BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
Tof2PID.cxx
Go to the documentation of this file.
1#include "TMath.h"
2#include <cmath>
3
4#include "ParticleID/Tof2PID.h"
5
6#ifndef BEAN
7# include "DstEvent/TofHitStatus.h"
8# include "EvtRecEvent/EvtRecTrack.h"
9# include "MdcRecEvent/RecMdcTrack.h"
10# include "TofRecEvent/RecTofTrack.h"
11#else
12# include "TofHitStatus.h"
13#endif
14
15Tof2PID* Tof2PID::m_pointer = 0;
16
18 if ( !m_pointer ) m_pointer = new Tof2PID();
19 return m_pointer;
20}
21
22Tof2PID::Tof2PID() : ParticleIDBase() {
23 m_pars[0] = -0.237207;
24 m_pars[1] = 1.90436;
25 m_pars[2] = -0.210625;
26 m_pars[3] = 0.664667;
27 m_pars[4] = 0.00165226;
28 m_pars[5] = -1.86503e-06;
29 m_pars[6] = 6.07045e-10;
30 m_pars[7] = -0.0882228;
31 m_pars[8] = 0.0125708;
32 m_pars[9] = -0.117157;
33 m_pars[10] = 0.00252878;
34 m_pars[11] = 0.254343;
35 m_pars[12] = -5.74886;
36 m_pars[13] = 5.20507;
37 m_pars[14] = 1.86515;
38}
39
41
42 for ( int i = 0; i < 5; i++ )
43 {
44 m_chi[i] = 99.0;
45 m_prob[i] = -1.0;
46 m_sigma[i] = 1.0;
47 m_offset[i] = 99.0;
48 }
49 m_chimin = 99.;
50 m_pdfmin = 99.;
51 m_ndof = 0;
52 m_mass2 = -999;
53 m_ph2 = -99;
54 m_zhit2 = -99;
55}
56
58 if ( particleIDCalculation() == 0 ) m_ndof = 1;
59}
60
62 int irc = -1;
63 EvtRecTrack* recTrk = PidTrk();
64 if ( !( recTrk->isMdcTrackValid() ) ) return irc;
65 RecMdcTrack* mdcTrk = recTrk->mdcTrack();
66
67 double ptrk = mdcTrk->p();
68 // double cost = cos(mdcTrk->theta());
69 double charge = mdcTrk->charge();
70
71 if ( !( recTrk->isTofTrackValid() ) ) return irc;
72
73#ifndef BEAN
74 SmartRefVector<RecTofTrack> tofTrk = recTrk->tofTrack();
75 SmartRefVector<RecTofTrack>::iterator it; //=tofTrk.begin();
76#else
77 const std::vector<TTofTrack*>& tofTrk = recTrk->tofTrack();
78 std::vector<TTofTrack*>::const_iterator it; //=tofTrk.begin();
79#endif
80
81 TofHitStatus* hitst = new TofHitStatus;
82 std::vector<int> tof2count;
83 int goodtof2trk = 0;
84 for ( it = tofTrk.begin(); it != tofTrk.end(); it++, goodtof2trk++ )
85 {
86 unsigned int st = ( *it )->status();
87 hitst->setStatus( st );
88
89 if ( !( hitst->is_barrel() ) ) continue;
90 if ( !( hitst->is_counter() ) ) continue;
91 if ( hitst->layer() == 2 ) tof2count.push_back( goodtof2trk );
92 }
93 delete hitst;
94
95 if ( tof2count.size() != 1 ) return irc; // not tof2 track or more than 1 tracks
96 it = tofTrk.begin() + tof2count[0];
97 double tof = ( *it )->tof();
98 m_tof2 = tof;
99
100 if ( tof <= 0 ) return irc;
101 // int qual = (*it)->quality();
102 // if(qual != 1) return irc;
103 int cntr = ( *it )->tofID();
104 double path = ( ( *it )->path() ) * 10.0; // the unit from mm to cm
105
106 m_path2 = path;
107 // m_path2 = path;
108 // fix the bugs the 6.0.0, He K.L.
109 // double path = tofTrk->getPath1();
110 //
111 m_ph2 = ( *it )->ph();
112 m_zhit2 = ( ( *it )->zrhit() ) * 10; // the unit from mm to cm
113
114 double beta2 = path * path / velc() / velc() / tof / tof;
115 m_mass2 = ptrk * ptrk * ( 1 / beta2 - 1 );
116 if ( ( m_mass2 > 20 ) || ( m_mass2 < -1 ) ) return irc;
117
118 double chitemp = 99.;
119 double pdftemp = 0;
120 double sig_tmp = ( *it )->sigma( 0 );
121 for ( int i = 0; i < 5; i++ )
122 {
123 m_offset[i] = tof - ( *it )->texp( i ) -
124 ( *it )->toffset( i ); //- offsetTof1(i, cntr, ptrk, m_zhit1, m_ph1,charge);
125 if ( sig_tmp != 0 )
126 {
127 m_sigma[i] = 1.2 * sig_tmp;
128 if ( i < 2 ) m_sigma[i] = sig_tmp;
129 }
130 else m_sigma[i] = sigmaTof2( i, cntr, ptrk, m_zhit2, m_ph2, charge );
131 m_chi[i] = m_offset[i] / m_sigma[i];
132 if ( fabs( m_chi[i] ) < chitemp ) chitemp = fabs( m_chi[i] );
133 double ppp = pdfCalculate( m_chi[i], 1 );
134 if ( fabs( ppp ) > pdftemp ) pdftemp = fabs( ppp );
135 }
136 // if(ptrk<0.65) m_chi[2]=m_chi[3];
137 m_chimin = chitemp;
138 m_pdfmin = pdftemp;
139 if ( pdftemp < pdfCalculate( pdfMinSigmaCut(), 1 ) ) return irc;
140 if ( fabs( m_chimin ) > chiMinCut() ) return irc;
141
142 // calculate prob
143
144 for ( int i = 0; i < 5; i++ ) { m_prob[i] = probCalculate( m_chi[i] * m_chi[i], 1 ); }
145 irc = 0;
146 return irc;
147}
148
149//
150// TOF endcap: Correction routines
151//
152
153double Tof2PID::offsetTof2( int n, int cntr, double ptrk, double z, double ph,
154 double charge ) {
155 double offset;
156 // double gb = ptrk/xmass(n);
157 double betagamma;
158 switch ( n )
159 {
160
161 case 0: { // Electron
162 offset = 0.0;
163 return offset;
164 }
165
166 case 1: { // Muon
167 offset = 0.0;
168 return offset;
169 }
170
171 case 2: { // Pion
172 betagamma = ptrk / 139.57;
173 break;
174 }
175 case 3: { // Kaon
176 betagamma = ptrk / 493.68;
177 break;
178 }
179
180 case 4: { // Proton
181 betagamma = ptrk / 938.27;
182 break;
183 }
184
185 default: {
186 offset = 0.0;
187 return offset;
188 }
189 break;
190 }
191 z = z / 1000.0;
192 double Q = ph;
193 double beta = betagamma / TMath::Sqrt( 1 + betagamma * betagamma );
194 double Q0 = sampleQ0( betagamma, beta );
195 double func[15] = { 0. };
196 func[0] = 1.;
197 func[1] = 1. / sqrt( Q );
198 func[2] = z / sqrt( Q );
199 func[3] = z * z / sqrt( Q );
200 func[4] = Q;
201 func[5] = Q * Q;
202 func[6] = Q * Q * Q;
203 func[7] = 1. / ( 0.89 * 0.89 + z * z );
204 func[8] = z;
205 func[9] = z * z;
206 func[10] = z * z * z;
207 func[11] = 1. / sqrt( Q0 );
208 func[12] = z / sqrt( Q0 );
209 func[13] = z * z / sqrt( Q0 );
210 func[14] = z * z * z / sqrt( Q0 );
211 offset = 0.;
212 for ( int i = 0; i < 15; i++ ) { offset += m_pars[i] * func[i]; }
213
214 return offset;
215}
216
217double Tof2PID::sigmaTof2( int n, int cntr, double ptrk, double ztof, double ph,
218 double charge ) {
219 double sigma;
220 // double gb = ptrk/xmass(n);
221 double cosz = cos( ztof / 1000.0 );
222 // double phtemp=ph;
223 switch ( n )
224 {
225
226 case 0: { // Electron
227 sigma = 0.115816 - 0.0933215 * cosz + 0.0788252 * cosz * cosz;
228 break;
229 }
230
231 case 1: { // Muon
232 sigma = 0.121536 - 0.0935898 * cosz + 0.0748771 * cosz * cosz;
233 break;
234 }
235
236 case 2: { // Pion
237 sigma = 0.106882 - 0.0147375 * cosz + 0.027491 * cosz * cosz;
238 break;
239 }
240 case 3: { // Kaon
241 sigma = 0.106882 - 0.0147375 * cosz + 0.027491 * cosz * cosz;
242 break;
243 }
244
245 case 4: { // Proton
246 sigma = 0.168489 - 0.131762 * cosz + 0.105708 * cosz * cosz;
247 break;
248 }
249
250 default: sigma = 0.100; break;
251 }
252 sigma = 0.110;
253 // sigma = 1.0;
254 return sigma;
255}
256
257double Tof2PID::sampleQ0( double betagamma, double beta ) {
258 double p1 = 0.261;
259 double p2 = 5.43;
260 double p3 = 1.12;
261 double p4 = 1.96;
262 double p5 = 0.386;
263 double val =
264 p1 / TMath::Power( beta, p4 ) *
265 ( p2 - TMath::Power( beta, p4 ) - TMath::Log( p3 + TMath::Power( 1 / betagamma, p5 ) ) );
266
267 return val * 100.;
268}
double p2[4]
double p1[4]
const Int_t n
SmartRefVector< RecTofTrack > tofTrack()
double probCalculate(double chi2, int n)
double pdfCalculate(double offset, double sigma)
double sigmaTof2(int n, int cntr, double ptrk, double ztof, double m_ph2, double charge)
Definition Tof2PID.cxx:217
static Tof2PID * instance()
Definition Tof2PID.cxx:17
void init()
Definition Tof2PID.cxx:40
double sampleQ0(double betagamma, double beta)
Definition Tof2PID.cxx:257
int particleIDCalculation()
Definition Tof2PID.cxx:61
void calculate()
Definition Tof2PID.cxx:57
double offsetTof2(int n, int cntr, double ptrk, double ztof, double m_ph2, double charge)
Definition Tof2PID.cxx:153
void setStatus(unsigned int status)