diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenEventPileUpFillerTool.cxx b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenEventPileUpFillerTool.cxx index def7403bfb1cf4a91e4530228d43e42e266bbb5d..0d02c403b70a8361b7a622fe87a093c7a7b0b525 100644 --- a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenEventPileUpFillerTool.cxx +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenEventPileUpFillerTool.cxx @@ -66,12 +66,15 @@ namespace D3PD { /// pileUpType=5: dummy event used to separate types /// pileUpType=-1: not filled StatusCode GenEventPileUpFillerTool::fill( const HepMC::GenEvent& p ) { - +#ifdef HEPMC3 + *m_nparticle = p.particles().size(); +#else *m_nparticle = p.particles_size(); +#endif *m_pileUpType = -1; - if( ( p.event_number() == -1 ) && ( p.signal_process_id() == 0 ) ) { + if( ( p.event_number() == -1 ) && ( HepMC::signal_process_id(p) == 0 ) ) { *m_pileUpType = 5; return StatusCode::SUCCESS; } @@ -95,7 +98,7 @@ namespace D3PD { for( ;iter != end; ++iter ) { if( ( ( ( *iter )->event_number() == -1 ) && - ( ( *iter )->signal_process_id() == 0 ) ) ) { + ( HepMC::signal_process_id(( *iter )) == 0 ) ) ) { ++gotzero; } if( &p == *iter ) break; diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenParticleTruthParticleAssociationTool.cxx b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenParticleTruthParticleAssociationTool.cxx index 92e10d84989dfb8aa15997152d1749d814574fee..2020224a0f446fbb0577aa6662580f054a4810ed 100644 --- a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenParticleTruthParticleAssociationTool.cxx +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenParticleTruthParticleAssociationTool.cxx @@ -111,7 +111,7 @@ GenParticleTruthParticleAssociationTool::get (const HepMC::GenParticle& p) return 0; } - return m_container->truthParticle (p.barcode()); + return m_container->truthParticle (HepMC::barcode(p)); } diff --git a/PhysicsAnalysis/TruthParticleID/McParticleTools/src/EtaPtFilterTool.cxx b/PhysicsAnalysis/TruthParticleID/McParticleTools/src/EtaPtFilterTool.cxx index 6ece2481eea9030bb454985cccc02d0a28457331..37f031371e6e342188ef75f0532a8d0f423804c0 100755 --- a/PhysicsAnalysis/TruthParticleID/McParticleTools/src/EtaPtFilterTool.cxx +++ b/PhysicsAnalysis/TruthParticleID/McParticleTools/src/EtaPtFilterTool.cxx @@ -390,7 +390,7 @@ StatusCode EtaPtFilterTool::addVertex( const HepMC::GenVertex* srcVtx, HepMC::Ge bool EtaPtFilterTool::isFromHardScattering( const HepMC::GenVertex* vtx ) const { - if ( std::abs(vtx->barcode()) <= m_maxHardScatteringVtxBarcode.value() && + if ( std::abs(HepMC::barcode(vtx)) <= m_maxHardScatteringVtxBarcode.value() && m_ppFilter.isAccepted(vtx) && ! m_showerFilter.isAccepted(vtx) ) { diff --git a/Simulation/G4Utilities/MCTruthSimAlgs/src/NewMergeMcEventCollTool.cxx b/Simulation/G4Utilities/MCTruthSimAlgs/src/NewMergeMcEventCollTool.cxx index e5db164ce0fc68fbc0651474363deb9fb1a49081..877c514e4f59545ce6fdc54e1438c3b885e533a5 100644 --- a/Simulation/G4Utilities/MCTruthSimAlgs/src/NewMergeMcEventCollTool.cxx +++ b/Simulation/G4Utilities/MCTruthSimAlgs/src/NewMergeMcEventCollTool.cxx @@ -129,7 +129,7 @@ StatusCode NewMergeMcEventCollTool::processEvent(const McEventCollection *pMcEvt const HepMC::GenEvent& c_evt(*((*pMcEvtColl)[iEv])); #ifdef HEPMC3 HepMC::GenEvent * evt = new HepMC::GenEvent(c_evt); - for (auto itVer: evt->vertice()) { + for (auto itVer: evt->vertices()) { HepMC::FourVector newPos(itVer->position().x(),itVer->position().y(),itVer->position().z(),itVer->position().t()+timeOffset); itVer->set_position(newPos); } @@ -166,7 +166,8 @@ void NewMergeMcEventCollTool::printDetailsOfMergedMcEventCollection(McEventColle char fname[80]; sprintf(fname,"%s.event%d.txt",m_truthCollInputKey.value().c_str(),event_number); std::ofstream of(fname); - HepMC::Print::line(of,(*outputEventItr)); // verbose output + const HepMC::GenEvent *evt=(*outputEventItr); + HepMC::Print::line(of,*evt); // verbose output of.close(); ++outputEventItr; } diff --git a/Tracking/TrkValidation/TrkValTools/src/InDetReconstructableSelector.cxx b/Tracking/TrkValidation/TrkValTools/src/InDetReconstructableSelector.cxx index 5b7e11ba89d59693c2990b51d3a6522124c092b5..b913b975dc105b6dcd0149cd1ddca20d3978c058 100644 --- a/Tracking/TrkValidation/TrkValTools/src/InDetReconstructableSelector.cxx +++ b/Tracking/TrkValidation/TrkValTools/src/InDetReconstructableSelector.cxx @@ -11,7 +11,6 @@ #include "TrkValTools/InDetReconstructableSelector.h" #include "AtlasHepMC/GenVertex.h" -#include "CLHEP/Geometry/Point3D.h" #include "CLHEP/Units/SystemOfUnits.h" #include "HepPDT/ParticleData.hh" #include "GaudiKernel/IPartPropSvc.h" @@ -78,44 +77,41 @@ Trk::InDetReconstructableSelector::selectGenSignal (const McEventCollection* Sim for( ; itCollision != SimTracks->end(); ++itCollision ) { const HepMC::GenEvent* genEvent = *itCollision; - HepMC::GenParticle * particle = NULL; - for (HepMC::GenEvent::particle_const_iterator it = genEvent->particles_begin(); - it != genEvent->particles_end(); ++it) { + for ( auto particle: *genEvent) { - particle = *it; // 1) require stable particle from generation or simulation if ((particle->status()%1000) != 1 ) continue; if(particle->production_vertex() == NULL) { ATH_MSG_WARNING ("GenParticle without production vertex - simulation corrupt? "); - ATH_MSG_DEBUG ("It's this one: " << *particle); + ATH_MSG_DEBUG ("It's this one: " << particle); continue; } else { // 2) require track inside ID - relaxed definition including decays of neutrals (secondaries) - if ( fabs(particle->production_vertex()->position().perp()) > m_maxRStartAll || - fabs(particle->production_vertex()->position().z()) > m_maxZStartAll ) continue; + if ( std::abs(particle->production_vertex()->position().perp()) > m_maxRStartAll || + std::abs(particle->production_vertex()->position().z()) > m_maxZStartAll ) continue; // 3) if jobOption, require strict definition of particles from within beam pipe if ( m_selectPrimariesOnly && - ( fabs(particle->production_vertex()->position().perp()) > m_maxRStartPrimary || - fabs(particle->production_vertex()->position().z()) > m_maxZStartPrimary ) ) continue; + ( std::abs(particle->production_vertex()->position().perp()) > m_maxRStartPrimary || + std::abs(particle->production_vertex()->position().z()) > m_maxZStartPrimary ) ) continue; int pdgCode = particle->pdg_id(); - if (abs(pdgCode) > 1000000000 ) continue; // ignore nuclei from hadronic interactions + if (std::abs(pdgCode) > 1000000000 ) continue; // ignore nuclei from hadronic interactions const HepPDT::ParticleData* pd = m_particleDataTable->particle(abs(pdgCode)); if (!pd) { // nuclei excluded, still problems with a given type? - ATH_MSG_INFO ("Could not get particle data for particle with pdgCode="<<pdgCode<< ", status=" << particle->status() << ", barcode=" << particle->barcode()); - ATH_MSG_INFO ("GenParticle= " << *particle); + ATH_MSG_INFO ("Could not get particle data for particle with pdgCode="<<pdgCode<< ", status=" << particle->status() << ", barcode=" << HepMC::barcode(particle)); + ATH_MSG_INFO ("GenParticle= " << particle); continue; } float charge = pd->charge(); - if (fabs(charge)<0.5) continue; + if (std::abs(charge)<0.5) continue; - if (fabs(particle->momentum().perp()) > m_minPt && fabs(particle->momentum().pseudoRapidity()) < m_maxEta ) { + if (std::abs(particle->momentum().perp()) > m_minPt && std::abs(particle->momentum().pseudoRapidity()) < m_maxEta ) { genSignal->push_back(particle); } } diff --git a/Tracking/TrkValidation/TrkVertexFitterValidationTools/src/BasicVtxValidationNtupleTool.cxx b/Tracking/TrkValidation/TrkVertexFitterValidationTools/src/BasicVtxValidationNtupleTool.cxx index 00a281e5cf8604759891c563432ee30a2b466e5d..78ed3d248e82470925d3e8d5b6537752a00fb572 100755 --- a/Tracking/TrkValidation/TrkVertexFitterValidationTools/src/BasicVtxValidationNtupleTool.cxx +++ b/Tracking/TrkValidation/TrkVertexFitterValidationTools/src/BasicVtxValidationNtupleTool.cxx @@ -385,12 +385,15 @@ StatusCode Trk::BasicVtxValidationNtupleTool::fillTrueTrackAtVertexInfo(const Tr } else { TrackTruth trk_truth=found->second; - const HepMC::GenParticle * particle; - particle = trk_truth.particleLink(); - HepMC:: GenVertex* prod_vtx = particle->production_vertex(); + auto particle = trk_truth.particleLink(); + auto prod_vtx = particle->production_vertex(); //fill parent id +#ifdef HEPMC3 + auto parent_iter = prod_vtx->particles_in().begin(); +#else HepMC::GenVertex::particle_iterator parent_iter = prod_vtx->particles_begin(HepMC::parents); +#endif m_vxparent_id->push_back((*parent_iter)->pdg_id()); m_vxparticle_id->push_back(particle->pdg_id()); diff --git a/Trigger/TrigAnalysis/TrigInDetAnalysisExample/src/AnalysisConfig_Ntuple.cxx b/Trigger/TrigAnalysis/TrigInDetAnalysisExample/src/AnalysisConfig_Ntuple.cxx index 5166445fc35ecc6662550df6a4dda6cc928bf6c6..062f385fd6ec8899788a00485e73440b276b6d4d 100644 --- a/Trigger/TrigAnalysis/TrigInDetAnalysisExample/src/AnalysisConfig_Ntuple.cxx +++ b/Trigger/TrigAnalysis/TrigInDetAnalysisExample/src/AnalysisConfig_Ntuple.cxx @@ -84,9 +84,23 @@ const HepMC::GenParticle* fromParent( int pdg_id, const HepMC::GenParticle* p, b if (std::abs(p->pdg_id())==11 || std::abs(p->pdg_id())==13 ) return 0; //don't want light leptons from tau decays if ( std::abs(p->pdg_id())==pdg_id ) return p; /// recursive stopping conditions - const HepMC::GenVertex* vertex = p->production_vertex(); + auto vertex = p->production_vertex(); + if ( !vertex) return 0; // has no production vertex !!! +#ifdef HEPMC3 + if ( vertex->particles_in().size() < 1 ) return 0; /// recursive stopping conditions - if ( vertex==0 ) return 0; // has no production vertex !!! + if ( printout ) { + TruthParticle t(p); + } + + for ( auto in: vertex->particles_in()) { + auto parent = fromParent( pdg_id, in, printout ); + TruthParticle t(in); + if ( parent && std::abs(parent->pdg_id())==pdg_id) { + return parent; + } + } +#else if ( vertex->particles_in_size() < 1 ) return 0; /// recursive stopping conditions //if ( vertex->particles_in_size() > 1 ) std::cout << "more than 1 parent!!!" << std::endl; @@ -107,6 +121,7 @@ const HepMC::GenParticle* fromParent( int pdg_id, const HepMC::GenParticle* p, b } /// recursive stopping conditions in++; } +#endif return 0; }