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 hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () 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 50 of file HcalHitSelection.cc.

Constructor & Destructor Documentation

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

Definition at line 116 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_.

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

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

Member Function Documentation

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

Definition at line 157 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(), protons_cff::t, theHcalChStatus, theHcalSevLvlComputer, theHcalTopology_, toBeKept, tok_hbhe_, tok_hf_, tok_ho_, and toks_did_.

158 {
159  iSetup.get<HcalChannelQualityRcd>().get("withTopo", theHcalChStatus);
162  iSetup.get<HcalRecNumberingRecord>().get(topo);
163  theHcalTopology_ = topo.product();
164 
168 
169  iEvent.getByToken(tok_hbhe_,hbhe);
170  iEvent.getByToken(tok_hf_,hf);
171  iEvent.getByToken(tok_ho_,ho);
172 
173  toBeKept.clear();
175  for( unsigned int t = 0; t < toks_did_.size(); ++t )
176  {
177  iEvent.getByToken(toks_did_[t],detId);
178  if (!detId.isValid()){
179  edm::LogError("MissingInput")<<"the collection of interesting detIds:"<<interestingDetIdCollections[t]<<" is not found.";
180  continue;
181  }
182  toBeKept.insert(detId->begin(),detId->end());
183  }
184 
185  auto hbhe_out = std::make_unique<HBHERecHitCollection>();
186  skim(hbhe,*hbhe_out);
187  iEvent.put(std::move(hbhe_out),hbheTag.label());
188 
189  auto hf_out = std::make_unique<HFRecHitCollection>();
190  skim(hf,*hf_out);
191  iEvent.put(std::move(hf_out),hfTag.label());
192 
193  auto ho_out = std::make_unique<HORecHitCollection>();
194  skim(ho,*ho_out,hoSeverityLevel);
195  iEvent.put(std::move(ho_out),hoTag.label());
196 
197 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
std::vector< edm::InputTag > interestingDetIdCollections
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
std::set< DetId > toBeKept
const_iterator end() const
Definition: EDCollection.h:153
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:74
const_iterator begin() const
Definition: EDCollection.h:146
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:71
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 76 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().

76  {
77  output.reserve(input->size());
78  typename CollectionType::const_iterator begin=input->begin();
79  typename CollectionType::const_iterator end=input->end();
80  typename CollectionType::const_iterator hit=begin;
81 
82  for (;hit!=end;++hit){
83  // edm::LogError("HcalHitSelection")<<"the hit pointer is"<<&(*hit);
84  HcalDetId id = hit->detid();
85  if (theHcalTopology_->getMergePositionFlag() && id.subdet() == HcalEndcap) {
86  id = theHcalTopology_->idFront(id);
87  }
88  const uint32_t & recHitFlag = hit->flags();
89  // edm::LogError("HcalHitSelection")<<"the hit id and flag are "<<id.rawId()<<" "<<recHitFlag;
90 
91  const uint32_t & dbStatusFlag = theHcalChStatus->getValues(id)->getValue();
92  int severityLevel = theHcalSevLvlComputer->getSeverityLevel(id, recHitFlag, dbStatusFlag);
93  //anything that is not "good" goes in
94  if (severityLevel>severityThreshold){
95  output.push_back(*hit);
96  }else{
97  //chek on the detid list
98  if (toBeKept.find(id)!=toBeKept.end())
99  output.push_back(*hit);
100  }
101  }
102 }
std::set< DetId > toBeKept
edm::ESHandle< HcalChannelQuality > theHcalChStatus
const Item * getValues(DetId fId, bool throwOnFail=true) const
bool getMergePositionFlag() const
Definition: HcalTopology.h:171
#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:177
uint32_t getValue() const

Member Data Documentation

edm::InputTag HcalHitSelection::hbheTag
private

Definition at line 58 of file HcalHitSelection.cc.

Referenced by HcalHitSelection(), and produce().

edm::InputTag HcalHitSelection::hfTag
private

Definition at line 58 of file HcalHitSelection.cc.

Referenced by HcalHitSelection(), and produce().

int HcalHitSelection::hoSeverityLevel
private

Definition at line 63 of file HcalHitSelection.cc.

Referenced by HcalHitSelection(), and produce().

edm::InputTag HcalHitSelection::hoTag
private

Definition at line 58 of file HcalHitSelection.cc.

Referenced by HcalHitSelection(), and produce().

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

Definition at line 64 of file HcalHitSelection.cc.

Referenced by HcalHitSelection(), and produce().

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

Definition at line 68 of file HcalHitSelection.cc.

Referenced by produce(), and skim().

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

Definition at line 69 of file HcalHitSelection.cc.

Referenced by produce(), and skim().

const HcalTopology* HcalHitSelection::theHcalTopology_
private

Definition at line 65 of file HcalHitSelection.cc.

Referenced by produce(), and skim().

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

Definition at line 70 of file HcalHitSelection.cc.

Referenced by produce(), and skim().

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

Definition at line 59 of file HcalHitSelection.cc.

Referenced by HcalHitSelection(), and produce().

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

Definition at line 61 of file HcalHitSelection.cc.

Referenced by HcalHitSelection(), and produce().

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

Definition at line 60 of file HcalHitSelection.cc.

Referenced by HcalHitSelection(), and produce().

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

Definition at line 62 of file HcalHitSelection.cc.

Referenced by HcalHitSelection(), and produce().