1 | /* ======================================================================== *\
|
---|
2 | !
|
---|
3 | ! *
|
---|
4 | ! * This file is part of MARS, the MAGIC Analysis and Reconstruction
|
---|
5 | ! * Software. It is distributed to you in the hope that it can be a useful
|
---|
6 | ! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
|
---|
7 | ! * It is distributed WITHOUT ANY WARRANTY.
|
---|
8 | ! *
|
---|
9 | ! * Permission to use, copy, modify and distribute this software and its
|
---|
10 | ! * documentation for any purpose is hereby granted without fee,
|
---|
11 | ! * provided that the above copyright notice appear in all copies and
|
---|
12 | ! * that both that copyright notice and this permission notice appear
|
---|
13 | ! * in supporting documentation. It is provided "as is" without express
|
---|
14 | ! * or implied warranty.
|
---|
15 | ! *
|
---|
16 | !
|
---|
17 | !
|
---|
18 | ! Author(s): Thomas Bretz 12/2000 (tbretz@uni-sw.gwdg.de)
|
---|
19 | !
|
---|
20 | ! Copyright: MAGIC Software Development, 2000-2001
|
---|
21 | !
|
---|
22 | !
|
---|
23 | \* ======================================================================== */
|
---|
24 |
|
---|
25 | /////////////////////////////////////////////////////////////////////////////
|
---|
26 | //
|
---|
27 | // MRawRunHeader
|
---|
28 | //
|
---|
29 | // Root storage container for the RUN HEADER information
|
---|
30 | //
|
---|
31 | ////////////////////////////////////////////////////////////////////////////
|
---|
32 |
|
---|
33 | #include "MRawRunHeader.h"
|
---|
34 |
|
---|
35 | #include <fstream.h>
|
---|
36 | #include <iomanip.h>
|
---|
37 |
|
---|
38 | #include "MLog.h"
|
---|
39 | #include "MArrayS.h"
|
---|
40 |
|
---|
41 | ClassImp(MRawRunHeader);
|
---|
42 |
|
---|
43 | // --------------------------------------------------------------------------
|
---|
44 | //
|
---|
45 | // Default constructor. Creates array which stores the pixel assignment.
|
---|
46 | //
|
---|
47 | //
|
---|
48 | MRawRunHeader::MRawRunHeader(const char *name, const char *title) : fPixAssignment(NULL)
|
---|
49 | {
|
---|
50 | fName = name ? name : "MRawRunHeader";
|
---|
51 | fTitle = title ? title : "Raw Run Header Information";
|
---|
52 |
|
---|
53 | fPixAssignment = new MArrayS(0);
|
---|
54 | }
|
---|
55 |
|
---|
56 | // --------------------------------------------------------------------------
|
---|
57 | //
|
---|
58 | // Destructor. Deletes the 'pixel-assignment-array'
|
---|
59 | //
|
---|
60 | MRawRunHeader::~MRawRunHeader()
|
---|
61 | {
|
---|
62 | delete fPixAssignment;
|
---|
63 | }
|
---|
64 |
|
---|
65 | // --------------------------------------------------------------------------
|
---|
66 | //
|
---|
67 | // Read in one run header from the binary file
|
---|
68 | //
|
---|
69 | void MRawRunHeader::ReadEvt(istream& fin)
|
---|
70 | {
|
---|
71 | //
|
---|
72 | // read one RUN HEADER from the input stream
|
---|
73 | //
|
---|
74 | fin.read((Byte_t*)&fMagicNumber, 2);
|
---|
75 |
|
---|
76 | //
|
---|
77 | // check whether the the file has the right file type or not
|
---|
78 | //
|
---|
79 | if (fMagicNumber != kMagicNumber)
|
---|
80 | {
|
---|
81 | *fLog << "Error: Wrong Magic Number: Not a Magic File!" << endl;
|
---|
82 | return;
|
---|
83 | }
|
---|
84 |
|
---|
85 | Byte_t dummy[16];
|
---|
86 |
|
---|
87 | fin.read((Byte_t*)&fFormatVersion, 2);
|
---|
88 | fin.read((Byte_t*)&fSoftVersion, 2);
|
---|
89 | fin.read((Byte_t*)&fRunType, 2);
|
---|
90 | fin.read((Byte_t*)&fRunNumber, 4);
|
---|
91 | fin.read((Byte_t*)&fProjectName, 22);
|
---|
92 | fin.read((Byte_t*)&fSourceName, 12);
|
---|
93 | fin.read((Byte_t*)dummy, 4); // was RA (moved to tracking system)
|
---|
94 | fin.read((Byte_t*)dummy, 4); // was DEC (moved to tracking system)
|
---|
95 | fin.read((Byte_t*)&fSourceEpochChar, 2);
|
---|
96 | fin.read((Byte_t*)&fSourceEpochDate, 2);
|
---|
97 | fin.read((Byte_t*)&fMJD, 4);
|
---|
98 | fin.read((Byte_t*)&fDateYear, 2);
|
---|
99 | fin.read((Byte_t*)&fDateMonth, 2);
|
---|
100 | fin.read((Byte_t*)&fDateDay, 2);
|
---|
101 | fin.read((Byte_t*)&fNumCrates, 2);
|
---|
102 | fin.read((Byte_t*)&fNumPixInCrate, 2);
|
---|
103 | fin.read((Byte_t*)&fNumSamplesLoGain, 2);
|
---|
104 | fin.read((Byte_t*)&fNumSamplesHiGain, 2);
|
---|
105 | fin.read((Byte_t*)&fNumEvents, 4);
|
---|
106 |
|
---|
107 |
|
---|
108 | //
|
---|
109 | // calculate size of array, create it and fill it
|
---|
110 | //
|
---|
111 | Int_t nPixel = fNumCrates*fNumPixInCrate;
|
---|
112 | fPixAssignment->Set(nPixel);
|
---|
113 |
|
---|
114 | fin.read((Byte_t*)fPixAssignment->GetArray(), nPixel*2);
|
---|
115 | fin.read((Byte_t*)&dummy, 16);
|
---|
116 | }
|
---|
117 |
|
---|
118 | // --------------------------------------------------------------------------
|
---|
119 | //
|
---|
120 | // print run header information on *fLog
|
---|
121 | //
|
---|
122 | void MRawRunHeader::Print(Option_t *t) const
|
---|
123 | {
|
---|
124 | *fLog << endl;
|
---|
125 | *fLog << "MagicNumber: 0x" << hex << fMagicNumber << " - " << (fMagicNumber==kMagicNumber?"OK":"Wrong!") << endl;
|
---|
126 | *fLog << "Version: " << dec << "Format=" << fFormatVersion << " ";
|
---|
127 | *fLog << "Software=" << fSoftVersion << endl;
|
---|
128 | *fLog << "RunNumber: " << fRunNumber << " (Type=";
|
---|
129 | switch (fRunType)
|
---|
130 | {
|
---|
131 | case kRTData:
|
---|
132 | *fLog << "Data";
|
---|
133 | break;
|
---|
134 | case kRTPedestal:
|
---|
135 | *fLog << "Pedestal";
|
---|
136 | break;
|
---|
137 | case kRTCalibration:
|
---|
138 | *fLog << "Calibration";
|
---|
139 | break;
|
---|
140 | case kRTMonteCarlo:
|
---|
141 | *fLog << "Monte Carlo Data";
|
---|
142 | break;
|
---|
143 | }
|
---|
144 | *fLog << ")" << endl;
|
---|
145 | *fLog << "ProjectName: '" << fProjectName << "'" << endl;
|
---|
146 | *fLog << "Source: '" << fSourceName << "' " << " ";
|
---|
147 | *fLog << fSourceEpochChar << dec << fSourceEpochDate << endl;
|
---|
148 | *fLog << "Date: " << setprecision(1) << setiosflags(ios::fixed) << fMJD << " (MJD) " << fDateYear << "/" << fDateMonth << "/" << fDateDay << endl;
|
---|
149 | *fLog << "Crates: " << fNumCrates << " x " << fNumPixInCrate << " Pixel/Crate = " << fNumCrates*fNumPixInCrate << " Pixel/Evt" << endl;
|
---|
150 | *fLog << "Samples: " << fNumSamplesLoGain << "/" << fNumSamplesHiGain << " (lo/hi) = " << (fNumSamplesLoGain+fNumSamplesHiGain) * fNumCrates * fNumPixInCrate /1024 << "kB/Evt" << endl;
|
---|
151 | *fLog << "Evt Counter: " << fNumEvents << endl;
|
---|
152 |
|
---|
153 | *fLog << hex;
|
---|
154 | for (int i=0; i<GetNumPixel(); i++)
|
---|
155 | *fLog << setfill('0') << setw(3) << (*fPixAssignment)[i] << " ";
|
---|
156 | *fLog << hex << endl;
|
---|
157 |
|
---|
158 | *fLog << endl;
|
---|
159 | }
|
---|
160 |
|
---|
161 | // --------------------------------------------------------------------------
|
---|
162 | //
|
---|
163 | // Return the assigned pixel number for the given FADC channel
|
---|
164 | //
|
---|
165 | UShort_t MRawRunHeader::GetPixAssignment(UShort_t i) const
|
---|
166 | {
|
---|
167 | // FIXME: Do we need a range check here?
|
---|
168 | return (*fPixAssignment)[i];
|
---|
169 | }
|
---|
170 |
|
---|
171 | // --------------------------------------------------------------------------
|
---|
172 | //
|
---|
173 | // return the number of pixel in this event.
|
---|
174 | //
|
---|
175 | UShort_t MRawRunHeader::GetNumPixel() const
|
---|
176 | {
|
---|
177 | return fPixAssignment->GetSize();
|
---|
178 | }
|
---|