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(), DTCombinatorialExtendedPatternReco::buildSegments(), and DTMeantimerPatternReco::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  //cout << "[DTSegmentCleaner] to ghostbuster: " << result.size() << endl;
43  result = ghostBuster(result);
44 
45  return result;
46 }
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

cout << "Sharing " << (**cand) << " " << (**cand2) << " " << nSharedHits

Definition at line 135 of file DTSegmentCleaner.cc.

References query::result.

135  {
136  vector<DTSegmentCand*> ghosts;
137  for (vector<DTSegmentCand*>::const_iterator cand=inputCands.begin();
138  cand!=inputCands.end(); ++cand) {
139  for (vector<DTSegmentCand*>::const_iterator cand2=cand+1;
140  cand2!=inputCands.end(); ++cand2) {
141  unsigned int nSharedHits=(*cand)->nSharedHitPairs(*(*cand2));
143  // << " (first or second) " << ((**cand)<(**cand2)) << endl;
144  if ((nSharedHits==((*cand)->nHits())) && (nSharedHits==((*cand2)->nHits()))
145  &&(fabs((*cand)->chi2()-(*cand2)->chi2())<0.1)
146  &&(segmCleanerMode==3))
147  {
148  continue;
149  }
150 
151  if (((*cand)->nHits()==3 || (*cand2)->nHits()==3)
152  &&(fabs((*cand)->chi2()-(*cand2)->chi2())<0.0001))
153  {
154  continue;
155  }
156 
157  // if one segment is in-time and the other not then keep both
158  if (((*cand2)->nHits()==(*cand)->nHits()) && ((*cand)->t0()*(*cand2)->t0()==0) && ((*cand)->t0()!=(*cand2)->t0()))
159  {
160  continue;
161  }
162 
163  // remove the worst segment if too many shared hits or too few unshared
164  if ((int)nSharedHits >= nSharedHitsMax ||
165  (int)((*cand)->nHits()-nSharedHits)<=nUnSharedHitsMin ||
166  (int)((*cand2)->nHits()-nSharedHits)<=nUnSharedHitsMin) {
167 
168  if ((**cand)<(**cand2)) {
169  ghosts.push_back(*cand);
170  }
171  else {
172  ghosts.push_back(*cand2);
173  }
174  continue;
175  }
176 
177  }
178  }
179 
180  vector<DTSegmentCand*> result;
181  for (vector<DTSegmentCand*>::const_iterator cand=inputCands.begin();
182  cand!=inputCands.end(); ++cand) {
183  bool isGhost=false;
184  for (vector<DTSegmentCand*>::const_iterator ghost=ghosts.begin();
185  ghost!=ghosts.end(); ++ghost) {
186  if ((*cand)==(*ghost)) {
187  isGhost=true;
188  break;
189  }
190  }
191  if (!isGhost) result.push_back(*cand);
192  else delete *cand;
193  }
194  // cout << "No Ghosts ------" << endl;
195  // for (vector<DTSegmentCand*>::iterator cand=result.begin();
196  // cand!=result.end(); ++cand) {
197  // cout << "cand " << *cand << " nH " <<(*cand)->nHits() << " chi2 " << (*cand)->chi2() << endl;
198  // }
199  // cout << "----------------" << endl;
200 
201  return result;
202 }
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 48 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().

48  {
49  vector<DTSegmentCand*> result;
50 
51  vector<DTSegmentCand*> ghosts;
52 
53 
54  for (vector<DTSegmentCand*>::const_iterator cand=inputCands.begin();
55  cand!=inputCands.end(); ++cand) {
56  for (vector<DTSegmentCand*>::const_iterator cand2 = cand+1 ; cand2!=inputCands.end() ; ++cand2) {
57 
58  DTSegmentCand::AssPointCont confHits=(*cand)->conflictingHitPairs(*(*cand2));
59 
60  if (confHits.size()) {
64  if((confHits.size())==((*cand)->nHits()) && (confHits.size())==((*cand2)->nHits())
65  && (fabs((*cand)->chi2()-(*cand2)->chi2())<0.1)) { // cannot choose on the basis of # of hits or chi2
66 
67  if(segmCleanerMode == 2) { // mode 2: choose on the basis of the angle
68 
69  DTSegmentCand* badCand = 0;
70  if((*cand)->superLayer()->id().superlayer() != 2) { // we are in the phi view
71 
72  LocalVector dir1 = (*cand)->direction();
73  LocalVector dir2 = (*cand2)->direction();
74  float phi1=(atan((dir1.x())/(dir1.z())));
75  float phi2=(atan((dir2.x())/(dir2.z())));
76 
77  badCand = (fabs(phi1) > fabs(phi2)) ? (*cand) : (*cand2);
78 
79  } else { // we are in the theta view: choose the most pointing one
80 
82 
83  GlobalVector cand1GlobDir = (*cand)->superLayer()->toGlobal((*cand)->direction());
84  GlobalPoint cand1GlobPos = (*cand)->superLayer()->toGlobal((*cand)->position());
85  GlobalVector cand1GlobVecIP = cand1GlobPos-IP;
86  float DAlpha1 = fabs(cand1GlobDir.theta()-cand1GlobVecIP.theta());
87 
88 
89  GlobalVector cand2GlobDir = (*cand2)->superLayer()->toGlobal((*cand2)->direction());
90  GlobalPoint cand2GlobPos = (*cand2)->superLayer()->toGlobal((*cand2)->position());
91  GlobalVector cand2GlobVecIP = cand2GlobPos-IP;
92  float DAlpha2 = fabs(cand2GlobDir.theta()-cand2GlobVecIP.theta());
93 
94  badCand = (DAlpha1 > DAlpha2) ? (*cand) : (*cand2);
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  //cout << " Choose based on hits/chi2. " << endl << (**cand) << " vs " << (**cand2) << endl;
108 
109  // if one segment is in-time and the other not then keep both
110  if (((*cand)->t0()*(*cand2)->t0()!=0) || ((*cand)->t0()==(*cand2)->t0())) {
111  DTSegmentCand* badCand = (**cand) < (**cand2) ? (*cand) : (*cand2);
112  //cout << " Remove hits in " << (*badCand) << endl;
113  for (DTSegmentCand::AssPointCont::const_iterator cHit=confHits.begin() ;
114  cHit!=confHits.end(); ++cHit) badCand->removeHit(*cHit);
115  }
116  }
117 
118  }
119  }
120  }
121 
122  vector<DTSegmentCand*>::const_iterator cand=inputCands.begin();
123  while ( cand < inputCands.end() ) {
124  if ((*cand)->good()) result.push_back(*cand);
125  else {
126  vector<DTSegmentCand*>::const_iterator badCand=cand;
127  delete *badCand;
128  }
129  ++cand;
130  }
131  return result;
132 }
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:40
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.