]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG2/FLOW/AliFlowTasks/AliAnalysisTaskScalarProduct.cxx
changed inheritance to TaskSE
[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
16#include "Riostream.h" //needed as include
8d312f00 17
395fadba 18class TFile;
19class TList;
ea456d37 20class AliAnalysisTaskSE;
395fadba 21
22#include "TProfile.h" //needed as include
8d312f00 23#include "AliAnalysisManager.h"
dc3481ef 24#include "AliFlowEventSimple.h"
88e00a8a 25
8d312f00 26#include "AliAnalysisTaskScalarProduct.h"
8d312f00 27#include "AliFlowAnalysisWithScalarProduct.h"
04f6283b 28#include "AliFlowCommonHist.h"
dc3481ef 29#include "AliFlowCommonHistResults.h"
8d312f00 30
29195b69 31///////////////////////////////////////////////
8d312f00 32// AliAnalysisTaskScalarProduct:
33//
34// analysis task for Scalar Product Method
35//
36// Author: Naomi van der Kolk (kolk@nikhef.nl)
29195b69 37///////////////////////////////////////////////
8d312f00 38
39ClassImp(AliAnalysisTaskScalarProduct)
40
41//________________________________________________________________________
29195b69 42AliAnalysisTaskScalarProduct::AliAnalysisTaskScalarProduct(const char *name, Bool_t usePhiWeights) :
ea456d37 43 AliAnalysisTaskSE(name),
dc3481ef 44 fEvent(NULL),
d7eb18ec 45 fSP(NULL),
29195b69 46 fListHistos(NULL),
47 fUsePhiWeights(usePhiWeights),
48 fListWeights(NULL)
49{
8d312f00 50 // Constructor
51 cout<<"AliAnalysisTaskScalarProduct::AliAnalysisTaskScalarProduct(const char *name)"<<endl;
52
53 // Define input and output slots here
dc3481ef 54 // Input slot #0 works with an AliFlowEventSimple
55 DefineInput(0, AliFlowEventSimple::Class());
29195b69 56 // Input slot #1 is needed for the weights input file
57 if(usePhiWeights) {
58 DefineInput(1, TList::Class()); }
8d312f00 59 // Output slot #0 writes into a TList container
ea456d37 60 DefineOutput(1, TList::Class());
e2d51347 61}
62
882ffd6a 63//________________________________________________________________________
64AliAnalysisTaskScalarProduct::AliAnalysisTaskScalarProduct() :
ea456d37 65 AliAnalysisTaskSE(),
dc3481ef 66 fEvent(NULL),
882ffd6a 67 fSP(NULL),
29195b69 68 fListHistos(NULL),
69 fUsePhiWeights(kFALSE),
70 fListWeights(NULL)
dc3481ef 71 {
882ffd6a 72 // Constructor
73 cout<<"AliAnalysisTaskScalarProduct::AliAnalysisTaskScalarProduct()"<<endl;
74}
75
e2d51347 76//________________________________________________________________________
77AliAnalysisTaskScalarProduct::~AliAnalysisTaskScalarProduct()
78{
79 //
80 // Destructor
81 //
82
83 // histograms are in the output list and deleted when the output
84 // list is deleted by the TSelector dtor
85
86 // if (ListHistos) {
87 // delete fListHistos;
88 // fListHistos = NULL;
89 // }
8d312f00 90}
91
92//________________________________________________________________________
ea456d37 93void AliAnalysisTaskScalarProduct::UserCreateOutputObjects()
8d312f00 94{
e2d51347 95 // Called at every worker node to initialize
8d312f00 96 cout<<"AliAnalysisTaskScalarProduct::CreateOutputObjects()"<<endl;
dc3481ef 97
e2d51347 98 //Analyser
99 fSP = new AliFlowAnalysisWithScalarProduct() ;
29195b69 100
101 //for using phi weights:
102 if(fUsePhiWeights) {
103 //pass the flag to the analysis class:
104 fSP->SetUsePhiWeights(fUsePhiWeights);
105 //get data from input slot #1 which is used for weights:
106 if(GetNinputs()==2) {
107 fListWeights = (TList*)GetInputData(1);
108 }
109 //pass the list with weights to the analysis class:
110 if(fListWeights) fSP->SetWeightsList(fListWeights);
111 }
d7eb18ec 112
29195b69 113 fSP-> Init();
8d312f00 114
d7eb18ec 115 if (fSP->GetHistList()) {
dc3481ef 116 fListHistos = fSP->GetHistList();
8d312f00 117 }
d7eb18ec 118 else {Printf("ERROR: Could not retrieve histogram list"); }
8d312f00 119}
120
121//________________________________________________________________________
ea456d37 122void AliAnalysisTaskScalarProduct::UserExec(Option_t *)
8d312f00 123{
124 // Main loop
125 // Called for each event
126
882ffd6a 127
dc3481ef 128 fEvent = dynamic_cast<AliFlowEventSimple*>(GetInputData(0));
129 if (fEvent){
8d312f00 130 fSP->Make(fEvent);
8d312f00 131 }
dc3481ef 132 else {
29195b69 133 cout << "Warning no input data for Scalar Product task!!!" << endl;
8d312f00 134 }
88e00a8a 135
88e00a8a 136 //fListHistos->Print();
ea456d37 137 PostData(1,fListHistos);
dc3481ef 138
882ffd6a 139}
8d312f00 140
141//________________________________________________________________________
142void AliAnalysisTaskScalarProduct::Terminate(Option_t *)
143{
395fadba 144 // Called once at the end of the query
145 AliFlowAnalysisWithScalarProduct* fSPTerm = new AliFlowAnalysisWithScalarProduct() ;
ea456d37 146 fListHistos = (TList*)GetOutputData(1);
395fadba 147 if (fListHistos) {
fd46c3dd 148 fSPTerm -> GetOutputHistograms(fListHistos);
395fadba 149 fSPTerm -> Finish();
ea456d37 150 PostData(1,fListHistos);
395fadba 151 }
fd46c3dd 152
395fadba 153 else { cout << "histgram list pointer is empty in Scalar Product" << endl; }
9d062fe3 154
df802279 155}