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