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