]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG4/PartCorrBase/AliAnaPartCorrMaker.cxx
Access to the file analyzed available now in analysis classes through the reader...
[u/mrichter/AliRoot.git] / PWG4 / PartCorrBase / AliAnaPartCorrMaker.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
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  **************************************************************************/
15 /* $Id: $ */
16
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
23 //
24 // -- Author: Gustavo Conesa (INFN-LNF)
25
26 #include <cstdlib>
27
28 // --- ROOT system ---
29 #include "TClonesArray.h"
30 #include "TList.h"
31 #include "TH1.h"
32 //#include "Riostream.h"
33
34 //---- AliRoot system ---- 
35 #include "AliAnaPartCorrBaseClass.h" 
36 #include "AliAnaPartCorrMaker.h" 
37 #include "AliCaloTrackReader.h" 
38
39
40 ClassImp(AliAnaPartCorrMaker)
41
42
43 //____________________________________________________________________________
44 AliAnaPartCorrMaker::AliAnaPartCorrMaker() : 
45 TObject(),
46 fOutputContainer(new TList ), fAnalysisContainer(new TList ),
47 fMakeHisto(0), fMakeAOD(0), fAnaDebug(0), 
48 fReader(0x0), fAODBranchList(new TList )
49 {
50   //Default Ctor
51   if(fAnaDebug > 1 ) printf("*** Analysis Maker  Constructor *** \n");
52   
53   //Initialize parameters, pointers and histograms
54   if(!fReader)
55     fReader = new AliCaloTrackReader();
56   
57   InitParameters();
58 }
59
60 //____________________________________________________________________________
61 AliAnaPartCorrMaker::AliAnaPartCorrMaker(const AliAnaPartCorrMaker & g) :   
62 TObject(),
63 fOutputContainer(g. fOutputContainer), fAnalysisContainer(g.fAnalysisContainer), 
64 fMakeHisto(g.fMakeHisto), fMakeAOD(fMakeAOD), fAnaDebug(g. fAnaDebug),
65 fReader(g.fReader), fAODBranchList(g.fAODBranchList)
66 {
67   // cpy ctor
68         
69 }
70
71 //_________________________________________________________________________
72 AliAnaPartCorrMaker & AliAnaPartCorrMaker::operator = (const AliAnaPartCorrMaker & source)
73 {
74   // assignment operator
75   
76   if(this == &source)return *this;
77   ((TObject *)this)->operator=(source);
78   
79   fOutputContainer    = source.fOutputContainer ;
80   fAnalysisContainer  = source.fAnalysisContainer ;
81   fAnaDebug           = source.fAnaDebug;
82   fMakeHisto          = source.fMakeHisto;
83   fMakeAOD            = source.fMakeAOD;
84   
85   fReader             = source.fReader ;
86   fAODBranchList      = source.fAODBranchList;
87   
88   return *this;
89   
90 }
91
92 //____________________________________________________________________________
93 AliAnaPartCorrMaker::~AliAnaPartCorrMaker() 
94 {
95   // Remove all pointers.
96   
97   // Protection added in case of NULL pointers (MG)
98   if (fOutputContainer) {
99     fOutputContainer->Clear();
100     delete fOutputContainer ;
101   }   
102   
103   if (fAnalysisContainer) {
104     fAnalysisContainer->Clear();
105     delete fAnalysisContainer ;
106   }   
107   
108   if (fReader) delete fReader ;
109   
110   
111   if(fAODBranchList){
112 //              for(Int_t iaod = 0; iaod < fAODBranchList->GetEntries(); iaod++)
113 //                      fAODBranchList->At(iaod)->Clear();
114         
115     fAODBranchList->Clear();
116     delete fAODBranchList ;
117   }
118   
119 }
120
121 //________________________________________________________________________
122 TList * AliAnaPartCorrMaker::GetAODBranchList()
123
124
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
128  
129   for(Int_t iana = 0; iana <  fAnalysisContainer->GetEntries(); iana++){
130     
131     AliAnaPartCorrBaseClass * ana =  ((AliAnaPartCorrBaseClass *) fAnalysisContainer->At(iana)) ;
132     if(ana->NewOutputAOD()) fAODBranchList->Add(ana->GetCreateOutputAODBranch());
133   }
134   
135   return fAODBranchList ;
136   
137 }
138
139 //________________________________________________________________________
140 TList *AliAnaPartCorrMaker::GetOutputContainer()
141 {
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");
145     abort();
146   }
147
148   char newname[128];
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++){
155
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);
160         }
161         //Add histogram to general container
162         fOutputContainer->Add(templist->At(i)) ;
163       }
164     }// Analysis with histograms as output on
165   }//Loop on analysis defined
166   
167   return fOutputContainer;
168
169 }
170
171 //________________________________________________________________________
172 void AliAnaPartCorrMaker::Init()
173 {  
174   //Init container histograms and other common variables
175   // Fill the output list of histograms during the CreateOutputObjects stage.
176  
177   if(!fAnalysisContainer || fAnalysisContainer->GetEntries()==0){
178     printf("AliAnaPartCorrMaker::GetOutputInit() - Analysis job list not initialized\n");
179     abort();
180   }
181   
182   for(Int_t iana = 0; iana <  fAnalysisContainer->GetEntries(); iana++){
183     
184     AliAnaPartCorrBaseClass * ana =  ((AliAnaPartCorrBaseClass *) fAnalysisContainer->At(iana)) ;
185     ana->SetReader(fReader); //SetReader for each analysis
186     ana->Init();
187     
188   }//Loop on analysis defined
189 }
190
191 //____________________________________________________________________________
192 void AliAnaPartCorrMaker::InitParameters()
193 {       
194   //Init data members
195   
196   fMakeHisto = kTRUE;
197   fMakeAOD = kTRUE; 
198   fAnaDebug = 0; // No debugging info displayed by default
199   
200 }
201
202 //__________________________________________________________________
203 void AliAnaPartCorrMaker::Print(const Option_t * opt) const
204 {       
205   //Print some relevant parameters set for the analysis
206         
207   if(! opt)
208     return;
209   
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) ;
214   
215
216
217
218 //____________________________________________________________________________
219 Bool_t AliAnaPartCorrMaker::ProcessEvent(const Int_t iEntry, const char * currentFileName){
220   //Process analysis for this event
221   
222   if(fMakeHisto && !fOutputContainer){
223     printf("AliAnaPartCorrMaker::ProcessEvent() - Histograms not initialized\n");
224     abort();
225   }
226         
227         if(fAnaDebug >= 0 ){ 
228                 printf("***  Event %d   ***  \n",iEntry);
229                 if(fAnaDebug > 1 ) 
230                   printf("AliAnaPartCorrMaker::Current File Name : %s\n", currentFileName);
231   }
232   //Each event needs an empty branch    
233   for(Int_t iaod = 0; iaod < fAODBranchList->GetEntries(); iaod++)
234     fAODBranchList->At(iaod)->Clear();
235   
236   //Tell the reader to fill the data in the 3 detector lists
237   fReader->FillInputEvent(iEntry, currentFileName);
238   
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()  ;
249     
250   }
251   
252   fReader->ResetLists();
253   
254   if(fAnaDebug > 0 ) printf("*** End analysis *** \n");
255   
256   return kTRUE ;
257   
258 }
259
260 //________________________________________________________________________
261 void AliAnaPartCorrMaker::Terminate(TList * outputList)
262 {  
263   //Execute Terminate of analysis
264   //Do some final plots.
265   
266   if (!outputList) {
267           Error("Terminate", "No output list");
268           return;
269   }
270         
271   for(Int_t iana = 0; iana <  fAnalysisContainer->GetEntries(); iana++){
272     
273     AliAnaPartCorrBaseClass * ana =  ((AliAnaPartCorrBaseClass *) fAnalysisContainer->At(iana)) ;
274     ana->Terminate(outputList);
275     
276   }//Loop on analysis defined
277 }