]>
Commit | Line | Data |
---|---|---|
972432c1 | 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 | ||
bf4d93eb | 16 | /* $Id$ */ |
972432c1 | 17 | |
3d1463c8 | 18 | //----------------------------------------------------------------------------- |
c4ee792d | 19 | /// \class AliMUONRawStreamTrigger |
972432c1 | 20 | /// This class provides access to MUON digits in raw data. |
21 | /// | |
22 | /// It loops over all MUON digits in the raw data given by the AliRawReader. | |
b921196a | 23 | /// The Next method goes to the next local response. If there are no local response left |
24 | /// it returns kFALSE. | |
972432c1 | 25 | /// It can loop also over DDL and store the decoded rawdata in TClonesArrays |
313a427d | 26 | /// in payload class. |
972432c1 | 27 | /// |
b921196a | 28 | /// Version implement for Trigger |
c4ee792d | 29 | /// \author Christian Finck |
3d1463c8 | 30 | //----------------------------------------------------------------------------- |
972432c1 | 31 | |
b921196a | 32 | #include <TArrayS.h> |
33 | ||
972432c1 | 34 | #include "AliMUONRawStreamTrigger.h" |
b921196a | 35 | #include "AliMUONDarcHeader.h" |
36 | #include "AliMUONRegHeader.h" | |
37 | #include "AliMUONLocalStruct.h" | |
38 | #include "AliMUONDDLTrigger.h" | |
39 | #include "AliMUONLogger.h" | |
972432c1 | 40 | |
41 | #include "AliRawReader.h" | |
42 | #include "AliRawDataHeader.h" | |
9e378ff4 | 43 | #include "AliDAQ.h" |
972432c1 | 44 | #include "AliLog.h" |
45 | ||
b921196a | 46 | #include <cassert> |
47 | ||
00e86732 | 48 | /// \cond CLASSIMP |
972432c1 | 49 | ClassImp(AliMUONRawStreamTrigger) |
00e86732 | 50 | /// \endcond |
972432c1 | 51 | |
36f90a1a | 52 | const Int_t AliMUONRawStreamTrigger::fgkMaxDDL = 2; |
07a5b6b7 | 53 | |
ce350193 | 54 | //___________________________________________ |
55 | AliMUONRawStreamTrigger::AliMUONRawStreamTrigger(TRootIOCtor* /*dummy*/) | |
56 | : AliMUONVRawStreamTrigger(), | |
57 | fPayload(0x0), | |
58 | fCurrentDDL(0x0), | |
59 | fCurrentDDLIndex(fgkMaxDDL), | |
60 | fCurrentDarcHeader(0x0), | |
61 | fCurrentRegHeader(0x0), | |
62 | fCurrentRegHeaderIndex(0), | |
63 | fCurrentLocalStruct(0x0), | |
64 | fCurrentLocalStructIndex(0), | |
65 | fLocalStructRead(kFALSE), | |
66 | fDDL(0), | |
67 | fNextDDL(kFALSE) | |
68 | { | |
69 | /// | |
70 | /// create an object to read MUON raw digits | |
71 | /// Default ctor with no mem allocation for I/O | |
72 | /// | |
73 | } | |
74 | ||
07a5b6b7 | 75 | //___________________________________________ |
972432c1 | 76 | AliMUONRawStreamTrigger::AliMUONRawStreamTrigger() |
1788245f | 77 | : AliMUONVRawStreamTrigger(), |
9f5dcca3 | 78 | fPayload(new AliMUONPayloadTrigger()), |
b921196a | 79 | fCurrentDDL(0x0), |
80 | fCurrentDDLIndex(fgkMaxDDL), | |
81 | fCurrentDarcHeader(0x0), | |
82 | fCurrentRegHeader(0x0), | |
83 | fCurrentRegHeaderIndex(0), | |
84 | fCurrentLocalStruct(0x0), | |
85 | fCurrentLocalStructIndex(0), | |
86 | fLocalStructRead(kFALSE), | |
4a3224ff | 87 | fDDL(0), |
9ee1d6ff | 88 | fNextDDL(kFALSE) |
972432c1 | 89 | { |
00e86732 | 90 | /// |
91 | /// create an object to read MUON raw digits | |
92 | /// Default ctor for monitoring purposes | |
93 | /// | |
972432c1 | 94 | |
972432c1 | 95 | |
96 | } | |
97 | ||
98 | //_________________________________________________________________ | |
99 | AliMUONRawStreamTrigger::AliMUONRawStreamTrigger(AliRawReader* rawReader) | |
1788245f | 100 | : AliMUONVRawStreamTrigger(rawReader), |
9f5dcca3 | 101 | fPayload(new AliMUONPayloadTrigger()), |
b921196a | 102 | fCurrentDDL(0x0), |
103 | fCurrentDDLIndex(fgkMaxDDL), | |
104 | fCurrentDarcHeader(0x0), | |
105 | fCurrentRegHeader(0x0), | |
106 | fCurrentRegHeaderIndex(0), | |
107 | fCurrentLocalStruct(0x0), | |
108 | fCurrentLocalStructIndex(0), | |
109 | fLocalStructRead(kFALSE), | |
4a3224ff | 110 | fDDL(0), |
9ee1d6ff | 111 | fNextDDL(kFALSE) |
972432c1 | 112 | { |
00e86732 | 113 | /// |
114 | /// ctor with AliRawReader as argument | |
115 | /// for reconstruction purpose | |
116 | /// | |
972432c1 | 117 | |
972432c1 | 118 | } |
119 | ||
120 | //___________________________________ | |
121 | AliMUONRawStreamTrigger::~AliMUONRawStreamTrigger() | |
122 | { | |
00e86732 | 123 | /// |
124 | /// clean up | |
125 | /// | |
313a427d | 126 | delete fPayload; |
972432c1 | 127 | } |
128 | ||
129 | //_____________________________________________________________ | |
b921196a | 130 | Bool_t AliMUONRawStreamTrigger::Next(UChar_t& id, UChar_t& dec, Bool_t& trigY, |
131 | UChar_t& yPos, UChar_t& sXDev, UChar_t& xDev, | |
132 | UChar_t& xPos, Bool_t& triggerY, Bool_t& triggerX, | |
133 | TArrayS& xPattern, TArrayS& yPattern) | |
134 | { | |
135 | /// | |
136 | /// read the next raw digit (local structure) | |
137 | /// returns kFALSE if there is no digit left | |
138 | /// Should call First() before this method to start the iteration. | |
139 | /// | |
140 | ||
141 | if ( IsDone() ) return kFALSE; | |
142 | ||
143 | if ( fLocalStructRead ) { | |
144 | ||
145 | Bool_t ok = GetNextLocalStruct(); | |
146 | if (!ok) | |
147 | { | |
148 | // this is the end | |
149 | return kFALSE; | |
150 | } | |
151 | } | |
152 | ||
153 | fLocalStructRead = kTRUE; | |
154 | ||
155 | id = fCurrentLocalStruct->GetId(); | |
156 | dec = fCurrentLocalStruct->GetDec(); | |
157 | trigY = fCurrentLocalStruct->GetTrigY(); | |
158 | yPos = fCurrentLocalStruct->GetYPos(); | |
159 | sXDev = fCurrentLocalStruct->GetSXDev(); | |
160 | xDev = fCurrentLocalStruct->GetXDev(); | |
161 | xPos = fCurrentLocalStruct->GetXPos(); | |
162 | ||
163 | triggerX = fCurrentLocalStruct->GetTriggerX(); | |
164 | triggerY = fCurrentLocalStruct->GetTriggerY(); | |
165 | ||
166 | fCurrentLocalStruct->GetXPattern(xPattern); | |
167 | fCurrentLocalStruct->GetYPattern(yPattern); | |
168 | ||
169 | return kTRUE; | |
170 | } | |
171 | ||
172 | //______________________________________________________ | |
173 | Bool_t AliMUONRawStreamTrigger::IsDone() const | |
972432c1 | 174 | { |
b921196a | 175 | /// Whether the iteration is finished or not |
176 | return (fCurrentLocalStruct==0); | |
177 | } | |
178 | ||
179 | //______________________________________________________ | |
180 | void AliMUONRawStreamTrigger::First() | |
181 | { | |
182 | /// Initialize the iteration process. | |
183 | ||
184 | fCurrentDDLIndex = -1; | |
185 | // Must reset all the pointers because if we return before calling | |
186 | // GetNextLocalStruct() the user might call CurrentDDL(), CurrentBlockHeader(), | |
187 | // CurrentRegHeader() or CurrentLocalStruct() which should return reasonable | |
188 | // results in that case. | |
189 | fCurrentDDL = 0; | |
190 | fCurrentDarcHeader = 0; | |
191 | fCurrentRegHeader = 0; | |
192 | fCurrentLocalStruct = 0; | |
193 | ||
194 | // Find the first non-empty structure | |
195 | if (not GetNextDDL()) return; | |
196 | if (not GetNextRegHeader()) return; | |
197 | GetNextLocalStruct(); | |
198 | } | |
199 | ||
200 | //______________________________________________________ | |
201 | Bool_t AliMUONRawStreamTrigger::GetNextDDL() | |
202 | { | |
203 | /// Returns the next DDL present | |
204 | ||
205 | assert( GetReader() != 0 ); | |
f4ee80d2 | 206 | |
b921196a | 207 | |
208 | Bool_t kFound(kFALSE); | |
209 | ||
210 | while ( fCurrentDDLIndex < fgkMaxDDL-1 && !kFound ) | |
211 | { | |
212 | ++fCurrentDDLIndex; | |
213 | GetReader()->Reset(); | |
214 | GetReader()->Select("MUONTRG",fCurrentDDLIndex,fCurrentDDLIndex); | |
215 | if ( GetReader()->ReadHeader() ) | |
216 | { | |
217 | kFound = kTRUE; | |
218 | } | |
219 | } | |
220 | ||
221 | if ( !kFound ) | |
222 | { | |
223 | // fCurrentDDLIndex is set to fgkMaxDDL so that we exit the above loop immediately | |
224 | // for a subsequent call to this method, unless NextEvent is called in between. | |
225 | fCurrentDDLIndex = fgkMaxDDL; | |
226 | // We have not actually been able to complete the loading of the new DDL so | |
227 | // we are still on the old one. In this case we do not need to reset fCurrentDDL. | |
228 | //fCurrentDDL = 0; | |
6817de1c | 229 | if (IsErrorLogger()) AddErrorMessage(); |
b921196a | 230 | return kFALSE; |
231 | } | |
232 | ||
233 | Int_t totalDataWord = GetReader()->GetDataSize(); // in bytes | |
234 | ||
f4ee80d2 | 235 | Bool_t scalerEvent = GetReader()->GetDataHeader()->GetL1TriggerMessage() & 0x1; |
236 | ||
b921196a | 237 | AliDebug(3, Form("DDL Number %d totalDataWord %d\n", fCurrentDDLIndex, |
238 | totalDataWord)); | |
239 | ||
240 | UInt_t *buffer = new UInt_t[totalDataWord/4]; | |
f4ee80d2 | 241 | |
b921196a | 242 | if ( !GetReader()->ReadNext((UChar_t*)buffer, totalDataWord) ) |
243 | { | |
244 | // We have not actually been able to complete the loading of the new DDL so | |
245 | // we are still on the old one. In this case we do not need to reset fCurrentDDL. | |
246 | //fCurrentDDL = 0; | |
247 | delete [] buffer; | |
248 | return kFALSE; | |
249 | } | |
250 | ||
251 | #ifndef R__BYTESWAP | |
47c48013 | 252 | Swap(buffer, totalDataWord / sizeof(UInt_t)); // swap needed for mac power pc |
b921196a | 253 | #endif |
254 | ||
255 | fPayload->ResetDDL(); | |
256 | ||
f4ee80d2 | 257 | |
258 | ||
259 | Bool_t ok = fPayload->Decode(buffer, scalerEvent); | |
b921196a | 260 | |
261 | delete[] buffer; | |
262 | ||
263 | fCurrentDDL = fPayload->GetDDLTrigger(); | |
264 | ||
265 | fCurrentDarcHeader = fCurrentDDL->GetDarcHeader(); | |
266 | ||
267 | fCurrentRegHeaderIndex = -1; | |
268 | ||
269 | ||
270 | return ok; | |
271 | } | |
272 | ||
273 | ||
274 | //______________________________________________________ | |
275 | Bool_t AliMUONRawStreamTrigger::GetNextRegHeader() | |
276 | { | |
277 | /// Returns the next Reg Header present | |
278 | ||
279 | assert( fCurrentDarcHeader != 0 ); | |
280 | assert( fCurrentDDL != 0 ); | |
281 | ||
282 | fCurrentRegHeader = 0; | |
283 | ||
284 | Int_t i = fCurrentRegHeaderIndex; | |
285 | ||
286 | while ( fCurrentRegHeader == 0 && i < fCurrentDarcHeader->GetRegHeaderEntries()-1 ) | |
287 | { | |
288 | ++i; | |
289 | fCurrentRegHeader = fCurrentDarcHeader->GetRegHeaderEntry(i); | |
290 | } | |
291 | ||
292 | if ( !fCurrentRegHeader ) | |
293 | { | |
294 | Bool_t ok = GetNextDDL(); | |
295 | if (!ok) | |
296 | { | |
297 | return kFALSE; | |
298 | } | |
299 | else | |
300 | { | |
301 | return GetNextRegHeader(); | |
302 | } | |
303 | } | |
304 | ||
305 | fCurrentRegHeaderIndex = i; | |
306 | ||
307 | fCurrentLocalStructIndex = -1; | |
308 | ||
309 | return kTRUE; | |
310 | } | |
311 | ||
312 | //______________________________________________________ | |
313 | Bool_t AliMUONRawStreamTrigger::GetNextLocalStruct() | |
314 | { | |
315 | /// Find the next non-empty local structure | |
316 | ||
317 | assert( fCurrentRegHeader != 0 ); | |
318 | ||
319 | fCurrentLocalStruct = 0; | |
320 | ||
321 | Int_t i = fCurrentLocalStructIndex; | |
322 | ||
323 | while ( fCurrentLocalStruct == 0 && i < fCurrentRegHeader->GetLocalEntries()-1 ) | |
324 | { | |
325 | ++i; | |
326 | fCurrentLocalStruct = fCurrentRegHeader->GetLocalEntry(i); | |
327 | } | |
328 | ||
329 | if ( !fCurrentLocalStruct ) | |
330 | { | |
331 | Bool_t ok = GetNextRegHeader(); | |
332 | if (!ok) | |
333 | { | |
334 | return kFALSE; | |
335 | } | |
336 | else | |
337 | { | |
338 | return GetNextLocalStruct(); | |
339 | } | |
340 | } | |
341 | ||
342 | fCurrentLocalStructIndex = i; | |
343 | ||
344 | fLocalStructRead = kFALSE; | |
345 | ||
346 | return kTRUE; | |
972432c1 | 347 | } |
348 | ||
349 | //______________________________________________________ | |
350 | Bool_t AliMUONRawStreamTrigger::NextDDL() | |
351 | { | |
00e86732 | 352 | /// reading tracker DDL |
b921196a | 353 | /// store local info into Array |
354 | /// store only non-empty structures | |
972432c1 | 355 | |
972432c1 | 356 | // reset TClones |
313a427d | 357 | fPayload->ResetDDL(); |
358 | ||
972432c1 | 359 | |
360 | // loop over the two ddl's | |
07a5b6b7 | 361 | |
36f90a1a | 362 | while ( fDDL < fgkMaxDDL ) { |
b921196a | 363 | GetReader()->Reset(); |
364 | GetReader()->Select("MUONTRG", fDDL, fDDL); //Select the DDL file to be read | |
365 | if (GetReader()->ReadHeader()) break; | |
07a5b6b7 | 366 | AliDebug(3,Form("Skipping DDL %d which does not seem to be there",fDDL)); |
367 | ++fDDL; | |
368 | } | |
369 | ||
36f90a1a | 370 | if (fDDL >= fgkMaxDDL) { |
972432c1 | 371 | fDDL = 0; |
6817de1c | 372 | if (IsErrorLogger()) AddErrorMessage(); |
972432c1 | 373 | return kFALSE; |
374 | } | |
9e378ff4 | 375 | |
07a5b6b7 | 376 | AliDebug(3, Form("DDL Number %d\n", fDDL )); |
972432c1 | 377 | |
b921196a | 378 | Int_t totalDataWord = GetReader()->GetDataSize(); // in bytes |
07a5b6b7 | 379 | |
24b5e881 | 380 | Bool_t scalerEvent = GetReader()->GetDataHeader() && GetReader()->GetDataHeader()->GetL1TriggerMessage() & 0x1; |
f4ee80d2 | 381 | |
382 | ||
972432c1 | 383 | UInt_t *buffer = new UInt_t[totalDataWord/4]; |
384 | ||
d6ac560d | 385 | // check not necessary yet, but for future developments |
b921196a | 386 | if (!GetReader()->ReadNext((UChar_t*)buffer, totalDataWord)) return kFALSE; |
972432c1 | 387 | |
47c48013 | 388 | #ifndef R__BYTESWAP |
389 | Swap(buffer, totalDataWord / sizeof(UInt_t)); // swap needed for mac power pc | |
b921196a | 390 | #endif |
391 | ||
f4ee80d2 | 392 | fPayload->Decode(buffer, scalerEvent); |
6817de1c | 393 | |
972432c1 | 394 | |
313a427d | 395 | fDDL++; |
972432c1 | 396 | |
972432c1 | 397 | delete [] buffer; |
398 | ||
ea59383d | 399 | |
972432c1 | 400 | return kTRUE; |
401 | } | |
402 | ||
bfbfa5da | 403 | // //______________________________________________________ |
404 | // void AliMUONRawStreamTrigger::SetMaxReg(Int_t reg) | |
405 | // { | |
406 | // /// set regional card number | |
407 | // fPayload->SetMaxReg(reg); | |
408 | // } | |
972432c1 | 409 | |
410 | //______________________________________________________ | |
411 | void AliMUONRawStreamTrigger::SetMaxLoc(Int_t loc) | |
412 | { | |
00e86732 | 413 | /// set local card number |
313a427d | 414 | fPayload->SetMaxLoc(loc); |
972432c1 | 415 | } |
ea59383d | 416 | |
417 | //______________________________________________________ | |
418 | void AliMUONRawStreamTrigger::AddErrorMessage() | |
419 | { | |
420 | /// add message into logger of AliRawReader per event | |
421 | ||
9b4aee57 | 422 | TString msg; |
b921196a | 423 | Int_t occurance = 0; |
424 | AliMUONLogger* log = fPayload->GetErrorLogger(); | |
425 | ||
426 | log->ResetItr(); | |
427 | while(log->Next(msg, occurance)) | |
428 | { | |
429 | if (msg.Contains("Darc")) | |
430 | GetReader()->AddMajorErrorLog(kDarcEoWErr, msg.Data()); | |
ea59383d | 431 | |
b921196a | 432 | if (msg.Contains("Global")) |
433 | GetReader()->AddMajorErrorLog(kGlobalEoWErr, msg.Data()); | |
ea59383d | 434 | |
b921196a | 435 | if (msg.Contains("Regional")) |
436 | GetReader()->AddMajorErrorLog(kRegEoWErr, msg.Data()); | |
ea59383d | 437 | |
b921196a | 438 | if (msg.Contains("Local")) |
439 | GetReader()->AddMajorErrorLog(kLocalEoWErr, msg.Data()); | |
440 | } | |
6817de1c | 441 | |
442 | log->Clear(); // clear after each event | |
ea59383d | 443 | } |