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 ITS SDD digits in test beam raw data.
22 ///////////////////////////////////////////////////////////////////////////////
24 #include "AliITSRawStreamSDDv2.h"
25 #include "AliRawReader.h"
27 ClassImp(AliITSRawStreamSDDv2)
31 const UInt_t AliITSRawStreamSDDv2::fgkCodeLength[8] =
32 {8, 18, 2, 3, 4, 5, 6, 7};
35 AliITSRawStreamSDDv2::AliITSRawStreamSDDv2(AliRawReader* rawReader) :
36 AliITSRawStream(rawReader),
42 // create an object to read ITS SDD raw digits
44 for (Int_t iChannel = 0; iChannel < 2; iChannel++) {
45 fChannelData[iChannel] = 0;
46 fLastBit[iChannel] = 0;
47 fChannelCode[iChannel] = 0;
48 fReadCode[iChannel] = kTRUE;
49 fReadBits[iChannel] = 3;
50 fTimeBin[iChannel] = 0;
52 fLowThreshold[iChannel] = 0;
56 fRawReader->SelectEquipment(17, 1, 1);
60 Bool_t AliITSRawStreamSDDv2::Next()
62 // read the next raw digit
63 // returns kFALSE if there is no digit left
65 // skip the first 8 words
67 if (!fRawReader->ReadNextInt(fData)) return kFALSE;
68 if ((fData >> 30) == 0x01) continue; // JTAG word
71 Error("Next", "data not valid: %8.8d", fData);
79 if ((fChannel < 0) || (fLastBit[fChannel] < fReadBits[fChannel])) {
80 if (!fRawReader->ReadNextInt(fData)) return kFALSE; // read next word
83 if ((fData >> 28) == 0x02) { // header
84 fEventId = (fData >> 3) & 0x07FF;
85 fCarlosId = (fData >> 1) & 0x03;
86 } else if ((fData >> 28) == 0x03) { // footer
88 } else if ((fData >> 29) == 0x00) { // error
89 if ((fData & 0x1FFFFFFF) != 0) {
90 Error("Next", "error codes = %x, %x\n",
91 (fData >> 0) & 0x3FFF, (fData >> 14) & 0x3FFF);
94 } else if ((fData >> 30) == 0x01) { // JTAG word
96 } else if ((fData >> 30) == 0x02) { // channel 0 data
98 } else if ((fData >> 30) == 0x03) { // channel 1 data
100 } else { // unknown data format
101 Error("Next", "invalid data: %8.8x\n", fData);
105 if (fChannel >= 0) { // add read word to the data
106 fChannelData[fChannel] +=
107 (ULong64_t(fData & 0x3FFFFFFF) << fLastBit[fChannel]);
108 fLastBit[fChannel] += 30;
111 } else { // decode data
112 if (fReadCode[fChannel]) { // read the next code word
113 fChannelCode[fChannel] = ReadBits();
114 fReadCode[fChannel] = kFALSE;
115 fReadBits[fChannel] = fgkCodeLength[fChannelCode[fChannel]];
117 } else { // read the next data word
118 UInt_t data = ReadBits();
119 fReadCode[fChannel] = kTRUE;
120 fReadBits[fChannel] = 3;
121 if (fChannelCode[fChannel] == 0) { // set the time bin
122 fTimeBin[fChannel] = data;
123 } else if (fChannelCode[fChannel] == 1) { // next anode
124 fTimeBin[fChannel] = 0;
126 } else { // ADC signal data
127 fSignal = DecompAmbra(data + (1 << fChannelCode[fChannel]) +
128 fLowThreshold[fChannel]);
129 fCoord1 = fAnode[fChannel];
130 fCoord2 = fTimeBin[fChannel];
131 fTimeBin[fChannel]++;
142 UInt_t AliITSRawStreamSDDv2::ReadBits()
144 // read bits from the given channel
146 UInt_t result = (fChannelData[fChannel] & ((1<<fReadBits[fChannel]) - 1));
147 fChannelData[fChannel] >>= fReadBits[fChannel];
148 fLastBit[fChannel] -= fReadBits[fChannel];
152 Int_t AliITSRawStreamSDDv2::DecompAmbra(Int_t value) const
154 // AMBRA decompression
156 if ((value & 0x80) == 0) {
158 } else if ((value & 0x40) == 0) {
159 return 0x081 + ((value & 0x3f) << 1);
160 } else if ((value & 0x20) == 0) {
161 return 0x104 + ((value & 0x1f) << 3);
163 return 0x208 + ((value & 0x1f) << 4);