]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG2/FLOW/AliFlowTasks/AliAnalysisTaskLeeYangZeros.cxx
Corrected logic in MC vector.
[u/mrichter/AliRoot.git] / PWG2 / FLOW / AliFlowTasks / AliAnalysisTaskLeeYangZeros.cxx
CommitLineData
f1d945a1 1/*************************************************************************
2* Copyright(c) 1998-2008, 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#include "Riostream.h" //needed as include
17#include "TChain.h"
18#include "TTree.h"
19#include "TFile.h"
88e00a8a 20#include "TList.h"
9d062fe3 21#include "TProfile.h"
f1d945a1 22
f1d945a1 23class AliAnalysisTask;
24#include "AliAnalysisManager.h"
9808604e 25#include "AliFlowEventSimple.h"
bc92c0cb 26#include "AliFlowLYZConstants.h"
f1d945a1 27#include "AliAnalysisTaskLeeYangZeros.h"
9d062fe3 28#include "AliFlowCommonHist.h"
29#include "AliFlowCommonHistResults.h"
30#include "AliFlowLYZHist1.h"
31#include "AliFlowLYZHist2.h"
f1d945a1 32#include "AliFlowAnalysisWithLeeYangZeros.h"
33
34// AliAnalysisTaskLeeYangZeros:
35// analysis task for Lee Yang Zeros method
36// Author: Naomi van der Kolk (kolk@nikhef.nl)
37
38ClassImp(AliAnalysisTaskLeeYangZeros)
39
40//________________________________________________________________________
9808604e 41AliAnalysisTaskLeeYangZeros::AliAnalysisTaskLeeYangZeros(const char *name, Bool_t firstrun) :
f1d945a1 42 AliAnalysisTask(name, ""),
9808604e 43 fEvent(0),
f1d945a1 44 fLyz(0),
f1d945a1 45 fFirstRunFile(0),
88e00a8a 46 fListHistos(NULL),
9808604e 47 fFirstRunLYZ(firstrun), //set boolean for firstrun to initial value
48 fUseSumLYZ(kTRUE) //set boolean for use sum to initial value
f1d945a1 49{
50 // Constructor
51 cout<<"AliAnalysisTaskLeeYangZeros::AliAnalysisTaskLeeYangZeros(const char *name)"<<endl;
52
53 // Define input and output slots here
54 // Input slot #0 works with a TChain
9808604e 55 DefineInput(0, AliFlowEventSimple::Class());
f1d945a1 56 if (!firstrun) DefineInput(1, TList::Class()); //for second loop
57 // Output slot #0 writes into a TList container
58 DefineOutput(0, TList::Class());
9808604e 59
9d062fe3 60}
61
88e00a8a 62//________________________________________________________________________
63AliAnalysisTaskLeeYangZeros::AliAnalysisTaskLeeYangZeros() :
9808604e 64 fEvent(0),
88e00a8a 65 fLyz(0),
88e00a8a 66 fFirstRunFile(0),
67 fListHistos(NULL),
68 fFirstRunLYZ(kTRUE), //set boolean for firstrun to initial value
9808604e 69 fUseSumLYZ(kTRUE) //set boolean for use sum to initial value
88e00a8a 70{
71 // Constructor
9d062fe3 72 cout<<"AliAnalysisTaskLeeYangZeros::AliAnalysisTaskLeeYangZeros()"<<endl;
88e00a8a 73
74}
75
88e00a8a 76//________________________________________________________________________
77AliAnalysisTaskLeeYangZeros::~AliAnalysisTaskLeeYangZeros()
78{
79
80 //destructor
81
82}
83
f1d945a1 84//________________________________________________________________________
85void AliAnalysisTaskLeeYangZeros::ConnectInputData(Option_t *)
86{
87 // Connect ESD or AOD here
88 // Called once
89 cout<<"AliAnalysisTaskLeeYangZeros::ConnectInputData(Option_t *)"<<endl;
9808604e 90
f1d945a1 91}
92
93//________________________________________________________________________
94void AliAnalysisTaskLeeYangZeros::CreateOutputObjects()
95{
96 // Called once
97 cout<<"AliAnalysisTaskLeeYangZeros::CreateOutputObjects()"<<endl;
98
9808604e 99
f1d945a1 100 //Analyser
101 fLyz = new AliFlowAnalysisWithLeeYangZeros() ;
f1d945a1 102 fLyz -> SetFirstRun(GetFirstRunLYZ()); //set first run true or false
103 fLyz -> SetUseSum(GetUseSumLYZ()); //set use sum true or false
104
f1d945a1 105 // Get data from input slot 1
106 if (GetNinputs() == 2) { //if there are two input slots
9d062fe3 107 TList* pFirstRunList = (TList*)GetInputData(1);
108 if (pFirstRunList) {
109 fLyz -> SetFirstRunList(pFirstRunList);
110 } else { cout<<"No first run List!"<<endl; exit(0); }
f1d945a1 111 }
112
9d062fe3 113 fLyz -> Init();
f1d945a1 114
88e00a8a 115 if (fLyz->GetHistList()) {
9d062fe3 116 fListHistos = fLyz->GetHistList();
a58fb92e 117 // fListHistos->Print();
88e00a8a 118 }
119 else {Printf("ERROR: Could not retrieve histogram list"); }
120
f1d945a1 121}
122
123//________________________________________________________________________
124void AliAnalysisTaskLeeYangZeros::Exec(Option_t *)
125{
126 // Main loop
127 // Called for each event
f1d945a1 128
9808604e 129 fEvent = dynamic_cast<AliFlowEventSimple*>(GetInputData(0));
130 if (fEvent) {
f1d945a1 131 fLyz->Make(fEvent);
f1d945a1 132 }
9808604e 133 else {
134 cout << "Warning no input data!!!" << endl; }
f1d945a1 135
9d062fe3 136 PostData(0,fListHistos); //here for CAF
9808604e 137
f1d945a1 138}
139
140//________________________________________________________________________
141void AliAnalysisTaskLeeYangZeros::Terminate(Option_t *)
142{
143 // Called once at the end of the query
f1d945a1 144
bc92c0cb 145 const Int_t iNtheta = AliFlowLYZConstants::kTheta;
146
9d062fe3 147 AliFlowAnalysisWithLeeYangZeros* fLyzTerm = new AliFlowAnalysisWithLeeYangZeros() ;
148 fLyzTerm -> SetFirstRun(GetFirstRunLYZ()); //set first run true or false
149 fLyzTerm -> SetUseSum(GetUseSumLYZ()); //set use sum true or false
150
151 fListHistos = (TList*)GetOutputData(0);
9808604e 152 //cout << "histogram list in Terminate" << endl;
9d062fe3 153
7ebf0358 154 if (fListHistos) {
9d062fe3 155
156 //define histograms for first and second run
7ebf0358 157 AliFlowCommonHist *pCommonHist = NULL;
158 AliFlowCommonHistResults *pCommonHistResults = NULL;
ba37f85c 159 TProfile* pHistProVtheta = NULL;
160 TProfile* pHistProReDenom = NULL;
161 TProfile* pHistProImDenom = NULL;
162 TProfile* pHistProReDtheta = NULL;
163 TProfile* pHistProImDtheta = NULL;
e8c3ff94 164 TProfile* pHistProVetaRP = NULL;
165 TProfile* pHistProVetaPOI = NULL;
166 TProfile* pHistProVPtRP = NULL;
167 TProfile* pHistProVPtPOI = NULL;
bc92c0cb 168 AliFlowLYZHist1 *pLYZHist1[iNtheta] = {NULL}; //array of pointers to AliFlowLYZHist1
e8c3ff94 169 AliFlowLYZHist2 *pLYZHist2RP[iNtheta] = {NULL}; //array of pointers to AliFlowLYZHist2
170 AliFlowLYZHist2 *pLYZHist2POI[iNtheta] = {NULL}; //array of pointers to AliFlowLYZHist2
9d062fe3 171
7ebf0358 172 if (GetFirstRunLYZ()) { //first run
173 //Get the common histograms from the output list
174 pCommonHist = dynamic_cast<AliFlowCommonHist*>
175 (fListHistos->FindObject("AliFlowCommonHistLYZ1"));
176 pCommonHistResults = dynamic_cast<AliFlowCommonHistResults*>
177 (fListHistos->FindObject("AliFlowCommonHistResultsLYZ1"));
178 }
179 else { //second run
180 //Get the common histograms from the output list
181 pCommonHist = dynamic_cast<AliFlowCommonHist*>
182 (fListHistos->FindObject("AliFlowCommonHistLYZ2"));
183 pCommonHistResults = dynamic_cast<AliFlowCommonHistResults*>
184 (fListHistos->FindObject("AliFlowCommonHistResultsLYZ2"));
185 }
186
187 TProfile* pHistProR0theta = dynamic_cast<TProfile*>
188 (fListHistos->FindObject("First_FlowPro_r0theta_LYZ"));
189
190 TH1F* pHistQsumforChi = dynamic_cast<TH1F*>
191 (fListHistos->FindObject("Flow_QsumforChi_LYZ"));
192
193
9d062fe3 194 if (GetFirstRunLYZ()) { //for firstrun
195 //Get the histograms from the output list
bc92c0cb 196 for(Int_t theta = 0;theta<iNtheta;theta++){
9d062fe3 197 TString name = "AliFlowLYZHist1_";
198 name += theta;
199 pLYZHist1[theta] = dynamic_cast<AliFlowLYZHist1*>
200 (fListHistos->FindObject(name));
201 }
202 pHistProVtheta = dynamic_cast<TProfile*>
203 (fListHistos->FindObject("First_FlowPro_Vtheta_LYZ"));
204
205 //Set the histogram pointers and call Finish()
ba37f85c 206 if (pCommonHist && pCommonHistResults && pLYZHist1[0] &&
9d062fe3 207 pHistProVtheta && pHistProR0theta && pHistQsumforChi ) {
208 fLyzTerm->SetCommonHists(pCommonHist);
209 fLyzTerm->SetCommonHistsRes(pCommonHistResults);
210 fLyzTerm->SetHist1(pLYZHist1);
211 fLyzTerm->SetHistProVtheta(pHistProVtheta);
212 fLyzTerm->SetHistProR0theta(pHistProR0theta);
213 fLyzTerm->SetHistQsumforChi(pHistQsumforChi);
214 fLyzTerm->Finish();
215 PostData(0,fListHistos);
216 } else {
217 cout<<"WARNING: Histograms needed to run Finish() firstrun are not accessable!"<<endl;
218 }
219 } else { //for second run
220 //Get the histograms from the output list
bc92c0cb 221 for(Int_t theta = 0;theta<iNtheta;theta++){
e8c3ff94 222 TString nameRP = "AliFlowLYZHist2RP_";
223 nameRP += theta;
224 pLYZHist2RP[theta] = dynamic_cast<AliFlowLYZHist2*>
225 (fListHistos->FindObject(nameRP));
226 TString namePOI = "AliFlowLYZHist2POI_";
227 namePOI += theta;
228 pLYZHist2POI[theta] = dynamic_cast<AliFlowLYZHist2*>
229 (fListHistos->FindObject(namePOI));
230
9d062fe3 231 }
232
233 pHistProReDenom = dynamic_cast<TProfile*>
234 (fListHistos->FindObject("Second_FlowPro_ReDenom_LYZ"));
235 pHistProImDenom = dynamic_cast<TProfile*>
236 (fListHistos->FindObject("Second_FlowPro_ImDenom_LYZ"));
237
238 pHistProReDtheta = dynamic_cast<TProfile*>
239 (fListHistos->FindObject("Second_FlowPro_ReDtheta_LYZ"));
240 pHistProImDtheta = dynamic_cast<TProfile*>
241 (fListHistos->FindObject("Second_FlowPro_ImDtheta_LYZ"));
242
e8c3ff94 243 pHistProVetaRP = dynamic_cast<TProfile*>
244 (fListHistos->FindObject("Second_FlowPro_VetaRP_LYZ"));
245 pHistProVetaPOI = dynamic_cast<TProfile*>
246 (fListHistos->FindObject("Second_FlowPro_VetaPOI_LYZ"));
247 pHistProVPtRP = dynamic_cast<TProfile*>
248 (fListHistos->FindObject("Second_FlowPro_VPtRP_LYZ"));
249 pHistProVPtPOI = dynamic_cast<TProfile*>
250 (fListHistos->FindObject("Second_FlowPro_VPtPOI_LYZ"));
251
9d062fe3 252
253 //Set the histogram pointers and call Finish()
e8c3ff94 254 if (pCommonHist && pCommonHistResults && pLYZHist2RP[0] && pLYZHist2POI[0] &&
255 pHistProR0theta && pHistProReDenom && pHistProImDenom && pHistProVetaRP &&
256 pHistProVetaPOI && pHistProVPtRP && pHistProVPtPOI) {
9d062fe3 257 fLyzTerm->SetCommonHists(pCommonHist);
258 fLyzTerm->SetCommonHistsRes(pCommonHistResults);
e8c3ff94 259 fLyzTerm->SetHist2RP(pLYZHist2RP);
260 fLyzTerm->SetHist2POI(pLYZHist2POI);
9d062fe3 261 fLyzTerm->SetHistProR0theta(pHistProR0theta);
262 fLyzTerm->SetHistProReDenom(pHistProReDenom);
263 fLyzTerm->SetHistProImDenom(pHistProImDenom);
264 fLyzTerm->SetHistProReDtheta(pHistProReDtheta);
265 fLyzTerm->SetHistProImDtheta(pHistProImDtheta);
e8c3ff94 266 fLyzTerm->SetHistProVetaRP(pHistProVetaRP);
267 fLyzTerm->SetHistProVetaPOI(pHistProVetaPOI);
268 fLyzTerm->SetHistProVPtRP(pHistProVPtRP);
269 fLyzTerm->SetHistProVPtPOI(pHistProVPtPOI);
9d062fe3 270 fLyzTerm->SetHistQsumforChi(pHistQsumforChi);
271 fLyzTerm->Finish();
272 PostData(0,fListHistos);
273 } else {
274 cout<<"WARNING: Histograms needed to run Finish() secondrun are not accessable!"<<endl;
275 }
276 }
277
a58fb92e 278 // fListHistos->Print();
88e00a8a 279 }
9808604e 280 else { cout << "histogram list pointer in Lee-Yang Zeros is empty" << endl;}
f1d945a1 281
9808604e 282 //cout<<".....finished"<<endl;
f1d945a1 283}