1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
17 /* History of cvs commits:
24 //_________________________________________________________________________
25 // Base class for particle (gamma, hadron) identification and correlation analysis
26 // It is called by the task class AliAnalysisGammaTask and it connects the input
27 // (ESD/AOD/MonteCarlo)
28 // got with AliCaloTrackReader (produces TClonesArrays of TParticles), with the
29 // analysis classes that derive from AliAnaBaseClass
31 //*-- Author: Gustavo Conesa (INFN-LNF)
33 // --- ROOT system ---
35 //#include <TParticle.h>
38 //---- AliRoot system ----
39 #include "AliAnaBaseClass.h"
40 #include "AliAnaMaker.h"
41 #include "AliCaloTrackReader.h"
42 // #include "AliAODCaloCluster.h"
43 // #include "AliAODTrack.h"
44 // #include "AliAODEvent.h"
45 #include "Riostream.h"
51 //____________________________________________________________________________
52 AliAnaMaker::AliAnaMaker() :
54 fOutputContainer(new TList ), fAnalysisContainer(new TList ),
55 fMakeHisto(0), fMakeAOD(0), fAnaDebug(0),
56 fReader(0x0), fAODBranch(0x0), fAODBranchName("")
59 if(fAnaDebug > 1 ) printf("*** Analysis Maker Constructor *** \n");
61 //Initialize parameters, pointers and histograms
63 fReader = new AliCaloTrackReader();
68 //____________________________________________________________________________
69 AliAnaMaker::AliAnaMaker(const AliAnaMaker & g) :
71 fOutputContainer(g. fOutputContainer), fAnalysisContainer(g.fAnalysisContainer),
72 fMakeHisto(g.fMakeHisto), fMakeAOD(fMakeAOD), fAnaDebug(g. fAnaDebug),
73 fReader(g.fReader), fAODBranch(g.fAODBranch),
74 fAODBranchName(g.fAODBranchName)
80 //_________________________________________________________________________
81 AliAnaMaker & AliAnaMaker::operator = (const AliAnaMaker & source)
83 // assignment operator
85 if(this == &source)return *this;
86 ((TObject *)this)->operator=(source);
88 fOutputContainer = source.fOutputContainer ;
89 fAnalysisContainer = source.fAnalysisContainer ;
90 fAnaDebug = source.fAnaDebug;
91 fMakeHisto = source.fMakeHisto;
92 fMakeAOD = source.fMakeAOD;
94 fAODBranchName = source.fAODBranchName;
95 fAODBranch = source.fAODBranch;
97 fReader = source.fReader ;
103 //____________________________________________________________________________
104 AliAnaMaker::~AliAnaMaker()
106 // Remove all pointers.
108 // Protection added in case of NULL pointers (MG)
109 if (fOutputContainer) {
110 fOutputContainer->Clear();
111 delete fOutputContainer ;
114 if (fAnalysisContainer) {
115 fAnalysisContainer->Clear();
116 delete fAnalysisContainer ;
119 if (fReader) delete fReader ;
128 //________________________________________________________________________
129 void AliAnaMaker::Init()
131 //Init container histograms and other common variables
133 if(fMakeHisto){// Analysis with histograms as output on
135 //Fill container with appropriate histograms
137 if(!fAnalysisContainer || fAnalysisContainer->GetEntries()==0)
138 AliFatal("Analysis job list not initailized");
140 for(Int_t iana = 0; iana < fAnalysisContainer->GetEntries(); iana++){
141 TList * templist = ((AliAnaBaseClass *) fAnalysisContainer->At(iana)) -> GetCreateOutputObjects();
143 for(Int_t i = 0; i < templist->GetEntries(); i++)
144 fOutputContainer->Add(templist->At(i)) ;
147 }// Analysis with histograms as output on
150 //____________________________________________________________________________
151 void AliAnaMaker::InitParameters()
157 fAnaDebug = 0; // No debugging info displayed by default
158 fAODBranchName = "Photons" ;
162 //__________________________________________________________________
163 void AliAnaMaker::Print(const Option_t * opt) const
166 //Print some relevant parameters set for the analysis
170 printf("***** Print: %s %s ******\n", GetName(), GetTitle() ) ;
171 printf("Debug level = %d\n", fAnaDebug) ;
172 printf("New AOD branch = %s\n", fAODBranchName.Data()) ;
173 printf("Produce Histo = %d\n", fMakeHisto) ;
174 printf("Produce AOD = %d\n", fMakeAOD) ;
179 //____________________________________________________________________________
180 Bool_t AliAnaMaker::ProcessEvent(Int_t iEntry){
181 //Process analysis for this event
183 if(fMakeHisto && !fOutputContainer)
184 AliFatal("Histograms not initialized");
186 if(fAnaDebug >= 0 ) printf("*** Event %d *** \n",iEntry);
188 //Each event needs an empty branch
189 fAODBranch->Delete();
191 //Tell the reader to fill the data in the 3 detector lists
192 fReader->FillInputEvent();
194 //Loop on analysis algorithms
195 Int_t nana = fAnalysisContainer->GetEntries() ;
196 for(Int_t iana = 0; iana < nana; iana++){
198 AliAnaBaseClass * ana = ((AliAnaBaseClass *) fAnalysisContainer->At(iana)) ;
200 //Set reader and aod branch for each analysis
201 ana->SetReader(fReader);
202 ana->SetAODBranch(fAODBranch);
204 //Make analysis, create aods in aod branch or AODCaloClusters
205 if(fMakeAOD) ana->MakeAnalysisFillAOD() ;
206 //Make further analysis with aod branch and fill histograms
207 if(fMakeHisto) ana->MakeAnalysisFillHistograms() ;
211 fReader->ResetLists();