]> git.uio.no Git - u/mrichter/AliRoot.git/blame - SHUTTLE/TestShuttle/AliTestPreprocessor.cxx
Switching to retrieval of several DCS DPs at a time (multiDPrequest)
[u/mrichter/AliRoot.git] / SHUTTLE / TestShuttle / AliTestPreprocessor.cxx
CommitLineData
5c6b40ae 1#include "AliTestPreprocessor.h"
2
3#include "AliCDBMetaData.h"
d461a8a7 4#include "AliCDBEntry.h"
5c6b40ae 5#include "AliDCSValue.h"
6#include "AliLog.h"
7#include "AliTestDataDCS.h"
8
9#include <TTimeStamp.h>
d461a8a7 10#include <TObjString.h>
9827400b 11#include <TList.h>
5c6b40ae 12
13//
14// This class is an example for a simple preprocessor.
15// It takes data from DCS and passes it to the class AliTestDataDCS, which
16// reformats its. This class is then written to the CDB.
17//
18
19ClassImp(AliTestPreprocessor)
20
36137ac1 21//______________________________________________________________________________________________
fc5a4708 22AliTestPreprocessor::AliTestPreprocessor(AliShuttleInterface* shuttle) :
23 AliPreprocessor("TPC", shuttle),
5c6b40ae 24 fData(0)
25{
26 // constructor
27}
28
36137ac1 29//______________________________________________________________________________________________
5c6b40ae 30AliTestPreprocessor::~AliTestPreprocessor()
31{
32 // destructor
33}
34
36137ac1 35//______________________________________________________________________________________________
5c6b40ae 36void AliTestPreprocessor::Initialize(Int_t run, UInt_t startTime,
37 UInt_t endTime)
38{
39 // Creates AliTestDataDCS object
40
41 AliPreprocessor::Initialize(run, startTime, endTime);
42
9827400b 43 Log(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run,
5c6b40ae 44 TTimeStamp(startTime).AsString(),
45 TTimeStamp(endTime).AsString()));
46
47 fData = new AliTestDataDCS(fRun, fStartTime, fEndTime);
48}
49
9827400b 50//______________________________________________________________________________________________
51Bool_t AliTestPreprocessor::ProcessDCS()
52{
53 //
54 // decide here if DCS data is to be processed
55 //
56
57 // TODO implement a decision, e.g. based on the run type
58 // In this example: Skip DCS if run type is CALIB
59 if (strcmp(GetRunType(), "CALIB") == 0)
60 return kFALSE;
61
62 return kTRUE;
63}
64
36137ac1 65//______________________________________________________________________________________________
66UInt_t AliTestPreprocessor::Process(TMap* dcsAliasMap)
5c6b40ae 67{
68 // Fills data into a AliTestDataDCS object
69
70 if (!dcsAliasMap)
886d60e6 71 {
72 Log("ERROR: No DCS map provided by SHUTTLE!");
73 return 1;
74 }
75
36137ac1 76 // The processing of the DCS input data is forwarded to AliTestDataDCS
441b0e9c 77 fData->ProcessData(*dcsAliasMap);
5c6b40ae 78
441b0e9c 79 // Example of how to retrieve the run type from the Shuttle, using GetRunType() function
80 // TODO Here the run type for the "DET" detector must be set manually with SetInputRunType function,
81 // in reality it will be read from the "run type" logbook!
82 TString runType = GetRunType();
9827400b 83 Log(Form("Run type for run %d: %s", fRun, runType.Data()));
441b0e9c 84
886d60e6 85 // Example of how to retrieve the list of sources that produced the file with id DRIFTVELOCITY
86 TList* sourceList = GetFileSources(kDAQ, "DRIFTVELOCITY");
87 if (!sourceList)
88 {
89 Log("Error: No sources found for id DRIFTVELOCITY!");
90 return 1;
91 }
92
93 // TODO We have the list of sources that produced the files with Id DRIFTVELOCITY.
94 // Now we will loop on the list and we'll query the files one by one.
95 Log("The following sources produced files with the id DRIFTVELOCITY");
96 sourceList->Print();
4a33bdd9 97
886d60e6 98 TIter iter(sourceList);
99 TObjString *source = 0;
100 while((source=dynamic_cast<TObjString*> (iter.Next()))){
101 TString fileName = GetFile(kDAQ, "DRIFTVELOCITY", source->GetName());
102 if (fileName.Length() > 0)
103 Log(Form("Got the file %s, now we can extract some values.", fileName.Data()));
104 }
36137ac1 105
886d60e6 106 delete sourceList;
107
4a33bdd9 108 // Example of how to retrieve the list of sources that produced files
109 sourceList = GetFileSources(kDAQ);
110 if (!sourceList)
111 {
112 Log("Error: No sources found!");
113 return 1;
114 }
115
116 Log("The following sources produced files");
117 sourceList->Print();
118 delete sourceList;
119
120 // Example of how to retrieve the list of ids from a given source
121 TList* idList = GetFileIDs(kDAQ, "LDC0");
122 if (!idList)
123 {
124 Log("Error: No IDs found!");
125 return 1;
126 }
127
128 Log("The following ids are available");
129 idList->Print();
130 delete idList;
131
886d60e6 132 // Example to store a file directly to the reference storage
133 // Suppose we have queried the file from the FXS. Now the file is available locally and is called "file1.root".
134 const char* refFileName="file1.root";
135 if (!StoreReferenceFile(refFileName, "InputData.root"))
9827400b 136 return 1;
137
36137ac1 138
eba76848 139 // Example of how to retrieve a run parameter using GetRunParameter function
140 // TODO Here the parameter must be set manually with SetInputRunParameter function,
141 // in reality it will be read from the run logbook!
142
143 // note that the parameters are returned as character strings!
144 const char* nEvents = GetRunParameter("totalEvents");
145 if (nEvents) {
146 Log(Form("Number of events for run %d: %s",fRun, nEvents));
147 } else {
148 Log(Form("Number of events not put in logbook!"));
149 }
150
d461a8a7 151 // Example of how to retrieve a condition object from OCDB
152
153 AliCDBEntry *entry = GetFromOCDB("Calib", "Data");
154 if (!entry)
155 {
156 Log("No object found in OCDB!");
157 } else {
158 TObjString *obj = dynamic_cast<TObjString*> (entry->GetObject());
159 Log(Form("Got TPC/Calib/Data object from OCDB. The object says: %s",obj->GetName()));
160 }
161
eba76848 162
36137ac1 163 //Now we have to store the final CDB file
5c6b40ae 164 AliCDBMetaData metaData;
165 metaData.SetBeamPeriod(0);
441b0e9c 166 metaData.SetResponsible("TPC expert");
5c6b40ae 167 metaData.SetComment("This preprocessor fills an AliTestDataDCS object.");
168
9827400b 169 Bool_t result = Store("Calib", "Data", fData, &metaData, 0, 0);
5c6b40ae 170 delete fData;
171 fData = 0;
172
9827400b 173 if (!result)
174 return 1;
175
176 return 0;
5c6b40ae 177}
178