Go to the documentation of this file.00001 #include "HcalZSAlgoEnergy.h"
00002 #include "CondFormats/HcalObjects/interface/HcalPedestal.h"
00003 #include "CondFormats/HcalObjects/interface/HcalQIEShape.h"
00004 #include "CondFormats/HcalObjects/interface/HcalQIECoder.h"
00005 #include <iostream>
00006
00007 HcalZSAlgoEnergy::HcalZSAlgoEnergy(bool mp,int level, int start, int samples, bool twosided) :
00008 HcalZeroSuppressionAlgo(mp),
00009 threshold_(level),
00010 firstsample_(start),
00011 samplecount_(samples),
00012 twosided_(twosided)
00013 {
00014 }
00015
00016 namespace ZSEnergy_impl {
00017
00018 template <class DIGI>
00019 bool keepMe(const HcalDbService& db, const DIGI& inp, int threshold, int firstSample, int samples, bool twosided) {
00020 bool keepIt=false;
00021 const HcalQIECoder* channelCoder = db.getHcalCoder (inp.id());
00022 const HcalQIEShape* shape = db.getHcalShape (channelCoder);
00023
00024
00025 float pedsum=0, pedave=0, offset=0, slope=0;
00026 const HcalPedestal* ped=db.getPedestal(inp.id());
00027 for (int j=0; j<4; j++) {
00028 pedave+=ped->getValue(j)/4.0;
00029 offset+=channelCoder->charge(*shape,0,j)/4.0;
00030 slope+=channelCoder->charge(*shape,1,j)/4.0;
00031 }
00032 slope-=offset;
00033 pedave-=offset;
00034 pedave/=slope;
00035
00036 int sum=0;
00037
00038 for (int j=0; j<samples && j+firstSample < inp.size(); j++) {
00039 sum+=inp[j+firstSample].adc();
00040 pedsum+=pedave;
00041 }
00042
00043 sum-=(int)(pedsum);
00044
00045 if (sum>=threshold) keepIt=true;
00046 else if (sum<=(-threshold) && twosided) keepIt=true;
00047
00048
00049
00050
00051
00052
00053
00054 return keepIt;
00055 }
00056 }
00057
00058 bool HcalZSAlgoEnergy::shouldKeep(const HBHEDataFrame& digi) const {
00059 return ZSEnergy_impl::keepMe<HBHEDataFrame>(*db_,digi,threshold_,firstsample_,samplecount_,twosided_);
00060 }
00061 bool HcalZSAlgoEnergy::shouldKeep(const HODataFrame& digi) const {
00062 return ZSEnergy_impl::keepMe<HODataFrame>(*db_,digi,threshold_,firstsample_,samplecount_,twosided_);
00063 }
00064 bool HcalZSAlgoEnergy::shouldKeep(const HFDataFrame& digi) const {
00065 return ZSEnergy_impl::keepMe<HFDataFrame>(*db_,digi,threshold_,firstsample_,samplecount_,twosided_);
00066 }
00067
00068 void HcalZSAlgoEnergy::prepare(const HcalDbService* db) { db_=db; }
00069 void HcalZSAlgoEnergy::done() { db_=0; }