]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/BASE/AliHLTDAQ.cxx
skipping to unpck objects by default for better performance, optional argument
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTDAQ.cxx
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
19 /// @file   AliHLTDAQ.cxx
20 /// @author Matthias Richter
21 /// @date   24.10.2008
22 /// @brief  Virtual Interface to the AliDAQ class.
23 ///
24
25 #include "AliHLTDAQ.h"
26 #include "AliHLTLogging.h"
27 #include "AliHLTDataTypes.h"
28 #include "TClass.h"
29 #include "TSystem.h"
30
31 /** ROOT macro for the implementation of ROOT specific class methods */
32 ClassImp(AliHLTDAQ)
33
34 AliHLTDAQ::AliHLTDAQ()
35 {
36   // see header file for class documentation
37   // or
38   // refer to README to build package
39   // or
40   // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
41 }
42
43 AliHLTDAQ* AliHLTDAQ::fgpInstance=NULL;
44 const char* AliHLTDAQ::fgkImplName="AliHLTDAQInterfaceImplementation";
45 const char* AliHLTDAQ::fgkImplLibrary="libHLTrec.so";
46 const char* AliHLTDAQ::fgkOriginMapping[] = {
47   kAliHLTDataOriginITSSPD,  
48   kAliHLTDataOriginITSSDD,
49   kAliHLTDataOriginITSSSD,
50   kAliHLTDataOriginTPC,
51   kAliHLTDataOriginTRD,
52   kAliHLTDataOriginTOF,
53   kAliHLTDataOriginHMPID,
54   kAliHLTDataOriginPHOS,
55   kAliHLTDataOriginCPV,
56   kAliHLTDataOriginPMD,
57   kAliHLTDataOriginMUON,
58   "", // MUONTRG
59   kAliHLTDataOriginFMD,
60   kAliHLTDataOriginT0,
61   kAliHLTDataOriginVZERO,
62   kAliHLTDataOriginZDC,
63   kAliHLTDataOriginACORDE,
64   kAliHLTDataOriginTRG,
65   kAliHLTDataOriginEMCAL,
66   NULL
67 };
68
69 AliHLTDAQ::~AliHLTDAQ()
70 {
71   // see header file for class documentation
72 }
73
74 Int_t       AliHLTDAQ::NumberOfDetectors()
75 {
76   // see header file for class documentation
77   if (!fgpInstance) GetInstance();
78   if (fgpInstance) return fgpInstance->VirtNumberOfDetectors();
79   return -1;
80 }
81
82 Int_t       AliHLTDAQ::DetectorID(const char *detectorName)
83 {
84   // see header file for class documentation
85   if (!fgpInstance) GetInstance();
86   if (fgpInstance) return fgpInstance->VirtDetectorID(detectorName);
87   return -1;
88 }
89
90 const char *AliHLTDAQ::DetectorName(Int_t detectorID)
91 {
92   // see header file for class documentation
93   if (!fgpInstance) GetInstance();
94   if (fgpInstance) return fgpInstance->VirtDetectorName(detectorID);
95   return NULL;
96 }
97
98 const char *AliHLTDAQ::DetectorName(const char dataorigin[4])
99 {
100   // see header file for class documentation
101   for (int i=0; fgkOriginMapping[i]!=NULL; i++) {
102     if (strncmp(fgkOriginMapping[i], dataorigin, kAliHLTComponentDataTypefOriginSize)==0) {
103       return DetectorName(i);
104     }
105   }
106
107   return NULL;
108 }
109
110 Int_t       AliHLTDAQ::DdlIDOffset(const char *detectorName)
111 {
112   // see header file for class documentation
113   if (!fgpInstance) GetInstance();
114   if (fgpInstance) return fgpInstance->VirtDdlIDOffset(detectorName);
115   return -1;
116 }
117
118 Int_t       AliHLTDAQ::DdlIDOffset(Int_t detectorID)
119 {
120   // see header file for class documentation
121   if (!fgpInstance) GetInstance();
122   if (fgpInstance) return fgpInstance->VirtDdlIDOffset(detectorID);
123   return -1;
124 }
125
126 const char *AliHLTDAQ::DetectorNameFromDdlID(Int_t ddlID, Int_t &ddlIndex)
127 {
128   // see header file for class documentation
129   if (!fgpInstance) GetInstance();
130   if (fgpInstance) return fgpInstance->VirtDetectorNameFromDdlID(ddlID, ddlIndex);
131   return NULL;
132 }
133
134 Int_t       AliHLTDAQ::DetectorIDFromDdlID(Int_t ddlID, Int_t &ddlIndex)
135 {
136   // see header file for class documentation
137   if (!fgpInstance) GetInstance();
138   if (fgpInstance) return fgpInstance->VirtDetectorIDFromDdlID(ddlID, ddlIndex);
139   return -1;
140 }
141
142 Int_t       AliHLTDAQ::DdlID(const char *detectorName, Int_t ddlIndex)
143 {
144   // see header file for class documentation
145   if (!fgpInstance) GetInstance();
146   if (fgpInstance) return fgpInstance->VirtDdlID(detectorName, ddlIndex);
147   return -1;
148 }
149
150 Int_t       AliHLTDAQ::DdlID(Int_t detectorID, Int_t ddlIndex)
151 {
152   // see header file for class documentation
153   if (!fgpInstance) GetInstance();
154   if (fgpInstance) return fgpInstance->VirtDdlID(detectorID, ddlIndex);
155   return -1;
156 }
157
158 const char *AliHLTDAQ::DdlFileName(const char *detectorName, Int_t ddlIndex)
159 {
160   // see header file for class documentation
161   if (!fgpInstance) GetInstance();
162   if (fgpInstance) return fgpInstance->VirtDdlFileName(detectorName, ddlIndex);
163   return NULL;
164 }
165
166 const char *AliHLTDAQ::DdlFileName(Int_t detectorID, Int_t ddlIndex)
167 {
168   // see header file for class documentation
169   if (!fgpInstance) GetInstance();
170   if (fgpInstance) return fgpInstance->VirtDdlFileName(detectorID, ddlIndex);
171   return NULL;
172 }
173
174 Int_t       AliHLTDAQ::NumberOfDdls(const char *detectorName)
175 {
176   // see header file for class documentation
177   if (!fgpInstance) GetInstance();
178   if (fgpInstance) return fgpInstance->VirtNumberOfDdls(detectorName);
179   return -1;
180 }
181
182 Int_t       AliHLTDAQ::NumberOfDdls(Int_t detectorID)
183 {
184   // see header file for class documentation
185   if (!fgpInstance) GetInstance();
186   if (fgpInstance) return fgpInstance->VirtNumberOfDdls(detectorID);
187   return -1;
188 }
189
190 const char *AliHLTDAQ::ListOfTriggeredDetectors(UInt_t detectorPattern)
191 {
192   // see header file for class documentation
193   if (!fgpInstance) GetInstance();
194   if (fgpInstance) return fgpInstance->VirtListOfTriggeredDetectors(detectorPattern);
195   return NULL;
196 }
197
198 UInt_t      AliHLTDAQ::DetectorPattern(const char *detectorList)
199 {
200   // see header file for class documentation
201   if (!fgpInstance) GetInstance();
202   if (fgpInstance) return fgpInstance->VirtDetectorPattern(detectorList);
203   return 0;
204 }
205
206 const char *AliHLTDAQ::OfflineModuleName(const char *detectorName)
207 {
208   // see header file for class documentation
209   if (!fgpInstance) GetInstance();
210   if (fgpInstance) return fgpInstance->VirtOfflineModuleName(detectorName);
211   return NULL;
212 }
213 const char *AliHLTDAQ::OfflineModuleName(Int_t detectorID)
214 {
215   // see header file for class documentation
216   if (!fgpInstance) GetInstance();
217   if (fgpInstance) return fgpInstance->VirtOfflineModuleName(detectorID);
218   return NULL;
219 }
220
221 const char *AliHLTDAQ::OnlineName(const char *detectorName)
222 {
223   // see header file for class documentation
224   if (!fgpInstance) GetInstance();
225   if (fgpInstance) return fgpInstance->VirtOnlineName(detectorName);
226   return NULL;
227 }
228 const char *AliHLTDAQ::OnlineName(Int_t detectorID)
229 {
230   // see header file for class documentation
231   if (!fgpInstance) GetInstance();
232   if (fgpInstance) return fgpInstance->VirtOnlineName(detectorID);
233   return NULL;
234 }
235
236 string AliHLTDAQ::HLTOrigin(const char *detectorName)
237 {
238   // get HLT origin from detector name
239   return HLTOrigin(DetectorID(detectorName));
240 }
241
242 string AliHLTDAQ::HLTOrigin(Int_t detectorID)
243 {
244   // get HLT origin from detector ID
245   string origin;
246   if (detectorID>=0 && (unsigned)detectorID<sizeof(fgkOriginMapping)/sizeof(const char*)) {
247     origin.append(fgkOriginMapping[detectorID], kAliHLTComponentDataTypefOriginSize);
248   }
249   return origin;
250 }
251
252 AliHLTDAQ* AliHLTDAQ::GetInstance()
253 {
254   // see header file for class documentation
255   int iLibResult=0;
256   if (!fgpInstance) {
257     AliHLTLogging log;
258     TClass* pCl=NULL;
259     ROOT::NewFunc_t pNewFunc=NULL;
260     do {
261       pCl=TClass::GetClass(fgkImplName);
262     } while (!pCl && (iLibResult=gSystem->Load(fgkImplLibrary))==0);
263     if (iLibResult>=0) {
264       if (pCl && (pNewFunc=pCl->GetNew())!=NULL) {
265         void* p=(*pNewFunc)(NULL);
266         if (p) {
267           fgpInstance=reinterpret_cast<AliHLTDAQ*>(p);
268           if (!fgpInstance) {
269             log.Logging(kHLTLogError, "AliHLTDAQ::Instance", "HLT Analysis", "type cast to AliHLTDAQ instance failed");
270           }
271         } else {
272           log.Logging(kHLTLogError, "AliHLTDAQ::Instance", "HLT Analysis", "can not create AliHLTDAQ instance from class descriptor");
273         }
274       } else {
275         log.Logging(kHLTLogError, "AliHLTDAQ::Instance", "HLT Analysis", "can not find AliHLTDAQ class descriptor");
276       }
277     } else {
278       log.Logging(kHLTLogError, "AliHLTDAQ::Instance", "HLT Analysis", "can not load libHLTrec library");
279     }
280   }
281   return fgpInstance;
282 }