diff --git a/Generator/src/GenPrinter.cpp b/Generator/src/GenPrinter.cpp index 48c6d499451ec24b1eb9b0874b971cdc0678f3b2..4840bee179b367531ab4c2f32cf14ec6d3c7eebe 100644 --- a/Generator/src/GenPrinter.cpp +++ b/Generator/src/GenPrinter.cpp @@ -6,26 +6,39 @@ DECLARE_COMPONENT(GenPrinter) bool GenPrinter::mutate(MyHepMC::GenEvent& event){ 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); - std::cout<< "PDG :"<< p.getPDG ()<<std::endl - << "id :"<< p.id ()<<std::endl - << "ID :"<< p.getObjectID().index <<std::endl - << "GeneratorStatus :"<< p.getGeneratorStatus ()<<std::endl - << "SimulatorStatus :"<< p.getSimulatorStatus ()<<std::endl - << "Charge :"<< p.getCharge ()<<std::endl - << "Time :"<< p.getTime ()<<std::endl - << "Mass :"<< p.getMass ()<<std::endl - << "Vertex :"<< p.getVertex ()<<std::endl - << "Endpoint :"<< p.getEndpoint ()<<std::endl - << "Momentum :"<< p.getMomentum ()<<std::endl - << "MomentumAtEndpoint:"<< p.getMomentumAtEndpoint()<<std::endl - << "Spin :"<< p.getSpin ()<<std::endl - << "ColorFlow :"<< p.getColorFlow ()<<std::endl - << "Parent size :"<< p.parents_size ()<<std::endl - << "Daughter size :"<< p.daughters_size ()<<std::endl; - //for(unsigned int j=0; j<p.parents_size(); j++) std::cout << " for parent: "<< j << ",PDG="<< p.getParents(j).getPDG() << ",id=:"<< p.getParents(j).id()<<std::endl; - for (auto it = p.parents_begin(), end = p.parents_end(); it != end ; ++it ) std::cout << " for parent ,PDG="<< it->getPDG() << ",id=:"<< it->getObjectID().index<<std::endl; + auto p = event.m_mc_vec.at(i); + std::cout<< "PDG :"<< p.getPDG ()<<std::endl + << "id :"<< p.id ()<<std::endl + << "ID :"<< p.getObjectID().index <<std::endl + << "GeneratorStatus :"<< p.getGeneratorStatus ()<<std::endl + << "SimulatorStatus :"<< p.getSimulatorStatus ()<<std::endl + << "Charge :"<< p.getCharge ()<<std::endl + << "Time :"<< p.getTime ()<<std::endl + << "Mass :"<< p.getMass ()<<std::endl + << "Vertex :"<< p.getVertex ()<<std::endl + << "Endpoint :"<< p.getEndpoint ()<<std::endl + << "Momentum :"<< p.getMomentum ()<<std::endl + << "MomentumAtEndpoint:"<< p.getMomentumAtEndpoint()<<std::endl + << "Spin :"<< p.getSpin ()<<std::endl + << "ColorFlow :"<< p.getColorFlow ()<<std::endl + << "Parent size :"<< p.parents_size ()<<std::endl + << "Daughter size :"<< p.daughters_size ()<<std::endl; + //for(unsigned int j=0; j<p.parents_size(); j++) std::cout << " for parent: "<< j << ",PDG="<< p.getParents(j).getPDG() << ",id=:"<< p.getParents(j).id()<<std::endl; + for (auto it = p.parents_begin(), end = p.parents_end(); it != end ; ++it ) { + std::cout << " - parent, PDG=" << it->getPDG() + << ", id=" << it->id() + << ", ID=" << it->getObjectID().index + << std::endl; + } + + for (auto it = p.daughters_begin(), end = p.daughters_end(); it != end ; ++it ) { + std::cout << " - daughter, PDG=" << it->getPDG() + << ", id=" << it->id() + << ", ID=" << it->getObjectID().index + << std::endl; + } } + return true; } diff --git a/Generator/src/StdHepRdr.cpp b/Generator/src/StdHepRdr.cpp index b56342b0bfb25de4eb4ceee6b6d6362004bcb1bd..4255e4bd314f3549f0bea3f56be3d4e470221c5a 100644 --- a/Generator/src/StdHepRdr.cpp +++ b/Generator/src/StdHepRdr.cpp @@ -36,13 +36,13 @@ bool StdHepRdr::mutate(MyHepMC::GenEvent& event){ m_processed_event ++; int n_mc = mc_vec->getNumberOfElements(); //std::cout<<"Debug: Read event :"<< m_processed_event <<", mc size :"<< n_mc <<std::endl; - std::map<int, int> pmcid_lmcid; + std::map<int, int> pmcid_lmcid; // mapping between the obj idx in edm4hep and the idx in stdhep for (int i=0; i < n_mc; i++){ MCParticleImpl* mc = (MCParticleImpl*) mc_vec->getElementAt(i); //std::cout<<"At mc :"<< i <<std::endl; auto mcp = event.m_mc_vec.create(); pmcid_lmcid.insert(std::pair<int, int>(mc->id(),i)); - //std::cout<<"map<id,i>:"<<mc->id()<<","<< i <<std::endl; + // std::cout<<"map<id,i>:"<<mc->id()<<","<< i <<std::endl; mcp.setPDG (mc->getPDG()); mcp.setGeneratorStatus (mc->getGeneratorStatus()); diff --git a/Simulation/DetSimCore/src/G4PrimaryCnvTool.cpp b/Simulation/DetSimCore/src/G4PrimaryCnvTool.cpp index c756412f62dccf71d5628191b10f4a4e6f555e26..b03a403e6d2eb013c0b0bb8d88dfebe7623eb3f8 100644 --- a/Simulation/DetSimCore/src/G4PrimaryCnvTool.cpp +++ b/Simulation/DetSimCore/src/G4PrimaryCnvTool.cpp @@ -12,11 +12,13 @@ bool G4PrimaryCnvTool::mutate(G4Event* anEvent) { auto mcCol = m_mcParCol.get(); info() << "Start a new event: " << endmsg; for ( auto p : *mcCol ) { - info() << p.getObjectID().index << " : ["; + info() << " 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; } - info() << " ]; " << endmsg; + info() << " ]); " << endmsg; // only the GeneratorStatus == 1 is used. if (p.getGeneratorStatus() != 1) { @@ -31,7 +33,7 @@ bool G4PrimaryCnvTool::mutate(G4Event* anEvent) { vertex.z*CLHEP::mm, t); - info() << "Geant4 Primary Vertex: (" + info() << "--> Creating Geant4 Primary Vertex: (" << vertex.x*CLHEP::mm << "," << vertex.y*CLHEP::mm << "," << vertex.z*CLHEP::mm << ")" diff --git a/Simulation/DetSimInterface/CMakeLists.txt b/Simulation/DetSimInterface/CMakeLists.txt index ed99eead6c48943bbe639731e2705a8e70423d31..b5fd14616a4bf34b98f3d4545d6c398954423bda 100644 --- a/Simulation/DetSimInterface/CMakeLists.txt +++ b/Simulation/DetSimInterface/CMakeLists.txt @@ -4,7 +4,9 @@ gaudi_add_library(DetSimInterface SOURCES src/IDetSimSvc.cpp + src/CommonUserEventInfo.cc LINK Gaudi::GaudiKernel + ${Geant4_LIBRARIES} ) install(TARGETS DetSimInterface diff --git a/Simulation/DetSimInterface/include/DetSimInterface/CommonUserEventInfo.hh b/Simulation/DetSimInterface/include/DetSimInterface/CommonUserEventInfo.hh new file mode 100644 index 0000000000000000000000000000000000000000..733c66669b02fcb9c39ad4b0ae38342e8821583c --- /dev/null +++ b/Simulation/DetSimInterface/include/DetSimInterface/CommonUserEventInfo.hh @@ -0,0 +1,29 @@ +#ifndef CommonUserEventInfo_hh +#define CommonUserEventInfo_hh + +/* + * Description: + * This class is a part of simulation framework to allow users to extend the G4Event. + * + * For example, when G4 converts the EDM4hep/G4 primary vertex/particle to G4 track, + * the relationship between the EDM4hep track and G4 track is missing. + * So a map is used as a bookkeeping. + * + * Author: + * Tao Lin <lintao AT ihep.ac.cn> + */ + +#include "G4VUserEventInformation.hh" + +class CommonUserEventInfo: public G4VUserEventInformation { +public: + + CommonUserEventInfo(); + virtual ~CommonUserEventInfo(); + +public: + virtual void Print() const; + +}; + +#endif diff --git a/Simulation/DetSimInterface/src/CommonUserEventInfo.cc b/Simulation/DetSimInterface/src/CommonUserEventInfo.cc new file mode 100644 index 0000000000000000000000000000000000000000..3f7d2af760f7fa5fd2071e4a38378f35a0187afb --- /dev/null +++ b/Simulation/DetSimInterface/src/CommonUserEventInfo.cc @@ -0,0 +1,14 @@ +#include "DetSimInterface/CommonUserEventInfo.hh" + +CommonUserEventInfo::CommonUserEventInfo() { + +} + +CommonUserEventInfo::~CommonUserEventInfo() { + +} + +void +CommonUserEventInfo::Print() const { + +}