]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG2/FLOW/AliFlowTasks/AliAnalysisTaskScalarProduct.cxx
support for nonisotropic detctor in SP method also on task level
[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),
51 fApplyCorrectionForNUA(kFALSE)
29195b69 52{
8d312f00 53 // Constructor
54 cout<<"AliAnalysisTaskScalarProduct::AliAnalysisTaskScalarProduct(const char *name)"<<endl;
55
56 // Define input and output slots here
dc3481ef 57 // Input slot #0 works with an AliFlowEventSimple
58 DefineInput(0, AliFlowEventSimple::Class());
29195b69 59 // Input slot #1 is needed for the weights input file
60 if(usePhiWeights) {
61 DefineInput(1, TList::Class()); }
8d312f00 62 // Output slot #0 writes into a TList container
ea456d37 63 DefineOutput(1, TList::Class());
e2d51347 64}
65
882ffd6a 66//________________________________________________________________________
67AliAnalysisTaskScalarProduct::AliAnalysisTaskScalarProduct() :
ea456d37 68 AliAnalysisTaskSE(),
dc3481ef 69 fEvent(NULL),
882ffd6a 70 fSP(NULL),
29195b69 71 fListHistos(NULL),
72 fUsePhiWeights(kFALSE),
a554b203 73 fListWeights(NULL),
3c5d5752 74 fRelDiffMsub(1.0),
75 fApplyCorrectionForNUA(kFALSE)
dc3481ef 76 {
882ffd6a 77 // Constructor
78 cout<<"AliAnalysisTaskScalarProduct::AliAnalysisTaskScalarProduct()"<<endl;
79}
80
e2d51347 81//________________________________________________________________________
82AliAnalysisTaskScalarProduct::~AliAnalysisTaskScalarProduct()
83{
84 //
85 // Destructor
86 //
87
88 // histograms are in the output list and deleted when the output
89 // list is deleted by the TSelector dtor
90
91 // if (ListHistos) {
92 // delete fListHistos;
93 // fListHistos = NULL;
94 // }
8d312f00 95}
96
97//________________________________________________________________________
ea456d37 98void AliAnalysisTaskScalarProduct::UserCreateOutputObjects()
8d312f00 99{
e2d51347 100 // Called at every worker node to initialize
8d312f00 101 cout<<"AliAnalysisTaskScalarProduct::CreateOutputObjects()"<<endl;
dc3481ef 102
e2d51347 103 //Analyser
a554b203 104 fSP = new AliFlowAnalysisWithScalarProduct();
105
106 //set the allowed relative difference in the subevent multiplicities
107 fSP->SetRelDiffMsub(fRelDiffMsub);
3c5d5752 108
109 cout<<endl;
110 cout<<endl;
111 cout<<endl;
112 cout<<endl;
113 cout<<"TASK SP: "<<fApplyCorrectionForNUA<<endl;
114 cout<<endl;
115 cout<<endl;
116 cout<<endl;
117 cout<<endl;
118
119 //apply automatic correction for non-uniform acceptance:
120 fSP->SetApplyCorrectionForNUA(fApplyCorrectionForNUA);
29195b69 121
122 //for using phi weights:
123 if(fUsePhiWeights) {
124 //pass the flag to the analysis class:
125 fSP->SetUsePhiWeights(fUsePhiWeights);
126 //get data from input slot #1 which is used for weights:
127 if(GetNinputs()==2) {
128 fListWeights = (TList*)GetInputData(1);
129 }
130 //pass the list with weights to the analysis class:
131 if(fListWeights) fSP->SetWeightsList(fListWeights);
132 }
d7eb18ec 133
29195b69 134 fSP-> Init();
8d312f00 135
d7eb18ec 136 if (fSP->GetHistList()) {
dc3481ef 137 fListHistos = fSP->GetHistList();
8d312f00 138 }
d7eb18ec 139 else {Printf("ERROR: Could not retrieve histogram list"); }
61e0c8c0 140
141 PostData(1,fListHistos);
142
8d312f00 143}
144
145//________________________________________________________________________
ea456d37 146void AliAnalysisTaskScalarProduct::UserExec(Option_t *)
8d312f00 147{
148 // Main loop
149 // Called for each event
150
882ffd6a 151
dc3481ef 152 fEvent = dynamic_cast<AliFlowEventSimple*>(GetInputData(0));
153 if (fEvent){
8d312f00 154 fSP->Make(fEvent);
8d312f00 155 }
dc3481ef 156 else {
29195b69 157 cout << "Warning no input data for Scalar Product task!!!" << endl;
8d312f00 158 }
88e00a8a 159
88e00a8a 160 //fListHistos->Print();
ea456d37 161 PostData(1,fListHistos);
dc3481ef 162
882ffd6a 163}
8d312f00 164
165//________________________________________________________________________
166void AliAnalysisTaskScalarProduct::Terminate(Option_t *)
167{
395fadba 168 // Called once at the end of the query
169 AliFlowAnalysisWithScalarProduct* fSPTerm = new AliFlowAnalysisWithScalarProduct() ;
ea456d37 170 fListHistos = (TList*)GetOutputData(1);
395fadba 171 if (fListHistos) {
fd46c3dd 172 fSPTerm -> GetOutputHistograms(fListHistos);
395fadba 173 fSPTerm -> Finish();
ea456d37 174 PostData(1,fListHistos);
395fadba 175 }
fd46c3dd 176
395fadba 177 else { cout << "histgram list pointer is empty in Scalar Product" << endl; }
9d062fe3 178
df802279 179}