CMS 3D CMS Logo

HFValueStruct.cc
Go to the documentation of this file.
1 
2 #include "HFValueStruct.h"
3 #include <cstdio>
4 #include <cstdlib>
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 reco::HFValueStruct::HFValueStruct(const int& version, const std::vector<double>& vect) : v_(version), hfvv_(vect) {
14  //if(v_==-1) hfvv_=SetHfvvFromDB_();
15  //v==99 will always give defaults
16 
17  //version control, add in versions as they appear!!
18  if (v_ == 0 || v_ == 1)
19  doEnCor_ = true;
20  else
21  doEnCor_ = false;
22 
23  if (v_ == 1)
24  doPU_ = true;
25  else
26  doPU_ = false;
27 }
28 
29 int reco::HFValueStruct::indexByIeta(int& ieta) const { return (ieta > 0) ? (abs(ieta) - 29 + 13) : (41 - abs(ieta)); }
30 int reco::HFValueStruct::ietaByIndex(int& indx) const { return (indx > 13) ? (indx + 29 - 13) : (indx - 41); }
31 //version 0
32 // EnCor=energy corrections,default 1.0, 26 slots
33 
34 //version 1
35 //PUSlope= slope for pile up corrections,default 0.0, 26 slots, 0,1,12,13,24,25 are all defaults always
36 
37 //PUIntercept= intercept slope for pile up corrections,default 1.0, 26 slots, 0,1,12,13,24,25 are all defaults always
38 
39 // returns single value by index
40 
41 double reco::HFValueStruct::EnCor(int ieta) const {
42  int indx = indexByIeta(ieta);
43  if (doEnCor_)
44  return hfvv_[indx];
45  else
46  return 1.0;
47 }
49  int indx = indexByIeta(ieta) + 26;
50  if (doPU_)
51  return hfvv_[indx];
52  else
53  return 0.0;
54 }
56  int indx = indexByIeta(ieta) + 52;
57  if (doPU_)
58  return hfvv_[indx];
59  else
60  return 1.0;
61 }
62 
63 // sets single value by index
65  int indx = indexByIeta(ieta);
66  hfvv_[indx] = val;
67 }
69  int indx = indexByIeta(ieta) + 26;
70  hfvv_[indx] = val;
71 }
73  int indx = indexByIeta(ieta) + 52;
74  hfvv_[indx] = val;
75 }
76 
77 // returns whole vector
78 std::vector<double> reco::HFValueStruct::EnCor() const {
79  std::vector<double> vct;
80  if (doEnCor_) {
81  for (int ii = 0; ii < 13; ii++)
82  vct.push_back(hfvv_[ii]);
83  } else {
84  for (int ii = 0; ii < 13; ii++)
85  vct.push_back(1.0);
86  }
87  return vct;
88 }
89 
90 std::vector<double> reco::HFValueStruct::PUSlope() const {
91  std::vector<double> vct;
92  if (doPU_) {
93  for (int ii = 0; ii < 13; ii++)
94  vct.push_back(hfvv_[ii + 26]);
95  } else {
96  for (int ii = 0; ii < 13; ii++)
97  vct.push_back(0.0);
98  }
99  return vct;
100 }
101 
102 std::vector<double> reco::HFValueStruct::PUIntercept() const {
103  std::vector<double> vct;
104  if (doPU_) {
105  for (int ii = 0; ii < 13; ii++)
106  vct.push_back(hfvv_[ii + 52]);
107  } else {
108  for (int ii = 0; ii < 13; ii++)
109  vct.push_back(1.0);
110  }
111  return vct;
112 }
113 
114 // set whole vector
115 void reco::HFValueStruct::setEnCor(const std::vector<double>& val) {
116  for (int ii = 0; ii < 13; ii++)
117  hfvv_[ii] = val[ii];
118 }
119 void reco::HFValueStruct::setPUSlope(const std::vector<double>& val) {
120  for (int ii = 0; ii < 13; ii++)
121  hfvv_[ii + 26] = val[ii];
122 }
123 void reco::HFValueStruct::setPUIntercept(const std::vector<double>& val) {
124  for (int ii = 0; ii < 13; ii++)
125  hfvv_[ii + 52] = val[ii];
126 }
int ietaByIndex(int &indx) const
void setEnCor(int ieta, double val)
std::vector< double > EnCor() const
std::vector< double > PUSlope() const
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< double > hfvv_
Definition: HFValueStruct.h:37
ii
Definition: cuy.py:590
void setPUSlope(int ieta, double val)
std::vector< double > PUIntercept() const
int indexByIeta(int &ieta) const
void setPUIntercept(int ieta, double val)