]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/BASE/AliHLTDAQ.cxx
Adding event modulo option to all components.
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTDAQ.cxx
CommitLineData
7c4d1228 1// $Id$
2
3//**************************************************************************
4//* This file is property of and copyright by the ALICE HLT Project *
5//* ALICE Experiment at CERN, All rights reserved. *
6//* *
7//* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
8//* for The ALICE HLT Project. *
9//* *
10//* Permission to use, copy, modify and distribute this software and its *
11//* documentation strictly for non-commercial purposes is hereby granted *
12//* without fee, provided that the above copyright notice appears in all *
13//* copies and that both the copyright notice and this permission notice *
14//* appear in the supporting documentation. The authors make no claims *
15//* about the suitability of this software for any purpose. It is *
16//* provided "as is" without express or implied warranty. *
17//**************************************************************************
18
eb8e9901 19/// @file AliHLTDAQ.cxx
20/// @author Matthias Richter
21/// @date 24.10.2008
22/// @brief Virtual Interface to the AliDAQ class.
23///
7c4d1228 24
25#include "AliHLTDAQ.h"
26#include "AliHLTLogging.h"
eb8e9901 27#include "AliHLTDataTypes.h"
2ce72c0a 28#include "AliHLTMisc.h"
7c4d1228 29#include "TClass.h"
30#include "TSystem.h"
31
32/** ROOT macro for the implementation of ROOT specific class methods */
33ClassImp(AliHLTDAQ)
34
35AliHLTDAQ::AliHLTDAQ()
36{
37 // see header file for class documentation
38 // or
39 // refer to README to build package
40 // or
41 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
42}
43
44AliHLTDAQ* AliHLTDAQ::fgpInstance=NULL;
45const char* AliHLTDAQ::fgkImplName="AliHLTDAQInterfaceImplementation";
46const char* AliHLTDAQ::fgkImplLibrary="libHLTrec.so";
eb8e9901 47const char* AliHLTDAQ::fgkOriginMapping[] = {
48 kAliHLTDataOriginITSSPD,
49 kAliHLTDataOriginITSSDD,
50 kAliHLTDataOriginITSSSD,
51 kAliHLTDataOriginTPC,
52 kAliHLTDataOriginTRD,
53 kAliHLTDataOriginTOF,
54 kAliHLTDataOriginHMPID,
55 kAliHLTDataOriginPHOS,
56 kAliHLTDataOriginCPV,
57 kAliHLTDataOriginPMD,
58 kAliHLTDataOriginMUON,
59 "", // MUONTRG
60 kAliHLTDataOriginFMD,
61 kAliHLTDataOriginT0,
62 kAliHLTDataOriginVZERO,
63 kAliHLTDataOriginZDC,
64 kAliHLTDataOriginACORDE,
65 kAliHLTDataOriginTRG,
66 kAliHLTDataOriginEMCAL,
67 NULL
68};
7c4d1228 69
70AliHLTDAQ::~AliHLTDAQ()
71{
72 // see header file for class documentation
73}
74
84221957 75Int_t AliHLTDAQ::NumberOfDetectors()
76{
77 // see header file for class documentation
78 if (!fgpInstance) GetInstance();
79 if (fgpInstance) return fgpInstance->VirtNumberOfDetectors();
80 return -1;
81}
82
7c4d1228 83Int_t AliHLTDAQ::DetectorID(const char *detectorName)
84{
2ce72c0a 85 // get the detector ID from the detector name
86 // forwards to AliDAQ::DetectorName
7c4d1228 87 if (!fgpInstance) GetInstance();
88 if (fgpInstance) return fgpInstance->VirtDetectorID(detectorName);
89 return -1;
90}
91
92const char *AliHLTDAQ::DetectorName(Int_t detectorID)
93{
2ce72c0a 94 // get the detector name from the detector ID
95 // forwards to AliDAQ::DetectorName
7c4d1228 96 if (!fgpInstance) GetInstance();
97 if (fgpInstance) return fgpInstance->VirtDetectorName(detectorID);
98 return NULL;
99}
100
2ce72c0a 101Int_t AliHLTDAQ::DetectorIDFromHLTOrigin(const char dataorigin[kAliHLTComponentDataTypefOriginSize])
eb8e9901 102{
2ce72c0a 103 // get the detector id from HLT origin
eb8e9901 104 for (int i=0; fgkOriginMapping[i]!=NULL; i++) {
105 if (strncmp(fgkOriginMapping[i], dataorigin, kAliHLTComponentDataTypefOriginSize)==0) {
2ce72c0a 106 return i;
eb8e9901 107 }
108 }
109
2ce72c0a 110 return -1;
111}
112
113const char *AliHLTDAQ::DetectorName(const char dataorigin[kAliHLTComponentDataTypefOriginSize])
114{
115 // get the detector name from HLT origin
116 Int_t detectorID=DetectorIDFromHLTOrigin(dataorigin);
117 if (detectorID<0) return NULL;
118
119 return DetectorName(detectorID);
eb8e9901 120}
121
7c4d1228 122Int_t AliHLTDAQ::DdlIDOffset(const char *detectorName)
123{
2ce72c0a 124 // get ID of the first DDL of a detector
125 // forwards to AliDAQ::DdlIDOffset
7c4d1228 126 if (!fgpInstance) GetInstance();
127 if (fgpInstance) return fgpInstance->VirtDdlIDOffset(detectorName);
128 return -1;
129}
130
131Int_t AliHLTDAQ::DdlIDOffset(Int_t detectorID)
132{
2ce72c0a 133 // get ID of the first DDL of a detector
134 // forwards to AliDAQ::DdlIDOffset
7c4d1228 135 if (!fgpInstance) GetInstance();
136 if (fgpInstance) return fgpInstance->VirtDdlIDOffset(detectorID);
137 return -1;
138}
139
140const char *AliHLTDAQ::DetectorNameFromDdlID(Int_t ddlID, Int_t &ddlIndex)
141{
2ce72c0a 142 // get detector name from global DDL ID and index of DDL within the detector
143 // forwards to AliDAQ::DetectorNameFromDdlID
7c4d1228 144 if (!fgpInstance) GetInstance();
145 if (fgpInstance) return fgpInstance->VirtDetectorNameFromDdlID(ddlID, ddlIndex);
146 return NULL;
147}
148
149Int_t AliHLTDAQ::DetectorIDFromDdlID(Int_t ddlID, Int_t &ddlIndex)
150{
2ce72c0a 151 // get detector ID from global DDL ID and index of DDL within the detector
152 // forwards to AliDAQ::DetectorNameFromDdlID
7c4d1228 153 if (!fgpInstance) GetInstance();
154 if (fgpInstance) return fgpInstance->VirtDetectorIDFromDdlID(ddlID, ddlIndex);
155 return -1;
156}
157
158Int_t AliHLTDAQ::DdlID(const char *detectorName, Int_t ddlIndex)
159{
2ce72c0a 160 // get global DDL ID from detector name and index of DDL within the detector
161 // forwards to AliDAQ::DdlID
7c4d1228 162 if (!fgpInstance) GetInstance();
163 if (fgpInstance) return fgpInstance->VirtDdlID(detectorName, ddlIndex);
164 return -1;
165}
166
167Int_t AliHLTDAQ::DdlID(Int_t detectorID, Int_t ddlIndex)
168{
2ce72c0a 169 // get global DDL ID from detector ID and index of DDL within the detector
170 // forwards to AliDAQ::DdlID
7c4d1228 171 if (!fgpInstance) GetInstance();
172 if (fgpInstance) return fgpInstance->VirtDdlID(detectorID, ddlIndex);
173 return -1;
174}
175
176const char *AliHLTDAQ::DdlFileName(const char *detectorName, Int_t ddlIndex)
177{
178 // see header file for class documentation
179 if (!fgpInstance) GetInstance();
180 if (fgpInstance) return fgpInstance->VirtDdlFileName(detectorName, ddlIndex);
181 return NULL;
182}
183
184const char *AliHLTDAQ::DdlFileName(Int_t detectorID, Int_t ddlIndex)
185{
186 // see header file for class documentation
187 if (!fgpInstance) GetInstance();
188 if (fgpInstance) return fgpInstance->VirtDdlFileName(detectorID, ddlIndex);
189 return NULL;
190}
191
192Int_t AliHLTDAQ::NumberOfDdls(const char *detectorName)
193{
194 // see header file for class documentation
195 if (!fgpInstance) GetInstance();
196 if (fgpInstance) return fgpInstance->VirtNumberOfDdls(detectorName);
197 return -1;
198}
199
200Int_t AliHLTDAQ::NumberOfDdls(Int_t detectorID)
201{
202 // see header file for class documentation
203 if (!fgpInstance) GetInstance();
204 if (fgpInstance) return fgpInstance->VirtNumberOfDdls(detectorID);
205 return -1;
206}
207
84221957 208const char *AliHLTDAQ::ListOfTriggeredDetectors(UInt_t detectorPattern)
209{
210 // see header file for class documentation
211 if (!fgpInstance) GetInstance();
212 if (fgpInstance) return fgpInstance->VirtListOfTriggeredDetectors(detectorPattern);
213 return NULL;
214}
215
216UInt_t AliHLTDAQ::DetectorPattern(const char *detectorList)
217{
218 // see header file for class documentation
219 if (!fgpInstance) GetInstance();
220 if (fgpInstance) return fgpInstance->VirtDetectorPattern(detectorList);
221 return 0;
222}
223
224const char *AliHLTDAQ::OfflineModuleName(const char *detectorName)
225{
226 // see header file for class documentation
227 if (!fgpInstance) GetInstance();
228 if (fgpInstance) return fgpInstance->VirtOfflineModuleName(detectorName);
229 return NULL;
230}
231const char *AliHLTDAQ::OfflineModuleName(Int_t detectorID)
232{
233 // see header file for class documentation
234 if (!fgpInstance) GetInstance();
235 if (fgpInstance) return fgpInstance->VirtOfflineModuleName(detectorID);
236 return NULL;
237}
238
239const char *AliHLTDAQ::OnlineName(const char *detectorName)
240{
241 // see header file for class documentation
242 if (!fgpInstance) GetInstance();
243 if (fgpInstance) return fgpInstance->VirtOnlineName(detectorName);
244 return NULL;
245}
246const char *AliHLTDAQ::OnlineName(Int_t detectorID)
247{
248 // see header file for class documentation
249 if (!fgpInstance) GetInstance();
250 if (fgpInstance) return fgpInstance->VirtOnlineName(detectorID);
251 return NULL;
252}
253
eb8e9901 254string AliHLTDAQ::HLTOrigin(const char *detectorName)
255{
256 // get HLT origin from detector name
257 return HLTOrigin(DetectorID(detectorName));
258}
259
260string AliHLTDAQ::HLTOrigin(Int_t detectorID)
261{
262 // get HLT origin from detector ID
263 string origin;
f8d00daf 264 if (detectorID>=0 && (unsigned)detectorID<sizeof(fgkOriginMapping)/sizeof(const char*)) {
eb8e9901 265 origin.append(fgkOriginMapping[detectorID], kAliHLTComponentDataTypefOriginSize);
266 }
267 return origin;
268}
269
41f65320 270string AliHLTDAQ::HLTSpecificationFromDdlID(Int_t ddlID)
271{
2ce72c0a 272 // get the HLT data specification from equipment id
41f65320 273 string result = "";
2ce72c0a 274 Int_t ddlIndex=0;
41f65320 275 Int_t detectorID = DetectorIDFromDdlID(ddlID, ddlIndex);
276 if (detectorID < 0)
277 return result;
278 Int_t TPCID = DetectorID("TPC");
1209ef88 279 const int strtmplength=11;
280 char strtmp[strtmplength];
281 memset(strtmp, 0, strtmplength);
2ce72c0a 282 if (detectorID == TPCID) {
41f65320 283 int partition;
284 int slice;
285 if (ddlID < 840) {
286 partition = ddlID % 2;
287 slice = (ddlID - 768) / 2;
288 } else {
289 partition = (ddlID % 4) + 2;
290 slice = (ddlID - 840) / 4;
291 }
1209ef88 292 snprintf(strtmp, strtmplength, "0x%02x%02x%02x%02x", slice, slice, partition, partition);
41f65320 293 result = strtmp;
294 }
2ce72c0a 295 else if (detectorID == DetectorID("TOF")) {
296 AliHLTLogging log;
297 log.Logging(kHLTLogWarning, "AliHLTDAQ::HLTSpecificationFromDdlID", "HLT Analysis", "Mapping of data specification not implemented for TOF");
298 }
299 else { // default
300 snprintf(strtmp, strtmplength, "0x%08x", 0x1 << ddlIndex);
301 result = strtmp;
302 }
41f65320 303 return result;
304}
305
2ce72c0a 306Int_t AliHLTDAQ::DdlIDFromHLTBlockData(const char dataorigin[kAliHLTComponentDataTypefOriginSize], UInt_t specification)
307{
308 // get the DDL ID (global equipment ID) from HLT origin and data specification
309 Int_t detectorID=DetectorIDFromHLTOrigin(dataorigin);
310 if (detectorID<0) return -1;
311 Int_t ddlID=DdlIDOffset(detectorID);
312 if (ddlID<0) return -1;
313
314 if (detectorID == DetectorID("TPC")) {
315 int minPartition= specification &0xff;
316 int maxPartition=(specification>>8) &0xff;
317 int minSlice =(specification>>16)&0xff;
318 int maxSlice =(specification>>24)&0xff;
319 if (minPartition<0 || minPartition>5 ||
320 maxPartition<0 || maxPartition>5 ||
321 minSlice<0 || minSlice>35 ||
322 maxSlice<0 || maxSlice>35) {
323 AliHLTLogging log;
324 log.Logging(kHLTLogError, "AliHLTDAQ::DdlID", "HLT Analysis", "invalid data specification 0x%08x", specification);
325 return -1;
326 }
327 else if (minPartition!=maxPartition ||
328 minSlice!=maxSlice) {
329 AliHLTLogging log;
330 log.Logging(kHLTLogError, "AliHLTDAQ::DdlID", "HLT Analysis", "ambiguous data specification 0x%08x", specification);
331 return -1;
332 }
333 if (minPartition<2) ddlID+=2*minSlice+minPartition; // inner sector
334 else ddlID+=4*minSlice+(minPartition-2)+72; // outer sector
335 }
336 else if (detectorID == DetectorID("TOF")) {
337 AliHLTLogging log;
338 log.Logging(kHLTLogWarning, "AliHLTDAQ::DdlID", "HLT Analysis", "Mapping of data specification not implemented for TOF");
339 return -1;
340 }
341 else { // default
342 for (int i=0; i<32; i++) {
343 if ((specification&(0x1<<i))==0) continue; // if bit not set
344 if ((specification&(0xffffffff^(0x1<<i)))!=0) { // check if other bits set
345 AliHLTLogging log;
346 log.Logging(kHLTLogError, "AliHLTDAQ::DdlID", "HLT Analysis", "ambiguous data specification 0x%08x", specification);
347 return -1;
348 }
349 ddlID+=i;
350 break;
351 }
352 }
353
354 return ddlID;
355}
356
7c4d1228 357AliHLTDAQ* AliHLTDAQ::GetInstance()
358{
359 // see header file for class documentation
7c4d1228 360 if (!fgpInstance) {
2ce72c0a 361 fgpInstance=AliHLTMisc::LoadInstance((AliHLTDAQ*)NULL, fgkImplName, fgkImplLibrary);
362 if (!fgpInstance) {
363 AliHLTLogging log;
364 log.Logging(kHLTLogError, "AliHLTDAQ::Instance", "HLT Analysis", "failed to load AliHLTDAQ implementation");
7c4d1228 365 }
366 }
367 return fgpInstance;
368}