CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes
SiStripRecHitConverterAlgorithm Class Reference

#include <SiStripRecHitConverterAlgorithm.h>

Classes

struct  products
 

Public Member Functions

void initialize (const edm::EventSetup &)
 
void run (edm::Handle< edmNew::DetSetVector< SiStripCluster > > input, products &output)
 
void run (edm::Handle< edmNew::DetSetVector< SiStripCluster > > input, products &output, LocalVector trackdirection)
 
 SiStripRecHitConverterAlgorithm (const edm::ParameterSet &)
 

Private Types

typedef SiStripRecHit2DCollection::FastFiller Collector
 

Private Member Functions

void fillBad128StripBlocks (const uint32_t detid, bool bad128StripBlocks[6]) const
 
bool isMasked (const SiStripCluster &cluster, bool bad128StripBlocks[6]) const
 
void match (products &output, LocalVector trackdirection) const
 
bool useModule (const uint32_t id) const
 

Private Attributes

uint32_t cpe_cache_id
 
edm::ESInputTag cpeTag
 
bool maskBad128StripBlocks
 
edm::ESHandle< SiStripRecHitMatchermatcher
 
edm::ESInputTag matcherTag
 
edm::ESHandle< StripClusterParameterEstimatorparameterestimator
 
edm::ESHandle< SiStripQualityquality
 
uint32_t quality_cache_id
 
edm::ESInputTag qualityTag
 
edm::ESHandle< TrackerGeometrytracker
 
uint32_t tracker_cache_id
 
bool useQuality
 

Detailed Description

Definition at line 20 of file SiStripRecHitConverterAlgorithm.h.

Member Typedef Documentation

Definition at line 62 of file SiStripRecHitConverterAlgorithm.h.

Constructor & Destructor Documentation

SiStripRecHitConverterAlgorithm::SiStripRecHitConverterAlgorithm ( const edm::ParameterSet conf)

Definition at line 17 of file SiStripRecHitConverterAlgorithm.cc.

References initialize().

17  :
18  useQuality(conf.getParameter<bool>("useSiStripQuality")),
19  maskBad128StripBlocks( conf.existsAs<bool>("MaskBadAPVFibers") && conf.getParameter<bool>("MaskBadAPVFibers")),
21  cpe_cache_id(0),
23  cpeTag(conf.getParameter<edm::ESInputTag>("StripCPE")),
24  matcherTag(conf.getParameter<edm::ESInputTag>("Matcher")),
25  qualityTag(conf.getParameter<edm::ESInputTag>("siStripQualityLabel"))
26 {}
T getParameter(std::string const &) const
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:186

Member Function Documentation

void SiStripRecHitConverterAlgorithm::fillBad128StripBlocks ( const uint32_t  detid,
bool  bad128StripBlocks[6] 
) const
private

Definition at line 290 of file SiStripRecHitConverterAlgorithm.cc.

References SiStripQuality::getBadApvs(), SiStripQuality::getBadFibers(), isMasked(), maskBad128StripBlocks, and quality.

Referenced by match(), and run().

291 {
293  short badApvs = quality->getBadApvs(detid);
294  short badFibers = quality->getBadFibers(detid);
295  for (int j = 0; j < 6; j++) {
296  bad128StripBlocks[j] = (badApvs & (1 << j));
297  }
298  for (int j = 0; j < 3; j++) {
299  if (badFibers & (1 << j)) {
300  bad128StripBlocks[2*j+0] = true;
301  bad128StripBlocks[2*j+1] = true;
302  }
303  }
304  }
305 }
short getBadFibers(const uint32_t &detid) const
short getBadApvs(const uint32_t &detid) const
edm::ESHandle< SiStripQuality > quality
void SiStripRecHitConverterAlgorithm::initialize ( const edm::EventSetup es)

Definition at line 29 of file SiStripRecHitConverterAlgorithm.cc.

References cpe_cache_id, cpeTag, edm::EventSetup::get(), matcher, matcherTag, parameterestimator, quality, quality_cache_id, qualityTag, run(), tracker, tracker_cache_id, and useQuality.

Referenced by SiStripRecHitConverter::produce(), and SiStripRecHitConverterAlgorithm().

30 {
31  uint32_t tk_cache_id = es.get<TrackerDigiGeometryRecord>().cacheIdentifier();
32  uint32_t c_cache_id = es.get<TkStripCPERecord>().cacheIdentifier();
33  uint32_t q_cache_id = es.get<SiStripQualityRcd>().cacheIdentifier();
34 
35  if(tk_cache_id != tracker_cache_id) {
37  tracker_cache_id = tk_cache_id;
38  }
39  if(c_cache_id != cpe_cache_id) {
42  cpe_cache_id = c_cache_id;
43  }
44  if( useQuality && q_cache_id!=quality_cache_id) {
46  quality_cache_id = q_cache_id;
47  }
48 }
edm::ESHandle< SiStripRecHitMatcher > matcher
edm::ESHandle< TrackerGeometry > tracker
T get() const
Definition: EventSetup.h:63
edm::ESHandle< StripClusterParameterEstimator > parameterestimator
edm::ESHandle< SiStripQuality > quality
bool SiStripRecHitConverterAlgorithm::isMasked ( const SiStripCluster cluster,
bool  bad128StripBlocks[6] 
) const
inlineprivate

Definition at line 309 of file SiStripRecHitConverterAlgorithm.cc.

References SiStripCluster::amplitudes(), SiStripCluster::barycenter(), SiStripCluster::firstStrip(), maskBad128StripBlocks, and useModule().

Referenced by fillBad128StripBlocks(), and run().

310 {
312  if ( bad128StripBlocks[cluster.firstStrip() >> 7] ) {
313  if ( bad128StripBlocks[(cluster.firstStrip()+cluster.amplitudes().size()) >> 7] ||
314  bad128StripBlocks[static_cast<int32_t>(cluster.barycenter()-0.499999) >> 7] ) {
315  return true;
316  }
317  } else {
318  if ( bad128StripBlocks[(cluster.firstStrip()+cluster.amplitudes().size()) >> 7] &&
319  bad128StripBlocks[static_cast<int32_t>(cluster.barycenter()-0.499999) >> 7] ) {
320  return true;
321  }
322  }
323  }
324  return false;
325 }
uint16_t firstStrip() const
float barycenter() const
const std::vector< uint8_t > & amplitudes() const
void SiStripRecHitConverterAlgorithm::match ( products output,
LocalVector  trackdirection 
) const
private

Definition at line 155 of file SiStripRecHitConverterAlgorithm.cc.

References edmNew::DetSet< T >::begin(), edm::OwnVector< T, P >::begin(), edm::OwnVector< T, P >::clear(), popcon2dropbox::copy(), edmNew::DetSet< T >::detId(), SiStripRecHitMatcher::doubleMatch(), edmNew::DetSet< T >::empty(), edmNew::DetSet< T >::end(), edm::OwnVector< T, P >::end(), fillBad128StripBlocks(), objects.autophobj::filler, TrackerGeometry::idToDet(), SiStripRecHitMatcher::match(), SiStripRecHitConverterAlgorithm::products::matched, matcher, StripSubdetector::partnerDetId(), edmNew::DetSetVector< T >::FastFiller::push_back(), SiStripRecHitConverterAlgorithm::products::rphi, SiStripRecHitConverterAlgorithm::products::rphiUnmatched, edmNew::DetSet< T >::size(), edm::OwnVector< T, P >::size(), SiStripRecHitConverterAlgorithm::products::stereo, SiStripRecHitConverterAlgorithm::products::stereoUnmatched, and tracker.

Referenced by run().

156 {
157  int nmatch=0;
158  edm::OwnVector<SiStripMatchedRecHit2D> collectorMatched; // gp/FIXME: avoid this
159 
160  // Remember the ends of the collections, as we will use them a lot
161  SiStripRecHit2DCollection::const_iterator edStereoDet = output.stereo->end();
162  SiStripRecHit2DCollection::const_iterator edRPhiDet = output.rphi->end();
163 
164  // two work vectors for bookeeping clusters used by the stereo part of the matched hits
165  std::vector<SiStripRecHit2D::ClusterRef::key_type> matchedSteroClusters;
166 
167  for (SiStripRecHit2DCollection::const_iterator itRPhiDet = output.rphi->begin(); itRPhiDet != edRPhiDet; ++itRPhiDet) {
168  edmNew::DetSet<SiStripRecHit2D> rphiHits = *itRPhiDet;
169  StripSubdetector specDetId(rphiHits.detId());
170  uint32_t partnerId = specDetId.partnerDetId();
171 
172  // if not part of a glued pair
173  if (partnerId == 0) {
174  // I must copy these as unmatched
175  if (!rphiHits.empty()) {
176  SiStripRecHit2DCollection::FastFiller filler(*output.rphiUnmatched, rphiHits.detId());
177  filler.resize(rphiHits.size());
178  std::copy(rphiHits.begin(), rphiHits.end(), filler.begin());
179  }
180  continue;
181  }
182 
183  SiStripRecHit2DCollection::const_iterator itStereoDet = output.stereo->find(partnerId);
184 
185  // if the partner is not found (which probably can happen if it's empty)
186  if (itStereoDet == edStereoDet) {
187  // I must copy these as unmatched
188  if (!rphiHits.empty()) {
189  SiStripRecHit2DCollection::FastFiller filler(*output.rphiUnmatched, rphiHits.detId());
190  filler.resize(rphiHits.size());
191  std::copy(rphiHits.begin(), rphiHits.end(), filler.begin());
192  }
193  continue;
194  }
195 
196  edmNew::DetSet<SiStripRecHit2D> stereoHits = *itStereoDet;
197 
198 
199  // Get ready for making glued hits
200  const GluedGeomDet* gluedDet = (const GluedGeomDet*)tracker->idToDet(DetId(specDetId.glued()));
202  Collector collector(*output.matched, specDetId.glued());
203 
204  // Prepare also the list for unmatched rphi hits
205  SiStripRecHit2DCollection::FastFiller fillerRphiUnm(*output.rphiUnmatched, rphiHits.detId());
206 
207  // a list of clusters used by the matched part of the stereo hits in this detector
208  matchedSteroClusters.clear(); // at the beginning, empty
209 
210 #ifdef DOUBLE_MATCH
211  CollectorHelper chelper(collector, collectorMatched,
212  fillerRphiUnm,
213  matchedSteroClusters
214  );
215  matcher->doubleMatch(rphiHits.begin(), rphiHits.end(),
216  stereoHits.begin(),stereoHits.end(),gluedDet,trackdirection,chelper);
217  nmatch+=chelper.nmatch;
218 #else
219  // Make simple collection of this (gp:FIXME: why do we need it?)
221  // gp:FIXME: use std::transform
222  stereoSimpleHits.reserve(stereoHits.size());
223  for (edmNew::DetSet<SiStripRecHit2D>::const_iterator it = stereoHits.begin(), ed = stereoHits.end(); it != ed; ++it) {
224  stereoSimpleHits.push_back(&*it);
225  }
226 
227  for (edmNew::DetSet<SiStripRecHit2D>::const_iterator it = rphiHits.begin(), ed = rphiHits.end(); it != ed; ++it) {
228  matcher->match(&(*it),stereoSimpleHits.begin(),stereoSimpleHits.end(),collectorMatched,gluedDet,trackdirection);
229  if (collectorMatched.size()>0){
230  nmatch+=collectorMatched.size();
232  edm = collectorMatched.end();
233  itm != edm;
234  ++itm) {
235  collector.push_back(*itm);
236  // mark the stereo hit cluster as used, so that the hit won't go in the unmatched stereo ones
237  matchedSteroClusters.push_back(itm->stereoClusterRef().key());
238  }
239  collectorMatched.clear();
240  } else {
241  // store a copy of this rphi hit as an unmatched rphi hit
242  fillerRphiUnm.push_back(*it);
243  }
244  }
245 
246 #endif
247 
248 
249  // discard matched hits if the collection is empty
250  if (collector.empty()) collector.abort();
251 
252  // discard unmatched rphi hits if there are none
253  if (fillerRphiUnm.empty()) fillerRphiUnm.abort();
254 
255  // now look for unmatched stereo hits
256  SiStripRecHit2DCollection::FastFiller fillerStereoUnm(*output.stereoUnmatched, stereoHits.detId());
257  std::sort(matchedSteroClusters.begin(), matchedSteroClusters.end());
258  for (edmNew::DetSet<SiStripRecHit2D>::const_iterator it = stereoHits.begin(), ed = stereoHits.end(); it != ed; ++it) {
259  if (!std::binary_search(matchedSteroClusters.begin(), matchedSteroClusters.end(), it->cluster().key())) {
260  fillerStereoUnm.push_back(*it);
261  }
262  }
263  if (fillerStereoUnm.empty()) fillerStereoUnm.abort();
264 
265 
266  }
267 
268  for (SiStripRecHit2DCollection::const_iterator itStereoDet = output.stereo->begin(); itStereoDet != edStereoDet; ++itStereoDet) {
269  edmNew::DetSet<SiStripRecHit2D> stereoHits = *itStereoDet;
270  StripSubdetector specDetId(stereoHits.detId());
271  uint32_t partnerId = specDetId.partnerDetId();
272  if (partnerId == 0) continue;
273  SiStripRecHit2DCollection::const_iterator itRPhiDet = output.rphi->find(partnerId);
274  if (itRPhiDet == edRPhiDet) {
275  if (!stereoHits.empty()) {
276  SiStripRecHit2DCollection::FastFiller filler(*output.stereoUnmatched, stereoHits.detId());
277  filler.resize(stereoHits.size());
278  std::copy(stereoHits.begin(), stereoHits.end(), filler.begin());
279  }
280  }
281  }
282 
283  edm::LogInfo("SiStripRecHitConverter")
284  << "found\n"
285  << nmatch
286  << " matched RecHits\n";
287 }
void push_back(data_type const &d)
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
def copy(args, dbName)
edm::ESHandle< SiStripRecHitMatcher > matcher
edm::ESHandle< TrackerGeometry > tracker
size_type size() const
Definition: OwnVector.h:264
data_type const * const_iterator
Definition: DetSetNew.h:30
unsigned int partnerDetId() const
iterator begin()
Definition: OwnVector.h:244
std::unique_ptr< SiStripMatchedRecHit2D > match(const SiStripRecHit2D *monoRH, const SiStripRecHit2D *stereoRH, const GluedGeomDet *gluedDet, LocalVector trackdirection, bool force) const
bool empty() const
Definition: DetSetNew.h:90
void clear()
Definition: OwnVector.h:445
void doubleMatch(MonoIterator monoRHiter, MonoIterator monoRHend, StereoIterator seconditer, StereoIterator seconditerend, const GluedGeomDet *gluedDet, LocalVector trdir, CollectorHelper &collectorHelper) const
Definition: DetId.h:18
iterator end()
Definition: OwnVector.h:249
std::vector< const SiStripRecHit2D * > SimpleHitCollection
SiStripRecHit2DCollection::FastFiller Collector
id_type detId() const
Definition: DetSetNew.h:84
HLT enums.
iterator end()
Definition: DetSetNew.h:70
const TrackerGeomDet * idToDet(DetId) const override
size_type size() const
Definition: DetSetNew.h:87
iterator begin()
Definition: DetSetNew.h:67
void SiStripRecHitConverterAlgorithm::run ( edm::Handle< edmNew::DetSetVector< SiStripCluster > >  input,
products output 
)

Definition at line 51 of file SiStripRecHitConverterAlgorithm.cc.

References input.

Referenced by initialize(), and SiStripRecHitConverter::produce().

52 { run(input, output, LocalVector(0.,0.,0.)); }
Local3DVector LocalVector
Definition: LocalVector.h:12
void run(edm::Handle< edmNew::DetSetVector< SiStripCluster > > input, products &output)
void SiStripRecHitConverterAlgorithm::run ( edm::Handle< edmNew::DetSetVector< SiStripCluster > >  input,
products output,
LocalVector  trackdirection 
)

Definition at line 57 of file SiStripRecHitConverterAlgorithm.cc.

References edmNew::DetSetVector< T >::FastFiller::abort(), edmNew::DetSetVector< T >::FastFiller::empty(), fillBad128StripBlocks(), h, TrackerGeometry::idToDetUnit(), isMasked(), StripClusterParameterEstimator::localParameters(), match(), parameterestimator, edmNew::DetSetVector< T >::FastFiller::push_back(), SiStripRecHitConverterAlgorithm::products::rphi, edmNew::DetSetVector< T >::FastFiller::size(), SiStripRecHitConverterAlgorithm::products::stereo, StripSubdetector::stereo(), tracker, and useModule().

58 {
59 
60  for (auto const & DS : *inputhandle) {
61  auto id = DS.id();
62  if(!useModule(id)) continue;
63 
64  Collector collector = StripSubdetector(id).stereo()
65  ? Collector(*output.stereo, id)
66  : Collector(*output.rphi, id);
67 
68  bool bad128StripBlocks[6]; fillBad128StripBlocks( id, bad128StripBlocks);
69 
70  GeomDetUnit const & du = *(tracker->idToDetUnit(id));
71  for(auto const & cluster : DS) {
72 
73  if(isMasked(cluster,bad128StripBlocks)) continue;
74 
76  collector.push_back(SiStripRecHit2D( parameters.first, parameters.second, du,
77  DS.makeRefTo(inputhandle, &cluster)
78  ));
79  }
80 
81  if (collector.empty()) collector.abort();
82  }
83  match(output,trackdirection);
84 }
edm::ESHandle< TrackerGeometry > tracker
virtual void localParameters(AClusters const &clusters, ALocalValues &retValues, const GeomDetUnit &gd, const LocalTrajectoryParameters &ltp) const
std::pair< LocalPoint, LocalError > LocalValues
void fillBad128StripBlocks(const uint32_t detid, bool bad128StripBlocks[6]) const
const TrackerGeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
void match(products &output, LocalVector trackdirection) const
unsigned int stereo() const
stereo
SiStripRecHit2DCollection::FastFiller Collector
edm::ESHandle< StripClusterParameterEstimator > parameterestimator
bool isMasked(const SiStripCluster &cluster, bool bad128StripBlocks[6]) const
bool SiStripRecHitConverterAlgorithm::useModule ( const uint32_t  id) const
inlineprivate

Definition at line 329 of file SiStripRecHitConverterAlgorithm.cc.

References TrackerGeometry::idToDetUnit(), SiStripQuality::IsModuleUsable(), quality, tracker, and useQuality.

Referenced by isMasked(), and run().

330 {
331  const StripGeomDetUnit * stripdet=(const StripGeomDetUnit*)tracker->idToDetUnit(id);
332  if(stripdet==nullptr) edm::LogWarning("SiStripRecHitConverter") << "Detid=" << id << " not found";
333  return stripdet!=nullptr && (!useQuality || quality->IsModuleUsable(id));
334 }
edm::ESHandle< TrackerGeometry > tracker
const TrackerGeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
bool IsModuleUsable(const uint32_t &detid) const
edm::ESHandle< SiStripQuality > quality

Member Data Documentation

uint32_t SiStripRecHitConverterAlgorithm::cpe_cache_id
private

Definition at line 55 of file SiStripRecHitConverterAlgorithm.h.

Referenced by initialize().

edm::ESInputTag SiStripRecHitConverterAlgorithm::cpeTag
private

Definition at line 56 of file SiStripRecHitConverterAlgorithm.h.

Referenced by initialize().

bool SiStripRecHitConverterAlgorithm::maskBad128StripBlocks
private

Definition at line 54 of file SiStripRecHitConverterAlgorithm.h.

Referenced by fillBad128StripBlocks(), and isMasked().

edm::ESHandle<SiStripRecHitMatcher> SiStripRecHitConverterAlgorithm::matcher
private

Definition at line 59 of file SiStripRecHitConverterAlgorithm.h.

Referenced by initialize(), and match().

edm::ESInputTag SiStripRecHitConverterAlgorithm::matcherTag
private

Definition at line 56 of file SiStripRecHitConverterAlgorithm.h.

Referenced by initialize().

edm::ESHandle<StripClusterParameterEstimator> SiStripRecHitConverterAlgorithm::parameterestimator
private

Definition at line 58 of file SiStripRecHitConverterAlgorithm.h.

Referenced by initialize(), and run().

edm::ESHandle<SiStripQuality> SiStripRecHitConverterAlgorithm::quality
private

Definition at line 60 of file SiStripRecHitConverterAlgorithm.h.

Referenced by fillBad128StripBlocks(), initialize(), and useModule().

uint32_t SiStripRecHitConverterAlgorithm::quality_cache_id
private

Definition at line 55 of file SiStripRecHitConverterAlgorithm.h.

Referenced by initialize().

edm::ESInputTag SiStripRecHitConverterAlgorithm::qualityTag
private

Definition at line 56 of file SiStripRecHitConverterAlgorithm.h.

Referenced by initialize().

edm::ESHandle<TrackerGeometry> SiStripRecHitConverterAlgorithm::tracker
private

Definition at line 57 of file SiStripRecHitConverterAlgorithm.h.

Referenced by initialize(), match(), run(), and useModule().

uint32_t SiStripRecHitConverterAlgorithm::tracker_cache_id
private

Definition at line 55 of file SiStripRecHitConverterAlgorithm.h.

Referenced by initialize().

bool SiStripRecHitConverterAlgorithm::useQuality
private

Definition at line 54 of file SiStripRecHitConverterAlgorithm.h.

Referenced by initialize(), and useModule().