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