CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Types | Public Member Functions | Static Protected Attributes | Private Attributes
DTSegmentCand Class Reference

#include <DTSegmentCand.h>

Inheritance diagram for DTSegmentCand:
DTSegmentExtendedCand

Classes

struct  AssPointLessZ
 

Public Types

typedef std::pair
< std::shared_ptr
< DTHitPairForFit >
, DTEnums::DTCellSide
AssPoint
 
typedef std::set< AssPoint,
AssPointLessZ
AssPointCont
 

Public Member Functions

virtual void add (std::shared_ptr< DTHitPairForFit > hit, DTEnums::DTCellSide code)
 add hits to the hit list. More...
 
virtual double chi2 () const
 the chi2 (NOT chi2/NDOF) of the fit More...
 
virtual double chi2ndof () const
 the chi2/NDOF of the fit More...
 
virtual AssPointCont conflictingHitPairs (const DTSegmentCand &seg) const
 
virtual AlgebraicSymMatrix covMatrix () const
 the covariance matrix More...
 
virtual LocalVector direction () const
 
 DTSegmentCand (AssPointCont &hits, const DTSuperLayer *sl)
 Constructor. More...
 
 DTSegmentCand (const AssPointCont &hits, LocalPoint &position, LocalVector &direction, double chi2, const AlgebraicSymMatrix &covMat, const DTSuperLayer *sl)
 
virtual bool good () const
 
virtual AssPointCont hits () const
 the used hits More...
 
virtual bool hitsShareLayer () const
 
virtual unsigned int NDOF () const
 
virtual unsigned int nHits () const
 
virtual int nLayers () const
 number of different layers with hits More...
 
virtual int nSharedHitPairs (const DTSegmentCand &seg) const
 number of shared hit pair with other segment candidate More...
 
 operator DTChamberRecSegment2D * () const
 convert this DTSegmentCand into a DTChamberRecSegment2D More...
 
 operator DTSLRecSegment2D * () const
 convert this DTSegmentCand into a DTRecSegment2D More...
 
virtual bool operator< (const DTSegmentCand &seg)
 less operator based on nHits and chi2 More...
 
virtual bool operator== (const DTSegmentCand &seg)
 equality operator based on position, direction, chi2 and nHits More...
 
virtual LocalPoint position () const
 
virtual void removeHit (AssPoint hit)
 remove hit from the candidate More...
 
virtual void setChi2 (double &chi2)
 set chi2 More...
 
virtual void setCovMatrix (AlgebraicSymMatrix &cov)
 set the cov matrix More...
 
virtual void setDirection (LocalVector &dir)
 set direction More...
 
virtual void setPosition (LocalPoint &pos)
 set position More...
 
virtual void sett0 (double &t0)
 set t0 More...
 
const DTSuperLayersuperLayer () const
 the super layer on which relies More...
 
virtual double t0 () const
 the t0 of the segment More...
 
virtual ~DTSegmentCand ()
 Destructor. More...
 

Static Protected Attributes

static const double chi2max =20.
 
static const unsigned int nHitsMin =3
 

Private Attributes

double theChi2
 
AlgebraicSymMatrix theCovMatrix
 
LocalVector theDirection
 
AssPointCont theHits
 
LocalPoint thePosition
 
const DTSuperLayertheSL
 
double thet0
 

Detailed Description

A Candidate for a DT segment. It's used by the algorithm to build segments and store relative information. It must be transformed into a DTSegment for further use.

Author
Stefano Lacaprara - INFN Legnaro stefa.nosp@m.no.l.nosp@m.acapr.nosp@m.ara@.nosp@m.pd.in.nosp@m.fn.i.nosp@m.t
Riccardo Bellan - INFN TO ricca.nosp@m.rdo..nosp@m.bella.nosp@m.n@ce.nosp@m.rn.ch

Definition at line 35 of file DTSegmentCand.h.

Member Typedef Documentation

typedef std::pair<std::shared_ptr<DTHitPairForFit>, DTEnums::DTCellSide> DTSegmentCand::AssPoint

Definition at line 38 of file DTSegmentCand.h.

Definition at line 40 of file DTSegmentCand.h.

Constructor & Destructor Documentation

DTSegmentCand::DTSegmentCand ( AssPointCont hits,
const DTSuperLayer sl 
)

Constructor.

Definition at line 23 of file DTSegmentCand.cc.

24  :
25 theSL(sl), theChi2(-1.) , theHits(hits){
26 }
AssPointCont theHits
virtual AssPointCont hits() const
the used hits
const DTSuperLayer * theSL
DTSegmentCand::DTSegmentCand ( const AssPointCont hits,
LocalPoint position,
LocalVector direction,
double  chi2,
const AlgebraicSymMatrix covMat,
const DTSuperLayer sl 
)

Definition at line 28 of file DTSegmentCand.cc.

33  :
34 theSL(sl), thePosition(position), theDirection(direction), theChi2(chi2),
35  theCovMatrix( covMat), theHits(hits) {
36 }
AlgebraicSymMatrix theCovMatrix
AssPointCont theHits
virtual double chi2() const
the chi2 (NOT chi2/NDOF) of the fit
Definition: DTSegmentCand.h:64
virtual AssPointCont hits() const
the used hits
const DTSuperLayer * theSL
LocalPoint thePosition
LocalVector theDirection
DTSegmentCand::~DTSegmentCand ( )
virtual

Destructor.

Definition at line 39 of file DTSegmentCand.cc.

39  {
40 }

Member Function Documentation

void DTSegmentCand::add ( std::shared_ptr< DTHitPairForFit hit,
DTEnums::DTCellSide  code 
)
virtual

add hits to the hit list.

Definition at line 61 of file DTSegmentCand.cc.

References theHits.

61  {
62  theHits.insert(AssPoint(hit,code));
63 }
std::pair< std::shared_ptr< DTHitPairForFit >, DTEnums::DTCellSide > AssPoint
Definition: DTSegmentCand.h:38
AssPointCont theHits
virtual double DTSegmentCand::chi2 ( void  ) const
inlinevirtual

the chi2 (NOT chi2/NDOF) of the fit

Definition at line 64 of file DTSegmentCand.h.

References theChi2.

Referenced by good(), operator<(), operator<<(), operator==(), and setChi2().

64 { return theChi2; }
virtual double DTSegmentCand::chi2ndof ( ) const
inlinevirtual

the chi2/NDOF of the fit

Definition at line 67 of file DTSegmentCand.h.

References nHits(), and theChi2.

Referenced by DTMeantimerPatternReco::checkDoubleCandidates().

67 { return theChi2/(nHits()-2.); }
virtual unsigned int nHits() const
Definition: DTSegmentCand.h:61
DTSegmentCand::AssPointCont DTSegmentCand::conflictingHitPairs ( const DTSegmentCand seg) const
virtual

return the hits shared with other segment and with confliction L/R assignment

Definition at line 88 of file DTSegmentCand.cc.

References query::result, and theHits.

88  {
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 }
AssPointCont theHits
tuple result
Definition: query.py:137
std::set< AssPoint, AssPointLessZ > AssPointCont
Definition: DTSegmentCand.h:40
virtual AlgebraicSymMatrix DTSegmentCand::covMatrix ( ) const
inlinevirtual

the covariance matrix

Definition at line 88 of file DTSegmentCand.h.

References theCovMatrix.

88 {return theCovMatrix; }
AlgebraicSymMatrix theCovMatrix
virtual LocalVector DTSegmentCand::direction ( ) const
inlinevirtual

Definition at line 85 of file DTSegmentCand.h.

References theDirection.

Referenced by operator<<(), and operator==().

85 { return theDirection;}
LocalVector theDirection
bool DTSegmentCand::good ( ) const
virtual

Reimplemented in DTSegmentExtendedCand.

Definition at line 108 of file DTSegmentCand.cc.

References chi2(), chi2max, edm::false, hitsShareLayer(), NDOF(), nHits(), and nHitsMin.

Referenced by DTCombinatorialPatternReco::buildSegments(), and DTSegmentUpdator::fit().

109 {
110  // std::cout << NDOF() << " " << chi2()/NDOF() << " " << nHits() << std::endl;
111  if(NDOF() == 0) return false;
112  if(chi2()/NDOF() > chi2max || nHits() < nHitsMin) return false;
113 
114  if(nHits() == nHitsMin && hitsShareLayer()) return false ;
115 
116  return true;
117 }
virtual unsigned int NDOF() const
Definition: DTSegmentCand.h:90
static const unsigned int nHitsMin
virtual bool hitsShareLayer() const
static const double chi2max
virtual double chi2() const
the chi2 (NOT chi2/NDOF) of the fit
Definition: DTSegmentCand.h:64
virtual unsigned int nHits() const
Definition: DTSegmentCand.h:61
volatile std::atomic< bool > shutdown_flag false
virtual AssPointCont DTSegmentCand::hits ( ) const
inlinevirtual

the used hits

Definition at line 124 of file DTSegmentCand.h.

References theHits.

Referenced by DTSegmentUpdator::fit(), and nSharedHitPairs().

124 { return theHits;}
AssPointCont theHits
bool DTSegmentCand::hitsShareLayer ( ) const
virtual

Definition at line 119 of file DTSegmentCand.cc.

References i, j, and theHits.

Referenced by good().

120 {
121  int layerN[20];
122  int i=0;
123 
124  // we don't expect so many 1D hits, if such a segment arrives just drop it
125  if (theHits.size()>20) return false;
126 
127  for(DTSegmentCand::AssPointCont::iterator assHit=theHits.begin();
128  assHit!=theHits.end(); ++assHit) {
129  layerN[i]=(*assHit).first->id().layerId().layer()+10*(*assHit).first->id().superlayerId().superlayer();
130  i++;
131 // std::cout << (*assHit).first->id().layerId().layer()+10*(*assHit).first->id().superlayerId().superlayer()) << std::endl;
132  }
133 
134  for(int i=0;i<(int)theHits.size();i++){
135  for(int j=0;j<i;j++){
136  if(layerN[i] == layerN[j]) return true;
137  }
138  }
139 
140  return false;
141 }
int i
Definition: DBlmapReader.cc:9
AssPointCont theHits
int j
Definition: DBlmapReader.cc:9
virtual unsigned int DTSegmentCand::NDOF ( ) const
inlinevirtual

Definition at line 90 of file DTSegmentCand.h.

References nHits().

Referenced by good().

90 { return nHits()-2; }
virtual unsigned int nHits() const
Definition: DTSegmentCand.h:61
virtual unsigned int DTSegmentCand::nHits ( void  ) const
inlinevirtual
int DTSegmentCand::nLayers ( ) const
virtual

number of different layers with hits

Definition at line 143 of file DTSegmentCand.cc.

143  {
144  // TODO
145  return 0;
146 }
int DTSegmentCand::nSharedHitPairs ( const DTSegmentCand seg) const
virtual

number of shared hit pair with other segment candidate

Definition at line 69 of file DTSegmentCand.cc.

References hits(), query::result, and theHits.

69  {
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 }
AssPointCont theHits
tuple result
Definition: query.py:137
virtual AssPointCont hits() const
the used hits
std::set< AssPoint, AssPointLessZ > AssPointCont
Definition: DTSegmentCand.h:40
DTSegmentCand::operator DTChamberRecSegment2D * ( ) const

convert this DTSegmentCand into a DTChamberRecSegment2D

Definition at line 178 of file DTSegmentCand.cc.

References funct::cos(), position, PV3DBase< T, PVType, FrameType >::theta(), toLocal(), and PV3DBase< T, PVType, FrameType >::z().

178  {
179 
180  // input position and direction are in sl frame, while must be stored in
181  // chamber one: so I have to extrapolate the position (along the direction) to
182  // the chamber reference plane.
183 
184  LocalPoint posInCh = theSL->chamber()->toLocal(theSL->toGlobal( position() ));
186 
187  LocalPoint pos=posInCh + dirInCh * posInCh.z()/cos(dirInCh.theta());
188 
189  double seg2DChi2 = chi2();
190  AlgebraicSymMatrix seg2DCovMatrix = covMatrix();
191 
192  std::vector<DTRecHit1D> hits1D;
193  for(DTSegmentCand::AssPointCont::iterator assHit=theHits.begin();
194  assHit!=theHits.end(); ++assHit) {
195 
196  GlobalPoint hitGlobalPos =
197  theSL->toGlobal( (*assHit).first->localPosition((*assHit).second) );
198 
199  LocalPoint hitPosInLayer =
200  theSL->chamber()
201  ->superLayer((*assHit).first->id().superlayerId())
202  ->layer( (*assHit).first->id().layerId() )->toLocal(hitGlobalPos);
203 
204  DTRecHit1D hit( ((*assHit).first)->id(),
205  (*assHit).second,
206  ((*assHit).first)->digiTime(),
207  hitPosInLayer,
208  ((*assHit).first)->localPositionError() );
209  hits1D.push_back(hit);
210  }
211 
212  return new DTChamberRecSegment2D(theSL->chamber()->id(),
213  pos,dirInCh,seg2DCovMatrix,
214  seg2DChi2,hits1D);
215 
216  // chamber and Phi SLs' frame are oriented in the same way, only a transaltion,
217  // so the covariance matrix is the same!
218 }
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:47
virtual AlgebraicSymMatrix covMatrix() const
the covariance matrix
Definition: DTSegmentCand.h:88
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
Definition: GeomDet.h:62
LocalVector toLocal(const reco::Track::Vector &v, const Surface &s)
Geom::Theta< T > theta() const
Definition: PV3DBase.h:75
AssPointCont theHits
DTChamberId id() const
Return the DTChamberId of this chamber.
Definition: DTChamber.cc:33
T z() const
Definition: PV3DBase.h:64
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
virtual double chi2() const
the chi2 (NOT chi2/NDOF) of the fit
Definition: DTSegmentCand.h:64
const DTSuperLayer * theSL
virtual LocalPoint position() const
Definition: DTSegmentCand.h:82
const DTChamber * chamber() const
Definition: DTSuperLayer.cc:64
CLHEP::HepSymMatrix AlgebraicSymMatrix
virtual LocalVector direction() const
Definition: DTSegmentCand.h:85
const DTSuperLayer * superLayer(DTSuperLayerId id) const
Return the superlayer corresponding to the given id.
Definition: DTChamber.cc:65
DTSegmentCand::operator DTSLRecSegment2D * ( ) const

convert this DTSegmentCand into a DTRecSegment2D

Definition at line 148 of file DTSegmentCand.cc.

References position, and toLocal().

148  {
149 
150  LocalPoint seg2Dposition = position();
151  LocalVector seg2DDirection = direction();
152  double seg2DChi2 = chi2();
153  AlgebraicSymMatrix seg2DCovMatrix = covMatrix();
154 
155  std::vector<DTRecHit1D> hits1D;
156  for(DTSegmentCand::AssPointCont::iterator assHit=theHits.begin();
157  assHit!=theHits.end(); ++assHit) {
158 
159  GlobalPoint hitGlobalPos =
160  theSL->toGlobal( (*assHit).first->localPosition((*assHit).second) );
161 
162  LocalPoint hitPosInLayer =
163  theSL->layer( (*assHit).first->id().layerId() )->toLocal(hitGlobalPos);
164 
165  DTRecHit1D hit( ((*assHit).first)->id(),
166  (*assHit).second,
167  ((*assHit).first)->digiTime(),
168  hitPosInLayer,
169  ((*assHit).first)->localPositionError() );
170  hits1D.push_back(hit);
171  }
172 
173  return new DTSLRecSegment2D(theSL->id(),
174  seg2Dposition,seg2DDirection,seg2DCovMatrix,
175  seg2DChi2,hits1D);
176 }
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:47
virtual AlgebraicSymMatrix covMatrix() const
the covariance matrix
Definition: DTSegmentCand.h:88
LocalVector toLocal(const reco::Track::Vector &v, const Surface &s)
DTSuperLayerId id() const
Return the DetId of this SL.
Definition: DTSuperLayer.cc:36
AssPointCont theHits
const DTLayer * layer(DTLayerId id) const
Return the layer corresponding to the given id.
Definition: DTSuperLayer.cc:68
virtual double chi2() const
the chi2 (NOT chi2/NDOF) of the fit
Definition: DTSegmentCand.h:64
const DTSuperLayer * theSL
virtual LocalPoint position() const
Definition: DTSegmentCand.h:82
CLHEP::HepSymMatrix AlgebraicSymMatrix
virtual LocalVector direction() const
Definition: DTSegmentCand.h:85
bool DTSegmentCand::operator< ( const DTSegmentCand seg)
virtual

less operator based on nHits and chi2

Definition at line 56 of file DTSegmentCand.cc.

References chi2(), and nHits().

56  {
57  if (nHits()==seg.nHits()) return (chi2()>seg.chi2());
58  return (nHits()<seg.nHits());
59 }
virtual double chi2() const
the chi2 (NOT chi2/NDOF) of the fit
Definition: DTSegmentCand.h:64
virtual unsigned int nHits() const
Definition: DTSegmentCand.h:61
bool DTSegmentCand::operator== ( const DTSegmentCand seg)
virtual

equality operator based on position, direction, chi2 and nHits

Definition at line 43 of file DTSegmentCand.cc.

References chi2(), direction(), epsilon, nHits(), position(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

43  {
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 }
T y() const
Definition: PV3DBase.h:63
T z() const
Definition: PV3DBase.h:64
virtual double chi2() const
the chi2 (NOT chi2/NDOF) of the fit
Definition: DTSegmentCand.h:64
virtual unsigned int nHits() const
Definition: DTSegmentCand.h:61
virtual LocalPoint position() const
Definition: DTSegmentCand.h:82
const double epsilon
T x() const
Definition: PV3DBase.h:62
virtual LocalVector direction() const
Definition: DTSegmentCand.h:85
virtual LocalPoint DTSegmentCand::position ( ) const
inlinevirtual

Definition at line 82 of file DTSegmentCand.h.

References thePosition.

Referenced by operator<<(), and operator==().

82 { return thePosition; }
LocalPoint thePosition
void DTSegmentCand::removeHit ( AssPoint  hit)
virtual

remove hit from the candidate

Definition at line 65 of file DTSegmentCand.cc.

References theHits.

Referenced by DTSegmentCleaner::solveConflict().

65  {
66  theHits.erase(badHit);
67 }
AssPointCont theHits
virtual void DTSegmentCand::setChi2 ( double &  chi2)
inlinevirtual

set chi2

Definition at line 105 of file DTSegmentCand.h.

References chi2(), and theChi2.

Referenced by DTSegmentUpdator::fit().

105 { theChi2 = chi2; }
virtual double chi2() const
the chi2 (NOT chi2/NDOF) of the fit
Definition: DTSegmentCand.h:64
virtual void DTSegmentCand::setCovMatrix ( AlgebraicSymMatrix cov)
inlinevirtual

set the cov matrix

Definition at line 118 of file DTSegmentCand.h.

References theCovMatrix.

Referenced by DTSegmentUpdator::fit().

118 { theCovMatrix = cov; }
AlgebraicSymMatrix theCovMatrix
virtual void DTSegmentCand::setDirection ( LocalVector dir)
inlinevirtual

set direction

Definition at line 96 of file DTSegmentCand.h.

References dir, and theDirection.

Referenced by DTSegmentUpdator::fit().

96 { theDirection = dir; }
LocalVector theDirection
dbl *** dir
Definition: mlp_gen.cc:35
virtual void DTSegmentCand::setPosition ( LocalPoint pos)
inlinevirtual

set position

Definition at line 93 of file DTSegmentCand.h.

References thePosition.

Referenced by DTSegmentUpdator::fit().

93 { thePosition=pos; }
LocalPoint thePosition
virtual void DTSegmentCand::sett0 ( double &  t0)
inlinevirtual

set t0

Definition at line 108 of file DTSegmentCand.h.

References t0(), and thet0.

Referenced by DTSegmentUpdator::fit().

108 { thet0 = t0; }
virtual double t0() const
the t0 of the segment
Definition: DTSegmentCand.h:70
const DTSuperLayer* DTSegmentCand::superLayer ( ) const
inline

the super layer on which relies

Definition at line 79 of file DTSegmentCand.h.

References theSL.

Referenced by DTCombinatorialExtendedPatternReco::extendCandidates().

79 {return theSL;}
const DTSuperLayer * theSL
virtual double DTSegmentCand::t0 ( ) const
inlinevirtual

the t0 of the segment

Definition at line 70 of file DTSegmentCand.h.

References thet0.

Referenced by operator<<(), and sett0().

70 { return thet0; }

Member Data Documentation

const double DTSegmentCand::chi2max =20.
staticprotected

Definition at line 156 of file DTSegmentCand.h.

Referenced by good().

const unsigned int DTSegmentCand::nHitsMin =3
staticprotected

Definition at line 157 of file DTSegmentCand.h.

Referenced by good().

double DTSegmentCand::theChi2
private

Definition at line 145 of file DTSegmentCand.h.

Referenced by chi2(), chi2ndof(), and setChi2().

AlgebraicSymMatrix DTSegmentCand::theCovMatrix
private

mat[1][1]=sigma (dx/dz) mat[2][2]=sigma (x) mat[1][2]=cov(dx/dz,x)

Definition at line 151 of file DTSegmentCand.h.

Referenced by covMatrix(), and setCovMatrix().

LocalVector DTSegmentCand::theDirection
private

Definition at line 144 of file DTSegmentCand.h.

Referenced by direction(), and setDirection().

AssPointCont DTSegmentCand::theHits
private
LocalPoint DTSegmentCand::thePosition
private

Definition at line 143 of file DTSegmentCand.h.

Referenced by position(), and setPosition().

const DTSuperLayer* DTSegmentCand::theSL
private

Definition at line 142 of file DTSegmentCand.h.

Referenced by superLayer().

double DTSegmentCand::thet0
private

Definition at line 146 of file DTSegmentCand.h.

Referenced by sett0(), and t0().