]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/trigger/AliHLTReadoutList.cxx
Removal of no longer maintained neural trackers
[u/mrichter/AliRoot.git] / HLT / trigger / AliHLTReadoutList.cxx
CommitLineData
dce3e5ce 1/**************************************************************************
2 * This file is property of and copyright by the ALICE HLT Project *
3 * ALICE Experiment at CERN, All rights reserved. *
4 * *
5 * Primary Authors: Artur Szostak <artursz@iafrica.com> *
6 * for The ALICE HLT Project. *
7 * *
8 * Permission to use, copy, modify and distribute this software and its *
9 * documentation strictly for non-commercial purposes is hereby granted *
10 * without fee, provided that the above copyright notice appears in all *
11 * copies and that both the copyright notice and this permission notice *
12 * appear in the supporting documentation. The authors make no claims *
13 * about the suitability of this software for any purpose. It is *
14 * provided "as is" without express or implied warranty. *
15 **************************************************************************/
16
17/// @file AliHLTReadoutList.cxx
18/// @author Artur Szostak <artursz@iafrica.com>
19/// @date 19 Nov 2008
20/// @brief Implementation of the AliHLTReadoutList class.
21///
22/// The AliHLTReadoutList class is used as an interface to the AliHLTEventDDL
23/// structure. It makes it easy to manipulate the bits in this structure, which
24/// define what DDLs should be readout by DAQ.
25/// Several operators are also overloaded which are meant to be used in the trigger
26/// menu specification for the AliHLTGlobalTrigger. It allows one to construct
27/// expressions for the readout lists, which is necessary to be able to evaluate
28/// or compose the final readout list, given multiple input readout lists received
29/// from individual components that derive from AliHLTTrigger.
30
31#include "AliHLTReadoutList.h"
32#include "AliDAQ.h"
33#include "Riostream.h"
34#include "TString.h"
35#include "TObjString.h"
36#include "TObjArray.h"
37#include <cassert>
38
39ClassImp(AliHLTReadoutList)
40
41
42AliHLTReadoutList::AliHLTReadoutList() :
43 TObject(),
44 fReadoutList()
45{
46 // Default constructor.
47
48 fReadoutList.fCount = gkAliHLTDDLListSize; // Required by ALICE-INT-2007-015
49 memset(fReadoutList.fList, 0x0, sizeof(fReadoutList.fList));
50}
51
52
53AliHLTReadoutList::AliHLTReadoutList(Int_t enabledDetectors) :
54 TObject(),
55 fReadoutList()
56{
57 // Constructor to select which detectors to enable for readout.
58 // See header file for more details.
59
60 fReadoutList.fCount = gkAliHLTDDLListSize; // Required by ALICE-INT-2007-015
61 memset(fReadoutList.fList, 0x0, sizeof(fReadoutList.fList));
62 Enable(enabledDetectors);
63}
64
65
66AliHLTReadoutList::AliHLTReadoutList(const char* enabledList) :
67 TObject(),
68 fReadoutList()
69{
70 // Constructor to select which detectors and DDLs to enable for readout.
71 // See header file for more details.
72
73 fReadoutList.fCount = gkAliHLTDDLListSize; // Required by ALICE-INT-2007-015
74 memset(fReadoutList.fList, 0x0, sizeof(fReadoutList.fList));
75
76 TString str(enabledList);
77 str.ToUpper();
78 Int_t enabledDetectors = 0;
79 if (str.Contains("ITSSPD")) enabledDetectors |= kITSSPD;
80 if (str.Contains("ITSSDD")) enabledDetectors |= kITSSDD;
81 if (str.Contains("ITSSSD")) enabledDetectors |= kITSSSD;
82 if (str.Contains("TPC")) enabledDetectors |= kTPC;
83 if (str.Contains("TRD")) enabledDetectors |= kTRD;
84 if (str.Contains("TOF")) enabledDetectors |= kTOF;
85 if (str.Contains("HMPID")) enabledDetectors |= kHMPID;
86 if (str.Contains("PHOS")) enabledDetectors |= kPHOS;
87 if (str.Contains("CPV")) enabledDetectors |= kCPV;
88 if (str.Contains("PMD")) enabledDetectors |= kPMD;
89 if (str.Contains("MUONTRK")) enabledDetectors |= kMUONTRK;
90 if (str.Contains("MUONTRG")) enabledDetectors |= kMUONTRG;
91 if (str.Contains("FMD")) enabledDetectors |= kFMD;
92 if (str.Contains("T0")) enabledDetectors |= kT0;
93 if (str.Contains("V0")) enabledDetectors |= kV0;
94 if (str.Contains("ZDC")) enabledDetectors |= kZDC;
95 if (str.Contains("ACORDE")) enabledDetectors |= kACORDE;
96 if (str.Contains("TRG")) enabledDetectors |= kTRG;
97 if (str.Contains("EMCAL")) enabledDetectors |= kEMCAL;
98 if (str.Contains("DAQTEST")) enabledDetectors |= kDAQTEST;
99 if (str.Contains("HLT")) enabledDetectors |= kHLT;
100 if (str.Contains("ALL")) enabledDetectors |= kALLDET;
101 Enable(enabledDetectors);
102
103 TObjArray* list = str.Tokenize(" ");
104 TIter next(list);
105 const TObjString* objstr = NULL;
106 while ((objstr = dynamic_cast<const TObjString*>(next())) != NULL)
107 {
108 str = objstr->GetString();
109 if (str.IsDigit()) EnableDDLBit(str.Atoi());
110 }
111 delete list;
112}
113
114
115AliHLTReadoutList::AliHLTReadoutList(const AliHLTEventDDL& list) :
116 TObject(),
117 fReadoutList()
118{
119 // Constructor to create readout list from AliHLTEventDDL structure.
120 // See header file for more details.
121
122 memcpy(&fReadoutList, &list, sizeof(fReadoutList));
123}
124
125
126AliHLTReadoutList::AliHLTReadoutList(const AliHLTReadoutList& list) :
127 TObject(list),
128 fReadoutList()
129{
130 // Copy constructor performs a deep copy.
131
132 memcpy(&fReadoutList, &list.fReadoutList, sizeof(fReadoutList));
133}
134
135
136AliHLTReadoutList::~AliHLTReadoutList()
137{
138 // Default destructor.
139}
140
141
8b745301 142bool AliHLTReadoutList::Empty() const
143{
144 // Returns true if the readout list has no DDLs enabled.
145
146 for (int i = 0; i < sizeof(fReadoutList.fList) / sizeof(fReadoutList.fList[0]); i++)
147 {
148 if (fReadoutList.fList[i] != 0x0) return false;
149 }
150 return true;
151}
152
153
dce3e5ce 154bool AliHLTReadoutList::DecodeDDLID(Int_t ddlId, Int_t& wordIndex, Int_t& bitIndex)
155{
156 // Decodes the word index and bit index within that word for the readout list structure.
157 // See header file for more details.
158
159 // The detector number is bits 15..8 of ddlId and DDL number is bits 7..0.
160 Int_t detNum = ddlId >> 8;
161 Int_t ddlNum = ddlId & 0xFF;
162
163 if (detNum < 3)
164 {
165 wordIndex = detNum;
166 }
167 else if (detNum == 3)
168 {
169 wordIndex = detNum + (ddlNum >> 5);
170 }
171 else if (detNum == 4)
172 {
173 wordIndex = detNum + 7;
174 }
175 else if (detNum == 5)
176 {
177 wordIndex = detNum + 7 + (ddlNum >> 5);
178 }
179 else if (detNum == 30)
180 {
181 wordIndex = 29;
182 }
183 else
184 {
185 wordIndex = detNum + 9;
186 }
187
188 if (wordIndex < 0 or gkAliHLTDDLListSize <= wordIndex) return false;
189
190 // The bit index within the word indicated by wordIndex.
191 bitIndex = (ddlId & 0xFF) % 32;
192 return true;
193}
194
195
196Bool_t AliHLTReadoutList::GetDDLBit(Int_t ddlId) const
197{
198 // Fetches the bit value for a particular DDL in the readout list.
199 // See header file for more details.
200
201 Int_t wordIndex, bitIndex;
202 if (! DecodeDDLID(ddlId, wordIndex, bitIndex)) return kFALSE;
203 return ((fReadoutList.fList[wordIndex] >> bitIndex) & 0x1) == 0x1;
204}
205
206
207void AliHLTReadoutList::SetDDLBit(Int_t ddlId, Bool_t state)
208{
209 // Sets the bit value for a particular DDL in the readout list.
210 // See header file for more details.
211
212 Int_t wordIndex, bitIndex;
213 if (! DecodeDDLID(ddlId, wordIndex, bitIndex)) return;
214
215 // To set, 'OR' word with bit mask
216 if ( state )
217 fReadoutList.fList[wordIndex] |= (0x00000001 << bitIndex);
218 // To unset, 'AND' word with bit mask
219 else
220 fReadoutList.fList[wordIndex] &= (0xFFFFFFFF ^ (0x00000001 << bitIndex));
221}
222
223
224void AliHLTReadoutList::Enable(Int_t detector)
225{
226 // Enables all DDLs for a particular detector or detectors.
227 // See header file for more details.
228
229 if ((detector & kITSSPD) != 0) fReadoutList.fList[0] = 0x000FFFFF;
230 if ((detector & kITSSDD) != 0) fReadoutList.fList[1] = 0x00FFFFFF;
231 if ((detector & kITSSSD) != 0) fReadoutList.fList[2] = 0x0000FFFF;
232 if ((detector & kTPC) != 0)
233 {
234 fReadoutList.fList[3] = 0xFFFFFFFF;
235 fReadoutList.fList[4] = 0xFFFFFFFF;
236 fReadoutList.fList[5] = 0xFFFFFFFF;
237 fReadoutList.fList[6] = 0xFFFFFFFF;
238 fReadoutList.fList[7] = 0xFFFFFFFF;
239 fReadoutList.fList[8] = 0xFFFFFFFF;
240 fReadoutList.fList[9] = 0x00FFFFFF;
241 fReadoutList.fList[10] = 0x00000000;
242 }
243 if ((detector & kTRD) != 0) fReadoutList.fList[11] = 0x0003FFFF;
244 if ((detector & kTOF) != 0)
245 {
246 fReadoutList.fList[12] = 0xFFFFFFFF;
247 fReadoutList.fList[13] = 0xFFFFFFFF;
248 fReadoutList.fList[14] = 0x000000FF;
249 }
250 if ((detector & kHMPID) != 0) fReadoutList.fList[15] = 0x00003FFF;
251 if ((detector & kPHOS) != 0) fReadoutList.fList[16] = 0x000FFFFF;
252 if ((detector & kCPV) != 0) fReadoutList.fList[17] = 0x000003FF;
253 if ((detector & kPMD) != 0) fReadoutList.fList[18] = 0x0000003F;
254 if ((detector & kMUONTRK) != 0) fReadoutList.fList[19] = 0x000FFFFF;
255 if ((detector & kMUONTRG) != 0) fReadoutList.fList[20] = 0x00000003;
256 if ((detector & kFMD) != 0) fReadoutList.fList[21] = 0x00000007;
257 if ((detector & kT0) != 0) fReadoutList.fList[22] = 0x00000001;
258 if ((detector & kV0) != 0) fReadoutList.fList[23] = 0x00000001;
259 if ((detector & kZDC) != 0) fReadoutList.fList[24] = 0x00000001;
260 if ((detector & kACORDE) != 0) fReadoutList.fList[25] = 0x00000001;
261 if ((detector & kTRG) != 0) fReadoutList.fList[26] = 0x00000001;
262 if ((detector & kEMCAL) != 0) fReadoutList.fList[27] = 0x00FFFFFF;
263 if ((detector & kDAQTEST) != 0) fReadoutList.fList[28] = 0x00000001;
264 if ((detector & kHLT) != 0) fReadoutList.fList[29] = 0x000003FF;
265}
266
267
268void AliHLTReadoutList::Disable(Int_t detector)
269{
270 // Disables all DDLs for a particular detector or detectors.
271 // See header file for more details.
272
273 if ((detector & kITSSPD) != 0) fReadoutList.fList[0] = 0x00000000;
274 if ((detector & kITSSDD) != 0) fReadoutList.fList[1] = 0x00000000;
275 if ((detector & kITSSSD) != 0) fReadoutList.fList[2] = 0x00000000;
276 if ((detector & kTPC) != 0)
277 {
278 fReadoutList.fList[3] = 0x00000000;
279 fReadoutList.fList[4] = 0x00000000;
280 fReadoutList.fList[5] = 0x00000000;
281 fReadoutList.fList[6] = 0x00000000;
282 fReadoutList.fList[7] = 0x00000000;
283 fReadoutList.fList[8] = 0x00000000;
284 fReadoutList.fList[9] = 0x00000000;
285 fReadoutList.fList[10] = 0x00000000;
286 }
287 if ((detector & kTRD) != 0) fReadoutList.fList[11] = 0x00000000;
288 if ((detector & kTOF) != 0)
289 {
290 fReadoutList.fList[12] = 0x00000000;
291 fReadoutList.fList[13] = 0x00000000;
292 fReadoutList.fList[14] = 0x00000000;
293 }
294 if ((detector & kHMPID) != 0) fReadoutList.fList[15] = 0x00000000;
295 if ((detector & kPHOS) != 0) fReadoutList.fList[16] = 0x00000000;
296 if ((detector & kCPV) != 0) fReadoutList.fList[17] = 0x00000000;
297 if ((detector & kPMD) != 0) fReadoutList.fList[18] = 0x00000000;
298 if ((detector & kMUONTRK) != 0) fReadoutList.fList[19] = 0x00000000;
299 if ((detector & kMUONTRG) != 0) fReadoutList.fList[20] = 0x00000000;
300 if ((detector & kFMD) != 0) fReadoutList.fList[21] = 0x00000000;
301 if ((detector & kT0) != 0) fReadoutList.fList[22] = 0x00000000;
302 if ((detector & kV0) != 0) fReadoutList.fList[23] = 0x00000000;
303 if ((detector & kZDC) != 0) fReadoutList.fList[24] = 0x00000000;
304 if ((detector & kACORDE) != 0) fReadoutList.fList[25] = 0x00000000;
305 if ((detector & kTRG) != 0) fReadoutList.fList[26] = 0x00000000;
306 if ((detector & kEMCAL) != 0) fReadoutList.fList[27] = 0x00000000;
307 if ((detector & kDAQTEST) != 0) fReadoutList.fList[28] = 0x00000000;
308 if ((detector & kHLT) != 0) fReadoutList.fList[29] = 0x00000000;
309}
310
311
52f67e50 312bool AliHLTReadoutList::DetectorEnabled(Int_t detector) const
313{
314 // Checks if a particular detector's DDLs are enabled.
315 // See header file for more details.
316
317 bool result = true;
318 if ((detector & kITSSPD) != 0) result &= fReadoutList.fList[0] == 0x000FFFFF;
319 if ((detector & kITSSDD) != 0) result &= fReadoutList.fList[1] == 0x00FFFFFF;
320 if ((detector & kITSSSD) != 0) result &= fReadoutList.fList[2] == 0x0000FFFF;
321 if ((detector & kTPC) != 0)
322 {
323 result &= fReadoutList.fList[3] == 0xFFFFFFFF;
324 result &= fReadoutList.fList[4] == 0xFFFFFFFF;
325 result &= fReadoutList.fList[5] == 0xFFFFFFFF;
326 result &= fReadoutList.fList[6] == 0xFFFFFFFF;
327 result &= fReadoutList.fList[7] == 0xFFFFFFFF;
328 result &= fReadoutList.fList[8] == 0xFFFFFFFF;
329 result &= fReadoutList.fList[9] == 0x00FFFFFF;
330 }
331 if ((detector & kTRD) != 0) result &= fReadoutList.fList[11] == 0x0003FFFF;
332 if ((detector & kTOF) != 0)
333 {
334 result &= fReadoutList.fList[12] == 0xFFFFFFFF;
335 result &= fReadoutList.fList[13] == 0xFFFFFFFF;
336 result &= fReadoutList.fList[14] == 0x000000FF;
337 }
338 if ((detector & kHMPID) != 0) result &= fReadoutList.fList[15] == 0x00003FFF;
339 if ((detector & kPHOS) != 0) result &= fReadoutList.fList[16] == 0x000FFFFF;
340 if ((detector & kCPV) != 0) result &= fReadoutList.fList[17] == 0x000003FF;
341 if ((detector & kPMD) != 0) result &= fReadoutList.fList[18] == 0x0000003F;
342 if ((detector & kMUONTRK) != 0) result &= fReadoutList.fList[19] == 0x000FFFFF;
343 if ((detector & kMUONTRG) != 0) result &= fReadoutList.fList[20] == 0x00000003;
344 if ((detector & kFMD) != 0) result &= fReadoutList.fList[21] == 0x00000007;
345 if ((detector & kT0) != 0) result &= fReadoutList.fList[22] == 0x00000001;
346 if ((detector & kV0) != 0) result &= fReadoutList.fList[23] == 0x00000001;
347 if ((detector & kZDC) != 0) result &= fReadoutList.fList[24] == 0x00000001;
348 if ((detector & kACORDE) != 0) result &= fReadoutList.fList[25] == 0x00000001;
349 if ((detector & kTRG) != 0) result &= fReadoutList.fList[26] == 0x00000001;
350 if ((detector & kEMCAL) != 0) result &= fReadoutList.fList[27] == 0x00FFFFFF;
351 if ((detector & kDAQTEST) != 0) result &= fReadoutList.fList[28] == 0x00000001;
352 if ((detector & kHLT) != 0) result &= fReadoutList.fList[29] == 0x000003FF;
353
354 return result;
355}
356
357
dce3e5ce 358void AliHLTReadoutList::Print(Option_t* /*option*/) const
359{
360 // Prints the DDLs that will be readout according to this readout list.
361
362 cout << "Readout enabled for DDLs:" << endl;
363 for (Int_t i = 0; i < AliDAQ::kNDetectors; i++)
364 {
365 Int_t maxddls = AliDAQ::NumberOfDdls(i);
366 cout << AliDAQ::DetectorName(i) << ":";
367 bool nonefound = true;
368 for (Int_t j = 0; j < maxddls; j++)
369 {
370 Int_t ddlId = ( ((i == AliDAQ::kNDetectors-1) ? 30 : i) << 8 ) + j;
371 if (GetDDLBit(ddlId))
372 {
373 cout << " " << ddlId;
374 nonefound = false;
375 }
376 }
377 if (nonefound) cout << " none";
378 cout << endl;
379 }
380}
381
382
383AliHLTReadoutList& AliHLTReadoutList::operator = (const AliHLTReadoutList& list)
384{
385 // Assignment operator performs a deep copy.
386
387 TObject::operator = (list);
388 if (&list != this)
389 {
390 memcpy(&fReadoutList, &list.fReadoutList, sizeof(fReadoutList));
391 }
392 return *this;
393}
394
395
396AliHLTReadoutList& AliHLTReadoutList::operator |= (const AliHLTReadoutList& list)
397{
398 // This operator performs a bitwise inclusive or operation on all DDL bits.
399 // See header file for more details.
400
401 assert( fReadoutList.fCount == gkAliHLTDDLListSize );
402 for (Int_t i = 0; i < gkAliHLTDDLListSize; i++)
403 {
404 fReadoutList.fList[i] |= list.fReadoutList.fList[i];
405 }
406 return *this;
407}
408
409
410AliHLTReadoutList& AliHLTReadoutList::operator ^= (const AliHLTReadoutList& list)
411{
412 // This operator performs a bitwise exclusive or (xor) operation on all DDL bits.
413 // See header file for more details.
414
415 assert( fReadoutList.fCount == gkAliHLTDDLListSize );
416 for (Int_t i = 0; i < gkAliHLTDDLListSize; i++)
417 {
418 fReadoutList.fList[i] ^= list.fReadoutList.fList[i];
419 }
420 return *this;
421}
422
423
424AliHLTReadoutList& AliHLTReadoutList::operator &= (const AliHLTReadoutList& list)
425{
426 // This operator performs a bitwise and operation on all DDL bits.
427 // See header file for more details.
428
429 assert( fReadoutList.fCount == gkAliHLTDDLListSize );
430 for (Int_t i = 0; i < gkAliHLTDDLListSize; i++)
431 {
432 fReadoutList.fList[i] &= list.fReadoutList.fList[i];
433 }
434 return *this;
435}
436
437
438AliHLTReadoutList& AliHLTReadoutList::operator -= (const AliHLTReadoutList& list)
439{
440 // This operator removes all the DDLs specified in list from this readout list.
441 // See header file for more details.
442
443 assert( fReadoutList.fCount == gkAliHLTDDLListSize );
444 for (Int_t i = 0; i < gkAliHLTDDLListSize; i++)
445 {
446 // Effectively apply: this = this & (~ (this & list))
447 // i.e. this = this & (this ^ list)
448 fReadoutList.fList[i] &= fReadoutList.fList[i] ^ list.fReadoutList.fList[i];
449 }
450 return *this;
451}
452
453
454AliHLTReadoutList AliHLTReadoutList::operator ~ () const
455{
456 // This operator performs a bitwise ones compliment on all DDL bits.
457 // See header file for more details.
458
459 AliHLTReadoutList readoutlist;
460 readoutlist.fReadoutList.fCount = fReadoutList.fCount;
461 readoutlist.fReadoutList.fList[0] = 0x000FFFFF & (~fReadoutList.fList[0]);
462 readoutlist.fReadoutList.fList[1] = 0x00FFFFFF & (~fReadoutList.fList[1]);
463 readoutlist.fReadoutList.fList[2] = 0x0000FFFF & (~fReadoutList.fList[2]);
464 readoutlist.fReadoutList.fList[3] = 0xFFFFFFFF & (~fReadoutList.fList[3]);
465 readoutlist.fReadoutList.fList[4] = 0xFFFFFFFF & (~fReadoutList.fList[4]);
466 readoutlist.fReadoutList.fList[5] = 0xFFFFFFFF & (~fReadoutList.fList[5]);
467 readoutlist.fReadoutList.fList[6] = 0xFFFFFFFF & (~fReadoutList.fList[6]);
468 readoutlist.fReadoutList.fList[7] = 0xFFFFFFFF & (~fReadoutList.fList[7]);
469 readoutlist.fReadoutList.fList[8] = 0xFFFFFFFF & (~fReadoutList.fList[8]);
470 readoutlist.fReadoutList.fList[9] = 0x00FFFFFF & (~fReadoutList.fList[9]);
471 readoutlist.fReadoutList.fList[10] = 0x00000000 & (~fReadoutList.fList[10]);
472 readoutlist.fReadoutList.fList[11] = 0x0003FFFF & (~fReadoutList.fList[11]);
473 readoutlist.fReadoutList.fList[12] = 0xFFFFFFFF & (~fReadoutList.fList[12]);
474 readoutlist.fReadoutList.fList[13] = 0xFFFFFFFF & (~fReadoutList.fList[13]);
475 readoutlist.fReadoutList.fList[14] = 0x000000FF & (~fReadoutList.fList[14]);
476 readoutlist.fReadoutList.fList[15] = 0x00003FFF & (~fReadoutList.fList[15]);
477 readoutlist.fReadoutList.fList[16] = 0x000FFFFF & (~fReadoutList.fList[16]);
478 readoutlist.fReadoutList.fList[17] = 0x000003FF & (~fReadoutList.fList[17]);
479 readoutlist.fReadoutList.fList[18] = 0x0000003F & (~fReadoutList.fList[18]);
480 readoutlist.fReadoutList.fList[19] = 0x000FFFFF & (~fReadoutList.fList[19]);
481 readoutlist.fReadoutList.fList[20] = 0x00000003 & (~fReadoutList.fList[20]);
482 readoutlist.fReadoutList.fList[21] = 0x00000007 & (~fReadoutList.fList[21]);
483 readoutlist.fReadoutList.fList[22] = 0x00000001 & (~fReadoutList.fList[22]);
484 readoutlist.fReadoutList.fList[23] = 0x00000001 & (~fReadoutList.fList[23]);
485 readoutlist.fReadoutList.fList[24] = 0x00000001 & (~fReadoutList.fList[24]);
486 readoutlist.fReadoutList.fList[25] = 0x00000001 & (~fReadoutList.fList[25]);
487 readoutlist.fReadoutList.fList[26] = 0x00000001 & (~fReadoutList.fList[26]);
488 readoutlist.fReadoutList.fList[27] = 0x00FFFFFF & (~fReadoutList.fList[27]);
489 readoutlist.fReadoutList.fList[28] = 0x00000001 & (~fReadoutList.fList[28]);
490 readoutlist.fReadoutList.fList[29] = 0x000003FF & (~fReadoutList.fList[29]);
491 return readoutlist;
492}
493