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 coef0_= 0.93;
00020 coef1_ = -0.38275;
00021 coef2_ = -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 coef0_ = HFDigiTimeParams.getParameter<double>("HFdigiflagCoef0");
00044 coef1_ = HFDigiTimeParams.getParameter<double>("HFdigiflagCoef1");
00045 coef2_ = HFDigiTimeParams.getParameter<double>("HFdigiflagCoef2");
00046
00047
00048 HFlongwindowMinTime_ = HFTimeInWindowParams.getParameter<std::vector<double> >("hflongMinWindowTime");
00049 HFlongwindowMaxTime_ = HFTimeInWindowParams.getParameter<std::vector<double> >("hflongMaxWindowTime");
00050 HFlongwindowEthresh_ = HFTimeInWindowParams.getParameter<double>("hflongEthresh");
00051 HFshortwindowMinTime_ = HFTimeInWindowParams.getParameter<std::vector<double> >("hfshortMinWindowTime");
00052 HFshortwindowMaxTime_ = HFTimeInWindowParams.getParameter<std::vector<double> >("hfshortMaxWindowTime");
00053 HFshortwindowEthresh_ = HFTimeInWindowParams.getParameter<double>("hfshortEthresh");
00054 }
00055
00056 HcalHFStatusBitFromDigis::~HcalHFStatusBitFromDigis(){}
00057
00058 void HcalHFStatusBitFromDigis::resetFlagTimeSamples(int firstSample, int samplesToAdd, int expectedPeak)
00059 {
00060
00061
00062 firstSample_ = firstSample;
00063 samplesToAdd_ = samplesToAdd;
00064 expectedPeak_ = expectedPeak;
00065 }
00066
00067 void HcalHFStatusBitFromDigis::hfSetFlagFromDigi(HFRecHit& hf,
00068 const HFDataFrame& digi,
00069 const HcalCoder& coder,
00070 const HcalCalibrations& calib)
00071 {
00072
00073
00074
00075
00076 double totalCharge=0;
00077 double peakCharge=0;
00078 double RecomputedEnergy=0;
00079
00080 CaloSamples tool;
00081 coder.adc2fC(digi,tool);
00082
00083
00084 for (int i=0;i<digi.size();++i)
00085 {
00086 int capid=digi.sample(i).capid();
00087 double value = tool[i]-calib.pedestal(capid);
00088
00089
00090
00091 if (i >=firstSample_ && i < firstSample_+samplesToAdd_)
00092 {
00093 totalCharge+=value;
00094 RecomputedEnergy+=value*calib.respcorrgain(capid);
00095 if (i==expectedPeak_) peakCharge=value;
00096 }
00097 }
00098
00099
00100
00101
00102 if (RecomputedEnergy>=minthreshold_)
00103 {
00104
00105 double cutoff=coef0_-exp(coef1_+coef2_*RecomputedEnergy);
00106
00107 if (peakCharge/totalCharge<cutoff)
00108 hf.setFlagField(1,HcalCaloFlagLabels::HFDigiTime);
00109 }
00110
00111
00112
00113 if (hf.id().depth()==1)
00114 {
00115 if (hf.energy()>=HFlongwindowEthresh_)
00116 {
00117 float mult=1./hf.energy();
00118 float enPow=1.;
00119 float mintime=0;
00120 float maxtime=0;
00121 for (unsigned int i=0;i<HFlongwindowMinTime_.size();++i)
00122 {
00123 mintime+=HFlongwindowMinTime_[i]*enPow;
00124 maxtime+=HFlongwindowMaxTime_[i]*enPow;
00125 enPow*=mult;
00126 }
00127 if (hf.time()<mintime || hf.time()>maxtime)
00128 hf.setFlagField(1,HcalCaloFlagLabels::HFInTimeWindow);
00129 }
00130 }
00131 else if (hf.id().depth()==2)
00132 {
00133 if (hf.energy()>=HFshortwindowEthresh_)
00134 {
00135 float mult=1./hf.energy();
00136 float enPow=1.;
00137 float mintime=0;
00138 float maxtime=0;
00139 for (unsigned int i=0;i<HFshortwindowMinTime_.size();++i)
00140 {
00141 mintime+=HFshortwindowMinTime_[i]*enPow;
00142 maxtime+=HFshortwindowMaxTime_[i]*enPow;
00143 enPow*=mult;
00144 }
00145 if (hf.time()<mintime || hf.time()>maxtime)
00146 hf.setFlagField(1,HcalCaloFlagLabels::HFInTimeWindow);
00147 }
00148 }
00149
00150 return;
00151 }
00152