Skip to content
Snippets Groups Projects
Commit c73cc87b authored by lintao@ihep.ac.cn's avatar lintao@ihep.ac.cn
Browse files

WIP: start to fix the inconsistency between track ID in G4 and id of MC particle in EDM4hep.

parent 849c9c2c
No related branches found
No related tags found
No related merge requests found
......@@ -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;
}
......
......@@ -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());
......
......@@ -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 << ")"
......
......@@ -4,7 +4,9 @@
gaudi_add_library(DetSimInterface
SOURCES src/IDetSimSvc.cpp
src/CommonUserEventInfo.cc
LINK Gaudi::GaudiKernel
${Geant4_LIBRARIES}
)
install(TARGETS DetSimInterface
......
#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
#include "DetSimInterface/CommonUserEventInfo.hh"
CommonUserEventInfo::CommonUserEventInfo() {
}
CommonUserEventInfo::~CommonUserEventInfo() {
}
void
CommonUserEventInfo::Print() const {
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment