1 | #ifndef __MFadc__
|
---|
2 | #define __MFadc__
|
---|
3 | //
|
---|
4 | // class MFadc
|
---|
5 | //
|
---|
6 | // implemented by Harald Kornmayer
|
---|
7 | //
|
---|
8 | // This is a class to simulate the FADC.
|
---|
9 | // It assumes a special response of the PMT for one single Photo-electron.
|
---|
10 | //
|
---|
11 | //
|
---|
12 | //
|
---|
13 | #include <sstream>
|
---|
14 | #include <math.h>
|
---|
15 |
|
---|
16 | #include "TObject.h"
|
---|
17 | #include "TRandom.h"
|
---|
18 |
|
---|
19 | #include "Mdefine.h"
|
---|
20 |
|
---|
21 | #include "MTriggerDefine.h"
|
---|
22 | #include "MFadcDefine.h"
|
---|
23 |
|
---|
24 | class MMcEvt;
|
---|
25 |
|
---|
26 | //==========
|
---|
27 | // MFadc
|
---|
28 | //
|
---|
29 | // The simulation of the Flash ADC system for the MAGIC teleskop is done with
|
---|
30 | // this class.
|
---|
31 | // So all methods concerning the FADC System should be done inside this
|
---|
32 | // class.
|
---|
33 | //
|
---|
34 | // The Idea is to (in)put the data of the photo electrons into the class and
|
---|
35 | // generate the response (output) of the FADC to that input. Response means
|
---|
36 | // in this sense the ADC values of the different time slices for all pixels
|
---|
37 | //
|
---|
38 | // The pixelisation is done by the camera program of Jose Carlos.
|
---|
39 | //
|
---|
40 | // This class is closly connected to the MTrigger classs. So some of the
|
---|
41 | // values defined in MTriggerDefine.h are also used by this class.
|
---|
42 | //
|
---|
43 | // But a lot of other stuff is defined in MFadcDefine.h.
|
---|
44 | //
|
---|
45 | //
|
---|
46 |
|
---|
47 |
|
---|
48 | class MFadc {
|
---|
49 | private:
|
---|
50 | Int_t numpix;
|
---|
51 | Int_t fInnerPixelsNum; // number of inner (small) pixels.
|
---|
52 | //
|
---|
53 | // then for all pixels the shape of all the analog signals
|
---|
54 | //
|
---|
55 | Bool_t used[CAMERA_PIXELS] ; // a boolean to indicated if the pixels is used in this event
|
---|
56 | Float_t pedestal[CAMERA_PIXELS] ; // Pedestal of FADCs
|
---|
57 |
|
---|
58 | Int_t fSlices_mFadc; // Number of simulated FADC slices. Larger than the actual number of slices
|
---|
59 | // that will be written, since we have to account for possible delays in the
|
---|
60 | // trigger
|
---|
61 |
|
---|
62 | Int_t fResponseSlicesFadc;
|
---|
63 |
|
---|
64 | //
|
---|
65 | // Float_t sig[CAMERA_PIXELS][] ;
|
---|
66 | // the analog signal for pixels, in bins of width
|
---|
67 | // equal to the FADC slice: (default 50/15 ns), but with a
|
---|
68 | // total of fSlices_mFadc bins (default 48).
|
---|
69 | //
|
---|
70 | Float_t *sig[CAMERA_PIXELS];
|
---|
71 |
|
---|
72 | Float_t *noise;
|
---|
73 | Float_t *noise_outer;
|
---|
74 | Float_t *digital_noise;
|
---|
75 |
|
---|
76 | Float_t *output[CAMERA_PIXELS]; // the analog signal for pixels that is read after a trigger
|
---|
77 | // occurs (high gain).
|
---|
78 |
|
---|
79 | Float_t *output_lowgain[CAMERA_PIXELS]; // analog signal, low gain.
|
---|
80 |
|
---|
81 | Float_t high2low_gain;
|
---|
82 |
|
---|
83 | //
|
---|
84 | // first the data for the response function
|
---|
85 | //
|
---|
86 | Int_t shape_resp; // index shape of the phe_response function
|
---|
87 | // = 0 --> Gaussian
|
---|
88 | // = 1 --> Pulpo set-up
|
---|
89 | Float_t fwhm_resp; // fwhm of the phe_response function (in ns)
|
---|
90 | Float_t integ_resp; // area below curve of the phe_response function (in counts * ns)
|
---|
91 | Float_t *sing_resp; // the shape of the phe_response function
|
---|
92 |
|
---|
93 | Float_t fFadcSlicesPerNanosec; // Number of FADC slices per nanosecond, that is, the
|
---|
94 | // sampling frequency of the FADC.
|
---|
95 |
|
---|
96 | Int_t fFadcSlices; // Number of FADC slices that will be written on the output
|
---|
97 | // file (same number for high and low gain)
|
---|
98 |
|
---|
99 | //
|
---|
100 | // We may end up with a different reponse for the outer pixels
|
---|
101 | //
|
---|
102 | Int_t shape_resp_outer ; // index shape of the phe_response function
|
---|
103 | // = 0 --> Gaussian
|
---|
104 | // = 1 --> Pulpo set-up
|
---|
105 | Float_t fwhm_resp_outer ; // fwhm of the phe_response function (in ns)
|
---|
106 | Float_t integ_resp_outer; // area below curve of the phe_response function (in counts * ns)
|
---|
107 | Float_t *sing_resp_outer; // the shape of the phe_response function
|
---|
108 |
|
---|
109 | Int_t fGainSwitchAmp; // Height of the high gain signal (in ADC counts) at which we decide
|
---|
110 | // to fill the low gain with a scaled down version of the pulse in the
|
---|
111 | // high gain. Else we put in the continuation of the high gain.
|
---|
112 | // By default it is now 120 ADC counts (see constructor).
|
---|
113 |
|
---|
114 | Int_t fShiftFromSwitch2LowGain;
|
---|
115 | // Distance in FADC slices from the slice in which the amplitude
|
---|
116 | // fGainSwitchAmp is reached to were the switch to low gain will happen.
|
---|
117 | // By default it is now 13 slices (see constructor)
|
---|
118 |
|
---|
119 | Int_t fHi2LoGainPeak;
|
---|
120 | // Distance in FADC slices from the signal peak in the high gain to the signal peak in
|
---|
121 | // the low gain. By default we set now 16 slices (see constructor).
|
---|
122 |
|
---|
123 | //
|
---|
124 | // RandomGenerator for the Electronic Noise
|
---|
125 | //
|
---|
126 |
|
---|
127 | TRandom *GenElec ;
|
---|
128 |
|
---|
129 | Float_t fadc_time_offset; // Time offset to adjust the delay between trigger
|
---|
130 | // and the peak position in the FADC of the signal
|
---|
131 | // in the trigger pixels.
|
---|
132 |
|
---|
133 | public:
|
---|
134 |
|
---|
135 | MFadc(Int_t pix = 577,
|
---|
136 | Int_t shape = 0,
|
---|
137 | Float_t ampl = MFADC_RESPONSE_INTEGRAL,
|
---|
138 | Float_t fwhm = MFADC_RESPONSE_FWHM,
|
---|
139 | Int_t shapeout = 0,
|
---|
140 | Float_t amplout = MFADC_RESPONSE_INTEGRAL,
|
---|
141 | Float_t fwhmout = MFADC_RESPONSE_FWHM,
|
---|
142 | Float_t trig_delay = 0.,
|
---|
143 | Float_t fadc_slices_per_ns = FADC_SLICES_PER_NSEC,
|
---|
144 | Int_t fadc_slices_written = FADC_SLICES,
|
---|
145 | Int_t gainswitchamp = 120,
|
---|
146 | Int_t shiftfromswitch2lowgain = 13,
|
---|
147 | Int_t hi2logainpeak = 16);
|
---|
148 |
|
---|
149 | void SetSeed(UInt_t seed) {GenElec->SetSeed(seed);}
|
---|
150 |
|
---|
151 | void Reset() ;
|
---|
152 |
|
---|
153 | void Fill( Int_t, Float_t, Float_t, Int_t ) ;
|
---|
154 |
|
---|
155 | void Fill( Int_t, Float_t, Float_t ) ;
|
---|
156 |
|
---|
157 | void FillOuter( Int_t, Float_t, Float_t ) ;
|
---|
158 |
|
---|
159 | void Set( Int_t iPix, Float_t *res);
|
---|
160 | void AddSignal( Int_t iPix, Float_t *res);
|
---|
161 |
|
---|
162 | void SetPedestals( Int_t ped);
|
---|
163 |
|
---|
164 | void SetPedestals( Float_t *ped);
|
---|
165 |
|
---|
166 | void SetShape( Int_t inner, Int_t outer){
|
---|
167 | shape_resp=inner;
|
---|
168 | shape_resp_outer=outer;
|
---|
169 | }
|
---|
170 |
|
---|
171 | void SetFwhm( Float_t fwhm){
|
---|
172 | fwhm_resp=fwhm;
|
---|
173 | }
|
---|
174 |
|
---|
175 | void SetInteg( Float_t x){
|
---|
176 | integ_resp=x;
|
---|
177 | }
|
---|
178 |
|
---|
179 | void SetFwhmOuter( Float_t fwhm){
|
---|
180 | fwhm_resp_outer=fwhm;
|
---|
181 | }
|
---|
182 |
|
---|
183 | void SetIntegOuter( Float_t x){
|
---|
184 | integ_resp_outer=x;
|
---|
185 | }
|
---|
186 |
|
---|
187 | void Baseline();
|
---|
188 |
|
---|
189 | void Pedestals();
|
---|
190 |
|
---|
191 | void Offset( Float_t, Int_t );
|
---|
192 |
|
---|
193 | void SetElecNoise(Float_t value1=2.0, Float_t value2=2.0, UInt_t ninpix=CAMERA_PIXELS);
|
---|
194 |
|
---|
195 | void ElecNoise();
|
---|
196 |
|
---|
197 | void SetDigitalNoise(Float_t value=2.0);
|
---|
198 |
|
---|
199 | void DigitalNoise() ;
|
---|
200 |
|
---|
201 | void Scan() ;
|
---|
202 |
|
---|
203 | void Scan(Float_t time) ;
|
---|
204 |
|
---|
205 | void GetResponse( Float_t *resp ) ;
|
---|
206 |
|
---|
207 | void GetPedestals( Float_t *offset);
|
---|
208 |
|
---|
209 | Float_t GetPedestalNoise (Int_t pix, Int_t ishigh);
|
---|
210 |
|
---|
211 | Float_t AddNoiseInSlices( Int_t pix, Int_t ishigh, Int_t n_slices);
|
---|
212 |
|
---|
213 | void TriggeredFadc(Float_t time);
|
---|
214 |
|
---|
215 | void ShowSignal ( MMcEvt *McEvt , Float_t ) ;
|
---|
216 |
|
---|
217 | UChar_t GetFadcSignal(Int_t pixel, Int_t slice);
|
---|
218 |
|
---|
219 | UChar_t GetFadcLowGainSignal(Int_t pixel, Int_t slice);
|
---|
220 |
|
---|
221 | void SetHigh2LowGain(Float_t h2l) {high2low_gain=h2l;}
|
---|
222 |
|
---|
223 | Int_t GetShape() {
|
---|
224 | return shape_resp;
|
---|
225 | }
|
---|
226 |
|
---|
227 | Float_t GetIntegral() {
|
---|
228 | return integ_resp ;
|
---|
229 | }
|
---|
230 |
|
---|
231 | Float_t GetFwhm() {
|
---|
232 | return fwhm_resp ;
|
---|
233 | }
|
---|
234 |
|
---|
235 | Float_t GetIntegralOuter() {
|
---|
236 | return integ_resp_outer ;
|
---|
237 | }
|
---|
238 |
|
---|
239 | Float_t GetFwhmOuter() {
|
---|
240 | return fwhm_resp_outer ;
|
---|
241 | }
|
---|
242 |
|
---|
243 | Float_t GetFadcSlicesPerNanosec() {
|
---|
244 | return fFadcSlicesPerNanosec;
|
---|
245 | }
|
---|
246 |
|
---|
247 | Int_t GetResponseSlicesFadc() {
|
---|
248 | return fResponseSlicesFadc;
|
---|
249 | }
|
---|
250 |
|
---|
251 | Bool_t IsPixelUsed(UInt_t p){
|
---|
252 | return used[p];
|
---|
253 | }
|
---|
254 |
|
---|
255 | } ;
|
---|
256 |
|
---|
257 |
|
---|
258 | #endif
|
---|