]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/BASE/AliHLTModulePreprocessor.cxx
using TObjString::String instead of GetString to get directly to reference to TString...
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTModulePreprocessor.cxx
CommitLineData
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
36ClassImp(AliHLTModulePreprocessor)
37
83cb7e1d 38AliHLTModulePreprocessor::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
50AliHLTModulePreprocessor::~AliHLTModulePreprocessor()
51{
52 // see header file for function documentation
53}
54
aa8989c7 55// TODO: map this constants to AliHLTDAQ class
d83b59c6 56const Int_t AliHLTModulePreprocessor::kNDetectors = 21;
57
58const 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",
80 "HLT"
81};
82
310c7637 83void AliHLTModulePreprocessor::SetShuttleInterface(AliHLTShuttleInterface* pInterface)
12ec5482 84{
310c7637 85 assert(fpInterface==NULL || fpInterface==pInterface || pInterface==NULL);
86 fpInterface=pInterface;
12ec5482 87}
88
5b2ee212 89Int_t AliHLTModulePreprocessor::GetRun() const
12ec5482 90{
91 // see header file for function documentation
92
310c7637 93 assert(fpInterface);
94 if (!fpInterface) return 0;
95 return fpInterface->PreprocessorGetRun();
12ec5482 96}
97
5b2ee212 98UInt_t AliHLTModulePreprocessor::GetStartTime() const
12ec5482 99{
100 // see header file for function documentation
101
310c7637 102 assert(fpInterface);
103 if (!fpInterface) return 0;
104 return fpInterface->PreprocessorGetStartTime();
12ec5482 105}
106
5b2ee212 107UInt_t AliHLTModulePreprocessor::GetEndTime() const
12ec5482 108{
109 // see header file for function documentation
110
310c7637 111 assert(fpInterface);
112 if (!fpInterface) return 0;
113 return fpInterface->PreprocessorGetEndTime();
12ec5482 114}
115
116Bool_t AliHLTModulePreprocessor::Store(const char* pathLevel2, const char* pathLevel3, TObject* object,
117 AliCDBMetaData* metaData, Int_t validityStart, Bool_t validityInfinite)
118{
119 // see header file for function documentation
120
310c7637 121 assert(fpInterface);
122 if (!fpInterface) return 0;
123 return fpInterface->PreprocessorStore(pathLevel2, pathLevel3, object, metaData, validityStart, validityInfinite);
12ec5482 124}
125
126Bool_t AliHLTModulePreprocessor::StoreReferenceData(const char* pathLevel2, const char* pathLevel3, TObject* object,
127 AliCDBMetaData* metaData)
128{
129 // see header file for function documentation
130
310c7637 131 assert(fpInterface);
132 if (!fpInterface) return 0;
133 return fpInterface->PreprocessorStoreReferenceData(pathLevel2, pathLevel3, object, metaData);
12ec5482 134}
135
136Bool_t AliHLTModulePreprocessor::StoreReferenceFile(const char* localFile, const char* gridFileName)
137{
138 // see header file for function documentation
139
310c7637 140 assert(fpInterface);
141 if (!fpInterface) return 0;
142 return fpInterface->PreprocessorStoreReferenceFile(localFile, gridFileName);
12ec5482 143}
144
145Bool_t AliHLTModulePreprocessor::StoreRunMetadataFile(const char* localFile, const char* gridFileName)
146{
147 // see header file for function documentation
148
310c7637 149 assert(fpInterface);
150 if (!fpInterface) return 0;
151 return fpInterface->PreprocessorStoreRunMetadataFile(localFile, gridFileName);
12ec5482 152}
153
154const char* AliHLTModulePreprocessor::GetFile(Int_t system, const char* id, const char* source)
155{
156 // see header file for function documentation
157
310c7637 158 assert(fpInterface);
159 if (!fpInterface) return 0;
160 return fpInterface->PreprocessorGetFile(system, id, source);
12ec5482 161}
162
163TList* AliHLTModulePreprocessor::GetFileSources(Int_t system, const char* id)
164{
165 // see header file for function documentation
166
310c7637 167 assert(fpInterface);
168 if (!fpInterface) return 0;
169 return fpInterface->PreprocessorGetFileSources(system, id);
12ec5482 170}
171
172TList* AliHLTModulePreprocessor::GetFileIDs(Int_t system, const char* source)
173{
174 // see header file for function documentation
175
310c7637 176 assert(fpInterface);
177 if (!fpInterface) return 0;
178 return fpInterface->PreprocessorGetFileIDs(system, source);
12ec5482 179}
180
181const char* AliHLTModulePreprocessor::GetRunParameter(const char* param)
182{
183 // see header file for function documentation
184
310c7637 185 assert(fpInterface);
186 if (!fpInterface) return 0;
187 return fpInterface->PreprocessorGetRunParameter(param);
12ec5482 188}
189
190AliCDBEntry* AliHLTModulePreprocessor::GetFromOCDB(const char* pathLevel2, const char* pathLevel3)
191{
192 // see header file for function documentation
193
310c7637 194 assert(fpInterface);
195 if (!fpInterface) return 0;
196 return fpInterface->PreprocessorGetFromOCDB(pathLevel2, pathLevel3);
12ec5482 197}
198
199const char* AliHLTModulePreprocessor::GetRunType()
200{
201 // see header file for function documentation
202
310c7637 203 assert(fpInterface);
204 if (!fpInterface) return 0;
205 return fpInterface->PreprocessorGetRunType();
12ec5482 206}
207
208void AliHLTModulePreprocessor::Log(const char* message)
209{
210 // see header file for function documentation
211
310c7637 212 assert(fpInterface);
213 if (!fpInterface) return;
214 fpInterface->PreprocessorLog(message);
12ec5482 215}
d83b59c6 216
217Int_t AliHLTModulePreprocessor::DetectorBitMask(const char *detectorName)
218{
219 // Return the detector index
220 // corresponding to a given
221 // detector name
222 TString detStr = detectorName;
223
224 Int_t iDet;
225 for(iDet = 0; iDet < kNDetectors; iDet++) {
226 if (detStr.CompareTo(fgkDetectorName[iDet],TString::kIgnoreCase) == 0)
227 break;
228 }
229 if (iDet == kNDetectors)
230 {
231 TString errormessage;
232 errormessage.Form("Invalid detector name: %s !",detectorName);
233 Log(errormessage.Data());
234 return -1;
235 }
236
237 Int_t detectorbitmask = 0;
238 if(iDet > 32)
239 {
240 TString errormessage2;
241 errormessage2.Form("Invalid detector bit position in detectorMask: %d !", iDet);
242 Log(errormessage2.Data());
243 return -1;
244 }
245
246 detectorbitmask = (1 << iDet);
247 return detectorbitmask;
248}
249
250Bool_t AliHLTModulePreprocessor::GetDetectorStatus(Int_t detectorbitmask)
251{
252 // see header file for function documentation
253 // retrieve list of active detectors from previous run.
254 fActiveDetectors = atoi(AliHLTModulePreprocessor::GetRunParameter("detectorMask"));
255
256 if((fActiveDetectors & detectorbitmask) != 0)
257 {
258 return 1;
259 }
260 else
261 {
262 return 0;
263 }
264}
265
266// function copied from AliDAQ.cxx
267const char *AliHLTModulePreprocessor::DetectorName(Int_t detectorID)
268{
269 // Returns the name of particular
270 // detector identified by its index
271 if (detectorID < 0 || detectorID >= kNDetectors)
272 {
273 TString errormessage;
274 errormessage.Form("Invalid detector index: %d (%d -> %d) !",detectorID,0,kNDetectors-1);
275 Log(errormessage.Data());
276 return "";
277 }
278 return fgkDetectorName[detectorID];
279}
aa8989c7 280
281TObject* AliHLTModulePreprocessor::GetFromMap(TMap* dcsAliasMap, const char* stringId) const
282{
283 /// extract object from the alias map
284 /// return the last object from the value set
285 TObject* object=dcsAliasMap->FindObject(stringId);
286 if (!object) return NULL;
287 TPair* pair = dynamic_cast<TPair*>(object);
288 if (pair && pair->Value()) {
289 TObjArray* valueSet = dynamic_cast<TObjArray*>(pair->Value());
290 if (!valueSet) return NULL;
291 Int_t nentriesDCS = valueSet->GetEntriesFast() - 1;
292 if(nentriesDCS>=0 && valueSet->At(nentriesDCS)){
293 return valueSet->At(nentriesDCS);
294 }
295 }
296 return NULL;
297}