From 3556d14cf23feefa66f4b3f17cc6b042e27bdc88 Mon Sep 17 00:00:00 2001 From: Mircho Rodozov Date: Fri, 17 Jul 2020 17:35:12 +0200 Subject: [PATCH 1/2] clang checks --- .../JetMET/plugins/HLTScoutingCaloProducer.cc | 6 ++-- .../JetMET/plugins/HLTScoutingPFProducer.cc | 6 ++-- HLTrigger/JetMET/plugins/PixelJetPuId.cc | 2 +- HLTrigger/Tools/bin/hltTimingSummary.cpp | 32 +++++++++---------- HLTrigger/btau/plugins/ConeIsolation.cc | 4 +-- .../btau/plugins/HLTDisplacedmumuFilter.cc | 2 +- .../btau/plugins/HLTDisplacedmumumuFilter.cc | 2 +- .../btau/plugins/HLTDisplacedtktkFilter.cc | 2 +- .../src/L2TauPixelIsoTagProducer.cc | 10 ++++-- 9 files changed, 35 insertions(+), 31 deletions(-) diff --git a/HLTrigger/JetMET/plugins/HLTScoutingCaloProducer.cc b/HLTrigger/JetMET/plugins/HLTScoutingCaloProducer.cc index 52cce8433cf2a..61b24e6fd159d 100644 --- a/HLTrigger/JetMET/plugins/HLTScoutingCaloProducer.cc +++ b/HLTrigger/JetMET/plugins/HLTScoutingCaloProducer.cc @@ -156,7 +156,7 @@ void HLTScoutingCaloProducer::produce(edm::StreamID sid, edm::Event& iEvent, edm Handle rho; std::unique_ptr outRho(new double(-999)); if (iEvent.getByToken(rho_, rho)) { - outRho.reset(new double(*rho)); + outRho = std::make_unique(*rho); } //get MET @@ -164,8 +164,8 @@ void HLTScoutingCaloProducer::produce(edm::StreamID sid, edm::Event& iEvent, edm std::unique_ptr outMetPt(new double(-999)); std::unique_ptr outMetPhi(new double(-999)); if (doMet && iEvent.getByToken(metCollection_, metCollection)) { - outMetPt.reset(new double(metCollection->front().pt())); - outMetPhi.reset(new double(metCollection->front().phi())); + outMetPt = std::make_unique(metCollection->front().pt()); + outMetPhi = std::make_unique(metCollection->front().phi()); } //put output diff --git a/HLTrigger/JetMET/plugins/HLTScoutingPFProducer.cc b/HLTrigger/JetMET/plugins/HLTScoutingPFProducer.cc index 33093fe7c23ba..ca45c46989002 100644 --- a/HLTrigger/JetMET/plugins/HLTScoutingPFProducer.cc +++ b/HLTrigger/JetMET/plugins/HLTScoutingPFProducer.cc @@ -124,7 +124,7 @@ void HLTScoutingPFProducer::produce(edm::StreamID sid, edm::Event &iEvent, edm:: Handle rho; std::unique_ptr outRho(new double(-999)); if (iEvent.getByToken(rho_, rho)) { - outRho.reset(new double(*rho)); + outRho = std::make_unique(*rho); } //get MET @@ -132,8 +132,8 @@ void HLTScoutingPFProducer::produce(edm::StreamID sid, edm::Event &iEvent, edm:: std::unique_ptr outMetPt(new double(-999)); std::unique_ptr outMetPhi(new double(-999)); if (doMet && iEvent.getByToken(metCollection_, metCollection)) { - outMetPt.reset(new double(metCollection->front().pt())); - outMetPhi.reset(new double(metCollection->front().phi())); + outMetPt = std::make_unique(metCollection->front().pt()); + outMetPhi = std::make_unique(metCollection->front().phi()); } //get PF candidates diff --git a/HLTrigger/JetMET/plugins/PixelJetPuId.cc b/HLTrigger/JetMET/plugins/PixelJetPuId.cc index 6a07061b91a2f..b3509570d70f4 100644 --- a/HLTrigger/JetMET/plugins/PixelJetPuId.cc +++ b/HLTrigger/JetMET/plugins/PixelJetPuId.cc @@ -173,7 +173,7 @@ void PixelJetPuId::produce(edm::StreamID sid, edm::Event& iEvent, const edm::Eve //init JetTagCollection if (!generaljets.product()->empty()) { edm::RefToBase jj = edm::RefToBase(generaljets, 0); - pOut_jetTagCollection.reset(new reco::JetTagCollection(edm::makeRefToBaseProdFrom(jj, iEvent))); + pOut_jetTagCollection = std::make_unique(edm::makeRefToBaseProdFrom(jj, iEvent)); } //loop on trackIPTagInfos diff --git a/HLTrigger/Tools/bin/hltTimingSummary.cpp b/HLTrigger/Tools/bin/hltTimingSummary.cpp index cf48d4dc87fb2..352de906c35ad 100644 --- a/HLTrigger/Tools/bin/hltTimingSummary.cpp +++ b/HLTrigger/Tools/bin/hltTimingSummary.cpp @@ -787,8 +787,8 @@ int main(int argc, char** argv) { std::string skipped; getline(filterFile, skipped); //--- Special: remove any trailing whitespace ---// - size_t spos = skipped.find_first_not_of(" "); - size_t epos = skipped.find_last_not_of(" "); + size_t spos = skipped.find_first_not_of(' '); + size_t epos = skipped.find_last_not_of(' '); if (spos != std::string::npos && epos != std::string::npos) { skipped = skipped.substr(spos, epos); squareOne.push_back(skipped); @@ -796,7 +796,7 @@ int main(int argc, char** argv) { } } else { //--- Assume the file is a comma-separated list of modules ---// size_t strStart = 0; - for (size_t itr = startHere.find(",", 0); itr != std::string::npos; itr = startHere.find(",", itr)) { + for (size_t itr = startHere.find(',', 0); itr != std::string::npos; itr = startHere.find(',', itr)) { std::string skipped = startHere.substr(strStart, (itr - strStart)); itr++; strStart = itr; @@ -815,8 +815,8 @@ int main(int argc, char** argv) { std::string skipped; getline(excludeModFile, skipped); //--- Special: remove any trailing whitespace ---// - size_t spos = skipped.find_first_not_of(" "); - size_t epos = skipped.find_last_not_of(" "); + size_t spos = skipped.find_first_not_of(' '); + size_t epos = skipped.find_last_not_of(' '); if (spos != std::string::npos && epos != std::string::npos) { skipped = skipped.substr(spos, epos + 1); skipTimingMod.push_back(skipped); @@ -824,7 +824,7 @@ int main(int argc, char** argv) { } } else { //--- Assume the file is a comma-separated list of modules ---// size_t strStart = 0; - for (size_t itr = excludeModName.find(",", 0); itr != std::string::npos; itr = excludeModName.find(",", itr)) { + for (size_t itr = excludeModName.find(',', 0); itr != std::string::npos; itr = excludeModName.find(',', itr)) { std::string skipped = excludeModName.substr(strStart, (itr - strStart)); itr++; strStart = itr; @@ -844,8 +844,8 @@ int main(int argc, char** argv) { std::string skipped; getline(excludePathFile, skipped); //--- Special: remove any trailing whitespace ---// - size_t spos = skipped.find_first_not_of(" "); - size_t epos = skipped.find_last_not_of(" "); + size_t spos = skipped.find_first_not_of(' '); + size_t epos = skipped.find_last_not_of(' '); if (spos != std::string::npos && epos != std::string::npos) { skipped = skipped.substr(spos, epos + 1); skipTimingPath.push_back(skipped); @@ -853,7 +853,7 @@ int main(int argc, char** argv) { } } else { //--- Assume the file is a comma-separated list of paths ---// size_t strStart = 0; - for (size_t itr = excludePathName.find(",", 0); itr != std::string::npos; itr = excludePathName.find(",", itr)) { + for (size_t itr = excludePathName.find(',', 0); itr != std::string::npos; itr = excludePathName.find(',', itr)) { std::string skipped = excludePathName.substr(strStart, (itr - strStart)); itr++; strStart = itr; @@ -873,8 +873,8 @@ int main(int argc, char** argv) { std::string modname; getline(modPrintFile, modname); //--- Special: remove any trailing whitespace ---// - size_t spos = modname.find_first_not_of(" "); - size_t epos = modname.find_last_not_of(" "); + size_t spos = modname.find_first_not_of(' '); + size_t epos = modname.find_last_not_of(' '); if (spos != std::string::npos && epos != std::string::npos) { modname = modname.substr(spos, epos + 1); modInterested.push_back(modname); @@ -882,7 +882,7 @@ int main(int argc, char** argv) { } } else { //--- Assume the file is a comma-separated list of modules ---// size_t strStart = 0; - for (size_t itr = modPrintName.find(",", 0); itr != std::string::npos; itr = modPrintName.find(",", itr)) { + for (size_t itr = modPrintName.find(',', 0); itr != std::string::npos; itr = modPrintName.find(',', itr)) { std::string modname = modPrintName.substr(strStart, (itr - strStart)); itr++; strStart = itr; @@ -899,10 +899,10 @@ int main(int argc, char** argv) { unsigned int strStart = 0; numberOfspecificTotalTime = 0; - for (size_t itr = strSpecificTotalTime.find("A", 0); itr != std::string::npos; - itr = strSpecificTotalTime.find("A", itr)) { + for (size_t itr = strSpecificTotalTime.find('A', 0); itr != std::string::npos; + itr = strSpecificTotalTime.find('A', itr)) { std::string strSpecificTimePair = strSpecificTotalTime.substr(strStart, (itr - strStart)); - size_t commaPos = strSpecificTimePair.find(",", 0); + size_t commaPos = strSpecificTimePair.find(',', 0); std::pair specificTimePair; specificTimePair.first = atof(strSpecificTimePair.substr(0, commaPos).c_str()); specificTimePair.second = @@ -914,7 +914,7 @@ int main(int argc, char** argv) { } //--- Fill the last entry ---// std::string strSpecificTimePair = strSpecificTotalTime.substr(strStart, strSpecificTotalTime.length() - strStart); - size_t commaPos = strSpecificTimePair.find(",", 0); + size_t commaPos = strSpecificTimePair.find(',', 0); std::pair specificTimePair; specificTimePair.first = atof(strSpecificTimePair.substr(0, commaPos).c_str()); specificTimePair.second = diff --git a/HLTrigger/btau/plugins/ConeIsolation.cc b/HLTrigger/btau/plugins/ConeIsolation.cc index a1c9e6993b71b..7ebbdef9cf8b1 100644 --- a/HLTrigger/btau/plugins/ConeIsolation.cc +++ b/HLTrigger/btau/plugins/ConeIsolation.cc @@ -91,9 +91,9 @@ void ConeIsolation::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { std::unique_ptr extCollection(new reco::IsolatedTauTagInfoCollection()); if (not jetTracksAssociation->empty()) { RefToBaseProd prod(edm::makeRefToBaseProdFrom(jetTracksAssociation->begin()->first, iEvent)); - tagCollection.reset(new reco::JetTagCollection(prod)); + tagCollection = std::make_unique(prod); } else { - tagCollection.reset(new reco::JetTagCollection()); + tagCollection = std::make_unique(); } Vertex::Error e; diff --git a/HLTrigger/btau/plugins/HLTDisplacedmumuFilter.cc b/HLTrigger/btau/plugins/HLTDisplacedmumuFilter.cc index 91f05e4e56265..09750014e974a 100644 --- a/HLTrigger/btau/plugins/HLTDisplacedmumuFilter.cc +++ b/HLTrigger/btau/plugins/HLTDisplacedmumuFilter.cc @@ -106,7 +106,7 @@ bool HLTDisplacedmumuFilter::hltFilter(edm::Event& iEvent, bool triggered = false; // loop over vertex collection - for (auto displacedVertex : displacedVertexColl) { + for (const auto& displacedVertex : displacedVertexColl) { // check if the vertex actually consists of exactly two muon tracks, throw exception if not if (displacedVertex.tracksSize() != 2) throw cms::Exception("BadLogic") << "HLTDisplacedmumuFilter: ERROR: the Jpsi vertex must have exactly two muons " diff --git a/HLTrigger/btau/plugins/HLTDisplacedmumumuFilter.cc b/HLTrigger/btau/plugins/HLTDisplacedmumumuFilter.cc index 62af2db6c1a6d..9e31f269a7edd 100644 --- a/HLTrigger/btau/plugins/HLTDisplacedmumumuFilter.cc +++ b/HLTrigger/btau/plugins/HLTDisplacedmumumuFilter.cc @@ -107,7 +107,7 @@ bool HLTDisplacedmumumuFilter::hltFilter(edm::Event& iEvent, bool triggered = false; // loop over vertex collection - for (auto displacedVertex : displacedVertexColl) { + for (const auto& displacedVertex : displacedVertexColl) { // check if the vertex actually consists of exactly two muon tracks, throw exception if not if (displacedVertex.tracksSize() != 3) throw cms::Exception("BadLogic") << "HLTDisplacedmumumuFilter: ERROR: the Jpsi vertex must have exactly three " diff --git a/HLTrigger/btau/plugins/HLTDisplacedtktkFilter.cc b/HLTrigger/btau/plugins/HLTDisplacedtktkFilter.cc index eaf94c5224ee8..7bee59f555cb9 100644 --- a/HLTrigger/btau/plugins/HLTDisplacedtktkFilter.cc +++ b/HLTrigger/btau/plugins/HLTDisplacedtktkFilter.cc @@ -108,7 +108,7 @@ bool HLTDisplacedtktkFilter::hltFilter(edm::Event& iEvent, bool triggered = false; // loop over vertex collection - for (auto displacedVertex : displacedVertexColl) { + for (const auto& displacedVertex : displacedVertexColl) { // check if the vertex actually consists of exactly two track tracks, reject the event if not if (displacedVertex.tracksSize() != 2) { edm::LogError("HLTDisplacedtktkFilter") << "HLTDisplacedtktkFilter: ERROR: the Jpsi vertex must have exactly two " diff --git a/RecoTauTag/HLTProducers/src/L2TauPixelIsoTagProducer.cc b/RecoTauTag/HLTProducers/src/L2TauPixelIsoTagProducer.cc index 35659b82d73e5..fd30247cc0295 100644 --- a/RecoTauTag/HLTProducers/src/L2TauPixelIsoTagProducer.cc +++ b/RecoTauTag/HLTProducers/src/L2TauPixelIsoTagProducer.cc @@ -3,7 +3,11 @@ // Created: 2012-03-07 // -#include "RecoTauTag/HLTProducers/interface/L2TauPixelIsoTagProducer.h" +#include + + + + #include "RecoTauTag/HLTProducers/interface/L2TauPixelIsoTagProducer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/EventSetup.h" @@ -50,9 +54,9 @@ void L2TauPixelIsoTagProducer::produce(edm::StreamID sid, edm::Event& ev, const // define the product to store unique_ptr jetTagCollection; if (jets.empty()) { - jetTagCollection.reset(new JetTagCollection()); + jetTagCollection = std::make_unique(); } else { - jetTagCollection.reset(new JetTagCollection(RefToBaseProd(jets_h))); + jetTagCollection = std::make_unique(RefToBaseProd(jets_h)); } // by default, initialize all the jets as isolated: for (const auto& jet : jets) From 94761e5120356839df6eb0921b9038ce3874fc80 Mon Sep 17 00:00:00 2001 From: Mircho Rodozov Date: Fri, 17 Jul 2020 17:43:43 +0200 Subject: [PATCH 2/2] clang format --- RecoTauTag/HLTProducers/src/L2TauPixelIsoTagProducer.cc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/RecoTauTag/HLTProducers/src/L2TauPixelIsoTagProducer.cc b/RecoTauTag/HLTProducers/src/L2TauPixelIsoTagProducer.cc index fd30247cc0295..d7af5e126f74c 100644 --- a/RecoTauTag/HLTProducers/src/L2TauPixelIsoTagProducer.cc +++ b/RecoTauTag/HLTProducers/src/L2TauPixelIsoTagProducer.cc @@ -5,9 +5,7 @@ #include - - - #include "RecoTauTag/HLTProducers/interface/L2TauPixelIsoTagProducer.h" +#include "RecoTauTag/HLTProducers/interface/L2TauPixelIsoTagProducer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/EventSetup.h"