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 "AliITSRawStreamSDDv2.h"
24 #include "AliRawReader.h"
26 ClassImp(AliITSRawStreamSDDv2)
30 const UInt_t AliITSRawStreamSDDv2::fgkCodeLength[8] =
31 {8, 18, 2, 3, 4, 5, 6, 7};
34 AliITSRawStreamSDDv2::AliITSRawStreamSDDv2(AliRawReader* rawReader) :
35 AliITSRawStream(rawReader),
41 // create an object to read ITS SDD raw digits
43 for (Int_t iChannel = 0; iChannel < 2; iChannel++) {
44 fChannelData[iChannel] = 0;
45 fLastBit[iChannel] = 0;
46 fChannelCode[iChannel] = 0;
47 fReadCode[iChannel] = kTRUE;
48 fReadBits[iChannel] = 3;
49 fTimeBin[iChannel] = 0;
51 fLowThreshold[iChannel] = 0;
55 fRawReader->SelectEquipment(17, 1, 1);
59 Bool_t AliITSRawStreamSDDv2::Next()
61 // read the next raw digit
62 // returns kFALSE if there is no digit left
64 // skip the first 8 words
66 if (!fRawReader->ReadNextInt(fData)) return kFALSE;
67 if ((fData >> 30) == 0x01) continue; // JTAG word
70 Error("Next", "data not valid: %8.8d", fData);
78 if ((fChannel < 0) || (fLastBit[fChannel] < fReadBits[fChannel])) {
79 if (!fRawReader->ReadNextInt(fData)) return kFALSE; // read next word
82 if ((fData >> 28) == 0x02) { // header
83 fEventId = (fData >> 3) & 0x07FF;
84 fCarlosId = (fData >> 1) & 0x03;
85 } else if ((fData >> 28) == 0x03) { // footer
87 } else if ((fData >> 29) == 0x00) { // error
88 if ((fData & 0x1FFFFFFF) != 0) {
89 Error("Next", "error codes = %x, %x\n",
90 (fData >> 0) & 0x3FFF, (fData >> 14) & 0x3FFF);
93 } else if ((fData >> 30) == 0x01) { // JTAG word
95 } else if ((fData >> 30) == 0x02) { // channel 0 data
97 } else if ((fData >> 30) == 0x03) { // channel 1 data
99 } else { // unknown data format
100 Error("Next", "invalid data: %8.8x\n", fData);
104 if (fChannel >= 0) { // add read word to the data
105 fChannelData[fChannel] +=
106 (ULong64_t(fData & 0x3FFFFFFF) << fLastBit[fChannel]);
107 fLastBit[fChannel] += 30;
110 } else { // decode data
111 if (fReadCode[fChannel]) { // read the next code word
112 fChannelCode[fChannel] = ReadBits();
113 fReadCode[fChannel] = kFALSE;
114 fReadBits[fChannel] = fgkCodeLength[fChannelCode[fChannel]];
116 } else { // read the next data word
117 UInt_t data = ReadBits();
118 fReadCode[fChannel] = kTRUE;
119 fReadBits[fChannel] = 3;
120 if (fChannelCode[fChannel] == 0) { // set the time bin
121 fTimeBin[fChannel] = data;
122 } else if (fChannelCode[fChannel] == 1) { // next anode
123 fTimeBin[fChannel] = 0;
125 } else { // ADC signal data
126 fSignal = DecompAmbra(data + (1 << fChannelCode[fChannel]) +
127 fLowThreshold[fChannel]);
128 fCoord1 = fAnode[fChannel];
129 fCoord2 = fTimeBin[fChannel];
130 fTimeBin[fChannel]++;
141 UInt_t AliITSRawStreamSDDv2::ReadBits()
143 // read bits from the given channel
145 UInt_t result = (fChannelData[fChannel] & ((1<<fReadBits[fChannel]) - 1));
146 fChannelData[fChannel] >>= fReadBits[fChannel];
147 fLastBit[fChannel] -= fReadBits[fChannel];
151 Int_t AliITSRawStreamSDDv2::DecompAmbra(Int_t value) const
153 // AMBRA decompression
155 if ((value & 0x80) == 0) {
157 } else if ((value & 0x40) == 0) {
158 return 0x081 + ((value & 0x3f) << 1);
159 } else if ((value & 0x20) == 0) {
160 return 0x104 + ((value & 0x1f) << 3);
162 return 0x208 + ((value & 0x1f) << 4);