]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG4/PartCorrBase/AliAnaPartCorrMaker.cxx
add a histogram counting the analyzed number of events
[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
fbeaf916 26#include <cstdlib>
27
1c5acb87 28// --- ROOT system ---
477d6cee 29#include "TClonesArray.h"
477d6cee 30#include "TList.h"
031ac63e 31#include "TH1I.h"
1c5acb87 32//#include "Riostream.h"
1d4cea01 33//#include <TObjectTable.h>
1c5acb87 34
35//---- AliRoot system ----
36#include "AliAnaPartCorrBaseClass.h"
37#include "AliAnaPartCorrMaker.h"
38#include "AliCaloTrackReader.h"
1c5acb87 39
40
41ClassImp(AliAnaPartCorrMaker)
42
43
44//____________________________________________________________________________
45AliAnaPartCorrMaker::AliAnaPartCorrMaker() :
46TObject(),
47fOutputContainer(new TList ), fAnalysisContainer(new TList ),
48fMakeHisto(0), fMakeAOD(0), fAnaDebug(0),
031ac63e 49fReader(0x0), fAODBranchList(new TList ),
50fhNEvents(0x0)
1c5acb87 51{
477d6cee 52 //Default Ctor
53 if(fAnaDebug > 1 ) printf("*** Analysis Maker Constructor *** \n");
54
55 //Initialize parameters, pointers and histograms
56 if(!fReader)
57 fReader = new AliCaloTrackReader();
58
59 InitParameters();
1c5acb87 60}
61
62//____________________________________________________________________________
d151d2ee 63AliAnaPartCorrMaker::AliAnaPartCorrMaker(const AliAnaPartCorrMaker & maker) :
1c5acb87 64TObject(),
d151d2ee 65fOutputContainer(new TList()), fAnalysisContainer(new TList()),
66fMakeHisto(maker.fMakeHisto), fMakeAOD(maker.fMakeAOD), fAnaDebug(maker.fAnaDebug),
031ac63e 67fReader(new AliCaloTrackReader(*maker.fReader)), fAODBranchList(new TList()),
68fhNEvents(maker.fhNEvents)
1c5acb87 69{
477d6cee 70 // cpy ctor
1c5acb87 71
72}
73
74//_________________________________________________________________________
d151d2ee 75//AliAnaPartCorrMaker & AliAnaPartCorrMaker::operator = (const AliAnaPartCorrMaker & source)
76//{
77// // assignment operator
78//
79// if(this == &source)return *this;
80// ((TObject *)this)->operator=(source);
81//
82// delete fOutputContainer; fOutputContainer = source.fOutputContainer ;
83// delete fAnalysisContainer; fAnalysisContainer = source.fAnalysisContainer ;
84// fAnaDebug = source.fAnaDebug;
85// fMakeHisto = source.fMakeHisto;
86// fMakeAOD = source.fMakeAOD;
87//
88// delete fReader ; fReader = new AliCaloTrackReader(*source.fReader) ;
89// delete fAODBranchList; fAODBranchList = source.fAODBranchList;
90//
91// return *this;
92//
93//}
1c5acb87 94
95//____________________________________________________________________________
96AliAnaPartCorrMaker::~AliAnaPartCorrMaker()
97{
477d6cee 98 // Remove all pointers.
99
100 // Protection added in case of NULL pointers (MG)
101 if (fOutputContainer) {
102 fOutputContainer->Clear();
103 delete fOutputContainer ;
104 }
105
106 if (fAnalysisContainer) {
107 fAnalysisContainer->Clear();
108 delete fAnalysisContainer ;
109 }
110
111 if (fReader) delete fReader ;
112
113
114 if(fAODBranchList){
1c5acb87 115// for(Int_t iaod = 0; iaod < fAODBranchList->GetEntries(); iaod++)
116// fAODBranchList->At(iaod)->Clear();
117
477d6cee 118 fAODBranchList->Clear();
119 delete fAODBranchList ;
120 }
121
1c5acb87 122}
123
124//________________________________________________________________________
125TList * AliAnaPartCorrMaker::GetAODBranchList()
126{
127
128// Get any new output AOD branches from analysis and put them in a list
129// The list is filled in the maker, and new branch passed to the analysis frame
130// AliAnalysisTaskPartCorr
131
477d6cee 132 for(Int_t iana = 0; iana < fAnalysisContainer->GetEntries(); iana++){
133
134 AliAnaPartCorrBaseClass * ana = ((AliAnaPartCorrBaseClass *) fAnalysisContainer->At(iana)) ;
135 if(ana->NewOutputAOD()) fAODBranchList->Add(ana->GetCreateOutputAODBranch());
136 }
137
138 return fAODBranchList ;
139
1c5acb87 140}
141
2e557d1c 142//________________________________________________________________________
143TList *AliAnaPartCorrMaker::GetOutputContainer()
144{
145// Fill the output list of histograms during the CreateOutputObjects stage.
477d6cee 146 if(!fAnalysisContainer || fAnalysisContainer->GetEntries()==0){
a8a55c9d 147 printf("AliAnaPartCorrMaker::GetOutputContainer() - Analysis job list not initialized!!!\n");
148 //abort();
477d6cee 149 }
a3aebfff 150
151 char newname[128];
477d6cee 152 for(Int_t iana = 0; iana < fAnalysisContainer->GetEntries(); iana++){
153 AliAnaPartCorrBaseClass * ana = ((AliAnaPartCorrBaseClass *) fAnalysisContainer->At(iana)) ;
154 if(fMakeHisto){// Analysis with histograms as output on
155 //Fill container with appropriate histograms
156 TList * templist = ana -> GetCreateOutputObjects();
a3aebfff 157 for(Int_t i = 0; i < templist->GetEntries(); i++){
158
159 //Add only to the histogram name the name of the task
160 if( strcmp((templist->At(i))->ClassName(),"TObjString") ) {
161 sprintf(newname,"%s%s", (ana->GetAddedHistogramsStringToName()).Data(), (templist->At(i))->GetName());
162 ((TH1*) templist->At(i))->SetName(newname);
163 }
164 //Add histogram to general container
477d6cee 165 fOutputContainer->Add(templist->At(i)) ;
a3aebfff 166 }
477d6cee 167 }// Analysis with histograms as output on
168 }//Loop on analysis defined
a3aebfff 169
031ac63e 170
171 fhNEvents = new TH1I("hNEvents", "Number of analyzed events" , 1 , 0 , 1 ) ;
172 fOutputContainer->Add(fhNEvents);
173
477d6cee 174 return fOutputContainer;
a3aebfff 175
2e557d1c 176}
177
1c5acb87 178//________________________________________________________________________
179void AliAnaPartCorrMaker::Init()
180{
477d6cee 181 //Init container histograms and other common variables
182 // Fill the output list of histograms during the CreateOutputObjects stage.
183
184 if(!fAnalysisContainer || fAnalysisContainer->GetEntries()==0){
a8a55c9d 185 printf("AliAnaPartCorrMaker::GetOutputInit() - Analysis job list not initialized!!!\n");
186 //abort();
477d6cee 187 }
591cc579 188
189 //Initialize reader
190 fReader->Init();
191
477d6cee 192 for(Int_t iana = 0; iana < fAnalysisContainer->GetEntries(); iana++){
193
194 AliAnaPartCorrBaseClass * ana = ((AliAnaPartCorrBaseClass *) fAnalysisContainer->At(iana)) ;
195 ana->SetReader(fReader); //SetReader for each analysis
196 ana->Init();
197
198 }//Loop on analysis defined
1c5acb87 199}
200
201//____________________________________________________________________________
202void AliAnaPartCorrMaker::InitParameters()
477d6cee 203{
204 //Init data members
205
206 fMakeHisto = kTRUE;
207 fMakeAOD = kTRUE;
208 fAnaDebug = 0; // No debugging info displayed by default
591cc579 209
1c5acb87 210}
211
212//__________________________________________________________________
213void AliAnaPartCorrMaker::Print(const Option_t * opt) const
477d6cee 214{
215 //Print some relevant parameters set for the analysis
216
217 if(! opt)
218 return;
219
220 printf("***** Print: %s %s ******\n", GetName(), GetTitle() ) ;
221 printf("Debug level = %d\n", fAnaDebug) ;
222 printf("Produce Histo = %d\n", fMakeHisto) ;
223 printf("Produce AOD = %d\n", fMakeAOD) ;
591cc579 224
1c5acb87 225}
226
227
228//____________________________________________________________________________
29b2ceec 229void AliAnaPartCorrMaker::ProcessEvent(const Int_t iEntry, const char * currentFileName){
477d6cee 230 //Process analysis for this event
231
232 if(fMakeHisto && !fOutputContainer){
233 printf("AliAnaPartCorrMaker::ProcessEvent() - Histograms not initialized\n");
234 abort();
235 }
a79a2424 236
902aa95c 237 if(fAnaDebug >= 0 ){
a79a2424 238 printf("*** Event %d *** \n",iEntry);
902aa95c 239 if(fAnaDebug > 1 ) {
240 printf("AliAnaPartCorrMaker::ProcessEvent() - Current File Name : %s\n", currentFileName);
241 //printf("fAODBranchList %p, entries %d\n",fAODBranchList,fAODBranchList->GetEntries());
242 }
a79a2424 243 }
902aa95c 244 //Each event needs an empty branch
245 Int_t nAODBranches = fAODBranchList->GetEntries();
4a745797 246 for(Int_t iaod = 0; iaod < nAODBranches; iaod++){
247 //fAODBranchList->At(iaod)->Clear();
248 TClonesArray *tca = dynamic_cast<TClonesArray*> (fAODBranchList->At(iaod));
249 if(tca) tca->Delete();
250 }
902aa95c 251
477d6cee 252 //Tell the reader to fill the data in the 3 detector lists
29b2ceec 253 Bool_t ok = fReader->FillInputEvent(iEntry, currentFileName);
254 if(!ok){
72d2488e 255 if(fAnaDebug >= 1 )printf("*** Skip event *** %d \n",iEntry);
29b2ceec 256 return ;
257 }
902aa95c 258
1d4cea01 259 //printf(">>>>>>>>>> BEFORE >>>>>>>>>>>\n");
260 //gObjectTable->Print();
477d6cee 261 //Loop on analysis algorithms
262 if(fAnaDebug > 0 ) printf("*** Begin analysis *** \n");
263 Int_t nana = fAnalysisContainer->GetEntries() ;
264 for(Int_t iana = 0; iana < nana; iana++){
265 AliAnaPartCorrBaseClass * ana = ((AliAnaPartCorrBaseClass *) fAnalysisContainer->At(iana)) ;
1e86c71e 266
267 ana->ConnectInputOutputAODBranches(); //Sets branches for each analysis
477d6cee 268 //Make analysis, create aods in aod branch or AODCaloClusters
1e86c71e 269 if(fMakeAOD) ana->MakeAnalysisFillAOD() ;
477d6cee 270 //Make further analysis with aod branch and fill histograms
271 if(fMakeHisto) ana->MakeAnalysisFillHistograms() ;
272
273 }
031ac63e 274
275 fhNEvents->Fill(0); //Event analyzed
276
477d6cee 277 fReader->ResetLists();
278
1d4cea01 279 //printf(">>>>>>>>>> AFTER >>>>>>>>>>>\n");
280 //gObjectTable->Print();
5efec477 281
477d6cee 282 if(fAnaDebug > 0 ) printf("*** End analysis *** \n");
283
1c5acb87 284}
6639984f 285
286//________________________________________________________________________
a5cc4f03 287void AliAnaPartCorrMaker::Terminate(TList * outputList)
6639984f 288{
477d6cee 289 //Execute Terminate of analysis
290 //Do some final plots.
291
a5cc4f03 292 if (!outputList) {
293 Error("Terminate", "No output list");
294 return;
295 }
296
477d6cee 297 for(Int_t iana = 0; iana < fAnalysisContainer->GetEntries(); iana++){
298
299 AliAnaPartCorrBaseClass * ana = ((AliAnaPartCorrBaseClass *) fAnalysisContainer->At(iana)) ;
a5cc4f03 300 ana->Terminate(outputList);
477d6cee 301
302 }//Loop on analysis defined
6639984f 303}