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 ( const edm::ParameterSet iConfig)
explicit

Definition at line 118 of file HcalHitSelection.cc.

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

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 }
T getParameter(std::string const &) const
std::vector< edm::InputTag > interestingDetIdCollections
edm::EDGetTokenT< HORecHitCollection > tok_ho_
std::vector< edm::EDGetTokenT< DetIdCollection > > toks_did_
edm::InputTag hoTag
edm::InputTag hfTag
edm::EDGetTokenT< HBHERecHitCollection > tok_hbhe_
edm::EDGetTokenT< HFRecHitCollection > tok_hf_
std::string const & label() const
Definition: InputTag.h:36
edm::InputTag hbheTag
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

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

Definition at line 151 of file HcalHitSelection.cc.

References edm::EDCollection< T >::begin(), DEFINE_FWK_MODULE, edm::EDCollection< T >::end(), edm::EventSetup::get(), edm::Event::getByToken(), photonIsolationHIProducer_cfi::hbhe, hbheTag, photonIsolationHIProducer_cfi::hf, hfTag, photonIsolationHIProducer_cfi::ho, hoSeverityLevel, hoTag, interestingDetIdCollections, edm::HandleBase::isValid(), edm::InputTag::label(), eostools::move(), edm::ESHandle< T >::product(), edm::Event::put(), skim(), OrderedSet::t, theHcalChStatus, theHcalSevLvlComputer, theHcalTopology_, toBeKept, tok_hbhe_, tok_hf_, tok_ho_, and toks_did_.

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 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
std::vector< edm::InputTag > interestingDetIdCollections
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
std::set< DetId > toBeKept
const_iterator end() const
Definition: EDCollection.h:122
edm::ESHandle< HcalChannelQuality > theHcalChStatus
edm::EDGetTokenT< HORecHitCollection > tok_ho_
std::vector< edm::EDGetTokenT< DetIdCollection > > toks_did_
edm::InputTag hoTag
edm::InputTag hfTag
edm::EDGetTokenT< HBHERecHitCollection > tok_hbhe_
void skim(const edm::Handle< CollectionType > &input, CollectionType &output, int severityThreshold=0) const
bool isValid() const
Definition: HandleBase.h:70
const_iterator begin() const
Definition: EDCollection.h:117
edm::EDGetTokenT< HFRecHitCollection > tok_hf_
const HcalTopology * theHcalTopology_
std::string const & label() const
Definition: InputTag.h:36
edm::ESHandle< HcalSeverityLevelComputer > theHcalSevLvlComputer
T get() const
Definition: EventSetup.h:73
edm::InputTag hbheTag
T const * product() const
Definition: ESHandle.h:86
def move(src, dest)
Definition: eostools.py:511
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.

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

Referenced by produce().

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 }
std::set< DetId > toBeKept
edm::ESHandle< HcalChannelQuality > theHcalChStatus
const Item * getValues(DetId fId, bool throwOnFail=true) const
bool getMergePositionFlag() const
Definition: HcalTopology.h:167
#define end
Definition: vmac.h:39
int getSeverityLevel(const DetId &myid, const uint32_t &myflag, const uint32_t &mystatus) const
const HcalTopology * theHcalTopology_
edm::ESHandle< HcalSeverityLevelComputer > theHcalSevLvlComputer
#define begin
Definition: vmac.h:32
HcalDetId idFront(const HcalDetId &id) const
Definition: HcalTopology.h:170
uint32_t getValue() const

Member Data Documentation

edm::InputTag HcalHitSelection::hbheTag
private

Definition at line 57 of file HcalHitSelection.cc.

Referenced by HcalHitSelection(), and produce().

edm::InputTag HcalHitSelection::hfTag
private

Definition at line 57 of file HcalHitSelection.cc.

Referenced by HcalHitSelection(), and produce().

int HcalHitSelection::hoSeverityLevel
private

Definition at line 62 of file HcalHitSelection.cc.

Referenced by HcalHitSelection(), and produce().

edm::InputTag HcalHitSelection::hoTag
private

Definition at line 57 of file HcalHitSelection.cc.

Referenced by HcalHitSelection(), and produce().

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

Definition at line 63 of file HcalHitSelection.cc.

Referenced by HcalHitSelection(), and produce().

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

Definition at line 67 of file HcalHitSelection.cc.

Referenced by produce(), and skim().

edm::ESHandle<HcalSeverityLevelComputer> HcalHitSelection::theHcalSevLvlComputer
private

Definition at line 68 of file HcalHitSelection.cc.

Referenced by produce(), and skim().

const HcalTopology* HcalHitSelection::theHcalTopology_
private

Definition at line 64 of file HcalHitSelection.cc.

Referenced by produce(), and skim().

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

Definition at line 69 of file HcalHitSelection.cc.

Referenced by produce(), and skim().

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

Definition at line 58 of file HcalHitSelection.cc.

Referenced by HcalHitSelection(), and produce().

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

Definition at line 60 of file HcalHitSelection.cc.

Referenced by HcalHitSelection(), and produce().

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

Definition at line 59 of file HcalHitSelection.cc.

Referenced by HcalHitSelection(), and produce().

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

Definition at line 61 of file HcalHitSelection.cc.

Referenced by HcalHitSelection(), and produce().