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