]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGDQ/dielectron/TakuAlberica/pair/makefig.C
Merge branch 'feature-movesplit'
[u/mrichter/AliRoot.git] / PWGDQ / dielectron / TakuAlberica / pair / makefig.C
1 void makefig(const int trig=0, const int icut=0, const int icent=0){
2
3   gStyle->SetPalette(1);
4   gStyle->SetOptStat(0);
5   gStyle->SetOptFit(111111);
6   gStyle->SetOptFit(0);
7   gStyle->SetOptTitle(0);
8   //gStyle->SetFillColor(10);
9   gStyle->SetCanvasColor(10);
10   gStyle->SetFrameBorderMode(0);
11   gStyle->SetFrameFillColor(0);
12   gStyle->SetCanvasColor(0);
13   gStyle->SetPadBorderSize(0);
14   gStyle->SetCanvasBorderSize(0);
15   //gStyle->SetPadLeftMargin(0.15);
16   gStyle->SetPadLeftMargin(0.125);
17   gStyle->SetPadBottomMargin(0.125);
18   gStyle->SetPadTopMargin(0.1);
19   gStyle->SetTitleYOffset(1.3);
20   //gStyle->SetPadLeftMargin(0.1);
21   gStyle->SetTitleW(0.7);
22   gStyle->SetTitleH(0.1);
23   cout<<"physics is always fun! "<<endl; 
24
25   TH2D *hmasspt[7][11];
26
27   ////// input root file ///////////////
28   char name[100];
29   sprintf(name,"result_trig%d_cut%d.root", trig, icut);
30   TFile *fin = new TFile(name,"read");
31
32   for(int i=0;i<7;i++){
33     sprintf(name,"hmasspt_mb_%d",i);
34     hmasspt[i][10] = new TH2D(name, name, 500, 0, 5, 500, 0, 5);
35   }    
36
37   ////// add into the histograms //////////////////
38   for(int i=0;i<7;i++){
39     for(int j=0;j<10;j++){
40       sprintf(name,"hmasspt_cent%d_pair%d", j, i);
41       hmasspt[i][j] = (TH2D*)fin->Get(name);
42       hmasspt[i][10]->Add(hmasspt[i][j]);
43     }
44   }
45
46
47   TH1D *hpy = hmasspt[0][0]->ProjectionY("hpy");
48   
49   ////// range of pT /////////////////////////////////
50   int npt=3;
51   float low[4] ={0, 1, 2};
52   float high[4]={1, 2, 4};
53   
54   //// [pairtype][pt] //////////////////////////////
55   TH1D *hmass[7][4]; ///sliced mass spectrum
56   for(int i=0;i<7;i++){
57     for(int ipt=0;ipt<npt;ipt++){
58       int rangelow = hpy->FindBin(low[ipt]);  
59       int rangehigh = hpy->FindBin(high[ipt]);
60       sprintf(name,"hmass_tmp_pt%d_cent%d_%d",ipt, icent, i);
61       hmass[i][ipt] = (TH1D*)hmasspt[i][icent]->ProjectionX(name, rangelow, rangehigh-1);
62     }
63   }
64
65   //////// another historgram to merge like sign/mixed like sign
66   //////// hmass_add will be scaled.
67   ///////  hmass_org will be unchanged.
68   TH1D *hmass_add[4][4];
69   TH1D *hmass_org[4][4];
70   for(int i=0;i<4;i++){
71     for(int ipt=0;ipt<npt;ipt++){
72       sprintf(name,"hmass_pt%d_cent%d_%d",ipt, j, i);
73       hmass_add[i][ipt] = new TH1D(name, name, 500, 0, 5);
74       hmass_add[i][ipt]->Sumw2();
75       sprintf(name,"hmass_pt%d_cent%d_%d_org",ipt, j, i);
76       hmass_org[i][ipt] = new TH1D(name, name, 500, 0, 5);
77       hmass_org[i][ipt]->Sumw2();
78     }
79   }
80   for(int ipt=0;ipt<npt;ipt++){
81     hmass_add[0][ipt]->Add(hmass[0][ipt]);
82     hmass_add[1][ipt]->Add(hmass[1][ipt]);
83     hmass_add[1][ipt]->Add(hmass[2][ipt]);
84     hmass_add[2][ipt]->Add(hmass[3][ipt]);
85     hmass_add[2][ipt]->Add(hmass[4][ipt]);
86     hmass_add[3][ipt]->Add(hmass[5][ipt]);
87     hmass_add[3][ipt]->Add(hmass[6][ipt]);
88
89     hmass_org[0][ipt]->Add(hmass[0][ipt]);
90     hmass_org[1][ipt]->Add(hmass[1][ipt]);
91     hmass_org[1][ipt]->Add(hmass[2][ipt]);
92     hmass_org[2][ipt]->Add(hmass[3][ipt]);
93     hmass_org[2][ipt]->Add(hmass[4][ipt]);
94     hmass_org[3][ipt]->Add(hmass[5][ipt]);
95     hmass_org[3][ipt]->Add(hmass[6][ipt]);
96
97
98     ///// scaling factor for like sign and mixed like sign
99     float scale1 = hmass_add[0][ipt]->GetEntries()/(2*sqrt(hmass[1][ipt]->GetEntries()*hmass[2][ipt]->GetEntries()));
100     float scale2 = hmass_add[2][ipt]->GetEntries()/(2*sqrt(hmass[5][ipt]->GetEntries()*hmass[6][ipt]->GetEntries()));
101     
102     hmass_add[1][ipt]->Scale(scale1);
103     hmass_add[3][ipt]->Scale(scale2);
104     hmass_org[1][ipt]->Scale(scale1);
105     hmass_org[3][ipt]->Scale(scale2);
106   }
107
108
109   ///// then take ratio of mixed unlike / mixed like
110   TH1F *hdiv[4]; 
111   for(int ipt=0;ipt<npt;ipt++){
112     sprintf(name,"hdiv_pt%d",ipt);
113     hdiv[ipt] = new TH1F(name, name, 500, 0, 5);
114     hdiv[ipt]->Sumw2();
115     hdiv[ipt]->Divide(hmass_add[2][ipt], hmass_add[3][ipt]);
116     hdiv[ipt]->SetMaximum(2);
117     hdiv[ipt]->SetMinimum(0);
118
119     //// multiply to like sign 
120     hmass_add[1][ipt]->Multiply(hdiv[ipt]);
121
122   }
123
124   TCanvas *c0 = new TCanvas("c0","c0",1200,800);
125   c0->Divide(npt,2);
126   for(int ipt=0;ipt<npt;ipt++){
127     c0->cd(ipt+1);
128     gPad->SetLogy();
129     gPad->SetGrid(1);
130     hmass_add[0][ipt]->SetXTitle("M_{ee} [GeV]");
131     hmass_add[0][ipt]->SetYTitle("counts");
132     hmass_add[0][ipt]->SetAxisRange(0,4);
133     hmass_add[0][ipt]->SetLineColor(1);
134     hmass_org[1][ipt]->SetLineColor(2);
135     hmass_add[0][ipt]->SetMinimum(1);
136     hmass_add[0][ipt]->Draw();
137     hmass_org[1][ipt]->Draw("same");
138
139     c0->cd(ipt+1+npt);
140     gPad->SetLogy();
141     gPad->SetGrid(1);
142     hmass_add[2][ipt]->SetXTitle("M_{ee} [GeV]");
143     hmass_add[2][ipt]->SetYTitle("counts");
144     hmass_add[2][ipt]->SetAxisRange(0,4);
145     hmass_add[2][ipt]->SetLineColor(4);
146     hmass_org[3][ipt]->SetLineColor(6);
147     hmass_add[2][ipt]->SetMinimum(1);
148     hmass_add[2][ipt]->Draw();
149     hmass_org[3][ipt]->Draw("same");
150   }
151     
152
153
154
155   
156   TCanvas *c1 = new TCanvas("c1","c1",1200,800);
157   c1->Divide(npt,2);
158   for(int ipt=0;ipt<npt;ipt++){
159     c1->cd(ipt+1);
160
161     gPad->SetGrid(1);
162     hdiv[ipt]->SetXTitle("M_{ee}");
163     hdiv[ipt]->SetYTitle("R(Mixed unlike/Mixed like)");
164     hdiv[ipt]->Draw();
165
166     c1->cd(ipt+1+npt);
167
168     gPad->SetGrid(1);
169     gPad->SetLogy();
170     hmass_add[0][ipt]->SetXTitle("M_{ee} [GeV]");
171     hmass_add[0][ipt]->SetYTitle("counts");
172     hmass_add[0][ipt]->SetAxisRange(0,4);
173     hmass_add[0][ipt]->SetLineColor(1);
174     hmass_add[1][ipt]->SetLineColor(2);
175
176     hmass_add[0][ipt]->SetMinimum(1);
177     hmass_add[0][ipt]->Draw();
178     hmass_add[1][ipt]->Draw("same");
179     hmass_add[0][ipt]->Draw("same");
180   }
181 }