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