]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG/FLOW/Tasks/AliAnalysisTaskScalarProduct.cxx
initial checkin of the new flow development - from an OLD diff!
[u/mrichter/AliRoot.git] / PWG / FLOW / Tasks / 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
cea49479 40#include "AliLog.h"
3a7af7bd 41
42using std::endl;
43using std::cout;
8d312f00 44ClassImp(AliAnalysisTaskScalarProduct)
45
46//________________________________________________________________________
29195b69 47AliAnalysisTaskScalarProduct::AliAnalysisTaskScalarProduct(const char *name, Bool_t usePhiWeights) :
ea456d37 48 AliAnalysisTaskSE(name),
dc3481ef 49 fEvent(NULL),
d7eb18ec 50 fSP(NULL),
29195b69 51 fListHistos(NULL),
b591bbbb 52 fMinimalBook(kFALSE),
29195b69 53 fUsePhiWeights(usePhiWeights),
a554b203 54 fListWeights(NULL),
3c5d5752 55 fRelDiffMsub(1.0),
50fe33aa 56 fApplyCorrectionForNUA(kFALSE),
2a3b9289 57 fHarmonic(2),
02914cfa 58 fNormalizationType(1),
2a3b9289 59 fTotalQvector(NULL)
29195b69 60{
8d312f00 61 // Constructor
cea49479 62 AliDebug(2,"AliAnalysisTaskScalarProduct::AliAnalysisTaskScalarProduct(const char *name)");
8d312f00 63
64 // Define input and output slots here
dc3481ef 65 // Input slot #0 works with an AliFlowEventSimple
66 DefineInput(0, AliFlowEventSimple::Class());
29195b69 67 // Input slot #1 is needed for the weights input file
68 if(usePhiWeights) {
69 DefineInput(1, TList::Class()); }
8d312f00 70 // Output slot #0 writes into a TList container
ea456d37 71 DefineOutput(1, TList::Class());
2a3b9289 72
73 // Total Q-vector is: "QaQb" (means Qa+Qb), "Qa" or "Qb"
74 fTotalQvector = new TString("QaQb");
e2d51347 75}
76
882ffd6a 77//________________________________________________________________________
78AliAnalysisTaskScalarProduct::AliAnalysisTaskScalarProduct() :
ea456d37 79 AliAnalysisTaskSE(),
dc3481ef 80 fEvent(NULL),
882ffd6a 81 fSP(NULL),
29195b69 82 fListHistos(NULL),
b591bbbb 83 fMinimalBook(kFALSE),
29195b69 84 fUsePhiWeights(kFALSE),
a554b203 85 fListWeights(NULL),
3c5d5752 86 fRelDiffMsub(1.0),
50fe33aa 87 fApplyCorrectionForNUA(kFALSE),
2a3b9289 88 fHarmonic(0),
02914cfa 89 fNormalizationType(1),
2a3b9289 90 fTotalQvector(NULL)
dc3481ef 91 {
882ffd6a 92 // Constructor
cea49479 93 AliDebug(2,"AliAnalysisTaskScalarProduct::AliAnalysisTaskScalarProduct()");
882ffd6a 94}
95
e2d51347 96//________________________________________________________________________
97AliAnalysisTaskScalarProduct::~AliAnalysisTaskScalarProduct()
98{
99 //
100 // Destructor
101 //
102
103 // histograms are in the output list and deleted when the output
104 // list is deleted by the TSelector dtor
105
106 // if (ListHistos) {
107 // delete fListHistos;
108 // fListHistos = NULL;
109 // }
8d312f00 110}
111
112//________________________________________________________________________
ea456d37 113void AliAnalysisTaskScalarProduct::UserCreateOutputObjects()
8d312f00 114{
e2d51347 115 // Called at every worker node to initialize
cea49479 116 AliDebug(2,"AliAnalysisTaskScalarProduct::CreateOutputObjects()");
dc3481ef 117
e2d51347 118 //Analyser
a554b203 119 fSP = new AliFlowAnalysisWithScalarProduct();
b591bbbb 120 fSP->SetBookOnlyBasicCCH(fMinimalBook);
a554b203 121
122 //set the allowed relative difference in the subevent multiplicities
02914cfa 123 //fSP->SetRelDiffMsub(fRelDiffMsub);
1073c74a 124
3c5d5752 125 //apply automatic correction for non-uniform acceptance:
1073c74a 126 if (fApplyCorrectionForNUA) {
cea49479 127 AliDebug(2,"Corrections for non-uniform acceptance applied in the Scalar Product method");
1073c74a 128 }
3c5d5752 129 fSP->SetApplyCorrectionForNUA(fApplyCorrectionForNUA);
50fe33aa 130 // harmonic:
131 fSP->SetHarmonic(fHarmonic);
02914cfa 132 fSP->SetNormalizationType( fNormalizationType );
2a3b9289 133 // total Q-vector:
02914cfa 134 Int_t totalQ = 0;
135 if( fTotalQvector->Contains("Qa") ) totalQ += 1;
136 if( fTotalQvector->Contains("Qb") ) totalQ += 2;
137 fSP->SetTotalQvector( totalQ );
29195b69 138 //for using phi weights:
139 if(fUsePhiWeights) {
140 //pass the flag to the analysis class:
141 fSP->SetUsePhiWeights(fUsePhiWeights);
142 //get data from input slot #1 which is used for weights:
143 if(GetNinputs()==2) {
144 fListWeights = (TList*)GetInputData(1);
145 }
146 //pass the list with weights to the analysis class:
147 if(fListWeights) fSP->SetWeightsList(fListWeights);
148 }
d7eb18ec 149
29195b69 150 fSP-> Init();
8d312f00 151
d7eb18ec 152 if (fSP->GetHistList()) {
dc3481ef 153 fListHistos = fSP->GetHistList();
8d312f00 154 }
d7eb18ec 155 else {Printf("ERROR: Could not retrieve histogram list"); }
61e0c8c0 156
157 PostData(1,fListHistos);
158
8d312f00 159}
160
161//________________________________________________________________________
ea456d37 162void AliAnalysisTaskScalarProduct::UserExec(Option_t *)
8d312f00 163{
164 // Main loop
165 // Called for each event
166
882ffd6a 167
dc3481ef 168 fEvent = dynamic_cast<AliFlowEventSimple*>(GetInputData(0));
169 if (fEvent){
8fa6a5fa 170 fSP->ProcessEvent(fEvent);
8d312f00 171 }
dc3481ef 172 else {
29195b69 173 cout << "Warning no input data for Scalar Product task!!!" << endl;
8d312f00 174 }
88e00a8a 175
88e00a8a 176 //fListHistos->Print();
ea456d37 177 PostData(1,fListHistos);
dc3481ef 178
882ffd6a 179}
8d312f00 180
181//________________________________________________________________________
182void AliAnalysisTaskScalarProduct::Terminate(Option_t *)
183{
395fadba 184 // Called once at the end of the query
185 AliFlowAnalysisWithScalarProduct* fSPTerm = new AliFlowAnalysisWithScalarProduct() ;
ea456d37 186 fListHistos = (TList*)GetOutputData(1);
395fadba 187 if (fListHistos) {
fd46c3dd 188 fSPTerm -> GetOutputHistograms(fListHistos);
395fadba 189 fSPTerm -> Finish();
ea456d37 190 PostData(1,fListHistos);
395fadba 191 }
fd46c3dd 192
395fadba 193 else { cout << "histgram list pointer is empty in Scalar Product" << endl; }
9d062fe3 194
df802279 195}