added uQ method for proton-proton
[u/mrichter/AliRoot.git] / PWG2 / FLOW / AliFlowAnalysisWithScalarProduct.cxx
CommitLineData
8d312f00 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#define AliFlowAnalysisWithScalarProduct_cxx
17
18#include "Riostream.h" //needed as include
19#include "TFile.h" //needed as include
20#include "TMath.h"
21#include "TProfile.h"
22#include "TVector2.h"
23
24class TH1F;
25
26#include "AliFlowCommonConstants.h" //needed as include
27#include "AliFlowEventSimple.h"
28#include "AliFlowTrackSimple.h"
29#include "AliFlowCommonHist.h"
30//#include "AliFlowCommonHistResults.h"
31#include "AliFlowAnalysisWithScalarProduct.h"
32
33class AliFlowVector;
34
35// AliFlowAnalysisWithScalarProduct:
36// Description:
37// Maker to analyze Flow with the Scalar product method.
38//
39// author: N. van der Kolk (kolk@nikhef.nl)
40
41ClassImp(AliFlowAnalysisWithScalarProduct)
42
43 //-----------------------------------------------------------------------
44
45 AliFlowAnalysisWithScalarProduct::AliFlowAnalysisWithScalarProduct():
46 fEventNumber(0),
47 fEvent(0x0),
48 fTrack(0x0),
49 fDebug(kFALSE),
50 fHistFileName(0),
51 fHistFile(0),
52 fHistProUQ(0),
53 fCommonHists(0)
54{
55
56 // Constructor.
57 fQ.Set(0.,0.); // flow vector
58 fU.Set(0.,0.); // particle unit vector
59
60}
61 //-----------------------------------------------------------------------
62
63
64 AliFlowAnalysisWithScalarProduct::~AliFlowAnalysisWithScalarProduct()
65 {
66 //destructor
67
68 }
69
70
71//-----------------------------------------------------------------------
72void AliFlowAnalysisWithScalarProduct::Init() {
73
74 //Define all histograms
75 cout<<"---Analysis with the Scalar Product Method---"<<endl;
76
77 Int_t fNbinsPt = AliFlowCommonConstants::GetNbinsPt();
78 Double_t fPtMin = AliFlowCommonConstants::GetPtMin();
79 Double_t fPtMax = AliFlowCommonConstants::GetPtMax();
80
81 // analysis file (output)
82 fHistFile = new TFile(fHistFileName.Data(),"RECREATE") ;
83
84 fHistProUQ = new TProfile("Flow_UQ_SP","Flow_UQ_SP",fNbinsPt,fPtMin,fPtMax);
85 fHistProUQ->SetXTitle("p_t (GeV)");
86 fHistProUQ->SetYTitle("<uQ>");
87
88 fCommonHists = new AliFlowCommonHist("SP");
89 //fCommonHistsRes = new AliFlowCommonHistResults("SP");
90
91 fEventNumber = 0; //set number of events to zero
92
93}
94
95//-----------------------------------------------------------------------
96
97void AliFlowAnalysisWithScalarProduct::Make(AliFlowEventSimple* fEvent) {
98
99 //Fill histogram
100 if (fEvent) {
101
102 //fill control histograms
103 fCommonHists->FillControlHistograms(fEvent);
104
105 //get the Q vector from the FlowEvent
106 fQ = fEvent->GetQ();
107 //Double_t fMult = fQ.GetMult();
108
109 //loop over the tracks of the event
110 Int_t fNumberOfTracks = fEvent->NumberOfTracks();
111 for (Int_t i=0;i<fNumberOfTracks;i++)
112 {
113
114 fTrack = fEvent->GetTrack(i) ;
115 if (fTrack){
116 if (fTrack->UseForDifferentialFlow()) {
117 Double_t fPhi = fTrack->Phi();
118
119 //calculate fU
120 Double_t fUX = TMath::Cos(2*fPhi);
121 Double_t fUY = TMath::Sin(2*fPhi);
122 fU.Set(fUX,fUY);
123 Double_t fModulus = fU.Mod();
124 if (fModulus!=0.) fU.Set(fUX/fModulus,fUY/fModulus); // make length 1
125 else cerr<<"fModulus is zero!"<<endl;
126
127 TVector2 fQm = fQ;
128 //subtrackt particle from the flowvector if used to define it
129 if (fTrack->UseForIntegratedFlow()) {
130 Double_t fQmX = fQm.X() - fUX;
131 Double_t fQmY = fQm.Y() - fUY;
132 fQm.Set(fQmX,fQmY);
133 }
134
135 //Double_t fUQ = scalar product of fU and fQm
136 Double_t fUQ = fU*fQm;
137 Double_t fPt = fTrack->Pt();
138 //fill the profile histogram
139 fHistProUQ->Fill(fPt,fUQ);
140 }
141 }//track selected
142 }//loop over tracks
143
144 fEventNumber++;
145 cout<<"@@@@@ "<<fEventNumber<<" events processed"<<endl;
146 }
147}
148
149 //--------------------------------------------------------------------
150void AliFlowAnalysisWithScalarProduct::Finish() {
151
152 //*************make histograms etc.
153 if (fDebug) cout<<"AliFlowAnalysisWithScalarProduct::Terminate()"<<endl;
154
155 fHistProUQ->Draw();
156
157 // write to file
158 fHistFile->Write();
159
160 cout<<".....finished"<<endl;
161 }
162
163