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
57 const Int_t AliHLTModulePreprocessor::kNDetectors = 22;
59 const Int_t AliHLTModulePreprocessor::kNDetectors = 21;
62 const char* AliHLTModulePreprocessor::fgkDetectorName[kNDetectors] =
78 "VZERO", // Name to be changed to V0 ?
90 void AliHLTModulePreprocessor::SetShuttleInterface(AliHLTShuttleInterface* pInterface)
92 assert(fpInterface==NULL || fpInterface==pInterface || pInterface==NULL);
93 fpInterface=pInterface;
96 Int_t AliHLTModulePreprocessor::GetRun() const
98 // see header file for function documentation
101 if (!fpInterface) return 0;
102 return fpInterface->PreprocessorGetRun();
105 UInt_t AliHLTModulePreprocessor::GetStartTime() const
107 // see header file for function documentation
110 if (!fpInterface) return 0;
111 return fpInterface->PreprocessorGetStartTime();
114 UInt_t AliHLTModulePreprocessor::GetEndTime() const
116 // see header file for function documentation
119 if (!fpInterface) return 0;
120 return fpInterface->PreprocessorGetEndTime();
123 Bool_t AliHLTModulePreprocessor::Store(const char* pathLevel2, const char* pathLevel3, TObject* object,
124 AliCDBMetaData* metaData, Int_t validityStart, Bool_t validityInfinite)
126 // see header file for function documentation
129 if (!fpInterface) return 0;
130 return fpInterface->PreprocessorStore(pathLevel2, pathLevel3, object, metaData, validityStart, validityInfinite);
133 Bool_t AliHLTModulePreprocessor::StoreReferenceData(const char* pathLevel2, const char* pathLevel3, TObject* object,
134 AliCDBMetaData* metaData)
136 // see header file for function documentation
139 if (!fpInterface) return 0;
140 return fpInterface->PreprocessorStoreReferenceData(pathLevel2, pathLevel3, object, metaData);
143 Bool_t AliHLTModulePreprocessor::StoreReferenceFile(const char* localFile, const char* gridFileName)
145 // see header file for function documentation
148 if (!fpInterface) return 0;
149 return fpInterface->PreprocessorStoreReferenceFile(localFile, gridFileName);
152 Bool_t AliHLTModulePreprocessor::StoreRunMetadataFile(const char* localFile, const char* gridFileName)
154 // see header file for function documentation
157 if (!fpInterface) return 0;
158 return fpInterface->PreprocessorStoreRunMetadataFile(localFile, gridFileName);
161 const char* AliHLTModulePreprocessor::GetFile(Int_t system, const char* id, const char* source)
163 // see header file for function documentation
166 if (!fpInterface) return 0;
167 return fpInterface->PreprocessorGetFile(system, id, source);
170 TList* AliHLTModulePreprocessor::GetFileSources(Int_t system, const char* id)
172 // see header file for function documentation
175 if (!fpInterface) return 0;
176 return fpInterface->PreprocessorGetFileSources(system, id);
179 TList* AliHLTModulePreprocessor::GetFileIDs(Int_t system, const char* source)
181 // see header file for function documentation
184 if (!fpInterface) return 0;
185 return fpInterface->PreprocessorGetFileIDs(system, source);
188 const char* AliHLTModulePreprocessor::GetRunParameter(const char* param)
190 // see header file for function documentation
193 if (!fpInterface) return 0;
194 return fpInterface->PreprocessorGetRunParameter(param);
197 AliCDBEntry* AliHLTModulePreprocessor::GetFromOCDB(const char* pathLevel2, const char* pathLevel3)
199 // see header file for function documentation
202 if (!fpInterface) return 0;
203 return fpInterface->PreprocessorGetFromOCDB(pathLevel2, pathLevel3);
206 const char* AliHLTModulePreprocessor::GetRunType()
208 // see header file for function documentation
211 if (!fpInterface) return 0;
212 return fpInterface->PreprocessorGetRunType();
215 void AliHLTModulePreprocessor::Log(const char* message)
217 // see header file for function documentation
220 if (!fpInterface) return;
221 fpInterface->PreprocessorLog(message);
224 Int_t AliHLTModulePreprocessor::DetectorBitMask(const char *detectorName)
226 // Return the detector index
227 // corresponding to a given
229 TString detStr = detectorName;
232 for(iDet = 0; iDet < kNDetectors; iDet++) {
233 if (detStr.CompareTo(fgkDetectorName[iDet],TString::kIgnoreCase) == 0)
236 if (iDet == kNDetectors)
238 TString errormessage;
239 errormessage.Form("Invalid detector name: %s !",detectorName);
240 Log(errormessage.Data());
244 Int_t detectorbitmask = 0;
247 TString errormessage2;
248 errormessage2.Form("Invalid detector bit position in detectorMask: %d !", iDet);
249 Log(errormessage2.Data());
253 detectorbitmask = (1 << iDet);
254 return detectorbitmask;
257 Bool_t AliHLTModulePreprocessor::GetDetectorStatus(Int_t detectorbitmask)
259 // see header file for function documentation
260 // retrieve list of active detectors from previous run.
261 fActiveDetectors = atoi(AliHLTModulePreprocessor::GetRunParameter("detectorMask"));
263 if((fActiveDetectors & detectorbitmask) != 0)
273 // function copied from AliDAQ.cxx
274 const char *AliHLTModulePreprocessor::DetectorName(Int_t detectorID)
276 // Returns the name of particular
277 // detector identified by its index
278 if (detectorID < 0 || detectorID >= kNDetectors)
280 TString errormessage;
281 errormessage.Form("Invalid detector index: %d (%d -> %d) !",detectorID,0,kNDetectors-1);
282 Log(errormessage.Data());
285 return fgkDetectorName[detectorID];
288 TObject* AliHLTModulePreprocessor::GetFromMap(TMap* dcsAliasMap, const char* stringId) const
290 /// extract object from the alias map
291 /// return the last object from the value set
292 TObject* object=dcsAliasMap->FindObject(stringId);
293 if (!object) return NULL;
294 TPair* pair = dynamic_cast<TPair*>(object);
295 if (pair && pair->Value()) {
296 TObjArray* valueSet = dynamic_cast<TObjArray*>(pair->Value());
297 if (!valueSet) return NULL;
298 Int_t nentriesDCS = valueSet->GetEntriesFast() - 1;
299 if(nentriesDCS>=0 && valueSet->At(nentriesDCS)){
300 return valueSet->At(nentriesDCS);