]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG2/RESONANCES/AliRsnAnalysisTask2ndStep.cxx
removed external class
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnAnalysisTask2ndStep.cxx
CommitLineData
aec0ec32 1//
2// Class AliRsnAnalysisTask2ndStep
3//
4// TODO
5//
6// authors: Martin Vala (martin.vala@cern.ch)
7// Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
8//
9#include <TTree.h>
10#include <TChain.h>
11#include <TH1F.h>
12#include <TList.h>
13#include <TObjArray.h>
14
15#include "AliLog.h"
16
17#include "AliAODEvent.h"
18#include "AliAODInputHandler.h"
19#include "AliAnalysisManager.h"
20#include "AliAnalysisTaskSE.h"
21
22#include "AliRsnEvent.h"
23#include "AliRsnPair.h"
24#include "AliRsnPairMgr.h"
25
26#include "AliRsnAnalysisTask2ndStep.h"
27
28ClassImp(AliRsnAnalysisTask2ndStep)
29
30//_____________________________________________________________________________
31AliRsnAnalysisTask2ndStep::AliRsnAnalysisTask2ndStep(const char *name) :
e0baff8c 32 AliAnalysisTaskSE(name),
33 fOutList(0x0),
34 fPairMgrs(0x0),
35 fEventBuffer(0x0),
36 fRsnHandlerAOD(0x0),
37 fAnalysisMgr(0x0)
aec0ec32 38{
39//
40// Default constructor
41//
42
e0baff8c 43 DefineOutput(1, TList::Class());
aec0ec32 44}
45
46//_____________________________________________________________________________
47void AliRsnAnalysisTask2ndStep::CreateHandlers(AliAnalysisManager* am)
48{
49//
50// Sets the handlers.
51//
52
e0baff8c 53 fAnalysisMgr = am;
54 if (!fAnalysisMgr)
55 {
56 AliWarning("Passed a NULL AnalysisManager!");
57 return;
58 }
59
60 // this task is made only for building histograms from
61 // a set of RSN events saved as non-standard branches in AOD tree
62 fRsnHandlerAOD = new AliAODInputHandler();
63 if (fRsnHandlerAOD) fAnalysisMgr->SetInputEventHandler(fRsnHandlerAOD);
aec0ec32 64}
65
66//_____________________________________________________________________________
67void AliRsnAnalysisTask2ndStep::UserCreateOutputObjects()
68{
69//
70// Creates output objects, as a TList of all histograms
71//
e0baff8c 72 AliInfo("--->");
73
74 //OpenFile (1);
75 if (fOutList)
76 {
77 fOutList->Clear();
78 delete fOutList;
79 }
80 fOutList = new TList();
81 fOutList->SetOwner();
82 AliRsnPairMgr *pairMgr = 0x0;
83 AliRsnPair *pair = 0x0;
84
85 if (!fPairMgrs)
86 {
87 AliError("No pair managers defined!");
88 return;
89 }
90
91 TObjArrayIter next(fPairMgrs);
92 while ((pairMgr = (AliRsnPairMgr*)next()))
93 {
94 TList *listTmp = new TList();
95 listTmp->SetName(pairMgr->GetName());
96 TObjArrayIter nextPair(pairMgr->GetPairs());
97 while ((pair = (AliRsnPair*)nextPair()))
98 {
99 pair->Init();
100 //pair->Print();
101 pair->GenerateHistograms(pairMgr->GetName(), listTmp);
102 //listTmp->Add(pair->GenerateHistograms(pairMgr->GetName()));
103 //fOutList->Add(listTmp);
aec0ec32 104 }
e0baff8c 105 fOutList->Add(listTmp);
106 }
107 fEventBuffer = new AliRsnEventBuffer(1000);
108
109 AliInfo("<---");
aec0ec32 110}
111
112//_____________________________________________________________________________
113void AliRsnAnalysisTask2ndStep::UserExec(Option_t *)
114{
115//
116// Executes the task
117//
e0baff8c 118
119 if (fEntry++ % 1000 == 0) AliInfo(Form("Event %d",-1));
120
121 // retrieve AOD
122 AliAODEvent *aod = dynamic_cast<AliAODEvent*>(fInputEvent);
123
124 // find RSN event
125 AliRsnEvent *rsn = (AliRsnEvent*)(aod->GetList()->FindObject("rsnEvents"));
126
127 // execute analysis
128 ProcessEventAnalysis(rsn);
129 PostEventProcess();
130
131 PostData(1, fOutList);
aec0ec32 132}
133
134//_____________________________________________________________________________
135void AliRsnAnalysisTask2ndStep::Terminate(Option_t *)
136{
137//
138// A simple check on the output list
139//
140
e0baff8c 141 fOutList = dynamic_cast<TList*>(GetOutputData(1));
142 if (!fOutList) { AliError("--- Output list not available ---"); return; }
143 fOutList->Print();
aec0ec32 144}
145
146//_____________________________________________________________________________
147void AliRsnAnalysisTask2ndStep::ProcessEventAnalysis(AliRsnEvent *curEvent)
148{
149//
150// Process of one event
151//
152
e0baff8c 153 // Adds event to Event Buffer
154 fEventBuffer->AddEvent(curEvent);
155
156 // loop over all Pair managers
157 AliRsnPair *pair = 0;
158 AliRsnPairMgr *mgr = 0;
159 TObjArrayIter nextMgr(fPairMgrs);
160 while ((mgr = (AliRsnPairMgr*)nextMgr()))
161 {
162 TObjArrayIter nextPair(mgr->GetPairs());
163 while ((pair = (AliRsnPair*)nextPair()))
164 {
165 pair->ProcessPair(fEventBuffer);
aec0ec32 166 }
e0baff8c 167 }
aec0ec32 168}
169
170//_____________________________________________________________________________
171void AliRsnAnalysisTask2ndStep::PostEventProcess()
172{
173//
174// Some work done after event processing
175//
176
177}
178
179//_____________________________________________________________________________
180void AliRsnAnalysisTask2ndStep::AddPairMgr(AliRsnPairMgr *pairmgr)
181{
e0baff8c 182 if (!fPairMgrs) fPairMgrs = new TObjArray;
183 fPairMgrs->Add(pairmgr);
aec0ec32 184}