FairRoot/PandaRoot
PndMdtParamDigi.h
Go to the documentation of this file.
1 //==================================================================
2 //description
3 //parameterized digitizaiton model from garfield simulation
4 //author, Jifeng Hu, hu@to.infn.it, Torino University
5 //
6 
7 #ifndef PNDMDTPARAMDIGI_H
8 #define PNDMDTPARAMDIGI_H 1
9 
10 #include "TVector3.h"
11 #include "TGraphErrors.h"
12 #include <vector>
13 #include "TF1.h"
14 #include "TH1F.h"
15 #include "TH2F.h"
16 #include "TRandom.h"
17 #include <math.h>
18 #include <map>
19 
20 //value and its error
21 typedef std::pair<Double_t, Double_t> ValueErrorType;
22 
23 namespace CLHEP{
24 class RandGeneral;
25 }
26 
27 class PndMdtParamDigi : public TNamed
28 {
29 
30  public:
31 
34 
37  void SetVerbose(Int_t v) { fVerbose = v; }
38  //call Init before invoking the other interfaces.
39  Bool_t Init() ;
40  //signal on Anode wire
41  //==========================================================================
42  // Int_t particleType: electron, muon, pion, kaon+-, proton, indiced as 0, 1, 2, 3, 4
43  // TVector3 iniP : initial 3-momentum of this charged particle
44  // TVector3 iniPos : initial position when entering into a tube
45  // TVector3 fnlPos : final position when exiting a tube
46  //==========================================================================
47  //by default, strip lenght 100 cm
48  //this inteface should be invoked first when parameters change
49  PndMdtParamDigi& SetParams(Int_t ptlType, TVector3 iniP, TVector3 iniPos, TVector3 finalPos, Double_t stripLen=100.);
50 
51  void UseNoise(Bool_t swith) { fUseNoise = swith; }
52  void UseDetailedSim(Bool_t swith=kTRUE) { fDetailedSim = swith; }
53  void UsePlot(Bool_t swith=kTRUE) { fUsePlot = swith; }
54  void UseGaussianAmp(Bool_t swith) { fGaussianAmp = swith; }
56  void SetNoiseWidth(Double_t anode, Double_t strip) { fNoiseSigmaAnode = anode; fNoiseSigmaStrip = strip; }
57  //===============================================================
58  //readout interfaces
59  //only fired information is provided
60  //for wire, <-1, fired time>, for strips, <strip number from 0, fired time>
61  std::vector<std::pair<Int_t, Double_t> > GetFiredInfo();
62  //both anode and strip signals
63  void Compute(Bool_t useConvolution=kTRUE) ;
64  //access data of induced current
65  const std::vector<Double_t>& GetWireSignal() const { return fSignalDataAnode; }
66  const std::map<Int_t, std::vector<Double_t> > & GetStripSignals() const { return fSignalDataStripM; }
67  //===============================================================
68 
69  //plot a charged track and its produced signal
70  void Draw();
71 
72  private:
73  //anode signal only
74  void GetSignal(Bool_t useConvolution=kTRUE);
75  //get threshold-crossing time and amplitude
76  // if tube is fired, return kTRUE;
77  // in case of kTRUE, time and amplitude will be set.
78  Bool_t Digitize(Double_t& time, Double_t& amp);//anode
79  Bool_t Digitize(Int_t stripNo, Double_t& time, Double_t& amp);//strip
80  //
81  void GetRawSignalbySimAvalanche(Double_t fNoiseLevel=1.);
82  void GetRawSignalbyWeightingAvalanche(Double_t fNoiseLevel = 1.);
83  void AddNoise(Double_t fNoiseLevel = 1., Int_t isAnode=1);
84  void ApplyTransferFunction(Double_t* fSignalData, Int_t nSize=fSamplingSize);
85 
86  //by default, sampling rate is set to 100 MHz, 200 sampling points
87  static const Int_t fSamplingSize = 20;
90  std::vector<Double_t> fSignalDataAnode;
91  std::map<Int_t, std::vector<Double_t> > fSignalDataStripM;//strip no, and its corresponding signal
92  TF1* fTrF;//transfer function
94  Bool_t fGaussianAmp;//amplication model
95  Double_t fNoiseSigmaAnode ;//0.01 mu Ampere
96  Double_t fNoiseSigmaStrip ;//0.01 mu Ampere
98 
99 
100  private:
101  //drift time of primary ionized electrons to wire surface
102  inline Double_t GetElectronDriftTime(TVector2 iniPos)
103  {
104  const Double_t p0 = 5.35513e+03;
105  const Double_t p1 = 3.92749e+02;
106  const Double_t p2 = -5.41433e+03;
107  const Double_t p3 = -3.31810e+03;
108  Double_t x = iniPos.Mod() - cWIRERADIUS;
109  Double_t x1 = log(1.+x);
110  return (x*(p0 + p1*pow(x, 0.25)) + x1*(p2 + p3*x1));
111  }
112  //drift time of secondary ions from wire surface to a given point
113  inline Double_t GetShiftTime(TVector2 fWireSurfacePos, TVector2 fProductionPos)
114  {
115  const Double_t p0 = 1.81940e-8;//unit: micro sencond
116  const Double_t p1 = 1.80248;
117  const Double_t p2 = 3.68652e+2;
118  const Double_t p3 = 1.67353e+3;
119  //const Double_t mean = 0; //[R.K. 01/2017] unused variable?
120  //const Double_t sigma = 2.73477e-3;//micro second //[R.K. 01/2017] unused variable?
121  Double_t dr = (fProductionPos-fWireSurfacePos).Mod();
122  return (((p3*dr+p2)*dr+p1)*dr+p0 /*+ gRandom->Gaus(mean, sigma)*/)*1.e3;//nano sencod
123  }
124 
125  private:
126  Int_t fParticleType;//electron 0, muon 1, pion 2,
127  TVector3 fParticleMomentum;// momentum of the incident charged particle
128  TVector3 fInitPostion;
129  TVector3 fExitPosition;
133 
134 
135  void GetMPVofPrimaryIonization(Int_t particleType, const TVector3& momentum, ValueErrorType& val) const;
136  Int_t GetAmplicationFactor(Int_t particleType, Double_t momentum) const ;
137  //sampling position of secondary ion/electron for a given center
139  void SamplingPosition(TVector2 fDirection, TVector2& fIonProductionPos);
140  //mean free path function as velocity
141  TGraphErrors* gFreePath[5];//
142 
143  inline Double_t GetMeanFreePath(Int_t ptlType, Double_t mom) const
144  {
145  Double_t mMass = fRestMass[ptlType];
146  //Double_t mEnergy = sqrt(mom*mom + mMass*mMass);
147  Double_t mBeta = mom/mMass;
148  Double_t mPath = gFreePath[ptlType]->Eval(mBeta);
149  return gRandom->Exp(mPath);
150  }
151 
152  //avalanche size function
154  TH1F* hAvaSize;
155  //TH1F* hAnodeI;
156  //TH1F* hCathodeIx;
157  //TH1F* hCathodeIy;
158  //
160  static const Int_t NRAD= 100;//radial bins, not changeable
161  static const Int_t NPHI= 100;//phi bins, not changeable
162  //geometry constant
163  Double_t cWIRERADIUS ;//unit: cm
164  Double_t cCELLSIZE ;//unit: cm
165  Double_t cSTRIPWIDTH ;//unit: cm
166  Double_t cMAXRADIUS ;//not changeable
167  Double_t cMAPFACTOR ;//not changeable
168  Double_t cUNITLOGDR ;//= TMath::Log(1. + cMAPFACTOR*(cMAXRADIUS - cWIRERADIUS))/NRAD;
169  Double_t cUNITPHI ;//= TMath::Pi()*2./NPHI;
170  TH1F* hAnodeI1d[NRAD];
172  Int_t fNr[NRAD];
173  Int_t fNrNphi[NRAD*NPHI];
174 
175  //cluster initialization
176  struct ClusInfo
177  {
178  explicit ClusInfo(TVector3 _v=TVector3()): fPosition(_v) {}
179  TVector3 fPosition;
183  };
184 
185 
186  //histograms
188  TH1F* hIndex;
189  TH2F* h2dIndex;
190  TH2F* hTrack;
191  TH1F* hIonNum;
192  TH2F* hAvaPos;
193  TH1F* hAvaNum;
194  TH1F* hAva1D;
195  TH2F* hAva2D;
196  //
197  TH1F* hExp1;
198  TH1F* hExp2;
199  TH1F* hGen;
200  TH1F* hLan;
201  Int_t fVerbose;
202  //
203  public:
204  struct AvaBinType{
205  AvaBinType(Int_t _i=0, Double_t _v=0.) : Index(_i), Probabilty(_v){}
206  Int_t Index;
208  };//index, density
209  private:
210  std::vector<AvaBinType> fProbFunc1D;
211  std::vector<AvaBinType> fProbFunc2D;
212 
213  //
215  CLHEP::RandGeneral* fRandAva;
216 
218 };
219 
220 #endif
ClusInfo(TVector3 _v=TVector3())
std::pair< Double_t, Double_t > ValueErrorType
static const Int_t NRAD
Double_t fRestMass[5]
Int_t fNrNphi[NRAD *NPHI]
Double_t fNoiseSigmaStrip
void UseGaussianAmp(Bool_t swith)
Int_t GetAmplicationFactor(Int_t particleType, Double_t momentum) const
std::vector< std::pair< Int_t, Double_t > > GetFiredInfo()
Double_t val[nBoxes][nFEBox]
Definition: createCalib.C:11
void SetNoiseWidth(Double_t anode, Double_t strip)
Bool_t Digitize(Double_t &time, Double_t &amp)
friend F32vec4 log(const F32vec4 &a)
Definition: P4_F32vec4.h:110
Double_t mom
Definition: plot_dirc.C:14
Double_t GetMeanFreePath(Int_t ptlType, Double_t mom) const
__m128 v
Definition: P4_F32vec4.h:4
TH1F * hAnodeI1d[NRAD]
void AddNoise(Double_t fNoiseLevel=1., Int_t isAnode=1)
static const Int_t fSamplingSize
void GetSignal(Bool_t useConvolution=kTRUE)
Double_t fNoiseSigmaAnode
void ApplyTransferFunction(Double_t *fSignalData, Int_t nSize=fSamplingSize)
Double_t
static const Int_t NPHI
void GetMPVofPrimaryIonization(Int_t particleType, const TVector3 &momentum, ValueErrorType &val) const
void UsePlot(Bool_t swith=kTRUE)
ClassDef(PndMdtParamDigi, 1)
TVector3 fParticleMomentum
Double_t GetShiftTime(TVector2 fWireSurfacePos, TVector2 fProductionPos)
AvaBinType(Int_t _i=0, Double_t _v=0.)
TPad * p2
Definition: hist-t7.C:117
void UseDetailedSim(Bool_t swith=kTRUE)
PndMdtParamDigi & SetParams(Int_t ptlType, TVector3 iniP, TVector3 iniPos, TVector3 finalPos, Double_t stripLen=100.)
Double_t x
Double_t GetElectronDriftTime(TVector2 iniPos)
void Compute(Bool_t useConvolution=kTRUE)
std::map< Int_t, std::vector< Double_t > > fSignalDataStripM
void GetRawSignalbyWeightingAvalanche(Double_t fNoiseLevel=1.)
std::vector< AvaBinType > fProbFunc2D
void SamplingPosition(TVector2 fDirection, TVector2 &fIonProductionPos)
TPad * p1
Definition: hist-t7.C:116
void UseNoise(Bool_t swith)
std::vector< Double_t > fSignalDataAnode
const std::vector< Double_t > & GetWireSignal() const
TGraphErrors * gFreePath[5]
const std::map< Int_t, std::vector< Double_t > > & GetStripSignals() const
TVector3 fExitPosition
TH1F * hCathodeI2d[NRAD][NPHI]
CLHEP::RandGeneral * fRandAva
void SetOptimization(Int_t val)
std::vector< AvaBinType > fProbFunc1D
void SetVerbose(Int_t v)
void GetRawSignalbySimAvalanche(Double_t fNoiseLevel=1.)