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