FairRoot/PandaRoot
PndFsmMvd2.cxx
Go to the documentation of this file.
1 //--------------------------------------------------------------------------
2 // File and Version Information:
3 // $Id: FsmMvd2.cc,v 1.10 2007/05/24 08:07:40 klausg Exp $
4 //
5 // Description:
6 // Class FsmMvd2
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 //-----------------------
22 // This Class's Header --
23 //-----------------------
24 #include "PndFsmMvd2.h"
25 
26 //-------------
27 // C Headers --
28 //-------------
29 
30 //---------------
31 // C++ Headers --
32 //---------------
33 #include <math.h>
34 #include <iostream>
35 
36 using std::cout;
37 using std::endl;
38 using std::ostream;
39 using std::string;
40 
41 //-------------------------------
42 // Collaborating Class Headers --
43 //-------------------------------
44 
45 #include "ArgList.h"
46 #include "PndFsmResponse.h"
47 #include "PndFsmTrack.h"
48 
49 
50 //-----------------------------------------------------------------------
51 // Local Macros, Typedefs, Structures, Unions and Forward Declarations --
52 //-----------------------------------------------------------------------
53 
54 //----------------
55 // Constructors --
56 //----------------
57 
59 {
61 
62  _thtMin=_thtMin*M_PI/180.0;
63  _thtMax=_thtMax*M_PI/180.0;
64  //print(std::cout);
65 }
66 
68 {
70  //set default parameter values and parses a parameter list
71  //i.e. std::list<std::string> of the form
72  //"a=1" "b=2" "c=3"
73  parseParameterList(par);
74 
75  _thtMin=_thtMin*M_PI/180.0;
76  _thtMax=_thtMax*M_PI/180.0;
77  //print(std::cout);
78 }
79 
80 //--------------
81 // Destructor --
82 //--------------
83 
85 {
86 }
87 
88 //--------------
89 // Operations --
90 //--------------
91 
94 {
95  PndFsmResponse *result=new PndFsmResponse();
96 
97  result->setDetector(this);
98  bool wasDetected=detected(t);
99  result->setDetected(wasDetected);
100 
101  if (wasDetected && fabs(t->charge())>1e-8)
102  {
103  //select particle
104  PidType part;
105  switch(abs(t->pdt())) {
106  case 2212:part=proton; break;
107  case 321: part=kaon; break;
108  case 211: part=pion; break;
109  case 13: part=muon; break;
110  case 11: part=electron; break;
111  }
112 
113  //build random energy loss
114  _momentum = t->p4().Vect().Mag();
115  _energyloss = MeanEnergyLoss(part) + mpv(part) + _rand->Landau(0, width1(part)) + _rand->Gaus(0, width2(part))*_dEdxResMulti;
116 
117  //store random energy loss
118  result->setMvddEdx(_energyloss/1e-3);
119 
120  //store energy loss
121  if (_momentum>=0 && _momentum<=2.5) {
123  result->setLHMuon(Likelihood(muon));
124  result->setLHPion(Likelihood(pion));
125  result->setLHKaon(Likelihood(kaon));
126  result->setLHProton(Likelihood(proton));
127  } else {
128  result->setLHElectron(1);
129  result->setLHMuon(1);
130  result->setLHPion(1);
131  result->setLHKaon(1);
132  result->setLHProton(1);
133  }
134 
135  result->setdV(_vtxRes, _vtxRes, _vtxRes);
136  result->setdp(dp(t));
137  result->setdphi(dphi(t));
138  result->setdtheta(dtheta(t));
139  }
140 
141  return result;
142 }
143 
144 
145 bool
147 {
148  if (t->hitMapValid()) {
149  return t->hitMapResponse(FsmDetEnum::Mvd);
150  } else {
151  double theta = t->p4().Theta();
152  double p=t->p4().Vect().Mag();
153  double charge=t->charge();
154  return ( charge!=0.0 && theta>=_thtMin && theta<=_thtMax && p>_pmin && _rand->Uniform()<=_efficiency);
155  }
156 }
157 
158 double
160 {
161  double p=t->p4().Vect().Mag();
162  double Dp=_pRes*p; //10% smearing
163  return ( Dp ); //to be refined
164 }
165 
166 double
167 PndFsmMvd2::dphi(PndFsmTrack *) const // t //[R.K.03/2017] unused variable(s)
168 {
169  double Dphi=_phiRes*M_PI/180.0;
170  return Dphi; //to be refined
171 }
172 
173 double
174 PndFsmMvd2::dtheta(PndFsmTrack *) const // t //[R.K.03/2017] unused variable(s)
175 {
176  double dt=_thetaRes*M_PI/180.0;
177  return dt; //to be refined
178 }
179 
180 void
182 {
183  o <<"Parameters for detector <"<<detName()<<">"<<endl;
184  o <<" _thtMin = "<<_thtMin<<endl;
185  o <<" _thtMax = "<<_thtMax<<endl;
186  o <<" _radiationLength = "<<_radiationLength<<endl;
187  o <<" _pmin = "<<_pmin<<endl;
188  o <<" _pRes = "<<100*_pRes<< "\%" << endl;
189  o <<" _dEdxResMulti = "<<100*_dEdxResMulti<< "\%" << endl;
190  o <<" _vtxRes = "<<_vtxRes*1e5<<"um "<<endl;
191  o <<" _phiRes = "<<_phiRes << " degree" << endl;
192  o <<" _thetaRes = "<<_thetaRes <<" degree" << endl;
193  o <<" _efficiency = "<<_efficiency<<endl;
194 }
195 
196 void
198 {
200  _thtMin = 5.0;
201  _thtMax = 160.0;
202  _radiationLength = 0.0;
203  _pmin = 0.0;
204  _vtxRes = 100e-4; //vtx res = 100 um
205  _pRes =0.1;//10% smearing
206  _dEdxResMulti =1.00; //normal energy loss resolution
207  _phiRes =0.01; //0.01 degree smearing
208  _thetaRes =0.01; //0.01 degree smearing
209  _efficiency =1.0;
210 }
211 
212 bool
213 PndFsmMvd2::setParameter(std::string &name, double value)
214 {
215  // *****************
216  // include here all parameters which should be settable via tcl
217  // *****************
218 
219  bool knownName=true;
220 
221  if (name == "thtMin")
222  _thtMin=value;
223  else
224  if (name == "thtMax")
225  _thtMax=value;
226  else
227  if (name == "radiationLength")
228  _radiationLength=value;
229  else
230  if (name == "pmin")
231  _pmin=value;
232  else
233  if (name == "vtxRes")
234  _vtxRes=value;
235  else
236  if (name == "pRes")
237  _pRes=value;
238  else
239  if (name == "dEdxResMulti")
240  _dEdxResMulti=value;
241  else
242  if (name == "thetaRes")
243  _thetaRes=value;
244  else
245  if (name == "phiRes")
246  _phiRes=value;
247  else
248  if (name == "efficiency")
249  _efficiency=value;
250  else
251  knownName=false;
252 
253  return knownName;
254 }
255 
257  //Calculate the lower boundary of the energy loss distribution.
258 
259  //[GeV]
260  static float eb=0.14e-6;
261  //[m/s]
262  static float c=2.99792458e8;
263  //[GeV/c**2]
264  static float Mass[nPidType]={ 0.511e-3, 0.1058, 0.1396, 0.4937, 0.9383 };
265 
266  double sqrBeta=1/(1+pow(Mass[part]/_momentum,2));
267  return 4.9312e-05 * (log(2*Mass[electron]*c*c/eb*sqrBeta/(1-sqrBeta))-sqrBeta)/sqrBeta;
268 };
269 
270 double PndFsmMvd2::LandauGaus(double s_mpv, double widthone, double widthtwo) {
271  // this is the adapted TF1::Integral function from
272  // ROOT 5.14. GOTOs have been removed and interval
273  // division has been modified to maximize performance
274 
275  if (widthone<=0)
276  return TMath::Gaus(s_mpv, 0, widthtwo, true);
277  else if (widthtwo<=0)
278  return TMath::Landau(s_mpv, 0, widthone, true);
279  else {
280  static double x[12] = { 0.96028985649753623, 0.79666647741362674,
281  0.52553240991632899, 0.18343464249564980,
282  0.98940093499164993, 0.94457502307323258,
283  0.86563120238783174, 0.75540440835500303,
284  0.61787624440264375, 0.45801677765722739,
285  0.28160355077925891, 0.09501250983763744};
286 
287  static double w[12] = { 0.10122853629037626, 0.22238103445337447,
288  0.31370664587788729, 0.36268378337836198,
289  0.02715245941175409, 0.06225352393864789,
290  0.09515851168249278, 0.12462897125553387,
291  0.14959598881657673, 0.16915651939500254,
292  0.18260341504492359, 0.18945061045506850};
293 
294  double h, bb, aa, c1, c2, u, s8, s16, f1, f2;
295  double xx;
296  bool redo=true;
297  int i;
298 
299  h = 0;
300  aa = -5.0*widthtwo;
301  bb = -2.5*widthtwo;
302 
303  do {
304  c1 = 0.5*(bb+aa);
305  c2 = 0.5*(bb-aa);
306 
307  s8 = 0;
308  for (i=0;i<4;i++) {
309  u = c2*x[i];
310  xx = c1+u;
311  f1 = TMath::Landau(s_mpv+xx, 0, widthone, true)*TMath::Gaus(xx, 0, widthtwo, true);
312  xx = c1-u;
313  f2 = TMath::Landau(s_mpv+xx, 0, widthone, true)*TMath::Gaus(xx, 0, widthtwo, true);
314  s8+= w[i]*(f1 + f2);
315  }
316  s16 = 0;
317  for (i=4;i<12;i++) {
318  u = c2*x[i];
319  xx = c1+u;
320  f1 = TMath::Landau(s_mpv+xx, 0, widthone, true)*TMath::Gaus(xx, 0, widthtwo, true);
321  xx = c1-u;
322  f2 = TMath::Landau(s_mpv+xx, 0, widthone, true)*TMath::Gaus(xx, 0, widthtwo, true);
323  s16+= w[i]*(f1 + f2);
324  }
325  s16 = c2*s16;
326  if (TMath::Abs(s16-c2*s8) <= 1e-12*(s16+1) ) {
327  aa =bb;
328  bb+=2*c2*1.5;
329  if (bb>=5*widthtwo) {
330  bb=5*widthtwo;
331  redo=false;
332  }
333  h += s16;
334  } else
335  bb = c1;
336  } while (redo);
337  return h;
338  }
339 }
340 
342  return LandauGaus( _energyloss - MeanEnergyLoss(part) - mpv(part), width1(part), width2(part)*_dEdxResMulti );
343 }
344 
345 double PndFsmMvd2::mpv(PidType part) {
346  double x=_momentum;
347  double x0=0;
348  double x1=0;
349  double c0=0;
350  double c1=0;
351  double d1=0;
352  double a3=0;
353  double a4=0;
354  double a5=0;
355 
356  switch(part) {
357  case proton:
358  x0 = 0.45;
359  x1 = 1.3;
360  c0 = 0.383451e-03;
361  c1 = -0.126986e-03;
362  d1 = -5.21351e-06;
363  a3 = -3.05821;
364  a4 = 24.6356;
365  a5 = -68.632;
366  break;
367  case kaon:
368  x0 = 0.25;
369  x1 = 1.05;
370  c0 = 0.326259e-03;
371  c1 = -7.68052e-05;
372  d1 = 1.51033e-05;
373  a3 = -19.6615;
374  a4 = 264.382;
375  a5 = -1238.09;
376  break;
377  case pion:
378  x0 = 0.1;
379  x1 = 1.0;
380  c0 = 0.274692e-03;
381  c1 = 3.2571e-05;
382  d1 = 9.16527e-06;
383  a5 = -6624.05;
384  break;
385  case muon:
386  x0 = 0.15;
387  x1 = 1.15;
388  a3 = 4.33244;
389  a4 = -107.686;
390  a5 = 699.522;
391  c0 = 0.248749e-03;
392  c1 = 6.57118e-05;
393  d1 = -4.09447e-06;
394  break;
395  case electron:
396  x1 = 1.20;
397  c0 = 2.93999e-03;
398  c1 = 1.76792e-05;
399  break;
400  }
401  if (x>=x1)
402  return c0+c1*(x1-x0)+d1*(x-x1);
403  if (x>=x0)
404  return c0+c1*(x-x0);
405  else
406  return c0+c1*(x-x0)+pow(x0-x,3)*(a3+(x0-x)*(a4+(x0-x)*a5));
407 }
408 
410  double x=_momentum;
411  switch(part) {
412  case proton:
413  if (x>=1.10)
414  return +3.81174e-04+x*(-2.25108e-04+x*+5.45154e-05);
415  else
416  return -5.28145e-05+x*(+8.29883e-04+x*-5.35972e-04);
417  break;
418  case kaon:
419  if (x>=1.05)
420  return +2.61134e-04+x*(-1.30818e-04+x*+3.44165e-05);
421  else
422  return +3.41858e-04+x*(-3.21115e-04+x*+1.37459e-04);
423  break;
424  case pion:
425  if (x>=1.00)
426  return +1.88718e-04+x*(-6.38948e-05+x*+1.78590e-05);
427  else
428  return +1.82872e-04+x*(-1.28373e-04+x*+8.01459e-05);
429  break;
430  case muon:
431  if (x>=1.20)
432  return +1.06142e-04+x*(+3.68777e-05+x*-1.00190e-05);
433  else
434  return +1.89374e-04+x*(-1.46441e-04+x*+9.10813e-05);
435  break;
436  case electron:
437  if (x>1.2) x=1.2;
438  // electrons are constant for momentum > 1.2GeV
439  return +1.27955e-04+x*(-3.15732e-06+x*+9.64736e-06);
440  break;
441  }
442  return 0;
443 }
444 
446  double x=_momentum;
447  switch(part) {
448  case proton:
449  if (x>=1.10)
450  return +6.41067e-04+x*(-3.82507e-04+x*+9.03732e-05);
451  else
452  return +6.40328e-04-3.21725e-04*x+3.17708e-05*pow(x,-3);
453  break;
454  case kaon:
455  if (x>=1.05)
456  return +2.22504e-04+x*(-6.40051e-06+x*+2.14434e-06);
457  else
458  return +3.86684e-04-1.61873e-04*x+7.76586e-06*pow(x,-3);
459  break;
460  case pion:
461  if (x>=1.00)
462  return +1.32999e-04+x*(+1.19714e-04+x*-3.53302e-05);
463  else
464  return +2.21603e-04-3.21357e-06*x+4.64793e-06*pow(x,-2);
465  break;
466  case muon:
467  if (x>=1.20)
468  return +7.84582e-05+x*(+1.88988e-04+x*-5.49637e-05);
469  else
470  return +1.67388e-04+5.67991e-05*x+3.42702e-06*pow(x,-2);
471  break;
472  case electron:
473  if (x>1.2) x=1.2;
474  // electrons are constant for momentum > 1.2GeV
475  return +4.08849e-04-3.56548e-05*x+1.84825e-08*pow(x,-3);
476  break;
477  }
478  return 0;
479 }
480 
double dtheta(PndFsmTrack *t) const
Definition: PndFsmMvd2.cxx:174
double _momentum
Definition: PndFsmMvd2.h:107
double _thtMax
Definition: PndFsmMvd2.h:81
Double_t x0
Definition: checkhelixhit.C:70
Double_t p
Definition: anasim.C:58
double _efficiency
Definition: PndFsmAbsDet.h:93
void setdV(TVector3 v)
void setdphi(double val)
virtual PndFsmResponse * respond(PndFsmTrack *t)
Definition: PndFsmMvd2.cxx:93
void setLHElectron(double val)
double MeanEnergyLoss(PidType particle)
Definition: PndFsmMvd2.cxx:256
virtual ~PndFsmMvd2()
Definition: PndFsmMvd2.cxx:84
double width1(PidType particle)
Definition: PndFsmMvd2.cxx:409
double width2(PidType particle)
Definition: PndFsmMvd2.cxx:445
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
void initParameters()
Definition: PndFsmMvd2.cxx:197
void setLHMuon(double val)
bool hitMapResponse(unsigned int)
Definition: PndFsmTrack.h:86
Double_t par[3]
void print(std::ostream &o)
Definition: PndFsmMvd2.cxx:181
friend F32vec4 log(const F32vec4 &a)
Definition: P4_F32vec4.h:110
c2
Definition: plot_dirc.C:39
double charge()
Definition: PndFsmTrack.h:75
double _thetaRes
Definition: PndFsmMvd2.h:88
double _dEdxResMulti
Definition: PndFsmMvd2.h:86
void parseParameterList(ArgList &par)
double _thtMin
Definition: PndFsmMvd2.h:80
TRandom3 * _rand
Definition: PndFsmAbsDet.h:94
double dp(PndFsmTrack *t) const
Definition: PndFsmMvd2.cxx:159
static T Abs(const T &x)
Definition: PndCAMath.h:39
double dphi(PndFsmTrack *t) const
Definition: PndFsmMvd2.cxx:167
double _energyloss
Definition: PndFsmMvd2.h:108
static const std::string & name(unsigned int t)
Definition: FsmDetTypes.h:26
TLorentzVector p4()
Definition: PndFsmTrack.h:72
double LandauGaus(double s_mpv, double width1, double width2)
Definition: PndFsmMvd2.cxx:270
basic_ostream< char, char_traits< char > > ostream
void setDetector(PndFsmAbsDet *detector)
double _phiRes
Definition: PndFsmMvd2.h:87
const std::string & detName()
Definition: PndFsmAbsDet.h:74
void setdp(double val)
double _pmin
Definition: PndFsmMvd2.h:83
double _vtxRes
Definition: PndFsmMvd2.h:84
void setLHKaon(double val)
friend F32vec4 fabs(const F32vec4 &a)
Definition: P4_F32vec4.h:47
c1
Definition: plot_dirc.C:35
double _radiationLength
Definition: PndFsmMvd2.h:82
TString name
bool hitMapValid()
Definition: PndFsmTrack.h:85
bool setParameter(std::string &name, double value)
Definition: PndFsmMvd2.cxx:213
Double_t x
bool detected(PndFsmTrack *t) const
Definition: PndFsmMvd2.cxx:146
TFile * f2
std::string _detName
Definition: PndFsmAbsDet.h:92
void setDetected(bool isdet)
TTree * t
Definition: bump_analys.C:13
void setdtheta(double val)
double Likelihood(PidType particle)
Definition: PndFsmMvd2.cxx:341
void setMvddEdx(double val, double err=0)
double mpv(PidType particle)
Definition: PndFsmMvd2.cxx:345
void setLHPion(double val)
double _pRes
Definition: PndFsmMvd2.h:85