CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Private Attributes
DetHitAccess Class Reference

#include <DetHitAccess.h>

Public Types

enum  accessMode { standard, rphi, rphi_stereo }
 

Public Member Functions

 DetHitAccess ()
 
 DetHitAccess (const SiStripRecHit2DCollection *rphiRecHits, const SiStripRecHit2DCollection *stereoRecHits, const SiStripMatchedRecHit2DCollection *matchedRecHits, const SiPixelRecHitCollection *pixelRecHits)
 
std::vector< TrackingRecHit * > getHitVector (const DetId *detid)
 
void setCollections (const SiStripRecHit2DCollection *rphiRecHits, const SiStripRecHit2DCollection *stereoRecHits, const SiStripMatchedRecHit2DCollection *matchedRecHits, const SiPixelRecHitCollection *pixelRecHits)
 
void setMode (accessMode input)
 
void use_rphiRecHits (bool input)
 
void use_stereoRecHits (bool input)
 
 ~DetHitAccess ()
 

Private Attributes

accessMode accessMode_
 
const
SiStripMatchedRecHit2DCollection
matchedHits_
 
const SiPixelRecHitCollectionpixelHits_
 
const SiStripRecHit2DCollectionrphiHits_
 
const SiStripRecHit2DCollectionstereoHits_
 
bool use_rphiRecHits_
 
bool use_stereoRecHits_
 

Detailed Description

Definition at line 22 of file DetHitAccess.h.

Member Enumeration Documentation

Enumerator
standard 
rphi 
rphi_stereo 

Definition at line 26 of file DetHitAccess.h.

Constructor & Destructor Documentation

DetHitAccess::DetHitAccess ( )

Definition at line 15 of file DetHitAccess.cc.

References accessMode_, standard, and use_rphiRecHits_.

15  {
16  // default for access mode
18 
19  use_rphiRecHits_ = true;
20  use_rphiRecHits_ = true;
21 }
bool use_rphiRecHits_
Definition: DetHitAccess.h:52
accessMode accessMode_
Definition: DetHitAccess.h:50
DetHitAccess::~DetHitAccess ( )

Definition at line 23 of file DetHitAccess.cc.

23  {
24 }
DetHitAccess::DetHitAccess ( const SiStripRecHit2DCollection rphiRecHits,
const SiStripRecHit2DCollection stereoRecHits,
const SiStripMatchedRecHit2DCollection matchedRecHits,
const SiPixelRecHitCollection pixelRecHits 
)

Definition at line 26 of file DetHitAccess.cc.

References accessMode_, setCollections(), standard, use_rphiRecHits_, and use_stereoRecHits_.

29  {
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 }
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
bool use_rphiRecHits_
Definition: DetHitAccess.h:52
accessMode accessMode_
Definition: DetHitAccess.h:50

Member Function Documentation

std::vector< TrackingRecHit * > DetHitAccess::getHitVector ( const DetId detid)

Definition at line 55 of file DetHitAccess.cc.

References accessMode_, edmNew::DetSet< T >::begin(), detSetOrEmpty(), edmNew::DetSet< T >::end(), StripSubdetector::glued(), matchedHits_, PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, pixelHits_, rphi, rphi_stereo, rphiHits_, TrackingRecHit::some, stereoHits_, DetId::subdetId(), StripSubdetector::TEC, StripSubdetector::TIB, StripSubdetector::TID, StripSubdetector::TOB, use_rphiRecHits_, and use_stereoRecHits_.

Referenced by RoadSearchSeedFinderAlgorithm::calculateCircleSeedsFromRingsOneInnerOneOuter(), RoadSearchSeedFinderAlgorithm::calculateCircleSeedsFromRingsOneInnerTwoOuter(), RoadSearchSeedFinderAlgorithm::calculateCircleSeedsFromRingsTwoInnerOneOuter(), and RoadSearchCloudMakerAlgorithm::FillRecHitsIntoCloudGeneral().

55  {
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 }
const SiStripRecHit2DCollection * stereoHits_
Definition: DetHitAccess.h:56
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
bool use_stereoRecHits_
Definition: DetHitAccess.h:53
const SiPixelRecHitCollection * pixelHits_
Definition: DetHitAccess.h:58
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
bool use_rphiRecHits_
Definition: DetHitAccess.h:52
accessMode accessMode_
Definition: DetHitAccess.h:50
iterator begin()
Definition: DetSetNew.h:56
void DetHitAccess::setCollections ( const SiStripRecHit2DCollection rphiRecHits,
const SiStripRecHit2DCollection stereoRecHits,
const SiStripMatchedRecHit2DCollection matchedRecHits,
const SiPixelRecHitCollection pixelRecHits 
)

Definition at line 42 of file DetHitAccess.cc.

References matchedHits_, pixelHits_, rphiHits_, and stereoHits_.

Referenced by DetHitAccess(), RoadSearchSeedFinderAlgorithm::run(), and RoadSearchCloudMakerAlgorithm::run().

45  {
46 
47  rphiHits_ = rphiRecHits;
48  stereoHits_ = stereoRecHits;
49  matchedHits_ = matchedRecHits;
50  pixelHits_ = pixelRecHits;
51 
52 }
const SiStripRecHit2DCollection * stereoHits_
Definition: DetHitAccess.h:56
const SiPixelRecHitCollection * pixelHits_
Definition: DetHitAccess.h:58
const SiStripRecHit2DCollection * rphiHits_
Definition: DetHitAccess.h:55
const SiStripMatchedRecHit2DCollection * matchedHits_
Definition: DetHitAccess.h:57
void DetHitAccess::setMode ( accessMode  input)
inline
void DetHitAccess::use_rphiRecHits ( bool  input)
inline
void DetHitAccess::use_stereoRecHits ( bool  input)
inline

Member Data Documentation

accessMode DetHitAccess::accessMode_
private

Definition at line 50 of file DetHitAccess.h.

Referenced by DetHitAccess(), getHitVector(), and setMode().

const SiStripMatchedRecHit2DCollection* DetHitAccess::matchedHits_
private

Definition at line 57 of file DetHitAccess.h.

Referenced by getHitVector(), and setCollections().

const SiPixelRecHitCollection* DetHitAccess::pixelHits_
private

Definition at line 58 of file DetHitAccess.h.

Referenced by getHitVector(), and setCollections().

const SiStripRecHit2DCollection* DetHitAccess::rphiHits_
private

Definition at line 55 of file DetHitAccess.h.

Referenced by getHitVector(), and setCollections().

const SiStripRecHit2DCollection* DetHitAccess::stereoHits_
private

Definition at line 56 of file DetHitAccess.h.

Referenced by getHitVector(), and setCollections().

bool DetHitAccess::use_rphiRecHits_
private

Definition at line 52 of file DetHitAccess.h.

Referenced by DetHitAccess(), getHitVector(), and use_rphiRecHits().

bool DetHitAccess::use_stereoRecHits_
private

Definition at line 53 of file DetHitAccess.h.

Referenced by DetHitAccess(), getHitVector(), and use_stereoRecHits().