]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/FLOW/AliFlowLYZEventPlane.cxx
gain set to 1 for all ch
[u/mrichter/AliRoot.git] / PWG2 / FLOW / AliFlowLYZEventPlane.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 AliFlowAnalysisWithLYZEventPlane_cxx
17
18 // AliFlowLYZEventPlane:
19 //
20 // Class to calculate the event plane and event weight from the LYZ method
21 // It needs input from the standard LYZ first and second run
22 // author: N. van der Kolk (kolk@nikhef.nl)
23  
24 #include "Riostream.h"
25 #include "TProfile.h"
26 #include "TFile.h"
27 #include "TComplex.h"
28
29 #include "AliFlowVector.h"
30 #include "AliFlowLYZConstants.h"
31 #include "AliFlowEventSimple.h"
32 #include "AliFlowLYZEventPlane.h"
33
34 class AliFlowTrackSimple;
35
36 ClassImp(AliFlowLYZEventPlane)
37
38   //-----------------------------------------------------------------------
39   
40 AliFlowLYZEventPlane::AliFlowLYZEventPlane():
41   fSecondRunFile(0),
42   fSecondRunFileName("noname.ESD"),
43   fWR(0),            
44   fPsi(0),
45   fSecondReDtheta(0),
46   fSecondImDtheta(0),
47   fFirstr0theta(0)
48 {
49   // Constructor.
50   
51 }
52 //-----------------------------------------------------------------------
53
54
55 AliFlowLYZEventPlane::~AliFlowLYZEventPlane() 
56 {
57   //destructor
58    
59 }
60  
61
62 //-----------------------------------------------------------------------
63 void AliFlowLYZEventPlane::Init() 
64 {
65   //Declare histograms & get input files
66   cout<<"---Lee Yang Zeros Event Plane Method---"<<endl;
67
68   //input histograms
69   if (fSecondRunFile->IsZombie()){ //check if file exists
70     cout << "Error opening file, run first regular LYZ second run" << endl;
71     exit(-1);
72   } else if (fSecondRunFile->IsOpen()){
73     cout<<"----secondRunFile is open----"<<endl;
74     //get List
75     TList* list = (TList*)fSecondRunFile->Get("cobj1");
76     fSecondReDtheta = ( TProfile*)list->FindObject("Second_FlowPro_ReDtheta_LYZ");
77     fSecondImDtheta = ( TProfile*)list->FindObject("Second_FlowPro_ImDtheta_LYZ");
78     fFirstr0theta   = ( TProfile*)list->FindObject("First_FlowPro_r0theta_LYZ");
79   }
80
81 }
82
83 //-----------------------------------------------------------------------
84 void AliFlowLYZEventPlane::CalculateRPandW(AliFlowVector aQ)
85 {
86   //declare variables
87   Int_t iNtheta = AliFlowLYZConstants::kTheta;
88   Double_t dCosTerm = 0;
89   Double_t dSinTerm = 0;
90   TComplex cDtheta;
91   TComplex cRatio;
92
93   for (Int_t theta=0;theta<iNtheta;theta++)     {
94     Double_t dTheta = ((float)theta/iNtheta)*TMath::Pi()/2;  
95     //Calculate Qtheta 
96     Double_t dQtheta = aQ.X()*cos(2*dTheta)+aQ.Y()*sin(2*dTheta);  //get Qtheta from Q vector
97             
98     //get R0
99     Double_t dR0 = fFirstr0theta->GetBinContent(theta+1); 
100     //cerr<<"dR0 = "<<dR0<<endl;
101
102     //get Dtheta
103     Double_t dReDtheta = fSecondReDtheta->GetBinContent(theta+1);
104     //cerr<<"dReDtheta = "<<dReDtheta<<endl;
105     Double_t dImDtheta = fSecondImDtheta->GetBinContent(theta+1);
106     //cerr<<"dImDtheta = "<<dImDtheta<<endl;
107     cDtheta(dReDtheta,dImDtheta);
108     
109     TComplex cExpo(0.,dR0*dQtheta);                  //Complex number: 0 +(i r0 Qtheta)
110     if (cDtheta.Rho()!=0.) { cRatio =(TComplex::Exp(cExpo))/cDtheta; } //(e^(i r0 Qtheta))/Dtheta
111     else { cRatio(0.,0.); }
112       
113     //sum over theta
114     dCosTerm += cRatio.Re() * TMath::Cos(2*dTheta);    //Re{(e^(i r0 Qtheta))/Dtheta } cos(2 theta)  
115     dSinTerm += cRatio.Re() * TMath::Sin(2*dTheta);    //Re{(e^(i r0 Qtheta))/Dtheta } sin(2 theta)
116       
117   }//loop over theta
118
119   //average over theta
120   dCosTerm /= iNtheta;  
121   dSinTerm /= iNtheta;
122   //cerr<<"cosTerm & sinTerm are: "<<dCosTerm<<" & "<<dSinTerm<<endl;
123     
124   //calculate fWR
125   fWR = TMath::Sqrt(dCosTerm*dCosTerm + dSinTerm*dSinTerm);
126         
127   //calculate fRP
128   fPsi = 0.5*TMath::ATan2(dSinTerm,dCosTerm);   //takes care of the signs correctly!
129   if (fPsi < 0.) { fPsi += TMath::Pi(); }       //to shift distribution from (-pi/2 to pi/2) to (0 to pi)
130   
131 }
132