CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Static 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 &, edm::ConsumesCollector)
 

Static Public Member Functions

static void fillPSetDescription (edm::ParameterSetDescription &desc)
 

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

edm::ESGetToken< StripClusterParameterEstimator, TkStripCPERecordcpeToken
 
bool doMatching
 
bool maskBad128StripBlocks
 
const SiStripRecHitMatchermatcher = nullptr
 
edm::ESGetToken< SiStripRecHitMatcher, TkStripCPERecordmatcherToken
 
const StripClusterParameterEstimatorparameterestimator = nullptr
 
const SiStripQualityquality = nullptr
 
edm::ESGetToken< SiStripQuality, SiStripQualityRcdqualityToken
 
const TrackerGeometrytracker = nullptr
 
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecordtrackerToken
 
bool useQuality
 

Detailed Description

Definition at line 27 of file SiStripRecHitConverterAlgorithm.h.

Member Typedef Documentation

◆ Collector

Definition at line 71 of file SiStripRecHitConverterAlgorithm.h.

Constructor & Destructor Documentation

◆ SiStripRecHitConverterAlgorithm()

SiStripRecHitConverterAlgorithm::SiStripRecHitConverterAlgorithm ( const edm::ParameterSet conf,
edm::ConsumesCollector  iC 
)

Definition at line 18 of file SiStripRecHitConverterAlgorithm.cc.

References doMatching, edm::ConsumesCollector::esConsumes(), edm::ParameterSet::getParameter(), matcherToken, qualityToken, AlCaHarvesting_cff::SiStripQuality, and useQuality.

20  : useQuality(conf.getParameter<bool>("useSiStripQuality")),
21  maskBad128StripBlocks(conf.getParameter<bool>("MaskBadAPVFibers")),
22  doMatching(conf.getParameter<bool>("doMatching")),
25  conf.getParameter<edm::ESInputTag>("StripCPE"))) {
26  if (doMatching) {
28  }
29  if (useQuality) {
30  qualityToken =
31  iC.esConsumes<SiStripQuality, SiStripQualityRcd>(conf.getParameter<edm::ESInputTag>("siStripQualityLabel"));
32  }
33 }
edm::ESGetToken< SiStripRecHitMatcher, TkStripCPERecord > matcherToken
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
edm::ESGetToken< StripClusterParameterEstimator, TkStripCPERecord > cpeToken
edm::ESGetToken< SiStripQuality, SiStripQualityRcd > qualityToken
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > trackerToken

Member Function Documentation

◆ fillBad128StripBlocks()

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

Definition at line 269 of file SiStripRecHitConverterAlgorithm.cc.

References ALCARECOPPSCalTrackBasedSel_cff::detid, SiStripQuality::getBadApvs(), SiStripQuality::getBadFibers(), dqmiolumiharvest::j, maskBad128StripBlocks, and quality.

269  {
270  if (maskBad128StripBlocks) {
271  short badApvs = quality->getBadApvs(detid);
272  short badFibers = quality->getBadFibers(detid);
273  for (int j = 0; j < 6; j++) {
274  bad128StripBlocks[j] = (badApvs & (1 << j));
275  }
276  for (int j = 0; j < 3; j++) {
277  if (badFibers & (1 << j)) {
278  bad128StripBlocks[2 * j + 0] = true;
279  bad128StripBlocks[2 * j + 1] = true;
280  }
281  }
282  }
283 }
short getBadFibers(uint32_t detid) const
short getBadApvs(uint32_t detid) const

◆ fillPSetDescription()

void SiStripRecHitConverterAlgorithm::fillPSetDescription ( edm::ParameterSetDescription desc)
static

Definition at line 35 of file SiStripRecHitConverterAlgorithm.cc.

References submitPVResolutionJobs::desc.

Referenced by SiStripRecHitConverter::fillDescriptions().

35  {
36  desc.add<bool>("useSiStripQuality", false);
37  desc.add<bool>("MaskBadAPVFibers", false);
38  desc.add<bool>("doMatching", true);
39  desc.add<edm::ESInputTag>("StripCPE", edm::ESInputTag("StripCPEfromTrackAngleESProducer", "StripCPEfromTrackAngle"));
40  desc.add<edm::ESInputTag>("Matcher", edm::ESInputTag("SiStripRecHitMatcherESProducer", "StandardMatcher"));
41  desc.add<edm::ESInputTag>("siStripQualityLabel", edm::ESInputTag());
42 }

◆ initialize()

void SiStripRecHitConverterAlgorithm::initialize ( const edm::EventSetup es)

Definition at line 44 of file SiStripRecHitConverterAlgorithm.cc.

References cpeToken, doMatching, edm::EventSetup::getData(), matcher, matcherToken, parameterestimator, quality, qualityToken, tracker, trackerToken, and useQuality.

Referenced by SiStripRecHitConverter::produce().

44  {
47  if (doMatching) {
49  }
50  if (useQuality) {
52  }
53 }
edm::ESGetToken< SiStripRecHitMatcher, TkStripCPERecord > matcherToken
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
edm::ESGetToken< StripClusterParameterEstimator, TkStripCPERecord > cpeToken
const StripClusterParameterEstimator * parameterestimator
edm::ESGetToken< SiStripQuality, SiStripQualityRcd > qualityToken
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > trackerToken

◆ isMasked()

bool SiStripRecHitConverterAlgorithm::isMasked ( const SiStripCluster cluster,
bool  bad128StripBlocks[6] 
) const
inlineprivate

Definition at line 285 of file SiStripRecHitConverterAlgorithm.cc.

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

285  {
286  if (maskBad128StripBlocks) {
287  if (bad128StripBlocks[cluster.firstStrip() >> 7]) {
288  if (bad128StripBlocks[(cluster.firstStrip() + cluster.amplitudes().size()) >> 7] ||
289  bad128StripBlocks[static_cast<int32_t>(cluster.barycenter() - 0.499999) >> 7]) {
290  return true;
291  }
292  } else {
293  if (bad128StripBlocks[(cluster.firstStrip() + cluster.amplitudes().size()) >> 7] &&
294  bad128StripBlocks[static_cast<int32_t>(cluster.barycenter() - 0.499999) >> 7]) {
295  return true;
296  }
297  }
298  }
299  return false;
300 }
uint16_t firstStrip() const
SiStripCluster const & amplitudes() const
auto size() const
float barycenter() const

◆ match()

void SiStripRecHitConverterAlgorithm::match ( products output,
LocalVector  trackdirection 
) const
private

Definition at line 140 of file SiStripRecHitConverterAlgorithm.cc.

References edmNew::DetSet< T >::begin(), filterCSVwithJSON::copy, edmNew::DetSet< T >::detId(), SiStripRecHitMatcher::doubleMatch(), edmNew::DetSet< T >::empty(), edmNew::DetSet< T >::end(), trigObjTnPSource_cfi::filler, TrackerGeometry::idToDet(), ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, SiStripRecHitMatcher::match(), matcher, StripSubdetector::partnerDetId(), edmNew::DetSet< T >::size(), jetUpdater_cfi::sort, and tracker.

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

◆ run() [1/2]

void SiStripRecHitConverterAlgorithm::run ( edm::Handle< edmNew::DetSetVector< SiStripCluster > >  input,
products output 
)

◆ run() [2/2]

void SiStripRecHitConverterAlgorithm::run ( edm::Handle< edmNew::DetSetVector< SiStripCluster > >  input,
products output,
LocalVector  trackdirection 
)

◆ useModule()

bool SiStripRecHitConverterAlgorithm::useModule ( const uint32_t  id) const
inlineprivate

Definition at line 302 of file SiStripRecHitConverterAlgorithm.cc.

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

302  {
303  const StripGeomDetUnit* stripdet = (const StripGeomDetUnit*)tracker->idToDetUnit(id);
304  if (stripdet == nullptr)
305  edm::LogWarning("SiStripRecHitConverter") << "Detid=" << id << " not found";
306  return stripdet != nullptr && (!useQuality || quality->IsModuleUsable(id));
307 }
const TrackerGeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
Log< level::Warning, false > LogWarning
bool IsModuleUsable(uint32_t detid) const

Member Data Documentation

◆ cpeToken

edm::ESGetToken<StripClusterParameterEstimator, TkStripCPERecord> SiStripRecHitConverterAlgorithm::cpeToken
private

Definition at line 63 of file SiStripRecHitConverterAlgorithm.h.

Referenced by initialize().

◆ doMatching

bool SiStripRecHitConverterAlgorithm::doMatching
private

◆ maskBad128StripBlocks

bool SiStripRecHitConverterAlgorithm::maskBad128StripBlocks
private

Definition at line 61 of file SiStripRecHitConverterAlgorithm.h.

Referenced by fillBad128StripBlocks(), and isMasked().

◆ matcher

const SiStripRecHitMatcher* SiStripRecHitConverterAlgorithm::matcher = nullptr
private

Definition at line 68 of file SiStripRecHitConverterAlgorithm.h.

Referenced by initialize(), and match().

◆ matcherToken

edm::ESGetToken<SiStripRecHitMatcher, TkStripCPERecord> SiStripRecHitConverterAlgorithm::matcherToken
private

◆ parameterestimator

const StripClusterParameterEstimator* SiStripRecHitConverterAlgorithm::parameterestimator = nullptr
private

Definition at line 67 of file SiStripRecHitConverterAlgorithm.h.

Referenced by initialize().

◆ quality

const SiStripQuality* SiStripRecHitConverterAlgorithm::quality = nullptr
private

Definition at line 69 of file SiStripRecHitConverterAlgorithm.h.

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

◆ qualityToken

edm::ESGetToken<SiStripQuality, SiStripQualityRcd> SiStripRecHitConverterAlgorithm::qualityToken
private

◆ tracker

const TrackerGeometry* SiStripRecHitConverterAlgorithm::tracker = nullptr
private

Definition at line 66 of file SiStripRecHitConverterAlgorithm.h.

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

◆ trackerToken

edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> SiStripRecHitConverterAlgorithm::trackerToken
private

Definition at line 62 of file SiStripRecHitConverterAlgorithm.h.

Referenced by initialize().

◆ useQuality

bool SiStripRecHitConverterAlgorithm::useQuality
private