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 = 21;
58 const char* AliHLTModulePreprocessor::fgkDetectorName[kNDetectors] =
74 "VZERO", // Name to be changed to V0 ?
83 void AliHLTModulePreprocessor::SetShuttleInterface(AliHLTShuttleInterface* pInterface)
85 assert(fpInterface==NULL || fpInterface==pInterface || pInterface==NULL);
86 fpInterface=pInterface;
89 Int_t AliHLTModulePreprocessor::GetRun() const
91 // see header file for function documentation
94 if (!fpInterface) return 0;
95 return fpInterface->PreprocessorGetRun();
98 UInt_t AliHLTModulePreprocessor::GetStartTime() const
100 // see header file for function documentation
103 if (!fpInterface) return 0;
104 return fpInterface->PreprocessorGetStartTime();
107 UInt_t AliHLTModulePreprocessor::GetEndTime() const
109 // see header file for function documentation
112 if (!fpInterface) return 0;
113 return fpInterface->PreprocessorGetEndTime();
116 Bool_t AliHLTModulePreprocessor::Store(const char* pathLevel2, const char* pathLevel3, TObject* object,
117 AliCDBMetaData* metaData, Int_t validityStart, Bool_t validityInfinite)
119 // see header file for function documentation
122 if (!fpInterface) return 0;
123 return fpInterface->PreprocessorStore(pathLevel2, pathLevel3, object, metaData, validityStart, validityInfinite);
126 Bool_t AliHLTModulePreprocessor::StoreReferenceData(const char* pathLevel2, const char* pathLevel3, TObject* object,
127 AliCDBMetaData* metaData)
129 // see header file for function documentation
132 if (!fpInterface) return 0;
133 return fpInterface->PreprocessorStoreReferenceData(pathLevel2, pathLevel3, object, metaData);
136 Bool_t AliHLTModulePreprocessor::StoreReferenceFile(const char* localFile, const char* gridFileName)
138 // see header file for function documentation
141 if (!fpInterface) return 0;
142 return fpInterface->PreprocessorStoreReferenceFile(localFile, gridFileName);
145 Bool_t AliHLTModulePreprocessor::StoreRunMetadataFile(const char* localFile, const char* gridFileName)
147 // see header file for function documentation
150 if (!fpInterface) return 0;
151 return fpInterface->PreprocessorStoreRunMetadataFile(localFile, gridFileName);
154 const char* AliHLTModulePreprocessor::GetFile(Int_t system, const char* id, const char* source)
156 // see header file for function documentation
159 if (!fpInterface) return 0;
160 return fpInterface->PreprocessorGetFile(system, id, source);
163 TList* AliHLTModulePreprocessor::GetFileSources(Int_t system, const char* id)
165 // see header file for function documentation
168 if (!fpInterface) return 0;
169 return fpInterface->PreprocessorGetFileSources(system, id);
172 TList* AliHLTModulePreprocessor::GetFileIDs(Int_t system, const char* source)
174 // see header file for function documentation
177 if (!fpInterface) return 0;
178 return fpInterface->PreprocessorGetFileIDs(system, source);
181 const char* AliHLTModulePreprocessor::GetRunParameter(const char* param)
183 // see header file for function documentation
186 if (!fpInterface) return 0;
187 return fpInterface->PreprocessorGetRunParameter(param);
190 AliCDBEntry* AliHLTModulePreprocessor::GetFromOCDB(const char* pathLevel2, const char* pathLevel3)
192 // see header file for function documentation
195 if (!fpInterface) return 0;
196 return fpInterface->PreprocessorGetFromOCDB(pathLevel2, pathLevel3);
199 const char* AliHLTModulePreprocessor::GetRunType()
201 // see header file for function documentation
204 if (!fpInterface) return 0;
205 return fpInterface->PreprocessorGetRunType();
208 void AliHLTModulePreprocessor::Log(const char* message)
210 // see header file for function documentation
213 if (!fpInterface) return;
214 fpInterface->PreprocessorLog(message);
217 Int_t AliHLTModulePreprocessor::DetectorBitMask(const char *detectorName)
219 // Return the detector index
220 // corresponding to a given
222 TString detStr = detectorName;
225 for(iDet = 0; iDet < kNDetectors; iDet++) {
226 if (detStr.CompareTo(fgkDetectorName[iDet],TString::kIgnoreCase) == 0)
229 if (iDet == kNDetectors)
231 TString errormessage;
232 errormessage.Form("Invalid detector name: %s !",detectorName);
233 Log(errormessage.Data());
237 Int_t detectorbitmask = 0;
240 TString errormessage2;
241 errormessage2.Form("Invalid detector bit position in detectorMask: %d !", iDet);
242 Log(errormessage2.Data());
246 detectorbitmask = (1 << iDet);
247 return detectorbitmask;
250 Bool_t AliHLTModulePreprocessor::GetDetectorStatus(Int_t detectorbitmask)
252 // see header file for function documentation
253 // retrieve list of active detectors from previous run.
254 fActiveDetectors = atoi(AliHLTModulePreprocessor::GetRunParameter("detectorMask"));
256 if((fActiveDetectors & detectorbitmask) != 0)
266 // function copied from AliDAQ.cxx
267 const char *AliHLTModulePreprocessor::DetectorName(Int_t detectorID)
269 // Returns the name of particular
270 // detector identified by its index
271 if (detectorID < 0 || detectorID >= kNDetectors)
273 TString errormessage;
274 errormessage.Form("Invalid detector index: %d (%d -> %d) !",detectorID,0,kNDetectors-1);
275 Log(errormessage.Data());
278 return fgkDetectorName[detectorID];
281 TObject* AliHLTModulePreprocessor::GetFromMap(TMap* dcsAliasMap, const char* stringId) const
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);