]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSRawStreamSDDv2.cxx
bugfix to make the AliHLTDisplay working
[u/mrichter/AliRoot.git] / ITS / AliITSRawStreamSDDv2.cxx
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
16
17 ///////////////////////////////////////////////////////////////////////////////
18 ///
19 /// This class provides access to ITS SDD digits in test beam raw data,
20 /// for beam test of August 2004
21 ///
22 ///////////////////////////////////////////////////////////////////////////////
23
24 #include "AliITSRawStreamSDDv2.h"
25 #include "AliRawReader.h"
26
27 ClassImp(AliITSRawStreamSDDv2)
28
29
30 AliITSRawStreamSDDv2::AliITSRawStreamSDDv2(AliRawReader* rawReader) :
31   AliITSRawStreamSDD(rawReader)
32     
33 {
34 // create an object to read ITS SDD raw digits
35
36
37   fRawReader->Reset();
38   fRawReader->SelectEquipment(17, 204, 204);
39 }
40
41
42 Bool_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
48   while (fSkip < 8) {
49     if (!fRawReader->ReadNextInt(fData)) return kFALSE;
50     if ((fData >> 30) == 0x01) continue;  // JTAG word
51     if (fSkip == 4) {
52       if (fData != 0) {
53         Error("Next", "data not valid: %8.8d", fData);
54         return kFALSE;
55       }
56     }
57     fSkip++;
58   }
59
60   while (kTRUE) {
61     if ((fChannel < 0) || (fLastBit[fChannel] < fReadBits[fChannel])) {
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
88         fChannelData[fChannel] += 
89           (ULong64_t(fData & 0x3FFFFFFF) << fLastBit[fChannel]);
90         fLastBit[fChannel] += 30;
91       }
92
93     } else {  // decode data
94       if (fReadCode[fChannel]) {    // read the next code word
95         fChannelCode[fChannel] = ReadBits();
96         fReadCode[fChannel] = kFALSE;
97         fReadBits[fChannel] = fgkCodeLength[fChannelCode[fChannel]];
98
99       } else {                      // read the next data word
100         UInt_t data = ReadBits();
101         fReadCode[fChannel] = kTRUE;
102         fReadBits[fChannel] = 3;
103         if (fChannelCode[fChannel] == 0) {         // set the time bin
104           fTimeBin[fChannel] = data;
105         } else if (fChannelCode[fChannel] == 1) {  // next anode
106           fTimeBin[fChannel] = 0;
107           fAnode[fChannel]++;
108         } else {                                   // ADC signal data
109           fSignal = DecompAmbra(data + (1 << fChannelCode[fChannel]) + 
110             fLowThreshold[fChannel]);
111           fCoord1 = fAnode[fChannel];
112           fCoord2 = fTimeBin[fChannel];
113           fTimeBin[fChannel]++;
114           return kTRUE;
115         }
116       }
117     }
118   }
119
120   return kFALSE;
121 }
122
123