1 void makefig(const int trig=0, const int icut=0, const int icent=0){
5 gStyle->SetOptFit(111111);
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;
27 ////// input root file ///////////////
29 sprintf(name,"result_trig%d_cut%d.root", trig, icut);
30 TFile *fin = new TFile(name,"read");
33 sprintf(name,"hmasspt_mb_%d",i);
34 hmasspt[i][10] = new TH2D(name, name, 500, 0, 5, 500, 0, 5);
37 ////// add into the histograms //////////////////
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]);
47 TH1D *hpy = hmasspt[0][0]->ProjectionY("hpy");
49 ////// range of pT /////////////////////////////////
51 float low[4] ={0, 1, 2};
52 float high[4]={1, 2, 4};
54 //// [pairtype][pt] //////////////////////////////
55 TH1D *hmass[7][4]; ///sliced mass spectrum
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);
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];
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();
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]);
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]);
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()));
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);
109 ///// then take ratio of mixed unlike / mixed like
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);
115 hdiv[ipt]->Divide(hmass_add[2][ipt], hmass_add[3][ipt]);
116 hdiv[ipt]->SetMaximum(2);
117 hdiv[ipt]->SetMinimum(0);
119 //// multiply to like sign
120 hmass_add[1][ipt]->Multiply(hdiv[ipt]);
124 TCanvas *c0 = new TCanvas("c0","c0",1200,800);
126 for(int ipt=0;ipt<npt;ipt++){
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");
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");
156 TCanvas *c1 = new TCanvas("c1","c1",1200,800);
158 for(int ipt=0;ipt<npt;ipt++){
162 hdiv[ipt]->SetXTitle("M_{ee}");
163 hdiv[ipt]->SetYTitle("R(Mixed unlike/Mixed like)");
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);
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");