BOSS 6.6.4.p03
BESIII Offline Software System
Loading...
Searching...
No Matches
DedxPID.cxx
Go to the documentation of this file.
1#include <fstream>
2#include <cmath>
3#include <cstdlib>
4
6#ifndef BEAN
10#else
11#include "DstEvtRecTracks.h"
12#endif
13
14DedxPID * DedxPID::m_pointer = 0;
15
17 if(!m_pointer) m_pointer = new DedxPID();
18 return m_pointer;
19}
20
21DedxPID::DedxPID():ParticleIDBase() {
22 m_readstate=0;
23}
24
26 for(int i = 0; i < 5; i++) {
27 m_chi[i] = 99.0;
28 m_prob[i] = -1.0;
29 m_offset[i] = 99.0;
30 m_sigma[i] = 1.0;
31 }
32 m_chimin = 99.;
33 m_pdfmin =99;
34 m_ndof = 0;
35 m_goodHits = -99;
36 m_normPH = -99;
37 m_probPH = -99;
38 m_nhitcutdx=5;
39}
40
42 // int rundedx = getRunNo();
43 if(!m_readstate) {
44 inputpar();
45 m_readstate=1;
46 }
47 if(particleIDCalculation() == 0) m_ndof=1;
48}
49
51 // int rundedx2 = getRunNo();
52 int nhitcutdedx=getNhitCutDx();
53 int irc = -1;
54 EvtRecTrack* recTrk = PidTrk();
55 if(!(recTrk->isMdcTrackValid())) return irc;
56 RecMdcTrack* mdcTrk = recTrk->mdcTrack();
57
58 double ptrk = mdcTrk->p();
59 int charge = mdcTrk->charge();
60 if(ptrk>5) return irc;
61 double cost = cos(mdcTrk->theta());
62 // double sig_the= sin(mdcTrk->theta());
63
64 if(!(recTrk->isMdcDedxValid())) return irc;
65 RecMdcDedx* dedxTrk = recTrk->mdcDedx();
66
67 if((dedxTrk->normPH()>30)||(dedxTrk->normPH()<0)) return irc;
68 m_goodHits = dedxTrk->numGoodHits();
69 if(dedxTrk->numGoodHits()<nhitcutdedx) return irc;
70 m_normPH = dedxTrk->normPH();
71 m_probPH = dedxTrk->probPH();
72 // calculate chi and min chi
73 double chitemp = 99.;
74 double pdftemp = 0;
75 // double testchi[5];
76 // double testptrk[5];
77 // double testcost[5];
78 for(int i = 0; i < 5; i++) {
79 double sep = dedxTrk->chi(i);
80
81#ifndef BEAN
82 string sftver = getenv("BES_RELEASE");
83 string sft;
84 sft.assign(sftver,0,5);
85 if(sft=="6.6.0"||sft=="6.5.5") {
86 m_chi[i] = CorrDedx(i,ptrk,cost,sep,charge);
87 }
88 else
89 m_chi[i]=sep;
90#else
91 // It will work for version > "6.5.5"
92 m_chi[i] = CorrDedx(i,ptrk,cost,sep,charge);
93#endif
94
95 m_offset[i] = offsetDedx(i, ptrk, cost);
96 m_sigma[i] = sigmaDedx(i, ptrk, cost);
97 if(fabs(m_chi[i]) < chitemp) chitemp = fabs(m_chi[i]);
98 double ppp = pdfCalculate(m_chi[i],1);
99 if(fabs(ppp) > pdftemp) pdftemp = fabs(ppp);
100
101 }
102 m_chimin = chitemp;
103 m_pdfmin = pdftemp;
104 if(m_chimin > chiMinCut()) return irc;
105 if(pdftemp < pdfCalculate(pdfMinSigmaCut(),1)) return irc;
106
107
108 // calculate prob
109
110 for(int i = 0; i < 5; i++)
111 m_prob[i] = probCalculate(m_chi[i]*m_chi[i], 1);
112
113 m_ndof = 1;
114 irc = 0;
115 return irc;
116}
117
118//
119// dE/dx Correction routines
120//
121
122
123
124double DedxPID::offsetDedx(int n, double ptrk, double cost) {
125 return 0;
126}
127
128double DedxPID::CorrDedx(int n, double ptrk, double cost,double chi,int charge) {
129 int rundedx2 = getRunNo();
130 double offset = 0.0;
131 double offsetp = 0.0;
132 double offsetc = 0.0;
133 double sigcos = 1;
134 double sigp = 1;
135 double chicor=chi;
136 // double gb = ptrk/xmass(n);
137
138 switch(n) {
139 case 0: { // Electron
140 break;
141 }
142
143 case 1: {// Muon
144 break;
145 }
146
147 case 2: {// Pion
148 // double ptemp = ptrk;
149 double costm = cost;
150 if(ptrk<0.1||ptrk>1) break;
151 int index = int((ptrk-0.1)/0.05);
152 if(index<=0) index=1;
153 if(index>=17) index=16;
154
155 if(fabs(costm)>=0.8) break;
156 int index1 = int((costm+0.8)/0.1);
157 if(index1<=0) index1=1;
158 if(index1>=15) index1=14;
159
160 //psipp data
161 if(rundedx2>=11414&&rundedx2<=14604) {
162 offsetp = cal_par(index,m_psipp_pi_ptrk_offset,ptrk,0.125,0.05);
163 sigp = cal_par(index,m_psipp_pi_ptrk_sigma,ptrk,0.125,0.05);
164 offsetc = cal_par(index1,m_psipp_pi_theta_offset,costm,-0.75,0.1);
165 sigcos = cal_par(index1,m_psipp_pi_theta_sigma,costm,-0.75,0.1);
166 }
167 //psipp mc
168 if(rundedx2<=-11414&&rundedx2>=-14604) {
169 offsetp = cal_par(index,m_psipp_mc_pi_ptrk_offset,ptrk,0.125,0.05);
170 sigp = cal_par(index,m_psipp_mc_pi_ptrk_sigma,ptrk,0.125,0.05);
171 offsetc = cal_par(index1,m_psipp_mc_pi_theta_offset,costm,-0.75,0.1);
172 sigcos = cal_par(index1,m_psipp_mc_pi_theta_sigma,costm,-0.75,0.1);
173 }
174
175 offset=offsetp+sigp*offsetc;
176 chicor=(chicor-offset)/(sigcos*sigp);
177 break;
178 }
179
180 case 3: {// Kaon
181 // double ptemp = ptrk;
182 double costm = cost;
183 if(ptrk<0.3||ptrk>0.8) break;
184 offset=0;
185 int index = int((ptrk-0.3)/0.1);
186 if(index<=0) index=1;
187 if(index>=4) index=3;
188
189 int index1 = int((costm+0.9)/0.1);
190 if(index1<=0) index1=1;
191 if(index1>=17) index1=16;
192 //data Jpsi
193 if(rundedx2>=9947&&rundedx2<=10878) {
194 if(charge>0) {
195 offsetp = cal_par(index,m_jpsi_kap_ptrk_offset,ptrk,0.35,0.1);
196 sigp = cal_par(index,m_jpsi_kap_ptrk_sigma,ptrk,0.35,0.1);
197 if(fabs(costm)<=0.83) {
198 offsetc = cal_par(index1,m_jpsi_kap_theta_offset,costm,-0.85,0.1);
199 sigcos = cal_par(index1,m_jpsi_kap_theta_sigma,costm,-0.85,0.1);
200 }
201 }
202 if(charge<0) {
203 offsetp = cal_par(index,m_jpsi_kam_ptrk_offset,ptrk,0.35,0.1);
204 sigp = cal_par(index,m_jpsi_kam_ptrk_sigma,ptrk,0.35,0.1);
205 if(fabs(costm)<=0.83) {
206 offsetc = cal_par(index1,m_jpsi_kam_theta_offset,costm,-0.85,0.1);
207 sigcos = cal_par(index1,m_jpsi_kam_theta_sigma,costm,-0.85,0.1);
208 }
209 }
210 }
211
212 //mc Jpsi
213 if(rundedx2<=-9947&&rundedx2>=-10878) {
214 if(charge>0) {
215 offsetp = cal_par(index,m_jpsi_mc_kap_ptrk_offset,ptrk,0.35,0.1);
216 sigp = cal_par(index,m_jpsi_mc_kap_ptrk_sigma,ptrk,0.35,0.1);
217 if(fabs(costm)<=0.83) {
218 offsetc = cal_par(index1,m_jpsi_mc_kap_theta_offset,costm,-0.85,0.1);
219 sigcos = cal_par(index1,m_jpsi_mc_kap_theta_sigma,costm,-0.85,0.1);
220 }
221 }
222 if(charge<0) {
223 offsetp = cal_par(index,m_jpsi_mc_kam_ptrk_offset,ptrk,0.35,0.1);
224 sigp = cal_par(index,m_jpsi_mc_kam_ptrk_sigma,ptrk,0.35,0.1);
225 if(fabs(costm)<=0.83) {
226 offsetc = cal_par(index1,m_jpsi_mc_kam_theta_offset,costm,-0.85,0.1);
227 sigcos = cal_par(index1,m_jpsi_mc_kam_theta_sigma,costm,-0.85,0.1);
228 }
229 }
230 }
231
232 //data Psip
233 if(rundedx2>=8093&&rundedx2<=9025) {
234 if(ptrk<0.3||ptrk>1.2) break;
235 index = int((ptrk-0.3)/0.1);
236 if(index<=0) index=1;
237 if(index>=8) index=7;
238 if(charge>0) {
239 offsetp = cal_par(index,m_psip_kap_ptrk_offset,ptrk,0.35,0.1);
240 sigp = cal_par(index,m_psip_kap_ptrk_sigma,ptrk,0.35,0.1);
241 }
242 if(charge<0) {
243 offsetp = cal_par(index,m_psip_kam_ptrk_offset,ptrk,0.35,0.1);
244 sigp = cal_par(index,m_psip_kam_ptrk_sigma,ptrk,0.35,0.1);
245 }
246 }
247
248 //mc Psip
249 if(rundedx2<=-8093&&rundedx2>=-9025) {
250 // if(ptrk < 0.4) ptrk = 0.4;
251 if(ptrk<0.3||ptrk>1.2) break;
252 index = int((ptrk-0.3)/0.1);
253 if(index<=0) index=1;
254 if(index>=8) index=7;
255 if(charge>0) {
256 offsetp = cal_par(index,m_psip_mc_kap_ptrk_offset,ptrk,0.35,0.1);
257 sigp = cal_par(index,m_psip_mc_kap_ptrk_sigma,ptrk,0.35,0.1);
258 }
259 if(charge<0) {
260 offsetp = cal_par(index,m_psip_mc_kam_ptrk_offset,ptrk,0.35,0.1);
261 sigp = cal_par(index,m_psip_mc_kam_ptrk_sigma,ptrk,0.35,0.1);
262 }
263 }
264
265
266 //psipp kaon data
267 if(rundedx2>=11414&&rundedx2<=14604) {
268 if(ptrk<0.15||ptrk>1) break;
269 index = int((ptrk-0.15)/0.05);
270 if(index<=0) index=1;
271 if(index>=16) index=15;
272 if(fabs(costm)>=0.8) break;
273 index1 = int((costm+0.8)/0.1);
274 if(index1<=0) index1=1;
275 if(index1>=15) index1=14;
276
277 offsetp = cal_par(index,m_psipp_ka_ptrk_offset,ptrk,0.175,0.05);
278 sigp = cal_par(index,m_psipp_ka_ptrk_sigma,ptrk,0.175,0.05);
279 offsetc = cal_par(index1,m_psipp_ka_theta_offset,costm,-0.75,0.1);
280 sigcos = cal_par(index1,m_psipp_ka_theta_sigma,costm,-0.75,0.1);
281 }
282 //psipp kaon mc
283 if(rundedx2<=-11414&&rundedx2>=-14604) {
284 if(ptrk<0.15||ptrk>1) break;
285 index = int((ptrk-0.15)/0.05);
286 if(index<=0) index=1;
287 if(index>=16) index=15;
288 if(fabs(costm)>=0.8) break;
289 index1 = int((costm+0.8)/0.1);
290 if(index1<=0) index1=1;
291 if(index1>=15) index1=14;
292 offsetp = cal_par(index,m_psipp_mc_ka_ptrk_offset,ptrk,0.175,0.05);
293 sigp = cal_par(index,m_psipp_mc_ka_ptrk_sigma,ptrk,0.175,0.05);
294 offsetc = cal_par(index1,m_psipp_mc_ka_theta_offset,costm,-0.75,0.1);
295 sigcos = cal_par(index1,m_psipp_mc_ka_theta_sigma,costm,-0.75,0.1);
296 }
297
298 offset=offsetp+sigp*offsetc;
299 chicor=(chicor-offset)/(sigcos*sigp);
300 break;
301 }
302
303 case 4 : { // Proton
304 // double ptemp = ptrk;
305 double costm = cost;
306 if(ptrk<0.3||ptrk>1.1) break;
307 int index = int((ptrk-0.3)/0.1);
308 if(index<=0) index=1;
309 if(index>=7) index=6;
310
311 int index1 = int((costm+0.9)/0.1);
312 if(index1<=0) index1=1;
313 if(index1>=17) index1=16;
314
315 // double plog = log(ptemp);
316 offset=0;
317 if(rundedx2>=9947&&rundedx2<=10878) {
318 if(charge>0) {
319 offsetp = cal_par(index,m_jpsi_protonp_ptrk_offset,ptrk,0.35,0.1);
320 sigp = cal_par(index,m_jpsi_protonp_ptrk_sigma,ptrk,0.35,0.1);
321 if(fabs(costm)<=0.83) {
322 offsetc = cal_par(index1,m_jpsi_protonp_theta_offset,costm,-0.85,0.1);
323 sigcos = cal_par(index1,m_jpsi_protonp_theta_sigma,costm,-0.85,0.1);
324 }
325 }
326 if(charge<0) {
327 offsetp = cal_par(index,m_jpsi_protonm_ptrk_offset,ptrk,0.35,0.1);
328 sigp = cal_par(index,m_jpsi_protonm_ptrk_sigma,ptrk,0.35,0.1);
329 if(fabs(costm)<=0.83) {
330 offsetc = cal_par(index1,m_jpsi_protonm_theta_offset,costm,-0.85,0.1);
331 sigcos = cal_par(index1,m_jpsi_protonm_theta_sigma,costm,-0.85,0.1);
332 }
333 }
334 }
335
336 //mc JPsi
337 if(rundedx2<=-9947&&rundedx2>=-10878) {
338 if(charge>0) {
339 offsetp = cal_par(index,m_jpsi_mc_protonp_ptrk_offset,ptrk,0.35,0.1);
340 sigp = cal_par(index,m_jpsi_mc_protonp_ptrk_sigma,ptrk,0.35,0.1);
341 if(fabs(costm)<=0.83) {
342 offsetc = cal_par(index1,m_jpsi_mc_protonp_theta_offset,costm,-0.85,0.1);
343 sigcos = cal_par(index1,m_jpsi_mc_protonp_theta_sigma,costm,-0.85,0.1);
344 }
345 }
346 if(charge<0) {
347 offsetp = cal_par(index,m_jpsi_mc_protonm_ptrk_offset,ptrk,0.35,0.1);
348 sigp = cal_par(index,m_jpsi_mc_protonm_ptrk_sigma,ptrk,0.35,0.1);
349 if(fabs(costm)<=0.83) {
350 offsetc = cal_par(index1,m_jpsi_mc_protonm_theta_offset,costm,-0.85,0.1);
351 sigcos = cal_par(index1,m_jpsi_mc_protonm_theta_sigma,costm,-0.85,0.1);
352 }
353 }
354 }
355
356 //data Psip
357 if(rundedx2>=8093&&rundedx2<=9025) {
358 if(charge>0) {
359 offsetp = cal_par(index,m_psip_protonp_ptrk_offset,ptrk,0.35,0.1);
360 sigp = cal_par(index,m_psip_protonp_ptrk_sigma,ptrk,0.35,0.1);
361 }
362 if(charge<0) {
363 offsetp = cal_par(index,m_psip_protonm_ptrk_offset,ptrk,0.35,0.1);
364 sigp = cal_par(index,m_psip_protonm_ptrk_sigma,ptrk,0.35,0.1);
365 }
366 }
367
368 //mc Psip
369 if(rundedx2<=-8093&&rundedx2>=-9025) {
370 if(charge>0) {
371 offsetp = cal_par(index,m_psip_mc_protonp_ptrk_offset,ptrk,0.35,0.1);
372 sigp = cal_par(index,m_psip_mc_protonp_ptrk_sigma,ptrk,0.35,0.1);
373 }
374 if(charge<0) {
375 offsetp = cal_par(index,m_psip_mc_protonm_ptrk_offset,ptrk,0.35,0.1);
376 sigp = cal_par(index,m_psip_mc_protonm_ptrk_sigma,ptrk,0.35,0.1);
377 }
378 }
379
380 //psipp proton data
381 if(rundedx2>=11414&&rundedx2<=14604) {
382 if(ptrk<0.2||ptrk>1.1) break;
383 index = int((ptrk-0.2)/0.05);
384 if(index<=0) index=1;
385 if(index>=17) index=16;
386 if(fabs(costm)>=0.83) break;
387 index1 = int((costm+0.9)/0.1);
388 if(index1<=0) index1=1;
389 if(index1>=17) index1=16;
390
391 offsetp = cal_par(index,m_psipp_proton_ptrk_offset,ptrk,0.225,0.05);
392 sigp = cal_par(index,m_psipp_proton_ptrk_sigma,ptrk,0.225,0.05);
393 offsetc = cal_par(index1,m_psipp_proton_theta_offset,costm,-0.85,0.1);
394 sigcos = cal_par(index1,m_psipp_proton_theta_sigma,costm,-0.85,0.1);
395 }
396 //psipp proton mc
397 if(rundedx2<=-11414&&rundedx2>=-14604) {
398 if(ptrk<0.2||ptrk>1.1) break;
399 index = int((ptrk-0.2)/0.1);
400 if(index<=0) index=1;
401 if(index>=8) index=7;
402 if(fabs(costm)>=0.83) break;
403 index1 = int((costm+0.9)/0.1);
404 if(index1<=0) index1=1;
405 if(index1>=17) index1=16;
406 offsetp = cal_par(index,m_psipp_mc_proton_ptrk_offset,ptrk,0.25,0.1);
407 sigp = cal_par(index,m_psipp_mc_proton_ptrk_sigma,ptrk,0.25,0.1);
408 offsetc = cal_par(index1,m_psipp_mc_proton_theta_offset,costm,-0.85,0.1);
409 sigcos = cal_par(index1,m_psipp_mc_proton_theta_sigma,costm,-0.85,0.1);
410 }
411 offset=offsetp+sigp*offsetc;
412 chicor=(chicor-offset)/(sigcos*sigp);
413 break;
414 }
415
416 default:
417 offset = 0.0;
418 break;
419 }
420 // offset = 0.0;
421 return chicor;
422}
423
424double DedxPID::sigmaDedx(int n, double ptrk, double cost) {
425
426 /* int rundedx3 = getRunNo();
427 double sigma = 1.0;
428 double sigp = 1.0;
429 double sigmac = 1.0;
430 double gb = ptrk/xmass(n);
431 switch(n) {
432
433 case 0: {// Electron
434 double ptemp = ptrk;
435 double costm = cost;
436 break;
437 }
438
439 case 1: {// Muon
440 double ptemp = ptrk;
441 double costm = cost;
442 break;
443 }
444
445 case 2: {// Pion
446 double ptemp = ptrk;
447 double costm = cost;
448 break;
449 }
450
451 case 3: { // Kaon
452 double ptemp = ptrk;
453 double costm = cost;
454 break;
455 }
456
457
458 case 4: {// Proton
459 double ptemp = ptrk;
460 double costm = cost;
461 break;
462 }
463
464 default:
465 sigma = 1.0;
466 break;
467 }
468 */
469 // sigma = 1.2;
470 // sigma =1.0;
471 return 1;
472 // return sigma;
473}
474
475double DedxPID::mypol3(double x, double par0, double par1, double par2, double par3)
476{
477 double y = x;
478 return par0 + (par1 * y) +(par2 * y * y) + (par3 * y * y * y);
479
480}
481
482double DedxPID::mypol5(double x, double par0, double par1, double par2, double par3, double par4, double par5)
483{
484 double y = x;
485 return par0 + (par1 * y) +(par2 * y * y) + (par3 * y * y * y) + (par4 * y * y * y *y)+ (par5 * y * y * y * y * y);
486
487}
488
490
491 //Jpsi ka+ momentum correction
492 std::string jpsi_kap_mom = path + "/share/JPsi/kaon/dedx_kap.txt";
493 std::string jpsi_kap_mom_mc = path + "/share/JPsi/kaon/dedx_kap_mc.txt";
494 ifstream inputmomdata6(jpsi_kap_mom.c_str(),std::ios_base::in);
495 if ( !inputmomdata6 ) {
496 cout << " can not open: " << jpsi_kap_mom << endl;
497 exit(1);
498 }
499 ifstream inputmomdata6mc(jpsi_kap_mom_mc.c_str(),std::ios_base::in);
500 if ( !inputmomdata6mc ) {
501 cout << " can not open: " << jpsi_kap_mom_mc << endl;
502 exit(1);
503 }
504 for(int i=0; i<12; i++) {
505 inputmomdata6>>m_jpsi_kap_ptrk_offset[i];
506 inputmomdata6>>m_jpsi_kap_ptrk_sigma[i];
507 inputmomdata6mc>>m_jpsi_mc_kap_ptrk_offset[i];
508 inputmomdata6mc>>m_jpsi_mc_kap_ptrk_sigma[i];
509 }
510
511 //Jpsi ka- momentum correction
512 std::string jpsi_kam_mom = path + "/share/JPsi/kaon/dedx_kam.txt";
513 std::string jpsi_kam_mom_mc = path + "/share/JPsi/kaon/dedx_kam_mc.txt";
514 ifstream inputmomdata7(jpsi_kam_mom.c_str(),std::ios_base::in);
515 if ( !inputmomdata7 ) {
516 cout << " can not open: " << jpsi_kam_mom << endl;
517 exit(1);
518 }
519 ifstream inputmomdata7mc(jpsi_kam_mom_mc.c_str(),std::ios_base::in);
520 if ( !inputmomdata7mc ) {
521 cout << " can not open: " << jpsi_kam_mom_mc << endl;
522 exit(1);
523 }
524 for(int i=0; i<12; i++) {
525 inputmomdata7>>m_jpsi_kam_ptrk_offset[i];
526 inputmomdata7>>m_jpsi_kam_ptrk_sigma[i];
527 inputmomdata7mc>>m_jpsi_mc_kam_ptrk_offset[i];
528 inputmomdata7mc>>m_jpsi_mc_kam_ptrk_sigma[i];
529
530 }
531
532
533 //Jpsi ka+ theta correction
534 std::string jpsi_kap_the = path + "/share/JPsi/kaon/dedx_kap_theta.txt";
535 std::string jpsi_kap_the_mc = path + "/share/JPsi/kaon/dedx_kap_theta_mc.txt";
536 ifstream inputmomdata8(jpsi_kap_the.c_str(),std::ios_base::in);
537 if ( !inputmomdata8 ) {
538 cout << " can not open: " << jpsi_kap_the << endl;
539 exit(1);
540 }
541 ifstream inputmomdata8mc(jpsi_kap_the_mc.c_str(),std::ios_base::in);
542 if ( !inputmomdata8mc ) {
543 cout << " can not open: " << jpsi_kap_the_mc << endl;
544 exit(1);
545 }
546 for(int i=0; i<18; i++) {
547 inputmomdata8>>m_jpsi_kap_theta_offset[i];
548 inputmomdata8>>m_jpsi_kap_theta_sigma[i];
549 inputmomdata8mc>>m_jpsi_mc_kap_theta_offset[i];
550 inputmomdata8mc>>m_jpsi_mc_kap_theta_sigma[i];
551 }
552
553 //Jpsi ka- theta correction
554 std::string jpsi_kam_the = path + "/share/JPsi/kaon/dedx_kam_theta.txt";
555 std::string jpsi_kam_the_mc = path + "/share/JPsi/kaon/dedx_kam_theta_mc.txt";
556 ifstream inputmomdata9(jpsi_kam_the.c_str(),std::ios_base::in);
557 if ( !inputmomdata9 ) {
558 cout << " can not open: " << jpsi_kam_the << endl;
559 exit(1);
560 }
561 ifstream inputmomdata9mc(jpsi_kam_the_mc.c_str(),std::ios_base::in);
562 if ( !inputmomdata9mc ) {
563 cout << " can not open: " << jpsi_kam_the_mc << endl;
564 exit(1);
565 }
566 for(int i=0; i<18; i++) {
567 inputmomdata9>>m_jpsi_kam_theta_offset[i];
568 inputmomdata9>>m_jpsi_kam_theta_sigma[i];
569 inputmomdata9mc>>m_jpsi_mc_kam_theta_offset[i];
570 inputmomdata9mc>>m_jpsi_mc_kam_theta_sigma[i];
571 }
572
573 //Jpsi proton+ momentum correction
574 std::string jpsi_protonp_mom = path + "/share/JPsi/proton/dedx_protonp.txt";
575 std::string jpsi_protonp_mom_mc = path + "/share/JPsi/proton/dedx_protonp_mc.txt";
576 ifstream inputmomdata12(jpsi_protonp_mom.c_str(),std::ios_base::in);
577 if ( !inputmomdata12 ) {
578 cout << " can not open: " << jpsi_protonp_mom << endl;
579 exit(1);
580 }
581 ifstream inputmomdata12mc(jpsi_protonp_mom_mc.c_str(),std::ios_base::in);
582 if ( !inputmomdata12mc ) {
583 cout << " can not open: " << jpsi_protonp_mom_mc << endl;
584 exit(1);
585 }
586 for(int i=0; i<8; i++) {
587 inputmomdata12>>m_jpsi_protonp_ptrk_offset[i];
588 inputmomdata12>>m_jpsi_protonp_ptrk_sigma[i];
589 inputmomdata12mc>>m_jpsi_mc_protonp_ptrk_offset[i];
590 inputmomdata12mc>>m_jpsi_mc_protonp_ptrk_sigma[i];
591 }
592
593 //Jpsi proton- momentum correction
594 std::string jpsi_protonm_mom = path + "/share/JPsi/proton/dedx_protonm.txt";
595 std::string jpsi_protonm_mom_mc = path + "/share/JPsi/proton/dedx_protonm_mc.txt";
596 ifstream inputmomdata13(jpsi_protonm_mom.c_str(),std::ios_base::in);
597 if ( !inputmomdata13 ) {
598 cout << " can not open: " << jpsi_protonm_mom << endl;
599 exit(1);
600 }
601 ifstream inputmomdata13mc(jpsi_protonm_mom_mc.c_str(),std::ios_base::in);
602 if ( !inputmomdata13mc ) {
603 cout << " can not open: " << jpsi_protonm_mom_mc << endl;
604 exit(1);
605 }
606 for(int i=0; i<8; i++) {
607 inputmomdata13>>m_jpsi_protonm_ptrk_offset[i];
608 inputmomdata13>>m_jpsi_protonm_ptrk_sigma[i];
609 inputmomdata13mc>>m_jpsi_mc_protonm_ptrk_offset[i];
610 inputmomdata13mc>>m_jpsi_mc_protonm_ptrk_sigma[i];
611 }
612
613 //Jpsi proton+ theta correction
614 std::string jpsi_protonp_the = path + "/share/JPsi/proton/dedx_protonp_theta.txt";
615 std::string jpsi_protonp_the_mc = path + "/share/JPsi/proton/dedx_protonp_theta_mc.txt";
616
617 ifstream inputmomdata14(jpsi_protonp_the.c_str(),std::ios_base::in);
618 if ( !inputmomdata14 ) {
619 cout << " can not open: " << jpsi_protonp_the << endl;
620 exit(1);
621 }
622 ifstream inputmomdata14mc(jpsi_protonp_the_mc.c_str(),std::ios_base::in);
623 if ( !inputmomdata14mc ) {
624 cout << " can not open: " << jpsi_protonp_the_mc << endl;
625 exit(1);
626 }
627 for(int i=0; i<18; i++) {
628 inputmomdata14>>m_jpsi_protonp_theta_offset[i];
629 inputmomdata14>>m_jpsi_protonp_theta_sigma[i];
630 inputmomdata14mc>>m_jpsi_mc_protonp_theta_offset[i];
631 inputmomdata14mc>>m_jpsi_mc_protonp_theta_sigma[i];
632 }
633
634 //Jpsi proton- theta correction
635 std::string jpsi_protonm_the = path + "/share/JPsi/proton/dedx_protonm_theta.txt";
636 std::string jpsi_protonm_the_mc = path + "/share/JPsi/proton/dedx_protonm_theta_mc.txt";
637 ifstream inputmomdata15(jpsi_protonm_the.c_str(),std::ios_base::in);
638 if ( !inputmomdata15 ) {
639 cout << " can not open: " << jpsi_protonm_the << endl;
640 exit(1);
641 }
642 ifstream inputmomdata15mc(jpsi_protonm_the_mc.c_str(),std::ios_base::in);
643 if ( !inputmomdata15mc ) {
644 cout << " can not open: " << jpsi_protonm_the_mc << endl;
645 exit(1);
646 }
647 for(int i=0; i<18; i++) {
648 inputmomdata15>>m_jpsi_protonm_theta_offset[i];
649 inputmomdata15>>m_jpsi_protonm_theta_sigma[i];
650 inputmomdata15mc>>m_jpsi_mc_protonm_theta_offset[i];
651 inputmomdata15mc>>m_jpsi_mc_protonm_theta_sigma[i];
652 }
653
654
655
656
657 // Psip ka+ momentum correction
658 std::string psip_kap_mom = path + "/share/Psip/kaon/dedx_kap.txt";
659 std::string psip_kap_mom_mc = path + "/share/Psip/kaon/dedx_kap_mc.txt";
660 ifstream inputmomdata24(psip_kap_mom.c_str(),std::ios_base::in);
661 if ( !inputmomdata24 ) {
662 cout << " can not open: " << psip_kap_mom << endl;
663 exit(1);
664 }
665 ifstream inputmomdata24mc(psip_kap_mom_mc.c_str(),std::ios_base::in);
666 if ( !inputmomdata24mc ) {
667 cout << " can not open: " << psip_kap_mom_mc << endl;
668 exit(1);
669 }
670 for(int i=0; i<9; i++) {
671 inputmomdata24>>m_psip_kap_ptrk_offset[i];
672 inputmomdata24>>m_psip_kap_ptrk_sigma[i];
673 inputmomdata24mc>>m_psip_mc_kap_ptrk_offset[i];
674 inputmomdata24mc>>m_psip_mc_kap_ptrk_sigma[i];
675 }
676
677 //Psip ka- momentum correction
678 std::string psip_kam_mom = path + "/share/Psip/kaon/dedx_kam.txt";
679 std::string psip_kam_mom_mc = path + "/share/Psip/kaon/dedx_kam_mc.txt";
680 ifstream inputmomdata25(psip_kam_mom.c_str(),std::ios_base::in);
681 if ( !inputmomdata25 ) {
682 cout << " can not open: " << psip_kam_mom << endl;
683 exit(1);
684 }
685 ifstream inputmomdata25mc(psip_kam_mom_mc.c_str(),std::ios_base::in);
686 if ( !inputmomdata25mc ) {
687 cout << " can not open: " << psip_kam_mom_mc << endl;
688 exit(1);
689 }
690 for(int i=0; i<9; i++) {
691 inputmomdata25>>m_psip_kam_ptrk_offset[i];
692 inputmomdata25>>m_psip_kam_ptrk_sigma[i];
693 inputmomdata25mc>>m_psip_mc_kam_ptrk_offset[i];
694 inputmomdata25mc>>m_psip_mc_kam_ptrk_sigma[i];
695 }
696
697
698 // Psip proton+ momentum correction
699 std::string psip_protonp_mom = path + "/share/Psip/proton/dedx_protonp.txt";
700 std::string psip_protonp_mom_mc = path + "/share/Psip/proton/dedx_protonp_mc.txt";
701 ifstream inputmomdata26(psip_protonp_mom.c_str(),std::ios_base::in);
702 if ( !inputmomdata26 ) {
703 cout << " can not open: " << psip_protonp_mom << endl;
704 exit(1);
705 }
706 ifstream inputmomdata26mc(psip_protonp_mom_mc.c_str(),std::ios_base::in);
707 if ( !inputmomdata26mc ) {
708 cout << " can not open: " << psip_protonp_mom_mc << endl;
709 exit(1);
710 }
711 for(int i=0; i<9; i++) {
712 inputmomdata26>>m_psip_protonp_ptrk_offset[i];
713 inputmomdata26>>m_psip_protonp_ptrk_sigma[i];
714 inputmomdata26mc>>m_psip_mc_protonp_ptrk_offset[i];
715 inputmomdata26mc>>m_psip_mc_protonp_ptrk_sigma[i];
716 }
717
718 //Psip proton- momentum correction
719 std::string psip_protonm_mom = path + "/share/Psip/proton/dedx_protonm.txt";
720 std::string psip_protonm_mom_mc = path + "/share/Psip/proton/dedx_protonm_mc.txt";
721 ifstream inputmomdata27(psip_protonm_mom.c_str(),std::ios_base::in);
722 if ( !inputmomdata27 ) {
723 cout << " can not open: " << psip_protonm_mom << endl;
724 exit(1);
725 }
726 ifstream inputmomdata27mc(psip_protonm_mom_mc.c_str(),std::ios_base::in);
727 if ( !inputmomdata27mc ) {
728 cout << " can not open: " << psip_protonm_mom_mc << endl;
729 exit(1);
730 }
731 for(int i=0; i<9; i++) {
732 inputmomdata27>>m_psip_protonm_ptrk_offset[i];
733 inputmomdata27>>m_psip_protonm_ptrk_sigma[i];
734 inputmomdata27mc>>m_psip_mc_protonm_ptrk_offset[i];
735 inputmomdata27mc>>m_psip_mc_protonm_ptrk_sigma[i];
736 }
737
738 //Psipp pi momentum correction
739 std::string psipp_pi_mom = path + "/share/Psipp/pion/dedx_pi.txt";
740 std::string psipp_pi_mom_mc = path + "/share/Psipp/pion/dedx_pi_mc.txt";
741 ifstream inputmomdata28(psipp_pi_mom.c_str(),std::ios_base::in);
742 if ( !inputmomdata28 ) {
743 cout << " can not open: " << psipp_pi_mom << endl;
744 exit(1);
745 }
746 ifstream inputmomdata28mc(psipp_pi_mom_mc.c_str(),std::ios_base::in);
747 if ( !inputmomdata28mc ) {
748 cout << " can not open: " << psipp_pi_mom_mc << endl;
749 exit(1);
750 }
751 for(int i=0; i<18; i++) {
752 inputmomdata28>>m_psipp_pi_ptrk_offset[i];
753 inputmomdata28>>m_psipp_pi_ptrk_sigma[i];
754 inputmomdata28mc>>m_psipp_mc_pi_ptrk_offset[i];
755 inputmomdata28mc>>m_psipp_mc_pi_ptrk_sigma[i];
756 }
757
758 //Psipp pi theta correction
759 std::string psipp_pi_the = path + "/share/Psipp/pion/dedx_pi_theta.txt";
760 std::string psipp_pi_the_mc = path + "/share/Psipp/pion/dedx_pi_theta_mc.txt";
761 ifstream inputmomdata29(psipp_pi_the.c_str(),std::ios_base::in);
762 if ( !inputmomdata29 ) {
763 cout << " can not open: " << psipp_pi_the << endl;
764 exit(1);
765 }
766 ifstream inputmomdata29mc(psipp_pi_the_mc.c_str(),std::ios_base::in);
767 if ( !inputmomdata29mc ) {
768 cout << " can not open: " << psipp_pi_the_mc << endl;
769 exit(1);
770 }
771 for(int i=0; i<16; i++) {
772 inputmomdata29>>m_psipp_pi_theta_offset[i];
773 inputmomdata29>>m_psipp_pi_theta_sigma[i];
774 inputmomdata29mc>>m_psipp_mc_pi_theta_offset[i];
775 inputmomdata29mc>>m_psipp_mc_pi_theta_sigma[i];
776 }
777
778 //Psipp ka momentum correction
779 std::string psipp_ka_mom = path + "/share/Psipp/kaon/dedx_ka.txt";
780 std::string psipp_ka_mom_mc = path + "/share/Psipp/kaon/dedx_ka_mc.txt";
781 ifstream inputmomdata30(psipp_ka_mom.c_str(),std::ios_base::in);
782 if ( !inputmomdata30 ) {
783 cout << " can not open: " << psipp_ka_mom << endl;
784 exit(1);
785 }
786 ifstream inputmomdata30mc(psipp_ka_mom_mc.c_str(),std::ios_base::in);
787 if ( !inputmomdata30mc ) {
788 cout << " can not open: " << psipp_ka_mom_mc << endl;
789 exit(1);
790 }
791 for(int i=0; i<17; i++) {
792 inputmomdata30>>m_psipp_ka_ptrk_offset[i];
793 inputmomdata30>>m_psipp_ka_ptrk_sigma[i];
794 inputmomdata30mc>>m_psipp_mc_ka_ptrk_offset[i];
795 inputmomdata30mc>>m_psipp_mc_ka_ptrk_sigma[i];
796 }
797
798 //Psipp ka theta correction
799 std::string psipp_ka_the = path + "/share/Psipp/kaon/dedx_ka_theta.txt";
800 std::string psipp_ka_the_mc = path + "/share/Psipp/kaon/dedx_ka_theta_mc.txt";
801 ifstream inputmomdata31(psipp_ka_the.c_str(),std::ios_base::in);
802 if ( !inputmomdata31 ) {
803 cout << " can not open: " << psipp_ka_the << endl;
804 exit(1);
805 }
806 ifstream inputmomdata31mc(psipp_ka_the_mc.c_str(),std::ios_base::in);
807 if ( !inputmomdata31mc ) {
808 cout << " can not open: " << psipp_ka_the_mc << endl;
809 exit(1);
810 }
811 for(int i=0; i<16; i++) {
812 inputmomdata31>>m_psipp_ka_theta_offset[i];
813 inputmomdata31>>m_psipp_ka_theta_sigma[i];
814 inputmomdata31mc>>m_psipp_mc_ka_theta_offset[i];
815 inputmomdata31mc>>m_psipp_mc_ka_theta_sigma[i];
816 }
817
818
819 //Psipp proton momentum correction
820 std::string psipp_proton_mom = path + "/share/Psipp/proton/dedx_proton.txt";
821 std::string psipp_proton_mom_mc = path + "/share/Psipp/proton/dedx_proton_mc.txt";
822 ifstream inputmomdata32(psipp_proton_mom.c_str(),std::ios_base::in);
823 if ( !inputmomdata32 ) {
824 cout << " can not open: " << psipp_proton_mom << endl;
825 exit(1);
826 }
827 ifstream inputmomdata32mc(psipp_proton_mom_mc.c_str(),std::ios_base::in);
828 if ( !inputmomdata32mc ) {
829 cout << " can not open: " << psipp_proton_mom_mc << endl;
830 exit(1);
831 }
832 for(int i=0; i<18; i++) {
833 inputmomdata32>>m_psipp_proton_ptrk_offset[i];
834 inputmomdata32>>m_psipp_proton_ptrk_sigma[i];
835 }
836 for(int i=0; i<9; i++) {
837 inputmomdata32mc>>m_psipp_mc_proton_ptrk_offset[i];
838 inputmomdata32mc>>m_psipp_mc_proton_ptrk_sigma[i];
839 }
840
841 //Psipp proton theta correction
842 std::string psipp_proton_the = path + "/share/Psipp/proton/dedx_proton_theta.txt";
843 std::string psipp_proton_the_mc = path + "/share/Psipp/proton/dedx_proton_theta_mc.txt";
844 ifstream inputmomdata33(psipp_proton_the.c_str(),std::ios_base::in);
845 if ( !inputmomdata33 ) {
846 cout << " can not open: " << psipp_proton_the << endl;
847 exit(1);
848 }
849 ifstream inputmomdata33mc(psipp_proton_the_mc.c_str(),std::ios_base::in);
850 if ( !inputmomdata33mc ) {
851 cout << " can not open: " << psipp_proton_the_mc << endl;
852 exit(1);
853 }
854 for(int i=0; i<18; i++) {
855 inputmomdata33>>m_psipp_proton_theta_offset[i];
856 inputmomdata33>>m_psipp_proton_theta_sigma[i];
857 inputmomdata33mc>>m_psipp_mc_proton_theta_offset[i];
858 inputmomdata33mc>>m_psipp_mc_proton_theta_sigma[i];
859 }
860
861}
862
863double DedxPID::iterate(double ptrk,double *mean,double *p) {
864 double p1,p2,p3;
865 p2=((mean[0]-mean[1])*(p[1]*p[1]-p[2]*p[2])-(mean[1]-mean[2])*(p[0]*p[0]-p[1]*p[1]))/((p[0]-p[1])*(p[1]*p[1]-p[2]*p[2])-(p[1]-p[2])*(p[0]*p[0]-p[1]*p[1]));
866 p3=((p[0]-p[1])*(mean[1]-mean[2])-(p[1]-p[2])*(mean[0]-mean[1]))/((p[0]-p[1])*(p[1]*p[1]-p[2]*p[2])-(p[1]-p[2])*(p[0]*p[0]-p[1]*p[1]));
867 p1=mean[0]-p2*p[0]-p3*p[0]*p[0];
868 double mean1 = p1+p2*ptrk+p3*ptrk*ptrk;
869 return mean1;
870}
871
872double DedxPID::cal_par(int index1,double *m_jpsi_pip_ptrk_offset,double ptrk,double begin,double bin) {
873 double mean1[3],p[3];
874 p[0]=begin+(index1-1)*bin;
875 p[1]=begin+index1*bin;
876 p[2]=begin+(index1+1)*bin;
877 mean1[0]=m_jpsi_pip_ptrk_offset[index1-1];
878 mean1[1]=m_jpsi_pip_ptrk_offset[index1];
879 mean1[2]=m_jpsi_pip_ptrk_offset[index1+1];
880 double res=iterate(ptrk,mean1,p);
881 return res;
882}
883
double cos(const BesAngle a)
Definition: BesAngle.h:213
const Int_t n
Double_t x[10]
*******INTEGER m_nBinMax INTEGER m_NdiMax !No of bins in histogram for cell exploration division $ !Last vertex $ !Last active cell $ !Last cell in buffer $ !No of sampling when dividing cell $ !No of function total $ !Flag for random ceel for $ !Flag for type of for WtMax $ !Flag which decides whether vertices are included in the sampling $ entire domain is hyp !Maximum effective eevents per bin
Definition: FoamA.h:85
double mypol3(double x, double par0, double par1, double par2, double par3)
Definition: DedxPID.cxx:475
double mypol5(double x, double par0, double par1, double par2, double par3, double par4, double par5)
Definition: DedxPID.cxx:482
int getNhitCutDx() const
Definition: DedxPID.h:34
int particleIDCalculation()
Definition: DedxPID.cxx:50
double CorrDedx(int n, double ptrk, double cost, double chi, int charge)
Definition: DedxPID.cxx:128
double sigmaDedx(int n, double ptrk, double cost)
Definition: DedxPID.cxx:424
void inputpar()
Definition: DedxPID.cxx:489
double iterate(double ptrk, double *mean, double *p)
Definition: DedxPID.cxx:863
void init()
Definition: DedxPID.cxx:25
double offsetDedx(int n, double ptrk, double cost)
Definition: DedxPID.cxx:124
double offset(int n) const
Definition: DedxPID.h:28
double cal_par(int index1, double *m_jpsi_pip_ptrk_offset, double ptrk, double begin, double bin)
Definition: DedxPID.cxx:872
void calculate()
Definition: DedxPID.cxx:41
double chi(int n) const
Definition: DedxPID.h:26
static DedxPID * instance()
Definition: DedxPID.cxx:16
double probPH() const
Definition: DstMdcDedx.h:66
int numGoodHits() const
Definition: DstMdcDedx.h:64
double normPH() const
Definition: DstMdcDedx.h:67
double chi(int i) const
Definition: DstMdcDedx.h:58
const double theta() const
Definition: DstMdcTrack.h:59
const int charge() const
Definition: DstMdcTrack.h:53
const double p() const
Definition: DstMdcTrack.h:58
bool isMdcDedxValid()
Definition: EvtRecTrack.h:45
RecMdcDedx * mdcDedx()
Definition: EvtRecTrack.h:55
bool isMdcTrackValid()
Definition: EvtRecTrack.h:43
RecMdcTrack * mdcTrack()
Definition: EvtRecTrack.h:53
double chiMinCut() const
EvtRecTrack * PidTrk() const
double probCalculate(double chi2, int n)
double getRunNo() const
double pdfCalculate(double offset, double sigma)
double pdfMinSigmaCut() const
static std::string path