]> git.uio.no Git - u/mrichter/AliRoot.git/blame - SHUTTLE/TestShuttle/AliTestShuttle.cxx
MSTU(16) = 2 for all processes.
[u/mrichter/AliRoot.git] / SHUTTLE / TestShuttle / AliTestShuttle.cxx
CommitLineData
5c6b40ae 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
16/*
17$Log$
18Revision 1.2 2006/03/07 07:52:34 hristov
19New version (B.Yordanov)
20
21Revision 1.3 2005/11/17 17:47:34 byordano
22TList changed to TObjArray
23
24Revision 1.2 2005/11/17 14:43:22 byordano
25import to local CVS
26
27Revision 1.1.1.1 2005/10/28 07:33:58 hristov
28Initial import as subdirectory in AliRoot
29
30Revision 1.1.1.1 2005/09/12 22:11:40 byordano
31SHUTTLE package
32
33Revision 1.2 2005/08/29 21:15:47 byordano
34some docs added
35
36*/
37
38//
39// test implementation of the AliShuttleInterface, to be used for local tests of preprocessors
40//
41// reads files from the local disk
42// stores to local CDB
43// logs to the screen
44//
45
46#include "AliTestShuttle.h"
47#include "AliLog.h"
48
49#include "AliCDBManager.h"
50#include "AliCDBMetaData.h"
51#include "AliCDBId.h"
52
53#include <TMap.h>
54#include <TList.h>
55#include <TString.h>
56#include <TObjString.h>
57
58ClassImp(AliTestShuttle)
59
60AliTestShuttle::AliTestShuttle(TMap* inputFiles) : fInputFiles(inputFiles)
61{
62 // constructor
63 // inputFiles contains the map of local files that can be retrieved by the preprocessor
64 // check TestPreprocessor.C for an example of its structure
65}
66
67AliTestShuttle::~AliTestShuttle()
68{
69 // destructor
70}
71
72Int_t AliTestShuttle::Store(const char* detector, TObject* object, AliCDBMetaData* metaData)
73{
74 // Stores the CDB object
75 // This function should be called at the end of the preprocessor cycle
76 //
77 // This implementation just stores it on the local disk, the full AliShuttle
78 // puts it to the Grid FileCatalog
79
80 AliCDBId id(Form("%s/SHUTTLE/Data", detector), 0, 0);
81
82 AliCDBManager::Instance()->Put(object, id, metaData);
83
84 return -1;
85}
86
87const char* AliTestShuttle::GetFile(Int_t system, const char* detector, const char* id, const char* source)
88{
89 // This function retrieves a file from the given system (kDAQ, kDCS, kHLT) with the given file id
90 // and from the given source in the system.
91 // The function returnes the path to the local file.
92 //
93 // test implementation of GetFile
94 // takes files from the local disks, files are passen in a TMap in the constructor
95
96 TString key;
97 key.Form("%s-%s-%s", fkSystemNames[system], detector, id);
98 TPair* sourceListPair = dynamic_cast<TPair*> (fInputFiles->FindObject(key.Data()));
99 TMap* sourceList = 0;
100 if (sourceListPair)
101 sourceList = dynamic_cast<TMap*> (sourceListPair->Value());
102 if (!sourceList)
103 {
104 AliError(Form("Could not find any file in %s with id %s (%s)", fkSystemNames[system], id, key.Data()));
105 return 0;
106 }
107
108 TPair* fileNamePair = dynamic_cast<TPair*> (sourceList->FindObject(source));
109 TObjString* fileName = dynamic_cast<TObjString*> (fileNamePair->Value());
110 if (!fileName)
111 {
112 AliError(Form("Could not find files from source %s in %s with id %s", source, fkSystemNames[system], id));
113 return 0;
114 }
115
116 return fileName->GetString().Data();
117}
118
119TList* AliTestShuttle::GetFileSources(Int_t system, const char* detector, const char* id)
120{
121 // Returns a list of sources in a given system that saved a file with the given id
122 //
123 // test implementation of GetFileSources
124 // takes files from the local disks, files are passen in a TMap in the constructor
125
126 TString key;
127 key.Form("%s-%s-%s", fkSystemNames[system], detector, id);
128 TPair* sourceListPair = dynamic_cast<TPair*> (fInputFiles->FindObject(key.Data()));
129 TMap* sourceList = 0;
130 if (sourceListPair)
131 sourceList = dynamic_cast<TMap*> (sourceListPair->Value());
132 if (!sourceList)
133 {
134 AliError(Form("Could not find any file in %s with id %s (%s)", fkSystemNames[system], id, key.Data()));
135 return 0;
136 }
137
138 TIterator* iter = sourceList->GetTable()->MakeIterator();
139 TObject* obj = 0;
140 TList* list = new TList;
141 while ((obj = iter->Next()))
142 {
143 TPair* pair = dynamic_cast<TPair*> (obj);
144 if (pair)
145 list->Add(pair->Key());
146 }
147
148 delete iter;
149
150 return list;
151}
152
153void AliTestShuttle::Log(const char* detector, const char* message)
154{
155 // test implementation of Log
156 // just prints to the screen
157
158 AliInfo(Form("%s: %s", detector, message));
159}
160