1 | // ESAF : Euso Simulation and Analysis Framework |
---|
2 | // class PMT |
---|
3 | // $Id: Photomultiplier.hh 2604 2006-03-20 21:51:35Z thea $ |
---|
4 | // 10-4-2001 M.P. created |
---|
5 | // 26-3-2003 A.T. modified to become the base virtual class for all PMT |
---|
6 | // Simulate a multi-anode pmt |
---|
7 | |
---|
8 | #ifndef __PHOTOMULTIPLIER_HH_ |
---|
9 | #define __PHOTOMULTIPLIER_HH_ |
---|
10 | |
---|
11 | #include <vector> |
---|
12 | |
---|
13 | #include "euso.hh" |
---|
14 | #include "PmtSignal.hh" |
---|
15 | #include "Photon.hh" |
---|
16 | #include "PmtGeometry.hh" |
---|
17 | #include "EsafConfigurable.hh" |
---|
18 | #include "EsafMsgSource.hh" |
---|
19 | |
---|
20 | #define MAX_PMT_CHANNELS 64 |
---|
21 | |
---|
22 | class FrontEndChip; |
---|
23 | class MacroCell; |
---|
24 | class ElementaryCell; |
---|
25 | |
---|
26 | typedef Int_t ChannelUniqueId; |
---|
27 | |
---|
28 | enum PmtState {kPmtIdle, kPmtFilling, kPmtDone }; |
---|
29 | |
---|
30 | class Photomultiplier : public EsafConfigurable, public EsafMsgSource { |
---|
31 | protected: |
---|
32 | Photomultiplier( Int_t , PmtGeometry* ); |
---|
33 | public: |
---|
34 | virtual ~Photomultiplier(); |
---|
35 | |
---|
36 | EsafConfigClass(Electronics,Photomultiplier) |
---|
37 | |
---|
38 | // return parameters for this kind of pmt |
---|
39 | static Double_t GetQuantum() {return fgQuantum;} |
---|
40 | static Double_t GetGain() {return fgGain;} |
---|
41 | static Double_t GetGainSigma() {return fgGainSigma;} |
---|
42 | static Double_t GetWidth() {return fgWidth;} |
---|
43 | static Double_t GetGtuLength() {return fgGtuLength;} |
---|
44 | static Double_t GetDarkNoiseRate() {return fgDarkNoiseRate;} |
---|
45 | |
---|
46 | // static reset class variables |
---|
47 | static void ResetClass(); |
---|
48 | |
---|
49 | // Pmt identifier |
---|
50 | inline Int_t Id() const {return fId;} |
---|
51 | |
---|
52 | // unique id handlers |
---|
53 | // set first unique id associated to this pmt |
---|
54 | inline void SetStartUniqueId(ChannelUniqueId start) {Geometry()->SetStartUniqueId(start);} |
---|
55 | |
---|
56 | // get unique id for a given channel |
---|
57 | ChannelUniqueId GetUniqueId(Int_t ch) const; |
---|
58 | |
---|
59 | // get first unique id belonging to this pmt |
---|
60 | inline ChannelUniqueId GetStartUniqueId() const {return Geometry()->GetStartUniqueId();} |
---|
61 | |
---|
62 | // get last unique id belonging to this pmt |
---|
63 | inline ChannelUniqueId GetLastUniqueId() const {return Geometry()->GetLastUniqueId();} |
---|
64 | |
---|
65 | // get channel number (from 0 to pmtsize) given a unique id |
---|
66 | // returns -1 does not exist |
---|
67 | Int_t GetChannel(ChannelUniqueId id) const {return Geometry()->GetChannel(id);} |
---|
68 | |
---|
69 | // Pmt Status: can be kPmtIdle (after startup or reset), kPmtFilling |
---|
70 | // (after an Add call but before Simulate()) and kPmtDone (after Simulate) |
---|
71 | inline PmtState Status() const {return fState;} |
---|
72 | |
---|
73 | // number of PMT anodes |
---|
74 | virtual Int_t NumChan() const { return Geometry()->NumPads();} |
---|
75 | |
---|
76 | // returns true if n is a valid channel |
---|
77 | // channels run from 0 to NumChan()-1 |
---|
78 | virtual Bool_t isValid(Int_t n) const |
---|
79 | { if ( n>=0 && n<NumChan() ) return kTRUE; else return kFALSE;} |
---|
80 | |
---|
81 | // add a photon hit |
---|
82 | // the information is just stored. Simulation is done in Simulate() |
---|
83 | // return true if a signal was generated |
---|
84 | // return false is photon was lost |
---|
85 | // TO BE UNDERSTOOD:: reflection on the photocathode ???? |
---|
86 | virtual Bool_t Add( Photon& ); |
---|
87 | |
---|
88 | // simulation of the photons |
---|
89 | // the releated front end chip is filled with the charge |
---|
90 | // signals with the right amplitude and time |
---|
91 | void Simulate(); |
---|
92 | |
---|
93 | // reset ( delete all hits from the internal buffer ) |
---|
94 | virtual void Reset(); |
---|
95 | |
---|
96 | // pointer to the attached front end chip |
---|
97 | inline FrontEndChip* FrontEnd() { return fFrontEnd; } |
---|
98 | |
---|
99 | // pointer to attached Geometry |
---|
100 | virtual PmtGeometry* Geometry() const { return fGeometry;} |
---|
101 | |
---|
102 | // set macrocell pointer |
---|
103 | inline void SetCell(MacroCell* c) {fCell=c;} |
---|
104 | inline MacroCell* Cell() {return fCell;} |
---|
105 | |
---|
106 | // set elementary cell pointer |
---|
107 | inline void SetElemCell(ElementaryCell *p) { fEC=p; } |
---|
108 | inline ElementaryCell* ElemCell() { return fEC; } |
---|
109 | |
---|
110 | // attach a FrontEnd chip to this pmt |
---|
111 | void SetFrontEnd(FrontEndChip*, Int_t, Int_t ); |
---|
112 | |
---|
113 | Int_t FEChannel(Int_t n); |
---|
114 | |
---|
115 | inline Bool_t IsEmpty() const {return fEmpty;} |
---|
116 | inline void SetEmpty(Bool_t val) { fEmpty=val; } |
---|
117 | |
---|
118 | // start and end time |
---|
119 | inline Double_t GetStartTime() const {return fStartTime;} |
---|
120 | inline Double_t GetEndTime() const {return fEndTime;} |
---|
121 | |
---|
122 | // list of signals |
---|
123 | inline vector<PmtSignal*>& Signals(Int_t ch) { return *(fPmtHits[ch]);} |
---|
124 | |
---|
125 | // physically release the memory allocated by the arrays of this object |
---|
126 | virtual Bool_t ClearMemory(); |
---|
127 | protected: |
---|
128 | PmtState fState; // state of the PMT |
---|
129 | inline void SetState(PmtState val) {fState=val;} |
---|
130 | |
---|
131 | Int_t fId; // this pmt id number |
---|
132 | ChannelUniqueId fStartUniqueId; // unique id of first channel |
---|
133 | |
---|
134 | map<Int_t,Int_t> fFeMap; // mapping between pmt and front end channels |
---|
135 | |
---|
136 | FrontEndChip* fFrontEnd; // pointer to its front end chip |
---|
137 | PmtGeometry* fGeometry; // pointer to the geometry object |
---|
138 | MacroCell* fCell; // pointer to the macrocell |
---|
139 | ElementaryCell* fEC; // pointer to the elementary cell |
---|
140 | |
---|
141 | virtual void BuildFrontEndMap(Int_t, Int_t); // helper function to map pmt and front end |
---|
142 | |
---|
143 | // a map associating to each channel a vector that is a list of pointers to PmtSignals |
---|
144 | map<Int_t, vector<PmtSignal*>* > fPmtHits; |
---|
145 | |
---|
146 | Bool_t fEmpty; |
---|
147 | |
---|
148 | Double_t fStartTime, fEndTime; |
---|
149 | |
---|
150 | // add function for electronic test only |
---|
151 | virtual void AddTest(Double_t,Int_t); |
---|
152 | |
---|
153 | static Double_t fgQuantum; // quantum efficiency |
---|
154 | static Double_t fgGain; // nominal gain |
---|
155 | static Double_t fgGainSigma; // gain spread |
---|
156 | static Double_t fgWidth; // time width |
---|
157 | static Double_t fgDarkNoiseRate; // darknoise [microsec^-1] |
---|
158 | static Double_t fgGtuLength; // gtu length in ns |
---|
159 | |
---|
160 | friend class ElecTestDetTransManager; |
---|
161 | |
---|
162 | ClassDef(Photomultiplier,0) |
---|
163 | }; |
---|
164 | |
---|
165 | #endif |
---|