Skip to content

Commit

Permalink
Merge pull request #35393 from makortel/esconsumesTrackingRegion
Browse files Browse the repository at this point in the history
Migrate TrackingRegions to esConsumes
  • Loading branch information
cmsbuild authored Oct 1, 2021
2 parents abdf401 + ef18849 commit ec53ab6
Show file tree
Hide file tree
Showing 65 changed files with 629 additions and 402 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@
#include "DataFormats/Common/interface/Handle.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Utilities/interface/InputTag.h"
#include "MagneticField/Engine/interface/MagneticField.h"
#include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
#include "RecoTracker/Record/interface/TrackerMultipleScatteringRecord.h"
#include "RecoTracker/TkMSParametrization/interface/MultipleScatteringParametrisationMaker.h"
#include "RecoTracker/TkTrackingRegions/interface/TrackingRegionProducer.h"
#include "RecoTracker/TkTrackingRegions/interface/GlobalTrackingRegion.h"
#include "RecoTracker/TkTrackingRegions/interface/RectangularEtaPhiTrackingRegion.h"
#include "DataFormats/VertexReco/interface/Vertex.h"
#include "DataFormats/VertexReco/interface/VertexFwd.h"
Expand All @@ -31,10 +34,11 @@

class HITRegionalPixelSeedGenerator : public TrackingRegionProducer {
public:
explicit HITRegionalPixelSeedGenerator(const edm::ParameterSet& conf_, edm::ConsumesCollector&& iC) {
explicit HITRegionalPixelSeedGenerator(const edm::ParameterSet& conf, edm::ConsumesCollector&& iC)
: token_bfield(iC.esConsumes()), token_msmaker(iC.esConsumes()) {
edm::LogVerbatim("HITRegionalPixelSeedGenerator") << "Enter the HITRegionalPixelSeedGenerator";

edm::ParameterSet regionPSet = conf_.getParameter<edm::ParameterSet>("RegionPSet");
edm::ParameterSet regionPSet = conf.getParameter<edm::ParameterSet>("RegionPSet");

ptmin = regionPSet.getParameter<double>("ptMin");
originradius = regionPSet.getParameter<double>("originRadius");
Expand Down Expand Up @@ -69,6 +73,9 @@ class HITRegionalPixelSeedGenerator : public TrackingRegionProducer {

double deltaZVertex = halflength;

auto const& bfield = es.getData(token_bfield);
auto const& msmaker = es.getData(token_msmaker);

if (usetracks_) {
edm::Handle<reco::TrackCollection> tracks;
e.getByToken(token_trks, tracks);
Expand All @@ -93,8 +100,15 @@ class HITRegionalPixelSeedGenerator : public TrackingRegionProducer {
GlobalVector ptrVec((itr)->px(), (itr)->py(), (itr)->pz());
globalVector = ptrVec;

result.push_back(std::make_unique<RectangularEtaPhiTrackingRegion>(
globalVector, GlobalPoint(0, 0, originz), ptmin, originradius, deltaZVertex, deltaTrackEta, deltaTrackPhi));
result.push_back(std::make_unique<RectangularEtaPhiTrackingRegion>(globalVector,
GlobalPoint(0, 0, originz),
ptmin,
originradius,
deltaZVertex,
deltaTrackEta,
deltaTrackPhi,
bfield,
&msmaker));
}
}

Expand Down Expand Up @@ -127,8 +141,15 @@ class HITRegionalPixelSeedGenerator : public TrackingRegionProducer {
(isoPixTrackRefs[p]->track())->pz());
globalVector = ptrVec;

result.push_back(std::make_unique<RectangularEtaPhiTrackingRegion>(
globalVector, GlobalPoint(0, 0, originz), ptmin, originradius, deltaZVertex, deltaTrackEta, deltaTrackPhi));
result.push_back(std::make_unique<RectangularEtaPhiTrackingRegion>(globalVector,
GlobalPoint(0, 0, originz),
ptmin,
originradius,
deltaZVertex,
deltaTrackEta,
deltaTrackPhi,
bfield,
&msmaker));
}
}

Expand All @@ -155,7 +176,7 @@ class HITRegionalPixelSeedGenerator : public TrackingRegionProducer {
GlobalPoint vertex(0, 0, originz);

result.push_back(std::make_unique<RectangularEtaPhiTrackingRegion>(
jetVector, vertex, ptmin, originradius, deltaZVertex, deltaL1JetEta, deltaL1JetPhi));
jetVector, vertex, ptmin, originradius, deltaZVertex, deltaL1JetEta, deltaL1JetPhi, bfield, &msmaker));
}
}
if (fixedReg_) {
Expand All @@ -175,15 +196,13 @@ class HITRegionalPixelSeedGenerator : public TrackingRegionProducer {
}

result.push_back(std::make_unique<RectangularEtaPhiTrackingRegion>(
fixedVector, vertex, ptmin, originradius, deltaZVertex, deltaL1JetEta, deltaL1JetPhi));
fixedVector, vertex, ptmin, originradius, deltaZVertex, deltaL1JetEta, deltaL1JetPhi, bfield, &msmaker));
}

return result;
}

private:
edm::ParameterSet conf_;

float ptmin;
float originradius;
float halflength;
Expand All @@ -201,6 +220,8 @@ class HITRegionalPixelSeedGenerator : public TrackingRegionProducer {
edm::EDGetTokenT<reco::VertexCollection> token_vertex;
edm::EDGetTokenT<trigger::TriggerFilterObjectWithRefs> token_isoTrack;
edm::EDGetTokenT<l1extra::L1JetParticleCollection> token_l1jet;
edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> token_bfield;
edm::ESGetToken<MultipleScatteringParametrisationMaker, TrackerMultipleScatteringRecord> token_msmaker;
};

#include "FWCore/PluginManager/interface/ModuleDef.h"
Expand Down
2 changes: 1 addition & 1 deletion FastSimulation/Muons/plugins/FastTSGFromL2Muon.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void FastTSGFromL2Muon::produce(edm::Event& ev, const edm::EventSetup& es) {
std::unique_ptr<L3MuonTrajectorySeedCollection> result(new L3MuonTrajectorySeedCollection());

// Region builder
theRegionBuilder->setEvent(ev);
theRegionBuilder->setEvent(ev, es);

// Retrieve the Monte Carlo truth (SimTracks)
edm::Handle<edm::SimTrackContainer> theSimTracks;
Expand Down
8 changes: 8 additions & 0 deletions FastSimulation/Tracking/interface/SeedFinderSelector.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ class MultiHitGeneratorFromPairAndLayers;
class HitTripletGeneratorFromPairAndLayers;
class CAHitTripletGenerator;
class CAHitQuadrupletGenerator;
class IdealMagneticFieldRecord;
class MagneticField;
class MultipleScatteringParametrisationMaker;
class TrackerMultipleScatteringRecord;

class SeedFinderSelector {
public:
Expand All @@ -45,7 +49,11 @@ class SeedFinderSelector {
const std::string measurementTrackerLabel_;
const edm::ESGetToken<MeasurementTracker, CkfComponentsRecord> measurementTrackerESToken_;
const edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> trackerTopologyESToken_;
const edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> fieldESToken_;
const edm::ESGetToken<MultipleScatteringParametrisationMaker, TrackerMultipleScatteringRecord> msMakerESToken_;
const TrackerTopology* trackerTopology_ = nullptr;
const MagneticField* field_ = nullptr;
const MultipleScatteringParametrisationMaker* msmaker_ = nullptr;
std::unique_ptr<CAHitTripletGenerator> CAHitTriplGenerator_;
std::unique_ptr<CAHitQuadrupletGenerator> CAHitQuadGenerator_;
std::unique_ptr<SeedingLayerSetsBuilder> seedingLayers_;
Expand Down
23 changes: 14 additions & 9 deletions FastSimulation/Tracking/src/SeedFinderSelector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include "RecoPixelVertexing/PixelTriplets/interface/CAHitQuadrupletGenerator.h"
#include "RecoPixelVertexing/PixelTriplets/interface/OrderedHitSeeds.h"
#include "RecoTracker/TkHitPairs/interface/IntermediateHitDoublets.h"
#include "RecoTracker/TkMSParametrization/interface/MultipleScatteringParametrisationMaker.h"
#include "RecoTracker/Record/interface/TrackerMultipleScatteringRecord.h"
// data formats
#include "DataFormats/TrackerRecHit2D/interface/FastTrackerRecHit.h"

Expand All @@ -26,7 +28,9 @@ SeedFinderSelector::SeedFinderSelector(const edm::ParameterSet &cfg, edm::Consum
measurementTracker_(nullptr),
measurementTrackerLabel_(cfg.getParameter<std::string>("measurementTracker")),
measurementTrackerESToken_(consumesCollector.esConsumes(edm::ESInputTag("", measurementTrackerLabel_))),
trackerTopologyESToken_(consumesCollector.esConsumes()) {
trackerTopologyESToken_(consumesCollector.esConsumes()),
fieldESToken_(consumesCollector.esConsumes()),
msMakerESToken_(consumesCollector.esConsumes()) {
if (cfg.exists("pixelTripletGeneratorFactory")) {
const edm::ParameterSet &tripletConfig = cfg.getParameter<edm::ParameterSet>("pixelTripletGeneratorFactory");
pixelTripletGenerator_ = HitTripletGeneratorFromPairAndLayersFactory::get()->create(
Expand Down Expand Up @@ -80,6 +84,8 @@ void SeedFinderSelector::initEvent(const edm::Event &ev, const edm::EventSetup &

measurementTracker_ = &es.getData(measurementTrackerESToken_);
trackerTopology_ = &es.getData(trackerTopologyESToken_);
field_ = &es.getData(fieldESToken_);
msmaker_ = &es.getData(msMakerESToken_);

if (multiHitGenerator_) {
multiHitGenerator_->initES(es);
Expand Down Expand Up @@ -124,7 +130,7 @@ bool SeedFinderSelector::pass(const std::vector<const FastTrackerRecHit *> &hits

HitDoublets result(fhm, shm);
HitPairGeneratorFromLayerPair::doublets(
*trackingRegion_, *firstLayer, *secondLayer, fhm, shm, *eventSetup_, 0, result);
*trackingRegion_, *firstLayer, *secondLayer, fhm, shm, *field_, *msmaker_, 0, result);

if (result.empty()) {
return false;
Expand All @@ -150,8 +156,7 @@ bool SeedFinderSelector::pass(const std::vector<const FastTrackerRecHit *> &hits
return !tripletresult.empty();
} else if (multiHitGenerator_) {
OrderedMultiHits tripletresult;
multiHitGenerator_->hitTriplets(
*trackingRegion_, tripletresult, *eventSetup_, result, &thmp, thirdLayerDetLayer, 1);
multiHitGenerator_->hitTriplets(*trackingRegion_, tripletresult, result, &thmp, thirdLayerDetLayer, 1);
return !tripletresult.empty();
}
//new for Phase1
Expand Down Expand Up @@ -209,13 +214,13 @@ bool SeedFinderSelector::pass(const std::vector<const FastTrackerRecHit *> &hits
pairCandidate1[1], std::make_unique<RecHitsSortedInPhi>(sHits, trackingRegion_->origin(), sLayer));
HitDoublets res1(firsthm, secondhm);
HitPairGeneratorFromLayerPair::doublets(
*trackingRegion_, *fLayer, *sLayer, firsthm, secondhm, *eventSetup_, 0, res1);
*trackingRegion_, *fLayer, *sLayer, firsthm, secondhm, *field_, *msmaker_, 0, res1);
filler.addDoublets(pairCandidate1, std::move(res1));
const RecHitsSortedInPhi &thirdhm = *layerCache.add(
pairCandidate2[1], std::make_unique<RecHitsSortedInPhi>(tHits, trackingRegion_->origin(), tLayer));
HitDoublets res2(secondhm, thirdhm);
HitPairGeneratorFromLayerPair::doublets(
*trackingRegion_, *sLayer, *tLayer, secondhm, thirdhm, *eventSetup_, 0, res2);
*trackingRegion_, *sLayer, *tLayer, secondhm, thirdhm, *field_, *msmaker_, 0, res2);
filler.addDoublets(pairCandidate2, std::move(res2));

std::vector<OrderedHitSeeds> tripletresult;
Expand Down Expand Up @@ -290,19 +295,19 @@ bool SeedFinderSelector::pass(const std::vector<const FastTrackerRecHit *> &hits
pairCandidate1[1], std::make_unique<RecHitsSortedInPhi>(sHits, trackingRegion_->origin(), sLayer));
HitDoublets res1(firsthm, secondhm);
HitPairGeneratorFromLayerPair::doublets(
*trackingRegion_, *fLayer, *sLayer, firsthm, secondhm, *eventSetup_, 0, res1);
*trackingRegion_, *fLayer, *sLayer, firsthm, secondhm, *field_, *msmaker_, 0, res1);
filler.addDoublets(pairCandidate1, std::move(res1));
const RecHitsSortedInPhi &thirdhm = *layerCache.add(
pairCandidate2[1], std::make_unique<RecHitsSortedInPhi>(tHits, trackingRegion_->origin(), tLayer));
HitDoublets res2(secondhm, thirdhm);
HitPairGeneratorFromLayerPair::doublets(
*trackingRegion_, *sLayer, *tLayer, secondhm, thirdhm, *eventSetup_, 0, res2);
*trackingRegion_, *sLayer, *tLayer, secondhm, thirdhm, *field_, *msmaker_, 0, res2);
filler.addDoublets(pairCandidate2, std::move(res2));
const RecHitsSortedInPhi &fourthhm = *layerCache.add(
pairCandidate3[1], std::make_unique<RecHitsSortedInPhi>(frHits, trackingRegion_->origin(), frLayer));
HitDoublets res3(thirdhm, fourthhm);
HitPairGeneratorFromLayerPair::doublets(
*trackingRegion_, *tLayer, *frLayer, thirdhm, fourthhm, *eventSetup_, 0, res3);
*trackingRegion_, *tLayer, *frLayer, thirdhm, fourthhm, *field_, *msmaker_, 0, res3);
filler.addDoublets(pairCandidate3, std::move(res3));

std::vector<OrderedHitSeeds> quadrupletresult;
Expand Down
21 changes: 17 additions & 4 deletions HLTrigger/btau/plugins/L3MumuTrackingRegion.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/ConsumesCollector.h"

#include "MagneticField/Engine/interface/MagneticField.h"
#include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
#include "RecoTracker/Record/interface/TrackerMultipleScatteringRecord.h"
#include "RecoTracker/TkMSParametrization/interface/MultipleScatteringParametrisationMaker.h"
#include "RecoTracker/TkTrackingRegions/interface/TrackingRegionProducer.h"
#include "RecoTracker/TkTrackingRegions/interface/GlobalTrackingRegion.h"
#include "RecoTracker/TkTrackingRegions/interface/RectangularEtaPhiTrackingRegion.h"
Expand All @@ -16,7 +20,8 @@

class L3MumuTrackingRegion : public TrackingRegionProducer {
public:
L3MumuTrackingRegion(const edm::ParameterSet& cfg, edm::ConsumesCollector&& iC) {
L3MumuTrackingRegion(const edm::ParameterSet& cfg, edm::ConsumesCollector&& iC)
: theFieldToken(iC.esConsumes()), theMSMakerToken(iC.esConsumes()) {
edm::ParameterSet regionPSet = cfg.getParameter<edm::ParameterSet>("RegionPSet");

theVertexTag = regionPSet.getParameter<edm::InputTag>("vertexSrc");
Expand Down Expand Up @@ -49,7 +54,7 @@ class L3MumuTrackingRegion : public TrackingRegionProducer {
}
}

~L3MumuTrackingRegion() override {}
~L3MumuTrackingRegion() override = default;

std::vector<std::unique_ptr<TrackingRegion> > regions(const edm::Event& ev,
const edm::EventSetup& es) const override {
Expand All @@ -61,6 +66,8 @@ class L3MumuTrackingRegion : public TrackingRegionProducer {
ev.getByToken(theMeasurementTrackerToken, hmte);
measurementTracker = hmte.product();
}
const auto& field = es.getData(theFieldToken);
const auto& msmaker = es.getData(theMSMakerToken);

// optional constraint for vertex
// get highest Pt pixel vertex (if existing)
Expand Down Expand Up @@ -89,8 +96,10 @@ class L3MumuTrackingRegion : public TrackingRegionProducer {
deltaZVertex,
theDeltaEta,
theDeltaPhi,
m_howToUseMeasurementTracker,
field,
&msmaker,
true,
m_howToUseMeasurementTracker,
measurementTracker,
m_searchOpt));
}
Expand All @@ -110,8 +119,10 @@ class L3MumuTrackingRegion : public TrackingRegionProducer {
deltaZVertex,
theDeltaEta,
theDeltaPhi,
m_howToUseMeasurementTracker,
field,
&msmaker,
true,
m_howToUseMeasurementTracker,
measurementTracker,
m_searchOpt));
}
Expand All @@ -136,6 +147,8 @@ class L3MumuTrackingRegion : public TrackingRegionProducer {
double theDeltaPhi;
edm::EDGetTokenT<MeasurementTrackerEvent> theMeasurementTrackerToken;
RectangularEtaPhiTrackingRegion::UseMeasurementTracker m_howToUseMeasurementTracker;
edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> theFieldToken;
edm::ESGetToken<MultipleScatteringParametrisationMaker, TrackerMultipleScatteringRecord> theMSMakerToken;
bool m_searchOpt;
};

Expand Down
Loading

0 comments on commit ec53ab6

Please sign in to comment.