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

#include <PndHypAdvancedPidAlgo.h>

Public Types

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

Static Public Member Functions

static void CalcLikelihood (PndHypPidCand *cand)
 
static void CalcLikelihood (PidType particle, double momentum, PndHypPidCand *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

 PndHypAdvancedPidAlgo ()
 
virtual ~PndHypAdvancedPidAlgo ()
 
 ClassDef (PndHypAdvancedPidAlgo, 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 PndHypAdvancedPidAlgo.h.

Member Enumeration Documentation

anonymous enum
Enumerator
kNPidType 

Definition at line 16 of file PndHypAdvancedPidAlgo.h.

Constructor & Destructor Documentation

PndHypAdvancedPidAlgo::PndHypAdvancedPidAlgo ( )
inlineprivate

Definition at line 43 of file PndHypAdvancedPidAlgo.h.

43 {};
virtual PndHypAdvancedPidAlgo::~PndHypAdvancedPidAlgo ( )
inlineprivatevirtual

Definition at line 44 of file PndHypAdvancedPidAlgo.h.

44 {};

Member Function Documentation

static void PndHypAdvancedPidAlgo::CalcLikelihood ( PndHypPidCand cand)
static
void PndHypAdvancedPidAlgo::CalcLikelihood ( PidType  particle,
double  momentum,
PndHypPidCand cand 
)
static

Definition at line 44 of file PndHypAdvancedPidAlgo.cxx.

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

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

Definition at line 55 of file PndHypAdvancedPidAlgo.cxx.

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

55  {
56  fmomentum=momentum;
57  //Initialise random generator if not already done
58  if (!frand)
59  frand=new TRandom3();
60  //Build random energy loss
61  fenergyloss = MeanEnergyLoss(part) + mpv(part) + frand->Landau(0, width1(part)) + frand->Gaus(0, width2(part));
62  std::cout<<" energy loss "<<fenergyloss<<" part "<<part<<std::endl;
63  std::cout<<" mean energy loss "<<MeanEnergyLoss(part)<<" mpv "<< mpv(part)<<std::endl;
64  std::cout<<" landau "<<frand->Landau(0, width1(part)) + frand->Gaus(0, width2(part))<<std::endl;
65  std::cout<<" weight 1 "<<width1(part)<<" weight 2 "<< width2(part)<<std::endl;
66  CalcLikelihood(lh);
67 }
static double width2(PidType particle)
static double MeanEnergyLoss(PidType particle)
static double width1(PidType particle)
static double mpv(PidType particle)
static void CalcLikelihood(PndHypPidCand *cand)
void PndHypAdvancedPidAlgo::CalcLikelihood ( int  lundId,
double  momentum,
double *  lh 
)
static

Definition at line 70 of file PndHypAdvancedPidAlgo.cxx.

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

70  {
71  switch(lundId) {
72  case 2212: CalcLikelihood(kProton, momentum, lh); break;
73  case 321: CalcLikelihood(kKaon, momentum, lh); break;
74  case 211: CalcLikelihood(kPion, momentum, lh); break;
75  case 13: CalcLikelihood(kMuon, momentum, lh); break;
76  case 11: CalcLikelihood(kElectron, momentum, lh); break;
77  }
78 }
static void CalcLikelihood(PndHypPidCand *cand)
void PndHypAdvancedPidAlgo::CalcLikelihood ( double *  lh)
staticprivate

Definition at line 82 of file PndHypAdvancedPidAlgo.cxx.

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

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

Definition at line 39 of file PndHypAdvancedPidAlgo.h.

References fenergyloss.

39 {return fenergyloss;};
static double PndHypAdvancedPidAlgo::GetMomentum ( )
inlinestatic

Definition at line 38 of file PndHypAdvancedPidAlgo.h.

References fmomentum.

38 {return fmomentum;};
double PndHypAdvancedPidAlgo::LandauGaus ( double  s_mpv,
double  width1,
double  width2 
)
staticprivate

Definition at line 112 of file PndHypAdvancedPidAlgo.cxx.

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

Referenced by CalcLikelihood().

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

Definition at line 97 of file PndHypAdvancedPidAlgo.cxx.

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

Referenced by CalcLikelihood().

97  {
98  //Calculate the lower boundary of the energy loss distribution.
99 
100  //[GeV]
101  static float eb=0.14e-6;
102  //[m/s]
103  static float c=2.99792458e8;
104  //[GeV/c**2]
105  //static float Mass[kNPidType]={ 0.511e-3, 0.1058, 0.1396, 0.4937, 0.9383 };
106  float Mass[kNPidType]={ 0.511e-3, 0.1058, 0.1396, 0.4937, 0.9383 };
107  std::cout<<" meanloss mass"<< Mass[kProton]<<" "<<pow(Mass[kProton]/fmomentum,2)<<std::endl;
108  double sqrBeta=1/(1+pow(Mass[part]/fmomentum,2));
109  return 4.9312e-05 * (log(2*Mass[kElectron]*c*c/eb*sqrBeta/(1-sqrBeta))-sqrBeta)/sqrBeta;
110 };
friend F32vec4 log(const F32vec4 &a)
Definition: P4_F32vec4.h:110
double PndHypAdvancedPidAlgo::mpv ( PidType  particle)
staticprivate

Definition at line 183 of file PndHypAdvancedPidAlgo.cxx.

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

Referenced by CalcLikelihood().

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

Definition at line 249 of file PndHypAdvancedPidAlgo.cxx.

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

Referenced by CalcLikelihood().

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

Definition at line 285 of file PndHypAdvancedPidAlgo.cxx.

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

Referenced by CalcLikelihood(), and LandauGaus().

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

Member Data Documentation

double PndHypAdvancedPidAlgo::fenergyloss
staticprivate

Definition at line 58 of file PndHypAdvancedPidAlgo.h.

Referenced by CalcLikelihood(), and GetEnergyLoss().

double PndHypAdvancedPidAlgo::fmomentum
staticprivate

Definition at line 57 of file PndHypAdvancedPidAlgo.h.

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

TRandom3 * PndHypAdvancedPidAlgo::frand =0
staticprivate

Definition at line 66 of file PndHypAdvancedPidAlgo.h.

Referenced by CalcLikelihood().


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