CMS 3D CMS Logo

HcalHitSelection.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: HcalHitSelection
4 // Class: HcalHitSelection
5 //
13 //
14 // Original Author: Jean-Roch Vlimant,40 3-A28,+41227671209,
15 // Created: Thu Nov 4 22:17:56 CET 2010
16 //
17 //
18 
19 // system include files
20 #include <memory>
21 
22 // user include files
25 
28 
30 
38 
41 
44 
45 //
46 // class declaration
47 //
48 
50 public:
51  explicit HcalHitSelection(const edm::ParameterSet&);
52  ~HcalHitSelection() override;
53 
54 private:
55  void produce(edm::Event&, const edm::EventSetup&) override;
56 
61  std::vector<edm::EDGetTokenT<DetIdCollection> > toks_did_;
63  std::vector<edm::InputTag> interestingDetIdCollections;
65 
66  //hcal severity ES
69  std::set<DetId> toBeKept;
70  template <typename CollectionType>
71  void skim(const edm::Handle<CollectionType>& input, CollectionType& output, int severityThreshold = 0) const;
72 
73  // ES tokens
77 };
78 
79 template <class CollectionType>
81  CollectionType& output,
82  int severityThreshold) const {
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 }
109 
110 //
111 // constants, enums and typedefs
112 //
113 
114 //
115 // static data member definitions
116 //
117 
118 //
119 // constructors and destructor
120 //
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 }
150 
152  // do anything here that needs to be done at desctruction time
153  // (e.g. close files, deallocate resources etc.)
154 }
155 
156 //
157 // member functions
158 //
159 
160 // ------------ method called to produce the data ------------
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 }
198 
199 //define this as a plug-in
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
HcalHitSelection::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: HcalHitSelection.cc:161
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:72
HcalHitSelection
Definition: HcalHitSelection.cc:49
edm::EDGetTokenT
Definition: EDGetToken.h:33
edm
HLT enums.
Definition: AlignableModifier.h:19
HcalHitSelection::tok_hf_
edm::EDGetTokenT< HFRecHitCollection > tok_hf_
Definition: HcalHitSelection.cc:60
HcalTopology
Definition: HcalTopology.h:26
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89301
EDProducer.h
HcalRecNumberingRecord.h
HcalChannelQuality
Definition: HcalChannelQuality.h:17
HcalTopology::getMergePositionFlag
bool getMergePositionFlag() const
Definition: HcalTopology.h:167
edm::Handle
Definition: AssociativeIterator.h:50
ESGetToken.h
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
MakerMacros.h
photonIsolationHIProducer_cfi.hf
hf
Definition: photonIsolationHIProducer_cfi.py:9
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
HcalHitSelection::theHcalTopology_
const HcalTopology * theHcalTopology_
Definition: HcalHitSelection.cc:64
HcalHitSelection::HcalHitSelection
HcalHitSelection(const edm::ParameterSet &)
Definition: HcalHitSelection.cc:121
HcalSeverityLevelComputer
Definition: HcalSeverityLevelComputer.h:24
mps_fire.end
end
Definition: mps_fire.py:242
HcalHitSelection_cfi.hoTag
hoTag
Definition: HcalHitSelection_cfi.py:7
HcalHitSelection::~HcalHitSelection
~HcalHitSelection() override
Definition: HcalHitSelection.cc:151
HcalSeverityLevelComputerRcd.h
HcalHitSelection_cfi.hfTag
hfTag
Definition: HcalHitSelection_cfi.py:6
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
edm::ParameterSet
Definition: ParameterSet.h:47
HcalHitSelection_cfi.hbheTag
hbheTag
Definition: HcalHitSelection_cfi.py:5
Event.h
HcalDetId.h
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
edm::stream::EDProducer
Definition: EDProducer.h:36
edm::EventSetup
Definition: EventSetup.h:58
HcalHitSelection::hoTag
edm::InputTag hoTag
Definition: HcalHitSelection.cc:57
HcalHitSelection::hfTag
edm::InputTag hfTag
Definition: HcalHitSelection.cc:57
HcalSubdetector.h
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
edm::ESGetToken< HcalTopology, HcalRecNumberingRecord >
HcalChannelQualityRcd.h
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:127
HcalChannelQuality.h
photonIsolationHIProducer_cfi.hbhe
hbhe
Definition: photonIsolationHIProducer_cfi.py:8
HcalHitSelection::hoSeverityLevel
int hoSeverityLevel
Definition: HcalHitSelection.cc:62
HcalTopology.h
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
Frameworkfwd.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
HcalRecHitCollections.h
HcalSeverityLevelComputer.h
HcalHitSelection::theHcalSevLvlComputer
const HcalSeverityLevelComputer * theHcalSevLvlComputer
Definition: HcalHitSelection.cc:68
HcalHitSelection::tok_hbhe_
edm::EDGetTokenT< HBHERecHitCollection > tok_hbhe_
Definition: HcalHitSelection.cc:58
ParameterSet.h
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
edm::Event
Definition: Event.h:73
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
DetIdCollection.h
hit
Definition: SiStripHitEffFromCalibTree.cc:88