2 // Class AliRsnAnalysisSE
6 // authors: Martin Vala (martin.vala@cern.ch)
7 // Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
16 #include "AliAnalysisManager.h"
17 #include "AliRsnPairMgr.h"
18 #include "AliRsnEventBuffer.h"
20 #include "AliMCEventHandler.h"
21 #include "AliESDEvent.h"
23 #include "AliRsnAnalysisSE.h"
25 ClassImp(AliRsnAnalysisSE)
27 //________________________________________________________________________
28 AliRsnAnalysisSE::AliRsnAnalysisSE(const char * name)
29 : AliRsnAnalysisTaskSEBase(name),
30 fPairMgrs(0),fOutList(0x0),fRsnEventBuffer(0x0),
31 fNumOfEventsInBuffer(1000)
33 //=========================================================
34 // Default constructor
35 //=========================================================
38 DefineOutput(1, TList::Class());
41 //________________________________________________________________________
42 AliRsnAnalysisSE::~AliRsnAnalysisSE()
44 //=========================================================
46 //=========================================================
49 //________________________________________________________________________
50 void AliRsnAnalysisSE::InitIOVars()
52 //=========================================================
53 // Init input output values
54 //=========================================================
56 AliDebug(AliLog::kDebug, "<-");
57 AliRsnAnalysisTaskSEBase::InitIOVars();
62 AliDebug(AliLog::kDebug, "->");
65 //________________________________________________________________________
66 void AliRsnAnalysisSE::UserCreateOutputObjects()
68 //=========================================================
69 // UserCreateOutputObjects() of AliAnalysisTaskSE
70 //=========================================================
72 AliDebug(AliLog::kDebug, "<-");
75 fOutList = new TList();
80 for (Int_t iMgr=0 ;iMgr< fPairMgrs.GetEntries();iMgr++)
82 mgr = (AliRsnPairMgr *) fPairMgrs.At(iMgr);
84 listTmp = new TList();
85 listTmp->SetName(mgr->GetName());
86 for (Int_t i=0;i< mgr->GetPairs()->GetEntriesFast();i++)
88 def = (AliRsnPair *) mgr->GetPairs()->At(i);
92 listTmp->Add(def->GenerateHistograms(mgr->GetName()));
93 //def->GenerateHistograms(mgr->GetName(), listTmp);
97 fOutList->Add(listTmp);
100 fRsnEventBuffer = new AliRsnEventBuffer(1000);
101 // fRsnEventBuffer = new AliRsnEventBuffer ( 10000 ,kFALSE );
102 AliDebug(AliLog::kDebug, "->");
106 //________________________________________________________________________
107 void AliRsnAnalysisSE::UserExec(Option_t *)
109 //=========================================================
110 // UserExec() of AliAnalysisTaskSE
111 //=========================================================
113 if (fEntry++%1000==0)
114 AliInfo(Form("Event %d",fEntry-1));
116 AliRsnEvent *curEvent = GetRsnEventFromInputType();
117 if (!curEvent) return;
119 ProcessEventAnalysis(curEvent);
122 PostData(1, fOutList);
125 //________________________________________________________________________
126 void AliRsnAnalysisSE::Terminate(Option_t *)
128 //=========================================================
129 // Terminate() of AliAnalysisTask
130 //=========================================================
132 fOutList = dynamic_cast<TList*>(GetOutputData(1));
133 if (!fOutList) { AliError(" fOutList not available"); return; }
137 //________________________________________________________________________
138 void AliRsnAnalysisSE::ProcessEventAnalysis(AliRsnEvent *curEvent)
140 //=========================================================
141 // Process of one event
142 //=========================================================
145 // Adds event to Event Buffer
146 fRsnEventBuffer->AddEvent(curEvent);
148 // loop over all Pair managers
149 AliRsnPairMgr *mgr=0;
150 for (Int_t iMgr=0 ;iMgr< fPairMgrs.GetEntries();iMgr++)
152 mgr = (AliRsnPairMgr *) fPairMgrs.At(iMgr);
154 for (Int_t i=0;i< mgr->GetPairs()->GetEntriesFast();i++)
156 pair = (AliRsnPair *) mgr->GetPairs()->At(i);
157 pair->ProcessPair(fRsnEventBuffer);
162 //________________________________________________________________________
163 void AliRsnAnalysisSE::PostEventProcess(const Short_t & index)
165 //=========================================================
166 // Post process of one event
167 //=========================================================
169 switch (fInputType[index])
181 if (fRsnEventBuffer->GetDeleteBufferWhenReset() == kFALSE)
183 fRSN[index] = (AliRsnEvent*) fRsnEventBuffer->GetNextEvent();
184 SetBranchAddress(0 , "rsnEvents", &fRSN[index]);
194 void AliRsnAnalysisSE::AddPairMgr(AliRsnPairMgr * pairmgr)
196 fPairMgrs.Add(pairmgr);