Go to the documentation of this file.00001 #include "RecoLocalCalo/HcalRecAlgos/interface/HBHETimeProfileStatusBitSetter.h"
00002 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00003 #include "RecoLocalCalo/HcalRecAlgos/interface/HcalCaloFlagLabels.h"
00004
00005 #include <algorithm>
00006 #include <math.h>
00007 #include <TH1.h>
00008 #include <TF1.h>
00009
00010
00011 HBHETimeProfileStatusBitSetter::HBHETimeProfileStatusBitSetter()
00012 {
00013
00014 R1Min_ = 0.1;
00015 R1Max_ = 0.7;
00016 R2Min_ = 0.2;
00017 R2Max_ = 0.5;
00018 FracLeaderMin_ = 0.4;
00019 FracLeaderMax_ = 0.7;
00020 SlopeMin_ = -1.5;
00021 SlopeMax_ = -0.6;
00022 OuterMin_ = 0.9;
00023 OuterMax_ = 1.0;
00024 EnergyThreshold_=30;
00025 }
00026
00027 HBHETimeProfileStatusBitSetter::HBHETimeProfileStatusBitSetter(double R1Min, double R1Max,
00028 double R2Min, double R2Max,
00029 double FracLeaderMin, double FracLeaderMax,
00030 double SlopeMin, double SlopeMax,
00031 double OuterMin, double OuterMax,
00032 double EnergyThreshold)
00033 {
00034 R1Min_ = R1Min;
00035 R1Max_ = R1Max;
00036 R2Min_ = R2Min;
00037 R2Max_ = R2Max;
00038 FracLeaderMin_ = FracLeaderMin;
00039 FracLeaderMax_ = FracLeaderMax;
00040 SlopeMin_ = SlopeMin;
00041 SlopeMax_ = SlopeMax;
00042 OuterMin_ = OuterMin;
00043 OuterMax_ = OuterMax;
00044 EnergyThreshold_ = EnergyThreshold;
00045 }
00046
00047 HBHETimeProfileStatusBitSetter::~HBHETimeProfileStatusBitSetter(){}
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057 void HBHETimeProfileStatusBitSetter::hbheSetTimeFlagsFromDigi(HBHERecHitCollection * hbhe, const std::vector<HBHEDataFrame>& udigi, const std::vector<int>& RecHitIndex)
00058 {
00059
00060 bool Bits[4]={false, false, false, false};
00061 std::vector<HBHEDataFrame> digi = const_cast<std::vector<HBHEDataFrame>&>(udigi);
00062 std::sort(digi.begin(), digi.end(), compare_digi_energy());
00063 std::vector<double> PulseShape;
00064 int DigiSize=0;
00065
00066 int LeadingPhi=0;
00067 bool FoundLeadingChannel=false;
00068 for(std::vector<HBHEDataFrame>::const_iterator itDigi = digi.begin(); itDigi!=digi.end(); itDigi++)
00069 {
00070 if(!FoundLeadingChannel)
00071 {
00072
00073 LeadingPhi = itDigi->id().iphi();
00074 DigiSize=(*itDigi).size();
00075 PulseShape.clear();
00076 PulseShape.resize(DigiSize,0);
00077 FoundLeadingChannel=true;
00078 }
00079 if(abs(LeadingPhi - itDigi->id().iphi())<2)
00080 for(int i=0; i!=DigiSize; i++)
00081 PulseShape[i]+=itDigi->sample(i).nominal_fC();
00082
00083 }
00084
00085
00086
00087 if(RecHitIndex.size()>0)
00088 {
00089 double FracInLeader=-1;
00090
00091 double R1=-1;
00092 double R2=-1;
00093 double OuterEnergy=-1;
00094 double TotalEnergy=0;
00095 int PeakPosition=0;
00096
00097 for(int i=0; i!=DigiSize; i++)
00098 {
00099 if(PulseShape[i]>PulseShape[PeakPosition])
00100 PeakPosition=i;
00101 TotalEnergy+=PulseShape[i];
00102 }
00103
00104
00105 if(PeakPosition < (DigiSize-2))
00106 {
00107 R1 = PulseShape[PeakPosition+1]/PulseShape[PeakPosition];
00108 R2 = PulseShape[PeakPosition+2]/PulseShape[PeakPosition+1];
00109 }
00110
00111 FracInLeader = PulseShape[PeakPosition]/TotalEnergy;
00112
00113 if((PeakPosition > 0) && (PeakPosition < (DigiSize-2)))
00114 {
00115 OuterEnergy = 1. -((PulseShape[PeakPosition - 1] +
00116 PulseShape[PeakPosition] +
00117 PulseShape[PeakPosition + 1] +
00118 PulseShape[PeakPosition + 2] )
00119 / TotalEnergy);
00120
00121 }
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133 if (R1!=-1 && R2!=-1)
00134 Bits[0] = (R1Min_ > R1) || (R1Max_ < R1) || (R2Min_ > R2) || (R2Max_ < R2);
00135 if (FracInLeader!=-1)
00136 Bits[1] = (FracInLeader < FracLeaderMin_) || (FracInLeader > FracLeaderMax_);
00137 if (OuterEnergy!=-1)
00138 Bits[2] = (OuterEnergy < OuterMin_) || (OuterEnergy > OuterMax_);
00139
00140 Bits[3] = false;
00141
00142 }
00143 else
00144 {
00145
00146 Bits[0]=false;
00147 Bits[1]=false;
00148 Bits[2]=false;
00149 Bits[3]=true;
00150
00151 }
00152
00153 for(unsigned int i=0; i!=RecHitIndex.size(); i++)
00154 {
00155
00156
00157 (*hbhe)[RecHitIndex.at(i)].setFlagField(Bits[0],HcalCaloFlagLabels::HSCP_R1R2);
00158 (*hbhe)[RecHitIndex.at(i)].setFlagField(Bits[1],HcalCaloFlagLabels::HSCP_FracLeader);
00159 (*hbhe)[RecHitIndex.at(i)].setFlagField(Bits[2],HcalCaloFlagLabels::HSCP_OuterEnergy);
00160 (*hbhe)[RecHitIndex.at(i)].setFlagField(Bits[3],HcalCaloFlagLabels::HSCP_ExpFit);
00161
00162 }
00163
00164
00165
00166 }
00167