diff --git a/Generator/src/GenPrinter.cpp b/Generator/src/GenPrinter.cpp index 4840bee179b367531ab4c2f32cf14ec6d3c7eebe..359f26dee192363cb2f5410332fd527577a1d640 100644 --- a/Generator/src/GenPrinter.cpp +++ b/Generator/src/GenPrinter.cpp @@ -4,6 +4,13 @@ DECLARE_COMPONENT(GenPrinter) bool GenPrinter::mutate(MyHepMC::GenEvent& event){ + auto msglevel = msgLevel(); + + // only print when current msglevel is MSG::DEBUG/VERBOSE + if (msglevel != MSG::NIL && msglevel != MSG::VERBOSE && msglevel != MSG::DEBUG) { + return true; + } + std::cout << "print mc info for event "<< event.getID() << ", mc size ="<< event.m_mc_vec.size() << std::endl; for ( int i =0; i < event.m_mc_vec.size(); i++ ) { auto p = event.m_mc_vec.at(i); diff --git a/Simulation/DetSimAna/src/Edm4hepWriterAnaElemTool.cpp b/Simulation/DetSimAna/src/Edm4hepWriterAnaElemTool.cpp index b31b62d8332777e396ce835ee96e814476465b65..cfbf31dfca17462043695237e78e6a7af5caba41 100644 --- a/Simulation/DetSimAna/src/Edm4hepWriterAnaElemTool.cpp +++ b/Simulation/DetSimAna/src/Edm4hepWriterAnaElemTool.cpp @@ -19,6 +19,11 @@ DECLARE_COMPONENT(Edm4hepWriterAnaElemTool) void Edm4hepWriterAnaElemTool::BeginOfRunAction(const G4Run*) { + auto msglevel = msgLevel(); + if (msglevel == MSG::VERBOSE || msglevel == MSG::DEBUG) { + verboseOutput = true; + } + G4cout << "Begin Run of detector simultion..." << G4endl; // access geometry service @@ -52,7 +57,9 @@ Edm4hepWriterAnaElemTool::BeginOfEventAction(const G4Event* anEvent) { m_userinfo = nullptr; if (anEvent->GetUserInformation()) { m_userinfo = dynamic_cast<CommonUserEventInfo*>(anEvent->GetUserInformation()); - m_userinfo->dumpIdxG4Track2Edm4hep(); + if (verboseOutput) { + m_userinfo->dumpIdxG4Track2Edm4hep(); + } } auto mcGenCol = m_mcParGenCol.get(); @@ -84,6 +91,8 @@ Edm4hepWriterAnaElemTool::BeginOfEventAction(const G4Event* anEvent) { void Edm4hepWriterAnaElemTool::EndOfEventAction(const G4Event* anEvent) { + + msg() << "mcCol size (after simulation) : " << mcCol->size() << endmsg; // save all data // create collections. @@ -452,14 +461,14 @@ Edm4hepWriterAnaElemTool::PostUserTrackingAction(const G4Track* track) { // select the necessary processes if (creatorProcess==proc_decay) { - info() << "Creator Process is Decay for secondary particle: " - << " idx: " << i - << " trkid: " << sectrk->GetTrackID() // not valid until track - << " particle: " << secparticle->GetParticleName() - << " pdg: " << secparticle->GetPDGEncoding() - << " at position: " << sectrk->GetPosition() // - << " time: " << sectrk->GetGlobalTime() - << " momentum: " << sectrk->GetMomentum() // + debug() << "Creator Process is Decay for secondary particle: " + << " idx: " << i + << " trkid: " << sectrk->GetTrackID() // not valid until track + << " particle: " << secparticle->GetParticleName() + << " pdg: " << secparticle->GetPDGEncoding() + << " at position: " << sectrk->GetPosition() // + << " time: " << sectrk->GetGlobalTime() + << " momentum: " << sectrk->GetMomentum() // << endmsg; is_decay = true; @@ -496,9 +505,9 @@ Edm4hepWriterAnaElemTool::PostUserTrackingAction(const G4Track* track) { auto trackinfo = new CommonUserTrackInfo(); trackinfo->setIdxEdm4hep(mcp.getObjectID().index); sectrk->SetUserInformation(trackinfo); - info() << " Appending MCParticle: (id: " - << mcp.getObjectID().index << ")" - << endmsg; + debug() << " Appending MCParticle: (id: " + << mcp.getObjectID().index << ")" + << endmsg; } } } @@ -541,9 +550,9 @@ Edm4hepWriterAnaElemTool::UserSteppingAction(const G4Step* aStep) { // set back scattering auto idxedm4hep = trackinfo->idxEdm4hep(); mcCol->at(idxedm4hep).setBackscatter(true); - info() << " set back scatter for MCParticle " - << " (ID: " << idxedm4hep << ")" - << endmsg; + debug() << " set back scatter for MCParticle " + << " (ID: " << idxedm4hep << ")" + << endmsg; } } } diff --git a/Simulation/DetSimAna/src/Edm4hepWriterAnaElemTool.h b/Simulation/DetSimAna/src/Edm4hepWriterAnaElemTool.h index 9782cf5f5bd0fbbcca105f9d24b2eb25387ac915..e4415b17899012530817186c0428581b585bad62 100644 --- a/Simulation/DetSimAna/src/Edm4hepWriterAnaElemTool.h +++ b/Simulation/DetSimAna/src/Edm4hepWriterAnaElemTool.h @@ -151,6 +151,7 @@ private: double R = 0; double Z = 0; + bool verboseOutput = false; }; #endif diff --git a/Simulation/DetSimCore/src/G4PrimaryCnvTool.cpp b/Simulation/DetSimCore/src/G4PrimaryCnvTool.cpp index 35711ba17a37a365cf22c1232790c552f6433456..06528ec5538d1ba7b4fd406650c71e7aaab759f5 100644 --- a/Simulation/DetSimCore/src/G4PrimaryCnvTool.cpp +++ b/Simulation/DetSimCore/src/G4PrimaryCnvTool.cpp @@ -19,15 +19,15 @@ bool G4PrimaryCnvTool::mutate(G4Event* anEvent) { int idxEdm4hep = -1; // valid: [0, N) auto mcCol = m_mcParCol.get(); - info() << "Start a new event: " << endmsg; + info() << "Start a new event " << anEvent->GetEventID() << endmsg; for ( auto p : *mcCol ) { - info() << " gen track: " << p.getObjectID().index - << " : (status: " << p.getGeneratorStatus() << ")" - << " : (daughters: ["; + debug() << " gen track: " << p.getObjectID().index + << " : (status: " << p.getGeneratorStatus() << ")" + << " : (daughters: ["; for ( auto it = p.daughters_begin(), end = p.daughters_end(); it != end; ++it ) { - info() << " " << it->getObjectID().index; + debug() << " " << it->getObjectID().index; } - info() << " ]); " << endmsg; + debug() << " ]); " << endmsg; // idx in mc particle collection ++idxEdm4hep; @@ -50,11 +50,11 @@ bool G4PrimaryCnvTool::mutate(G4Event* anEvent) { vertex.z*CLHEP::mm, t); - info() << "--> Creating Geant4 Primary Vertex: (" - << vertex.x*CLHEP::mm << "," - << vertex.y*CLHEP::mm << "," - << vertex.z*CLHEP::mm << ")" - << endmsg; + debug() << "--> Creating Geant4 Primary Vertex: (" + << vertex.x*CLHEP::mm << "," + << vertex.y*CLHEP::mm << "," + << vertex.z*CLHEP::mm << ")" + << endmsg; // pdg/particle int pdgcode = p.getPDG(); diff --git a/Simulation/DetSimGeom/src/AnExampleDetElemTool.cpp b/Simulation/DetSimGeom/src/AnExampleDetElemTool.cpp index fb2c1126b79293482e3c66c6ebb3ffe9681302d7..00c84c75eaebcedad22265694d9c08ca6d081988 100644 --- a/Simulation/DetSimGeom/src/AnExampleDetElemTool.cpp +++ b/Simulation/DetSimGeom/src/AnExampleDetElemTool.cpp @@ -180,10 +180,12 @@ AnExampleDetElemTool::ConstructSDandField() { throw std::runtime_error("ConstructSDandField: Failed to access G4LogicalVolume for SD " + nam + " of type " + typ + "."); } - info() << " -> Adding " << g4v->GetName() << endmsg; + debug() << " -> Adding " << g4v->GetName() << endmsg; G4SDManager::GetSDMpointer()->AddNewDetector(g4sd); g4v->SetSensitiveDetector(g4sd); } + info() << "-> Total " << sens_vols.size() + << " senstive volumes are registered. " << endmsg; } // =======================================================================