1 | #ifndef MARS_MRawRunHeader
|
---|
2 | #define MARS_MRawRunHeader
|
---|
3 | ///////////////////////////////////////////////////////////////////////
|
---|
4 | // //
|
---|
5 | // MRunHeader //
|
---|
6 | // //
|
---|
7 | ///////////////////////////////////////////////////////////////////////
|
---|
8 |
|
---|
9 | #ifndef MARS_MTime
|
---|
10 | #include "MTime.h"
|
---|
11 | #endif
|
---|
12 |
|
---|
13 | class TBuffer;
|
---|
14 | class MArrayS;
|
---|
15 |
|
---|
16 | class MRawRunHeader : public MParContainer
|
---|
17 | {
|
---|
18 | public:
|
---|
19 | //
|
---|
20 | // enum for the Run Type. Monte Carlo Runs have
|
---|
21 | // to have a value greater than 255 (>0xff)
|
---|
22 | //
|
---|
23 | enum {
|
---|
24 | kRTData = 0x0000,
|
---|
25 | kRTPedestal = 0x0001,
|
---|
26 | kRTCalibration = 0x0002,
|
---|
27 | kRTDominoCal = 0x0003,
|
---|
28 | kRTLinearity = 0x0004,
|
---|
29 | kRTPointRun = 0x0007,
|
---|
30 | kRTMonteCarlo = 0x0100,
|
---|
31 | kRTFact = 0xfac7,
|
---|
32 | kRTNone = 0xffff
|
---|
33 | };
|
---|
34 |
|
---|
35 | //
|
---|
36 | // Magic number to detect the magic file type
|
---|
37 | //
|
---|
38 | static const UShort_t kMagicNumber;
|
---|
39 | static const Byte_t kMaxFormatVersion;
|
---|
40 |
|
---|
41 | private:
|
---|
42 | /* ---- Run Header Informations ---- */
|
---|
43 | UShort_t fMagicNumber; // File type identifier
|
---|
44 |
|
---|
45 | UInt_t fHeaderSizeRun; // Size of run header
|
---|
46 | UInt_t fHeaderSizeEvt; // Size of evt header
|
---|
47 | UInt_t fHeaderSizeCrate; // Size of crate header
|
---|
48 |
|
---|
49 | UShort_t fFormatVersion; // File format version
|
---|
50 | UShort_t fSoftVersion; // DAQ software version
|
---|
51 | UShort_t fFadcType; // FADC type (1=Siegen, 2=MUX)
|
---|
52 | UShort_t fCameraVersion; // Camera Version (1=MAGIC I)
|
---|
53 | UShort_t fTelescopeNumber; // Telescope number (1=Magic I)
|
---|
54 | UShort_t fRunType; // Run Type
|
---|
55 | UInt_t fRunNumber; // Run number
|
---|
56 | UInt_t fFileNumber; // File number
|
---|
57 | Char_t fProjectName[101]; // Project name
|
---|
58 | Char_t fSourceName[81]; // Source name
|
---|
59 | Char_t fObservationMode[61]; // observation mode
|
---|
60 | Char_t fSourceEpochChar[4]; // epoch char of the source
|
---|
61 | UShort_t fSourceEpochDate; // epoch date of the source
|
---|
62 | UShort_t fNumCrates; // number of electronic boards
|
---|
63 | UShort_t fNumPixInCrate; // number of pixels in crate
|
---|
64 | UShort_t fNumSamplesLoGain; // number of logain samples stored
|
---|
65 | UShort_t fNumSamplesHiGain; // number of higain samples stored
|
---|
66 | UShort_t fNumBytesPerSample; // number of bytes per sample
|
---|
67 | UInt_t fNumEvents; // number of events stored
|
---|
68 | UInt_t fNumEventsRead; // number of events read by the electronics
|
---|
69 | UShort_t fSamplingFrequency; // Sampling Frequency [MHz]
|
---|
70 | Byte_t fFadcResolution; // number of significant bits
|
---|
71 | MTime fRunStart; // time of run start
|
---|
72 | MTime fRunStop; // time of run stop
|
---|
73 | MArrayS *fPixAssignment; //-> pixel assignment table
|
---|
74 |
|
---|
75 | Bool_t SwapAssignment(Short_t id0, Short_t id1);
|
---|
76 | void FixRunNumbers();
|
---|
77 | Bool_t FixAssignment();
|
---|
78 | Bool_t Fixes();
|
---|
79 | Bool_t IsConsistent() const;
|
---|
80 |
|
---|
81 | Bool_t ReadEvtOld(istream& fin);
|
---|
82 |
|
---|
83 | // MParContainer
|
---|
84 | Int_t ReadEnv(const TEnv &env, TString prefix, Bool_t print);
|
---|
85 |
|
---|
86 | public:
|
---|
87 | MRawRunHeader(const char *name=NULL, const char *title=NULL);
|
---|
88 | MRawRunHeader(const MRawRunHeader &h);
|
---|
89 | ~MRawRunHeader();
|
---|
90 |
|
---|
91 | // This is to be used in the MC chain only!
|
---|
92 | /*
|
---|
93 | void SetMagicNumber(UShort_t a) { fMagicNumber=a; }
|
---|
94 | void SetFormatVersion(UShort_t a) { fFormatVersion=a; }
|
---|
95 | void SetSoftVersion(UShort_t a) { fSoftVersion=a; }
|
---|
96 | void SetRunType(UShort_t a) { fRunType=a; }
|
---|
97 | void SetRunNumber(UInt_t a) { fRunNumber=a; }
|
---|
98 | void SetNumEvents(UInt_t a) { fNumEvents=a; }
|
---|
99 | void SetNumSamples(UShort_t low, UShort_t high)
|
---|
100 | {
|
---|
101 | fNumSamplesLoGain=low;
|
---|
102 | fNumSamplesHiGain=high;
|
---|
103 | }
|
---|
104 | void SetNumCrates(UShort_t a) { fNumCrates=a; }
|
---|
105 | void SetNumPixInCrate(UShort_t a) { fNumPixInCrate=a; }
|
---|
106 | */
|
---|
107 | void InitFadcType(UShort_t type);
|
---|
108 | void InitCamera(UShort_t type, UShort_t pix=0);
|
---|
109 | void InitPixels(UShort_t pix) { InitCamera((UShort_t)-1, pix); }
|
---|
110 | void InitFact(UShort_t num, UShort_t pix, UShort_t samples);
|
---|
111 | void SetRunType(UShort_t type) { fRunType=type; }
|
---|
112 | void SetRunInfo(UShort_t tel, UInt_t run, UInt_t file=0);
|
---|
113 | void SetFileNumber(UInt_t file) { fFileNumber=file; }
|
---|
114 | void SetSourceInfo(const TString src, char epoch='J', UShort_t date=2000);
|
---|
115 | void SetRunTime(const MTime &start, const MTime &end);
|
---|
116 | void SetRunTimeMjd(Float_t start, Float_t stop) { fRunStart.SetMjd(start); fRunStop.SetMjd(stop); }
|
---|
117 | void SetObservation(const TString mode, const TString proj);
|
---|
118 | void SetNumEvents(UInt_t num);
|
---|
119 | void SetValidMagicNumber() { fMagicNumber=kMagicNumber; }
|
---|
120 | void SetFormat(UShort_t file, UShort_t soft) { fFormatVersion=file; fSoftVersion=soft; }
|
---|
121 |
|
---|
122 | // This is to get the numbers...
|
---|
123 | UShort_t GetMagicNumber() const { return fMagicNumber; }
|
---|
124 | UInt_t GetHeaderSizeEvt() const { return fHeaderSizeEvt; }
|
---|
125 | UInt_t GetHeaderSizeCrate() const { return fHeaderSizeCrate; }
|
---|
126 | UShort_t GetFormatVersion() const { return fFormatVersion; }
|
---|
127 | UShort_t GetSoftVersion() const { return fSoftVersion; }
|
---|
128 | UInt_t GetRunNumber() const { return fRunNumber; }
|
---|
129 | UInt_t GetFileNumber() const { return fFileNumber; }
|
---|
130 | UInt_t GetTypeID() const { return (fRunNumber/1000000)%100; }
|
---|
131 | UInt_t GetFileID() const { return fRunNumber>1000000?(fRunNumber%1000000)*1000+(fFileNumber%1000):fRunNumber; }
|
---|
132 | TString GetStringID() const;
|
---|
133 | UShort_t GetTelescopeNumber() const { return fTelescopeNumber; }
|
---|
134 | UShort_t GetRunType() const { return fRunType; }
|
---|
135 | const Char_t *GetRunTypeStr() const;
|
---|
136 | const Char_t GetRunTypeChar() const;
|
---|
137 | const Char_t *GetProjectName() const { return fProjectName; }
|
---|
138 | const Char_t *GetSourceName() const { return fSourceName; }
|
---|
139 | const Char_t *GetSourceEpocheChar() const { return fSourceEpochChar; }
|
---|
140 | const Char_t *GetObservationMode() const { return fObservationMode; }
|
---|
141 | UShort_t GetSourceEpocheDate() const { return fSourceEpochDate; }
|
---|
142 | UShort_t GetNumCrates() const { return fNumCrates; }
|
---|
143 | UShort_t GetNumPixInCrate() const { return fNumPixInCrate; }
|
---|
144 | UShort_t GetNumSamplesLoGain() const { return fNumSamplesLoGain; }
|
---|
145 | UShort_t GetNumSamplesHiGain() const { return fNumSamplesHiGain; }
|
---|
146 | UInt_t GetNumSamples() const { return fNumSamplesHiGain+fNumSamplesLoGain; }
|
---|
147 | UShort_t GetNumBytesPerSample() const { return fNumBytesPerSample; }
|
---|
148 | UInt_t GetNumEvents() const { return fNumEvents; }
|
---|
149 | UInt_t GetNumEventsRead() const { return fNumEventsRead; }
|
---|
150 | UShort_t GetFreqSampling() const { return fSamplingFrequency; }
|
---|
151 | const MTime &GetRunStart() const { return fRunStart; }
|
---|
152 | const MTime &GetRunEnd() const { return fRunStop; }
|
---|
153 | Double_t GetRunLength() const { return !fRunStart || !fRunStop ? 0 : fRunStop-fRunStart; }
|
---|
154 | Short_t GetPixAssignment(UShort_t i) const;
|
---|
155 | UShort_t GetMaxPixId() const;
|
---|
156 | UShort_t GetMinPixId() const;
|
---|
157 | UShort_t GetNumConnectedPixels() const;
|
---|
158 | UShort_t GetNumNormalPixels() const;
|
---|
159 | UShort_t GetNumSpecialPixels() const;
|
---|
160 | UInt_t GetScale() const { switch (fNumBytesPerSample) { case 1: return 0x1; case 2: return 0x100; case 4: return 0x1000000; } return 0; }
|
---|
161 | UInt_t GetMax() const { switch (fNumBytesPerSample) { case 1: return 0xff; case 2: return 0xffff; case 4: return 0xffffffff; } return 0; }
|
---|
162 |
|
---|
163 | UInt_t GetNumSamplesPerCrate() const
|
---|
164 | {
|
---|
165 | return fNumPixInCrate*(fNumSamplesLoGain+fNumSamplesHiGain);
|
---|
166 | }
|
---|
167 |
|
---|
168 | UShort_t GetNumPixel() const;
|
---|
169 | Int_t GetNumTotalBytes() const;
|
---|
170 |
|
---|
171 | Bool_t IsValid() const { return fMagicNumber==0xc0c0 || fMagicNumber==0xc0c1; }
|
---|
172 | Bool_t IsMonteCarloRun() const { return fRunType>0x00ff; }
|
---|
173 | Bool_t IsDataRun() const { return (fRunType&0xff)==kRTData; }
|
---|
174 | Bool_t IsPedestalRun() const { return (fRunType&0xff)==kRTPedestal; }
|
---|
175 | Bool_t IsCalibrationRun() const { return (fRunType&0xff)==kRTCalibration; }
|
---|
176 | Bool_t IsPointRun() const { return (fRunType&0xff)==kRTPointRun; }
|
---|
177 |
|
---|
178 | Bool_t IsValidRun() const { return fRunType!=kRTNone; }
|
---|
179 |
|
---|
180 | Bool_t IsConsistent(const MRawRunHeader &h) const;
|
---|
181 |
|
---|
182 | void Print(Option_t *t=NULL) const;
|
---|
183 |
|
---|
184 | Bool_t ReadEvt(istream& fin);
|
---|
185 | //Bool_t WriteEvt(ostream& fout) const;
|
---|
186 |
|
---|
187 | ClassDef(MRawRunHeader, 10) // storage container for general info
|
---|
188 | };
|
---|
189 | #endif
|
---|