]> git.uio.no Git - u/mrichter/AliRoot.git/blame - SHUTTLE/TestShuttle/AliTestPreprocessor.cxx
Function GetFromOCDB added to AliShuttle and AliTestShuttle.
[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>
5c6b40ae 11
12//
13// This class is an example for a simple preprocessor.
14// It takes data from DCS and passes it to the class AliTestDataDCS, which
15// reformats its. This class is then written to the CDB.
16//
17
18ClassImp(AliTestPreprocessor)
19
36137ac1 20//______________________________________________________________________________________________
fc5a4708 21AliTestPreprocessor::AliTestPreprocessor(AliShuttleInterface* shuttle) :
22 AliPreprocessor("TPC", shuttle),
5c6b40ae 23 fData(0)
24{
25 // constructor
26}
27
36137ac1 28//______________________________________________________________________________________________
5c6b40ae 29AliTestPreprocessor::~AliTestPreprocessor()
30{
31 // destructor
32}
33
36137ac1 34//______________________________________________________________________________________________
5c6b40ae 35void AliTestPreprocessor::Initialize(Int_t run, UInt_t startTime,
36 UInt_t endTime)
37{
38 // Creates AliTestDataDCS object
39
40 AliPreprocessor::Initialize(run, startTime, endTime);
41
42 AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run,
43 TTimeStamp(startTime).AsString(),
44 TTimeStamp(endTime).AsString()));
45
46 fData = new AliTestDataDCS(fRun, fStartTime, fEndTime);
47}
48
36137ac1 49//______________________________________________________________________________________________
50UInt_t AliTestPreprocessor::Process(TMap* dcsAliasMap)
5c6b40ae 51{
52 // Fills data into a AliTestDataDCS object
53
54 if (!dcsAliasMap)
36137ac1 55 return 0;
5c6b40ae 56
36137ac1 57 // The processing of the DCS input data is forwarded to AliTestDataDCS
5c6b40ae 58 fData->ProcessData(*dcsAliasMap);
59
60 const char* fileName = GetFile(kDAQ, "PEDESTALS", "GDC");
61 if (fileName)
62 AliInfo(Form("Got the file %s, now we can extract some values.", fileName));
36137ac1 63 //TODO here the file could be opened, some values extracted and written to e.g. fData
64
65 TList* list = GetFileSources(kDAQ, "DRIFTVELOCITY");
66 if (list)
67 {
68 AliInfo("The following sources produced files with the id DRIFTVELOCITY");
69 list->Print();
70 delete list;
71 }
72 //TODO here the files could be opened, some values extracted and written to e.g. fData
73
eba76848 74 // Example of how to retrieve a run parameter using GetRunParameter function
75 // TODO Here the parameter must be set manually with SetInputRunParameter function,
76 // in reality it will be read from the run logbook!
77
78 // note that the parameters are returned as character strings!
79 const char* nEvents = GetRunParameter("totalEvents");
80 if (nEvents) {
81 Log(Form("Number of events for run %d: %s",fRun, nEvents));
82 } else {
83 Log(Form("Number of events not put in logbook!"));
84 }
85
d461a8a7 86 // Example of how to retrieve a condition object from OCDB
87
88 AliCDBEntry *entry = GetFromOCDB("Calib", "Data");
89 if (!entry)
90 {
91 Log("No object found in OCDB!");
92 } else {
93 TObjString *obj = dynamic_cast<TObjString*> (entry->GetObject());
94 Log(Form("Got TPC/Calib/Data object from OCDB. The object says: %s",obj->GetName()));
95 }
96
eba76848 97
36137ac1 98 //Now we have to store the final CDB file
5c6b40ae 99 AliCDBMetaData metaData;
100 metaData.SetBeamPeriod(0);
101 metaData.SetResponsible("Alberto Colla");
102 metaData.SetComment("This preprocessor fills an AliTestDataDCS object.");
103
84090f85 104 UInt_t result = Store("SHUTTLE", "Data", fData, &metaData, 0, 0);
5c6b40ae 105 delete fData;
106 fData = 0;
107
36137ac1 108 return result;
5c6b40ae 109}
110