3 //**************************************************************************
4 //* This file is property of and copyright by the ALICE HLT Project *
5 //* ALICE Experiment at CERN, All rights reserved. *
7 //* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
8 //* for The ALICE HLT Project. *
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 //**************************************************************************
19 // @file AliHLTModulePreprocessor.cxx
20 // @author Matthias Richter
22 // @brief Base class for HLT module preprocessors
27 #include "AliHLTModulePreprocessor.h"
28 #include "AliHLTShuttleInterface.h"
29 #include "TObjString.h"
33 #include "TObjArray.h"
36 ClassImp(AliHLTModulePreprocessor)
38 AliHLTModulePreprocessor::AliHLTModulePreprocessor()
43 // see header file for class documentation
45 // refer to README to build package
47 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
50 AliHLTModulePreprocessor::~AliHLTModulePreprocessor()
52 // see header file for function documentation
55 // TODO: map this constants to AliHLTDAQ class
56 const Int_t AliHLTModulePreprocessor::kNDetectors = 22;
58 const char* AliHLTModulePreprocessor::fgkDetectorName[kNDetectors] =
74 "VZERO", // Name to be changed to V0 ?
84 void AliHLTModulePreprocessor::SetShuttleInterface(AliHLTShuttleInterface* pInterface)
86 assert(fpInterface==NULL || fpInterface==pInterface || pInterface==NULL);
87 fpInterface=pInterface;
90 Int_t AliHLTModulePreprocessor::GetRun() const
92 // see header file for function documentation
95 if (!fpInterface) return 0;
96 return fpInterface->PreprocessorGetRun();
99 UInt_t AliHLTModulePreprocessor::GetStartTime() const
101 // see header file for function documentation
104 if (!fpInterface) return 0;
105 return fpInterface->PreprocessorGetStartTime();
108 UInt_t AliHLTModulePreprocessor::GetEndTime() const
110 // see header file for function documentation
113 if (!fpInterface) return 0;
114 return fpInterface->PreprocessorGetEndTime();
117 Bool_t AliHLTModulePreprocessor::Store(const char* pathLevel2, const char* pathLevel3, TObject* object,
118 AliCDBMetaData* metaData, Int_t validityStart, Bool_t validityInfinite)
120 // see header file for function documentation
123 if (!fpInterface) return 0;
124 return fpInterface->PreprocessorStore(pathLevel2, pathLevel3, object, metaData, validityStart, validityInfinite);
127 Bool_t AliHLTModulePreprocessor::StoreReferenceData(const char* pathLevel2, const char* pathLevel3, TObject* object,
128 AliCDBMetaData* metaData)
130 // see header file for function documentation
133 if (!fpInterface) return 0;
134 return fpInterface->PreprocessorStoreReferenceData(pathLevel2, pathLevel3, object, metaData);
137 Bool_t AliHLTModulePreprocessor::StoreReferenceFile(const char* localFile, const char* gridFileName)
139 // see header file for function documentation
142 if (!fpInterface) return 0;
143 return fpInterface->PreprocessorStoreReferenceFile(localFile, gridFileName);
146 Bool_t AliHLTModulePreprocessor::StoreRunMetadataFile(const char* localFile, const char* gridFileName)
148 // see header file for function documentation
151 if (!fpInterface) return 0;
152 return fpInterface->PreprocessorStoreRunMetadataFile(localFile, gridFileName);
155 const char* AliHLTModulePreprocessor::GetFile(Int_t system, const char* id, const char* source)
157 // see header file for function documentation
160 if (!fpInterface) return 0;
161 return fpInterface->PreprocessorGetFile(system, id, source);
164 TList* AliHLTModulePreprocessor::GetFileSources(Int_t system, const char* id)
166 // see header file for function documentation
169 if (!fpInterface) return 0;
170 return fpInterface->PreprocessorGetFileSources(system, id);
173 TList* AliHLTModulePreprocessor::GetFileIDs(Int_t system, const char* source)
175 // see header file for function documentation
178 if (!fpInterface) return 0;
179 return fpInterface->PreprocessorGetFileIDs(system, source);
182 const char* AliHLTModulePreprocessor::GetRunParameter(const char* param)
184 // see header file for function documentation
187 if (!fpInterface) return 0;
188 return fpInterface->PreprocessorGetRunParameter(param);
191 AliCDBEntry* AliHLTModulePreprocessor::GetFromOCDB(const char* pathLevel2, const char* pathLevel3)
193 // see header file for function documentation
196 if (!fpInterface) return 0;
197 return fpInterface->PreprocessorGetFromOCDB(pathLevel2, pathLevel3);
200 const char* AliHLTModulePreprocessor::GetRunType()
202 // see header file for function documentation
205 if (!fpInterface) return 0;
206 return fpInterface->PreprocessorGetRunType();
209 void AliHLTModulePreprocessor::Log(const char* message)
211 // see header file for function documentation
214 if (!fpInterface) return;
215 fpInterface->PreprocessorLog(message);
218 Int_t AliHLTModulePreprocessor::DetectorBitMask(const char *detectorName)
220 // Return the detector index
221 // corresponding to a given
223 TString detStr = detectorName;
226 for(iDet = 0; iDet < kNDetectors; iDet++) {
227 if (detStr.CompareTo(fgkDetectorName[iDet],TString::kIgnoreCase) == 0)
230 if (iDet == kNDetectors)
232 TString errormessage;
233 errormessage.Form("Invalid detector name: %s !",detectorName);
234 Log(errormessage.Data());
238 Int_t detectorbitmask = 0;
241 TString errormessage2;
242 errormessage2.Form("Invalid detector bit position in detectorMask: %d !", iDet);
243 Log(errormessage2.Data());
247 detectorbitmask = (1 << iDet);
248 return detectorbitmask;
251 Bool_t AliHLTModulePreprocessor::GetDetectorStatus(Int_t detectorbitmask)
253 // see header file for function documentation
254 // retrieve list of active detectors from previous run.
255 fActiveDetectors = atoi(AliHLTModulePreprocessor::GetRunParameter("detectorMask"));
257 if((fActiveDetectors & detectorbitmask) != 0)
267 // function copied from AliDAQ.cxx
268 const char *AliHLTModulePreprocessor::DetectorName(Int_t detectorID)
270 // Returns the name of particular
271 // detector identified by its index
272 if (detectorID < 0 || detectorID >= kNDetectors)
274 TString errormessage;
275 errormessage.Form("Invalid detector index: %d (%d -> %d) !",detectorID,0,kNDetectors-1);
276 Log(errormessage.Data());
279 return fgkDetectorName[detectorID];
282 TObject* AliHLTModulePreprocessor::GetFromMap(TMap* dcsAliasMap, const char* stringId) const
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);