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 <mailto: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>
|
---|
36 | #include <iomanip>
|
---|
37 |
|
---|
38 | #include "MLog.h"
|
---|
39 | #include "MLogManip.h"
|
---|
40 |
|
---|
41 | #include "MArrayS.h"
|
---|
42 |
|
---|
43 | ClassImp(MRawRunHeader);
|
---|
44 |
|
---|
45 | using namespace std;
|
---|
46 |
|
---|
47 | // --------------------------------------------------------------------------
|
---|
48 | //
|
---|
49 | // Default constructor. Creates array which stores the pixel assignment.
|
---|
50 | //
|
---|
51 | //
|
---|
52 | MRawRunHeader::MRawRunHeader(const char *name, const char *title) : fPixAssignment(NULL)
|
---|
53 | {
|
---|
54 | fName = name ? name : "MRawRunHeader";
|
---|
55 | fTitle = title ? title : "Raw Run Header Information";
|
---|
56 |
|
---|
57 | fPixAssignment = new MArrayS(0);
|
---|
58 | }
|
---|
59 |
|
---|
60 | // --------------------------------------------------------------------------
|
---|
61 | //
|
---|
62 | // Destructor. Deletes the 'pixel-assignment-array'
|
---|
63 | //
|
---|
64 | MRawRunHeader::~MRawRunHeader()
|
---|
65 | {
|
---|
66 | delete fPixAssignment;
|
---|
67 | }
|
---|
68 |
|
---|
69 | // --------------------------------------------------------------------------
|
---|
70 | //
|
---|
71 | // Read in one run header from the binary file
|
---|
72 | //
|
---|
73 | void MRawRunHeader::ReadEvt(istream& fin)
|
---|
74 | {
|
---|
75 | //
|
---|
76 | // read one RUN HEADER from the input stream
|
---|
77 | //
|
---|
78 | fin.read((char*)&fMagicNumber, 2);
|
---|
79 |
|
---|
80 | //
|
---|
81 | // check whether the the file has the right file type or not
|
---|
82 | //
|
---|
83 | if (fMagicNumber != kMagicNumber)
|
---|
84 | {
|
---|
85 | *fLog << err << "Error: Wrong Magic Number: Not a Magic File!" << endl;
|
---|
86 | return;
|
---|
87 | }
|
---|
88 |
|
---|
89 | Byte_t dummy[16];
|
---|
90 |
|
---|
91 | fin.read((char*)&fFormatVersion, 2);
|
---|
92 | fin.read((char*)&fSoftVersion, 2);
|
---|
93 | fin.read((char*)&fRunType, 2);
|
---|
94 | fin.read((char*)&fRunNumber, 4);
|
---|
95 | fin.read((char*)&fProjectName, 22);
|
---|
96 | fin.read((char*)&fSourceName, 12);
|
---|
97 | fin.read((char*)dummy, 4); // was RA (moved to tracking system)
|
---|
98 | fin.read((char*)dummy, 4); // was DEC (moved to tracking system)
|
---|
99 | fin.read((char*)&fSourceEpochChar, 2);
|
---|
100 | fin.read((char*)&fSourceEpochDate, 2);
|
---|
101 | fin.read((char*)&fMJD, 4);
|
---|
102 | fin.read((char*)&fDateYear, 2);
|
---|
103 | fin.read((char*)&fDateMonth, 2);
|
---|
104 | fin.read((char*)&fDateDay, 2);
|
---|
105 | fin.read((char*)&fNumCrates, 2);
|
---|
106 | fin.read((char*)&fNumPixInCrate, 2);
|
---|
107 | fin.read((char*)&fNumSamplesLoGain, 2);
|
---|
108 | fin.read((char*)&fNumSamplesHiGain, 2);
|
---|
109 | fin.read((char*)&fNumEvents, 4);
|
---|
110 |
|
---|
111 |
|
---|
112 | //
|
---|
113 | // calculate size of array, create it and fill it
|
---|
114 | //
|
---|
115 | Int_t nPixel = fNumCrates*fNumPixInCrate;
|
---|
116 | fPixAssignment->Set(nPixel);
|
---|
117 |
|
---|
118 | fin.read((char*)fPixAssignment->GetArray(), nPixel*2);
|
---|
119 | fin.read((char*)&dummy, 16);
|
---|
120 | }
|
---|
121 |
|
---|
122 | // --------------------------------------------------------------------------
|
---|
123 | //
|
---|
124 | // print run header information on *fLog
|
---|
125 | //
|
---|
126 | void MRawRunHeader::Print(Option_t *t) const
|
---|
127 | {
|
---|
128 | *fLog << all << endl;
|
---|
129 | *fLog << "MagicNumber: 0x" << hex << fMagicNumber << " - " << (fMagicNumber==kMagicNumber?"OK":"Wrong!") << endl;
|
---|
130 | *fLog << "Version: " << dec << "Format=" << fFormatVersion << " ";
|
---|
131 | *fLog << "Software=" << fSoftVersion << endl;
|
---|
132 | *fLog << "RunNumber: " << fRunNumber << " (Type=";
|
---|
133 | switch (fRunType)
|
---|
134 | {
|
---|
135 | case kRTData:
|
---|
136 | *fLog << "Data";
|
---|
137 | break;
|
---|
138 | case kRTPedestal:
|
---|
139 | *fLog << "Pedestal";
|
---|
140 | break;
|
---|
141 | case kRTCalibration:
|
---|
142 | *fLog << "Calibration";
|
---|
143 | break;
|
---|
144 | case kRTMonteCarlo:
|
---|
145 | *fLog << "Monte Carlo Data";
|
---|
146 | break;
|
---|
147 | }
|
---|
148 | *fLog << ")" << endl;
|
---|
149 | *fLog << "ProjectName: '" << fProjectName << "'" << endl;
|
---|
150 | *fLog << "Source: '" << fSourceName << "' " << " ";
|
---|
151 | *fLog << fSourceEpochChar << dec << fSourceEpochDate << endl;
|
---|
152 | *fLog << "Date: " << setprecision(1) << setiosflags(ios::fixed) << fMJD << " (MJD) " << fDateYear << "/" << fDateMonth << "/" << fDateDay << endl;
|
---|
153 | *fLog << "Crates: " << fNumCrates << " x " << fNumPixInCrate << " Pixel/Crate = " << fNumCrates*fNumPixInCrate << " Pixel/Evt" << endl;
|
---|
154 | *fLog << "Samples: " << fNumSamplesLoGain << "/" << fNumSamplesHiGain << " (lo/hi) = " << (fNumSamplesLoGain+fNumSamplesHiGain) * fNumCrates * fNumPixInCrate /1024 << "kB/Evt" << endl;
|
---|
155 | *fLog << "Evt Counter: " << fNumEvents << endl;
|
---|
156 |
|
---|
157 | *fLog << hex;
|
---|
158 | for (int i=0; i<GetNumPixel(); i++)
|
---|
159 | *fLog << setfill('0') << setw(3) << (*fPixAssignment)[i] << " ";
|
---|
160 | *fLog << hex << endl;
|
---|
161 |
|
---|
162 | *fLog << endl;
|
---|
163 | }
|
---|
164 |
|
---|
165 | // --------------------------------------------------------------------------
|
---|
166 | //
|
---|
167 | // Return the assigned pixel number for the given FADC channel
|
---|
168 | //
|
---|
169 | UShort_t MRawRunHeader::GetPixAssignment(UShort_t i) const
|
---|
170 | {
|
---|
171 | // FIXME: Do we need a range check here?
|
---|
172 | return (*fPixAssignment)[i];
|
---|
173 | }
|
---|
174 |
|
---|
175 | // --------------------------------------------------------------------------
|
---|
176 | //
|
---|
177 | // return the number of pixel in this event.
|
---|
178 | //
|
---|
179 | UShort_t MRawRunHeader::GetNumPixel() const
|
---|
180 | {
|
---|
181 | return fPixAssignment->GetSize();
|
---|
182 | }
|
---|