]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/FLOW/AliFlowAnalysisWithScalarProduct.cxx
macro and flowevent maker to run part of the code in root
[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    fEventNumber(0),
48    fDebug(kFALSE),
49    fHistList(NULL),
50    fHistProUQ(NULL),
51    fCommonHists(NULL)
52 {
53   // Constructor.
54   fHistList = new TList();
55 }
56  //-----------------------------------------------------------------------
57
58
59  AliFlowAnalysisWithScalarProduct::~AliFlowAnalysisWithScalarProduct() 
60  {
61    //destructor
62    delete fHistList;
63  }
64  
65
66 //-----------------------------------------------------------------------
67
68 void 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
77 //-----------------------------------------------------------------------
78 void AliFlowAnalysisWithScalarProduct::Init() {
79
80   //Define all histograms
81   cout<<"---Analysis with the Scalar Product Method--- Init"<<endl;
82
83   Int_t iNbinsPt = AliFlowCommonConstants::GetNbinsPt();
84   Double_t  dPtMin = AliFlowCommonConstants::GetPtMin();             
85   Double_t  dPtMax = AliFlowCommonConstants::GetPtMax();
86
87   fHistProUQ = new TProfile("Flow_UQ_SP","Flow_UQ_SP",iNbinsPt,dPtMin,dPtMax);
88   fHistProUQ->SetXTitle("p_t (GeV)");
89   fHistProUQ->SetYTitle("<uQ>");
90   fHistList->Add(fHistProUQ);
91
92   fCommonHists = new AliFlowCommonHist("AliFlowCommonHistSP");
93   fHistList->Add(fCommonHists);
94   
95   //fCommonHistsRes = new AliFlowCommonHistResults("SP");
96   
97   fEventNumber = 0;  //set number of events to zero    
98 }
99
100 //-----------------------------------------------------------------------
101  
102 void AliFlowAnalysisWithScalarProduct::Make(AliFlowEventSimple* anEvent) {
103
104   //Fill histogram
105   if (anEvent) {
106
107     //fill control histograms     
108     fCommonHists->FillControlHistograms(anEvent);
109          
110     //get the Q vector from the FlowEvent
111     AliFlowVector vQ = anEvent->GetQ();
112                 
113     //loop over the tracks of the event
114     AliFlowTrackSimple*   pTrack = NULL; 
115     Int_t iNumberOfTracks = anEvent->NumberOfTracks(); 
116     for (Int_t i=0;i<iNumberOfTracks;i++) 
117       {
118         pTrack = anEvent->GetTrack(i) ; 
119         if (pTrack){
120           if (pTrack->UseForDifferentialFlow()) {
121           Double_t dPhi = pTrack->Phi();
122
123           //calculate vU
124           TVector2 vU;
125           Double_t dUX = TMath::Cos(2*dPhi);
126           Double_t dUY = TMath::Sin(2*dPhi);
127           vU.Set(dUX,dUY);
128           Double_t dModulus = vU.Mod();
129           if (dModulus!=0.) vU.Set(dUX/dModulus,dUY/dModulus);  // make length 1
130           else cerr<<"dModulus is zero!"<<endl;
131
132           TVector2 vQm = vQ;
133           //subtrackt particle from the flowvector if used to define it
134           if (pTrack->UseForIntegratedFlow()) {
135             Double_t dQmX = vQm.X() - dUX;
136             Double_t dQmY = vQm.Y() - dUY;
137             vQm.Set(dQmX,dQmY);
138           }
139
140           //dUQ = scalar product of vU and vQm
141           Double_t dUQ = vU * vQm;
142           Double_t dPt = pTrack->Pt();
143           //fill the profile histogram
144           fHistProUQ->Fill(dPt,dUQ); 
145           }  
146         }//track selected
147       }//loop over tracks
148          
149     fEventNumber++;
150     cout<<"@@@@@ "<<fEventNumber<<" events processed"<<endl;
151   }
152 }
153
154   //--------------------------------------------------------------------    
155 void AliFlowAnalysisWithScalarProduct::Finish() {
156    
157   //*************make histograms etc. 
158   if (fDebug) cout<<"AliFlowAnalysisWithScalarProduct::Terminate()"<<endl;
159
160   //  fHistProUQ->Draw();
161           
162   cout<<".....finished"<<endl;
163  }
164
165