fix coding violations
[u/mrichter/AliRoot.git] / PWG2 / FLOW / AliFlowCommon / 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
1dfa3c16 19#include "TFile.h" //needed as include
d7eb18ec 20#include "TList.h"
8d312f00 21#include "TMath.h"
22#include "TProfile.h"
23#include "TVector2.h"
24
25class TH1F;
26
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"
33
34class AliFlowVector;
35
36// AliFlowAnalysisWithScalarProduct:
37// Description:
38// Maker to analyze Flow with the Scalar product method.
39//
40// author: N. van der Kolk (kolk@nikhef.nl)
41
42ClassImp(AliFlowAnalysisWithScalarProduct)
43
44 //-----------------------------------------------------------------------
45
46 AliFlowAnalysisWithScalarProduct::AliFlowAnalysisWithScalarProduct():
e35ddff0 47 fEventNumber(0),
48 fDebug(kFALSE),
49 fHistList(NULL),
50 fHistProUQ(NULL),
51 fCommonHists(NULL)
8d312f00 52{
8d312f00 53 // Constructor.
e35ddff0 54 fHistList = new TList();
8d312f00 55}
56 //-----------------------------------------------------------------------
57
58
59 AliFlowAnalysisWithScalarProduct::~AliFlowAnalysisWithScalarProduct()
60 {
61 //destructor
e35ddff0 62 delete fHistList;
8d312f00 63 }
64
65
1dfa3c16 66//-----------------------------------------------------------------------
67
68void AliFlowAnalysisWithScalarProduct::WriteHistograms(TString* outputFileName)
69{
70 //store the final results in output .root file
71
72 TFile *output = new TFile(outputFileName->Data(),"RECREATE");
73 output->WriteObject(fHistList, "cobjSP","SingleKey");
74 delete output;
75}
76
b0fda271 77//-----------------------------------------------------------------------
78
79void AliFlowAnalysisWithScalarProduct::WriteHistograms(TString outputFileName)
80{
81 //store the final results in output .root file
82
83 TFile *output = new TFile(outputFileName.Data(),"RECREATE");
84 output->WriteObject(fHistList, "cobjSP","SingleKey");
85 delete output;
86}
87
8d312f00 88//-----------------------------------------------------------------------
89void AliFlowAnalysisWithScalarProduct::Init() {
90
91 //Define all histograms
d7eb18ec 92 cout<<"---Analysis with the Scalar Product Method--- Init"<<endl;
8d312f00 93
e35ddff0 94 Int_t iNbinsPt = AliFlowCommonConstants::GetNbinsPt();
95 Double_t dPtMin = AliFlowCommonConstants::GetPtMin();
96 Double_t dPtMax = AliFlowCommonConstants::GetPtMax();
8d312f00 97
e35ddff0 98 fHistProUQ = new TProfile("Flow_UQ_SP","Flow_UQ_SP",iNbinsPt,dPtMin,dPtMax);
8d312f00 99 fHistProUQ->SetXTitle("p_t (GeV)");
100 fHistProUQ->SetYTitle("<uQ>");
d7eb18ec 101 fHistList->Add(fHistProUQ);
8d312f00 102
04f6283b 103 fCommonHists = new AliFlowCommonHist("AliFlowCommonHistSP");
099e1753 104 fHistList->Add(fCommonHists);
9d062fe3 105
8d312f00 106 //fCommonHistsRes = new AliFlowCommonHistResults("SP");
e35ddff0 107
e2d51347 108 fEventNumber = 0; //set number of events to zero
109}
110
8d312f00 111//-----------------------------------------------------------------------
112
8232a5ec 113void AliFlowAnalysisWithScalarProduct::Make(AliFlowEventSimple* anEvent) {
8d312f00 114
115 //Fill histogram
8232a5ec 116 if (anEvent) {
8d312f00 117
118 //fill control histograms
8232a5ec 119 fCommonHists->FillControlHistograms(anEvent);
8d312f00 120
121 //get the Q vector from the FlowEvent
e35ddff0 122 AliFlowVector vQ = anEvent->GetQ();
123
8d312f00 124 //loop over the tracks of the event
e35ddff0 125 AliFlowTrackSimple* pTrack = NULL;
126 Int_t iNumberOfTracks = anEvent->NumberOfTracks();
127 for (Int_t i=0;i<iNumberOfTracks;i++)
8d312f00 128 {
e35ddff0 129 pTrack = anEvent->GetTrack(i) ;
130 if (pTrack){
131 if (pTrack->UseForDifferentialFlow()) {
132 Double_t dPhi = pTrack->Phi();
133
134 //calculate vU
135 TVector2 vU;
136 Double_t dUX = TMath::Cos(2*dPhi);
137 Double_t dUY = TMath::Sin(2*dPhi);
138 vU.Set(dUX,dUY);
139 Double_t dModulus = vU.Mod();
140 if (dModulus!=0.) vU.Set(dUX/dModulus,dUY/dModulus); // make length 1
141 else cerr<<"dModulus is zero!"<<endl;
142
143 TVector2 vQm = vQ;
8d312f00 144 //subtrackt particle from the flowvector if used to define it
e35ddff0 145 if (pTrack->UseForIntegratedFlow()) {
146 Double_t dQmX = vQm.X() - dUX;
147 Double_t dQmY = vQm.Y() - dUY;
148 vQm.Set(dQmX,dQmY);
8d312f00 149 }
150
e35ddff0 151 //dUQ = scalar product of vU and vQm
152 Double_t dUQ = vU * vQm;
153 Double_t dPt = pTrack->Pt();
8d312f00 154 //fill the profile histogram
e35ddff0 155 fHistProUQ->Fill(dPt,dUQ);
8d312f00 156 }
157 }//track selected
158 }//loop over tracks
d7eb18ec 159
8d312f00 160 fEventNumber++;
deebd72f 161 // cout<<"@@@@@ "<<fEventNumber<<" events processed"<<endl;
8d312f00 162 }
163}
164
165 //--------------------------------------------------------------------
166void AliFlowAnalysisWithScalarProduct::Finish() {
167
168 //*************make histograms etc.
169 if (fDebug) cout<<"AliFlowAnalysisWithScalarProduct::Terminate()"<<endl;
170
a58fb92e 171 // fHistProUQ->Draw();
e35ddff0 172
8d312f00 173 cout<<".....finished"<<endl;
174 }
8232a5ec 175
176