Run type field added in SHUTTLE framework. Run type is read from "run type" logbook...
[u/mrichter/AliRoot.git] / SHUTTLE / test / TestHMPIDPreprocessor.cxx
CommitLineData
84090f85 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//
f4b3bbb7 17// Prototype of HMPID Preprocessor
84090f85 18//
19
f4b3bbb7 20#include "TestHMPIDPreprocessor.h"
84090f85 21
22#include "AliCDBMetaData.h"
23#include "AliDCSValue.h"
24#include "AliLog.h"
25#include "AliShuttleInterface.h"
26
27#include <TTimeStamp.h>
28#include <TObjString.h>
29#include <TSystem.h>
30
f4b3bbb7 31ClassImp(TestHMPIDPreprocessor)
84090f85 32
33//________________________________________________________________________________________
f4b3bbb7 34TestHMPIDPreprocessor::TestHMPIDPreprocessor():
eba76848 35 AliPreprocessor("HMP",0)
84090f85 36{
37// default constructor - Don't use this!
38
39}
40
41//________________________________________________________________________________________
f4b3bbb7 42TestHMPIDPreprocessor::TestHMPIDPreprocessor(AliShuttleInterface* shuttle):
be48e3ea 43 AliPreprocessor("HMP", shuttle)
84090f85 44{
45// constructor - shuttle must be instantiated!
46
47}
48
49//________________________________________________________________________________________
f4b3bbb7 50void TestHMPIDPreprocessor::Initialize(Int_t run, UInt_t startTime,
84090f85 51 UInt_t endTime)
52{
53// Initialize preprocessor
54
55 AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run,
56 TTimeStamp(startTime).AsString(),
57 TTimeStamp(endTime).AsString()));
58
59 fRun = run;
60 fStartTime = startTime;
61 fEndTime = endTime;
62}
63
64//________________________________________________________________________________________
f4b3bbb7 65UInt_t TestHMPIDPreprocessor::Process(TMap* /*valueMap*/)
84090f85 66{
67// process data retrieved by the Shuttle
68
441b0e9c 69 UInt_t result = kFALSE;
84090f85 70
441b0e9c 71 // Get run type and start the processing algorithm accordingly
72 TString runType = GetRunType();
73 if (runType.Length()==0)
74 {
75 Log("Undefined run type!");
84090f85 76 return 0;
77 }
78
441b0e9c 79 Log(Form("Run type: %s", runType.Data()));
80
81 if (runType == "PHYSICS")
82 {
83 // DAQ
84 TList* filesources = GetFileSources(AliShuttleInterface::kDAQ, "DAQFile");
85
86 if(!filesources) {
87 AliError(Form("No sources found for thresholds.txt for run %d !", fRun));
88 return 0;
89 }
90
91 AliInfo("Here's the list of sources for thresholds.txt");
92 filesources->Print();
93
94 TIter iter(filesources);
95 TObjString* source;
96 int i=0;
97 while((source=dynamic_cast<TObjString*> (iter.Next()))){
98 printf("\n\n Getting file #%d\n",++i);
99 //if(i==1) continue;
100 TString filename = GetFile(AliShuttleInterface::kDAQ, "DAQFile", source->GetName());
101 if(!filename.Length()) {
102 AliError(Form("Error: retrieval of file from source %s failed!", source->GetName()));
103 delete filesources;
104 return 0;
105 }
106 TString command = Form("more %s",filename.Data());
107 gSystem->Exec(command.Data());
108
109 // STORAGE! The First file name will be stored into CDB, the second into reference storage
110 TObjString filenameObj(filename);
111 AliCDBMetaData metaData;
112 if(i==1) result = Store("Calib", "DAQData", &filenameObj, &metaData);
113 if(i==2) result = StoreReferenceData("Calib", "RefData", &filenameObj, &metaData);
114
115 }
116 delete filesources;
117
118 } else if (runType == "PEDESTALS")
119 {
120
121 // DCS
122 TString filename = GetFile(AliShuttleInterface::kDCS, "DCSFile", 0);
be48e3ea 123 if(!filename.Length()) {
441b0e9c 124 AliError(Form("Error: retrieval of file from DCS failed!"));
84090f85 125 return 0;
126 }
441b0e9c 127 TString command = Form("more %s", filename.Data());
84090f85 128 gSystem->Exec(command.Data());
129
130 // STORAGE! The First file name will be stored into CDB, the second into reference storage
131 TObjString filenameObj(filename);
132 AliCDBMetaData metaData;
441b0e9c 133 result = Store("Calib", "DCSData", &filenameObj, &metaData);
134
135 } else if (runType == "GAINS")
136 {
84090f85 137
441b0e9c 138 // HLT
139 TList* filesources = GetFileSources(AliShuttleInterface::kHLT, "HLTFile");
140
141 if(!filesources) {
142 Log(Form("No sources found for HLTFile for run %d !", fRun));
143 return 0;
144 }
145
146 AliInfo("Here's the list of sources for HLTFile");
147 filesources->Print();
148
149 TIter iter(filesources);
150 int i = 0;
151 TObjString* source;
152 while((source=dynamic_cast<TObjString*> (iter.Next()))){
153 printf("\n\n Getting file #%d\n",++i);
154 //if(i==1) continue;
155 TString filename = GetFile(AliShuttleInterface::kHLT, "HLTFile", source->GetName());
156 if(!filename.Length()) {
157 AliError(Form("Error: retrieval of file from source %s failed!", source->GetName()));
158 delete filesources;
159 return 0;
160 }
161 TString command = Form("more %s",filename.Data());
162 gSystem->Exec(command.Data());
163
164 // STORAGE! The First file name will be stored into CDB, the second into reference storage
165 TObjString filenameObj(filename);
166 AliCDBMetaData metaData;
167 if(i==1) result = Store("Calib", "HLTData", &filenameObj, &metaData);
168 if(i==2) result = StoreReferenceData("Calib", "RefHLTData", &filenameObj, &metaData);
169
170 }
171 delete filesources;
172 } else {
173 Log(Form("Unknown run type: %s", runType.Data()));
84090f85 174 }
84090f85 175
441b0e9c 176 AliInfo(Form("result = %d",result));
84090f85 177 return result;
178}
179