ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DrcPidFast.cxx
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file DrcPidFast.cxx
1 #include "DrcPidFast.h"
2 
4 
5  fMass[0] = 0.000511;
6  fMass[1] = 0.105658;
7  fMass[2] = 0.139570;
8  fMass[3] = 0.49368;
9  fMass[4] = 0.938272;
10 
11  // read Cherenkov track resolution map
12  ReadMap("ctr_map_p1_0.95.root");
13 
14  // multiple scattering for 17 mm thick radiator at 30 deg
15  fMs_mom = new TF1("", "expo(0)+expo(2)+expo(4)");
16  fMs_mom->SetParameters(4.40541e+00, -5.52436e+00, 2.35058e+00, -1.02703e+00, 9.55032e-01,
17  -1.48500e-01);
18  // fMs_mom->SetParameters(9.39815e-01, -1.48243e-01, 4.69733e+00, -4.33960e+00, 2.19745e+00,
19  // -9.68617e-01);
20 
21  fMs_thickness = new TF1("", "pol1");
22 
23  if (barid == 1) fMs_thickness->SetParameters(3.5, 0.0214286); // 10 mm bar
24  else fMs_thickness->SetParameters(4.5, 0.0357143); // 17 mm bar
25 
26  TF1 *fMs_thickness_17 = new TF1("", "pol1");
27  fMs_thickness_17->SetParameters(4.5, 0.0357143); // 17 mm bar
28  fMs_thickness_max = fMs_thickness_17->Eval(70);
29 }
30 
31 void DrcPidFast::ReadMap(TString name) {
32  TFile *file = TFile::Open(name);
33  fTrrMap = new TH2F();
34  file->GetObject("htrr", fTrrMap);
35 }
36 
37 DrcPidInfo DrcPidFast::GetInfo(int pdg, TVector3 mom, double track_err) {
38  double p = mom.Mag();
39  double theta = mom.Theta() * TMath::RadToDeg();
40  return GetInfo(pdg, p, theta, track_err);
41 }
42 
43 DrcPidInfo DrcPidFast::GetInfo(int pdg, double p, double theta, double track_err) {
44 
45  // double theta = 2.0*atan(exp(-eta))*TMath::RadToDeg();
46 
47  const int max = 5;
49  int pid = get_pid(pdg);
50 
51  // set default values
52  for (int i = 0; i < max; i++) {
53  info.probability[i] = 0.25;
54  info.sigma[i] = 100;
55  }
56  info.cangle = 0;
57  info.cctr = 0;
58 
59  // check range
60  if (theta < 19.99 || theta > 160.01){
61  std::cout<<"theta out of [20,160] deg range: "<<theta<<std::endl;
62  }
63 
64  double ms_mom_err = fMs_mom->Eval(p); // vector deviation after radiator
65 
66  double alpha = (theta < 90) ? 90 - theta : theta - 90;
67  double ms_thick_frac = fMs_thickness->Eval(alpha) / fMs_thickness_max;
68 
69  // 0.31 for averaging direction vector over the radiator thickness
70  double ms_err = 0.31 * ms_mom_err * ms_thick_frac;
71 
72  // ctr map is for theta = [25,153] and p = [0,10] GeV/c
73  if (theta < 25) theta = 25;
74  if (theta > 153) theta = 153;
75  if (p > 10) p = 10;
76 
77  int bin = fTrrMap->FindBin(theta, p);
78  double ctr = fTrrMap->GetBinContent(bin); // Cherenkov track resolution [mrad]
79  double cctr = sqrt(ctr * ctr + track_err * track_err + ms_err * ms_err) *
80  0.001; // combined Cherenkov track resolution[rad]
81 
82  // 1.46907 - fused silica
83  double true_cangle = acos(sqrt(p * p + fMass[pid] * fMass[pid]) / p / 1.46907);
84  true_cangle += gRandom->Gaus(0, cctr);
85 
86  // return default values if momentum below Cherenkov threshold (true_cangle is NaN)
87  if (true_cangle != true_cangle) return info;
88 
89  double cangle, sum = 0, fsum = 0;
90  double delta[max] = {0}, probability[max] = {0};
91 
92  for (int i = 0; i < max; i++) {
93  cangle = acos(sqrt(p * p + fMass[i] * fMass[i]) / p / 1.46907);
94  if (cangle != cangle) continue;
95  delta[i] = fabs(cangle - true_cangle);
96  sum += delta[i];
97  info.sigma[i] = (cangle - true_cangle) / cctr;
98  if (i == pid) info.cangle = cangle;
99  }
100  // normalization
101  for (int i = 0; i < max; i++) {
102  if (delta[i] > 0) info.probability[i] = sum / delta[i];
103  fsum += info.probability[i];
104  }
105  for (int i = 0; i < max; i++) info.probability[i] /= fsum;
106  info.cctr = cctr;
107 
108  return info;
109 }
110 
112  int pid = 0;
113  if (pdg == 11) pid = 0; // e
114  if (pdg == 13) pid = 1; // mu
115  if (pdg == 211) pid = 2; // pi
116  if (pdg == 321) pid = 3; // K
117  if (pdg == 2212) pid = 4; // p
118  return pid;
119 }