BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
Tof1PID.cxx
Go to the documentation of this file.
1#include "TMath.h"
2#include <cmath>
3
4#include "ParticleID/Tof1PID.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
15Tof1PID* Tof1PID::m_pointer = 0;
17 if ( !m_pointer ) m_pointer = new Tof1PID();
18 return m_pointer;
19}
20
21Tof1PID::Tof1PID() : ParticleIDBase() {
22 m_pars[0] = -0.208289;
23 m_pars[1] = 1.63092;
24 m_pars[2] = -0.0733139;
25 m_pars[3] = 1.02385;
26 m_pars[4] = 0.00145052;
27 m_pars[5] = -1.72471e-06;
28 m_pars[6] = 5.92726e-10;
29 m_pars[7] = -0.0645428;
30 m_pars[8] = -0.00143637;
31 m_pars[9] = -0.133817;
32 m_pars[10] = 0.0101188;
33 m_pars[11] = -5.07622;
34 m_pars[12] = 5.31472;
35 m_pars[13] = -0.443142;
36 m_pars[14] = -12.1083;
37}
38
40 for ( int i = 0; i < 5; i++ )
41 {
42 m_chi[i] = 99.0;
43 m_prob[i] = -1.0;
44 m_sigma[i] = 1;
45 m_offset[i] = 99.0;
46 }
47 m_chimin = 99.;
48 m_pdfmin = 99.;
49 m_ndof = 0;
50 m_mass2 = -999;
51 m_ph1 = -99;
52 m_zhit1 = -99;
53}
54
56 if ( particleIDCalculation() == 0 ) m_ndof = 1;
57}
58
60 int irc = -1;
61
62 EvtRecTrack* recTrk = PidTrk();
63 if ( !( recTrk->isMdcTrackValid() ) ) return irc;
64 RecMdcTrack* mdcTrk = recTrk->mdcTrack();
65 double ptrk = mdcTrk->p();
66 double charge = mdcTrk->charge();
67 // double cost = cos(mdcTrk->theta());
68 if ( !( recTrk->isTofTrackValid() ) ) return irc;
69
70#ifndef BEAN
71 SmartRefVector<RecTofTrack> tofTrk = recTrk->tofTrack();
72 SmartRefVector<RecTofTrack>::iterator it; //=tofTrk.begin();
73#else
74 const std::vector<TTofTrack*>& tofTrk = recTrk->tofTrack();
75 std::vector<TTofTrack*>::const_iterator it; //=tofTrk.begin();
76#endif
77
78 TofHitStatus* hitst = new TofHitStatus;
79 std::vector<int> tof1count;
80 int goodtof1trk = 0;
81 for ( it = tofTrk.begin(); it != tofTrk.end(); it++, goodtof1trk++ )
82 {
83 unsigned int st = ( *it )->status();
84 hitst->setStatus( st );
85 if ( !( hitst->is_barrel() ) ) continue;
86 if ( !( hitst->is_counter() ) ) continue;
87 if ( hitst->layer() == 1 ) tof1count.push_back( goodtof1trk );
88 }
89 delete hitst;
90 if ( tof1count.size() != 1 ) return irc; // not tof2 track or more than 1 tracks
91 it = tofTrk.begin() + tof1count[0];
92 double tof = ( *it )->tof();
93 m_tof1 = tof;
94 // int qual = (*it)->quality();
95 // if(qual != 1) return irc;
96 int cntr = ( *it )->tofID();
97 double path = ( ( *it )->path() ) * 10.0; // the unit from mm to cm
98 m_path1 = path;
99 m_ph1 = ( *it )->ph(); // no change
100 m_zhit1 = ( ( *it )->zrhit() ) * 10; // the unit from mm to cm
101 double beta2 = path * path / velc() / velc() / tof / tof;
102 m_mass2 = ptrk * ptrk * ( 1 / beta2 - 1 );
103 if ( ( m_mass2 > 20 ) || ( m_mass2 < -1 ) ) return irc;
104 if ( tof <= 0 ) return irc;
105 double chitemp = 99.;
106 double pdftemp = 0;
107 double sigma_tmp = ( *it )->sigma( 0 );
108 for ( int i = 0; i < 5; i++ )
109 {
110
111 m_offset[i] = tof - ( *it )->texp( i ) -
112 ( *it )->toffset( i ); //- offsetTof1(i, cntr, ptrk, m_zhit1, m_ph1,charge);
113 if ( sigma_tmp != 0 )
114 {
115 m_sigma[i] = 1.2 * sigma_tmp;
116 if ( i < 2 ) m_sigma[i] = sigma_tmp;
117 }
118 else m_sigma[i] = sigmaTof1( i, cntr, ptrk, m_zhit1, m_ph1, charge );
119 m_chi[i] = m_offset[i] / m_sigma[i];
120
121 if ( fabs( m_chi[i] ) < chitemp ) chitemp = fabs( m_chi[i] );
122 double ppp = pdfCalculate( m_chi[i], 1 );
123 if ( fabs( ppp ) > pdftemp ) pdftemp = fabs( ppp );
124 }
125 m_chimin = chitemp;
126 m_pdfmin = pdftemp;
127 if ( pdftemp < pdfCalculate( pdfMinSigmaCut(), 1 ) ) return irc;
128 if ( fabs( m_chimin ) > chiMinCut() ) return irc;
129 for ( int i = 0; i < 5; i++ ) { m_prob[i] = probCalculate( m_chi[i] * m_chi[i], 1 ); }
130 irc = 0;
131 return irc;
132}
133
134//
135// TOF endcap: Correction routines
136//
137
138double Tof1PID::offsetTof1( int n, int cntr, double ptrk, double z, double ph1,
139 double charge ) {
140 double offset;
141 // double gb = ptrk/xmass(n);
142 double betagamma;
143 switch ( n )
144 {
145
146 case 0: { // Electron
147 offset = 0.0;
148 return offset;
149 }
150
151 case 1: { // Muon
152 offset = 0.0;
153 return offset;
154 }
155
156 case 2: { // Pion
157 betagamma = ptrk / 139.57;
158 break;
159 }
160 case 3: { // Kaon
161 betagamma = ptrk / 493.68;
162 break;
163 }
164
165 case 4: { // Proton
166 betagamma = ptrk / 938.27;
167 break;
168 }
169
170 default: {
171 offset = 0.0;
172 return offset;
173 }
174 break;
175 }
176 double Q = ph1;
177 z = z / 1000.0;
178 double beta = betagamma / TMath::Sqrt( 1 + betagamma * betagamma );
179 double Q0 = sampleQ0( betagamma, beta );
180 double func[15] = { 0. };
181 func[0] = 1.;
182 func[1] = 1. / sqrt( Q );
183 func[2] = z / sqrt( Q );
184 func[3] = z * z / sqrt( Q );
185 func[4] = Q;
186 func[5] = Q * Q;
187 func[6] = Q * Q * Q;
188 func[7] = 1. / ( 0.84 * 0.84 + z * z );
189 func[8] = z;
190 func[9] = z * z;
191 func[10] = z * z * z;
192 func[11] = 1. / sqrt( Q0 );
193 func[12] = z / sqrt( Q0 );
194 func[13] = z * z / sqrt( Q0 );
195 func[14] = z * z * z / sqrt( Q0 );
196 offset = 0.;
197 for ( int i = 0; i < 15; i++ ) { offset += m_pars[i] * func[i]; }
198
199 return offset;
200}
201
202double Tof1PID::sigmaTof1( int n, int cntr, double ptrk, double ztof, double ph,
203 double charge ) {
204 double sigma;
205 // double gb = ptrk/xmass(n);
206 double cosz = cos( ztof / 1000.0 );
207
208 switch ( n )
209 {
210
211 case 0: { // Electron
212 sigma = 0.132405 - 0.135638 * cosz + 0.105528 * cosz * cosz;
213 break;
214 }
215
216 case 1: { // Muon
217 sigma = 0.164057 - 0.199648 * cosz + 0.139481 * cosz * cosz;
218 break;
219 }
220
221 case 2: { // Pion
222 sigma = 0.132943 - 0.0996678 * cosz + 0.0785578 * cosz * cosz;
223 break;
224 }
225 case 3: { // Kaon
226 sigma = 0.146572 - 0.124672 * cosz + 0.0920656 * cosz * cosz;
227 break;
228 }
229
230 case 4: { // Proton
231 sigma = 0.1513 - 0.0806081 * cosz + 0.0607409 * cosz * cosz;
232 break;
233 }
234
235 default: sigma = 0.100; break;
236 }
237 sigma = 0.110;
238 // sigma = 1.0;
239 return sigma;
240}
241
242double Tof1PID::sampleQ0( double betagamma, double beta ) {
243 double val = 0.261 / TMath::Power( beta, 1.96 ) *
244 ( 5.43 - TMath::Power( beta, 1.96 ) -
245 TMath::Log( 1.12 + TMath::Power( 1 / betagamma, 0.386 ) ) );
246 return val * 100.;
247}
const Int_t n
SmartRefVector< RecTofTrack > tofTrack()
double probCalculate(double chi2, int n)
double pdfCalculate(double offset, double sigma)
double sampleQ0(double betagamma, double beta)
Definition Tof1PID.cxx:242
double offsetTof1(int n, int cntr, double ptrk, double ztof, double m_ph1, double charge)
Definition Tof1PID.cxx:138
int particleIDCalculation()
Definition Tof1PID.cxx:59
void calculate()
Definition Tof1PID.cxx:55
void init()
Definition Tof1PID.cxx:39
static Tof1PID * instance()
Definition Tof1PID.cxx:16
double sigmaTof1(int n, int cntr, double ptrk, double ztof, double m_ph1, double charge)
Definition Tof1PID.cxx:202
void setStatus(unsigned int status)