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 
27  const SiStripRecHit2DCollection* stereoRecHits,
28  const SiStripMatchedRecHit2DCollection* matchedRecHits,
29  const SiPixelRecHitCollection* pixelRecHits) {
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 
43  const SiStripRecHit2DCollection* stereoRecHits,
44  const SiStripMatchedRecHit2DCollection* matchedRecHits,
45  const SiPixelRecHitCollection* pixelRecHits) {
46 
47  rphiHits_ = rphiRecHits;
48  stereoHits_ = stereoRecHits;
49  matchedHits_ = matchedRecHits;
50  pixelHits_ = pixelRecHits;
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  /*
87  * VI January 2012 not supported anymore (at least in this form)
88  * and (by-the-way) is infinitely slow with such a double loop!!!!!
89  *
90  if ( matchedHits_ != 0 ) {
91  DetId useDetId(StripDetId.glued());
92  SiStripMatchedRecHit2DCollection::DetSet matchedDetHits = detSetOrEmpty(*matchedHits_, useDetId);
93  for ( SiStripMatchedRecHit2DCollection::DetSet::const_iterator matchedDetHit = matchedDetHits.begin();
94  matchedDetHit != matchedDetHits.end(); ++matchedDetHit ) {
95  bool add = true;
96  TrackingRecHit *rphi = (TrackingRecHit*)matchedDetHit->monoHit();
97  for ( std::vector<TrackingRecHit*>::iterator hit = RecHitVec.begin();
98  hit != RecHitVec.end();
99  ++hit ) {
100  if ((*hit)->localPosition().x() == rphi->localPosition().x()) {
101  if ((*hit)->localPosition().y() == rphi->localPosition().y()) {
102  add = false;
103  break;
104  }
105  }
106  }
107  if ( add ) {
108  RecHitVec.push_back(rphi);
109  }
110  }
111  } else {
112  edm::LogWarning("RoadSearch") << "matched RecHit collection not set properly";
113  }
114  */
115  }
116  } else if (accessMode_ == rphi_stereo ) {
117  //
118  //return only r-phi and stereo RecHits
119  //
120  if( !StripDetId.glued() ) {
121  if ( rphiHits_ != 0 ) {
123  for ( SiStripRecHit2DCollection::DetSet::const_iterator rphiDetHit = rphiDetHits.begin();
124  rphiDetHit != rphiDetHits.end();
125  ++rphiDetHit ) {
126  RecHitVec.push_back((TrackingRecHit*)(&(*rphiDetHit)));
127  }
128  } else {
129  edm::LogWarning("RoadSearch") << "rphi RecHit collection not set properly";
130  }
131 
132  } else {
133  DetId rphiDetId(StripDetId.glued()+2);
134  if ( rphiHits_ != 0 ) {
135  SiStripRecHit2DCollection::DetSet rphiDetHits = detSetOrEmpty(*rphiHits_, rphiDetId);
136  for ( SiStripRecHit2DCollection::DetSet::const_iterator rphiDetHit = rphiDetHits.begin();
137  rphiDetHit != rphiDetHits.end();
138  ++rphiDetHit ) {
139  RecHitVec.push_back((TrackingRecHit*)(&(*rphiDetHit)));
140  }
141  } else {
142  edm::LogWarning("RoadSearch") << "rphi RecHit collection not set properly";
143  }
144 
145  DetId stereoDetId(StripDetId.glued()+1);
146  if ( stereoHits_ != 0 ) {
147  SiStripRecHit2DCollection::DetSet stereoDetHits = detSetOrEmpty(*stereoHits_, stereoDetId);
148  for ( SiStripRecHit2DCollection::DetSet::const_iterator stereoDetHit = stereoDetHits.begin();
149  stereoDetHit != stereoDetHits.end();
150  ++stereoDetHit ) {
151  RecHitVec.push_back((TrackingRecHit*)(&(*stereoDetHit)));
152  }
153  } else {
154  edm::LogWarning("RoadSearch") << "stereo RecHit collection not set properly";
155  }
156  }
157  } else if (accessMode_ == standard ) {
158  //
159  //single modules: return r-phi RecHits
160  //double modules: return matched RecHits + r-phi RecHits that are not used by matched RecHits
161  //
162  if( !StripDetId.glued() ) {
163  if ( rphiHits_ != 0 ) {
165  for ( SiStripRecHit2DCollection::DetSet::const_iterator rphiDetHit = rphiDetHits.begin();
166  rphiDetHit != rphiDetHits.end();
167  ++rphiDetHit ) {
168  RecHitVec.push_back((TrackingRecHit*)(&(*rphiDetHit)));
169  }
170  } else {
171  edm::LogWarning("RoadSearch") << "rphi RecHit collection not set properly";
172  }
173  } else {
174  if ( matchedHits_ != 0 ) {
175  DetId useDetId(StripDetId.glued());
177  for ( SiStripMatchedRecHit2DCollection::DetSet::const_iterator matchedDetHit = matchedDetHits.begin();
178  matchedDetHit != matchedDetHits.end(); ++matchedDetHit ) {
179  RecHitVec.push_back((TrackingRecHit*)(&(*matchedDetHit)));
180  }
181  } else {
182  edm::LogWarning("RoadSearch") << "matched RecHit collection not set properly";
183  }
184 
185  //check for additional r-phi RecHits (not used by matched RecHits)
186  if(use_rphiRecHits_) {
187  DetId rphiDetId(StripDetId.glued()+2);
188  if ( rphiHits_ != 0 ) {
189  SiStripRecHit2DCollection::DetSet rphiDetHits = detSetOrEmpty(*rphiHits_, rphiDetId);
190  for ( SiStripRecHit2DCollection::DetSet::const_iterator rphiDetHit = rphiDetHits.begin();
191  rphiDetHit != rphiDetHits.end(); ++rphiDetHit ) {
192  bool use_rphi=true;
193  DetId useDetId(StripDetId.glued());
195  //SiStripMatchedRecHit2DCollection::DetSet matchedDetHits = detSetOrEmpty(*matchedHits_, *detid);
196  for ( SiStripMatchedRecHit2DCollection::DetSet::const_iterator matchedDetHit = matchedDetHits.begin();
197  matchedDetHit != matchedDetHits.end(); ++matchedDetHit ) {
198  if (rphiDetHit->sharesInput((TrackingRecHit*)(&(*matchedDetHit)), TrackingRecHit::some)) {
199  use_rphi=false;
200  break;
201  }
202  }
203  if(use_rphi) RecHitVec.push_back((TrackingRecHit*)(&(*rphiDetHit)));
204  }
205  } else {
206  edm::LogWarning("RoadSearch") << "rphi RecHit collection not set properly";
207  }
208  }
209 
210  //check for additional stereo RecHits (not used by matched RecHits)
211  if(use_stereoRecHits_) {
212  DetId stereoDetId(StripDetId.glued()+1);
213  if ( stereoHits_ != 0 ) {
214  SiStripRecHit2DCollection::DetSet stereoDetHits = detSetOrEmpty(*stereoHits_, stereoDetId);
215  for ( SiStripRecHit2DCollection::DetSet::const_iterator stereoDetHit = stereoDetHits.begin();
216  stereoDetHit != stereoDetHits.end(); ++stereoDetHit ) {
217  bool use_stereo=true;
218  DetId useDetId(StripDetId.glued());
220  //SiStripMatchedRecHit2DCollection::DetSet matchedDetHits = detSetOrEmpty(*matchedHits_, *detid);
221  for ( SiStripMatchedRecHit2DCollection::DetSet::const_iterator matchedDetHit = matchedDetHits.begin();
222  matchedDetHit != matchedDetHits.end(); ++matchedDetHit ) {
223  if (stereoDetHit->sharesInput((TrackingRecHit*)(&(*matchedDetHit)), TrackingRecHit::some)) {
224  use_stereo=false;
225  break;
226  }
227  }
228  if(use_stereo) RecHitVec.push_back((TrackingRecHit*)(&(*stereoDetHit)));
229  }
230  } else {
231  edm::LogWarning("RoadSearch") << "stereo RecHit collection not set properly";
232  }
233  }
234  }
235  }
236 
237  } else if ( (unsigned int)detid->subdetId() == PixelSubdetector::PixelBarrel
238  || (unsigned int)detid->subdetId() == PixelSubdetector::PixelEndcap) {
239 
240  if ( pixelHits_ != 0 ) {
242  for ( SiPixelRecHitCollection::DetSet::const_iterator pixelDetHit = pixelDetHits.begin();
243  pixelDetHit!= pixelDetHits.end(); ++pixelDetHit) {
244  RecHitVec.push_back((TrackingRecHit*)(&(*pixelDetHit)));
245  }
246  } else {
247  edm::LogWarning("RoadSearch") << "pixel RecHit collection not set properly";
248  }
249  } else {
250 
251  edm::LogError("RoadSearch") << "NEITHER PIXEL NOR STRIP DETECTOR ID";
252 
253  }
254 
255 
256  return RecHitVec;
257 }
258 
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
bool use_stereoRecHits_
Definition: DetHitAccess.h:53
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
long double T
bool use_rphiRecHits_
Definition: DetHitAccess.h:52
accessMode accessMode_
Definition: DetHitAccess.h:50
iterator begin()
Definition: DetSetNew.h:56