]>
Commit | Line | Data |
---|---|---|
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 | **************************************************************************/ | |
15 | ||
16 | // root | |
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 | ||
24 | // analysis | |
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" | |
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), | |
46 | fAOD(0x0), | |
47 | fTreeG(0x0), | |
48 | fOutputContainer(0x0), | |
49 | fConfigName(0) | |
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), | |
60 | fAOD(0x0), | |
61 | fTreeG(0x0), | |
62 | fOutputContainer(0x0), | |
63 | fConfigName("ConfigGammaAnalysis") | |
64 | { | |
65 | // Default constructor | |
66 | ||
67 | DefineInput (0, TChain::Class()); | |
68 | DefineOutput(0, TTree::Class()); | |
69 | DefineOutput(1, TList::Class()); | |
70 | ||
71 | } | |
72 | ||
73 | //_____________________________________________________ | |
74 | AliAnalysisTaskGamma::~AliAnalysisTaskGamma() | |
75 | { | |
76 | // Remove all pointers | |
77 | ||
78 | if(fOutputContainer){ | |
79 | fOutputContainer->Clear() ; | |
80 | delete fOutputContainer ; | |
81 | } | |
82 | ||
83 | if(fTreeG) delete fTreeG ; | |
84 | ||
85 | } | |
86 | ||
87 | //_____________________________________________________ | |
88 | void AliAnalysisTaskGamma::CreateOutputObjects() | |
89 | { | |
90 | // Create the output container | |
91 | ||
92 | //AODs | |
93 | // OpenFile(0); | |
94 | AliAODHandler* handler = (AliAODHandler*) ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler()); | |
95 | fAOD = handler->GetAOD(); | |
96 | fTreeG = handler->GetTree(); | |
97 | fAna->ConnectAOD(fAOD); | |
98 | ||
99 | //Histograms container | |
100 | OpenFile(1); | |
101 | fOutputContainer = fAna->GetOutputContainer(); | |
102 | ||
103 | } | |
104 | ||
105 | //_____________________________________________________ | |
106 | void AliAnalysisTaskGamma::Init() | |
107 | { | |
108 | // Initialization | |
109 | AliDebug(1,"Begin"); | |
110 | ||
111 | // Call configuration file | |
112 | ||
113 | if(fConfigName == ""){ | |
114 | fConfigName="ConfigGammaAnalysis"; | |
115 | } | |
116 | ||
117 | AliInfo(Form("### Configuration file is %s.C ###", fConfigName.Data())); | |
118 | gROOT->LoadMacro(fConfigName+".C"); | |
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 | |
128 | /* | |
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); | |
134 | } | |
135 | */ | |
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() "); | |
146 | AliESDInputHandler* esdH = (AliESDInputHandler*) ((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler()); | |
147 | fESD = esdH->GetEvent(); | |
148 | fChain = (TChain*)GetInputData(0); | |
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 | ||
172 | if(mctruth) | |
173 | stack = mctruth->MCEvent()->Stack(); | |
174 | ||
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 | } | |
187 | ||
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 | ||
197 | PostData(0, fTreeG); | |
198 | PostData(1, fOutputContainer); | |
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 |