CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HFValueStruct.cc
Go to the documentation of this file.
1 
2 #include "HFValueStruct.h"
3 #include <stdio.h>
4 #include <stdlib.h>
5 //version -1 will take information from DB (NOT DONE YET)
6 //version 0 has energy corrections on, everything else off
7 //version 1 has energy correction, and pile up slope and interceept on
8 // version 2+ will use defaults of 'do nothing'
9 //
10 //
11 //
12 
13 
14 reco::HFValueStruct::HFValueStruct(const int& version, const std::vector<double>& vect): v_(version),hfvv_(vect) {
15  //if(v_==-1) hfvv_=SetHfvvFromDB_();
16  //v==99 will always give defaults
17 
18  //version control, add in versions as they appear!!
19  if(v_==0 || v_==1) doEnCor_=true;
20  else doEnCor_=false;
21 
22  if(v_==1) doPU_=true;
23  else doPU_=false;
24 
25 
26 }
27 
28 
29 
31  return (ieta>0)?(abs(ieta)-29+13):(41-abs(ieta));
32 }
34  return (indx>13)?(indx+29-13):(indx-41);
35 }
36 //version 0
37 // EnCor=energy corrections,default 1.0, 26 slots
38 
39 //version 1
40 //PUSlope= slope for pile up corrections,default 0.0, 26 slots, 0,1,12,13,24,25 are all defaults always
41 
42 //PUIntercept= intercept slope for pile up corrections,default 1.0, 26 slots, 0,1,12,13,24,25 are all defaults always
43 
44 
45 
46 
47 // returns single value by index
48 
49 double reco::HFValueStruct::EnCor(int ieta)const{
50  int indx=indexByIeta(ieta);
51  if(doEnCor_) return hfvv_[indx];
52  else return 1.0;}
53 double reco::HFValueStruct::PUSlope(int ieta)const{
54  int indx=indexByIeta(ieta)+26;
55  if(doPU_) return hfvv_[indx];
56  else return 0.0;}
57 double reco::HFValueStruct::PUIntercept(int ieta)const{
58  int indx=indexByIeta(ieta)+52;
59  if(doPU_) return hfvv_[indx];
60  else return 1.0;}
61 
62 // sets single value by index
63 void reco::HFValueStruct::setEnCor(int ieta,double val){
64  int indx=indexByIeta(ieta);
65  hfvv_[indx]=val;}
66 void reco::HFValueStruct::setPUSlope(int ieta,double val){
67  int indx=indexByIeta(ieta)+26;
68  hfvv_[indx]=val;}
70  int indx=indexByIeta(ieta)+52;
71  hfvv_[indx]=val;}
72 
73 
74 
75 // returns whole vector
76 std::vector<double> reco::HFValueStruct::EnCor()const{
77  std::vector<double> vct;
78  if(doEnCor_){
79  for(int ii=0;ii<13;ii++)
80  vct.push_back(hfvv_[ii]);
81  }else{
82  for(int ii=0;ii<13;ii++)
83  vct.push_back(1.0);
84  }
85  return vct;}
86 
87 std::vector<double> reco::HFValueStruct::PUSlope()const{
88  std::vector<double> vct;
89  if(doPU_){
90  for(int ii=0;ii<13;ii++)
91  vct.push_back(hfvv_[ii+26]);
92  }else{
93  for(int ii=0;ii<13;ii++)
94  vct.push_back(0.0);
95  }
96  return vct;}
97 
98 std::vector<double> reco::HFValueStruct::PUIntercept()const{
99  std::vector<double> vct;
100  if(doPU_){
101  for(int ii=0;ii<13;ii++)
102  vct.push_back(hfvv_[ii+52]);
103  }else{
104  for(int ii=0;ii<13;ii++)
105  vct.push_back(1.0);
106  }
107  return vct;}
108 
109 // set whole vector
110 void reco::HFValueStruct::setEnCor(const std::vector<double>& val){
111  for(int ii=0;ii<13;ii++) hfvv_[ii]=val[ii];}
112 void reco::HFValueStruct::setPUSlope(const std::vector<double>& val){
113  for(int ii=0;ii<13;ii++) hfvv_[ii+26]=val[ii];}
114 void reco::HFValueStruct::setPUIntercept(const std::vector<double>& val){
115  for(int ii=0;ii<13;ii++) hfvv_[ii+52]=val[ii];
116 }
int ietaByIndex(int &indx) const
void setEnCor(int ieta, double val)
std::vector< double > EnCor() const
std::vector< double > PUSlope() const
int ii
Definition: cuy.py:588
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
void setPUSlope(int ieta, double val)
std::vector< double > PUIntercept() const
int indexByIeta(int &ieta) const
void setPUIntercept(int ieta, double val)