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 | MFadc::MFadc(Int_t pix, Float_t ampl, Float_t fwhm, Float_t amplout, Float_t fwhmout) {
|
---|
21 | //
|
---|
22 | // Constructor overloaded II
|
---|
23 | //
|
---|
24 | // Input variables:
|
---|
25 | // 1. ampl(out) = integration of the single phe response (outer pixels)
|
---|
26 | // 2. fwhm(out) = width at half high of the single phe
|
---|
27 | // response(outer pixels)
|
---|
28 | //
|
---|
29 | // The procedure is the following:
|
---|
30 | // 1. some parameters of the trigger are set to default.
|
---|
31 | // this parameters of the trigger may be changed
|
---|
32 | // 3. Then the all signals are set to zero
|
---|
33 | numpix=pix;
|
---|
34 |
|
---|
35 | fwhm_resp = fwhm;
|
---|
36 | ampl_resp = ampl;
|
---|
37 | fwhm_resp_outer = fwhmout;
|
---|
38 | ampl_resp_outer = amplout;
|
---|
39 |
|
---|
40 | //
|
---|
41 | // set up the response shape
|
---|
42 | //
|
---|
43 | Int_t i ;
|
---|
44 |
|
---|
45 | Float_t sigma ;
|
---|
46 | Float_t x, x0 ;
|
---|
47 |
|
---|
48 | sigma = fwhm_resp / 2.35 ;
|
---|
49 | x0 = 3*sigma ;
|
---|
50 |
|
---|
51 | Float_t dX, dX2 ;
|
---|
52 |
|
---|
53 | dX = WIDTH_FADC_TIMESLICE / SUBBINS ;
|
---|
54 | dX2 = dX/2. ;
|
---|
55 |
|
---|
56 | for (i=0; i< RESPONSE_SLICES_MFADC ; i++ ) {
|
---|
57 |
|
---|
58 | x = i * dX + dX2 ;
|
---|
59 |
|
---|
60 | //
|
---|
61 | // the value 1/(2*Pi*sigma^2) was introduced to normalize
|
---|
62 | // the area at the input value
|
---|
63 | //
|
---|
64 | sing_resp[i] = ampl_resp / sqrt(2*3.1415926*sigma*sigma)*
|
---|
65 | expf(-0.5 * (x-x0)*(x-x0) / (sigma*sigma) ) ;
|
---|
66 |
|
---|
67 | }
|
---|
68 |
|
---|
69 | sigma = fwhm_resp_outer / 2.35 ;
|
---|
70 | x0 = 3*sigma ;
|
---|
71 |
|
---|
72 | dX = WIDTH_FADC_TIMESLICE / SUBBINS ;
|
---|
73 | dX2 = dX/2. ;
|
---|
74 |
|
---|
75 | for (i=0; i< RESPONSE_SLICES_MFADC ; i++ ) {
|
---|
76 |
|
---|
77 | x = i * dX + dX2 ;
|
---|
78 |
|
---|
79 | //
|
---|
80 | // the value 1/(2*Pi*sigma^2) was introduced to normalize
|
---|
81 | // the area at the input value
|
---|
82 | //
|
---|
83 | sing_resp_outer[i] = ampl_resp_outer / sqrt(2*3.1415926*sigma*sigma)*
|
---|
84 | expf(-0.5 * (x-x0)*(x-x0) / (sigma*sigma) ) ;
|
---|
85 |
|
---|
86 | }
|
---|
87 |
|
---|
88 | //
|
---|
89 | // init the Random Generator for Electonic Noise
|
---|
90 | //
|
---|
91 |
|
---|
92 | GenElec = new TRandom () ;
|
---|
93 |
|
---|
94 | Reset();
|
---|
95 |
|
---|
96 | //
|
---|
97 | // set all pedestals to 0
|
---|
98 | //
|
---|
99 |
|
---|
100 | for ( i =0 ; i <CAMERA_PIXELS ; i++ ) {
|
---|
101 | pedestal[i] = 0.0 ;
|
---|
102 | }
|
---|
103 | }
|
---|
104 |
|
---|
105 | void MFadc::Reset() {
|
---|
106 | //
|
---|
107 | // set all values of the signals to zero
|
---|
108 | // set tha values of FADC slices that would be read after trigger to zero
|
---|
109 | //
|
---|
110 | memset(used, 0, CAMERA_PIXELS*sizeof(Bool_t));
|
---|
111 | memset(output, 0, CAMERA_PIXELS*FADC_SLICES*sizeof(UChar_t));
|
---|
112 | memset(output_lowgain, 0, CAMERA_PIXELS*FADC_SLICES*sizeof(UChar_t));
|
---|
113 | }
|
---|
114 | void MFadc::Fill( Int_t iPix, Float_t time,
|
---|
115 | Float_t amplitude, Int_t isinner ) {
|
---|
116 |
|
---|
117 | if(isinner)
|
---|
118 | Fill(iPix, time, amplitude);
|
---|
119 | else
|
---|
120 | FillOuter(iPix, time, amplitude);
|
---|
121 |
|
---|
122 | }
|
---|
123 | void MFadc::Fill( Int_t iPix, Float_t time, Float_t amplitude ) {
|
---|
124 |
|
---|
125 | //
|
---|
126 | // fills the information about one single Phe in the Trigger class
|
---|
127 | //
|
---|
128 | // parameter is the number of the pixel and the time-difference to the
|
---|
129 | // first particle
|
---|
130 | //
|
---|
131 | //
|
---|
132 |
|
---|
133 | Int_t i, ichan, ichanfadc ;
|
---|
134 |
|
---|
135 | //
|
---|
136 | // first we have to check if the pixel iPix is used or not until now
|
---|
137 | // if this is the first use, reset all signal for that pixels
|
---|
138 | //
|
---|
139 | if ( iPix > numpix ) {
|
---|
140 | cout << " WARNING: MFadc::Fill() : iPix greater than Pixels in Camera = "
|
---|
141 | << numpix
|
---|
142 | << endl ;
|
---|
143 | exit(987) ;
|
---|
144 | }
|
---|
145 |
|
---|
146 | if ( used[iPix] == FALSE ) {
|
---|
147 | used [iPix] = TRUE ;
|
---|
148 |
|
---|
149 | for (i=0; i < (Int_t) SLICES_MFADC; i++ ) {
|
---|
150 | sig[iPix][i] = 0. ;
|
---|
151 | }
|
---|
152 | }
|
---|
153 |
|
---|
154 | //
|
---|
155 | // then select the time slice to use (ican)
|
---|
156 | //
|
---|
157 |
|
---|
158 |
|
---|
159 | if ( time < 0. ) {
|
---|
160 | cout << " WARNING! Fadc::Fill " << time << " below ZERO!! Very strange!!"
|
---|
161 | << endl ;
|
---|
162 | }
|
---|
163 | else if ( time < TOTAL_TRIGGER_TIME ) {
|
---|
164 | //
|
---|
165 | // determine the slices number assuming the WIDTH_RESPONSE_MFADC
|
---|
166 | //
|
---|
167 | ichan = (Int_t) ( time / ((Float_t) WIDTH_RESPONSE_MFADC ));
|
---|
168 |
|
---|
169 | //
|
---|
170 | // putting the response slices in the right sig slices.
|
---|
171 | // Be carefull, because both slices have different widths.
|
---|
172 | //
|
---|
173 |
|
---|
174 | for ( i = 0 ; i<RESPONSE_SLICES; i++ ) {
|
---|
175 | ichanfadc = (Int_t) ((ichan+i)/SUBBINS) ;
|
---|
176 | if ( (ichanfadc) < (Int_t)SLICES_MFADC ) {
|
---|
177 | sig[iPix][ichanfadc] += (amplitude * sing_resp[i] ) ;
|
---|
178 | }
|
---|
179 | }
|
---|
180 | }
|
---|
181 | else {
|
---|
182 | cout << " WARNING! Fadc::Fill " << time << " out of TriggerTimeRange "
|
---|
183 | << TOTAL_TRIGGER_TIME << endl ;
|
---|
184 | }
|
---|
185 |
|
---|
186 | }
|
---|
187 |
|
---|
188 | void MFadc::FillOuter( Int_t iPix, Float_t time, Float_t amplitude ) {
|
---|
189 |
|
---|
190 | //
|
---|
191 | // fills the information about one single Phe in the Trigger class
|
---|
192 | // for an outer pixel
|
---|
193 | //
|
---|
194 | // parameter is the number of the pixel and the time-difference to the
|
---|
195 | // first particle
|
---|
196 | //
|
---|
197 | //
|
---|
198 |
|
---|
199 | Int_t i, ichan, ichanfadc ;
|
---|
200 |
|
---|
201 | //
|
---|
202 | // first we have to check if the pixel iPix is used or not until now
|
---|
203 | // if this is the first use, reset all signal for that pixels
|
---|
204 | //
|
---|
205 | if ( iPix > numpix ) {
|
---|
206 | cout << " WARNING: MFadc::FillOuter() : iPix greater than CAMERA_PIXELS"
|
---|
207 | << endl ;
|
---|
208 | exit(987) ;
|
---|
209 | }
|
---|
210 |
|
---|
211 | if ( used[iPix] == FALSE ) {
|
---|
212 | used [iPix] = TRUE ;
|
---|
213 |
|
---|
214 | for (i=0; i < (Int_t) SLICES_MFADC; i++ ) {
|
---|
215 | sig[iPix][i] = 0. ;
|
---|
216 | }
|
---|
217 | }
|
---|
218 |
|
---|
219 | //
|
---|
220 | // then select the time slice to use (ican)
|
---|
221 | //
|
---|
222 |
|
---|
223 |
|
---|
224 | if ( time < 0. ) {
|
---|
225 | cout << " WARNING! Fadc::FillOuter " << time << " below ZERO!! Very strange!!"
|
---|
226 | << endl ;
|
---|
227 | }
|
---|
228 | else if ( time < TOTAL_TRIGGER_TIME ) {
|
---|
229 | //
|
---|
230 | // determine the slices number assuming the WIDTH_RESPONSE_MFADC
|
---|
231 | //
|
---|
232 | ichan = (Int_t) ( time / ((Float_t) WIDTH_RESPONSE_MFADC ));
|
---|
233 |
|
---|
234 | //
|
---|
235 | // putting the response slices in the right sig slices.
|
---|
236 | // Be carefull, because both slices have different widths.
|
---|
237 | //
|
---|
238 |
|
---|
239 | for ( i = 0 ; i<RESPONSE_SLICES; i++ ) {
|
---|
240 | ichanfadc = (Int_t) ((ichan+i)/SUBBINS) ;
|
---|
241 | if ( (ichanfadc) < (Int_t)SLICES_MFADC ) {
|
---|
242 | sig[iPix][ichanfadc] += (amplitude * sing_resp_outer[i] ) ;
|
---|
243 | }
|
---|
244 | }
|
---|
245 | }
|
---|
246 | else {
|
---|
247 | cout << " WARNING! Fadc::FillOuter " << time << " out of TriggerTimeRange "
|
---|
248 | << TOTAL_TRIGGER_TIME << endl ;
|
---|
249 | }
|
---|
250 |
|
---|
251 | }
|
---|
252 |
|
---|
253 | void MFadc::Set( Int_t iPix, Float_t resp[(Int_t) SLICES_MFADC]) {
|
---|
254 |
|
---|
255 | //
|
---|
256 | // Sets the information about fadc reponse from a given array
|
---|
257 | //
|
---|
258 | // parameter is the number of the pixel and the values to be set
|
---|
259 | //
|
---|
260 | //
|
---|
261 |
|
---|
262 | Int_t i ;
|
---|
263 |
|
---|
264 | //
|
---|
265 | // first we have to check if the pixel iPix is used or not until now
|
---|
266 | // if this is the first use, reset all signal for that pixels
|
---|
267 | //
|
---|
268 | if ( iPix > numpix ) {
|
---|
269 | cout << " WARNING: MFadc::Fill() : iPix greater than CAMERA_PIXELS"
|
---|
270 | << endl ;
|
---|
271 | exit(987) ;
|
---|
272 | }
|
---|
273 |
|
---|
274 | if ( used[iPix] == FALSE ) {
|
---|
275 | used [iPix] = TRUE ;
|
---|
276 |
|
---|
277 | for (i=0; i < (Int_t)SLICES_MFADC; i++ ) {
|
---|
278 | sig[iPix][i] = 0. ;
|
---|
279 | }
|
---|
280 | }
|
---|
281 | for ( i = 0 ; i<(Int_t)SLICES_MFADC; i++ ) {
|
---|
282 | sig[iPix][i] = resp[i] ;
|
---|
283 | }
|
---|
284 |
|
---|
285 | }
|
---|
286 |
|
---|
287 | void MFadc::AddSignal( Int_t iPix, Float_t resp[(Int_t) SLICES_MFADC]) {
|
---|
288 |
|
---|
289 | //
|
---|
290 | // Adds signals to the fadc reponse from a given array
|
---|
291 | //
|
---|
292 | // parameter is the number of the pixel and the values to be added
|
---|
293 | //
|
---|
294 | //
|
---|
295 |
|
---|
296 | Int_t i ;
|
---|
297 |
|
---|
298 | //
|
---|
299 | // first we have to check if the pixel iPix is used or not until now
|
---|
300 | // if this is the first use, reset all signal for that pixels
|
---|
301 | //
|
---|
302 | if ( iPix > numpix ) {
|
---|
303 | cout << " WARNING: MFadc::Fill() : iPix greater than CAMERA_PIXELS"
|
---|
304 | << endl ;
|
---|
305 | exit(987) ;
|
---|
306 | }
|
---|
307 |
|
---|
308 | if ( used[iPix] == FALSE ) {
|
---|
309 | used [iPix] = TRUE ;
|
---|
310 |
|
---|
311 | for (i=0; i < (Int_t)SLICES_MFADC; i++ ) {
|
---|
312 | sig[iPix][i] = 0. ;
|
---|
313 | }
|
---|
314 | }
|
---|
315 | for ( i = 0 ; i<(Int_t)SLICES_MFADC; i++ ) {
|
---|
316 | sig[iPix][i] += resp[i] ;
|
---|
317 | }
|
---|
318 |
|
---|
319 | }
|
---|
320 |
|
---|
321 | void MFadc::SetPedestals( Int_t ped) {
|
---|
322 | // It sets pedestal for each pixel flat randomly dstributed between 0 and ped
|
---|
323 | // It uses the instance of TRandom GenElec.
|
---|
324 |
|
---|
325 | Int_t i;
|
---|
326 |
|
---|
327 | for(i=0;i<numpix;i++){
|
---|
328 | pedestal[i]= (Float_t)(ped* GenElec->Rndm());
|
---|
329 | }
|
---|
330 | }
|
---|
331 |
|
---|
332 | void MFadc::SetPedestals( Float_t *ped) {
|
---|
333 | // It sets pedestal for each pixel from ped array
|
---|
334 |
|
---|
335 | Int_t i;
|
---|
336 |
|
---|
337 | for(i=0;i<numpix;i++){
|
---|
338 | pedestal[i]= ped[i];
|
---|
339 | }
|
---|
340 | }
|
---|
341 |
|
---|
342 |
|
---|
343 | void MFadc::Baseline(){
|
---|
344 | //
|
---|
345 | // It simulates the AC behaviour
|
---|
346 |
|
---|
347 | int i,j;
|
---|
348 | Float_t baseline;
|
---|
349 |
|
---|
350 | for(j=0;j<numpix;j++){
|
---|
351 | baseline=0.0;
|
---|
352 | for(i=0;i<(Int_t) SLICES_MFADC;i++){
|
---|
353 | baseline=+sig[j][i];
|
---|
354 | }
|
---|
355 | baseline=baseline/SLICES_MFADC;
|
---|
356 | for(i=0;i<(Int_t) SLICES_MFADC;i++){
|
---|
357 | sig[j][i]=-baseline;
|
---|
358 | }
|
---|
359 | }
|
---|
360 | }
|
---|
361 |
|
---|
362 | void MFadc::Pedestals(){
|
---|
363 | //
|
---|
364 | // It shifts the FADC contents their pedestal values
|
---|
365 | // It shifts the values in the analog signal,
|
---|
366 | // therefore it has to be done before getting FADC output
|
---|
367 | //
|
---|
368 |
|
---|
369 | Int_t i, j;
|
---|
370 |
|
---|
371 | for(i=0;i<numpix;i++)
|
---|
372 | for(j=0;j<(Int_t)SLICES_MFADC;j++)
|
---|
373 | sig[i][j]+=pedestal[i];
|
---|
374 |
|
---|
375 | }
|
---|
376 |
|
---|
377 | void MFadc::Offset(Float_t offset, Int_t pixel){
|
---|
378 | //
|
---|
379 | // It puts an offset in the FADC signal
|
---|
380 | //
|
---|
381 |
|
---|
382 | int i,j;
|
---|
383 | float fdum;
|
---|
384 | TRandom *GenOff = new TRandom () ;
|
---|
385 |
|
---|
386 | if (offset<0) {
|
---|
387 | // It cannot be, so the program assumes that
|
---|
388 | // it should generate random values for the offset.
|
---|
389 |
|
---|
390 | if (pixel<0) {
|
---|
391 | // It does not exist, so all pixels will have the same offset
|
---|
392 |
|
---|
393 | for(i=0;i<numpix;i++){
|
---|
394 | if (used[i]){
|
---|
395 | fdum=(10*GenOff->Rndm());
|
---|
396 | for(j=0;j<(Int_t) SLICES_MFADC;j++)
|
---|
397 | sig[i][j]=+fdum;
|
---|
398 | }
|
---|
399 | }
|
---|
400 | } else {
|
---|
401 | // The program will put the specifies offset to the pixel "pixel".
|
---|
402 |
|
---|
403 | if (used[pixel]){
|
---|
404 | fdum=(10*GenOff->Rndm());
|
---|
405 | for(j=0;j<(Int_t) SLICES_MFADC;j++)
|
---|
406 | sig[pixel][j]=+fdum;
|
---|
407 | }
|
---|
408 |
|
---|
409 | }
|
---|
410 | }else {
|
---|
411 | // The "offset" will be the offset for the FADC
|
---|
412 |
|
---|
413 | if (pixel<0) {
|
---|
414 | // It does not exist, so all pixels will have the same offset
|
---|
415 |
|
---|
416 | for(i=0;i<numpix;i++){
|
---|
417 | if (used[i]){
|
---|
418 | for(j=0;j<(Int_t) SLICES_MFADC;j++)
|
---|
419 | sig[i][j]=+offset;
|
---|
420 | }
|
---|
421 | }
|
---|
422 | } else {
|
---|
423 | // The program will put the specifies offset to the pixel "pixel".
|
---|
424 |
|
---|
425 | if (used[pixel]){
|
---|
426 | for(j=0;j<(Int_t) SLICES_MFADC;j++)
|
---|
427 | sig[pixel][j]=+offset;
|
---|
428 | }
|
---|
429 | }
|
---|
430 | }
|
---|
431 | delete GenOff;
|
---|
432 | }
|
---|
433 |
|
---|
434 | void MFadc::SetElecNoise(Float_t value){
|
---|
435 |
|
---|
436 | UInt_t i;
|
---|
437 |
|
---|
438 | cout<<"MFadc::SetElecNoise ... generating database for electronic noise."
|
---|
439 | <<endl;
|
---|
440 |
|
---|
441 | for (i=0;i<(UInt_t (SLICES_MFADC))*1001;i++){
|
---|
442 | noise[i]=GenElec->Gaus(0., value );
|
---|
443 | }
|
---|
444 |
|
---|
445 | cout<<"MFadc::SetElecNoise ... done"<<endl;
|
---|
446 |
|
---|
447 | }
|
---|
448 |
|
---|
449 | void MFadc::ElecNoise(Float_t value) {
|
---|
450 | // ============================================================
|
---|
451 | //
|
---|
452 | // adds the noise due to optronic and electronic
|
---|
453 | // to the signal
|
---|
454 | //
|
---|
455 | UInt_t startslice;
|
---|
456 |
|
---|
457 | for ( Int_t i = 0 ; i < numpix; i++) {
|
---|
458 | //
|
---|
459 | // but at the beginning we must check if this pixel is
|
---|
460 | // hitted the first time
|
---|
461 | //
|
---|
462 |
|
---|
463 | startslice=GenElec->Integer(((Int_t)SLICES_MFADC)*1000);
|
---|
464 |
|
---|
465 | if ( used[i] == FALSE ) {
|
---|
466 | used [i] = TRUE ;
|
---|
467 |
|
---|
468 | memcpy( (Float_t*)&sig[i][0],
|
---|
469 | (Float_t*)&noise[startslice],
|
---|
470 | ((Int_t) SLICES_MFADC)*sizeof(Float_t));
|
---|
471 |
|
---|
472 | for ( Int_t is=0 ; is< (Int_t)SLICES_MFADC ; is++ ) {
|
---|
473 |
|
---|
474 | }
|
---|
475 | }
|
---|
476 | //
|
---|
477 | // Then the noise is introduced for each time slice
|
---|
478 | //
|
---|
479 | else
|
---|
480 | for ( Int_t is=0 ; is< (Int_t)SLICES_MFADC ; is++ ) {
|
---|
481 |
|
---|
482 | sig[i][is] += noise[startslice+is] ;
|
---|
483 |
|
---|
484 | }
|
---|
485 | }
|
---|
486 | }
|
---|
487 |
|
---|
488 | void MFadc::SetDigitalNoise(Float_t value){
|
---|
489 |
|
---|
490 | UInt_t i;
|
---|
491 | Float_t xrdm;
|
---|
492 |
|
---|
493 | cout<<"MFadc::SetDigitalNoise ... generating database for electronic noise."
|
---|
494 | <<endl;
|
---|
495 |
|
---|
496 | for (i=0;i<UInt_t(SLICES_MFADC*1001);i++){
|
---|
497 | xrdm=GenElec->Gaus(0., value);
|
---|
498 | digital_noise[i]=(xrdm>0?Int_t(xrdm+0.5):Int_t(xrdm-0.5));
|
---|
499 | }
|
---|
500 |
|
---|
501 | cout<<"MFadc::SetDigitalNoise ... done"<<endl;
|
---|
502 |
|
---|
503 | }
|
---|
504 |
|
---|
505 | void MFadc::DigitalNoise() {
|
---|
506 | // ============================================================
|
---|
507 | //
|
---|
508 | // adds the noise due to optronic and electronic
|
---|
509 | // to the signal
|
---|
510 | //
|
---|
511 | UInt_t startslice;
|
---|
512 |
|
---|
513 | for ( Int_t i = 0 ; i < numpix; i++) {
|
---|
514 |
|
---|
515 | if ( used[i] == TRUE ) {
|
---|
516 | startslice=GenElec->Integer((Int_t) SLICES_MFADC*999);
|
---|
517 | //
|
---|
518 | // Then the noise is introduced for each time slice
|
---|
519 | //
|
---|
520 | for ( Int_t is=0 ; is< FADC_SLICES; is++ ) {
|
---|
521 |
|
---|
522 | if(digital_noise[startslice+is]+Int_t(output[i][is])<0)
|
---|
523 | output[i][is] = 0;
|
---|
524 | else
|
---|
525 | output[i][is] =
|
---|
526 | (digital_noise[startslice+is]+Int_t(output[i][is])>255 ?
|
---|
527 | 255 :
|
---|
528 | UChar_t(digital_noise[startslice+is]+Int_t(output[i][is])));
|
---|
529 | if(digital_noise[startslice+FADC_SLICES+is]+Int_t(output_lowgain[i][is])<0)
|
---|
530 | output_lowgain[i][is] = 0;
|
---|
531 | else
|
---|
532 | output_lowgain[i][is] =
|
---|
533 | (digital_noise[startslice+FADC_SLICES+is]
|
---|
534 | +Int_t(output_lowgain[i][is])>255?
|
---|
535 | 255:
|
---|
536 | UChar_t(digital_noise[startslice+FADC_SLICES+is]
|
---|
537 | +Int_t(output_lowgain[i][is])));
|
---|
538 | }
|
---|
539 | }
|
---|
540 | }
|
---|
541 | }
|
---|
542 |
|
---|
543 |
|
---|
544 | void MFadc::Scan() {
|
---|
545 |
|
---|
546 |
|
---|
547 | for ( Int_t ip=0; ip<numpix; ip++ ) {
|
---|
548 |
|
---|
549 | if ( used[ip] == kTRUE ) {
|
---|
550 |
|
---|
551 | printf ("Pid %3d", ip ) ;
|
---|
552 |
|
---|
553 | for ( Int_t is=0 ; is < (Int_t)SLICES_MFADC; is++ ) {
|
---|
554 |
|
---|
555 | if ( sig[ip][is] > 0. ) {
|
---|
556 | printf (" %4.1f/", sig[ip][is] ) ;
|
---|
557 | }
|
---|
558 | else {
|
---|
559 | printf ("----/" ) ;
|
---|
560 | }
|
---|
561 | }
|
---|
562 |
|
---|
563 | printf ("\n");
|
---|
564 |
|
---|
565 | }
|
---|
566 | }
|
---|
567 |
|
---|
568 | }
|
---|
569 |
|
---|
570 | void MFadc::Scan(Float_t time) {
|
---|
571 |
|
---|
572 | //
|
---|
573 | // first of all we subtract from the time a offset (8 ns)
|
---|
574 | //
|
---|
575 |
|
---|
576 | Float_t t ;
|
---|
577 |
|
---|
578 | (0 > time - TIME_BEFORE_TRIGGER)? t=0: t=(time-TIME_BEFORE_TRIGGER) ; // to show also the start of the pulse before the trigger time
|
---|
579 |
|
---|
580 | if ( t < 0. ) {
|
---|
581 | cout << " WARNING!! FROM MFADC::SCAN(t) " << endl ;
|
---|
582 | exit (776) ;
|
---|
583 | }
|
---|
584 |
|
---|
585 | //
|
---|
586 | // calculate the first slice to write out
|
---|
587 | //
|
---|
588 |
|
---|
589 | Int_t iFirstSlice ;
|
---|
590 |
|
---|
591 | iFirstSlice = (Int_t) ( t / WIDTH_FADC_TIMESLICE ) ;
|
---|
592 |
|
---|
593 | for ( Int_t ip=0; ip<numpix; ip++ ) {
|
---|
594 |
|
---|
595 | if ( used[ip] == kTRUE ) {
|
---|
596 |
|
---|
597 | printf ("Pid %3d", ip ) ;
|
---|
598 |
|
---|
599 | for ( Int_t is=iFirstSlice ; is < (iFirstSlice+15); is++ ) {
|
---|
600 | printf (" %5.2f /", sig[ip][is] ) ;
|
---|
601 | }
|
---|
602 |
|
---|
603 | printf ("\n");
|
---|
604 |
|
---|
605 | }
|
---|
606 | }
|
---|
607 | }
|
---|
608 |
|
---|
609 | void MFadc::GetResponse( Float_t *resp ) {
|
---|
610 | // ============================================================
|
---|
611 | //
|
---|
612 | // puts the standard response function into the array resp
|
---|
613 |
|
---|
614 | for ( Int_t i=0; i< RESPONSE_SLICES; i++ ) {
|
---|
615 |
|
---|
616 | resp[i] = sing_resp[i] ;
|
---|
617 | }
|
---|
618 | }
|
---|
619 |
|
---|
620 | void MFadc::GetPedestals( Float_t *offset) {
|
---|
621 | // ============================================================
|
---|
622 | //
|
---|
623 | // puts the pedestal values into the array offset
|
---|
624 |
|
---|
625 | for ( Int_t i=0; i< numpix; i++ ) {
|
---|
626 |
|
---|
627 | offset[i] = pedestal[i] ;
|
---|
628 | }
|
---|
629 | }
|
---|
630 |
|
---|
631 | Float_t MFadc::GetPedestalNoise( Int_t pix, Int_t ishigh) {
|
---|
632 | // ============================================================
|
---|
633 | //
|
---|
634 | // computes the pedestal sigma for channel pix
|
---|
635 |
|
---|
636 | Float_t rms=0;
|
---|
637 | UChar_t value=0;
|
---|
638 |
|
---|
639 | Float_t factor;
|
---|
640 | UInt_t startslice;
|
---|
641 |
|
---|
642 | factor=(ishigh?1.0:high2low_gain);
|
---|
643 |
|
---|
644 | startslice=GenElec->Integer((Int_t) SLICES_MFADC*999);
|
---|
645 |
|
---|
646 | for ( Int_t is=0; is < (Int_t)SLICES_MFADC ; is++ ) {
|
---|
647 | if (pedestal[pix]+(sig[pix][is]-pedestal[pix])/factor>0.0){
|
---|
648 | value=(pedestal[pix]+(sig[pix][is]-pedestal[pix])/factor > 255.
|
---|
649 | ? 255
|
---|
650 | :UChar_t(pedestal[pix]+(sig[pix][is]-pedestal[pix])/factor+0.5));
|
---|
651 | if(Int_t(value)+digital_noise[startslice+is]<0.0)
|
---|
652 | value=0;
|
---|
653 | else
|
---|
654 | value=(Int_t(value)+digital_noise[startslice+is]>255
|
---|
655 | ?255
|
---|
656 | :UChar_t(Int_t(value)+digital_noise[startslice+is]));
|
---|
657 | }
|
---|
658 | else {
|
---|
659 | value= 0;
|
---|
660 | if(Int_t(value)+digital_noise[startslice+is]<0.0)
|
---|
661 | value=0;
|
---|
662 | else
|
---|
663 | value=(Int_t(value)+digital_noise[startslice+is]>255
|
---|
664 | ?255
|
---|
665 | :UChar_t(Int_t(value)+digital_noise[startslice+is]));
|
---|
666 | }
|
---|
667 | rms+=((Float_t)value-pedestal[pix])*((Float_t)value-pedestal[pix]);
|
---|
668 | }
|
---|
669 |
|
---|
670 | rms=sqrt(rms/(SLICES_MFADC-1));
|
---|
671 |
|
---|
672 | return rms;
|
---|
673 | }
|
---|
674 |
|
---|
675 | void MFadc::TriggeredFadc(Float_t time) {
|
---|
676 |
|
---|
677 | //
|
---|
678 | // first of all we subtract from the time a offset (8 ns)
|
---|
679 | //
|
---|
680 |
|
---|
681 | Float_t t ;
|
---|
682 |
|
---|
683 | (0>time-TIME_BEFORE_TRIGGER)? t=0: t=(time-TIME_BEFORE_TRIGGER) ; // to show also the start of the pulse before the trigger time
|
---|
684 |
|
---|
685 | if ( t < 0. ) {
|
---|
686 | cout << " WARNING!! FROM MFADC::SCAN(t) " << endl ;
|
---|
687 | exit (776) ;
|
---|
688 | }
|
---|
689 |
|
---|
690 | //
|
---|
691 | // calculate the first slice to write out
|
---|
692 | //
|
---|
693 |
|
---|
694 | Int_t iFirstSlice ;
|
---|
695 | Int_t i;
|
---|
696 |
|
---|
697 | iFirstSlice = (Int_t) ( t / WIDTH_FADC_TIMESLICE ) ;
|
---|
698 |
|
---|
699 | for ( Int_t ip=0; ip<numpix; ip++ ) {
|
---|
700 |
|
---|
701 | if ( used[ip] == kTRUE ) {
|
---|
702 | i=0;
|
---|
703 | for ( Int_t is=iFirstSlice ; is < (iFirstSlice+FADC_SLICES) ; is++ ) {
|
---|
704 | if (is< (Int_t)SLICES_MFADC && sig[ip][is]>0.0)
|
---|
705 | {
|
---|
706 |
|
---|
707 | output[ip][i]=(sig[ip][is] > 255. ? 255 :(UChar_t) (sig[ip][is]+0.5));
|
---|
708 | output_lowgain[ip][i]=
|
---|
709 | (Int_t)(pedestal[ip]+(sig[ip][is]-pedestal[ip])/high2low_gain+0.5) > 255. ? 255 :
|
---|
710 | (UChar_t)(pedestal[ip]+(sig[ip][is]-pedestal[ip])/high2low_gain+0.5);
|
---|
711 | i++;
|
---|
712 |
|
---|
713 | }
|
---|
714 | else if(sig[ip][is]>=0.0)
|
---|
715 | {
|
---|
716 | output[ip][i]= (UChar_t)(pedestal[ip]+0.5);
|
---|
717 | output_lowgain[ip][i]= (UChar_t)(pedestal[ip]+0.5);
|
---|
718 | i++;
|
---|
719 | }
|
---|
720 | else
|
---|
721 | {
|
---|
722 | output[ip][i]= 0;
|
---|
723 | if((pedestal[ip]+(sig[ip][is]-pedestal[ip])/high2low_gain)<0)
|
---|
724 | output_lowgain[ip][i]= 0;
|
---|
725 | else
|
---|
726 | output_lowgain[ip][i]=(UChar_t)(pedestal[ip]+(sig[ip][is]-pedestal[ip])/high2low_gain+0.5);
|
---|
727 | i++;
|
---|
728 | }
|
---|
729 | }
|
---|
730 |
|
---|
731 | }
|
---|
732 | }
|
---|
733 | }
|
---|
734 |
|
---|
735 | void MFadc::ShowSignal (MMcEvt *McEvt, Float_t trigTime) {
|
---|
736 | // ============================================================
|
---|
737 | //
|
---|
738 | // This method is used to book the histogram to show the signal in
|
---|
739 | // a special gui frame (class MGTriggerSignal). After the look onto the
|
---|
740 | // signals for a better understanding of the things we will expect
|
---|
741 | // the gui frame and all histogramms will be destroyed.
|
---|
742 | //
|
---|
743 |
|
---|
744 | //
|
---|
745 | // first of all create a list of the histograms to show
|
---|
746 | //
|
---|
747 | // take only that one with a entry
|
---|
748 |
|
---|
749 | TH1F *hist ;
|
---|
750 | Char_t dumm[10];
|
---|
751 | Char_t name[256];
|
---|
752 |
|
---|
753 | TObjArray *AList ;
|
---|
754 | AList = new TObjArray(10) ;
|
---|
755 |
|
---|
756 | // the list of analog signal histograms
|
---|
757 | // at the beginning we initalise 10 elements
|
---|
758 | // but this array expand automaticly if neccessay
|
---|
759 |
|
---|
760 | Int_t ic = 0 ;
|
---|
761 | for ( Int_t i=0 ; i < numpix; i++ ) {
|
---|
762 | if ( used [i] == TRUE ) {
|
---|
763 |
|
---|
764 | sprintf (dumm, "FADC_%d", i ) ;
|
---|
765 | sprintf (name, "fadc signal %d", i ) ;
|
---|
766 |
|
---|
767 | hist = new TH1F(dumm, name, SLICES_MFADC, 0., TOTAL_TRIGGER_TIME);
|
---|
768 | //
|
---|
769 | // fill the histogram
|
---|
770 | //
|
---|
771 |
|
---|
772 | for (Int_t ibin=1; ibin <=(Int_t)SLICES_MFADC; ibin++) {
|
---|
773 | hist->SetBinContent (ibin, sig[i][ibin-1]) ;
|
---|
774 | }
|
---|
775 |
|
---|
776 | // hist->SetMaximum( 5.);
|
---|
777 | // hist->SetMinimum(-10.);
|
---|
778 | hist->SetStats(kFALSE);
|
---|
779 |
|
---|
780 | // hist->SetAxisRange(0., 80. ) ;
|
---|
781 |
|
---|
782 | AList->Add(hist) ;
|
---|
783 |
|
---|
784 | ic++ ;
|
---|
785 | }
|
---|
786 | }
|
---|
787 |
|
---|
788 | //
|
---|
789 | // create the Gui Tool
|
---|
790 | //
|
---|
791 | //
|
---|
792 |
|
---|
793 | new MGFadcSignal(McEvt,
|
---|
794 | AList,
|
---|
795 | trigTime,
|
---|
796 | gClient->GetRoot(),
|
---|
797 | gClient->GetRoot(),
|
---|
798 | 400, 400 ) ;
|
---|
799 |
|
---|
800 | //
|
---|
801 | // delete the List of histogramms
|
---|
802 | //
|
---|
803 | AList->Delete() ;
|
---|
804 |
|
---|
805 | delete AList ;
|
---|
806 | }
|
---|
807 |
|
---|
808 | UChar_t MFadc::GetFadcSignal(Int_t pixel, Int_t slice){
|
---|
809 |
|
---|
810 | // It returns the analog signal for a given pixel and a given FADC
|
---|
811 | // time slice which would be read.
|
---|
812 |
|
---|
813 | return (output[pixel][slice]);
|
---|
814 | }
|
---|
815 |
|
---|
816 |
|
---|
817 | UChar_t MFadc::GetFadcLowGainSignal(Int_t pixel, Int_t slice){
|
---|
818 |
|
---|
819 | // It returns the analog signal for a given pixel and a given FADC
|
---|
820 | // time slice which would be read.
|
---|
821 |
|
---|
822 | return (output_lowgain[pixel][slice]);
|
---|
823 | }
|
---|
824 |
|
---|
825 |
|
---|
826 |
|
---|