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 **************************************************************************/
19 #include <TInterpreter.h>
22 #include <Riostream.h>
25 #include "AliAnalysisTaskGamma.h"
26 #include "AliAnalysisManager.h"
27 #include "AliESDInputHandler.h"
28 #include "AliMCEventHandler.h"
29 #include "AliMCEvent.h"
30 #include "AliAnaGamma.h"
31 #include "AliGammaReader.h"
32 #include "AliESDEvent.h"
33 #include "AliAODEvent.h"
34 #include "AliAODHandler.h"
38 ClassImp(AliAnalysisTaskGamma)
40 ////////////////////////////////////////////////////////////////////////
42 AliAnalysisTaskGamma::AliAnalysisTaskGamma():
48 fOutputContainer(0x0),
51 // Default constructor
54 //_____________________________________________________
55 AliAnalysisTaskGamma::AliAnalysisTaskGamma(const char* name):
56 AliAnalysisTask(name, "AnalysisTaskGamma"),
62 fOutputContainer(0x0),
63 fConfigName("ConfigGammaAnalysis")
65 // Default constructor
67 DefineInput (0, TChain::Class());
68 DefineOutput(0, TTree::Class());
69 DefineOutput(1, TList::Class());
73 //_____________________________________________________
74 AliAnalysisTaskGamma::~AliAnalysisTaskGamma()
76 // Remove all pointers
79 fOutputContainer->Clear() ;
80 delete fOutputContainer ;
83 if(fTreeG) delete fTreeG ;
87 //_____________________________________________________
88 void AliAnalysisTaskGamma::CreateOutputObjects()
90 // Create the output container
94 AliAODHandler* handler = (AliAODHandler*) ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
95 fAOD = handler->GetAOD();
96 fTreeG = handler->GetTree();
97 fAna->ConnectAOD(fAOD);
99 //Histograms container
101 fOutputContainer = fAna->GetOutputContainer();
105 //_____________________________________________________
106 void AliAnalysisTaskGamma::Init()
111 // Call configuration file
113 if(fConfigName == ""){
114 fConfigName="ConfigGammaAnalysis";
117 AliInfo(Form("### Configuration file is %s.C ###", fConfigName.Data()));
118 gROOT->LoadMacro(fConfigName+".C");
119 fAna = (AliAnaGamma*) gInterpreter->ProcessLine("ConfigGammaAnalysis()");
122 AliFatal("Analysis pointer not initialized, abort analysis!");
124 // Initialise Gamma Analysis
127 //In case of MC analysis
129 // NOT ALLOWED TO SET MC HANDLER FROM WITHIN AN ANALYSIS TASK !!! (MG)
130 Int_t datatype = fAna->GetReader()->GetDataType();
131 if(datatype == AliGammaReader::kMC || datatype == AliGammaReader::kMCData ){
132 AliMCEventHandler * mc = new AliMCEventHandler();
133 (AliAnalysisManager::GetAnalysisManager())->SetMCtruthEventHandler(mc);
140 //_____________________________________________________
141 void AliAnalysisTaskGamma::ConnectInputData(Option_t */*option*/)
143 // Connect the input data
145 AliDebug(1,"ConnectInputData() ");
146 AliESDInputHandler* esdH = (AliESDInputHandler*) ((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
147 fESD = esdH->GetEvent();
148 fChain = (TChain*)GetInputData(0);
151 //_____________________________________________________
152 void AliAnalysisTaskGamma::Exec(Option_t */*option*/)
154 // Execute analysis for current event
157 //Get the type of data, check if type is correct
158 Int_t datatype = fAna->GetReader()->GetDataType();
159 if(datatype != AliGammaReader::kData &&
160 datatype != AliGammaReader::kMC &&
161 datatype != AliGammaReader::kMCData){
162 AliFatal("Wrong type of data");
167 AliStack* stack = 0x0;
168 if(datatype == AliGammaReader::kMC || datatype == AliGammaReader::kMCData ){
169 AliMCEventHandler* mctruth = (AliMCEventHandler*)
170 ((AliAnalysisManager::GetAnalysisManager())->GetMCtruthEventHandler());
173 stack = mctruth->MCEvent()->Stack();
178 Long64_t ientry = fChain->GetReadEntry();
179 if ( !((ientry)%100) )
180 AliInfo(Form("Analysing event # %5d\n", (Int_t) ientry));
182 //Pass ESD pointer to analysis
184 AliError("fESD is not connected to the input!") ;
190 //In case of montecarlo analysis, pass the stack also.
191 if((datatype == AliGammaReader::kMC || datatype == AliGammaReader::kMCData ) && stack)
192 fAna -> SetKine(stack);
195 fAna->ProcessEvent(ientry);
198 PostData(1, fOutputContainer);
202 //_____________________________________________________
203 void AliAnalysisTaskGamma::Terminate(Option_t */*option*/)
205 // Terminate analysis
207 AliDebug(1,"Do nothing in Terminate");