]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/FLOW/AliFlowTasks/AliAnalysisTaskScalarProduct.cxx
allow for correlations with only one subevent
[u/mrichter/AliRoot.git] / PWG2 / FLOW / AliFlowTasks / AliAnalysisTaskScalarProduct.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 // AliAnalysisTaskScalarProduct:
18 //
19 // analysis task for Scalar Product Method
20 //
21 // Author: Naomi van der Kolk (kolk@nikhef.nl)
22 ///////////////////////////////////////////////
23
24
25 #include "Riostream.h" //needed as include
26
27 class TFile;
28 class TList;
29 class AliAnalysisTaskSE;
30
31 #include "TProfile.h"  //needed as include
32 #include "AliAnalysisManager.h"
33 #include "AliFlowEventSimple.h"
34
35 #include "AliAnalysisTaskScalarProduct.h"
36 #include "AliFlowAnalysisWithScalarProduct.h"
37 #include "AliFlowCommonHist.h"
38 #include "AliFlowCommonHistResults.h"
39
40 ClassImp(AliAnalysisTaskScalarProduct)
41
42 //________________________________________________________________________
43 AliAnalysisTaskScalarProduct::AliAnalysisTaskScalarProduct(const char *name, Bool_t usePhiWeights) : 
44   AliAnalysisTaskSE(name), 
45   fEvent(NULL),
46   fSP(NULL),
47   fListHistos(NULL),
48   fUsePhiWeights(usePhiWeights),
49   fListWeights(NULL),
50   fRelDiffMsub(1.0),
51   fApplyCorrectionForNUA(kFALSE),
52   fHarmonic(2),
53   fTotalQvector(NULL) 
54 {
55   // Constructor
56   cout<<"AliAnalysisTaskScalarProduct::AliAnalysisTaskScalarProduct(const char *name)"<<endl;
57
58   // Define input and output slots here
59   // Input slot #0 works with an AliFlowEventSimple
60   DefineInput(0, AliFlowEventSimple::Class());
61   // Input slot #1 is needed for the weights input file
62   if(usePhiWeights) {
63     DefineInput(1, TList::Class()); }
64   // Output slot #0 writes into a TList container
65   DefineOutput(1, TList::Class());
66
67   // Total Q-vector is: "QaQb" (means Qa+Qb), "Qa"  or "Qb"
68   fTotalQvector = new TString("QaQb");
69 }
70
71 //________________________________________________________________________
72 AliAnalysisTaskScalarProduct::AliAnalysisTaskScalarProduct() : 
73   AliAnalysisTaskSE(), 
74   fEvent(NULL),
75   fSP(NULL),
76   fListHistos(NULL),
77   fUsePhiWeights(kFALSE),
78   fListWeights(NULL),
79   fRelDiffMsub(1.0),
80   fApplyCorrectionForNUA(kFALSE),
81   fHarmonic(0),
82   fTotalQvector(NULL) 
83   {
84   // Constructor
85   cout<<"AliAnalysisTaskScalarProduct::AliAnalysisTaskScalarProduct()"<<endl;
86 }
87
88 //________________________________________________________________________
89 AliAnalysisTaskScalarProduct::~AliAnalysisTaskScalarProduct()
90 {
91   //
92   // Destructor
93   //
94
95   // histograms are in the output list and deleted when the output
96   // list is deleted by the TSelector dtor
97
98   //  if (ListHistos) {
99   //    delete fListHistos;
100   //    fListHistos = NULL;
101   //  }
102 }
103
104 //________________________________________________________________________
105 void AliAnalysisTaskScalarProduct::UserCreateOutputObjects() 
106 {
107   // Called at every worker node to initialize
108   cout<<"AliAnalysisTaskScalarProduct::CreateOutputObjects()"<<endl;
109   
110   //Analyser
111   fSP = new AliFlowAnalysisWithScalarProduct();
112
113   //set the allowed relative difference in the subevent multiplicities
114   fSP->SetRelDiffMsub(fRelDiffMsub); 
115     
116   //apply automatic correction for non-uniform acceptance:
117   if (fApplyCorrectionForNUA) {
118     cout<<"Corrections for non-uniform acceptance applied in the Scalar Product method"<<endl;
119   }
120   fSP->SetApplyCorrectionForNUA(fApplyCorrectionForNUA);
121   // harmonic: 
122   fSP->SetHarmonic(fHarmonic);
123   // total Q-vector:
124   if(!(strcmp(fTotalQvector->Data(),"QaQb")==0)) // default is "QaQb" (means Qa+Qb)
125   {
126    fSP->SetTotalQvector(fTotalQvector->Data());
127   }  
128   
129   //for using phi weights:
130   if(fUsePhiWeights) {
131     //pass the flag to the analysis class:
132     fSP->SetUsePhiWeights(fUsePhiWeights);
133     //get data from input slot #1 which is used for weights:
134     if(GetNinputs()==2) {                   
135       fListWeights = (TList*)GetInputData(1); 
136     }
137     //pass the list with weights to the analysis class:
138     if(fListWeights) fSP->SetWeightsList(fListWeights);
139   }
140   
141   fSP-> Init();
142
143   if (fSP->GetHistList()) {
144     fListHistos = fSP->GetHistList();
145   }
146   else {Printf("ERROR: Could not retrieve histogram list"); }
147
148   PostData(1,fListHistos);
149
150 }
151
152 //________________________________________________________________________
153 void AliAnalysisTaskScalarProduct::UserExec(Option_t *) 
154 {
155   // Main loop
156   // Called for each event
157
158
159   fEvent = dynamic_cast<AliFlowEventSimple*>(GetInputData(0));
160   if (fEvent){
161     fSP->Make(fEvent);
162   }
163   else {
164     cout << "Warning no input data for Scalar Product task!!!" << endl;
165   }
166     
167   //fListHistos->Print();       
168   PostData(1,fListHistos);
169   
170
171
172 //________________________________________________________________________
173 void AliAnalysisTaskScalarProduct::Terminate(Option_t *) 
174 {
175   // Called once at the end of the query
176   AliFlowAnalysisWithScalarProduct* fSPTerm = new AliFlowAnalysisWithScalarProduct() ;
177   fListHistos = (TList*)GetOutputData(1);
178   if (fListHistos) {
179       fSPTerm -> GetOutputHistograms(fListHistos);
180       fSPTerm -> Finish();
181       PostData(1,fListHistos);
182     }
183     
184   else { cout << "histgram list pointer is empty in Scalar Product" << endl; }
185
186 }