]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG/FLOW/Base/AliFlowAnalysisWithMSP.cxx
adds void AliFlowEventSimple::ShuffleTracks() to allow for explicit reshuffling of...
[u/mrichter/AliRoot.git] / PWG / FLOW / Base / AliFlowAnalysisWithMSP.cxx
CommitLineData
dc8ba4dd 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 "AliFlowAnalysisWithMSP.h"
17
18#include "AliFlowVector.h"
19#include "AliFlowMSPHistograms.h"
20#include "AliFlowEventSimple.h"
21#include "AliFlowTrackSimple.h"
22#include "AliFlowCommonConstants.h"
23#include "AliFlowCommonHist.h"
24#include "AliFlowCommonHistResults.h"
25
26#include <TList.h>
27#include <TH1D.h>
28#include <TProfile.h>
29#include <TVector2.h>
30#include <TDirectoryFile.h>
31#include <TMath.h>
32
33#include <iostream>
34#include <iomanip>
35
36AliFlowAnalysisWithMSP::AliFlowAnalysisWithMSP()
7b5556ef 37 : TNamed(),
38 fHarmonic(2), fNUA(kFALSE), fUseCommonConstants(kFALSE), fBookCommonHistograms(kFALSE), fCommonHist(0), fQaComponents(0),
dc8ba4dd 39 fQbComponents(0), fQaQb(0), fPtUComponents(0), fEtaUComponents(0), fAllStatistics(0),
40 fPtStatistics(0), fEtaStatistics(0),
7b5556ef 41 fIntegratedFlow(0), fDiffFlowPt(0), fDiffFlowEta(0), fFlags(0), fHistList(0)
dc8ba4dd 42{
43 // Default constructor. Intended for root IO purposes only
44}
45
7b5556ef 46AliFlowAnalysisWithMSP::AliFlowAnalysisWithMSP(TDirectory *file)
47 : TNamed(),
48 fHarmonic(2), fNUA(kFALSE), fUseCommonConstants(kFALSE), fBookCommonHistograms(kFALSE), fCommonHist(0), fQaComponents(0),
dc8ba4dd 49 fQbComponents(0), fQaQb(0), fPtUComponents(0), fEtaUComponents(0), fAllStatistics(0),
50 fPtStatistics(0), fEtaStatistics(0),
7b5556ef 51 fIntegratedFlow(0), fDiffFlowPt(0), fDiffFlowEta(0), fFlags(0), fHistList(0)
dc8ba4dd 52{
7b5556ef 53 // Constructor reads the internal state from a root file.
54 // No check for consistency is done. If flags or histograms are not found they are left at default (0).
dc8ba4dd 55 ReadHistograms(file);
56}
57
7b5556ef 58AliFlowAnalysisWithMSP::AliFlowAnalysisWithMSP(TList *list)
59 : TNamed(),
60 fHarmonic(2), fNUA(kFALSE), fUseCommonConstants(kFALSE), fBookCommonHistograms(kFALSE), fCommonHist(0), fQaComponents(0),
61 fQbComponents(0), fQaQb(0), fPtUComponents(0), fEtaUComponents(0), fAllStatistics(0),
62 fPtStatistics(0), fEtaStatistics(0),
63 fIntegratedFlow(0), fDiffFlowPt(0), fDiffFlowEta(0), fFlags(0), fHistList(0)
64{
65 // Constructor reads the internal state from a root file.
66 // No check for consistency is done. If flags or histograms are not found they are left at default (0).
67 ReadHistograms(list);
68}
69
70
dc8ba4dd 71AliFlowAnalysisWithMSP::AliFlowAnalysisWithMSP(const unsigned int harmonic, const bool commonConst, const bool commonHist)
7b5556ef 72 : TNamed(),
73 fHarmonic(harmonic), fNUA(kFALSE), fUseCommonConstants(commonConst), fBookCommonHistograms(commonHist), fCommonHist(0), fQaComponents(0),
dc8ba4dd 74 fQbComponents(0), fQaQb(0), fPtUComponents(0), fEtaUComponents(0), fAllStatistics(0),
75 fPtStatistics(0), fEtaStatistics(0),
7b5556ef 76 fIntegratedFlow(0), fDiffFlowPt(0), fDiffFlowEta(0), fFlags(0), fHistList(0)
dc8ba4dd 77{
78 // Constructor defining the harmonic, usage of non uniform acceptance corrections and the AliFlowCommonHist() histograms
7b5556ef 79 // Calls Init() to set-up the histograms. This is equivalent to:
80 // AliFlowAnalysisWithMSP *ana= new AliFlowAnalysisWithMSP);
81 // ana->SetHarmonic(harmonic);
82 // ana->UseCommonConstants(commonConst);
83 // ana->EnableCommonHistograms(commonHist);
84 // ana->Init();
dc8ba4dd 85 // This is the constructor intended for the user
86 SetNameTitle("MSP","Flow analysis with the Modified Scalar Product method");
7b5556ef 87 Init();
88}
89
90AliFlowAnalysisWithMSP::AliFlowAnalysisWithMSP(const AliFlowAnalysisWithMSP &x)
91 : TNamed(),
92 fHarmonic(x.fHarmonic), fNUA(x.fNUA), fUseCommonConstants(x.fUseCommonConstants), fBookCommonHistograms(x.fBookCommonHistograms), fCommonHist(0),
93 fQaComponents(0), fQbComponents(0), fQaQb(0), fPtUComponents(0), fEtaUComponents(0), fAllStatistics(0),
94 fPtStatistics(0), fEtaStatistics(0),
95 fIntegratedFlow(0), fDiffFlowPt(0), fDiffFlowEta(0), fFlags(0), fHistList(0)
96{
97 // Copy constructor
98 SetNameTitle("MSP","Flow analysis with the Modified Scalar Product method");
99 if( x.fQaComponents ) fQaComponents=(AliFlowMSPHistograms *)(x.fQaComponents)->Clone();
100 if( x.fQbComponents ) fQbComponents=(AliFlowMSPHistograms *)(x.fQbComponents)->Clone();
101 if( x.fQaQb ) fQaQb=(AliFlowMSPHistograms *)(x.fQaQb)->Clone();
102 if( x.fPtUComponents) fPtUComponents=(AliFlowMSPHistograms *)(x.fPtUComponents)->Clone();
103 if( x.fEtaUComponents ) fEtaUComponents=(AliFlowMSPHistograms *)(x.fEtaUComponents)->Clone();
104 if( x.fAllStatistics ) fAllStatistics=(AliFlowMSPHistograms *)(x.fAllStatistics)->Clone();
105 if( x.fPtStatistics ) fPtStatistics=(AliFlowMSPHistograms *)(x.fPtStatistics)->Clone();
106 if( x.fEtaStatistics ) fEtaStatistics=(AliFlowMSPHistograms *)(x.fEtaStatistics)->Clone();
107 if( x.fIntegratedFlow ) fIntegratedFlow=(TH1D *)(x.fIntegratedFlow)->Clone();
108 if( x.fDiffFlowPt ) fDiffFlowPt=(TH1D *)(x.fDiffFlowPt)->Clone();
109 if( x.fDiffFlowEta ) fDiffFlowEta=(TH1D *)(x.fDiffFlowEta)->Clone();
110 if( x.fFlags ) fFlags=(TProfile *)(x.fFlags)->Clone();
111 if( x.fCommonHist ) fCommonHist=new AliFlowCommonHist(*(x.fCommonHist));
112 // The histogram list fHistList is not cloned because it is regenerated when requested
dc8ba4dd 113}
114
115AliFlowAnalysisWithMSP::~AliFlowAnalysisWithMSP()
116{
7b5556ef 117 // Destructor. All internal objects are owned by this class and deleted here.
dc8ba4dd 118 delete fCommonHist;
119 delete fQaComponents;
120 delete fQbComponents;
121 delete fQaQb;
122 delete fPtUComponents;
123 delete fEtaUComponents;
124 delete fAllStatistics;
125 delete fPtStatistics;
126 delete fEtaStatistics;
127 delete fIntegratedFlow;
128 delete fDiffFlowPt;
129 delete fDiffFlowEta;
130 delete fFlags;
7b5556ef 131 if(fHistList) {
132 fHistList->SetOwner(kFALSE); // Histograms were already deleted manually
133 delete fHistList; // Delete the TList itself
134 }
dc8ba4dd 135}
136
137void AliFlowAnalysisWithMSP::Init()
138{
139 // Create all output objects. Memory consumption can be reduced by switching off some of the control histograms.
7b5556ef 140 // pt and eta binning are set to the values defined in the static class AliFlowCommonConstants if enabled. Otherwise defaults are set.
dc8ba4dd 141 delete fCommonHist; fCommonHist=0; // Delete existing histograms
142 delete fQaComponents; fQaComponents=0;
143 delete fQbComponents; fQbComponents=0;
144 delete fQaQb; fQaQb=0;
145 delete fPtUComponents; fPtUComponents=0;
146 delete fEtaUComponents; fEtaUComponents=0;
147 delete fAllStatistics; fAllStatistics=0;
148 delete fPtStatistics; fPtStatistics=0;
149 delete fEtaStatistics; fEtaStatistics=0;
150 delete fIntegratedFlow; fIntegratedFlow=0;
151 delete fDiffFlowPt; fDiffFlowPt=0;
152 delete fDiffFlowEta; fDiffFlowEta=0;
153 delete fFlags; fFlags=0;
7b5556ef 154 if(fHistList) {
155 fHistList->SetOwner(kFALSE); // Histograms were already deleted manually
156 delete fHistList; // Delete the TList itself
157 fHistList=0; // Clear pointer which is invalid afcter delete
158 }
dc8ba4dd 159
160 // Default binning for histograms
7b5556ef 161 // TODO: allow variable binning in a simpler way than by AliFlowCommonConstants() only
dc8ba4dd 162
163 // Defaults
164 int nBinsPt=100;
165 double ptMin=0;
166 double ptMax=10.0;
167 int nBinsEta=100;
168 double etaMin=-0.8;
169 double etaMax=+0.8;
170
171 if( fUseCommonConstants || fBookCommonHistograms ) {
172 AliFlowCommonConstants *c=AliFlowCommonConstants::GetMaster();
173 nBinsPt=c->GetNbinsPt();
174 ptMin=c->GetPtMin();
175 ptMax=c->GetPtMax();
176 nBinsEta=c->GetNbinsEta();
177 etaMin=c->GetEtaMin();
178 etaMax=c->GetEtaMax();
179 }
180
181 if( fBookCommonHistograms ) { // Use the common constants from the flow package for histogram definitions
182 std::cerr << "AliFlowAnalysisWithMSP::Init() Creating common histograms" << std::endl;
183 fCommonHist=new AliFlowCommonHist("AliFlowCommonHist_MSP","AliFlowCommonHist",kTRUE);
184 }
185
186 std::cerr << "AliFlowAnalysisWithMSP::Init() creating MSPHistograms" << std::endl;
187 // Averages for NUA corrections:
188 fQaComponents=new AliFlowMSPHistograms(2,"QaComponents",1,0.5,1.5); // QaX, QaY
189 fQaComponents->SetXName("all");
190 fQaComponents->SetVarName("QaX",0);
191 fQaComponents->SetVarName("QaY",1);
192 fQbComponents=new AliFlowMSPHistograms(2,"QbComponents",1,0.5,1.5); // QbX, QbY
193 fQbComponents->SetXName("all");
194 fQbComponents->SetVarName("QbX",0);
195 fQbComponents->SetVarName("QbY",1);
196 fQaQb=new AliFlowMSPHistograms(1,"QaQb",1,0.5,1.5); // QaQb
197 fQaQb->SetXName("all");
198 fQaQb->SetVarName("QaQb",0);
199 fPtUComponents=new AliFlowMSPHistograms(2,"PtUComponents",nBinsPt,ptMin,ptMax); // ux(pt), uy(pt)
200 fPtUComponents->SetXName("pt");
201 fPtUComponents->SetVarName("ux",0);
202 fPtUComponents->SetVarName("uy",1);
203 fEtaUComponents=new AliFlowMSPHistograms(2,"EtaUComponents",nBinsEta,etaMin,etaMax); // ux(eta), uy(eta)
204 fEtaUComponents->SetXName("eta");
205 fEtaUComponents->SetVarName("ux",0);
206 fEtaUComponents->SetVarName("uy",1);
207
208 // Correlation terms
209 fAllStatistics=new AliFlowMSPHistograms(3,"AllStatistics",1,0.5,1.5); // terms integrated over pt and eta
210 fAllStatistics->SetXName("all");
211 fAllStatistics->SetVarName("uQa",0);
212 fAllStatistics->SetVarName("uQb",1);
213 fAllStatistics->SetVarName("QaQb",2);
214 fPtStatistics=new AliFlowMSPHistograms(3,"PtStatistics",nBinsPt,ptMin,ptMax); // terms per pt bin
215 fPtStatistics->SetXName("pt");
216 fPtStatistics->SetVarName("uQa",0);
217 fPtStatistics->SetVarName("uQb",1);
218 fPtStatistics->SetVarName("QaQb",2);
219 fEtaStatistics=new AliFlowMSPHistograms(3,"EtaStatistics",nBinsEta,etaMin,etaMax); // terms per eta bin
220 fEtaStatistics->SetXName("eta");
221 fEtaStatistics->SetVarName("uQa",0);
222 fEtaStatistics->SetVarName("uQb",1);
223 fEtaStatistics->SetVarName("QaQb",2);
224
225 fIntegratedFlow=0; // Created in Finish()
226 fDiffFlowPt=0; // Created in Finish
227 fDiffFlowEta=0; // Created in Finish
228
229 fFlags=new TProfile("Flags","Flags for AliFlowAnalysisWithMSP",10,0.5,10.5,"s");
230 fFlags->Fill("Harmonic",fHarmonic); // bin 1
231}
232
233void AliFlowAnalysisWithMSP::Make(AliFlowEventSimple *event)
234{
235 // Analyze one event. The modified scalar product method estimates flow using the formula:
236 // BEGIN_LATEX v_2(MSP) = \sqrt( uQ^{a} uQ^{b} / (Q^{a}Q^{b}) ) END_LATEX
237 // The Q vectors are calculated for the harmonic set previously: fHarmonic.
238 // Make(event) does not use the new operator, thus avoiding memory leaks in a simple way
239 // Depending on the compiler about 200 bytes may be pushed/popped on the stack for local variables.
240 //
241
242 if( !event ) return; // Protect against running without events. Can this happen???
243
244 AliFlowVector flowVectors[2]; // Calculate the two subevent Q vectors:
7b5556ef 245 event->Get2Qsub(flowVectors, fHarmonic); // TODO: Check how do the phi, pt, eta weights work in the flow event?
dc8ba4dd 246
247 AliFlowVector &Qa=flowVectors[0]; // Define some mnemonics for the subevent flow vectors:
248 AliFlowVector &Qb=flowVectors[1];
249
250 const double QaW=Qa.GetMult(); // Weight for Qa and combinations of Qa
251 const double QbW=Qb.GetMult(); // Weight for Qb and combinations of Qb
252
253 if( QaW<2 || QbW<2 ) return; // Require at least 2 particles in each subevent
254
255 if(fCommonHist)fCommonHist->FillControlHistograms(event); // Standard for all flow analysis
256
7b5556ef 257 // Fill NUA correction histograms for Qa, Qb and QaQb per event:
258 const double qaxy[]={Qa.X()/QaW,Qa.Y()/QaW}; // Two variables: Qa components
dc8ba4dd 259 const double wqaxy[]={QaW,QaW};
260 fQaComponents->Fill(1, qaxy, wqaxy); // only one bin (all pt)
261
7b5556ef 262 const double qbxy[]={Qb.X()/QbW,Qb.Y()/QbW}; // Two variables: Qb components
dc8ba4dd 263 const double wqbxy[]={QbW,QbW};
264 fQbComponents->Fill(1, qbxy, wqbxy); // only one bin (all pt)
265
266 const double QaQbW=QaW*QbW;
7b5556ef 267 const double weightedQaQb = (Qa*Qb)/QaQbW; // Scalar product of subevent Q vectors with weight, only 1 variable
dc8ba4dd 268 fQaQb->Fill(1,&weightedQaQb,&QaQbW); // Average of QaQb per event
dc8ba4dd 269
270 int iTrack=0;
271 while( AliFlowTrackSimple *track=event->GetTrack(iTrack++) ) {// Loop over the tracks in the event
7b5556ef 272 if(! track->InPOISelection() ) continue; // Ignore if not a POI
273 const double trackWeight=track->Weight(); // Get the track vector
dc8ba4dd 274 const double phi=track->Phi();
275 const double pt=track->Pt();
276 const double eta=track->Eta();
277
278 AliFlowVector u;
7b5556ef 279 u.SetMagPhi(trackWeight, fHarmonic*phi, trackWeight); // Length = track weight = multiplicity for a single track
dc8ba4dd 280
281 // Remove track from subevent a
7b5556ef 282 AliFlowVector mQa(Qa); // Initialize with Qa flow vector of this event
283 if( track->InSubevent(0) ) { // Correct for autocorrelation with POI for this track
284 mQa-=u;
dc8ba4dd 285 }
286
287 // Remove track from subevent b
7b5556ef 288 AliFlowVector mQb(Qb); // Initialize with Qb flow vector of this event
289 if( track->InSubevent(1) ) { // Correct for autocorrelation with POI for this track
290 mQb-=u;
dc8ba4dd 291 }
292
7b5556ef 293 const double uQaW = mQa.GetMult()*trackWeight; // Weight is multiplicity of Q vector times weight of POI
294 const double uQbW = mQb.GetMult()*trackWeight;
295 const double uQa=u*mQa; // Correlate POI with subevent
dc8ba4dd 296 const double uQb=u*mQb;
297
298 const double uxy[]={u.X(),u.Y()};
299 const double wxy[]={1.0,1.0};
7b5556ef 300 fPtUComponents->Fill(pt, uxy, wxy); // NUA for POI vs pt
301 fEtaUComponents->Fill(eta, uxy, wxy); // NUA for POI vs eta
dc8ba4dd 302
7b5556ef 303 const double par[]={uQa/uQaW, uQb/uQbW, weightedQaQb}; // Three variables to correlate: uQa, uQb and QaQb
dc8ba4dd 304 const double wgt[]={uQaW, uQbW, QaQbW};
7b5556ef 305 fAllStatistics->Fill(1, par, wgt ); // only 1 bin, integrated over pt and eta
306 fPtStatistics->Fill(pt, par, wgt ); // pt differential correlations
307 fEtaStatistics->Fill(eta, par, wgt ); // eta differential correlations
dc8ba4dd 308 }
309}
310
311void AliFlowAnalysisWithMSP::Finish()
312{
313 // Calculate the final result from the stored correlations.
314 // The NUA corrections are applied if the flag fNUA was set before the call to Finish()
315 // If the output histograms already exist then they are replaced by the newly calculated result
316
317 Print(); // Print a summary of the NUA terms and integrated flow
dc8ba4dd 318
319 // Create result histograms
320 fFlags->Fill("NUA",fNUA);
321 delete fIntegratedFlow; fIntegratedFlow=0; // First delete existing results (if any)
322 delete fDiffFlowPt; fDiffFlowPt=0;
323 delete fDiffFlowEta; fDiffFlowEta=0;
324
7b5556ef 325 bool oldAddStatus=TH1::AddDirectoryStatus(); // Do not store the next histograms automatically
326 TH1::AddDirectory(kFALSE); // We need full control over the writing of the hostograms
327
dc8ba4dd 328 fIntegratedFlow=new TH1D("IntegratedFlow","Integrated flow results",10,0.5,10.5);
7b5556ef 329 fIntegratedFlow->SetDirectory(0);
dc8ba4dd 330 double vn, vnerror;
331 Calculate(vn, vnerror, fAllStatistics, fPtUComponents, 0, 0);
332 fIntegratedFlow->SetBinContent(1,vn);
333 fIntegratedFlow->SetBinError(1,vnerror);
334 fIntegratedFlow->GetXaxis()->SetBinLabel(1,"POI");
335 Calculate(vn, vnerror, fAllStatistics, fPtUComponents, 0, 1);
336 fIntegratedFlow->SetBinContent(2,vn);
337 fIntegratedFlow->SetBinError(2,vnerror);
338 fIntegratedFlow->GetXaxis()->SetBinLabel(2,"A");
339 Calculate(vn, vnerror, fAllStatistics, fPtUComponents, 0, 2);
340 fIntegratedFlow->SetBinContent(3,vn);
341 fIntegratedFlow->SetBinError(3,vnerror);
342 fIntegratedFlow->GetXaxis()->SetBinLabel(3,"B");
343
344 int nbinspt=fPtStatistics->Nbins();
345 double ptlow=fPtStatistics->XLow();
346 double pthigh=fPtStatistics->XHigh();
347 fDiffFlowPt = new TH1D("DiffFlowPt","flow of POI vs pt",nbinspt,ptlow,pthigh);
348 fDiffFlowPt->SetDirectory(0); // Do not automatically store in file
349 fDiffFlowPt->SetStats(kFALSE);
350 fDiffFlowPt->SetXTitle("p_{t}");
351 fDiffFlowPt->SetYTitle(Form("v_{%d}",fHarmonic));
352
353 for(int i=1; i<=nbinspt; ++i) {
7b5556ef 354 double vnpt=0;
355 double evnpt=0;
356 if( Calculate(vnpt, evnpt, fPtStatistics, fPtUComponents, i) && evnpt<1 ) {
357 fDiffFlowPt->SetBinContent(i,vnpt);
358 fDiffFlowPt->SetBinError(i,evnpt);
dc8ba4dd 359 }
360 }
361
362 int nbinseta=fEtaStatistics->Nbins();
363 double etalow=fEtaStatistics->XLow();
364 double etahigh=fEtaStatistics->XHigh();
365 fDiffFlowEta= new TH1D("DiffFlowEta","flow of POI vs #eta",nbinseta,etalow,etahigh);
366 fDiffFlowEta->SetDirectory(0); // Do not automatically store in file
367 fDiffFlowEta->SetStats(kFALSE);
7b5556ef 368 fDiffFlowEta->SetXTitle("#eta");
dc8ba4dd 369 fDiffFlowEta->SetYTitle(Form("v_{%d}",fHarmonic));
370
371 for(int i=1; i<=nbinseta; ++i) {
7b5556ef 372 double vneta=0;
373 double evneta=0;
374 if( Calculate(vneta, evneta, fEtaStatistics, fEtaUComponents, i) && evneta<1 ) {
375 fDiffFlowEta->SetBinContent(i,vneta);
376 fDiffFlowEta->SetBinError(i,evneta);
dc8ba4dd 377 }
378 }
7b5556ef 379
380 TH1::AddDirectory(oldAddStatus);
dc8ba4dd 381}
382
383void AliFlowAnalysisWithMSP::WriteHistograms(TDirectoryFile *file) const
384{
7b5556ef 385 // Write the internal status to file. If the AliFlowCommonHistograms were enabled they are written also.
386 // Results are written only if they were calculated by Finish().
387 // From these histograms the internal state of *this can be reconstructed with ReadHistograms()
388
389 //file->Write(file->GetName(), TObject::kSingleKey); // Make sure the directory itself is written
dc8ba4dd 390
391 if(fCommonHist) file->WriteTObject(fCommonHist);
392
7b5556ef 393 TList *t=new TList(); // This object is written as a marker for redoFinish()
394 t->SetName("cobjMSP");
395 file->WriteTObject(t,0,"Overwrite");
396 file->WriteTObject(fQaComponents,0,"Overwrite"); // Averages of Qa components per event
397 file->WriteTObject(fQbComponents,0,"Overwrite"); // Averages of Qb components per event
398 file->WriteTObject(fQaQb,0,"Overwrite"); // Average of QaQb per event
399 file->WriteTObject(fPtUComponents,0,"Overwrite"); // u components vs pt
400 file->WriteTObject(fEtaUComponents,0,"Overwrite"); // u components vs eta
401 file->WriteTObject(fAllStatistics,0,"Overwrite"); // Integrated uQa, uQb and QaQa
402 file->WriteTObject(fPtStatistics,0,"Overwrite"); // uQa, uQb and QaQb vs pt
403 file->WriteTObject(fEtaStatistics,0,"Overwrite"); // uQa, uQb and QaQb vs eta
dc8ba4dd 404
405 if( fIntegratedFlow ) file->WriteTObject(fIntegratedFlow,0,"Overwrite"); // Integrated flow for POI and subevents
406 if( fDiffFlowPt ) file->WriteTObject(fDiffFlowPt,0,"Overwrite"); // Differential flow vs pt if calculated
407 if( fDiffFlowEta ) file->WriteTObject(fDiffFlowEta,0,"Overwrite"); // Differential flow vs eta if calculated
408
409 file->WriteTObject(fFlags,0,"Overwrite"); // fHarmonic, fNUA
410
411 file->WriteKeys(); // Make sure it happens now
412}
413
414void AliFlowAnalysisWithMSP::WriteCommonResults(TDirectoryFile *file) const
415{
7b5556ef 416 // Export the results to a AliFlowCommonHistResults() class and write to file
417 // If the results were not calculated then Finish() is called to generate them
418
419 int nBinsPt=fPtStatistics->Nbins(); // Get the actually used binning from the Statistics histograms
dc8ba4dd 420 double ptMin=fPtStatistics->XLow();
421 double ptMax=fPtStatistics->XHigh();
422
423 int nBinsEta=fEtaStatistics->Nbins();
424 double etaMin=fEtaStatistics->XLow();
425 double etaMax=fEtaStatistics->XHigh();
426
7b5556ef 427 AliFlowCommonConstants *c=AliFlowCommonConstants::GetMaster(); // Get the static common constants object
428 // Save the old AliFlowCommonConstants status
429 int oldNbinsPt=c->GetNbinsPt();
430 double oldPtMin=c->GetPtMin();
431 double oldPtMax=c->GetPtMax();
432 int oldNbinsEta=c->GetNbinsEta();
433 double oldEtaMin=c->GetEtaMin();
434 double oldEtaMax=c->GetEtaMax();
435 // Modify AliFlowCommonConstants to make sure that AliFlowCommonResults is generated with the correct binning
dc8ba4dd 436 c->SetNbinsPt(nBinsPt);
437 c->SetPtMin(ptMin);
438 c->SetPtMax(ptMax);
439 c->SetNbinsEta(nBinsEta);
440 c->SetEtaMin(etaMin);
441 c->SetEtaMax(etaMax);
442
7b5556ef 443 bool oldAddStatus=TH1::AddDirectoryStatus(); // Do not store the next histograms automatically
444 TH1::AddDirectory(kFALSE); // We need full control over the writing of the hostograms
dc8ba4dd 445 AliFlowCommonHistResults *h=new AliFlowCommonHistResults("AliFlowCommonHistResults_MSP","AliFlowCommonHistResults from the MSP method",fHarmonic);
446
447 double ivn, ivnerror;
448 Calculate(ivn, ivnerror, fAllStatistics, fPtUComponents, 0, 0);
449 h->FillIntegratedFlowPOI(ivn, ivnerror);
450
451 for(int bin=1; bin<=nBinsPt; ++bin) {
452 double vn=0;
453 double evn=0;
454 if( Calculate(vn, evn, fPtStatistics, fPtUComponents, bin) && evn>0 ) {
455 h->FillDifferentialFlowPtPOI(bin, vn, evn);
456 }
457 }
458
459 for(int bin=1; bin<=nBinsEta; ++bin) {
460 double vn=0;
461 double evn=0;
462 if( Calculate(vn, evn, fEtaStatistics, fEtaUComponents, bin) && evn>0 ) {
463 h->FillDifferentialFlowEtaPOI(bin, vn, evn);
464 }
465 }
466
467 file->WriteTObject(h,0,"Overwrite");
468
7b5556ef 469 TH1::AddDirectory(oldAddStatus); // Restore the automatic storage of histograms to its original status
470
471 // Restore AliFlowCommonConstants to make sure that no other analysis are affected
472 c->SetNbinsPt(oldNbinsPt);
473 c->SetPtMin(oldPtMin);
474 c->SetPtMax(oldPtMax);
475 c->SetNbinsEta(oldNbinsEta);
476 c->SetEtaMin(oldEtaMin);
477 c->SetEtaMax(oldEtaMax);
dc8ba4dd 478}
479
7b5556ef 480TList *AliFlowAnalysisWithMSP::ListHistograms()
481{
482 if( fHistList ) {
483 fHistList->SetOwner(kFALSE);
484 delete fHistList;
485 }
486 fHistList = new TList();
487 fHistList->SetOwner(kFALSE);
488
489 if(fCommonHist) fHistList->Add(fCommonHist); // Standard control histograms, if enabled
490
491 //Correlations
492 if(fQaComponents) fHistList->Add(fQaComponents); // Averages of Qa components per event for NUA
493 if(fQbComponents) fHistList->Add(fQbComponents); // Averages of Qb components per event for NUA
494 if(fQaQb) fHistList->Add(fQaQb); // Average of QaQb per event
495 if(fPtUComponents) fHistList->Add(fPtUComponents); // ux and uy per pt bin for NUA
496 if(fEtaUComponents) fHistList->Add(fEtaUComponents); // ux and uy per eta bin for NUA
497 if(fAllStatistics) fHistList->Add(fAllStatistics); // Correlations for uQa uQb and QaQb (integrated)
498 if(fPtStatistics) fHistList->Add(fPtStatistics); // Correlations for uQa uQb and QaQb per pt bin
499 if(fEtaStatistics) fHistList->Add(fEtaStatistics); // Correlations for uQa uQb and QaQb per eta bin
500
501 // Result histograms (if calculated)
502 if(fIntegratedFlow) fHistList->Add(fIntegratedFlow); // vn for POI and subevents
503 if(fDiffFlowPt) fHistList->Add(fDiffFlowPt); // vn as function of pt
504 if(fDiffFlowEta) fHistList->Add(fDiffFlowEta); // vn as function of eta
505 if(fFlags) fHistList->Add(fFlags); // Stores fHarmonic and fNUA
506
507 return fHistList;
508}
dc8ba4dd 509
510
511void AliFlowAnalysisWithMSP::Print(const Option_t *opt)const
512{
7b5556ef 513 if( opt ) std::cout << std::endl;
514
dc8ba4dd 515 std::cout << "****************************************************" << std::endl;
516 std::cout << " Integrated flow from Modified Scalar Product " << std::endl;
517 std::cout << " " << std::endl;
518
519 double vn=0;
520 double vnerror=0;
521
7b5556ef 522 std::cout << setprecision(4);
dc8ba4dd 523 Calculate(vn, vnerror, fAllStatistics, fPtUComponents, 0, 0);
7b5556ef 524 std::cout << "v" << fHarmonic << " for POI : " << setw(11) << vn << " +- " << setw(9) << vnerror << std::endl;
dc8ba4dd 525 Calculate(vn, vnerror, fAllStatistics, fPtUComponents, 0, 1);
7b5556ef 526 std::cout << "v" << fHarmonic << " for subevent A: " << setw(11) << vn << " +- " << setw(9) << vnerror << std::endl;
dc8ba4dd 527 Calculate(vn, vnerror, fAllStatistics, fPtUComponents, 0, 2);
7b5556ef 528 std::cout << "v" << fHarmonic << " for subevent B: " << setw(11) << vn << " +- " << setw(9) << vnerror << std::endl;
dc8ba4dd 529 std::cout << std::endl;
530
531 std::cout << "NUA terms: " << (fNUA?"(applied)":"(NOT applied)") << std::endl;
7b5556ef 532 std::cout << setprecision(3);
dc8ba4dd 533 const double ux=fPtUComponents->Average(0); // Average over all bins
534 const double eux=TMath::Sqrt(fPtUComponents->Variance(0));
535 std::cout << "<ux> " << setw(12) << ux << " +- " << setw(12) << eux << (TMath::Abs(ux)<2*eux?" NOT significant ":" ") << std::endl;
536 const double ux0eta=fEtaUComponents->Average(fEtaUComponents->FindBin(0.0),0);
537 const double eux0eta=TMath::Sqrt(fEtaUComponents->Variance(fEtaUComponents->FindBin(0.0),0));
538 std::cout << "<ux> eta=0 " << setw(12) << ux0eta << " +- " << setw(12) << eux0eta << (TMath::Abs(ux0eta)<2*eux0eta?" NOT significant":" ") << std::endl;
539 const double ux0pt=fPtUComponents->Average(fPtUComponents->FindBin(1.0),0);
540 const double eux0pt=TMath::Sqrt(fPtUComponents->Variance(fPtUComponents->FindBin(1.0),0));
541 std::cout << "<ux> pt=1 " << setw(12) << ux0pt << " +- " << setw(12) << eux0pt << (TMath::Abs(ux0pt)<2*eux0pt?" NOT significant":" ") << std::endl;
542
543 const double uy=fPtUComponents->Average(0); // Average over all bins
544 const double euy=TMath::Sqrt(fPtUComponents->Variance(0));
545 std::cout << "<uy> " << setw(12) << uy << " +- " << setw(12) << euy << (TMath::Abs(uy)<2*euy?" NOT significant ":" ") << std::endl;;
546 const double uy0eta=fEtaUComponents->Average(fEtaUComponents->FindBin(0.0),1);
547 const double euy0eta=TMath::Sqrt(fEtaUComponents->Variance(fEtaUComponents->FindBin(0.0),1));
548 std::cout << "<uy> eta=0 " << setw(12) << uy0eta << " +- " << setw(12) << euy0eta << (TMath::Abs(uy0eta)<2*euy0eta?" NOT significant ":" ") << std::endl;
549 const double uy0pt=fPtUComponents->Average(fPtUComponents->FindBin(1.0),1);
550 const double euy0pt=TMath::Sqrt(fPtUComponents->Variance(fPtUComponents->FindBin(1.0),1));
551 std::cout << "<uy> pt=1 " << setw(12) << uy0pt << " +- " << setw(12) << euy0pt << (TMath::Abs(uy0pt)<2*euy0pt?" NOT significant ":" ") << std::endl;
552
7b5556ef 553 const double ax=fQaComponents->Average(0);
554 const double eax=TMath::Sqrt(fQaComponents->Variance(0));
555 std::cout << "<QaX> " << setw(12) << ax << " +- " << setw(12) <<eax << (TMath::Abs(ax)<2*eax?" NOT significant ":" ") << std::endl;
556 const double ay=fQaComponents->Average(1);
557 const double eay=TMath::Sqrt(fQaComponents->Variance(1));
558 std::cout << "<QaY> " << setw(12) << ay << " +- " << setw(12) << eay << (TMath::Abs(ay)<2*eay?" NOT significant ":" ") << std::endl;
559 const double bx=fQbComponents->Average(0);
560 const double ebx=TMath::Sqrt(fQbComponents->Variance(0));
561 std::cout << "<QbX> " << setw(12) << bx << " +- " << setw(12) << ebx << (TMath::Abs(bx)<2*ebx?" NOT significant ":" ") << std::endl;
562 const double by=fQbComponents->Average(1);
563 const double eby=TMath::Sqrt(fQbComponents->Variance(1));
564 std::cout << "<QbY> " << setw(12) << by << " +- " << setw(12) << eby << (TMath::Abs(by)<2*eby?" NOT significant ":" ") << std::endl;
565 const double ab=fQaQb->Average(0);
566 const double eab=TMath::Sqrt(fQbComponents->Variance(0));
567 std::cout << "<QaQb> " << setw(12) << ab << " +- " << setw(12) << eab << (TMath::Abs(ab)<2*eab?" NOT significant ":" ") << std::endl;
dc8ba4dd 568 std::cout << std::endl;
569
570 std::cout << "Covariance matrix: " << std::endl;
571 std::cout << " " << setw(12) << "uQa" << setw(12) << "uQb" << setw(12) << "QaQb" << std::endl;
572 std::cout << "uQa " << setw(12) << fAllStatistics->Covariance(0,0) << std::endl;
573 std::cout << "uQb " << setw(12) << fAllStatistics->Covariance(1,0) << setw(12) << fAllStatistics->Covariance(1,1) << std::endl;
574 std::cout << "QaQb " << setw(12) << fAllStatistics->Covariance(2,0) << setw(12) << fAllStatistics->Covariance(2,1) << setw(12) << fQaQb->Variance(0) << std::endl;
575 std::cout << "****************************************************" << std::endl;
576 std::cout << std::endl;
577}
578
579
7b5556ef 580AliFlowAnalysisWithMSP &AliFlowAnalysisWithMSP::operator=(const AliFlowAnalysisWithMSP &x)
581{
582 SetNameTitle("MSP","Flow analysis with the Modified Scalar Product method");
583 delete fQaComponents; fQaComponents=0;
584 if( x.fQaComponents ) fQaComponents=(AliFlowMSPHistograms *)(x.fQaComponents)->Clone();
585 delete fQbComponents; fQbComponents=0;
586 if( x.fQbComponents ) fQbComponents=(AliFlowMSPHistograms *)(x.fQbComponents)->Clone();
587 delete fQaQb; fQaQb=0;
588 if( x.fQaQb ) fQaQb=(AliFlowMSPHistograms *)(x.fQaQb)->Clone();
589 delete fPtUComponents; fPtUComponents=0;
590 if( fPtUComponents) fPtUComponents=(AliFlowMSPHistograms *)(x.fPtUComponents)->Clone();
591 delete fEtaUComponents; fEtaUComponents=0;
592 if( fEtaUComponents ) fEtaUComponents=(AliFlowMSPHistograms *)(x.fEtaUComponents)->Clone();
593 delete fAllStatistics; fAllStatistics=0;
594 if( fAllStatistics ) fAllStatistics=(AliFlowMSPHistograms *)(x.fAllStatistics)->Clone();
595 delete fPtStatistics; fPtStatistics=0;
596 if( fPtStatistics ) fPtStatistics=(AliFlowMSPHistograms *)(x.fPtStatistics)->Clone();
597 delete fEtaStatistics; fEtaStatistics=0;
598 if( fEtaStatistics ) fEtaStatistics=(AliFlowMSPHistograms *)(x.fEtaStatistics)->Clone();
599 delete fIntegratedFlow; fIntegratedFlow=0;
600 if( fIntegratedFlow ) fIntegratedFlow=(TH1D *)(x.fIntegratedFlow)->Clone();
601 delete fDiffFlowPt; fDiffFlowPt=0;
602 if( fDiffFlowPt ) fDiffFlowPt=(TH1D *)(x.fDiffFlowPt)->Clone();
603 delete fDiffFlowEta; fDiffFlowEta=0;
604 if( fDiffFlowEta ) fDiffFlowEta=(TH1D *)(x.fDiffFlowEta)->Clone();
605 delete fFlags; fFlags=0;
606 if( fFlags ) fFlags=(TProfile *)(x.fFlags)->Clone();
607 delete fCommonHist; fCommonHist=0;
608 if( fCommonHist ) fCommonHist=new AliFlowCommonHist(*(x.fCommonHist));
609 return *this;
610}
611
dc8ba4dd 612// private functions --------------------------------------------------------------------------------------
613bool AliFlowAnalysisWithMSP::Calculate(double &vn, double &vnerror, const AliFlowMSPHistograms *hist, const AliFlowMSPHistograms *components, const int bin, const int poi) const
614{
615 // Get all averages and correlations need for the flow calculation
616 double uQa=hist->Average(bin,0); // <<uQa>>
617 double VuQa=hist->Variance(bin,0); // Var(<<uQa>>)
618 double uQb=hist->Average(bin,1); // <<uQb>>
619 double VuQb=hist->Variance(bin,1); // Var(<<uQb>>)
7b5556ef 620 double QaQb=fQaQb->Average(1,0); // <QaQb> Should not be taken from hist(bin) because there QaQb is entered multiple times: <<QaQb>>!!
dc8ba4dd 621 double VQaQb=fQaQb->Variance(1,0); // V(<QaQb>)
622 double CuQauQb=hist->Covariance(bin,0,1); // Cov(<<uQa>>,<<uQb>>)
623 double CuQaQaQb=hist->Covariance(bin,0,2); // Cov(<<uQa>>,<QaQb>)
624 double CuQbQaQb=hist->Covariance(bin,1,2); // Cov(<<uQb>>,<QaQb>)
625
626 if( fNUA && components ) {
627 // Apply NUA correction to QaQb.
628 double QaX=fQaComponents->Average(0);
629 double QaY=fQaComponents->Average(1);
630 double QbX=fQbComponents->Average(0);
631 double QbY=fQbComponents->Average(1);
632
633 QaQb=QaQb-QaX*QbX-QaY*QbY;
634
635 // Apply NUA to uQa and uQb (per bin)
636 double uX=components->Average(bin,0); // bin 0 is integrated over all bins
637 double uY=components->Average(bin,1);
638
639 uQa = uQa - uX*QaX - uY*QaY;
640 uQb = uQb - uX*QbX - uY*QbY;
641 // Error calculation not fully modified: only above terms, the spread in <<u>> and <Qa> and <Qb> are not used
642 // therefore this should only be applied if significant!
7b5556ef 643 // Check if not fully NUA correcting the error calculation is justified (but this is compatible with the original SP method)!
644 // In general it is not justified but this can only be checked by splitting the event sample in many subsamples and looking at
645 // the variance of the result. This may not be feasible if statistics is low
dc8ba4dd 646 }
647
648 // Some sanity checks:
7b5556ef 649 if( uQa*uQb*QaQb <= 0 ) { // Catch imaginary results
dc8ba4dd 650 vn=-99;
651 vnerror=-99;
652 return false;
653 }
654
7b5556ef 655 // Sanity checks passed, calculate, print and store
dc8ba4dd 656 switch (poi) {
657 case 1: // Subevent A reference flow
658 {
659 if( TMath::Abs(uQb) < 1e-30*TMath::Abs(uQa*QaQb) ) { // Protect against infinity
660 vn=0;
661 vnerror=-1;
662 return false;
663 }
7b5556ef 664 double vnA = TMath::Sqrt( uQa*QaQb / uQb ); // vn
665 double VvnA = QaQb*VuQa/(4*uQa*uQb) // Variance of vn
dc8ba4dd 666 + uQa*VQaQb/(4*QaQb*uQb)
667 + uQa*QaQb*VuQb/(4*TMath::Power(uQb,3))
668 + CuQaQaQb/(2*uQb)
669 - QaQb*CuQauQb/(2*TMath::Power(uQb,2))
670 - uQa*CuQbQaQb/(2*TMath::Power(uQb,2));
7b5556ef 671 vn=vnA;
672 if( VvnA<0 ) {
673 vnerror=VvnA;
dc8ba4dd 674 return false;
675 }
7b5556ef 676 vnerror=TMath::Sqrt(VvnA);
dc8ba4dd 677 }
678 break;
679 case 2: // Subevent B reference flow
680 {
681 if( TMath::Abs(uQa) < 1e-30*TMath::Abs(uQb*QaQb) ) { // Protect against infinity
682 vn=0;
683 vnerror=-1;
684 return false;
685 }
7b5556ef 686 double vnB = TMath::Sqrt( uQb*QaQb / uQa ); // vn
687 double VvnB = uQb*VQaQb/(4*QaQb*uQa) // Variance of vn
dc8ba4dd 688 + QaQb*VuQb/(4*uQb*uQa)
689 + QaQb*uQb*VuQa/(4*TMath::Power(uQa,3))
690 + CuQbQaQb/(2*uQa)
691 - uQb*CuQaQaQb/(2*TMath::Power(uQa,2))
7b5556ef 692 - QaQb*CuQauQb/(2*TMath::Power(uQa,2));
693 vn=vnB;
694 if( VvnB<0 ) {
695 vnerror=VvnB;
dc8ba4dd 696 return false;
697 }
7b5556ef 698 vnerror=TMath::Sqrt(VvnB);
dc8ba4dd 699 }
700 break;
701 default: // POI flow
702 {
703 if( TMath::Abs(QaQb) < 1e-30*TMath::Abs(uQa*uQb) ) { // Catch infinity
704 vn=0;
705 vnerror=-1;
706 return false;
707 }
708 double vnP = TMath::Sqrt( uQa*uQb / QaQb ); // vn
709 if( TMath::Abs(uQa*QaQb) < 1e-30*TMath::Abs(uQb*VuQa)
710 || TMath::Abs(uQb*QaQb) < 1e-30*TMath::Abs(uQa*VuQb)
711 || TMath::Abs(QaQb) < 1e-30*TMath::Abs(uQa*uQb*VQaQb)
712 || TMath::Abs(QaQb) < 1e-30*TMath::Abs(CuQauQb)
713 || TMath::Abs(QaQb) < 1e-30*TMath::Abs(uQb*CuQaQaQb)
714 || TMath::Abs(QaQb) < 1e-30*TMath::Abs(uQa*CuQbQaQb)
715 ){
716 vnerror=-98;
717 return false;
718 }
719 double VvnP = uQb*VuQa/(4*uQa*QaQb) // Variance of vn
720 + uQa*VuQb/(4*uQb*QaQb)
721 + uQa*uQb*VQaQb/(4*TMath::Power(QaQb,3))
722 + CuQauQb/(2*QaQb)
723 - uQb*CuQaQaQb/(2*TMath::Power(QaQb,2))
724 - uQa*CuQbQaQb/(2*TMath::Power(QaQb,2));
7b5556ef 725 vn=TMath::Sign(vnP,uQb);
dc8ba4dd 726 if( VvnP<0 ) {
727 vnerror=VvnP;
728 return false;
729 }
730 vnerror=TMath::Sqrt(VvnP);
731 }
732 } // Switch between POI and subevents
733
734 return (vnerror>=0);
735}
736
7b5556ef 737void AliFlowAnalysisWithMSP::ReadHistograms(TDirectory *file)
dc8ba4dd 738{
739 delete fCommonHist; fCommonHist=0; // Delete existing histograms
740 delete fQaComponents; fQaComponents=0;
741 delete fQbComponents; fQbComponents=0;
742 delete fQaQb; fQaQb=0;
743 delete fPtUComponents; fPtUComponents=0;
744 delete fEtaUComponents; fEtaUComponents=0;
745 delete fAllStatistics; fAllStatistics=0;
746 delete fPtStatistics; fPtStatistics=0;
747 delete fEtaStatistics; fEtaStatistics=0;
748 delete fIntegratedFlow; fIntegratedFlow=0;
749 delete fDiffFlowPt; fDiffFlowPt=0;
750 delete fDiffFlowEta; fDiffFlowEta=0;
751 delete fFlags; fFlags=0;
7b5556ef 752 if( fHistList ) {
753 fHistList->SetOwner(kFALSE);
754 delete fHistList;
755 fHistList=0;
756 }
dc8ba4dd 757
758 file->GetObject("QaComponents",fQaComponents);
759 file->GetObject("QbComponents",fQbComponents);
760 file->GetObject("QaQb",fQaQb);
761 file->GetObject("PtUComponents",fPtUComponents);
762 file->GetObject("EtaUComponents",fEtaUComponents);
763 file->GetObject("AllStatistics",fAllStatistics);
764 file->GetObject("PtStatistics",fPtStatistics);
765 file->GetObject("EtaStatistics",fEtaStatistics);
766 if( !fQaComponents || !fQbComponents || !fQaQb || !fPtUComponents || !fEtaUComponents || !fAllStatistics || !fPtStatistics || !fEtaStatistics ) {
767 std::cerr << "AliFlowAnalysisWithMSP::ReadHistograms() : One or more histograms were not read correctly from " << file->GetPath() << std::endl;
768 }
769
7b5556ef 770 file->GetObject("Flags",fFlags); // Flags are required
771
772 if( !fFlags ){
773 std::cerr << "AliFlowAnalysisWithMSP::ReadHistograms(TDirectoryFile *) : Flags histogram not found, using defaults" << std::endl;
774 fHarmonic=2;
775 fNUA=false;
776 }else{
777 fHarmonic=(UInt_t)(fFlags->GetBinContent(1));
778 double harmonicSpread=fFlags->GetBinError(1);
779 if( harmonicSpread!=0 ) {
780 std::cerr << "AliFlowAnalysisWithMSP::ReadHistograms(TDirectoryFile *) :These histograms seem to be merged from analysis with different Harmonics. Results removed!" << std::endl;
781 delete fIntegratedFlow; fIntegratedFlow=0;
782 delete fDiffFlowPt; fDiffFlowPt=0;
783 delete fDiffFlowEta; fDiffFlowEta=0;
784 }
785 fNUA=fFlags->GetBinContent(2); // Mixing NUA does not matter since it needs to be recalculated anyway
786 double nuaSpread=fFlags->GetBinError(2);
787 if( nuaSpread!=0 ) {
788 std::cerr << "AliFlowAnalysisWithMSP::ReadHistograms(TDirectoryFile *) :These histograms seem to be merged from analysis with different NUA corrections. Results removed" << std::endl;
789 delete fIntegratedFlow; fIntegratedFlow=0;
790 delete fDiffFlowPt; fDiffFlowPt=0;
791 delete fDiffFlowEta; fDiffFlowEta=0;
792 }
793 }
794
dc8ba4dd 795 // Optional histograms, may return a zero pointer
7b5556ef 796 file->GetObject("AliFlowCommonHist_MSP",fCommonHist); // The AliFlowCommonHist is optional
797 file->GetObject("IntegratedFlow",fIntegratedFlow); // Results are optional
dc8ba4dd 798 file->GetObject("DiffFlowPt",fDiffFlowPt);
799 file->GetObject("DiffFlowEta",fDiffFlowEta);
800
7b5556ef 801 fBookCommonHistograms=(fCommonHist!=0);
802}
803
804
805void AliFlowAnalysisWithMSP::ReadHistograms(TList *list)
806{
807 if( !list ) return;
808 delete fCommonHist; fCommonHist=0; // Delete existing histograms if any
809 delete fQaComponents; fQaComponents=0;
810 delete fQbComponents; fQbComponents=0;
811 delete fQaQb; fQaQb=0;
812 delete fPtUComponents; fPtUComponents=0;
813 delete fEtaUComponents; fEtaUComponents=0;
814 delete fAllStatistics; fAllStatistics=0;
815 delete fPtStatistics; fPtStatistics=0;
816 delete fEtaStatistics; fEtaStatistics=0;
817 delete fIntegratedFlow; fIntegratedFlow=0;
818 delete fDiffFlowPt; fDiffFlowPt=0;
819 delete fDiffFlowEta; fDiffFlowEta=0;
820 delete fFlags; fFlags=0;
821 if( fHistList ) {
822 fHistList->SetOwner(kFALSE);
823 delete fHistList;
824 fHistList=0;
825 }
826
827 fQaComponents = static_cast<AliFlowMSPHistograms *>(list->FindObject("QaComponents"));
828 fQbComponents = static_cast<AliFlowMSPHistograms *>(list->FindObject("QbComponents"));
829 fQaQb = static_cast<AliFlowMSPHistograms *>(list->FindObject("QaQb"));
830 fPtUComponents = static_cast<AliFlowMSPHistograms *>(list->FindObject("PtUComponents"));
831 fEtaUComponents = static_cast<AliFlowMSPHistograms *>(list->FindObject("EtaUComponents"));
832 fAllStatistics = static_cast<AliFlowMSPHistograms *>(list->FindObject("AllStatistics"));
833 fPtStatistics = static_cast<AliFlowMSPHistograms *>(list->FindObject("PtStatistics"));
834 fEtaStatistics = static_cast<AliFlowMSPHistograms *>(list->FindObject("EtaStatistics"));
835 if( !fQaComponents || !fQbComponents || !fQaQb || !fPtUComponents || !fEtaUComponents || !fAllStatistics || !fPtStatistics || !fEtaStatistics ) {
836 std::cerr << "AliFlowAnalysisWithMSP::ReadHistograms(Tlist *) : One or more histograms were not read correctly from TList" << std::endl;
837 }
838
839 fFlags = static_cast<TProfile *>(list->FindObject("Flags")); // Flags are required
dc8ba4dd 840
841 if( !fFlags ){
7b5556ef 842 std::cerr << "AliFlowAnalysisWithMSP::ReadHistograms(TList *) : Flags histogram not found, using defaults" << std::endl;
dc8ba4dd 843 fHarmonic=2;
844 fNUA=false;
845 }else{
7b5556ef 846 fHarmonic=(UInt_t)(fFlags->GetBinContent(1));
dc8ba4dd 847 double harmonicSpread=fFlags->GetBinError(1);
848 if( harmonicSpread!=0 ) {
7b5556ef 849 std::cerr << "These histograms seem to be merged from analysis with different Harmonics. Results removed!" << std::endl;
dc8ba4dd 850 delete fIntegratedFlow; fIntegratedFlow=0;
851 delete fDiffFlowPt; fDiffFlowPt=0;
852 delete fDiffFlowEta; fDiffFlowEta=0;
853 }
854 fNUA=fFlags->GetBinContent(2); // Mixing NUA does not matter since it needs to be recalculated anyway
855 double nuaSpread=fFlags->GetBinError(2);
856 if( nuaSpread!=0 ) {
857 std::cerr << "These histograms seem to be merged from analysis with different NUA corrections. Results removed" << std::endl;
858 delete fIntegratedFlow; fIntegratedFlow=0;
859 delete fDiffFlowPt; fDiffFlowPt=0;
860 delete fDiffFlowEta; fDiffFlowEta=0;
861 }
862 }
7b5556ef 863
864 // Optional histograms, may return a zero pointer
865 fCommonHist = static_cast<AliFlowCommonHist *>(list->FindObject("AliFlowCommonHist_MSP")); // The AliFlowCommonHist is optional
866 fIntegratedFlow = static_cast<TH1D *>(list->FindObject("IntegratedFlow")); // Results are optional
867 fDiffFlowPt = static_cast<TH1D *>(list->FindObject("DiffFlowPt"));
868 fDiffFlowEta = static_cast<TH1D *>(list->FindObject("DiffFlowEta"));
869
dc8ba4dd 870 fBookCommonHistograms=(fCommonHist!=0);
7b5556ef 871}