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