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