ROOT logo
/*************************************************************************
* Copyright(c) 1998-2008, ALICE Experiment at CERN, All rights reserved. *
*                                                                        *
* Author: The ALICE Off-line Project.                                    *
* Contributors are mentioned in the code where appropriate.              *
*                                                                        *
* Permission to use, copy, modify and distribute this software and its   *
* documentation strictly for non-commercial purposes is hereby granted   *
* without fee, provided that the above copyright notice appears in all   *
* copies and that both the copyright notice and this permission notice   *
* appear in the supporting documentation. The authors make no claims     *
* about the suitability of this software for any purpose. It is          *
* provided "as is" without express or implied warranty.                  * 
**************************************************************************/

#define AliFlowAnalysisWithLYZEventPlane_cxx

// AliFlowLYZEventPlane:
//
// Class to calculate the event plane and event weight from the LYZ method
// It needs input from the standard LYZ first and second run
// author: N. van der Kolk (kolk@nikhef.nl)
 
#include "Riostream.h"
#include "TProfile.h"
#include "TFile.h"
#include "TComplex.h"
#include "TList.h"

#include "AliFlowVector.h"
#include "AliFlowLYZConstants.h"
#include "AliFlowEventSimple.h"
#include "AliFlowLYZEventPlane.h"

class AliFlowTrackSimple;

using std::cout;
using std::endl;
ClassImp(AliFlowLYZEventPlane)

  //-----------------------------------------------------------------------
  
AliFlowLYZEventPlane::AliFlowLYZEventPlane():
  fSecondRunList(0),
  fWR(0),            
  fPsi(0),
  fSecondReDtheta(0),
  fSecondImDtheta(0),
  fFirstr0theta(0)
{
  // Constructor.
  
}
//-----------------------------------------------------------------------


AliFlowLYZEventPlane::~AliFlowLYZEventPlane() 
{
  //destructor
  delete fSecondRunList;
}
 

//-----------------------------------------------------------------------
void AliFlowLYZEventPlane::Init() 
{
  //Declare histograms & get input files
  cout<<"---Lee Yang Zeros Event Plane Method---"<<endl;

  //input histograms
  if (fSecondRunList) {
    fSecondReDtheta = (TProfile*)fSecondRunList->FindObject("Second_FlowPro_ReDtheta_LYZSUM");
    fSecondImDtheta = (TProfile*)fSecondRunList->FindObject("Second_FlowPro_ImDtheta_LYZSUM");
    fFirstr0theta   = (TProfile*)fSecondRunList->FindObject("First_FlowPro_r0theta_LYZSUM");

    //warnings
    if (!fSecondReDtheta) {cout<<"fSecondReDtheta is NULL!"<<endl; }
    if (!fSecondImDtheta) {cout<<"fSecondImDtheta is NULL!"<<endl; }
    if (!fFirstr0theta)   {cout<<"fFirstr0theta is NULL!"<<endl; }
  }


}

//-----------------------------------------------------------------------
void AliFlowLYZEventPlane::CalculateRPandW(AliFlowVector aQ)
{
  //declare variables
  Int_t iNtheta = AliFlowLYZConstants::GetMaster()->GetNtheta();
  Double_t dCosTerm = 0;
  Double_t dSinTerm = 0;
  TComplex cDtheta;
  TComplex cRatio;
  
  if (aQ.Mod()==0.) { cout<<"Q vector is NULL"<<endl; }
  else {
    for (Int_t theta=0;theta<iNtheta;theta++)	{
      Double_t dTheta = ((float)theta/iNtheta)*TMath::Pi()/2;  
      //Calculate Qtheta 
      Double_t dQtheta = aQ.X()*cos(2*dTheta)+aQ.Y()*sin(2*dTheta);  //get Qtheta from Q vector
            
      //get R0
      Double_t dR0 = fFirstr0theta->GetBinContent(theta+1); 
      //cerr<<"dR0 = "<<dR0<<endl;

      //get Dtheta
      Double_t dReDtheta = fSecondReDtheta->GetBinContent(theta+1);
      //cerr<<"dReDtheta = "<<dReDtheta<<endl;
      Double_t dImDtheta = fSecondImDtheta->GetBinContent(theta+1);
      //cerr<<"dImDtheta = "<<dImDtheta<<endl;
      cDtheta(dReDtheta,dImDtheta);
    
      TComplex cExpo(0.,dR0*dQtheta);                  //Complex number: 0 +(i r0 Qtheta)
      if (cDtheta.Rho()!=0.) { cRatio =(TComplex::Exp(cExpo))/cDtheta; } //(e^(i r0 Qtheta))/Dtheta
      else { cRatio(0.,0.); }
      
      //sum over theta
      dCosTerm += cRatio.Re() * TMath::Cos(2*dTheta);    //Re{(e^(i r0 Qtheta))/Dtheta } cos(2 theta)  
      dSinTerm += cRatio.Re() * TMath::Sin(2*dTheta);    //Re{(e^(i r0 Qtheta))/Dtheta } sin(2 theta)
      
    }//loop over theta

    //average over theta
    dCosTerm /= iNtheta;  
    dSinTerm /= iNtheta;
    //cerr<<"cosTerm & sinTerm are: "<<dCosTerm<<" & "<<dSinTerm<<endl;
    
    //calculate fWR
    fWR = TMath::Sqrt(dCosTerm*dCosTerm + dSinTerm*dSinTerm);
        
    //calculate fRP
    fPsi = 0.5*TMath::ATan2(dSinTerm,dCosTerm);   //takes care of the signs correctly!
    if (fPsi < 0.) { fPsi += TMath::Pi(); }       //to shift distribution from (-pi/2 to pi/2) to (0 to pi)
  }

}

 AliFlowLYZEventPlane.cxx:1
 AliFlowLYZEventPlane.cxx:2
 AliFlowLYZEventPlane.cxx:3
 AliFlowLYZEventPlane.cxx:4
 AliFlowLYZEventPlane.cxx:5
 AliFlowLYZEventPlane.cxx:6
 AliFlowLYZEventPlane.cxx:7
 AliFlowLYZEventPlane.cxx:8
 AliFlowLYZEventPlane.cxx:9
 AliFlowLYZEventPlane.cxx:10
 AliFlowLYZEventPlane.cxx:11
 AliFlowLYZEventPlane.cxx:12
 AliFlowLYZEventPlane.cxx:13
 AliFlowLYZEventPlane.cxx:14
 AliFlowLYZEventPlane.cxx:15
 AliFlowLYZEventPlane.cxx:16
 AliFlowLYZEventPlane.cxx:17
 AliFlowLYZEventPlane.cxx:18
 AliFlowLYZEventPlane.cxx:19
 AliFlowLYZEventPlane.cxx:20
 AliFlowLYZEventPlane.cxx:21
 AliFlowLYZEventPlane.cxx:22
 AliFlowLYZEventPlane.cxx:23
 AliFlowLYZEventPlane.cxx:24
 AliFlowLYZEventPlane.cxx:25
 AliFlowLYZEventPlane.cxx:26
 AliFlowLYZEventPlane.cxx:27
 AliFlowLYZEventPlane.cxx:28
 AliFlowLYZEventPlane.cxx:29
 AliFlowLYZEventPlane.cxx:30
 AliFlowLYZEventPlane.cxx:31
 AliFlowLYZEventPlane.cxx:32
 AliFlowLYZEventPlane.cxx:33
 AliFlowLYZEventPlane.cxx:34
 AliFlowLYZEventPlane.cxx:35
 AliFlowLYZEventPlane.cxx:36
 AliFlowLYZEventPlane.cxx:37
 AliFlowLYZEventPlane.cxx:38
 AliFlowLYZEventPlane.cxx:39
 AliFlowLYZEventPlane.cxx:40
 AliFlowLYZEventPlane.cxx:41
 AliFlowLYZEventPlane.cxx:42
 AliFlowLYZEventPlane.cxx:43
 AliFlowLYZEventPlane.cxx:44
 AliFlowLYZEventPlane.cxx:45
 AliFlowLYZEventPlane.cxx:46
 AliFlowLYZEventPlane.cxx:47
 AliFlowLYZEventPlane.cxx:48
 AliFlowLYZEventPlane.cxx:49
 AliFlowLYZEventPlane.cxx:50
 AliFlowLYZEventPlane.cxx:51
 AliFlowLYZEventPlane.cxx:52
 AliFlowLYZEventPlane.cxx:53
 AliFlowLYZEventPlane.cxx:54
 AliFlowLYZEventPlane.cxx:55
 AliFlowLYZEventPlane.cxx:56
 AliFlowLYZEventPlane.cxx:57
 AliFlowLYZEventPlane.cxx:58
 AliFlowLYZEventPlane.cxx:59
 AliFlowLYZEventPlane.cxx:60
 AliFlowLYZEventPlane.cxx:61
 AliFlowLYZEventPlane.cxx:62
 AliFlowLYZEventPlane.cxx:63
 AliFlowLYZEventPlane.cxx:64
 AliFlowLYZEventPlane.cxx:65
 AliFlowLYZEventPlane.cxx:66
 AliFlowLYZEventPlane.cxx:67
 AliFlowLYZEventPlane.cxx:68
 AliFlowLYZEventPlane.cxx:69
 AliFlowLYZEventPlane.cxx:70
 AliFlowLYZEventPlane.cxx:71
 AliFlowLYZEventPlane.cxx:72
 AliFlowLYZEventPlane.cxx:73
 AliFlowLYZEventPlane.cxx:74
 AliFlowLYZEventPlane.cxx:75
 AliFlowLYZEventPlane.cxx:76
 AliFlowLYZEventPlane.cxx:77
 AliFlowLYZEventPlane.cxx:78
 AliFlowLYZEventPlane.cxx:79
 AliFlowLYZEventPlane.cxx:80
 AliFlowLYZEventPlane.cxx:81
 AliFlowLYZEventPlane.cxx:82
 AliFlowLYZEventPlane.cxx:83
 AliFlowLYZEventPlane.cxx:84
 AliFlowLYZEventPlane.cxx:85
 AliFlowLYZEventPlane.cxx:86
 AliFlowLYZEventPlane.cxx:87
 AliFlowLYZEventPlane.cxx:88
 AliFlowLYZEventPlane.cxx:89
 AliFlowLYZEventPlane.cxx:90
 AliFlowLYZEventPlane.cxx:91
 AliFlowLYZEventPlane.cxx:92
 AliFlowLYZEventPlane.cxx:93
 AliFlowLYZEventPlane.cxx:94
 AliFlowLYZEventPlane.cxx:95
 AliFlowLYZEventPlane.cxx:96
 AliFlowLYZEventPlane.cxx:97
 AliFlowLYZEventPlane.cxx:98
 AliFlowLYZEventPlane.cxx:99
 AliFlowLYZEventPlane.cxx:100
 AliFlowLYZEventPlane.cxx:101
 AliFlowLYZEventPlane.cxx:102
 AliFlowLYZEventPlane.cxx:103
 AliFlowLYZEventPlane.cxx:104
 AliFlowLYZEventPlane.cxx:105
 AliFlowLYZEventPlane.cxx:106
 AliFlowLYZEventPlane.cxx:107
 AliFlowLYZEventPlane.cxx:108
 AliFlowLYZEventPlane.cxx:109
 AliFlowLYZEventPlane.cxx:110
 AliFlowLYZEventPlane.cxx:111
 AliFlowLYZEventPlane.cxx:112
 AliFlowLYZEventPlane.cxx:113
 AliFlowLYZEventPlane.cxx:114
 AliFlowLYZEventPlane.cxx:115
 AliFlowLYZEventPlane.cxx:116
 AliFlowLYZEventPlane.cxx:117
 AliFlowLYZEventPlane.cxx:118
 AliFlowLYZEventPlane.cxx:119
 AliFlowLYZEventPlane.cxx:120
 AliFlowLYZEventPlane.cxx:121
 AliFlowLYZEventPlane.cxx:122
 AliFlowLYZEventPlane.cxx:123
 AliFlowLYZEventPlane.cxx:124
 AliFlowLYZEventPlane.cxx:125
 AliFlowLYZEventPlane.cxx:126
 AliFlowLYZEventPlane.cxx:127
 AliFlowLYZEventPlane.cxx:128
 AliFlowLYZEventPlane.cxx:129
 AliFlowLYZEventPlane.cxx:130
 AliFlowLYZEventPlane.cxx:131
 AliFlowLYZEventPlane.cxx:132
 AliFlowLYZEventPlane.cxx:133
 AliFlowLYZEventPlane.cxx:134
 AliFlowLYZEventPlane.cxx:135
 AliFlowLYZEventPlane.cxx:136
 AliFlowLYZEventPlane.cxx:137