Fixed last warnings
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnComparisonAT.cxx
CommitLineData
aec0ec32 1//
2// Class AliRsnComparisonAT
3//
4// TODO
5//
6// authors: Martin Vala (martin.vala@cern.ch)
7// Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
8//
9#include "TChain.h"
10#include "TTree.h"
11#include "TH1F.h"
12#include "TFolder.h"
13#include "TCanvas.h"
14#include "TClonesArray.h"
15
16#include "AliLog.h"
17
18#include "AliESDtrack.h"
19#include "AliMCEvent.h"
20
21#include "AliRsnMCInfo.h"
22#include "AliRsnComparisonObj.h"
23#include "AliRsnComparisonAT.h"
24
25ClassImp(AliRsnComparisonAT)
26
27//________________________________________________________________________
28AliRsnComparisonAT::AliRsnComparisonAT(const char*name)
e0baff8c 29 : AliRsnAnalysisTaskBase(name),fOutList(0x0),fMyInputNum(1),fMyPIDInputNum(0)
aec0ec32 30{
31//=========================================================
32// Default constructor
33//=========================================================
34
35 InitIOVars();
36
37 DefineOutput(0, TList::Class());
38}
39
40//________________________________________________________________________
41void AliRsnComparisonAT::InitIOVars()
42{
43//=========================================================
44// Sets default values for input and output
45//=========================================================
46 AliDebug(AliLog::kDebug, "<-");
e0baff8c 47 AliRsnAnalysisTaskBase::InitIOVars();
aec0ec32 48 fOutList = 0;
49 AliDebug(AliLog::kDebug, "->");
50}
51
52//________________________________________________________________________
53void AliRsnComparisonAT::LocalInit()
54{
55//=========================================================
56// Local init
57//=========================================================
58}
59
60//________________________________________________________________________
61void AliRsnComparisonAT::CreateOutputObjects()
62{
63//=========================================================
64// CreateOutputObjects()
65//=========================================================
66 AliDebug(AliLog::kDebug, "<-");
67
68// AliRsnDaughter::SetPIDMethod ( AliRsnDaughter::kRealistic );
69// fReader = dynamic_cast<AliRsnReader*> ( GetInputData ( 1 ) );
70// fPID = dynamic_cast<AliRsnPID*> ( GetInputData ( 2 ) );
71
72
73 OpenFile(0);
74 fOutList = new TList();
75 AliRsnComparisonObj* obj;
76
77 TList *listMainParticle,*listMainPID,*listPID,*listParticle,*listTmp;
78
79 listMainParticle = new TList();
80 listMainParticle->SetName("MCParticles");
81 for (Int_t i=0;i<fMyInput[0].GetEntries();i++)
82 {
83 obj = (AliRsnComparisonObj*) fMyInput[0].At(i);
84 if (!obj) continue;
85 listParticle = obj->GenerateParticleInfoHistogramList("");
86 if (!listParticle)
87 {
88 AliError(Form("List not crated for i=%d",i));
89 continue;
90 }
91
92 listMainParticle->Add(listParticle);
93 }
94 fOutList->Add(listMainParticle);
95 if (fMyPIDInputNum>0)
96 {
97 listMainPID = new TList();
98 listMainPID->SetName("PID");
99 for (Int_t j=0;j<fMyPIDInputNum;j++)
100 {
101 listPID = new TList();
102 listPID->SetName(fMyPIDInput[j].GetName());
103 for (Int_t i=0;i<fMyPIDInput[j].GetEntries();i++)
104 {
105 obj = (AliRsnComparisonObj*) fMyPIDInput[j].At(i);
106 if (!obj) continue;
107 listTmp = obj->GeneratePIDHistogramList(fMyPIDInput[j].GetName());
108 if (!listTmp)
109 {
110 AliError(Form("List not crated for i=%d",i));
111 continue;
112 }
113 listPID->Add(listTmp);
114
115 }
116 listMainPID->Add(listPID);
117 }
118 fOutList->Add(listMainPID);
119// listMainPID->Print();
120 }
121 AliDebug(AliLog::kDebug, "->");
122}
123
124//________________________________________________________________________
125void AliRsnComparisonAT::Exec(Option_t *)
126{
127//=========================================================
128// Exec()
129//=========================================================
130
131 if (fInputType[0]==kESDMC)
132 {
133 fRSN[0] = GetRsnEventFromInputType(0);
134 LoopOverESDtracks();
135 LoopOverMCtracks();
136 }
137
138
139 if (!fRSN[0]) return;
140 LoopOverRSNDaughters();
141
142 if (fInputType[0]==kESDMC)
143 {
144 delete fRSN[0];
145 fRSN[0] = 0;
146 }
147
148// fNumEventsProcessed++;
149 PostData(0, fOutList);
150}
151
152//________________________________________________________________________
153void AliRsnComparisonAT::Terminate(Option_t *)
154{
155//=========================================================
156// Terminate()
157//=========================================================
158 AliDebug(AliLog::kDebug, "<-");
159 fOutList = dynamic_cast<TList*>(GetOutputData(0));
160 if (!fOutList)
161 {
162 AliError(" fOutList not available");
163 return;
164 }
165
166 AliDebug(AliLog::kDebug, "->");
167}
168
169//________________________________________________________________________
170void AliRsnComparisonAT::LoopOverESDtracks()
171{
172//=========================================================
173// Loop over all ESD tracks
174//=========================================================
175 if (!fESD[0]) return;
176// AliInfo(Form("%d",fESD[0]->GetNumberOfTracks()));
177 AliRsnComparisonObj* input=0;
178 for (Int_t i=0;i< fESD[0]->GetNumberOfTracks(); i++)
179 {
180 AliESDtrack *esdtrack = fESD[0]->GetTrack(i);
181 for (Int_t j=0;j<fMyInputNum;j++)
182 {
afafe970 183 for (Int_t k=0;i<fMyInput[j].GetEntries();k++)
aec0ec32 184 {
afafe970 185 input = (AliRsnComparisonObj*) fMyInput[j].At(k);
aec0ec32 186// input->FillPIDHistograms(esdtrack, fMC[0]);
187 }
188 }
189 for (Int_t j=0;j<fMyPIDInputNum;j++)
190 {
afafe970 191 for (Int_t k=0;i<fMyPIDInput[j].GetEntries();k++)
aec0ec32 192 {
afafe970 193 input = (AliRsnComparisonObj*) fMyPIDInput[j].At(k);
aec0ec32 194 input->FillPIDHistograms(esdtrack, fMC[0]);
195 }
196 }
197 }
198}
199
200//________________________________________________________________________
201void AliRsnComparisonAT::LoopOverMCtracks()
202{
203//=========================================================
204// Loop over all MC tracks
205//=========================================================
206
207 if (!fMC[0]) return;
208
209 AliRsnComparisonObj* input=0;
210 AliMCParticle *mctrack;
211 for (Int_t i=0;i<fMC[0]->GetNumberOfTracks(); i++)
212 {
213 mctrack = fMC[0]->GetTrack(i);
214 if (!mctrack) {AliInfo("mctrack == null");continue;}
215 for (Int_t j=0;j<fMyInputNum;j++)
216 {
afafe970 217 for (Int_t k=0;k<fMyInput[j].GetEntries();k++)
aec0ec32 218 {
afafe970 219 input = (AliRsnComparisonObj*) fMyInput[j].At(k);
aec0ec32 220 input->FillHistograms(mctrack);
221 }
222 }
223 for (Int_t j=0;j<fMyPIDInputNum;j++)
224 {
afafe970 225 for (Int_t k=0;k<fMyPIDInput[j].GetEntries();k++)
aec0ec32 226 {
afafe970 227 input = (AliRsnComparisonObj*) fMyPIDInput[j].At(k);
aec0ec32 228 input->FillPIDHistograms(mctrack);
229 }
230 }
231 }
232}
233
234//________________________________________________________________________
235void AliRsnComparisonAT::LoopOverRSNDaughters()
236{
237//=========================================================
238// Loop over all rsn daughters
239//=========================================================
240
241 TClonesArray *tracks = (TClonesArray*) fRSN[0]->GetTracks();
242 AliRsnDaughter *daughter=0;
243 AliRsnComparisonObj* input=0;
244 for (Int_t i=0;i< tracks->GetEntriesFast(); i++)
245 {
246 daughter = (AliRsnDaughter*) tracks->At(i);
247 for (Int_t j=0;j<fMyInputNum;j++)
248 {
afafe970 249 for (Int_t k=0;k<fMyInput[j].GetEntries();k++)
aec0ec32 250 {
afafe970 251 input = (AliRsnComparisonObj*) fMyInput[j].At(k);
aec0ec32 252// input->FillPIDHistograms(daughter);
253 }
254 }
255 for (Int_t j=0;j<fMyPIDInputNum;j++)
256 {
afafe970 257 for (Int_t k=0;k<fMyPIDInput[j].GetEntries();k++)
aec0ec32 258 {
afafe970 259 input = (AliRsnComparisonObj*) fMyPIDInput[j].At(k);
aec0ec32 260 input->FillPIDHistograms(daughter);
261 }
262 }
263 }
264}
265
266//________________________________________________________________________
267void AliRsnComparisonAT::PrintStat()
268{
269//=========================================================
270// Print stat
271//=========================================================
272 AliDebug(AliLog::kDebug, "<-");
273
274 AliDebug(AliLog::kDebug, "->");
275}
276
277void AliRsnComparisonAT::AddMyInput(AliRsnComparisonObj * obj, const Int_t & index)
278{
279// if ( ( index<0 ) || ( index>kMyInputNum ) ) return;
280
281 fMyInput[index].Add(obj);
282// AliInfo(Form("%d %s",fMyInput[index].GetEntries(),fMyInput[index].GetName()));
283}
284
285void AliRsnComparisonAT::AddMyPIDInput(AliRsnComparisonObj * obj, const Int_t & index)
286{
287// if ( ( index<0 ) || ( index>kMyInputNum ) ) return;
288
289 fMyPIDInput[index].Add(obj);
290// AliInfo(Form("%d %s",fMyInput[index].GetEntries(),fMyInput[index].GetName()));
291}
292
293void AliRsnComparisonAT::SetMyPIDInputName(TString name, const Int_t & index)
294{
295 fMyPIDInput[index].SetName(name.Data());
296}
297