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