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 63 of file SiStripRecHitConverterAlgorithm.h.

Constructor & Destructor Documentation

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

Definition at line 17 of file SiStripRecHitConverterAlgorithm.cc.

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:184

Member Function Documentation

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

Definition at line 292 of file SiStripRecHitConverterAlgorithm.cc.

References j, maskBad128StripBlocks, and quality.

Referenced by run().

293 {
295  short badApvs = quality->getBadApvs(detid);
296  short badFibers = quality->getBadFibers(detid);
297  for (int j = 0; j < 6; j++) {
298  bad128StripBlocks[j] = (badApvs & (1 << j));
299  }
300  for (int j = 0; j < 3; j++) {
301  if (badFibers & (1 << j)) {
302  bad128StripBlocks[2*j+0] = true;
303  bad128StripBlocks[2*j+1] = true;
304  }
305  }
306  }
307 }
int j
Definition: DBlmapReader.cc:9
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, tracker, tracker_cache_id, and useQuality.

Referenced by SiStripRecHitConverter::produce().

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
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 311 of file SiStripRecHitConverterAlgorithm.cc.

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

Referenced by run().

312 {
314  if ( bad128StripBlocks[cluster.firstStrip() >> 7] ) {
315  if ( bad128StripBlocks[(cluster.firstStrip()+cluster.amplitudes().size()) >> 7] ||
316  bad128StripBlocks[static_cast<int32_t>(cluster.barycenter()-0.499999) >> 7] ) {
317  return true;
318  }
319  } else {
320  if ( bad128StripBlocks[(cluster.firstStrip()+cluster.amplitudes().size()) >> 7] &&
321  bad128StripBlocks[static_cast<int32_t>(cluster.barycenter()-0.499999) >> 7] ) {
322  return true;
323  }
324  }
325  }
326  return false;
327 }
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 157 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().

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

References input.

Referenced by 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(), isMasked(), edmNew::makeRefTo(), match(), parameterestimator, Parameters::parameters, edmNew::DetSetVector< T >::FastFiller::push_back(), SiStripRecHitConverterAlgorithm::products::rphi, SiStripRecHitConverterAlgorithm::products::stereo, StripSubdetector::stereo(), tracker, and useModule().

58 {
59 
62  DS = inputhandle->begin(); DS != dse; ++DS ) {
63  edmNew::det_id_type id = (*DS).id();
64  if(!useModule(id)) continue;
65 
66  Collector collector = StripSubdetector(id).stereo()
67  ? Collector(*output.stereo, id)
68  : Collector(*output.rphi, id);
69 
70  bool bad128StripBlocks[6]; fillBad128StripBlocks( id, bad128StripBlocks);
71 
72  GeomDetUnit const & du = *(tracker->idToDetUnit(id));
75  cluster = (*DS).begin(); cluster != cle; ++cluster ) {
76 
77  if(isMasked(*cluster,bad128StripBlocks)) continue;
78 
80  collector.push_back(SiStripRecHit2D( parameters.first, parameters.second, du, edmNew::makeRefTo(inputhandle,cluster) ));
81  }
82 
83  if (collector.empty()) collector.abort();
84  }
85  match(output,trackdirection);
86 }
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 331 of file SiStripRecHitConverterAlgorithm.cc.

References quality, tracker, and useQuality.

Referenced by run().

332 {
333  const StripGeomDetUnit * stripdet=(const StripGeomDetUnit*)tracker->idToDetUnit(id);
334  if(stripdet==0) edm::LogWarning("SiStripRecHitConverter") << "Detid=" << id << " not found";
335  return stripdet!=0 && (!useQuality || quality->IsModuleUsable(id));
336 }
edm::ESHandle< TrackerGeometry > tracker
edm::ESHandle< SiStripQuality > quality

Member Data Documentation

uint32_t SiStripRecHitConverterAlgorithm::cpe_cache_id
private

Definition at line 56 of file SiStripRecHitConverterAlgorithm.h.

Referenced by initialize().

edm::ESInputTag SiStripRecHitConverterAlgorithm::cpeTag
private

Definition at line 57 of file SiStripRecHitConverterAlgorithm.h.

Referenced by initialize().

bool SiStripRecHitConverterAlgorithm::maskBad128StripBlocks
private

Definition at line 55 of file SiStripRecHitConverterAlgorithm.h.

Referenced by fillBad128StripBlocks(), and isMasked().

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

Definition at line 60 of file SiStripRecHitConverterAlgorithm.h.

Referenced by initialize(), and match().

edm::ESInputTag SiStripRecHitConverterAlgorithm::matcherTag
private

Definition at line 57 of file SiStripRecHitConverterAlgorithm.h.

Referenced by initialize().

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

Definition at line 59 of file SiStripRecHitConverterAlgorithm.h.

Referenced by initialize(), and run().

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

Definition at line 61 of file SiStripRecHitConverterAlgorithm.h.

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

uint32_t SiStripRecHitConverterAlgorithm::quality_cache_id
private

Definition at line 56 of file SiStripRecHitConverterAlgorithm.h.

Referenced by initialize().

edm::ESInputTag SiStripRecHitConverterAlgorithm::qualityTag
private

Definition at line 57 of file SiStripRecHitConverterAlgorithm.h.

Referenced by initialize().

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

Definition at line 58 of file SiStripRecHitConverterAlgorithm.h.

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

uint32_t SiStripRecHitConverterAlgorithm::tracker_cache_id
private

Definition at line 56 of file SiStripRecHitConverterAlgorithm.h.

Referenced by initialize().

bool SiStripRecHitConverterAlgorithm::useQuality
private

Definition at line 55 of file SiStripRecHitConverterAlgorithm.h.

Referenced by initialize(), and useModule().