CMS 3D CMS Logo

HBHEPhase1Reconstructor.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: RecoLocalCalo/HcalRecProducers
4 // Class: HBHEPhase1Reconstructor
5 //
13 //
14 // Original Author: Igor Volobouev
15 // Created: Tue, 21 Jun 2016 00:56:40 GMT
16 //
17 //
18 
19 
20 // system include files
21 #include <cmath>
22 #include <utility>
23 #include <algorithm>
24 
25 // user include files
32 
35 
40 
44 
46 
48 
53 
56 
57 // Parser for Phase 1 HB/HE reco algorithms
59 
60 // Fetcher for reco algorithm data
62 
63 // Some helper functions
64 namespace {
65  // Class for making SiPM/QIE11 look like HPD/QIE8. HPD/QIE8
66  // needs only pedestal and gain to convert charge into energy.
67  // Due to nonlinearities, response of SiPM/QIE11 is substantially
68  // more complicated. It is possible to calculate all necessary
69  // quantities from the charge and the info stored in the DB every
70  // time the raw charge is needed. However, it does not make sense
71  // to retrieve DB contents stored by channel for every time slice.
72  // Because of this, we look things up only once, in the constructor.
73  template<class DFrame>
74  class RawChargeFromSample
75  {
76  public:
77  inline RawChargeFromSample(const HcalDbService& cond,
78  const HcalDetId id) {}
79 
80  inline double getRawCharge(const double decodedCharge,
81  const double pedestal) const
82  {return decodedCharge;}
83  };
84 
85  template<>
86  class RawChargeFromSample<QIE11DataFrame>
87  {
88  public:
89  inline RawChargeFromSample(const HcalDbService& cond,
90  const HcalDetId id)
91  : siPMParameter_(*cond.getHcalSiPMParameter(id)),
92  fcByPE_(siPMParameter_.getFCByPE()),
93  corr_(cond.getHcalSiPMCharacteristics()->getNonLinearities(siPMParameter_.getType()))
94  {
95  if (fcByPE_ <= 0.0)
96  throw cms::Exception("HBHEPhase1BadDB")
97  << "Invalid fC/PE conversion factor for SiPM " << id
98  << std::endl;
99  }
100 
101  inline double getRawCharge(const double decodedCharge,
102  const double pedestal) const
103  {
104  const double sipmQ = decodedCharge - pedestal;
105  const double nPixelsFired = sipmQ/fcByPE_;
106  return sipmQ*corr_.getRecoCorrectionFactor(nPixelsFired) + pedestal;
107  }
108 
109  private:
110  const HcalSiPMParameter& siPMParameter_;
111  double fcByPE_;
112  HcalSiPMnonlinearity corr_;
113  };
114 
115  float getTDCTimeFromSample(const QIE11DataFrame::Sample& s)
116  {
117  // Conversion from TDC to ns for the QIE11 chip
118  static const float qie11_tdc_to_ns = 0.5f;
119 
120  // TDC values produced in case the pulse is always above/below
121  // the discriminator
122  static const int qie11_tdc_code_overshoot = 62;
123  static const int qie11_tdc_code_undershoot = 63;
124 
125  const int tdc = s.tdc();
126  float t = qie11_tdc_to_ns*tdc;
127  if (tdc == qie11_tdc_code_overshoot)
129  else if (tdc == qie11_tdc_code_undershoot)
131  return t;
132  }
133 
134  float getTDCTimeFromSample(const HcalQIESample&)
135  {
137  }
138 
139  float getDifferentialChargeGain(const HcalQIECoder& coder,
140  const HcalQIEShape& shape,
141  const unsigned adc,
142  const unsigned capid,
143  const bool isQIE11)
144  {
145  // We have 5-bit ADC mantissa in QIE8 and 6-bit in QIE11
146  static const unsigned mantissaMaskQIE8 = 0x1f;
147  static const unsigned mantissaMaskQIE11 = 0x3f;
148 
149  const float q = coder.charge(shape, adc, capid);
150  const unsigned mantissaMask = isQIE11 ? mantissaMaskQIE11 : mantissaMaskQIE8;
151  const unsigned mantissa = adc & mantissaMask;
152 
153  // First, check if we are in the two lowest or two highest ADC
154  // values for this range. Assume that they have the lowest and
155  // the highest gain in the range, respectively.
156  if (mantissa == 0U || mantissa == mantissaMask - 1U)
157  return coder.charge(shape, adc+1U, capid) - q;
158  else if (mantissa == 1U || mantissa == mantissaMask)
159  return q - coder.charge(shape, adc-1U, capid);
160  else
161  {
162  const float qup = coder.charge(shape, adc+1U, capid);
163  const float qdown = coder.charge(shape, adc-1U, capid);
164  const float upGain = qup - q;
165  const float downGain = q - qdown;
166  const float averageGain = (qup - qdown)/2.f;
167  if (std::abs(upGain - downGain) < 0.01f*averageGain)
168  return averageGain;
169  else
170  {
171  // We are in the gain transition region.
172  // Need to determine if we are in the lower
173  // gain ADC count or in the higher one.
174  // This can be done by figuring out if the
175  // "up" gain is more consistent then the
176  // "down" gain.
177  const float q2up = coder.charge(shape, adc+2U, capid);
178  const float q2down = coder.charge(shape, adc-2U, capid);
179  const float upGain2 = q2up - qup;
180  const float downGain2 = qdown - q2down;
181  if (std::abs(upGain2 - upGain) < std::abs(downGain2 - downGain))
182  return upGain;
183  else
184  return downGain;
185  }
186  }
187  }
188 
189  // The first element of the pair indicates presence of optical
190  // link errors. The second indicated presence of capid errors.
191  std::pair<bool,bool> findHWErrors(const HBHEDataFrame& df,
192  const unsigned len)
193  {
194  bool linkErr = false;
195  bool capidErr = false;
196  if (len)
197  {
198  int expectedCapid = df[0].capid();
199  for (unsigned i=0; i<len; ++i)
200  {
201  if (df[i].er())
202  linkErr = true;
203  if (df[i].capid() != expectedCapid)
204  capidErr = true;
205  expectedCapid = (expectedCapid + 1) % 4;
206  }
207  }
208  return std::pair<bool,bool>(linkErr, capidErr);
209  }
210 
211  std::pair<bool,bool> findHWErrors(const QIE11DataFrame& df,
212  const unsigned /* len */)
213  {
214  return std::pair<bool,bool>(df.linkError(), df.capidError());
215  }
216 
217  std::unique_ptr<HBHEStatusBitSetter> parse_HBHEStatusBitSetter(
218  const edm::ParameterSet& psdigi)
219  {
220  return std::make_unique<HBHEStatusBitSetter>(
221  psdigi.getParameter<double>("nominalPedestal"),
222  psdigi.getParameter<double>("hitEnergyMinimum"),
223  psdigi.getParameter<int>("hitMultiplicityThreshold"),
224  psdigi.getParameter<std::vector<edm::ParameterSet> >("pulseShapeParameterSets"));
225  }
226 
227  std::unique_ptr<HBHEPulseShapeFlagSetter> parse_HBHEPulseShapeFlagSetter(
228  const edm::ParameterSet& psPulseShape, const bool setLegacyFlags)
229  {
230  return std::make_unique<HBHEPulseShapeFlagSetter>(
231  psPulseShape.getParameter<double>("MinimumChargeThreshold"),
232  psPulseShape.getParameter<double>("TS4TS5ChargeThreshold"),
233  psPulseShape.getParameter<double>("TS3TS4ChargeThreshold"),
234  psPulseShape.getParameter<double>("TS3TS4UpperChargeThreshold"),
235  psPulseShape.getParameter<double>("TS5TS6ChargeThreshold"),
236  psPulseShape.getParameter<double>("TS5TS6UpperChargeThreshold"),
237  psPulseShape.getParameter<double>("R45PlusOneRange"),
238  psPulseShape.getParameter<double>("R45MinusOneRange"),
239  psPulseShape.getParameter<unsigned int>("TrianglePeakTS"),
240  psPulseShape.getParameter<std::vector<double> >("LinearThreshold"),
241  psPulseShape.getParameter<std::vector<double> >("LinearCut"),
242  psPulseShape.getParameter<std::vector<double> >("RMS8MaxThreshold"),
243  psPulseShape.getParameter<std::vector<double> >("RMS8MaxCut"),
244  psPulseShape.getParameter<std::vector<double> >("LeftSlopeThreshold"),
245  psPulseShape.getParameter<std::vector<double> >("LeftSlopeCut"),
246  psPulseShape.getParameter<std::vector<double> >("RightSlopeThreshold"),
247  psPulseShape.getParameter<std::vector<double> >("RightSlopeCut"),
248  psPulseShape.getParameter<std::vector<double> >("RightSlopeSmallThreshold"),
249  psPulseShape.getParameter<std::vector<double> >("RightSlopeSmallCut"),
250  psPulseShape.getParameter<std::vector<double> >("TS4TS5LowerThreshold"),
251  psPulseShape.getParameter<std::vector<double> >("TS4TS5LowerCut"),
252  psPulseShape.getParameter<std::vector<double> >("TS4TS5UpperThreshold"),
253  psPulseShape.getParameter<std::vector<double> >("TS4TS5UpperCut"),
254  psPulseShape.getParameter<bool>("UseDualFit"),
255  psPulseShape.getParameter<bool>("TriangleIgnoreSlow"),
256  setLegacyFlags);
257  }
258 }
259 
260 
261 //
262 // class declaration
263 //
265 {
266 public:
269 
270  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
271 
272 private:
273  virtual void beginRun(edm::Run const&, edm::EventSetup const&) override;
274  virtual void endRun(edm::Run const&, edm::EventSetup const&) override;
275  virtual void produce(edm::Event&, const edm::EventSetup&) override;
276 
277  // Configuration parameters
285  bool tsFromDB_;
288 
289  // Parameters for turning status bit setters on/off
296 
297  // Other members
300  std::unique_ptr<AbsHBHEPhase1Algo> reco_;
301  std::unique_ptr<AbsHcalAlgoData> recoConfig_;
302  std::unique_ptr<HcalRecoParams> paramTS_;
303 
304  // Status bit setters
305  const HBHENegativeEFilter* negEFilter_; // We don't manage this pointer
306  std::unique_ptr<HBHEStatusBitSetter> hbheFlagSetterQIE8_;
307  std::unique_ptr<HBHEStatusBitSetter> hbheFlagSetterQIE11_;
308  std::unique_ptr<HBHEPulseShapeFlagSetter> hbhePulseShapeFlagSetterQIE8_;
309  std::unique_ptr<HBHEPulseShapeFlagSetter> hbhePulseShapeFlagSetterQIE11_;
310 
311  // For the function below, arguments "infoColl" and/or "rechits"
312  // are allowed to be null.
313  template<class DataFrame, class Collection>
314  void processData(const Collection& coll,
315  const HcalDbService& cond,
316  const HcalChannelQuality& qual,
318  const bool isRealData,
320  HBHEChannelInfoCollection* infoColl,
322 
323  // Methods for setting rechit status bits
324  void setAsicSpecificBits(const HBHEDataFrame& frame, const HcalCoder& coder,
326  HBHERecHit* rh);
327  void setAsicSpecificBits(const QIE11DataFrame& frame, const HcalCoder& coder,
329  HBHERecHit* rh);
330  void setCommonStatusBits(const HBHEChannelInfo& info, const HcalCalibrations& calib,
331  HBHERecHit* rh);
332 
333  void runHBHENegativeEFilter(const HBHEChannelInfo& info, HBHERecHit* rh);
334 };
335 
336 //
337 // constructors and destructor
338 //
340  : algoConfigClass_(conf.getParameter<std::string>("algoConfigClass")),
341  processQIE8_(conf.getParameter<bool>("processQIE8")),
342  processQIE11_(conf.getParameter<bool>("processQIE11")),
343  saveInfos_(conf.getParameter<bool>("saveInfos")),
344  saveDroppedInfos_(conf.getParameter<bool>("saveDroppedInfos")),
345  makeRecHits_(conf.getParameter<bool>("makeRecHits")),
346  dropZSmarkedPassed_(conf.getParameter<bool>("dropZSmarkedPassed")),
347  tsFromDB_(conf.getParameter<bool>("tsFromDB")),
348  recoParamsFromDB_(conf.getParameter<bool>("recoParamsFromDB")),
349  saveEffectivePedestal_(conf.getParameter<bool>("saveEffectivePedestal")),
350  setNegativeFlagsQIE8_(conf.getParameter<bool>("setNegativeFlagsQIE8")),
351  setNegativeFlagsQIE11_(conf.getParameter<bool>("setNegativeFlagsQIE11")),
352  setNoiseFlagsQIE8_(conf.getParameter<bool>("setNoiseFlagsQIE8")),
353  setNoiseFlagsQIE11_(conf.getParameter<bool>("setNoiseFlagsQIE11")),
354  setPulseShapeFlagsQIE8_(conf.getParameter<bool>("setPulseShapeFlagsQIE8")),
355  setPulseShapeFlagsQIE11_(conf.getParameter<bool>("setPulseShapeFlagsQIE11")),
356  reco_(parseHBHEPhase1AlgoDescription(conf.getParameter<edm::ParameterSet>("algorithm"))),
357  negEFilter_(nullptr)
358 {
359  // Check that the reco algorithm has been successfully configured
360  if (!reco_.get())
361  throw cms::Exception("HBHEPhase1BadConfig")
362  << "Invalid HBHEPhase1Algo algorithm configuration"
363  << std::endl;
364 
365  // Configure the status bit setters that have been turned on
366  if (setNoiseFlagsQIE8_)
367  hbheFlagSetterQIE8_ = parse_HBHEStatusBitSetter(
368  conf.getParameter<edm::ParameterSet>("flagParametersQIE8"));
369 
371  hbheFlagSetterQIE11_ = parse_HBHEStatusBitSetter(
372  conf.getParameter<edm::ParameterSet>("flagParametersQIE11"));
373 
375  hbhePulseShapeFlagSetterQIE8_ = parse_HBHEPulseShapeFlagSetter(
376  conf.getParameter<edm::ParameterSet>("pulseShapeParametersQIE8"),
377  conf.getParameter<bool>("setLegacyFlagsQIE8"));
378 
380  hbhePulseShapeFlagSetterQIE11_ = parse_HBHEPulseShapeFlagSetter(
381  conf.getParameter<edm::ParameterSet>("pulseShapeParametersQIE11"),
382  conf.getParameter<bool>("setLegacyFlagsQIE11"));
383 
384  // Consumes and produces statements
385  if (processQIE8_)
386  tok_qie8_ = consumes<HBHEDigiCollection>(
387  conf.getParameter<edm::InputTag>("digiLabelQIE8"));
388 
389  if (processQIE11_)
390  tok_qie11_ = consumes<QIE11DigiCollection>(
391  conf.getParameter<edm::InputTag>("digiLabelQIE11"));
392 
393  if (saveInfos_)
394  produces<HBHEChannelInfoCollection>();
395 
396  if (makeRecHits_)
397  produces<HBHERecHitCollection>();
398 }
399 
400 
402 {
403  // do anything here that needs to be done at destruction time
404  // (e.g. close files, deallocate resources etc.)
405 }
406 
407 
408 //
409 // member functions
410 //
411 template<class DFrame, class Collection>
413  const HcalDbService& cond,
414  const HcalChannelQuality& qual,
416  const bool isRealData,
417  HBHEChannelInfo* channelInfo,
420 {
421  // If "saveDroppedInfos_" flag is set, fill the info with something
422  // meaningful even if the database tells us to drop this channel.
423  // Note that this flag affects only "infos", the rechits are still
424  // not going to be constructed from such channels.
425  const bool skipDroppedChannels = !(infos && saveDroppedInfos_);
426 
427  // Iterate over the input collection
428  for (typename Collection::const_iterator it = coll.begin();
429  it != coll.end(); ++it)
430  {
431  const DFrame& frame(*it);
432  const HcalDetId cell(frame.id());
433 
434  // Protection against calibration channels which are not
435  // in the database but can still come in the QIE11DataFrame
436  // in the laser calibs, etc.
437  const HcalSubdetector subdet = cell.subdet();
438  if (!(subdet == HcalSubdetector::HcalBarrel ||
439  subdet == HcalSubdetector::HcalEndcap ||
440  subdet == HcalSubdetector::HcalOuter))
441  continue;
442 
443  // Check if the database tells us to drop this channel
444  const HcalChannelStatus* mydigistatus = qual.getValues(cell.rawId());
445  const bool taggedBadByDb = severity.dropChannel(mydigistatus->getValue());
446  if (taggedBadByDb && skipDroppedChannels)
447  continue;
448 
449  // Check if the channel is zero suppressed
450  bool dropByZS = false;
452  if (frame.zsMarkAndPass())
453  dropByZS = true;
454  if (dropByZS && skipDroppedChannels)
455  continue;
456 
457  // Basic ADC decoding tools
458  const HcalRecoParam* param_ts = paramTS_->getValues(cell.rawId());
459  const HcalCalibrations& calib = cond.getHcalCalibrations(cell);
460  const HcalCalibrationWidths& calibWidth = cond.getHcalCalibrationWidths(cell);
461  const HcalQIECoder* channelCoder = cond.getHcalCoder(cell);
462  const HcalQIEShape* shape = cond.getHcalShape(channelCoder);
463  const HcalCoderDb coder(*channelCoder, *shape);
464  const RawChargeFromSample<DFrame> rcfs(cond, cell);
465 
466  // needed for the dark current in the M2
467  const HcalSiPMParameter& siPMParameter(*cond.getHcalSiPMParameter(cell));
468  const double darkCurrent = siPMParameter.getDarkCurrent();
469  const double fcByPE = siPMParameter.getFCByPE();
470  const double lambda = cond.getHcalSiPMCharacteristics()->getCrossTalk(siPMParameter.getType());
471 
472  // ADC to fC conversion
473  CaloSamples cs;
474  coder.adc2fC(frame, cs);
475 
476  // Prepare to iterate over time slices
477  const int nRead = cs.size();
478  const int maxTS = std::min(nRead, static_cast<int>(HBHEChannelInfo::MAXSAMPLES));
479  const int soi = tsFromDB_ ? param_ts->firstSample() : frame.presamples();
480  int soiCapid = 4;
481 
482  // Go over time slices and fill the samples
483  for (int ts = 0; ts < maxTS; ++ts)
484  {
485  auto s(frame[ts]);
486  const uint8_t adc = s.adc();
487  const int capid = s.capid();
488  //optionally store "effective" pedestal = QIE contribution (default, from calib.pedestal()) + SiPM contribution (dark current + crosstalk)
489  //only done for pedestal mean, to be used for pedestal subtraction downstream
490  const double pedestal = calib.pedestal(capid) + (saveEffectivePedestal_ ? darkCurrent * 25. / (1. - lambda) : 0.);
491  const double pedestalWidth = calibWidth.pedestal(capid);
492  const double gain = calib.respcorrgain(capid);
493  const double gainWidth = calibWidth.gain(capid);
494  const double rawCharge = rcfs.getRawCharge(cs[ts], pedestal);
495  const float t = getTDCTimeFromSample(s);
496  const float dfc = getDifferentialChargeGain(*channelCoder, *shape, adc,
497  capid, channelInfo->hasTimeInfo());
498  channelInfo->setSample(ts, adc, dfc, rawCharge,
499  pedestal, pedestalWidth,
500  gain, gainWidth, t);
501  if (ts == soi)
502  soiCapid = capid;
503  }
504 
505  // Fill the overall channel info items
506  const int pulseShapeID = param_ts->pulseShapeID();
507  const std::pair<bool,bool> hwerr = findHWErrors(frame, maxTS);
508  channelInfo->setChannelInfo(cell, pulseShapeID, maxTS, soi, soiCapid,
509  darkCurrent, fcByPE, lambda,
510  hwerr.first, hwerr.second,
511  taggedBadByDb || dropByZS);
512 
513  // If needed, add the channel info to the output collection
514  const bool makeThisRechit = !channelInfo->isDropped();
515  if (infos && (saveDroppedInfos_ || makeThisRechit))
516  infos->push_back(*channelInfo);
517 
518  // Reconstruct the rechit
519  if (rechits && makeThisRechit)
520  {
521  const HcalRecoParam* pptr = nullptr;
522  if (recoParamsFromDB_)
523  pptr = param_ts;
524  HBHERecHit rh = reco_->reconstruct(*channelInfo, pptr, calib, isRealData);
525  if (rh.id().rawId())
526  {
527  setAsicSpecificBits(frame, coder, *channelInfo, calib, &rh);
528  setCommonStatusBits(*channelInfo, calib, &rh);
529  rechits->push_back(rh);
530  }
531  }
532  }
533 }
534 
536  const HBHEChannelInfo& /* info */, const HcalCalibrations& /* calib */,
537  HBHERecHit* /* rh */)
538 {
539 }
540 
542  const HBHEDataFrame& frame, const HcalCoder& coder,
544  HBHERecHit* rh)
545 {
546  if (setNoiseFlagsQIE8_)
547  hbheFlagSetterQIE8_->rememberHit(*rh);
548 
550  hbhePulseShapeFlagSetterQIE8_->SetPulseShapeFlags(*rh, frame, coder, calib);
551 
553  runHBHENegativeEFilter(info, rh);
554 }
555 
557  const QIE11DataFrame& frame, const HcalCoder& coder,
559  HBHERecHit* rh)
560 {
562  hbheFlagSetterQIE11_->rememberHit(*rh);
563 
565  hbhePulseShapeFlagSetterQIE11_->SetPulseShapeFlags(*rh, frame, coder, calib);
566 
568  runHBHENegativeEFilter(info, rh);
569 }
570 
572  HBHERecHit* rh)
573 {
574  double ts[HBHEChannelInfo::MAXSAMPLES];
575  const unsigned nRead = info.nSamples();
576  for (unsigned i=0; i<nRead; ++i)
577  ts[i] = info.tsCharge(i);
578  const bool passes = negEFilter_->checkPassFilter(info.id(), &ts[0], nRead);
579  if (!passes)
581 }
582 
583 // ------------ method called to produce the data ------------
584 void
586 {
587  using namespace edm;
588 
589  // Get the Hcal topology
591  eventSetup.get<HcalRecNumberingRecord>().get(htopo);
592  paramTS_->setTopo(htopo.product());
593 
594  // Fetch the calibrations
595  ESHandle<HcalDbService> conditions;
596  eventSetup.get<HcalDbRecord>().get(conditions);
597 
599  eventSetup.get<HcalChannelQualityRcd>().get("withTopo", p);
600 
602  eventSetup.get<HcalSeverityLevelComputerRcd>().get(mycomputer);
603 
604  // Configure the negative energy filter
607  {
608  eventSetup.get<HBHENegativeEFilterRcd>().get(negEHandle);
609  negEFilter_ = negEHandle.product();
610  }
611 
612  // Find the input data
613  unsigned maxOutputSize = 0;
615  if (processQIE8_)
616  {
617  e.getByToken(tok_qie8_, hbDigis);
618  maxOutputSize += hbDigis->size();
619  }
620 
622  if (processQIE11_)
623  {
624  e.getByToken(tok_qie11_, heDigis);
625  maxOutputSize += heDigis->size();
626  }
627 
628  // Create new output collections
629  std::unique_ptr<HBHEChannelInfoCollection> infos;
630  if (saveInfos_)
631  {
632  infos = std::make_unique<HBHEChannelInfoCollection>();
633  infos->reserve(maxOutputSize);
634  }
635 
636  std::unique_ptr<HBHERecHitCollection> out;
637  if (makeRecHits_)
638  {
639  out = std::make_unique<HBHERecHitCollection>();
640  out->reserve(maxOutputSize);
641  }
642 
643  // Process the input collections, filling the output ones
644  const bool isData = e.isRealData();
645  if (processQIE8_)
646  {
647  if (setNoiseFlagsQIE8_)
648  hbheFlagSetterQIE8_->Clear();
649 
650  HBHEChannelInfo channelInfo(false);
651  processData<HBHEDataFrame>(*hbDigis, *conditions, *p, *mycomputer,
652  isData, &channelInfo, infos.get(), out.get());
653  if (setNoiseFlagsQIE8_)
654  hbheFlagSetterQIE8_->SetFlagsFromRecHits(*out);
655  }
656 
657  if (processQIE11_)
658  {
660  hbheFlagSetterQIE11_->Clear();
661 
662  HBHEChannelInfo channelInfo(true);
663  processData<QIE11DataFrame>(*heDigis, *conditions, *p, *mycomputer,
664  isData, &channelInfo, infos.get(), out.get());
666  hbheFlagSetterQIE11_->SetFlagsFromRecHits(*out);
667  }
668 
669  // Add the output collections to the event record
670  if (saveInfos_)
671  e.put(std::move(infos));
672  if (makeRecHits_)
673  e.put(std::move(out));
674 }
675 
676 // ------------ method called when starting to processes a run ------------
677 void
679 {
681  es.get<HcalRecoParamsRcd>().get(p);
682  paramTS_ = std::make_unique<HcalRecoParams>(*p.product());
683 
684  if (reco_->isConfigurable())
685  {
687  if (!recoConfig_.get())
688  throw cms::Exception("HBHEPhase1BadConfig")
689  << "Invalid HBHEPhase1Reconstructor \"algoConfigClass\" parameter value \""
690  << algoConfigClass_ << '"' << std::endl;
691  if (!reco_->configure(recoConfig_.get()))
692  throw cms::Exception("HBHEPhase1BadConfig")
693  << "Failed to configure HBHEPhase1Algo algorithm from EventSetup"
694  << std::endl;
695  }
696 
698  {
700  es.get<HcalFrontEndMapRcd>().get(hfemap);
701  if (hfemap.isValid())
702  {
703  if (setNoiseFlagsQIE8_)
704  hbheFlagSetterQIE8_->SetFrontEndMap(hfemap.product());
706  hbheFlagSetterQIE11_->SetFrontEndMap(hfemap.product());
707  }
708  else
709  edm::LogWarning("EventSetup") <<
710  "HBHEPhase1Reconstructor failed to get HcalFrontEndMap!" << std::endl;
711  }
712 
713  reco_->beginRun(r, es);
714 }
715 
716 void
718 {
719  reco_->endRun();
720 }
721 
722 #define add_param_set(name) \
723  edm::ParameterSetDescription name; \
724  name.setAllowAnything(); \
725  desc.add<edm::ParameterSetDescription>(#name, name)
726 
727 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
728 void
730 {
732 
733  desc.add<edm::InputTag>("digiLabelQIE8");
734  desc.add<edm::InputTag>("digiLabelQIE11");
735  desc.add<std::string>("algoConfigClass");
736  desc.add<bool>("processQIE8");
737  desc.add<bool>("processQIE11");
738  desc.add<bool>("saveInfos");
739  desc.add<bool>("saveDroppedInfos");
740  desc.add<bool>("makeRecHits");
741  desc.add<bool>("dropZSmarkedPassed");
742  desc.add<bool>("tsFromDB");
743  desc.add<bool>("recoParamsFromDB");
744  desc.add<bool>("saveEffectivePedestal",false);
745  desc.add<bool>("setNegativeFlagsQIE8");
746  desc.add<bool>("setNegativeFlagsQIE11");
747  desc.add<bool>("setNoiseFlagsQIE8");
748  desc.add<bool>("setNoiseFlagsQIE11");
749  desc.add<bool>("setPulseShapeFlagsQIE8");
750  desc.add<bool>("setPulseShapeFlagsQIE11");
751  desc.add<bool>("setLegacyFlagsQIE8");
752  desc.add<bool>("setLegacyFlagsQIE11");
753 
759 
760  descriptions.addDefault(desc);
761 }
762 
763 //define this as a plug-in
int adc(sample_type sample)
get the ADC sample (12 bits)
HBHEPhase1Reconstructor(const edm::ParameterSet &)
std::unique_ptr< HBHEPulseShapeFlagSetter > hbhePulseShapeFlagSetterQIE8_
unsigned int firstSample() const
Definition: HcalRecoParam.h:32
T getParameter(std::string const &) const
const HBHENegativeEFilter * negEFilter_
double gain(int fCapId) const
get gain width for capid=0..3
static const TGPicture * info(bool iBackgroundIsBlack)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
double respcorrgain(int fCapId) const
get response corrected gain for capid=0..3
auto_ptr< ClusterSequence > cs
int maxTS(DIGI const &digi, double ped=0)
Definition: Utilities.h:51
HcalSubdetector subdet() const
get the subdetector
Definition: HcalDetId.h:49
bool hasTimeInfo() const
void setCommonStatusBits(const HBHEChannelInfo &info, const HcalCalibrations &calib, HBHERecHit *rh)
std::unique_ptr< HBHEStatusBitSetter > hbheFlagSetterQIE11_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
std::unique_ptr< HBHEStatusBitSetter > hbheFlagSetterQIE8_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
virtual void beginRun(edm::Run const &, edm::EventSetup const &) override
HcalDetId id() const
get the id
Definition: HBHERecHit.h:25
void setFlagField(uint32_t value, int base, int width=1)
Definition: CaloRecHit.cc:20
void push_back(T const &t)
double pedestal(int fCapId) const
get pedestal for capid=0..3
const Item * getValues(DetId fId, bool throwOnFail=true) const
#define nullptr
std::unique_ptr< AbsHcalAlgoData > fetchHcalAlgoData(const std::string &className, const edm::EventSetup &es)
void setSample(const unsigned ts, const uint8_t rawADC, const float differentialChargeGain, const double q, const double ped, const double pedWidth, const double g, const double gainWidth, const float t)
bool isRealData() const
Definition: EventBase.h:62
HcalDetId id() const
constexpr float UNKNOWN_T_UNDERSHOOT
float getCrossTalk(int type) const
get cross talk
bool checkPassFilter(const HcalDetId &id, const double *ts, unsigned lenTS) const
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
std::unique_ptr< HcalRecoParams > paramTS_
void addDefault(ParameterSetDescription const &psetDescription)
constexpr float UNKNOWN_T_OVERSHOOT
static const unsigned MAXSAMPLES
double pedestal(int fCapId) const
get pedestal width for capid=0..3
virtual void endRun(edm::Run const &, edm::EventSetup const &) override
bool linkError() const
void processData(const Collection &coll, const HcalDbService &cond, const HcalChannelQuality &qual, const HcalSeverityLevelComputer &severity, const bool isRealData, HBHEChannelInfo *info, HBHEChannelInfoCollection *infoColl, HBHERecHitCollection *rechits)
virtual void adc2fC(const HBHEDataFrame &df, CaloSamples &lf) const
Definition: HcalCoderDb.cc:68
edm::EDGetTokenT< QIE11DigiCollection > tok_qie11_
edm::EDGetTokenT< HBHEDigiCollection > tok_qie8_
std::unique_ptr< AbsHBHEPhase1Algo > parseHBHEPhase1AlgoDescription(const edm::ParameterSet &ps)
HcalSubdetector
Definition: HcalAssistant.h:31
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
bool dropChannel(const uint32_t &mystatus) const
double f[11][100]
double tsCharge(const unsigned ts) const
std::unique_ptr< AbsHBHEPhase1Algo > reco_
T min(T a, T b)
Definition: MathUtil.h:58
float getDarkCurrent() const
get dark current
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void runHBHENegativeEFilter(const HBHEChannelInfo &info, HBHERecHit *rh)
const HcalCalibrationWidths & getHcalCalibrationWidths(const HcalGenericDetId &fId) const
bool capidError() const
unsigned int pulseShapeID() const
Definition: HcalRecoParam.h:34
std::unique_ptr< HBHEPulseShapeFlagSetter > hbhePulseShapeFlagSetterQIE11_
JetCorrectorParametersCollection coll
Definition: classes.h:10
int size() const
get the size
Definition: CaloSamples.h:24
const T & get() const
Definition: EventSetup.h:56
const HcalSiPMCharacteristics * getHcalSiPMCharacteristics() const
const HcalQIECoder * getHcalCoder(const HcalGenericDetId &fId) const
void setAsicSpecificBits(const HBHEDataFrame &frame, const HcalCoder &coder, const HBHEChannelInfo &info, const HcalCalibrations &calib, HBHERecHit *rh)
const HcalQIEShape * getHcalShape(const HcalGenericDetId &fId) const
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
constexpr float UNKNOWN_T_NOTDC
Definition: plugin.cc:24
HLT enums.
size_type size() const
void setChannelInfo(const HcalDetId &detId, const int recoShape, const unsigned nSamp, const unsigned iSoi, const int iCapid, const double darkCurrent, const double fcByPE, const double lambda, const bool linkError, const bool capidError, const bool dropThisChannel)
bool isDropped() const
std::unique_ptr< AbsHcalAlgoData > recoConfig_
unsigned nSamples() const
uint32_t getValue() const
bool isValid() const
Definition: ESHandle.h:47
const HcalCalibrations & getHcalCalibrations(const HcalGenericDetId &fId) const
const HcalSiPMParameter * getHcalSiPMParameter(const HcalGenericDetId &fId) const
T const * product() const
Definition: ESHandle.h:86
def move(src, dest)
Definition: eostools.py:510
virtual void produce(edm::Event &, const edm::EventSetup &) override
Definition: Run.h:42
#define add_param_set(name)
float charge(const HcalQIEShape &fShape, unsigned fAdc, unsigned fCapId) const
ADC [0..127] + capid [0..3] -> fC conversion.
Definition: HcalQIECoder.cc:22