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.
6 // Name of the text file with the dump from MonaLisa RCT page
8 // Author: Adam.Kisiel@cern.ch
10 int getposition(const char *token, int poscount)
14 if (strstr(token, "#raw_run")) {
16 cout << "Run number at " << poscount << endl;
18 else if (strstr(token, "partition")) {
20 cout << "LHC Period at " << poscount << endl;
22 else if (strstr(token, "fillno")) {
24 cout << "Fill number at " << poscount << endl;
26 else if (strstr(token, "energy")) {
28 cout << "Beam Energy at " << poscount << endl;
30 else if (strstr(token, "intensity_per_bunch")) {
32 cout << "Bunch Intensity at " << poscount << endl;
34 else if (strstr(token, "cbeamb_abce_nopf_all")) {
36 cout << "Beam Triggers at " << poscount << endl;
38 else if (strstr(token, "cint1b_abce_nopf_all")) {
40 cout << "Collision Triggers at " << poscount << endl;
42 else if (strstr(token, "rate")) {
44 cout << "Collision rate at " << poscount << endl;
46 else if (strstr(token, "cint1_e_nopf_all")) {
48 cout << "Empty Triggers at " << poscount << endl;
50 else if (strstr(token, "cint1a_abce_nopf_all")) {
52 cout << "ASide Triggers at " << poscount << endl;
54 else if (strstr(token, "cint1c_abce_nopf_all")) {
56 cout << "CSide Triggers at " << poscount << endl;
58 else if (strstr(token, "mean_vertex_xyz")) {
60 cout << "Mean Vertex at " << poscount << endl;
62 else if (strstr(token, "vertex_quality")) {
64 cout << "Vertex Quality at " << poscount << endl;
66 else if (strstr(token, "field")) {
68 cout << "Magnetic Field at " << poscount << endl;
70 else if (strstr(token, "det_aco")) {
72 cout << "ACORDE at " << poscount << endl;
74 else if (strstr(token, "det_emc")) {
76 cout << "EMC at " << poscount << endl;
78 else if (strstr(token, "det_fmd")) {
80 cout << "FMD at " << poscount << endl;
82 else if (strstr(token, "det_hlt")) {
84 cout << "HLT at " << poscount << endl;
86 else if (strstr(token, "det_hmp")) {
88 cout << "HMPID at " << poscount << endl;
90 else if (strstr(token, "det_mch")) {
92 cout << "MCH at " << poscount << endl;
94 else if (strstr(token, "det_mtr")) {
96 cout << "MTR at " << poscount << endl;
98 else if (strstr(token, "det_phs")) {
100 cout << "PHOS at " << poscount << endl;
102 else if (strstr(token, "det_pmd")) {
104 cout << "pmd at " << poscount << endl;
106 else if (strstr(token, "det_spd")) {
108 cout << "SPD at " << poscount << endl;
110 else if (strstr(token, "det_sdd")) {
112 cout << "SDD at " << poscount << endl;
114 else if (strstr(token, "det_ssd")) {
116 cout << "SSD at " << poscount << endl;
118 else if (strstr(token, "det_tof")) {
120 cout << "TOF at " << poscount << endl;
122 else if (strstr(token, "det_tpc")) {
124 cout << "TPC at " << poscount << endl;
126 else if (strstr(token, "det_trd")) {
128 cout << "TRD at " << poscount << endl;
130 else if (strstr(token, "det_t00")) {
132 cout << "TZERO at " << poscount << endl;
134 else if (strstr(token, "det_v00")) {
136 cout << "VZERO at " << poscount << endl;
138 else if (strstr(token, "det_zdc")) {
140 cout << "ZDC at " << poscount << endl;
142 else if (strstr(token, "filling_config")) {
144 cout << "Filling Scheme at " << poscount << endl;
146 else if (strstr(token, "quality")) {
148 cout << "Quality at " << poscount << endl;
150 else if (strstr(token, "muon_trigger")) {
152 cout << "Muon Trigger at " << poscount << endl;
154 else if (strstr(token, "high_multiplicity_trigger")) {
156 cout << "High Multiplicity trigger at " << poscount << endl;
162 void ParseRCTDump(const char *insum = "rctdump.txt")
164 ifstream *istr = new ifstream(insum);
167 istr->getline(buf, 10000);
169 if (strstr(buf, "#raw_run"))
170 cout << "Found raw run " << endl;
173 char *nlin = strstr(buf, "|");
178 // Parse field name list
185 strcpy(ntok, nbeg+1);
186 // ntok[nlin-nbeg-1] = '\0';
189 strncpy(ntok, nbeg+1, nlin-nbeg-1);
190 ntok[nlin-nbeg-1] = '\0';
193 cout << "Token is " << ntok << endl;
195 fieldpos[poscount] = getposition(ntok, poscount);
198 nlin = strstr(nlin+1, "|");
201 while (nlin != NULL);
203 strcpy(ntok, nbeg+1);
205 cout << "Token is " << ntok << endl;
207 fieldpos[poscount] = getposition(ntok, poscount);
209 TFile* ftag = TFile::Open("RunTableTagSummary.root", "recreate");
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);
219 while (!istr->eof()) {
220 istr->getline(buf, 10000);
221 nlin = strstr(buf, "|");
226 cout << "Line " << nlin << endl;
233 strcpy(ntok, nbeg+1);
237 strncpy(ntok, nbeg+1, nlin-nbeg-1);
238 ntok[nlin-nbeg-1] = '\0';
240 if (ntok[0] == '"') {
241 strncpy(nstr, ntok+1, strlen(ntok)-2);
242 nstr[strlen(ntok)-2] = '\0';
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';
258 nlin = strstr(nlin+1, "|");
261 switch (fieldpos[nfield]) {
263 tag->SetRunId(atoi(ntok));
266 tag->SetLHCPeriod(nstr);
273 tag->GetLHCTag()->SetFillNo(atoi(ntok));
276 tag->GetLHCTag()->SetBeamEnergy(atof(ntok));
279 tag->GetLHCTag()->SetBunchIntensity(atof(ntok));
282 tag->SetBeamTriggers(atol(ntok));
285 tag->SetCollisionTriggers(atol(ntok));
288 tag->SetCollisionRate(atof(ntok));
291 tag->SetEmptyTriggers(atol(ntok));
294 tag->SetASideTriggers(atol(ntok));
297 tag->SetCSideTriggers(atol(ntok));
300 tag->SetMeanVertex(atof(ntok));
303 tag->SetVertexQuality(atof(ntok));
306 tag->SetMagneticField(atoi(ntok+1));
309 tag->GetDetectorTags()->SetDetectorStatus(17, nstr);
312 tag->GetDetectorTags()->SetDetectorStatus(18, nstr);
315 tag->GetDetectorTags()->SetDetectorStatus(12, nstr);
318 tag->GetDetectorTags()->SetDetectorStatus(21, nstr);
321 tag->GetDetectorTags()->SetDetectorStatus(6, nstr);
324 tag->GetDetectorTags()->SetDetectorStatus(10, nstr);
327 tag->GetDetectorTags()->SetDetectorStatus(11, nstr);
330 tag->GetDetectorTags()->SetDetectorStatus(7, nstr);
333 tag->GetDetectorTags()->SetDetectorStatus(9, nstr);
336 tag->GetDetectorTags()->SetDetectorStatus(0, nstr);
339 tag->GetDetectorTags()->SetDetectorStatus(1, nstr);
342 tag->GetDetectorTags()->SetDetectorStatus(2, nstr);
345 tag->GetDetectorTags()->SetDetectorStatus(5, nstr);
348 tag->GetDetectorTags()->SetDetectorStatus(3, nstr);
351 tag->GetDetectorTags()->SetDetectorStatus(4, nstr);
354 tag->GetDetectorTags()->SetDetectorStatus(13, nstr);
357 tag->GetDetectorTags()->SetDetectorStatus(14, nstr);
360 tag->GetDetectorTags()->SetDetectorStatus(15, nstr);
378 tag->GetLHCTag()->SetFillingScheme(nstr);
381 cout << "Setting Quality ]" << nstr << "[" << atoi(nstr) << endl;
382 if (strlen(nstr) == 0)
383 tag->SetRunQuality(0);
385 tag->SetRunQuality(atoi(nstr));
388 tag->SetMuonTriggers(atol(ntok));
391 tag->SetHMTriggers(atol(ntok));