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 **************************************************************************/
16 ///////////////////////////////////////////////////////////////////////////////
18 // This is a class for reading ITS SDD raw data files and providing
19 // information about digits
21 ///////////////////////////////////////////////////////////////////////////////
23 #include "AliVMERawStream.h"
24 #include "AliRawReader.h"
26 ClassImp(AliVMERawStream)
30 AliVMERawStream::AliVMERawStream(AliRawReader* rawReader) :
31 fRawReader(rawReader),
41 // create an object to read VME raw digits
43 fRawReader = rawReader;
49 fRawReader->SelectEquipment(551, 38, 38);
52 AliVMERawStream::AliVMERawStream(const AliVMERawStream& stream) :
55 Fatal("AliVMERawStream", "copy constructor not implemented");
58 AliVMERawStream& AliVMERawStream::operator = (const AliVMERawStream&
61 Fatal("operator =", "assignment operator not implemented");
66 Bool_t AliVMERawStream::Next()
68 // read the next raw digit
69 // returns kFALSE if there is no digit left
72 if (fNChannels == -1) {
73 if (!fRawReader->ReadNextInt(fData)) return kFALSE;
74 if (!CheckString("V551")) return kFALSE;
78 while (fNChannels == 0) {
79 // V550 or v551 string
80 if (!fRawReader->ReadNextInt(fData)) {
81 Error("Next", "incomplete equipment");
84 // check for v551 string (end of data)
85 const char* v551 = "v551";
86 if (fData == *((UInt_t*) v551)) return kFALSE;
87 if (!CheckString("V550")) return kFALSE;
90 if (!fRawReader->ReadNextShort(fBlock)) {
91 Error("Next", "incomplete equipment");
96 if (!fRawReader->ReadNextShort(fNumber)) {
97 Error("Next", "incomplete equipment");
101 // number of channels
102 if (!fRawReader->ReadNextInt((UInt_t) fNChannels)) {
103 Error("Next", "incomplete equipment");
108 if (!fRawReader->ReadNextInt(fData)) {
109 Error("Next", "incomplete equipment");
112 fChannel = (fData >> 12) & 0x03ff;
113 fValue = fData & 0x0fff;
121 Bool_t AliVMERawStream::CheckString(const char* str) const
123 // check fData to be equal to the given string
125 if (fData != *((UInt_t*) str)) {
127 memcpy(strData, &fData, 4);
129 Error("CheckString", "invalid %s string (%s)", str, strData);
135 Bool_t AliVMERawStream::ReadTDC()
137 // read the TDC information
140 fRawReader->SelectEquipment(775, 72, 72);
143 if (!fRawReader->ReadNextInt(fData)) return kFALSE;
144 if (!CheckString("V775")) return kFALSE;
147 if (!fRawReader->ReadNextInt(fData)) {
148 Error("ReadTDC", "incomplete TDC equipment");
151 if ((fData & 0x02000000) == 0) {
152 Error("ReadTDC", "invalid header: 0x%x", fData);
156 // check the array size
157 Int_t nTDC = fRawReader->GetDataSize() / 4 - 4; // - V775,header,counter,v775
159 Error("ReadTDC", "wrong number of TDC channels: %d", nTDC);
164 for (Int_t i = 0; i < fgkNTDC; i++) {
165 if (!fRawReader->ReadNextInt(fData)) {
166 Error("ReadTDC", "incomplete TDC equipment");
169 if (fData & 0x07000000) {
170 Warning("ReadTDC", "bad TDC data: %x", fData);
172 if ((fData & 0x00004000) == 0) {
173 Warning("ReadTDC", "TDC data not valid: %x", fData);
175 if (fData & 0x00002000) {
176 Warning("ReadTDC", "TDC data underflow: %x", fData);
178 if (fData & 0x00001000) {
179 Warning("ReadTDC", "TDC data overflow: %x", fData);
181 fTDCChannel[i] = (fData >> 16) & 0x1f;
182 fTDCValue[i] = fData & 0x0fff;
186 if (!fRawReader->ReadNextInt(fData)) {
187 Error("ReadTDC", "incomplete TDC equipment");
190 if ((fData & 0x04000000) == 0) {
191 Error("ReadTDC", "invalid counter: 0x%x", fData);
196 if (!fRawReader->ReadNextInt(fData)) {
197 Error("ReadTDC", "incomplete TDC equipment");
200 if (!CheckString("v775")) return kFALSE;
205 Bool_t AliVMERawStream::ReadTime()
207 // read the time information
210 fRawReader->SelectEquipment(1970, 0x12345678, 0x12345678);
213 if (!fRawReader->ReadNextInt(fData)) return kFALSE;
214 if (!CheckString("TIME")) return kFALSE;
217 if (!fRawReader->ReadNextInt(fTime)) {
218 Error("ReadTime", "incomplete time equipment");
222 // micro seconds value
223 if (!fRawReader->ReadNextInt(fTimeMuSec)) {
224 Error("ReadTime", "incomplete time equipment");
229 if (!fRawReader->ReadNextInt(fData)) {
230 Error("ReadTime", "incomplete time equipment");
233 if (!CheckString("time")) return kFALSE;