CMS 3D CMS Logo

HFValueStruct.cc
Go to the documentation of this file.
1 #include "HFValueStruct.h"
2 
3 //version -1 will take information from DB (NOT DONE YET)
4 //version 0 has energy corrections on, everything else off
5 //version 1 has energy correction, and pile up slope and interceept on
6 // version 2+ will use defaults of 'do nothing'
7 //
8 //
9 //
10 
11 reco::HFValueStruct::HFValueStruct(const int& version, const std::vector<double>& vect) : v_(version), hfvv_(vect) {
12  //if(v_==-1) hfvv_=SetHfvvFromDB_();
13  //v==99 will always give defaults
14 
15  //version control, add in versions as they appear!!
16  if (v_ == 0 || v_ == 1)
17  doEnCor_ = true;
18  else
19  doEnCor_ = false;
20 
21  if (v_ == 1)
22  doPU_ = true;
23  else
24  doPU_ = false;
25 }
26 
27 int reco::HFValueStruct::indexByIeta(int& ieta) const { return (ieta > 0) ? (ieta - 29 + 13) : (41 + ieta); }
28 int reco::HFValueStruct::ietaByIndex(int& indx) const { return (indx > 13) ? (indx + 29 - 13) : (indx - 41); }
29 //version 0
30 // EnCor=energy corrections,default 1.0, 26 slots
31 
32 //version 1
33 //PUSlope= slope for pile up corrections,default 0.0, 26 slots, 0,1,12,13,24,25 are all defaults always
34 
35 //PUIntercept= intercept slope for pile up corrections,default 1.0, 26 slots, 0,1,12,13,24,25 are all defaults always
36 
37 // returns single value by index
38 
39 double reco::HFValueStruct::EnCor(int ieta) const {
40  int indx = indexByIeta(ieta);
41  if (doEnCor_)
42  return hfvv_[indx];
43  else
44  return 1.0;
45 }
47  int indx = indexByIeta(ieta) + 26;
48  if (doPU_)
49  return hfvv_[indx];
50  else
51  return 0.0;
52 }
54  int indx = indexByIeta(ieta) + 52;
55  if (doPU_)
56  return hfvv_[indx];
57  else
58  return 1.0;
59 }
60 
61 // sets single value by index
63  int indx = indexByIeta(ieta);
64  hfvv_[indx] = val;
65 }
67  int indx = indexByIeta(ieta) + 26;
68  hfvv_[indx] = val;
69 }
71  int indx = indexByIeta(ieta) + 52;
72  hfvv_[indx] = val;
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 
88 std::vector<double> reco::HFValueStruct::PUSlope() const {
89  std::vector<double> vct;
90  if (doPU_) {
91  for (int ii = 0; ii < 13; ii++)
92  vct.push_back(hfvv_[ii + 26]);
93  } else {
94  for (int ii = 0; ii < 13; ii++)
95  vct.push_back(0.0);
96  }
97  return vct;
98 }
99 
100 std::vector<double> reco::HFValueStruct::PUIntercept() const {
101  std::vector<double> vct;
102  if (doPU_) {
103  for (int ii = 0; ii < 13; ii++)
104  vct.push_back(hfvv_[ii + 52]);
105  } else {
106  for (int ii = 0; ii < 13; ii++)
107  vct.push_back(1.0);
108  }
109  return vct;
110 }
111 
112 // set whole vector
113 void reco::HFValueStruct::setEnCor(const std::vector<double>& val) {
114  for (int ii = 0; ii < 13; ii++)
115  hfvv_[ii] = val[ii];
116 }
117 void reco::HFValueStruct::setPUSlope(const std::vector<double>& val) {
118  for (int ii = 0; ii < 13; ii++)
119  hfvv_[ii + 26] = val[ii];
120 }
121 void reco::HFValueStruct::setPUIntercept(const std::vector<double>& val) {
122  for (int ii = 0; ii < 13; ii++)
123  hfvv_[ii + 52] = val[ii];
124 }
void setEnCor(int ieta, double val)
std::vector< double > PUSlope() const
int ietaByIndex(int &indx) const
ii
Definition: cuy.py:589
void setPUSlope(int ieta, double val)
int indexByIeta(int &ieta) const
void setPUIntercept(int ieta, double val)
std::vector< double > EnCor() const
std::vector< double > PUIntercept() const