source: trunk/MagicSoft/include-Classes/MRawEvt.cxx@ 434

Last change on this file since 434 was 434, checked in by harald, 24 years ago
Changed the format for root to store the raw data from the pixels. This is the version that was discussed on the software meeting in Goettingen.
File size: 7.7 KB
Line 
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#include "MRawCrate.h"
9
10#include "Mdefine.h"
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 and the class MRawCrate to describe Crates.
18// To define a single events some other data members are needed
19// (Time of the events, tirgger pattern of event..)
20//
21// To describe one event on the level of FADC values the Class MRawEvt is
22// created. It has the following data members:
23//
24// ----------
25//
26// UInt_t DAQEvtNumber
27//
28// This it the number of the Event in one
29// data run. The first event in this run get
30// the number zero. The next one is one bigger.
31//
32// Assuming that one run takes 1 hour and a
33// triggerrate of 1kHz the number must be able
34// to reach 3.6e6 Events. To reach this number
35// you need at least 22 bits. This is the reason
36// why we use an integer (of root type UInt_t)
37// with a range to 4.2e9.
38//
39// ----------
40//
41// UInt_t AbsTime[2]
42//
43// Time of the event.
44// The start point of the time determination can be
45// the millenium. From that start point the time is
46// measured in 200ns-count. One day for example
47// contains 432.e9 counts. An array of two unsigned Int is able to
48// contain 1.8e19 200ns-counts. This corresponds to 41.e6
49// days. This should be more than the livetime of MAGIC.
50//
51// ----------
52//
53// UInt_t FstLvlTrigNumber
54//
55// Number of first level trigger
56// This member counts the number of First Level Trigger
57// between the last and this event. May be that due to
58// dead time of the DAQ this number is different from 1.
59// If the DAQ is fast enough, this value should be 1.
60// This may be usefull in GammaRayBursts and if we
61// apply a data reduction in the DAQ-chain, which selects
62// only good events.
63//
64// ----------
65//
66// UInt_t SecLvlTrigNumber
67//
68// Number of second level trigger
69// This member counts the number of Second Level Trigger
70// between the last and this event.
71//
72// ----------
73//
74// UInt_t TriggerPattern[2]
75//
76// Trigger Pattern used for this event
77// Each event triggers for a particular configuration and each
78// configuration shoul have an ID (which is not fixed yet).
79//
80// ----------
81//
82// Byte_t TriggerType
83//
84// Type of Trigger.
85// This is a Byte (8 bit) to indicated the status of
86// the event (Normal (0), Pedestal (1), Calibration (2), etc).
87//
88// ----------
89//
90// Byte_t AllLowGainOn
91//
92// Type of Trigger.
93// This is a Byte (8 bit) to indicated if any of the pixels
94// have a non-negligible low gain (1) or not (0)
95//
96// ----------
97//
98// TClonesArray *Crates
99//
100// Array of Crates
101// The Clones array is a list of the Crates used in one
102// event with the information about the Crate.
103//
104// ----------
105//
106// TClonesArray *PixelsHigh
107//
108// Array of Pixels for their high voltage channel
109// The Clones array is a list of the Pixels used in one
110// event with the information about the Pixels.
111//
112//
113// ----------
114//
115// TClonesArray *PixelsLow
116//
117// Array of Pixels for their low voltage channel
118// The Clones array is a list of the Pixels used in one
119// event that have a significant signal in the low gain channel
120// with the information about the Pixels.
121//
122//
123
124//
125void GetFadcNoise ( Byte_t asF[] )
126{
127 static TRandom Gen ;
128 static Float_t z1, z2 ;
129 for (Int_t i=0; i<FADC_SLICES; i++ ) {
130 Gen.Rannor(z1, z2) ;
131 asF[i] = 10 + (Byte_t)(z1*4) ;
132 // if (asF[i] < 0 ) asF[i] = 0 ;
133 }
134}
135
136ClassImp(MRawEvt)
137
138MRawEvt::MRawEvt() {
139 //
140 // Implementation of the default constructor
141 //
142 // set all member to zero, init the pointer to ClonesArray,
143
144 DAQEvtNumber = 0 ;
145 AbsTime[0] = AbsTime [1] = 0 ;
146 FstLvlTrigNumber = 0 ;
147 SecLvlTrigNumber = 0 ;
148 TriggerPattern[0] = TriggerPattern[1] = 0 ;
149 TriggerType = 0 ;
150 AllLowGainOn = 0 ;
151
152 //
153 // Then we have to initialize the ClonesArray list for the Pixels.
154 // This is neccessary once!
155 //
156 // initialize the list to this global pointer
157
158 PixelsHigh = new TClonesArray ("MRawPixel", 5*CAMERA_PIXELS ) ;
159 PixelsLow = new TClonesArray ("MRawPixel", CAMERA_PIXELS ) ;
160 Crates = new TClonesArray ("MRawCrate", 25 ) ;
161
162 cout << " default constructor " << endl ;
163}
164
165
166MRawEvt::~MRawEvt() {
167 //
168 // Implementation of the default destructor
169 //
170 delete PixelsHigh ;
171 delete PixelsLow ;
172 delete Crates ;
173 cout << " default destructor " << endl ;
174}
175
176void MRawEvt::Clear() {
177 //
178 // Implementation of the Clear function
179 //
180 // Resets all members to zero, clear the list of Pixels
181 //
182 DAQEvtNumber = 0 ;
183 AbsTime[0] = AbsTime [1] = 0 ;
184 FstLvlTrigNumber = 0 ;
185 SecLvlTrigNumber = 0 ;
186 TriggerPattern[0] = TriggerPattern[1] = 0 ;
187 TriggerType = 0 ;
188 AllLowGainOn = 0 ;
189
190 PixelsHigh->Clear() ;
191 PixelsLow->Clear() ;
192 Crates -> Clear() ;
193}
194
195
196
197void MRawEvt::Print() {
198 //
199 // This member function prints all Data of one Event on screen.
200 //
201
202 Int_t i = 0;
203
204 // Prints out the data of one Pixel
205 cout << endl << "EventNumber " << DAQEvtNumber ;
206 cout << endl << "Event Time Stamp " << (Float_t) AbsTime[0]*4294967296
207 +AbsTime[1] ;
208 cout << endl << "Trigger 1. Level " << FstLvlTrigNumber ;
209 cout << endl << "Trigger 2. Level " << SecLvlTrigNumber ;
210 cout << endl << "Trigger Pattern " << (Float_t) TriggerPattern[0]*4294967296
211 +TriggerPattern[1] ;
212 cout << endl << "Trigger Type ";
213 switch (TriggerType){
214 case 0:
215 cout<<" Normal Trigger ";
216 break;
217 case 1:
218 cout<<" Pedestal ";
219 break;
220 case 2:
221 cout<<" Calibration ";
222 break;
223 default:
224 cout<<TriggerType;
225 break;
226 }
227
228 cout<<"High Voltage channel"<<endl;
229 while (PixelsHigh+i) {
230 ((MRawPixel *)PixelsHigh->At(i))->Print() ;
231 i++;
232 }
233 cout<<"Low Voltage channel"<<endl;
234 while (PixelsLow+i) {
235 ((MRawPixel *)PixelsLow->At(i))->Print() ;
236 i++;
237 }
238}
239
240void MRawEvt::FillHeader ( UInt_t uiN, Float_t ulT, Float_t ulTP ) {
241
242 DAQEvtNumber = uiN ;
243 AbsTime[0] = (UInt_t) (ulT/4294967296) ;
244 AbsTime[1] = (UInt_t) (ulT-AbsTime[0]*4294967296) ;
245 TriggerPattern[0] = (UInt_t) (ulTP/4294967296) ;
246 TriggerPattern[1] = (UInt_t) (ulTP-TriggerPattern[0]*4294967296) ;
247
248}
249
250void MRawEvt::FillPixel ( Short_t siPix, UShort_t *MultPixel, Float_t *array ) {
251 //
252 // This is to fill the data of one pixel to the MRawEvt Class.
253 // The parameters are the pixelnumber and the FADC_SLICES values of ADCs
254 //
255
256 Int_t i = 0;
257 Byte_t ucA[FADC_SLICES] ;
258
259 for(i=0;i<FADC_SLICES;i++){
260 ucA[i] = (Byte_t) array[i] ;
261 }
262
263 TClonesArray &caP = *PixelsHigh ;
264 new ( caP[(*(MultPixel))++] ) MRawPixel((siPix), ucA) ;
265}
266
267void MRawEvt::FillPixelLow ( Short_t siPix, UShort_t *MultPixel, Float_t *array ) {
268 //
269 // This is to fill the data of one pixel to the MRawEvt Class.
270 // The parameters are the pixelnumber and the FADC_SLICES values of ADCs
271 //
272
273 Int_t i = 0;
274 Byte_t ucA[FADC_SLICES] ;
275
276 for(i=0;i<FADC_SLICES;i++){
277 ucA[i] = (Byte_t) array[i] ;
278 }
279
280 TClonesArray &caP = *PixelsLow ;
281 new ( caP[(*(MultPixel))++] ) MRawPixel((siPix), ucA) ;
282}
283
284UShort_t MRawEvt::GetMultPixel(){
285 //
286 // returns the number of pixells which are already in the list
287 //
288
289 UShort_t i =0;
290 while(PixelsHigh+i) i++;
291 return (i);
292}
293
294// void MRawEvt::AddPixel ( UShort_t usP ) {
295// //
296// // Implementation of the AddPixel function
297// //
298
299// cout << " need implementation " << endl ;
300// }
301
302// void MRawEvt::AddPixel ( UShort_t usP, UChar_t ucStat, Byte_t ausAR[] ) {
303// cout << " need implementation 2 " << endl ;
304// }
Note: See TracBrowser for help on using the repository browser.