diff --git a/Event/xAOD/xAODTruthCnv/src/HepMCTruthReader.cxx b/Event/xAOD/xAODTruthCnv/src/HepMCTruthReader.cxx index 63e6a7e50bfac8b466acdcdf6e0102420597167c..bb5b253bb65c2eb86278aa17c086998e27db3f4c 100644 --- a/Event/xAOD/xAODTruthCnv/src/HepMCTruthReader.cxx +++ b/Event/xAOD/xAODTruthCnv/src/HepMCTruthReader.cxx @@ -217,7 +217,7 @@ void HepMCTruthReader::printParticle(const HepMC::GenParticlePtr particle) { cout << particle->momentum().e() << " "; cout.setf(ios::fmtflags(0), ios::floatfield); cout.unsetf(ios_base::showpos); - if ( particle->has_decayed() ) { + if ( particle->status()==2 ) { if ( HepMC::barcode(particle->end_vertex())!=0 ) { cout.width(3); cout << particle->status() << " "; diff --git a/Event/xAOD/xAODTruthCnv/src/xAODTruthCnvAlg.cxx b/Event/xAOD/xAODTruthCnv/src/xAODTruthCnvAlg.cxx index be134d9c472abea3952950efb5e1e2d3aca1d96d..6a3698116ebbbb21f2f3c51db4daaf87d5774020 100644 --- a/Event/xAOD/xAODTruthCnv/src/xAODTruthCnvAlg.cxx +++ b/Event/xAOD/xAODTruthCnv/src/xAODTruthCnvAlg.cxx @@ -269,7 +269,9 @@ namespace xAODMaker { // Get the beam particles pair<HepMC::GenParticlePtr,HepMC::GenParticlePtr> beamParticles; - if ( genEvt->valid_beam_particles() ) beamParticles = genEvt->beam_particles(); + bool genEvt_valid_beam_particles=false; + genEvt_valid_beam_particles=genEvt->valid_beam_particles(); + if ( genEvt_valid_beam_particles ) beamParticles = genEvt->beam_particles(); for (HepMC::GenEvent::particle_const_iterator pitr=genEvt->particles_begin(); pitr!=genEvt->particles_end(); ++pitr) { // (a) create TruthParticle xAOD::TruthParticle* xTruthParticle = new xAOD::TruthParticle(); @@ -285,7 +287,7 @@ namespace xAODMaker { if (!isSignalProcess) truthLinkVec->push_back(new xAODTruthParticleLink(HepMcParticleLink((*pitr),genEvt->event_number()), eltp)); // Is this one of the beam particles? - if (genEvt->valid_beam_particles()) { + if (genEvt_valid_beam_particles) { if (isSignalProcess) { if (*pitr == beamParticles.first) xTruthEvent->setBeamParticle1Link(eltp); if (*pitr == beamParticles.second) xTruthEvent->setBeamParticle2Link(eltp); diff --git a/Generators/AtlasHepMC/AtlasHepMC/GenVertex.h b/Generators/AtlasHepMC/AtlasHepMC/GenVertex.h index d34899f96f78c29a21d64d685086b26997ece045..2130d84475ecf36d765e87adb11022d78bf7d954 100644 --- a/Generators/AtlasHepMC/AtlasHepMC/GenVertex.h +++ b/Generators/AtlasHepMC/AtlasHepMC/GenVertex.h @@ -41,10 +41,11 @@ inline void* raw_pointer(GenVertexPtr p){ return p.get();} #include "HepMC/GenVertex.h" namespace HepMC { typedef HepMC::GenVertex* GenVertexPtr; -typedef HepMC::GenVertex* ConstGenVertexPtr; +typedef HepMC::GenVertex* const ConstGenVertexPtr; inline GenVertexPtr newGenVertexPtr(const HepMC::FourVector &pos = HepMC::FourVector(0.0,0.0,0.0,0.0), const int i=0) { return new HepMC::GenVertex(pos,i); } +inline int barcode(ConstGenVertexPtr p){ return p->barcode();} } #endif #endif diff --git a/Generators/BoostAfterburner/src/BoostEvent.cxx b/Generators/BoostAfterburner/src/BoostEvent.cxx index fe526bb814a898b0c552cf8909666902fecaaa03..7fe551b3cb775a4ef546001b6aa77af606981192 100644 --- a/Generators/BoostAfterburner/src/BoostEvent.cxx +++ b/Generators/BoostAfterburner/src/BoostEvent.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #include "BoostAfterburner/BoostEvent.h" @@ -60,25 +60,24 @@ StatusCode BoostEvent::execute() for (McEventCollection::iterator itr = output_collection->begin(); itr!=output_collection->end(); itr++) { - for ( HepMC::GenEvent::particle_iterator particleItr = (*itr)->particles_begin(); - particleItr != (*itr)->particles_end(); particleItr++ ) { - CLHEP::HepLorentzVector momentum((*particleItr)->momentum().px(), - (*particleItr)->momentum().py(), - (*particleItr)->momentum().pz(), - (*particleItr)->momentum().e()); + for ( auto particle: **itr){ + CLHEP::HepLorentzVector momentum(particle->momentum().px(), + particle->momentum().py(), + particle->momentum().pz(), + particle->momentum().e()); momentum.boost(m_beta_x,m_beta_y,m_beta_z); - msg(MSG::VERBOSE) << std::setw(10) << (*particleItr)->momentum().perp() - << std::setw(10) << (*particleItr)->momentum().e() - << std::setw(10) << (*particleItr)->momentum().eta() - << std::setw(10) << (*particleItr)->momentum().phi() + msg(MSG::VERBOSE) << std::setw(10) << particle->momentum().perp() + << std::setw(10) << particle->momentum().e() + << std::setw(10) << particle->momentum().eta() + << std::setw(10) << particle->momentum().phi() << std::setw(10) << momentum.perp() << std::setw(10) << momentum.e() << std::setw(10) << momentum.eta() << std::setw(10) << momentum.phi() << endmsg; - (*particleItr)->set_momentum( HepMC::FourVector(momentum.px(),momentum.py(),momentum.pz(),momentum.e()) ); + particle->set_momentum( HepMC::FourVector(momentum.px(),momentum.py(),momentum.pz(),momentum.e()) ); } } diff --git a/Generators/Epos_i/src/Epos.cxx b/Generators/Epos_i/src/Epos.cxx index f8308215ac31dd459527de159964906a0fcb6da8..e265133b45bb4bef251f87c1191eb59e33ceefcf 100644 --- a/Generators/Epos_i/src/Epos.cxx +++ b/Generators/Epos_i/src/Epos.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ // ---------------------------------------------------------------------- @@ -260,22 +260,6 @@ StatusCode Epos::callGenerator() crmc_f_( m_iout, m_ievent ,nParticles, impactParameter, m_partID[0], m_partPx[0], m_partPy[0], m_partPz[0], m_partEnergy[0], m_partMass[0], m_partStat[0] ); - // std::cout << "events " << m_events << " " << m_ievent << std::endl; - // HepMC::HEPEVT_Wrapper::print_hepevt(); - - /* for (int i=1;i<=50;++i){ - std::cout << "wrapper gen " << i << " " << HepMC::HEPEVT_Wrapper::number_entries() << " " << HepMC::HEPEVT_Wrapper::px(i)<<" " << - HepMC::HEPEVT_Wrapper::py(i) << " " << HepMC::HEPEVT_Wrapper::pz(i) << " " << HepMC::HEPEVT_Wrapper::e(i) << " " << HepMC::HEPEVT_Wrapper::m(i) << " " << HepMC::HEPEVT_Wrapper::id(i) << " " << HepMC::HEPEVT_Wrapper::status(i) << std::endl; - }*/ - - - // debug printout - /* std::cout << "parameters "<< m_iout << " " << m_ievent << " " << impactParameter << std::endl; - std::cout << "n particles " << nParticles << std::endl; - for (int i=0; i<nParticles; i++){ - std::cout << "part " << i << " " << m_partID[i] << " " << m_partStat[i] << std::endl; - std::cout << "part x " << m_partPx[i]<< " " << m_partPy[i] << " " << m_partPz[i] << " " << m_partEnergy[i] <<" " << m_partMass[i] << std::endl; - }*/ diff --git a/Generators/EvgenProdTools/src/SimTimeEstimate.cxx b/Generators/EvgenProdTools/src/SimTimeEstimate.cxx index c45a2aa3487bfea3a15ba1b0d6f9009e3b92184a..1a3d6f223b6e57bb23369f5aaca45797d5f0e085 100644 --- a/Generators/EvgenProdTools/src/SimTimeEstimate.cxx +++ b/Generators/EvgenProdTools/src/SimTimeEstimate.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #ifndef XAOD_ANALYSIS @@ -28,19 +28,19 @@ StatusCode SimTimeEstimate::execute() m_particleEtas.clear(); m_particleEnergies.clear(); // Check particles - for (HepMC::GenEvent::particle_const_iterator pitr = itr->particles_begin(); pitr != itr->particles_end(); ++pitr ) + for (auto part: *itr) { // Only use stable particles - if ((*pitr)->status()!=1) continue; + if (part->status()!=1) continue; // Only use particles that are interacting - if (!(MC::isSimInteracting(*pitr))) continue; + if (!(MC::isSimInteracting(part))) continue; // Grab the momentum - const HepMC::FourVector pmom = (*pitr)->momentum(); + const HepMC::FourVector pmom = part->momentum(); // Only count particles with finite eta if (pmom.perp()==0 || fabs(pmom.eta())>m_etaMax) continue; m_particleEtas.push_back(pmom.eta()); // add ID of particle to list - m_particleIDs.push_back(abs((*pitr)->pdg_id())); + m_particleIDs.push_back(abs(part->pdg_id())); // add energy per particle to get the distribution: m_particleEnergies.push_back(pmom.e()); @@ -50,7 +50,7 @@ StatusCode SimTimeEstimate::execute() // it decays. This algorithm will always be a little tricky // in those cases, but better to *overestimate* the sim time. - if(std::find(m_pidsToSkip.begin(), m_pidsToSkip.end(), abs((*pitr)->pdg_id())) != m_pidsToSkip.end()) continue; + if(std::find(m_pidsToSkip.begin(), m_pidsToSkip.end(), abs(part->pdg_id())) != m_pidsToSkip.end()) continue; // Add in the total energy m_total_Energy += pmom.e(); m_eventEnergy += pmom.e(); diff --git a/Generators/Rivet_i/src/Rivet_i.cxx b/Generators/Rivet_i/src/Rivet_i.cxx index 515e1fd366bba95ce9ded7327cff950e44c16980..ed05856340f3666ddea37dcf607b980b14591695 100644 --- a/Generators/Rivet_i/src/Rivet_i.cxx +++ b/Generators/Rivet_i/src/Rivet_i.cxx @@ -225,7 +225,7 @@ StatusCode Rivet_i::finalize() { /// Helper function to sort GenParticles by descending energy /// @todo Move into GeneratorUtils (with many friends) -bool cmpGenParticleByEDesc(const HepMC::GenParticle* a, const HepMC::GenParticle* b) { +bool cmpGenParticleByEDesc(const HepMC::GenParticlePtr a, const HepMC::GenParticlePtr b) { return a->momentum().e() > b->momentum().e(); } @@ -239,7 +239,7 @@ inline std::vector<std::string> split(const std::string& input, const std::strin } const HepMC::GenEvent* Rivet_i::checkEvent(const HepMC::GenEvent* event) { - std::vector<HepMC::GenParticle*> beams; + std::vector<HepMC::GenParticlePtr> beams; HepMC::GenEvent* modEvent = new HepMC::GenEvent(*event); // overwrite the HEPMC dummy event number with the proper ATLAS event number diff --git a/Generators/Rivet_i/src/Rivet_i.h b/Generators/Rivet_i/src/Rivet_i.h index 852c9b626cd799556371108ec10b6f50f7dec628..37143176d27d26a9905a8516dc5decfc24d6db36 100644 --- a/Generators/Rivet_i/src/Rivet_i.h +++ b/Generators/Rivet_i/src/Rivet_i.h @@ -9,6 +9,7 @@ #include "GaudiKernel/ServiceHandle.h" #include "Rivet/AnalysisHandler.hh" +#include "AtlasHepMC/GenEvent.h" #include <vector> #include <string>