Skip to content

Commit

Permalink
Clang tidy checks - fix clang warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
mrodozov committed Jul 10, 2020
1 parent 92997c6 commit 5d140cc
Show file tree
Hide file tree
Showing 12 changed files with 54 additions and 47 deletions.
22 changes: 13 additions & 9 deletions Alignment/OfflineValidation/bin/DMRtrends.cc
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ void DMRtrends(vector<int> IOVlist,
exit(EXIT_FAILURE);
}
}
for (TString Variable : Variables) {
for (const auto &Variable : Variables) {
compileDMRTrends(IOVlist, Variable, labels, Year, myValidation, geometries, showlumi, FORCE);
cout << "Begin plotting" << endl;
PlotDMRTrends(IOVlist,
Expand Down Expand Up @@ -406,7 +406,7 @@ void compileDMRTrends(vector<int> IOVlist,
TRegexp regexp("[0-9][0-9][0-9][0-9][0-9][0-9]");
for (const auto &entry : fs::recursive_directory_iterator(myValidation)) {
bool found_all_labels = true;
for (string label : labels) {
for (const string &label : labels) {
if (entry.path().string().find(label) == std::string::npos)
found_all_labels = false;
}
Expand Down Expand Up @@ -449,7 +449,7 @@ void compileDMRTrends(vector<int> IOVlist,
map<pair<pair<TString, int>, TString>, Geometry> mappoints; // pair = (structure, layer), geometry

std::sort(filenames.begin(), filenames.end()); //order the files in alphabetical order
for (TString filename : filenames) {
for (const TString &filename : filenames) {
int runN;
TString runstring(filename(regexp));
if (runstring.IsFloat()) {
Expand All @@ -466,7 +466,7 @@ void compileDMRTrends(vector<int> IOVlist,
structname.ReplaceAll("_y", "");
size_t layersnumber = nlayers.at(structname);
for (size_t layer = 0; layer <= layersnumber; layer++) {
for (string geometry : geometries) {
for (const string &geometry : geometries) {
TString name = Variable + "_" + getName(structure, layer, geometry);
TH1F *histo = dynamic_cast<TH1F *>(f->Get(name));
//Geometry *geom =nullptr;
Expand Down Expand Up @@ -502,7 +502,7 @@ void compileDMRTrends(vector<int> IOVlist,
f->Close();
}
TString outname = myValidation + "DMRtrends";
for (TString label : labels) {
for (const auto &label : labels) {
outname += "_";
outname += label;
}
Expand All @@ -514,7 +514,7 @@ void compileDMRTrends(vector<int> IOVlist,
structname.ReplaceAll("_y", "");
size_t layersnumber = nlayers.at(structname);
for (size_t layer = 0; layer <= layersnumber; layer++) {
for (string geometry : geometries) {
for (const string &geometry : geometries) {
TString name = Variable + "_" + getName(structure, layer, geometry);
Geometry geom = mappoints[make_pair(make_pair(structure, layer), geometry)];
using Trend = vector<float> (Geometry::*)() const;
Expand Down Expand Up @@ -808,7 +808,7 @@ void PlotDMRTrends(vector<int> IOVlist,
lumiIOVpairs = lumiperIOV(IOVlist, Year);

TString filename = myValidation + "DMRtrends";
for (TString label : labels) {
for (const auto &label : labels) {
filename += "_";
filename += label;
}
Expand Down Expand Up @@ -875,7 +875,7 @@ void PlotDMRTrends(vector<int> IOVlist,
TMultiGraph *mg = new TMultiGraph(structure, structure);
THStack *mh = new THStack(structure, structure);
size_t igeom = 0;
for (string geometry : geometries) {
for (const string &geometry : geometries) {
TString name = Variable + "_" + getName(structure, layer, geometry);
TGraphErrors *g = dynamic_cast<TGraphErrors *>(in->Get(name + "_" + variables.at(i)));
g->SetName(name + "_" + variables.at(i));
Expand Down Expand Up @@ -1018,7 +1018,7 @@ void PlotDMRTrends(vector<int> IOVlist,
TString printfile = outputdir;
if (!(outputdir.EndsWith("/")))
outputdir += "/";
for (TString label : labels) {
for (const auto &label : labels) {
printfile += label;
printfile += "_";
}
Expand Down Expand Up @@ -1097,18 +1097,22 @@ int main(int argc, char *argv[]) {
bool showpixelupdate = argv[9], showlumi = argv[10], FORCE = argv[11];
TObjArray *vararray = all_variables.Tokenize(",");
vector<string> Variables;
Variables.reserve(vararray->GetEntries());
for (int i = 0; i < vararray->GetEntries(); i++)
Variables.push_back((string)(vararray->At(i)->GetName()));
TObjArray *labelarray = all_labels.Tokenize(",");
vector<string> labels;
labels.reserve(labelarray->GetEntries());
for (int i = 0; i < labelarray->GetEntries(); i++)
labels.push_back((string)(labelarray->At(i)->GetName()));
TObjArray *IOVarray = runlist.Tokenize(",");
vector<int> IOVlist;
IOVlist.reserve(IOVarray->GetEntries());
for (int i = 0; i < IOVarray->GetEntries(); i++)
IOVlist.push_back(stoi(IOVarray->At(i)->GetName()));
vector<int> pixelupdateruns;
TObjArray *PIXarray = pixelupdatelist.Tokenize(",");
pixelupdateruns.reserve(PIXarray->GetEntries());
for (int i = 0; i < PIXarray->GetEntries(); i++)
pixelupdateruns.push_back(stoi(PIXarray->At(i)->GetName()));
vector<string> geometries;
Expand Down
22 changes: 11 additions & 11 deletions Alignment/OfflineValidation/plugins/PrimaryVertexValidation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -106,24 +106,24 @@ PrimaryVertexValidation::PrimaryVertexValidation(const edm::ParameterSet& iConfi
theBeamspotToken = consumes<reco::BeamSpot>(BeamspotTag_);

// select and configure the track filter
theTrackFilter_ = std::unique_ptr<TrackFilterForPVFinding>(
new TrackFilterForPVFinding(iConfig.getParameter<edm::ParameterSet>("TkFilterParameters")));
theTrackFilter_ =
std::make_unique<TrackFilterForPVFinding>(iConfig.getParameter<edm::ParameterSet>("TkFilterParameters"));
// select and configure the track clusterizer
std::string clusteringAlgorithm =
iConfig.getParameter<edm::ParameterSet>("TkClusParameters").getParameter<std::string>("algorithm");
if (clusteringAlgorithm == "gap") {
theTrackClusterizer_ = std::unique_ptr<GapClusterizerInZ>(
new GapClusterizerInZ(iConfig.getParameter<edm::ParameterSet>("TkClusParameters")
.getParameter<edm::ParameterSet>("TkGapClusParameters")));
theTrackClusterizer_ =
std::make_unique<GapClusterizerInZ>(iConfig.getParameter<edm::ParameterSet>("TkClusParameters")
.getParameter<edm::ParameterSet>("TkGapClusParameters"));
} else if (clusteringAlgorithm == "DA") {
theTrackClusterizer_ = std::unique_ptr<DAClusterizerInZ>(
new DAClusterizerInZ(iConfig.getParameter<edm::ParameterSet>("TkClusParameters")
.getParameter<edm::ParameterSet>("TkDAClusParameters")));
theTrackClusterizer_ =
std::make_unique<DAClusterizerInZ>(iConfig.getParameter<edm::ParameterSet>("TkClusParameters")
.getParameter<edm::ParameterSet>("TkDAClusParameters"));
// provide the vectorized version of the clusterizer, if supported by the build
} else if (clusteringAlgorithm == "DA_vect") {
theTrackClusterizer_ = std::unique_ptr<DAClusterizerInZ_vect>(
new DAClusterizerInZ_vect(iConfig.getParameter<edm::ParameterSet>("TkClusParameters")
.getParameter<edm::ParameterSet>("TkDAClusParameters")));
theTrackClusterizer_ =
std::make_unique<DAClusterizerInZ_vect>(iConfig.getParameter<edm::ParameterSet>("TkClusParameters")
.getParameter<edm::ParameterSet>("TkDAClusParameters"));
} else {
throw VertexException("PrimaryVertexProducerAlgorithm: unknown clustering algorithm: " + clusteringAlgorithm);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ class TrackerOfflineValidation : public edm::EDAnalyzer {
if (newDir.length() == 0)
tfd.reset(&(*upDir.tfd));
else
tfd.reset(new TFileDirectory(upDir.tfd->mkdir(newDir)));
tfd = std::make_unique<TFileDirectory>(upDir.tfd->mkdir(newDir));
} else {
theDbe = edm::Service<DQMStore>().operator->();
}
Expand All @@ -187,9 +187,9 @@ class TrackerOfflineValidation : public edm::EDAnalyzer {
if (!dqmMode) {
edm::Service<TFileService> fs;
if (newDir.length() == 0) {
tfd.reset(new TFileDirectory(fs->tFileDirectory()));
tfd = std::make_unique<TFileDirectory>(fs->tFileDirectory());
} else {
tfd.reset(new TFileDirectory(fs->mkdir(newDir)));
tfd = std::make_unique<TFileDirectory>(fs->mkdir(newDir));
directoryString = newDir;
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion CalibTracker/SiStripCommon/plugins/PrescaleEventFilter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class PrescaleEventFilter : public edm::stream::EDFilter<edm::GlobalCache<presca
~PrescaleEventFilter() override;

static std::unique_ptr<prescale::Efficiency> initializeGlobalCache(edm::ParameterSet const&) {
return std::unique_ptr<prescale::Efficiency>(new prescale::Efficiency());
return std::make_unique<prescale::Efficiency>();
};

static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ ShallowRechitClustersProducer::ShallowRechitClustersProducer(const edm::Paramete
Prefix(iConfig.getParameter<std::string>("Prefix")),
clusters_token_(consumes<edmNew::DetSetVector<SiStripCluster>>(iConfig.getParameter<edm::InputTag>("Clusters"))) {
std::vector<edm::InputTag> rec_hits_tags = iConfig.getParameter<std::vector<edm::InputTag>>("InputTags");
for (auto itag : rec_hits_tags) {
for (const auto& itag : rec_hits_tags) {
rec_hits_tokens_.push_back(consumes<SiStripRecHit2DCollection>(itag));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ ShallowSimhitClustersProducer::ShallowSimhitClustersProducer(const edm::Paramete
Prefix(iConfig.getParameter<std::string>("Prefix")),
runningmode_(iConfig.getParameter<std::string>("runningMode")) {
std::vector<edm::InputTag> simhits_tags = iConfig.getParameter<std::vector<edm::InputTag>>("InputTags");
for (auto itag : simhits_tags) {
for (const auto& itag : simhits_tags) {
simhits_tokens_.push_back(consumes<std::vector<PSimHit>>(itag));
}

Expand Down
2 changes: 1 addition & 1 deletion CalibTracker/SiStripCommon/plugins/ShallowTree.cc
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ ShallowTree::ShallowTree(const edm::ParameterSet& iConfig) {
default: {
std::string leafstring = "";
typedef std::pair<std::string, LEAFTYPE> pair_t;
for (const pair_t leaf : leafmap) {
for (const auto& leaf : leafmap) {
leafstring += "\t" + leaf.first + "\n";
}

Expand Down
7 changes: 4 additions & 3 deletions HLTriggerOffline/Egamma/src/EmDQM.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1088,10 +1088,11 @@ void EmDQM::dqmEndRun(edm::Run const &iRun, edm::EventSetup const &iSetup) {
// check which ones were never found
std::vector<std::string> labelsNeverFound;

for (edm::InputTag const tag : hltCollectionLabelsMissedPerPath.at(vPos)) {
if ((hltCollectionLabelsFoundPerPath.at(vPos)).count(tag.encode()) == 0)
for (const auto &tag : hltCollectionLabelsMissedPerPath.at(vPos)) {
auto atag = edm::InputTag(tag);
if ((hltCollectionLabelsFoundPerPath.at(vPos)).count(atag.encode()) == 0)
// never found
labelsNeverFound.push_back(tag.encode());
labelsNeverFound.push_back(atag.encode());

} // loop over all tags which were missed at least once

Expand Down
26 changes: 14 additions & 12 deletions HLTriggerOffline/Egamma/src/EmDQMReco.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
#include "TH1F.h"
#include <Math/VectorUtil.h>
#include <iostream>
#include <memory>

#include <string>
using namespace ROOT::Math::VectorUtil;

Expand Down Expand Up @@ -258,27 +260,27 @@ void EmDQMReco::bookHistograms(DQMStore::IBooker &iBooker, edm::Run const &iRun,

// reco
// (note that reset(..) must be used to set the value of the scoped_ptr...)
histReco.reset(new FourVectorMonitorElements(this,
iBooker,
"reco_%s", // pattern for histogram name
"%s of " + pdgIdString + "s"));
histReco = std::make_unique<FourVectorMonitorElements>(this,
iBooker,
"reco_%s", // pattern for histogram name
"%s of " + pdgIdString + "s");

//--------------------

// monpath
histRecoMonpath.reset(new FourVectorMonitorElements(this,
iBooker,
"reco_%s_monpath", // pattern for histogram name
"%s of " + pdgIdString + "s monpath"));
histRecoMonpath = std::make_unique<FourVectorMonitorElements>(this,
iBooker,
"reco_%s_monpath", // pattern for histogram name
"%s of " + pdgIdString + "s monpath");

//--------------------

// TODO: WHAT ARE THESE HISTOGRAMS FOR ? THEY SEEM NEVER REFERENCED ANYWHERE
// IN THIS FILE... final X monpath
histMonpath.reset(new FourVectorMonitorElements(this,
iBooker,
"final_%s_monpath", // pattern for histogram name
"Final %s Monpath"));
histMonpath = std::make_unique<FourVectorMonitorElements>(this,
iBooker,
"final_%s_monpath", // pattern for histogram name
"Final %s Monpath");

//--------------------

Expand Down
6 changes: 3 additions & 3 deletions L1TriggerConfig/Utilities/src/L1MenuViewer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ void L1MenuViewer::analyze(const edm::Event& iEvent, const edm::EventSetup& evSe
cout << " modules: " << ptr1->getNmodules() << endl;

cout << " Algorithms[" << ptr1->getAlgorithmMap().size() << "]: " << endl;
for (auto a : ptr1->getAlgorithmMap())
for (const auto& a : ptr1->getAlgorithmMap())
cout << " " << a.first << endl;

cout << " Conditions[" << ptr1->getConditionMap().size() << "]: " << endl;
for (auto a : ptr1->getConditionMap())
for (const auto& a : ptr1->getConditionMap())
cout << " " << a.first << endl;

cout << " Conditions[" << ptr1->getScaleMap().size() << "]: " << endl;
for (auto a : ptr1->getScaleMap())
for (const auto& a : ptr1->getScaleMap())
cout << " " << a.first << endl;
}

Expand Down
2 changes: 1 addition & 1 deletion L1TriggerConfig/Utilities/src/L1TMuonBarrelParamsViewer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ void L1TMuonBarrelParamsViewer::analyze(const edm::Event &iEvent, const edm::Eve
}

// typedef std::map< LUTID, LUTCONT > qpLUT;
for (const pair<pair<short, short>, pair<short, vector<short>>> item : ptr1->qp_lut()) {
for (const auto &item : ptr1->qp_lut()) {
cout << " qp_lut[" << item.first.first << "," << item.first.second << "]= " << item.second.first << ", ["
<< item.second.second.size() << "] " << flush;
if (!item.second.second.empty()) {
Expand Down
2 changes: 1 addition & 1 deletion L1TriggerConfig/Utilities/src/L1TriggerKeyExtViewer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void L1TriggerKeyExtViewer::analyze(const edm::Event& iEvent, const edm::EventSe
for (; itr != end; ++itr) {
std::string recordType = itr->first;
std::string objectKey = itr->second;
std::string recordName(recordType, 0, recordType.find_first_of("@"));
std::string recordName(recordType, 0, recordType.find_first_of('@'));
cout << " record " << recordName << " key: " << itr->second << endl;
}

Expand Down

0 comments on commit 5d140cc

Please sign in to comment.