File indexing completed on 2024-04-06 12:11:16
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #include "FastSimulation/ForwardDetectors/plugins/AcceptanceTableHelper.h"
0012
0013 #include <iostream>
0014 #include <cmath>
0015
0016
0017
0018 void AcceptanceTableHelper::Init(TFile& f, const std::string basename) {
0019
0020 TH3F* h = (TH3F*)f.Get(basename.c_str());
0021
0022 if (h != nullptr) {
0023 h_log10t_log10Xi_Phi = (TH3F*)h->Clone();
0024 std::cout << "Read ";
0025 h_log10t_log10Xi_Phi->SetDirectory(nullptr);
0026 h_log10t_log10Xi_Phi->Print();
0027 } else {
0028 std::cout << "Warning: could not get acceptance table " << basename << std::endl;
0029 }
0030
0031
0032 std::string name2 = basename + "_hight";
0033 h = (TH3F*)f.Get(name2.c_str());
0034
0035 if (h != nullptr) {
0036 h_t_log10Xi_Phi = (TH3F*)h->Clone();
0037 h_t_log10Xi_Phi->SetDirectory(nullptr);
0038 std::cout << "Read ";
0039 h_t_log10Xi_Phi->Print();
0040 } else {
0041 std::cout << "Warning: could not get acceptance table " << name2 << std::endl;
0042 }
0043 }
0044
0045
0046
0047 float AcceptanceTableHelper::GetAcceptance(float t, float xi, float phi) {
0048 float log10t = log10(-t);
0049 float log10Xi = log10(xi);
0050
0051 float acc = 0;
0052
0053 if ((h_log10t_log10Xi_Phi != nullptr)
0054 && (log10t < h_log10t_log10Xi_Phi->GetXaxis()->GetXmax()))
0055 {
0056 float log10tMin = h_log10t_log10Xi_Phi->GetXaxis()->GetXmin();
0057 if (log10t < log10tMin)
0058 log10t = log10tMin;
0059
0060 acc = h_log10t_log10Xi_Phi->GetBinContent(h_log10t_log10Xi_Phi->FindBin(log10t, log10Xi, phi));
0061
0062 } else if (h_t_log10Xi_Phi != nullptr) {
0063
0064 acc = h_t_log10Xi_Phi->GetBinContent(h_t_log10Xi_Phi->FindBin(-t, log10Xi, phi));
0065 }
0066
0067 return acc;
0068 }