]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGCF/FLOW/Attic/AliAnalysisTaskMSP.cxx
moved files
[u/mrichter/AliRoot.git] / PWGCF / FLOW / Attic / AliAnalysisTaskMSP.cxx
CommitLineData
9d7fd9bf 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// AliAnalysisTaskMSP:
18//
19// analysis task for Scalar Product Method
20//
21// Author: Paul Kuijer (Paul.Kuijer@nikhef.nl)
22///////////////////////////////////////////////
23
24
25#include "Riostream.h" //needed as include
26
27class TFile;
28class TList;
29class AliAnalysisTaskSE;
30
31#include "TProfile.h" //needed as include
32#include "AliAnalysisManager.h"
33#include "AliFlowEventSimple.h"
34
35#include "AliAnalysisTaskMSP.h"
36#include "AliFlowAnalysisWithMSP.h"
37#include "AliFlowCommonHist.h"
38#include "AliFlowCommonHistResults.h"
39
40#include "AliLog.h"
41
42using std::endl;
43using std::cout;
44ClassImp(AliAnalysisTaskMSP)
45
46//________________________________________________________________________
47AliAnalysisTaskMSP::AliAnalysisTaskMSP(const char *name, Bool_t usePhiWeights) :
48 AliAnalysisTaskSE(name),
49 fEvent(NULL),
50 fSP(NULL),
51 fListHistos(NULL),
52 fMinimalBook(kFALSE),
53 fUsePhiWeights(usePhiWeights),
54 fListWeights(NULL),
55 fApplyCorrectionForNUA(kFALSE),
56 fHarmonic(2)
57{
58 // Constructor
59 AliDebug(2,"AliAnalysisTaskMSP::AliAnalysisTaskMSP(const char *name)");
60
61 // Define input and output slots here
62 // Input slot #0 works with an AliFlowEventSimple
63 DefineInput(0, AliFlowEventSimple::Class());
64 // Input slot #1 is needed for the weights input file
65 if(usePhiWeights) {
66 DefineInput(1, TList::Class()); }
67 // Output slot #0 writes into a TList container
68 DefineOutput(1, TList::Class());
69}
70
71//________________________________________________________________________
72AliAnalysisTaskMSP::AliAnalysisTaskMSP() :
73 AliAnalysisTaskSE(),
74 fEvent(NULL),
75 fSP(NULL),
76 fListHistos(NULL),
77 fMinimalBook(kFALSE),
78 fUsePhiWeights(kFALSE),
79 fListWeights(NULL),
80 fApplyCorrectionForNUA(kFALSE),
81 fHarmonic(0)
82 {
83 // Constructor
84 AliDebug(2,"AliAnalysisTaskMSP::AliAnalysisTaskMSP()");
85}
86
87//________________________________________________________________________
88AliAnalysisTaskMSP::~AliAnalysisTaskMSP()
89{
90 //
91 // Destructor
92 //
93
94 // histograms are in the output list and deleted when the output
95 // list is deleted by the TSelector dtor
96
97 // if (ListHistos) {
98 // delete fListHistos;
99 // fListHistos = NULL;
100 // }
101}
102
103//________________________________________________________________________
104void AliAnalysisTaskMSP::UserCreateOutputObjects()
105{
106 // Called at every worker node to initialize
107 AliDebug(2,"AliAnalysisTaskMSP::CreateOutputObjects()");
108
109 //Analyser
110 fSP = new AliFlowAnalysisWithMSP();
111 fSP->UseCommonConstants(kTRUE);
112 fSP->EnableCommonHistograms(!fMinimalBook);
113
114 //set the allowed relative difference in the subevent multiplicities
115 //fSP->SetRelDiffMsub(fRelDiffMsub);
116
117 //apply automatic correction for non-uniform acceptance:
118 if (fApplyCorrectionForNUA) {
119 AliDebug(2,"Corrections for non-uniform acceptance applied in the MSP method");
120 }
121 fSP->EnableNUA(fApplyCorrectionForNUA);
122 // harmonic:
123 fSP->SetHarmonic(fHarmonic);
124
125 /* TODO: Phi weigths not implemented yet:
126 //for using phi weights:
127 if(fUsePhiWeights) {
128 //pass the flag to the analysis class:
129 fSP->SetUsePhiWeights(fUsePhiWeights);
130 //get data from input slot #1 which is used for weights:
131 if(GetNinputs()==2) {
132 fListWeights = (TList*)GetInputData(1);
133 }
134 //pass the list with weights to the analysis class:
135 if(fListWeights) fSP->SetWeightsList(fListWeights);
136 }
137 */
138
139 fSP-> Init();
140
141 if( !(fListHistos = fSP->ListHistograms()) ) {
142 Printf("ERROR: Could not retrieve histogram list");
143 }else{
144 fListHistos->SetOwner(kTRUE); // TODO: required by analysis manager but will clash with destructor of AliAnalysisWithMSP
145 }
146
147 PostData(1,fListHistos);
148}
149
150//________________________________________________________________________
151void AliAnalysisTaskMSP::UserExec(Option_t *)
152{
153 // Main loop
154 // Called for each event
155
156
157 fEvent = dynamic_cast<AliFlowEventSimple*>(GetInputData(0));
158 if (fEvent){
159 fSP->Make(fEvent);
160 }
161 else {
162 cout << "Warning no input data for Scalar Product task!!!" << endl;
163 }
164
165 //fListHistos->Print();
166 PostData(1,fListHistos);
167
168}
169
170//________________________________________________________________________
171void AliAnalysisTaskMSP::Terminate(Option_t *)
172{
173 // Called once at the end of the query
174 // TODO: check if it is really required to do Finish here. The results should be calculated after merging, not here. Finish does not do much else.
175
176 fListHistos = (TList*)GetOutputData(1);
177 if (fListHistos) {
178 // Create a temporary analysis object to calculate the results because the original is not available on CAF.
179 AliFlowAnalysisWithMSP* fMSPTerm = new AliFlowAnalysisWithMSP(fListHistos) ; // Load histograms
180 fMSPTerm->EnableNUA(fApplyCorrectionForNUA);
181 fMSPTerm -> Finish(); // Create result histograms
182 fListHistos=fMSPTerm->ListHistograms(); // Get new list including results
183 fListHistos->SetOwner(kTRUE); // TODO: Required by analysis manager, but will clash with destructor of this object
184 PostData(1,fListHistos);
185 } else {
186 cout << "histgram list pointer is empty in Scalar Product" << endl;
187 }
188}