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
18 #include "Riostream.h" //needed as include
19 #include "TFile.h" //needed as include
27 #include "AliFlowCommonConstants.h" //needed as include
28 #include "AliFlowEventSimple.h"
29 #include "AliFlowTrackSimple.h"
30 #include "AliFlowCommonHist.h"
31 #include "AliFlowCommonHistResults.h"
32 #include "AliFlowAnalysisWithScalarProduct.h"
36 // AliFlowAnalysisWithScalarProduct:
38 // Maker to analyze Flow with the Scalar product method.
40 // author: N. van der Kolk (kolk@nikhef.nl)
42 ClassImp(AliFlowAnalysisWithScalarProduct)
44 //-----------------------------------------------------------------------
46 AliFlowAnalysisWithScalarProduct::AliFlowAnalysisWithScalarProduct():
50 fHistProUQetaRP(NULL),
51 fHistProUQetaPOI(NULL),
53 fHistProUQPtPOI(NULL),
60 fHistList = new TList();
62 //-----------------------------------------------------------------------
65 AliFlowAnalysisWithScalarProduct::~AliFlowAnalysisWithScalarProduct()
72 //-----------------------------------------------------------------------
74 void AliFlowAnalysisWithScalarProduct::WriteHistograms(TString* outputFileName)
76 //store the final results in output .root file
78 TFile *output = new TFile(outputFileName->Data(),"RECREATE");
79 //output->WriteObject(fHistList, "cobjSP","SingleKey");
80 fHistList->SetName("cobjSP");
81 fHistList->Write(fHistList->GetName(), TObject::kSingleKey);
85 //-----------------------------------------------------------------------
87 void AliFlowAnalysisWithScalarProduct::WriteHistograms(TString outputFileName)
89 //store the final results in output .root file
91 TFile *output = new TFile(outputFileName.Data(),"RECREATE");
92 //output->WriteObject(fHistList, "cobjSP","SingleKey");
93 fHistList->SetName("cobjSP");
94 fHistList->Write(fHistList->GetName(), TObject::kSingleKey);
98 //-----------------------------------------------------------------------
99 void AliFlowAnalysisWithScalarProduct::Init() {
101 //Define all histograms
102 cout<<"---Analysis with the Scalar Product Method--- Init"<<endl;
104 Int_t iNbinsPt = AliFlowCommonConstants::GetNbinsPt();
105 Double_t dPtMin = AliFlowCommonConstants::GetPtMin();
106 Double_t dPtMax = AliFlowCommonConstants::GetPtMax();
107 Int_t iNbinsEta = AliFlowCommonConstants::GetNbinsEta();
108 Double_t dEtaMin = AliFlowCommonConstants::GetEtaMin();
109 Double_t dEtaMax = AliFlowCommonConstants::GetEtaMax();
111 fHistProUQetaRP = new TProfile("Flow_UQetaRP_SP","Flow_UQetaRP_SP",iNbinsEta,dEtaMin,dEtaMax);
112 fHistProUQetaRP->SetXTitle("{eta}");
113 fHistProUQetaRP->SetYTitle("<uQ>");
114 fHistList->Add(fHistProUQetaRP);
116 fHistProUQetaPOI = new TProfile("Flow_UQetaPOI_SP","Flow_UQetaPOI_SP",iNbinsEta,dEtaMin,dEtaMax);
117 fHistProUQetaPOI->SetXTitle("{eta}");
118 fHistProUQetaPOI->SetYTitle("<uQ>");
119 fHistList->Add(fHistProUQetaPOI);
121 fHistProUQPtRP = new TProfile("Flow_UQPtRP_SP","Flow_UQPtRP_SP",iNbinsPt,dPtMin,dPtMax);
122 fHistProUQPtRP->SetXTitle("p_t (GeV)");
123 fHistProUQPtRP->SetYTitle("<uQ>");
124 fHistList->Add(fHistProUQPtRP);
126 fHistProUQPtPOI = new TProfile("Flow_UQPtPOI_SP","Flow_UQPtPOI_SP",iNbinsPt,dPtMin,dPtMax);
127 fHistProUQPtPOI->SetXTitle("p_t (GeV)");
128 fHistProUQPtPOI->SetYTitle("<uQ>");
129 fHistList->Add(fHistProUQPtPOI);
131 fHistProQaQb = new TProfile("Flow_QaQb_SP","Flow_QaQb_SP", 1, -0.5, 0.5);
132 fHistProQaQb->SetYTitle("<QaQb>");
133 fHistList->Add(fHistProQaQb);
135 fHistProM = new TProfile("Flow_M_SP","Flow_M_SP",2,0.5, 2.5);
136 fHistProM -> SetYTitle("<*>");
137 fHistProM -> SetXTitle("<M-1>, <Ma*Mb>");
138 fHistList->Add(fHistProM);
140 fCommonHists = new AliFlowCommonHist("AliFlowCommonHistSP");
141 fHistList->Add(fCommonHists);
142 fCommonHistsRes = new AliFlowCommonHistResults("AliFlowCommonHistResultsSP");
143 fHistList->Add(fCommonHistsRes);
145 fEventNumber = 0; //set number of events to zero
148 //-----------------------------------------------------------------------
150 void AliFlowAnalysisWithScalarProduct::Make(AliFlowEventSimple* anEvent) {
155 //fill control histograms
156 fCommonHists->FillControlHistograms(anEvent);
158 //get the Q vector from the FlowEvent
159 AliFlowVector vQ = anEvent->GetQ();
160 fHistProM -> Fill(1,vQ.GetMult()-1);
161 //get Q vectors for the subevents
162 AliFlowVector vQa = anEvent->GetQsub(-0.9,-0.1);
163 AliFlowVector vQb = anEvent->GetQsub(0.1,0.9);
164 fHistProM -> Fill(2,vQa.GetMult()*vQb.GetMult());
165 Double_t dQaQb = vQa*vQb;
166 fHistProQaQb -> Fill(0.,dQaQb);
168 //loop over the tracks of the event
169 AliFlowTrackSimple* pTrack = NULL;
170 Int_t iNumberOfTracks = anEvent->NumberOfTracks();
171 for (Int_t i=0;i<iNumberOfTracks;i++)
173 pTrack = anEvent->GetTrack(i) ;
175 Double_t dPhi = pTrack->Phi();
178 Double_t dUX = TMath::Cos(2*dPhi);
179 Double_t dUY = TMath::Sin(2*dPhi);
181 Double_t dModulus = vU.Mod();
182 if (dModulus!=0.) vU.Set(dUX/dModulus,dUY/dModulus); // make length 1
183 else cerr<<"dModulus is zero!"<<endl;
186 //subtrackt particle from the flowvector if used to define it
187 if (pTrack->InRPSelection()) {
188 Double_t dQmX = vQm.X() - dUX;
189 Double_t dQmY = vQm.Y() - dUY;
193 //dUQ = scalar product of vU and vQm
194 Double_t dUQ = vU * vQm;
195 Double_t dPt = pTrack->Pt();
196 Double_t dEta = pTrack->Eta();
197 //fill the profile histograms
198 if (pTrack->InRPSelection()) {
199 fHistProUQetaRP -> Fill(dEta,dUQ);
200 fHistProUQPtRP -> Fill(dPt,dUQ);
202 if (pTrack->InPOISelection()) {
203 fHistProUQetaPOI -> Fill(dEta,dUQ);
204 fHistProUQPtPOI -> Fill(dPt,dUQ);
210 // cout<<"@@@@@ "<<fEventNumber<<" events processed"<<endl;
214 //--------------------------------------------------------------------
215 void AliFlowAnalysisWithScalarProduct::GetOutputHistograms(TList *outputListHistos){
217 //get pointers to all output histograms (called before Finish())
218 if (outputListHistos) {
219 //Get the common histograms from the output list
220 AliFlowCommonHist *pCommonHist = dynamic_cast<AliFlowCommonHist*>
221 (outputListHistos->FindObject("AliFlowCommonHistSP"));
222 AliFlowCommonHistResults *pCommonHistResults = dynamic_cast<AliFlowCommonHistResults*>
223 (outputListHistos->FindObject("AliFlowCommonHistResultsSP"));
224 TProfile* pHistProQaQb = dynamic_cast<TProfile*>(outputListHistos->FindObject("Flow_QaQb_SP"));
225 TProfile* pHistProM = dynamic_cast<TProfile*>(outputListHistos->FindObject("Flow_M_SP"));
226 TProfile* pHistProUQetaRP = dynamic_cast<TProfile*>(outputListHistos->FindObject("Flow_UQetaRP_SP"));
227 TProfile* pHistProUQetaPOI = dynamic_cast<TProfile*>(outputListHistos->FindObject("Flow_UQetaPOI_SP"));
228 TProfile* pHistProUQPtRP = dynamic_cast<TProfile*>(outputListHistos->FindObject("Flow_UQPtRP_SP"));
229 TProfile* pHistProUQPtPOI = dynamic_cast<TProfile*>(outputListHistos->FindObject("Flow_UQPtPOI_SP"));
230 if (pCommonHist && pCommonHistResults && pHistProQaQb && pHistProM &&
231 pHistProUQetaRP && pHistProUQetaPOI && pHistProUQPtRP && pHistProUQPtPOI) {
232 this -> SetCommonHists(pCommonHist);
233 this -> SetCommonHistsRes(pCommonHistResults);
234 this -> SetHistProQaQb(pHistProQaQb);
235 this -> SetHistProM(pHistProM);
236 this -> SetHistProUQetaRP(pHistProUQetaRP);
237 this -> SetHistProUQetaPOI(pHistProUQetaPOI);
238 this -> SetHistProUQPtRP(pHistProUQPtRP);
239 this -> SetHistProUQPtPOI(pHistProUQPtPOI);
244 //--------------------------------------------------------------------
245 void AliFlowAnalysisWithScalarProduct::Finish() {
247 //calculate flow and fill the AliFlowCommonHistResults
248 if (fDebug) cout<<"AliFlowAnalysisWithScalarProduct::Finish()"<<endl;
250 cout<<"*************************************"<<endl;
251 cout<<"*************************************"<<endl;
252 cout<<" Integrated flow from "<<endl;
253 cout<<" Scalar product "<<endl;
256 Int_t iNbinsPt = AliFlowCommonConstants::GetNbinsPt();
257 Int_t iNbinsEta = AliFlowCommonConstants::GetNbinsEta();
259 Double_t dMmin1 = fHistProM->GetBinContent(1); //average over M-1
260 Double_t dMmin1Err = fHistProM->GetBinError(1); //error on average over M-1
261 Double_t dMaMb = fHistProM->GetBinContent(2); //average over Ma*Mb
262 Double_t dMaMbErr = fHistProM->GetBinError(2); //error on average over Ma*Mb
264 Double_t dMcorrection = 0.; //correction factor for Ma != Mb
265 Double_t dMcorrectionErr = 0.;
266 Double_t dMcorrectionErrRel = 0.;
267 Double_t dMcorrectionErrRel2 = 0.;
269 if (dMaMb != 0. && dMmin1 != 0.) {
270 dMcorrection = dMmin1/(TMath::Sqrt(dMaMb));
271 dMcorrectionErr = dMcorrection*(dMmin1Err/dMmin1 + dMaMbErr/(2*dMaMb));
272 dMcorrectionErrRel = dMcorrectionErr/dMcorrection;
273 dMcorrectionErrRel2 = dMcorrectionErrRel*dMcorrectionErrRel;
276 Double_t dQaQbAv = fHistProQaQb->GetBinContent(1); //average over events
277 Double_t dQaQbErr = fHistProQaQb->GetBinError(1);
278 Double_t dQaQbErrRel = 0.;
280 dQaQbErrRel = dQaQbErr/dQaQbAv; }
281 Double_t dQaQbErrRel2 = dQaQbErrRel*dQaQbErrRel;
285 fCommonHistsRes->FillIntegratedFlowRP(-0.,0.);
286 fCommonHistsRes->FillIntegratedFlow(-0.,0.);
287 cout<<"dV(RP) = -0. +- 0."<<endl;
288 fCommonHistsRes->FillIntegratedFlowPOI(-0.,0.);
289 cout<<"dV(POI) = -0. +- 0."<<endl;
291 Double_t dQaQbSqrt = TMath::Sqrt(dQaQbAv);
292 if (dMaMb>0.) { dQaQbSqrt *= dMcorrection; }
293 else { dQaQbSqrt = 0.; }
294 Double_t dQaQbSqrtErrRel2 = dMcorrectionErrRel2 + (1/4)*dQaQbErrRel2;
296 //v as a function of eta for RP selection
297 for(Int_t b=0;b<iNbinsEta;b++) {
298 Double_t duQpro = fHistProUQetaRP->GetBinContent(b);
299 Double_t duQerr = fHistProUQetaRP->GetBinError(b); //copy error for now
300 Double_t duQerrRel = 0.;
301 if (duQpro != 0.) {duQerrRel = duQerr/duQpro;}
302 Double_t duQerrRel2 = duQerrRel*duQerrRel;
304 Double_t dv2pro = 0.;
305 if (dQaQbSqrt!=0.) { dv2pro = duQpro/dQaQbSqrt; }
306 Double_t dv2errRel2 = duQerrRel2 + dQaQbSqrtErrRel2;
307 Double_t dv2errRel = 0.;
308 if (dv2errRel2>0.) { dv2errRel = TMath::Sqrt(dv2errRel2); }
309 Double_t dv2err = dv2pro*dv2errRel;
311 fCommonHistsRes->FillDifferentialFlowEtaRP(b, dv2pro, dv2err);
314 //v as a function of eta for POI selection
315 for(Int_t b=0;b<iNbinsEta;b++) {
316 Double_t duQpro = fHistProUQetaPOI->GetBinContent(b);
317 Double_t duQerr = fHistProUQetaPOI->GetBinError(b); //copy error for now
318 Double_t duQerrRel = 0.;
319 if (duQpro != 0.) {duQerrRel = duQerr/duQpro;}
320 Double_t duQerrRel2 = duQerrRel*duQerrRel;
322 Double_t dv2pro = 0.;
323 if (dQaQbSqrt!=0.) { dv2pro = duQpro/dQaQbSqrt; }
324 Double_t dv2errRel2 = duQerrRel2 + dQaQbSqrtErrRel2;
325 Double_t dv2errRel = 0.;
326 if (dv2errRel2>0.) { dv2errRel = TMath::Sqrt(dv2errRel2); }
327 Double_t dv2err = dv2pro*dv2errRel;
329 fCommonHistsRes->FillDifferentialFlowEtaPOI(b, dv2pro, dv2err);
332 //v as a function of Pt for RP selection
333 TH1F* fHistPtRP = fCommonHists->GetHistPtRP(); //for calculating integrated flow
338 for(Int_t b=0;b<iNbinsPt;b++) {
339 Double_t duQpro = fHistProUQPtRP->GetBinContent(b);
340 Double_t duQerr = fHistProUQPtRP->GetBinError(b); //copy error for now
341 Double_t duQerrRel = 0.;
342 if (duQpro != 0.) {duQerrRel = duQerr/duQpro;}
343 Double_t duQerrRel2 = duQerrRel*duQerrRel;
345 Double_t dv2pro = 0.;
346 if (dQaQbSqrt!=0.) { dv2pro = duQpro/dQaQbSqrt; }
347 Double_t dv2errRel2 = duQerrRel2 + dQaQbSqrtErrRel2;
348 Double_t dv2errRel = 0.;
349 if (dv2errRel2>0.) { dv2errRel = TMath::Sqrt(dv2errRel2); }
350 Double_t dv2err = dv2pro*dv2errRel;
352 fCommonHistsRes->FillDifferentialFlowPtRP(b, dv2pro, dv2err);
353 //calculate integrated flow for RP selection
355 Double_t dYieldPt = fHistPtRP->GetBinContent(b);
356 dVRP += dv2pro*dYieldPt;
358 dErrV += dYieldPt*dYieldPt*dv2err*dv2err;
359 } else { cout<<"fHistPtRP is NULL"<<endl; }
363 dVRP /= dSum; //the pt distribution should be normalised
364 dErrV /= (dSum*dSum);
365 dErrV = TMath::Sqrt(dErrV);
367 fCommonHistsRes->FillIntegratedFlowRP(dVRP,dErrV);
368 fCommonHistsRes->FillIntegratedFlow(dVRP,dErrV);
370 cout<<"dV(RP) = "<<dVRP<<" +- "<<dErrV<<endl;
372 //v as a function of Pt for POI selection
373 TH1F* fHistPtPOI = fCommonHists->GetHistPtPOI(); //for calculating integrated flow
378 for(Int_t b=0;b<iNbinsPt;b++) {
379 Double_t duQpro = fHistProUQPtPOI->GetBinContent(b);
380 Double_t duQerr = fHistProUQPtPOI->GetBinError(b); //copy error for now
381 Double_t duQerrRel = 0.;
382 if (duQpro != 0.) {duQerrRel = duQerr/duQpro;}
383 Double_t duQerrRel2 = duQerrRel*duQerrRel;
385 Double_t dv2pro = 0.;
386 if (dQaQbSqrt!=0.) { dv2pro = duQpro/dQaQbSqrt; }
387 Double_t dv2errRel2 = duQerrRel2 + dQaQbSqrtErrRel2;
388 Double_t dv2errRel = 0.;
389 if (dv2errRel2>0.) { dv2errRel = TMath::Sqrt(dv2errRel2); }
390 Double_t dv2err = dv2pro*dv2errRel;
392 fCommonHistsRes->FillDifferentialFlowPtPOI(b, dv2pro, dv2err);
394 //calculate integrated flow for POI selection
396 Double_t dYieldPt = fHistPtPOI->GetBinContent(b);
397 dVPOI += dv2pro*dYieldPt;
399 dErrV += dYieldPt*dYieldPt*dv2err*dv2err;
400 } else { cout<<"fHistPtPOI is NULL"<<endl; }
404 dVPOI /= dSum; //the pt distribution should be normalised
405 dErrV /= (dSum*dSum);
406 dErrV = TMath::Sqrt(dErrV);
408 fCommonHistsRes->FillIntegratedFlowPOI(dVPOI,dErrV);
410 cout<<"dV(POI) = "<<dVPOI<<" +- "<<dErrV<<endl;
413 cout<<"*************************************"<<endl;
414 cout<<"*************************************"<<endl;
416 //cout<<".....finished"<<endl;