]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG4/PartCorrBase/AliAnalysisTaskParticleCorrelationM.cxx
1) Do not fill aod file if not requested
[u/mrichter/AliRoot.git] / PWG4 / PartCorrBase / AliAnalysisTaskParticleCorrelationM.cxx
CommitLineData
c8fe2783 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// 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
22//
23// -- Author: Gustavo Conesa (INFN-LNF)
24
25#include <cstdlib>
26
27// --- Root ---
28#include <TROOT.h>
29#include <TInterpreter.h>
30#include <TClonesArray.h>
31//#include <Riostream.h>
32//#include <TObjectTable.h>
33
34// --- Analysis ---
35#include "AliAnalysisTaskParticleCorrelationM.h"
36#include "AliAnaPartCorrMaker.h"
37#include "AliCaloTrackReader.h"
38#include "AliPDG.h"
39#include "AliAnalysisManager.h"
40#include "AliMultiEventInputHandler.h"
41#include "AliMixedEvent.h"
42#include "AliAODEvent.h"
43#include "AliESDEvent.h"
44
45ClassImp(AliAnalysisTaskParticleCorrelationM)
46
47////////////////////////////////////////////////////////////////////////
48AliAnalysisTaskParticleCorrelationM::AliAnalysisTaskParticleCorrelationM():
49 AliAnalysisTaskME(),
50 fAna(0x0),
51 fOutputContainer(0x0),
52 fConfigName(""), fCuts(0x0), fInputEvent(NULL)
53{
54 // Default constructor
55}
56
57//_____________________________________________________
58AliAnalysisTaskParticleCorrelationM::AliAnalysisTaskParticleCorrelationM(const char* name):
59 AliAnalysisTaskME(name),
60 fAna(0x0),
61 fOutputContainer(0x0),
62 fConfigName(""), fCuts(0x0), fInputEvent(NULL)
63{
64 // Default constructor
65
66 DefineOutput(1, TList::Class());
67 DefineOutput(2, TList::Class()); // will contain cuts or local params
68}
69
70//_____________________________________________________
71AliAnalysisTaskParticleCorrelationM::~AliAnalysisTaskParticleCorrelationM()
72{
73 // Remove all pointers
74
75// printf("********** Delete Task\n");
76// // Do not delete it here, already done somewhere else, need to understand where.
77// if(fOutputContainer){
78// fOutputContainer->Clear() ;
79// delete fOutputContainer ;
80// }
81
82 delete fInputEvent ;
83 if(fAna) delete fAna;
84
85// printf("********** Task deleted \n");
86}
87
88//_____________________________________________________
89void AliAnalysisTaskParticleCorrelationM::UserCreateOutputObjects()
90{
91 // Create the output container
92 if (DebugLevel() > 1) printf("AliAnalysisTaskParticleCorrelationM::UserCreateOutputObjects() - Begin\n");
93
94 //Get list of aod arrays, add each aod array to analysis frame
95 TClonesArray *array = 0;
f37fa8d2 96 TList * list = fAna->FillAndGetAODBranchList();
97 if (DebugLevel() >= 1) printf("AliAnalysisTaskParticleCorrelationM::UserCreateOutputObjects() - n AOD branches %d\n",list->GetEntries());
98
99 //Put the delta AODs in output file, std or delta
100 if((fAna->GetReader())->WriteDeltaAODToFile()){
101 TString deltaAODName = (fAna->GetReader())->GetDeltaAODFileName();
102 for(Int_t iaod = 0; iaod < list->GetEntries(); iaod++){
103 array = (TClonesArray*) list->At(iaod);
104 if(deltaAODName!="") AddAODBranch("TClonesArray", &array, deltaAODName);//Put it in DeltaAOD file
105 else AddAODBranch("TClonesArray", &array);//Put it in standard AOD file
106 }
107 }
c8fe2783 108
109 //Histograms container
110 OpenFile(1);
111 fOutputContainer = fAna->GetOutputContainer();
f37fa8d2 112
113 if (DebugLevel() >= 1) printf("AliAnalysisTaskParticleCorrelationM::UserCreateOutputObjects() - n histograms %d\n",fOutputContainer->GetEntries());
114
c8fe2783 115 fOutputContainer->SetOwner(kTRUE);
f37fa8d2 116
c8fe2783 117 if (DebugLevel() > 1) printf("AliAnalysisTaskParticleCorrelationM::UserCreateOutputObjects() - End\n");
118
119 PostData(1,fOutputContainer);
120
121}
122//_____________________________________________________
123void AliAnalysisTaskParticleCorrelationM::LocalInit()
124{
125 // Local Initialization
126
127 //Call the Init to initialize the configuration of the analysis
128 Init();
129
130 // Create cuts/param objects and publish to slot
131 fCuts = fAna->GetListOfAnalysisCuts();
132
133 // Post Data
134 PostData(2, fCuts);
135
136}
137
138//_____________________________________________________
139void AliAnalysisTaskParticleCorrelationM::Init()
140{
141 // Initialization
142
143 if (DebugLevel() > 1) printf("AliAnalysisTaskParticleCorrelationM::Init() - Begin\n");
144
145 fInputEvent = new AliMixedEvent() ;
146
147 // Call configuration file if specified
148
149 if (fConfigName.Length()) {
150 printf("AliAnalysisTaskParticleCorrelationM::Init() - ### Configuration file is %s.C ###\n", fConfigName.Data());
151 gROOT->LoadMacro(fConfigName+".C");
152 fAna = (AliAnaPartCorrMaker*) gInterpreter->ProcessLine("ConfigAnalysis()");
153 }
154
155 if(!fAna) {
156 printf("AliAnalysisTaskParticleCorrelationM::Init() - Analysis maker pointer not initialized, no analysis specified, STOP !\n");
157 abort();
158 }
159
160 // Add different generator particles to PDG Data Base
161 // to avoid problems when reading MC generator particles
162 AliPDG::AddParticlesToPdgDataBase();
163
164 //Set in the reader the name of the task in case is needed
165 (fAna->GetReader())->SetTaskName(GetName());
166
167 // Initialise analysis
168 fAna->Init();
169
170 //Delta AOD
171 if((fAna->GetReader())->GetDeltaAODFileName()!="")
172 AliAnalysisManager::GetAnalysisManager()->RegisterExtraFile((fAna->GetReader())->GetDeltaAODFileName());
173
174 if (DebugLevel() > 1) printf("AliAnalysisTaskParticleCorrelationM::Init() - End\n");
175
176}
177
178
179//_____________________________________________________
180void AliAnalysisTaskParticleCorrelationM::UserExec(Option_t */*option*/)
181{
182 // Execute analysis for current event
183 //
184 if (DebugLevel() > 1) printf("AliAnalysisTaskParticleCorrelationM::UserExec() - Begin\n");
185
186 //Get the type of data, check if type is correct
187 Int_t datatype = fAna->GetReader()->GetDataType();
188 if(datatype != AliCaloTrackReader::kESD && datatype != AliCaloTrackReader::kAOD &&
189 datatype != AliCaloTrackReader::kMC){
190 printf("AliAnalysisTaskParticleCorrelationM::UserExec() - Wrong type of data\n");
191 return ;
192 }
193
194 Int_t nev = fInputHandler->GetBufferSize();
195 fInputEvent->Reset();
196
197 for (Int_t iev = 0; iev < nev; iev++) {
198 if (datatype == AliCaloTrackReader::kESD) {
199 AliESDEvent* esd = dynamic_cast<AliESDEvent*>(GetEvent(iev));
200 fInputEvent->AddEvent(esd);
201 } else if (datatype == AliCaloTrackReader::kAOD) {
202 AliAODEvent* aod = dynamic_cast<AliAODEvent*>(GetEvent(iev));
203 fInputEvent->AddEvent(aod);
204 } else {
205 AliFatal("need to implement mixed event for MC") ;
206 }
207 }
208 fInputEvent->Init();
209
210 fAna->GetReader()->SetInputOutputMCEvent(fInputEvent, AODEvent(), MCEvent());
211
212 //Process event
213 fAna->ProcessEvent((Int_t) Entry(), CurrentFileName());
214 //printf("AliAnalysisTaskParticleCorrelationM::Current Event %d; Current File Name : %s\n",(Int_t) Entry(), CurrentFileName());
215 if (DebugLevel() > 1) printf("AliAnalysisTaskParticleCorrelationM::UserExec() - End\n");
216
217 PostData(1, fOutputContainer);
218
219 //gObjectTable->Print();
220
221
222}
223
224//_____________________________________________________
225void AliAnalysisTaskParticleCorrelationM::Terminate(Option_t */*option*/)
226{
227 // Terminate analysis
228 // Do some plots
229
230 // Get merged histograms from the output container
231 // Propagate histagrams to maker
232 fAna->Terminate((TList*)GetOutputData(1));
233
234}
235