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"
34 //---- AliRoot system ----
35 #include "AliAnaPartCorrBaseClass.h"
36 #include "AliAnaPartCorrMaker.h"
37 #include "AliCaloTrackReader.h"
40 ClassImp(AliAnaPartCorrMaker)
43 //____________________________________________________________________________
44 AliAnaPartCorrMaker::AliAnaPartCorrMaker() :
46 fOutputContainer(new TList ), fAnalysisContainer(new TList ),
47 fMakeHisto(0), fMakeAOD(0), fAnaDebug(0),
48 fReader(0x0), fAODBranchList(new TList )
51 if(fAnaDebug > 1 ) printf("*** Analysis Maker Constructor *** \n");
53 //Initialize parameters, pointers and histograms
55 fReader = new AliCaloTrackReader();
60 //____________________________________________________________________________
61 AliAnaPartCorrMaker::AliAnaPartCorrMaker(const AliAnaPartCorrMaker & g) :
63 fOutputContainer(g. fOutputContainer), fAnalysisContainer(g.fAnalysisContainer),
64 fMakeHisto(g.fMakeHisto), fMakeAOD(fMakeAOD), fAnaDebug(g. fAnaDebug),
65 fReader(g.fReader), fAODBranchList(g.fAODBranchList)
71 //_________________________________________________________________________
72 AliAnaPartCorrMaker & AliAnaPartCorrMaker::operator = (const AliAnaPartCorrMaker & source)
74 // assignment operator
76 if(this == &source)return *this;
77 ((TObject *)this)->operator=(source);
79 fOutputContainer = source.fOutputContainer ;
80 fAnalysisContainer = source.fAnalysisContainer ;
81 fAnaDebug = source.fAnaDebug;
82 fMakeHisto = source.fMakeHisto;
83 fMakeAOD = source.fMakeAOD;
85 fReader = source.fReader ;
86 fAODBranchList = source.fAODBranchList;
92 //____________________________________________________________________________
93 AliAnaPartCorrMaker::~AliAnaPartCorrMaker()
95 // Remove all pointers.
97 // Protection added in case of NULL pointers (MG)
98 if (fOutputContainer) {
99 fOutputContainer->Clear();
100 delete fOutputContainer ;
103 if (fAnalysisContainer) {
104 fAnalysisContainer->Clear();
105 delete fAnalysisContainer ;
108 if (fReader) delete fReader ;
112 // for(Int_t iaod = 0; iaod < fAODBranchList->GetEntries(); iaod++)
113 // fAODBranchList->At(iaod)->Clear();
115 fAODBranchList->Clear();
116 delete fAODBranchList ;
121 //________________________________________________________________________
122 TList * AliAnaPartCorrMaker::GetAODBranchList()
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
129 for(Int_t iana = 0; iana < fAnalysisContainer->GetEntries(); iana++){
131 AliAnaPartCorrBaseClass * ana = ((AliAnaPartCorrBaseClass *) fAnalysisContainer->At(iana)) ;
132 if(ana->NewOutputAOD()) fAODBranchList->Add(ana->GetCreateOutputAODBranch());
135 return fAODBranchList ;
139 //________________________________________________________________________
140 TList *AliAnaPartCorrMaker::GetOutputContainer()
142 // Fill the output list of histograms during the CreateOutputObjects stage.
143 if(!fAnalysisContainer || fAnalysisContainer->GetEntries()==0){
144 printf("AliAnaPartCorrMaker::GetOutputContainer() - Analysis job list not initialized\n");
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();
154 for(Int_t i = 0; i < templist->GetEntries(); i++){
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);
161 //Add histogram to general container
162 fOutputContainer->Add(templist->At(i)) ;
164 }// Analysis with histograms as output on
165 }//Loop on analysis defined
167 return fOutputContainer;
171 //________________________________________________________________________
172 void AliAnaPartCorrMaker::Init()
174 //Init container histograms and other common variables
175 // Fill the output list of histograms during the CreateOutputObjects stage.
177 if(!fAnalysisContainer || fAnalysisContainer->GetEntries()==0){
178 printf("AliAnaPartCorrMaker::GetOutputInit() - Analysis job list not initialized\n");
182 for(Int_t iana = 0; iana < fAnalysisContainer->GetEntries(); iana++){
184 AliAnaPartCorrBaseClass * ana = ((AliAnaPartCorrBaseClass *) fAnalysisContainer->At(iana)) ;
185 ana->SetReader(fReader); //SetReader for each analysis
188 }//Loop on analysis defined
191 //____________________________________________________________________________
192 void AliAnaPartCorrMaker::InitParameters()
198 fAnaDebug = 0; // No debugging info displayed by default
202 //__________________________________________________________________
203 void AliAnaPartCorrMaker::Print(const Option_t * opt) const
205 //Print some relevant parameters set for the analysis
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) ;
218 //____________________________________________________________________________
219 Bool_t AliAnaPartCorrMaker::ProcessEvent(const Int_t iEntry, const char * currentFileName){
220 //Process analysis for this event
222 if(fMakeHisto && !fOutputContainer){
223 printf("AliAnaPartCorrMaker::ProcessEvent() - Histograms not initialized\n");
228 printf("*** Event %d *** \n",iEntry);
230 printf("AliAnaPartCorrMaker::Current File Name : %s\n", currentFileName);
232 //Each event needs an empty branch
233 for(Int_t iaod = 0; iaod < fAODBranchList->GetEntries(); iaod++)
234 fAODBranchList->At(iaod)->Clear();
236 //Tell the reader to fill the data in the 3 detector lists
237 fReader->FillInputEvent(iEntry, currentFileName);
239 //Loop on analysis algorithms
240 if(fAnaDebug > 0 ) printf("*** Begin analysis *** \n");
241 Int_t nana = fAnalysisContainer->GetEntries() ;
242 for(Int_t iana = 0; iana < nana; iana++){
243 AliAnaPartCorrBaseClass * ana = ((AliAnaPartCorrBaseClass *) fAnalysisContainer->At(iana)) ;
244 ana->ConnectInputOutputAODBranches(); //Sets branches for each analysis
245 //Make analysis, create aods in aod branch or AODCaloClusters
246 if(fMakeAOD) ana->MakeAnalysisFillAOD() ;
247 //Make further analysis with aod branch and fill histograms
248 if(fMakeHisto) ana->MakeAnalysisFillHistograms() ;
252 fReader->ResetLists();
254 if(fAnaDebug > 0 ) printf("*** End analysis *** \n");
260 //________________________________________________________________________
261 void AliAnaPartCorrMaker::Terminate(TList * outputList)
263 //Execute Terminate of analysis
264 //Do some final plots.
267 Error("Terminate", "No output list");
271 for(Int_t iana = 0; iana < fAnalysisContainer->GetEntries(); iana++){
273 AliAnaPartCorrBaseClass * ana = ((AliAnaPartCorrBaseClass *) fAnalysisContainer->At(iana)) ;
274 ana->Terminate(outputList);
276 }//Loop on analysis defined