FairRoot/PandaRoot
PndFsmMvdPid.cxx
Go to the documentation of this file.
1 //--------------------------------------------------------------------------
2 // File and Version Information:
3 // $Id: PndFsmMvdPid.cc,v 1.10 2007/05/24 08:07:40 klausg Exp $
4 //
5 // Description:
6 // Class PndFsmMvdPid
7 //
8 // Implementation of the MVD for the FastSim
9 //
10 // This software was developed for the PANDA collaboration. If you
11 // use all or part of it, please give an appropriate acknowledgement.
12 //
13 // Author List:
14 // Klaus Goetzen Original Author
15 //
16 // Copyright Information:
17 // Copyright (C) 2006 GSI
18 //
19 //------------------------------------------------------------------------
20 
21 #include "PndFsmMvdPid.h"
22 #include <math.h>
23 #include <iostream>
24 
25 using std::cout;
26 using std::endl;
27 using std::ostream;
28 using std::string;
29 
30 #include "ArgList.h"
31 #include "PndFsmResponse.h"
32 #include "PndFsmTrack.h"
33 
35 {
37 
38  _thtMin=_thtMin*M_PI/180.0;
39  _thtMax=_thtMax*M_PI/180.0;
40  //print(std::cout);
41 }
42 
44 {
46  //set default parameter values and parses a parameter list
47  //i.e. std::list<std::string> of the form
48  //"a=1" "b=2" "c=3"
49  parseParameterList(par);
50 
51  _thtMin=_thtMin*M_PI/180.0;
52  _thtMax=_thtMax*M_PI/180.0;
53  //print(std::cout);
54 }
55 
56 //--------------
57 // Destructor --
58 //--------------
59 
61 {
62 }
63 
64 //--------------
65 // Operations --
66 //--------------
67 
70 {
71  PndFsmResponse *result=new PndFsmResponse();
72 
73  result->setDetector(this);
74  bool wasDetected=detected(t);
75  result->setDetected(wasDetected);
76 
77  if (wasDetected && fabs(t->charge())>1e-8)
78  {
79  //select particle
80  PidType part;
81  switch(abs(t->pdt())) {
82  case 2212:part=proton; break;
83  case 321: part=kaon; break;
84  case 211: part=pion; break;
85  case 13: part=muon; break;
86  case 11: part=electron; break;
87  }
88 
89  //build random energy loss
90  _momentum = t->p4().Vect().Mag();
91  _energyloss = MeanEnergyLoss(part) + mpv(part) + _rand->Landau(0, width1(part)) + _rand->Gaus(0, width2(part))*_dEdxResMulti;
92 
93  //store random energy loss
94  result->setMvddEdx(_energyloss/1e-3);
95 
96  //store energy loss
97  if (_momentum>=0 && _momentum<=2.5) {
99  result->setLHMuon(Likelihood(muon));
100  result->setLHPion(Likelihood(pion));
101  result->setLHKaon(Likelihood(kaon));
102  result->setLHProton(Likelihood(proton));
103  } else {
104  result->setLHElectron(0.2);
105  result->setLHMuon(0.2);
106  result->setLHPion(0.2);
107  result->setLHKaon(0.2);
108  result->setLHProton(0.2);
109  }
110  }
111 
112  return result;
113 }
114 
115 
116 bool
118 {
119  double theta = t->p4().Theta();
120  double p_t=t->p4().Vect().Perp(TVector3(0.,0.,1.));
121  double charge=t->charge();
122 
123  return ( charge!=0.0 && theta>=_thtMin && theta<=_thtMax && p_t>_ptmin && _rand->Rndm()<=_efficiency);
124 }
125 
126 
127 void
129 {
130  o <<"Parameters for detector <"<<detName()<<">"<<endl;
131  o <<" _thtMin = "<<_thtMin<<endl;
132  o <<" _thtMax = "<<_thtMax<<endl;
133  o <<" _ptmin = "<<_ptmin<<endl;
134  o <<" _dEdxResMulti = "<<100*_dEdxResMulti<< "\%" << endl;
135  o <<" _efficiency = "<<_efficiency<<endl;
136 }
137 
138 void
140 {
141  _detName = "MvdPid";
142  _thtMin = 5.0;
143  _thtMax = 160.0;
144  _ptmin = 0.0;
145  _dEdxResMulti = 1.00; //normal energy loss resolution
146  _efficiency = 1.0;
147 }
148 
149 bool
150 PndFsmMvdPid::setParameter(std::string &name, double value)
151 {
152  // *****************
153  // include here all parameters which should be settable via tcl
154  // *****************
155 
156  bool knownName=true;
157 
158  if (name == "thtMin")
159  _thtMin=value;
160  else
161  if (name == "thtMax")
162  _thtMax=value;
163  else
164  if (name == "ptmin")
165  _ptmin=value;
166  else
167  if (name == "dEdxResMulti")
168  _dEdxResMulti=value;
169  else
170  if (name == "efficiency")
171  _efficiency=value;
172  else
173  knownName=false;
174 
175  return knownName;
176 }
177 
179  //Calculate the lower boundary of the energy loss distribution.
180 
181  //[GeV]
182  static float eb=0.14e-6;
183  //[m/s]
184  static float c=2.99792458e8;
185  //[GeV/c**2]
186  static float Mass[nPidType]={ 0.511e-3, 0.1058, 0.1396, 0.4937, 0.9383 };
187 
188  double sqrBeta=1/(1+pow(Mass[part]/_momentum,2));
189  return 4.9312e-05 * (log(2*Mass[electron]*c*c/eb*sqrBeta/(1-sqrBeta))-sqrBeta)/sqrBeta;
190 };
191 
192 double PndFsmMvdPid::LandauGaus(double s_mpv, double widthone, double widthtwo) {
193  // this is the adapted TF1::Integral function from
194  // ROOT 5.14. GOTOs have been removed and interval
195  // division has been modified to maximize performance
196 
197  if (widthone<=0)
198  return TMath::Gaus(s_mpv, 0, widthtwo, true);
199  else if (widthtwo<=0)
200  return TMath::Landau(s_mpv, 0, widthone, true);
201  else {
202  static double x[12] = { 0.96028985649753623, 0.79666647741362674,
203  0.52553240991632899, 0.18343464249564980,
204  0.98940093499164993, 0.94457502307323258,
205  0.86563120238783174, 0.75540440835500303,
206  0.61787624440264375, 0.45801677765722739,
207  0.28160355077925891, 0.09501250983763744};
208 
209  static double w[12] = { 0.10122853629037626, 0.22238103445337447,
210  0.31370664587788729, 0.36268378337836198,
211  0.02715245941175409, 0.06225352393864789,
212  0.09515851168249278, 0.12462897125553387,
213  0.14959598881657673, 0.16915651939500254,
214  0.18260341504492359, 0.18945061045506850};
215 
216  double h, bb, aa, c1, c2, u, s8, s16, f1, f2;
217  double xx;
218  bool redo=true;
219  int i;
220 
221  h = 0;
222  aa = -5.0*widthtwo;
223  bb = -2.5*widthtwo;
224 
225  do {
226  c1 = 0.5*(bb+aa);
227  c2 = 0.5*(bb-aa);
228 
229  s8 = 0;
230  for (i=0;i<4;i++) {
231  u = c2*x[i];
232  xx = c1+u;
233  f1 = TMath::Landau(s_mpv+xx, 0, widthone, true)*TMath::Gaus(xx, 0, widthtwo, true);
234  xx = c1-u;
235  f2 = TMath::Landau(s_mpv+xx, 0, widthone, true)*TMath::Gaus(xx, 0, widthtwo, true);
236  s8+= w[i]*(f1 + f2);
237  }
238  s16 = 0;
239  for (i=4;i<12;i++) {
240  u = c2*x[i];
241  xx = c1+u;
242  f1 = TMath::Landau(s_mpv+xx, 0, widthone, true)*TMath::Gaus(xx, 0, widthtwo, true);
243  xx = c1-u;
244  f2 = TMath::Landau(s_mpv+xx, 0, widthone, true)*TMath::Gaus(xx, 0, widthtwo, true);
245  s16+= w[i]*(f1 + f2);
246  }
247  s16 = c2*s16;
248  if (TMath::Abs(s16-c2*s8) <= 1e-12*(s16+1) ) {
249  aa =bb;
250  bb+=2*c2*1.5;
251  if (bb>=5*widthtwo) {
252  bb=5*widthtwo;
253  redo=false;
254  }
255  h += s16;
256  } else
257  bb = c1;
258  } while (redo);
259  return h;
260  }
261 }
262 
264  return LandauGaus( _energyloss - MeanEnergyLoss(part) - mpv(part), width1(part), width2(part)*_dEdxResMulti );
265 }
266 
268  double x=_momentum;
269  double x0=0;
270  double x1=0;
271  double c0=0;
272  double c1=0;
273  double d1=0;
274  double a3=0;
275  double a4=0;
276  double a5=0;
277 
278  switch(part) {
279  case proton:
280  x0 = 0.45;
281  x1 = 1.3;
282  c0 = 0.383451e-03;
283  c1 = -0.126986e-03;
284  d1 = -5.21351e-06;
285  a3 = -3.05821;
286  a4 = 24.6356;
287  a5 = -68.632;
288  break;
289  case kaon:
290  x0 = 0.25;
291  x1 = 1.05;
292  c0 = 0.326259e-03;
293  c1 = -7.68052e-05;
294  d1 = 1.51033e-05;
295  a3 = -19.6615;
296  a4 = 264.382;
297  a5 = -1238.09;
298  break;
299  case pion:
300  x0 = 0.1;
301  x1 = 1.0;
302  c0 = 0.274692e-03;
303  c1 = 3.2571e-05;
304  d1 = 9.16527e-06;
305  a5 = -6624.05;
306  break;
307  case muon:
308  x0 = 0.15;
309  x1 = 1.15;
310  a3 = 4.33244;
311  a4 = -107.686;
312  a5 = 699.522;
313  c0 = 0.248749e-03;
314  c1 = 6.57118e-05;
315  d1 = -4.09447e-06;
316  break;
317  case electron:
318  x1 = 1.20;
319  c0 = 2.93999e-03;
320  c1 = 1.76792e-05;
321  break;
322  }
323  if (x>=x1)
324  return c0+c1*(x1-x0)+d1*(x-x1);
325  if (x>=x0)
326  return c0+c1*(x-x0);
327  else
328  return c0+c1*(x-x0)+pow(x0-x,3)*(a3+(x0-x)*(a4+(x0-x)*a5));
329 }
330 
332  double x=_momentum;
333  switch(part) {
334  case proton:
335  if (x>=1.10)
336  return +3.81174e-04+x*(-2.25108e-04+x*+5.45154e-05);
337  else
338  return -5.28145e-05+x*(+8.29883e-04+x*-5.35972e-04);
339  break;
340  case kaon:
341  if (x>=1.05)
342  return +2.61134e-04+x*(-1.30818e-04+x*+3.44165e-05);
343  else
344  return +3.41858e-04+x*(-3.21115e-04+x*+1.37459e-04);
345  break;
346  case pion:
347  if (x>=1.00)
348  return +1.88718e-04+x*(-6.38948e-05+x*+1.78590e-05);
349  else
350  return +1.82872e-04+x*(-1.28373e-04+x*+8.01459e-05);
351  break;
352  case muon:
353  if (x>=1.20)
354  return +1.06142e-04+x*(+3.68777e-05+x*-1.00190e-05);
355  else
356  return +1.89374e-04+x*(-1.46441e-04+x*+9.10813e-05);
357  break;
358  case electron:
359  if (x>1.2) x=1.2;
360  // electrons are constant for momentum > 1.2GeV
361  return +1.27955e-04+x*(-3.15732e-06+x*+9.64736e-06);
362  break;
363  }
364  return 0;
365 }
366 
368  double x=_momentum;
369  switch(part) {
370  case proton:
371  if (x>=1.10)
372  return +6.41067e-04+x*(-3.82507e-04+x*+9.03732e-05);
373  else
374  return +6.40328e-04-3.21725e-04*x+3.17708e-05*pow(x,-3);
375  break;
376  case kaon:
377  if (x>=1.05)
378  return +2.22504e-04+x*(-6.40051e-06+x*+2.14434e-06);
379  else
380  return +3.86684e-04-1.61873e-04*x+7.76586e-06*pow(x,-3);
381  break;
382  case pion:
383  if (x>=1.00)
384  return +1.32999e-04+x*(+1.19714e-04+x*-3.53302e-05);
385  else
386  return +2.21603e-04-3.21357e-06*x+4.64793e-06*pow(x,-2);
387  break;
388  case muon:
389  if (x>=1.20)
390  return +7.84582e-05+x*(+1.88988e-04+x*-5.49637e-05);
391  else
392  return +1.67388e-04+5.67991e-05*x+3.42702e-06*pow(x,-2);
393  break;
394  case electron:
395  if (x>1.2) x=1.2;
396  // electrons are constant for momentum > 1.2GeV
397  return +4.08849e-04-3.56548e-05*x+1.84825e-08*pow(x,-3);
398  break;
399  }
400  return 0;
401 }
402 
Double_t x0
Definition: checkhelixhit.C:70
double LandauGaus(double s_mpv, double width1, double width2)
double _efficiency
Definition: PndFsmAbsDet.h:93
void setLHElectron(double val)
Int_t i
Definition: run_full.C:25
void setLHProton(double val)
std::list< std::string > ArgList
Definition: ArgList.h:7
TF1 * f1
Definition: reco_analys2.C:50
bool detected(PndFsmTrack *t) const
double width1(PidType particle)
double _ptmin
Definition: PndFsmMvdPid.h:75
void setLHMuon(double val)
void print(std::ostream &o)
Double_t par[3]
friend F32vec4 log(const F32vec4 &a)
Definition: P4_F32vec4.h:110
c2
Definition: plot_dirc.C:39
double charge()
Definition: PndFsmTrack.h:75
void parseParameterList(ArgList &par)
double _momentum
Definition: PndFsmMvdPid.h:94
TRandom3 * _rand
Definition: PndFsmAbsDet.h:94
double width2(PidType particle)
double mpv(PidType particle)
static T Abs(const T &x)
Definition: PndCAMath.h:39
double Likelihood(PidType particle)
TLorentzVector p4()
Definition: PndFsmTrack.h:72
basic_ostream< char, char_traits< char > > ostream
void setDetector(PndFsmAbsDet *detector)
const std::string & detName()
Definition: PndFsmAbsDet.h:74
void setLHKaon(double val)
friend F32vec4 fabs(const F32vec4 &a)
Definition: P4_F32vec4.h:47
c1
Definition: plot_dirc.C:35
TString name
void initParameters()
virtual PndFsmResponse * respond(PndFsmTrack *t)
double MeanEnergyLoss(PidType particle)
Double_t x
TFile * f2
std::string _detName
Definition: PndFsmAbsDet.h:92
double _dEdxResMulti
Definition: PndFsmMvdPid.h:76
void setDetected(bool isdet)
TTree * t
Definition: bump_analys.C:13
double _thtMin
Definition: PndFsmMvdPid.h:73
bool setParameter(std::string &name, double value)
double _thtMax
Definition: PndFsmMvdPid.h:74
double _energyloss
Definition: PndFsmMvdPid.h:95
virtual ~PndFsmMvdPid()
void setMvddEdx(double val, double err=0)
void setLHPion(double val)