source: branches/start/MagicSoft/Simulation/Detector/include-MFadc/MFadc.cxx

Last change on this file was 378, checked in by harald, 25 years ago
This is the startpoint for the further development of the FADC system. This implementation of the class MFadc is based on the implementation of the class MTRigger (see ../include-MTrigger ).
File size: 6.1 KB
Line 
1/////////////////////////////////////////////////////////////////
2//
3// MFadc
4//
5//
6#include "MFadc.hxx"
7
8#include "MMcEvt.h"
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
20MFadc::MFadc() {
21 //
22 // default constructor
23 //
24 // The procedure is the following:
25 // 1. some parameters of the trigger are set to default.
26 // this parameters of the trigger may be changed
27 // 3. Then the all signals are set to zero
28
29 fwhm_resp = MFADC_RESPONSE_FWHM ;
30 ampl_resp = MFADC_RESPONSE_AMPLITUDE ;
31
32 //
33 // set up the response shape
34 //
35 Int_t i ;
36
37 Float_t sigma ;
38 Float_t x, x0 ;
39
40 sigma = fwhm_resp / 2.35 ;
41 x0 = 3*sigma ;
42
43 Float_t dX, dX2 ;
44
45 dX = WIDTH_FADC_TIMESLICE / SUBBINS ;
46 dX2 = dX/2. ;
47
48 for (i=0; i< RESPONSE_SLICES_MFADC ; i++ ) {
49
50 x = i * dX + dX2 ;
51
52 //
53 // the value 0.125 was introduced to normalize the things
54 //
55 sing_resp[i] = 0.125 *
56 ampl_resp * expf(-0.5 * (x-x0)*(x-x0) / (sigma*sigma) ) ;
57
58 }
59
60 //
61 // init the Random Generator for Electonic Noise
62 //
63
64 GenElec = new TRandom () ;
65
66 //
67 // set all the booleans used to FALSE, indicating that the pixel is not
68 // used in this event.
69 //
70
71 for ( i =0 ; i <CAMERA_PIXELS ; i++ ) {
72 used [i] = FALSE ;
73 }
74}
75
76
77void MFadc::Reset() {
78 //
79 // set all values of the signals to zero
80 //
81 Int_t i ;
82
83 for ( i =0 ; i <CAMERA_PIXELS ; i++ ) {
84 used [i] = FALSE ;
85 }
86}
87
88
89void MFadc::Fill( Int_t iPix, Float_t time, Float_t amplitude ) {
90
91 //
92 // fills the information about one single Phe in the Trigger class
93 //
94 // parameter is the number of the pixel and the time-difference to the
95 // first particle
96 //
97 //
98
99 Int_t i, ichan, ichanfadc ;
100
101 //
102 // first we have to check if the pixel iPix is used or not until now
103 // if this is the first use, reset all signal for that pixels
104 //
105 if ( iPix > CAMERA_PIXELS ) {
106 cout << " WARNING: MFadc::Fill() : iPix greater than CAMERA_PIXELS"
107 << endl ;
108 exit(987) ;
109 }
110
111 if ( used[iPix] == FALSE ) {
112 used [iPix] = TRUE ;
113
114 for (i=0; i < SLICES_MFADC; i++ ) {
115 sig[iPix][i] = 0. ;
116 }
117 }
118
119 //
120 // then select the time slice to use (ican)
121 //
122
123
124 if ( time < 0. ) {
125 cout << " WARNING! Fadc::Fill " << time << " below ZERO!! Very strange!!"
126 << endl ;
127 }
128 else if ( time < TOTAL_TRIGGER_TIME ) {
129 //
130 // determine the slices number assuming the WIDTH_RESPONSE_MFADC
131 //
132 ichan = (Int_t) ( time / ((Float_t) WIDTH_RESPONSE_MFADC ));
133
134 //
135 // putting the response slices in the right sig slices.
136 // Be carefull, because both slices have different widths.
137 //
138
139 for ( i = 0 ; i<RESPONSE_SLICES; i++ ) {
140 ichanfadc = (Int_t) ((ichan+i)/SUBBINS) ;
141 if ( (ichanfadc) < SLICES_MFADC ) {
142 sig[iPix][ichanfadc] += (amplitude * sing_resp[i] ) ;
143 }
144 }
145 }
146 else {
147 cout << " WARNING! Fadc::Fill " << time << " out of TriggerTimeRange "
148 << TOTAL_TRIGGER_TIME << endl ;
149 }
150
151}
152
153void MFadc::ElecNoise() {
154 //
155 //
156 //
157
158 for ( Int_t i = 0 ; i < CAMERA_PIXELS; i++) {
159 if ( used [i] == TRUE ) {
160
161 for ( Int_t is=0 ; is< SLICES_MFADC ; is++ ) {
162
163 sig[i][is] += GenElec->Gaus(0., 2.) ;
164 }
165 }
166 }
167}
168
169
170
171void MFadc::Scan() {
172
173
174 for ( Int_t ip=0; ip<CAMERA_PIXELS; ip++ ) {
175
176 if ( used[ip] == kTRUE ) {
177
178 printf ("Pid %3d", ip ) ;
179
180 for ( Int_t is=0 ; is < SLICES_MFADC; is++ ) {
181
182 if ( sig[ip][is] > 0. ) {
183 printf (" %4.1f/", sig[ip][is] ) ;
184 }
185 else {
186 printf ("----/" ) ;
187 }
188 }
189
190 printf ("\n");
191
192 }
193 }
194
195}
196
197void MFadc::Scan(Float_t time) {
198
199 //
200 // first of all we subtract from the time a offset (8 ns)
201 //
202
203 Float_t t ;
204
205 t = time - 10. ; // to show also the start of the pulse before the
206 // the trigger time
207
208 if ( t < 0. ) {
209 cout << " WARNING!! FROM MFADC::SCAN(t) " << endl ;
210 exit (776) ;
211 }
212
213 //
214 // calculate the first slice to write out
215 //
216
217 Int_t iFirstSlice ;
218
219 iFirstSlice = (Int_t) ( t / WIDTH_FADC_TIMESLICE ) ;
220
221 for ( Int_t ip=0; ip<CAMERA_PIXELS; ip++ ) {
222
223 if ( used[ip] == kTRUE ) {
224
225 printf ("Pid %3d", ip ) ;
226
227 for ( Int_t is=iFirstSlice ; is < (iFirstSlice+15); is++ ) {
228 printf (" %5.2f /", sig[ip][is] ) ;
229 }
230
231 printf ("\n");
232
233 }
234 }
235}
236
237
238
239void MFadc::ShowSignal (MMcEvt *McEvt, Float_t trigTime) {
240 // ============================================================
241 //
242 // This method is used to book the histogramm to show the signal in
243 // a special gui frame (class MGTriggerSignal). After the look onto the
244 // signals for a better understanding of the things we will expect
245 // the gui frame and all histogramms will be destroyed.
246 //
247
248 //
249 // first of all create a list of the histograms to show
250 //
251 // take only that one with a entry
252
253 TH1F *hist ;
254 Char_t dumm[10];
255 Char_t name[256];
256
257 TObjArray *AList ;
258 AList = new TObjArray(10) ;
259
260 // the list of analog signal histograms
261 // at the beginning we initalise 10 elements
262 // but this array expand automaticly if neccessay
263
264 Int_t ic = 0 ;
265 for ( Int_t i=0 ; i < CAMERA_PIXELS; i++ ) {
266 if ( used [i] == TRUE ) {
267
268 sprintf (dumm, "FADC_%d", i ) ;
269 sprintf (name, "fadc signal %d", i ) ;
270
271 hist = new TH1F(dumm, name, SLICES_MFADC, 0., TOTAL_TRIGGER_TIME);
272 //
273 // fill the histogram
274 //
275
276 for (Int_t ibin=1; ibin <=SLICES_MFADC; ibin++) {
277 hist->SetBinContent (ibin, sig[i][ibin-1]) ;
278 }
279
280 // hist->SetMaximum( 5.);
281 // hist->SetMinimum(-10.);
282 hist->SetStats(kFALSE);
283
284 // hist->SetAxisRange(0., 80. ) ;
285
286 AList->Add(hist) ;
287
288 ic++ ;
289 }
290 }
291
292 //
293 // create the Gui Tool
294 //
295 //
296
297 new MGFadcSignal(McEvt,
298 AList,
299 trigTime,
300 gClient->GetRoot(),
301 gClient->GetRoot(),
302 400, 400 ) ;
303
304 //
305 // delete the List of histogramms
306 //
307 AList->Delete() ;
308
309 delete AList ;
310}
311
312
313
Note: See TracBrowser for help on using the repository browser.