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 //_________________________________________________________________________
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
24 // -- Author: Gustavo Conesa (INFN-LNF)
28 // --- ROOT system ---
29 #include "TClonesArray.h"
32 //#include "Riostream.h"
33 #include <TObjectTable.h>
35 //---- AliRoot system ----
36 #include "AliAnaPartCorrBaseClass.h"
37 #include "AliAnaPartCorrMaker.h"
38 #include "AliCaloTrackReader.h"
41 ClassImp(AliAnaPartCorrMaker)
44 //____________________________________________________________________________
45 AliAnaPartCorrMaker::AliAnaPartCorrMaker() :
47 fOutputContainer(new TList ), fAnalysisContainer(new TList ),
48 fMakeHisto(0), fMakeAOD(0), fAnaDebug(0),
49 fReader(0x0), fAODBranchList(new TList )
52 if(fAnaDebug > 1 ) printf("*** Analysis Maker Constructor *** \n");
54 //Initialize parameters, pointers and histograms
56 fReader = new AliCaloTrackReader();
61 //____________________________________________________________________________
62 AliAnaPartCorrMaker::AliAnaPartCorrMaker(const AliAnaPartCorrMaker & g) :
64 fOutputContainer(g. fOutputContainer), fAnalysisContainer(g.fAnalysisContainer),
65 fMakeHisto(g.fMakeHisto), fMakeAOD(fMakeAOD), fAnaDebug(g. fAnaDebug),
66 fReader(g.fReader), fAODBranchList(g.fAODBranchList)
72 //_________________________________________________________________________
73 AliAnaPartCorrMaker & AliAnaPartCorrMaker::operator = (const AliAnaPartCorrMaker & source)
75 // assignment operator
77 if(this == &source)return *this;
78 ((TObject *)this)->operator=(source);
80 fOutputContainer = source.fOutputContainer ;
81 fAnalysisContainer = source.fAnalysisContainer ;
82 fAnaDebug = source.fAnaDebug;
83 fMakeHisto = source.fMakeHisto;
84 fMakeAOD = source.fMakeAOD;
86 fReader = source.fReader ;
87 fAODBranchList = source.fAODBranchList;
93 //____________________________________________________________________________
94 AliAnaPartCorrMaker::~AliAnaPartCorrMaker()
96 // Remove all pointers.
98 // Protection added in case of NULL pointers (MG)
99 if (fOutputContainer) {
100 fOutputContainer->Clear();
101 delete fOutputContainer ;
104 if (fAnalysisContainer) {
105 fAnalysisContainer->Clear();
106 delete fAnalysisContainer ;
109 if (fReader) delete fReader ;
113 // for(Int_t iaod = 0; iaod < fAODBranchList->GetEntries(); iaod++)
114 // fAODBranchList->At(iaod)->Clear();
116 fAODBranchList->Clear();
117 delete fAODBranchList ;
122 //________________________________________________________________________
123 TList * AliAnaPartCorrMaker::GetAODBranchList()
126 // Get any new output AOD branches from analysis and put them in a list
127 // The list is filled in the maker, and new branch passed to the analysis frame
128 // AliAnalysisTaskPartCorr
130 for(Int_t iana = 0; iana < fAnalysisContainer->GetEntries(); iana++){
132 AliAnaPartCorrBaseClass * ana = ((AliAnaPartCorrBaseClass *) fAnalysisContainer->At(iana)) ;
133 if(ana->NewOutputAOD()) fAODBranchList->Add(ana->GetCreateOutputAODBranch());
136 return fAODBranchList ;
140 //________________________________________________________________________
141 TList *AliAnaPartCorrMaker::GetOutputContainer()
143 // Fill the output list of histograms during the CreateOutputObjects stage.
144 if(!fAnalysisContainer || fAnalysisContainer->GetEntries()==0){
145 printf("AliAnaPartCorrMaker::GetOutputContainer() - Analysis job list not initialized!!!\n");
150 for(Int_t iana = 0; iana < fAnalysisContainer->GetEntries(); iana++){
151 AliAnaPartCorrBaseClass * ana = ((AliAnaPartCorrBaseClass *) fAnalysisContainer->At(iana)) ;
152 if(fMakeHisto){// Analysis with histograms as output on
153 //Fill container with appropriate histograms
154 TList * templist = ana -> GetCreateOutputObjects();
155 for(Int_t i = 0; i < templist->GetEntries(); i++){
157 //Add only to the histogram name the name of the task
158 if( strcmp((templist->At(i))->ClassName(),"TObjString") ) {
159 sprintf(newname,"%s%s", (ana->GetAddedHistogramsStringToName()).Data(), (templist->At(i))->GetName());
160 ((TH1*) templist->At(i))->SetName(newname);
162 //Add histogram to general container
163 fOutputContainer->Add(templist->At(i)) ;
165 }// Analysis with histograms as output on
166 }//Loop on analysis defined
168 return fOutputContainer;
172 //________________________________________________________________________
173 void AliAnaPartCorrMaker::Init()
175 //Init container histograms and other common variables
176 // Fill the output list of histograms during the CreateOutputObjects stage.
178 if(!fAnalysisContainer || fAnalysisContainer->GetEntries()==0){
179 printf("AliAnaPartCorrMaker::GetOutputInit() - Analysis job list not initialized!!!\n");
186 for(Int_t iana = 0; iana < fAnalysisContainer->GetEntries(); iana++){
188 AliAnaPartCorrBaseClass * ana = ((AliAnaPartCorrBaseClass *) fAnalysisContainer->At(iana)) ;
189 ana->SetReader(fReader); //SetReader for each analysis
192 }//Loop on analysis defined
195 //____________________________________________________________________________
196 void AliAnaPartCorrMaker::InitParameters()
202 fAnaDebug = 0; // No debugging info displayed by default
206 //__________________________________________________________________
207 void AliAnaPartCorrMaker::Print(const Option_t * opt) const
209 //Print some relevant parameters set for the analysis
214 printf("***** Print: %s %s ******\n", GetName(), GetTitle() ) ;
215 printf("Debug level = %d\n", fAnaDebug) ;
216 printf("Produce Histo = %d\n", fMakeHisto) ;
217 printf("Produce AOD = %d\n", fMakeAOD) ;
222 //____________________________________________________________________________
223 void AliAnaPartCorrMaker::ProcessEvent(const Int_t iEntry, const char * currentFileName){
224 //Process analysis for this event
226 if(fMakeHisto && !fOutputContainer){
227 printf("AliAnaPartCorrMaker::ProcessEvent() - Histograms not initialized\n");
232 printf("*** Event %d *** \n",iEntry);
234 printf("AliAnaPartCorrMaker::Current File Name : %s\n", currentFileName);
236 //Each event needs an empty branch
237 for(Int_t iaod = 0; iaod < fAODBranchList->GetEntries(); iaod++)
238 fAODBranchList->At(iaod)->Clear();
240 //Tell the reader to fill the data in the 3 detector lists
241 Bool_t ok = fReader->FillInputEvent(iEntry, currentFileName);
243 printf("*** Skip event *** %d \n",iEntry);
246 printf(">>>>>>>>>> BEFORE >>>>>>>>>>>\n");
247 gObjectTable->Print();
248 //Loop on analysis algorithms
249 if(fAnaDebug > 0 ) printf("*** Begin analysis *** \n");
250 Int_t nana = fAnalysisContainer->GetEntries() ;
251 for(Int_t iana = 0; iana < nana; iana++){
252 AliAnaPartCorrBaseClass * ana = ((AliAnaPartCorrBaseClass *) fAnalysisContainer->At(iana)) ;
253 ana->ConnectInputOutputAODBranches(); //Sets branches for each analysis
254 //Make analysis, create aods in aod branch or AODCaloClusters
255 if(fMakeAOD) ana->MakeAnalysisFillAOD() ;
256 //Make further analysis with aod branch and fill histograms
257 if(fMakeHisto) ana->MakeAnalysisFillHistograms() ;
261 fReader->ResetLists();
263 printf(">>>>>>>>>> AFTER >>>>>>>>>>>\n");
264 gObjectTable->Print();
266 if(fAnaDebug > 0 ) printf("*** End analysis *** \n");
270 //________________________________________________________________________
271 void AliAnaPartCorrMaker::Terminate(TList * outputList)
273 //Execute Terminate of analysis
274 //Do some final plots.
277 Error("Terminate", "No output list");
281 for(Int_t iana = 0; iana < fAnalysisContainer->GetEntries(); iana++){
283 AliAnaPartCorrBaseClass * ana = ((AliAnaPartCorrBaseClass *) fAnalysisContainer->At(iana)) ;
284 ana->Terminate(outputList);
286 }//Loop on analysis defined