]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG4/AliAnalysisTaskGamma.cxx
updates to comply with AliTOFGeometryV5 becoming AliTOFGeometry and Calibration objects
[u/mrichter/AliRoot.git] / PWG4 / AliAnalysisTaskGamma.cxx
CommitLineData
bdcfac30 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#include <TROOT.h>
17#include <TSystem.h>
18#include <TInterpreter.h>
19#include <TChain.h>
20#include <TFile.h>
21#include <Riostream.h>
22
23#include "AliAnalysisTaskGamma.h"
24#include "AliAnalysisManager.h"
25#include "AliMCEventHandler.h"
26#include "AliAnaGamma.h"
27#include "AliGammaReader.h"
28#include "AliESDEvent.h"
29#include "AliStack.h"
30#include "AliLog.h"
31
32ClassImp(AliAnalysisTaskGamma)
33
34////////////////////////////////////////////////////////////////////////
35
36AliAnalysisTaskGamma::AliAnalysisTaskGamma():
37 fAna(0x0),
38 fChain(0x0),
39 fESD(0x0),
40 fTreeG(0x0),//Not used for the moment
41 fOutputContainer(0x0)
42{
43 // Default constructor
44}
45
46//_____________________________________________________
47AliAnalysisTaskGamma::AliAnalysisTaskGamma(const char* name):
48 AliAnalysisTask(name, "AnalysisTaskGamma"),
49 fAna(0x0),
50 fChain(0x0),
51 fESD(0x0),
52 fTreeG(0x0),//Not used for the moment
53 fOutputContainer(0x0)
54{
55 // Default constructor
56
57 Init();
58
59 DefineInput (0, TChain::Class());
60 //DefineOutput(0, TTree::Class());// to create AODs, to be done
61 DefineOutput(0, TList::Class());
62
63}
64
65//_____________________________________________________
66AliAnalysisTaskGamma::~AliAnalysisTaskGamma()
67{
68
69 // Remove all pointers
70 fOutputContainer->Clear() ;
71 delete fOutputContainer ;
72
73 delete fTreeG ; //Not used for the moment
74}
75
76//_____________________________________________________
77void AliAnalysisTaskGamma::CreateOutputObjects()
78{
79 // Create the output container
80 //OpenFile(0);
81 //fTreeG = new TTree ; // fAna->MakeTreeG("TreeG");// to create AODs, to be done
82
83 OpenFile(0);
84
85 fOutputContainer = fAna->GetOutputContainer();
86
87}
88
89//_____________________________________________________
90void AliAnalysisTaskGamma::Init()
91{
92 // Initialization
93 AliDebug(1,"Begin");
94
95 // Call configuration file
96 gROOT->LoadMacro("ConfigGammaAnalysis.C");
97 fAna = (AliAnaGamma*) gInterpreter->ProcessLine("ConfigGammaAnalysis()");
98
99 if(!fAna)
100 AliFatal("Analysis pointer not initialized, abort analysis!");
101
102 // Initialise Gamma Analysis
103 fAna->Init();
104
105 //In case of MC analysis
106 Int_t datatype = fAna->GetReader()->GetDataType();
107 if(datatype == AliGammaReader::kMC || datatype == AliGammaReader::kMCData ){
108 AliMCEventHandler * mc = new AliMCEventHandler();
109 (AliAnalysisManager::GetAnalysisManager())->SetMCtruthEventHandler(mc);
110 }
111
112 AliDebug(1,"End");
113
114}
115
116//_____________________________________________________
117void AliAnalysisTaskGamma::ConnectInputData(Option_t */*option*/)
118{
119 // Connect the input data
120 //
121 AliDebug(1,"ConnectInputData() ");
122 fChain = (TChain*)GetInputData(0);
123 fESD = new AliESDEvent();
124 fESD->ReadFromTree(fChain);
125
126}
127
128//_____________________________________________________
129void AliAnalysisTaskGamma::Exec(Option_t */*option*/)
130{
131 // Execute analysis for current event
132 //
133
134 //Get the type of data, check if type is correct
135 Int_t datatype = fAna->GetReader()->GetDataType();
136 if(datatype != AliGammaReader::kData &&
137 datatype != AliGammaReader::kMC &&
138 datatype != AliGammaReader::kMCData){
139 AliFatal("Wrong type of data");
140 return ;
141 }
142
143 //Get MC data
144 AliStack* stack = 0x0;
145 if(datatype == AliGammaReader::kMC || datatype == AliGammaReader::kMCData ){
146 AliMCEventHandler* mctruth = (AliMCEventHandler*)
147 ((AliAnalysisManager::GetAnalysisManager())->GetMCtruthEventHandler());
148
149 if(mctruth){
150 stack = mctruth->Stack();
151 //printf("AliAnalysisTaskJets: Number of tracks %5d\n", stack->GetNtrack());
152 }
153 }
154
155 //Get Event
156 Long64_t ientry = fChain->GetReadEntry();
157 if ( !((ientry)%100) )
158 AliInfo(Form("Analysing event # %5d\n", (Int_t) ientry));
159
160 //Pass ESD pointer to analysis
161 if (!fESD) {
162 AliError("fESD is not connected to the input!") ;
163 return ;
164 }
165 fAna->SetData(fESD);
166
167 //In case of montecarlo analysis, pass the stack also.
168 if((datatype == AliGammaReader::kMC || datatype == AliGammaReader::kMCData ) && stack)
169 fAna -> SetKine(stack);
170
171 //Process event
172 fAna->ProcessEvent(ientry);
173
174 //PostData(0, fTreeG); // Create AODs, to be done.
175 PostData(0, fOutputContainer);
176
177}
178
179//_____________________________________________________
180void AliAnalysisTaskGamma::Terminate(Option_t */*option*/)
181{
182 // Terminate analysis
183 //
184 AliDebug(1,"Do nothing in Terminate");
185
186}
187