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