CMS 3D CMS Logo

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::DTCellSideAssPoint
 
typedef std::set< AssPoint, DTSegmentCand::AssPointLessZAssPointCont
 

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

◆ AssPoint

Definition at line 33 of file DTSegmentCleaner.h.

◆ AssPointCont

Definition at line 34 of file DTSegmentCleaner.h.

Constructor & Destructor Documentation

◆ DTSegmentCleaner()

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

Definition at line 20 of file DTSegmentCleaner.cc.

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 }

References HLT_2018_cff::nSharedHitsMax, HLT_2018_cff::nUnSharedHitsMin, muonDTDigis_cfi::pset, and HLT_2018_cff::segmCleanerMode.

◆ ~DTSegmentCleaner()

DTSegmentCleaner::~DTSegmentCleaner ( )

Definition at line 33 of file DTSegmentCleaner.cc.

33 {}

Member Function Documentation

◆ clean()

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

do the cleaning

Definition at line 36 of file DTSegmentCleaner.cc.

36  {
37  if (inputCands.size() < 2)
38  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;
44 
45  return result;
46 }

References mps_fire::result.

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

◆ ghostBuster()

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

ghost suppression

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

Definition at line 129 of file DTSegmentCleaner.cc.

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

References createfilelist::int, HLT_2018_cff::nSharedHitsMax, HLT_2018_cff::nUnSharedHitsMin, mps_fire::result, and HLT_2018_cff::segmCleanerMode.

◆ solveConflict()

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.

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

References L1TDiffHarvesting_cfi::dir1, L1TDiffHarvesting_cfi::dir2, listHistos::IP, DTSegmentCand::removeHit(), mps_fire::result, HLT_2018_cff::segmCleanerMode, and PV3DBase< T, PVType, FrameType >::theta().

Member Data Documentation

◆ nSharedHitsMax

int DTSegmentCleaner::nSharedHitsMax
private

Definition at line 53 of file DTSegmentCleaner.h.

◆ nUnSharedHitsMin

int DTSegmentCleaner::nUnSharedHitsMin
private

Definition at line 54 of file DTSegmentCleaner.h.

◆ segmCleanerMode

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 58 of file DTSegmentCleaner.h.

Vector3DBase< float, LocalTag >
L1TDiffHarvesting_cfi.dir2
dir2
Definition: L1TDiffHarvesting_cfi.py:12
DTSegmentCleaner::segmCleanerMode
int segmCleanerMode
Definition: DTSegmentCleaner.h:58
DTSegmentCleaner::solveConflict
std::vector< DTSegmentCand * > solveConflict(const std::vector< DTSegmentCand * > &inputCands) const
solve the conflicts
Definition: DTSegmentCleaner.cc:48
DTSegmentCleaner::nSharedHitsMax
int nSharedHitsMax
Definition: DTSegmentCleaner.h:53
PV3DBase::theta
Geom::Theta< T > theta() const
Definition: PV3DBase.h:72
DTSegmentCleaner::nUnSharedHitsMin
int nUnSharedHitsMin
Definition: DTSegmentCleaner.h:54
DTSegmentCand
Definition: DTSegmentCand.h:34
L1TDiffHarvesting_cfi.dir1
dir1
Definition: L1TDiffHarvesting_cfi.py:10
DTSegmentCleaner::ghostBuster
std::vector< DTSegmentCand * > ghostBuster(const std::vector< DTSegmentCand * > &inputCands) const
ghost suppression
Definition: DTSegmentCleaner.cc:129
Point3DBase< float, GlobalTag >
listHistos.IP
IP
Definition: listHistos.py:76
edm::LogError
Definition: MessageLogger.h:183
cand
Definition: decayParser.h:34
createfilelist.int
int
Definition: createfilelist.py:10
DTSegmentCand::AssPointCont
std::set< AssPoint, AssPointLessZ > AssPointCont
Definition: DTSegmentCand.h:38
DTSegmentCand::removeHit
virtual void removeHit(AssPoint hit)
remove hit from the candidate
Definition: DTSegmentCand.cc:65
mps_fire.result
result
Definition: mps_fire.py:303
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27