CGEM BOSS 6.6.5.h
BESIII Offline Software System
Loading...
Searching...
No Matches
TofCorrPID Class Reference

#include <TofCorrPID.h>

+ Inheritance diagram for TofCorrPID:

Public Member Functions

 ~TofCorrPID ()
 
void init ()
 
void calculate ()
 
bool IsPidInfoValid () const
 
double chi (int n) const
 
double prob (int n) const
 
double offset (int n) const
 
double sigma (int n) const
 
int ndof () const
 
- Public Member Functions inherited from ParticleIDBase
 ParticleIDBase ()
 
virtual ~ParticleIDBase ()
 
EvtRecTrackPidTrk () const
 
void setRecTrack (EvtRecTrack *trk)
 
double chiMinCut () const
 
void setChiMinCut (const double chi=4)
 
double pdfMinSigmaCut () const
 
void setPdfMinSigmaCut (const double pdf=4)
 
double getRunNo () const
 
void setRunNo (const double runh=8093)
 
double p ()
 
double pt ()
 
double charge ()
 
double xmass (int n)
 
double velc ()
 
double probCalculate (double chi2, int n)
 
double pdfCalculate (double offset, double sigma)
 
double interpolation (double *x, double *y, double x1)
 
double pol2 (double x, double *par)
 
double pol3 (double x, double *par)
 
double pol4 (double x, double *par)
 
int useDedx () const
 
int useTof () const
 
int useTof1 () const
 
int useTof2 () const
 
int useTofE () const
 
int useTofQ () const
 
int useTofC () const
 
int useTofCorr () const
 
int useEmc () const
 
int useMuc () const
 
int useMrpc () const
 
int onlyPionKaon () const
 
int onlyPionKaonProton () const
 
int onlyPionKaonElectron () const
 
int all () const
 
int onlyElectron () const
 
int onlyMuon () const
 
int onlyPion () const
 
int onlyKaon () const
 
int onlyProton () const
 
int methodLikelihood () const
 
int methodProbability () const
 
int methodNeuronNetwork () const
 
int dedxValid () const
 
int tofValid () const
 
int tofeValid () const
 
int tofqValid () const
 
int tofcValid () const
 
int tofcorrValid () const
 
int emcValid () const
 
int mucValid () const
 
int MrpcValid () const
 
void set_path (const char *s_path=0)
 
void set_path (std::string s_path)
 

Static Public Member Functions

static TofCorrPIDinstance ()
 

Protected Member Functions

int particleIDCalculation ()
 
int neuronPIDCalculation ()
 
int LikelihoodCalculation ()
 
void inputParameter (int run)
 
double offsetTof (unsigned int ispecies, bool barrel, unsigned int ipmt, double betaGamma, int charge, double zrhit, double dt)
 
double offsetTof (unsigned int ispecies, int tofid, double zrhit, double dt)
 
double offsetTof (unsigned int ispecies, int tofid1, int tofid2, double zrhit1, double zrhit2, double dt)
 
double sigmaTof (unsigned int ispecies, int charge, bool barrel, unsigned int ipmt, int tofid[2], double zrhit[2], double betaGamma)
 
double sigmaTof (unsigned int ispecies, int charge, bool barrel, unsigned int ipmt, double zrhit, int ibgbin)
 
double qCurveFunc (unsigned int layer, double betaGamma)
 
double bSigma (unsigned int end, int tofid, double zrhit)
 
double bSigma (int tofid[2], double zrhit[2])
 
double eSigma (int tofid, double zrhit)
 
bool correlationCheck ()
 
- Protected Member Functions inherited from ParticleIDBase

Additional Inherited Members

- Static Protected Attributes inherited from ParticleIDBase
static std::string path = ""
 

Detailed Description

Definition at line 14 of file TofCorrPID.h.

Constructor & Destructor Documentation

◆ ~TofCorrPID()

TofCorrPID::~TofCorrPID ( )
inline

Definition at line 19 of file TofCorrPID.h.

19{;}

Member Function Documentation

◆ bSigma() [1/2]

double TofCorrPID::bSigma ( int tofid[2],
double zrhit[2] )
protected

Definition at line 841 of file TofCorrPID.cxx.

841 {
842
843 double sigma1 = bSigma( 2, tofid[0], zrhit[0] );
844 double sigma2 = bSigma( 2, tofid[1], zrhit[1] );
845 double sigmaCorr2 = m_p_common*m_p_common;
846 double sigma = ( sigma1*sigma1*sigma2*sigma2 - sigmaCorr2*sigmaCorr2 )/( sigma1*sigma1 + sigma2*sigma2 - 2.0*sigmaCorr2 );
847 sigma = sqrt(fabs(sigma));
848
849 return sigma;
850}
double sigma2(0)
double sigma(int n) const
Definition TofCorrPID.h:27
double bSigma(unsigned int end, int tofid, double zrhit)

◆ bSigma() [2/2]

double TofCorrPID::bSigma ( unsigned int end,
int tofid,
double zrhit )
protected

Definition at line 823 of file TofCorrPID.cxx.

823 {
824
825 double func[5];
826 func[0] = 1.0;
827 func[1] = zrhit;
828 func[2] = zrhit*zrhit;
829 func[3] = zrhit*zrhit*zrhit;
830 func[4] = zrhit*zrhit*zrhit*zrhit;
831
832 double sigma = 0.0;
833 for( unsigned int i=0; i<5; i++ ) {
834 sigma += m_p_weight[tofid][end][i]*func[i];
835 }
836
837 return sigma;
838}

Referenced by bSigma(), offsetTof(), offsetTof(), and sigmaTof().

◆ calculate()

void TofCorrPID::calculate ( )
virtual

Implements ParticleIDBase.

Definition at line 56 of file TofCorrPID.cxx.

56 {
57 if(particleIDCalculation() == 0) m_ndof=1;
58}
int particleIDCalculation()

◆ chi()

double TofCorrPID::chi ( int n) const
inlinevirtual

Implements ParticleIDBase.

Definition at line 24 of file TofCorrPID.h.

24{return m_chi[n];}
const Int_t n

◆ correlationCheck()

bool TofCorrPID::correlationCheck ( )
protected

Definition at line 869 of file TofCorrPID.cxx.

869 {
870 bool chiCut = false;
871 bool good = false;
872 double pdftemp = 0;
873 for( unsigned int i=0; i<5; i++ ) {
874 m_chi[i] = m_offset[i]/m_sigma[i];
875 if( ( m_chi[i]>-4.0 && m_chi[i]<6.0 ) && !good ) { good=true; }
876 double ppp = pdfCalculate(m_chi[i],1);
877 if( fabs(ppp) > pdftemp) { pdftemp = fabs(ppp); }
878 }
879 m_pdfmin = pdftemp;
880 if( pdftemp < pdfCalculate(pdfMinSigmaCut(),1) ) return chiCut;
881 if( !good ) return chiCut;
882 chiCut = true;
883 return chiCut;
884}
double pdfCalculate(double offset, double sigma)
double pdfMinSigmaCut() const

Referenced by particleIDCalculation().

◆ eSigma()

double TofCorrPID::eSigma ( int tofid,
double zrhit )
protected

Definition at line 853 of file TofCorrPID.cxx.

853 {
854
855 double func[5];
856 func[0] = 1.0;
857 func[1] = zrhit;
858 func[2] = zrhit*zrhit;
859
860 double sigma = 0.0;
861 for( unsigned int i=0; i<3; i++ ) {
862 sigma += m_ec_sigma[tofid][i]*func[i];
863 }
864
865 return sigma;
866}

Referenced by sigmaTof().

◆ init()

void TofCorrPID::init ( )
virtual

Implements ParticleIDBase.

Definition at line 29 of file TofCorrPID.cxx.

29 {
30
31 for(int i = 0; i < 5; i++) {
32 m_chi[i] = -100.0;
33 m_prob[i] = -1.0;
34 m_sigma[i] = 10.0;
35 m_offset[i] = -1000.0;
36 }
37 m_chimin = 99.;
38 m_pdfmin = 99.;
39 m_ndof = 0;
40
41 for( unsigned int i=0; i<5; i++ ) {
42 for( unsigned int j=0; j<7; j++ ) {
43 m_deltaT[j][i] = -1000.0;
44 }
45 }
46
47 int run = getRunNo();
48 if( !( abs(run)>=m_runBegin && abs(run)<=m_runEnd ) ) {
50 }
51
52 return;
53}
double abs(const EvtComplex &c)
double getRunNo() const
void inputParameter(int run)

◆ inputParameter()

void TofCorrPID::inputParameter ( int run)
protected

Definition at line 216 of file TofCorrPID.cxx.

216 {
217
218 std::string filePath = path + "/share/TofCorrPID/";
219
220 if( abs(run)>=8093 && abs(run)<=9025 ) {
221 filePath = filePath + "psip2009";
222 m_runBegin = 8093;
223 m_runEnd = 9025;
224 }
225 else if( abs(run)>=9947 && abs(run)<=10878 ) {
226 filePath = filePath + "jpsi2009";
227 m_runBegin = 9947;
228 m_runEnd = 10878;
229 }
230
231 if( run>0 ) {
232 filePath = filePath + "/data/";
233 }
234 else {
235 filePath = filePath + "/mc/";
236 }
237
238
239 // weight from tof calibration
240 std::string fileWeight = filePath + "calib_barrel_sigma.txt";
241 ifstream inputWeight( fileWeight.c_str(), std::ios_base::in );
242 if( !inputWeight ) {
243 cout << "ParticleID::TofCorrPID: Can NOT open file: " << fileWeight << endl;
244 exit(1);
245 }
246
247 for( unsigned int tofid=0; tofid<176; tofid++ ) {
248 for( unsigned int readout=0; readout<3; readout++ ) {
249 for( unsigned int p_i=0; p_i<5; p_i++ ) {
250 inputWeight >> m_p_weight[tofid][readout][p_i];
251 }
252 }
253 }
254 // cout << "finish read " << fileWeight << endl;
255
256 // common item, from bunch size and bunch time
257 std::string fileCommon = filePath + "calib_barrel_common.txt";
258 ifstream inputCommon( fileCommon.c_str(), std::ios_base::in );
259 if( !inputCommon ) {
260 cout << "ParticleID::TofCorrPID: Can NOT open file: " << fileCommon << endl;
261 exit(1);
262 }
263 inputCommon >> m_p_common;
264 // cout << "finish read " << fileCommon << endl;
265
266 // endcap sigma
267 std::string fileEcSigma = filePath + "calib_endcap_sigma.txt";
268 ifstream inputEcSigma( fileEcSigma.c_str(), std::ios_base::in );
269 if( !inputEcSigma ) {
270 cout << "ParticleID::TofCorrPID: Can NOT open file: " << fileEcSigma << endl;
271 exit(1);
272 }
273
274 for( unsigned int tofid=0; tofid<96; tofid++ ) {
275 for( unsigned int p_i=0; p_i<3; p_i++ ) {
276 inputEcSigma >> m_ec_sigma[tofid][p_i];
277 }
278 }
279 // cout << "finish read " << fileEcSigma << endl;
280
281 // curve of betaGamma versus Q0
282 std::string fileQ0BetaGamma = filePath + "curve_Q0_BetaGamma.txt";
283 ifstream inputQ0BetaGamma( fileQ0BetaGamma.c_str(), std::ios_base::in );
284 if( !inputQ0BetaGamma ) {
285 cout << "ParticleID::TofCorrPID: Can NOT open file: " << fileQ0BetaGamma << endl;
286 exit(1);
287 }
288 // barrel layer1 layer2 and endcap
289 for( unsigned int layer=0; layer<3; layer++ ) {
290 for( unsigned int ipar=0; ipar<5; ipar++ ) {
291 inputQ0BetaGamma >> m_q0_bg[layer][ipar];
292 }
293 }
294 // cout << "finish read " << fileQ0BetaGamma << endl;
295
296 // paramter of A and B
297 std::string fileParAB = filePath + "parameter_A_B.txt";
298 ifstream inputParAB( fileParAB.c_str(), std::ios_base::in );
299 if( !inputParAB ) {
300 cout << "ParticleID::TofCorrPID: Can NOT open file: " << fileParAB << endl;
301 exit(1);
302 }
303 // 0: inner east, 1: inner west, 2: outer east, 3: outer west, 4: west endcap
304 // 0: parameter A, 1: parameter B
305 for( unsigned int ipmt=0; ipmt<5; ipmt++ ) {
306 for( unsigned int iab=0; iab<2; iab++ ) {
307 for( unsigned int ipar=0; ipar<5; ipar++ ) {
308 inputParAB >> m_par_ab[ipmt][iab][ipar];
309 }
310 }
311 }
312 for( unsigned int ipmt=0; ipmt<5; ipmt++ ) {
313 for( unsigned int iab=0; iab<2; iab++ ) {
314 for( unsigned int ipar=0; ipar<5; ipar++ ) {
315 inputParAB >> m_par_pbar_ab[ipmt][iab][ipar];
316 }
317 }
318 }
319 // cout << "finish read " << fileParAB << endl;
320
321 // sigma for pion, kaon and proton
322 std::string fileSigma = filePath + "parameter_sigma.txt";
323 ifstream inputSigma( fileSigma.c_str(), std::ios_base::in );
324 if( !inputSigma ) {
325 cout << "ParticleID::TofCorrPID: Can NOT open file: " << fileSigma << endl;
326 exit(1);
327 }
328 // 0: pion, 1: kaon, 2: proton, 3: anti-proton
329 // 0: inner east, 1: inner west, 2: outer east, 3: outer west
330 // 4: inner layer, 5: outer layer, 6: double layer
331 // 7: west endcap
332 for( unsigned int ispecies=0; ispecies<4; ispecies++ ) {
333 for( unsigned int ipmt=0; ipmt<8; ipmt++ ) {
334 for( unsigned int ipar=0; ipar<9; ipar++ ) {
335 inputSigma >> m_par_sigma[ispecies][ipmt][ipar];
336 }
337 }
338 }
339 // cout << "finish read " << fileSigma << endl;
340
341 // chi for pion, kaon and proton
342 /*
343 std::string fileChi = filePath + "parameter_sigma_momentum.txt";
344 ifstream inputChi( fileChi.c_str(), std::ios_base::in );
345 if( !inputChi ) {
346 cout << "ParticleID::TofCorrPID: Can NOT open file: " << fileChi << endl;
347 exit(1);
348 }
349 // 0: inner east, 1: inner west, 2: outer east, 3: outer west
350 // 4: inner layer, 5: outer layer, 6: double layer
351 for( unsigned int ispecies=0; ispecies<3; ispecies++ ) {
352 for( unsigned int ipmt=0; ipmt<7; ipmt++ ) {
353 for( unsigned int ipar=0; ipar<3; ipar++ ) {
354 inputChi >> m_par_sig_mom[ispecies][ipmt][ipar];
355 }
356 }
357 }
358 */
359 // cout << "finish read " << fileChi << endl;
360
361
362 // offset for low momentum proton and anti-proton
363 std::string fileProtonOffset = filePath + "parameter_offset_proton.txt";
364 ifstream inputProtonOffset( fileProtonOffset.c_str(), std::ios_base::in );
365 if( !inputProtonOffset ) {
366 cout << "ParticleID::TofCorrPID: Can NOT open file: " << fileProtonOffset << endl;
367 exit(1);
368 }
369 // 0: proton, 1: anti-proton
370 // 0: inner east, 1: inner west, 2: outer east, 3: outer west
371 for( unsigned int ispecies=0; ispecies<2; ispecies++ ) {
372 for( unsigned int ipmt=0; ipmt<4; ipmt++ ) {
373 for( unsigned int ipar=0; ipar<10; ipar++ ) {
374 for( unsigned int jpar=0; jpar<20; jpar++ ) {
375 inputProtonOffset >> m_p_offset[ispecies][ipmt][ipar][jpar];
376 }
377 }
378 }
379 }
380 // cout << "finish read " << fileProtonOffset << endl;
381
382 // sigma for low momentum proton and anti-proton
383 std::string fileProtonSigma = filePath + "parameter_sigma_proton.txt";
384 ifstream inputProtonSigma( fileProtonSigma.c_str(), std::ios_base::in );
385 if( !inputProtonSigma ) {
386 cout << "ParticleID::TofCorrPID: Can NOT open file: " << fileProtonSigma << endl;
387 exit(1);
388 }
389 // 0: proton, 1: anti-proton
390 // 0: inner east, 1: inner west, 2: outer east, 3: outer west
391 // 4: inner layer, 5: outer layer, 6: double layer
392 // 7: west endcap
393 for( unsigned int ispecies=0; ispecies<2; ispecies++ ) {
394 for( unsigned int ipmt=0; ipmt<7; ipmt++ ) {
395 for( unsigned int ipar=0; ipar<10; ipar++ ) {
396 for( unsigned int jpar=0; jpar<20; jpar++ ) {
397 inputProtonSigma >> m_p_sigma[ispecies][ipmt][ipar][jpar];
398 }
399 }
400 }
401 }
402 // cout << "finish read " << fileProtonSigma << endl;
403
404
405 return;
406}
static std::string path

Referenced by init().

◆ instance()

TofCorrPID * TofCorrPID::instance ( )
static

Definition at line 19 of file TofCorrPID.cxx.

19 {
20 if(!m_pointer) m_pointer = new TofCorrPID();
21 return m_pointer;
22}

Referenced by ParticleID::init().

◆ IsPidInfoValid()

bool TofCorrPID::IsPidInfoValid ( ) const
inlinevirtual

Implements ParticleIDBase.

Definition at line 23 of file TofCorrPID.h.

23{return (m_ndof > 0); }

◆ LikelihoodCalculation()

int TofCorrPID::LikelihoodCalculation ( )
inlineprotectedvirtual

Implements ParticleIDBase.

Definition at line 34 of file TofCorrPID.h.

34{return -1;}

◆ ndof()

int TofCorrPID::ndof ( ) const
inlinevirtual

Implements ParticleIDBase.

Definition at line 28 of file TofCorrPID.h.

28{return m_ndof;}

◆ neuronPIDCalculation()

int TofCorrPID::neuronPIDCalculation ( )
inlineprotected

Definition at line 33 of file TofCorrPID.h.

33{ return -1;}

◆ offset()

double TofCorrPID::offset ( int n) const
inline

Definition at line 26 of file TofCorrPID.h.

26{return m_offset[n];}

Referenced by ParticleID::offset(), and particleIDCalculation().

◆ offsetTof() [1/3]

double TofCorrPID::offsetTof ( unsigned int ispecies,
bool barrel,
unsigned int ipmt,
double betaGamma,
int charge,
double zrhit,
double dt )
protected

Definition at line 409 of file TofCorrPID.cxx.

409 {
410 if( ispecies==0 || ispecies==1 ) { return dt; }
411
412 double deltaT = -1000.0;
413 if( ( ipmt>= 4 && barrel ) || ( ipmt!=0 && !barrel ) || betaGamma<0.0 || abs(charge)!=1 || fabs(zrhit)>120.0 ) {
414 cout << "Particle::TofCorrPID: offsetTof for single end: the input parameter are NOT correct! Please check them!" << endl;
415 return deltaT;
416 }
417 unsigned int layer=0;
418 if( barrel ) {
419 if( ipmt==0 || ipmt==1 ) { layer=0; }
420 else if( ipmt==2 || ipmt==3 ) { layer=1; }
421 }
422 else { layer=2; }
423 double q0 = qCurveFunc( layer, betaGamma );
424
425 unsigned int inumber=ipmt;
426 if( !barrel ) { inumber=4; }
427
428 double func[5];
429 func[0] = 1.0;
430 func[1] = zrhit;
431 func[2] = zrhit*zrhit;
432 func[3] = zrhit*zrhit*zrhit;
433 func[4] = zrhit*zrhit*zrhit*zrhit;
434
435 double parA = 0.0;
436 double parB = 0.0;
437 // anti-proton
438 if( ispecies==4 && charge==-1 ) {
439 for( unsigned int i=0; i<5; i++ ) {
440 parA += m_par_pbar_ab[inumber][0][i]*func[i];
441 parB += m_par_pbar_ab[inumber][1][i]*func[i];
442 }
443 }
444 // proton
445 else {
446 for( unsigned int i=0; i<5; i++ ) {
447 parA += m_par_ab[inumber][0][i]*func[i];
448 parB += m_par_ab[inumber][1][i]*func[i];
449 }
450 }
451
452 double tcorr = parA + parB/sqrt(q0);
453
454 // barrel TOF low momentum proton and anti-proton
455 if( barrel && ispecies==4 && betaGamma<0.8 ) {
456 int nzbin = 10;
457 double zbegin = -115.0;
458 double zend = 115.0;
459 double zstep = (zend-zbegin)/nzbin;
460
461 double nbgbin = 20.0;
462 double bgbegin[2] = { 0.4, 0.55 };
463 double bgend[2] = { 0.8, 0.8 };
464 double bgstep[2];
465 bgstep[0] = (bgend[0]-bgbegin[0])/nbgbin;
466 bgstep[1] = (bgend[1]-bgbegin[1])/nbgbin;
467
468 int izbin = static_cast<int>((zrhit-zbegin)/zstep);
469 if( izbin<0 ) { izbin=0; }
470 else if( izbin>=nzbin ) { izbin=nzbin-1; }
471 unsigned int layer=0;
472 if( ipmt==2 || ipmt==3 ) { layer=1; }
473 int ibgbin = static_cast<int>((betaGamma-bgbegin[layer])/bgstep[layer]);
474 if( ibgbin<0 ) { ibgbin=0; }
475 else if( ibgbin>=nbgbin ) { ibgbin=nbgbin-1; }
476
477 if( charge==1 ) {
478 tcorr += m_p_offset[0][ipmt][izbin][ibgbin];
479 }
480 else {
481 tcorr += m_p_offset[1][ipmt][izbin][ibgbin];
482 }
483 }
484
485 deltaT = dt - tcorr;
486
487 return deltaT;
488}
TGraphErrors * dt
Definition AbsCor.cxx:72
const double zend
Definition TofCalibFit.h:15
const double zbegin
Definition TofCalibFit.h:14
double qCurveFunc(unsigned int layer, double betaGamma)

Referenced by particleIDCalculation().

◆ offsetTof() [2/3]

double TofCorrPID::offsetTof ( unsigned int ispecies,
int tofid,
double zrhit,
double dt )
protected

Definition at line 491 of file TofCorrPID.cxx.

491 {
492 if( ispecies==0 || ispecies==1 ) { return dt; }
493
494 double deltaT = -1000.0;
495 if( tofid<0 || tofid>=176 ) {
496 cout << "Particle::TofCorrPID: offsetTof for single layer: the input parameter are NOT correct! Please check them!" << endl;
497 exit(1);
498 }
499 int pmt[3] = { -9, -9, -9 };
500 if( tofid>=0 && tofid<=87 ) {
501 pmt[0] = 0;
502 pmt[1] = 1;
503 pmt[2] = 4;
504 }
505 else {
506 pmt[0] = 2;
507 pmt[1] = 3;
508 pmt[2] = 5;
509 }
510
511 double sigmaCorr2 = m_p_common*m_p_common;
512 double sigmaLeft = bSigma( 0, tofid, zrhit );
513 double sigmaLeft2 = sigmaLeft*sigmaLeft;
514 double sigmaRight = bSigma( 1, tofid, zrhit );
515 double sigmaRight2 = sigmaRight*sigmaRight;
516
517 double fraction = ( sigmaRight2 - sigmaCorr2 )/( sigmaLeft2 + sigmaRight2 - 2.0*sigmaCorr2);
518 deltaT = fraction*m_deltaT[pmt[0]][ispecies] + (1.0-fraction)*m_deltaT[pmt[1]][ispecies];
519
520 return deltaT;
521}

◆ offsetTof() [3/3]

double TofCorrPID::offsetTof ( unsigned int ispecies,
int tofid1,
int tofid2,
double zrhit1,
double zrhit2,
double dt )
protected

Definition at line 524 of file TofCorrPID.cxx.

524 {
525 if( ispecies==0 || ispecies==1 ) { return dt; }
526
527 double deltaT = -1000.0;
528 if( tofid1<0 || tofid1>=88 || tofid2<88 || tofid2>=176 ) {
529 cout << "Particle::TofCorrPID: offsetTof for double layer: the input parameter are NOT correct! Please check them!" << endl;
530 exit(1);
531 }
532
533 double sigmaCorr2 = m_p_common*m_p_common;
534 double sigmaInner = bSigma( 2, tofid1, zrhit1 );
535 double sigmaInner2 = sigmaInner*sigmaInner;
536 double sigmaOuter = bSigma( 2, tofid2, zrhit2 );
537 double sigmaOuter2 = sigmaOuter*sigmaOuter;
538 double sigma = sqrt( (sigmaInner2*sigmaOuter2-sigmaCorr2*sigmaCorr2)/(sigmaInner2+sigmaOuter2-2.0*sigmaCorr2) );
539
540 m_sigma[0] = sigma;
541 m_sigma[1] = sigma;
542
543 double fraction = ( sigmaOuter2 - sigmaCorr2 )/( sigmaInner2 + sigmaOuter2 - 2.0*sigmaCorr2);
544 deltaT = fraction*m_deltaT[4][ispecies] + (1.0-fraction)*m_deltaT[5][ispecies];
545
546 return deltaT;
547}

◆ particleIDCalculation()

int TofCorrPID::particleIDCalculation ( )
protectedvirtual

Implements ParticleIDBase.

Definition at line 61 of file TofCorrPID.cxx.

61 {
62 int irc=-1;
63
64 EvtRecTrack* recTrk = PidTrk();
65 if(!(recTrk->isMdcTrackValid())) return irc;
66 if(!(recTrk->isMdcKalTrackValid())) return irc;
67 if(!(recTrk->isExtTrackValid())) return irc;
68 if(!(recTrk->isTofTrackValid())) return irc;
69
70#ifndef BEAN
71 SmartRefVector<RecTofTrack> tofTrk = recTrk->tofTrack();
72 SmartRefVector<RecTofTrack>::iterator it;
73#else
74 const std::vector<TTofTrack* >& tofTrk = recTrk->tofTrack();
75 std::vector<TTofTrack* >::const_iterator it;
76#endif
77
78 RecMdcTrack* mdcTrk = recTrk->mdcTrack();
79 int charge = mdcTrk->charge();
80
81 double p[5], betaGamma[5];
82 RecMdcKalTrack* kalTrk = recTrk->mdcKalTrack();
83 for( int i=0; i<5; i++ ) {
84 if( i==0 ) {
86 }
87 else if( i==1 ) {
89 }
90 else if( i==2 ) {
92 }
93 else if( i==3 ) {
95 }
96 else if( i==4 ) {
98 }
99#ifndef BEAN
100 HepLorentzVector ptrk = kalTrk->p4();
101#else
102 HepLorentzVector ptrk = kalTrk->p4( xmass(i) );
103#endif
104 p[i] = ptrk.rho();
105 betaGamma[i] = p[i]/xmass(i);
106 }
107
108 double zrhit[2];
109 RecExtTrack* extTrk = recTrk->extTrack();
110 zrhit[0] = extTrk->tof1Position().z();
111 zrhit[1] = extTrk->tof2Position().z();
112
113 int tofid[2] = { -9, -9 };
114
115 bool readFile = false;
116 bool signal[2] = { false, false };
117 TofHitStatus *hitst = new TofHitStatus;
118 for( it = tofTrk.begin(); it!=tofTrk.end(); it++ ) {
119 unsigned int st = (*it)->status();
120 hitst->setStatus(st);
121 if( hitst->is_raw() ) return irc; // TOF no hit
122 bool barrel = hitst->is_barrel();
123 if( !barrel ) { zrhit[0] = extTrk->tof1Position().rho(); }
124 bool readout = hitst->is_readout();
125 bool counter = hitst->is_counter();
126 bool cluster = hitst->is_cluster();
127 int layer = hitst->layer();
128 tofid[layer-1] = (*it)->tofID();
129 bool east = hitst->is_east();
130 double tof = (*it)->tof();
131 if( readout ) {
132 // default 0: end cap
133 unsigned int ipmt = 0;
134 // barrel: 0: inner east, 1:inner west, 2:outer east, 3: outer west
135 // endcap: 0
136 if( barrel ) { ipmt = ( ( st & 0xC0 ) >> 5 ) + ( ( ( st ^ 0x20 ) & 0x20 ) >> 5 ) - 2; }
137 for( unsigned int i=0; i<5; i++ ) {
138 double offset = (*it)->toffset(i);
139 double texp = (*it)->texp(i);
140 if( texp<0.0 ) continue;
141 double dt = tof - offset - texp;
142 m_deltaT[ipmt][i] = offsetTof( i, barrel, ipmt, betaGamma[i], charge, zrhit[layer-1], dt );
143 }
144 if( counter && cluster ) {
145 for( unsigned int i=0; i<5; i++ ) {
146 if( ((*it)->texp(i))>0.0 ) {
147 m_offset[i] = m_deltaT[ipmt][i];
148 m_sigma[i] = sigmaTof( i, charge, barrel, ipmt, &tofid[0], &zrhit[0], betaGamma[i] );
149 }
150 }
151 }
152 }
153 else {
154 if( counter ) {
155 for( unsigned int i=0; i<5; i++ ) {
156 double offset = (*it)->toffset(i);
157 double texp = (*it)->texp(i);
158 if( texp<0.0 ) continue;
159 double dt = tof - offset - texp;
160 m_deltaT[layer+3][i] = offsetTof( i, tofid[layer-1], zrhit[layer-1], dt );
161 m_offset[i] = m_deltaT[layer+3][i];
162 m_sigma[i] = sigmaTof( i, charge, barrel, layer+3, &tofid[0], &zrhit[0], betaGamma[i] );
163 }
164 signal[layer-1] = correlationCheck();
165 }
166 else {
167 if( cluster ) {
168 if( signal[0] && signal[1] ) {
169 for( unsigned int i=0; i<5; i++ ) {
170 double offset = (*it)->toffset(i);
171 double texp = (*it)->texp(i);
172 if( texp<0.0 ) continue;
173 double dt = tof - offset - texp;
174 m_deltaT[6][i] = offsetTof( i, tofid[0], tofid[1], zrhit[0], zrhit[1], dt );
175 m_offset[i] = m_deltaT[6][i];
176 m_sigma[i] = sigmaTof( i, charge, barrel, 6, &tofid[0], &zrhit[0], betaGamma[i] );
177 }
178 }
179 else if( signal[0] && !signal[1] ) {
180 for( unsigned int i=0; i<5; i++ ) {
181 m_offset[i] = m_deltaT[4][i];
182 m_sigma[i] = sigmaTof( i, charge, barrel, 4, &tofid[0], &zrhit[0], betaGamma[i] );
183 }
184 }
185 else if( !signal[0] && signal[1] ) {
186 for( unsigned int i=0; i<5; i++ ) {
187 m_offset[i] = m_deltaT[5][i];
188 m_sigma[i] = sigmaTof( i, charge, barrel, 5, &tofid[1], &zrhit[1], betaGamma[i] );
189 }
190 }
191 else return irc;
192 }
193 }
194 }
195 }
196
197 bool good = false;
198 double pdftemp = 0;
199 for( unsigned int i=0; i<5; i++ ) {
200 m_chi[i] = m_offset[i]/m_sigma[i];
201 if( ( m_chi[i]>-4.0 && m_chi[i]<6.0 ) && !good ) { good = true; }
202 double ppp = pdfCalculate(m_chi[i],1);
203 if( fabs(ppp) > pdftemp) { pdftemp = fabs(ppp); }
204 }
205 m_pdfmin = pdftemp;
206 if( pdftemp < pdfCalculate(pdfMinSigmaCut(),1) ) return irc;
207 if( !good ) return irc;
208 for(int i = 0; i < 5; i++) {
209 m_prob[i] = probCalculate(m_chi[i]*m_chi[i], 1);
210 }
211 irc = 0;
212 return irc;
213}
const double xmass[5]
Definition Gam4pikp.cxx:50
const Hep3Vector tof1Position() const
Definition DstExtTrack.h:58
const Hep3Vector tof2Position() const
Definition DstExtTrack.h:94
static void setPidType(PidType pidType)
const HepLorentzVector p4() const
const int charge() const
Definition DstMdcTrack.h:53
bool isExtTrackValid()
Definition EvtRecTrack.h:57
RecExtTrack * extTrack()
Definition EvtRecTrack.h:68
bool isMdcKalTrackValid()
Definition EvtRecTrack.h:48
SmartRefVector< RecTofTrack > tofTrack()
Definition EvtRecTrack.h:69
bool isTofTrackValid()
Definition EvtRecTrack.h:54
bool isMdcTrackValid()
Definition EvtRecTrack.h:47
RecMdcTrack * mdcTrack()
Definition EvtRecTrack.h:61
RecMdcKalTrack * mdcKalTrack()
Definition EvtRecTrack.h:62
EvtRecTrack * PidTrk() const
double probCalculate(double chi2, int n)
bool correlationCheck()
double offset(int n) const
Definition TofCorrPID.h:26
double sigmaTof(unsigned int ispecies, int charge, bool barrel, unsigned int ipmt, int tofid[2], double zrhit[2], double betaGamma)
double offsetTof(unsigned int ispecies, bool barrel, unsigned int ipmt, double betaGamma, int charge, double zrhit, double dt)
bool is_barrel() const
unsigned int layer() const
bool is_cluster() const
void setStatus(unsigned int status)
bool is_counter() const
bool is_east() const
bool is_readout() const
bool is_raw() const

Referenced by calculate().

◆ prob()

double TofCorrPID::prob ( int n) const
inlinevirtual

Implements ParticleIDBase.

Definition at line 25 of file TofCorrPID.h.

25{return m_prob[n];}

◆ qCurveFunc()

double TofCorrPID::qCurveFunc ( unsigned int layer,
double betaGamma )
protected

Definition at line 808 of file TofCorrPID.cxx.

808 {
809 double q0 = -100.0;
810 if( layer>=3 || betaGamma<0.0 ) {
811 cout << "Particle::TofCorrPID::qCurveFunc: the input parameter are NOT correct! Please check them!" << endl;
812 return q0;
813 }
814
815 double beta = betaGamma/sqrt(1.0+betaGamma*betaGamma);
816 double logterm = log( m_q0_bg[layer][2]+pow((1.0/betaGamma), m_q0_bg[layer][4] ) );
817 q0 = m_q0_bg[layer][0]*( m_q0_bg[layer][1]-pow( beta, m_q0_bg[layer][3] ) - logterm )/pow( beta, m_q0_bg[layer][3] );
818
819 return q0;
820}

Referenced by offsetTof().

◆ sigma()

double TofCorrPID::sigma ( int n) const
inline

Definition at line 27 of file TofCorrPID.h.

27{return m_sigma[n];}

Referenced by bSigma(), bSigma(), eSigma(), offsetTof(), ParticleID::sigma(), sigmaTof(), and sigmaTof().

◆ sigmaTof() [1/2]

double TofCorrPID::sigmaTof ( unsigned int ispecies,
int charge,
bool barrel,
unsigned int ipmt,
double zrhit,
int ibgbin )
protected

Definition at line 607 of file TofCorrPID.cxx.

607 {
608
609 int izbin=0;
610 if( barrel && ispecies==4 && ibgbin!=-1 ) {
611 int nzbin = 10;
612 double zbegin = -115.0;
613 double zend = 115.0;
614 double zstep = (zend-zbegin)/nzbin;
615
616 izbin = static_cast<int>((zrhit-zbegin)/zstep);
617 if( izbin<0 ) { izbin=0; }
618 else if( izbin>=nzbin ) { izbin=nzbin-1; }
619 }
620
621 double func[10];
622 for( unsigned int i=0; i<9; i++ ) {
623 if( i==0 ) { func[i] = 1.0; }
624 else {
625 func[i] = func[i-1]*zrhit;
626 }
627 }
628 func[9] = -1.0/(zrhit*zrhit-115.0*115.0);
629
630 unsigned int inumber = ipmt;
631 if( !barrel ) { inumber=7; }
632
633 double sigma = 0.0;
634 // barrel
635 if( barrel ) {
636 // barrel inner layer east/west
637 if( ipmt==0 || ipmt==1 ) {
638 if( ispecies==2 || ispecies==3 ) { // pion / kaon
639 for( unsigned int i=0; i<5; i++ ) {
640 if( i!=4 ) {
641 sigma += m_par_sigma[ispecies-2][inumber][i]*func[i];
642 }
643 else {
644 sigma += m_par_sigma[ispecies-2][inumber][i]*func[9];
645 }
646 }
647 }
648 else if( ispecies==4 ) {
649 if( ibgbin!=-1 ) {
650 if( charge==1 ) {
651 sigma = m_p_sigma[0][inumber][izbin][ibgbin];
652 }
653 else {
654 sigma = m_p_sigma[1][inumber][izbin][ibgbin];
655 }
656 }
657 else {
658 for( unsigned int i=0; i<7; i++ ) {
659 if( charge==1 ) {
660 sigma += m_par_sigma[2][inumber][i]*func[i];
661 }
662 else {
663 sigma += m_par_sigma[3][inumber][i]*func[i];
664 }
665 }
666 }
667 }
668 }
669 // barrel outer layer east/west
670 else if( ipmt==2 || ipmt==3 ) {
671 if( ispecies==2 || ispecies==3 ) { // pion / kaon
672 for( unsigned int i=0; i<4; i++ ) {
673 if( i!=3 ) {
674 sigma += m_par_sigma[ispecies-2][inumber][i]*func[i];
675 }
676 else {
677 sigma += m_par_sigma[ispecies-2][inumber][i]*func[9];
678 }
679 }
680 }
681 else if( ispecies==4 ) {
682 if( ibgbin!=-1 ) {
683 if( charge==1 ) {
684 sigma = m_p_sigma[0][inumber][izbin][ibgbin];
685 }
686 else {
687 sigma = m_p_sigma[1][inumber][izbin][ibgbin];
688 }
689 }
690 else {
691 for( unsigned int i=0; i<5; i++ ) {
692 if( charge==1 ) {
693 sigma += m_par_sigma[2][inumber][i]*func[i];
694 }
695 else {
696 sigma += m_par_sigma[3][inumber][i]*func[i];
697 }
698 }
699 }
700 }
701 }
702 // barrel inner layer and outer layer
703 else if( ipmt==4 || ipmt==5 ) {
704 if( ispecies==2 ) { // pion
705 for( unsigned int i=0; i<5; i++ ) {
706 if( i!=4 ) {
707 sigma += m_par_sigma[ispecies-2][inumber][i]*func[i];
708 }
709 else {
710 sigma += m_par_sigma[ispecies-2][inumber][i]*func[9];
711 }
712 }
713 }
714 else if( ispecies==3 ) { // kaon
715 for( unsigned int i=0; i<4; i++ ) {
716 sigma += m_par_sigma[ispecies-2][inumber][i]*func[i];
717 }
718 }
719 else if( ispecies==4 ) {
720 if( ibgbin!=-1 ) {
721 if( charge==1 ) {
722 sigma = m_p_sigma[0][inumber][izbin][ibgbin];
723 }
724 else {
725 sigma = m_p_sigma[1][inumber][izbin][ibgbin];
726 }
727 }
728 else {
729 for( unsigned int i=0; i<9; i++ ) {
730 if( charge==1 ) {
731 sigma += m_par_sigma[2][inumber][i]*func[i];
732 }
733 else {
734 sigma += m_par_sigma[3][inumber][i]*func[i];
735 }
736 }
737 }
738 }
739 }
740 // barrel double layer
741 else if( ipmt==6 ) {
742 if( ispecies==2 || ispecies==3 ) { // pion / kaon
743 for( unsigned int i=0; i<5; i++ ) {
744 sigma += m_par_sigma[ispecies-2][inumber][i]*func[i];
745 }
746 }
747 else if( ispecies==4 ) {
748 if( ibgbin!=-1 ) {
749 if( charge==1 ) {
750 sigma = m_p_sigma[0][inumber][izbin][ibgbin];
751 }
752 else {
753 sigma = m_p_sigma[1][inumber][izbin][ibgbin];
754 }
755 }
756 else {
757 for( unsigned int i=0; i<9; i++ ) {
758 if( charge==1 ) {
759 sigma += m_par_sigma[2][inumber][i]*func[i];
760 }
761 else {
762 sigma += m_par_sigma[3][inumber][i]*func[i];
763 }
764 }
765 }
766 }
767 }
768 }
769 // endcap
770 else {
771 if( ispecies==2 || ispecies==3 ) { // pion / kaon
772 for( unsigned int i=0; i<3; i++ ) {
773 sigma += m_par_sigma[ispecies-2][inumber][i]*func[i];
774 }
775 }
776 else if( ispecies==4 ) {
777 for( unsigned int i=0; i<4; i++ ) {
778 int iparticle=4;
779 if( charge==-1 ) { iparticle=5; }
780 if( i!=3 ) {
781 sigma += m_par_sigma[iparticle-2][inumber][i]*func[i];
782 }
783 else {
784 sigma += m_par_sigma[iparticle-2][inumber][i]*func[9];
785 }
786 }
787 }
788 }
789
790 /*
791 double chi = 1.0;
792 if( barrel ) {
793 if( ( ispecies==3 || ispecies==4 ) && ipmt<4 ) {
794 chi = m_par_sig_mom[ispecies-2][inumber][0];
795 }
796 else {
797 chi = m_par_sig_mom[ispecies-2][inumber][0]*exp(0.0-m_par_sig_mom[ispecies-2][inumber][1]*p)+m_par_sig_mom[ispecies-2][inumber][2];
798 }
799 }
800
801 sigma = sigma*chi;
802 */
803
804 return sigma;
805}

◆ sigmaTof() [2/2]

double TofCorrPID::sigmaTof ( unsigned int ispecies,
int charge,
bool barrel,
unsigned int ipmt,
int tofid[2],
double zrhit[2],
double betaGamma )
protected

Definition at line 550 of file TofCorrPID.cxx.

550 {
551
552 double sigma = 1.0e-6;
553
554 if( ispecies==0 || ispecies==1 ) {
555 if( barrel ) {
556 if( ipmt==0 ) {
557 sigma = bSigma( 0, tofid[0], zrhit[0] );
558 }
559 else if( ipmt==1 ) {
560 sigma = bSigma( 1, tofid[0], zrhit[0] );
561 }
562 else if( ipmt==2 ) {
563 sigma = bSigma( 0, tofid[1], zrhit[1] );
564 }
565 else if( ipmt==3 ) {
566 sigma = bSigma( 1, tofid[1], zrhit[1] );
567 }
568 else if( ipmt==4 ) {
569 sigma = bSigma( 2, tofid[0], zrhit[0] );
570 }
571 else if( ipmt==5 ) {
572 sigma = bSigma( 2, tofid[1], zrhit[1] );
573 }
574 else if( ipmt==6 ) {
575 sigma = bSigma( &tofid[0], &zrhit[0] );
576 }
577 }
578 else {
579 sigma = eSigma( tofid[0], zrhit[0] );
580 }
581 }
582 else {
583 int ibgbin = -1;
584 unsigned int iz = 0;
585 if( ipmt==2 || ipmt==3 || ipmt==5 ) { iz=1; }
586 // low momentum proton and anti-proton
587 if( barrel && ispecies==4 && betaGamma<0.8 ) {
588 double nbgbin = 20.0;
589 double bgbegin[2] = { 0.4, 0.55 };
590 double bgend[2] = { 0.8, 0.8 };
591 double bgstep[2];
592 bgstep[0] = (bgend[0]-bgbegin[0])/nbgbin;
593 bgstep[1] = (bgend[1]-bgbegin[1])/nbgbin;
594
595 ibgbin = static_cast<int>((betaGamma-bgbegin[iz])/bgstep[iz]);
596 if( ibgbin<0 ) { ibgbin=0; }
597 else if( ibgbin>=nbgbin ) { ibgbin=nbgbin-1; }
598 }
599
600 sigma = sigmaTof( ispecies, charge, barrel, ipmt, zrhit[iz], ibgbin );
601 }
602
603 return sigma;
604}
double eSigma(int tofid, double zrhit)

Referenced by particleIDCalculation(), and sigmaTof().


The documentation for this class was generated from the following files: