Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replaced remaining BOOST_FOREACH #25132

Merged
merged 10 commits into from
Nov 19, 2018
8 changes: 4 additions & 4 deletions CalibTracker/SiStripCommon/interface/Book.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class Book {
void fill( double_t X, const poly<std::string>& names,
uint_t NbinsX, double_t Xlow, double_t Xup, double_t W=1 )
{
BOOST_FOREACH(string_t name, std::make_pair(names.begin(),names.end())) {
for(auto const& name : names) {
guitargeek marked this conversation as resolved.
Show resolved Hide resolved
book_t::const_iterator current = book_.find(name);
if( current == book_.end() )
book(name, new TH1D(name.c_str(), "", NbinsX, Xlow, Xup))->Fill(X,W);
Expand All @@ -74,7 +74,7 @@ class Book {
void fill( double_t X, double_t Y, const poly<std::string>& names,
uint_t NbinsX, double_t Xlow, double_t Xup, double_t W=1 )
{
BOOST_FOREACH(string_t name, std::make_pair(names.begin(),names.end())) {
for(auto const& name : names) {
guitargeek marked this conversation as resolved.
Show resolved Hide resolved
book_t::const_iterator current = book_.find(name);
if( current == book_.end() )
static_cast<TProfile*>(book(name, new TProfile(name.c_str(), "", NbinsX, Xlow, Xup)))->Fill(X,Y,W);
Expand All @@ -88,7 +88,7 @@ class Book {
uint_t NbinsX, double_t Xlow, double_t Xup,
uint_t NbinsY, double_t Ylow, double_t Yup, double_t W=1 )
{
BOOST_FOREACH(string_t name, std::make_pair(names.begin(),names.end())) {
for(auto const& name : names) {
guitargeek marked this conversation as resolved.
Show resolved Hide resolved
book_t::const_iterator current = book_.find(name);
if( current == book_.end() )
static_cast<TH2*>(book(name, new TH2D(name.c_str(), "", NbinsX, Xlow, Xup, NbinsY, Ylow, Yup)))->Fill(X,Y,W);
Expand All @@ -104,7 +104,7 @@ class Book {
uint_t NbinsY, double_t Ylow, double_t Yup,
uint_t NbinsZ, double_t Zlow, double_t Zup, double_t W=1 )
{
BOOST_FOREACH(string_t name, std::make_pair(names.begin(),names.end())) {
for(auto const& name : names) {
guitargeek marked this conversation as resolved.
Show resolved Hide resolved
book_t::const_iterator current = book_.find(name);
if( current == book_.end() )
static_cast<TH3*>(book(name, new TH3D(name.c_str(), "", NbinsX, Xlow, Xup, NbinsY, Ylow, Yup, NbinsZ, Zlow, Zup)))->Fill(X,Y,Z,W);
Expand Down
16 changes: 6 additions & 10 deletions CalibTracker/SiStripCommon/interface/poly.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

#include <boost/iterator/iterator_facade.hpp>
#include <boost/operators.hpp>
#include <boost/foreach.hpp>
#include <iostream>
#include <list>
#include <set>
Expand Down Expand Up @@ -47,11 +46,8 @@ class poly :
const_iterator begin() const { return const_iterator(*this);}
const_iterator end() const { return const_iterator::end_of(*this);}

column_iterator begin_columns() { return columns.begin();}
column_iterator end_columns() { return columns.end();}

const_column_iterator begin_columns() const { return columns.begin();}
const_column_iterator end_columns() const { return columns.end();}
auto const& getColumns() const { return columns; }
auto& getColumns() { return columns; }

size_t size() const {
if(columns.empty()) return 0;
Expand Down Expand Up @@ -91,13 +87,13 @@ class poly :
public:

const_iterator() {}
const_iterator(const poly& p) : begin(p.begin_columns()), end(p.end_columns()) {
const_iterator(const poly& p) : begin(p.getColumns().begin()), end(p.getColumns().end()) {
const_column_iterator column = begin;
while(column!=end) state.push_back((column++)->begin());
}
static const_iterator end_of(const poly& p) {
const_iterator it(p);
if(p.size()!=0) *--(it.state.end()) = (--p.end_columns())->end();
if(p.size()!=0) *--(it.state.end()) = (--p.getColumns().end())->end();
return it;
}

Expand All @@ -111,8 +107,8 @@ template<class T> poly<T> operator+ (const char* lhs, const poly<T>& rhs ) { ret
template <class charT, class traits, class T>
inline
std::basic_ostream<charT,traits>& operator<<(std::basic_ostream<charT,traits>& strm, const poly<T>& f) {
BOOST_FOREACH(std::set<T> column, std::make_pair(f.begin_columns(),f.end_columns()))
{ strm << "( "; BOOST_FOREACH(T entry, column) strm << entry << ", "; strm << " )" << std::endl; }
for(auto const& column : f.getColumns())
{ strm << "( "; for(auto const& entry : column) strm << entry << ", "; strm << " )" << std::endl; }
return strm;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include "DataFormats/Common/interface/DetSetVectorNew.h"
#include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
#include "Geometry/Records/interface/TrackerTopologyRcd.h"
#include "boost/foreach.hpp"

ShallowClustersProducer::ShallowClustersProducer(const edm::ParameterSet& iConfig)
: Prefix(iConfig.getParameter<std::string>("Prefix") )
Expand Down
7 changes: 3 additions & 4 deletions CalibTracker/SiStripCommon/plugins/ShallowDigisProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include "DataFormats/SiStripDigi/interface/SiStripDigi.h"
#include "CondFormats/DataRecord/interface/SiStripNoisesRcd.h"
#include "CondFormats/SiStripObjects/interface/SiStripNoises.h"
#include "boost/foreach.hpp"

ShallowDigisProducer::ShallowDigisProducer(const edm::ParameterSet& conf)
: inputTags(conf.getParameter<std::vector<edm::InputTag> >("DigiProducersList"))
Expand All @@ -34,9 +33,9 @@ template<class T>
inline
void ShallowDigisProducer::
recordDigis(const T& digiCollection, products& p) {
BOOST_FOREACH(const typename T::value_type set, digiCollection) {
for(auto const& set : digiCollection) {
SiStripNoises::Range detNoiseRange = noiseHandle->getRange(set.detId());
BOOST_FOREACH(const SiStripDigi digi, set) {
for(auto const& digi : set) {
p.id->push_back(set.detId());
p.subdet->push_back((set.detId()>>25)&0x7);
p.strip->push_back(digi.strip());
Expand All @@ -62,7 +61,7 @@ template<class T>
inline
bool ShallowDigisProducer::
findInput(edm::Handle<T>& handle, const edm::Event& e) {
BOOST_FOREACH( const edm::InputTag inputTag, inputTags) {
for(auto const& inputTag : inputTags) {
e.getByLabel(inputTag, handle);
if( handle.isValid() && !handle->empty() ) {
LogDebug("Input") << inputTag;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include "FWCore/ParameterSet/interface/ParameterSet.h"

#include "CalibTracker/SiStripCommon/interface/ShallowTools.h"
#include "boost/foreach.hpp"

ShallowRechitClustersProducer::ShallowRechitClustersProducer(const edm::ParameterSet& iConfig)
: Suffix ( iConfig.getParameter<std::string>("Suffix") ),
Expand Down Expand Up @@ -54,8 +53,8 @@ produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
for(auto recHit_token : rec_hits_tokens_) {
edm::Handle<SiStripRecHit2DCollection> recHits;
iEvent.getByToken(recHit_token, recHits);
BOOST_FOREACH( const SiStripRecHit2DCollection::value_type& ds, *recHits) {
BOOST_FOREACH( const SiStripRecHit2D& hit, ds) {
for(auto const& ds : *recHits) {
for(auto const& hit : ds) {

shallow::CLUSTERMAP::iterator cluster = clustermap.find( std::make_pair(hit.geographicalId().rawId(), hit.cluster()->firstStrip() ) );
if(cluster != clustermap.end() ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "boost/foreach.hpp"

ShallowSimhitClustersProducer::ShallowSimhitClustersProducer(const edm::ParameterSet& iConfig)
: clusters_token_( consumes< edmNew::DetSetVector<SiStripCluster> >(iConfig.getParameter<edm::InputTag>("Clusters"))),
Expand Down Expand Up @@ -68,7 +67,7 @@ produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
for(auto& simhit_token : simhits_tokens_) {
edm::Handle< std::vector<PSimHit> > simhits;
iEvent.getByToken(simhit_token, simhits);
BOOST_FOREACH( const PSimHit hit, *simhits ) {
for(auto const& hit : *simhits ) {

const uint32_t id = hit.detUnitId();
const StripGeomDetUnit* theStripDet = dynamic_cast<const StripGeomDetUnit*>( theTrackerGeometry->idToDet( id ) );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "boost/foreach.hpp"

#include "CalibTracker/Records/interface/SiStripDependentRecords.h"
#include <map>
Expand Down Expand Up @@ -141,7 +140,7 @@ produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
int trk_idx = shallow::findTrackIndex(tracks, track);
size_t trk_strt_idx = ontrk_cluster_idx;

BOOST_FOREACH( const TrajectoryMeasurement measurement, traj->measurements() ) {
for(auto const& measurement : traj->measurements() ) {
const TrajectoryStateOnSurface& tsos = measurement.updatedState();
const TrajectoryStateOnSurface unbiased = combiner(measurement.forwardPredictedState(), measurement.backwardPredictedState());

Expand Down Expand Up @@ -220,7 +219,7 @@ produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {

ontrk_cluster_idx++;
} //for(unsigned h=0; h<2; h++) { //loop over possible Hit options (1D, 2D)
} //BOOST_FOREACH( const TrajectoryMeasurement measurement, traj->measurements() )
} //for(auto const& measurement : traj->measurements() )

onTrkClustersBegin->at(trk_idx) = trk_strt_idx;
onTrkClustersEnd->at(trk_idx) = ontrk_cluster_idx;
Expand Down
3 changes: 1 addition & 2 deletions CalibTracker/SiStripCommon/plugins/ShallowTracksProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include "DataFormats/TrackReco/interface/Track.h"
#include "DataFormats/TrackReco/interface/TrackFwd.h"
#include "TrackingTools/PatternTools/interface/Trajectory.h"
#include "boost/foreach.hpp"

ShallowTracksProducer::ShallowTracksProducer(const edm::ParameterSet& iConfig)
: tracks_token_( consumes<edm::View<reco::Track> >( iConfig.getParameter<edm::InputTag>("Tracks") )),
Expand Down Expand Up @@ -72,7 +71,7 @@ produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
edm::Handle<edm::View<reco::Track> > tracks; iEvent.getByToken(tracks_token_, tracks);

*number = tracks->size();
BOOST_FOREACH( const reco::Track track, *tracks) {
for(auto const& track : *tracks) {
chi2->push_back( track.chi2() );
ndof->push_back( track.ndof() );
chi2ndof->push_back( track.chi2()/track.ndof() );
Expand Down
5 changes: 2 additions & 3 deletions CalibTracker/SiStripCommon/src/ShallowTools.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include "MagneticField/Engine/interface/MagneticField.h"
#include "CondFormats/SiStripObjects/interface/SiStripLorentzAngle.h"
#include "Geometry/TrackerGeometryBuilder/interface/StripGeomDetUnit.h"
#include "boost/foreach.hpp"


namespace shallow {
Expand All @@ -17,8 +16,8 @@ make_cluster_map( const edm::Event& iEvent, const edm::EDGetTokenT< edmNew::DetS
iEvent.getByToken(cluster_token, clusters);

unsigned int clusterindex = 0;
BOOST_FOREACH(const edmNew::DetSet<SiStripCluster>& ds, *clusters)
BOOST_FOREACH(const SiStripCluster& cluster, ds)
for(auto const& ds : *clusters)
for(auto const& cluster : ds)
clustermap.insert( std::make_pair( std::make_pair(ds.detId(),cluster.firstStrip()),
clusterindex++));
return clustermap;
Expand Down
19 changes: 9 additions & 10 deletions CalibTracker/SiStripDCS/src/SiStripDetVOffBuilder.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include "CalibTracker/SiStripDCS/interface/SiStripDetVOffBuilder.h"
#include "boost/foreach.hpp"
#include <sys/stat.h>

// constructor
Expand Down Expand Up @@ -45,12 +44,12 @@ SiStripDetVOffBuilder::SiStripDetVOffBuilder(const edm::ParameterSet& pset, cons
tsetmin = coral::TimeStamp(tset_par[0],tset_par[1],tset_par[2],tset_par[3],tset_par[4],tset_par[5],tset_par[6]);
}

if (onlineDbConnectionString == "") {
if (onlineDbConnectionString.empty()) {
edm::LogError("SiStripDetVOffBuilder") << "[SiStripDetVOffBuilder::SiStripDetVOffBuilder] DB name has not been set properly ... Returning ...";
return;
}

if (fromFile && whichTable == "LASTVALUE" && lastValueFileName == "") {
if (fromFile && whichTable == "LASTVALUE" && lastValueFileName.empty()) {
edm::LogError("SiStripDetVOffBuilder") << "[SiStripDetVOffBuilder::SiStripDetVOffBuilder] File expected for lastValue table, but filename not specified ... Returning ...";
return;
}
Expand Down Expand Up @@ -82,7 +81,7 @@ SiStripDetVOffBuilder::~SiStripDetVOffBuilder() {
}

void SiStripDetVOffBuilder::printPar(std::stringstream& ss, const std::vector<int>& par){
BOOST_FOREACH(int val, par){
for(int val : par){
ss << val << " ";
}
}
Expand Down Expand Up @@ -194,7 +193,7 @@ void SiStripDetVOffBuilder::BuildDetVOffObj()
// These modules are expected to not be in the PSU-DetId map, so they will never get any status change from the query.
SiStripPsuDetIdMap map;
std::vector< std::pair<uint32_t, std::string> > excludedDetIdMap;
if( excludedDetIdListFile_ != "" ) {
if( !excludedDetIdListFile_.empty() ) {
map.BuildMap(excludedDetIdListFile_, excludedDetIdMap);
}
for(std::map<uint32_t, SiStripDetInfoFileReader::DetInfo >::const_iterator it = detInfos.begin(); it != detInfos.end(); ++it) {
Expand Down Expand Up @@ -599,7 +598,7 @@ void SiStripDetVOffBuilder::statusChange( cond::Time_t & lastTime, TimesAndValue
tStruct.actualStatus.resize(tStruct.actualValue.size());
tStruct.actualStatus.clear();

BOOST_FOREACH(float val, tStruct.actualValue) {
for(float val : tStruct.actualValue) {
tStruct.actualStatus.push_back(static_cast<int>(val));
}
}
Expand Down Expand Up @@ -721,7 +720,7 @@ void SiStripDetVOffBuilder::buildPSUdetIdMap(TimesAndValues & psuStruct, DetIdLi
//It may make sense to split this method eventually.
{
SiStripPsuDetIdMap map_;
if( psuDetIdMapFile_ == "" ) {
if( psuDetIdMapFile_.empty() ) {
std::cout<<"PLEASE provide the name of a valid PSUDetIDMapFile in the cfg: currently still necessary to have a file, soon will access the info straight from the DB!"<<endl;
//map_.BuildMap();//This method is not currently used (it would try to build a map based on a query to SiStripConfigDB, and the info there is STALE!)
}
Expand Down Expand Up @@ -751,7 +750,7 @@ void SiStripDetVOffBuilder::buildPSUdetIdMap(TimesAndValues & psuStruct, DetIdLi
std::ifstream ifs("HVUnmappedChannelState.dat");
string line;
while( getline( ifs, line ) ) {
if( line != "" ) {
if( !line.empty() ) {
// split the line and insert in the map
stringstream ss(line);
string PSUChannel;
Expand Down Expand Up @@ -812,7 +811,7 @@ void SiStripDetVOffBuilder::buildPSUdetIdMap(TimesAndValues & psuStruct, DetIdLi
std::ifstream ifs("HVCrosstalkingChannelState.dat");
string line;
while( getline( ifs, line ) ) {
if( line != "" ) {
if( !line.empty() ) {
// split the line and insert in the map
stringstream ss(line);
string PSUChannel;
Expand Down Expand Up @@ -1197,7 +1196,7 @@ pair<int, int> SiStripDetVOffBuilder::extractDetIdVector( const unsigned int i,
// TESTING WITHOUT THE FIX
// -----------------------

if( psuDetIdMapFile_ == "" ) {
if( psuDetIdMapFile_.empty() ) {
// temporary fix to handle the fact that we don't know which HV channel the detIDs are associated to
if (i > 0) {
std::string iChannel = detIdStruct.psuName[i].substr( (detIdStruct.psuName[i].size()-3) );
Expand Down
20 changes: 9 additions & 11 deletions CalibTracker/SiStripLorentzAngle/plugins/EnsembleCalibrationLA.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include "Geometry/Records/interface/TrackerTopologyRcd.h"
#include <TChain.h>
#include <TFile.h>
#include <boost/foreach.hpp>
#include <boost/lexical_cast.hpp>
#include <fstream>

Expand All @@ -27,9 +26,10 @@ void EnsembleCalibrationLA::endJob()
{
Book book("la_ensemble");
TChain*const chain = new TChain("la_ensemble");
BOOST_FOREACH(std::string file, inputFiles) chain->Add((file+inFileLocation).c_str());
for(auto const& file : inputFiles) chain->Add((file+inFileLocation).c_str());

int methods = 0; BOOST_FOREACH(unsigned method, vMethods) methods|=method;
int methods = 0;
for(unsigned int method : vMethods) methods|=method;

LA_Filler_Fitter laff(methods,samples,nbins,lowBin,highBin,maxEvents,tTopo_);
laff.fill(chain,book);
Expand All @@ -51,10 +51,9 @@ void EnsembleCalibrationLA::endRun(const edm::Run&, const edm::EventSetup& eSetu

void EnsembleCalibrationLA::write_ensembles_text(const Book& book)
{
std::pair<std::string, std::vector<LA_Filler_Fitter::EnsembleSummary> > ensemble;
BOOST_FOREACH(ensemble, LA_Filler_Fitter::ensemble_summary(book)) {
for(auto const& ensemble : LA_Filler_Fitter::ensemble_summary(book)) {
std::fstream file((Prefix+ensemble.first+".dat").c_str(),std::ios::out);
BOOST_FOREACH(LA_Filler_Fitter::EnsembleSummary summary, ensemble.second)
for(auto const& summary : ensemble.second)
file << summary << std::endl;

const std::pair<std::pair<float,float>,std::pair<float,float> > line = LA_Filler_Fitter::offset_slope(ensemble.second);
Expand Down Expand Up @@ -109,12 +108,11 @@ write_samples_plots(const Book& book) const {
void EnsembleCalibrationLA::
write_calibrations() const {
std::fstream file((Prefix+"calibrations.dat").c_str(),std::ios::out);
std::pair<std::string,MethodCalibrations> cal;
BOOST_FOREACH(cal,calibrations) {
for(auto const& cal : calibrations) {
file << cal.first << std::endl
<< "\t slopes("; BOOST_FOREACH(float i, cal.second.slopes) file << i<< ","; file << ")" << std::endl
<< "\t offsets("; BOOST_FOREACH(float i, cal.second.offsets) file << i<< ","; file << ")" << std::endl
<< "\t pulls("; BOOST_FOREACH(float i, cal.second.pulls) file << i<< ","; file << ")" << std::endl;
<< "\t slopes("; for(float i : cal.second.slopes) file << i<< ","; file << ")" << std::endl
<< "\t offsets("; for(float i : cal.second.offsets) file << i<< ","; file << ")" << std::endl
<< "\t pulls("; for(float i : cal.second.pulls) file << i<< ","; file << ")" << std::endl;
}
file.close();
}
Expand Down
Loading