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
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

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<>
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

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.

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 }

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_.

◆ ~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.

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 }

References edm::EDCollection< T >::begin(), edm::EDCollection< T >::end(), edm::EventSetup::getData(), photonIsolationHIProducer_cfi::hbhe, hbheTag, photonIsolationHIProducer_cfi::hf, hfTag, photonIsolationHIProducer_cfi::ho, hoSeverityLevel, hoTag, htopoToken_, iEvent, interestingDetIdCollections, edm::HandleBase::isValid(), edm::InputTag::label(), eostools::move(), qualToken_, sevToken_, skim(), submitPVValidationJobs::t, theHcalChStatus, theHcalSevLvlComputer, theHcalTopology_, toBeKept, tok_hbhe_, tok_hf_, tok_ho_, and toks_did_.

◆ 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.

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 }

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

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

HcalHitSelection::htopoToken_
edm::ESGetToken< HcalTopology, HcalRecNumberingRecord > htopoToken_
Definition: HcalHitSelection.cc:74
edm::EDCollection::begin
const_iterator begin() const
Definition: EDCollection.h:117
mps_fire.i
i
Definition: mps_fire.py:428
edm::ESInputTag
Definition: ESInputTag.h:87
input
static const std::string input
Definition: EdmProvDump.cc:48
HcalTopology::idFront
HcalDetId idFront(const HcalDetId &id) const
Definition: HcalTopology.h:170
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:72
HcalHitSelection::tok_hf_
edm::EDGetTokenT< HFRecHitCollection > tok_hf_
Definition: HcalHitSelection.cc:60
HcalTopology::getMergePositionFlag
bool getMergePositionFlag() const
Definition: HcalTopology.h:167
edm::Handle
Definition: AssociativeIterator.h:50
HcalCondObjectContainer::getValues
const Item * getValues(DetId fId, bool throwOnFail=true) const
Definition: HcalCondObjectContainer.h:159
edm::InputTag::label
std::string const & label() const
Definition: InputTag.h:36
photonIsolationHIProducer_cfi.hf
hf
Definition: photonIsolationHIProducer_cfi.py:9
HcalHitSelection::theHcalTopology_
const HcalTopology * theHcalTopology_
Definition: HcalHitSelection.cc:64
mps_fire.end
end
Definition: mps_fire.py:242
HcalHitSelection::hbheTag
edm::InputTag hbheTag
Definition: HcalHitSelection.cc:57
HcalHitSelection::interestingDetIdCollections
std::vector< edm::InputTag > interestingDetIdCollections
Definition: HcalHitSelection.cc:63
HcalSeverityLevelComputer::getSeverityLevel
int getSeverityLevel(const DetId &myid, const uint32_t &myflag, const uint32_t &mystatus) const
Definition: HcalSeverityLevelComputer.cc:304
HcalChannelStatus::getValue
uint32_t getValue() const
Definition: HcalChannelStatus.h:60
HcalHitSelection::skim
void skim(const edm::Handle< CollectionType > &input, CollectionType &output, int severityThreshold=0) const
Definition: HcalHitSelection.cc:80
HcalHitSelection::sevToken_
edm::ESGetToken< HcalSeverityLevelComputer, HcalSeverityLevelComputerRcd > sevToken_
Definition: HcalHitSelection.cc:76
HcalDetId
Definition: HcalDetId.h:12
iEvent
int iEvent
Definition: GenABIO.cc:224
photonIsolationHIProducer_cfi.ho
ho
Definition: photonIsolationHIProducer_cfi.py:10
HcalHitSelection::hoTag
edm::InputTag hoTag
Definition: HcalHitSelection.cc:57
HcalHitSelection::hfTag
edm::InputTag hfTag
Definition: HcalHitSelection.cc:57
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
HcalHitSelection::theHcalChStatus
const HcalChannelQuality * theHcalChStatus
Definition: HcalHitSelection.cc:67
HcalHitSelection::toBeKept
std::set< DetId > toBeKept
Definition: HcalHitSelection.cc:69
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:120
photonIsolationHIProducer_cfi.hbhe
hbhe
Definition: photonIsolationHIProducer_cfi.py:8
HcalHitSelection::hoSeverityLevel
int hoSeverityLevel
Definition: HcalHitSelection.cc:62
HcalHitSelection::qualToken_
edm::ESGetToken< HcalChannelQuality, HcalChannelQualityRcd > qualToken_
Definition: HcalHitSelection.cc:75
eostools.move
def move(src, dest)
Definition: eostools.py:511
HcalHitSelection::tok_ho_
edm::EDGetTokenT< HORecHitCollection > tok_ho_
Definition: HcalHitSelection.cc:59
interestingDetIdCollectionProducer_cfi.severityLevel
severityLevel
Definition: interestingDetIdCollectionProducer_cfi.py:10
HcalEndcap
Definition: HcalAssistant.h:34
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
HcalHitSelection::theHcalSevLvlComputer
const HcalSeverityLevelComputer * theHcalSevLvlComputer
Definition: HcalHitSelection.cc:68
HcalHitSelection::tok_hbhe_
edm::EDGetTokenT< HBHERecHitCollection > tok_hbhe_
Definition: HcalHitSelection.cc:58
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
submitPVValidationJobs.t
string t
Definition: submitPVValidationJobs.py:644
HcalHitSelection::toks_did_
std::vector< edm::EDGetTokenT< DetIdCollection > > toks_did_
Definition: HcalHitSelection.cc:61
edm::InputTag
Definition: InputTag.h:15
edm::EDCollection::end
const_iterator end() const
Definition: EDCollection.h:122
hit
Definition: SiStripHitEffFromCalibTree.cc:88