]>
Commit | Line | Data |
---|---|---|
b6461bb1 | 1 | // Macro to parse the text dump of the RCT and convert it into |
2 | // a RunTag object. This object needs to be then merged with the | |
3 | // proper RunTag from the Run. | |
4 | // | |
5 | // Parameters: | |
6 | // Name of the text file with the dump from MonaLisa RCT page | |
7 | // | |
8 | // Author: Adam.Kisiel@cern.ch | |
9 | ||
10 | int getposition(const char *token, int poscount) | |
11 | { | |
12 | int position = -1; | |
13 | ||
14 | if (strstr(token, "#raw_run")) { | |
15 | position = 0; | |
16 | cout << "Run number at " << poscount << endl; | |
17 | } | |
18 | else if (strstr(token, "partition")) { | |
19 | position = 1; | |
20 | cout << "LHC Period at " << poscount << endl; | |
21 | } | |
22 | else if (strstr(token, "fillno")) { | |
23 | position = 4; | |
24 | cout << "Fill number at " << poscount << endl; | |
25 | } | |
26 | else if (strstr(token, "energy")) { | |
27 | position = 5; | |
28 | cout << "Beam Energy at " << poscount << endl; | |
29 | } | |
30 | else if (strstr(token, "intensity_per_bunch")) { | |
31 | position = 6; | |
32 | cout << "Bunch Intensity at " << poscount << endl; | |
33 | } | |
34 | else if (strstr(token, "cbeamb_abce_nopf_all")) { | |
35 | position = 7; | |
36 | cout << "Beam Triggers at " << poscount << endl; | |
37 | } | |
38 | else if (strstr(token, "cint1b_abce_nopf_all")) { | |
39 | position = 8; | |
40 | cout << "Collision Triggers at " << poscount << endl; | |
41 | } | |
42 | else if (strstr(token, "rate")) { | |
43 | position = 9; | |
44 | cout << "Collision rate at " << poscount << endl; | |
45 | } | |
46 | else if (strstr(token, "cint1_e_nopf_all")) { | |
47 | position = 10; | |
48 | cout << "Empty Triggers at " << poscount << endl; | |
49 | } | |
50 | else if (strstr(token, "cint1a_abce_nopf_all")) { | |
51 | position = 11; | |
52 | cout << "ASide Triggers at " << poscount << endl; | |
53 | } | |
54 | else if (strstr(token, "cint1c_abce_nopf_all")) { | |
55 | position = 12; | |
56 | cout << "CSide Triggers at " << poscount << endl; | |
57 | } | |
58 | else if (strstr(token, "mean_vertex_xyz")) { | |
59 | position = 13; | |
60 | cout << "Mean Vertex at " << poscount << endl; | |
61 | } | |
62 | else if (strstr(token, "vertex_quality")) { | |
63 | position = 14; | |
64 | cout << "Vertex Quality at " << poscount << endl; | |
65 | } | |
66 | else if (strstr(token, "field")) { | |
67 | position = 15; | |
68 | cout << "Magnetic Field at " << poscount << endl; | |
69 | } | |
70 | else if (strstr(token, "det_aco")) { | |
71 | position = 16; | |
72 | cout << "ACORDE at " << poscount << endl; | |
73 | } | |
74 | else if (strstr(token, "det_emc")) { | |
75 | position = 17; | |
76 | cout << "EMC at " << poscount << endl; | |
77 | } | |
78 | else if (strstr(token, "det_fmd")) { | |
79 | position = 18; | |
80 | cout << "FMD at " << poscount << endl; | |
81 | } | |
82 | else if (strstr(token, "det_hlt")) { | |
83 | position = 19; | |
84 | cout << "HLT at " << poscount << endl; | |
85 | } | |
86 | else if (strstr(token, "det_hmp")) { | |
87 | position = 20; | |
88 | cout << "HMPID at " << poscount << endl; | |
89 | } | |
90 | else if (strstr(token, "det_mch")) { | |
91 | position = 21; | |
92 | cout << "MCH at " << poscount << endl; | |
93 | } | |
94 | else if (strstr(token, "det_mtr")) { | |
95 | position = 22; | |
96 | cout << "MTR at " << poscount << endl; | |
97 | } | |
98 | else if (strstr(token, "det_phs")) { | |
99 | position = 23; | |
100 | cout << "PHOS at " << poscount << endl; | |
101 | } | |
102 | else if (strstr(token, "det_pmd")) { | |
103 | position = 24; | |
104 | cout << "pmd at " << poscount << endl; | |
105 | } | |
106 | else if (strstr(token, "det_spd")) { | |
107 | position = 25; | |
108 | cout << "SPD at " << poscount << endl; | |
109 | } | |
110 | else if (strstr(token, "det_sdd")) { | |
111 | position = 26; | |
112 | cout << "SDD at " << poscount << endl; | |
113 | } | |
114 | else if (strstr(token, "det_ssd")) { | |
115 | position = 27; | |
116 | cout << "SSD at " << poscount << endl; | |
117 | } | |
118 | else if (strstr(token, "det_tof")) { | |
119 | position = 28; | |
120 | cout << "TOF at " << poscount << endl; | |
121 | } | |
122 | else if (strstr(token, "det_tpc")) { | |
123 | position = 29; | |
124 | cout << "TPC at " << poscount << endl; | |
125 | } | |
126 | else if (strstr(token, "det_trd")) { | |
127 | position = 30; | |
128 | cout << "TRD at " << poscount << endl; | |
129 | } | |
130 | else if (strstr(token, "det_t00")) { | |
131 | position = 31; | |
132 | cout << "TZERO at " << poscount << endl; | |
133 | } | |
134 | else if (strstr(token, "det_v00")) { | |
135 | position = 32; | |
136 | cout << "VZERO at " << poscount << endl; | |
137 | } | |
138 | else if (strstr(token, "det_zdc")) { | |
139 | position = 33; | |
140 | cout << "ZDC at " << poscount << endl; | |
141 | } | |
142 | else if (strstr(token, "filling_config")) { | |
143 | position = 39; | |
144 | cout << "Filling Scheme at " << poscount << endl; | |
145 | } | |
146 | else if (strstr(token, "quality")) { | |
147 | position = 40; | |
148 | cout << "Quality at " << poscount << endl; | |
149 | } | |
150 | else if (strstr(token, "muon_trigger")) { | |
151 | position = 41; | |
152 | cout << "Muon Trigger at " << poscount << endl; | |
153 | } | |
154 | else if (strstr(token, "high_multiplicity_trigger")) { | |
155 | position = 42; | |
156 | cout << "High Multiplicity trigger at " << poscount << endl; | |
157 | } | |
158 | ||
159 | return position; | |
160 | } | |
161 | ||
162 | void ParseRCTDump(const char *insum = "rctdump.txt") | |
163 | { | |
164 | ifstream *istr = new ifstream(insum); | |
165 | ||
166 | char buf[10000]; | |
167 | istr->getline(buf, 10000); | |
168 | ||
169 | if (strstr(buf, "#raw_run")) | |
170 | cout << "Found raw run " << endl; | |
171 | ||
172 | char *nval; | |
173 | char *nlin = strstr(buf, "|"); | |
174 | char *nbeg = buf-1; | |
175 | char ntok[1000]; | |
176 | char nstr[1000]; | |
177 | ||
178 | // Parse field name list | |
179 | ||
180 | int fieldpos[200]; | |
181 | int poscount = 0; | |
182 | ||
183 | do { | |
184 | if (nlin == NULL) { | |
185 | strcpy(ntok, nbeg+1); | |
186 | // ntok[nlin-nbeg-1] = '\0'; | |
187 | } | |
188 | else { | |
189 | strncpy(ntok, nbeg+1, nlin-nbeg-1); | |
190 | ntok[nlin-nbeg-1] = '\0'; | |
191 | } | |
192 | ||
193 | cout << "Token is " << ntok << endl; | |
194 | ||
195 | fieldpos[poscount] = getposition(ntok, poscount); | |
196 | ||
197 | nbeg = nlin; | |
198 | nlin = strstr(nlin+1, "|"); | |
199 | poscount++; | |
200 | } | |
201 | while (nlin != NULL); | |
202 | ||
203 | strcpy(ntok, nbeg+1); | |
204 | ||
205 | cout << "Token is " << ntok << endl; | |
206 | ||
207 | fieldpos[poscount] = getposition(ntok, poscount); | |
208 | ||
209 | TFile* ftag = TFile::Open("RunTableTagSummary.root", "recreate"); | |
210 | ||
211 | AliRunTag *tag = new AliRunTag(); | |
212 | TTree * ttag = new TTree("T","A Tree with event tags"); | |
213 | TBranch * btag = ttag->Branch("AliTAG", &tag); | |
214 | btag->SetCompressionLevel(9); | |
215 | ||
216 | int nfield = 0; | |
217 | ||
218 | ||
219 | while (!istr->eof()) { | |
220 | istr->getline(buf, 10000); | |
221 | nlin = strstr(buf, "|"); | |
222 | nbeg = buf-1; | |
223 | ||
224 | nfield = 0; | |
225 | ||
226 | cout << "Line " << nlin << endl; | |
227 | ||
228 | int endline = 0; | |
229 | ||
230 | while (!endline) { | |
231 | ||
232 | if (nlin == NULL) { | |
233 | strcpy(ntok, nbeg+1); | |
234 | endline = 1; | |
235 | } | |
236 | else { | |
237 | strncpy(ntok, nbeg+1, nlin-nbeg-1); | |
238 | ntok[nlin-nbeg-1] = '\0'; | |
239 | } | |
240 | if (ntok[0] == '"') { | |
241 | strncpy(nstr, ntok+1, strlen(ntok)-2); | |
242 | nstr[strlen(ntok)-2] = '\0'; | |
243 | } | |
244 | else if (ntok[0] == '(') { | |
245 | char *com = strstr(ntok, ";"); | |
246 | cout << ntok << " "<< com << endl; | |
247 | strncpy(nstr, ntok+1, com-ntok-1); | |
248 | nstr[com-ntok-1] = '\0'; | |
249 | } | |
250 | else { | |
251 | nstr[0] = '\0'; | |
252 | nstr[1] = '\0'; | |
253 | nstr[2] = '\0'; | |
254 | } | |
255 | ||
256 | if (nlin != NULL) { | |
257 | nbeg = nlin; | |
258 | nlin = strstr(nlin+1, "|"); | |
259 | } | |
260 | ||
261 | switch (fieldpos[nfield]) { | |
262 | case 0: | |
263 | tag->SetRunId(atoi(ntok)); | |
264 | break; | |
265 | case 1: | |
266 | tag->SetLHCPeriod(nstr); | |
267 | break; | |
268 | case 2: | |
269 | break; | |
270 | case 3: | |
271 | break; | |
272 | case 4: | |
273 | tag->GetLHCTag()->SetFillNo(atoi(ntok)); | |
274 | break; | |
275 | case 5: | |
276 | tag->GetLHCTag()->SetBeamEnergy(atof(ntok)); | |
277 | break; | |
278 | case 6: | |
279 | tag->GetLHCTag()->SetBunchIntensity(atof(ntok)); | |
280 | break; | |
281 | case 7: | |
282 | tag->SetBeamTriggers(atol(ntok)); | |
283 | break; | |
284 | case 8: | |
285 | tag->SetCollisionTriggers(atol(ntok)); | |
286 | break; | |
287 | case 9: | |
288 | tag->SetCollisionRate(atof(ntok)); | |
289 | break; | |
290 | case 10: | |
291 | tag->SetEmptyTriggers(atol(ntok)); | |
292 | break; | |
293 | case 11: | |
294 | tag->SetASideTriggers(atol(ntok)); | |
295 | break; | |
296 | case 12: | |
297 | tag->SetCSideTriggers(atol(ntok)); | |
298 | break; | |
299 | case 13: | |
300 | tag->SetMeanVertex(atof(ntok)); | |
301 | break; | |
302 | case 14: | |
303 | tag->SetVertexQuality(atof(ntok)); | |
304 | break; | |
305 | case 15: | |
306 | tag->SetMagneticField(atoi(ntok+1)); | |
307 | break; | |
308 | case 16: | |
309 | tag->GetDetectorTags()->SetDetectorStatus(17, nstr); | |
310 | break; | |
311 | case 17: | |
312 | tag->GetDetectorTags()->SetDetectorStatus(18, nstr); | |
313 | break; | |
314 | case 18: | |
315 | tag->GetDetectorTags()->SetDetectorStatus(12, nstr); | |
316 | break; | |
317 | case 19: | |
318 | tag->GetDetectorTags()->SetDetectorStatus(21, nstr); | |
319 | break; | |
320 | case 20: | |
321 | tag->GetDetectorTags()->SetDetectorStatus(6, nstr); | |
322 | break; | |
323 | case 21: | |
324 | tag->GetDetectorTags()->SetDetectorStatus(10, nstr); | |
325 | break; | |
326 | case 22: | |
327 | tag->GetDetectorTags()->SetDetectorStatus(11, nstr); | |
328 | break; | |
329 | case 23: | |
330 | tag->GetDetectorTags()->SetDetectorStatus(7, nstr); | |
331 | break; | |
332 | case 24: | |
333 | tag->GetDetectorTags()->SetDetectorStatus(9, nstr); | |
334 | break; | |
335 | case 25: | |
336 | tag->GetDetectorTags()->SetDetectorStatus(0, nstr); | |
337 | break; | |
338 | case 26: | |
339 | tag->GetDetectorTags()->SetDetectorStatus(1, nstr); | |
340 | break; | |
341 | case 27: | |
342 | tag->GetDetectorTags()->SetDetectorStatus(2, nstr); | |
343 | break; | |
344 | case 28: | |
345 | tag->GetDetectorTags()->SetDetectorStatus(5, nstr); | |
346 | break; | |
347 | case 29: | |
348 | tag->GetDetectorTags()->SetDetectorStatus(3, nstr); | |
349 | break; | |
350 | case 30: | |
351 | tag->GetDetectorTags()->SetDetectorStatus(4, nstr); | |
352 | break; | |
353 | case 31: | |
354 | tag->GetDetectorTags()->SetDetectorStatus(13, nstr); | |
355 | break; | |
356 | case 32: | |
357 | tag->GetDetectorTags()->SetDetectorStatus(14, nstr); | |
358 | break; | |
359 | case 33: | |
360 | tag->GetDetectorTags()->SetDetectorStatus(15, nstr); | |
361 | break; | |
362 | case 34: | |
363 | // comment | |
364 | break; | |
365 | case 35: | |
366 | // detectors | |
367 | break; | |
368 | case 36: | |
369 | // changedby | |
370 | break; | |
371 | case 37: | |
372 | // changedon | |
373 | break; | |
374 | case 38: | |
375 | // run duration | |
376 | break; | |
377 | case 39: | |
378 | tag->GetLHCTag()->SetFillingScheme(nstr); | |
379 | break; | |
380 | case 40: | |
381 | cout << "Setting Quality ]" << nstr << "[" << atoi(nstr) << endl; | |
382 | if (strlen(nstr) == 0) | |
383 | tag->SetRunQuality(0); | |
384 | else | |
385 | tag->SetRunQuality(atoi(nstr)); | |
386 | break; | |
387 | case 41: | |
388 | tag->SetMuonTriggers(atol(ntok)); | |
389 | break; | |
390 | case 42: | |
391 | tag->SetHMTriggers(atol(ntok)); | |
392 | break; | |
393 | } | |
394 | ||
395 | nfield++; | |
396 | } | |
397 | ||
398 | ||
399 | if (nfield > 1) { | |
400 | ttag->Fill(); | |
401 | tag->Clear(""); | |
402 | } | |
403 | } | |
404 | ||
405 | ftag->cd(); | |
406 | tag->Clear(); | |
407 | ttag->Write(); | |
408 | ftag->Close(); | |
409 | ||
410 | } |