CMS 3D CMS Logo

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