ROOT logo
int drawMB=0;

void GetNU(int side=0){

gStyle->SetOptStat(0);

  TFile * f = new TFile("flow11h_QA.root") ;

  TFile * f2 = new TFile("flow11hMB_QA.root") ;

  char what[20];
  if(side==0) sprintf(what,"phiRPV0Aflat") ;
  if(side==1) sprintf(what,"phiRPV0Cflat") ;
  if(side==2) sprintf(what,"phiRPflat") ;

  TH2F* h=f->Get(what);
  TH2F* h2=f2->Get(what);

  TH3D* hPHOSphi=f->Get("hPHOSphi");

  TF1 *fu=new TF1("fu","[0]*(1+2*[1]*TMath::Cos(2*x)+2*[2]*TMath::Sin(2*x))",1,5);

  TH1D* hcos=new TH1D("cos","cos",10,0.,50.);
  TH1D* hsin=new TH1D("sin","sin",10,0.,50.);
  TH1D* hcosMB=new TH1D("cosMB","cosMB",10,0.,50.);
  TH1D* hsinMB=new TH1D("sinMB","sinMB",10,0.,50.);
  TH1D* hsinv2=new TH1D("sinv2","sinv2",10,0.,50.);

  for(int cen=1;cen<=10;cen++){
  char name[255];
  sprintf(name,"phi_%d",cen);
  TH3D* hphi = hPHOSphi->Clone(name);
  hphi->GetXaxis()->SetRangeUser((cen-1)*5,(cen)*5);
  TH1D* hCos=hphi->Project3D("z");

  double meanC=0,meanS=0,errC=0,errS=0,mean=0;

  for(int i=0;i<hCos->GetXaxis()->GetNbins();i++){
    double bin=hCos->GetBinContent(i+1);
    double err=hCos->GetBinError(i+1);
    double phi=hCos->GetBinCenter(i+1);
    mean+=bin;
    meanC+=TMath::Cos(2*phi)*bin;
    meanS+=TMath::Sin(2*phi)*bin;
    errC+=TMath::Cos(2*phi)*err;
    errS+=TMath::Cos(2*phi)*err;
  }
  meanC/=mean;
  meanS/=mean;
  errC/=mean;
  errS/=mean;

  cout<<"i: "<<cen<<", cos: "<<meanC<<"+-"<<errC<<", sin: "<<meanS<<"+-"<<errS<<endl;

    char name[255];
    sprintf(name,"EP_cen%d",cen);
    TH1D * h1D = h->ProjectionX(name,cen,cen) ;
    sprintf(name,"MB_cen%d",cen);
    TH1D * h1DMB = h2->ProjectionX(name,cen,cen) ;

    h1D->Fit(fu,"q0");

    double sinv2 = meanS*fu->GetParameter(1) - meanC*fu->GetParameter(2);
    double err = meanS*fu->GetParError(1) + errS*fu->GetParameter(1);

    hsinv2->SetBinContent(cen,sinv2);
    hsinv2->SetBinError(cen,err);

    hcos->SetBinContent(cen,fu->GetParameter(1));
    hcos->SetBinError(cen,fu->GetParError(1));
    hsin->SetBinContent(cen,fu->GetParameter(2));
    hsin->SetBinError(cen,fu->GetParError(2));

    h1DMB->Fit(fu,"q0");

    hcosMB->SetBinContent(cen,fu->GetParameter(1));
    hcosMB->SetBinError(cen,fu->GetParError(1));
    hsinMB->SetBinContent(cen,fu->GetParameter(2));
    hsinMB->SetBinError(cen,fu->GetParError(2));
  }

  if(side==0)  hcos->SetTitle("V0A EP");
  if(side==1)  hcos->SetTitle("V0C EP");
  if(side==2)  hcos->SetTitle("TPC EP");

  hcos->SetMarkerStyle(20) ; 
  hcos->SetMarkerColor(2) ; 
  hcos->SetLineColor(2) ; 
  hcos->SetLineWidth(3);

  hcos->SetMinimum(-0.01) ;
  hcos->SetMaximum(0.01) ;
  hcos->SetXTitle("centrality") ;
  hcos->SetYTitle("<cos2#Psi> and <sin2#Psi") ;

  hsin->SetMarkerStyle(20) ;
  hsin->SetMarkerColor(3) ;
  hsin->SetLineColor(3) ;
  hsin->SetLineWidth(2);

  hcosMB->SetMarkerStyle(25) ;
  hcosMB->SetMarkerColor(2) ;
  hcosMB->SetLineColor(2) ;
  hcosMB->SetLineWidth(3);

  hsinMB->SetMarkerStyle(25) ;
  hsinMB->SetMarkerColor(3) ;
  hsinMB->SetLineColor(3) ;
  hsinMB->SetLineWidth(2);

  hsinv2->SetMarkerStyle(20) ;
  hsinv2->SetMarkerColor(4) ;
  hsinv2->SetLineColor(4) ;
  hsinv2->SetLineWidth(2);


  hcos->Draw("pl") ;
  hsin->Draw("pl same") ;
  hsinv2->Draw("pl same");
  if(drawMB){
    hcosMB->Draw("pl same") ;
    hsinMB->Draw("pl same") ;
  }

  TLegend * leg = new TLegend(0.6,0.7,0.9,0.9) ;
  leg->AddEntry(hcos,"cos2#Psi","p") ;
  leg->AddEntry(hsin,"sin2#Psi","p") ;
  leg->AddEntry(hsinv2,"sin2#phi*cos2#Psi - cos2#phi*sin2#Psi","p") ;

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