1 /*************************************************************************
2 * Copyright(c) 1998-2008, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 #define ALIFLOWANALYSISWITHSCALARPRODUCT_CXX
28 #include "AliFlowCommonConstants.h"
29 #include "AliFlowEventSimple.h"
30 #include "AliFlowVector.h"
31 #include "AliFlowTrackSimple.h"
32 #include "AliFlowCommonHist.h"
33 #include "AliFlowCommonHistResults.h"
34 #include "AliFlowAnalysisWithScalarProduct.h"
36 //////////////////////////////////////////////////////////////////////////////
37 // AliFlowAnalysisWithScalarProduct:
38 // Description: Maker to analyze Flow from the Scalar Product method.
39 // authors: Naomi van del Kolk (kolk@nikhef.nl)
40 // Ante Bilandzic (anteb@nikhef.nl)
41 // mods: Carlos Perez (cperez@nikhef.nl)
42 //////////////////////////////////////////////////////////////////////////////
44 ClassImp(AliFlowAnalysisWithScalarProduct)
46 //-----------------------------------------------------------------------
47 AliFlowAnalysisWithScalarProduct::AliFlowAnalysisWithScalarProduct():
50 fApplyCorrectionForNUA(0),
52 fNormalizationType(1),
57 fHistProQaQbNorm(NULL),
58 fHistSumOfWeights(NULL),
64 fHistQNormQaQbNorm(NULL),
75 for(int i=0; i!=2; ++i) {
76 fPhiWeightsSub[i] = NULL;
77 for(int j=0; j!=2; ++j) {
78 fHistProUQ[i][j] = NULL;
79 fHistProUQQaQb[i][j] = NULL;
80 fHistProNUAu[i][j][0] = NULL;
81 fHistProNUAu[i][j][1] = NULL;
82 for(int k=0; k!=3; ++k)
83 fHistSumOfWeightsu[i][j][k] = NULL;
87 //-----------------------------------------------------------------------
88 AliFlowAnalysisWithScalarProduct::~AliFlowAnalysisWithScalarProduct()
94 //-----------------------------------------------------------------------
95 void AliFlowAnalysisWithScalarProduct::Init() {
96 //Define all histograms
97 printf("---Analysis with the Scalar Product Method--- Init\n");
98 printf("--- fNormalizationType %d ---\n", fNormalizationType);
99 //save old value and prevent histograms from being added to directory
100 //to avoid name clashes in case multiple analaysis objects are used
102 Bool_t oldHistAddStatus = TH1::AddDirectoryStatus();
103 TH1::AddDirectory(kFALSE);
105 fHistList = new TList();
106 fHistList->SetName("cobjSP");
107 fHistList->SetOwner();
109 TList *uQRelated = new TList();
110 uQRelated->SetName("uQ");
111 uQRelated->SetOwner();
113 TList *nuaRelated = new TList();
114 nuaRelated->SetName("NUA");
115 nuaRelated->SetOwner();
117 TList *errorRelated = new TList();
118 errorRelated->SetName("error");
119 errorRelated->SetOwner();
121 TList *tQARelated = new TList();
122 tQARelated->SetName("QA");
123 tQARelated->SetOwner();
125 fCommonHists = new AliFlowCommonHist("AliFlowCommonHist_SP");
126 (fCommonHists->GetHarmonic())->Fill(0.5,fHarmonic); // store harmonic
127 fHistList->Add(fCommonHists);
129 fCommonHistsuQ = new AliFlowCommonHist("AliFlowCommonHist_uQ");
130 (fCommonHistsuQ->GetHarmonic())->Fill(0.5,fHarmonic); // store harmonic
131 fHistList->Add(fCommonHistsuQ);
133 fCommonHistsRes = new AliFlowCommonHistResults("AliFlowCommonHistResults_SP","",fHarmonic);
134 fHistList->Add(fCommonHistsRes);
136 fHistProConfig = new TProfile("FlowPro_Flags_SP","Flow_Flags_SP",4,0.5,4.5,"s");
137 fHistProConfig->GetXaxis()->SetBinLabel(1,"fApplyCorrectionForNUA");
138 fHistProConfig->GetXaxis()->SetBinLabel(2,"fNormalizationType");
139 fHistProConfig->GetXaxis()->SetBinLabel(3,"fUsePhiWeights");
140 fHistProConfig->GetXaxis()->SetBinLabel(4,"fHarmonic");
141 fHistProConfig->Fill(1,fApplyCorrectionForNUA);
142 fHistProConfig->Fill(2,fNormalizationType);
143 fHistProConfig->Fill(3,fUsePhiWeights);
144 fHistProConfig->Fill(4,fHarmonic);
145 fHistList->Add(fHistProConfig);
147 fHistProQaQbNorm = new TProfile("FlowPro_QaQbNorm_SP","FlowPro_QaQbNorm_SP", 1, 0.5, 1.5,"s");
148 fHistProQaQbNorm->SetYTitle("<QaQb/Na/Nb>");
149 errorRelated->Add(fHistProQaQbNorm);
151 fHistProNUAq = new TProfile("FlowPro_NUAq_SP","FlowPro_NUAq_SP", 6, 0.5, 6.5,"s");
152 fHistProNUAq->GetXaxis()->SetBinLabel( 1,"<<sin(#Phi_{a})>>");
153 fHistProNUAq->GetXaxis()->SetBinLabel( 2,"<<cos(#Phi_{a})>>");
154 fHistProNUAq->GetXaxis()->SetBinLabel( 3,"<<sin(#Phi_{b})>>");
155 fHistProNUAq->GetXaxis()->SetBinLabel( 4,"<<cos(#Phi_{b})>>");
156 fHistProNUAq->GetXaxis()->SetBinLabel( 5,"<<sin(#Phi_{t})>>");
157 fHistProNUAq->GetXaxis()->SetBinLabel( 6,"<<cos(#Phi_{t})>>");
158 nuaRelated->Add(fHistProNUAq);
160 fHistSumOfWeights = new TH1D("Flow_SumOfWeights_SP","Flow_SumOfWeights_SP",2,0.5, 2.5);
161 fHistSumOfWeights->GetXaxis()->SetBinLabel( 1,"#Sigma Na*Nb");
162 fHistSumOfWeights->GetXaxis()->SetBinLabel( 2,"#Sigma (Na*Nb)^2");
163 errorRelated->Add(fHistSumOfWeights);
165 TString sPOI[2] = {"RP","POI"}; // backward compatibility
166 TString sEta[2] = {"Pt","eta"}; // backward compatibility
167 TString sTitle[2] = {"p_{T} [GeV]","#eta"};
168 TString sWeights[3] = {"uQ","uQuQ","uQQaQb"};
170 Double_t dMin[2], dMax[2];
171 iNbins[0] = AliFlowCommonConstants::GetMaster()->GetNbinsPt();
172 iNbins[1] = AliFlowCommonConstants::GetMaster()->GetNbinsEta();
173 dMin[0] = AliFlowCommonConstants::GetMaster()->GetPtMin();
174 dMin[1] = AliFlowCommonConstants::GetMaster()->GetEtaMin();
175 dMax[0] = AliFlowCommonConstants::GetMaster()->GetPtMax();
176 dMax[1] = AliFlowCommonConstants::GetMaster()->GetEtaMax();
177 for(Int_t iPOI=0; iPOI!=2; ++iPOI) for(Int_t iSpace=0; iSpace!=2; ++iSpace) {
179 fHistProUQ[iPOI][iSpace] = new TProfile( Form( "FlowPro_UQ_%s%s_SP", sEta[iSpace].Data(), sPOI[iPOI].Data() ),
180 Form( "FlowPro_UQ%s%s_SP", sEta[iSpace].Data(), sPOI[iPOI].Data() ),
181 iNbins[iSpace], dMin[iSpace], dMax[iSpace], "s");
182 fHistProUQ[iPOI][iSpace]->SetXTitle(sTitle[iSpace].Data());
183 fHistProUQ[iPOI][iSpace]->SetYTitle("<uQ>");
184 uQRelated->Add(fHistProUQ[iPOI][iSpace]);
187 fHistProNUAu[iPOI][iSpace][0] = new TProfile( Form("FlowPro_NUAu_%s%s_IM_SP", sEta[iSpace].Data(), sPOI[iPOI].Data() ),
188 Form("FlowPro_NUAu_%s%s_IM_SP", sEta[iSpace].Data(), sPOI[iPOI].Data() ),
189 iNbins[iSpace], dMin[iSpace], dMax[iSpace]);
190 fHistProNUAu[iPOI][iSpace][0]->SetXTitle(sTitle[iSpace].Data());
191 nuaRelated->Add(fHistProNUAu[iPOI][iSpace][0]);
192 fHistProNUAu[iPOI][iSpace][1] = new TProfile( Form("FlowPro_NUAu_%s%s_RE_SP", sEta[iSpace].Data(), sPOI[iPOI].Data() ),
193 Form("FlowPro_NUAu_%s%s_RE_SP", sEta[iSpace].Data(), sPOI[iPOI].Data() ),
194 iNbins[iSpace], dMin[iSpace], dMax[iSpace]);
195 fHistProNUAu[iPOI][iSpace][1]->SetXTitle(sTitle[iSpace].Data());
196 nuaRelated->Add(fHistProNUAu[iPOI][iSpace][1]);
199 fHistProUQQaQb[iPOI][iSpace] = new TProfile( Form("FlowPro_UQQaQb_%s%s_SP", sEta[iSpace].Data(), sPOI[iPOI].Data() ),
200 Form("FlowPro_UQQaQb_%s%s_SP", sEta[iSpace].Data(), sPOI[iPOI].Data() ),
201 iNbins[iSpace], dMin[iSpace], dMax[iSpace]);
202 fHistProUQQaQb[iPOI][iSpace]->SetXTitle(sTitle[iSpace].Data());
203 fHistProUQQaQb[iPOI][iSpace]-> SetYTitle("<Qu QaQb>");
204 errorRelated->Add(fHistProUQQaQb[iPOI][iSpace]);
207 for(Int_t i=0; i!=3; ++i) {
208 fHistSumOfWeightsu[iPOI][iSpace][i] = new TH1D( Form("Flow_SumOfWeights_%s%s_%s_SP",sWeights[i].Data(),sPOI[iPOI].Data(),sEta[iSpace].Data()),
209 Form("Flow_SumOfWeights_%s%s_%s_SP",sWeights[i].Data(),sPOI[iPOI].Data(),sEta[iSpace].Data()),
210 iNbins[iSpace], dMin[iSpace], dMax[iSpace]);
211 fHistSumOfWeightsu[iPOI][iSpace][i]->SetYTitle(sWeights[i].Data());
212 fHistSumOfWeightsu[iPOI][iSpace][i]->SetXTitle(sTitle[iSpace].Data());
213 errorRelated->Add(fHistSumOfWeightsu[iPOI][iSpace][i]);
219 printf( "WARNING: fWeightsList is NULL in the Scalar Product method.\n" );
222 fPhiWeightsSub[0] = dynamic_cast<TH1F*>
223 (fWeightsList->FindObject("phi_weights_sub0"));
224 if(!fPhiWeightsSub[0]) {
225 printf( "WARNING: phi_weights_sub0 not found in the Scalar Product method.\n" );
228 nuaRelated->Add( fPhiWeightsSub[0] );
229 fPhiWeightsSub[1] = dynamic_cast<TH1F*>
230 (fWeightsList->FindObject("phi_weights_sub1"));
231 if(!fPhiWeightsSub[1]) {
232 printf( "WARNING: phi_weights_sub1 not found in the Scalar Product method.\n" );
235 nuaRelated->Add( fPhiWeightsSub[1] );
239 fHistProQNorm = new TProfile("FlowPro_QNorm_SP","FlowPro_QNorm_SP", 1,0.5,1.5,"s");
240 fHistProQNorm->SetYTitle("<|Qa+Qb|>");
241 tQARelated->Add(fHistProQNorm);
243 fHistProQaQb = new TProfile("FlowPro_QaQb_SP","FlowPro_QaQb_SP", 1,0.5,1.5,"s");
244 fHistProQaQb->SetYTitle("<QaQb>");
245 tQARelated->Add(fHistProQaQb);
247 fHistProQaQbM = new TProfile("FlowPro_QaQbvsM_SP","FlowPro_QaQbvsM_SP",1000,0.0,10000);
248 fHistProQaQbM->SetYTitle("<QaQb>");
249 fHistProQaQbM->SetXTitle("M");
250 fHistProQaQbM->Sumw2();
251 tQARelated->Add(fHistProQaQbM);
253 fHistMaMb = new TH2D("Flow_MavsMb_SP","Flow_MavsMb_SP",100,0.,100.,100,0.,100.);
254 fHistMaMb->SetYTitle("Ma");
255 fHistMaMb->SetXTitle("Mb");
256 tQARelated->Add(fHistMaMb);
258 fHistQNormQaQbNorm = new TH2D("Flow_QNormvsQaQbNorm_SP","Flow_QNormvsQaQbNorm_SP",88,-1.1,1.1,22,0.,1.1);
259 fHistQNormQaQbNorm->SetYTitle("|Q/Mq|");
260 fHistQNormQaQbNorm->SetXTitle("QaQb/MaMb");
261 tQARelated->Add(fHistQNormQaQbNorm);
263 fHistQaNormMa = new TH2D("Flow_QaNormvsMa_SP","Flow_QaNormvsMa_SP",100,0.,100.,22,0.,1.1);
264 fHistQaNormMa->SetYTitle("|Qa/Ma|");
265 fHistQaNormMa->SetXTitle("Ma");
266 tQARelated->Add(fHistQaNormMa);
268 fHistQbNormMb = new TH2D("Flow_QbNormvsMb_SP","Flow_QbNormvsMb_SP",100,0.,100.,22,0.,1.1);
269 fHistQbNormMb->SetYTitle("|Qb/Mb|");
270 fHistQbNormMb->SetXTitle("Mb");
271 tQARelated->Add(fHistQbNormMb);
273 fResolution = new TH1D("Flow_resolution_SP","Flow_resolution_SP",100,-1.0,1.0);
274 fResolution->SetYTitle("dN/d(Cos2(#phi_a - #phi_b))");
275 fResolution->SetXTitle("Cos2(#phi_a - #phi_b)");
276 tQARelated->Add(fResolution);
278 fHistQaQb = new TH1D("Flow_QaQb_SP","Flow_QaQb_SP",200,-100.,100.);
279 fHistQaQb->SetYTitle("dN/dQaQb");
280 fHistQaQb->SetXTitle("dQaQb");
281 tQARelated->Add(fHistQaQb);
283 fHistQaQbCos = new TH1D("Flow_QaQbCos_SP","Flow_QaQbCos_SP",63,0.,TMath::Pi());
284 fHistQaQbCos->SetYTitle("dN/d#phi");
285 fHistQaQbCos->SetXTitle("#phi");
286 tQARelated->Add(fHistQaQbCos);
288 fHistList->Add(uQRelated);
289 fHistList->Add(nuaRelated);
290 fHistList->Add(errorRelated);
291 fHistList->Add(tQARelated);
293 TH1::AddDirectory(oldHistAddStatus);
296 //-----------------------------------------------------------------------
297 void AliFlowAnalysisWithScalarProduct::Make(AliFlowEventSimple* anEvent) {
298 // Scalar Product method
299 if (!anEvent) return; // for coverity
301 // Get Q vectors for the subevents
302 AliFlowVector* vQarray = new AliFlowVector[2];
304 anEvent->Get2Qsub(vQarray,fHarmonic,fWeightsList,kTRUE);
306 anEvent->Get2Qsub(vQarray,fHarmonic);
308 AliFlowVector vQa = vQarray[0];
310 AliFlowVector vQb = vQarray[1];
313 Double_t dMa = vQa.GetMult();
314 if( dMa < 2 ) return;
315 Double_t dMb = vQb.GetMult();
316 if( dMb < 2 ) return;
317 //fill control histograms
318 if (fUsePhiWeights) {
319 fCommonHists->FillControlHistograms(anEvent,fWeightsList,kTRUE);
321 fCommonHists->FillControlHistograms(anEvent);
324 //Normalizing: weight the Q vectors for the subevents
325 Double_t dNa = fNormalizationType ? dMa: vQa.Mod(); // SP corresponds to true
326 Double_t dNb = fNormalizationType ? dMb: vQb.Mod(); // SP corresponds to true
327 Double_t dWa = fNormalizationType ? dMa: 1; // SP corresponds to true
328 Double_t dWb = fNormalizationType ? dMb: 1; // SP corresponds to true
330 //Scalar product of the two subevents vectors
331 Double_t dQaQb = (vQa*vQb);
333 //printf("==============\n");
334 //printf("vQa: { %f, %f }\n",vQa.X(),vQa.Y());
335 //printf("QaQb/|Qa||Qb|: %f\n",dQaQb/vQa.Mod()/vQb.Mod());
336 //printf("QaQb/|Ma||Mb|: %f\n",dQaQb/dMa/dMb);
338 // 01 10 11 <=== fTotalQVector
339 // Q ?= Qa or Qb or QaQb
343 if( (fTotalQvector%2)>0 ) { // 01 or 11
347 if( fTotalQvector>1 ) { // 10 or 11
351 Double_t dWq = fNormalizationType ? dNq: 1; // SP corresponds to true
352 dNq = fNormalizationType ? dNq: vQm.Mod(); // SP corresponds to true
354 //fill some EP control histograms
355 fHistProQaQbNorm->Fill(1.,dQaQb/dNa/dNb,dWa*dWb); //Fill (QaQb/NaNb) with weight (WaWb).
356 //needed for the error calculation:
357 fHistSumOfWeights -> Fill(1.,dWa*dWb);
358 fHistSumOfWeights -> Fill(2.,pow(dWa*dWb,2.));
359 //needed for correcting non-uniform acceptance:
360 fHistProNUAq->Fill(1.,vQa.Y()/dNa,dWa); // to get <<sin(phi_a)>>
361 fHistProNUAq->Fill(2.,vQa.X()/dNa,dWa); // to get <<cos(phi_a)>>
362 fHistProNUAq->Fill(3.,vQb.Y()/dNb,dWb); // to get <<sin(phi_b)>>
363 fHistProNUAq->Fill(4.,vQb.X()/dNb,dWb); // to get <<cos(phi_b)>>
364 fHistProNUAq->Fill(5.,vQm.Y()/dNq,dWq);
365 fHistProNUAq->Fill(6.,vQm.X()/dNq,dWq);
367 //loop over the tracks of the event
368 AliFlowTrackSimple* pTrack = NULL;
369 Int_t iNumberOfTracks = anEvent->NumberOfTracks();
370 for (Int_t i=0;i<iNumberOfTracks;i++) {
371 pTrack = anEvent->GetTrack(i) ;
372 if (!pTrack) continue;
373 Double_t dPhi = pTrack->Phi();
374 Double_t dPt = pTrack->Pt();
375 Double_t dEta = pTrack->Eta();
379 Double_t dUX = TMath::Cos(fHarmonic*dPhi);
380 Double_t dUY = TMath::Sin(fHarmonic*dPhi);
383 // 01 10 11 <=== fTotalQVector
384 // Q ?= Qa or Qb or QaQb
385 vQm.Set(0.0,0.0); //start the loop fresh
387 if( (fTotalQvector%2)>0 ) { // 01 or 11
391 if( fTotalQvector>1 ) { // 10 or 11
396 //remove track if in subevent
397 for(Int_t inSubEvent=0; inSubEvent!=2; ++inSubEvent) {
398 if( !pTrack->InSubevent( inSubEvent ) )
401 if( (fTotalQvector%2)!=1 )
404 if( fTotalQvector>0 )
407 Double_t dPhiCenter = dPhi;
408 //if phi weights are used
409 if(fUsePhiWeights && fPhiWeightsSub[inSubEvent]) {
410 Int_t iNBinsPhiSub = fPhiWeightsSub[inSubEvent]->GetNbinsX();
411 Int_t phiBin = 1+(Int_t)(TMath::Floor(dPhi*iNBinsPhiSub/TMath::TwoPi()));
412 dW = fPhiWeightsSub[inSubEvent]->GetBinContent(phiBin);
413 dPhiCenter = fPhiWeightsSub[inSubEvent]->GetBinCenter(phiBin);
415 Double_t dQmX = vQm.X() - dW*(pTrack->Weight())* TMath::Cos(fHarmonic*dPhiCenter);
416 Double_t dQmY = vQm.Y() - dW*(pTrack->Weight())* TMath::Sin(fHarmonic*dPhiCenter);
418 dMq = dMq-dW*pTrack->Weight();
420 dNq = fNormalizationType ? dMq : vQm.Mod();
421 dWq = fNormalizationType ? dMq : 1;
423 //Filling QA (for compatibility with previous version)
424 fHistProQaQb->Fill(1,vQa*vQb,1);
425 fHistProQaQbM->Fill(anEvent->GetNumberOfRPs()+0.5,(vQa*vQb)/dMa/dMb,dMa*dMb);
426 fHistQaQbCos->Fill(TMath::ACos((vQa*vQb)/vQa.Mod()/vQb.Mod()));
427 fResolution->Fill( TMath::Cos( vQa.Phi()-vQb.Phi() ) );
428 fHistQaQb->Fill(vQa*vQb);
429 fHistMaMb->Fill(dMb,dMa);
430 fHistProQNorm->Fill(1,vQm.Mod()/dMq,dMq);
431 fHistQNormQaQbNorm->Fill((vQa*vQb)/dMa/dMb,vQm.Mod()/dMq);
432 fHistQaNormMa->Fill(dMa,vQa.Mod()/dMa);
433 fHistQbNormMb->Fill(dMb,vQb.Mod()/dMb);
435 Double_t dUQ = vU*vQm;
437 //fill the profile histograms
438 for(Int_t iPOI=0; iPOI!=2; ++iPOI) {
439 if( (iPOI==0)&&(!pTrack->InRPSelection()) )
441 if( (iPOI==1)&&(!pTrack->InPOISelection()) )
443 fHistProUQ[iPOI][0]->Fill(dPt ,dUQ/dNq,dWq); //Fill (uQ/Nq') with weight (Nq')
444 fHistProUQ[iPOI][1]->Fill(dEta,dUQ/dNq,dWq); //Fill (uQ/Nq') with weight (Nq')
445 //needed for the error calculation:
446 fHistProUQQaQb[iPOI][0]-> Fill(dPt ,dUQ/dNq*dQaQb/dNa/dNb,dWq*dWa*dWb); //Fill [Qu/Nq']*[QaQb/NaNb] with weight (Nq')NaNb
447 fHistProUQQaQb[iPOI][1]-> Fill(dEta,dUQ/dNq*dQaQb/dNa/dNb,dWq*dWa*dWb); //Fill [Qu/Nq']*[QaQb/NaNb] with weight (Nq')NaNb
448 fHistSumOfWeightsu[iPOI][0][0]->Fill(dPt ,dWq); // sum of Nq'
449 fHistSumOfWeightsu[iPOI][0][1]->Fill(dPt ,pow(dWq,2.));// sum of Nq'^2
450 fHistSumOfWeightsu[iPOI][0][2]->Fill(dPt ,dWq*dWa*dWb);// sum of Nq'*Na*Nb
451 fHistSumOfWeightsu[iPOI][1][0]->Fill(dEta,dWq); // sum of Nq'
452 fHistSumOfWeightsu[iPOI][1][1]->Fill(dEta,pow(dWq,2.));// sum of Nq'^2
453 fHistSumOfWeightsu[iPOI][1][2]->Fill(dEta,dNq*dWa*dWb);// sum of Nq'*Na*Nb
455 fHistProNUAu[iPOI][0][0]->Fill(dPt,dUY,1.); //sin u
456 fHistProNUAu[iPOI][0][1]->Fill(dPt,dUX,1.); //cos u
457 fHistProNUAu[iPOI][1][0]->Fill(dEta,dUY,1.); //sin u
458 fHistProNUAu[iPOI][1][1]->Fill(dEta,dUX,1.); //cos u
464 //--------------------------------------------------------------------
465 void AliFlowAnalysisWithScalarProduct::GetOutputHistograms(TList *outputListHistos){
466 //get pointers to all output histograms (called before Finish())
467 fHistList = outputListHistos;
469 fCommonHists = (AliFlowCommonHist*) fHistList->FindObject("AliFlowCommonHist_SP");
470 fCommonHistsuQ = (AliFlowCommonHist*) fHistList->FindObject("AliFlowCommonHist_uQ");
471 fCommonHistsRes = (AliFlowCommonHistResults*) fHistList->FindObject("AliFlowCommonHistResults_SP");
472 fHistProConfig = (TProfile*) fHistList->FindObject("FlowPro_Flags_SP");
473 if(!fHistProConfig) printf("Error loading fHistProConfig\n");
474 TList *uQ = (TList*) fHistList->FindObject("uQ");
475 TList *nua = (TList*) fHistList->FindObject("NUA");
476 TList *error = (TList*) fHistList->FindObject("error");
478 fHistProQaQbNorm = (TProfile*) error->FindObject("FlowPro_QaQbNorm_SP");
479 if(!fHistProQaQbNorm) printf("Error loading fHistProQaQbNorm\n");
480 fHistProNUAq = (TProfile*) nua->FindObject("FlowPro_NUAq_SP");
481 if(!fHistProNUAq) printf("Error loading fHistProNUAq\n");
482 fHistSumOfWeights = (TH1D*) error->FindObject("Flow_SumOfWeights_SP");
483 if(!fHistSumOfWeights) printf("Error loading fHistSumOfWeights\n");
485 TString sPOI[2] = {"RP","POI"};
486 TString sEta[2] = {"Pt","eta"};
487 TString sWeights[3] = {"uQ","uQuQ","uQQaQb"};
488 for(Int_t iPOI=0; iPOI!=2; ++iPOI) for(Int_t iSpace=0; iSpace!=2; ++iSpace) {
489 fHistProUQ[iPOI][iSpace] = (TProfile*) uQ->FindObject( Form( "FlowPro_UQ_%s%s_SP", sEta[iSpace].Data(), sPOI[iPOI].Data() ) );
490 if(!fHistProUQ[iPOI][iSpace]) printf("Error loading fHistProUQ[%d][%d]\n",iPOI,iSpace);
491 fHistProNUAu[iPOI][iSpace][0] = (TProfile*) nua->FindObject( Form("FlowPro_NUAu_%s%s_IM_SP", sEta[iSpace].Data(), sPOI[iPOI].Data() ) );
492 if(!fHistProNUAu[iPOI][iSpace][0]) printf("Error loading fHistProNUAu[%d][%d][0]\n",iPOI,iSpace);
493 fHistProNUAu[iPOI][iSpace][1] = (TProfile*) nua->FindObject( Form("FlowPro_NUAu_%s%s_RE_SP", sEta[iSpace].Data(), sPOI[iPOI].Data() ) );
494 if(!fHistProNUAu[iPOI][iSpace][1]) printf("Error loading fHistProNUAu[%d][%d][1]\n",iPOI,iSpace);
495 fHistProUQQaQb[iPOI][iSpace] = (TProfile*) error->FindObject( Form("FlowPro_UQQaQb_%s%s_SP", sEta[iSpace].Data(), sPOI[iPOI].Data() ) );
496 for(Int_t i=0; i!=3; ++i){
497 fHistSumOfWeightsu[iPOI][iSpace][i] = (TH1D*) error->FindObject( Form("Flow_SumOfWeights_%s%s_%s_SP",sWeights[i].Data(),sPOI[iPOI].Data(),sEta[iSpace].Data()) );
498 if(!fHistSumOfWeightsu[iPOI][iSpace][i]) printf("Error loading fHistSumOfWeightsu[%d][%d][%d]\n",iPOI,iSpace,i);
502 fApplyCorrectionForNUA = (Int_t) fHistProConfig->GetBinContent(1);
503 fNormalizationType = (Int_t) fHistProConfig->GetBinContent(2);
504 fUsePhiWeights = (Int_t) fHistProConfig->GetBinContent(3);
505 fHarmonic = (Int_t) fHistProConfig->GetBinContent(4);
509 //--------------------------------------------------------------------
510 void AliFlowAnalysisWithScalarProduct::Finish() {
511 //calculate flow and fill the AliFlowCommonHistResults
512 printf("AliFlowAnalysisWithScalarProduct::Finish()\n");
515 fApplyCorrectionForNUA = fHistProConfig->GetBinContent(1);
516 fNormalizationType = fHistProConfig->GetBinContent(2);
517 fHarmonic = fHistProConfig->GetBinContent(4);
519 printf("*************************************\n");
520 printf("*************************************\n");
521 printf(" Integrated flow from \n");
522 printf(" Scalar Product \n\n");
523 if(!fNormalizationType)
524 printf(" (BehaveAsEP) \n\n");
526 //Calculate reference flow
527 //----------------------------------
528 //weighted average over (QaQb/NaNb) with weight (NaNb)
529 Double_t dEntriesQaQb = fHistProQaQbNorm->GetEntries();
530 if( dEntriesQaQb < 1 )
532 Double_t dQaQb = fHistProQaQbNorm->GetBinContent(1);
535 Double_t dSpreadQaQb = fHistProQaQbNorm->GetBinError(1);
538 Double_t dImQa = fHistProNUAq->GetBinContent(1);
539 Double_t dReQa = fHistProNUAq->GetBinContent(2);
540 Double_t dImQb = fHistProNUAq->GetBinContent(3);
541 Double_t dReQb = fHistProNUAq->GetBinContent(4);
542 if(fApplyCorrectionForNUA)
543 dQaQb = dQaQb - dImQa*dImQb - dReQa*dReQb;
544 printf("QaQb = %f +- %f\n", dQaQb, (dSpreadQaQb/TMath::Sqrt(dEntriesQaQb)) );
545 Double_t dV = TMath::Sqrt(dQaQb);
547 printf("ResSub = %f\n", dV );
548 printf("fTotalQvector %d \n",fTotalQvector);
549 if(!fNormalizationType) {
550 if(fTotalQvector>2) {
551 dV = ComputeResolution( TMath::Sqrt2()*FindXi(dV,1e-6) );
552 printf("An estimate of the event plane resolution is: %f\n", dV );
555 printf("ResTot = %f\n", dV );
556 //statistical error of dQaQb:
557 // statistical error = term1 * spread * term2:
558 // term1 = sqrt{sum_{i=1}^{N} w^2}/(sum_{i=1}^{N} w)
559 // term2 = 1/sqrt(1-term1^2)
560 Double_t dSumOfLinearWeights = fHistSumOfWeights->GetBinContent(1);
561 Double_t dSumOfQuadraticWeights = fHistSumOfWeights->GetBinContent(2);
562 Double_t dTerm1 = 0.;
563 Double_t dTerm2 = 0.;
564 if(dSumOfLinearWeights)
565 dTerm1 = pow(dSumOfQuadraticWeights,0.5)/dSumOfLinearWeights;
566 if(1.-pow(dTerm1,2.) > 0.)
567 dTerm2 = 1./pow(1-pow(dTerm1,2.),0.5);
568 Double_t dStatErrorQaQb = dTerm1 * dSpreadQaQb * dTerm2;
571 dVerr = (1./(2.*pow(dQaQb,0.5)))*dStatErrorQaQb;
572 fCommonHistsRes->FillIntegratedFlow(dV,dVerr);
573 printf("v%d(subevents) = %f +- %f\n",fHarmonic,dV,dVerr);
576 iNbins[0] = AliFlowCommonConstants::GetMaster()->GetNbinsPt();
577 iNbins[1] = AliFlowCommonConstants::GetMaster()->GetNbinsEta();
579 //Calculate differential flow and integrated flow (RP, POI)
580 //---------------------------------------------------------
581 //v as a function of eta for RP selection
582 for(Int_t iRFPorPOI=0; iRFPorPOI != 2; ++iRFPorPOI)
583 for(Int_t iPTorETA=0; iPTorETA != 2; ++iPTorETA)
584 for(Int_t b=1; b != iNbins[iPTorETA]+1; ++b) {
585 Double_t duQpro = fHistProUQ[iRFPorPOI][iPTorETA]->GetBinContent(b);
586 if(fApplyCorrectionForNUA)
588 - fHistProNUAu[iRFPorPOI][iPTorETA][1]->GetBinContent(b)*fHistProNUAq->GetBinContent(6)
589 - fHistProNUAu[iRFPorPOI][iPTorETA][0]->GetBinContent(b)*fHistProNUAq->GetBinContent(5);
590 Double_t dv2pro = -999.;
591 if( TMath::Abs(dV!=0.) ) { dv2pro = duQpro/dV; }
592 //calculate the statistical error
593 Double_t dv2ProErr = CalculateStatisticalError(iRFPorPOI, iPTorETA, b, dStatErrorQaQb);
594 if( (iRFPorPOI==0)&&(iPTorETA==0) )
595 fCommonHistsRes->FillDifferentialFlowPtRP( b, dv2pro, dv2ProErr);
596 if( (iRFPorPOI==0)&&(iPTorETA==1) )
597 fCommonHistsRes->FillDifferentialFlowEtaRP( b, dv2pro, dv2ProErr);
598 if( (iRFPorPOI==1)&&(iPTorETA==0) )
599 fCommonHistsRes->FillDifferentialFlowPtPOI( b, dv2pro, dv2ProErr);
600 if( (iRFPorPOI==1)&&(iPTorETA==1) )
601 fCommonHistsRes->FillDifferentialFlowEtaPOI(b, dv2pro, dv2ProErr);
602 //printf("POI %d | PT %d >>> %f +- %f\n",iRFPorPOI,iPTorETA,dv2pro,dv2ProErr);
606 printf("*************************************\n");
607 printf("*************************************\n");
610 //-----------------------------------------------------------------------
611 void AliFlowAnalysisWithScalarProduct::WriteHistograms(TDirectoryFile *outputFileName) const {
612 //store the final results in output .root file
613 outputFileName->Add(fHistList);
614 outputFileName->Write(outputFileName->GetName(), TObject::kSingleKey);
617 //--------------------------------------------------------------------
618 Double_t AliFlowAnalysisWithScalarProduct::CalculateStatisticalError(Int_t iRFPorPOI, Int_t iPTorETA, Int_t b, Double_t aStatErrorQaQb) const {
619 //calculate the statistical error for differential flow for bin b
620 Double_t duQproSpread = fHistProUQ[iRFPorPOI][iPTorETA]->GetBinError(b);
621 Double_t sumOfMq = fHistSumOfWeightsu[iRFPorPOI][iPTorETA][0]->GetBinContent(b);
622 Double_t sumOfMqSquared = fHistSumOfWeightsu[iRFPorPOI][iPTorETA][1]->GetBinContent(b);
623 Double_t dQaQb = fHistProQaQbNorm->GetBinContent(1);
625 //non-isotropic terms:
626 if(fApplyCorrectionForNUA) {
627 Double_t dImQa = fHistProNUAq->GetBinContent(1); // <<sin(phi_a)>>
628 Double_t dReQa = fHistProNUAq->GetBinContent(2); // <<cos(phi_a)>>
629 Double_t dImQb = fHistProNUAq->GetBinContent(3); // <<sin(phi_b)>>
630 Double_t dReQb = fHistProNUAq->GetBinContent(4); // <<cos(phi_b)>>
631 dQaQb = dQaQb - dImQa*dImQb - dReQa*dReQb;
634 Double_t dTerm1 = 0.;
635 Double_t dTerm2 = 0.;
637 dTerm1 = (pow(sumOfMqSquared,0.5)/sumOfMq);
639 if(1.-pow(dTerm1,2.)>0.) {
640 dTerm2 = 1./pow(1.-pow(dTerm1,2.),0.5);
642 Double_t duQproErr = dTerm1*duQproSpread*dTerm2;
644 Double_t dTerm1Cov = fHistSumOfWeightsu[iRFPorPOI][iPTorETA][2]->GetBinContent(b);
645 Double_t dTerm2Cov = fHistSumOfWeights->GetBinContent(1);
646 Double_t dTerm3Cov = sumOfMq;
647 Double_t dWeightedCovariance = 0.;
648 if(dTerm2Cov*dTerm3Cov>0.) {
649 Double_t dDenominator = 1.-dTerm1Cov/(dTerm2Cov*dTerm3Cov);
650 Double_t dPrefactor = dTerm1Cov/(dTerm2Cov*dTerm3Cov);
651 if(dDenominator!=0) {
652 Double_t dCovariance = ( fHistProUQQaQb[iRFPorPOI][iPTorETA]->GetBinContent(b)-dQaQb*fHistProUQ[iRFPorPOI][iPTorETA]->GetBinContent(b))/dDenominator;
653 dWeightedCovariance = dCovariance*dPrefactor;
656 Double_t dv2ProErr = 0.; // final statitical error:
658 Double_t dv2ProErrorSquared = (1./4.)*pow(dQaQb,-3.)*
659 (pow(fHistProUQ[iRFPorPOI][iPTorETA]->GetBinContent(b),2.)*pow(aStatErrorQaQb,2.)
660 + 4.*pow(dQaQb,2.)*pow(duQproErr,2.)
661 - 4.*dQaQb*fHistProUQ[iRFPorPOI][iPTorETA]->GetBinContent(b)*dWeightedCovariance);
662 if(dv2ProErrorSquared>0.) dv2ProErr = pow(dv2ProErrorSquared,0.5);
667 Double_t AliFlowAnalysisWithScalarProduct::ComputeResolution( Double_t x ) const {
668 // Computes resolution for Event Plane method
670 printf("Warning: Estimation of total resolution might be WRONG. Please check!");
674 Double_t b = TMath::Exp(-a)*TMath::BesselI0(a)+TMath::Exp(-a)*TMath::BesselI1(a);
675 return TMath::Sqrt(TMath::PiOver2())/2*x*b;
678 Double_t AliFlowAnalysisWithScalarProduct::FindXi( Double_t res, Double_t prec ) const {
679 // Computes x(res) for Event Plane method
681 printf("Warning: Resolution for subEvent is high. You reached the precision limit.");
685 Double_t xtmp=0, xmin=0, xmax=51.3, rtmp=0, delta=2*prec;
686 while( delta > prec ) {
687 xtmp = 0.5*(xmin+xmax);
688 rtmp = ComputeResolution(xtmp);
689 delta = TMath::Abs( res-rtmp );
690 if(rtmp>res) xmax = xtmp;
691 if(rtmp<res) xmin = xtmp;