]>
Commit | Line | Data |
---|---|---|
92e5c8ed | 1 | |
2 | // This macro runs the GRP test preprocessor | |
3 | // It uses AliTestShuttle to simulate a full Shuttle process | |
4 | ||
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 | |
9 | ||
e75e6e01 | 10 | // Taking as input runtype and errorLevel |
11 | // errorLevel used to simulate errors: | |
12 | // 0 --> no error | |
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 | |
6b2ffa8d | 20 | // 8 --> Missing LTU configuration |
e75e6e01 | 21 | |
22 | // Need to include dummy files in TestShuttle/TestCDB for CTP Configuration and Scalers | |
23 | // (see macro $ALICE_ROOT/GRP/MakeCTPDummyEntries.C) | |
24 | ||
25 | // Modified by C. Zampolli | |
26 | ||
27 | ||
e3efae04 | 28 | #include <iostream> |
29 | #include <fstream> | |
30 | using namespace std; | |
92e5c8ed | 31 | |
e75e6e01 | 32 | void TestGRPPreprocessor(const char* runtype="PHYSICS", TString partition="ALICE", TString detector="", TString beamType = "p-p", Int_t errorLevel=0) |
92e5c8ed | 33 | { |
92e5c8ed | 34 | gSystem->Load("$ALICE_ROOT/SHUTTLE/TestShuttle/libTestShuttle.so"); |
35 | ||
7f32679b | 36 | AliLog::SetClassDebugLevel("AliGRPPreprocessor",3); |
92e5c8ed | 37 | Int_t kRun = 7; |
6614fa48 | 38 | AliTestShuttle* shuttle = new AliTestShuttle(kRun, 1000, 2000); |
92e5c8ed | 39 | |
e75e6e01 | 40 | AliTestShuttle::SetMainCDB("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB"); |
41 | AliTestShuttle::SetMainRefStorage("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestReference"); | |
92e5c8ed | 42 | |
43 | printf("Test OCDB storage Uri: %s\n", AliShuttleInterface::GetMainCDB().Data()); | |
44 | printf("Test Reference storage Uri: %s\n", AliShuttleInterface::GetMainRefStorage().Data()); | |
45 | ||
e75e6e01 | 46 | // setting runtype |
47 | shuttle->SetInputRunType(runtype); | |
92e5c8ed | 48 | |
6ecb073a | 49 | Int_t detectorMask = 1074200319; |
50 | TString detectorMask_Str(Form("%d",detectorMask)); | |
51 | shuttle->AddInputRunParameter("detectorMask", detectorMask_Str.Data()); | |
52 | ||
53 | TString* ltu = new TString[3]; | |
54 | ltu[0] = "2000"; | |
55 | ltu[1] = "6000"; | |
56 | ltu[2] = "8000"; | |
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"){ | |
61 | ltu[0] = "3000"; | |
62 | ltu[1] = "7000"; | |
63 | ltu[2] = "9000"; | |
64 | } | |
6b2ffa8d | 65 | if (errorLevel != 8 && !partition.IsNull() && detector.IsNull()){ |
66 | shuttle->SetLTUConfig(ltu,detOnlineName.Data()); | |
67 | } | |
6ecb073a | 68 | } |
69 | } | |
70 | ||
e75e6e01 | 71 | // simulating DCS DPs |
72 | TMap* dcsAliasMap = CreateDCSAliasMap(errorLevel); | |
92e5c8ed | 73 | shuttle->SetDCSInput(dcsAliasMap); |
74 | ||
e75e6e01 | 75 | // simulating input from DAQ FXS |
76 | if (errorLevel != 2){ | |
6ecb073a | 77 | |
6614fa48 | 78 | //$ALICE_ROOT to be expanded manually by the user for this test macro |
7f32679b | 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"); | |
6a150f83 | 83 | shuttle->AddInputFile(AliShuttleInterface::kDAQ, "SPD", "VertexDiamond", "gdc-GLOBAL-01", "$ALICE_ROOT/GRP/ShuttleInput/run000104892_SPD_mon-DA-SPD-0_VertexDiamond"); |
0254e751 | 84 | shuttle->AddInputFile(AliShuttleInterface::kDCS, "GRP", "LHCData", "", "$ALICE_ROOT/GRP/ShuttleInput/testRun_GRP_run_number_testRun_data.txt"); |
59fef0d0 | 85 | shuttle->AddInputFile(AliShuttleInterface::kDQM, "GRP", "TriggerClassesAndHistosToClone", "DQM", "$ALICE_ROOT/GRP/ShuttleInput/run000158496_GRP_DQM_TriggerClassesAndHistosToClone"); |
72a680b3 | 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"); | |
6ecb073a | 88 | |
6ecb073a | 89 | /* |
6b2ffa8d | 90 | // for example: |
91 | ||
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"); | |
6ecb073a | 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"); | |
6b2ffa8d | 98 | */ |
e75e6e01 | 99 | } |
100 | ||
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")); | |
104 | } | |
105 | ||
e3efae04 | 106 | Char_t * filename = gSystem->ExpandPathName("$ALICE_ROOT/GRP/CTP/p-p.cfg"); |
107 | ifstream is; | |
108 | is.open(filename); | |
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); | |
114 | is.close(); | |
e75e6e01 | 115 | const char *emptybuffer = NULL; |
92e5c8ed | 116 | |
e75e6e01 | 117 | // simulating input from DAQ logbook_trigger_config |
7f32679b | 118 | if (errorLevel != 3 && errorLevel != 7 && !partition.IsNull() && detector.IsNull()) { |
119 | cout << " adding trigger config " << endl; | |
120 | shuttle->SetInputTriggerConfiguration(buffer); | |
e75e6e01 | 121 | } |
122 | else if (errorLevel == 7) { | |
123 | shuttle->SetInputTriggerConfiguration(emptybuffer); | |
124 | } | |
e3efae04 | 125 | |
6614fa48 | 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); | |
135 | ifstrTiming.close(); | |
136 | // const char *emptybuffer = NULL; | |
137 | ||
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); | |
142 | } | |
143 | else if (errorLevel == 7) { | |
144 | shuttle->SetInputCTPTimeParams(emptybuffer); | |
145 | } | |
146 | ||
e75e6e01 | 147 | // simulating input from DAQ logbook |
148 | if (errorLevel != 1){ | |
6614fa48 | 149 | shuttle->AddInputRunParameter("DAQ_time_start", "1020"); |
e75e6e01 | 150 | } |
151 | if (errorLevel != 6){ | |
6ecb073a | 152 | shuttle->AddInputRunParameter("beamEnergy", "123"); |
e75e6e01 | 153 | } |
154 | ||
6614fa48 | 155 | shuttle->AddInputRunParameter("DAQ_time_end", "1980"); |
6ecb073a | 156 | shuttle->AddInputRunParameter("beamType", beamType); |
92e5c8ed | 157 | shuttle->AddInputRunParameter("numberOfDetectors", "5"); |
92e5c8ed | 158 | shuttle->AddInputRunParameter("LHCperiod", "LHC08b"); |
e75e6e01 | 159 | shuttle->AddInputRunParameter("partition",partition); |
160 | shuttle->AddInputRunParameter("detector",detector); | |
92e5c8ed | 161 | |
e75e6e01 | 162 | // simulating HLT |
92e5c8ed | 163 | Bool_t hltStatus = kTRUE; |
164 | shuttle->SetInputHLTStatus(hltStatus); | |
165 | ||
92e5c8ed | 166 | // Create the preprocessor that should be tested, it registers itself automatically to the shuttle |
167 | AliPreprocessor* test = new AliGRPPreprocessor(shuttle); | |
168 | ||
169 | // Test the preprocessor | |
170 | shuttle->Process(); | |
171 | ||
172 | printf("\n\n"); | |
173 | ||
92e5c8ed | 174 | // Check the file which should have been created |
175 | AliCDBEntry* chkEntry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB()) | |
176 | ->Get("GRP/GRP/Data", kRun); | |
177 | if (!chkEntry) { | |
178 | printf("The file is not there. Something went wrong.\n"); | |
179 | return; | |
180 | } | |
181 | chkEntry->PrintId(); | |
182 | chkEntry->GetObject()->Print(); | |
183 | printf("\n\n"); | |
184 | ||
92e5c8ed | 185 | } |
186 | ||
e75e6e01 | 187 | TMap* CreateDCSAliasMap(Int_t errorLevel) |
92e5c8ed | 188 | { |
189 | // Creates a DCS structure | |
190 | // The structure is the following: | |
e75e6e01 | 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 | |
92e5c8ed | 196 | |
0254e751 | 197 | const Int_t fgknDCSDP = 48; |
92e5c8ed | 198 | const char* fgkDCSDataPoints[AliGRPPreprocessor::fgknDCSDP] = { |
92e5c8ed | 199 | "L3Polarity", |
200 | "DipolePolarity", | |
92e5c8ed | 201 | "L3Current", |
202 | "DipoleCurrent", | |
e75e6e01 | 203 | "L3_BSF17_H1", |
204 | "L3_BSF17_H2", | |
205 | "L3_BSF17_H3", | |
206 | "L3_BSF17_Temperature", | |
207 | "L3_BSF4_H1", | |
208 | "L3_BSF4_H2", | |
209 | "L3_BSF4_H3", | |
210 | "L3_BSF4_Temperature", | |
211 | "L3_BKF17_H1", | |
212 | "L3_BKF17_H2", | |
213 | "L3_BKF17_H3", | |
214 | "L3_BKF17_Temperature", | |
215 | "L3_BKF4_H1", | |
216 | "L3_BKF4_H2", | |
217 | "L3_BKF4_H3", | |
218 | "L3_BKF4_Temperature", | |
219 | "L3_BSF13_H1", | |
220 | "L3_BSF13_H2", | |
221 | "L3_BSF13_H3", | |
222 | "L3_BSF13_Temperature", | |
223 | "L3_BSF8_H1", | |
224 | "L3_BSF8_H2", | |
225 | "L3_BSF8_H3", | |
226 | "L3_BSF8_Temperature", | |
227 | "L3_BKF13_H1", | |
228 | "L3_BKF13_H2", | |
229 | "L3_BKF13_H3", | |
230 | "L3_BKF13_Temperature", | |
231 | "L3_BKF8_H1", | |
232 | "L3_BKF8_H2", | |
233 | "L3_BKF8_H3", | |
234 | "L3_BKF8_Temperature", | |
235 | "Dipole_Inside_H1", | |
236 | "Dipole_Inside_H2", | |
237 | "Dipole_Inside_H3", | |
238 | "Dipole_Inside_Temperature", | |
239 | "Dipole_Outside_H1", | |
240 | "Dipole_Outside_H2", | |
241 | "Dipole_Outside_H3", | |
242 | "Dipole_Outside_Temperature", | |
92e5c8ed | 243 | "CavernTemperature", |
244 | "CavernAtmosPressure", | |
ce996d13 | 245 | "SurfaceAtmosPressure", |
246 | "CavernAtmosPressure2", | |
92e5c8ed | 247 | }; |
248 | ||
249 | TMap* aliasMap; | |
250 | TObjArray* valueSet; | |
251 | AliDCSValue* dcsVal; | |
252 | ||
253 | aliasMap = new TMap; | |
254 | aliasMap->SetOwner(1); | |
255 | ||
92e5c8ed | 256 | // L3Polarity |
257 | valueSet = new TObjArray; | |
258 | valueSet->SetOwner(1); | |
6614fa48 | 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 ); | |
92e5c8ed | 266 | valueSet->Add(dcsVal); |
dba333ae | 267 | // add the following two lines to test errors for changing polarity |
268 | // dcsVal = new AliDCSValue( kFALSE, 2 ); | |
269 | // valueSet->Add(dcsVal); | |
92e5c8ed | 270 | aliasMap->Add( new TObjString(fgkDCSDataPoints[1]), valueSet ); |
271 | ||
272 | // DipolePolarity | |
273 | valueSet = new TObjArray; | |
274 | valueSet->SetOwner(1); | |
6614fa48 | 275 | dcsVal = new AliDCSValue( kTRUE, 1010 ); |
276 | valueSet->Add(dcsVal); | |
277 | dcsVal = new AliDCSValue( kTRUE, 1100 ); | |
92e5c8ed | 278 | valueSet->Add(dcsVal); |
6614fa48 | 279 | dcsVal = new AliDCSValue( kTRUE, 1500 ); |
280 | valueSet->Add(dcsVal); | |
281 | dcsVal = new AliDCSValue( kTRUE, 1990 ); | |
92e5c8ed | 282 | aliasMap->Add( new TObjString(fgkDCSDataPoints[2]), valueSet ); |
6614fa48 | 283 | |
6614fa48 | 284 | |
92e5c8ed | 285 | TRandom random; |
286 | ||
e75e6e01 | 287 | Int_t maxDPindex = 0; |
288 | if (errorLevel != 5) { | |
289 | maxDPindex = fgknDCSDP; | |
290 | } | |
291 | else { | |
292 | maxDPindex = 3; // simulating only a few DP in case errorLevel=5 | |
293 | } | |
294 | ||
0254e751 | 295 | for( int nAlias=2; nAlias<maxDPindex; nAlias++) { |
296 | if (nAlias>=4 && nAlias < 44) continue; | |
92e5c8ed | 297 | valueSet = new TObjArray; |
298 | valueSet->SetOwner(1); | |
299 | ||
6614fa48 | 300 | Int_t timeStampValue[10] = { 1010, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1990}; |
301 | ||
302 | ||
e75e6e01 | 303 | for (int timeStamp=0; timeStamp<10; timeStamp++) { |
6614fa48 | 304 | dcsVal = new AliDCSValue((Float_t) (timeStamp+1+10*nAlias), timeStampValue[timeStamp]); |
92e5c8ed | 305 | valueSet->Add(dcsVal); |
306 | } | |
ce996d13 | 307 | cout << " simulating " << fgkDCSDataPoints[nAlias] << endl; |
92e5c8ed | 308 | aliasMap->Add( new TObjString( fgkDCSDataPoints[nAlias]), valueSet ); |
309 | } | |
310 | ||
e75e6e01 | 311 | // Hall Probes |
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"}; | |
315 | Int_t hp = 0; | |
316 | ||
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++) { | |
6614fa48 | 324 | dcsVal = new AliDCSValue((Float_t) (timeStamp+1+10*hp), timeStampValue[timeStamp]); |
e75e6e01 | 325 | valueSet->Add(dcsVal); |
326 | //cout << " hall probe = " << dpAlias << " with value = " << dcsVal->GetFloat() << endl; | |
327 | } | |
328 | aliasMap->Add( new TObjString(dpAlias), valueSet ); | |
329 | hp++; | |
330 | } | |
331 | } | |
332 | } | |
333 | ||
92e5c8ed | 334 | return aliasMap; |
335 | } | |
336 | ||
337 | /* | |
338 | TMap* ReadDCSAliasMap() | |
339 | { | |
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() | |
345 | ||
346 | AliCDBEntry *entry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB()) | |
347 | ->Get("DET/DCS/Data", 0); | |
348 | return dynamic_cast<TMap*> (entry->GetObject()); | |
349 | } | |
350 | */ | |
351 | ||
352 | ||
353 | void WriteDCSAliasMap() | |
354 | { | |
355 | // This writes the output from CreateDCSAliasMap to a CDB file | |
356 | ||
e75e6e01 | 357 | TMap* dcsAliasMap = CreateDCSAliasMap(Int_t errorLevel); |
92e5c8ed | 358 | |
359 | AliCDBMetaData metaData; | |
360 | metaData.SetBeamPeriod(0); | |
361 | metaData.SetResponsible("Ernesto Lopez Torres"); | |
362 | metaData.SetComment("Test object for TestGRPPreprocessor.C"); | |
363 | ||
364 | AliCDBId id("GRP/Data", 0, 0); | |
365 | ||
366 | // look into AliTestShuttle's CDB main folder | |
367 | ||
368 | AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB()) | |
369 | ->Put(dcsAliasMap, id, &metaData); | |
370 | } |