--- /dev/null
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * *
+ * Author: The ALICE Off-line Project. *
+ * Contributors are mentioned in the code where appropriate. *
+ * *
+ * Permission to use, copy, modify and distribute this software and its *
+ * documentation strictly for non-commercial purposes is hereby granted *
+ * without fee, provided that the above copyright notice appears in all *
+ * copies and that both the copyright notice and this permission notice *
+ * appear in the supporting documentation. The authors make no claims *
+ * about the suitability of this software for any purpose. It is *
+ * provided "as is" without express or implied warranty. *
+ **************************************************************************/
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// This is a class for reading ITS SDD raw data files and providing
+// information about digits
+//
+///////////////////////////////////////////////////////////////////////////////
+
+#include "AliITSRawStreamSDDv2.h"
+#include "AliRawReader.h"
+
+ClassImp(AliITSRawStreamSDDv2)
+
+
+
+const UInt_t AliITSRawStreamSDDv2::fgkCodeLength[8] =
+ {8, 18, 2, 3, 4, 5, 6, 7};
+
+
+AliITSRawStreamSDDv2::AliITSRawStreamSDDv2(AliRawReader* rawReader) :
+ AliITSRawStream(rawReader),
+ fSkip(0),
+ fEventId(-1),
+ fCarlosId(-1),
+ fChannel(-1)
+{
+// create an object to read ITS SDD raw digits
+
+ for (Int_t iChannel = 0; iChannel < 2; iChannel++) {
+ fChannelData[iChannel] = 0;
+ fLastBit[iChannel] = 0;
+ fChannelCode[iChannel] = 0;
+ fReadCode[iChannel] = kTRUE;
+ fReadBits[iChannel] = 3;
+ fTimeBin[iChannel] = 0;
+ fAnode[iChannel] = 0;
+ fLowThreshold[iChannel] = 0;
+ }
+
+ fRawReader->Reset();
+ fRawReader->SelectEquipment(17, 1, 1);
+}
+
+
+Bool_t AliITSRawStreamSDDv2::Next()
+{
+// read the next raw digit
+// returns kFALSE if there is no digit left
+
+ // skip the first 8 words
+ while (fSkip < 8) {
+ if (!fRawReader->ReadNextInt(fData)) return kFALSE;
+ if ((fData >> 30) == 0x01) continue; // JTAG word
+ if (fSkip == 4) {
+ if (fData != 0) {
+ Error("Next", "data not valid: %8.8d", fData);
+ return kFALSE;
+ }
+ }
+ fSkip++;
+ }
+
+ while (kTRUE) {
+ if ((fChannel < 0) || (fLastBit[fChannel] < fReadBits[fChannel])) {
+ if (!fRawReader->ReadNextInt(fData)) return kFALSE; // read next word
+
+ fChannel = -1;
+ if ((fData >> 28) == 0x02) { // header
+ fEventId = (fData >> 3) & 0x07FF;
+ fCarlosId = (fData >> 1) & 0x03;
+ } else if ((fData >> 28) == 0x03) { // footer
+ // ignored
+ } else if ((fData >> 29) == 0x00) { // error
+ if ((fData & 0x1FFFFFFF) != 0) {
+ Error("Next", "error codes = %x, %x\n",
+ (fData >> 0) & 0x3FFF, (fData >> 14) & 0x3FFF);
+ return kFALSE;
+ }
+ } else if ((fData >> 30) == 0x01) { // JTAG word
+ // ignored
+ } else if ((fData >> 30) == 0x02) { // channel 0 data
+ fChannel = 0;
+ } else if ((fData >> 30) == 0x03) { // channel 1 data
+ fChannel = 1;
+ } else { // unknown data format
+ Error("Next", "invalid data: %8.8x\n", fData);
+ return kFALSE;
+ }
+
+ if (fChannel >= 0) { // add read word to the data
+ fChannelData[fChannel] +=
+ (ULong64_t(fData & 0x3FFFFFFF) << fLastBit[fChannel]);
+ fLastBit[fChannel] += 30;
+ }
+
+ } else { // decode data
+ if (fReadCode[fChannel]) { // read the next code word
+ fChannelCode[fChannel] = ReadBits();
+ fReadCode[fChannel] = kFALSE;
+ fReadBits[fChannel] = fgkCodeLength[fChannelCode[fChannel]];
+
+ } else { // read the next data word
+ UInt_t data = ReadBits();
+ fReadCode[fChannel] = kTRUE;
+ fReadBits[fChannel] = 3;
+ if (fChannelCode[fChannel] == 0) { // set the time bin
+ fTimeBin[fChannel] = data;
+ } else if (fChannelCode[fChannel] == 1) { // next anode
+ fTimeBin[fChannel] = 0;
+ fAnode[fChannel]++;
+ } else { // ADC signal data
+ fSignal = DecompAmbra(data + (1 << fChannelCode[fChannel]) +
+ fLowThreshold[fChannel]);
+ fCoord1 = fAnode[fChannel];
+ fCoord2 = fTimeBin[fChannel];
+ fTimeBin[fChannel]++;
+ return kTRUE;
+ }
+ }
+ }
+ }
+
+ return kFALSE;
+}
+
+
+UInt_t AliITSRawStreamSDDv2::ReadBits()
+{
+// read bits from the given channel
+
+ UInt_t result = (fChannelData[fChannel] & ((1<<fReadBits[fChannel]) - 1));
+ fChannelData[fChannel] >>= fReadBits[fChannel];
+ fLastBit[fChannel] -= fReadBits[fChannel];
+ return result;
+}
+
+Int_t AliITSRawStreamSDDv2::DecompAmbra(Int_t value) const
+{
+// AMBRA decompression
+
+ if ((value & 0x80) == 0) {
+ return value & 0x7f;
+ } else if ((value & 0x40) == 0) {
+ return 0x081 + ((value & 0x3f) << 1);
+ } else if ((value & 0x20) == 0) {
+ return 0x104 + ((value & 0x1f) << 3);
+ } else {
+ return 0x208 + ((value & 0x1f) << 4);
+ }
+}
--- /dev/null
+#ifndef ALIITSRAWSTREAMSDDV2_H
+#define ALIITSRAWSTREAMSDDV2_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice */
+
+#include "AliITSRawStream.h"
+
+class AliRawReader;
+
+
+class AliITSRawStreamSDDv2: public AliITSRawStream {
+ public :
+ AliITSRawStreamSDDv2(AliRawReader* rawReader);
+ virtual ~AliITSRawStreamSDDv2() {};
+
+ virtual Bool_t Next();
+
+ Int_t GetAnode() const {return fCoord1;};
+ Int_t GetTimeBin() const {return fCoord2;};
+
+ private :
+ UInt_t ReadBits();
+ Int_t DecompAmbra(Int_t value) const;
+
+ UInt_t fData; // data read for file
+
+ static const UInt_t fgkCodeLength[8]; // length of coded data word
+ Int_t fSkip; // number of skipped words
+ Int_t fEventId; // event ID from the header
+ Int_t fCarlosId; // carlos ID from the header
+ Int_t fChannel; // current channel
+ ULong64_t fChannelData[2]; // packed data for the 2 channels
+ UInt_t fLastBit[2]; // last filled bit in fChannelData
+ UInt_t fChannelCode[2]; // current channel code
+ Bool_t fReadCode[2]; // next bits are code or data
+ UInt_t fReadBits[2]; // number of bits to read
+ Int_t fTimeBin[2]; // current time bin
+ Int_t fAnode[2]; // current anode number
+ Int_t fLowThreshold[2]; // low Carlos threshold
+
+ ClassDef(AliITSRawStreamSDDv2, 0) // class for reading ITS SDD raw digits
+};
+
+#endif
--- /dev/null
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * *
+ * Author: The ALICE Off-line Project. *
+ * Contributors are mentioned in the code where appropriate. *
+ * *
+ * Permission to use, copy, modify and distribute this software and its *
+ * documentation strictly for non-commercial purposes is hereby granted *
+ * without fee, provided that the above copyright notice appears in all *
+ * copies and that both the copyright notice and this permission notice *
+ * appear in the supporting documentation. The authors make no claims *
+ * about the suitability of this software for any purpose. It is *
+ * provided "as is" without express or implied warranty. *
+ **************************************************************************/
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// This is a class for reading ITS SDD raw data files and providing
+// information about digits
+//
+///////////////////////////////////////////////////////////////////////////////
+
+#include "AliVMERawStream.h"
+#include "AliRawReader.h"
+
+ClassImp(AliVMERawStream)
+
+
+
+AliVMERawStream::AliVMERawStream(AliRawReader* rawReader) :
+ fRawReader(rawReader),
+ fData(0),
+ fNChannels(-1),
+ fBlock(0),
+ fNumber(0),
+ fChannel(0),
+ fValue(0),
+ fTime(0),
+ fTimeMuSec(0)
+{
+// create an object to read VME raw digits
+
+ fRawReader = rawReader;
+
+ ReadTDC();
+ ReadTime();
+
+ fRawReader->Reset();
+ fRawReader->SelectEquipment(551, 38, 38);
+}
+
+AliVMERawStream::AliVMERawStream(const AliVMERawStream& stream) :
+ TObject(stream)
+{
+ Fatal("AliVMERawStream", "copy constructor not implemented");
+}
+
+AliVMERawStream& AliVMERawStream::operator = (const AliVMERawStream&
+ /* stream */)
+{
+ Fatal("operator =", "assignment operator not implemented");
+ return *this;
+}
+
+
+Bool_t AliVMERawStream::Next()
+{
+// read the next raw digit
+// returns kFALSE if there is no digit left
+
+ // V551 string
+ if (fNChannels == -1) {
+ if (!fRawReader->ReadNextInt(fData)) return kFALSE;
+ if (!CheckString("V551")) return kFALSE;
+ fNChannels = 0;
+ }
+
+ while (fNChannels == 0) {
+ // V550 or v551 string
+ if (!fRawReader->ReadNextInt(fData)) {
+ Error("Next", "incomplete equipment");
+ return kFALSE;
+ }
+ // check for v551 string (end of data)
+ const char* v551 = "v551";
+ if (fData == *((UInt_t*) v551)) return kFALSE;
+ if (!CheckString("V550")) return kFALSE;
+
+ // block
+ if (!fRawReader->ReadNextShort(fBlock)) {
+ Error("Next", "incomplete equipment");
+ return kFALSE;
+ }
+
+ // serial number
+ if (!fRawReader->ReadNextShort(fNumber)) {
+ Error("Next", "incomplete equipment");
+ return kFALSE;
+ }
+
+ // number of channels
+ if (!fRawReader->ReadNextInt((UInt_t) fNChannels)) {
+ Error("Next", "incomplete equipment");
+ return kFALSE;
+ }
+ }
+
+ if (!fRawReader->ReadNextInt(fData)) {
+ Error("Next", "incomplete equipment");
+ return kFALSE;
+ }
+ fChannel = (fData >> 12) & 0x03ff;
+ fValue = fData & 0x0fff;
+ fNChannels--;
+
+ return kTRUE;
+}
+
+
+
+Bool_t AliVMERawStream::CheckString(const char* str) const
+{
+// check fData to be equal to the given string
+
+ if (fData != *((UInt_t*) str)) {
+ char strData[5];
+ memcpy(strData, &fData, 4);
+ strData[4] = 0;
+ Error("CheckString", "invalid %s string (%s)", str, strData);
+ return kFALSE;
+ }
+ return kTRUE;
+}
+
+Bool_t AliVMERawStream::ReadTDC()
+{
+// read the TDC information
+
+ fRawReader->Reset();
+ fRawReader->SelectEquipment(775, 72, 72);
+
+ // V775 string
+ if (!fRawReader->ReadNextInt(fData)) return kFALSE;
+ if (!CheckString("V775")) return kFALSE;
+
+ // header
+ if (!fRawReader->ReadNextInt(fData)) {
+ Error("ReadTDC", "incomplete TDC equipment");
+ return kFALSE;
+ }
+ if ((fData & 0x02000000) == 0) {
+ Error("ReadTDC", "invalid header: 0x%x", fData);
+ return kFALSE;
+ }
+
+ // check the array size
+ Int_t nTDC = fRawReader->GetDataSize() / 4 - 4; // - V775,header,counter,v775
+ if ( nTDC != 3 ) {
+ Error("ReadTDC", "wrong number of TDC channels: %d", nTDC);
+ return kFALSE;
+ }
+
+ // TDC data
+ for (Int_t i = 0; i < fgkNTDC; i++) {
+ if (!fRawReader->ReadNextInt(fData)) {
+ Error("ReadTDC", "incomplete TDC equipment");
+ return kFALSE;
+ }
+ if (fData & 0x07000000) {
+ Warning("ReadTDC", "bad TDC data: %x", fData);
+ }
+ if ((fData & 0x00004000) == 0) {
+ Warning("ReadTDC", "TDC data not valid: %x", fData);
+ }
+ if (fData & 0x00002000) {
+ Warning("ReadTDC", "TDC data underflow: %x", fData);
+ }
+ if (fData & 0x00001000) {
+ Warning("ReadTDC", "TDC data overflow: %x", fData);
+ }
+ fTDCChannel[i] = (fData >> 16) & 0x1f;
+ fTDCValue[i] = fData & 0x0fff;
+ }
+
+ // counter
+ if (!fRawReader->ReadNextInt(fData)) {
+ Error("ReadTDC", "incomplete TDC equipment");
+ return kFALSE;
+ }
+ if ((fData & 0x04000000) == 0) {
+ Error("ReadTDC", "invalid counter: 0x%x", fData);
+ return kFALSE;
+ }
+
+ // v775 string
+ if (!fRawReader->ReadNextInt(fData)) {
+ Error("ReadTDC", "incomplete TDC equipment");
+ return kFALSE;
+ }
+ if (!CheckString("v775")) return kFALSE;
+
+ return kTRUE;
+}
+
+Bool_t AliVMERawStream::ReadTime()
+{
+// read the time information
+
+ fRawReader->Reset();
+ fRawReader->SelectEquipment(1970, 0x12345678, 0x12345678);
+
+ // TIME string
+ if (!fRawReader->ReadNextInt(fData)) return kFALSE;
+ if (!CheckString("TIME")) return kFALSE;
+
+ // time value
+ if (!fRawReader->ReadNextInt(fTime)) {
+ Error("ReadTime", "incomplete time equipment");
+ return kFALSE;
+ }
+
+ // micro seconds value
+ if (!fRawReader->ReadNextInt(fTimeMuSec)) {
+ Error("ReadTime", "incomplete time equipment");
+ return kFALSE;
+ }
+
+ // time string
+ if (!fRawReader->ReadNextInt(fData)) {
+ Error("ReadTime", "incomplete time equipment");
+ return kFALSE;
+ }
+ if (!CheckString("time")) return kFALSE;
+
+ return kTRUE;
+}
--- /dev/null
+#ifndef ALIVMERAWSTREAM_H
+#define ALIVMERAWSTREAM_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice */
+
+#include <TObject.h>
+
+class AliRawReader;
+
+
+class AliVMERawStream: public TObject {
+ public :
+ AliVMERawStream(AliRawReader* rawReader);
+ AliVMERawStream(const AliVMERawStream& stream);
+ AliVMERawStream& operator = (const AliVMERawStream& stream);
+ virtual ~AliVMERawStream() {};
+
+ virtual Bool_t Next();
+
+ UShort_t GetBlock() const {return fBlock;};
+ UShort_t GetNumber() const {return fNumber;};
+ UShort_t GetChannel() const {return fChannel;};
+ UShort_t GetValue() const {return fValue;};
+
+ UInt_t GetTDCChannel(Int_t iTDC) const
+ {return fTDCChannel[iTDC];};
+ UInt_t GetTDCValue(Int_t iTDC) const
+ {return fTDCValue[iTDC];};
+
+ UInt_t GetTime() const {return fTime;};
+ UInt_t GetTimeMuSec() const {return fTimeMuSec;};
+
+ private :
+ Bool_t CheckString(const char* str) const;
+ Bool_t ReadTDC();
+ Bool_t ReadTime();
+
+ AliRawReader* fRawReader; // object for reading the raw data
+
+ UInt_t fData; // data read for file
+
+ Int_t fNChannels; // number of c-ram channels
+ UShort_t fBlock; // C-ram block
+ UShort_t fNumber; // C-ram serial number
+ UShort_t fChannel; // C-ram channel
+ UShort_t fValue; // C-ram ADC value
+
+ static const Int_t fgkNTDC = 3; // number of TDCs
+ UInt_t fTDCChannel[fgkNTDC]; // TDC channels
+ UInt_t fTDCValue[fgkNTDC]; // TDC values
+
+ UInt_t fTime; // timing information
+ UInt_t fTimeMuSec; // micro seconds
+
+ ClassDef(AliVMERawStream, 0) // class for reading VME raw digits
+};
+
+#endif
#pragma link C++ class AliITSRawStreamSPD+;
#pragma link C++ class AliITSRawStreamSDD+;
#pragma link C++ class AliITSRawStreamSSD+;
+#pragma link C++ class AliITSRawStreamSDDv2+;
+#pragma link C++ class AliVMERawStream+;
#endif
AliTPCBuffer160.cxx AliTPCHuffman.cxx AliTPCCompression.cxx \
AliTPCRawStream.cxx \
AliITSRawStream.cxx AliITSRawStreamSPD.cxx \
- AliITSRawStreamSDD.cxx AliITSRawStreamSSD.cxx
+ AliITSRawStreamSDD.cxx AliITSRawStreamSSD.cxx \
+ AliITSRawStreamSDDv2.cxx AliVMERawStream.cxx
HDRS:= $(SRCS:.cxx=.h)