diff --git a/DDG4/examples/CLICSidSimu.py b/DDG4/examples/CLICSidSimu.py index 3e8ef6111d24a1ad4afe6873d96ead5542e66ca8..425fffb96ad83894d41f922761b1eec3cb7b6352 100644 --- a/DDG4/examples/CLICSidSimu.py +++ b/DDG4/examples/CLICSidSimu.py @@ -44,10 +44,10 @@ def run(): kernel.eventAction().adopt(prt) # Configure I/O - evt_root = simple.setupROOTOutput('RootOutput','CLICSiD_'+time.strftime('%Y-%m-%d_%H-%M')) evt_lcio = simple.setupLCIOOutput('LcioOutput','CLICSiD_'+time.strftime('%Y-%m-%d_%H-%M')) evt_lcio.OutputLevel = Output.ERROR + evt_root = simple.setupROOTOutput('RootOutput','CLICSiD_'+time.strftime('%Y-%m-%d_%H-%M')) generator_output_level = Output.INFO @@ -110,7 +110,8 @@ def run(): #gen.Input = "LCIOStdHepReader|/home/frankm/SW/data/smuonLR_PointK_3TeV_BS_noBkg_run0001.stdhep" #gen.Input = "LCIOStdHepReader|/home/frankm/SW/data/bbbb_3TeV.stdhep" #gen.Input = "LCIOFileReader|/home/frankm/SW/data/mcparticles_pi-_5GeV.slcio" - gen.Input = "LCIOFileReader|/home/frankm/SW/data/bbbb_3TeV.slcio" + gen.Input = "LCIOFileReader|/home/frankm/SW/data/mcparticles_mu-_5GeV.slcio" + #gen.Input = "LCIOFileReader|/home/frankm/SW/data/bbbb_3TeV.slcio" #gen.Input = "LCIOStdHepReader|/home/frankm/SW/data/FCC-eh.stdhep" #gen.Input = "Geant4EventReaderHepMC|/home/frankm/SW/data/data.hepmc.txt" gen.OutputLevel = 4 # generator_output_level diff --git a/DDG4/include/DDG4/Geant4Particle.h b/DDG4/include/DDG4/Geant4Particle.h index 35bbb66b59a473a08d65074f4cd110859e8bc7d9..6e31d970a90c49786e9583f07b945214b4976232 100644 --- a/DDG4/include/DDG4/Geant4Particle.h +++ b/DDG4/include/DDG4/Geant4Particle.h @@ -298,6 +298,8 @@ namespace DD4hep { Geant4ParticleMap() {} /// Default destructor virtual ~Geant4ParticleMap(); + /// Dump content + void dump() const; /// Clear particle maps void clear(); /// Adopt particle maps diff --git a/DDG4/lcio/LCIOEventReader.cpp b/DDG4/lcio/LCIOEventReader.cpp index f51da1a043013f31cd570f31bb2fba4bc17d4160..952b0593ccd2b1a1fe5528bb37a1451775348d81 100644 --- a/DDG4/lcio/LCIOEventReader.cpp +++ b/DDG4/lcio/LCIOEventReader.cpp @@ -64,7 +64,8 @@ LCIOEventReader::readParticles(int event_number, vector<Particle*>& particles) else if ( m_numEvent == event_number ) ret = readParticles(event_number,&primaries); else - ret = EVENT_READER_NO_DIRECT; + ret = readParticles(event_number,&primaries); + //ret = EVENT_READER_NO_DIRECT; ++m_numEvent; if ( ret != EVENT_READER_OK ) return ret; diff --git a/DDG4/src/Geant4InputAction.cpp b/DDG4/src/Geant4InputAction.cpp index 161a4e9de1045f2e018b21d1d3f156d39c52c06e..e5c095576d274ebcfee8f5ed48a1600d3ab2af2b 100644 --- a/DDG4/src/Geant4InputAction.cpp +++ b/DDG4/src/Geant4InputAction.cpp @@ -46,11 +46,14 @@ Geant4EventReader::EventReaderStatus Geant4EventReader::skipEvent() { /// Move to the indicated event number. Geant4EventReader::EventReaderStatus Geant4EventReader::moveToEvent(int event_number) { - if ( m_currEvent == event_number-1 ) { + if ( event_number >= INT_MIN ) { + return EVENT_READER_OK; // Logic below does not work as expected. + } // This shortcuts it! + if ( m_currEvent == event_number ) { return EVENT_READER_OK; } else if ( hasDirectAccess() ) { - m_currEvent = event_number-1; + m_currEvent = event_number; return EVENT_READER_OK; } else if ( event_number<m_currEvent ) { @@ -59,7 +62,7 @@ Geant4EventReader::moveToEvent(int event_number) { else { for(int i=m_currEvent; i<event_number;++i) skipEvent(); - m_currEvent = event_number-1; + m_currEvent = event_number; return EVENT_READER_OK; } return EVENT_READER_ERROR; diff --git a/DDG4/src/Geant4Particle.cpp b/DDG4/src/Geant4Particle.cpp index a529c210a4773843275f5be13448489cd9ef71d2..fd1feb80633a95b5c93e36dadf753dd1bb87db91 100644 --- a/DDG4/src/Geant4Particle.cpp +++ b/DDG4/src/Geant4Particle.cpp @@ -17,6 +17,7 @@ #include "G4ParticleTable.hh" #include "G4ParticleDefinition.hh" #include "G4VProcess.hh" +#include <iostream> using namespace DD4hep; using namespace DD4hep::Simulation; @@ -328,6 +329,38 @@ void Geant4ParticleMap::clear() { equivalentTracks.clear(); } +/// Dump content +void Geant4ParticleMap::dump() const { + int cnt; + char text[64]; + using namespace std; + const Geant4ParticleMap* m = this; + + cnt = 0; + cout << "Particle map:" << endl; + for(Geant4ParticleMap::ParticleMap::const_iterator i=m->particleMap.begin(); i!=m->particleMap.end();++i) { + ::snprintf(text,sizeof(text)," [%-4d:%p]",(*i).second->id,(void*)(*i).second); + cout << text; + if ( ++cnt == 8 ) { + cout << endl; + cnt = 0; + } + } + cout << endl; + + cnt = 0; + cout << "Equivalents:" << endl; + for(Geant4ParticleMap::TrackEquivalents::const_iterator i=m->equivalentTracks.begin(); i!=m->equivalentTracks.end();++i) { + ::snprintf(text,sizeof(text)," [%-5d : %-5d]",(*i).first,(*i).second); + cout << text; + if ( ++cnt == 8 ) { + cout << endl; + cnt = 0; + } + } + cout << endl; +} + /// Adopt particle maps void Geant4ParticleMap::adopt(ParticleMap& pm, TrackEquivalents& equiv) { clear(); @@ -335,6 +368,7 @@ void Geant4ParticleMap::adopt(ParticleMap& pm, TrackEquivalents& equiv) { equivalentTracks = equiv; pm.clear(); equiv.clear(); + //dumpMap(this); } /// Access the equivalent track id (shortcut to the usage of TrackEquivalents)