Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:24:51

0001 #include "HFValueStruct.h"
0002 
0003 //version -1 will take information from DB (NOT DONE YET)
0004 //version 0 has energy corrections on, everything else off
0005 //version 1 has energy correction, and pile up slope and interceept on
0006 // version 2+ will use defaults of 'do nothing'
0007 //
0008 //
0009 //
0010 
0011 reco::HFValueStruct::HFValueStruct(const int& version, const std::vector<double>& vect) : v_(version), hfvv_(vect) {
0012   //if(v_==-1) hfvv_=SetHfvvFromDB_();
0013   //v==99 will always give defaults
0014 
0015   //version control, add in versions as they appear!!
0016   if (v_ == 0 || v_ == 1)
0017     doEnCor_ = true;
0018   else
0019     doEnCor_ = false;
0020 
0021   if (v_ == 1)
0022     doPU_ = true;
0023   else
0024     doPU_ = false;
0025 }
0026 
0027 int reco::HFValueStruct::indexByIeta(int& ieta) const { return (ieta > 0) ? (ieta - 29 + 13) : (41 + ieta); }
0028 int reco::HFValueStruct::ietaByIndex(int& indx) const { return (indx > 13) ? (indx + 29 - 13) : (indx - 41); }
0029 //version 0
0030 // EnCor=energy corrections,default 1.0, 26 slots
0031 
0032 //version 1
0033 //PUSlope= slope for pile up corrections,default 0.0, 26 slots, 0,1,12,13,24,25 are all defaults always
0034 
0035 //PUIntercept= intercept  slope for pile up corrections,default 1.0, 26 slots, 0,1,12,13,24,25 are all defaults always
0036 
0037 // returns single value by index
0038 
0039 double reco::HFValueStruct::EnCor(int ieta) const {
0040   int indx = indexByIeta(ieta);
0041   if (doEnCor_)
0042     return hfvv_[indx];
0043   else
0044     return 1.0;
0045 }
0046 double reco::HFValueStruct::PUSlope(int ieta) const {
0047   int indx = indexByIeta(ieta) + 26;
0048   if (doPU_)
0049     return hfvv_[indx];
0050   else
0051     return 0.0;
0052 }
0053 double reco::HFValueStruct::PUIntercept(int ieta) const {
0054   int indx = indexByIeta(ieta) + 52;
0055   if (doPU_)
0056     return hfvv_[indx];
0057   else
0058     return 1.0;
0059 }
0060 
0061 // sets single value by index
0062 void reco::HFValueStruct::setEnCor(int ieta, double val) {
0063   int indx = indexByIeta(ieta);
0064   hfvv_[indx] = val;
0065 }
0066 void reco::HFValueStruct::setPUSlope(int ieta, double val) {
0067   int indx = indexByIeta(ieta) + 26;
0068   hfvv_[indx] = val;
0069 }
0070 void reco::HFValueStruct::setPUIntercept(int ieta, double val) {
0071   int indx = indexByIeta(ieta) + 52;
0072   hfvv_[indx] = val;
0073 }
0074 
0075 // returns whole vector
0076 std::vector<double> reco::HFValueStruct::EnCor() const {
0077   std::vector<double> vct;
0078   if (doEnCor_) {
0079     for (int ii = 0; ii < 13; ii++)
0080       vct.push_back(hfvv_[ii]);
0081   } else {
0082     for (int ii = 0; ii < 13; ii++)
0083       vct.push_back(1.0);
0084   }
0085   return vct;
0086 }
0087 
0088 std::vector<double> reco::HFValueStruct::PUSlope() const {
0089   std::vector<double> vct;
0090   if (doPU_) {
0091     for (int ii = 0; ii < 13; ii++)
0092       vct.push_back(hfvv_[ii + 26]);
0093   } else {
0094     for (int ii = 0; ii < 13; ii++)
0095       vct.push_back(0.0);
0096   }
0097   return vct;
0098 }
0099 
0100 std::vector<double> reco::HFValueStruct::PUIntercept() const {
0101   std::vector<double> vct;
0102   if (doPU_) {
0103     for (int ii = 0; ii < 13; ii++)
0104       vct.push_back(hfvv_[ii + 52]);
0105   } else {
0106     for (int ii = 0; ii < 13; ii++)
0107       vct.push_back(1.0);
0108   }
0109   return vct;
0110 }
0111 
0112 // set whole vector
0113 void reco::HFValueStruct::setEnCor(const std::vector<double>& val) {
0114   for (int ii = 0; ii < 13; ii++)
0115     hfvv_[ii] = val[ii];
0116 }
0117 void reco::HFValueStruct::setPUSlope(const std::vector<double>& val) {
0118   for (int ii = 0; ii < 13; ii++)
0119     hfvv_[ii + 26] = val[ii];
0120 }
0121 void reco::HFValueStruct::setPUIntercept(const std::vector<double>& val) {
0122   for (int ii = 0; ii < 13; ii++)
0123     hfvv_[ii + 52] = val[ii];
0124 }