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<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Classes

struct  ParamBlock
 

Public Member Functions

 HITrackClusterRemover (const edm::ParameterSet &iConfig)
 
void produce (edm::Event &iEvent, const edm::EventSetup &iSetup) override
 
 ~HITrackClusterRemover ()
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, std::unordered_multimap< std::string, edm::ProductResolverIndex > const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

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
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::stream::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

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_, edm::EDConsumerBase::consumes(), doPixel_, doPixelChargeCheck_, doStrip_, doStripChargeCheck_, doTracks_, Exception, edm::ParameterSet::exists(), edm::ParameterSet::existsAs(), lumiContext::fill, filterTracks_, edm::ParameterSet::getParameter(), mps_fire::i, diffTwoXMLs::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  fill(pblocks_, pblocks_+NumberOfParamBlocks, ParamBlock());
165  readPSet(iConfig, "Common",-1);
166  if (doPixel_) {
167  readPSet(iConfig, "Pixel" ,0,1);
168  readPSet(iConfig, "PXB" ,0);
169  readPSet(iConfig, "PXE" ,1);
170  }
171  if (doStrip_) {
172  readPSet(iConfig, "Strip" ,2,3,4,5);
173  readPSet(iConfig, "StripInner" ,2,3);
174  readPSet(iConfig, "StripOuter" ,4,5);
175  readPSet(iConfig, "TIB" ,2);
176  readPSet(iConfig, "TID" ,3);
177  readPSet(iConfig, "TOB" ,4);
178  readPSet(iConfig, "TEC" ,5);
179  }
180 
181  bool usingCharge = false;
182  for (size_t i = 0; i < NumberOfParamBlocks; ++i) {
183  if (!pblocks_[i].isSet_) throw cms::Exception("Configuration Error") << "HITrackClusterRemover: Missing configuration for detector with subDetID = " << (i+1);
184  if (pblocks_[i].usesCharge_ && !usingCharge) {
185  throw cms::Exception("Configuration Error") << "HITrackClusterRemover: Configuration for subDetID = " << (i+1) << " uses cluster charge, which is not enabled.";
186  }
187  }
188 
189  if (!clusterWasteSolution_){
190  produces<edm::ContainerMask<edmNew::DetSetVector<SiPixelCluster> > >();
191  produces<edm::ContainerMask<edmNew::DetSetVector<SiStripCluster> > >();
192  }
194  filterTracks_=false;
195  if (iConfig.exists("TrackQuality")){
196  filterTracks_=true;
197  trackQuality_=reco::TrackBase::qualityByName(iConfig.getParameter<std::string>("TrackQuality"));
198  minNumberOfLayersWithMeasBeforeFiltering_ = iConfig.existsAs<int>("minNumberOfLayersWithMeasBeforeFiltering") ?
199  iConfig.getParameter<int>("minNumberOfLayersWithMeasBeforeFiltering") : 0;
200  }
201 
202  if (doTracks_) tracks_ = consumes<reco::TrackCollection>(iConfig.getParameter<InputTag>("trajectories"));
203  if (doPixel_) pixelClusters_ = consumes<edmNew::DetSetVector<SiPixelCluster> >(iConfig.getParameter<InputTag>("pixelClusters"));
204  if (doStrip_) stripClusters_ = consumes<edmNew::DetSetVector<SiStripCluster> >(iConfig.getParameter<InputTag>("stripClusters"));
205  if (mergeOld_) {
206  oldRemovalInfo_ = consumes<ClusterRemovalInfo>(iConfig.getParameter<InputTag>("oldClusterRemovalInfo"));
207  oldPxlMaskToken_ = consumes<PixelMaskContainer>(iConfig.getParameter<InputTag>("oldClusterRemovalInfo"));
208  oldStrMaskToken_ = consumes<StripMaskContainer>(iConfig.getParameter<InputTag>("oldClusterRemovalInfo"));
209  }
210 
211  if (doStripChargeCheck_) {
212  rphiRecHitToken_ = consumes<SiStripRecHit2DCollection>(InputTag(stripRecHits_,"rphiRecHit"));
213  stereoRecHitToken_ = consumes<SiStripRecHit2DCollection>(InputTag(stripRecHits_,"stereoRecHit"));
214  }
215 // if(doPixelChargeCheck_) pixelRecHitsToken_ = consumes<SiPixelRecHitCollection>(InputTag(pixelRecHits_));
216 
217 }
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:186
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
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::EDGetTokenT< reco::ClusterRemovalInfo > oldRemovalInfo_
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:125
edm::EDGetTokenT< edmNew::DetSetVector< SiStripCluster > > stripClusters_
edm::EDGetTokenT< SiStripRecHit2DCollection > stereoRecHitToken_
edm::EDGetTokenT< SiStripRecHit2DCollection > rphiRecHitToken_
edm::EDGetTokenT< edmNew::DetSetVector< SiPixelCluster > > pixelClusters_
HITrackClusterRemover::~HITrackClusterRemover ( )

Definition at line 220 of file HITrackClusterRemover.cc.

221 {
222 }

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 235 of file HITrackClusterRemover.cc.

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

Referenced by produce().

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

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

Referenced by cleanup().

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

Definition at line 313 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 ConfigBuilder.ConfigBuilder::addExtraStream(), ConfigBuilder.ConfigBuilder::completeInputCommand(), ConfigBuilder.ConfigBuilder::doNotInlineEventContent(), ConfigBuilder.ConfigBuilder.PrintAllModules::leave(), ConfigBuilder.ConfigBuilder::prepare(), ConfigBuilder.ConfigBuilder::prepare_ALCA(), ConfigBuilder.ConfigBuilder::prepare_DQM(), ConfigBuilder.ConfigBuilder::prepare_HLT(), ConfigBuilder.ConfigBuilder::prepare_LHE(), ConfigBuilder.ConfigBuilder::prepare_PATFILTER(), ConfigBuilder.ConfigBuilder::prepare_VALIDATION(), produce(), ConfigBuilder.ConfigBuilder::renameHLTprocessInSequence(), ConfigBuilder.ConfigBuilder::renameInputTagsInSequence(), ConfigBuilder.ConfigBuilder::scheduleSequence(), and sensorThickness().

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

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

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

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