FairRoot/PandaRoot
PndFsmEffTracker.cxx
Go to the documentation of this file.
1 //--------------------------------------------------------------------------
2 // File and Version Information:
3 // $Id: FsmEffTracker.cc,v 1.9 2007/05/24 08:07:40 klausg Exp $
4 //
5 // Description:
6 // Class FsmEffTracker
7 //
8 // Implementation of an effective Tracker for the FastSim
9 // which provides resolution for mom, tht, phi from full sim
10 // NOTE: should be used INSTEAD Tpc/Stt, Mvd and the Mdc's
11 //
12 // This software was developed for the PANDA collaboration. If you
13 // use all or part of it, please give an appropriate acknowledgement.
14 //
15 // Author List:
16 // Klaus Goetzen Original Author
17 //
18 // Copyright Information:
19 // Copyright (C) 2006 GSI
20 //
21 //------------------------------------------------------------------------
22 
23 //-----------------------
24 // This Class's Header --
25 //-----------------------
26 #include "PndFsmEffTracker.h"
27 
28 //-------------
29 // C Headers --
30 //-------------
31 
32 //---------------
33 // C++ Headers --
34 //---------------
35 #include <math.h>
36 #include <iostream>
37 #include <fstream>
38 
39 using std::cout;
40 using std::endl;
41 using std::ostream;
42 using std::string;
43 using std::ifstream;
44 
45 //-------------------------------
46 // Collaborating Class Headers --
47 //-------------------------------
48 
49 #include "ArgList.h"
50 #include "PndFsmResponse.h"
51 #include "PndFsmTrack.h"
52 
53 //-----------------------------------------------------------------------
54 // Local Macros, Typedefs, Structures, Unions and Forward Declarations --
55 //-----------------------------------------------------------------------
56 
57 //----------------
58 // Constructors --
59 //----------------
60 
62 {
64 
65  _thtMin=_thtMin*M_PI/180.0;
66  _thtMax=_thtMax*M_PI/180.0;
67  _parFileName = "$VMCWORKDIR/fastsim/resParsTracker.dat";
69 
70  //print(std::cout);
71 }
72 
74 {
76  //set default parameter values and parses a parameter list
77  //i.e. std::list<std::string> of the form
78  //"a=1" "b=2" "c=3"
79  parseParameterList(par);
80 
81  _thtMin=_thtMin*M_PI/180.0;
82  _thtMax=_thtMax*M_PI/180.0;
83  _parFileName = "$VMCWORKDIR/fastsim/resParsTracker.dat";
85 
86  //print(std::cout);
87 }
88 
89 //--------------
90 // Destructor --
91 //--------------
92 
94 {
95 }
96 
97 //--------------
98 // Operations --
99 //--------------
100 
103 {
104  PndFsmResponse *result=new PndFsmResponse();
105 
106  result->setDetector(this);
107  bool wasDetected=detected(t);
108  result->setDetected(wasDetected);
109 
110  if (wasDetected && fabs(t->charge())>1e-8)
111  {
112  result->setdp(dp(t));
113  result->setdphi(dphi(t));
114  result->setdtheta(dtheta(t));
115 
116  // now the dEdx information
117  TParticlePDG* part = _fdbPDG->GetParticle(t->pdt());
118  double mass = (part) ? part->Mass() : t->p4().M();
119  double p=t->p4().Vect().Mag();
120 
121  // overall resolution for the tht_c measurement
122  double dEdx = compdEdx(p,mass);
123  double sig = _dEdxRes*dEdx;
124 
125  double m_e = _fdbPDG->GetParticle(11)->Mass();
126  double m_mu = _fdbPDG->GetParticle(13)->Mass();
127  double m_pi = _fdbPDG->GetParticle(211)->Mass();
128  double m_K = _fdbPDG->GetParticle(321)->Mass();
129  double m_p = _fdbPDG->GetParticle(2212)->Mass();
130 
131 
132  // compute the expected dEdx values for all particle types
133  // we need these to determine the pdf's (gaussian around nominal dEdx with res sig)
134 
135  double dEdx_e = compdEdx(p,m_e);
136  double dEdx_mu = compdEdx(p,m_mu);
137  double dEdx_pi = compdEdx(p,m_pi);
138  double dEdx_K = compdEdx(p,m_K);
139  double dEdx_p = compdEdx(p,m_p);
140 
141  double measdEdx =_rand->Gaus(dEdx,sig);
142  result ->setTpcdEdx(measdEdx);
143 
144  if (dEdx_e) result->setLHElectron( gauss(measdEdx,dEdx_e,sig) );
145  if (dEdx_mu) result->setLHMuon( gauss(measdEdx,dEdx_mu,sig) );
146  if (dEdx_pi) result->setLHPion( gauss(measdEdx,dEdx_pi,sig) );
147  if (dEdx_K) result->setLHKaon( gauss(measdEdx,dEdx_K,sig) );
148  if (dEdx_p) result->setLHProton(gauss(measdEdx,dEdx_p,sig) );
149  }
150 
151  return result;
152 }
153 
154 double
155 PndFsmEffTracker::gauss(double x, double x0, double s)
156 {
157  return (1.0/(sqrt(2.0*M_PI)*s))*
158  exp(-(x-x0)*(x-x0)/(2.0*s*s));
159 }
160 
161 
162 double
163 PndFsmEffTracker::compdEdx(double p, double M)
164 {
165  double dEdX;
166 
167  p*=1000;
168  M*=1000;
169 
170  const double Z=10;
171  const double A=20;
172  const double z=1;//charge of incident particle in unit of e
173 
174  double beta;
175  beta=p/sqrt(M*M+p*p); //CalculateBeta(KE,M);
176 
177  double gamma;
178  gamma=1./sqrt(1-beta*beta);
179 
180  const double I=10e-6*Z;//0.000188;//MeV
181  const double me=0.511;//Mev/c2
182 
183  double Wmax;
184  Wmax=(2*me*beta*beta*gamma*gamma) / (1 + 2*gamma*me/M + (me/M)*(me/M));
185 
186  //const double C1=0.1535;//MeV cm2/g
187 
188  double X,X0,X1;
189  double kappa=0.307075;
190  X0=0.201;
191  X1=3;
192  X=log10(beta*gamma);
193  double delta;
194  double C,a;
195  C=-5.217;
196  a=0.196;
197 
198  if(X<=X0)
199  delta=0;
200  else if(X<=X1)
201  delta=2*log(10.)*X+C+a*(X1-X)*(X1-X)*(X1-X);
202  else
203  delta=2*log(10.)*X+C;
204 
205  dEdX= ( kappa * (Z/A) * z*z /(beta*beta)) * (log(2*me*beta*beta*gamma*gamma*Wmax / (I*I)) - 2*beta*beta - delta); //-Dshell??
206 
207  return dEdX;
208 }
209 
210 bool
212 {
213  if (t->hitMapValid()) {
214  return t->hitMapResponse(FsmDetEnum::Tpc);
215  } else {
216  double theta = t->p4().Theta();
217  double p=t->p4().Vect().Mag();
218  double charge=t->charge();
219  return ( charge!=0.0 && theta>=_thtMin && theta<=_thtMax && p>_pmin && _rand->Rndm()<=_efficiency);
220  }
221 }
222 
223 double
225 {
226  double p=t->p4().Vect().Mag();
227  double th=t->p4().Vect().Theta();
228  //assert(th>=0 && p>=0);
229 
230  int idxR = int(p/6.0*_cols);
231  if (idxR>=_cols) idxR=_cols-1;
232 
233  int idxT = int(th/160.*_rows);
234  if (idxT>=_rows) idxT=_rows-1;
235 
236  double Dp=_sigMom[idxT][idxR]*p;
237 
238  return ( Dp );
239 }
240 
241 double
243 {
244  double p=t->p4().Vect().Mag();
245  double th=t->p4().Vect().Theta();
246  //assert(th>=0 && p>=0);
247 
248  int idxR = int(p/6.0*_cols);
249  if (idxR>=_cols) idxR=_cols-1;
250 
251  int idxT = int(th/160.*_rows);
252  if (idxT>=_rows) idxT=_rows-1;
253 
254  double Dphi=_sigPhi[idxT][idxR]*M_PI/180.0;
255 
256  return Dphi;
257 }
258 
259 double
261 {
262  double p=t->p4().Vect().Mag();
263  double th=t->p4().Vect().Theta();
264  //assert(th>=0 && p>=0);
265 
266  int idxR = int(p/6.0*_cols);
267  if (idxR>=_cols) idxR=_cols-1;
268 
269  int idxT = int(th/160.*_rows);
270  if (idxT>=_rows) idxT=_rows-1;
271 
272  double dt=_sigTht[idxT][idxR]*M_PI/180.0;
273 
274  return dt; //to be refined
275 }
276 
277 void
279 {
280  o <<"Parameters for detector <"<<detName()<<">"<<endl;
281  o <<" _thtMin = "<<_thtMin<<endl;
282  o <<" _thtMax = "<<_thtMax<<endl;
283  o <<" _radiationLength = "<<_radiationLength<<endl;
284  o <<" _pmin = "<<_pmin<<endl;
285  o <<" _pRes = "<<_pRes <<endl;
286  o <<" _phiRes = "<<_phiRes << " degree" << endl;
287  o <<" _thetaRes = "<<_thetaRes <<" degree" << endl;
288  o <<" _dEdxRes = "<<_dEdxRes << " (rel)"<< endl;
289  o <<" _efficiency = "<<_efficiency<<endl;
290  o <<" Parametrizations:"<<endl<<"Phi:"<<endl;
291 
292  for (int i=0;i<_rows;i++){
293  for (int j=0;j<_cols;j++) o << _sigPhi[i][j]<<" ";
294  o<<endl;
295  }
296  o <<endl<<"Theta:"<<endl;
297  for (int i=0;i<_rows;i++){
298  for (int j=0;j<_cols;j++) o << _sigTht[i][j]<<" ";
299  o<<endl;
300  }
301  o <<endl<<"Mom:"<<endl;
302 
303  for (int i=0;i<_rows;i++){
304  for (int j=0;j<_cols;j++) o << _sigMom[i][j]<<" ";
305  o<<endl;
306  }
307  o <<endl;
308 }
309 
310 void
312 {
313  _detName = "PndFsmEffTracker";
314  _thtMin = 1.0;
315  _thtMax = 150.00;
316  _radiationLength = 0.0;
317  _pmin = 0.0;
318  _pRes =0.005;//0.5% smearing
319  _phiRes =0.1; //0.1 degree smearing
320  _thetaRes =0.1; //0.1 degree smearing
321  _dEdxRes =0.07; // 7% dEdx resolution
322  _efficiency =1.0;
323 
324  _rows = 6; //for the parameterization of res
325  _cols = 12; //in mom, tht, phi
326 }
327 
328 bool
329 PndFsmEffTracker::setParameter(std::string &name, double value)
330 {
331  // *****************
332  // include here all parameters which should be settable via tcl
333  // *****************
334 
335  bool knownName=true;
336 
337  if (name == "thtMin")
338  _thtMin=value;
339  else
340  if (name == "thtMax")
341  _thtMax=value;
342  else
343  if (name == "radiationLength")
344  _radiationLength=value;
345  else
346  if (name == "pmin")
347  _pmin=value;
348  else
349  if (name == "pRes")
350  _pRes=value;
351  else
352  if (name == "phiRes")
353  _phiRes=value;
354  else
355  if (name == "thetaRes")
356  _thetaRes=value;
357  else
358  if (name == "dEdxRes")
359  _dEdxRes=value;
360  else
361  if (name == "efficiency")
362  _efficiency=value;
363  else
364  knownName=false;
365 
366  return knownName;
367 }
368 
370 {
371  ifstream parFile(_parFileName.c_str());
372 
373  for (int i=0;i<_rows;i++)
374  for (int j=0;j<_cols;j++) parFile >> _sigPhi[i][j];
375 
376  for (int i=0;i<_rows;i++)
377  for (int j=0;j<_cols;j++) parFile >> _sigTht[i][j];
378 
379  for (int i=0;i<_rows;i++)
380  for (int j=0;j<_cols;j++) parFile >> _sigMom[i][j];
381 
382  parFile.close();
383 
384  return true;
385 }
double gauss(double x, double x0, double s)
Double_t x0
Definition: checkhelixhit.C:70
double _efficiency
Definition: PndFsmAbsDet.h:93
void setdphi(double val)
void setLHElectron(double val)
virtual PndFsmResponse * respond(PndFsmTrack *t)
friend F32vec4 exp(const F32vec4 &a)
Definition: P4_F32vec4.h:109
Int_t i
Definition: run_full.C:25
static const double me
Definition: mzparameters.h:12
TDatabasePDG * _fdbPDG
Definition: PndFsmAbsDet.h:95
void setLHProton(double val)
std::list< std::string > ArgList
Definition: ArgList.h:7
double dtheta(PndFsmTrack *t) const
friend F32vec4 sqrt(const F32vec4 &a)
Definition: P4_F32vec4.h:29
std::string _parFileName
void setTpcdEdx(double val, double err=0)
void setLHMuon(double val)
bool hitMapResponse(unsigned int)
Definition: PndFsmTrack.h:86
TLorentzVector s
Definition: Pnd2DStar.C:50
Double_t par[3]
friend F32vec4 log(const F32vec4 &a)
Definition: P4_F32vec4.h:110
double charge()
Definition: PndFsmTrack.h:75
void parseParameterList(ArgList &par)
TRandom3 * _rand
Definition: PndFsmAbsDet.h:94
Double_t p
Definition: anasim.C:58
Double_t dEdX
Definition: anasim.C:58
double _sigMom[6][12]
int Pic_FED Eff_lEE C()
Int_t a
Definition: anaLmdDigi.C:126
TLorentzVector p4()
Definition: PndFsmTrack.h:72
basic_ostream< char, char_traits< char > > ostream
void setDetector(PndFsmAbsDet *detector)
TString parFile
Definition: hit_dirc.C:14
const std::string & detName()
Definition: PndFsmAbsDet.h:74
void setdp(double val)
double _sigTht[6][12]
Double_t z
double _sigPhi[6][12]
void setLHKaon(double val)
friend F32vec4 fabs(const F32vec4 &a)
Definition: P4_F32vec4.h:47
TString name
bool hitMapValid()
Definition: PndFsmTrack.h:85
double X
Definition: anaLmdDigi.C:68
Double_t x
std::string _detName
Definition: PndFsmAbsDet.h:92
double Z
Definition: anaLmdDigi.C:68
void setDetected(bool isdet)
TTree * t
Definition: bump_analys.C:13
double dp(PndFsmTrack *t) const
void setdtheta(double val)
double compdEdx(double p, double M)
virtual ~PndFsmEffTracker()
double dphi(PndFsmTrack *t) const
bool detected(PndFsmTrack *t) const
void print(std::ostream &o)
void setLHPion(double val)
bool setParameter(std::string &name, double value)