source: trunk/MagicSoft/MarsOctober/mrootformat/MRawEvt.cc@ 9128

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