]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/FLOW/AliFlowTasks/AliAnalysisTaskFittingQDistribution.cxx
Reverting the wrong commit of AliAnalysisTaskFlowEvent
[u/mrichter/AliRoot.git] / PWG2 / FLOW / AliFlowTasks / AliAnalysisTaskFittingQDistribution.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   *f
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 fitting       * 
18  *         q-distribution             *
19  *                                    * 
20  * authors: Naomi van der Kolk        *
21  *           (kolk@nikhef.nl)         *  
22  *          Raimond Snellings         *
23  *           (snelling@nikhef.nl)     * 
24  *          Ante Bilandzic            *
25  *           (anteb@nikhef.nl)        * 
26  * ***********************************/
27  
28 class TFile;
29 class TList;
30 class AliAnalysisTaskSE; 
31  
32 #include "Riostream.h"
33 #include "AliFlowEventSimple.h"
34 #include "AliAnalysisTaskFittingQDistribution.h"
35 #include "AliFlowAnalysisWithFittingQDistribution.h"
36
37 ClassImp(AliAnalysisTaskFittingQDistribution)
38
39 //================================================================================================================
40
41 AliAnalysisTaskFittingQDistribution::AliAnalysisTaskFittingQDistribution(const char *name, Bool_t useWeights): 
42  AliAnalysisTaskSE(name), 
43  fEvent(NULL),
44  fFQD(NULL),
45  fListHistos(NULL),
46  fUseWeights(useWeights),
47  fUsePhiWeights(kFALSE),
48  fListWeights(NULL),
49  fHarmonic(2), 
50  fqMin(0.),
51  fqMax(1000.),
52  fqNbins(10000)
53  {
54   //constructor
55   cout<<"AliAnalysisTaskFittingQDistribution::AliAnalysisTaskFittingQDistribution(const char *name, Bool_t useWeights)"<<endl;
56   
57   // Define input and output slots here
58   // Input slot #0 works with an AliFlowEventSimple
59   DefineInput(0, AliFlowEventSimple::Class());
60   
61   // Input slot #1 is needed for the weights input files 
62   if(useWeights) 
63   {
64    DefineInput(1, TList::Class());   
65   }
66   // Output slot #0 is reserved
67   // Output slot #1 writes into a TList container
68   DefineOutput(1, TList::Class());  
69  }
70
71 AliAnalysisTaskFittingQDistribution::AliAnalysisTaskFittingQDistribution(): 
72  AliAnalysisTaskSE(),
73  fEvent(NULL),
74  fFQD(NULL),
75  fListHistos(NULL),  
76  fUseWeights(kFALSE),
77  fUsePhiWeights(kFALSE),
78  fListWeights(NULL),
79  fHarmonic(0), 
80  fqMin(0.),
81  fqMax(0.),
82  fqNbins(0)
83  {
84   // Dummy constructor
85   cout<<"AliAnalysisTaskFittingQDistribution::AliAnalysisTaskFittingQDistribution()"<<endl;
86  }
87
88 //================================================================================================================
89
90 void AliAnalysisTaskFittingQDistribution::UserCreateOutputObjects() 
91 {
92   // Called at every worker node to initialize
93   cout<<"AliAnalysisTaskFittingQDistribution::UserCreateOutputObjects()"<<endl;
94   
95   // Analyser:
96   fFQD = new AliFlowAnalysisWithFittingQDistribution();
97   
98   // Particle weights:
99   if(fUseWeights) 
100   {
101    // Pass the flags to class:
102    if(fUsePhiWeights) fFQD->SetUsePhiWeights(fUsePhiWeights);
103    // Get data from input slot #1 which is used for weights:
104    if(GetNinputs()==2) 
105    {                   
106     fListWeights = (TList*)GetInputData(1); 
107    }
108    // Pass the list with weights to class:
109    if(fListWeights) fFQD->SetWeightsList(fListWeights);
110   }
111   fFQD->SetHarmonic(fHarmonic);
112   // Settings for q-distribution:
113   fFQD->SetqMin(fqMin);
114   fFQD->SetqMax(fqMax);
115   fFQD->SetqNbins(fqNbins); 
116
117   fFQD->Init();
118   
119   if(fFQD->GetHistList()) 
120   {
121    fListHistos = fFQD->GetHistList();
122    //fListHistos->Print();
123   } else 
124     {
125       Printf("ERROR: Could not retrieve histogram list (FQD, Task::UserCreateOutputObjects()) !!!!"); 
126     }
127
128  PostData(1,fListHistos);
129   
130 } // end of void AliAnalysisTaskFittingQDistribution::UserCreateOutputObjects()
131
132 //================================================================================================================
133
134 void AliAnalysisTaskFittingQDistribution::UserExec(Option_t *) 
135 {
136   // Main loop (called for each event):
137   fEvent = dynamic_cast<AliFlowEventSimple*>(GetInputData(0));
138
139   // Fitting q-distribution: 
140   if(fEvent) 
141   {
142    fFQD->Make(fEvent);
143   } else 
144     {
145      cout<<"WARNING: No input data (FQD, Task::UserExec()) !!!!"<<endl;
146     }
147   
148  PostData(1,fListHistos); 
149 }
150
151 //================================================================================================================
152
153 void AliAnalysisTaskFittingQDistribution::Terminate(Option_t *) 
154 {  
155   //accessing the output list
156   fListHistos = (TList*)GetOutputData(1);
157   
158   fFQD = new AliFlowAnalysisWithFittingQDistribution();
159   
160   if(fListHistos) 
161   {          
162    fFQD->GetOutputHistograms(fListHistos);
163    fFQD->Finish();  
164    PostData(1,fListHistos);
165   } else 
166     {
167      cout<<" WARNING: histogram list pointer is empty (FQD, Task::Terminate()) !!!!"<<endl;
168      cout<<endl;
169     }
170     
171 } // end of void AliAnalysisTaskFittingQDistribution::Terminate(Option_t *)
172
173 //================================================================================================================
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192