BOSS 6.6.4.p01
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 ()
 
virtual void init ()=0
 
virtual void calculate ()=0
 
virtual bool IsPidInfoValid () const =0
 
virtual double chi (int n) const =0
 
virtual double prob (int n) const =0
 
virtual int ndof () const =0
 
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 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
 
void set_path (const char *s_path=0)
 

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 ()
 
virtual int particleIDCalculation ()=0
 
virtual int LikelihoodCalculation ()=0
 

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 837 of file TofCorrPID.cxx.

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

◆ bSigma() [2/2]

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

Definition at line 819 of file TofCorrPID.cxx.

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

Referenced by bSigma(), 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()
Definition: TofCorrPID.cxx:61

◆ 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 865 of file TofCorrPID.cxx.

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

Referenced by particleIDCalculation().

◆ eSigma()

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

Definition at line 849 of file TofCorrPID.cxx.

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

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)
Definition: EvtComplex.hh:212
double getRunNo() const
void inputParameter(int run)
Definition: TofCorrPID.cxx:212

◆ inputParameter()

void TofCorrPID::inputParameter ( int  run)
protected

Definition at line 212 of file TofCorrPID.cxx.

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

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 405 of file TofCorrPID.cxx.

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

Referenced by particleIDCalculation().

◆ offsetTof() [2/3]

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

Definition at line 487 of file TofCorrPID.cxx.

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

◆ offsetTof() [3/3]

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

Definition at line 520 of file TofCorrPID.cxx.

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

◆ 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 HepLorentzVector ptrk = kalTrk->p4();
100 p[i] = ptrk.rho();
101 betaGamma[i] = p[i]/xmass(i);
102 }
103
104 double zrhit[2];
105 RecExtTrack* extTrk = recTrk->extTrack();
106 zrhit[0] = extTrk->tof1Position().z();
107 zrhit[1] = extTrk->tof2Position().z();
108
109 int tofid[2] = { -9, -9 };
110
111 bool readFile = false;
112 bool signal[2] = { false, false };
113 TofHitStatus *hitst = new TofHitStatus;
114 for( it = tofTrk.begin(); it!=tofTrk.end(); it++ ) {
115 unsigned int st = (*it)->status();
116 hitst->setStatus(st);
117 if( hitst->is_raw() ) return irc; // TOF no hit
118 bool barrel = hitst->is_barrel();
119 if( !barrel ) { zrhit[0] = extTrk->tof1Position().rho(); }
120 bool readout = hitst->is_readout();
121 bool counter = hitst->is_counter();
122 bool cluster = hitst->is_cluster();
123 int layer = hitst->layer();
124 tofid[layer-1] = (*it)->tofID();
125 bool east = hitst->is_east();
126 double tof = (*it)->tof();
127 if( readout ) {
128 // default 0: end cap
129 unsigned int ipmt = 0;
130 // barrel: 0: inner east, 1:inner west, 2:outer east, 3: outer west
131 // endcap: 0
132 if( barrel ) { ipmt = ( ( st & 0xC0 ) >> 5 ) + ( ( ( st ^ 0x20 ) & 0x20 ) >> 5 ) - 2; }
133 for( unsigned int i=0; i<5; i++ ) {
134 double offset = (*it)->toffset(i);
135 double texp = (*it)->texp(i);
136 if( texp<0.0 ) continue;
137 double dt = tof - offset - texp;
138 m_deltaT[ipmt][i] = offsetTof( i, barrel, ipmt, betaGamma[i], charge, zrhit[layer-1], dt );
139 }
140 if( counter && cluster ) {
141 for( unsigned int i=0; i<5; i++ ) {
142 if( ((*it)->texp(i))>0.0 ) {
143 m_offset[i] = m_deltaT[ipmt][i];
144 m_sigma[i] = sigmaTof( i, charge, barrel, ipmt, &tofid[0], &zrhit[0], betaGamma[i] );
145 }
146 }
147 }
148 }
149 else {
150 if( counter ) {
151 for( unsigned int i=0; i<5; i++ ) {
152 double offset = (*it)->toffset(i);
153 double texp = (*it)->texp(i);
154 if( texp<0.0 ) continue;
155 double dt = tof - offset - texp;
156 m_deltaT[layer+3][i] = offsetTof( i, tofid[layer-1], zrhit[layer-1], dt );
157 m_offset[i] = m_deltaT[layer+3][i];
158 m_sigma[i] = sigmaTof( i, charge, barrel, layer+3, &tofid[0], &zrhit[0], betaGamma[i] );
159 }
160 signal[layer-1] = correlationCheck();
161 }
162 else {
163 if( cluster ) {
164 if( signal[0] && signal[1] ) {
165 for( unsigned int i=0; i<5; i++ ) {
166 double offset = (*it)->toffset(i);
167 double texp = (*it)->texp(i);
168 if( texp<0.0 ) continue;
169 double dt = tof - offset - texp;
170 m_deltaT[6][i] = offsetTof( i, tofid[0], tofid[1], zrhit[0], zrhit[1], dt );
171 m_offset[i] = m_deltaT[6][i];
172 m_sigma[i] = sigmaTof( i, charge, barrel, 6, &tofid[0], &zrhit[0], betaGamma[i] );
173 }
174 }
175 else if( signal[0] && !signal[1] ) {
176 for( unsigned int i=0; i<5; i++ ) {
177 m_offset[i] = m_deltaT[4][i];
178 m_sigma[i] = sigmaTof( i, charge, barrel, 4, &tofid[0], &zrhit[0], betaGamma[i] );
179 }
180 }
181 else if( !signal[0] && signal[1] ) {
182 for( unsigned int i=0; i<5; i++ ) {
183 m_offset[i] = m_deltaT[5][i];
184 m_sigma[i] = sigmaTof( i, charge, barrel, 5, &tofid[1], &zrhit[1], betaGamma[i] );
185 }
186 }
187 else return irc;
188 }
189 }
190 }
191 }
192
193 bool good = false;
194 double pdftemp = 0;
195 for( unsigned int i=0; i<5; i++ ) {
196 m_chi[i] = m_offset[i]/m_sigma[i];
197 if( ( m_chi[i]>-4.0 && m_chi[i]<6.0 ) && !good ) { good = true; }
198 double ppp = pdfCalculate(m_chi[i],1);
199 if( fabs(ppp) > pdftemp) { pdftemp = fabs(ppp); }
200 }
201 m_pdfmin = pdftemp;
202 if( pdftemp < pdfCalculate(pdfMinSigmaCut(),1) ) return irc;
203 if( !good ) return irc;
204 for(int i = 0; i < 5; i++) {
205 m_prob[i] = probCalculate(m_chi[i]*m_chi[i], 1);
206 }
207 irc = 0;
208 return irc;
209}
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:49
RecExtTrack * extTrack()
Definition: EvtRecTrack.h:56
bool isMdcKalTrackValid()
Definition: EvtRecTrack.h:44
SmartRefVector< RecTofTrack > tofTrack()
Definition: EvtRecTrack.h:57
bool isTofTrackValid()
Definition: EvtRecTrack.h:46
bool isMdcTrackValid()
Definition: EvtRecTrack.h:43
RecMdcTrack * mdcTrack()
Definition: EvtRecTrack.h:53
RecMdcKalTrack * mdcKalTrack()
Definition: EvtRecTrack.h:54
EvtRecTrack * PidTrk() const
double probCalculate(double chi2, int n)
bool correlationCheck()
Definition: TofCorrPID.cxx:865
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)
Definition: TofCorrPID.cxx:546
double offsetTof(unsigned int ispecies, bool barrel, unsigned int ipmt, double betaGamma, int charge, double zrhit, double dt)
Definition: TofCorrPID.cxx:405
bool is_barrel() const
Definition: TofHitStatus.h:26
unsigned int layer() const
Definition: TofHitStatus.h:28
bool is_cluster() const
Definition: TofHitStatus.h:25
void setStatus(unsigned int status)
bool is_counter() const
Definition: TofHitStatus.h:24
bool is_east() const
Definition: TofHitStatus.h:27
bool is_readout() const
Definition: TofHitStatus.h:23
bool is_raw() const
Definition: TofHitStatus.h:22

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 804 of file TofCorrPID.cxx.

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

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(), eSigma(), offsetTof(), ParticleID::sigma(), 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 603 of file TofCorrPID.cxx.

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

◆ 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 546 of file TofCorrPID.cxx.

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

Referenced by particleIDCalculation(), and sigmaTof().


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