AliPhysics  c0d7b22 (c0d7b22)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliAnalysisTaskScalarProduct.cxx
Go to the documentation of this file.
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 
17 // AliAnalysisTaskScalarProduct:
18 //
19 // analysis task for Scalar Product Method
20 //
21 // Author: Naomi van der Kolk (kolk@nikhef.nl)
23 
24 
25 #include "Riostream.h" //needed as include
26 
27 class TFile;
28 class TList;
29 class AliAnalysisTaskSE;
30 
31 #include "TProfile.h" //needed as include
32 #include "AliAnalysisManager.h"
33 #include "AliFlowEventSimple.h"
34 
37 #include "AliFlowCommonHist.h"
39 
40 #include "AliLog.h"
41 
42 using std::endl;
43 using std::cout;
45 
46 //________________________________________________________________________
47 AliAnalysisTaskScalarProduct::AliAnalysisTaskScalarProduct(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  fRelDiffMsub(1.0),
56  fApplyCorrectionForNUA(kFALSE),
57  fHarmonic(2),
58  fNormalizationType(1),
59  fTotalQvector(NULL)
60 {
61  // Constructor
62  AliDebug(2,"AliAnalysisTaskScalarProduct::AliAnalysisTaskScalarProduct(const char *name)");
63 
64  // Define input and output slots here
65  // Input slot #0 works with an AliFlowEventSimple
66  DefineInput(0, AliFlowEventSimple::Class());
67  // Input slot #1 is needed for the weights input file
68  if(usePhiWeights) {
69  DefineInput(1, TList::Class()); }
70  // Output slot #0 writes into a TList container
71  DefineOutput(1, TList::Class());
72 
73  // Total Q-vector is: "QaQb" (means Qa+Qb), "Qa" or "Qb"
74  fTotalQvector = new TString("QaQb");
75 }
76 
77 //________________________________________________________________________
79  AliAnalysisTaskSE(),
80  fEvent(NULL),
81  fSP(NULL),
82  fListHistos(NULL),
83  fMinimalBook(kFALSE),
84  fUsePhiWeights(kFALSE),
85  fListWeights(NULL),
86  fRelDiffMsub(1.0),
87  fApplyCorrectionForNUA(kFALSE),
88  fHarmonic(0),
89  fNormalizationType(1),
90  fTotalQvector(NULL)
91  {
92  // Constructor
93  AliDebug(2,"AliAnalysisTaskScalarProduct::AliAnalysisTaskScalarProduct()");
94 }
95 
96 //________________________________________________________________________
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  // }
110 }
111 
112 //________________________________________________________________________
114 {
115  // Called at every worker node to initialize
116  AliDebug(2,"AliAnalysisTaskScalarProduct::CreateOutputObjects()");
117 
118  //Analyser
121 
122  //set the allowed relative difference in the subevent multiplicities
123  //fSP->SetRelDiffMsub(fRelDiffMsub);
124 
125  //apply automatic correction for non-uniform acceptance:
127  AliDebug(2,"Corrections for non-uniform acceptance applied in the Scalar Product method");
128  }
130  // harmonic:
133  // total Q-vector:
134  Int_t totalQ = 0;
135  if( fTotalQvector->Contains("Qa") ) totalQ += 1;
136  if( fTotalQvector->Contains("Qb") ) totalQ += 2;
137  fSP->SetTotalQvector( totalQ );
138  //for using phi weights:
139  if(fUsePhiWeights) {
140  //pass the flag to the analysis class:
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:
148  }
149 
150  fSP-> Init();
151 
152  if (fSP->GetHistList()) {
154  }
155  else {Printf("ERROR: Could not retrieve histogram list"); }
156 
157  PostData(1,fListHistos);
158 
159 }
160 
161 //________________________________________________________________________
163 {
164  // Main loop
165  // Called for each event
166 
167 
168  fEvent = dynamic_cast<AliFlowEventSimple*>(GetInputData(0));
169  if (fEvent){
171  }
172  else {
173  cout << "Warning no input data for Scalar Product task!!!" << endl;
174  }
175 
176  //fListHistos->Print();
177  PostData(1,fListHistos);
178 
179 }
180 
181 //________________________________________________________________________
183 {
184  // Called once at the end of the query
186  fListHistos = (TList*)GetOutputData(1);
187  if (fListHistos) {
188  fSPTerm -> GetOutputHistograms(fListHistos);
189  fSPTerm -> Finish();
190  PostData(1,fListHistos);
191  }
192 
193  else { cout << "histgram list pointer is empty in Scalar Product" << endl; }
194 
195 }
ClassImp(AliAnalysisTaskScalarProduct) AliAnalysisTaskScalarProduct
virtual void ProcessEvent(AliFlowEventSimple *)
virtual void UserExec(Option_t *option)
AliFlowAnalysisWithScalarProduct * fSP
void SetWeightsList(TList *const aWeightsList)