]>
Commit | Line | Data |
---|---|---|
438a188c | 1 | /* $Id$ */ |
2 | ||
3 | // This class runs the test preprocessor | |
4 | // It uses AliTestShuttle to simulate a full Shuttle process | |
5 | ||
6 | // The input data is created in the functions | |
7 | // CreateDCSAliasMap() creates input that would in the same way come from DCS | |
8 | // ReadDCSAliasMap() reads from a file | |
9 | // CreateInputFilesMap() creates a list of local files, that can be accessed by the shuttle | |
10 | ||
11 | void TestZDCPreprocessor() | |
12 | { | |
13 | // load library | |
14 | gSystem->Load("libTestShuttle.so"); | |
15 | ||
16 | // create AliTestShuttle instance | |
17 | // The parameters are run, startTime, endTime | |
18 | AliTestShuttle* shuttle = new AliTestShuttle(7, 0, 1); | |
19 | ||
438a188c | 20 | // TODO if needed, change location of OCDB and Reference test folders |
21 | // by default they are set to $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB and TestReference | |
22 | AliTestShuttle::SetMainCDB("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB"); | |
23 | AliTestShuttle::SetMainRefStorage("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestReference"); | |
24 | ||
25 | printf("Test OCDB storage Uri: %s\n", AliShuttleInterface::GetMainCDB().Data()); | |
26 | printf("Test Reference storage Uri: %s\n", AliShuttleInterface::GetMainRefStorage().Data()); | |
27 | ||
28 | ||
29 | // TODO(1) | |
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 | //WriteDCSAliasMap(); | |
46 | ||
47 | // now give the alias map to the shuttle | |
48 | shuttle->SetDCSInput(dcsAliasMap); | |
49 | ||
50 | // TODO(2) | |
51 | // | |
52 | // The shuttle can also process files that originate from DCS, DAQ and HLT. | |
53 | // To test it, we provide some local files and locations where these would be found when | |
54 | // the online machinery would be there. | |
55 | // In real life this functions would be produces by the sub-detectors | |
56 | // calibration programs in DCS, DAQ or HLT. These files can then be retrieved using the Shuttle. | |
57 | // | |
58 | // Files are added with the function AliTestShuttle::AddInputFile. The syntax is: | |
59 | // AddInputFile(<system>, <detector>, <id>, <source>, <local-file>) | |
60 | // In this example we add a file originating from the GDC with the id PEDESTALS | |
61 | // Three files originating from different LDCs but with the same id are also added | |
62 | // Note that the test preprocessor name is TPC. The name of the detector's preprocessor must follow | |
63 | // the "online" naming convention ALICE-INT-2003-039. | |
64 | shuttle->AddInputFile(AliTestShuttle::kDAQ, "ZDC", "PEDESTALS", "LDC0", "ZDCPedestal.dat"); | |
b5856638 | 65 | shuttle->AddInputFile(AliTestShuttle::kDAQ, "ZDC", "EMDCALIB", "LDC0", "ZDCEMDCalib.dat"); |
66 | shuttle->AddInputFile(AliTestShuttle::kDAQ, "ZDC", "PHYSICS", "LDC0", "ZDCRecParam.dat"); | |
438a188c | 67 | |
68 | // TODO(3) | |
69 | // | |
70 | // The shuttle can read run type stored in the DAQ logbook. | |
71 | // To test it, we must provide the run type manually. They will be retrieved in the preprocessor | |
72 | // using GetRunType function. | |
952af594 | 73 | // shuttle->SetInputRunType("PEDESTALS"); |
b5856638 | 74 | // shuttle->SetInputRunType("PULSER_RUN"); |
75 | shuttle->SetInputRunType("PHYSICS"); | |
438a188c | 76 | |
77 | // TODO(4) | |
78 | // | |
79 | // The shuttle can read run parameters stored in the DAQ run logbook. | |
80 | // To test it, we must provide the run parameters manually. They will be retrieved in the preprocessor | |
81 | // using GetRunParameter function. | |
82 | // In real life the parameters will be retrieved automatically from the run logbook; | |
83 | shuttle->AddInputRunParameter("totalEvents", "1000"); | |
84 | shuttle->AddInputRunParameter("NumberOfGDCs", "1"); | |
85 | ||
952af594 | 86 | // TODO(5) NEW! |
87 | // | |
88 | // This is for preprocessor that require data from HLT. | |
89 | // Since HLT may be switched off, the preprocessor should first query the Run logbook where | |
90 | // the HLT status is stored. SHUTTLE implements a shortcut function (GetHLTStatus) that returns | |
91 | // a bool directly. 1 = HLT ON, 0 = HLT OFF | |
92 | // | |
93 | Bool_t hltStatus=kFALSE; | |
94 | //shuttle->SetInputHLTStatus(hltStatus); | |
95 | ||
96 | // TODO(6) | |
438a188c | 97 | // |
98 | // The shuttle can query condition parameters valid from the current run from the OCDB | |
99 | // To test it, we must first store the object into the OCDB. It will be retrieved in the preprocessor | |
100 | // using GetFromOCDB function. | |
952af594 | 101 | /* |
438a188c | 102 | TObjString obj("This is a condition parameter stored in OCDB"); |
103 | AliCDBId id("ZDC/Calib/Data", 0, AliCDBRunRange::Infinity()); | |
104 | AliCDBMetaData md; | |
105 | AliCDBEntry entry(&obj, id, &md); | |
106 | ||
107 | shuttle->AddInputCDBEntry(&entry); | |
952af594 | 108 | */ |
438a188c | 109 | // TODO(6) |
110 | // Create the preprocessor that should be tested, it registers itself automatically to the shuttle | |
952af594 | 111 | AliPreprocessor* test = new AliZDCPreprocessor(shuttle); |
438a188c | 112 | |
113 | // Test the preprocessor | |
114 | shuttle->Process(); | |
115 | ||
116 | // TODO(7) | |
117 | // In the preprocessor AliShuttleInterface::Store should be called to put the final | |
118 | // data to the CDB. To check if all went fine have a look at the files produced in | |
119 | // $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB/<detector>/SHUTTLE/Data | |
120 | // | |
121 | // Check the file which should have been created | |
952af594 | 122 | AliCDBEntry* chkEntry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB()) |
123 | ->Get("ZDC/Calib/Data", 7); | |
438a188c | 124 | if (!chkEntry) |
125 | { | |
126 | printf("The file is not there. Something went wrong.\n"); | |
127 | return; | |
128 | } | |
129 | ||
130 | AliTestDataDCS* output = dynamic_cast<AliTestDataDCS*> (chkEntry->GetObject()); | |
131 | // If everything went fine, draw the result | |
132 | if (output) | |
133 | output->Draw(); | |
134 | } | |
135 | ||
136 | TMap* 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 | // In this example 6 aliases exists: DCSAlias1 ... DCSAlias6 | |
147 | // Each contains 1000 values randomly generated by TRandom::Gaus + 5*nAlias | |
148 | ||
149 | TMap* aliasMap = new TMap; | |
150 | aliasMap->SetOwner(1); | |
151 | ||
152 | TRandom random; | |
952af594 | 153 | TString aliasNames[28]; |
438a188c | 154 | |
155 | // ******************************** alignment values | |
156 | aliasNames[0] = "ZDC_ZNA_POS.actual.position"; | |
157 | aliasNames[1] = "ZDC_ZPA_POS.actual.position"; | |
158 | aliasNames[2] = "ZDC_ZNC_POS.actual.position"; | |
159 | aliasNames[3] = "ZDC_ZPC_POS.actual.position"; | |
160 | // | |
161 | for(int nAlias=0; nAlias<4; nAlias++) | |
162 | { | |
163 | TObjArray* valueSet = new TObjArray; | |
164 | valueSet->SetOwner(1); | |
165 | ||
166 | TString aliasName = aliasNames[nAlias]; | |
167 | printf("\n\n alias: %s\n\n",aliasName.Data()); | |
168 | ||
169 | Float_t simVal = (Float_t) (random.Rndm()*0.025+random.Rndm()*0.1); | |
170 | for(int i=0;i<3;i++) | |
171 | { | |
172 | int timeStamp1[3] = {0,500,1000}; | |
173 | AliDCSValue* dcsVal = new AliDCSValue(simVal, timeStamp1[i]); | |
174 | printf("%s\n",dcsVal->ToString()); | |
175 | valueSet->Add(dcsVal); | |
176 | } | |
177 | aliasMap->Add(new TObjString(aliasName), valueSet); | |
178 | } | |
179 | // ******************************** HV values | |
180 | /*TString ZNAAlias = "ZNA_HV.actual.vMon"; | |
181 | TString ZPAAlias = "ZPA_HV.actual.vMon"; | |
182 | TString ZNCAlias = "ZNC_HV.actual.vMon"; | |
183 | TString ZPCAlias = "ZPC_HV.actual.vMon"; | |
184 | TString idat[5]; | |
185 | for(int i=0;i<5;i++) | |
186 | { | |
187 | idat[i] = i; | |
188 | aliasNames[i+3] = ZNAAlias.Insert(6,idat[i]); | |
189 | aliasNames[i+7] = ZPAAlias.Insert(6,idat[i]); | |
190 | aliasNames[i+11] = ZNCAlias.Insert(6,idat[i]); | |
191 | aliasNames[i+15] = ZPCAlias.Insert(6,idat[i]); | |
192 | }*/ | |
193 | aliasNames[4] = "ZDC_ZNA_HV0.actual.vMon"; | |
194 | aliasNames[5] = "ZDC_ZNA_HV1.actual.vMon"; | |
195 | aliasNames[6] = "ZDC_ZNA_HV2.actual.vMon"; | |
196 | aliasNames[7] = "ZDC_ZNA_HV3.actual.vMon"; | |
197 | aliasNames[8] = "ZDC_ZNA_HV4.actual.vMon"; | |
198 | // | |
199 | aliasNames[9] = "ZDC_ZPA_HV0.actual.vMon"; | |
200 | aliasNames[10] = "ZDC_ZPA_HV1.actual.vMon"; | |
201 | aliasNames[11] = "ZDC_ZPA_HV2.actual.vMon"; | |
202 | aliasNames[12] = "ZDC_ZPA_HV3.actual.vMon"; | |
203 | aliasNames[13] = "ZDC_ZPA_HV4.actual.vMon"; | |
204 | // | |
205 | aliasNames[14] = "ZDC_ZNC_HV0.actual.vMon"; | |
206 | aliasNames[15] = "ZDC_ZNC_HV1.actual.vMon"; | |
207 | aliasNames[16] = "ZDC_ZNC_HV2.actual.vMon"; | |
208 | aliasNames[17] = "ZDC_ZNC_HV3.actual.vMon"; | |
209 | aliasNames[18] = "ZDC_ZNC_HV4.actual.vMon"; | |
210 | // | |
211 | aliasNames[19] = "ZDC_ZPC_HV0.actual.vMon"; | |
212 | aliasNames[20] = "ZDC_ZPC_HV1.actual.vMon"; | |
213 | aliasNames[21] = "ZDC_ZPC_HV2.actual.vMon"; | |
214 | aliasNames[22] = "ZDC_ZPC_HV3.actual.vMon"; | |
215 | aliasNames[23] = "ZDC_ZPC_HV4.actual.vMon"; | |
216 | // | |
952af594 | 217 | aliasNames[24] = "ZDC_ZEM_HV0.actual.vMon"; |
218 | aliasNames[25] = "ZDC_ZEM_HV1.actual.vMon"; | |
219 | // | |
220 | aliasNames[26] = "ZDC_REFA_HV0.actual.vMon"; | |
221 | aliasNames[27] = "ZDC_REFC_HV1.actual.vMon"; | |
438a188c | 222 | // |
952af594 | 223 | for(int nAlias=4;nAlias<28;nAlias++) |
438a188c | 224 | { |
225 | TObjArray* valueSet = new TObjArray; | |
226 | valueSet->SetOwner(1); | |
227 | ||
228 | TString aliasName = aliasNames[nAlias]; | |
229 | printf("\n\n alias: %s\n\n",aliasName.Data()); | |
230 | ||
231 | for(int timeStamp=0;timeStamp<=1000;timeStamp+=500) | |
232 | { | |
233 | Float_t simVal = (Float_t) (random.Gaus()*600.+1800.); | |
234 | AliDCSValue* dcsVal = new AliDCSValue(simVal, timeStamp); | |
235 | printf("%s\n",dcsVal->ToString()); | |
236 | valueSet->Add(dcsVal); | |
237 | } | |
238 | aliasMap->Add(new TObjString(aliasName), valueSet); | |
239 | } | |
240 | ||
241 | return aliasMap; | |
242 | } | |
243 | ||
244 | TMap* ReadDCSAliasMap() | |
245 | { | |
246 | // Open a file that contains DCS input data | |
247 | // The CDB framework is used to open the file, this means the file is located | |
248 | // in $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB/<detector>/DCS/Data | |
249 | // The file contains an AliCDBEntry that contains a TMap with the DCS structure. | |
250 | // An explanation of the structure can be found in CreateDCSAliasMap() | |
251 | ||
252 | AliCDBEntry *entry = AliCDBManager::Instance()->Get("ZDC/DCS/Data", 0); | |
253 | return dynamic_cast<TMap*> (entry->GetObject()); | |
254 | } | |
255 | ||
256 | void WriteDCSAliasMap() | |
257 | { | |
258 | // This writes the output from CreateDCSAliasMap to a CDB file | |
259 | ||
260 | TMap* dcsAliasMap = CreateDCSAliasMap(); | |
261 | ||
262 | AliCDBMetaData metaData; | |
263 | metaData.SetBeamPeriod(0); | |
264 | metaData.SetResponsible("Responsible person"); | |
265 | metaData.SetComment("Test object for TestPreprocessor.C"); | |
266 | ||
267 | AliCDBId id("ZDC/DCS/Data", 0, 0); | |
268 | ||
269 | // initialize location of CDB | |
270 | AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB"); | |
271 | ||
272 | AliCDBManager::Instance()->Put(dcsAliasMap, id, &metaData); | |
273 | } |