CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 < 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<HcalUpgradeDataFrame>(*db_,digi,threshold_,firstsample_,samplecount_,twosided_);
69 }
70 
virtual bool shouldKeep(const HBHEDataFrame &digi) const
tuple start
Check for commandline option errors.
Definition: dqm_diff.py:58
static const double slope[3]
tuple db
Definition: EcalCondDB.py:151
HcalZSAlgoEnergy(bool markAndPass, int level, int start, int samples, bool twosided)
void prepare(const HcalDbService *db)
int j
Definition: DBlmapReader.cc:9
float getValue(int fCapId) const
get value for capId = 0..3
Definition: HcalPedestal.h:19
unsigned int offset(bool)
const HcalQIECoder * getHcalCoder(const HcalGenericDetId &fId) const
const HcalQIEShape * getHcalShape(const HcalGenericDetId &fId) const
const HcalDbService * db_
tuple level
Definition: testEve_cfg.py:34
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] -&gt; fC conversion.
Definition: HcalQIECoder.cc:22