1 | /////////////////////////////////////////////////////////////////////////////
|
---|
2 | //
|
---|
3 | // MRawRunHeader
|
---|
4 | //
|
---|
5 | // Root storage container for the RUN HEADER information
|
---|
6 | //
|
---|
7 | ////////////////////////////////////////////////////////////////////////////
|
---|
8 |
|
---|
9 | #include "MRawRunHeader.h"
|
---|
10 |
|
---|
11 | #include <fstream.h>
|
---|
12 | #include <iomanip.h>
|
---|
13 |
|
---|
14 | #include "MLog.h"
|
---|
15 | #include "MArrayS.h"
|
---|
16 |
|
---|
17 | ClassImp(MRawRunHeader)
|
---|
18 |
|
---|
19 | MRawRunHeader::MRawRunHeader(const char *name, const char *title) : fPixAssignment(NULL)
|
---|
20 | {
|
---|
21 | *fName = name ? name : "MRawRunHeader";
|
---|
22 | *fTitle = title ? title : "Raw Run Header Information";
|
---|
23 |
|
---|
24 | fPixAssignment = new MArrayS(0);
|
---|
25 |
|
---|
26 | // This is only valid for root > 3.0
|
---|
27 | // IsA()->CanIgnoreTObjectStreamer();
|
---|
28 | }
|
---|
29 |
|
---|
30 | MRawRunHeader::~MRawRunHeader()
|
---|
31 | {
|
---|
32 | delete fPixAssignment;
|
---|
33 | }
|
---|
34 |
|
---|
35 | void MRawRunHeader::ReadEvt(istream& fin)
|
---|
36 | {
|
---|
37 | //
|
---|
38 | // read one RUN HEADER from the input stream
|
---|
39 | //
|
---|
40 | fin.read((Byte_t*)&fMagicNumber, 2);
|
---|
41 |
|
---|
42 | //
|
---|
43 | // check whether the the file has the right file type or not
|
---|
44 | //
|
---|
45 | if (fMagicNumber != kMagicNumber)
|
---|
46 | {
|
---|
47 | *fLog << "Error: Wrong Magic Number: Not a Magic File!" << endl;
|
---|
48 | return;
|
---|
49 | }
|
---|
50 |
|
---|
51 | Byte_t dummy[16];
|
---|
52 |
|
---|
53 | fin.read((Byte_t*)&fFormatVersion, 2);
|
---|
54 | fin.read((Byte_t*)&fSoftVersion, 2);
|
---|
55 | fin.read((Byte_t*)&fRunType, 2);
|
---|
56 | fin.read((Byte_t*)&fRunNumber, 4);
|
---|
57 | fin.read((Byte_t*)&fProjectName, 22);
|
---|
58 | fin.read((Byte_t*)&fSourceName, 12);
|
---|
59 | fin.read((Byte_t*)dummy, 4); // was RA
|
---|
60 | fin.read((Byte_t*)dummy, 4); // was DEC
|
---|
61 | fin.read((Byte_t*)&fSourceEpochChar, 2);
|
---|
62 | fin.read((Byte_t*)&fSourceEpochDate, 2);
|
---|
63 | fin.read((Byte_t*)&fMJD, 4);
|
---|
64 | fin.read((Byte_t*)&fDateYear, 2);
|
---|
65 | fin.read((Byte_t*)&fDateMonth, 2);
|
---|
66 | fin.read((Byte_t*)&fDateDay, 2);
|
---|
67 | fin.read((Byte_t*)&fNumCrates, 2);
|
---|
68 | fin.read((Byte_t*)&fNumPixInCrate, 2);
|
---|
69 | fin.read((Byte_t*)&fNumSamplesLoGain, 2);
|
---|
70 | fin.read((Byte_t*)&fNumSamplesHiGain, 2);
|
---|
71 | fin.read((Byte_t*)&fNumEvents, 4);
|
---|
72 |
|
---|
73 |
|
---|
74 | //
|
---|
75 | // calculate size of array, create it and fill it
|
---|
76 | //
|
---|
77 | Int_t nPixel = fNumCrates*fNumPixInCrate;
|
---|
78 | fPixAssignment->Set(nPixel);
|
---|
79 |
|
---|
80 | fin.read((Byte_t*)fPixAssignment->GetArray(), nPixel*2);
|
---|
81 | fin.read((Byte_t*)&dummy, 16);
|
---|
82 | }
|
---|
83 |
|
---|
84 | void MRawRunHeader::Print(Option_t *t)
|
---|
85 | {
|
---|
86 | //
|
---|
87 | // print run header information on screen
|
---|
88 | //
|
---|
89 | *fLog << endl;
|
---|
90 | *fLog << "MagicNumber: 0x" << hex << fMagicNumber << " - " << (fMagicNumber==0xc0c0?"OK":"Wrong!") << endl;
|
---|
91 | *fLog << "Version: " << dec << "Format=" << fFormatVersion << " ";
|
---|
92 | *fLog << "Software=" << fSoftVersion << endl;
|
---|
93 | *fLog << "RunNumber: " << fRunNumber << " (Type=";
|
---|
94 | switch (fRunType)
|
---|
95 | {
|
---|
96 | case 0:
|
---|
97 | *fLog << "Data";
|
---|
98 | break;
|
---|
99 | case 1:
|
---|
100 | *fLog << "Pedestal";
|
---|
101 | break;
|
---|
102 | case 2:
|
---|
103 | *fLog << "Calibration";
|
---|
104 | break;
|
---|
105 | }
|
---|
106 | *fLog << ")" << endl;
|
---|
107 | *fLog << "ProjectName: '" << fProjectName << "'" << endl;
|
---|
108 | *fLog << "Source: '" << fSourceName << "' " << " ";
|
---|
109 | *fLog << fSourceEpochChar << dec << fSourceEpochDate << endl;
|
---|
110 | *fLog << "Date: " << setprecision(1) << setiosflags(ios::fixed) << fMJD << " (MJD) " << fDateYear << "/" << fDateMonth << "/" << fDateDay << endl;
|
---|
111 | *fLog << "Crates: " << fNumCrates << " x " << fNumPixInCrate << " Pixel/Crate = " << fNumCrates*fNumPixInCrate << " Pixel/Evt" << endl;
|
---|
112 | *fLog << "Samples: " << fNumSamplesLoGain << "/" << fNumSamplesHiGain << " (lo/hi) = " << (fNumSamplesLoGain+fNumSamplesHiGain) * fNumCrates * fNumPixInCrate /1024 << "kB/Evt" << endl;
|
---|
113 | *fLog << "Evt Counter: " << fNumEvents << endl;
|
---|
114 |
|
---|
115 | *fLog << hex;
|
---|
116 | for (int i=0; i<GetNumPixel(); i++)
|
---|
117 | *fLog << setfill('0') << setw(3) << (*fPixAssignment)[i] << " ";
|
---|
118 | *fLog << hex << endl;
|
---|
119 |
|
---|
120 | *fLog << endl;
|
---|
121 | }
|
---|
122 |
|
---|
123 | UShort_t MRawRunHeader::GetPixAssignment(UShort_t i) const
|
---|
124 | {
|
---|
125 | // FIXME: Do we need a range check here?
|
---|
126 | return (*fPixAssignment)[i];
|
---|
127 | }
|
---|
128 |
|
---|
129 | UShort_t MRawRunHeader::GetNumPixel() const
|
---|
130 | {
|
---|
131 | return fPixAssignment->GetSize();
|
---|
132 | }
|
---|