CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
IntermediateTrajectoryCleaner.cc
Go to the documentation of this file.
2 #include <algorithm>
3 #include <functional>
4 
5 //#define GIO_WAIT
6 #ifdef GIO_WAIT
7 void IntermediateTrajectoryCleaner::clean(TempTrajectoryContainer &theTrajectories) {}
8 #else
9 
11  if (theTrajectories.empty())
12  return;
13  if (theTrajectories[0].measurements().size() < 4)
14  return;
15 
16  for (TempTrajectoryContainer::iterator firstTraj = theTrajectories.begin(), firstEnd = theTrajectories.end() - 1;
17  firstTraj != firstEnd;
18  ++firstTraj) {
19  if ((!firstTraj->isValid()) || (!firstTraj->lastMeasurement().recHit()->isValid()))
20  continue;
21 
22  TempTrajectory::DataContainer::const_iterator itFirst = firstTraj->measurements().rbegin();
23  ConstRecHitPointer first_hit1 = itFirst->recHit();
24  --itFirst;
25  ConstRecHitPointer first_hit2 = itFirst->recHit();
26  --itFirst;
27  ConstRecHitPointer first_hit3 = itFirst->recHit();
28 
29  bool fh2Valid = first_hit2->isValid();
30 
31  for (TempTrajectoryContainer::iterator secondTraj = (firstTraj + 1), secondEnd = theTrajectories.end();
32  secondTraj != secondEnd;
33  ++secondTraj) {
34  if ((!secondTraj->isValid()) || (!secondTraj->lastMeasurement().recHit()->isValid()))
35  continue;
36 
37  TempTrajectory::DataContainer::const_iterator itSecond = secondTraj->measurements().rbegin();
38  ConstRecHitPointer second_hit1 = itSecond->recHit();
39  --itSecond;
40  ConstRecHitPointer second_hit2 = itSecond->recHit();
41  --itSecond;
42  ConstRecHitPointer second_hit3 = itSecond->recHit();
43 
44  if (&(*first_hit3) == &(*second_hit3)) {
45  if (fh2Valid ^ second_hit2->isValid()) { // ^ = XOR!
46  if (first_hit1->hit()->sharesInput(second_hit1->hit(), TrackingRecHit::all)) {
47  if (!fh2Valid) {
48  firstTraj->invalidate();
49  break;
50  }
51  // else // if (!second_hit2->isValid()) // should be always true, as we did XOR !
52  secondTraj->invalidate();
53  }
54  }
55  }
56  }
57  }
58  theTrajectories.erase(
59  std::remove_if(theTrajectories.begin(), theTrajectories.end(), std::not_fn(&TempTrajectory::isValid)),
60  theTrajectories.end());
61 }
62 #endif
TransientTrackingRecHit::ConstRecHitPointer ConstRecHitPointer
BaseCkfTrajectoryBuilder::TempTrajectoryContainer TempTrajectoryContainer
static void clean(TempTrajectoryContainer &tracks)
bool isValid() const