Adding a reminder for coders
[u/mrichter/AliRoot.git] / ANALYSIS / AliAnalysisStatistics.cxx
CommitLineData
f091ecb5 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16/* $Id$ */
17// Author: Andrei Gheata, 20/12/2010
18
19//==============================================================================
20// AliAnalysisStatistics - basic class for storing statistics for the processed
21// events. The object is mergeable and can be used for general purpose. In case
22// a AliAnalysisTaskStat is used, this will set the global statistics object
23// to the analysis manager and will update it for the accepted events.
24//==============================================================================
25
26#include "AliAnalysisStatistics.h"
27
28#include "Riostream.h"
29#include "TCollection.h"
30
c3732d79 31#include "AliVEvent.h"
32
f091ecb5 33ClassImp(AliAnalysisStatistics)
34
35//______________________________________________________________________________
36AliAnalysisStatistics::AliAnalysisStatistics(const AliAnalysisStatistics &other)
37 :TNamed(other),
38 fNinput(other.fNinput),
39 fNprocessed(other.fNprocessed),
40 fNfailed(other.fNfailed),
c3732d79 41 fNaccepted(other.fNaccepted),
42 fOfflineMask(other.fOfflineMask)
f091ecb5 43{
44// Copy constructor.
45}
46
47//______________________________________________________________________________
48AliAnalysisStatistics &AliAnalysisStatistics::operator=(const AliAnalysisStatistics &other)
49{
50// Assignment.
51 if (&other == this) return *this;
52 fNinput = other.fNinput;
53 fNprocessed = other.fNprocessed;
54 fNfailed = other.fNfailed;
55 fNaccepted = other.fNaccepted;
c3732d79 56 fOfflineMask = other.fOfflineMask;
f091ecb5 57 return *this;
58}
59
60//______________________________________________________________________________
61Long64_t AliAnalysisStatistics::Merge(TCollection* list)
62{
63// Merge statistics objets from list on top of this.
64 TIter next(list);
65 AliAnalysisStatistics *current;
66 Long64_t count = 1;
67 while ((current = (AliAnalysisStatistics*)next())) {
68 fNinput += current->GetNinput();
69 fNprocessed += current->GetNprocessed();
70 fNfailed += current->GetNfailed();
71 fNaccepted += current->GetNaccepted();
72 current++;
73 }
74 return count;
75}
76
77//______________________________________________________________________________
78void AliAnalysisStatistics::Print(const Option_t *) const
79{
80// Print info about the processed statistics.
81 cout << "### Input events : " << fNinput << endl;
82 cout << "### Processed events w/o errors : " << fNprocessed << endl;
83 cout << "### Failed events : " << fNfailed << endl;
c3732d79 84 cout << "### Accepted events for mask: " << GetMaskAsString(fOfflineMask) << ": " << fNaccepted << endl;
85}
86
87//______________________________________________________________________________
88const char *AliAnalysisStatistics::GetMaskAsString(UInt_t mask)
89{
90// Returns a string corresponding to the offline mask.
91 static TString smask;
92 smask = "ALL EVT.";
93 if (!mask) return smask.Data();
94 smask.Clear();
95 if (mask & AliVEvent::kMB) smask = "MB";
96 if (mask & AliVEvent::kMUON) {
97 if (!smask.IsNull()) smask += " | ";
98 smask += "MUON";
99 }
100 if (mask & AliVEvent::kHighMult) {
101 if (!smask.IsNull()) smask += " | ";
102 smask += "HighMult";
103 }
104 if (mask & AliVEvent::kUserDefined) {
105 if (!smask.IsNull()) smask += " | ";
106 smask += "UserDefined";
107 }
108 if (mask == AliVEvent::kAny) smask = "ANY";
109 return smask.Data();
f091ecb5 110}
c3732d79 111