]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/BASE/AliHLTModulePreprocessor.cxx
reverting r27483 partially in order to cope with bug of the PubSub framework
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTModulePreprocessor.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 /**
20  * @file   AliHLTModulePreprocessor.cxx
21  * @author Matthias Richter
22  * @date   2008-01-22
23  * @brief  Base class for HLT module preprocessors
24  */
25
26 #include <cstdlib>
27 #include <cassert>
28 #include "AliHLTModulePreprocessor.h"
29 #include "AliHLTShuttleInterface.h"
30 #include "TObjString.h"
31 #include "TString.h"
32
33
34 ClassImp(AliHLTModulePreprocessor)
35
36 AliHLTModulePreprocessor::AliHLTModulePreprocessor() 
37   :
38   fpInterface(NULL),
39   fActiveDetectors(0)
40 {
41   // see header file for class documentation
42   // or
43   // refer to README to build package
44   // or
45   // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
46 }
47
48 AliHLTModulePreprocessor::~AliHLTModulePreprocessor() 
49 {
50   // see header file for function documentation
51 }
52
53 const Int_t AliHLTModulePreprocessor::kNDetectors = 21;
54
55 const char* AliHLTModulePreprocessor::fgkDetectorName[kNDetectors] = 
56 {
57   "ITSSPD",
58   "ITSSDD",
59   "ITSSSD",
60   "TPC",
61   "TRD",
62   "TOF",
63   "HMPID",
64   "PHOS",
65   "CPV",
66   "PMD",
67   "MUONTRK",
68   "MUONTRG",
69   "FMD",
70   "T0",
71   "VZERO", // Name to be changed to V0 ?
72   "ZDC",
73   "ACORDE",
74   "TRG",
75   "EMCAL",
76   "DAQ_TEST",
77   "HLT"
78 };
79
80 void AliHLTModulePreprocessor::SetShuttleInterface(AliHLTShuttleInterface* pInterface)
81 {
82   assert(fpInterface==NULL || fpInterface==pInterface || pInterface==NULL);
83   fpInterface=pInterface;
84 }
85
86 Int_t AliHLTModulePreprocessor::GetRun()
87 {
88   // see header file for function documentation
89
90   assert(fpInterface);
91   if (!fpInterface) return 0;
92   return fpInterface->PreprocessorGetRun();
93 }
94
95 UInt_t AliHLTModulePreprocessor::GetStartTime()
96 {
97   // see header file for function documentation
98
99   assert(fpInterface);
100   if (!fpInterface) return 0;
101   return fpInterface->PreprocessorGetStartTime();
102 }
103
104 UInt_t AliHLTModulePreprocessor::GetEndTime()
105 {
106   // see header file for function documentation
107
108   assert(fpInterface);
109   if (!fpInterface) return 0;
110   return fpInterface->PreprocessorGetEndTime();
111 }
112
113 Bool_t AliHLTModulePreprocessor::Store(const char* pathLevel2, const char* pathLevel3, TObject* object,
114                                  AliCDBMetaData* metaData, Int_t validityStart, Bool_t validityInfinite)
115 {
116   // see header file for function documentation
117
118   assert(fpInterface);
119   if (!fpInterface) return 0;
120   return fpInterface->PreprocessorStore(pathLevel2, pathLevel3, object, metaData, validityStart, validityInfinite);
121 }
122
123 Bool_t AliHLTModulePreprocessor::StoreReferenceData(const char* pathLevel2, const char* pathLevel3, TObject* object,
124                                               AliCDBMetaData* metaData)
125 {
126   // see header file for function documentation
127
128   assert(fpInterface);
129   if (!fpInterface) return 0;
130   return fpInterface->PreprocessorStoreReferenceData(pathLevel2, pathLevel3, object, metaData);
131 }
132
133 Bool_t AliHLTModulePreprocessor::StoreReferenceFile(const char* localFile, const char* gridFileName)
134 {
135   // see header file for function documentation
136
137   assert(fpInterface);
138   if (!fpInterface) return 0;
139   return fpInterface->PreprocessorStoreReferenceFile(localFile, gridFileName);
140 }
141
142 Bool_t AliHLTModulePreprocessor::StoreRunMetadataFile(const char* localFile, const char* gridFileName)
143 {
144   // see header file for function documentation
145
146   assert(fpInterface);
147   if (!fpInterface) return 0;
148   return fpInterface->PreprocessorStoreRunMetadataFile(localFile, gridFileName);
149 }
150     
151 const char* AliHLTModulePreprocessor::GetFile(Int_t system, const char* id, const char* source)
152 {
153   // see header file for function documentation
154
155   assert(fpInterface);
156   if (!fpInterface) return 0;
157   return fpInterface->PreprocessorGetFile(system, id, source);
158 }
159
160 TList* AliHLTModulePreprocessor::GetFileSources(Int_t system, const char* id)
161 {
162   // see header file for function documentation
163
164   assert(fpInterface);
165   if (!fpInterface) return 0;
166   return fpInterface->PreprocessorGetFileSources(system, id);
167 }
168
169 TList* AliHLTModulePreprocessor::GetFileIDs(Int_t system, const char* source)
170 {
171   // see header file for function documentation
172
173   assert(fpInterface);
174   if (!fpInterface) return 0;
175   return fpInterface->PreprocessorGetFileIDs(system, source);
176 }
177
178 const char* AliHLTModulePreprocessor::GetRunParameter(const char* param)
179 {
180   // see header file for function documentation
181
182   assert(fpInterface);
183   if (!fpInterface) return 0;
184   return fpInterface->PreprocessorGetRunParameter(param);
185 }
186
187 AliCDBEntry* AliHLTModulePreprocessor::GetFromOCDB(const char* pathLevel2, const char* pathLevel3)
188 {
189   // see header file for function documentation
190
191   assert(fpInterface);
192   if (!fpInterface) return 0;
193   return fpInterface->PreprocessorGetFromOCDB(pathLevel2, pathLevel3);
194 }
195
196 const char* AliHLTModulePreprocessor::GetRunType()
197 {
198   // see header file for function documentation
199
200   assert(fpInterface);
201   if (!fpInterface) return 0;
202   return fpInterface->PreprocessorGetRunType();
203 }
204
205 void AliHLTModulePreprocessor::Log(const char* message)
206 {
207   // see header file for function documentation
208
209   assert(fpInterface);
210   if (!fpInterface) return;
211   fpInterface->PreprocessorLog(message);
212 }
213
214 Int_t AliHLTModulePreprocessor::DetectorBitMask(const char *detectorName)
215 {
216   // Return the detector index
217   // corresponding to a given
218   // detector name
219   TString detStr = detectorName;
220
221   Int_t iDet;
222   for(iDet = 0; iDet < kNDetectors; iDet++) {
223     if (detStr.CompareTo(fgkDetectorName[iDet],TString::kIgnoreCase) == 0)
224       break;
225   }
226   if (iDet == kNDetectors) 
227     {
228       TString errormessage;
229       errormessage.Form("Invalid detector name: %s !",detectorName);
230       Log(errormessage.Data());
231       return -1;
232     }
233
234   Int_t detectorbitmask = 0;
235   if(iDet > 32)
236     {
237       TString errormessage2;
238       errormessage2.Form("Invalid detector bit position in detectorMask: %d !", iDet);
239       Log(errormessage2.Data());
240       return -1;
241     }
242   
243   detectorbitmask = (1 << iDet);
244   return detectorbitmask;
245 }
246
247 Bool_t AliHLTModulePreprocessor::GetDetectorStatus(Int_t detectorbitmask)
248 {
249   // see header file for function documentation
250   // retrieve list of active detectors from previous run.
251   fActiveDetectors = atoi(AliHLTModulePreprocessor::GetRunParameter("detectorMask"));
252  
253   if((fActiveDetectors & detectorbitmask) != 0)
254     {
255       return 1;
256     }
257   else
258     {
259       return 0;
260     }
261 }
262
263 // function copied from AliDAQ.cxx
264 const char *AliHLTModulePreprocessor::DetectorName(Int_t detectorID)
265 {
266   // Returns the name of particular
267   // detector identified by its index
268   if (detectorID < 0 || detectorID >= kNDetectors) 
269     {
270       TString errormessage;
271       errormessage.Form("Invalid detector index: %d (%d -> %d) !",detectorID,0,kNDetectors-1);
272       Log(errormessage.Data());
273       return "";
274     }
275   return fgkDetectorName[detectorID];
276 }