CbmRoot
Acceptance.cxx
Go to the documentation of this file.
1 #include "Acceptance.h"
2 #include "TString.h"
3 #include <fstream>
4 
5 using std::ifstream;
6 
8  TString filename) {
9  double ymin = 0., ymax = 6.;
10  double ptmin = 0., ptmax = 2.5;
11  func.ys.resize(0);
12  func.pts.resize(0);
13  func.probs.resize(0);
14  ifstream fin(filename.Data());
15  if (!fin.is_open()) return 0;
16  fin >> func.dy >> func.dpt;
17  double ty, tpt, prob;
18  func.ys.resize(0);
19  func.pts.resize(0);
20  func.probs.resize(0);
21  while (fin >> ty >> tpt >> prob) {
22  if (tpt < ptmin || tpt > ptmax || ty < ymin || ty > ymax) continue;
23  func.ys.push_back(ty);
24  func.pts.push_back(tpt);
25  func.probs.push_back(prob);
26  }
27  func.setSpline();
28  fin.close();
29  return 1;
30 }
31 
32 Double_t
34  const Double_t& pt) const {
35  double ret = sfunc.Eval(y, pt);
36  if (ret < 0.) ret = 0.;
37  if (ret > 1.) ret = 1.;
38  return ret;
39 }
Acceptance::AcceptanceFunction::pts
std::vector< Double_t > pts
Definition: Acceptance.h:12
Acceptance::AcceptanceFunction::getAcceptance
Double_t getAcceptance(const Double_t &y, const Double_t &pt) const
Definition: Acceptance.cxx:33
Acceptance::AcceptanceFunction::sfunc
BilinearSplineFunction sfunc
Definition: Acceptance.h:13
Acceptance::AcceptanceFunction::setSpline
void setSpline()
Definition: Acceptance.h:14
Acceptance::AcceptanceFunction::dy
Double_t dy
Definition: Acceptance.h:11
Acceptance::AcceptanceFunction
Definition: Acceptance.h:10
BilinearSplineFunction::Eval
double Eval(double x, double y) const
Definition: CbmBilinearSplineFunction.h:55
Acceptance.h
Acceptance::AcceptanceFunction::dpt
Double_t dpt
Definition: Acceptance.h:11
Acceptance::AcceptanceFunction::ys
std::vector< Double_t > ys
Definition: Acceptance.h:12
y
Double_t y
Definition: CbmMvdSensorDigiToHitTask.cxx:68
Acceptance::ReadAcceptanceFunction
int ReadAcceptanceFunction(AcceptanceFunction &func, TString filename)
Definition: Acceptance.cxx:7
Acceptance::AcceptanceFunction::probs
std::vector< Double_t > probs
Definition: Acceptance.h:12