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