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 "AliMCEventHandler.h"
28 #include "AliMCEvent.h"
29 #include "AliAnaGamma.h"
30 #include "AliGammaReader.h"
31 #include "AliESDEvent.h"
32 #include "AliAODEvent.h"
33 #include "AliAODHandler.h"
37 ClassImp(AliAnalysisTaskGamma)
39 ////////////////////////////////////////////////////////////////////////
41 AliAnalysisTaskGamma::AliAnalysisTaskGamma():
49 // Default constructor
52 //_____________________________________________________
53 AliAnalysisTaskGamma::AliAnalysisTaskGamma(const char* name):
54 AliAnalysisTask(name, "AnalysisTaskGamma"),
62 // Default constructor
64 DefineInput (0, TChain::Class());
65 DefineOutput(0, TTree::Class());
66 DefineOutput(1, TList::Class());
70 //_____________________________________________________
71 AliAnalysisTaskGamma::~AliAnalysisTaskGamma()
73 // Remove all pointers
76 fOutputContainer->Clear() ;
77 delete fOutputContainer ;
80 if(fTreeG) delete fTreeG ;
84 //_____________________________________________________
85 void AliAnalysisTaskGamma::CreateOutputObjects()
87 // Create the output container
91 AliAODHandler* handler = (AliAODHandler*) ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
92 fAOD = handler->GetAOD();
93 fTreeG = handler->GetTree();
94 fAna->ConnectAOD(fAOD);
96 //Histograms container
98 fOutputContainer = fAna->GetOutputContainer();
102 //_____________________________________________________
103 void AliAnalysisTaskGamma::Init()
108 // Call configuration file
109 gROOT->LoadMacro("ConfigGammaAnalysis.C");
110 fAna = (AliAnaGamma*) gInterpreter->ProcessLine("ConfigGammaAnalysis()");
113 AliFatal("Analysis pointer not initialized, abort analysis!");
115 // Initialise Gamma Analysis
118 //In case of MC analysis
119 Int_t datatype = fAna->GetReader()->GetDataType();
120 if(datatype == AliGammaReader::kMC || datatype == AliGammaReader::kMCData ){
121 AliMCEventHandler * mc = new AliMCEventHandler();
122 (AliAnalysisManager::GetAnalysisManager())->SetMCtruthEventHandler(mc);
129 //_____________________________________________________
130 void AliAnalysisTaskGamma::ConnectInputData(Option_t */*option*/)
132 // Connect the input data
134 AliDebug(1,"ConnectInputData() ");
135 fChain = (TChain*)GetInputData(0);
136 fESD = new AliESDEvent();
137 fESD->ReadFromTree(fChain);
141 //_____________________________________________________
142 void AliAnalysisTaskGamma::Exec(Option_t */*option*/)
144 // Execute analysis for current event
147 //Get the type of data, check if type is correct
148 Int_t datatype = fAna->GetReader()->GetDataType();
149 if(datatype != AliGammaReader::kData &&
150 datatype != AliGammaReader::kMC &&
151 datatype != AliGammaReader::kMCData){
152 AliFatal("Wrong type of data");
157 AliStack* stack = 0x0;
158 if(datatype == AliGammaReader::kMC || datatype == AliGammaReader::kMCData ){
159 AliMCEventHandler* mctruth = (AliMCEventHandler*)
160 ((AliAnalysisManager::GetAnalysisManager())->GetMCtruthEventHandler());
163 stack = mctruth->MCEvent()->Stack();
168 Long64_t ientry = fChain->GetReadEntry();
169 if ( !((ientry)%100) )
170 AliInfo(Form("Analysing event # %5d\n", (Int_t) ientry));
172 //Pass ESD pointer to analysis
174 AliError("fESD is not connected to the input!") ;
180 //In case of montecarlo analysis, pass the stack also.
181 if((datatype == AliGammaReader::kMC || datatype == AliGammaReader::kMCData ) && stack)
182 fAna -> SetKine(stack);
185 fAna->ProcessEvent(ientry);
188 PostData(1, fOutputContainer);
192 //_____________________________________________________
193 void AliAnalysisTaskGamma::Terminate(Option_t */*option*/)
195 // Terminate analysis
197 AliDebug(1,"Do nothing in Terminate");