test
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(newHit);
63 }
64 
65 void DTSegmentCand::add(std::shared_ptr<DTHitPairForFit> hit, DTEnums::DTCellSide code) {
66  AssPoint newHit(hit,code);
67  theHits.insert(newHit);
68 }
69 
71  theHits.erase(badHit);
72 }
73 
75  int result=0;
76 
77  for (AssPointCont::const_iterator hit=theHits.begin();
78  hit!=theHits.end() ; ++hit) {
79  for (AssPointCont::const_iterator hit2=seg.hits().begin();
80  hit2!=seg.hits().end() ; ++hit2) {
81  // if(result) return result ; // TODO, uncomm this line or move it in another func
82  if ((*(*hit).first)==(*(*hit2).first)) {
83  ++result;
84  continue;
85  }
86  }
87  }
88  return result;
89 }
90 
94  const AssPointCont & hits2 = seg.theHits;
95 
96 // if (nSharedHitPairs(seg)==0) return result;
97 
98  AssPointCont::const_iterator hitBegin2 = hits2.begin(), hitEnd2 = hits2.end();
99  for (AssPointCont::const_iterator hit = theHits.begin(), hitEnd = theHits.end();
100  hit != hitEnd ; ++hit) {
101  for (AssPointCont::const_iterator hit2 = hitBegin2; hit2 != hitEnd2; ++hit2) {
102  if ((*(*hit).first)==(*(*hit2).first) &&
103  (*hit).second != (*hit2).second) {
104  result.insert(*hit);
105  continue;
106  }
107  }
108  }
109  return result;
110 }
111 
113 {
114  // std::cout << NDOF() << " " << chi2()/NDOF() << " " << nHits() << std::endl;
115  if(NDOF() == 0) return false;
116  if(chi2()/NDOF() > chi2max || nHits() < nHitsMin) return false;
117 
118  if(nHits() == nHitsMin && hitsShareLayer()) return false ;
119 
120  return true;
121 }
122 
124 {
125  int layerN[20];
126  int i=0;
127 
128  // we don't expect so many 1D hits, if such a segment arrives just drop it
129  if (theHits.size()>20) return false;
130 
131  for(DTSegmentCand::AssPointCont::iterator assHit=theHits.begin();
132  assHit!=theHits.end(); ++assHit) {
133  layerN[i]=(*assHit).first->id().layerId().layer()+10*(*assHit).first->id().superlayerId().superlayer();
134  i++;
135  }
136 
137  for(int i=0;i<(int)theHits.size();i++){
138  for(int j=0;j<i;j++){
139  if(layerN[i] == layerN[j]) return true;
140  }
141  }
142 
143  return false;
144 }
145 
147  // TODO
148  return 0;
149 }
150 
152 
153  LocalPoint seg2Dposition = position();
154  LocalVector seg2DDirection = direction();
155  double seg2DChi2 = chi2();
156  AlgebraicSymMatrix seg2DCovMatrix = covMatrix();
157 
158  std::vector<DTRecHit1D> hits1D;
159  for(DTSegmentCand::AssPointCont::iterator assHit=theHits.begin();
160  assHit!=theHits.end(); ++assHit) {
161 
162  GlobalPoint hitGlobalPos =
163  theSL->toGlobal( (*assHit).first->localPosition((*assHit).second) );
164 
165  LocalPoint hitPosInLayer =
166  theSL->layer( (*assHit).first->id().layerId() )->toLocal(hitGlobalPos);
167 
168  DTRecHit1D hit( ((*assHit).first)->id(),
169  (*assHit).second,
170  ((*assHit).first)->digiTime(),
171  hitPosInLayer,
172  ((*assHit).first)->localPositionError() );
173  hits1D.push_back(hit);
174  }
175 
176  return new DTSLRecSegment2D(theSL->id(),
177  seg2Dposition,seg2DDirection,seg2DCovMatrix,
178  seg2DChi2,hits1D);
179 }
180 
182 
183  // input position and direction are in sl frame, while must be stored in
184  // chamber one: so I have to extrapolate the position (along the direction) to
185  // the chamber reference plane.
186 
187  LocalPoint posInCh = theSL->chamber()->toLocal(theSL->toGlobal( position() ));
188  LocalVector dirInCh= theSL->chamber()->toLocal(theSL->toGlobal( direction() ));
189 
190  LocalPoint pos=posInCh + dirInCh * posInCh.z()/cos(dirInCh.theta());
191 
192  double seg2DChi2 = chi2();
193  AlgebraicSymMatrix seg2DCovMatrix = covMatrix();
194 
195  std::vector<DTRecHit1D> hits1D;
196  for(DTSegmentCand::AssPointCont::iterator assHit=theHits.begin();
197  assHit!=theHits.end(); ++assHit) {
198 
199  GlobalPoint hitGlobalPos =
200  theSL->toGlobal( (*assHit).first->localPosition((*assHit).second) );
201 
202  LocalPoint hitPosInLayer =
203  theSL->chamber()
204  ->superLayer((*assHit).first->id().superlayerId())
205  ->layer( (*assHit).first->id().layerId() )->toLocal(hitGlobalPos);
206 
207  DTRecHit1D hit( ((*assHit).first)->id(),
208  (*assHit).second,
209  ((*assHit).first)->digiTime(),
210  hitPosInLayer,
211  ((*assHit).first)->localPositionError() );
212  hits1D.push_back(hit);
213  }
214 
215  return new DTChamberRecSegment2D(theSL->chamber()->id(),
216  pos,dirInCh,seg2DCovMatrix,
217  seg2DChi2,hits1D);
218 
219  // chamber and Phi SLs' frame are oriented in the same way, only a transaltion,
220  // so the covariance matrix is the same!
221 }
222 
223 
225  const AssPoint& pt2) const {
226  return *(pt1.first) < *(pt2.first);
227 }
228 
229 std::ostream& operator<<(std::ostream& out, const DTSegmentCand& seg) {
230  out << " pos: " << seg.position() << " dir: " << seg.direction()
231  << " chi2/nHits: " << seg.chi2() << "/" << seg.DTSegmentCand::nHits()
232  << " t0: " << seg.t0();
233  return out;
234 }
235 
236 std::ostream& operator<<(std::ostream& out, const DTSegmentCand::AssPoint& hit) {
237  // out << "Hits " << (hit.first)->localPosition(DTEnums::Left) <<
238  // " " << hit.second << " Lay " << (hit.first)->layerNumber() << endl;
239  return out;
240 }
std::pair< std::shared_ptr< DTHitPairForFit >, DTEnums::DTCellSide > AssPoint
Definition: DTSegmentCand.h:38
int i
Definition: DBlmapReader.cc:9
virtual const AssPointCont & hits() const
the used hits
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:188
virtual bool good() const
virtual unsigned int NDOF() const
Definition: DTSegmentCand.h:90
static const unsigned int nHitsMin
tuple result
Definition: mps_fire.py:84
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 void add(AssPoint newHit)
add hits to the hit list.
virtual bool operator<(const DTSegmentCand &seg)
less operator based on nHits and chi2
AssPointCont theHits
T z() const
Definition: PV3DBase.h:64
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:64
virtual AssPointCont conflictingHitPairs(const DTSegmentCand &seg) const
std::set< AssPoint, AssPointLessZ > AssPointCont
Definition: DTSegmentCand.h:40
virtual unsigned int nHits() const
Definition: DTSegmentCand.h:61
virtual double t0() const
the t0 of the segment
Definition: DTSegmentCand.h:70
virtual LocalPoint position() const
Definition: DTSegmentCand.h:82
static int position[264][3]
Definition: ReadPGInfo.cc:509
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
T x() const
Definition: PV3DBase.h:62
virtual LocalVector direction() const
Definition: DTSegmentCand.h:85