Changeset 10111 for trunk/Mars/melectronics
- Timestamp:
- 01/19/11 20:08:56 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Mars/melectronics/MAvalanchePhotoDiode.h
r9462 r10111 6 6 #endif 7 7 8 #ifndef ROOT_TSortedList 9 #include <TSortedList.h> 10 #endif 11 12 class Afterpulse : public TObject 13 { 14 private: 15 UInt_t fCellIndex; // Index of G-APD cell the afterpulse belongs to 16 17 Float_t fTime; // Time at which the afterpulse avalanch broke through 18 Float_t fAmplitude; // Amplitude (crosstalk!) the pulse produced 19 20 Int_t Compare(const TObject *obj) const 21 { 22 return static_cast<const Afterpulse*>(obj)->fTime>fTime ? -1 : 1; 23 } 24 25 Bool_t IsSortable() const { return kTRUE; } 26 27 public: 28 Afterpulse(UInt_t idx, Float_t t) : fCellIndex(idx), fTime(t), fAmplitude(0) { } 29 30 UInt_t GetCellIndex() const { return fCellIndex; } 31 32 Float_t GetTime() const { return fTime; } 33 Float_t GetAmplitude() const { return fAmplitude; } 34 35 Float_t Process(APD &apd) 36 { 37 // Do not process afterpulses twice (e.g. HitRelative + IncreaseTime) 38 // This should not happen anyway 39 // if (fAmplitude>0) 40 // return fAmplitude; 41 42 const UInt_t nx = apd.GetNumCellsX()+2; 43 44 const UInt_t x = fCellIndex%nx; 45 const UInt_t y = fCellIndex/nx; 46 47 fAmplitude = apd.HitCellImp(x, y, fTime); 48 49 return fAmplitude; 50 } 51 }; 52 8 53 class APD : public TObject // FIXME: Derive from TH2? 9 54 { 55 friend class Afterpulse; 56 10 57 private: 11 58 TH2F fHist; 12 59 13 Float_t fCrosstalkProb; // Probability that a converted photon creates another one in a neighboring cell 14 Float_t fDeadTime; // Deadtime of a single cell after a hit 15 Float_t fRecoveryTime; // Recoverytime after Deadtime (1-exp(-t/fRecoveryTime) 60 TSortedList fAfterpulses; //! List of produced afterpulses 16 61 17 Float_t fTime; // A user settable time of the system 62 Float_t fCrosstalkProb; // Probability that a converted photon creates another one in a neighboring cell 63 Float_t fDeadTime; // Deadtime of a single cell after a hit 64 Float_t fRecoveryTime; // Recoverytime after Deadtime (1-exp(-t/fRecoveryTime) 65 Float_t fAfterpulseProb[2]; // Afterpulse probabilities 66 Float_t fAfterpulseTau[2]; // Afterpulse time constants 18 67 68 Float_t fTime; // A user settable time of the system 69 70 // The implementation of the cell behaviour (crosstalk and afterpulses) 19 71 Float_t HitCellImp(Int_t x, Int_t y, Float_t t=0); 72 73 // Processing of afterpulses 74 void GenerateAfterpulse(UInt_t cell, Int_t idx, Double_t charge, Double_t t); 75 void ProcessAfterpulses(Float_t time, Float_t dt); 76 void DeleteAfterpulses(Float_t time); 20 77 21 78 public: 22 79 APD(Int_t n, Float_t prob=0, Float_t dt=0, Float_t rt=0); 23 80 24 Float_t HitCell(Int_t x, Int_t y, Float_t t=0); 25 Float_t HitRandomCell(Float_t t=0); 26 Float_t HitRandomCellRelative(Float_t t=0) { return HitRandomCell(fTime+t); } 81 // --- Setter and Getter ---- 27 82 28 void FillEmpty(Float_t t=0); 29 void FillRandom(Float_t rate, Float_t t=0); 83 // Set the afterpulse probability and time-constant of distribution 1 and 2 84 void SetAfterpulse1(Double_t p, Double_t tau) { fAfterpulseProb[0]=p; fAfterpulseTau[0]=tau; } 85 void SetAfterpulse2(Double_t p, Double_t tau) { fAfterpulseProb[1]=p; fAfterpulseTau[1]=tau; } 30 86 31 void Init(Float_t rate) { if (fTime<0) FillRandom(rate); else Relax(rate); } 87 // Set the afterpulse probability for distribution 1 and 2 88 void SetAfterpulseProb(Double_t p1, Double_t p2) { fAfterpulseProb[0]=p1; fAfterpulseProb[1]=p2; } 32 89 33 Int_t CountDeadCells(Float_t t=0) const; 34 Int_t CountRecoveringCells(Float_t t=0) const; 35 90 // Getter functions 36 91 Float_t GetCellContent(Int_t x, Int_t y) const { return fHist.GetBinContent(x, y); } 37 92 Int_t GetNumCellsX() const { return fHist.GetNbinsX(); } … … 46 101 Float_t GetLastHit() const { return fHist.GetMaximum(); } 47 102 48 void SetTime(Float_t tm) { fTime=tm; } 49 void IncreaseTime(Float_t dt) { fTime += dt; } 103 TSortedList &GetListOfAfterpulses() { return fAfterpulses; } 50 104 105 // Functions for easy production of statistics about the cells 106 Int_t CountDeadCells(Float_t t=0) const; 107 Int_t CountRecoveringCells(Float_t t=0) const; 108 109 // --- Lower level user interface --- 110 111 // Implementation to hit a specified or random cell 112 Float_t HitCell(Int_t x, Int_t y, Float_t t=0); 113 Float_t HitRandomCell(Float_t t=0); 114 115 // Functions to produce virgin chips or just effected by constant rates 116 void FillEmpty(Float_t t=0); 117 void FillRandom(Float_t rate, Float_t t=0); 118 119 // Produce random pulses with the given rate over a time dt. 120 // Processes afterpulses until the new time and deletes previous 121 // afterpulses. 51 122 Float_t Evolve(Double_t freq, Double_t dt); 123 124 // Delete Afterpulses before fTime. This might be wanted after 125 // a call to Evolve or Relax to maintain memeory usage. 126 void DeleteAfterpulses() { DeleteAfterpulses(fTime); } 127 128 // --- High level user interface --- 129 130 // This fills a G-APD with a rough estimated state at a given time 131 // T=0. It then evolves the time over the ralaxation time. If the 132 // chip is not virgin (i.e. fTime<0) the random filling is omitted 133 void Init(Float_t rate) { if (fTime<0) FillRandom(rate); Relax(rate); ShiftTime(); } 134 135 // Shifts all times including fTime by dt backwards (adds -dt) 136 // This is convenient because you can set the current time (fTime) to 0 137 void ShiftTime(Double_t dt); 138 void ShiftTime() { ShiftTime(fTime); } 139 140 // Functions producing photons hitting cells. It is meant to add 141 // many photons with an arrival time t after fTime. The photons 142 // must be sorted in time first to ensure proper treatment of the 143 // afterpulses. 144 Float_t HitRandomCellRelative(Float_t t=0) { ProcessAfterpulses(fTime, t); return HitRandomCell(fTime+t); } 145 146 // Produce random pulses with a given frequency until the influence 147 // of the effects of the G-APD (relaxation time, afterpulses) are 148 // below the given threshold. (Calls Evolve()) 149 // FIXME: Maybe the calculation of the relaxation time could be optimized? 52 150 Float_t Relax(Double_t freq, Float_t threshold=0.001) { return Evolve(freq, GetRelaxationTime(threshold)); } 53 151 152 // Issue afterpulses until fTime+dt and set fTime to fTime+dt 153 // This is needed to create all afterpulses from external pulses 154 // and afterpulses until the time fTime+dt. This makes mainly 155 // the list of afterpulses complete until fTime+dt 156 void IncreaseTime(Float_t dt) { ProcessAfterpulses(fTime, dt); fTime += dt; } 157 158 // TObject 54 159 void Draw(Option_t *o="") { fHist.Draw(o); } 55 160 void DrawCopy(Option_t *o="") { fHist.DrawCopy(o); }
Note:
See TracChangeset
for help on using the changeset viewer.