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
20 // 8 --> Missing LTU configuration
22 // Need to include dummy files in TestShuttle/TestCDB for CTP Configuration and Scalers
23 // (see macro $ALICE_ROOT/GRP/MakeCTPDummyEntries.C)
25 // Modified by C. Zampolli
32 void TestGRPPreprocessor(const char* runtype="PHYSICS", TString partition="ALICE", TString detector="", TString beamType = "p-p", Int_t errorLevel=0)
34 gSystem->Load("$ALICE_ROOT/SHUTTLE/TestShuttle/libTestShuttle.so");
36 AliLog::SetClassDebugLevel("AliGRPPreprocessor",3);
38 AliTestShuttle* shuttle = new AliTestShuttle(kRun, 1000, 2000);
40 AliTestShuttle::SetMainCDB("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB");
41 AliTestShuttle::SetMainRefStorage("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestReference");
43 printf("Test OCDB storage Uri: %s\n", AliShuttleInterface::GetMainCDB().Data());
44 printf("Test Reference storage Uri: %s\n", AliShuttleInterface::GetMainRefStorage().Data());
47 shuttle->SetInputRunType(runtype);
49 Int_t detectorMask = 1074200319;
50 TString detectorMask_Str(Form("%d",detectorMask));
51 shuttle->AddInputRunParameter("detectorMask", detectorMask_Str.Data());
53 TString* ltu = new TString[3];
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"){
65 if (errorLevel != 8 && !partition.IsNull() && detector.IsNull()){
66 shuttle->SetLTUConfig(ltu,detOnlineName.Data());
72 TMap* dcsAliasMap = CreateDCSAliasMap(errorLevel);
73 shuttle->SetDCSInput(dcsAliasMap);
75 // simulating input from DAQ FXS
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");
89 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");
90 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");
91 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");
92 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");
93 shuttle->AddInputFile(AliShuttleInterface::kDAQ, "SPD", "VertexDiamond", "gdc-GLOBAL-01", "/home/zampolli/SOFT/AliRoot/AliRoot_Trunk/GRP/ShuttleInput/run000104892_SPD_mon-DA-SPD-0_VertexDiamond");
94 shuttle->AddInputFile(AliShuttleInterface::kDCS, "GRP", "LHCData", "", "/home/zampolli/SOFT/AliRoot/AliRoot_Trunk/GRP/ShuttleInput/testRun_GRP_run_number_testRun_data.txt");
98 // simulating input from DCS FXS
99 if (errorLevel != 4 && !partition.IsNull() && detector.IsNull()){
100 shuttle->AddInputFile(AliShuttleInterface::kDCS, "GRP", "CTP_xcounters", "", gSystem->ExpandPathName("$ALICE_ROOT/GRP/CTP/xcounters.txt"));
103 Char_t * filename = gSystem->ExpandPathName("$ALICE_ROOT/GRP/CTP/p-p.cfg");
106 is.seekg(0,ios::end);
107 int length = is.tellg();
108 const char *buffer = new char[length];
109 is.seekg(0,ios::beg);
110 is.read(buffer,length);
112 const char *emptybuffer = NULL;
114 // simulating input from DAQ logbook_trigger_config
115 if (errorLevel != 3 && errorLevel != 7 && !partition.IsNull() && detector.IsNull()) {
116 cout << " adding trigger config " << endl;
117 shuttle->SetInputTriggerConfiguration(buffer);
119 else if (errorLevel == 7) {
120 shuttle->SetInputTriggerConfiguration(emptybuffer);
123 // open text file with CTP timing params
124 Char_t * fileNameTiming = gSystem->ExpandPathName("$ALICE_ROOT/GRP/ShuttleInput/ctptime.tim");
125 ifstream ifstrTiming;
126 ifstrTiming.open(fileNameTiming);
127 ifstrTiming.seekg(0,ios::end);
128 int lengthTiming = ifstrTiming.tellg();
129 const char *bufferTiming = new char[lengthTiming];
130 ifstrTiming.seekg(0,ios::beg);
131 ifstrTiming.read(bufferTiming,lengthTiming);
133 // const char *emptybuffer = NULL;
135 // simulating input from DAQ logbook_ctp_timing_params
136 if (errorLevel != 3 && errorLevel != 7 && !partition.IsNull() && detector.IsNull()) {
137 cout << " adding ctp timing params " <<endl;
138 shuttle->SetInputCTPTimeParams(bufferTiming);
140 else if (errorLevel == 7) {
141 shuttle->SetInputCTPTimeParams(emptybuffer);
144 // simulating input from DAQ logbook
145 if (errorLevel != 1){
146 shuttle->AddInputRunParameter("DAQ_time_start", "1020");
148 if (errorLevel != 6){
149 shuttle->AddInputRunParameter("beamEnergy", "123");
152 shuttle->AddInputRunParameter("DAQ_time_end", "1980");
153 shuttle->AddInputRunParameter("beamType", beamType);
154 shuttle->AddInputRunParameter("numberOfDetectors", "5");
155 shuttle->AddInputRunParameter("LHCperiod", "LHC08b");
156 shuttle->AddInputRunParameter("partition",partition);
157 shuttle->AddInputRunParameter("detector",detector);
160 Bool_t hltStatus = kTRUE;
161 shuttle->SetInputHLTStatus(hltStatus);
163 // Create the preprocessor that should be tested, it registers itself automatically to the shuttle
164 AliPreprocessor* test = new AliGRPPreprocessor(shuttle);
166 // Test the preprocessor
171 // Check the file which should have been created
172 AliCDBEntry* chkEntry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())
173 ->Get("GRP/GRP/Data", kRun);
175 printf("The file is not there. Something went wrong.\n");
179 chkEntry->GetObject()->Print();
184 TMap* CreateDCSAliasMap(Int_t errorLevel)
186 // Creates a DCS structure
187 // The structure is the following:
188 // TMap (key --> value)
189 // <DCSAlias> --> <valueList>
190 // <DCSAlias> is a string
191 // <valueList> is a TObjArray of AliDCSValue
192 // An AliDCSValue consists of timestamp and a value in form of a AliSimpleValue
194 const Int_t fgknDCSDP = 48;
195 const char* fgkDCSDataPoints[AliGRPPreprocessor::fgknDCSDP] = {
203 "L3_BSF17_Temperature",
207 "L3_BSF4_Temperature",
211 "L3_BKF17_Temperature",
215 "L3_BKF4_Temperature",
219 "L3_BSF13_Temperature",
223 "L3_BSF8_Temperature",
227 "L3_BKF13_Temperature",
231 "L3_BKF8_Temperature",
235 "Dipole_Inside_Temperature",
239 "Dipole_Outside_Temperature",
241 "CavernAtmosPressure",
242 "SurfaceAtmosPressure",
243 "CavernAtmosPressure2",
251 aliasMap->SetOwner(1);
254 valueSet = new TObjArray;
255 valueSet->SetOwner(1);
256 dcsVal = new AliDCSValue( kTRUE, 1010 );
257 valueSet->Add(dcsVal);
258 dcsVal = new AliDCSValue( kTRUE, 1100 );
259 valueSet->Add(dcsVal);
260 dcsVal = new AliDCSValue( kTRUE, 1500 );
261 valueSet->Add(dcsVal);
262 dcsVal = new AliDCSValue( kTRUE, 1990 );
263 valueSet->Add(dcsVal);
264 // add the following two lines to test errors for changing polarity
265 // dcsVal = new AliDCSValue( kFALSE, 2 );
266 // valueSet->Add(dcsVal);
267 aliasMap->Add( new TObjString(fgkDCSDataPoints[1]), valueSet );
270 valueSet = new TObjArray;
271 valueSet->SetOwner(1);
272 dcsVal = new AliDCSValue( kTRUE, 1010 );
273 valueSet->Add(dcsVal);
274 dcsVal = new AliDCSValue( kTRUE, 1100 );
275 valueSet->Add(dcsVal);
276 dcsVal = new AliDCSValue( kTRUE, 1500 );
277 valueSet->Add(dcsVal);
278 dcsVal = new AliDCSValue( kTRUE, 1990 );
279 aliasMap->Add( new TObjString(fgkDCSDataPoints[2]), valueSet );
284 Int_t maxDPindex = 0;
285 if (errorLevel != 5) {
286 maxDPindex = fgknDCSDP;
289 maxDPindex = 3; // simulating only a few DP in case errorLevel=5
292 for( int nAlias=2; nAlias<maxDPindex; nAlias++) {
293 if (nAlias>=4 && nAlias < 44) continue;
294 valueSet = new TObjArray;
295 valueSet->SetOwner(1);
297 Int_t timeStampValue[10] = { 1010, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1990};
300 for (int timeStamp=0; timeStamp<10; timeStamp++) {
301 dcsVal = new AliDCSValue((Float_t) (timeStamp+1+10*nAlias), timeStampValue[timeStamp]);
302 valueSet->Add(dcsVal);
304 cout << " simulating " << fgkDCSDataPoints[nAlias] << endl;
305 aliasMap->Add( new TObjString( fgkDCSDataPoints[nAlias]), valueSet );
309 TString probe1[3] = {"L3_BSF","L3_BKF","Dipole_"};
310 TString probe2[6] = {"17_","4_","13_","8_","Inside_","Outside_"};
311 TString probe3[4] = {"H1","H2","H3","Temperature"};
314 for (Int_t i=0;i<3;i++){
315 for (Int_t j=0;j<6;j++){
316 for (Int_t k=0;k<4;k++){
317 TString dpAlias = probe1[i]+probe2[j]+probe3[k];
318 valueSet = new TObjArray;
319 valueSet->SetOwner(1);
320 for (int timeStamp=0; timeStamp<10; timeStamp++) {
321 dcsVal = new AliDCSValue((Float_t) (timeStamp+1+10*hp), timeStampValue[timeStamp]);
322 valueSet->Add(dcsVal);
323 //cout << " hall probe = " << dpAlias << " with value = " << dcsVal->GetFloat() << endl;
325 aliasMap->Add( new TObjString(dpAlias), valueSet );
335 TMap* ReadDCSAliasMap()
337 // Open a file that contains DCS input data
338 // The CDB framework is used to open the file, this means the file is located
339 // in $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB/<detector>/DCS/Data
340 // The file contains an AliCDBEntry that contains a TMap with the DCS structure.
341 // An explanation of the structure can be found in CreateDCSAliasMap()
343 AliCDBEntry *entry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())
344 ->Get("DET/DCS/Data", 0);
345 return dynamic_cast<TMap*> (entry->GetObject());
350 void WriteDCSAliasMap()
352 // This writes the output from CreateDCSAliasMap to a CDB file
354 TMap* dcsAliasMap = CreateDCSAliasMap(Int_t errorLevel);
356 AliCDBMetaData metaData;
357 metaData.SetBeamPeriod(0);
358 metaData.SetResponsible("Ernesto Lopez Torres");
359 metaData.SetComment("Test object for TestGRPPreprocessor.C");
361 AliCDBId id("GRP/Data", 0, 0);
363 // look into AliTestShuttle's CDB main folder
365 AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())
366 ->Put(dcsAliasMap, id, &metaData);