Skip to content

Commit

Permalink
Merge pull request #33238 from mmusich/migrateValidationTracker_esCon…
Browse files Browse the repository at this point in the history
…sumes

Migrated Validation/*Tracker* to esConsumes
  • Loading branch information
cmsbuild authored Mar 22, 2021
2 parents 2bbbd04 + 0b80e87 commit 1b23a1c
Show file tree
Hide file tree
Showing 13 changed files with 71 additions and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
// constructors and destructor
//
OuterTrackerMonitorTrackingParticles::OuterTrackerMonitorTrackingParticles(const edm::ParameterSet &iConfig)
: conf_(iConfig) {
: m_topoToken(esConsumes()), conf_(iConfig) {
topFolderName_ = conf_.getParameter<std::string>("TopFolderName");
trackingParticleToken_ =
consumes<std::vector<TrackingParticle>>(conf_.getParameter<edm::InputTag>("trackingParticleToken"));
Expand Down Expand Up @@ -80,9 +80,7 @@ void OuterTrackerMonitorTrackingParticles::analyze(const edm::Event &iEvent, con
iEvent.getByToken(ttStubMCTruthToken_, MCTruthTTStubHandle);

// Geometries
edm::ESHandle<TrackerTopology> tTopoHandle;
iSetup.get<TrackerTopologyRcd>().get(tTopoHandle);
const TrackerTopology *const tTopo = tTopoHandle.product();
const TrackerTopology *const tTopo = &iSetup.getData(m_topoToken);

// Loop over tracking particles
int this_tp = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ class OuterTrackerMonitorTrackingParticles : public DQMEDAnalyzer {
MonitorElement *resd0_eta2to2p4 = nullptr;

private:
const edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> m_topoToken;
edm::ParameterSet conf_;
edm::EDGetTokenT<std::vector<TrackingParticle>> trackingParticleToken_;
edm::EDGetTokenT<TTClusterAssociationMap<Ref_Phase2TrackerDigi_>>
Expand Down
14 changes: 5 additions & 9 deletions Validation/TrackerDigis/plugins/SiPixelDigiValid.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@
#include "Geometry/CommonDetUnit/interface/PixelGeomDetType.h"
#include "Geometry/CommonDetUnit/interface/PixelGeomDetUnit.h"
#include "Geometry/TrackerGeometryBuilder/interface/RectangularPixelTopology.h"
#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
#include "Geometry/TrackerNumberingBuilder/interface/GeometricDet.h"
#include "SiPixelDigiValid.h"

// using namespace std;
// using namespace edm;

SiPixelDigiValid::SiPixelDigiValid(const edm::ParameterSet &ps)
: outputFile_(ps.getUntrackedParameter<std::string>("outputFile", "pixeldigihisto.root")),
: m_geomToken(esConsumes<edm::Transition::BeginRun>()),
m_topoToken(esConsumes()),
outputFile_(ps.getUntrackedParameter<std::string>("outputFile", "pixeldigihisto.root")),
runStandalone(ps.getParameter<bool>("runStandalone")),
dbe_(nullptr),
edmDetSetVector_PixelDigi_Token_(consumes<edm::DetSetVector<PixelDigi>>(ps.getParameter<edm::InputTag>("src"))) {}
Expand All @@ -32,7 +33,7 @@ SiPixelDigiValid::~SiPixelDigiValid() {}

void SiPixelDigiValid::bookHistograms(DQMStore::IBooker &ibooker, const edm::Run &run, const edm::EventSetup &es) {
dbe_ = edm::Service<DQMStore>().operator->();
es.get<TrackerRecoGeometryRecord>().get(tracker);
tracker = &es.getData(m_geomToken);

if (dbe_) {
ibooker.setCurrentFolder("TrackerDigisV/TrackerDigis/Pixel");
Expand Down Expand Up @@ -274,9 +275,7 @@ void SiPixelDigiValid::bookHistograms(DQMStore::IBooker &ibooker, const edm::Run

void SiPixelDigiValid::analyze(const edm::Event &e, const edm::EventSetup &c) {
// Retrieve tracker topology from geometry
edm::ESHandle<TrackerTopology> tTopoHandle;
c.get<TrackerTopologyRcd>().get(tTopoHandle);
const TrackerTopology *const tTopo = tTopoHandle.product();
const TrackerTopology *const tTopo = &c.getData(m_topoToken);
// Number of blades and ladders.
// TODO: other Geometry-Dependent quantities, e.g. num layers.
int nblades = tracker->posPixelForwardLayers()[0]->components().size();
Expand Down Expand Up @@ -332,9 +331,6 @@ void SiPixelDigiValid::analyze(const edm::Event &e, const edm::EventSetup &c) {
// LogInfo("EventInfo") << " Run = " << e.id().run() << " Event = " <<
// e.id().event();

edm::ESHandle<TrackerGeometry> tracker;
c.get<TrackerDigiGeometryRecord>().get(tracker);

// string digiProducer = "siPixelDigis";
edm::Handle<edm::DetSetVector<PixelDigi>> pixelDigis;
e.getByToken(edmDetSetVector_PixelDigi_Token_, pixelDigis);
Expand Down
6 changes: 5 additions & 1 deletion Validation/TrackerDigis/plugins/SiPixelDigiValid.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "FWCore/Framework/interface/EDAnalyzer.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
#include "RecoTracker/Record/interface/TrackerRecoGeometryRecord.h"
#include "RecoTracker/TkDetLayers/interface/GeometricSearchTracker.h"
#include "DQMServices/Core/interface/DQMStore.h"
Expand All @@ -27,6 +28,9 @@ class SiPixelDigiValid : public DQMEDAnalyzer {
void bookHistograms(DQMStore::IBooker &ibooker, const edm::Run &run, const edm::EventSetup &es) override;

private:
const edm::ESGetToken<GeometricSearchTracker, TrackerRecoGeometryRecord> m_geomToken;
const edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> m_topoToken;

std::string outputFile_;
bool runStandalone;

Expand Down Expand Up @@ -259,6 +263,6 @@ class SiPixelDigiValid : public DQMEDAnalyzer {

DQMStore *dbe_;
edm::EDGetTokenT<edm::DetSetVector<PixelDigi>> edmDetSetVector_PixelDigi_Token_;
edm::ESHandle<GeometricSearchTracker> tracker;
const GeometricSearchTracker *tracker;
};
#endif
9 changes: 3 additions & 6 deletions Validation/TrackerDigis/plugins/SiStripDigiValid.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
#include "SiStripDigiValid.h"

SiStripDigiValid::SiStripDigiValid(const edm::ParameterSet &ps)
: dbe_(nullptr),
: m_topoToken(esConsumes()),
dbe_(nullptr),
runStandalone(ps.getParameter<bool>("runStandalone")),
outputFile_(ps.getUntrackedParameter<std::string>("outputFile", "stripdigihisto.root")),
edmDetSetVector_SiStripDigi_Token_(
Expand Down Expand Up @@ -325,9 +326,7 @@ void SiStripDigiValid::bookHistograms(DQMStore::IBooker &ibooker, const edm::Run

void SiStripDigiValid::analyze(const edm::Event &e, const edm::EventSetup &c) {
// Retrieve tracker topology from geometry
edm::ESHandle<TrackerTopology> tTopoHandle;
c.get<TrackerTopologyRcd>().get(tTopoHandle);
const TrackerTopology *const tTopo = tTopoHandle.product();
const TrackerTopology *const tTopo = &c.getData(m_topoToken);

int ndigilayertibzp[4];
int ndigilayertibzm[4];
Expand Down Expand Up @@ -363,8 +362,6 @@ void SiStripDigiValid::analyze(const edm::Event &e, const edm::EventSetup &c) {

// LogInfo("EventInfo") << " Run = " << e.id().run() << " Event = " <<
// e.id().event();
edm::ESHandle<TrackerGeometry> tracker;
c.get<TrackerDigiGeometryRecord>().get(tracker);

std::string digiProducer = "siStripDigis";
edm::Handle<edm::DetSetVector<SiStripDigi>> stripDigis;
Expand Down
1 change: 1 addition & 0 deletions Validation/TrackerDigis/plugins/SiStripDigiValid.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class SiStripDigiValid : public DQMEDAnalyzer {
void bookHistograms(DQMStore::IBooker &ibooker, const edm::Run &run, const edm::EventSetup &es) override;

private:
const edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> m_topoToken;
// TIB ADC
MonitorElement *meAdcTIBLayer1Extzp_[3];
MonitorElement *meAdcTIBLayer2Extzp_[3];
Expand Down
6 changes: 5 additions & 1 deletion Validation/TrackerHits/interface/TrackerHitAnalyzer.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@
#include "FWCore/Framework/interface/EDAnalyzer.h"
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include <DQMServices/Core/interface/DQMEDAnalyzer.h>
#include "DQMServices/Core/interface/DQMEDAnalyzer.h"

#include "SimDataFormats/Track/interface/SimTrackContainer.h"
#include "SimDataFormats/TrackingHit/interface/PSimHitContainer.h"
#include "DQMServices/Core/interface/DQMStore.h"

#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"

#include <string>

class TrackerHitAnalyzer : public DQMEDAnalyzer {
Expand All @@ -36,6 +39,7 @@ class TrackerHitAnalyzer : public DQMEDAnalyzer {
// void BookTestHistos(Char_t sname, int nbin, float *xmin, float *xmax);

private:
const edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> tGeomEsToken_;
bool verbose_;

edm::EDGetTokenT<edm::PSimHitContainer> edmPSimHitContainer_pxlBrlLow_Token_, edmPSimHitContainer_pxlBrlHigh_Token_;
Expand Down
4 changes: 2 additions & 2 deletions Validation/TrackerHits/interface/TrackerHitProducer.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define TrackerHitProducer_h

// framework & common header files
#include "FWCore/Framework/interface/EDProducer.h"
#include "FWCore/Framework/interface/one/EDProducer.h"
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"

Expand All @@ -18,7 +18,7 @@ namespace edm {
}
class PTrackerSimHit;

class TrackerHitProducer : public edm::EDProducer {
class TrackerHitProducer : public edm::one::EDProducer<> {
public:
typedef std::vector<float> FloatVector;
typedef std::vector<int> IntegerVector;
Expand Down
9 changes: 3 additions & 6 deletions Validation/TrackerHits/src/TrackerHitAnalyzer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
#include "DataFormats/SiStripDetId/interface/StripSubdetector.h"
#include "Geometry/CommonDetUnit/interface/GeomDet.h"
#include "Geometry/CommonDetUnit/interface/TrackingGeometry.h"
#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"

// data in edm::event
#include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h"
Expand All @@ -38,7 +36,8 @@
#include <vector>

TrackerHitAnalyzer::TrackerHitAnalyzer(const edm::ParameterSet &ps)
: verbose_(ps.getUntrackedParameter<bool>("Verbosity", false)),
: tGeomEsToken_(esConsumes()),
verbose_(ps.getUntrackedParameter<bool>("Verbosity", false)),
edmPSimHitContainer_pxlBrlLow_Token_(
consumes<edm::PSimHitContainer>(ps.getParameter<edm::InputTag>("PxlBrlLowSrc"))),
edmPSimHitContainer_pxlBrlHigh_Token_(
Expand Down Expand Up @@ -457,9 +456,7 @@ void TrackerHitAnalyzer::analyze(const edm::Event &e, const edm::EventSetup &c)
}

// Get geometry information

edm::ESHandle<TrackerGeometry> tracker;
c.get<TrackerDigiGeometryRecord>().get(tracker);
const auto &tracker = &c.getData(tGeomEsToken_);

int ir = -100;
edm::SimTrackContainer::const_iterator itTrk;
Expand Down
7 changes: 7 additions & 0 deletions Validation/TrackerRecHits/interface/SiPixelRecHitsValid.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#include "DQMServices/Core/interface/DQMEDAnalyzer.h"
#include "SimTracker/TrackerHitAssociation/interface/TrackerHitAssociator.h"
#include "DQMServices/Core/interface/DQMStore.h"
#include "Geometry/Records/interface/TrackerTopologyRcd.h"
#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"

#include <string>

Expand All @@ -23,6 +25,7 @@ class PSimHit;
class PixelGeomDetUnit;
class SiPixelRecHit;
class TrackerTopology;
class TrackerGeometry;

class SiPixelRecHitsValid : public DQMEDAnalyzer {
public:
Expand All @@ -40,6 +43,10 @@ class SiPixelRecHitsValid : public DQMEDAnalyzer {
void fillBarrel(const SiPixelRecHit&, const PSimHit&, DetId, const PixelGeomDetUnit*, const TrackerTopology* tTopo);
void fillForward(const SiPixelRecHit&, const PSimHit&, DetId, const PixelGeomDetUnit*, const TrackerTopology* tTopo);

// Es Tokens
const edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> tTopoEsToken;
const edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> tGeomEsToken;

//Clusters BPIX
MonitorElement* clustYSizeModule[8];
MonitorElement* clustXSizeLayer[3];
Expand Down
14 changes: 13 additions & 1 deletion Validation/TrackerRecHits/interface/SiStripRecHitsValid.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Utilities/interface/EDGetToken.h"
#include "FWCore/Framework/interface/ESWatcher.h"
//only mine
#include "DataFormats/Common/interface/Handle.h"
#include "FWCore/Framework/interface/MakerMacros.h"
Expand Down Expand Up @@ -34,6 +35,12 @@
#include "Geometry/CommonDetUnit/interface/PixelGeomDetType.h"
#include "Geometry/TrackerGeometryBuilder/interface/StripGeomDetType.h"

// -- for es tokens
#include "CalibTracker/Records/interface/SiStripDetCablingRcd.h"
#include "CalibFormats/SiStripObjects/interface/SiStripDetCabling.h"
#include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
#include "Geometry/Records/interface/TrackerTopologyRcd.h"

#include <string>
#include <DQMServices/Core/interface/DQMEDAnalyzer.h>
//For RecHit
Expand Down Expand Up @@ -123,6 +130,12 @@ class SiStripRecHitsValid : public DQMEDAnalyzer {
void bookHistograms(DQMStore::IBooker& ibooker, const edm::Run& run, const edm::EventSetup& es) override;

private:
const edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> m_geomToken;
const edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> m_topoToken, m_topoTokenBR;
const edm::ESGetToken<SiStripDetCabling, SiStripDetCablingRcd> m_SiStripDetCablingToken;

edm::ESWatcher<SiStripDetCablingRcd> watchSiStripDetCablingRcd_;

TotalMEs totalMEs;

bool switchNumTotrphi;
Expand Down Expand Up @@ -210,7 +223,6 @@ class SiStripRecHitsValid : public DQMEDAnalyzer {

edm::ParameterSet conf_;
TrackerHitAssociator::Config trackerHitAssociatorConfig_;
unsigned long long m_cacheID_;
//const StripTopology* topol;

/* static const int MAXHIT = 1000; */
Expand Down
21 changes: 9 additions & 12 deletions Validation/TrackerRecHits/src/SiPixelRecHitsValid.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@
#include "Geometry/CommonDetUnit/interface/GeomDetType.h"
#include "Geometry/CommonDetUnit/interface/GeomDet.h"
#include "Geometry/CommonTopologies/interface/PixelTopology.h"
#include "Geometry/Records/interface/TrackerTopologyRcd.h"
#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
#include "Geometry/CommonDetUnit/interface/PixelGeomDetType.h"
#include "Geometry/CommonDetUnit/interface/PixelGeomDetUnit.h"
#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
Expand All @@ -46,7 +44,9 @@
#include <cmath>

SiPixelRecHitsValid::SiPixelRecHitsValid(const edm::ParameterSet& ps)
: trackerHitAssociatorConfig_(ps, consumesCollector()),
: tTopoEsToken(esConsumes()),
tGeomEsToken(esConsumes()),
trackerHitAssociatorConfig_(ps, consumesCollector()),
siPixelRecHitCollectionToken_(consumes<SiPixelRecHitCollection>(ps.getParameter<edm::InputTag>("src"))) {}

SiPixelRecHitsValid::~SiPixelRecHitsValid() {}
Expand Down Expand Up @@ -274,9 +274,7 @@ void SiPixelRecHitsValid::bookHistograms(DQMStore::IBooker& ibooker, const edm::

void SiPixelRecHitsValid::analyze(const edm::Event& e, const edm::EventSetup& es) {
//Retrieve tracker topology from geometry
edm::ESHandle<TrackerTopology> tTopoHand;
es.get<TrackerTopologyRcd>().get(tTopoHand);
const TrackerTopology* tTopo = tTopoHand.product();
const TrackerTopology* tTopo = &es.getData(tTopoEsToken);

edm::LogInfo("EventInfo") << " Run = " << e.id().run() << " Event = " << e.id().event();
if (e.id().event() % 1000 == 0)
Expand All @@ -287,21 +285,20 @@ void SiPixelRecHitsValid::analyze(const edm::Event& e, const edm::EventSetup& es
e.getByToken(siPixelRecHitCollectionToken_, recHitColl);

//Get event setup
edm::ESHandle<TrackerGeometry> geom;
es.get<TrackerDigiGeometryRecord>().get(geom);
const TrackerGeometry& theTracker(*geom);
const TrackerGeometry* theTracker = &es.getData(tGeomEsToken);

TrackerHitAssociator associate(e, trackerHitAssociatorConfig_);

//iterate over detunits
for (TrackerGeometry::DetContainer::const_iterator it = geom->dets().begin(); it != geom->dets().end(); it++) {
DetId detId = ((*it)->geographicalId());
//for (TrackerGeometry::DetContainer::const_iterator it = geom->dets().begin(); it != geom->dets().end(); it++) {
for (const auto& it : theTracker->dets()) {
DetId detId = it->geographicalId();
unsigned int subid = detId.subdetId();

if (!((subid == 1) || (subid == 2)))
continue;

const PixelGeomDetUnit* theGeomDet = dynamic_cast<const PixelGeomDetUnit*>(theTracker.idToDet(detId));
const PixelGeomDetUnit* theGeomDet = dynamic_cast<const PixelGeomDetUnit*>(theTracker->idToDet(detId));

SiPixelRecHitCollection::const_iterator pixeldet = recHitColl->find(detId);
if (pixeldet == recHitColl->end())
Expand Down
Loading

0 comments on commit 1b23a1c

Please sign in to comment.