source: trunk/MagicSoft/include-Classes/MRawFormat/MRawRunHeader.cc@ 674

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