Run type field added in SHUTTLE framework. Run type is read from "run type" logbook...
[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
441b0e9c 58 fData->ProcessData(*dcsAliasMap);
5c6b40ae 59
441b0e9c 60 // Example of how to retrieve the run type from the Shuttle, using GetRunType() function
61 // TODO Here the run type for the "DET" detector must be set manually with SetInputRunType function,
62 // in reality it will be read from the "run type" logbook!
63 TString runType = GetRunType();
64 AliInfo(Form("Run type for run %d: %s", fRun, runType.Data()));
65
66 TString fileName = GetFile(kDAQ, "PEDESTALS", "GDC");
67 if (fileName.Length() > 0)
68 AliInfo(Form("Got the file %s, now we can extract some values.", fileName.Data()));
36137ac1 69 //TODO here the file could be opened, some values extracted and written to e.g. fData
70
71 TList* list = GetFileSources(kDAQ, "DRIFTVELOCITY");
72 if (list)
73 {
74 AliInfo("The following sources produced files with the id DRIFTVELOCITY");
75 list->Print();
76 delete list;
77 }
78 //TODO here the files could be opened, some values extracted and written to e.g. fData
79
eba76848 80 // Example of how to retrieve a run parameter using GetRunParameter function
81 // TODO Here the parameter must be set manually with SetInputRunParameter function,
82 // in reality it will be read from the run logbook!
83
84 // note that the parameters are returned as character strings!
85 const char* nEvents = GetRunParameter("totalEvents");
86 if (nEvents) {
87 Log(Form("Number of events for run %d: %s",fRun, nEvents));
88 } else {
89 Log(Form("Number of events not put in logbook!"));
90 }
91
d461a8a7 92 // Example of how to retrieve a condition object from OCDB
93
94 AliCDBEntry *entry = GetFromOCDB("Calib", "Data");
95 if (!entry)
96 {
97 Log("No object found in OCDB!");
98 } else {
99 TObjString *obj = dynamic_cast<TObjString*> (entry->GetObject());
100 Log(Form("Got TPC/Calib/Data object from OCDB. The object says: %s",obj->GetName()));
101 }
102
eba76848 103
36137ac1 104 //Now we have to store the final CDB file
5c6b40ae 105 AliCDBMetaData metaData;
106 metaData.SetBeamPeriod(0);
441b0e9c 107 metaData.SetResponsible("TPC expert");
5c6b40ae 108 metaData.SetComment("This preprocessor fills an AliTestDataDCS object.");
109
441b0e9c 110 UInt_t result = Store("Calib", "Data", fData, &metaData, 0, 0);
5c6b40ae 111 delete fData;
112 fData = 0;
113
36137ac1 114 return result;
5c6b40ae 115}
116