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