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