1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 ///////////////////////////////////////////////////////////////////////////////
20 /// This class provides access to VME data in test beam raw data.
22 ///////////////////////////////////////////////////////////////////////////////
24 #include "AliVMERawStream.h"
25 #include "AliRawReader.h"
27 ClassImp(AliVMERawStream)
31 AliVMERawStream::AliVMERawStream(AliRawReader* rawReader) :
32 fRawReader(rawReader),
42 // create an object to read VME raw digits
44 fRawReader = rawReader;
50 fRawReader->SelectEquipment(551, 38, 38);
53 Bool_t AliVMERawStream::Next()
55 // read the next raw digit
56 // returns kFALSE if there is no digit left
59 if (fNChannels == -1) {
60 if (!fRawReader->ReadNextInt(fData)) return kFALSE;
61 if (!CheckString("V551")) return kFALSE;
65 while (fNChannels == 0) {
66 // V550 or v551 string
67 if (!fRawReader->ReadNextInt(fData)) {
68 Error("Next", "incomplete equipment");
71 // check for v551 string (end of data)
72 const char* v551 = "v551";
73 if (fData == *((UInt_t*) v551)) return kFALSE;
74 if (!CheckString("V550")) return kFALSE;
77 if (!fRawReader->ReadNextShort(fBlock)) {
78 Error("Next", "incomplete equipment");
83 if (!fRawReader->ReadNextShort(fNumber)) {
84 Error("Next", "incomplete equipment");
89 if (!fRawReader->ReadNextInt((UInt_t&) fNChannels)) {
90 Error("Next", "incomplete equipment");
95 if (!fRawReader->ReadNextInt(fData)) {
96 Error("Next", "incomplete equipment");
99 fChannel = (fData >> 12) & 0x03ff;
100 fValue = fData & 0x0fff;
108 Bool_t AliVMERawStream::CheckString(const char* str) const
110 // check fData to be equal to the given string
112 if (fData != *((UInt_t*) str)) {
114 memcpy(strData, &fData, 4);
116 Error("CheckString", "invalid %s string (%s)", str, strData);
122 Bool_t AliVMERawStream::ReadTDC()
124 // read the TDC information
127 fRawReader->SelectEquipment(775, 72, 72);
130 if (!fRawReader->ReadNextInt(fData)) return kFALSE;
131 if (!CheckString("V775")) return kFALSE;
134 if (!fRawReader->ReadNextInt(fData)) {
135 Error("ReadTDC", "incomplete TDC equipment");
138 if ((fData & 0x02000000) == 0) {
139 Error("ReadTDC", "invalid header: 0x%x", fData);
143 // check the array size
144 Int_t nTDC = fRawReader->GetDataSize() / 4 - 4; // - V775,header,counter,v775
146 Error("ReadTDC", "wrong number of TDC channels: %d", nTDC);
151 for (Int_t i = 0; i < fgkNTDC; i++) {
152 if (!fRawReader->ReadNextInt(fData)) {
153 Error("ReadTDC", "incomplete TDC equipment");
156 if (fData & 0x07000000) {
157 Warning("ReadTDC", "bad TDC data: %x", fData);
159 if ((fData & 0x00004000) == 0) {
160 Warning("ReadTDC", "TDC data not valid: %x", fData);
162 if (fData & 0x00002000) {
163 Warning("ReadTDC", "TDC data underflow: %x", fData);
165 if (fData & 0x00001000) {
166 Warning("ReadTDC", "TDC data overflow: %x", fData);
168 fTDCChannel[i] = (fData >> 16) & 0x1f;
169 fTDCValue[i] = fData & 0x0fff;
173 if (!fRawReader->ReadNextInt(fData)) {
174 Error("ReadTDC", "incomplete TDC equipment");
177 if ((fData & 0x04000000) == 0) {
178 Error("ReadTDC", "invalid counter: 0x%x", fData);
183 if (!fRawReader->ReadNextInt(fData)) {
184 Error("ReadTDC", "incomplete TDC equipment");
187 if (!CheckString("v775")) return kFALSE;
192 Bool_t AliVMERawStream::ReadTime()
194 // read the time information
197 fRawReader->SelectEquipment(1970, 0x12345678, 0x12345678);
200 if (!fRawReader->ReadNextInt(fData)) return kFALSE;
201 if (!CheckString("TIME")) return kFALSE;
204 if (!fRawReader->ReadNextInt(fTime)) {
205 Error("ReadTime", "incomplete time equipment");
209 // micro seconds value
210 if (!fRawReader->ReadNextInt(fTimeMuSec)) {
211 Error("ReadTime", "incomplete time equipment");
216 if (!fRawReader->ReadNextInt(fData)) {
217 Error("ReadTime", "incomplete time equipment");
220 if (!CheckString("time")) return kFALSE;