From eeea91e2b3003014480235a831f02857bdbd0972 Mon Sep 17 00:00:00 2001 From: mmusich Date: Fri, 28 Jan 2022 11:19:52 +0100 Subject: [PATCH 1/2] get rid of CMSDEPRECATED_X warnings in FastSimulation/TrackerSetup --- .../TrackerInteractionGeometryESProducer.cc | 38 ++++++++++++------- .../TrackerInteractionGeometryESProducer.h | 22 ----------- 2 files changed, 24 insertions(+), 36 deletions(-) delete mode 100644 FastSimulation/TrackerSetup/plugins/TrackerInteractionGeometryESProducer.h diff --git a/FastSimulation/TrackerSetup/plugins/TrackerInteractionGeometryESProducer.cc b/FastSimulation/TrackerSetup/plugins/TrackerInteractionGeometryESProducer.cc index 30cb8360698e8..396e47aca8ad7 100644 --- a/FastSimulation/TrackerSetup/plugins/TrackerInteractionGeometryESProducer.cc +++ b/FastSimulation/TrackerSetup/plugins/TrackerInteractionGeometryESProducer.cc @@ -1,26 +1,36 @@ -#include "FastSimulation/TrackerSetup/plugins/TrackerInteractionGeometryESProducer.h" -#include "RecoTracker/Record/interface/TrackerRecoGeometryRecord.h" - -#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/ESProducer.h" #include "FWCore/Framework/interface/ModuleFactory.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FastSimulation/TrackerSetup/interface/TrackerInteractionGeometry.h" +#include "FastSimulation/TrackerSetup/interface/TrackerInteractionGeometryRecord.h" +#include "RecoTracker/Record/interface/TrackerRecoGeometryRecord.h" #include +#include -TrackerInteractionGeometryESProducer::TrackerInteractionGeometryESProducer(const edm::ParameterSet& p) { - setWhatProduced(this); - _label = p.getUntrackedParameter("trackerGeometryLabel", ""); +class TrackerInteractionGeometryESProducer : public edm::ESProducer { +public: + TrackerInteractionGeometryESProducer(const edm::ParameterSet& p); + ~TrackerInteractionGeometryESProducer() override = default; + std::unique_ptr produce(const TrackerInteractionGeometryRecord&); - theTrackerMaterial = p.getParameter("TrackerMaterial"); -} +private: + edm::ESGetToken geoSearchToken_; + std::string label_; + edm::ParameterSet theTrackerMaterial_; +}; -TrackerInteractionGeometryESProducer::~TrackerInteractionGeometryESProducer() {} +TrackerInteractionGeometryESProducer::TrackerInteractionGeometryESProducer(const edm::ParameterSet& p) { + auto cc = setWhatProduced(this); + label_ = p.getUntrackedParameter("trackerGeometryLabel", ""); + geoSearchToken_ = cc.consumes(edm::ESInputTag("", label_)); + theTrackerMaterial_ = p.getParameter("TrackerMaterial"); +} std::unique_ptr TrackerInteractionGeometryESProducer::produce( const TrackerInteractionGeometryRecord& iRecord) { - edm::ESHandle theGeomSearchTracker; - - iRecord.getRecord().get(_label, theGeomSearchTracker); - return std::make_unique(theTrackerMaterial, &(*theGeomSearchTracker)); + const GeometricSearchTracker* theGeomSearchTracker = &iRecord.get(geoSearchToken_); + return std::make_unique(theTrackerMaterial_, theGeomSearchTracker); } DEFINE_FWK_EVENTSETUP_MODULE(TrackerInteractionGeometryESProducer); diff --git a/FastSimulation/TrackerSetup/plugins/TrackerInteractionGeometryESProducer.h b/FastSimulation/TrackerSetup/plugins/TrackerInteractionGeometryESProducer.h deleted file mode 100644 index f48987cb60726..0000000000000 --- a/FastSimulation/TrackerSetup/plugins/TrackerInteractionGeometryESProducer.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef FastSimulation_TrackerSetup_TrackerInteractionGeometryESProducer_H -#define FastSimulation_TrackerSetup_TrackerInteractionGeometryESProducer_H - -#include "FWCore/Framework/interface/ESProducer.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "FastSimulation/TrackerSetup/interface/TrackerInteractionGeometryRecord.h" -#include "FastSimulation/TrackerSetup/interface/TrackerInteractionGeometry.h" -#include -#include - -class TrackerInteractionGeometryESProducer : public edm::ESProducer { -public: - TrackerInteractionGeometryESProducer(const edm::ParameterSet &p); - ~TrackerInteractionGeometryESProducer() override; - std::unique_ptr produce(const TrackerInteractionGeometryRecord &); - -private: - std::string _label; - edm::ParameterSet theTrackerMaterial; -}; - -#endif From bdc9f374c5f7e085f7559c33bf44e8e948489b0f Mon Sep 17 00:00:00 2001 From: mmusich Date: Fri, 28 Jan 2022 11:48:26 +0100 Subject: [PATCH 2/2] modernize FastSimulation/Tracking/test/testGeneralTracks.cc --- .../Tracking/test/testGeneralTracks.cc | 40 ++++++++++--------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/FastSimulation/Tracking/test/testGeneralTracks.cc b/FastSimulation/Tracking/test/testGeneralTracks.cc index 6cc0ac1be515a..d45d83bcdf998 100644 --- a/FastSimulation/Tracking/test/testGeneralTracks.cc +++ b/FastSimulation/Tracking/test/testGeneralTracks.cc @@ -42,6 +42,9 @@ class testGeneralTracks : public DQMEDAnalyzer { void bookHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&) override; private: + edm::ESGetToken geomToken; + edm::ESGetToken pdtToken; + // See RecoParticleFlow/PFProducer/interface/PFProducer.h edm::ParameterSet particleFilter_; std::vector allTracks; @@ -72,7 +75,9 @@ class testGeneralTracks : public DQMEDAnalyzer { }; testGeneralTracks::testGeneralTracks(const edm::ParameterSet& p) - : mySimEvent(2, static_cast(0)), + : geomToken(esConsumes()), + pdtToken(esConsumes()), + mySimEvent(2, static_cast(0)), h0(2, static_cast(0)), TracksvsEtaP(2, static_cast(0)), HitsvsP(2, static_cast(0)), @@ -122,31 +127,28 @@ void testGeneralTracks::bookHistograms(DQMStore::IBooker& ibooker, } testGeneralTracks::~testGeneralTracks() { - std::cout << "\t\t Number of Tracks " << std::endl; - std::cout << "\tFULL\t" << numfull << "\t HP= " << numfullHP << std::endl; - std::cout << "\tFAST\t" << numfast << "\t HP= " << numfastHP << std::endl; + edm::LogPrint("testGeneralTracks") << "\t\t Number of Tracks "; + edm::LogPrint("testGeneralTracks") << "\tFULL\t" << numfull << "\t HP= "; + edm::LogPrint("testGeneralTracks") << "\tFAST\t" << numfast << "\t HP= "; } void testGeneralTracks::dqmBeginRun(edm::Run const&, edm::EventSetup const& es) { // init Particle data table (from Pythia) - edm::ESHandle pdt; - es.getData(pdt); + const HepPDT::ParticleDataTable* pdt = &es.getData(pdtToken); - mySimEvent[0]->initializePdt(&(*pdt)); - mySimEvent[1]->initializePdt(&(*pdt)); + mySimEvent[0]->initializePdt(pdt); + mySimEvent[1]->initializePdt(pdt); - edm::ESHandle geometry; - es.get().get(geometry); - theGeometry = &(*geometry); + theGeometry = &es.getData(geomToken); } void testGeneralTracks::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { ++totalNEvt; - // std::cout << " >>>>>>>>> Analizying Event " << totalNEvt << "<<<<<<< " << std::endl; + // edm::LogPrint("testGeneralTracks") << " >>>>>>>>> Analizying Event " << totalNEvt << "<<<<<<< "; if (totalNEvt / 1000 * 1000 == totalNEvt) - std::cout << "Number of event analysed " << totalNEvt << std::endl; + edm::LogPrint("testGeneralTracks") << "Number of event analysed " << totalNEvt; std::unique_ptr nuclSimTracks(new edm::SimTrackContainer); @@ -170,7 +172,7 @@ void testGeneralTracks::analyze(const edm::Event& iEvent, const edm::EventSetup& h0[0]->Fill(pGen); h0[1]->Fill(etaGen); genTracksvsEtaP->Fill(etaGen, pGen, 1.); - // std::cout << " PArticle list: Pt = " << pGen << " , eta = " << etaGen << std::endl; + // edm::LogPrint("testGeneralTracks") << " PArticle list: Pt = " << pGen << " , eta = " << etaGen << std::endl; std::vector firstSeed(2, static_cast(false)); std::vector secondSeed(2, static_cast(false)); @@ -184,9 +186,9 @@ void testGeneralTracks::analyze(const edm::Event& iEvent, const edm::EventSetup& reco::TrackCollection::const_iterator itk0 = tkColl[0]->begin(); reco::TrackCollection::const_iterator itk0_e = tkColl[0]->end(); for (; itk0 != itk0_e; ++itk0) { - //std::cout << "quality " << itk0->quality(_trackQuality) << std::endl; + //edm::LogPrint("testGeneralTracks") << "quality " << itk0->quality(_trackQuality) << std::endl; if (!(itk0->quality(_trackQuality))) { - //std::cout << "evt " << totalNEvt << "\tTRACK REMOVED" << std::endl; + //edm::LogPrint("testGeneralTracks") << "evt " << totalNEvt << "\tTRACK REMOVED" << std::endl; continue; } if (ievt == 0) @@ -200,13 +202,13 @@ void testGeneralTracks::analyze(const edm::Event& iEvent, const edm::EventSetup& LayersvsP[ievt]->Fill(pGen, itk0->hitPattern().trackerLayersWithMeasurement(), 1.); } - // std::cout << "\t\t Number of Tracks " << std::endl; + // edm::LogPrint("testGeneralTracks") << "\t\t Number of Tracks " << std::endl; if (ievt == 0) { numfull += tkColl[0]->size(); - // std::cout << "\tFULL\t" << tkColl[0]->size() << "\t" << numfull << "\t" << numfullHP << std::endl; + // edm::LogPrint("testGeneralTracks") << "\tFULL\t" << tkColl[0]->size() << "\t" << numfull << "\t" << numfullHP << std::endl; } else if (ievt == 1) { numfast += tkColl[0]->size(); - // std::cout << "\tFAST\t" << tkColl[0]->size() << "\t" << numfast << "\t" << numfastHP << std::endl; + // edm::LogPrint("testGeneralTracks") << "\tFAST\t" << tkColl[0]->size() << "\t" << numfast << "\t" << numfastHP << std::endl; } } }