]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSRawStreamSDDv2.cxx
Additional protection needed by AliRawReaderMemory (Henrik)
[u/mrichter/AliRoot.git] / ITS / AliITSRawStreamSDDv2.cxx
CommitLineData
2906f4c2 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
2906f4c2 16
17///////////////////////////////////////////////////////////////////////////////
18///
1ba0280f 19/// This class provides access to ITS SDD digits in test beam raw data,
20/// for beam test of August 2004
2906f4c2 21///
22///////////////////////////////////////////////////////////////////////////////
23
24#include "AliITSRawStreamSDDv2.h"
25#include "AliRawReader.h"
26
27ClassImp(AliITSRawStreamSDDv2)
28
29
2906f4c2 30AliITSRawStreamSDDv2::AliITSRawStreamSDDv2(AliRawReader* rawReader) :
1ba0280f 31 AliITSRawStreamSDD(rawReader)
32
2906f4c2 33{
34// create an object to read ITS SDD raw digits
35
2906f4c2 36
37 fRawReader->Reset();
1ba0280f 38 fRawReader->SelectEquipment(17, 204, 204);
2906f4c2 39}
40
41
42Bool_t AliITSRawStreamSDDv2::Next()
43{
44// read the next raw digit
45// returns kFALSE if there is no digit left
46
47 // skip the first 8 words
a97b3678 48 while (fSkip[0] < 8) {
2906f4c2 49 if (!fRawReader->ReadNextInt(fData)) return kFALSE;
50 if ((fData >> 30) == 0x01) continue; // JTAG word
a97b3678 51 if (fSkip[0] == 4) {
2906f4c2 52 if (fData != 0) {
53 Error("Next", "data not valid: %8.8d", fData);
54 return kFALSE;
55 }
56 }
a97b3678 57 fSkip[0]++;
2906f4c2 58 }
59
60 while (kTRUE) {
a97b3678 61 if ((fChannel < 0) || (fLastBit[0][fChannel] < fReadBits[0][fChannel])) {
2906f4c2 62 if (!fRawReader->ReadNextInt(fData)) return kFALSE; // read next word
63
64 fChannel = -1;
65 if ((fData >> 28) == 0x02) { // header
66 fEventId = (fData >> 3) & 0x07FF;
67 fCarlosId = (fData >> 1) & 0x03;
68 } else if ((fData >> 28) == 0x03) { // footer
69 // ignored
70 } else if ((fData >> 29) == 0x00) { // error
71 if ((fData & 0x1FFFFFFF) != 0) {
72 Error("Next", "error codes = %x, %x\n",
73 (fData >> 0) & 0x3FFF, (fData >> 14) & 0x3FFF);
74 return kFALSE;
75 }
76 } else if ((fData >> 30) == 0x01) { // JTAG word
77 // ignored
78 } else if ((fData >> 30) == 0x02) { // channel 0 data
79 fChannel = 0;
80 } else if ((fData >> 30) == 0x03) { // channel 1 data
81 fChannel = 1;
82 } else { // unknown data format
83 Error("Next", "invalid data: %8.8x\n", fData);
84 return kFALSE;
85 }
86
87 if (fChannel >= 0) { // add read word to the data
a97b3678 88 fChannelData[0][fChannel] +=
89 (ULong64_t(fData & 0x3FFFFFFF) << fLastBit[0][fChannel]);
90 fLastBit[0][fChannel] += 30;
2906f4c2 91 }
92
93 } else { // decode data
a97b3678 94 if (fReadCode[0][fChannel]) { // read the next code word
95 fChannelCode[0][fChannel] = ReadBits();
96 fReadCode[0][fChannel] = kFALSE;
97 fReadBits[0][fChannel] = fgkCodeLength[fChannelCode[0][fChannel]];
2906f4c2 98
99 } else { // read the next data word
100 UInt_t data = ReadBits();
a97b3678 101 fReadCode[0][fChannel] = kTRUE;
102 fReadBits[0][fChannel] = 3;
103 if (fChannelCode[0][fChannel] == 0) { // set the time bin
104 fTimeBin[0][fChannel] = data;
105 } else if (fChannelCode[0][fChannel] == 1) { // next anode
106 fTimeBin[0][fChannel] = 0;
107 fAnode[0][fChannel]++;
2906f4c2 108 } else { // ADC signal data
a97b3678 109 fSignal = DecompAmbra(data + (1 << fChannelCode[0][fChannel]) +
2906f4c2 110 fLowThreshold[fChannel]);
a97b3678 111 fCoord1 = fAnode[0][fChannel];
112 fCoord2 = fTimeBin[0][fChannel];
113 fTimeBin[0][fChannel]++;
2906f4c2 114 return kTRUE;
115 }
116 }
117 }
118 }
119
120 return kFALSE;
121}
122
123