CMS 3D CMS Logo

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