provide adress of the pointer to new AOD branch, not the pointer itself Mihaela G.
[u/mrichter/AliRoot.git] / PWG4 / AliAnalysisTaskParticleCorrelation.cxx
CommitLineData
d92b41ad 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
16// root
17#include <TROOT.h>
18#include <TSystem.h>
19#include <TInterpreter.h>
20#include <TChain.h>
21#include <TFile.h>
22#include <Riostream.h>
23
24// analysis
25#include "AliAnalysisTaskParticleCorrelation.h"
26#include "AliAnalysisManager.h"
27#include "AliESDInputHandler.h"
28#include "AliMCEventHandler.h"
29#include "AliMCEvent.h"
30#include "AliAnaMaker.h"
31#include "AliCaloTrackReader.h"
32#include "AliESDEvent.h"
33#include "AliAODEvent.h"
34#include "AliAODHandler.h"
35#include "AliStack.h"
36#include "AliLog.h"
37
38ClassImp(AliAnalysisTaskParticleCorrelation)
39
40////////////////////////////////////////////////////////////////////////
41
42 AliAnalysisTaskParticleCorrelation::AliAnalysisTaskParticleCorrelation():
43 AliAnalysisTaskSE(),
44 fAna(0x0),
45 fOutputContainer(0x0),
46 fAODBranch(0x0),
47 fConfigName(0)
48{
49 // Default constructor
50}
51
52//_____________________________________________________
53AliAnalysisTaskParticleCorrelation::AliAnalysisTaskParticleCorrelation(const char* name):
54 AliAnalysisTaskSE(name),
55 fAna(0x0),
56 fOutputContainer(0x0),
57 fAODBranch(0x0),
58 fConfigName("ConfigAnalysis")
59{
60 // Default constructor
61
62 DefineOutput(1, TList::Class());
63
64}
65
66//_____________________________________________________
67AliAnalysisTaskParticleCorrelation::~AliAnalysisTaskParticleCorrelation()
68{
69 // Remove all pointers
70
71 if(fOutputContainer){
72 fOutputContainer->Clear() ;
73 delete fOutputContainer ;
74 }
75
76}
77
78//_____________________________________________________
79void AliAnalysisTaskParticleCorrelation::UserCreateOutputObjects()
80{
81 // Create the output container
82 if (fDebug > 1) printf("AnalysisTaskParticleCorrelation::CreateOutputData() \n");
83
84 //AODs
85 fAODBranch = new TClonesArray("AliAODParticleCorrelation", 0);
86 fAODBranch->SetName(fAna->GetAODBranchName());
9401440e 87 AddAODBranch("TClonesArray", &fAODBranch);
d92b41ad 88 fAna->SetAODBranch(fAODBranch);
89
90 //Histograms container
91 OpenFile(1);
92 fOutputContainer = fAna->GetOutputContainer();
93
94}
95
96//_____________________________________________________
97void AliAnalysisTaskParticleCorrelation::Init()
98{
99 // Initialization
100 if (fDebug > 1) printf("AnalysisTaskParticleCorrelation::Init() \n");
101
102 // Call configuration file
103
104 if(fConfigName == ""){
105 fConfigName="ConfigAnalysis";
106 }
107
108 AliInfo(Form("### Configuration file is %s.C ###", fConfigName.Data()));
109 gROOT->LoadMacro(fConfigName+".C");
110 fAna = (AliAnaMaker*) gInterpreter->ProcessLine("ConfigAnalysis()");
111
112 if(!fAna)
113 AliFatal("Analysis pointer not initialized, abort analysis!");
114
115 // Initialise analysis
116 fAna->Init();
117
118 AliDebug(1,"End");
119
120}
121
122
123//_____________________________________________________
124void AliAnalysisTaskParticleCorrelation::UserExec(Option_t */*option*/)
125{
126 // Execute analysis for current event
127 //
128 if (fDebug > 1) printf("AnalysisTaskParticleCorrelation::Exec() \n");
129
130 //Get the type of data, check if type is correct
131 Int_t datatype = fAna->GetReader()->GetDataType();
132 if(datatype != AliCaloTrackReader::kESD && datatype != AliCaloTrackReader::kAOD &&
133 datatype != AliCaloTrackReader::kMC){
134 AliFatal("Wrong type of data");
135 return ;
136 }
137
138 fAna->GetReader()->SetInputEvent(InputEvent(), AODEvent(), MCEvent());
139
140 //Process event
141 fAna->ProcessEvent((Int_t) Entry());
142
143 PostData(1, fOutputContainer);
144
145}
146
147//_____________________________________________________
148void AliAnalysisTaskParticleCorrelation::Terminate(Option_t */*option*/)
149{
150 // Terminate analysis
151 //
152 AliDebug(1,"Do nothing in Terminate");
153 //fAna->Terminate();
154}
155