]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/FLOW/AliFlowAnalysisWithMCEventPlane.cxx
gain set to 1 for all ch
[u/mrichter/AliRoot.git] / PWG2 / FLOW / AliFlowAnalysisWithMCEventPlane.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 AliFlowAnalysisWithMCEventPlane_cxx
17  
18 #include "Riostream.h"  //needed as include
19 #include "TFile.h"      //needed as include
20 #include "TProfile.h"   //needed as include
21 #include "TComplex.h"   //needed as include
22 #include "TList.h"
23
24 class 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 "AliFlowAnalysisWithMCEventPlane.h"
32
33 class AliFlowVector;
34
35 // AliFlowAnalysisWithMCEventPlane:
36 // Description: Maker to analyze Flow from the generated MC reaction plane.
37 //              This class is used to get the real value of the flow 
38 //              to compare the other methods to when analysing simulated events
39 // author: N. van der Kolk (kolk@nikhef.nl)
40
41 ClassImp(AliFlowAnalysisWithMCEventPlane)
42
43   //-----------------------------------------------------------------------
44  
45  AliFlowAnalysisWithMCEventPlane::AliFlowAnalysisWithMCEventPlane():
46    fQsum(NULL),
47    fQ2sum(0),
48    fEventNumber(0),
49    fDebug(kFALSE),
50    fHistList(NULL),
51    fCommonHists(NULL),
52    fCommonHistsRes(NULL),
53    fHistProFlow(NULL),
54    fHistRP(NULL)
55
56 {
57
58   // Constructor.
59   fHistList = new TList();
60
61   fQsum = new TVector2;        // flow vector sum
62 }
63
64  
65  //-----------------------------------------------------------------------
66
67
68  AliFlowAnalysisWithMCEventPlane::~AliFlowAnalysisWithMCEventPlane() 
69  {
70    //destructor
71    delete fHistList;
72    delete fQsum;
73  }
74  
75
76 //-----------------------------------------------------------------------
77 void AliFlowAnalysisWithMCEventPlane::Init() {
78
79   //Define all histograms
80   cout<<"---Analysis with the real MC Event Plane---"<<endl;
81
82   Int_t iNbinsPt = AliFlowCommonConstants::GetNbinsPt();
83   Double_t  dPtMin = AliFlowCommonConstants::GetPtMin();             
84   Double_t  dPtMax = AliFlowCommonConstants::GetPtMax();
85
86   fCommonHists = new AliFlowCommonHist("MC");
87   fHistList->Add(fCommonHists->GetHistMultOrig());
88   fHistList->Add(fCommonHists->GetHistMultInt());
89   fHistList->Add(fCommonHists->GetHistMultDiff());
90   fHistList->Add(fCommonHists->GetHistPtInt());
91   fHistList->Add(fCommonHists->GetHistPtDiff());
92   fHistList->Add(fCommonHists->GetHistPhiInt());
93   fHistList->Add(fCommonHists->GetHistPhiDiff());
94   fHistList->Add(fCommonHists->GetHistEtaInt());
95   fHistList->Add(fCommonHists->GetHistEtaDiff());
96   fHistList->Add(fCommonHists->GetHistProMeanPtperBin());
97   fHistList->Add(fCommonHists->GetHistQ());
98   fCommonHistsRes = new AliFlowCommonHistResults("MC");
99   fHistList->Add(fCommonHistsRes->GetHistDiffFlow()); 
100   fHistList->Add(fCommonHistsRes->GetHistChi()); 
101   fHistList->Add(fCommonHistsRes->GetHistIntFlow()); 
102
103   fHistProFlow = new TProfile("FlowPro_VPt_MC","FlowPro_VPt_MC",iNbinsPt,dPtMin,dPtMax);
104   fHistProFlow->SetXTitle("Pt");
105   fHistProFlow->SetYTitle("v2 (%)");
106   fHistList->Add(fHistProFlow);
107
108   fHistRP = new TH1F("Flow_RP_MC","Flow_RP_MC",100,0.,3.14);
109   fHistRP->SetXTitle("Reaction Plane Angle");
110   fHistRP->SetYTitle("Counts");
111   fHistList->Add(fHistRP);
112
113  
114   fEventNumber = 0;  //set number of events to zero
115       
116
117  
118 //-----------------------------------------------------------------------
119  
120 void AliFlowAnalysisWithMCEventPlane::Make(AliFlowEventSimple* anEvent, Double_t aRP) {
121
122   //Calculate v2 from the MC reaction plane
123   if (anEvent) {
124          
125     //fill control histograms     
126     fCommonHists->FillControlHistograms(anEvent);
127
128     //get the Q vector from the FlowEvent
129     AliFlowVector vQ = anEvent->GetQ(); 
130     //cout<<"vQ.Mod() = " << vQ.Mod() << endl;
131     //for chi calculation:
132     *fQsum += vQ;
133     //cout<<"fQsum.Mod() = "<<fQsum.Mod()<<endl;
134     fQ2sum += vQ.Mod2();
135     cout<<"fQ2sum = "<<fQ2sum<<endl;
136         
137     fHistRP->Fill(aRP);   
138               
139     //calculate flow
140     //loop over the tracks of the event
141     Int_t iNumberOfTracks = anEvent->NumberOfTracks(); 
142     for (Int_t i=0;i<iNumberOfTracks;i++) 
143       {
144         AliFlowTrackSimple* pTrack = anEvent->GetTrack(i) ; 
145         if (pTrack){
146           if (pTrack->UseForDifferentialFlow()) {
147             Double_t dPhi = pTrack->Phi();
148             //if (dPhi<0.) dPhi+=2*TMath::Pi();
149             //calculate flow v2:
150             Double_t dv2 = TMath::Cos(2*(dPhi-aRP));
151             Double_t dPt = pTrack->Pt();
152             //fill histogram
153             fHistProFlow->Fill(dPt,100*dv2);  
154           }  
155         }//track selected
156       }//loop over tracks
157           
158     fEventNumber++;
159     cout<<"@@@@@ "<<fEventNumber<<" events processed"<<endl;
160   }
161 }
162
163   //--------------------------------------------------------------------    
164 void AliFlowAnalysisWithMCEventPlane::Finish() {
165    
166   //*************make histograms etc. 
167   if (fDebug) cout<<"AliFlowAnalysisWithMCEventPlane::Terminate()"<<endl;
168      
169   Int_t iNbinsPt = AliFlowCommonConstants::GetNbinsPt();
170     
171   TH1F* fHistPtDiff = fCommonHists->GetHistPtDiff();
172   Double_t dV = 0.;
173   Double_t dErrV = 0.;
174   Double_t dSum = 0.;
175   for(Int_t b=0;b<iNbinsPt;b++){
176     Double_t dv2pro = 0.;
177     Double_t dErrdifcomb = 0.; //in case error from profile is correct
178     if(fHistProFlow) {
179       dv2pro = fHistProFlow->GetBinContent(b);
180       dErrdifcomb = fHistProFlow->GetBinError(b);
181       //fill TH1D
182       fCommonHistsRes->FillDifferentialFlow(b, dv2pro, dErrdifcomb); 
183       if (fHistPtDiff){
184         //integrated flow
185         Double_t dYield = fHistPtDiff->GetBinContent(b);
186         dV += dv2pro/100*dYield ;
187         dSum += dYield;
188         //error on integrated flow
189         dErrV += dYield*dYield*(dErrdifcomb/100)*(dErrdifcomb/100);
190       }
191     }
192   }
193   dV /= dSum;  //because pt distribution should be normalised
194   dErrV /= dSum*dSum;
195   dErrV = TMath::Sqrt(dErrV);
196   cout<<"dV is "<<dV<<" +- "<<dErrV<<endl;
197   fCommonHistsRes->FillIntegratedFlow(dV,dErrV); 
198           
199   cout<<".....finished"<<endl;
200  }
201
202