Go to the documentation of this file.00001 #include "RecoLocalCalo/HcalRecAlgos/interface/HcalHFStatusBitFromDigis.h"
00002 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00003
00004 #include <algorithm>
00005 #include <math.h>
00006 #include <iostream>
00007
00008 HcalHFStatusBitFromDigis::HcalHFStatusBitFromDigis()
00009 {
00010
00011 minthreshold_=40;
00012
00013 firstSample_=1;
00014 samplesToAdd_=3;
00015 expectedPeak_=2;
00016
00017
00018
00019 coef_.push_back(0.93);
00020 coef_.push_back(-0.38275);
00021 coef_.push_back(-0.012667);
00022
00023 HFlongwindowEthresh_=40;
00024 HFlongwindowMinTime_.clear();
00025 HFlongwindowMinTime_.push_back(-10);
00026 HFlongwindowMaxTime_.clear();
00027 HFlongwindowMaxTime_.push_back(8);
00028 HFshortwindowEthresh_=40;
00029 HFshortwindowMinTime_.clear();
00030 HFshortwindowMinTime_.push_back(-10);
00031 HFshortwindowMaxTime_.clear();
00032 HFshortwindowMaxTime_.push_back(8);
00033 }
00034
00035 HcalHFStatusBitFromDigis::HcalHFStatusBitFromDigis(const edm::ParameterSet& HFDigiTimeParams,
00036 const edm::ParameterSet& HFTimeInWindowParams)
00037 {
00038
00039 firstSample_ = HFDigiTimeParams.getParameter<int>("HFdigiflagFirstSample");
00040 samplesToAdd_ = HFDigiTimeParams.getParameter<int>("HFdigiflagSamplesToAdd");
00041 expectedPeak_ = HFDigiTimeParams.getParameter<int>("HFdigiflagExpectedPeak");
00042 minthreshold_ = HFDigiTimeParams.getParameter<double>("HFdigiflagMinEthreshold");
00043 coef_ = HFDigiTimeParams.getParameter<std::vector<double> >("HFdigiflagCoef");
00044
00045
00046 HFlongwindowMinTime_ = HFTimeInWindowParams.getParameter<std::vector<double> >("hflongMinWindowTime");
00047 HFlongwindowMaxTime_ = HFTimeInWindowParams.getParameter<std::vector<double> >("hflongMaxWindowTime");
00048 HFlongwindowEthresh_ = HFTimeInWindowParams.getParameter<double>("hflongEthresh");
00049 HFshortwindowMinTime_ = HFTimeInWindowParams.getParameter<std::vector<double> >("hfshortMinWindowTime");
00050 HFshortwindowMaxTime_ = HFTimeInWindowParams.getParameter<std::vector<double> >("hfshortMaxWindowTime");
00051 HFshortwindowEthresh_ = HFTimeInWindowParams.getParameter<double>("hfshortEthresh");
00052 }
00053
00054 HcalHFStatusBitFromDigis::~HcalHFStatusBitFromDigis(){}
00055
00056 void HcalHFStatusBitFromDigis::resetParamsFromDB(int firstSample, int samplesToAdd, int expectedPeak, double minthreshold, std::vector<double> coef)
00057 {
00058
00059 firstSample_ = firstSample;
00060 samplesToAdd_ = samplesToAdd;
00061 expectedPeak_ = expectedPeak;
00062 minthreshold_ = minthreshold;
00063 coef_ = coef;
00064 }
00065
00066
00067 void HcalHFStatusBitFromDigis::resetFlagTimeSamples(int firstSample, int samplesToAdd, int expectedPeak)
00068 {
00069
00070
00071 firstSample_ = firstSample;
00072 samplesToAdd_ = samplesToAdd;
00073 expectedPeak_ = expectedPeak;
00074 }
00075
00076 void HcalHFStatusBitFromDigis::hfSetFlagFromDigi(HFRecHit& hf,
00077 const HFDataFrame& digi,
00078 const HcalCoder& coder,
00079 const HcalCalibrations& calib)
00080 {
00081
00082
00083
00084
00085 double totalCharge=0;
00086 double peakCharge=0;
00087 double RecomputedEnergy=0;
00088
00089 CaloSamples tool;
00090 coder.adc2fC(digi,tool);
00091
00092
00093 for (int i=0;i<digi.size();++i)
00094 {
00095 int capid=digi.sample(i).capid();
00096 double value = tool[i]-calib.pedestal(capid);
00097
00098
00099
00100 if (i >=firstSample_ && i < firstSample_+samplesToAdd_)
00101 {
00102 totalCharge+=value;
00103 RecomputedEnergy+=value*calib.respcorrgain(capid);
00104 if (i==expectedPeak_) peakCharge=value;
00105 }
00106 }
00107
00108
00109
00110 if (RecomputedEnergy>=minthreshold_)
00111 {
00112
00113 double cutoff=0;
00114 if (coef_.size()>0)
00115 cutoff=coef_[0];
00116
00117
00118 double powRE=1;
00119 double expo_arg=0;
00120 for (unsigned int zz=1;zz<coef_.size();++zz)
00121 {
00122 expo_arg+=coef_[zz]*powRE;
00123 powRE*=RecomputedEnergy;
00124 }
00125 cutoff-=exp(expo_arg);
00126
00127 if (peakCharge/totalCharge<cutoff)
00128 hf.setFlagField(1,HcalCaloFlagLabels::HFDigiTime);
00129 }
00130
00131
00132
00133 if (hf.id().depth()==1)
00134 {
00135 if (hf.energy()>=HFlongwindowEthresh_)
00136 {
00137 float mult=1./hf.energy();
00138 float enPow=1.;
00139 float mintime=0;
00140 float maxtime=0;
00141 for (unsigned int i=0;i<HFlongwindowMinTime_.size();++i)
00142 {
00143 mintime+=HFlongwindowMinTime_[i]*enPow;
00144 maxtime+=HFlongwindowMaxTime_[i]*enPow;
00145 enPow*=mult;
00146 }
00147 if (hf.time()<mintime || hf.time()>maxtime)
00148 hf.setFlagField(1,HcalCaloFlagLabels::HFInTimeWindow);
00149 }
00150 }
00151 else if (hf.id().depth()==2)
00152 {
00153 if (hf.energy()>=HFshortwindowEthresh_)
00154 {
00155 float mult=1./hf.energy();
00156 float enPow=1.;
00157 float mintime=0;
00158 float maxtime=0;
00159 for (unsigned int i=0;i<HFshortwindowMinTime_.size();++i)
00160 {
00161 mintime+=HFshortwindowMinTime_[i]*enPow;
00162 maxtime+=HFshortwindowMaxTime_[i]*enPow;
00163 enPow*=mult;
00164 }
00165 if (hf.time()<mintime || hf.time()>maxtime)
00166 hf.setFlagField(1,HcalCaloFlagLabels::HFInTimeWindow);
00167 }
00168 }
00169
00170 return;
00171 }
00172