CGEM BOSS 6.6.5.i
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;
18const int ParticleIDBase::USE_MRPC = 1024;
19
20const int ParticleIDBase::IDENTIFY_ELECTRON = 1;
21const int ParticleIDBase::IDENTIFY_MUON = 2;
22const int ParticleIDBase::IDENTIFY_PION = 4;
23const int ParticleIDBase::IDENTIFY_KAON = 8;
24const int ParticleIDBase::IDENTIFY_PROTON = 16;
25
26const int ParticleIDBase::PROBABILITY_PID = 1;
27const int ParticleIDBase::LIKELIHOOD_PID = 2;
28const int ParticleIDBase::NEURONNETWORK_PID = 4;
29
30const int ParticleIDBase::DEDX_VALID = 1;
31const int ParticleIDBase::TOF1_VALID = 2;
32const int ParticleIDBase::TOF2_VALID = 4;
33const int ParticleIDBase::TOFE_VALID = 8;
34const int ParticleIDBase::TOFQ_VALID = 16;
35const int ParticleIDBase::EMC_VALID = 32;
36const int ParticleIDBase::MUC_VALID = 64;
37const int ParticleIDBase::TOF_VALID = 128;
38const int ParticleIDBase::TOFC_VALID = 256;
39const int ParticleIDBase::TOFCorr_VALID = 512;
40const int ParticleIDBase::MRPC_VALID = 1024;
41
42
43std::string ParticleIDBase::path = "";
44
46{
47 m_trk = 0;
48 m_chimin_cut = 4;
49 m_pdfsigmamin_cut=99;
50
51#ifndef BEAN
52 if( path.empty() ) set_path(0);
53#endif
54}
55
56void ParticleIDBase::set_path(const char* s_path)
57{
58 if ( s_path ) {
59 path = string(s_path);
60 } else {
61 char* env_path = getenv("PARTICLEIDROOT");
62 if ( !env_path ) {
63 cout << " ParticleIDBase::set_path ERROR:"
64 " the environment PARTICLEIDROOT not defined " << endl;
65 exit(1);
66 }
67 path = string(env_path);
68 }
69}
70
71
73 double mass[5] = {0.000511, 0.105658, 0.139570,0.493677, 0.938272};
74 if(n < 0 || n >=5) return 0.0;
75 return mass[n];
76}
77
79 // double vel = 29.9792458; // tof_path unit in cm.
80 double vel = 299.792458; // tof path unit in mm
81 return vel;
82}
83
84double ParticleIDBase::probCalculate(double chi2, int ndof) {
85 double p = -1.0;
86 if(chi2 < 0) return p;
87 p = TMath::Prob(chi2, ndof);
88 return p;
89}
90
91//huangb add -----------------------------------------
92double ParticleIDBase::pdfCalculate(double offset,double sigma) {
93 // const double pi = 3.141592653589793238;
94 const double pi = M_PI;
95 const double twoPi = 2*pi;
96 double chi2 = -0.5*offset*offset/(sigma*sigma);
97 double pdf = exp(chi2)/(sigma*sqrt(twoPi));
98 return pdf;
99}
100
102 double val = 999;
103 if(!m_trk) return val;
104 if(!m_trk->isMdcTrackValid()) return val;
105 RecMdcTrack *mdcTrk = m_trk->mdcTrack();
106 val = mdcTrk->p();
107 return val;
108}
110 double val = 999;
111 if(!m_trk) return val;
112 if(!m_trk->isMdcTrackValid()) return val;
113 RecMdcTrack *mdcTrk = m_trk->mdcTrack();
114 val = mdcTrk->pxy();
115 return val;
116}
118 double val = 999;
119 if(!m_trk) return val;
120 if(!m_trk->isMdcTrackValid()) return val;
121 RecMdcTrack *mdcTrk = m_trk->mdcTrack();
122 val = mdcTrk->charge() + 0.0;
123 return val;
124}
125
126double ParticleIDBase::interpolation(double* x, double* y,double x1) {
127 double c1 = (y[0]-y[1])*(x[1]-x[2])-(x[0]-x[1])*(y[1]-y[2]);
128 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]);
129 double c = c1/c2;
130 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]);
131 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]);
132 double b = b1/b2;
133 double a = y[0] - b*x[0]-c*x[0]*x[0];
134 double y1 = a + b*x1 +c*x1*x1;
135 return y1;
136}
137
138double ParticleIDBase::pol2(double x, double* par) {
139 double y=x;
140 // return par[0] + (par[1] * y) +(par[2] * y * y);
141 return par[0] + y*(par[1] + y*(par[2]));
142}
143
144double ParticleIDBase::pol3(double x, double* par) {
145 double y=x;
146 // return par[0] + (par[1] * y) +(par[2] * y * y)+(par[3] * y * y*y);
147 return par[0] + y*(par[1] + y*(par[2] + y*(par[3])));
148}
149
150double ParticleIDBase::pol4(double x, double* par) {
151 double y=x;
152 // return par[0] + (par[1] * y) +(par[2] * y * y)+(par[3] * y * y*y) + (par[4] * y * y*y*y);
153 return par[0] + y*(par[1] + y*(par[2] + y*(par[3] + y*(par[4]))));
154}
TCanvas * c1
double mass
const Int_t n
Double_t x[10]
EvtComplex exp(const EvtComplex &c)
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:47
RecMdcTrack * mdcTrack()
Definition EvtRecTrack.h:61
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)
const float pi
Definition vector3.h:133