]>
Commit | Line | Data |
---|---|---|
1 | /************************************************************************** | |
2 | * Copyright(c) 2007-2009, 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 | ||
16 | /* $Id: $*/ | |
17 | ||
18 | /////////////////////////////////////////////////////////////////////////////// | |
19 | /// | |
20 | /// This class provides access to ITS SDD digits in beam test raw data | |
21 | /// | |
22 | /////////////////////////////////////////////////////////////////////////////// | |
23 | ||
24 | #include "AliLog.h" | |
25 | #include "AliITSRawStreamSDDBeamTest.h" | |
26 | #include "AliRawReader.h" | |
27 | ||
28 | ||
29 | ClassImp(AliITSRawStreamSDDBeamTest) | |
30 | ||
31 | const UInt_t AliITSRawStreamSDDBeamTest::fgkCodeLength[8] = {8, 18, 2, 3, 4, 5, 6, 7}; | |
32 | ||
33 | //______________________________________________________________________ | |
34 | AliITSRawStreamSDDBeamTest::AliITSRawStreamSDDBeamTest(AliRawReader* rawReader) : | |
35 | AliITSRawStream(rawReader), | |
36 | fData(0), | |
37 | fSkip(0), | |
38 | fEventId(0), | |
39 | fCarlosId(-1), | |
40 | fChannel(0), | |
41 | fJitter(0) | |
42 | { | |
43 | // create an object to read ITS SDD raw digits | |
44 | fRawReader->Reset(); | |
45 | fRawReader->SelectEquipment(17, 204, 204); | |
46 | ||
47 | ||
48 | } | |
49 | ||
50 | //______________________________________________________________________ | |
51 | UInt_t AliITSRawStreamSDDBeamTest::ReadBits() | |
52 | { | |
53 | // read bits from the given channel | |
54 | UInt_t result = (fChannelData[fCarlosId][fChannel] & ((1<<fReadBits[fCarlosId][fChannel]) - 1)); | |
55 | fChannelData[fCarlosId][fChannel] >>= fReadBits[fCarlosId][fChannel]; | |
56 | fLastBit[fCarlosId][fChannel] -= fReadBits[fCarlosId][fChannel]; | |
57 | return result; | |
58 | } | |
59 | ||
60 | //______________________________________________________________________ | |
61 | Int_t AliITSRawStreamSDDBeamTest::DecompAmbra(Int_t value) const | |
62 | { | |
63 | // AMBRA decompression (from 8 to 10 bit) | |
64 | ||
65 | if ((value & 0x80) == 0) { | |
66 | return value & 0x7f; | |
67 | } else if ((value & 0x40) == 0) { | |
68 | return 0x081 + ((value & 0x3f) << 1); | |
69 | } else if ((value & 0x20) == 0) { | |
70 | return 0x104 + ((value & 0x1f) << 3); | |
71 | } else { | |
72 | return 0x208 + ((value & 0x1f) << 4); | |
73 | } | |
74 | ||
75 | } | |
76 | ||
77 | //______________________________________________________________________ | |
78 | Bool_t AliITSRawStreamSDDBeamTest::Next() | |
79 | { | |
80 | // read the next raw digit | |
81 | // returns kFALSE if there is no digit left | |
82 | ||
83 | // skip the first 8 words | |
84 | while (fSkip < 8) { | |
85 | if (!fRawReader->ReadNextInt(fData)) return kFALSE; | |
86 | if ((fData >> 30) == 0x01) continue; // JTAG word | |
87 | if (fSkip == 4) { | |
88 | if (fData != 0) { | |
89 | Error("Next", "data not valid: %8.8d", fData); | |
90 | return kFALSE; | |
91 | } | |
92 | } | |
93 | fSkip++; | |
94 | } | |
95 | ||
96 | while (kTRUE) { | |
97 | if ((fChannel < 0) || (fLastBit[0][fChannel] < fReadBits[0][fChannel])) { | |
98 | if (!fRawReader->ReadNextInt(fData)) return kFALSE; // read next word | |
99 | ||
100 | fChannel = -1; | |
101 | if ((fData >> 28) == 0x02) { // header | |
102 | fEventId = (fData >> 3) & 0x07FF; | |
103 | fCarlosId = (fData >> 1) & 0x03; | |
104 | } else if ((fData >> 28) == 0x03) { // footer | |
105 | // ignored | |
106 | } else if ((fData >> 29) == 0x00) { // error | |
107 | if ((fData & 0x1FFFFFFF) != 0) { | |
108 | Error("Next", "error codes = %x, %x\n", | |
109 | (fData >> 0) & 0x3FFF, (fData >> 14) & 0x3FFF); | |
110 | return kFALSE; | |
111 | } | |
112 | } else if ((fData >> 30) == 0x01) { // JTAG word | |
113 | // ignored | |
114 | } else if ((fData >> 30) == 0x02) { // channel 0 data | |
115 | fChannel = 0; | |
116 | } else if ((fData >> 30) == 0x03) { // channel 1 data | |
117 | fChannel = 1; | |
118 | } else { // unknown data format | |
119 | Error("Next", "invalid data: %8.8x\n", fData); | |
120 | return kFALSE; | |
121 | } | |
122 | ||
123 | if (fChannel >= 0) { // add read word to the data | |
124 | fChannelData[0][fChannel] += | |
125 | (ULong64_t(fData & 0x3FFFFFFF) << fLastBit[0][fChannel]); | |
126 | fLastBit[0][fChannel] += 30; | |
127 | } | |
128 | ||
129 | } else { // decode data | |
130 | if (fReadCode[0][fChannel]) { // read the next code word | |
131 | fChannelCode[0][fChannel] = ReadBits(); | |
132 | fReadCode[0][fChannel] = kFALSE; | |
133 | fReadBits[0][fChannel] = fgkCodeLength[fChannelCode[0][fChannel]]; | |
134 | ||
135 | } else { // read the next data word | |
136 | UInt_t data = ReadBits(); | |
137 | fReadCode[0][fChannel] = kTRUE; | |
138 | fReadBits[0][fChannel] = 3; | |
139 | if (fChannelCode[0][fChannel] == 0) { // set the time bin | |
140 | fTimeBin[0][fChannel] = data; | |
141 | } else if (fChannelCode[0][fChannel] == 1) { // next anode | |
142 | fTimeBin[0][fChannel] = 0; | |
143 | fAnode[0][fChannel]++; | |
144 | } else { // ADC signal data | |
145 | fSignal = DecompAmbra(data + (1 << fChannelCode[0][fChannel]) + | |
146 | fLowThreshold[fChannel]); | |
147 | fCoord1 = fAnode[0][fChannel]; | |
148 | fCoord2 = fTimeBin[0][fChannel]; | |
149 | fTimeBin[0][fChannel]++; | |
150 | return kTRUE; | |
151 | } | |
152 | } | |
153 | } | |
154 | } | |
155 | ||
156 | return kFALSE; | |
157 | } | |
158 | ||
159 | ||
160 | ||
161 |