]>
Commit | Line | Data |
---|---|---|
ea199e33 | 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 | ||
e54bf126 | 20 | /// \ingroup macros |
21 | /// \file TestMUONPreprocessor.C | |
22 | /// \brief The macro for testing the shuttle preprocessors | |
23 | /// | |
608c3123 | 24 | /// This macro runs the test preprocessor for MUON. |
25 | /// It uses AliTestShuttle to simulate a full Shuttle process | |
49e110ec | 26 | /// |
2c1e4958 | 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 : | |
49e110ec | 30 | /// <pre> |
31 | /// gSystem->Load("$ALICE_ROOT/SHUTTLE/TestShuttle/libTestShuttle"); | |
6a69d972 | 32 | /// gSystem->Load("$ALICE_ROOT/MUON/libMUONshuttle"); |
49e110ec | 33 | /// </pre> |
608c3123 | 34 | /// |
2c1e4958 | 35 | /// Having $ALICE_ROOT/SHUTTLE/TestShuttle directory in your LD_LIBRARY_PATH |
36 | /// (or DYLD_LIBRARY_PATH on Mac OS X) won't hurt either... | |
37 | /// | |
38 | /// You must also make a link of some OCDB entries to have the mapping loaded | |
39 | /// correctly : | |
40 | /// | |
41 | /// cd $ALICE_ROOT/OCDB/SHUTTLE/TestShuttle/TestCDB | |
42 | /// mkdir -p MUON/Calib | |
43 | /// cd MUON/Calib | |
44 | /// ln -si $ALICE_ROOT/OCDB/MUON/Calib/MappingData . | |
45 | /// | |
46 | /// and Align/Baseline if you'd like to test GMS subprocessor : | |
47 | /// | |
48 | /// cd $ALICE_ROOT/OCDB/SHUTTLE/TestShuttle/TestCDB | |
49 | /// mkdir -p MUON/Align/Baseline | |
50 | /// cd MUON/Align | |
51 | /// ln -si $ALICE_ROOT/OCDB/MUON/Align/Baseline . | |
52 | /// | |
608c3123 | 53 | /// The input data has to be created first by other processes (or is created |
54 | /// here by CreateDCSAliasMap() for tracker HV). | |
55 | /// | |
56 | /// To play with it, you'll have to set/modify several lines, to | |
e54bf126 | 57 | /// - a) select input files, using shuttle->AddInputFile() |
58 | /// - b) select run type, using shuttle->AddInputRunParameter() (the run type | |
59 | /// dictates which task is really performed by the MUONPreprocessor | |
608c3123 | 60 | /// |
49e110ec | 61 | /// The sourceDirectory is there to "emulate" what the real preprocessor will |
62 | /// find on the FXS, and is assumed to have the following structure : | |
e54bf126 | 63 | /// <pre> |
49e110ec | 64 | /// GAINS/ |
65 | /// LDC0.gain | |
66 | /// LDC1.gain | |
67 | /// LDC2.gain | |
68 | /// LDC3.gain | |
69 | /// GMS/ | |
70 | /// GMS.root | |
7eafe398 | 71 | /// OCCUPANCY/ |
72 | /// mch.occupancy | |
49e110ec | 73 | /// PEDESTALS/ |
74 | /// LDC0.ped | |
75 | /// LDC1.ped | |
76 | /// LDC2.ped | |
77 | /// LDC3.ped | |
78 | /// TRIGGER/ | |
79 | /// ExportedFiles.dat (mandatory) | |
80 | /// MtgGlobalCrate-1.dat | |
81 | /// MtgLocalLut-1.dat | |
82 | /// MtgLocalMask-1.dat | |
83 | /// MtgRegionalCrate-1.dat | |
84 | /// </pre> | |
85 | /// | |
86 | /// IMPORTANT: | |
87 | /// The trigger files have to be present in order for the algorithm to work correctly. | |
88 | /// If you want to test the Trigger DCS maps only, but you don't have the .dat trigger files, | |
89 | /// you have to create dummy files through : | |
90 | /// <pre> | |
91 | /// cd sourceDirectory/TRIGGER | |
92 | /// echo -e "MtgLocalMask-1.dat\nMtgRegionalCrate-1.dat\nMtgGlobalCrate-1.dat\nMtgLocalLut-1.dat" > ExportedFiles.dat | |
93 | /// touch MtgLocalMask-1.dat MtgRegionalCrate-1.dat MtgGlobalCrate-1.dat MtgLocalLut-1.dat | |
e54bf126 | 94 | /// </pre> |
5699c0e6 | 95 | /// |
e54bf126 | 96 | /// For more information on usage, please see the \ref README_shuttle page. |
5699c0e6 | 97 | /// |
49e110ec | 98 | /// \author Laurent Aphecetche, SUBATECH Nantes; \n |
99 | /// Diego Stocco, SUBATECH Nantes | |
ea199e33 | 100 | |
608c3123 | 101 | #include "TestMUONPreprocessor.h" |
8a2055e0 | 102 | |
103 | #include "AliMUONTrackerPreprocessor.h" | |
2ab3623b | 104 | #include "AliMUONTriggerPreprocessor.h" |
5699c0e6 | 105 | |
106 | #include "AliLog.h" | |
8a2055e0 | 107 | |
108 | #include "AliMpExMap.h" | |
109 | #include "AliMpHelper.h" | |
49e110ec | 110 | #include "AliMpDCSNamer.h" |
8a2055e0 | 111 | #include "AliMpCDB.h" |
112 | ||
ea199e33 | 113 | #include "AliCDBManager.h" |
8a2055e0 | 114 | #include "AliCDBEntry.h" |
ea199e33 | 115 | #include "AliCDBId.h" |
8a2055e0 | 116 | #include "AliShuttleInterface.h" |
ea199e33 | 117 | #include "AliTestShuttle.h" |
8a2055e0 | 118 | #include "AliDCSValue.h" |
119 | ||
ea199e33 | 120 | #include "Riostream.h" |
121 | #include "TSystem.h" | |
ea199e33 | 122 | #include "TMap.h" |
ea199e33 | 123 | #include "TObjArray.h" |
ea199e33 | 124 | #include "TObjString.h" |
8a2055e0 | 125 | #include "TString.h" |
ea199e33 | 126 | #include "TRandom.h" |
ea199e33 | 127 | #endif |
128 | ||
49e110ec | 129 | void TestMUONPreprocessor(Int_t runNumber=80, |
130 | const char* runType="CALIBRATION", | |
131 | const char* sourceDirectory="/afs/cern.ch/user/l/laphecet/public") | |
ea199e33 | 132 | { |
f37df338 | 133 | // runType can be : |
134 | // | |
7103cd04 | 135 | // PEDESTAL -> pedestals |
49419555 | 136 | // CALIBRATION -> gains |
f37df338 | 137 | // PHYSICS -> HV |
138 | // GMS | |
49e110ec | 139 | |
ea199e33 | 140 | // create AliTestShuttle instance |
141 | // The parameters are run, startTime, endTime | |
608c3123 | 142 | AliTestShuttle* shuttle = new AliTestShuttle(runNumber, 0, 1); |
9e62d05d | 143 | |
162637e4 | 144 | const char* inputCDB = "local://$ALICE_ROOT/OCDB/SHUTTLE/TestShuttle/TestCDB"; |
3dd0ddc5 | 145 | //const char* inputCDB = "alien://folder=/alice/testdata/2008/TS08a/OCDB"; |
146 | ||
5699c0e6 | 147 | AliTestShuttle::SetMainCDB(inputCDB); |
162637e4 | 148 | AliTestShuttle::SetMainRefStorage("local://$ALICE_ROOT/OCDB/SHUTTLE/TestShuttle/TestReference"); |
9e62d05d | 149 | |
c2d0667a | 150 | TString rt(runType); |
151 | rt.ToUpper(); | |
5699c0e6 | 152 | |
c2d0667a | 153 | if ( rt.Contains("PHYSICS") ) |
5699c0e6 | 154 | { |
49e110ec | 155 | // Create DCS aliases |
6498767e | 156 | TMap* dcsAliasMap = CreateDCSAliasMap(inputCDB, runNumber); |
49e110ec | 157 | |
c2d0667a | 158 | if ( dcsAliasMap ) |
159 | { | |
160 | // now give the alias map to the shuttle | |
161 | shuttle->SetDCSInput(dcsAliasMap); | |
162 | } | |
163 | } | |
5699c0e6 | 164 | |
9e62d05d | 165 | printf("Test Shuttle temp dir: %s\n", AliShuttleInterface::GetShuttleTempDir()); |
166 | printf("Test Shuttle log dir: %s\n", AliShuttleInterface::GetShuttleLogDir()); | |
167 | printf("Test OCDB storage Uri: %s\n", AliShuttleInterface::GetMainCDB().Data()); | |
168 | printf("Test Reference storage Uri: %s\n", AliShuttleInterface::GetMainRefStorage().Data()); | |
169 | ||
608c3123 | 170 | // The shuttle can process files that originate from DCS, DAQ and HLT. |
ea199e33 | 171 | // To test it, we provide some local files and locations where these would be found when |
172 | // the online machinery would be there. | |
173 | // In real life this functions would be produces by the sub-detectors | |
174 | // calibration programs in DCS, DAQ or HLT. These files can then be retrieved using the Shuttle. | |
175 | // | |
176 | // Files are added with the function AliTestShuttle::AddInputFile. The syntax is: | |
177 | // AddInputFile(<system>, <detector>, <id>, <source>, <local-file>) | |
608c3123 | 178 | // In this example we add 4 files originating from different LDCs but with the same id (PEDESTALS) |
ea199e33 | 179 | |
49e110ec | 180 | shuttle->AddInputFile(AliTestShuttle::kDAQ,"MCH","PEDESTALS","LDC0",Form("%s/PEDESTALS/LDC0.ped",sourceDirectory)); |
181 | shuttle->AddInputFile(AliTestShuttle::kDAQ,"MCH","PEDESTALS","LDC1",Form("%s/PEDESTALS/LDC1.ped",sourceDirectory)); | |
182 | shuttle->AddInputFile(AliTestShuttle::kDAQ,"MCH","PEDESTALS","LDC2",Form("%s/PEDESTALS/LDC2.ped",sourceDirectory)); | |
183 | shuttle->AddInputFile(AliTestShuttle::kDAQ,"MCH","PEDESTALS","LDC3",Form("%s/PEDESTALS/LDC3.ped",sourceDirectory)); | |
49419555 | 184 | |
49e110ec | 185 | shuttle->AddInputFile(AliTestShuttle::kDAQ,"MCH","GAINS","LDC0",Form("%s/GAINS/LDC0.gain",sourceDirectory)); |
186 | shuttle->AddInputFile(AliTestShuttle::kDAQ,"MCH","GAINS","LDC1",Form("%s/GAINS/LDC1.gain",sourceDirectory)); | |
187 | shuttle->AddInputFile(AliTestShuttle::kDAQ,"MCH","GAINS","LDC2",Form("%s/GAINS/LDC2.gain",sourceDirectory)); | |
188 | shuttle->AddInputFile(AliTestShuttle::kDAQ,"MCH","GAINS","LDC3",Form("%s/GAINS/LDC3.gain",sourceDirectory)); | |
49419555 | 189 | |
7eafe398 | 190 | shuttle->AddInputFile(AliTestShuttle::kDAQ,"MCH","OCCUPANCY","MON",Form("%s/OCCUPANCY/mch.occupancy",sourceDirectory)); |
191 | ||
608c3123 | 192 | // and GMS file |
49e110ec | 193 | shuttle->AddInputFile(AliTestShuttle::kDCS,"MCH","GMS","GMS",Form("%s/GMS/GMS.root",sourceDirectory)); |
038d1637 | 194 | |
2ab3623b | 195 | // and then the trigger stuff |
49e110ec | 196 | shuttle->AddInputFile(AliTestShuttle::kDAQ,"MTR","LOCAL","LDC0",Form("%s/TRIGGER/MtgLocalMask-1.dat",sourceDirectory)); |
197 | shuttle->AddInputFile(AliTestShuttle::kDAQ,"MTR","REGIONAL","LDC0",Form("%s/TRIGGER/MtgRegionalCrate-1.dat",sourceDirectory)); | |
198 | shuttle->AddInputFile(AliTestShuttle::kDAQ,"MTR","GLOBAL","LDC0",Form("%s/TRIGGER/MtgGlobalCrate-1.dat",sourceDirectory)); | |
199 | shuttle->AddInputFile(AliTestShuttle::kDAQ,"MTR","LUT","LDC0",Form("%s/TRIGGER/MtgLocalLut-1.dat",sourceDirectory)); | |
200 | shuttle->AddInputFile(AliTestShuttle::kDAQ,"MTR","EXPORTED","LDC0",Form("%s/TRIGGER/ExportedFiles.dat",sourceDirectory)); | |
201 | ||
608c3123 | 202 | // The shuttle can read run parameters stored in the DAQ run logbook. |
203 | // To test it, we must provide the run parameters manually. They will be retrieved in the preprocessor | |
204 | // using GetRunParameter function. | |
205 | // In real life the parameters will be retrieved automatically from the run logbook; | |
f37df338 | 206 | shuttle->SetInputRunType(runType); |
608c3123 | 207 | |
ea199e33 | 208 | // Create the preprocessor that should be tested, it registers itself automatically to the shuttle |
9e62d05d | 209 | new AliMUONTrackerPreprocessor(shuttle); |
2ab3623b | 210 | new AliMUONTriggerPreprocessor(shuttle); |
211 | ||
ea199e33 | 212 | shuttle->Print(); |
213 | ||
214 | // Test the preprocessor | |
215 | shuttle->Process(); | |
608c3123 | 216 | } |
ea199e33 | 217 | |
6498767e | 218 | TMap* CreateDCSAliasMap(const char* inputCDB, Int_t runNumber) |
608c3123 | 219 | { |
49e110ec | 220 | /// Creates a DCS structure for MUON Tracker HV and Trigger DCS and Currents |
608c3123 | 221 | /// |
222 | /// The structure is the following: | |
223 | /// TMap (key --> value) | |
224 | /// <DCSAlias> --> <valueList> | |
225 | /// <DCSAlias> is a string | |
226 | /// <valueList> is a TObjArray of AliDCSValue | |
227 | /// An AliDCSValue consists of timestamp and a value in form of a AliSimpleValue | |
228 | ||
5699c0e6 | 229 | Bool_t undefStorage(kFALSE); |
230 | ||
231 | AliCDBManager* man = AliCDBManager::Instance(); | |
232 | if (!man->IsDefaultStorageSet()) | |
233 | { | |
234 | undefStorage = kTRUE; | |
235 | man->SetDefaultStorage(inputCDB); | |
6498767e | 236 | man->SetRun(runNumber); |
5699c0e6 | 237 | } |
238 | ||
331a617a | 239 | // Load mapping |
5699c0e6 | 240 | Bool_t ok = AliMpCDB::LoadDDLStore(); |
241 | ||
242 | if (undefStorage) | |
243 | { | |
244 | man->UnsetDefaultStorage(); | |
245 | } | |
246 | ||
247 | if (!ok) | |
248 | { | |
249 | AliErrorGeneral("CreateDCSAliasMap","Could not load DDLStore from OCDB"); | |
250 | return 0x0; | |
251 | } | |
ba55f1e6 | 252 | |
608c3123 | 253 | TMap* aliasMap = new TMap; |
254 | aliasMap->SetOwner(kTRUE); | |
255 | ||
256 | TRandom random(0); | |
49e110ec | 257 | |
258 | const Char_t* detName[2] = { "TRACKER", "TRIGGER" }; | |
259 | ||
260 | for(Int_t idet=0; idet<2; idet++){ | |
261 | ||
262 | TString sDetName(detName[idet]); | |
263 | sDetName.ToUpper(); | |
608c3123 | 264 | |
49e110ec | 265 | AliMpDCSNamer dcsNamer(detName[idet]); |
608c3123 | 266 | |
49e110ec | 267 | TObjArray* aliases = dcsNamer.GenerateAliases(); |
608c3123 | 268 | |
49e110ec | 269 | for ( Int_t i = 0; i < aliases->GetEntries(); ++i ) |
608c3123 | 270 | { |
49e110ec | 271 | TObjString* alias = static_cast<TObjString*>(aliases->At(i)); |
272 | TString& aliasName = alias->String(); | |
273 | if ( aliasName.Contains("sw") && sDetName.Contains("TRACKER")) | |
274 | { | |
275 | // HV Switch (St345 only) | |
276 | TObjArray* valueSet = new TObjArray; | |
277 | valueSet->SetOwner(kTRUE); | |
7eafe398 | 278 | Bool_t bvalue = kTRUE; |
608c3123 | 279 | // Float_t r = random.Uniform(); |
280 | // if ( r < 0.007 ) value = kFALSE; | |
281 | // if ( aliasName.Contains("DE513sw2") ) value = kFALSE; | |
282 | ||
49e110ec | 283 | for ( UInt_t timeStamp = 0; timeStamp < 60*3; timeStamp += 60 ) |
284 | { | |
7eafe398 | 285 | AliDCSValue* dcsValue = new AliDCSValue(bvalue,timeStamp); |
49e110ec | 286 | valueSet->Add(dcsValue); |
287 | } | |
288 | aliasMap->Add(new TObjString(*alias),valueSet); | |
608c3123 | 289 | } |
49e110ec | 290 | else |
608c3123 | 291 | { |
49e110ec | 292 | TObjArray* valueSet = new TObjArray; |
293 | valueSet->SetOwner(kTRUE); | |
294 | for ( UInt_t timeStamp = 0; timeStamp < 60*15; timeStamp += 120 ) | |
295 | { | |
296 | Float_t value = 0; | |
297 | if(sDetName.Contains("TRACKER")){ | |
298 | value = random.Gaus(1750,62.5); | |
299 | if ( aliasName == "MchHvLvLeft/Chamber00Left/Quad2Sect1.actual.vMon") value = 500; | |
300 | } | |
9b1e069f | 301 | else if(aliasName.Contains("iMon")){ |
302 | value = random.Gaus(2.,0.4); | |
49e110ec | 303 | } |
304 | else { | |
9b1e069f | 305 | value = random.Gaus(8000.,16.); |
49e110ec | 306 | } |
307 | ||
308 | AliDCSValue* dcsValue = new AliDCSValue(value,timeStamp); | |
309 | valueSet->Add(dcsValue); | |
310 | } | |
311 | if ( aliasName == "MchHvLvLeft/Chamber04Left/Slat06.actual.vMon" ) continue; | |
9b1e069f | 312 | if ( aliasName == "MTR_INSIDE_MT22_RPC3_HV.vEff" ) continue; |
313 | if ( aliasName == "MTR_OUTSIDE_MT21_RPC4_HV.actual.iMon" ) continue; | |
49e110ec | 314 | aliasMap->Add(new TObjString(*alias),valueSet); |
608c3123 | 315 | } |
49e110ec | 316 | } // loop on aliases |
317 | ||
318 | delete aliases; | |
319 | } // loop on detectors (tracker and trigger) | |
608c3123 | 320 | |
49e110ec | 321 | |
608c3123 | 322 | |
2fbe202b | 323 | AliMpCDB::UnloadAll(); |
324 | ||
608c3123 | 325 | return aliasMap; |
ea199e33 | 326 | } |
608c3123 | 327 |