CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
InterestingDetIdCollectionProducer Class Reference

#include <InterestingDetIdCollectionProducer.h>

Inheritance diagram for InterestingDetIdCollectionProducer:
edm::stream::EDProducer<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

virtual void beginRun (edm::Run const &, const edm::EventSetup &) override final
 
 InterestingDetIdCollectionProducer (const edm::ParameterSet &)
 ctor More...
 
virtual void produce (edm::Event &, const edm::EventSetup &) override
 producer More...
 
- 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 Attributes

edm::EDGetTokenT< reco::BasicClusterCollectionbasicClustersToken_
 
const CaloTopologycaloTopology_
 
std::string interestingDetIdCollection_
 
bool keepNextToBoundary_
 
bool keepNextToDead_
 
int minimalEtaSize_
 
int minimalPhiSize_
 
edm::EDGetTokenT< EcalRecHitCollectionrecHitsToken_
 
const EcalSeverityLevelAlgoseverity_
 
int severityLevel_
 

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

Original author: Paolo Meridiani PH/CMG

Make a collection of detids to be kept tipically in a AOD rechit collection

The following classes of "interesting id" are considered

1.in a region around  the seed of the cluster collection specified
  by paramter basicClusters. The size of the region is specified by
  minimalEtaSize_, minimalPhiSize_

2. if the severity of the hit is >= severityLevel_
   If severityLevel=0 this class is ignored

3. Channels next to dead ones,  keepNextToDead_ is true
4. Channels next to the EB/EE transition if keepNextToBoundary_ is true

Definition at line 47 of file InterestingDetIdCollectionProducer.h.

Constructor & Destructor Documentation

InterestingDetIdCollectionProducer::InterestingDetIdCollectionProducer ( const edm::ParameterSet iConfig)
explicit

ctor

Definition at line 23 of file InterestingDetIdCollectionProducer.cc.

References basicClustersToken_, edm::ParameterSet::getParameter(), interestingDetIdCollection_, keepNextToBoundary_, keepNextToDead_, minimalEtaSize_, minimalPhiSize_, recHitsToken_, severityLevel_, and AlCaHLTBitMon_QueryRunRegistry::string.

24 {
25 
26  recHitsToken_ =
27  consumes<EcalRecHitCollection>(iConfig.getParameter< edm::InputTag > ("recHitsLabel"));
29  consumes<reco::BasicClusterCollection>(iConfig.getParameter< edm::InputTag >("basicClustersLabel"));
30 
31  interestingDetIdCollection_ = iConfig.getParameter<std::string>("interestingDetIdCollection");
32 
33  minimalEtaSize_ = iConfig.getParameter<int> ("etaSize");
34  minimalPhiSize_ = iConfig.getParameter<int> ("phiSize");
35  if ( minimalPhiSize_ % 2 == 0 || minimalEtaSize_ % 2 == 0)
36  edm::LogError("InterestingDetIdCollectionProducerError") << "Size of eta/phi should be odd numbers";
37 
38  //register your products
39  produces< DetIdCollection > (interestingDetIdCollection_) ;
40 
41  severityLevel_ = iConfig.getParameter<int>("severityLevel");
42  keepNextToDead_ = iConfig.getParameter<bool>("keepNextToDead");
43  keepNextToBoundary_ = iConfig.getParameter<bool>("keepNextToBoundary");
44 }
T getParameter(std::string const &) const
edm::EDGetTokenT< EcalRecHitCollection > recHitsToken_
edm::EDGetTokenT< reco::BasicClusterCollection > basicClustersToken_

Member Function Documentation

void InterestingDetIdCollectionProducer::beginRun ( edm::Run const &  run,
const edm::EventSetup iSetup 
)
finaloverridevirtual

Definition at line 47 of file InterestingDetIdCollectionProducer.cc.

References caloTopology_, edm::EventSetup::get(), edm::ESHandle< T >::product(), and severity_.

48 {
49  edm::ESHandle<CaloTopology> theCaloTopology;
50  iSetup.get<CaloTopologyRecord>().get(theCaloTopology);
51  caloTopology_ = &(*theCaloTopology);
52 
54  iSetup.get<EcalSeverityLevelAlgoRcd>().get(sevLv);
55  severity_ = sevLv.product();
56 }
const T & get() const
Definition: EventSetup.h:56
T const * product() const
Definition: ESHandle.h:86
void InterestingDetIdCollectionProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overridevirtual

producer

Definition at line 60 of file InterestingDetIdCollectionProducer.cc.

References funct::abs(), basicClustersToken_, edm::SortedCollection< T, SORT >::begin(), caloTopology_, DetId::det(), EcalBarrel, EcalEndcap, photonPostprocessing_cfi::eMax, edm::SortedCollection< T, SORT >::end(), edm::SortedCollection< T, SORT >::find(), edm::Event::getByToken(), CaloTopology::getSubdetectorTopology(), CaloSubdetectorTopology::getWindow(), interestingDetIdCollection_, EcalTools::isNextToDead(), EEDetId::isNextToRingBoundary(), keepNextToBoundary_, keepNextToDead_, EcalRecHit::kTPSaturated, minimalEtaSize_, minimalPhiSize_, DetId::null(), edm::Event::put(), recHitsToken_, severity_, EcalSeverityLevelAlgo::severityLevel(), severityLevel_, DetId::subdetId(), ecaldqm::topology(), and tier0::unique().

62 {
63  using namespace edm;
64  using namespace std;
65 
66  // take BasicClusters
68  iEvent.getByToken(basicClustersToken_, pClusters);
69 
70  // take EcalRecHits
71  Handle<EcalRecHitCollection> recHitsHandle;
72  iEvent.getByToken(recHitsToken_,recHitsHandle);
73 
74  //Create empty output collections
75  std::vector<DetId> indexToStore;
76  indexToStore.reserve(1000);
77 
78  reco::BasicClusterCollection::const_iterator clusIt;
79 
80  std::vector<DetId> xtalsToStore;
81  xtalsToStore.reserve(50);
82  for (clusIt=pClusters->begin(); clusIt!=pClusters->end(); clusIt++) {
83  const std::vector<std::pair<DetId,float> > &clusterDetIds = clusIt->hitsAndFractions();
84  for (const auto &detidpair : clusterDetIds) {
85  indexToStore.push_back(detidpair.first);
86  }
87 
88  //below checks and additional code are only relevant for EB/EE, not for ES
89  if (clusterDetIds.front().first.subdetId()==EcalBarrel || clusterDetIds.front().first.subdetId()==EcalEndcap) {
90  std::vector<std::pair<DetId,float> >::const_iterator posCurrent;
91 
92  float eMax=0.;
93  DetId eMaxId(0);
94 
95  EcalRecHit testEcalRecHit;
96 
97  for(posCurrent = clusterDetIds.begin(); posCurrent != clusterDetIds.end(); posCurrent++)
98  {
99  EcalRecHitCollection::const_iterator itt = recHitsHandle->find((*posCurrent).first);
100  if ((!((*posCurrent).first.null())) && (itt != recHitsHandle->end()) && ((*itt).energy() > eMax) )
101  {
102  eMax = (*itt).energy();
103  eMaxId = (*itt).id();
104  }
105  }
106 
107  if (eMaxId.null())
108  continue;
109 
110  const CaloSubdetectorTopology* topology = caloTopology_->getSubdetectorTopology(eMaxId.det(),eMaxId.subdetId());
111 
112  xtalsToStore=topology->getWindow(eMaxId,minimalEtaSize_,minimalPhiSize_);
113 
114  for (const auto &detid : xtalsToStore) {
115  indexToStore.push_back(detid);
116  }
117 
118  }
119  }
120 
121 
123  for (EcalRecHitCollection::const_iterator it = recHitsHandle->begin(); it != recHitsHandle->end(); ++it) {
124  // also add recHits of dead TT if the corresponding TP is saturated
125  if ( it->checkFlag(EcalRecHit::kTPSaturated) ) {
126  indexToStore.push_back(it->id());
127  }
128  // add hits for severities above a threshold
129  if ( severityLevel_>=0 &&
131 
132  indexToStore.push_back(it->id());
133  }
134  if (keepNextToDead_) {
135  // also keep channels next to dead ones
136  if (EcalTools::isNextToDead(it->id(), iSetup)) {
137  indexToStore.push_back(it->id());
138  }
139  }
140 
141  if (keepNextToBoundary_){
142  // keep channels around EB/EE boundary
143  if (it->id().subdetId() == EcalBarrel){
144  EBDetId ebid(it->id());
145  if (abs(ebid.ieta())== 85)
146  indexToStore.push_back(it->id());
147  } else {
148 
149  if (EEDetId::isNextToRingBoundary(it->id()))
150  indexToStore.push_back(it->id());
151  }
152 
153  }
154 
155  }
156  }
157 
158  //unify the vector
159  std::sort(indexToStore.begin(),indexToStore.end());
160  std::unique(indexToStore.begin(),indexToStore.end());
161 
162 
163  iEvent.put(std::make_unique<DetIdCollection>(indexToStore), interestingDetIdCollection_);
164 
165 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
static bool isNextToDead(const DetId &id, const edm::EventSetup &es)
true if the channel is near a dead one (in the 3x3)
Definition: EcalTools.cc:52
EcalSeverityLevel::SeverityLevel severityLevel(const DetId &id) const
Evaluate status from id use channelStatus from DB.
CaloTopology const * topology(0)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
std::vector< EcalRecHit >::const_iterator const_iterator
def unique(seq, keepstr=True)
Definition: tier0.py:24
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
static bool isNextToRingBoundary(EEDetId id)
Definition: EEDetId.cc:375
edm::EDGetTokenT< EcalRecHitCollection > recHitsToken_
const_iterator end() const
Definition: DetId.h:18
virtual std::vector< DetId > getWindow(const DetId &id, const int &northSouthSize, const int &eastWestSize) const
const CaloSubdetectorTopology * getSubdetectorTopology(const DetId &id) const
access the subdetector Topology for the given subdetector directly
Definition: CaloTopology.cc:26
iterator find(key_type k)
HLT enums.
const_iterator begin() const
edm::EDGetTokenT< reco::BasicClusterCollection > basicClustersToken_

Member Data Documentation

edm::EDGetTokenT<reco::BasicClusterCollection> InterestingDetIdCollectionProducer::basicClustersToken_
private
const CaloTopology* InterestingDetIdCollectionProducer::caloTopology_
private

Definition at line 62 of file InterestingDetIdCollectionProducer.h.

Referenced by beginRun(), and produce().

std::string InterestingDetIdCollectionProducer::interestingDetIdCollection_
private
bool InterestingDetIdCollectionProducer::keepNextToBoundary_
private
bool InterestingDetIdCollectionProducer::keepNextToDead_
private
int InterestingDetIdCollectionProducer::minimalEtaSize_
private
int InterestingDetIdCollectionProducer::minimalPhiSize_
private
edm::EDGetTokenT<EcalRecHitCollection> InterestingDetIdCollectionProducer::recHitsToken_
private
const EcalSeverityLevelAlgo* InterestingDetIdCollectionProducer::severity_
private

Definition at line 65 of file InterestingDetIdCollectionProducer.h.

Referenced by beginRun(), and produce().

int InterestingDetIdCollectionProducer::severityLevel_
private