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"
39 ClassImp(AliAnaPartCorrMaker)
42 //____________________________________________________________________________
43 AliAnaPartCorrMaker::AliAnaPartCorrMaker() :
45 fOutputContainer(new TList ), fAnalysisContainer(new TList ),
46 fMakeHisto(kFALSE), fMakeAOD(kFALSE), fAnaDebug(0),
47 fReader(0), fCaloUtils(0),
48 fCuts(new TList), fhNEvents(0x0)
51 if(fAnaDebug > 1 ) printf("*** Analysis Maker Constructor *** \n");
53 //Initialize parameters, pointers and histograms
57 //____________________________________________________________________________
58 AliAnaPartCorrMaker::AliAnaPartCorrMaker(const AliAnaPartCorrMaker & maker) :
60 fOutputContainer(new TList()), fAnalysisContainer(new TList()),
61 fMakeHisto(maker.fMakeHisto), fMakeAOD(maker.fMakeAOD),
62 fAnaDebug(maker.fAnaDebug),
63 fReader(),//new AliCaloTrackReader(*maker.fReader)),
64 fCaloUtils(),//(new AliCalorimeterUtils(*maker.fCaloUtils)),
65 fCuts(new TList()), fhNEvents(maker.fhNEvents)
71 //_________________________________________________________________________
72 //AliAnaPartCorrMaker & AliAnaPartCorrMaker::operator = (const AliAnaPartCorrMaker & source)
74 // // assignment operator
76 // if(this == &source)return *this;
77 // ((TObject *)this)->operator=(source);
79 // delete fOutputContainer; fOutputContainer = source.fOutputContainer ;
80 // delete fAnalysisContainer; fAnalysisContainer = source.fAnalysisContainer ;
81 // fAnaDebug = source.fAnaDebug;
82 // fMakeHisto = source.fMakeHisto;
83 // fMakeAOD = source.fMakeAOD;
85 // delete fReader ; fReader = new AliCaloTrackReader(*source.fReader) ;
86 // delete fAODBranchList; fAODBranchList = source.fAODBranchList;
92 //____________________________________________________________________________
93 AliAnaPartCorrMaker::~AliAnaPartCorrMaker()
95 // Remove all owned pointers.
96 //printf("======Delete Maker \n");
98 // Do not delete it here, already done somewhere else, need to understand where.
99 // if (fOutputContainer) {
100 // fOutputContainer->Clear();
101 // delete fOutputContainer ;
104 if (fAnalysisContainer) {
105 fAnalysisContainer->Delete();
106 delete fAnalysisContainer ;
109 if (fReader) delete fReader ;
110 if (fCaloUtils) delete fCaloUtils ;
117 // printf("====== Maker deleted \n");
120 //________________________________________________________________________
121 TList * AliAnaPartCorrMaker::GetListOfAnalysisCuts()
124 // Get the list of the cuts used for the analysis
125 // The list is filled in the maker, called by the task in LocalInit() and posted there
126 //printf("GetListOfAnalysis! \n");
128 for(Int_t iana = 0; iana < fAnalysisContainer->GetEntries(); iana++){
129 AliAnaPartCorrBaseClass * ana = ((AliAnaPartCorrBaseClass *) fAnalysisContainer->At(iana)) ;
130 TObjString * objstring = ana->GetAnalysisCuts();
131 //printf("analysis %d cuts %p\n",iana,objstring);
132 if(objstring)fCuts->Add(objstring);
134 //printf("Maker::GetEntries() %d\n",fCuts->GetEntries());
139 //________________________________________________________________________
140 TList * AliAnaPartCorrMaker::FillAndGetAODBranchList()
143 // Get any new output AOD branches from analysis and put them in a list
144 // The list is filled in the maker, and new branch passed to the analysis frame
145 // AliAnalysisTaskPartCorr
147 TList *aodBranchList = fReader->GetAODBranchList() ;
149 for(Int_t iana = 0; iana < fAnalysisContainer->GetEntries(); iana++){
151 AliAnaPartCorrBaseClass * ana = ((AliAnaPartCorrBaseClass *) fAnalysisContainer->At(iana)) ;
152 if(ana->NewOutputAOD()) aodBranchList->Add(ana->GetCreateOutputAODBranch());
156 return aodBranchList ;
160 //________________________________________________________________________
161 TList *AliAnaPartCorrMaker::GetOutputContainer()
163 // Fill the output list of histograms during the CreateOutputObjects stage.
164 if(!fAnalysisContainer || fAnalysisContainer->GetEntries()==0){
165 printf("AliAnaPartCorrMaker::GetOutputContainer() - Analysis job list not initialized!!!\n");
169 //Initialize calorimeters geometry pointers
170 GetCaloUtils()->InitPHOSGeometry();
171 GetCaloUtils()->InitEMCALGeometry();
174 for(Int_t iana = 0; iana < fAnalysisContainer->GetEntries(); iana++){
175 AliAnaPartCorrBaseClass * ana = ((AliAnaPartCorrBaseClass *) fAnalysisContainer->At(iana)) ;
176 if(fMakeHisto){// Analysis with histograms as output on
177 //Fill container with appropriate histograms
178 TList * templist = ana ->GetCreateOutputObjects();
179 templist->SetOwner(kFALSE); //Owner is fOutputContainer.
180 for(Int_t i = 0; i < templist->GetEntries(); i++){
182 //Add only to the histogram name the name of the task
183 if( strcmp((templist->At(i))->ClassName(),"TObjString") ) {
184 sprintf(newname,"%s%s", (ana->GetAddedHistogramsStringToName()).Data(), (templist->At(i))->GetName());
185 ((TH1*) templist->At(i))->SetName(newname);
187 //Add histogram to general container
188 fOutputContainer->Add(templist->At(i)) ;
191 }// Analysis with histograms as output on
192 }//Loop on analysis defined
194 fhNEvents = new TH1I("hNEvents", "Number of analyzed events" , 1 , 0 , 1 ) ;
195 fOutputContainer->Add(fhNEvents);
197 return fOutputContainer;
201 //________________________________________________________________________
202 void AliAnaPartCorrMaker::Init()
204 //Init container histograms and other common variables
205 // Fill the output list of histograms during the CreateOutputObjects stage.
207 if(!fAnalysisContainer || fAnalysisContainer->GetEntries()==0){
208 printf("AliAnaPartCorrMaker::GetOutputInit() - Analysis job list not initialized!!!\n");
214 GetReader()->SetCaloUtils(GetCaloUtils()); // pass the calo utils pointer to the reader
216 //fCaloUtils->Init();
217 for(Int_t iana = 0; iana < fAnalysisContainer->GetEntries(); iana++){
219 AliAnaPartCorrBaseClass * ana = ((AliAnaPartCorrBaseClass *) fAnalysisContainer->At(iana)) ;
220 ana->SetReader(fReader); //SetReader for each analysis
221 ana->SetCaloUtils(fCaloUtils); //Set CaloUtils for each analysis
225 }//Loop on analysis defined
228 //____________________________________________________________________________
229 void AliAnaPartCorrMaker::InitParameters()
235 fAnaDebug = 0; // No debugging info displayed by default
239 //__________________________________________________________________
240 void AliAnaPartCorrMaker::Print(const Option_t * opt) const
242 //Print some relevant parameters set for the analysis
247 printf("***** Print: %s %s ******\n", GetName(), GetTitle() ) ;
248 printf("Debug level = %d\n", fAnaDebug) ;
249 printf("Produce Histo = %d\n", fMakeHisto) ;
250 printf("Produce AOD = %d\n", fMakeAOD) ;
251 printf("Number of analysis tasks = %d\n", fAnalysisContainer->GetEntries()) ;
252 if(!strcmp("all",opt)){
253 printf("Print analysis Tasks settings :\n") ;
254 for(Int_t iana = 0; iana<fAnalysisContainer->GetEntries(); iana++){
255 ((AliAnaPartCorrBaseClass *) fAnalysisContainer->At(iana))->Print("");
258 printf("Print analysis Reader settings :\n") ;
260 printf("Print analysis Calorimeter Utils settings :\n") ;
261 fCaloUtils->Print("");
266 //____________________________________________________________________________
267 void AliAnaPartCorrMaker::ProcessEvent(const Int_t iEntry, const char * currentFileName){
268 //Process analysis for this event
270 if(fMakeHisto && !fOutputContainer){
271 printf("AliAnaPartCorrMaker::ProcessEvent() - Histograms not initialized\n");
276 printf("*** Event %d *** \n",iEntry);
278 printf("AliAnaPartCorrMaker::ProcessEvent() - Current File Name : %s\n", currentFileName);
279 //printf("fAODBranchList %p, entries %d\n",fAODBranchList,fAODBranchList->GetEntries());
283 //Each event needs an empty branch
284 TList * aodList = fReader->GetAODBranchList();
285 Int_t nAODBranches = aodList->GetEntries();
286 for(Int_t iaod = 0; iaod < nAODBranches; iaod++){
287 //aodList->At(iaod)->Clear();
288 TClonesArray *tca = dynamic_cast<TClonesArray*> (aodList->At(iaod));
289 if(tca) tca->Delete();
292 //Tell the reader to fill the data in the 3 detector lists
293 Bool_t ok = fReader->FillInputEvent(iEntry, currentFileName);
295 if(fAnaDebug >= 1 )printf("*** Skip event *** %d \n",iEntry);
299 fCaloUtils->SetGeometryTransformationMatrices(fReader->GetInputEvent());
301 //printf(">>>>>>>>>> BEFORE >>>>>>>>>>>\n");
302 //gObjectTable->Print();
303 //Loop on analysis algorithms
304 if(fAnaDebug > 0 ) printf("*** Begin analysis *** \n");
305 Int_t nana = fAnalysisContainer->GetEntries() ;
306 for(Int_t iana = 0; iana < nana; iana++){
307 AliAnaPartCorrBaseClass * ana = ((AliAnaPartCorrBaseClass *) fAnalysisContainer->At(iana)) ;
309 ana->ConnectInputOutputAODBranches(); //Sets branches for each analysis
310 //Make analysis, create aods in aod branch or AODCaloClusters
311 if(fMakeAOD ) ana->MakeAnalysisFillAOD() ;
312 //Make further analysis with aod branch and fill histograms
313 if(fMakeHisto) ana->MakeAnalysisFillHistograms() ;
317 fhNEvents->Fill(0); //Event analyzed
319 fReader->ResetLists();
321 //printf(">>>>>>>>>> AFTER >>>>>>>>>>>\n");
322 //gObjectTable->Print();
324 if(fAnaDebug > 0 ) printf("*** End analysis *** \n");
328 //________________________________________________________________________
329 void AliAnaPartCorrMaker::Terminate(TList * outputList)
331 //Execute Terminate of analysis
332 //Do some final plots.
335 Error("Terminate", "No output list");
339 for(Int_t iana = 0; iana < fAnalysisContainer->GetEntries(); iana++){
341 AliAnaPartCorrBaseClass * ana = ((AliAnaPartCorrBaseClass *) fAnalysisContainer->At(iana)) ;
342 ana->Terminate(outputList);
344 }//Loop on analysis defined