1 #include "AliTestPreprocessor.h"
3 #include "AliCDBMetaData.h"
4 #include "AliCDBEntry.h"
5 #include "AliDCSValue.h"
7 #include "AliTestDataDCS.h"
9 #include <TTimeStamp.h>
10 #include <TObjString.h>
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.
19 ClassImp(AliTestPreprocessor)
21 //______________________________________________________________________________________________
22 AliTestPreprocessor::AliTestPreprocessor(AliShuttleInterface* shuttle) :
23 AliPreprocessor("TPC", shuttle),
28 AddRunType("PHYSICS");
29 AddRunType("CALIBRATION");
32 //______________________________________________________________________________________________
33 AliTestPreprocessor::~AliTestPreprocessor()
38 //______________________________________________________________________________________________
39 void AliTestPreprocessor::Initialize(Int_t run, UInt_t startTime,
42 // Creates AliTestDataDCS object
44 AliPreprocessor::Initialize(run, startTime, endTime);
46 Log(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run,
47 TTimeStamp(startTime).AsString(),
48 TTimeStamp(endTime).AsString()));
50 fData = new AliTestDataDCS(fRun, fStartTime, fEndTime);
53 //______________________________________________________________________________________________
54 Bool_t AliTestPreprocessor::ProcessDCS()
57 // decide here if DCS data is to be processed
60 // TODO implement a decision, e.g. based on the run type
61 // In this example: Skip DCS if run type is CALIB
62 if (strcmp(GetRunType(), "CALIB") == 0)
68 //______________________________________________________________________________________________
69 UInt_t AliTestPreprocessor::Process(TMap* dcsAliasMap)
71 // Fills data into a AliTestDataDCS object
75 Log("ERROR: No DCS map provided by SHUTTLE!");
79 // The processing of the DCS input data is forwarded to AliTestDataDCS
80 fData->ProcessData(*dcsAliasMap);
82 // Example of how to retrieve the run type from the Shuttle, using GetRunType() function
83 // TODO Here the run type for the "DET" detector must be set manually with SetInputRunType function,
84 // in reality it will be read from the "run type" logbook!
85 TString runType = GetRunType();
86 Log(Form("Run type for run %d: %s", fRun, runType.Data()));
88 // Example of how to retrieve the list of sources that produced the file with id DRIFTVELOCITY
89 TList* sourceList = GetFileSources(kDAQ, "DRIFTVELOCITY");
90 sourceList = GetFileSources(kHLT, "HLTData");
93 Log("Error retrieving list of sources from FXS!");
97 if (sourceList->GetEntries() == 0)
99 Log("No sources found for id HLTData!");
100 // TODO What to do now depends on the expected behaviour of the
101 // online DA: if it expected to produce data for the FXS every run, then
102 // if no sources are found it means a problem happened and you should return error;
103 // if DA may or may not send files to FXS, then you shouldn't return error
104 // and go on with the analysis!
108 // TODO We have the list of sources that produced the files with Id DRIFTVELOCITY.
109 // Now we will loop on the list and we'll query the files one by one.
110 Log("The following sources produced files with the id DRIFTVELOCITY");
113 TIter iter(sourceList);
114 TObjString *source = 0;
115 while((source=dynamic_cast<TObjString*> (iter.Next()))){
116 TString fileName = GetFile(kDAQ, "DRIFTVELOCITY", source->GetName());
117 if (fileName.Length() > 0)
118 Log(Form("Got the file %s, now we can extract some values.", fileName.Data()));
123 // Example of retrieving files from HLT, including how to query HLT status
125 Bool_t hltStatus = GetHLTStatus(); // 1 = HLT ON (=> Query HLT), 0 = HLT OFF (=> skip HLT query)
129 Log("HLT is ON, let's query our files");
130 sourceList = GetFileSources(kHLT, "HLTData");
133 Log("Error retrieving list of sources from FXS!");
137 if (sourceList->GetEntries() == 0)
139 Log("No sources found for id HLTData!");
140 // TODO What to do now depends on the expected behaviour of the
141 // online DA: if it expected to produce data for the FXS every run, then
142 // if no sources are found it means a problem happened and you should return error;
143 // if DA may or may not send files to FXS, then you shouldn't return error
144 // and go on with the analysis!
147 Log("The following sources produced files with the id HLTData");
151 TIter iter(sourceList);
152 TObjString *source = 0;
153 while((source=dynamic_cast<TObjString*> (iter.Next()))){
154 TString fileName = GetFile(kHLT, "HLTData", source->GetName());
155 if (fileName.Length() > 0)
156 Log(Form("Got the file %s from HLT, now we can extract some values.", fileName.Data()));
162 Log("HLT is OFF, skipping query...");
165 // Example of how to retrieve the list of sources that produced files
166 sourceList = GetFileSources(kDAQ);
169 Log("Error: No sources found!");
173 Log("The following sources produced files");
177 // Example of how to retrieve the list of ids from a given source
178 TList* idList = GetFileIDs(kDAQ, "LDC0");
181 Log("Error: No IDs found!");
185 Log("The following ids are available");
189 // Example to store a file directly to the reference storage
190 // Suppose we have queried the file from the FXS. Now the file is available locally and is called "file1.root".
191 const char* refFileName="file1.root";
192 if (!StoreReferenceFile(refFileName, "InputData.root"))
196 // Example of how to retrieve a run parameter using GetRunParameter function
197 // TODO Here the parameter must be set manually with SetInputRunParameter function,
198 // in reality it will be read from the run logbook!
200 // note that the parameters are returned as character strings!
201 const char* nEvents = GetRunParameter("totalEvents");
203 Log(Form("Number of events for run %d: %s",fRun, nEvents));
205 Log(Form("Number of events not put in logbook!"));
208 // Example of how to retrieve a condition object from OCDB
210 AliCDBEntry *entry = GetFromOCDB("Calib", "Data");
213 Log("No object found in OCDB!");
215 Log("Got TPC/Calib/Data object from OCDB. The object's metadata is: ");
216 entry->PrintMetaData();
220 //Now we have to store the final CDB file
221 AliCDBMetaData metaData;
222 metaData.SetBeamPeriod(0);
223 metaData.SetResponsible("TPC expert");
224 metaData.SetComment("This preprocessor fills an AliTestDataDCS object.");
226 Bool_t result = Store("Calib", "Data", fData, &metaData, 0, 0);