source: trunk/MagicSoft/Mars/mraw/MRawRunHeader.cc@ 527

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