FairRoot/PandaRoot
PndFsmDrcBarrel.cxx
Go to the documentation of this file.
1 //--------------------------------------------------------------------------
2 // File and Version Information:
3 // $Id: FsmDrcBarrel.cc,v 1.9 2007/05/24 08:07:40 klausg Exp $
4 //
5 // Description:
6 // Class FsmDrcBarrel
7 //
8 // Implementation of the barrel DIRC 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 "PndFsmDrcBarrel.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 #include "TH2F.h"
50 #include "TFile.h"
51 
52 //-----------------------------------------------------------------------
53 // Local Macros, Typedefs, Structures, Unions and Forward Declarations --
54 //-----------------------------------------------------------------------
55 
56 //----------------
57 // Constructors --
58 //----------------
59 
61 {
63 
64  _thtMin=_thtMin*M_PI/180.0;
65  _thtMax=_thtMax*M_PI/180.0;
66 
68 
69 // print(std::cout);
70 }
71 
73 {
75  //set default parameter values and parses a parameter list
76  //i.e. std::list<std::string> of the form
77  //"a=1" "b=2" "c=3"
78  parseParameterList(par);
79 
80  _thtMin=_thtMin*M_PI/180.0;
81  _thtMax=_thtMax*M_PI/180.0;
82 
84 
85 // print(std::cout);
86 }
87 
88 //--------------
89 // Destructor --
90 //--------------
91 
93 {
94  for (int i=0;i<5;i++)
95  if (trapfrac[i]) delete trapfrac[i];
96 }
97 
98 //--------------
99 // Operations --
100 //--------------
101 
104 {
105  PndFsmResponse *result=new PndFsmResponse();
106 
107  result->setDetector(this);
108  bool wasDetected=detected(t);
109  result->setDetected(wasDetected);
110 
111  if (wasDetected && fabs(t->charge())>1e-8)
112  {
113  TParticlePDG* part = _fdbPDG->GetParticle(t->pdt());
114  double mass = (part) ? part->Mass() : t->p4().M();
115  double theta = t->p4().Theta();
116  double p=t->p4().Vect().Mag();
117  double stht=sin(theta);
118  double p_t=p*stht;
119 
120  int pid=abs(t->pdt());
121  int npid=-1;
122 
123  if (pid==11) npid=0;
124  else if (pid==13) npid=1;
125  else if (pid==211) npid=2;
126  else if (pid==321) npid=3;
127  else if (pid==2212) npid=4;
128 
129  double thtdeg=theta/M_PI*180.;
130 
131  if ( p==0 || p_t==0 || stht==0 ) {result->setDetected(false);return result;} // floating point check ********************
132 
133  double lambda1 = 280e-9; //range of wavelength, which is seen by the PMT/PD
134  double lambda2 = 330e-9;
135 
136  double alpha=7.2974e-3; //finestructure constant
137  // curvature of track due to magnet field
138  double r = 3.3356 * p_t / _Bfield;
139 
140  if (_rBarrel>(2*r)) {result->setDetected(false);return result;} // floating point check ********************
141 
142  // dip angle in phi direction (due to curvature of track in magnet field)
143  double psi = acos(_rBarrel/(2*r));
144 
145  // path length in radiator
146  double tpsi=tan(psi);
147 
148  if ( tpsi==0 ) {result->setDetected(false);return result;} // floating point check ********************
149 
150  double l = _dSlab*sqrt( 1/(stht*stht) + 1/(tpsi*tpsi) );
151 
152  // deteremine trapping fraction
153  double trapped = _trap;
154 
155  if (npid>=0 && trapfrac[npid])
156  trapped = npid<0 ? 0.0 : trapfrac[npid]->GetBinContent(trapfrac[npid]->FindBin(p<6.0?p:6.0,thtdeg));
157 
158  // estimate the number of initially produced cherenkov photons
159  double nPhot = 2*M_PI*alpha*l*(1./lambda1 - 1./lambda2)*(1 - (mass*mass+p*p)/(p*p*_nRefrac*_nRefrac));
160 
161  // dice a poisson value
162  nPhot = _rand->Poisson(nPhot);
163 
164  // determine the number of photons hitting the sensor
165  nPhot *= trapped*_effNPhotons;
166 
167  // ************** reset detected and quit due to low numbers of photons
168 
169  if (nPhot<=_nPhotMin) {
170  result->setDetected(false);
171  return result;
172  }
173 
174  if (nPhot>100) nPhot=100;
175 
176  // overall resolution for the tht_c measurement
177  double sig = _dthtc/sqrt(nPhot);
178  // the true tht_c value for the true momentum
179  double thtC = compThetaC(p,mass);
180 
181  double m_e = _fdbPDG->GetParticle(11)->Mass();
182  double m_mu = _fdbPDG->GetParticle(13)->Mass();
183  double m_pi = _fdbPDG->GetParticle(211)->Mass();
184  double m_K = _fdbPDG->GetParticle(321)->Mass();
185  double m_p = _fdbPDG->GetParticle(2212)->Mass();
186 
187  // compute the expected cherenkov angles for all particle types
188  // we need these to determine the pdf's (gaussian around nominal tht_c with res sig)
189  // this Likelihood function has to be evaluated for the _measured_ momentum, which
190  // is smeared with dp!
191 
192  double measp=_rand->Gaus(p,_dp*p);
193  if (measp<0) measp=0;
194 
195  double thtc_e = compThetaC(measp,m_e);
196  double thtc_mu = compThetaC(measp,m_mu);
197  double thtc_pi = compThetaC(measp,m_pi);
198  double thtc_K = compThetaC(measp,m_K);
199  double thtc_p = compThetaC(measp,m_p);
200 
201  double measThetaC = _rand->Gaus(thtC,sig);
202  if (measThetaC<0) measThetaC=0;
203 
204  result->setDrcBarrelThtc(measThetaC,sig);
205 
206  if (thtc_e) result->setLHElectron( gauss(measThetaC,thtc_e,sig) );
207  if (thtc_mu) result->setLHMuon( gauss(measThetaC,thtc_mu,sig) );
208  if (thtc_pi) result->setLHPion( gauss(measThetaC,thtc_pi,sig) );
209  if (thtc_K) result->setLHKaon( gauss(measThetaC,thtc_K,sig) );
210  if (thtc_p) result->setLHProton(gauss(measThetaC,thtc_p,sig) );
211 
212  }
213 
214  return result;
215 }
216 
217 double
218 PndFsmDrcBarrel::gauss(double x, double x0, double s)
219 {
220  return (1.0/(sqrt(2.0*M_PI)*s))*
221  exp(-(x-x0)*(x-x0)/(2.0*s*s));
222 }
223 
224 double
226 {
227  double val=0.0;
228  if (p==0) return 0.0;
229  if ( (val = (p*p+m*m)/(p*p*_nRefrac*_nRefrac)) <= 1.0 ) return acos(sqrt(val));
230  else return 0.0;
231 }
232 
233 
234 bool
236 {
237  if (t->hitMapValid()) {
238  return t->hitMapResponse(FsmDetEnum::Drc);
239  }
240  else
241  {
242  int lundId = abs(t->pdt());
243  TParticlePDG* part = _fdbPDG->GetParticle(lundId);
244  double mass = (part) ? part->Mass() : t->p4().M();
245  double theta = t->p4().Theta();
246  double p = t->p4().Vect().Mag();
247  double p_t = t->p4().Vect().Pt();
248  double charge=t->charge();
249 
250  //only charged particles give signal
251  if (fabs(charge)<0.001) return false;
252 
253  // due to track curvature particle doesn't reach barrel
254  double rho = 3.3356 * p_t / _Bfield;
255  if (_rBarrel>(2*rho)) return false;
256 
257  //particle doesn't produce cherenkov light
258  if (!(lundId==11 || lundId==13 || lundId==211 || lundId==321 || lundId==2212)) return false;
259 
260  // particles momentum below cherenkov threshold
261  double p_cerenkov_min=mass/sqrt(_nRefrac*_nRefrac - 1.0);
262  if (p<p_cerenkov_min) return false;
263 
264  //due to helix trajectory particle doesn't hit detector (even with dip angle in tht range)
265  double z=2*rho*asin(_rBarrel/(2*rho))/tan(theta);
266  double polar=atan2(_rBarrel,z);
267  if (polar<_thtMin || polar>_thtMax) return false;
268 
269  //finally check for efficiency;
270  return ( _rand->Rndm()<=_efficiency);
271  }
272 }
273 
274 
275 void
277 {
278  o <<"Parameters for detector <"<<detName()<<">"<<endl;
279  o <<" _thtMin = "<<_thtMin<<endl;
280  o <<" _thtMax = "<<_thtMax<<endl;
281  o <<" _radiationLength = "<<_radiationLength<<endl;
282  o <<" _pmin = "<<_pmin<<endl;
283  o <<" _dthtc = "<<_dthtc<<endl;
284  o <<" _nPhotMin = "<<_nPhotMin<<endl;
285  o <<" _nRefrac = "<<_nRefrac<<endl;
286  o <<" _Bfield = "<<_Bfield<<endl;
287  o <<" _effNPhotons = "<<_effNPhotons<<endl;
288  o <<" _rBarrel = "<<_rBarrel<<endl;
289  o <<" _dSlab = "<<_dSlab<<endl;
290  o <<" _dp = "<<_dp<<endl;
291  o <<" _trap = "<<_trap<<endl;
292  o <<" _efficiency = "<<_efficiency<<endl;
293  o <<" _parFileName = "<<_parFileName<<endl;
294 }
295 
296 void
298 {
299  _detName = "DrcBarrel";
300  _thtMin = 22.0;
301  _thtMax = 140.0;
302  _radiationLength = 0.0;
303  _pmin = 0.0;
304  _dthtc = 0.01;
305  _nPhotMin = 5;
306  _nRefrac = 1.472;
307  _Bfield = 2.;
308  _effNPhotons = 0.10;
309  _rBarrel = 0.48;
310  _dSlab = 0.017;
311  _dp = 0.01;
312  _trap = 0.7;
313  _efficiency = 1.0;
314  _parFileName = "$VMCWORKDIR/fastsim/trapfrac_barrel.root";
315 }
316 
317 bool
318 PndFsmDrcBarrel::setParameter(std::string &name,std::string &value)
319 {
320  // *****************
321  // include here all string parameters which should be settable
322  // *****************
323 
324  bool knownName=true;
325 
326  if (name == "parFileName")
327  _parFileName=value;
328  else
329  knownName=false;
330 
331  return knownName;
332 }
333 
334 bool
335 PndFsmDrcBarrel::setParameter(std::string &name, double value)
336 {
337  // *****************
338  // include here all float parameters which should be settable
339  // *****************
340 
341  bool knownName=true;
342 
343  if (name == "thtMin")
344  _thtMin=value;
345  else
346  if (name == "thtMax")
347  _thtMax=value;
348  else
349  if (name == "radiationLength")
350  _radiationLength=value;
351  else
352  if (name == "pmin")
353  _pmin=value;
354  else
355  if (name == "dthtc")
356  _dthtc=value;
357  else
358  if (name == "nPhotMin")
359  _nPhotMin=value;
360  else
361  if (name == "nRefrac")
362  _nRefrac=value;
363  else
364  if (name == "Bfield")
365  _Bfield=value;
366  else
367  if (name == "effNPhotons")
368  _effNPhotons=value;
369  else
370  if (name == "rBarrel")
371  _rBarrel=value;
372  else
373  if (name == "dSlab")
374  _dSlab=value;
375  else
376  if (name == "dp")
377  _dp=value;
378  else
379  if (name == "trap")
380  _trap=value;
381  else
382  if (name == "efficiency")
383  _efficiency=value;
384  else
385  knownName=false;
386 
387  return knownName;
388 }
389 
391 {
392 
393  TFile *f=new TFile(_parFileName.c_str());
394 
395  for (int i=0;i<5;i++)
396  {
397  trapfrac[i]=0;
398  }
399 
400  if (f->IsZombie())
401  {
402  cout <<" -W- (PndFsmDrcBarrel::readParameters) - file "<<_parFileName.c_str()
403  <<" doesn't exist. Using constant trapping fraction _trap="<<_trap<<endl;
404  }
405  else
406  {
407  trapfrac[0]=(TH2F*)f->Get("hacc0");
408  trapfrac[1]=(TH2F*)f->Get("hacc1");
409  trapfrac[2]=(TH2F*)f->Get("hacc2");
410  trapfrac[3]=(TH2F*)f->Get("hacc3");
411  trapfrac[4]=(TH2F*)f->Get("hacc4");
412 
413  for (int i=0;i<5;i++) trapfrac[i]->SetDirectory(0);
414 
415  f->Close();
416  }
417  delete f;
418 
419  return true;
420 }
friend F32vec4 acos(const F32vec4 &a)
Definition: P4_F32vec4.h:113
Double_t x0
Definition: checkhelixhit.C:70
void setDrcBarrelThtc(double val, double err=0)
double _efficiency
Definition: PndFsmAbsDet.h:93
void setLHElectron(double val)
double r
Definition: RiemannTest.C:14
friend F32vec4 exp(const F32vec4 &a)
Definition: P4_F32vec4.h:109
Int_t i
Definition: run_full.C:25
__m128 m
Definition: P4_F32vec4.h:28
std::string _parFileName
TDatabasePDG * _fdbPDG
Definition: PndFsmAbsDet.h:95
void setLHProton(double val)
std::list< std::string > ArgList
Definition: ArgList.h:7
virtual ~PndFsmDrcBarrel()
friend F32vec4 sqrt(const F32vec4 &a)
Definition: P4_F32vec4.h:29
Double_t val[nBoxes][nFEBox]
Definition: createCalib.C:11
void setLHMuon(double val)
friend F32vec4 sin(const F32vec4 &a)
Definition: P4_F32vec4.h:111
bool hitMapResponse(unsigned int)
Definition: PndFsmTrack.h:86
TLorentzVector s
Definition: Pnd2DStar.C:50
bool detected(PndFsmTrack *t) const
int pid()
Double_t par[3]
double charge()
Definition: PndFsmTrack.h:75
void parseParameterList(ArgList &par)
TRandom3 * _rand
Definition: PndFsmAbsDet.h:94
Double_t p
Definition: anasim.C:58
TLorentzVector p4()
Definition: PndFsmTrack.h:72
double compThetaC(double p, double m)
basic_ostream< char, char_traits< char > > ostream
void setDetector(PndFsmAbsDet *detector)
const std::string & detName()
Definition: PndFsmAbsDet.h:74
TFile * f
Definition: bump_analys.C:12
Double_t z
bool setParameter(std::string &name, double value)
void setLHKaon(double val)
friend F32vec4 fabs(const F32vec4 &a)
Definition: P4_F32vec4.h:47
TString name
virtual PndFsmResponse * respond(PndFsmTrack *t)
bool hitMapValid()
Definition: PndFsmTrack.h:85
friend F32vec4 atan2(const F32vec4 &y, const F32vec4 &x)
Definition: P4_F32vec4.h:117
Double_t x
std::string _detName
Definition: PndFsmAbsDet.h:92
void setDetected(bool isdet)
TTree * t
Definition: bump_analys.C:13
double gauss(double x, double x0, double s)
double alpha
Definition: f_Init.h:9
TH2F * trapfrac[5]
void setLHPion(double val)
void print(std::ostream &o)