Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
LightCollectionModel.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file LightCollectionModel.cc
1 #include "LightCollectionModel.h"
2 
4 
6 
7 #include <phool/recoConsts.h>
8 
9 #include <TAxis.h> // for TAxis
10 #include <TFile.h>
11 #include <TH1.h>
12 #include <TH2.h>
13 #include <TObject.h> // for TObject
14 #include <TSystem.h>
15 
16 #include <cassert>
17 #include <iostream>
18 
20 {
21  delete data_grid_light_guide_efficiency;
22  delete data_grid_fiber_trans;
23 }
24 
26  const std::string &domain,
27  const std::string &histogram_light_guide_model,
28  const std::string &histogram_fiber_model)
29 {
32  if (url.empty())
33  {
34  std::cout << "No calibration for domain " << domain << " for timestamp " << rc->get_uint64Flag("TIMESTAMP") << std::endl;
35  gSystem->Exit(1);
36  }
37  TFile *fin = TFile::Open(url.c_str());
38  if (!fin)
39  {
40  std::cout << "could not open " << url << std::endl;
41  gSystem->Exit(1);
42  }
43  delete data_grid_light_guide_efficiency;
44  data_grid_light_guide_efficiency = dynamic_cast<TH2 *>(fin->Get(histogram_light_guide_model.c_str()));
45  assert(data_grid_light_guide_efficiency);
46  data_grid_light_guide_efficiency->SetDirectory(nullptr);
47  delete data_grid_fiber_trans;
48  data_grid_fiber_trans = dynamic_cast<TH1 *>(fin->Get(histogram_fiber_model.c_str()));
50  data_grid_fiber_trans->SetDirectory(nullptr);
51  delete fin;
52 }
53 
55  const std::string &input_file,
56  const std::string &histogram_light_guide_model,
57  const std::string &histogram_fiber_model)
58 {
59  TFile *fin = TFile::Open(input_file.c_str());
60 
61  assert(fin);
62  assert(fin->IsOpen());
63 
64  delete data_grid_light_guide_efficiency;
65  data_grid_light_guide_efficiency = dynamic_cast<TH2 *>(fin->Get(histogram_light_guide_model.c_str()));
66  assert(data_grid_light_guide_efficiency);
67  data_grid_light_guide_efficiency->SetDirectory(nullptr);
68 
69  delete data_grid_fiber_trans;
70  data_grid_fiber_trans = dynamic_cast<TH1 *>(fin->Get(histogram_fiber_model.c_str()));
72  data_grid_fiber_trans->SetDirectory(nullptr);
73 
74  delete fin;
75 }
76 
77 double LightCollectionModel::get_light_guide_efficiency(const double x_fraction, const double y_fraction)
78 {
79  assert(data_grid_light_guide_efficiency);
80  assert(x_fraction >= 0);
81  assert(x_fraction <= 1);
82  assert(y_fraction >= 0);
83  assert(y_fraction <= 1);
84 
85  const double eff = data_grid_light_guide_efficiency->Interpolate(x_fraction,
86  y_fraction);
87 
89  {
90  data_grid_light_guide_efficiency_verify = new TH2F("data_grid_light_guide_efficiency_verify",
91  "light collection efficiency as used in LightCollectionModel;x positio fraction;y position fraction", //
92  100, 0., 1., 100, 0., 1.);
94  }
95 
97  data_grid_light_guide_efficiency_verify->GetXaxis()->FindBin(x_fraction), //
98  data_grid_light_guide_efficiency_verify->GetYaxis()->FindBin(y_fraction), //
99  eff //
100  );
101 
102  return eff;
103 }
104 
105 double LightCollectionModel::get_fiber_transmission(const double z_distance)
106 {
108 
109  const double eff = data_grid_fiber_trans->Interpolate(z_distance);
111  {
112  data_grid_fiber_trans_verify = new TH1F("data_grid_fiber_trans",
113  "SCSF-78 Fiber Transmission as used in LightCollectionModel;position in fiber (cm);Effective transmission",
114  100, -15, 15);
116  }
117 
118  data_grid_fiber_trans_verify->SetBinContent( //
119  data_grid_fiber_trans_verify->GetXaxis()->FindBin(z_distance), //
120  eff //
121  );
122 
123  return eff;
124 }