CMS 3D CMS Logo

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 
23 DTSegmentCand::DTSegmentCand(AssPointCont& hits, const DTSuperLayer* sl) : theSL(sl), theChi2(-1.), theHits(hits) {}
24 
27  LocalVector& direction,
28  double chi2,
29  const AlgebraicSymMatrix& covMat,
30  const DTSuperLayer* sl)
31  : theSL(sl), thePosition(position), theDirection(direction), theChi2(chi2), theCovMatrix(covMat), theHits(hits) {}
32 
35 
36 /* Operations */
38  static const double epsilon = 0.00001;
39  if (nHits() != seg.nHits())
40  return false;
41  if (fabs(chi2() - seg.chi2()) > epsilon)
42  return false;
43  if (fabs(position().x() - seg.position().x()) > epsilon || fabs(position().y() - seg.position().y()) > epsilon ||
44  fabs(position().z() - seg.position().z()) > epsilon)
45  return false;
46  if (fabs(direction().x() - seg.direction().x()) > epsilon || fabs(direction().y() - seg.direction().y()) > epsilon ||
47  fabs(direction().z() - seg.direction().z()) > epsilon)
48  return false;
49  return true;
50 }
51 
53  if (nHits() == seg.nHits())
54  return (chi2() > seg.chi2());
55  return (nHits() < seg.nHits());
56 }
57 
58 void DTSegmentCand::add(AssPoint newHit) { theHits.insert(newHit); }
59 
60 void DTSegmentCand::add(std::shared_ptr<DTHitPairForFit> hit, DTEnums::DTCellSide code) {
61  AssPoint newHit(hit, code);
62  theHits.insert(newHit);
63 }
64 
65 void DTSegmentCand::removeHit(AssPoint badHit) { theHits.erase(badHit); }
66 
68  int result = 0;
69 
70  for (AssPointCont::const_iterator hit = theHits.begin(); hit != theHits.end(); ++hit) {
71  for (AssPointCont::const_iterator hit2 = seg.hits().begin(); hit2 != seg.hits().end(); ++hit2) {
72  // if(result) return result ; // TODO, uncomm this line or move it in another func
73  if ((*(*hit).first) == (*(*hit2).first)) {
74  ++result;
75  continue;
76  }
77  }
78  }
79  return result;
80 }
81 
84  const AssPointCont& hits2 = seg.theHits;
85 
86  // if (nSharedHitPairs(seg)==0) return result;
87 
88  AssPointCont::const_iterator hitBegin2 = hits2.begin(), hitEnd2 = hits2.end();
89  for (AssPointCont::const_iterator hit = theHits.begin(), hitEnd = theHits.end(); hit != hitEnd; ++hit) {
90  for (AssPointCont::const_iterator hit2 = hitBegin2; hit2 != hitEnd2; ++hit2) {
91  if ((*(*hit).first) == (*(*hit2).first) && (*hit).second != (*hit2).second) {
92  result.insert(*hit);
93  continue;
94  }
95  }
96  }
97  return result;
98 }
99 
100 bool DTSegmentCand::good() const {
101  // std::cout << NDOF() << " " << chi2()/NDOF() << " " << nHits() << std::endl;
102  if (NDOF() == 0)
103  return false;
104  if (chi2() / NDOF() > chi2max || nHits() < nHitsMin)
105  return false;
106 
107  if (nHits() == nHitsMin && hitsShareLayer())
108  return false;
109 
110  return true;
111 }
112 
114  const unsigned int hitsSize = theHits.size();
115  // we don't expect so many 1D hits, if such a segment arrives just drop it
116  if (hitsSize > 20)
117  return false;
118 
119  int layerN[hitsSize];
120  unsigned int i = 0;
121  for (DTSegmentCand::AssPointCont::iterator assHit = theHits.begin(); assHit != theHits.end(); ++assHit) {
122  layerN[i] = (*assHit).first->id().layerId().layer() + 10 * (*assHit).first->id().superlayerId().superlayer();
123  for (unsigned int j = 0; j < i; j++) {
124  if (layerN[i] == layerN[j])
125  return true;
126  }
127  i++;
128  }
129 
130  return false;
131 }
132 
134  // TODO
135  return 0;
136 }
137 
139  LocalPoint seg2Dposition = position();
140  LocalVector seg2DDirection = direction();
141  double seg2DChi2 = chi2();
142  AlgebraicSymMatrix seg2DCovMatrix = covMatrix();
143 
144  std::vector<DTRecHit1D> hits1D;
145  for (DTSegmentCand::AssPointCont::iterator assHit = theHits.begin(); assHit != theHits.end(); ++assHit) {
146  GlobalPoint hitGlobalPos = theSL->toGlobal((*assHit).first->localPosition((*assHit).second));
147 
148  LocalPoint hitPosInLayer = theSL->layer((*assHit).first->id().layerId())->toLocal(hitGlobalPos);
149 
150  DTRecHit1D hit(((*assHit).first)->id(),
151  (*assHit).second,
152  ((*assHit).first)->digiTime(),
153  hitPosInLayer,
154  ((*assHit).first)->localPositionError());
155  hits1D.push_back(hit);
156  }
157 
158  return new DTSLRecSegment2D(theSL->id(), seg2Dposition, seg2DDirection, seg2DCovMatrix, seg2DChi2, hits1D);
159 }
160 
162  // input position and direction are in sl frame, while must be stored in
163  // chamber one: so I have to extrapolate the position (along the direction) to
164  // the chamber reference plane.
165 
166  LocalPoint posInCh = theSL->chamber()->toLocal(theSL->toGlobal(position()));
167  LocalVector dirInCh = theSL->chamber()->toLocal(theSL->toGlobal(direction()));
168 
169  LocalPoint pos = posInCh + dirInCh * posInCh.z() / cos(dirInCh.theta());
170 
171  double seg2DChi2 = chi2();
172  AlgebraicSymMatrix seg2DCovMatrix = covMatrix();
173 
174  std::vector<DTRecHit1D> hits1D;
175  for (DTSegmentCand::AssPointCont::iterator assHit = theHits.begin(); assHit != theHits.end(); ++assHit) {
176  GlobalPoint hitGlobalPos = theSL->toGlobal((*assHit).first->localPosition((*assHit).second));
177 
178  LocalPoint hitPosInLayer = theSL->chamber()
179  ->superLayer((*assHit).first->id().superlayerId())
180  ->layer((*assHit).first->id().layerId())
181  ->toLocal(hitGlobalPos);
182 
183  DTRecHit1D hit(((*assHit).first)->id(),
184  (*assHit).second,
185  ((*assHit).first)->digiTime(),
186  hitPosInLayer,
187  ((*assHit).first)->localPositionError());
188  hits1D.push_back(hit);
189  }
190 
191  return new DTChamberRecSegment2D(theSL->chamber()->id(), pos, dirInCh, seg2DCovMatrix, seg2DChi2, hits1D);
192 
193  // chamber and Phi SLs' frame are oriented in the same way, only a transaltion,
194  // so the covariance matrix is the same!
195 }
196 
198  return *(pt1.first) < *(pt2.first);
199 }
200 
201 std::ostream& operator<<(std::ostream& out, const DTSegmentCand& seg) {
202  out << " pos: " << seg.position() << " dir: " << seg.direction() << " chi2/nHits: " << seg.chi2() << "/"
203  << seg.DTSegmentCand::nHits() << " t0: " << seg.t0();
204  return out;
205 }
206 
207 std::ostream& operator<<(std::ostream& out, const DTSegmentCand::AssPoint& hit) {
208  // out << "Hits " << (hit.first)->localPosition(DTEnums::Left) <<
209  // " " << hit.second << " Lay " << (hit.first)->layerNumber() << endl;
210  return out;
211 }
Vector3DBase< float, LocalTag >
DTSegmentCand::t0
virtual double t0() const
the t0 of the segment
Definition: DTSegmentCand.h:67
DTSLRecSegment2D
Definition: DTSLRecSegment2D.h:15
DTSegmentCand::operator<
virtual bool operator<(const DTSegmentCand &seg)
less operator based on nHits and chi2
Definition: DTSegmentCand.cc:52
mps_fire.i
i
Definition: mps_fire.py:428
DTSegmentCand::hitsShareLayer
virtual bool hitsShareLayer() const
Definition: DTSegmentCand.cc:113
hfClusterShapes_cfi.hits
hits
Definition: hfClusterShapes_cfi.py:5
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
PV3DBase::theta
Geom::Theta< T > theta() const
Definition: PV3DBase.h:72
pos
Definition: PixelAliasList.h:18
DTRecHit1D
Definition: DTRecHit1D.h:25
DTSegmentCand::direction
virtual LocalVector direction() const
Definition: DTSegmentCand.h:82
DTSegmentCand::nHits
virtual unsigned int nHits() const
Definition: DTSegmentCand.h:58
DTSuperLayer
Definition: DTSuperLayer.h:24
hltPixelTracks_cff.chi2
chi2
Definition: hltPixelTracks_cff.py:25
geometryDiff.epsilon
int epsilon
Definition: geometryDiff.py:26
DTSegmentCand::conflictingHitPairs
virtual AssPointCont conflictingHitPairs(const DTSegmentCand &seg) const
Definition: DTSegmentCand.cc:82
Utilities.operator
operator
Definition: Utilities.py:24
DTSegmentCand::nLayers
virtual int nLayers() const
number of different layers with hits
Definition: DTSegmentCand.cc:133
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
DTSegmentCand.h
DTSegmentCand::NDOF
virtual unsigned int NDOF() const
Definition: DTSegmentCand.h:87
DTSegmentCand::chi2max
static const double chi2max
Definition: DTSegmentCand.h:151
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
DTSegmentCand::position
virtual LocalPoint position() const
Definition: DTSegmentCand.h:79
DTSegmentCand::AssPoint
std::pair< std::shared_ptr< DTHitPairForFit >, DTEnums::DTCellSide > AssPoint
Definition: DTSegmentCand.h:36
DTSegmentCand::hits
virtual const AssPointCont & hits() const
the used hits
Definition: DTSegmentCand.h:122
HLT_FULL_cff.pt1
pt1
Definition: HLT_FULL_cff.py:9870
DTSegmentCand
Definition: DTSegmentCand.h:34
DTSegmentCand::chi2
virtual double chi2() const
the chi2 (NOT chi2/NDOF) of the fit
Definition: DTSegmentCand.h:61
DTSegmentCand::add
virtual void add(AssPoint newHit)
add hits to the hit list.
Definition: DTSegmentCand.cc:58
Point3DBase< float, LocalTag >
DTSegmentCand::operator==
virtual bool operator==(const DTSegmentCand &seg)
equality operator based on position, direction, chi2 and nHits
Definition: DTSegmentCand.cc:37
position
static int position[264][3]
Definition: ReadPGInfo.cc:289
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
DTChamberRecSegment2D
Definition: DTChamberRecSegment2D.h:31
operator<<
std::ostream & operator<<(std::ostream &out, const DTSegmentCand &seg)
Definition: DTSegmentCand.cc:201
DTSegmentCand::AssPointCont
std::set< AssPoint, AssPointLessZ > AssPointCont
Definition: DTSegmentCand.h:38
AlgebraicSymMatrix
CLHEP::HepSymMatrix AlgebraicSymMatrix
Definition: AlgebraicObjects.h:15
DTSegmentCand::nHitsMin
static const unsigned int nHitsMin
Definition: DTSegmentCand.h:152
HLT_FULL_cff.pt2
pt2
Definition: HLT_FULL_cff.py:9872
DTSegmentCand::good
virtual bool good() const
Definition: DTSegmentCand.cc:100
DTChamberRecSegment2D.h
DTSegmentCand::DTSegmentCand
DTSegmentCand(AssPointCont &hits, const DTSuperLayer *sl)
Constructor.
Definition: DTSegmentCand.cc:23
bscTrigger_cfi.theHits
theHits
Definition: bscTrigger_cfi.py:18
DTEnums::DTCellSide
DTCellSide
Which side of the DT cell.
Definition: DTEnums.h:15
toLocal
LocalVector toLocal(const reco::Track::Vector &v, const Surface &s)
Definition: ConversionProducer.h:199
DTSLRecSegment2D.h
DTSegmentCand::removeHit
virtual void removeHit(AssPoint hit)
remove hit from the candidate
Definition: DTSegmentCand.cc:65
DTSegmentCand::AssPointLessZ::operator()
bool operator()(const AssPoint &pt1, const AssPoint &pt2) const
Definition: DTSegmentCand.cc:197
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
mps_fire.result
result
Definition: mps_fire.py:311
DTSegmentCand::nSharedHitPairs
virtual int nSharedHitPairs(const DTSegmentCand &seg) const
number of shared hit pair with other segment candidate
Definition: DTSegmentCand.cc:67
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
DTSuperLayer.h
DTSegmentCand::theHits
AssPointCont theHits
Definition: DTSegmentCand.h:148
hit
Definition: SiStripHitEffFromCalibTree.cc:88
DTSegmentCand::~DTSegmentCand
virtual ~DTSegmentCand()
Destructor.
Definition: DTSegmentCand.cc:34