saving updates: new histograms for IPSig tagging and EMCAL only histogram
[u/mrichter/AliRoot.git] / GRP / TestGRPPreprocessor.C
CommitLineData
92e5c8ed 1
2// This macro runs the GRP test preprocessor
3// It uses AliTestShuttle to simulate a full Shuttle process
4
5// The input data is created in the functions
6// CreateDCSAliasMap() creates input that would in the same way come from DCS
7// ReadDCSAliasMap() reads from a file
8// CreateInputFilesMap() creates a list of local files, that can be accessed by the shuttle
9
e75e6e01 10// Taking as input runtype and errorLevel
11// errorLevel used to simulate errors:
12// 0 --> no error
13// 1 --> DAQ logbook error
14// 2 --> DAQ FXS error
15// 3 --> DAQ logbook_trigger_config erro
16// 4 --> DCS FXS error
17// 5 --> DCS DPs error
18// 6 --> Missing beamEnergy
19// 7 --> null buffer for Trigger Config
20
21// Need to include dummy files in TestShuttle/TestCDB for CTP Configuration and Scalers
22// (see macro $ALICE_ROOT/GRP/MakeCTPDummyEntries.C)
23
24// Modified by C. Zampolli
25
26
e3efae04 27#include <iostream>
28#include <fstream>
29using namespace std;
92e5c8ed 30
e75e6e01 31void TestGRPPreprocessor(const char* runtype="PHYSICS", TString partition="ALICE", TString detector="", TString beamType = "p-p", Int_t errorLevel=0)
92e5c8ed 32{
92e5c8ed 33 gSystem->Load("$ALICE_ROOT/SHUTTLE/TestShuttle/libTestShuttle.so");
34
92e5c8ed 35 Int_t kRun = 7;
36 AliTestShuttle* shuttle = new AliTestShuttle(kRun, 1, 10);
37
e75e6e01 38 AliTestShuttle::SetMainCDB("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB");
39 AliTestShuttle::SetMainRefStorage("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestReference");
92e5c8ed 40
41 printf("Test OCDB storage Uri: %s\n", AliShuttleInterface::GetMainCDB().Data());
42 printf("Test Reference storage Uri: %s\n", AliShuttleInterface::GetMainRefStorage().Data());
43
e75e6e01 44 // setting runtype
45 shuttle->SetInputRunType(runtype);
92e5c8ed 46
e75e6e01 47 // simulating DCS DPs
48 TMap* dcsAliasMap = CreateDCSAliasMap(errorLevel);
92e5c8ed 49 shuttle->SetDCSInput(dcsAliasMap);
50
e75e6e01 51 // simulating input from DAQ FXS
52 if (errorLevel != 2){
dba333ae 53 shuttle->AddInputFile(AliShuttleInterface::kDAQ, "GRP", "Period_LHC09c_TPC.Seq_0.tag.root", "GDC35", "/home/zampolli/GRP190809/run000080740_GRP_gdc-aldaqpc035_Period_LHC09c.Seq_0.tag.root");
54 shuttle->AddInputFile(AliShuttleInterface::kDAQ, "GRP", "Period_LHC09c_TPC.Seq_0.tag.root", "GDC36", "/home/zampolli/GRP190809/run000080740_GRP_gdc-aldaqpc036_Period_LHC09c.Seq_0.tag.root");
55 shuttle->AddInputFile(AliShuttleInterface::kDAQ, "GRP", "Period_LHC09c_TPC.Seq_0.tag.root", "GDC44", "/home/zampolli/GRP190809/run000080740_GRP_gdc-aldaqpc044_Period_LHC09c.Seq_0.tag.root");
56 shuttle->AddInputFile(AliShuttleInterface::kDAQ, "GRP", "Period_LHC09c_TPC.Seq_0.tag.root", "GDC45", "/home/zampolli/GRP190809/run000080740_GRP_gdc-aldaqpc045_Period_LHC09c.Seq_0.tag.root");
e75e6e01 57
58 }
59
60 // simulating input from DCS FXS
61 if (errorLevel != 4 && !partition.IsNull() && detector.IsNull()){
62 shuttle->AddInputFile(AliShuttleInterface::kDCS, "GRP", "CTP_xcounters", "", gSystem->ExpandPathName("$ALICE_ROOT/GRP/CTP/xcounters.txt"));
63 }
64
e3efae04 65 Char_t * filename = gSystem->ExpandPathName("$ALICE_ROOT/GRP/CTP/p-p.cfg");
66 ifstream is;
67 is.open(filename);
68 is.seekg(0,ios::end);
69 int length = is.tellg();
70 const char *buffer = new char[length];
71 is.seekg(0,ios::beg);
72 is.read(buffer,length);
73 is.close();
e75e6e01 74 const char *emptybuffer = NULL;
92e5c8ed 75
e75e6e01 76 // simulating input from DAQ logbook_trigger_config
77 if {
dba333ae 78 (errorLevel != 3 && errorLevel != 7 && !partition.IsNull() && detector.IsNull()) shuttle->SetInputTriggerConfiguration(buffer);
e75e6e01 79 }
80 else if (errorLevel == 7) {
81 shuttle->SetInputTriggerConfiguration(emptybuffer);
82 }
e3efae04 83
e75e6e01 84 // simulating input from DAQ logbook
85 if (errorLevel != 1){
86 shuttle->AddInputRunParameter("DAQ_time_start", "1233213.22");
87 }
88 if (errorLevel != 6){
89 shuttle->AddInputRunParameter("beamEnergy", "1400.");
90 }
91
92 shuttle->AddInputRunParameter("DAQ_time_end", "1345645.22");
93 shuttle->AddInputRunParameter("beamType", beamType);
92e5c8ed 94 shuttle->AddInputRunParameter("numberOfDetectors", "5");
95 shuttle->AddInputRunParameter("detectorMask", "34555");
96 shuttle->AddInputRunParameter("LHCperiod", "LHC08b");
e75e6e01 97 shuttle->AddInputRunParameter("partition",partition);
98 shuttle->AddInputRunParameter("detector",detector);
92e5c8ed 99
e75e6e01 100 // simulating HLT
92e5c8ed 101 Bool_t hltStatus = kTRUE;
102 shuttle->SetInputHLTStatus(hltStatus);
103
92e5c8ed 104 // Create the preprocessor that should be tested, it registers itself automatically to the shuttle
105 AliPreprocessor* test = new AliGRPPreprocessor(shuttle);
106
107 // Test the preprocessor
108 shuttle->Process();
109
110 printf("\n\n");
111
92e5c8ed 112 // Check the file which should have been created
113 AliCDBEntry* chkEntry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())
114 ->Get("GRP/GRP/Data", kRun);
115 if (!chkEntry) {
116 printf("The file is not there. Something went wrong.\n");
117 return;
118 }
119 chkEntry->PrintId();
120 chkEntry->GetObject()->Print();
121 printf("\n\n");
122
92e5c8ed 123}
124
e75e6e01 125TMap* CreateDCSAliasMap(Int_t errorLevel)
92e5c8ed 126{
127 // Creates a DCS structure
128 // The structure is the following:
e75e6e01 129 // TMap (key --> value)
130 // <DCSAlias> --> <valueList>
131 // <DCSAlias> is a string
132 // <valueList> is a TObjArray of AliDCSValue
133 // An AliDCSValue consists of timestamp and a value in form of a AliSimpleValue
92e5c8ed 134
e75e6e01 135 const Int_t fgknDCSDP = 50;
92e5c8ed 136 const char* fgkDCSDataPoints[AliGRPPreprocessor::fgknDCSDP] = {
e75e6e01 137 "LHCState", // missing in DCS
92e5c8ed 138 "L3Polarity",
139 "DipolePolarity",
e75e6e01 140 "LHCLuminosity", // missing in DCS
141 "BeamIntensity", // missing in DCS
92e5c8ed 142 "L3Current",
143 "DipoleCurrent",
e75e6e01 144 "L3_BSF17_H1",
145 "L3_BSF17_H2",
146 "L3_BSF17_H3",
147 "L3_BSF17_Temperature",
148 "L3_BSF4_H1",
149 "L3_BSF4_H2",
150 "L3_BSF4_H3",
151 "L3_BSF4_Temperature",
152 "L3_BKF17_H1",
153 "L3_BKF17_H2",
154 "L3_BKF17_H3",
155 "L3_BKF17_Temperature",
156 "L3_BKF4_H1",
157 "L3_BKF4_H2",
158 "L3_BKF4_H3",
159 "L3_BKF4_Temperature",
160 "L3_BSF13_H1",
161 "L3_BSF13_H2",
162 "L3_BSF13_H3",
163 "L3_BSF13_Temperature",
164 "L3_BSF8_H1",
165 "L3_BSF8_H2",
166 "L3_BSF8_H3",
167 "L3_BSF8_Temperature",
168 "L3_BKF13_H1",
169 "L3_BKF13_H2",
170 "L3_BKF13_H3",
171 "L3_BKF13_Temperature",
172 "L3_BKF8_H1",
173 "L3_BKF8_H2",
174 "L3_BKF8_H3",
175 "L3_BKF8_Temperature",
176 "Dipole_Inside_H1",
177 "Dipole_Inside_H2",
178 "Dipole_Inside_H3",
179 "Dipole_Inside_Temperature",
180 "Dipole_Outside_H1",
181 "Dipole_Outside_H2",
182 "Dipole_Outside_H3",
183 "Dipole_Outside_Temperature",
92e5c8ed 184 "CavernTemperature",
185 "CavernAtmosPressure",
649b8dcf 186 "SurfaceAtmosPressure"
92e5c8ed 187 };
188
189 TMap* aliasMap;
190 TObjArray* valueSet;
191 AliDCSValue* dcsVal;
192
193 aliasMap = new TMap;
194 aliasMap->SetOwner(1);
195
196 // LHCState
197 valueSet = new TObjArray;
198 valueSet->SetOwner(1);
e75e6e01 199 dcsVal = new AliDCSValue( 'F', 2 );
92e5c8ed 200 valueSet->Add(dcsVal);
e75e6e01 201 aliasMap->Add( new TObjString(fgkDCSDataPoints[0]), valueSet );
92e5c8ed 202
203 // L3Polarity
204 valueSet = new TObjArray;
205 valueSet->SetOwner(1);
e75e6e01 206 dcsVal = new AliDCSValue( kTRUE, 2 );
92e5c8ed 207 valueSet->Add(dcsVal);
dba333ae 208 // add the following two lines to test errors for changing polarity
209 // dcsVal = new AliDCSValue( kFALSE, 2 );
210 // valueSet->Add(dcsVal);
92e5c8ed 211 aliasMap->Add( new TObjString(fgkDCSDataPoints[1]), valueSet );
212
213 // DipolePolarity
214 valueSet = new TObjArray;
215 valueSet->SetOwner(1);
e75e6e01 216 dcsVal = new AliDCSValue( kTRUE, 2 );
92e5c8ed 217 valueSet->Add(dcsVal);
218 aliasMap->Add( new TObjString(fgkDCSDataPoints[2]), valueSet );
219
220 TRandom random;
221
e75e6e01 222 Int_t maxDPindex = 0;
223 if (errorLevel != 5) {
224 maxDPindex = fgknDCSDP;
225 }
226 else {
227 maxDPindex = 3; // simulating only a few DP in case errorLevel=5
228 }
229
230 for( int nAlias=3; nAlias<maxDPindex; nAlias++) {
231 if (nAlias>=7 && nAlias < 47) continue;
92e5c8ed 232 valueSet = new TObjArray;
233 valueSet->SetOwner(1);
234
e75e6e01 235 for (int timeStamp=0; timeStamp<10; timeStamp++) {
236 dcsVal = new AliDCSValue((Float_t) (timeStamp+1+10*nAlias), timeStamp+1);
92e5c8ed 237 valueSet->Add(dcsVal);
238 }
239 aliasMap->Add( new TObjString( fgkDCSDataPoints[nAlias]), valueSet );
240 }
241
e75e6e01 242 // Hall Probes
243 TString probe1[3] = {"L3_BSF","L3_BKF","Dipole_"};
244 TString probe2[6] = {"17_","4_","13_","8_","Inside_","Outside_"};
245 TString probe3[4] = {"H1","H2","H3","Temperature"};
246 Int_t hp = 0;
247
248 for (Int_t i=0;i<3;i++){
249 for (Int_t j=0;j<6;j++){
250 for (Int_t k=0;k<4;k++){
251 TString dpAlias = probe1[i]+probe2[j]+probe3[k];
252 valueSet = new TObjArray;
253 valueSet->SetOwner(1);
254 for (int timeStamp=0; timeStamp<10; timeStamp++) {
255 dcsVal = new AliDCSValue((Float_t) (timeStamp+1+10*hp), timeStamp+1);
256 valueSet->Add(dcsVal);
257 //cout << " hall probe = " << dpAlias << " with value = " << dcsVal->GetFloat() << endl;
258 }
259 aliasMap->Add( new TObjString(dpAlias), valueSet );
260 hp++;
261 }
262 }
263 }
264
92e5c8ed 265 return aliasMap;
266}
267
268/*
269TMap* ReadDCSAliasMap()
270{
271 // Open a file that contains DCS input data
272 // The CDB framework is used to open the file, this means the file is located
273 // in $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB/<detector>/DCS/Data
274 // The file contains an AliCDBEntry that contains a TMap with the DCS structure.
275 // An explanation of the structure can be found in CreateDCSAliasMap()
276
277 AliCDBEntry *entry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())
278 ->Get("DET/DCS/Data", 0);
279 return dynamic_cast<TMap*> (entry->GetObject());
280}
281*/
282
283
284void WriteDCSAliasMap()
285{
286 // This writes the output from CreateDCSAliasMap to a CDB file
287
e75e6e01 288 TMap* dcsAliasMap = CreateDCSAliasMap(Int_t errorLevel);
92e5c8ed 289
290 AliCDBMetaData metaData;
291 metaData.SetBeamPeriod(0);
292 metaData.SetResponsible("Ernesto Lopez Torres");
293 metaData.SetComment("Test object for TestGRPPreprocessor.C");
294
295 AliCDBId id("GRP/Data", 0, 0);
296
297 // look into AliTestShuttle's CDB main folder
298
299 AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())
300 ->Put(dcsAliasMap, id, &metaData);
301}