diff --git a/Examples/options/tut_detsim.py b/Examples/options/tut_detsim.py index 2ecb5e3f6ea15ba4ce0dd5b6f8e37b33c102c1c2..6750292727e27d2c0f61da05ff99a1e29dd395e6 100644 --- a/Examples/options/tut_detsim.py +++ b/Examples/options/tut_detsim.py @@ -107,7 +107,8 @@ detsimalg.RunCmds = [ ] detsimalg.AnaElems = [ # example_anatool.name() - "ExampleAnaElemTool" + # "ExampleAnaElemTool" + "Edm4hepWriterAnaElemTool" ] detsimalg.RootDetElem = "WorldDetElemTool" diff --git a/Generator/CMakeLists.txt b/Generator/CMakeLists.txt index f1c10a13618fe61c29112ad7e577c67415211fd8..d01b06e06f9edf39552728276c1b6f4bf33ef9de 100644 --- a/Generator/CMakeLists.txt +++ b/Generator/CMakeLists.txt @@ -22,6 +22,7 @@ find_package(ROOT COMPONENTS RIO Tree TreePlayer MathCore Net Graf3d Graf Gpad E find_package(LCIO) find_package(podio) find_package(plcio) +find_package(EDM4HEP) find_package(HepMC) find_package(CLHEP) if(ROOT_FOUND) @@ -66,6 +67,7 @@ gaudi_add_module(GenAlgo ${GenAlgo_srcs} HepMC CLHEP # Geant4 + EDM4HEP::edm4hep ) #gaudi_add_test(Reader FRAMEWORK options/read.py) diff --git a/Generator/src/GenAlgo.cpp b/Generator/src/GenAlgo.cpp index 74c2db30e0f75fc02bd2015b349ddade470c4f40..58f9d4e8b438085a5322e565f778506830e7ec14 100644 --- a/Generator/src/GenAlgo.cpp +++ b/Generator/src/GenAlgo.cpp @@ -5,7 +5,7 @@ #include "GaudiKernel/GaudiException.h" -#include "plcio/MCParticleCollection.h"//plico +#include "edm4hep/MCParticleCollection.h"//plico #include <iostream> #include <vector> diff --git a/Generator/src/GenAlgo.h b/Generator/src/GenAlgo.h index 44c478a0c88f0063d7580086957721f739d252a6..47745aefec9c8ac7a90819bf88c9eecf91fc7ab8 100644 --- a/Generator/src/GenAlgo.h +++ b/Generator/src/GenAlgo.h @@ -42,7 +42,7 @@ private: int m_evtid; int m_evtMax; //MyHepMC::GenEvent m_event; - DataHandle<plcio::MCParticleCollection> m_hdl{"MCParticle", Gaudi::DataHandle::Writer, this}; + DataHandle<edm4hep::MCParticleCollection> m_hdl{"MCParticle", Gaudi::DataHandle::Writer, this}; }; diff --git a/Generator/src/GenEvent.cpp b/Generator/src/GenEvent.cpp index 1cd5ccb3c6bcc02df464106e391b846a77bbd159..3e40c65b8476c83a48e98fc4b596e60d15bcab5f 100644 --- a/Generator/src/GenEvent.cpp +++ b/Generator/src/GenEvent.cpp @@ -1,12 +1,12 @@ #include "GenEvent.h" -#include "plcio/MCParticleCollection.h"//plico +#include "edm4hep/MCParticleCollection.h"//plico using namespace std; namespace MyHepMC{ //GenEvent::GenEvent(){ -GenEvent::GenEvent(plcio::MCParticleCollection& mcCol) +GenEvent::GenEvent(edm4hep::MCParticleCollection& mcCol) : m_mc_vec(mcCol){ m_event_id=-1; @@ -24,11 +24,11 @@ void GenEvent::SetEventHeader(long event_id_, long run_id_, float time_, string m_det_name = det_name_; } /* -void GenEvent::SetMCCollection(plcio::MCParticleCollection vec_){ +void GenEvent::SetMCCollection(edm4hep::MCParticleCollection vec_){ m_mc_vec = vec_; } */ -plcio::MCParticleCollection GenEvent::getMCVec(){ +edm4hep::MCParticleCollection GenEvent::getMCVec(){ return m_mc_vec; } diff --git a/Generator/src/GenEvent.h b/Generator/src/GenEvent.h index dae1b3772d3044ad3434898ec1c216ab41493d57..72895413a5d06438fcffe72495ef56b646921c5c 100644 --- a/Generator/src/GenEvent.h +++ b/Generator/src/GenEvent.h @@ -1,25 +1,25 @@ #ifndef GenEvent_h #define GenEvent_h 1 -#include "plcio/MCParticleCollection.h"//plico +#include "edm4hep/MCParticleCollection.h"//plico namespace MyHepMC { class GenEvent{ public: //GenEvent(); - GenEvent(plcio::MCParticleCollection& mcCol); + GenEvent(edm4hep::MCParticleCollection& mcCol); ~GenEvent(); void SetEventHeader(long event_id_, long run_id_, float time_, std::string det_name_); - //void SetMCCollection(plcio::MCParticleCollection vec_); + //void SetMCCollection(edm4hep::MCParticleCollection vec_); long getID(); long getRun(); long getTime(); void ReSet(); std::string getName(); - plcio::MCParticleCollection getMCVec(); - plcio::MCParticleCollection& m_mc_vec; - //plcio::MCParticleCollection m_mc_vec; + edm4hep::MCParticleCollection getMCVec(); + edm4hep::MCParticleCollection& m_mc_vec; + //edm4hep::MCParticleCollection m_mc_vec; private: long m_event_id; long m_run_id; diff --git a/Generator/src/GtGunTool.cpp b/Generator/src/GtGunTool.cpp index a8f65da3863f1622f63997fef74ebc77c36c4a05..7a6a8a64c902682aac4d83e325f9979be8dedc64 100644 --- a/Generator/src/GtGunTool.cpp +++ b/Generator/src/GtGunTool.cpp @@ -81,7 +81,7 @@ GtGunTool::mutate(MyHepMC::GenEvent& event) { double energy = m_energies.value()[i]; // create the MC particle - plcio::MCParticle mcp = event.m_mc_vec.create(); + edm4hep::MCParticle mcp = event.m_mc_vec.create(); mcp.setPDG(pdgcode); mcp.setGeneratorStatus(1); mcp.setSimulatorStatus(1); @@ -134,7 +134,7 @@ GtGunTool::mutate(MyHepMC::GenEvent& event) { double py = p*sintheta*sin(phi); double pz = p*costheta; - mcp.setMomentum(plcio::FloatThree(px,py,pz)); + mcp.setMomentum(edm4hep::Vector3f(px,py,pz)); // mcp.setMomentumAtEndpoint(); // mcp.setSpin(); // mcp.setColorFlow(); diff --git a/Generator/src/HepMCRdr.cpp b/Generator/src/HepMCRdr.cpp index b8c81809efb2efb4e0e25a5f4d3a9f3f624fdc60..491e0b47913a7815408c674e812055f0287b3421 100644 --- a/Generator/src/HepMCRdr.cpp +++ b/Generator/src/HepMCRdr.cpp @@ -7,12 +7,10 @@ #include "HepMC/Polarization.h" -#include "plcio/MCParticle.h" //plcio -#include "plcio/MCParticleObj.h" -#include "plcio/MCParticleCollection.h" -#include "plcio/DoubleThree.h" -#include "plcio/FloatThree.h" -#include "plcio/EventHeaderCollection.h" +#include "edm4hep/MCParticle.h" //edm4hep +#include "edm4hep/MCParticleObj.h" +#include "edm4hep/MCParticleCollection.h" +#include "edm4hep/EventHeaderCollection.h" @@ -21,7 +19,7 @@ #include <fstream> -using namespace plcio; +using namespace edm4hep; using namespace std; DECLARE_COMPONENT(HepMCRdr) @@ -41,7 +39,7 @@ bool HepMCRdr::mutate(MyHepMC::GenEvent& event){ int index = 0 ; for ( HepMC::GenEvent::particle_iterator p = evt->particles_begin(); p != evt->particles_end(); ++p ) { //std::cout<<"start mc "<<index<<std::endl; - plcio::MCParticle mcp = event.m_mc_vec.create(); + edm4hep::MCParticle mcp = event.m_mc_vec.create(); pmcid_lmcid.insert(std::pair<int, int>((*p)->barcode(),index)); index++; //std::cout<<"map<id,i>:"<<mc->id()<<","<< i <<std::endl; @@ -55,26 +53,26 @@ bool HepMCRdr::mutate(MyHepMC::GenEvent& event){ if ( (*p)->production_vertex() ){ HepMC::GenVertex* vertex_pro = (*p)->production_vertex(); double three[3] = {vertex_pro->point3d().x(), vertex_pro->point3d().y(), vertex_pro->point3d().z()}; - mcp.setVertex (plcio::DoubleThree (three)); + mcp.setVertex (edm4hep::Vector3d (three)); } - else mcp.setVertex(plcio::DoubleThree()); + else mcp.setVertex(edm4hep::Vector3d()); if ( (*p)->end_vertex() ){ HepMC::GenVertex* vertex_end = (*p)->end_vertex(); double three[3] = {vertex_end->point3d().x(), vertex_end->point3d().y(), vertex_end->point3d().z()}; - mcp.setEndpoint (plcio::DoubleThree (three)); + mcp.setEndpoint (edm4hep::Vector3d (three)); } - else mcp.setEndpoint (plcio::DoubleThree()); - mcp.setMomentum (plcio::FloatThree(float((*p)->momentum().px()), float((*p)->momentum().py()), float((*p)->momentum().pz()) )); - mcp.setMomentumAtEndpoint (plcio::FloatThree(float((*p)->momentum().px()), float((*p)->momentum().py()), float((*p)->momentum().pz()) )); + else mcp.setEndpoint (edm4hep::Vector3d()); + mcp.setMomentum (edm4hep::Vector3f(float((*p)->momentum().px()), float((*p)->momentum().py()), float((*p)->momentum().pz()) )); + mcp.setMomentumAtEndpoint (edm4hep::Vector3f(float((*p)->momentum().px()), float((*p)->momentum().py()), float((*p)->momentum().pz()) )); const HepMC::Polarization & polar = (*p)->polarization(); - mcp.setSpin (plcio::FloatThree(polar.normal3d().x(), polar.normal3d().y(), polar.normal3d().z()) ); + mcp.setSpin (edm4hep::Vector3f(polar.normal3d().x(), polar.normal3d().y(), polar.normal3d().z()) ); int two[2] = {1, (*p)->flow(1)}; - mcp.setColorFlow (plcio::IntTwo (two) ); + mcp.setColorFlow (edm4hep::Vector2i (two) ); } // second loop for setting parents and daughters index = 0 ; for ( HepMC::GenEvent::particle_iterator p = evt->particles_begin(); p != evt->particles_end(); ++p ) { - plcio::MCParticle pmc = event.m_mc_vec.at(index); + edm4hep::MCParticle pmc = event.m_mc_vec.at(index); index++; if ( (*p)->production_vertex() ) { for ( HepMC::GenVertex::particle_iterator mother = (*p)->production_vertex()-> particles_begin(HepMC::parents); mother != (*p)->production_vertex()-> particles_end(HepMC::parents); ++mother ) { diff --git a/Generator/src/SLCIORdr.cpp b/Generator/src/SLCIORdr.cpp index 9db71153961d29ece2a4479d36bddfa8fb7dde98..13bd39ed18f56b5b79071c81ec366408548a34dd 100644 --- a/Generator/src/SLCIORdr.cpp +++ b/Generator/src/SLCIORdr.cpp @@ -12,12 +12,10 @@ #include "IMPL/LCCollectionVec.h" -#include "plcio/MCParticle.h" //plcio -#include "plcio/MCParticleObj.h" -#include "plcio/MCParticleCollection.h" -#include "plcio/DoubleThree.h" -#include "plcio/FloatThree.h" -#include "plcio/EventHeaderCollection.h" +#include "edm4hep/MCParticle.h" //edm4hep +#include "edm4hep/MCParticleObj.h" +#include "edm4hep/MCParticleCollection.h" +#include "edm4hep/EventHeaderCollection.h" @@ -28,7 +26,7 @@ using namespace lcio; using namespace IMPL; -using namespace plcio; +using namespace edm4hep; using namespace std; DECLARE_COMPONENT(SLCIORdr) @@ -75,7 +73,7 @@ bool SLCIORdr::mutate(MyHepMC::GenEvent& event){ for(i=0;i<NHEP;i++){ if(p==lcCol->getElementAt(i)) break; } - if(i==NHEP) cout << "HepLCIOInterfaceNew: error" << endl; + if(i==NHEP) cout << "Heedm4hepInterfaceNew: error" << endl; mcp->addParent(dynamic_cast<MCParticleImpl*>(lcMCVec->getElementAt(i))); } //ignore daughter table, auto-regonize relationship while addParent() @@ -88,7 +86,7 @@ bool SLCIORdr::mutate(MyHepMC::GenEvent& event){ for(i=0;i<NHEP;i++){ if(d==lcCol->getElementAt(i)) break; } - if(i==NHEP) cout << "HepLCIOInterfaceNew: error" << endl; + if(i==NHEP) cout << "Heedm4hepInterfaceNew: error" << endl; mcp->addDaughter(dynamic_cast<MCParticleImpl*>(lcMCVec->getElementAt(i))); } */ @@ -108,7 +106,7 @@ bool SLCIORdr::mutate(MyHepMC::GenEvent& event){ for (int i=0; i < n_mc; i++){ MCParticleImpl* mc = (MCParticleImpl*) lcMCVec->getElementAt(i); //std::cout<<"At mc :"<< i <<std::endl; - plcio::MCParticle mcp = event.m_mc_vec.create(); + edm4hep::MCParticle 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; @@ -120,8 +118,8 @@ bool SLCIORdr::mutate(MyHepMC::GenEvent& event){ mcp.setMass (mc->getMass()); mcp.setVertex (mc->getVertex()); mcp.setEndpoint (mc->getEndpoint()); - mcp.setMomentum (FloatThree(float(mc->getMomentum()[0]), float(mc->getMomentum()[1]), float(mc->getMomentum()[2]) )); - mcp.setMomentumAtEndpoint (FloatThree(float(mc->getMomentumAtEndpoint()[0]), float(mc->getMomentumAtEndpoint()[1]), float(mc->getMomentumAtEndpoint()[2]) )); + mcp.setMomentum (Vector3f(float(mc->getMomentum()[0]), float(mc->getMomentum()[1]), float(mc->getMomentum()[2]) )); + mcp.setMomentumAtEndpoint (Vector3f(float(mc->getMomentumAtEndpoint()[0]), float(mc->getMomentumAtEndpoint()[1]), float(mc->getMomentumAtEndpoint()[2]) )); mcp.setSpin (mc->getSpin()); mcp.setColorFlow (mc->getColorFlow()); } @@ -131,7 +129,7 @@ bool SLCIORdr::mutate(MyHepMC::GenEvent& event){ MCParticleImpl* mc = (MCParticleImpl*) lcMCVec->getElementAt(i); const MCParticleVec & mc_parents = mc->getParents(); const MCParticleVec & mc_daughters = mc->getDaughters(); - plcio::MCParticle pmc = event.m_mc_vec.at(i); + edm4hep::MCParticle pmc = event.m_mc_vec.at(i); //std::cout<<"mc at "<< i<<", parent size "<<mc_parents.size() <<std::endl; for(unsigned int j=0; j< mc_parents.size(); j++){int p_id = mc_parents.at(j)->id(); //std::cout<<"parent id "<<p_id<<std::endl; diff --git a/Generator/src/StdHepRdr.cpp b/Generator/src/StdHepRdr.cpp index b81abb0569a52df5a3674290d9f8a958f33aba35..3bc1412fe14ca9c56ece0bea6ae5167eb74a6ffb 100644 --- a/Generator/src/StdHepRdr.cpp +++ b/Generator/src/StdHepRdr.cpp @@ -7,12 +7,10 @@ #include "IMPL/MCParticleImpl.h" -#include "plcio/MCParticle.h" //plcio -#include "plcio/MCParticleObj.h" -#include "plcio/MCParticleCollection.h" -#include "plcio/DoubleThree.h" -#include "plcio/FloatThree.h" -#include "plcio/EventHeaderCollection.h" +#include "edm4hep/MCParticle.h" //edm4hep +#include "edm4hep/MCParticleObj.h" +#include "edm4hep/MCParticleCollection.h" +#include "edm4hep/EventHeaderCollection.h" @@ -23,7 +21,7 @@ using namespace lcio; using namespace IMPL; -using namespace plcio; +using namespace edm4hep; using namespace std; DECLARE_COMPONENT(StdHepRdr) @@ -42,7 +40,7 @@ bool StdHepRdr::mutate(MyHepMC::GenEvent& event){ for (int i=0; i < n_mc; i++){ MCParticleImpl* mc = (MCParticleImpl*) mc_vec->getElementAt(i); //std::cout<<"At mc :"<< i <<std::endl; - plcio::MCParticle mcp = event.m_mc_vec.create(); + edm4hep::MCParticle 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; @@ -54,8 +52,8 @@ bool StdHepRdr::mutate(MyHepMC::GenEvent& event){ mcp.setMass (mc->getMass()); mcp.setVertex (mc->getVertex()); mcp.setEndpoint (mc->getEndpoint()); - mcp.setMomentum (FloatThree(float(mc->getMomentum()[0]), float(mc->getMomentum()[1]), float(mc->getMomentum()[2]) )); - mcp.setMomentumAtEndpoint (FloatThree(float(mc->getMomentumAtEndpoint()[0]), float(mc->getMomentumAtEndpoint()[1]), float(mc->getMomentumAtEndpoint()[2]) )); + mcp.setMomentum (Vector3f(float(mc->getMomentum()[0]), float(mc->getMomentum()[1]), float(mc->getMomentum()[2]) )); + mcp.setMomentumAtEndpoint (Vector3f(float(mc->getMomentumAtEndpoint()[0]), float(mc->getMomentumAtEndpoint()[1]), float(mc->getMomentumAtEndpoint()[2]) )); mcp.setSpin (mc->getSpin()); mcp.setColorFlow (mc->getColorFlow()); } @@ -65,7 +63,7 @@ bool StdHepRdr::mutate(MyHepMC::GenEvent& event){ MCParticleImpl* mc = (MCParticleImpl*) mc_vec->getElementAt(i); const MCParticleVec & mc_parents = mc->getParents(); const MCParticleVec & mc_daughters = mc->getDaughters(); - plcio::MCParticle pmc = event.m_mc_vec.at(i); + edm4hep::MCParticle pmc = event.m_mc_vec.at(i); //std::cout<<"mc at "<< i<<", parent size "<<mc_parents.size() <<std::endl; for(unsigned int j=0; j< mc_parents.size(); j++){int p_id = mc_parents.at(j)->id(); //std::cout<<"parent id "<<p_id<<std::endl; diff --git a/Simulation/DetSimAna/CMakeLists.txt b/Simulation/DetSimAna/CMakeLists.txt index f1f361420c4bf6a98ebcb8333d391ab2d963cf14..4ab78a91cb9f3bb8e6e0511c398dbc0ddb257f56 100644 --- a/Simulation/DetSimAna/CMakeLists.txt +++ b/Simulation/DetSimAna/CMakeLists.txt @@ -13,10 +13,12 @@ find_package(DD4hep COMPONENTS DDG4 REQUIRED) # For EDM & I/O find_package(podio REQUIRED) find_package(plcio REQUIRED) +find_package(EDM4HEP REQUIRED) # find_package(LCIO REQUIRED) set(DetSimAna_srcs src/ExampleAnaElemTool.cpp + src/Edm4hepWriterAnaElemTool.cpp ) message("podio_LIBRARIES: ${podio_LIBRARIES}") message("plcio_LIBRARIES: ${plcio_LIBRARIES}") @@ -37,5 +39,6 @@ gaudi_add_module(DetSimAna ${DetSimAna_srcs} GaudiKernel # Geant4 ${plcio_LIBRARIES} + EDM4HEP::edm4hep # ${podio_LIBRARIES} ) diff --git a/Simulation/DetSimCore/CMakeLists.txt b/Simulation/DetSimCore/CMakeLists.txt index 520ba3c5eb4baaf41bd6e6ea5260fdf3da44cd6f..0de611c003ad41450f40c96d29a6187643805274 100644 --- a/Simulation/DetSimCore/CMakeLists.txt +++ b/Simulation/DetSimCore/CMakeLists.txt @@ -10,6 +10,7 @@ find_package(Geant4 REQUIRED ui_all vis_all) include(${Geant4_USE_FILE}) find_package(podio REQUIRED) find_package(plcio REQUIRED) +find_package(EDM4HEP REQUIRED) find_package(DD4hep COMPONENTS DDG4 REQUIRED) set(DetSimCore_srcs @@ -40,5 +41,6 @@ gaudi_add_module(DetSimCore ${DetSimCore_srcs} # ${Geant4_LIBRARIES} DD4hep ${DD4hep_COMPONENT_LIBRARIES} plcio + EDM4HEP::edm4hep # podio ) diff --git a/Simulation/DetSimCore/src/G4PrimaryCnvTool.cpp b/Simulation/DetSimCore/src/G4PrimaryCnvTool.cpp index 3a79e9d95bf268bd5777ed88d6321b369b103c66..d725aa27dead84d3b95df9fc66c0c990f9189fe4 100644 --- a/Simulation/DetSimCore/src/G4PrimaryCnvTool.cpp +++ b/Simulation/DetSimCore/src/G4PrimaryCnvTool.cpp @@ -24,7 +24,7 @@ bool G4PrimaryCnvTool::mutate(G4Event* anEvent) { } // vertex - const plcio::DoubleThree& vertex = p.getVertex(); + const edm4hep::Vector3d& vertex = p.getVertex(); double t = p.getTime()*CLHEP::ns; G4PrimaryVertex* g4vtx = new G4PrimaryVertex(vertex.x*CLHEP::mm, vertex.y*CLHEP::mm, @@ -36,7 +36,7 @@ bool G4PrimaryCnvTool::mutate(G4Event* anEvent) { G4ParticleDefinition* particle_def = particletbl->FindParticle(pdgcode); // momentum - const plcio::FloatThree& momentum = p.getMomentum(); + const edm4hep::Vector3f& momentum = p.getMomentum(); G4PrimaryParticle* g4prim = new G4PrimaryParticle(particle_def, momentum.x*CLHEP::GeV, momentum.y*CLHEP::GeV, diff --git a/Simulation/DetSimCore/src/G4PrimaryCnvTool.h b/Simulation/DetSimCore/src/G4PrimaryCnvTool.h index 3aaf2997ceccd780f3b477809db33ba093d791b0..ed0fd4b5ba5453ad229d9e0981eced6e6036c9d4 100644 --- a/Simulation/DetSimCore/src/G4PrimaryCnvTool.h +++ b/Simulation/DetSimCore/src/G4PrimaryCnvTool.h @@ -5,8 +5,8 @@ #include "DetSimInterface/IG4PrimaryCnvTool.h" #include "FWCore/DataHandle.h" -#include "plcio/EventHeaderCollection.h" -#include "plcio/MCParticleCollection.h" +#include "edm4hep/EventHeaderCollection.h" +#include "edm4hep/MCParticleCollection.h" class G4PrimaryCnvTool: public extends<AlgTool, IG4PrimaryCnvTool> { public: @@ -16,7 +16,7 @@ public: bool mutate(G4Event* anEvent) override; private: - DataHandle<plcio::MCParticleCollection> m_mcParCol{"MCParticle", Gaudi::DataHandle::Reader, this}; + DataHandle<edm4hep::MCParticleCollection> m_mcParCol{"MCParticle", Gaudi::DataHandle::Reader, this}; };