HARPO  5.1.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
TpcSimDriftChamber.cxx
Go to the documentation of this file.
1 #include "TpcSimDriftChamber.h"
2 
3 #include "HarpoConfig.h"
4 
5 #include "TRandom3.h"
6 #include "TMath.h"
7 
8 ClassImp(TpcSimDriftChamber)
9 
11 {
12  fDiffX = 0.08; //
13  fDiffY = 0.08; // mm/sqrt(mm)
14  fDiffZ = 0.05; //
15 
16  fDriftVelocity = 60;//33; // mm/us
17 
18  fElectronCapture = 0.001; // 1/mm
19 
20  fZReadout = 0; // mm
21  fLengthTpc = 300; // mm
22 
23 
24  Double_t diffX;
25  if ( ! gHConfig->Lookup("Sim.DiffX",diffX) )
26  Info("Constructor","Use default DiffX %g",fDiffX);
27  else
28  fDiffX = diffX;
29 
30  Double_t diffY;
31  if ( ! gHConfig->Lookup("Sim.DiffY",diffY) )
32  Info("Constructor","Use default DiffY %g",fDiffY);
33  else
34  fDiffY = diffY;
35 
36  Double_t diffZ;
37  if ( ! gHConfig->Lookup("Sim.DiffZ",diffZ) )
38  Info("Constructor","Use default DiffZ %g",fDiffZ);
39  else
40  fDiffZ = diffZ;
41 
42  Double_t driftVelocity;
43  if ( ! gHConfig->Lookup("Sim.DriftVelocity",driftVelocity) )
44  Info("Constructor","Use default DriftVelocity %g",fDriftVelocity);
45  else
46  fDriftVelocity = driftVelocity;
47 
48  Double_t electronCapture;
49  if ( ! gHConfig->Lookup("Sim.ElectronCapture",electronCapture) )
50  Info("Constructor","Use default ElectronCapture %g",fElectronCapture);
51  else
52  fElectronCapture = electronCapture;
53 
54  Double_t zReadout;
55  if ( ! gHConfig->Lookup("Sim.ZReadout",zReadout) )
56  Info("Constructor","Use default ZReadout %g",fZReadout);
57  else
58  fZReadout = zReadout;
59 
60  Double_t lengthTpc;
61  if ( ! gHConfig->Lookup("Sim.LengthTpc",lengthTpc) )
62  Info("Constructor","Use default ZReadout %g",fLengthTpc);
63  else
64  fLengthTpc = lengthTpc;
65 
66 }
67 
68 
69 
71 {
72 }
73 
74 
75 
76 Int_t TpcSimDriftChamber::DriftElectron(Double_t x0, Double_t y0, Double_t z0, Double_t t0, Double_t &xEnd, Double_t &yEnd, Double_t &zEnd, Double_t &tEnd)
77 {
78 
79  if(z0<fZReadout && fDriftVelocity>=0) return -1;
80  if(z0>fZReadout && fDriftVelocity<=0) return -1;
81  if(fDriftVelocity>=0){
82  if(z0<fZReadout) return -1;
83  if(z0>fZReadout + fLengthTpc) return -1;
84  }else{
85  if(z0>fZReadout) return -1;
86  if(z0<fZReadout - fLengthTpc) return -1;
87  }
88 
89  Double_t r = gRandom->Rndm();
90  if(r>TMath::Exp(-fElectronCapture*TMath::Abs(z0-fZReadout))) return 0;
91 
92  Double_t driftDistance = TMath::Abs(z0-fZReadout);
93 
94  Double_t diffX = fDiffX*TMath::Sqrt(driftDistance);
95  Double_t diffY = fDiffY*TMath::Sqrt(driftDistance);
96  Double_t diffZ = fDiffZ*TMath::Sqrt(driftDistance);
97 
98  xEnd = gRandom->Gaus(x0,diffX);
99  yEnd = gRandom->Gaus(y0,diffY);
100  driftDistance += gRandom->Gaus(0,diffZ);
101 
102  Double_t driftTime = driftDistance/TMath::Abs(fDriftVelocity);
103  tEnd = t0 + driftTime;
104 
105  // Info("DriftElectron","%f + %f = %f",t0,driftTime,tEnd);
106 
107  zEnd = fZReadout;
108 
109  return 1;
110 }
111 
Int_t DriftElectron(Double_t x0, Double_t y0, Double_t z0, Double_t t0, Double_t &xEnd, Double_t &yEnd, Double_t &zEnd, Double_t &tEnd)
Bool_t Lookup(const char *path, Bool_t &val)
Lookup function for scalar values.
HarpoConfig * gHConfig