Skip to content

Commit

Permalink
migrate RecoPixelVertexing/PixelLowPtUtilities to esConsumes
Browse files Browse the repository at this point in the history
  • Loading branch information
mmusich committed Mar 15, 2021
1 parent 4adab38 commit 57b88a1
Show file tree
Hide file tree
Showing 12 changed files with 72 additions and 75 deletions.
12 changes: 7 additions & 5 deletions RecoPixelVertexing/PixelLowPtUtilities/BuildFile.xml
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
<use name="CondFormats/DataRecord"/>
<use name="CondFormats/SiPixelObjects"/>
<use name="CondFormats/SiStripObjects"/>
<use name="DataFormats/TrackerCommon"/>
<use name="FWCore/Framework"/>
<use name="FWCore/ParameterSet"/>
<use name="FWCore/PluginManager"/>
<use name="FWCore/Utilities"/>
<use name="Geometry/Records"/>
<use name="Geometry/TrackerGeometryBuilder"/>
<use name="TrackingTools/PatternTools"/>
<use name="RecoPixelVertexing/PixelTriplets"/>
<use name="MagneticField/Records"/>
<use name="RecoPixelVertexing/PixelTrackFitting"/>
<use name="TrackingTools/TrajectoryFiltering"/>
<use name="RecoPixelVertexing/PixelTriplets"/>
<use name="TrackingTools/PatternTools"/>
<use name="TrackingTools/Records"/>
<use name="MagneticField/Records"/>
<use name="DataFormats/TrackerCommon"/>
<use name="TrackingTools/TrajectoryFiltering"/>
<export>
<lib name="1"/>
</export>
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ class PixelClusterShapeExtractor final : public edm::global::EDAnalyzer<> {
void analyzeSimHits(const edm::Event& ev, const edm::EventSetup& es) const;
void analyzeRecTracks(const edm::Event& ev, const edm::EventSetup& es) const;

/// Tokens for ESconsumes
const edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> topoToken_;
const edm::ESGetToken<ClusterShapeHitFilter, CkfComponentsRecord> csfToken_;

TFile* file;

const bool hasSimHits;
Expand Down Expand Up @@ -143,7 +147,9 @@ void PixelClusterShapeExtractor::init() {

/*****************************************************************************/
PixelClusterShapeExtractor::PixelClusterShapeExtractor(const edm::ParameterSet& pset)
: hasSimHits(pset.getParameter<bool>("hasSimHits")),
: topoToken_(esConsumes()),
csfToken_(esConsumes(edm::ESInputTag("", "ClusterShapeHitFilter"))),
hasSimHits(pset.getParameter<bool>("hasSimHits")),
hasRecTracks(pset.getParameter<bool>("hasRecTracks")),
noBPIX1(pset.getParameter<bool>("noBPIX1")),
tracks_token(hasRecTracks ? consumes<reco::TrackCollection>(pset.getParameter<edm::InputTag>("tracks"))
Expand Down Expand Up @@ -300,13 +306,8 @@ void PixelClusterShapeExtractor::processPixelRecHits(const SiPixelRecHitCollecti

/*****************************************************************************/
void PixelClusterShapeExtractor::analyzeSimHits(const edm::Event& ev, const edm::EventSetup& es) const {
edm::ESHandle<ClusterShapeHitFilter> shape;
es.get<CkfComponentsRecord>().get("ClusterShapeHitFilter", shape);
auto const& theClusterShape = *shape.product();

edm::ESHandle<TrackerTopology> tTopoHandle;
es.get<TrackerTopologyRcd>().get(tTopoHandle);
auto const& tkTpl = *tTopoHandle;
auto const& theClusterShape = es.getData(csfToken_);
auto const& tkTpl = es.getData(topoToken_);

edm::Handle<SiPixelClusterShapeCache> clusterShapeCache;
ev.getByToken(clusterShapeCache_token, clusterShapeCache);
Expand All @@ -329,13 +330,8 @@ void PixelClusterShapeExtractor::analyzeSimHits(const edm::Event& ev, const edm:

/*****************************************************************************/
void PixelClusterShapeExtractor::analyzeRecTracks(const edm::Event& ev, const edm::EventSetup& es) const {
edm::ESHandle<ClusterShapeHitFilter> shape;
es.get<CkfComponentsRecord>().get("ClusterShapeHitFilter", shape);
auto const& theClusterShape = *shape.product();

edm::ESHandle<TrackerTopology> tTopoHandle;
es.get<TrackerTopologyRcd>().get(tTopoHandle);
auto const& tkTpl = *tTopoHandle;
auto const& theClusterShape = es.getData(csfToken_);
auto const& tkTpl = es.getData(topoToken_);

// Get tracks
edm::Handle<reco::TrackCollection> tracks;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
provided Layers
*/

#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
#include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
#include "Geometry/Records/interface/TrackerTopologyRcd.h"

#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Utilities/interface/EDGetToken.h"
Expand Down Expand Up @@ -41,6 +46,9 @@ class PixelTripletLowPtGenerator : public HitTripletGeneratorFromPairAndLayers {
const int nThirdLayers) override;

private:
edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> m_geomToken;
edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> m_topoToken;

void getTracker(const edm::EventSetup& es);
GlobalPoint getGlobalPosition(const TrackingRecHit* recHit);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include "FWCore/Utilities/interface/EDGetToken.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "RecoTracker/TkSeedingLayers/interface/SeedComparitor.h"
#include "CondFormats/SiStripObjects/interface/SiStripNoises.h"
#include "CondFormats/DataRecord/interface/SiStripNoisesRcd.h"

class ClusterShapeHitFilter;
class TrackerTopology;
Expand Down Expand Up @@ -40,6 +42,12 @@ class StripSubClusterShapeFilterBase {
const GlobalVector &gdir,
bool mustProject = false) const;

// esConsumes tokens
edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> topoToken_;
edm::ESGetToken<ClusterShapeHitFilter, CkfComponentsRecord> csfToken_;
edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> geomToken_;
edm::ESGetToken<SiStripNoises, SiStripNoisesRcd> stripNoiseToken_;

// who am i
std::string label_;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,12 @@
#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
#include "Geometry/CommonDetUnit/interface/PixelGeomDetUnit.h"
#include "Geometry/CommonTopologies/interface/PixelTopology.h"
#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"

#include "Geometry/CommonDetUnit/interface/GeomDet.h"

#include "DataFormats/GeometryVector/interface/LocalPoint.h"
#include "DataFormats/GeometryVector/interface/GlobalPoint.h"

#include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
#include "Geometry/Records/interface/TrackerTopologyRcd.h"

#include "SimDataFormats/Vertex/interface/SimVertexContainer.h"

#include <vector>
Expand Down Expand Up @@ -56,7 +53,7 @@ namespace {

/*****************************************************************************/
PixelVertexProducerClusters::PixelVertexProducerClusters(const edm::ParameterSet& ps)
: pixelToken_(consumes<SiPixelRecHitCollection>(edm::InputTag("siPixelRecHits"))) {
: geomToken_(esConsumes()), pixelToken_(consumes<SiPixelRecHitCollection>(edm::InputTag("siPixelRecHits"))) {
// Product
produces<reco::VertexCollection>();
}
Expand All @@ -66,14 +63,8 @@ PixelVertexProducerClusters::~PixelVertexProducerClusters() {}

/*****************************************************************************/
void PixelVertexProducerClusters::produce(edm::StreamID, edm::Event& ev, const edm::EventSetup& es) const {
//Retrieve tracker topology from geometry
edm::ESHandle<TrackerTopology> tTopo;
es.get<TrackerTopologyRcd>().get(tTopo);

// Get tracker geometry
edm::ESHandle<TrackerGeometry> trackerHandle;
es.get<TrackerDigiGeometryRecord>().get(trackerHandle);
const TrackerGeometry* theTracker = trackerHandle.product();
const TrackerGeometry* theTracker = &es.getData(geomToken_);

// Get pixel hit collections
edm::Handle<SiPixelRecHitCollection> pixelColl;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#ifndef PixelVertexProducerClusters_H
#define PixelVertexProducerClusters_H

#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
#include "FWCore/Framework/interface/global/EDProducer.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"

#include "DataFormats/TrackerRecHit2D/interface/SiPixelRecHitCollection.h"

namespace edm {
Expand All @@ -21,6 +22,7 @@ class PixelVertexProducerClusters : public edm::global::EDProducer<> {
void produce(edm::StreamID, edm::Event& ev, const edm::EventSetup& es) const override;

private:
const edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> geomToken_;
edm::EDGetTokenT<SiPixelRecHitCollection> pixelToken_;
};
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,21 @@ struct ComparePairs {

/*****************************************************************************/
PixelVertexProducerMedian::PixelVertexProducerMedian(const edm::ParameterSet& ps) : theConfig(ps) {
thePtMin = theConfig.getParameter<double>("PtMin");
produces<reco::VertexCollection>();
}

/*****************************************************************************/
PixelVertexProducerMedian::~PixelVertexProducerMedian() {}

/*****************************************************************************/
void PixelVertexProducerMedian::produce(edm::Event& ev, const edm::EventSetup& es) {
void PixelVertexProducerMedian::produce(edm::StreamID, edm::Event& ev, const edm::EventSetup& es) const {
// Get pixel tracks
edm::Handle<reco::TrackCollection> trackCollection;
std::string trackCollectionName = theConfig.getParameter<std::string>("TrackCollection");
ev.getByLabel(trackCollectionName, trackCollection);
const reco::TrackCollection tracks_ = *(trackCollection.product());

thePtMin = theConfig.getParameter<double>("PtMin");

// Select tracks
std::vector<const reco::Track*> tracks;
for (unsigned int i = 0; i < tracks_.size(); i++) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
#ifndef PixelVertexProducerMedian_H
#define PixelVertexProducerMedian_H

#include "FWCore/Framework/interface/EDProducer.h"
#include "FWCore/Framework/interface/global/EDProducer.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"

namespace edm {
class Event;
class EventSetup;
} // namespace edm

class PixelVertexProducerMedian : public edm::EDProducer {
class PixelVertexProducerMedian : public edm::global::EDProducer<> {
public:
explicit PixelVertexProducerMedian(const edm::ParameterSet& ps);
~PixelVertexProducerMedian() override;
void produce(edm::Event& ev, const edm::EventSetup& es) override;
void produce(edm::StreamID, edm::Event& ev, const edm::EventSetup& es) const override;

private:
edm::ParameterSet theConfig;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@ class SiPixelClusterShapeCacheProducer : public edm::global::EDProducer<> {
using InputCollection = edmNew::DetSetVector<SiPixelCluster>;

const edm::EDGetTokenT<InputCollection> token_;
const edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> geomToken_;
};

SiPixelClusterShapeCacheProducer::SiPixelClusterShapeCacheProducer(const edm::ParameterSet& iConfig)
: token_(consumes<InputCollection>(iConfig.getParameter<edm::InputTag>("src"))) {
: token_(consumes<InputCollection>(iConfig.getParameter<edm::InputTag>("src"))), geomToken_(esConsumes()) {
if (iConfig.getParameter<bool>("onDemand")) {
throw cms::Exception("OnDemandNotAllowed")
<< "Use of the `onDemand` feature of SiPixelClusterShapeCacheProducer is no longer supported";
Expand All @@ -60,8 +61,7 @@ void SiPixelClusterShapeCacheProducer::produce(edm::StreamID, edm::Event& iEvent
edm::Handle<InputCollection> input;
iEvent.getByToken(token_, input);

edm::ESHandle<TrackerGeometry> geom;
iSetup.get<TrackerDigiGeometryRecord>().get(geom);
const auto& geom = &iSetup.getData(geomToken_);

auto output = std::make_unique<SiPixelClusterShapeCache>(input);
output->resize(input->data().size());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,16 @@ class TrackFitterProducer : public edm::global::EDProducer<> {
private:
void produce(edm::StreamID, edm::Event& iEvent, const edm::EventSetup& iSetup) const override;

std::string theTTRHBuilderName;
const edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> geomToken_;
const edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> magFieldToken_;
const edm::ESGetToken<TransientTrackingRecHitBuilder, TransientRecHitRecord> ttrhToken_;
edm::EDGetTokenT<reco::BeamSpot> theBeamSpotToken;
};

TrackFitterProducer::TrackFitterProducer(const edm::ParameterSet& iConfig)
: theTTRHBuilderName(iConfig.getParameter<std::string>("TTRHBuilder")) {
: geomToken_(esConsumes()),
magFieldToken_(esConsumes()),
ttrhToken_(esConsumes(edm::ESInputTag("", iConfig.getParameter<std::string>("TTRHBuilder")))) {
produces<PixelFitter>();
}

Expand All @@ -48,16 +52,11 @@ void TrackFitterProducer::fillDescriptions(edm::ConfigurationDescriptions& descr
}

void TrackFitterProducer::produce(edm::StreamID, edm::Event& iEvent, const edm::EventSetup& iSetup) const {
edm::ESHandle<TrackerGeometry> trackerESH;
iSetup.get<TrackerDigiGeometryRecord>().get(trackerESH);
const auto& tracker = &iSetup.getData(geomToken_);
const auto& field = &iSetup.getData(magFieldToken_);
const auto& ttrh = &iSetup.getData(ttrhToken_);

edm::ESHandle<MagneticField> fieldESH;
iSetup.get<IdealMagneticFieldRecord>().get(fieldESH);

edm::ESHandle<TransientTrackingRecHitBuilder> ttrhbESH;
iSetup.get<TransientRecHitRecord>().get(theTTRHBuilderName, ttrhbESH);

auto impl = std::make_unique<TrackFitter>(trackerESH.product(), fieldESH.product(), ttrhbESH.product());
auto impl = std::make_unique<TrackFitter>(tracker, field, ttrh);
auto prod = std::make_unique<PixelFitter>(std::move(impl));
iEvent.put(std::move(prod));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,9 @@
#include "RecoTracker/TkMSParametrization/interface/PixelRecoPointRZ.h"
#include "RecoTracker/TkHitPairs/interface/HitPairGeneratorFromLayerPair.h"

#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/ConsumesCollector.h"

#include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
#include "Geometry/Records/interface/TrackerTopologyRcd.h"

#include "FWCore/Framework/interface/Event.h"
#include "DataFormats/SiPixelCluster/interface/SiPixelClusterShapeCache.h"

Expand All @@ -24,6 +19,8 @@ using namespace std;
/*****************************************************************************/
PixelTripletLowPtGenerator::PixelTripletLowPtGenerator(const edm::ParameterSet& cfg, edm::ConsumesCollector& iC)
: HitTripletGeneratorFromPairAndLayers(), // no theMaxElement used in this class
m_geomToken(iC.esConsumes<TrackerGeometry, TrackerDigiGeometryRecord>()),
m_topoToken(iC.esConsumes<TrackerTopology, TrackerTopologyRcd>()),
theTracker(nullptr),
theClusterShapeCacheToken(
iC.consumes<SiPixelClusterShapeCache>(cfg.getParameter<edm::InputTag>("clusterShapeCacheSrc"))) {
Expand All @@ -44,10 +41,7 @@ PixelTripletLowPtGenerator::~PixelTripletLowPtGenerator() {}
void PixelTripletLowPtGenerator::getTracker(const edm::EventSetup& es) {
if (theTracker == nullptr) {
// Get tracker geometry
edm::ESHandle<TrackerGeometry> tracker;
es.get<TrackerDigiGeometryRecord>().get(tracker);

theTracker = tracker.product();
theTracker = &es.getData(m_geomToken);
}

if (!theFilter) {
Expand All @@ -70,9 +64,7 @@ void PixelTripletLowPtGenerator::hitTriplets(const TrackingRegion& region,
const SeedingLayerSetsHits::SeedingLayerSet& pairLayers,
const std::vector<SeedingLayerSetsHits::SeedingLayer>& thirdLayers) {
//Retrieve tracker topology from geometry
edm::ESHandle<TrackerTopology> tTopoHand;
es.get<TrackerTopologyRcd>().get(tTopoHand);
const TrackerTopology* tTopo = tTopoHand.product();
const TrackerTopology* tTopo = &es.getData(m_topoToken);

edm::Handle<SiPixelClusterShapeCache> clusterShapeCache;
ev.getByToken(theClusterShapeCacheToken, clusterShapeCache);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@
#include "RecoTracker/TkSeedingLayers/interface/SeedingHitSet.h"
#include "DataFormats/SiStripDetId/interface/SiStripDetId.h"

#include "CondFormats/SiStripObjects/interface/SiStripNoises.h"
#include "CondFormats/DataRecord/interface/SiStripNoisesRcd.h"

#ifdef StripSubClusterShapeFilterBase_COUNTERS
#define INC_COUNTER(X) X++;
#else
Expand Down Expand Up @@ -137,7 +134,12 @@ namespace {
/*****************************************************************************/
StripSubClusterShapeFilterBase::StripSubClusterShapeFilterBase(const edm::ParameterSet &iCfg,
edm::ConsumesCollector &iC)
: label_(iCfg.getUntrackedParameter<std::string>("label", "")),
: topoToken_(iC.esConsumes<TrackerTopology, TrackerTopologyRcd>()),
csfToken_(
iC.esConsumes<ClusterShapeHitFilter, CkfComponentsRecord>(edm::ESInputTag("", "ClusterShapeHitFilter"))),
geomToken_(iC.esConsumes<TrackerGeometry, TrackerDigiGeometryRecord>()),
stripNoiseToken_(iC.esConsumes<SiStripNoises, SiStripNoisesRcd>()),
label_(iCfg.getUntrackedParameter<std::string>("label", "")),
maxNSat_(iCfg.getParameter<uint32_t>("maxNSat")),
trimMaxADC_(iCfg.getParameter<double>("trimMaxADC")),
trimMaxFracTotal_(iCfg.getParameter<double>("trimMaxFracTotal")),
Expand Down Expand Up @@ -322,14 +324,12 @@ bool StripSubClusterShapeFilterBase::testLastHit(const TrackingRecHit *hit,

void StripSubClusterShapeFilterBase::setEventBase(const edm::Event &event, const edm::EventSetup &es) {
// Get tracker geometry
es.get<TrackerDigiGeometryRecord>().get(theTracker);

es.get<CkfComponentsRecord>().get("ClusterShapeHitFilter", theFilter);
theTracker = es.getHandle(geomToken_);
theFilter = es.getHandle(csfToken_);

//Retrieve tracker topology from geometry
es.get<TrackerTopologyRcd>().get(theTopology);

es.get<SiStripNoisesRcd>().get(theNoise);
theTopology = es.getHandle(topoToken_);
theNoise = es.getHandle(stripNoiseToken_);
}

/*****************************************************************************/
Expand Down

0 comments on commit 57b88a1

Please sign in to comment.