2#include "GaudiKernel/MsgStream.h"
3#include "GaudiKernel/SmartDataPtr.h"
11#include "DstEvent/TofHitStatus.h"
12#include "EventModel/EventHeader.h"
20 : base_class( name, svcLoc ) {
21 declareProperty(
"DedxChiCut", m_dedx_chi_cut = 4 );
22 declareProperty(
"TofChiCut", m_tof_chi_cut = 4 );
23 declareProperty(
"IsTofCorr", m_tof_corr =
true );
24 declareProperty(
"IsDedxCorr", m_dedx_corr =
true );
25 declareProperty(
"EidRatio", m_eid_ratio = 0.80 );
31 MsgStream log(
msgSvc(), name() );
32 log << MSG::INFO <<
"in SimplePIDSvc initialize()" << endmsg;
34 StatusCode sc = Service::initialize();
36 sc = serviceLocator()->service(
"EventDataSvc", eventSvc_,
true );
45 MsgStream log(
msgSvc(), name() );
46 log << MSG::INFO <<
"in SimplePIDSvc finalize()" << endmsg;
48 StatusCode sc = Service::finalize();
50 for (
unsigned int i = 0; i < 2; i++ )
52 for (
unsigned int j = 0; j < 4; j++ )
54 f_dedx[i][j]->Close();
55 f_tof_q[i][j]->Close();
56 f_tof_bgcost[i][j]->Close();
57 f_tof_wgt[i][j]->Close();
58 f_tof_final[i][j]->Close();
59 f_tofec_q[i][j]->Close();
60 f_tofec_bg[i][j]->Close();
61 f_tofec_cost[i][j]->Close();
64 for (
unsigned int i = 0; i < 3; i++ )
66 for (
unsigned int j = 0; j < 4; j++ ) { f_emc[i][j]->Close(); }
89 SmartDataPtr<Event::EventHeader> eventHeaderpid( eventSvc_,
"/Event/EventHeader" );
90 m_run = eventHeaderpid->runNumber();
100 0.000511, 0.105658, 0.13957, 0.493677, 0.938272,
102 for (
unsigned int pid = 0; pid < 5; pid++ )
105 m_p[pid] = mdckalTrk->
p();
106 m_betagamma[pid] = m_p[pid] /
mass[pid];
107 m_charge[pid] = mdckalTrk->
charge();
108 m_cost[pid] =
cos( mdckalTrk->
theta() );
113 for (
unsigned int i = 0; i < 5; i++ )
116 m_betagamma[i] = -99;
123 loadDedxInfo( track );
127 dedxSecondCorrection();
130 loadTOFInfo( track );
133 if ( m_tof_barrel == 1 )
135 tofBarrelCorrection();
136 tofBarrelSecondCorrection();
138 else if ( m_tof_barrel == 0 )
140 tofEndcapCorrection();
141 tofEndcapSecondCorrection();
145 loadEMCInfo( track );
150void SimplePIDSvc::calprob() {
151 bool usededx =
false;
154 for (
unsigned int i = 0; i < 5; i++ )
156 if ( !usededx && fabs( m_dedx_chi[i] ) < m_dedx_chi_cut ) usededx =
true;
157 if ( !usetof && fabs( m_tof_chi[i] ) < m_tof_chi_cut ) usetof =
true;
159 m_dedx_only[i] =
false;
163 for (
unsigned int i = 0; i < 5; i++ ) m_dedx_chi[i] = -99;
167 for (
unsigned int i = 0; i < 5; i++ ) m_tof_chi[i] = -99;
170 for (
unsigned int i = 0; i < 5; i++ )
176 if ( usededx && usetof )
178 chi2 = pow( m_dedx_chi[i], 2 ) + pow( m_tof_chi[i], 2 );
181 else if ( usededx && !usetof )
183 chi2 = pow( m_dedx_chi[i], 2 );
185 m_dedx_only[i] =
true;
187 else if ( !usededx && usetof )
189 chi2 = pow( m_tof_chi[i], 2 );
192 if ( ndf > 0 && chi2 > 0 ) m_prob[i] = TMath::Prob( chi2, ndf );
196int SimplePIDSvc::getRunIdx(
int run_no ) {
202 const int RUN_BEGIN_DATA_10 = 11414;
203 const int RUN_END_DATA_10 = 14604;
204 const int RUN_BEGIN_MC_10 = -14604;
205 const int RUN_END_MC_10 = -11414;
206 const int RUN_BEGIN_DATA_11 = 20448;
207 const int RUN_END_DATA_11 = 23454;
208 const int RUN_BEGIN_MC_11 = -23454;
209 const int RUN_END_MC_11 = -20448;
211 const int RUN_BEGIN_DATA_22 = 70521;
212 const int RUN_END_DATA_22 = 73930;
213 const int RUN_BEGIN_MC_22 = -73930;
214 const int RUN_END_MC_22 = -70521;
216 const int RUN_BEGIN_DATA_23 = 74031;
217 const int RUN_END_DATA_23 = 78536;
218 const int RUN_BEGIN_MC_23 = -78536;
219 const int RUN_END_MC_23 = -74031;
221 const int RUN_BEGIN_DATA_24 = 78615;
222 const int RUN_END_DATA_24 = 81094;
223 const int RUN_BEGIN_MC_24 = -81094;
224 const int RUN_END_MC_24 = -78615;
226 const int RUN_BEGIN_DATA_OffRes_24 = 81095;
227 const int RUN_END_DATA_OffRes_24 = 81631;
228 const int RUN_BEGIN_MC_OffRes_24 = -81631;
229 const int RUN_END_MC_OffRes_24 = -81095;
231 if ( run_no >= RUN_BEGIN_DATA_10 && run_no <= RUN_END_DATA_10 )
return 0;
232 else if ( run_no >= RUN_BEGIN_DATA_11 && run_no <= RUN_END_DATA_11 )
return 1;
233 else if ( run_no >= RUN_BEGIN_MC_10 && run_no <= RUN_END_MC_10 )
return 2;
234 else if ( run_no >= RUN_BEGIN_MC_11 && run_no <= RUN_END_MC_11 )
return 3;
236 else if ( run_no >= RUN_BEGIN_DATA_22 && run_no <= RUN_END_DATA_22 )
return 1;
237 else if ( run_no >= RUN_BEGIN_MC_22 && run_no <= RUN_END_MC_22 )
return 3;
238 else if ( run_no >= RUN_BEGIN_DATA_23 && run_no <= RUN_END_DATA_23 )
return 1;
239 else if ( run_no >= RUN_BEGIN_MC_23 && run_no <= RUN_END_MC_23 )
return 3;
240 else if ( run_no >= RUN_BEGIN_DATA_24 && run_no <= RUN_END_DATA_24 )
return 1;
241 else if ( run_no >= RUN_BEGIN_MC_24 && run_no <= RUN_END_MC_24 )
return 3;
242 else if ( run_no >= RUN_BEGIN_DATA_OffRes_24 && run_no <= RUN_END_DATA_OffRes_24 )
return 1;
243 else if ( run_no >= RUN_BEGIN_MC_OffRes_24 && run_no <= RUN_END_MC_OffRes_24 )
return 3;
247void SimplePIDSvc::loadTOFInfo(
EvtRecTrack* track ) {
249 for (
unsigned int i = 0; i < 8; i++ )
251 for (
unsigned int j = 0; j < 5; j++ ) m_tof_dt[i][j] = -99.;
254 for (
unsigned int i = 0; i < 2; i++ )
256 m_tof_zr[i] = -9999.;
257 m_tof_counter[i] = -1;
259 for (
unsigned int i = 0; i < 5; i++ ) { m_tof_chi[i] = -99.; }
264 SmartRefVector<RecTofTrack> tofTrk = track->
tofTrack();
265 SmartRefVector<RecTofTrack>::iterator it;
266 RecExtTrack* extTrk = track->
extTrack();
271 TofHitStatus* hitst =
new TofHitStatus;
273 for ( it = tofTrk.begin(); it != tofTrk.end(); it++ )
275 unsigned int st = ( *it )->status();
277 if ( hitst->
is_raw() )
continue;
282 int layer = hitst->
layer();
283 double tof = ( *it )->tof();
284 double ph = ( *it )->ph();
285 m_tof_counter[layer - 1] = ( *it )->tofID();
287 if ( barrel ) { m_tof_barrel = 1; }
293 m_tof_zr[0] = zrhit[0];
294 m_tof_zr[1] = zrhit[1];
299 if ( barrel ) idx = ( ( st & 0xC0 ) >> 5 ) + ( ( ( st ^ 0x20 ) & 0x20 ) >> 5 ) - 2;
302 else if ( counter ) { idx = layer + 3; }
303 else if ( cluster ) { idx = 6; }
304 if ( idx == -1 )
continue;
306 for (
unsigned int i = 0; i < 5; i++ )
308 double offset = ( *it )->toffset( i );
309 double texp = ( *it )->texp( i );
310 if ( texp < 0.0 )
continue;
311 double dt = tof - offset - texp;
312 m_tof_dt[idx][i] =
dt;
318void SimplePIDSvc::tofBarrelCorrection() {
319 const double EPS = 1e-4;
320 const double BG_LOW = 0.20;
321 const double BG_UP = 7.40;
322 const double COST_LOW = -0.81;
323 const double COST_UP = 0.81;
324 const double Q_LOW = 0.;
325 const double Q_UP = 9000.;
326 const double P_LOW = 0.2;
327 const double P_UP = 1.3;
328 const int BIN_BG = 15;
329 const int BIN_COST = 15;
330 const int BIN_P = 15;
331 double BG[BIN_BG + 1] = { 0.20, 0.87, 1.11, 1.35, 1.55, 1.72, 1.91, 2.17,
332 2.63, 3.05, 3.47, 3.93, 4.50, 5.27, 6.00, 7.40 };
333 double COST[BIN_COST + 1] = { -0.81, -0.64, -0.53, -0.43, -0.33, -0.23, -0.13, -0.04,
334 0.05, 0.14, 0.24, 0.34, 0.44, 0.54, 0.65, 0.81 };
335 double P[BIN_P + 1] = { 0.20, 0.47, 0.56, 0.65, 0.72, 0.79, 0.86, 0.92,
336 0.98, 1.03, 1.08, 1.13, 1.17, 1.22, 1.26, 1.30 };
337 int idx = getRunIdx( m_run );
341 for (
unsigned int i = 0; i < 4; i++ )
344 int bin_bg, bin_cost, bin_wgt;
349 bin_bg = findBin(
P, BIN_P, bg );
352 else if ( i == 2 || i == 3 )
354 bg =
max( BG_LOW +
EPS,
min( BG_UP -
EPS, m_betagamma[i] ) );
355 bin_bg = findBin( BG, BIN_BG, bg );
359 double cost = m_cost[i];
360 int charge = m_charge[i];
362 double offset, sigma;
363 double offset_q, offset_bgcost;
370 cost =
max( COST_LOW +
EPS,
min( COST_UP -
EPS, cost ) );
371 bin_cost = findBin( COST, BIN_COST, cost );
372 if ( bin_bg == -1 || bin_cost == -1 )
continue;
375 for (
unsigned int j = 0; j < 4; j++ )
377 t[j] = m_tof_dt[j][i];
378 if ( fabs(
t[j] + 99. ) <
EPS )
385 offset_q = h_tof_p_q_offset[pid][idx][j]->Interpolate(
q );
386 offset_bgcost = h_tof_p_bgcost_offset[pid][idx][j]->Interpolate( bg, cost );
387 t[j] =
t[j] - offset_q - offset_bgcost;
391 offset_q = h_tof_m_q_offset[pid][idx][j]->Interpolate(
q );
392 offset_bgcost = h_tof_m_bgcost_offset[pid][idx][j]->Interpolate( bg, cost );
393 t[j] =
t[j] - offset_q - offset_bgcost;
397 if ( bin_wgt == -1 )
continue;
399 for (
unsigned int j = 0; j < 4; j++ )
403 h_tof_p_wgt[pid][idx][bin_wgt][j]->GetBinContent( bin_bg + 1, bin_cost + 1 );
406 h_tof_m_wgt[pid][idx][bin_wgt][j]->GetBinContent( bin_bg + 1, bin_cost + 1 );
410 t[4] /= h_tof_p_wgt[pid][idx][bin_wgt][4]->GetBinContent( bin_bg + 1, bin_cost + 1 );
411 offset = h_tof_p_final_offset[pid][idx][bin_wgt]->Interpolate( bg, cost );
412 sigma = h_tof_p_final_sigma[pid][idx][bin_wgt]->Interpolate( bg, cost );
413 m_tof_chi[i] = (
t[4] - offset ) / sigma;
417 t[4] /= h_tof_m_wgt[pid][idx][bin_wgt][4]->GetBinContent( bin_bg + 1, bin_cost + 1 );
418 offset = h_tof_m_final_offset[pid][idx][bin_wgt]->Interpolate( bg, cost );
419 sigma = h_tof_m_final_sigma[pid][idx][bin_wgt]->Interpolate( bg, cost );
420 m_tof_chi[i] = (
t[4] - offset ) / sigma;
426void SimplePIDSvc::tofEndcapCorrection() {
427 const double EPS = 1e-4;
428 const double BG_LOW = 0.30;
429 const double BG_UP = 7.40;
430 const double Q_LOW = 0.;
431 const double Q_UP = 6000.;
432 const double COST_EAST_LOW = 0.720;
433 const double COST_EAST_UP = 0.930;
434 const double COST_WEST_LOW = -0.930;
435 const double COST_WEST_UP = -0.720;
436 const double P_LOW = 0.2;
437 const double P_UP = 1.3;
439 int idx = getRunIdx( m_run );
443 for (
unsigned int i = 0; i < 4; i++ )
452 else if ( i == 2 || i == 3 )
454 bg =
max( BG_LOW +
EPS,
min( BG_UP -
EPS, m_betagamma[i] ) );
460 double cost = m_cost[i];
461 int charge = m_charge[i];
462 double t = m_tof_dt[7][i];
463 double q = m_tof_ph[7];
464 double off_q, off_bg, off_cost;
465 double sg_q, sg_bg, sg_cost;
469 cost =
max( COST_EAST_LOW +
EPS,
min( COST_EAST_UP -
EPS, cost ) );
474 cost =
max( COST_WEST_LOW +
EPS,
min( COST_WEST_UP -
EPS, cost ) );
481 off_q = h_tofec_p_q_offset[pid][idx][
flag]->Interpolate(
q );
482 sg_q = h_tofec_p_q_sigma[pid][idx][
flag]->Interpolate(
q );
483 off_bg = h_tofec_p_bg_offset[pid][idx][
flag]->Interpolate( bg );
484 sg_bg = h_tofec_p_bg_sigma[pid][idx][
flag]->Interpolate( bg );
485 off_cost = h_tofec_p_cost_offset[pid][idx][
flag]->Interpolate( cost );
486 sg_cost = h_tofec_p_cost_sigma[pid][idx][
flag]->Interpolate( cost );
487 m_tof_chi[i] = ( ( (
t - off_q ) / sg_q - off_bg ) / sg_bg - off_cost ) / sg_cost;
491 off_q = h_tofec_m_q_offset[pid][idx][
flag]->Interpolate(
q );
492 sg_q = h_tofec_m_q_sigma[pid][idx][
flag]->Interpolate(
q );
493 off_bg = h_tofec_m_bg_offset[pid][idx][
flag]->Interpolate( bg );
494 sg_bg = h_tofec_m_bg_sigma[pid][idx][
flag]->Interpolate( bg );
495 off_cost = h_tofec_m_cost_offset[pid][idx][
flag]->Interpolate( cost );
496 sg_cost = h_tofec_m_cost_sigma[pid][idx][
flag]->Interpolate( cost );
497 m_tof_chi[i] = ( ( (
t - off_q ) / sg_q - off_bg ) / sg_bg - off_cost ) / sg_cost;
503void SimplePIDSvc::loadDedxInfo(
EvtRecTrack* track ) {
506 RecMdcDedx* dedx_trk = track->
mdcDedx();
507 for (
unsigned int i = 0; i < 5; i++ ) m_dedx_chi[i] = dedx_trk->
chi( i );
511 for (
unsigned int i = 0; i < 5; i++ ) m_dedx_chi[i] = -99;
515void SimplePIDSvc::dedxCorrection() {
516 int idx = getRunIdx( m_run );
517 const double EPS = 1e-4;
518 const double BG_LOW = 0.20;
519 const double BG_UP = 7.40;
520 const double COST_LOW = -0.93;
521 const double COST_UP = 0.93;
522 const double P_LOW = 0.2;
523 const double P_UP = 1.3;
526 double offset, sigma;
527 for (
unsigned int i = 0; i < 4; i++ )
536 else if ( i == 2 || i == 3 )
538 bg =
max( BG_LOW +
EPS,
min( BG_UP -
EPS, m_betagamma[i] ) );
542 double cost = m_cost[i];
543 double charge = m_charge[i];
544 cost =
max( COST_LOW +
EPS,
min( COST_UP -
EPS, cost ) );
547 offset = h_dedx_p_offset[pid][idx]->Interpolate( bg, cost );
548 sigma = h_dedx_p_sigma[pid][idx]->Interpolate( bg, cost );
549 m_dedx_chi[i] = ( m_dedx_chi[i] - offset ) / sigma;
553 offset = h_dedx_m_offset[pid][idx]->Interpolate( bg, cost );
554 sigma = h_dedx_m_sigma[pid][idx]->Interpolate( bg, cost );
555 m_dedx_chi[i] = ( m_dedx_chi[i] - offset ) / sigma;
561void SimplePIDSvc::tofBarrelSecondCorrection() {
563 int idx = getRunIdx( m_run );
564 const double EPS = 1e-4;
565 const double P_LOW = 0.0;
566 const double P_UP = 1.3;
567 const int BIN_P = 10;
569 const int RUN_BEGIN_DATA_10 = 11414;
570 const int RUN_END_DATA_10 = 14604;
571 const int RUN_BEGIN_MC_10 = -14604;
572 const int RUN_END_MC_10 = -11414;
573 const int RUN_BEGIN_DATA_11 = 20448;
574 const int RUN_END_DATA_11 = 23454;
575 const int RUN_BEGIN_MC_11 = -23454;
576 const int RUN_END_MC_11 = -20448;
578 const int RUN_BEGIN_DATA_22 = 70521;
579 const int RUN_END_DATA_22 = 73930;
580 const int RUN_BEGIN_MC_22 = -73930;
581 const int RUN_END_MC_22 = -70521;
583 const int RUN_BEGIN_DATA_23 = 74031;
584 const int RUN_END_DATA_23 = 78536;
585 const int RUN_BEGIN_MC_23 = -78536;
586 const int RUN_END_MC_23 = -74031;
588 const int RUN_BEGIN_DATA_24 = 78615;
589 const int RUN_END_DATA_24 = 81094;
590 const int RUN_BEGIN_MC_24 = -81094;
591 const int RUN_END_MC_24 = -78615;
593 const int RUN_BEGIN_DATA_OffRes_24 = 81095;
594 const int RUN_END_DATA_OffRes_24 = 81631;
595 const int RUN_BEGIN_MC_OffRes_24 = -81631;
596 const int RUN_END_MC_OffRes_24 = -81095;
598 double P[BIN_P + 1] = { 0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.3 };
602 for (
unsigned int i = 2; i < 4; i++ )
605 int aa = 99, bb = 99;
610 bin_p = findBin(
P, BIN_P, ptk );
615 if ( ( m_run >= RUN_BEGIN_DATA_10 && m_run <= RUN_END_DATA_10 && idx == 0 ) ||
616 ( m_run >= RUN_BEGIN_DATA_11 && m_run <= RUN_END_DATA_11 && idx == 1 ) )
622 if ( ( m_run >= RUN_BEGIN_MC_10 && m_run <= RUN_END_MC_10 && idx == 2 ) ||
623 ( m_run >= RUN_BEGIN_MC_11 && m_run <= RUN_END_MC_11 && idx == 3 ) )
629 if ( m_run >= RUN_BEGIN_DATA_22 && m_run <= RUN_END_DATA_22 && idx == 1 )
635 if ( m_run >= RUN_BEGIN_MC_22 && m_run <= RUN_END_MC_22 && idx == 3 )
641 if ( m_run >= RUN_BEGIN_DATA_23 && m_run <= RUN_END_DATA_23 && idx == 1 )
647 if ( m_run >= RUN_BEGIN_MC_23 && m_run <= RUN_END_MC_23 && idx == 3 )
653 if ( m_run >= RUN_BEGIN_DATA_24 && m_run <= RUN_END_DATA_24 && idx == 1 )
659 if ( m_run >= RUN_BEGIN_MC_24 && m_run <= RUN_END_MC_24 && idx == 3 )
665 if ( m_run >= RUN_BEGIN_DATA_OffRes_24 && m_run <= RUN_END_DATA_OffRes_24 && idx == 1 )
671 if ( m_run >= RUN_BEGIN_MC_OffRes_24 && m_run <= RUN_END_MC_OffRes_24 && idx == 3 )
681 if ( ( m_run >= RUN_BEGIN_DATA_10 && m_run <= RUN_END_DATA_10 && idx == 0 ) ||
682 ( m_run >= RUN_BEGIN_DATA_11 && m_run <= RUN_END_DATA_11 && idx == 1 ) )
688 if ( ( m_run >= RUN_BEGIN_MC_10 && m_run <= RUN_END_MC_10 && idx == 2 ) ||
689 ( m_run >= RUN_BEGIN_MC_11 && m_run <= RUN_END_MC_11 && idx == 3 ) )
695 if ( m_run >= RUN_BEGIN_DATA_22 && m_run <= RUN_END_DATA_22 && idx == 1 )
701 if ( m_run >= RUN_BEGIN_MC_22 && m_run <= RUN_END_MC_22 && idx == 3 )
707 if ( m_run >= RUN_BEGIN_DATA_23 && m_run <= RUN_END_DATA_23 && idx == 1 )
713 if ( m_run >= RUN_BEGIN_MC_23 && m_run <= RUN_END_MC_23 && idx == 3 )
719 if ( m_run >= RUN_BEGIN_DATA_24 && m_run <= RUN_END_DATA_24 && idx == 1 )
725 if ( m_run >= RUN_BEGIN_MC_24 && m_run <= RUN_END_MC_24 && idx == 3 )
731 if ( m_run >= RUN_BEGIN_DATA_OffRes_24 && m_run <= RUN_END_DATA_OffRes_24 && idx == 1 )
737 if ( m_run >= RUN_BEGIN_MC_OffRes_24 && m_run <= RUN_END_MC_OffRes_24 && idx == 3 )
744 if ( m_tof_chi[i] != -99 && m_run > 0 )
750 if ( !( ( m_run >= RUN_BEGIN_DATA_23 && m_run <= RUN_END_DATA_23 ) ||
751 ( m_run >= RUN_BEGIN_DATA_24 && m_run <= RUN_END_DATA_24 ) ||
752 ( m_run >= RUN_BEGIN_DATA_OffRes_24 && m_run <= RUN_END_DATA_OffRes_24 ) ) )
757 ( m_tof_chi[i] - m_gaussion_mean[aa][bb][bin_p] ) /
758 ( m_gaussion_sigmab[aa][bb][bin_p] / m_gaussion_sigmab[aa][bb + 1][bin_p] );
761 { m_tof_chi[i] = ( m_tof_chi[i] - m_gaussion_mean[aa][bb][bin_p] ); }
768 ( m_tof_chi[i] - m_gaussion_mean[aa][bb][bin_p] ) /
769 ( m_gaussion_sigmab[aa][bb][bin_p] / m_gaussion_sigmab[aa][bb + 1][bin_p] );
772 { m_tof_chi[i] = ( m_tof_chi[i] - m_gaussion_mean[aa][bb][bin_p] ); }
775 if ( m_tof_chi[i] != -99 && m_run < 0 )
777 m_tof_chi[i] = ( m_tof_chi[i] - m_gaussion_mean[aa][bb][bin_p] ) /
778 ( m_gaussion_sigmab[aa][bb][bin_p] / m_gaussion_sigmab[aa][bb][bin_p] );
785void SimplePIDSvc::tofEndcapSecondCorrection() {
787 int idx = getRunIdx( m_run );
788 const double EPS = 1e-4;
789 const double P_LOW = 0.0;
790 const double P_UP = 1.3;
791 const int BIN_P = 10;
793 const int RUN_BEGIN_DATA_10 = 11414;
794 const int RUN_END_DATA_10 = 14604;
795 const int RUN_BEGIN_MC_10 = -14604;
796 const int RUN_END_MC_10 = -11414;
797 const int RUN_BEGIN_DATA_11 = 20448;
798 const int RUN_END_DATA_11 = 23454;
799 const int RUN_BEGIN_MC_11 = -23454;
800 const int RUN_END_MC_11 = -20448;
802 const int RUN_BEGIN_DATA_22 = 70521;
803 const int RUN_END_DATA_22 = 73930;
804 const int RUN_BEGIN_MC_22 = -73930;
805 const int RUN_END_MC_22 = -70521;
807 const int RUN_BEGIN_DATA_23 = 74031;
808 const int RUN_END_DATA_23 = 78536;
809 const int RUN_BEGIN_MC_23 = -78536;
810 const int RUN_END_MC_23 = -74031;
812 const int RUN_BEGIN_DATA_24 = 78615;
813 const int RUN_END_DATA_24 = 81094;
814 const int RUN_BEGIN_MC_24 = -81094;
815 const int RUN_END_MC_24 = -78615;
817 const int RUN_BEGIN_DATA_OffRes_24 = 81095;
818 const int RUN_END_DATA_OffRes_24 = 81631;
819 const int RUN_BEGIN_MC_OffRes_24 = -81631;
820 const int RUN_END_MC_OffRes_24 = -81095;
822 double P[BIN_P + 1] = { 0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.3 };
826 for (
unsigned int i = 2; i < 4; i++ )
829 int aa = 99, bb = 99;
834 bin_p = findBin(
P, BIN_P, ptk );
839 if ( ( m_run >= RUN_BEGIN_DATA_10 && m_run <= RUN_END_DATA_10 && idx == 0 ) ||
840 ( m_run >= RUN_BEGIN_DATA_11 && m_run <= RUN_END_DATA_11 && idx == 1 ) )
846 if ( ( m_run >= RUN_BEGIN_MC_10 && m_run <= RUN_END_MC_10 && idx == 2 ) ||
847 ( m_run >= RUN_BEGIN_MC_11 && m_run <= RUN_END_MC_11 && idx == 3 ) )
853 if ( m_run >= RUN_BEGIN_DATA_22 && m_run <= RUN_END_DATA_22 && idx == 1 )
859 if ( m_run >= RUN_BEGIN_MC_22 && m_run <= RUN_END_MC_22 && idx == 3 )
865 if ( m_run >= RUN_BEGIN_DATA_23 && m_run <= RUN_END_DATA_23 && idx == 1 )
871 if ( m_run >= RUN_BEGIN_MC_23 && m_run <= RUN_END_MC_23 && idx == 3 )
877 if ( m_run >= RUN_BEGIN_DATA_24 && m_run <= RUN_END_DATA_24 && idx == 1 )
883 if ( m_run >= RUN_BEGIN_MC_24 && m_run <= RUN_END_MC_24 && idx == 3 )
889 if ( m_run >= RUN_BEGIN_DATA_OffRes_24 && m_run <= RUN_END_DATA_OffRes_24 && idx == 1 )
895 if ( m_run >= RUN_BEGIN_MC_OffRes_24 && m_run <= RUN_END_MC_OffRes_24 && idx == 3 )
905 if ( ( m_run >= RUN_BEGIN_DATA_10 && m_run <= RUN_END_DATA_10 && idx == 0 ) ||
906 ( m_run >= RUN_BEGIN_DATA_11 && m_run <= RUN_END_DATA_11 && idx == 1 ) )
912 if ( ( m_run >= RUN_BEGIN_MC_10 && m_run <= RUN_END_MC_10 && idx == 2 ) ||
913 ( m_run >= RUN_BEGIN_MC_11 && m_run <= RUN_END_MC_11 && idx == 3 ) )
919 if ( m_run >= RUN_BEGIN_DATA_22 && m_run <= RUN_END_DATA_22 && idx == 1 )
925 if ( m_run >= RUN_BEGIN_MC_22 && m_run <= RUN_END_MC_22 && idx == 3 )
931 if ( m_run >= RUN_BEGIN_DATA_23 && m_run <= RUN_END_DATA_23 && idx == 1 )
937 if ( m_run >= RUN_BEGIN_MC_23 && m_run <= RUN_END_MC_23 && idx == 3 )
943 if ( m_run >= RUN_BEGIN_DATA_24 && m_run <= RUN_END_DATA_24 && idx == 1 )
949 if ( m_run >= RUN_BEGIN_MC_24 && m_run <= RUN_END_MC_24 && idx == 3 )
955 if ( m_run >= RUN_BEGIN_DATA_OffRes_24 && m_run <= RUN_END_DATA_OffRes_24 && idx == 1 )
961 if ( m_run >= RUN_BEGIN_MC_OffRes_24 && m_run <= RUN_END_MC_OffRes_24 && idx == 3 )
968 if ( m_tof_chi[i] != -99 && ( aa == 5 || aa == 8 || aa == 11 ) )
971 m_tof_chi[i] = ( m_tof_chi[i] - m_gaussion_mean[aa][bb][bin_p] ) / ( 60. / 110. );
974 if ( m_tof_chi[i] != -99 && aa == 4 )
977 m_tof_chi[i] = ( m_tof_chi[i] - m_gaussion_mean[aa][bb][bin_p] );
984void SimplePIDSvc::dedxSecondCorrection()
988 int idx = getRunIdx( m_run );
989 const double EPS = 1e-4;
990 const double P_LOW = 0.0;
991 const double P_UP = 1.3;
992 const int BIN_P = 10;
994 const int RUN_BEGIN_DATA_10 = 11414;
995 const int RUN_END_DATA_10 = 14604;
996 const int RUN_BEGIN_MC_10 = -14604;
997 const int RUN_END_MC_10 = -11414;
998 const int RUN_BEGIN_DATA_11 = 20448;
999 const int RUN_END_DATA_11 = 23454;
1000 const int RUN_BEGIN_MC_11 = -23454;
1001 const int RUN_END_MC_11 = -20448;
1003 const int RUN_BEGIN_DATA_22 = 70521;
1004 const int RUN_END_DATA_22 = 73930;
1005 const int RUN_BEGIN_MC_22 = -73930;
1006 const int RUN_END_MC_22 = -70521;
1008 const int RUN_BEGIN_DATA_23 = 74031;
1009 const int RUN_END_DATA_23 = 78536;
1010 const int RUN_BEGIN_MC_23 = -78536;
1011 const int RUN_END_MC_23 = -74031;
1013 const int RUN_BEGIN_DATA_24 = 78615;
1014 const int RUN_END_DATA_24 = 81094;
1015 const int RUN_BEGIN_MC_24 = -81094;
1016 const int RUN_END_MC_24 = -78615;
1018 const int RUN_BEGIN_DATA_OffRes_24 = 81095;
1019 const int RUN_END_DATA_OffRes_24 = 81631;
1020 const int RUN_BEGIN_MC_OffRes_24 = -81631;
1021 const int RUN_END_MC_OffRes_24 = -81095;
1023 double P[BIN_P + 1] = { 0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.3 };
1027 for (
unsigned int i = 2; i < 4; i++ )
1030 int aa = 99, bb = 99;
1033 double ptk = m_p[i];
1035 bin_p = findBin(
P, BIN_P, ptk );
1040 if ( ( m_run >= RUN_BEGIN_DATA_10 && m_run <= RUN_END_DATA_10 && idx == 0 ) ||
1041 ( m_run >= RUN_BEGIN_DATA_11 && m_run <= RUN_END_DATA_11 && idx == 1 ) )
1047 if ( ( m_run >= RUN_BEGIN_MC_10 && m_run <= RUN_END_MC_10 && idx == 2 ) ||
1048 ( m_run >= RUN_BEGIN_MC_11 && m_run <= RUN_END_MC_11 && idx == 3 ) )
1054 if ( m_run >= RUN_BEGIN_DATA_22 && m_run <= RUN_END_DATA_22 && idx == 1 )
1060 if ( m_run >= RUN_BEGIN_MC_22 && m_run <= RUN_END_MC_22 && idx == 3 )
1066 if ( m_run >= RUN_BEGIN_DATA_23 && m_run <= RUN_END_DATA_23 && idx == 1 )
1072 if ( m_run >= RUN_BEGIN_MC_23 && m_run <= RUN_END_MC_23 && idx == 3 )
1078 if ( m_run >= RUN_BEGIN_DATA_24 && m_run <= RUN_END_DATA_24 && idx == 1 )
1084 if ( m_run >= RUN_BEGIN_MC_24 && m_run <= RUN_END_MC_24 && idx == 3 )
1090 if ( m_run >= RUN_BEGIN_DATA_OffRes_24 && m_run <= RUN_END_DATA_OffRes_24 && idx == 1 )
1096 if ( m_run >= RUN_BEGIN_MC_OffRes_24 && m_run <= RUN_END_MC_OffRes_24 && idx == 3 )
1106 if ( ( m_run >= RUN_BEGIN_DATA_10 && m_run <= RUN_END_DATA_10 && idx == 0 ) ||
1107 ( m_run >= RUN_BEGIN_DATA_11 && m_run <= RUN_END_DATA_11 && idx == 1 ) )
1113 if ( ( m_run >= RUN_BEGIN_MC_10 && m_run <= RUN_END_MC_10 && idx == 2 ) ||
1114 ( m_run >= RUN_BEGIN_MC_11 && m_run <= RUN_END_MC_11 && idx == 3 ) )
1120 if ( m_run >= RUN_BEGIN_DATA_22 && m_run <= RUN_END_DATA_22 && idx == 1 )
1126 if ( m_run >= RUN_BEGIN_MC_22 && m_run <= RUN_END_MC_22 && idx == 3 )
1132 if ( m_run >= RUN_BEGIN_DATA_23 && m_run <= RUN_END_DATA_23 && idx == 1 )
1138 if ( m_run >= RUN_BEGIN_MC_23 && m_run <= RUN_END_MC_23 && idx == 3 )
1144 if ( m_run >= RUN_BEGIN_DATA_24 && m_run <= RUN_END_DATA_24 && idx == 1 )
1150 if ( m_run >= RUN_BEGIN_MC_24 && m_run <= RUN_END_MC_24 && idx == 3 )
1156 if ( m_run >= RUN_BEGIN_DATA_OffRes_24 && m_run <= RUN_END_DATA_OffRes_24 && idx == 1 )
1162 if ( m_run >= RUN_BEGIN_MC_OffRes_24 && m_run <= RUN_END_MC_OffRes_24 && idx == 3 )
1169 if ( m_dedx_chi[i] != -99 && m_run > 0 )
1172 ( m_dedx_chi[i] - m_gaussion_mean[aa][bb][bin_p] ) /
1173 ( m_gaussion_sigmab[aa][bb][bin_p] / m_gaussion_sigmab[aa][bb + 1][bin_p] );
1175 if ( m_dedx_chi[i] != -99 && m_run < 0 )
1178 ( m_dedx_chi[i] - m_gaussion_mean[aa][bb][bin_p] ) /
1179 ( m_gaussion_sigmab[aa][bb][bin_p] / m_gaussion_sigmab[aa][bb][bin_p] );
1186void SimplePIDSvc::loadSecondPar() {
1187 string path = getenv(
"SIMPLEPIDSVCROOT" );
1189 for (
int i = 0; i < 12; i++ )
1194 if ( i == 0 ) dir =
"round0304_dedx";
1195 else if ( i == 1 ) dir =
"round15_dedx";
1196 else if ( i == 2 ) dir =
"round0304_tof";
1197 else if ( i == 3 ) dir =
"round15_tof";
1198 else if ( i == 4 ) dir =
"round0304_tof_endcap";
1199 else if ( i == 5 ) dir =
"round15_tof_endcap";
1201 else if ( i == 6 ) dir =
"round16_dedx";
1202 else if ( i == 7 ) dir =
"round16_tof";
1203 else if ( i == 8 ) dir =
"round16_tof_endcap";
1205 else if ( i == 9 ) dir =
"round17_dedx";
1206 else if ( i == 10 ) dir =
"round17_tof";
1207 else if ( i == 11 ) dir =
"round17_tof_endcap";
1211 cout <<
"Boundary Error! " << endl;
1215 for (
int j = 0; j < 4; j++ )
1220 if ( j == 0 ) name =
"data_K";
1221 else if ( j == 1 ) name =
"inc_K";
1222 else if ( j == 2 ) name =
"data_pi";
1223 else if ( j == 3 ) name =
"inc_pi";
1226 cout <<
"Boundary Error! " << endl;
1231 Form(
"/share/second_correct/%s/%s_%s.dat", dir, dir, name ) );
1233 for (
int m = 0; m < 10; m++ )
1236 second_cor >> m_gaussion_mean[i][j][m] >> m_gaussion_sigma[i][j][m] >>
1237 m_gaussion_sigmab[i][j][m];
1245void SimplePIDSvc::loadHistogram() {
1246 string path = getenv(
"SIMPLEPIDSVCROOT" );
1247 vector<string> filename;
1248 for (
unsigned int idx = 0; idx < 2; idx++ )
1251 if ( idx == 0 ) dir =
"electron";
1252 else if ( idx == 1 ) dir =
"kpi";
1255 cout <<
"Boundary Error! " << endl;
1261 filename.push_back( path + Form(
"/share/%s/dedx/dedx_d10.root", dir ) );
1262 filename.push_back( path + Form(
"/share/%s/dedx/dedx_d11.root", dir ) );
1263 filename.push_back( path + Form(
"/share/%s/dedx/dedx_m10.root", dir ) );
1264 filename.push_back( path + Form(
"/share/%s/dedx/dedx_m11.root", dir ) );
1265 for (
unsigned int i = 0; i < filename.size(); i++ )
1267 f_dedx[idx][i] =
new TFile( filename[i].
c_str(),
"READ" );
1269 if ( i == 0 ) name =
"d10";
1270 else if ( i == 1 ) name =
"d11";
1271 else if ( i == 2 ) name =
"m10";
1272 else if ( i == 3 ) name =
"m11";
1275 cout <<
"Boundary Error! " << endl;
1278 h_dedx_p_offset[idx][i] =
1279 (TH2D*)f_dedx[idx][i]->Get( Form(
"h_dedx_p_offset_%s", name ) );
1280 h_dedx_p_sigma[idx][i] = (TH2D*)f_dedx[idx][i]->Get( Form(
"h_dedx_p_sigma_%s", name ) );
1281 h_dedx_m_offset[idx][i] =
1282 (TH2D*)f_dedx[idx][i]->Get( Form(
"h_dedx_m_offset_%s", name ) );
1283 h_dedx_m_sigma[idx][i] = (TH2D*)f_dedx[idx][i]->Get( Form(
"h_dedx_m_sigma_%s", name ) );
1287 filename.push_back( path + Form(
"/share/%s/tof_barrel/tof_q_d10.root", dir ) );
1288 filename.push_back( path + Form(
"/share/%s/tof_barrel/tof_q_d11.root", dir ) );
1289 filename.push_back( path + Form(
"/share/%s/tof_barrel/tof_q_m10.root", dir ) );
1290 filename.push_back( path + Form(
"/share/%s/tof_barrel/tof_q_m11.root", dir ) );
1291 for (
unsigned int i = 0; i < filename.size(); i++ )
1293 f_tof_q[idx][i] =
new TFile( filename[i].
c_str(),
"READ" );
1295 if ( i == 0 ) name =
"d10";
1296 else if ( i == 1 ) name =
"d11";
1297 else if ( i == 2 ) name =
"m10";
1298 else if ( i == 3 ) name =
"m11";
1301 cout <<
"Boundary Error! " << endl;
1304 for (
unsigned int j = 0; j < 4; j++ )
1306 h_tof_p_q_offset[idx][i][j] =
1307 (TH1D*)f_tof_q[idx][i]->Get( Form(
"h_tof_p_q_offset_%s_%d", name, j ) );
1308 h_tof_m_q_offset[idx][i][j] =
1309 (TH1D*)f_tof_q[idx][i]->Get( Form(
"h_tof_m_q_offset_%s_%d", name, j ) );
1310 h_tof_p_q_sigma[idx][i][j] =
1311 (TH1D*)f_tof_q[idx][i]->Get( Form(
"h_tof_p_q_sigma_%s_%d", name, j ) );
1312 h_tof_m_q_sigma[idx][i][j] =
1313 (TH1D*)f_tof_q[idx][i]->Get( Form(
"h_tof_m_q_sigma_%s_%d", name, j ) );
1318 filename.push_back( path + Form(
"/share/%s/tof_barrel/tof_bg_cost_d10.root", dir ) );
1319 filename.push_back( path + Form(
"/share/%s/tof_barrel/tof_bg_cost_d11.root", dir ) );
1320 filename.push_back( path + Form(
"/share/%s/tof_barrel/tof_bg_cost_m10.root", dir ) );
1321 filename.push_back( path + Form(
"/share/%s/tof_barrel/tof_bg_cost_m11.root", dir ) );
1322 for (
unsigned int i = 0; i < filename.size(); i++ )
1324 f_tof_bgcost[idx][i] =
new TFile( filename[i].
c_str(),
"READ" );
1326 if ( i == 0 ) name =
"d10";
1327 else if ( i == 1 ) name =
"d11";
1328 else if ( i == 2 ) name =
"m10";
1329 else if ( i == 3 ) name =
"m11";
1332 cout <<
"Boundary Error! " << endl;
1335 for (
unsigned int j = 0; j < 4; j++ )
1337 h_tof_p_bgcost_offset[idx][i][j] =
1338 (TH2D*)f_tof_bgcost[idx][i]->Get( Form(
"h_tof_p_bgcost_offset_%s_%d", name, j ) );
1339 h_tof_m_bgcost_offset[idx][i][j] =
1340 (TH2D*)f_tof_bgcost[idx][i]->Get( Form(
"h_tof_m_bgcost_offset_%s_%d", name, j ) );
1341 h_tof_p_bgcost_sigma[idx][i][j] =
1342 (TH2D*)f_tof_bgcost[idx][i]->Get( Form(
"h_tof_p_bgcost_sigma_%s_%d", name, j ) );
1343 h_tof_m_bgcost_sigma[idx][i][j] =
1344 (TH2D*)f_tof_bgcost[idx][i]->Get( Form(
"h_tof_m_bgcost_sigma_%s_%d", name, j ) );
1349 filename.push_back( path + Form(
"/share/%s/tof_barrel/tof_wgt_d10.root", dir ) );
1350 filename.push_back( path + Form(
"/share/%s/tof_barrel/tof_wgt_d11.root", dir ) );
1351 filename.push_back( path + Form(
"/share/%s/tof_barrel/tof_wgt_m10.root", dir ) );
1352 filename.push_back( path + Form(
"/share/%s/tof_barrel/tof_wgt_m11.root", dir ) );
1353 for (
unsigned int i = 0; i < filename.size(); i++ )
1355 f_tof_wgt[idx][i] =
new TFile( filename[i].
c_str(),
"READ" );
1357 if ( i == 0 ) name =
"d10";
1358 else if ( i == 1 ) name =
"d11";
1359 else if ( i == 2 ) name =
"m10";
1360 else if ( i == 3 ) name =
"m11";
1363 cout <<
"Boundary Error! " << endl;
1366 for (
unsigned int j = 0; j < 15; j++ )
1368 for (
unsigned int k = 0; k < 5; k++ )
1370 h_tof_p_wgt[idx][i][j][k] =
1371 (TH2D*)f_tof_wgt[idx][i]->Get( Form(
"h_tof_p_wgt_%s_%d_%d", name, j, k ) );
1372 h_tof_m_wgt[idx][i][j][k] =
1373 (TH2D*)f_tof_wgt[idx][i]->Get( Form(
"h_tof_m_wgt_%s_%d_%d", name, j, k ) );
1379 filename.push_back( path + Form(
"/share/%s/tof_barrel/tof_final_d10.root", dir ) );
1380 filename.push_back( path + Form(
"/share/%s/tof_barrel/tof_final_d11.root", dir ) );
1381 filename.push_back( path + Form(
"/share/%s/tof_barrel/tof_final_m10.root", dir ) );
1382 filename.push_back( path + Form(
"/share/%s/tof_barrel/tof_final_m11.root", dir ) );
1383 for (
unsigned int i = 0; i < filename.size(); i++ )
1385 f_tof_final[idx][i] =
new TFile( filename[i].
c_str(),
"READ" );
1387 if ( i == 0 ) name =
"d10";
1388 else if ( i == 1 ) name =
"d11";
1389 else if ( i == 2 ) name =
"m10";
1390 else if ( i == 3 ) name =
"m11";
1393 cout <<
"Boundary Error! " << endl;
1396 for (
unsigned int j = 0; j < 15; j++ )
1398 h_tof_p_final_offset[idx][i][j] =
1399 (TH2D*)f_tof_final[idx][i]->Get( Form(
"h_tof_p_final_offset_%s_%d", name, j ) );
1400 h_tof_m_final_offset[idx][i][j] =
1401 (TH2D*)f_tof_final[idx][i]->Get( Form(
"h_tof_m_final_offset_%s_%d", name, j ) );
1402 h_tof_p_final_sigma[idx][i][j] =
1403 (TH2D*)f_tof_final[idx][i]->Get( Form(
"h_tof_p_final_sigma_%s_%d", name, j ) );
1404 h_tof_m_final_sigma[idx][i][j] =
1405 (TH2D*)f_tof_final[idx][i]->Get( Form(
"h_tof_m_final_sigma_%s_%d", name, j ) );
1410 filename.push_back( path + Form(
"/share/%s/tof_endcap/tofec_q_d10.root", dir ) );
1411 filename.push_back( path + Form(
"/share/%s/tof_endcap/tofec_q_d11.root", dir ) );
1412 filename.push_back( path + Form(
"/share/%s/tof_endcap/tofec_q_m10.root", dir ) );
1413 filename.push_back( path + Form(
"/share/%s/tof_endcap/tofec_q_m11.root", dir ) );
1414 for (
unsigned int i = 0; i < filename.size(); i++ )
1416 f_tofec_q[idx][i] =
new TFile( filename[i].
c_str(),
"READ" );
1418 if ( i == 0 ) name =
"d10";
1419 else if ( i == 1 ) name =
"d11";
1420 else if ( i == 2 ) name =
"m10";
1421 else if ( i == 3 ) name =
"m11";
1424 cout <<
"Boundary Error! " << endl;
1427 for (
unsigned int j = 0; j < 2; j++ )
1429 h_tofec_p_q_offset[idx][i][j] =
1430 (TH1D*)f_tofec_q[idx][i]->Get( Form(
"h_tofec_p_q_offset_%s_%d", name, j ) );
1431 h_tofec_m_q_offset[idx][i][j] =
1432 (TH1D*)f_tofec_q[idx][i]->Get( Form(
"h_tofec_m_q_offset_%s_%d", name, j ) );
1433 h_tofec_p_q_sigma[idx][i][j] =
1434 (TH1D*)f_tofec_q[idx][i]->Get( Form(
"h_tofec_p_q_sigma_%s_%d", name, j ) );
1435 h_tofec_m_q_sigma[idx][i][j] =
1436 (TH1D*)f_tofec_q[idx][i]->Get( Form(
"h_tofec_m_q_sigma_%s_%d", name, j ) );
1441 filename.push_back( path + Form(
"/share/%s/tof_endcap/tofec_bg_d10.root", dir ) );
1442 filename.push_back( path + Form(
"/share/%s/tof_endcap/tofec_bg_d11.root", dir ) );
1443 filename.push_back( path + Form(
"/share/%s/tof_endcap/tofec_bg_m10.root", dir ) );
1444 filename.push_back( path + Form(
"/share/%s/tof_endcap/tofec_bg_m11.root", dir ) );
1445 for (
unsigned int i = 0; i < filename.size(); i++ )
1447 f_tofec_bg[idx][i] =
new TFile( filename[i].
c_str(),
"READ" );
1449 if ( i == 0 ) name =
"d10";
1450 else if ( i == 1 ) name =
"d11";
1451 else if ( i == 2 ) name =
"m10";
1452 else if ( i == 3 ) name =
"m11";
1455 cout <<
"Boundary Error! " << endl;
1458 for (
unsigned int j = 0; j < 2; j++ )
1460 h_tofec_p_bg_offset[idx][i][j] =
1461 (TH1D*)f_tofec_bg[idx][i]->Get( Form(
"h_tofec_p_bg_offset_%s_%d", name, j ) );
1462 h_tofec_m_bg_offset[idx][i][j] =
1463 (TH1D*)f_tofec_bg[idx][i]->Get( Form(
"h_tofec_m_bg_offset_%s_%d", name, j ) );
1464 h_tofec_p_bg_sigma[idx][i][j] =
1465 (TH1D*)f_tofec_bg[idx][i]->Get( Form(
"h_tofec_p_bg_sigma_%s_%d", name, j ) );
1466 h_tofec_m_bg_sigma[idx][i][j] =
1467 (TH1D*)f_tofec_bg[idx][i]->Get( Form(
"h_tofec_m_bg_sigma_%s_%d", name, j ) );
1472 filename.push_back( path + Form(
"/share/%s/tof_endcap/tofec_cost_d10.root", dir ) );
1473 filename.push_back( path + Form(
"/share/%s/tof_endcap/tofec_cost_d11.root", dir ) );
1474 filename.push_back( path + Form(
"/share/%s/tof_endcap/tofec_cost_m10.root", dir ) );
1475 filename.push_back( path + Form(
"/share/%s/tof_endcap/tofec_cost_m11.root", dir ) );
1476 for (
unsigned int i = 0; i < filename.size(); i++ )
1478 f_tofec_cost[idx][i] =
new TFile( filename[i].
c_str(),
"READ" );
1480 if ( i == 0 ) name =
"d10";
1481 else if ( i == 1 ) name =
"d11";
1482 else if ( i == 2 ) name =
"m10";
1483 else if ( i == 3 ) name =
"m11";
1486 cout <<
"Boundary Error! " << endl;
1489 for (
unsigned int j = 0; j < 2; j++ )
1491 h_tofec_p_cost_offset[idx][i][j] =
1492 (TH1D*)f_tofec_cost[idx][i]->Get( Form(
"h_tofec_p_cost_offset_%s_%d", name, j ) );
1493 h_tofec_m_cost_offset[idx][i][j] =
1494 (TH1D*)f_tofec_cost[idx][i]->Get( Form(
"h_tofec_m_cost_offset_%s_%d", name, j ) );
1495 h_tofec_p_cost_sigma[idx][i][j] =
1496 (TH1D*)f_tofec_cost[idx][i]->Get( Form(
"h_tofec_p_cost_sigma_%s_%d", name, j ) );
1497 h_tofec_m_cost_sigma[idx][i][j] =
1498 (TH1D*)f_tofec_cost[idx][i]->Get( Form(
"h_tofec_m_cost_sigma_%s_%d", name, j ) );
1502 for (
unsigned int idx = 0; idx < 3; idx++ )
1505 if ( idx == 0 ) dir =
"electron/emc";
1506 else if ( idx == 1 ) dir =
"kpi/emc_pion";
1507 else if ( idx == 2 ) dir =
"kpi/emc_kaon";
1510 cout <<
"Boundary Error! " << endl;
1515 filename.push_back( path + Form(
"/share/%s/emc_d10.root", dir ) );
1516 filename.push_back( path + Form(
"/share/%s/emc_d11.root", dir ) );
1517 filename.push_back( path + Form(
"/share/%s/emc_m10.root", dir ) );
1518 filename.push_back( path + Form(
"/share/%s/emc_m11.root", dir ) );
1519 for (
unsigned int i = 0; i < filename.size(); i++ )
1521 f_emc[idx][i] =
new TFile( filename[i].
c_str(),
"READ" );
1523 if ( i == 0 ) name =
"d10";
1524 else if ( i == 1 ) name =
"d11";
1525 else if ( i == 2 ) name =
"m10";
1526 else if ( i == 3 ) name =
"m11";
1529 cout <<
"Boundary Error! " << endl;
1532 for (
unsigned int j = 0; j < 15; j++ )
1534 for (
unsigned int k = 0; k < 25; k++ )
1536 h_emc_ep[idx][i][j][k] =
1537 (TH1D*)f_emc[idx][i]->Get( Form(
"h_ep_%s_%d_%d", name, j, k ) );
1538 h_emc_e35[idx][i][j][k] =
1539 (TH1D*)f_emc[idx][i]->Get( Form(
"h_e35_%s_%d_%d", name, j, k ) );
1544 cout <<
"Successfully Return from Loading Initializations by package SimplePIDSvc ... "
1548int SimplePIDSvc::findBin(
double* a,
int length,
double value ) {
1549 for (
int i = 0; i < length; i++ )
1551 if ( value > a[i] && value <= a[i + 1] ) {
return i; }
1553 if ( value < a[0] ) {
return 0; }
1554 else {
return length; }
1558 return pow( m_dedx_chi[i], 2 ) + pow( m_tof_chi[i], 2 );
1561void SimplePIDSvc::loadEMCInfo(
EvtRecTrack* track ) {
1563 for (
unsigned int i = 0; i < 5; i++ )
1565 m_emc_eop[i] = -99.;
1566 m_emc_likelihood[i] = -99.;
1573 m_lh_electron = -99.;
1577 RecEmcShower* emc_trk = track->
emcShower();
1578 m_emc_e = emc_trk->
energy();
1579 for (
unsigned int i = 0; i < 5; i++ ) { m_emc_eop[i] = m_emc_e / fabs( m_p[i] ); }
1580 double eseed = emc_trk->
eSeed();
1581 double e3 = emc_trk->
e3x3();
1582 double e5 = emc_trk->
e5x5();
1585 if ( e3 != 0 ) { m_emc_e13 = eseed / e3; }
1586 if ( e5 != 0 ) { m_emc_e35 = e3 / e5; }
1589bool SimplePIDSvc::calEMCLikelihood() {
1590 if ( m_emc_eop[0] < 0 )
return false;
1592 int idx = getRunIdx( m_run );
1593 const Int_t BIN_P = 15;
1594 const Int_t BIN_COST = 25;
1595 const Int_t BIN_PID = 3;
1596 const double EPS = 1e-4;
1598 double P[BIN_PID][BIN_P + 1] = {
1599 { 0.20, 0.47, 0.56, 0.65, 0.72, 0.79, 0.86, 0.92, 0.98, 1.03, 1.08, 1.13, 1.17, 1.22,
1601 { 0.20, 0.26, 0.31, 0.35, 0.39, 0.42, 0.46, 0.49, 0.53, 0.57, 0.62, 0.67, 0.73, 0.80,
1603 { 0.20, 0.33, 0.39, 0.43, 0.48, 0.52, 0.56, 0.61, 0.67, 0.73, 0.76, 0.81, 0.85, 0.90,
1606 double COST[BIN_PID][BIN_COST + 1] = {
1607 { -0.930, -0.910, -0.905, -0.897, -0.890, -0.881, -0.871, -0.858, -0.775,
1608 -0.732, -0.669, -0.561, -0.330, 0.199, 0.515, 0.645, 0.718, 0.766,
1609 0.804, 0.870, 0.882, 0.891, 0.898, 0.906, 0.913, 0.930 },
1610 { -0.930, -0.810, -0.728, -0.648, -0.574, -0.501, -0.431, -0.364, -0.295,
1611 -0.228, -0.161, -0.096, -0.031, 0.035, 0.100, 0.167, 0.234, 0.301,
1612 0.370, 0.439, 0.510, 0.580, 0.655, 0.733, 0.813, 0.930 },
1613 { -0.930, -0.804, -0.721, -0.643, -0.568, -0.497, -0.429, -0.362, -0.293,
1614 -0.228, -0.161, -0.096, -0.029, 0.035, 0.100, 0.166, 0.233, 0.298,
1615 0.365, 0.432, 0.500, 0.571, 0.644, 0.722, 0.805, 0.930 },
1620 int bin_p, bin_cost;
1621 for (
unsigned int i = 0; i < 4; i++ )
1624 if ( i == 0 ) pid = 0;
1625 else if ( i == 2 ) pid = 1;
1626 else if ( i == 3 ) pid = 2;
1630 vcost =
max( COST[pid][0] +
EPS,
min( COST[pid][BIN_COST] -
EPS, m_cost[i] ) );
1631 bin_p = findBin(
P[pid], BIN_P, vp );
1632 bin_cost = findBin( COST[pid], BIN_COST, vcost );
1634 m_emc_likelihood[i] = h_emc_ep[pid][idx][bin_p][bin_cost]->Interpolate( m_emc_eop[i] ) *
1635 h_emc_e35[pid][idx][bin_p][bin_cost]->Interpolate( m_emc_e35 );
1637 double a = m_prob[0] > 0 ? m_prob[0] : 0;
1638 double b = m_prob[2] > 0 ? m_prob[2] : 0;
1639 double c = m_prob[3] > 0 ? m_prob[3] : 0;
1640 double sum = a * m_emc_likelihood[0] + b * m_emc_likelihood[2] + c * m_emc_likelihood[3];
1642 if ( sum > 0 && m_prob[0] > 0 )
1644 m_lh_electron = m_prob[0] * m_emc_likelihood[0] / sum;
1647 else {
return false; }
1651 if ( m_prob[2] > 0.00 && m_prob[2] > m_prob[3] )
return true;
1656 if ( m_prob[3] > 0.00 && m_prob[3] > m_prob[2] )
return true;
1678 if ( m_prob[0] > 0 && m_prob[0] > m_prob[2] && m_prob[0] > m_prob[3] )
return true;
1683 if ( calEMCLikelihood() )
1685 if ( m_lh_electron > m_eid_ratio )
return true;
1690 if ( m_prob[0] > 0 && m_prob[0] > m_prob[2] && m_prob[0] > m_prob[3] )
return true;
DECLARE_COMPONENT(BesBdkRc)
double P(RecMdcKalTrack *trk)
double cos(const BesAngle a)
****INTEGER imax DOUBLE PRECISION m_pi *DOUBLE PRECISION m_amfin DOUBLE PRECISION m_Chfin DOUBLE PRECISION m_Xenph DOUBLE PRECISION m_sinw2 DOUBLE PRECISION m_GFermi DOUBLE PRECISION m_MfinMin DOUBLE PRECISION m_ta2 INTEGER m_out INTEGER m_KeyFSR INTEGER m_KeyQCD *COMMON c_Semalib $ !copy of input $ !CMS energy $ !beam mass $ !final mass $ !beam charge $ !final charge $ !smallest final mass $ !Z mass $ !Z width $ !EW mixing angle $ !Gmu Fermi $ alphaQED at q
double secondMoment() const
const Hep3Vector tof1Position() const
const Hep3Vector tof2Position() const
const double theta() const
static void setPidType(PidType pidType)
bool isMdcKalTrackValid()
SmartRefVector< RecTofTrack > tofTrack()
RecEmcShower * emcShower()
RecMdcKalTrack * mdcKalTrack()
SimplePIDSvc(const std::string &name, ISvcLocator *svcLoc)
void preparePID(EvtRecTrack *track)
virtual StatusCode initialize()
bool iselectron(bool emc=true)
virtual StatusCode finalize()
unsigned int layer() const
void setStatus(unsigned int status)