From 6691b75f34d75ff3dfde13b6afa60265cfe198b2 Mon Sep 17 00:00:00 2001 From: mmusich Date: Sat, 20 Nov 2021 11:48:30 +0100 Subject: [PATCH 1/8] get rid of CMS deprecation warnings in Alignment/CommonAlignmentProducer --- .../test/AlignmentRcdScan.cpp | 67 +++++++++-------- .../test/GlobalPositionRcdRead.cpp | 36 ++++----- .../test/GlobalPositionRcdScan.cpp | 48 ++++++------ .../test/GlobalPositionRcdWrite.cpp | 74 +++++++++---------- .../test/TestAccessGeom.cc | 62 +++++++++------- 5 files changed, 151 insertions(+), 136 deletions(-) diff --git a/Alignment/CommonAlignmentProducer/test/AlignmentRcdScan.cpp b/Alignment/CommonAlignmentProducer/test/AlignmentRcdScan.cpp index 6c4116c1d1830..1122cddd4e479 100644 --- a/Alignment/CommonAlignmentProducer/test/AlignmentRcdScan.cpp +++ b/Alignment/CommonAlignmentProducer/test/AlignmentRcdScan.cpp @@ -13,7 +13,7 @@ #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/EDAnalyzer.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" #include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/Framework/interface/ESHandle.h" #include "CondFormats/Alignment/interface/Alignments.h" @@ -26,7 +26,7 @@ #include "FWCore/Framework/interface/ESWatcher.h" -class AlignmentRcdScan : public edm::EDAnalyzer { +class AlignmentRcdScan : public edm::one::EDAnalyzer<> { public: enum Mode { Unknown = 0, Tk = 1, DT = 2, CSC = 3 }; @@ -36,7 +36,7 @@ class AlignmentRcdScan : public edm::EDAnalyzer { virtual void analyze(const edm::Event& evt, const edm::EventSetup& evtSetup); private: - void inspectRecord(const std::string& rcdname, const edm::Event& evt, const edm::ESHandle& alignments); + void inspectRecord(const std::string& rcdname, const edm::Event& evt, const Alignments* alignments); int mode_; bool verbose_; @@ -45,11 +45,19 @@ class AlignmentRcdScan : public edm::EDAnalyzer { edm::ESWatcher watchDT_; edm::ESWatcher watchCSC_; + const edm::ESGetToken tkAliToken_; + const edm::ESGetToken dtAliToken_; + const edm::ESGetToken cscAliToken_; + Alignments* refAlignments_; }; AlignmentRcdScan::AlignmentRcdScan(const edm::ParameterSet& iConfig) - : verbose_(iConfig.getUntrackedParameter("verbose")), refAlignments_(0) { + : verbose_(iConfig.getUntrackedParameter("verbose")), + tkAliToken_(esConsumes()), + dtAliToken_(esConsumes()), + cscAliToken_(esConsumes()), + refAlignments_(0) { std::string modestring = iConfig.getUntrackedParameter("mode"); if (modestring == "Tk") { mode_ = Tk; @@ -73,36 +81,31 @@ AlignmentRcdScan::~AlignmentRcdScan() { void AlignmentRcdScan::analyze(const edm::Event& evt, const edm::EventSetup& evtSetup) { if (mode_ == Tk && watchTk_.check(evtSetup)) { - edm::ESHandle alignments; - evtSetup.get().get(alignments); + const Alignments* alignments = &evtSetup.getData(tkAliToken_); inspectRecord("TrackerAlignmentRcd", evt, alignments); } if (mode_ == DT && watchDT_.check(evtSetup)) { - edm::ESHandle alignments; - evtSetup.get().get(alignments); + const Alignments* alignments = &evtSetup.getData(dtAliToken_); inspectRecord("DTAlignmentRcd", evt, alignments); } if (mode_ == CSC && watchCSC_.check(evtSetup)) { - edm::ESHandle alignments; - evtSetup.get().get(alignments); + const Alignments* alignments = &evtSetup.getData(cscAliToken_); inspectRecord("CSCAlignmentRcd", evt, alignments); } } -void AlignmentRcdScan::inspectRecord(const std::string& rcdname, - const edm::Event& evt, - const edm::ESHandle& alignments) { - std::cout << rcdname << " content starting from run " << evt.run(); +void AlignmentRcdScan::inspectRecord(const std::string& rcdname, const edm::Event& evt, const Alignments* alignments) { + edm::LogPrint("inspectRecord") << rcdname << " content starting from run " << evt.run(); if (verbose_ == false) { - std::cout << std::endl; + edm::LogPrint("inspectRecord") << std::endl; return; } - std::cout << " with " << alignments->m_align.size() << " entries" << std::endl; + edm::LogPrint("inspectRecord") << " with " << alignments->m_align.size() << " entries" << std::endl; if (refAlignments_) { - std::cout << " Compared to previous record:" << std::endl; + edm::LogPrint("inspectRecord") << " Compared to previous record:" << std::endl; double meanX = 0; double rmsX = 0; @@ -132,10 +135,10 @@ void AlignmentRcdScan::inspectRecord(const std::string& rcdname, rmsR += pow(i->translation().perp() - iref->translation().perp(), 2); dPhi = i->translation().phi() - iref->translation().phi(); - if (dPhi > TMath::Pi()) - dPhi -= 2.0 * TMath::Pi(); - if (dPhi < -TMath::Pi()) - dPhi += 2.0 * TMath::Pi(); + if (dPhi > M_PI) + dPhi -= 2.0 * M_PI; + if (dPhi < -M_PI) + dPhi += 2.0 * M_PI; meanPhi += dPhi; rmsPhi += dPhi * dPhi; @@ -152,23 +155,23 @@ void AlignmentRcdScan::inspectRecord(const std::string& rcdname, meanPhi /= alignments->m_align.size(); rmsPhi /= alignments->m_align.size(); - std::cout << " mean X shift: " << std::setw(12) << std::scientific << std::setprecision(3) << meanX - << " (RMS = " << sqrt(rmsX) << ")" << std::endl; - std::cout << " mean Y shift: " << std::setw(12) << std::scientific << std::setprecision(3) << meanY - << " (RMS = " << sqrt(rmsY) << ")" << std::endl; - std::cout << " mean Z shift: " << std::setw(12) << std::scientific << std::setprecision(3) << meanZ - << " (RMS = " << sqrt(rmsZ) << ")" << std::endl; - std::cout << " mean R shift: " << std::setw(12) << std::scientific << std::setprecision(3) << meanR - << " (RMS = " << sqrt(rmsR) << ")" << std::endl; - std::cout << " mean Phi shift: " << std::setw(12) << std::scientific << std::setprecision(3) << meanPhi - << " (RMS = " << sqrt(rmsPhi) << ")" << std::endl; + edm::LogPrint("inspectRecord") << " mean X shift: " << std::setw(12) << std::scientific << std::setprecision(3) + << meanX << " (RMS = " << sqrt(rmsX) << ")" << std::endl; + edm::LogPrint("inspectRecord") << " mean Y shift: " << std::setw(12) << std::scientific << std::setprecision(3) + << meanY << " (RMS = " << sqrt(rmsY) << ")" << std::endl; + edm::LogPrint("inspectRecord") << " mean Z shift: " << std::setw(12) << std::scientific << std::setprecision(3) + << meanZ << " (RMS = " << sqrt(rmsZ) << ")" << std::endl; + edm::LogPrint("inspectRecord") << " mean R shift: " << std::setw(12) << std::scientific << std::setprecision(3) + << meanR << " (RMS = " << sqrt(rmsR) << ")" << std::endl; + edm::LogPrint("inspectRecord") << " mean Phi shift: " << std::setw(12) << std::scientific << std::setprecision(3) + << meanPhi << " (RMS = " << sqrt(rmsPhi) << ")" << std::endl; delete refAlignments_; } refAlignments_ = new Alignments(*alignments); - std::cout << std::endl; + edm::LogPrint("inspectRecord") << std::endl; } //define this as a plug-in diff --git a/Alignment/CommonAlignmentProducer/test/GlobalPositionRcdRead.cpp b/Alignment/CommonAlignmentProducer/test/GlobalPositionRcdRead.cpp index 49d294153fbe3..c9fa36320ad76 100644 --- a/Alignment/CommonAlignmentProducer/test/GlobalPositionRcdRead.cpp +++ b/Alignment/CommonAlignmentProducer/test/GlobalPositionRcdRead.cpp @@ -3,7 +3,7 @@ #include #include "FWCore/Framework/interface/EventSetup.h" -#include "FWCore/Framework/interface/EDAnalyzer.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" #include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/Framework/interface/ESHandle.h" #include "CondFormats/Alignment/interface/Alignments.h" @@ -11,41 +11,43 @@ #include "CondFormats/AlignmentRecord/interface/GlobalPositionRcd.h" #include "DataFormats/DetId/interface/DetId.h" -class GlobalPositionRcdRead : public edm::EDAnalyzer { +class GlobalPositionRcdRead : public edm::one::EDAnalyzer<> { public: - explicit GlobalPositionRcdRead(const edm::ParameterSet& iConfig) : nEventCalls_(0) {} + explicit GlobalPositionRcdRead(const edm::ParameterSet& iConfig) : GPRToken_(esConsumes()), nEventCalls_(0) {} ~GlobalPositionRcdRead() {} - virtual void analyze(const edm::Event& evt, const edm::EventSetup& evtSetup); + void analyze(const edm::Event&, const edm::EventSetup&) override; private: + const edm::ESGetToken GPRToken_; unsigned int nEventCalls_; }; -void GlobalPositionRcdRead::analyze(const edm::Event& evt, const edm::EventSetup& evtSetup) { +void GlobalPositionRcdRead::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { if (nEventCalls_ > 0) { - std::cout << "Reading from DB to be done only once, " - << "set 'untracked PSet maxEvents = {untracked int32 input = 1}'." << std::endl; + edm::LogPrint("GlobalPositionRcdRead") + << "Reading from DB to be done only once, " + << "set 'untracked PSet maxEvents = {untracked int32 input = 1}'." << std::endl; return; } - std::cout << "Reading from database in GlobalPositionRcdRead::analyze..." << std::endl; + edm::LogPrint("GlobalPositionRcdRead") << "Reading from database in GlobalPositionRcdRead::analyze..." << std::endl; - edm::ESHandle globalPositionRcd; - evtSetup.get().get(globalPositionRcd); + const Alignments* globalPositionRcd = &iSetup.getData(GPRToken_); - std::cout << "Expecting entries in " << DetId(DetId::Tracker).rawId() << " " << DetId(DetId::Muon).rawId() << " " - << DetId(DetId::Ecal).rawId() << " " << DetId(DetId::Hcal).rawId() << " " << DetId(DetId::Calo).rawId() - << std::endl; + edm::LogPrint("GlobalPositionRcdRead") << "Expecting entries in " << DetId(DetId::Tracker).rawId() << " " + << DetId(DetId::Muon).rawId() << " " << DetId(DetId::Ecal).rawId() << " " + << DetId(DetId::Hcal).rawId() << " " << DetId(DetId::Calo).rawId() + << std::endl; for (std::vector::const_iterator i = globalPositionRcd->m_align.begin(); i != globalPositionRcd->m_align.end(); ++i) { - std::cout << "entry " << i->rawId() << " translation " << i->translation() << " angles " - << i->rotation().eulerAngles() << std::endl; - std::cout << i->rotation() << std::endl; + edm::LogPrint("GlobalPositionRcdRead") << "entry " << i->rawId() << " translation " << i->translation() + << " angles " << i->rotation().eulerAngles() << std::endl; + edm::LogPrint("GlobalPositionRcdRead") << i->rotation() << std::endl; } - std::cout << "done!" << std::endl; + edm::LogPrint("GlobalPositionRcdRead") << "done!" << std::endl; nEventCalls_++; } diff --git a/Alignment/CommonAlignmentProducer/test/GlobalPositionRcdScan.cpp b/Alignment/CommonAlignmentProducer/test/GlobalPositionRcdScan.cpp index 6ede80231d3ae..98335f9ac78db 100644 --- a/Alignment/CommonAlignmentProducer/test/GlobalPositionRcdScan.cpp +++ b/Alignment/CommonAlignmentProducer/test/GlobalPositionRcdScan.cpp @@ -4,7 +4,7 @@ #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/EventSetup.h" -#include "FWCore/Framework/interface/EDAnalyzer.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" #include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/Framework/interface/ESHandle.h" #include "CondFormats/Alignment/interface/Alignments.h" @@ -16,16 +16,17 @@ #include "Alignment/CommonAlignment/interface/Utilities.h" -class GlobalPositionRcdScan : public edm::EDAnalyzer { +class GlobalPositionRcdScan : public edm::one::EDAnalyzer<> { public: explicit GlobalPositionRcdScan(const edm::ParameterSet& iConfig); - virtual ~GlobalPositionRcdScan() {} + virtual ~GlobalPositionRcdScan() = default; virtual void analyze(const edm::Event& evt, const edm::EventSetup& evtSetup); virtual void endJob(); private: edm::ESWatcher watcher_; + const edm::ESGetToken GPRToken_; bool eulerAngles_; bool alignAngles_; @@ -35,7 +36,7 @@ class GlobalPositionRcdScan : public edm::EDAnalyzer { }; GlobalPositionRcdScan::GlobalPositionRcdScan(const edm::ParameterSet& iConfig) - : eulerAngles_(false), alignAngles_(false), matrix_(false), firstRun_(0), lastRun_(0) { + : GPRToken_(esConsumes()), eulerAngles_(false), alignAngles_(false), matrix_(false), firstRun_(0), lastRun_(0) { const std::string howRot(iConfig.getParameter("rotation")); if (howRot == "euler" || howRot == "all") @@ -59,33 +60,34 @@ void GlobalPositionRcdScan::analyze(const edm::Event& evt, const edm::EventSetup firstRun_ = lastRun_; if (watcher_.check(evtSetup)) { - edm::ESHandle globalPositionRcd; - evtSetup.get().get(globalPositionRcd); + const Alignments* globalPositionRcd = &evtSetup.getData(GPRToken_); - std::cout << "=====================================================\n" - << "GlobalPositionRcd content starting from run " << evt.run() << ":" << std::endl; + edm::LogPrint("GlobalPositionRcdScan") + << "=====================================================\n" + << "GlobalPositionRcd content starting from run " << evt.run() << ":" << std::endl; for (std::vector::const_iterator i = globalPositionRcd->m_align.begin(); i != globalPositionRcd->m_align.end(); ++i) { - std::cout << " Component "; + edm::LogPrint("GlobalPositionRcdScan") << " Component "; if (i->rawId() == DetId(DetId::Tracker).rawId()) { - std::cout << "Tracker"; + edm::LogPrint("GlobalPositionRcdScan") << "Tracker"; } else if (i->rawId() == DetId(DetId::Muon).rawId()) { - std::cout << "Muon "; + edm::LogPrint("GlobalPositionRcdScan") << "Muon "; } else if (i->rawId() == DetId(DetId::Ecal).rawId()) { - std::cout << "Ecal "; + edm::LogPrint("GlobalPositionRcdScan") << "Ecal "; } else if (i->rawId() == DetId(DetId::Hcal).rawId()) { - std::cout << "Hcal "; + edm::LogPrint("GlobalPositionRcdScan") << "Hcal "; } else if (i->rawId() == DetId(DetId::Calo).rawId()) { - std::cout << "Calo "; + edm::LogPrint("GlobalPositionRcdScan") << "Calo "; } else { - std::cout << "Unknown"; + edm::LogPrint("GlobalPositionRcdScan") << "Unknown"; } - std::cout << " entry " << i->rawId() << "\n translation " << i->translation() << "\n"; + edm::LogPrint("GlobalPositionRcdScan") + << " entry " << i->rawId() << "\n translation " << i->translation() << "\n"; const AlignTransform::Rotation hepRot(i->rotation()); if (eulerAngles_) { - std::cout << " euler angles " << hepRot.eulerAngles() << std::endl; + edm::LogPrint("GlobalPositionRcdScan") << " euler angles " << hepRot.eulerAngles() << std::endl; } if (alignAngles_) { const align::RotationType matrix(hepRot.xx(), @@ -98,20 +100,20 @@ void GlobalPositionRcdScan::analyze(const edm::Event& evt, const edm::EventSetup hepRot.zy(), hepRot.zz()); const AlgebraicVector angles(align::toAngles(matrix)); - std::cout << " alpha, beta, gamma (" << angles[0] << ", " << angles[1] << ", " << angles[2] << ')' - << std::endl; + edm::LogPrint("GlobalPositionRcdScan") + << " alpha, beta, gamma (" << angles[0] << ", " << angles[1] << ", " << angles[2] << ')' << std::endl; } if (matrix_) { - std::cout << " rotation matrix " << hepRot << std::endl; + edm::LogPrint("GlobalPositionRcdScan") << " rotation matrix " << hepRot << std::endl; } } } } void GlobalPositionRcdScan::endJob() { - std::cout << "\n=====================================================\n" - << "=====================================================\n" - << "Checked run range " << firstRun_ << " to " << lastRun_ << "." << std::endl; + edm::LogPrint("GlobalPositionRcdScan") << "\n=====================================================\n" + << "=====================================================\n" + << "Checked run range " << firstRun_ << " to " << lastRun_ << "." << std::endl; } //define this as a plug-in diff --git a/Alignment/CommonAlignmentProducer/test/GlobalPositionRcdWrite.cpp b/Alignment/CommonAlignmentProducer/test/GlobalPositionRcdWrite.cpp index d34780d0b9285..7a802dc13ee3e 100644 --- a/Alignment/CommonAlignmentProducer/test/GlobalPositionRcdWrite.cpp +++ b/Alignment/CommonAlignmentProducer/test/GlobalPositionRcdWrite.cpp @@ -7,12 +7,11 @@ #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/ServiceRegistry/interface/Service.h" #include "FWCore/Framework/interface/EventSetup.h" -#include "FWCore/Framework/interface/EDAnalyzer.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" #include "FWCore/Framework/interface/MakerMacros.h" #include "DataFormats/DetId/interface/DetId.h" // Database -#include "FWCore/Framework/interface/ESHandle.h" #include "CondCore/DBOutputService/interface/PoolDBOutputService.h" // Alignment @@ -21,7 +20,7 @@ #include "CondFormats/Alignment/interface/AlignTransform.h" #include "CondFormats/AlignmentRecord/interface/GlobalPositionRcd.h" -class GlobalPositionRcdWrite : public edm::EDAnalyzer { +class GlobalPositionRcdWrite : public edm::one::EDAnalyzer<> { public: explicit GlobalPositionRcdWrite(const edm::ParameterSet& iConfig) : m_useEulerAngles(iConfig.getParameter("useEulerAngles")), @@ -63,13 +62,13 @@ AlignTransform::Rotation GlobalPositionRcdWrite::toMatrix(double alpha, double b void GlobalPositionRcdWrite::analyze(const edm::Event& evt, const edm::EventSetup& iSetup) { if (nEventCalls_ > 0) { - std::cout << "Writing to DB to be done only once, " - << "set 'untracked PSet maxEvents = {untracked int32 input = 1}'." - << "(Your writing should be fine.)" << std::endl; + edm::LogPrint("GlobalPositionRcdWrite") << "Writing to DB to be done only once, " + << "set 'untracked PSet maxEvents = {untracked int32 input = 1}'." + << "(Your writing should be fine.)" << std::endl; return; } - Alignments* globalPositions = new Alignments(); + Alignments globalPositions{}; AlignTransform tracker(AlignTransform::Translation(m_tracker.getParameter("x"), m_tracker.getParameter("y"), @@ -127,37 +126,38 @@ void GlobalPositionRcdWrite::analyze(const edm::Event& evt, const edm::EventSetu m_calo.getParameter("gamma")), DetId(DetId::Calo).rawId()); - std::cout << "\nProvided rotation angles are interpreted as " - << ((m_useEulerAngles != true) ? "rotations around X, Y and Z" : "Euler angles") << ".\n" - << std::endl; + edm::LogPrint("GlobalPositionRcdWrite") + << "\nProvided rotation angles are interpreted as " + << ((m_useEulerAngles != true) ? "rotations around X, Y and Z" : "Euler angles") << ".\n" + << std::endl; - std::cout << "Tracker (" << tracker.rawId() << ") at " << tracker.translation() << " " - << tracker.rotation().eulerAngles() << std::endl; - std::cout << tracker.rotation() << std::endl; + edm::LogPrint("GlobalPositionRcdWrite") << "Tracker (" << tracker.rawId() << ") at " << tracker.translation() << " " + << tracker.rotation().eulerAngles() << std::endl; + edm::LogPrint("GlobalPositionRcdWrite") << tracker.rotation() << std::endl; - std::cout << "Muon (" << muon.rawId() << ") at " << muon.translation() << " " << muon.rotation().eulerAngles() - << std::endl; - std::cout << muon.rotation() << std::endl; + edm::LogPrint("GlobalPositionRcdWrite") + << "Muon (" << muon.rawId() << ") at " << muon.translation() << " " << muon.rotation().eulerAngles() << std::endl; + edm::LogPrint("GlobalPositionRcdWrite") << muon.rotation() << std::endl; - std::cout << "Ecal (" << ecal.rawId() << ") at " << ecal.translation() << " " << ecal.rotation().eulerAngles() - << std::endl; - std::cout << ecal.rotation() << std::endl; + edm::LogPrint("GlobalPositionRcdWrite") + << "Ecal (" << ecal.rawId() << ") at " << ecal.translation() << " " << ecal.rotation().eulerAngles() << std::endl; + edm::LogPrint("GlobalPositionRcdWrite") << ecal.rotation() << std::endl; - std::cout << "Hcal (" << hcal.rawId() << ") at " << hcal.translation() << " " << hcal.rotation().eulerAngles() - << std::endl; - std::cout << hcal.rotation() << std::endl; + edm::LogPrint("GlobalPositionRcdWrite") + << "Hcal (" << hcal.rawId() << ") at " << hcal.translation() << " " << hcal.rotation().eulerAngles() << std::endl; + edm::LogPrint("GlobalPositionRcdWrite") << hcal.rotation() << std::endl; - std::cout << "Calo (" << calo.rawId() << ") at " << calo.translation() << " " << calo.rotation().eulerAngles() - << std::endl; - std::cout << calo.rotation() << std::endl; + edm::LogPrint("GlobalPositionRcdWrite") + << "Calo (" << calo.rawId() << ") at " << calo.translation() << " " << calo.rotation().eulerAngles() << std::endl; + edm::LogPrint("GlobalPositionRcdWrite") << calo.rotation() << std::endl; - globalPositions->m_align.push_back(tracker); - globalPositions->m_align.push_back(muon); - globalPositions->m_align.push_back(ecal); - globalPositions->m_align.push_back(hcal); - globalPositions->m_align.push_back(calo); + globalPositions.m_align.push_back(tracker); + globalPositions.m_align.push_back(muon); + globalPositions.m_align.push_back(ecal); + globalPositions.m_align.push_back(hcal); + globalPositions.m_align.push_back(calo); - std::cout << "Uploading to the database..." << std::endl; + edm::LogPrint("GlobalPositionRcdWrite") << "Uploading to the database..." << std::endl; edm::Service poolDbService; @@ -165,16 +165,12 @@ void GlobalPositionRcdWrite::analyze(const edm::Event& evt, const edm::EventSetu throw cms::Exception("NotAvailable") << "PoolDBOutputService not available"; // if (poolDbService->isNewTagRequest("GlobalPositionRcd")) { - // poolDbService->createNewIOV(&(*globalPositions), poolDbService->endOfTime(), "GlobalPositionRcd"); + // poolDbService->createOneIOV(globalPositions, poolDbService->endOfTime(), "GlobalPositionRcd"); // } else { - // poolDbService->appendSinceTime(&(*globalPositions), poolDbService->currentTime(), "GlobalPositionRcd"); + // poolDbService->appendOneIOV(globalPositions, poolDbService->currentTime(), "GlobalPositionRcd"); // } - poolDbService->writeOne(&(*globalPositions), - poolDbService->currentTime(), - //poolDbService->beginOfTime(), - "GlobalPositionRcd"); - - std::cout << "done!" << std::endl; + poolDbService->writeOneIOV(globalPositions, poolDbService->currentTime(), "GlobalPositionRcd"); + edm::LogPrint("GlobalPositionRcdWrite") << "done!" << std::endl; nEventCalls_++; } diff --git a/Alignment/CommonAlignmentProducer/test/TestAccessGeom.cc b/Alignment/CommonAlignmentProducer/test/TestAccessGeom.cc index 5f54828c5ecfa..686dc59f38054 100644 --- a/Alignment/CommonAlignmentProducer/test/TestAccessGeom.cc +++ b/Alignment/CommonAlignmentProducer/test/TestAccessGeom.cc @@ -22,7 +22,7 @@ // user include files #include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDAnalyzer.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/EventSetup.h" @@ -47,42 +47,54 @@ // class declaration // -class TestAccessGeom : public edm::EDAnalyzer { +class TestAccessGeom : public edm::one::EDAnalyzer<> { public: explicit TestAccessGeom(const edm::ParameterSet&); - ~TestAccessGeom(); + ~TestAccessGeom() = default; private: virtual void analyze(const edm::Event&, const edm::EventSetup&); // ----------member data --------------------------- - const std::vector tkGeomLabels_; const std::vector dtGeomLabels_; const std::vector cscGeomLabels_; -}; - -// -// constants, enums and typedefs -// -// -// static data member definitions -// + std::vector> tkGeoTokens_; + std::vector> dtGeoTokens_; + std::vector> cscGeoTokens_; +}; // // constructors and destructor // TestAccessGeom::TestAccessGeom(const edm::ParameterSet& iConfig) - : tkGeomLabels_(iConfig.getParameter >("TrackerGeomLabels")), - dtGeomLabels_(iConfig.getParameter >("DTGeomLabels")), - cscGeomLabels_(iConfig.getParameter >("CSCGeomLabels")) { + : tkGeomLabels_(iConfig.getParameter>("TrackerGeomLabels")), + dtGeomLabels_(iConfig.getParameter>("DTGeomLabels")), + cscGeomLabels_(iConfig.getParameter>("CSCGeomLabels")) { //now do what ever initialization is needed -} -TestAccessGeom::~TestAccessGeom() { - // do anything here that needs to be done at desctruction time - // (e.g. close files, deallocate resources etc.) + for (std::vector::const_iterator iL = tkGeomLabels_.begin(), iE = tkGeomLabels_.end(); iL != iE; ++iL) { + auto index = std::distance(tkGeomLabels_.begin(), iL); + TString label(iL->c_str()); + label.ReplaceAll(" ", ""); // fix for buggy framework + tkGeoTokens_[index] = esConsumes(edm::ESInputTag("", label.Data())); + } + + for (std::vector::const_iterator iL = dtGeomLabels_.begin(), iE = dtGeomLabels_.end(); iL != iE; ++iL) { + auto index = std::distance(dtGeomLabels_.begin(), iL); + TString label(iL->c_str()); + label.ReplaceAll(" ", ""); // fix for buggy framework + dtGeoTokens_[index] = esConsumes(edm::ESInputTag("", label.Data())); + } + + for (std::vector::const_iterator iL = cscGeomLabels_.begin(), iE = cscGeomLabels_.end(); iL != iE; + ++iL) { + auto index = std::distance(cscGeomLabels_.begin(), iL); + TString label(iL->c_str()); + label.ReplaceAll(" ", ""); // fix for buggy framework + cscGeoTokens_[index] = esConsumes(edm::ESInputTag("", label.Data())); + } } // @@ -102,9 +114,9 @@ void TestAccessGeom::analyze(const edm::Event& iEvent, const edm::EventSetup& iS TString label(iL->c_str()); label.ReplaceAll(" ", ""); // fix for buggy framework edm::LogInfo("Test") << "Try access to tracker geometry with label '" << label << "'."; + auto idx = std::distance(tkGeomLabels_.begin(), iL); //*iL << "'."; - edm::ESHandle tkGeomHandle; - iSetup.get().get(label, tkGeomHandle); // *iL, tkGeomHandle); + edm::ESHandle tkGeomHandle = iSetup.getHandle(tkGeoTokens_[idx]); edm::LogInfo("Test") << "TrackerGeometry pointer: " << tkGeomHandle.product(); } @@ -112,9 +124,9 @@ void TestAccessGeom::analyze(const edm::Event& iEvent, const edm::EventSetup& iS TString label(iL->c_str()); label.ReplaceAll(" ", ""); // fix for buggy framework edm::LogInfo("Test") << "Try access to DT geometry with label '" << label << "'."; + auto idx = std::distance(dtGeomLabels_.begin(), iL); //*iL << "'."; - edm::ESHandle dtGeomHandle; - iSetup.get().get(label, dtGeomHandle); //*iL, dtGeomHandle); + edm::ESHandle dtGeomHandle = iSetup.getHandle(dtGeoTokens_[idx]); edm::LogInfo("Test") << "DTGeometry pointer: " << dtGeomHandle.product(); } @@ -122,9 +134,9 @@ void TestAccessGeom::analyze(const edm::Event& iEvent, const edm::EventSetup& iS TString label(iL->c_str()); label.ReplaceAll(" ", ""); // fix for buggy framework edm::LogInfo("Test") << "Try access to CSC geometry with label '" << label << "'."; + auto idx = std::distance(cscGeomLabels_.begin(), iL); //*iL << "'."; - edm::ESHandle cscGeomHandle; - iSetup.get().get(label, cscGeomHandle); //*iL, cscGeomHandle); + edm::ESHandle cscGeomHandle = iSetup.getHandle(cscGeoTokens_[idx]); edm::LogInfo("Test") << "CSCGeometry pointer: " << cscGeomHandle.product(); } From 9f16c1a4952532b77c4026cde207151357877529 Mon Sep 17 00:00:00 2001 From: mmusich Date: Sat, 20 Nov 2021 11:56:09 +0100 Subject: [PATCH 2/8] get rid of CMS deprecation warnings in Alignment/OfflineValidation --- Alignment/OfflineValidation/plugins/CosmicSplitterValidation.cc | 1 - Alignment/OfflineValidation/src/TrackerValidationVariables.cc | 1 - 2 files changed, 2 deletions(-) diff --git a/Alignment/OfflineValidation/plugins/CosmicSplitterValidation.cc b/Alignment/OfflineValidation/plugins/CosmicSplitterValidation.cc index e9ae585ecd97b..251ea5ded5af1 100644 --- a/Alignment/OfflineValidation/plugins/CosmicSplitterValidation.cc +++ b/Alignment/OfflineValidation/plugins/CosmicSplitterValidation.cc @@ -34,7 +34,6 @@ #include "FWCore/Framework/interface/ConsumesCollector.h" #include "FWCore/Framework/interface/one/EDAnalyzer.h" -#include "FWCore/Framework/interface/EDProducer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/Framework/interface/MakerMacros.h" diff --git a/Alignment/OfflineValidation/src/TrackerValidationVariables.cc b/Alignment/OfflineValidation/src/TrackerValidationVariables.cc index 736cc0b8c0d2c..c786da4b73ff8 100644 --- a/Alignment/OfflineValidation/src/TrackerValidationVariables.cc +++ b/Alignment/OfflineValidation/src/TrackerValidationVariables.cc @@ -1,7 +1,6 @@ #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Framework/interface/ConsumesCollector.h" #include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDAnalyzer.h" #include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/EventSetup.h" From 0a3e1dbf08a5a27e9924692a7dcb1222d1d32036 Mon Sep 17 00:00:00 2001 From: mmusich Date: Sat, 20 Nov 2021 12:29:28 +0100 Subject: [PATCH 3/8] get rid of CMS deprecation warnings in Alignment/LaserAlignment --- .../plugins/LaserAlignmentT0Producer.cc | 85 +++++++++++++------ .../plugins/LaserAlignmentT0Producer.h | 53 ------------ 2 files changed, 61 insertions(+), 77 deletions(-) delete mode 100644 Alignment/LaserAlignment/plugins/LaserAlignmentT0Producer.h diff --git a/Alignment/LaserAlignment/plugins/LaserAlignmentT0Producer.cc b/Alignment/LaserAlignment/plugins/LaserAlignmentT0Producer.cc index fbe932baaa005..a187837fe7ec5 100644 --- a/Alignment/LaserAlignment/plugins/LaserAlignmentT0Producer.cc +++ b/Alignment/LaserAlignment/plugins/LaserAlignmentT0Producer.cc @@ -1,10 +1,56 @@ -// -*- C++ -*- +/**\class LaserAlignmentT0Producer LaserAlignmentT0Producer.cc NewAlignment/LaserAlignmentT0Producer/src/LaserAlignmentT0Producer.cc + + Description: AlCaRECO producer (TkLAS data filter) running on T0 + + Implementation: + +*/ +// +// Original Author: Jan Olzem +// Created: Wed Feb 13 17:30:40 CET 2008 +// $Id: LaserAlignmentT0Producer.h,v 1.2 2008/03/03 09:43:32 olzem Exp $ +// +// + +// system include files +#include +#include + +// user include files +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/global/EDProducer.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +#include "DataFormats/Common/interface/DetSetVector.h" +#include "DataFormats/SiStripDigi/interface/SiStripDigi.h" +#include "DataFormats/SiStripDigi/interface/SiStripRawDigi.h" + // -// Package: LaserAlignmentT0Producer -// Class: LaserAlignmentT0Producer +// class decleration // -#include "Alignment/LaserAlignment/plugins/LaserAlignmentT0Producer.h" +class LaserAlignmentT0Producer : public edm::global::EDProducer<> { +public: + explicit LaserAlignmentT0Producer(const edm::ParameterSet&); + ~LaserAlignmentT0Producer() override; + +private: + void beginJob() override; + void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override; + //void produce(edm::Event&, const edm::EventSetup&) override; + void FillDetIds(void); + + // container for cfg data + std::vector digiProducerList; + std::string digiProducer; + std::string digiLabel; + std::string digiType; + + // this one stores the det ids for all the 434 LAS modules + std::vector theLasDetIds; +}; /// /// Loops all input SiStripDigi or SiStripRawDigi collections @@ -18,12 +64,10 @@ LaserAlignmentT0Producer::LaserAlignmentT0Producer(const edm::ParameterSet& iCon digiProducerList = iConfig.getParameter>("DigiProducerList"); // loop all input products - for (std::vector::iterator aDigiProducer = digiProducerList.begin(); - aDigiProducer != digiProducerList.end(); - ++aDigiProducer) { - std::string digiProducer = aDigiProducer->getParameter("DigiProducer"); - std::string digiLabel = aDigiProducer->getParameter("DigiLabel"); - std::string digiType = aDigiProducer->getParameter("DigiType"); + for (const auto& aDigiProducer : digiProducerList) { + std::string digiProducer = aDigiProducer.getParameter("DigiProducer"); + std::string digiLabel = aDigiProducer.getParameter("DigiLabel"); + std::string digiType = aDigiProducer.getParameter("DigiType"); // check if raw/processed digis in this collection if (digiType == "Raw") { @@ -40,7 +84,7 @@ LaserAlignmentT0Producer::LaserAlignmentT0Producer(const edm::ParameterSet& iCon /// /// /// -LaserAlignmentT0Producer::~LaserAlignmentT0Producer() {} +LaserAlignmentT0Producer::~LaserAlignmentT0Producer() = default; /// /// outline: @@ -49,16 +93,15 @@ LaserAlignmentT0Producer::~LaserAlignmentT0Producer() {} /// * for each product: selects only LAS module DetSets /// and copies them to new DetSetVector /// -void LaserAlignmentT0Producer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { +void LaserAlignmentT0Producer::produce(edm::StreamID id, edm::Event& iEvent, const edm::EventSetup& iSetup) const { + //void LaserAlignmentT0Producer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { using namespace edm; // loop all input products - for (std::vector::iterator aDigiProducer = digiProducerList.begin(); - aDigiProducer != digiProducerList.end(); - ++aDigiProducer) { - std::string digiProducer = aDigiProducer->getParameter("DigiProducer"); - std::string digiLabel = aDigiProducer->getParameter("DigiLabel"); - std::string digiType = aDigiProducer->getParameter("DigiType"); + for (const auto& aDigiProducer : digiProducerList) { + std::string digiProducer = aDigiProducer.getParameter("DigiProducer"); + std::string digiLabel = aDigiProducer.getParameter("DigiLabel"); + std::string digiType = aDigiProducer.getParameter("DigiType"); // now a distinction of cases: raw or processed digis? @@ -114,7 +157,6 @@ void LaserAlignmentT0Producer::produce(edm::Event& iEvent, const edm::EventSetup for (edm::DetSet::const_iterator aDigi = aDetSet->begin(); aDigi != aDetSet->end(); ++aDigi) { outputDetSet.push_back(*aDigi); } - theDigiVector.push_back(outputDetSet); } } @@ -139,11 +181,6 @@ void LaserAlignmentT0Producer::beginJob() { FillDetIds(); } -/// -/// -/// -void LaserAlignmentT0Producer::endJob() {} - /// /// fill a vector with all the det ids of the 434 /// siStrip modules relevant to the LAS diff --git a/Alignment/LaserAlignment/plugins/LaserAlignmentT0Producer.h b/Alignment/LaserAlignment/plugins/LaserAlignmentT0Producer.h deleted file mode 100644 index 797ed1d612ef8..0000000000000 --- a/Alignment/LaserAlignment/plugins/LaserAlignmentT0Producer.h +++ /dev/null @@ -1,53 +0,0 @@ -/**\class LaserAlignmentT0Producer LaserAlignmentT0Producer.cc NewAlignment/LaserAlignmentT0Producer/src/LaserAlignmentT0Producer.cc - - Description: AlCaRECO producer (TkLAS data filter) running on T0 - - Implementation: - -*/ -// -// Original Author: Jan Olzem -// Created: Wed Feb 13 17:30:40 CET 2008 -// $Id: LaserAlignmentT0Producer.h,v 1.2 2008/03/03 09:43:32 olzem Exp $ -// -// - -// system include files -#include -#include - -// user include files -#include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDProducer.h" -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/MakerMacros.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" - -#include -#include -#include - -// -// class decleration -// - -class LaserAlignmentT0Producer : public edm::EDProducer { -public: - explicit LaserAlignmentT0Producer(const edm::ParameterSet&); - ~LaserAlignmentT0Producer() override; - -private: - void beginJob() override; - void produce(edm::Event&, const edm::EventSetup&) override; - void endJob() override; - void FillDetIds(void); - - // container for cfg data - std::vector digiProducerList; - std::string digiProducer; - std::string digiLabel; - std::string digiType; - - // this one stores the det ids for all the 434 LAS modules - std::vector theLasDetIds; -}; From 1b0ae36cf9cdef8f6716b47824bfa99ffe1e8827 Mon Sep 17 00:00:00 2001 From: mmusich Date: Sat, 20 Nov 2021 13:15:33 +0100 Subject: [PATCH 4/8] get rid of CMS deprecation warnings in Alignment/LaserAlignmentSimulation --- .../test/SealModules.cc | 6 - .../test/SimAnalyzer.cc | 105 +++++++++++++++--- .../test/SimAnalyzer.h | 87 --------------- 3 files changed, 91 insertions(+), 107 deletions(-) delete mode 100644 Alignment/LaserAlignmentSimulation/test/SealModules.cc delete mode 100644 Alignment/LaserAlignmentSimulation/test/SimAnalyzer.h diff --git a/Alignment/LaserAlignmentSimulation/test/SealModules.cc b/Alignment/LaserAlignmentSimulation/test/SealModules.cc deleted file mode 100644 index 5b4f4957757e5..0000000000000 --- a/Alignment/LaserAlignmentSimulation/test/SealModules.cc +++ /dev/null @@ -1,6 +0,0 @@ - -// define the SEAL module -#include "Alignment/LaserAlignmentSimulation/test/SimAnalyzer.h" -#include "FWCore/Framework/interface/MakerMacros.h" - -DEFINE_FWK_MODULE(SimAnalyzer); diff --git a/Alignment/LaserAlignmentSimulation/test/SimAnalyzer.cc b/Alignment/LaserAlignmentSimulation/test/SimAnalyzer.cc index 96bdc7fe6ba89..cdf6ecf53aa33 100644 --- a/Alignment/LaserAlignmentSimulation/test/SimAnalyzer.cc +++ b/Alignment/LaserAlignmentSimulation/test/SimAnalyzer.cc @@ -1,13 +1,14 @@ -/** \file SimAnalyzer.cc +/** \class SimAnalyzer * Get some statistics and plots about the simulation of the Laser Alignment * System * - * $Date: 2009/12/14 22:21:45 $ - * $Revision: 1.6 $ + * $Date: 2008/01/05 15:30:17 $ + * $Revision: 1.5 $ * \author Maarten Thomas */ -#include "Alignment/LaserAlignmentSimulation/test/SimAnalyzer.h" +// user includes +#include "FWCore/Framework/interface/one/EDAnalyzer.h" #include "DataFormats/DetId/interface/DetId.h" #include "DataFormats/SiStripDetId/interface/StripSubdetector.h" #include "FWCore/Framework/interface/ESHandle.h" @@ -21,10 +22,85 @@ #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h" #include "SimDataFormats/TrackingHit/interface/PSimHit.h" #include "SimDataFormats/TrackingHit/interface/PSimHitContainer.h" + +// ROOT +#include "TH1.h" +#include "TH2.h" #include "TFile.h" +// system includes +#include + +class SimAnalyzer : public edm::one::EDAnalyzer<> { +public: + /// constructor + explicit SimAnalyzer(edm::ParameterSet const &theConf); + /// destructor + ~SimAnalyzer(); + + /// this method will do the user analysis + virtual void analyze(edm::Event const &theEvent, edm::EventSetup const &theSetup); + /// begin job + virtual void beginJob(); + +private: + /// return angle in radian betwee 0 and 2*pi + double angle(double theAngle); + /// write the ROOT file with histograms + void closeRootFile(); + /// initialize the histograms + void initHistograms(); + /// find the dets which are hit by a laser beam and fill the SimHit info into + /// histograms + void trackerStatistics(edm::Event const &theEvent, edm::EventSetup const &theSetup); + +private: + const edm::ESGetToken tkGeomToken_; + int theEvents; + int theDebugLevel; + double theSearchPhiTIB; + double theSearchPhiTOB; + double theSearchPhiTEC; + double theSearchZTIB; + double theSearchZTOB; + + // Tree stuff + TFile *theFile; + int theCompression; + std::string theFileName; + + // the histograms for Barrel Hits + TH1D *theBarrelSimHitsX; + TH1D *theBarrelSimHitsY; + TH1D *theBarrelSimHitsZ; + TH2D *theBarrelSimHitsYvsX; + TH2D *theBarrelSimHitsXvsZ; + TH2D *theBarrelSimHitsYvsZ; + TH2D *theBarrelSimHitsRvsZ; + TH2D *theBarrelSimHitsPhivsX; + TH2D *theBarrelSimHitsPhivsY; + TH2D *theBarrelSimHitsPhivsZ; + + // the histograms for Endcap Hits + TH1D *theEndcapSimHitsX; + TH1D *theEndcapSimHitsY; + TH1D *theEndcapSimHitsZ; + TH2D *theEndcapSimHitsYvsX; + TH2D *theEndcapSimHitsXvsZ; + TH2D *theEndcapSimHitsYvsZ; + TH2D *theEndcapSimHitsRvsZ; + TH2D *theEndcapSimHitsPhivsX; + TH2D *theEndcapSimHitsPhivsY; + TH2D *theEndcapSimHitsPhivsZ; + + // the histograms for all SimHits + TH2D *theSimHitsRvsZ; + TH2D *theSimHitsPhivsZ; +}; + SimAnalyzer::SimAnalyzer(edm::ParameterSet const &theConf) - : theEvents(0), + : tkGeomToken_(esConsumes()), + theEvents(0), theDebugLevel(theConf.getUntrackedParameter("DebugLevel", 0)), theSearchPhiTIB(theConf.getUntrackedParameter("SearchWindowPhiTIB", 0.05)), theSearchPhiTOB(theConf.getUntrackedParameter("SearchWindowPhiTOB", 0.05)), @@ -244,27 +320,25 @@ void SimAnalyzer::initHistograms() { } void SimAnalyzer::trackerStatistics(edm::Event const &theEvent, edm::EventSetup const &theSetup) { - LogDebug("SimAnalyzer") << " theTrackerGeometry; - theSetup.get().get(theTrackerGeometry); - const TrackerGeometry &theTracker(*theTrackerGeometry); + const TrackerGeometry *theTracker = &theSetup.getData(tkGeomToken_); // the DetUnits - TrackingGeometry::DetContainer theDetUnits = theTracker.dets(); + TrackingGeometry::DetContainer theDetUnits = theTracker->dets(); // get the SimHitContainers std::vector> theSimHitContainers; theEvent.getManyByType(theSimHitContainers); - LogDebug("SimAnalyzer") << " Geometry node for TrackingGeometry is " << &(*theTrackerGeometry) << "\n I have " - << theTrackerGeometry->dets().size() << " detectors " - << "\n I have " << theTrackerGeometry->detTypes().size() << " types " + LogDebug("SimAnalyzer") << " Geometry node for TrackingGeometry is " << theTracker << "\n I have " + << theTracker->dets().size() << " detectors " + << "\n I have " << theTracker->detTypes().size() << " types " << "\n theDetUnits has " << theDetUnits.size() << " dets "; // theSimHits contains all the sim hits in this event @@ -279,7 +353,7 @@ void SimAnalyzer::trackerStatistics(edm::Event const &theEvent, edm::EventSetup DetId theDetUnitId((*iHit).detUnitId()); // get the DetUnit via the DetUnitId and cast it to a StripGeomDetUnit - const GeomDet *theDet = theTracker.idToDet(theDetUnitId); + const GeomDet *theDet = theTracker->idToDet(theDetUnitId); // the detector part std::string thePart = ""; @@ -377,3 +451,6 @@ void SimAnalyzer::trackerStatistics(edm::Event const &theEvent, edm::EventSetup edm::LogInfo("SimAnalyzer") << " number of SimHits = " << theBarrelHits << "/" << theEndcapHits << " (Barrel/Endcap) "; } + +#include "FWCore/Framework/interface/MakerMacros.h" +DEFINE_FWK_MODULE(SimAnalyzer); diff --git a/Alignment/LaserAlignmentSimulation/test/SimAnalyzer.h b/Alignment/LaserAlignmentSimulation/test/SimAnalyzer.h deleted file mode 100644 index 701ced78e21c7..0000000000000 --- a/Alignment/LaserAlignmentSimulation/test/SimAnalyzer.h +++ /dev/null @@ -1,87 +0,0 @@ -#ifndef LaserAlignmentSimulation_SimAnalyzer_H -#define LaserAlignmentSimulation_SimAnalyzer_H - -/** \class SimAnalyzer - * Get some statistics and plots about the simulation of the Laser Alignment - * System - * - * $Date: 2008/01/05 15:30:17 $ - * $Revision: 1.5 $ - * \author Maarten Thomas - */ - -#include "FWCore/Framework/interface/EDAnalyzer.h" - -// ROOT -#include "TH1.h" -#include "TH2.h" -class TFile; - -#include - -class SimAnalyzer : public edm::EDAnalyzer { -public: - /// constructor - explicit SimAnalyzer(edm::ParameterSet const &theConf); - /// destructor - ~SimAnalyzer(); - - /// this method will do the user analysis - virtual void analyze(edm::Event const &theEvent, edm::EventSetup const &theSetup); - /// begin job - virtual void beginJob(); - -private: - /// return angle in radian betwee 0 and 2*pi - double angle(double theAngle); - /// write the ROOT file with histograms - void closeRootFile(); - /// initialize the histograms - void initHistograms(); - /// find the dets which are hit by a laser beam and fill the SimHit info into - /// histograms - void trackerStatistics(edm::Event const &theEvent, edm::EventSetup const &theSetup); - -private: - int theEvents; - int theDebugLevel; - double theSearchPhiTIB; - double theSearchPhiTOB; - double theSearchPhiTEC; - double theSearchZTIB; - double theSearchZTOB; - - // Tree stuff - TFile *theFile; - int theCompression; - std::string theFileName; - - // the histograms for Barrel Hits - TH1D *theBarrelSimHitsX; - TH1D *theBarrelSimHitsY; - TH1D *theBarrelSimHitsZ; - TH2D *theBarrelSimHitsYvsX; - TH2D *theBarrelSimHitsXvsZ; - TH2D *theBarrelSimHitsYvsZ; - TH2D *theBarrelSimHitsRvsZ; - TH2D *theBarrelSimHitsPhivsX; - TH2D *theBarrelSimHitsPhivsY; - TH2D *theBarrelSimHitsPhivsZ; - - // the histograms for Endcap Hits - TH1D *theEndcapSimHitsX; - TH1D *theEndcapSimHitsY; - TH1D *theEndcapSimHitsZ; - TH2D *theEndcapSimHitsYvsX; - TH2D *theEndcapSimHitsXvsZ; - TH2D *theEndcapSimHitsYvsZ; - TH2D *theEndcapSimHitsRvsZ; - TH2D *theEndcapSimHitsPhivsX; - TH2D *theEndcapSimHitsPhivsY; - TH2D *theEndcapSimHitsPhivsZ; - - // the histograms for all SimHits - TH2D *theSimHitsRvsZ; - TH2D *theSimHitsPhivsZ; -}; -#endif From 4c2097b2f65cf6b38df9fe1fa9c427bba6927208 Mon Sep 17 00:00:00 2001 From: mmusich Date: Sat, 20 Nov 2021 13:24:00 +0100 Subject: [PATCH 5/8] get rid of CMS deprecation warnings in Alignment/MuonAlignment --- .../plugins/MuonGeometrySVGTemplate.cc | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/Alignment/MuonAlignment/plugins/MuonGeometrySVGTemplate.cc b/Alignment/MuonAlignment/plugins/MuonGeometrySVGTemplate.cc index b447c59441aec..addfe09767f8e 100644 --- a/Alignment/MuonAlignment/plugins/MuonGeometrySVGTemplate.cc +++ b/Alignment/MuonAlignment/plugins/MuonGeometrySVGTemplate.cc @@ -20,7 +20,7 @@ #include #include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDAnalyzer.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/Event.h" @@ -43,7 +43,7 @@ // class decleration // -class MuonGeometrySVGTemplate : public edm::EDAnalyzer { +class MuonGeometrySVGTemplate : public edm::one::EDAnalyzer<> { public: explicit MuonGeometrySVGTemplate(const edm::ParameterSet &iConfig); ~MuonGeometrySVGTemplate() override; @@ -58,14 +58,6 @@ class MuonGeometrySVGTemplate : public edm::EDAnalyzer { // std::string m_diskm4TemplateName; }; -// -// constants, enums and typedefs -// - -// -// static data member definitions -// - // // constructors and destructor // @@ -73,7 +65,7 @@ class MuonGeometrySVGTemplate : public edm::EDAnalyzer { MuonGeometrySVGTemplate::MuonGeometrySVGTemplate(const edm::ParameterSet &iConfig) : m_wheelTemplateName(iConfig.getParameter("wheelTemplateName")) {} -MuonGeometrySVGTemplate::~MuonGeometrySVGTemplate() {} +MuonGeometrySVGTemplate::~MuonGeometrySVGTemplate() = default; // ------------ method called to for each event ------------ void MuonGeometrySVGTemplate::analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup) { From 981fff11768e43e1b3804d9a3ae6579176736cb3 Mon Sep 17 00:00:00 2001 From: mmusich Date: Sat, 20 Nov 2021 15:06:41 +0100 Subject: [PATCH 6/8] get rid of CMS deprecation warnings in Alignment/MuonAlignmentAlgorithms --- .../plugins/CSCOverlapsBeamSplashCut.cc | 29 +++---------------- .../plugins/MuonAlignmentPreFilter.cc | 27 ++++++++--------- 2 files changed, 16 insertions(+), 40 deletions(-) diff --git a/Alignment/MuonAlignmentAlgorithms/plugins/CSCOverlapsBeamSplashCut.cc b/Alignment/MuonAlignmentAlgorithms/plugins/CSCOverlapsBeamSplashCut.cc index 8764616e85ffe..179b133ab6404 100644 --- a/Alignment/MuonAlignmentAlgorithms/plugins/CSCOverlapsBeamSplashCut.cc +++ b/Alignment/MuonAlignmentAlgorithms/plugins/CSCOverlapsBeamSplashCut.cc @@ -20,7 +20,7 @@ // user include files #include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDFilter.h" +#include "FWCore/Framework/interface/one/EDFilter.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/Framework/interface/ESHandle.h" @@ -37,44 +37,29 @@ // class decleration // -class CSCOverlapsBeamSplashCut : public edm::EDFilter { +class CSCOverlapsBeamSplashCut : public edm::one::EDFilter { public: explicit CSCOverlapsBeamSplashCut(const edm::ParameterSet&); - ~CSCOverlapsBeamSplashCut() override; + ~CSCOverlapsBeamSplashCut() override = default; private: - void beginJob() override; bool filter(edm::Event&, const edm::EventSetup&) override; - void endJob() override; - // ----------member data --------------------------- edm::InputTag m_src; int m_maxSegments; TH1F* m_numSegments; }; -// -// constants, enums and typedefs -// - -// -// static data member definitions -// - // // constructors and destructor // CSCOverlapsBeamSplashCut::CSCOverlapsBeamSplashCut(const edm::ParameterSet& iConfig) : m_src(iConfig.getParameter("src")), m_maxSegments(iConfig.getParameter("maxSegments")) { + usesResource(TFileService::kSharedResource); edm::Service tFileService; m_numSegments = tFileService->make("numSegments", "", 201, -0.5, 200.5); } -CSCOverlapsBeamSplashCut::~CSCOverlapsBeamSplashCut() { - // do anything here that needs to be done at desctruction time - // (e.g. close files, deallocate resources etc.) -} - // // member functions // @@ -96,11 +81,5 @@ bool CSCOverlapsBeamSplashCut::filter(edm::Event& iEvent, const edm::EventSetup& return false; } -// ------------ method called once each job just before starting event loop ------------ -void CSCOverlapsBeamSplashCut::beginJob() {} - -// ------------ method called once each job just after ending the event loop ------------ -void CSCOverlapsBeamSplashCut::endJob() {} - //define this as a plug-in DEFINE_FWK_MODULE(CSCOverlapsBeamSplashCut); diff --git a/Alignment/MuonAlignmentAlgorithms/plugins/MuonAlignmentPreFilter.cc b/Alignment/MuonAlignmentAlgorithms/plugins/MuonAlignmentPreFilter.cc index aeceb092b2427..53605abe42ec0 100644 --- a/Alignment/MuonAlignmentAlgorithms/plugins/MuonAlignmentPreFilter.cc +++ b/Alignment/MuonAlignmentAlgorithms/plugins/MuonAlignmentPreFilter.cc @@ -13,7 +13,7 @@ #include #include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDFilter.h" +#include "FWCore/Framework/interface/stream/EDFilter.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" @@ -27,27 +27,24 @@ #include "DataFormats/DetId/interface/DetId.h" #include "DataFormats/MuonDetId/interface/MuonSubdetId.h" -class MuonAlignmentPreFilter : public edm::EDFilter { +class MuonAlignmentPreFilter : public edm::stream::EDFilter<> { public: explicit MuonAlignmentPreFilter(const edm::ParameterSet&); - ~MuonAlignmentPreFilter() override {} + ~MuonAlignmentPreFilter() override = default; private: - void beginJob() override {} bool filter(edm::Event&, const edm::EventSetup&) override; - void endJob() override {} // ----------member data --------------------------- - - edm::InputTag m_tracksTag; - double m_minTrackPt; - double m_minTrackP; - bool m_allowTIDTEC; - int m_minTrackerHits; - int m_minDTHits; - int m_minCSCHits; - double m_minTrackEta; - double m_maxTrackEta; + const edm::InputTag m_tracksTag; + const double m_minTrackPt; + const double m_minTrackP; + const bool m_allowTIDTEC; + const int m_minTrackerHits; + const int m_minDTHits; + const int m_minCSCHits; + const double m_minTrackEta; + const double m_maxTrackEta; }; MuonAlignmentPreFilter::MuonAlignmentPreFilter(const edm::ParameterSet& cfg) From 6de96224344122ca25f393a2b8b38dc0863c4ed8 Mon Sep 17 00:00:00 2001 From: mmusich Date: Sat, 20 Nov 2021 16:27:25 +0100 Subject: [PATCH 7/8] get rid of CMS deprecation warnings in Alignment/SurveyAnalysis --- Alignment/SurveyAnalysis/test/Modules.cc | 10 --- .../SurveyAnalysis/test/SurveyDBReader.cc | 51 ++++++++++++--- .../SurveyAnalysis/test/SurveyDBReader.h | 37 ----------- .../SurveyAnalysis/test/SurveyInputDummy.cc | 62 ++++++++++++++----- .../SurveyAnalysis/test/SurveyInputDummy.h | 51 --------------- .../SurveyAnalysis/test/SurveyInputTest.cc | 30 ++++++++- .../SurveyAnalysis/test/SurveyInputTest.h | 32 ---------- Alignment/SurveyAnalysis/test/SurveyTest.cc | 37 ++++++++++- Alignment/SurveyAnalysis/test/SurveyTest.h | 38 ------------ .../SurveyAnalysis/test/TestConverter.cpp | 21 ++++--- .../SurveyAnalysis/test/TestConverter2.cpp | 31 +++++----- .../SurveyAnalysis/test/TestIdealGeometry.cpp | 17 +++-- .../test/TestIdealGeometry2.cpp | 23 +++---- 13 files changed, 199 insertions(+), 241 deletions(-) delete mode 100644 Alignment/SurveyAnalysis/test/Modules.cc delete mode 100644 Alignment/SurveyAnalysis/test/SurveyDBReader.h delete mode 100644 Alignment/SurveyAnalysis/test/SurveyInputDummy.h delete mode 100644 Alignment/SurveyAnalysis/test/SurveyInputTest.h delete mode 100644 Alignment/SurveyAnalysis/test/SurveyTest.h diff --git a/Alignment/SurveyAnalysis/test/Modules.cc b/Alignment/SurveyAnalysis/test/Modules.cc deleted file mode 100644 index cb359a2975ea7..0000000000000 --- a/Alignment/SurveyAnalysis/test/Modules.cc +++ /dev/null @@ -1,10 +0,0 @@ -#include "Alignment/SurveyAnalysis/test/SurveyDBReader.h" -#include "Alignment/SurveyAnalysis/test/SurveyInputDummy.h" -#include "Alignment/SurveyAnalysis/test/SurveyInputTest.h" -#include "Alignment/SurveyAnalysis/test/SurveyTest.h" -#include "FWCore/Framework/interface/MakerMacros.h" - -DEFINE_FWK_MODULE(SurveyDBReader); -DEFINE_FWK_MODULE(SurveyInputDummy); -DEFINE_FWK_MODULE(SurveyInputTest); -DEFINE_FWK_MODULE(SurveyTest); diff --git a/Alignment/SurveyAnalysis/test/SurveyDBReader.cc b/Alignment/SurveyAnalysis/test/SurveyDBReader.cc index 7378de8465555..43cfa67f6d233 100644 --- a/Alignment/SurveyAnalysis/test/SurveyDBReader.cc +++ b/Alignment/SurveyAnalysis/test/SurveyDBReader.cc @@ -1,3 +1,14 @@ +/** \class SurveyDBReader + * + * Module that reads survey info from DB and prints them out. + * + * Only one parameter to set the name of the output ROOT file. + * + * $Date: 2007/06/19 14:56:18 $ + * $Revision: 1.3 $ + * \author Chung Khim Lae + */ + #include "TFile.h" #include "TTree.h" #include "Math/EulerAngles.h" @@ -10,22 +21,39 @@ #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" + +typedef AlignTransform SurveyValue; +typedef Alignments SurveyValues; + +class SurveyDBReader : public edm::one::EDAnalyzer<> { +public: + /// Set file name + SurveyDBReader(const edm::ParameterSet&); + + /// Read from DB and print survey info. + virtual void beginJob() { theFirstEvent = true; } + + virtual void analyze(const edm::Event&, const edm::EventSetup&); -#include "Alignment/SurveyAnalysis/test/SurveyDBReader.h" +private: + const edm::ESGetToken tkSurveyToken_; + const edm::ESGetToken tkSurveyErrToken_; + const std::string theFileName; + + bool theFirstEvent; +}; SurveyDBReader::SurveyDBReader(const edm::ParameterSet& cfg) - : theFileName(cfg.getParameter("fileName")), theFirstEvent(true) {} + : tkSurveyToken_(esConsumes()), + tkSurveyErrToken_(esConsumes()), + theFileName(cfg.getParameter("fileName")), + theFirstEvent(true) {} void SurveyDBReader::analyze(const edm::Event&, const edm::EventSetup& setup) { - typedef AlignTransform SurveyValue; - typedef Alignments SurveyValues; - if (theFirstEvent) { - edm::ESHandle valuesHandle; - edm::ESHandle errorsHandle; - - setup.get().get(valuesHandle); - setup.get().get(errorsHandle); + const SurveyValues* valuesHandle = &setup.getData(tkSurveyToken_); + const SurveyErrors* errorsHandle = &setup.getData(tkSurveyErrToken_); const std::vector& values = valuesHandle->m_align; const std::vector& errors = errorsHandle->m_surveyErrors; @@ -81,3 +109,6 @@ void SurveyDBReader::analyze(const edm::Event&, const edm::EventSetup& setup) { theFirstEvent = false; } } + +#include "FWCore/Framework/interface/MakerMacros.h" +DEFINE_FWK_MODULE(SurveyDBReader); diff --git a/Alignment/SurveyAnalysis/test/SurveyDBReader.h b/Alignment/SurveyAnalysis/test/SurveyDBReader.h deleted file mode 100644 index 57d0afba3963b..0000000000000 --- a/Alignment/SurveyAnalysis/test/SurveyDBReader.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef Alignment_SurveyAnalysis_SurveyDBReader_h -#define Alignment_SurveyAnalysis_SurveyDBReader_h - -/** \class SurveyDBReader - * - * Module that reads survey info from DB and prints them out. - * - * Usage: - * module reader = SurveyDBReader { string fileName = 'surveyDBDump.root' } - * path p = { reader } - * - * Only one parameter to set the name of the output ROOT file. - * - * $Date: 2007/06/19 14:56:18 $ - * $Revision: 1.3 $ - * \author Chung Khim Lae - */ - -#include "FWCore/Framework/interface/EDAnalyzer.h" - -class SurveyDBReader : public edm::EDAnalyzer { -public: - /// Set file name - SurveyDBReader(const edm::ParameterSet&); - - /// Read from DB and print survey info. - virtual void beginJob() { theFirstEvent = true; } - - virtual void analyze(const edm::Event&, const edm::EventSetup&); - -private: - std::string theFileName; - - bool theFirstEvent; -}; - -#endif diff --git a/Alignment/SurveyAnalysis/test/SurveyInputDummy.cc b/Alignment/SurveyAnalysis/test/SurveyInputDummy.cc index e500979980c1f..857c23d18e181 100644 --- a/Alignment/SurveyAnalysis/test/SurveyInputDummy.cc +++ b/Alignment/SurveyAnalysis/test/SurveyInputDummy.cc @@ -1,18 +1,53 @@ -#include "TRandom3.h" -#include "FWCore/Framework/interface/EventSetup.h" -#include "FWCore/Framework/interface/ESHandle.h" -#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h" -#include "Geometry/Records/interface/TrackerTopologyRcd.h" +/** \class SurveyInputDummy + * + * For uploading some random survey values and pseudo-dummy errors to DB. + * + * If randomizeValue is true, the survey value of a structure in a level + * is randomly selected from a Gaussian distribution of mean given by the + * ideal geometry and width = "value" (e.g. width = 5e-4 for a Panel). + * + * The covariance matrix for all structures of a level will be diagonal + * given by value^2 * identity. + * + * \author Chung Khim Lae + */ #include "Alignment/CommonAlignment/interface/AlignableObjectId.h" +#include "Alignment/CommonAlignment/interface/StructureType.h" #include "Alignment/CommonAlignment/interface/SurveyDet.h" +#include "Alignment/SurveyAnalysis/interface/SurveyInputBase.h" #include "Alignment/TrackerAlignment/interface/AlignableTracker.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h" +#include "Geometry/Records/interface/TrackerTopologyRcd.h" +#include "TRandom3.h" + +#include + +class SurveyInputDummy : public SurveyInputBase { +public: + SurveyInputDummy(const edm::ParameterSet&); + + /// Read ideal tracker geometry from DB + virtual void analyze(const edm::Event&, const edm::EventSetup&); -#include "Alignment/SurveyAnalysis/test/SurveyInputDummy.h" +private: + /// Add survey info to an alignable + void addSurveyInfo(Alignable*); + + const edm::ESGetToken tTopoToken_; + const edm::ESGetToken tkGeomToken_; + const bool theRandomizeValue; // randomize survey values if true + + std::map theErrors; +}; SurveyInputDummy::SurveyInputDummy(const edm::ParameterSet& cfg) - : theRandomizeValue(cfg.getParameter("randomizeValue")) { + : tTopoToken_(esConsumes()), + tkGeomToken_(esConsumes()), + theRandomizeValue(cfg.getParameter("randomizeValue")) { typedef std::vector ParameterSets; const ParameterSets& errors = cfg.getParameter("errors"); @@ -34,14 +69,10 @@ SurveyInputDummy::SurveyInputDummy(const edm::ParameterSet& cfg) void SurveyInputDummy::analyze(const edm::Event&, const edm::EventSetup& setup) { if (theFirstEvent) { //Retrieve tracker topology from geometry - edm::ESHandle tTopoHandle; - setup.get().get(tTopoHandle); - const TrackerTopology* const tTopo = tTopoHandle.product(); + const TrackerTopology* const tTopo = &setup.getData(tTopoToken_); + const TrackerGeometry* tracker = &setup.getData(tkGeomToken_); - edm::ESHandle tracker; - setup.get().get(tracker); - - Alignable* ali = new AlignableTracker(&*tracker, tTopo); + Alignable* ali = new AlignableTracker(tracker, tTopo); addSurveyInfo(ali); addComponent(ali); @@ -91,3 +122,6 @@ void SurveyInputDummy::addSurveyInfo(Alignable* ali) { ali->setSurvey(new SurveyDet(ali->surface(), cov)); } + +#include "FWCore/Framework/interface/MakerMacros.h" +DEFINE_FWK_MODULE(SurveyInputDummy); diff --git a/Alignment/SurveyAnalysis/test/SurveyInputDummy.h b/Alignment/SurveyAnalysis/test/SurveyInputDummy.h deleted file mode 100644 index 3c97d255012bf..0000000000000 --- a/Alignment/SurveyAnalysis/test/SurveyInputDummy.h +++ /dev/null @@ -1,51 +0,0 @@ -#ifndef Alignment_SurveyAnalysis_SurveyInputDummy_h -#define Alignment_SurveyAnalysis_SurveyInputDummy_h - -/** \class SurveyInputDummy - * - * For uploading some random survey values and pseudo-dummy errors to DB. - * - * Usage: - * module FPix = SurveyInputDummy - * { - * bool randomizeValue = true - * - * VPSet errors = - * { - * { string level = "DetUnit" double value = 5e-4 }, - * { string level = "Panel" double value = 5e-4 } - * } - * } - * - * If randomizeValue is true, the survey value of a structure in a level - * is randomly selected from a Gaussian distribution of mean given by the - * ideal geometry and width = "value" (e.g. width = 5e-4 for a Panel). - * - * The covariance matrix for all structures of a level will be diagonal - * given by value^2 * identity. - * - * \author Chung Khim Lae - */ - -#include "Alignment/CommonAlignment/interface/StructureType.h" -#include "Alignment/SurveyAnalysis/interface/SurveyInputBase.h" - -#include - -class SurveyInputDummy : public SurveyInputBase { -public: - SurveyInputDummy(const edm::ParameterSet&); - - /// Read ideal tracker geometry from DB - virtual void analyze(const edm::Event&, const edm::EventSetup&); - -private: - /// Add survey info to an alignable - void addSurveyInfo(Alignable*); - - bool theRandomizeValue; // randomize survey values if true - - std::map theErrors; -}; - -#endif diff --git a/Alignment/SurveyAnalysis/test/SurveyInputTest.cc b/Alignment/SurveyAnalysis/test/SurveyInputTest.cc index 66fc5843a3790..fc0336c9d5196 100644 --- a/Alignment/SurveyAnalysis/test/SurveyInputTest.cc +++ b/Alignment/SurveyAnalysis/test/SurveyInputTest.cc @@ -1,8 +1,33 @@ +/** \class SurveyInputTest + * + * Class to read survey raw measurements from a config file. + * + * $Date: 2007/04/07 01:58:49 $ + * $Revision: 1.1 $ + * \author Chung Khim Lae + */ + #include "Alignment/CommonAlignment/interface/AlignableComposite.h" #include "Alignment/CommonAlignment/interface/AlignableObjectId.h" #include "Alignment/CommonAlignment/interface/SurveyDet.h" +#include "Alignment/SurveyAnalysis/interface/SurveyInputBase.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +class SurveyInputTest : public SurveyInputBase { +public: + SurveyInputTest(const edm::ParameterSet&); + + /// Read data from cfg file + virtual void beginJob(); -#include "Alignment/SurveyAnalysis/test/SurveyInputTest.h" + virtual void analyze(const edm::Event&, const edm::EventSetup&) {} + +private: + Alignable* create(const std::string& parName // name of alignable + ); + + edm::ParameterSet theConfig; +}; using namespace align; @@ -67,3 +92,6 @@ Alignable* SurveyInputTest::create(const std::string& parName) { return ali; } + +#include "FWCore/Framework/interface/MakerMacros.h" +DEFINE_FWK_MODULE(SurveyInputTest); diff --git a/Alignment/SurveyAnalysis/test/SurveyInputTest.h b/Alignment/SurveyAnalysis/test/SurveyInputTest.h deleted file mode 100644 index 0f30f4f853e64..0000000000000 --- a/Alignment/SurveyAnalysis/test/SurveyInputTest.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef Alignment_SurveyAnalysis_SurveyInputTest_h -#define Alignment_SurveyAnalysis_SurveyInputTest_h - -/** \class SurveyInputTest - * - * Class to read survey raw measurements from a config file. - * - * $Date: 2007/04/07 01:58:49 $ - * $Revision: 1.1 $ - * \author Chung Khim Lae - */ - -#include "Alignment/SurveyAnalysis/interface/SurveyInputBase.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" - -class SurveyInputTest : public SurveyInputBase { -public: - SurveyInputTest(const edm::ParameterSet&); - - /// Read data from cfg file - virtual void beginJob(); - - virtual void analyze(const edm::Event&, const edm::EventSetup&) {} - -private: - Alignable* create(const std::string& parName // name of alignable - ); - - edm::ParameterSet theConfig; -}; - -#endif diff --git a/Alignment/SurveyAnalysis/test/SurveyTest.cc b/Alignment/SurveyAnalysis/test/SurveyTest.cc index d0f00a4ba4124..308b2434edce3 100644 --- a/Alignment/SurveyAnalysis/test/SurveyTest.cc +++ b/Alignment/SurveyAnalysis/test/SurveyTest.cc @@ -1,12 +1,42 @@ +/** \class SurveyTest + * + * Analyser module for testing. + * + * $Date: 2007/10/10 20:54:07 $ + * $Revision: 1.6 $ + * \author Chung Khim Lae + */ + #include "Alignment/CommonAlignment/interface/Alignable.h" #include "Alignment/CommonAlignment/interface/AlignableObjectId.h" #include "Alignment/SurveyAnalysis/interface/SurveyAlignmentPoints.h" #include "Alignment/SurveyAnalysis/interface/SurveyAlignmentSensor.h" #include "Alignment/SurveyAnalysis/interface/SurveyInputBase.h" - #include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "Alignment/CommonAlignment/interface/StructureType.h" +#include "Alignment/CommonAlignment/interface/Utilities.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" + +class SurveyTest : public edm::one::EDAnalyzer<> { +public: + SurveyTest(const edm::ParameterSet&); + + virtual void beginJob(); + + virtual void analyze(const edm::Event&, const edm::EventSetup&) {} -#include "Alignment/SurveyAnalysis/test/SurveyTest.h" +private: + void getTerminals(align::Alignables& terminals, Alignable* ali); + + bool theBiasFlag; // true for biased residuals + + unsigned int theIterations; // number of iterations + + std::string theAlgorithm; // points or sensor residual + std::string theOutputFile; // name of output file + + std::vector theHierarchy; +}; SurveyTest::SurveyTest(const edm::ParameterSet& cfg) : theBiasFlag(cfg.getUntrackedParameter("bias", false)), @@ -56,3 +86,6 @@ void SurveyTest::getTerminals(align::Alignables& terminals, Alignable* ali) { else terminals.push_back(ali); } + +#include "FWCore/Framework/interface/MakerMacros.h" +DEFINE_FWK_MODULE(SurveyTest); diff --git a/Alignment/SurveyAnalysis/test/SurveyTest.h b/Alignment/SurveyAnalysis/test/SurveyTest.h deleted file mode 100644 index 771e6eceee3ef..0000000000000 --- a/Alignment/SurveyAnalysis/test/SurveyTest.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef Alignment_SurveyAnalysis_SurveyTest_h -#define Alignment_SurveyAnalysis_SurveyTest_h - -/** \class SurveyTest - * - * Analyser module for testing. - * - * $Date: 2007/10/10 20:54:07 $ - * $Revision: 1.6 $ - * \author Chung Khim Lae - */ - -#include "Alignment/CommonAlignment/interface/StructureType.h" -#include "Alignment/CommonAlignment/interface/Utilities.h" -#include "FWCore/Framework/interface/EDAnalyzer.h" - -class SurveyTest : public edm::EDAnalyzer { -public: - SurveyTest(const edm::ParameterSet&); - - virtual void beginJob(); - - virtual void analyze(const edm::Event&, const edm::EventSetup&) {} - -private: - void getTerminals(align::Alignables& terminals, Alignable* ali); - - bool theBiasFlag; // true for biased residuals - - unsigned int theIterations; // number of iterations - - std::string theAlgorithm; // points or sensor residual - std::string theOutputFile; // name of output file - - std::vector theHierarchy; -}; - -#endif diff --git a/Alignment/SurveyAnalysis/test/TestConverter.cpp b/Alignment/SurveyAnalysis/test/TestConverter.cpp index 1e06ec437b89a..f9ae867f66e41 100644 --- a/Alignment/SurveyAnalysis/test/TestConverter.cpp +++ b/Alignment/SurveyAnalysis/test/TestConverter.cpp @@ -18,7 +18,7 @@ // #include "TRotMatrix.h" // user include files -#include "FWCore/Framework/interface/EDAnalyzer.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/MakerMacros.h" @@ -41,7 +41,7 @@ // class declaration // -class TestConverter : public edm::EDAnalyzer { +class TestConverter : public edm::one::EDAnalyzer<> { typedef SurveyDataReader::MapType MapType; typedef SurveyDataReader::PairType PairType; typedef SurveyDataReader::MapTypeOr MapTypeOr; @@ -55,6 +55,10 @@ class TestConverter : public edm::EDAnalyzer { private: // ----------member data --------------------------- + const edm::ESGetToken tTopoToken_; + const edm::ESGetToken aliToken_; + const edm::ESGetToken aliErrToken_; + TTree* theTree; TFile* theFile; edm::ParameterSet theParameterSet; @@ -72,7 +76,8 @@ class TestConverter : public edm::EDAnalyzer { // // constructors and destructor // -TestConverter::TestConverter(const edm::ParameterSet& iConfig) : theParameterSet(iConfig) { +TestConverter::TestConverter(const edm::ParameterSet& iConfig) + : tTopoToken_(esConsumes()), aliToken_(esConsumes()), aliErrToken_(esConsumes()), theParameterSet(iConfig) { // Open root file and define tree std::string fileName = theParameterSet.getUntrackedParameter("fileName", "test.root"); theFile = new TFile(fileName.c_str(), "RECREATE"); @@ -105,9 +110,7 @@ void TestConverter::analyze(const edm::Event& iEvent, const edm::EventSetup& iSe edm::LogInfo("TrackerAlignment") << "Starting!"; //Retrieve tracker topology from geometry - edm::ESHandle tTopoHandle; - iSetup.get().get(tTopoHandle); - const TrackerTopology* const tTopo = tTopoHandle.product(); + const TrackerTopology* const tTopo = &iSetup.getData(tTopoToken_); // // Read in the survey information from the text files @@ -140,10 +143,8 @@ void TestConverter::analyze(const edm::Event& iEvent, const edm::EventSetup& iSe // iSetup.get().get( trackerGeometry ); // Retrieve alignment[Error]s from DBase - edm::ESHandle alignments; - iSetup.get().get(alignments); - edm::ESHandle alignmentErrors; - iSetup.get().get(alignmentErrors); + const Alignments* alignments = &iSetup.getData(aliToken_); + const AlignmentErrorsExtended* alignmentErrors = &iSetup.getData(aliErrToken_); std::vector alignErrors = alignmentErrors->m_alignError; // int countDet = 0; diff --git a/Alignment/SurveyAnalysis/test/TestConverter2.cpp b/Alignment/SurveyAnalysis/test/TestConverter2.cpp index 7bf81be2c27fb..57aa3b903a27d 100644 --- a/Alignment/SurveyAnalysis/test/TestConverter2.cpp +++ b/Alignment/SurveyAnalysis/test/TestConverter2.cpp @@ -18,7 +18,7 @@ // #include "TRotMatrix.h" // user include files -#include "FWCore/Framework/interface/EDAnalyzer.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/MakerMacros.h" @@ -45,7 +45,7 @@ // using namespace std; -class TestConverter2 : public edm::EDAnalyzer { +class TestConverter2 : public edm::one::EDAnalyzer<> { public: explicit TestConverter2(const edm::ParameterSet&); ~TestConverter2(); @@ -54,6 +54,11 @@ class TestConverter2 : public edm::EDAnalyzer { private: // ----------member data --------------------------- + const edm::ESGetToken tTopoToken_; + const edm::ESGetToken tkGeomToken_; + const edm::ESGetToken aliToken_; + const edm::ESGetToken aliErrToken_; + TTree* theTree; TFile* theFile; edm::ParameterSet theParameterSet; @@ -69,7 +74,12 @@ class TestConverter2 : public edm::EDAnalyzer { // // constructors and destructor // -TestConverter2::TestConverter2(const edm::ParameterSet& iConfig) : theParameterSet(iConfig) { +TestConverter2::TestConverter2(const edm::ParameterSet& iConfig) + : tTopoToken_(esConsumes()), + tkGeomToken_(esConsumes()), + aliToken_(esConsumes()), + aliErrToken_(esConsumes()), + theParameterSet(iConfig) { // Open root file and define tree std::string fileName = theParameterSet.getUntrackedParameter("fileName", "test.root"); theFile = new TFile(fileName.c_str(), "RECREATE"); @@ -106,23 +116,16 @@ TestConverter2::~TestConverter2() { void TestConverter2::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { //Retrieve tracker topology from geometry - edm::ESHandle tTopoHandle; - iSetup.get().get(tTopoHandle); - const TrackerTopology* const tTopo = tTopoHandle.product(); edm::LogInfo("TrackerAlignment") << "Starting!"; - + const TrackerTopology* const tTopo = &iSetup.getData(tTopoToken_); // // Retrieve tracker geometry from event setup - edm::ESHandle trackerGeometry; - iSetup.get().get(trackerGeometry); + const TrackerGeometry* trackerGeometry = &iSetup.getData(tkGeomToken_); // Retrieve alignment[Error]s from DBase - edm::ESHandle alignments; - iSetup.get().get(alignments); - edm::ESHandle alignmentErrors; - iSetup.get().get(alignmentErrors); - + const Alignments* alignments = &iSetup.getData(aliToken_); + const AlignmentErrorsExtended* alignmentErrors = &iSetup.getData(aliErrToken_); auto alignErrors = alignmentErrors->m_alignError; // Now loop on detector units, and store difference position and orientation w.r.t. survey diff --git a/Alignment/SurveyAnalysis/test/TestIdealGeometry.cpp b/Alignment/SurveyAnalysis/test/TestIdealGeometry.cpp index ee702bd6cdbc9..0c2f359432951 100644 --- a/Alignment/SurveyAnalysis/test/TestIdealGeometry.cpp +++ b/Alignment/SurveyAnalysis/test/TestIdealGeometry.cpp @@ -17,7 +17,7 @@ // #include "TRotMatrix.h" // user include files -#include "FWCore/Framework/interface/EDAnalyzer.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" #include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/MakerMacros.h" @@ -45,7 +45,7 @@ // using namespace std; -class TestIdealGeometry : public edm::EDAnalyzer { +class TestIdealGeometry : public edm::one::EDAnalyzer<> { typedef SurveyDataReader::MapType MapType; typedef SurveyDataReader::PairType PairType; typedef SurveyDataReader::MapTypeOr MapTypeOr; @@ -59,6 +59,8 @@ class TestIdealGeometry : public edm::EDAnalyzer { private: // ----------member data --------------------------- + const edm::ESGetToken tTopoToken_; + const edm::ESGetToken tkGeomToken_; TTree* theTree; TFile* theFile; edm::ParameterSet theParameterSet; @@ -74,7 +76,8 @@ class TestIdealGeometry : public edm::EDAnalyzer { // // constructors and destructor // -TestIdealGeometry::TestIdealGeometry(const edm::ParameterSet& iConfig) : theParameterSet(iConfig) { +TestIdealGeometry::TestIdealGeometry(const edm::ParameterSet& iConfig) + : tTopoToken_(esConsumes()), tkGeomToken_(esConsumes()), theParameterSet(iConfig) { // Open root file and define tree std::string fileName = theParameterSet.getUntrackedParameter("fileName", "testideal.root"); theFile = new TFile(fileName.c_str(), "RECREATE"); @@ -102,10 +105,7 @@ TestIdealGeometry::~TestIdealGeometry() { void TestIdealGeometry::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { //Retrieve tracker topology from geometry - edm::ESHandle tTopoHandle; - iSetup.get().get(tTopoHandle); - const TrackerTopology* const tTopo = tTopoHandle.product(); - + const TrackerTopology* const tTopo = &iSetup.getData(tTopoToken_); edm::LogInfo("TrackerAlignment") << "Starting!"; // @@ -135,8 +135,7 @@ void TestIdealGeometry::analyze(const edm::Event& iEvent, const edm::EventSetup& // // Retrieve tracker geometry from event setup // - edm::ESHandle trackerGeometry; - iSetup.get().get(trackerGeometry); + const TrackerGeometry* trackerGeometry = &iSetup.getData(tkGeomToken_); // Retrieve alignment[Error]s from DBase // edm::ESHandle alignments; diff --git a/Alignment/SurveyAnalysis/test/TestIdealGeometry2.cpp b/Alignment/SurveyAnalysis/test/TestIdealGeometry2.cpp index 82f35783fb082..98e29a57ba2a2 100644 --- a/Alignment/SurveyAnalysis/test/TestIdealGeometry2.cpp +++ b/Alignment/SurveyAnalysis/test/TestIdealGeometry2.cpp @@ -18,7 +18,7 @@ // #include "TRotMatrix.h" // user include files -#include "FWCore/Framework/interface/EDAnalyzer.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/MakerMacros.h" @@ -27,9 +27,7 @@ #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "CondFormats/Alignment/interface/Alignments.h" -#include "CondFormats/Alignment/interface/AlignmentErrorsExtended.h" #include "CondFormats/AlignmentRecord/interface/TrackerAlignmentRcd.h" -#include "CondFormats/AlignmentRecord/interface/TrackerAlignmentErrorExtendedRcd.h" #include "DataFormats/SiStripDetId/interface/StripSubdetector.h" #include "DataFormats/TrackerCommon/interface/TrackerTopology.h" @@ -41,7 +39,7 @@ // class declaration // -class TestIdealGeometry2 : public edm::EDAnalyzer { +class TestIdealGeometry2 : public edm::one::EDAnalyzer<> { typedef SurveyDataReader::MapType MapType; typedef SurveyDataReader::PairType PairType; typedef SurveyDataReader::MapTypeOr MapTypeOr; @@ -55,6 +53,9 @@ class TestIdealGeometry2 : public edm::EDAnalyzer { private: // ----------member data --------------------------- + const edm::ESGetToken tTopoToken_; + const edm::ESGetToken aliToken_; + TTree* theTree; TFile* theFile; edm::ParameterSet theParameterSet; @@ -71,7 +72,8 @@ class TestIdealGeometry2 : public edm::EDAnalyzer { // // constructors and destructor // -TestIdealGeometry2::TestIdealGeometry2(const edm::ParameterSet& iConfig) : theParameterSet(iConfig) { +TestIdealGeometry2::TestIdealGeometry2(const edm::ParameterSet& iConfig) + : tTopoToken_(esConsumes()), aliToken_(esConsumes()), theParameterSet(iConfig) { // Open root file and define tree std::string fileName = theParameterSet.getUntrackedParameter("fileName", "testideal.root"); theFile = new TFile(fileName.c_str(), "RECREATE"); @@ -99,10 +101,7 @@ TestIdealGeometry2::~TestIdealGeometry2() { void TestIdealGeometry2::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { //Retrieve tracker topology from geometry - edm::ESHandle tTopoHandle; - iSetup.get().get(tTopoHandle); - const TrackerTopology* const tTopo = tTopoHandle.product(); - + const TrackerTopology* const tTopo = &iSetup.getData(tTopoToken_); edm::LogInfo("TrackerAlignment") << "Starting!"; // @@ -136,10 +135,8 @@ void TestIdealGeometry2::analyze(const edm::Event& iEvent, const edm::EventSetup // iSetup.get().get( trackerGeometry ); // Retrieve alignment[Error]s from DBase - edm::ESHandle alignments; - iSetup.get().get(alignments); - edm::ESHandle alignmentErrors; - iSetup.get().get(alignmentErrors); + const Alignments* alignments = &iSetup.getData(aliToken_); + int countDet = 0; // Now loop on detector units, and store difference position and orientation w.r.t. survey From e16b9af18331c6cc5246e73f83cf3612da91433a Mon Sep 17 00:00:00 2001 From: mmusich Date: Sat, 20 Nov 2021 17:13:22 +0100 Subject: [PATCH 8/8] get rid of CMS deprecation warnings in Alignment/TrackerAlignment --- Alignment/TrackerAlignment/test/ApeAdder.cpp | 21 +++++++-------- .../TrackerAlignment/test/TestAnalyzer.cpp | 10 +++---- .../TrackerAlignment/test/TestReader.cpp | 14 +++++----- .../test/TestTrackerHierarchy.cpp | 27 +++++++++++-------- .../test/TrackerGeometryAnalyzer.cc | 23 +++++++--------- .../test/TrackerGeometryAnalyzer.h | 18 +++++++++++-- 6 files changed, 63 insertions(+), 50 deletions(-) diff --git a/Alignment/TrackerAlignment/test/ApeAdder.cpp b/Alignment/TrackerAlignment/test/ApeAdder.cpp index 5ace33fbb6bfb..abf4da27b089d 100644 --- a/Alignment/TrackerAlignment/test/ApeAdder.cpp +++ b/Alignment/TrackerAlignment/test/ApeAdder.cpp @@ -12,7 +12,7 @@ // user include files //#include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDAnalyzer.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/Framework/interface/ESHandle.h" @@ -33,12 +33,12 @@ #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h" // Class declaration -class ApeAdder : public edm::EDAnalyzer { +class ApeAdder : public edm::one::EDAnalyzer<> { public: explicit ApeAdder(const edm::ParameterSet&); - ~ApeAdder(){}; + ~ApeAdder() override = default; - virtual void analyze(const edm::Event&, const edm::EventSetup&); + void analyze(const edm::Event&, const edm::EventSetup&) override; private: // methods @@ -46,11 +46,14 @@ class ApeAdder : public edm::EDAnalyzer { private: // members + const edm::ESGetToken tTopoToken_; + const edm::ESGetToken tkGeomToken_; std::string theErrorRecordName; std::vector theApe; // Amount of APE to add (from config.) }; -ApeAdder::ApeAdder(const edm::ParameterSet& iConfig) : theErrorRecordName("TrackerAlignmentErrorExtendedRcd") { +ApeAdder::ApeAdder(const edm::ParameterSet& iConfig) + : tTopoToken_(esConsumes()), tkGeomToken_(esConsumes()), theErrorRecordName("TrackerAlignmentErrorExtendedRcd") { // The APE to set to all GeomDets theApe = iConfig.getUntrackedParameter >("apeVector"); } @@ -60,13 +63,9 @@ void ApeAdder::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { //Retrieve tracker topology from geometry - edm::ESHandle tTopoHandle; - iSetup.get().get(tTopoHandle); - const TrackerTopology* const tTopo = tTopoHandle.product(); - + const TrackerTopology* const tTopo = &iSetup.getData(tTopoToken_); // Get geometry from ES - edm::ESHandle trackerGeometry; - iSetup.get().get(trackerGeometry); + const TrackerGeometry* trackerGeometry = &iSetup.getData(tkGeomToken_); // Create the alignable hierarchy AlignableTracker* theAlignableTracker = new AlignableTracker(&(*trackerGeometry), tTopo); diff --git a/Alignment/TrackerAlignment/test/TestAnalyzer.cpp b/Alignment/TrackerAlignment/test/TestAnalyzer.cpp index 1a09dfe691885..8ffdc98074ffe 100644 --- a/Alignment/TrackerAlignment/test/TestAnalyzer.cpp +++ b/Alignment/TrackerAlignment/test/TestAnalyzer.cpp @@ -19,7 +19,7 @@ // user include files #include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "FWCore/Framework/interface/EDAnalyzer.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/Framework/interface/ESHandle.h" @@ -37,7 +37,7 @@ // class declaration // -class TestAnalyzer : public edm::EDAnalyzer { +class TestAnalyzer : public edm::one::EDAnalyzer<> { public: explicit TestAnalyzer(const edm::ParameterSet&); ~TestAnalyzer(); @@ -46,6 +46,7 @@ class TestAnalyzer : public edm::EDAnalyzer { private: // ----------member data --------------------------- + const edm::ESGetToken tkGeomToken_; TTree* theTree; TFile* theFile; float x_, y_, z_, phi_, theta_, length_, thick_, width_; @@ -56,7 +57,7 @@ class TestAnalyzer : public edm::EDAnalyzer { // // constructors and destructor // -TestAnalyzer::TestAnalyzer(const edm::ParameterSet& iConfig) { +TestAnalyzer::TestAnalyzer(const edm::ParameterSet& iConfig) : tkGeomToken_(esConsumes()) { // Open root file and define tree std::string fileName = iConfig.getUntrackedParameter("fileName", "test.root"); theFile = new TFile(fileName.c_str(), "RECREATE"); @@ -86,8 +87,7 @@ void TestAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSet // // Retrieve tracker geometry from event setup // - edm::ESHandle trackerGeometry; - iSetup.get().get(trackerGeometry); + const TrackerGeometry* trackerGeometry = &iSetup.getData(tkGeomToken_); // Now loop on detector units, and store position and orientation for (auto iGeomDet = trackerGeometry->dets().begin(); iGeomDet != trackerGeometry->dets().end(); iGeomDet++) { diff --git a/Alignment/TrackerAlignment/test/TestReader.cpp b/Alignment/TrackerAlignment/test/TestReader.cpp index 1d71448d46fae..ed9a9a3c7d4d0 100644 --- a/Alignment/TrackerAlignment/test/TestReader.cpp +++ b/Alignment/TrackerAlignment/test/TestReader.cpp @@ -12,7 +12,7 @@ #include // user include files -#include "FWCore/Framework/interface/EDAnalyzer.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/MakerMacros.h" @@ -29,14 +29,16 @@ // class declaration // -class TestTrackerReader : public edm::EDAnalyzer { +class TestTrackerReader : public edm::one::EDAnalyzer<> { public: - explicit TestTrackerReader(const edm::ParameterSet&) : rot(0) {} + explicit TestTrackerReader(const edm::ParameterSet&) : aliToken_(esConsumes()), aliErrToken_(esConsumes()), rot(0) {} virtual void analyze(const edm::Event&, const edm::EventSetup&); private: // ----------member data --------------------------- + const edm::ESGetToken aliToken_; + const edm::ESGetToken aliErrToken_; float x, y, z, phi, theta, length, thick, width; TRotMatrix* rot; }; @@ -45,10 +47,8 @@ void TestTrackerReader::analyze(const edm::Event& iEvent, const edm::EventSetup& edm::LogInfo("TrackerAlignment") << "Starting!"; // Retrieve alignment[Error]s from DBase - edm::ESHandle alignments; - iSetup.get().get(alignments); - edm::ESHandle alignmentErrors; - iSetup.get().get(alignmentErrors); + const Alignments* alignments = &iSetup.getData(aliToken_); + const AlignmentErrorsExtended* alignmentErrors = &iSetup.getData(aliErrToken_); edm::LogVerbatim("DumpAlignments") << "\n----------------------\n"; for (std::vector::const_iterator it = alignments->m_align.begin(); it != alignments->m_align.end(); diff --git a/Alignment/TrackerAlignment/test/TestTrackerHierarchy.cpp b/Alignment/TrackerAlignment/test/TestTrackerHierarchy.cpp index 114f75c6aedbd..b1700f6f9d0a9 100644 --- a/Alignment/TrackerAlignment/test/TestTrackerHierarchy.cpp +++ b/Alignment/TrackerAlignment/test/TestTrackerHierarchy.cpp @@ -17,7 +17,7 @@ #include // user include files -#include "FWCore/Framework/interface/EDAnalyzer.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" #include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/Framework/interface/ESHandle.h" @@ -39,15 +39,24 @@ static const int kLEAD_WIDTH = 40; // First field width // class declaration // -class TestTrackerHierarchy : public edm::EDAnalyzer { +class TestTrackerHierarchy : public edm::one::EDAnalyzer<> { public: explicit TestTrackerHierarchy(const edm::ParameterSet& pSet) - : dumpAlignments_(pSet.getUntrackedParameter("dumpAlignments")) {} + : tTopoToken_(esConsumes()), + tkGeomToken_(esConsumes()), + aliToken_(esConsumes()), + aliErrToken_(esConsumes()), + dumpAlignments_(pSet.getUntrackedParameter("dumpAlignments")) {} virtual void analyze(const edm::Event&, const edm::EventSetup&); private: // ----------member data --------------------------- + const edm::ESGetToken tTopoToken_; + const edm::ESGetToken tkGeomToken_; + const edm::ESGetToken aliToken_; + const edm::ESGetToken aliErrToken_; + void dumpAlignable(const Alignable*, unsigned int, unsigned int); void printInfo(const Alignable*, unsigned int); void dumpAlignments(const edm::EventSetup& setup, AlignableTracker* aliTracker) const; @@ -60,13 +69,10 @@ class TestTrackerHierarchy : public edm::EDAnalyzer { void TestTrackerHierarchy::analyze(const edm::Event&, const edm::EventSetup& setup) { //Retrieve tracker topology from geometry - edm::ESHandle tTopoHandle; - setup.get().get(tTopoHandle); - const TrackerTopology* const tTopo = tTopoHandle.product(); - + const TrackerTopology* const tTopo = &setup.getData(tTopoToken_); edm::LogInfo("TrackerHierarchy") << "Starting!"; - edm::ESHandle trackerGeometry; - setup.get().get(trackerGeometry); + + const TrackerGeometry* trackerGeometry = &setup.getData(tkGeomToken_); alignableTracker_ = std::make_unique(&(*trackerGeometry), tTopo); leaders_ = ""; @@ -126,8 +132,7 @@ void TestTrackerHierarchy::printInfo(const Alignable* alignable, unsigned int id //__________________________________________________________________________________________________ void TestTrackerHierarchy::dumpAlignments(const edm::EventSetup& setup, AlignableTracker* aliTracker) const { - edm::ESHandle alignments; - setup.get().get(alignments); + const Alignments* alignments = &setup.getData(aliToken_); if (alignments->empty()) { edm::LogWarning("TrackerAlignment") << "@SUB=dumpAlignments" << "No TrackerAlignmentRcd."; diff --git a/Alignment/TrackerAlignment/test/TrackerGeometryAnalyzer.cc b/Alignment/TrackerAlignment/test/TrackerGeometryAnalyzer.cc index 9669061419194..d8077454e3e78 100644 --- a/Alignment/TrackerAlignment/test/TrackerGeometryAnalyzer.cc +++ b/Alignment/TrackerAlignment/test/TrackerGeometryAnalyzer.cc @@ -26,10 +26,13 @@ //_____________________________________________________________________________ TrackerGeometryAnalyzer ::TrackerGeometryAnalyzer(const edm::ParameterSet& config) - : analyzeAlignables_(config.getParameter("analyzeAlignables")), + : tTopoToken_(esConsumes()), + geomDetToken_(esConsumes()), + ptpToken_(esConsumes()), + ptapToken_(esConsumes()), + analyzeAlignables_(config.getParameter("analyzeAlignables")), printTrackerStructure_(config.getParameter("printTrackerStructure")), maxPrintDepth_(config.getParameter("maxPrintDepth")), - analyzeGeometry_(config.getParameter("analyzeGeometry")), analyzePXB_(config.getParameter("analyzePXB")), analyzePXE_(config.getParameter("analyzePXE")), @@ -63,22 +66,14 @@ void TrackerGeometryAnalyzer ::beginRun(const edm::Run& /* run */, const edm::Ev //_____________________________________________________________________________ void TrackerGeometryAnalyzer ::setTrackerTopology(const edm::EventSetup& setup) { - edm::ESHandle trackerTopologyHandle; - setup.get().get(trackerTopologyHandle); - - trackerTopology = trackerTopologyHandle.product(); + trackerTopology = &setup.getData(tTopoToken_); } //_____________________________________________________________________________ void TrackerGeometryAnalyzer ::setTrackerGeometry(const edm::EventSetup& setup) { - edm::ESHandle geometricDet; - setup.get().get(geometricDet); - - edm::ESHandle trackerParams; - setup.get().get(trackerParams); - - edm::ESHandle trackerGeometricDetExtra; - setup.get().get(trackerGeometricDetExtra); + edm::ESHandle geometricDet = setup.getHandle(geomDetToken_); + edm::ESHandle trackerParams = setup.getHandle(ptpToken_); + edm::ESHandle trackerGeometricDetExtra = setup.getHandle(ptapToken_); TrackerGeomBuilderFromGeometricDet trackerGeometryBuilder; trackerGeometry = diff --git a/Alignment/TrackerAlignment/test/TrackerGeometryAnalyzer.h b/Alignment/TrackerAlignment/test/TrackerGeometryAnalyzer.h index 33fd0bb8243a8..07f3e67c0c5bb 100644 --- a/Alignment/TrackerAlignment/test/TrackerGeometryAnalyzer.h +++ b/Alignment/TrackerAlignment/test/TrackerGeometryAnalyzer.h @@ -10,21 +10,28 @@ #include // core framework functionality -#include "FWCore/Framework/interface/EDAnalyzer.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/MakerMacros.h" // topology and geometry +#include "CondFormats/GeometryObjects/interface/PTrackerParameters.h" #include "DataFormats/TrackerCommon/interface/TrackerTopology.h" +#include "Geometry/Records/interface/IdealGeometryRecord.h" +#include "Geometry/Records/interface/PTrackerAdditionalParametersPerDetRcd.h" +#include "Geometry/Records/interface/PTrackerParametersRcd.h" +#include "Geometry/Records/interface/TrackerTopologyRcd.h" +#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeomBuilderFromGeometricDet.h" #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h" +#include "Geometry/TrackerNumberingBuilder/interface/GeometricDet.h" // alignment #include "Alignment/CommonAlignment/interface/AlignableObjectId.h" class Alignable; -class TrackerGeometryAnalyzer : public edm::EDAnalyzer { +class TrackerGeometryAnalyzer : public edm::one::EDAnalyzer { //========================== PUBLIC METHODS ================================= public: //=================================================================== TrackerGeometryAnalyzer(const edm::ParameterSet&); @@ -32,6 +39,7 @@ class TrackerGeometryAnalyzer : public edm::EDAnalyzer { virtual void beginRun(const edm::Run&, const edm::EventSetup&) override; virtual void analyze(const edm::Event&, const edm::EventSetup&) override{}; + virtual void endRun(const edm::Run&, const edm::EventSetup&) override{}; //========================= PRIVATE METHODS ================================= private: //================================================================== @@ -62,6 +70,12 @@ class TrackerGeometryAnalyzer : public edm::EDAnalyzer { //========================== PRIVATE DATA =================================== //=========================================================================== + // ESTokens + const edm::ESGetToken tTopoToken_; + const edm::ESGetToken geomDetToken_; + const edm::ESGetToken ptpToken_; + const edm::ESGetToken ptapToken_; + // config-file parameters const bool analyzeAlignables_; const bool printTrackerStructure_;