]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/UPGRADE/AliITSUSimuParam.h
a786cf5522c51a8d8467ea951032b27ed10d4ea2
[u/mrichter/AliRoot.git] / ITS / UPGRADE / AliITSUSimuParam.h
1 #ifndef ALIITSUSIMUPARAM_H
2 #define ALIITSUSIMUPARAM_H
3 /* Copyright(c) 2007-2009, ALICE Experiment at CERN, All rights reserved. *
4  * See cxx source for full Copyright notice                               */
5
6
7 ///////////////////////////////////////////////////////////////////
8 //                                                               //
9 // Class to store the parameters used in the simulation ITS      //
10 //                                                               //
11 ///////////////////////////////////////////////////////////////////
12 #include <TRandom.h>
13 #include <TObject.h>
14 #include <TObjArray.h>
15 #include <TMath.h>
16 #include "AliMathBase.h"
17 class AliParamList;
18
19 class AliITSUSimuParam : public TObject {
20
21  public:
22   enum {kOldCouplingPix,kNewCouplingPix,kMaxCouplingOptPix};
23   //
24   AliITSUSimuParam();
25   AliITSUSimuParam(UInt_t nPix);
26   AliITSUSimuParam(const AliITSUSimuParam& simpar);
27   // assignment operator 
28   AliITSUSimuParam& operator=(const AliITSUSimuParam& source);
29   ~AliITSUSimuParam();
30
31   Double_t ApplyPixBaselineAndNoise(UInt_t mod) const;
32   Double_t CalcProbNoiseOverThreshold(UInt_t mod) const;
33   //
34   void     SetPixThreshold(Double_t thresh, Double_t sigma, int mod=-1);
35   void     SetPixMinElToAdd(Double_t nel)                                        {fPixMinElToAddDef = nel;}
36   void     GetPixThreshold(UInt_t mod, Double_t& thresh, Double_t& sigma) const;
37   Double_t GetPixThreshold(UInt_t mod)                                    const;
38   Double_t GetPixMinElToAdd()                                             const  {return fPixMinElToAddDef;}
39   //
40   void     SetPixNoise(Double_t noise, Double_t baseline, Int_t mod=-1);
41   void     GetPixNoise(UInt_t mod,Double_t &noise, Double_t &baseline)    const;
42   //
43   void     SetPixBiasVoltage(Double_t bias=18.182,Int_t mod=-1);
44   Double_t GetPixBiasVoltage(UInt_t mod)                                  const;
45
46  
47   void     SetGeVToCharge(Double_t gc=fgkNcompsDefault)                             {fGeVcharge = gc;}
48   Double_t GetGeVToCharge()                                                  const  {return fGeVcharge;}
49   Double_t GeVToCharge(Double_t gev)                                         const  {return gev/fGeVcharge;}
50   //
51   void     SetPixCouplingOption(UInt_t opt);
52   UInt_t   GetPixCouplingOption()                                         const  {return fPixCouplOpt;}
53
54   void     SetPixCouplingParam(Double_t col, Double_t row)                       {fPixCouplCol = col; fPixCouplRow = row;}
55   void     GetPixCouplingParam(Double_t &col, Double_t &row)              const  {col = fPixCouplCol; row = fPixCouplRow;}
56
57   void     SetPixLorentzDrift(Bool_t ison)                                       {fPixLorentzDrift=ison;}
58   Bool_t   GetPixLorentzDrift()                                           const  {return fPixLorentzDrift;}
59   void     SetPixLorentzHoleWeight(Double_t weight)                               {fPixLorentzHoleWeight=weight;}
60   Double_t GetPixLorentzHoleWeight()                                      const  {return fPixLorentzHoleWeight;}
61   
62   void     SetPixAddNoisyFlag(Bool_t value)                                      {fPixAddNoisyFlag = value;}
63   Bool_t   GetPixAddNoisyFlag()                                           const  {return fPixAddNoisyFlag;}
64   void     SetPixRemoveDeadFlag(Bool_t value)                                    {fPixRemoveDeadFlag = value;}
65   Bool_t   GetPixRemoveDeadFlag()                                         const  {return fPixRemoveDeadFlag;}
66   //
67   Double_t LorentzAngleElectron(Double_t bz)                                 const;
68   Double_t LorentzAngleHole(Double_t bz)                                     const;
69   //
70   Int_t    GetNRespFunParams()                                               const {return fRespFunParam.GetEntriesFast();}
71   const AliParamList* GetRespFunParams(Int_t i)                              const {return (const AliParamList*)fRespFunParam[i];}
72   const AliParamList* FindRespFunParams(Int_t detId)                         const;
73   void     AddRespFunParam(AliParamList* pr);
74   //
75   virtual void Print(Option_t *opt = "")                                     const; 
76   //
77   static Double_t CalcProbNoiseOverThreshold(double base, double noise, double thresh);
78   static Double_t GenerateNoiseQFunction(double prob, double mean, double sigma);
79   //
80  protected:
81
82   static const Double_t fgkPixBiasVoltageDefault;//default for fPixBiasVoltage
83   static const Double_t fgkPixThreshDefault; //default for fThresh
84   static const Double_t fgkPixMinElToAddDefault; // default min number of electrons to add to sdigit
85   static const Double_t fgkPixThrSigmaDefault; //default for fSigma
86   static const Double_t fgkPixCouplColDefault; //default for fPixCouplCol
87   static const Double_t fgkPixCouplRowDefault; //default for fPixCouplRow
88   static const Double_t fgkPixEccDiffDefault;//default for fPixEccDiff
89   static const Double_t fgkPixLorentzHoleWeightDefault;//default for fPixLorentzHoleWeight
90   static const UInt_t   fgkPixCouplingOptDefault;  // type of pixel Coupling (old or new)
91   static const Double_t fgkDOverVDefault;             // default distance over voltage 
92   static const Double_t fgkGeVtoChargeDefault;        // default energy to ionize (free an electron) in GeV
93   static const Double_t fgkTDefault;                  // default temperature
94
95   static const Double_t fgkNsigmasDefault; //default for fNsigmas
96   static const Int_t fgkNcompsDefault; //default for fNcomps
97
98  private:
99   //
100   Double_t   fGeVcharge;          // Energy to ionize (free an electron) in GeV
101   Double_t   fDOverV;             // The parameter d/v where d is the disance over which the the potential v is applied d/v [cm/volts]
102   Double_t   fT;                  // The temperature of the Si in Degree K.
103   //
104   UInt_t     fNPix;            // number of Pix type detectors
105   UInt_t     fPixCouplOpt;     // Pix Coupling Option
106   Double_t   fPixCouplCol;     // Pix Coupling parameter along the cols
107   Double_t   fPixCouplRow;     // Pix Coupling parameter along the rows
108   Bool_t     fPixLorentzDrift;     // Flag to decide whether to simulate the Lorentz Drift or not in Pix
109   Double_t   fPixLorentzHoleWeight;// Lorentz Angle is computed for Pix as average of Hole and Electron
110   //                                    this parameter gives the relative weights between the two
111   Bool_t     fPixAddNoisyFlag;     // Flag saying whether noisy pixels should be added to digits
112   Bool_t     fPixRemoveDeadFlag;   // Flag saying whether dead pixels should be removed from digits
113   //
114   Double_t   fPixThreshDef;      // Pix Threshold value
115   Double_t   fPixThrSigmaDef;    // Pix Threshold fluctuation
116   Double_t   fPixBiasVoltageDef; // Bias Voltage for the Pix
117   Double_t   fPixNoiseDef;       // Pix electronic noise: sigma
118   Double_t   fPixBaselineDef;    // Pix electronic noise: baseline
119   Double_t   fPixMinElToAddDef;  // min number of electrons to add
120   //
121   Double_t*  fPixThresh;      //[fNPix] Pix Threshold value
122   Double_t*  fPixThrSigma;    //[fNPix] Pix Threshold fluctuation
123   Double_t*  fPixBiasVoltage; //[fNPix] Bias Voltage for the Pix
124   Double_t*  fPixSigma;       //[fNPix] Pix threshold fluctuations spread
125   Double_t*  fPixNoise;       //[fNPix] Pix electronic noise: sigma
126   Double_t*  fPixBaseline;    //[fNPix] Pix electronic noise: baseline
127   //
128   TObjArray  fRespFunParam;   // set of parameterizations for response function (AliParamList)
129
130   ClassDef(AliITSUSimuParam,1);  // ITSU simulataion params
131 };
132
133 //_______________________________________________________________________
134 inline Double_t AliITSUSimuParam::CalcProbNoiseOverThreshold(double mean, double sigma, double thresh) 
135 {
136   // calculate probability of gaussian noise exceeding the threshold
137   if (mean+6*sigma<thresh) return 0;
138   if (mean-6*sigma>thresh) return 1.;
139   const double ksqrt2 = 1.41421356237309515e+00;
140   return 0.5*AliMathBase::ErfcFast( (thresh-mean)/(sigma*ksqrt2));
141 }
142
143 //_______________________________________________________________________
144 inline Double_t AliITSUSimuParam::GenerateNoiseQFunction(double prob, double mean, double sigma) 
145 {
146   // generate random noise exceeding threshold probability prob, i.e. find a random point in the right
147   // tail of the gaussian(base,noise), provided that the tail integral = prob
148   const double ksqrt2 = 1.41421356237309515e+00;
149   return mean+sigma*ksqrt2*TMath::ErfcInverse(2*prob*(1.-gRandom->Rndm()));
150 }
151
152
153
154 #endif