added SelectCollisionCandidates J. Otwinowski
[u/mrichter/AliRoot.git] / PWG3 / muon / AliCounterCollection.h
CommitLineData
94ef1a28 1#ifndef ALICOUNTERCOLLECTION_H
2#define ALICOUNTERCOLLECTION_H
3/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * See cxx source for full Copyright notice */
5
6/// \ingroup PWG3muon
7/// \class AliCounterCollection
8/// \brief generic class to handle a collection of counters
9// Author: Philippe Pillot
10
11#include <TNamed.h>
12
13class TString;
14class TObjArray;
15class THnSparse;
16class THashList;
17class TArrayI;
18class TH1D;
19class TH2D;
20class TCollection;
21
22class AliCounterCollection : public TNamed {
23public:
24
25 AliCounterCollection(const char* name = "counters");
26 virtual ~AliCounterCollection();
27
28 virtual void Clear(Option_t* = "");
29
30 // Add a new rubric with the complete list of related key words separated by "/"
31 void AddRubric(TString name, TString listOfKeyWords);
32 // Add a new rubric containing at maximum maxNKeyWords key words
33 void AddRubric(TString name, Int_t maxNKeyWords);
34 // Initialize the internal counters from the added rubrics
35 void Init();
36
37 // Add "value" to the counter referenced by "externalKey"
38 void Count(TString externalKey, Int_t value = 1);
39
40 // Print every individual counters if opt=="", else call "Print(TString rubrics=opt, TString selections="")"
41 virtual void Print(const Option_t* opt = "") const;
42 // Print the full list of key words
43 void PrintKeyWords() const;
44 // Print value of selected counter
45 void PrintValue(TString selections);
46 // Print desired rubrics for the given selection
47 void Print(TString rubrics, TString selections);
48 // Print the overall statistics under the given rubric for the given selection
49 void PrintSum(TString rubric, TString selections = "");
50
51 /// Overload TObject::Draw(Option_t*): Call "Draw(TString rubric1=opt, TString selections="")"
52 virtual void Draw(Option_t* opt = "") {Draw(opt, "");}
53 // Draw counters of the rubric "rubric1" for the given "selection"
54 TH1D* Draw(TString rubric1, TString selections);
55 // Draw counters of the "rubric1" vs "rubric2" for the given "selection"
56 TH2D* Draw(TString rubric1, TString rubric2, TString selections);
57
58 // Add the given AliCounterCollections to this
59 void Add(const AliCounterCollection* counter);
60
61 // Merge this with a list of AliCounterCollections
62 Long64_t Merge(TCollection* list);
63
64 // Sort rubrics defined without a list of authorized key words or all rubrics if opt=="all"
65 void Sort(Option_t* opt = "", Bool_t asInt = kFALSE);
66 /// Sort only that rubric. If asInt=kTRUE, key words are ordered as interger instead of alphabetically
67 void SortRubric(TString rubric, Bool_t asInt = kFALSE);
68
69private:
70
71 /// Not implemented
72 AliCounterCollection(const AliCounterCollection& rhs);
73 /// Not implemented
74 AliCounterCollection& operator = (const AliCounterCollection& rhs);
75
76 // Return the corresponding bins ordered by rubric or 0x0 if externalKey is not valid
77 const Int_t* FindBins(const TString& externalKey, Bool_t allocate, Int_t& nEmptySlots);
78 // Return the dimension corresponding to that rubric (or -1)
79 Int_t FindDim(const TString& rubricName) const;
80 // Return the bin number corresponding to that key word (or -1)
81 Int_t FindBin(Int_t dim, const TString& keyWord, Bool_t allocate);
82
83 // Make sure all strings appear only once in this list
84 void CleanListOfStrings(TObjArray* list);
85
86 // Print the content of 1D histogram as a list
87 void PrintList(const TH1D* hist) const;
88 // Print the content of 2D histogram as an array
89 void PrintArray(const TH2D* hist) const;
90 // Print the content of nD histogram as a list of arrays
91 void PrintListOfArrays(const THnSparse* hist) const;
92
93 // Return the number of characters of the longest label
94 Int_t GetMaxLabelSize(THashList* labels) const;
95
96 // Return desired "data" for the given "selection" stored in a new histogram or 0x0
97 TObject* Projection(const TObjArray& data, const TString& selections);
98
99 // Consistency check of the two counter collections
100 Int_t* CheckConsistency(const AliCounterCollection* c);
101
102 // Sort labels (alphabetically or as integer) in each rubric flagged in "rubricsToSort"
103 void Sort(const Bool_t* rubricsToSort, Bool_t asInt);
104 /// Return a list (not owner) of labels sorted assuming they are integers
105 THashList* SortAsInt(const THashList* labels);
106
107private:
108
109 THashList* fRubrics; ///< list of rubrics with associated key words
110 TArrayI* fRubricsSize; ///< maximum number of key words in the corresponding rubric
111 THnSparse* fCounters; ///< histogram of nRubrics dimensions used as n-dimensional counter
112
113 ClassDef(AliCounterCollection, 1); // collection of mergeable counters
114};
115
116#endif
117