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 & maker) :
64 fOutputContainer(new TList()), fAnalysisContainer(new TList()),
65 fMakeHisto(maker.fMakeHisto), fMakeAOD(maker.fMakeAOD), fAnaDebug(maker.fAnaDebug),
66 fReader(new AliCaloTrackReader(*maker.fReader)), fAODBranchList(new TList())
72 //_________________________________________________________________________
73 //AliAnaPartCorrMaker & AliAnaPartCorrMaker::operator = (const AliAnaPartCorrMaker & source)
75 // // assignment operator
77 // if(this == &source)return *this;
78 // ((TObject *)this)->operator=(source);
80 // delete fOutputContainer; fOutputContainer = source.fOutputContainer ;
81 // delete fAnalysisContainer; fAnalysisContainer = source.fAnalysisContainer ;
82 // fAnaDebug = source.fAnaDebug;
83 // fMakeHisto = source.fMakeHisto;
84 // fMakeAOD = source.fMakeAOD;
86 // delete fReader ; fReader = new AliCaloTrackReader(*source.fReader) ;
87 // delete fAODBranchList; 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::ProcessEvent() - Current File Name : %s\n", currentFileName);
235 //printf("fAODBranchList %p, entries %d\n",fAODBranchList,fAODBranchList->GetEntries());
238 //Each event needs an empty branch
239 Int_t nAODBranches = fAODBranchList->GetEntries();
240 for(Int_t iaod = 0; iaod < nAODBranches; iaod++){
241 //fAODBranchList->At(iaod)->Clear();
242 TClonesArray *tca = dynamic_cast<TClonesArray*> (fAODBranchList->At(iaod));
243 if(tca) tca->Delete();
246 //Tell the reader to fill the data in the 3 detector lists
247 Bool_t ok = fReader->FillInputEvent(iEntry, currentFileName);
249 if(fAnaDebug >= 1 )printf("*** Skip event *** %d \n",iEntry);
253 //printf(">>>>>>>>>> BEFORE >>>>>>>>>>>\n");
254 //gObjectTable->Print();
255 //Loop on analysis algorithms
256 if(fAnaDebug > 0 ) printf("*** Begin analysis *** \n");
257 Int_t nana = fAnalysisContainer->GetEntries() ;
258 for(Int_t iana = 0; iana < nana; iana++){
259 AliAnaPartCorrBaseClass * ana = ((AliAnaPartCorrBaseClass *) fAnalysisContainer->At(iana)) ;
261 ana->ConnectInputOutputAODBranches(); //Sets branches for each analysis
262 //Make analysis, create aods in aod branch or AODCaloClusters
263 if(fMakeAOD) ana->MakeAnalysisFillAOD() ;
264 //Make further analysis with aod branch and fill histograms
265 if(fMakeHisto) ana->MakeAnalysisFillHistograms() ;
269 fReader->ResetLists();
271 //printf(">>>>>>>>>> AFTER >>>>>>>>>>>\n");
272 //gObjectTable->Print();
274 if(fAnaDebug > 0 ) printf("*** End analysis *** \n");
278 //________________________________________________________________________
279 void AliAnaPartCorrMaker::Terminate(TList * outputList)
281 //Execute Terminate of analysis
282 //Do some final plots.
285 Error("Terminate", "No output list");
289 for(Int_t iana = 0; iana < fAnalysisContainer->GetEntries(); iana++){
291 AliAnaPartCorrBaseClass * ana = ((AliAnaPartCorrBaseClass *) fAnalysisContainer->At(iana)) ;
292 ana->Terminate(outputList);
294 }//Loop on analysis defined