2 // This macro runs the GRP test preprocessor
3 // It uses AliTestShuttle to simulate a full Shuttle process
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
10 // Taking as input runtype and errorLevel
11 // errorLevel used to simulate errors:
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
21 // Need to include dummy files in TestShuttle/TestCDB for CTP Configuration and Scalers
22 // (see macro $ALICE_ROOT/GRP/MakeCTPDummyEntries.C)
24 // Modified by C. Zampolli
31 void TestGRPPreprocessor(const char* runtype="PHYSICS", TString partition="ALICE", TString detector="", TString beamType = "p-p", Int_t errorLevel=0)
33 gSystem->Load("$ALICE_ROOT/SHUTTLE/TestShuttle/libTestShuttle.so");
35 AliLog::SetClassDebugLevel("AliGRPPreprocessor",3);
37 AliTestShuttle* shuttle = new AliTestShuttle(kRun, 1000, 2000);
39 AliTestShuttle::SetMainCDB("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB");
40 AliTestShuttle::SetMainRefStorage("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestReference");
42 printf("Test OCDB storage Uri: %s\n", AliShuttleInterface::GetMainCDB().Data());
43 printf("Test Reference storage Uri: %s\n", AliShuttleInterface::GetMainRefStorage().Data());
46 shuttle->SetInputRunType(runtype);
49 TMap* dcsAliasMap = CreateDCSAliasMap(errorLevel);
50 shuttle->SetDCSInput(dcsAliasMap);
52 // simulating input from DAQ FXS
54 //$ALICE_ROOT to be expanded manually by the user for this test macro
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");
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");
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"));
72 Char_t * filename = gSystem->ExpandPathName("$ALICE_ROOT/GRP/CTP/p-p.cfg");
76 int length = is.tellg();
77 const char *buffer = new char[length];
79 is.read(buffer,length);
81 const char *emptybuffer = NULL;
83 // simulating input from DAQ logbook_trigger_config
84 if (errorLevel != 3 && errorLevel != 7 && !partition.IsNull() && detector.IsNull()) {
85 cout << " adding trigger config " << endl;
86 shuttle->SetInputTriggerConfiguration(buffer);
88 else if (errorLevel == 7) {
89 shuttle->SetInputTriggerConfiguration(emptybuffer);
92 // open text file with CTP timing params
93 Char_t * fileNameTiming = gSystem->ExpandPathName("$ALICE_ROOT/GRP/ShuttleInput/ctptime.tim");
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);
102 // const char *emptybuffer = NULL;
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);
109 else if (errorLevel == 7) {
110 shuttle->SetInputCTPTimeParams(emptybuffer);
113 // simulating input from DAQ logbook
114 if (errorLevel != 1){
115 shuttle->AddInputRunParameter("DAQ_time_start", "1020");
117 if (errorLevel != 6){
118 shuttle->AddInputRunParameter("beamEnergy", "1400.");
121 shuttle->AddInputRunParameter("DAQ_time_end", "1980");
122 shuttle->AddInputRunParameter("beamType", beamType);
123 shuttle->AddInputRunParameter("numberOfDetectors", "5");
124 shuttle->AddInputRunParameter("detectorMask", "34555");
125 shuttle->AddInputRunParameter("LHCperiod", "LHC08b");
126 shuttle->AddInputRunParameter("partition",partition);
127 shuttle->AddInputRunParameter("detector",detector);
130 Bool_t hltStatus = kTRUE;
131 shuttle->SetInputHLTStatus(hltStatus);
133 // Create the preprocessor that should be tested, it registers itself automatically to the shuttle
134 AliPreprocessor* test = new AliGRPPreprocessor(shuttle);
136 // Test the preprocessor
141 // Check the file which should have been created
142 AliCDBEntry* chkEntry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())
143 ->Get("GRP/GRP/Data", kRun);
145 printf("The file is not there. Something went wrong.\n");
149 chkEntry->GetObject()->Print();
154 TMap* CreateDCSAliasMap(Int_t errorLevel)
156 // Creates a DCS structure
157 // The structure is the following:
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
164 const Int_t fgknDCSDP = 51;
165 const char* fgkDCSDataPoints[AliGRPPreprocessor::fgknDCSDP] = {
166 "LHCState", // missing in DCS
169 "LHCLuminosity", // missing in DCS
170 "BeamIntensity", // missing in DCS
176 "L3_BSF17_Temperature",
180 "L3_BSF4_Temperature",
184 "L3_BKF17_Temperature",
188 "L3_BKF4_Temperature",
192 "L3_BSF13_Temperature",
196 "L3_BSF8_Temperature",
200 "L3_BKF13_Temperature",
204 "L3_BKF8_Temperature",
208 "Dipole_Inside_Temperature",
212 "Dipole_Outside_Temperature",
214 "CavernAtmosPressure",
215 "SurfaceAtmosPressure",
216 "CavernAtmosPressure2",
224 aliasMap->SetOwner(1);
228 valueSet = new TObjArray;
229 valueSet->SetOwner(1);
230 dcsVal = new AliDCSValue( 'F', 2 );
231 valueSet->Add(dcsVal);
232 aliasMap->Add( new TObjString(fgkDCSDataPoints[0]), valueSet );
236 valueSet = new TObjArray;
237 valueSet->SetOwner(1);
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 );
245 valueSet->Add(dcsVal);
246 // add the following two lines to test errors for changing polarity
247 // dcsVal = new AliDCSValue( kFALSE, 2 );
248 // valueSet->Add(dcsVal);
249 aliasMap->Add( new TObjString(fgkDCSDataPoints[1]), valueSet );
252 valueSet = new TObjArray;
253 valueSet->SetOwner(1);
254 dcsVal = new AliDCSValue( kTRUE, 1010 );
255 valueSet->Add(dcsVal);
256 dcsVal = new AliDCSValue( kTRUE, 1100 );
257 valueSet->Add(dcsVal);
258 dcsVal = new AliDCSValue( kTRUE, 1500 );
259 valueSet->Add(dcsVal);
260 dcsVal = new AliDCSValue( kTRUE, 1990 );
261 aliasMap->Add( new TObjString(fgkDCSDataPoints[2]), valueSet );
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 );
278 Int_t maxDPindex = 0;
279 if (errorLevel != 5) {
280 maxDPindex = fgknDCSDP;
283 maxDPindex = 3; // simulating only a few DP in case errorLevel=5
286 for( int nAlias=4; nAlias<maxDPindex; nAlias++) {
287 if (nAlias>=7 && nAlias < 47) continue;
288 valueSet = new TObjArray;
289 valueSet->SetOwner(1);
291 Int_t timeStampValue[10] = { 1010, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1990};
294 for (int timeStamp=0; timeStamp<10; timeStamp++) {
295 dcsVal = new AliDCSValue((Float_t) (timeStamp+1+10*nAlias), timeStampValue[timeStamp]);
296 valueSet->Add(dcsVal);
298 cout << " simulating " << fgkDCSDataPoints[nAlias] << endl;
299 aliasMap->Add( new TObjString( fgkDCSDataPoints[nAlias]), valueSet );
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"};
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++) {
315 dcsVal = new AliDCSValue((Float_t) (timeStamp+1+10*hp), timeStampValue[timeStamp]);
316 valueSet->Add(dcsVal);
317 //cout << " hall probe = " << dpAlias << " with value = " << dcsVal->GetFloat() << endl;
319 aliasMap->Add( new TObjString(dpAlias), valueSet );
329 TMap* ReadDCSAliasMap()
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()
337 AliCDBEntry *entry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())
338 ->Get("DET/DCS/Data", 0);
339 return dynamic_cast<TMap*> (entry->GetObject());
344 void WriteDCSAliasMap()
346 // This writes the output from CreateDCSAliasMap to a CDB file
348 TMap* dcsAliasMap = CreateDCSAliasMap(Int_t errorLevel);
350 AliCDBMetaData metaData;
351 metaData.SetBeamPeriod(0);
352 metaData.SetResponsible("Ernesto Lopez Torres");
353 metaData.SetComment("Test object for TestGRPPreprocessor.C");
355 AliCDBId id("GRP/Data", 0, 0);
357 // look into AliTestShuttle's CDB main folder
359 AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())
360 ->Put(dcsAliasMap, id, &metaData);