]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/trigger/AliHLTReadoutList.cxx
Adding custom linkdef file so that dictionaries are correctly generated for AliHLTTri...
[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
142bool AliHLTReadoutList::DecodeDDLID(Int_t ddlId, Int_t& wordIndex, Int_t& bitIndex)
143{
144 // Decodes the word index and bit index within that word for the readout list structure.
145 // See header file for more details.
146
147 // The detector number is bits 15..8 of ddlId and DDL number is bits 7..0.
148 Int_t detNum = ddlId >> 8;
149 Int_t ddlNum = ddlId & 0xFF;
150
151 if (detNum < 3)
152 {
153 wordIndex = detNum;
154 }
155 else if (detNum == 3)
156 {
157 wordIndex = detNum + (ddlNum >> 5);
158 }
159 else if (detNum == 4)
160 {
161 wordIndex = detNum + 7;
162 }
163 else if (detNum == 5)
164 {
165 wordIndex = detNum + 7 + (ddlNum >> 5);
166 }
167 else if (detNum == 30)
168 {
169 wordIndex = 29;
170 }
171 else
172 {
173 wordIndex = detNum + 9;
174 }
175
176 if (wordIndex < 0 or gkAliHLTDDLListSize <= wordIndex) return false;
177
178 // The bit index within the word indicated by wordIndex.
179 bitIndex = (ddlId & 0xFF) % 32;
180 return true;
181}
182
183
184Bool_t AliHLTReadoutList::GetDDLBit(Int_t ddlId) const
185{
186 // Fetches the bit value for a particular DDL in the readout list.
187 // See header file for more details.
188
189 Int_t wordIndex, bitIndex;
190 if (! DecodeDDLID(ddlId, wordIndex, bitIndex)) return kFALSE;
191 return ((fReadoutList.fList[wordIndex] >> bitIndex) & 0x1) == 0x1;
192}
193
194
195void AliHLTReadoutList::SetDDLBit(Int_t ddlId, Bool_t state)
196{
197 // Sets the bit value for a particular DDL in the readout list.
198 // See header file for more details.
199
200 Int_t wordIndex, bitIndex;
201 if (! DecodeDDLID(ddlId, wordIndex, bitIndex)) return;
202
203 // To set, 'OR' word with bit mask
204 if ( state )
205 fReadoutList.fList[wordIndex] |= (0x00000001 << bitIndex);
206 // To unset, 'AND' word with bit mask
207 else
208 fReadoutList.fList[wordIndex] &= (0xFFFFFFFF ^ (0x00000001 << bitIndex));
209}
210
211
212void AliHLTReadoutList::Enable(Int_t detector)
213{
214 // Enables all DDLs for a particular detector or detectors.
215 // See header file for more details.
216
217 if ((detector & kITSSPD) != 0) fReadoutList.fList[0] = 0x000FFFFF;
218 if ((detector & kITSSDD) != 0) fReadoutList.fList[1] = 0x00FFFFFF;
219 if ((detector & kITSSSD) != 0) fReadoutList.fList[2] = 0x0000FFFF;
220 if ((detector & kTPC) != 0)
221 {
222 fReadoutList.fList[3] = 0xFFFFFFFF;
223 fReadoutList.fList[4] = 0xFFFFFFFF;
224 fReadoutList.fList[5] = 0xFFFFFFFF;
225 fReadoutList.fList[6] = 0xFFFFFFFF;
226 fReadoutList.fList[7] = 0xFFFFFFFF;
227 fReadoutList.fList[8] = 0xFFFFFFFF;
228 fReadoutList.fList[9] = 0x00FFFFFF;
229 fReadoutList.fList[10] = 0x00000000;
230 }
231 if ((detector & kTRD) != 0) fReadoutList.fList[11] = 0x0003FFFF;
232 if ((detector & kTOF) != 0)
233 {
234 fReadoutList.fList[12] = 0xFFFFFFFF;
235 fReadoutList.fList[13] = 0xFFFFFFFF;
236 fReadoutList.fList[14] = 0x000000FF;
237 }
238 if ((detector & kHMPID) != 0) fReadoutList.fList[15] = 0x00003FFF;
239 if ((detector & kPHOS) != 0) fReadoutList.fList[16] = 0x000FFFFF;
240 if ((detector & kCPV) != 0) fReadoutList.fList[17] = 0x000003FF;
241 if ((detector & kPMD) != 0) fReadoutList.fList[18] = 0x0000003F;
242 if ((detector & kMUONTRK) != 0) fReadoutList.fList[19] = 0x000FFFFF;
243 if ((detector & kMUONTRG) != 0) fReadoutList.fList[20] = 0x00000003;
244 if ((detector & kFMD) != 0) fReadoutList.fList[21] = 0x00000007;
245 if ((detector & kT0) != 0) fReadoutList.fList[22] = 0x00000001;
246 if ((detector & kV0) != 0) fReadoutList.fList[23] = 0x00000001;
247 if ((detector & kZDC) != 0) fReadoutList.fList[24] = 0x00000001;
248 if ((detector & kACORDE) != 0) fReadoutList.fList[25] = 0x00000001;
249 if ((detector & kTRG) != 0) fReadoutList.fList[26] = 0x00000001;
250 if ((detector & kEMCAL) != 0) fReadoutList.fList[27] = 0x00FFFFFF;
251 if ((detector & kDAQTEST) != 0) fReadoutList.fList[28] = 0x00000001;
252 if ((detector & kHLT) != 0) fReadoutList.fList[29] = 0x000003FF;
253}
254
255
256void AliHLTReadoutList::Disable(Int_t detector)
257{
258 // Disables all DDLs for a particular detector or detectors.
259 // See header file for more details.
260
261 if ((detector & kITSSPD) != 0) fReadoutList.fList[0] = 0x00000000;
262 if ((detector & kITSSDD) != 0) fReadoutList.fList[1] = 0x00000000;
263 if ((detector & kITSSSD) != 0) fReadoutList.fList[2] = 0x00000000;
264 if ((detector & kTPC) != 0)
265 {
266 fReadoutList.fList[3] = 0x00000000;
267 fReadoutList.fList[4] = 0x00000000;
268 fReadoutList.fList[5] = 0x00000000;
269 fReadoutList.fList[6] = 0x00000000;
270 fReadoutList.fList[7] = 0x00000000;
271 fReadoutList.fList[8] = 0x00000000;
272 fReadoutList.fList[9] = 0x00000000;
273 fReadoutList.fList[10] = 0x00000000;
274 }
275 if ((detector & kTRD) != 0) fReadoutList.fList[11] = 0x00000000;
276 if ((detector & kTOF) != 0)
277 {
278 fReadoutList.fList[12] = 0x00000000;
279 fReadoutList.fList[13] = 0x00000000;
280 fReadoutList.fList[14] = 0x00000000;
281 }
282 if ((detector & kHMPID) != 0) fReadoutList.fList[15] = 0x00000000;
283 if ((detector & kPHOS) != 0) fReadoutList.fList[16] = 0x00000000;
284 if ((detector & kCPV) != 0) fReadoutList.fList[17] = 0x00000000;
285 if ((detector & kPMD) != 0) fReadoutList.fList[18] = 0x00000000;
286 if ((detector & kMUONTRK) != 0) fReadoutList.fList[19] = 0x00000000;
287 if ((detector & kMUONTRG) != 0) fReadoutList.fList[20] = 0x00000000;
288 if ((detector & kFMD) != 0) fReadoutList.fList[21] = 0x00000000;
289 if ((detector & kT0) != 0) fReadoutList.fList[22] = 0x00000000;
290 if ((detector & kV0) != 0) fReadoutList.fList[23] = 0x00000000;
291 if ((detector & kZDC) != 0) fReadoutList.fList[24] = 0x00000000;
292 if ((detector & kACORDE) != 0) fReadoutList.fList[25] = 0x00000000;
293 if ((detector & kTRG) != 0) fReadoutList.fList[26] = 0x00000000;
294 if ((detector & kEMCAL) != 0) fReadoutList.fList[27] = 0x00000000;
295 if ((detector & kDAQTEST) != 0) fReadoutList.fList[28] = 0x00000000;
296 if ((detector & kHLT) != 0) fReadoutList.fList[29] = 0x00000000;
297}
298
299
300void AliHLTReadoutList::Print(Option_t* /*option*/) const
301{
302 // Prints the DDLs that will be readout according to this readout list.
303
304 cout << "Readout enabled for DDLs:" << endl;
305 for (Int_t i = 0; i < AliDAQ::kNDetectors; i++)
306 {
307 Int_t maxddls = AliDAQ::NumberOfDdls(i);
308 cout << AliDAQ::DetectorName(i) << ":";
309 bool nonefound = true;
310 for (Int_t j = 0; j < maxddls; j++)
311 {
312 Int_t ddlId = ( ((i == AliDAQ::kNDetectors-1) ? 30 : i) << 8 ) + j;
313 if (GetDDLBit(ddlId))
314 {
315 cout << " " << ddlId;
316 nonefound = false;
317 }
318 }
319 if (nonefound) cout << " none";
320 cout << endl;
321 }
322}
323
324
325AliHLTReadoutList& AliHLTReadoutList::operator = (const AliHLTReadoutList& list)
326{
327 // Assignment operator performs a deep copy.
328
329 TObject::operator = (list);
330 if (&list != this)
331 {
332 memcpy(&fReadoutList, &list.fReadoutList, sizeof(fReadoutList));
333 }
334 return *this;
335}
336
337
338AliHLTReadoutList& AliHLTReadoutList::operator |= (const AliHLTReadoutList& list)
339{
340 // This operator performs a bitwise inclusive or operation on all DDL bits.
341 // See header file for more details.
342
343 assert( fReadoutList.fCount == gkAliHLTDDLListSize );
344 for (Int_t i = 0; i < gkAliHLTDDLListSize; i++)
345 {
346 fReadoutList.fList[i] |= list.fReadoutList.fList[i];
347 }
348 return *this;
349}
350
351
352AliHLTReadoutList& AliHLTReadoutList::operator ^= (const AliHLTReadoutList& list)
353{
354 // This operator performs a bitwise exclusive or (xor) operation on all DDL bits.
355 // See header file for more details.
356
357 assert( fReadoutList.fCount == gkAliHLTDDLListSize );
358 for (Int_t i = 0; i < gkAliHLTDDLListSize; i++)
359 {
360 fReadoutList.fList[i] ^= list.fReadoutList.fList[i];
361 }
362 return *this;
363}
364
365
366AliHLTReadoutList& AliHLTReadoutList::operator &= (const AliHLTReadoutList& list)
367{
368 // This operator performs a bitwise and operation on all DDL bits.
369 // See header file for more details.
370
371 assert( fReadoutList.fCount == gkAliHLTDDLListSize );
372 for (Int_t i = 0; i < gkAliHLTDDLListSize; i++)
373 {
374 fReadoutList.fList[i] &= list.fReadoutList.fList[i];
375 }
376 return *this;
377}
378
379
380AliHLTReadoutList& AliHLTReadoutList::operator -= (const AliHLTReadoutList& list)
381{
382 // This operator removes all the DDLs specified in list from this readout list.
383 // See header file for more details.
384
385 assert( fReadoutList.fCount == gkAliHLTDDLListSize );
386 for (Int_t i = 0; i < gkAliHLTDDLListSize; i++)
387 {
388 // Effectively apply: this = this & (~ (this & list))
389 // i.e. this = this & (this ^ list)
390 fReadoutList.fList[i] &= fReadoutList.fList[i] ^ list.fReadoutList.fList[i];
391 }
392 return *this;
393}
394
395
396AliHLTReadoutList AliHLTReadoutList::operator ~ () const
397{
398 // This operator performs a bitwise ones compliment on all DDL bits.
399 // See header file for more details.
400
401 AliHLTReadoutList readoutlist;
402 readoutlist.fReadoutList.fCount = fReadoutList.fCount;
403 readoutlist.fReadoutList.fList[0] = 0x000FFFFF & (~fReadoutList.fList[0]);
404 readoutlist.fReadoutList.fList[1] = 0x00FFFFFF & (~fReadoutList.fList[1]);
405 readoutlist.fReadoutList.fList[2] = 0x0000FFFF & (~fReadoutList.fList[2]);
406 readoutlist.fReadoutList.fList[3] = 0xFFFFFFFF & (~fReadoutList.fList[3]);
407 readoutlist.fReadoutList.fList[4] = 0xFFFFFFFF & (~fReadoutList.fList[4]);
408 readoutlist.fReadoutList.fList[5] = 0xFFFFFFFF & (~fReadoutList.fList[5]);
409 readoutlist.fReadoutList.fList[6] = 0xFFFFFFFF & (~fReadoutList.fList[6]);
410 readoutlist.fReadoutList.fList[7] = 0xFFFFFFFF & (~fReadoutList.fList[7]);
411 readoutlist.fReadoutList.fList[8] = 0xFFFFFFFF & (~fReadoutList.fList[8]);
412 readoutlist.fReadoutList.fList[9] = 0x00FFFFFF & (~fReadoutList.fList[9]);
413 readoutlist.fReadoutList.fList[10] = 0x00000000 & (~fReadoutList.fList[10]);
414 readoutlist.fReadoutList.fList[11] = 0x0003FFFF & (~fReadoutList.fList[11]);
415 readoutlist.fReadoutList.fList[12] = 0xFFFFFFFF & (~fReadoutList.fList[12]);
416 readoutlist.fReadoutList.fList[13] = 0xFFFFFFFF & (~fReadoutList.fList[13]);
417 readoutlist.fReadoutList.fList[14] = 0x000000FF & (~fReadoutList.fList[14]);
418 readoutlist.fReadoutList.fList[15] = 0x00003FFF & (~fReadoutList.fList[15]);
419 readoutlist.fReadoutList.fList[16] = 0x000FFFFF & (~fReadoutList.fList[16]);
420 readoutlist.fReadoutList.fList[17] = 0x000003FF & (~fReadoutList.fList[17]);
421 readoutlist.fReadoutList.fList[18] = 0x0000003F & (~fReadoutList.fList[18]);
422 readoutlist.fReadoutList.fList[19] = 0x000FFFFF & (~fReadoutList.fList[19]);
423 readoutlist.fReadoutList.fList[20] = 0x00000003 & (~fReadoutList.fList[20]);
424 readoutlist.fReadoutList.fList[21] = 0x00000007 & (~fReadoutList.fList[21]);
425 readoutlist.fReadoutList.fList[22] = 0x00000001 & (~fReadoutList.fList[22]);
426 readoutlist.fReadoutList.fList[23] = 0x00000001 & (~fReadoutList.fList[23]);
427 readoutlist.fReadoutList.fList[24] = 0x00000001 & (~fReadoutList.fList[24]);
428 readoutlist.fReadoutList.fList[25] = 0x00000001 & (~fReadoutList.fList[25]);
429 readoutlist.fReadoutList.fList[26] = 0x00000001 & (~fReadoutList.fList[26]);
430 readoutlist.fReadoutList.fList[27] = 0x00FFFFFF & (~fReadoutList.fList[27]);
431 readoutlist.fReadoutList.fList[28] = 0x00000001 & (~fReadoutList.fList[28]);
432 readoutlist.fReadoutList.fList[29] = 0x000003FF & (~fReadoutList.fList[29]);
433 return readoutlist;
434}
435