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 **************************************************************************/
16 //_____________________________________________________________________________
17 // Steering class for particle (gamma, hadron) identification and correlation
18 // analysis. It is called by the task class AliAnalysisTaskCaloTrackCorrelation
19 // and it connects the input (ESD/AOD/MonteCarlo) got with AliCaloTrackReader
20 // (produces TClonesArrays of AODs (TParticles in MC case if requested)), with
21 // the analysis classes that derive from AliAnaCaloTrackCorrBaseClass
23 // -- Author: Gustavo Conesa (INFN-LNF, LPSC-Grenoble)
27 // --- ROOT system ---
28 #include "TClonesArray.h"
31 //#include "Riostream.h"
32 //#include <TObjectTable.h>
34 //---- AliRoot system ----
35 #include "AliAnalysisManager.h"
36 #include "AliVEventHandler.h"
37 #include "AliAnaCaloTrackCorrBaseClass.h"
38 #include "AliAnaCaloTrackCorrMaker.h"
40 ClassImp(AliAnaCaloTrackCorrMaker)
43 //__________________________________________________
44 AliAnaCaloTrackCorrMaker::AliAnaCaloTrackCorrMaker() :
46 fOutputContainer(new TList ), fAnalysisContainer(new TList ),
47 fMakeHisto(kFALSE), fMakeAOD(kFALSE),
48 fAnaDebug(0), fReader(0),
49 fCaloUtils(0), fCuts(new TList),
50 fhNEvents(0x0), fhTrackMult(0x0)
53 if(fAnaDebug > 1 ) printf("*** Analysis Maker Constructor *** \n");
55 //Initialize parameters, pointers and histograms
59 //________________________________________________________________________________________
60 AliAnaCaloTrackCorrMaker::AliAnaCaloTrackCorrMaker(const AliAnaCaloTrackCorrMaker & maker) :
62 fOutputContainer(new TList()), fAnalysisContainer(new TList()),
63 fMakeHisto(maker.fMakeHisto), fMakeAOD(maker.fMakeAOD),
64 fAnaDebug(maker.fAnaDebug), fReader(),//new AliCaloTrackReader(*maker.fReader)),
65 fCaloUtils(),//(new AliCalorimeterUtils(*maker.fCaloUtils)),
67 fhNEvents(maker.fhNEvents), fhTrackMult(maker.fhTrackMult)
72 //___________________________________________________
73 AliAnaCaloTrackCorrMaker::~AliAnaCaloTrackCorrMaker()
75 // Remove all owned pointers.
77 // Do not delete it here, already done somewhere else, need to understand where.
78 // if (fOutputContainer) {
79 // fOutputContainer->Clear();
80 // delete fOutputContainer ;
83 if (fAnalysisContainer) {
84 fAnalysisContainer->Delete();
85 delete fAnalysisContainer ;
88 if (fReader) delete fReader ;
89 if (fCaloUtils) delete fCaloUtils ;
98 //_______________________________________________________
99 void AliAnaCaloTrackCorrMaker::AddAnalysis(TObject* ana, Int_t n)
101 // Add analysis depending on AliAnaCaloTrackCorrBaseClass to list
103 if ( fAnalysisContainer)
105 fAnalysisContainer->AddAt(ana,n);
109 printf("AliAnaCaloTrackCorrMaker::AddAnalysis() - AnalysisContainer not initialized\n");
114 //_________________________________________________________
115 TList * AliAnaCaloTrackCorrMaker::FillAndGetAODBranchList()
118 // Get any new output AOD branches from analysis and put them in a list
119 // The list is filled in the maker, and new branch passed to the analysis frame
120 // AliAnalysisTaskCaloTrackCorrelation
122 TList *aodBranchList = fReader->GetAODBranchList() ;
124 for(Int_t iana = 0; iana < fAnalysisContainer->GetEntries(); iana++){
126 AliAnaCaloTrackCorrBaseClass * ana = ((AliAnaCaloTrackCorrBaseClass *) fAnalysisContainer->At(iana)) ;
127 if(ana->NewOutputAOD()) aodBranchList->Add(ana->GetCreateOutputAODBranch());
131 return aodBranchList ;
135 //_______________________________________________________
136 TList * AliAnaCaloTrackCorrMaker::GetListOfAnalysisCuts()
139 // Get the list of the cuts used for the analysis
140 // The list is filled in the maker, called by the task in LocalInit() and posted there
143 for(Int_t iana = 0; iana < fAnalysisContainer->GetEntries(); iana++){
144 AliAnaCaloTrackCorrBaseClass * ana = ((AliAnaCaloTrackCorrBaseClass *) fAnalysisContainer->At(iana)) ;
145 TObjString * objstring = ana->GetAnalysisCuts();
147 if(objstring)fCuts->Add(objstring);
154 //___________________________________________________
155 TList *AliAnaCaloTrackCorrMaker::GetOutputContainer()
157 // Fill the output list of histograms during the CreateOutputObjects stage.
159 //Initialize calorimeters geometry pointers
160 GetCaloUtils()->InitPHOSGeometry();
161 GetCaloUtils()->InitEMCALGeometry();
163 if(!fAnalysisContainer || fAnalysisContainer->GetEntries()==0){
164 printf("AliAnaCaloTrackCorrMaker::GetOutputContainer() - Analysis job list not initialized!!!\n");
168 const Int_t buffersize = 255;
170 for(Int_t iana = 0; iana < fAnalysisContainer->GetEntries(); iana++){
171 AliAnaCaloTrackCorrBaseClass * ana = ((AliAnaCaloTrackCorrBaseClass *) fAnalysisContainer->At(iana)) ;
172 if(fMakeHisto){// Analysis with histograms as output on
173 //Fill container with appropriate histograms
174 TList * templist = ana ->GetCreateOutputObjects();
175 templist->SetOwner(kFALSE); //Owner is fOutputContainer.
176 for(Int_t i = 0; i < templist->GetEntries(); i++){
178 //Add only to the histogram name the name of the task
179 if( strcmp((templist->At(i))->ClassName(),"TObjString") ) {
180 snprintf(newname,buffersize, "%s%s", (ana->GetAddedHistogramsStringToName()).Data(), (templist->At(i))->GetName());
181 ((TH1*) templist->At(i))->SetName(newname);
183 //Add histogram to general container
184 fOutputContainer->Add(templist->At(i)) ;
187 }// Analysis with histograms as output on
188 }//Loop on analysis defined
189 }//Analysis list available
191 //General event histograms
193 fhNEvents = new TH1I("hNEvents", "Number of analyzed events" , 1 , 0 , 1 ) ;
194 fOutputContainer->Add(fhNEvents);
195 fhTrackMult = new TH1I("hTrackMult", "Number of tracks per events" , 2000 , 0 , 2000 ) ;
196 fOutputContainer->Add(fhTrackMult);
198 return fOutputContainer;
202 //___________________________________
203 void AliAnaCaloTrackCorrMaker::Init()
205 //Init container histograms and other common variables
206 // Fill the output list of histograms during the CreateOutputObjects stage.
210 GetReader()->SetCaloUtils(GetCaloUtils()); // pass the calo utils pointer to the reader
213 if(!fAnalysisContainer || fAnalysisContainer->GetEntries()==0){
214 printf("AliAnaCaloTrackCorrMaker::GetOutputInit() - Analysis job list not initialized!!!\n");
219 for(Int_t iana = 0; iana < fAnalysisContainer->GetEntries(); iana++){
221 AliAnaCaloTrackCorrBaseClass * ana = ((AliAnaCaloTrackCorrBaseClass *) fAnalysisContainer->At(iana)) ;
222 ana->SetReader(fReader); //SetReader for each analysis
223 ana->SetCaloUtils(fCaloUtils); //Set CaloUtils for each analysis
227 }//Loop on analysis defined
228 }//Analysis list available
231 //_____________________________________________
232 void AliAnaCaloTrackCorrMaker::InitParameters()
238 fAnaDebug = 0; // No debugging info displayed by default
242 //______________________________________________________________
243 void AliAnaCaloTrackCorrMaker::Print(const Option_t * opt) const
245 //Print some relevant parameters set for the analysis
250 printf("***** Print: %s %s ******\n", GetName(), GetTitle() ) ;
251 printf("Debug level = %d\n", fAnaDebug) ;
252 printf("Produce Histo = %d\n", fMakeHisto) ;
253 printf("Produce AOD = %d\n", fMakeAOD) ;
254 printf("Number of analysis tasks = %d\n", fAnalysisContainer->GetEntries()) ;
256 if(!strcmp("all",opt)){
257 printf("Print analysis Tasks settings :\n") ;
258 for(Int_t iana = 0; iana<fAnalysisContainer->GetEntries(); iana++){
259 ((AliAnaCaloTrackCorrBaseClass *) fAnalysisContainer->At(iana))->Print("");
262 printf("Print analysis Reader settings :\n") ;
264 printf("Print analysis Calorimeter Utils settings :\n") ;
265 fCaloUtils->Print("");
269 //_______________________________________________________________________
270 void AliAnaCaloTrackCorrMaker::ProcessEvent(const Int_t iEntry,
271 const char * currentFileName)
273 //Process analysis for this event
275 if(fMakeHisto && !fOutputContainer){
276 printf("AliAnaCaloTrackCorrMaker::ProcessEvent() - Histograms not initialized\n");
281 printf("*** AliAnaCaloTrackCorrMaker::ProcessEvent() Event %d *** \n",iEntry);
283 printf("AliAnaCaloTrackCorrMaker::ProcessEvent() - Current File Name : %s\n", currentFileName);
284 //printf("fAODBranchList %p, entries %d\n",fAODBranchList,fAODBranchList->GetEntries());
288 //Each event needs an empty branch
289 TList * aodList = fReader->GetAODBranchList();
290 Int_t nAODBranches = aodList->GetEntries();
291 for(Int_t iaod = 0; iaod < nAODBranches; iaod++){
292 TClonesArray *tca = dynamic_cast<TClonesArray*> (aodList->At(iaod));
293 if(tca) tca->Clear("C");
296 //Set geometry matrices before filling arrays, in case recalibration/position calculation etc is needed
297 fCaloUtils->SetGeometryTransformationMatrices(fReader->GetInputEvent());
299 //Tell the reader to fill the data in the 3 detector lists
300 Bool_t ok = fReader->FillInputEvent(iEntry, currentFileName);
302 if(fAnaDebug >= 1 )printf("*** Skip event *** %d \n",iEntry);
306 //Magic line to write events to file
307 if(fReader->WriteDeltaAODToFile())AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler()->SetFillAOD(kTRUE);
309 //printf(">>>>>>>>>> BEFORE >>>>>>>>>>>\n");
310 //gObjectTable->Print();
311 //Loop on analysis algorithms
312 if(fAnaDebug > 0 ) printf("*** Begin analysis *** \n");
313 Int_t nana = fAnalysisContainer->GetEntries() ;
314 for(Int_t iana = 0; iana < nana; iana++){
315 AliAnaCaloTrackCorrBaseClass * ana = ((AliAnaCaloTrackCorrBaseClass *) fAnalysisContainer->At(iana)) ;
317 ana->ConnectInputOutputAODBranches(); //Sets branches for each analysis
318 //Make analysis, create aods in aod branch or AODCaloClusters
319 if(fMakeAOD ) ana->MakeAnalysisFillAOD() ;
320 //Make further analysis with aod branch and fill histograms
321 if(fMakeHisto) ana->MakeAnalysisFillHistograms() ;
325 fhNEvents->Fill(0); //Event analyzed
326 fhTrackMult->Fill(fReader->GetTrackMultiplicity());
328 fReader->ResetLists();
330 //printf(">>>>>>>>>> AFTER >>>>>>>>>>>\n");
331 //gObjectTable->Print();
333 if(fAnaDebug > 0 ) printf("*** End analysis *** \n");
337 //__________________________________________________________
338 void AliAnaCaloTrackCorrMaker::Terminate(TList * outputList)
340 //Execute Terminate of analysis
341 //Do some final plots.
344 Error("Terminate", "No output list");
348 for(Int_t iana = 0; iana < fAnalysisContainer->GetEntries(); iana++){
350 AliAnaCaloTrackCorrBaseClass * ana = ((AliAnaCaloTrackCorrBaseClass *) fAnalysisContainer->At(iana)) ;
351 if(ana->MakePlotsOn())ana->Terminate(outputList);
353 }//Loop on analysis defined