Go to the documentation of this file.00001 #include "RecoLocalCalo/HcalRecAlgos/interface/HcalHF_PETalgorithm.h"
00002 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00003 #include "Geometry/HcalTowerAlgo/src/HcalHardcodeGeometryData.h"
00004 #include "RecoLocalCalo/HcalRecAlgos/interface/HcalCaloFlagLabels.h"
00005 #include "CondFormats/HcalObjects/interface/HcalChannelQuality.h"
00006 #include "RecoLocalCalo/HcalRecAlgos/interface/HcalSeverityLevelComputer.h"
00007 #include "RecoLocalCalo/HcalRecAlgos/interface/HcalSeverityLevelComputerRcd.h"
00008
00009 #include <algorithm>
00010 #include <cmath>
00011 #include <iostream>
00012
00013 HcalHF_PETalgorithm::HcalHF_PETalgorithm()
00014 {
00015
00016 short_R.clear();
00017 short_R.push_back(0.995);
00018 short_R_29.clear();
00019 short_R_29.push_back(0.995);
00020 short_Energy_Thresh.clear();
00021 short_Energy_Thresh.push_back(50);
00022 short_ET_Thresh.clear();
00023 short_ET_Thresh.push_back(0);
00024
00025 long_R.clear();
00026 long_R.push_back(0.995);
00027 long_R_29.clear();
00028 long_R_29.push_back(0.995);
00029 long_Energy_Thresh.clear();
00030 long_Energy_Thresh.push_back(50);
00031 long_ET_Thresh.clear();
00032 long_ET_Thresh.push_back(0);
00033 HcalAcceptSeverityLevel_=0;
00034 }
00035
00036 HcalHF_PETalgorithm::HcalHF_PETalgorithm(std::vector<double> shortR,
00037 std::vector<double> shortEnergyParams,
00038 std::vector<double> shortETParams,
00039 std::vector<double> longR,
00040 std::vector<double> longEnergyParams,
00041 std::vector<double> longETParams,
00042 int HcalAcceptSeverityLevel,
00043 std::vector<double> shortR29,
00044 std::vector<double> longR29)
00045 {
00046
00047 short_R = shortR;
00048 long_R = longR;
00049 short_R_29 = shortR29;
00050 long_R_29 = longR29;
00051
00052
00053 short_Energy_Thresh.clear();
00054 short_ET_Thresh.clear();
00055 long_Energy_Thresh.clear();
00056 long_ET_Thresh.clear();
00057
00058
00059 short_Energy_Thresh=shortEnergyParams;
00060 short_ET_Thresh=shortETParams;
00061 long_Energy_Thresh=longEnergyParams;
00062 long_ET_Thresh=longETParams;
00063
00064 HcalAcceptSeverityLevel_=HcalAcceptSeverityLevel;
00065 }
00066
00067 HcalHF_PETalgorithm::~HcalHF_PETalgorithm(){}
00068
00069
00070
00071 void HcalHF_PETalgorithm::HFSetFlagFromPET(HFRecHit& hf,
00072 HFRecHitCollection& rec,
00073 HcalChannelQuality* myqual,
00074 const HcalSeverityLevelComputer* mySeverity)
00075 {
00076
00077
00078 int ieta=hf.id().ieta();
00079 int depth=hf.id().depth();
00080 int iphi=hf.id().iphi();
00081 double fEta = 0.5*(theHFEtaBounds[abs(ieta)-29] + theHFEtaBounds[abs(ieta)-28]);
00082 double energy=hf.energy();
00083 double ET = energy/fabs(cosh(fEta));
00084
00085
00086 double ETthresh=0, Energythresh=0;
00087
00088 if (depth==1)
00089 {
00090 Energythresh = long_Energy_Thresh[abs(ieta)-29];
00091 ETthresh = long_ET_Thresh[abs(ieta)-29];
00092 }
00093 else if (depth==2)
00094 {
00095 Energythresh = short_Energy_Thresh[abs(ieta)-29];
00096 ETthresh = short_ET_Thresh[abs(ieta)-29];
00097 }
00098
00099 if (energy<Energythresh || ET < ETthresh)
00100 {
00101 hf.setFlagField(0, HcalCaloFlagLabels::HFLongShort);
00102 hf.setFlagField(0, HcalCaloFlagLabels::HFPET);
00103 return;
00104 }
00105
00106
00107 HcalDetId partner(HcalForward, ieta, iphi, 3-depth);
00108 DetId detpartner=DetId(partner);
00109 const HcalChannelStatus* partnerstatus=myqual->getValues(detpartner.rawId());
00110
00111
00112 if (mySeverity->dropChannel(partnerstatus->getValue() ) )
00113 {
00114 hf.setFlagField(0, HcalCaloFlagLabels::HFLongShort);
00115 hf.setFlagField(0, HcalCaloFlagLabels::HFPET);
00116 return;
00117 }
00118
00119
00120 double Ratio=1;
00121 HFRecHitCollection::const_iterator part=rec.find(partner);
00122 if (part!=rec.end())
00123 {
00124 HcalDetId neighbor(part->detid().rawId());
00125 const uint32_t chanstat = myqual->getValues(neighbor)->getValue();
00126 int SeverityLevel=mySeverity->getSeverityLevel(neighbor, part->flags(),
00127 chanstat);
00128
00129
00130 if (SeverityLevel<=HcalAcceptSeverityLevel_)
00131 Ratio=(energy-part->energy())/(energy+part->energy());
00132 }
00133
00134 double RatioThresh=0;
00135
00136 if (abs(ieta)==29)
00137 {
00138 if (depth==1) RatioThresh=CalcThreshold(energy,long_R_29);
00139 else if (depth==2) RatioThresh=CalcThreshold(energy,short_R_29);
00140 }
00141 else
00142 {
00143 if (depth==1) RatioThresh=CalcThreshold(energy,long_R);
00144 else if (depth==2) RatioThresh=CalcThreshold(energy,short_R);
00145 }
00146 if (Ratio<=RatioThresh)
00147 {
00148 hf.setFlagField(0, HcalCaloFlagLabels::HFLongShort);
00149 hf.setFlagField(0, HcalCaloFlagLabels::HFPET);
00150 return;
00151 }
00152
00153
00154
00155 hf.setFlagField(1, HcalCaloFlagLabels::HFLongShort);
00156 hf.setFlagField(1, HcalCaloFlagLabels::HFPET);
00157 }
00158
00159
00160
00161 double HcalHF_PETalgorithm::CalcThreshold(double abs_x,std::vector<double> params)
00162 {
00163
00164
00165
00166
00167
00168 double threshold=0;
00169 for (std::vector<double>::size_type i=0;i<params.size();++i)
00170 {
00171 threshold+=params[i]*pow(abs_x, (int)i);
00172 }
00173 return threshold;
00174 }
00175