#include <LCDG4LcioHelper.hh>
Collaboration diagram for LCDG4LcioHelper:

Public Types | |
| typedef std::map< int, IMPL::MCParticleImpl * > | TagToMCParticleMap |
| typedef std::map< IMPL::MCParticleImpl *, int > | MCParticleToTagMap |
Public Member Functions | |
| ~LCDG4LcioHelper () | |
| IO::LCWriter * | getWriter () const |
| void | openLcioFile (const std::string &filename) |
| void | beginRun (const G4Run *, const std::string &detname) |
| void | endRun () |
| void | writeEvent (const G4Event *) |
| void | reset () |
| void | saveCollection (const std::string &collName, IMPL::LCCollectionVec *coll) |
| IMPL::SimCalorimeterHitImpl * | getCalHitLcio (const LCDG4CalHit &hit) |
| IMPL::SimTrackerHitImpl * | getTrkHitLcio (const LCDG4TrackerHit &hit) |
| void | buildMCParticleColl (const std::vector< LCDMcPart * > &lcdMcpColl) |
| void | buildParentageLinks (const std::vector< LCDMcPart * > &lcdMcpColl) |
| IMPL::MCParticleImpl * | getMCParticleLcio (LCDMcPart &part) |
| void | prepareMCParticleCollection (IMPL::LCCollectionVec *newColl) |
| void | insertAllFamily (IMPL::LCCollectionVec *newColl, TagToMCParticleMap::iterator head) |
| void | dumpParticleLists (const std::vector< LCDMcPart * > &lcdMcpColl) const |
Static Public Member Functions | |
| LCDG4LcioHelper * | getInstance () |
Private Member Functions | |
| LCDG4LcioHelper () | |
Private Attributes | |
| IO::LCWriter * | _writer |
| TagToMCParticleMap * | _mcPartColl |
| MCParticleToTagMap | _mcp2tag |
| IMPL::LCRunHeaderImpl * | _runHdr |
| std::map< std::string, IMPL::LCCollectionVec * > | _savedColls |
Static Private Attributes | |
| LCDG4LcioHelper * | _me = new LCDG4LcioHelper() |
|
|
Definition at line 36 of file LCDG4LcioHelper.hh. |
|
|
Definition at line 35 of file LCDG4LcioHelper.hh. |
|
|
Definition at line 77 of file LCDG4LcioHelper.cc. References _mcPartColl, and _writer. Referenced by LCDG4LcioHelper().
00077 {
00078 if(_writer) {
00079 _writer->close();
00080 delete _writer;
00081 _writer = NULL;
00082 }
00083 if(_mcPartColl) {
00084 delete _mcPartColl;
00085 _mcPartColl = NULL;
00086 }
00087 }
|
|
|
Definition at line 62 of file LCDG4LcioHelper.cc. References _mcPartColl, _me, _writer, and ~LCDG4LcioHelper().
00063 : _writer(0), _mcPartColl(0) 00064 { 00065 if( _me==0 ) { 00066 cout << "*** LcioHelper constructor: _me="<< _me << endl; 00067 _writer = IOIMPL::LCFactory::getInstance()->createLCWriter(); 00068 _mcPartColl = new map<int, MCParticleImpl*>(); 00069 } 00070 else { 00071 // Inforce single instance 00072 this->~LCDG4LcioHelper(); 00073 } 00074 } |
|
||||||||||||
|
Referenced by LCDG4RunAction::BeginOfRunAction(). |
|
|
Referenced by LCDG4EventAction::EndOfEventAction(). |
|
|
|
|
|
|
|
|
Definition at line 418 of file LCDG4LcioHelper.cc. References _runHdr. Referenced by LCDG4RunAction::EndOfRunAction().
|
|
|
Definition at line 97 of file LCDG4LcioHelper.cc. References _mcPartColl, LCDG4CalHit::GetCellID(), LCDG4CalHit::GetEMC(), LCDG4CalHit::GetNMC(), LCDG4McPartManager::GetPointer(), LCDG4CalHit::GetPos(), LCDG4CalHit::GetTimeMC(), LCDG4CalHit::GetTrkID(), GeV, ns, and LCDG4McPartManager::trkidToMctag(). Referenced by LCDG4EventAction::EndOfEventAction().
00097 {
00098 SimCalorimeterHitImpl* outhit = new SimCalorimeterHitImpl();
00099 outhit->setCellID0( inhit.GetCellID() );
00100 outhit->setCellID1( 0 );
00101
00102 const Hep3Vector inpos = inhit.GetPos()/mm;
00103 float pos[3] = { inpos.x(), inpos.y(), inpos.z() };
00104 outhit->setPosition( pos );
00105
00106 // loop over energy contributions
00107 LCDG4McPartManager* mcmgr = LCDG4McPartManager::GetPointer();
00108 unsigned int nmc = inhit.GetNMC();
00109 for(unsigned int imc=0; imc<nmc; ++imc) {
00110 float energy = inhit.GetEMC(imc)/GeV;
00111 float time = inhit.GetTimeMC(imc)/ns;
00112 // link to contributing MCParticle
00113 int trkid = inhit.GetTrkID(imc);
00114 G4int mctag = mcmgr->trkidToMctag(trkid);
00115 if(mctag != -1) {
00116 MCParticleImpl* ppart = _mcPartColl->find(mctag)->second;
00117 outhit->addMCParticleContribution( ppart, energy, time,
00118 ppart->getPDG() );
00119 }
00120 else {
00121 cout << "LcioHelper: mctag==-1?" << endl;
00122 }
00123 }
00124 return outhit;
00125 }
|
|
|
Definition at line 57 of file LCDG4LcioHelper.cc. References _me. Referenced by LCDG4RunAction::BeginOfRunAction(), LCDG4RunAction::EndOfRunAction(), and LCDG4EventAction::SetupOutputLcio().
00057 {
00058 return _me;
00059 }
|
|
|
Definition at line 162 of file LCDG4LcioHelper.cc. References LCDMcPart::Get4Momentum(), LCDMcPart::GetCharge(), LCDMcPart::GetG4Status(), LCDMcPart::GetGenStatus(), LCDMcPart::GetParticleID(), LCDMcPart::GetParticleTag(), LCDMcPart::GetPosition(), LCDMcPart::GetTermPosition(), and GeV.
00162 {
00163 // create an MCParticleImpl
00164 MCParticleImpl* outpart = new MCParticleImpl();
00165
00166 // set PDGID
00167 outpart->setPDG( inpart.GetParticleID() );
00168
00169 // set simulation status
00170 int simstat = inpart.GetG4Status();
00171 switch(simstat) {
00172 case 0:
00173 cout<<"inpart: ALIVE, tag="<< inpart.GetParticleTag() << endl;
00174 // assert(false);
00175 break; // alive
00176 case 1: outpart->setDecayedInTracker(true); break; // decayed
00177 case 2: break; // interacted
00178 case 3: outpart->setHasLeftDetector(true); break; // left
00179 case 4: outpart->setStopped(true); break; // stopped
00180 case 5: assert(false); break; // looped
00181 case 6: assert(false); break; // lost
00182 case 7: assert(false); break; // stuck
00183 case 8: break; // documentation
00184 case 9: outpart->isDecayedInCalorimeter(); break; // showered
00185 case 10: assert(false); break; // maxsteps
00186 default: cout<< "Problem: simstat="<< simstat << endl;
00187 }
00188
00189 // set generator status
00190 outpart->setGeneratorStatus( inpart.GetGenStatus() );
00191 if( outpart->getGeneratorStatus()==4 ) { // generated in simulation
00192 outpart->setGeneratorStatus( 0 );
00193 outpart->setCreatedInSimulation(true);
00194 }
00195
00196 // set production vertex
00197 Hep3Vector pos = inpart.GetPosition()/mm;
00198 double daux[3] = { pos.x(), pos.y(), pos.z() };
00199 outpart->setVertex( daux );
00200
00201 // set end point
00202 pos = inpart.GetTermPosition()/mm;
00203 daux[0] = pos.x(); daux[1] = pos.y(); daux[2] = pos.z();
00204 outpart->setEndpoint( daux );
00205
00206 // set mass and momentum
00207 HepLorentzVector pmom = inpart.Get4Momentum()/GeV;
00208 float faux[3] = { pmom.px(), pmom.py(), pmom.pz() };
00209 outpart->setMomentum( faux );
00210 outpart->setMass( pmom.mag() );
00211 outpart->setCharge( inpart.GetCharge() );
00212
00213 // Note: parentage info still not setup at this point
00214 return outpart;
00215 }
|
|
|
Definition at line 129 of file LCDG4LcioHelper.cc. References _mcPartColl, LCDG4TrackerHit::GetBarEnd(), LCDG4TrackerHit::GetEdep(), LCDG4TrackerHit::GetLayer(), LCDG4TrackerHit::GetNorthSouth(), LCDG4McPartManager::GetPointer(), LCDG4TrackerHit::GetPos(), LCDG4TrackerHit::GetSystem(), LCDG4TrackerHit::GetTdep(), LCDG4TrackerHit::GetTrackID(), GeV, ns, and LCDG4McPartManager::trkidToMctag(). Referenced by LCDG4EventAction::EndOfEventAction().
00129 {
00130
00131 // pack hit info into tag
00132 unsigned int tag = inhit.GetLayer();
00133 tag |= (inhit.GetSystem() << 28);
00134 tag |= (inhit.GetNorthSouth() << 30);
00135 tag |= (inhit.GetBarEnd() << 31);
00136
00137 SimTrackerHitImpl* outhit = new SimTrackerHitImpl();
00138 outhit->setCellID( tag );
00139 outhit->setdEdx( inhit.GetEdep()/GeV );
00140 outhit->setTime( inhit.GetTdep()/ns );
00141
00142 const Hep3Vector inpos = inhit.GetPos()/mm;
00143 double pos[3] = { inpos.x(), inpos.y(), inpos.z() };
00144 // pos[0] = inhit.GetPos().x()/mm;
00145 // pos[1] = inhit.GetPos().y()/mm;
00146 // pos[2] = inhit.GetPos().z()/mm;
00147 outhit->setPosition( pos );
00148
00149 // link to particle which produced hit
00150 int trkid = inhit.GetTrackID();
00151
00152 G4int mctag = LCDG4McPartManager::GetPointer()->trkidToMctag(trkid);
00153 assert(mctag>=0);
00154 // if(mctag != -1) {
00155 MCParticleImpl* ppart = _mcPartColl->find(mctag)->second;
00156 outhit->setMCParticle( ppart );
00157 // }
00158 return outhit;
00159 }
|
|
|
Definition at line 44 of file LCDG4LcioHelper.hh. References _writer.
00044 { return _writer; }
|
|
||||||||||||
|
|
|
|
Referenced by LCDG4EventAction::SetupOutputLcio(). |
|
|
|
|
|
Definition at line 425 of file LCDG4LcioHelper.cc. References _mcp2tag, _mcPartColl, and _savedColls. Referenced by writeEvent().
00425 {
00426 _mcPartColl->clear();
00427 _savedColls.clear();
00428 _mcp2tag.clear();
00429 }
|
|
||||||||||||
|
Referenced by LCDG4EventAction::EndOfEventAction(). |
|
|
Definition at line 343 of file LCDG4LcioHelper.cc. References _mcPartColl, _runHdr, _savedColls, _writer, and reset(). Referenced by LCDG4EventAction::EndOfEventAction().
00343 {
00344
00345 // we need to use the implementation classes here
00346 LCEventImpl* lcevt = new LCEventImpl();
00347 lcevt->setEventNumber( g4evt->GetEventID() );
00348 lcevt->setRunNumber( _runHdr->getRunNumber() );
00349 lcevt->setDetectorName( _runHdr->getDetectorName() );
00350
00351 //***** MCParticle collection
00352
00353 // Create collection for writing into LCIO file
00354 LCCollectionVec* mcVec = new LCCollectionVec( LCIO::MCPARTICLE );
00355 TagToMCParticleMap::const_iterator ipart;
00356
00357 // Setup LCCollectionVec for MCParticle table
00358 // prepareMCParticleCollection(mcVec);
00359 for( ipart = _mcPartColl->begin();
00360 ipart != _mcPartColl->end(); ++ipart ) {
00361 mcVec->push_back( ipart->second );
00362 }
00363
00364 // Save particles into LCIO event
00365 lcevt->addCollection(mcVec,"MCParticle");
00366
00367 // other collections to be saved
00368 map<string,LCCollectionVec*>::const_iterator icoll;
00369 for( icoll=_savedColls.begin();
00370 icoll!=_savedColls.end();
00371 ++icoll ) {
00372 lcevt->addCollection( icoll->second, icoll->first);
00373 }
00374
00375 // write the event to the file
00376 _writer->writeEvent( lcevt );
00377
00378 // // dump the event to the screen
00379 // G4cout<< "Dumping LCIO event:"<< G4endl;
00380 // LCTOOLS::dumpEvent( lcevt );
00381
00382 // ------------ IMPORTANT ------------- !
00383 // we created the event so we need to delete it ...
00384 // the LCEvent destructor takes care of deleting all the hits and particles
00385 delete lcevt;
00386 reset();
00387 }
|
|
|
Definition at line 78 of file LCDG4LcioHelper.hh. Referenced by reset(). |
|
|
Definition at line 77 of file LCDG4LcioHelper.hh. Referenced by getCalHitLcio(), getTrkHitLcio(), LCDG4LcioHelper(), reset(), writeEvent(), and ~LCDG4LcioHelper(). |
|
|
Definition at line 54 of file LCDG4LcioHelper.cc. Referenced by getInstance(), and LCDG4LcioHelper(). |
|
|
Definition at line 79 of file LCDG4LcioHelper.hh. Referenced by endRun(), and writeEvent(). |
|
|
Definition at line 80 of file LCDG4LcioHelper.hh. Referenced by reset(), and writeEvent(). |
|
|
Definition at line 76 of file LCDG4LcioHelper.hh. Referenced by getWriter(), LCDG4LcioHelper(), writeEvent(), and ~LCDG4LcioHelper(). |
1.3.4