00001 00002 #include "HFValueStruct.h" 00003 #include <stdio.h> 00004 #include <stdlib.h> 00005 //version -1 will take information from DB (NOT DONE YET) 00006 //version 0 has energy corrections on, everything else off 00007 //version 1 has energy correction, and pile up slope and interceept on 00008 // version 2+ will use defaults of 'do nothing' 00009 // 00010 // 00011 // 00012 00013 00014 reco::HFValueStruct::HFValueStruct(const int& version, const std::vector<double>& vect): v_(version),hfvv_(vect) { 00015 //if(v_==-1) hfvv_=SetHfvvFromDB_(); 00016 //v==99 will always give defaults 00017 00018 //version control, add in versions as they appear!! 00019 if(v_==0 || v_==1) doEnCor_=true; 00020 else doEnCor_=false; 00021 00022 if(v_==1) doPU_=true; 00023 else doPU_=false; 00024 00025 00026 } 00027 00028 00029 00030 int reco::HFValueStruct::indexByIeta(int& ieta)const{ 00031 return (ieta>0)?(abs(ieta)-29+13):(41-abs(ieta)); 00032 } 00033 int reco::HFValueStruct::ietaByIndex(int& indx)const{ 00034 return (indx>13)?(indx+29-13):(indx-41); 00035 } 00036 //version 0 00037 // EnCor=energy corrections,default 1.0, 26 slots 00038 00039 //version 1 00040 //PUSlope= slope for pile up corrections,default 0.0, 26 slots, 0,1,12,13,24,25 are all defaults always 00041 00042 //PUIntercept= intercept slope for pile up corrections,default 1.0, 26 slots, 0,1,12,13,24,25 are all defaults always 00043 00044 00045 00046 00047 // returns single value by index 00048 00049 double reco::HFValueStruct::EnCor(int ieta)const{ 00050 int indx=indexByIeta(ieta); 00051 if(doEnCor_) return hfvv_[indx]; 00052 else return 1.0;} 00053 double reco::HFValueStruct::PUSlope(int ieta)const{ 00054 int indx=indexByIeta(ieta)+26; 00055 if(doPU_) return hfvv_[indx]; 00056 else return 0.0;} 00057 double reco::HFValueStruct::PUIntercept(int ieta)const{ 00058 int indx=indexByIeta(ieta)+52; 00059 if(doPU_) return hfvv_[indx]; 00060 else return 1.0;} 00061 00062 // sets single value by index 00063 void reco::HFValueStruct::setEnCor(int ieta,double val){ 00064 int indx=indexByIeta(ieta); 00065 hfvv_[indx]=val;} 00066 void reco::HFValueStruct::setPUSlope(int ieta,double val){ 00067 int indx=indexByIeta(ieta)+26; 00068 hfvv_[indx]=val;} 00069 void reco::HFValueStruct::setPUIntercept(int ieta,double val){ 00070 int indx=indexByIeta(ieta)+52; 00071 hfvv_[indx]=val;} 00072 00073 00074 00075 // returns whole vector 00076 std::vector<double> reco::HFValueStruct::EnCor()const{ 00077 std::vector<double> vct; 00078 if(doEnCor_){ 00079 for(int ii=0;ii<13;ii++) 00080 vct.push_back(hfvv_[ii]); 00081 }else{ 00082 for(int ii=0;ii<13;ii++) 00083 vct.push_back(1.0); 00084 } 00085 return vct;} 00086 00087 std::vector<double> reco::HFValueStruct::PUSlope()const{ 00088 std::vector<double> vct; 00089 if(doPU_){ 00090 for(int ii=0;ii<13;ii++) 00091 vct.push_back(hfvv_[ii+26]); 00092 }else{ 00093 for(int ii=0;ii<13;ii++) 00094 vct.push_back(0.0); 00095 } 00096 return vct;} 00097 00098 std::vector<double> reco::HFValueStruct::PUIntercept()const{ 00099 std::vector<double> vct; 00100 if(doPU_){ 00101 for(int ii=0;ii<13;ii++) 00102 vct.push_back(hfvv_[ii+52]); 00103 }else{ 00104 for(int ii=0;ii<13;ii++) 00105 vct.push_back(1.0); 00106 } 00107 return vct;} 00108 00109 // set whole vector 00110 void reco::HFValueStruct::setEnCor(const std::vector<double>& val){ 00111 for(int ii=0;ii<13;ii++) hfvv_[ii]=val[ii];} 00112 void reco::HFValueStruct::setPUSlope(const std::vector<double>& val){ 00113 for(int ii=0;ii<13;ii++) hfvv_[ii+26]=val[ii];} 00114 void reco::HFValueStruct::setPUIntercept(const std::vector<double>& val){ 00115 for(int ii=0;ii<13;ii++) hfvv_[ii+52]=val[ii]; 00116 }