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 **************************************************************************/
18 #include <TInterpreter.h>
21 #include <Riostream.h>
23 #include "AliAnalysisTaskGamma.h"
24 #include "AliAnalysisManager.h"
25 #include "AliMCEventHandler.h"
26 #include "AliAnaGamma.h"
27 #include "AliGammaReader.h"
28 #include "AliESDEvent.h"
32 ClassImp(AliAnalysisTaskGamma)
34 ////////////////////////////////////////////////////////////////////////
36 AliAnalysisTaskGamma::AliAnalysisTaskGamma():
40 fTreeG(0x0),//Not used for the moment
43 // Default constructor
46 //_____________________________________________________
47 AliAnalysisTaskGamma::AliAnalysisTaskGamma(const char* name):
48 AliAnalysisTask(name, "AnalysisTaskGamma"),
52 fTreeG(0x0),//Not used for the moment
55 // Default constructor
59 DefineInput (0, TChain::Class());
60 //DefineOutput(0, TTree::Class());// to create AODs, to be done
61 DefineOutput(0, TList::Class());
65 //_____________________________________________________
66 AliAnalysisTaskGamma::~AliAnalysisTaskGamma()
69 // Remove all pointers
70 fOutputContainer->Clear() ;
71 delete fOutputContainer ;
73 delete fTreeG ; //Not used for the moment
76 //_____________________________________________________
77 void AliAnalysisTaskGamma::CreateOutputObjects()
79 // Create the output container
81 //fTreeG = new TTree ; // fAna->MakeTreeG("TreeG");// to create AODs, to be done
85 fOutputContainer = fAna->GetOutputContainer();
89 //_____________________________________________________
90 void AliAnalysisTaskGamma::Init()
95 // Call configuration file
96 gROOT->LoadMacro("ConfigGammaAnalysis.C");
97 fAna = (AliAnaGamma*) gInterpreter->ProcessLine("ConfigGammaAnalysis()");
100 AliFatal("Analysis pointer not initialized, abort analysis!");
102 // Initialise Gamma Analysis
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);
116 //_____________________________________________________
117 void AliAnalysisTaskGamma::ConnectInputData(Option_t */*option*/)
119 // Connect the input data
121 AliDebug(1,"ConnectInputData() ");
122 fChain = (TChain*)GetInputData(0);
123 fESD = new AliESDEvent();
124 fESD->ReadFromTree(fChain);
128 //_____________________________________________________
129 void AliAnalysisTaskGamma::Exec(Option_t */*option*/)
131 // Execute analysis for current event
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");
144 AliStack* stack = 0x0;
145 if(datatype == AliGammaReader::kMC || datatype == AliGammaReader::kMCData ){
146 AliMCEventHandler* mctruth = (AliMCEventHandler*)
147 ((AliAnalysisManager::GetAnalysisManager())->GetMCtruthEventHandler());
150 stack = mctruth->Stack();
151 //printf("AliAnalysisTaskJets: Number of tracks %5d\n", stack->GetNtrack());
156 Long64_t ientry = fChain->GetReadEntry();
157 if ( !((ientry)%100) )
158 AliInfo(Form("Analysing event # %5d\n", (Int_t) ientry));
160 //Pass ESD pointer to analysis
162 AliError("fESD is not connected to the input!") ;
167 //In case of montecarlo analysis, pass the stack also.
168 if((datatype == AliGammaReader::kMC || datatype == AliGammaReader::kMCData ) && stack)
169 fAna -> SetKine(stack);
172 fAna->ProcessEvent(ientry);
174 //PostData(0, fTreeG); // Create AODs, to be done.
175 PostData(0, fOutputContainer);
179 //_____________________________________________________
180 void AliAnalysisTaskGamma::Terminate(Option_t */*option*/)
182 // Terminate analysis
184 AliDebug(1,"Do nothing in Terminate");