CMS 3D CMS Logo

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

Public Member Functions

void beginRun (edm::Run const &, const edm::EventSetup &) final
 
 InterestingDetIdCollectionProducer (const edm::ParameterSet &)
 ctor More...
 
void produce (edm::Event &, const edm::EventSetup &) override
 producer More...
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Private Attributes

edm::EDGetTokenT< reco::BasicClusterCollectionbasicClustersToken_
 
const CaloTopologycaloTopology_
 
edm::ESGetToken< CaloTopology, CaloTopologyRecordcaloTopologyToken_
 
std::string interestingDetIdCollection_
 
bool keepNextToBoundary_
 
bool keepNextToDead_
 
int minimalEtaSize_
 
int minimalPhiSize_
 
edm::ESGetToken< EcalNextToDeadChannel, EcalNextToDeadChannelRcdnextToDeadToken_
 
edm::EDGetTokenT< EcalRecHitCollectionrecHitsToken_
 
const EcalSeverityLevelAlgoseverity_
 
int severityLevel_
 
edm::ESGetToken< EcalSeverityLevelAlgo, EcalSeverityLevelAlgoRcdsevLVToken_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

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 50 of file InterestingDetIdCollectionProducer.cc.

Constructor & Destructor Documentation

◆ InterestingDetIdCollectionProducer()

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

ctor

Definition at line 80 of file InterestingDetIdCollectionProducer.cc.

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

80  {
81  recHitsToken_ = consumes<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>("recHitsLabel"));
83  consumes<reco::BasicClusterCollection>(iConfig.getParameter<edm::InputTag>("basicClustersLabel"));
84  caloTopologyToken_ = esConsumes<CaloTopology, CaloTopologyRecord, edm::Transition::BeginRun>();
85  sevLVToken_ = esConsumes<EcalSeverityLevelAlgo, EcalSeverityLevelAlgoRcd, edm::Transition::BeginRun>();
86  nextToDeadToken_ = esConsumes<EcalNextToDeadChannel, EcalNextToDeadChannelRcd>();
87 
88  interestingDetIdCollection_ = iConfig.getParameter<std::string>("interestingDetIdCollection");
89 
90  minimalEtaSize_ = iConfig.getParameter<int>("etaSize");
91  minimalPhiSize_ = iConfig.getParameter<int>("phiSize");
92  if (minimalPhiSize_ % 2 == 0 || minimalEtaSize_ % 2 == 0)
93  edm::LogError("InterestingDetIdCollectionProducerError") << "Size of eta/phi should be odd numbers";
94 
95  //register your products
96  produces<DetIdCollection>(interestingDetIdCollection_);
97 
98  severityLevel_ = iConfig.getParameter<int>("severityLevel");
99  keepNextToDead_ = iConfig.getParameter<bool>("keepNextToDead");
100  keepNextToBoundary_ = iConfig.getParameter<bool>("keepNextToBoundary");
101 }
edm::ESGetToken< EcalNextToDeadChannel, EcalNextToDeadChannelRcd > nextToDeadToken_
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
Log< level::Error, false > LogError
edm::EDGetTokenT< EcalRecHitCollection > recHitsToken_
edm::ESGetToken< EcalSeverityLevelAlgo, EcalSeverityLevelAlgoRcd > sevLVToken_
edm::EDGetTokenT< reco::BasicClusterCollection > basicClustersToken_
edm::ESGetToken< CaloTopology, CaloTopologyRecord > caloTopologyToken_

Member Function Documentation

◆ beginRun()

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

Definition at line 103 of file InterestingDetIdCollectionProducer.cc.

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

103  {
104  edm::ESHandle<CaloTopology> theCaloTopology = iSetup.getHandle(caloTopologyToken_);
105  caloTopology_ = &(*theCaloTopology);
106 
108  severity_ = sevLv.product();
109 }
T const * product() const
Definition: ESHandle.h:86
edm::ESGetToken< EcalSeverityLevelAlgo, EcalSeverityLevelAlgoRcd > sevLVToken_
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:130
edm::ESGetToken< CaloTopology, CaloTopologyRecord > caloTopologyToken_

◆ produce()

void InterestingDetIdCollectionProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
override

producer

Definition at line 112 of file InterestingDetIdCollectionProducer.cc.

References funct::abs(), basicClustersToken_, edm::SortedCollection< T, SORT >::begin(), caloTopology_, DetId::det(), EcalBarrel, EcalEndcap, cosmicPhotonAnalyzer_cfi::eMax, edm::SortedCollection< T, SORT >::end(), edm::SortedCollection< T, SORT >::find(), edm::EventSetup::getHandle(), CaloTopology::getSubdetectorTopology(), iEvent, interestingDetIdCollection_, EcalTools::isNextToDead(), EEDetId::isNextToRingBoundary(), keepNextToBoundary_, keepNextToDead_, EcalRecHit::kTPSaturated, minimalEtaSize_, minimalPhiSize_, nextToDeadToken_, DetId::null(), recHitsToken_, severity_, EcalSeverityLevelAlgo::severityLevel(), severityLevel_, jetUpdater_cfi::sort, DetId::subdetId(), pfClusterHBHEAlpaka_cff::topology, and tier0::unique().

112  {
113  using namespace edm;
114  using namespace std;
115 
116  // take BasicClusters
118  iEvent.getByToken(basicClustersToken_, pClusters);
119 
120  // take EcalRecHits
121  Handle<EcalRecHitCollection> recHitsHandle;
122  iEvent.getByToken(recHitsToken_, recHitsHandle);
123 
124  //Create empty output collections
125  std::vector<DetId> indexToStore;
126  indexToStore.reserve(1000);
127 
128  reco::BasicClusterCollection::const_iterator clusIt;
129 
130  std::vector<DetId> xtalsToStore;
131  xtalsToStore.reserve(50);
132  for (clusIt = pClusters->begin(); clusIt != pClusters->end(); clusIt++) {
133  const std::vector<std::pair<DetId, float> >& clusterDetIds = clusIt->hitsAndFractions();
134  for (const auto& detidpair : clusterDetIds) {
135  indexToStore.push_back(detidpair.first);
136  }
137 
138  //below checks and additional code are only relevant for EB/EE, not for ES
139  if (clusterDetIds.front().first.subdetId() == EcalBarrel || clusterDetIds.front().first.subdetId() == EcalEndcap) {
140  std::vector<std::pair<DetId, float> >::const_iterator posCurrent;
141 
142  float eMax = 0.;
143  DetId eMaxId(0);
144 
145  EcalRecHit testEcalRecHit;
146 
147  for (posCurrent = clusterDetIds.begin(); posCurrent != clusterDetIds.end(); posCurrent++) {
148  EcalRecHitCollection::const_iterator itt = recHitsHandle->find((*posCurrent).first);
149  if ((!((*posCurrent).first.null())) && (itt != recHitsHandle->end()) && ((*itt).energy() > eMax)) {
150  eMax = (*itt).energy();
151  eMaxId = (*itt).id();
152  }
153  }
154 
155  if (eMaxId.null())
156  continue;
157 
158  const CaloSubdetectorTopology* topology = caloTopology_->getSubdetectorTopology(eMaxId.det(), eMaxId.subdetId());
159 
160  xtalsToStore = topology->getWindow(eMaxId, minimalEtaSize_, minimalPhiSize_);
161 
162  for (const auto& detid : xtalsToStore) {
163  indexToStore.push_back(detid);
164  }
165  }
166  }
167 
169  for (EcalRecHitCollection::const_iterator it = recHitsHandle->begin(); it != recHitsHandle->end(); ++it) {
170  // also add recHits of dead TT if the corresponding TP is saturated
171  if (it->checkFlag(EcalRecHit::kTPSaturated)) {
172  indexToStore.push_back(it->id());
173  }
174  // add hits for severities above a threshold
175  if (severityLevel_ >= 0 && severity_->severityLevel(*it) >= severityLevel_) {
176  indexToStore.push_back(it->id());
177  }
178  if (keepNextToDead_) {
180  // also keep channels next to dead ones
181  if (EcalTools::isNextToDead(it->id(), *dch)) {
182  indexToStore.push_back(it->id());
183  }
184  }
185 
186  if (keepNextToBoundary_) {
187  // keep channels around EB/EE boundary
188  if (it->id().subdetId() == EcalBarrel) {
189  EBDetId ebid(it->id());
190  if (abs(ebid.ieta()) == 85)
191  indexToStore.push_back(it->id());
192  } else {
193  if (EEDetId::isNextToRingBoundary(it->id()))
194  indexToStore.push_back(it->id());
195  }
196  }
197  }
198  }
199 
200  //unify the vector
201  std::sort(indexToStore.begin(), indexToStore.end());
202  std::unique(indexToStore.begin(), indexToStore.end());
203 
204  iEvent.put(std::make_unique<DetIdCollection>(indexToStore), interestingDetIdCollection_);
205 }
edm::ESGetToken< EcalNextToDeadChannel, EcalNextToDeadChannelRcd > nextToDeadToken_
std::vector< EcalRecHit >::const_iterator const_iterator
EcalSeverityLevel::SeverityLevel severityLevel(const DetId &id) const
Evaluate status from id use channelStatus from DB.
int iEvent
Definition: GenABIO.cc:224
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:284
edm::EDGetTokenT< EcalRecHitCollection > recHitsToken_
const_iterator begin() const
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:130
const_iterator end() const
static bool isNextToDead(const DetId &id, const EcalNextToDeadChannel &es)
true if the channel is near a dead one (in the 3x3)
Definition: EcalTools.cc:54
Definition: DetId.h:17
const CaloSubdetectorTopology * getSubdetectorTopology(const DetId &id) const
access the subdetector Topology for the given subdetector directly
Definition: CaloTopology.cc:17
iterator find(key_type k)
HLT enums.
edm::EDGetTokenT< reco::BasicClusterCollection > basicClustersToken_

Member Data Documentation

◆ basicClustersToken_

edm::EDGetTokenT<reco::BasicClusterCollection> InterestingDetIdCollectionProducer::basicClustersToken_
private

◆ caloTopology_

const CaloTopology* InterestingDetIdCollectionProducer::caloTopology_
private

Definition at line 69 of file InterestingDetIdCollectionProducer.cc.

Referenced by beginRun(), and produce().

◆ caloTopologyToken_

edm::ESGetToken<CaloTopology, CaloTopologyRecord> InterestingDetIdCollectionProducer::caloTopologyToken_
private

◆ interestingDetIdCollection_

std::string InterestingDetIdCollectionProducer::interestingDetIdCollection_
private

◆ keepNextToBoundary_

bool InterestingDetIdCollectionProducer::keepNextToBoundary_
private

◆ keepNextToDead_

bool InterestingDetIdCollectionProducer::keepNextToDead_
private

◆ minimalEtaSize_

int InterestingDetIdCollectionProducer::minimalEtaSize_
private

◆ minimalPhiSize_

int InterestingDetIdCollectionProducer::minimalPhiSize_
private

◆ nextToDeadToken_

edm::ESGetToken<EcalNextToDeadChannel, EcalNextToDeadChannelRcd> InterestingDetIdCollectionProducer::nextToDeadToken_
private

◆ recHitsToken_

edm::EDGetTokenT<EcalRecHitCollection> InterestingDetIdCollectionProducer::recHitsToken_
private

◆ severity_

const EcalSeverityLevelAlgo* InterestingDetIdCollectionProducer::severity_
private

Definition at line 72 of file InterestingDetIdCollectionProducer.cc.

Referenced by beginRun(), and produce().

◆ severityLevel_

int InterestingDetIdCollectionProducer::severityLevel_
private

◆ sevLVToken_

edm::ESGetToken<EcalSeverityLevelAlgo, EcalSeverityLevelAlgoRcd> InterestingDetIdCollectionProducer::sevLVToken_
private