]>
Commit | Line | Data |
---|---|---|
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 | |
33 | ClassImp(AliCTPRawStream) | |
34 | ||
35 | //_____________________________________________________________________________ | |
36 | AliCTPRawStream::AliCTPRawStream(AliRawReader* rawReader) : | |
ce9ace8c | 37 | fIRArray("AliTriggerIR",3), |
86ad02d4 | 38 | fClassMask(0), |
39 | fClusterMask(0), | |
40 | fRawReader(rawReader) | |
41 | { | |
42 | // create an object to read CTP raw data | |
43 | // | |
44 | // select the raw data corresponding to | |
45 | // the CTP detector id | |
46 | fRawReader->Reset(); | |
362c9d61 | 47 | AliDebug(1,Form("Selecting raw data for detector %d",AliDAQ::DetectorID("TRG"))); |
48 | fRawReader->Select("TRG"); | |
86ad02d4 | 49 | } |
50 | ||
51 | //_____________________________________________________________________________ | |
52 | AliCTPRawStream::AliCTPRawStream(const AliCTPRawStream& stream) : | |
53 | TObject(stream), | |
ce9ace8c | 54 | fIRArray("AliTriggerIR",3), |
86ad02d4 | 55 | fClassMask(0), |
56 | fClusterMask(0), | |
57 | fRawReader(NULL) | |
58 | { | |
59 | // Copy constructor | |
60 | AliFatal("Copy constructor not implemented"); | |
61 | } | |
62 | ||
63 | //_____________________________________________________________________________ | |
64 | AliCTPRawStream& AliCTPRawStream::operator = (const AliCTPRawStream& | |
65 | /* stream */) | |
66 | { | |
67 | AliFatal("Assignment operator not implemented"); | |
68 | return *this; | |
69 | } | |
70 | ||
71 | //_____________________________________________________________________________ | |
72 | AliCTPRawStream::~AliCTPRawStream() | |
73 | { | |
74 | // destructor | |
ce9ace8c | 75 | fIRArray.Delete(); |
86ad02d4 | 76 | } |
77 | ||
78 | //_____________________________________________________________________________ | |
79 | void AliCTPRawStream::Reset() | |
80 | { | |
81 | // reset raw stream params | |
ce9ace8c | 82 | fIRArray.Clear(); |
86ad02d4 | 83 | |
84 | fClassMask = fClusterMask = 0; | |
85 | ||
86 | if (fRawReader) fRawReader->Reset(); | |
87 | } | |
88 | ||
89 | //_____________________________________________________________________________ | |
90 | Bool_t AliCTPRawStream::Next() | |
91 | { | |
92 | // read the whole CTP raw data stream | |
93 | // return kFALSE in case of error | |
94 | ||
95 | UChar_t *data = NULL; | |
96 | ||
43e9e2a9 | 97 | // CTP raw data does not contain CDH |
98 | fRawReader->RequireHeader(kFALSE); | |
99 | ||
100 | if (!fRawReader->ReadNextData(data)) { | |
101 | fRawReader->RequireHeader(kTRUE); | |
102 | return kFALSE; | |
103 | } | |
86ad02d4 | 104 | |
ce9ace8c | 105 | if ((fRawReader->GetDataSize()) < 32 || |
106 | ((fRawReader->GetDataSize() % 4) != 0)) { | |
86ad02d4 | 107 | AliError(Form("Wrong CTP raw data size: %d",fRawReader->GetDataSize())); |
43e9e2a9 | 108 | fRawReader->RequireHeader(kTRUE); |
86ad02d4 | 109 | return kFALSE; |
110 | } | |
111 | ||
112 | fClusterMask = data[12] >> 2; | |
113 | ||
114 | fClassMask = ((ULong64_t)data[12] & 0x3) << 48; | |
115 | ||
116 | fClassMask |= (ULong64_t)data[16] << 36; | |
117 | fClassMask |= ((ULong64_t)data[17] & 0xF) << 44; | |
118 | ||
119 | fClassMask |= (ULong64_t)data[20] << 24; | |
120 | fClassMask |= ((ULong64_t)data[21] & 0xF) << 32; | |
121 | ||
122 | fClassMask |= (ULong64_t)data[24] << 12; | |
123 | fClassMask |= ((ULong64_t)data[25] & 0xF) << 20; | |
124 | ||
125 | fClassMask |= (ULong64_t)data[28]; | |
126 | fClassMask |= ((ULong64_t)data[29] & 0xF) << 8; | |
127 | ||
ce9ace8c | 128 | if (fRawReader->GetDataSize() == 32) { |
129 | AliDebug(1,"No interaction records found"); | |
130 | fRawReader->RequireHeader(kTRUE); | |
131 | return kTRUE; | |
132 | } | |
133 | ||
134 | // Read IRs | |
135 | Int_t iword = 32; | |
136 | UChar_t level = 0; | |
137 | UInt_t *irdata = NULL; | |
138 | UInt_t irsize = 0; | |
139 | UShort_t orbit = 0; | |
140 | Bool_t incomplete = kFALSE, transerr = kFALSE; | |
141 | while (iword < fRawReader->GetDataSize()) { | |
142 | if (data[iword+1] & 0x80) { | |
143 | UChar_t flag = ((data[iword+1] >> 4) & 0x3); | |
144 | if (flag == 0) { | |
145 | if (irdata) { | |
146 | new (fIRArray[fIRArray.GetEntriesFast()]) | |
147 | AliTriggerIR(orbit,irsize,irdata,incomplete,transerr); | |
148 | irdata = NULL; irsize = 0; | |
149 | } | |
150 | level = 1; | |
151 | orbit = data[iword] << 12; | |
152 | orbit |= (data[iword+1] & 0xF) << 20; | |
153 | transerr = ((data[iword+1] >> 6) & 0x1); | |
154 | iword += 4; | |
155 | continue; | |
156 | } | |
157 | else if (flag == 3) { | |
158 | if (level == 1) { | |
159 | level = 2; | |
160 | orbit |= data[iword]; | |
161 | orbit |= ((data[iword+1] & 0xF) << 8); | |
162 | iword += 4; | |
163 | continue; | |
164 | } | |
165 | } | |
166 | UShort_t bc = data[iword]; | |
167 | bc |= ((data[iword] & 0xF) << 8); | |
168 | if (bc == 0xFFF) { | |
169 | incomplete = kTRUE; | |
170 | } | |
171 | else { | |
172 | if (level == 2) { | |
173 | level = 3; | |
174 | irdata = (UInt_t *)&data[iword]; | |
175 | irsize = 0; | |
176 | } | |
177 | if (level == 3) { | |
178 | irsize++; | |
179 | } | |
180 | } | |
181 | } | |
182 | else | |
183 | AliWarning(Form("Invalid interaction record (%d %d)",iword,fRawReader->GetDataSize())); | |
184 | ||
185 | iword += 4; | |
186 | } | |
187 | ||
188 | if (irdata) { | |
189 | new (fIRArray[fIRArray.GetEntriesFast()]) | |
190 | AliTriggerIR(orbit,irsize,irdata,incomplete,transerr); | |
191 | irdata = NULL; irsize = 0; | |
192 | } | |
193 | ||
43e9e2a9 | 194 | // Restore the raw-reader state!! |
195 | fRawReader->RequireHeader(kTRUE); | |
196 | ||
86ad02d4 | 197 | return kTRUE; |
198 | } | |
199 |