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