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");
59 shuttle->AddInputFile(AliShuttleInterface::kDAQ, "SPD", "VertexDiamond", "gdc-GLOBAL-01", "$ALICE_ROOT/GRP/ShuttleInput/run000104892_SPD_mon-DA-SPD-0_VertexDiamond");
60 shuttle->AddInputFile(AliShuttleInterface::kDCS, "GRP", "LHCData", "", "$ALICE_ROOT/GRP/ShuttleInput/testRun_GRP_run_number_testRun_data.txt");
63 shuttle->AddInputFile(AliShuttleInterface::kDAQ, "GRP", "Period_LHC09c_TPC.Seq_0.tag.root", "GDC35", "/home/zampolli/SOFT/AliRoot/AliRoot_Trunk_OCDB/GRP/ShuttleInput/run000080740_GRP_gdc-aldaqpc035_Period_LHC09c.Seq_0.tag.root");
64 shuttle->AddInputFile(AliShuttleInterface::kDAQ, "GRP", "Period_LHC09c_TPC.Seq_0.tag.root", "GDC36", "/home/zampolli/SOFT/AliRoot/AliRoot_Trunk_OCDB/GRP/ShuttleInput/run000080740_GRP_gdc-aldaqpc036_Period_LHC09c.Seq_0.tag.root");
65 shuttle->AddInputFile(AliShuttleInterface::kDAQ, "GRP", "Period_LHC09c_TPC.Seq_0.tag.root", "GDC44", "/home/zampolli/SOFT/AliRoot/AliRoot_Trunk_OCDB/GRP/ShuttleInput/run000080740_GRP_gdc-aldaqpc044_Period_LHC09c.Seq_0.tag.root");
66 shuttle->AddInputFile(AliShuttleInterface::kDAQ, "GRP", "Period_LHC09c_TPC.Seq_0.tag.root", "GDC45", "/home/zampolli/SOFT/AliRoot/AliRoot_Trunk_OCDB/GRP/ShuttleInput/run000080740_GRP_gdc-aldaqpc045_Period_LHC09c.Seq_0.tag.root");
67 shuttle->AddInputFile(AliShuttleInterface::kDAQ, "SPD", "VertexDiamond", "gdc-GLOBAL-01", "/home/zampolli/SOFT/AliRoot/AliRoot_Trunk_OCDB/GRP/ShuttleInput/run000104892_SPD_mon-DA-SPD-0_VertexDiamond");
68 shuttle->AddInputFile(AliShuttleInterface::kDCS, "GRP", "LHCData", "", "/home/zampolli/SOFT/AliRoot/AliRoot_Trunk_OCDB/GRP/ShuttleInput/testRun_GRP_run_number_testRun_data.txt");
72 // simulating input from DCS FXS
73 if (errorLevel != 4 && !partition.IsNull() && detector.IsNull()){
74 shuttle->AddInputFile(AliShuttleInterface::kDCS, "GRP", "CTP_xcounters", "", gSystem->ExpandPathName("$ALICE_ROOT/GRP/CTP/xcounters.txt"));
77 Char_t * filename = gSystem->ExpandPathName("$ALICE_ROOT/GRP/CTP/p-p.cfg");
81 int length = is.tellg();
82 const char *buffer = new char[length];
84 is.read(buffer,length);
86 const char *emptybuffer = NULL;
88 // simulating input from DAQ logbook_trigger_config
89 if (errorLevel != 3 && errorLevel != 7 && !partition.IsNull() && detector.IsNull()) {
90 cout << " adding trigger config " << endl;
91 shuttle->SetInputTriggerConfiguration(buffer);
93 else if (errorLevel == 7) {
94 shuttle->SetInputTriggerConfiguration(emptybuffer);
97 // open text file with CTP timing params
98 Char_t * fileNameTiming = gSystem->ExpandPathName("$ALICE_ROOT/GRP/ShuttleInput/ctptime.tim");
100 ifstrTiming.open(fileNameTiming);
101 ifstrTiming.seekg(0,ios::end);
102 int lengthTiming = ifstrTiming.tellg();
103 const char *bufferTiming = new char[lengthTiming];
104 ifstrTiming.seekg(0,ios::beg);
105 ifstrTiming.read(bufferTiming,lengthTiming);
107 // const char *emptybuffer = NULL;
109 // simulating input from DAQ logbook_ctp_timing_params
110 if (errorLevel != 3 && errorLevel != 7 && !partition.IsNull() && detector.IsNull()) {
111 cout << " adding ctp timing params " <<endl;
112 shuttle->SetInputCTPTimeParams(bufferTiming);
114 else if (errorLevel == 7) {
115 shuttle->SetInputCTPTimeParams(emptybuffer);
118 // simulating input from DAQ logbook
119 if (errorLevel != 1){
120 shuttle->AddInputRunParameter("DAQ_time_start", "1020");
122 if (errorLevel != 6){
123 shuttle->AddInputRunParameter("beamEnergy", "1400.");
126 shuttle->AddInputRunParameter("DAQ_time_end", "1980");
127 shuttle->AddInputRunParameter("beamType", beamType);
128 shuttle->AddInputRunParameter("numberOfDetectors", "5");
129 shuttle->AddInputRunParameter("detectorMask", "34555");
130 shuttle->AddInputRunParameter("LHCperiod", "LHC08b");
131 shuttle->AddInputRunParameter("partition",partition);
132 shuttle->AddInputRunParameter("detector",detector);
135 Bool_t hltStatus = kTRUE;
136 shuttle->SetInputHLTStatus(hltStatus);
138 // Create the preprocessor that should be tested, it registers itself automatically to the shuttle
139 AliPreprocessor* test = new AliGRPPreprocessor(shuttle);
141 // Test the preprocessor
146 // Check the file which should have been created
147 AliCDBEntry* chkEntry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())
148 ->Get("GRP/GRP/Data", kRun);
150 printf("The file is not there. Something went wrong.\n");
154 chkEntry->GetObject()->Print();
159 TMap* CreateDCSAliasMap(Int_t errorLevel)
161 // Creates a DCS structure
162 // The structure is the following:
163 // TMap (key --> value)
164 // <DCSAlias> --> <valueList>
165 // <DCSAlias> is a string
166 // <valueList> is a TObjArray of AliDCSValue
167 // An AliDCSValue consists of timestamp and a value in form of a AliSimpleValue
169 const Int_t fgknDCSDP = 48;
170 const char* fgkDCSDataPoints[AliGRPPreprocessor::fgknDCSDP] = {
178 "L3_BSF17_Temperature",
182 "L3_BSF4_Temperature",
186 "L3_BKF17_Temperature",
190 "L3_BKF4_Temperature",
194 "L3_BSF13_Temperature",
198 "L3_BSF8_Temperature",
202 "L3_BKF13_Temperature",
206 "L3_BKF8_Temperature",
210 "Dipole_Inside_Temperature",
214 "Dipole_Outside_Temperature",
216 "CavernAtmosPressure",
217 "SurfaceAtmosPressure",
218 "CavernAtmosPressure2",
226 aliasMap->SetOwner(1);
229 valueSet = new TObjArray;
230 valueSet->SetOwner(1);
231 dcsVal = new AliDCSValue( kTRUE, 1010 );
232 valueSet->Add(dcsVal);
233 dcsVal = new AliDCSValue( kTRUE, 1100 );
234 valueSet->Add(dcsVal);
235 dcsVal = new AliDCSValue( kTRUE, 1500 );
236 valueSet->Add(dcsVal);
237 dcsVal = new AliDCSValue( kTRUE, 1990 );
238 valueSet->Add(dcsVal);
239 // add the following two lines to test errors for changing polarity
240 // dcsVal = new AliDCSValue( kFALSE, 2 );
241 // valueSet->Add(dcsVal);
242 aliasMap->Add( new TObjString(fgkDCSDataPoints[1]), valueSet );
245 valueSet = new TObjArray;
246 valueSet->SetOwner(1);
247 dcsVal = new AliDCSValue( kTRUE, 1010 );
248 valueSet->Add(dcsVal);
249 dcsVal = new AliDCSValue( kTRUE, 1100 );
250 valueSet->Add(dcsVal);
251 dcsVal = new AliDCSValue( kTRUE, 1500 );
252 valueSet->Add(dcsVal);
253 dcsVal = new AliDCSValue( kTRUE, 1990 );
254 aliasMap->Add( new TObjString(fgkDCSDataPoints[2]), valueSet );
259 Int_t maxDPindex = 0;
260 if (errorLevel != 5) {
261 maxDPindex = fgknDCSDP;
264 maxDPindex = 3; // simulating only a few DP in case errorLevel=5
267 for( int nAlias=2; nAlias<maxDPindex; nAlias++) {
268 if (nAlias>=4 && nAlias < 44) continue;
269 valueSet = new TObjArray;
270 valueSet->SetOwner(1);
272 Int_t timeStampValue[10] = { 1010, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1990};
275 for (int timeStamp=0; timeStamp<10; timeStamp++) {
276 dcsVal = new AliDCSValue((Float_t) (timeStamp+1+10*nAlias), timeStampValue[timeStamp]);
277 valueSet->Add(dcsVal);
279 cout << " simulating " << fgkDCSDataPoints[nAlias] << endl;
280 aliasMap->Add( new TObjString( fgkDCSDataPoints[nAlias]), valueSet );
284 TString probe1[3] = {"L3_BSF","L3_BKF","Dipole_"};
285 TString probe2[6] = {"17_","4_","13_","8_","Inside_","Outside_"};
286 TString probe3[4] = {"H1","H2","H3","Temperature"};
289 for (Int_t i=0;i<3;i++){
290 for (Int_t j=0;j<6;j++){
291 for (Int_t k=0;k<4;k++){
292 TString dpAlias = probe1[i]+probe2[j]+probe3[k];
293 valueSet = new TObjArray;
294 valueSet->SetOwner(1);
295 for (int timeStamp=0; timeStamp<10; timeStamp++) {
296 dcsVal = new AliDCSValue((Float_t) (timeStamp+1+10*hp), timeStampValue[timeStamp]);
297 valueSet->Add(dcsVal);
298 //cout << " hall probe = " << dpAlias << " with value = " << dcsVal->GetFloat() << endl;
300 aliasMap->Add( new TObjString(dpAlias), valueSet );
310 TMap* ReadDCSAliasMap()
312 // Open a file that contains DCS input data
313 // The CDB framework is used to open the file, this means the file is located
314 // in $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB/<detector>/DCS/Data
315 // The file contains an AliCDBEntry that contains a TMap with the DCS structure.
316 // An explanation of the structure can be found in CreateDCSAliasMap()
318 AliCDBEntry *entry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())
319 ->Get("DET/DCS/Data", 0);
320 return dynamic_cast<TMap*> (entry->GetObject());
325 void WriteDCSAliasMap()
327 // This writes the output from CreateDCSAliasMap to a CDB file
329 TMap* dcsAliasMap = CreateDCSAliasMap(Int_t errorLevel);
331 AliCDBMetaData metaData;
332 metaData.SetBeamPeriod(0);
333 metaData.SetResponsible("Ernesto Lopez Torres");
334 metaData.SetComment("Test object for TestGRPPreprocessor.C");
336 AliCDBId id("GRP/Data", 0, 0);
338 // look into AliTestShuttle's CDB main folder
340 AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())
341 ->Put(dcsAliasMap, id, &metaData);