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 (const std::vector< DTSegmentCand * > &inputCands) const
 do the cleaning More...
 
 DTSegmentCleaner (const edm::ParameterSet &pset)
 
 ~DTSegmentCleaner ()
 

Private Member Functions

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

Private Attributes

int nSharedHitsMax
 
int nUnSharedHitsMin
 
int segmCleanerMode
 

Detailed Description

Definition at line 31 of file DTSegmentCleaner.h.

Member Typedef Documentation

Definition at line 35 of file DTSegmentCleaner.h.

Definition at line 36 of file DTSegmentCleaner.h.

Constructor & Destructor Documentation

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

Definition at line 20 of file DTSegmentCleaner.cc.

References edm::ParameterSet::getParameter().

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

Definition at line 33 of file DTSegmentCleaner.cc.

33  {
34 }

Member Function Documentation

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

do the cleaning

Definition at line 37 of file DTSegmentCleaner.cc.

References query::result.

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

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

ghost suppression

Definition at line 130 of file DTSegmentCleaner.cc.

References query::result.

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

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

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

Member Data Documentation

int DTSegmentCleaner::nSharedHitsMax
private

Definition at line 55 of file DTSegmentCleaner.h.

int DTSegmentCleaner::nUnSharedHitsMin
private

Definition at line 56 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 60 of file DTSegmentCleaner.h.