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");
62 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");
63 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");
64 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");
65 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");
66 shuttle->AddInputFile(AliShuttleInterface::kDAQ, "SPD", "VertexDiamond", "gdc-GLOBAL-01", "/home/zampolli/SOFT/AliRoot/AliRoot_Trunk/GRP/ShuttleInput/run000104892_SPD_mon-DA-SPD-0_VertexDiamond");
70 // simulating input from DCS FXS
71 if (errorLevel != 4 && !partition.IsNull() && detector.IsNull()){
72 shuttle->AddInputFile(AliShuttleInterface::kDCS, "GRP", "CTP_xcounters", "", gSystem->ExpandPathName("$ALICE_ROOT/GRP/CTP/xcounters.txt"));
75 Char_t * filename = gSystem->ExpandPathName("$ALICE_ROOT/GRP/CTP/p-p.cfg");
79 int length = is.tellg();
80 const char *buffer = new char[length];
82 is.read(buffer,length);
84 const char *emptybuffer = NULL;
86 // simulating input from DAQ logbook_trigger_config
87 if (errorLevel != 3 && errorLevel != 7 && !partition.IsNull() && detector.IsNull()) {
88 cout << " adding trigger config " << endl;
89 shuttle->SetInputTriggerConfiguration(buffer);
91 else if (errorLevel == 7) {
92 shuttle->SetInputTriggerConfiguration(emptybuffer);
95 // open text file with CTP timing params
96 Char_t * fileNameTiming = gSystem->ExpandPathName("$ALICE_ROOT/GRP/ShuttleInput/ctptime.tim");
98 ifstrTiming.open(fileNameTiming);
99 ifstrTiming.seekg(0,ios::end);
100 int lengthTiming = ifstrTiming.tellg();
101 const char *bufferTiming = new char[lengthTiming];
102 ifstrTiming.seekg(0,ios::beg);
103 ifstrTiming.read(bufferTiming,lengthTiming);
105 // const char *emptybuffer = NULL;
107 // simulating input from DAQ logbook_ctp_timing_params
108 if (errorLevel != 3 && errorLevel != 7 && !partition.IsNull() && detector.IsNull()) {
109 cout << " adding ctp timing params " <<endl;
110 shuttle->SetInputCTPTimeParams(bufferTiming);
112 else if (errorLevel == 7) {
113 shuttle->SetInputCTPTimeParams(emptybuffer);
116 // simulating input from DAQ logbook
117 if (errorLevel != 1){
118 shuttle->AddInputRunParameter("DAQ_time_start", "1020");
120 if (errorLevel != 6){
121 shuttle->AddInputRunParameter("beamEnergy", "1400.");
124 shuttle->AddInputRunParameter("DAQ_time_end", "1980");
125 shuttle->AddInputRunParameter("beamType", beamType);
126 shuttle->AddInputRunParameter("numberOfDetectors", "5");
127 shuttle->AddInputRunParameter("detectorMask", "34555");
128 shuttle->AddInputRunParameter("LHCperiod", "LHC08b");
129 shuttle->AddInputRunParameter("partition",partition);
130 shuttle->AddInputRunParameter("detector",detector);
133 Bool_t hltStatus = kTRUE;
134 shuttle->SetInputHLTStatus(hltStatus);
136 // Create the preprocessor that should be tested, it registers itself automatically to the shuttle
137 AliPreprocessor* test = new AliGRPPreprocessor(shuttle);
139 // Test the preprocessor
144 // Check the file which should have been created
145 AliCDBEntry* chkEntry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())
146 ->Get("GRP/GRP/Data", kRun);
148 printf("The file is not there. Something went wrong.\n");
152 chkEntry->GetObject()->Print();
157 TMap* CreateDCSAliasMap(Int_t errorLevel)
159 // Creates a DCS structure
160 // The structure is the following:
161 // TMap (key --> value)
162 // <DCSAlias> --> <valueList>
163 // <DCSAlias> is a string
164 // <valueList> is a TObjArray of AliDCSValue
165 // An AliDCSValue consists of timestamp and a value in form of a AliSimpleValue
167 const Int_t fgknDCSDP = 51;
168 const char* fgkDCSDataPoints[AliGRPPreprocessor::fgknDCSDP] = {
169 "LHCState", // missing in DCS
172 "LHCLuminosity", // missing in DCS
173 "BeamIntensity", // missing in DCS
179 "L3_BSF17_Temperature",
183 "L3_BSF4_Temperature",
187 "L3_BKF17_Temperature",
191 "L3_BKF4_Temperature",
195 "L3_BSF13_Temperature",
199 "L3_BSF8_Temperature",
203 "L3_BKF13_Temperature",
207 "L3_BKF8_Temperature",
211 "Dipole_Inside_Temperature",
215 "Dipole_Outside_Temperature",
217 "CavernAtmosPressure",
218 "SurfaceAtmosPressure",
219 "CavernAtmosPressure2",
227 aliasMap->SetOwner(1);
231 valueSet = new TObjArray;
232 valueSet->SetOwner(1);
233 dcsVal = new AliDCSValue( 'F', 2 );
234 valueSet->Add(dcsVal);
235 aliasMap->Add( new TObjString(fgkDCSDataPoints[0]), valueSet );
239 valueSet = new TObjArray;
240 valueSet->SetOwner(1);
241 dcsVal = new AliDCSValue( kTRUE, 1010 );
242 valueSet->Add(dcsVal);
243 dcsVal = new AliDCSValue( kTRUE, 1100 );
244 valueSet->Add(dcsVal);
245 dcsVal = new AliDCSValue( kTRUE, 1500 );
246 valueSet->Add(dcsVal);
247 dcsVal = new AliDCSValue( kTRUE, 1990 );
248 valueSet->Add(dcsVal);
249 // add the following two lines to test errors for changing polarity
250 // dcsVal = new AliDCSValue( kFALSE, 2 );
251 // valueSet->Add(dcsVal);
252 aliasMap->Add( new TObjString(fgkDCSDataPoints[1]), valueSet );
255 valueSet = new TObjArray;
256 valueSet->SetOwner(1);
257 dcsVal = new AliDCSValue( kTRUE, 1010 );
258 valueSet->Add(dcsVal);
259 dcsVal = new AliDCSValue( kTRUE, 1100 );
260 valueSet->Add(dcsVal);
261 dcsVal = new AliDCSValue( kTRUE, 1500 );
262 valueSet->Add(dcsVal);
263 dcsVal = new AliDCSValue( kTRUE, 1990 );
264 aliasMap->Add( new TObjString(fgkDCSDataPoints[2]), valueSet );
266 // LHCLuminosity - keeping outside look to check procedure to calculate statistics values
267 valueSet = new TObjArray;
268 valueSet->SetOwner(1);
269 dcsVal = new AliDCSValue( (Float_t)2, 1010 );
270 valueSet->Add(dcsVal);
271 dcsVal = new AliDCSValue( (Float_t)4, 1100 );
272 valueSet->Add(dcsVal);
273 dcsVal = new AliDCSValue( (Float_t)6, 1200 );
274 valueSet->Add(dcsVal);
275 dcsVal = new AliDCSValue( (Float_t)8, 1985 );
276 valueSet->Add(dcsVal);
277 aliasMap->Add( new TObjString(fgkDCSDataPoints[3]), valueSet );
281 Int_t maxDPindex = 0;
282 if (errorLevel != 5) {
283 maxDPindex = fgknDCSDP;
286 maxDPindex = 3; // simulating only a few DP in case errorLevel=5
289 for( int nAlias=4; nAlias<maxDPindex; nAlias++) {
290 if (nAlias>=7 && nAlias < 47) continue;
291 valueSet = new TObjArray;
292 valueSet->SetOwner(1);
294 Int_t timeStampValue[10] = { 1010, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1990};
297 for (int timeStamp=0; timeStamp<10; timeStamp++) {
298 dcsVal = new AliDCSValue((Float_t) (timeStamp+1+10*nAlias), timeStampValue[timeStamp]);
299 valueSet->Add(dcsVal);
301 cout << " simulating " << fgkDCSDataPoints[nAlias] << endl;
302 aliasMap->Add( new TObjString( fgkDCSDataPoints[nAlias]), valueSet );
306 TString probe1[3] = {"L3_BSF","L3_BKF","Dipole_"};
307 TString probe2[6] = {"17_","4_","13_","8_","Inside_","Outside_"};
308 TString probe3[4] = {"H1","H2","H3","Temperature"};
311 for (Int_t i=0;i<3;i++){
312 for (Int_t j=0;j<6;j++){
313 for (Int_t k=0;k<4;k++){
314 TString dpAlias = probe1[i]+probe2[j]+probe3[k];
315 valueSet = new TObjArray;
316 valueSet->SetOwner(1);
317 for (int timeStamp=0; timeStamp<10; timeStamp++) {
318 dcsVal = new AliDCSValue((Float_t) (timeStamp+1+10*hp), timeStampValue[timeStamp]);
319 valueSet->Add(dcsVal);
320 //cout << " hall probe = " << dpAlias << " with value = " << dcsVal->GetFloat() << endl;
322 aliasMap->Add( new TObjString(dpAlias), valueSet );
332 TMap* ReadDCSAliasMap()
334 // Open a file that contains DCS input data
335 // The CDB framework is used to open the file, this means the file is located
336 // in $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB/<detector>/DCS/Data
337 // The file contains an AliCDBEntry that contains a TMap with the DCS structure.
338 // An explanation of the structure can be found in CreateDCSAliasMap()
340 AliCDBEntry *entry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())
341 ->Get("DET/DCS/Data", 0);
342 return dynamic_cast<TMap*> (entry->GetObject());
347 void WriteDCSAliasMap()
349 // This writes the output from CreateDCSAliasMap to a CDB file
351 TMap* dcsAliasMap = CreateDCSAliasMap(Int_t errorLevel);
353 AliCDBMetaData metaData;
354 metaData.SetBeamPeriod(0);
355 metaData.SetResponsible("Ernesto Lopez Torres");
356 metaData.SetComment("Test object for TestGRPPreprocessor.C");
358 AliCDBId id("GRP/Data", 0, 0);
360 // look into AliTestShuttle's CDB main folder
362 AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())
363 ->Put(dcsAliasMap, id, &metaData);