Skip to content

Commit

Permalink
Merge pull request cms-sw#35347 from Dr15Jones/esConsumesSeedGenerato…
Browse files Browse the repository at this point in the history
…rFromProtoTracksEDProducer

Added esConsumes to SeedFromProtoTrack
  • Loading branch information
cmsbuild authored Sep 24, 2021
2 parents 60b7869 + 2bca9a9 commit ac2754c
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 27 deletions.
7 changes: 3 additions & 4 deletions RecoMuon/TrackerSeedGenerator/plugins/TSGFromL1Muon.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include "DataFormats/TrackReco/interface/Track.h"
#include "DataFormats/TrackReco/interface/TrackFwd.h"

#include "RecoTracker/TkSeedGenerator/interface/SeedFromProtoTrack.h"
#include "DataFormats/TrajectorySeed/interface/TrajectorySeedCollection.h"

#include <vector>
Expand All @@ -39,7 +38,7 @@ namespace {
}
} // namespace

TSGFromL1Muon::TSGFromL1Muon(const edm::ParameterSet& cfg) {
TSGFromL1Muon::TSGFromL1Muon(const edm::ParameterSet& cfg) : theSFPTConfig(consumesCollector()) {
produces<L3MuonTrajectorySeedCollection>();
theSourceTag = cfg.getParameter<edm::InputTag>("L1MuonLabel");

Expand All @@ -55,7 +54,7 @@ TSGFromL1Muon::TSGFromL1Muon(const edm::ParameterSet& cfg) {
theRegionProducer = std::make_unique<L1MuonRegionProducer>(cfg.getParameter<edm::ParameterSet>("RegionFactoryPSet"));
theFitter = std::make_unique<L1MuonPixelTrackFitter>(cfg.getParameter<edm::ParameterSet>("FitterPSet"));

edm::ParameterSet cleanerPSet = theConfig.getParameter<edm::ParameterSet>("CleanerPSet");
edm::ParameterSet cleanerPSet = cfg.getParameter<edm::ParameterSet>("CleanerPSet");
theMerger = std::make_unique<L1MuonSeedsMerger>(cleanerPSet);
}

Expand Down Expand Up @@ -114,7 +113,7 @@ void TSGFromL1Muon::produce(edm::Event& ev, const edm::EventSetup& es) {
if (theMerger)
theMerger->resolve(tracks);
for (L1MuonSeedsMerger::TracksAndHits::const_iterator it = tracks.begin(); it != tracks.end(); ++it) {
SeedFromProtoTrack seed(*(it->first), it->second, es);
SeedFromProtoTrack seed(theSFPTConfig, *(it->first), it->second, es);
if (seed.isValid())
(*result).push_back(L3MuonTrajectorySeed(seed.trajectorySeed(), l1Ref));

Expand Down
3 changes: 2 additions & 1 deletion RecoMuon/TrackerSeedGenerator/plugins/TSGFromL1Muon.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#include "FWCore/Framework/interface/stream/EDProducer.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "RecoTracker/TkSeedGenerator/interface/SeedFromProtoTrack.h"
#include "DataFormats/L1Trigger/interface/L1MuonParticle.h"
#include "DataFormats/L1Trigger/interface/L1MuonParticleFwd.h"

Expand All @@ -30,10 +31,10 @@ class TSGFromL1Muon : public edm::stream::EDProducer<> {

private:
private:
edm::ParameterSet theConfig;
edm::InputTag theSourceTag;
edm::EDGetTokenT<l1extra::L1MuonParticleCollection> theSourceToken;
edm::EDGetTokenT<PixelTrackFilter> theFilterToken;
const SeedFromProtoTrack::Config theSFPTConfig;

std::unique_ptr<L1MuonRegionProducer> theRegionProducer;
std::unique_ptr<OrderedHitsGenerator> theHitGenerator;
Expand Down
25 changes: 21 additions & 4 deletions RecoTracker/TkSeedGenerator/interface/SeedFromProtoTrack.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,35 @@
#include "DataFormats/TrackingRecHit/interface/TrackingRecHit.h"
#include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h"
#include "RecoTracker/TkSeedingLayers/interface/SeedingHitSet.h"
#include "FWCore/Utilities/interface/ESGetToken.h"

namespace reco {
class Track;
}
namespace edm {
class EventSetup;
}
class ConsumesCollector;
} // namespace edm

class TrackerGeometry;
class TrackerDigiGeometryRecord;
class Propagator;
class TrackingComponentsRecord;
class MagneticField;
class IdealMagneticFieldRecord;

class SeedFromProtoTrack {
public:
SeedFromProtoTrack(const reco::Track& proto, const edm::EventSetup&);
SeedFromProtoTrack(const reco::Track& proto, const SeedingHitSet& hits, const edm::EventSetup& es);
struct Config {
Config(edm::ConsumesCollector);

const edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> trackerToken_;
const edm::ESGetToken<Propagator, TrackingComponentsRecord> propagatorToken_;
const edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> fieldToken_;
};

SeedFromProtoTrack(const Config&, const reco::Track& proto, const edm::EventSetup&);
SeedFromProtoTrack(const Config&, const reco::Track& proto, const SeedingHitSet& hits, const edm::EventSetup& es);

~SeedFromProtoTrack() {}

Expand All @@ -25,7 +42,7 @@ class SeedFromProtoTrack {
bool isValid() const { return theValid; }

private:
void init(const reco::Track& proto, const edm::EventSetup& es);
void init(const Config&, const reco::Track& proto, const edm::EventSetup& es);

PropagationDirection direction() const { return alongMomentum; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include "DataFormats/VertexReco/interface/Vertex.h"
#include "DataFormats/TrajectorySeed/interface/TrajectorySeedCollection.h"

#include "RecoTracker/TkSeedGenerator/interface/SeedFromProtoTrack.h"
#include "RecoTracker/TkSeedingLayers/interface/SeedingHitSet.h"
#include "TrackingTools/TransientTrackingRecHit/interface/TransientTrackingRecHitBuilder.h"
#include "TrackingTools/Records/interface/TransientRecHitRecord.h"
Expand Down Expand Up @@ -72,7 +71,8 @@ SeedGeneratorFromProtoTracksEDProducer::SeedGeneratorFromProtoTracksEDProducer(c
theInputCollectionTag(consumes<reco::TrackCollection>(cfg.getParameter<InputTag>("InputCollection"))),
theInputVertexCollectionTag(
consumes<reco::VertexCollection>(cfg.getParameter<InputTag>("InputVertexCollection"))),
seedCreator_(cfg.getParameter<edm::ParameterSet>("SeedCreatorPSet"), consumesCollector()) {
seedCreator_(cfg.getParameter<edm::ParameterSet>("SeedCreatorPSet"), consumesCollector()),
config_(consumesCollector()) {
produces<TrajectorySeedCollection>();
}

Expand Down Expand Up @@ -122,7 +122,7 @@ void SeedGeneratorFromProtoTracksEDProducer::produce(edm::Event& ev, const edm::
continue;

if (useProtoTrackKinematics) {
SeedFromProtoTrack seedFromProtoTrack(proto, es);
SeedFromProtoTrack seedFromProtoTrack(config_, proto, es);
if (seedFromProtoTrack.isValid())
(*result).push_back(seedFromProtoTrack.trajectorySeed());
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "FWCore/Framework/interface/FrameworkfwdMostUsed.h"
#include "DataFormats/TrackReco/interface/TrackFwd.h"
#include "DataFormats/VertexReco/interface/VertexFwd.h"
#include "RecoTracker/TkSeedGenerator/interface/SeedFromProtoTrack.h"
#include "SeedFromConsecutiveHitsCreator.h"

#include <string>
Expand All @@ -27,5 +28,6 @@ class dso_hidden SeedGeneratorFromProtoTracksEDProducer : public edm::stream::ED
const edm::EDGetTokenT<reco::TrackCollection> theInputCollectionTag;
const edm::EDGetTokenT<reco::VertexCollection> theInputVertexCollectionTag;
SeedFromConsecutiveHitsCreator seedCreator_;
const SeedFromProtoTrack::Config config_;
};
#endif
36 changes: 21 additions & 15 deletions RecoTracker/TkSeedGenerator/src/SeedFromProtoTrack.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/ConsumesCollector.h"

#include "Geometry/CommonDetUnit/interface/GeomDet.h"
#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
Expand All @@ -18,40 +19,45 @@

#include "FWCore/MessageLogger/interface/MessageLogger.h"

SeedFromProtoTrack::SeedFromProtoTrack(const reco::Track& proto, const SeedingHitSet& hits, const edm::EventSetup& es)
SeedFromProtoTrack::Config::Config(edm::ConsumesCollector iC)
: trackerToken_(iC.esConsumes()),
propagatorToken_(iC.esConsumes(edm::ESInputTag("", "PropagatorWithMaterial"))),
fieldToken_(iC.esConsumes()) {}

SeedFromProtoTrack::SeedFromProtoTrack(const Config& config,
const reco::Track& proto,
const SeedingHitSet& hits,
const edm::EventSetup& es)
: theValid(true) {
for (unsigned int i = 0, n = hits.size(); i < n; ++i) {
const TrackingRecHit* trh = hits[i]->hit();
theHits.push_back(trh->clone());
}
init(proto, es);
init(config, proto, es);
}

SeedFromProtoTrack::SeedFromProtoTrack(const reco::Track& proto, const edm::EventSetup& es) : theValid(true) {
SeedFromProtoTrack::SeedFromProtoTrack(const Config& config, const reco::Track& proto, const edm::EventSetup& es)
: theValid(true) {
const TrackingRecHit* hit = nullptr;
for (unsigned int iHit = 0, nHits = proto.recHitsSize(); iHit < nHits; ++iHit) {
TrackingRecHitRef refHit = proto.recHit(iHit);
hit = &(*refHit);
theHits.push_back(hit->clone());
}
init(proto, es);
init(config, proto, es);
}

void SeedFromProtoTrack::init(const reco::Track& proto, const edm::EventSetup& es) {
edm::ESHandle<TrackerGeometry> tracker;
es.get<TrackerDigiGeometryRecord>().get(tracker);
void SeedFromProtoTrack::init(const Config& config, const reco::Track& proto, const edm::EventSetup& es) {
TrackerGeometry const& tracker = es.getData(config.trackerToken_);

edm::ESHandle<Propagator> propagatorHandle;
es.get<TrackingComponentsRecord>().get("PropagatorWithMaterial", propagatorHandle);
const Propagator* propagator = &(*propagatorHandle);
const Propagator* propagator = &es.getData(config.propagatorToken_);

edm::ESHandle<MagneticField> field;
es.get<IdealMagneticFieldRecord>().get(field); //fixme
const MagneticField* field = &es.getData(config.fieldToken_);

const reco::TrackBase::Point& vtx = proto.referencePoint();
const reco::TrackBase::Vector& mom = proto.momentum();
GlobalTrajectoryParameters gtp(
GlobalPoint(vtx.x(), vtx.y(), vtx.z()), GlobalVector(mom.x(), mom.y(), mom.z()), proto.charge(), &(*field));
GlobalPoint(vtx.x(), vtx.y(), vtx.z()), GlobalVector(mom.x(), mom.y(), mom.z()), proto.charge(), field);

CurvilinearTrajectoryError err = proto.covariance();

Expand All @@ -60,10 +66,10 @@ void SeedFromProtoTrack::init(const reco::Track& proto, const edm::EventSetup& e
const TrackingRecHit& lastHit = theHits.back();

TrajectoryStateOnSurface outerState =
propagator->propagate(fts, tracker->idToDet(lastHit.geographicalId())->surface());
propagator->propagate(fts, tracker.idToDet(lastHit.geographicalId())->surface());

if (!outerState.isValid()) {
const Surface& surface = tracker->idToDet(lastHit.geographicalId())->surface();
const Surface& surface = tracker.idToDet(lastHit.geographicalId())->surface();
edm::LogError("SeedFromProtoTrack") << " was trying to create a seed from:\n"
<< fts << "\n propagating to: " << std::hex << lastHit.geographicalId().rawId()
<< std::dec << ' ' << surface.position();
Expand Down

0 comments on commit ac2754c

Please sign in to comment.