1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 #if !defined(__CINT__) || defined(__MAKECINT__)
21 /// \file TestMUONPreprocessor.C
22 /// \brief The macro for testing the shuttle preprocessors
24 /// This macro runs the test preprocessor for MUON.
25 /// It uses AliTestShuttle to simulate a full Shuttle process
27 /// The input data has to be created first by other processes (or is created
28 /// here by CreateDCSAliasMap() for tracker HV).
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
35 /// You must load relevant libraries (besides normal MUON ones) before
36 /// compiling this macro :
38 /// gSystem->Load("$ALICE_ROOT/SHUTTLE/TestShuttle/libTestShuttle");
39 /// gSystem->Load("libMUONshuttle.so");
42 /// For more information on usage, please see the \ref README_shuttle page.
44 /// \author Laurent Aphecetche, SUBATECH Nantes
46 #include "TestMUONPreprocessor.h"
48 #include "AliMUONTrackerPreprocessor.h"
49 #include "AliMUONTriggerPreprocessor.h"
53 #include "AliMpExMap.h"
54 #include "AliMpHelper.h"
55 #include "AliMpHVNamer.h"
58 #include "AliCDBManager.h"
59 #include "AliCDBEntry.h"
61 #include "AliShuttleInterface.h"
62 #include "AliTestShuttle.h"
63 #include "AliDCSValue.h"
65 #include "Riostream.h"
68 #include "TObjArray.h"
69 #include "TObjString.h"
74 void TestMUONPreprocessor(Int_t runNumber=80, const char* runType="PEDESTAL")
78 // PEDESTAL -> pedestals
79 // ELECTRONICS_CALIBRATION -> gains
83 // create AliTestShuttle instance
84 // The parameters are run, startTime, endTime
85 AliTestShuttle* shuttle = new AliTestShuttle(runNumber, 0, 1);
87 const char* inputCDB = "local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB";
89 AliTestShuttle::SetMainCDB(inputCDB);
90 AliTestShuttle::SetMainRefStorage("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestReference");
95 if ( rt.Contains("PHYSICS") )
97 // Create DCS HV aliases
98 TMap* dcsAliasMap = CreateDCSAliasMap(inputCDB, runNumber);
102 // now give the alias map to the shuttle
103 shuttle->SetDCSInput(dcsAliasMap);
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());
112 // The shuttle can process files that originate from DCS, DAQ and HLT.
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.
118 // Files are added with the function AliTestShuttle::AddInputFile. The syntax is:
119 // AddInputFile(<system>, <detector>, <id>, <source>, <local-file>)
120 // In this example we add 4 files originating from different LDCs but with the same id (PEDESTALS)
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");
127 shuttle->AddInputFile(AliTestShuttle::kDAQ,"MCH","GAINS","LDC0","$ALICE_ROOT/MUON/data/LDC0.gain");
128 shuttle->AddInputFile(AliTestShuttle::kDAQ,"MCH","GAINS","LDC1","$ALICE_ROOT/MUON/data/LDC1.gain");
129 shuttle->AddInputFile(AliTestShuttle::kDAQ,"MCH","GAINS","LDC2","$ALICE_ROOT/MUON/data/LDC2.gain");
130 shuttle->AddInputFile(AliTestShuttle::kDAQ,"MCH","GAINS","LDC3","$ALICE_ROOT/MUON/data/LDC3.gain");
133 shuttle->AddInputFile(AliTestShuttle::kDCS,"MCH","GMS","GMS","$ALICE_ROOT/MUON/data/GMS.root");
135 // and then the trigger stuff
136 shuttle->AddInputFile(AliTestShuttle::kDAQ,"MTR","LOCAL","LDC0","$ALICE_ROOT/MUON/data/MtgLocalMask-1.dat");
137 shuttle->AddInputFile(AliTestShuttle::kDAQ,"MTR","REGIONAL","LDC0","$ALICE_ROOT/MUON/data/MtgRegionalCrate-1.dat");
138 shuttle->AddInputFile(AliTestShuttle::kDAQ,"MTR","GLOBAL","LDC0","$ALICE_ROOT/MUON/data/MtgGlobalCrate-1.dat");
139 shuttle->AddInputFile(AliTestShuttle::kDAQ,"MTR","LUT","LDC0","$ALICE_ROOT/MUON/data/MtgLocalLut-1.dat");
140 shuttle->AddInputFile(AliTestShuttle::kDAQ,"MTR","EXPORTED","LDC0","$ALICE_ROOT/MUON/data/ExportedFiles.dat");
142 // The shuttle can read run parameters stored in the DAQ run logbook.
143 // To test it, we must provide the run parameters manually. They will be retrieved in the preprocessor
144 // using GetRunParameter function.
145 // In real life the parameters will be retrieved automatically from the run logbook;
146 shuttle->SetInputRunType(runType);
148 // Create the preprocessor that should be tested, it registers itself automatically to the shuttle
149 new AliMUONTrackerPreprocessor(shuttle);
150 new AliMUONTriggerPreprocessor(shuttle);
154 // Test the preprocessor
158 TMap* CreateDCSAliasMap(const char* inputCDB, Int_t runNumber)
160 /// Creates a DCS structure for MUON Tracker HV
162 /// The structure is the following:
163 /// TMap (key --> value)
164 /// <DCSAlias> --> <valueList>
165 /// <DCSAlias> is a string
166 /// <valueList> is a TObjArray of AliDCSValue
167 /// An AliDCSValue consists of timestamp and a value in form of a AliSimpleValue
169 Bool_t undefStorage(kFALSE);
171 AliCDBManager* man = AliCDBManager::Instance();
172 if (!man->IsDefaultStorageSet())
174 undefStorage = kTRUE;
175 man->SetDefaultStorage(inputCDB);
176 man->SetRun(runNumber);
180 Bool_t ok = AliMpCDB::LoadDDLStore();
184 man->UnsetDefaultStorage();
189 AliErrorGeneral("CreateDCSAliasMap","Could not load DDLStore from OCDB");
193 TMap* aliasMap = new TMap;
194 aliasMap->SetOwner(kTRUE);
198 AliMpHVNamer hvNamer;
200 TObjArray* aliases = hvNamer.GenerateAliases();
202 for ( Int_t i = 0; i < aliases->GetEntries(); ++i )
204 TObjString* alias = static_cast<TObjString*>(aliases->At(i));
205 TString& aliasName = alias->String();
206 if ( aliasName.Contains("sw") )
208 // HV Switch (St345 only)
209 TObjArray* valueSet = new TObjArray;
210 valueSet->SetOwner(kTRUE);
211 Bool_t value = kTRUE;
212 // Float_t r = random.Uniform();
213 // if ( r < 0.007 ) value = kFALSE;
214 // if ( aliasName.Contains("DE513sw2") ) value = kFALSE;
216 for ( UInt_t timeStamp = 0; timeStamp < 60*3; timeStamp += 60 )
218 AliDCSValue* dcsValue = new AliDCSValue(value,timeStamp);
219 valueSet->Add(dcsValue);
221 aliasMap->Add(new TObjString(*alias),valueSet);
225 TObjArray* valueSet = new TObjArray;
226 valueSet->SetOwner(kTRUE);
227 for ( UInt_t timeStamp = 0; timeStamp < 60*15; timeStamp += 120 )
229 Float_t value = random.Gaus(1750,62.5);
230 if ( aliasName == "MchHvLvLeft/Chamber00Left/Quad2Sect1.actual.vMon") value = 500;
231 AliDCSValue* dcsValue = new AliDCSValue(value,timeStamp);
232 valueSet->Add(dcsValue);
234 if ( aliasName == "MchHvLvLeft/Chamber04Left/Slat06.actual.vMon" ) continue;
235 aliasMap->Add(new TObjString(*alias),valueSet);