3 //**************************************************************************
4 //* This file is property of and copyright by the ALICE HLT Project *
5 //* ALICE Experiment at CERN, All rights reserved. *
7 //* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
8 //* for The ALICE HLT Project. *
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 //**************************************************************************
19 /// @file AliHLTDAQ.cxx
20 /// @author Matthias Richter
22 /// @brief Virtual Interface to the AliDAQ class.
25 #include "AliHLTDAQ.h"
26 #include "AliHLTLogging.h"
27 #include "AliHLTDataTypes.h"
28 #include "AliHLTMisc.h"
32 /** ROOT macro for the implementation of ROOT specific class methods */
35 AliHLTDAQ::AliHLTDAQ()
37 // see header file for class documentation
39 // refer to README to build package
41 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
44 AliHLTDAQ* AliHLTDAQ::fgpInstance=NULL;
45 const char* AliHLTDAQ::fgkImplName="AliHLTDAQInterfaceImplementation";
46 const char* AliHLTDAQ::fgkImplLibrary="libHLTrec.so";
47 const char* AliHLTDAQ::fgkOriginMapping[] = {
48 kAliHLTDataOriginITSSPD,
49 kAliHLTDataOriginITSSDD,
50 kAliHLTDataOriginITSSSD,
54 kAliHLTDataOriginHMPID,
55 kAliHLTDataOriginPHOS,
58 kAliHLTDataOriginMUON,
62 kAliHLTDataOriginVZERO,
64 kAliHLTDataOriginACORDE,
66 kAliHLTDataOriginEMCAL,
70 AliHLTDAQ::~AliHLTDAQ()
72 // see header file for class documentation
75 Int_t AliHLTDAQ::NumberOfDetectors()
77 // see header file for class documentation
78 if (!fgpInstance) GetInstance();
79 if (fgpInstance) return fgpInstance->VirtNumberOfDetectors();
83 Int_t AliHLTDAQ::DetectorID(const char *detectorName)
85 // get the detector ID from the detector name
86 // forwards to AliDAQ::DetectorName
87 if (!fgpInstance) GetInstance();
88 if (fgpInstance) return fgpInstance->VirtDetectorID(detectorName);
92 const char *AliHLTDAQ::DetectorName(Int_t detectorID)
94 // get the detector name from the detector ID
95 // forwards to AliDAQ::DetectorName
96 if (!fgpInstance) GetInstance();
97 if (fgpInstance) return fgpInstance->VirtDetectorName(detectorID);
101 Int_t AliHLTDAQ::DetectorIDFromHLTOrigin(const char dataorigin[kAliHLTComponentDataTypefOriginSize])
103 // get the detector id from HLT origin
104 for (int i=0; fgkOriginMapping[i]!=NULL; i++) {
105 if (strncmp(fgkOriginMapping[i], dataorigin, kAliHLTComponentDataTypefOriginSize)==0) {
113 const char *AliHLTDAQ::DetectorName(const char dataorigin[kAliHLTComponentDataTypefOriginSize])
115 // get the detector name from HLT origin
116 Int_t detectorID=DetectorIDFromHLTOrigin(dataorigin);
117 if (detectorID<0) return NULL;
119 return DetectorName(detectorID);
122 Int_t AliHLTDAQ::DdlIDOffset(const char *detectorName)
124 // get ID of the first DDL of a detector
125 // forwards to AliDAQ::DdlIDOffset
126 if (!fgpInstance) GetInstance();
127 if (fgpInstance) return fgpInstance->VirtDdlIDOffset(detectorName);
131 Int_t AliHLTDAQ::DdlIDOffset(Int_t detectorID)
133 // get ID of the first DDL of a detector
134 // forwards to AliDAQ::DdlIDOffset
135 if (!fgpInstance) GetInstance();
136 if (fgpInstance) return fgpInstance->VirtDdlIDOffset(detectorID);
140 const char *AliHLTDAQ::DetectorNameFromDdlID(Int_t ddlID, Int_t &ddlIndex)
142 // get detector name from global DDL ID and index of DDL within the detector
143 // forwards to AliDAQ::DetectorNameFromDdlID
144 if (!fgpInstance) GetInstance();
145 if (fgpInstance) return fgpInstance->VirtDetectorNameFromDdlID(ddlID, ddlIndex);
149 Int_t AliHLTDAQ::DetectorIDFromDdlID(Int_t ddlID, Int_t &ddlIndex)
151 // get detector ID from global DDL ID and index of DDL within the detector
152 // forwards to AliDAQ::DetectorNameFromDdlID
153 if (!fgpInstance) GetInstance();
154 if (fgpInstance) return fgpInstance->VirtDetectorIDFromDdlID(ddlID, ddlIndex);
158 Int_t AliHLTDAQ::DdlID(const char *detectorName, Int_t ddlIndex)
160 // get global DDL ID from detector name and index of DDL within the detector
161 // forwards to AliDAQ::DdlID
162 if (!fgpInstance) GetInstance();
163 if (fgpInstance) return fgpInstance->VirtDdlID(detectorName, ddlIndex);
167 Int_t AliHLTDAQ::DdlID(Int_t detectorID, Int_t ddlIndex)
169 // get global DDL ID from detector ID and index of DDL within the detector
170 // forwards to AliDAQ::DdlID
171 if (!fgpInstance) GetInstance();
172 if (fgpInstance) return fgpInstance->VirtDdlID(detectorID, ddlIndex);
176 const char *AliHLTDAQ::DdlFileName(const char *detectorName, Int_t ddlIndex)
178 // see header file for class documentation
179 if (!fgpInstance) GetInstance();
180 if (fgpInstance) return fgpInstance->VirtDdlFileName(detectorName, ddlIndex);
184 const char *AliHLTDAQ::DdlFileName(Int_t detectorID, Int_t ddlIndex)
186 // see header file for class documentation
187 if (!fgpInstance) GetInstance();
188 if (fgpInstance) return fgpInstance->VirtDdlFileName(detectorID, ddlIndex);
192 Int_t AliHLTDAQ::NumberOfDdls(const char *detectorName)
194 // see header file for class documentation
195 if (!fgpInstance) GetInstance();
196 if (fgpInstance) return fgpInstance->VirtNumberOfDdls(detectorName);
200 Int_t AliHLTDAQ::NumberOfDdls(Int_t detectorID)
202 // see header file for class documentation
203 if (!fgpInstance) GetInstance();
204 if (fgpInstance) return fgpInstance->VirtNumberOfDdls(detectorID);
208 const char *AliHLTDAQ::ListOfTriggeredDetectors(UInt_t detectorPattern)
210 // see header file for class documentation
211 if (!fgpInstance) GetInstance();
212 if (fgpInstance) return fgpInstance->VirtListOfTriggeredDetectors(detectorPattern);
216 UInt_t AliHLTDAQ::DetectorPattern(const char *detectorList)
218 // see header file for class documentation
219 if (!fgpInstance) GetInstance();
220 if (fgpInstance) return fgpInstance->VirtDetectorPattern(detectorList);
224 const char *AliHLTDAQ::OfflineModuleName(const char *detectorName)
226 // see header file for class documentation
227 if (!fgpInstance) GetInstance();
228 if (fgpInstance) return fgpInstance->VirtOfflineModuleName(detectorName);
231 const char *AliHLTDAQ::OfflineModuleName(Int_t detectorID)
233 // see header file for class documentation
234 if (!fgpInstance) GetInstance();
235 if (fgpInstance) return fgpInstance->VirtOfflineModuleName(detectorID);
239 const char *AliHLTDAQ::OnlineName(const char *detectorName)
241 // see header file for class documentation
242 if (!fgpInstance) GetInstance();
243 if (fgpInstance) return fgpInstance->VirtOnlineName(detectorName);
246 const char *AliHLTDAQ::OnlineName(Int_t detectorID)
248 // see header file for class documentation
249 if (!fgpInstance) GetInstance();
250 if (fgpInstance) return fgpInstance->VirtOnlineName(detectorID);
254 string AliHLTDAQ::HLTOrigin(const char *detectorName)
256 // get HLT origin from detector name
257 return HLTOrigin(DetectorID(detectorName));
260 string AliHLTDAQ::HLTOrigin(Int_t detectorID)
262 // get HLT origin from detector ID
264 if (detectorID>=0 && (unsigned)detectorID<sizeof(fgkOriginMapping)/sizeof(const char*)) {
265 origin.append(fgkOriginMapping[detectorID], kAliHLTComponentDataTypefOriginSize);
270 string AliHLTDAQ::HLTSpecificationFromDdlID(Int_t ddlID)
272 // get the HLT data specification from equipment id
275 Int_t detectorID = DetectorIDFromDdlID(ddlID, ddlIndex);
278 Int_t TPCID = DetectorID("TPC");
279 const int strtmplength=11;
280 char strtmp[strtmplength];
281 memset(strtmp, 0, strtmplength);
282 if (detectorID == TPCID) {
286 partition = ddlID % 2;
287 slice = (ddlID - 768) / 2;
289 partition = (ddlID % 4) + 2;
290 slice = (ddlID - 840) / 4;
292 snprintf(strtmp, strtmplength, "0x%02x%02x%02x%02x", slice, slice, partition, partition);
295 else if (detectorID == DetectorID("TOF")) {
297 log.Logging(kHLTLogWarning, "AliHLTDAQ::HLTSpecificationFromDdlID", "HLT Analysis", "Mapping of data specification not implemented for TOF");
300 snprintf(strtmp, strtmplength, "0x%08x", 0x1 << ddlIndex);
306 Int_t AliHLTDAQ::DdlIDFromHLTBlockData(const char dataorigin[kAliHLTComponentDataTypefOriginSize], UInt_t specification)
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;
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) {
324 log.Logging(kHLTLogError, "AliHLTDAQ::DdlID", "HLT Analysis", "invalid data specification 0x%08x", specification);
327 else if (minPartition!=maxPartition ||
328 minSlice!=maxSlice) {
330 log.Logging(kHLTLogError, "AliHLTDAQ::DdlID", "HLT Analysis", "ambiguous data specification 0x%08x", specification);
333 if (minPartition<2) ddlID+=2*minSlice+minPartition; // inner sector
334 else ddlID+=4*minSlice+(minPartition-2)+72; // outer sector
336 else if (detectorID == DetectorID("TOF")) {
338 log.Logging(kHLTLogWarning, "AliHLTDAQ::DdlID", "HLT Analysis", "Mapping of data specification not implemented for TOF");
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
346 log.Logging(kHLTLogError, "AliHLTDAQ::DdlID", "HLT Analysis", "ambiguous data specification 0x%08x", specification);
357 AliHLTDAQ* AliHLTDAQ::GetInstance()
359 // see header file for class documentation
361 fgpInstance=AliHLTMisc::LoadInstance((AliHLTDAQ*)NULL, fgkImplName, fgkImplLibrary);
364 log.Logging(kHLTLogError, "AliHLTDAQ::Instance", "HLT Analysis", "failed to load AliHLTDAQ implementation");