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()) {
63 for(
int i = 0; i < 4; i++) {
96 cout <<
" please use ParticleID::calculate(run) ! " << endl;
107 IDataProviderSvc* m_eventSvc;
108 Gaudi::svcLocator()->service(
"EventDataSvc", m_eventSvc,
true);
110 SmartDataPtr<Event::EventHeader> eventHeaderpid(m_eventSvc,
"/Event/EventHeader");
111 int runpid=eventHeaderpid->runNumber();
112 int eventpid=eventHeaderpid->eventNumber();
128 if(m_pidcase == 0 ) {
132 if(IsDedxInfoUsed()) {
144 if(IsTofInfoUsed()|IsTof1InfoUsed()|IsTof2InfoUsed()|IsTofCInfoUsed())
168 if(IsTofCorrInfoUsed()) {
171 m_tofcorrpid->
init();
201 if(IsTofQInfoUsed()) {
210 if(IsTofEInfoUsed()&&(!IsTofCorrInfoUsed())) {
219 if(IsEmcInfoUsed()) {
228 if(IsMucInfoUsed()) {
250int ParticleID ::particleIDCalculation() {
252 bool valid = IsDedxInfoValid() || IsTofInfoValid()||IsTofEInfoValid()
253 || IsTofQInfoValid() || IsEmcInfoValid() || IsMucInfoValid()
254 || IsTofCInfoValid() || IsTofCorrInfoValid();
256 if(!valid)
return irc;
260 for(
int i = 0; i < 5; i++) {
265 if((m_pidcase & onlyElectron()) == onlyElectron()) pidcase[0] =
true;
266 if((m_pidcase & onlyMuon()) == onlyMuon()) pidcase[1] =
true;
267 if((m_pidcase & onlyPion()) == onlyPion()) pidcase[2] =
true;
268 if((m_pidcase & onlyKaon()) == onlyKaon()) pidcase[3] =
true;
269 if((m_pidcase & onlyProton()) == onlyProton()) pidcase[4] =
true;
274 if(IsDedxInfoUsed()) {
275 if(IsDedxInfoValid()) {
277 for(
int i = 0; i < 5; i++) {
278 if(pidcase[i] && (fabs(chiDedx(i)) < m_dedxpid->chiMinCut()))
279 if(!okpid) okpid =
true;
283 for(
int i = 0; i < 5; i++) chisq[i] += chiDedx(i)*chiDedx(i);
293 if(IsTofInfoUsed()|IsTof1InfoUsed()|IsTof2InfoUsed() | IsTofCInfoUsed())
294 {
if(IsTofCInfoUsed())
296 if(IsTofCInfoValid()) {
298 for(
int i = 0; i < 5; i++) {
299 if(pidcase[i] && (fabs(chiTofC(i)) < m_tofcpid->chiMinCut()))
300 if(!okpid) okpid =
true;
304 for(
int i = 0; i < 5; i++) chisq[i] += chiTofC(i)*chiTofC(i);
309 if(IsTofInfoValid()) {
311 for(
int i = 0; i < 5; i++) {
312 if(pidcase[i] && (fabs(chiTof(i)) < m_tofpid->chiMinCut()))
313 if(!okpid) okpid =
true;
317 for(
int i = 0; i < 5; i++) chisq[i] += chiTof(i)*chiTof(i);
326 if(IsTofEInfoUsed()) {
327 if(IsTofEInfoValid()) {
329 for(
int i = 0; i < 5; i++) {
330 if(pidcase[i] && (fabs(chiTofE(i)) < m_tofepid->chiMinCut()))
331 if(!okpid) okpid =
true;
335 for(
int i = 0; i < 5; i++) chisq[i] += chiTofE(i)*chiTofE(i);
344 if(IsTofCorrInfoUsed()) {
345 if(IsTofCorrInfoValid()) {
347 for(
int i = 0; i < 5; i++) {
349 if(pidcase[i] && ( chiTofCorr(i) < 6.0 && chiTofCorr(i) > -4.0 ) )
350 if(!okpid) okpid =
true;
354 for(
int i = 0; i < 5; i++) chisq[i] += chiTofCorr(i)*chiTofCorr(i);
363 if(IsTofQInfoUsed()) {
364 if(IsTofQInfoValid()) {
366 for(
int i = 0; i < 5; i++) {
367 if(pidcase[i] && (fabs(chiTofQ(i)) < m_tofqpid->chiMinCut()))
368 if(!okpid) okpid =
true;
372 for(
int i = 0; i < 5; i++) chisq[i] += chiTofQ(i)*chiTofQ(i);
378 if(IsMucInfoUsed()) {
379 if(IsMucInfoValid()) {
381 for(
int i = 0; i < 5; i++) {
382 if(pidcase[i] && (fabs(chiMuc(i)) < m_mucpid->chiMinCut()))
383 if(!okpid) okpid =
true;
387 for(
int i = 0; i < 5; i++) chisq[i] += chiMuc(i)*chiMuc(i);
394 if(IsEmcInfoUsed()) {
395 if(IsEmcInfoValid()) {
397 for(
int i = 0; i < 5; i++) {
398 if(pidcase[i] && (fabs(chiEmc(i)) < m_emcpid->chiMinCut()))
399 if(!okpid) okpid =
true;
403 for(
int i = 0; i < 5; i++) chisq[i] += chiEmc(i)*chiEmc(i);
409 if(m_ndof <= 0)
return irc;
412 for(
int i = 0; i < 5; i++) {
413 m_chisq[i] = chisq[i];
414 m_prob[i] = probCalculate(chisq[i], m_ndof);
430 if(!valid)
return irc;
433 for(
int i = 0; i < 5; i++) {
444 for(
int i = 0; i < 5; i++) {
452 if(IsDedxInfoUsed()) {
455 for(
int i = 0; i < 5; i++) {
457 if(!okpid) okpid =
true;
461 for(
int i = 0; i < 5; i++) {
472 if(IsTofInfoUsed()|IsTof1InfoUsed()|IsTof2InfoUsed()|IsTofCInfoUsed())
473 {
if(IsTofCInfoUsed())
478 for(
int i = 0; i < 5; i++) {
480 if(!okpid) okpid =
true;
484 for(
int i = 0; i < 5; i++) {
494 for(
int i = 0; i < 5; i++) {
496 if(!okpid) okpid =
true;
500 for(
int i = 0; i < 5; i++) {
512 if(IsTofEInfoUsed()) {
515 for(
int i = 0; i < 5; i++) {
517 if(!okpid) okpid =
true;
530 if(IsTofCorrInfoUsed()) {
533 for(
int i = 0; i < 5; i++) {
535 if(!okpid) okpid =
true;
539 for(
int i = 0; i < 5; i++) {
553 for(
int i = 0; i < 5; i++) {
555 if(!okpid) okpid =
true;
559 for(
int i = 0; i < 5; i++)
pdf[i] *=
pdfTofQ(i);
566 if(IsEmcInfoUsed()) {
569 for(
int i = 0; i < 5; i++) {
570 if(pidcase[i]&&
pdfEmc(i)>0)
571 if(!okpid) okpid =
true;
575 for(
int i = 0; i < 5; i++) {
581 if(IsMucInfoUsed()) {
584 for(
int i = 0; i < 5; i++) {
585 if(pidcase[i]&&
pdfMuc(i)>0)
586 if(!okpid) okpid =
true;
590 for(
int i = 0; i < 5; i++) {
599 if(m_ndof <= 0)
return irc;
600 for(
int i = 0; i < 5; i++) {
602 m_TotalLikelihood +=
pdf[i];
604 for(
int i = 0; i < 5; i++) {
605 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 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()