CMS 3D CMS Logo

HcalZSAlgoEnergy.cc
Go to the documentation of this file.
4 #include "HcalZSAlgoEnergy.h"
5 #include <iostream>
6 
7 HcalZSAlgoEnergy::HcalZSAlgoEnergy(bool mp, int level, int start, int samples, bool twosided)
8  : HcalZeroSuppressionAlgo(mp), threshold_(level), firstsample_(start), samplecount_(samples), twosided_(twosided) {}
9 
10 namespace ZSEnergy_impl {
11 
12  template <class DIGI>
13  bool keepMe(const HcalDbService &db, const DIGI &inp, int threshold, int firstSample, int samples, bool twosided) {
14  bool keepIt = false;
15  const HcalQIECoder *channelCoder = db.getHcalCoder(inp.id());
16  const HcalQIEShape *shape = db.getHcalShape(channelCoder);
17 
18  // determine average pedestal for channel
19  float pedsum = 0, pedave = 0, offset = 0, slope = 0;
20  const HcalPedestal *ped = db.getPedestal(inp.id());
21  for (int j = 0; j < 4; j++) {
22  pedave += ped->getValue(j) / 4.0;
23  offset += channelCoder->charge(*shape, 0, j) / 4.0;
24  slope += channelCoder->charge(*shape, 1, j) / 4.0;
25  }
26  slope -= offset;
27  pedave -= offset;
28  pedave /= slope;
29 
30  int sum = 0;
31 
32  for (int j = 0; j < samples && j + firstSample < (int)inp.size(); j++) {
33  sum += inp[j + firstSample].adc();
34  pedsum += pedave;
35  }
36  // int presum=sum;
37  sum -= (int)(pedsum);
38 
39  if (sum >= threshold)
40  keepIt = true;
41  else if (sum <= (-threshold) && twosided)
42  keepIt = true;
43  /*
44  else
45  std::cout << inp.id() << " " << sum << ":" << presum << " " << threshold
46  << " " << pedsum << " " << pedave
47  << " " << offset << " " << slope
48  << std::endl;
49  */
50  return keepIt;
51  }
52 } // namespace ZSEnergy_impl
53 
55  return ZSEnergy_impl::keepMe<HBHEDataFrame>(*db_, digi, threshold_, firstsample_, samplecount_, twosided_);
56 }
57 bool HcalZSAlgoEnergy::shouldKeep(const HODataFrame &digi) const {
58  return ZSEnergy_impl::keepMe<HODataFrame>(*db_, digi, threshold_, firstsample_, samplecount_, twosided_);
59 }
60 bool HcalZSAlgoEnergy::shouldKeep(const HFDataFrame &digi) const {
61  return ZSEnergy_impl::keepMe<HFDataFrame>(*db_, digi, threshold_, firstsample_, samplecount_, twosided_);
62 }
64  return ZSEnergy_impl::keepMe<QIE10DataFrame>(*db_, digi, threshold_, firstsample_, samplecount_, twosided_);
65 }
67  return ZSEnergy_impl::keepMe<QIE11DataFrame>(*db_, digi, threshold_, firstsample_, samplecount_, twosided_);
68 }
69 
70 void HcalZSAlgoEnergy::prepare(const HcalDbService *db) { db_ = db; }
71 void HcalZSAlgoEnergy::done() { db_ = nullptr; }
Definition: start.py:1
static const double slope[3]
HcalZSAlgoEnergy(bool markAndPass, int level, int start, int samples, bool twosided)
void prepare(const HcalDbService *db)
float getValue(int fCapId) const
get value for capId = 0..3
Definition: HcalPedestal.h:21
const HcalQIECoder * getHcalCoder(const HcalGenericDetId &fId) const
const HcalQIEShape * getHcalShape(const HcalGenericDetId &fId) const
const HcalDbService * db_
bool shouldKeep(const HBHEDataFrame &digi) const override
const HcalPedestal * getPedestal(const HcalGenericDetId &fId) const
bool keepMe(const HcalDbService &db, const DIGI &inp, int threshold, int firstSample, int samples, bool twosided)
float charge(const HcalQIEShape &fShape, unsigned fAdc, unsigned fCapId) const
ADC [0..127] + capid [0..3] -> fC conversion.
Definition: HcalQIECoder.cc:20