CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DetHitAccess.cc
Go to the documentation of this file.
2 
4 template<typename T>
6  typename edmNew::DetSetVector<T>::const_iterator iter = dsv.find(detid.rawId());
7  if (iter == dsv.end()) {
8  return typename edmNew::DetSet<T>(detid.rawId(), static_cast<const T *>(0), size_t(0) );
9  } else {
10  return *iter;
11  }
12 }
13 
14 
16  // default for access mode
18 
19  use_rphiRecHits_ = true;
20  use_rphiRecHits_ = true;
21 }
22 
24 }
25 
30 
31  // default for access mode
33 
34  use_rphiRecHits_ = true;
35  use_stereoRecHits_ = true;
36 
37  // set collections
38  setCollections(rphiRecHits,stereoRecHits,matchedRecHits,pixelRecHits);
39 
40 }
41 
46 
51 
52 }
53 
54 
55 std::vector<TrackingRecHit*> DetHitAccess::getHitVector(const DetId* detid) {
56  //
57  //DetId that is given to getHitVector is *always* rphi
58  //
59 
60  std::vector<TrackingRecHit*> RecHitVec;
61 
62  if ( (unsigned int)detid->subdetId() == StripSubdetector::TIB
63  || (unsigned int)detid->subdetId() == StripSubdetector::TOB
64  || (unsigned int)detid->subdetId() == StripSubdetector::TID
65  || (unsigned int)detid->subdetId() == StripSubdetector::TEC ) {
66 
67  StripSubdetector StripDetId(*detid);
68 
69 
70  if (accessMode_ == rphi ) {
71  //
72  //return only r-phi RecHits; in case of double modules eliminate recurring r-phi RecHits
73  //
74  if( !StripDetId.glued() ) {
75  if ( rphiHits_ != 0 ) {
77  for ( SiStripRecHit2DCollection::DetSet::const_iterator rphiDetHit = rphiDetHits.begin();
78  rphiDetHit != rphiDetHits.end();
79  ++rphiDetHit ) {
80  RecHitVec.push_back((TrackingRecHit*)(&(*rphiDetHit)));
81  }
82  } else {
83  edm::LogWarning("RoadSearch") << "rphi RecHit collection not set properly";
84  }
85  } else {
86  if ( matchedHits_ != 0 ) {
87  DetId useDetId(StripDetId.glued());
89  for ( SiStripMatchedRecHit2DCollection::DetSet::const_iterator matchedDetHit = matchedDetHits.begin();
90  matchedDetHit != matchedDetHits.end(); ++matchedDetHit ) {
91  bool add = true;
92  TrackingRecHit *rphi = (TrackingRecHit*)matchedDetHit->monoHit();
93  for ( std::vector<TrackingRecHit*>::iterator hit = RecHitVec.begin();
94  hit != RecHitVec.end();
95  ++hit ) {
96  if ((*hit)->localPosition().x() == rphi->localPosition().x()) {
97  if ((*hit)->localPosition().y() == rphi->localPosition().y()) {
98  add = false;
99  break;
100  }
101  }
102  }
103  if ( add ) {
104  RecHitVec.push_back(rphi);
105  }
106  }
107  } else {
108  edm::LogWarning("RoadSearch") << "matched RecHit collection not set properly";
109  }
110  }
111  } else if (accessMode_ == rphi_stereo ) {
112  //
113  //return only r-phi and stereo RecHits
114  //
115  if( !StripDetId.glued() ) {
116  if ( rphiHits_ != 0 ) {
118  for ( SiStripRecHit2DCollection::DetSet::const_iterator rphiDetHit = rphiDetHits.begin();
119  rphiDetHit != rphiDetHits.end();
120  ++rphiDetHit ) {
121  RecHitVec.push_back((TrackingRecHit*)(&(*rphiDetHit)));
122  }
123  } else {
124  edm::LogWarning("RoadSearch") << "rphi RecHit collection not set properly";
125  }
126 
127  } else {
128  DetId rphiDetId(StripDetId.glued()+2);
129  if ( rphiHits_ != 0 ) {
130  SiStripRecHit2DCollection::DetSet rphiDetHits = detSetOrEmpty(*rphiHits_, rphiDetId);
131  for ( SiStripRecHit2DCollection::DetSet::const_iterator rphiDetHit = rphiDetHits.begin();
132  rphiDetHit != rphiDetHits.end();
133  ++rphiDetHit ) {
134  RecHitVec.push_back((TrackingRecHit*)(&(*rphiDetHit)));
135  }
136  } else {
137  edm::LogWarning("RoadSearch") << "rphi RecHit collection not set properly";
138  }
139 
140  DetId stereoDetId(StripDetId.glued()+1);
141  if ( stereoHits_ != 0 ) {
142  SiStripRecHit2DCollection::DetSet stereoDetHits = detSetOrEmpty(*stereoHits_, stereoDetId);
143  for ( SiStripRecHit2DCollection::DetSet::const_iterator stereoDetHit = stereoDetHits.begin();
144  stereoDetHit != stereoDetHits.end();
145  ++stereoDetHit ) {
146  RecHitVec.push_back((TrackingRecHit*)(&(*stereoDetHit)));
147  }
148  } else {
149  edm::LogWarning("RoadSearch") << "stereo RecHit collection not set properly";
150  }
151  }
152  } else if (accessMode_ == standard ) {
153  //
154  //single modules: return r-phi RecHits
155  //double modules: return matched RecHits + r-phi RecHits that are not used by matched RecHits
156  //
157  if( !StripDetId.glued() ) {
158  if ( rphiHits_ != 0 ) {
160  for ( SiStripRecHit2DCollection::DetSet::const_iterator rphiDetHit = rphiDetHits.begin();
161  rphiDetHit != rphiDetHits.end();
162  ++rphiDetHit ) {
163  RecHitVec.push_back((TrackingRecHit*)(&(*rphiDetHit)));
164  }
165  } else {
166  edm::LogWarning("RoadSearch") << "rphi RecHit collection not set properly";
167  }
168  } else {
169  if ( matchedHits_ != 0 ) {
170  DetId useDetId(StripDetId.glued());
172  for ( SiStripMatchedRecHit2DCollection::DetSet::const_iterator matchedDetHit = matchedDetHits.begin();
173  matchedDetHit != matchedDetHits.end(); ++matchedDetHit ) {
174  RecHitVec.push_back((TrackingRecHit*)(&(*matchedDetHit)));
175  }
176  } else {
177  edm::LogWarning("RoadSearch") << "matched RecHit collection not set properly";
178  }
179 
180  //check for additional r-phi RecHits (not used by matched RecHits)
181  if(use_rphiRecHits_) {
182  DetId rphiDetId(StripDetId.glued()+2);
183  if ( rphiHits_ != 0 ) {
184  SiStripRecHit2DCollection::DetSet rphiDetHits = detSetOrEmpty(*rphiHits_, rphiDetId);
185  for ( SiStripRecHit2DCollection::DetSet::const_iterator rphiDetHit = rphiDetHits.begin();
186  rphiDetHit != rphiDetHits.end(); ++rphiDetHit ) {
187  bool use_rphi=true;
188  DetId useDetId(StripDetId.glued());
190  //SiStripMatchedRecHit2DCollection::DetSet matchedDetHits = detSetOrEmpty(*matchedHits_, *detid);
191  for ( SiStripMatchedRecHit2DCollection::DetSet::const_iterator matchedDetHit = matchedDetHits.begin();
192  matchedDetHit != matchedDetHits.end(); ++matchedDetHit ) {
193  if (rphiDetHit->localPosition().x()==matchedDetHit->monoHit()->localPosition().x()
194  && rphiDetHit->localPosition().y()==matchedDetHit->monoHit()->localPosition().y() ) {
195  use_rphi=false;
196  break;
197  }
198  }
199  if(use_rphi) RecHitVec.push_back((TrackingRecHit*)(&(*rphiDetHit)));
200  }
201  } else {
202  edm::LogWarning("RoadSearch") << "rphi RecHit collection not set properly";
203  }
204  }
205 
206  //check for additional stereo RecHits (not used by matched RecHits)
207  if(use_stereoRecHits_) {
208  DetId stereoDetId(StripDetId.glued()+1);
209  if ( stereoHits_ != 0 ) {
210  SiStripRecHit2DCollection::DetSet stereoDetHits = detSetOrEmpty(*stereoHits_, stereoDetId);
211  for ( SiStripRecHit2DCollection::DetSet::const_iterator stereoDetHit = stereoDetHits.begin();
212  stereoDetHit != stereoDetHits.end(); ++stereoDetHit ) {
213  bool use_stereo=true;
214  DetId useDetId(StripDetId.glued());
216  //SiStripMatchedRecHit2DCollection::DetSet matchedDetHits = detSetOrEmpty(*matchedHits_, *detid);
217  for ( SiStripMatchedRecHit2DCollection::DetSet::const_iterator matchedDetHit = matchedDetHits.begin();
218  matchedDetHit != matchedDetHits.end(); ++matchedDetHit ) {
219  if (stereoDetHit->localPosition().x()==matchedDetHit->stereoHit()->localPosition().x()
220  && stereoDetHit->localPosition().y()==matchedDetHit->stereoHit()->localPosition().y() ) {
221  use_stereo=false;
222  break;
223  }
224  }
225  if(use_stereo) RecHitVec.push_back((TrackingRecHit*)(&(*stereoDetHit)));
226  }
227  } else {
228  edm::LogWarning("RoadSearch") << "stereo RecHit collection not set properly";
229  }
230  }
231  }
232  }
233 
234  } else if ( (unsigned int)detid->subdetId() == PixelSubdetector::PixelBarrel
235  || (unsigned int)detid->subdetId() == PixelSubdetector::PixelEndcap) {
236 
237  if ( pixelHits_ != 0 ) {
239  for ( SiPixelRecHitCollection::DetSet::const_iterator pixelDetHit = pixelDetHits.begin();
240  pixelDetHit!= pixelDetHits.end(); ++pixelDetHit) {
241  RecHitVec.push_back((TrackingRecHit*)(&(*pixelDetHit)));
242  }
243  } else {
244  edm::LogWarning("RoadSearch") << "pixel RecHit collection not set properly";
245  }
246  } else {
247 
248  edm::LogError("RoadSearch") << "NEITHER PIXEL NOR STRIP DETECTOR ID";
249 
250  }
251 
252 
253  return RecHitVec;
254 }
255 
const SiStripRecHit2DCollection * stereoHits_
Definition: DetHitAccess.h:56
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
void setCollections(const SiStripRecHit2DCollection *rphiRecHits, const SiStripRecHit2DCollection *stereoRecHits, const SiStripMatchedRecHit2DCollection *matchedRecHits, const SiPixelRecHitCollection *pixelRecHits)
Definition: DetHitAccess.cc:42
T y() const
Definition: PV3DBase.h:57
bool use_stereoRecHits_
Definition: DetHitAccess.h:53
void add(const std::vector< const T * > &source, std::vector< const T * > &dest)
const_iterator find(id_type i) const
uint32_t rawId() const
get the raw id
Definition: DetId.h:45
const SiPixelRecHitCollection * pixelHits_
Definition: DetHitAccess.h:58
unsigned int glued() const
glued
const_iterator end() const
std::vector< TrackingRecHit * > getHitVector(const DetId *detid)
Definition: DetHitAccess.cc:55
const SiStripRecHit2DCollection * rphiHits_
Definition: DetHitAccess.h:55
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:39
Definition: DetId.h:20
edmNew::DetSet< T > detSetOrEmpty(const edmNew::DetSetVector< T > &dsv, DetId detid)
I need this because DetHitAccess assumes that it can search a hit container using a detid which is no...
Definition: DetHitAccess.cc:5
iterator end()
Definition: DetSetNew.h:59
const SiStripMatchedRecHit2DCollection * matchedHits_
Definition: DetHitAccess.h:57
T x() const
Definition: PV3DBase.h:56
virtual LocalPoint localPosition() const =0
bool use_rphiRecHits_
Definition: DetHitAccess.h:52
accessMode accessMode_
Definition: DetHitAccess.h:50
iterator begin()
Definition: DetSetNew.h:56