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.2 2006/06/06 14:20:05 jgrosseo
19 o) updated test preprocessor (alberto)
20 o) added comments to example macro
21 o) test shuttle implements new interface
23 Revision 1.2 2006/03/07 07:52:34 hristov
24 New version (B.Yordanov)
26 Revision 1.3 2005/11/17 17:47:34 byordano
27 TList changed to TObjArray
29 Revision 1.2 2005/11/17 14:43:22 byordano
32 Revision 1.1.1.1 2005/10/28 07:33:58 hristov
33 Initial import as subdirectory in AliRoot
35 Revision 1.1.1.1 2005/09/12 22:11:40 byordano
38 Revision 1.2 2005/08/29 21:15:47 byordano
44 // test implementation of the AliShuttleInterface, to be used for local tests of preprocessors
46 // reads files from the local disk
47 // stores to local CDB
51 #include "AliTestShuttle.h"
54 #include "AliCDBManager.h"
55 #include "AliCDBMetaData.h"
57 #include "AliPreprocessor.h"
62 #include <TObjString.h>
64 ClassImp(AliTestShuttle)
66 //______________________________________________________________________________________________
67 AliTestShuttle::AliTestShuttle(Int_t run, UInt_t startTime, UInt_t endTime) :
69 fStartTime(startTime),
77 fInputFiles = new TMap;
78 fPreprocessors = new TObjArray;
81 //______________________________________________________________________________________________
82 AliTestShuttle::~AliTestShuttle()
89 delete fPreprocessors;
96 //______________________________________________________________________________________________
97 UInt_t AliTestShuttle::Store(const char* detector, TObject* object, AliCDBMetaData* metaData, Int_t validityStart, Bool_t validityInfinite)
99 // Stores the CDB object
100 // This function should be called at the end of the preprocessor cycle
102 // This implementation just stores it on the local disk, the full AliShuttle
103 // puts it to the Grid FileCatalog
106 Int_t startRun = fRun;
109 if (validityStart > 0)
110 startRun -= validityStart;
112 // TODO put define for infinite
113 if (validityInfinite != kFALSE)
116 AliCDBId id(Form("%s/SHUTTLE/Data", detector), startRun, endRun);
118 return AliCDBManager::Instance()->Put(object, id, metaData);
121 //______________________________________________________________________________________________
122 const char* AliTestShuttle::GetFile(Int_t system, const char* detector, const char* id, const char* source)
124 // This function retrieves a file from the given system (kDAQ, kDCS, kHLT) with the given file id
125 // and from the given source in the system.
126 // The function returnes the path to the local file.
128 // test implementation of GetFile
129 // takes files from the local disks, files are passen in a TMap in the constructor
132 key.Form("%s-%s-%s", fkSystemNames[system], detector, id);
133 TPair* sourceListPair = dynamic_cast<TPair*> (fInputFiles->FindObject(key.Data()));
134 TMap* sourceList = 0;
136 sourceList = dynamic_cast<TMap*> (sourceListPair->Value());
139 AliError(Form("Could not find any file in %s with id %s (%s)", fkSystemNames[system], id, key.Data()));
143 TPair* fileNamePair = dynamic_cast<TPair*> (sourceList->FindObject(source));
144 TObjString* fileName = dynamic_cast<TObjString*> (fileNamePair->Value());
147 AliError(Form("Could not find files from source %s in %s with id %s",
148 source, fkSystemNames[system], id));
152 return fileName->GetString().Data();
155 //______________________________________________________________________________________________
156 TList* AliTestShuttle::GetFileSources(Int_t system, const char* detector, const char* id)
158 // Returns a list of sources in a given system that saved a file with the given id
160 // test implementation of GetFileSources
161 // takes files from the local disks, files are passen in a TMap in the constructor
164 key.Form("%s-%s-%s", fkSystemNames[system], detector, id);
165 TPair* sourceListPair = dynamic_cast<TPair*> (fInputFiles->FindObject(key.Data()));
166 TMap* sourceList = 0;
168 sourceList = dynamic_cast<TMap*> (sourceListPair->Value());
171 AliError(Form("Could not find any file in %s with id %s (%s)", fkSystemNames[system], id, key.Data()));
175 TIterator* iter = sourceList->GetTable()->MakeIterator();
177 TList* list = new TList;
178 while ((obj = iter->Next()))
180 TPair* pair = dynamic_cast<TPair*> (obj);
182 list->Add(pair->Key());
190 //______________________________________________________________________________________________
191 void AliTestShuttle::Log(const char* detector, const char* message)
193 // test implementation of Log
194 // just prints to the screen
196 AliInfo(Form("%s: %s", detector, message));
199 //______________________________________________________________________________________________
200 void AliTestShuttle::AddInputFile(Int_t system, const char* detector, const char* id, const char* source, const char* fileName)
202 // This function adds a file to the list of input files
205 key.Form("%s-%s-%s", fkSystemNames[system], detector, id);
206 TPair* sourceListPair = dynamic_cast<TPair*> (fInputFiles->FindObject(key.Data()));
207 TMap* sourceList = 0;
209 sourceList = dynamic_cast<TMap*> (sourceListPair->Value());
212 sourceList = new TMap;
213 fInputFiles->Add(new TObjString(key), sourceList);
216 sourceList->Add(new TObjString(source), new TObjString(fileName));
219 //______________________________________________________________________________________________
220 void AliTestShuttle::Process()
222 // This function tests all preprocessors that are registered to it
223 // All preprocessors get the same dcs alias map and have access to the same list of files.
225 for (Int_t i=0; i<fPreprocessors->GetEntries(); ++i)
227 AliPreprocessor* preprocessor = dynamic_cast<AliPreprocessor*> (fPreprocessors->At(i));
230 preprocessor->Initialize(fRun, fStartTime, fEndTime);
231 preprocessor->Process(fDcsAliasMap);
236 //______________________________________________________________________________________________
237 void AliTestShuttle::RegisterPreprocessor(AliPreprocessor* preprocessor)
239 // registers a preprocessor
241 fPreprocessors->Add(preprocessor);