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