source: trunk/MagicSoft/Simulation/Detector/include-MFadc/MFadc.hxx@ 6584

Last change on this file since 6584 was 6584, checked in by moralejo, 20 years ago
*** empty log message ***
File size: 6.6 KB
Line 
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
24class 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
48class 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
113 Int_t fShiftFromSwitch2LowGain;
114 // Distance in FADC slices from the slice in which the amplitude
115 // fGainSwitchAmp is reached to were the switch to low gain will happen.
116
117 //
118 // RandomGenerator for the Electronic Noise
119 //
120
121 TRandom *GenElec ;
122
123 Float_t fadc_time_offset; // Time offset to adjust the delay between trigger
124 // and the peak position in the FADC of the signal
125 // in the trigger pixels.
126
127public:
128
129 MFadc(Int_t pix = 577,
130 Int_t shape = 0,
131 Float_t ampl = MFADC_RESPONSE_INTEGRAL,
132 Float_t fwhm = MFADC_RESPONSE_FWHM,
133 Int_t shapeout = 0,
134 Float_t amplout = MFADC_RESPONSE_INTEGRAL,
135 Float_t fwhmout = MFADC_RESPONSE_FWHM,
136 Float_t trig_delay = 0.,
137 Float_t fadc_slices_per_ns = FADC_SLICES_PER_NSEC,
138 Int_t fadc_slices_written = FADC_SLICES,
139 Int_t gainswitchamp = 120,
140 Int_t shiftfromswitch2lowgain = 13);
141
142 void SetSeed(UInt_t seed) {GenElec->SetSeed(seed);}
143
144 void Reset() ;
145
146 void Fill( Int_t, Float_t, Float_t, Int_t ) ;
147
148 void Fill( Int_t, Float_t, Float_t ) ;
149
150 void FillOuter( Int_t, Float_t, Float_t ) ;
151
152 void Set( Int_t iPix, Float_t *res);
153 void AddSignal( Int_t iPix, Float_t *res);
154
155 void SetPedestals( Int_t ped);
156
157 void SetPedestals( Float_t *ped);
158
159 void SetShape( Int_t inner, Int_t outer){
160 shape_resp=inner;
161 shape_resp_outer=outer;
162 }
163
164 void SetFwhm( Float_t fwhm){
165 fwhm_resp=fwhm;
166 }
167
168 void SetInteg( Float_t x){
169 integ_resp=x;
170 }
171
172 void SetFwhmOuter( Float_t fwhm){
173 fwhm_resp_outer=fwhm;
174 }
175
176 void SetIntegOuter( Float_t x){
177 integ_resp_outer=x;
178 }
179
180 void Baseline();
181
182 void Pedestals();
183
184 void Offset( Float_t, Int_t );
185
186 void SetElecNoise(Float_t value1=2.0, Float_t value2=2.0, UInt_t ninpix=CAMERA_PIXELS);
187
188 void ElecNoise();
189
190 void SetDigitalNoise(Float_t value=2.0);
191
192 void DigitalNoise() ;
193
194 void Scan() ;
195
196 void Scan(Float_t time) ;
197
198 void GetResponse( Float_t *resp ) ;
199
200 void GetPedestals( Float_t *offset);
201
202 Float_t GetPedestalNoise (Int_t pix, Int_t ishigh);
203
204 Float_t AddNoiseInSlices( Int_t pix, Int_t ishigh, Int_t n_slices);
205
206 void TriggeredFadc(Float_t time);
207
208 void ShowSignal ( MMcEvt *McEvt , Float_t ) ;
209
210 UChar_t GetFadcSignal(Int_t pixel, Int_t slice);
211
212 UChar_t GetFadcLowGainSignal(Int_t pixel, Int_t slice);
213
214 void SetHigh2LowGain(Float_t h2l) {high2low_gain=h2l;}
215
216 Int_t GetShape() {
217 return shape_resp;
218 }
219
220 Float_t GetIntegral() {
221 return integ_resp ;
222 }
223
224 Float_t GetFwhm() {
225 return fwhm_resp ;
226 }
227
228 Float_t GetIntegralOuter() {
229 return integ_resp_outer ;
230 }
231
232 Float_t GetFwhmOuter() {
233 return fwhm_resp_outer ;
234 }
235
236 Float_t GetFadcSlicesPerNanosec() {
237 return fFadcSlicesPerNanosec;
238 }
239
240 Int_t GetResponseSlicesFadc() {
241 return fResponseSlicesFadc;
242 }
243
244 Bool_t IsPixelUsed(UInt_t p){
245 return used[p];
246 }
247
248} ;
249
250
251#endif
Note: See TracBrowser for help on using the repository browser.