]> git.uio.no Git - u/mrichter/AliRoot.git/blame - GRP/TestGRPPreprocessor.C
In the calculation of the jacobian use the transposed matrix instead of its inverse...
[u/mrichter/AliRoot.git] / GRP / TestGRPPreprocessor.C
CommitLineData
92e5c8ed 1
2// This macro runs the GRP test preprocessor
3// It uses AliTestShuttle to simulate a full Shuttle process
4
5// The input data is created in the functions
6// CreateDCSAliasMap() creates input that would in the same way come from DCS
7// ReadDCSAliasMap() reads from a file
8// CreateInputFilesMap() creates a list of local files, that can be accessed by the shuttle
9
e3efae04 10#include <iostream>
11#include <fstream>
12using namespace std;
92e5c8ed 13
14void TestGRPPreprocessor()
15{
16 // load library
17// gSystem->Load("libSTEER.so"); // needed for AliGRPPreprocessor
18 gSystem->Load("$ALICE_ROOT/SHUTTLE/TestShuttle/libTestShuttle.so");
19
20 // create AliTestShuttle instance
21 // The parameters are run, startTime, endTime
22 Int_t kRun = 7;
23 AliTestShuttle* shuttle = new AliTestShuttle(kRun, 1, 10);
24
25 // by default they are set to $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB and TestReference
26 AliTestShuttle::SetMainCDB("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB");
27 AliTestShuttle::SetMainRefStorage("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestReference");
28
29 printf("Test OCDB storage Uri: %s\n", AliShuttleInterface::GetMainCDB().Data());
30 printf("Test Reference storage Uri: %s\n", AliShuttleInterface::GetMainRefStorage().Data());
31
32
33 // The shuttle can read DCS data, if the preprocessor should be tested to process DCS data,
34 // some fake data has to be created.
35 //
36 // The "fake" input data can be taken using either (a) or (b):
37 // (a) data from a file: Use ReadDCSAliasMap()
38 // the format of the file is explained in ReadDCSAliasMap()
39 // To use it uncomment the following line:
40 //
41 //TMap* dcsAliasMap = ReadDCSAliasMap();
42 //
43 // (b) generated in this macro: Use CreateDCSAliasMap() and its documentation
44 // To use it uncomment the following line:
45 //
46 TMap* dcsAliasMap = CreateDCSAliasMap();
47
48 // now give the alias map to the shuttle
49 shuttle->SetDCSInput(dcsAliasMap);
50
51 // The shuttle can also process files that originate from DCS, DAQ and HLT.
52 // To test it, we provide some local files and locations where these would be found when
53 // the online machinery would be there.
54 // In real life this functions would be produces by the sub-detectors
55 // calibration programs in DCS, DAQ or HLT. These files can then be retrieved using the Shuttle.
56 //
57 // Files are added with the function AliTestShuttle::AddInputFile. The syntax is:
58 // AddInputFile(<system>, <detector>, <id>, <source>, <local-file>)
59 // In this example we add a file originating from the GDC with the id PEDESTALS
60 // Three files originating from different LDCs but with the same id are also added
61 // Note that the test preprocessor name is TPC. The name of the detector's preprocessor must follow
62 // the "online" naming convention ALICE-INT-2003-039.
e3efae04 63 //shuttle->AddInputFile(AliShuttleInterface::kDAQ, "GRP", "Period_test000.tag.root", "GDC0", "runTags01.root");
64 //shuttle->AddInputFile(AliShuttleInterface::kDAQ, "GRP", "Period_test001.tag.root", "GDC1", "runTags02.root");
65 //shuttle->AddInputFile(AliShuttleInterface::kDAQ, "GRP", "Period_test002.tag.root", "GDC2", "runTags03.root");
66
67 shuttle->AddInputFile(AliShuttleInterface::kDAQ, "GRP", "run000021390_GRP_gdc0_Period_TDSMtest.Seq_0.tag.root", "GDC0", "$ALICE_ROOT/GRP/ShuttleInput/run000021390_GRP_gdc0_Period_TDSMtest.Seq_0.tag.root");
68 shuttle->AddInputFile(AliShuttleInterface::kDAQ, "GRP", "run000021390_GRP_gdc1_Period_TDSMtest.Seq_0.tag.root", "GDC1", "$ALICE_ROOT/GRP/ShuttleInput/run000021390_GRP_gdc0_Period_TDSMtest.Seq_0.tag.root");
69 shuttle->AddInputFile(AliShuttleInterface::kDAQ, "GRP", "run000021391_GRP_gdc0_Period_TDSMtest.Seq_0.tag.root", "GDC0", "$ALICE_ROOT/GRP/ShuttleInput/run000021391_GRP_gdc0_Period_TDSMtest.Seq_0.tag.root");
70 shuttle->AddInputFile(AliShuttleInterface::kDAQ, "GRP", "run000021391_GRP_gdc1_Period_TDSMtest.Seq_0.tag.root", "GDC1", "$ALICE_ROOT/GRP/ShuttleInput/run000021391_GRP_gdc1_Period_TDSMtest.Seq_0.tag.root");
71
72 shuttle->AddInputFile(AliShuttleInterface::kDCS, "GRP", "CTP_runconfig", "", gSystem->ExpandPathName("$ALICE_ROOT/GRP/CTP/p-p.cfg"));
92e5c8ed 73 shuttle->AddInputFile(AliShuttleInterface::kDCS, "GRP", "CTP_xcounters", "DCS FXS", gSystem->ExpandPathName("$ALICE_ROOT/GRP/CTP/xcounters.txt"));
74
e3efae04 75 Char_t * filename = gSystem->ExpandPathName("$ALICE_ROOT/GRP/CTP/p-p.cfg");
76 ifstream is;
77 is.open(filename);
78 is.seekg(0,ios::end);
79 int length = is.tellg();
80 const char *buffer = new char[length];
81 is.seekg(0,ios::beg);
82 is.read(buffer,length);
83 is.close();
92e5c8ed 84
e3efae04 85 shuttle->SetInputTriggerConfiguration(buffer);
86
92e5c8ed 87 // The shuttle can read run type stored in the DAQ logbook.
88 // To test it, we must provide the run type manually. They will be retrieved in the preprocessor
89 // using GetRunType function.
90 shuttle->SetInputRunType("PHYSICS");
91
92 // The shuttle can read run parameters stored in the DAQ run logbook.
93 // To test it, we must provide the run parameters manually. They will be retrieved in the preprocessor
94 // using GetRunParameter function.
95 shuttle->AddInputRunParameter("time_start", "1233213.22");
96 shuttle->AddInputRunParameter("time_end", "1345645.22");
97 shuttle->AddInputRunParameter("beamEnergy", "1400.");
98 shuttle->AddInputRunParameter("beamType", "p-p");
99 shuttle->AddInputRunParameter("numberOfDetectors", "5");
100 shuttle->AddInputRunParameter("detectorMask", "34555");
101 shuttle->AddInputRunParameter("LHCperiod", "LHC08b");
102
103// shuttle->AddInputRunParameter("totalEvents", "30000");
104// shuttle->AddInputRunParameter("NumberOfGDCs", "15");
105
106 // TODO(5) NOT NEEDED
107 //
108 // This is for preprocessor that require data from HLT.
109 // Since HLT may be switched off, the preprocessor should first query the Run logbook where
110 // the HLT status is stored. SHUTTLE implements a shortcut function (GetHLTStatus) that returns
111 // a bool directly. 1 = HLT ON, 0 = HLT OFF
112 //
113
114 Bool_t hltStatus = kTRUE;
115 shuttle->SetInputHLTStatus(hltStatus);
116
117
118 // Create the preprocessor that should be tested, it registers itself automatically to the shuttle
119 AliPreprocessor* test = new AliGRPPreprocessor(shuttle);
120
121 // Test the preprocessor
122 shuttle->Process();
123
124 printf("\n\n");
125
126 // In the preprocessor AliShuttleInterface::Store should be called to put the final
127 // data to the CDB. To check if all went fine have a look at the files produced in
128 // $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB/<detector>/SHUTTLE/Data
129 //
130 // Check the file which should have been created
131 AliCDBEntry* chkEntry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())
132 ->Get("GRP/GRP/Data", kRun);
133 if (!chkEntry) {
134 printf("The file is not there. Something went wrong.\n");
135 return;
136 }
137 chkEntry->PrintId();
138 chkEntry->GetObject()->Print();
139 printf("\n\n");
140
649b8dcf 141 AliDCSSensor* sen = (AliDCSSensor*)(((TMap*)chkEntry->GetObject())->GetValue("fP2Pressure"));
92e5c8ed 142 if(sen)
143 sen->GetFit()->MakeGraph(1.5, 9.5, 15)->Draw();
144
145// AliTestDataDCS* output = dynamic_cast<AliTestDataDCS*> (chkEntry->GetObject());
146 // If everything went fine, draw the result
147// if (output) {
148// output->Print();
149// }
150
151
152}
153
154TMap* CreateDCSAliasMap()
155{
156 // Creates a DCS structure
157 // The structure is the following:
158 // TMap (key --> value)
159 // <DCSAlias> --> <valueList>
160 // <DCSAlias> is a string
161 // <valueList> is a TObjArray of AliDCSValue
162 // An AliDCSValue consists of timestamp and a value in form of a AliSimpleValue
163
649b8dcf 164 const Int_t fgknDCSDP = 10;
92e5c8ed 165 const char* fgkDCSDataPoints[AliGRPPreprocessor::fgknDCSDP] = {
166 "LHCState",
167 "L3Polarity",
168 "DipolePolarity",
169 "LHCLuminosity",
170 "BeamIntensity",
171 "L3Current",
172 "DipoleCurrent",
173 "CavernTemperature",
174 "CavernAtmosPressure",
649b8dcf 175 "SurfaceAtmosPressure"
92e5c8ed 176 };
177
178 TMap* aliasMap;
179 TObjArray* valueSet;
180 AliDCSValue* dcsVal;
181
182 aliasMap = new TMap;
183 aliasMap->SetOwner(1);
184
185 // LHCState
186 valueSet = new TObjArray;
187 valueSet->SetOwner(1);
188 dcsVal = new AliDCSValue( 'F', 0 );
189 valueSet->Add(dcsVal);
190// aliasMap->Add( new TObjString(fgkDCSDataPoints[0]), valueSet );
191
192 // L3Polarity
193 valueSet = new TObjArray;
194 valueSet->SetOwner(1);
195 dcsVal = new AliDCSValue( kTRUE, 0 );
196 valueSet->Add(dcsVal);
197 aliasMap->Add( new TObjString(fgkDCSDataPoints[1]), valueSet );
198
199 // DipolePolarity
200 valueSet = new TObjArray;
201 valueSet->SetOwner(1);
202 dcsVal = new AliDCSValue( kTRUE, 0 );
203 valueSet->Add(dcsVal);
204 aliasMap->Add( new TObjString(fgkDCSDataPoints[2]), valueSet );
205
206 TRandom random;
207
649b8dcf 208 // for( int nAlias=3; nAlias<fgknDCSDP-1; nAlias++) {
209 for( int nAlias=3; nAlias<fgknDCSDP; nAlias++) {
92e5c8ed 210 valueSet = new TObjArray;
211 valueSet->SetOwner(1);
212
213 for (int timeStamp=0; timeStamp<100; timeStamp++) {
214 dcsVal = new AliDCSValue((Float_t) (random.Gaus()+5*nAlias), timeStamp);
215 //printf("%s\n",dcsVal->ToString().Data());
216 valueSet->Add(dcsVal);
217 }
218 aliasMap->Add( new TObjString( fgkDCSDataPoints[nAlias]), valueSet );
219 }
220
221 return aliasMap;
222}
223
224/*
225TMap* ReadDCSAliasMap()
226{
227 // Open a file that contains DCS input data
228 // The CDB framework is used to open the file, this means the file is located
229 // in $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB/<detector>/DCS/Data
230 // The file contains an AliCDBEntry that contains a TMap with the DCS structure.
231 // An explanation of the structure can be found in CreateDCSAliasMap()
232
233 AliCDBEntry *entry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())
234 ->Get("DET/DCS/Data", 0);
235 return dynamic_cast<TMap*> (entry->GetObject());
236}
237*/
238
239
240void WriteDCSAliasMap()
241{
242 // This writes the output from CreateDCSAliasMap to a CDB file
243
244 TMap* dcsAliasMap = CreateDCSAliasMap();
245
246 AliCDBMetaData metaData;
247 metaData.SetBeamPeriod(0);
248 metaData.SetResponsible("Ernesto Lopez Torres");
249 metaData.SetComment("Test object for TestGRPPreprocessor.C");
250
251 AliCDBId id("GRP/Data", 0, 0);
252
253 // look into AliTestShuttle's CDB main folder
254
255 AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())
256 ->Put(dcsAliasMap, id, &metaData);
257}