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