BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
TofPID.cxx
Go to the documentation of this file.
1#include <cmath>
2
3#include "ParticleID/Tof1PID.h"
4#include "ParticleID/Tof2PID.h"
5#include "ParticleID/TofPID.h"
6
7#ifndef BEAN
8# include "EvtRecEvent/EvtRecTrack.h"
9# include "MdcRecEvent/RecMdcTrack.h"
10# include "TofRecEvent/RecTofTrack.h"
11#endif
12
13TofPID* TofPID::m_pointer = 0;
15 if ( !m_pointer ) m_pointer = new TofPID();
16 return m_pointer;
17}
18
19TofPID::TofPID() : ParticleIDBase() { ; }
20
22 for ( int i = 0; i < 5; i++ )
23 {
24 m_chi[i] = 99.0;
25 m_prob[i] = -1.0;
26 m_sigma[i] = 1;
27 m_offset[i] = 99.0;
28 }
29 m_chimin = 99.;
30 m_pdfmin = 99.;
31 m_ndof = 0;
32}
33
34double TofPID ::chilayer1( int n ) const {
35 double chi = 99;
36 if ( val_tof1 ) chi = m_tof1pid->chi( n );
37 return chi;
38}
39
40double TofPID ::chilayer2( int n ) const {
41 double chi = 99;
42 if ( val_tof2 ) chi = m_tof2pid->chi( n );
43 return chi;
44}
45
47 if ( particleIDCalculation() == 0 ) m_ndof = 1;
48}
49
51 int irc = -1;
52 EvtRecTrack* recTrk = PidTrk();
53 m_tof1pid = Tof1PID::instance();
54 m_tof1pid->init();
55 m_tof1pid->setRecTrack( recTrk );
56 m_tof1pid->setChiMinCut( chiMinCut() );
57 m_tof1pid->setPdfMinSigmaCut( pdfMinSigmaCut() );
58 m_tof1pid->calculate();
59 val_tof1 = m_tof1pid->IsPidInfoValid();
60 m_tof2pid = Tof2PID::instance();
61 m_tof2pid->init();
62 m_tof2pid->setRecTrack( recTrk );
63 m_tof2pid->setChiMinCut( chiMinCut() );
64 m_tof2pid->setPdfMinSigmaCut( pdfMinSigmaCut() );
65 m_tof2pid->calculate();
66 val_tof2 = m_tof2pid->IsPidInfoValid();
67 double chitemp = 99.;
68 double pdftemp = 0;
69 for ( int i = 0; i < 5; i++ )
70 {
71 double t_tof1 = m_tof1pid->offset( i );
72 double t_tof2 = m_tof2pid->offset( i );
73 double m_sigma1 = m_tof1pid->sigma( i );
74 double m_sigma2 = m_tof2pid->sigma( i );
75 // double weight1,weight2;
76 if ( val_tof1 == 1 && val_tof2 == 1 )
77 {
78 weight1 = ( m_sigma2 * m_sigma2 - 0.041 * 0.041 ) /
79 ( m_sigma1 * m_sigma1 + m_sigma2 * m_sigma2 - 2 * 0.041 * 0.041 );
80 weight2 = ( m_sigma1 * m_sigma1 - 0.041 * 0.041 ) /
81 ( m_sigma1 * m_sigma1 + m_sigma2 * m_sigma2 - 2 * 0.041 * 0.041 );
82 m_sigma[i] =
83 sqrt( ( m_sigma1 * m_sigma1 * m_sigma2 * m_sigma2 - 0.041 * 0.041 * 0.041 * 0.041 ) /
84 ( m_sigma1 * m_sigma1 + m_sigma2 * m_sigma2 - 2 * 0.041 * 0.041 ) );
85 m_offset[i] = weight1 * t_tof1 + weight2 * t_tof2;
86 m_chi[i] = m_offset[i] / m_sigma[i];
87 }
88 if ( val_tof1 == 1 && val_tof2 == 0 )
89 {
90 weight1 = 1;
91 weight2 = 0;
92 m_sigma[i] = m_tof1pid->sigma( i );
93 m_offset[i] = t_tof1;
94 m_chi[i] = m_tof1pid->chi( i );
95 }
96
97 if ( val_tof1 == 0 && val_tof2 == 1 )
98 {
99 weight1 = 0;
100 weight2 = 1;
101 m_sigma[i] = m_tof2pid->sigma( i );
102 m_offset[i] = t_tof2;
103 m_chi[i] = m_tof2pid->chi( i );
104 }
105
106 if ( val_tof1 == 0 && val_tof2 == 0 ) return irc;
107 if ( fabs( m_chi[i] ) < chitemp ) chitemp = fabs( m_chi[i] );
108 double ppp = pdfCalculate( m_chi[i], 1 );
109 if ( fabs( ppp ) > pdftemp ) pdftemp = fabs( ppp );
110 }
111
112 m_chimin = chitemp;
113 m_pdfmin = pdftemp;
114 if ( pdftemp < pdfCalculate( pdfMinSigmaCut(), 1 ) ) return irc;
115 if ( m_chimin > chiMinCut() ) return irc;
116 for ( int i = 0; i < 5; i++ ) m_prob[i] = probCalculate( m_chi[i] * m_chi[i], 1 );
117 irc = 0;
118 return irc;
119}
const Int_t n
double probCalculate(double chi2, int n)
double pdfCalculate(double offset, double sigma)
static Tof1PID * instance()
Definition Tof1PID.cxx:16
static Tof2PID * instance()
Definition Tof2PID.cxx:17
int particleIDCalculation()
Definition TofPID.cxx:50
void init()
Definition TofPID.cxx:21
void calculate()
Definition TofPID.cxx:46
static TofPID * instance()
Definition TofPID.cxx:14