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 ),
53 if(fAnaDebug > 1 ) printf("*** Analysis Maker Constructor *** \n");
55 //Initialize parameters, pointers and histograms
57 fReader = new AliCaloTrackReader();
62 //____________________________________________________________________________
63 AliAnaPartCorrMaker::AliAnaPartCorrMaker(const AliAnaPartCorrMaker & maker) :
65 fOutputContainer(new TList()), fAnalysisContainer(new TList()),
66 fMakeHisto(maker.fMakeHisto), fMakeAOD(maker.fMakeAOD), fAnaDebug(maker.fAnaDebug),
67 fReader(new AliCaloTrackReader(*maker.fReader)), fAODBranchList(new TList()),
68 fhNEvents(maker.fhNEvents)
74 //_________________________________________________________________________
75 //AliAnaPartCorrMaker & AliAnaPartCorrMaker::operator = (const AliAnaPartCorrMaker & source)
77 // // assignment operator
79 // if(this == &source)return *this;
80 // ((TObject *)this)->operator=(source);
82 // delete fOutputContainer; fOutputContainer = source.fOutputContainer ;
83 // delete fAnalysisContainer; fAnalysisContainer = source.fAnalysisContainer ;
84 // fAnaDebug = source.fAnaDebug;
85 // fMakeHisto = source.fMakeHisto;
86 // fMakeAOD = source.fMakeAOD;
88 // delete fReader ; fReader = new AliCaloTrackReader(*source.fReader) ;
89 // delete fAODBranchList; fAODBranchList = source.fAODBranchList;
95 //____________________________________________________________________________
96 AliAnaPartCorrMaker::~AliAnaPartCorrMaker()
98 // Remove all pointers.
100 // Protection added in case of NULL pointers (MG)
101 if (fOutputContainer) {
102 fOutputContainer->Clear();
103 delete fOutputContainer ;
106 if (fAnalysisContainer) {
107 fAnalysisContainer->Clear();
108 delete fAnalysisContainer ;
111 if (fReader) delete fReader ;
115 // for(Int_t iaod = 0; iaod < fAODBranchList->GetEntries(); iaod++)
116 // fAODBranchList->At(iaod)->Clear();
118 fAODBranchList->Clear();
119 delete fAODBranchList ;
124 //________________________________________________________________________
125 TList * AliAnaPartCorrMaker::GetAODBranchList()
128 // Get any new output AOD branches from analysis and put them in a list
129 // The list is filled in the maker, and new branch passed to the analysis frame
130 // AliAnalysisTaskPartCorr
132 for(Int_t iana = 0; iana < fAnalysisContainer->GetEntries(); iana++){
134 AliAnaPartCorrBaseClass * ana = ((AliAnaPartCorrBaseClass *) fAnalysisContainer->At(iana)) ;
135 if(ana->NewOutputAOD()) fAODBranchList->Add(ana->GetCreateOutputAODBranch());
138 return fAODBranchList ;
142 //________________________________________________________________________
143 TList *AliAnaPartCorrMaker::GetOutputContainer()
145 // Fill the output list of histograms during the CreateOutputObjects stage.
146 if(!fAnalysisContainer || fAnalysisContainer->GetEntries()==0){
147 printf("AliAnaPartCorrMaker::GetOutputContainer() - Analysis job list not initialized!!!\n");
152 for(Int_t iana = 0; iana < fAnalysisContainer->GetEntries(); iana++){
153 AliAnaPartCorrBaseClass * ana = ((AliAnaPartCorrBaseClass *) fAnalysisContainer->At(iana)) ;
154 if(fMakeHisto){// Analysis with histograms as output on
155 //Fill container with appropriate histograms
156 TList * templist = ana -> GetCreateOutputObjects();
157 for(Int_t i = 0; i < templist->GetEntries(); i++){
159 //Add only to the histogram name the name of the task
160 if( strcmp((templist->At(i))->ClassName(),"TObjString") ) {
161 sprintf(newname,"%s%s", (ana->GetAddedHistogramsStringToName()).Data(), (templist->At(i))->GetName());
162 ((TH1*) templist->At(i))->SetName(newname);
164 //Add histogram to general container
165 fOutputContainer->Add(templist->At(i)) ;
167 }// Analysis with histograms as output on
168 }//Loop on analysis defined
171 fhNEvents = new TH1I("hNEvents", "Number of analyzed events" , 1 , 0 , 1 ) ;
172 fOutputContainer->Add(fhNEvents);
174 return fOutputContainer;
178 //________________________________________________________________________
179 void AliAnaPartCorrMaker::Init()
181 //Init container histograms and other common variables
182 // Fill the output list of histograms during the CreateOutputObjects stage.
184 if(!fAnalysisContainer || fAnalysisContainer->GetEntries()==0){
185 printf("AliAnaPartCorrMaker::GetOutputInit() - Analysis job list not initialized!!!\n");
192 for(Int_t iana = 0; iana < fAnalysisContainer->GetEntries(); iana++){
194 AliAnaPartCorrBaseClass * ana = ((AliAnaPartCorrBaseClass *) fAnalysisContainer->At(iana)) ;
195 ana->SetReader(fReader); //SetReader for each analysis
198 }//Loop on analysis defined
201 //____________________________________________________________________________
202 void AliAnaPartCorrMaker::InitParameters()
208 fAnaDebug = 0; // No debugging info displayed by default
212 //__________________________________________________________________
213 void AliAnaPartCorrMaker::Print(const Option_t * opt) const
215 //Print some relevant parameters set for the analysis
220 printf("***** Print: %s %s ******\n", GetName(), GetTitle() ) ;
221 printf("Debug level = %d\n", fAnaDebug) ;
222 printf("Produce Histo = %d\n", fMakeHisto) ;
223 printf("Produce AOD = %d\n", fMakeAOD) ;
228 //____________________________________________________________________________
229 void AliAnaPartCorrMaker::ProcessEvent(const Int_t iEntry, const char * currentFileName){
230 //Process analysis for this event
232 if(fMakeHisto && !fOutputContainer){
233 printf("AliAnaPartCorrMaker::ProcessEvent() - Histograms not initialized\n");
238 printf("*** Event %d *** \n",iEntry);
240 printf("AliAnaPartCorrMaker::ProcessEvent() - Current File Name : %s\n", currentFileName);
241 //printf("fAODBranchList %p, entries %d\n",fAODBranchList,fAODBranchList->GetEntries());
244 //Each event needs an empty branch
245 Int_t nAODBranches = fAODBranchList->GetEntries();
246 for(Int_t iaod = 0; iaod < nAODBranches; iaod++){
247 //fAODBranchList->At(iaod)->Clear();
248 TClonesArray *tca = dynamic_cast<TClonesArray*> (fAODBranchList->At(iaod));
249 if(tca) tca->Delete();
252 //Tell the reader to fill the data in the 3 detector lists
253 Bool_t ok = fReader->FillInputEvent(iEntry, currentFileName);
255 if(fAnaDebug >= 1 )printf("*** Skip event *** %d \n",iEntry);
259 //printf(">>>>>>>>>> BEFORE >>>>>>>>>>>\n");
260 //gObjectTable->Print();
261 //Loop on analysis algorithms
262 if(fAnaDebug > 0 ) printf("*** Begin analysis *** \n");
263 Int_t nana = fAnalysisContainer->GetEntries() ;
264 for(Int_t iana = 0; iana < nana; iana++){
265 AliAnaPartCorrBaseClass * ana = ((AliAnaPartCorrBaseClass *) fAnalysisContainer->At(iana)) ;
267 ana->ConnectInputOutputAODBranches(); //Sets branches for each analysis
268 //Make analysis, create aods in aod branch or AODCaloClusters
269 if(fMakeAOD) ana->MakeAnalysisFillAOD() ;
270 //Make further analysis with aod branch and fill histograms
271 if(fMakeHisto) ana->MakeAnalysisFillHistograms() ;
275 fhNEvents->Fill(0); //Event analyzed
277 fReader->ResetLists();
279 //printf(">>>>>>>>>> AFTER >>>>>>>>>>>\n");
280 //gObjectTable->Print();
282 if(fAnaDebug > 0 ) printf("*** End analysis *** \n");
286 //________________________________________________________________________
287 void AliAnaPartCorrMaker::Terminate(TList * outputList)
289 //Execute Terminate of analysis
290 //Do some final plots.
293 Error("Terminate", "No output list");
297 for(Int_t iana = 0; iana < fAnalysisContainer->GetEntries(); iana++){
299 AliAnaPartCorrBaseClass * ana = ((AliAnaPartCorrBaseClass *) fAnalysisContainer->At(iana)) ;
300 ana->Terminate(outputList);
302 }//Loop on analysis defined