--- /dev/null
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * *
+ * Author: The ALICE Off-line Project. *
+ * Contributors are mentioned in the code where appropriate. *
+ * *
+ * Permission to use, copy, modify and distribute this software and its *
+ * documentation strictly for non-commercial purposes is hereby granted *
+ * without fee, provided that the above copyright notice appears in all *
+ * copies and that both the copyright notice and this permission notice *
+ * appear in the supporting documentation. The authors make no claims *
+ * about the suitability of this software for any purpose. It is *
+ * provided "as is" without express or implied warranty. *
+ **************************************************************************/
+
+/* $Id$ */
+// Author: Andrei Gheata, 20/12/2010
+
+//==============================================================================
+// AliAnalysisStatistics - basic class for storing statistics for the processed
+// events. The object is mergeable and can be used for general purpose. In case
+// a AliAnalysisTaskStat is used, this will set the global statistics object
+// to the analysis manager and will update it for the accepted events.
+//==============================================================================
+
+#include "AliAnalysisStatistics.h"
+
+#include "Riostream.h"
+#include "TCollection.h"
+
+ClassImp(AliAnalysisStatistics)
+
+//______________________________________________________________________________
+AliAnalysisStatistics::AliAnalysisStatistics(const AliAnalysisStatistics &other)
+ :TNamed(other),
+ fNinput(other.fNinput),
+ fNprocessed(other.fNprocessed),
+ fNfailed(other.fNfailed),
+ fNaccepted(other.fNaccepted)
+{
+// Copy constructor.
+}
+
+//______________________________________________________________________________
+AliAnalysisStatistics &AliAnalysisStatistics::operator=(const AliAnalysisStatistics &other)
+{
+// Assignment.
+ if (&other == this) return *this;
+ fNinput = other.fNinput;
+ fNprocessed = other.fNprocessed;
+ fNfailed = other.fNfailed;
+ fNaccepted = other.fNaccepted;
+ return *this;
+}
+
+//______________________________________________________________________________
+Long64_t AliAnalysisStatistics::Merge(TCollection* list)
+{
+// Merge statistics objets from list on top of this.
+ TIter next(list);
+ AliAnalysisStatistics *current;
+ Long64_t count = 1;
+ while ((current = (AliAnalysisStatistics*)next())) {
+ fNinput += current->GetNinput();
+ fNprocessed += current->GetNprocessed();
+ fNfailed += current->GetNfailed();
+ fNaccepted += current->GetNaccepted();
+ current++;
+ }
+ return count;
+}
+
+//______________________________________________________________________________
+void AliAnalysisStatistics::Print(const Option_t *) const
+{
+// Print info about the processed statistics.
+ cout << "### Input events : " << fNinput << endl;
+ cout << "### Processed events w/o errors : " << fNprocessed << endl;
+ cout << "### Failed events : " << fNfailed << endl;
+ cout << "### Accepted events : " << fNaccepted << endl;
+}
--- /dev/null
+#ifndef ALIANALYSISSTATISTICS_H
+#define ALIANALYSISSTATISTICS_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice */
+
+/* $Id$ */
+// Author: Andrei Gheata, 20/12/2010
+
+//==============================================================================
+// AliAnalysisStatistics - Class holding statistics information regarding the
+// number of events processed, failed and accepted.
+//==============================================================================
+
+#ifndef ROOT_TNamed
+#include "TNamed.h"
+#endif
+
+class TCollection;
+
+class AliAnalysisStatistics : public TNamed {
+
+protected:
+ Long64_t fNinput; // Total number of input events
+ Long64_t fNprocessed; // Number of events processed
+ Long64_t fNfailed; // Number of events for which reading failed
+ Long64_t fNaccepted; // Number of events that passed filtering criteria
+
+public:
+ AliAnalysisStatistics() : TNamed(),fNinput(0),fNprocessed(0),fNfailed(0),fNaccepted(0) {}
+ AliAnalysisStatistics(const char *name) : TNamed(name,""),fNinput(0),fNprocessed(0),fNfailed(0),fNaccepted(0) {}
+ AliAnalysisStatistics(const AliAnalysisStatistics &other);
+ virtual ~AliAnalysisStatistics() {}
+
+ AliAnalysisStatistics& operator=(const AliAnalysisStatistics &other);
+ // Update methods
+ void AddInput(Int_t nevents=1) {fNinput += nevents;}
+ void AddProcessed(Int_t nevents=1) {fNprocessed += nevents;}
+ void AddFailed(Int_t nevents=1) {fNfailed += nevents;}
+ void AddAccepted(Int_t nevents=1) {fNaccepted += nevents;}
+ // Getters
+ Long64_t GetNinput() const {return fNinput;}
+ Long64_t GetNprocessed() const {return fNprocessed;}
+ Long64_t GetNfailed() const {return fNfailed;}
+ Long64_t GetNaccepted() const {return fNaccepted;}
+
+ virtual Long64_t Merge(TCollection* list);
+ virtual void Print(const Option_t *option) const;
+
+ ClassDef(AliAnalysisStatistics,1) // Class holding the processed events statistics
+};
+#endif