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");
85 shuttle->AddInputFile(AliShuttleInterface::kDQM, "GRP", "TriggerClassesAndHistosToClone", "DQM", "$ALICE_ROOT/GRP/ShuttleInput/run000158496_GRP_DQM_TriggerClassesAndHistosToClone");
86 shuttle->AddInputFile(AliShuttleInterface::kDQM, "ACO", "QAThresholds", "DQM", "$ALICE_ROOT/GRP/ShuttleInput/run000168322_ACO_DQM_QAThresholds");
87 shuttle->AddInputFile(AliShuttleInterface::kDQM, "TPC", "QAThresholds", "DQM", "$ALICE_ROOT/GRP/ShuttleInput/run000168322_TPC_DQM_QAThresholds");
92 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");
93 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");
94 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");
95 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");
96 shuttle->AddInputFile(AliShuttleInterface::kDAQ, "SPD", "VertexDiamond", "gdc-GLOBAL-01", "/home/zampolli/SOFT/AliRoot/AliRoot_Trunk/GRP/ShuttleInput/run000104892_SPD_mon-DA-SPD-0_VertexDiamond");
97 shuttle->AddInputFile(AliShuttleInterface::kDCS, "GRP", "LHCData", "", "/home/zampolli/SOFT/AliRoot/AliRoot_Trunk/GRP/ShuttleInput/testRun_GRP_run_number_testRun_data.txt");
101 // simulating input from DCS FXS
102 if (errorLevel != 4 && !partition.IsNull() && detector.IsNull()){
103 shuttle->AddInputFile(AliShuttleInterface::kDCS, "GRP", "CTP_xcounters", "", gSystem->ExpandPathName("$ALICE_ROOT/GRP/CTP/xcounters.txt"));
106 Char_t * filename = gSystem->ExpandPathName("$ALICE_ROOT/GRP/CTP/p-p.cfg");
109 is.seekg(0,ios::end);
110 int length = is.tellg();
111 const char *buffer = new char[length];
112 is.seekg(0,ios::beg);
113 is.read(buffer,length);
115 const char *emptybuffer = NULL;
117 // simulating input from DAQ logbook_trigger_config
118 if (errorLevel != 3 && errorLevel != 7 && !partition.IsNull() && detector.IsNull()) {
119 cout << " adding trigger config " << endl;
120 shuttle->SetInputTriggerConfiguration(buffer);
122 else if (errorLevel == 7) {
123 shuttle->SetInputTriggerConfiguration(emptybuffer);
126 // open text file with CTP timing params
127 Char_t * fileNameTiming = gSystem->ExpandPathName("$ALICE_ROOT/GRP/ShuttleInput/ctptime.tim");
128 ifstream ifstrTiming;
129 ifstrTiming.open(fileNameTiming);
130 ifstrTiming.seekg(0,ios::end);
131 int lengthTiming = ifstrTiming.tellg();
132 const char *bufferTiming = new char[lengthTiming];
133 ifstrTiming.seekg(0,ios::beg);
134 ifstrTiming.read(bufferTiming,lengthTiming);
136 // const char *emptybuffer = NULL;
138 // simulating input from DAQ logbook_ctp_timing_params
139 if (errorLevel != 3 && errorLevel != 7 && !partition.IsNull() && detector.IsNull()) {
140 cout << " adding ctp timing params " <<endl;
141 shuttle->SetInputCTPTimeParams(bufferTiming);
143 else if (errorLevel == 7) {
144 shuttle->SetInputCTPTimeParams(emptybuffer);
147 // simulating input from DAQ logbook
148 if (errorLevel != 1){
149 shuttle->AddInputRunParameter("DAQ_time_start", "1020");
151 if (errorLevel != 6){
152 shuttle->AddInputRunParameter("beamEnergy", "123");
155 shuttle->AddInputRunParameter("DAQ_time_end", "1980");
156 shuttle->AddInputRunParameter("beamType", beamType);
157 shuttle->AddInputRunParameter("numberOfDetectors", "5");
158 shuttle->AddInputRunParameter("LHCperiod", "LHC08b");
159 shuttle->AddInputRunParameter("partition",partition);
160 shuttle->AddInputRunParameter("detector",detector);
163 Bool_t hltStatus = kTRUE;
164 shuttle->SetInputHLTStatus(hltStatus);
166 // Create the preprocessor that should be tested, it registers itself automatically to the shuttle
167 AliPreprocessor* test = new AliGRPPreprocessor(shuttle);
169 // Test the preprocessor
174 // Check the file which should have been created
175 AliCDBEntry* chkEntry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())
176 ->Get("GRP/GRP/Data", kRun);
178 printf("The file is not there. Something went wrong.\n");
182 chkEntry->GetObject()->Print();
187 TMap* CreateDCSAliasMap(Int_t errorLevel)
189 // Creates a DCS structure
190 // The structure is the following:
191 // TMap (key --> value)
192 // <DCSAlias> --> <valueList>
193 // <DCSAlias> is a string
194 // <valueList> is a TObjArray of AliDCSValue
195 // An AliDCSValue consists of timestamp and a value in form of a AliSimpleValue
197 const Int_t fgknDCSDP = 48;
198 const char* fgkDCSDataPoints[AliGRPPreprocessor::fgknDCSDP] = {
206 "L3_BSF17_Temperature",
210 "L3_BSF4_Temperature",
214 "L3_BKF17_Temperature",
218 "L3_BKF4_Temperature",
222 "L3_BSF13_Temperature",
226 "L3_BSF8_Temperature",
230 "L3_BKF13_Temperature",
234 "L3_BKF8_Temperature",
238 "Dipole_Inside_Temperature",
242 "Dipole_Outside_Temperature",
244 "CavernAtmosPressure",
245 "SurfaceAtmosPressure",
246 "CavernAtmosPressure2",
254 aliasMap->SetOwner(1);
257 valueSet = new TObjArray;
258 valueSet->SetOwner(1);
259 dcsVal = new AliDCSValue( kTRUE, 1010 );
260 valueSet->Add(dcsVal);
261 dcsVal = new AliDCSValue( kTRUE, 1100 );
262 valueSet->Add(dcsVal);
263 dcsVal = new AliDCSValue( kTRUE, 1500 );
264 valueSet->Add(dcsVal);
265 dcsVal = new AliDCSValue( kTRUE, 1990 );
266 valueSet->Add(dcsVal);
267 // add the following two lines to test errors for changing polarity
268 // dcsVal = new AliDCSValue( kFALSE, 2 );
269 // valueSet->Add(dcsVal);
270 aliasMap->Add( new TObjString(fgkDCSDataPoints[1]), valueSet );
273 valueSet = new TObjArray;
274 valueSet->SetOwner(1);
275 dcsVal = new AliDCSValue( kTRUE, 1010 );
276 valueSet->Add(dcsVal);
277 dcsVal = new AliDCSValue( kTRUE, 1100 );
278 valueSet->Add(dcsVal);
279 dcsVal = new AliDCSValue( kTRUE, 1500 );
280 valueSet->Add(dcsVal);
281 dcsVal = new AliDCSValue( kTRUE, 1990 );
282 aliasMap->Add( new TObjString(fgkDCSDataPoints[2]), valueSet );
287 Int_t maxDPindex = 0;
288 if (errorLevel != 5) {
289 maxDPindex = fgknDCSDP;
292 maxDPindex = 3; // simulating only a few DP in case errorLevel=5
295 for( int nAlias=2; nAlias<maxDPindex; nAlias++) {
296 if (nAlias>=4 && nAlias < 44) continue;
297 valueSet = new TObjArray;
298 valueSet->SetOwner(1);
300 Int_t timeStampValue[10] = { 1010, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1990};
303 for (int timeStamp=0; timeStamp<10; timeStamp++) {
304 dcsVal = new AliDCSValue((Float_t) (timeStamp+1+10*nAlias), timeStampValue[timeStamp]);
305 valueSet->Add(dcsVal);
307 cout << " simulating " << fgkDCSDataPoints[nAlias] << endl;
308 aliasMap->Add( new TObjString( fgkDCSDataPoints[nAlias]), valueSet );
312 TString probe1[3] = {"L3_BSF","L3_BKF","Dipole_"};
313 TString probe2[6] = {"17_","4_","13_","8_","Inside_","Outside_"};
314 TString probe3[4] = {"H1","H2","H3","Temperature"};
317 for (Int_t i=0;i<3;i++){
318 for (Int_t j=0;j<6;j++){
319 for (Int_t k=0;k<4;k++){
320 TString dpAlias = probe1[i]+probe2[j]+probe3[k];
321 valueSet = new TObjArray;
322 valueSet->SetOwner(1);
323 for (int timeStamp=0; timeStamp<10; timeStamp++) {
324 dcsVal = new AliDCSValue((Float_t) (timeStamp+1+10*hp), timeStampValue[timeStamp]);
325 valueSet->Add(dcsVal);
326 //cout << " hall probe = " << dpAlias << " with value = " << dcsVal->GetFloat() << endl;
328 aliasMap->Add( new TObjString(dpAlias), valueSet );
338 TMap* ReadDCSAliasMap()
340 // Open a file that contains DCS input data
341 // The CDB framework is used to open the file, this means the file is located
342 // in $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB/<detector>/DCS/Data
343 // The file contains an AliCDBEntry that contains a TMap with the DCS structure.
344 // An explanation of the structure can be found in CreateDCSAliasMap()
346 AliCDBEntry *entry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())
347 ->Get("DET/DCS/Data", 0);
348 return dynamic_cast<TMap*> (entry->GetObject());
353 void WriteDCSAliasMap()
355 // This writes the output from CreateDCSAliasMap to a CDB file
357 TMap* dcsAliasMap = CreateDCSAliasMap(Int_t errorLevel);
359 AliCDBMetaData metaData;
360 metaData.SetBeamPeriod(0);
361 metaData.SetResponsible("Ernesto Lopez Torres");
362 metaData.SetComment("Test object for TestGRPPreprocessor.C");
364 AliCDBId id("GRP/Data", 0, 0);
366 // look into AliTestShuttle's CDB main folder
368 AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())
369 ->Put(dcsAliasMap, id, &metaData);