]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/STEERBase/AliCounterCollection.h
New MFT analysis tools
[u/mrichter/AliRoot.git] / STEER / STEERBase / 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
27de2dfb 6/* $Id$ */
7
94ef1a28 8/// \ingroup PWG3muon
9/// \class AliCounterCollection
10/// \brief generic class to handle a collection of counters
11// Author: Philippe Pillot
12
13#include <TNamed.h>
14
15class TString;
16class TObjArray;
17class THnSparse;
18class THashList;
19class TArrayI;
20class TH1D;
21class TH2D;
22class TCollection;
23
24class AliCounterCollection : public TNamed {
25public:
26
27 AliCounterCollection(const char* name = "counters");
28 virtual ~AliCounterCollection();
29
30 virtual void Clear(Option_t* = "");
31
32 // Add a new rubric with the complete list of related key words separated by "/"
33 void AddRubric(TString name, TString listOfKeyWords);
34 // Add a new rubric containing at maximum maxNKeyWords key words
35 void AddRubric(TString name, Int_t maxNKeyWords);
36 // Initialize the internal counters from the added rubrics
d810835e 37 void Init(Bool_t weightedCounters = kFALSE);
94ef1a28 38
d649ab79 39 // return the list of key words for the given rubric
40 TString GetKeyWords(TString rubric) const;
41
94ef1a28 42 // Add "value" to the counter referenced by "externalKey"
43 void Count(TString externalKey, Int_t value = 1);
d810835e 44 void Count(TString externalKey, Double_t value);
45
46 // Get the overall statistics for the given selection (result is integrated over not specified rubrics)
5d8c0c8a 47 Double_t GetSum(TString selections = "", Bool_t* longCounters = 0x0);
0dc8b856 48 // Get counters of the rubric "rubric1" for the given "selection"
49 TH1D* Get(TString rubric1, TString selections);
50 // Get counters of the "rubric1" vs "rubric2" for the given "selection"
51 TH2D* Get(TString rubric1, TString rubric2, TString selections);
94ef1a28 52
7471ae1a 53 // Print every individual counters if opt=="" or call "Print(opt, "")".
94ef1a28 54 virtual void Print(const Option_t* opt = "") const;
55 // Print the full list of key words
56 void PrintKeyWords() const;
57 // Print value of selected counter
58 void PrintValue(TString selections);
59 // Print desired rubrics for the given selection
7471ae1a 60 void Print(TString rubrics, TString selections, Bool_t removeEmpty = kFALSE);
6f5626c7 61 // Print the overall statistics for the given selection (result is integrated over not specified rubrics)
62 void PrintSum(TString selections = "");
94ef1a28 63
64 /// Overload TObject::Draw(Option_t*): Call "Draw(TString rubric1=opt, TString selections="")"
65 virtual void Draw(Option_t* opt = "") {Draw(opt, "");}
66 // Draw counters of the rubric "rubric1" for the given "selection"
67 TH1D* Draw(TString rubric1, TString selections);
68 // Draw counters of the "rubric1" vs "rubric2" for the given "selection"
69 TH2D* Draw(TString rubric1, TString rubric2, TString selections);
70
71 // Add the given AliCounterCollections to this
72 void Add(const AliCounterCollection* counter);
73
74 // Merge this with a list of AliCounterCollections
75 Long64_t Merge(TCollection* list);
76
77 // Sort rubrics defined without a list of authorized key words or all rubrics if opt=="all"
78 void Sort(Option_t* opt = "", Bool_t asInt = kFALSE);
79 /// Sort only that rubric. If asInt=kTRUE, key words are ordered as interger instead of alphabetically
80 void SortRubric(TString rubric, Bool_t asInt = kFALSE);
81
82private:
83
84 /// Not implemented
85 AliCounterCollection(const AliCounterCollection& rhs);
86 /// Not implemented
87 AliCounterCollection& operator = (const AliCounterCollection& rhs);
88
6f5626c7 89 // return the number of labels in that rubric
90 Int_t GetNActiveBins(Int_t dim);
91 // return kTRUE if that rubric contains the keyWord "ANY"
92 Bool_t ContainsAny(Int_t dim);
93
94ef1a28 94 // Return the corresponding bins ordered by rubric or 0x0 if externalKey is not valid
95 const Int_t* FindBins(const TString& externalKey, Bool_t allocate, Int_t& nEmptySlots);
96 // Return the dimension corresponding to that rubric (or -1)
97 Int_t FindDim(const TString& rubricName) const;
98 // Return the bin number corresponding to that key word (or -1)
99 Int_t FindBin(Int_t dim, const TString& keyWord, Bool_t allocate);
100
6f5626c7 101 // Tag the selected keywords in each rubric (-1=subtract; 0=discard; 1=add)
102 Short_t** DecodeSelection(const TString& selections, const TObjArray& displayedRubrics);
103 // Tag the selected keywords (separated by ',') in that rubric (-1=subtract; 0=discard; 1=add)
104 Bool_t Select(Bool_t include, const TString& rubric, const TString& keywords, Bool_t displayed, Short_t* selectBins[]);
105
94ef1a28 106 // Make sure all strings appear only once in this list
107 void CleanListOfStrings(TObjArray* list);
108
d810835e 109 // Add "value" to the counter referenced by "externalKey"
110 void CountAsDouble(TString externalKey, Double_t value);
111
94ef1a28 112 // Print the content of 1D histogram as a list
5d8c0c8a 113 void PrintList(const TH1D* hist, Bool_t removeEmpty, Bool_t longCounters) const;
94ef1a28 114 // Print the content of 2D histogram as an array
5d8c0c8a 115 void PrintArray(const TH2D* hist, Bool_t removeEmpty, Bool_t longCounters) const;
94ef1a28 116 // Print the content of nD histogram as a list of arrays
5d8c0c8a 117 void PrintListOfArrays(const THnSparse* hist, Bool_t removeEmpty, Bool_t longCounters) const;
94ef1a28 118
119 // Return the number of characters of the longest label
120 Int_t GetMaxLabelSize(THashList* labels) const;
121
122 // Return desired "data" for the given "selection" stored in a new histogram or 0x0
5d8c0c8a 123 TObject* Projection(const TObjArray& data, const TString& selections, Bool_t& longCounters);
94ef1a28 124
125 // Consistency check of the two counter collections
126 Int_t* CheckConsistency(const AliCounterCollection* c);
127
128 // Sort labels (alphabetically or as integer) in each rubric flagged in "rubricsToSort"
129 void Sort(const Bool_t* rubricsToSort, Bool_t asInt);
5d8c0c8a 130 // Return a list (not owner) of labels sorted assuming they are integers
94ef1a28 131 THashList* SortAsInt(const THashList* labels);
132
5d8c0c8a 133 // Convert the given THnSparse to a THnSparseL (able to handle numbers >= 2^31)
134 void ConvertToTHnSparseL(THnSparse* &h);
135
94ef1a28 136private:
137
138 THashList* fRubrics; ///< list of rubrics with associated key words
139 TArrayI* fRubricsSize; ///< maximum number of key words in the corresponding rubric
140 THnSparse* fCounters; ///< histogram of nRubrics dimensions used as n-dimensional counter
d810835e 141 Bool_t fWeightedCounters; ///< use THnSparseF instead of THnSparseI
5d8c0c8a 142 Bool_t fLongCounters; ///< use THnSparseL instead of THnSparseI
94ef1a28 143
5d8c0c8a 144 ClassDef(AliCounterCollection, 3); // collection of mergeable counters
94ef1a28 145};
146
147#endif
148