]>
Commit | Line | Data |
---|---|---|
5eb970a4 | 1 | // |
2 | // *** Class AliRsnVATProcessInfo *** | |
3 | // | |
32992791 | 4 | // Virtual class which makes computations at the event level, |
5 | // in order to return a list of histograms useful to have a look | |
6 | // of the characteristics of used events. | |
7 | // If can be inherited and customized for the needs of the analysis. | |
5eb970a4 | 8 | // |
9 | // authors: A. Pulvirenti (email: alberto.pulvirenti@ct.infn.it) | |
10 | // M. Vala (email: martin.vala@cern.ch) | |
11 | // | |
12 | ||
13 | #include <TList.h> | |
14 | #include <TH1.h> | |
15 | ||
16 | #include "AliLog.h" | |
17 | ||
968abd78 | 18 | #include "AliRsnFunction.h" |
5eb970a4 | 19 | #include "AliRsnVATProcessInfo.h" |
20 | ||
21 | ClassImp(AliRsnVATProcessInfo) | |
22 | ||
32992791 | 23 | //______________________________________________________________________________ |
4fbb2459 | 24 | AliRsnVATProcessInfo::AliRsnVATProcessInfo(const char *name) : |
32992791 | 25 | TNamed(name,name), |
26 | fHistUsedEvents(0x0), | |
27 | fEventUsed(kFALSE), | |
968abd78 | 28 | fEventFunctions("AliRsnFunction", 0), |
32992791 | 29 | fPrintInfoNumber(1000) |
5eb970a4 | 30 | { |
4fbb2459 | 31 | // |
32 | // Constructor. | |
32992791 | 33 | // Does nothing more than initialization of data members. |
4fbb2459 | 34 | // |
35 | ||
32992791 | 36 | AliDebug(AliLog::kDebug+2, "Entering"); |
37 | AliDebug(AliLog::kDebug+2, "Exiting"); | |
5eb970a4 | 38 | } |
39 | ||
32992791 | 40 | //______________________________________________________________________________ |
4fbb2459 | 41 | AliRsnVATProcessInfo::AliRsnVATProcessInfo(const AliRsnVATProcessInfo& copy) : |
32992791 | 42 | TNamed(copy), |
43 | fHistUsedEvents(0x0), | |
44 | fEventUsed(copy.fEventUsed), | |
968abd78 | 45 | fEventFunctions(copy.fEventFunctions), |
32992791 | 46 | fPrintInfoNumber(copy.fPrintInfoNumber) |
5eb970a4 | 47 | { |
4fbb2459 | 48 | // |
49 | // Copy constructor. | |
32992791 | 50 | // Clones the histogram and copies the values of other data members |
4fbb2459 | 51 | // |
52 | ||
32992791 | 53 | AliDebug(AliLog::kDebug+2, "Entering"); |
54 | ||
55 | fHistUsedEvents = (TH1I*)copy.fHistUsedEvents->Clone(); | |
56 | ||
57 | AliDebug(AliLog::kDebug+2, "Exiting"); | |
5eb970a4 | 58 | } |
59 | ||
32992791 | 60 | //______________________________________________________________________________ |
61 | AliRsnVATProcessInfo& AliRsnVATProcessInfo::operator= | |
62 | (const AliRsnVATProcessInfo& copy) | |
5eb970a4 | 63 | { |
4fbb2459 | 64 | // |
32992791 | 65 | // Assignment operator. |
66 | // Clones the histogram and copies the values of other data members. | |
4fbb2459 | 67 | // |
68 | ||
32992791 | 69 | AliDebug(AliLog::kDebug+2, "Entering"); |
70 | ||
71 | fHistUsedEvents = (TH1I*)copy.fHistUsedEvents->Clone(); | |
72 | fEventUsed = copy.fEventUsed; | |
73 | fPrintInfoNumber = copy.fPrintInfoNumber; | |
968abd78 | 74 | fEventFunctions = copy.fEventFunctions; |
32992791 | 75 | |
76 | AliDebug(AliLog::kDebug+2, "Exiting"); | |
77 | ||
78 | return (*this); | |
5eb970a4 | 79 | } |
80 | ||
32992791 | 81 | //______________________________________________________________________________ |
82 | AliRsnVATProcessInfo::~AliRsnVATProcessInfo() | |
83 | { | |
84 | // | |
85 | // Destructor. | |
86 | // Does nothing, since the histogram it creates is usually owned | |
87 | // by another object (TList output of AnalysisTask's), but sets | |
88 | // the data member pointers to NULL. | |
89 | // | |
90 | ||
91 | AliDebug(AliLog::kDebug+2, "Entering"); | |
92 | ||
93 | fHistUsedEvents = 0x0; | |
94 | fEventUsed = 0; | |
95 | fPrintInfoNumber = 0; | |
96 | ||
97 | AliDebug(AliLog::kDebug+2, "Exiting"); | |
98 | } | |
99 | ||
100 | //______________________________________________________________________________ | |
4fbb2459 | 101 | void AliRsnVATProcessInfo::GenerateInfoList(TList *list) |
102 | { | |
103 | // | |
32992791 | 104 | // Allocate in memory the histograms created in this class and store them |
105 | // inside the TList object passed as argument, which usually belongs to | |
106 | // an AnalysisTask object, and represents one of its outputs. | |
107 | // If the histogram was already initialized, it is deleted and recreated. | |
4fbb2459 | 108 | // |
109 | ||
32992791 | 110 | AliDebug(AliLog::kDebug+2, "Entering"); |
5eb970a4 | 111 | |
32992791 | 112 | // delete existing allocation of stored objects |
113 | if (fHistUsedEvents) delete fHistUsedEvents; | |
114 | ||
115 | // create stored objects | |
28399a41 | 116 | fHistUsedEvents = new TH1I(GetEventHistogramName(), "Skipped/used events", 3, 0, 3); |
5eb970a4 | 117 | |
4fbb2459 | 118 | // ad objects to list |
119 | list->Add(fHistUsedEvents); | |
968abd78 | 120 | |
121 | // add all other functions | |
122 | Int_t i; | |
123 | TString hName(""); | |
124 | AliRsnFunction *fcn = 0; | |
125 | for (i = 0; i < fEventFunctions.GetEntries(); i++) | |
126 | { | |
127 | fcn = (AliRsnFunction*)fEventFunctions.At(i); | |
128 | hName += GetName(); | |
129 | hName += '_'; | |
130 | hName += fcn->GetName(); | |
131 | if (fcn->IsUsingTH1()) list->Add(fcn->CreateHistogram(hName.Data(), "")); | |
132 | else list->Add(fcn->CreateHistogramSparse(hName.Data(), "")); | |
133 | } | |
5eb970a4 | 134 | |
32992791 | 135 | AliDebug(AliLog::kDebug+2, "Exiting"); |
5eb970a4 | 136 | } |
137 | ||
32992791 | 138 | //______________________________________________________________________________ |
5faf5a07 | 139 | void AliRsnVATProcessInfo::FillInfo() |
4fbb2459 | 140 | { |
141 | // | |
142 | // This method defines how the information histograms must be filled. | |
32992791 | 143 | // The structure of this class is auto-consistent, but in case of inheritance |
4fbb2459 | 144 | // this method must be modified accordingly. |
145 | // Current implementation uses the 'fEventUsed' flag to choose if the event | |
32992791 | 146 | // has been used or not, and increments the corresponding bin in the related |
4fbb2459 | 147 | // histogram (bin '0' = skipped, bin '1' = used). |
148 | // | |
149 | ||
28399a41 | 150 | fHistUsedEvents->Fill(fEventUsed); |
968abd78 | 151 | |
5faf5a07 | 152 | if (!fEventUsed) return; |
153 | ||
968abd78 | 154 | Int_t i; |
155 | AliRsnFunction *fcn = 0; | |
156 | for (i = 0; i < fEventFunctions.GetEntries(); i++) | |
157 | { | |
158 | fcn = (AliRsnFunction*)fEventFunctions.At(i); | |
968abd78 | 159 | fcn->Fill(); |
160 | } | |
4fbb2459 | 161 | } |
162 | ||
32992791 | 163 | //______________________________________________________________________________ |
4fbb2459 | 164 | void AliRsnVATProcessInfo::PrintInfo(const Long64_t &num) |
165 | { | |
166 | // | |
167 | // This method is used in some cases | |
168 | // to inform about number of events processed | |
169 | // | |
170 | ||
32992791 | 171 | if ((num+1) % fPrintInfoNumber == 0) AliInfo(Form("Events processed %lld", num+1)); |
5eb970a4 | 172 | } |
173 | ||
32992791 | 174 | //______________________________________________________________________________ |
4fbb2459 | 175 | Long64_t AliRsnVATProcessInfo::GetNumerOfEventsProcessed() |
176 | { | |
177 | // | |
178 | // returns number of events from histogram | |
179 | // | |
32992791 | 180 | |
181 | if (fHistUsedEvents) return fHistUsedEvents->Integral(); | |
4fbb2459 | 182 | return 0; |
5eb970a4 | 183 | } |
968abd78 | 184 | |
185 | //_____________________________________________________________________________ | |
186 | void AliRsnVATProcessInfo::AddEventFunction(AliRsnFunction * fcn) | |
187 | { | |
188 | // | |
189 | // Adds a new computing function | |
190 | // | |
191 | ||
192 | AliDebug(AliLog::kDebug+2,"<-"); | |
193 | ||
194 | fEventFunctions.Print(); | |
195 | Int_t size = fEventFunctions.GetEntries(); | |
196 | new(fEventFunctions[size]) AliRsnFunction(*fcn); | |
197 | ||
198 | AliDebug(AliLog::kDebug+2,"->"); | |
199 | } |