1 /*************************************************************************
2 * Copyright(c) 1998-2008, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 #include "Riostream.h" //needed as include
23 class AliAnalysisTask;
24 #include "AliAnalysisManager.h"
26 #include "AliESDEvent.h"
27 #include "AliESDInputHandler.h"
29 #include "AliAODEvent.h"
30 #include "AliAODInputHandler.h"
32 #include "AliMCEventHandler.h"
33 #include "AliMCEvent.h"
35 #include "../../CORRFW/AliCFManager.h"
37 #include "AliFlowLYZConstants.h"
38 #include "AliAnalysisTaskLeeYangZeros.h"
39 #include "AliFlowEventSimpleMaker.h"
40 #include "AliFlowCommonHist.h"
41 #include "AliFlowCommonHistResults.h"
42 #include "AliFlowLYZHist1.h"
43 #include "AliFlowLYZHist2.h"
44 #include "AliFlowAnalysisWithLeeYangZeros.h"
46 // AliAnalysisTaskLeeYangZeros:
47 // analysis task for Lee Yang Zeros method
48 // Author: Naomi van der Kolk (kolk@nikhef.nl)
50 ClassImp(AliAnalysisTaskLeeYangZeros)
52 //________________________________________________________________________
53 AliAnalysisTaskLeeYangZeros::AliAnalysisTaskLeeYangZeros(const char *name, Bool_t firstrun, Bool_t on) :
54 AliAnalysisTask(name, ""),
66 fFirstRunLYZ(firstrun), //set boolean for firstrun to initial value
67 fUseSumLYZ(kTRUE), //set boolean for use sum to initial value
71 cout<<"AliAnalysisTaskLeeYangZeros::AliAnalysisTaskLeeYangZeros(const char *name)"<<endl;
73 // Define input and output slots here
74 // Input slot #0 works with a TChain
75 DefineInput(0, TChain::Class());
76 if (!firstrun) DefineInput(1, TList::Class()); //for second loop
77 // Output slot #0 writes into a TList container
78 DefineOutput(0, TList::Class());
80 DefineOutput(1, TList::Class());
81 DefineOutput(2, TList::Class()); }
86 //________________________________________________________________________
87 AliAnalysisTaskLeeYangZeros::AliAnalysisTaskLeeYangZeros() :
99 fFirstRunLYZ(kTRUE), //set boolean for firstrun to initial value
100 fUseSumLYZ(kTRUE), //set boolean for use sum to initial value
104 cout<<"AliAnalysisTaskLeeYangZeros::AliAnalysisTaskLeeYangZeros()"<<endl;
108 //________________________________________________________________________
109 AliAnalysisTaskLeeYangZeros::~AliAnalysisTaskLeeYangZeros()
116 //________________________________________________________________________
117 void AliAnalysisTaskLeeYangZeros::ConnectInputData(Option_t *)
119 // Connect ESD or AOD here
121 cout<<"AliAnalysisTaskLeeYangZeros::ConnectInputData(Option_t *)"<<endl;
123 TTree* tree = dynamic_cast<TTree*> (GetInputData(0));
125 Printf("ERROR: Could not read chain from input slot 0");
128 // Disable all branches and enable only the needed ones
129 if (fAnalysisType == "MC") {
130 // we want to process only MC
131 tree->SetBranchStatus("*", kFALSE);
133 AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
136 Printf("ERROR: Could not get ESDInputHandler");
138 fESD = esdH->GetEvent();
141 else if (fAnalysisType == "ESD" || fAnalysisType == "ESDMC0" || fAnalysisType == "ESDMC1" ) {
142 tree->SetBranchStatus("*", kFALSE);
143 tree->SetBranchStatus("Tracks.*", kTRUE);
145 AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
148 Printf("ERROR: Could not get ESDInputHandler");
150 fESD = esdH->GetEvent();
152 else if (fAnalysisType == "AOD") {
153 AliAODInputHandler *aodH = dynamic_cast<AliAODInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
156 Printf("ERROR: Could not get AODInputHandler");
159 fAOD = aodH->GetEvent();
163 Printf("Wrong analysis type: Only ESD, ESDMC0, ESDMC1, AOD and MC types are allowed!");
169 //________________________________________________________________________
170 void AliAnalysisTaskLeeYangZeros::CreateOutputObjects()
173 cout<<"AliAnalysisTaskLeeYangZeros::CreateOutputObjects()"<<endl;
175 if (!(fAnalysisType == "AOD" || fAnalysisType == "ESD" || fAnalysisType == "ESDMC0" || fAnalysisType == "ESDMC1" || fAnalysisType == "MC")) {
176 cout<<"WRONG ANALYSIS TYPE! only ESD, ESDMC0, ESDMC1, AOD and MC are allowed."<<endl;
181 fEventMaker = new AliFlowEventSimpleMaker();
183 fLyz = new AliFlowAnalysisWithLeeYangZeros() ;
185 fLyz -> SetFirstRun(GetFirstRunLYZ()); //set first run true or false
186 fLyz -> SetUseSum(GetUseSumLYZ()); //set use sum true or false
188 // Get data from input slot 1
189 if (GetNinputs() == 2) { //if there are two input slots
190 TList* pFirstRunList = (TList*)GetInputData(1);
192 fLyz -> SetFirstRunList(pFirstRunList);
193 } else { cout<<"No first run List!"<<endl; exit(0); }
198 if (fLyz->GetHistList()) {
199 fListHistos = fLyz->GetHistList();
200 // fListHistos->Print();
202 else {Printf("ERROR: Could not retrieve histogram list"); }
206 //________________________________________________________________________
207 void AliAnalysisTaskLeeYangZeros::Exec(Option_t *)
210 // Called for each event
211 if (fAnalysisType == "MC") {
212 // Process MC truth, therefore we receive the AliAnalysisManager and ask it for the AliMCEventHandler
213 // This handler can return the current MC event
215 AliMCEventHandler* eventHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
217 Printf("ERROR: Could not retrieve MC event handler");
221 AliMCEvent* mcEvent = eventHandler->MCEvent();
223 Printf("ERROR: Could not retrieve MC event");
227 fCFManager1->SetEventInfo(mcEvent);
228 fCFManager2->SetEventInfo(mcEvent);
230 Printf("MC particles: %d", mcEvent->GetNumberOfTracks());
232 //lee yang zeros analysis
233 //AliFlowEventSimple* fEvent = fEventMaker->FillTracks(mcEvent);
234 AliFlowEventSimple* fEvent = fEventMaker->FillTracks(mcEvent,fCFManager1,fCFManager2);
238 else if (fAnalysisType == "ESD") {
240 Printf("ERROR: fESD not available");
243 Printf("There are %d tracks in this event", fESD->GetNumberOfTracks());
245 //lee yang zeros analysis
246 //AliFlowEventSimple* fEvent = fEventMaker->FillTracks(fESD);
247 AliFlowEventSimple* fEvent = fEventMaker->FillTracks(fESD,fCFManager1,fCFManager2);
251 else if (fAnalysisType == "ESDMC0" || fAnalysisType == "ESDMC1") {
253 Printf("ERROR: fESD not available");
256 Printf("There are %d tracks in this event", fESD->GetNumberOfTracks());
258 AliMCEventHandler* eventHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
260 Printf("ERROR: Could not retrieve MC event handler");
264 AliMCEvent* mcEvent = eventHandler->MCEvent();
266 Printf("ERROR: Could not retrieve MC event");
270 fCFManager1->SetEventInfo(mcEvent);
271 fCFManager2->SetEventInfo(mcEvent);
273 //lee yang zeros analysis
274 //AliFlowEventSimple* fEvent = fEventMaker->FillTracks(fESD,mcEvent,0); //0 = kine from ESD, 1 = kine from MC
275 AliFlowEventSimple* fEvent=NULL;
276 if (fAnalysisType == "ESDMC0") {
277 fEvent = fEventMaker->FillTracks(fESD, mcEvent, fCFManager1, fCFManager2, 0); //0 = kine from ESD, 1 = kine from MC
278 } else if (fAnalysisType == "ESDMC1") {
279 fEvent = fEventMaker->FillTracks(fESD, mcEvent, fCFManager1, fCFManager2, 1); //0 = kine from ESD, 1 = kine from MC
286 else if (fAnalysisType == "AOD") {
288 Printf("ERROR: fAOD not available");
291 Printf("There are %d tracks in this event", fAOD->GetNumberOfTracks());
293 //lee yang zeros analysis
294 AliFlowEventSimple* fEvent = fEventMaker->FillTracks(fAOD); //no CF yet!
299 PostData(0,fListHistos); //here for CAF
302 PostData(2,fQADiff); }
305 //________________________________________________________________________
306 void AliAnalysisTaskLeeYangZeros::Terminate(Option_t *)
308 // Called once at the end of the query
310 const Int_t iNtheta = AliFlowLYZConstants::kTheta;
312 AliFlowAnalysisWithLeeYangZeros* fLyzTerm = new AliFlowAnalysisWithLeeYangZeros() ;
313 fLyzTerm -> SetFirstRun(GetFirstRunLYZ()); //set first run true or false
314 fLyzTerm -> SetUseSum(GetUseSumLYZ()); //set use sum true or false
316 fListHistos = (TList*)GetOutputData(0);
317 //cout << "histogram list in Terminate" << endl;
321 //define histograms for first and second run
322 AliFlowCommonHist *pCommonHist = NULL;
323 AliFlowCommonHistResults *pCommonHistResults = NULL;
324 TProfile* pHistProVtheta = NULL;
325 TProfile* pHistProReDenom = NULL;
326 TProfile* pHistProImDenom = NULL;
327 TProfile* pHistProReDtheta = NULL;
328 TProfile* pHistProImDtheta = NULL;
329 TProfile* pHistProVeta = NULL;
330 TProfile* pHistProVPt = NULL;
331 AliFlowLYZHist1 *pLYZHist1[iNtheta] = {NULL}; //array of pointers to AliFlowLYZHist1
332 AliFlowLYZHist2 *pLYZHist2[iNtheta] = {NULL}; //array of pointers to AliFlowLYZHist2
334 if (GetFirstRunLYZ()) { //first run
335 //Get the common histograms from the output list
336 pCommonHist = dynamic_cast<AliFlowCommonHist*>
337 (fListHistos->FindObject("AliFlowCommonHistLYZ1"));
338 pCommonHistResults = dynamic_cast<AliFlowCommonHistResults*>
339 (fListHistos->FindObject("AliFlowCommonHistResultsLYZ1"));
342 //Get the common histograms from the output list
343 pCommonHist = dynamic_cast<AliFlowCommonHist*>
344 (fListHistos->FindObject("AliFlowCommonHistLYZ2"));
345 pCommonHistResults = dynamic_cast<AliFlowCommonHistResults*>
346 (fListHistos->FindObject("AliFlowCommonHistResultsLYZ2"));
349 TProfile* pHistProR0theta = dynamic_cast<TProfile*>
350 (fListHistos->FindObject("First_FlowPro_r0theta_LYZ"));
352 TH1F* pHistQsumforChi = dynamic_cast<TH1F*>
353 (fListHistos->FindObject("Flow_QsumforChi_LYZ"));
356 if (GetFirstRunLYZ()) { //for firstrun
357 //Get the histograms from the output list
358 for(Int_t theta = 0;theta<iNtheta;theta++){
359 TString name = "AliFlowLYZHist1_";
361 pLYZHist1[theta] = dynamic_cast<AliFlowLYZHist1*>
362 (fListHistos->FindObject(name));
364 pHistProVtheta = dynamic_cast<TProfile*>
365 (fListHistos->FindObject("First_FlowPro_Vtheta_LYZ"));
367 //Set the histogram pointers and call Finish()
368 if (pCommonHist && pCommonHistResults && pLYZHist1[0] &&
369 pHistProVtheta && pHistProR0theta && pHistQsumforChi ) {
370 fLyzTerm->SetCommonHists(pCommonHist);
371 fLyzTerm->SetCommonHistsRes(pCommonHistResults);
372 fLyzTerm->SetHist1(pLYZHist1);
373 fLyzTerm->SetHistProVtheta(pHistProVtheta);
374 fLyzTerm->SetHistProR0theta(pHistProR0theta);
375 fLyzTerm->SetHistQsumforChi(pHistQsumforChi);
377 PostData(0,fListHistos);
379 cout<<"WARNING: Histograms needed to run Finish() firstrun are not accessable!"<<endl;
381 } else { //for second run
382 //Get the histograms from the output list
383 for(Int_t theta = 0;theta<iNtheta;theta++){
384 TString name = "AliFlowLYZHist2_";
386 pLYZHist2[theta] = dynamic_cast<AliFlowLYZHist2*>
387 (fListHistos->FindObject(name));
390 pHistProReDenom = dynamic_cast<TProfile*>
391 (fListHistos->FindObject("Second_FlowPro_ReDenom_LYZ"));
392 pHistProImDenom = dynamic_cast<TProfile*>
393 (fListHistos->FindObject("Second_FlowPro_ImDenom_LYZ"));
395 pHistProReDtheta = dynamic_cast<TProfile*>
396 (fListHistos->FindObject("Second_FlowPro_ReDtheta_LYZ"));
397 pHistProImDtheta = dynamic_cast<TProfile*>
398 (fListHistos->FindObject("Second_FlowPro_ImDtheta_LYZ"));
400 pHistProVeta = dynamic_cast<TProfile*>
401 (fListHistos->FindObject("Second_FlowPro_Veta_LYZ"));
402 pHistProVPt = dynamic_cast<TProfile*>
403 (fListHistos->FindObject("Second_FlowPro_VPt_LYZ"));
405 //Set the histogram pointers and call Finish()
406 if (pCommonHist && pCommonHistResults && pLYZHist2[0] && pHistProR0theta &&
407 pHistProReDenom && pHistProImDenom && pHistProVeta && pHistProVPt) {
408 fLyzTerm->SetCommonHists(pCommonHist);
409 fLyzTerm->SetCommonHistsRes(pCommonHistResults);
410 fLyzTerm->SetHist2(pLYZHist2);
411 fLyzTerm->SetHistProR0theta(pHistProR0theta);
412 fLyzTerm->SetHistProReDenom(pHistProReDenom);
413 fLyzTerm->SetHistProImDenom(pHistProImDenom);
414 fLyzTerm->SetHistProReDtheta(pHistProReDtheta);
415 fLyzTerm->SetHistProImDtheta(pHistProImDtheta);
416 fLyzTerm->SetHistProVeta(pHistProVeta);
417 fLyzTerm->SetHistProVPt(pHistProVPt);
418 fLyzTerm->SetHistQsumforChi(pHistQsumforChi);
420 PostData(0,fListHistos);
422 cout<<"WARNING: Histograms needed to run Finish() secondrun are not accessable!"<<endl;
426 // fListHistos->Print();
428 else { cout << "histogram list pointer is empty" << endl;}
430 cout<<".....finished LYZ"<<endl;