]>
Commit | Line | Data |
---|---|---|
a65a7e70 | 1 | #include "TChain.h" |
2 | #include "TTree.h" | |
3 | #include "TString.h" | |
4 | #include "TList.h" | |
5 | #include "TH2F.h" | |
6 | ||
7 | #include "AliAnalysisTask.h" | |
8 | #include "AliAnalysisManager.h" | |
9 | ||
10 | #include "AliESDEvent.h" | |
11 | #include "AliESDInputHandler.h" | |
12 | #include "AliAODEvent.h" | |
13 | #include "AliAODInputHandler.h" | |
14 | #include "AliMCEventHandler.h" | |
15 | #include "AliMCEvent.h" | |
16 | #include "AliStack.h" | |
17 | #include "AliESDVertex.h" | |
18 | ||
19 | #include "AliProtonFeedDownAnalysis.h" | |
20 | #include "AliProtonAnalysisBase.h" | |
21 | #include "AliProtonCorrectionAnalysisTask.h" | |
22 | ||
23 | #include "AliProtonAbsorptionCorrection.h" | |
24 | #include "AliProtonSpectraCorrection.h" | |
25 | ||
26 | #include <Riostream.h> | |
27 | ||
28 | ClassImp(AliProtonCorrectionAnalysisTask) | |
29 | ||
30 | //________________________________________________________________________ | |
31 | AliProtonCorrectionAnalysisTask::AliProtonCorrectionAnalysisTask() | |
32 | : AliAnalysisTask(), fESD(0), fAOD(0), fMC(0), | |
33 | fList(0),fProtonAnalysisBase(0),fProtonAbsorptionCorrection(0), fProtonFeedDownAnalysis(0),fProtonSpectraCorrection(0),fStatHist(0), | |
34 | fIsOn_AliProtonAbsorptionCorrection(0),fIsOn_AliProtonFeedDownAnalysis(0),fIsOn_AliProtonSpectraCorrection(0) | |
35 | { | |
36 | //Dummy constructor | |
37 | ||
38 | } | |
39 | ||
40 | //________________________________________________________________________ | |
41 | AliProtonCorrectionAnalysisTask::AliProtonCorrectionAnalysisTask(const char *name) | |
42 | : AliAnalysisTask(name, ""), fESD(0), fAOD(0), fMC(0), | |
43 | fList(0),fProtonAnalysisBase(0),fProtonAbsorptionCorrection(0), fProtonFeedDownAnalysis(0),fProtonSpectraCorrection(0),fStatHist(0), | |
44 | fIsOn_AliProtonAbsorptionCorrection(0),fIsOn_AliProtonFeedDownAnalysis(0),fIsOn_AliProtonSpectraCorrection(0) | |
45 | { | |
46 | // Constructor | |
47 | ||
48 | // Define input and output slots here | |
49 | // Input slot #0 works with a TChain | |
50 | DefineInput(0, TChain::Class()); | |
51 | // Output slot #0 writes into a TList container | |
52 | DefineOutput(0, TList::Class()); | |
53 | } | |
54 | ||
55 | //________________________________________________________________________ | |
56 | void AliProtonCorrectionAnalysisTask::ConnectInputData(Option_t *) | |
57 | { | |
58 | // Connect ESD or AOD here | |
59 | // Called once | |
60 | TString gAnalysisLevel = fProtonAnalysisBase->GetAnalysisLevel(); | |
61 | ||
62 | TTree* tree = dynamic_cast<TTree*> (GetInputData(0)); | |
63 | if (!tree) | |
64 | { | |
65 | Printf("ERROR: Could not read chain from input slot 0"); | |
66 | } | |
67 | else | |
68 | { | |
69 | if(gAnalysisLevel == "ESD") | |
70 | { | |
71 | AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()); | |
72 | if (!esdH) | |
73 | { | |
74 | Printf("ERROR: Could not get ESDInputHandler"); | |
75 | } | |
76 | else | |
77 | fESD = esdH->GetEvent(); | |
78 | AliMCEventHandler* mcH = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler()); | |
79 | if (!mcH) | |
80 | { | |
81 | Printf("ERROR: Could not retrieve MC event handler"); | |
82 | } | |
83 | else | |
84 | fMC = mcH->MCEvent(); | |
85 | } | |
86 | else if(gAnalysisLevel == "AOD") | |
87 | { | |
88 | AliAODInputHandler *aodH = dynamic_cast<AliAODInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()); | |
89 | if (!aodH) | |
90 | { | |
91 | Printf("ERROR: Could not get AODInputHandler"); | |
92 | } | |
93 | else | |
94 | fAOD = aodH->GetEvent(); | |
95 | } | |
96 | else | |
97 | Printf("Wrong analysis type: Only ESD, AOD types are allowed!"); | |
98 | } | |
99 | } | |
100 | //________________________________________________________________________ | |
101 | void AliProtonCorrectionAnalysisTask::CreateOutputObjects() | |
102 | { | |
103 | // Create output objects | |
104 | // Called once | |
105 | fList = new TList(); | |
106 | if(fIsOn_AliProtonAbsorptionCorrection) | |
107 | { | |
108 | fProtonAbsorptionCorrection->GetProtonContainer()->SetName("containerProtonsAbsorptionCorrection"); | |
109 | fList->Add(fProtonAbsorptionCorrection->GetProtonContainer()); | |
110 | fProtonAbsorptionCorrection->GetAntiProtonContainer()->SetName("containerAntiProtonsAbsorptionCorrection"); | |
111 | fList->Add(fProtonAbsorptionCorrection->GetAntiProtonContainer()); | |
112 | } | |
113 | if(fIsOn_AliProtonFeedDownAnalysis) | |
114 | { | |
115 | fProtonFeedDownAnalysis->GetProtonContainer()->SetName("containerProtonsFeedDown"); | |
116 | fList->Add(fProtonFeedDownAnalysis->GetProtonContainer()); | |
117 | fProtonFeedDownAnalysis->GetAntiProtonContainer()->SetName("containerAntiProtonsFeedDown"); | |
118 | fList->Add(fProtonFeedDownAnalysis->GetAntiProtonContainer()); | |
119 | fList->Add(fProtonFeedDownAnalysis->GetLambdaHist()); | |
120 | fList->Add(fProtonFeedDownAnalysis->GetLambdaweightedHist()); | |
121 | fList->Add(fProtonFeedDownAnalysis->GetAntiLambdaHist()); | |
122 | fList->Add(fProtonFeedDownAnalysis->GetAntiLambdaweightedHist()); | |
123 | } | |
124 | if(fIsOn_AliProtonSpectraCorrection) | |
125 | { | |
126 | fProtonSpectraCorrection->GetProtonContainer()->SetName("containerProtonsSpectraCorrection"); | |
127 | fList->Add(fProtonSpectraCorrection->GetProtonContainer()); | |
128 | fProtonSpectraCorrection->GetProtonContainer()->SetName("containerAntiProtonsSpectraCorrection"); | |
129 | fList->Add(fProtonSpectraCorrection->GetAntiProtonContainer()); | |
130 | } | |
131 | fStatHist=new TH1F("StatsHist","StatsHist",10,-0.5,9.5); | |
132 | fList->Add(fStatHist); | |
133 | fStatHist->GetXaxis()->SetBinLabel(1,"level1cutESD"); | |
134 | fStatHist->GetXaxis()->SetBinLabel(2,"level2cutTrigger"); | |
135 | fStatHist->GetXaxis()->SetBinLabel(3,"level3cutVerstex"); | |
136 | fStatHist->GetXaxis()->SetBinLabel(4,"level4cutMC"); | |
137 | } | |
138 | //________________________________________________________________________ | |
139 | void AliProtonCorrectionAnalysisTask::Exec(Option_t *) | |
140 | { | |
141 | // Main loop | |
142 | // Called for each event | |
143 | TString gAnalysisLevel =fProtonAnalysisBase->GetAnalysisLevel(); | |
144 | //TString gAnalysisLevel = (fProtonFeedDownAnalysis->GetProtonAnalysisBaseObject())->GetAnalysisLevel(); | |
145 | if(gAnalysisLevel == "ESD") | |
146 | { | |
147 | if (!fESD) | |
148 | { | |
149 | Printf("ERROR: fESD not available"); | |
150 | return; | |
151 | } | |
152 | fStatHist->Fill(0); | |
153 | if(fProtonAnalysisBase->IsEventTriggered(fESD,fProtonAnalysisBase->GetTriggerMode())) | |
154 | { | |
155 | fStatHist->Fill(1); | |
156 | const AliESDVertex *vertex = fProtonAnalysisBase->GetVertex(fESD,fProtonAnalysisBase->GetAnalysisMode(),fProtonAnalysisBase->GetVxMax(),fProtonAnalysisBase->GetVyMax(),fProtonAnalysisBase->GetVzMax()); | |
157 | if(vertex) | |
158 | { | |
159 | fStatHist->Fill(2); | |
160 | Printf("Proton ESD analysis task: There are %d tracks in this event", fESD->GetNumberOfTracks()); | |
161 | AliStack* stack1=0x0; | |
162 | if(!fMC) | |
163 | return; | |
164 | stack1 = fMC->Stack(); | |
165 | if(!stack1) | |
166 | return; | |
167 | fStatHist->Fill(3); | |
168 | if(fIsOn_AliProtonAbsorptionCorrection) | |
169 | //fProtonAbsorptionCorrection->FillAbsorptionMaps(fESD,vertex,fMC); | |
170 | fProtonAbsorptionCorrection->FillAbsorptionMaps(fESD,fMC); | |
171 | if(fIsOn_AliProtonFeedDownAnalysis) | |
172 | { | |
173 | fProtonFeedDownAnalysis->Analyze(fESD,vertex,stack1); | |
174 | fProtonFeedDownAnalysis->Analyze(stack1); | |
175 | } | |
176 | if(fIsOn_AliProtonSpectraCorrection) | |
177 | fProtonSpectraCorrection->FillCorrectionMaps(fESD,vertex,fMC); | |
178 | ||
179 | }//reconstructed vertex | |
180 | }//triggered event | |
181 | }//ESD analysis | |
182 | ||
183 | else if(gAnalysisLevel == "AOD") | |
184 | { | |
185 | if (!fAOD) | |
186 | { | |
187 | Printf("ERROR: fAOD not available"); | |
188 | return; | |
189 | } | |
190 | Printf("Proton AOD analysis task: There are %d tracks in this event", fAOD->GetNumberOfTracks()); | |
191 | if(fIsOn_AliProtonAbsorptionCorrection) | |
192 | fProtonAbsorptionCorrection->FillAbsorptionMaps(fAOD); | |
193 | if(fIsOn_AliProtonFeedDownAnalysis) | |
194 | fProtonFeedDownAnalysis->Analyze(fAOD); | |
195 | if(fIsOn_AliProtonSpectraCorrection) | |
196 | fProtonSpectraCorrection->FillCorrectionMaps(fAOD); | |
197 | }//AOD analysis | |
198 | ||
199 | ||
200 | // Post output data. | |
201 | PostData(0, fList); | |
202 | } | |
203 | //__________________________________________________________________________________________ | |
204 | void AliProtonCorrectionAnalysisTask::Terminate(Option_t *) | |
205 | { | |
206 | ||
207 | } | |
208 | //___________________________________________________________________________________________ | |
209 | void AliProtonCorrectionAnalysisTask::SetAnalysisObjectAbsorptionCorrection(AliProtonAbsorptionCorrection *const analysis) | |
210 | { | |
211 | if (analysis&&fProtonAnalysisBase) | |
212 | { | |
213 | Printf("Absorption Correection ON\n"); | |
214 | fIsOn_AliProtonAbsorptionCorrection=kTRUE; | |
215 | fProtonAbsorptionCorrection = analysis; | |
216 | fProtonAbsorptionCorrection->SetBaseAnalysis(fProtonAnalysisBase); | |
217 | fProtonAbsorptionCorrection->InitAnalysisHistograms(fProtonAnalysisBase->GetNBinsX(),fProtonAnalysisBase->GetMinX(),fProtonAnalysisBase->GetMaxX(),fProtonAnalysisBase->GetNBinsY(),fProtonAnalysisBase->GetMinY(),fProtonAnalysisBase->GetMaxY()); | |
218 | } | |
219 | else | |
220 | fIsOn_AliProtonAbsorptionCorrection=kFALSE; | |
221 | } | |
222 | //___________________________________________________________________________________________ | |
223 | void AliProtonCorrectionAnalysisTask::SetAnalysisObjectFeedDown(AliProtonFeedDownAnalysis *const analysis) | |
224 | { | |
225 | if (analysis&&fProtonAnalysisBase) | |
226 | { | |
227 | Printf("Feed Down ON\n"); | |
228 | fIsOn_AliProtonFeedDownAnalysis=kTRUE; | |
229 | fProtonFeedDownAnalysis = analysis; | |
230 | fProtonFeedDownAnalysis->SetBaseAnalysis(fProtonAnalysisBase); | |
231 | fProtonFeedDownAnalysis->InitAnalysisHistograms(fProtonAnalysisBase->GetNBinsX(),fProtonAnalysisBase->GetMinX(),fProtonAnalysisBase->GetMaxX(),fProtonAnalysisBase->GetNBinsY(),fProtonAnalysisBase->GetMinY(),fProtonAnalysisBase->GetMaxY()); | |
232 | } | |
233 | else | |
234 | fIsOn_AliProtonFeedDownAnalysis=kFALSE; | |
235 | } | |
236 | //___________________________________________________________________________________________ | |
237 | void AliProtonCorrectionAnalysisTask::SetAnalysisObjectSpectraCorrection(AliProtonSpectraCorrection *const analysis) | |
238 | { | |
239 | if (analysis&&fProtonAnalysisBase) | |
240 | { | |
241 | Printf("Spectra Correection ON\n"); | |
242 | fIsOn_AliProtonSpectraCorrection=kTRUE; | |
243 | fProtonSpectraCorrection= analysis; | |
244 | fProtonSpectraCorrection->SetBaseAnalysis(fProtonAnalysisBase); | |
245 | fProtonSpectraCorrection->InitAnalysisHistograms(fProtonAnalysisBase->GetNBinsX(),fProtonAnalysisBase->GetMinX(),fProtonAnalysisBase->GetMaxX(),fProtonAnalysisBase->GetNBinsY(),fProtonAnalysisBase->GetMinY(),fProtonAnalysisBase->GetMaxY()); | |
246 | } | |
247 | else | |
248 | fIsOn_AliProtonSpectraCorrection=kFALSE; | |
249 | } | |
250 | ||
251 | ||
252 | ||
253 |