diff --git a/Calorimeter/CaloLocalHadCalib/src/GetLCDeadMaterialTree.cxx b/Calorimeter/CaloLocalHadCalib/src/GetLCDeadMaterialTree.cxx index f66783db12c45e7ecd8cabd7e4eed77dcd205e92..b6e7a34868067f71a50387ee2ba41ad77a646d9b 100644 --- a/Calorimeter/CaloLocalHadCalib/src/GetLCDeadMaterialTree.cxx +++ b/Calorimeter/CaloLocalHadCalib/src/GetLCDeadMaterialTree.cxx @@ -222,8 +222,12 @@ StatusCode GetLCDeadMaterialTree::execute() ******************************************** */ const McEventCollection* truthEvent=nullptr; ATH_CHECK( evtStore()->retrieve(truthEvent, "TruthEvent") ); +#ifdef HEPMC3 + HepMC::ConstGenParticlePtr gen = truthEvent->at(0)->particles().front(); +#else HepMC::GenEvent::particle_const_iterator pit = truthEvent->at(0)->particles_begin(); const HepMC::GenParticle * gen = *pit; +#endif double mc_eta = gen->momentum().pseudoRapidity(); double mc_phi = gen->momentum().phi(); diff --git a/Calorimeter/CaloLocalHadCalib/src/GetLCSinglePionsPerf.cxx b/Calorimeter/CaloLocalHadCalib/src/GetLCSinglePionsPerf.cxx index 5f576ea4470c0024a09512e0d1ac86f3d415778d..02428e9727cc282f55d09a43765fa1d5b848a75b 100644 --- a/Calorimeter/CaloLocalHadCalib/src/GetLCSinglePionsPerf.cxx +++ b/Calorimeter/CaloLocalHadCalib/src/GetLCSinglePionsPerf.cxx @@ -679,6 +679,13 @@ StatusCode GetLCSinglePionsPerf::execute() ******************************************** */ const McEventCollection* truthEvent=nullptr; ATH_CHECK( evtStore()->retrieve(truthEvent, "TruthEvent") ); +#ifdef HEPMC3 + if( truthEvent->at(0)->particles().empty() ){ + ATH_MSG_ERROR( "No particles in McEventCollection" ); + return StatusCode::FAILURE; + } + HepMC::ConstGenParticlePtr gen=truthEvent->at(0)->particles().front(); +#else if( truthEvent->at(0)->particles_empty() ){ ATH_MSG_ERROR( "No particles in McEventCollection" ); return StatusCode::FAILURE; @@ -686,6 +693,7 @@ StatusCode GetLCSinglePionsPerf::execute() // primary particle info HepMC::GenEvent::particle_const_iterator pit = truthEvent->at(0)->particles_begin(); const HepMC::GenParticle *gen = (*pit); +#endif m_mc_eta = gen->momentum().pseudoRapidity(); m_mc_phi = gen->momentum().phi(); m_mc_ener = gen->momentum().e(); diff --git a/MuonSpectrometer/MuonValidation/MuonPRDTest/src/TruthVariables.cxx b/MuonSpectrometer/MuonValidation/MuonPRDTest/src/TruthVariables.cxx index c93e1db106c6ab294d3874245304c83da80bee8e..da776767426dfce3e159d2dab09ace6077a0cf5f 100644 --- a/MuonSpectrometer/MuonValidation/MuonPRDTest/src/TruthVariables.cxx +++ b/MuonSpectrometer/MuonValidation/MuonPRDTest/src/TruthVariables.cxx @@ -27,11 +27,14 @@ StatusCode TruthVariables::fillVariables(const MuonGM::MuonDetectorManager* Muon unsigned int nSubEvents = 0; for(auto it : *truthContainer) { const HepMC::GenEvent *subEvent = it; - +#ifdef HEPMC3 + for(auto vertex : subEvent->vertices()) { +#else // Vertex HepMC::ConstGenEventVertexRange vertex_range = subEvent->vertex_range(); for(auto vit : vertex_range) { const HepMC::GenVertex *vertex = vit; +#endif const HepMC::FourVector position = vertex->position(); m_Truth_vertexX->push_back(position.x()); m_Truth_vertexY->push_back(position.y()); @@ -41,10 +44,14 @@ StatusCode TruthVariables::fillVariables(const MuonGM::MuonDetectorManager* Muon m_Truth_nVertices++; } +#ifdef HEPMC3 + for(auto particle : subEvent->particles()) { +#else // Particle HepMC::ConstGenEventParticleRange particle_range = subEvent->particle_range(); for(auto pit : particle_range) { const HepMC::GenParticle *particle = pit; +#endif const HepMC::FourVector momentum = particle->momentum(); m_Truth_particlePt->push_back(momentum.perp()); m_Truth_particleEta->push_back(momentum.eta()); @@ -53,10 +60,10 @@ StatusCode TruthVariables::fillVariables(const MuonGM::MuonDetectorManager* Muon m_Truth_particleM->push_back(momentum.m()); m_Truth_particlePdg_id->push_back(particle->pdg_id()); m_Truth_particleStatus->push_back(particle->status()); - m_Truth_particleBarcode->push_back(particle->barcode()); - HepMC::GenVertex* production_vertex = particle->production_vertex(); + m_Truth_particleBarcode->push_back(HepMC::barcode(particle)); + auto production_vertex = particle->production_vertex(); m_Truth_particleProduction_vertex_id->push_back(production_vertex ? production_vertex->id() : -1); - HepMC::GenVertex* end_vertex = particle->end_vertex(); + auto end_vertex = particle->end_vertex(); m_Truth_particleEnd_vertex_id->push_back(end_vertex ? end_vertex->id() : -1); m_Truth_nParticles++; } diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenEventGetterFilterTool.cxx b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenEventGetterFilterTool.cxx index 207d15cd1a3cae923c7550e70c60b45f4e373fc9..978365b30056a6af9ad62cb81c51c6dfb41359d2 100644 --- a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenEventGetterFilterTool.cxx +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenEventGetterFilterTool.cxx @@ -38,7 +38,11 @@ GenEventGetterFilterTool::GenEventGetterFilterTool */ bool GenEventGetterFilterTool::filter (const HepMC::GenEvent* p) const { +#ifdef HEPMC3 + return ! p->particles().empty(); +#else return ! p->particles_empty(); +#endif }