1 | ////////////////////////////////////////////////////////////////
|
---|
2 | //
|
---|
3 | // MFadc
|
---|
4 | //
|
---|
5 | //
|
---|
6 | #include "MFadc.hxx"
|
---|
7 |
|
---|
8 | #include "MMcEvt.hxx"
|
---|
9 |
|
---|
10 | #include "TROOT.h"
|
---|
11 | #include <TApplication.h>
|
---|
12 | #include <TVirtualX.h>
|
---|
13 | #include <TGClient.h>
|
---|
14 |
|
---|
15 | #include "TH1.h"
|
---|
16 | #include "TObjArray.h"
|
---|
17 |
|
---|
18 | #include "MGFadcSignal.hxx"
|
---|
19 |
|
---|
20 | using namespace std;
|
---|
21 |
|
---|
22 | MFadc::MFadc(Int_t pix, Int_t shape, Float_t integral, Float_t fwhm,
|
---|
23 | Int_t shapeout, Float_t integralout, Float_t fwhmout,
|
---|
24 | Float_t trigger_delay, Float_t fadc_slices_per_ns,
|
---|
25 | Int_t fadc_slices_written, Int_t gainswitchamp,
|
---|
26 | Int_t shiftfromswitch2lowgain, Int_t hi2logainpeak) {
|
---|
27 | //
|
---|
28 | // Constructor overloaded II
|
---|
29 | //
|
---|
30 | // Input variables:
|
---|
31 | // 1. integral(out) = integration of the single phe response for inner
|
---|
32 | // (outer) pixels.
|
---|
33 | // 2. fwhm(out) = width at half high of the single phe response for
|
---|
34 | // inner (outer) pixels.
|
---|
35 | //
|
---|
36 | // trigger_delay: shift of signals towards later times in FADC, in order
|
---|
37 | // to center the signals in a good range. It acts as a sort of delay of
|
---|
38 | // the signals (before being sent to the FADC) with respect to the trigger.
|
---|
39 | //
|
---|
40 | // The procedure is the following:
|
---|
41 | // 1. some parameters of the trigger are set to default.
|
---|
42 | // this parameters of the trigger may be changed
|
---|
43 | // 3. Then the all signals are set to zero
|
---|
44 |
|
---|
45 | numpix=pix;
|
---|
46 |
|
---|
47 | fwhm_resp = fwhm;
|
---|
48 | integ_resp = integral;
|
---|
49 | fwhm_resp_outer = fwhmout;
|
---|
50 | integ_resp_outer = integralout;
|
---|
51 | shape_resp = shape;
|
---|
52 | shape_resp_outer = shapeout;
|
---|
53 | fFadcSlicesPerNanosec = fadc_slices_per_ns;
|
---|
54 | fFadcSlices = fadc_slices_written;
|
---|
55 | fGainSwitchAmp = gainswitchamp;
|
---|
56 | fShiftFromSwitch2LowGain = shiftfromswitch2lowgain;
|
---|
57 | fHi2LoGainPeak = hi2logainpeak;
|
---|
58 |
|
---|
59 | fSlices_mFadc = (Int_t)(TOTAL_TRIGGER_TIME*fFadcSlicesPerNanosec);
|
---|
60 |
|
---|
61 | for (Int_t i = 0; i < CAMERA_PIXELS; i++)
|
---|
62 | sig[i] = new Float_t[fSlices_mFadc];
|
---|
63 |
|
---|
64 | noise = new Float_t[fSlices_mFadc*1001];
|
---|
65 | noise_outer = new Float_t[fSlices_mFadc*1001];
|
---|
66 | digital_noise = new Float_t[fSlices_mFadc*1001];
|
---|
67 |
|
---|
68 | for (Int_t i = 0; i < CAMERA_PIXELS; i++)
|
---|
69 | {
|
---|
70 | output[i] = new Float_t[fFadcSlices];
|
---|
71 | output_lowgain[i] = new Float_t[fFadcSlices];
|
---|
72 | }
|
---|
73 |
|
---|
74 | cout<< "[MFadc] Setting up the MFadc with this values "<< endl ;
|
---|
75 | cout<< "[MFadc] FADC sampling frequency: " << fFadcSlicesPerNanosec << " GHz" << endl ;
|
---|
76 | cout<< "[MFadc] - Inner pixels : "<< endl ;
|
---|
77 |
|
---|
78 | switch(shape_resp){
|
---|
79 | case 0:
|
---|
80 | cout<< "[MFadc] Pulse shape : Gaussian ("<<shape_resp<<")"<< endl ;
|
---|
81 | cout<< "[MFadc] Response Area : "<<integ_resp<<" adc counts"<< endl ;
|
---|
82 | cout<< "[MFadc] Response FWHM : "<<fwhm_resp<<" ns"<< endl ;
|
---|
83 | break;
|
---|
84 | case 1:
|
---|
85 | cout<< "[MFadc] Pulse shape : From Pulpo ("<<shape_resp<<")"<< endl ;
|
---|
86 | cout<< "[MFadc] Response Area : "<<integ_resp<<" adc counts"<< endl ;
|
---|
87 | break;
|
---|
88 | default:
|
---|
89 | cout<< "[MFadc] Pulse shape unknown"<<endl;
|
---|
90 | }
|
---|
91 | cout<< "[MFadc] - Outer pixels : "<< endl ;
|
---|
92 | switch(shape_resp_outer){
|
---|
93 | case 0:
|
---|
94 | cout<< "[MFadc] Pulse shape : Gaussian ("<<shape_resp_outer<<")"<<endl;
|
---|
95 | cout<< "[MFadc] Response Area : "<<integ_resp_outer<<" adc counts"<<endl;
|
---|
96 | cout<< "[MFadc] Response FWHM : "<<fwhm_resp_outer<<" ns"<< endl ;
|
---|
97 | break;
|
---|
98 | case 1:
|
---|
99 | cout<< "[MFadc] Pulse shape : From Pulpo ("<<shape_resp_outer<<")"<<endl;
|
---|
100 | cout<< "[MFadc] Response Area : "<<integ_resp_outer<<" adc counts"<< endl ;
|
---|
101 | break;
|
---|
102 | default:
|
---|
103 | cout<< "[MFadc] Pulse shape unknown ("<<shape_resp_outer<<")"<<endl;
|
---|
104 | }
|
---|
105 |
|
---|
106 |
|
---|
107 | //
|
---|
108 | // set up the response shape
|
---|
109 | //
|
---|
110 |
|
---|
111 | //
|
---|
112 | // First select number of bins for the histogram which will contain the single
|
---|
113 | // photoelectron response of the FADC. The width of these bins is smaller than that
|
---|
114 | // of the real FADC slices by a factor SUBBINS (see MFadcDefine.h):
|
---|
115 | //
|
---|
116 | if (shape_resp == 1)
|
---|
117 | fResponseSlicesFadc = (Int_t)(50.*fFadcSlicesPerNanosec*SUBBINS);
|
---|
118 | // 50 ns range
|
---|
119 |
|
---|
120 | else
|
---|
121 | fResponseSlicesFadc = (Int_t)(7*fwhm_resp/2.35*fFadcSlicesPerNanosec*SUBBINS);
|
---|
122 | // 7 sigma range
|
---|
123 |
|
---|
124 | sing_resp = new Float_t[fResponseSlicesFadc];
|
---|
125 | sing_resp_outer = new Float_t[fResponseSlicesFadc];
|
---|
126 |
|
---|
127 | Int_t i ;
|
---|
128 |
|
---|
129 | Float_t sigma ;
|
---|
130 | Float_t x, x0 ;
|
---|
131 | Float_t dX, dX2 ;
|
---|
132 |
|
---|
133 | Float_t response_sum_inner, response_sum_outer;
|
---|
134 | response_sum_inner = 0.;
|
---|
135 | response_sum_outer = 0.;
|
---|
136 |
|
---|
137 | dX = 1. / fFadcSlicesPerNanosec / SUBBINS ; // Units: ns
|
---|
138 | dX2 = dX/2. ;
|
---|
139 |
|
---|
140 | switch(shape_resp){
|
---|
141 |
|
---|
142 | case 0:
|
---|
143 | sigma = fwhm_resp / 2.35 ;
|
---|
144 | x0 = 3*sigma;
|
---|
145 | fadc_time_offset = trigger_delay-x0; // ns
|
---|
146 |
|
---|
147 | for (i = 0; i < fResponseSlicesFadc ; i++ )
|
---|
148 | {
|
---|
149 | x = i * dX + dX2 ;
|
---|
150 |
|
---|
151 | sing_resp[i] = (Float_t)(expf(-0.5*(x-x0)*(x-x0)/(sigma*sigma)));
|
---|
152 |
|
---|
153 | response_sum_inner += sing_resp[i];
|
---|
154 | }
|
---|
155 |
|
---|
156 | break;
|
---|
157 | case 1:
|
---|
158 | float p1,p2,p3,p4,p5,p6,p7;
|
---|
159 | float d;
|
---|
160 | float zed_slices;
|
---|
161 | // Parameters values extracted from fitting a real FADC response
|
---|
162 | // gaussian electronic pulse passed through the whole chain from
|
---|
163 | // transmitter boards to FADC.
|
---|
164 | p1 = 2.066;
|
---|
165 | p2 = 1.568;
|
---|
166 | p3 = 3; // This will set the peak of the pulse at x ~ 3*3.3 = 10 ns
|
---|
167 | // It is just a safe value so that the pulse is well contained.
|
---|
168 | p4 = 0.00282;
|
---|
169 | p5 = 0.04093;
|
---|
170 | p6 = 0.2411;
|
---|
171 | p7 = -0.009442;
|
---|
172 |
|
---|
173 | // Now define the time before trigger to read FADC signal when it
|
---|
174 | // has to be written. Here FADC_SLICES_PER_NSEC (=0.3) is the value
|
---|
175 | // for the 300 MHz MAGIC FADCs and must NOT be changed, even if you
|
---|
176 | // use a faster sampling in the simulation (through the input card
|
---|
177 | // command "fadc_GHz"), because this is just a conversion of units. The
|
---|
178 | // parameters of the "pulpo" pulse shape were obtained with the 300 MHz
|
---|
179 | // FADC and so we convert the time parameter to units of 3.3 ns slices
|
---|
180 | // just to use the provided parametrization, and no matter what sampling
|
---|
181 | // frequency we are simulating!
|
---|
182 |
|
---|
183 | fadc_time_offset = trigger_delay - p3 / FADC_SLICES_PER_NSEC; // ns
|
---|
184 |
|
---|
185 | for (i=0; i< fResponseSlicesFadc ; i++ )
|
---|
186 | {
|
---|
187 | x = i * dX + dX2;
|
---|
188 |
|
---|
189 | // x has to be converted from ns to units FADC slices of the default
|
---|
190 | // FADC of 300 MHz (these are just units, and must be these even if you
|
---|
191 | // are using another sampling frequency!):
|
---|
192 | //
|
---|
193 | zed_slices = x * FADC_SLICES_PER_NSEC - p3;
|
---|
194 | d=(zed_slices>0)?0.5:-0.5;
|
---|
195 |
|
---|
196 | sing_resp[i] = (Float_t) (p1*exp(-p2*(exp(-p2*zed_slices)+zed_slices))+
|
---|
197 | p4+p5*exp(-p2*(exp(-p2*zed_slices)+
|
---|
198 | p6*zed_slices))+p7*d);
|
---|
199 |
|
---|
200 | response_sum_inner += sing_resp[i];
|
---|
201 | }
|
---|
202 |
|
---|
203 | break;
|
---|
204 | default:
|
---|
205 | cout<<"[MFadc] MFadc::MFadc : Shape of FADC pulse for inner pixel unknown."
|
---|
206 | <<endl;
|
---|
207 | cout<<"[MFadc] MFadc::MFadc : Exiting Camera ..."
|
---|
208 | <<endl;
|
---|
209 | exit(1);
|
---|
210 | }
|
---|
211 |
|
---|
212 | // Response for outer pixels
|
---|
213 |
|
---|
214 | switch(shape_resp_outer){
|
---|
215 |
|
---|
216 | case 0:
|
---|
217 | sigma = fwhm_resp_outer / 2.35 ;
|
---|
218 | x0 = 3*sigma ;
|
---|
219 | fadc_time_offset = trigger_delay-x0; // ns
|
---|
220 |
|
---|
221 | for (i = 0; i < fResponseSlicesFadc ; i++ )
|
---|
222 | {
|
---|
223 | x = i * dX + dX2 ;
|
---|
224 |
|
---|
225 | //
|
---|
226 | // the value 1/sqrt(2*Pi*sigma^2) was introduced to normalize
|
---|
227 | // the area at the input value After this, the integral
|
---|
228 | // of the response will be integ_resp.
|
---|
229 | //
|
---|
230 | sing_resp_outer[i] = (Float_t) (expf(-0.5 * (x-x0)*(x-x0) /
|
---|
231 | (sigma*sigma)) ) ;
|
---|
232 | response_sum_outer += sing_resp_outer[i];
|
---|
233 | }
|
---|
234 | break;
|
---|
235 | case 1:
|
---|
236 | float p1,p2,p3,p4,p5,p6,p7;
|
---|
237 | float d;
|
---|
238 | float zed_slices;
|
---|
239 | // Parameters values extracted from fitting a real FADC response
|
---|
240 | // gaussian electronic pulse passed through the whole chain from
|
---|
241 | // transmitter boards to FADC.
|
---|
242 | p1 = 2.066;
|
---|
243 | p2 = 1.568;
|
---|
244 | p3 = 3; // This sets the peak of the pulse at x ~ 3*3.3 = 10 nanosec
|
---|
245 | // It is just a safe value so that the pulse is well contained.
|
---|
246 | p4 = 0.00282;
|
---|
247 | p5 = 0.04093;
|
---|
248 | p6 = 0.2411;
|
---|
249 | p7 = -0.009442;
|
---|
250 |
|
---|
251 | // Now define the time before trigger to read FADC signal when it
|
---|
252 | // has to be written. Here FADC_SLICES_PER_NSEC (=0.3) is the value
|
---|
253 | // for the 300 MHz MAGIC FADCs and must NOT be changed, even if you
|
---|
254 | // use a faster sampling in the simulation (through the input card
|
---|
255 | // command "fadc_GHz"), because this is just a conversion of units. The
|
---|
256 | // parameters of the "pulpo" pulse shape were obtained with the 300 MHz
|
---|
257 | // FADC and so we convert the time parameter to units of 3.3 ns slices
|
---|
258 | // just to use the provided parametrization, and no matter what sampling
|
---|
259 | // frequency we are simulating!
|
---|
260 |
|
---|
261 | fadc_time_offset = trigger_delay - p3 / FADC_SLICES_PER_NSEC; // ns
|
---|
262 |
|
---|
263 | for (i=0; i< fResponseSlicesFadc ; i++ )
|
---|
264 | {
|
---|
265 | x = i * dX + dX2;
|
---|
266 |
|
---|
267 | // x has to be converted from ns to units FADC slices of the default
|
---|
268 | // FADC of 300 MHz (these are just units, and must be these even if you
|
---|
269 | // are using another sampling frequency!):
|
---|
270 | //
|
---|
271 | zed_slices = x * FADC_SLICES_PER_NSEC - p3;
|
---|
272 | d=(zed_slices>0)?0.5:-0.5;
|
---|
273 |
|
---|
274 | sing_resp_outer[i] = (Float_t) (p1*exp(-p2*(exp(-p2*zed_slices)+
|
---|
275 | zed_slices))+p4+
|
---|
276 | p5*exp(-p2*(exp(-p2*zed_slices)+
|
---|
277 | p6*zed_slices))+p7*d);
|
---|
278 | response_sum_outer += sing_resp_outer[i];
|
---|
279 | }
|
---|
280 | break;
|
---|
281 | default:
|
---|
282 | cout<<"[MFadc] MFadc::MFadc : Shape of FADC pulse for inner pixel unknown."
|
---|
283 | <<endl;
|
---|
284 | cout<<"[MFadc] MFadc::MFadc : Exiting Camera ..."
|
---|
285 | <<endl;
|
---|
286 | exit(1);
|
---|
287 | }
|
---|
288 |
|
---|
289 | //
|
---|
290 | // Normalize responses to values set trhough input card: (= set gain of electronic chain)
|
---|
291 | // Take into account that only 1 of every SUBBINS bins of sing_resp[] will be "sampled" by
|
---|
292 | // the FADC, so we have to correct for this to get the right "FADC integral" (=integ_resp)
|
---|
293 | // per photoelectron:
|
---|
294 | //
|
---|
295 |
|
---|
296 | for (i=0; i< fResponseSlicesFadc ; i++ )
|
---|
297 | {
|
---|
298 | sing_resp[i] *= integ_resp / response_sum_inner * SUBBINS;
|
---|
299 | sing_resp_outer[i] *= integ_resp_outer / response_sum_outer * SUBBINS;
|
---|
300 | }
|
---|
301 |
|
---|
302 | //
|
---|
303 | // init the Random Generator for Electonic Noise
|
---|
304 | //
|
---|
305 |
|
---|
306 | GenElec = new TRandom () ;
|
---|
307 |
|
---|
308 | Reset();
|
---|
309 |
|
---|
310 | //
|
---|
311 | // set all pedestals to 0
|
---|
312 | //
|
---|
313 |
|
---|
314 | for ( i =0 ; i <CAMERA_PIXELS ; i++ ) {
|
---|
315 | pedestal[i] = 0.0 ;
|
---|
316 | }
|
---|
317 |
|
---|
318 | cout<<" end of MFadc::MFadc()"<<endl;
|
---|
319 | }
|
---|
320 |
|
---|
321 | void MFadc::Reset() {
|
---|
322 | //
|
---|
323 | // set all values of the signals to zero
|
---|
324 | // set the values of FADC slices that would be read after trigger to zero
|
---|
325 | //
|
---|
326 | memset(used, 0, CAMERA_PIXELS*sizeof(Bool_t));
|
---|
327 |
|
---|
328 | for (Int_t i = 0; i < CAMERA_PIXELS; i++)
|
---|
329 | {
|
---|
330 | memset(output[i], 0, fFadcSlices*sizeof(Float_t));
|
---|
331 | memset(output_lowgain[i], 0, fFadcSlices*sizeof(Float_t));
|
---|
332 | }
|
---|
333 |
|
---|
334 | //
|
---|
335 | // Added 15 01 2004, AM:
|
---|
336 | //
|
---|
337 | for (Int_t i = 0; i < CAMERA_PIXELS; i++)
|
---|
338 | memset(sig[i], 0, (Int_t)(fSlices_mFadc*sizeof(Float_t)));
|
---|
339 | }
|
---|
340 | void MFadc::Fill( Int_t iPix, Float_t time,
|
---|
341 | Float_t amplitude, Int_t isinner ) {
|
---|
342 |
|
---|
343 | // AM, Jan 2004 : added delay to shift the signal peak to the desired
|
---|
344 | // range in the FADC window (indicated through the trigger_delay command
|
---|
345 | // in the camera input card.
|
---|
346 |
|
---|
347 | time += fadc_time_offset;
|
---|
348 |
|
---|
349 | if(isinner)
|
---|
350 | Fill(iPix, time, amplitude);
|
---|
351 | else
|
---|
352 | FillOuter(iPix, time, amplitude);
|
---|
353 |
|
---|
354 | }
|
---|
355 | void MFadc::Fill( Int_t iPix, Float_t time, Float_t amplitude ) {
|
---|
356 |
|
---|
357 | //
|
---|
358 | // fills the information about one single Phe in the Trigger class
|
---|
359 | //
|
---|
360 | // Parameters are the number of the pixel and the time-difference to the
|
---|
361 | // first photon.
|
---|
362 | //
|
---|
363 | //
|
---|
364 | // AM, Jan 2004: Replaced former FADC simulation (integration of signal)
|
---|
365 | // with a more realistic one (measuring signal height at discrete points).
|
---|
366 | //
|
---|
367 |
|
---|
368 |
|
---|
369 | Int_t i, ichan, ichanfadc ;
|
---|
370 |
|
---|
371 | //
|
---|
372 | // first we have to check if the pixel iPix is used or not until now
|
---|
373 | // if this is the first use, reset all signal for that pixel
|
---|
374 | //
|
---|
375 | if ( iPix > numpix )
|
---|
376 | {
|
---|
377 | cout << " WARNING: MFadc::Fill() : iPix greater than Pixels in Camera = "
|
---|
378 | << numpix
|
---|
379 | << endl;
|
---|
380 | exit(987);
|
---|
381 | }
|
---|
382 |
|
---|
383 | if ( used[iPix] == FALSE )
|
---|
384 | {
|
---|
385 | used [iPix] = TRUE;
|
---|
386 |
|
---|
387 | for (i=0; i < (Int_t) fSlices_mFadc; i++ )
|
---|
388 | sig[iPix][i] = 0.;
|
---|
389 | }
|
---|
390 |
|
---|
391 | //
|
---|
392 | // then select the time slice to use (ichan)
|
---|
393 | //
|
---|
394 |
|
---|
395 | if ( time < TOTAL_TRIGGER_TIME+fadc_time_offset ) {
|
---|
396 | //
|
---|
397 | // Convert time into units of the width of the analog
|
---|
398 | // signal histogram, sing_resp:
|
---|
399 | //
|
---|
400 | ichan = (Int_t) ( time * fFadcSlicesPerNanosec * SUBBINS);
|
---|
401 |
|
---|
402 | //
|
---|
403 | // putting the response slices in the right sig slices.
|
---|
404 | // Be careful, because both slices have different widths.
|
---|
405 | //
|
---|
406 |
|
---|
407 | // We want to put the single phe response given by sing_resp into the
|
---|
408 | // array sig[][], but only one of each SUBBINS bins, since the binning
|
---|
409 | // of sing_resp is finer than that of sig[][]. We want that the start of
|
---|
410 | // sing_resp coincides with the time "time" with respect to the begining
|
---|
411 | // of sig[][]
|
---|
412 |
|
---|
413 | // We take the pulse height in the middle of FADC slices, we start in the
|
---|
414 | // first such point after the time "time" (=ichan in response bins). Each
|
---|
415 | // FADC slice corresponds to SUBBINS response bins (SUBBINS=5 by default).
|
---|
416 |
|
---|
417 | Int_t first_i = Int_t(SUBBINS/2) - ichan%(Int_t)SUBBINS;
|
---|
418 | first_i = first_i < 0 ? (Int_t)SUBBINS+first_i : first_i; //
|
---|
419 | //
|
---|
420 | // first_i is the first bin of sing_resp which matches the center of one
|
---|
421 | // bin of sig[][]
|
---|
422 | //
|
---|
423 |
|
---|
424 | for ( i = first_i ; i < (Int_t)fResponseSlicesFadc; i += (Int_t)SUBBINS)
|
---|
425 | {
|
---|
426 | ichanfadc = (Int_t) ((ichan+i)/SUBBINS) ;
|
---|
427 | if ( ichanfadc < 0 )
|
---|
428 | continue;
|
---|
429 |
|
---|
430 | //
|
---|
431 | // fSlices_mFadc is by default 48. sig[][] is not the true FADC, which
|
---|
432 | // is filled (from sig[][]) in MFadc::TriggeredFadc()
|
---|
433 | //
|
---|
434 | if ( (ichanfadc) < (Int_t) fSlices_mFadc )
|
---|
435 | sig[iPix][ichanfadc] += (amplitude * sing_resp[i] );
|
---|
436 | }
|
---|
437 |
|
---|
438 | }
|
---|
439 | else
|
---|
440 | cout << " WARNING! Fadc::Fill " << time << " out of TriggerTimeRange "
|
---|
441 | << TOTAL_TRIGGER_TIME+fadc_time_offset << endl ;
|
---|
442 |
|
---|
443 | }
|
---|
444 |
|
---|
445 | void MFadc::FillOuter( Int_t iPix, Float_t time, Float_t amplitude ) {
|
---|
446 |
|
---|
447 | //
|
---|
448 | // fills the information about one single Phe in the Trigger class
|
---|
449 | // for an outer pixel
|
---|
450 | //
|
---|
451 | // See explanations of the code in function Fill() above
|
---|
452 | //
|
---|
453 |
|
---|
454 | Int_t i, ichan, ichanfadc ;
|
---|
455 |
|
---|
456 | if ( iPix > numpix )
|
---|
457 | {
|
---|
458 | cout << " WARNING: MFadc::FillOuter() : iPix greater than CAMERA_PIXELS"
|
---|
459 | << endl ;
|
---|
460 | exit(987) ;
|
---|
461 | }
|
---|
462 |
|
---|
463 | if ( used[iPix] == FALSE )
|
---|
464 | {
|
---|
465 | used [iPix] = TRUE ;
|
---|
466 |
|
---|
467 | for (i=0; i < (Int_t) fSlices_mFadc; i++)
|
---|
468 | sig[iPix][i] = 0.;
|
---|
469 | }
|
---|
470 |
|
---|
471 |
|
---|
472 | if ( time < TOTAL_TRIGGER_TIME+fadc_time_offset ) {
|
---|
473 |
|
---|
474 | ichan = (Int_t) ( time * fFadcSlicesPerNanosec * SUBBINS);
|
---|
475 |
|
---|
476 | Int_t first_i = Int_t(SUBBINS/2) - ichan%(Int_t)SUBBINS;
|
---|
477 | first_i = first_i < 0 ? (Int_t)SUBBINS+first_i : first_i;
|
---|
478 |
|
---|
479 | for ( i = first_i ; i < (Int_t)fResponseSlicesFadc; i += (Int_t)SUBBINS)
|
---|
480 | {
|
---|
481 | ichanfadc = (Int_t) ((ichan+i)/SUBBINS);
|
---|
482 |
|
---|
483 | if ( ichanfadc < 0 )
|
---|
484 | continue;
|
---|
485 |
|
---|
486 | if ( (ichanfadc) < (Int_t)fSlices_mFadc )
|
---|
487 | sig[iPix][ichanfadc] += (amplitude * sing_resp_outer[i] );
|
---|
488 | }
|
---|
489 |
|
---|
490 | }
|
---|
491 | else {
|
---|
492 | cout << " WARNING! Fadc::FillOuter " << time << " out of TriggerTimeRange "
|
---|
493 | << TOTAL_TRIGGER_TIME+fadc_time_offset << endl ;
|
---|
494 | }
|
---|
495 |
|
---|
496 | }
|
---|
497 |
|
---|
498 | void MFadc::Set( Int_t iPix, Float_t *resp) {
|
---|
499 |
|
---|
500 | //
|
---|
501 | // Sets the information about fadc reponse from a given array
|
---|
502 | //
|
---|
503 | // parameter is the number of the pixel and the values to be set
|
---|
504 | //
|
---|
505 | //
|
---|
506 |
|
---|
507 | Int_t i ;
|
---|
508 |
|
---|
509 | //
|
---|
510 | // first we have to check if the pixel iPix is used or not until now
|
---|
511 | // if this is the first use, reset all signal for that pixels
|
---|
512 | //
|
---|
513 | if ( iPix > numpix ) {
|
---|
514 | cout << " WARNING: MFadc::Fill() : iPix greater than CAMERA_PIXELS"
|
---|
515 | << endl ;
|
---|
516 | exit(987) ;
|
---|
517 | }
|
---|
518 |
|
---|
519 | if ( used[iPix] == FALSE ) {
|
---|
520 | used [iPix] = TRUE ;
|
---|
521 |
|
---|
522 | for (i=0; i < (Int_t)fSlices_mFadc; i++ ) {
|
---|
523 | sig[iPix][i] = 0. ;
|
---|
524 | }
|
---|
525 | }
|
---|
526 | for ( i = 0 ; i<(Int_t)fSlices_mFadc; i++ ) {
|
---|
527 | sig[iPix][i] = resp[i] ;
|
---|
528 | }
|
---|
529 |
|
---|
530 | }
|
---|
531 |
|
---|
532 | void MFadc::AddSignal( Int_t iPix, Float_t *resp) {
|
---|
533 |
|
---|
534 | //
|
---|
535 | // Adds signals to the fadc reponse from a given array
|
---|
536 | //
|
---|
537 | // parameters are the number of the pixel and the values to be added
|
---|
538 | //
|
---|
539 | //
|
---|
540 |
|
---|
541 | Int_t i ;
|
---|
542 |
|
---|
543 | //
|
---|
544 | // first we have to check if the pixel iPix is used or not until now
|
---|
545 | // if this is the first use, reset all signal for that pixels
|
---|
546 | //
|
---|
547 | if ( iPix > numpix ) {
|
---|
548 | cout << " WARNING: MFadc::Fill() : iPix greater than CAMERA_PIXELS"
|
---|
549 | << endl ;
|
---|
550 | exit(987) ;
|
---|
551 | }
|
---|
552 |
|
---|
553 | if ( used[iPix] == FALSE ) {
|
---|
554 | used [iPix] = TRUE ;
|
---|
555 |
|
---|
556 | for (i=0; i < (Int_t)fSlices_mFadc; i++ ) {
|
---|
557 | sig[iPix][i] = 0. ;
|
---|
558 | }
|
---|
559 | }
|
---|
560 | for ( i = 0 ; i<(Int_t)fSlices_mFadc; i++ ) {
|
---|
561 | sig[iPix][i] += resp[i] ;
|
---|
562 | }
|
---|
563 |
|
---|
564 | }
|
---|
565 |
|
---|
566 | void MFadc::SetPedestals( Int_t ped) {
|
---|
567 | // It sets pedestal for each pixel flat randomly dstributed between 0 and ped
|
---|
568 | // It uses the instance of TRandom GenElec.
|
---|
569 |
|
---|
570 | Int_t i;
|
---|
571 |
|
---|
572 | for(i=0;i<numpix;i++){
|
---|
573 | pedestal[i]= (Float_t)(ped* GenElec->Rndm());
|
---|
574 | }
|
---|
575 | }
|
---|
576 |
|
---|
577 | void MFadc::SetPedestals( Float_t *ped) {
|
---|
578 | // It sets pedestal for each pixel from ped array
|
---|
579 |
|
---|
580 | Int_t i;
|
---|
581 |
|
---|
582 | for(i=0;i<numpix;i++){
|
---|
583 | pedestal[i]= ped[i];
|
---|
584 | }
|
---|
585 | }
|
---|
586 |
|
---|
587 |
|
---|
588 | void MFadc::Baseline(){
|
---|
589 | //
|
---|
590 | // It simulates the AC behaviour
|
---|
591 |
|
---|
592 | int i,j;
|
---|
593 | Float_t baseline;
|
---|
594 |
|
---|
595 | for(j=0;j<numpix;j++){
|
---|
596 | baseline=0.0;
|
---|
597 | for(i=0;i<(Int_t) fSlices_mFadc;i++){
|
---|
598 | baseline+=sig[j][i];
|
---|
599 | }
|
---|
600 | baseline=baseline/fSlices_mFadc;
|
---|
601 | for(i=0;i<(Int_t) fSlices_mFadc;i++){
|
---|
602 | sig[j][i]=-baseline;
|
---|
603 | }
|
---|
604 | }
|
---|
605 | }
|
---|
606 |
|
---|
607 | void MFadc::Pedestals(){
|
---|
608 | //
|
---|
609 | // It shifts the FADC contents their pedestal values
|
---|
610 | // It shifts the values in the analog signal,
|
---|
611 | // therefore it has to be done before getting FADC output
|
---|
612 | //
|
---|
613 |
|
---|
614 | Int_t i, j;
|
---|
615 |
|
---|
616 | for(i=0;i<numpix;i++)
|
---|
617 | for(j=0;j<(Int_t)fSlices_mFadc;j++)
|
---|
618 | sig[i][j]+=pedestal[i];
|
---|
619 | //
|
---|
620 | // AM 15 01 2003: Formerly the above operation was performed only
|
---|
621 | // for pixels in which used[] was true. But to run camera with no noise
|
---|
622 | // and get the right baseline on the pixels with no C-photons, we have
|
---|
623 | // to do it for all pixels.
|
---|
624 | //
|
---|
625 | }
|
---|
626 |
|
---|
627 | void MFadc::Offset(Float_t offset, Int_t pixel){
|
---|
628 | //
|
---|
629 | // It puts an offset in the FADC signal
|
---|
630 | //
|
---|
631 |
|
---|
632 | int i,j;
|
---|
633 | float fdum;
|
---|
634 | TRandom *GenOff = new TRandom () ;
|
---|
635 |
|
---|
636 | if (offset<0) {
|
---|
637 | // It cannot be, so the program assumes that
|
---|
638 | // it should generate random values for the offset.
|
---|
639 |
|
---|
640 | if (pixel<0) {
|
---|
641 | // It does not exist, so all pixels will have the same offset
|
---|
642 |
|
---|
643 | for(i=0;i<numpix;i++){
|
---|
644 | if (used[i]){
|
---|
645 | fdum=(10*GenOff->Rndm());
|
---|
646 | for(j=0;j<(Int_t) fSlices_mFadc;j++)
|
---|
647 | sig[i][j]+=fdum;
|
---|
648 | }
|
---|
649 | }
|
---|
650 | } else {
|
---|
651 | // The program will put the specifies offset to the pixel "pixel".
|
---|
652 |
|
---|
653 | if (used[pixel]){
|
---|
654 | fdum=(10*GenOff->Rndm());
|
---|
655 | for(j=0;j<(Int_t) fSlices_mFadc;j++)
|
---|
656 | sig[pixel][j]+=fdum;
|
---|
657 | }
|
---|
658 |
|
---|
659 | }
|
---|
660 | }else {
|
---|
661 | // The "offset" will be the offset for the FADC
|
---|
662 |
|
---|
663 | if (pixel<0) {
|
---|
664 | // It does not exist, so all pixels will have the same offset
|
---|
665 |
|
---|
666 | for(i=0;i<numpix;i++){
|
---|
667 | if (used[i]){
|
---|
668 | for(j=0;j<(Int_t) fSlices_mFadc;j++)
|
---|
669 | sig[i][j]+=offset;
|
---|
670 | }
|
---|
671 | }
|
---|
672 | } else {
|
---|
673 | // The program will put the specifies offset to the pixel "pixel".
|
---|
674 |
|
---|
675 | if (used[pixel]){
|
---|
676 | for(j=0;j<(Int_t) fSlices_mFadc;j++)
|
---|
677 | sig[pixel][j]+=offset;
|
---|
678 | }
|
---|
679 | }
|
---|
680 | }
|
---|
681 | delete GenOff;
|
---|
682 | }
|
---|
683 |
|
---|
684 | void MFadc::SetElecNoise(Float_t value1, Float_t value2, UInt_t n_in_pix){
|
---|
685 |
|
---|
686 | UInt_t i;
|
---|
687 |
|
---|
688 | fInnerPixelsNum = n_in_pix;
|
---|
689 |
|
---|
690 | cout<<"MFadc::SetElecNoise ... generating database for electronic noise."
|
---|
691 | <<endl;
|
---|
692 |
|
---|
693 | for (i=0;i<(UInt_t (fSlices_mFadc))*1001;i++){
|
---|
694 | noise[i]=GenElec->Gaus(0., value1 );
|
---|
695 | noise_outer[i]=GenElec->Gaus(0., value2 );
|
---|
696 | }
|
---|
697 |
|
---|
698 | cout<<"MFadc::SetElecNoise ... done"<<endl;
|
---|
699 |
|
---|
700 | }
|
---|
701 |
|
---|
702 | void MFadc::ElecNoise() {
|
---|
703 | // ============================================================
|
---|
704 | //
|
---|
705 | // adds the noise due to optronics and electronics
|
---|
706 | // to the signal. This is noise which comes before the FADC,
|
---|
707 | // so it will be later scaled down in the low gain branch, if
|
---|
708 | // the switch to low gain occurs.
|
---|
709 | //
|
---|
710 | UInt_t startslice;
|
---|
711 |
|
---|
712 | for ( Int_t i = 0 ; i < numpix; i++) {
|
---|
713 | //
|
---|
714 | // but at the beginning we must check if this pixel is
|
---|
715 | // hitted the first time
|
---|
716 | //
|
---|
717 |
|
---|
718 | startslice=GenElec->Integer(((Int_t)fSlices_mFadc)*1000);
|
---|
719 |
|
---|
720 | if ( used[i] == FALSE )
|
---|
721 | {
|
---|
722 | used [i] = TRUE ;
|
---|
723 | if (i < fInnerPixelsNum)
|
---|
724 | memcpy( (Float_t*)&sig[i][0],
|
---|
725 | (Float_t*)&noise[startslice],
|
---|
726 | ((Int_t) fSlices_mFadc)*sizeof(Float_t));
|
---|
727 | else
|
---|
728 | memcpy( (Float_t*)&sig[i][0],
|
---|
729 | (Float_t*)&noise_outer[startslice],
|
---|
730 | ((Int_t) fSlices_mFadc)*sizeof(Float_t));
|
---|
731 | }
|
---|
732 |
|
---|
733 | //
|
---|
734 | // If pixel already in use, the noise is added each time slice
|
---|
735 | //
|
---|
736 | else
|
---|
737 | {
|
---|
738 | if (i < fInnerPixelsNum)
|
---|
739 | for ( Int_t is=0 ; is< (Int_t)fSlices_mFadc ; is++ )
|
---|
740 | sig[i][is] += noise[startslice+is];
|
---|
741 | else
|
---|
742 | for ( Int_t is=0 ; is< (Int_t)fSlices_mFadc ; is++ )
|
---|
743 | sig[i][is] += noise_outer[startslice+is];
|
---|
744 | }
|
---|
745 | }
|
---|
746 | }
|
---|
747 |
|
---|
748 | void MFadc::SetDigitalNoise(Float_t value){
|
---|
749 |
|
---|
750 | UInt_t i;
|
---|
751 | Float_t xrdm;
|
---|
752 |
|
---|
753 | cout<<"MFadc::SetDigitalNoise ... generating database for electronic noise."
|
---|
754 | <<endl;
|
---|
755 |
|
---|
756 | for (i=0;i<UInt_t(fSlices_mFadc*1001);i++){
|
---|
757 | xrdm=GenElec->Gaus(0., value);
|
---|
758 | digital_noise[i]=(xrdm>0?Int_t(xrdm+0.5):Int_t(xrdm-0.5));
|
---|
759 | }
|
---|
760 |
|
---|
761 | cout<<"MFadc::SetDigitalNoise ... done"<<endl;
|
---|
762 |
|
---|
763 | }
|
---|
764 |
|
---|
765 | void MFadc::DigitalNoise() {
|
---|
766 | // ============================================================
|
---|
767 | //
|
---|
768 | // adds the noise due to FADC electronics to the signal. This
|
---|
769 | // noise affects equally the high and low gain branches, that is,
|
---|
770 | // it is not scaled down in the low gain branch.
|
---|
771 | //
|
---|
772 | UInt_t startslice;
|
---|
773 |
|
---|
774 | for ( Int_t i = 0 ; i < numpix; i++)
|
---|
775 | {
|
---|
776 | if ( used[i] == FALSE )
|
---|
777 | continue;
|
---|
778 |
|
---|
779 | startslice=GenElec->Integer((Int_t) fSlices_mFadc*999);
|
---|
780 | //
|
---|
781 | // Then the noise is introduced for each time slice
|
---|
782 | //
|
---|
783 | for ( Int_t is = 0 ; is < fFadcSlices; is++ )
|
---|
784 | {
|
---|
785 | output[i][is] += digital_noise[startslice+is];
|
---|
786 | output_lowgain[i][is] += digital_noise[startslice+fFadcSlices+is];
|
---|
787 | }
|
---|
788 | }
|
---|
789 | }
|
---|
790 |
|
---|
791 | void MFadc::Scan() {
|
---|
792 |
|
---|
793 |
|
---|
794 | for ( Int_t ip=0; ip<numpix; ip++ ) {
|
---|
795 |
|
---|
796 | if ( used[ip] == kTRUE ) {
|
---|
797 |
|
---|
798 | printf ("Pid %3d", ip ) ;
|
---|
799 |
|
---|
800 | for ( Int_t is=0 ; is < (Int_t)fSlices_mFadc; is++ ) {
|
---|
801 |
|
---|
802 | if ( sig[ip][is] > 0. ) {
|
---|
803 | printf (" %4.1f/", sig[ip][is] ) ;
|
---|
804 | }
|
---|
805 | else {
|
---|
806 | printf ("----/" ) ;
|
---|
807 | }
|
---|
808 | }
|
---|
809 |
|
---|
810 | printf ("\n");
|
---|
811 |
|
---|
812 | }
|
---|
813 | }
|
---|
814 |
|
---|
815 | }
|
---|
816 |
|
---|
817 | void MFadc::Scan(Float_t time) {
|
---|
818 |
|
---|
819 | //
|
---|
820 | // first of all we subtract from the time a offset (8 ns)
|
---|
821 | //
|
---|
822 |
|
---|
823 | Float_t t ;
|
---|
824 |
|
---|
825 | (0 > time - TIME_BEFORE_TRIGGER)? t=fadc_time_offset: t=(time-TIME_BEFORE_TRIGGER+fadc_time_offset) ; // to show also the start of the pulse before the trigger time
|
---|
826 |
|
---|
827 | if ( t < 0. ) {
|
---|
828 | cout << " WARNING!! FROM MFADC::SCAN(t) " << endl ;
|
---|
829 | exit (776) ;
|
---|
830 | }
|
---|
831 |
|
---|
832 | //
|
---|
833 | // calculate the first slice to write out
|
---|
834 | //
|
---|
835 |
|
---|
836 | Int_t iFirstSlice ;
|
---|
837 |
|
---|
838 | iFirstSlice = (Int_t) ( t * fFadcSlicesPerNanosec ) ;
|
---|
839 |
|
---|
840 | for ( Int_t ip=0; ip<numpix; ip++ ) {
|
---|
841 |
|
---|
842 | if ( used[ip] == kTRUE ) {
|
---|
843 |
|
---|
844 | printf ("Pid %3d", ip ) ;
|
---|
845 |
|
---|
846 | for ( Int_t is=iFirstSlice ; is < (iFirstSlice+15); is++ ) {
|
---|
847 | printf (" %5.2f /", sig[ip][is] ) ;
|
---|
848 | }
|
---|
849 |
|
---|
850 | printf ("\n");
|
---|
851 |
|
---|
852 | }
|
---|
853 | }
|
---|
854 | }
|
---|
855 |
|
---|
856 | void MFadc::GetResponse( Float_t *resp ) {
|
---|
857 | // ============================================================
|
---|
858 | //
|
---|
859 | // puts the standard response function into the array resp
|
---|
860 |
|
---|
861 | for ( Int_t i=0; i< fResponseSlicesFadc; i++ )
|
---|
862 | resp[i] = sing_resp[i];
|
---|
863 |
|
---|
864 | }
|
---|
865 |
|
---|
866 | void MFadc::GetPedestals( Float_t *offset) {
|
---|
867 | // ============================================================
|
---|
868 | //
|
---|
869 | // puts the pedestal values into the array offset
|
---|
870 |
|
---|
871 | for ( Int_t i=0; i< numpix; i++ ) {
|
---|
872 |
|
---|
873 | offset[i] = pedestal[i] ;
|
---|
874 | }
|
---|
875 | }
|
---|
876 |
|
---|
877 | //===========================================================================
|
---|
878 | //
|
---|
879 | // Next function adds up the noise in pixel "pix", scaling down the part
|
---|
880 | // of it which comes from before the receivers in the case we are dealing with
|
---|
881 | // low gain (ishigh=0). The output is the sum of the readouts of a number
|
---|
882 | // n_slices of FADC slices. For the case of low gain, the FADC contents we add
|
---|
883 | // are not what we would have in a real pedestal event, but nevertheless this
|
---|
884 | // is useful in the camera simulation to obtain what the pedestal fluctuations
|
---|
885 | // are for the low gain. This will be written to the camera output, in the
|
---|
886 | // MMcFadcHeader.
|
---|
887 | //
|
---|
888 | Float_t MFadc::AddNoiseInSlices( Int_t pix, Int_t ishigh, Int_t n_slices) {
|
---|
889 |
|
---|
890 | Float_t sum=0;
|
---|
891 | Float_t fvalue = 0.;
|
---|
892 | UChar_t value=0;
|
---|
893 |
|
---|
894 | Float_t factor;
|
---|
895 | UInt_t startslice;
|
---|
896 |
|
---|
897 | //
|
---|
898 | // If we deal with low gain, we have to scale the values in sig[][] by
|
---|
899 | // the gain ratio (high2low_gain), since "sig" contains here the noise
|
---|
900 | // produced before the receiver boards (for instance NSB noise)
|
---|
901 | //
|
---|
902 | factor=(ishigh?1.0:high2low_gain);
|
---|
903 |
|
---|
904 | //
|
---|
905 | // Get at random a point in the FADC presimulated digital noise:
|
---|
906 | //
|
---|
907 | startslice=GenElec->Integer((Int_t) fSlices_mFadc*999);
|
---|
908 |
|
---|
909 | for ( Int_t is=0; is < n_slices ; is++ )
|
---|
910 | {
|
---|
911 | fvalue = pedestal[pix]+(sig[pix][is]-pedestal[pix])/factor;
|
---|
912 | fvalue += digital_noise[startslice+is];
|
---|
913 |
|
---|
914 | fvalue = fvalue < 0? fvalue-0.5 : fvalue+0.5;
|
---|
915 |
|
---|
916 | value = fvalue < 0.? (UChar_t) 0 :
|
---|
917 | (fvalue > 255.? 255 : (UChar_t) fvalue);
|
---|
918 |
|
---|
919 |
|
---|
920 | // Add up slices:
|
---|
921 | sum += value - pedestal[pix];
|
---|
922 | }
|
---|
923 |
|
---|
924 | return sum;
|
---|
925 | }
|
---|
926 |
|
---|
927 | //=======================================================================
|
---|
928 |
|
---|
929 | void MFadc::TriggeredFadc(Float_t time) {
|
---|
930 |
|
---|
931 | //
|
---|
932 | // Here the slices to write out are calculated. Warning: the digitalization
|
---|
933 | // is NOT done here (it is already done in MFadc::Fill). This procedure only
|
---|
934 | // selects which FADC slices to write out, out of those contained in the sig[][]
|
---|
935 | // array.
|
---|
936 | //
|
---|
937 |
|
---|
938 | //
|
---|
939 | // calculate the first slice to write out, according to trigger time:
|
---|
940 | //
|
---|
941 |
|
---|
942 | Int_t iFirstSlice ;
|
---|
943 | Int_t i;
|
---|
944 |
|
---|
945 | //
|
---|
946 | // We had 0.5 for the correct rounding:
|
---|
947 | //
|
---|
948 | iFirstSlice = (Int_t) ( 0.5 + time * fFadcSlicesPerNanosec ) ;
|
---|
949 |
|
---|
950 | for ( Int_t ip = 0; ip < numpix; ip++ )
|
---|
951 | {
|
---|
952 |
|
---|
953 | if ( used[ip] == kFALSE)
|
---|
954 | // Pixels with no C-photons, in the case that camera is being run with
|
---|
955 | // no noise (nor NSB neither electronic). We then set the mean pedestal as
|
---|
956 | // signal, since when analyzing the camera output file, MARS will subtract
|
---|
957 | // it anyway!
|
---|
958 | {
|
---|
959 | for ( Int_t i=0 ; i < fFadcSlices ; i++ )
|
---|
960 | {
|
---|
961 | output[ip][i] = pedestal[ip];
|
---|
962 | output_lowgain[ip][i] = pedestal[ip];
|
---|
963 | }
|
---|
964 | continue;
|
---|
965 | }
|
---|
966 |
|
---|
967 |
|
---|
968 | // First put the high gain in the output slices:
|
---|
969 | i = 0;
|
---|
970 | Int_t switch_i = 0;
|
---|
971 | for ( Int_t is = iFirstSlice; is < (iFirstSlice+fFadcSlices); is++ )
|
---|
972 | {
|
---|
973 | if (is < (Int_t)fSlices_mFadc)
|
---|
974 | {
|
---|
975 | output[ip][i] = sig[ip][is];
|
---|
976 |
|
---|
977 | if (switch_i == 0) // Hi gain limit not yet surpassed before.
|
---|
978 | {
|
---|
979 | if (output[ip][i] > fGainSwitchAmp)
|
---|
980 | switch_i = i + fShiftFromSwitch2LowGain;
|
---|
981 | }
|
---|
982 | }
|
---|
983 |
|
---|
984 | else // We are beyond the simulated signal history in sig[][]! Put just mean pedestal!
|
---|
985 | output[ip][i] = pedestal[ip];
|
---|
986 |
|
---|
987 | i++;
|
---|
988 | }
|
---|
989 |
|
---|
990 | // Now put the low gain:
|
---|
991 | // FIXME: for now, the shift between the high and low gain peaks has to be an integer number
|
---|
992 | // of FADC slices. But in the data the shift is ~16.5 slices. This has to be implemented.
|
---|
993 | i=0;
|
---|
994 | for ( Int_t is = iFirstSlice; is < (iFirstSlice+fFadcSlices); is++ )
|
---|
995 | {
|
---|
996 | if (is < (Int_t)fSlices_mFadc)
|
---|
997 | {
|
---|
998 | if (switch_i > 0 && (i+fFadcSlices) >= switch_i)
|
---|
999 | output_lowgain[ip][i] = pedestal[ip] +
|
---|
1000 | (sig[ip][is-(fHi2LoGainPeak-fFadcSlices)]-pedestal[ip])/high2low_gain;
|
---|
1001 | // Once the shift occurs, low gain is filled with the high
|
---|
1002 | // gain signal scaled down by the factor high2low_gain
|
---|
1003 |
|
---|
1004 | else
|
---|
1005 | output_lowgain[ip][i] = sig[ip][is+fFadcSlices];
|
---|
1006 | // Write out high gain into low gain slices if there was no
|
---|
1007 | // switch, or before the switch occurs.
|
---|
1008 | }
|
---|
1009 |
|
---|
1010 | else // We are beyond the simulated signal history in sig[][]! Put just mean pedestal!
|
---|
1011 | {
|
---|
1012 | output_lowgain[ip][i]= pedestal[ip];
|
---|
1013 | }
|
---|
1014 | i++;
|
---|
1015 | }
|
---|
1016 |
|
---|
1017 | }
|
---|
1018 | }
|
---|
1019 |
|
---|
1020 |
|
---|
1021 | void MFadc::ShowSignal (MMcEvt *McEvt, Float_t trigTime) {
|
---|
1022 | // ============================================================
|
---|
1023 | //
|
---|
1024 | // This method is used to book the histogram to show the signal in
|
---|
1025 | // a special gui frame (class MGTriggerSignal). After the look onto the
|
---|
1026 | // signals for a better understanding of the things we will expect
|
---|
1027 | // the gui frame and all histogramms will be destroyed.
|
---|
1028 | //
|
---|
1029 |
|
---|
1030 | //
|
---|
1031 | // first of all create a list of the histograms to show
|
---|
1032 | //
|
---|
1033 | // take only that one with a entry
|
---|
1034 |
|
---|
1035 | TH1F *hist ;
|
---|
1036 | Char_t dumm[10];
|
---|
1037 | Char_t name[256];
|
---|
1038 |
|
---|
1039 | TObjArray *AList ;
|
---|
1040 | AList = new TObjArray(10) ;
|
---|
1041 |
|
---|
1042 | // the list of analog signal histograms
|
---|
1043 | // at the beginning we initalise 10 elements
|
---|
1044 | // but this array expand automatically if neccessay
|
---|
1045 |
|
---|
1046 | Int_t ic = 0 ;
|
---|
1047 | for ( Int_t i=0 ; i < numpix; i++ ) {
|
---|
1048 | if ( used [i] == TRUE ) {
|
---|
1049 |
|
---|
1050 | sprintf (dumm, "FADC_%d", i ) ;
|
---|
1051 | sprintf (name, "fadc signal %d", i ) ;
|
---|
1052 |
|
---|
1053 | hist = new TH1F(dumm, name, (Int_t)fSlices_mFadc, fadc_time_offset, TOTAL_TRIGGER_TIME+fadc_time_offset);
|
---|
1054 | //
|
---|
1055 | // fill the histogram
|
---|
1056 | //
|
---|
1057 |
|
---|
1058 | for (Int_t ibin = 1; ibin <= (Int_t)fSlices_mFadc; ibin++)
|
---|
1059 | hist->SetBinContent (ibin, sig[i][ibin-1]);
|
---|
1060 |
|
---|
1061 |
|
---|
1062 | // hist->SetMaximum( 5.);
|
---|
1063 | // hist->SetMinimum(-10.);
|
---|
1064 | hist->SetStats(kFALSE);
|
---|
1065 |
|
---|
1066 | // hist->SetAxisRange(0., 80. ) ;
|
---|
1067 |
|
---|
1068 | AList->Add(hist) ;
|
---|
1069 |
|
---|
1070 | ic++ ;
|
---|
1071 | }
|
---|
1072 | }
|
---|
1073 |
|
---|
1074 | //
|
---|
1075 | // create the Gui Tool
|
---|
1076 | //
|
---|
1077 | //
|
---|
1078 |
|
---|
1079 | new MGFadcSignal(McEvt,
|
---|
1080 | AList,
|
---|
1081 | trigTime,
|
---|
1082 | gClient->GetRoot(),
|
---|
1083 | gClient->GetRoot(),
|
---|
1084 | 400, 400 ) ;
|
---|
1085 |
|
---|
1086 | //
|
---|
1087 | // delete the List of histogramms
|
---|
1088 | //
|
---|
1089 | AList->Delete() ;
|
---|
1090 |
|
---|
1091 | delete AList ;
|
---|
1092 | }
|
---|
1093 |
|
---|
1094 | UChar_t MFadc::GetFadcSignal(Int_t pixel, Int_t slice){
|
---|
1095 |
|
---|
1096 | // It returns the analog signal for a given pixel and a given FADC
|
---|
1097 | // time slice which would be read.
|
---|
1098 |
|
---|
1099 | // Since May 1 2004, we do the rounding and the truncation to the range
|
---|
1100 | // 0-255 counts here. (A. Moralejo)
|
---|
1101 |
|
---|
1102 | Float_t out = output[pixel][slice] > 0. ?
|
---|
1103 | output[pixel][slice]+0.5 : output[pixel][slice]-0.5;
|
---|
1104 | // (add or subtract 0.5 for correct rounding)
|
---|
1105 |
|
---|
1106 | return (out < 0.? (UChar_t) 0 :
|
---|
1107 | (out > 255.? (UChar_t) 255 :
|
---|
1108 | (UChar_t) out));
|
---|
1109 | }
|
---|
1110 |
|
---|
1111 |
|
---|
1112 | UChar_t MFadc::GetFadcLowGainSignal(Int_t pixel, Int_t slice){
|
---|
1113 |
|
---|
1114 | // It returns the analog signal for a given pixel and a given FADC
|
---|
1115 | // time slice which would be read. Same comment as above.
|
---|
1116 |
|
---|
1117 | Float_t outlow = output_lowgain[pixel][slice] > 0. ?
|
---|
1118 | output_lowgain[pixel][slice]+0.5 :
|
---|
1119 | output_lowgain[pixel][slice]-0.5;
|
---|
1120 | // (add or subtract 0.5 for correct rounding)
|
---|
1121 |
|
---|
1122 | return (outlow < 0.? (UChar_t) 0 :
|
---|
1123 | (outlow > 255.? (UChar_t) 255 :
|
---|
1124 | (UChar_t) outlow));
|
---|
1125 | }
|
---|
1126 |
|
---|
1127 |
|
---|
1128 |
|
---|