]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG2/RESONANCES/AliRsnAnalysisManager.cxx
bugfix
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnAnalysisManager.cxx
CommitLineData
5eb970a4 1//
2// Class AliRsnAnalysisManager
3//
4// This is the uppermost level of analysis objects collection.
5// It contains a list of pair managers, which all will process
6// a pool of events passed to this object, and fill their histograms.
7//
8// The utility of this object is to define a unique implementation
9// of the whole processing, which can then be included in the different
10// designs of AnalysisTask provided for SE and ME analysis.
11//
12// The base architecture is still AliRsnVManager, but in this case
13// all the objects in the list will be AliRsnPairManager's.
14//
15// author : M. Vala [martin.vala@cern.ch]
16// revised by : A. Pulvirenti [alberto.pulvirenti@ct.infn.it]
17//
18
2dab9030 19#include <Riostream.h>
4fbb2459 20#include <TROOT.h>
5eb970a4 21
4fbb2459 22#include "AliLog.h"
2dab9030 23#include "AliVEvent.h"
2e521c29 24#include "AliMCEvent.h"
4fbb2459 25#include "AliRsnEvent.h"
4fbb2459 26#include "AliRsnPair.h"
5eb970a4 27#include "AliRsnAnalysisManager.h"
28
4fbb2459 29
5eb970a4 30ClassImp(AliRsnAnalysisManager)
31
32//_____________________________________________________________________________
33AliRsnAnalysisManager::AliRsnAnalysisManager(const char*name) :
2dab9030 34 TNamed(name, ""),
35 fPairs(0)
5eb970a4 36{
37//
38// Default constructor
39//
40
41 AliDebug(AliLog::kDebug+2, "<-");
42 AliDebug(AliLog::kDebug+2, "->");
43}
44
45//_____________________________________________________________________________
2dab9030 46void AliRsnAnalysisManager::Add(AliRsnPair *pair)
5eb970a4 47{
48//
49// Adds a new pair manager to the list.
50//
51
52 AliDebug(AliLog::kDebug+2,"<-");
53
54 if (!pair) {
55 AliWarning(Form("AliRsnPairManager is %p. Skipping ...", pair));
56 return;
57 }
58
2dab9030 59 AliDebug(AliLog::kDebug+1, Form("Adding %s [%d]...", pair->GetName(), fPairs.GetEntries()));
60 fPairs.Add((AliRsnPair*)pair);
5eb970a4 61
62 AliDebug(AliLog::kDebug+2,"->");
63}
64
65//_____________________________________________________________________________
66void AliRsnAnalysisManager::Print(Option_t* /*dummy*/) const
67{
68//
69// Overload of the TObject::Print() method
70//
71
72 AliInfo(Form("\t======== Analysis Manager %s ========", GetName()));
73 PrintArray();
74}
75
76//_____________________________________________________________________________
77void AliRsnAnalysisManager::PrintArray() const
78{
79//
80// Calls the "Print" method of all included pair managers
81//
82
83 AliDebug(AliLog::kDebug+2,"<-");
84
2dab9030 85 AliRsnPair *pair = 0;
86 TObjArrayIter next(&fPairs);
87 while ((pair = (AliRsnPair*)next())) pair->Print();
5eb970a4 88
89 AliDebug(AliLog::kDebug+2,"->");
90}
91
92//_____________________________________________________________________________
2dab9030 93void AliRsnAnalysisManager::InitAllPairs(TList *list)
5eb970a4 94{
95//
96// Initialize all pair managers, and put all the TList of histograms
97// generated by each one into a unique final output TList
98//
99
100 AliDebug(AliLog::kDebug+2,"<-");
101
4fbb2459 102// TList *list = new TList();
103// list->SetName(GetName());
104// list->SetOwner();
5eb970a4 105
2dab9030 106 AliRsnPair *pair = 0;
107 TObjArrayIter next(&fPairs);
5eb970a4 108 Int_t i = 0;
2dab9030 109 while ((pair = (AliRsnPair*)next()))
110 {
111 if (!pair) continue;
112 AliDebug(AliLog::kDebug+1, Form("InitAllPairs of the PairManager(%s) [%d] ...", pair->GetName(), i++));
113 pair->Init("", list);
5eb970a4 114 }
115 AliDebug(AliLog::kDebug+2, "->");
4fbb2459 116// return list;
5eb970a4 117}
118
119//_____________________________________________________________________________
2dab9030 120void AliRsnAnalysisManager::ProcessAllPairs(AliRsnEvent *ev0, AliRsnEvent *ev1)
5eb970a4 121{
122//
123// Process one or two events for all pair managers.
124//
125
126 AliDebug(AliLog::kDebug+2,"<-");
2dab9030 127
128 if (!ev1) ev1 = ev0;
129
130 Int_t nTracks[2], nV0[2], nTot[2];
131 nTracks[0] = ev0->GetRef()->GetNumberOfTracks();
132 nV0[0] = ev0->GetRef()->GetNumberOfV0s();
133 nTracks[1] = ev1->GetRef()->GetNumberOfTracks();
134 nV0[1] = ev1->GetRef()->GetNumberOfV0s();
135 nTot[0] = nTracks[0] + nV0[0];
136 nTot[1] = nTracks[1] + nV0[1];
137
138 // external loop
139 // joins the loop on tracks and v0s, by looping the indexes from 0
140 // to the sum of them, and checking what to take depending of its value
141 Int_t i0, i1, i;
142 AliRsnDaughter daughter0, daughter1;
143 AliRsnPair *pair = 0x0;
144 TObjArrayIter next(&fPairs);
145
146 for (i0 = 0; i0 < nTot[0]; i0++)
147 {
148 // assign first track
149 if (i0 < nTracks[0]) ev0->SetDaughter(daughter0, i0, AliRsnDaughter::kTrack);
150 else ev0->SetDaughter(daughter0, i0 - nTracks[0], AliRsnDaughter::kV0);
151
152 // internal loop (same criterion)
153 for (i1 = 0; i1 < nTot[1]; i1++)
154 {
155 // if looking same event, skip the case when the two indexes are equal
156 if (ev0 == ev1 && i0 == i1) continue;
157
158 // assign second track
159 if (i1 < nTracks[1]) ev1->SetDaughter(daughter1, i1, AliRsnDaughter::kTrack);
160 else ev1->SetDaughter(daughter1, i1 - nTracks[1], AliRsnDaughter::kV0);
161
162 // loop over all pairs and make computations
163 next.Reset();
164 i = 0;
165 while ((pair = (AliRsnPair*)next()))
166 {
167 AliDebug(AliLog::kDebug+1, Form("ProcessAllPairs of the AnalysisManager(%s) [%d] ...", pair->GetName(), i++));
168
169 // if the pair is a like-sign, skip the case when i1 < i0,
170 // in order not to double count each like-sign pair
171 // (equivalent to looping from i0+1 to ntracks)
172 if (pair->GetPairDef()->IsLikeSign() && i1 < i0) continue;
173
174 // process the two tracks
175 if (!pair->Fill(&daughter0, &daughter1, ev0, ev1)) continue;
176 pair->Compute();
177 }
178 }
5eb970a4 179 }
180
181 AliDebug(AliLog::kDebug+2,"->");
182}
2e521c29 183
184//_____________________________________________________________________________
185void AliRsnAnalysisManager::ProcessAllPairsMC(AliRsnEvent *ev0, AliRsnEvent *ev1)
186{
187//
188// Process one or two events for all pair managers.
189//
190
191 AliDebug(AliLog::kDebug+2,"<-");
192
193 if (!ev1) ev1 = ev0;
194
195 Int_t nTracks[2];
196 nTracks[0] = ev0->GetRefMC()->GetNumberOfTracks();
197 nTracks[1] = ev1->GetRefMC()->GetNumberOfTracks();
198
199 // external loop
200 // joins the loop on tracks and v0s, by looping the indexes from 0
201 // to the sum of them, and checking what to take depending of its value
202 Int_t i0, i1, i;
203 AliRsnDaughter daughter0, daughter1;
204 AliRsnPair *pair = 0x0;
205 TObjArrayIter next(&fPairs);
206
207 for (i0 = 0; i0 < nTracks[0]; i0++)
208 {
209 // assign first track
210 if (i0 < nTracks[0]) ev0->SetDaughter(daughter0, i0, AliRsnDaughter::kTrack);
211 else ev0->SetDaughter(daughter0, i0 - nTracks[0], AliRsnDaughter::kV0);
212
213 // internal loop (same criterion)
214 for (i1 = 0; i1 < nTracks[1]; i1++)
215 {
216 // if looking same event, skip the case when the two indexes are equal
217 if (ev0 == ev1 && i0 == i1) continue;
218
219 // assign second track
220 if (i1 < nTracks[1]) ev1->SetDaughter(daughter1, i1, AliRsnDaughter::kTrack);
221 else ev1->SetDaughter(daughter1, i1 - nTracks[1], AliRsnDaughter::kV0);
222
223 // loop over all pairs and make computations
224 next.Reset();
225 i = 0;
226 while ((pair = (AliRsnPair*)next()))
227 {
228 AliDebug(AliLog::kDebug+1, Form("ProcessAllPairs of the AnalysisManager(%s) [%d] ...", pair->GetName(), i++));
229
230 // if the pair is a like-sign, skip the case when i1 < i0,
231 // in order not to double count each like-sign pair
232 // (equivalent to looping from i0+1 to ntracks)
233 if (pair->GetPairDef()->IsLikeSign() && i1 < i0) continue;
234
235 // process the two tracks
236 if (!pair->Fill(&daughter0, &daughter1, ev0, ev1)) continue;
237 pair->Compute();
238 }
239 }
240 }
241
242 AliDebug(AliLog::kDebug+2,"->");
243}
244