- add output graphs for efficiency
[u/mrichter/AliRoot.git] / PWG2 / FLOW / AliFlowCommon / AliFlowEventSimple.cxx
CommitLineData
f1d945a1 1/**************************************************************************
2 * Copyright(c) 1998-1999, 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
f1d945a1 16#include "Riostream.h"
17#include "TObjArray.h"
26c4cbb9 18#include "TFile.h"
03a02aca 19#include "TList.h"
f1d945a1 20#include "TMath.h"
26c4cbb9 21#include "TH1F.h"
22#include "TH1D.h"
23#include "TProfile.h"
f1d945a1 24#include "AliFlowVector.h"
25#include "AliFlowTrackSimple.h"
26#include "AliFlowEventSimple.h"
27
26c4cbb9 28/**************************************
29 * AliFlowEventSimple: A simple event *
30 * for flow analysis *
31 * *
32 * authors: Naomi van der Kolk *
33 * (kolk@nikhef.nl) *
34 * Ante Bilandzic *
35 * (anteb@nikhef.nl) *
36 * ***********************************/
37
f1d945a1 38ClassImp(AliFlowEventSimple)
39
40//-----------------------------------------------------------------------
41
e35ddff0 42 AliFlowEventSimple::AliFlowEventSimple(Int_t aLenght):
d29ba078 43 fTrackCollection(NULL),
f1d945a1 44 fNumberOfTracks(0),
03a02aca 45 fEventNSelTracksIntFlow(0)
f1d945a1 46{
47 //constructor
e35ddff0 48 fTrackCollection = new TObjArray(aLenght) ;
f1d945a1 49}
50
51//-----------------------------------------------------------------------
52
e35ddff0 53AliFlowEventSimple::AliFlowEventSimple(const AliFlowEventSimple& anEvent):
bc6b015e 54 TObject(),
e35ddff0 55 fTrackCollection(anEvent.fTrackCollection),
56 fNumberOfTracks(anEvent.fNumberOfTracks),
03a02aca 57 fEventNSelTracksIntFlow(anEvent.fEventNSelTracksIntFlow)
f1d945a1 58{
59 //copy constructor
f1d945a1 60}
61
62//-----------------------------------------------------------------------
63
e35ddff0 64AliFlowEventSimple& AliFlowEventSimple::operator=(const AliFlowEventSimple& anEvent)
f1d945a1 65{
26c4cbb9 66 *fTrackCollection = *anEvent.fTrackCollection ;
e35ddff0 67 fNumberOfTracks = anEvent.fNumberOfTracks;
68 fEventNSelTracksIntFlow = anEvent.fEventNSelTracksIntFlow;
26c4cbb9 69
f1d945a1 70 return *this;
f1d945a1 71}
72
f1d945a1 73//-----------------------------------------------------------------------
74
75AliFlowEventSimple::~AliFlowEventSimple()
76{
77 //destructor
78 fTrackCollection->Delete() ; delete fTrackCollection ;
79}
80
81//-----------------------------------------------------------------------
82
83AliFlowTrackSimple* AliFlowEventSimple::GetTrack(Int_t i)
84{
85 //get track i from collection
e35ddff0 86 AliFlowTrackSimple* pTrack = (AliFlowTrackSimple*)TrackCollection()->At(i) ;
87 return pTrack;
f1d945a1 88}
89
90//-----------------------------------------------------------------------
03a02aca 91AliFlowVector AliFlowEventSimple::GetQ(Int_t n, TList *weightsList, Bool_t usePhiWeights, Bool_t usePtWeights, Bool_t useEtaWeights)
f1d945a1 92{
26c4cbb9 93 //calculate Q-vector in harmonic n without weights (default harmonic n=2)
e35ddff0 94 Double_t dQX = 0.;
95 Double_t dQY = 0.;
96 AliFlowVector vQ;
97 vQ.Set(0.,0.);
9825d4a9 98
99 Int_t iOrder = n;
e35ddff0 100 Int_t iUsedTracks = 0;
26c4cbb9 101 Double_t dPhi=0.;
102 Double_t dPt=0;
103 Double_t dEta=0;
104
105 AliFlowTrackSimple* pTrack = NULL;
106
107 Int_t nBinsPhi=0;
108 Double_t dBinWidthPt=0.;
109 Double_t dNormPt=0.;
110 Double_t dBinWidthEta=0.;
111 Double_t dNormEta=0.;
112
113 Double_t wPhi=1.; //weight Phi
114 Double_t wPt=1.; //weight Pt
115 Double_t wEta=1.; //weight Eta
116
03a02aca 117 TH1F *phiWeights = NULL;
118 TH1D *ptWeights = NULL;
119 TH1D *etaWeights = NULL;
120
121 if(weightsList)
26c4cbb9 122 {
03a02aca 123 if(usePhiWeights)
26c4cbb9 124 {
03a02aca 125 phiWeights = dynamic_cast<TH1F *>(weightsList->FindObject("phi_weights"));
126 if(phiWeights) nBinsPhi = phiWeights->GetNbinsX();
127 }
128 if(usePtWeights)
26c4cbb9 129 {
03a02aca 130 ptWeights = dynamic_cast<TH1D *>(weightsList->FindObject("pt_weights"));
131 if(ptWeights)
132 {
133 dBinWidthPt = ptWeights->GetBinWidth(1); // assuming that all bins have the same width
134 dNormPt = ptWeights->Integral();
135 }
136 }
137 if(useEtaWeights)
26c4cbb9 138 {
03a02aca 139 etaWeights = dynamic_cast<TH1D *>(weightsList->FindObject("eta_weights"));
140 if(etaWeights)
141 {
142 dBinWidthEta = etaWeights->GetBinWidth(1); // assuming that all bins have the same width
143 dNormEta = etaWeights->Integral();
144 }
145 }
146 } // end of if(weightsList)
147
26c4cbb9 148
03a02aca 149 // loop over tracks
26c4cbb9 150 for(Int_t i=0;i<fNumberOfTracks;i++)
151 {
152 pTrack = (AliFlowTrackSimple*)TrackCollection()->At(i);
153 if(pTrack)
154 {
155 if(pTrack->UseForIntegratedFlow())
f1d945a1 156 {
26c4cbb9 157 dPhi = pTrack->Phi();
158 dPt = pTrack->Pt();
159 dEta = pTrack->Eta();
03a02aca 160
26c4cbb9 161 //determine Phi weight: (to be improved, I should here only access it + the treatment of gaps in the if statement)
03a02aca 162 if(phiWeights && (nBinsPhi!=0) && (phiWeights->GetBinContent(1+(Int_t)(TMath::Floor(dPhi*nBinsPhi/TMath::TwoPi())))!=0))
26c4cbb9 163 {
03a02aca 164 wPhi=pow(nBinsPhi*phiWeights->GetBinContent(1+(Int_t)(TMath::Floor(dPhi*nBinsPhi/TMath::TwoPi()))),-1);
26c4cbb9 165 }
166 //determine v'(pt) weight:
03a02aca 167 if(ptWeights && dBinWidthPt && dNormPt)
26c4cbb9 168 {
03a02aca 169 wPt=ptWeights->GetBinContent(1+(Int_t)(TMath::Floor(dPt/dBinWidthPt)))/dNormPt;
26c4cbb9 170 }
171 //determine v'(eta) weight:
03a02aca 172 if(etaWeights && dBinWidthEta && dNormEta)
26c4cbb9 173 {
03a02aca 174 wEta=etaWeights->GetBinContent(1+(Int_t)(TMath::Floor(dEta/dBinWidthEta)))/dNormEta;
175 }
e04e4ec5 176
26c4cbb9 177 //building up the weighted Q-vector:
178 dQX += wPhi*wPt*wEta*TMath::Cos(iOrder*dPhi);
179 dQY += wPhi*wPt*wEta*TMath::Sin(iOrder*dPhi);
180 iUsedTracks++;
03a02aca 181
26c4cbb9 182 }//end of if (pTrack->UseForIntegratedFlow())
183 }//end of if (pTrack)
184 else {cerr << "no particle!!!"<<endl;}
185 }//loop over particles
186
e35ddff0 187 vQ.Set(dQX,dQY);
188 vQ.SetMult(iUsedTracks);
26c4cbb9 189
e35ddff0 190 return vQ;
f1d945a1 191
5fef318d 192}
193
194
26c4cbb9 195
196
197
198
199
200
201
202