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 hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () 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 44 of file HITrackClusterRemover.cc.

Member Typedef Documentation

Definition at line 72 of file HITrackClusterRemover.cc.

Definition at line 73 of file HITrackClusterRemover.cc.

Constructor & Destructor Documentation

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

Definition at line 139 of file HITrackClusterRemover.cc.

References clusterWasteSolution_, doPixel_, doPixelChargeCheck_, doStrip_, doStripChargeCheck_, doTracks_, Exception, edm::ParameterSet::exists(), edm::ParameterSet::existsAs(), lumiContext::fill, filterTracks_, edm::ParameterSet::getParameter(), mps_fire::i, 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.

139  :
140  doTracks_(iConfig.exists("trajectories")),
141  doStrip_(iConfig.existsAs<bool>("doStrip") ? iConfig.getParameter<bool>("doStrip") : true),
142  doPixel_(iConfig.existsAs<bool>("doPixel") ? iConfig.getParameter<bool>("doPixel") : true),
143  mergeOld_(iConfig.exists("oldClusterRemovalInfo")),
144  clusterWasteSolution_(true),
145  doStripChargeCheck_(iConfig.existsAs<bool>("doStripChargeCheck") ? iConfig.getParameter<bool>("doStripChargeCheck") : false),
146  doPixelChargeCheck_(iConfig.existsAs<bool>("doPixelChargeCheck") ? iConfig.getParameter<bool>("doPixelChargeCheck") : false),
147  stripRecHits_(doStripChargeCheck_ ? iConfig.getParameter<std::string>("stripRecHits") : std::string("siStripMatchedRecHits")),
148  pixelRecHits_(doPixelChargeCheck_ ? iConfig.getParameter<std::string>("pixelRecHits") : std::string("siPixelRecHits"))
149 {
150  mergeOld_ = mergeOld_ && iConfig.getParameter<InputTag>("oldClusterRemovalInfo").label()!="";
151  if (iConfig.exists("overrideTrkQuals"))
152  overrideTrkQuals_.push_back(consumes<edm::ValueMap<int> >(iConfig.getParameter<InputTag>("overrideTrkQuals")));
153  if (iConfig.exists("clusterLessSolution"))
154  clusterWasteSolution_=!iConfig.getParameter<bool>("clusterLessSolution");
156  throw cms::Exception("Configuration Error") << "HITrackClusterRemover: Charge check asked without cluster collection ";
158  throw cms::Exception("Configuration Error") << "HITrackClusterRemover: Pixel cluster charge check not yet implemented";
159 
160  if (doPixel_ && clusterWasteSolution_) produces< edmNew::DetSetVector<SiPixelCluster> >();
161  if (doStrip_ && clusterWasteSolution_) produces< edmNew::DetSetVector<SiStripCluster> >();
162  if (clusterWasteSolution_) produces< ClusterRemovalInfo >();
163 
164  assert(!clusterWasteSolution_);
165 
166 
167  fill(pblocks_, pblocks_+NumberOfParamBlocks, ParamBlock());
168  readPSet(iConfig, "Common",-1);
169  if (doPixel_) {
170  readPSet(iConfig, "Pixel" ,0,1);
171  readPSet(iConfig, "PXB" ,0);
172  readPSet(iConfig, "PXE" ,1);
173  }
174  if (doStrip_) {
175  readPSet(iConfig, "Strip" ,2,3,4,5);
176  readPSet(iConfig, "StripInner" ,2,3);
177  readPSet(iConfig, "StripOuter" ,4,5);
178  readPSet(iConfig, "TIB" ,2);
179  readPSet(iConfig, "TID" ,3);
180  readPSet(iConfig, "TOB" ,4);
181  readPSet(iConfig, "TEC" ,5);
182  }
183 
184  bool usingCharge = false;
185  for (size_t i = 0; i < NumberOfParamBlocks; ++i) {
186  if (!pblocks_[i].isSet_) throw cms::Exception("Configuration Error") << "HITrackClusterRemover: Missing configuration for detector with subDetID = " << (i+1);
187  if (pblocks_[i].usesCharge_ && !usingCharge) {
188  throw cms::Exception("Configuration Error") << "HITrackClusterRemover: Configuration for subDetID = " << (i+1) << " uses cluster charge, which is not enabled.";
189  }
190  }
191 
192  if (!clusterWasteSolution_){
193  produces<edm::ContainerMask<edmNew::DetSetVector<SiPixelCluster> > >();
194  produces<edm::ContainerMask<edmNew::DetSetVector<SiStripCluster> > >();
195  }
197  filterTracks_=false;
198  if (iConfig.exists("TrackQuality")){
199  filterTracks_=true;
200  trackQuality_=reco::TrackBase::qualityByName(iConfig.getParameter<std::string>("TrackQuality"));
201  minNumberOfLayersWithMeasBeforeFiltering_ = iConfig.existsAs<int>("minNumberOfLayersWithMeasBeforeFiltering") ?
202  iConfig.getParameter<int>("minNumberOfLayersWithMeasBeforeFiltering") : 0;
203  }
204 
205  if (doTracks_) tracks_ = consumes<reco::TrackCollection>(iConfig.getParameter<InputTag>("trajectories"));
206  if (doPixel_) pixelClusters_ = consumes<edmNew::DetSetVector<SiPixelCluster> >(iConfig.getParameter<InputTag>("pixelClusters"));
207  if (doStrip_) stripClusters_ = consumes<edmNew::DetSetVector<SiStripCluster> >(iConfig.getParameter<InputTag>("stripClusters"));
208  if (mergeOld_) {
209  oldRemovalInfo_ = consumes<ClusterRemovalInfo>(iConfig.getParameter<InputTag>("oldClusterRemovalInfo"));
210  oldPxlMaskToken_ = consumes<PixelMaskContainer>(iConfig.getParameter<InputTag>("oldClusterRemovalInfo"));
211  oldStrMaskToken_ = consumes<StripMaskContainer>(iConfig.getParameter<InputTag>("oldClusterRemovalInfo"));
212  }
213 
214  if (doStripChargeCheck_) {
215  rphiRecHitToken_ = consumes<SiStripRecHit2DCollection>(InputTag(stripRecHits_,"rphiRecHit"));
216  stereoRecHitToken_ = consumes<SiStripRecHit2DCollection>(InputTag(stripRecHits_,"stereoRecHit"));
217  }
218 // if(doPixelChargeCheck_) pixelRecHitsToken_ = consumes<SiPixelRecHitCollection>(InputTag(pixelRecHits_));
219 
220 }
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:161
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:134
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 223 of file HITrackClusterRemover.cc.

224 {
225 }

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 238 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().

239  {
240  typedef typename edmNew::DetSetVector<T> DSV;
241  typedef typename edmNew::DetSetVector<T>::FastFiller DSF;
242  typedef typename edmNew::DetSet<T> DS;
243  auto output = std::make_unique<DSV>();
244  output->reserve(oldClusters.size(), oldClusters.dataSize());
245 
246  unsigned int countOld=0;
247  unsigned int countNew=0;
248 
249  // cluster removal loop
250  const T * firstOffset = & oldClusters.data().front();
251  for (typename DSV::const_iterator itdet = oldClusters.begin(), enddet = oldClusters.end(); itdet != enddet; ++itdet) {
252  DS oldDS = *itdet;
253 
254  if (oldDS.empty()) continue; // skip empty detsets
255 
256  uint32_t id = oldDS.detId();
257  DSF outds(*output, id);
258 
259  for (typename DS::const_iterator it = oldDS.begin(), ed = oldDS.end(); it != ed; ++it) {
260  uint32_t index = ((&*it) - firstOffset);
261  countOld++;
262  if (isGood[index]) {
263  outds.push_back(*it);
264  countNew++;
265  refs.push_back(index);
266  //std::cout << "HITrackClusterRemover::cleanup " << typeid(T).name() << " reference " << index << " to " << (refs.size() - 1) << std::endl;
267  }
268 
269  }
270  if (outds.empty()) outds.abort(); // not write in an empty DSV
271  }
272 
273  if (oldRefs != nullptr) mergeOld(refs, *oldRefs);
274  return output;
275 }
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 227 of file HITrackClusterRemover.cc.

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

Referenced by cleanup().

229 {
230  for (size_t i = 0, n = refs.size(); i < n; ++i) {
231  refs[i] = oldRefs[refs[i]];
232  }
233 }
void HITrackClusterRemover::process ( const TrackingRecHit hit,
unsigned char  chi2,
const TrackerGeometry tg 
)
inlineprivate

Definition at line 316 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().

316  {
317  SiStripDetId detid = hit->geographicalId();
318  uint32_t subdet = detid.subdetId();
319 
320  assert ((subdet > 0) && (subdet <= NumberOfParamBlocks));
321 
322  // chi2 cut
323  if (chi2 > Traj2TrackHits::toChi2x5(pblocks_[subdet-1].maxChi2_)) return;
324 
326  if (!doPixel_) return;
327  // this is a pixel, and i *know* it is
328  const SiPixelRecHit *pixelHit = static_cast<const SiPixelRecHit *>(hit);
329 
330  SiPixelRecHit::ClusterRef cluster = pixelHit->cluster();
331 
332  if (cluster.id() != pixelSourceProdID) throw cms::Exception("Inconsistent Data") <<
333  "HITrackClusterRemover: pixel cluster ref from Product ID = " << cluster.id() <<
334  " does not match with source cluster collection (ID = " << pixelSourceProdID << ")\n.";
335 
336  assert(cluster.id() == pixelSourceProdID);
337 //DBG// cout << "HIT NEW PIXEL DETID = " << detid.rawId() << ", Cluster [ " << cluster.key().first << " / " << cluster.key().second << " ] " << endl;
338 
339  // if requested, cut on cluster size
340  if (pblocks_[subdet-1].usesSize_ && (cluster->pixels().size() > pblocks_[subdet-1].maxSize_)) return;
341 
342  // mark as used
343  pixels[cluster.key()] = false;
344 
345  //if(!clusterWasteSolution_) collectedPixel[detid.rawId()].insert(cluster);
346  assert(collectedPixels_.size() > cluster.key());
347  //assert(detid.rawId() == cluster->geographicalId()); //This condition fails
348  if(!clusterWasteSolution_) collectedPixels_[cluster.key()]=true;
349 
350  } else { // aka Strip
351  if (!doStrip_) return;
352  const type_info &hitType = typeid(*hit);
353  if (hitType == typeid(SiStripRecHit2D)) {
354  const SiStripRecHit2D *stripHit = static_cast<const SiStripRecHit2D *>(hit);
355 //DBG// cout << "Plain RecHit 2D: " << endl;
356  process(stripHit->omniClusterRef(),detid, true);}
357  else if (hitType == typeid(SiStripRecHit1D)) {
358  const SiStripRecHit1D *hit1D = static_cast<const SiStripRecHit1D *>(hit);
359  process(hit1D->omniClusterRef(),detid, true);
360  } else if (hitType == typeid(SiStripMatchedRecHit2D)) {
361  const SiStripMatchedRecHit2D *matchHit = static_cast<const SiStripMatchedRecHit2D *>(hit);
362 //DBG// cout << "Matched RecHit 2D: " << endl;
363  process(matchHit->monoClusterRef(),detid, true);
364  process(matchHit->stereoClusterRef(),detid, true);
365  } else if (hitType == typeid(ProjectedSiStripRecHit2D)) {
366  const ProjectedSiStripRecHit2D *projHit = static_cast<const ProjectedSiStripRecHit2D *>(hit);
367 //DBG// cout << "Projected RecHit 2D: " << endl;
368  process(projHit->originalHit().omniClusterRef(),detid, true);
369  } else throw cms::Exception("NOT IMPLEMENTED") << "Don't know how to handle " << hitType.name() << " on detid " << detid.rawId() << "\n";
370  }
371 }
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:50
static const unsigned int NumberOfParamBlocks
key_type key() const
Accessor for product key.
Definition: Ref.h:263
ProductID id() const
Accessor for product ID.
Definition: Ref.h:257
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:41
OmniClusterRef const & monoClusterRef() const
ParamBlock pblocks_[NumberOfParamBlocks]
SiStripRecHit2D originalHit() const
Detector identifier class for the strip tracker.
Definition: SiStripDetId.h:17
OmniClusterRef const & omniClusterRef() const
ClusterRef cluster() const
Definition: SiPixelRecHit.h:49
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 385 of file HITrackClusterRemover.cc.

References cleanup(), clusterWasteSolution_, collectedPixels_, collectedStrips_, edm::ContainerMask< T >::copyMaskTo(), KineDebug3::count(), DEFINE_FWK_MODULE, doPixel_, doStrip_, doStripChargeCheck_, doTracks_, Exception, lumiContext::fill, filterTracks_, edm::EventSetup::get(), edm::Event::getByToken(), h, hcalSimParameters_cfi::hb, edm::ProductID::id(), edm::HandleBase::id(), tablePrinter::labels, LogDebug, mergeOld_, minNumberOfLayersWithMeasBeforeFiltering_, eostools::move(), oldPxlMaskToken_, oldRemovalInfo_, oldStrMaskToken_, overrideTrkQuals_, HiRegitMuonDetachedTripletStep_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_, HiRegitMuonDetachedTripletStep_cff::stripClusters, stripClusters_, strips, stripSourceProdID, HiIsolationCommonParameters_cff::track, trackQuality_, l1t::tracks, and tracks_.

386 {
387  ProductID pixelOldProdID, stripOldProdID;
388 
390  iSetup.get<TrackerDigiGeometryRecord>().get(tgh);
391 
393  if (doPixel_) {
394  iEvent.getByToken(pixelClusters_, pixelClusters);
395  pixelSourceProdID = pixelClusters.id();
396  }
397 //DBG// std::cout << "HITrackClusterRemover: Read pixel " << pixelClusters_.encode() << " = ID " << pixelSourceProdID << std::endl;
398 
400  if (doStrip_) {
401  iEvent.getByToken(stripClusters_, stripClusters);
402  stripSourceProdID = stripClusters.id();
403  }
404 //DBG// std::cout << "HITrackClusterRemover: Read strip " << stripClusters_.encode() << " = ID " << stripSourceProdID << std::endl;
405 
406  std::unique_ptr<ClusterRemovalInfo> cri;
408  if (doStrip_ && doPixel_) cri = std::make_unique<ClusterRemovalInfo>(pixelClusters, stripClusters);
409  else if (doStrip_) cri = std::make_unique<ClusterRemovalInfo>(stripClusters);
410  else if (doPixel_) cri = std::make_unique<ClusterRemovalInfo>(pixelClusters);
411  }
412 
413  Handle<ClusterRemovalInfo> oldRemovalInfo;
415  iEvent.getByToken(oldRemovalInfo_, oldRemovalInfo);
416  // Check ProductIDs
417  if ( (oldRemovalInfo->stripNewRefProd().id() == stripClusters.id()) &&
418  (oldRemovalInfo->pixelNewRefProd().id() == pixelClusters.id()) ) {
419 
420  cri->getOldClustersFrom(*oldRemovalInfo);
421 
422  pixelOldProdID = oldRemovalInfo->pixelRefProd().id();
423  stripOldProdID = oldRemovalInfo->stripRefProd().id();
424 
425  } else {
426 
428  labelsForToken(oldRemovalInfo_,labels);
429  throw cms::Exception("Inconsistent Data") << "HITrackClusterRemover: " <<
430  "Input collection product IDs are [pixel: " << pixelClusters.id() << ", strip: " << stripClusters.id() << "] \n" <<
431  "\t but the *old* ClusterRemovalInfo " << labels.productInstance << " refers as 'new product ids' to " <<
432  "[pixel: " << oldRemovalInfo->pixelNewRefProd().id() << ", strip: " << oldRemovalInfo->stripNewRefProd().id() << "]\n" <<
433  "NOTA BENE: when running HITrackClusterRemover with an old ClusterRemovalInfo the hits in the trajectory MUST be already re-keyed.\n";
434  }
435  } else { // then Old == Source
436  pixelOldProdID = pixelSourceProdID;
437  stripOldProdID = stripSourceProdID;
438  }
439 
440  if (doStrip_) {
441  strips.resize(stripClusters->dataSize()); fill(strips.begin(), strips.end(), true);
442  }
443  if (doPixel_) {
444  pixels.resize(pixelClusters->dataSize()); fill(pixels.begin(), pixels.end(), true);
445  }
446  if(mergeOld_) {
449  iEvent.getByToken(oldPxlMaskToken_ ,oldPxlMask);
450  iEvent.getByToken(oldStrMaskToken_ ,oldStrMask);
451  LogDebug("HITrackClusterRemover")<<"to merge in, "<<oldStrMask->size()<<" strp and "<<oldPxlMask->size()<<" pxl";
452  oldStrMask->copyMaskTo(collectedStrips_);
453  oldPxlMask->copyMaskTo(collectedPixels_);
454  assert(stripClusters->dataSize()>=collectedStrips_.size());
455  collectedStrips_.resize(stripClusters->dataSize(), false);
456  }else {
457  collectedStrips_.resize(stripClusters->dataSize(), false);
458  collectedPixels_.resize(pixelClusters->dataSize(), false);
459  }
460 
461  if (doTracks_) {
462 
464  iEvent.getByToken(tracks_,tracks);
465 
466  std::vector<Handle<edm::ValueMap<int> > > quals;
467  if ( !overrideTrkQuals_.empty()) {
468  quals.resize(1);
469  iEvent.getByToken(overrideTrkQuals_[0],quals[0]);
470  }
471  int it=0;
472  for (const auto & track: *tracks) {
473  if (filterTracks_) {
474  bool goodTk = true;
475  if ( !quals.empty()) {
476  int qual=(*(quals[0])). get(it++);
477  if ( qual < 0 ) {goodTk=false;}
478  //note that this does not work for some trackquals (goodIterative or undefQuality)
479  else
480  goodTk = ( qual & (1<<trackQuality_))>>trackQuality_;
481  }
482  else
483  goodTk=(track.quality(trackQuality_));
484  if ( !goodTk) continue;
485  if(track.hitPattern().trackerLayersWithMeasurement() < minNumberOfLayersWithMeasBeforeFiltering_) continue;
486  }
487  auto const & chi2sX5 = track.extra()->chi2sX5();
488  assert(chi2sX5.size()==track.recHitsSize());
489  auto hb = track.recHitsBegin();
490  for(unsigned int h=0;h<track.recHitsSize();h++){
491  auto hit = *(hb+h);
492  if (!hit->isValid()) continue;
493  process( hit, chi2sX5[h], tgh.product());
494  }
495  }
496  }
497 
498  if (doStripChargeCheck_) {
500  iEvent.getByToken(rphiRecHitToken_, rechitsrphi);
501  const SiStripRecHit2DCollection::DataContainer * rphiRecHits = & (rechitsrphi).product()->data();
503  recHit = rphiRecHits->begin(); recHit!= rphiRecHits->end(); recHit++){
504  SiStripDetId detid = recHit->geographicalId();
505  process(recHit->omniClusterRef(),detid,false);
506  }
508  iEvent.getByToken(stereoRecHitToken_, rechitsstereo);
509  const SiStripRecHit2DCollection::DataContainer * stereoRecHits = & (rechitsstereo).product()->data();
511  recHit = stereoRecHits->begin(); recHit!= stereoRecHits->end(); recHit++){
512  SiStripDetId detid = recHit->geographicalId();
513  process(recHit->omniClusterRef(),detid,false);
514  }
515 
516  }
517 // if(doPixelChargeCheck_) {
518 // edm::Handle<SiPixelRecHitCollection> pixelrechits;
519 // iEvent.getByToken(pixelRecHitsToken_,pixelrechits);
520 // }
521 
524  iEvent.put(cleanup(*pixelClusters, pixels, cri->pixelIndices(), mergeOld_ ? &oldRemovalInfo->pixelIndices() : nullptr));
525 //DBG// std::cout << "HITrackClusterRemover: Wrote pixel " << newPixels.id() << " from " << pixelSourceProdID << std::endl;
526  cri->setNewPixelClusters(newPixels);
527  }
529  OrphanHandle<edmNew::DetSetVector<SiStripCluster> > newStrips = iEvent.put(cleanup(*stripClusters, strips, cri->stripIndices(), mergeOld_ ? &oldRemovalInfo->stripIndices() : nullptr));
530 //DBG// std::cout << "HITrackClusterRemover: Wrote strip " << newStrips.id() << " from " << stripSourceProdID << std::endl;
531  cri->setNewStripClusters(newStrips);
532  }
533 
534 
535  if (clusterWasteSolution_) {
536  // double fraction_pxl= cri->pixelIndices().size() / (double) pixels.size();
537  // double fraction_strp= cri->stripIndices().size() / (double) strips.size();
538  // edm::LogWarning("HITrackClusterRemover")<<" fraction: " << fraction_pxl <<" "<<fraction_strp;
539  iEvent.put(std::move(cri));
540  }
541 
542  pixels.clear(); strips.clear();
543 
544  if (!clusterWasteSolution_){
545  //auto_ptr<edmNew::DetSetVector<SiPixelClusterRefNew> > removedPixelClsuterRefs(new edmNew::DetSetVector<SiPixelClusterRefNew>());
546  //auto_ptr<edmNew::DetSetVector<SiStripRecHit1D::ClusterRef> > removedStripClsuterRefs(new edmNew::DetSetVector<SiStripRecHit1D::ClusterRef>());
547 
548  LogDebug("HITrackClusterRemover")<<"total strip to skip: "<<std::count(collectedStrips_.begin(),collectedStrips_.end(),true);
549  // std::cout << "HITrackClusterRemover " <<"total strip to skip: "<<std::count(collectedStrips_.begin(),collectedStrips_.end(),true) <<std::endl;
550  iEvent.put(std::make_unique<StripMaskContainer>(edm::RefProd<edmNew::DetSetVector<SiStripCluster> >(stripClusters),collectedStrips_));
551 
552  LogDebug("HITrackClusterRemover")<<"total pxl to skip: "<<std::count(collectedPixels_.begin(),collectedPixels_.end(),true);
553  iEvent.put(std::make_unique<PixelMaskContainer>(edm::RefProd<edmNew::DetSetVector<SiPixelCluster> >(pixelClusters),collectedPixels_));
554 
555  }
556  collectedStrips_.clear();
557  collectedPixels_.clear();
558 
559 }
#define LogDebug(id)
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
std::vector< edm::EDGetTokenT< edm::ValueMap< int > > > overrideTrkQuals_
void process(const TrackingRecHit *hit, unsigned char chi2, const TrackerGeometry *tg)
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
std::vector< data_type > DataContainer
ProductID id() const
Definition: HandleBase.cc:15
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
std::vector< uint8_t > strips
void copyMaskTo(std::vector< bool > &) const
Definition: ContainerMask.h:91
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:55
Detector identifier class for the strip tracker.
Definition: SiStripDetId.h:17
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:71
ProductIndex id() const
Definition: ProductID.h:38
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 121 of file HITrackClusterRemover.cc.

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

Referenced by HITrackClusterRemover().

123 {
124  if (iConfig.exists(name)) {
125  ParamBlock pblock(iConfig.getParameter<ParameterSet>(name));
126  if (id1 == -1) {
128  } else {
129  pblocks_[id1] = pblock;
130  if (id2 != -1) pblocks_[id2] = pblock;
131  if (id3 != -1) pblocks_[id3] = pblock;
132  if (id4 != -1) pblocks_[id4] = pblock;
133  if (id5 != -1) pblocks_[id5] = pblock;
134  if (id6 != -1) pblocks_[id6] = pblock;
135  }
136  }
137 }
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 277 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, SiStripDetId::W5, SiStripDetId::W6, and SiStripDetId::W7.

278 {
279  if (detid.subdetId()>=SiStripDetId::TIB) {
280  if (detid.subdetId()==SiStripDetId::TOB) return 0.047;
283  return 0.047;
284  return 0.029; // so it is TEC ring 1-4 or TIB or TOB;
285  } else if (detid.subdetId()==PixelSubdetector::PixelBarrel) return 0.0285;
286  else return 0.027;
287 }
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:41
ModuleGeometry moduleGeometry() const
Definition: SiStripDetId.h:106

Member Data Documentation

bool HITrackClusterRemover::clusterWasteSolution_
private

Definition at line 103 of file HITrackClusterRemover.cc.

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

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

Definition at line 109 of file HITrackClusterRemover.cc.

Referenced by process(), and produce().

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

Definition at line 108 of file HITrackClusterRemover.cc.

Referenced by produce(), and sensorThickness().

bool HITrackClusterRemover::doPixel_
private

Definition at line 70 of file HITrackClusterRemover.cc.

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

bool HITrackClusterRemover::doPixelChargeCheck_
private

Definition at line 103 of file HITrackClusterRemover.cc.

Referenced by HITrackClusterRemover().

bool HITrackClusterRemover::doStrip_
private

Definition at line 70 of file HITrackClusterRemover.cc.

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

bool HITrackClusterRemover::doStripChargeCheck_
private

Definition at line 103 of file HITrackClusterRemover.cc.

Referenced by HITrackClusterRemover(), and produce().

bool HITrackClusterRemover::doTracks_
private

Definition at line 69 of file HITrackClusterRemover.cc.

Referenced by HITrackClusterRemover(), and produce().

bool HITrackClusterRemover::filterTracks_
private

Definition at line 105 of file HITrackClusterRemover.cc.

Referenced by HITrackClusterRemover(), and produce().

bool HITrackClusterRemover::mergeOld_
private

Definition at line 71 of file HITrackClusterRemover.cc.

Referenced by HITrackClusterRemover(), and produce().

int HITrackClusterRemover::minNumberOfLayersWithMeasBeforeFiltering_
private

Definition at line 106 of file HITrackClusterRemover.cc.

Referenced by HITrackClusterRemover(), and produce().

const unsigned int HITrackClusterRemover::NumberOfParamBlocks = 6
staticprivate

Definition at line 67 of file HITrackClusterRemover.cc.

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

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

Definition at line 78 of file HITrackClusterRemover.cc.

Referenced by HITrackClusterRemover(), and produce().

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

Definition at line 77 of file HITrackClusterRemover.cc.

Referenced by HITrackClusterRemover(), and produce().

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

Definition at line 79 of file HITrackClusterRemover.cc.

Referenced by HITrackClusterRemover(), and produce().

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

Definition at line 80 of file HITrackClusterRemover.cc.

Referenced by HITrackClusterRemover(), and produce().

ParamBlock HITrackClusterRemover::pblocks_[NumberOfParamBlocks]
private

Definition at line 84 of file HITrackClusterRemover.cc.

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

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

Definition at line 74 of file HITrackClusterRemover.cc.

Referenced by HITrackClusterRemover(), and produce().

std::string HITrackClusterRemover::pixelRecHits_
private

Definition at line 104 of file HITrackClusterRemover.cc.

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

Definition at line 88 of file HITrackClusterRemover.cc.

Referenced by process(), and produce().

edm::ProductID HITrackClusterRemover::pixelSourceProdID
private

Definition at line 89 of file HITrackClusterRemover.cc.

Referenced by process(), and produce().

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

Definition at line 81 of file HITrackClusterRemover.cc.

Referenced by HITrackClusterRemover(), and produce().

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

Definition at line 81 of file HITrackClusterRemover.cc.

Referenced by HITrackClusterRemover(), and produce().

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

Definition at line 75 of file HITrackClusterRemover.cc.

Referenced by HITrackClusterRemover(), and produce().

std::string HITrackClusterRemover::stripRecHits_
private

Definition at line 104 of file HITrackClusterRemover.cc.

Referenced by HITrackClusterRemover().

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

Definition at line 88 of file HITrackClusterRemover.cc.

Referenced by produce(), and sensorThickness().

edm::ProductID HITrackClusterRemover::stripSourceProdID
private

Definition at line 89 of file HITrackClusterRemover.cc.

Referenced by produce(), and sensorThickness().

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

Definition at line 107 of file HITrackClusterRemover.cc.

Referenced by HITrackClusterRemover(), and produce().

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

Definition at line 76 of file HITrackClusterRemover.cc.

Referenced by HITrackClusterRemover(), and produce().