]>
Commit | Line | Data |
---|---|---|
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 | **************************************************************************/ | |
4b707925 | 15 | |
16 | // root | |
bdcfac30 | 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 | ||
4b707925 | 24 | // analysis |
bdcfac30 | 25 | #include "AliAnalysisTaskGamma.h" |
26 | #include "AliAnalysisManager.h" | |
2021085e | 27 | #include "AliESDInputHandler.h" |
bdcfac30 | 28 | #include "AliMCEventHandler.h" |
4b707925 | 29 | #include "AliMCEvent.h" |
bdcfac30 | 30 | #include "AliAnaGamma.h" |
31 | #include "AliGammaReader.h" | |
32 | #include "AliESDEvent.h" | |
4b707925 | 33 | #include "AliAODEvent.h" |
34 | #include "AliAODHandler.h" | |
bdcfac30 | 35 | #include "AliStack.h" |
36 | #include "AliLog.h" | |
37 | ||
38 | ClassImp(AliAnalysisTaskGamma) | |
39 | ||
40 | //////////////////////////////////////////////////////////////////////// | |
41 | ||
42 | AliAnalysisTaskGamma::AliAnalysisTaskGamma(): | |
43 | fAna(0x0), | |
44 | fChain(0x0), | |
45 | fESD(0x0), | |
4b707925 | 46 | fAOD(0x0), |
47 | fTreeG(0x0), | |
3bb2c538 | 48 | fOutputContainer(0x0), |
49 | fConfigName(0) | |
bdcfac30 | 50 | { |
51 | // Default constructor | |
52 | } | |
53 | ||
54 | //_____________________________________________________ | |
55 | AliAnalysisTaskGamma::AliAnalysisTaskGamma(const char* name): | |
56 | AliAnalysisTask(name, "AnalysisTaskGamma"), | |
57 | fAna(0x0), | |
58 | fChain(0x0), | |
59 | fESD(0x0), | |
4b707925 | 60 | fAOD(0x0), |
61 | fTreeG(0x0), | |
3bb2c538 | 62 | fOutputContainer(0x0), |
63 | fConfigName("ConfigGammaAnalysis") | |
bdcfac30 | 64 | { |
65 | // Default constructor | |
bdcfac30 | 66 | |
67 | DefineInput (0, TChain::Class()); | |
4b707925 | 68 | DefineOutput(0, TTree::Class()); |
69 | DefineOutput(1, TList::Class()); | |
bdcfac30 | 70 | |
71 | } | |
72 | ||
73 | //_____________________________________________________ | |
74 | AliAnalysisTaskGamma::~AliAnalysisTaskGamma() | |
75 | { | |
bdcfac30 | 76 | // Remove all pointers |
4b707925 | 77 | |
78 | if(fOutputContainer){ | |
79 | fOutputContainer->Clear() ; | |
80 | delete fOutputContainer ; | |
81 | } | |
82 | ||
83 | if(fTreeG) delete fTreeG ; | |
bdcfac30 | 84 | |
bdcfac30 | 85 | } |
86 | ||
87 | //_____________________________________________________ | |
88 | void AliAnalysisTaskGamma::CreateOutputObjects() | |
89 | { | |
90 | // Create the output container | |
bdcfac30 | 91 | |
4b707925 | 92 | //AODs |
2021085e | 93 | // OpenFile(0); |
4b707925 | 94 | AliAODHandler* handler = (AliAODHandler*) ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler()); |
95 | fAOD = handler->GetAOD(); | |
96 | fTreeG = handler->GetTree(); | |
97 | fAna->ConnectAOD(fAOD); | |
bdcfac30 | 98 | |
4b707925 | 99 | //Histograms container |
100 | OpenFile(1); | |
101 | fOutputContainer = fAna->GetOutputContainer(); | |
102 | ||
bdcfac30 | 103 | } |
104 | ||
105 | //_____________________________________________________ | |
106 | void AliAnalysisTaskGamma::Init() | |
107 | { | |
108 | // Initialization | |
109 | AliDebug(1,"Begin"); | |
4b707925 | 110 | |
bdcfac30 | 111 | // Call configuration file |
3bb2c538 | 112 | |
113 | if(fConfigName == ""){ | |
114 | fConfigName="ConfigGammaAnalysis"; | |
115 | } | |
116 | ||
117 | AliInfo(Form("### Configuration file is %s.C ###", fConfigName.Data())); | |
118 | gROOT->LoadMacro(fConfigName+".C"); | |
bdcfac30 | 119 | fAna = (AliAnaGamma*) gInterpreter->ProcessLine("ConfigGammaAnalysis()"); |
120 | ||
121 | if(!fAna) | |
122 | AliFatal("Analysis pointer not initialized, abort analysis!"); | |
123 | ||
124 | // Initialise Gamma Analysis | |
125 | fAna->Init(); | |
126 | ||
127 | //In case of MC analysis | |
2021085e | 128 | /* |
129 | // NOT ALLOWED TO SET MC HANDLER FROM WITHIN AN ANALYSIS TASK !!! (MG) | |
bdcfac30 | 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); | |
134 | } | |
2021085e | 135 | */ |
bdcfac30 | 136 | AliDebug(1,"End"); |
137 | ||
138 | } | |
139 | ||
140 | //_____________________________________________________ | |
141 | void AliAnalysisTaskGamma::ConnectInputData(Option_t */*option*/) | |
142 | { | |
143 | // Connect the input data | |
144 | // | |
145 | AliDebug(1,"ConnectInputData() "); | |
2021085e | 146 | AliESDInputHandler* esdH = (AliESDInputHandler*) ((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler()); |
147 | fESD = esdH->GetEvent(); | |
bdcfac30 | 148 | fChain = (TChain*)GetInputData(0); |
bdcfac30 | 149 | } |
150 | ||
151 | //_____________________________________________________ | |
152 | void AliAnalysisTaskGamma::Exec(Option_t */*option*/) | |
153 | { | |
154 | // Execute analysis for current event | |
155 | // | |
156 | ||
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"); | |
163 | return ; | |
164 | } | |
165 | ||
166 | //Get MC data | |
167 | AliStack* stack = 0x0; | |
168 | if(datatype == AliGammaReader::kMC || datatype == AliGammaReader::kMCData ){ | |
169 | AliMCEventHandler* mctruth = (AliMCEventHandler*) | |
170 | ((AliAnalysisManager::GetAnalysisManager())->GetMCtruthEventHandler()); | |
171 | ||
4b707925 | 172 | if(mctruth) |
173 | stack = mctruth->MCEvent()->Stack(); | |
174 | ||
bdcfac30 | 175 | } |
176 | ||
177 | //Get Event | |
178 | Long64_t ientry = fChain->GetReadEntry(); | |
179 | if ( !((ientry)%100) ) | |
180 | AliInfo(Form("Analysing event # %5d\n", (Int_t) ientry)); | |
181 | ||
182 | //Pass ESD pointer to analysis | |
183 | if (!fESD) { | |
184 | AliError("fESD is not connected to the input!") ; | |
185 | return ; | |
186 | } | |
4b707925 | 187 | |
bdcfac30 | 188 | fAna->SetData(fESD); |
189 | ||
190 | //In case of montecarlo analysis, pass the stack also. | |
191 | if((datatype == AliGammaReader::kMC || datatype == AliGammaReader::kMCData ) && stack) | |
192 | fAna -> SetKine(stack); | |
193 | ||
194 | //Process event | |
195 | fAna->ProcessEvent(ientry); | |
196 | ||
4b707925 | 197 | PostData(0, fTreeG); |
198 | PostData(1, fOutputContainer); | |
bdcfac30 | 199 | |
200 | } | |
201 | ||
202 | //_____________________________________________________ | |
203 | void AliAnalysisTaskGamma::Terminate(Option_t */*option*/) | |
204 | { | |
205 | // Terminate analysis | |
206 | // | |
207 | AliDebug(1,"Do nothing in Terminate"); | |
208 | ||
209 | } | |
210 |