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,"<-");
85 AliWarning(Form("AliRsnPairManager is %p. Skipping ...", pair));
89 AliDebug(AliLog::kDebug+1, Form("Adding %s [%d]...", pair->GetName(), fPairs.GetEntries()));
92 AliDebug(AliLog::kDebug+2,"->");
95 //_____________________________________________________________________________
96 void AliRsnAnalysisManager::Print(Option_t* /*dummy*/) const
99 // Overload of the TObject::Print() method
102 AliInfo(Form("\t======== Analysis Manager %s ========", GetName()));
106 //_____________________________________________________________________________
107 void AliRsnAnalysisManager::PrintArray() const
110 // Calls the "Print" method of all included pair managers
113 AliDebug(AliLog::kDebug+2,"<-");
115 AliRsnPair *pair = 0;
116 TObjArrayIter next(&fPairs);
117 while ((pair = (AliRsnPair*)next())) pair->Print();
119 AliDebug(AliLog::kDebug+2,"->");
122 //_____________________________________________________________________________
123 void AliRsnAnalysisManager::InitAllPairs(TList *list)
126 // Initialize all pair managers, and put all the TList of histograms
127 // generated by each one into a unique final output TList
130 AliDebug(AliLog::kDebug+2,"<-");
132 // TList *list = new TList();
133 // list->SetName(GetName());
136 AliRsnPair *pair = 0;
137 TObjArrayIter next(&fPairs);
139 while ((pair = (AliRsnPair*)next()))
142 AliDebug(AliLog::kDebug+1, Form("InitAllPairs of the PairManager(%s) [%d] ...", pair->GetName(), i++));
143 pair->Init("", list);
145 // add a counter for used/unused events for each pair
146 TH1I *hPairUsed = new TH1I(Form("_%s_USED", pair->GetName()), "Used events for pair", 2, 0, 2);
147 list->Add(hPairUsed);
149 AliDebug(AliLog::kDebug+2, "->");
155 //_____________________________________________________________________________
156 void AliRsnAnalysisManager::ProcessAllPairs(AliRsnEvent *ev0, AliRsnEvent *ev1)
159 // Process one or two events for all pair managers.
162 AliDebug(AliLog::kDebug+2,"<-");
167 nTot[0] = ev0->GetAbsoluteSum();
168 nTot[1] = ev1->GetAbsoluteSum();
171 // joins the loop on tracks and v0s, by looping the indexes from 0
172 // to the sum of them, and checking what to take depending of its value
173 // in this step, the global cuts are checked
174 Int_t i0, i1, i, realIndex;
175 AliRsnDaughter daughter0, daughter1;
176 AliRsnPair *pair = 0x0;
177 TObjArrayIter next(&fPairs);
178 AliRsnDaughter::ERefType type;
180 // reset all counters
181 while ((pair = (AliRsnPair*)next()))
186 for (i0 = 0; i0 < nTot[0]; i0++)
188 // assign first track
189 if (!ev0->ConvertAbsoluteIndex(i0, realIndex, type)) continue;
190 ev0->SetDaughter(daughter0, realIndex, type);
193 if (!fGlobalTrackCuts.IsSelected(&daughter0)) continue;
195 // internal loop (same criterion)
196 for (i1 = 0; i1 < nTot[1]; i1++)
198 // if looking same event, skip the case when the two indexes are equal
199 if (ev0 == ev1 && i0 == i1) continue;
201 // assign second track
202 if (!ev1->ConvertAbsoluteIndex(i1, realIndex, type)) continue;
203 ev1->SetDaughter(daughter1, realIndex, type);
206 if (!fGlobalTrackCuts.IsSelected(&daughter1)) continue;
208 // loop over all pairs and make computations
211 while ((pair = (AliRsnPair*)next()))
213 AliDebug(AliLog::kDebug+1, Form("ProcessAllPairs of the AnalysisManager(%s) [%d] ...", pair->GetName(), i++));
215 // if the pair is a like-sign, skip the case when i1 < i0,
216 // in order not to double count each like-sign pair
217 // (equivalent to looping from i0+1 to ntracks)
218 if (pair->GetPairDef()->IsLikeSign() && i1 < i0) continue;
220 // process the two tracks
221 if (!pair->Fill(&daughter0, &daughter1, ev0, ev1)) continue;
227 // update all count histograms counters
230 while ((pair = (AliRsnPair*)next()))
232 TH1I *hist = (TH1I*)fList->FindObject(Form("_%s_USED", pair->GetName()));
234 if (pair->GetCount() > 0) hist->Fill(1); else hist->Fill(0);
237 AliDebug(AliLog::kDebug+2,"->");
240 //_____________________________________________________________________________
241 void AliRsnAnalysisManager::ProcessAllPairsMC(AliRsnEvent *ev0, AliRsnEvent *ev1)
244 // Process one or two events for all pair managers.
247 AliDebug(AliLog::kDebug+2,"<-");
252 nTracks[0] = ev0->GetRefMC()->GetNumberOfTracks();
253 nTracks[1] = ev1->GetRefMC()->GetNumberOfTracks();
256 // joins the loop on tracks and v0s, by looping the indexes from 0
257 // to the sum of them, and checking what to take depending of its value
260 AliRsnDaughter daughter0, daughter1;
261 AliRsnPair *pair = 0x0;
262 TObjArrayIter next(&fPairs);
264 // reset all counters
265 while ((pair = (AliRsnPair*)next()))
270 for (i0 = 0; i0 < nTracks[0]; i0++)
272 // skip not physical primaries
273 if (!ev0->GetRefMCESD()->Stack()->IsPhysicalPrimary(i0)) continue;
275 // assign first track
276 ev0->SetDaughterMC(daughter0, i0);
278 // internal loop (same criterion)
279 for (i1 = 0; i1 < nTracks[1]; i1++)
281 // if looking same event, skip the case when the two indexes are equal
282 if (ev0 == ev1 && i0 == i1) continue;
284 // skip not physical primaries
285 if (!ev1->GetRefMCESD()->Stack()->IsPhysicalPrimary(i1)) continue;
287 // assign second track
288 ev1->SetDaughterMC(daughter1, i1);
290 // loop over all pairs and make computations
293 while ((pair = (AliRsnPair*)next()))
295 AliDebug(AliLog::kDebug+1, Form("ProcessAllPairs of the AnalysisManager(%s) [%d] ...", pair->GetName(), i++));
297 // if the pair is a like-sign, skip the case when i1 < i0,
298 // in order not to double count each like-sign pair
299 // (equivalent to looping from i0+1 to ntracks)
300 if (pair->GetPairDef()->IsLikeSign() && i1 < i0) continue;
302 // process the two tracks
303 filled = pair->Fill(&daughter0, &daughter1, ev0, ev1);
304 if (!filled) continue;
310 // update all count histograms counters
313 while ((pair = (AliRsnPair*)next()))
315 TH1I *hist = (TH1I*)fList->FindObject(Form("_%s_USED", pair->GetName()));
317 if (pair->GetCount() > 0) hist->Fill(1); else hist->Fill(0);
320 AliDebug(AliLog::kDebug+2,"->");