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 AliRsnPair *pair = 0;
133 TObjArrayIter next(&fPairs);
135 while ((pair = (AliRsnPair*)next()))
137 AliDebug(AliLog::kDebug+1, Form("InitAllPairs of the PairManager(%s) [%d] ...", pair->GetName(), i++));
138 pair->Init("", list);
140 // add a counter for used/unused events for each pair
141 TH1I *hPairUsed = new TH1I(Form("_%s_USED", pair->GetName()), "Used events for pair", 2, 0, 2);
142 list->Add(hPairUsed);
147 AliDebug(AliLog::kDebug+2, "->");
150 //_____________________________________________________________________________
151 void AliRsnAnalysisManager::ProcessAllPairs()
154 // Process one or two events for all pair managers.
157 static Int_t evnum = 0;
160 AliDebug(AliLog::kDebug+2,"<-");
162 // skip if the global event pointers are NULL
163 if (!AliRsnEvent::IsCurrentEvent1()) return;
164 if (!AliRsnEvent::IsCurrentEvent2()) return;
166 // for better readability, reference two pointers to the current events
167 AliRsnEvent *ev0 = AliRsnEvent::GetCurrentEvent1();
168 AliRsnEvent *ev1 = AliRsnEvent::GetCurrentEvent2();
170 // count total number of candidates per event
171 // (sum of tracks, V0s and cascades)
173 nTot[0] = AliRsnEvent::GetCurrentEvent1()->GetAbsoluteSum();
174 nTot[1] = AliRsnEvent::GetCurrentEvent2()->GetAbsoluteSum();
177 Int_t i0, i1, i, start, index0, index1;
178 AliRsnDaughter daughter0, daughter1;
179 AliRsnPair *pair = 0x0;
180 TObjArrayIter next(&fPairs);
181 AliRsnDaughter::ERefType type0, type1;
183 // reset all counters which tell us
184 // how many entries were added now
185 while ((pair = (AliRsnPair*)next()))
191 for (i0 = 0; i0 < nTot[0]; i0++)
193 // assign first track
194 if (!ev0->ConvertAbsoluteIndex(i0, index0, type0)) continue;
195 ev0->SetDaughter(daughter0, index0, type0);
198 if (!fGlobalTrackCuts.IsSelected(&daughter0)) continue;
200 // define start depending if we are processing one or two events
201 start = (AliRsnEvent::SameEvent() ? i0 + 1 : 0);
203 // internal loop (same criterion)
204 for (i1 = start; i1 < nTot[1]; i1++)
206 // if looking same event, skip the case when the two indexes are equal
207 // if (AliRsnEvent::SameEvent() && i0 == i1) continue;
209 // assign second track
210 if (!ev1->ConvertAbsoluteIndex(i1, index1, type1)) continue;
211 ev1->SetDaughter(daughter1, index1, type1);
214 if (!fGlobalTrackCuts.IsSelected(&daughter1)) continue;
216 // loop over all pairs and make computations
219 while ((pair = (AliRsnPair*)next()))
221 AliDebug(AliLog::kDebug+1, Form("ProcessAllPairs of the AnalysisManager(%s) [%d] ...", pair->GetName(), i++));
223 // if the pair is a like-sign, skip the case when i1 < i0,
224 // in order not to double count each like-sign pair
225 // (equivalent to looping from i0+1 to ntracks)
226 // if (AliRsnEvent::SameEvent() && pair->GetPairDef()->IsLikeSign() && i1 < i0) continue;
228 // process the two tracks
229 if (pair->Fill(&daughter0, &daughter1))
233 else if (pair->Fill(&daughter1, &daughter0))
241 // update all count histograms counters
244 while ((pair = (AliRsnPair*)next()))
246 TH1I *hist = (TH1I*)fList->FindObject(Form("_%s_USED", pair->GetName()));
248 if (pair->GetCount() > 0) hist->Fill(1); else hist->Fill(0);
251 AliDebug(AliLog::kDebug+2,"->");
254 //_____________________________________________________________________________
255 void AliRsnAnalysisManager::ProcessAllPairsMC()
258 // Process one or two events for all pair managers.
261 AliDebug(AliLog::kDebug+2,"<-");
263 // skip if the global event pointers are NULL
264 if (!AliRsnEvent::IsCurrentEvent1()) return;
265 if (!AliRsnEvent::IsCurrentEvent2()) return;
267 // for better readability, reference two pointers to the current events
268 AliRsnEvent *ev0 = AliRsnEvent::GetCurrentEvent1();
269 AliRsnEvent *ev1 = AliRsnEvent::GetCurrentEvent2();
271 // this time the number of tracks comes from MC
273 nTracks[0] = ev0->GetRefMC()->GetNumberOfTracks();
274 nTracks[1] = ev1->GetRefMC()->GetNumberOfTracks();
277 // joins the loop on tracks and v0s, by looping the indexes from 0
278 // to the sum of them, and checking what to take depending of its value
279 Int_t i0, i1, start, i;
281 AliRsnDaughter daughter0, daughter1;
282 AliRsnPair *pair = 0x0;
283 TObjArrayIter next(&fPairs);
285 // reset all counters
286 while ((pair = (AliRsnPair*)next()))
291 for (i0 = 0; i0 < nTracks[0]; i0++)
293 // skip not physical primaries
294 if (!ev0->GetRefMCESD()->Stack()->IsPhysicalPrimary(i0)) continue;
296 // assign first track
297 ev0->SetDaughterMC(daughter0, i0);
299 // define start depending if we are processing one or two events
300 start = (AliRsnEvent::SameEvent() ? i0 + 1 : 0);
302 // internal loop (same criterion)
303 for (i1 = start; i1 < nTracks[1]; i1++)
305 // if looking same event, skip the case when the two indexes are equal
306 if (AliRsnEvent::SameEvent() && i0 == i1) continue;
308 // skip not physical primaries
309 if (!ev1->GetRefMCESD()->Stack()->IsPhysicalPrimary(i1)) continue;
311 // assign second track
312 ev1->SetDaughterMC(daughter1, i1);
314 // loop over all pairs and make computations
317 while ((pair = (AliRsnPair*)next()))
319 AliDebug(AliLog::kDebug+1, Form("ProcessAllPairs of the AnalysisManager(%s) [%d] ...", pair->GetName(), i++));
321 // if the pair is a like-sign, skip the case when i1 < i0,
322 // in order not to double count each like-sign pair
323 // (equivalent to looping from i0+1 to ntracks)
324 if (pair->GetPairDef()->IsLikeSign() && i1 < i0) continue;
326 // process the two tracks
327 filled = pair->Fill(&daughter0, &daughter1);
328 if (!filled) continue;
334 // update all count histograms counters
337 while ((pair = (AliRsnPair*)next()))
339 TH1I *hist = (TH1I*)fList->FindObject(Form("_%s_USED", pair->GetName()));
341 if (pair->GetCount() > 0) hist->Fill(1); else hist->Fill(0);
344 AliDebug(AliLog::kDebug+2,"->");