9#include "GaudiKernel/Bootstrap.h"
10#include "GaudiKernel/ISvcLocator.h"
11#include "GaudiKernel/ISvcLocator.h"
12#include "GaudiKernel/IDataProviderSvc.h"
13#include "GaudiKernel/SmartDataPtr.h"
29 if(IsDedxInfoUsed()) {
34 if(IsTofInfoUsed()|IsTof1InfoUsed()|IsTof2InfoUsed()) {
39 if(IsTofCorrInfoUsed()) {
55 if(IsMrpcInfoUsed()) {
70 for(
int i = 0; i < 4; i++) {
103 cout <<
" please use ParticleID::calculate(run) ! " << endl;
114 IDataProviderSvc* m_eventSvc;
115 Gaudi::svcLocator()->service(
"EventDataSvc", m_eventSvc,
true);
117 SmartDataPtr<Event::EventHeader> eventHeaderpid(m_eventSvc,
"/Event/EventHeader");
118 int runpid=eventHeaderpid->runNumber();
119 int eventpid=eventHeaderpid->eventNumber();
135 if(m_pidcase == 0 ) {
139 if(IsDedxInfoUsed()) {
151 if(IsTofInfoUsed()|IsTof1InfoUsed()|IsTof2InfoUsed()|IsTofCInfoUsed())
175 if(IsTofCorrInfoUsed()) {
178 m_tofcorrpid->
init();
208 if(IsTofQInfoUsed()) {
217 if(IsTofEInfoUsed()&&(!IsTofCorrInfoUsed())) {
226 if(IsEmcInfoUsed()) {
235 if(IsMucInfoUsed()) {
243 if(IsMrpcInfoUsed()) {
269int ParticleID ::particleIDCalculation() {
271 bool valid = IsDedxInfoValid() || IsTofInfoValid()||IsTofEInfoValid()
272 || IsTofQInfoValid() || IsEmcInfoValid() || IsMucInfoValid()
273 || IsTofCInfoValid() || IsTofCorrInfoValid() || IsMrpcInfoValid();
275 if(!valid)
return irc;
279 for(
int i = 0; i < 5; i++) {
284 if((m_pidcase & onlyElectron()) == onlyElectron()) pidcase[0] =
true;
285 if((m_pidcase & onlyMuon()) == onlyMuon()) pidcase[1] =
true;
286 if((m_pidcase & onlyPion()) == onlyPion()) pidcase[2] =
true;
287 if((m_pidcase & onlyKaon()) == onlyKaon()) pidcase[3] =
true;
288 if((m_pidcase & onlyProton()) == onlyProton()) pidcase[4] =
true;
293 if(IsDedxInfoUsed()) {
294 if(IsDedxInfoValid()) {
296 for(
int i = 0; i < 5; i++) {
297 if(pidcase[i] && (fabs(chiDedx(i)) < m_dedxpid->chiMinCut()))
298 if(!okpid) okpid =
true;
302 for(
int i = 0; i < 5; i++) chisq[i] += chiDedx(i)*chiDedx(i);
312 if(IsTofInfoUsed()|IsTof1InfoUsed()|IsTof2InfoUsed() | IsTofCInfoUsed())
313 {
if(IsTofCInfoUsed())
315 if(IsTofCInfoValid()) {
317 for(
int i = 0; i < 5; i++) {
318 if(pidcase[i] && (fabs(chiTofC(i)) < m_tofcpid->chiMinCut()))
319 if(!okpid) okpid =
true;
323 for(
int i = 0; i < 5; i++) chisq[i] += chiTofC(i)*chiTofC(i);
328 if(IsTofInfoValid()) {
330 for(
int i = 0; i < 5; i++) {
331 if(pidcase[i] && (fabs(chiTof(i)) < m_tofpid->chiMinCut()))
332 if(!okpid) okpid =
true;
336 for(
int i = 0; i < 5; i++) chisq[i] += chiTof(i)*chiTof(i);
345 if(IsTofEInfoUsed()) {
346 if(IsTofEInfoValid()) {
348 for(
int i = 0; i < 5; i++) {
349 if(pidcase[i] && (fabs(chiTofE(i)) < m_tofepid->chiMinCut()))
350 if(!okpid) okpid =
true;
354 for(
int i = 0; i < 5; i++) chisq[i] += chiTofE(i)*chiTofE(i);
363 if(IsTofCorrInfoUsed()) {
364 if(IsTofCorrInfoValid()) {
366 for(
int i = 0; i < 5; i++) {
368 if(pidcase[i] && ( chiTofCorr(i) < 6.0 && chiTofCorr(i) > -4.0 ) )
369 if(!okpid) okpid =
true;
373 for(
int i = 0; i < 5; i++) chisq[i] += chiTofCorr(i)*chiTofCorr(i);
382 if(IsTofQInfoUsed()) {
383 if(IsTofQInfoValid()) {
385 for(
int i = 0; i < 5; i++) {
386 if(pidcase[i] && (fabs(chiTofQ(i)) < m_tofqpid->chiMinCut()))
387 if(!okpid) okpid =
true;
391 for(
int i = 0; i < 5; i++) chisq[i] += chiTofQ(i)*chiTofQ(i);
397 if(IsMucInfoUsed()) {
398 if(IsMucInfoValid()) {
400 for(
int i = 0; i < 5; i++) {
401 if(pidcase[i] && (fabs(chiMuc(i)) < m_mucpid->chiMinCut()))
402 if(!okpid) okpid =
true;
406 for(
int i = 0; i < 5; i++) chisq[i] += chiMuc(i)*chiMuc(i);
413 if(IsEmcInfoUsed()) {
414 if(IsEmcInfoValid()) {
416 for(
int i = 0; i < 5; i++) {
417 if(pidcase[i] && (fabs(chiEmc(i)) < m_emcpid->chiMinCut()))
418 if(!okpid) okpid =
true;
422 for(
int i = 0; i < 5; i++) chisq[i] += chiEmc(i)*chiEmc(i);
428 if(IsMrpcInfoUsed()) {
429 if(IsMrpcInfoValid()) {
431 for(
int i = 0; i < 5; i++) {
432 if(pidcase[i] && (fabs(chiMrpc(i)) < m_mrpcpid->chiMinCut()))
433 if(!okpid) okpid =
true;
437 for(
int i = 0; i < 5; i++) chisq[i] += chiMrpc(i)*chiMrpc(i);
443 if(m_ndof <= 0)
return irc;
446 for(
int i = 0; i < 5; i++) {
447 m_chisq[i] = chisq[i];
448 m_prob[i] = probCalculate(chisq[i], m_ndof);
464 if(!valid)
return irc;
467 for(
int i = 0; i < 5; i++) {
478 for(
int i = 0; i < 5; i++) {
486 if(IsDedxInfoUsed()) {
489 for(
int i = 0; i < 5; i++) {
491 if(!okpid) okpid =
true;
495 for(
int i = 0; i < 5; i++) {
506 if(IsTofInfoUsed()|IsTof1InfoUsed()|IsTof2InfoUsed()|IsTofCInfoUsed())
507 {
if(IsTofCInfoUsed())
512 for(
int i = 0; i < 5; i++) {
514 if(!okpid) okpid =
true;
518 for(
int i = 0; i < 5; i++) {
528 for(
int i = 0; i < 5; i++) {
530 if(!okpid) okpid =
true;
534 for(
int i = 0; i < 5; i++) {
546 if(IsTofEInfoUsed()) {
549 for(
int i = 0; i < 5; i++) {
551 if(!okpid) okpid =
true;
564 if(IsTofCorrInfoUsed()) {
567 for(
int i = 0; i < 5; i++) {
569 if(!okpid) okpid =
true;
573 for(
int i = 0; i < 5; i++) {
587 for(
int i = 0; i < 5; i++) {
589 if(!okpid) okpid =
true;
593 for(
int i = 0; i < 5; i++)
pdf[i] *=
pdfTofQ(i);
600 if(IsEmcInfoUsed()) {
603 for(
int i = 0; i < 5; i++) {
604 if(pidcase[i]&&
pdfEmc(i)>0)
605 if(!okpid) okpid =
true;
609 for(
int i = 0; i < 5; i++) {
615 if(IsMucInfoUsed()) {
618 for(
int i = 0; i < 5; i++) {
619 if(pidcase[i]&&
pdfMuc(i)>0)
620 if(!okpid) okpid =
true;
624 for(
int i = 0; i < 5; i++) {
630 if(IsMrpcInfoUsed()) {
633 for(
int i = 0; i < 5; i++) {
635 if(!okpid) okpid =
true;
639 for(
int i = 0; i < 5; i++) {
649 if(m_ndof <= 0)
return irc;
650 for(
int i = 0; i < 5; i++) {
652 m_TotalLikelihood +=
pdf[i];
654 for(
int i = 0; i < 5; i++) {
655 m_likelihoodfraction[i] =
pdf[i]/m_TotalLikelihood;
void setNhitCutDx(const int nhitcuthdx=5)
static DedxPID * instance()
static EmcPID * instance()
static MrpcPID * instance()
static MucPID * instance()
void setPdfMinSigmaCut(const double pdf=4)
EvtRecTrack * PidTrk() const
int methodProbability() const
double pdfCalculate(double offset, double sigma)
void setRunNo(const double runh=8093)
double pdfMinSigmaCut() const
int methodNeuronNetwork() const
void setChiMinCut(const double chi=4)
int methodLikelihood() const
void setRecTrack(EvtRecTrack *trk)
bool IsTofEInfoValid() const
bool IsEmcInfoValid() const
int LikelihoodCalculation()
double chiTofE(int n) const
bool IsTofCorrInfoValid() const
bool IsMrpcInfoValid() const
bool IsTofCInfoValid() const
bool IsTofInfoValid() const
bool IsTofQInfoValid() const
int particleIDCalculation()
static ParticleID * instance()
bool IsDedxInfoValid() const
bool IsMucInfoValid() const
double chiTof(int n) const
double chiTofCorr(int n) const
double chiDedx(int n) const
static TofCPID * instance()
static TofCorrPID * instance()
static TofEPID * instance()
static TofPID * instance()
static TofQPID * instance()