FairRoot/PandaRoot
Public Types | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Static Private Attributes | List of all members
PndMvdAdvancedPidAlgo Class Reference

#include <PndMvdAdvancedPidAlgo.h>

Public Types

enum  { kNPidType = 5 }
 
enum  PidType {
  kElectron =0, kMuon, kPion, kKaon,
  kProton
}
 

Static Public Member Functions

static void CalcLikelihood (PndMvdPidCand *cand)
 
static void CalcLikelihood (PidType particle, double momentum, PndMvdPidCand *cand)
 
static void CalcLikelihood (PidType part, double momentum, double *lh)
 
static void CalcLikelihood (int lundId, double momentum, double *lh)
 
static double GetMomentum ()
 
static double GetEnergyLoss ()
 

Private Member Functions

 PndMvdAdvancedPidAlgo ()
 
virtual ~PndMvdAdvancedPidAlgo ()
 
 ClassDef (PndMvdAdvancedPidAlgo, 1)
 

Static Private Member Functions

static void CalcLikelihood (double *lh)
 
static double MeanEnergyLoss (PidType particle)
 
static double LandauGaus (double s_mpv, double width1, double width2)
 
static double mpv (PidType particle)
 
static double width1 (PidType particle)
 
static double width2 (PidType particle)
 

Static Private Attributes

static double fmomentum
 
static double fenergyloss
 
static TRandom3 * frand =0
 

Detailed Description

Definition at line 11 of file PndMvdAdvancedPidAlgo.h.

Member Enumeration Documentation

anonymous enum
Enumerator
kNPidType 

Definition at line 14 of file PndMvdAdvancedPidAlgo.h.

Constructor & Destructor Documentation

PndMvdAdvancedPidAlgo::PndMvdAdvancedPidAlgo ( )
inlineprivate

Definition at line 41 of file PndMvdAdvancedPidAlgo.h.

41 {};
virtual PndMvdAdvancedPidAlgo::~PndMvdAdvancedPidAlgo ( )
inlineprivatevirtual

Definition at line 42 of file PndMvdAdvancedPidAlgo.h.

42 {};

Member Function Documentation

void PndMvdAdvancedPidAlgo::CalcLikelihood ( PndMvdPidCand cand)
static

Definition at line 12 of file PndMvdAdvancedPidAlgo.cxx.

References dE, and dx.

Referenced by CalcLikelihood(), PndMvdPidIdealTask::Exec(), and for().

12  {
13  //computes pid likelihoods for pi, k, p, mu, e and stores them in the likelihood
14  //map with the map key used as pdg id. This is basically done by integrating the
15  //respective energy loss distribution within the chosen selector limits
16 
17  double weight[kNPidType];
18  double dE=0;
19  double dx=0;
20  fmomentum=0;
21 
22  for (int k=0;k<cand->GetMvdHits(); k++) {
23  dE+=cand->GetMvdHitdE(k);
24  dx+=cand->GetMvdHitdx(k);
25  fmomentum+=cand->GetMvdHitMomentum(k);
26  }
27 
28  if (dx>0) {
29  fmomentum/=cand->GetMvdHits();
30  fenergyloss=dE/dx;
31  } else
32  fmomentum=-1; // whateva
33 
34  CalcLikelihood(weight);
35 
36  cand->SetLikelihood(2212, weight[kProton]);
37  cand->SetLikelihood(211, weight[kPion]);
38  cand->SetLikelihood(321, weight[kKaon]);
39  cand->SetLikelihood(13, weight[kMuon]);
40  cand->SetLikelihood(11, weight[kElectron]);
41 }
static void CalcLikelihood(PndMvdPidCand *cand)
double GetMvdHitdx(int mvdhit) const
double GetMvdHitMomentum(int mvdhit) const
Double_t dE
Definition: anasim.C:58
double dx
double GetMvdHitdE(int mvdhit) const
void SetLikelihood(int lundId, double likelihood)
int GetMvdHits() const
void PndMvdAdvancedPidAlgo::CalcLikelihood ( PidType  particle,
double  momentum,
PndMvdPidCand cand 
)
static

Definition at line 43 of file PndMvdAdvancedPidAlgo.cxx.

References CalcLikelihood(), kElectron, kKaon, kMuon, kNPidType, kPion, kProton, and PndMvdPidCand::SetLikelihood().

43  {
44  double weight[kNPidType];
45  CalcLikelihood(part, momentum, weight);
46  cand->SetLikelihood(2212, weight[kProton]);
47  cand->SetLikelihood(211, weight[kPion]);
48  cand->SetLikelihood(321, weight[kKaon]);
49  cand->SetLikelihood(13, weight[kMuon]);
50  cand->SetLikelihood(11, weight[kElectron]);
51 }
static void CalcLikelihood(PndMvdPidCand *cand)
void SetLikelihood(int lundId, double likelihood)
void PndMvdAdvancedPidAlgo::CalcLikelihood ( PidType  part,
double  momentum,
double *  lh 
)
static

Definition at line 54 of file PndMvdAdvancedPidAlgo.cxx.

References CalcLikelihood(), fenergyloss, fmomentum, frand, MeanEnergyLoss(), mpv(), width1(), and width2().

54  {
55  fmomentum=momentum;
56  //Initialise random generator if not already done
57  if (!frand)
58  frand=new TRandom3();
59  //Build random energy loss
60  fenergyloss = MeanEnergyLoss(part) + mpv(part) + frand->Landau(0, width1(part)) + frand->Gaus(0, width2(part));
61  CalcLikelihood(lh);
62 }
static double MeanEnergyLoss(PidType particle)
static double mpv(PidType particle)
static void CalcLikelihood(PndMvdPidCand *cand)
static double width2(PidType particle)
static double width1(PidType particle)
void PndMvdAdvancedPidAlgo::CalcLikelihood ( int  lundId,
double  momentum,
double *  lh 
)
static

Definition at line 65 of file PndMvdAdvancedPidAlgo.cxx.

References CalcLikelihood(), kElectron, kKaon, kMuon, kPion, and kProton.

65  {
66  switch(lundId) {
67  case 2212: CalcLikelihood(kProton, momentum, lh); break;
68  case 321: CalcLikelihood(kKaon, momentum, lh); break;
69  case 211: CalcLikelihood(kPion, momentum, lh); break;
70  case 13: CalcLikelihood(kMuon, momentum, lh); break;
71  case 11: CalcLikelihood(kElectron, momentum, lh); break;
72  }
73 }
static void CalcLikelihood(PndMvdPidCand *cand)
void PndMvdAdvancedPidAlgo::CalcLikelihood ( double *  lh)
staticprivate

Definition at line 77 of file PndMvdAdvancedPidAlgo.cxx.

References fenergyloss, fmomentum, kElectron, kProton, LandauGaus(), MeanEnergyLoss(), mpv(), width1(), and width2().

77  {
78  if (fmomentum>=0 && fmomentum<=2.5) {
79  for (PidType part=kElectron; part<=kProton;part=(PidType)(part+1))
80  lh[part]=LandauGaus(fenergyloss - MeanEnergyLoss(part) - mpv(part), width1(part), width2(part));
81  } else
82  for (int part=kElectron;part<=kProton;part++)
83  lh[part]=1;
84  double sum=0;
85  for (int part=kElectron;part<=kProton;part++)
86  sum+=lh[part];
87  for (int part=kElectron;part<=kProton;part++)
88  lh[part]/=sum;
89 }
static double MeanEnergyLoss(PidType particle)
static double mpv(PidType particle)
static double width2(PidType particle)
static double LandauGaus(double s_mpv, double width1, double width2)
static double width1(PidType particle)
PndMvdAdvancedPidAlgo::ClassDef ( PndMvdAdvancedPidAlgo  ,
 
)
private
static double PndMvdAdvancedPidAlgo::GetEnergyLoss ( )
inlinestatic

Definition at line 37 of file PndMvdAdvancedPidAlgo.h.

References fenergyloss.

37 {return fenergyloss;};
static double PndMvdAdvancedPidAlgo::GetMomentum ( )
inlinestatic

Definition at line 36 of file PndMvdAdvancedPidAlgo.h.

References fmomentum.

36 {return fmomentum;};
double PndMvdAdvancedPidAlgo::LandauGaus ( double  s_mpv,
double  width1,
double  width2 
)
staticprivate

Definition at line 106 of file PndMvdAdvancedPidAlgo.cxx.

References CAMath::Abs(), c1, c2, f1, f2, h, i, width2(), and x.

Referenced by CalcLikelihood().

106  {
107  // this is the adapted TF1::Integral function from
108  // ROOT 5.14. GOTOs have been removed and interval
109  // division has been modified to maximize performance
110 
111  if (width1<=0)
112  return TMath::Gaus(s_mpv, 0, width2, true);
113  else if (width2<=0)
114  return TMath::Landau(s_mpv, 0, width1, true);
115  else {
116  static double x[12] = { 0.96028985649753623, 0.79666647741362674,
117  0.52553240991632899, 0.18343464249564980,
118  0.98940093499164993, 0.94457502307323258,
119  0.86563120238783174, 0.75540440835500303,
120  0.61787624440264375, 0.45801677765722739,
121  0.28160355077925891, 0.09501250983763744};
122 
123  static double w[12] = { 0.10122853629037626, 0.22238103445337447,
124  0.31370664587788729, 0.36268378337836198,
125  0.02715245941175409, 0.06225352393864789,
126  0.09515851168249278, 0.12462897125553387,
127  0.14959598881657673, 0.16915651939500254,
128  0.18260341504492359, 0.18945061045506850};
129 
130  double h, bb, aa, c1, c2, u, s8, s16, f1, f2;
131  double xx;
132  bool redo=true;
133  int i;
134 
135  h = 0;
136  aa = -5.0*width2;
137  bb = -2.5*width2;
138 
139  do {
140  c1 = 0.5*(bb+aa);
141  c2 = 0.5*(bb-aa);
142 
143  s8 = 0;
144  for (i=0;i<4;i++) {
145  u = c2*x[i];
146  xx = c1+u;
147  f1 = TMath::Landau(s_mpv+xx, 0, width1, true)*TMath::Gaus(xx, 0, width2, true);
148  xx = c1-u;
149  f2 = TMath::Landau(s_mpv+xx, 0, width1, true)*TMath::Gaus(xx, 0, width2, true);
150  s8+= w[i]*(f1 + f2);
151  }
152  s16 = 0;
153  for (i=4;i<12;i++) {
154  u = c2*x[i];
155  xx = c1+u;
156  f1 = TMath::Landau(s_mpv+xx, 0, width1, true)*TMath::Gaus(xx, 0, width2, true);
157  xx = c1-u;
158  f2 = TMath::Landau(s_mpv+xx, 0, width1, true)*TMath::Gaus(xx, 0, width2, true);
159  s16+= w[i]*(f1 + f2);
160  }
161  s16 = c2*s16;
162  if (TMath::Abs(s16-c2*s8) <= 1e-12*(s16+1) ) {
163  aa =bb;
164  bb+=2*c2*1.5;
165  if (bb>=5*width2) {
166  bb=5*width2;
167  redo=false;
168  }
169  h += s16;
170  } else
171  bb = c1;
172  } while (redo);
173  return h;
174  }
175 }
Int_t i
Definition: run_full.C:25
TF1 * f1
Definition: reco_analys2.C:50
c2
Definition: plot_dirc.C:39
static T Abs(const T &x)
Definition: PndCAMath.h:39
c1
Definition: plot_dirc.C:35
static double width2(PidType particle)
Double_t x
TFile * f2
static double width1(PidType particle)
double PndMvdAdvancedPidAlgo::MeanEnergyLoss ( PidType  particle)
staticprivate

Definition at line 92 of file PndMvdAdvancedPidAlgo.cxx.

References c, fmomentum, kElectron, kNPidType, log(), and Mass.

Referenced by CalcLikelihood().

92  {
93  //Calculate the lower boundary of the energy loss distribution.
94 
95  //[GeV]
96  static float eb=0.14e-6;
97  //[m/s]
98  static float c=2.99792458e8;
99  //[GeV/c**2]
100  static float Mass[kNPidType]={ 0.511e-3, 0.1058, 0.1396, 0.4937, 0.9383 };
101 
102  double sqrBeta=1/(1+pow(Mass[part]/fmomentum,2));
103  return 4.9312e-05 * (log(2*Mass[kElectron]*c*c/eb*sqrBeta/(1-sqrBeta))-sqrBeta)/sqrBeta;
104 };
friend F32vec4 log(const F32vec4 &a)
Definition: P4_F32vec4.h:110
double PndMvdAdvancedPidAlgo::mpv ( PidType  particle)
staticprivate

Definition at line 177 of file PndMvdAdvancedPidAlgo.cxx.

References c1, fmomentum, kElectron, kKaon, kMuon, kPion, kProton, x, and x0.

Referenced by CalcLikelihood().

177  {
178  double x=fmomentum;
179  double x0=0;
180  double x1=0;
181  double c0=0;
182  double c1=0;
183  double d1=0;
184  double a3=0;
185  double a4=0;
186  double a5=0;
187 
188  switch(part) {
189  case kProton:
190  x0 = 0.45;
191  x1 = 1.3;
192  c0 = 0.383451e-03;
193  c1 = -0.126986e-03;
194  d1 = -5.21351e-06;
195  a3 = -3.05821;
196  a4 = 24.6356;
197  a5 = -68.632;
198  break;
199  case kKaon:
200  x0 = 0.25;
201  x1 = 1.05;
202  c0 = 0.326259e-03;
203  c1 = -7.68052e-05;
204  d1 = 1.51033e-05;
205  a3 = -19.6615;
206  a4 = 264.382;
207  a5 = -1238.09;
208  break;
209  case kPion:
210  x0 = 0.1;
211  x1 = 1.0;
212  c0 = 0.274692e-03;
213  c1 = 3.2571e-05;
214  d1 = 9.16527e-06;
215  a5 = -6624.05;
216  break;
217  case kMuon:
218  x0 = 0.15;
219  x1 = 1.15;
220  a3 = 4.33244;
221  a4 = -107.686;
222  a5 = 699.522;
223  c0 = 0.248749e-03;
224  c1 = 6.57118e-05;
225  d1 = -4.09447e-06;
226  break;
227  case kElectron:
228  x1 = 1.20;
229  c0 = 2.93999e-03;
230  c1 = 1.76792e-05;
231  break;
232  }
233  if (x>=x1)
234  return c0+c1*(x1-x0)+d1*(x-x1);
235  if (x>=x0)
236  return c0+c1*(x-x0);
237  else
238  return c0+c1*(x-x0)+pow(x0-x,3)*(a3+(x0-x)*(a4+(x0-x)*a5));
239 }
Double_t x0
Definition: checkhelixhit.C:70
c1
Definition: plot_dirc.C:35
Double_t x
double PndMvdAdvancedPidAlgo::width1 ( PidType  particle)
staticprivate

Definition at line 241 of file PndMvdAdvancedPidAlgo.cxx.

References fmomentum, kElectron, kKaon, kMuon, kPion, kProton, and x.

Referenced by CalcLikelihood().

241  {
242  double x=fmomentum;
243  switch(part) {
244  case kProton:
245  if (x>=1.10)
246  return +3.81174e-04+x*(-2.25108e-04+x*+5.45154e-05);
247  else
248  return -5.28145e-05+x*(+8.29883e-04+x*-5.35972e-04);
249  break;
250  case kKaon:
251  if (x>=1.05)
252  return +2.61134e-04+x*(-1.30818e-04+x*+3.44165e-05);
253  else
254  return +3.41858e-04+x*(-3.21115e-04+x*+1.37459e-04);
255  break;
256  case kPion:
257  if (x>=1.00)
258  return +1.88718e-04+x*(-6.38948e-05+x*+1.78590e-05);
259  else
260  return +1.82872e-04+x*(-1.28373e-04+x*+8.01459e-05);
261  break;
262  case kMuon:
263  if (x>=1.20)
264  return +1.06142e-04+x*(+3.68777e-05+x*-1.00190e-05);
265  else
266  return +1.89374e-04+x*(-1.46441e-04+x*+9.10813e-05);
267  break;
268  case kElectron:
269  if (x>1.2) x=1.2;
270  // electrons are constant for momentum > 1.2GeV
271  return +1.27955e-04+x*(-3.15732e-06+x*+9.64736e-06);
272  break;
273  }
274  //TODO: what to return?
275  return -999.;
276 }
Double_t x
double PndMvdAdvancedPidAlgo::width2 ( PidType  particle)
staticprivate

Definition at line 278 of file PndMvdAdvancedPidAlgo.cxx.

References fmomentum, kElectron, kKaon, kMuon, kPion, kProton, and x.

Referenced by CalcLikelihood(), and LandauGaus().

278  {
279  double x=fmomentum;
280  switch(part) {
281  case kProton:
282  if (x>=1.10)
283  return +6.41067e-04+x*(-3.82507e-04+x*+9.03732e-05);
284  else
285  return +6.40328e-04-3.21725e-04*x+3.17708e-05*pow(x,-3);
286  break;
287  case kKaon:
288  if (x>=1.05)
289  return +2.22504e-04+x*(-6.40051e-06+x*+2.14434e-06);
290  else
291  return +3.86684e-04-1.61873e-04*x+7.76586e-06*pow(x,-3);
292  break;
293  case kPion:
294  if (x>=1.00)
295  return +1.32999e-04+x*(+1.19714e-04+x*-3.53302e-05);
296  else
297  return +2.21603e-04-3.21357e-06*x+4.64793e-06*pow(x,-2);
298  break;
299  case kMuon:
300  if (x>=1.20)
301  return +7.84582e-05+x*(+1.88988e-04+x*-5.49637e-05);
302  else
303  return +1.67388e-04+5.67991e-05*x+3.42702e-06*pow(x,-2);
304  break;
305  case kElectron:
306  if (x>1.2) x=1.2;
307  // electrons are constant for momentum > 1.2GeV
308  return +4.08849e-04-3.56548e-05*x+1.84825e-08*pow(x,-3);
309  break;
310  }
311  //TODO: what to return?
312  return -999.;
313 }
Double_t x

Member Data Documentation

double PndMvdAdvancedPidAlgo::fenergyloss
staticprivate

Definition at line 57 of file PndMvdAdvancedPidAlgo.h.

Referenced by CalcLikelihood(), and GetEnergyLoss().

double PndMvdAdvancedPidAlgo::fmomentum
staticprivate

Definition at line 56 of file PndMvdAdvancedPidAlgo.h.

Referenced by CalcLikelihood(), GetMomentum(), MeanEnergyLoss(), mpv(), width1(), and width2().

TRandom3 * PndMvdAdvancedPidAlgo::frand =0
staticprivate

Definition at line 65 of file PndMvdAdvancedPidAlgo.h.

Referenced by CalcLikelihood().


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