CMS 3D CMS Logo

LoadEPDB.h
Go to the documentation of this file.
1 #ifndef RecoHI_HiEvtPlaneAlgos_LoadEPDB_h
2 #define RecoHI_HiEvtPlaneAlgos_LoadEPDB_h
3 
4 // system include files
5 #include <memory>
6 #include <iostream>
7 #include <string>
8 
9 // user include files
11 
13 
15 
19 #include <vector>
20 
21 class LoadEPDB {
22 public:
23  explicit LoadEPDB(const RPFlatParams& flatparmsDB_, HiEvtPlaneFlatten** flat) {
24  int Hbins;
25  int Obins;
26  int flatTableSize = flatparmsDB_.m_table.size();
27  genFlatPsi_ = kTRUE;
28  if (flatTableSize < flat[0]->getHBins() + 2 * flat[0]->getOBins()) {
29  genFlatPsi_ = kFALSE;
30  } else {
31  Hbins = flat[0]->getHBins();
32  Obins = flat[0]->getOBins();
33 
34  for (int i = 0; i < flatTableSize; i++) {
35  const RPFlatParams::EP* thisBin = &(flatparmsDB_.m_table[i]);
36  for (int j = 0; j < hi::NumEPNames; j++) {
37  int indx = thisBin->RPNameIndx[j];
38  if (indx < 0 || indx >= hi::NumEPNames) {
39  genFlatPsi_ = kFALSE;
40  break;
41  }
42  if (indx >= 0) {
43  if (i < Hbins) {
44  flat[indx]->setXDB(i, thisBin->x[j]);
45  flat[indx]->setYDB(i, thisBin->y[j]);
46  } else if (i >= Hbins && i < Hbins + Obins) {
47  flat[indx]->setXoffDB(i - Hbins, thisBin->x[j]);
48  flat[indx]->setYoffDB(i - Hbins, thisBin->y[j]);
49  } else if (i >= Hbins + Obins && i < Hbins + 2 * Obins) {
50  flat[indx]->setPtDB(i - Hbins - Obins, thisBin->x[j]);
51  flat[indx]->setPt2DB(i - Hbins - Obins, thisBin->y[j]);
52  }
53  }
54  }
55  }
56  int cbins = 0;
57  while (flatTableSize > Hbins + 2 * Obins + cbins) {
58  const RPFlatParams::EP* thisBin = &(flatparmsDB_.m_table[Hbins + 2 * Obins + cbins]);
59  double centbinning = thisBin->x[0];
60  int ncentbins = (int)thisBin->y[0] + 0.01;
61  if (ncentbins == 0)
62  break;
63  for (int j = 0; j < ncentbins; j++) {
64  const RPFlatParams::EP* thisBin = &(flatparmsDB_.m_table[Hbins + 2 * Obins + cbins + j + 1]);
65  if (fabs(centbinning - 1.) < 0.01) {
66  for (int i = 0; i < hi::NumEPNames; i++) {
67  flat[i]->setCentRes1(j, thisBin->x[i], thisBin->y[i]);
68  }
69  }
70  if (fabs(centbinning - 2.) < 0.01) {
71  for (int i = 0; i < hi::NumEPNames; i++)
72  flat[i]->setCentRes2(j, thisBin->x[i], thisBin->y[i]);
73  }
74  if (fabs(centbinning - 5.) < 0.01) {
75  for (int i = 0; i < hi::NumEPNames; i++)
76  flat[i]->setCentRes5(j, thisBin->x[i], thisBin->y[i]);
77  }
78  if (fabs(centbinning - 10.) < 0.01) {
79  for (int i = 0; i < hi::NumEPNames; i++)
80  flat[i]->setCentRes10(j, thisBin->x[i], thisBin->y[i]);
81  }
82  if (fabs(centbinning - 20.) < 0.01) {
83  for (int i = 0; i < hi::NumEPNames; i++)
84  flat[i]->setCentRes20(j, thisBin->x[i], thisBin->y[i]);
85  }
86  if (fabs(centbinning - 25.) < 0.01) {
87  for (int i = 0; i < hi::NumEPNames; i++)
88  flat[i]->setCentRes25(j, thisBin->x[i], thisBin->y[i]);
89  }
90  if (fabs(centbinning - 30.) < 0.01) {
91  for (int i = 0; i < hi::NumEPNames; i++)
92  flat[i]->setCentRes30(j, thisBin->x[i], thisBin->y[i]);
93  }
94  if (fabs(centbinning - 40.) < 0.01) {
95  for (int i = 0; i < hi::NumEPNames; i++)
96  flat[i]->setCentRes40(j, thisBin->x[i], thisBin->y[i]);
97  }
98  }
99 
100  cbins += ncentbins + 1;
101  }
102  }
103  }
104 
105  bool IsSuccess() { return genFlatPsi_; }
107 
108 private:
110 };
111 
112 #endif
void setCentRes1(unsigned int bin, double res, double err)
void setXoffDB(unsigned int indx, double val)
void setXDB(unsigned int indx, double val)
~LoadEPDB()
Definition: LoadEPDB.h:106
bool IsSuccess()
Definition: LoadEPDB.h:105
void setYDB(unsigned int indx, double val)
bool genFlatPsi_
Definition: LoadEPDB.h:109
void setYoffDB(unsigned int indx, double val)
std::vector< EP > m_table
Definition: RPFlatParams.h:22
void setPt2DB(unsigned int indx, double val)
int RPNameIndx[50]
Definition: RPFlatParams.h:16
void setPtDB(unsigned int indx, double val)
static const int NumEPNames
LoadEPDB(const RPFlatParams &flatparmsDB_, HiEvtPlaneFlatten **flat)
Definition: LoadEPDB.h:23