1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
16 ////////////////////////////////////////////////////////////////////////////////
18 // This is the uppermost level in the analysis task and is built as a
19 // separate object since up to this level the execution of the analysis
20 // is not directly related to the real analysis task structure.
21 // An analysis task for resonances will just configure and initialize an
22 // instance of this class, which will do all the work, and will share with it
23 // the TList containing all the outputs.
25 // This object collects all AliRsnPair and AliRsnMonitor objects which do
26 // the computations and fill histograms, each properly initialized with
27 // outputs (histos, ntuples) and cuts on whatever is needed.
29 // authors: A. Pulvirenti (alberto.pulvirenti@ct.infn.it)
30 // M. Vala (martin.vala@cern.ch)
32 ////////////////////////////////////////////////////////////////////////////////
39 #include "AliVEvent.h"
40 #include "AliMCEvent.h"
41 #include "AliRsnEvent.h"
42 #include "AliRsnPairFunctions.h"
43 #include "AliRsnPairNtuple.h"
44 #include "AliRsnMonitorFunctions.h"
45 #include "AliRsnMonitorNtuple.h"
47 #include "AliRsnAnalysisManager.h"
50 ClassImp(AliRsnAnalysisManager)
52 //_____________________________________________________________________________
53 AliRsnAnalysisManager::AliRsnAnalysisManager(const char *name) :
55 fAddUsageHist(kFALSE),
62 // Default constructor
66 //_____________________________________________________________________________
67 AliRsnAnalysisManager::AliRsnAnalysisManager(const AliRsnAnalysisManager& copy) :
69 fAddUsageHist(copy.fAddUsageHist),
72 fMonitors(copy.fMonitors),
73 fGlobalTrackCuts(copy.fGlobalTrackCuts)
80 //_____________________________________________________________________________
81 AliRsnAnalysisManager& AliRsnAnalysisManager::operator=(const AliRsnAnalysisManager& copy)
84 // Assignment operator
87 TNamed::operator=(copy);
89 fAddUsageHist = copy.fAddUsageHist;
92 fMonitors = copy.fMonitors;
93 fGlobalTrackCuts = copy.fGlobalTrackCuts;
98 //_____________________________________________________________________________
99 void AliRsnAnalysisManager::Add(AliRsnPair *pair)
102 // Adds a new pair to the list.
105 AliDebug(AliLog::kDebug + 2, "<-");
108 AliWarning(Form("AliRsnPairManager is %p. Skipping ...", pair));
112 AliDebug(AliLog::kDebug + 1, Form("Adding %s [%d]...", pair->GetName(), fPairs.GetEntries()));
115 AliDebug(AliLog::kDebug + 2, "->");
118 //_____________________________________________________________________________
119 void AliRsnAnalysisManager::Add(AliRsnMonitor *monitor)
122 // Adds a new monitor to the list.
125 AliDebug(AliLog::kDebug + 2, "<-");
128 AliWarning(Form("AliRsnPairManager is %p. Skipping ...", monitor));
132 AliDebug(AliLog::kDebug + 1, Form("Adding %s [%d]...", monitor->GetName(), fMonitors.GetEntries()));
133 fMonitors.Add(monitor);
135 AliDebug(AliLog::kDebug + 2, "->");
138 //_____________________________________________________________________________
139 void AliRsnAnalysisManager::Print(Option_t* /*dummy*/) const
142 // Overload of the TObject::Print() method
145 AliInfo(Form("\t======== Analysis Manager %s ========", GetName()));
149 //_____________________________________________________________________________
150 void AliRsnAnalysisManager::PrintArray() const
153 // Calls the "Print" method of all included pair managers
156 AliDebug(AliLog::kDebug + 2, "<-");
158 AliRsnPair *pair = 0;
159 TObjArrayIter nextPair(&fPairs);
160 while ((pair = (AliRsnPair*)nextPair())) pair->Print();
162 AliRsnMonitor *monitor = 0;
163 TObjArrayIter nextMonitor(&fMonitors);
164 while ((monitor = (AliRsnMonitor*)nextMonitor())) monitor->Print();
166 AliDebug(AliLog::kDebug + 2, "->");
169 //_____________________________________________________________________________
170 void AliRsnAnalysisManager::InitAllPairs(TList *list)
173 // Initialize all pair managers, and put all the TList of histograms
174 // generated by each one into a unique final output TList
180 AliRsnPair *pair = 0;
181 TObjArrayIter nextPair(&fPairs);
182 while ((pair = (AliRsnPair*)nextPair())) {
183 AliDebug(AliLog::kDebug + 1, Form("InitAllPairs of the PairManager(%s) [%d] ...", pair->GetName(), i++));
184 pair->Init(GetName(), list);
186 // add a counter for used/unused events for each pair
188 TH1I *hPairUsed = new TH1I(Form("%s_%s_USED", GetName(), pair->GetName()), "Used events for pair", 2, 0, 2);
189 list->Add(hPairUsed);
195 AliRsnMonitor *monitor = 0;
196 TObjArrayIter nextMonitor(&fMonitors);
197 while ((monitor = (AliRsnMonitor*)nextMonitor())) {
198 AliDebug(AliLog::kDebug + 1, Form("InitAllPairs of the PairManager(%s) [%d] ...", monitor->GetName(), i++));
199 monitor->Init(GetName(), list);
207 //_____________________________________________________________________________
208 void AliRsnAnalysisManager::ProcessAll(Bool_t pureMC)
211 // Loop on all pairs/monitors stored here
212 // and process all candidate daughters.
215 AliDebug(AliLog::kDebug + 2, "<-");
217 // don't do anything if the output list isn't initialized
220 // skip if the global event pointers are NULL
221 if (!AliRsnEvent::IsCurrentEvent1()) return;
222 if (!AliRsnEvent::IsCurrentEvent2()) return;
224 // for better readability, reference two pointers to the current events
225 AliRsnEvent *ev0 = AliRsnEvent::GetCurrentEvent1();
226 AliRsnEvent *ev1 = AliRsnEvent::GetCurrentEvent2();
228 // if MC reference is absent, cannot process pure MC
229 if (pureMC && (!ev0->GetRefMC() || !ev1->GetRefMC())) {
230 AliError("Cannot process a pure MC analysis without MC references!");
234 // count total number of candidates per event
235 // (sum of tracks, V0s and cascades)
238 nTot[0] = ev0->GetRefMC()->GetNumberOfTracks();
239 nTot[1] = ev1->GetRefMC()->GetNumberOfTracks();
241 nTot[0] = AliRsnEvent::GetCurrentEvent1()->GetAbsoluteSum();
242 nTot[1] = AliRsnEvent::GetCurrentEvent2()->GetAbsoluteSum();
246 Int_t i0, i1, i, start;
247 AliRsnDaughter daughter0, daughter1;
248 AliRsnPair *pair = 0x0;
249 AliRsnMonitor *monitor = 0x0;
250 TObjArrayIter nextPair(&fPairs);
251 TObjArrayIter nextMonitor(&fMonitors);
253 // reset all counters which tell us
254 // how many entries were added now
255 while ((pair = (AliRsnPair*)nextPair())) {
260 for (i0 = 0; i0 < nTot[0]; i0++) {
262 // try to assign first track
263 // and check global cuts
264 // in case of ESD pure MC, skip not physical primaries
266 if (ev0->IsESD()) if (!ev0->GetRefMCESD()->Stack()->IsPhysicalPrimary(i0)) continue;
267 if (!ev0->SetDaughterMC(daughter0, i0)) continue;
269 if (!ev0->SetDaughterAbs(daughter0, i0)) continue;
271 if (!fGlobalTrackCuts.IsSelected(&daughter0)) continue;
273 // process all single-track monitors
275 while ((monitor = (AliRsnMonitor*)nextMonitor())) if (monitor->Fill(&daughter0)) monitor->Compute();
277 // define start of inner loop depending if we are processing one or two events
278 start = (AliRsnEvent::SameEvent() ? i0 + 1 : 0);
280 // internal loop (same criterion)
281 for (i1 = start; i1 < nTot[1]; i1++) {
283 // try to assign first track
284 // and check global cuts
285 // in case of ESD pure MC, skip not physical primaries
287 if (ev1->IsESD()) if (!ev1->GetRefMCESD()->Stack()->IsPhysicalPrimary(i1)) continue;
288 if (!ev1->SetDaughterMC(daughter1, i1)) continue;
290 if (!ev1->SetDaughterAbs(daughter1, i1)) continue;
292 if (!fGlobalTrackCuts.IsSelected(&daughter1)) continue;
294 // loop over all pairs and make computations
297 while ((pair = (AliRsnPair*)nextPair())) {
300 AliDebug(AliLog::kDebug + 1, Form("ProcessAllPairs of the AnalysisManager(%s) [%d] ...", pair->GetName(), i++));
302 // process the two tracks
303 // the Fill() method returns kTRUE if the two daughters
304 // do match the pair definition of each AliRsnPait object,
305 // and the pair is processed only in this case
306 if (pair->Fill(&daughter0, &daughter1)) {
308 } else if (pair->Fill(&daughter1, &daughter0)) {
315 // update all count histograms counters
318 while ((pair = (AliRsnPair*)nextPair())) {
319 TH1I *hist = (TH1I*)fList->FindObject(Form("%s_%s_USED", GetName(), pair->GetName()));
321 if (pair->GetCount() > 0) hist->Fill(1); else hist->Fill(0);
325 AliDebug(AliLog::kDebug + 2, "->");