StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
doVogel.C
1 //-----------------------------------------------------
2 //* Fit pQCD and calculate corrections finite bin width
3 //-----------------------------------------------------
4 void doVogel(int trig)
5 {
6  gSystem->Load("gamma/analysis/lib/AnaCuts");
7 
8  AnaCuts *cuts=new AnaCuts("dAu");
9 
10  char *gifout;
11  Int_t nbins;
12  TArrayD bins;
13  TH1F *h;
14 
15  if(trig==1){
16  nbins=cuts->nPtBinsMB;
17  bins=cuts->ptBinsMB;
18  h=new TH1F("h","h",nbins,bins.GetArray());
19  gifout="mbbincorr.gif";
20  }
21  else if(trig==2){
22  nbins=cuts->nPtBinsHT1;
23  bins=cuts->ptBinsHT1;
24  h=new TH1F("h","h",nbins,bins.GetArray());
25  gifout="ht1bincorr.gif";
26  }
27  else if(trig==3){
28  nbins=cuts->nPtBinsHT2;
29  bins=cuts->ptBinsHT2;
30  h=new TH1F("h","h",nbins,bins.GetArray());
31  gifout="ht2bincorr.gif";
32  }
33  else
34  cout<<"error"<<endl;
35 
36 
37  for(Int_t b=1;b<=nbins;b++){
38  Float_t xmin=bins[b-1];
39  Float_t xmax=bins[b];
40  Float_t dpT=xmax-xmin;
41  Float_t pT=xmin + 0.5*dpT;
42 
43  cout<<xmin<<" "<<xmax<<" "<<dpT<<" "<<pT<<endl;
44 
45  TF1 *fit=new TF1("fit","[0]*pow(1.+x,[1])*pow(x,[2])",1.,7.);
46  if(trig==2) fit->SetRange(4.,10.);
47  if(trig==3) fit->SetRange(8.,15.);
48  fit->SetParameters(1.,-10.,0.0);
49  fit->FixParameter(2,0.);
50 
51  ifstream in("./pQCD.dat");
52  Float_t x[100];
53  Float_t y[100];
54  Int_t i=0;
55  while(i<28){
56  if(!in.good()) break;
57  in >> x[i] >> y[i];
58  i++;
59  }
60 
61  TGraph *g=new TGraph(i,x,y);
62  g->Fit("fit","QR");
63  fit->SetRange(0.,15.);
64  TF1 *N=new TF1(*fit);
65  N->FixParameter(2,1.);
66 
67  //now this is N(p_{T})
68  Float_t ratio=fit->Eval(pT)/(N->Integral(xmin,xmax)/(pT*dpT));
69  h->Fill(pT,ratio);
70  }
71 
72  h->SetBinContent(1,0);
73  h->SetMaximum(1.2);
74  h->SetMinimum(.6);
75  TCanvas *c=new TCanvas("c","c",800,400);
76  c->Divide(2,1);
77  c->cd(1);
78  gPad->SetLogy();
79  g->SetMaximum(10.e+10);
80  g->SetMinimum(1.);
81  g->Draw("ap");
82  g->SetMarkerStyle(8);
83  fit->Draw("same");
84  c->cd(2);
85  h->Draw();
86  h->SetLineWidth(2);
87  c->cd(0);
88  c->SaveAs("vogelsang.eps");
89 
90  TCanvas *cc=new TCanvas("cc","cc",300,300);
91  h->Draw();
92  cc->SaveAs(gifout);
93 
94  char *hname;
95  if(trig==1) hname="h4mb";
96  else if(trig==2) hname="h4ht1";
97  else if(trig==3) hname="h4ht2";
98  else return;
99  TFile *outf=new TFile("bincorrections.root","UPDATE");
100  h->Write(hname,2,0);
101  outf->Close();
102 }
103 
104