CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Attributes
TrajectoryCleanerBySharedHits Class Reference

#include <TrajectoryCleanerBySharedHits.h>

Inheritance diagram for TrajectoryCleanerBySharedHits:
TrajectoryCleaner

Public Types

typedef std::vector< Trajectory * > TrajectoryPointerContainer
 
- Public Types inherited from TrajectoryCleaner
typedef TrackingComponentsRecord Record
 
using TempTrajectoryContainer = std::vector< TempTrajectory >
 
typedef std::vector< TrajectoryTrajectoryContainer
 
typedef TrajectoryContainer::iterator TrajectoryIterator
 
typedef std::vector< Trajectory * > TrajectoryPointerContainer
 
typedef TrajectoryPointerContainer::iterator TrajectoryPointerIterator
 

Public Member Functions

virtual void clean (TempTrajectoryContainer &) const
 
virtual void clean (TrajectoryPointerContainer &) const=0
 
virtual void clean (TrajectoryContainer &) const
 
void clean (TrajectoryPointerContainer &) const override
 
 TrajectoryCleanerBySharedHits ()
 
 TrajectoryCleanerBySharedHits (const edm::ParameterSet &iConfig)
 
 ~TrajectoryCleanerBySharedHits () override
 
- Public Member Functions inherited from TrajectoryCleaner
virtual void clean (TempTrajectoryContainer &) const
 
virtual void clean (TrajectoryContainer &) const
 
 TrajectoryCleaner ()
 
 TrajectoryCleaner (edm::ParameterSet &iConfig)
 
virtual ~TrajectoryCleaner ()
 

Private Attributes

bool allowSharedFirstHit
 
float missingHitPenalty_
 
float theFraction
 
float validHitBonus_
 

Detailed Description

A concrete TrajectoryCleaner that considers two trajectories to be mutually exclusive if they share more than some fraction of their hits. The "best" trajectory of each set of mutually exclusive ones is kept, the others are eliminated. The goodness of a track is defined in terms of Chi^2, number of reconstructed hits, and number of lost hits.

Definition at line 15 of file TrajectoryCleanerBySharedHits.h.

Member Typedef Documentation

◆ TrajectoryPointerContainer

Definition at line 17 of file TrajectoryCleanerBySharedHits.h.

Constructor & Destructor Documentation

◆ TrajectoryCleanerBySharedHits() [1/2]

TrajectoryCleanerBySharedHits::TrajectoryCleanerBySharedHits ( )
inline

◆ TrajectoryCleanerBySharedHits() [2/2]

TrajectoryCleanerBySharedHits::TrajectoryCleanerBySharedHits ( const edm::ParameterSet iConfig)
inline

Definition at line 21 of file TrajectoryCleanerBySharedHits.h.

22  : theFraction(iConfig.getParameter<double>("fractionShared")),
23  validHitBonus_(iConfig.getParameter<double>("ValidHitBonus")),
24  missingHitPenalty_(iConfig.getParameter<double>("MissingHitPenalty")),
25  allowSharedFirstHit(iConfig.getParameter<bool>("allowSharedFirstHit")) {}
T getParameter(std::string const &) const
Definition: ParameterSet.h:307

◆ ~TrajectoryCleanerBySharedHits()

TrajectoryCleanerBySharedHits::~TrajectoryCleanerBySharedHits ( )
inlineoverride

Definition at line 27 of file TrajectoryCleanerBySharedHits.h.

27 {};

Member Function Documentation

◆ clean() [1/4]

void TrajectoryCleaner::clean

Definition at line 5 of file TrajectoryCleaner.cc.

5  {
6  edm::LogError("TrajectoryCleaner") << "not implemented for TempTrajectory";
7  assert(false);
8 }
Log< level::Error, false > LogError
assert(be >=bs)

◆ clean() [2/4]

virtual void TrajectoryCleaner::clean

◆ clean() [3/4]

void TrajectoryCleaner::clean

Definition at line 10 of file TrajectoryCleaner.cc.

10  {
11  TrajectoryPointerContainer thePointerContainer;
12  thePointerContainer.reserve(tc.size());
13  for (TrajectoryCleaner::TrajectoryIterator it = tc.begin(); it != tc.end(); it++) {
14  thePointerContainer.push_back(&(*it));
15  }
16 
17  clean(thePointerContainer);
18 }
void clean(TrajectoryPointerContainer &) const override
std::vector< Trajectory * > TrajectoryPointerContainer
TrajectoryContainer::iterator TrajectoryIterator

◆ clean() [4/4]

void TrajectoryCleanerBySharedHits::clean ( TrajectoryPointerContainer tc) const
overridevirtual

Implements TrajectoryCleaner.

Definition at line 42 of file TrajectoryCleanerBySharedHits.cc.

References HLT_2024v11_cff::allowSharedFirstHit, alongMomentum, gather_cfg::cout, DEBUG_PRINT, TrackingRecHit::geographicalId(), TrackingRecHit::hit(), Trajectory::invalidate(), ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, SiStripPI::min, mkfit::Config::missingHitPenalty_, rpcPointValidation_cfi::recHit, offlineSlimmedPrimaryVertices_cfi::score, TrackingRecHit::sharesInput(), TrackingRecHit::some, submitPVValidationJobs::t, and mkfit::Config::validHitBonus_.

Referenced by InOutConversionTrackFinder::tracks(), and OutInConversionTrackFinder::tracks().

42  {
43  if (tc.size() <= 1)
44  return; // nothing to clean
45 
46  auto &theRecHitMap = theMaps.theRecHitMap;
47 
48  theRecHitMap.clear(10 * tc.size()); // set 10*tc.size() active buckets
49  // numbers are not optimized
50 
51  DEBUG_PRINT(std::cout << "Filling RecHit map" << std::endl);
52  for (auto const &it : tc) {
53  DEBUG_PRINT(std::cout << " Processing trajectory " << it << " (" << it->foundHits() << " valid hits)"
54  << std::endl);
55  auto const &pd = it->measurements();
56  for (auto const &im : pd) {
57  auto theRecHit = &(*im.recHit());
58  if (theRecHit->isValid()) {
59  DEBUG_PRINT(std::cout << " Added hit " << theRecHit << " for trajectory " << it << std::endl);
60  theRecHitMap.insert(theRecHit, it);
61  }
62  }
63  }
64  DEBUG_PRINT(theRecHitMap.dump());
65 
66  DEBUG_PRINT(std::cout << "Using RecHit map" << std::endl);
67  // for each trajectory fill theTrajMap
68  auto &theTrajMap = theMaps.theTrajMap;
69  for (auto const &itt : tc) {
70  if (itt->isValid()) {
71  DEBUG_PRINT(std::cout << " Processing trajectory " << itt << " (" << itt->foundHits() << " valid hits)"
72  << std::endl);
73  theTrajMap.clear();
74  const Trajectory::DataContainer &pd = itt->measurements();
75  for (auto const &im : pd) {
76  auto theRecHit = &(*im.recHit());
77  if (theRecHit->isValid()) {
78  DEBUG_PRINT(std::cout << " Searching for overlaps on hit " << theRecHit << " for trajectory " << itt
79  << std::endl);
80  for (RecHitMap::value_iterator ivec = theRecHitMap.values(theRecHit); ivec.good(); ++ivec) {
81  if (*ivec != itt) {
82  if ((*ivec)->isValid()) {
83  theTrajMap[*ivec]++;
84  }
85  }
86  }
87  }
88  }
89  //end filling theTrajMap
90 
91  auto score = [&](Trajectory const &t) -> float {
92  // possible variant under study
93  // auto ns = t.foundHits()-t.trailingFoundHits();
94  //auto penalty = 0.8f*missingHitPenalty_;
95  // return validHitBonus_*(t.foundHits()-0.2f*t.cccBadHits()) - penalty*t.lostHits() - t.chiSquared();
96  // classical score
97  return validHitBonus_ * t.foundHits() - missingHitPenalty_ * t.lostHits() - t.chiSquared();
98  };
99 
100  // check for duplicated tracks
101  if (!theTrajMap.empty() > 0) {
102  for (auto const &imapp : theTrajMap) {
103  if (imapp.second > 0) { // at least 1 hits in common!!!
104  int innerHit = 0;
105  if (allowSharedFirstHit) {
106  const TrajectoryMeasurement &innerMeasure1 =
107  (itt->direction() == alongMomentum) ? itt->firstMeasurement() : itt->lastMeasurement();
108  const TransientTrackingRecHit *h1 = &(*(innerMeasure1).recHit());
109  const TrajectoryMeasurement &innerMeasure2 = (imapp.first->direction() == alongMomentum)
110  ? imapp.first->firstMeasurement()
111  : imapp.first->lastMeasurement();
112  const TransientTrackingRecHit *h2 = &(*(innerMeasure2).recHit());
113  if ((h1 == h2) || ((h1->geographicalId() == h2->geographicalId()) &&
114  (h1->hit()->sharesInput(h2->hit(), TrackingRecHit::some)))) {
115  innerHit = 1;
116  }
117  }
118  int nhit1 = itt->foundHits();
119  int nhit2 = imapp.first->foundHits();
120  if ((imapp.second - innerHit) >= ((min(nhit1, nhit2) - innerHit) * theFraction)) {
121  Trajectory *badtraj;
122  auto score1 = score(*itt);
123  auto score2 = score(*imapp.first);
124  badtraj = (score1 > score2) ? imapp.first : itt;
125  badtraj->invalidate(); // invalidate this trajectory
126  }
127  }
128  }
129  }
130  }
131  }
132 }
void invalidate()
Method to invalidate a trajectory. Useful during ambiguity resolution.
Definition: Trajectory.h:260
virtual bool sharesInput(const TrackingRecHit *other, SharedInputType what) const
std::vector< TrajectoryMeasurement > DataContainer
Definition: Trajectory.h:40
#define DEBUG_PRINT(X)
DetId geographicalId() const
virtual TrackingRecHit const * hit() const

Member Data Documentation

◆ allowSharedFirstHit

bool TrajectoryCleanerBySharedHits::allowSharedFirstHit
private

Definition at line 36 of file TrajectoryCleanerBySharedHits.h.

◆ missingHitPenalty_

float TrajectoryCleanerBySharedHits::missingHitPenalty_
private

Definition at line 35 of file TrajectoryCleanerBySharedHits.h.

◆ theFraction

float TrajectoryCleanerBySharedHits::theFraction
private

Definition at line 33 of file TrajectoryCleanerBySharedHits.h.

◆ validHitBonus_

float TrajectoryCleanerBySharedHits::validHitBonus_
private

Definition at line 34 of file TrajectoryCleanerBySharedHits.h.