diff --git a/Calorimeter/CaloExample/CaloTests/src/MyAnalysis.cxx b/Calorimeter/CaloExample/CaloTests/src/MyAnalysis.cxx index bbafed3e8f5f69a018b1bcd826f27368980872f4..c00338a04af68add8ae083739f09ed357973606a 100644 --- a/Calorimeter/CaloExample/CaloTests/src/MyAnalysis.cxx +++ b/Calorimeter/CaloExample/CaloTests/src/MyAnalysis.cxx @@ -612,12 +612,10 @@ namespace MyAnalysis { McEventCollection::const_iterator itr; for (itr = mcCollptr->begin(); itr!=mcCollptr->end(); ++itr) { - HepMC::GenEvent::particle_const_iterator itrPart; - for (itrPart = (*itr)->particles_begin(); itrPart!=(*itr)->particles_end(); ++itrPart ) + for (auto part: *(*itr)) { - HepMC::GenParticle *part=*itrPart; - if( (abs(part->pdg_id())==11 || part->pdg_id()==22 || part->pdg_id()==13 - || (abs(part->pdg_id())==211) ) + if( (std::abs(part->pdg_id())==11 || part->pdg_id()==22 || part->pdg_id()==13 + || (std::abs(part->pdg_id())==211) ) && part->momentum().e()> 5000.) { nn++; @@ -627,7 +625,7 @@ namespace MyAnalysis { phi_true = part->momentum().phi(); ATH_MSG_INFO( " true particle found " << part->pdg_id() << " " << e_true << " " << eta_true << " " << phi_true ); - HepMC::GenVertex* vertex = part->end_vertex(); + auto vertex = part->end_vertex(); if (vertex) { m_xconv = vertex->position().x(); m_yconv = vertex->position().y(); diff --git a/ForwardDetectors/ALFA/ALFA_Reconstruction/ALFA_GloRec/src/ALFA_GloRec.cxx b/ForwardDetectors/ALFA/ALFA_Reconstruction/ALFA_GloRec/src/ALFA_GloRec.cxx index 2dac1d0c7d653f08cbe0539d757bc0f007f093d7..f4f104249c1f53e610c8b81fb6781da50f03a507 100644 --- a/ForwardDetectors/ALFA/ALFA_Reconstruction/ALFA_GloRec/src/ALFA_GloRec.cxx +++ b/ForwardDetectors/ALFA/ALFA_Reconstruction/ALFA_GloRec/src/ALFA_GloRec.cxx @@ -342,22 +342,18 @@ StatusCode ALFA_GloRec::Truth_info(){ //loop over collection (container) with hits (i.e. over 1 event) for(;mcTruBeg!=mcTruEnd;++mcTruBeg){ - - HepMC::GenEvent::particle_const_iterator begGenItr = (**mcTruBeg).particles_begin(); - HepMC::GenEvent::particle_const_iterator endGenItr = (**mcTruBeg).particles_end(); //loop over one event m_z_g_pos = -1.e10; m_z_g_neg = 1.e10; - for(int i = 0;begGenItr!=endGenItr;++begGenItr){ - //if(((*begGenItr)->status()==1)&&((abs((*begGenItr)->pdg_id())==2212)||(abs((*begGenItr)->pdg_id())==211))){ - if(((abs((*begGenItr)->pdg_id())==2212)||(abs((*begGenItr)->pdg_id())==211))){ + for(auto begGen: (**mcTruBeg)){ + if(((std::abs(begGen->pdg_id())==2212)||(std::abs(begGen->pdg_id())==211))){ double px, py, pz; double x, y, z; - px = (**begGenItr).momentum().px(); - py = (**begGenItr).momentum().py(); - pz = (**begGenItr).momentum().pz(); - HepMC::GenVertex * l_prodvert = (**begGenItr).production_vertex(); + px = begGen->momentum().px(); + py = begGen->momentum().py(); + pz = begGen->momentum().pz(); + auto l_prodvert = begGen->production_vertex(); x = l_prodvert->position().x(); y = l_prodvert->position().y(); z = l_prodvert->position().z(); @@ -379,7 +375,6 @@ StatusCode ALFA_GloRec::Truth_info(){ continue; } - i++; // ... break the loop if both suitable vertices were found if (m_z_g_pos > 0. && m_z_g_neg < 0.){ msg(MSG::DEBUG) << "gen px, py, pz = " << m_px_g_pos << " " << m_py_g_pos << " " << m_pz_g_pos << endmsg;