]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/FLOW/AliFlowTasks/AliAnalysisTaskMCEventPlane.cxx
more consistent names
[u/mrichter/AliRoot.git] / PWG2 / FLOW / AliFlowTasks / AliAnalysisTaskMCEventPlane.cxx
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 "TProfile.h"
18 #include "TList.h"
19
20
21 class AliAnalysisTask;
22 #include "AliAnalysisManager.h"
23 #include "AliFlowEventSimple.h"
24
25
26 #include "AliAnalysisTaskMCEventPlane.h"
27 #include "AliFlowAnalysisWithMCEventPlane.h"
28 #include "AliFlowCommonHist.h"
29 #include "AliFlowCommonHistResults.h"
30
31 // AliAnalysisTaskMCEventPlane:
32 //
33 // analysis task for Monte Carlo Event Plane
34 //
35 // Author: Naomi van der Kolk (kolk@nikhef.nl)
36
37 ClassImp(AliAnalysisTaskMCEventPlane)
38
39 //________________________________________________________________________
40 AliAnalysisTaskMCEventPlane::AliAnalysisTaskMCEventPlane(const char *name) : 
41   AliAnalysisTask(name, ""), 
42   fEvent(NULL),
43   fMc(NULL),
44   fListHistos(NULL)
45 {
46   // Constructor
47   cout<<"AliAnalysisTaskMCEventPlane::AliAnalysisTaskMCEventPlane(const char *name)"<<endl;
48
49   // Define input and output slots here
50   // Input slot #0 works with a TChain
51   DefineInput(0, AliFlowEventSimple::Class());
52   // Output slot #0 writes into a TList container
53   DefineOutput(0, TList::Class()); 
54 }
55
56 //________________________________________________________________________
57 AliAnalysisTaskMCEventPlane::AliAnalysisTaskMCEventPlane() : 
58   fEvent(NULL),
59   fMc(NULL),
60   fListHistos(NULL)
61 {
62   // Constructor
63   cout<<"AliAnalysisTaskMCEventPlane::AliAnalysisTaskMCEventPlane()"<<endl;
64
65 }
66
67 //________________________________________________________________________
68 AliAnalysisTaskMCEventPlane::~AliAnalysisTaskMCEventPlane()
69 {
70
71   //destructor
72
73 }
74
75 //________________________________________________________________________
76 void AliAnalysisTaskMCEventPlane::ConnectInputData(Option_t *) 
77 {
78   // Connect ESD or AOD here
79   // Called once
80   cout<<"AliAnalysisTaskMCEventPlane::ConnectInputData(Option_t *)"<<endl;
81
82 }
83
84 //________________________________________________________________________
85 void AliAnalysisTaskMCEventPlane::CreateOutputObjects() 
86 {
87   // Called once
88   cout<<"AliAnalysisTaskMCEventPlane::CreateOutputObjects()"<<endl;
89
90   //Analyser
91   fMc  = new AliFlowAnalysisWithMCEventPlane() ;
92       
93   fMc-> Init();
94
95   if (fMc->GetHistList()) {
96     //fMc->GetHistList()->Print();
97     fListHistos = fMc->GetHistList();
98     //fListHistos->Print();
99   }
100   else {Printf("ERROR: Could not retrieve histogram list"); }
101
102 }
103
104 //________________________________________________________________________
105 void AliAnalysisTaskMCEventPlane::Exec(Option_t *) 
106 {
107   // Main loop
108   // Called for each event
109
110   fEvent = dynamic_cast<AliFlowEventSimple*>(GetInputData(0));
111   if (fEvent){
112     fMc->Make(fEvent);
113   }
114   else {
115     cout << "Warning no input data!!!" << endl;
116   }
117
118   PostData(0,fListHistos); 
119 }      
120
121
122 //________________________________________________________________________
123 void AliAnalysisTaskMCEventPlane::Terminate(Option_t *) 
124 {
125   // Called once at the end of the query
126   AliFlowAnalysisWithMCEventPlane* fMcTerm = new AliFlowAnalysisWithMCEventPlane() ;
127
128   //Get output data
129   fListHistos = (TList*)GetOutputData(0);
130   // cout << "histogram list in Terminate" << endl;
131   if (fListHistos) {
132     //Get the common histograms from the output list
133     AliFlowCommonHist *pCommonHists = dynamic_cast<AliFlowCommonHist*> 
134       (fListHistos->FindObject("AliFlowCommonHistMCEP"));
135     AliFlowCommonHistResults *pCommonHistResults = 
136       dynamic_cast<AliFlowCommonHistResults*> 
137       (fListHistos->FindObject("AliFlowCommonHistResultsMCEP"));
138
139     TProfile *pHistProIntFlow = dynamic_cast<TProfile*> 
140       (fListHistos->FindObject("FlowPro_V_MCEP")); 
141                                
142     TProfile *pHistProDiffFlowPtRP = dynamic_cast<TProfile*> 
143       (fListHistos->FindObject("FlowPro_VPtRP_MCEP")); 
144      
145     TProfile *pHistProDiffFlowEtaRP = dynamic_cast<TProfile*> 
146       (fListHistos->FindObject("FlowPro_VetaRP_MCEP"));
147       
148     TProfile *pHistProDiffFlowPtPOI = dynamic_cast<TProfile*> 
149       (fListHistos->FindObject("FlowPro_VPtPOI_MCEP")); 
150      
151     TProfile *pHistProDiffFlowEtaPOI = dynamic_cast<TProfile*> 
152       (fListHistos->FindObject("FlowPro_VetaPOI_MCEP"));                             
153
154     if (pCommonHists && pCommonHistResults && pHistProIntFlow && 
155         pHistProDiffFlowPtRP && pHistProDiffFlowEtaRP && 
156         pHistProDiffFlowPtPOI && pHistProDiffFlowEtaPOI) {
157       fMcTerm->SetCommonHists(pCommonHists);
158       fMcTerm->SetCommonHistsRes(pCommonHistResults);
159       fMcTerm->SetHistProIntFlow(pHistProIntFlow);
160       fMcTerm->SetHistProDiffFlowPtRP(pHistProDiffFlowPtRP);      
161       fMcTerm->SetHistProDiffFlowEtaRP(pHistProDiffFlowEtaRP);  
162       fMcTerm->SetHistProDiffFlowPtPOI(pHistProDiffFlowPtPOI);      
163       fMcTerm->SetHistProDiffFlowEtaPOI(pHistProDiffFlowEtaPOI);          
164       fMcTerm->Finish();
165       PostData(0,fListHistos);
166     } else {
167       cout<<"WARNING: Histograms needed to run Finish() are not accessable!"<<endl;  }
168     
169     //fListHistos->Print();
170   } else { cout << "histogram list pointer is empty" << endl;}
171 }
172