]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - GRP/TestGRPPreprocessor.C
debug statement in call to event listing added
[u/mrichter/AliRoot.git] / GRP / TestGRPPreprocessor.C
... / ...
CommitLineData
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
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// 8 --> Missing LTU configuration
21
22// Need to include dummy files in TestShuttle/TestCDB for CTP Configuration and Scalers
23// (see macro $ALICE_ROOT/GRP/MakeCTPDummyEntries.C)
24
25// Modified by C. Zampolli
26
27
28#include <iostream>
29#include <fstream>
30using namespace std;
31
32void TestGRPPreprocessor(const char* runtype="PHYSICS", TString partition="ALICE", TString detector="", TString beamType = "p-p", Int_t errorLevel=0)
33{
34 gSystem->Load("$ALICE_ROOT/SHUTTLE/TestShuttle/libTestShuttle.so");
35
36 AliLog::SetClassDebugLevel("AliGRPPreprocessor",3);
37 Int_t kRun = 7;
38 AliTestShuttle* shuttle = new AliTestShuttle(kRun, 1000, 2000);
39
40 AliTestShuttle::SetMainCDB("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB");
41 AliTestShuttle::SetMainRefStorage("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestReference");
42
43 printf("Test OCDB storage Uri: %s\n", AliShuttleInterface::GetMainCDB().Data());
44 printf("Test Reference storage Uri: %s\n", AliShuttleInterface::GetMainRefStorage().Data());
45
46 // setting runtype
47 shuttle->SetInputRunType(runtype);
48
49 Int_t detectorMask = 1074200319;
50 TString detectorMask_Str(Form("%d",detectorMask));
51 shuttle->AddInputRunParameter("detectorMask", detectorMask_Str.Data());
52
53 TString* ltu = new TString[3];
54 ltu[0] = "2000";
55 ltu[1] = "6000";
56 ltu[2] = "8000";
57 for (Int_t i = 0; i<AliDAQ::kNDetectors-2; i++){
58 if ((detectorMask >> i) & 0x1) {
59 TString detOnlineName = AliDAQ::DetectorName(i);
60 if (detOnlineName == "VZERO"){
61 ltu[0] = "3000";
62 ltu[1] = "7000";
63 ltu[2] = "9000";
64 }
65 if (errorLevel != 8 && !partition.IsNull() && detector.IsNull()){
66 shuttle->SetLTUConfig(ltu,detOnlineName.Data());
67 }
68 }
69 }
70
71 // simulating DCS DPs
72 TMap* dcsAliasMap = CreateDCSAliasMap(errorLevel);
73 shuttle->SetDCSInput(dcsAliasMap);
74
75 // simulating input from DAQ FXS
76 if (errorLevel != 2){
77
78 //$ALICE_ROOT to be expanded manually by the user for this test macro
79 shuttle->AddInputFile(AliShuttleInterface::kDAQ, "GRP", "Period_LHC09c_TPC.Seq_0.tag.root", "GDC35", "$ALICE_ROOT/GRP/ShuttleInput/run000080740_GRP_gdc-aldaqpc035_Period_LHC09c.Seq_0.tag.root");
80 shuttle->AddInputFile(AliShuttleInterface::kDAQ, "GRP", "Period_LHC09c_TPC.Seq_0.tag.root", "GDC36", "$ALICE_ROOT/GRP/ShuttleInput/run000080740_GRP_gdc-aldaqpc036_Period_LHC09c.Seq_0.tag.root");
81 shuttle->AddInputFile(AliShuttleInterface::kDAQ, "GRP", "Period_LHC09c_TPC.Seq_0.tag.root", "GDC44", "$ALICE_ROOT/GRP/ShuttleInput/run000080740_GRP_gdc-aldaqpc044_Period_LHC09c.Seq_0.tag.root");
82 shuttle->AddInputFile(AliShuttleInterface::kDAQ, "GRP", "Period_LHC09c_TPC.Seq_0.tag.root", "GDC45", "$ALICE_ROOT/GRP/ShuttleInput/run000080740_GRP_gdc-aldaqpc045_Period_LHC09c.Seq_0.tag.root");
83 shuttle->AddInputFile(AliShuttleInterface::kDAQ, "SPD", "VertexDiamond", "gdc-GLOBAL-01", "$ALICE_ROOT/GRP/ShuttleInput/run000104892_SPD_mon-DA-SPD-0_VertexDiamond");
84 shuttle->AddInputFile(AliShuttleInterface::kDCS, "GRP", "LHCData", "", "$ALICE_ROOT/GRP/ShuttleInput/testRun_GRP_run_number_testRun_data.txt");
85 shuttle->AddInputFile(AliShuttleInterface::kDQM, "GRP", "TriggerClassesAndHistosToClone", "DQM", "$ALICE_ROOT/GRP/ShuttleInput/run000158496_GRP_DQM_TriggerClassesAndHistosToClone");
86 shuttle->AddInputFile(AliShuttleInterface::kDQM, "ACO", "QAThresholds", "DQM", "$ALICE_ROOT/GRP/ShuttleInput/run000168322_ACO_DQM_QAThresholds");
87 shuttle->AddInputFile(AliShuttleInterface::kDQM, "TPC", "QAThresholds", "DQM", "$ALICE_ROOT/GRP/ShuttleInput/run000168322_TPC_DQM_QAThresholds");
88
89 /*
90 // for example:
91
92 shuttle->AddInputFile(AliShuttleInterface::kDAQ, "GRP", "Period_LHC09c_TPC.Seq_0.tag.root", "GDC35", "/home/zampolli/SOFT/AliRoot/AliRoot_Trunk/GRP/ShuttleInput/run000080740_GRP_gdc-aldaqpc035_Period_LHC09c.Seq_0.tag.root");
93 shuttle->AddInputFile(AliShuttleInterface::kDAQ, "GRP", "Period_LHC09c_TPC.Seq_0.tag.root", "GDC36", "/home/zampolli/SOFT/AliRoot/AliRoot_Trunk/GRP/ShuttleInput/run000080740_GRP_gdc-aldaqpc036_Period_LHC09c.Seq_0.tag.root");
94 shuttle->AddInputFile(AliShuttleInterface::kDAQ, "GRP", "Period_LHC09c_TPC.Seq_0.tag.root", "GDC44", "/home/zampolli/SOFT/AliRoot/AliRoot_Trunk/GRP/ShuttleInput/run000080740_GRP_gdc-aldaqpc044_Period_LHC09c.Seq_0.tag.root");
95 shuttle->AddInputFile(AliShuttleInterface::kDAQ, "GRP", "Period_LHC09c_TPC.Seq_0.tag.root", "GDC45", "/home/zampolli/SOFT/AliRoot/AliRoot_Trunk/GRP/ShuttleInput/run000080740_GRP_gdc-aldaqpc045_Period_LHC09c.Seq_0.tag.root");
96 shuttle->AddInputFile(AliShuttleInterface::kDAQ, "SPD", "VertexDiamond", "gdc-GLOBAL-01", "/home/zampolli/SOFT/AliRoot/AliRoot_Trunk/GRP/ShuttleInput/run000104892_SPD_mon-DA-SPD-0_VertexDiamond");
97 shuttle->AddInputFile(AliShuttleInterface::kDCS, "GRP", "LHCData", "", "/home/zampolli/SOFT/AliRoot/AliRoot_Trunk/GRP/ShuttleInput/testRun_GRP_run_number_testRun_data.txt");
98 */
99 }
100
101 // simulating input from DCS FXS
102 if (errorLevel != 4 && !partition.IsNull() && detector.IsNull()){
103 shuttle->AddInputFile(AliShuttleInterface::kDCS, "GRP", "CTP_xcounters", "", gSystem->ExpandPathName("$ALICE_ROOT/GRP/CTP/xcounters.txt"));
104 }
105
106 Char_t * filename = gSystem->ExpandPathName("$ALICE_ROOT/GRP/CTP/p-p.cfg");
107 ifstream is;
108 is.open(filename);
109 is.seekg(0,ios::end);
110 int length = is.tellg();
111 const char *buffer = new char[length];
112 is.seekg(0,ios::beg);
113 is.read(buffer,length);
114 is.close();
115 const char *emptybuffer = NULL;
116
117 // simulating input from DAQ logbook_trigger_config
118 if (errorLevel != 3 && errorLevel != 7 && !partition.IsNull() && detector.IsNull()) {
119 cout << " adding trigger config " << endl;
120 shuttle->SetInputTriggerConfiguration(buffer);
121 }
122 else if (errorLevel == 7) {
123 shuttle->SetInputTriggerConfiguration(emptybuffer);
124 }
125
126 // open text file with CTP timing params
127 Char_t * fileNameTiming = gSystem->ExpandPathName("$ALICE_ROOT/GRP/ShuttleInput/ctptime.tim");
128 ifstream ifstrTiming;
129 ifstrTiming.open(fileNameTiming);
130 ifstrTiming.seekg(0,ios::end);
131 int lengthTiming = ifstrTiming.tellg();
132 const char *bufferTiming = new char[lengthTiming];
133 ifstrTiming.seekg(0,ios::beg);
134 ifstrTiming.read(bufferTiming,lengthTiming);
135 ifstrTiming.close();
136 // const char *emptybuffer = NULL;
137
138 // simulating input from DAQ logbook_ctp_timing_params
139 if (errorLevel != 3 && errorLevel != 7 && !partition.IsNull() && detector.IsNull()) {
140 cout << " adding ctp timing params " <<endl;
141 shuttle->SetInputCTPTimeParams(bufferTiming);
142 }
143 else if (errorLevel == 7) {
144 shuttle->SetInputCTPTimeParams(emptybuffer);
145 }
146
147 // simulating input from DAQ logbook
148 if (errorLevel != 1){
149 shuttle->AddInputRunParameter("DAQ_time_start", "1020");
150 }
151 if (errorLevel != 6){
152 shuttle->AddInputRunParameter("beamEnergy", "123");
153 }
154
155 shuttle->AddInputRunParameter("DAQ_time_end", "1980");
156 shuttle->AddInputRunParameter("beamType", beamType);
157 shuttle->AddInputRunParameter("numberOfDetectors", "5");
158 shuttle->AddInputRunParameter("LHCperiod", "LHC08b");
159 shuttle->AddInputRunParameter("partition",partition);
160 shuttle->AddInputRunParameter("detector",detector);
161
162 // simulating HLT
163 Bool_t hltStatus = kTRUE;
164 shuttle->SetInputHLTStatus(hltStatus);
165
166 // Create the preprocessor that should be tested, it registers itself automatically to the shuttle
167 AliPreprocessor* test = new AliGRPPreprocessor(shuttle);
168
169 // Test the preprocessor
170 shuttle->Process();
171
172 printf("\n\n");
173
174 // Check the file which should have been created
175 AliCDBEntry* chkEntry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())
176 ->Get("GRP/GRP/Data", kRun);
177 if (!chkEntry) {
178 printf("The file is not there. Something went wrong.\n");
179 return;
180 }
181 chkEntry->PrintId();
182 chkEntry->GetObject()->Print();
183 printf("\n\n");
184
185}
186
187TMap* CreateDCSAliasMap(Int_t errorLevel)
188{
189 // Creates a DCS structure
190 // The structure is the following:
191 // TMap (key --> value)
192 // <DCSAlias> --> <valueList>
193 // <DCSAlias> is a string
194 // <valueList> is a TObjArray of AliDCSValue
195 // An AliDCSValue consists of timestamp and a value in form of a AliSimpleValue
196
197 const Int_t fgknDCSDP = 48;
198 const char* fgkDCSDataPoints[AliGRPPreprocessor::fgknDCSDP] = {
199 "L3Polarity",
200 "DipolePolarity",
201 "L3Current",
202 "DipoleCurrent",
203 "L3_BSF17_H1",
204 "L3_BSF17_H2",
205 "L3_BSF17_H3",
206 "L3_BSF17_Temperature",
207 "L3_BSF4_H1",
208 "L3_BSF4_H2",
209 "L3_BSF4_H3",
210 "L3_BSF4_Temperature",
211 "L3_BKF17_H1",
212 "L3_BKF17_H2",
213 "L3_BKF17_H3",
214 "L3_BKF17_Temperature",
215 "L3_BKF4_H1",
216 "L3_BKF4_H2",
217 "L3_BKF4_H3",
218 "L3_BKF4_Temperature",
219 "L3_BSF13_H1",
220 "L3_BSF13_H2",
221 "L3_BSF13_H3",
222 "L3_BSF13_Temperature",
223 "L3_BSF8_H1",
224 "L3_BSF8_H2",
225 "L3_BSF8_H3",
226 "L3_BSF8_Temperature",
227 "L3_BKF13_H1",
228 "L3_BKF13_H2",
229 "L3_BKF13_H3",
230 "L3_BKF13_Temperature",
231 "L3_BKF8_H1",
232 "L3_BKF8_H2",
233 "L3_BKF8_H3",
234 "L3_BKF8_Temperature",
235 "Dipole_Inside_H1",
236 "Dipole_Inside_H2",
237 "Dipole_Inside_H3",
238 "Dipole_Inside_Temperature",
239 "Dipole_Outside_H1",
240 "Dipole_Outside_H2",
241 "Dipole_Outside_H3",
242 "Dipole_Outside_Temperature",
243 "CavernTemperature",
244 "CavernAtmosPressure",
245 "SurfaceAtmosPressure",
246 "CavernAtmosPressure2",
247 };
248
249 TMap* aliasMap;
250 TObjArray* valueSet;
251 AliDCSValue* dcsVal;
252
253 aliasMap = new TMap;
254 aliasMap->SetOwner(1);
255
256 // L3Polarity
257 valueSet = new TObjArray;
258 valueSet->SetOwner(1);
259 dcsVal = new AliDCSValue( kTRUE, 1010 );
260 valueSet->Add(dcsVal);
261 dcsVal = new AliDCSValue( kTRUE, 1100 );
262 valueSet->Add(dcsVal);
263 dcsVal = new AliDCSValue( kTRUE, 1500 );
264 valueSet->Add(dcsVal);
265 dcsVal = new AliDCSValue( kTRUE, 1990 );
266 valueSet->Add(dcsVal);
267 // add the following two lines to test errors for changing polarity
268 // dcsVal = new AliDCSValue( kFALSE, 2 );
269 // valueSet->Add(dcsVal);
270 aliasMap->Add( new TObjString(fgkDCSDataPoints[1]), valueSet );
271
272 // DipolePolarity
273 valueSet = new TObjArray;
274 valueSet->SetOwner(1);
275 dcsVal = new AliDCSValue( kTRUE, 1010 );
276 valueSet->Add(dcsVal);
277 dcsVal = new AliDCSValue( kTRUE, 1100 );
278 valueSet->Add(dcsVal);
279 dcsVal = new AliDCSValue( kTRUE, 1500 );
280 valueSet->Add(dcsVal);
281 dcsVal = new AliDCSValue( kTRUE, 1990 );
282 aliasMap->Add( new TObjString(fgkDCSDataPoints[2]), valueSet );
283
284
285 TRandom random;
286
287 Int_t maxDPindex = 0;
288 if (errorLevel != 5) {
289 maxDPindex = fgknDCSDP;
290 }
291 else {
292 maxDPindex = 3; // simulating only a few DP in case errorLevel=5
293 }
294
295 for( int nAlias=2; nAlias<maxDPindex; nAlias++) {
296 if (nAlias>=4 && nAlias < 44) continue;
297 valueSet = new TObjArray;
298 valueSet->SetOwner(1);
299
300 Int_t timeStampValue[10] = { 1010, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1990};
301
302
303 for (int timeStamp=0; timeStamp<10; timeStamp++) {
304 dcsVal = new AliDCSValue((Float_t) (timeStamp+1+10*nAlias), timeStampValue[timeStamp]);
305 valueSet->Add(dcsVal);
306 }
307 cout << " simulating " << fgkDCSDataPoints[nAlias] << endl;
308 aliasMap->Add( new TObjString( fgkDCSDataPoints[nAlias]), valueSet );
309 }
310
311 // Hall Probes
312 TString probe1[3] = {"L3_BSF","L3_BKF","Dipole_"};
313 TString probe2[6] = {"17_","4_","13_","8_","Inside_","Outside_"};
314 TString probe3[4] = {"H1","H2","H3","Temperature"};
315 Int_t hp = 0;
316
317 for (Int_t i=0;i<3;i++){
318 for (Int_t j=0;j<6;j++){
319 for (Int_t k=0;k<4;k++){
320 TString dpAlias = probe1[i]+probe2[j]+probe3[k];
321 valueSet = new TObjArray;
322 valueSet->SetOwner(1);
323 for (int timeStamp=0; timeStamp<10; timeStamp++) {
324 dcsVal = new AliDCSValue((Float_t) (timeStamp+1+10*hp), timeStampValue[timeStamp]);
325 valueSet->Add(dcsVal);
326 //cout << " hall probe = " << dpAlias << " with value = " << dcsVal->GetFloat() << endl;
327 }
328 aliasMap->Add( new TObjString(dpAlias), valueSet );
329 hp++;
330 }
331 }
332 }
333
334 return aliasMap;
335}
336
337/*
338TMap* ReadDCSAliasMap()
339{
340 // Open a file that contains DCS input data
341 // The CDB framework is used to open the file, this means the file is located
342 // in $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB/<detector>/DCS/Data
343 // The file contains an AliCDBEntry that contains a TMap with the DCS structure.
344 // An explanation of the structure can be found in CreateDCSAliasMap()
345
346 AliCDBEntry *entry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())
347 ->Get("DET/DCS/Data", 0);
348 return dynamic_cast<TMap*> (entry->GetObject());
349}
350*/
351
352
353void WriteDCSAliasMap()
354{
355 // This writes the output from CreateDCSAliasMap to a CDB file
356
357 TMap* dcsAliasMap = CreateDCSAliasMap(Int_t errorLevel);
358
359 AliCDBMetaData metaData;
360 metaData.SetBeamPeriod(0);
361 metaData.SetResponsible("Ernesto Lopez Torres");
362 metaData.SetComment("Test object for TestGRPPreprocessor.C");
363
364 AliCDBId id("GRP/Data", 0, 0);
365
366 // look into AliTestShuttle's CDB main folder
367
368 AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())
369 ->Put(dcsAliasMap, id, &metaData);
370}