]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG/FLOW/Tasks/AliAnalysisTaskNestedLoops.cxx
Merge branch 'feature-movesplit'
[u/mrichter/AliRoot.git] / PWG / FLOW / Tasks / AliAnalysisTaskNestedLoops.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 /**********************************
17  * analysis task for nested loops * 
18  *                                * 
19  * authors: Naomi van der Kolk    *
20  *           (kolk@nikhef.nl)     *  
21  *          Raimond Snellings     *
22  *           (snelling@nikhef.nl) * 
23  *          Ante Bilandzic        *
24  *           (anteb@nikhef.nl)    * 
25  * *******************************/
26  
27 class TFile;
28 class TString;
29 class TList;
30 class AliAnalysisTaskSE; 
31  
32 #include "Riostream.h"
33 #include "AliFlowEventSimple.h"
34 #include "AliAnalysisTaskNestedLoops.h"
35 #include "AliFlowAnalysisWithNestedLoops.h"
36
37 using std::cout;
38 using std::endl;
39 ClassImp(AliAnalysisTaskNestedLoops)
40
41 //================================================================================================================
42
43 AliAnalysisTaskNestedLoops::AliAnalysisTaskNestedLoops(const char *name, Bool_t useParticleWeights): 
44 AliAnalysisTaskSE(name), 
45 fEvent(NULL),
46 fNL(NULL), 
47 fListHistos(NULL),
48 fHarmonic(0),
49 fOppositeChargesPOI(kFALSE),
50 fEvaluateDifferential3pCorrelator(kFALSE),
51 fUseParticleWeights(useParticleWeights),
52 fUsePhiWeights(kFALSE),
53 fUsePtWeights(kFALSE),
54 fUseEtaWeights(kFALSE),
55 fWeightsList(NULL),
56 fEvaluateNestedLoopsForRAD(kTRUE),
57 fEvaluateNestedLoopsForQC(kFALSE),
58 fEvaluateNestedLoopsForMH(kFALSE)
59 {
60  // constructor
61  cout<<"AliAnalysisTaskNestedLoops::AliAnalysisTaskNestedLoops(const char *name, Bool_t useParticleWeights)"<<endl;
62  
63  // Define input and output slots here
64  // Input slot #0 works with an AliFlowEventSimple
65  DefineInput(0, AliFlowEventSimple::Class());  
66  // Input slot #1 is needed for the weights input file:
67  if(useParticleWeights)
68  {
69   DefineInput(1, TList::Class());   
70  }  
71  // Output slot #0 is reserved              
72  // Output slot #1 writes into a TList container
73  DefineOutput(1, TList::Class());  
74 }
75
76 AliAnalysisTaskNestedLoops::AliAnalysisTaskNestedLoops(): 
77 AliAnalysisTaskSE(),
78 fEvent(NULL),
79 fNL(NULL),
80 fListHistos(NULL),
81 fHarmonic(0),
82 fOppositeChargesPOI(kFALSE),
83 fEvaluateDifferential3pCorrelator(kFALSE),
84 fUseParticleWeights(kFALSE),
85 fUsePhiWeights(kFALSE),
86 fUsePtWeights(kFALSE),
87 fUseEtaWeights(kFALSE),
88 fWeightsList(NULL),
89 fEvaluateNestedLoopsForRAD(kFALSE),
90 fEvaluateNestedLoopsForQC(kFALSE),
91 fEvaluateNestedLoopsForMH(kFALSE)
92 {
93  // Dummy constructor
94  cout<<"AliAnalysisTaskNestedLoops::AliAnalysisTaskNestedLoops()"<<endl;
95 }
96
97 //================================================================================================================
98
99 void AliAnalysisTaskNestedLoops::UserCreateOutputObjects() 
100 {
101  // Called at every worker node to initialize
102  cout<<"AliAnalysisTaskNestedLoops::UserCreateOutputObjects()"<<endl;
103
104  // Analyser:
105  fNL = new AliFlowAnalysisWithNestedLoops();
106
107  fNL->SetHarmonic(fHarmonic);
108  fNL->SetOppositeChargesPOI(fOppositeChargesPOI);
109  fNL->SetEvaluateDifferential3pCorrelator(fEvaluateDifferential3pCorrelator);
110
111  if(fUseParticleWeights)
112  {
113   // Pass the flags to class:
114   if(fUsePhiWeights) fNL->SetUsePhiWeights(fUsePhiWeights);
115   if(fUsePtWeights) fNL->SetUsePtWeights(fUsePtWeights);
116   if(fUseEtaWeights) fNL->SetUseEtaWeights(fUseEtaWeights);
117   // Get data from input slot #1 which is used for weights:
118   if(GetNinputs()==2) 
119   {                   
120    fWeightsList = (TList*)GetInputData(1); 
121   }
122   // Pass the list with weights to class:
123   if(fWeightsList) fNL->SetWeightsList(fWeightsList);
124  }
125  
126  fNL->SetEvaluateNestedLoopsForRAD(fEvaluateNestedLoopsForRAD);
127  fNL->SetEvaluateNestedLoopsForQC(fEvaluateNestedLoopsForQC);
128  fNL->SetEvaluateNestedLoopsForMH(fEvaluateNestedLoopsForMH);
129  
130  fNL->Init();
131  
132  if(fNL->GetHistList()) 
133  {
134   fListHistos = fNL->GetHistList();
135   // fListHistos->Print();
136  } else 
137    {
138     Printf("ERROR: Could not retrieve histogram list (NL, Task::UserCreateOutputObjects()) !!!!"); 
139    }
140   
141  PostData(1,fListHistos);
142  
143 } // end of void AliAnalysisTaskNestedLoops::UserCreateOutputObjects() 
144
145 //================================================================================================================
146
147 void AliAnalysisTaskNestedLoops::UserExec(Option_t *) 
148 {
149  // main loop (called for each event)
150  fEvent = dynamic_cast<AliFlowEventSimple*>(GetInputData(0));
151
152  // Nested Loops:
153  if(fEvent) 
154  {
155   fNL->Make(fEvent);
156  } else 
157    {
158     cout<<"WARNING: No input data (NL, Task::UserExec()) !!!!"<<endl;
159     cout<<endl;
160    }
161   
162  PostData(1,fListHistos);
163 }
164
165 //================================================================================================================
166
167 void AliAnalysisTaskNestedLoops::Terminate(Option_t *) 
168 {
169  //accessing the merged output list: 
170  fListHistos = (TList*)GetOutputData(1);
171  
172  fNL = new AliFlowAnalysisWithNestedLoops(); 
173  
174  if(fListHistos) 
175  {
176   fNL->GetOutputHistograms(fListHistos);
177   fNL->Finish();
178   PostData(1,fListHistos);
179  } else
180    {
181     cout<<" WARNING: histogram list pointer is empty (NL, Task::Terminate()) !!!!"<<endl;
182     cout<<endl;
183    }
184     
185 } // end of void AliAnalysisTaskNestedLoops::Terminate(Option_t *)
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206