CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes
HITrackClusterRemover Class Reference
Inheritance diagram for HITrackClusterRemover:
edm::stream::EDProducer<>

Classes

struct  ParamBlock
 

Public Member Functions

 HITrackClusterRemover (const edm::ParameterSet &iConfig)
 
void produce (edm::Event &iEvent, const edm::EventSetup &iSetup) override
 
 ~HITrackClusterRemover () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

Private Types

typedef edm::ContainerMask< edmNew::DetSetVector< SiPixelCluster > > PixelMaskContainer
 
typedef edm::ContainerMask< edmNew::DetSetVector< SiStripCluster > > StripMaskContainer
 

Private Member Functions

template<typename T >
std::unique_ptr< edmNew::DetSetVector< T > > cleanup (const edmNew::DetSetVector< T > &oldClusters, const std::vector< uint8_t > &isGood, reco::ClusterRemovalInfo::Indices &refs, const reco::ClusterRemovalInfo::Indices *oldRefs)
 
void mergeOld (reco::ClusterRemovalInfo::Indices &refs, const reco::ClusterRemovalInfo::Indices &oldRefs)
 
void process (const TrackingRecHit *hit, unsigned char chi2, const TrackerGeometry *tg)
 
void process (const OmniClusterRef &cluRef, SiStripDetId &detid, bool fromTrack)
 
void readPSet (const edm::ParameterSet &iConfig, const std::string &name, int id1=-1, int id2=-1, int id3=-1, int id4=-1, int id5=-1, int id6=-1)
 
float sensorThickness (const SiStripDetId &detid) const
 

Private Attributes

bool clusterWasteSolution_
 
std::vector< bool > collectedPixels_
 
std::vector< bool > collectedStrips_
 
bool doPixel_
 
bool doPixelChargeCheck_
 
bool doStrip_
 
bool doStripChargeCheck_
 
bool doTracks_
 
bool filterTracks_
 
bool mergeOld_
 
int minNumberOfLayersWithMeasBeforeFiltering_
 
edm::EDGetTokenT< PixelMaskContaineroldPxlMaskToken_
 
edm::EDGetTokenT< reco::ClusterRemovalInfooldRemovalInfo_
 
edm::EDGetTokenT< StripMaskContaineroldStrMaskToken_
 
std::vector< edm::EDGetTokenT< edm::ValueMap< int > > > overrideTrkQuals_
 
ParamBlock pblocks_ [NumberOfParamBlocks]
 
edm::EDGetTokenT< edmNew::DetSetVector< SiPixelCluster > > pixelClusters_
 
std::string pixelRecHits_
 
std::vector< uint8_t > pixels
 
edm::ProductID pixelSourceProdID
 
edm::EDGetTokenT< SiStripRecHit2DCollectionrphiRecHitToken_
 
edm::EDGetTokenT< SiStripRecHit2DCollectionstereoRecHitToken_
 
edm::EDGetTokenT< edmNew::DetSetVector< SiStripCluster > > stripClusters_
 
std::string stripRecHits_
 
std::vector< uint8_t > strips
 
edm::ProductID stripSourceProdID
 
reco::TrackBase::TrackQuality trackQuality_
 
edm::EDGetTokenT< reco::TrackCollectiontracks_
 

Static Private Attributes

static const unsigned int NumberOfParamBlocks = 6
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

Definition at line 42 of file HITrackClusterRemover.cc.

Member Typedef Documentation

Definition at line 71 of file HITrackClusterRemover.cc.

Definition at line 72 of file HITrackClusterRemover.cc.

Constructor & Destructor Documentation

HITrackClusterRemover::HITrackClusterRemover ( const edm::ParameterSet iConfig)

Definition at line 145 of file HITrackClusterRemover.cc.

References clusterWasteSolution_, doPixel_, doPixelChargeCheck_, doStrip_, doStripChargeCheck_, doTracks_, Exception, edm::ParameterSet::exists(), edm::ParameterSet::existsAs(), ntuplemaker::fill, filterTracks_, edm::ParameterSet::getParameter(), mps_fire::i, HLT_2018_cff::InputTag, label, mergeOld_, minNumberOfLayersWithMeasBeforeFiltering_, NumberOfParamBlocks, oldPxlMaskToken_, oldRemovalInfo_, oldStrMaskToken_, overrideTrkQuals_, pblocks_, pixelClusters_, reco::TrackBase::qualityByName(), readPSet(), rphiRecHitToken_, stereoRecHitToken_, AlCaHLTBitMon_QueryRunRegistry::string, stripClusters_, stripRecHits_, trackQuality_, tracks_, and reco::TrackBase::undefQuality.

146  : doTracks_(iConfig.exists("trajectories")),
147  doStrip_(iConfig.existsAs<bool>("doStrip") ? iConfig.getParameter<bool>("doStrip") : true),
148  doPixel_(iConfig.existsAs<bool>("doPixel") ? iConfig.getParameter<bool>("doPixel") : true),
149  mergeOld_(iConfig.exists("oldClusterRemovalInfo")),
150  clusterWasteSolution_(true),
152  iConfig.existsAs<bool>("doStripChargeCheck") ? iConfig.getParameter<bool>("doStripChargeCheck") : false),
154  iConfig.existsAs<bool>("doPixelChargeCheck") ? iConfig.getParameter<bool>("doPixelChargeCheck") : false),
155  stripRecHits_(doStripChargeCheck_ ? iConfig.getParameter<std::string>("stripRecHits")
156  : std::string("siStripMatchedRecHits")),
157  pixelRecHits_(doPixelChargeCheck_ ? iConfig.getParameter<std::string>("pixelRecHits")
158  : std::string("siPixelRecHits")) {
159  mergeOld_ = mergeOld_ && !iConfig.getParameter<InputTag>("oldClusterRemovalInfo").label().empty();
160  if (iConfig.exists("overrideTrkQuals"))
161  overrideTrkQuals_.push_back(consumes<edm::ValueMap<int> >(iConfig.getParameter<InputTag>("overrideTrkQuals")));
162  if (iConfig.exists("clusterLessSolution"))
163  clusterWasteSolution_ = !iConfig.getParameter<bool>("clusterLessSolution");
165  throw cms::Exception("Configuration Error")
166  << "HITrackClusterRemover: Charge check asked without cluster collection ";
168  throw cms::Exception("Configuration Error")
169  << "HITrackClusterRemover: Pixel cluster charge check not yet implemented";
170 
172  produces<edmNew::DetSetVector<SiPixelCluster> >();
174  produces<edmNew::DetSetVector<SiStripCluster> >();
176  produces<ClusterRemovalInfo>();
177 
178  assert(!clusterWasteSolution_);
179 
180  fill(pblocks_, pblocks_ + NumberOfParamBlocks, ParamBlock());
181  readPSet(iConfig, "Common", -1);
182  if (doPixel_) {
183  readPSet(iConfig, "Pixel", 0, 1);
184  readPSet(iConfig, "PXB", 0);
185  readPSet(iConfig, "PXE", 1);
186  }
187  if (doStrip_) {
188  readPSet(iConfig, "Strip", 2, 3, 4, 5);
189  readPSet(iConfig, "StripInner", 2, 3);
190  readPSet(iConfig, "StripOuter", 4, 5);
191  readPSet(iConfig, "TIB", 2);
192  readPSet(iConfig, "TID", 3);
193  readPSet(iConfig, "TOB", 4);
194  readPSet(iConfig, "TEC", 5);
195  }
196 
197  bool usingCharge = false;
198  for (size_t i = 0; i < NumberOfParamBlocks; ++i) {
199  if (!pblocks_[i].isSet_)
200  throw cms::Exception("Configuration Error")
201  << "HITrackClusterRemover: Missing configuration for detector with subDetID = " << (i + 1);
202  if (pblocks_[i].usesCharge_ && !usingCharge) {
203  throw cms::Exception("Configuration Error") << "HITrackClusterRemover: Configuration for subDetID = " << (i + 1)
204  << " uses cluster charge, which is not enabled.";
205  }
206  }
207 
208  if (!clusterWasteSolution_) {
209  produces<edm::ContainerMask<edmNew::DetSetVector<SiPixelCluster> > >();
210  produces<edm::ContainerMask<edmNew::DetSetVector<SiStripCluster> > >();
211  }
213  filterTracks_ = false;
214  if (iConfig.exists("TrackQuality")) {
215  filterTracks_ = true;
216  trackQuality_ = reco::TrackBase::qualityByName(iConfig.getParameter<std::string>("TrackQuality"));
218  iConfig.existsAs<int>("minNumberOfLayersWithMeasBeforeFiltering")
219  ? iConfig.getParameter<int>("minNumberOfLayersWithMeasBeforeFiltering")
220  : 0;
221  }
222 
223  if (doTracks_)
224  tracks_ = consumes<reco::TrackCollection>(iConfig.getParameter<InputTag>("trajectories"));
225  if (doPixel_)
226  pixelClusters_ = consumes<edmNew::DetSetVector<SiPixelCluster> >(iConfig.getParameter<InputTag>("pixelClusters"));
227  if (doStrip_)
228  stripClusters_ = consumes<edmNew::DetSetVector<SiStripCluster> >(iConfig.getParameter<InputTag>("stripClusters"));
229  if (mergeOld_) {
230  oldRemovalInfo_ = consumes<ClusterRemovalInfo>(iConfig.getParameter<InputTag>("oldClusterRemovalInfo"));
231  oldPxlMaskToken_ = consumes<PixelMaskContainer>(iConfig.getParameter<InputTag>("oldClusterRemovalInfo"));
232  oldStrMaskToken_ = consumes<StripMaskContainer>(iConfig.getParameter<InputTag>("oldClusterRemovalInfo"));
233  }
234 
235  if (doStripChargeCheck_) {
236  rphiRecHitToken_ = consumes<SiStripRecHit2DCollection>(InputTag(stripRecHits_, "rphiRecHit"));
237  stereoRecHitToken_ = consumes<SiStripRecHit2DCollection>(InputTag(stripRecHits_, "stereoRecHit"));
238  }
239  // if(doPixelChargeCheck_) pixelRecHitsToken_ = consumes<SiPixelRecHitCollection>(InputTag(pixelRecHits_));
240 }
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:160
std::vector< edm::EDGetTokenT< edm::ValueMap< int > > > overrideTrkQuals_
bool exists(std::string const &parameterName) const
checks if a parameter exists
static const unsigned int NumberOfParamBlocks
edm::EDGetTokenT< reco::ClusterRemovalInfo > oldRemovalInfo_
char const * label
edm::EDGetTokenT< StripMaskContainer > oldStrMaskToken_
edm::EDGetTokenT< reco::TrackCollection > tracks_
reco::TrackBase::TrackQuality trackQuality_
ParamBlock pblocks_[NumberOfParamBlocks]
void readPSet(const edm::ParameterSet &iConfig, const std::string &name, int id1=-1, int id2=-1, int id3=-1, int id4=-1, int id5=-1, int id6=-1)
edm::EDGetTokenT< PixelMaskContainer > oldPxlMaskToken_
static TrackQuality qualityByName(const std::string &name)
Definition: TrackBase.cc:126
edm::EDGetTokenT< edmNew::DetSetVector< SiStripCluster > > stripClusters_
edm::EDGetTokenT< SiStripRecHit2DCollection > stereoRecHitToken_
edm::EDGetTokenT< SiStripRecHit2DCollection > rphiRecHitToken_
edm::EDGetTokenT< edmNew::DetSetVector< SiPixelCluster > > pixelClusters_
HITrackClusterRemover::~HITrackClusterRemover ( )
override

Definition at line 242 of file HITrackClusterRemover.cc.

242 {}

Member Function Documentation

template<typename T >
std::unique_ptr< edmNew::DetSetVector< T > > HITrackClusterRemover::cleanup ( const edmNew::DetSetVector< T > &  oldClusters,
const std::vector< uint8_t > &  isGood,
reco::ClusterRemovalInfo::Indices refs,
const reco::ClusterRemovalInfo::Indices oldRefs 
)
private

Definition at line 251 of file HITrackClusterRemover.cc.

References edmNew::DetSetVector< T >::begin(), edmNew::DetSetVector< T >::data(), edmNew::DetSetVector< T >::dataSize(), edmNew::DetSetVector< T >::end(), mergeOld(), convertSQLitetoXML_cfg::output, and edmNew::DetSetVector< T >::size().

Referenced by produce().

255  {
256  typedef typename edmNew::DetSetVector<T> DSV;
257  typedef typename edmNew::DetSetVector<T>::FastFiller DSF;
258  typedef typename edmNew::DetSet<T> DS;
259  auto output = std::make_unique<DSV>();
260  output->reserve(oldClusters.size(), oldClusters.dataSize());
261 
262  unsigned int countOld = 0;
263  unsigned int countNew = 0;
264 
265  // cluster removal loop
266  const T *firstOffset = &oldClusters.data().front();
267  for (typename DSV::const_iterator itdet = oldClusters.begin(), enddet = oldClusters.end(); itdet != enddet; ++itdet) {
268  DS oldDS = *itdet;
269 
270  if (oldDS.empty())
271  continue; // skip empty detsets
272 
273  uint32_t id = oldDS.detId();
274  DSF outds(*output, id);
275 
276  for (typename DS::const_iterator it = oldDS.begin(), ed = oldDS.end(); it != ed; ++it) {
277  uint32_t index = ((&*it) - firstOffset);
278  countOld++;
279  if (isGood[index]) {
280  outds.push_back(*it);
281  countNew++;
282  refs.push_back(index);
283  //std::cout << "HITrackClusterRemover::cleanup " << typeid(T).name() << " reference " << index << " to " << (refs.size() - 1) << std::endl;
284  }
285  }
286  if (outds.empty())
287  outds.abort(); // not write in an empty DSV
288  }
289 
290  if (oldRefs != nullptr)
291  mergeOld(refs, *oldRefs);
292  return output;
293 }
const_iterator end(bool update=false) const
size_type dataSize() const
data_type const * data(size_t cell) const
void mergeOld(reco::ClusterRemovalInfo::Indices &refs, const reco::ClusterRemovalInfo::Indices &oldRefs)
size_type size() const
long double T
const_iterator begin(bool update=false) const
void HITrackClusterRemover::mergeOld ( reco::ClusterRemovalInfo::Indices refs,
const reco::ClusterRemovalInfo::Indices oldRefs 
)
private

Definition at line 244 of file HITrackClusterRemover.cc.

References mps_fire::i, and dqmiodumpmetadata::n.

Referenced by cleanup().

244  {
245  for (size_t i = 0, n = refs.size(); i < n; ++i) {
246  refs[i] = oldRefs[refs[i]];
247  }
248 }
void HITrackClusterRemover::process ( const TrackingRecHit hit,
unsigned char  chi2,
const TrackerGeometry tg 
)
inlineprivate

Definition at line 340 of file HITrackClusterRemover.cc.

References SiPixelRecHit::cluster(), clusterWasteSolution_, collectedPixels_, doPixel_, doStrip_, Exception, TrackingRecHit::geographicalId(), TrackerGeometry::geomDetSubDetector(), edm::Ref< C, T, F >::id(), GeomDetEnumerators::isTrackerPixel(), edm::Ref< C, T, F >::key(), HITrackClusterRemover::ParamBlock::maxSize_, SiStripMatchedRecHit2D::monoClusterRef(), NumberOfParamBlocks, TrackerSingleRecHit::omniClusterRef(), ProjectedSiStripRecHit2D::originalHit(), pblocks_, pixels, pixelSourceProdID, DetId::rawId(), SiStripMatchedRecHit2D::stereoClusterRef(), DetId::subdetId(), and Traj2TrackHits::toChi2x5().

Referenced by produce(), and sensorThickness().

340  {
341  SiStripDetId detid = hit->geographicalId();
342  uint32_t subdet = detid.subdetId();
343 
344  assert((subdet > 0) && (subdet <= NumberOfParamBlocks));
345 
346  // chi2 cut
347  if (chi2 > Traj2TrackHits::toChi2x5(pblocks_[subdet - 1].maxChi2_))
348  return;
349 
351  if (!doPixel_)
352  return;
353  // this is a pixel, and i *know* it is
354  const SiPixelRecHit *pixelHit = static_cast<const SiPixelRecHit *>(hit);
355 
356  SiPixelRecHit::ClusterRef cluster = pixelHit->cluster();
357 
358  if (cluster.id() != pixelSourceProdID)
359  throw cms::Exception("Inconsistent Data")
360  << "HITrackClusterRemover: pixel cluster ref from Product ID = " << cluster.id()
361  << " does not match with source cluster collection (ID = " << pixelSourceProdID << ")\n.";
362 
363  assert(cluster.id() == pixelSourceProdID);
364  //DBG// cout << "HIT NEW PIXEL DETID = " << detid.rawId() << ", Cluster [ " << cluster.key().first << " / " << cluster.key().second << " ] " << endl;
365 
366  // if requested, cut on cluster size
367  if (pblocks_[subdet - 1].usesSize_ && (cluster->pixels().size() > pblocks_[subdet - 1].maxSize_))
368  return;
369 
370  // mark as used
371  pixels[cluster.key()] = false;
372 
373  //if(!clusterWasteSolution_) collectedPixel[detid.rawId()].insert(cluster);
374  assert(collectedPixels_.size() > cluster.key());
375  //assert(detid.rawId() == cluster->geographicalId()); //This condition fails
377  collectedPixels_[cluster.key()] = true;
378 
379  } else { // aka Strip
380  if (!doStrip_)
381  return;
382  const type_info &hitType = typeid(*hit);
383  if (hitType == typeid(SiStripRecHit2D)) {
384  const SiStripRecHit2D *stripHit = static_cast<const SiStripRecHit2D *>(hit);
385  //DBG// cout << "Plain RecHit 2D: " << endl;
386  process(stripHit->omniClusterRef(), detid, true);
387  } else if (hitType == typeid(SiStripRecHit1D)) {
388  const SiStripRecHit1D *hit1D = static_cast<const SiStripRecHit1D *>(hit);
389  process(hit1D->omniClusterRef(), detid, true);
390  } else if (hitType == typeid(SiStripMatchedRecHit2D)) {
391  const SiStripMatchedRecHit2D *matchHit = static_cast<const SiStripMatchedRecHit2D *>(hit);
392  //DBG// cout << "Matched RecHit 2D: " << endl;
393  process(matchHit->monoClusterRef(), detid, true);
394  process(matchHit->stereoClusterRef(), detid, true);
395  } else if (hitType == typeid(ProjectedSiStripRecHit2D)) {
396  const ProjectedSiStripRecHit2D *projHit = static_cast<const ProjectedSiStripRecHit2D *>(hit);
397  //DBG// cout << "Projected RecHit 2D: " << endl;
398  process(projHit->originalHit().omniClusterRef(), detid, true);
399  } else
400  throw cms::Exception("NOT IMPLEMENTED")
401  << "Don't know how to handle " << hitType.name() << " on detid " << detid.rawId() << "\n";
402  }
403 }
const GeomDetEnumerators::SubDetector geomDetSubDetector(int subdet) const
void process(const TrackingRecHit *hit, unsigned char chi2, const TrackerGeometry *tg)
static unsigned char toChi2x5(float chi2)
OmniClusterRef const & stereoClusterRef() const
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
static const unsigned int NumberOfParamBlocks
key_type key() const
Accessor for product key.
Definition: Ref.h:250
ProductID id() const
Accessor for product ID.
Definition: Ref.h:244
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
OmniClusterRef const & monoClusterRef() const
ParamBlock pblocks_[NumberOfParamBlocks]
SiStripRecHit2D originalHit() const
Detector identifier class for the strip tracker.
Definition: SiStripDetId.h:18
OmniClusterRef const & omniClusterRef() const
ClusterRef cluster() const
Definition: SiPixelRecHit.h:47
std::vector< uint8_t > pixels
DetId geographicalId() const
std::vector< bool > collectedPixels_
bool isTrackerPixel(GeomDetEnumerators::SubDetector m)
Our base class.
Definition: SiPixelRecHit.h:23
void HITrackClusterRemover::process ( const OmniClusterRef cluRef,
SiStripDetId detid,
bool  fromTrack 
)
inlineprivate
void HITrackClusterRemover::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
override

Definition at line 415 of file HITrackClusterRemover.cc.

References cleanup(), clusterWasteSolution_, collectedPixels_, collectedStrips_, edm::ContainerMask< T >::copyMaskTo(), KineDebug3::count(), DEFINE_FWK_MODULE, doPixel_, doStrip_, doStripChargeCheck_, doTracks_, Exception, ntuplemaker::fill, filterTracks_, edm::EventSetup::get(), edm::Event::getByToken(), h, hcalSimParameters_cfi::hb, edm::ProductID::id(), edm::HandleBase::id(), SummaryClient_cfi::labels, LogDebug, mergeOld_, minNumberOfLayersWithMeasBeforeFiltering_, eostools::move(), oldPxlMaskToken_, oldRemovalInfo_, oldStrMaskToken_, overrideTrkQuals_, LumiMonitor_cff::pixelClusters, pixelClusters_, pixels, pixelSourceProdID, process(), edm::ESHandle< T >::product(), edm::ProductLabels::productInstance, edm::Event::put(), rpcPointValidation_cfi::recHit, LaserSeedGenerator_cfi::rphiRecHits, rphiRecHitToken_, edm::ContainerMask< T >::size(), LaserSeedGenerator_cfi::stereoRecHits, stereoRecHitToken_, HLT_2018_cff::stripClusters, stripClusters_, strips, stripSourceProdID, HLT_2018_cff::track, trackQuality_, PDWG_EXOHSCP_cff::tracks, and tracks_.

415  {
416  ProductID pixelOldProdID, stripOldProdID;
417 
419  iSetup.get<TrackerDigiGeometryRecord>().get(tgh);
420 
422  if (doPixel_) {
423  iEvent.getByToken(pixelClusters_, pixelClusters);
424  pixelSourceProdID = pixelClusters.id();
425  }
426  //DBG// std::cout << "HITrackClusterRemover: Read pixel " << pixelClusters_.encode() << " = ID " << pixelSourceProdID << std::endl;
427 
429  if (doStrip_) {
430  iEvent.getByToken(stripClusters_, stripClusters);
431  stripSourceProdID = stripClusters.id();
432  }
433  //DBG// std::cout << "HITrackClusterRemover: Read strip " << stripClusters_.encode() << " = ID " << stripSourceProdID << std::endl;
434 
435  std::unique_ptr<ClusterRemovalInfo> cri;
436  if (clusterWasteSolution_) {
437  if (doStrip_ && doPixel_)
438  cri = std::make_unique<ClusterRemovalInfo>(pixelClusters, stripClusters);
439  else if (doStrip_)
440  cri = std::make_unique<ClusterRemovalInfo>(stripClusters);
441  else if (doPixel_)
442  cri = std::make_unique<ClusterRemovalInfo>(pixelClusters);
443  }
444 
445  Handle<ClusterRemovalInfo> oldRemovalInfo;
447  iEvent.getByToken(oldRemovalInfo_, oldRemovalInfo);
448  // Check ProductIDs
449  if ((oldRemovalInfo->stripNewRefProd().id() == stripClusters.id()) &&
450  (oldRemovalInfo->pixelNewRefProd().id() == pixelClusters.id())) {
451  cri->getOldClustersFrom(*oldRemovalInfo);
452 
453  pixelOldProdID = oldRemovalInfo->pixelRefProd().id();
454  stripOldProdID = oldRemovalInfo->stripRefProd().id();
455 
456  } else {
458  labelsForToken(oldRemovalInfo_, labels);
459  throw cms::Exception("Inconsistent Data")
460  << "HITrackClusterRemover: "
461  << "Input collection product IDs are [pixel: " << pixelClusters.id() << ", strip: " << stripClusters.id()
462  << "] \n"
463  << "\t but the *old* ClusterRemovalInfo " << labels.productInstance << " refers as 'new product ids' to "
464  << "[pixel: " << oldRemovalInfo->pixelNewRefProd().id()
465  << ", strip: " << oldRemovalInfo->stripNewRefProd().id() << "]\n"
466  << "NOTA BENE: when running HITrackClusterRemover with an old ClusterRemovalInfo the hits in the trajectory "
467  "MUST be already re-keyed.\n";
468  }
469  } else { // then Old == Source
470  pixelOldProdID = pixelSourceProdID;
471  stripOldProdID = stripSourceProdID;
472  }
473 
474  if (doStrip_) {
475  strips.resize(stripClusters->dataSize());
476  fill(strips.begin(), strips.end(), true);
477  }
478  if (doPixel_) {
479  pixels.resize(pixelClusters->dataSize());
480  fill(pixels.begin(), pixels.end(), true);
481  }
482  if (mergeOld_) {
485  iEvent.getByToken(oldPxlMaskToken_, oldPxlMask);
486  iEvent.getByToken(oldStrMaskToken_, oldStrMask);
487  LogDebug("HITrackClusterRemover") << "to merge in, " << oldStrMask->size() << " strp and " << oldPxlMask->size()
488  << " pxl";
489  oldStrMask->copyMaskTo(collectedStrips_);
490  oldPxlMask->copyMaskTo(collectedPixels_);
491  assert(stripClusters->dataSize() >= collectedStrips_.size());
492  collectedStrips_.resize(stripClusters->dataSize(), false);
493  } else {
494  collectedStrips_.resize(stripClusters->dataSize(), false);
495  collectedPixels_.resize(pixelClusters->dataSize(), false);
496  }
497 
498  if (doTracks_) {
500  iEvent.getByToken(tracks_, tracks);
501 
502  std::vector<Handle<edm::ValueMap<int> > > quals;
503  if (!overrideTrkQuals_.empty()) {
504  quals.resize(1);
505  iEvent.getByToken(overrideTrkQuals_[0], quals[0]);
506  }
507  int it = 0;
508  for (const auto &track : *tracks) {
509  if (filterTracks_) {
510  bool goodTk = true;
511  if (!quals.empty()) {
512  int qual = (*(quals[0])).get(it++);
513  if (qual < 0) {
514  goodTk = false;
515  }
516  //note that this does not work for some trackquals (goodIterative or undefQuality)
517  else
518  goodTk = (qual & (1 << trackQuality_)) >> trackQuality_;
519  } else
520  goodTk = (track.quality(trackQuality_));
521  if (!goodTk)
522  continue;
523  if (track.hitPattern().trackerLayersWithMeasurement() < minNumberOfLayersWithMeasBeforeFiltering_)
524  continue;
525  }
526  auto const &chi2sX5 = track.extra()->chi2sX5();
527  assert(chi2sX5.size() == track.recHitsSize());
528  auto hb = track.recHitsBegin();
529  for (unsigned int h = 0; h < track.recHitsSize(); h++) {
530  auto hit = *(hb + h);
531  if (!hit->isValid())
532  continue;
533  process(hit, chi2sX5[h], tgh.product());
534  }
535  }
536  }
537 
538  if (doStripChargeCheck_) {
540  iEvent.getByToken(rphiRecHitToken_, rechitsrphi);
541  const SiStripRecHit2DCollection::DataContainer *rphiRecHits = &(rechitsrphi).product()->data();
543  recHit != rphiRecHits->end();
544  recHit++) {
545  SiStripDetId detid = recHit->geographicalId();
546  process(recHit->omniClusterRef(), detid, false);
547  }
549  iEvent.getByToken(stereoRecHitToken_, rechitsstereo);
550  const SiStripRecHit2DCollection::DataContainer *stereoRecHits = &(rechitsstereo).product()->data();
552  recHit != stereoRecHits->end();
553  recHit++) {
554  SiStripDetId detid = recHit->geographicalId();
555  process(recHit->omniClusterRef(), detid, false);
556  }
557  }
558  // if(doPixelChargeCheck_) {
559  // edm::Handle<SiPixelRecHitCollection> pixelrechits;
560  // iEvent.getByToken(pixelRecHitsToken_,pixelrechits);
561  // }
562 
565  cleanup(*pixelClusters, pixels, cri->pixelIndices(), mergeOld_ ? &oldRemovalInfo->pixelIndices() : nullptr));
566  //DBG// std::cout << "HITrackClusterRemover: Wrote pixel " << newPixels.id() << " from " << pixelSourceProdID << std::endl;
567  cri->setNewPixelClusters(newPixels);
568  }
571  cleanup(*stripClusters, strips, cri->stripIndices(), mergeOld_ ? &oldRemovalInfo->stripIndices() : nullptr));
572  //DBG// std::cout << "HITrackClusterRemover: Wrote strip " << newStrips.id() << " from " << stripSourceProdID << std::endl;
573  cri->setNewStripClusters(newStrips);
574  }
575 
576  if (clusterWasteSolution_) {
577  // double fraction_pxl= cri->pixelIndices().size() / (double) pixels.size();
578  // double fraction_strp= cri->stripIndices().size() / (double) strips.size();
579  // edm::LogWarning("HITrackClusterRemover")<<" fraction: " << fraction_pxl <<" "<<fraction_strp;
580  iEvent.put(std::move(cri));
581  }
582 
583  pixels.clear();
584  strips.clear();
585 
586  if (!clusterWasteSolution_) {
587  //auto_ptr<edmNew::DetSetVector<SiPixelClusterRefNew> > removedPixelClsuterRefs(new edmNew::DetSetVector<SiPixelClusterRefNew>());
588  //auto_ptr<edmNew::DetSetVector<SiStripRecHit1D::ClusterRef> > removedStripClsuterRefs(new edmNew::DetSetVector<SiStripRecHit1D::ClusterRef>());
589 
590  LogDebug("HITrackClusterRemover") << "total strip to skip: "
591  << std::count(collectedStrips_.begin(), collectedStrips_.end(), true);
592  // std::cout << "HITrackClusterRemover " <<"total strip to skip: "<<std::count(collectedStrips_.begin(),collectedStrips_.end(),true) <<std::endl;
593  iEvent.put(std::make_unique<StripMaskContainer>(edm::RefProd<edmNew::DetSetVector<SiStripCluster> >(stripClusters),
595 
596  LogDebug("HITrackClusterRemover") << "total pxl to skip: "
597  << std::count(collectedPixels_.begin(), collectedPixels_.end(), true);
598  iEvent.put(std::make_unique<PixelMaskContainer>(edm::RefProd<edmNew::DetSetVector<SiPixelCluster> >(pixelClusters),
600  }
601  collectedStrips_.clear();
602  collectedPixels_.clear();
603 }
#define LogDebug(id)
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
void process(const TrackingRecHit *hit, unsigned char chi2, const TrackerGeometry *tg)
std::vector< data_type > DataContainer
ProductID id() const
Definition: HandleBase.cc:13
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
std::vector< edm::EDGetTokenT< edm::ValueMap< int > > > overrideTrkQuals_
std::vector< uint8_t > strips
void copyMaskTo(std::vector< bool > &) const
Definition: ContainerMask.h:87
edm::EDGetTokenT< reco::ClusterRemovalInfo > oldRemovalInfo_
edm::EDGetTokenT< StripMaskContainer > oldStrMaskToken_
edm::EDGetTokenT< reco::TrackCollection > tracks_
reco::TrackBase::TrackQuality trackQuality_
size_t size() const
Definition: ContainerMask.h:53
Detector identifier class for the strip tracker.
Definition: SiStripDetId.h:18
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
edm::EDGetTokenT< PixelMaskContainer > oldPxlMaskToken_
edm::EDGetTokenT< edmNew::DetSetVector< SiStripCluster > > stripClusters_
std::vector< bool > collectedStrips_
edm::EDGetTokenT< SiStripRecHit2DCollection > stereoRecHitToken_
edm::EDGetTokenT< SiStripRecHit2DCollection > rphiRecHitToken_
std::unique_ptr< edmNew::DetSetVector< T > > cleanup(const edmNew::DetSetVector< T > &oldClusters, const std::vector< uint8_t > &isGood, reco::ClusterRemovalInfo::Indices &refs, const reco::ClusterRemovalInfo::Indices *oldRefs)
char const * productInstance
Definition: ProductLabels.h:6
std::vector< uint8_t > pixels
T get() const
Definition: EventSetup.h:73
ProductIndex id() const
Definition: ProductID.h:35
std::vector< bool > collectedPixels_
T const * product() const
Definition: ESHandle.h:86
def move(src, dest)
Definition: eostools.py:511
edm::EDGetTokenT< edmNew::DetSetVector< SiPixelCluster > > pixelClusters_
void HITrackClusterRemover::readPSet ( const edm::ParameterSet iConfig,
const std::string &  name,
int  id1 = -1,
int  id2 = -1,
int  id3 = -1,
int  id4 = -1,
int  id5 = -1,
int  id6 = -1 
)
private

Definition at line 123 of file HITrackClusterRemover.cc.

References edm::ParameterSet::exists(), ntuplemaker::fill, edm::ParameterSet::getParameter(), globals_cff::id1, globals_cff::id2, NumberOfParamBlocks, and pblocks_.

Referenced by HITrackClusterRemover().

124  {
125  if (iConfig.exists(name)) {
126  ParamBlock pblock(iConfig.getParameter<ParameterSet>(name));
127  if (id1 == -1) {
129  } else {
130  pblocks_[id1] = pblock;
131  if (id2 != -1)
132  pblocks_[id2] = pblock;
133  if (id3 != -1)
134  pblocks_[id3] = pblock;
135  if (id4 != -1)
136  pblocks_[id4] = pblock;
137  if (id5 != -1)
138  pblocks_[id5] = pblock;
139  if (id6 != -1)
140  pblocks_[id6] = pblock;
141  }
142  }
143 }
T getParameter(std::string const &) const
bool exists(std::string const &parameterName) const
checks if a parameter exists
static const unsigned int NumberOfParamBlocks
ParamBlock pblocks_[NumberOfParamBlocks]
float HITrackClusterRemover::sensorThickness ( const SiStripDetId detid) const
private

Definition at line 295 of file HITrackClusterRemover.cc.

References OmniClusterRef::cluster_strip(), clusterWasteSolution_, collectedStrips_, edm::Ref< C, T, F >::id(), edm::Ref< C, T, F >::key(), HITrackClusterRemover::ParamBlock::maxSize_, SiStripDetId::moduleGeometry(), pblocks_, PixelSubdetector::PixelBarrel, process(), strips, stripSourceProdID, DetId::subdetId(), SiStripDetId::TIB, SiStripDetId::TOB, W5, W6, and W7.

295  {
296  if (detid.subdetId() >= SiStripDetId::TIB) {
297  if (detid.subdetId() == SiStripDetId::TOB)
298  return 0.047;
301  return 0.047;
302  return 0.029; // so it is TEC ring 1-4 or TIB or TOB;
303  } else if (detid.subdetId() == PixelSubdetector::PixelBarrel)
304  return 0.0285;
305  else
306  return 0.027;
307 }
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
static constexpr auto TOB
Definition: SiStripDetId.h:39
static constexpr auto TIB
Definition: SiStripDetId.h:37
SiStripModuleGeometry moduleGeometry() const
Definition: SiStripDetId.h:109

Member Data Documentation

bool HITrackClusterRemover::clusterWasteSolution_
private

Definition at line 108 of file HITrackClusterRemover.cc.

Referenced by HITrackClusterRemover(), process(), produce(), and sensorThickness().

std::vector<bool> HITrackClusterRemover::collectedPixels_
private

Definition at line 114 of file HITrackClusterRemover.cc.

Referenced by process(), and produce().

std::vector<bool> HITrackClusterRemover::collectedStrips_
private

Definition at line 113 of file HITrackClusterRemover.cc.

Referenced by produce(), and sensorThickness().

bool HITrackClusterRemover::doPixel_
private

Definition at line 69 of file HITrackClusterRemover.cc.

Referenced by HITrackClusterRemover(), process(), and produce().

bool HITrackClusterRemover::doPixelChargeCheck_
private

Definition at line 108 of file HITrackClusterRemover.cc.

Referenced by HITrackClusterRemover().

bool HITrackClusterRemover::doStrip_
private

Definition at line 69 of file HITrackClusterRemover.cc.

Referenced by HITrackClusterRemover(), process(), and produce().

bool HITrackClusterRemover::doStripChargeCheck_
private

Definition at line 108 of file HITrackClusterRemover.cc.

Referenced by HITrackClusterRemover(), and produce().

bool HITrackClusterRemover::doTracks_
private

Definition at line 68 of file HITrackClusterRemover.cc.

Referenced by HITrackClusterRemover(), and produce().

bool HITrackClusterRemover::filterTracks_
private

Definition at line 110 of file HITrackClusterRemover.cc.

Referenced by HITrackClusterRemover(), and produce().

bool HITrackClusterRemover::mergeOld_
private

Definition at line 70 of file HITrackClusterRemover.cc.

Referenced by HITrackClusterRemover(), and produce().

int HITrackClusterRemover::minNumberOfLayersWithMeasBeforeFiltering_
private

Definition at line 111 of file HITrackClusterRemover.cc.

Referenced by HITrackClusterRemover(), and produce().

const unsigned int HITrackClusterRemover::NumberOfParamBlocks = 6
staticprivate

Definition at line 66 of file HITrackClusterRemover.cc.

Referenced by HITrackClusterRemover(), process(), and readPSet().

edm::EDGetTokenT<PixelMaskContainer> HITrackClusterRemover::oldPxlMaskToken_
private

Definition at line 77 of file HITrackClusterRemover.cc.

Referenced by HITrackClusterRemover(), and produce().

edm::EDGetTokenT<reco::ClusterRemovalInfo> HITrackClusterRemover::oldRemovalInfo_
private

Definition at line 76 of file HITrackClusterRemover.cc.

Referenced by HITrackClusterRemover(), and produce().

edm::EDGetTokenT<StripMaskContainer> HITrackClusterRemover::oldStrMaskToken_
private

Definition at line 78 of file HITrackClusterRemover.cc.

Referenced by HITrackClusterRemover(), and produce().

std::vector<edm::EDGetTokenT<edm::ValueMap<int> > > HITrackClusterRemover::overrideTrkQuals_
private

Definition at line 79 of file HITrackClusterRemover.cc.

Referenced by HITrackClusterRemover(), and produce().

ParamBlock HITrackClusterRemover::pblocks_[NumberOfParamBlocks]
private

Definition at line 83 of file HITrackClusterRemover.cc.

Referenced by HITrackClusterRemover(), process(), readPSet(), and sensorThickness().

edm::EDGetTokenT<edmNew::DetSetVector<SiPixelCluster> > HITrackClusterRemover::pixelClusters_
private

Definition at line 73 of file HITrackClusterRemover.cc.

Referenced by HITrackClusterRemover(), and produce().

std::string HITrackClusterRemover::pixelRecHits_
private

Definition at line 109 of file HITrackClusterRemover.cc.

std::vector<uint8_t> HITrackClusterRemover::pixels
private

Definition at line 93 of file HITrackClusterRemover.cc.

Referenced by process(), and produce().

edm::ProductID HITrackClusterRemover::pixelSourceProdID
private

Definition at line 94 of file HITrackClusterRemover.cc.

Referenced by process(), and produce().

edm::EDGetTokenT<SiStripRecHit2DCollection> HITrackClusterRemover::rphiRecHitToken_
private

Definition at line 80 of file HITrackClusterRemover.cc.

Referenced by HITrackClusterRemover(), and produce().

edm::EDGetTokenT<SiStripRecHit2DCollection> HITrackClusterRemover::stereoRecHitToken_
private

Definition at line 80 of file HITrackClusterRemover.cc.

Referenced by HITrackClusterRemover(), and produce().

edm::EDGetTokenT<edmNew::DetSetVector<SiStripCluster> > HITrackClusterRemover::stripClusters_
private

Definition at line 74 of file HITrackClusterRemover.cc.

Referenced by HITrackClusterRemover(), and produce().

std::string HITrackClusterRemover::stripRecHits_
private

Definition at line 109 of file HITrackClusterRemover.cc.

Referenced by HITrackClusterRemover().

std::vector<uint8_t> HITrackClusterRemover::strips
private

Definition at line 93 of file HITrackClusterRemover.cc.

Referenced by produce(), and sensorThickness().

edm::ProductID HITrackClusterRemover::stripSourceProdID
private

Definition at line 94 of file HITrackClusterRemover.cc.

Referenced by produce(), and sensorThickness().

reco::TrackBase::TrackQuality HITrackClusterRemover::trackQuality_
private

Definition at line 112 of file HITrackClusterRemover.cc.

Referenced by HITrackClusterRemover(), and produce().

edm::EDGetTokenT<reco::TrackCollection> HITrackClusterRemover::tracks_
private

Definition at line 75 of file HITrackClusterRemover.cc.

Referenced by HITrackClusterRemover(), and produce().