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