slic/src
diff -u -r1.28 -r1.29
--- StdHepToLcioConvertor.cc 19 Oct 2005 22:51:18 -0000 1.28
+++ StdHepToLcioConvertor.cc 29 Nov 2005 00:23:16 -0000 1.29
@@ -1,4 +1,4 @@
-// $Header: /cvs/lcd/slic/src/StdHepToLcioConvertor.cc,v 1.28 2005/10/19 22:51:18 jeremy Exp $
+// $Header: /cvs/lcd/slic/src/StdHepToLcioConvertor.cc,v 1.29 2005/11/29 00:23:16 jeremy Exp $
#include "StdHepToLcioConvertor.hh"
// slic
@@ -43,7 +43,6 @@
StdHepToLcioConvertor::~StdHepToLcioConvertor()
{}
- // set the current mcp collection to an empty one
void StdHepToLcioConvertor::setCurrentMcpCollection(EVENT::LCCollection* mcpColl)
{
m_currentMcpColl = mcpColl;
@@ -54,12 +53,11 @@
return m_currentMcpColl;
}
- // fill the current Mcp coll using the current StdHep record
void StdHepToLcioConvertor::fillCurrentMcpCollectionFromStdHep()
{
#ifdef SLIC_VERBOSE
if ( verbose() > 0 ) {
- cout << std::endl << "createMcpCollectionFromStdHep()" << endl;
+ cout << std::endl << "********** Creating LCIO MCParticle Collection from StdHep **********" << endl << endl;
}
#endif
@@ -68,7 +66,7 @@
#ifdef SLIC_VERBOSE
if ( verbose() > 0 ) {
- cout << "first loop..." << endl;
+ cout << "******** loop 1: create MCParticles ********" << endl << endl;
}
#endif
@@ -78,13 +76,31 @@
ihep < ntracks;
ihep++ ) {
+#ifdef SLIC_VERBOSE
+ if ( verbose() > 0 ) {
+ printTrack( ihep );
+ }
+#endif
+
+#ifdef SLIC_VERBOSE
+ if ( verbose() > 1 ) {
+ checkParentage( ihep );
+ }
+#endif
+
// create MCP and add to coll
- createMcpFromStdHep( ihep, m_reader, m_currentMcpColl );
+ createMcpFromStdHep( ihep );
+
+#ifdef SLIC_VERBOSE
+ if ( verbose() > 0 ) {
+ cout << endl << "--" << endl << endl;
+ }
+#endif
}
#ifdef SLIC_VERBOSE
if ( verbose() > 0 ) {
- cout << "dau loop..." << endl;
+ cout << "******** loop 2: parent setup ********" << endl << endl;
}
#endif
@@ -93,29 +109,62 @@
ihep < ntracks;
ihep++ ) {
+#ifdef SLIC_VERBOSE
+ if ( verbose() > 0 ) {
+ printIndex( ihep );
+ printMothers( ihep );
+ }
+#endif
+
MCParticleImpl* mcp =
dynamic_cast<MCParticleImpl*> ( m_currentMcpColl->getElementAt(ihep) );
if ( mcp ) {
- setupParents( ihep, mcp, m_reader, m_currentMcpColl );
+ setupParents( ihep, mcp );
+ }
+
+#ifdef SLIC_VERBOSE
+ if ( verbose() > 0 ) {
+ cout << endl << "--" << endl << endl;
}
+#endif
+
+ }
+
+#ifdef SLIC_VERBOSE
+ if ( verbose() > 0 ) {
+ cout << "******** loop 3: daughter setup ********" << endl << endl;
}
+#endif
/* Loop #3 : Setup the daughters. */
for ( int ihep = 0;
ihep < ntracks;
ihep++ ) {
+#ifdef SLIC_VERBOSE
+ if ( verbose() > 0 ) {
+ printIndex( ihep );
+ printDaughters( ihep );
+ }
+#endif
+
MCParticleImpl* mcp =
dynamic_cast<MCParticleImpl*> ( m_currentMcpColl->getElementAt(ihep) );
if ( mcp ) {
- setupDaughters( ihep, mcp, m_reader, m_currentMcpColl);
+ setupDaughters( ihep, mcp );
}
else {
- cerr << "Null mcp; ihep <" << ihep << "> is not a valid index!" << endl;
- break;
+ cerr << "mcp is null; ihep <" << ihep << "> does not appear to be a valid idx!" << endl;
}
+
+#ifdef SLIC_VERBOSE
+ if ( verbose() > 0 ) {
+ cout << endl << "--" << endl << endl;
+ }
+#endif
+
}
#ifdef SLIC_VERBOSE
@@ -125,30 +174,13 @@
#endif
}
- /*
- * Create an MCParticle from a single StdHep particle record.
- * NOTE: Does not setup parentage or daughters.
- */
- IMPL::MCParticleImpl* StdHepToLcioConvertor::createMcpFromStdHep( int ihep, lStdHep* rdr, EVENT::LCCollection* mcpColl )
+ IMPL::MCParticleImpl* StdHepToLcioConvertor::createMcpFromStdHep( int ihep )
{
- assert(mcpColl);
-
-#ifdef SLIC_VERBOSE
- if ( verbose() > 1 ) {
- cout << "ihep <" << ihep << ">" << endl;
- }
-#endif
-
- // setup mcpColl if null
- if ( mcpColl == 0 ) {
- mcpColl = m_currentMcpColl;
- }
-
// new MCP
MCParticleImpl* mcp = new MCParticleImpl();
// PDG
- int pdgid = rdr->pid( ihep );
+ int pdgid = m_reader->pid( ihep );
mcp->setPDG(pdgid);
G4ParticleDefinition* pdef = G4ParticleTable::GetParticleTable()->FindParticle(pdgid);
@@ -179,326 +211,378 @@
}
// momentum vec
- float p[3] = { rdr->Px( ihep ),
- rdr->Py( ihep ),
- rdr->Pz( ihep ) };
+ float p[3] = { m_reader->Px( ihep ),
+ m_reader->Py( ihep ),
+ m_reader->Pz( ihep ) };
mcp->setMomentum( p );
// mass
- mcp->setMass( rdr->M( ihep ) );
+ mcp->setMass( m_reader->M( ihep ) );
// vertex
- double vtx[3] = { rdr->X( ihep ),
- rdr->Y( ihep ),
- rdr->Z( ihep ) };
+ double vtx[3] = { m_reader->X( ihep ),
+ m_reader->Y( ihep ),
+ m_reader->Z( ihep ) };
mcp->setVertex( vtx );
// generator status
- mcp->setGeneratorStatus( rdr->status( ihep ) );
+ mcp->setGeneratorStatus( m_reader->status( ihep ) );
// sim status = none
mcp->setSimulatorStatus( 0 );
-#ifdef SLIC_VERBOSE
- if ( verbose() > 1 ) {
- cout << "decay time <" << rdr->T( ihep ) / c_light << ">" << endl;
- }
-#endif
-
// creation time
- mcp->setTime( rdr->T( ihep ) / c_light );
+ mcp->setTime( m_reader->T( ihep ) / c_light );
// add to mcpColl
- mcpColl->addElement( mcp );
-
-#ifdef SLIC_VERBOSE
- if ( verbose() > 1 ) {
- cout << "done with ihep <" << ihep << ">" << endl;
- }
-#endif
+ m_currentMcpColl->addElement( mcp );
return mcp;
}
// util functions
- void StdHepToLcioConvertor::setupParents( int ihep, IMPL::MCParticleImpl* mcp, lStdHep* rdr, EVENT::LCCollection* mcpColl)
+ void StdHepToLcioConvertor::setupParents( int ihep, IMPL::MCParticleImpl* mcp )
{
#ifdef SLIC_VERBOSE
- if ( verbose() > 3 ) {
- std::cerr << "StdHepToLcioConverter::setupParents" << std::endl;
+ if ( verbose() > 2 ) {
+ std::cerr << "setupParents" << std::endl;
}
#endif
- // setup rdr ptr
- if ( rdr == 0 ) {
- rdr = m_reader;
- }
+ // get parent indices
+ int mom1_idx = m_reader->mother1( ihep ) - 1;
+ int mom2_idx = m_reader->mother2( ihep ) - 1;
- // setup mcpColl ptr
- if ( mcpColl == 0 ) {
- mcpColl = m_currentMcpColl;
- }
+ std::vector<int> parVec;
+ makeIndexVec( mom1_idx, mom2_idx, parVec );
- // get parent indices
- int mom1_idx = rdr->mother1( ihep ) - 1;
- int mom2_idx = rdr->mother2( ihep ) - 1;
+ if ( parVec.size() > 0 ) {
+ for ( std::vector<int>::iterator it = parVec.begin();
+ it != parVec.end();
+ it++ ) {
+ if ( *it != ihep ) {
+ addMcpParent( *it, mcp );
+ }
+ else {
+ cerr << "WARNING: Ignoring parent pointing to self!" << endl;
+ }
+ }
+ }
+#ifdef SLIC_VERBOSE
+ else {
+ if ( verbose() > 0 ) {
+ cout << "particle has no parents" << endl;
+ }
+ }
+#endif
+ }
+ void StdHepToLcioConvertor::setupDaughters( int ihep, IMPL::MCParticleImpl* mcp )
+ {
#ifdef SLIC_VERBOSE
- if ( verbose() > 1 ) {
- cout << "mom1_idx <" << mom1_idx << ">" << endl;
- cout << "mom2_idx <" << mom2_idx << ">" << endl;
+ if ( verbose() > 2 ) {
+ cout << "setupDaughters" << endl;
}
#endif
- if ( mom1_idx > -1 && mom2_idx > -1 ) {
+ // get dau indices
+ int dau1_idx = m_reader->daughter1( ihep ) % 10000 - 1;
+ int dau2_idx = m_reader->daughter2( ihep ) % 10000 - 1;
- // range of mothers
- if ( mom1_idx >= mom2_idx ) {
+ std::vector<int> dauVec;
+ dauVec = makeIndexVec( dau1_idx, dau2_idx, dauVec );
-#ifdef SLIC_VERBOSE
- if ( verbose() > 1 ) {
- cout << "mom range" << endl;
+ if ( dauVec.size() > 0 ) {
+ for ( std::vector<int>::iterator it = dauVec.begin();
+ it != dauVec.end();
+ it++ ) {
+ if ( *it != ihep ) {
+ addMcpDaughter( *it, mcp );
}
+ else {
+ cerr << "WARNING: Ignoring daughter pointing to self!" << endl;
+ }
+ }
+ }
+#ifdef SLIC_VERBOSE
+ else {
+ if ( verbose() > 0 ) {
+ cout << "particle has no daughters" << endl;
+ }
+ }
#endif
+ }
- for ( int i = mom1_idx;
- i < mom2_idx + 1;
- i++ ) {
- addMcpParent( i, mcp, mcpColl );
+ bool StdHepToLcioConvertor::hasParent( IMPL::MCParticleImpl* dauMcp, IMPL::MCParticleImpl* parMcp)
+ {
+ bool isPar = false;
+ if ( dauMcp && parMcp ) {
+ int numParents = dauMcp->getParents().size();
+
+ MCParticleImpl* pMomMcp;
+
+ // find if already lists as parent
+ for ( int i = 0;
+ i < numParents;
+ i++ ) {
+
+ pMomMcp = static_cast<MCParticleImpl*>
+ ( dauMcp->getParents()[i] );
+
+ if ( pMomMcp == parMcp ) {
+ isPar = true;
+ break;
}
}
- // 2 discreet mothers: mom1 & mom2
- else {
+ }
+
+ return isPar;
+ }
+
+ void StdHepToLcioConvertor::addMcpDaughter( int dauIdx, IMPL::MCParticleImpl* parMcp )
+ {
+ if ( dauIdx > -1 ) {
+
+ MCParticleImpl* dauMcp = static_cast<MCParticleImpl*>
+ ( m_currentMcpColl->getElementAt( dauIdx ) );
+ assert( dauMcp );
+
+ if ( dauMcp ) {
+ if ( !hasParent( dauMcp, parMcp ) ) {
+ dauMcp->addParent( parMcp );
#ifdef SLIC_VERBOSE
- if ( verbose() > 1 ) {
- cout << "mom discreet" << endl;
+ if ( verbose() > 1 ) {
+ cout << "added daughter <" << dauIdx << ">" << endl;
+ }
+#endif
+ }
+#ifdef SLIC_VERBOSE
+ else {
+ if ( verbose() > 1 ) {
+ cout << "daughter <" << dauIdx << "> already has this parent" << endl;
+ }
}
#endif
-
- // mom1
- addMcpParent( mom1_idx, mcp, mcpColl );
-
- // mom2
- addMcpParent( mom2_idx, mcp, mcpColl );
+ }
+ else {
+ cerr << "WARNING: dauMcp or parMcp is null!" << endl;
}
}
- // mom1 only
- else if ( mom1_idx > -1 ) {
+ }
+ void StdHepToLcioConvertor::addMcpParent( int parIdx, IMPL::MCParticleImpl* mcp )
+ {
#ifdef SLIC_VERBOSE
- if ( verbose() > 1 ) {
- cout << "mom1" << endl;
- }
+ if ( verbose() > 3 ) {
+ std::cout << "addMcpParent" << std::endl;
+ }
#endif
- addMcpParent( mom1_idx, mcp, mcpColl );
- }
- // mom2 only
- else if ( mom2_idx > -1 ) {
+ if ( parIdx > -1 ) {
-#ifdef SLIC_VERBOSE
- if ( verbose() > 1 ) {
- cout << "mom2" << endl;
+ /* If index is > size of collection, the particle's parent doesn't exist yet. We need to die! */
+ if ( parIdx > m_currentMcpColl->getNumberOfElements() ) {
+ std::cerr << "StdHepToLcioConverter::addMcpParent - Parent index is out of range <" << parIdx << ">" << std::endl;
+ G4Exception("ERROR: StdHep index (ihep) is out of range.");
}
-#endif
- addMcpParent( mom2_idx, mcp, mcpColl );
+ MCParticleImpl* parMcp = static_cast<MCParticleImpl*>
+ ( m_currentMcpColl->getElementAt( parIdx ) );
+
+ if ( parMcp ) {
+ if ( !hasParent(mcp, parMcp) ) {
+ mcp->addParent( parMcp );
+
+#ifdef SLIC_VERBOSE
+ if ( verbose() > 1 ) {
+ cout << "added parent <" << parIdx << ">" << endl;
+ }
+#endif
+ }
+#ifdef SLIC_VERBOSE
+ else {
+ if ( verbose() > 0 ) {
+ cout << "daughter already has parent <" << parIdx << ">" << std::endl;
+ }
+ }
+#endif
+ }
+ else {
+ G4Exception("Failed to get parent particle from MCParticle collection.");
+ }
}
#ifdef SLIC_VERBOSE
else {
- // could be okay?
- if ( verbose() > 0 ) {
- cerr << "WARNING: ihep <" << ihep << "> has NO PARENTS." << endl;
+ if ( verbose() > 2 ) {
+ std::cout << "ignoring parIdx = -1 " << std::endl;
}
}
#endif
}
- void StdHepToLcioConvertor::setupDaughters( int ihep, IMPL::MCParticleImpl* mcp, lStdHep* rdr, EVENT::LCCollection* mcpColl)
+ std::vector<int> StdHepToLcioConvertor::makeIndexVec( int idx1, int idx2, std::vector<int>& vec )
{
#ifdef SLIC_VERBOSE
- if ( verbose() > 0 ) {
- cout << "setting up daughters..." << endl;
+ if ( verbose() > 2 ) {
+ std::cout << "idx1 <" << idx1 << ">" << endl;
+ std::cout << "idx2 <" << idx2 << ">" << endl;
}
#endif
- // setup rdr ptr
- if ( rdr == 0 ) {
- rdr = m_reader;
- }
-
- // setup mcpColl ptr
- if ( mcpColl == 0 ) {
- mcpColl = m_currentMcpColl;
- }
+ if ( idx1 != -1 && idx2 != -1 ) {
- // get dau indices
- int dau1_idx = rdr->daughter1( ihep ) % 10000 - 1;
- int dau2_idx = rdr->daughter2( ihep ) % 10000 - 1;
+ if ( idx1 < idx2 ) {
#ifdef SLIC_VERBOSE
- if ( verbose() > 1 ) {
- cout << "dau1_idx <" << dau1_idx << ">" << endl;
- cout << "dau2_idx <" << dau2_idx << ">" << endl;
- }
+ if ( verbose() > 1 ) {
+ cout << "range: idx1 to idx2" << endl;
+ }
#endif
- // range
- if ( dau1_idx > -1 and dau2_idx > -1 ) {
- if ( dau1_idx >= dau2_idx ) {
+ for ( int i = idx1;
+ i < (idx2 + 1);
+ i++ ) {
+ vec.push_back(i);
+ }
+ }
+ else if ( idx1 > idx2 ) {
#ifdef SLIC_VERBOSE
if ( verbose() > 1 ) {
- cout << "dau range" << endl;
+ cout << "discrete: idx1 and idx2" << endl;
}
#endif
- for ( int i = dau1_idx;
- i < dau2_idx + 1;
- i++ ) {
- addMcpDaughter( i, mcp, mcpColl );
- }
-
+ vec.push_back(idx1);
+ vec.push_back(idx2);
}
- // discreet case: dau1 & dau2
+ // indices are equal
else {
#ifdef SLIC_VERBOSE
if ( verbose() > 1 ) {
- cout << "dau discreet" << endl;
+ cout << "single: idx1 == idx2" << endl;
}
#endif
- // dau1
- addMcpDaughter( dau1_idx, mcp, mcpColl );
-
- // dau2
- addMcpDaughter( dau2_idx, mcp, mcpColl );
+ vec.push_back(idx1);
}
}
- // dau1 only
- else if ( dau1_idx > -1 ) {
+ else if ( idx1 != -1 ) {
#ifdef SLIC_VERBOSE
if ( verbose() > 1 ) {
- cout << "dau1" << endl;
+ cout << "single: idx1 only" << endl;
}
#endif
- addMcpDaughter( dau1_idx, mcp, mcpColl );
+ vec.push_back(idx1);
}
-
- // dau2 only
- else if ( dau2_idx > -1 ) {
+ else if ( idx2 != -1 ) {
#ifdef SLIC_VERBOSE
if ( verbose() > 1 ) {
- cout << "dau2" << endl;
+ cout << "single: idx2 only" << endl;
}
#endif
- addMcpDaughter( dau2_idx, mcp, mcpColl );
+ vec.push_back(idx2);
}
-#ifdef SLIC_VERBOSE
- else {
- if ( verbose() > 1 ) {
- cerr << "WARNING: ihep <" << ihep << "> has NO DAUGHTERS." << endl;
- }
- }
-#endif
+
+ return vec;
}
- bool StdHepToLcioConvertor::hasParent( IMPL::MCParticleImpl* dauMcp, IMPL::MCParticleImpl* parMcp)
+ void StdHepToLcioConvertor::printIndex( int ihep )
{
- bool bIsPar = false;
- if ( dauMcp && parMcp ) {
- int numParents = dauMcp->getParents().size();
+ cout << "ihep <" << ihep << ">" << endl;
+ }
- MCParticleImpl* pMomMcp;
+ void StdHepToLcioConvertor::printMothers( int ihep )
+ {
+ cout << "mom1 <" << m_reader->mother1(ihep) - 1 << ">" << endl;
+ cout << "mom2 <" << m_reader->mother2(ihep) - 1 << ">" << endl;
+ }
- // find if already lists as parent
- for ( int i = 0;
- i < numParents;
- i++ ) {
+ void StdHepToLcioConvertor::printDaughters( int ihep )
+ {
+ cout << "dau1 <" << m_reader->daughter1(ihep) - 1 << ">" << endl;
+ cout << "dau2 <" << m_reader->daughter2(ihep) - 1 << ">" << endl;
+ }
- pMomMcp = static_cast<MCParticleImpl*>
- ( dauMcp->getParents()[i] );
+ void StdHepToLcioConvertor::printTrack( int ihep )
+ {
+ printIndex( ihep );
- if ( pMomMcp == parMcp ) {
- bIsPar = true;
- break;
- }
- }
- }
+ cout << "pid <" << m_reader->pid( ihep ) << ">" << endl;
+ cout << "M = " << m_reader->M( ihep ) << endl;
+ cout << "T = " << m_reader->T( ihep ) << endl;
+ cout << "status <" << m_reader->status( ihep ) << ">" << endl;
+
+ printMothers(ihep);
+ printDaughters(ihep);
+
+ cout << "P = ("
+ << m_reader->Px( ihep ) << ", "
+ << m_reader->Py( ihep ) << ", "
+ << m_reader->Pz( ihep) << ")"
+ << endl;
+
+ cout << "Vtx = ("
+ << m_reader->X( ihep ) << ", "
+ << m_reader->Y( ihep ) << ", "
+ << m_reader->Z( ihep ) << ")"
+ << endl;
- return bIsPar;
+ cout << endl;
}
- void StdHepToLcioConvertor::addMcpDaughter( int dauIdx, IMPL::MCParticleImpl* parMcp, EVENT::LCCollection* mcpColl)
+ void StdHepToLcioConvertor::checkParentage(int ihep )
{
- assert( parMcp );
- assert( mcpColl );
-
- if ( dauIdx > -1 ) {
+ int mom1 = m_reader->mother1(ihep) - 1;
+ int mom2 = m_reader->mother2(ihep) - 1;
+ int dau1 = m_reader->daughter1(ihep) - 1;
+ int dau2 = m_reader->daughter2(ihep) -1;
- MCParticleImpl* pDauMcp = 0;
- pDauMcp = static_cast<MCParticleImpl*>
- ( mcpColl->getElementAt( dauIdx ) );
- assert( pDauMcp );
-
- if ( pDauMcp ) {
- if ( !hasParent( pDauMcp, parMcp ) ) {
- pDauMcp->addParent( parMcp );
- }
- }
- else {
- cerr << "WARNING: pDauMcp or parMcp is null!" << endl;
- }
+ // dau1 < ihep
+ if ( dau1 != -1 && dau1 < ihep ) {
+ cout << "WARNING: dau1 < ihep" << endl;
}
- }
- void StdHepToLcioConvertor::addMcpParent( int parIdx, IMPL::MCParticleImpl* mcp, EVENT::LCCollection* mcpColl)
- {
-#ifdef SLIC_VERBOSE
- if ( verbose() > 3 ) {
- std::cout << "StdHepToLcioConverter::addMcpParent" << std::endl;
- std::cout << "mcp: " << mcp << std::endl;
+ // dau2 < ihep
+ if ( dau2 != -1 && dau2 < ihep ) {
+ cout << "WARNING: dau2 < ihep" << endl;
}
-#endif
- assert( mcpColl );
- assert( mcp );
- if ( parIdx > -1 ) {
+ // mom1 > ihep
+ if ( mom1 != -1 && mom1 > ihep ) {
+ cout << "WARNING: mom1 > ihep" << endl;
+ }
- /* If index is > size of collection, the particle's parent doesn't exist yet. We need to die! */
- if ( parIdx > mcpColl->getNumberOfElements() ) {
- std::cerr << "StdHepToLcioConverter::addMcpParent - Parent index is out of range <" << parIdx << ">" << std::endl;
- G4Exception("ERROR: StdHep index (ihep) is out of range.");
- }
+ // mom2 > ihep
+ if ( mom2 != -1 && mom2 > ihep ) {
+ cout << "WARNING: mom2 > ihep" << endl;
+ }
- MCParticleImpl* pParMcp = static_cast<MCParticleImpl*>
- ( mcpColl->getElementAt( parIdx ) );
+ // first particle in list has parents
+ if ( ihep == 0 && ( mom1 != -1 || mom2 != -1 ) ) {
+ cout << "WARNING: ihep == 0 has parents" << endl;
+ }
-#ifdef SLIC_VERBOSE
- if ( verbose() > 2 ) {
- std::cout << "pParMcp: " << pParMcp << std::endl;
- }
-#endif
+ // particle past first 2 with no mother
+ if ( ihep > 1 && ( mom1 == -1 && mom2 == -1 ) ) {
+ cout << "WARNING: ihep > 1 with no mother" << endl;
+ }
- if ( pParMcp ) {
- mcp->addParent( pParMcp );
- }
- else {
- G4Exception("Failed to get parent particle from MCParticle collection.");
- }
+ // mother points to self
+ if ( ihep == mom1 || ihep == mom2 ) {
+ cout << "WARNING: mom1 or mom2 == ihep" << endl;
}
-#ifdef SLIC_VERBOSE
- else {
- if ( verbose() > 2 ) {
- std::cout << "ignoring parIdx = -1 " << std::endl;
- }
+
+ // daughter points to self
+ if ( ihep == dau1 || ihep == dau2 ) {
+ cout << "WARNING: dau1 or dau2 == ihep" << endl;
}
-#endif
}
-}
+
+} // namespace slic
slic/include
diff -u -r1.16 -r1.17
--- StdHepToLcioConvertor.hh 19 Oct 2005 22:51:10 -0000 1.16
+++ StdHepToLcioConvertor.hh 29 Nov 2005 00:23:16 -0000 1.17
@@ -1,6 +1,6 @@
-// $Header: /cvs/lcd/slic/include/StdHepToLcioConvertor.hh,v 1.16 2005/10/19 22:51:10 jeremy Exp $
+// $Header: /cvs/lcd/slic/include/StdHepToLcioConvertor.hh,v 1.17 2005/11/29 00:23:16 jeremy Exp $
#ifndef slic_StdHepToLcioConvertor_hh
-#define slic_StdHepToLcioConvertor_hh
+#define slic_StdHepToLcioConvertor_hh 1
// lcdd
#include "Verbose.hh"
@@ -13,14 +13,34 @@
#include "EVENT/LCCollection.h"
// std
+#include <vector>
#include <cassert>
namespace slic
{
/**
- @class StdHepToLcioConvertor
- @brief Converts an input StdHep event to Lcio MCParticle collection.
+ * @class StdHepToLcioConvertor
+ * @brief Converts an input StdHep event to an LCIO MCParticle collection.
+ */
+
+ /**
+ @verbatim
+
+ The index "pointers" daughter1, daughter2, mother1 and mother2 are handled as follows,
+ where idx1 is daughter1/mother1, and idx2 is daughter2/mother2.
+
+ idx1 cmp idx2 action
+ _______________________
+
+ -1 -1 do nothing
+ # -1 use idx1
+ -1 # use idx2
+ # == # use idx1
+ # < # range = idx1 to idx2
+ # > # use idx1 and idx2 as discrete indices
+
+ @endverbatim
*/
class StdHepToLcioConvertor : public Verbose
{
@@ -32,34 +52,84 @@
public:
+ /**
+ * Set the lStdHep reader to be used by the convertor.
+ */
void setStdHepReader(lStdHep* rdr)
{
assert( rdr );
m_reader = rdr;
}
- // create the next MCP collection using current event
- // ***depends on prior, external read operation for next event***
+ /**
+ * Create the next MCP collection using current event
+ * NOTE: This function depends upon an external read operation for the next event.
+ */
void fillCurrentMcpCollectionFromStdHep();
- // set the current mcp collection to an empty one
+ /**
+ * Reset the current MCParticle collection.
+ */
void setCurrentMcpCollection(EVENT::LCCollection* mcpColl);
+ /**
+ * Get the current MCParticle collection.
+ */
EVENT::LCCollection* getCurrentMcpCollection();
- // create based on args
- IMPL::MCParticleImpl* createMcpFromStdHep( int ihep, lStdHep* rdr = 0, EVENT::LCCollection* mcpColl = 0 );
-
- // util functions
- void setupParents( int ihep, IMPL::MCParticleImpl*, lStdHep* rdr=0, EVENT::LCCollection* mcpColl=0);
- void setupDaughters( int ihep, IMPL::MCParticleImpl*, lStdHep* rdr=0, EVENT::LCCollection* mcpColl=0);
+ /**
+ * Create a single MCParticle from a StdHep track.
+ * NOTE: Does not setup mother or daughter links.
+ */
+ IMPL::MCParticleImpl* createMcpFromStdHep( int ihep );
+
+ /**
+ * Setup the parent pointers of this track.
+ */
+ void setupParents( int ihep, IMPL::MCParticleImpl* );
+
+ /**
+ * Setup the input MCParticle as a parent of this track.
+ */
+ void addMcpParent( int parIdx, IMPL::MCParticleImpl* parMcp );
+
+ /**
+ * Setup the daughter pointers of this track.
+ */
+ void setupDaughters( int ihep, IMPL::MCParticleImpl* );
+
+ /**
+ * Setup the input MCParticle as a parent of this track.
+ */
+ void addMcpDaughter( int dauIdx, IMPL::MCParticleImpl* parMcp );
+
+ /**
+ * Check if an MCParticle has another particle as its parent.
+ */
bool hasParent( IMPL::MCParticleImpl* dauMcp, IMPL::MCParticleImpl* parMcp);
- void addMcpDaughter( int dauIdx, IMPL::MCParticleImpl* parMcp, EVENT::LCCollection* );
- void addMcpParent( int parIdx, IMPL::MCParticleImpl* parMcp, EVENT::LCCollection* );
+
+ /**
+ * Given two ihep indices, return a vector of all the included indices (discrete, range, etc.).
+ */
+ std::vector<int> makeIndexVec( int idx1, int idx2, std::vector<int>& vec );
+
+ /**
+ * Perform various sanity checks on the track's mother and daughter index values.
+ */
+ void checkParentage( int ihep );
+
+ /* Print utilities. */
+ void printIndex( int ihep );
+ void printMothers( int ihep );
+ void printDaughters( int ihep );
+ void printTrack( int ihep );
private:
+ /* Pointer to the current MCParticle collection that is being filled. */
EVENT::LCCollection* m_currentMcpColl;
+
+ /* Pointer to the lStdHep reader being used as a data source. */
lStdHep* m_reader;
};
}