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