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