]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG4/PartCorrBase/AliAnaPartCorrMaker.cxx
Fix for improper corrections from revision 30849
[u/mrichter/AliRoot.git] / PWG4 / PartCorrBase / AliAnaPartCorrMaker.cxx
CommitLineData
1c5acb87 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15/* $Id: $ */
16
17//_________________________________________________________________________
18// Steering class for particle (gamma, hadron) identification and correlation analysis
19// It is called by the task class AliAnalysisTaskParticleCorrelation and it connects the input
20// (ESD/AOD/MonteCarlo) got with AliCaloTrackReader (produces TClonesArrays of AODs
21// (TParticles in MC case if requested)), with the
22// analysis classes that derive from AliAnaPartCorrBaseClass
23//
24// -- Author: Gustavo Conesa (INFN-LNF)
25
26// --- ROOT system ---
27class TClonesArray;
28class TString ;
29//#include "Riostream.h"
30
31//---- AliRoot system ----
32#include "AliAnaPartCorrBaseClass.h"
33#include "AliAnaPartCorrMaker.h"
34#include "AliCaloTrackReader.h"
35#include "AliLog.h"
36
37
38ClassImp(AliAnaPartCorrMaker)
39
40
41//____________________________________________________________________________
42AliAnaPartCorrMaker::AliAnaPartCorrMaker() :
43TObject(),
44fOutputContainer(new TList ), fAnalysisContainer(new TList ),
45fMakeHisto(0), fMakeAOD(0), fAnaDebug(0),
46fReader(0x0), fAODBranchList(new TList )
47{
48 //Default Ctor
49 if(fAnaDebug > 1 ) printf("*** Analysis Maker Constructor *** \n");
50
51 //Initialize parameters, pointers and histograms
52 if(!fReader)
53 fReader = new AliCaloTrackReader();
54
55 InitParameters();
56}
57
58//____________________________________________________________________________
59AliAnaPartCorrMaker::AliAnaPartCorrMaker(const AliAnaPartCorrMaker & g) :
60TObject(),
61fOutputContainer(g. fOutputContainer), fAnalysisContainer(g.fAnalysisContainer),
62fMakeHisto(g.fMakeHisto), fMakeAOD(fMakeAOD), fAnaDebug(g. fAnaDebug),
63fReader(g.fReader), fAODBranchList(g.fAODBranchList)
64{
65 // cpy ctor
66
67}
68
69//_________________________________________________________________________
70AliAnaPartCorrMaker & AliAnaPartCorrMaker::operator = (const AliAnaPartCorrMaker & source)
71{
72 // assignment operator
73
74 if(this == &source)return *this;
75 ((TObject *)this)->operator=(source);
76
77 fOutputContainer = source.fOutputContainer ;
78 fAnalysisContainer = source.fAnalysisContainer ;
79 fAnaDebug = source.fAnaDebug;
80 fMakeHisto = source.fMakeHisto;
81 fMakeAOD = source.fMakeAOD;
82
83 fReader = source.fReader ;
84 fAODBranchList = source.fAODBranchList;
85
86 return *this;
87
88}
89
90//____________________________________________________________________________
91AliAnaPartCorrMaker::~AliAnaPartCorrMaker()
92{
93 // Remove all pointers.
94
95 // Protection added in case of NULL pointers (MG)
96 if (fOutputContainer) {
97 fOutputContainer->Clear();
98 delete fOutputContainer ;
99 }
100
101 if (fAnalysisContainer) {
102 fAnalysisContainer->Clear();
103 delete fAnalysisContainer ;
104 }
105
106 if (fReader) delete fReader ;
107
108
109 if(fAODBranchList){
110// for(Int_t iaod = 0; iaod < fAODBranchList->GetEntries(); iaod++)
111// fAODBranchList->At(iaod)->Clear();
112
113 fAODBranchList->Clear();
114 delete fAODBranchList ;
115 }
116
117}
118
119//________________________________________________________________________
120TList * AliAnaPartCorrMaker::GetAODBranchList()
121{
122
123// Get any new output AOD branches from analysis and put them in a list
124// The list is filled in the maker, and new branch passed to the analysis frame
125// AliAnalysisTaskPartCorr
126
127 for(Int_t iana = 0; iana < fAnalysisContainer->GetEntries(); iana++){
128
129 AliAnaPartCorrBaseClass * ana = ((AliAnaPartCorrBaseClass *) fAnalysisContainer->At(iana)) ;
130 if(ana->NewOutputAOD()) fAODBranchList->Add(ana->GetCreateOutputAODBranch());
131 }
132
133 return fAODBranchList ;
134
135}
136
137//________________________________________________________________________
138void AliAnaPartCorrMaker::Init()
139{
140 //Init container histograms and other common variables
141
142 if(!fAnalysisContainer || fAnalysisContainer->GetEntries()==0)
143 AliFatal("Analysis job list not initialized");
144
145 for(Int_t iana = 0; iana < fAnalysisContainer->GetEntries(); iana++){
146
147 AliAnaPartCorrBaseClass * ana = ((AliAnaPartCorrBaseClass *) fAnalysisContainer->At(iana)) ;
148 ana->SetReader(fReader); //SetReader for each analysis
149 ana->Init();
150
151 if(fMakeHisto){// Analysis with histograms as output on
152 //Fill container with appropriate histograms
153 TList * templist = ana -> GetCreateOutputObjects();
154 for(Int_t i = 0; i < templist->GetEntries(); i++)
155 fOutputContainer->Add(templist->At(i)) ;
156 }// Analysis with histograms as output on
157 }//Loop on analysis defined
158}
159
160//____________________________________________________________________________
161void AliAnaPartCorrMaker::InitParameters()
162{
163
164 //Init data members
165 fMakeHisto = kTRUE;
166 fMakeAOD = kTRUE;
167 fAnaDebug = 0; // No debugging info displayed by default
168
169}
170
171//__________________________________________________________________
172void AliAnaPartCorrMaker::Print(const Option_t * opt) const
173{
174
175 //Print some relevant parameters set for the analysis
176 if(! opt)
177 return;
178
179 printf("***** Print: %s %s ******\n", GetName(), GetTitle() ) ;
180 printf("Debug level = %d\n", fAnaDebug) ;
181 printf("Produce Histo = %d\n", fMakeHisto) ;
182 printf("Produce AOD = %d\n", fMakeAOD) ;
183
184}
185
186
187//____________________________________________________________________________
188Bool_t AliAnaPartCorrMaker::ProcessEvent(Int_t iEntry){
189 //Process analysis for this event
190
191 if(fMakeHisto && !fOutputContainer)
192 AliFatal("Histograms not initialized");
193
194 if(fAnaDebug >= 0 ) printf("*** Event %d *** \n",iEntry);
195
196 //Each event needs an empty branch
197 for(Int_t iaod = 0; iaod < fAODBranchList->GetEntries(); iaod++)
198 fAODBranchList->At(iaod)->Clear();
199
200 //Tell the reader to fill the data in the 3 detector lists
6639984f 201 fReader->FillInputEvent(iEntry);
1c5acb87 202
203 //Loop on analysis algorithms
204 if(fAnaDebug > 0 ) printf("*** Begin analysis *** \n");
205 Int_t nana = fAnalysisContainer->GetEntries() ;
206 for(Int_t iana = 0; iana < nana; iana++){
207
208 AliAnaPartCorrBaseClass * ana = ((AliAnaPartCorrBaseClass *) fAnalysisContainer->At(iana)) ;
209
210 ana->ConnectInputOutputAODBranches(); //Sets branches for each analysis
211
212 //Make analysis, create aods in aod branch or AODCaloClusters
213 if(fMakeAOD) ana->MakeAnalysisFillAOD() ;
214 //Make further analysis with aod branch and fill histograms
215 if(fMakeHisto) ana->MakeAnalysisFillHistograms() ;
216
217 }
218
219 fReader->ResetLists();
220
221 if(fAnaDebug > 0 ) printf("*** End analysis *** \n");
222
223 return kTRUE ;
224
225}
6639984f 226
227//________________________________________________________________________
228void AliAnaPartCorrMaker::Terminate()
229{
230 //Execute Terminate of analysis
231 //Do some final plots.
232
233 for(Int_t iana = 0; iana < fAnalysisContainer->GetEntries(); iana++){
234
235 AliAnaPartCorrBaseClass * ana = ((AliAnaPartCorrBaseClass *) fAnalysisContainer->At(iana)) ;
236 ana->Terminate();
237
238 }//Loop on analysis defined
239}