CMS 3D CMS Logo

SeedGeneratorFromL1TTracksEDProducer.cc
Go to the documentation of this file.
8 
16 
21 
24 
30 
32 #include <vector>
33 
35 public:
37  ~SeedGeneratorFromL1TTracksEDProducer() override = default;
38 
39  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
40 
41  void findSeedsOnLayer(const GeometricSearchDet& layer,
42  const TrajectoryStateOnSurface& tsosAtIP,
46  unsigned int& numSeedsMade,
47  std::unique_ptr<std::vector<TrajectorySeed>>& out) const;
48 
49  void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
50 
51 private:
54 
55  // Minimum eta value to activate searching in the TEC
56  const double theMinEtaForTEC_;
57 
58  // Maximum eta value to activate searching in the TOB
59  const double theMaxEtaForTOB_;
60 
61  const double theErrorSFHitless_;
62 
68 };
69 
71  : theInputCollectionTag_(
72  consumes<std::vector<TTTrack<Ref_Phase2TrackerDigi_>>>(cfg.getParameter<edm::InputTag>("InputCollection"))),
73  theMeasurementTrackerTag_(
74  consumes<MeasurementTrackerEvent>(cfg.getParameter<edm::InputTag>("MeasurementTrackerEvent"))),
75  theMinEtaForTEC_(cfg.getParameter<double>("minEtaForTEC")),
76  theMaxEtaForTOB_(cfg.getParameter<double>("maxEtaForTOB")),
77  theErrorSFHitless_(cfg.getParameter<double>("errorSFHitless")),
78  mfToken_{esConsumes<MagneticField, IdealMagneticFieldRecord>()},
79  geomToken_{esConsumes<TrackerGeometry, TrackerDigiGeometryRecord>()},
80  estToken_{esConsumes<Chi2MeasurementEstimatorBase, TrackingComponentsRecord>(
81  edm::ESInputTag("", cfg.getParameter<std::string>("estimator")))},
82  propagatorAlongToken_{esConsumes<Propagator, TrackingComponentsRecord>(
83  edm::ESInputTag("", cfg.getParameter<std::string>("propagator")))},
84  propagatorOppositeToken_{esConsumes<Propagator, TrackingComponentsRecord>(
85  edm::ESInputTag("", cfg.getParameter<std::string>("propagator")))} {
86  produces<TrajectorySeedCollection>();
87 }
88 
91  desc.add<edm::InputTag>("InputCollection", {"TTTracksFromTrackletEmulation", "Level1TTTracks"});
92  desc.add<std::string>("estimator", "");
93  desc.add<std::string>("propagator", "");
94  desc.add<edm::InputTag>("MeasurementTrackerEvent", {""});
95  desc.add<double>("minEtaForTEC", 0.9);
96  desc.add<double>("maxEtaForTOB", 1.2);
97  desc.add<double>("errorSFHitless", 1e-9);
98  descriptions.addWithDefaultLabel(desc);
99 }
100 
102  const TrajectoryStateOnSurface& tsosAtIP,
106  unsigned int& numSeedsMade,
107  std::unique_ptr<std::vector<TrajectorySeed>>& out) const {
108  std::vector<GeometricSearchDet::DetWithState> dets;
109  layer.compatibleDetsV(tsosAtIP, propagatorAlong, estimator, dets);
110 
111  if (!dets.empty()) {
112  auto const& detOnLayer = dets.front().first;
113  auto const& tsosOnLayer = dets.front().second;
114  if (!tsosOnLayer.isValid()) {
115  LogDebug("SeedGeneratorFromL1TTracks") << "Hitless TSOS is not valid!";
116  } else {
117  dets.front().second.rescaleError(theErrorSFHitless_);
118 
119  PTrajectoryStateOnDet const& ptsod =
120  trajectoryStateTransform::persistentState(tsosOnLayer, detOnLayer->geographicalId().rawId());
122  if (numSeedsMade < 1) { // only outermost seed
123  out->emplace_back(ptsod, rHC, oppositeToMomentum);
124  numSeedsMade++;
125  }
126  }
127  }
128 }
129 
131  std::unique_ptr<std::vector<TrajectorySeed>> result(new std::vector<TrajectorySeed>());
132 
133  // TTrack Collection
134  auto const& trks = ev.get(theInputCollectionTag_);
135 
136  // Trk Geometry
137  const auto& geom = es.getData(geomToken_);
138 
139  // Mag field
140  const auto& mag = es.getData(mfToken_);
141 
142  // Estimator
143  auto const& estimator = es.getData(estToken_);
144 
145  // Get Propagators
146  const auto& propagatorAlongH = es.getData(propagatorAlongToken_);
147  std::unique_ptr<Propagator> propagatorAlong = SetPropagationDirection(propagatorAlongH, alongMomentum);
148 
149  const auto& propagatorOppositeH = es.getData(propagatorOppositeToken_);
150  std::unique_ptr<Propagator> propagatorOpposite = SetPropagationDirection(propagatorOppositeH, oppositeToMomentum);
151 
152  // Get vector of Detector layers
154  std::vector<BarrelDetLayer const*> const& tob = measurementTracker.geometricSearchTracker()->tobLayers();
155 
156  std::vector<ForwardDetLayer const*> const& tecPositive =
157  geom.isThere(GeomDetEnumerators::P2OTEC) ? measurementTracker.geometricSearchTracker()->posTidLayers()
158  : measurementTracker.geometricSearchTracker()->posTecLayers();
159  std::vector<ForwardDetLayer const*> const& tecNegative =
160  geom.isThere(GeomDetEnumerators::P2OTEC) ? measurementTracker.geometricSearchTracker()->negTidLayers()
161  : measurementTracker.geometricSearchTracker()->negTecLayers();
162 
165 
166  // Loop over the L1's and make seeds for all of them:
167  for (auto const& l1 : trks) {
168  std::unique_ptr<std::vector<TrajectorySeed>> out(new std::vector<TrajectorySeed>());
170  dummyPlane->move(fts.position() - dummyPlane->position());
171  TrajectoryStateOnSurface tsosAtIP = TrajectoryStateOnSurface(fts, *dummyPlane);
172 
173  unsigned int numSeedsMade = 0;
174  //BARREL
175  if (std::abs(l1.momentum().eta()) < theMaxEtaForTOB_) {
176  for (auto it = tob.rbegin(); it != tob.rend(); ++it) { //This goes from outermost to innermost layer
177  findSeedsOnLayer(**it, tsosAtIP, *(propagatorAlong.get()), l1, estimator, numSeedsMade, out);
178  }
179  }
180  if (std::abs(l1.momentum().eta()) > theMinEtaForTEC_) {
181  numSeedsMade = 0; // reset num of seeds
182  }
183  //ENDCAP+
184  if (l1.momentum().eta() > theMinEtaForTEC_) {
185  for (auto it = tecPositive.rbegin(); it != tecPositive.rend(); ++it) {
186  findSeedsOnLayer(**it, tsosAtIP, *(propagatorAlong.get()), l1, estimator, numSeedsMade, out);
187  }
188  }
189  //ENDCAP-
190  if (l1.momentum().eta() < -theMinEtaForTEC_) {
191  for (auto it = tecNegative.rbegin(); it != tecNegative.rend(); ++it) {
192  findSeedsOnLayer(**it, tsosAtIP, *(propagatorAlong.get()), l1, estimator, numSeedsMade, out);
193  }
194  }
195  std::copy(out->begin(), out->end(), std::back_inserter(*result));
196  } // end loop over L1Tracks
197 
198  ev.put(std::move(result));
199 }
200 
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
const edm::EDGetTokenT< std::vector< TTTrack< Ref_Phase2TrackerDigi_ > > > theInputCollectionTag_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
PTrajectoryStateOnDet persistentState(const TrajectoryStateOnSurface &ts, unsigned int detid)
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > geomToken_
void findSeedsOnLayer(const GeometricSearchDet &layer, const TrajectoryStateOnSurface &tsosAtIP, Propagator &propagatorAlong, const TTTrack< Ref_Phase2TrackerDigi_ > &l1, const MeasurementEstimator &estimator, unsigned int &numSeedsMade, std::unique_ptr< std::vector< TrajectorySeed >> &out) const
std::unique_ptr< T, impl::DeviceDeleter > unique_ptr
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
constexpr std::array< uint8_t, layerIndexSize > layer
static PlanePointer build(Args &&... args)
Definition: Plane.h:33
GlobalPoint position() const
std::unique_ptr< Propagator > SetPropagationDirection(Propagator const &iprop, PropagationDirection dir)
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > mfToken_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
bool getData(T &iHolder) const
Definition: EventSetup.h:122
static void fillDescriptions(ConfigurationDescriptions &descriptions)
#define dso_hidden
Definition: Visibility.h:12
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
Class to store the L1 Track Trigger tracks.
Definition: TTTrack.h:29
const edm::ESGetToken< Chi2MeasurementEstimatorBase, TrackingComponentsRecord > estToken_
virtual void produce(StreamID, Event &, EventSetup const &) const =0
const edm::ESGetToken< Propagator, TrackingComponentsRecord > propagatorOppositeToken_
FreeTrajectoryState initialFreeStateL1TTrack(const TTTrack< Ref_Phase2TrackerDigi_ > &tk, const MagneticField *field, bool withErr=false)
HLT enums.
const edm::ESGetToken< Propagator, TrackingComponentsRecord > propagatorAlongToken_
SeedGeneratorFromL1TTracksEDProducer(const edm::ParameterSet &cfg)
def move(src, dest)
Definition: eostools.py:511
const edm::EDGetTokenT< MeasurementTrackerEvent > theMeasurementTrackerTag_
#define LogDebug(id)