diff --git a/Alignment/CocoaUtilities/src/ALIFileIn.cc b/Alignment/CocoaUtilities/src/ALIFileIn.cc index de453718274cb..57dd5a66f46cb 100644 --- a/Alignment/CocoaUtilities/src/ALIFileIn.cc +++ b/Alignment/CocoaUtilities/src/ALIFileIn.cc @@ -128,9 +128,9 @@ ALIint ALIFileIn::getWordsInLine(std::vector& wordlist) { } } tt++; - } while (*tt != '\0' && stemp.length() != 0); + } while (*tt != '\0' && !stemp.empty()); ALIstring stempt(ltemp); - if (stempt.length() == 0) + if (stempt.empty()) NoWords = 0; //--------- Read words from istr_line and write them into wordlist @@ -138,7 +138,7 @@ ALIint ALIFileIn::getWordsInLine(std::vector& wordlist) { for (ii = 0; ii < NoWords; ii++) { ALIstring stemp = ""; istr_line >> stemp; //?? gives warning in Insure++ - if (stemp.length() == 0) + if (stemp.empty()) break; ALIint comment = stemp.find(ALIstring("//")); // std::cout << "!!!COMMENT" << comment << stemp.c_str() << std::endl; diff --git a/Alignment/CommonAlignment/src/AlignableModifier.cc b/Alignment/CommonAlignment/src/AlignableModifier.cc index 3239172e43fb6..fe8407a18a504 100644 --- a/Alignment/CommonAlignment/src/AlignableModifier.cc +++ b/Alignment/CommonAlignment/src/AlignableModifier.cc @@ -174,7 +174,7 @@ bool AlignableModifier::modify(Alignable* alignable, const edm::ParameterSet& pS << "with 's' or a digit at the end.\n"; } // other PSets should now be hierarchy levels and thus be OK to ignore here } else { - if (!error.str().length()) + if (error.str().empty()) error << "Unknown parameter name(s): "; error << " " << *iParam; } @@ -189,7 +189,7 @@ bool AlignableModifier::modify(Alignable* alignable, const edm::ParameterSet& pS throw cms::Exception("BadConfig") << "Found both localZ and phiZlocal"; // Check error - if (error.str().length()) + if (!error.str().empty()) throw cms::Exception("BadConfig") << error.str(); // Decode distribution diff --git a/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeAlignmentAlgorithm.cc b/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeAlignmentAlgorithm.cc index 1cc31f5b2db17..5ffe0431cea6e 100644 --- a/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeAlignmentAlgorithm.cc +++ b/Alignment/MillePedeAlignmentAlgorithm/plugins/MillePedeAlignmentAlgorithm.cc @@ -396,7 +396,7 @@ void MillePedeAlignmentAlgorithm::terminate() { std::string filesForLogOutput; for (const auto &file : files) filesForLogOutput += " " + file + ","; - if (filesForLogOutput.length() != 0) + if (!filesForLogOutput.empty()) filesForLogOutput.pop_back(); edm::LogInfo("Alignment") << "Based on the config parameter mergeBinaryFiles, using the following " << "files as input (assigned weights are indicated by ' -- '):" diff --git a/Alignment/MuonAlignment/src/MuonScenarioBuilder.cc b/Alignment/MuonAlignment/src/MuonScenarioBuilder.cc index 5715d4f4104cd..5e57d107b3afb 100644 --- a/Alignment/MuonAlignment/src/MuonScenarioBuilder.cc +++ b/Alignment/MuonAlignment/src/MuonScenarioBuilder.cc @@ -89,7 +89,7 @@ align::Scalars MuonScenarioBuilder::extractParameters(const edm::ParameterSet& p else if ((*iParam) == "dZ") dZ_ = Parameters.getParameter(*iParam); else if (Parameters.retrieve(*iParam).typeCode() != 'P') { // Add unknown parameter to list - if (!error.str().length()) + if (error.str().empty()) error << "Unknown parameter name(s): "; error << " " << *iParam; } diff --git a/Alignment/OfflineValidation/plugins/TrackerOfflineValidation.cc b/Alignment/OfflineValidation/plugins/TrackerOfflineValidation.cc index 399015744e964..794367cc4f786 100644 --- a/Alignment/OfflineValidation/plugins/TrackerOfflineValidation.cc +++ b/Alignment/OfflineValidation/plugins/TrackerOfflineValidation.cc @@ -169,8 +169,8 @@ class TrackerOfflineValidation : public edm::one::EDAnalyzer(upDir.tfd->mkdir(newDir)); @@ -191,15 +191,15 @@ class TrackerOfflineValidation : public edm::one::EDAnalyzer fs; - if (newDir.length() == 0) { + if (newDir.empty()) { tfd = std::make_unique(fs->tFileDirectory()); } else { tfd = std::make_unique(fs->mkdir(newDir)); directoryString = newDir; } } else { - if (newDir.length() != 0) { - if (basedir.length() != 0) + if (!newDir.empty()) { + if (!basedir.empty()) directoryString = basedir + "/" + newDir; else directoryString = newDir; diff --git a/Alignment/OfflineValidation/plugins/TrackerOfflineValidationSummary.cc b/Alignment/OfflineValidation/plugins/TrackerOfflineValidationSummary.cc index 23f4f86a0e7e3..705cb5f1ab978 100644 --- a/Alignment/OfflineValidation/plugins/TrackerOfflineValidationSummary.cc +++ b/Alignment/OfflineValidation/plugins/TrackerOfflineValidationSummary.cc @@ -504,7 +504,7 @@ const std::string TrackerOfflineValidationSummary::associateModuleHistsWithTree( std::map& substructureName) { std::stringstream histDir, sSubdetName; std::string componentName; - if (moduleDirectory_.length() != 0) + if (!moduleDirectory_.empty()) histDir << moduleDirectory_ << "/"; std::string wheelOrLayer("_layer_"); if (treeMem.subDetId == PixelSubdetector::PixelBarrel) { @@ -770,7 +770,7 @@ void TrackerOfflineValidationSummary::applyHarvestingHierarchy(TTree& tree) { iSubdet == StripSubdetector::TID || iSubdet == StripSubdetector::TEC)) continue; treeEntries.push_back(iTree); - if (hierarchyName.length() == 0) { + if (hierarchyName.empty()) { hierarchyName = (*substructureName)["subdet"]; componentName = (*substructureName)["component"]; } @@ -804,7 +804,7 @@ void TrackerOfflineValidationSummary::bookHarvestingHists() { dmrYprimeHistoTitle << "DMR for " << iHier->hierarchyName << ";<#DeltaY> [cm];# modules"; std::string directoryString(moduleDirectory_); - if (directoryString.length() != 0) + if (!directoryString.empty()) directoryString += "/"; directoryString += iHier->componentName; dbe_->setCurrentFolder(directoryString); diff --git a/CalibPPS/AlignmentRelative/plugins/PPSModifySingularModes.cc b/CalibPPS/AlignmentRelative/plugins/PPSModifySingularModes.cc index b2f2b1dc5c59c..9aedcc8a9c5b5 100644 --- a/CalibPPS/AlignmentRelative/plugins/PPSModifySingularModes.cc +++ b/CalibPPS/AlignmentRelative/plugins/PPSModifySingularModes.cc @@ -60,7 +60,7 @@ void PPSModifySingularModes::beginRun(edm::Run const &, edm::EventSetup const &e const double de_rho2 = ps_.getUntrackedParameter("de_rho2"); FileInPath inputFileInPath(ps_.getUntrackedParameter("inputFile")); - const string inputFile = inputFileInPath.fullPath(); + const string &inputFile = inputFileInPath.fullPath(); const string outputFile = ps_.getUntrackedParameter("outputFile"); // validate config parameters diff --git a/CalibTracker/SiStripChannelGain/src/APVGainHelpers.cc b/CalibTracker/SiStripChannelGain/src/APVGainHelpers.cc index a55b005b304bb..3e45517aa4d87 100644 --- a/CalibTracker/SiStripChannelGain/src/APVGainHelpers.cc +++ b/CalibTracker/SiStripChannelGain/src/APVGainHelpers.cc @@ -225,7 +225,7 @@ std::vector> APVGain::monHnames(std::vector< out.reserve(re); std::string Tag = tag; - if (Tag.length()) + if (!Tag.empty()) Tag = "__" + Tag; std::string h_tag = ""; diff --git a/CaloOnlineTools/HcalOnlineDb/src/RooGKCounter.cc b/CaloOnlineTools/HcalOnlineDb/src/RooGKCounter.cc index f4e3dff334c8b..b22bbb8aa0805 100644 --- a/CaloOnlineTools/HcalOnlineDb/src/RooGKCounter.cc +++ b/CaloOnlineTools/HcalOnlineDb/src/RooGKCounter.cc @@ -14,7 +14,7 @@ RooGKCounter::RooGKCounter() { init(); } RooGKCounter::RooGKCounter(const char *message) { init(); _message = message; - if (_message.length() == 0) + if (_message.empty()) printCount = false; } diff --git a/CondCore/CondDB/src/Binary.cc b/CondCore/CondDB/src/Binary.cc index 43cb226a345d9..6d21db0c020e1 100644 --- a/CondCore/CondDB/src/Binary.cc +++ b/CondCore/CondDB/src/Binary.cc @@ -5,8 +5,9 @@ // #include -#include #include +#include +#include cond::Binary::Binary() : m_data(new coral::Blob(0)) {} @@ -30,7 +31,7 @@ cond::Binary& cond::Binary::operator=(const Binary& rhs) { const coral::Blob& cond::Binary::get() const { return *m_data; } void cond::Binary::copy(const std::string& source) { - m_data.reset(new coral::Blob(source.size())); + m_data = std::make_shared(source.size()); ::memcpy(m_data->startingAddress(), source.c_str(), source.size()); } diff --git a/CondCore/CondDB/src/CoralMsgReporter.cc b/CondCore/CondDB/src/CoralMsgReporter.cc index 7acc72e746878..d87516bbf095c 100644 --- a/CondCore/CondDB/src/CoralMsgReporter.cc +++ b/CondCore/CondDB/src/CoralMsgReporter.cc @@ -2,6 +2,7 @@ #include #include // fix bug #58581 #include // fix bug #58581 +#include // Local include files #include "CondCore/CondDB/interface/Logger.h" @@ -142,7 +143,7 @@ void cond::persistency::CoralMsgReporter::report(int lvl, const std::string&, co } void cond::persistency::CoralMsgReporter::subscribe(Logger& logger) { - m_dispatcher.reset(new MsgDispatcher(logger)); + m_dispatcher = std::make_shared(logger); std::weak_ptr callBack(m_dispatcher); logger.subscribeCoralMessages(callBack); } diff --git a/CondCore/CondDB/src/PayloadReader.cc b/CondCore/CondDB/src/PayloadReader.cc index 1b042dbb21091..2d96409fee39e 100644 --- a/CondCore/CondDB/src/PayloadReader.cc +++ b/CondCore/CondDB/src/PayloadReader.cc @@ -1,10 +1,12 @@ +#include + #include "CondCore/CondDB/interface/PayloadReader.h" namespace cond { namespace persistency { - PayloadReader::PayloadReader() { m_connection.reset(new ConnectionPool); } + PayloadReader::PayloadReader() { m_connection = std::make_shared(); } PayloadReader::PayloadReader(const PayloadReader& rhs) : m_connection(rhs.m_connection), m_session(rhs.m_session) {} diff --git a/CondCore/Utilities/bin/conddb_test_gt_load.cpp b/CondCore/Utilities/bin/conddb_test_gt_load.cpp index 1696695b9902c..9a9df3fe1c2b5 100644 --- a/CondCore/Utilities/bin/conddb_test_gt_load.cpp +++ b/CondCore/Utilities/bin/conddb_test_gt_load.cpp @@ -6,6 +6,7 @@ #include #include +#include // ================================================================================ @@ -156,7 +157,7 @@ namespace cond { } // namespace cond cond::UntypedPayloadProxy::UntypedPayloadProxy(Session& session) : m_session(session) { - m_data.reset(new pimpl); + m_data = std::make_shared(); m_data->current.clear(); } diff --git a/CondCore/Utilities/bin/conddb_test_gt_perf.cpp b/CondCore/Utilities/bin/conddb_test_gt_perf.cpp index 46448140c61b3..9342d082115a2 100644 --- a/CondCore/Utilities/bin/conddb_test_gt_perf.cpp +++ b/CondCore/Utilities/bin/conddb_test_gt_perf.cpp @@ -115,7 +115,7 @@ cond::Session cond::ConnectionPoolWrapper::createSession(const std::string& conn } cond::UntypedPayloadProxy::UntypedPayloadProxy() : m_session(), m_iov(), m_data(), m_buffer() { - m_data.reset(new pimpl); + m_data = std::make_shared(); m_data->current.clear(); } diff --git a/CondCore/Utilities/src/Utilities.cc b/CondCore/Utilities/src/Utilities.cc index c81517a00358a..62f2cdefcb1d6 100644 --- a/CondCore/Utilities/src/Utilities.cc +++ b/CondCore/Utilities/src/Utilities.cc @@ -42,7 +42,7 @@ namespace cond { while ((ch = getch()) != RETURN) { if (ch == BACKSPACE) { - if (password.length() != 0) { + if (!password.empty()) { if (show_asterisk) std::cout << "\b \b"; password.resize(password.length() - 1); diff --git a/CondFormats/JetMETObjects/src/FactorizedJetCorrectorCalculator.cc b/CondFormats/JetMETObjects/src/FactorizedJetCorrectorCalculator.cc index e610b07cfe9a2..2c1bbf8b8a794 100644 --- a/CondFormats/JetMETObjects/src/FactorizedJetCorrectorCalculator.cc +++ b/CondFormats/JetMETObjects/src/FactorizedJetCorrectorCalculator.cc @@ -118,15 +118,15 @@ void FactorizedJetCorrectorCalculator::initCorrectors(const std::string& fLevels if (mLevels[i] == kL1 || mLevels[i] == kL1JPT || mLevels[i] == kL2 || mLevels[i] == kL3 || mLevels[i] == kL4 || mLevels[i] == kL6 || mLevels[i] == kL1fj) mCorrectors.push_back(new SimpleJetCorrector(Files[i])); - else if (mLevels[i] == kL5 && FlavorOption.length() == 0) + else if (mLevels[i] == kL5 && FlavorOption.empty()) handleError("FactorizedJetCorrectorCalculator", "must specify flavor option when requesting L5Flavor correction!"); - else if (mLevels[i] == kL5 && FlavorOption.length() > 0) + else if (mLevels[i] == kL5 && !FlavorOption.empty()) mCorrectors.push_back(new SimpleJetCorrector(Files[i], FlavorOption)); - else if (mLevels[i] == kL7 && PartonOption.length() == 0) + else if (mLevels[i] == kL7 && PartonOption.empty()) handleError("FactorizedJetCorrectorCalculator", "must specify parton option when requesting L7Parton correction!"); - else if (mLevels[i] == kL7 && PartonOption.length() > 0) + else if (mLevels[i] == kL7 && !PartonOption.empty()) mCorrectors.push_back(new SimpleJetCorrector(Files[i], PartonOption)); else { std::stringstream sserr; diff --git a/CondFormats/JetMETObjects/src/SimpleJetCorrectionUncertainty.cc b/CondFormats/JetMETObjects/src/SimpleJetCorrectionUncertainty.cc index c3546acc405f8..3370c9e26959a 100644 --- a/CondFormats/JetMETObjects/src/SimpleJetCorrectionUncertainty.cc +++ b/CondFormats/JetMETObjects/src/SimpleJetCorrectionUncertainty.cc @@ -54,7 +54,7 @@ float SimpleJetCorrectionUncertainty::uncertaintyBin(unsigned fBin, float fY, bo return -999.0; } const std::vector& p = mParameters.record(fBin).parameters(); - if ((p.size() % 3) != 0 or p.size() == 0) + if ((p.size() % 3) != 0 or p.empty()) throw cms::Exception("SimpleJetCorrectionUncertainty") << "wrong # of parameters: multiple of 3 expected, " << p.size() << " got"; Span3 yGrid{p}; diff --git a/MuonAnalysis/MomentumScaleCalibration/plugins/DBReader.cc b/MuonAnalysis/MomentumScaleCalibration/plugins/DBReader.cc index 3982db4ba43de..1426db1c18413 100644 --- a/MuonAnalysis/MomentumScaleCalibration/plugins/DBReader.cc +++ b/MuonAnalysis/MomentumScaleCalibration/plugins/DBReader.cc @@ -1,6 +1,7 @@ // system include files #include #include +#include #include #include #include @@ -71,11 +72,11 @@ void DBReader::initialize(const edm::EventSetup& iSetup) { // This string is one of: scale, resolution, background. // Create the corrector and set the parameters if (type_ == "scale") - corrector_.reset(new MomentumScaleCorrector(dbObject)); + corrector_ = std::make_shared(dbObject); else if (type_ == "resolution") - resolution_.reset(new ResolutionFunction(dbObject)); + resolution_ = std::make_shared(dbObject); else if (type_ == "background") - background_.reset(new BackgroundFunction(dbObject)); + background_ = std::make_shared(dbObject); else { edm::LogPrint("DBReader") << "Error: unrecognized type. Use one of those: 'scale', 'resolution', 'background'" << std::endl; diff --git a/MuonAnalysis/MomentumScaleCalibration/plugins/MuScleFitMuonProducer.cc b/MuonAnalysis/MomentumScaleCalibration/plugins/MuScleFitMuonProducer.cc index ed6e61e80fad3..b63aa11575d2b 100644 --- a/MuonAnalysis/MomentumScaleCalibration/plugins/MuScleFitMuonProducer.cc +++ b/MuonAnalysis/MomentumScaleCalibration/plugins/MuScleFitMuonProducer.cc @@ -104,7 +104,7 @@ void MuScleFitMuonProducer::produce(edm::Event& iEvent, const edm::EventSetup& i //std::cout << "parameters size from dbObject = " << dbObject_->parameters.size() << std::endl;; // Create the corrector and set the parameters - corrector_.reset(new MomentumScaleCorrector(dbObject_.product())); + corrector_ = std::make_shared(dbObject_.product()); if (patMuons_ == true) { edm::Handle allMuons; diff --git a/OnlineDB/EcalCondDB/bin/cmsecal_rootplot.cpp b/OnlineDB/EcalCondDB/bin/cmsecal_rootplot.cpp index 15c41fd1c6e86..9b50a2faddfd1 100644 --- a/OnlineDB/EcalCondDB/bin/cmsecal_rootplot.cpp +++ b/OnlineDB/EcalCondDB/bin/cmsecal_rootplot.cpp @@ -744,7 +744,7 @@ int main(int argc, char* argv[]) { string line; ifstream* finput = (ifstream*)&cin; - if (file.length() > 0) { + if (!file.empty()) { finput = new ifstream(file.c_str()); } while (getline(*finput, line) && finput->good() && !finput->eof()) { @@ -757,7 +757,7 @@ int main(int argc, char* argv[]) { finput->close(); - if (file.length() > 0) { + if (!file.empty()) { delete finput; } rootplot.draw(); diff --git a/OnlineDB/EcalCondDB/src/LMFDat.cc b/OnlineDB/EcalCondDB/src/LMFDat.cc index 1d59f42481e27..269cfb3cb6561 100644 --- a/OnlineDB/EcalCondDB/src/LMFDat.cc +++ b/OnlineDB/EcalCondDB/src/LMFDat.cc @@ -131,7 +131,7 @@ std::string LMFDat::buildSelectSql(int logic_id, int direction) { std::stringstream sql; int count = 1; if (getLMFRunIOVID() > 0) { - if (_where.length() > 0) { + if (!_where.empty()) { // check if this is an expert query. If so, add a WHERE clause _where = " AND " + _where; } diff --git a/OnlineDB/EcalCondDB/src/LMFRunTag.cc b/OnlineDB/EcalCondDB/src/LMFRunTag.cc index a659a4a3d20e5..878e6a6fe441f 100644 --- a/OnlineDB/EcalCondDB/src/LMFRunTag.cc +++ b/OnlineDB/EcalCondDB/src/LMFRunTag.cc @@ -79,7 +79,7 @@ bool LMFRunTag::isValid() { if (getVersion() <= 0) { ret = false; } - if (getGeneralTag().length() <= 0) { + if (getGeneralTag().empty()) { ret = false; } return ret; diff --git a/OnlineDB/EcalCondDB/src/LMFSeqDat.cc b/OnlineDB/EcalCondDB/src/LMFSeqDat.cc index 36a3e82a28074..2bb357188bcfb 100644 --- a/OnlineDB/EcalCondDB/src/LMFSeqDat.cc +++ b/OnlineDB/EcalCondDB/src/LMFSeqDat.cc @@ -129,7 +129,7 @@ bool LMFSeqDat::isValid() const { if (getSequenceStart().isNull()) { ret = false; } - if ((getSequenceStop().str().length() > 0) && (getSequenceStop().microsTime() < getSequenceStart().microsTime())) { + if ((!getSequenceStop().str().empty()) && (getSequenceStop().microsTime() < getSequenceStart().microsTime())) { ret = false; } if (getSequenceStop() == Tm().plusInfinity()) { @@ -147,7 +147,7 @@ std::string LMFSeqDat::writeDBSql(Statement *stmt) { throw(std::runtime_error("LMFSeqDat::writeDB: not valid")); } - if (getSequenceStop().str().length() == 0) { + if (getSequenceStop().str().empty()) { setSequenceStop(dh.getPlusInfTm()); } int runIOVID = m_runIOV.getID();