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