BOSS 6.6.4.p01
BESIII Offline Software System
Loading...
Searching...
No Matches
ParticleIDBase.cxx
Go to the documentation of this file.
1#include <iostream>
2#include <cmath>
3#include <cstdlib>
4
6#include "TMath.h"
7
8const int ParticleIDBase::USE_DEDX = 1;
9const int ParticleIDBase::USE_TOF1 = 2;
10const int ParticleIDBase::USE_TOF2 = 4;
11const int ParticleIDBase::USE_TOFE = 8;
12const int ParticleIDBase::USE_TOFQ = 16;
13const int ParticleIDBase::USE_EMC = 32;
14const int ParticleIDBase::USE_MUC = 64;
15const int ParticleIDBase::USE_TOF = 128;
16const int ParticleIDBase::USE_TOFC = 256;
17const int ParticleIDBase::USE_TOFCorr = 512;
18
19const int ParticleIDBase::IDENTIFY_ELECTRON = 1;
20const int ParticleIDBase::IDENTIFY_MUON = 2;
21const int ParticleIDBase::IDENTIFY_PION = 4;
22const int ParticleIDBase::IDENTIFY_KAON = 8;
23const int ParticleIDBase::IDENTIFY_PROTON = 16;
24
25const int ParticleIDBase::PROBABILITY_PID = 1;
26const int ParticleIDBase::LIKELIHOOD_PID = 2;
27const int ParticleIDBase::NEURONNETWORK_PID = 4;
28
29const int ParticleIDBase::DEDX_VALID = 1;
30const int ParticleIDBase::TOF1_VALID = 2;
31const int ParticleIDBase::TOF2_VALID = 4;
32const int ParticleIDBase::TOFE_VALID = 8;
33const int ParticleIDBase::TOFQ_VALID = 16;
34const int ParticleIDBase::EMC_VALID = 32;
35const int ParticleIDBase::MUC_VALID = 64;
36const int ParticleIDBase::TOF_VALID = 128;
37const int ParticleIDBase::TOFC_VALID = 256;
38const int ParticleIDBase::TOFCorr_VALID = 512;
39
40
41std::string ParticleIDBase::path = "";
42
44{
45 m_trk = 0;
46 m_chimin_cut = 4;
47 m_pdfsigmamin_cut=99;
48
49#ifndef BEAN
50 if( path.empty() ) set_path(0);
51#endif
52}
53
54void ParticleIDBase::set_path(const char* s_path)
55{
56 if ( s_path ) {
57 path = string(s_path);
58 } else {
59 char* env_path = getenv("PARTICLEIDROOT");
60 if ( !env_path ) {
61 cout << " ParticleIDBase::set_path ERROR:"
62 " the environment PARTICLEIDROOT not defined " << endl;
63 exit(1);
64 }
65 path = string(env_path);
66 }
67}
68
69
71 double mass[5] = {0.000511, 0.105658, 0.139570,0.493677, 0.938272};
72 if(n < 0 || n >=5) return 0.0;
73 return mass[n];
74}
75
77 // double vel = 29.9792458; // tof_path unit in cm.
78 double vel = 299.792458; // tof path unit in mm
79 return vel;
80}
81
82double ParticleIDBase::probCalculate(double chi2, int ndof) {
83 double p = -1.0;
84 if(chi2 < 0) return p;
85 p = TMath::Prob(chi2, ndof);
86 return p;
87}
88
89//huangb add -----------------------------------------
90double ParticleIDBase::pdfCalculate(double offset,double sigma) {
91 // const double pi = 3.141592653589793238;
92 const double pi = M_PI;
93 const double twoPi = 2*pi;
94 double chi2 = -0.5*offset*offset/(sigma*sigma);
95 double pdf = exp(chi2)/(sigma*sqrt(twoPi));
96 return pdf;
97}
98
100 double val = 999;
101 if(!m_trk) return val;
102 if(!m_trk->isMdcTrackValid()) return val;
103 RecMdcTrack *mdcTrk = m_trk->mdcTrack();
104 val = mdcTrk->p();
105 return val;
106}
108 double val = 999;
109 if(!m_trk) return val;
110 if(!m_trk->isMdcTrackValid()) return val;
111 RecMdcTrack *mdcTrk = m_trk->mdcTrack();
112 val = mdcTrk->pxy();
113 return val;
114}
116 double val = 999;
117 if(!m_trk) return val;
118 if(!m_trk->isMdcTrackValid()) return val;
119 RecMdcTrack *mdcTrk = m_trk->mdcTrack();
120 val = mdcTrk->charge() + 0.0;
121 return val;
122}
123
124double ParticleIDBase::interpolation(double* x, double* y,double x1) {
125 double c1 = (y[0]-y[1])*(x[1]-x[2])-(x[0]-x[1])*(y[1]-y[2]);
126 double c2 = (x[0]*x[0]-x[1]*x[1])*(x[1]-x[2])-(x[1]*x[1]-x[2]*x[2])*(x[0]-x[1]);
127 double c = c1/c2;
128 double b1 = (y[0]-y[1])*(x[1]*x[1]-x[2]*x[2])-(x[0]*x[0]-x[1]*x[1])*(y[1]-y[2]);
129 double b2 = (x[0]-x[1])*(x[1]*x[1]-x[2]*x[2])-(x[1]-x[2])*(x[0]*x[0]-x[1]*x[1]);
130 double b = b1/b2;
131 double a = y[0] - b*x[0]-c*x[0]*x[0];
132 double y1 = a + b*x1 +c*x1*x1;
133 return y1;
134}
135
136double ParticleIDBase::pol2(double x, double* par) {
137 double y=x;
138 // return par[0] + (par[1] * y) +(par[2] * y * y);
139 return par[0] + y*(par[1] + y*(par[2]));
140}
141
142double ParticleIDBase::pol3(double x, double* par) {
143 double y=x;
144 // return par[0] + (par[1] * y) +(par[2] * y * y)+(par[3] * y * y*y);
145 return par[0] + y*(par[1] + y*(par[2] + y*(par[3])));
146}
147
148double ParticleIDBase::pol4(double x, double* par) {
149 double y=x;
150 // return par[0] + (par[1] * y) +(par[2] * y * y)+(par[3] * y * y*y) + (par[4] * y * y*y*y);
151 return par[0] + y*(par[1] + y*(par[2] + y*(par[3] + y*(par[4]))));
152}
double mass
const Int_t n
Double_t x[10]
EvtComplex exp(const EvtComplex &c)
Definition: EvtComplex.hh:252
const double twoPi
Definition: MdcSeg.cxx:33
#define M_PI
Definition: TConstant.h:4
const int charge() const
Definition: DstMdcTrack.h:53
const double pxy() const
Definition: DstMdcTrack.h:54
const double p() const
Definition: DstMdcTrack.h:58
bool isMdcTrackValid()
Definition: EvtRecTrack.h:43
RecMdcTrack * mdcTrack()
Definition: EvtRecTrack.h:53
double pol2(double x, double *par)
virtual int ndof() const =0
double interpolation(double *x, double *y, double x1)
double probCalculate(double chi2, int n)
double pol4(double x, double *par)
double pol3(double x, double *par)
double pdfCalculate(double offset, double sigma)
double xmass(int n)
static std::string path
void set_path(const char *s_path=0)
TCanvas * c1
Definition: tau_mode.c:75
const float pi
Definition: vector3.h:133