CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CSCSegment.cc
Go to the documentation of this file.
1 
8 #include <iostream>
9 
10 namespace {
11  // Get CSCDetId from one of the rechits, but then remove the layer part so it's a _chamber_ id
12  inline
13  DetId buildDetId(CSCDetId id) {
14  return CSCDetId(id.endcap(),id.station(),id.ring(),id.chamber(), 0);
15  }
16 
17 }
18 
19 CSCSegment::CSCSegment(std::vector<const CSCRecHit2D*> proto_segment, LocalPoint origin,
20  LocalVector direction, AlgebraicSymMatrix errors, double chi2) :
21  RecSegment(buildDetId(proto_segment.front()->cscDetId())),
22  theOrigin(origin),
23  theLocalDirection(direction), theCovMatrix(errors), theChi2(chi2), aME11a_duplicate(false) {
24 
25  for(unsigned int i=0; i<proto_segment.size(); ++i)
26  theCSCRecHits.push_back(*proto_segment[i]);
27 }
28 
30 
31 std::vector<const TrackingRecHit*> CSCSegment::recHits() const{
32  std::vector<const TrackingRecHit*> pointersOfRecHits;
33  for (std::vector<CSCRecHit2D>::const_iterator irh = theCSCRecHits.begin(); irh!=theCSCRecHits.end(); ++irh) {
34  pointersOfRecHits.push_back(&(*irh));
35  }
36  return pointersOfRecHits;
37 }
38 
39 std::vector<TrackingRecHit*> CSCSegment::recHits() {
40 
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 
56 
58  // For consistency with DT and what we require for the TrackingRecHit interface,
59  // the order of the parameters in the returned vector should be (dx/dz, dy/dz, x, z)
60 
62 
63  result[0] = theLocalDirection.x()/theLocalDirection.z();
64  result[1] = theLocalDirection.y()/theLocalDirection.z();
65  result[2] = theOrigin.x();
66  result[3] = theOrigin.y();
67 
68  return result;
69 }
70 
71 
73  static AlgebraicMatrix theProjectionMatrix( 4, 5, 0);
74  static bool isInitialized = false;
75  if (!isInitialized) {
76  theProjectionMatrix[0][1] = 1;
77  theProjectionMatrix[1][2] = 1;
78  theProjectionMatrix[2][3] = 1;
79  theProjectionMatrix[3][4] = 1;
80  isInitialized=true;
81  }
82  return theProjectionMatrix;
83 }
84 
85 void CSCSegment::setDuplicateSegments(std::vector<CSCSegment*> & duplicates){
86  theDuplicateSegments.clear();
87  for(unsigned int i=0; i<duplicates.size(); ++i){
88  theDuplicateSegments.push_back(*duplicates[i]);
89  //avoid copying duplicates of duplicates of duplicates...
90  theDuplicateSegments.back().theDuplicateSegments.resize(0);
91  }
92 }
93 
94 bool CSCSegment::testSharesAllInSpecificRecHits( const std::vector<CSCRecHit2D>& specificRecHits_1,
95  const std::vector<CSCRecHit2D>& specificRecHits_2,
96  CSCRecHit2D::SharedInputType sharesInput) const{
97  const std::vector<CSCRecHit2D> * rhContainer_1 = &specificRecHits_1;
98  const std::vector<CSCRecHit2D> * rhContainer_2 = &specificRecHits_2;
99  if(specificRecHits_1.size()>specificRecHits_2.size()){
100  rhContainer_2 = &specificRecHits_1;
101  rhContainer_1 = &specificRecHits_2;
102  }
103  //
104  bool shareConditionPassed = true;
105  for ( std::vector<CSCRecHit2D>::const_iterator itRH = rhContainer_1->begin();
106  itRH != rhContainer_1->end(); ++itRH) {
107  const CSCRecHit2D *firstRecHit = &(*itRH);
108  bool sharedHit = false;
109  for ( std::vector<CSCRecHit2D>::const_iterator itRH2 = rhContainer_2->begin();
110  itRH2 != rhContainer_2->end(); ++itRH2) {
111  if(itRH2->sharesInput(firstRecHit,sharesInput)){
112  sharedHit = true;
113  break;
114  }
115  }
116  if(!sharedHit){
117  shareConditionPassed = false;
118  break;
119  }
120  }
121  return shareConditionPassed;
122 }
123 
124 //bool CSCSegment::sharesRecHits(CSCSegment & anotherSegment, CSCRecHit2D::SharedInputType sharesInput){
125  // 2 tracks through a chamber leave 4 rechits per layer (2 strips x 2 wire groups)
126  // this function finds segments sharing wires or strips (first the rechits by sharesInput() )
127  // there could probably be more complicated cases with partial sharing (but this needs studies)
128  //
129  //return testSharesAllInSpecificRecHits( theCSCRecHits , anotherSegment.specificRecHits(), sharesInput);
130 //}
131 
132 bool CSCSegment::sharesRecHits(const CSCSegment & anotherSegment, CSCRecHit2D::SharedInputType sharesInput) const {
134 }
135 
136 //
137 bool CSCSegment::sharesRecHits(const CSCSegment & anotherSegment) const {
140  return true;
141  }
142  else{
143  return false;
144  }
145 }
146 
147 //
148 void CSCSegment::print() const {
149  std::cout << *this << std::endl;
150 }
151 
152 std::ostream& operator<<(std::ostream& os, const CSCSegment& seg) {
153  os << "CSCSegment: local pos = " << seg.localPosition() <<
154  " posErr = (" << sqrt(seg.localPositionError().xx())<<","<<sqrt(seg.localPositionError().yy())<<
155  "0,)\n"<<
156  " dir = " << seg.localDirection() <<
157  " dirErr = (" << sqrt(seg.localDirectionError().xx())<<","<<sqrt(seg.localDirectionError().yy())<<
158  "0,)\n"<<
159  " chi2/ndf = " << seg.chi2()/double(seg.degreesOfFreedom()) <<
160  " #rechits = " << seg.specificRecHits().size()<<
161  " ME1/1a duplicates : "<<seg.duplicateSegments().size();
162  return os;
163 }
164 
165 /*
166 const CSCChamber* CSCSegment::chamber() const { return theChamber; }
167 */
int i
Definition: DBlmapReader.cc:9
float xx() const
Definition: LocalError.h:19
AlgebraicVector parameters() const
Parameters of the segment, for the track fit in the order (dx/dz, dy/dz, x, y )
Definition: CSCSegment.cc:57
LocalError localPositionError() const
Definition: CSCSegment.cc:48
const std::vector< CSCSegment > & duplicateSegments() const
Definition: CSCSegment.h:76
T y() const
Definition: PV3DBase.h:57
virtual bool sharesInput(const TrackingRecHit *other, SharedInputType what) const
std::vector< CSCSegment > theDuplicateSegments
Definition: CSCSegment.h:98
void setDuplicateSegments(std::vector< CSCSegment * > &duplicates)
Definition: CSCSegment.cc:85
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:187
virtual int degreesOfFreedom() const
Degrees of freedom of the segment fit.
Definition: CSCSegment.h:62
LocalPoint localPosition() const
Definition: CSCSegment.h:39
LocalVector localDirection() const
Local direction.
Definition: CSCSegment.h:42
bool testSharesAllInSpecificRecHits(const std::vector< CSCRecHit2D > &specificRecHits_1, const std::vector< CSCRecHit2D > &specificRecHits_2, CSCRecHit2D::SharedInputType) const
Definition: CSCSegment.cc:94
CLHEP::HepMatrix AlgebraicMatrix
float yy() const
Definition: LocalError.h:21
T sqrt(T t)
Definition: SSEVec.h:28
AlgebraicSymMatrix theCovMatrix
Definition: CSCSegment.h:95
T z() const
Definition: PV3DBase.h:58
tuple result
Definition: query.py:137
LocalPoint theOrigin
Definition: CSCSegment.h:93
virtual ~CSCSegment()
Destructor.
Definition: CSCSegment.cc:29
virtual std::vector< const TrackingRecHit * > recHits() const
Access to component RecHits (if any)
Definition: CSCSegment.cc:31
const std::vector< CSCRecHit2D > & specificRecHits() const
Definition: CSCSegment.h:66
Definition: DetId.h:20
CLHEP::HepVector AlgebraicVector
std::vector< CSCRecHit2D > theCSCRecHits
Definition: CSCSegment.h:92
CSCSegment()
Default constructor.
Definition: CSCSegment.h:27
virtual AlgebraicMatrix projectionMatrix() const
The projection matrix relates the trajectory state parameters to the segment parameters().
Definition: CSCSegment.cc:72
double chi2() const
Chi2 of the segment fit.
Definition: CSCSegment.h:58
LocalVector theLocalDirection
Definition: CSCSegment.h:94
CLHEP::HepSymMatrix AlgebraicSymMatrix
tuple cout
Definition: gather_cfg.py:41
bool sharesRecHits(const CSCSegment &anotherSegment, CSCRecHit2D::SharedInputType sharesInput) const
Definition: CSCSegment.cc:132
void print() const
Definition: CSCSegment.cc:148
T x() const
Definition: PV3DBase.h:56
LocalError localDirectionError() const
Error on the local direction.
Definition: CSCSegment.cc:52