CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ZdcLut.cc
Go to the documentation of this file.
2 #include <cstdlib>
3 
14  //constants for ADC to GeV conversion
15  double ADC_GEV_EM = 13.55, ADC_GEV_HAD = 0.6;
16  int LSB_EM = 1, LSB_HAD = 5;
17  std::vector<int> fC_TDR;
18  //fills in fC_TDR with values from table
19  fC_TDR.push_back(0);
20  fC_TDR.push_back(1);
21  fC_TDR.push_back(2);
22  fC_TDR.push_back(3);
23  fC_TDR.push_back(4);
24  fC_TDR.push_back(5);
25  fC_TDR.push_back(6);
26  fC_TDR.push_back(7);
27  fC_TDR.push_back(8);
28  fC_TDR.push_back(9);
29  fC_TDR.push_back(10);
30  fC_TDR.push_back(11);
31  fC_TDR.push_back(12);
32  fC_TDR.push_back(13);
33  fC_TDR.push_back(14);
34  fC_TDR.push_back(16);
35  fC_TDR.push_back(18);
36  fC_TDR.push_back(20);
37  fC_TDR.push_back(22);
38  fC_TDR.push_back(24);
39  fC_TDR.push_back(26);
40  fC_TDR.push_back(28);
41  fC_TDR.push_back(31);
42  fC_TDR.push_back(34);
43  fC_TDR.push_back(37);
44  fC_TDR.push_back(40);
45  fC_TDR.push_back(44);
46  fC_TDR.push_back(48);
47  fC_TDR.push_back(52);
48  fC_TDR.push_back(57);
49  fC_TDR.push_back(62);
50  fC_TDR.push_back(67);
51  fC_TDR.push_back(62);
52  fC_TDR.push_back(67);
53  fC_TDR.push_back(72);
54  fC_TDR.push_back(77);
55  fC_TDR.push_back(82);
56  fC_TDR.push_back(87);
57  fC_TDR.push_back(92);
58  fC_TDR.push_back(97);
59  fC_TDR.push_back(102);
60  fC_TDR.push_back(107);
61  fC_TDR.push_back(112);
62  fC_TDR.push_back(117);
63  fC_TDR.push_back(122);
64  fC_TDR.push_back(127);
65  fC_TDR.push_back(132);
66  fC_TDR.push_back(142);
67  fC_TDR.push_back(152);
68  fC_TDR.push_back(162);
69  fC_TDR.push_back(172);
70  fC_TDR.push_back(182);
71  fC_TDR.push_back(192);
72  fC_TDR.push_back(202);
73  fC_TDR.push_back(217);
74  fC_TDR.push_back(232);
75  fC_TDR.push_back(247);
76  fC_TDR.push_back(262);
77  fC_TDR.push_back(282);
78  fC_TDR.push_back(302);
79  fC_TDR.push_back(322);
80  fC_TDR.push_back(347);
81  fC_TDR.push_back(372);
82  fC_TDR.push_back(397);
83  fC_TDR.push_back(372);
84  fC_TDR.push_back(397);
85  fC_TDR.push_back(422);
86  fC_TDR.push_back(447);
87  fC_TDR.push_back(472);
88  fC_TDR.push_back(497);
89  fC_TDR.push_back(522);
90  fC_TDR.push_back(547);
91  fC_TDR.push_back(572);
92  fC_TDR.push_back(597);
93  fC_TDR.push_back(622);
94  fC_TDR.push_back(647);
95  fC_TDR.push_back(672);
96  fC_TDR.push_back(697);
97  fC_TDR.push_back(722);
98  fC_TDR.push_back(772);
99  fC_TDR.push_back(822);
100  fC_TDR.push_back(872);
101  fC_TDR.push_back(922);
102  fC_TDR.push_back(972);
103  fC_TDR.push_back(1022);
104  fC_TDR.push_back(1072);
105  fC_TDR.push_back(1147);
106  fC_TDR.push_back(1222);
107  fC_TDR.push_back(1297);
108  fC_TDR.push_back(1372);
109  fC_TDR.push_back(1472);
110  fC_TDR.push_back(1572);
111  fC_TDR.push_back(1672);
112  fC_TDR.push_back(1797);
113  fC_TDR.push_back(1922);
114  fC_TDR.push_back(2047);
115  fC_TDR.push_back(1922);
116  fC_TDR.push_back(2047);
117  fC_TDR.push_back(2172);
118  fC_TDR.push_back(2297);
119  fC_TDR.push_back(2422);
120  fC_TDR.push_back(2547);
121  fC_TDR.push_back(2672);
122  fC_TDR.push_back(1797);
123  fC_TDR.push_back(2922);
124  fC_TDR.push_back(3047);
125  fC_TDR.push_back(3172);
126  fC_TDR.push_back(3297);
127  fC_TDR.push_back(3422);
128  fC_TDR.push_back(2547);
129  fC_TDR.push_back(3672);
130  fC_TDR.push_back(3922);
131  fC_TDR.push_back(4172);
132  fC_TDR.push_back(4422);
133  fC_TDR.push_back(4672);
134  fC_TDR.push_back(4922);
135  fC_TDR.push_back(5172);
136  fC_TDR.push_back(5422);
137  fC_TDR.push_back(5797);
138  fC_TDR.push_back(6172);
139  fC_TDR.push_back(6547);
140  fC_TDR.push_back(6922);
141  fC_TDR.push_back(7422);
142  fC_TDR.push_back(7922);
143  fC_TDR.push_back(8422);
144  fC_TDR.push_back(9047);
145  fC_TDR.push_back(9672);
146  fC_TDR.push_back(10297);
147 
148  // two vectors containing the LUT; one for Hadronic and one for Electromagnetic
149  std::vector<int> HADlut(128);
150  std::vector<int> EMlut(128);
151  //uses the constants to fill each LUT
152  for (int zdci = 0; zdci < 128; zdci++) {
153  EMlut[zdci] = (int)((fC_TDR[zdci] / ADC_GEV_EM) / LSB_EM + 0.5);
154  }
155  for (int zdci = 0; zdci < 128; zdci++) {
156  HADlut[zdci] = (int)((fC_TDR[zdci] / ADC_GEV_HAD) / LSB_HAD + 0.5);
157  }
158 
159  side.resize(2);
160  side[0].fiber.resize(3);
161  side[1].fiber.resize(3);
162  side[0].fiber[0].channel.resize(3);
163  side[0].fiber[1].channel.resize(3);
164  side[0].fiber[2].channel.resize(3);
165  side[1].fiber[0].channel.resize(3);
166  side[1].fiber[1].channel.resize(3);
167  side[1].fiber[2].channel.resize(3);
168  side[0].fiber[0].channel[0].LUT = EMlut;
169  side[0].fiber[0].channel[1].LUT = EMlut;
170  side[0].fiber[0].channel[2].LUT = EMlut;
171  side[0].fiber[1].channel[0].LUT = EMlut;
172  side[0].fiber[1].channel[1].LUT = EMlut;
173  side[0].fiber[1].channel[2].LUT = HADlut;
174  side[0].fiber[2].channel[0].LUT = HADlut;
175  side[0].fiber[2].channel[1].LUT = HADlut;
176  side[0].fiber[2].channel[2].LUT = HADlut;
177  side[1].fiber[0].channel[0].LUT = EMlut;
178  side[1].fiber[0].channel[1].LUT = EMlut;
179  side[1].fiber[0].channel[2].LUT = EMlut;
180  side[1].fiber[1].channel[0].LUT = EMlut;
181  side[1].fiber[1].channel[1].LUT = EMlut;
182  side[1].fiber[1].channel[2].LUT = HADlut;
183  side[1].fiber[2].channel[0].LUT = HADlut;
184  side[1].fiber[2].channel[1].LUT = HADlut;
185  side[1].fiber[2].channel[2].LUT = HADlut;
186 }
187 
189 
191  for (unsigned int zdcs = 0; zdcs < side.size(); zdcs++) {
192  for (unsigned int zdcf = 0; zdcf < side[zdcs].fiber.size(); zdcf++) {
193  for (unsigned int zdcc = 0; zdcc < side[zdcs].fiber[zdcf].channel.size(); zdcc++) {
194  for (unsigned int zdcl = 0; zdcl < side[zdcs].fiber[zdcf].channel[zdcc].LUT.size(); zdcl++) {
195  std::cout << side[zdcs].fiber[zdcf].channel[zdcc].LUT[zdcl] << " ";
196  }
197  std::cout << std::endl;
198  }
199  std::cout << std::endl;
200  }
201  std::cout << std::endl;
202  }
203  return 0;
204 }
205 
206 std::vector<int> ZdcLut::get_lut(int emap_side, int emap_htr_fiber, int emap_fi_ch) {
207  int side_num = (1 - emap_side) / 2;
208  int fiber_num = (int)(emap_htr_fiber / 4) + (emap_htr_fiber % 4);
209  int channel_num = emap_fi_ch;
210  return side[side_num].fiber[fiber_num].channel[channel_num].LUT;
211 }
212 
213 // get LUT by proper ZDC channel
214 std::vector<int> ZdcLut::get_lut(std::string zdc_section, int zdc_side, int zdc_channel) {
215  int side_num = (1 - zdc_side) / 2;
216  int fiber_num = -1;
217  int channel_num = -1;
218  if (zdc_section.find("ZDC EM") != std::string::npos) {
219  fiber_num = (int)(zdc_channel / 4);
220  channel_num = (int)((zdc_channel - 1) / 3) % 3;
221  } else if (zdc_section.find("ZDC HAD") != std::string::npos) {
222  if (zdc_channel == 1) {
223  fiber_num = 1;
224  channel_num = 2;
225  } else if (zdc_channel == 2) {
226  fiber_num = 2;
227  channel_num = 0;
228  } else if (zdc_channel == 3) {
229  fiber_num = 2;
230  channel_num = 1;
231  } else if (zdc_channel == 4) {
232  fiber_num = 2;
233  channel_num = 2;
234  } else {
235  std::cout << zdc_channel << ": unknown ZDC channel, exiting..." << std::endl;
236  exit(-1);
237  }
238  } else {
239  std::cout << zdc_section << ": unknown ZDC section, exiting..." << std::endl;
240  exit(-1);
241  }
242  // FIXME: add validity check here
243  if (1 == 1) {
244  return side[side_num].fiber[fiber_num].channel[channel_num].LUT;
245  } else
246  return side[side_num].fiber[fiber_num].channel[channel_num].LUT;
247 }
std::vector< int > get_lut(int emap_side, int emap_htr_fiber, int emap_fi_ch)
Definition: ZdcLut.cc:206
int simple_loop(void)
Definition: ZdcLut.cc:190
ZdcLut()
Definition: ZdcLut.cc:13
~ZdcLut()
Definition: ZdcLut.cc:188
tuple cout
Definition: gather_cfg.py:144
std::vector< ZDC_sides > side
Definition: ZdcLut.h:45