]>
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 | ||
19 | /** | |
20 | * @file AliHLTModulePreprocessor.cxx | |
21 | * @author Matthias Richter | |
22 | * @date 2008-01-22 | |
23 | * @brief Base class for HLT module preprocessors | |
24 | */ | |
25 | ||
b09247a2 | 26 | #include <cstdlib> |
12ec5482 | 27 | #include <cassert> |
28 | #include "AliHLTModulePreprocessor.h" | |
310c7637 | 29 | #include "AliHLTShuttleInterface.h" |
d83b59c6 | 30 | #include "TObjString.h" |
31 | #include "TString.h" | |
32 | ||
12ec5482 | 33 | |
34 | ClassImp(AliHLTModulePreprocessor) | |
35 | ||
83cb7e1d | 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 | ||
d83b59c6 | 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 | ||
310c7637 | 80 | void AliHLTModulePreprocessor::SetShuttleInterface(AliHLTShuttleInterface* pInterface) |
12ec5482 | 81 | { |
310c7637 | 82 | assert(fpInterface==NULL || fpInterface==pInterface || pInterface==NULL); |
83 | fpInterface=pInterface; | |
12ec5482 | 84 | } |
85 | ||
86 | Int_t AliHLTModulePreprocessor::GetRun() | |
87 | { | |
88 | // see header file for function documentation | |
89 | ||
310c7637 | 90 | assert(fpInterface); |
91 | if (!fpInterface) return 0; | |
92 | return fpInterface->PreprocessorGetRun(); | |
12ec5482 | 93 | } |
94 | ||
95 | UInt_t AliHLTModulePreprocessor::GetStartTime() | |
96 | { | |
97 | // see header file for function documentation | |
98 | ||
310c7637 | 99 | assert(fpInterface); |
100 | if (!fpInterface) return 0; | |
101 | return fpInterface->PreprocessorGetStartTime(); | |
12ec5482 | 102 | } |
103 | ||
104 | UInt_t AliHLTModulePreprocessor::GetEndTime() | |
105 | { | |
106 | // see header file for function documentation | |
107 | ||
310c7637 | 108 | assert(fpInterface); |
109 | if (!fpInterface) return 0; | |
110 | return fpInterface->PreprocessorGetEndTime(); | |
12ec5482 | 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 | ||
310c7637 | 118 | assert(fpInterface); |
119 | if (!fpInterface) return 0; | |
120 | return fpInterface->PreprocessorStore(pathLevel2, pathLevel3, object, metaData, validityStart, validityInfinite); | |
12ec5482 | 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 | ||
310c7637 | 128 | assert(fpInterface); |
129 | if (!fpInterface) return 0; | |
130 | return fpInterface->PreprocessorStoreReferenceData(pathLevel2, pathLevel3, object, metaData); | |
12ec5482 | 131 | } |
132 | ||
133 | Bool_t AliHLTModulePreprocessor::StoreReferenceFile(const char* localFile, const char* gridFileName) | |
134 | { | |
135 | // see header file for function documentation | |
136 | ||
310c7637 | 137 | assert(fpInterface); |
138 | if (!fpInterface) return 0; | |
139 | return fpInterface->PreprocessorStoreReferenceFile(localFile, gridFileName); | |
12ec5482 | 140 | } |
141 | ||
142 | Bool_t AliHLTModulePreprocessor::StoreRunMetadataFile(const char* localFile, const char* gridFileName) | |
143 | { | |
144 | // see header file for function documentation | |
145 | ||
310c7637 | 146 | assert(fpInterface); |
147 | if (!fpInterface) return 0; | |
148 | return fpInterface->PreprocessorStoreRunMetadataFile(localFile, gridFileName); | |
12ec5482 | 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 | ||
310c7637 | 155 | assert(fpInterface); |
156 | if (!fpInterface) return 0; | |
157 | return fpInterface->PreprocessorGetFile(system, id, source); | |
12ec5482 | 158 | } |
159 | ||
160 | TList* AliHLTModulePreprocessor::GetFileSources(Int_t system, const char* id) | |
161 | { | |
162 | // see header file for function documentation | |
163 | ||
310c7637 | 164 | assert(fpInterface); |
165 | if (!fpInterface) return 0; | |
166 | return fpInterface->PreprocessorGetFileSources(system, id); | |
12ec5482 | 167 | } |
168 | ||
169 | TList* AliHLTModulePreprocessor::GetFileIDs(Int_t system, const char* source) | |
170 | { | |
171 | // see header file for function documentation | |
172 | ||
310c7637 | 173 | assert(fpInterface); |
174 | if (!fpInterface) return 0; | |
175 | return fpInterface->PreprocessorGetFileIDs(system, source); | |
12ec5482 | 176 | } |
177 | ||
178 | const char* AliHLTModulePreprocessor::GetRunParameter(const char* param) | |
179 | { | |
180 | // see header file for function documentation | |
181 | ||
310c7637 | 182 | assert(fpInterface); |
183 | if (!fpInterface) return 0; | |
184 | return fpInterface->PreprocessorGetRunParameter(param); | |
12ec5482 | 185 | } |
186 | ||
187 | AliCDBEntry* AliHLTModulePreprocessor::GetFromOCDB(const char* pathLevel2, const char* pathLevel3) | |
188 | { | |
189 | // see header file for function documentation | |
190 | ||
310c7637 | 191 | assert(fpInterface); |
192 | if (!fpInterface) return 0; | |
193 | return fpInterface->PreprocessorGetFromOCDB(pathLevel2, pathLevel3); | |
12ec5482 | 194 | } |
195 | ||
196 | const char* AliHLTModulePreprocessor::GetRunType() | |
197 | { | |
198 | // see header file for function documentation | |
199 | ||
310c7637 | 200 | assert(fpInterface); |
201 | if (!fpInterface) return 0; | |
202 | return fpInterface->PreprocessorGetRunType(); | |
12ec5482 | 203 | } |
204 | ||
205 | void AliHLTModulePreprocessor::Log(const char* message) | |
206 | { | |
207 | // see header file for function documentation | |
208 | ||
310c7637 | 209 | assert(fpInterface); |
210 | if (!fpInterface) return; | |
211 | fpInterface->PreprocessorLog(message); | |
12ec5482 | 212 | } |
d83b59c6 | 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 | } |