From 6bd9c4aa9b8f6e0aeede42e7f9bb88dca88ad92e Mon Sep 17 00:00:00 2001 From: scott snyder Date: Mon, 4 Nov 2019 06:52:41 +0100 Subject: [PATCH 1/3] TruthD3PDAnalysis: Remove use of BOOST_FOREACH. Change to range-based for. --- .../src/TruthParticleFilterBase.cxx | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDAnalysis/src/TruthParticleFilterBase.cxx b/PhysicsAnalysis/D3PDMaker/TruthD3PDAnalysis/src/TruthParticleFilterBase.cxx index c4b0209eb9f..242273eecb6 100644 --- a/PhysicsAnalysis/D3PDMaker/TruthD3PDAnalysis/src/TruthParticleFilterBase.cxx +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDAnalysis/src/TruthParticleFilterBase.cxx @@ -1,8 +1,6 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ - -// $Id$ /** * @file TruthD3PDAnalysis/src/TruthParticleFilterBase.cxx * @author scott snyder @@ -19,7 +17,7 @@ #include "HepMC/GenEvent.h" #include "HepMC/GenVertex.h" #include "HepMC/GenParticle.h" -#include "boost/foreach.hpp" +#include "boost/range/iterator_range_core.hpp" #include @@ -139,7 +137,7 @@ TruthParticleFilterBase::buildMcAod (const McEventCollection* mc_in, { // Loop over GenEvent's. mc_out->reserve (mc_in->size()); - BOOST_FOREACH (const HepMC::GenEvent* ev_in, *mc_in) { + for (const HepMC::GenEvent* ev_in : *mc_in) { if (!ev_in) continue; // Copy the GenEvent. @@ -180,7 +178,7 @@ TruthParticleFilterBase::filterEvent (const HepMC::GenEvent* ev_in, HepMC::GenEvent* ev_out) { // Loop over particles. - // (FOREACH doesn't work here because particle_const_iterator + // (range-based for doesn't work here because particle_const_iterator // isn't consistent in the use of const...) for (HepMC::GenEvent::particle_const_iterator ip = ev_in->particles_begin(); ip != ev_in->particles_end(); @@ -255,18 +253,18 @@ TruthParticleFilterBase::addVertex (const HepMC::GenVertex* v, ev->add_vertex (vnew); // Fill in the existing relations of the new vertex. - BOOST_FOREACH(const HepMC::GenParticle* p, - std::make_pair (v->particles_in_const_begin(), - v->particles_in_const_end())) + for (const HepMC::GenParticle* p : + boost::make_iterator_range (v->particles_in_const_begin(), + v->particles_in_const_end())) { HepMC::GenParticle* pnew = ev->barcode_to_particle (p->barcode()); if (pnew) vnew->add_particle_in (pnew); } - BOOST_FOREACH(const HepMC::GenParticle* p, - std::make_pair (v->particles_out_const_begin(), - v->particles_out_const_end())) + for (const HepMC::GenParticle* p : + boost::make_iterator_range (v->particles_out_const_begin(), + v->particles_out_const_end())) { HepMC::GenParticle* pnew = ev->barcode_to_particle (p->barcode()); if (pnew) -- GitLab From 9b433dc69f32adfee510a1485ffad1d57ac2038a Mon Sep 17 00:00:00 2001 From: scott snyder Date: Mon, 4 Nov 2019 06:56:58 +0100 Subject: [PATCH 2/3] TruthD3PDMaker: Remove use of BOOST_FOREACH. Change to range-based for. --- .../TruthD3PDMaker/src/TruthJetFilterTool.cxx | 22 +++++++++---------- .../src/TruthLeptonParentAssociationTool.cxx | 7 ++---- .../src/TruthTauDecayAssociationTool.cxx | 8 +++---- 3 files changed, 15 insertions(+), 22 deletions(-) diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthJetFilterTool.cxx b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthJetFilterTool.cxx index 88b58d71261..43ecda7e372 100644 --- a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthJetFilterTool.cxx +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthJetFilterTool.cxx @@ -1,8 +1,6 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ - -// $Id$ /** * @file TruthD3PDMaker/src/TruthJetFilterTool.cxx * @author Renaud Bruneliere @@ -18,7 +16,7 @@ #include "HepMC/GenVertex.h" #include "HepMC/GenParticle.h" #include "CLHEP/Vector/LorentzVector.h" -#include "boost/foreach.hpp" +#include "boost/range/iterator_range_core.hpp" #include @@ -174,7 +172,7 @@ TruthJetFilterTool::buildMcAod (const McEventCollection* mc_in, { // Loop over GenEvent's. mc_out->reserve (mc_in->size()); - BOOST_FOREACH (const HepMC::GenEvent* ev_in, *mc_in) { + for (const HepMC::GenEvent* ev_in : *mc_in) { if (!ev_in) continue; // Copy the GenEvent. @@ -215,7 +213,7 @@ TruthJetFilterTool::filterEvent (const HepMC::GenEvent* ev_in, HepMC::GenEvent* ev_out) { // Loop over particles. - // (FOREACH doesn't work here because particle_const_iterator + // (range-based for doesn't work here because particle_const_iterator // isn't consistent in the use of const...) for (HepMC::GenEvent::particle_const_iterator ip = ev_in->particles_begin(); ip != ev_in->particles_end(); @@ -290,18 +288,18 @@ TruthJetFilterTool::addVertex (const HepMC::GenVertex* v, ev->add_vertex (vnew); // Fill in the existing relations of the new vertex. - BOOST_FOREACH(const HepMC::GenParticle* p, - std::make_pair (v->particles_in_const_begin(), - v->particles_in_const_end())) + for (const HepMC::GenParticle* p : + boost::make_iterator_range (v->particles_in_const_begin(), + v->particles_in_const_end())) { HepMC::GenParticle* pnew = ev->barcode_to_particle (p->barcode()); if (pnew) vnew->add_particle_in (pnew); } - BOOST_FOREACH(const HepMC::GenParticle* p, - std::make_pair (v->particles_out_const_begin(), - v->particles_out_const_end())) + for (const HepMC::GenParticle* p : + boost::make_iterator_range (v->particles_out_const_begin(), + v->particles_out_const_end())) { HepMC::GenParticle* pnew = ev->barcode_to_particle (p->barcode()); if (pnew) diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthLeptonParentAssociationTool.cxx b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthLeptonParentAssociationTool.cxx index c9df3d75bac..f2b8d9f27f0 100644 --- a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthLeptonParentAssociationTool.cxx +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthLeptonParentAssociationTool.cxx @@ -1,8 +1,6 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ - -// $Id: /** * @file TruthD3PDMaker/src/TruthLeptonParentAssociationTool.cxx * @author Zach Marshall @@ -18,7 +16,6 @@ #include "McParticleEvent/TruthParticle.h" #include "McParticleEvent/TruthParticleContainer.h" #include "GeneratorObjects/McEventCollection.h" -#include "boost/foreach.hpp" #include "HepPID/ParticleIDMethods.hh" #include @@ -59,7 +56,7 @@ TruthLeptonParentAssociationTool::reset (const TruthParticle& p) const DataHandle mcec; if (evtStore()->retrieve(mcec,"GEN_EVENT").isSuccess()){ // Always run on EVGEN anyway... // Loop over GenEvent's. - BOOST_FOREACH (const HepMC::GenEvent* ev_in, *mcec) { + for (const HepMC::GenEvent* ev_in : *mcec) { if (!ev_in) continue; for (HepMC::GenEvent::particle_const_iterator itrPart = ev_in->particles_begin(); itrPart!=ev_in->particles_end();++itrPart){ diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthTauDecayAssociationTool.cxx b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthTauDecayAssociationTool.cxx index f09fc72ba31..f4a2d27f19d 100644 --- a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthTauDecayAssociationTool.cxx +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthTauDecayAssociationTool.cxx @@ -1,8 +1,6 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ - -// $Id: /** * @file TruthD3PDMaker/src/TruthTauDecayAssociationTool.cxx * @author Zach Marshall @@ -18,7 +16,7 @@ #include "McParticleEvent/TruthParticle.h" #include "McParticleEvent/TruthParticleContainer.h" #include "GeneratorObjects/McEventCollection.h" -#include "boost/foreach.hpp" + namespace D3PD { @@ -52,7 +50,7 @@ TruthTauDecayAssociationTool::reset (const TruthParticle& p) const DataHandle mcec; if (evtStore()->retrieve(mcec,"GEN_EVENT").isSuccess()){ // Loop over GenEvent's. - BOOST_FOREACH (const HepMC::GenEvent* ev_in, *mcec) { + for (const HepMC::GenEvent* ev_in : *mcec) { if (!ev_in) continue; for (HepMC::GenEvent::particle_const_iterator itrPart = ev_in->particles_begin(); itrPart!=ev_in->particles_end();++itrPart){ -- GitLab From 499c8222ef1cd899e1a090de351c2186bc5b3e90 Mon Sep 17 00:00:00 2001 From: scott snyder Date: Mon, 4 Nov 2019 07:00:39 +0100 Subject: [PATCH 3/3] MuonCalibrationFit: Remove use of BOOST_FOREACH. Change to range-based for. --- .../MuonCalibrationFit/MuonCalibrationFit.h | 3 +-- .../src/MuonCalibrationFit.cxx | 26 +++++++++---------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonCalibrationFit/MuonCalibrationFit/MuonCalibrationFit.h b/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonCalibrationFit/MuonCalibrationFit/MuonCalibrationFit.h index 253615af306..6e3a2f9279d 100644 --- a/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonCalibrationFit/MuonCalibrationFit/MuonCalibrationFit.h +++ b/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonCalibrationFit/MuonCalibrationFit/MuonCalibrationFit.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #ifndef MuonCalibrationFit_h @@ -41,7 +41,6 @@ #include #include -#include #include #include "MuonCalibrationFit/Regions.h" diff --git a/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonCalibrationFit/src/MuonCalibrationFit.cxx b/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonCalibrationFit/src/MuonCalibrationFit.cxx index c82bf8b1a14..6c27d9997a2 100644 --- a/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonCalibrationFit/src/MuonCalibrationFit.cxx +++ b/PhysicsAnalysis/MuonID/MuonPerformanceAnalysis/MuonCalibrationFit/src/MuonCalibrationFit.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #include "MuonCalibrationFit/MuonCalibrationFit.h" @@ -366,27 +366,27 @@ double MuonCalibrationFit::GetChiSquare( const double* par ) { void MuonCalibrationFit::DoMonitoringPlots( const double* par ) { //::: Data std::vector< std::string > names = m_CurrentTemplate->GetMonitoredVariables(); - BOOST_FOREACH( Tools::Info theInfo, *m_DataSingleInfo ) { + for( Tools::Info theInfo : *m_DataSingleInfo ) { for( auto name: names ) { m_CurrentTemplate->FillMonitoredVariable( Type::Data, name, theInfo.GetFirst( name ), std::max( theInfo.First_Mu_pt, theInfo.Second_Mu_pt ), theInfo.GetMass(), theInfo.IsOS, 1, true ); m_CurrentTemplate->FillMonitoredVariable( Type::Data, name, theInfo.GetSecond( name ), std::max( theInfo.First_Mu_pt, theInfo.Second_Mu_pt ), theInfo.GetMass(), theInfo.IsOS, 1, false ); } } - BOOST_FOREACH( Tools::Info theInfo, *m_DataBothInfo ) { + for( Tools::Info theInfo : *m_DataBothInfo ) { for( auto name: names ) { m_CurrentTemplate->FillMonitoredVariable( Type::Data, name, theInfo.GetFirst( name ), std::max( theInfo.First_Mu_pt, theInfo.Second_Mu_pt ), theInfo.GetMass(), theInfo.IsOS, 1, true ); m_CurrentTemplate->FillMonitoredVariable( Type::Data, name, theInfo.GetSecond( name ), std::max( theInfo.First_Mu_pt, theInfo.Second_Mu_pt ), theInfo.GetMass(), theInfo.IsOS, 1, true ); } } //::: Background - BOOST_FOREACH( Tools::Info theInfo, *m_BackgroundSingleInfo ) { + for( Tools::Info theInfo : *m_BackgroundSingleInfo ) { if( ! theInfo.IsOS ) continue; for( auto name: names ) { m_CurrentTemplate->FillMonitoredVariable( Type::Background, name, theInfo.GetFirst( name ), std::max( theInfo.First_Mu_pt, theInfo.Second_Mu_pt ), theInfo.GetMass(), theInfo.IsOS, theInfo.Weight, true ); m_CurrentTemplate->FillMonitoredVariable( Type::Background, name, theInfo.GetSecond( name ), std::max( theInfo.First_Mu_pt, theInfo.Second_Mu_pt ), theInfo.GetMass(), theInfo.IsOS, theInfo.Weight, false ); } } - BOOST_FOREACH( Tools::Info theInfo, *m_BackgroundBothInfo ) { + for( Tools::Info theInfo : *m_BackgroundBothInfo ) { if( ! theInfo.IsOS ) continue; for( auto name: names ) { m_CurrentTemplate->FillMonitoredVariable( Type::Background, name, theInfo.GetFirst( name ), std::max( theInfo.First_Mu_pt, theInfo.Second_Mu_pt ), theInfo.GetMass(), theInfo.IsOS, theInfo.Weight, true ); @@ -396,7 +396,7 @@ void MuonCalibrationFit::DoMonitoringPlots( const double* par ) { //::: MonteCarlo //::: Single Muon Correction TRandom3 rand_gen( 2988100123 ); - BOOST_FOREACH( Tools::Info theInfo, *m_MonteCarloSingleInfo ) { + for( Tools::Info theInfo : *m_MonteCarloSingleInfo ) { if( ! theInfo.IsOS ) continue; double rnd = rand_gen.Gaus( 0, 1 ); for( auto name: names ) { @@ -405,7 +405,7 @@ void MuonCalibrationFit::DoMonitoringPlots( const double* par ) { } } //::: Double Muon Correction - BOOST_FOREACH( Tools::Info theInfo, *m_MonteCarloBothInfo ) { + for( Tools::Info theInfo : *m_MonteCarloBothInfo ) { if( ! theInfo.IsOS ) continue; double rnd1 = rand_gen.Gaus( 0, 1 ); double rnd2 = rand_gen.Gaus( 0, 1 ); @@ -921,7 +921,7 @@ void MuonCalibrationFit::UpdateTemplates( const double* par ) { if( ! m_FilledData ) { //::: Data m_CurrentTemplate->ClearData(); - BOOST_FOREACH( Tools::Info theInfo, *m_DataSingleInfo ) { + for( Tools::Info theInfo : *m_DataSingleInfo ) { if( ! theInfo.IsOS ) continue; float pt_for_binning = ( theInfo.GetMass() < 10 ) ? std::min( theInfo.First_Mu_pt, theInfo.Second_Mu_pt ) : std::max( theInfo.First_Mu_pt, theInfo.Second_Mu_pt ); //::://::://::: @@ -940,7 +940,7 @@ void MuonCalibrationFit::UpdateTemplates( const double* par ) { //::: Rho m_CurrentTemplate->FillRho( Type::Data, theInfo.GetRho().first, theInfo.First_Mu_pt ); } - BOOST_FOREACH( Tools::Info theInfo, *m_DataBothInfo ) { + for( Tools::Info theInfo : *m_DataBothInfo ) { if( ! theInfo.IsOS ) continue; float pt_for_binning = ( theInfo.GetMass() < 10 ) ? std::min( theInfo.First_Mu_pt, theInfo.Second_Mu_pt ) : std::max( theInfo.First_Mu_pt, theInfo.Second_Mu_pt ); //::://::://::: @@ -958,7 +958,7 @@ void MuonCalibrationFit::UpdateTemplates( const double* par ) { } //::: Background m_CurrentTemplate->ClearBackground(); - BOOST_FOREACH( Tools::Info theInfo, *m_BackgroundSingleInfo ) { + for( Tools::Info theInfo : *m_BackgroundSingleInfo ) { if( ! theInfo.IsOS ) continue; float pt_for_binning = ( theInfo.GetMass() < 10 ) ? std::min( theInfo.First_Mu_pt, theInfo.Second_Mu_pt ) : std::max( theInfo.First_Mu_pt, theInfo.Second_Mu_pt ); //::://::://::: @@ -975,7 +975,7 @@ void MuonCalibrationFit::UpdateTemplates( const double* par ) { //::: Rho m_CurrentTemplate->FillRho( Type::Background, theInfo.GetRho().first, theInfo.First_Mu_pt, theInfo.Weight ); } - BOOST_FOREACH( Tools::Info theInfo, *m_BackgroundBothInfo ) { + for( Tools::Info theInfo : *m_BackgroundBothInfo ) { if( ! theInfo.IsOS ) continue; float pt_for_binning = ( theInfo.GetMass() < 10 ) ? std::min( theInfo.First_Mu_pt, theInfo.Second_Mu_pt ) : std::max( theInfo.First_Mu_pt, theInfo.Second_Mu_pt ); //::://::://::: @@ -996,7 +996,7 @@ void MuonCalibrationFit::UpdateTemplates( const double* par ) { //::: MonteCarlo //::: Single Muon Correction TRandom3 rand_gen( 2988100123 ); - BOOST_FOREACH( Tools::Info theInfo, *m_MonteCarloSingleInfo ) { + for( Tools::Info theInfo : *m_MonteCarloSingleInfo ) { if( ! theInfo.IsOS ) continue; //std::cout << "GREP ME ====== " << int( TMath::Abs( theInfo.Gamma ) * 1000000 ) << std::endl; for( int index = 0; index < m_NumRandomValues; index++ ) { @@ -1018,7 +1018,7 @@ void MuonCalibrationFit::UpdateTemplates( const double* par ) { } } //::: Double Muon Correction - BOOST_FOREACH( Tools::Info theInfo, *m_MonteCarloBothInfo ) { + for( Tools::Info theInfo : *m_MonteCarloBothInfo ) { if( ! theInfo.IsOS ) continue; //std::cout << "GREP ME ====== " << int( TMath::Abs( theInfo.Gamma ) * 1000000 ) << std::endl; //TRandom2 rand_gen( int( TMath::Abs( theInfo.Gamma ) * 1000000 ) ); -- GitLab