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 Member Functions | Private Attributes
DTSegmentCleaner Class Reference

#include <DTSegmentCleaner.h>

Public Types

typedef std::pair
< DTHitPairForFit
*, DTEnums::DTCellSide
AssPoint
 
typedef std::set< AssPoint,
DTSegmentCand::AssPointLessZ
AssPointCont
 

Public Member Functions

std::vector< DTSegmentCand * > clean (std::vector< DTSegmentCand * > inputCands) const
 do the cleaning More...
 
 DTSegmentCleaner (const edm::ParameterSet &pset)
 
 ~DTSegmentCleaner ()
 

Private Member Functions

std::vector< DTSegmentCand * > ghostBuster (std::vector< DTSegmentCand * > inputCands) const
 ghost suppression More...
 
std::vector< DTSegmentCand * > solveConflict (std::vector< DTSegmentCand * > inputCands) const
 solve the conflicts More...
 

Private Attributes

int nSharedHitsMax
 
int nUnSharedHitsMin
 
int segmCleanerMode
 

Detailed Description

Definition at line 33 of file DTSegmentCleaner.h.

Member Typedef Documentation

Definition at line 37 of file DTSegmentCleaner.h.

Definition at line 38 of file DTSegmentCleaner.h.

Constructor & Destructor Documentation

DTSegmentCleaner::DTSegmentCleaner ( const edm::ParameterSet pset)

Definition at line 22 of file DTSegmentCleaner.cc.

References edm::ParameterSet::getParameter().

22  {
23  nSharedHitsMax = pset.getParameter<int>("nSharedHitsMax");
24 
25  nUnSharedHitsMin = pset.getParameter<int>("nUnSharedHitsMin");
26 
27  segmCleanerMode = pset.getParameter<int>("segmCleanerMode");
28 
29  if((segmCleanerMode!=1)&&(segmCleanerMode!=2)&&(segmCleanerMode!=3))
30  edm::LogError("Muon|RecoLocalMuon|DTSegmentCleaner")
31  << "Wrong segmCleanerMode! It must be 1,2 or 3. The default is 1";
32 }
T getParameter(std::string const &) const
DTSegmentCleaner::~DTSegmentCleaner ( )

Definition at line 35 of file DTSegmentCleaner.cc.

35  {
36 }

Member Function Documentation

vector< DTSegmentCand * > DTSegmentCleaner::clean ( std::vector< DTSegmentCand * >  inputCands) const

do the cleaning

Definition at line 39 of file DTSegmentCleaner.cc.

References query::result.

Referenced by DTCombinatorialPatternReco::buildSegments(), DTMeantimerPatternReco::buildSegments(), and DTCombinatorialExtendedPatternReco::buildSegments().

39  {
40  if (inputCands.size()<2) return inputCands;
41  // cout << "[DTSegmentCleaner] # of candidates: " << inputCands.size() << endl;
42  vector<DTSegmentCand*> result = solveConflict(inputCands);
43 
44  result = ghostBuster(result);
45 
46  return result;
47 }
std::vector< DTSegmentCand * > solveConflict(std::vector< DTSegmentCand * > inputCands) const
solve the conflicts
tuple result
Definition: query.py:137
std::vector< DTSegmentCand * > ghostBuster(std::vector< DTSegmentCand * > inputCands) const
ghost suppression
vector< DTSegmentCand * > DTSegmentCleaner::ghostBuster ( std::vector< DTSegmentCand * >  inputCands) const
private

ghost suppression

Definition at line 132 of file DTSegmentCleaner.cc.

References query::result.

132  {
133  vector<DTSegmentCand*> ghosts;
134  for (vector<DTSegmentCand*>::iterator cand=inputCands.begin();
135  cand!=inputCands.end(); ++cand) {
136  for (vector<DTSegmentCand*>::iterator cand2=cand+1;
137  cand2!=inputCands.end(); ++cand2) {
138  unsigned int nSharedHits=(*cand)->nSharedHitPairs(*(*cand2));
139  // cout << "Sharing " << (**cand) << " " << (**cand2) << " " << nSharedHits
140  // << " (first or second) " << ((**cand)<(**cand2)) << endl;
141  if ((nSharedHits==((*cand)->nHits())) && (nSharedHits==((*cand2)->nHits()))
142  &&(fabs((*cand)->chi2()-(*cand2)->chi2())<0.1)
143  &&(segmCleanerMode==3))
144  {
145  continue;
146  }
147 
148  // remove the worst segment if too many shared hits or too few unshared
149  if ((int)nSharedHits >= nSharedHitsMax ||
150  (int)((*cand)->nHits()-nSharedHits)<=nUnSharedHitsMin ||
151  (int)((*cand2)->nHits()-nSharedHits)<=nUnSharedHitsMin) {
152 
153  if ((**cand)<(**cand2)) {
154  ghosts.push_back(*cand);
155  }
156  else {
157  ghosts.push_back(*cand2);
158  }
159  continue;
160  }
161 
162  }
163  }
164 
165  vector<DTSegmentCand*> result;
166  for (vector<DTSegmentCand*>::const_iterator cand=inputCands.begin();
167  cand!=inputCands.end(); ++cand) {
168  bool isGhost=false;
169  for (vector<DTSegmentCand*>::const_iterator ghost=ghosts.begin();
170  ghost!=ghosts.end(); ++ghost) {
171  if ((*cand)==(*ghost)) {
172  isGhost=true;
173  break;
174  }
175  }
176  if (!isGhost) result.push_back(*cand);
177  else delete *cand;
178  }
179  // cout << "No Ghosts ------" << endl;
180  // for (vector<DTSegmentCand*>::iterator cand=result.begin();
181  // cand!=result.end(); ++cand) {
182  // cout << "cand " << *cand << " nH " <<(*cand)->nHits() << " chi2 " << (*cand)->chi2() << endl;
183  // }
184  // cout << "----------------" << endl;
185 
186  return result;
187 }
tuple result
Definition: query.py:137
vector< DTSegmentCand * > DTSegmentCleaner::solveConflict ( std::vector< DTSegmentCand * >  inputCands) const
private

solve the conflicts

treatment of LR ambiguity cases: 1 chooses the best chi2 2 chooses the smaller angle 3 keeps both candidates

Definition at line 49 of file DTSegmentCleaner.cc.

References GetRecoTauVFromDQM_MC_cff::dir2, DTSegmentCand::removeHit(), query::result, PV3DBase< T, PVType, FrameType >::theta(), PV3DBase< T, PVType, FrameType >::x(), and PV3DBase< T, PVType, FrameType >::z().

49  {
50  vector<DTSegmentCand*> result;
51 
52  vector<DTSegmentCand*> ghosts;
53 
54 
55  for (vector<DTSegmentCand*>::iterator cand=inputCands.begin();
56  cand!=inputCands.end(); ++cand) {
57  for (vector<DTSegmentCand*>::iterator cand2 = cand+1 ; cand2!=inputCands.end() ; ++cand2) {
58 
59  DTSegmentCand::AssPointCont confHits=(*cand)->conflictingHitPairs(*(*cand2));
60 
61  if (confHits.size()) {
65  if((confHits.size())==((*cand)->nHits()) && (confHits.size())==((*cand2)->nHits())
66  && (fabs((*cand)->chi2()-(*cand2)->chi2())<0.1) ) { // cannot choose on the basis of # of hits or chi2
67 
68  if(segmCleanerMode == 2) { // mode 2: choose on the basis of the angle
69 
70  DTSegmentCand* badCand = 0;
71  if((*cand)->superLayer()->id().superlayer() != 2) { // we are in the phi view
72 
73  LocalVector dir1 = (*cand)->direction();
74  LocalVector dir2 = (*cand2)->direction();
75  float phi1=(atan((dir1.x())/(dir1.z())));
76  float phi2=(atan((dir2.x())/(dir2.z())));
77 
78  badCand = (fabs(phi1) > fabs(phi2)) ? (*cand) : (*cand2);
79 
80  } else { // we are in the theta view: choose the most pointing one
81 
82  GlobalPoint IP;
83 
84  GlobalVector cand1GlobDir = (*cand)->superLayer()->toGlobal((*cand)->direction());
85  GlobalPoint cand1GlobPos = (*cand)->superLayer()->toGlobal((*cand)->position());
86  GlobalVector cand1GlobVecIP = cand1GlobPos-IP;
87  float DAlpha1 = fabs(cand1GlobDir.theta()-cand1GlobVecIP.theta());
88 
89 
90  GlobalVector cand2GlobDir = (*cand2)->superLayer()->toGlobal((*cand2)->direction());
91  GlobalPoint cand2GlobPos = (*cand2)->superLayer()->toGlobal((*cand2)->position());
92  GlobalVector cand2GlobVecIP = cand2GlobPos-IP;
93  float DAlpha2 = fabs(cand2GlobDir.theta()-cand2GlobVecIP.theta());
94 
95  badCand = (DAlpha1 > DAlpha2) ? (*cand) : (*cand2);
96 
97  }
98 
99  for (DTSegmentCand::AssPointCont::const_iterator cHit=confHits.begin() ;
100  cHit!=confHits.end(); ++cHit) {
101  badCand->removeHit(*cHit);
102  }
103 
104  } else { // mode 3: keep both candidates
105  continue;
106  }
107 
108  } else { // mode 1: take > # hits or best chi2
109  DTSegmentCand* badCand = (**cand) < (**cand2) ? (*cand) : (*cand2);
110  for (DTSegmentCand::AssPointCont::const_iterator cHit=confHits.begin() ;
111  cHit!=confHits.end(); ++cHit) badCand->removeHit(*cHit);
112  }
113 
114  }
115  }
116  }
117 
118 
119  vector<DTSegmentCand*>::iterator cand=inputCands.begin();
120  while ( cand < inputCands.end() ) {
121  if ((*cand)->good()) result.push_back(*cand);
122  else {
123  vector<DTSegmentCand*>::iterator badCand=cand;
124  delete *badCand;
125  }
126  ++cand;
127  }
128  return result;
129 }
Geom::Theta< T > theta() const
Definition: PV3DBase.h:74
T z() const
Definition: PV3DBase.h:63
tuple result
Definition: query.py:137
std::set< AssPoint, AssPointLessZ > AssPointCont
Definition: DTSegmentCand.h:41
virtual void removeHit(AssPoint hit)
remove hit from the candidate
T x() const
Definition: PV3DBase.h:61

Member Data Documentation

int DTSegmentCleaner::nSharedHitsMax
private

Definition at line 57 of file DTSegmentCleaner.h.

int DTSegmentCleaner::nUnSharedHitsMin
private

Definition at line 58 of file DTSegmentCleaner.h.

int DTSegmentCleaner::segmCleanerMode
private

treatment of LR ambiguity cases: 1 chooses the best chi2 2 chooses the smaller angle 3 keeps both candidates

Definition at line 62 of file DTSegmentCleaner.h.