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()) {
66 for(
int i = 0; i < 5; i++) {
99 cout <<
" please use ParticleID::calculate(run) ! " << endl;
110 IDataProviderSvc* m_eventSvc;
111 Gaudi::svcLocator()->service(
"EventDataSvc", m_eventSvc,
true);
113 SmartDataPtr<Event::EventHeader> eventHeaderpid(m_eventSvc,
"/Event/EventHeader");
114 int runpid=eventHeaderpid->runNumber();
115 int eventpid=eventHeaderpid->eventNumber();
131 if(m_pidcase == 0 ) {
135 if(IsDedxInfoUsed()) {
147 if(IsTofInfoUsed()|IsTof1InfoUsed()|IsTof2InfoUsed()|IsTofCInfoUsed())
173 if(IsTofCorrInfoUsed()) {
176 m_tofcorrpid->
init();
207 if(IsTofQInfoUsed()) {
216 if(IsTofEInfoUsed()&&(!IsTofCorrInfoUsed())) {
225 if(IsEmcInfoUsed()) {
234 if(IsMucInfoUsed()) {
256int ParticleID ::particleIDCalculation() {
258 bool valid = IsDedxInfoValid() || IsTofInfoValid()||IsTofEInfoValid()
259 || IsTofQInfoValid() || IsEmcInfoValid() || IsMucInfoValid()
260 || IsTofCInfoValid() || IsTofCorrInfoValid();
262 if(!valid)
return irc;
266 for(
int i = 0; i < 5; i++) {
271 if((m_pidcase & onlyElectron()) == onlyElectron()) pidcase[0] =
true;
272 if((m_pidcase & onlyMuon()) == onlyMuon()) pidcase[1] =
true;
273 if((m_pidcase & onlyPion()) == onlyPion()) pidcase[2] =
true;
274 if((m_pidcase & onlyKaon()) == onlyKaon()) pidcase[3] =
true;
275 if((m_pidcase & onlyProton()) == onlyProton()) pidcase[4] =
true;
280 if(IsDedxInfoUsed()) {
281 if(IsDedxInfoValid()) {
283 for(
int i = 0; i < 5; i++) {
284 if(pidcase[i] && (fabs(chiDedx(i)) < m_dedxpid->chiMinCut()))
285 if(!okpid) okpid =
true;
289 for(
int i = 0; i < 5; i++) chisq[i] += chiDedx(i)*chiDedx(i);
299 if(IsTofInfoUsed()|IsTof1InfoUsed()|IsTof2InfoUsed() | IsTofCInfoUsed())
300 {
if(IsTofCInfoUsed())
302 if(IsTofCInfoValid()) {
304 for(
int i = 0; i < 5; i++) {
305 if(pidcase[i] && (fabs(chiTofC(i)) < m_tofcpid->chiMinCut()))
306 if(!okpid) okpid =
true;
310 for(
int i = 0; i < 5; i++) chisq[i] += chiTofC(i)*chiTofC(i);
315 if(IsTofInfoValid()) {
317 for(
int i = 0; i < 5; i++) {
318 if(pidcase[i] && (fabs(chiTof(i)) < m_tofpid->chiMinCut()))
319 if(!okpid) okpid =
true;
323 for(
int i = 0; i < 5; i++) chisq[i] += chiTof(i)*chiTof(i);
332 if(IsTofEInfoUsed()) {
333 if(IsTofEInfoValid()) {
335 for(
int i = 0; i < 5; i++) {
336 if(pidcase[i] && (fabs(chiTofE(i)) < m_tofepid->chiMinCut()))
337 if(!okpid) okpid =
true;
341 for(
int i = 0; i < 5; i++) chisq[i] += chiTofE(i)*chiTofE(i);
350 if(IsTofCorrInfoUsed()) {
351 if(IsTofCorrInfoValid()) {
353 for(
int i = 0; i < 5; i++) {
354 if(pidcase[i] && ( chiTofCorr(i) < m_tofcorrpid->chiMaxCut() ) && ( chiTofCorr(i) > ( 0.0 - m_tofcorrpid->chiMinCut() ) ) )
356 if(!okpid) okpid =
true;
360 for(
int i = 0; i < 5; i++) chisq[i] += chiTofCorr(i)*chiTofCorr(i);
369 if(IsTofQInfoUsed()) {
370 if(IsTofQInfoValid()) {
372 for(
int i = 0; i < 5; i++) {
373 if(pidcase[i] && (fabs(chiTofQ(i)) < m_tofqpid->chiMinCut()))
374 if(!okpid) okpid =
true;
378 for(
int i = 0; i < 5; i++) chisq[i] += chiTofQ(i)*chiTofQ(i);
384 if(IsMucInfoUsed()) {
385 if(IsMucInfoValid()) {
387 for(
int i = 0; i < 5; i++) {
388 if(pidcase[i] && (fabs(chiMuc(i)) < m_mucpid->chiMinCut()))
389 if(!okpid) okpid =
true;
393 for(
int i = 0; i < 5; i++) chisq[i] += chiMuc(i)*chiMuc(i);
400 if(IsEmcInfoUsed()) {
401 if(IsEmcInfoValid()) {
403 for(
int i = 0; i < 5; i++) {
404 if(pidcase[i] && (fabs(chiEmc(i)) < m_emcpid->chiMinCut()))
405 if(!okpid) okpid =
true;
409 for(
int i = 0; i < 5; i++) chisq[i] += chiEmc(i)*chiEmc(i);
415 if(m_ndof <= 0)
return irc;
418 for(
int i = 0; i < 5; i++) {
419 m_chisq[i] = chisq[i];
420 m_prob[i] = probCalculate(chisq[i], m_ndof);
436 if(!valid)
return irc;
439 for(
int i = 0; i < 5; i++) {
450 for(
int i = 0; i < 5; i++) {
458 if(IsDedxInfoUsed()) {
461 for(
int i = 0; i < 5; i++) {
463 if(!okpid) okpid =
true;
467 for(
int i = 0; i < 5; i++) {
478 if(IsTofInfoUsed()|IsTof1InfoUsed()|IsTof2InfoUsed()|IsTofCInfoUsed())
479 {
if(IsTofCInfoUsed())
484 for(
int i = 0; i < 5; i++) {
486 if(!okpid) okpid =
true;
490 for(
int i = 0; i < 5; i++) {
500 for(
int i = 0; i < 5; i++) {
502 if(!okpid) okpid =
true;
506 for(
int i = 0; i < 5; i++) {
518 if(IsTofEInfoUsed()) {
521 for(
int i = 0; i < 5; i++) {
523 if(!okpid) okpid =
true;
536 if(IsTofCorrInfoUsed()) {
539 for(
int i = 0; i < 5; i++) {
541 if(!okpid) okpid =
true;
545 for(
int i = 0; i < 5; i++) {
559 for(
int i = 0; i < 5; i++) {
561 if(!okpid) okpid =
true;
565 for(
int i = 0; i < 5; i++)
pdf[i] *=
pdfTofQ(i);
572 if(IsEmcInfoUsed()) {
575 for(
int i = 0; i < 5; i++) {
576 if(pidcase[i]&&
pdfEmc(i)>0)
577 if(!okpid) okpid =
true;
581 for(
int i = 0; i < 5; i++) {
587 if(IsMucInfoUsed()) {
590 for(
int i = 0; i < 5; i++) {
591 if(pidcase[i]&&
pdfMuc(i)>0)
592 if(!okpid) okpid =
true;
596 for(
int i = 0; i < 5; i++) {
605 if(m_ndof <= 0)
return irc;
606 for(
int i = 0; i < 5; i++) {
608 m_TotalLikelihood +=
pdf[i];
610 for(
int i = 0; i < 5; i++) {
611 m_likelihoodfraction[i] =
pdf[i]/m_TotalLikelihood;
void setNhitCutDx(const int nhitcuthdx=5)
static DedxPID * instance()
static EmcPID * 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 setChiMaxCut(const double chi=6)
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 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()