CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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
 
typedef std::vector< TrajectoryTrajectoryContainer
 
typedef
TrajectoryContainer::iterator 
TrajectoryIterator
 
typedef std::vector< Trajectory * > TrajectoryPointerContainer
 
typedef
TrajectoryPointerContainer::iterator 
TrajectoryPointerIterator
 

Public Member Functions

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

Private Attributes

bool allowSharedFirstHit
 
double missingHitPenalty_
 
double theFraction
 
double 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 16 of file TrajectoryCleanerBySharedHits.h.

Member Typedef Documentation

Definition at line 20 of file TrajectoryCleanerBySharedHits.h.

Constructor & Destructor Documentation

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

Definition at line 27 of file TrajectoryCleanerBySharedHits.h.

27  :
28  theFraction(iConfig.getParameter<double>("fractionShared")),
29  validHitBonus_(iConfig.getParameter<double>("ValidHitBonus")),
30  missingHitPenalty_(iConfig.getParameter<double>("MissingHitPenalty")),
31  allowSharedFirstHit(iConfig.getParameter<bool>("allowSharedFirstHit")){}
T getParameter(std::string const &) const
virtual TrajectoryCleanerBySharedHits::~TrajectoryCleanerBySharedHits ( )
inlinevirtual

Definition at line 33 of file TrajectoryCleanerBySharedHits.h.

33 {};

Member Function Documentation

void TrajectoryCleanerBySharedHits::clean ( TrajectoryPointerContainer tc) const
virtual

Implements TrajectoryCleaner.

Definition at line 41 of file TrajectoryCleanerBySharedHits.cc.

References HLT_FULL_cff::allowSharedFirstHit, alongMomentum, gather_cfg::cout, DEBUG_PRINT, TrackingRecHit::geographicalId(), TrackingRecHit::hit(), Trajectory::invalidate(), TrackingRecHit::isValid(), Trajectory::lostHits(), min(), TrackingRecHit::sharesInput(), and TrackingRecHit::some.

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

42 {
43  if (tc.size() <= 1) return; // nothing to clean
44 
45  auto & theRecHitMap = theMaps.theRecHitMap;
46 
47  theRecHitMap.clear(10*tc.size()); // set 10*tc.size() active buckets
48  // numbers are not optimized
49 
50  DEBUG_PRINT(std::cout << "Filling RecHit map" << std::endl);
51  for (TrajectoryPointerContainer::iterator
52  it = tc.begin(); it != tc.end(); ++it) {
53  DEBUG_PRINT(std::cout << " Processing trajectory " << *it << " (" << (*it)->foundHits() << " valid hits)" << std::endl);
54  const Trajectory::DataContainer & pd = (*it)->measurements();
55  for (Trajectory::DataContainer::const_iterator im = pd.begin();
56  im != pd.end(); im++) {
57  const TransientTrackingRecHit* 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;
70  itt = tc.begin(); itt != tc.end(); ++itt) {
71  if((*itt)->isValid()){
72  DEBUG_PRINT(std::cout << " Processing trajectory " << *itt << " (" << (*itt)->foundHits() << " valid hits)" << std::endl);
73  theTrajMap.clear();
74  const Trajectory::DataContainer & pd = (*itt)->measurements();
75  for (Trajectory::DataContainer::const_iterator im = pd.begin();
76  im != pd.end(); ++im) {
77  //RC const TransientTrackingRecHit* theRecHit = ((*im).recHit());
78  const TransientTrackingRecHit* theRecHit = &(*(*im).recHit());
79  if (theRecHit->isValid()) {
80  DEBUG_PRINT(std::cout << " Searching for overlaps on hit " << theRecHit << " for trajectory " << *itt << std::endl);
81  for (RecHitMap::value_iterator ivec = theRecHitMap.values(theRecHit);
82  ivec.good(); ++ivec) {
83  if (*ivec != *itt){
84  if ((*ivec)->isValid()){
85  theTrajMap[*ivec]++;
86  }
87  }
88  }
89  }
90  }
91  //end filling theTrajMap
92 
93  // check for duplicated tracks
94  if(!theTrajMap.empty() > 0){
95  for(TrajMap::iterator imapp = theTrajMap.begin();
96  imapp != theTrajMap.end(); ++imapp){
97  if((*imapp).second > 0 ){
98  int innerHit = 0;
99  if ( allowSharedFirstHit ) {
100  const TrajectoryMeasurement & innerMeasure1 = ( (*itt)->direction() == alongMomentum ) ?
101  (*itt)->firstMeasurement() : (*itt)->lastMeasurement();
102  const TransientTrackingRecHit* h1 = &(*(innerMeasure1).recHit());
103  const TrajectoryMeasurement & innerMeasure2 = ( (*imapp).first->direction() == alongMomentum ) ?
104  (*imapp).first->firstMeasurement() : (*imapp).first->lastMeasurement();
105  const TransientTrackingRecHit* h2 = &(*(innerMeasure2).recHit());
106  if ( (h1 == h2) || ((h1->geographicalId() == h2->geographicalId()) &&
107  (h1->hit()->sharesInput(h2->hit(), TrackingRecHit::some))) ) {
108  innerHit = 1;
109  }
110  }
111  int nhit1 = (*itt)->foundHits();
112  int nhit2 = (*imapp).first->foundHits();
113  if( ((*imapp).second - innerHit) >= ( (min(nhit1, nhit2)-innerHit) * theFraction) ){
114  Trajectory* badtraj;
115  double score1 = validHitBonus_*nhit1 - missingHitPenalty_*(*itt)->lostHits() - (*itt)->chiSquared();
116  double score2 = validHitBonus_*nhit2 - missingHitPenalty_*(*imapp).first->lostHits() - (*imapp).first->chiSquared();
117  badtraj = (score1 > score2) ? (*imapp).first : *itt;
118  badtraj->invalidate(); // invalidate this trajectory
119  }
120  }
121  }
122  }
123  }
124  }
125 }
TrajectoryPointerContainer::iterator TrajectoryPointerIterator
void invalidate()
Method to invalidate a trajectory. Useful during ambiguity resolution.
Definition: Trajectory.h:327
virtual bool sharesInput(const TrackingRecHit *other, SharedInputType what) const
std::vector< TrajectoryMeasurement > DataContainer
Definition: Trajectory.h:44
#define DEBUG_PRINT(X)
T min(T a, T b)
Definition: MathUtil.h:58
virtual TrackingRecHit const * hit() const
bool isValid() const
tuple cout
Definition: gather_cfg.py:145
DetId geographicalId() const

Member Data Documentation

bool TrajectoryCleanerBySharedHits::allowSharedFirstHit
private

Definition at line 42 of file TrajectoryCleanerBySharedHits.h.

double TrajectoryCleanerBySharedHits::missingHitPenalty_
private

Definition at line 41 of file TrajectoryCleanerBySharedHits.h.

double TrajectoryCleanerBySharedHits::theFraction
private

Definition at line 39 of file TrajectoryCleanerBySharedHits.h.

double TrajectoryCleanerBySharedHits::validHitBonus_
private

Definition at line 40 of file TrajectoryCleanerBySharedHits.h.