Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
calTowerCalib.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file calTowerCalib.C
1 
3 {
4  const double energy_in[16] = {0.00763174, 0.00692298, 0.00637355, 0.0059323, 0.00762296, 0.00691832, 0.00636611, 0.0059203, 0.00762873, 0.00693594, 0.00637791, 0.00592433, 0.00762898, 0.00691679, 0.00636373, 0.00592433};
5  const double adc_in[16] = {2972.61, 2856.43, 2658.19, 2376.10, 3283.39, 2632.81, 2775.77, 2491.68, 2994.11, 3385.70, 3258.01, 2638.31, 3479.97, 3081.41, 2768.36, 2626.77};
6  const double gain_factor_in = 32.0;
7  const double samplefrac_in = 0.09267;
8 
9  const double energy_out[16] = {0.00668176, 0.00678014, 0.00687082, 0.00706854, 0.00668973, 0.00678279, 0.00684794, 0.00705448, 0.00668976, 0.0068013, 0.00685931, 0.00704985, 0.0066926, 0.00678282, 0.00684403, 0.00704143};
10  // const double adc_out[16] = {666.378, 1488.15, 1493.36, 1816.82, 666.378, 1488.15, 1493.36, 1816.82, 666.378, 1488.15, 1493.36, 1816.82, 666.378, 1488.15, 1493.36, 1816.82}; // use 1st column for whole HCALOUT
11  const double adc_out[16] = {276.9, 290.0, 280.7, 272.1, 309.5, 304.8, 318.5, 289.6, 289.9, 324.2, 297.9, 294.6, 292.7, 310.5, 302.3, 298.5}; // Songkyo's number
12  const double adc_amp[16] = {2.505, 5.330, 5.330, 6.965, 2.505, 5.330, 5.330, 6.965, 2.505, 5.330, 5.330, 6.965, 2.505, 5.330, 5.330, 6.965}; // amplify from 2017 to 2018
13  const double gain_factor_out = 16.0;
14  const double samplefrac_out = 0.02862;
15 
16  double towercalib_lg_in[16];
17  double towercalib_hg_in[16];
18  double towercalib_lg_out[16];
19  double towercalib_hg_out[16];
20  for(int i_tower = 0; i_tower < 16; ++i_tower)
21  {
22  towercalib_lg_in[i_tower] = gain_factor_in*energy_in[i_tower]/(adc_in[i_tower]*samplefrac_in);
23  towercalib_hg_in[i_tower] = energy_in[i_tower]/(adc_in[i_tower]*samplefrac_in);
24 
25  towercalib_lg_out[i_tower] = gain_factor_out*energy_out[i_tower]/(adc_amp[i_tower]*adc_out[i_tower]*samplefrac_out);
26  towercalib_hg_out[i_tower] = energy_out[i_tower]/(adc_amp[i_tower]*adc_out[i_tower]*samplefrac_out);
27  // towercalib_lg_out[i_tower] = gain_factor_out*energy_out[i_tower]/(adc_out[i_tower]*samplefrac_out);
28  // towercalib_hg_out[i_tower] = energy_out[i_tower]/(adc_out[i_tower]*samplefrac_out);
29 
30  cout << "i_tower = " << i_tower << ", towercalib_lg_in = " << towercalib_lg_in[i_tower] << ", towercalib_lg_out = " << towercalib_lg_out[i_tower] << endl;
31  cout << "i_tower = " << i_tower << ", towercalib_hg_in = " << towercalib_hg_in[i_tower] << ", towercalib_hg_out = " << towercalib_hg_out[i_tower] << endl;
32  cout << endl;
33  }
34 
35  // save high gain tower-by-tower calibration factors into calibration files
36  int hbdchanIHC[4][4] = { { 4, 8, 12, 16},
37  { 3, 7, 11, 15},
38  { 2, 6, 10, 14},
39  { 1, 5, 9, 13}};
40 
41  string output_hcalin = "calib_hcalin_hg.txt";
42  ofstream File_OutPut_hcalin(output_hcalin.c_str());
43  for(int i_col = 0; i_col < 4; ++i_col)
44  {
45  for(int i_row = 0; i_row < 4; ++i_row)
46  {
47  int i_tower = hbdchanIHC[i_row][i_col]-1;
48  cout << "i_col = " << i_col << ", i_row = " << i_row << ", i_tower = " << i_tower << ", towercalib_hg_in = " << towercalib_hg_in[i_tower] << endl;
49 
50  File_OutPut_hcalin << i_col << " " << i_row << " " << towercalib_hg_in[i_tower] << endl;
51  }
52  }
53  File_OutPut_hcalin.close();
54 
55  string output_hcalout = "calib_hcalout_hg.txt";
56  ofstream File_OutPut_hcalout(output_hcalout.c_str());
57  for(int i_col = 0; i_col < 4; ++i_col)
58  {
59  for(int i_row = 0; i_row < 4; ++i_row)
60  {
61  int i_tower = hbdchanIHC[i_row][i_col]-1;
62  cout << "i_col = " << i_col << ", i_row = " << i_row << ", i_tower = " << i_tower << ", towercalib_hg_out = " << towercalib_hg_out[i_tower] << endl;
63 
64  File_OutPut_hcalout << i_col << " " << i_row << " " << towercalib_hg_out[i_tower] << endl;
65  }
66  }
67  File_OutPut_hcalout.close();
68 }