]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/trigger/AliHLTDomainEntry.cxx
Finished code for global HLT trigger and the trigger menu implementation.
[u/mrichter/AliRoot.git] / HLT / trigger / AliHLTDomainEntry.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 AliHLTDomainEntry.cxx
18/// @author Artur Szostak <artursz@iafrica.com>
19/// @date 20 Nov 2008
20/// @brief Implementation of the AliHLTDomainEntry class.
21///
22/// The AliHLTDomainEntry class is used to store information identifying a particular
23/// HLT internal data block, or set of data blocks using wild card values. This
24/// class is used by AliHLTTriggerDomain to store a list of data block classes
25/// that should be readout by the HLT. The information identifying a data block is
26/// the following:
27/// - the data block type
28/// - the data block's origin (detector name)
29/// - the data block's specification (detector specific bits)
30/// Several useful operators and methods are defined to help manipulate this
31/// information in the AliHLTTriggerDomain class.
32
33#include "AliHLTDomainEntry.h"
34#include "Riostream.h"
35#include "TString.h"
36#include <cstring>
37
38ClassImp(AliHLTDomainEntry)
39
40
41AliHLTDomainEntry::AliHLTDomainEntry() :
42 TObject(),
43 fExclude(kFALSE),
44 fUseSpec(kFALSE),
45 fType(kAliHLTVoidDataType),
46 fSpecification(0x0)
47{
48 // Default constructor.
49}
50
51AliHLTDomainEntry::AliHLTDomainEntry(const AliHLTDomainEntry& domain) :
52 TObject(domain),
53 fExclude(domain.fExclude),
54 fUseSpec(domain.fUseSpec),
55 fType(domain.fType),
56 fSpecification(domain.fSpecification)
57{
58 // Copy constructor performs a deep copy.
59}
60
61
62AliHLTDomainEntry::AliHLTDomainEntry(const AliHLTComponentDataType& type) :
63 TObject(),
64 fExclude(kFALSE),
65 fUseSpec(kFALSE),
66 fType(type),
67 fSpecification(0x0)
68{
69 // Constructs a domain entry with a particular data type and any specification.
70 // See header file for more information.
71}
72
73
74AliHLTDomainEntry::AliHLTDomainEntry(const char* blocktype, const char* origin) :
75 TObject(),
76 fExclude(kFALSE),
77 fUseSpec(kFALSE),
78 fType(),
79 fSpecification(0x0)
80{
81 // Constructs a domain entry with a particular data type and any specification.
82 // See header file for more information.
83
84 char id[kAliHLTComponentDataTypefIDsize];
85 memset(&id, 0x0, sizeof(id));
86 for (int i = 0; i < kAliHLTComponentDataTypefIDsize && blocktype[i] != '\0'; i++)
87 {
88 id[i] = blocktype[i];
89 }
90 fType = AliHLTComponentDataTypeInitializer(id, origin);
91}
92
93
94AliHLTDomainEntry::AliHLTDomainEntry(const AliHLTComponentDataType& type, UInt_t spec) :
95 TObject(),
96 fExclude(kFALSE),
97 fUseSpec(kTRUE),
98 fType(type),
99 fSpecification(spec)
100{
101 // Constructs a domain entry with a particular data type and specification.
102 // See header file for more information.
103}
104
105
106AliHLTDomainEntry::AliHLTDomainEntry(const char* blocktype, const char* origin, UInt_t spec) :
107 TObject(),
108 fExclude(kFALSE),
109 fUseSpec(kTRUE),
110 fType(),
111 fSpecification(spec)
112{
113 // Constructs a domain entry with a particular data type and specification.
114 // See header file for more information.
115
116 char id[kAliHLTComponentDataTypefIDsize];
117 memset(&id, 0x0, sizeof(id));
118 for (int i = 0; i < kAliHLTComponentDataTypefIDsize && blocktype[i] != '\0'; i++)
119 {
120 id[i] = blocktype[i];
121 }
122 fType = AliHLTComponentDataTypeInitializer(id, origin);
123}
124
125
126AliHLTDomainEntry::AliHLTDomainEntry(Bool_t exclude, const AliHLTDomainEntry& domain) :
127 TObject(domain),
128 fExclude(exclude),
129 fUseSpec(domain.fUseSpec),
130 fType(domain.fType),
131 fSpecification(domain.fSpecification)
132{
133 // Constructs a domain entry from an existing one but with the exclude flag set.
134 // See header file for more information.
135}
136
137
138AliHLTDomainEntry::AliHLTDomainEntry(Bool_t exclude, const AliHLTComponentDataType& type) :
139 TObject(),
140 fExclude(exclude),
141 fUseSpec(kFALSE),
142 fType(type),
143 fSpecification(0x0)
144{
145 // Constructs a domain entry with the given data type, any specification
146 // and the exclude flag set.
147 // See header file for more information.
148}
149
150
151AliHLTDomainEntry::AliHLTDomainEntry(Bool_t exclude, const char* blocktype, const char* origin) :
152 TObject(),
153 fExclude(exclude),
154 fUseSpec(kFALSE),
155 fType(),
156 fSpecification(0x0)
157{
158 // Constructs a domain entry with a particular data type, any specification
159 // and the exclude flag set.
160 // See header file for more information.
161
162 char id[kAliHLTComponentDataTypefIDsize];
163 memset(&id, 0x0, sizeof(id));
164 for (int i = 0; i < kAliHLTComponentDataTypefIDsize && blocktype[i] != '\0'; i++)
165 {
166 id[i] = blocktype[i];
167 }
168 fType = AliHLTComponentDataTypeInitializer(id, origin);
169}
170
171
172AliHLTDomainEntry::AliHLTDomainEntry(Bool_t exclude, const AliHLTComponentDataType& type, UInt_t spec) :
173 TObject(),
174 fExclude(exclude),
175 fUseSpec(kTRUE),
176 fType(type),
177 fSpecification(spec)
178{
179 // Constructs a domain entry with a particular data type and specification,
180 // and the exclude flag is set.
181 // See header file for more information.
182}
183
184
185AliHLTDomainEntry::AliHLTDomainEntry(Bool_t exclude, const char* blocktype, const char* origin, UInt_t spec) :
186 TObject(),
187 fExclude(exclude),
188 fUseSpec(kTRUE),
189 fType(),
190 fSpecification(spec)
191{
192 // Constructs a domain entry with a particular data type and specification,
193 // and the exclude flag is set.
194 // See header file for more information.
195
196 char id[kAliHLTComponentDataTypefIDsize];
197 memset(&id, 0x0, sizeof(id));
198 for (int i = 0; i < kAliHLTComponentDataTypefIDsize && blocktype[i] != '\0'; i++)
199 {
200 id[i] = blocktype[i];
201 }
202 fType = AliHLTComponentDataTypeInitializer(id, origin);
203}
204
205
206AliHLTDomainEntry::~AliHLTDomainEntry()
207{
208 // Default destructor.
209}
210
211
212AliHLTDomainEntry& AliHLTDomainEntry::operator = (const AliHLTDomainEntry& domain)
213{
214 // The copy operator performs a deep copy.
215
216 TObject::operator = (domain);
217 fType = domain.fType;
218 fUseSpec = domain.fUseSpec;
219 fSpecification = domain.fSpecification;
220 return *this;
221}
222
223
224bool AliHLTDomainEntry::IdenticalTo(const AliHLTDomainEntry& rhs) const
225{
226 // Checks if this domain entry is identical to 'rhs' and do not just have a
227 // set intersection.
228 // See header file for more information.
229
230 if (not MatchExactly(fType, rhs.fType)) return false;
231 return (fUseSpec == rhs.fUseSpec) and (fSpecification == rhs.fSpecification);
232}
233
234
235bool AliHLTDomainEntry::SubsetOf(const AliHLTDomainEntry& rhs) const
236{
237 // Checks if this domain entry is a subset of 'rhs'.
238 // See header file for more information.
239
240 if (*this != rhs) return false;
241 bool thisTypeIsAny = strncmp(&fType.fID[0], kAliHLTAnyDataTypeID, kAliHLTComponentDataTypefIDsize) == 0;
242 bool thisOriginIsAny = strncmp(&fType.fOrigin[0], kAliHLTDataOriginAny, kAliHLTComponentDataTypefOriginSize) == 0;
243 bool thisSpecIsAny = not fUseSpec;
244 bool rhsTypeIsAny = strncmp(&rhs.fType.fID[0], kAliHLTAnyDataTypeID, kAliHLTComponentDataTypefIDsize) == 0;
245 bool rhsOriginIsAny = strncmp(&rhs.fType.fOrigin[0], kAliHLTDataOriginAny, kAliHLTComponentDataTypefOriginSize) == 0;
246 bool rhsSpecIsAny = not rhs.fUseSpec;
247 if (thisTypeIsAny and not rhsTypeIsAny) return false;
248 if (thisOriginIsAny and not rhsOriginIsAny) return false;
249 if (thisSpecIsAny and not rhsSpecIsAny) return false;
250 return true;
251}
252
253
254bool AliHLTDomainEntry::IntersectWith(const AliHLTDomainEntry& rhs, AliHLTDomainEntry& result) const
255{
256 // Finds the set intersection between this domain entry and 'rhs'.
257 // See header file for more information.
258
259 if (*this != rhs) return false;
260 bool thisTypeIsAny = strncmp(&fType.fID[0], kAliHLTAnyDataTypeID, kAliHLTComponentDataTypefIDsize) == 0;
261 bool thisOriginIsAny = strncmp(&fType.fOrigin[0], kAliHLTDataOriginAny, kAliHLTComponentDataTypefOriginSize) == 0;
262 bool thisSpecIsAny = not fUseSpec;
263 const AliHLTComponentDataType& type = (not thisTypeIsAny) ? fType : rhs.fType;
264 const AliHLTComponentDataType& origin = (not thisOriginIsAny) ? fType : rhs.fType;
265 Bool_t useSpec;
266 UInt_t spec;
267 if (not thisSpecIsAny)
268 {
269 useSpec = fUseSpec;
270 spec = fSpecification;
271 }
272 else
273 {
274 useSpec = rhs.fUseSpec;
275 spec = rhs.fSpecification;
276 }
277 if (useSpec)
278 {
279 result = AliHLTDomainEntry(type | origin.fOrigin, spec);
280 }
281 else
282 {
283 result = AliHLTDomainEntry(type | origin.fOrigin);
284 }
285 return true;
286}
287
288
289void AliHLTDomainEntry::Print(Option_t* option) const
290{
291 // Inherited from TObject. Prints the domain entry contents.
292 // See header file for more information.
293
52f67e50 294 cout << AsString().Data();
295 TString opt(option);
296 if (opt.Contains("noendl")) return;
297 cout << endl;
298}
299
300
301TString AliHLTDomainEntry::AsString() const
302{
303 // Returns a string representation of the domain entry.
304 // See header file for more information.
305
306 TString str;
dce3e5ce 307 if (strncmp(&fType.fID[0], kAliHLTAnyDataTypeID, kAliHLTComponentDataTypefIDsize) == 0)
308 {
52f67e50 309 for (int i = 0; i < kAliHLTComponentDataTypefIDsize; i++) str += "*";
dce3e5ce 310 }
311 else
312 {
313 for (int i = 0; i < kAliHLTComponentDataTypefIDsize; i++)
314 {
315 if (fType.fID[i] != '\0')
52f67e50 316 str += fType.fID[i];
dce3e5ce 317 else
52f67e50 318 str += "\\0";
dce3e5ce 319 }
320 }
52f67e50 321 str += ":";
dce3e5ce 322 if (strncmp(&fType.fOrigin[0], kAliHLTDataOriginAny, kAliHLTComponentDataTypefOriginSize) == 0)
323 {
52f67e50 324 for (int i = 0; i < kAliHLTComponentDataTypefOriginSize; i++) str += "*";
dce3e5ce 325 }
326 else
327 {
328 for (int i = 0; i < kAliHLTComponentDataTypefOriginSize; i++)
329 {
330 if (fType.fOrigin[i] != '\0')
52f67e50 331 str += fType.fOrigin[i];
dce3e5ce 332 else
52f67e50 333 str += "\\0";
dce3e5ce 334 }
335 }
52f67e50 336 str += ":";
dce3e5ce 337 if (fUseSpec)
338 {
52f67e50 339 char num[16];
340 sprintf(num, "0x%8.8X", fSpecification);
341 str += num;
dce3e5ce 342 }
343 else
344 {
52f67e50 345 str += "**********";
dce3e5ce 346 }
52f67e50 347 return str;
dce3e5ce 348}
349