]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliCTPRawStream.cxx
modification(by Levente) to solve the problem in the QA mentioned in the bug report...
[u/mrichter/AliRoot.git] / STEER / AliCTPRawStream.cxx
CommitLineData
86ad02d4 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/// This class provides access to CTP DDL raw data.
19///
20/// The raw data format is taken form the trigger TDR.
21/// The meaning of the trigger class and cluster masks
22/// are given in the trigger description file (in /data)
23/// and in the AliCentralTrigger class.
24///
25///////////////////////////////////////////////////////////////////////////////
26
27#include "AliCTPRawStream.h"
28#include "AliRawReader.h"
29#include "AliLog.h"
362c9d61 30#include "AliDAQ.h"
ce9ace8c 31#include "AliTriggerIR.h"
86ad02d4 32
33ClassImp(AliCTPRawStream)
34
35//_____________________________________________________________________________
36AliCTPRawStream::AliCTPRawStream(AliRawReader* rawReader) :
ce9ace8c 37 fIRArray("AliTriggerIR",3),
4bc0c995 38 fOrbit(0),
39 fBC(0),
40 fL0TriggerInputs(0),
41 fL1TriggerInputs(0),
42 fL2TriggerInputs(0),
86ad02d4 43 fClassMask(0),
44 fClusterMask(0),
45 fRawReader(rawReader)
46{
47 // create an object to read CTP raw data
48 //
49 // select the raw data corresponding to
50 // the CTP detector id
51 fRawReader->Reset();
362c9d61 52 AliDebug(1,Form("Selecting raw data for detector %d",AliDAQ::DetectorID("TRG")));
53 fRawReader->Select("TRG");
86ad02d4 54}
55
56//_____________________________________________________________________________
57AliCTPRawStream::AliCTPRawStream(const AliCTPRawStream& stream) :
58 TObject(stream),
ce9ace8c 59 fIRArray("AliTriggerIR",3),
4bc0c995 60 fOrbit(0),
61 fBC(0),
62 fL0TriggerInputs(0),
63 fL1TriggerInputs(0),
64 fL2TriggerInputs(0),
86ad02d4 65 fClassMask(0),
66 fClusterMask(0),
67 fRawReader(NULL)
68{
69 // Copy constructor
70 AliFatal("Copy constructor not implemented");
71}
72
73//_____________________________________________________________________________
74AliCTPRawStream& AliCTPRawStream::operator = (const AliCTPRawStream&
75 /* stream */)
76{
77 AliFatal("Assignment operator not implemented");
78 return *this;
79}
80
81//_____________________________________________________________________________
82AliCTPRawStream::~AliCTPRawStream()
83{
84 // destructor
ce9ace8c 85 fIRArray.Delete();
86ad02d4 86}
87
88//_____________________________________________________________________________
89void AliCTPRawStream::Reset()
90{
91 // reset raw stream params
ce9ace8c 92 fIRArray.Clear();
86ad02d4 93
94 fClassMask = fClusterMask = 0;
95
96 if (fRawReader) fRawReader->Reset();
97}
98
99//_____________________________________________________________________________
100Bool_t AliCTPRawStream::Next()
101{
102 // read the whole CTP raw data stream
103 // return kFALSE in case of error
104
105 UChar_t *data = NULL;
106
43e9e2a9 107 // CTP raw data does not contain CDH
108 fRawReader->RequireHeader(kFALSE);
109
110 if (!fRawReader->ReadNextData(data)) {
111 fRawReader->RequireHeader(kTRUE);
112 return kFALSE;
113 }
86ad02d4 114
ce9ace8c 115 if ((fRawReader->GetDataSize()) < 32 ||
116 ((fRawReader->GetDataSize() % 4) != 0)) {
86ad02d4 117 AliError(Form("Wrong CTP raw data size: %d",fRawReader->GetDataSize()));
43e9e2a9 118 fRawReader->RequireHeader(kTRUE);
86ad02d4 119 return kFALSE;
120 }
121
4bc0c995 122 fBC = data[0];
123 fBC |= (data[1] & 0xF) << 8;
124
125 fOrbit = data[4] << 12;
126 fOrbit |= (data[5] & 0xF) << 20;
127 fOrbit |= data[8];
128 fOrbit |= (data[9] & 0xF) << 8;
129
86ad02d4 130 fClusterMask = data[12] >> 2;
131
132 fClassMask = ((ULong64_t)data[12] & 0x3) << 48;
133
134 fClassMask |= (ULong64_t)data[16] << 36;
135 fClassMask |= ((ULong64_t)data[17] & 0xF) << 44;
136
137 fClassMask |= (ULong64_t)data[20] << 24;
138 fClassMask |= ((ULong64_t)data[21] & 0xF) << 32;
139
140 fClassMask |= (ULong64_t)data[24] << 12;
141 fClassMask |= ((ULong64_t)data[25] & 0xF) << 20;
142
143 fClassMask |= (ULong64_t)data[28];
144 fClassMask |= ((ULong64_t)data[29] & 0xF) << 8;
145
ce9ace8c 146 if (fRawReader->GetDataSize() == 32) {
4bc0c995 147 AliDebug(1,"No trigger input and interaction records found");
ce9ace8c 148 fRawReader->RequireHeader(kTRUE);
149 return kTRUE;
150 }
151
4bc0c995 152 // Read detector trigger inputs
153 if (fRawReader->GetDataSize() < 52) {
154 AliError(Form("Wrong CTP raw data size: %d",fRawReader->GetDataSize()));
155 fRawReader->RequireHeader(kTRUE);
156 return kFALSE;
157 }
158
159 fL0TriggerInputs = data[32] << 12;
160 fL0TriggerInputs |= (data[33] & 0xF) << 20;
161 fL0TriggerInputs |= data[36];
162 fL0TriggerInputs |= (data[37] & 0xF) << 8;
163
164 fL1TriggerInputs = data[40] << 12;
165 fL1TriggerInputs |= (data[41] & 0xF) << 20;
166 fL1TriggerInputs |= data[44];
167 fL1TriggerInputs |= (data[45] & 0xF) << 8;
168
169 fL2TriggerInputs = data[48] << 12;
170 fL2TriggerInputs |= (data[49] & 0xF) << 20;
171
172 if (fRawReader->GetDataSize() == 52) {
173 AliDebug(1,"No interaction records found");
174 fRawReader->RequireHeader(kTRUE);
9b8aed53 175 return kTRUE;
4bc0c995 176 }
177
ce9ace8c 178 // Read IRs
4bc0c995 179 Int_t iword = 52;
ce9ace8c 180 UChar_t level = 0;
181 UInt_t *irdata = NULL;
182 UInt_t irsize = 0;
4bc0c995 183 UInt_t orbit = 0;
ce9ace8c 184 Bool_t incomplete = kFALSE, transerr = kFALSE;
185 while (iword < fRawReader->GetDataSize()) {
186 if (data[iword+1] & 0x80) {
187 UChar_t flag = ((data[iword+1] >> 4) & 0x3);
188 if (flag == 0) {
189 if (irdata) {
190 new (fIRArray[fIRArray.GetEntriesFast()])
191 AliTriggerIR(orbit,irsize,irdata,incomplete,transerr);
192 irdata = NULL; irsize = 0;
193 }
194 level = 1;
195 orbit = data[iword] << 12;
196 orbit |= (data[iword+1] & 0xF) << 20;
197 transerr = ((data[iword+1] >> 6) & 0x1);
198 iword += 4;
199 continue;
200 }
201 else if (flag == 3) {
202 if (level == 1) {
203 level = 2;
204 orbit |= data[iword];
205 orbit |= ((data[iword+1] & 0xF) << 8);
206 iword += 4;
207 continue;
208 }
209 }
210 UShort_t bc = data[iword];
211 bc |= ((data[iword] & 0xF) << 8);
212 if (bc == 0xFFF) {
213 incomplete = kTRUE;
214 }
215 else {
216 if (level == 2) {
217 level = 3;
218 irdata = (UInt_t *)&data[iword];
219 irsize = 0;
220 }
221 if (level == 3) {
222 irsize++;
223 }
224 }
225 }
226 else
227 AliWarning(Form("Invalid interaction record (%d %d)",iword,fRawReader->GetDataSize()));
228
229 iword += 4;
230 }
231
232 if (irdata) {
233 new (fIRArray[fIRArray.GetEntriesFast()])
234 AliTriggerIR(orbit,irsize,irdata,incomplete,transerr);
235 irdata = NULL; irsize = 0;
236 }
237
43e9e2a9 238 // Restore the raw-reader state!!
239 fRawReader->RequireHeader(kTRUE);
240
86ad02d4 241 return kTRUE;
242}
243