source: trunk/MagicSoft/include-Classes/MRawFormat/MRawEvtHeader.cc@ 9029

Last change on this file since 9029 was 498, checked in by magicsol, 24 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 6.2 KB
Line 
1/////////////////////////////////////////////////////////////////////////////
2//
3// MRawEvtHeader
4//
5// One Event is a sample of FADC measurements of different Pixels
6// (Photomultipliers) from the Camera of MAGIC. So all data (FADC) of the
7// interesting pixels are the modules of an event. To describe pixels the
8// class MRawPixel is used and the class MRawCrate to describe Crates.
9// To define a single events some other data members are needed
10// (Time of the events, tirgger pattern of event..)
11//
12// To describe one event on the level of FADC values the Class MRawEvtHeader is
13// created. It has the following data members:
14//
15// UInt_t fDAQEvtNumber
16// -----------------------
17// This it the number of the Event in one
18// data run. The first event in this run get
19// the number zero. The next one is one bigger.
20//
21// Assuming that one run takes 1 hour and a
22// triggerrate of 1kHz the number must be able
23// to reach 3.6e6 Events. To reach this number
24// you need at least 22 bits. This is the reason
25// why we use an integer (of root type UInt_t)
26// with a range to 4.2e9.
27//
28// MTime fRawEvtTime
29// -------------------
30// Time of the event.
31// The start point of the time determination can be
32// the millenium. From that start point the time is
33// measured in 200ns-count. One day for example
34// contains 432.e9 counts. An array of two unsigned Int is able to
35// contain 1.8e19 200ns-counts. This corresponds to 41.e6
36// days. This should be more than the livetime of MAGIC.
37// Private member of MTime.h
38//
39// UInt_t fNumTrigLvl1
40// --------------------
41//
42// Number of first level trigger
43// This member counts the number of First Level Trigger
44// between the last and this event. May be that due to
45// dead time of the DAQ this number is different from 1.
46// If the DAQ is fast enough, this value should be 1.
47// This may be usefull in GammaRayBursts and if we
48// apply a data reduction in the DAQ-chain, which selects
49// only good events.
50//
51// UInt_t fNumTrigLvl2
52// ------------------ -
53//
54// Number of second level trigger
55// This member counts the number of Second Level Trigger
56// between the last and this event.
57//
58// UInt_t fTrigPattern[2]
59// -----------------------
60// Trigger Pattern used for this event
61// Each event triggers for a particular configuration and each
62// configuration shoul have an ID (which is not fixed yet).
63//
64// UShort_t fAllLowGainOn
65// ----------------------
66// Type of Trigger.
67// This is a Byte (8 bit) to indicated if any of the pixels
68// have a non-negligible low gain (1) or not (0)
69//
70/////////////////////////////////////////////////////////////////////////////
71#include "MRawEvtHeader.h"
72
73#include <iostream.h>
74#include <iomanip.h>
75#include <fstream.h>
76
77#include "../MBase/MTime.h"
78#include "../MBase/MArrayB.h"
79#include "MRawRunHeader.h"
80
81ClassImp(MRawEvtHeader)
82
83MRawEvtHeader::MRawEvtHeader(const char *name, const char *title)
84{
85 *fName = name ? name : "MRawEvtHeader";
86 *fTitle = title ? title : "Raw Event Header Information";
87
88 //
89 // set all member to zero, init the pointer to ClonesArray,
90 //
91
92 fPixLoGainOn = new MArrayB;
93
94 Clear();
95}
96
97
98MRawEvtHeader::~MRawEvtHeader()
99{
100}
101
102void MRawEvtHeader::Init(MRawRunHeader *rh, MTime *t)
103{
104 //
105 // you have to init the conatainer before you can read from
106 // a raw binary file
107 //
108
109 //
110 // this is the number of entries in the array like specification
111 //
112 UInt_t fN = (rh->GetNumCrates() * rh->GetNumPixInCrate() + 7) / 8;
113
114 //
115 // initialize the array
116 //
117 fPixLoGainOn->Set(fN);
118
119 //
120 // this is the conatiner where we have to store the time of the event we
121 // read from the input stream
122 //
123 fTime = t;
124}
125
126void MRawEvtHeader::Clear(Option_t *)
127{
128 //
129 // Implementation of the Clear function
130 //
131 // Resets all members to zero, clear the list of Pixels
132 //
133 fDAQEvtNumber = 0;
134 fNumTrigLvl1 = 0;
135 fNumTrigLvl2 = 0;
136 fTrigPattern[0] = 0;
137 fTrigPattern[1] = 0;
138 fTrigType = 0;
139 fNumLoGainOn = 0;
140}
141
142void MRawEvtHeader::Print(Option_t *o)
143{
144 //
145 // This member function prints all Data of one Event on screen.
146 //
147 cout << "DAQEvtNr: " << dec << fDAQEvtNumber << " (";
148 cout << "Trigger: ";
149 cout << "NumLvl1=" << fNumTrigLvl1 << " ";
150 cout << "NumLvl2=" << fNumTrigLvl2 << " ";
151 cout << "Pattern=" << hex << setfill('0');
152 cout << setw(2) << fTrigPattern[0];
153 cout << setw(2) << fTrigPattern[1] << " " << dec;
154
155 cout << "Type=";
156 switch (fTrigType)
157 {
158 case 0:
159 cout << "Trigger";
160 break;
161 case 1:
162 cout << "Pedestal";
163 break;
164 case 2:
165 cout << "Calibration";
166 break;
167 }
168 cout << ")" << endl;
169 cout << "Number of Lo Gains On: " << fNumLoGainOn << endl;
170
171 for (int i=0; i<fPixLoGainOn->GetSize(); i++)
172 {
173 for (int j=0; j<8; j++)
174 {
175 const UInt_t on = (*fPixLoGainOn)[i]&(1<<j) ? 1 : 0;
176 cout << on;
177 }
178 }
179
180 cout << endl;
181
182 cout << endl;
183
184}
185
186void MRawEvtHeader::FillHeader(UInt_t uiN, Float_t ulTP)
187{
188 //
189 // used to set the header information (eg. from MC)
190 //
191 fDAQEvtNumber = uiN;
192 fTrigPattern[0] = (UInt_t) (ulTP/4294967296.0) ;
193 fTrigPattern[1] = (UInt_t) (ulTP-fTrigPattern[0]*4294967296.0);
194}
195
196int MRawEvtHeader::ReadEvt(ifstream &fin)
197{
198 //
199 // read the EVENT HEADER information from the input stream
200 // return FALSE if there is now header anymore, else TRUE
201 //
202 fin.read((Byte_t*)&fDAQEvtNumber, 4);
203
204 UInt_t fAbsTime[2];
205 fin.read((Byte_t*)fAbsTime, 8);
206
207 //
208 // store the time of the event in the corresponding container
209 //
210 fTime->SetTime(fAbsTime[0], fAbsTime[1]);
211
212 Byte_t dummy[4];
213
214 fin.read((Byte_t*)&fNumTrigLvl1, 4);
215 fin.read((Byte_t*)&fNumTrigLvl2, 4);
216 fin.read((Byte_t*)fTrigPattern, 8);
217 fin.read((Byte_t*)&fTrigType, 2);
218 fin.read((Byte_t*)dummy, 2); // was fAllLoGainOn
219 fin.read((Byte_t*)fPixLoGainOn->GetArray(), fPixLoGainOn->GetSize());
220
221 fNumLoGainOn = 0;
222 for (int i=0; i<fPixLoGainOn->GetSize(); i++)
223 for (int j=0; j<8; j++)
224 if ((*fPixLoGainOn)[i] & (1<<j))
225 fNumLoGainOn++;
226
227 fin.read((Byte_t*)&dummy, 4);
228
229 return !fin.eof();
230}
Note: See TracBrowser for help on using the repository browser.