ATTPCROOT  0.3.0-alpha
A ROOT-based framework for analyzing data from active target detectors
GETBasicFrameHeader.cxx
Go to the documentation of this file.
1 #include "GETBasicFrameHeader.h"
2 
3 #include <Rtypes.h>
4 
5 #include <cstring>
6 #include <iostream>
7 
9 
11 {
12  Clear();
13 }
14 
15 UInt_t GETBasicFrameHeader::GetHeaderSize(Bool_t inBytes)
16 {
17  return CorrectEndianness(fHeaderSize, 2) * (inBytes ? GetUnitBlock() : 1);
18 }
20 {
21  return CorrectEndianness(fItemSize, 2);
22 }
24 {
25  return CorrectEndianness(fNItems, 4);
26 }
28 {
29  return CorrectEndianness(fEventTime, 6);
30 }
32 {
33  return CorrectEndianness(fEventID, 4);
34 }
36 {
37  return (UInt_t)fCoboID;
38 }
40 {
41  return (UInt_t)fAsadID;
42 }
44 {
45  return CorrectEndianness(fReadOffset, 2);
46 }
48 {
49  return (UInt_t)fStatus;
50 }
51 
52 bitset<72> GETBasicFrameHeader::GetHitPat(Int_t asadID)
53 {
54  bitset<72> tempHitPat;
55 
56  if (!IsLittleEndian()) {
57  for (Int_t iByte = 0; iByte < 9; iByte++)
58  for (Int_t iBit = 0; iBit < 8; iBit++)
59  if ((fHitPat[asadID][iByte] >> iBit) & 0x1)
60  tempHitPat.set((9 - iByte - 1) * 8 + iBit);
61  } else {
62  for (Int_t iByte = 0; iByte < 9; iByte++)
63  for (Int_t iBit = 0; iBit < 8; iBit++)
64  if ((fHitPat[asadID][iByte] >> iBit) & 0x1)
65  tempHitPat.set(iByte * 8 + iBit);
66  }
67 
68  return tempHitPat;
69 }
70 
71 UInt_t GETBasicFrameHeader::GetMultip(Int_t asadID)
72 {
73  uint8_t *tempMultip = fMultip[0] + 2 * asadID;
74  return CorrectEndianness(tempMultip, 2);
75 }
76 
78 {
79  return CorrectEndianness(fWindowOut, 4);
80 }
82 {
83  uint8_t *tempLastCell = fLastCell[0] + 2 * asadID;
84 
85  return CorrectEndianness(tempLastCell, 2);
86 }
87 
89 {
90  return GetFrameSize() - GetHeaderSize();
91 }
93 {
95 }
96 
98 {
100 
101  memset(fHeaderSize, 0, sizeof(uint8_t) * 2);
102  memset(fItemSize, 0, sizeof(uint8_t) * 2);
103  memset(fNItems, 0, sizeof(uint8_t) * 4);
104  memset(fEventTime, 0, sizeof(uint8_t) * 6);
105  memset(fEventID, 0, sizeof(uint8_t) * 4);
106  memset(&fCoboID, 0, sizeof(uint8_t) * 1);
107  memset(&fAsadID, 0, sizeof(uint8_t) * 1);
108  memset(fReadOffset, 0, sizeof(uint8_t) * 2);
109  memset(&fStatus, 0, sizeof(uint8_t) * 1);
110  memset(fHitPat, 0, sizeof(uint8_t) * 4 * 9);
111  memset(fMultip, 0, sizeof(uint8_t) * 4 * 2);
112  memset(fWindowOut, 0, sizeof(uint8_t) * 4);
113  memset(fLastCell, 0, sizeof(uint8_t) * 4 * 2);
114 }
115 
116 void GETBasicFrameHeader::Read(ifstream &stream)
117 {
118  Clear();
119 
120  GETHeaderBase::Read(stream);
121 
122  stream.read((Char_t *)fHeaderSize, 2);
123  stream.read((Char_t *)fItemSize, 2);
124  stream.read((Char_t *)fNItems, 4);
125  stream.read((Char_t *)fEventTime, 6);
126  stream.read((Char_t *)fEventID, 4);
127  stream.read((Char_t *)&fCoboID, 1);
128  stream.read((Char_t *)&fAsadID, 1);
129  stream.read((Char_t *)fReadOffset, 2);
130  stream.read((Char_t *)&fStatus, 1);
131  stream.read((Char_t *)fHitPat, 4 * 9);
132  stream.read((Char_t *)fMultip, 4 * 2);
133  stream.read((Char_t *)fWindowOut, 4);
134  stream.read((Char_t *)fLastCell, 4 * 2);
135 
136  stream.ignore(GetHeaderSkip());
137 }
138 
140 {
141  cout << showbase << hex;
142  cout << " == GETBasicFrameHeader ========================================================================" << endl;
143  cout << " metaType: " << GetMetaType() << endl;
144  cout << " - Endianness: " << (IsLittleEndian() ? "Little" : "Big") << endl;
145  cout << " - Blobness: " << (IsBlob() ? "YES" : "NO") << endl;
146  cout << " - UnitBlock: " << dec << GetUnitBlock() << " Bytes" << hex << endl;
147  cout << " frameSize: " << GetFrameSize(kFALSE) << " (" << dec << GetFrameSize(kFALSE)
148  << " Blocks = " << GetFrameSize() << hex << " Bytes)" << endl;
149  cout << " dataSource: " << GetDataSource() << endl;
150  cout << " frameType: " << GetFrameType() << endl;
151  cout << " revision: " << GetRevision() << endl;
152  cout << " headerSize: " << GetHeaderSize(kFALSE) << " (" << dec << GetHeaderSize(kFALSE)
153  << " Blocks = " << GetHeaderSize() << hex << " Bytes)" << endl;
154  cout << " itemSize: " << GetItemSize() << endl;
155  cout << " nItems: " << GetNItems() << dec << " (" << GetNItems() << ")" << hex << endl;
156  cout << " eventTime: " << GetEventTime() << dec << " (" << GetEventTime() << ")" << endl;
157  cout << " eventID: " << GetEventID() << endl;
158  cout << " coboID: " << GetCoboID() << endl;
159  cout << " asadID: " << GetAsadID() << endl;
160  cout << " readOffset: " << GetReadOffset() << endl;
161  cout << " status: " << GetStatus() << endl;
162  for (Int_t iAsad = 0; iAsad < 4; iAsad++)
163  cout << " hitPat_" << iAsad << ": " << GetHitPat(iAsad) << endl;
164  for (Int_t iAsad = 0; iAsad < 4; iAsad++)
165  cout << " multip_" << iAsad << ": " << GetMultip(iAsad) << endl;
166  cout << " windowOut: " << GetWindowOut() << endl;
167  for (Int_t iAsad = 0; iAsad < 4; iAsad++)
168  cout << " lastCell_" << iAsad << ": " << GetLastCell(iAsad) << endl;
169  cout << " ===============================================================================================" << endl;
170 }
GETBasicFrameHeader::GetWindowOut
UInt_t GetWindowOut()
Definition: GETBasicFrameHeader.cxx:77
GETBasicFrameHeader::GetHeaderSize
UInt_t GetHeaderSize(Bool_t inBytes=kTRUE)
Definition: GETBasicFrameHeader.cxx:15
GETHeaderBase::GetFrameSize
UInt_t GetFrameSize(Bool_t inBytes=kTRUE)
Definition: GETHeaderBase.cxx:21
GETHeaderBase::Clear
void Clear(Option_t *="")
Definition: GETHeaderBase.cxx:74
GETHeaderBase::GetRevision
UInt_t GetRevision()
Definition: GETHeaderBase.cxx:33
GETBasicFrameHeader::Print
void Print()
Definition: GETBasicFrameHeader.cxx:139
GETBasicFrameHeader::GetEventTime
ULong_t GetEventTime()
Definition: GETBasicFrameHeader.cxx:27
GETBasicFrameHeader::GetHeaderSkip
UInt_t GetHeaderSkip()
Definition: GETBasicFrameHeader.cxx:92
GETBasicFrameHeader::GetLastCell
UInt_t GetLastCell(Int_t asadID)
Definition: GETBasicFrameHeader.cxx:81
GETHeaderBase::GetMetaType
UInt_t GetMetaType()
Definition: GETHeaderBase.cxx:17
GETBasicFrameHeader::GetCoboID
UInt_t GetCoboID()
Definition: GETBasicFrameHeader.cxx:35
GETHeaderBase::IsLittleEndian
Bool_t IsLittleEndian()
Definition: GETHeaderBase.cxx:42
ClassImp
ClassImp(GETBasicFrameHeader) GETBasicFrameHeader
Definition: GETBasicFrameHeader.cxx:8
GETBasicFrameHeader::Read
void Read(ifstream &stream)
Definition: GETBasicFrameHeader.cxx:116
GETBasicFrameHeader::GetStatus
UInt_t GetStatus()
Definition: GETBasicFrameHeader.cxx:47
GETBasicFrameHeader.h
GETBasicFrameHeader::GetHitPat
bitset< 72 > GetHitPat(Int_t asadID)
Definition: GETBasicFrameHeader.cxx:52
GETBasicFrameHeader::GetItemSize
UInt_t GetItemSize()
Definition: GETBasicFrameHeader.cxx:19
GETBasicFrameHeader::Clear
void Clear(Option_t *="")
Definition: GETBasicFrameHeader.cxx:97
GETHeaderBase::GetFrameType
UInt_t GetFrameType()
Definition: GETHeaderBase.cxx:29
GETHeaderBase::IsBlob
Bool_t IsBlob()
Definition: GETHeaderBase.cxx:46
GETHeaderBase::GetUnitBlock
UInt_t GetUnitBlock()
Definition: GETHeaderBase.cxx:50
GETBasicFrameHeader::GetAsadID
UInt_t GetAsadID()
Definition: GETBasicFrameHeader.cxx:39
GETHeaderBase::Read
void Read(ifstream &file, Bool_t rewind=kFALSE)
Definition: GETHeaderBase.cxx:83
GETBasicFrameHeader::GetNItems
UInt_t GetNItems()
Definition: GETBasicFrameHeader.cxx:23
GETBASICFRAMEHEADERSIZE
#define GETBASICFRAMEHEADERSIZE
Definition: GETBasicFrameHeader.h:10
GETBasicFrameHeader::GetReadOffset
UInt_t GetReadOffset()
Definition: GETBasicFrameHeader.cxx:43
GETHeaderBase::GetDataSource
UInt_t GetDataSource()
Definition: GETHeaderBase.cxx:25
GETBasicFrameHeader
Definition: GETBasicFrameHeader.h:21
GETBasicFrameHeader::GETBasicFrameHeader
GETBasicFrameHeader()
GETBasicFrameHeader::GetMultip
UInt_t GetMultip(Int_t asadID)
Definition: GETBasicFrameHeader.cxx:71
GETHeaderBase::CorrectEndianness
ULong64_t CorrectEndianness(uint8_t *variable, Short_t length)
Definition: GETHeaderBase.cxx:55
GETBasicFrameHeader::GetFrameSkip
ULong64_t GetFrameSkip()
Definition: GETBasicFrameHeader.cxx:88
GETBasicFrameHeader::GetEventID
UInt_t GetEventID()
Definition: GETBasicFrameHeader.cxx:31