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 | Float_t *sig_LG[CAMERA_PIXELS];
|
---|
72 |
|
---|
73 | Float_t *noise;
|
---|
74 | Float_t *noise_outer;
|
---|
75 | Float_t *digital_noise;
|
---|
76 |
|
---|
77 | Float_t *output[CAMERA_PIXELS]; // the analog signal for pixels that is read after a trigger
|
---|
78 | // occurs (high gain).
|
---|
79 |
|
---|
80 | Float_t *output_lowgain[CAMERA_PIXELS]; // analog signal, low gain.
|
---|
81 |
|
---|
82 | Float_t high2low_gain;
|
---|
83 |
|
---|
84 | //
|
---|
85 | // first the data for the response function
|
---|
86 | //
|
---|
87 | Int_t shape_resp; // index shape of the phe_response function
|
---|
88 | // = 0 --> Gaussian
|
---|
89 | // = 1 --> Pulpo set-up
|
---|
90 | Float_t fwhm_resp; // fwhm of the phe_response function (in ns)
|
---|
91 | Float_t integ_resp; // area below curve of the phe_response function (in counts * ns)
|
---|
92 | Float_t *sing_resp; // the shape of the phe_response function
|
---|
93 | Float_t *sing_resp_lowgain; // phe response for the low gain
|
---|
94 |
|
---|
95 | Float_t fFadcSlicesPerNanosec; // Number of FADC slices per nanosecond, that is, the
|
---|
96 | // sampling frequency of the FADC.
|
---|
97 |
|
---|
98 | Int_t fFadcSlices; // Number of FADC slices that will be written on the output
|
---|
99 | // file (same number for high and low gain)
|
---|
100 |
|
---|
101 | //
|
---|
102 | // We may end up with a different reponse for the outer pixels
|
---|
103 | //
|
---|
104 | Int_t shape_resp_outer ; // index shape of the phe_response function
|
---|
105 | // = 0 --> Gaussian
|
---|
106 | // = 1 --> Pulpo set-up
|
---|
107 | Float_t fwhm_resp_outer ; // fwhm of the phe_response function (in ns)
|
---|
108 | Float_t integ_resp_outer; // area below curve of the phe_response function (in counts * ns)
|
---|
109 | Float_t *sing_resp_outer; // the shape of the phe_response function
|
---|
110 | Float_t *sing_resp_outer_lowgain; // phe response for the low gain
|
---|
111 |
|
---|
112 | Int_t fGainSwitchAmp; // Height of the high gain signal (in ADC counts) at which we decide
|
---|
113 | // to fill the low gain with a scaled down version of the pulse in the
|
---|
114 | // high gain. Else we put in the continuation of the high gain.
|
---|
115 | // By default it is now 120 ADC counts (see constructor).
|
---|
116 |
|
---|
117 | Int_t fShiftFromSwitch2LowGain;
|
---|
118 | // Distance in FADC slices from the slice in which the amplitude
|
---|
119 | // fGainSwitchAmp is reached to were the switch to low gain will happen.
|
---|
120 | // By default it is now 13 slices (see constructor)
|
---|
121 |
|
---|
122 | Float_t fHi2LoGainPeak;
|
---|
123 | // Distance in FADC slices from the signal peak in the high gain to the signal peak in
|
---|
124 | // the low gain. By default we set now 16 slices (see constructor).
|
---|
125 |
|
---|
126 | //
|
---|
127 | // RandomGenerator for the Electronic Noise
|
---|
128 | //
|
---|
129 |
|
---|
130 | TRandom *GenElec ;
|
---|
131 |
|
---|
132 | Float_t fadc_time_offset; // Time offset to adjust the delay between trigger
|
---|
133 | // and the peak position in the FADC of the signal
|
---|
134 | // in the trigger pixels.
|
---|
135 |
|
---|
136 | Float_t fPulseParameters[7]; // Parameters for the parametrization of the real pulse shape
|
---|
137 | Float_t fPulseParametersLG[7]; // The same for low gain
|
---|
138 |
|
---|
139 | public:
|
---|
140 |
|
---|
141 | MFadc(Int_t pix = 577,
|
---|
142 | Int_t shape = 0,
|
---|
143 | Float_t ampl = MFADC_RESPONSE_INTEGRAL,
|
---|
144 | Float_t fwhm = MFADC_RESPONSE_FWHM,
|
---|
145 | Int_t shapeout = 0,
|
---|
146 | Float_t amplout = MFADC_RESPONSE_INTEGRAL,
|
---|
147 | Float_t fwhmout = MFADC_RESPONSE_FWHM,
|
---|
148 | Float_t trig_delay = 0.,
|
---|
149 | Float_t fadc_slices_per_ns = FADC_SLICES_PER_NSEC,
|
---|
150 | Int_t fadc_slices_written = FADC_SLICES,
|
---|
151 | Int_t gainswitchamp = 120,
|
---|
152 | Int_t shiftfromswitch2lowgain = 13,
|
---|
153 | Float_t hi2logainpeak = 16.5);
|
---|
154 |
|
---|
155 | void SetSeed(UInt_t seed) {GenElec->SetSeed(seed);}
|
---|
156 |
|
---|
157 | void Reset() ;
|
---|
158 |
|
---|
159 | void Fill( Int_t, Float_t, Float_t, Int_t ) ;
|
---|
160 |
|
---|
161 | void Fill( Int_t, Float_t, Float_t ) ;
|
---|
162 |
|
---|
163 | void FillOuter( Int_t, Float_t, Float_t ) ;
|
---|
164 |
|
---|
165 | void AddSignal( Int_t iPix, Float_t *res);
|
---|
166 |
|
---|
167 | void SetPedestals( Int_t ped);
|
---|
168 |
|
---|
169 | void SetPedestals( Float_t *ped);
|
---|
170 |
|
---|
171 | void SetShape( Int_t inner, Int_t outer){
|
---|
172 | shape_resp=inner;
|
---|
173 | shape_resp_outer=outer;
|
---|
174 | }
|
---|
175 |
|
---|
176 | void SetFwhm( Float_t fwhm){
|
---|
177 | fwhm_resp=fwhm;
|
---|
178 | }
|
---|
179 |
|
---|
180 | void SetInteg( Float_t x){
|
---|
181 | integ_resp=x;
|
---|
182 | }
|
---|
183 |
|
---|
184 | void SetFwhmOuter( Float_t fwhm){
|
---|
185 | fwhm_resp_outer=fwhm;
|
---|
186 | }
|
---|
187 |
|
---|
188 | void SetIntegOuter( Float_t x){
|
---|
189 | integ_resp_outer=x;
|
---|
190 | }
|
---|
191 |
|
---|
192 |
|
---|
193 | void Pedestals();
|
---|
194 |
|
---|
195 | void SetElecNoise(Float_t value1=2.0, Float_t value2=2.0, UInt_t ninpix=CAMERA_PIXELS);
|
---|
196 |
|
---|
197 | void ElecNoise();
|
---|
198 |
|
---|
199 | void SetDigitalNoise(Float_t value=2.0);
|
---|
200 |
|
---|
201 | void DigitalNoise() ;
|
---|
202 |
|
---|
203 | void Scan() ;
|
---|
204 |
|
---|
205 | void Scan(Float_t time) ;
|
---|
206 |
|
---|
207 | void GetResponse( Float_t *resp ) ;
|
---|
208 |
|
---|
209 | void GetPedestals( Float_t *offset);
|
---|
210 |
|
---|
211 | Float_t GetPedestalNoise (Int_t pix, Int_t ishigh);
|
---|
212 |
|
---|
213 | Float_t AddNoiseInSlices( Int_t pix, Int_t ishigh, Int_t n_slices);
|
---|
214 |
|
---|
215 | void TriggeredFadc(Float_t time);
|
---|
216 |
|
---|
217 | void ShowSignal ( MMcEvt *McEvt , Float_t ) ;
|
---|
218 |
|
---|
219 | UChar_t GetFadcSignal(Int_t pixel, Int_t slice);
|
---|
220 |
|
---|
221 | UChar_t GetFadcLowGainSignal(Int_t pixel, Int_t slice);
|
---|
222 |
|
---|
223 | void SetHigh2LowGain(Float_t h2l) {high2low_gain=h2l;}
|
---|
224 |
|
---|
225 | Int_t GetShape() {
|
---|
226 | return shape_resp;
|
---|
227 | }
|
---|
228 |
|
---|
229 | Float_t GetIntegral() {
|
---|
230 | return integ_resp ;
|
---|
231 | }
|
---|
232 |
|
---|
233 | Float_t GetFwhm() {
|
---|
234 | return fwhm_resp ;
|
---|
235 | }
|
---|
236 |
|
---|
237 | Float_t GetIntegralOuter() {
|
---|
238 | return integ_resp_outer ;
|
---|
239 | }
|
---|
240 |
|
---|
241 | Float_t GetFwhmOuter() {
|
---|
242 | return fwhm_resp_outer ;
|
---|
243 | }
|
---|
244 |
|
---|
245 | Float_t GetFadcSlicesPerNanosec() {
|
---|
246 | return fFadcSlicesPerNanosec;
|
---|
247 | }
|
---|
248 |
|
---|
249 | Int_t GetResponseSlicesFadc() {
|
---|
250 | return fResponseSlicesFadc;
|
---|
251 | }
|
---|
252 |
|
---|
253 | Bool_t IsPixelUsed(UInt_t p){
|
---|
254 | return used[p];
|
---|
255 | }
|
---|
256 |
|
---|
257 | } ;
|
---|
258 |
|
---|
259 |
|
---|
260 | #endif
|
---|