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