]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - STEER/STEER/AliCTPRawStream.cxx
Changes for #92834: Implement trigger aliases in AliRoot, RAW data reconstruction
[u/mrichter/AliRoot.git] / STEER / STEER / AliCTPRawStream.cxx
... / ...
CommitLineData
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"
30#include "AliDAQ.h"
31#include "AliTriggerIR.h"
32
33ClassImp(AliCTPRawStream)
34
35//_____________________________________________________________________________
36AliCTPRawStream::AliCTPRawStream(AliRawReader* rawReader) :
37 fIRArray("AliTriggerIR",3),
38 fOrbit(0),
39 fBC(0),
40 fL0TriggerInputs(0),
41 fL1TriggerInputs(0),
42 fL2TriggerInputs(0),
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();
52 AliDebug(1,Form("Selecting raw data for detector %d",AliDAQ::DetectorID("TRG")));
53 fRawReader->Select("TRG");
54}
55
56//_____________________________________________________________________________
57AliCTPRawStream::AliCTPRawStream(const AliCTPRawStream& stream) :
58 TObject(stream),
59 fIRArray("AliTriggerIR",3),
60 fOrbit(0),
61 fBC(0),
62 fL0TriggerInputs(0),
63 fL1TriggerInputs(0),
64 fL2TriggerInputs(0),
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
85 fIRArray.Delete();
86}
87
88//_____________________________________________________________________________
89void AliCTPRawStream::Reset()
90{
91 // reset raw stream params
92 fIRArray.Clear();
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
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 }
114
115 if ((fRawReader->GetDataSize()) < 32 ||
116 ((fRawReader->GetDataSize() % 4) != 0)) {
117 AliError(Form("Wrong CTP raw data size: %d",fRawReader->GetDataSize()));
118 fRawReader->RequireHeader(kTRUE);
119 return kFALSE;
120 }
121
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
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
146 if (fRawReader->GetDataSize() == 32) {
147 AliDebug(1,"No trigger input and interaction records found");
148 fRawReader->RequireHeader(kTRUE);
149 return kTRUE;
150 }
151
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);
175 return kTRUE;
176 }
177
178 // Read IRs
179 Int_t iword = 52;
180 UChar_t level = 0;
181 UInt_t *irdata = NULL;
182 UInt_t irsize = 0;
183 UInt_t orbit = 0;
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 AliDebug(1,Form("Orbit=0x%x\n",orbit));
208 continue;
209 }
210 }
211 UShort_t bc = data[iword];
212 bc |= ((data[iword+1] & 0xF) << 8);
213 AliDebug(1,Form("BC=0x%x\n",bc));
214 if (bc == 0xFFF) {
215 incomplete = kTRUE;
216 }
217 else {
218 if (level == 2) {
219 level = 3;
220 irdata = (UInt_t *)&data[iword];
221 irsize = 0;
222 }
223 if (level == 3) {
224 irsize++;
225 }
226 }
227 }
228 else
229 AliWarning(Form("Invalid interaction record (%d %d)",iword,fRawReader->GetDataSize()));
230
231 iword += 4;
232 }
233
234 if (irdata) {
235 new (fIRArray[fIRArray.GetEntriesFast()])
236 AliTriggerIR(orbit,irsize,irdata,incomplete,transerr);
237 irdata = NULL; irsize = 0;
238 }
239
240 // Restore the raw-reader state!!
241 fRawReader->RequireHeader(kTRUE);
242
243 return kTRUE;
244}
245