Belle II Software  release-08-01-10
ARICHReconstructionPar.cc
1 /**************************************************************************
2  * basf2 (Belle II Analysis Software Framework) *
3  * Author: The Belle II Collaboration *
4  * *
5  * See git log for contributors and copyright holders. *
6  * This file is licensed under LGPL-3.0, see LICENSE.md. *
7  **************************************************************************/
8 
9 #include <arich/dbobjects/ARICHReconstructionPar.h>
10 
11 #include <iostream>
12 #include <vector>
13 
14 using namespace std;
15 using namespace Belle2;
16 
17 
18 void ARICHReconstructionPar::initializeDefault()
19 {
20 
21  double parsBkg[10] = {0, 1, 8.764830e+00, -4.815370e+00, 3.268570e-06, 8.518560e+00, -9.609710e+00, 9.769060e-06, 1.095350e-02, -1.322410e-02};
22  m_bkgPDF = new TF1("bkgPDF",
23  "0*[0] + (1-[1])*(exp([2]+[3]*x)*[4]) + [1]*(exp([5]+[6]*x)*[7]+x*[8]+x*x*[9])");
24  m_bkgPDF->SetParameters(parsBkg);
25 
26  double parsRes[4] = {1.12147e-01, 3.81701e+00, 0.0093, -6.14984e-04};
27  m_thcResolution = new TF1("thcResolution", "([p0]*exp(-[p1]*x)+[p2]+[p3]*x-((x>3)?[p3]*(x-3):0))*1.35");
28  m_thcResolution->SetParameters(parsRes);
29 
30  double parsBkgPhi[8] = {0, 0, 6.68258e-02, 6.50048e+00, -1.04876e-01, -7.06652e-03, 1.34111e-01, 1.83823e-01};
31  m_bkgPhiPDF = new TF2("m_bkgPhiPDF",
32  "[0]*0 + [1]*0 + 1/( ([2]*exp(y*[3]) + [4])*cos(x/2)*cos(x/2)*cos(x/2)*cos(x/2) + sqrt([5] + [6]*y + [7]*y*y ) )");
33  m_bkgPhiPDF->SetParameters(parsBkgPhi);
34 
35  m_pars = {0.098304138, 5.973590e-02, 21, 0.88, 3.7, 0.357, 0.46, 1, 0.12, 0.12, 0.02, 1.5, 0.0288};
36  m_flatBkgPerPad = 0.000892;
37 
38  m_aerogelFOM = {13.200797, 15.186757};
39 }
40 
41 double ARICHReconstructionPar::getBackgroundPerPad(double th_cer, const std::vector<double>& pars) const
42 {
43 
44  int ipar = 0;
45  for (auto par : pars) {
46  m_bkgPDF->SetParameter(ipar, par);
47  ipar++;
48  }
49  return m_bkgPDF->Eval(th_cer) + m_flatBkgPerPad;
50 }
51 
52 double ARICHReconstructionPar::getPhiCorrectedBackgroundPerPad(double fi_cer_trk, double th_cer,
53  const std::vector<double>& pars) const
54 {
55 
56  int ipar = 0;
57  for (auto par : pars) {
58  m_bkgPhiPDF->SetParameter(ipar, par);
59  ipar++;
60  }
61  return m_flatBkgPerPad * m_bkgPhiPDF->Eval(fi_cer_trk, th_cer);
62 }
63 
64 double ARICHReconstructionPar::getExpectedBackgroundHits(const std::vector<double>& pars, double minThc, double maxThc) const
65 {
66 
67  int ipar = 0;
68  for (auto par : pars) {
69  m_bkgPDF->SetParameter(ipar, par);
70  ipar++;
71  }
72 
73  // parameters of fit of pol3 to the number of nPads per ring with given theta and width 5mrad
74  const double surf[4] = { -2.19669e-02, 3.59010e+01, -2.77441e+01, 1.43564e+02};
75  double step = 0.005;
76  double thc = minThc + step / 2.;
77  double bkg = 0;
78  while (thc < maxThc) {
79  bkg += (surf[0] + surf[1] * thc + surf[2] * pow(thc, 2) + surf[3] * pow(thc, 3)) * getBackgroundPerPad(thc, pars);
80  thc += step;
81  }
82  return bkg;
83 
84 }
85 
86 double ARICHReconstructionPar::getNPadsInRing(double maxThc, double minThc, double trackTh) const
87 {
88 
89  double s1 = sqrt(tan(maxThc)) * pow((tan(maxThc + trackTh) + tan(maxThc - trackTh)) / 2, 3. / 2.);
90  double s2 = 0;
91  if (minThc > 0) s2 = sqrt(tan(minThc)) * pow((tan(minThc + trackTh) + tan(minThc - trackTh)) / 2, 3. / 2.);
92  return 3.1416 * 0.18 * 0.18 * (s1 - s2) * 0.6 / 0.005 / 0.005; // pi*dist^2*s*avg_geo_acc/pad_size
93 }
94 
95 void ARICHReconstructionPar::print() const
96 {
97 
98  cout << endl << "-----bkg PDF-----" << endl;
99  m_bkgPDF->Print();
100  int Npar = m_bkgPDF->GetNpar();
101  std::vector<double> bkgPars(Npar, 0);
102  m_bkgPDF->GetParameters(bkgPars.data());
103  for (int i = 0; i < Npar; i++)cout << Form("bkg Pars %d = %e", i, bkgPars[i]) << endl;
104 
105  cout << endl << "-----bkg phi corr PDF-----" << endl;
106  m_bkgPhiPDF->Print();
107  int Npar2 = m_bkgPhiPDF->GetNpar();
108  std::vector<double> bkgPhiCorPars(Npar2, 0);
109  m_bkgPhiPDF->GetParameters(bkgPhiCorPars.data());
110  for (int i = 0; i < Npar2; i++)cout << Form("bkg Pars %d = %e", i, bkgPhiCorPars[i]) << endl;
111 
112  cout << endl << "-----flat backgroud per pad-----" << endl;
113  cout << " flat background per pad is " << m_flatBkgPerPad << endl;
114 
115  cout << endl << "----additional parameters (for wide gaus, quartz etc.)-----" << endl;
116  for (int i = 0; i < (int)m_pars.size(); i++) {
117  printf("m_pars[%d] = %e\n", i, m_pars[i]);
118  }
119 
120  cout << endl << "----Aerogel FOM-----" << endl;
121  for (int i = 0; i < (int)m_aerogelFOM.size(); i++) {
122  printf("m_aerogelFOM[%d] = %f\n", i, m_aerogelFOM[i]);
123  }
124 
125  cout << endl << "----- Resolution PDF-----" << endl;
126  m_thcResolution->Print();
127  double resPars[4];
128  m_thcResolution->GetParameters(resPars);
129  for (int i = 0; i < 4; i++)cout << Form("resolution Pars %d = %e", i, resPars[i]) << endl;
130 
131 }
132 
double sqrt(double a)
sqrt for double
Definition: beamHelpers.h:28
double tan(double a)
tan for double
Definition: beamHelpers.h:31
Abstract base class for different kinds of events.