CMS 3D CMS Logo

GroupedCkfTrajectoryBuilder.cc
Go to the documentation of this file.
1 #include <algorithm>
2 #include <array>
3 
6 
9 
13 #include "GroupedTrajCandLess.h"
25 
34 
36 
37 // only included for RecHit comparison operator:
39 
41 
42 // for looper reconstruction
46 
48 
49 // #define STAT_TSB
50 
51 namespace {
52 #ifdef STAT_TSB
53  struct StatCount {
54  long long totSeed;
55  long long totTraj;
56  long long totRebuilt;
57  long long totInvCand;
58  void zero() { totSeed = totTraj = totRebuilt = totInvCand = 0; }
59  void traj(long long t) { totTraj += t; }
60  void seed() { ++totSeed; }
61  void rebuilt(long long t) { totRebuilt += t; }
62  void invalid() { ++totInvCand; }
63  void print() const {
64  std::cout << "GroupedCkfTrajectoryBuilder stat\nSeed/Traj/Rebuilt " << totSeed << '/' << totTraj << '/'
65  << totRebuilt << std::endl;
66  }
67  StatCount() { zero(); }
68  ~StatCount() { print(); }
69  };
70  StatCount statCount;
71 
72 #else
73  struct StatCount {
74  void traj(long long) {}
75  void seed() {}
76  void rebuilt(long long) {}
77  void invalid() {}
78  };
79  CMS_THREAD_SAFE StatCount statCount;
80 #endif
81 
82 } // namespace
83 
84 using namespace std;
85 
86 //#define DBG2_GCTB
87 
88 //#define STANDARD_INTERMEDIARYCLEAN
89 
90 #ifdef STANDARD_INTERMEDIARYCLEAN
92 #endif
93 
94 /* ====== B.M. to be ported layer ===========
95 #ifdef DBG_GCTB
96 #include "RecoTracker/CkfPattern/src/ShowCand.h"
97 #endif
98 // #define DBG2_GCTB
99 #ifdef DBG2_GCTB
100 #include "RecoTracker/CkfPattern/src/SimIdPrinter.h"
101 #include "Tracker/TkDebugTools/interface/LayerFinderByDet.h"
102 #include "Tracker/TkLayout/interface/TkLayerName.h"
103 #endif
104 =================================== */
105 
106 namespace {
107 
109 
110 }
111 
114  BaseCkfTrajectoryBuilder::createTrajectoryFilter(
115  conf.getParameter<edm::ParameterSet>("trajectoryFilter"), iC),
116  conf.getParameter<bool>("useSameTrajFilter")
117  ? BaseCkfTrajectoryBuilder::createTrajectoryFilter(
118  conf.getParameter<edm::ParameterSet>("trajectoryFilter"), iC)
119  : BaseCkfTrajectoryBuilder::createTrajectoryFilter(
120  conf.getParameter<edm::ParameterSet>("inOutTrajectoryFilter"), iC)) {
121  // fill data members from parameters (eventually data members could be dropped)
122  //
123  theMaxCand = conf.getParameter<int>("maxCand");
124  theLostHitPenalty = conf.getParameter<double>("lostHitPenalty");
125  theFoundHitBonus = conf.getParameter<double>("foundHitBonus");
126  theIntermediateCleaning = conf.getParameter<bool>("intermediateCleaning");
127  theAlwaysUseInvalid = conf.getParameter<bool>("alwaysUseInvalidHits");
128  theLockHits = conf.getParameter<bool>("lockHits");
129  theBestHitOnly = conf.getParameter<bool>("bestHitOnly");
131  theRequireSeedHitsInRebuild = conf.getParameter<bool>("requireSeedHitsInRebuild");
132  theKeepOriginalIfRebuildFails = conf.getParameter<bool>("keepOriginalIfRebuildFails");
133  theMinNrOfHitsForRebuild = max(0, conf.getParameter<int>("minNrOfHitsForRebuild"));
134  maxPt2ForLooperReconstruction = conf.existsAs<double>("maxPtForLooperReconstruction")
135  ? conf.getParameter<double>("maxPtForLooperReconstruction")
136  : 0;
138  maxDPhiForLooperReconstruction = conf.existsAs<double>("maxDPhiForLooperReconstruction")
139  ? conf.getParameter<double>("maxDPhiForLooperReconstruction")
140  : 2.0;
141 
142  /* ======= B.M. to be ported layer ===========
143  bool setOK = thePropagator->setMaxDirectionChange(1.6);
144  if (!setOK)
145  cout << "GroupedCkfTrajectoryBuilder WARNING: "
146  << "propagator does not support setMaxDirectionChange"
147  << endl;
148  // addStopCondition(theMinPtStopCondition);
149 
150  theConfigurableCondition = createAlgo<TrajectoryFilter>(componentConfig("StopCondition"));
151  ===================================== */
152 }
153 
154 /*
155  void GroupedCkfTrajectoryBuilder::setEvent(const edm::Event& event) const
156  {
157  theMeasurementTracker->update(event);
158 }
159 */
160 
162 
164  const TrajectorySeed& seed) const {
166  ret.reserve(10);
167  unsigned int tmp;
168  buildTrajectories(seed, ret, tmp, nullptr);
169  return ret;
170 }
171 
173  const TrajectorySeed& seed, const TrackingRegion& region) const {
175  ret.reserve(10);
176  unsigned int tmp;
177  RegionalTrajectoryFilter regionalCondition(region);
178  buildTrajectories(seed, ret, tmp, &regionalCondition);
179  return ret;
180 }
181 
184  unsigned int tmp;
185  buildTrajectories(seed, ret, tmp, nullptr);
186 }
187 
190  const TrackingRegion& region) const {
191  RegionalTrajectoryFilter regionalCondition(region);
192  unsigned int tmp;
193  buildTrajectories(seed, ret, tmp, &regionalCondition);
194 }
195 
197  TempTrajectory const& startingTraj = createStartingTrajectory(seed);
198  rebuildTrajectories(startingTraj, seed, result);
199 }
200 
202  const TrajectorySeed& seed,
203  TrajectoryContainer& result) const {
205 
206  TrajectoryContainer final;
207 
208  // better the seed to be always the same...
209  std::shared_ptr<const TrajectorySeed> sharedSeed;
210  if (result.empty())
211  sharedSeed.reset(new TrajectorySeed(seed));
212  else
213  sharedSeed = result.front().sharedSeed();
214 
215  work.reserve(result.size());
216  for (auto&& traj : result)
217  if (traj.isValid())
218  work.emplace_back(std::move(traj));
219 
220  rebuildSeedingRegion(seed, startingTraj, work);
221 
222  // we clean here now
224  cleaner.clean(work);
225 
226  for (auto const& it : work)
227  if (it.isValid()) {
228  final.push_back(it.toTrajectory());
229  final.back().setSharedSeed(sharedSeed);
230  }
231 
232  result.swap(final);
233 
234  statCount.rebuilt(result.size());
235 }
236 
239  unsigned int& nCandPerSeed,
240  const TrajectoryFilter* regionalCondition) const {
241  if (theMeasurementTracker == nullptr) {
242  throw cms::Exception("LogicError")
243  << "Asking to create trajectories to an un-initialized GroupedCkfTrajectoryBuilder.\nYou have to call "
244  "clone(const MeasurementTrackerEvent *data) and then call trajectories on it instead.\n";
245  }
246 
247  statCount.seed();
248  //
249  // Build trajectory outwards from seed
250  //
251 
252  analyseSeed(seed);
253 
254  TempTrajectory const& startingTraj = createStartingTrajectory(seed);
255 
256  work_.clear();
257  const bool inOut = true;
258  nCandPerSeed = groupedLimitedCandidates(seed, startingTraj, regionalCondition, forwardPropagator(seed), inOut, work_);
259  if (work_.empty())
260  return startingTraj;
261 
262  // cleaning now done here...
264  cleaner.clean(work_);
265 
266  std::shared_ptr<const TrajectorySeed> pseed(new TrajectorySeed(seed));
267  for (auto const& it : work_)
268  if (it.isValid()) {
269  result.push_back(it.toTrajectory());
270  result.back().setSharedSeed(pseed);
271  }
272  work_.clear();
273  if (work_.capacity() > work_MaxSize_) {
274  TempTrajectoryContainer().swap(work_);
275  work_.reserve(work_MaxSize_ / 2);
276  }
277 
278  analyseResult(result);
279 
280  LogDebug("CkfPattern") << "GroupedCkfTrajectoryBuilder: returning result of size " << result.size();
281  statCount.traj(result.size());
282 
283 #ifdef VI_DEBUG
284  int kt = 0;
285  for (auto const& traj : result) {
286  int chit[7] = {};
287  for (auto const& tm : traj.measurements()) {
288  auto const& hit = tm.recHitR();
289  if (!hit.isValid())
290  ++chit[0];
291  if (hit.det() == nullptr)
292  ++chit[1];
294  continue;
295  if (hit.dimension() != 2) {
296  ++chit[2];
297  } else if (trackerHitRTTI::isFromDet(hit)) {
298  auto const& thit = static_cast<BaseTrackerRecHit const&>(hit);
299  auto const& clus = thit.firstClusterRef();
300  if (clus.isPixel())
301  ++chit[3];
302  else if (thit.isMatched()) {
303  ++chit[4];
304  } else if (thit.isProjected()) {
305  ++chit[5];
306  } else {
307  ++chit[6];
308  }
309  }
310  }
311 
312  std::cout << "ckf " << kt++ << ": ";
313  for (auto c : chit)
314  std::cout << c << '/';
315  std::cout << std::endl;
316  }
317 #endif
318 
319  return startingTraj;
320 }
321 
322 unsigned int GroupedCkfTrajectoryBuilder::groupedLimitedCandidates(const TrajectorySeed& seed,
323  TempTrajectory const& startingTraj,
324  const TrajectoryFilter* regionalCondition,
325  const Propagator* propagator,
326  bool inOut,
327  TempTrajectoryContainer& result) const {
328  unsigned int nIter = 1;
329  unsigned int nCands = 0; // ignore startingTraj
330  unsigned int prevNewCandSize = 0;
332  TempTrajectoryContainer newCand;
333  candidates.push_back(startingTraj);
334 
335  while (!candidates.empty()) {
336  newCand.clear();
337  for (TempTrajectoryContainer::iterator traj = candidates.begin(); traj != candidates.end(); traj++) {
338  if (!advanceOneLayer(seed, *traj, regionalCondition, propagator, inOut, newCand, result)) {
339  LogDebug("CkfPattern") << "GCTB: terminating after advanceOneLayer==false";
340  continue;
341  }
342 
343  LogDebug("CkfPattern") << "newCand(1): after advanced one layer:\n" << PrintoutHelper::dumpCandidates(newCand);
344  // account only new candidates, i.e.
345  // - 1 candidate -> 1 candidate, don't increase count
346  // - 1 candidate -> 2 candidates, increase count by 1
347  nCands += newCand.size() - prevNewCandSize;
348  prevNewCandSize = newCand.size();
349 
350  if ((int)newCand.size() > theMaxCand) {
351  //ShowCand()(newCand);
352 
353  std::nth_element(newCand.begin(),
354  newCand.begin() + theMaxCand,
355  newCand.end(),
357  newCand.erase(newCand.begin() + theMaxCand, newCand.end());
358  }
359  LogDebug("CkfPattern") << "newCand(2): after removing extra candidates.\n"
360  << PrintoutHelper::dumpCandidates(newCand);
361  }
362 
363  LogDebug("CkfPattern") << "newCand.size() at end = " << newCand.size();
364  /*
365  if (theIntermediateCleaning) {
366  candidates.clear();
367  candidates = groupedIntermediaryClean(newCand);
368  } else {
369  candidates.swap(newCand);
370  }
371 */
373 #ifdef STANDARD_INTERMEDIARYCLEAN
375 #else
376  groupedIntermediaryClean(newCand);
377 #endif
378  }
379  candidates.swap(newCand);
380 
381  LogDebug("CkfPattern") << "candidates(3): " << result.size() << " candidates after " << nIter++
382  << " groupedCKF iteration: \n"
383  << PrintoutHelper::dumpCandidates(result) << "\n " << candidates.size()
384  << " running candidates are: \n"
386  }
387 
388  return nCands;
389 }
390 
391 #ifdef EDM_ML_DEBUG
392 std::string whatIsTheNextStep(TempTrajectory const& traj,
393  std::pair<TrajectoryStateOnSurface, std::vector<const DetLayer*> >& stateAndLayers) {
394  std::stringstream buffer;
395  vector<const DetLayer*>& nl = stateAndLayers.second;
396  // #include "TrackingTools/DetLayers/interface/BarrelDetLayer.h"
397  // #include "TrackingTools/DetLayers/interface/ForwardDetLayer.h"
398  //B.M. TkLayerName layerName;
399  //B.M. buffer << "Started from " << layerName(traj.lastLayer())
400  const BarrelDetLayer* sbdl = dynamic_cast<const BarrelDetLayer*>(traj.lastLayer());
401  const ForwardDetLayer* sfdl = dynamic_cast<const ForwardDetLayer*>(traj.lastLayer());
402  if (sbdl) {
403  buffer << "Started from " << traj.lastLayer() << " r=" << sbdl->specificSurface().radius()
404  << " phi=" << sbdl->specificSurface().phi() << endl;
405  } else if (sfdl) {
406  buffer << "Started from " << traj.lastLayer() << " z " << sfdl->specificSurface().position().z() << " phi "
407  << sfdl->specificSurface().phi() << endl;
408  }
409  buffer << "Trying to go to";
410  for (vector<const DetLayer*>::iterator il = nl.begin(); il != nl.end(); il++) {
411  //B.M. buffer << " " << layerName(*il) << " " << *il << endl;
412  const BarrelDetLayer* bdl = dynamic_cast<const BarrelDetLayer*>(*il);
413  const ForwardDetLayer* fdl = dynamic_cast<const ForwardDetLayer*>(*il);
414 
415  if (bdl)
416  buffer << " r " << bdl->specificSurface().radius() << endl;
417  if (fdl)
418  buffer << " z " << fdl->specificSurface().position().z() << endl;
419  //buffer << " " << *il << endl;
420  }
421  return buffer.str();
422 }
423 
424 std::string whatIsTheStateToUse(TrajectoryStateOnSurface& initial,
425  TrajectoryStateOnSurface& stateToUse,
426  const DetLayer* l) {
427  std::stringstream buffer;
428  buffer << "GCTB: starting from "
429  << " r / phi / z = " << stateToUse.globalPosition().perp() << " / " << stateToUse.globalPosition().phi()
430  << " / " << stateToUse.globalPosition().z()
431  << " , pt / phi / pz /charge = " << stateToUse.globalMomentum().perp() << " / "
432  << stateToUse.globalMomentum().phi() << " / " << stateToUse.globalMomentum().z() << " / "
433  << stateToUse.charge() << " for layer at " << l << endl;
434  buffer << " errors:";
435  for (int i = 0; i < 5; i++)
436  buffer << " " << sqrt(stateToUse.curvilinearError().matrix()(i, i));
437  buffer << endl;
438 
439  //buffer << "GCTB: starting from r / phi / z = " << initial.globalPosition().perp()
440  //<< " / " << initial.globalPosition().phi()
441  //<< " / " << initial.globalPosition().z() << " , pt / pz = "
442  //<< initial.globalMomentum().perp() << " / "
443  //<< initial.globalMomentum().z() << " for layer at "
444  //<< l << endl;
445  //buffer << " errors:";
446  //for ( int i=0; i<5; i++ ) buffer << " " << sqrt(initial.curvilinearError().matrix()(i,i));
447  //buffer << endl;
448  return buffer.str();
449 }
450 #endif
451 
452 bool GroupedCkfTrajectoryBuilder::advanceOneLayer(const TrajectorySeed& seed,
453  TempTrajectory& traj,
454  const TrajectoryFilter* regionalCondition,
455  const Propagator* propagator,
456  bool inOut,
457  TempTrajectoryContainer& newCand,
458  TempTrajectoryContainer& result) const {
459  std::pair<TSOS, std::vector<const DetLayer*> >&& stateAndLayers = findStateAndLayers(seed, traj);
460 
462  if (
463  //stateAndLayers.second.size()==0 &&
464  traj.lastLayer()->location() == 0) {
465  float pt2 = stateAndLayers.first.globalMomentum().perp2();
466  if (pt2 < maxPt2ForLooperReconstruction && pt2 > (0.3f * 0.3f))
467  stateAndLayers.second.push_back(traj.lastLayer());
468  }
469  }
470 
471  auto layerBegin = stateAndLayers.second.begin();
472  auto layerEnd = stateAndLayers.second.end();
473 
474  // if (nl.empty()) {
475  // addToResult(traj,result,inOut);
476  // return false;
477  // }
478 
479 #ifdef EDM_ML_DEBUG
480  LogDebug("CkfPattern") << whatIsTheNextStep(traj, stateAndLayers);
481 #endif
482 
483  bool foundSegments(false);
484  bool foundNewCandidates(false);
485  for (auto il = layerBegin; il != layerEnd; il++) {
486  TSOS stateToUse = stateAndLayers.first;
487 
488  double dPhiCacheForLoopersReconstruction(0);
489  if
490  UNLIKELY(!traj.empty() && (*il) == traj.lastLayer()) {
492  // ------ For loopers reconstruction
493  //cout<<" self propagating in advanceOneLayer (for loopers) \n";
494  const BarrelDetLayer* sbdl = dynamic_cast<const BarrelDetLayer*>(traj.lastLayer());
495  if (sbdl) {
496  HelixBarrelCylinderCrossing cylinderCrossing(stateToUse.globalPosition(),
497  stateToUse.globalMomentum(),
498  stateToUse.transverseCurvature(),
499  propagator->propagationDirection(),
500  sbdl->specificSurface());
501  if (!cylinderCrossing.hasSolution())
502  continue;
503  GlobalPoint starting = stateToUse.globalPosition();
504  GlobalPoint target1 = cylinderCrossing.position1();
505  GlobalPoint target2 = cylinderCrossing.position2();
506 
507  GlobalPoint farther =
508  fabs(starting.phi() - target1.phi()) > fabs(starting.phi() - target2.phi()) ? target1 : target2;
509 
510  const Bounds& bounds(sbdl->specificSurface().bounds());
511  float length = 0.5f * bounds.length();
512 
513  /*
514  cout << "starting: " << starting << endl;
515  cout << "target1: " << target1 << endl;
516  cout << "target2: " << target2 << endl;
517  cout << "dphi: " << (target1.phi()-target2.phi()) << endl;
518  cout << "length: " << length << endl;
519  */
520 
521  /*
522  float deltaZ = bounds.thickness()/2.f/fabs(tan(stateToUse.globalDirection().theta()) ) ;
523  if(stateToUse.hasError())
524  deltaZ += 3*sqrt(stateToUse.cartesianError().position().czz());
525  if( fabs(farther.z()) > length + deltaZ ) continue;
526  */
527  if (fabs(farther.z()) * 0.95f > length)
528  continue;
529 
530  Geom::Phi<float> tmpDphi = target1.phi() - target2.phi();
532  continue;
533  GlobalPoint target(0.5f * (target1.basicVector() + target2.basicVector()));
534  //cout << "target: " << target << endl;
535 
537  stateToUse = extrapolator.extrapolate(stateToUse, target, *propagator);
538  if (!stateToUse.isValid())
539  continue; //SK: consider trying the original? probably not
540 
541  //dPhiCacheForLoopersReconstruction = fabs(target1.phi()-target2.phi())*2.;
542  dPhiCacheForLoopersReconstruction = std::abs(tmpDphi);
543  traj.incrementLoops();
544  } else { // not barrel
545  continue;
546  }
547  } else { // loopers not requested (why else???)
548  // ------ For cosmics reconstruction
549  LogDebug("CkfPattern") << " self propagating in advanceOneLayer.\n from: \n" << stateToUse;
550  //self navigation case
551  // go to a middle point first
553  GlobalPoint center(0, 0, 0);
554  stateToUse = middle.extrapolate(stateToUse, center, *(forwardPropagator(seed)));
555 
556  if (!stateToUse.isValid())
557  continue;
558  LogDebug("CkfPattern") << "to: " << stateToUse;
559  }
560  } // last layer...
561 
562  //unsigned int maxCandidates = theMaxCand > 21 ? theMaxCand*2 : 42; //limit the number of returned segments
563  LayerMeasurements layerMeasurements(theMeasurementTracker->measurementTracker(), *theMeasurementTracker);
564  TrajectorySegmentBuilder layerBuilder(
565  &layerMeasurements, **il, *propagator, *theUpdator, *theEstimator, theLockHits, theBestHitOnly, theMaxCand);
566 
567 #ifdef EDM_ML_DEBUG
568  LogDebug("CkfPattern") << whatIsTheStateToUse(stateAndLayers.first, stateToUse, *il);
569 #endif
570 
571  auto&& segments = layerBuilder.segments(stateToUse);
572 
573  LogDebug("CkfPattern") << "GCTB: number of segments = " << segments.size();
574 
575  if (!segments.empty())
576  foundSegments = true;
577 
578  for (auto is = segments.begin(); is != segments.end(); is++) {
579  //
580  // assume "invalid hit only" segment is last in list
581  //
582  auto const& measurements = is->measurements();
583  if (!theAlwaysUseInvalid && is != segments.begin() && measurements.size() == 1 &&
584  (measurements.front().recHit()->getType() == TrackingRecHit::missing))
585  break;
586 
587  //---- avoid to add the same hits more than once in the trajectory ----
588  bool toBeRejected(false);
589  for (auto revIt = measurements.rbegin(); revIt != measurements.rend(); --revIt) {
590  // int tmpCounter(0);
591  for (auto newTrajMeasIt = traj.measurements().rbegin(); newTrajMeasIt != traj.measurements().rend();
592  --newTrajMeasIt) {
593  //if(tmpCounter==2) break;
594  if (revIt->recHitR().geographicalId() == newTrajMeasIt->recHitR().geographicalId() &&
595  (revIt->recHitR().geographicalId() != DetId(0))) {
596  toBeRejected = true;
597  goto rejected; //break; // see http://stackoverflow.com/questions/1257744/can-i-use-break-to-exit-multiple-nested-for-loops
598  }
599  // tmpCounter++;
600  }
601  }
602 
603  rejected:; // http://xkcd.com/292/
604  if (toBeRejected) {
605 #ifdef VI_DEBUG
606  cout << "WARNING: neglect candidate because it contains the same hit twice \n";
607  cout << "-- discarded track's pt,eta,#found/lost: "
608  << traj.lastMeasurement().updatedState().globalMomentum().perp() << " , "
609  << traj.lastMeasurement().updatedState().globalMomentum().eta() << " , " << traj.foundHits() << '/'
610  << traj.lostHits() << "\n";
611 #endif
612  traj.setDPhiCacheForLoopersReconstruction(dPhiCacheForLoopersReconstruction);
613  continue; //Are we sure about this????
614  }
615  // ------------------------
616 
617  //
618  // create new candidate
619  //
620  TempTrajectory newTraj(traj);
621  traj.setDPhiCacheForLoopersReconstruction(dPhiCacheForLoopersReconstruction);
622  newTraj.join(*is);
623 
624  //std::cout << "DEBUG: newTraj after push found,lost: "
625  // << newTraj.foundHits() << " , "
626  // << newTraj.lostHits() << " , "
627  // << newTraj.measurements().size() << std::endl;
628 
629  //GIO// for ( vector<TM>::const_iterator im=measurements.begin();
630  //GIO// im!=measurements.end(); im++ ) newTraj.push(*im);
631  //if ( toBeContinued(newTraj,regionalCondition) ) { TOBE FIXED
632  if (toBeContinued(newTraj, inOut)) {
633  // Have added one more hit to track candidate
634 
635  LogDebug("CkfPattern") << "GCTB: adding updated trajectory to candidates: inOut=" << inOut
636  << " hits=" << newTraj.foundHits();
637 
638  newTraj.setStopReason(StopReason::NOT_STOPPED);
639  newCand.push_back(std::move(newTraj));
640  foundNewCandidates = true;
641  } else {
642  // Have finished building this track. Check if it passes cuts.
643 
644  LogDebug("CkfPattern") << "GCTB: adding completed trajectory to results if passes cuts: inOut=" << inOut
645  << " hits=" << newTraj.foundHits();
646  moveToResult(std::move(newTraj), result, inOut);
647  }
648  } // loop over segs
649  } // loop over layers
650 
651  if (!foundSegments) {
652  LogDebug("CkfPattern") << "GCTB: adding input trajectory to result";
653  if (!stateAndLayers.second.empty())
655  addToResult(traj, result, inOut);
656  }
657  return foundNewCandidates;
658 }
659 
660 namespace {
663  struct LayersInTraj {
664  static constexpr int N = 3;
665  TempTrajectory* traj;
666  std::array<DetLayer const*, N> layers;
667  int tot;
668  void fill(TempTrajectory& t) {
669  traj = &t;
670  tot = 0;
671  const TempTrajectory::DataContainer& measurements = traj->measurements();
672 
673  auto currl = layers[tot] = measurements.back().layer();
675  --ifirst;
676  for (TempTrajectory::DataContainer::const_iterator im = ifirst; im != measurements.rend(); --im) {
677  if (im->layer() != currl) {
678  ++tot;
679  currl = im->layer();
680  if (tot < N)
681  layers[tot] = currl;
682  }
683  }
684  ++tot;
685  }
686 
687  //void verify() {
688  // for (vector<const DetLayer*>::const_iterator iter = result.begin(); iter != result.end(); iter++)
689  // if (!*iter) edm::LogWarning("CkfPattern")<< "Warning: null det layer!! ";
690  // }
691  };
692 } // namespace
693 
694 //TempTrajectoryContainer
695 void GroupedCkfTrajectoryBuilder::groupedIntermediaryClean(TempTrajectoryContainer& theTrajectories) const {
696  //if (theTrajectories.empty()) return TrajectoryContainer();
697  //TrajectoryContainer result;
698  if (theTrajectories.empty())
699  return;
700  //RecHitEqualByChannels recHitEqualByChannels(false, false);
701  LayersInTraj layers[theTrajectories.size()];
702  int ntraj = 0;
703  for (auto& t : theTrajectories) {
704  if (t.isValid() && t.lastMeasurement().recHitR().isValid())
705  layers[ntraj++].fill(t);
706  }
707 
708  if (ntraj < 2)
709  return;
710 
711  for (int ifirst = 0; ifirst != ntraj - 1; ++ifirst) {
712  auto firstTraj = layers[ifirst].traj;
713  if (!firstTraj->isValid())
714  continue;
715  const TempTrajectory::DataContainer& firstMeasurements = firstTraj->measurements();
716 
717  int firstLayerSize = layers[ifirst].tot;
718  if (firstLayerSize < 4)
719  continue;
720  auto const& firstLayers = layers[ifirst].layers;
721 
722  for (int isecond = ifirst + 1; isecond != ntraj; ++isecond) {
723  auto secondTraj = layers[isecond].traj;
724  if (!secondTraj->isValid())
725  continue;
726 
727  const TempTrajectory::DataContainer& secondMeasurements = secondTraj->measurements();
728 
729  int secondLayerSize = layers[isecond].tot;
730  //
731  // only candidates using the same last 3 layers are compared
732  //
733  if (firstLayerSize != secondLayerSize)
734  continue; // V.I. why equal???
735  auto const& secondLayers = layers[isecond].layers;
736  if (firstLayers[0] != secondLayers[0] || firstLayers[1] != secondLayers[1] || firstLayers[2] != secondLayers[2])
737  continue;
738 
739  TempTrajectory::DataContainer::const_iterator im1 = firstMeasurements.rbegin();
740  TempTrajectory::DataContainer::const_iterator im2 = secondMeasurements.rbegin();
741  //
742  // check for identical hits in the last layer
743  //
744  bool unequal(false);
745  const DetLayer* layerPtr = firstLayers[0];
746  while (im1 != firstMeasurements.rend() && im2 != secondMeasurements.rend()) {
747  if (im1->layer() != layerPtr || im2->layer() != layerPtr)
748  break;
749  if (!(im1->recHit()->isValid()) || !(im2->recHit()->isValid()) ||
750  !im1->recHit()->hit()->sharesInput(im2->recHit()->hit(), TrackingRecHit::some)) {
752  unequal = true;
753  break;
754  }
755  --im1;
756  --im2;
757  }
758  if (im1 == firstMeasurements.rend() || im2 == secondMeasurements.rend() || im1->layer() == layerPtr ||
759  im2->layer() == layerPtr || unequal)
760  continue;
761  //
762  // check for invalid hits in the layer -2
763  // compare only candidates with invalid / valid combination
764  //
765  layerPtr = firstLayers[1];
766  bool firstValid(true);
767  while (im1 != firstMeasurements.rend() && im1->layer() == layerPtr) {
768  if (!im1->recHit()->isValid())
769  firstValid = false;
770  --im1;
771  }
772  bool secondValid(true);
773  while (im2 != secondMeasurements.rend() && im2->layer() == layerPtr) {
774  if (!im2->recHit()->isValid())
775  secondValid = false;
776  --im2;
777  }
778  if (!tkxor(firstValid, secondValid))
779  continue;
780  //
781  // ask for identical hits in layer -3
782  //
783  unequal = false;
784  layerPtr = firstLayers[2];
785  while (im1 != firstMeasurements.rend() && im2 != secondMeasurements.rend()) {
786  if (im1->layer() != layerPtr || im2->layer() != layerPtr)
787  break;
788  if (!(im1->recHit()->isValid()) || !(im2->recHit()->isValid()) ||
789  !im1->recHit()->hit()->sharesInput(im2->recHit()->hit(), TrackingRecHit::some)) {
791  unequal = true;
792  break;
793  }
794  --im1;
795  --im2;
796  }
797  if (im1 == firstMeasurements.rend() || im2 == secondMeasurements.rend() || im1->layer() == layerPtr ||
798  im2->layer() == layerPtr || unequal)
799  continue;
800 
801  if (!firstValid) {
802  firstTraj->invalidate();
803  break;
804  } else {
805  secondTraj->invalidate(); // V.I. why break?
806  break;
807  }
808  } // second
809  } // first
810  /*
811  for (TempTrajectoryContainer::const_iterator it = theTrajectories.begin();
812  it != theTrajectories.end(); it++) {
813  if(it->isValid()) result.push_back( *it);
814  }
815 
816  return result;
817 */
818  theTrajectories.erase(
819  std::remove_if(theTrajectories.begin(), theTrajectories.end(), std::not_fn(&TempTrajectory::isValid)),
820  theTrajectories.end());
821 }
822 
824  TempTrajectory const& startingTraj,
825  TempTrajectoryContainer& result) const {
826  //
827  // Rebuilding of trajectories. Candidates are taken from result,
828  // which will be replaced with the solutions after rebuild
829  // (assume vector::swap is more efficient than building new container)
830  //
831  LogDebug("CkfPattern") << "Starting to rebuild " << result.size() << " tracks";
832  //
833  // Fitter (need to create it here since the propagation direction
834  // might change between different starting trajectories)
835  //
836  auto hitCloner = static_cast<TkTransientTrackingRecHitBuilder const*>(hitBuilder())->cloner();
837  KFTrajectoryFitter fitter(backwardPropagator(seed), &updator(), &estimator(), 3, nullptr, &hitCloner);
838  //
839  TrajectorySeed::range rseedHits = seed.recHits();
840  std::vector<const TrackingRecHit*> seedHits;
841  //seedHits.insert(seedHits.end(), rseedHits.first, rseedHits.second);
842  //for (TrajectorySeed::recHitContainer::const_iterator iter = rseedHits.first; iter != rseedHits.second; iter++){
843  // seedHits.push_back(&*iter);
844  //}
845 
846  //unsigned int nSeed(seedHits.size());
847  unsigned int nSeed(rseedHits.second - rseedHits.first);
848  //seedHits.reserve(nSeed);
849  TempTrajectoryContainer rebuiltTrajectories;
850 
851  for (TempTrajectoryContainer::iterator it = result.begin(); it != result.end(); it++) {
852  // Refit - keep existing trajectory in case fit is not possible
853  // or fails
854  //
855 
856  auto&& reFitted = backwardFit(*it, nSeed, fitter, seedHits);
857  if
858  UNLIKELY(!reFitted.isValid()) {
859  rebuiltTrajectories.push_back(std::move(*it));
860  LogDebug("CkfPattern") << "RebuildSeedingRegion skipped as backward fit failed";
861  // << "after reFitted.size() " << reFitted.size();
862  continue;
863  }
864  //LogDebug("CkfPattern")<<"after reFitted.size() " << reFitted.size();
865  //
866  // Rebuild seeding part. In case it fails: keep initial trajectory
867  // (better to drop it??)
868  //
869  int nRebuilt = rebuildSeedingRegion(seed, seedHits, reFitted, rebuiltTrajectories);
870  // Loop over the last nRebuilt trajectories and propagate back the
871  // real cause that stopped the original in-out trajectory, since
872  // that's the one we want to monitor
873  for (size_t i = rebuiltTrajectories.size() - 1; i < rebuiltTrajectories.size() - nRebuilt - 1; --i) {
874  rebuiltTrajectories[i].setStopReason(it->stopReason());
875  }
876 
877  if (nRebuilt == 0 && !theKeepOriginalIfRebuildFails)
878  it->invalidate(); // won't use original in-out track
879 
880  if (nRebuilt < 0)
881  rebuiltTrajectories.push_back(std::move(*it));
882  }
883  //
884  // Replace input trajectories with new ones
885  //
886  result.swap(rebuiltTrajectories);
887  result.erase(std::remove_if(result.begin(), result.end(), std::not_fn(&TempTrajectory::isValid)), result.end());
888 }
889 
891  const std::vector<const TrackingRecHit*>& seedHits,
892  TempTrajectory& candidate,
893  TempTrajectoryContainer& result) const {
894  //
895  // Starting from track found by in-out tracking phase, extrapolate it inwards through
896  // the seeding region if possible in towards smaller Tracker radii, searching for additional
897  // hits.
898  // The resulting trajectories are returned in result,
899  // the count is the return value.
900  //
901  TempTrajectoryContainer rebuiltTrajectories;
902 #ifdef DBG2_GCTB
903  /* const LayerFinderByDet layerFinder;
904  if ( !seedHits.empty() && seedHits.front().isValid() ) {
905  DetLayer* seedLayer = layerFinder(seedHits.front().det());
906  cout << "Seed hit at " << seedHits.front().globalPosition()
907  << " " << seedLayer << endl;
908  cout << "Started from "
909  << candidate.lastMeasurement().updatedState().globalPosition().perp() << " "
910  << candidate.lastMeasurement().updatedState().globalPosition().z() << endl;
911  pair<bool,TrajectoryStateOnSurface> layerComp(false,TrajectoryStateOnSurface());
912  if ( seedLayer ) layerComp =
913  seedLayer->compatible(candidate.lastMeasurement().updatedState(),
914  propagator(),estimator());
915  pair<bool,TrajectoryStateOnSurface> detComp =
916  seedHits.front().det().compatible(candidate.lastMeasurement().updatedState(),
917  propagator(),estimator());
918  cout << " layer compatibility = " << layerComp.first;
919  cout << " det compatibility = " << detComp.first;
920  if ( detComp.first ) {
921  cout << " estimate = "
922  << estimator().estimate(detComp.second,seedHits.front()).second ;
923  }
924  cout << endl;
925  }*/
926  cout << "Before backward building: #measurements = " << candidate.measurements().size(); //<< endl;;
927 #endif
928  //
929  // Use standard building with standard cuts. Maybe better to use different
930  // cuts from "forward" building (e.g. no check on nr. of invalid hits)?
931  //
932  const bool inOut = false;
933  groupedLimitedCandidates(seed, candidate, nullptr, backwardPropagator(seed), inOut, rebuiltTrajectories);
934 
935  LogDebug("CkfPattern") << " After backward building: " << PrintoutHelper::dumpCandidates(rebuiltTrajectories);
936 
937  //
938  // Check & count resulting candidates
939  //
940  int nrOfTrajectories(0);
941  bool orig_ok = false;
942  //const RecHitEqualByChannels recHitEqual(false,false);
943  //vector<TM> oldMeasurements(candidate.measurements());
944  for (TempTrajectoryContainer::iterator it = rebuiltTrajectories.begin(); it != rebuiltTrajectories.end(); it++) {
945  TempTrajectory::DataContainer newMeasurements(it->measurements());
946  //
947  // Verify presence of seeding hits?
948  //
950  orig_ok = true;
951  // no hits found (and possibly some invalid hits discarded): drop track
952  if (newMeasurements.size() <= candidate.measurements().size()) {
953  LogDebug("CkfPattern") << "newMeasurements.size()<=candidate.measurements().size()";
954  continue;
955  }
956  // verify presence of hits
957  //GIO//if ( !verifyHits(newMeasurements.begin()+candidate.measurements().size(),
958  //GIO// newMeasurements.end(),seedHits) ){
959  if (!verifyHits(newMeasurements.rbegin(), newMeasurements.size() - candidate.measurements().size(), seedHits)) {
960  LogDebug("CkfPattern") << "seed hits not found in rebuild";
961  continue;
962  }
963  }
964  //
965  // construct final trajectory in the right order
966  //
967  // save & count result
968  nrOfTrajectories++;
969  result.emplace_back(seed.direction(), seed.nHits());
970  TempTrajectory& reversedTrajectory = result.back();
971  reversedTrajectory.setNLoops(it->nLoops());
972  for (TempTrajectory::DataContainer::const_iterator im = newMeasurements.rbegin(), ed = newMeasurements.rend();
973  im != ed;
974  --im) {
975  reversedTrajectory.push(*im);
976  }
977 
978  LogDebug("CkgPattern") << "New traj direction = " << reversedTrajectory.direction() << "\n"
979  << PrintoutHelper::dumpMeasurements(reversedTrajectory.measurements());
980  } // rebuiltTrajectories
981 
982  // If nrOfTrajectories = 0 and orig_ok = true, this means that a track was actually found on the
983  // out-in step (meeting those requirements) but did not have the seed hits in it.
984  // In this case when we return we will go ahead and use the original in-out track.
985 
986  // If nrOfTrajectories = 0 and orig_ok = false, this means that the out-in step failed to
987  // find any track. Two cases are a technical failure in fitting the original seed hits or
988  // because the track did not meet the out-in criteria (which may be stronger than the out-in
989  // criteria). In this case we will NOT allow the original in-out track to be used.
990 
991  if ((nrOfTrajectories == 0) && orig_ok) {
992  nrOfTrajectories = -1;
993  }
994  return nrOfTrajectories;
995 }
996 
997 TempTrajectory GroupedCkfTrajectoryBuilder::backwardFit(TempTrajectory& candidate,
998  unsigned int nSeed,
999  const TrajectoryFitter& fitter,
1000  std::vector<const TrackingRecHit*>& remainingHits) const {
1001  //
1002  // clear array of non-fitted hits
1003  //
1004  remainingHits.clear();
1005 
1006  LogDebug("CkfPattern") << "nSeed " << nSeed << endl
1007  << "Old traj direction = " << candidate.direction() << endl
1009 
1010  //
1011  // backward fit trajectory.
1012  // (Will try to fit only hits outside the seeding region. However,
1013  // if there are not enough of these, it will also use the seeding hits).
1014  //
1015  // const unsigned int nHitAllMin(5);
1016  // const unsigned int nHit2dMin(2);
1017  unsigned int nHit(0); // number of valid hits after seeding region
1018  //unsigned int nHit2d(0); // number of valid hits after seeding region with 2D info
1019  // use all hits except the first n (from seed), but require minimum
1020  // specified in configuration.
1021  // Swapped over next two lines.
1022  unsigned int nHitMin = std::max(candidate.foundHits() - nSeed, theMinNrOfHitsForRebuild);
1023  // unsigned int nHitMin = oldMeasurements.size()-nSeed;
1024  // we want to rebuild only if the number of VALID measurements excluding the seed measurements is higher than the cut
1025  if
1027 
1028  LogDebug("CkfPattern") /* << "nHitMin " << nHitMin*/ << "Sizes: " << candidate.measurements().size() << " / ";
1029  //
1030  // create input trajectory for backward fit
1031  //
1032  Trajectory fwdTraj(oppositeDirection(candidate.direction()));
1033  fwdTraj.setNLoops(candidate.nLoops());
1034  //const TrajectorySeed seed = TrajectorySeed(PTrajectoryStateOnDet(), TrajectorySeed::recHitContainer(), oppositeDirection(candidate.direction()));
1035  //Trajectory fwdTraj(seed, oppositeDirection(candidate.direction()));
1036 
1037  const DetLayer* bwdDetLayer[candidate.measurements().size()];
1038  int nl = 0;
1039  for (auto const& tm : candidate.measurements()) {
1040  const TrackingRecHit* hit = tm.recHitR().hit();
1041  //
1042  // add hits until required number is reached
1043  //
1044  if (nHit < nHitMin) { //|| nHit2d<theMinNrOf2dHitsForRebuild ) {
1045  fwdTraj.push(tm);
1046  bwdDetLayer[nl++] = tm.layer();
1047  //
1048  // count valid / 2D hits
1049  //
1050  if
1051  LIKELY(hit->isValid()) {
1052  nHit++;
1053  //if ( hit.isMatched() ||
1054  // hit.det().detUnits().front()->type().module()==pixel )
1055  //nHit2d++;
1056  }
1057  }
1058  //if (nHit==nHitMin) lastBwdDetLayer=im->layer();
1059  //
1060  // keep remaining (valid) hits for verification
1061  //
1062  else if (hit->isValid()) {
1063  //std::cout << "Adding a remaining hit" << std::endl;
1064  remainingHits.push_back(hit);
1065  }
1066  }
1067  //
1068  // Fit only if required number of valid hits can be used
1069  //
1070  if
1071  UNLIKELY(nHit < nHitMin) return TempTrajectory();
1072 
1073  //
1074  // Do the backward fit (important: start from scaled, not random cov. matrix!)
1075  //
1076  TrajectoryStateOnSurface firstTsos(fwdTraj.firstMeasurement().updatedState());
1077  //cout << "firstTsos "<< firstTsos << endl;
1078  firstTsos.rescaleError(10.);
1079  //TrajectoryContainer bwdFitted(fitter.fit(fwdTraj.seed(),fwdTraj.recHits(),firstTsos));
1080  Trajectory&& bwdFitted = fitter.fitOne(
1082  PTrajectoryStateOnDet(), TrajectorySeed::recHitContainer(), oppositeDirection(candidate.direction())),
1083  fwdTraj.recHits(),
1084  firstTsos);
1085  if
1086  UNLIKELY(!bwdFitted.isValid()) return TempTrajectory();
1087 
1088  LogDebug("CkfPattern") << "Obtained bwdFitted trajectory with measurement size " << bwdFitted.measurements().size();
1089  TempTrajectory fitted(fwdTraj.direction(), nSeed);
1090  fitted.setNLoops(fwdTraj.nLoops());
1091  vector<TM> const& tmsbf = bwdFitted.measurements();
1092  int iDetLayer = 0;
1093  //this is ugly but the TM in the fitted track do not contain the DetLayer.
1094  //So we have to cache the detLayer pointers and replug them in.
1095  //For the backward building it would be enaugh to cache the last DetLayer,
1096  //but for the intermediary cleaning we need all
1097  for (vector<TM>::const_iterator im = tmsbf.begin(); im != tmsbf.end(); im++) {
1098  fitted.emplace((*im).forwardPredictedState(),
1099  (*im).backwardPredictedState(),
1100  (*im).updatedState(),
1101  (*im).recHit(),
1102  (*im).estimate(),
1103  bwdDetLayer[iDetLayer]);
1104 
1105  LogDebug("CkfPattern") << PrintoutHelper::dumpMeasurement(*im);
1106  iDetLayer++;
1107  }
1108  /*
1109  TM lastMeas = bwdFitted.front().lastMeasurement();
1110  fitted.pop();
1111  fitted.push(TM(lastMeas.forwardPredictedState(),
1112  lastMeas.backwardPredictedState(),
1113  lastMeas.updatedState(),
1114  lastMeas.recHit(),
1115  lastMeas.estimate(),
1116  lastBwdDetLayer));
1117  */
1118 
1119  return fitted;
1120 }
1121 
1122 bool GroupedCkfTrajectoryBuilder::verifyHits(TempTrajectory::DataContainer::const_iterator rbegin,
1123  size_t maxDepth,
1124  const std::vector<const TrackingRecHit*>& hits) const {
1125  //
1126  // verify presence of the seeding hits
1127  //
1128  LogDebug("CkfPattern") << "Checking for " << hits.size() << " hits in " << maxDepth << " measurements" << endl;
1129 
1130  auto rend = rbegin;
1131  while (maxDepth > 0) {
1132  --maxDepth;
1133  --rend;
1134  }
1135  for (auto ir = hits.begin(); ir != hits.end(); ir++) {
1136  // assume that all seeding hits are valid!
1137  bool foundHit(false);
1138  for (auto im = rbegin; im != rend; --im) {
1139  if (im->recHit()->isValid() && (*ir)->sharesInput(im->recHit()->hit(), TrackingRecHit::some)) {
1140  foundHit = true;
1141  break;
1142  }
1143  }
1144  if (!foundHit)
1145  return false;
1146  }
1147  return true;
1148 }
runTheMatrix.ret
ret
prodAgent to be discontinued
Definition: runTheMatrix.py:355
BaseCkfTrajectoryBuilder::addToResult
void addToResult(std::shared_ptr< const TrajectorySeed > const &seed, TempTrajectory &traj, TrajectoryContainer &result, bool inOut=false) const
Definition: BaseCkfTrajectoryBuilder.cc:146
Chi2MeasurementEstimator.h
TrajMeasLessEstim.h
TrajectoryFilter
Definition: TrajectoryFilter.h:28
HelixBarrelCylinderCrossing.h
BaseCkfTrajectoryBuilder
Definition: BaseCkfTrajectoryBuilder.h:53
electrons_cff.bool
bool
Definition: electrons_cff.py:372
mps_fire.i
i
Definition: mps_fire.py:355
TempTrajectory::direction
PropagationDirection direction() const
Definition: TempTrajectory.cc:118
HLT_2018_cff.pt2
pt2
Definition: HLT_2018_cff.py:8552
MeasurementTrackerEvent.h
MessageLogger.h
PrintoutHelper::dumpCandidates
static std::string dumpCandidates(collection &candidates)
Definition: PrintoutHelper.h:69
GroupedCkfTrajectoryBuilder::theMaxCand
int theMaxCand
Definition: GroupedCkfTrajectoryBuilder.h:170
GroupedTrajCandLess
Definition: GroupedTrajCandLess.h:13
hfClusterShapes_cfi.hits
hits
Definition: hfClusterShapes_cfi.py:5
TrajectoryCleanerBySharedHits.h
TempTrajectory::push
void push(const TrajectoryMeasurement &tm)
Definition: TempTrajectory.h:108
DetLayer
Definition: DetLayer.h:21
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
GroupedCkfTrajectoryBuilder::theAlwaysUseInvalid
bool theAlwaysUseInvalid
Definition: GroupedCkfTrajectoryBuilder.h:178
TrajectorySeed::range
std::pair< const_iterator, const_iterator > range
Definition: TrajectorySeed.h:21
GroupedCkfTrajectoryBuilder::theBestHitOnly
bool theBestHitOnly
Definition: GroupedCkfTrajectoryBuilder.h:181
edm
HLT enums.
Definition: AlignableModifier.h:19
TempTrajectory
Definition: TempTrajectory.h:40
GroupedCkfTrajectoryBuilder.h
TransientRecHitRecord.h
BaseCkfTrajectoryBuilder::TrajectoryContainer
std::vector< Trajectory > TrajectoryContainer
Definition: BaseCkfTrajectoryBuilder.h:62
TrajectoryStateOnSurface::globalPosition
GlobalPoint globalPosition() const
Definition: TrajectoryStateOnSurface.h:65
GroupedCkfTrajectoryBuilder::theKeepOriginalIfRebuildFails
bool theKeepOriginalIfRebuildFails
Definition: GroupedCkfTrajectoryBuilder.h:190
gather_cfg.cout
cout
Definition: gather_cfg.py:144
BaseCkfTrajectoryBuilder::theEstimator
const Chi2MeasurementEstimatorBase * theEstimator
Definition: BaseCkfTrajectoryBuilder.h:173
ALCARECOTkAlBeamHalo_cff.nHitMin
nHitMin
Definition: ALCARECOTkAlBeamHalo_cff.py:34
GroupedCkfTrajectoryBuilder::theLostHitPenalty
float theLostHitPenalty
Definition: GroupedCkfTrajectoryBuilder.h:172
BaseCkfTrajectoryBuilder::findStateAndLayers
StateAndLayers findStateAndLayers(const TrajectorySeed &seed, const TempTrajectory &traj) const
Definition: BaseCkfTrajectoryBuilder.cc:195
TrajectoryStateOnSurface::charge
TrackCharge charge() const
Definition: TrajectoryStateOnSurface.h:68
Bounds
Definition: Bounds.h:18
trackerHitRTTI::isUndef
bool isUndef(TrackingRecHit const &hit)
Definition: trackerHitRTTI.h:23
TrajectoryMeasurement.h
TrajectoryMeasurement::updatedState
TrajectoryStateOnSurface const & updatedState() const
Definition: TrajectoryMeasurement.h:184
TrajectoryStateOnSurface::transverseCurvature
double transverseCurvature() const
Definition: TrajectoryStateOnSurface.h:70
GroupedCkfTrajectoryBuilder::maxPt2ForLooperReconstruction
float maxPt2ForLooperReconstruction
Definition: GroupedCkfTrajectoryBuilder.h:195
align_cfg.firstValid
firstValid
Definition: align_cfg.py:68
TransverseImpactPointExtrapolator
Definition: TransverseImpactPointExtrapolator.h:26
edm::ParameterSet::existsAs
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:160
CTPPSpixelLocalTrackReconstructionInfo::invalid
rejected
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is rejected(acceptEvent retursns false). There are 3 relevant cases of types of criteria
GeometricSearchDet::position
virtual const Surface::PositionType & position() const
Returns position of the surface.
Definition: GeometricSearchDet.h:31
createJobs.tmp
tmp
align.sh
Definition: createJobs.py:716
TrajectoryStateUpdator.h
HLT_2018_cff.maxDepth
maxDepth
Definition: HLT_2018_cff.py:7356
TkTransientTrackingRecHitBuilder.h
Bounds::length
virtual float length() const =0
cmsutils::bqueue::back
const T & back() const
Definition: bqueue.h:195
PrintoutHelper::dumpMeasurement
static std::string dumpMeasurement(const TrajectoryMeasurement &tm)
Definition: PrintoutHelper.cc:41
edmScanValgrind.buffer
buffer
Definition: edmScanValgrind.py:171
IntermediateTrajectoryCleaner.h
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
Propagator
Definition: Propagator.h:44
edmIntegrityCheck.work
work
Definition: edmIntegrityCheck.py:75
DetId
Definition: DetId.h:17
GeometricSearchTracker.h
UNLIKELY
#define UNLIKELY(x)
Definition: Likely.h:21
DetLayer::location
virtual Location location() const =0
Which part of the detector (barrel, endcap)
TempTrajectory::setNLoops
void setNLoops(signed char value)
Definition: TempTrajectory.h:259
TrajectoryStateOnSurface
Definition: TrajectoryStateOnSurface.h:16
BaseCkfTrajectoryBuilder::toBeContinued
bool toBeContinued(TempTrajectory &traj, bool inOut=false) const
Definition: BaseCkfTrajectoryBuilder.cc:114
LayerMeasurements
Definition: LayerMeasurements.h:18
TempTrajectory::isValid
bool isValid() const
Definition: TempTrajectory.h:224
GroupedCkfTrajectoryBuilder::theRequireSeedHitsInRebuild
bool theRequireSeedHitsInRebuild
Definition: GroupedCkfTrajectoryBuilder.h:183
DetGroup.h
TrackCandidateProducer_cfi.propagator
propagator
Definition: TrackCandidateProducer_cfi.py:17
cmsutils::bqueue::size
size_type size() const
Definition: bqueue.h:201
GroupedCkfTrajectoryBuilder::GroupedCkfTrajectoryBuilder
GroupedCkfTrajectoryBuilder(const edm::ParameterSet &conf, edm::ConsumesCollector &iC)
constructor from ParameterSet
Definition: GroupedCkfTrajectoryBuilder.cc:112
BaseCkfTrajectoryBuilder::theUpdator
const TrajectoryStateUpdator * theUpdator
Definition: BaseCkfTrajectoryBuilder.h:170
PrintoutHelper::dumpMeasurements
static std::string dumpMeasurements(const std::vector< TrajectoryMeasurement > &v)
Definition: PrintoutHelper.cc:21
TempTrajectory::lastMeasurement
const TrajectoryMeasurement & lastMeasurement() const
Definition: TempTrajectory.h:159
LayerMeasurements.h
GroupedCkfTrajectoryBuilder::buildTrajectories
TempTrajectory buildTrajectories(const TrajectorySeed &seed, TrajectoryContainer &ret, unsigned int &nCandPerSeed, const TrajectoryFilter *) const override
common part of both public trajectory building methods
Definition: GroupedCkfTrajectoryBuilder.cc:237
TempTrajectory::measurements
const DataContainer & measurements() const
Definition: TempTrajectory.h:177
BaseCkfTrajectoryBuilder::backwardPropagator
const Propagator * backwardPropagator(const TrajectorySeed &seed) const
Definition: BaseCkfTrajectoryBuilder.h:163
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
TempTrajectory::foundHits
int foundHits() const
Definition: TempTrajectory.h:184
N
#define N
Definition: blowfish.cc:9
BaseCkfTrajectoryBuilder::theMeasurementTracker
const MeasurementTrackerEvent * theMeasurementTracker
Definition: BaseCkfTrajectoryBuilder.h:175
BaseCkfTrajectoryBuilder::hitBuilder
const TransientTrackingRecHitBuilder * hitBuilder() const
Definition: BaseCkfTrajectoryBuilder.h:104
cmsutils::bqueue< TrajectoryMeasurement >
BaseCkfTrajectoryBuilder::moveToResult
void moveToResult(TempTrajectory &&traj, TempTrajectoryContainer &result, bool inOut=false) const
Definition: BaseCkfTrajectoryBuilder.cc:182
GroupedCkfTrajectoryBuilder::theLockHits
bool theLockHits
Definition: GroupedCkfTrajectoryBuilder.h:180
CMS_THREAD_SAFE
#define CMS_THREAD_SAFE
Definition: thread_safety_macros.h:4
Point3DBase< float, GlobalTag >
TrackingRecHit::some
Definition: TrackingRecHit.h:59
OrderedSet.t
t
Definition: OrderedSet.py:90
GroupedCkfTrajectoryBuilder::rebuildSeedingRegion
void rebuildSeedingRegion(const TrajectorySeed &, TrajectoryContainer &result) const override
Definition: GroupedCkfTrajectoryBuilder.cc:196
cmsutils::bqueue::rbegin
const_iterator rbegin() const
Definition: bqueue.h:197
TempTrajectory::setDPhiCacheForLoopersReconstruction
void setDPhiCacheForLoopersReconstruction(float dphi)
Definition: TempTrajectory.h:254
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
BaseCkfTrajectoryBuilder::TempTrajectoryContainer
std::vector< TempTrajectory > TempTrajectoryContainer
Definition: BaseCkfTrajectoryBuilder.h:63
ntuplemaker.fill
fill
Definition: ntuplemaker.py:304
FastTrajectoryCleaner::clean
void clean(TempTrajectoryContainer &) const override
Definition: FastTrajectoryCleaner.cc:7
HelixArbitraryPlaneCrossing.h
KFUpdator.h
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
edm::ParameterSet
Definition: ParameterSet.h:36
cmsutils::_bqueue_itr
Definition: bqueue.h:39
GroupedTrajCandLess.h
TempTrajectory::lostHits
int lostHits() const
Definition: TempTrajectory.h:194
ParameterSet
Definition: Functions.h:16
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
BaseCkfTrajectoryBuilder::setEvent_
virtual void setEvent_(const edm::Event &iEvent, const edm::EventSetup &iSetup)=0
TrackingRecHit::missing
Definition: TrackingRecHit.h:47
thread_safety_macros.h
PV3DBase::eta
T eta() const
Definition: PV3DBase.h:73
RegionalTrajectoryFilter.h
trackerHitRTTI::isFromDet
bool isFromDet(TrackingRecHit const &hit)
Definition: trackerHitRTTI.h:35
Geom::Phi< float >
BaseCkfTrajectoryBuilder::forwardPropagator
const Propagator * forwardPropagator(const TrajectorySeed &seed) const
Definition: BaseCkfTrajectoryBuilder.h:160
GroupedCkfTrajectoryBuilder::work_MaxSize_
Definition: GroupedCkfTrajectoryBuilder.h:201
GroupedCkfTrajectoryBuilder::updator
const TrajectoryStateUpdator & updator() const
Definition: GroupedCkfTrajectoryBuilder.h:66
edm::EventSetup
Definition: EventSetup.h:57
GroupedCkfTrajectoryBuilder::rebuildTrajectories
void rebuildTrajectories(TempTrajectory const &startingTraj, const TrajectorySeed &, TrajectoryContainer &result) const override
Definition: GroupedCkfTrajectoryBuilder.cc:201
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
OmniClusterRef.h
BarrelDetLayer
Definition: BarrelDetLayer.h:22
edm::print
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
cmsLHEtoEOSManager.l
l
Definition: cmsLHEtoEOSManager.py:193
PV3DBase::basicVector
const BasicVectorType & basicVector() const
Definition: PV3DBase.h:53
Trajectory::measurements
DataContainer const & measurements() const
Definition: Trajectory.h:178
BasicSingleTrajectoryState.h
TempTrajectory::incrementLoops
void incrementLoops()
Definition: TempTrajectory.h:260
TrajectoryStateOnSurface::rescaleError
void rescaleError(double factor)
Definition: TrajectoryStateOnSurface.h:82
TrackingRecHit
Definition: TrackingRecHit.h:21
FastTrajectoryCleaner.h
TrajectorySegmentBuilder
Definition: TrajectorySegmentBuilder.h:31
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Trajectory.h
TrajectoryStateOnSurface::globalMomentum
GlobalVector globalMomentum() const
Definition: TrajectoryStateOnSurface.h:66
TrajectoryFitter
Definition: TrajectoryFitter.h:19
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
TrajectorySegmentBuilder.h
ForwardDetLayer
Definition: ForwardDetLayer.h:22
GroupedCkfTrajectoryBuilder::theMinNrOfHitsForRebuild
unsigned int theMinNrOfHitsForRebuild
Definition: GroupedCkfTrajectoryBuilder.h:185
StopReason::NOT_STOPPED
Trajectory
Definition: Trajectory.h:38
HLT_2018_cff.candidates
candidates
Definition: HLT_2018_cff.py:53513
GroupedCkfTrajectoryBuilder::maxDPhiForLooperReconstruction
float maxDPhiForLooperReconstruction
Definition: GroupedCkfTrajectoryBuilder.h:197
LIKELY
#define LIKELY(x)
Definition: Likely.h:20
TrackingComponentsRecord.h
Exception
Definition: hltDiff.cc:246
TrajectoryStateOnSurface::curvilinearError
const CurvilinearTrajectoryError & curvilinearError() const
Definition: TrajectoryStateOnSurface.h:72
TempTrajectory::setStopReason
void setStopReason(StopReason s)
Definition: TempTrajectory.h:263
cmsutils::bqueue::rend
const_iterator rend() const
Definition: bqueue.h:198
FastTrajectoryCleaner
Definition: FastTrajectoryCleaner.h:14
TransverseImpactPointExtrapolator.h
GroupedCkfTrajectoryBuilder::theMinNrOf2dHitsForRebuild
unsigned int theMinNrOf2dHitsForRebuild
Definition: GroupedCkfTrajectoryBuilder.h:188
HLT_2018_cff.region
region
Definition: HLT_2018_cff.py:81479
TrajectorySeed::recHits
range recHits() const
Definition: TrajectorySeed.h:52
DetLayer.h
TrajectorySeed
Definition: TrajectorySeed.h:17
TransverseImpactPointExtrapolator::extrapolate
TrajectoryStateOnSurface extrapolate(const FreeTrajectoryState &fts, const GlobalPoint &vtx) const
extrapolation with default (=geometrical) propagator
Definition: TransverseImpactPointExtrapolator.cc:23
TempTrajectory::lastLayer
const DetLayer * lastLayer() const
Redundant method, returns the layer of lastMeasurement() .
Definition: TempTrajectory.h:237
RegionalTrajectoryFilter
Definition: RegionalTrajectoryFilter.h:13
TempTrajectory::nLoops
signed char nLoops() const
Definition: TempTrajectory.h:257
KFTrajectoryFitter.h
filterCSVwithJSON.target
target
Definition: filterCSVwithJSON.py:32
TrackingRegion
Definition: TrackingRegion.h:40
HelixBarrelCylinderCrossing
Definition: HelixBarrelCylinderCrossing.h:16
TransientTrackingRecHitBuilder.h
mps_fire.result
result
Definition: mps_fire.py:303
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
GroupedCkfTrajectoryBuilder::estimator
const Chi2MeasurementEstimatorBase & estimator() const
Definition: GroupedCkfTrajectoryBuilder.h:67
PTrajectoryStateOnDet
Definition: PTrajectoryStateOnDet.h:10
TrajectoryMeasurement::layer
const DetLayer * layer() const
Definition: TrajectoryMeasurement.h:194
GroupedCkfTrajectoryBuilder::theIntermediateCleaning
bool theIntermediateCleaning
Definition: GroupedCkfTrajectoryBuilder.h:175
event
Definition: event.py:1
edm::Event
Definition: Event.h:73
GroupedCkfTrajectoryBuilder::theFoundHitBonus
float theFoundHitBonus
Definition: GroupedCkfTrajectoryBuilder.h:173
GroupedCkfTrajectoryBuilder::trajectories
TrajectoryContainer trajectories(const TrajectorySeed &) const override
set Event for the internal MeasurementTracker data member
Definition: GroupedCkfTrajectoryBuilder.cc:163
TrajectoryFitter::fitOne
virtual Trajectory fitOne(const Trajectory &traj, fitType type=standard) const =0
BarrelDetLayer::specificSurface
virtual const BoundCylinder & specificSurface() const final
Extension of the interface.
Definition: BarrelDetLayer.h:39
TempTrajectory.h
PV3DBase::perp
T perp() const
Definition: PV3DBase.h:69
StopReason::NO_SEGMENTS_FOR_VALID_LAYERS
edm::ConsumesCollector
Definition: ConsumesCollector.h:39
hgcalTopologyTester_cfi.layers
layers
Definition: hgcalTopologyTester_cfi.py:8
PV3DBase::phi
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
CurvilinearTrajectoryError::matrix
const AlgebraicSymMatrix55 & matrix() const
Definition: CurvilinearTrajectoryError.h:61
TrajectoryStateOnSurface::isValid
bool isValid() const
Definition: TrajectoryStateOnSurface.h:54
BaseCkfTrajectoryBuilder::createStartingTrajectory
TempTrajectory createStartingTrajectory(const TrajectorySeed &seed) const
Definition: BaseCkfTrajectoryBuilder.cc:105
Trajectory::isValid
bool isValid() const
Definition: Trajectory.h:257
SurveyInfoScenario_cff.seed
seed
Definition: SurveyInfoScenario_cff.py:295
hit
Definition: SiStripHitEffFromCalibTree.cc:88
edm::OwnVector< TrackingRecHit >
ForwardDetLayer::specificSurface
virtual const BoundDisk & specificSurface() const final
Definition: ForwardDetLayer.h:39
MeasurementTracker.h
IntermediateTrajectoryCleaner::clean
static void clean(TempTrajectoryContainer &tracks)
Definition: IntermediateTrajectoryCleaner.cc:11
HelixBarrelPlaneCrossingByCircle.h
TempTrajectory::empty
bool empty() const
True if trajectory has no measurements.
Definition: TempTrajectory.h:210