30 #include "StProbPidTraits.h"
31 #include "StParticleTypes.hh"
35 static const
char rcsid[] = "$Id:
StProbPidTraits.cxx,v 2.5 2004/07/21 14:09:57 fisyak Exp $";
37 StElectron::instance(),
39 StKaonMinus::instance(),
40 StPionMinus::instance(),
41 StMuonMinus::instance(),
42 StDeuteron::instance(),
49 StProbPidTraits::StProbPidTraits(
const Int_t NDF,
const StDetectorId Id,
const StPidParticle N,
50 const Float_t *PidArray, Double_t *Fractions) :
52 if (PidArray) mPidArray =
new TArrayF(N,PidArray);
53 else mPidArray =
new TArrayF(N);
57 StProbPidTraits::~StProbPidTraits() {
delete mPidArray;}
60 Double_t StProbPidTraits::GetProbability(Int_t PartId) {
61 if (mSum > 0)
return mProbability[PartId];
62 Int_t N = mPidArray->GetSize();
64 memset(&mProbability[0],0,KPidParticles*
sizeof(Double_t));
65 const Float_t *Array = mPidArray->GetArray();
67 for (i=kPidElectron; i< N; i++) {
69 mProbability[i] = TMath::Exp(-Array[i]/2.)*mFractions[i];
71 mProbability[i] = TMath::Exp(-Array[i]/2.);
72 mSum += mProbability[i];
74 if (mSum > 0)
for (i=kPidElectron; i< N; i++) mProbability[i] /= mSum;
75 return mSum > 0 ? mProbability[PartId] : 0;
78 Double_t StProbPidTraits::GetChi2Prob(Int_t k)
const {
79 if (mNDF < 1 || ! mPidArray )
return -1;
80 Int_t N = mPidArray->GetSize();
81 if (k >= N)
return -1;
82 const Float_t *Array = mPidArray->GetArray();
83 return TMath::Prob(Array[k],mNDF);
86 void StProbPidTraits::Print(Option_t *opt)
const {
88 Int_t N = mPidArray->GetSize();
89 const Float_t *Array = mPidArray->GetArray();
91 cout <<
"\tNDF = \t" << mNDF << endl;
92 for (i = kPidElectron; i < N; i++) {
93 cout <<
"Particle : \t" << mPidParticleDefinitions[i]->name();
94 if (mFractions) cout <<
"\tFraction : \t" << mFractions[i];
95 cout <<
"\tProbability :\t" << This->GetProbability(i)
96 <<
"\tChisq :\t" << Array[i];
97 if (mNDF > 0) cout <<
"\t Chisq Prob:\t" << GetChi2Prob(i);