CMS 3D CMS Logo

TSGForOIFromL2.cc
Go to the documentation of this file.
1 
11 
12 #include <memory>
13 
15  : src_(consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("src"))),
16  maxSeeds_(iConfig.getParameter<uint32_t>("maxSeeds")),
17  maxHitlessSeeds_(iConfig.getParameter<uint32_t>("maxHitlessSeeds")),
18  maxHitSeeds_(iConfig.getParameter<uint32_t>("maxHitSeeds")),
19  numOfLayersToTry_(iConfig.getParameter<int32_t>("layersToTry")),
20  numOfHitsToTry_(iConfig.getParameter<int32_t>("hitsToTry")),
21  numL2ValidHitsCutAllEta_(iConfig.getParameter<uint32_t>("numL2ValidHitsCutAllEta")),
22  numL2ValidHitsCutAllEndcap_(iConfig.getParameter<uint32_t>("numL2ValidHitsCutAllEndcap")),
23  fixedErrorRescalingForHits_(iConfig.getParameter<double>("fixedErrorRescaleFactorForHits")),
24  fixedErrorRescalingForHitless_(iConfig.getParameter<double>("fixedErrorRescaleFactorForHitless")),
25  adjustErrorsDynamicallyForHits_(iConfig.getParameter<bool>("adjustErrorsDynamicallyForHits")),
26  adjustErrorsDynamicallyForHitless_(iConfig.getParameter<bool>("adjustErrorsDynamicallyForHitless")),
27  estimatorName_(iConfig.getParameter<std::string>("estimator")),
28  minEtaForTEC_(iConfig.getParameter<double>("minEtaForTEC")),
29  maxEtaForTOB_(iConfig.getParameter<double>("maxEtaForTOB")),
30  useHitLessSeeds_(iConfig.getParameter<bool>("UseHitLessSeeds")),
31  updator_(new KFUpdator()),
32  measurementTrackerTag_(
33  consumes<MeasurementTrackerEvent>(iConfig.getParameter<edm::InputTag>("MeasurementTrackerEvent"))),
34  pT1_(iConfig.getParameter<double>("pT1")),
35  pT2_(iConfig.getParameter<double>("pT2")),
36  pT3_(iConfig.getParameter<double>("pT3")),
37  eta1_(iConfig.getParameter<double>("eta1")),
38  eta2_(iConfig.getParameter<double>("eta2")),
39  eta3_(iConfig.getParameter<double>("eta3")),
40  eta4_(iConfig.getParameter<double>("eta4")),
41  eta5_(iConfig.getParameter<double>("eta5")),
42  eta6_(iConfig.getParameter<double>("eta6")),
43  eta7_(iConfig.getParameter<double>("eta7")),
44  SF1_(iConfig.getParameter<double>("SF1")),
45  SF2_(iConfig.getParameter<double>("SF2")),
46  SF3_(iConfig.getParameter<double>("SF3")),
47  SF4_(iConfig.getParameter<double>("SF4")),
48  SF5_(iConfig.getParameter<double>("SF5")),
49  SF6_(iConfig.getParameter<double>("SF6")),
50  SFHld_(iConfig.getParameter<double>("SFHld")),
51  SFHd_(iConfig.getParameter<double>("SFHd")),
52  tsosDiff1_(iConfig.getParameter<double>("tsosDiff1")),
53  tsosDiff2_(iConfig.getParameter<double>("tsosDiff2")),
54  displacedReco_(iConfig.getParameter<bool>("displacedReco")),
55  propagatorName_(iConfig.getParameter<std::string>("propagatorName")),
56  theCategory_(std::string("Muon|RecoMuon|TSGForOIFromL2")),
57  estimatorToken_(esConsumes(edm::ESInputTag("", estimatorName_))),
58  magfieldToken_(esConsumes()),
59  propagatorToken_(esConsumes(edm::ESInputTag("", propagatorName_))),
60  tmpTkGeometryToken_(esConsumes()),
61  geometryToken_(esConsumes()),
62  sHPOppositeToken_(esConsumes(edm::ESInputTag("", "hltESPSteppingHelixPropagatorOpposite"))) {
63  produces<std::vector<TrajectorySeed> >();
64 }
65 
67 
68 //
69 // Produce seeds
70 //
72  // Initialize variables
73  unsigned int numSeedsMade = 0;
74  unsigned int layerCount = 0;
75  unsigned int hitlessSeedsMadeIP = 0;
76  unsigned int hitlessSeedsMadeMuS = 0;
77  unsigned int hitSeedsMade = 0;
78  unsigned int hitSeedsMadeMuS = 0;
79 
80  // Surface used to make a TSOS at the PCA to the beamline
82 
83  // Read ESHandles
84  edm::Handle<MeasurementTrackerEvent> measurementTrackerH;
86  const edm::ESHandle<MagneticField> magfieldH = iSetup.getHandle(magfieldToken_);
87  const edm::ESHandle<Propagator> propagatorAlongH = iSetup.getHandle(propagatorToken_);
88  const edm::ESHandle<Propagator>& propagatorOppositeH = propagatorAlongH;
89  const edm::ESHandle<TrackerGeometry> tmpTkGeometryH = iSetup.getHandle(tmpTkGeometryToken_);
91 
92  iEvent.getByToken(measurementTrackerTag_, measurementTrackerH);
93 
94  // Read L2 track collection
96  iEvent.getByToken(src_, l2TrackCol);
97 
98  // The product
99  std::unique_ptr<std::vector<TrajectorySeed> > result(new std::vector<TrajectorySeed>());
100 
101  // Get vector of Detector layers
102  std::vector<BarrelDetLayer const*> const& tob = measurementTrackerH->geometricSearchTracker()->tobLayers();
103  std::vector<ForwardDetLayer const*> const& tecPositive =
104  tmpTkGeometryH->isThere(GeomDetEnumerators::P2OTEC)
105  ? measurementTrackerH->geometricSearchTracker()->posTidLayers()
106  : measurementTrackerH->geometricSearchTracker()->posTecLayers();
107  std::vector<ForwardDetLayer const*> const& tecNegative =
108  tmpTkGeometryH->isThere(GeomDetEnumerators::P2OTEC)
109  ? measurementTrackerH->geometricSearchTracker()->negTidLayers()
110  : measurementTrackerH->geometricSearchTracker()->negTecLayers();
111 
112  // Get suitable propagators
113  std::unique_ptr<Propagator> propagatorAlong = SetPropagationDirection(*propagatorAlongH, alongMomentum);
114  std::unique_ptr<Propagator> propagatorOpposite = SetPropagationDirection(*propagatorOppositeH, oppositeToMomentum);
115 
116  // Stepping Helix Propagator for propogation from muon system to tracker
117  const edm::ESHandle<Propagator> SHPOpposite = iSetup.getHandle(sHPOppositeToken_);
118 
119  // Loop over the L2's and make seeds for all of them
120  LogTrace(theCategory_) << "TSGForOIFromL2::produce: Number of L2's: " << l2TrackCol->size();
121  for (unsigned int l2TrackColIndex(0); l2TrackColIndex != l2TrackCol->size(); ++l2TrackColIndex) {
122  const reco::TrackRef l2(l2TrackCol, l2TrackColIndex);
123 
124  // Container of Seeds
125  std::vector<TrajectorySeed> out;
126  LogTrace("TSGForOIFromL2") << "TSGForOIFromL2::produce: L2 muon pT, eta, phi --> " << l2->pt() << " , " << l2->eta()
127  << " , " << l2->phi() << std::endl;
128 
130 
131  dummyPlane->move(fts.position() - dummyPlane->position());
132  TrajectoryStateOnSurface tsosAtIP = TrajectoryStateOnSurface(fts, *dummyPlane);
133  LogTrace("TSGForOIFromL2") << "TSGForOIFromL2::produce: Created TSOSatIP: " << tsosAtIP << std::endl;
134 
135  // Get the TSOS on the innermost layer of the L2
136  TrajectoryStateOnSurface tsosAtMuonSystem =
137  trajectoryStateTransform::innerStateOnSurface(*l2, *geometryH, magfieldH.product());
138  LogTrace("TSGForOIFromL2") << "TSGForOIFromL2::produce: Created TSOSatMuonSystem: " << tsosAtMuonSystem
139  << std::endl;
140 
141  LogTrace("TSGForOIFromL2")
142  << "TSGForOIFromL2::produce: Check the error of the L2 parameter and use hit seeds if big errors" << std::endl;
143 
144  StateOnTrackerBound fromInside(propagatorAlong.get());
145  TrajectoryStateOnSurface outerTkStateInside = fromInside(fts);
146 
147  StateOnTrackerBound fromOutside(&*SHPOpposite);
148  TrajectoryStateOnSurface outerTkStateOutside = fromOutside(tsosAtMuonSystem);
149 
150  // Check if the two positions (using updated and not-updated TSOS) agree withing certain extent.
151  // If both TSOSs agree, use only the one at vertex, as it uses more information. If they do not agree, search for seeds based on both.
152  double L2muonEta = l2->eta();
153  double absL2muonEta = std::abs(L2muonEta);
154  bool useBoth = false;
155  if (outerTkStateInside.isValid() && outerTkStateOutside.isValid()) {
156  //following commented out variables dist1 (5 par compatibility of tsos at outertracker surface)
157  //dist2 (angle between two tsos) could further be explored in combination of L2 valid hits for seeding. So kept for
158  //future developers
159  //auto dist1 = match_Chi2(outerTkStateInside,outerTkStateOutside);//for future developers
160  //auto dist2 = deltaR(outerTkStateInside.globalMomentum(),outerTkStateOutside.globalMomentum());//for future developers
161  //if ((dist1 > tsosDiff1_ || dist2 > tsosDiff2_) && l2->numberOfValidHits() < 20) useBoth = true;//for future developers
162  if (l2->numberOfValidHits() < numL2ValidHitsCutAllEta_)
163  useBoth = true;
164  if (l2->numberOfValidHits() < numL2ValidHitsCutAllEndcap_ && absL2muonEta > eta7_)
165  useBoth = true;
166  if (absL2muonEta > eta1_ && absL2muonEta < eta1_)
167  useBoth = true;
168  }
169 
170  numSeedsMade = 0;
171  hitlessSeedsMadeIP = 0;
172  hitlessSeedsMadeMuS = 0;
173  hitSeedsMade = 0;
174  hitSeedsMadeMuS = 0;
175 
176  // calculate scale factors
178  double errorSFHitless =
180 
181  // BARREL
182  if (absL2muonEta < maxEtaForTOB_) {
183  layerCount = 0;
184  for (auto it = tob.rbegin(); it != tob.rend(); ++it) {
185  LogTrace("TSGForOIFromL2") << "TSGForOIFromL2::produce: looping in TOB layer " << layerCount << std::endl;
186  if (useHitLessSeeds_ && hitlessSeedsMadeIP < maxHitlessSeeds_ && numSeedsMade < maxSeeds_)
188  tsosAtIP,
189  *(propagatorAlong.get()),
190  estimatorH,
191  errorSFHitless,
192  hitlessSeedsMadeIP,
193  numSeedsMade,
194  out);
195 
196  // Do not create hitbased seeds in barrel region
197  if (absL2muonEta > 1.0 && hitSeedsMade < maxHitSeeds_ && numSeedsMade < maxSeeds_)
198  makeSeedsFromHits(**it,
199  tsosAtIP,
200  *(propagatorAlong.get()),
201  estimatorH,
202  measurementTrackerH,
203  errorSFHits,
204  hitSeedsMade,
205  numSeedsMade,
206  layerCount,
207  out);
208 
209  if (useBoth && !displacedReco_) {
210  if (useHitLessSeeds_ && hitlessSeedsMadeMuS < maxHitlessSeeds_ && numSeedsMade < maxSeeds_)
212  outerTkStateOutside,
213  *(propagatorOpposite.get()),
214  estimatorH,
215  errorSFHitless,
216  hitlessSeedsMadeMuS,
217  numSeedsMade,
218  out);
219  }
220  }
221  LogTrace("TSGForOIFromL2") << "TSGForOIFromL2:::produce: NumSeedsMade = " << numSeedsMade
222  << " , layerCount = " << layerCount << std::endl;
223  }
224 
225  // Reset number of seeds if in overlap region
226  if (absL2muonEta > minEtaForTEC_ && absL2muonEta < maxEtaForTOB_ && !displacedReco_) {
227  numSeedsMade = 0;
228  hitlessSeedsMadeIP = 0;
229  hitlessSeedsMadeMuS = 0;
230  hitSeedsMade = 0;
231  }
232 
233  // ENDCAP+
234  if (L2muonEta > minEtaForTEC_) {
235  layerCount = 0;
236  for (auto it = tecPositive.rbegin(); it != tecPositive.rend(); ++it) {
237  LogTrace("TSGForOIFromL2") << "TSGForOIFromL2::produce: looping in TEC+ layer " << layerCount << std::endl;
238  if (useHitLessSeeds_ && hitlessSeedsMadeIP < maxHitlessSeeds_ && numSeedsMade < maxSeeds_)
240  tsosAtIP,
241  *(propagatorAlong.get()),
242  estimatorH,
243  errorSFHitless,
244  hitlessSeedsMadeIP,
245  numSeedsMade,
246  out);
247 
248  if (absL2muonEta > 1.0 && hitSeedsMade < maxHitSeeds_ && numSeedsMade < maxSeeds_)
249  makeSeedsFromHits(**it,
250  tsosAtIP,
251  *(propagatorAlong.get()),
252  estimatorH,
253  measurementTrackerH,
254  errorSFHits,
255  hitSeedsMade,
256  numSeedsMade,
257  layerCount,
258  out);
259 
260  if (useBoth && !displacedReco_) {
261  if (useHitLessSeeds_ && hitlessSeedsMadeMuS < maxHitlessSeeds_ && numSeedsMade < maxSeeds_)
263  outerTkStateOutside,
264  *(propagatorOpposite.get()),
265  estimatorH,
266  errorSFHitless,
267  hitlessSeedsMadeMuS,
268  numSeedsMade,
269  out);
270  }
271  }
272  LogTrace("TSGForOIFromL2") << "TSGForOIFromL2:::produce: NumSeedsMade = " << numSeedsMade
273  << " , layerCount = " << layerCount << std::endl;
274  }
275 
276  // ENDCAP-
277  if (L2muonEta < -minEtaForTEC_) {
278  layerCount = 0;
279  for (auto it = tecNegative.rbegin(); it != tecNegative.rend(); ++it) {
280  LogTrace("TSGForOIFromL2") << "TSGForOIFromL2::produce: looping in TEC- layer " << layerCount << std::endl;
281  if (useHitLessSeeds_ && hitlessSeedsMadeIP < maxHitlessSeeds_ && numSeedsMade < maxSeeds_)
283  tsosAtIP,
284  *(propagatorAlong.get()),
285  estimatorH,
286  errorSFHitless,
287  hitlessSeedsMadeIP,
288  numSeedsMade,
289  out);
290 
291  if (absL2muonEta > 1.0 && hitSeedsMade < maxHitSeeds_ && numSeedsMade < maxSeeds_)
292  makeSeedsFromHits(**it,
293  tsosAtIP,
294  *(propagatorAlong.get()),
295  estimatorH,
296  measurementTrackerH,
297  errorSFHits,
298  hitSeedsMade,
299  numSeedsMade,
300  layerCount,
301  out);
302 
303  if (useBoth && !displacedReco_) {
304  if (useHitLessSeeds_ && hitlessSeedsMadeMuS < maxHitlessSeeds_ && numSeedsMade < maxSeeds_)
306  outerTkStateOutside,
307  *(propagatorOpposite.get()),
308  estimatorH,
309  errorSFHitless,
310  hitlessSeedsMadeMuS,
311  numSeedsMade,
312  out);
313  }
314  }
315  LogTrace("TSGForOIFromL2") << "TSGForOIFromL2:::produce: NumSeedsMade = " << numSeedsMade
316  << " , layerCount = " << layerCount << std::endl;
317  }
318 
319  // Displaced Reconstruction
320  if (displacedReco_ && outerTkStateOutside.isValid()) {
321  layerCount = 0;
322  for (auto it = tob.rbegin(); it != tob.rend(); ++it) {
323  LogTrace("TSGForOIFromL2") << "TSGForOIFromL2::produce: looping in TOB layer " << layerCount;
324  if (useHitLessSeeds_ && hitlessSeedsMadeMuS < maxHitlessSeeds_ && numSeedsMade < maxSeeds_)
326  outerTkStateOutside,
327  *(propagatorOpposite.get()),
328  estimatorH,
329  errorSFHitless * SFHld_,
330  hitlessSeedsMadeMuS,
331  numSeedsMade,
332  out);
333  if (hitSeedsMadeMuS < maxHitSeeds_ && numSeedsMade < maxSeeds_)
334  makeSeedsFromHits(**it,
335  outerTkStateOutside,
336  *(propagatorOpposite.get()),
337  estimatorH,
338  measurementTrackerH,
339  errorSFHits * SFHd_,
340  hitSeedsMadeMuS,
341  numSeedsMade,
342  layerCount,
343  out);
344  }
345  LogTrace("TSGForOIFromL2") << "TSGForOIFromL2:::produce: NumSeedsMade = " << numSeedsMade
346  << " , layerCount = " << layerCount;
347  if (L2muonEta >= 0.0) {
348  layerCount = 0;
349  for (auto it = tecPositive.rbegin(); it != tecPositive.rend(); ++it) {
350  LogTrace("TSGForOIFromL2") << "TSGForOIFromL2::produce: looping in TEC+ layer " << layerCount << std::endl;
351  if (useHitLessSeeds_ && hitlessSeedsMadeMuS < maxHitlessSeeds_ && numSeedsMade < maxSeeds_)
353  outerTkStateOutside,
354  *(propagatorOpposite.get()),
355  estimatorH,
356  errorSFHitless * SFHld_,
357  hitlessSeedsMadeMuS,
358  numSeedsMade,
359  out);
360  if (hitSeedsMadeMuS < maxHitSeeds_ && numSeedsMade < maxSeeds_)
361  makeSeedsFromHits(**it,
362  outerTkStateOutside,
363  *(propagatorOpposite.get()),
364  estimatorH,
365  measurementTrackerH,
366  errorSFHits * SFHd_,
367  hitSeedsMadeMuS,
368  numSeedsMade,
369  layerCount,
370  out);
371  }
372  LogTrace("TSGForOIFromL2") << "TSGForOIFromL2:::produce: NumSeedsMade = " << numSeedsMade
373  << " , layerCount = " << layerCount;
374  }
375 
376  else {
377  layerCount = 0;
378  for (auto it = tecNegative.rbegin(); it != tecNegative.rend(); ++it) {
379  LogTrace("TSGForOIFromL2") << "TSGForOIFromL2::produce: looping in TEC- layer " << layerCount;
380  if (useHitLessSeeds_ && hitlessSeedsMadeMuS < maxHitlessSeeds_ && numSeedsMade < maxSeeds_)
382  outerTkStateOutside,
383  *(propagatorOpposite.get()),
384  estimatorH,
385  errorSFHitless * SFHld_,
386  hitlessSeedsMadeMuS,
387  numSeedsMade,
388  out);
389  if (hitSeedsMadeMuS < maxHitSeeds_ && numSeedsMade < maxSeeds_)
390  makeSeedsFromHits(**it,
391  outerTkStateOutside,
392  *(propagatorOpposite.get()),
393  estimatorH,
394  measurementTrackerH,
395  errorSFHits * SFHd_,
396  hitSeedsMadeMuS,
397  numSeedsMade,
398  layerCount,
399  out);
400  }
401  LogTrace("TSGForOIFromL2") << "TSGForOIFromL2:::produce: NumSeedsMade = " << numSeedsMade
402  << " , layerCount = " << layerCount;
403  }
404  }
405 
406  for (std::vector<TrajectorySeed>::iterator it = out.begin(); it != out.end(); ++it) {
407  result->push_back(*it);
408  }
409 
410  } // L2Collection
411 
412  edm::LogInfo(theCategory_) << "TSGForOIFromL2::produce: number of seeds made: " << result->size();
413 
414  iEvent.put(std::move(result));
415 }
416 
417 //
418 // Create seeds without hits on a given layer (TOB or TEC)
419 //
421  const TrajectoryStateOnSurface& tsos,
424  double errorSF,
425  unsigned int& hitlessSeedsMade,
426  unsigned int& numSeedsMade,
427  std::vector<TrajectorySeed>& out) const {
428  // create hitless seeds
429  LogTrace("TSGForOIFromL2") << "TSGForOIFromL2::makeSeedsWithoutHits: Start hitless" << std::endl;
430  std::vector<GeometricSearchDet::DetWithState> dets;
431  layer.compatibleDetsV(tsos, propagatorAlong, *estimator, dets);
432  if (!dets.empty()) {
433  auto const& detOnLayer = dets.front().first;
434  auto const& tsosOnLayer = dets.front().second;
435  LogTrace("TSGForOIFromL2") << "TSGForOIFromL2::makeSeedsWithoutHits: tsosOnLayer " << tsosOnLayer << std::endl;
436  if (!tsosOnLayer.isValid()) {
437  edm::LogInfo(theCategory_) << "ERROR!: Hitless TSOS is not valid!";
438  } else {
439  dets.front().second.rescaleError(errorSF);
440  PTrajectoryStateOnDet const& ptsod =
441  trajectoryStateTransform::persistentState(tsosOnLayer, detOnLayer->geographicalId().rawId());
443  out.push_back(TrajectorySeed(ptsod, rHC, oppositeToMomentum));
444  LogTrace("TSGForOIFromL2") << "TSGForOIFromL2::makeSeedsWithoutHits: TSOS (Hitless) done " << std::endl;
445  hitlessSeedsMade++;
446  numSeedsMade++;
447  }
448  }
449 }
450 
451 //
452 // Find hits on a given layer (TOB or TEC) and create seeds from updated TSOS with hit
453 //
455  const TrajectoryStateOnSurface& tsos,
459  double errorSF,
460  unsigned int& hitSeedsMade,
461  unsigned int& numSeedsMade,
462  unsigned int& layerCount,
463  std::vector<TrajectorySeed>& out) const {
464  if (layerCount > numOfLayersToTry_)
465  return;
466 
467  // Error Rescaling
468  TrajectoryStateOnSurface onLayer(tsos);
469  onLayer.rescaleError(errorSF);
470 
471  std::vector<GeometricSearchDet::DetWithState> dets;
472  layer.compatibleDetsV(onLayer, propagatorAlong, *estimator, dets);
473 
474  // Find Measurements on each DetWithState
475  LogTrace("TSGForOIFromL2") << "TSGForOIFromL2::makeSeedsFromHits: Find measurements on each detWithState "
476  << dets.size() << std::endl;
477  std::vector<TrajectoryMeasurement> meas;
478  for (std::vector<GeometricSearchDet::DetWithState>::iterator it = dets.begin(); it != dets.end(); ++it) {
479  MeasurementDetWithData det = measurementTracker->idToDet(it->first->geographicalId());
480  if (det.isNull())
481  continue;
482  if (!it->second.isValid())
483  continue; // Skip if TSOS is not valid
484 
485  std::vector<TrajectoryMeasurement> mymeas =
486  det.fastMeasurements(it->second, onLayer, propagatorAlong, *estimator); // Second TSOS is not used
487  for (std::vector<TrajectoryMeasurement>::const_iterator it2 = mymeas.begin(), ed2 = mymeas.end(); it2 != ed2;
488  ++it2) {
489  if (it2->recHit()->isValid())
490  meas.push_back(*it2); // Only save those which are valid
491  }
492  }
493 
494  // Update TSOS using TMs after sorting, then create Trajectory Seed and put into vector
495  LogTrace("TSGForOIFromL2") << "TSGForOIFromL2::makeSeedsFromHits: Update TSOS using TMs after sorting, then create "
496  "Trajectory Seed, number of TM = "
497  << meas.size() << std::endl;
498  std::sort(meas.begin(), meas.end(), TrajMeasLessEstim());
499 
500  unsigned int found = 0;
501  for (std::vector<TrajectoryMeasurement>::const_iterator it = meas.begin(); it != meas.end(); ++it) {
502  TrajectoryStateOnSurface updatedTSOS = updator_->update(it->forwardPredictedState(), *it->recHit());
503  LogTrace("TSGForOIFromL2") << "TSGForOIFromL2::makeSeedsFromHits: TSOS for TM " << found << std::endl;
504  if (not updatedTSOS.isValid())
505  continue;
506 
508  seedHits.push_back(*it->recHit()->hit());
509  PTrajectoryStateOnDet const& pstate =
510  trajectoryStateTransform::persistentState(updatedTSOS, it->recHit()->geographicalId().rawId());
511  LogTrace("TSGForOIFromL2") << "TSGForOIFromL2::makeSeedsFromHits: Number of seedHits: " << seedHits.size()
512  << std::endl;
513  TrajectorySeed seed(pstate, std::move(seedHits), oppositeToMomentum);
514  out.push_back(seed);
515  found++;
516  numSeedsMade++;
517  hitSeedsMade++;
518  if (found == numOfHitsToTry_)
519  break;
520  if (hitSeedsMade > maxHitSeeds_)
521  return;
522  }
523 
524  if (found)
525  layerCount++;
526 }
527 
528 //
529 // Calculate the dynamic error SF by analysing the L2
530 //
532  double theSF = 1.0;
533  // L2 direction vs pT blowup - as was previously done:
534  // Split into 4 pT ranges: <pT1_, pT1_<pT2_, pT2_<pT3_, <pT4_: 13,30,70
535  // Split into different eta ranges depending in pT
536  double abseta = std::abs(track->eta());
537  if (track->pt() <= pT1_)
538  theSF = SF1_;
539  else if (track->pt() > pT1_ && track->pt() <= pT2_) {
540  if (abseta <= eta3_)
541  theSF = SF3_;
542  else if (abseta > eta3_ && abseta <= eta6_)
543  theSF = SF2_;
544  else if (abseta > eta6_)
545  theSF = SF3_;
546  } else if (track->pt() > pT2_ && track->pt() <= pT3_) {
547  if (abseta <= eta1_)
548  theSF = SF6_;
549  else if (abseta > eta1_ && abseta <= eta2_)
550  theSF = SF4_;
551  else if (abseta > eta2_ && abseta <= eta3_)
552  theSF = SF6_;
553  else if (abseta > eta3_ && abseta <= eta4_)
554  theSF = SF1_;
555  else if (abseta > eta4_ && abseta <= eta5_)
556  theSF = SF1_;
557  else if (abseta > eta5_)
558  theSF = SF5_;
559  } else if (track->pt() > pT3_) {
560  if (abseta <= eta3_)
561  theSF = SF5_;
562  else if (abseta > eta3_ && abseta <= eta4_)
563  theSF = SF4_;
564  else if (abseta > eta4_ && abseta <= eta5_)
565  theSF = SF4_;
566  else if (abseta > eta5_)
567  theSF = SF5_;
568  }
569 
570  LogTrace(theCategory_) << "TSGForOIFromL2::calculateSFFromL2: SF has been calculated as: " << theSF;
571 
572  return theSF;
573 }
574 
575 //
576 // calculate Chi^2 of two trajectory states
577 //
579  if (!tsos1.isValid() || !tsos2.isValid())
580  return -1.;
581 
583  AlgebraicSymMatrix55 m(tsos1.localError().matrix() + tsos2.localError().matrix());
584 
585  bool ierr = !m.Invert();
586 
587  if (ierr) {
588  edm::LogInfo("TSGForOIFromL2") << "Error inverting covariance matrix";
589  return -1;
590  }
591 
592  double est = ROOT::Math::Similarity(v, m);
593 
594  return est;
595 }
596 
597 //
598 //
599 //
602  desc.add<edm::InputTag>("src", edm::InputTag("hltL2Muons", "UpdatedAtVtx"));
603  desc.add<int>("layersToTry", 2);
604  desc.add<double>("fixedErrorRescaleFactorForHitless", 2.0);
605  desc.add<int>("hitsToTry", 1);
606  desc.add<bool>("adjustErrorsDynamicallyForHits", false);
607  desc.add<bool>("adjustErrorsDynamicallyForHitless", true);
608  desc.add<edm::InputTag>("MeasurementTrackerEvent", edm::InputTag("hltSiStripClusters"));
609  desc.add<bool>("UseHitLessSeeds", true);
610  desc.add<std::string>("estimator", "hltESPChi2MeasurementEstimator100");
611  desc.add<double>("maxEtaForTOB", 1.8);
612  desc.add<double>("minEtaForTEC", 0.7);
613  desc.addUntracked<bool>("debug", false);
614  desc.add<double>("fixedErrorRescaleFactorForHits", 1.0);
615  desc.add<unsigned int>("maxSeeds", 20);
616  desc.add<unsigned int>("maxHitlessSeeds", 5);
617  desc.add<unsigned int>("maxHitSeeds", 1);
618  desc.add<unsigned int>("numL2ValidHitsCutAllEta", 20);
619  desc.add<unsigned int>("numL2ValidHitsCutAllEndcap", 30);
620  desc.add<double>("pT1", 13.0);
621  desc.add<double>("pT2", 30.0);
622  desc.add<double>("pT3", 70.0);
623  desc.add<double>("eta1", 0.2);
624  desc.add<double>("eta2", 0.3);
625  desc.add<double>("eta3", 1.0);
626  desc.add<double>("eta4", 1.2);
627  desc.add<double>("eta5", 1.6);
628  desc.add<double>("eta6", 1.4);
629  desc.add<double>("eta7", 2.1);
630  desc.add<double>("SF1", 3.0);
631  desc.add<double>("SF2", 4.0);
632  desc.add<double>("SF3", 5.0);
633  desc.add<double>("SF4", 7.0);
634  desc.add<double>("SF5", 10.0);
635  desc.add<double>("SF6", 2.0);
636  desc.add<double>("SFHld", 2.0)->setComment("Scale Factor used to rescale the TSOS error of the hitless seeds");
637  desc.add<double>("SFHd", 4.0)->setComment("Scale Factor used to rescale the TSOS error of the hit based seeds");
638  desc.add<double>("tsosDiff1", 0.2);
639  desc.add<double>("tsosDiff2", 0.02);
640  desc.add<bool>("displacedReco", false)->setComment("Flag to turn on the displaced seeding");
641  desc.add<std::string>("propagatorName", "PropagatorWithMaterialParabolicMf");
642  descriptions.add("TSGForOIFromL2", desc);
643 }
644 
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const bool useHitLessSeeds_
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
std::vector< ForwardDetLayer const * > const & posTecLayers() const
TSGForOIFromL2(const edm::ParameterSet &iConfig)
const double eta2_
const LocalTrajectoryError & localError() const
std::vector< TrajectoryMeasurement > fastMeasurements(const TrajectoryStateOnSurface &stateOnThisDet, const TrajectoryStateOnSurface &tsos2, const Propagator &prop, const MeasurementEstimator &est) const
const unsigned int numOfHitsToTry_
How many hits to try per layer.
const double SFHd_
const double minEtaForTEC_
Minimum eta value to activate searching in the TEC.
const double SFHld_
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
PTrajectoryStateOnDet persistentState(const TrajectoryStateOnSurface &ts, unsigned int detid)
const unsigned int maxHitSeeds_
Maximum number of hitbased seeds for each L2.
const LocalTrajectoryParameters & localParameters() const
double calculateSFFromL2(const reco::TrackRef track) const
Calculate the dynamic error SF by analysing the L2.
const double SF2_
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magfieldToken_
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > tmpTkGeometryToken_
const edm::ESGetToken< GlobalTrackingGeometry, GlobalTrackingGeometryRecord > geometryToken_
double match_Chi2(const TrajectoryStateOnSurface &tsos1, const TrajectoryStateOnSurface &tsos2) const
Find compatability between two TSOSs.
#define LogTrace(id)
static PlanePointer build(Args &&... args)
Definition: Plane.h:33
GlobalPoint position() const
const edm::ESGetToken< Chi2MeasurementEstimatorBase, TrackingComponentsRecord > estimatorToken_
const unsigned int maxHitlessSeeds_
Maximum number of hitless seeds for each L2.
std::unique_ptr< Propagator > SetPropagationDirection(Propagator const &iprop, PropagationDirection dir)
void push_back(D *&d)
Definition: OwnVector.h:326
const double pT2_
const double SF6_
int iEvent
Definition: GenABIO.cc:224
T const * product() const
Definition: ESHandle.h:86
const double eta7_
bool isThere(GeomDetEnumerators::SubDetector subdet) const
const edm::ESGetToken< Propagator, TrackingComponentsRecord > propagatorToken_
const unsigned int numL2ValidHitsCutAllEndcap_
AlgebraicVector5 vector() const
size_type size() const
Definition: OwnVector.h:300
void produce(edm::StreamID sid, edm::Event &iEvent, const edm::EventSetup &iSetup) const override
const unsigned int maxSeeds_
Maximum number of seeds for each L2.
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
ROOT::Math::SVector< double, 5 > AlgebraicVector5
const double eta1_
void makeSeedsWithoutHits(const GeometricSearchDet &layer, const TrajectoryStateOnSurface &tsos, const Propagator &propagatorAlong, const edm::ESHandle< Chi2MeasurementEstimatorBase > &estimator, double errorSF, unsigned int &hitlessSeedsMade, unsigned int &numSeedsMade, std::vector< TrajectorySeed > &out) const
Create seeds without hits on a given layer (TOB or TEC)
const std::unique_ptr< TrajectoryStateUpdator > updator_
KFUpdator defined in constructor.
const double SF3_
const double fixedErrorRescalingForHits_
Rescale L2 parameter uncertainties (fixed error vs pT, eta)
const double maxEtaForTOB_
Maximum eta value to activate searching in the TOB.
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
const bool adjustErrorsDynamicallyForHits_
Whether or not to use an automatically calculated scale-factor value.
const std::string theCategory_
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:130
const edm::EDGetTokenT< MeasurementTrackerEvent > measurementTrackerTag_
const unsigned int numL2ValidHitsCutAllEta_
L2 valid hit cuts to decide seed creation by both states.
~TSGForOIFromL2() override
std::vector< ForwardDetLayer const * > const & negTidLayers() const
Log< level::Info, false > LogInfo
const double eta6_
std::vector< ForwardDetLayer const * > const & posTidLayers() const
const double eta5_
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
void add(std::string const &label, ParameterSetDescription const &psetDescription)
const double SF4_
const GeometricSearchTracker * geometricSearchTracker() const
const edm::EDGetTokenT< reco::TrackCollection > src_
Labels for input collections.
fixed size matrix
HLT enums.
const double eta3_
const double eta4_
std::vector< BarrelDetLayer const * > const & tobLayers() const
const bool adjustErrorsDynamicallyForHitless_
const edm::ESGetToken< Propagator, TrackingComponentsRecord > sHPOppositeToken_
const AlgebraicSymMatrix55 & matrix() const
const bool displacedReco_
Displaced reconstruction.
std::vector< ForwardDetLayer const * > const & negTecLayers() const
FreeTrajectoryState initialFreeState(const reco::Track &tk, const MagneticField *field, bool withErr=true)
Create L3MuonTrajectorySeeds from L2 Muons updated at vertex in an outside-in manner.
void makeSeedsFromHits(const GeometricSearchDet &layer, const TrajectoryStateOnSurface &tsos, const Propagator &propagatorAlong, const edm::ESHandle< Chi2MeasurementEstimatorBase > &estimator, const edm::Handle< MeasurementTrackerEvent > &measurementTracker, double errorSF, unsigned int &hitSeedsMade, unsigned int &numSeedsMade, unsigned int &layerCount, std::vector< TrajectorySeed > &out) const
Find hits on a given layer (TOB or TEC) and create seeds from updated TSOS with hit.
const double SF5_
const unsigned int numOfLayersToTry_
How many layers to try.
const double SF1_
def move(src, dest)
Definition: eostools.py:511
const double pT3_
const double pT1_
pT, eta ranges and scale factor values
TrajectoryStateOnSurface innerStateOnSurface(const reco::Track &tk, const TrackingGeometry &geom, const MagneticField *field, bool withErr=true)
const double fixedErrorRescalingForHitless_