]>
Commit | Line | Data |
---|---|---|
1 | /************************************************************************** | |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | /* $Id$ */ | |
17 | ||
18 | #if !defined(__CINT__) || defined(__MAKECINT__) | |
19 | ||
20 | /// \ingroup macros | |
21 | /// \file TestMUONPreprocessor.C | |
22 | /// \brief The macro for testing the shuttle preprocessors | |
23 | /// | |
24 | /// This macro runs the test preprocessor for MUON. | |
25 | /// It uses AliTestShuttle to simulate a full Shuttle process | |
26 | /// | |
27 | /// You must load relevant libraries (besides normal MUON ones -which is done | |
28 | /// easily by executing root from the $ALICE_ROOT/MUON directory to use | |
29 | /// the rootlogon.C there) before compiling this macro : | |
30 | /// <pre> | |
31 | /// gSystem->Load("$ALICE_ROOT/SHUTTLE/TestShuttle/libTestShuttle"); | |
32 | /// gSystem->Load("libMUONshuttle"); | |
33 | /// </pre> | |
34 | /// Last line above assume you have $ALICE_ROOT/MUON/lib/tgt_[arch] (where | |
35 | /// libMUONshuttle is located) in your LD_LIBRARY_PATH | |
36 | /// | |
37 | /// Having $ALICE_ROOT/SHUTTLE/TestShuttle directory in your LD_LIBRARY_PATH | |
38 | /// (or DYLD_LIBRARY_PATH on Mac OS X) won't hurt either... | |
39 | /// | |
40 | /// You must also make a link of some OCDB entries to have the mapping loaded | |
41 | /// correctly : | |
42 | /// | |
43 | /// <pre> | |
44 | /// cd $ALICE_ROOT/OCDB/SHUTTLE/TestShuttle/TestCDB | |
45 | /// mkdir -p MUON/Calib | |
46 | /// cd MUON/Calib | |
47 | /// ln -si $ALICE_ROOT/OCDB/MUON/Calib/MappingData . | |
48 | /// </pre> | |
49 | /// | |
50 | /// and Align/Baseline if you'd like to test GMS subprocessor : | |
51 | /// | |
52 | /// <pre> | |
53 | /// cd $ALICE_ROOT/OCDB/SHUTTLE/TestShuttle/TestCDB | |
54 | /// mkdir -p MUON/Align | |
55 | /// cd MUON/Align | |
56 | /// ln -si $ALICE_ROOT/OCDB/MUON/Align/Baseline . | |
57 | /// </pre> | |
58 | /// | |
59 | /// The input data has to be created first by other processes (or is created | |
60 | /// here by CreateDCSAliasMap() for tracker HV). | |
61 | /// | |
62 | /// To play with it, you'll have to set/modify several lines, to | |
63 | /// - a) select input files, using shuttle->AddInputFile() | |
64 | /// - b) select run type, using shuttle->AddInputRunParameter() (the run type | |
65 | /// dictates which task is really performed by the MUONPreprocessor | |
66 | /// | |
67 | /// The sourceDirectory is there to "emulate" what the real preprocessor will | |
68 | /// find on the FXS, and is assumed to have the following structure : | |
69 | /// <pre> | |
70 | /// GAINS/ | |
71 | /// LDC0.gain | |
72 | /// LDC1.gain | |
73 | /// LDC2.gain | |
74 | /// LDC3.gain | |
75 | /// GMS/ | |
76 | /// GMS.root | |
77 | /// OCCUPANCY/ | |
78 | /// mch.occupancy | |
79 | /// PEDESTALS/ | |
80 | /// LDC0.ped | |
81 | /// LDC1.ped | |
82 | /// LDC2.ped | |
83 | /// LDC3.ped | |
84 | /// LDC4.conf | |
85 | /// CONFIG/ | |
86 | /// LDC0.conf | |
87 | /// LDC1.conf | |
88 | /// LDC2.conf | |
89 | /// LDC3.conf | |
90 | /// LDC4.conf | |
91 | /// TRIGGER/ | |
92 | /// ExportedFiles.dat (mandatory) | |
93 | /// MtgGlobalCrate-1.dat | |
94 | /// MtgLocalLut-1.dat | |
95 | /// MtgLocalMask-1.dat | |
96 | /// MtgRegionalCrate-1.dat | |
97 | /// </pre> | |
98 | /// | |
99 | /// IMPORTANT: | |
100 | /// The trigger files have to be present in order for the algorithm to work correctly. | |
101 | /// If you want to test the Trigger DCS maps only, but you don't have the .dat trigger files, | |
102 | /// you have to create dummy files through : | |
103 | /// <pre> | |
104 | /// cd sourceDirectory/TRIGGER | |
105 | /// echo -e "MtgLocalMask-1.dat\nMtgRegionalCrate-1.dat\nMtgGlobalCrate-1.dat\nMtgLocalLut-1.dat" > ExportedFiles.dat | |
106 | /// touch MtgLocalMask-1.dat MtgRegionalCrate-1.dat MtgGlobalCrate-1.dat MtgLocalLut-1.dat | |
107 | /// </pre> | |
108 | /// | |
109 | /// For more information on usage, please see the \ref README_shuttle page. | |
110 | /// | |
111 | /// \author Laurent Aphecetche, SUBATECH Nantes; \n | |
112 | /// Diego Stocco, SUBATECH Nantes | |
113 | ||
114 | #include "TestMUONPreprocessor.h" | |
115 | ||
116 | #include "AliMUONTrackerPreprocessor.h" | |
117 | #include "AliMUONTriggerPreprocessor.h" | |
118 | ||
119 | #include "AliLog.h" | |
120 | ||
121 | #include "AliMpBusPatch.h" | |
122 | #include "AliMpExMap.h" | |
123 | #include "AliMpHelper.h" | |
124 | #include "AliMpDDLStore.h" | |
125 | #include "AliMpDCSNamer.h" | |
126 | #include "AliMpCDB.h" | |
127 | ||
128 | #include "AliCDBManager.h" | |
129 | #include "AliCDBEntry.h" | |
130 | #include "AliCDBId.h" | |
131 | #include "AliShuttleInterface.h" | |
132 | #include "AliTestShuttle.h" | |
133 | #include "AliDCSValue.h" | |
134 | ||
135 | #include "Riostream.h" | |
136 | #include "TSystem.h" | |
137 | #include "TMap.h" | |
138 | #include "TObjArray.h" | |
139 | #include "TObjString.h" | |
140 | #include "TString.h" | |
141 | #include "TRandom.h" | |
142 | #endif | |
143 | ||
144 | //______________________________________________________________________________ | |
145 | void TestMUONPreprocessor(Int_t runNumber=80, | |
146 | const char* runType="CALIBRATION", | |
147 | const char* sourceDirectory="/afs/cern.ch/user/l/laphecet/public") | |
148 | { | |
149 | // runType can be : | |
150 | // | |
151 | // PEDESTAL -> pedestals | |
152 | // CALIBRATION -> gains | |
153 | // PHYSICS -> HV | |
154 | // GMS | |
155 | ||
156 | // create AliTestShuttle instance | |
157 | // The parameters are run, startTime, endTime | |
158 | ||
159 | gSystem->Load("libTestShuttle.so"); | |
160 | ||
161 | AliTestShuttle* shuttle = new AliTestShuttle(runNumber, 0, 1); | |
162 | ||
163 | const char* inputCDB = "local://$ALICE_ROOT/OCDB/SHUTTLE/TestShuttle/TestCDB"; | |
164 | //const char* inputCDB = "alien://folder=/alice/testdata/2008/TS08a/OCDB"; | |
165 | ||
166 | AliTestShuttle::SetMainCDB(inputCDB); | |
167 | AliTestShuttle::SetMainRefStorage("local://$ALICE_ROOT/OCDB/SHUTTLE/TestShuttle/TestReference"); | |
168 | ||
169 | TString rt(runType); | |
170 | rt.ToUpper(); | |
171 | ||
172 | if ( rt.Contains("PHYSICS") ) | |
173 | { | |
174 | // Create DCS aliases | |
175 | UInt_t startTime, endTime; | |
176 | ||
177 | TMap* dcsAliasMap = CreateDCSAliasMap(inputCDB, runNumber); | |
178 | ||
179 | if ( dcsAliasMap ) | |
180 | { | |
181 | // now give the alias map to the shuttle | |
182 | shuttle->SetDCSInput(dcsAliasMap); | |
183 | } | |
184 | } | |
185 | ||
186 | printf("Test Shuttle temp dir: %s\n", AliShuttleInterface::GetShuttleTempDir()); | |
187 | printf("Test Shuttle log dir: %s\n", AliShuttleInterface::GetShuttleLogDir()); | |
188 | printf("Test OCDB storage Uri: %s\n", AliShuttleInterface::GetMainCDB().Data()); | |
189 | printf("Test Reference storage Uri: %s\n", AliShuttleInterface::GetMainRefStorage().Data()); | |
190 | ||
191 | // The shuttle can process files that originate from DCS, DAQ and HLT. | |
192 | // To test it, we provide some local files and locations where these would be found when | |
193 | // the online machinery would be there. | |
194 | // In real life this functions would be produces by the sub-detectors | |
195 | // calibration programs in DCS, DAQ or HLT. These files can then be retrieved using the Shuttle. | |
196 | // | |
197 | // Files are added with the function AliTestShuttle::AddInputFile. The syntax is: | |
198 | // AddInputFile(<system>, <detector>, <id>, <source>, <local-file>) | |
199 | // In this example we add 4 files originating from different LDCs but with the same id (PEDESTALS) | |
200 | ||
201 | shuttle->AddInputFile(AliTestShuttle::kDAQ,"MCH","PEDESTALS","LDC0",Form("%s/PEDESTALS/LDC0.ped",sourceDirectory)); | |
202 | shuttle->AddInputFile(AliTestShuttle::kDAQ,"MCH","PEDESTALS","LDC1",Form("%s/PEDESTALS/LDC1.ped",sourceDirectory)); | |
203 | shuttle->AddInputFile(AliTestShuttle::kDAQ,"MCH","PEDESTALS","LDC2",Form("%s/PEDESTALS/LDC2.ped",sourceDirectory)); | |
204 | shuttle->AddInputFile(AliTestShuttle::kDAQ,"MCH","PEDESTALS","LDC3",Form("%s/PEDESTALS/LDC3.ped",sourceDirectory)); | |
205 | shuttle->AddInputFile(AliTestShuttle::kDAQ,"MCH","PEDESTALS","LDC4",Form("%s/PEDESTALS/LDC4.ped",sourceDirectory)); | |
206 | ||
207 | shuttle->AddInputFile(AliTestShuttle::kDAQ,"MCH","CONFIG","LDC0",Form("%s/CONFIG/LDC0.conf",sourceDirectory)); | |
208 | shuttle->AddInputFile(AliTestShuttle::kDAQ,"MCH","CONFIG","LDC1",Form("%s/CONFIG/LDC1.conf",sourceDirectory)); | |
209 | shuttle->AddInputFile(AliTestShuttle::kDAQ,"MCH","CONFIG","LDC2",Form("%s/CONFIG/LDC2.conf",sourceDirectory)); | |
210 | shuttle->AddInputFile(AliTestShuttle::kDAQ,"MCH","CONFIG","LDC3",Form("%s/CONFIG/LDC3.conf",sourceDirectory)); | |
211 | shuttle->AddInputFile(AliTestShuttle::kDAQ,"MCH","CONFIG","LDC4",Form("%s/CONFIG/LDC4.conf",sourceDirectory)); | |
212 | ||
213 | shuttle->AddInputFile(AliTestShuttle::kDAQ,"MCH","GAINS","LDC0",Form("%s/GAINS/LDC0.gain",sourceDirectory)); | |
214 | shuttle->AddInputFile(AliTestShuttle::kDAQ,"MCH","GAINS","LDC1",Form("%s/GAINS/LDC1.gain",sourceDirectory)); | |
215 | shuttle->AddInputFile(AliTestShuttle::kDAQ,"MCH","GAINS","LDC2",Form("%s/GAINS/LDC2.gain",sourceDirectory)); | |
216 | shuttle->AddInputFile(AliTestShuttle::kDAQ,"MCH","GAINS","LDC3",Form("%s/GAINS/LDC3.gain",sourceDirectory)); | |
217 | ||
218 | shuttle->AddInputFile(AliTestShuttle::kDAQ,"MCH","OCCUPANCY","MON",Form("%s/OCCUPANCY/mch.occupancy",sourceDirectory)); | |
219 | ||
220 | // and GMS file | |
221 | shuttle->AddInputFile(AliTestShuttle::kDCS,"MCH","GMS","GMS",Form("%s/GMS/GMS.root",sourceDirectory)); | |
222 | ||
223 | // and then the trigger stuff | |
224 | shuttle->AddInputFile(AliTestShuttle::kDAQ,"MTR","LOCAL","LDC0",Form("%s/TRIGGER/MtgLocalMask-1.dat",sourceDirectory)); | |
225 | shuttle->AddInputFile(AliTestShuttle::kDAQ,"MTR","REGIONAL","LDC0",Form("%s/TRIGGER/MtgRegionalCrate-1.dat",sourceDirectory)); | |
226 | shuttle->AddInputFile(AliTestShuttle::kDAQ,"MTR","GLOBAL","LDC0",Form("%s/TRIGGER/MtgGlobalCrate-1.dat",sourceDirectory)); | |
227 | shuttle->AddInputFile(AliTestShuttle::kDAQ,"MTR","LUT","LDC0",Form("%s/TRIGGER/MtgLocalLut-1.dat",sourceDirectory)); | |
228 | shuttle->AddInputFile(AliTestShuttle::kDAQ,"MTR","EXPORTED","LDC0",Form("%s/TRIGGER/ExportedFiles.dat",sourceDirectory)); | |
229 | ||
230 | // The shuttle can read run parameters stored in the DAQ run logbook. | |
231 | // To test it, we must provide the run parameters manually. They will be retrieved in the preprocessor | |
232 | // using GetRunParameter function. | |
233 | // In real life the parameters will be retrieved automatically from the run logbook; | |
234 | shuttle->SetInputRunType(runType); | |
235 | ||
236 | // Create the preprocessor that should be tested, it registers itself automatically to the shuttle | |
237 | new AliMUONTrackerPreprocessor(shuttle); | |
238 | new AliMUONTriggerPreprocessor(shuttle); | |
239 | ||
240 | shuttle->Print(); | |
241 | ||
242 | // Test the preprocessor | |
243 | shuttle->Process(); | |
244 | } | |
245 | ||
246 | //______________________________________________________________________________ | |
247 | void GenerateConfig() | |
248 | { | |
249 | /// Generate "fake" configuration files for the tracker. One per LDC. | |
250 | ||
251 | Bool_t undefStorage(kFALSE); | |
252 | ||
253 | AliCDBManager* man = AliCDBManager::Instance(); | |
254 | if (!man->IsDefaultStorageSet()) | |
255 | { | |
256 | undefStorage = kTRUE; | |
257 | man->SetDefaultStorage("local://$ALICE_ROOT/OCDB"); | |
258 | man->SetRun(0); | |
259 | } | |
260 | ||
261 | // Load mapping | |
262 | Bool_t ok = AliMpCDB::LoadDDLStore(); | |
263 | ||
264 | if (undefStorage) | |
265 | { | |
266 | man->UnsetDefaultStorage(); | |
267 | } | |
268 | ||
269 | if (!ok) | |
270 | { | |
271 | AliErrorGeneral("GenerateConfig","Could not load DDLStore from OCDB"); | |
272 | return; | |
273 | } | |
274 | ||
275 | ofstream* files[5]; | |
276 | for ( Int_t i = 0; i < 5; ++i ) | |
277 | { | |
278 | files[i]=0; | |
279 | } | |
280 | ||
281 | TIter next(AliMpDDLStore::Instance()->CreateBusPatchIterator()); | |
282 | AliMpBusPatch* bp; | |
283 | ||
284 | while ( ( bp = static_cast<AliMpBusPatch*>(next()) ) ) | |
285 | { | |
286 | Int_t ddl = bp->GetDdlId(); | |
287 | ||
288 | Int_t ldc = ddl/4; | |
289 | ||
290 | if (!files[ldc]) | |
291 | { | |
292 | files[ldc] = new ofstream(Form("LDC%d.conf",ldc)); | |
293 | *(files[ldc]) << "# changed" << endl; | |
294 | } | |
295 | ||
296 | for ( Int_t imanu = 0; imanu < bp->GetNofManus(); ++imanu ) | |
297 | { | |
298 | *(files[ldc]) << bp->GetId() << " " << bp->GetManuId(imanu) << endl; | |
299 | } | |
300 | } | |
301 | ||
302 | for ( Int_t i = 0; i < 5; ++i ) | |
303 | { | |
304 | if ( files[i] ) files[i]->close(); | |
305 | delete files[i]; | |
306 | } | |
307 | } | |
308 | ||
309 | //______________________________________________________________________________ | |
310 | TMap* CreateDCSAliasMap(const char* inputCDB, Int_t runNumber) | |
311 | { | |
312 | /// Creates a DCS structure for MUON Tracker HV and Trigger DCS and Currents | |
313 | /// | |
314 | /// The structure is the following: | |
315 | /// TMap (key --> value) | |
316 | /// <DCSAlias> --> <valueList> | |
317 | /// <DCSAlias> is a string | |
318 | /// <valueList> is a TObjArray of AliDCSValue | |
319 | /// An AliDCSValue consists of timestamp and a value in form of a AliSimpleValue | |
320 | ||
321 | Bool_t undefStorage(kFALSE); | |
322 | ||
323 | AliCDBManager* man = AliCDBManager::Instance(); | |
324 | if (!man->IsDefaultStorageSet()) | |
325 | { | |
326 | undefStorage = kTRUE; | |
327 | man->SetDefaultStorage(inputCDB); | |
328 | man->SetRun(runNumber); | |
329 | } | |
330 | ||
331 | // Load mapping | |
332 | Bool_t ok = AliMpCDB::LoadDDLStore(); | |
333 | ||
334 | if (undefStorage) | |
335 | { | |
336 | man->UnsetDefaultStorage(); | |
337 | } | |
338 | ||
339 | if (!ok) | |
340 | { | |
341 | AliErrorGeneral("CreateDCSAliasMap","Could not load DDLStore from OCDB"); | |
342 | return 0x0; | |
343 | } | |
344 | ||
345 | TMap* aliasMap = new TMap; | |
346 | aliasMap->SetOwner(kTRUE); | |
347 | ||
348 | TRandom random(0); | |
349 | ||
350 | const Char_t* detName[2] = { "TRACKER", "TRIGGER" }; | |
351 | ||
352 | for(Int_t idet=0; idet<2; idet++){ | |
353 | ||
354 | TString sDetName(detName[idet]); | |
355 | sDetName.ToUpper(); | |
356 | ||
357 | AliMpDCSNamer dcsNamer(detName[idet]); | |
358 | ||
359 | TObjArray* aliases = dcsNamer.GenerateAliases(); | |
360 | ||
361 | for ( Int_t i = 0; i < aliases->GetEntries(); ++i ) | |
362 | { | |
363 | TObjString* alias = static_cast<TObjString*>(aliases->At(i)); | |
364 | TString& aliasName = alias->String(); | |
365 | if ( aliasName.Contains("sw") && sDetName.Contains("TRACKER")) | |
366 | { | |
367 | // HV Switch (St345 only) | |
368 | TObjArray* valueSet = new TObjArray; | |
369 | valueSet->SetOwner(kTRUE); | |
370 | Bool_t bvalue = kTRUE; | |
371 | // Float_t r = random.Uniform(); | |
372 | // if ( r < 0.007 ) value = kFALSE; | |
373 | // if ( aliasName.Contains("DE513sw2") ) value = kFALSE; | |
374 | ||
375 | for ( UInt_t timeStamp = 0; timeStamp < 60*3; timeStamp += 60 ) | |
376 | { | |
377 | AliDCSValue* dcsValue = new AliDCSValue(bvalue,timeStamp); | |
378 | valueSet->Add(dcsValue); | |
379 | } | |
380 | aliasMap->Add(new TObjString(*alias),valueSet); | |
381 | } | |
382 | else | |
383 | { | |
384 | TObjArray* valueSet = new TObjArray; | |
385 | valueSet->SetOwner(kTRUE); | |
386 | for ( UInt_t timeStamp = 0; timeStamp < 60*15; timeStamp += 120 ) | |
387 | { | |
388 | Float_t value = 0; | |
389 | if(sDetName.Contains("TRACKER")){ | |
390 | value = random.Gaus(1750,62.5); | |
391 | if ( aliasName == "MchHvLvLeft/Chamber00Left/Quad2Sect1.actual.vMon") value = 500; | |
392 | } | |
393 | else if(aliasName.Contains("iMon")){ | |
394 | value = random.Gaus(2.,0.4); | |
395 | } | |
396 | else { | |
397 | value = random.Gaus(8000.,16.); | |
398 | } | |
399 | ||
400 | AliDCSValue* dcsValue = new AliDCSValue(value,timeStamp); | |
401 | valueSet->Add(dcsValue); | |
402 | } | |
403 | if ( aliasName == "MchHvLvLeft/Chamber04Left/Slat06.actual.vMon" ) continue; | |
404 | if ( aliasName == "MTR_INSIDE_MT22_RPC3_HV.vEff" ) continue; | |
405 | if ( aliasName == "MTR_OUTSIDE_MT21_RPC4_HV.actual.iMon" ) continue; | |
406 | aliasMap->Add(new TObjString(*alias),valueSet); | |
407 | } | |
408 | } // loop on aliases | |
409 | ||
410 | delete aliases; | |
411 | } // loop on detectors (tracker and trigger) | |
412 | ||
413 | AliMpCDB::UnloadAll(); | |
414 | ||
415 | return aliasMap; | |
416 | } | |
417 |