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 hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () 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
 
std::vector< edm::InputTaginterestingDetIdCollections
 
edm::ESHandle< HcalChannelQualitytheHcalChStatus
 
edm::ESHandle< 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 118 of file HcalHitSelection.cc.

118  {
119  hbheTag = iConfig.getParameter<edm::InputTag>("hbheTag");
120  hfTag = iConfig.getParameter<edm::InputTag>("hfTag");
121  hoTag = iConfig.getParameter<edm::InputTag>("hoTag");
122 
123  // register for data access
124  tok_hbhe_ = consumes<HBHERecHitCollection>(hbheTag);
125  tok_hf_ = consumes<HFRecHitCollection>(hfTag);
126  tok_ho_ = consumes<HORecHitCollection>(hoTag);
127 
128  interestingDetIdCollections = iConfig.getParameter<std::vector<edm::InputTag> >("interestingDetIds");
129 
130  const unsigned nLabels = interestingDetIdCollections.size();
131  for (unsigned i = 0; i != nLabels; i++)
132  toks_did_.push_back(consumes<DetIdCollection>(interestingDetIdCollections[i]));
133 
134  hoSeverityLevel = iConfig.getParameter<int>("hoSeverityLevel");
135 
136  produces<HBHERecHitCollection>(hbheTag.label());
137  produces<HFRecHitCollection>(hfTag.label());
138  produces<HORecHitCollection>(hoTag.label());
139 }

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

◆ ~HcalHitSelection()

HcalHitSelection::~HcalHitSelection ( )
override

Definition at line 141 of file HcalHitSelection.cc.

141  {
142  // do anything here that needs to be done at desctruction time
143  // (e.g. close files, deallocate resources etc.)
144 }

Member Function Documentation

◆ produce()

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

Definition at line 151 of file HcalHitSelection.cc.

151  {
152  iSetup.get<HcalChannelQualityRcd>().get("withTopo", theHcalChStatus);
155  iSetup.get<HcalRecNumberingRecord>().get(topo);
156  theHcalTopology_ = topo.product();
157 
161 
162  iEvent.getByToken(tok_hbhe_, hbhe);
163  iEvent.getByToken(tok_hf_, hf);
164  iEvent.getByToken(tok_ho_, ho);
165 
166  toBeKept.clear();
168  for (unsigned int t = 0; t < toks_did_.size(); ++t) {
169  iEvent.getByToken(toks_did_[t], detId);
170  if (!detId.isValid()) {
171  edm::LogError("MissingInput") << "the collection of interesting detIds:" << interestingDetIdCollections[t]
172  << " is not found.";
173  continue;
174  }
175  toBeKept.insert(detId->begin(), detId->end());
176  }
177 
178  auto hbhe_out = std::make_unique<HBHERecHitCollection>();
179  skim(hbhe, *hbhe_out);
180  iEvent.put(std::move(hbhe_out), hbheTag.label());
181 
182  auto hf_out = std::make_unique<HFRecHitCollection>();
183  skim(hf, *hf_out);
184  iEvent.put(std::move(hf_out), hfTag.label());
185 
186  auto ho_out = std::make_unique<HORecHitCollection>();
187  skim(ho, *ho_out, hoSeverityLevel);
188  iEvent.put(std::move(ho_out), hoTag.label());
189 }

References edm::EDCollection< T >::begin(), edm::EDCollection< T >::end(), edm::EventSetup::get(), get, photonIsolationHIProducer_cfi::hbhe, hbheTag, photonIsolationHIProducer_cfi::hf, hfTag, photonIsolationHIProducer_cfi::ho, hoSeverityLevel, hoTag, iEvent, interestingDetIdCollections, edm::HandleBase::isValid(), edm::InputTag::label(), eostools::move(), edm::ESHandle< T >::product(), skim(), OrderedSet::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 77 of file HcalHitSelection.cc.

79  {
80  output.reserve(input->size());
81  typename CollectionType::const_iterator begin = input->begin();
82  typename CollectionType::const_iterator end = input->end();
83  typename CollectionType::const_iterator hit = begin;
84 
85  for (; hit != end; ++hit) {
86  // edm::LogError("HcalHitSelection")<<"the hit pointer is"<<&(*hit);
87  HcalDetId id = hit->detid();
88  if (theHcalTopology_->getMergePositionFlag() && id.subdet() == HcalEndcap) {
89  id = theHcalTopology_->idFront(id);
90  }
91  const uint32_t& recHitFlag = hit->flags();
92  // edm::LogError("HcalHitSelection")<<"the hit id and flag are "<<id.rawId()<<" "<<recHitFlag;
93 
94  const uint32_t& dbStatusFlag = theHcalChStatus->getValues(id)->getValue();
95  int severityLevel = theHcalSevLvlComputer->getSeverityLevel(id, recHitFlag, dbStatusFlag);
96  //anything that is not "good" goes in
97  if (severityLevel > severityThreshold) {
98  output.push_back(*hit);
99  } else {
100  //chek on the detid list
101  if (toBeKept.find(id) != toBeKept.end())
102  output.push_back(*hit);
103  }
104  }
105 }

References begin, 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().

◆ interestingDetIdCollections

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

Definition at line 63 of file HcalHitSelection.cc.

Referenced by HcalHitSelection(), and produce().

◆ theHcalChStatus

edm::ESHandle<HcalChannelQuality> HcalHitSelection::theHcalChStatus
private

Definition at line 67 of file HcalHitSelection.cc.

Referenced by produce(), and skim().

◆ theHcalSevLvlComputer

edm::ESHandle<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().

edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
edm::EDCollection::begin
const_iterator begin() const
Definition: EDCollection.h:117
mps_fire.i
i
Definition: mps_fire.py:355
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:32
HcalChannelQualityRcd
Definition: HcalChannelQualityRcd.h:8
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
end
#define end
Definition: vmac.h:39
edm::InputTag::label
std::string const & label() const
Definition: InputTag.h:36
photonIsolationHIProducer_cfi.hf
hf
Definition: photonIsolationHIProducer_cfi.py:9
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
HcalHitSelection::theHcalTopology_
const HcalTopology * theHcalTopology_
Definition: HcalHitSelection.cc:64
edm::ESHandle< HcalTopology >
HcalHitSelection::theHcalSevLvlComputer
edm::ESHandle< HcalSeverityLevelComputer > theHcalSevLvlComputer
Definition: HcalHitSelection.cc:68
OrderedSet.t
t
Definition: OrderedSet.py:90
HcalRecNumberingRecord
Definition: HcalRecNumberingRecord.h:23
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:77
edm::LogError
Definition: MessageLogger.h:183
HcalDetId
Definition: HcalDetId.h:12
iEvent
int iEvent
Definition: GenABIO.cc:224
photonIsolationHIProducer_cfi.ho
ho
Definition: photonIsolationHIProducer_cfi.py:10
HcalHitSelection::theHcalChStatus
edm::ESHandle< HcalChannelQuality > theHcalChStatus
Definition: HcalHitSelection.cc:67
HcalHitSelection::hoTag
edm::InputTag hoTag
Definition: HcalHitSelection.cc:57
HcalHitSelection::hfTag
edm::InputTag hfTag
Definition: HcalHitSelection.cc:57
get
#define get
HcalHitSelection::toBeKept
std::set< DetId > toBeKept
Definition: HcalHitSelection.cc:69
photonIsolationHIProducer_cfi.hbhe
hbhe
Definition: photonIsolationHIProducer_cfi.py:8
HcalHitSelection::hoSeverityLevel
int hoSeverityLevel
Definition: HcalHitSelection.cc:62
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
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
HcalHitSelection::tok_hbhe_
edm::EDGetTokenT< HBHERecHitCollection > tok_hbhe_
Definition: HcalHitSelection.cc:58
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
HcalHitSelection::toks_did_
std::vector< edm::EDGetTokenT< DetIdCollection > > toks_did_
Definition: HcalHitSelection.cc:61
edm::InputTag
Definition: InputTag.h:15
begin
#define begin
Definition: vmac.h:32
edm::EDCollection::end
const_iterator end() const
Definition: EDCollection.h:122
HcalSeverityLevelComputerRcd
Definition: HcalSeverityLevelComputerRcd.h:23
hit
Definition: SiStripHitEffFromCalibTree.cc:88