Minor fix for software triggers.
[u/mrichter/AliRoot.git] / PWG3 / base / 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
d649ab79 37 // return the list of key words for the given rubric
38 TString GetKeyWords(TString rubric) const;
39
94ef1a28 40 // Add "value" to the counter referenced by "externalKey"
41 void Count(TString externalKey, Int_t value = 1);
42
43 // Print every individual counters if opt=="", else call "Print(TString rubrics=opt, TString selections="")"
44 virtual void Print(const Option_t* opt = "") const;
45 // Print the full list of key words
46 void PrintKeyWords() const;
47 // Print value of selected counter
48 void PrintValue(TString selections);
49 // Print desired rubrics for the given selection
50 void Print(TString rubrics, TString selections);
6f5626c7 51 // Print the overall statistics for the given selection (result is integrated over not specified rubrics)
52 void PrintSum(TString selections = "");
94ef1a28 53
54 /// Overload TObject::Draw(Option_t*): Call "Draw(TString rubric1=opt, TString selections="")"
55 virtual void Draw(Option_t* opt = "") {Draw(opt, "");}
56 // Draw counters of the rubric "rubric1" for the given "selection"
57 TH1D* Draw(TString rubric1, TString selections);
58 // Draw counters of the "rubric1" vs "rubric2" for the given "selection"
59 TH2D* Draw(TString rubric1, TString rubric2, TString selections);
60
61 // Add the given AliCounterCollections to this
62 void Add(const AliCounterCollection* counter);
63
64 // Merge this with a list of AliCounterCollections
65 Long64_t Merge(TCollection* list);
66
67 // Sort rubrics defined without a list of authorized key words or all rubrics if opt=="all"
68 void Sort(Option_t* opt = "", Bool_t asInt = kFALSE);
69 /// Sort only that rubric. If asInt=kTRUE, key words are ordered as interger instead of alphabetically
70 void SortRubric(TString rubric, Bool_t asInt = kFALSE);
71
72private:
73
74 /// Not implemented
75 AliCounterCollection(const AliCounterCollection& rhs);
76 /// Not implemented
77 AliCounterCollection& operator = (const AliCounterCollection& rhs);
78
6f5626c7 79 // return the number of labels in that rubric
80 Int_t GetNActiveBins(Int_t dim);
81 // return kTRUE if that rubric contains the keyWord "ANY"
82 Bool_t ContainsAny(Int_t dim);
83
94ef1a28 84 // Return the corresponding bins ordered by rubric or 0x0 if externalKey is not valid
85 const Int_t* FindBins(const TString& externalKey, Bool_t allocate, Int_t& nEmptySlots);
86 // Return the dimension corresponding to that rubric (or -1)
87 Int_t FindDim(const TString& rubricName) const;
88 // Return the bin number corresponding to that key word (or -1)
89 Int_t FindBin(Int_t dim, const TString& keyWord, Bool_t allocate);
90
6f5626c7 91 // Tag the selected keywords in each rubric (-1=subtract; 0=discard; 1=add)
92 Short_t** DecodeSelection(const TString& selections, const TObjArray& displayedRubrics);
93 // Tag the selected keywords (separated by ',') in that rubric (-1=subtract; 0=discard; 1=add)
94 Bool_t Select(Bool_t include, const TString& rubric, const TString& keywords, Bool_t displayed, Short_t* selectBins[]);
95
94ef1a28 96 // Make sure all strings appear only once in this list
97 void CleanListOfStrings(TObjArray* list);
98
99 // Print the content of 1D histogram as a list
100 void PrintList(const TH1D* hist) const;
101 // Print the content of 2D histogram as an array
102 void PrintArray(const TH2D* hist) const;
103 // Print the content of nD histogram as a list of arrays
104 void PrintListOfArrays(const THnSparse* hist) const;
105
106 // Return the number of characters of the longest label
107 Int_t GetMaxLabelSize(THashList* labels) const;
108
109 // Return desired "data" for the given "selection" stored in a new histogram or 0x0
110 TObject* Projection(const TObjArray& data, const TString& selections);
111
112 // Consistency check of the two counter collections
113 Int_t* CheckConsistency(const AliCounterCollection* c);
114
115 // Sort labels (alphabetically or as integer) in each rubric flagged in "rubricsToSort"
116 void Sort(const Bool_t* rubricsToSort, Bool_t asInt);
117 /// Return a list (not owner) of labels sorted assuming they are integers
118 THashList* SortAsInt(const THashList* labels);
119
120private:
121
122 THashList* fRubrics; ///< list of rubrics with associated key words
123 TArrayI* fRubricsSize; ///< maximum number of key words in the corresponding rubric
124 THnSparse* fCounters; ///< histogram of nRubrics dimensions used as n-dimensional counter
125
126 ClassDef(AliCounterCollection, 1); // collection of mergeable counters
127};
128
129#endif
130