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 AliVMERawStream::AliVMERawStream(const AliVMERawStream& stream) :
56 Fatal("AliVMERawStream", "copy constructor not implemented");
59 AliVMERawStream& AliVMERawStream::operator = (const AliVMERawStream&
62 Fatal("operator =", "assignment operator not implemented");
67 Bool_t AliVMERawStream::Next()
69 // read the next raw digit
70 // returns kFALSE if there is no digit left
73 if (fNChannels == -1) {
74 if (!fRawReader->ReadNextInt(fData)) return kFALSE;
75 if (!CheckString("V551")) return kFALSE;
79 while (fNChannels == 0) {
80 // V550 or v551 string
81 if (!fRawReader->ReadNextInt(fData)) {
82 Error("Next", "incomplete equipment");
85 // check for v551 string (end of data)
86 const char* v551 = "v551";
87 if (fData == *((UInt_t*) v551)) return kFALSE;
88 if (!CheckString("V550")) return kFALSE;
91 if (!fRawReader->ReadNextShort(fBlock)) {
92 Error("Next", "incomplete equipment");
97 if (!fRawReader->ReadNextShort(fNumber)) {
98 Error("Next", "incomplete equipment");
102 // number of channels
103 if (!fRawReader->ReadNextInt((UInt_t&) fNChannels)) {
104 Error("Next", "incomplete equipment");
109 if (!fRawReader->ReadNextInt(fData)) {
110 Error("Next", "incomplete equipment");
113 fChannel = (fData >> 12) & 0x03ff;
114 fValue = fData & 0x0fff;
122 Bool_t AliVMERawStream::CheckString(const char* str) const
124 // check fData to be equal to the given string
126 if (fData != *((UInt_t*) str)) {
128 memcpy(strData, &fData, 4);
130 Error("CheckString", "invalid %s string (%s)", str, strData);
136 Bool_t AliVMERawStream::ReadTDC()
138 // read the TDC information
141 fRawReader->SelectEquipment(775, 72, 72);
144 if (!fRawReader->ReadNextInt(fData)) return kFALSE;
145 if (!CheckString("V775")) return kFALSE;
148 if (!fRawReader->ReadNextInt(fData)) {
149 Error("ReadTDC", "incomplete TDC equipment");
152 if ((fData & 0x02000000) == 0) {
153 Error("ReadTDC", "invalid header: 0x%x", fData);
157 // check the array size
158 Int_t nTDC = fRawReader->GetDataSize() / 4 - 4; // - V775,header,counter,v775
160 Error("ReadTDC", "wrong number of TDC channels: %d", nTDC);
165 for (Int_t i = 0; i < fgkNTDC; i++) {
166 if (!fRawReader->ReadNextInt(fData)) {
167 Error("ReadTDC", "incomplete TDC equipment");
170 if (fData & 0x07000000) {
171 Warning("ReadTDC", "bad TDC data: %x", fData);
173 if ((fData & 0x00004000) == 0) {
174 Warning("ReadTDC", "TDC data not valid: %x", fData);
176 if (fData & 0x00002000) {
177 Warning("ReadTDC", "TDC data underflow: %x", fData);
179 if (fData & 0x00001000) {
180 Warning("ReadTDC", "TDC data overflow: %x", fData);
182 fTDCChannel[i] = (fData >> 16) & 0x1f;
183 fTDCValue[i] = fData & 0x0fff;
187 if (!fRawReader->ReadNextInt(fData)) {
188 Error("ReadTDC", "incomplete TDC equipment");
191 if ((fData & 0x04000000) == 0) {
192 Error("ReadTDC", "invalid counter: 0x%x", fData);
197 if (!fRawReader->ReadNextInt(fData)) {
198 Error("ReadTDC", "incomplete TDC equipment");
201 if (!CheckString("v775")) return kFALSE;
206 Bool_t AliVMERawStream::ReadTime()
208 // read the time information
211 fRawReader->SelectEquipment(1970, 0x12345678, 0x12345678);
214 if (!fRawReader->ReadNextInt(fData)) return kFALSE;
215 if (!CheckString("TIME")) return kFALSE;
218 if (!fRawReader->ReadNextInt(fTime)) {
219 Error("ReadTime", "incomplete time equipment");
223 // micro seconds value
224 if (!fRawReader->ReadNextInt(fTimeMuSec)) {
225 Error("ReadTime", "incomplete time equipment");
230 if (!fRawReader->ReadNextInt(fData)) {
231 Error("ReadTime", "incomplete time equipment");
234 if (!CheckString("time")) return kFALSE;