AliRoot Core  3dc7879 (3dc7879)
MCHBPEVOda.cxx
Go to the documentation of this file.
1 /*
2  MCH DA for online BP occupancy evolution
3 
4  Contact: Laurent Aphecetche <laurent.aphecetche@subatech.in2p3.fr>
5  Link:
6  Run Type: PHYSICS STANDALONE
7  DA Type: MON
8  Inputs files: mchbpevo.conf
9  Number of events needed: all (or at least as much as possible...)
10  Reference Run: 233721
11  Link: 15000233721019.1104.root
12  Output Files: mchbpevo.root, to be exported to the DAQ FXS
13  Trigger types used: PHYSICS_EVENT
14  */
15 
16 /**************************************************************************
17  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
18  * *
19  * Author: The ALICE Off-line Project. *
20  * Contributors are mentioned in the code where appropriate. *
21  * *
22  * Permission to use, copy, modify and distribute this software and its *
23  * documentation strictly for non-commercial purposes is hereby granted *
24  * without fee, provided that the above copyright notice appears in all *
25  * copies and that both the copyright notice and this permission notice *
26  * appear in the supporting documentation. The authors make no claims *
27  * about the suitability of this software for any purpose. It is *
28  * provided "as is" without express or implied warranty. *
29  **************************************************************************/
30 
49 
50 #include "AliDAQ.h"
51 #include "AliMergeableCollection.h"
52 #include "AliMpConstants.h"
55 #include "AliRawEventHeaderBase.h"
56 #include "AliRawReaderDate.h"
57 #include "daqDA.h"
58 #include "event.h"
59 #include "monitor.h"
60 #include "Riostream.h"
61 #include "signal.h"
62 #include "TDatime.h"
63 #include "TEnv.h"
64 #include "TFile.h"
65 #include "TH1.h"
66 #include "TMath.h"
67 #include "TObjString.h"
68 #include "TPluginManager.h"
69 #include "TROOT.h"
70 #include "TStopwatch.h"
71 #include "TString.h"
72 #include "TTimeStamp.h"
73 
74 const char* OUTPUT_FILE = "mchbpevo.root";
75 const char* DAVERSION = "MCHPBEVOda v0.2 ($Id$)";
76 const char* CONFIG_FILE = "mchbpevo.conf";
77 int DEFAULT_MAX_DURATION = 5*60*60; // 5 hours, in seconds
78 int DEFAULT_TIME_RESOLUTION = 60; // seconds
79 int DEFAULT_NOF_EVENTS_REQUIRED_FOR_DECISION = 10000; // ten thousand events needed before any decision can be taken
80 float DEFAULT_OCCUPANCY_THRESHOLD = 0.30; // by default a bus patch with more than 30% occupancy for the last 1000 is declared suspicious ;-)
81 
82 //_________________________________________________________________________________________________
83 Int_t AssertHistogramsRange(AliMergeableCollection& hc, Int_t timeFromRef,
84  const std::vector<int>& timeResolutions,
85  const std::map<int,int>& busPatches)
86 {
90 
91  assert(timeResolutions.size()>=1);
92  assert(busPatches.size()==888);
93 
94  TH1* htest = hc.Histo(Form("/BUSPATCH/HITS/%ds/BP%04d",timeResolutions[0],1));
95 
96  assert(htest!=0x0);
97 
98  TAxis* axis = htest->GetXaxis();
99 
100  Int_t expansionTime(0);
101 
102  if ( timeFromRef < axis->GetXmin() )
103  {
104  expansionTime = timeFromRef - axis->GetXmin();
105  }
106 
107  if ( timeFromRef > axis->GetXmax() )
108  {
109  expansionTime = timeFromRef - axis->GetXmax();
110  }
111 
112  if ( TMath::Abs(expansionTime) < timeResolutions[0] )
113  {
114  // current binning is OK. Nothing to do.
115  return 0;
116  }
117 
118  if ( TMath::Abs(expansionTime) > 12*3600 )
119  {
120  std::cout << DAVERSION << " ERROR : Time range expansion bigger than 12 hours. Not doing it." << std::endl;
121  return 0;
122  }
123 
124  Int_t currentDuration = TMath::Nint(axis->GetXmax()-axis->GetXmin());
125 
126  std::cout << Form("%s INFO : I will expand my time range by %10d s (current duration %10d s, new one %10d s)",
127  DAVERSION,expansionTime,currentDuration,currentDuration+TMath::Abs(expansionTime))<< std::endl;
128 
129  // increase the time range by expansionTime, for all histograms
130 
131  for ( std::vector<int>::size_type itr = 0; itr < timeResolutions.size(); ++itr )
132  {
133  int timeReso = timeResolutions[itr];
134 
135  std::map<int,int>::const_iterator it;
136 
137  for ( it = busPatches.begin(); it != busPatches.end(); ++it )
138  {
139  int busPatchId = it->first;
140 
141  TString path;
142 
143  path.Form("/BUSPATCH/HITS/%ds/BP%04d",timeReso,busPatchId);
144 
145  TH1* h = hc.Histo(path.Data());
146 
147  assert(h!=0x0);
148 
149  TH1* hnew = AliMUONBusPatchEvolution::ExpandTimeAxis(*h, expansionTime, timeReso);
150 
151  hc.Remove(path.Data());
152 
153  hc.Adopt(hc.GetIdentifier(path),hnew);
154  }
155  }
156 
157 
158  if ( expansionTime < 0 )
159  {
160  TTimeStamp origin;
161 
162  htest = hc.Histo(Form("/BUSPATCH/HITS/%ds/BP%04d",timeResolutions[0],1));
163 
165 
166  std::cout << DAVERSION << " INFO : New refTime = " << origin.AsString() << std::endl;
167  }
168 
169  return 1;
170 }
171 
172 //_________________________________________________________________________________________________
173 void FillBusPatchesMap(std::map<int,int>& buspatches)
174 {
186  buspatches[1236]=992;
187  buspatches[1]=1272;
188  buspatches[1237]=1184;
189  buspatches[2]=1336;
190  buspatches[3]=1528;
191  buspatches[4]=1656;
192  buspatches[5]=1592;
193  buspatches[6]=1528;
194  buspatches[7]=1528;
195  buspatches[8]=1152;
196  buspatches[9]=808;
197  buspatches[10]=704;
198  buspatches[11]=512;
199  buspatches[13]=1280;
200  buspatches[12]=664;
201  buspatches[14]=1344;
202  buspatches[15]=1536;
203  buspatches[16]=1664;
204  buspatches[17]=1664;
205  buspatches[18]=1536;
206  buspatches[19]=1536;
207  buspatches[20]=1152;
208  buspatches[21]=800;
209  buspatches[22]=624;
210  buspatches[23]=512;
211  buspatches[24]=744;
212  buspatches[25]=1272;
213  buspatches[26]=1336;
214  buspatches[27]=1528;
215  buspatches[28]=1656;
216  buspatches[29]=1592;
217  buspatches[30]=1528;
218  buspatches[31]=1528;
219  buspatches[32]=1152;
220  buspatches[33]=808;
221  buspatches[34]=704;
222  buspatches[35]=512;
223  buspatches[37]=1280;
224  buspatches[36]=664;
225  buspatches[38]=1344;
226  buspatches[39]=1536;
227  buspatches[40]=1664;
228  buspatches[41]=1664;
229  buspatches[42]=1536;
230  buspatches[43]=1536;
231  buspatches[44]=1152;
232  buspatches[45]=800;
233  buspatches[46]=624;
234  buspatches[47]=512;
235  buspatches[48]=744;
236  buspatches[1238]=1024;
237  buspatches[1239]=576;
238  buspatches[1240]=992;
239  buspatches[1241]=1184;
240  buspatches[1242]=512;
241  buspatches[1243]=720;
242  buspatches[1244]=912;
243  buspatches[1245]=480;
244  buspatches[1246]=608;
245  buspatches[1301]=480;
246  buspatches[1303]=720;
247  buspatches[1302]=608;
248  buspatches[1305]=576;
249  buspatches[1304]=912;
250  buspatches[1306]=992;
251  buspatches[1307]=1184;
252  buspatches[1309]=1152;
253  buspatches[1308]=512;
254  buspatches[1310]=992;
255  buspatches[1311]=1184;
256  buspatches[1313]=2176;
257  buspatches[1312]=1024;
258  buspatches[1314]=1264;
259  buspatches[1315]=1456;
260  buspatches[1317]=1664;
261  buspatches[1316]=2176;
262  buspatches[1318]=1184;
263  buspatches[1319]=992;
264  buspatches[1320]=2304;
265  buspatches[1321]=832;
266  buspatches[1322]=1664;
267  buspatches[1323]=992;
268  buspatches[1324]=1184;
269  buspatches[1325]=1600;
270  buspatches[1326]=1664;
271  buspatches[1327]=1184;
272  buspatches[1328]=992;
273  buspatches[1329]=2304;
274  buspatches[1331]=2176;
275  buspatches[1330]=832;
276  buspatches[1332]=1264;
277  buspatches[1333]=1456;
278  buspatches[1335]=1152;
279  buspatches[1334]=2176;
280  buspatches[1336]=992;
281  buspatches[101]=1272;
282  buspatches[1339]=576;
283  buspatches[102]=1336;
284  buspatches[103]=1528;
285  buspatches[104]=1656;
286  buspatches[105]=1592;
287  buspatches[106]=1528;
288  buspatches[107]=1528;
289  buspatches[108]=1152;
290  buspatches[109]=808;
291  buspatches[110]=704;
292  buspatches[111]=512;
293  buspatches[113]=1280;
294  buspatches[112]=664;
295  buspatches[114]=1344;
296  buspatches[115]=1536;
297  buspatches[116]=1664;
298  buspatches[117]=1664;
299  buspatches[118]=1536;
300  buspatches[119]=1536;
301  buspatches[120]=1152;
302  buspatches[121]=800;
303  buspatches[122]=624;
304  buspatches[123]=512;
305  buspatches[124]=744;
306  buspatches[125]=1272;
307  buspatches[126]=1336;
308  buspatches[127]=1528;
309  buspatches[128]=1656;
310  buspatches[129]=1592;
311  buspatches[130]=1528;
312  buspatches[131]=1528;
313  buspatches[132]=1152;
314  buspatches[133]=808;
315  buspatches[134]=704;
316  buspatches[135]=512;
317  buspatches[137]=1280;
318  buspatches[136]=664;
319  buspatches[138]=1344;
320  buspatches[139]=1536;
321  buspatches[140]=1664;
322  buspatches[141]=1664;
323  buspatches[142]=1536;
324  buspatches[143]=1536;
325  buspatches[144]=1152;
326  buspatches[145]=800;
327  buspatches[146]=624;
328  buspatches[147]=512;
329  buspatches[148]=744;
330  buspatches[1345]=480;
331  buspatches[1346]=608;
332  buspatches[1343]=720;
333  buspatches[1344]=912;
334  buspatches[1340]=992;
335  buspatches[1341]=1184;
336  buspatches[1342]=512;
337  buspatches[1337]=1184;
338  buspatches[1338]=1024;
339  buspatches[1401]=480;
340  buspatches[1402]=608;
341  buspatches[1403]=720;
342  buspatches[1404]=912;
343  buspatches[1405]=576;
344  buspatches[1406]=992;
345  buspatches[1407]=1184;
346  buspatches[1408]=512;
347  buspatches[1409]=1152;
348  buspatches[1410]=992;
349  buspatches[1411]=1184;
350  buspatches[1412]=1024;
351  buspatches[1413]=2176;
352  buspatches[1414]=1264;
353  buspatches[1415]=1456;
354  buspatches[1416]=2176;
355  buspatches[1417]=1664;
356  buspatches[1418]=1184;
357  buspatches[1419]=992;
358  buspatches[1420]=2304;
359  buspatches[1421]=832;
360  buspatches[1422]=1664;
361  buspatches[1423]=992;
362  buspatches[1424]=1184;
363  buspatches[1425]=1600;
364  buspatches[1426]=1664;
365  buspatches[1427]=1184;
366  buspatches[1428]=992;
367  buspatches[1429]=2304;
368  buspatches[1430]=832;
369  buspatches[1431]=2176;
370  buspatches[1432]=1264;
371  buspatches[1433]=1456;
372  buspatches[1434]=2176;
373  buspatches[1435]=1152;
374  buspatches[1436]=992;
375  buspatches[201]=1272;
376  buspatches[1437]=1184;
377  buspatches[202]=1336;
378  buspatches[203]=1528;
379  buspatches[204]=1656;
380  buspatches[205]=1592;
381  buspatches[206]=1528;
382  buspatches[207]=1528;
383  buspatches[208]=1152;
384  buspatches[209]=808;
385  buspatches[210]=704;
386  buspatches[211]=512;
387  buspatches[213]=1280;
388  buspatches[212]=664;
389  buspatches[214]=1344;
390  buspatches[215]=1536;
391  buspatches[216]=1664;
392  buspatches[217]=1664;
393  buspatches[218]=1536;
394  buspatches[219]=1536;
395  buspatches[220]=1152;
396  buspatches[221]=800;
397  buspatches[222]=624;
398  buspatches[223]=512;
399  buspatches[224]=744;
400  buspatches[225]=1272;
401  buspatches[226]=1336;
402  buspatches[227]=1528;
403  buspatches[228]=1656;
404  buspatches[229]=1592;
405  buspatches[230]=1528;
406  buspatches[231]=1528;
407  buspatches[232]=1152;
408  buspatches[233]=808;
409  buspatches[234]=704;
410  buspatches[235]=512;
411  buspatches[237]=1280;
412  buspatches[236]=664;
413  buspatches[238]=1344;
414  buspatches[239]=1536;
415  buspatches[240]=1664;
416  buspatches[241]=1664;
417  buspatches[242]=1536;
418  buspatches[243]=1536;
419  buspatches[244]=1152;
420  buspatches[245]=800;
421  buspatches[246]=624;
422  buspatches[247]=512;
423  buspatches[248]=744;
424  buspatches[1438]=1024;
425  buspatches[1439]=576;
426  buspatches[1440]=992;
427  buspatches[1441]=1184;
428  buspatches[1442]=512;
429  buspatches[1443]=720;
430  buspatches[1444]=912;
431  buspatches[1445]=480;
432  buspatches[1446]=608;
433  buspatches[1501]=480;
434  buspatches[1503]=720;
435  buspatches[1502]=608;
436  buspatches[1505]=576;
437  buspatches[1504]=912;
438  buspatches[1506]=992;
439  buspatches[1507]=1184;
440  buspatches[1509]=1152;
441  buspatches[1508]=512;
442  buspatches[1510]=992;
443  buspatches[1511]=1184;
444  buspatches[1513]=2176;
445  buspatches[1512]=1024;
446  buspatches[1514]=1264;
447  buspatches[1515]=1456;
448  buspatches[1517]=1664;
449  buspatches[1516]=2176;
450  buspatches[1518]=1184;
451  buspatches[1519]=992;
452  buspatches[1520]=2304;
453  buspatches[1521]=832;
454  buspatches[1522]=1664;
455  buspatches[1523]=992;
456  buspatches[1524]=1184;
457  buspatches[1525]=1600;
458  buspatches[1526]=1664;
459  buspatches[1527]=1184;
460  buspatches[1528]=992;
461  buspatches[1529]=2304;
462  buspatches[1531]=2176;
463  buspatches[1530]=832;
464  buspatches[1532]=1264;
465  buspatches[1533]=1456;
466  buspatches[1535]=1152;
467  buspatches[1534]=2176;
468  buspatches[1536]=992;
469  buspatches[301]=1272;
470  buspatches[1539]=576;
471  buspatches[302]=1336;
472  buspatches[303]=1528;
473  buspatches[304]=1656;
474  buspatches[305]=1592;
475  buspatches[306]=1528;
476  buspatches[307]=1528;
477  buspatches[308]=1152;
478  buspatches[309]=808;
479  buspatches[310]=704;
480  buspatches[311]=512;
481  buspatches[313]=1280;
482  buspatches[312]=664;
483  buspatches[314]=1344;
484  buspatches[315]=1536;
485  buspatches[316]=1664;
486  buspatches[317]=1664;
487  buspatches[318]=1536;
488  buspatches[319]=1536;
489  buspatches[320]=1152;
490  buspatches[321]=800;
491  buspatches[322]=624;
492  buspatches[323]=512;
493  buspatches[324]=744;
494  buspatches[325]=1272;
495  buspatches[326]=1336;
496  buspatches[327]=1528;
497  buspatches[328]=1656;
498  buspatches[329]=1592;
499  buspatches[330]=1528;
500  buspatches[331]=1528;
501  buspatches[332]=1152;
502  buspatches[333]=808;
503  buspatches[334]=704;
504  buspatches[335]=512;
505  buspatches[337]=1280;
506  buspatches[336]=664;
507  buspatches[338]=1344;
508  buspatches[339]=1536;
509  buspatches[340]=1664;
510  buspatches[341]=1664;
511  buspatches[342]=1536;
512  buspatches[343]=1536;
513  buspatches[344]=1152;
514  buspatches[345]=800;
515  buspatches[346]=624;
516  buspatches[347]=512;
517  buspatches[348]=744;
518  buspatches[1545]=480;
519  buspatches[1546]=608;
520  buspatches[1543]=720;
521  buspatches[1544]=912;
522  buspatches[1540]=992;
523  buspatches[1541]=1184;
524  buspatches[1542]=512;
525  buspatches[1537]=1184;
526  buspatches[1538]=1024;
527  buspatches[1601]=720;
528  buspatches[1602]=912;
529  buspatches[1603]=304;
530  buspatches[1604]=720;
531  buspatches[1605]=912;
532  buspatches[1606]=240;
533  buspatches[1607]=1152;
534  buspatches[1608]=720;
535  buspatches[1609]=912;
536  buspatches[1610]=1024;
537  buspatches[1611]=1728;
538  buspatches[1612]=720;
539  buspatches[1613]=912;
540  buspatches[1614]=1536;
541  buspatches[1615]=2752;
542  buspatches[1616]=992;
543  buspatches[1617]=1184;
544  buspatches[1618]=2688;
545  buspatches[1619]=1664;
546  buspatches[1620]=1184;
547  buspatches[1621]=992;
548  buspatches[1622]=2304;
549  buspatches[1623]=832;
550  buspatches[1624]=1664;
551  buspatches[1625]=992;
552  buspatches[1626]=1184;
553  buspatches[1627]=1600;
554  buspatches[1628]=1664;
555  buspatches[1629]=1184;
556  buspatches[1630]=992;
557  buspatches[1631]=2304;
558  buspatches[1632]=832;
559  buspatches[1633]=2752;
560  buspatches[1634]=992;
561  buspatches[1635]=1184;
562  buspatches[1636]=2688;
563  buspatches[401]=1196;
564  buspatches[1637]=1728;
565  buspatches[402]=1260;
566  buspatches[403]=1446;
567  buspatches[404]=1594;
568  buspatches[405]=1472;
569  buspatches[406]=1404;
570  buspatches[407]=1275;
571  buspatches[408]=938;
572  buspatches[409]=832;
573  buspatches[410]=799;
574  buspatches[411]=1145;
575  buspatches[413]=1200;
576  buspatches[412]=625;
577  buspatches[414]=1264;
578  buspatches[415]=1450;
579  buspatches[416]=1594;
580  buspatches[417]=1472;
581  buspatches[418]=1408;
582  buspatches[419]=1265;
583  buspatches[420]=935;
584  buspatches[421]=832;
585  buspatches[422]=736;
586  buspatches[423]=1247;
587  buspatches[424]=544;
588  buspatches[425]=1196;
589  buspatches[426]=1260;
590  buspatches[427]=1446;
591  buspatches[428]=1594;
592  buspatches[429]=1472;
593  buspatches[430]=1404;
594  buspatches[431]=1275;
595  buspatches[432]=938;
596  buspatches[433]=832;
597  buspatches[434]=799;
598  buspatches[435]=1145;
599  buspatches[437]=1200;
600  buspatches[436]=625;
601  buspatches[438]=1264;
602  buspatches[439]=1450;
603  buspatches[440]=1594;
604  buspatches[441]=1472;
605  buspatches[442]=1408;
606  buspatches[443]=1265;
607  buspatches[444]=935;
608  buspatches[445]=832;
609  buspatches[446]=736;
610  buspatches[447]=1247;
611  buspatches[448]=544;
612  buspatches[1638]=720;
613  buspatches[1639]=912;
614  buspatches[1640]=1536;
615  buspatches[1641]=1152;
616  buspatches[1642]=720;
617  buspatches[1643]=912;
618  buspatches[1644]=1024;
619  buspatches[1645]=304;
620  buspatches[1646]=720;
621  buspatches[1647]=912;
622  buspatches[1648]=240;
623  buspatches[1649]=720;
624  buspatches[1650]=912;
625  buspatches[1701]=720;
626  buspatches[1703]=304;
627  buspatches[1702]=912;
628  buspatches[1704]=720;
629  buspatches[1705]=912;
630  buspatches[1707]=1152;
631  buspatches[1706]=240;
632  buspatches[1708]=720;
633  buspatches[1709]=912;
634  buspatches[1711]=1728;
635  buspatches[1710]=1024;
636  buspatches[1712]=720;
637  buspatches[1713]=912;
638  buspatches[1715]=2752;
639  buspatches[1714]=1536;
640  buspatches[1716]=992;
641  buspatches[1717]=1184;
642  buspatches[1719]=1664;
643  buspatches[1718]=2688;
644  buspatches[1720]=1184;
645  buspatches[1721]=992;
646  buspatches[1722]=2304;
647  buspatches[1723]=832;
648  buspatches[1724]=1664;
649  buspatches[1725]=992;
650  buspatches[1726]=1184;
651  buspatches[1727]=1600;
652  buspatches[1728]=1664;
653  buspatches[1729]=1184;
654  buspatches[1730]=992;
655  buspatches[1731]=2304;
656  buspatches[1733]=2752;
657  buspatches[1732]=832;
658  buspatches[1734]=992;
659  buspatches[1735]=1184;
660  buspatches[1737]=1728;
661  buspatches[501]=1196;
662  buspatches[1738]=720;
663  buspatches[502]=1260;
664  buspatches[503]=1446;
665  buspatches[504]=1594;
666  buspatches[505]=1472;
667  buspatches[506]=1404;
668  buspatches[507]=1275;
669  buspatches[508]=938;
670  buspatches[509]=832;
671  buspatches[510]=799;
672  buspatches[511]=1145;
673  buspatches[513]=1200;
674  buspatches[512]=625;
675  buspatches[514]=1264;
676  buspatches[515]=1450;
677  buspatches[516]=1594;
678  buspatches[517]=1472;
679  buspatches[518]=1408;
680  buspatches[519]=1265;
681  buspatches[520]=935;
682  buspatches[521]=832;
683  buspatches[522]=736;
684  buspatches[523]=1247;
685  buspatches[524]=544;
686  buspatches[525]=1196;
687  buspatches[526]=1260;
688  buspatches[527]=1446;
689  buspatches[528]=1594;
690  buspatches[529]=1472;
691  buspatches[530]=1404;
692  buspatches[531]=1275;
693  buspatches[532]=938;
694  buspatches[533]=832;
695  buspatches[534]=799;
696  buspatches[535]=1145;
697  buspatches[537]=1200;
698  buspatches[536]=625;
699  buspatches[538]=1264;
700  buspatches[539]=1450;
701  buspatches[540]=1594;
702  buspatches[541]=1472;
703  buspatches[542]=1408;
704  buspatches[543]=1265;
705  buspatches[544]=935;
706  buspatches[545]=832;
707  buspatches[546]=736;
708  buspatches[547]=1247;
709  buspatches[548]=544;
710  buspatches[1749]=720;
711  buspatches[1750]=912;
712  buspatches[1745]=304;
713  buspatches[1746]=720;
714  buspatches[1747]=912;
715  buspatches[1748]=240;
716  buspatches[1741]=1152;
717  buspatches[1742]=720;
718  buspatches[1743]=912;
719  buspatches[1744]=1024;
720  buspatches[1739]=912;
721  buspatches[1740]=1536;
722  buspatches[1736]=2688;
723  buspatches[1801]=720;
724  buspatches[1802]=912;
725  buspatches[1803]=304;
726  buspatches[1804]=720;
727  buspatches[1805]=912;
728  buspatches[1806]=240;
729  buspatches[1807]=1152;
730  buspatches[1808]=720;
731  buspatches[1809]=912;
732  buspatches[1810]=1024;
733  buspatches[1811]=1728;
734  buspatches[1812]=720;
735  buspatches[1813]=912;
736  buspatches[1814]=1536;
737  buspatches[1815]=2752;
738  buspatches[1816]=992;
739  buspatches[1817]=1184;
740  buspatches[1818]=2688;
741  buspatches[1819]=1664;
742  buspatches[1820]=1184;
743  buspatches[1821]=992;
744  buspatches[1822]=2304;
745  buspatches[1823]=832;
746  buspatches[1824]=1664;
747  buspatches[1825]=992;
748  buspatches[1826]=1184;
749  buspatches[1827]=1600;
750  buspatches[1828]=1664;
751  buspatches[1829]=1184;
752  buspatches[1830]=992;
753  buspatches[1831]=2304;
754  buspatches[1832]=832;
755  buspatches[1833]=2752;
756  buspatches[1834]=992;
757  buspatches[1835]=1184;
758  buspatches[1836]=2688;
759  buspatches[601]=1196;
760  buspatches[1837]=1728;
761  buspatches[602]=1260;
762  buspatches[603]=1446;
763  buspatches[604]=1594;
764  buspatches[605]=1472;
765  buspatches[606]=1404;
766  buspatches[607]=1275;
767  buspatches[608]=938;
768  buspatches[609]=832;
769  buspatches[610]=799;
770  buspatches[611]=1145;
771  buspatches[613]=1200;
772  buspatches[612]=625;
773  buspatches[614]=1264;
774  buspatches[615]=1450;
775  buspatches[616]=1594;
776  buspatches[617]=1472;
777  buspatches[618]=1408;
778  buspatches[619]=1265;
779  buspatches[620]=935;
780  buspatches[621]=832;
781  buspatches[622]=736;
782  buspatches[623]=1247;
783  buspatches[624]=544;
784  buspatches[625]=1196;
785  buspatches[626]=1260;
786  buspatches[627]=1446;
787  buspatches[628]=1594;
788  buspatches[629]=1472;
789  buspatches[630]=1404;
790  buspatches[631]=1275;
791  buspatches[632]=938;
792  buspatches[633]=832;
793  buspatches[634]=799;
794  buspatches[635]=1145;
795  buspatches[637]=1200;
796  buspatches[636]=625;
797  buspatches[638]=1264;
798  buspatches[639]=1450;
799  buspatches[640]=1594;
800  buspatches[641]=1472;
801  buspatches[642]=1408;
802  buspatches[643]=1265;
803  buspatches[644]=935;
804  buspatches[645]=832;
805  buspatches[646]=736;
806  buspatches[647]=1247;
807  buspatches[648]=544;
808  buspatches[1838]=720;
809  buspatches[1839]=912;
810  buspatches[1840]=1536;
811  buspatches[1841]=1152;
812  buspatches[1842]=720;
813  buspatches[1843]=912;
814  buspatches[1844]=1024;
815  buspatches[1845]=304;
816  buspatches[1846]=720;
817  buspatches[1847]=912;
818  buspatches[1848]=240;
819  buspatches[1849]=720;
820  buspatches[1850]=912;
821  buspatches[1901]=720;
822  buspatches[1903]=304;
823  buspatches[1902]=912;
824  buspatches[1904]=720;
825  buspatches[1905]=912;
826  buspatches[1907]=1152;
827  buspatches[1906]=240;
828  buspatches[1908]=720;
829  buspatches[1909]=912;
830  buspatches[1911]=1728;
831  buspatches[1910]=1024;
832  buspatches[1912]=720;
833  buspatches[1913]=912;
834  buspatches[1915]=2752;
835  buspatches[1914]=1536;
836  buspatches[1916]=992;
837  buspatches[1917]=1184;
838  buspatches[1919]=1664;
839  buspatches[1918]=2688;
840  buspatches[1920]=1184;
841  buspatches[1921]=992;
842  buspatches[1922]=2304;
843  buspatches[1923]=832;
844  buspatches[1924]=1664;
845  buspatches[1925]=992;
846  buspatches[1926]=1184;
847  buspatches[1927]=1600;
848  buspatches[1928]=1664;
849  buspatches[1929]=1184;
850  buspatches[1930]=992;
851  buspatches[1931]=2304;
852  buspatches[1933]=2752;
853  buspatches[1932]=832;
854  buspatches[1934]=992;
855  buspatches[1935]=1184;
856  buspatches[1937]=1728;
857  buspatches[701]=1196;
858  buspatches[1938]=720;
859  buspatches[702]=1260;
860  buspatches[703]=1446;
861  buspatches[704]=1594;
862  buspatches[705]=1472;
863  buspatches[706]=1404;
864  buspatches[707]=1275;
865  buspatches[708]=938;
866  buspatches[709]=832;
867  buspatches[710]=799;
868  buspatches[711]=1145;
869  buspatches[713]=1200;
870  buspatches[712]=625;
871  buspatches[714]=1264;
872  buspatches[715]=1450;
873  buspatches[716]=1594;
874  buspatches[717]=1472;
875  buspatches[718]=1408;
876  buspatches[719]=1265;
877  buspatches[720]=935;
878  buspatches[721]=832;
879  buspatches[722]=736;
880  buspatches[723]=1247;
881  buspatches[724]=544;
882  buspatches[725]=1196;
883  buspatches[726]=1260;
884  buspatches[727]=1446;
885  buspatches[728]=1594;
886  buspatches[729]=1472;
887  buspatches[730]=1404;
888  buspatches[731]=1275;
889  buspatches[732]=938;
890  buspatches[733]=832;
891  buspatches[734]=799;
892  buspatches[735]=1145;
893  buspatches[737]=1200;
894  buspatches[736]=625;
895  buspatches[738]=1264;
896  buspatches[739]=1450;
897  buspatches[740]=1594;
898  buspatches[741]=1472;
899  buspatches[742]=1408;
900  buspatches[743]=1265;
901  buspatches[744]=935;
902  buspatches[745]=832;
903  buspatches[746]=736;
904  buspatches[747]=1247;
905  buspatches[748]=544;
906  buspatches[1949]=720;
907  buspatches[1950]=912;
908  buspatches[1945]=304;
909  buspatches[1946]=720;
910  buspatches[1947]=912;
911  buspatches[1948]=240;
912  buspatches[1941]=1152;
913  buspatches[1942]=720;
914  buspatches[1943]=912;
915  buspatches[1944]=1024;
916  buspatches[1939]=912;
917  buspatches[1940]=1536;
918  buspatches[1936]=2688;
919  buspatches[801]=1024;
920  buspatches[802]=1152;
921  buspatches[803]=1536;
922  buspatches[804]=1728;
923  buspatches[805]=1088;
924  buspatches[806]=1472;
925  buspatches[807]=1648;
926  buspatches[808]=1088;
927  buspatches[809]=448;
928  buspatches[810]=2160;
929  buspatches[811]=2048;
930  buspatches[812]=576;
931  buspatches[813]=832;
932  buspatches[814]=1408;
933  buspatches[815]=960;
934  buspatches[816]=1072;
935  buspatches[817]=1536;
936  buspatches[818]=1024;
937  buspatches[819]=1152;
938  buspatches[820]=1536;
939  buspatches[821]=1728;
940  buspatches[822]=1088;
941  buspatches[823]=1536;
942  buspatches[824]=1728;
943  buspatches[825]=1088;
944  buspatches[826]=448;
945  buspatches[827]=2240;
946  buspatches[828]=2112;
947  buspatches[829]=576;
948  buspatches[830]=832;
949  buspatches[901]=1024;
950  buspatches[903]=1536;
951  buspatches[902]=1152;
952  buspatches[905]=1088;
953  buspatches[904]=1728;
954  buspatches[906]=1472;
955  buspatches[907]=1648;
956  buspatches[909]=448;
957  buspatches[908]=1088;
958  buspatches[910]=2160;
959  buspatches[911]=2048;
960  buspatches[912]=576;
961  buspatches[913]=832;
962  buspatches[914]=1024;
963  buspatches[915]=1152;
964  buspatches[916]=1536;
965  buspatches[917]=1728;
966  buspatches[918]=1088;
967  buspatches[919]=1536;
968  buspatches[920]=1728;
969  buspatches[921]=1088;
970  buspatches[922]=448;
971  buspatches[923]=2240;
972  buspatches[924]=2112;
973  buspatches[925]=576;
974  buspatches[927]=1408;
975  buspatches[926]=832;
976  buspatches[928]=1024;
977  buspatches[929]=1152;
978  buspatches[930]=1536;
979  buspatches[1001]=448;
980  buspatches[1002]=2160;
981  buspatches[1003]=2048;
982  buspatches[1004]=576;
983  buspatches[1005]=832;
984  buspatches[1006]=1088;
985  buspatches[1007]=1472;
986  buspatches[1008]=1648;
987  buspatches[1009]=1088;
988  buspatches[1010]=1536;
989  buspatches[1011]=1728;
990  buspatches[1012]=1024;
991  buspatches[1013]=1152;
992  buspatches[1014]=1408;
993  buspatches[1015]=1024;
994  buspatches[1016]=1152;
995  buspatches[1017]=1536;
996  buspatches[1018]=448;
997  buspatches[1019]=2240;
998  buspatches[1020]=2112;
999  buspatches[1021]=576;
1000  buspatches[1022]=832;
1001  buspatches[1023]=1088;
1002  buspatches[1024]=1536;
1003  buspatches[1025]=1728;
1004  buspatches[1026]=1088;
1005  buspatches[1027]=1536;
1006  buspatches[1028]=1728;
1007  buspatches[1029]=1024;
1008  buspatches[1030]=1152;
1009  buspatches[1101]=1408;
1010  buspatches[1102]=960;
1011  buspatches[1103]=1072;
1012  buspatches[1104]=1536;
1013  buspatches[1105]=448;
1014  buspatches[1106]=2160;
1015  buspatches[1107]=2048;
1016  buspatches[1108]=576;
1017  buspatches[1109]=832;
1018  buspatches[1110]=1088;
1019  buspatches[1111]=1472;
1020  buspatches[1112]=1648;
1021  buspatches[1113]=1088;
1022  buspatches[1114]=1536;
1023  buspatches[1115]=1728;
1024  buspatches[1116]=1024;
1025  buspatches[1117]=1152;
1026  buspatches[1118]=448;
1027  buspatches[1119]=2240;
1028  buspatches[1120]=2112;
1029  buspatches[1121]=576;
1030  buspatches[1123]=1088;
1031  buspatches[1122]=832;
1032  buspatches[1124]=1536;
1033  buspatches[1125]=1728;
1034  buspatches[1127]=1536;
1035  buspatches[1126]=1088;
1036  buspatches[1129]=1024;
1037  buspatches[1128]=1728;
1038  buspatches[1130]=1152;
1039  buspatches[1201]=480;
1040  buspatches[1202]=608;
1041  buspatches[1203]=720;
1042  buspatches[1204]=912;
1043  buspatches[1205]=576;
1044  buspatches[1206]=992;
1045  buspatches[1207]=1184;
1046  buspatches[1208]=512;
1047  buspatches[1209]=1152;
1048  buspatches[1210]=992;
1049  buspatches[1211]=1184;
1050  buspatches[1212]=1024;
1051  buspatches[1213]=2176;
1052  buspatches[1214]=1264;
1053  buspatches[1215]=1456;
1054  buspatches[1216]=2176;
1055  buspatches[1217]=1664;
1056  buspatches[1218]=1184;
1057  buspatches[1219]=992;
1058  buspatches[1220]=2304;
1059  buspatches[1221]=832;
1060  buspatches[1222]=1664;
1061  buspatches[1223]=992;
1062  buspatches[1224]=1184;
1063  buspatches[1225]=1600;
1064  buspatches[1226]=1664;
1065  buspatches[1227]=1184;
1066  buspatches[1228]=992;
1067  buspatches[1229]=2304;
1068  buspatches[1230]=832;
1069  buspatches[1231]=2176;
1070  buspatches[1232]=1264;
1071  buspatches[1233]=1456;
1072  buspatches[1234]=2176;
1073  buspatches[1235]=1152;
1074 }
1075 
1076 //_________________________________________________________________________________________________
1077 void FillCollection(AliMergeableCollection& hc, UInt_t timeOrigin, int maxDuration, int timeResolution, const std::map<int,int>& buspatches)
1078 {
1081 
1082  assert(buspatches.size()==888);
1083 
1084  TTimeStamp origin(static_cast<time_t>(timeOrigin),0);
1085 
1086  std::cout << DAVERSION << " INFO : Using refTime = " << origin.AsString() << std::endl;
1087 
1088  Double_t xmin = 0;
1089  Double_t xmax = xmin + maxDuration*1.0;
1090 
1091  int nbins = TMath::Nint((xmax-xmin)/timeResolution);
1092 
1093  // basis for all plot = per buspatch
1094 
1095  std::map<int,int>::const_iterator it;
1096 
1097  for ( it = buspatches.begin(); it != buspatches.end(); ++it)
1098  {
1099  int busPatchId = it->first;
1100  int nofPads = it->second;
1101 
1102  TH1* h = new TH1F(Form("BP%04d",busPatchId),Form("Number of hits in %d s bins",timeResolution),nbins,xmin,xmax);
1103 
1104  h->GetXaxis()->SetTimeDisplay(1);
1105  h->GetXaxis()->SetTimeFormat("%d/%m/%y %H:%M");
1106  h->GetXaxis()->SetTimeOffset(timeOrigin,"gmt");
1107  hc.Adopt(Form("/BUSPATCH/HITS/%ds",timeResolution),h);
1108  }
1109 
1110  // number of events needed for normalization
1111 
1112  TH1* h = new TH1F(Form("Nevents%ds",timeResolution),Form("Number of events %d s bins",timeResolution),nbins,xmin,xmax);
1113 
1114  h->GetXaxis()->SetTimeDisplay(1);
1115  h->GetXaxis()->SetTimeFormat("%d/%m/%y %H:%M");
1116  h->GetXaxis()->SetTimeOffset(timeOrigin,"gmt");
1117 
1118  hc.Adopt("",h);
1119 }
1120 
1121 //______________________________________________________________________________
1123  const std::map<int,int>& buspatches,
1124  int timeResolution,
1125  int requiredEvents,
1126  float occupancyThreshold)
1127 {
1129 
1130  // find how many bins should be considered, by finding in the Nevents histogram
1131  // how many of the latest bins are required to get an integral >= requiredEvents
1132 
1133  AliMUONBusPatchEvolution bpevo(hc,buspatches);
1134 
1135  std::map<int,double> faultyBP;
1136 
1137  Bool_t ok = bpevo.GetFaultyBusPatches(timeResolution,requiredEvents,occupancyThreshold,faultyBP);
1138 
1139  if (!ok) return;
1140 
1141  std::map<int,double>::const_iterator it;
1142 
1143  if ( faultyBP.empty() ) return;
1144 
1145  std::cout << Form("%s WARNING : %3d bus patches above occupancy threshold (of %7.2f %%) : ",DAVERSION,(int)faultyBP.size(),occupancyThreshold*100.0);
1146 
1147  for ( it = faultyBP.begin(); it != faultyBP.end(); ++it )
1148  {
1149  int busPatchId = it->first;
1150  std::cout << Form("%4d ",busPatchId);
1151  }
1152 
1153  std::cout << std::endl;
1154  std::cout << Form("%s INFO : Faulty bus patches occupancies : ",DAVERSION);
1155 
1156 
1157  for ( it = faultyBP.begin(); it != faultyBP.end(); ++it )
1158  {
1159  int busPatchId = it->first;
1160  double busPatchOccupancy = it->second;
1161  std::cout << Form("%4d (%7.2f %%) ",busPatchId,busPatchOccupancy*100.0);
1162  }
1163 
1164  std::cout << std::endl;
1165 }
1166 
1167 //______________________________________________________________________________
1168 int main(int argc, char **argv)
1169 {
1171 
1172  signal(SIGSEGV,SIG_DFL); // to be able to get core dumps...
1173 
1174  TStopwatch timers;
1175  timers.Start(kTRUE);
1176 
1177  ios::sync_with_stdio();
1178 
1179  std::cout << "Running " << DAVERSION << std::endl;
1180 
1181  if ( argc != 2 )
1182  {
1183  std::cout << "Wrong number of arguments" << std::endl;
1184  std::cout << "Usage : " << argv[0] << " datasource" << std::endl;
1185  return -1;
1186  }
1187 
1188  TString dataSource=argv[1];
1189 
1190  UInt_t refTime = 0;
1191  TString outputFileName = OUTPUT_FILE;
1192 
1193  // needed for streamer application
1194  gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo",
1195  "*",
1196  "TStreamerInfo",
1197  "RIO",
1198  "TStreamerInfo()");
1199 
1200  Int_t numberOfEvents(0);
1201  Int_t numberOfPhysicsEvent(0);
1202  Int_t numberOfBadEvents(0);
1203  Int_t numberOfUsedEvents(0);
1204  Int_t numberOfIncompleteEvents(0);
1205  Int_t numberOfFlushedEvents(0);
1206  Int_t numberOfEventsWithMCH(0);
1207  Int_t numberOfEventsSinceLastDecision(0);
1208 
1209  UInt_t runNumber(0);
1210 
1211  std::vector<int> timeResolutions;
1212  std::map<int,int> busPatches;
1213  int maxDuration;
1214  int nofEventsRequiredForDecision;
1215  float occupancyThreshold;
1216 
1217  int status=daqDA_DB_getFile(CONFIG_FILE,CONFIG_FILE);
1218 
1219  if (status)
1220  {
1221  std::cout << DAVERSION << " WARNING: Could not get configuration file " << CONFIG_FILE
1222  << " from DAQ detector database. Will use (hopefully sensible) defaults" << std::endl;
1223 
1224  timeResolutions.push_back(DEFAULT_TIME_RESOLUTION);
1225  maxDuration = DEFAULT_MAX_DURATION;
1226  nofEventsRequiredForDecision = DEFAULT_NOF_EVENTS_REQUIRED_FOR_DECISION;
1227  occupancyThreshold = DEFAULT_OCCUPANCY_THRESHOLD;
1228  FillBusPatchesMap(busPatches);
1229  }
1230  else
1231  {
1232  TEnv env(CONFIG_FILE);
1233 
1234  occupancyThreshold = env.GetValue("occupancyThreshold",DEFAULT_OCCUPANCY_THRESHOLD);
1235  nofEventsRequiredForDecision = env.GetValue("nofEventsRequiredForDecision",DEFAULT_NOF_EVENTS_REQUIRED_FOR_DECISION);
1236 
1237  TString tr = env.GetValue("timeResolutions","");
1238  TObjArray* a = tr.Tokenize(" ");
1239  TObjString* s;
1240  TIter next(a);
1241  while ( ( s = static_cast<TObjString*>(next())))
1242  {
1243  if (s->String().Atoi())
1244  {
1245  timeResolutions.push_back(s->String().Atoi());
1246  }
1247  }
1248  delete a;
1249 
1250  if ( timeResolutions.size() == 0 )
1251  {
1252  std::cout << DAVERSION << " WARNING : Configuration file " << CONFIG_FILE << " contains an incorrect timeResolutions setting. "
1253  << " Using default of " << DEFAULT_TIME_RESOLUTION << " s instead"
1254  << std::endl;
1255  timeResolutions.push_back(DEFAULT_TIME_RESOLUTION);
1256  }
1257 
1258  maxDuration = env.GetValue("maxDuration",DEFAULT_MAX_DURATION);
1259 
1260  TString sbp = env.GetValue("bp","");
1261 
1262  TObjArray* b = sbp.Tokenize(" ");
1263  TIter nextBP(b);
1264 
1265  int total(0);
1266 
1267  while ( ( s = static_cast<TObjString*>(nextBP())))
1268  {
1269  TString bpinfo = s->String();
1270  int ix = bpinfo.Index(':');
1271  if (ix<=0) continue;
1272  int bpid = TString(bpinfo(0,ix)).Atoi();
1273  int npads = TString(bpinfo(ix+1,bpinfo.Length()-ix)).Atoi();
1274  total += npads;
1275  busPatches[bpid]=npads;
1276  }
1277 
1278  delete b;
1279 
1280  if (busPatches.size() != 888)
1281  {
1282  std::cout << DAVERSION << " ERROR : Configuration file is incorrect : wrong number of bus patches : "
1283  << " got " << busPatches.size() << " but expected 888. Cannot work like that." << std::endl;
1284  return -3;
1285  }
1286 
1287  if (busPatches.size() > 0 && total != 1064008)
1288  {
1289  std::cout << DAVERSION << " ERROR : Configuration file is incorrect : wrong total number of pads ! Got " << total
1290  << " but expected 1064008. Cannot work like that." << std::endl;
1291  return -2;
1292  }
1293 
1294  if ( busPatches.size() == 0 )
1295  {
1296  std::cout << DAVERSION << " WARNING : Configuration file " << CONFIG_FILE << " does not contain the list of buspath ids (and their "
1297  " corresponding number of pads). Using default values instead"
1298  << std::endl;
1299  FillBusPatchesMap(busPatches);
1300  }
1301  }
1302 
1304  std::sort(timeResolutions.begin(),timeResolutions.end());
1305 
1306  AliMergeableCollection* hc(0x0);
1307 
1308  AliRawReaderDate* rawReader(0x0);
1309 
1310  // define data source :
1311  status=monitorSetDataSource(dataSource.Data());
1312  if (status!=0)
1313  {
1314  std::cout << DAVERSION << " ERROR : monitorSetDataSource() failed: " << monitorDecodeError(status) << endl;
1315  return -1;
1316  }
1317 
1318  // Declare monitoring program
1319  status=monitorDeclareMp("MUON_TRK_BPEVO");
1320  if (status!=0)
1321  {
1322  std::cout << DAVERSION << " ERROR : monitorDeclareMp() failed: " << monitorDecodeError(status) << endl;
1323  return -1;
1324  }
1325 
1326  // Define wait event timeout - 1s max
1327  monitorSetNowait();
1328  monitorSetNoWaitNetworkTimeout(1000);
1329 
1330  int nofRealloc(0);
1331 
1332  for(;;)
1333  {
1334  struct eventHeaderStruct *event(0x0);
1335  eventTypeType eventT;
1336 
1337  status=monitorGetEventDynamic((void **)&event);
1338  if (status!=0)
1339  {
1340  std::cout << DAVERSION << " ERROR : " << monitorDecodeError(status) << std::endl;
1341  delete event;
1342  break;
1343  }
1344 
1345  /* check shutdown condition */
1346  if (daqDA_checkShutdown())
1347  {
1348  std::cout << DAVERSION << " WARNING : I am requested to stop, so I will stop..." << std::endl;
1349  delete event;
1350  break;
1351  }
1352 
1353  /* retry if got no event */
1354  if (event==NULL) continue;
1355 
1356  ++numberOfEvents;
1357 
1358  eventT=event->eventType;
1359 
1360  if ((eventT == END_OF_RUN)||(eventT == END_OF_RUN_FILES))
1361  {
1362  delete event;
1363  break;
1364  }
1365 
1366  if (eventT != PHYSICS_EVENT)
1367  {
1368  delete event;
1369  continue;
1370  }
1371 
1372  if( TEST_SYSTEM_ATTRIBUTE(event->eventTypeAttribute, ATTR_INCOMPLETE_EVENT))
1373  {
1374  delete event;
1375  ++numberOfIncompleteEvents;
1376  continue;
1377  }
1378 
1379  if( TEST_SYSTEM_ATTRIBUTE(event->eventTypeAttribute, ATTR_FLUSHED_EVENT))
1380  {
1381  delete event;
1382  ++numberOfFlushedEvents;
1383  continue;
1384  }
1385 
1386  ++numberOfPhysicsEvent;
1387 
1388  rawReader = new AliRawReaderDate((void*)event);
1389 
1390  if ( rawReader->GetRunNumber() != runNumber )
1391  {
1392  if ( runNumber != 0 )
1393  {
1394  std::cout << DAVERSION << " ERROR : Uh oh. That's bad... Changing of run number ???" << std::endl;
1395  delete event;
1396  delete rawReader;
1397  return -9999;
1398  }
1399 
1400  runNumber = rawReader->GetRunNumber();
1401  }
1402 
1403  // *without* using the MUONTRK event decoder, we update the number
1404  // of events where we have information about MUONTRK.
1405  // this should be what is called subevents in the logbook
1406  // we do *not* use the MCH decoder on purpose, to not mistakenly
1407  // believe there's no event if the data is corrupted (and thus the decoder
1408  // "sees" nothing).
1409 
1410  Bool_t mchThere(kFALSE);
1411 
1412  for ( int iDDL = 0; iDDL < AliDAQ::NumberOfDdls("MUONTRK") && !mchThere; ++iDDL )
1413  {
1414  rawReader->Reset();
1415  rawReader->Select("MUONTRK",iDDL,iDDL);
1416  if (rawReader->ReadHeader() )
1417  {
1418  if (rawReader->GetEquipmentSize() ) mchThere = kTRUE;
1419  }
1420  }
1421 
1422  if ( mchThere )
1423  {
1424  ++numberOfEventsWithMCH;
1425  }
1426  else
1427  {
1428  delete event;
1429  delete rawReader;
1430  continue;
1431  }
1432 
1433  rawReader->Reset();
1434 
1435  // now do our real work with the MCH decoder
1436 
1437  AliMUONRawStreamTrackerHP stream(rawReader);
1438 
1439  stream.DisableWarnings();
1440  stream.First();
1441 
1442  Int_t buspatchId;
1443  UShort_t manuId;
1444  UChar_t manuChannel;
1445  UShort_t adc;
1446 
1447  std::map<int,int> bpValues;
1448 
1449  while ( stream.Next(buspatchId,manuId,manuChannel,adc,kTRUE) )
1450  {
1451  bpValues[buspatchId]++;
1452  }
1453 
1454  if ( bpValues.empty() )
1455  {
1456  static int emptyevent(0);
1457 
1458  emptyevent++;
1459 
1460  std::cout << DAVERSION << " WARNING : Empty event" << emptyevent << std::endl;
1461  }
1462 
1463  Bool_t badEvent = stream.HasPaddingError() || stream.HasGlitchError();
1464 
1465  if ( !badEvent )
1466  {
1467  if (!hc)
1468  {
1469  hc = new AliMergeableCollection("bpevo");
1470 
1471  assert(refTime==0);
1472 
1473  refTime = rawReader->GetTimestamp();
1474 
1475  for ( std::vector<int>::size_type is = 0; is < timeResolutions.size(); ++is )
1476  {
1477  FillCollection(*hc, refTime,maxDuration,timeResolutions[is],busPatches);
1478  }
1479  }
1480  else
1481  {
1482  assert(refTime>0);
1483  nofRealloc += AssertHistogramsRange(*hc,rawReader->GetTimestamp()-refTime,timeResolutions,busPatches);
1484  }
1485 
1486  ++numberOfUsedEvents;
1487 
1488  ++numberOfEventsSinceLastDecision;
1489 
1490  if ( numberOfEventsSinceLastDecision > nofEventsRequiredForDecision )
1491  {
1492  ReportFaultyBusPatches(*hc,busPatches,timeResolutions[timeResolutions.size()-1],nofEventsRequiredForDecision,occupancyThreshold);
1493  numberOfEventsSinceLastDecision=0;
1494  }
1495 
1496  for ( std::map<int,int>::const_iterator it = bpValues.begin(); it != bpValues.end(); ++it )
1497  {
1498  const int& buspatchId = it->first;
1499  const int& bpvalue = it->second;
1500 
1501  TString bpName = Form("BP%04d",buspatchId);
1502 
1503  for ( std::vector<int>::size_type is = 0; is < timeResolutions.size(); ++is )
1504  {
1505  TString hname;
1506 
1507  hname.Form("/BUSPATCH/HITS/%ds/%s",timeResolutions[is],bpName.Data());
1508  TH1* h = hc->Histo(hname.Data());
1509 
1510  if (!h)
1511  {
1512  std::cout << DAVERSION << " ERROR : histogram " << hname.Data() << " not found" << std::endl;
1513  continue;
1514  }
1515 
1516  h->Fill(rawReader->GetTimestamp()-refTime,bpvalue);
1517  }
1518  }
1519 
1520  for ( std::vector<int>::size_type is = 0; is < timeResolutions.size(); ++is )
1521  {
1522  TString hname;
1523 
1524  hname.Form("Nevents%ds",timeResolutions[is]);
1525  TH1* h = hc->Histo(hname.Data());
1526 
1527  if (!h)
1528  {
1529  std::cout << DAVERSION << " ERROR : histogram " << hname.Data() << " not found" << std::endl;
1530  continue;
1531  }
1532 
1533  h->Fill(rawReader->GetTimestamp()-refTime);
1534  }
1535 
1536  }
1537  else
1538  {
1539  ++numberOfBadEvents;
1540  }
1541 
1542  delete event;
1543 
1544  delete rawReader;
1545  }
1546 
1547 
1548  std::cout << DAVERSION << Form(" INFO : %12d events processed : %12d physics %d used ones %d bad ones [ %d with MCH information ] [ %d incomplet %d flushed ]",
1549  numberOfEvents,numberOfPhysicsEvent,numberOfUsedEvents,numberOfBadEvents,numberOfEventsWithMCH,
1550  numberOfIncompleteEvents,numberOfFlushedEvents) << std::endl;
1551 
1552  std::cout << DAVERSION << " INFO : Number of histogram re-allocation : " << nofRealloc << std::endl;
1553 
1554  if ( hc )
1555  {
1556  TFile* f = TFile::Open(outputFileName,"RECREATE");
1557  hc->Write();
1558  delete f;
1559  }
1560 
1561  /* store the result file on FXS */
1562  if (daqDA_FES_storeFile(outputFileName,"BPEVO")) return -9;
1563 
1564  timers.Stop();
1565 
1566  std::cout << DAVERSION << Form(" INFO : Execution time : R:%7.2fs C:%7.2fs\n", timers.RealTime(), timers.CpuTime()) << std::endl;
1567 
1568  return 0;
1569 }
A high performance stream decoder for muon tracking DDL streams.
TBrowser b
Definition: RunAnaESD.C:12
TFile * Open(const char *filename, Long64_t &nevents)
int main(int argc, char **argv)
#define TObjArray
void ReportFaultyBusPatches(AliMergeableCollection &hc, const std::map< int, int > &buspatches, int timeResolution, int requiredEvents, float occupancyThreshold)
const char * path
float DEFAULT_OCCUPANCY_THRESHOLD
Definition: MCHBPEVOda.cxx:80
TROOT * gROOT
int DEFAULT_NOF_EVENTS_REQUIRED_FOR_DECISION
Definition: MCHBPEVOda.cxx:79
TH1 * Histo(const char *fullIdentifier) const
int DEFAULT_TIME_RESOLUTION
Definition: MCHBPEVOda.cxx:78
void DisableWarnings()
Set warnings flag to disable warnings on data errors.
int DEFAULT_MAX_DURATION
Definition: MCHBPEVOda.cxx:77
virtual TObject * Remove(const char *fullIdentifier)
static TH1 * ExpandTimeAxis(const TH1 &h, Int_t expansionTime, Int_t timeResolution=-1)
Bool_t HasPaddingError() const
Whether we got padding errors or not.
Bool_t GetFaultyBusPatches(int timeResolution, int requiredEvents, float occupancyThreshold, std::map< int, double > &faultyBusPatchOccupancies)
void FillBusPatchesMap(std::map< int, int > &buspatches)
Definition: MCHBPEVOda.cxx:173
TF1 * f
Definition: interpolTest.C:21
const char * DAVERSION
Definition: MCHBPEVOda.cxx:75
Bool_t HasGlitchError() const
Whether we got glitch errors or not.
virtual void First()
Initialize iterator.
Int_t AssertHistogramsRange(AliMergeableCollection &hc, Int_t timeFromRef, const std::vector< int > &timeResolutions, const std::map< int, int > &busPatches)
Definition: MCHBPEVOda.cxx:83
TString GetIdentifier(const char *fullIdentifier) const
static Int_t runNumber
Definition: pdc06_config.C:126
void FillCollection(AliMergeableCollection &hc, UInt_t timeOrigin, int maxDuration, int timeResolution, const std::map< int, int > &buspatches)
Utility class to massage the output of the MCHBPEVO DA.
static Bool_t GetTimeOffset(const TH1 &h, TTimeStamp &origin)
const char * CONFIG_FILE
Definition: MCHBPEVOda.cxx:76
static Int_t NumberOfDdls(const char *detectorName)
Definition: AliDAQ.cxx:368
Declaration of the high performance decoder for muon trigger chamber raw streams. ...
const char * OUTPUT_FILE
Definition: MCHBPEVOda.cxx:74
virtual Bool_t Next(Int_t &busPatchId, UShort_t &manuId, UChar_t &manuChannel, UShort_t &adc)
Advance one step in the iteration. Returns false if finished.