]>
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 | ||
86dc0caa | 11 | void TestZDCPreprocessor(Int_t obj=0) |
438a188c | 12 | { |
13 | // load library | |
14 | gSystem->Load("libTestShuttle.so"); | |
15 | ||
16 | // create AliTestShuttle instance | |
17 | // The parameters are run, startTime, endTime | |
86dc0caa | 18 | AliTestShuttle* shuttle = new AliTestShuttle(0, 0, 1); |
438a188c | 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 | |
162637e4 | 22 | AliTestShuttle::SetMainCDB("local://$ALICE_ROOT/OCDB/SHUTTLE/TestShuttle/TestCDB"); |
23 | AliTestShuttle::SetMainRefStorage("local://$ALICE_ROOT/OCDB/SHUTTLE/TestShuttle/TestReference"); | |
438a188c | 24 | |
25 | printf("Test OCDB storage Uri: %s\n", AliShuttleInterface::GetMainCDB().Data()); | |
26 | printf("Test Reference storage Uri: %s\n", AliShuttleInterface::GetMainRefStorage().Data()); | |
27 | ||
438a188c | 28 | // TODO(1) |
29 | // | |
30 | // The shuttle can read DCS data, if the preprocessor should be tested to process DCS data, | |
31 | // some fake data has to be created. | |
32 | // | |
33 | // The "fake" input data can be taken using either (a) or (b): | |
34 | // (a) data from a file: Use ReadDCSAliasMap() | |
35 | // the format of the file is explained in ReadDCSAliasMap() | |
36 | // To use it uncomment the following line: | |
37 | // | |
38 | //TMap* dcsAliasMap = ReadDCSAliasMap(); | |
39 | // | |
40 | // (b) generated in this macro: Use CreateDCSAliasMap() and its documentation | |
41 | // To use it uncomment the following line: | |
42 | // | |
43 | TMap* dcsAliasMap = CreateDCSAliasMap(); | |
44 | //WriteDCSAliasMap(); | |
45 | ||
46 | // now give the alias map to the shuttle | |
47 | shuttle->SetDCSInput(dcsAliasMap); | |
48 | ||
49 | // TODO(2) | |
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. | |
1ee299a5 | 63 | // |
438a188c | 64 | shuttle->AddInputFile(AliTestShuttle::kDAQ, "ZDC", "PEDESTALS", "LDC0", "ZDCPedestal.dat"); |
321fe3b8 | 65 | // |
66 | shuttle->AddInputFile(AliTestShuttle::kDAQ, "ZDC", "LASER", "LDC0", "ZDCLaserCalib.dat"); | |
321fe3b8 | 67 | // |
68 | shuttle->AddInputFile(AliTestShuttle::kDAQ, "ZDC", "EMDCALIB", "LDC0", "ZDCEMDCalib.dat"); | |
321fe3b8 | 69 | // |
70 | shuttle->AddInputFile(AliTestShuttle::kDAQ, "ZDC", "PHYSICS", "LDC0", "ZDCChMapping.dat"); | |
321fe3b8 | 71 | // |
72 | shuttle->AddInputFile(AliTestShuttle::kDAQ, "ZDC", "BC", "LDC0", "ZDCChMapping.dat"); | |
438a188c | 73 | |
74 | // TODO(3) | |
75 | // | |
76 | // The shuttle can read run type stored in the DAQ logbook. | |
77 | // To test it, we must provide the run type manually. They will be retrieved in the preprocessor | |
78 | // using GetRunType function. | |
86dc0caa | 79 | if(obj==1) shuttle->SetInputRunType("STANDALONE_PEDESTAL"); |
80 | else if(obj==2) shuttle->SetInputRunType("STANDALONE_LASER"); | |
81 | else if(obj==3) shuttle->SetInputRunType("STANDALONE_EMD"); | |
321fe3b8 | 82 | else if(obj==4) shuttle->SetInputRunType("STANDALONE_COSMIC"); |
83 | else if(obj==5) shuttle->SetInputRunType("STANDALONE_BC"); | |
84 | else if(obj==6) shuttle->SetInputRunType("PHYSICS"); | |
438a188c | 85 | |
86 | // TODO(4) | |
87 | // | |
88 | // The shuttle can read run parameters stored in the DAQ run logbook. | |
89 | // To test it, we must provide the run parameters manually. They will be retrieved in the preprocessor | |
90 | // using GetRunParameter function. | |
91 | // In real life the parameters will be retrieved automatically from the run logbook; | |
321fe3b8 | 92 | //shuttle->AddInputRunParameter("beamType", "Pb-Pb"); |
93 | shuttle->AddInputRunParameter("beamType", "p-p"); | |
438a188c | 94 | shuttle->AddInputRunParameter("totalEvents", "1000"); |
95 | shuttle->AddInputRunParameter("NumberOfGDCs", "1"); | |
96 | ||
952af594 | 97 | // TODO(5) NEW! |
98 | // | |
99 | // This is for preprocessor that require data from HLT. | |
100 | // Since HLT may be switched off, the preprocessor should first query the Run logbook where | |
101 | // the HLT status is stored. SHUTTLE implements a shortcut function (GetHLTStatus) that returns | |
102 | // a bool directly. 1 = HLT ON, 0 = HLT OFF | |
103 | // | |
104 | Bool_t hltStatus=kFALSE; | |
d2317a93 | 105 | shuttle->SetInputHLTStatus(hltStatus); |
952af594 | 106 | |
107 | // TODO(6) | |
438a188c | 108 | // |
109 | // The shuttle can query condition parameters valid from the current run from the OCDB | |
110 | // To test it, we must first store the object into the OCDB. It will be retrieved in the preprocessor | |
111 | // using GetFromOCDB function. | |
1ee299a5 | 112 | |
113 | /*TObjString obj("This is a condition parameter stored in OCDB"); | |
438a188c | 114 | AliCDBId id("ZDC/Calib/Data", 0, AliCDBRunRange::Infinity()); |
115 | AliCDBMetaData md; | |
116 | AliCDBEntry entry(&obj, id, &md); | |
117 | ||
118 | shuttle->AddInputCDBEntry(&entry); | |
1ee299a5 | 119 | */ |
120 | ||
438a188c | 121 | // TODO(6) |
122 | // Create the preprocessor that should be tested, it registers itself automatically to the shuttle | |
952af594 | 123 | AliPreprocessor* test = new AliZDCPreprocessor(shuttle); |
438a188c | 124 | |
125 | // Test the preprocessor | |
126 | shuttle->Process(); | |
127 | ||
128 | // TODO(7) | |
129 | // In the preprocessor AliShuttleInterface::Store should be called to put the final | |
130 | // data to the CDB. To check if all went fine have a look at the files produced in | |
131 | // $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB/<detector>/SHUTTLE/Data | |
132 | // | |
133 | // Check the file which should have been created | |
1ee299a5 | 134 | AliCDBEntry* chkEntry0 = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB()) |
86dc0caa | 135 | ->Get("ZDC/Calib/ChMap", 0); |
136 | AliCDBEntry* chkEntry1; | |
137 | if(obj==1) chkEntry1 = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB()) | |
138 | ->Get("ZDC/Calib/Pedestals", 0); | |
139 | else if(obj==2) chkEntry1 = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB()) | |
140 | ->Get("ZDC/Calib/LaserCalib", 0); | |
141 | else if(obj==3) chkEntry1 = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB()) | |
142 | ->Get("ZDC/Calib/EMDCalib", 0); | |
1ee299a5 | 143 | |
6024ec85 | 144 | |
86dc0caa | 145 | if(!chkEntry0){ |
146 | printf("No file in \n ZDC/Calib/ChMap\n"); | |
438a188c | 147 | return; |
148 | } | |
86dc0caa | 149 | if(!chkEntry1){ |
150 | if(obj==1) printf("No file in \n ZDC/Calib/Pedestal\n"); | |
151 | else if(obj==2) printf("No file in \n ZDC/Calib/LaserCalib\n"); | |
152 | else if(obj==3) printf("No file in \n ZDC/Calib/EMDCalib\n"); | |
153 | return; | |
154 | } | |
155 | ||
438a188c | 156 | |
86dc0caa | 157 | /*AliTestDataDCS* output = dynamic_cast<AliTestDataDCS*> (chkEntry1->GetObject()); |
438a188c | 158 | // If everything went fine, draw the result |
159 | if (output) | |
86dc0caa | 160 | output->Draw();*/ |
438a188c | 161 | } |
162 | ||
163 | TMap* CreateDCSAliasMap() | |
164 | { | |
165 | // Creates a DCS structure | |
166 | // The structure is the following: | |
167 | // TMap (key --> value) | |
168 | // <DCSAlias> --> <valueList> | |
169 | // <DCSAlias> is a string | |
170 | // <valueList> is a TObjArray of AliDCSValue | |
171 | // An AliDCSValue consists of timestamp and a value in form of a AliSimpleValue | |
172 | ||
173 | // In this example 6 aliases exists: DCSAlias1 ... DCSAlias6 | |
174 | // Each contains 1000 values randomly generated by TRandom::Gaus + 5*nAlias | |
175 | ||
176 | TMap* aliasMap = new TMap; | |
177 | aliasMap->SetOwner(1); | |
178 | ||
179 | TRandom random; | |
952af594 | 180 | TString aliasNames[28]; |
438a188c | 181 | |
182 | // ******************************** alignment values | |
183 | aliasNames[0] = "ZDC_ZNA_POS.actual.position"; | |
184 | aliasNames[1] = "ZDC_ZPA_POS.actual.position"; | |
185 | aliasNames[2] = "ZDC_ZNC_POS.actual.position"; | |
186 | aliasNames[3] = "ZDC_ZPC_POS.actual.position"; | |
187 | // | |
188 | for(int nAlias=0; nAlias<4; nAlias++) | |
189 | { | |
190 | TObjArray* valueSet = new TObjArray; | |
191 | valueSet->SetOwner(1); | |
192 | ||
193 | TString aliasName = aliasNames[nAlias]; | |
194 | printf("\n\n alias: %s\n\n",aliasName.Data()); | |
195 | ||
196 | Float_t simVal = (Float_t) (random.Rndm()*0.025+random.Rndm()*0.1); | |
197 | for(int i=0;i<3;i++) | |
198 | { | |
199 | int timeStamp1[3] = {0,500,1000}; | |
200 | AliDCSValue* dcsVal = new AliDCSValue(simVal, timeStamp1[i]); | |
201 | printf("%s\n",dcsVal->ToString()); | |
202 | valueSet->Add(dcsVal); | |
203 | } | |
204 | aliasMap->Add(new TObjString(aliasName), valueSet); | |
205 | } | |
206 | // ******************************** HV values | |
438a188c | 207 | aliasNames[4] = "ZDC_ZNA_HV0.actual.vMon"; |
208 | aliasNames[5] = "ZDC_ZNA_HV1.actual.vMon"; | |
209 | aliasNames[6] = "ZDC_ZNA_HV2.actual.vMon"; | |
210 | aliasNames[7] = "ZDC_ZNA_HV3.actual.vMon"; | |
211 | aliasNames[8] = "ZDC_ZNA_HV4.actual.vMon"; | |
212 | // | |
213 | aliasNames[9] = "ZDC_ZPA_HV0.actual.vMon"; | |
214 | aliasNames[10] = "ZDC_ZPA_HV1.actual.vMon"; | |
215 | aliasNames[11] = "ZDC_ZPA_HV2.actual.vMon"; | |
216 | aliasNames[12] = "ZDC_ZPA_HV3.actual.vMon"; | |
217 | aliasNames[13] = "ZDC_ZPA_HV4.actual.vMon"; | |
218 | // | |
219 | aliasNames[14] = "ZDC_ZNC_HV0.actual.vMon"; | |
220 | aliasNames[15] = "ZDC_ZNC_HV1.actual.vMon"; | |
221 | aliasNames[16] = "ZDC_ZNC_HV2.actual.vMon"; | |
222 | aliasNames[17] = "ZDC_ZNC_HV3.actual.vMon"; | |
223 | aliasNames[18] = "ZDC_ZNC_HV4.actual.vMon"; | |
224 | // | |
225 | aliasNames[19] = "ZDC_ZPC_HV0.actual.vMon"; | |
226 | aliasNames[20] = "ZDC_ZPC_HV1.actual.vMon"; | |
227 | aliasNames[21] = "ZDC_ZPC_HV2.actual.vMon"; | |
228 | aliasNames[22] = "ZDC_ZPC_HV3.actual.vMon"; | |
229 | aliasNames[23] = "ZDC_ZPC_HV4.actual.vMon"; | |
230 | // | |
952af594 | 231 | aliasNames[24] = "ZDC_ZEM_HV0.actual.vMon"; |
232 | aliasNames[25] = "ZDC_ZEM_HV1.actual.vMon"; | |
233 | // | |
20a3b76c | 234 | aliasNames[26] = "ZDC_REFA_HV.actual.vMon"; |
235 | aliasNames[27] = "ZDC_REFC_HV.actual.vMon"; | |
438a188c | 236 | // |
952af594 | 237 | for(int nAlias=4;nAlias<28;nAlias++) |
438a188c | 238 | { |
239 | TObjArray* valueSet = new TObjArray; | |
240 | valueSet->SetOwner(1); | |
241 | ||
242 | TString aliasName = aliasNames[nAlias]; | |
243 | printf("\n\n alias: %s\n\n",aliasName.Data()); | |
244 | ||
245 | for(int timeStamp=0;timeStamp<=1000;timeStamp+=500) | |
246 | { | |
247 | Float_t simVal = (Float_t) (random.Gaus()*600.+1800.); | |
248 | AliDCSValue* dcsVal = new AliDCSValue(simVal, timeStamp); | |
249 | printf("%s\n",dcsVal->ToString()); | |
250 | valueSet->Add(dcsVal); | |
251 | } | |
252 | aliasMap->Add(new TObjString(aliasName), valueSet); | |
253 | } | |
254 | ||
255 | return aliasMap; | |
256 | } | |
257 | ||
258 | TMap* ReadDCSAliasMap() | |
259 | { | |
260 | // Open a file that contains DCS input data | |
261 | // The CDB framework is used to open the file, this means the file is located | |
262 | // in $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB/<detector>/DCS/Data | |
263 | // The file contains an AliCDBEntry that contains a TMap with the DCS structure. | |
264 | // An explanation of the structure can be found in CreateDCSAliasMap() | |
265 | ||
266 | AliCDBEntry *entry = AliCDBManager::Instance()->Get("ZDC/DCS/Data", 0); | |
267 | return dynamic_cast<TMap*> (entry->GetObject()); | |
268 | } | |
269 | ||
270 | void WriteDCSAliasMap() | |
271 | { | |
272 | // This writes the output from CreateDCSAliasMap to a CDB file | |
273 | ||
274 | TMap* dcsAliasMap = CreateDCSAliasMap(); | |
275 | ||
276 | AliCDBMetaData metaData; | |
277 | metaData.SetBeamPeriod(0); | |
d2317a93 | 278 | metaData.SetResponsible("Chiara Oppedisano"); |
279 | metaData.SetComment("Test object for TestZDCPreprocessor.C"); | |
438a188c | 280 | |
281 | AliCDBId id("ZDC/DCS/Data", 0, 0); | |
282 | ||
283 | // initialize location of CDB | |
162637e4 | 284 | AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/OCDB/SHUTTLE/TestShuttle/TestCDB"); |
438a188c | 285 | |
286 | AliCDBManager::Instance()->Put(dcsAliasMap, id, &metaData); | |
287 | } |