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  // ----------member data ---------------------------
74 };
75 
76 template <class CollectionType>
78  CollectionType& output,
79  int severityThreshold) const {
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 }
106 
107 //
108 // constants, enums and typedefs
109 //
110 
111 //
112 // static data member definitions
113 //
114 
115 //
116 // constructors and destructor
117 //
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 }
140 
142  // do anything here that needs to be done at desctruction time
143  // (e.g. close files, deallocate resources etc.)
144 }
145 
146 //
147 // member functions
148 //
149 
150 // ------------ method called to produce the data ------------
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 }
190 
191 //define this as a plug-in
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
ESHandle.h
HcalHitSelection::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: HcalHitSelection.cc:151
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:32
HcalChannelQualityRcd
Definition: HcalChannelQualityRcd.h:8
HcalHitSelection
Definition: HcalHitSelection.cc:49
edm::EDGetTokenT
Definition: EDGetToken.h:33
HcalHitSelection::tok_hf_
edm::EDGetTokenT< HFRecHitCollection > tok_hf_
Definition: HcalHitSelection.cc:60
HcalTopology
Definition: HcalTopology.h:26
EDProducer.h
HcalRecNumberingRecord.h
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
MakerMacros.h
photonIsolationHIProducer_cfi.hf
hf
Definition: photonIsolationHIProducer_cfi.py:9
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
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:118
edm::ESHandle< HcalChannelQuality >
HcalHitSelection::theHcalSevLvlComputer
edm::ESHandle< HcalSeverityLevelComputer > theHcalSevLvlComputer
Definition: HcalHitSelection.cc:68
OrderedSet.t
t
Definition: OrderedSet.py:90
HcalHitSelection::~HcalHitSelection
~HcalHitSelection() override
Definition: HcalHitSelection.cc:141
HcalRecNumberingRecord
Definition: HcalRecNumberingRecord.h:23
HcalSeverityLevelComputerRcd.h
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::ParameterSet
Definition: ParameterSet.h:36
edm::LogError
Definition: MessageLogger.h:183
Event.h
HcalDetId.h
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:38
HcalHitSelection::theHcalChStatus
edm::ESHandle< HcalChannelQuality > theHcalChStatus
Definition: HcalHitSelection.cc:67
edm::EventSetup
Definition: EventSetup.h:57
HcalHitSelection::hoTag
edm::InputTag hoTag
Definition: HcalHitSelection.cc:57
HcalHitSelection::hfTag
edm::InputTag hfTag
Definition: HcalHitSelection.cc:57
HcalSubdetector.h
get
#define get
HcalChannelQualityRcd.h
HcalHitSelection::toBeKept
std::set< DetId > toBeKept
Definition: HcalHitSelection.cc:69
HcalChannelQuality.h
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
HcalTopology.h
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
HcalRecHitCollections.h
HcalSeverityLevelComputer.h
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
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
DetIdCollection.h
hit
Definition: SiStripHitEffFromCalibTree.cc:88