]>
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 | |
20 | ||
21 | // Need to include dummy files in TestShuttle/TestCDB for CTP Configuration and Scalers | |
22 | // (see macro $ALICE_ROOT/GRP/MakeCTPDummyEntries.C) | |
23 | ||
24 | // Modified by C. Zampolli | |
25 | ||
26 | ||
e3efae04 | 27 | #include <iostream> |
28 | #include <fstream> | |
29 | using namespace std; | |
92e5c8ed | 30 | |
e75e6e01 | 31 | void TestGRPPreprocessor(const char* runtype="PHYSICS", TString partition="ALICE", TString detector="", TString beamType = "p-p", Int_t errorLevel=0) |
92e5c8ed | 32 | { |
92e5c8ed | 33 | gSystem->Load("$ALICE_ROOT/SHUTTLE/TestShuttle/libTestShuttle.so"); |
34 | ||
7f32679b | 35 | AliLog::SetClassDebugLevel("AliGRPPreprocessor",3); |
92e5c8ed | 36 | Int_t kRun = 7; |
6614fa48 | 37 | AliTestShuttle* shuttle = new AliTestShuttle(kRun, 1000, 2000); |
92e5c8ed | 38 | |
e75e6e01 | 39 | AliTestShuttle::SetMainCDB("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB"); |
40 | AliTestShuttle::SetMainRefStorage("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestReference"); | |
92e5c8ed | 41 | |
42 | printf("Test OCDB storage Uri: %s\n", AliShuttleInterface::GetMainCDB().Data()); | |
43 | printf("Test Reference storage Uri: %s\n", AliShuttleInterface::GetMainRefStorage().Data()); | |
44 | ||
e75e6e01 | 45 | // setting runtype |
46 | shuttle->SetInputRunType(runtype); | |
92e5c8ed | 47 | |
6ecb073a | 48 | Int_t detectorMask = 1074200319; |
49 | TString detectorMask_Str(Form("%d",detectorMask)); | |
50 | shuttle->AddInputRunParameter("detectorMask", detectorMask_Str.Data()); | |
51 | ||
52 | TString* ltu = new TString[3]; | |
53 | ltu[0] = "2000"; | |
54 | ltu[1] = "6000"; | |
55 | ltu[2] = "8000"; | |
56 | for (Int_t i = 0; i<AliDAQ::kNDetectors-2; i++){ | |
57 | if ((detectorMask >> i) & 0x1) { | |
58 | TString detOnlineName = AliDAQ::DetectorName(i); | |
59 | if (detOnlineName == "VZERO"){ | |
60 | ltu[0] = "3000"; | |
61 | ltu[1] = "7000"; | |
62 | ltu[2] = "9000"; | |
63 | } | |
64 | shuttle->SetLTUConfig(ltu,detOnlineName.Data()); | |
65 | } | |
66 | } | |
67 | ||
e75e6e01 | 68 | // simulating DCS DPs |
69 | TMap* dcsAliasMap = CreateDCSAliasMap(errorLevel); | |
92e5c8ed | 70 | shuttle->SetDCSInput(dcsAliasMap); |
71 | ||
e75e6e01 | 72 | // simulating input from DAQ FXS |
73 | if (errorLevel != 2){ | |
6ecb073a | 74 | |
6614fa48 | 75 | //$ALICE_ROOT to be expanded manually by the user for this test macro |
7f32679b | 76 | 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"); |
77 | 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"); | |
78 | 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"); | |
79 | 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 | 80 | shuttle->AddInputFile(AliShuttleInterface::kDAQ, "SPD", "VertexDiamond", "gdc-GLOBAL-01", "$ALICE_ROOT/GRP/ShuttleInput/run000104892_SPD_mon-DA-SPD-0_VertexDiamond"); |
0254e751 | 81 | shuttle->AddInputFile(AliShuttleInterface::kDCS, "GRP", "LHCData", "", "$ALICE_ROOT/GRP/ShuttleInput/testRun_GRP_run_number_testRun_data.txt"); |
6ecb073a | 82 | |
6614fa48 | 83 | // for example: |
6ecb073a | 84 | /* |
85 | 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"); | |
86 | 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"); | |
87 | 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"); | |
88 | 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"); | |
89 | shuttle->AddInputFile(AliShuttleInterface::kDAQ, "SPD", "VertexDiamond", "gdc-GLOBAL-01", "/home/zampolli/SOFT/AliRoot/AliRoot_Trunk/GRP/ShuttleInput/run000104892_SPD_mon-DA-SPD-0_VertexDiamond"); | |
90 | shuttle->AddInputFile(AliShuttleInterface::kDCS, "GRP", "LHCData", "", "/home/zampolli/SOFT/AliRoot/AliRoot_Trunk/GRP/ShuttleInput/testRun_GRP_run_number_testRun_data.txt"); | |
91 | */ | |
e75e6e01 | 92 | } |
93 | ||
94 | // simulating input from DCS FXS | |
95 | if (errorLevel != 4 && !partition.IsNull() && detector.IsNull()){ | |
96 | shuttle->AddInputFile(AliShuttleInterface::kDCS, "GRP", "CTP_xcounters", "", gSystem->ExpandPathName("$ALICE_ROOT/GRP/CTP/xcounters.txt")); | |
97 | } | |
98 | ||
e3efae04 | 99 | Char_t * filename = gSystem->ExpandPathName("$ALICE_ROOT/GRP/CTP/p-p.cfg"); |
100 | ifstream is; | |
101 | is.open(filename); | |
102 | is.seekg(0,ios::end); | |
103 | int length = is.tellg(); | |
104 | const char *buffer = new char[length]; | |
105 | is.seekg(0,ios::beg); | |
106 | is.read(buffer,length); | |
107 | is.close(); | |
e75e6e01 | 108 | const char *emptybuffer = NULL; |
92e5c8ed | 109 | |
e75e6e01 | 110 | // simulating input from DAQ logbook_trigger_config |
7f32679b | 111 | if (errorLevel != 3 && errorLevel != 7 && !partition.IsNull() && detector.IsNull()) { |
112 | cout << " adding trigger config " << endl; | |
113 | shuttle->SetInputTriggerConfiguration(buffer); | |
e75e6e01 | 114 | } |
115 | else if (errorLevel == 7) { | |
116 | shuttle->SetInputTriggerConfiguration(emptybuffer); | |
117 | } | |
e3efae04 | 118 | |
6614fa48 | 119 | // open text file with CTP timing params |
120 | Char_t * fileNameTiming = gSystem->ExpandPathName("$ALICE_ROOT/GRP/ShuttleInput/ctptime.tim"); | |
121 | ifstream ifstrTiming; | |
122 | ifstrTiming.open(fileNameTiming); | |
123 | ifstrTiming.seekg(0,ios::end); | |
124 | int lengthTiming = ifstrTiming.tellg(); | |
125 | const char *bufferTiming = new char[lengthTiming]; | |
126 | ifstrTiming.seekg(0,ios::beg); | |
127 | ifstrTiming.read(bufferTiming,lengthTiming); | |
128 | ifstrTiming.close(); | |
129 | // const char *emptybuffer = NULL; | |
130 | ||
131 | // simulating input from DAQ logbook_ctp_timing_params | |
132 | if (errorLevel != 3 && errorLevel != 7 && !partition.IsNull() && detector.IsNull()) { | |
133 | cout << " adding ctp timing params " <<endl; | |
134 | shuttle->SetInputCTPTimeParams(bufferTiming); | |
135 | } | |
136 | else if (errorLevel == 7) { | |
137 | shuttle->SetInputCTPTimeParams(emptybuffer); | |
138 | } | |
139 | ||
e75e6e01 | 140 | // simulating input from DAQ logbook |
141 | if (errorLevel != 1){ | |
6614fa48 | 142 | shuttle->AddInputRunParameter("DAQ_time_start", "1020"); |
e75e6e01 | 143 | } |
144 | if (errorLevel != 6){ | |
6ecb073a | 145 | shuttle->AddInputRunParameter("beamEnergy", "123"); |
e75e6e01 | 146 | } |
147 | ||
6614fa48 | 148 | shuttle->AddInputRunParameter("DAQ_time_end", "1980"); |
6ecb073a | 149 | shuttle->AddInputRunParameter("beamType", beamType); |
92e5c8ed | 150 | shuttle->AddInputRunParameter("numberOfDetectors", "5"); |
92e5c8ed | 151 | shuttle->AddInputRunParameter("LHCperiod", "LHC08b"); |
e75e6e01 | 152 | shuttle->AddInputRunParameter("partition",partition); |
153 | shuttle->AddInputRunParameter("detector",detector); | |
92e5c8ed | 154 | |
e75e6e01 | 155 | // simulating HLT |
92e5c8ed | 156 | Bool_t hltStatus = kTRUE; |
157 | shuttle->SetInputHLTStatus(hltStatus); | |
158 | ||
92e5c8ed | 159 | // Create the preprocessor that should be tested, it registers itself automatically to the shuttle |
160 | AliPreprocessor* test = new AliGRPPreprocessor(shuttle); | |
161 | ||
162 | // Test the preprocessor | |
163 | shuttle->Process(); | |
164 | ||
165 | printf("\n\n"); | |
166 | ||
92e5c8ed | 167 | // Check the file which should have been created |
168 | AliCDBEntry* chkEntry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB()) | |
169 | ->Get("GRP/GRP/Data", kRun); | |
170 | if (!chkEntry) { | |
171 | printf("The file is not there. Something went wrong.\n"); | |
172 | return; | |
173 | } | |
174 | chkEntry->PrintId(); | |
175 | chkEntry->GetObject()->Print(); | |
176 | printf("\n\n"); | |
177 | ||
92e5c8ed | 178 | } |
179 | ||
e75e6e01 | 180 | TMap* CreateDCSAliasMap(Int_t errorLevel) |
92e5c8ed | 181 | { |
182 | // Creates a DCS structure | |
183 | // The structure is the following: | |
e75e6e01 | 184 | // TMap (key --> value) |
185 | // <DCSAlias> --> <valueList> | |
186 | // <DCSAlias> is a string | |
187 | // <valueList> is a TObjArray of AliDCSValue | |
188 | // An AliDCSValue consists of timestamp and a value in form of a AliSimpleValue | |
92e5c8ed | 189 | |
0254e751 | 190 | const Int_t fgknDCSDP = 48; |
92e5c8ed | 191 | const char* fgkDCSDataPoints[AliGRPPreprocessor::fgknDCSDP] = { |
92e5c8ed | 192 | "L3Polarity", |
193 | "DipolePolarity", | |
92e5c8ed | 194 | "L3Current", |
195 | "DipoleCurrent", | |
e75e6e01 | 196 | "L3_BSF17_H1", |
197 | "L3_BSF17_H2", | |
198 | "L3_BSF17_H3", | |
199 | "L3_BSF17_Temperature", | |
200 | "L3_BSF4_H1", | |
201 | "L3_BSF4_H2", | |
202 | "L3_BSF4_H3", | |
203 | "L3_BSF4_Temperature", | |
204 | "L3_BKF17_H1", | |
205 | "L3_BKF17_H2", | |
206 | "L3_BKF17_H3", | |
207 | "L3_BKF17_Temperature", | |
208 | "L3_BKF4_H1", | |
209 | "L3_BKF4_H2", | |
210 | "L3_BKF4_H3", | |
211 | "L3_BKF4_Temperature", | |
212 | "L3_BSF13_H1", | |
213 | "L3_BSF13_H2", | |
214 | "L3_BSF13_H3", | |
215 | "L3_BSF13_Temperature", | |
216 | "L3_BSF8_H1", | |
217 | "L3_BSF8_H2", | |
218 | "L3_BSF8_H3", | |
219 | "L3_BSF8_Temperature", | |
220 | "L3_BKF13_H1", | |
221 | "L3_BKF13_H2", | |
222 | "L3_BKF13_H3", | |
223 | "L3_BKF13_Temperature", | |
224 | "L3_BKF8_H1", | |
225 | "L3_BKF8_H2", | |
226 | "L3_BKF8_H3", | |
227 | "L3_BKF8_Temperature", | |
228 | "Dipole_Inside_H1", | |
229 | "Dipole_Inside_H2", | |
230 | "Dipole_Inside_H3", | |
231 | "Dipole_Inside_Temperature", | |
232 | "Dipole_Outside_H1", | |
233 | "Dipole_Outside_H2", | |
234 | "Dipole_Outside_H3", | |
235 | "Dipole_Outside_Temperature", | |
92e5c8ed | 236 | "CavernTemperature", |
237 | "CavernAtmosPressure", | |
ce996d13 | 238 | "SurfaceAtmosPressure", |
239 | "CavernAtmosPressure2", | |
92e5c8ed | 240 | }; |
241 | ||
242 | TMap* aliasMap; | |
243 | TObjArray* valueSet; | |
244 | AliDCSValue* dcsVal; | |
245 | ||
246 | aliasMap = new TMap; | |
247 | aliasMap->SetOwner(1); | |
248 | ||
92e5c8ed | 249 | // L3Polarity |
250 | valueSet = new TObjArray; | |
251 | valueSet->SetOwner(1); | |
6614fa48 | 252 | dcsVal = new AliDCSValue( kTRUE, 1010 ); |
253 | valueSet->Add(dcsVal); | |
254 | dcsVal = new AliDCSValue( kTRUE, 1100 ); | |
255 | valueSet->Add(dcsVal); | |
256 | dcsVal = new AliDCSValue( kTRUE, 1500 ); | |
257 | valueSet->Add(dcsVal); | |
258 | dcsVal = new AliDCSValue( kTRUE, 1990 ); | |
92e5c8ed | 259 | valueSet->Add(dcsVal); |
dba333ae | 260 | // add the following two lines to test errors for changing polarity |
261 | // dcsVal = new AliDCSValue( kFALSE, 2 ); | |
262 | // valueSet->Add(dcsVal); | |
92e5c8ed | 263 | aliasMap->Add( new TObjString(fgkDCSDataPoints[1]), valueSet ); |
264 | ||
265 | // DipolePolarity | |
266 | valueSet = new TObjArray; | |
267 | valueSet->SetOwner(1); | |
6614fa48 | 268 | dcsVal = new AliDCSValue( kTRUE, 1010 ); |
269 | valueSet->Add(dcsVal); | |
270 | dcsVal = new AliDCSValue( kTRUE, 1100 ); | |
92e5c8ed | 271 | valueSet->Add(dcsVal); |
6614fa48 | 272 | dcsVal = new AliDCSValue( kTRUE, 1500 ); |
273 | valueSet->Add(dcsVal); | |
274 | dcsVal = new AliDCSValue( kTRUE, 1990 ); | |
92e5c8ed | 275 | aliasMap->Add( new TObjString(fgkDCSDataPoints[2]), valueSet ); |
6614fa48 | 276 | |
6614fa48 | 277 | |
92e5c8ed | 278 | TRandom random; |
279 | ||
e75e6e01 | 280 | Int_t maxDPindex = 0; |
281 | if (errorLevel != 5) { | |
282 | maxDPindex = fgknDCSDP; | |
283 | } | |
284 | else { | |
285 | maxDPindex = 3; // simulating only a few DP in case errorLevel=5 | |
286 | } | |
287 | ||
0254e751 | 288 | for( int nAlias=2; nAlias<maxDPindex; nAlias++) { |
289 | if (nAlias>=4 && nAlias < 44) continue; | |
92e5c8ed | 290 | valueSet = new TObjArray; |
291 | valueSet->SetOwner(1); | |
292 | ||
6614fa48 | 293 | Int_t timeStampValue[10] = { 1010, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1990}; |
294 | ||
295 | ||
e75e6e01 | 296 | for (int timeStamp=0; timeStamp<10; timeStamp++) { |
6614fa48 | 297 | dcsVal = new AliDCSValue((Float_t) (timeStamp+1+10*nAlias), timeStampValue[timeStamp]); |
92e5c8ed | 298 | valueSet->Add(dcsVal); |
299 | } | |
ce996d13 | 300 | cout << " simulating " << fgkDCSDataPoints[nAlias] << endl; |
92e5c8ed | 301 | aliasMap->Add( new TObjString( fgkDCSDataPoints[nAlias]), valueSet ); |
302 | } | |
303 | ||
e75e6e01 | 304 | // Hall Probes |
305 | TString probe1[3] = {"L3_BSF","L3_BKF","Dipole_"}; | |
306 | TString probe2[6] = {"17_","4_","13_","8_","Inside_","Outside_"}; | |
307 | TString probe3[4] = {"H1","H2","H3","Temperature"}; | |
308 | Int_t hp = 0; | |
309 | ||
310 | for (Int_t i=0;i<3;i++){ | |
311 | for (Int_t j=0;j<6;j++){ | |
312 | for (Int_t k=0;k<4;k++){ | |
313 | TString dpAlias = probe1[i]+probe2[j]+probe3[k]; | |
314 | valueSet = new TObjArray; | |
315 | valueSet->SetOwner(1); | |
316 | for (int timeStamp=0; timeStamp<10; timeStamp++) { | |
6614fa48 | 317 | dcsVal = new AliDCSValue((Float_t) (timeStamp+1+10*hp), timeStampValue[timeStamp]); |
e75e6e01 | 318 | valueSet->Add(dcsVal); |
319 | //cout << " hall probe = " << dpAlias << " with value = " << dcsVal->GetFloat() << endl; | |
320 | } | |
321 | aliasMap->Add( new TObjString(dpAlias), valueSet ); | |
322 | hp++; | |
323 | } | |
324 | } | |
325 | } | |
326 | ||
92e5c8ed | 327 | return aliasMap; |
328 | } | |
329 | ||
330 | /* | |
331 | TMap* ReadDCSAliasMap() | |
332 | { | |
333 | // Open a file that contains DCS input data | |
334 | // The CDB framework is used to open the file, this means the file is located | |
335 | // in $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB/<detector>/DCS/Data | |
336 | // The file contains an AliCDBEntry that contains a TMap with the DCS structure. | |
337 | // An explanation of the structure can be found in CreateDCSAliasMap() | |
338 | ||
339 | AliCDBEntry *entry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB()) | |
340 | ->Get("DET/DCS/Data", 0); | |
341 | return dynamic_cast<TMap*> (entry->GetObject()); | |
342 | } | |
343 | */ | |
344 | ||
345 | ||
346 | void WriteDCSAliasMap() | |
347 | { | |
348 | // This writes the output from CreateDCSAliasMap to a CDB file | |
349 | ||
e75e6e01 | 350 | TMap* dcsAliasMap = CreateDCSAliasMap(Int_t errorLevel); |
92e5c8ed | 351 | |
352 | AliCDBMetaData metaData; | |
353 | metaData.SetBeamPeriod(0); | |
354 | metaData.SetResponsible("Ernesto Lopez Torres"); | |
355 | metaData.SetComment("Test object for TestGRPPreprocessor.C"); | |
356 | ||
357 | AliCDBId id("GRP/Data", 0, 0); | |
358 | ||
359 | // look into AliTestShuttle's CDB main folder | |
360 | ||
361 | AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB()) | |
362 | ->Put(dcsAliasMap, id, &metaData); | |
363 | } |