]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG2/FLOW/AliFlowTasks/AliAnalysisTaskScalarProduct.cxx
allow for correlations with only one subevent
[u/mrichter/AliRoot.git] / PWG2 / FLOW / AliFlowTasks / AliAnalysisTaskScalarProduct.cxx
CommitLineData
8d312f00 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
a554b203 16///////////////////////////////////////////////
17// AliAnalysisTaskScalarProduct:
18//
19// analysis task for Scalar Product Method
20//
21// Author: Naomi van der Kolk (kolk@nikhef.nl)
22///////////////////////////////////////////////
23
24
8d312f00 25#include "Riostream.h" //needed as include
8d312f00 26
395fadba 27class TFile;
28class TList;
ea456d37 29class AliAnalysisTaskSE;
395fadba 30
31#include "TProfile.h" //needed as include
8d312f00 32#include "AliAnalysisManager.h"
dc3481ef 33#include "AliFlowEventSimple.h"
88e00a8a 34
8d312f00 35#include "AliAnalysisTaskScalarProduct.h"
8d312f00 36#include "AliFlowAnalysisWithScalarProduct.h"
04f6283b 37#include "AliFlowCommonHist.h"
dc3481ef 38#include "AliFlowCommonHistResults.h"
8d312f00 39
8d312f00 40ClassImp(AliAnalysisTaskScalarProduct)
41
42//________________________________________________________________________
29195b69 43AliAnalysisTaskScalarProduct::AliAnalysisTaskScalarProduct(const char *name, Bool_t usePhiWeights) :
ea456d37 44 AliAnalysisTaskSE(name),
dc3481ef 45 fEvent(NULL),
d7eb18ec 46 fSP(NULL),
29195b69 47 fListHistos(NULL),
48 fUsePhiWeights(usePhiWeights),
a554b203 49 fListWeights(NULL),
3c5d5752 50 fRelDiffMsub(1.0),
50fe33aa 51 fApplyCorrectionForNUA(kFALSE),
2a3b9289 52 fHarmonic(2),
53 fTotalQvector(NULL)
29195b69 54{
8d312f00 55 // Constructor
56 cout<<"AliAnalysisTaskScalarProduct::AliAnalysisTaskScalarProduct(const char *name)"<<endl;
57
58 // Define input and output slots here
dc3481ef 59 // Input slot #0 works with an AliFlowEventSimple
60 DefineInput(0, AliFlowEventSimple::Class());
29195b69 61 // Input slot #1 is needed for the weights input file
62 if(usePhiWeights) {
63 DefineInput(1, TList::Class()); }
8d312f00 64 // Output slot #0 writes into a TList container
ea456d37 65 DefineOutput(1, TList::Class());
2a3b9289 66
67 // Total Q-vector is: "QaQb" (means Qa+Qb), "Qa" or "Qb"
68 fTotalQvector = new TString("QaQb");
e2d51347 69}
70
882ffd6a 71//________________________________________________________________________
72AliAnalysisTaskScalarProduct::AliAnalysisTaskScalarProduct() :
ea456d37 73 AliAnalysisTaskSE(),
dc3481ef 74 fEvent(NULL),
882ffd6a 75 fSP(NULL),
29195b69 76 fListHistos(NULL),
77 fUsePhiWeights(kFALSE),
a554b203 78 fListWeights(NULL),
3c5d5752 79 fRelDiffMsub(1.0),
50fe33aa 80 fApplyCorrectionForNUA(kFALSE),
2a3b9289 81 fHarmonic(0),
82 fTotalQvector(NULL)
dc3481ef 83 {
882ffd6a 84 // Constructor
85 cout<<"AliAnalysisTaskScalarProduct::AliAnalysisTaskScalarProduct()"<<endl;
86}
87
e2d51347 88//________________________________________________________________________
89AliAnalysisTaskScalarProduct::~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 // }
8d312f00 102}
103
104//________________________________________________________________________
ea456d37 105void AliAnalysisTaskScalarProduct::UserCreateOutputObjects()
8d312f00 106{
e2d51347 107 // Called at every worker node to initialize
8d312f00 108 cout<<"AliAnalysisTaskScalarProduct::CreateOutputObjects()"<<endl;
dc3481ef 109
e2d51347 110 //Analyser
a554b203 111 fSP = new AliFlowAnalysisWithScalarProduct();
112
113 //set the allowed relative difference in the subevent multiplicities
114 fSP->SetRelDiffMsub(fRelDiffMsub);
1073c74a 115
3c5d5752 116 //apply automatic correction for non-uniform acceptance:
1073c74a 117 if (fApplyCorrectionForNUA) {
118 cout<<"Corrections for non-uniform acceptance applied in the Scalar Product method"<<endl;
119 }
3c5d5752 120 fSP->SetApplyCorrectionForNUA(fApplyCorrectionForNUA);
50fe33aa 121 // harmonic:
122 fSP->SetHarmonic(fHarmonic);
2a3b9289 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
29195b69 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 }
d7eb18ec 140
29195b69 141 fSP-> Init();
8d312f00 142
d7eb18ec 143 if (fSP->GetHistList()) {
dc3481ef 144 fListHistos = fSP->GetHistList();
8d312f00 145 }
d7eb18ec 146 else {Printf("ERROR: Could not retrieve histogram list"); }
61e0c8c0 147
148 PostData(1,fListHistos);
149
8d312f00 150}
151
152//________________________________________________________________________
ea456d37 153void AliAnalysisTaskScalarProduct::UserExec(Option_t *)
8d312f00 154{
155 // Main loop
156 // Called for each event
157
882ffd6a 158
dc3481ef 159 fEvent = dynamic_cast<AliFlowEventSimple*>(GetInputData(0));
160 if (fEvent){
8d312f00 161 fSP->Make(fEvent);
8d312f00 162 }
dc3481ef 163 else {
29195b69 164 cout << "Warning no input data for Scalar Product task!!!" << endl;
8d312f00 165 }
88e00a8a 166
88e00a8a 167 //fListHistos->Print();
ea456d37 168 PostData(1,fListHistos);
dc3481ef 169
882ffd6a 170}
8d312f00 171
172//________________________________________________________________________
173void AliAnalysisTaskScalarProduct::Terminate(Option_t *)
174{
395fadba 175 // Called once at the end of the query
176 AliFlowAnalysisWithScalarProduct* fSPTerm = new AliFlowAnalysisWithScalarProduct() ;
ea456d37 177 fListHistos = (TList*)GetOutputData(1);
395fadba 178 if (fListHistos) {
fd46c3dd 179 fSPTerm -> GetOutputHistograms(fListHistos);
395fadba 180 fSPTerm -> Finish();
ea456d37 181 PostData(1,fListHistos);
395fadba 182 }
fd46c3dd 183
395fadba 184 else { cout << "histgram list pointer is empty in Scalar Product" << endl; }
9d062fe3 185
df802279 186}