vctFrame4x4<double> robSAHThumb::ForwardKinematics( const vctFixedSizeVector<double,4>& q, robSAHThumb::Phalanx phalanx ) const { switch( phalanx ){ case robSAHThumb::BASE: return Rtw0; case robSAHThumb::METACARPUS: { vctMatrixRotation3<double> Rb0; vctFixedSizeVector<double,3> tb0( -3.0/1000.0, 27.1/1000.0, 0.0 ); vctFrame4x4<double> Rtb0(Rb0,tb0); vctMatrixRotation3<double> Rb1( 0.00000, -1, 0.00000, 0.57358, 0, -0.81915, 0.81915, 0, 0.57358, VCT_NORMALIZE ); vctFixedSizeVector<double,3> tb1( -9.0/1000.0, 114.0/1000.0, 97.0/1000.0); vctFrame4x4<double> Rtb1( Rb1, tb1 ); vctFrame4x4<double> Rt0b( Rtb0 ); Rt0b.InverseSelf(); vctFrame4x4<double> Rt01 = Rt0b * Rtb1; vctMatrixRotation3<double> R( cos( -q[0] ), -sin( -q[0] ), 0.0, sin( -q[0] ), cos( -q[0] ), 0.0, 0.0, 0.0, 1.0, VCT_NORMALIZE ); vctFixedSizeVector<double,3> t(0.0); vctFrame4x4<double> Rt( R, t ); return ForwardKinematics( q, robSAHThumb::BASE ) * Rtb0 * Rt * Rt01; } case robSAHThumb::MCP: { return ( ForwardKinematics( q, robSAHThumb::METACARPUS ) * links[0].ForwardKinematics( q[1] ) ); } case robSAHThumb::PROXIMAL: return ( ForwardKinematics( q, robSAHThumb::MCP ) * links[1].ForwardKinematics( q[2] ) ); case robSAHThumb::INTERMEDIATE: return ( ForwardKinematics( q, robSAHThumb::PROXIMAL ) * links[2].ForwardKinematics( q[3] ) ); case robSAHThumb::DISTAL: return ( ForwardKinematics( q, robSAHThumb::INTERMEDIATE ) * links[3].ForwardKinematics( q[3] ) ); } }
int sc_main(int ac, char *av[]) { sc_clock clk( "CLOCK", 20, SC_NS, 0.5, 0, SC_NS, false); // Clock function testbench tb1("TB1", clk ); // Testbench Instance sc_start(); return 0; }
int sc_main(int ac, char *av[]) { sc_clock clk( "CLOCK", 20, SC_NS, 0.5, 10, SC_NS); // Clock function testbench tb1("TB1", clk ); // Testbench Instance sc_start(); // Simulation runs forever // due to negative value return 0; }
/* funzione per interpolare l'energia */ Double_t EN ( Double_t *x, Double_t *par ) { /* variabile ausiliaria: par[0] = $\hbar c$ */ Double_t l = TMath::Power( B * par[0] / x[0], 1./3. ); /* * termine tra parentesi (ho sfruttato le funzioni note per non * dover riscrivere un'altra funzione per calcolare $l d\beta/dl$) */ Double_t tmp = tb1( l ) - 3. * b1( l ); /* moltiplico per il coefficiente */ tmp = tmp * l * l / ( par[1] * B ); /* primo termine fuori dalle parentesi */ tmp += tb0( l ); /* incremento di uno */ tmp += 1.; /* 'par[2]' è la densità d'energia $e_0$ */ return par[2] - tmp / ( 3. * B * x[0] * x[0] ); }
void SLi_gen::SliceTriangle(const P3& a, const P3& b1, const P3& b2) { // resolve into transformed coordinates P2 ta(Dot(perp1, a), Dot(perp2, a)); P2 tb1(Dot(perp1, b1), Dot(perp2, b1)); P2 tb2(Dot(perp1, b2), Dot(perp2, b2)); P2 tv1 = tb1 - ta; P2 tv2 = tb2 - ta; P2 m = axis - ta; // in 2D we need to solve the matrix equation // ( tv1.u tv2.u ) ( l1 ) ( m.u ) // ( tv1.v tv2.v ) * ( l2 ) = ( m.v ). // determinant double det = tv1.u * tv2.v - tv1.v * tv2.u; if (det == 0.0) return; double l1 = (tv2.v * m.u - tv2.u * m.v) / det; if (l1 <= 0.0) return; double l2 = (-tv1.v * m.u + tv1.u * m.v) / det; if ((l2 <= 0.0) || (l1 + l2 >= 1.0)) return; // point of intersection P3 p = a * (1.0 - l1 - l2) + b1 * l1 + b2 * l2; double lamf = Dot(v01n, p); TOL_ZERO((p0p + v01n * lamf - p).Len()); inter.push_back(lamf); }
void xsecSummary() { //-------------------------------------------------------------------------------------------------------------- // input parameter const Double_t xsec_wp = 11356; const Double_t xsec_wp_stat = 9; const Double_t xsec_wp_sys = 197; const Double_t xsec_wp_lumi = 307; const Double_t xsec_wm = 8284; const Double_t xsec_wm_stat = 8; const Double_t xsec_wm_sys = 124; const Double_t xsec_wm_lumi = 224; const Double_t xsec_w = 19708; const Double_t xsec_w_stat = 11; const Double_t xsec_w_sys = 265; const Double_t xsec_w_lumi = 532; const Double_t xsec_z = 1904; const Double_t xsec_z_stat = 1; const Double_t xsec_z_sys = 30; const Double_t xsec_z_lumi = 51; const Double_t xsec_wr = 1.372; const Double_t xsec_wr_stat = 0.002; const Double_t xsec_wr_sys = 0.022; const Double_t xsec_wpr= 5.966; const Double_t xsec_wpr_stat= 0.006; const Double_t xsec_wpr_sys= 0.100; const Double_t xsec_wmr= 4.351; const Double_t xsec_wmr_stat= 0.005; const Double_t xsec_wmr_sys= 0.069; const Double_t xsec_wz = 10.330; const Double_t xsec_wz_stat = 0.009; const Double_t xsec_wz_sys = 0.147; const Double_t theo_wp = 11328.8; const Double_t theo_wp_unc = (268.75+323.94)/2.; const Double_t theo_wm = 8369.09; const Double_t theo_wm_unc = (213.11+244.29)/2.; const Double_t theo_w = 19697.6; const Double_t theo_w_unc = (473.95+563.48)/2.; const Double_t theo_z = 1867.66; const Double_t theo_z_unc = (43.49+47.36)/2.; const Double_t theo_wr = 1.35367; const Double_t theo_wr_unc = (0.0123+0.01054)/2.; const Double_t theo_wpr= 6.06494; const Double_t theo_wpr_unc= (0.04716+0.04361)/2.; const Double_t theo_wmr= 4.48044; const Double_t theo_wmr_unc= (0.01779+0.02685)/2.; const Double_t theo_wz = 10.54538; const Double_t theo_wz_unc = (0.06495+0.07046)/2.; const Double_t ratio_wp = xsec_wp/theo_wp; const Double_t ratio_wp_the = theo_wp_unc*xsec_wp/(theo_wp*theo_wp); const Double_t ratio_wp_exp = sqrt(xsec_wp_stat*xsec_wp_stat+xsec_wp_sys*xsec_wp_sys)/(theo_wp); const Double_t ratio_wm = xsec_wm/theo_wm; const Double_t ratio_wm_the = theo_wm_unc*xsec_wm/(theo_wm*theo_wm); const Double_t ratio_wm_exp = sqrt(xsec_wm_stat*xsec_wm_stat+xsec_wm_sys*xsec_wm_sys)/(theo_wm); const Double_t ratio_w = xsec_w/theo_w; const Double_t ratio_w_the = theo_w_unc*xsec_w/(theo_w*theo_w); const Double_t ratio_w_exp = sqrt(xsec_w_stat*xsec_w_stat+xsec_w_sys*xsec_w_sys)/(theo_w); const Double_t ratio_z = xsec_z/theo_z; const Double_t ratio_z_the = theo_z_unc*xsec_z/(theo_z*theo_z); const Double_t ratio_z_exp = sqrt(xsec_z_stat*xsec_z_stat+xsec_z_sys*xsec_z_sys)/(theo_z); const Double_t ratio_wr = xsec_wr/theo_wr; const Double_t ratio_wr_the = theo_wr_unc*xsec_wr/(theo_wr*theo_wr); const Double_t ratio_wr_exp = sqrt(xsec_wr_stat*xsec_wr_stat+xsec_wr_sys*xsec_wr_sys)/(theo_wr); const Double_t ratio_wpr = xsec_wpr/theo_wpr; const Double_t ratio_wpr_the= theo_wpr_unc*xsec_wpr/(theo_wpr*theo_wpr); const Double_t ratio_wpr_exp= sqrt(xsec_wpr_stat*xsec_wpr_stat+xsec_wpr_sys*xsec_wpr_sys)/(theo_wpr); const Double_t ratio_wmr = xsec_wmr/theo_wmr; const Double_t ratio_wmr_the = theo_wmr_unc*xsec_wmr/(theo_wmr*theo_wmr); const Double_t ratio_wmr_exp= sqrt(xsec_wmr_stat*xsec_wmr_stat+xsec_wmr_sys*xsec_wmr_sys)/(theo_wmr); const Double_t ratio_wz = xsec_wz/theo_wz; const Double_t ratio_wz_the = theo_wz_unc*xsec_wz/(theo_wz*theo_wz); const Double_t ratio_wz_exp = sqrt(xsec_wz_stat*xsec_wz_stat+xsec_wz_sys*xsec_wz_sys)/(theo_wz); Double_t test = sqrt(xsec_wp_stat*xsec_wp_stat+xsec_wp_sys*xsec_wp_sys)/(xsec_wp); //============================================================================================================== //-------------------------------------------------------------------------------------------------------------- // plotting parameter Double_t yshift, ydrift; // used for point and error bar yshift = 3.75; ydrift = -0.245; Double_t td, tp, tw; // used for text td = 0.025; tp = 0.708; tw = 0.035; Double_t range_max, range_min; //range_min = 0.82; //range_max = 1.27; range_min = 0.82; range_max = 1.25; Int_t expColor, theColor; // colors used Int_t prodColor, decayColor, cmbColor; // colors used expColor = kBlue; theColor = kGreen+2; prodColor = kBlue+2; decayColor= kRed+2; cmbColor = kBlack; //============================================================================================================== //-------------------------------------------------------------------------------------------------------------- // make plots TCanvas *c = MakeCanvas("c","c",800,600); c->SetTickx(1); c->SetTicky(0); c->SetFrameFillStyle(0); c->SetFrameLineWidth(2); c->SetFrameBorderMode(0); c->SetLeftMargin(0.07); gStyle->SetEndErrorSize(8); Double_t xval, errl, errh, yval; xval = ratio_wp; yval = yshift+0*ydrift; errl = ratio_wp_exp; errh = sqrt(ratio_wp_exp*ratio_wp_exp+ratio_wp_the*ratio_wp_the); TGraphAsymmErrors grWP(1,&xval,&yval,&errl,&errl,0,0); grWP.SetTitle(""); grWP.GetXaxis()->SetTitle(""); grWP.GetXaxis()->SetTitleSize(0.05); grWP.GetYaxis()->SetTitle(""); grWP.GetYaxis()->SetRangeUser(0,5); grWP.GetXaxis()->SetLimits(range_min,range_max); grWP.GetXaxis()->SetNdivisions(506); grWP.GetYaxis()->SetNdivisions(0); grWP.SetMarkerStyle(kFullCircle); grWP.SetMarkerSize(1); grWP.SetLineWidth(2); grWP.SetMarkerColor(kBlack); grWP.SetLineColor(expColor); grWP.Draw("AP"); // lumi uncertainty band TBox lumi_box(0.973,yshift+7.*ydrift,1.027,3.98); //TBox lumi_box(0.974,yshift+7.*ydrift,1.026,3.98); lumi_box.SetLineColor(796); lumi_box.SetFillColor(796); lumi_box.Draw(); c->RedrawAxis(); TLine theory_line(1,0.02,1,3.98); theory_line.SetLineColor(kRed); theory_line.SetLineStyle(1); theory_line.SetLineWidth(3); theory_line.Draw(); TGraphAsymmErrors grWP2(1,&xval,&yval,&errh,&errh,0,0); grWP2.SetMarkerStyle(kFullCircle); grWP2.SetMarkerSize(1); grWP2.SetLineWidth(2); grWP2.SetMarkerColor(kBlack); grWP2.SetLineColor(theColor); grWP2.Draw("EPSAME"); grWP.Draw("EPSAME"); xval = ratio_wm; yval = yshift+2*ydrift; errl = ratio_wm_exp; errh = sqrt(ratio_wm_exp*ratio_wm_exp+ratio_wm_the*ratio_wm_the); TGraphAsymmErrors grWM(1,&xval,&yval,&errl,&errl,0,0); grWM.SetMarkerStyle(kFullCircle); grWM.SetMarkerSize(1); grWM.SetLineWidth(2); grWM.SetMarkerColor(kBlack); grWM.SetLineColor(expColor); TGraphAsymmErrors grWM2(1,&xval,&yval,&errh,&errh,0,0); grWM2.SetMarkerStyle(kFullCircle); grWM2.SetMarkerSize(1); grWM2.SetLineWidth(2); grWM2.SetMarkerColor(kBlack); grWM2.SetLineColor(theColor); grWM2.Draw("EPSAME"); grWM.Draw("EPSAME"); xval = ratio_w; yval = yshift+4*ydrift; errl = ratio_w_exp; errh = sqrt(ratio_w_exp*ratio_w_exp+ratio_w_the*ratio_w_the); TGraphAsymmErrors grW(1,&xval,&yval,&errl,&errl,0,0); grW.SetMarkerStyle(kFullCircle); grW.SetMarkerSize(1); grW.SetLineWidth(2); grW.SetMarkerColor(kBlack); grW.SetLineColor(expColor); TGraphAsymmErrors grW2(1,&xval,&yval,&errh,&errh,0,0); grW2.SetMarkerStyle(kFullCircle); grW2.SetMarkerSize(1); grW2.SetLineWidth(2); grW2.SetMarkerColor(kBlack); grW2.SetLineColor(theColor); grW2.Draw("EPSAME"); grW.Draw("EPSAME"); xval = ratio_z; yval = yshift+6*ydrift; errl = ratio_z_exp; errh = sqrt(ratio_z_exp*ratio_z_exp+ratio_z_the*ratio_z_the); TGraphAsymmErrors grZ(1,&xval,&yval,&errl,&errl,0,0); grZ.SetMarkerSize(1); grZ.SetLineWidth(2); grZ.SetMarkerColor(kBlack); grZ.SetLineColor(expColor); TGraphAsymmErrors grZ2(1,&xval,&yval,&errh,&errh,0,0); grZ2.SetMarkerStyle(kFullCircle); grZ2.SetMarkerSize(1); grZ2.SetLineWidth(2); grZ2.SetMarkerColor(kBlack); grZ2.SetLineColor(theColor); grZ2.Draw("EPSAME"); grZ.Draw("EPSAME"); xval = ratio_wr; yval = yshift+8*ydrift; errl = ratio_wr_exp; errh = sqrt(ratio_wr_exp*ratio_wr_exp+ratio_wr_the*ratio_wr_the); TGraphAsymmErrors grWR(1,&xval,&yval,&errl,&errl,0,0); grWR.SetMarkerStyle(kFullCircle); grWR.SetMarkerSize(1); grWR.SetLineWidth(2); grWR.SetMarkerColor(kBlack); grWR.SetLineColor(expColor); TGraphAsymmErrors grWR2(1,&xval,&yval,&errh,&errh,0,0); grWR2.SetMarkerStyle(kFullCircle); grWR2.SetMarkerSize(1); grWR2.SetLineWidth(2); grWR2.SetMarkerColor(kBlack); grWR2.SetLineColor(theColor); grWR2.Draw("EPSAME"); grWR.Draw("EPSAME"); xval = ratio_wpr; yval = yshift+10*ydrift; errl = ratio_wpr_exp; errh = sqrt(ratio_wpr_exp*ratio_wpr_exp+ratio_wpr_the*ratio_wpr_the); TGraphAsymmErrors grWPR(1,&xval,&yval,&errl,&errl,0,0); grWPR.SetMarkerStyle(kFullCircle); grWPR.SetMarkerSize(1); grWPR.SetLineWidth(2); grWPR.SetMarkerColor(kBlack); grWPR.SetLineColor(expColor); TGraphAsymmErrors grWPR2(1,&xval,&yval,&errh,&errh,0,0); grWPR2.SetMarkerStyle(kFullCircle); grWPR2.SetMarkerSize(1); grWPR2.SetLineWidth(2); grWPR2.SetMarkerColor(kBlack); grWPR2.SetLineColor(theColor); grWPR2.Draw("EPSAME"); grWPR.Draw("EPSAME"); xval = ratio_wmr; yval = yshift+12*ydrift; errl = ratio_wmr_exp; errh = sqrt(ratio_wmr_exp*ratio_wmr_exp+ratio_wmr_the*ratio_wmr_the); TGraphAsymmErrors grWMR(1,&xval,&yval,&errl,&errl,0,0); grWMR.SetMarkerStyle(kFullCircle); grWMR.SetMarkerSize(1); grWMR.SetLineWidth(2); grWMR.SetMarkerColor(kBlack); grWMR.SetLineColor(expColor); TGraphAsymmErrors grWMR2(1,&xval,&yval,&errh,&errh,0,0); grWMR2.SetMarkerStyle(kFullCircle); grWMR2.SetMarkerSize(1); grWMR2.SetLineWidth(2); grWMR2.SetMarkerColor(kBlack); grWMR2.SetLineColor(theColor); grWMR2.Draw("EPSAME"); grWMR.Draw("EPSAME"); xval = ratio_wz; yval = yshift+14*ydrift; errl = ratio_wz_exp; errh = sqrt(ratio_wz_exp*ratio_wz_exp+ratio_wz_the*ratio_wz_the); TGraphAsymmErrors grWZ(1,&xval,&yval,&errl,&errl,0,0); grWZ.SetMarkerStyle(kFullCircle); grWZ.SetMarkerSize(1); grWZ.SetLineWidth(2); grWZ.SetMarkerColor(kBlack); grWZ.SetLineColor(expColor); TGraphAsymmErrors grWZ2(1,&xval,&yval,&errh,&errh,0,0); grWZ2.SetMarkerStyle(kFullCircle); grWZ2.SetMarkerSize(1); grWZ2.SetLineWidth(2); grWZ2.SetMarkerColor(kBlack); grWZ2.SetLineColor(theColor); grWZ2.Draw("EPSAME"); grWZ.Draw("EPSAME"); // legend xval = range_min+(0.06*(range_max-range_min)); yval = 4.6; errl = 0.015*(range_max-range_min); errh = 0.03*(range_max-range_min); TGraphAsymmErrors grLeg(1,&xval,&yval,&errl,&errl,0,0); grLeg.SetMarkerStyle(kFullCircle); grLeg.SetMarkerSize(1); grLeg.SetLineWidth(2); grLeg.SetMarkerColor(kBlack); grLeg.SetLineColor(expColor); TGraphAsymmErrors grLeg2(1,&xval,&yval,&errh,&errh,0,0); grLeg2.SetMarkerStyle(kFullCircle); grLeg2.SetMarkerSize(1); grLeg2.SetLineWidth(2); grLeg2.SetMarkerColor(kBlack); grLeg2.SetLineColor(theColor); grLeg2.Draw("EPSAME"); grLeg.Draw("EPSAME"); TPaveText tb4(0.14,0.84,0.6,0.875,"NDC"); tb4.SetFillStyle(0); tb4.SetBorderSize(0); tb4.SetTextAlign(12); tb4.AddText("Observation, uncertainty (exp., exp. #oplus theory)"); tb4.Draw(); TPaveText tb6(0.14,0.795,0.6,0.83,"NDC"); tb6.SetFillStyle(0); tb6.SetBorderSize(0); tb6.SetTextAlign(12); tb6.AddText("Uncertainty (lumi)"); tb6.Draw(); TBox exp_box_leg2(range_min+(0.04*(range_max-range_min)),4.18,range_min+(0.08*(range_max-range_min)),4.38); exp_box_leg2.SetLineColor(796); exp_box_leg2.SetFillColor(796); exp_box_leg2.Draw(); // split lines TLine split_line0(range_min,yshift+1*ydrift,range_max,yshift+1*ydrift); split_line0.SetLineColor(kBlack); split_line0.SetLineStyle(2); split_line0.SetLineWidth(1); split_line0.Draw(); TLine split_line1(range_min,yshift+3*ydrift,range_max,yshift+3*ydrift); split_line1.SetLineColor(kBlack); split_line1.SetLineStyle(2); split_line1.SetLineWidth(1); split_line1.Draw(); TLine split_line2(range_min,yshift+5*ydrift,range_max,yshift+5*ydrift); split_line2.SetLineColor(kBlack); split_line2.SetLineStyle(2); split_line2.SetLineWidth(1); split_line2.Draw(); TLine split_line3(range_min,yshift+7*ydrift,range_max,yshift+7*ydrift); split_line3.SetLineColor(kBlack); split_line3.SetLineStyle(2); split_line3.SetLineWidth(1); split_line3.Draw(); TLine split_line4(range_min,yshift+9*ydrift,range_max,yshift+9*ydrift); split_line4.SetLineColor(kBlack); split_line4.SetLineStyle(2); split_line4.SetLineWidth(1); split_line4.Draw(); TLine split_line5(range_min,yshift+11*ydrift,range_max,yshift+11*ydrift); split_line5.SetLineColor(kBlack); split_line5.SetLineStyle(2); split_line5.SetLineWidth(1); split_line5.Draw(); TLine split_line6(range_min,yshift+13*ydrift,range_max,yshift+13*ydrift); split_line6.SetLineColor(kBlack); split_line6.SetLineStyle(2); split_line6.SetLineWidth(1); split_line6.Draw(); TLine split_line7(range_min,yshift+(-1)*ydrift,range_max,yshift+(-1)*ydrift); split_line7.SetLineColor(kBlack); split_line7.SetLineStyle(2); split_line7.SetLineWidth(1); split_line7.Draw(); TPaveText tb1(0.08,0.93,0.34,0.99,"NDC"); tb1.SetFillStyle(0); tb1.SetBorderSize(0); tb1.SetTextAlign(12); tb1.AddText("#bf{CMS}"); tb1.Draw(); TPaveText tb2(0.75,0.93,0.95,0.99,"NDC"); tb2.SetFillStyle(0); tb2.SetBorderSize(0); tb2.SetTextAlign(12); tb2.AddText("2.3 fb^{-1} (13 TeV)"); tb2.Draw(); TPaveText tb3(0.6,0.83,0.95,0.88,"NDC"); tb3.SetFillStyle(0); tb3.SetBorderSize(0); tb3.SetTextAlign(12); tb3.AddText("Theory: FEWZ (NNLO), NNPDF3.0"); tb3.Draw(); TPaveText tb7(0.6,0.795,0.95,0.83,"NDC"); tb7.SetFillStyle(0); tb7.SetBorderSize(0); tb7.SetTextAlign(12); tb7.AddText("Observation: NNPDF3.0"); tb7.Draw(); TPaveText textwp(0.10,tp-(0*td),0.50,tp+tw-(0*td),"NDC"); textwp.SetFillStyle(0); textwp.SetBorderSize(0); textwp.SetTextAlign(12); textwp.AddText("#bf{W^{+}#rightarrowl^{+}#nu}"); textwp.Draw(); char buffer[200]; Double_t tmp[4]; Double_t tmp2[4]; roundXsec(xsec_wp, xsec_wp_stat, xsec_wp_sys, xsec_wp_lumi, tmp); sprintf(buffer,"%.0f #pm %.0f_{stat} #pm %.0f_{syst}", tmp[0], tmp[1], tmp[2]); sprintf(buffer,"%s #pm %.0f_{lum} pb",buffer,tmp[3]); TPaveText resultwp(0.60,tp-(-0.5*td),1.00,tp+tw-(-0.5*td),"NDC"); resultwp.SetFillStyle(0); resultwp.SetBorderSize(0); resultwp.SetTextAlign(12); resultwp.AddText(buffer); resultwp.Draw(); roundXsec(theo_wp, theo_wp_unc, tmp2); sprintf(buffer,"%.0f #pm %.0f pb", tmp2[0], tmp2[1]); TPaveText theorywp(0.60,tp-(0.6*td),1.00,tp+tw-(0.6*td),"NDC"); theorywp.SetFillStyle(0); theorywp.SetBorderSize(0); theorywp.SetTextAlign(12); theorywp.AddText(buffer); theorywp.Draw(); TPaveText textwm(0.10,tp-(3*td),0.50,tp+tw-(3*td),"NDC"); textwm.SetFillStyle(0); textwm.SetBorderSize(0); textwm.SetTextAlign(12); textwm.AddText("#bf{W^{-}#rightarrowl^{-}#nu}"); textwm.Draw(); roundXsec(xsec_wm, xsec_wm_stat, xsec_wm_sys,xsec_wm_lumi, tmp); sprintf(buffer,"%.0f #pm %.0f_{stat} #pm %.0f_{syst}", tmp[0], tmp[1], tmp[2]); sprintf(buffer,"%s #pm %.0f_{lum} pb",buffer,tmp[3]); TPaveText resultwm(0.60,tp-(2.5*td),1.00,tp+tw-(2.5*td),"NDC"); resultwm.SetFillStyle(0); resultwm.SetBorderSize(0); resultwm.SetTextAlign(12); resultwm.AddText(buffer); resultwm.Draw(); roundXsec(theo_wm, theo_wm_unc, tmp2); sprintf(buffer,"%.0f #pm %.0f pb", tmp2[0], tmp2[1]); TPaveText theorywm(0.60,tp-(3.6*td),1.00,tp+tw-(3.6*td),"NDC"); theorywm.SetFillStyle(0); theorywm.SetBorderSize(0); theorywm.SetTextAlign(12); theorywm.AddText(buffer); theorywm.Draw(); TPaveText textw(0.10,tp-(6*td),0.50,tp+tw-(6*td),"NDC"); textw.SetFillStyle(0); textw.SetBorderSize(0); textw.SetTextAlign(12); textw.AddText("#bf{W#rightarrowl#nu}"); textw.Draw(); roundXsec(xsec_w, xsec_w_stat, xsec_w_sys, xsec_w_lumi, tmp); sprintf(buffer,"%.0f #pm %.0f_{stat} #pm %.0f_{syst}", tmp[0], tmp[1], tmp[2]); sprintf(buffer,"%s #pm %.0f_{lum} pb",buffer,tmp[3]); TPaveText resultw(0.60,tp-(5.5*td),1.00,tp+tw-(5.5*td),"NDC"); resultw.SetFillStyle(0); resultw.SetBorderSize(0); resultw.SetTextAlign(12); resultw.AddText(buffer); resultw.Draw(); roundXsec(theo_w, theo_w_unc, tmp2); sprintf(buffer,"%.0f #pm %.0f pb", tmp2[0], tmp2[1]); TPaveText theoryw(0.60,tp-(6.6*td),1.00,tp+tw-(6.6*td),"NDC"); theoryw.SetFillStyle(0); theoryw.SetBorderSize(0); theoryw.SetTextAlign(12); theoryw.AddText(buffer); theoryw.Draw(); TPaveText textz(0.10,tp-(9*td),0.50,tp+tw-(9*td),"NDC"); textz.SetFillStyle(0); textz.SetBorderSize(0); textz.SetTextAlign(12); textz.AddText("#bf{Z#rightarrowl^{+}l^{-}}"); textz.Draw(); roundXsec(xsec_z, xsec_z_stat, xsec_z_sys,xsec_z_lumi, tmp); sprintf(buffer,"%.0f #pm %.0f_{stat} #pm %.0f_{syst}", tmp[0], tmp[1], tmp[2]); sprintf(buffer,"%s #pm %.0f_{lum} pb",buffer,tmp[3]); TPaveText resultz(0.60,tp-(8.5*td),1.00,tp+tw-(8.5*td),"NDC"); resultz.SetFillStyle(0); resultz.SetBorderSize(0); resultz.SetTextAlign(12); resultz.AddText(buffer); resultz.Draw(); roundXsec(theo_z, theo_z_unc, tmp2); sprintf(buffer,"%.0f #pm %.0f pb", tmp2[0], tmp2[1]); TPaveText theoryz(0.60,tp-(9.6*td),1.00,tp+tw-(9.6*td),"NDC"); theoryz.SetFillStyle(0); theoryz.SetBorderSize(0); theoryz.SetTextAlign(12); theoryz.AddText(buffer); theoryz.Draw(); TPaveText textwr(0.10,tp-(12*td),0.50,tp+tw-(12*td),"NDC"); textwr.SetFillStyle(0); textwr.SetBorderSize(0); textwr.SetTextAlign(12); textwr.AddText("#bf{W^{+}#rightarrowl^{+}#nu / W^{-}#rightarrowl^{-}#nu}"); textwr.Draw(); sprintf(buffer,"%.3f #pm %.3f_{stat} #pm %.3f_{syst}", xsec_wr, xsec_wr_stat, xsec_wr_sys); TPaveText resultwr(0.60,tp-(11.5*td),1.00,tp+tw-(11.5*td),"NDC"); resultwr.SetFillStyle(0); resultwr.SetBorderSize(0); resultwr.SetTextAlign(12); resultwr.AddText(buffer); resultwr.Draw(); sprintf(buffer,"%.3f #pm %.3f", theo_wr, theo_wr_unc); TPaveText theorywr(0.60,tp-(12.6*td),1.00,tp+tw-(12.6*td),"NDC"); theorywr.SetFillStyle(0); theorywr.SetBorderSize(0); theorywr.SetTextAlign(12); theorywr.AddText(buffer); theorywr.Draw(); TPaveText textwpr(0.10,tp-(15*td),0.50,tp+tw-(15*td),"NDC"); textwpr.SetFillStyle(0); textwpr.SetBorderSize(0); textwpr.SetTextAlign(12); textwpr.AddText("#bf{W^{+}#rightarrowl^{+}#nu / Z#rightarrowl^{+}l^{-}}"); textwpr.Draw(); sprintf(buffer,"%.2f #pm %.2f_{stat} #pm %.2f_{syst}", xsec_wpr, xsec_wpr_stat, xsec_wpr_sys); TPaveText resultwpr(0.60,tp-(14.5*td),1.00,tp+tw-(14.5*td),"NDC"); resultwpr.SetFillStyle(0); resultwpr.SetBorderSize(0); resultwpr.SetTextAlign(12); resultwpr.AddText(buffer); resultwpr.Draw(); sprintf(buffer,"%.2f #pm %.2f", theo_wpr, theo_wpr_unc); TPaveText theorywpr(0.60,tp-(15.6*td),1.00,tp+tw-(15.6*td),"NDC"); theorywpr.SetFillStyle(0); theorywpr.SetBorderSize(0); theorywpr.SetTextAlign(12); theorywpr.AddText(buffer); theorywpr.Draw(); TPaveText textwmr(0.10,tp-(18*td),0.50,tp+tw-(18*td),"NDC"); textwmr.SetFillStyle(0); textwmr.SetBorderSize(0); textwmr.SetTextAlign(12); textwmr.AddText("#bf{W^{-}#rightarrowl^{-}#nu / Z#rightarrowl^{+}l^{-}}"); textwmr.Draw(); sprintf(buffer,"%.2f #pm %.2f_{stat} #pm %.2f_{syst}", xsec_wmr, xsec_wmr_stat, xsec_wmr_sys); TPaveText resultwmr(0.60,tp-(17.5*td),1.00,tp+tw-(17.5*td),"NDC"); resultwmr.SetFillStyle(0); resultwmr.SetBorderSize(0); resultwmr.SetTextAlign(12); resultwmr.AddText(buffer); resultwmr.Draw(); sprintf(buffer,"%.2f #pm %.2f", theo_wmr, theo_wmr_unc); TPaveText theorywmr(0.60,tp-(18.6*td),1.00,tp+tw-(18.6*td),"NDC"); theorywmr.SetFillStyle(0); theorywmr.SetBorderSize(0); theorywmr.SetTextAlign(12); theorywmr.AddText(buffer); theorywmr.Draw(); TPaveText textwz(0.10,tp-(21*td),0.50,tp+tw-(21*td),"NDC"); textwz.SetFillStyle(0); textwz.SetBorderSize(0); textwz.SetTextAlign(12); textwz.AddText("#bf{W#rightarrowl#nu / Z#rightarrowl^{+}l^{-}}"); textwz.Draw(); sprintf(buffer,"%.2f #pm %.2f_{stat} #pm %.2f_{syst}", xsec_wz, xsec_wz_stat, xsec_wz_sys); TPaveText resultwz(0.60,tp-(20.5*td),1.00,tp+tw-(20.5*td),"NDC"); resultwz.SetFillStyle(0); resultwz.SetBorderSize(0); resultwz.SetTextAlign(12); resultwz.AddText(buffer); resultwz.Draw(); sprintf(buffer,"%.2f #pm %.2f", theo_wz, theo_wz_unc); TPaveText theorywz(0.60,tp-(21.6*td),1.00,tp+tw-(21.6*td),"NDC"); theorywz.SetFillStyle(0); theorywz.SetBorderSize(0); theorywz.SetTextAlign(12); theorywz.AddText(buffer); theorywz.Draw(); TPaveText tb5(0.28,0.02,0.98,0.12,"NDC"); tb5.SetFillStyle(0); tb5.SetBorderSize(0); tb5.SetTextAlign(12); tb5.AddText("ratio (exp./th.) of total cross sections and ratios"); tb5.Draw(); c->SaveAs("xsecSummary13TeV.png"); c->SaveAs("xsecSummary13TeV.pdf"); }
void EleScaleClosureTest() { //-------------------------------------------------------------------------------------------------------------- // Settings //============================================================================================================== // event category enumeration enum { eEleEle2HLT=1, eEleEle1HLT1L1, eEleEle1HLT, eEleEleNoSel, eEleSC }; // Create output directory TString outputDir = "EleScaleClosureTestResults"; TString pufname = "../Tools/pileup_weights_2015B.root"; gSystem->mkdir(outputDir,kTRUE); vector<TString> infilenamev; infilenamev.push_back("/afs/cern.ch/work/c/cmedlock/public/wz-ntuples/Zee/ntuples/data_select.root"); // data infilenamev.push_back("/afs/cern.ch/work/c/cmedlock/public/wz-ntuples/Zee/ntuples/zee_select.raw.root"); // MC (raw) infilenamev.push_back("/afs/cern.ch/work/c/cmedlock/public/wz-ntuples/Zee/ntuples/zee_select.raw.root"); // MC2 (corrected) enum { eData=0, eMC, eMC2 }; Float_t lumi=40.0; const Int_t NBINS = 40; const Double_t MASS_LOW = 80; const Double_t MASS_HIGH = 100; const Double_t PT_CUT = 25; const Double_t ETA_CUT = 2.5; const Double_t ELE_MASS = 0.000511; vector<pair<Double_t,Double_t> > scEta_limits; scEta_limits.push_back(make_pair(0.0,0.4)); scEta_limits.push_back(make_pair(0.4,0.8)); scEta_limits.push_back(make_pair(0.8,1.4442)); scEta_limits.push_back(make_pair(1.566,2.5)); CPlot::sOutDir = outputDir; const TString format("png"); TRandom3 *rnd = new TRandom3(); //-------------------------------------------------------------------------------------------------------------- // Main analysis code //============================================================================================================== TFile *pufile = new TFile(pufname); assert(pufile); TH1D *puWeights = (TH1D*)pufile->Get("npv_rw"); TH1D* hData_Tot = new TH1D("hData_Tot","",NBINS,MASS_LOW,MASS_HIGH); hData_Tot->Sumw2(); TH1D* hMC_Tot = new TH1D("hMC_Tot","",NBINS,MASS_LOW,MASS_HIGH); hMC_Tot->Sumw2(); TH1D* hMC2_Tot = new TH1D("hMC2_Tot","",NBINS,MASS_LOW,MASS_HIGH); hMC2_Tot->Sumw2(); char hname[100]; vector<TH1D*> hMCv, hDatav, hMC2v; for(UInt_t ibin=0; ibin<scEta_limits.size(); ibin++) { for(UInt_t jbin=ibin; jbin<scEta_limits.size(); jbin++) { sprintf(hname,"data_%i_%i",ibin,jbin); hDatav.push_back(new TH1D(hname,"",NBINS,MASS_LOW,MASS_HIGH)); hDatav.back()->Sumw2(); sprintf(hname,"mc_%i_%i",ibin,jbin); hMCv.push_back(new TH1D(hname,"",NBINS,MASS_LOW,MASS_HIGH)); hMCv.back()->Sumw2(); sprintf(hname,"mc2_%i_%i",ibin,jbin); hMC2v.push_back(new TH1D(hname,"",NBINS,MASS_LOW,MASS_HIGH)); hMC2v.back()->Sumw2(); } } // // Declare output ntuple variables // UInt_t runNum, lumiSec, evtNum; UInt_t matchGen; UInt_t category; UInt_t npv, npu; Int_t q1, q2; Float_t scale1fb, puWeight; TLorentzVector *dilep=0, *lep1=0, *lep2=0; ///// electron specific ///// TLorentzVector *sc1=0, *sc2=0; for(UInt_t ifile=0; ifile<infilenamev.size(); ifile++) { cout << "Processing " << infilenamev[ifile] << "..." << endl; TFile *infile = TFile::Open(infilenamev[ifile]); assert(infile); TTree *intree = (TTree*)infile->Get("Events"); assert(intree); intree->SetBranchAddress("runNum", &runNum); // event run number intree->SetBranchAddress("lumiSec", &lumiSec); // event lumi section intree->SetBranchAddress("evtNum", &evtNum); // event number intree->SetBranchAddress("scale1fb", &scale1fb); // event weight intree->SetBranchAddress("puWeight", &puWeight); // pileup reweighting intree->SetBranchAddress("matchGen", &matchGen); // event has both leptons matched to MC Z->ll intree->SetBranchAddress("category", &category); // dilepton category intree->SetBranchAddress("npv", &npv); // number of primary vertices intree->SetBranchAddress("npu", &npu); // number of in-time PU events (MC) intree->SetBranchAddress("q1", &q1); // charge of lead lepton intree->SetBranchAddress("q2", &q2); // charge of trail lepton intree->SetBranchAddress("dilep", &dilep); // dilepton 4-vector intree->SetBranchAddress("lep1", &lep1); // lead lepton 4-vector intree->SetBranchAddress("lep2", &lep2); // trail lepton 4-vector intree->SetBranchAddress("sc1", &sc1); // lead Supercluster 4-vector intree->SetBranchAddress("sc2", &sc2); // trail Supercluster 4-vector for(UInt_t ientry=0; ientry<intree->GetEntries(); ientry++) { intree->GetEntry(ientry); Double_t weight = 1; if(ifile==eMC || ifile==eMC2) weight=scale1fb*lumi*puWeights->GetBinContent(npv+1); if((category!=eEleEle2HLT) && (category!=eEleEle1HLT) && (category!=eEleEle1HLT1L1)) continue; if(q1 == q2) continue; if(dilep->M() < MASS_LOW) continue; if(dilep->M() > MASS_HIGH) continue; if(sc1->Pt() < PT_CUT) continue; if(sc2->Pt() < PT_CUT) continue; if(fabs(sc1->Eta()) > ETA_CUT) continue; if(fabs(sc2->Eta()) > ETA_CUT) continue; TLorentzVector vLep1(0,0,0,0); TLorentzVector vLep2(0,0,0,0); if (ifile==eData) { vLep1.SetPtEtaPhiM(lep1->Pt(), lep1->Eta(), lep1->Phi(), ELE_MASS); vLep2.SetPtEtaPhiM(lep2->Pt(), lep2->Eta(), lep2->Phi(), ELE_MASS); } else if (ifile==eMC) { vLep1.SetPtEtaPhiM(lep1->Pt(), lep1->Eta(), lep1->Phi(), ELE_MASS); vLep2.SetPtEtaPhiM(lep2->Pt(), lep2->Eta(), lep2->Phi(), ELE_MASS); } else { vLep1.SetPtEtaPhiM(gRandom->Gaus(lep1->Pt()*getEleScaleCorr(lep1->Eta(),0),getEleResCorr(lep1->Eta(),0)), lep1->Eta(), lep1->Phi(), ELE_MASS); vLep2.SetPtEtaPhiM(gRandom->Gaus(lep2->Pt()*getEleScaleCorr(lep2->Eta(),0),getEleResCorr(lep2->Eta(),0)), lep2->Eta(), lep2->Phi(), ELE_MASS); } TLorentzVector vDilep = vLep1 + vLep2; Int_t bin1=-1, bin2=-1; for(UInt_t i=0; i<scEta_limits.size(); i++) { Double_t etalow = scEta_limits.at(i).first; Double_t etahigh = scEta_limits.at(i).second; if(fabs(sc1->Eta())>=etalow && fabs(sc1->Eta())<=etahigh) bin1=i; if(fabs(sc2->Eta())>=etalow && fabs(sc2->Eta())<=etahigh) bin2=i; } assert(bin1>=0); assert(bin2>=0); Int_t ibin= (bin1<=bin2) ? bin1 : bin2; Int_t jbin= (bin1<=bin2) ? bin2 : bin1; if (ifile==eData) hData_Tot->Fill(vDilep.M(),weight); else if (ifile==eMC) hMC_Tot->Fill(vDilep.M(),weight); else if (ifile==eMC2) hMC2_Tot->Fill(vDilep.M(),weight); UInt_t n=jbin-ibin; for(Int_t k=0; k<ibin; k++) n+=(scEta_limits.size()-k); if(ifile==eData) hDatav[n]->Fill(vDilep.M(),weight); else if(ifile==eMC) hMCv[n]->Fill(vDilep.M(),weight); else if(ifile==eMC2) hMC2v[n]->Fill(vDilep.M(),weight); } delete infile; infile=0, intree=0; } TCanvas *c1 = MakeCanvas("c1", "", 800, 800); char pname[100]; c1->Divide(1,2,0,0); c1->cd(1)->SetPad(0,0.3,1.0,1.0); c1->cd(1)->SetTopMargin(0.1); c1->cd(1)->SetBottomMargin(0.01); //0.01 c1->cd(1)->SetLeftMargin(0.15); c1->cd(1)->SetRightMargin(0.07); c1->cd(1)->SetTickx(1); c1->cd(1)->SetTicky(1); c1->cd(2)->SetPad(0,0,1.0,0.3); c1->cd(2)->SetTopMargin(0.05); c1->cd(2)->SetBottomMargin(0.45);//0.25 c1->cd(2)->SetLeftMargin(0.15); c1->cd(2)->SetRightMargin(0.07); c1->cd(2)->SetTickx(1); c1->cd(2)->SetTicky(0); TGaxis::SetMaxDigits(3); for (UInt_t ibin=0; ibin<scEta_limits.size(); ibin++) { for(UInt_t jbin=ibin; jbin<scEta_limits.size(); jbin++) { UInt_t n=jbin-ibin; for(UInt_t k=0; k<ibin; k++) n+=(scEta_limits.size()-k); //hMCv[n] ->Scale(1.0/hMCv[n]->Integral()); //hDatav[n] ->Scale(1.0/hDatav[n]->Integral()); //hMC2v[n]->Scale(1.0/hMC2v[n]->Integral()); c1->cd(1); hMCv[n]->SetLineColor(kRed); hMCv[n]->GetYaxis()->SetTitleOffset(1.100); hMCv[n]->GetYaxis()->SetTitle("Events"); hMCv[n]->GetYaxis()->SetRangeUser(0.01, 1.3*TMath::Max(hMCv[n]->GetMaximum(),hDatav[n]->GetMaximum())); hMCv[n]->Draw("hist"); hDatav[n]->Draw("EX0 same"); hMC2v[n]->SetLineColor(kBlue); hMC2v[n]->Draw("histsame"); c1->cd(2); TH1D* hDiffMC = returnRelDiff(hMCv[n],hDatav[n],"foo"); TH1D* hDiffMC2 = returnRelDiff(hMC2v[n],hDatav[n],"foo2"); hDiffMC->GetYaxis()->SetRangeUser(-1.0,1.0); hDiffMC->GetXaxis()->SetTitle("m_{ee} [GeV]"); hDiffMC->GetYaxis()->SetTitle("#chi"); hDiffMC->GetYaxis()->SetTitleOffset(0.42); hDiffMC->GetYaxis()->SetTitleSize(0.13); hDiffMC->GetXaxis()->SetTitleSize(0.13); hDiffMC->GetYaxis()->SetLabelSize(0.12); hDiffMC->GetXaxis()->SetLabelSize(0.12); hDiffMC->GetYaxis()->SetNdivisions(102); hDiffMC->GetYaxis()->CenterTitle(); hDiffMC->GetXaxis()->SetTitleOffset(1.2); hDiffMC->GetXaxis()->CenterTitle(); hDiffMC->Draw("hist"); TLine l(80,0.0,100,0.0); l.Draw(); hDiffMC->Draw("histsame"); hDiffMC2->SetMarkerColor(kBlue); hDiffMC2->SetMarkerSize(1); hDiffMC2->SetLineColor(kBlue); hDiffMC2->Draw("EX0 same"); c1->cd(1); TLegend *leg = new TLegend(0.65, 0.55, 0.90, 0.80); leg->SetShadowColor(0); leg->SetLineColor(0); leg->AddEntry(hMCv[n],"Raw MC","l"); leg->AddEntry(hDatav[n],"Data","l"); leg->AddEntry(hMC2v[n],"Corr. MC","l"); leg->Draw(); // CMS label TPaveText tb1(0.65,0.92,0.95,0.99,"NDC"); tb1.SetFillStyle(0); tb1.SetBorderSize(0); tb1.SetTextAlign(32); tb1.AddText("CMS Preliminary"); tb1.Draw(); char buffer[200]; // lumi label sprintf(buffer,"%.1f pb^{-1} at #sqrt{s} = 13 TeV",lumi); TPaveText tb2(0.55,0.82,0.90,0.90,"NDC"); tb2.SetFillStyle(0); tb2.SetBorderSize(0); tb2.SetTextAlign(32); tb2.AddText(buffer); tb2.Draw(); char str1[200],str2[200]; sprintf(str1,"[%.1f, %.1f]",scEta_limits.at(ibin).first,scEta_limits.at(ibin).second); sprintf(str2,"[%.1f, %.1f]",scEta_limits.at(jbin).first,scEta_limits.at(jbin).second); TPaveText *a = new TPaveText(0.16,0.75,0.40,0.82,"NDC"); a->SetFillColor(0); a->SetShadowColor(0); a->SetLineColor(0); a->AddText(str1); TPaveText *b = new TPaveText(0.16,0.68,0.40,0.75,"NDC"); b->SetFillColor(0); b->SetShadowColor(0); b->SetLineColor(0); b->AddText(str2); a->Draw(); b->Draw(); sprintf(pname,"ele_comp_%i_%i.png",ibin,jbin); c1->SaveAs(outputDir+"/"+pname); delete hDiffMC; delete hDiffMC2; } } cout << endl; cout << hMC_Tot->Integral() << ", " << hData_Tot->Integral() << ", " << hMC2_Tot->Integral() << endl; c1->cd(1); hMC_Tot->SetLineColor(kRed); hMC_Tot->SetMarkerColor(kRed); hMC_Tot->GetYaxis()->SetTitleOffset(1.100); hMC_Tot->GetYaxis()->SetTitle("Events"); hMC_Tot->GetYaxis()->SetRangeUser(0.01, 1.2*hMC_Tot->GetMaximum()); hMC_Tot->Draw("hist"); hData_Tot->Draw("EX0 same"); hMC2_Tot->SetLineColor(kBlue); hMC2_Tot->SetMarkerColor(kBlue); hMC2_Tot->Draw("hist same"); c1->cd(2); TH1D* hDiffMC = returnRelDiff(hMC_Tot,hData_Tot,"foo"); TH1D* hDiffMC2 = returnRelDiff(hMC2_Tot,hData_Tot,"foo2"); hDiffMC->GetYaxis()->SetRangeUser(-1.0,1.0); hDiffMC->GetXaxis()->SetTitle("m_{ee} [GeV]"); hDiffMC->GetYaxis()->SetTitle("#chi"); hDiffMC->GetYaxis()->SetTitleOffset(0.42); hDiffMC->GetYaxis()->SetTitleSize(0.13); hDiffMC->GetXaxis()->SetTitleSize(0.13); hDiffMC->GetYaxis()->SetLabelSize(0.12); hDiffMC->GetXaxis()->SetLabelSize(0.12); hDiffMC->GetYaxis()->SetNdivisions(102); hDiffMC->GetYaxis()->CenterTitle(); hDiffMC->GetXaxis()->SetTitleOffset(1.2); hDiffMC->GetXaxis()->CenterTitle(); hDiffMC->SetMarkerColor(kRed); hDiffMC->SetMarkerSize(1); hDiffMC->SetLineColor(kRed); hDiffMC->Draw("hist"); TLine l(80,0.0,100,0.0); l.Draw(); //hDiffMC->Draw("EX0 same"); hDiffMC2->SetMarkerColor(kBlue); hDiffMC2->SetMarkerSize(1); hDiffMC2->SetLineColor(kBlue); hDiffMC2->Draw("EX0 same"); c1->cd(1); TLegend *leg = new TLegend(0.65, 0.55, 0.90, 0.80); leg->SetShadowColor(0); leg->SetLineColor(0); leg->AddEntry(hMC_Tot,"Raw MC","l"); leg->AddEntry(hData_Tot,"Data","l"); leg->AddEntry(hMC2_Tot,"Corr. MC","l"); leg->Draw(); // CMS label TPaveText tb1(0.65,0.92,0.95,0.99,"NDC"); tb1.SetFillStyle(0); tb1.SetBorderSize(0); tb1.SetTextAlign(32); tb1.AddText("CMS Preliminary"); tb1.Draw(); char buffer[200]; // lumi label sprintf(buffer,"%.1f pb^{-1} at #sqrt{s} = 13 TeV",lumi); TPaveText tb2(0.55,0.82,0.90,0.90,"NDC"); tb2.SetFillStyle(0); tb2.SetBorderSize(0); tb2.SetTextAlign(32); tb2.AddText(buffer); tb2.Draw(); char str1[200],str2[200]; sprintf(str1,"[%.1f, %.1f]",scEta_limits.at(0).first,scEta_limits.at(scEta_limits.size()-1).second); sprintf(str2,"[%.1f, %.1f]",scEta_limits.at(0).first,scEta_limits.at(scEta_limits.size()-1).second); TPaveText *a = new TPaveText(0.16,0.75,0.40,0.82,"NDC"); a->SetFillColor(0); a->SetShadowColor(0); a->SetLineColor(0); a->AddText(str1); TPaveText *b = new TPaveText(0.16,0.68,0.40,0.75,"NDC"); b->SetFillColor(0); b->SetShadowColor(0); b->SetLineColor(0); b->AddText(str2); a->Draw(); b->Draw(); sprintf(pname,"ele_comp_tot.png"); c1->SaveAs(outputDir+"/"+pname); }