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@astro.uni-wuerzburg.de>
|
---|
19 | !
|
---|
20 | ! Copyright: MAGIC Software Development, 2000-2008
|
---|
21 | !
|
---|
22 | !
|
---|
23 | \* ======================================================================== */
|
---|
24 |
|
---|
25 | /////////////////////////////////////////////////////////////////////////////
|
---|
26 | //
|
---|
27 | // MRawCrateData
|
---|
28 | //
|
---|
29 | // This container stores the information about one crate. A list of this
|
---|
30 | // informations can be find at MRawCrateArray
|
---|
31 | //
|
---|
32 | /////////////////////////////////////////////////////////////////////////////
|
---|
33 | #include "MRawCrateData.h"
|
---|
34 |
|
---|
35 | #include <fstream>
|
---|
36 |
|
---|
37 | #include <TArrayC.h>
|
---|
38 |
|
---|
39 | #include "MLog.h"
|
---|
40 | #include "MLogManip.h"
|
---|
41 |
|
---|
42 | ClassImp(MRawCrateData);
|
---|
43 |
|
---|
44 | using namespace std;
|
---|
45 |
|
---|
46 | MRawCrateData::MRawCrateData() : fDAQCrateNumber(0), fFADCEvtNumber(0), fFADCClockTick(0), fABFlags(0)
|
---|
47 | {
|
---|
48 | }
|
---|
49 |
|
---|
50 | // --------------------------------------------------------------------------
|
---|
51 | //
|
---|
52 | // read the information from a binary input stream about the CRATE DATA,
|
---|
53 | // like specified in a TDAS note
|
---|
54 | //
|
---|
55 | Bool_t MRawCrateData::ReadEvtOld(istream& fin, UShort_t ver)
|
---|
56 | {
|
---|
57 | if (ver<7)
|
---|
58 | {
|
---|
59 | fin.read((char*)&fDAQCrateNumber, 2);
|
---|
60 | fin.read((char*)&fFADCEvtNumber, 4);
|
---|
61 | fin.read((char*)&fFADCClockTick, 4);
|
---|
62 | if (ver>1)
|
---|
63 | fin.read((char*)&fABFlags, 1);
|
---|
64 | }
|
---|
65 | else
|
---|
66 | {
|
---|
67 | // U8 CrateNumber; // 0-4
|
---|
68 | // U8 BoardNumber; // 0-1
|
---|
69 | // U8 ChannelNumber; // 0-3
|
---|
70 | fDAQCrateNumber = 0;
|
---|
71 | fin.read((char*)&fDAQCrateNumber, 1); // U8: CrateNumber 0-4
|
---|
72 |
|
---|
73 | Byte_t dummyb;
|
---|
74 | fin.read((char*)&dummyb, 1); // U8 Board number 0-1
|
---|
75 | fin.read((char*)&dummyb, 1); // U8 Channel number 0-3
|
---|
76 |
|
---|
77 | fin.read((char*)&fFADCEvtNumber, 4); // U32 CrateEvtNumber
|
---|
78 |
|
---|
79 | // Clock count. The Clock is synchronized with the 10 MHz external clock,
|
---|
80 | // which is feed to for all FADC channels.
|
---|
81 | // The units are [psec], which is obviously much smaller than the real accuracy.
|
---|
82 | // The ClockTick should be identical for all channels of the same board.
|
---|
83 | // Still keep it for debugging purposes.
|
---|
84 | // Like in the 300MHz system this number is extremely useful to check the
|
---|
85 | // integrity of the data.
|
---|
86 | UInt_t dummyi;
|
---|
87 | fin.read((char*)&dummyi, 4); // U32 FadcClockTickHi; // high significant bits
|
---|
88 | fin.read((char*)&dummyi, 4); // U32 FadcClockTickLo; // low significant bits
|
---|
89 |
|
---|
90 | // Trigger Time Interpolation in [psec] (originally it is a double
|
---|
91 | // in Acqiris software). Again this number should be identical for
|
---|
92 | // all channels in the same board. It is not clear at the moment
|
---|
93 | // if this number will be useful in the end, but I propose to keep
|
---|
94 | // it. The data volume is increase by <0.1%
|
---|
95 | UInt_t dummys;
|
---|
96 | fin.read((char*)&dummys, 2); // U16 TrigTimeInterpol;
|
---|
97 | }
|
---|
98 |
|
---|
99 | return fin.eof() ? kFALSE : kTRUE;
|
---|
100 | }
|
---|
101 |
|
---|
102 | Bool_t MRawCrateData::ReadEvt(istream& fin, UShort_t ver, UInt_t size)
|
---|
103 | {
|
---|
104 | if (ver<11)
|
---|
105 | return ReadEvtOld(fin, ver);
|
---|
106 |
|
---|
107 | if (size==0)
|
---|
108 | {
|
---|
109 | *fLog << err << "ERROR - Event header size unknown." << endl;
|
---|
110 | return kFALSE;
|
---|
111 | }
|
---|
112 |
|
---|
113 | if (size<28)
|
---|
114 | {
|
---|
115 | *fLog << err << "ERROR - Event header too small (<28b)." << endl;
|
---|
116 | return kFALSE;
|
---|
117 | }
|
---|
118 |
|
---|
119 | TArrayC h(size);
|
---|
120 | fin.read(h.GetArray(), h.GetSize());
|
---|
121 | if (!fin)
|
---|
122 | return kFALSE;
|
---|
123 |
|
---|
124 | // ----- convert -----
|
---|
125 | //const Byte_t *Char = reinterpret_cast<Byte_t* >(h.GetArray());
|
---|
126 | const UInt_t *Int = reinterpret_cast<UInt_t* >(h.GetArray());
|
---|
127 | //const Float_t *Float = reinterpret_cast<Float_t*>(h.GetArray());
|
---|
128 |
|
---|
129 | fDAQCrateNumber = Int[0];
|
---|
130 | fFADCEvtNumber = Int[3];
|
---|
131 |
|
---|
132 | return kTRUE;
|
---|
133 | }
|
---|
134 |
|
---|
135 | void MRawCrateData::SkipEvt(istream &fin, UShort_t ver)
|
---|
136 | {
|
---|
137 | fin.seekg(ver>1?11:10);
|
---|
138 | }
|
---|
139 |
|
---|
140 | // --------------------------------------------------------------------------
|
---|
141 | //
|
---|
142 | // print all stored information to gLog
|
---|
143 | //
|
---|
144 | void MRawCrateData::Print(Option_t *t) const
|
---|
145 | {
|
---|
146 | *fLog << all;
|
---|
147 | *fLog << "Crate #" << dec << fDAQCrateNumber << ": ";
|
---|
148 | *fLog << "FADCEventNr = " << fFADCEvtNumber << " ";
|
---|
149 | *fLog << "FADCClockTick = " << fFADCClockTick << " (20MHz) ";
|
---|
150 | *fLog << "ABFlags = 0x" << Form("%02x", fABFlags) << endl;
|
---|
151 | }
|
---|