Skip to content

Commit

Permalink
Merge pull request #35300 from makortel/esconsumesRecoPixelVertexing
Browse files Browse the repository at this point in the history
Migrate EDModules in RecoPixelVertexing/PixelTrackFitting to esConsumes
  • Loading branch information
cmsbuild authored Sep 18, 2021
2 parents fc2c6b7 + f41bfc7 commit aeb2739
Show file tree
Hide file tree
Showing 27 changed files with 86 additions and 151 deletions.
13 changes: 4 additions & 9 deletions FastSimulation/Tracking/plugins/PixelTracksProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,12 @@
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Framework/interface/ConsumesCollector.h"
#include "FWCore/Framework/interface/ESHandle.h"

#include "DataFormats/Common/interface/Handle.h"
#include "DataFormats/Common/interface/OwnVector.h"

#include "DataFormats/TrackingRecHit/interface/TrackingRecHit.h"

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

//Pixel Specific stuff
#include "RecoTracker/TkTrackingRegions/interface/TrackingRegionProducer.h"
#include "RecoTracker/TkTrackingRegions/interface/TrackingRegionProducerFactory.h"
Expand All @@ -32,7 +28,8 @@

using namespace pixeltrackfitting;

PixelTracksProducer::PixelTracksProducer(const edm::ParameterSet& conf) : theRegionProducer(nullptr) {
PixelTracksProducer::PixelTracksProducer(const edm::ParameterSet& conf)
: theRegionProducer(nullptr), ttopoToken(esConsumes()) {
produces<reco::TrackCollection>();
produces<TrackingRecHitCollection>();
produces<reco::TrackExtraCollection>();
Expand Down Expand Up @@ -62,9 +59,7 @@ void PixelTracksProducer::produce(edm::Event& e, const edm::EventSetup& es) {
TracksWithRecHits pixeltracks;
TracksWithRecHits cleanedTracks;

edm::ESHandle<TrackerTopology> httopo;
es.get<TrackerTopologyRcd>().get(httopo);
const TrackerTopology& ttopo = *httopo;
const TrackerTopology& ttopo = es.getData(ttopoToken);

edm::Handle<PixelFitter> hfitter;
e.getByToken(fitterToken, hfitter);
Expand Down Expand Up @@ -107,7 +102,7 @@ void PixelTracksProducer::produce(edm::Event& e, const edm::EventSetup& es) {
}

// fitting the triplet
std::unique_ptr<reco::Track> track = fitter.run(TripletHits, region, es);
std::unique_ptr<reco::Track> track = fitter.run(TripletHits, region);

// decide if track should be skipped according to filter
if (!theFilter(track.get(), TripletHits)) {
Expand Down
11 changes: 5 additions & 6 deletions FastSimulation/Tracking/plugins/PixelTracksProducer.h
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
#ifndef FastSimulation_Tracking_PixelTracksProducer_H
#define FastSimulation_Tracking_PixelTracksProducer_H

#include "FWCore/Framework/interface/FrameworkfwdMostUsed.h"
#include "FWCore/Framework/interface/stream/EDProducer.h"
#include "FWCore/Utilities/interface/InputTag.h"

#include "DataFormats/TrajectorySeed/interface/TrajectorySeedCollection.h"

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

#include <string>

class PixelFitter;
class PixelTrackFilter;
class TrackingRegionProducer;

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

class PixelTracksProducer : public edm::stream::EDProducer<> {
public:
explicit PixelTracksProducer(const edm::ParameterSet& conf);
Expand All @@ -32,5 +30,6 @@ class PixelTracksProducer : public edm::stream::EDProducer<> {

edm::EDGetTokenT<TrajectorySeedCollection> seedProducerToken;
edm::EDGetTokenT<PixelTrackFilter> filterToken;
edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> ttopoToken;
};
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include "RecoPixelVertexing/PixelTrackFitting/interface/PixelFitterBase.h"
#include "DataFormats/TrackingRecHit/interface/TrackingRecHit.h"
#include "RecoTracker/TkTrackingRegions/interface/TrackingRegion.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "DataFormats/TrackReco/interface/Track.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"

Expand All @@ -23,8 +22,7 @@ class TrackFitter : public PixelFitterBase {
~TrackFitter() override {}

std::unique_ptr<reco::Track> run(const std::vector<const TrackingRecHit*>& hits,
const TrackingRegion& region,
const edm::EventSetup& setup) const override;
const TrackingRegion& region) const override;

private:
float getCotThetaAndUpdateZip(
Expand Down
3 changes: 1 addition & 2 deletions RecoPixelVertexing/PixelLowPtUtilities/src/TrackFitter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ namespace {

/*****************************************************************************/
std::unique_ptr<reco::Track> TrackFitter::run(const std::vector<const TrackingRecHit*>& hits,
const TrackingRegion& region,
const edm::EventSetup& setup) const {
const TrackingRegion& region) const {
std::unique_ptr<reco::Track> ret;

int nhits = hits.size();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@

#include <vector>

namespace edm {
class EventSetup;
}
namespace reco {
class Track;
class BeamSpot;
Expand All @@ -33,8 +30,7 @@ class KFBasedPixelFitter : public PixelFitterBase {
~KFBasedPixelFitter() override {}

std::unique_ptr<reco::Track> run(const std::vector<const TrackingRecHit *> &hits,
const TrackingRegion &region,
const edm::EventSetup &setup) const override;
const TrackingRegion &region) const override;

private:
//this two simple classes are copied from Alignment/ReferenceTrajectories in order to avoid dependencies
Expand Down
6 changes: 2 additions & 4 deletions RecoPixelVertexing/PixelTrackFitting/interface/PixelFitter.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@ class PixelFitter {

void swap(PixelFitter& o) { std::swap(fitter_, o.fitter_); }

std::unique_ptr<reco::Track> run(const std::vector<const TrackingRecHit*>& hits,
const TrackingRegion& region,
const edm::EventSetup& setup) const {
return fitter_->run(hits, region, setup);
std::unique_ptr<reco::Track> run(const std::vector<const TrackingRecHit*>& hits, const TrackingRegion& region) const {
return fitter_->run(hits, region);
}

private:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
#include <vector>
#include <memory>

namespace edm {
class EventSetup;
}
class TrackingRegion;
class TrackingRecHit;

Expand All @@ -17,7 +14,6 @@ class PixelFitterBase {
virtual ~PixelFitterBase() {}

virtual std::unique_ptr<reco::Track> run(const std::vector<const TrackingRecHit*>& hits,
const TrackingRegion& region,
const edm::EventSetup& setup) const = 0;
const TrackingRegion& region) const = 0;
};
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include "RecoPixelVertexing/PixelTrackFitting/interface/PixelFitterBase.h"
#include "DataFormats/TrackingRecHit/interface/TrackingRecHit.h"
#include "RecoTracker/TkTrackingRegions/interface/TrackingRegion.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "DataFormats/TrackReco/interface/Track.h"

class TrackerGeometry;
Expand All @@ -20,8 +19,7 @@ class PixelFitterByConformalMappingAndLine : public PixelFitterBase {
bool useFixImpactParameter);
~PixelFitterByConformalMappingAndLine() override {}
std::unique_ptr<reco::Track> run(const std::vector<const TrackingRecHit *> &hits,
const TrackingRegion &region,
const edm::EventSetup &setup) const override;
const TrackingRegion &region) const override;

private:
const TransientTrackingRecHitBuilder *theTTRHBuilder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include "RecoPixelVertexing/PixelTrackFitting/interface/PixelFitterBase.h"
#include "DataFormats/TrackingRecHit/interface/TrackingRecHit.h"
#include "RecoTracker/TkTrackingRegions/interface/TrackingRegion.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "DataFormats/TrackReco/interface/Track.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"

Expand All @@ -14,19 +13,18 @@ class TrackerTopology;

class PixelFitterByHelixProjections final : public PixelFitterBase {
public:
explicit PixelFitterByHelixProjections(const edm::EventSetup *es,
explicit PixelFitterByHelixProjections(const TrackerTopology *ttopo,
const MagneticField *field,
bool scaleErrorsForBPix1,
float scaleFactor);
~PixelFitterByHelixProjections() override {}
std::unique_ptr<reco::Track> run(const std::vector<const TrackingRecHit *> &hits,
const TrackingRegion &region,
const edm::EventSetup &setup) const override;
const TrackingRegion &region) const override;

private:
const TrackerTopology *theTopo;
const MagneticField *theField;
const bool thescaleErrorsForBPix1;
const float thescaleFactor;
TrackerTopology const *theTopo = nullptr;
};
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

#include "DataFormats/TrackReco/interface/Track.h"
#include "DataFormats/TrackingRecHit/interface/TrackingRecHit.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "RecoPixelVertexing/PixelTrackFitting/interface/PixelFitterBase.h"
#include "RecoTracker/TkTrackingRegions/interface/TrackingRegion.h"
Expand All @@ -15,8 +14,7 @@ class PixelNtupletsFitter final : public PixelFitterBase {
explicit PixelNtupletsFitter(float nominalB, const MagneticField* field, bool useRiemannFit);
~PixelNtupletsFitter() override = default;
std::unique_ptr<reco::Track> run(const std::vector<const TrackingRecHit*>& hits,
const TrackingRegion& region,
const edm::EventSetup& setup) const override;
const TrackingRegion& region) const override;

private:
float nominalB_;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,20 @@
#ifndef RecoPixelVertexing_PixelTrackFitting_PixelTrackReconstruction_H
#define RecoPixelVertexing_PixelTrackFitting_PixelTrackReconstruction_H

#include "FWCore/Framework/interface/ConsumesCollector.h"
#include "FWCore/Framework/interface/FrameworkfwdMostUsed.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "RecoPixelVertexing/PixelTrackFitting/interface/TracksWithHits.h"
#include "FWCore/Framework/interface/ConsumesCollector.h"
#include "RecoPixelVertexing/PixelTrackFitting/interface/PixelTrackCleaner.h"

#include "FWCore/Utilities/interface/EDGetToken.h"

#include <memory>

class PixelFitter;
class PixelTrackCleaner;
class PixelTrackFilter;
class RegionsSeedingHitSets;

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

class PixelTrackReconstruction {
public:
PixelTrackReconstruction(const edm::ParameterSet& conf, edm::ConsumesCollector&& iC);
Expand All @@ -34,6 +28,6 @@ class PixelTrackReconstruction {
edm::EDGetTokenT<RegionsSeedingHitSets> theHitSetsToken;
edm::EDGetTokenT<PixelFitter> theFitterToken;
edm::EDGetTokenT<PixelTrackFilter> theFilterToken;
std::string theCleanerName;
edm::ESGetToken<PixelTrackCleaner, PixelTrackCleaner::Record> theCleanerToken;
};
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/ESHandle.h"

#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
Expand All @@ -30,21 +29,25 @@ class KFBasedPixelFitterProducer : public edm::global::EDProducer<> {
private:
void produce(edm::StreamID, edm::Event& iEvent, const edm::EventSetup& iSetup) const override;

std::string thePropagatorLabel;
std::string thePropagatorOppositeLabel;
std::string theTTRHBuilderName;
edm::EDGetTokenT<reco::BeamSpot> theBeamSpotToken;
const edm::ESGetToken<TransientTrackingRecHitBuilder, TransientRecHitRecord> theTTRHBuilderToken;
const edm::ESGetToken<Propagator, TrackingComponentsRecord> thePropagatorToken;
const edm::ESGetToken<Propagator, TrackingComponentsRecord> thePropagatorOppositeToken;
const edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> theTrackerToken;
const edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> theFieldToken;
const edm::EDPutTokenT<PixelFitter> thePutToken;
};

KFBasedPixelFitterProducer::KFBasedPixelFitterProducer(const edm::ParameterSet& iConfig)
: thePropagatorLabel(iConfig.getParameter<std::string>("propagator")),
thePropagatorOppositeLabel(iConfig.getParameter<std::string>("propagator")),
theTTRHBuilderName(iConfig.getParameter<std::string>("TTRHBuilder")) {
: theTTRHBuilderToken(esConsumes(edm::ESInputTag("", iConfig.getParameter<std::string>("TTRHBuilder")))),
thePropagatorToken(esConsumes(edm::ESInputTag("", iConfig.getParameter<std::string>("propagator")))),
thePropagatorOppositeToken(esConsumes(edm::ESInputTag("", iConfig.getParameter<std::string>("propagator")))),
theTrackerToken(esConsumes()),
theFieldToken(esConsumes()),
thePutToken(produces()) {
if (iConfig.getParameter<bool>("useBeamSpotConstraint")) {
theBeamSpotToken = consumes<reco::BeamSpot>(iConfig.getParameter<edm::InputTag>("beamSpotConstraint"));
}

produces<PixelFitter>();
}

void KFBasedPixelFitterProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
Expand All @@ -60,32 +63,20 @@ void KFBasedPixelFitterProducer::fillDescriptions(edm::ConfigurationDescriptions
}

void KFBasedPixelFitterProducer::produce(edm::StreamID, edm::Event& iEvent, const edm::EventSetup& iSetup) const {
edm::ESHandle<TransientTrackingRecHitBuilder> ttrhb;
iSetup.get<TransientRecHitRecord>().get(theTTRHBuilderName, ttrhb);

edm::ESHandle<Propagator> propagator;
iSetup.get<TrackingComponentsRecord>().get(thePropagatorLabel, propagator);

edm::ESHandle<Propagator> opropagator;
iSetup.get<TrackingComponentsRecord>().get(thePropagatorOppositeLabel, opropagator);

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

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

const reco::BeamSpot* beamspot = nullptr;
if (!theBeamSpotToken.isUninitialized()) {
edm::Handle<reco::BeamSpot> hbs;
iEvent.getByToken(theBeamSpotToken, hbs);
beamspot = hbs.product();
}

auto impl = std::make_unique<KFBasedPixelFitter>(
propagator.product(), opropagator.product(), ttrhb.product(), tracker.product(), field.product(), beamspot);
auto prod = std::make_unique<PixelFitter>(std::move(impl));
iEvent.put(std::move(prod));
iEvent.emplace(thePutToken,
std::make_unique<KFBasedPixelFitter>(&iSetup.getData(thePropagatorToken),
&iSetup.getData(thePropagatorOppositeToken),
&iSetup.getData(theTTRHBuilderToken),
&iSetup.getData(theTrackerToken),
&iSetup.getData(theFieldToken),
beamspot));
}

DEFINE_FWK_MODULE(KFBasedPixelFitterProducer);
Loading

0 comments on commit aeb2739

Please sign in to comment.