CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DTSegmentCand.cc
Go to the documentation of this file.
1 
9 /* This Class Header */
11 
15 
16 /* Collaborating Class Header */
17 
18 /* C++ Headers */
19 
20 /* ====================================================================== */
21 double DTSegmentCand::chi2max=20.; // to be tuned!!
22 unsigned int DTSegmentCand::nHitsMin=3; // to be tuned!!
23 
26  const DTSuperLayer* sl) :
27 theSL(sl), theChi2(-1.) , theHits(hits){
28 }
29 
32  LocalVector& direction,
33  double chi2,
34  AlgebraicSymMatrix covMat,
35  const DTSuperLayer* sl) :
36 theSL(sl), thePosition(position), theDirection(direction), theChi2(chi2),
37  theCovMatrix( covMat), theHits(hits) {
38 }
39 
42 }
43 
44 /* Operations */
46  static const double epsilon=0.00001;
47  if (nHits()!=seg.nHits()) return false;
48  if (fabs(chi2()-seg.chi2())>epsilon) return false;
49  if (fabs(position().x()-seg.position().x())>epsilon ||
50  fabs(position().y()-seg.position().y())>epsilon ||
51  fabs(position().z()-seg.position().z())>epsilon) return false;
52  if (fabs(direction().x()-seg.direction().x())>epsilon ||
53  fabs(direction().y()-seg.direction().y())>epsilon ||
54  fabs(direction().z()-seg.direction().z())>epsilon) return false;
55  return true;
56 }
57 
59  if (nHits()==seg.nHits()) return (chi2()>seg.chi2());
60  return (nHits()<seg.nHits());
61 }
62 
64  theHits.insert(AssPoint(hit,code));
65 }
66 
68  theHits.erase(badHit);
69 }
70 
72  int result=0;
73  AssPointCont hitsCont = seg.hits();
74 
75  for (AssPointCont::const_iterator hit=theHits.begin();
76  hit!=theHits.end() ; ++hit) {
77  for (AssPointCont::const_iterator hit2=hitsCont.begin();
78  hit2!=hitsCont.end() ; ++hit2) {
79  // if(result) return result ; // TODO, uncomm this line or move it in another func
80  if ((*(*hit).first)==(*(*hit2).first)) {
81  ++result;
82  continue;
83  }
84  }
85  }
86  return result;
87 }
88 
92  const AssPointCont & hits2 = seg.theHits;
93 
94 // if (nSharedHitPairs(seg)==0) return result;
95 
96  AssPointCont::const_iterator hitBegin2 = hits2.begin(), hitEnd2 = hits2.end();
97  for (AssPointCont::const_iterator hit = theHits.begin(), hitEnd = theHits.end();
98  hit != hitEnd ; ++hit) {
99  for (AssPointCont::const_iterator hit2 = hitBegin2; hit2 != hitEnd2; ++hit2) {
100  if ((*(*hit).first)==(*(*hit2).first) &&
101  (*hit).second != (*hit2).second) {
102  result.insert(*hit);
103  continue;
104  }
105  }
106  }
107  return result;
108 }
109 
111 {
112  if(NDOF() == 0) return false;
113  if(chi2()/NDOF() > chi2max || nHits() < nHitsMin) return false;
114 
115  if(nHits() == nHitsMin && hitsShareLayer()) return false ;
116 
117  return true;
118 }
119 
121 {
122  std::vector<int> layerN;
123 
124  for(DTSegmentCand::AssPointCont::iterator assHit=theHits.begin();
125  assHit!=theHits.end(); ++assHit) {
126  layerN.push_back((*assHit).first->id().layerId().layer());
127 
128  //std::cout << (*assHit).first->id().layerId().layer() << std::endl;
129  }
130 
131  for(int i=0;i<(int)layerN.size();i++){
132  for(int j=i+1;j<(int)layerN.size();j++){
133  if(layerN[i] == layerN[j]) return true;
134  }
135  }
136 
137  return false;
138 }
139 
141  // TODO
142  return 0;
143 }
144 
146 
147  LocalPoint seg2Dposition = position();
148  LocalVector seg2DDirection = direction();
149  double seg2DChi2 = chi2();
150  AlgebraicSymMatrix seg2DCovMatrix = covMatrix();
151 
152  std::vector<DTRecHit1D> hits1D;
153  for(DTSegmentCand::AssPointCont::iterator assHit=theHits.begin();
154  assHit!=theHits.end(); ++assHit) {
155 
156  GlobalPoint hitGlobalPos =
157  theSL->toGlobal( (*assHit).first->localPosition((*assHit).second) );
158 
159  LocalPoint hitPosInLayer =
160  theSL->layer( (*assHit).first->id().layerId() )->toLocal(hitGlobalPos);
161 
162  DTRecHit1D hit( ((*assHit).first)->id(),
163  (*assHit).second,
164  ((*assHit).first)->digiTime(),
165  hitPosInLayer,
166  ((*assHit).first)->localPositionError() );
167  hits1D.push_back(hit);
168  }
169 
170  return new DTSLRecSegment2D(theSL->id(),
171  seg2Dposition,seg2DDirection,seg2DCovMatrix,
172  seg2DChi2,hits1D);
173 }
174 
176 
177  // input position and direction are in sl frame, while must be stored in
178  // chamber one: so I have to extrapolate the position (along the direction) to
179  // the chamber reference plane.
180 
181  LocalPoint posInCh = theSL->chamber()->toLocal(theSL->toGlobal( position() ));
182  LocalVector dirInCh= theSL->chamber()->toLocal(theSL->toGlobal( direction() ));
183 
184  LocalPoint pos=posInCh + dirInCh * posInCh.z()/cos(dirInCh.theta());
185 
186  double seg2DChi2 = chi2();
187  AlgebraicSymMatrix seg2DCovMatrix = covMatrix();
188 
189  std::vector<DTRecHit1D> hits1D;
190  for(DTSegmentCand::AssPointCont::iterator assHit=theHits.begin();
191  assHit!=theHits.end(); ++assHit) {
192 
193  GlobalPoint hitGlobalPos =
194  theSL->toGlobal( (*assHit).first->localPosition((*assHit).second) );
195 
196  LocalPoint hitPosInLayer =
197  theSL->chamber()
198  ->superLayer((*assHit).first->id().superlayerId())
199  ->layer( (*assHit).first->id().layerId() )->toLocal(hitGlobalPos);
200 
201  DTRecHit1D hit( ((*assHit).first)->id(),
202  (*assHit).second,
203  ((*assHit).first)->digiTime(),
204  hitPosInLayer,
205  ((*assHit).first)->localPositionError() );
206  hits1D.push_back(hit);
207  }
208 
209  return new DTChamberRecSegment2D(theSL->chamber()->id(),
210  pos,dirInCh,seg2DCovMatrix,
211  seg2DChi2,hits1D);
212 
213  // chamber and Phi SLs' frame are oriented in the same way, only a transaltion,
214  // so the covariance matrix is the same!
215 }
216 
217 
219  const AssPoint& pt2) const {
220  return *(pt1.first) < *(pt2.first);
221 }
222 
223 std::ostream& operator<<(std::ostream& out, const DTSegmentCand& seg) {
224  out << " pos: " << seg.position() << " dir: " << seg.direction()
225  << " chi2/nHits: " << seg.chi2() << "/" << seg.DTSegmentCand::nHits() << "/" << seg.nHits();
226  return out;
227 }
228 
229 std::ostream& operator<<(std::ostream& out, const DTSegmentCand::AssPoint& hit) {
230  // out << "Hits " << (hit.first)->localPosition(DTEnums::Left) <<
231  // " " << hit.second << " Lay " << (hit.first)->layerNumber() << endl;
232  return out;
233 }
int i
Definition: DBlmapReader.cc:9
static unsigned int nHitsMin
T y() const
Definition: PV3DBase.h:62
DTCellSide
Which side of the DT cell.
Definition: DTEnums.h:17
LocalVector toLocal(const reco::Track::Vector &v, const Surface &s)
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:187
virtual bool good() const
virtual unsigned int NDOF() const
Definition: DTSegmentCand.h:88
static int position[TOTALCHAMBERS][3]
Definition: ReadPGInfo.cc:509
DTSegmentCand(AssPointCont &hits, const DTSuperLayer *sl)
Constructor.
Geom::Theta< T > theta() const
Definition: PV3DBase.h:74
virtual bool operator==(const DTSegmentCand &seg)
equality operator based on position, direction, chi2 and nHits
virtual bool hitsShareLayer() const
virtual bool operator<(const DTSegmentCand &seg)
less operator based on nHits and chi2
AssPointCont theHits
T z() const
Definition: PV3DBase.h:63
tuple result
Definition: query.py:137
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
int j
Definition: DBlmapReader.cc:9
bool operator()(const AssPoint &pt1, const AssPoint &pt2) const
virtual int nLayers() const
number of different layers with hits
virtual double chi2() const
the chi2 (NOT chi2/NDOF) of the fit
Definition: DTSegmentCand.h:65
virtual AssPointCont hits() const
the used hits
std::pair< DTHitPairForFit *, DTEnums::DTCellSide > AssPoint
Definition: DTSegmentCand.h:39
tuple out
Definition: dbtoconf.py:99
virtual AssPointCont conflictingHitPairs(const DTSegmentCand &seg) const
std::set< AssPoint, AssPointLessZ > AssPointCont
Definition: DTSegmentCand.h:41
virtual unsigned int nHits() const
Definition: DTSegmentCand.h:62
virtual LocalPoint position() const
Definition: DTSegmentCand.h:80
virtual void add(DTHitPairForFit *hit, DTEnums::DTCellSide code)
add hits to the hit list.
virtual void removeHit(AssPoint hit)
remove hit from the candidate
CLHEP::HepSymMatrix AlgebraicSymMatrix
virtual ~DTSegmentCand()
Destructor.
virtual int nSharedHitPairs(const DTSegmentCand &seg) const
number of shared hit pair with other segment candidate
const double epsilon
static double chi2max
T x() const
Definition: PV3DBase.h:61
virtual LocalVector direction() const
Definition: DTSegmentCand.h:83