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 // Analysis task that executes the analysis classes
19 // that depend on the PartCorr frame, frame for Particle identification and correlations.
20 // Specially designed for calorimeters but also can be used for charged tracks
21 // Input of this task is a configuration file that contains all the settings of the analyis
23 // -- Author: Gustavo Conesa (INFN-LNF)
29 #include <TInterpreter.h>
30 #include <TClonesArray.h>
31 //#include <Riostream.h>
32 //#include <TObjectTable.h>
35 #include "AliAnalysisTaskParticleCorrelation.h"
36 #include "AliAnaPartCorrMaker.h"
37 #include "AliCaloTrackReader.h"
39 #include "AliAnalysisManager.h"
41 ClassImp(AliAnalysisTaskParticleCorrelation)
43 ////////////////////////////////////////////////////////////////////////
44 AliAnalysisTaskParticleCorrelation::AliAnalysisTaskParticleCorrelation():
47 fOutputContainer(0x0),
48 fConfigName(""), fCuts(0x0)
50 // Default constructor
53 //_____________________________________________________
54 AliAnalysisTaskParticleCorrelation::AliAnalysisTaskParticleCorrelation(const char* name):
55 AliAnalysisTaskSE(name),
57 fOutputContainer(0x0),
58 fConfigName(""), fCuts(0x0)
60 // Default constructor
62 DefineOutput(1, TList::Class());
63 DefineOutput(2, TList::Class()); // will contain cuts or local params
66 //_____________________________________________________
67 AliAnalysisTaskParticleCorrelation::~AliAnalysisTaskParticleCorrelation()
69 // Remove all pointers
71 // printf("********** Delete Task\n");
72 // // Do not delete it here, already done somewhere else, need to understand where.
73 // if(fOutputContainer){
74 // fOutputContainer->Clear() ;
75 // delete fOutputContainer ;
80 // printf("********** Task deleted \n");
83 //_____________________________________________________
84 void AliAnalysisTaskParticleCorrelation::UserCreateOutputObjects()
86 // Create the output container
87 if (DebugLevel() > 1) printf("AliAnalysisTaskParticleCorrelation::UserCreateOutputObjects() - Begin\n");
89 //Get list of aod arrays, add each aod array to analysis frame
90 TClonesArray *array = 0;
91 TList * list = fAna->FillAndGetAODBranchList(); //Loop the analysis and create the list of branches
92 if (DebugLevel() >= 1) printf("AliAnalysisTaskParticleCorrelation::UserCreateOutputObjects() - n AOD branches %d\n",list->GetEntries());
94 //Put the delta AODs in output file, std or delta
95 if((fAna->GetReader())->WriteDeltaAODToFile()){
96 TString deltaAODName = (fAna->GetReader())->GetDeltaAODFileName();
97 for(Int_t iaod = 0; iaod < list->GetEntries(); iaod++){
98 array = (TClonesArray*) list->At(iaod);
99 if(deltaAODName!="") AddAODBranch("TClonesArray", &array, deltaAODName);//Put it in DeltaAOD file
100 else AddAODBranch("TClonesArray", &array);//Put it in standard AOD file
104 //Histograms container
106 fOutputContainer = fAna->GetOutputContainer();
108 if (DebugLevel() >= 1) printf("AliAnalysisTaskParticleCorrelation::UserCreateOutputObjects() - n histograms %d\n",fOutputContainer->GetEntries());
110 fOutputContainer->SetOwner(kTRUE);
112 if (DebugLevel() > 1) printf("AliAnalysisTaskParticleCorrelation::UserCreateOutputObjects() - End\n");
114 PostData(1,fOutputContainer);
117 //_____________________________________________________
118 void AliAnalysisTaskParticleCorrelation::LocalInit()
120 // Local Initialization
122 //Call the Init to initialize the configuration of the analysis
125 // Create cuts/param objects and publish to slot
126 fCuts = fAna->GetListOfAnalysisCuts();
133 //_____________________________________________________
134 void AliAnalysisTaskParticleCorrelation::Init()
138 if (DebugLevel() > 1) printf("AliAnalysisTaskParticleCorrelation::Init() - Begin\n");
140 // Call configuration file if specified
142 if (fConfigName.Length()) {
143 printf("AliAnalysisTaskParticleCorrelation::Init() - ### Configuration file is %s.C ###\n", fConfigName.Data());
144 gROOT->LoadMacro(fConfigName+".C");
145 fAna = (AliAnaPartCorrMaker*) gInterpreter->ProcessLine("ConfigAnalysis()");
149 printf("AliAnalysisTaskParticleCorrelation::Init() - Analysis maker pointer not initialized, no analysis specified, STOP !\n");
153 // Add different generator particles to PDG Data Base
154 // to avoid problems when reading MC generator particles
155 AliPDG::AddParticlesToPdgDataBase();
157 //Set in the reader the name of the task in case is needed
158 (fAna->GetReader())->SetTaskName(GetName());
160 // Initialise analysis
164 if((fAna->GetReader())->GetDeltaAODFileName()!="")
165 AliAnalysisManager::GetAnalysisManager()->RegisterExtraFile((fAna->GetReader())->GetDeltaAODFileName());
167 if (DebugLevel() > 1) printf("AliAnalysisTaskParticleCorrelation::Init() - End\n");
172 //_____________________________________________________
173 void AliAnalysisTaskParticleCorrelation::UserExec(Option_t */*option*/)
175 // Execute analysis for current event
177 if (DebugLevel() > 1) printf("AliAnalysisTaskParticleCorrelation::UserExec() - Begin\n");
179 //Get the type of data, check if type is correct
180 Int_t datatype = fAna->GetReader()->GetDataType();
181 if(datatype != AliCaloTrackReader::kESD && datatype != AliCaloTrackReader::kAOD &&
182 datatype != AliCaloTrackReader::kMC){
183 printf("AliAnalysisTaskParticleCorrelation::UserExec() - Wrong type of data\n");
187 fAna->GetReader()->SetInputOutputMCEvent(InputEvent(), AODEvent(), MCEvent());
190 fAna->ProcessEvent((Int_t) Entry(), CurrentFileName());
191 //printf("AliAnalysisTaskParticleCorrelation::Current Event %d; Current File Name : %s\n",(Int_t) Entry(), CurrentFileName());
192 if (DebugLevel() > 1) printf("AliAnalysisTaskParticleCorrelation::UserExec() - End\n");
194 PostData(1, fOutputContainer);
196 //gObjectTable->Print();
201 //_____________________________________________________
202 void AliAnalysisTaskParticleCorrelation::Terminate(Option_t */*option*/)
204 // Terminate analysis
207 // Get merged histograms from the output container
208 // Propagate histagrams to maker
209 fAna->Terminate((TList*)GetOutputData(1));