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