]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG2/RESONANCES/AliRsnAnalysisManager.cxx
Fixed sprintf, so that the pointer address is printed correctly
[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"
4fbb2459 24#include "AliRsnEvent.h"
4fbb2459 25#include "AliRsnPair.h"
5eb970a4 26#include "AliRsnAnalysisManager.h"
27
4fbb2459 28
5eb970a4 29ClassImp(AliRsnAnalysisManager)
30
31//_____________________________________________________________________________
32AliRsnAnalysisManager::AliRsnAnalysisManager(const char*name) :
2dab9030 33 TNamed(name, ""),
34 fPairs(0)
5eb970a4 35{
36//
37// Default constructor
38//
39
40 AliDebug(AliLog::kDebug+2, "<-");
41 AliDebug(AliLog::kDebug+2, "->");
42}
43
44//_____________________________________________________________________________
2dab9030 45void AliRsnAnalysisManager::Add(AliRsnPair *pair)
5eb970a4 46{
47//
48// Adds a new pair manager to the list.
49//
50
51 AliDebug(AliLog::kDebug+2,"<-");
52
53 if (!pair) {
54 AliWarning(Form("AliRsnPairManager is %p. Skipping ...", pair));
55 return;
56 }
57
2dab9030 58 AliDebug(AliLog::kDebug+1, Form("Adding %s [%d]...", pair->GetName(), fPairs.GetEntries()));
59 fPairs.Add((AliRsnPair*)pair);
5eb970a4 60
61 AliDebug(AliLog::kDebug+2,"->");
62}
63
64//_____________________________________________________________________________
65void AliRsnAnalysisManager::Print(Option_t* /*dummy*/) const
66{
67//
68// Overload of the TObject::Print() method
69//
70
71 AliInfo(Form("\t======== Analysis Manager %s ========", GetName()));
72 PrintArray();
73}
74
75//_____________________________________________________________________________
76void AliRsnAnalysisManager::PrintArray() const
77{
78//
79// Calls the "Print" method of all included pair managers
80//
81
82 AliDebug(AliLog::kDebug+2,"<-");
83
2dab9030 84 AliRsnPair *pair = 0;
85 TObjArrayIter next(&fPairs);
86 while ((pair = (AliRsnPair*)next())) pair->Print();
5eb970a4 87
88 AliDebug(AliLog::kDebug+2,"->");
89}
90
91//_____________________________________________________________________________
2dab9030 92void AliRsnAnalysisManager::InitAllPairs(TList *list)
5eb970a4 93{
94//
95// Initialize all pair managers, and put all the TList of histograms
96// generated by each one into a unique final output TList
97//
98
99 AliDebug(AliLog::kDebug+2,"<-");
100
4fbb2459 101// TList *list = new TList();
102// list->SetName(GetName());
103// list->SetOwner();
5eb970a4 104
2dab9030 105 AliRsnPair *pair = 0;
106 TObjArrayIter next(&fPairs);
5eb970a4 107 Int_t i = 0;
2dab9030 108 while ((pair = (AliRsnPair*)next()))
109 {
110 if (!pair) continue;
111 AliDebug(AliLog::kDebug+1, Form("InitAllPairs of the PairManager(%s) [%d] ...", pair->GetName(), i++));
112 pair->Init("", list);
5eb970a4 113 }
114 AliDebug(AliLog::kDebug+2, "->");
4fbb2459 115// return list;
5eb970a4 116}
117
118//_____________________________________________________________________________
2dab9030 119void AliRsnAnalysisManager::ProcessAllPairs(AliRsnEvent *ev0, AliRsnEvent *ev1)
5eb970a4 120{
121//
122// Process one or two events for all pair managers.
123//
124
125 AliDebug(AliLog::kDebug+2,"<-");
2dab9030 126
127 if (!ev1) ev1 = ev0;
128
129 Int_t nTracks[2], nV0[2], nTot[2];
130 nTracks[0] = ev0->GetRef()->GetNumberOfTracks();
131 nV0[0] = ev0->GetRef()->GetNumberOfV0s();
132 nTracks[1] = ev1->GetRef()->GetNumberOfTracks();
133 nV0[1] = ev1->GetRef()->GetNumberOfV0s();
134 nTot[0] = nTracks[0] + nV0[0];
135 nTot[1] = nTracks[1] + nV0[1];
136
137 // external loop
138 // joins the loop on tracks and v0s, by looping the indexes from 0
139 // to the sum of them, and checking what to take depending of its value
140 Int_t i0, i1, i;
141 AliRsnDaughter daughter0, daughter1;
142 AliRsnPair *pair = 0x0;
143 TObjArrayIter next(&fPairs);
144
145 for (i0 = 0; i0 < nTot[0]; i0++)
146 {
147 // assign first track
148 if (i0 < nTracks[0]) ev0->SetDaughter(daughter0, i0, AliRsnDaughter::kTrack);
149 else ev0->SetDaughter(daughter0, i0 - nTracks[0], AliRsnDaughter::kV0);
150
151 // internal loop (same criterion)
152 for (i1 = 0; i1 < nTot[1]; i1++)
153 {
154 // if looking same event, skip the case when the two indexes are equal
155 if (ev0 == ev1 && i0 == i1) continue;
156
157 // assign second track
158 if (i1 < nTracks[1]) ev1->SetDaughter(daughter1, i1, AliRsnDaughter::kTrack);
159 else ev1->SetDaughter(daughter1, i1 - nTracks[1], AliRsnDaughter::kV0);
160
161 // loop over all pairs and make computations
162 next.Reset();
163 i = 0;
164 while ((pair = (AliRsnPair*)next()))
165 {
166 AliDebug(AliLog::kDebug+1, Form("ProcessAllPairs of the AnalysisManager(%s) [%d] ...", pair->GetName(), i++));
167
168 // if the pair is a like-sign, skip the case when i1 < i0,
169 // in order not to double count each like-sign pair
170 // (equivalent to looping from i0+1 to ntracks)
171 if (pair->GetPairDef()->IsLikeSign() && i1 < i0) continue;
172
173 // process the two tracks
174 if (!pair->Fill(&daughter0, &daughter1, ev0, ev1)) continue;
175 pair->Compute();
176 }
177 }
5eb970a4 178 }
179
180 AliDebug(AliLog::kDebug+2,"->");
181}