]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/FLOW/AliFlowTasks/AliAnalysisTaskFittingQDistribution.cxx
move some more tasks to TaskSE and add some setters
[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  {
50   //constructor
51   cout<<"AliAnalysisTaskFittingQDistribution::AliAnalysisTaskFittingQDistribution(const char *name, Bool_t useWeights)"<<endl;
52   
53   // Define input and output slots here
54   // Input slot #0 works with an AliFlowEventSimple
55   DefineInput(0, AliFlowEventSimple::Class());
56   
57   // Input slot #1 is needed for the weights input files 
58   if(useWeights) 
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 AliAnalysisTaskFittingQDistribution::AliAnalysisTaskFittingQDistribution(): 
68  AliAnalysisTaskSE(),
69  fEvent(NULL),
70  fFQD(NULL),
71  fListHistos(NULL),  
72  fUseWeights(kFALSE),
73  fUsePhiWeights(kFALSE),
74  fListWeights(NULL)
75  {
76   // Dummy constructor
77   cout<<"AliAnalysisTaskFittingQDistribution::AliAnalysisTaskFittingQDistribution()"<<endl;
78  }
79
80 //================================================================================================================
81
82 void AliAnalysisTaskFittingQDistribution::UserCreateOutputObjects() 
83 {
84   // Called at every worker node to initialize
85   cout<<"AliAnalysisTaskFittingQDistribution::UserCreateOutputObjects()"<<endl;
86   
87   // Analyser:
88   fFQD = new AliFlowAnalysisWithFittingQDistribution();
89   
90   // Particle weights:
91   if(fUseWeights) 
92   {
93    // Pass the flags to class:
94    if(fUsePhiWeights) fFQD->SetUsePhiWeights(fUsePhiWeights);
95    // Get data from input slot #1 which is used for weights:
96    if(GetNinputs()==2) 
97    {                   
98     fListWeights = (TList*)GetInputData(1); 
99    }
100    // Pass the list with weights to class:
101    if(fListWeights) fFQD->SetWeightsList(fListWeights);
102   }
103   
104   fFQD->Init();
105   
106   if(fFQD->GetHistList()) 
107   {
108    fListHistos = fFQD->GetHistList();
109    //fListHistos->Print();
110   } else 
111     {
112       Printf("ERROR: Could not retrieve histogram list (FQD, Task::UserCreateOutputObjects()) !!!!"); 
113     }
114   
115 } // end of void AliAnalysisTaskFittingQDistribution::UserCreateOutputObjects()
116
117 //================================================================================================================
118
119 void AliAnalysisTaskFittingQDistribution::UserExec(Option_t *) 
120 {
121   // Main loop (called for each event):
122   fEvent = dynamic_cast<AliFlowEventSimple*>(GetInputData(0));
123
124   // Fitting q-distribution: 
125   if(fEvent) 
126   {
127    fFQD->Make(fEvent);
128   } else 
129     {
130      cout<<"WARNING: No input data (FQD, Task::UserExec()) !!!!"<<endl;
131     }
132   
133  PostData(1,fListHistos); 
134 }
135
136 //================================================================================================================
137
138 void AliAnalysisTaskFittingQDistribution::Terminate(Option_t *) 
139 {  
140   //accessing the output list
141   fListHistos = (TList*)GetOutputData(1);
142   
143   fFQD = new AliFlowAnalysisWithFittingQDistribution();
144   
145   if(fListHistos) 
146   {          
147    fFQD->GetOutputHistograms(fListHistos);
148    fFQD->Finish();  
149    PostData(1,fListHistos);
150   } else 
151     {
152      cout<<" WARNING: histogram list pointer is empty (FQD, Task::Terminate()) !!!!"<<endl;
153      cout<<endl;
154     }
155     
156 } // end of void AliAnalysisTaskFittingQDistribution::Terminate(Option_t *)
157
158 //================================================================================================================
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177