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__)
20 /// This macro runs the test preprocessor for MUON.
21 /// It uses AliTestShuttle to simulate a full Shuttle process
23 /// The input data has to be created first by other processes (or is created
24 /// here by CreateDCSAliasMap() for tracker HV).
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
31 /// For more information on usage, please see READMEshuttle.
33 // By Laurent Aphecetche, SUBATECH Nantes
35 #include "TestMUONPreprocessor.h"
36 #include "AliCDBManager.h"
37 #include "AliShuttleInterface.h"
39 #include "AliTestShuttle.h"
41 #include "Riostream.h"
43 #include "AliMpExMap.h"
46 #include "TObjArray.h"
47 #include "AliMpHelper.h"
48 #include "AliDCSValue.h"
49 #include "TObjString.h"
51 #include "AliMUONTrackerPreprocessor.h"
52 #include "AliCDBEntry.h"
53 #include "AliMUONHVNamer.h"
56 void TestMUONPreprocessor(Int_t runNumber=80)
59 gSystem->Load("../SHUTTLE/TestShuttle/libTestShuttle.so");
60 gSystem->Load("libMUONshuttle.so");
62 // create AliTestShuttle instance
63 // The parameters are run, startTime, endTime
64 AliTestShuttle* shuttle = new AliTestShuttle(runNumber, 0, 1);
67 AliTestShuttle::SetMainCDB("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB");
68 AliTestShuttle::SetMainRefStorage("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestReference");
70 printf("Test Shuttle temp dir: %s\n", AliShuttleInterface::GetShuttleTempDir());
71 printf("Test Shuttle log dir: %s\n", AliShuttleInterface::GetShuttleLogDir());
72 printf("Test OCDB storage Uri: %s\n", AliShuttleInterface::GetMainCDB().Data());
73 printf("Test Reference storage Uri: %s\n", AliShuttleInterface::GetMainRefStorage().Data());
75 // Create DCS HV aliases
76 TMap* dcsAliasMap = CreateDCSAliasMap();
78 // now give the alias map to the shuttle
79 shuttle->SetDCSInput(dcsAliasMap);
81 // The shuttle can process files that originate from DCS, DAQ and HLT.
82 // To test it, we provide some local files and locations where these would be found when
83 // the online machinery would be there.
84 // In real life this functions would be produces by the sub-detectors
85 // calibration programs in DCS, DAQ or HLT. These files can then be retrieved using the Shuttle.
87 // Files are added with the function AliTestShuttle::AddInputFile. The syntax is:
88 // AddInputFile(<system>, <detector>, <id>, <source>, <local-file>)
89 // In this example we add 4 files originating from different LDCs but with the same id (PEDESTALS)
91 shuttle->AddInputFile(AliTestShuttle::kDAQ,"MCH","PEDESTALS","LDC0","$ALICE_ROOT/MUON/data/LDC0.ped");
92 shuttle->AddInputFile(AliTestShuttle::kDAQ,"MCH","PEDESTALS","LDC1","$ALICE_ROOT/MUON/data/LDC1.ped");
93 shuttle->AddInputFile(AliTestShuttle::kDAQ,"MCH","PEDESTALS","LDC2","$ALICE_ROOT/MUON/data/LDC2.ped");
94 shuttle->AddInputFile(AliTestShuttle::kDAQ,"MCH","PEDESTALS","LDC3","$ALICE_ROOT/MUON/data/LDC3.ped");
96 shuttle->AddInputFile(AliTestShuttle::kDAQ,"MCH","GAINS","LDC0","$HOME/Desktop/makegain_214.online");
97 shuttle->AddInputFile(AliTestShuttle::kDAQ,"MCH","GAINS","LDC1","$HOME/Desktop/makegain_214.online.1");
98 shuttle->AddInputFile(AliTestShuttle::kDAQ,"MCH","GAINS","LDC2","$HOME/Desktop/makegain_214.online.2");
99 shuttle->AddInputFile(AliTestShuttle::kDAQ,"MCH","GAINS","LDC3","$HOME/Desktop/makegain_214.online.3");
102 shuttle->AddInputFile(AliTestShuttle::kDAQ,"MCH","GMS","GMS","$ALICE_ROOT/MUON/data/GMS.root");
104 // The shuttle can read run parameters stored in the DAQ run logbook.
105 // To test it, we must provide the run parameters manually. They will be retrieved in the preprocessor
106 // using GetRunParameter function.
107 // In real life the parameters will be retrieved automatically from the run logbook;
108 shuttle->SetInputRunType("PEDESTAL_RUN");
109 //shuttle->SetInputRunType("ELECTRONICS_CALIBRATION_RUN");
110 //shuttle->SetInputRunType("GMS");
111 //shuttle->SetInputRunType("PHYSICS");
112 // PEDESTAL_RUN -> pedestals
113 // ELECTRONICS_CALIBRATION_RUN -> gains
116 // Create the preprocessor that should be tested, it registers itself automatically to the shuttle
117 new AliMUONTrackerPreprocessor(shuttle);
121 // Test the preprocessor
125 TMap* CreateDCSAliasMap()
127 /// Creates a DCS structure for MUON Tracker HV
129 /// The structure is the following:
130 /// TMap (key --> value)
131 /// <DCSAlias> --> <valueList>
132 /// <DCSAlias> is a string
133 /// <valueList> is a TObjArray of AliDCSValue
134 /// An AliDCSValue consists of timestamp and a value in form of a AliSimpleValue
136 TMap* aliasMap = new TMap;
137 aliasMap->SetOwner(kTRUE);
141 AliMUONHVNamer hvNamer;
143 TObjArray* aliases = hvNamer.GenerateAliases();
145 for ( Int_t i = 0; i < aliases->GetEntries(); ++i )
147 TObjString* alias = static_cast<TObjString*>(aliases->At(i));
148 TString& aliasName = alias->String();
149 if ( aliasName.Contains("sw") )
151 // HV Switch (St345 only)
152 TObjArray* valueSet = new TObjArray;
153 valueSet->SetOwner(kTRUE);
154 Bool_t value = kTRUE;
155 // Float_t r = random.Uniform();
156 // if ( r < 0.007 ) value = kFALSE;
157 // if ( aliasName.Contains("DE513sw2") ) value = kFALSE;
159 for ( UInt_t timeStamp = 0; timeStamp < 60*3; timeStamp += 60 )
161 AliDCSValue* dcsValue = new AliDCSValue(value,timeStamp);
162 valueSet->Add(dcsValue);
164 aliasMap->Add(new TObjString(*alias),valueSet);
168 TObjArray* valueSet = new TObjArray;
169 valueSet->SetOwner(kTRUE);
170 for ( UInt_t timeStamp = 0; timeStamp < 60*15; timeStamp += 120 )
172 Float_t value = random.Gaus(1750,62.5);
173 if ( aliasName == "MchHvLvLeft/Chamber01Left/Quad3Sect2.actual.vMon") value = 500;
174 // if ( aliasName == "MchHvLvLeft/Chamber05Left/Slat07.actual.vMon") value = 1300;
175 // if ( aliasName == "MchHvLvLeft/Chamber05Left/Slat03.actual.vMon") value = 2500;
176 AliDCSValue* dcsValue = new AliDCSValue(value,timeStamp);
177 valueSet->Add(dcsValue);
179 if ( aliasName == "MchHvLvLeft/Chamber05Left/Slat07.actual.vMon" ) continue;
180 aliasMap->Add(new TObjString(*alias),valueSet);