CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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
< SiStripRecHitMatcher
matcher
 
edm::ESInputTag matcherTag
 
edm::ESHandle
< StripClusterParameterEstimator
parameterestimator
 
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 21 of file SiStripRecHitConverterAlgorithm.h.

Member Typedef Documentation

Definition at line 57 of file SiStripRecHitConverterAlgorithm.h.

Constructor & Destructor Documentation

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

Definition at line 20 of file SiStripRecHitConverterAlgorithm.cc.

20  :
21  useQuality(conf.getParameter<bool>("useSiStripQuality")),
22  maskBad128StripBlocks( conf.existsAs<bool>("MaskBadAPVFibers") && conf.getParameter<bool>("MaskBadAPVFibers")),
24  cpe_cache_id(0),
26  cpeTag(conf.getParameter<edm::ESInputTag>("StripCPE")),
27  matcherTag(conf.getParameter<edm::ESInputTag>("Matcher")),
28  qualityTag(conf.getParameter<edm::ESInputTag>("siStripQualityLabel"))
29 {}
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:184

Member Function Documentation

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

Definition at line 308 of file SiStripRecHitConverterAlgorithm.cc.

References j, maskBad128StripBlocks, and quality.

Referenced by run().

309 {
311  short badApvs = quality->getBadApvs(detid);
312  short badFibers = quality->getBadFibers(detid);
313  for (int j = 0; j < 6; j++) {
314  bad128StripBlocks[j] = (badApvs & (1 << j));
315  }
316  for (int j = 0; j < 3; j++) {
317  if (badFibers & (1 << j)) {
318  bad128StripBlocks[2*j+0] = true;
319  bad128StripBlocks[2*j+1] = true;
320  }
321  }
322  }
323 }
int j
Definition: DBlmapReader.cc:9
edm::ESHandle< SiStripQuality > quality
void SiStripRecHitConverterAlgorithm::initialize ( const edm::EventSetup es)

Definition at line 32 of file SiStripRecHitConverterAlgorithm.cc.

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

Referenced by SiStripRecHitConverter::produce().

33 {
34  uint32_t tk_cache_id = es.get<TrackerDigiGeometryRecord>().cacheIdentifier();
35  uint32_t c_cache_id = es.get<TkStripCPERecord>().cacheIdentifier();
36  uint32_t q_cache_id = es.get<SiStripQualityRcd>().cacheIdentifier();
37 
38  if(tk_cache_id != tracker_cache_id) {
40  tracker_cache_id = tk_cache_id;
41  }
42  if(c_cache_id != cpe_cache_id) {
45  cpe_cache_id = c_cache_id;
46  }
47  if( useQuality && q_cache_id!=quality_cache_id) {
49  quality_cache_id = q_cache_id;
50  }
51 }
edm::ESHandle< SiStripRecHitMatcher > matcher
edm::ESHandle< TrackerGeometry > tracker
const T & get() const
Definition: EventSetup.h:55
edm::ESHandle< StripClusterParameterEstimator > parameterestimator
edm::ESHandle< SiStripQuality > quality
bool SiStripRecHitConverterAlgorithm::isMasked ( const SiStripCluster cluster,
bool  bad128StripBlocks[6] 
) const
inlineprivate

Definition at line 327 of file SiStripRecHitConverterAlgorithm.cc.

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

Referenced by run().

328 {
330  if ( bad128StripBlocks[cluster.firstStrip() >> 7] ) {
331  if ( bad128StripBlocks[(cluster.firstStrip()+cluster.amplitudes().size()) >> 7] ||
332  bad128StripBlocks[static_cast<int32_t>(cluster.barycenter()-0.499999) >> 7] ) {
333  return true;
334  }
335  } else {
336  if ( bad128StripBlocks[(cluster.firstStrip()+cluster.amplitudes().size()) >> 7] &&
337  bad128StripBlocks[static_cast<int32_t>(cluster.barycenter()-0.499999) >> 7] ) {
338  return true;
339  }
340  }
341  }
342  return false;
343 }
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 173 of file SiStripRecHitConverterAlgorithm.cc.

References edmNew::DetSet< T >::begin(), edm::OwnVector< T, P >::begin(), edm::OwnVector< T, P >::clear(), filterCSVwithJSON::copy, edmNew::DetSet< T >::detId(), edmNew::DetSet< T >::empty(), edmNew::DetSet< T >::end(), edm::OwnVector< T, P >::end(), SiStripRecHitConverterAlgorithm::products::matched, matcher, StripSubdetector::partnerDetId(), edmNew::DetSetVector< T >::FastFiller::resize(), SiStripRecHitConverterAlgorithm::products::rphi, SiStripRecHitConverterAlgorithm::products::rphiUnmatched, edmNew::DetSet< T >::size(), edm::OwnVector< T, P >::size(), python.multivaluedict::sort(), SiStripRecHitConverterAlgorithm::products::stereo, SiStripRecHitConverterAlgorithm::products::stereoUnmatched, and tracker.

Referenced by run().

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

Definition at line 54 of file SiStripRecHitConverterAlgorithm.cc.

References input.

Referenced by SiStripRecHitConverter::produce().

55 { 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 73 of file SiStripRecHitConverterAlgorithm.cc.

References edmNew::DetSetVector< T >::FastFiller::abort(), edmNew::DetSetVector< T >::FastFiller::empty(), fillBad128StripBlocks(), isMasked(), edmNew::makeRefTo(), match(), parameterestimator, Parameters::parameters, edmNew::DetSetVector< T >::FastFiller::push_back(), SiStripRecHitConverterAlgorithm::products::rphi, SiStripRecHitConverterAlgorithm::products::stereo, StripSubdetector::stereo(), tracker, and useModule().

74 {
75 
78  DS = inputhandle->begin(); DS != dse; ++DS ) {
79  edmNew::det_id_type id = (*DS).id();
80  if(!useModule(id)) continue;
81 
82  Collector collector = StripSubdetector(id).stereo()
83  ? Collector(*output.stereo, id)
84  : Collector(*output.rphi, id);
85 
86  bool bad128StripBlocks[6]; fillBad128StripBlocks( id, bad128StripBlocks);
87 
88  GeomDetUnit const & du = *(tracker->idToDetUnit(id));
91  cluster = (*DS).begin(); cluster != cle; ++cluster ) {
92 
93  if(isMasked(*cluster,bad128StripBlocks)) continue;
94 
96  collector.push_back(SiStripRecHit2D( parameters.first, parameters.second, du, edmNew::makeRefTo(inputhandle,cluster) ));
97  }
98 
99  if (collector.empty()) collector.abort();
100  }
101  match(output,trackdirection);
102 }
edm::Ref< typename HandleT::element_type, typename HandleT::element_type::value_type::value_type > makeRefTo(const HandleT &iHandle, typename HandleT::element_type::value_type::const_iterator itIter)
dictionary parameters
Definition: Parameters.py:2
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
unsigned int det_id_type
Definition: DetSetNew.h:10
edm::ESHandle< TrackerGeometry > tracker
data_type const * const_iterator
Definition: DetSetNew.h:30
void fillBad128StripBlocks(const uint32_t detid, bool bad128StripBlocks[6]) const
void match(products &output, LocalVector trackdirection) const
unsigned int stereo() const
stereo
SiStripRecHit2DCollection::FastFiller Collector
std::pair< LocalPoint, LocalError > LocalValues
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 347 of file SiStripRecHitConverterAlgorithm.cc.

References quality, tracker, and useQuality.

Referenced by run().

348 {
349  const StripGeomDetUnit * stripdet=(const StripGeomDetUnit*)tracker->idToDetUnit(id);
350  if(stripdet==0) edm::LogWarning("SiStripRecHitConverter") << "Detid=" << id << " not found";
351  return stripdet!=0 && (!useQuality || quality->IsModuleUsable(id));
352 }
edm::ESHandle< TrackerGeometry > tracker
edm::ESHandle< SiStripQuality > quality

Member Data Documentation

uint32_t SiStripRecHitConverterAlgorithm::cpe_cache_id
private

Definition at line 50 of file SiStripRecHitConverterAlgorithm.h.

Referenced by initialize().

edm::ESInputTag SiStripRecHitConverterAlgorithm::cpeTag
private

Definition at line 51 of file SiStripRecHitConverterAlgorithm.h.

Referenced by initialize().

bool SiStripRecHitConverterAlgorithm::maskBad128StripBlocks
private

Definition at line 49 of file SiStripRecHitConverterAlgorithm.h.

Referenced by fillBad128StripBlocks(), and isMasked().

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

Definition at line 54 of file SiStripRecHitConverterAlgorithm.h.

Referenced by initialize(), and match().

edm::ESInputTag SiStripRecHitConverterAlgorithm::matcherTag
private

Definition at line 51 of file SiStripRecHitConverterAlgorithm.h.

Referenced by initialize().

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

Definition at line 53 of file SiStripRecHitConverterAlgorithm.h.

Referenced by initialize(), and run().

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

Definition at line 55 of file SiStripRecHitConverterAlgorithm.h.

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

uint32_t SiStripRecHitConverterAlgorithm::quality_cache_id
private

Definition at line 50 of file SiStripRecHitConverterAlgorithm.h.

Referenced by initialize().

edm::ESInputTag SiStripRecHitConverterAlgorithm::qualityTag
private

Definition at line 51 of file SiStripRecHitConverterAlgorithm.h.

Referenced by initialize().

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

Definition at line 52 of file SiStripRecHitConverterAlgorithm.h.

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

uint32_t SiStripRecHitConverterAlgorithm::tracker_cache_id
private

Definition at line 50 of file SiStripRecHitConverterAlgorithm.h.

Referenced by initialize().

bool SiStripRecHitConverterAlgorithm::useQuality
private

Definition at line 49 of file SiStripRecHitConverterAlgorithm.h.

Referenced by initialize(), and useModule().