1 | #include <iostream.h>
|
---|
2 | #include "TClonesArray.h"
|
---|
3 | #include "TString.h"
|
---|
4 | #include "TRandom.h"
|
---|
5 |
|
---|
6 | #include "MRawEvt.h"
|
---|
7 | #include "MRawPixel.h"
|
---|
8 |
|
---|
9 | #include "Mdefine.h"
|
---|
10 | //==========
|
---|
11 | // MRawEvt
|
---|
12 | //
|
---|
13 | // One Event is a sample of FADC measurements of different Pixels
|
---|
14 | // (Photomultipliers) from the Camera of MAGIC. So all data (FADC) of the
|
---|
15 | // interesting pixels are the modules of an event. To describe pixels the
|
---|
16 | // class MRawPixel is used. To define a single events
|
---|
17 | // some other data members are needed (Time of the events, kind of event..).
|
---|
18 | //
|
---|
19 | // To describe one event on the level of FADC values the Class MRawEvt is
|
---|
20 | // created. It has the following data members:
|
---|
21 | //
|
---|
22 | // ----------
|
---|
23 | //
|
---|
24 | // UInt_t uiEvtNo
|
---|
25 | //
|
---|
26 | // This it the number of the Event in one
|
---|
27 | // data run. The first event in this run get
|
---|
28 | // the number zero. The next one is one bigger.
|
---|
29 | //
|
---|
30 | // Assuming that one run takes 1 hour and a
|
---|
31 | // triggerrate of 1kHz the number must be able
|
---|
32 | // to reach 3.6e6 Events. To reach this number
|
---|
33 | // you need at least 22 bits. This is the reason
|
---|
34 | // why we use an integer (of root type UInt_t)
|
---|
35 | // with a range to 4.2e9.
|
---|
36 | //
|
---|
37 | // ----------
|
---|
38 | //
|
---|
39 | // ULong_t ulTimeStamp
|
---|
40 | //
|
---|
41 | // Time of the event.
|
---|
42 | // The start point of the time determination can be
|
---|
43 | // the millenium. From that start point the time is
|
---|
44 | // measured in 200ns-count. One day for example
|
---|
45 | // contains 432.e9 counts. An unsigned Long is able to
|
---|
46 | // contain 1.8e19 200ns-counts. This corresponds to 41.e6
|
---|
47 | // days. This should be more than the livetime of MAGIC.
|
---|
48 | //
|
---|
49 | // ----------
|
---|
50 | //
|
---|
51 | // UChar_t ucEvtStatus
|
---|
52 | //
|
---|
53 | // Status of Event.
|
---|
54 | // This is a Byte (8 bit) to indicated the status of
|
---|
55 | // the event (Pedestal, Calibration, etc).
|
---|
56 | //
|
---|
57 | // ----------
|
---|
58 | //
|
---|
59 | // UShort_t usTrig1st
|
---|
60 | //
|
---|
61 | // Number of first level trigger
|
---|
62 | // This member counts the number of First Level Trigger
|
---|
63 | // between the last and this event. May be that due to
|
---|
64 | // dead time of the DAQ this number is different from 1.
|
---|
65 | // If the DAQ is fast enough, this value should be 1.
|
---|
66 | // This may be usefull in GammaRayBursts and if we
|
---|
67 | // apply a data reduction in the DAQ-chain, which selects
|
---|
68 | // only good events.
|
---|
69 | //
|
---|
70 | // ----------
|
---|
71 | //
|
---|
72 | // UShort_t usMultPixel
|
---|
73 | //
|
---|
74 | // Multiplicity of Pixels
|
---|
75 | // Each event consists of a specific number of
|
---|
76 | // pixels. This is the number of pixels in one event.
|
---|
77 | // The array of ClonesPixels (taClonesArray) is of this
|
---|
78 | // size.
|
---|
79 | //
|
---|
80 | // ----------
|
---|
81 | //
|
---|
82 | // TClonesArray *taPixels
|
---|
83 | //
|
---|
84 | // Array of Pixels
|
---|
85 | // The Clones array is a list of the Pixels used in one
|
---|
86 | // event with the information about the Pixels.
|
---|
87 | //
|
---|
88 | //
|
---|
89 |
|
---|
90 | //
|
---|
91 | void GetFadcNoise ( UChar_t asF[] )
|
---|
92 | {
|
---|
93 | static TRandom Gen ;
|
---|
94 | static Float_t z1, z2 ;
|
---|
95 | for (Int_t i=0; i<FADC_SLICES; i++ ) {
|
---|
96 | Gen.Rannor(z1, z2) ;
|
---|
97 | asF[i] = 10 + (UChar_t)(z1*4) ;
|
---|
98 | // if (asF[i] < 0 ) asF[i] = 0 ;
|
---|
99 | }
|
---|
100 | }
|
---|
101 |
|
---|
102 | ClassImp(MRawEvt)
|
---|
103 |
|
---|
104 | MRawEvt::MRawEvt() {
|
---|
105 | //
|
---|
106 | // Implementation of the default constructor
|
---|
107 | //
|
---|
108 | // set all member to zero, init the pointer to ClonesArray,
|
---|
109 |
|
---|
110 | uiEvtNo = 0 ;
|
---|
111 | ulTimeStamp = 0 ;
|
---|
112 | ucEvtStatus = 0 ;
|
---|
113 | usTrig1st = 0 ;
|
---|
114 | usMultPixel = 0 ;
|
---|
115 |
|
---|
116 | //
|
---|
117 | // Then we have to initialize the ClonesArray list for the Pixels.
|
---|
118 | // This is neccessary once!
|
---|
119 | //
|
---|
120 | // initialize the list to this global pointer
|
---|
121 |
|
---|
122 | taPixels = new TClonesArray ("MRawPixel", 2*CAMERA_PIXELS ) ;
|
---|
123 |
|
---|
124 | cout << " default constructor " << endl ;
|
---|
125 | }
|
---|
126 |
|
---|
127 |
|
---|
128 | MRawEvt::~MRawEvt() {
|
---|
129 | //
|
---|
130 | // Implementation of the default destructor
|
---|
131 | //
|
---|
132 | delete taPixels ;
|
---|
133 | cout << " default destructor " << endl ;
|
---|
134 | }
|
---|
135 |
|
---|
136 | void MRawEvt::Clear() {
|
---|
137 | //
|
---|
138 | // Implementation of the Clear function
|
---|
139 | //
|
---|
140 | // Resets all members to zero, clear the list of Pixels
|
---|
141 | //
|
---|
142 | uiEvtNo = 0 ;
|
---|
143 | ulTimeStamp = 0 ;
|
---|
144 | ucEvtStatus = 0 ;
|
---|
145 | usTrig1st = 0 ;
|
---|
146 | usMultPixel = 0 ;
|
---|
147 |
|
---|
148 | taPixels->Clear() ;
|
---|
149 | }
|
---|
150 |
|
---|
151 |
|
---|
152 |
|
---|
153 | void MRawEvt::Print() {
|
---|
154 | //
|
---|
155 | // This member function prints all Data of one Event on screen.
|
---|
156 | //
|
---|
157 |
|
---|
158 | // Prints out the data of one Pixel
|
---|
159 | cout << endl << "EventNumber " << uiEvtNo ;
|
---|
160 | cout << endl << "Event Time Stamp " << ulTimeStamp ;
|
---|
161 | cout << endl << "Event Status " << (int) ucEvtStatus ;
|
---|
162 | cout << endl << "Trigger 1. Level " << usTrig1st ;
|
---|
163 | cout << endl << "Number of Pixels " << usMultPixel ;
|
---|
164 |
|
---|
165 | for (Int_t i=0 ; i<usMultPixel; i++ ) {
|
---|
166 | ((MRawPixel *)taPixels->At(i))->Print() ;
|
---|
167 | }
|
---|
168 | }
|
---|
169 |
|
---|
170 |
|
---|
171 | void MRawEvt::FillRandom ( UInt_t uiN, ULong_t ulT, UShort_t usMuPi ) {
|
---|
172 | //
|
---|
173 | // This is neccessary to fill the MRawEvt Class with randomized FADC
|
---|
174 | // values. The EventNumber, EventTime and the Number of Pixels are given
|
---|
175 | // as parameters.
|
---|
176 | //
|
---|
177 |
|
---|
178 | uiEvtNo = uiN ;
|
---|
179 | ulTimeStamp = ulT ;
|
---|
180 |
|
---|
181 | UChar_t ucA[FADC_SLICES] ;
|
---|
182 |
|
---|
183 | for (UShort_t i = 0 ; i< usMuPi; i++ ) {
|
---|
184 | GetFadcNoise ( ucA ) ;
|
---|
185 |
|
---|
186 | TClonesArray &caP = *taPixels ;
|
---|
187 | new ( caP[usMultPixel++] ) MRawPixel((usMultPixel), 0, ucA) ;
|
---|
188 | }
|
---|
189 | }
|
---|
190 |
|
---|
191 | void MRawEvt::FillHeader ( UInt_t uiN, ULong_t ulT ) {
|
---|
192 |
|
---|
193 | uiEvtNo = uiN ;
|
---|
194 | ulTimeStamp = ulT ;
|
---|
195 |
|
---|
196 | ucEvtStatus = 0 ;
|
---|
197 | usTrig1st = 0 ;
|
---|
198 | usMultPixel = 0 ;
|
---|
199 |
|
---|
200 | taPixels->Clear() ;
|
---|
201 | }
|
---|
202 |
|
---|
203 | void MRawEvt::FillPixel ( UShort_t uiPix, Float_t *array ) {
|
---|
204 | //
|
---|
205 | // This is to fill the data of one pixel to the MRawEvt Class.
|
---|
206 | // The parameters are the pixelnumber and the FADC_SLICES values of ADCs
|
---|
207 | //
|
---|
208 |
|
---|
209 | UChar_t ucA[FADC_SLICES] ;
|
---|
210 |
|
---|
211 | for (UShort_t i = 0 ; i< FADC_SLICES ; i++ ) {
|
---|
212 | ucA[i] = (UShort_t) array[i] ;
|
---|
213 | }
|
---|
214 |
|
---|
215 | TClonesArray &caP = *taPixels ;
|
---|
216 | new ( caP[usMultPixel++] ) MRawPixel((uiPix), 0, ucA) ;
|
---|
217 | }
|
---|
218 |
|
---|
219 | void MRawEvt::FillMontCarl ( UInt_t uiN, ULong_t ulT, Float_t *array ) {
|
---|
220 | //
|
---|
221 | // This is neccessary to fill the MRawEvt Class with randomized FADC
|
---|
222 | // values. The EventNumber, EventTime and the Number of Pixels are given
|
---|
223 | // as parameters.
|
---|
224 | //
|
---|
225 |
|
---|
226 | uiEvtNo = uiN ;
|
---|
227 | ulTimeStamp = ulT ;
|
---|
228 |
|
---|
229 | usMultPixel = 0 ;
|
---|
230 |
|
---|
231 | UChar_t ucA[FADC_SLICES] ;
|
---|
232 |
|
---|
233 | for (UShort_t i = 0 ; i< CAMERA_PIXELS; i++ ) {
|
---|
234 |
|
---|
235 | if ( array[i] > 0. ) {
|
---|
236 | for ( Int_t ii = 0 ; ii < FADC_SLICES ; ii++ ) {
|
---|
237 | ucA[ii] = 0 ;
|
---|
238 | }
|
---|
239 | ucA[5] = (UShort_t) (array[i]) ;
|
---|
240 |
|
---|
241 | TClonesArray &caP = *taPixels ;
|
---|
242 | new ( caP[usMultPixel++] ) MRawPixel(i, 0, ucA) ;
|
---|
243 | }
|
---|
244 | }
|
---|
245 | }
|
---|
246 |
|
---|
247 | UShort_t MRawEvt::GetMultPixel() {
|
---|
248 | //
|
---|
249 | // returns the pixel multiplicity of the Event
|
---|
250 | //
|
---|
251 | return usMultPixel;
|
---|
252 | }
|
---|
253 |
|
---|
254 |
|
---|
255 | // void MRawEvt::AddPixel ( UShort_t usP ) {
|
---|
256 | // //
|
---|
257 | // // Implementation of the AddPixel function
|
---|
258 | // //
|
---|
259 |
|
---|
260 | // cout << " need implementation " << endl ;
|
---|
261 | // }
|
---|
262 |
|
---|
263 | // void MRawEvt::AddPixel ( UShort_t usP, UChar_t ucStat, UChar_t ausAR[] ) {
|
---|
264 | // cout << " need implementation 2 " << endl ;
|
---|
265 | // }
|
---|
266 |
|
---|
267 |
|
---|
268 |
|
---|