CMS 3D CMS Logo

HFPhase1Reconstructor.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: RecoLocalCalo/HcalRecProducers
4 // Class: HFPhase1Reconstructor
5 //
13 //
14 // Original Author: Igor Volobouev
15 // Created: Thu, 25 May 2016 00:17:51 GMT
16 //
17 //
18 
19 // system include files
20 
21 // user include files
28 
31 
33 
36 
39 
40 // Noise cleanup algos
44 
45 // Parser for Phase 1 HF reco algorithms
47 
48 // Fetcher for reco algorithm data
50 
51 //
52 // class declaration
53 //
55 public:
57  ~HFPhase1Reconstructor() override;
58 
59  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
60 
61 private:
62  void beginRun(const edm::Run&, const edm::EventSetup&) override;
63  void produce(edm::Event&, const edm::EventSetup&) override;
64 
65  // Configuration parameters
71 
72  // Other members
74  std::unique_ptr<AbsHFPhase1Algo> reco_;
75  std::unique_ptr<AbsHcalAlgoData> recoConfig_;
76 
77  // Noise cleanup algos
78  std::unique_ptr<HcalHF_S9S1algorithm> hfS9S1_;
79  std::unique_ptr<HcalHF_S9S1algorithm> hfS8S1_;
80  std::unique_ptr<HcalHF_PETalgorithm> hfPET_;
81  std::unique_ptr<HFStripFilter> hfStripFilter_;
82 
83  // ES tokens
87 };
88 
89 //
90 // constructors and destructor
91 //
93  : algoConfigClass_(conf.getParameter<std::string>("algoConfigClass")),
94  setNoiseFlags_(conf.getParameter<bool>("setNoiseFlags")),
95  runHFStripFilter_(conf.getParameter<bool>("runHFStripFilter")),
96  useChannelQualityFromDB_(conf.getParameter<bool>("useChannelQualityFromDB")),
97  checkChannelQualityForDepth3and4_(conf.getParameter<bool>("checkChannelQualityForDepth3and4")),
98  reco_(parseHFPhase1AlgoDescription(conf.getParameter<edm::ParameterSet>("algorithm"))) {
99  // Check that the reco algorithm has been successfully configured
100  if (!reco_.get())
101  throw cms::Exception("HFPhase1BadConfig") << "Invalid HFPhase1Reconstructor algorithm configuration" << std::endl;
102 
103  // Configure the noise cleanup algorithms
104  if (setNoiseFlags_) {
105  const edm::ParameterSet& psS9S1 = conf.getParameter<edm::ParameterSet>("S9S1stat");
106  hfS9S1_ = std::make_unique<HcalHF_S9S1algorithm>(psS9S1.getParameter<std::vector<double> >("short_optimumSlope"),
107  psS9S1.getParameter<std::vector<double> >("shortEnergyParams"),
108  psS9S1.getParameter<std::vector<double> >("shortETParams"),
109  psS9S1.getParameter<std::vector<double> >("long_optimumSlope"),
110  psS9S1.getParameter<std::vector<double> >("longEnergyParams"),
111  psS9S1.getParameter<std::vector<double> >("longETParams"),
112  psS9S1.getParameter<int>("HcalAcceptSeverityLevel"),
113  psS9S1.getParameter<bool>("isS8S1"));
114 
115  const edm::ParameterSet& psS8S1 = conf.getParameter<edm::ParameterSet>("S8S1stat");
116  hfS8S1_ = std::make_unique<HcalHF_S9S1algorithm>(psS8S1.getParameter<std::vector<double> >("short_optimumSlope"),
117  psS8S1.getParameter<std::vector<double> >("shortEnergyParams"),
118  psS8S1.getParameter<std::vector<double> >("shortETParams"),
119  psS8S1.getParameter<std::vector<double> >("long_optimumSlope"),
120  psS8S1.getParameter<std::vector<double> >("longEnergyParams"),
121  psS8S1.getParameter<std::vector<double> >("longETParams"),
122  psS8S1.getParameter<int>("HcalAcceptSeverityLevel"),
123  psS8S1.getParameter<bool>("isS8S1"));
124 
125  const edm::ParameterSet& psPET = conf.getParameter<edm::ParameterSet>("PETstat");
126  hfPET_ = std::make_unique<HcalHF_PETalgorithm>(psPET.getParameter<std::vector<double> >("short_R"),
127  psPET.getParameter<std::vector<double> >("shortEnergyParams"),
128  psPET.getParameter<std::vector<double> >("shortETParams"),
129  psPET.getParameter<std::vector<double> >("long_R"),
130  psPET.getParameter<std::vector<double> >("longEnergyParams"),
131  psPET.getParameter<std::vector<double> >("longETParams"),
132  psPET.getParameter<int>("HcalAcceptSeverityLevel"),
133  psPET.getParameter<std::vector<double> >("short_R_29"),
134  psPET.getParameter<std::vector<double> >("long_R_29"));
135 
136  // Configure HFStripFilter
137  if (runHFStripFilter_) {
138  const edm::ParameterSet& psStripFilter = conf.getParameter<edm::ParameterSet>("HFStripFilter");
140  }
141  }
142 
143  // Describe consumed data
144  tok_PreRecHit_ = consumes<HFPreRecHitCollection>(conf.getParameter<edm::InputTag>("inputLabel"));
145 
146  // Register the product
147  produces<HFRecHitCollection>();
148 
149  // ES tokens
150  conditionsToken_ = esConsumes<HcalDbService, HcalDbRecord>();
151  qualToken_ = esConsumes<HcalChannelQuality, HcalChannelQualityRcd>(edm::ESInputTag("", "withTopo"));
152  sevToken_ = esConsumes<HcalSeverityLevelComputer, HcalSeverityLevelComputerRcd>();
153 }
154 
156  // do anything here that needs to be done at destruction time
157  // (e.g. close files, deallocate resources etc.)
158 }
159 
161  if (reco_->isConfigurable()) {
163  if (!recoConfig_.get())
164  throw cms::Exception("HFPhase1BadConfig")
165  << "Invalid HFPhase1Reconstructor \"algoConfigClass\" parameter value \"" << algoConfigClass_ << '"'
166  << std::endl;
167  if (!reco_->configure(recoConfig_.get()))
168  throw cms::Exception("HFPhase1BadConfig")
169  << "Failed to configure HFPhase1Reconstructor algorithm from EventSetup" << std::endl;
170  }
171 }
172 
173 // ------------ method called to produce the data ------------
175  using namespace edm;
176 
177  // Fetch the calibrations
178  const HcalDbService* conditions = &eventSetup.getData(conditionsToken_);
179  const HcalChannelQuality* myqual = &eventSetup.getData(qualToken_);
180  const HcalSeverityLevelComputer* mySeverity = &eventSetup.getData(sevToken_);
181 
182  // Get the input data
184  e.getByToken(tok_PreRecHit_, preRecHits);
185 
186  // Create a new output collection
187  std::unique_ptr<HFRecHitCollection> rec(std::make_unique<HFRecHitCollection>());
188  rec->reserve(preRecHits->size());
189 
190  // Iterate over the input and fill the output collection
191  for (HFPreRecHitCollection::const_iterator it = preRecHits->begin(); it != preRecHits->end(); ++it) {
192  // The check whether this PMT is single-anode one should go here.
193  // Fix this piece of code if/when mixed-anode readout configurations
194  // become available.
195  const bool thisIsSingleAnodePMT = false;
196 
197  // Check if the anodes were tagged bad in the database
198  bool taggedBadByDb[2] = {false, false};
200  if (checkChannelQualityForDepth3and4_ && !thisIsSingleAnodePMT) {
201  HcalDetId anodeIds[2];
202  anodeIds[0] = it->id();
203  anodeIds[1] = anodeIds[0].secondAnodeId();
204  for (unsigned i = 0; i < 2; ++i) {
205  const HcalChannelStatus* mydigistatus = myqual->getValues(anodeIds[i].rawId());
206  taggedBadByDb[i] = mySeverity->dropChannel(mydigistatus->getValue());
207  }
208  } else {
209  const HcalChannelStatus* mydigistatus = myqual->getValues(it->id().rawId());
210  const bool b = mySeverity->dropChannel(mydigistatus->getValue());
211  taggedBadByDb[0] = b;
212  taggedBadByDb[1] = b;
213  }
214  }
215 
216  // Reconstruct the rechit
217  const HFRecHit& rh =
218  reco_->reconstruct(*it, conditions->getHcalCalibrations(it->id()), taggedBadByDb, thisIsSingleAnodePMT);
219 
220  // The rechit will have the id of 0 if the algorithm
221  // decides that it should be dropped
222  if (rh.id().rawId())
223  rec->push_back(rh);
224  }
225 
226  // At this point, the rechits contain energy, timing,
227  // as well as proper auxiliary words. We do still need
228  // to set certain flags using the noise cleanup algoritms.
229 
230  // The following flags require the full set of rechits.
231  // These flags need to be set consecutively.
232  if (setNoiseFlags_) {
233  // Step 1: Set PET flag (short fibers of |ieta|==29)
234  for (HFRecHitCollection::iterator i = rec->begin(); i != rec->end(); ++i) {
235  int depth = i->id().depth();
236  int ieta = i->id().ieta();
237  // Short fibers and all channels at |ieta|=29 use PET settings in Algo 3
238  if (depth == 2 || abs(ieta) == 29)
239  hfPET_->HFSetFlagFromPET(*i, *rec, myqual, mySeverity);
240  }
241 
242  // Step 2: Set S8S1 flag (short fibers or |ieta|==29)
243  for (HFRecHitCollection::iterator i = rec->begin(); i != rec->end(); ++i) {
244  int depth = i->id().depth();
245  int ieta = i->id().ieta();
246  // Short fibers and all channels at |ieta|=29 use PET settings in Algo 3
247  if (depth == 2 || abs(ieta) == 29)
248  hfS8S1_->HFSetFlagFromS9S1(*i, *rec, myqual, mySeverity);
249  }
250 
251  // Step 3: Set S9S1 flag (long fibers)
252  for (HFRecHitCollection::iterator i = rec->begin(); i != rec->end(); ++i) {
253  int depth = i->id().depth();
254  int ieta = i->id().ieta();
255  // Short fibers and all channels at |ieta|=29 use PET settings in Algo 3
256  if (depth == 1 && abs(ieta) != 29)
257  hfS9S1_->HFSetFlagFromS9S1(*i, *rec, myqual, mySeverity);
258  }
259 
260  // Step 4: Run HFStripFilter if requested
261  if (runHFStripFilter_)
262  hfStripFilter_->runFilter(*rec, myqual);
263  }
264 
265  // Add the output collection to the event record
266  e.put(std::move(rec));
267 }
268 
269 #define add_param_set(name) \
270  edm::ParameterSetDescription name; \
271  name.setAllowAnything(); \
272  desc.add<edm::ParameterSetDescription>(#name, name)
273 
274 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
277 
278  desc.add<edm::InputTag>("inputLabel");
279  desc.add<std::string>("algoConfigClass");
280  desc.add<bool>("setNoiseFlags");
281  desc.add<bool>("runHFStripFilter", false);
282  desc.add<bool>("useChannelQualityFromDB");
283  desc.add<bool>("checkChannelQualityForDepth3and4");
286 
290 
291  descriptions.addDefault(desc);
292 }
293 
294 //define this as a plug-in
HFPhase1Reconstructor
Definition: HFPhase1Reconstructor.cc:54
electrons_cff.bool
bool
Definition: electrons_cff.py:366
mps_fire.i
i
Definition: mps_fire.py:428
edm::ESInputTag
Definition: ESInputTag.h:87
edm::SortedCollection::const_iterator
std::vector< T >::const_iterator const_iterator
Definition: SortedCollection.h:80
HFPhase1Reconstructor::hfStripFilter_
std::unique_ptr< HFStripFilter > hfStripFilter_
Definition: HFPhase1Reconstructor.cc:81
HFPhase1Reconstructor::recoConfig_
std::unique_ptr< AbsHcalAlgoData > recoConfig_
Definition: HFPhase1Reconstructor.cc:75
edm::Run
Definition: Run.h:45
edm::EDGetTokenT
Definition: EDGetToken.h:33
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
HFRecHit::id
constexpr HcalDetId id() const
Definition: HFRecHit.h:26
EDProducer.h
edm::SortedCollection::size
size_type size() const
Definition: SortedCollection.h:215
HFPhase1Reconstructor::hfS9S1_
std::unique_ptr< HcalHF_S9S1algorithm > hfS9S1_
Definition: HFPhase1Reconstructor.cc:78
HcalChannelQuality
Definition: HcalChannelQuality.h:17
HFPhase1Reconstructor::hfS8S1_
std::unique_ptr< HcalHF_S9S1algorithm > hfS8S1_
Definition: HFPhase1Reconstructor.cc:79
edm::Handle
Definition: AssociativeIterator.h:50
ESGetToken.h
HcalCondObjectContainer::getValues
const Item * getValues(DetId fId, bool throwOnFail=true) const
Definition: HcalCondObjectContainer.h:159
HFPhase1Reconstructor::conditionsToken_
edm::ESGetToken< HcalDbService, HcalDbRecord > conditionsToken_
Definition: HFPhase1Reconstructor.cc:84
HFPhase1Reconstructor::useChannelQualityFromDB_
bool useChannelQualityFromDB_
Definition: HFPhase1Reconstructor.cc:69
MakerMacros.h
HFPhase1Reconstructor::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: HFPhase1Reconstructor.cc:275
HFRecHit
Definition: HFRecHit.h:11
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
fillDescriptionForParseHFPhase1AlgoDescription
edm::ParameterSetDescription fillDescriptionForParseHFPhase1AlgoDescription()
Definition: parseHFPhase1AlgoDescription.cc:80
edm::SortedCollection::begin
const_iterator begin() const
Definition: SortedCollection.h:262
HcalChannelStatus
Definition: HcalChannelStatus.h:13
HcalSeverityLevelComputer
Definition: HcalSeverityLevelComputer.h:24
HFStripFilter.h
HcalDbRecord.h
b
double b
Definition: hdecay.h:118
HFPhase1Reconstructor::sevToken_
edm::ESGetToken< HcalSeverityLevelComputer, HcalSeverityLevelComputerRcd > sevToken_
Definition: HFPhase1Reconstructor.cc:86
LEDCalibrationChannels.depth
depth
Definition: LEDCalibrationChannels.py:65
HcalSeverityLevelComputer::dropChannel
bool dropChannel(const uint32_t &mystatus) const
Definition: HcalSeverityLevelComputer.cc:395
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
HcalSeverityLevelComputerRcd.h
HcalChannelStatus::getValue
uint32_t getValue() const
Definition: HcalChannelStatus.h:60
HFPhase1Reconstructor::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: HFPhase1Reconstructor.cc:174
HcalHF_S9S1algorithm.h
LEDCalibrationChannels.ieta
ieta
Definition: LEDCalibrationChannels.py:63
parseHFPhase1AlgoDescription
std::unique_ptr< AbsHFPhase1Algo > parseHFPhase1AlgoDescription(const edm::ParameterSet &ps)
Definition: parseHFPhase1AlgoDescription.cc:10
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
ParameterSet
Definition: Functions.h:16
HFPhase1Reconstructor::reco_
std::unique_ptr< AbsHFPhase1Algo > reco_
Definition: HFPhase1Reconstructor.cc:74
edm::SortedCollection::iterator
std::vector< T >::iterator iterator
Definition: SortedCollection.h:81
edm::SortedCollection::end
const_iterator end() const
Definition: SortedCollection.h:267
fetchHcalAlgoData
std::unique_ptr< AbsHcalAlgoData > fetchHcalAlgoData(const std::string &className, const edm::EventSetup &es)
Definition: fetchHcalAlgoData.cc:21
HFPhase1Reconstructor::tok_PreRecHit_
edm::EDGetTokenT< HFPreRecHitCollection > tok_PreRecHit_
Definition: HFPhase1Reconstructor.cc:73
HcalDetId
Definition: HcalDetId.h:12
HFStripFilter::fillDescription
static edm::ParameterSetDescription fillDescription()
Definition: HFStripFilter.cc:356
edm::stream::EDProducer
Definition: EDProducer.h:38
HFPhase1Reconstructor::qualToken_
edm::ESGetToken< HcalChannelQuality, HcalChannelQualityRcd > qualToken_
Definition: HFPhase1Reconstructor.cc:85
edm::EventSetup
Definition: EventSetup.h:58
HFPhase1Reconstructor::HFPhase1Reconstructor
HFPhase1Reconstructor(const edm::ParameterSet &)
Definition: HFPhase1Reconstructor.cc:92
HcalHF_PETalgorithm.h
HFPhase1Reconstructor::hfPET_
std::unique_ptr< HcalHF_PETalgorithm > hfPET_
Definition: HFPhase1Reconstructor.cc:80
HLT_FULL_cff.S8S1stat
S8S1stat
Definition: HLT_FULL_cff.py:8485
edm::ESGetToken< HcalDbService, HcalDbRecord >
HFPhase1Reconstructor::~HFPhase1Reconstructor
~HFPhase1Reconstructor() override
Definition: HFPhase1Reconstructor.cc:155
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:127
alignCSCRings.r
r
Definition: alignCSCRings.py:93
HFPhase1Reconstructor::runHFStripFilter_
bool runHFStripFilter_
Definition: HFPhase1Reconstructor.cc:68
parseHFPhase1AlgoDescription.h
HcalDbService
Definition: HcalDbService.h:26
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
add_param_set
#define add_param_set(name)
Definition: HFPhase1Reconstructor.cc:269
submitPVValidationJobs.conditions
list conditions
Definition: submitPVValidationJobs.py:674
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
DetId::rawId
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
HLT_FULL_cff.S9S1stat
S9S1stat
Definition: HLT_FULL_cff.py:8463
Frameworkfwd.h
HFPhase1Reconstructor::beginRun
void beginRun(const edm::Run &, const edm::EventSetup &) override
Definition: HFPhase1Reconstructor.cc:160
HFPhase1Reconstructor::checkChannelQualityForDepth3and4_
bool checkChannelQualityForDepth3and4_
Definition: HFPhase1Reconstructor.cc:70
HLT_FULL_cff.PETstat
PETstat
Definition: HLT_FULL_cff.py:8450
Exception
Definition: hltDiff.cc:245
HFPhase1Reconstructor::algoConfigClass_
std::string algoConfigClass_
Definition: HFPhase1Reconstructor.cc:66
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
HcalRecHitCollections.h
HcalSeverityLevelComputer.h
Exception.h
HFStripFilter::parseParameterSet
static std::unique_ptr< HFStripFilter > parseParameterSet(const edm::ParameterSet &ps)
Definition: HFStripFilter.cc:344
HcalDbService.h
cms::Exception
Definition: Exception.h:70
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
ParameterSet.h
fetchHcalAlgoData.h
edm::Event
Definition: Event.h:73
edm::ConfigurationDescriptions::addDefault
void addDefault(ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:99
StreamID.h
edm::InputTag
Definition: InputTag.h:15
HcalDetId::secondAnodeId
constexpr HcalDetId secondAnodeId() const
second PMT anode detId for HF dual channels
Definition: HcalDetId.h:241
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
HFPhase1Reconstructor::setNoiseFlags_
bool setNoiseFlags_
Definition: HFPhase1Reconstructor.cc:67