2 // Class AliRsnAnalysisManager
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.
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.
12 // The base architecture is still AliRsnVManager, but in this case
13 // all the objects in the list will be AliRsnPairManager's.
15 // author : M. Vala [martin.vala@cern.ch]
16 // revised by : A. Pulvirenti [alberto.pulvirenti@ct.infn.it]
24 #include "AliVEvent.h"
25 #include "AliMCEvent.h"
26 #include "AliRsnEvent.h"
27 #include "AliRsnPairFunctions.h"
28 #include "AliRsnPairNtuple.h"
29 #include "AliRsnAnalysisManager.h"
32 ClassImp(AliRsnAnalysisManager)
34 //_____________________________________________________________________________
35 AliRsnAnalysisManager::AliRsnAnalysisManager(const char*name) :
42 // Default constructor
46 //_____________________________________________________________________________
47 AliRsnAnalysisManager::AliRsnAnalysisManager(const AliRsnAnalysisManager& copy) :
51 fGlobalTrackCuts(copy.fGlobalTrackCuts)
58 //_____________________________________________________________________________
59 AliRsnAnalysisManager& AliRsnAnalysisManager::operator=(const AliRsnAnalysisManager& copy)
62 // Assignment operator
65 TNamed::operator=(copy);
69 fGlobalTrackCuts = copy.fGlobalTrackCuts;
74 //_____________________________________________________________________________
75 void AliRsnAnalysisManager::Add(AliRsnPair *pair)
78 // Adds a new pair manager to the list.
81 AliDebug(AliLog::kDebug + 2, "<-");
84 AliWarning(Form("AliRsnPairManager is %p. Skipping ...", pair));
88 AliDebug(AliLog::kDebug + 1, Form("Adding %s [%d]...", pair->GetName(), fPairs.GetEntries()));
91 AliDebug(AliLog::kDebug + 2, "->");
94 //_____________________________________________________________________________
95 void AliRsnAnalysisManager::Print(Option_t* /*dummy*/) const
98 // Overload of the TObject::Print() method
101 AliInfo(Form("\t======== Analysis Manager %s ========", GetName()));
105 //_____________________________________________________________________________
106 void AliRsnAnalysisManager::PrintArray() const
109 // Calls the "Print" method of all included pair managers
112 AliDebug(AliLog::kDebug + 2, "<-");
114 AliRsnPair *pair = 0;
115 TObjArrayIter next(&fPairs);
116 while ((pair = (AliRsnPair*)next())) pair->Print();
118 AliDebug(AliLog::kDebug + 2, "->");
121 //_____________________________________________________________________________
122 void AliRsnAnalysisManager::InitAllPairs(TList *list)
125 // Initialize all pair managers, and put all the TList of histograms
126 // generated by each one into a unique final output TList
129 AliDebug(AliLog::kDebug + 2, "<-");
131 AliRsnPair *pair = 0;
132 TObjArrayIter next(&fPairs);
134 while ((pair = (AliRsnPair*)next())) {
135 AliDebug(AliLog::kDebug + 1, Form("InitAllPairs of the PairManager(%s) [%d] ...", pair->GetName(), i++));
136 // pair->Init("", list);
137 pair->Init(GetName(), list);
139 // add a counter for used/unused events for each pair
140 TH1I *hPairUsed = new TH1I(Form("%s_%s_USED", GetName(), pair->GetName()), "Used events for pair", 2, 0, 2);
141 list->Add(hPairUsed);
146 AliDebug(AliLog::kDebug + 2, "->");
149 //_____________________________________________________________________________
150 void AliRsnAnalysisManager::ProcessAllPairs()
153 // Process one or two events for all pair managers.
156 static Int_t evnum = 0;
159 AliDebug(AliLog::kDebug + 2, "<-");
161 // skip if the global event pointers are NULL
162 if (!AliRsnEvent::IsCurrentEvent1()) return;
163 if (!AliRsnEvent::IsCurrentEvent2()) return;
165 // for better readability, reference two pointers to the current events
166 AliRsnEvent *ev0 = AliRsnEvent::GetCurrentEvent1();
167 AliRsnEvent *ev1 = AliRsnEvent::GetCurrentEvent2();
169 // count total number of candidates per event
170 // (sum of tracks, V0s and cascades)
172 nTot[0] = AliRsnEvent::GetCurrentEvent1()->GetAbsoluteSum();
173 nTot[1] = AliRsnEvent::GetCurrentEvent2()->GetAbsoluteSum();
176 Int_t i0, i1, i, start, index0, index1;
177 AliRsnDaughter daughter0, daughter1;
178 AliRsnPair *pair = 0x0;
179 TObjArrayIter next(&fPairs);
180 AliRsnDaughter::ERefType type0, type1;
182 // reset all counters which tell us
183 // how many entries were added now
184 while ((pair = (AliRsnPair*)next())) {
189 for (i0 = 0; i0 < nTot[0]; i0++) {
190 // assign first track
191 if (!ev0->ConvertAbsoluteIndex(i0, index0, type0)) continue;
192 ev0->SetDaughter(daughter0, index0, type0);
195 if (!fGlobalTrackCuts.IsSelected(&daughter0)) continue;
197 // define start depending if we are processing one or two events
198 start = (AliRsnEvent::SameEvent() ? i0 + 1 : 0);
200 // internal loop (same criterion)
201 for (i1 = start; i1 < nTot[1]; i1++) {
202 // if looking same event, skip the case when the two indexes are equal
203 // if (AliRsnEvent::SameEvent() && i0 == i1) continue;
205 // assign second track
206 if (!ev1->ConvertAbsoluteIndex(i1, index1, type1)) continue;
207 ev1->SetDaughter(daughter1, index1, type1);
210 if (!fGlobalTrackCuts.IsSelected(&daughter1)) continue;
212 // loop over all pairs and make computations
215 while ((pair = (AliRsnPair*)next())) {
216 AliDebug(AliLog::kDebug + 1, Form("ProcessAllPairs of the AnalysisManager(%s) [%d] ...", pair->GetName(), i++));
218 // if the pair is a like-sign, skip the case when i1 < i0,
219 // in order not to double count each like-sign pair
220 // (equivalent to looping from i0+1 to ntracks)
221 // if (AliRsnEvent::SameEvent() && pair->GetPairDef()->IsLikeSign() && i1 < i0) continue;
223 // process the two tracks
224 if (pair->Fill(&daughter0, &daughter1)) {
226 } else if (pair->Fill(&daughter1, &daughter0)) {
233 // update all count histograms counters
236 while ((pair = (AliRsnPair*)next())) {
237 TH1I *hist = (TH1I*)fList->FindObject(Form("_%s_USED", pair->GetName()));
239 if (pair->GetCount() > 0) hist->Fill(1); else hist->Fill(0);
242 AliDebug(AliLog::kDebug + 2, "->");
245 //_____________________________________________________________________________
246 void AliRsnAnalysisManager::ProcessAllPairsMC()
249 // Process one or two events for all pair managers.
252 AliDebug(AliLog::kDebug + 2, "<-");
254 // skip if the global event pointers are NULL
255 if (!AliRsnEvent::IsCurrentEvent1()) return;
256 if (!AliRsnEvent::IsCurrentEvent2()) return;
258 // for better readability, reference two pointers to the current events
259 AliRsnEvent *ev0 = AliRsnEvent::GetCurrentEvent1();
260 AliRsnEvent *ev1 = AliRsnEvent::GetCurrentEvent2();
262 // this time the number of tracks comes from MC
264 nTracks[0] = ev0->GetRefMC()->GetNumberOfTracks();
265 nTracks[1] = ev1->GetRefMC()->GetNumberOfTracks();
268 // joins the loop on tracks and v0s, by looping the indexes from 0
269 // to the sum of them, and checking what to take depending of its value
270 Int_t i0, i1, start, i;
272 AliRsnDaughter daughter0, daughter1;
273 AliRsnPair *pair = 0x0;
274 TObjArrayIter next(&fPairs);
276 // reset all counters
277 while ((pair = (AliRsnPair*)next())) {
281 for (i0 = 0; i0 < nTracks[0]; i0++) {
282 // skip not physical primaries
283 if (!ev0->GetRefMCESD()->Stack()->IsPhysicalPrimary(i0)) continue;
285 // assign first track
286 ev0->SetDaughterMC(daughter0, i0);
288 // define start depending if we are processing one or two events
289 start = (AliRsnEvent::SameEvent() ? i0 + 1 : 0);
291 // internal loop (same criterion)
292 for (i1 = start; i1 < nTracks[1]; i1++) {
293 // if looking same event, skip the case when the two indexes are equal
294 if (AliRsnEvent::SameEvent() && i0 == i1) continue;
296 // skip not physical primaries
297 if (!ev1->GetRefMCESD()->Stack()->IsPhysicalPrimary(i1)) continue;
299 // assign second track
300 ev1->SetDaughterMC(daughter1, i1);
302 // loop over all pairs and make computations
305 while ((pair = (AliRsnPair*)next())) {
306 AliDebug(AliLog::kDebug + 1, Form("ProcessAllPairs of the AnalysisManager(%s) [%d] ...", pair->GetName(), i++));
308 // if the pair is a like-sign, skip the case when i1 < i0,
309 // in order not to double count each like-sign pair
310 // (equivalent to looping from i0+1 to ntracks)
311 if (pair->GetPairDef()->IsLikeSign() && i1 < i0) continue;
313 // process the two tracks
314 filled = pair->Fill(&daughter0, &daughter1);
315 if (!filled) continue;
321 // update all count histograms counters
324 while ((pair = (AliRsnPair*)next())) {
325 TH1I *hist = (TH1I*)fList->FindObject(Form("_%s_USED", pair->GetName()));
327 if (pair->GetCount() > 0) hist->Fill(1); else hist->Fill(0);
330 AliDebug(AliLog::kDebug + 2, "->");