1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 Revision 1.3 2006/07/11 12:44:32 jgrosseo
19 adding parameters for extended validity range of data produced by preprocessor
21 Revision 1.2 2006/06/06 14:20:05 jgrosseo
22 o) updated test preprocessor (alberto)
23 o) added comments to example macro
24 o) test shuttle implements new interface
26 Revision 1.2 2006/03/07 07:52:34 hristov
27 New version (B.Yordanov)
29 Revision 1.3 2005/11/17 17:47:34 byordano
30 TList changed to TObjArray
32 Revision 1.2 2005/11/17 14:43:22 byordano
35 Revision 1.1.1.1 2005/10/28 07:33:58 hristov
36 Initial import as subdirectory in AliRoot
38 Revision 1.1.1.1 2005/09/12 22:11:40 byordano
41 Revision 1.2 2005/08/29 21:15:47 byordano
47 // test implementation of the AliShuttleInterface, to be used for local tests of preprocessors
49 // reads files from the local disk
50 // stores to local CDB
54 #include "AliTestShuttle.h"
57 #include "AliCDBManager.h"
58 #include "AliCDBStorage.h"
59 #include "AliCDBMetaData.h"
60 #include "AliCDBPath.h"
62 #include "AliPreprocessor.h"
67 #include <TObjString.h>
69 ClassImp(AliTestShuttle)
71 //______________________________________________________________________________________________
72 AliTestShuttle::AliTestShuttle(Int_t run, UInt_t startTime, UInt_t endTime) :
74 fStartTime(startTime),
82 fInputFiles = new TMap;
83 fPreprocessors = new TObjArray;
86 //______________________________________________________________________________________________
87 AliTestShuttle::~AliTestShuttle()
94 delete fPreprocessors;
101 //______________________________________________________________________________________________
102 UInt_t AliTestShuttle::Store(const AliCDBPath& path, TObject* object, AliCDBMetaData* metaData,
103 Int_t validityStart, Bool_t validityInfinite)
105 // Stores the CDB object
106 // This function should be called at the end of the preprocessor cycle
108 // This implementation just stores it on the local disk, the full AliShuttle
109 // puts it to the Grid FileCatalog
111 Int_t startRun = fRun - validityStart;
113 AliError("First valid run happens to be less than 0! Setting it to 0...");
118 if(validityInfinite) {
119 endRun = AliCDBRunRange::Infinity();
124 AliCDBId id(path, startRun, endRun);
126 return AliCDBManager::Instance()->Put(object, id, metaData);
129 //______________________________________________________________________________________________
130 UInt_t AliTestShuttle::StoreReferenceData(const AliCDBPath& path, TObject* object, AliCDBMetaData* metaData,
131 Int_t validityStart, Bool_t validityInfinite)
134 // Stores the object as reference data
135 // This function should be called at the end of the preprocessor cycle
137 // This implementation just stores it on the local disk, the full AliShuttle
138 // puts it to the Grid FileCatalog
140 Int_t startRun = fRun - validityStart;
142 AliError("First valid run happens to be less than 0! Setting it to 0...");
147 if(validityInfinite) {
148 endRun = AliCDBRunRange::Infinity();
153 AliCDBId id(path, startRun, endRun);
155 return AliCDBManager::Instance()->GetStorage("local://ReferenceStorage")->Put(object, id, metaData);
158 //______________________________________________________________________________________________
159 const char* AliTestShuttle::GetFile(Int_t system, const char* detector, const char* id, const char* source)
161 // This function retrieves a file from the given system (kDAQ, kDCS, kHLT) with the given file id
162 // and from the given source in the system.
163 // The function returnes the path to the local file.
165 // test implementation of GetFile
166 // takes files from the local disks, files are passen in a TMap in the constructor
169 key.Form("%s-%s-%s", fkSystemNames[system], detector, id);
170 TPair* sourceListPair = dynamic_cast<TPair*> (fInputFiles->FindObject(key.Data()));
171 TMap* sourceList = 0;
173 sourceList = dynamic_cast<TMap*> (sourceListPair->Value());
176 AliError(Form("Could not find any file in %s with id %s (%s)", fkSystemNames[system], id, key.Data()));
180 TPair* fileNamePair = dynamic_cast<TPair*> (sourceList->FindObject(source));
181 TObjString* fileName = dynamic_cast<TObjString*> (fileNamePair->Value());
184 AliError(Form("Could not find files from source %s in %s with id %s",
185 source, fkSystemNames[system], id));
189 return fileName->GetString().Data();
192 //______________________________________________________________________________________________
193 TList* AliTestShuttle::GetFileSources(Int_t system, const char* detector, const char* id)
195 // Returns a list of sources in a given system that saved a file with the given id
197 // test implementation of GetFileSources
198 // takes files from the local disks, files are passen in a TMap in the constructor
201 key.Form("%s-%s-%s", fkSystemNames[system], detector, id);
202 TPair* sourceListPair = dynamic_cast<TPair*> (fInputFiles->FindObject(key.Data()));
203 TMap* sourceList = 0;
205 sourceList = dynamic_cast<TMap*> (sourceListPair->Value());
208 AliError(Form("Could not find any file in %s with id %s (%s)", fkSystemNames[system], id, key.Data()));
212 TIterator* iter = sourceList->GetTable()->MakeIterator();
214 TList* list = new TList;
215 while ((obj = iter->Next()))
217 TPair* pair = dynamic_cast<TPair*> (obj);
219 list->Add(pair->Key());
227 //______________________________________________________________________________________________
228 void AliTestShuttle::Log(const char* detector, const char* message)
230 // test implementation of Log
231 // just prints to the screen
233 AliInfo(Form("%s: %s", detector, message));
236 //______________________________________________________________________________________________
237 void AliTestShuttle::AddInputFile(Int_t system, const char* detector, const char* id, const char* source, const char* fileName)
239 // This function adds a file to the list of input files
242 key.Form("%s-%s-%s", fkSystemNames[system], detector, id);
243 TPair* sourceListPair = dynamic_cast<TPair*> (fInputFiles->FindObject(key.Data()));
244 TMap* sourceList = 0;
246 sourceList = dynamic_cast<TMap*> (sourceListPair->Value());
249 sourceList = new TMap;
250 fInputFiles->Add(new TObjString(key), sourceList);
253 sourceList->Add(new TObjString(source), new TObjString(fileName));
256 //______________________________________________________________________________________________
257 void AliTestShuttle::Process()
259 // This function tests all preprocessors that are registered to it
260 // All preprocessors get the same dcs alias map and have access to the same list of files.
262 for (Int_t i=0; i<fPreprocessors->GetEntries(); ++i)
264 AliPreprocessor* preprocessor = dynamic_cast<AliPreprocessor*> (fPreprocessors->At(i));
267 preprocessor->Initialize(fRun, fStartTime, fEndTime);
268 preprocessor->Process(fDcsAliasMap);
273 //______________________________________________________________________________________________
274 void AliTestShuttle::RegisterPreprocessor(AliPreprocessor* preprocessor)
276 // registers a preprocessor
278 fPreprocessors->Add(preprocessor);