CMS 3D CMS Logo

CSCSegment.cc
Go to the documentation of this file.
1 
7 #include <iostream>
8 
9 namespace {
10  // Get CSCDetId from one of the rechits, but then remove the layer part so it's a _chamber_ id
11  inline DetId buildDetId(CSCDetId id) { return CSCDetId(id.endcap(), id.station(), id.ring(), id.chamber(), 0); }
12 
13 } // namespace
14 
15 CSCSegment::CSCSegment(const std::vector<const CSCRecHit2D*>& proto_segment,
16  LocalPoint origin,
17  LocalVector direction,
19  double chi2)
20  : RecSegment(buildDetId(proto_segment.front()->cscDetId())),
21  theOrigin(origin),
22  theLocalDirection(direction),
23  theCovMatrix(errors),
24  theChi2(chi2),
25  aME11a_duplicate(false) {
26  for (unsigned int i = 0; i < proto_segment.size(); ++i)
27  theCSCRecHits.push_back(*proto_segment[i]);
28 }
29 
31 
32 std::vector<const TrackingRecHit*> CSCSegment::recHits() const {
33  std::vector<const TrackingRecHit*> pointersOfRecHits;
34  for (std::vector<CSCRecHit2D>::const_iterator irh = theCSCRecHits.begin(); irh != theCSCRecHits.end(); ++irh) {
35  pointersOfRecHits.push_back(&(*irh));
36  }
37  return pointersOfRecHits;
38 }
39 
40 std::vector<TrackingRecHit*> CSCSegment::recHits() {
41  std::vector<TrackingRecHit*> pointersOfRecHits;
42  for (std::vector<CSCRecHit2D>::iterator irh = theCSCRecHits.begin(); irh != theCSCRecHits.end(); ++irh) {
43  pointersOfRecHits.push_back(&(*irh));
44  }
45  return pointersOfRecHits;
46 }
47 
49  return LocalError(theCovMatrix[2][2], theCovMatrix[2][3], theCovMatrix[3][3]);
50 }
51 
53  return LocalError(theCovMatrix[0][0], theCovMatrix[0][1], theCovMatrix[1][1]);
54 }
55 
57  // For consistency with DT and what we require for the TrackingRecHit interface,
58  // the order of the parameters in the returned vector should be (dx/dz, dy/dz, x, z)
59 
61 
64  result[2] = theOrigin.x();
65  result[3] = theOrigin.y();
66 
67  return result;
68 }
69 
71  AlgebraicMatrix m(4, 5, 0);
72  m[0][1] = 1;
73  m[1][2] = 1;
74  m[2][3] = 1;
75  m[3][4] = 1;
76  return m;
77 }
78 
80 
82 
83 void CSCSegment::setDuplicateSegments(std::vector<CSCSegment*>& duplicates) {
84  theDuplicateSegments.clear();
85  for (unsigned int i = 0; i < duplicates.size(); ++i) {
86  theDuplicateSegments.push_back(*duplicates[i]);
87  //avoid copying duplicates of duplicates of duplicates...
88  theDuplicateSegments.back().theDuplicateSegments.resize(0);
89  }
90 }
91 
92 bool CSCSegment::testSharesAllInSpecificRecHits(const std::vector<CSCRecHit2D>& specificRecHits_1,
93  const std::vector<CSCRecHit2D>& specificRecHits_2,
94  CSCRecHit2D::SharedInputType sharesInput) const {
95  const std::vector<CSCRecHit2D>* rhContainer_1 = &specificRecHits_1;
96  const std::vector<CSCRecHit2D>* rhContainer_2 = &specificRecHits_2;
97  if (specificRecHits_1.size() > specificRecHits_2.size()) {
98  rhContainer_2 = &specificRecHits_1;
99  rhContainer_1 = &specificRecHits_2;
100  }
101  //
102  bool shareConditionPassed = true;
103  for (std::vector<CSCRecHit2D>::const_iterator itRH = rhContainer_1->begin(); itRH != rhContainer_1->end(); ++itRH) {
104  const CSCRecHit2D* firstRecHit = &(*itRH);
105  bool sharedHit = false;
106  for (std::vector<CSCRecHit2D>::const_iterator itRH2 = rhContainer_2->begin(); itRH2 != rhContainer_2->end();
107  ++itRH2) {
108  if (itRH2->sharesInput(firstRecHit, sharesInput)) {
109  sharedHit = true;
110  break;
111  }
112  }
113  if (!sharedHit) {
114  shareConditionPassed = false;
115  break;
116  }
117  }
118  return shareConditionPassed;
119 }
120 
121 //bool CSCSegment::sharesRecHits(CSCSegment & anotherSegment, CSCRecHit2D::SharedInputType sharesInput){
122 // 2 tracks through a chamber leave 4 rechits per layer (2 strips x 2 wire groups)
123 // this function finds segments sharing wires or strips (first the rechits by sharesInput() )
124 // there could probably be more complicated cases with partial sharing (but this needs studies)
125 //
126 //return testSharesAllInSpecificRecHits( theCSCRecHits , anotherSegment.specificRecHits(), sharesInput);
127 //}
128 
129 bool CSCSegment::sharesRecHits(const CSCSegment& anotherSegment, CSCRecHit2D::SharedInputType sharesInput) const {
131 }
132 
133 //
134 bool CSCSegment::sharesRecHits(const CSCSegment& anotherSegment) const {
137  return true;
138  } else {
139  return false;
140  }
141 }
142 //
143 
144 float CSCSegment::time() const {
145  float averageTime = 0;
146  std::vector<float> wireTimes;
147  for (std::vector<CSCRecHit2D>::const_iterator itRH = theCSCRecHits.begin(); itRH != theCSCRecHits.end(); ++itRH) {
148  const CSCRecHit2D* recHit = &(*itRH);
149  averageTime += recHit->tpeak();
150  averageTime += recHit->wireTime();
151  wireTimes.push_back(recHit->wireTime());
152  }
153  averageTime = averageTime / (2 * theCSCRecHits.size());
154 
155  //The wire times have a long tail that has to be pruned. The strip times (tpeak) are fine
156  bool modified = true;
157  while (modified) {
158  modified = false;
159  double maxDiff = -1;
160  std::vector<float>::iterator maxHit;
161  for (std::vector<float>::iterator itWT = wireTimes.begin(); itWT != wireTimes.end(); ++itWT) {
162  float diff = fabs(*itWT - averageTime);
163  if (diff > maxDiff) {
164  maxDiff = diff;
165  maxHit = itWT;
166  }
167  }
168  if (maxDiff > 26) {
169  int N = theCSCRecHits.size() + wireTimes.size();
170  averageTime = (averageTime * N - (*maxHit)) / (N - 1);
171  wireTimes.erase(maxHit);
172  modified = true;
173  }
174  }
175  return averageTime;
176 }
177 
178 //
179 void CSCSegment::print() const { std::cout << *this << std::endl; }
180 
181 std::ostream& operator<<(std::ostream& os, const CSCSegment& seg) {
182  os << "CSCSegment: local pos = " << seg.localPosition() << " posErr = (" << sqrt(seg.localPositionError().xx()) << ","
183  << sqrt(seg.localPositionError().yy()) << "0,)\n"
184  << " dir = " << seg.localDirection() << " dirErr = (" << sqrt(seg.localDirectionError().xx()) << ","
185  << sqrt(seg.localDirectionError().yy()) << "0,)\n"
186  << " chi2/ndf = " << seg.chi2() / double(seg.degreesOfFreedom())
187  << " #rechits = " << seg.specificRecHits().size() << " ME1/1a duplicates : " << seg.duplicateSegments().size();
188  return os;
189 }
190 
191 /*
192 const CSCChamber* CSCSegment::chamber() const { return theChamber; }
193 */
CSCSegment::specificRecHits
const std::vector< CSCRecHit2D > & specificRecHits() const
Definition: CSCSegment.h:66
Vector3DBase< float, LocalTag >
change_name.diff
diff
Definition: change_name.py:13
CSCSegment::setDuplicateSegments
void setDuplicateSegments(std::vector< CSCSegment * > &duplicates)
Definition: CSCSegment.cc:83
mps_fire.i
i
Definition: mps_fire.py:355
funct::false
false
Definition: Factorize.h:34
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
relativeConstraints.station
station
Definition: relativeConstraints.py:67
operator<<
std::ostream & operator<<(std::ostream &os, const CSCSegment &seg)
Definition: CSCSegment.cc:181
CSCSegment::time
float time() const
Definition: CSCSegment.cc:144
gather_cfg.cout
cout
Definition: gather_cfg.py:144
RecSegment
Definition: RecSegment.h:27
reco::castor::maxDiff
float maxDiff(float one, float two, float three, float four)
Definition: CastorAlgoUtils.cc:19
hltPixelTracks_cff.chi2
chi2
Definition: hltPixelTracks_cff.py:25
makeMuonMisalignmentScenario.endcap
endcap
Definition: makeMuonMisalignmentScenario.py:320
CSCSegment::theDuplicateSegments
std::vector< CSCSegment > theDuplicateSegments
Definition: CSCSegment.h:99
CSCSegment::~CSCSegment
~CSCSegment() override
Destructor.
Definition: CSCSegment.cc:30
rpcPointValidation_cfi.recHit
recHit
Definition: rpcPointValidation_cfi.py:7
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
DetId
Definition: DetId.h:17
errors
Definition: errors.py:1
AlgebraicVector
CLHEP::HepVector AlgebraicVector
Definition: AlgebraicObjects.h:13
LocalError::xx
float xx() const
Definition: LocalError.h:22
CSCSegment::duplicateSegments
const std::vector< CSCSegment > & duplicateSegments() const
Definition: CSCSegment.h:76
CSCSegment::degreesOfFreedom
int degreesOfFreedom() const override
Degrees of freedom of the segment fit.
Definition: CSCSegment.h:62
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:72
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
N
#define N
Definition: blowfish.cc:9
Point3DBase< float, LocalTag >
CSCSegment
Definition: CSCSegment.h:21
CSCSegment::theCSCRecHits
std::vector< CSCRecHit2D > theCSCRecHits
Definition: CSCSegment.h:93
MTVHistoProducerAlgoForTrackerBlock_cfi.maxHit
maxHit
Definition: MTVHistoProducerAlgoForTrackerBlock_cfi.py:37
CSCSegment::print
void print() const
Definition: CSCSegment.cc:179
CSCRecHit2D
Definition: CSCRecHit2D.h:18
CSCSegment::projectionMatrix
AlgebraicMatrix projectionMatrix() const override
The projection matrix relates the trajectory state parameters to the segment parameters().
Definition: CSCSegment.cc:81
CSCRecHit2D::someStrips
Definition: CSCRecHit2D.h:29
LocalError
Definition: LocalError.h:12
CSCDetId
Definition: CSCDetId.h:26
CSCSegment::localDirection
LocalVector localDirection() const override
Local direction.
Definition: CSCSegment.h:42
CSCSegment::localDirectionError
LocalError localDirectionError() const override
Error on the local direction.
Definition: CSCSegment.cc:52
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
CSCSegment::testSharesAllInSpecificRecHits
bool testSharesAllInSpecificRecHits(const std::vector< CSCRecHit2D > &specificRecHits_1, const std::vector< CSCRecHit2D > &specificRecHits_2, CSCRecHit2D::SharedInputType) const
Definition: CSCSegment.cc:92
AlgebraicSymMatrix
CLHEP::HepSymMatrix AlgebraicSymMatrix
Definition: AlgebraicObjects.h:15
CSCSegment::CSCSegment
CSCSegment()
Default constructor.
Definition: CSCSegment.h:24
CSCSegment::theCovMatrix
AlgebraicSymMatrix theCovMatrix
Definition: CSCSegment.h:96
CSCSegment::sharesRecHits
bool sharesRecHits(const CSCSegment &anotherSegment, CSCRecHit2D::SharedInputType sharesInput) const
Definition: CSCSegment.cc:129
CSCSegment::theOrigin
LocalPoint theOrigin
Definition: CSCSegment.h:94
CSCRecHit2D::someWires
Definition: CSCRecHit2D.h:27
AlgebraicMatrix
CLHEP::HepMatrix AlgebraicMatrix
Definition: AlgebraicObjects.h:14
relativeConstraints.ring
ring
Definition: relativeConstraints.py:68
relativeConstraints.chamber
chamber
Definition: relativeConstraints.py:53
theProjectionMatrix
static const AlgebraicMatrix theProjectionMatrix
Definition: CSCSegment.cc:79
TrackingRecHit::sharesInput
virtual bool sharesInput(const TrackingRecHit *other, SharedInputType what) const
Definition: TrackingRecHit.cc:12
CSCSegment::theLocalDirection
LocalVector theLocalDirection
Definition: CSCSegment.h:95
CSCSegment.h
CSCSegment::parameters
AlgebraicVector parameters() const override
Parameters of the segment, for the track fit in the order (dx/dz, dy/dz, x, y )
Definition: CSCSegment.cc:56
CSCSegment::chi2
double chi2() const override
Chi2 of the segment fit.
Definition: CSCSegment.h:58
mps_fire.result
result
Definition: mps_fire.py:303
CSCRecHit2D::SharedInputType
SharedInputType
Definition: CSCRecHit2D.h:23
createStaticMatrix
AlgebraicMatrix createStaticMatrix()
Definition: CSCSegment.cc:70
CSCSegment::localPosition
LocalPoint localPosition() const override
Definition: CSCSegment.h:39
LocalError::yy
float yy() const
Definition: LocalError.h:24
CSCSegment::localPositionError
LocalError localPositionError() const override
Definition: CSCSegment.cc:48
CSCSegment::recHits
std::vector< const TrackingRecHit * > recHits() const override
Access to component RecHits (if any)
Definition: CSCSegment.cc:32