CMS 3D CMS Logo

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

#include <RecoLocalCalo/HcalHitSelection/src/HcalHitSelection.cc>

Inheritance diagram for HcalHitSelection:
edm::stream::EDProducer<>

Public Member Functions

 HcalHitSelection (const edm::ParameterSet &)
 
 ~HcalHitSelection () override
 
- 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 Member Functions

void produce (edm::Event &, const edm::EventSetup &) override
 
template<typename CollectionType >
void skim (const edm::Handle< CollectionType > &input, CollectionType &output, int severityThreshold=0) const
 

Private Attributes

edm::InputTag hbheTag
 
edm::InputTag hfTag
 
int hoSeverityLevel
 
edm::InputTag hoTag
 
edm::ESGetToken< HcalTopology, HcalRecNumberingRecordhtopoToken_
 
std::vector< edm::InputTaginterestingDetIdCollections
 
edm::ESGetToken< HcalChannelQuality, HcalChannelQualityRcdqualToken_
 
edm::ESGetToken< HcalSeverityLevelComputer, HcalSeverityLevelComputerRcdsevToken_
 
const HcalChannelQualitytheHcalChStatus
 
const HcalSeverityLevelComputertheHcalSevLvlComputer
 
const HcalTopologytheHcalTopology_
 
std::set< DetIdtoBeKept
 
edm::EDGetTokenT< HBHERecHitCollectiontok_hbhe_
 
edm::EDGetTokenT< HFRecHitCollectiontok_hf_
 
edm::EDGetTokenT< HORecHitCollectiontok_ho_
 
std::vector< edm::EDGetTokenT< DetIdCollection > > toks_did_
 

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

Description: [one line class summary]

Implementation: [Notes on implementation]

Definition at line 49 of file HcalHitSelection.cc.

Constructor & Destructor Documentation

◆ HcalHitSelection()

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

Definition at line 121 of file HcalHitSelection.cc.

References edm::ParameterSet::getParameter(), hbheTag, hfTag, hoSeverityLevel, hoTag, htopoToken_, mps_fire::i, interestingDetIdCollections, edm::InputTag::label(), qualToken_, sevToken_, tok_hbhe_, tok_hf_, tok_ho_, and toks_did_.

122  : hbheTag(iConfig.getParameter<edm::InputTag>("hbheTag")),
123  hoTag(iConfig.getParameter<edm::InputTag>("hoTag")),
124  hfTag(iConfig.getParameter<edm::InputTag>("hfTag")),
125  theHcalTopology_(nullptr),
126  theHcalChStatus(nullptr),
127  theHcalSevLvlComputer(nullptr) {
128  // register for data access
129  tok_hbhe_ = consumes<HBHERecHitCollection>(hbheTag);
130  tok_hf_ = consumes<HFRecHitCollection>(hfTag);
131  tok_ho_ = consumes<HORecHitCollection>(hoTag);
132 
133  interestingDetIdCollections = iConfig.getParameter<std::vector<edm::InputTag> >("interestingDetIds");
134 
135  const unsigned nLabels = interestingDetIdCollections.size();
136  for (unsigned i = 0; i != nLabels; i++)
137  toks_did_.push_back(consumes<DetIdCollection>(interestingDetIdCollections[i]));
138 
139  hoSeverityLevel = iConfig.getParameter<int>("hoSeverityLevel");
140 
141  produces<HBHERecHitCollection>(hbheTag.label());
142  produces<HFRecHitCollection>(hfTag.label());
143  produces<HORecHitCollection>(hoTag.label());
144 
145  // ES tokens
146  htopoToken_ = esConsumes<HcalTopology, HcalRecNumberingRecord>();
147  qualToken_ = esConsumes<HcalChannelQuality, HcalChannelQualityRcd>(edm::ESInputTag("", "withTopo"));
148  sevToken_ = esConsumes<HcalSeverityLevelComputer, HcalSeverityLevelComputerRcd>();
149 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::vector< edm::InputTag > interestingDetIdCollections
const HcalChannelQuality * theHcalChStatus
edm::EDGetTokenT< HORecHitCollection > tok_ho_
std::string const & label() const
Definition: InputTag.h:36
std::vector< edm::EDGetTokenT< DetIdCollection > > toks_did_
edm::ESGetToken< HcalChannelQuality, HcalChannelQualityRcd > qualToken_
edm::InputTag hoTag
edm::InputTag hfTag
const HcalSeverityLevelComputer * theHcalSevLvlComputer
edm::EDGetTokenT< HBHERecHitCollection > tok_hbhe_
edm::ESGetToken< HcalTopology, HcalRecNumberingRecord > htopoToken_
edm::EDGetTokenT< HFRecHitCollection > tok_hf_
const HcalTopology * theHcalTopology_
edm::InputTag hbheTag
edm::ESGetToken< HcalSeverityLevelComputer, HcalSeverityLevelComputerRcd > sevToken_

◆ ~HcalHitSelection()

HcalHitSelection::~HcalHitSelection ( )
override

Definition at line 151 of file HcalHitSelection.cc.

151  {
152  // do anything here that needs to be done at desctruction time
153  // (e.g. close files, deallocate resources etc.)
154 }

Member Function Documentation

◆ produce()

void HcalHitSelection::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 161 of file HcalHitSelection.cc.

References hcalRecHitTable_cff::detId, edm::EventSetup::getData(), photonIsolationHIProducer_cfi::hbhe, hbheTag, photonIsolationHIProducer_cfi::hf, hfTag, photonIsolationHIProducer_cfi::ho, hoSeverityLevel, hoTag, htopoToken_, iEvent, interestingDetIdCollections, edm::InputTag::label(), eostools::move(), qualToken_, sevToken_, skim(), submitPVValidationJobs::t, theHcalChStatus, theHcalSevLvlComputer, theHcalTopology_, toBeKept, tok_hbhe_, tok_hf_, tok_ho_, and toks_did_.

161  {
165 
169 
170  iEvent.getByToken(tok_hbhe_, hbhe);
171  iEvent.getByToken(tok_hf_, hf);
172  iEvent.getByToken(tok_ho_, ho);
173 
174  toBeKept.clear();
176  for (unsigned int t = 0; t < toks_did_.size(); ++t) {
177  iEvent.getByToken(toks_did_[t], detId);
178  if (!detId.isValid()) {
179  edm::LogError("MissingInput") << "the collection of interesting detIds:" << interestingDetIdCollections[t]
180  << " is not found.";
181  continue;
182  }
183  toBeKept.insert(detId->begin(), detId->end());
184  }
185 
186  auto hbhe_out = std::make_unique<HBHERecHitCollection>();
187  skim(hbhe, *hbhe_out);
188  iEvent.put(std::move(hbhe_out), hbheTag.label());
189 
190  auto hf_out = std::make_unique<HFRecHitCollection>();
191  skim(hf, *hf_out);
192  iEvent.put(std::move(hf_out), hfTag.label());
193 
194  auto ho_out = std::make_unique<HORecHitCollection>();
195  skim(ho, *ho_out, hoSeverityLevel);
196  iEvent.put(std::move(ho_out), hoTag.label());
197 }
void skim(const edm::Handle< CollectionType > &input, CollectionType &output, int severityThreshold=0) const
std::vector< edm::InputTag > interestingDetIdCollections
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
std::set< DetId > toBeKept
const HcalChannelQuality * theHcalChStatus
edm::EDGetTokenT< HORecHitCollection > tok_ho_
std::string const & label() const
Definition: InputTag.h:36
std::vector< edm::EDGetTokenT< DetIdCollection > > toks_did_
Log< level::Error, false > LogError
edm::ESGetToken< HcalChannelQuality, HcalChannelQualityRcd > qualToken_
edm::InputTag hoTag
edm::InputTag hfTag
const HcalSeverityLevelComputer * theHcalSevLvlComputer
int iEvent
Definition: GenABIO.cc:224
edm::EDGetTokenT< HBHERecHitCollection > tok_hbhe_
edm::ESGetToken< HcalTopology, HcalRecNumberingRecord > htopoToken_
edm::EDGetTokenT< HFRecHitCollection > tok_hf_
const HcalTopology * theHcalTopology_
edm::InputTag hbheTag
edm::ESGetToken< HcalSeverityLevelComputer, HcalSeverityLevelComputerRcd > sevToken_
def move(src, dest)
Definition: eostools.py:511

◆ skim()

template<class CollectionType >
void HcalHitSelection::skim ( const edm::Handle< CollectionType > &  input,
CollectionType &  output,
int  severityThreshold = 0 
) const
private

Definition at line 80 of file HcalHitSelection.cc.

References mps_fire::end, HcalTopology::getMergePositionFlag(), HcalSeverityLevelComputer::getSeverityLevel(), HcalChannelStatus::getValue(), HcalCondObjectContainer< Item >::getValues(), HcalEndcap, HcalTopology::idFront(), input, convertSQLitetoXML_cfg::output, interestingDetIdCollectionProducer_cfi::severityLevel, theHcalChStatus, theHcalSevLvlComputer, theHcalTopology_, and toBeKept.

Referenced by produce().

82  {
83  output.reserve(input->size());
84  typename CollectionType::const_iterator begin = input->begin();
85  typename CollectionType::const_iterator end = input->end();
86  typename CollectionType::const_iterator hit = begin;
87 
88  for (; hit != end; ++hit) {
89  // edm::LogError("HcalHitSelection")<<"the hit pointer is"<<&(*hit);
90  HcalDetId id = hit->detid();
91  if (theHcalTopology_->getMergePositionFlag() && id.subdet() == HcalEndcap) {
92  id = theHcalTopology_->idFront(id);
93  }
94  const uint32_t& recHitFlag = hit->flags();
95  // edm::LogError("HcalHitSelection")<<"the hit id and flag are "<<id.rawId()<<" "<<recHitFlag;
96 
97  const uint32_t& dbStatusFlag = theHcalChStatus->getValues(id)->getValue();
98  int severityLevel = theHcalSevLvlComputer->getSeverityLevel(id, recHitFlag, dbStatusFlag);
99  //anything that is not "good" goes in
100  if (severityLevel > severityThreshold) {
101  output.push_back(*hit);
102  } else {
103  //chek on the detid list
104  if (toBeKept.find(id) != toBeKept.end())
105  output.push_back(*hit);
106  }
107  }
108 }
bool getMergePositionFlag() const
Definition: HcalTopology.h:167
std::set< DetId > toBeKept
const HcalChannelQuality * theHcalChStatus
const Item * getValues(DetId fId, bool throwOnFail=true) const
static std::string const input
Definition: EdmProvDump.cc:50
const HcalSeverityLevelComputer * theHcalSevLvlComputer
HcalDetId idFront(const HcalDetId &id) const
Definition: HcalTopology.h:170
uint32_t getValue() const
const HcalTopology * theHcalTopology_
int getSeverityLevel(const DetId &myid, const uint32_t &myflag, const uint32_t &mystatus) const

Member Data Documentation

◆ hbheTag

edm::InputTag HcalHitSelection::hbheTag
private

Definition at line 57 of file HcalHitSelection.cc.

Referenced by HcalHitSelection(), and produce().

◆ hfTag

edm::InputTag HcalHitSelection::hfTag
private

Definition at line 57 of file HcalHitSelection.cc.

Referenced by HcalHitSelection(), and produce().

◆ hoSeverityLevel

int HcalHitSelection::hoSeverityLevel
private

Definition at line 62 of file HcalHitSelection.cc.

Referenced by HcalHitSelection(), and produce().

◆ hoTag

edm::InputTag HcalHitSelection::hoTag
private

Definition at line 57 of file HcalHitSelection.cc.

Referenced by HcalHitSelection(), and produce().

◆ htopoToken_

edm::ESGetToken<HcalTopology, HcalRecNumberingRecord> HcalHitSelection::htopoToken_
private

Definition at line 74 of file HcalHitSelection.cc.

Referenced by HcalHitSelection(), and produce().

◆ interestingDetIdCollections

std::vector<edm::InputTag> HcalHitSelection::interestingDetIdCollections
private

Definition at line 63 of file HcalHitSelection.cc.

Referenced by HcalHitSelection(), and produce().

◆ qualToken_

edm::ESGetToken<HcalChannelQuality, HcalChannelQualityRcd> HcalHitSelection::qualToken_
private

Definition at line 75 of file HcalHitSelection.cc.

Referenced by HcalHitSelection(), and produce().

◆ sevToken_

Definition at line 76 of file HcalHitSelection.cc.

Referenced by HcalHitSelection(), and produce().

◆ theHcalChStatus

const HcalChannelQuality* HcalHitSelection::theHcalChStatus
private

Definition at line 67 of file HcalHitSelection.cc.

Referenced by produce(), and skim().

◆ theHcalSevLvlComputer

const HcalSeverityLevelComputer* HcalHitSelection::theHcalSevLvlComputer
private

Definition at line 68 of file HcalHitSelection.cc.

Referenced by produce(), and skim().

◆ theHcalTopology_

const HcalTopology* HcalHitSelection::theHcalTopology_
private

Definition at line 64 of file HcalHitSelection.cc.

Referenced by produce(), and skim().

◆ toBeKept

std::set<DetId> HcalHitSelection::toBeKept
private

Definition at line 69 of file HcalHitSelection.cc.

Referenced by produce(), and skim().

◆ tok_hbhe_

edm::EDGetTokenT<HBHERecHitCollection> HcalHitSelection::tok_hbhe_
private

Definition at line 58 of file HcalHitSelection.cc.

Referenced by HcalHitSelection(), and produce().

◆ tok_hf_

edm::EDGetTokenT<HFRecHitCollection> HcalHitSelection::tok_hf_
private

Definition at line 60 of file HcalHitSelection.cc.

Referenced by HcalHitSelection(), and produce().

◆ tok_ho_

edm::EDGetTokenT<HORecHitCollection> HcalHitSelection::tok_ho_
private

Definition at line 59 of file HcalHitSelection.cc.

Referenced by HcalHitSelection(), and produce().

◆ toks_did_

std::vector<edm::EDGetTokenT<DetIdCollection> > HcalHitSelection::toks_did_
private

Definition at line 61 of file HcalHitSelection.cc.

Referenced by HcalHitSelection(), and produce().