void DrawFitValue( TH2* frame, Double_t mean, Double_t err ) { Int_t DarkColor = TColor::GetColor( "#115000" ); Int_t LightColor = TColor::GetColor( "#bdff66" ); Double_t xmin = mean - err; Double_t xmax = mean + err; Double_t ymin = frame->GetYaxis()->GetXmin(); Double_t ymax = frame->GetYaxis()->GetXmax(); Double_t x[5] = { xmin, xmin, xmax, xmax, xmin }; Double_t y[5] = { ymin, ymax, ymax, ymin, ymin }; TGraph *box = new TGraph( 5, x, y ); box->SetLineColor( DarkColor ); box->SetFillColor( LightColor ); box->Draw("F"); TLine* louter = new TLine; TLine* linner = new TLine; louter->SetLineWidth( 1 ); louter->SetLineColor( DarkColor ); linner->SetLineWidth( 1 ); linner->SetLineStyle( 3 ); linner->SetLineColor( DarkColor ); louter->DrawLine( xmin, ymin, xmin, ymax ); louter->DrawLine( xmax, ymin, xmax, ymax ); linner->DrawLine( mean, ymin, mean, ymax ); }
void table(Float_t x1, Float_t x2, Float_t yrange, TText *t, const char **symbol, Bool_t octal) { Int_t i; Int_t n = 0; for (i=0;i<1000;i++) { if (!strcmp(symbol[i],"END")) break; n++; } Float_t y1 = 2.5; Float_t y2 = yrange - 0.5; Float_t dx = (x2-x1)/5; Float_t dy = (y2 - 1 -y1)/(n+1); Float_t y = y2 - 1 - 0.7*dy; Float_t xc0 = x1 + 0.5*dx; Float_t xc1 = xc0 + dx; Float_t xc2 = xc1 + dx; Float_t xc3 = xc2 + dx; Float_t xc4 = xc3 + dx; TLine *line = new TLine(); line->DrawLine(x1,y1,x1,y2); line->DrawLine(x1,y1,x2,y1); line->DrawLine(x1,y2,x2,y2); line->DrawLine(x2,y1,x2,y2); line->DrawLine(x1,y2-1,x2,y2-1); line->DrawLine(x1+ dx,y1,x1+ dx,y2); line->DrawLine(x1+2*dx,y1,x1+2*dx,y2); line->DrawLine(x1+3*dx,y1,x1+3*dx,y2); line->DrawLine(x1+4*dx,y1,x1+4*dx,y2); TText *tit = new TText(0,0,"a"); tit->SetTextSize(0.015); tit->SetTextFont(72); tit->SetTextAlign(22); tit->DrawText(xc0,y2-0.6,"Input"); tit->DrawText(xc1,y2-0.6,"Roman"); tit->DrawText(xc2,y2-0.6,"Greek"); tit->DrawText(xc3,y2-0.6,"Special"); tit->DrawText(xc4,y2-0.6,"Zapf"); char text[12]; for (i=0;i<n;i++) { if (octal) { unsigned char value = *symbol[i]; sprintf(text,"@\\ %3o",value); } else { strcpy(text,symbol[i]); } t->DrawText(xc0,y,text); sprintf(text,"%s",symbol[i]); t->DrawText(xc1,y,text); sprintf(text,"`%s",symbol[i]); t->DrawText(xc2,y,text); sprintf(text,"'%s",symbol[i]); t->DrawText(xc3,y,text); sprintf(text,"~%s",symbol[i]); t->DrawText(xc4,y,text); y -= dy; } }
void drawLine(TAxis* a) { TLine* line = new TLine; line->SetLineStyle(2); line->DrawLine(a->GetXmin(),1,a->GetXmax(),1); }
void DrawInsituCorr_vs_Eta(Str jetAlgo) { Nbins=sizeof(Ebins)/sizeof(double); myJES = new JetCalibrationTool(jetAlgo,_jesFile); TH1F *h = new TH1F("","",100,-4.8,4.8); h->SetXTitle("Jet #eta_{det}"); h->SetYTitle("Residual correction for data only"); h->SetMaximum(1.1); h->SetMinimum(0.85); h->Draw(); TLine *l = new TLine(); l->SetLineWidth(2); l->SetLineColor(kGray+2); l->SetLineStyle(4); l->DrawLine(-4.65,1,4.65,1); for (int i=0;i<Nbins;++i) { Graph *g = GetInsituGraph(Ebins[i]); FormatGraph(g,i); g->Draw("PL"); double x=0.52, y=0.3-0.05*i; if (i>2) { x=0.74; y=0.3-0.05*(i-3); } DrawLabel(Form("p_{T} = %.0f GeV",Ebins[i]),x,y,i); } l->SetLineWidth(2); l->SetLineColor(kGray+2); l->SetLineStyle(1); tex->SetNDC(); tex->SetTextAlign(12); //tex->DrawLatex(0.18,0.975,myJES->AbsoluteJES_Description()); tex->DrawLatex(0.18,0.9,GetJetDesc(jetAlgo)); }
void DrawInsituCorr_vs_Pt(Str jetAlgo) { myJES = new JetCalibrationTool(jetAlgo,_jesFile); TH1F *h = new TH1F("","",100,15,2500); h->SetXTitle("Jet p_{T}"); h->SetYTitle("Residual correction for data only"); h->SetMaximum(1.1); h->SetMinimum(0.85); h->Draw(); TLine *l = new TLine(); l->SetLineWidth(2); l->SetLineColor(kGray+2); l->SetLineStyle(4); l->DrawLine(16,1,2400,1); for (int i=0;i<6;++i) { double eta=4.0*i/5; Graph *g = GetInsituGraphVsPt(eta); FormatGraph(g,i); g->Draw("PL"); double x=0.52, y=0.3-0.05*i; if (i>2) { x=0.74; y=0.3-0.05*(i-3); } DrawLabel(Form("#eta = %.1f",eta),x,y,i); } l->SetLineWidth(2); l->SetLineColor(kGray+2); l->SetLineStyle(1); tex->SetNDC(); tex->SetTextAlign(12); //tex->DrawLatex(0.18,0.975,myJES->AbsoluteJES_Description()); tex->DrawLatex(0.18,0.9,GetJetDesc(jetAlgo)); }
void DrawJMS_vs_Eta(Str jetAlgo) { double massEbins[] = {50, 100, 250, 500, 750, 1500}; double massNbins = sizeof(massEbins)/sizeof(double); myJES = new JetCalibrationTool(jetAlgo,_jesFile); TH1F *h = new TH1F("","",100,-4.8,4.8); h->SetXTitle("Jet #eta_{det}"); h->SetYTitle("Jet mass response"); h->SetMaximum(1.4); h->SetMinimum(0.6); h->Draw(); TLine *l = new TLine(); l->SetLineWidth(2); l->SetLineColor(kGray+2); l->SetLineStyle(4); l->DrawLine(-4.65,1,4.65,1); for (int i=0;i<massNbins;++i) { Graph *g = GetJMSGraph(massEbins[i]); FormatGraph(g,i); g->Draw("PL"); double x=0.52, y=0.3-0.05*i; if (i>2) { x=0.74; y=0.3-0.05*(i-3); } DrawLabel(Form("E = %.0f GeV",massEbins[i]),x,y,i); } tex->SetNDC(); tex->SetTextAlign(12); tex->DrawLatex(0.18,0.975,myJES->AbsoluteJES_Description()); tex->DrawLatex(0.18,0.9,jetAlgo); }
void drawGrid(float x1, float y1, float x2, float y2, int nxbins, int nybins, float yOffset = 0.){ float step = (x2-x1) / nxbins; TLine* l = new TLine(0,0,0,0); for(float x = x1; x < x2; x += step){ l->DrawLine(x, y1, x, y2); } l->DrawLine(x2, y1, x2, y2); step = (y2-y1) / nybins; for(float y = y1; y < y2; y += step){ l->DrawLine(x1, y+yOffset, x2, y+yOffset); } if(yOffset<1.e-9) l->DrawLine(x1, y2, x2, y2); }
void drawcutline(double cutval, double maximum) { TLine *cut = new TLine(); cut->SetLineWidth(3); cut->SetLineColor(28); cut->DrawLine(cutval,0.,cutval,maximum); }
void HiggsPlot::PlotBF(int iDecay, double tBmH_max, double BF_max){ if(iDecay<0 || iDecay>2) {cout<<"iDecay must be 0, 1 or 2"<<endl; return;} styles style; style.setPadsStyle(-1); style.setDefaultStyle(); int nBins = 1000; TString hName, epsName = "public_html/Higgs_BF_TEMP_BaBar.eps", label, Llabel, Rlabel; TString yTitle[] = {"BF(B#rightarrow#tau#nu) (10^{-5})", "R(D)", "R(D*)"}; TString TagDecay[] = {"BF", "R(D)", "R(D*)"}; TCanvas can; TH1F *hBF[2]; for(int his=0; his<1; his++) { hName = "hBF"; hName += his; hBF[his] = new TH1F(hName,"",nBins,0,tBmH_max); } double tBmH, BF[2]; for(int bin=1; bin<=nBins; bin++){ tBmH = hBF[0]->GetBinCenter(bin); Compute(tBmH,BF,iDecay); hBF[0]->SetBinContent(bin, BF[0]); hBF[0]->SetBinError(bin, BF[1]); } hBF[0]->SetFillColor(2); hBF[0]->SetLineColor(2); hName += "1"; hBF[1] = static_cast<TH1F*>(hBF[0]->Clone(hName)); for(int bin=1; bin<=nBins; bin++)hBF[1]->SetBinError(bin,0); hBF[1]->SetFillColor(0);hBF[1]->SetLineColor(1); hBF[1]->SetLineWidth(2); TBox box; box.SetLineColor(4);box.SetFillColor(4); TLine line; line.SetLineStyle(1); line.SetLineColor(4); line.SetLineWidth(3); if(BF_max>0) hBF[0]->SetMaximum(BF_max); hBF[0]->Draw("e3"); box.SetFillStyle(3002); box.DrawBox(0,Measurement[iDecay][0]-Measurement[iDecay][1], tBmH_max,Measurement[iDecay][0]+Measurement[iDecay][1]); line.DrawLine(0,Measurement[iDecay][0],tBmH_max,Measurement[iDecay][0]); hBF[0]->Draw("e3 same"); hBF[1]->Draw("c same"); Compute(0,BF,iDecay); label = "#splitline{"; label += TagDecay[iDecay]; label += "_{SM} = "; if(iDecay==0){ label+="(";label+=RoundNumber(BF[0],1); label+=" #pm "; label+=RoundNumber(BF[1],1); label+=")#times10^{-5}}{BF_{exp} = ("; label+=RoundNumber(Measurement[iDecay][0],1); label+=" #pm "; label+=RoundNumber(Measurement[iDecay][1],1); label+=")#times10^{-5}}"; Llabel = ""; Rlabel = label; } else { label+=RoundNumber(BF[0],3); label+=" #pm "; label+=RoundNumber(BF[1],3); label+="}{"; label += TagDecay[iDecay]; label += "_{exp} = "; label+=RoundNumber(Measurement[iDecay][0],3); label+=" #pm "; label+=RoundNumber(Measurement[iDecay][1],3); label+="}"; Rlabel = ""; Llabel = label; } style.setTitles(hBF[0],"tan#beta/m_{H^{+}} (GeV^{-1})",yTitle[iDecay],Llabel,Rlabel); epsName.ReplaceAll("TEMP",DecayName[iDecay]); can.SaveAs(epsName); for(int his=0; his<2; his++) hBF[his]->Delete(); }
void SetupTowerDisplay(TH2F *hist) { hist->SetStats(kFALSE); hist->SetXTitle("ieta"); hist->SetYTitle("iphi"); hist->GetXaxis()->CenterTitle(); hist->GetYaxis()->CenterTitle(); hist->GetXaxis()->SetNdivisions(65); hist->GetXaxis()->SetLabelColor(0); hist->GetXaxis()->SetTickLength(.78); hist->GetXaxis()->SetTitleOffset(0.95); hist->GetYaxis()->SetNdivisions(72); hist->GetYaxis()->SetLabelColor(0); hist->GetYaxis()->SetTitleOffset(0.85); TText *yLabel = new TText(); TLine *pLine = new TLine(); pLine->SetLineStyle(1); pLine->SetLineColor(1); pLine->SetLineWidth(1); yLabel->SetTextAlign(22); yLabel->SetTextSize(0.015); char phi_num[3]; char eta_num[3]; TText *xLabel = new TText(); xLabel->SetTextSize(0.015); xLabel->SetTextAlign(22); for (Int_t i=1; i<73; ++i) { sprintf(phi_num,"%d",i); if(TMath::Abs(i%2)==1) {yLabel->DrawText(-33,0.5+i,phi_num);} else {yLabel->DrawText(-34.5,0.5+i,phi_num);} pLine->DrawLine(-32,i,33,i); } for (Int_t i=-32; i<33;++i) { sprintf(eta_num,"%d",i); if(TMath::Abs(i%2)==0) {xLabel->DrawText(0.5+i,-0.5,eta_num);} else {xLabel->DrawText(0.5+i,-2,eta_num);} pLine->DrawLine(i,1,i,72); } }
//======================================== void Draw2DHist(TH2F *h2D_Pt_Rap, Char_t *hltTag){ gStyle->SetOptStat(0); gStyle->SetPadRightMargin(0.12); Char_t name[100]; TCanvas *c2 = new TCanvas("c2a", "2D distribution", 600, 600); gPad->SetLogz(); // TH1F *hFrame = gPad->DrawFrame( // h2D_Pt_Rap->Draw("box"); h2D_Pt_Rap->GetYaxis()->SetTitleOffset(1.6); h2D_Pt_Rap->SetAxisRange(0,30.,"y"); h2D_Pt_Rap->SetMaximum(4000.); h2D_Pt_Rap->Draw("colz"); h2D_Pt_Rap->SetXTitle("y"); h2D_Pt_Rap->SetYTitle("p_{T} [GeV]"); TLine *lineV = new TLine(); lineV->SetLineColor(0); lineV->SetLineWidth(2); for(int iRap = 0; iRap < 2*onia::kNbRapBins+1; iRap++) lineV->DrawLine(onia::rapRange[iRap], 0., onia::rapRange[iRap], 30.); TLine *lineH = new TLine(); lineH->SetLineColor(0); lineH->SetLineWidth(2); for(int iRap = 1; iRap < onia::kNbRapForPTBins+1; iRap++){ for(int iPT = 1; iPT < onia::kNbPTBins[iRap]+1; iPT++){ lineH->DrawLine(onia::rapForPTRange[iRap-1], onia::pTRange[iRap][iPT], onia::rapForPTRange[iRap], onia::pTRange[iRap][iPT]); lineH->DrawLine(-onia::rapForPTRange[iRap-1], onia::pTRange[iRap][iPT], -onia::rapForPTRange[iRap], onia::pTRange[iRap][iPT]); } } // TLatex *tex = new TLatex(-2.3, 27., hltTag); // tex->SetTextSize(0.045); // tex->Draw(); // sprintf(name, "Figures/ptVsRap_%s.gif", hltTag); c2->Print(name); // sprintf(name, "Figures/ptVsRap_%s.pdf", hltTag); c2->Print(name); sprintf(name, "Figures/ptVsRap_Upsilons.gif"); c2->Print(name); sprintf(name, "Figures/ptVsRap_Upsilons.pdf"); c2->Print(name); }
void draw_diagonal_xchange(int scantype, std::string scanx = "" ) { // Line marking the diagonal TLine *line; float verticaloffset=0.0; if(scantype==PlottingSetup::GMSB) verticaloffset=75.0; line = new TLine(50.+75.0, 50.0+verticaloffset, 1200., 1200.0-75.0+verticaloffset); line->SetLineStyle(7); line->SetLineWidth(4); //line->Draw("same"); // Do not draw: draw the other one instead // Add a dashed line to indicate where x changes float offset = 0.; if ( 0 == scanx.compare("0.5") ) { offset = 91/0.5; } else if ( 0 == scanx.compare("0.25") ) { offset = 91/0.25; } else if ( 0 == scanx.compare("0.75") ) { offset = 91/0.75; } else if ( scantype==PlottingSetup::GMSB) { offset = 0; }; if ( offset>0. ) { line->DrawLine(50+offset, 50.0, 1175., 1175.0-offset); }else if ( scantype==PlottingSetup::GMSB ) { line->DrawLine(100, 100, 1175., 1175.0-offset); } }
void TPTiming () { TAxis * ax = TPMatchEmul2D->GetZaxis() ; ax->SetRangeUser(-1,6) ; TCanvas* canv = new TCanvas("canv", "canv") ; canv->SetLogz(0) ; gStyle->SetOptStat(10) ; int color[10]= {1,10,3,4,5,6,7,8,9,2} ; gStyle->SetPalette(7, color) ; TPMatchEmul2D->GetXaxis()->SetTitle("Phi index"); TPMatchEmul2D->GetYaxis()->SetTitle("Eta index"); TPMatchEmul2D->Draw("colz") ; TH2I * label = new TH2I("label", "",72, 1, 73, 38, -19, 19) ; label->SetMarkerSize(0.6); label->SetBit(kCanDelete); for (int x=3 ; x<73 ; x+=4) { for (int y=21; y<=37; y++) { int towernb = 4*(y-21)+1 ; label->SetBinContent(x-1, y, towernb) ; //EB+ label->SetBinContent(x, 40-y, towernb) ; //EB- } } label->Draw("same text") ; TLatex txt; txt.SetTextSize(0.02); TLine line; line.SetLineColor(1) ; line.SetLineStyle(1) ; line.SetLineWidth(1) ; TAxis* xAxis = TPMatchEmul2D->GetXaxis(); TAxis* yAxis = TPMatchEmul2D->GetYaxis(); // draw SM borders and numbers float sm ; for (int i=0; i<36 ; i++ ) { if (i<18) { sm = 4*i+3 ; line.DrawLine(sm, 1, sm, 18) ; txt.SetTextAlign(32); txt.DrawText(sm-1+0.3, -17.7, Form("-%d",i+1)); } else { sm = 4*(i-18)+3 ; line.DrawLine(sm, 0, sm, -17) ; txt.SetTextAlign(12); txt.DrawText(sm-2+0.3, 18.5, Form("+%d",i-17)); } } line.DrawLine(1, 0, 73, 0) ; line.DrawLine(1, -17, 73, -17) ; line.DrawLine(1, 1, 73, 1) ; line.DrawLine(1, 18, 73, 18) ; }
void DrawMeasurement( TH1 *h, Int_t nbin, Double_t val, Double_t err ) { TAxis *axis = h->GetYaxis(); Double_t dy; Double_t x1,y1,x2,y2, ymin; Int_t i = nbin; ymin = axis->GetBinCenter(i)+1; dy = axis->GetBinWidth(i); x1 = val - err; y1 = ymin - 0.05*dy; x2 = val + err; y2 = ymin + 0.05*dy; TLine* line = new TLine; TLine* lbar = new TLine; TLine* rbar = new TLine; TMarker* m2 = new TMarker( val, ymin, 20 ); Int_t color = 1; line->SetLineColor( color ); line->SetLineWidth( 2 ); lbar->SetLineColor( color ); lbar->SetLineWidth( 2 ); rbar->SetLineColor( color ); rbar->SetLineWidth( 2 ); m2->SetMarkerColor( color ); m2->SetMarkerSize( 1.2 ); m2->SetMarkerStyle( 21 ); line->DrawLine( x1, ymin, x2, ymin ); lbar->DrawLine( x1, y1, x1, y2 ); rbar->DrawLine( x2, y1, x2, y2 ); m2->Draw(); }
void DrawHijing2GeV() { TCanvas *c1 = new TCanvas(); TFile *fin = TFile::Open("Gamma_Neutron_Hijing_Energy_Graphs.root"); gROOT->cd(); TH1 *h1lim = new TH1F("h1lim","",1,0,0.1); TH1 *hjbkg = (TH1 *) fin->Get("hjbkg")->Clone(); TGraph *anti_neutron2GeV = (TGraph *) fin->Get("anti_neutron2GeV")->Clone(); TGraph *neutron2GeV = (TGraph *) fin->Get("neutron2GeV")->Clone(); h1lim->SetStats(0); h1lim->SetMaximum(0.3); h1lim->SetTitle("2 GeV Hadronic Showers with HIJING background"); h1lim->GetYaxis()->SetTitle("Deposited Energey [GeV]"); h1lim->GetYaxis()->SetTitleOffset(1.2); h1lim->GetXaxis()->SetTitle("cone size (#sqrt{#Delta#Phi^{2}+#Delta#Theta^{2}})"); h1lim->GetXaxis()->SetTitleOffset(1.2); h1lim->Draw(); hjbkg->SetStats(0); hjbkg->SetLineColor(6); hjbkg->SetMaximum(5.5); hjbkg->SetLineWidth(2); hjbkg->Draw("same"); anti_neutron2GeV->SetLineColor(4); anti_neutron2GeV->SetLineWidth(2); anti_neutron2GeV->Draw("same"); neutron2GeV->SetLineColor(2); neutron2GeV->SetLineWidth(2); neutron2GeV->Draw("same"); TLine *tl = new TLine(); tl->SetLineStyle(2); tl->DrawLine(0.024,0,0.024,0.3); TLegend *legrda = new TLegend(0.67,0.34,0.87,0.54,NULL,"brNDC"); legrda->SetLineColor(1); legrda->SetLineStyle(1); legrda->SetLineWidth(1); legrda->SetFillColor(10); legrda->SetFillStyle(1001); legrda->SetBorderSize(0); // legrda->SetTextSize(labelsize); legrda->AddEntry(hjbkg,"HIJING bkg"); legrda->AddEntry(anti_neutron2GeV,"2 GeV Anti Neutron","l"); legrda->AddEntry(neutron2GeV,"2 GeV Neutron", "l"); legrda->AddEntry(tl,"EMCal tower size","l"); legrda->Draw(); fin->Close(); c1->Print("Hijing2GeV.png"); }
void draw_graphs(void) { const char title[4][20] = {"Na_mean;um", "Na_sigma;um", "Co_mean;um", "Co_sigma;um"}; const double tgt[4] = {1.787, 0.394, 2.082, 0.473}; const double mc[4][4] = {{2.008, 1.985, 1.974, 1.933}, {0.319, 0.326, 0.330, 0.336}, {2.233, 2.211, 2.185, 2.149}, {0.377, 0.385, 0.394, 0.405}}; const double dl[4] = {0, 50, 100, 200}; const double mm[4][2] = {{1.7, 2.1}, {0.3, 0.4}, {2.0, 2.3}, {0.35, 0.5}}; TGraph *gr; TLine *ln; TH1D *h; TLegend *lg; int i; TCanvas *cv = new TCanvas; cv->Divide(2,2); gr = new TGraph; ln = new TLine; gr->SetMarkerStyle(kFullCircle); gr->SetMarkerSize(1.5); gr->SetMarkerColor(kBlue); ln->SetLineWidth(4); ln->SetLineColor(kRed); lg = new TLegend(0.65, 0.65, 0.95, 0.85); lg->AddEntry(ln, "Exp.", "L"); lg->AddEntry(gr, "MC", "P"); for (i=0; i<4; i++) { cv->cd(i+1); h = new TH1D(title[i], title[i], 100, 0, 200); h->SetMinimum(mm[i][0]); h->SetMaximum(mm[i][1]); h->DrawCopy(); gr->DrawGraph(4, dl, mc[i], "P"); ln->DrawLine(0, tgt[i], 200, tgt[i]); lg->Draw(); delete h; } }
//------------------------------------------// // Problem 1: there is a function called // utctimes(...). I want to figure out // where I should place cuts to seperate // the various luminosities //------------------------------------------// void checkUTCTimes(TTree* tree) { // Variables to plot TString varx = "startUTCDaqTime_/1.e15"; // scale by 1e15 TString vary = "DetectorResponseEvent_.totalBestEstimatedNPE_/1000."; //TString vary = "AtwdResponseChannels_.estimatedNPE_"; // Make canvas TCanvas* c = makeCanvas("c"); // Make a histogram to save float xmin = isSC2 ? 279.98 : 276.67; float xmax = isSC2 ? 280.15 : 276.84; float ymin = 0; float ymax = isSC2 ? 900 : 160; TH2F* frame = new TH2F("frame","",1, xmin,xmax,1,ymin,ymax); setAtt(frame,"Start DAQ Time / 10^{14}","Total Best Estimated NPE / 10^{3}"); frame->Draw(); // Draw from tree tree->Draw((vary+":"+varx).Data(),"","same"); // Add constant functions of time vector<double> times = isSC2 ? getTimesSC2() : getTimesSC1(); TLine* line = new TLine(); line->SetLineWidth(1); line->SetLineColor(kBlue); for(unsigned int t=0; t<times.size(); ++t){ double time = times.at(t); line->DrawLine(time,ymin,time,ymax); line->Draw("same"); } // Save the plot TString pname = "timeVsAmp.png"; c->SaveAs((savedir+pname).Data()); }
void plotThisOne() { gSystem->Load("libAskRay.so"); TCanvas * can = new TCanvas("can","can"); TH1F *framey = can->DrawFrame(-7e6,-7e6,+7e6,+7e6); TEllipse *elipsey = new TEllipse(0,0,6378.1e3,6378.1e3); elipsey->SetLineColor(8); elipsey->SetLineWidth(3); elipsey->Draw();//Ellipse(0,0,6378.1e3,6378.1e3); Double_t gz[361],gx[361]; Int_t count=0; for(Double_t theta=-180;theta<=180;theta+=1) { Double_t radius=AskGeom::getGeoidFromTheta(theta*TMath::DegToRad()); gz[count]=radius*TMath::Cos(theta*TMath::DegToRad()); gx[count]=radius*TMath::Sin(theta*TMath::DegToRad()); // cout << theta << "\t" << radius << "\t" << gz[count] << "\t" << gx[count] << endl; count++; } TGraph *geoid = new TGraph(count,gx,gz); geoid->Draw("l"); TLine *liney = new TLine(); liney->SetLineColor(9); liney->SetLineWidth(1); liney->SetLineStyle(2); Double_t point1[3]={-294476, 489656, 6.33461e+06}; Double_t point2[3]={-297716, 487929, 6.34309e+06}; liney->DrawLine(point1[1],point1[2],point2[1],point2[2]); }
void plotComparison( TH1F* h_dt , TH1F* h_mc , TH1F *h_extra, char* label, bool dolog, bool drawbkg) { TPad* fullpad = new TPad(); TPad* plotpad = new TPad(); TPad* respad = new TPad(); fullpad = new TPad("fullpad","fullpad",0,0,1,1); fullpad->Draw(); fullpad->cd(); plotpad = new TPad("plotpad","plotpad",0,0,1,0.8); plotpad->Draw(); plotpad->cd(); if (dolog) plotpad->SetLogy(); h_dt->GetYaxis()->SetTitle("Entries"); h_dt->GetXaxis()->SetTitle(Form("%s", label)); h_dt->GetYaxis()->SetTitleSize(0.05); h_dt->GetXaxis()->SetTitleSize(0.05); h_dt->GetYaxis()->SetTitleOffset(1.5); h_dt->GetXaxis()->SetTitleOffset(1.3); if (!dolog) h_dt->GetYaxis()->SetRangeUser(0., 1.4*h_dt->GetMaximum()); h_dt->SetLineColor(kBlack); h_dt->SetMarkerColor(kBlack); h_mc->SetLineColor(kBlue); h_mc->SetMarkerColor(kBlue); h_extra->SetLineColor(kRed); h_extra->SetLineWidth(2); h_mc->SetLineWidth(2); h_dt->Draw(); h_mc->Draw("HISTSAME"); if (drawbkg) h_extra->Draw("HISTSAME"); h_dt->Draw("ESAME"); TLegend *legComp = new TLegend( 0.653, 0.663, 0.944, 0.870); legComp->AddEntry(h_dt, "Data", "lp"); legComp->AddEntry(h_mc, "MC", "l"); if (drawbkg) legComp->AddEntry(h_extra, "MC Bkg", "l"); legComp->SetFillColor(0); legComp->SetBorderSize(0); legComp->Draw(); TLatex *text = new TLatex(); text->SetNDC(); text->SetTextSize(0.04); // float xtex = 0.65; // text->DrawLatex(xtex,0.88,"1 lepton + jets Sample"); fullpad->cd(); respad = new TPad("respad","respad",0,0.8,1,1); respad->Draw(); respad->cd(); //gPad->SetGridy(); TH1F* ratio = (TH1F*) h_dt->Clone("ratio"); ratio->Divide(h_mc); ratio->GetYaxis()->SetTitleOffset(0.3); ratio->GetYaxis()->SetTitleSize(0.2); ratio->GetYaxis()->SetNdivisions(5); ratio->GetYaxis()->SetLabelSize(0.2); if (dolog) ratio->GetYaxis()->SetRangeUser(0.5,1.5); else ratio->GetYaxis()->SetRangeUser(0.7,1.3); ratio->GetYaxis()->SetTitle("Ratio "); ratio->GetXaxis()->SetLabelSize(0); ratio->GetXaxis()->SetTitleSize(0); ratio->SetMarkerSize(1); ratio->SetLineWidth(2); ratio->SetLineColor(kBlue); ratio->SetMarkerColor(kBlue); ratio->SetFillColor(kBlue); ratio->SetFillStyle(3002); ratio->Draw("E2"); TLine line; line.SetLineWidth(2); line.DrawLine(h_dt->GetXaxis()->GetXmin(),1,h_dt->GetXaxis()->GetXmax(),1); }
void tree() { // // This macro displays the Tree data structures //Author: Rene Brun TCanvas* c1 = new TCanvas("c1","Tree Data Structure",200,10,750,940); c1->Range(0,-0.1,1,1.15); gBenchmark->Start("tree"); Int_t branchcolor = 26; Int_t leafcolor = 30; Int_t basketcolor = 42; Int_t offsetcolor = 43; TPaveLabel* title = new TPaveLabel(.3,1.05,.8,1.13,c1->GetTitle()); title->SetFillColor(16); title->Draw(); TPaveText* treePave = new TPaveText(.01,.75,.15,1.00); treePave->SetFillColor(18); treePave->SetTextAlign(12); TText *tnt = treePave->AddText("Tree"); tnt->SetTextAlign(22); tnt->SetTextSize(0.030); treePave->AddText("fScanField"); treePave->AddText("fMaxEventLoop"); treePave->AddText("fMaxVirtualSize"); treePave->AddText("fEntries"); treePave->AddText("fDimension"); treePave->AddText("fSelectedRows"); treePave->Draw(); TPavesText* farm = new TPavesText(.01,1.02,.15,1.1,9,"tr"); TText *tfarm = farm->AddText("CHAIN"); tfarm->SetTextSize(0.024); farm->AddText("Collection"); farm->AddText("of Trees"); farm->Draw(); TLine* llink = new TLine(.15,.92,.80,.92); llink->SetLineWidth(2); llink->SetLineColor(1); llink->Draw(); llink->DrawLine(.21,.87,.21,.275); llink->DrawLine(.23,.87,.23,.375); llink->DrawLine(.25,.87,.25,.775); llink->DrawLine(.41,.25,.41,-.025); llink->DrawLine(.43,.25,.43,.075); llink->DrawLine(.45,.25,.45,.175); TPaveLabel* branch0 = new TPaveLabel(.20,.87,.35,.97,"Branch 0"); branch0->SetTextSize(0.35); branch0->SetFillColor(branchcolor); branch0->Draw(); TPaveLabel* branch1 = new TPaveLabel(.40,.87,.55,.97,"Branch 1"); branch1->SetTextSize(0.35); branch1->SetFillColor(branchcolor); branch1->Draw(); TPaveLabel* branch2 = new TPaveLabel(.60,.87,.75,.97,"Branch 2"); branch2->SetTextSize(0.35); branch2->SetFillColor(branchcolor); branch2->Draw(); TPaveLabel* branch3 = new TPaveLabel(.80,.87,.95,.97,"Branch 3"); branch3->SetTextSize(0.35); branch3->SetFillColor(branchcolor); branch3->Draw(); TPaveLabel* leaf0 = new TPaveLabel(.4,.75,.5,.8,"Leaf 0"); leaf0->SetFillColor(leafcolor); leaf0->Draw(); TPaveLabel* leaf1 = new TPaveLabel(.6,.75,.7,.8,"Leaf 1"); leaf1->SetFillColor(leafcolor); leaf1->Draw(); TPaveLabel* leaf2 = new TPaveLabel(.8,.75,.9,.8,"Leaf 2"); leaf2->SetFillColor(leafcolor); leaf2->Draw(); TPaveText* firstevent = new TPaveText(.4,.35,.9,.4); firstevent->AddText("First event of each basket"); firstevent->AddText("Array of fMaxBaskets Integers"); firstevent->SetFillColor(basketcolor); firstevent->Draw(); TPaveLabel* basket0 = new TPaveLabel(.4,.25,.5,.3,"Basket 0"); basket0->SetFillColor(basketcolor); basket0->Draw(); TPaveLabel* basket1 = new TPaveLabel(.6,.25,.7,.3,"Basket 1"); basket1->SetFillColor(basketcolor); basket1->Draw(); TPaveLabel* basket2 = new TPaveLabel(.8,.25,.9,.3,"Basket 2"); basket2->SetFillColor(basketcolor); basket2->Draw(); TPaveText* offset = new TPaveText(.55,.15,.9,.2); offset->AddText("Offset of events in fBuffer"); offset->AddText("Array of fEventOffsetLen Integers"); offset->AddText("(if variable length structure)"); offset->SetFillColor(offsetcolor); offset->Draw(); TPaveText* buffer = new TPaveText(.55,.05,.9,.1); buffer->AddText("Basket buffer"); buffer->AddText("Array of fBasketSize chars"); buffer->SetFillColor(offsetcolor); buffer->Draw(); TPaveText* zipbuffer = new TPaveText(.55,-.05,.75,.0); zipbuffer->AddText("Basket compressed buffer"); zipbuffer->AddText("(if compression)"); zipbuffer->SetFillColor(offsetcolor); zipbuffer->Draw(); TArrow* ar1 = new TArrow(); ar1->SetLineWidth(2); ar1->SetLineColor(1); ar1->SetFillStyle(1001); ar1->SetFillColor(1); ar1->DrawArrow(.21,.275,.39,.275,0.015,"|>"); ar1->DrawArrow(.23,.375,.39,.375,0.015,"|>"); ar1->DrawArrow(.25,.775,.39,.775,0.015,"|>"); ar1->DrawArrow(.50,.775,.59,.775,0.015,"|>"); ar1->DrawArrow(.70,.775,.79,.775,0.015,"|>"); ar1->DrawArrow(.50,.275,.59,.275,0.015,"|>"); ar1->DrawArrow(.70,.275,.79,.275,0.015,"|>"); ar1->DrawArrow(.45,.175,.54,.175,0.015,"|>"); ar1->DrawArrow(.43,.075,.54,.075,0.015,"|>"); ar1->DrawArrow(.41,-.025,.54,-.025,0.015,"|>"); TLine* ldot = new TLine(.95,.92,.99,.92); ldot->SetLineStyle(3); ldot->Draw(); ldot->DrawLine(.9,.775,.99,.775); ldot->DrawLine(.9,.275,.99,.275); ldot->DrawLine(.55,.05,.55,0); ldot->DrawLine(.9,.05,.75,0); TText* pname = new TText(.46,.21,"fEventOffset"); pname->SetTextFont(72); pname->SetTextSize(0.018); pname->Draw(); pname->DrawText(.44,.11,"fBuffer"); pname->DrawText(.42,.01,"fZipBuffer"); pname->DrawText(.26,.81,"fLeaves = TObjArray of TLeaf"); pname->DrawText(.24,.40,"fBasketEvent"); pname->DrawText(.22,.31,"fBaskets = TObjArray of TBasket"); pname->DrawText(.20,1.0,"fBranches = TObjArray of TBranch"); TPaveText* ntleaf = new TPaveText(0.30,.42,.62,.7); ntleaf->SetTextSize(0.014); ntleaf->SetFillColor(leafcolor); ntleaf->SetTextAlign(12); ntleaf->AddText("fLen: number of fixed elements"); ntleaf->AddText("fLenType: number of bytes of data type"); ntleaf->AddText("fOffset: relative to Leaf0-fAddress"); ntleaf->AddText("fNbytesIO: number of bytes used for I/O"); ntleaf->AddText("fIsPointer: True if pointer"); ntleaf->AddText("fIsRange: True if leaf has a range"); ntleaf->AddText("fIsUnsigned: True if unsigned"); ntleaf->AddText("*fLeafCount: points to Leaf counter"); ntleaf->AddText(" "); ntleaf->AddLine(0,0,0,0); ntleaf->AddText("fName = Leaf name"); ntleaf->AddText("fTitle = Leaf type (see Type codes)"); ntleaf->Draw(); TPaveText* type = new TPaveText(.65,.42,.95,.7); type->SetTextAlign(12); type->SetFillColor(leafcolor); type->AddText(" "); type->AddText("C : a character string"); type->AddText("B : an 8 bit signed integer"); type->AddText("b : an 8 bit unsigned integer"); type->AddText("S : a 16 bit signed short integer"); type->AddText("s : a 16 bit unsigned short integer"); type->AddText("I : a 32 bit signed integer"); type->AddText("i : a 32 bit unsigned integer"); type->AddText("F : a 32 bit floating point"); type->AddText("D : a 64 bit floating point"); type->AddText("TXXXX : a class name TXXXX"); type->Draw(); TPaveLabel* typecode = new TPaveLabel(.7,.68,.9,.72,"fType codes"); typecode->SetFillColor(leafcolor); typecode->Draw(); ldot->DrawLine(.4,.75,.30,.7); ldot->DrawLine(.5,.75,.62,.7); TPaveText* ntbasket = new TPaveText(0.02,-0.07,0.35,.25); ntbasket->SetFillColor(basketcolor); ntbasket->SetTextSize(0.014); ntbasket->SetTextAlign(12); ntbasket->AddText("fNbytes: Size of compressed Basket"); ntbasket->AddText("fObjLen: Size of uncompressed Basket"); ntbasket->AddText("fDatime: Date/Time when written to store"); ntbasket->AddText("fKeylen: Number of bytes for the key"); ntbasket->AddText("fCycle : Cycle number"); ntbasket->AddText("fSeekKey: Pointer to Basket on file"); ntbasket->AddText("fSeekPdir: Pointer to directory on file"); ntbasket->AddText("fClassName: 'TBasket'"); ntbasket->AddText("fName: Branch name"); ntbasket->AddText("fTitle: TreePave name"); ntbasket->AddText(" "); ntbasket->AddLine(0,0,0,0); ntbasket->AddText("fNevBuf: Number of events in Basket"); ntbasket->AddText("fLast: pointer to last used byte in Basket"); ntbasket->Draw(); ldot->DrawLine(.4,.3,0.02,0.25); ldot->DrawLine(.5,.25,0.35,-.07); ldot->DrawLine(.5,.3,0.35,0.25); TPaveText* ntbranch = new TPaveText(0.02,0.40,0.18,0.68); ntbranch->SetFillColor(branchcolor); ntbranch->SetTextSize(0.015); ntbranch->SetTextAlign(12); ntbranch->AddText("fBasketSize"); ntbranch->AddText("fEventOffsetLen"); ntbranch->AddText("fMaxBaskets"); ntbranch->AddText("fEntries"); ntbranch->AddText("fAddress of Leaf0"); ntbranch->AddText(" "); ntbranch->AddLine(0,0,0,0); ntbranch->AddText("fName: Branchname"); ntbranch->AddText("fTitle: leaflist"); ntbranch->Draw(); ldot->DrawLine(.2,.97,.02,.68); ldot->DrawLine(.35,.97,.18,.68); ldot->DrawLine(.35,.87,.18,.40); TPavesText* basketstore = new TPavesText(.8,-0.088,0.952,-0.0035,7,"tr"); basketstore->SetFillColor(28); basketstore->AddText("Baskets"); basketstore->AddText("Stores"); basketstore->Draw(); c1->Update(); gBenchmark->Show("treePave"); }
void drawCMSresponse() { // New style settings // #include "tdrstyle_mod14.C" setTDRStyle(); // call cmsPrel(iPeriod, iPos); // int iPeriod = 2; // 1=7TeV, 2=8TeV, 3=7+8TeV, 7=7+8+13TeV // second parameter in example_plot is iPos, which drives the position of the CMS logo in the plot // iPos=11 : top-left, left-aligned // iPos=33 : top-right, right-aligned // iPos=22 : center, centered // mode generally : // iPos = 10*(alignement 1/2/3) + position (1/2/3 = left/center/right) if (!_jec) { const char *sd = "CondFormats/JetMETObjects/data"; //const char *st = "Winter14_V5_MC"; //const char *st = "Winter14_V8_MC"; // 2012 //const char *st = "Winter14_V8_DATA"; //const char *st = "Summer15_25nsV3_DATA"; //const char *st = "Summer15_25nsV6_DATA"; //const char *st = "Summer15_25nsV7_DATA"; //const char *st = "Fall15_25nsV1_DATA"; //const char *st = "Spring16_25nsV3_MC"; //const char *st = "Summer16_23Sep2016GV3_DATA"; // 2017 //const char *st = "Summer16_03Feb2017G_V3_DATA"; // 2017 03FebV3 const char *st = "Summer16_03Feb2017BCD_V7_DATA"; // 2017 03FebV7 const char *s; //s = Form("%s/%s_L1FastJet_AK5PFchs.txt",sd,st); cout << s << endl; //JetCorrectorParameters *l1 = new JetCorrectorParameters(s); s = Form("%s/%s_L1FastJet_AK4PFchs.txt",sd,st); cout << s << endl; JetCorrectorParameters *l1 = new JetCorrectorParameters(s); //s = Form("%s/%s_L2Relative_AK5PFchs.txt",sd,st); cout << s << endl; s = Form("%s/%s_L2Relative_AK4PFchs.txt",sd,st); cout << s << endl; JetCorrectorParameters *l2 = new JetCorrectorParameters(s); //s = Form("%s/%s_L3Absolute_AK5PFchs.txt",sd,st); cout << s << endl; s = Form("%s/%s_L3Absolute_AK4PFchs.txt",sd,st); cout << s << endl; JetCorrectorParameters *l3 = new JetCorrectorParameters(s); s = Form("%s/%s_L2L3Residual_AK4PFchs.txt",sd,st); cout << s << endl; JetCorrectorParameters *l2l3 = new JetCorrectorParameters(s); vector<JetCorrectorParameters> v; v.push_back(l1); v.push_back(*l2); v.push_back(*l3); v.push_back(*l2l3); _jec = new FactorizedJetCorrector(v); } if (!_jecpt) { _jecpt = new TF1("jecpt",fJECPt,0,6500,3); } //double ergs[] = {30, 60, 110, 400, 2000}; //const int ne = sizeof(ergs)/sizeof(ergs[0]); double pts[] = {10, 30, 100, 400, 2000}; const int npt = sizeof(pts)/sizeof(pts[0]); const int neta = 48;//52; const int jeta = TMath::Pi()*0.4*0.4; const int mu = 0; TGraph *gs[npt]; //for (int ie = 0; ie != ne; ++ie) { for (int ipt = 0; ipt != npt; ++ipt) { //double energy = ergs[ie]; double pt = pts[ipt]; TGraph *g = new TGraph(0); gs[ipt] = g; for (int ieta = 0; ieta != neta; ++ieta) { double eta = (ieta+0.5)*0.1; //double pt = energy / cosh(eta); double energy = pt * cosh(eta); if (pt >= 10. && energy < 6500.) { // 13 TeV double jes = getResp(pt, eta, jeta, mu); int n = g->GetN(); g->SetPoint(n, eta, jes); } } // for ie } // for ieta // Draw results //TH1D *h = new TH1D("h",";Jet |#eta|;Simulated jet response",40,0,4.8); //TH1D *h = new TH1D("h",";Jet |#eta|;Data jet response",40,0,4.8); TH1D *h = new TH1D("h",";Jet |#eta|;Data response+offset",40,0,4.8); h->SetMaximum(1.25); h->SetMinimum(0.5); extraText = "Simulation"; //extraText = "Simulation Preliminary"; //extraText = "Preliminary"; lumi_8TeV = ""; lumi_13TeV = ""; //lumi_13TeV = "2.1 fb^{-1}"; //TCanvas *c1 = tdrCanvas("c1",h,2,0,kSquare); TCanvas *c1 = tdrCanvas("c1",h,4,0,kSquare); TLegend *leg1 = tdrLeg(0.25,0.25,0.55,0.30); TLegend *leg2 = tdrLeg(0.25,0.20,0.55,0.25); TLegend *leg3 = tdrLeg(0.25,0.15,0.55,0.20); TLegend *leg4 = tdrLeg(0.55,0.25,0.85,0.30); TLegend *leg5 = tdrLeg(0.55,0.20,0.85,0.25); TLegend *legs[npt] = {leg1, leg2, leg3, leg4, leg5}; int colors[] = {kGreen+2, kBlack, kOrange+1, kBlue, kRed+1}; int markers[] = {kFullCircle, kOpenCircle, kFullSquare, kOpenSquare, kFullTriangleUp}; for (int ipt = 0; ipt != npt; ++ipt) { TGraph *g = gs[ipt]; g->SetMarkerColor(colors[ipt]); g->SetMarkerStyle(markers[ipt]); g->Draw("SAMEP"); //TLegend *leg = (ie<3 ? leg1 : leg2); TLegend *leg = legs[ipt]; leg->SetTextColor(colors[ipt]); //leg->AddEntry(g, Form("E = %1.0f GeV",ergs[ie]), "P"); leg->AddEntry(g, Form("p_{T} = %1.0f GeV",pts[ipt]), "P"); } TLatex *tex = new TLatex(); tex->SetNDC(); tex->SetTextSize(0.045); TLine *l = new TLine(); l->DrawLine(1.3,0.7,1.3,1.1); l->DrawLine(2.5,0.7,2.5,1.1); l->DrawLine(3.0,0.7,3.0,1.1); l->DrawLine(4.5,0.7,4.5,1.1); l->SetLineStyle(kDashed); l->DrawLine(3.2,0.7,3.2,1.1); //tex->DrawLatex(0.23,0.86,"2012 JES: Anti-k_{t} R = 0.5, PF+CHS"); //tex->DrawLatex(0.30,0.86,"53X JES: Anti-k_{t} R = 0.5, PF+CHS"); //tex->DrawLatex(0.30,0.86,"74X JES: Anti-k_{t} R = 0.4, PF+CHS"); //tex->DrawLatex(0.30,0.86,"76X JES: Anti-k_{t} R = 0.4, PF+CHS"); //tex->DrawLatex(0.23,0.86,"2016 JES: Anti-k_{T} R=0.4, PF+CHS"); tex->DrawLatex(0.23,0.86,"2017 JES: Anti-k_{t} R = 0.4, PF+CHS"); //tex->DrawLatex(0.23,0.86,"2017 03FebV3: Anti-k_{t} R = 0.4, PF+CHS"); tex->DrawLatex(0.19,0.78,"Barrel"); tex->DrawLatex(0.47,0.78,"Endcap"); //0.42 tex->DrawLatex(0.73,0.78,"Forward"); tex->DrawLatex(0.21,0.73,"BB"); tex->DrawLatex(0.43,0.73,"EC1"); tex->DrawLatex(0.57,0.73,"EC2"); tex->DrawLatex(0.77,0.73,"HF"); c1->SaveAs("pdf/drawCMSresponse.pdf"); } // drawCMSresponse
void qcd_study1( bool fillHists=false, bool savePlots=false, bool interactive=true, const char* datfile = "null" ) { TLine* line = new TLine() ; gStyle->SetPalette(1) ; gStyle->SetPadBottomMargin(0.20) ; gDirectory->Delete("h*") ; int nBinsBjets = 3 ; //-- met3-ht3-v5 const int nBinsMET = 3 ; const int nBinsHT = 3 ; // const int version = 5; float Mbins[nBinsMET+1] = {125, 200.,350.,99999.}; float Hbins[nBinsHT+1] = {400, 600.,1000.,99999.}; // ////-- met4-ht3-v3 // const int nBinsMET = 4 ; // const int nBinsHT = 3 ; // const int version = 3; // float Mbins[nBinsMET+1] = {125, 150.,250.,350.,99999.}; // float Hbins[nBinsHT+1] = {400, 600.,1000.,99999.}; ////-- met4-ht4-v15 //const int nBinsMET = 4 ; //const int nBinsHT = 4 ; // const int version = 15; //float Mbins[nBinsMET+1] = {125, 150.,250.,350.,99999.}; //float Hbins[nBinsHT+1] = {400, 500.,800.,1000.,99999.}; TH2F* hdummy = new TH2F("hdummy","",2, Mbins[0], 1500., 2, Hbins[0], 1500. ) ; const int nQcdSamples(9) ; char inputfile[9][1000] = { "files15fb_8TeV/QCD-120to170.root" ,"files15fb_8TeV/QCD-170to300.root" ,"files15fb_8TeV/QCD-300to470.root" ,"files15fb_8TeV/QCD-470to600.root" ,"files15fb_8TeV/QCD-600to800.root" ,"files15fb_8TeV/QCD-800to1000.root" ,"files15fb_8TeV/QCD-1000to1400.root" ,"files15fb_8TeV/QCD-1400to1800.root" ,"files15fb_8TeV/QCD-1800.root" } ; char samplename[9][100] = { "qcd_0120_to_0170" ,"qcd_0170_to_0300" ,"qcd_0300_to_0470" ,"qcd_0470_to_0600" ,"qcd_0600_to_0800" ,"qcd_0800_to_1000" ,"qcd_1000_to_1400" ,"qcd_1400_to_1800" ,"qcd_1800_to_9999" } ; // int samplecolor[9] = { // kOrange+8, // kRed, // KMagenta+2, // KBlue+1, // KAzure+2, // KGreen+2, // kPink-2, // kViolet+2, // kOrange+2 // } ; int samplecolor[9] = { 800+8, 632, 616+2, 600+1, 860+2, 416+2, 900-2, 880+2, 800+2 } ; TH2F* h0lep[nQcdSamples][nBinsBjets] ; TH2F* hldp [nQcdSamples][nBinsBjets] ; TCanvas* cqcd = (TCanvas*) gDirectory->FindObject("cqcd") ; if ( cqcd == 0x0 ) { cqcd = new TCanvas("cqcd", "qcd study", 700, 900 ) ; } char hname[1000] ; char htitle[1000] ; if ( fillHists ) { TChain* qcdch[nQcdSamples] ; printf("\n\n") ; for ( int si=0; si<nQcdSamples; si++ ) { qcdch[si] = new TChain("tree") ; printf(" %2d : connecting to %s\n", si, inputfile[si] ) ; qcdch[si] -> Add( inputfile[si] ) ; for ( int bbi=0; bbi<nBinsBjets; bbi++ ) { sprintf( hname, "h_0lep_%db_%s", bbi+1, samplename[si] ) ; sprintf( htitle, "QCD 0lep yield, nb=%d, %s", bbi+1, samplename[si] ) ; printf(" booking hist %s : %s\n", hname, htitle ) ; h0lep[si][bbi] = new TH2F( hname, htitle, nBinsMET, Mbins, nBinsHT, Hbins ) ; h0lep[si][bbi] -> Sumw2() ; sprintf( hname, "h_ldp_%db_%s", bbi+1, samplename[si] ) ; sprintf( htitle, "QCD LDP yield, nb=%d, %s", bbi+1, samplename[si] ) ; printf(" booking hist %s : %s\n", hname, htitle ) ; hldp [si][bbi] = new TH2F( hname, htitle, nBinsMET, Mbins, nBinsHT, Hbins ) ; hldp [si][bbi] -> Sumw2() ; } // bbi. } // si. printf("\n\n") ; char basecuts[10000] ; sprintf( basecuts, "pt_1st_leadJet>50&&pt_2nd_leadJet>50&&pt_3rd_leadJet>50&&HT>400&&MET>125&&nMu==0&&nEl==0&&nB>=1&&nJets>=3" ) ; char bcut[3][100] = { "nB==1", "nB==2", "nB>=3" } ; for ( int si=0; si<nQcdSamples; si++ ) { printf(" %2d : %s : 0lep\n", si, samplename[si] ) ; cout << flush ; for ( int bbi=0; bbi<nBinsBjets; bbi++ ) { char arg1[1000] ; char cuts0lep[10000] ; sprintf( cuts0lep, "(%s)&&(minDelPhiN>4&&%s)", basecuts, bcut[bbi] ) ; printf(" %db, 0lep cuts : %s\n", bbi+1, cuts0lep ) ; sprintf( arg1, "HT:MET>>h_0lep_%db_%s", bbi+1, samplename[si] ) ; qcdch[si] -> Draw( arg1, cuts0lep ) ; hdummy->Draw() ; h0lep[si][bbi]->Draw("samecolz") ; cqcd->Update() ; cqcd->Draw() ; char cutsldp[10000] ; sprintf( cutsldp, "(%s)&&(minDelPhiN<=4&&%s)", basecuts, bcut[bbi] ) ; printf(" %db, ldp cuts : %s\n", bbi+1, cutsldp ) ; sprintf( arg1, "HT:MET>>h_ldp_%db_%s", bbi+1, samplename[si] ) ; qcdch[si] -> Draw( arg1, cutsldp, "colz" ) ; hdummy->Draw() ; hldp[si][bbi]->Draw("samecolz") ; cqcd->Update() ; cqcd->Draw() ; } // bbi. } // si. saveHist( "rootfiles/qcd-study1.root", "h*" ) ; } //-------- gStyle->SetOptStat(0) ; gDirectory->Delete("h*") ; loadHist( "rootfiles/qcd-study1.root" ) ; for ( int si=0; si<nQcdSamples; si++ ) { for ( int bbi=0; bbi<nBinsBjets; bbi++ ) { sprintf( hname, "h_0lep_%db_%s", bbi+1, samplename[si] ) ; printf(" loading %s\n", hname ) ; h0lep[si][bbi] = (TH2F*) gDirectory->FindObject( hname ) ; if ( h0lep[si][bbi] == 0x0 ) { printf("\n\n *** %s missing.\n\n", hname ) ; return ; } sprintf( hname, "h_ldp_%db_%s", bbi+1, samplename[si] ) ; printf(" loading %s\n", hname ) ; hldp [si][bbi] = (TH2F*) gDirectory->FindObject( hname ) ; if ( hldp [si][bbi] == 0x0 ) { printf("\n\n *** %s missing.\n\n", hname ) ; return ; } } // bbi. } // si. //--- Flatten 2D histos and compute 0lep/LDP ratios for each sample. int nbins = nBinsMET*(nBinsHT+1) + 1 ; TH1F* hflat_0lep[nQcdSamples][nBinsBjets] ; TH1F* hflat_ldp [nQcdSamples][nBinsBjets] ; TH1F* hflat_0lepldp_ratio[nQcdSamples][nBinsBjets] ; sprintf( hname, "hflat_0lep_all" ) ; sprintf( htitle, "All QCD 0lep events" ) ; TH1F* hflat_0lep_all = bookHist( hname, htitle, nBinsMET, nBinsHT, 5 ) ; sprintf( hname, "hflat_ldp_all" ) ; sprintf( htitle, "All QCD ldp events" ) ; TH1F* hflat_ldp_all = bookHist( hname, htitle, nBinsMET, nBinsHT, 5 ) ; for ( int bbi=0; bbi<nBinsBjets; bbi++ ) { for ( int si=0; si<nQcdSamples; si++ ) { sprintf( hname, "hflat_0lep_%db_%s", bbi+1, samplename[si] ) ; sprintf( htitle, "QCD 0lep events, nb=%d, %s", bbi+1, samplename[si] ) ; hflat_0lep[si][bbi] = bookHist( hname, htitle, nBinsMET, nBinsHT, si ) ; hflat_0lep[si][bbi]->SetFillColor(11) ; hldp[si][bbi]->Print("all") ; sprintf( hname, "hflat_ldp_%db_%s", bbi+1, samplename[si] ) ; sprintf( htitle, "QCD LDP events, nb=%d, %s", bbi+1, samplename[si] ) ; hflat_ldp[si][bbi] = bookHist( hname, htitle, nBinsMET, nBinsHT, si ) ; hflat_ldp[si][bbi]->SetFillColor(11) ; sprintf( hname, "hflat_0lepldp_ratio_%db_%s", bbi+1, samplename[si] ) ; sprintf( htitle, "QCD 0lep/LDP ratio, nb=%d, %s", bbi+1, samplename[si] ) ; hflat_0lepldp_ratio[si][bbi] = bookHist( hname, htitle, nBinsMET, nBinsHT, si ) ; for ( int mbi=0; mbi<nBinsMET; mbi++ ) { for ( int hbi=0; hbi<nBinsHT; hbi++ ) { int histbin = 1 + (nBinsHT+1)*mbi + hbi + 1 ; float n0lep = h0lep[si][bbi] -> GetBinContent( mbi+1, hbi+1 ) ; float n0lep_err = h0lep[si][bbi] -> GetBinError( mbi+1, hbi+1 ) ; float nldp = hldp [si][bbi] -> GetBinContent( mbi+1, hbi+1 ) ; float nldp_err = hldp [si][bbi] -> GetBinError( mbi+1, hbi+1 ) ; hflat_0lep[si][bbi] -> SetBinContent( histbin, n0lep ) ; hflat_0lep[si][bbi] -> SetBinError( histbin, n0lep_err ) ; hflat_ldp[si][bbi] -> SetBinContent( histbin, nldp ) ; hflat_ldp[si][bbi] -> SetBinError( histbin, nldp_err ) ; double ratio(0.) ; if ( nldp > 0 ) { ratio = n0lep / nldp ; } double ratio_err(0.) ; if ( n0lep_err > 0. && nldp_err > 0. ) { ratio_err = ratio * sqrt( pow(n0lep_err/n0lep,2) + pow(nldp_err/nldp,2) ) ; } hflat_0lepldp_ratio[si][bbi] -> SetBinContent( histbin, ratio ) ; hflat_0lepldp_ratio[si][bbi] -> SetBinError( histbin, ratio_err ) ; } // hbi. } // mbi. hflat_0lep_all -> Add( hflat_0lep[si][bbi] ) ; hflat_ldp_all -> Add( hflat_ldp [si][bbi] ) ; cqcd->Clear() ; cqcd->Divide(1,3) ; cqcd->cd(1) ; hflat_0lep[si][bbi] -> DrawCopy("histe") ; hflat_0lep[si][bbi] -> DrawCopy("samee") ; cqcd->cd(2) ; hflat_ldp[si][bbi] -> DrawCopy("histe") ; hflat_ldp[si][bbi] -> DrawCopy("samee") ; cqcd->cd(3) ; hflat_0lepldp_ratio[si][bbi]->SetMinimum(-0.1) ; hflat_0lepldp_ratio[si][bbi]->SetMaximum(0.6) ; hflat_0lepldp_ratio[si][bbi]->SetMarkerStyle(20) ; hflat_0lepldp_ratio[si][bbi]->SetLineWidth(2) ; hflat_0lepldp_ratio[si][bbi]->DrawCopy() ; gPad->SetGridx(1) ; gPad->SetGridy(1) ; line->DrawLine(0.5,0,nbins+0.5,0) ; cqcd->Update() ; cqcd->Draw() ; } // si. } // bbi. TH1F* hflat_0lep_all_sqrtNerrs = (TH1F*) hflat_0lep_all->Clone("hflat_0lep_all_sqrtNerrs") ; TH1F* hflat_ldp_all_sqrtNerrs = (TH1F*) hflat_ldp_all ->Clone("hflat_ldp_all_sqrtNerrs") ; for ( int bi=1; bi<=nbins; bi++ ) { double val ; val = hflat_0lep_all_sqrtNerrs->GetBinContent( bi ) ; hflat_0lep_all_sqrtNerrs -> SetBinError( bi, sqrt(val) ) ; val = hflat_ldp_all_sqrtNerrs->GetBinContent( bi ) ; hflat_ldp_all_sqrtNerrs -> SetBinError( bi, sqrt(val) ) ; } //--- Compute sample average of 0lep/LDP ratio TH1F* hflat_0lepldp_ratio_ave[nBinsBjets] ; for ( int bbi=0; bbi<nBinsBjets; bbi++ ) { sprintf( hname, "hflat_0lepldp_ratio_ave_%db", bbi+1 ) ; sprintf( htitle, "QCD 0lep/LDP average ratio, nb=%d", bbi+1 ) ; hflat_0lepldp_ratio_ave[bbi] = bookHist( hname, htitle, nBinsMET, nBinsHT, 5 ) ; hflat_0lepldp_ratio_ave[bbi] -> SetMarkerStyle(24) ; hflat_0lepldp_ratio_ave[bbi] -> SetMarkerSize(2.0) ; hflat_0lepldp_ratio_ave[bbi] -> SetLineWidth(3) ; for ( int binind=1; binind<=nbins; binind++ ) { double wvsum(0.) ; double wsum(0.) ; for ( int si=0; si<nQcdSamples; si++ ) { double val = hflat_0lepldp_ratio[si][bbi] -> GetBinContent( binind ) ; double err = hflat_0lepldp_ratio[si][bbi] -> GetBinError( binind ) ; if ( err > 0 ) { double weight = 1./(err*err) ; wvsum += val*weight ; wsum += weight ; } } // si. if ( wsum > 0. ) { hflat_0lepldp_ratio_ave[bbi] -> SetBinContent( binind, wvsum/wsum ) ; hflat_0lepldp_ratio_ave[bbi] -> SetBinError( binind, 1./sqrt(wsum) ) ; } } // binind } // bbi. //--- Compute RMS spread of samples and total uncertainty TH1F* hflat_0lepldp_ratio_ave_withRMSerror[nBinsBjets] ; printf("\n\n") ; for ( int bbi=0; bbi<nBinsBjets; bbi++ ) { sprintf( hname, "hflat_0lepldp_ratio_ave_%db_withRMSerror", bbi+1 ) ; sprintf( htitle, "QCD 0lep/LDP average ratio, RMS included in error, nb=%d", bbi+1 ) ; hflat_0lepldp_ratio_ave_withRMSerror[bbi] = bookHist( hname, htitle, nBinsMET, nBinsHT, 5 ) ; hflat_0lepldp_ratio_ave_withRMSerror[bbi] -> SetMarkerStyle(24) ; hflat_0lepldp_ratio_ave_withRMSerror[bbi] -> SetMarkerSize(2.0) ; hflat_0lepldp_ratio_ave_withRMSerror[bbi] -> SetLineWidth(3) ; for ( int binind=1; binind<=nbins; binind++ ) { double sumsquare(0.) ; int nsum(0) ; double ave = hflat_0lepldp_ratio_ave[bbi] -> GetBinContent( binind ) ; double ave_err = hflat_0lepldp_ratio_ave[bbi] -> GetBinError( binind ) ; for ( int si=0; si<nQcdSamples; si++ ) { double val = hflat_0lepldp_ratio[si][bbi] -> GetBinContent( binind ) ; double err = hflat_0lepldp_ratio[si][bbi] -> GetBinError( binind ) ; if ( err <= 0 ) { continue ; } if ( val <= 0 ) { continue ; } if ( err/val > 0.5 ) { continue ; } //-- do not include points with very large errors. double diff = val - ave ; sumsquare += diff*diff ; nsum ++ ; } // si. if ( nsum > 1 ) { double rms = sqrt(sumsquare/nsum) ; double totalerr = sqrt( ave_err*ave_err + rms*rms ) ; const char* binlabel = hflat_0lepldp_ratio_ave_withRMSerror[bbi] -> GetXaxis() -> GetBinLabel( binind ) ; printf(" %s : %s : ratio = %5.3f, stat err = %5.3f, RMS = %5.3f, total err = %5.3f\n", hname, binlabel, ave, ave_err, rms, totalerr ) ; hflat_0lepldp_ratio_ave_withRMSerror[bbi] -> SetBinContent( binind, ave ) ; hflat_0lepldp_ratio_ave_withRMSerror[bbi] -> SetBinError( binind, totalerr ) ; } else { hflat_0lepldp_ratio_ave_withRMSerror[bbi] -> SetBinContent( binind, ave ) ; hflat_0lepldp_ratio_ave_withRMSerror[bbi] -> SetBinError( binind, ave_err ) ; } } // binind printf("\n") ; } // bbi. printf("\n\n") ; //--- compute global average 0lep/LDP ratio. double all0lep(0.) ; double allldp(0.) ; printf("\n\n") ; for ( int bbi=0; bbi<nBinsBjets; bbi++ ) { for ( int si=0; si<nQcdSamples; si++ ) { double sample_all0lep = h0lep[si][bbi] -> Integral() ; double sample_allldp = hldp [si][bbi] -> Integral() ; double sample_ratio(0.) ; if ( sample_allldp > 0 ) { sample_ratio = sample_all0lep / sample_allldp ; } printf( "%s, nb=%d : 0lep = %8.1f, LDP = %8.1f, ratio = %5.3f\n", samplename[si], bbi+1, sample_all0lep, sample_allldp, sample_ratio ) ; all0lep += sample_all0lep ; allldp += sample_allldp ; } // si. printf("\n") ; } // bbi. printf("\n\n") ; double global_0lepldp_ratio(0.) ; if ( allldp > 0.) { global_0lepldp_ratio = all0lep / allldp ; } else { printf("\n\n *** You screwed up.\n\n") ; return ; } printf(" overall : 0lep = %9.1f, LDP = %9.1f, ratio = %5.3f\n", all0lep, allldp, global_0lepldp_ratio ) ; //--- Compute scale factors. SF_i = (0lep/LDP)_i / global_(0lep/LDP) TH1F* hflat_scale_factor[nBinsBjets] ; TH1F* hflat_scale_factor_withRMSerror[nBinsBjets] ; for ( int bbi=0; bbi<nBinsBjets; bbi++ ) { sprintf( hname, "hflat_scale_factor_%db", bbi+1 ) ; sprintf( htitle, "QCD scale factor, nb=%d", bbi+1 ) ; hflat_scale_factor[bbi] = (TH1F*) hflat_0lepldp_ratio_ave[bbi]->Clone( hname ) ; hflat_scale_factor[bbi] -> SetTitle( htitle ) ; hflat_scale_factor[bbi] -> Scale( 1./ global_0lepldp_ratio ) ; sprintf( hname, "hflat_scale_factor_%db_withRMSerror", bbi+1 ) ; sprintf( htitle, "QCD scale factor, nb=%d, RMS error included ", bbi+1 ) ; hflat_scale_factor_withRMSerror[bbi] = (TH1F*) hflat_0lepldp_ratio_ave_withRMSerror[bbi]->Clone( hname ) ; hflat_scale_factor_withRMSerror[bbi] -> SetTitle( htitle ) ; hflat_scale_factor_withRMSerror[bbi] -> Scale( 1./ global_0lepldp_ratio ) ; } // bbi. //--- set Scale Factor values in dat file if one is provided. if ( strcmp( datfile, "null" ) != 0 ) { printf("\n\n\n Setting QCD scale factors in %s\n\n", datfile ) ; for ( int mbi=0; mbi<nBinsMET; mbi++ ) { for ( int hbi=0; hbi<nBinsHT; hbi++ ) { for ( int bbi=0; bbi<nBinsBjets; bbi++ ) { char parname[1000] ; int histbin = 1 + (nBinsHT+1)*mbi + hbi + 1 ; double val = hflat_scale_factor_withRMSerror[bbi]->GetBinContent( histbin ) ; double err = hflat_scale_factor_withRMSerror[bbi]->GetBinError( histbin ) ; if ( err <= 0 ) { val = 1.0 ; err = 3.0 ; } sprintf( parname, "sf_qcd_M%d_H%d_%db", mbi+1, hbi+1, bbi+1 ) ; updateFileValue( datfile, parname, val ) ; sprintf( parname, "sf_qcd_M%d_H%d_%db_err", mbi+1, hbi+1, bbi+1 ) ; updateFileValue( datfile, parname, err ) ; } // bbi. } // hbi. } // mbi. } //=========== End calculations. Plots and other output below here. =================================== //--- Plot all samples together TCanvas* cqcd2 = (TCanvas*) gDirectory->FindObject("cqcd2") ; if ( cqcd2 == 0x0 ) { cqcd2 = new TCanvas("cqcd2", "qcd study", 1700, 600 ) ; } TLegend* l2 = new TLegend( 0.79, 0.70, 0.99, 0.99 ) ; l2->AddEntry( hflat_0lepldp_ratio[0][0], "120 to 170" ) ; l2->AddEntry( hflat_0lepldp_ratio[1][0], "170 to 300" ) ; l2->AddEntry( hflat_0lepldp_ratio[2][0], "300 to 470" ) ; l2->AddEntry( hflat_0lepldp_ratio[3][0], "470 to 600" ) ; l2->AddEntry( hflat_0lepldp_ratio[4][0], "600 to 800" ) ; l2->AddEntry( hflat_0lepldp_ratio[5][0], "800 to 1000" ) ; l2->AddEntry( hflat_0lepldp_ratio[6][0], "1000 to 1400" ) ; l2->AddEntry( hflat_0lepldp_ratio[7][0], "1400 to 1800" ) ; l2->AddEntry( hflat_0lepldp_ratio[8][0], "> 1800" ) ; l2->AddEntry( hflat_0lepldp_ratio_ave[0], "Average ratio" ) ; cqcd2 -> Clear() ; cqcd2 -> Divide(3,1) ; cqcd2 -> cd(1) ; hflat_0lepldp_ratio[0][0] -> SetTitle("QCD 0lep/LDP ratio, nb=1") ; for ( int si=0; si<nQcdSamples; si++ ) { hflat_0lepldp_ratio[si][0] -> SetMarkerStyle(20+si) ; hflat_0lepldp_ratio[si][0] -> SetLineColor(samplecolor[si]) ; hflat_0lepldp_ratio[si][0] -> SetMarkerColor(samplecolor[si]) ; if ( si == 0 ) { hflat_0lepldp_ratio[si][0] -> DrawCopy() ; } else { hflat_0lepldp_ratio[si][0] -> DrawCopy("same") ; } } hflat_0lepldp_ratio_ave[0]->DrawCopy("same") ; line->DrawLine(0.5,0,nbins+0.5,0) ; l2->Draw() ; gPad->SetGridx(1) ; gPad->SetGridy(1) ; cqcd2 -> cd(2) ; hflat_0lepldp_ratio[0][1] -> SetTitle("QCD 0lep/LDP ratio, nb=2") ; for ( int si=0; si<nQcdSamples; si++ ) { hflat_0lepldp_ratio[si][1] -> SetMarkerStyle(20+si) ; hflat_0lepldp_ratio[si][1] -> SetLineColor(samplecolor[si]) ; hflat_0lepldp_ratio[si][1] -> SetMarkerColor(samplecolor[si]) ; if ( si == 0 ) { hflat_0lepldp_ratio[si][1] -> DrawCopy() ; } else { hflat_0lepldp_ratio[si][1] -> DrawCopy("same") ; } } hflat_0lepldp_ratio_ave[1]->DrawCopy("same") ; line->DrawLine(0.5,0,nbins+0.5,0) ; l2->Draw() ; gPad->SetGridx(1) ; gPad->SetGridy(1) ; cqcd2 -> cd(3) ; hflat_0lepldp_ratio[0][2] -> SetTitle("QCD 0lep/LDP ratio, nb>=3") ; for ( int si=0; si<nQcdSamples; si++ ) { hflat_0lepldp_ratio[si][2] -> SetMarkerStyle(20+si) ; hflat_0lepldp_ratio[si][2] -> SetLineColor(samplecolor[si]) ; hflat_0lepldp_ratio[si][2] -> SetMarkerColor(samplecolor[si]) ; if ( si == 0 ) { hflat_0lepldp_ratio[si][2] -> DrawCopy() ; } else { hflat_0lepldp_ratio[si][2] -> DrawCopy("same") ; } } hflat_0lepldp_ratio_ave[2]->DrawCopy("same") ; line->DrawLine(0.5,0,nbins+0.5,0) ; l2->Draw() ; gPad->SetGridx(1) ; gPad->SetGridy(1) ; cqcd2->Update() ; cqcd2->Draw() ; if ( savePlots ) { cqcd2 -> SaveAs("outputfiles/qcd-study1-allonone.png") ; cqcd2 -> SaveAs("outputfiles/qcd-study1-allonone.pdf") ; } //--- Go through the samples, 1 by 1, and draw numerator, denominator, and ratio TCanvas* cqcd3 = (TCanvas*) gDirectory->FindObject("cqcd3") ; if ( cqcd3 == 0x0 ) { cqcd3 = new TCanvas("cqcd3", "qcd study", 1200, 900 ) ; } char oldtitle[1000] ; sprintf( oldtitle, "QCD 0lep/LDP ratio, nb=1, %s", samplename[0] ) ; hflat_0lepldp_ratio[0][0] -> SetTitle(oldtitle) ; sprintf( oldtitle, "QCD 0lep/LDP ratio, nb=2, %s", samplename[0] ) ; hflat_0lepldp_ratio[0][1] -> SetTitle(oldtitle) ; sprintf( oldtitle, "QCD 0lep/LDP ratio, nb>=3, %s", samplename[0] ) ; hflat_0lepldp_ratio[0][2] -> SetTitle(oldtitle) ; cqcd3->Clear() ; cqcd3->Divide(3,3) ; for ( int si=0; si<nQcdSamples; si++ ) { TLegend* l3 = new TLegend( 0.65, 0.78, 0.99, 0.92) ; l3->AddEntry( hflat_0lepldp_ratio[si][0], samplename[si] ) ; l3->AddEntry( hflat_0lepldp_ratio_ave[0], "Average") ; for ( int bbi=0; bbi<nBinsBjets; bbi++ ) { cqcd3->cd(1+bbi) ; hflat_0lep[si][bbi] -> DrawCopy("histe") ; hflat_0lep[si][bbi] -> DrawCopy("samee") ; cqcd3->cd(4+bbi) ; hflat_ldp[si][bbi] -> DrawCopy("histe") ; hflat_ldp[si][bbi] -> DrawCopy("samee") ; cqcd3->cd(7+bbi) ; gPad->SetGridx(1) ; gPad->SetGridy(1) ; hflat_0lepldp_ratio[si][bbi]->DrawCopy() ; hflat_0lepldp_ratio_ave[bbi]->DrawCopy("same") ; line->DrawLine(0.5,0,nbins+0.5,0) ; l3->Draw() ; } // bbi. cqcd3->Update() ; cqcd3->Draw() ; if ( savePlots ) { char filename[1000] ; sprintf( filename, "outputfiles/qcd-study1-%s.pdf", samplename[si] ) ; cqcd3 -> SaveAs( filename ) ; sprintf( filename, "outputfiles/qcd-study1-%s.png", samplename[si] ) ; cqcd3 -> SaveAs( filename ) ; } if ( interactive ) { char a = getchar() ; if ( a == 'q') { return ; } } } // si. //--- Draw the average 0lep/LDP ratio with MC stat error and total error. TCanvas* cqcd4 = (TCanvas*) gDirectory->FindObject("cqcd4") ; if ( cqcd4 == 0x0 ) { cqcd4 = new TCanvas("cqcd4", "qcd study", 1700, 600 ) ; } gStyle->SetEndErrorSize(5) ; cqcd4->Clear() ; cqcd4->Divide(3,1) ; cqcd4 -> cd(1) ; hflat_0lepldp_ratio_ave[0] -> SetTitle("Average QCD 0lep/LDP ratio, nb=1") ; hflat_0lepldp_ratio_ave[0] -> SetMarkerSize(1.2) ; hflat_0lepldp_ratio_ave[0] -> SetMarkerStyle(20) ; hflat_0lepldp_ratio_ave[0] -> SetMaximum(0.6) ; hflat_0lepldp_ratio_ave[0] -> SetMinimum(-0.1) ; hflat_0lepldp_ratio_ave[0]->DrawCopy("e1") ; hflat_0lepldp_ratio_ave_withRMSerror[0]->SetMarkerStyle() ; hflat_0lepldp_ratio_ave_withRMSerror[0]->SetLineColor(4) ; hflat_0lepldp_ratio_ave_withRMSerror[0]->DrawCopy("samee1") ; hflat_0lepldp_ratio_ave[0]->DrawCopy("samee1") ; line->DrawLine(0.5,0,nbins+0.5,0) ; gPad->SetGridx(1) ; gPad->SetGridy(1) ; cqcd4 -> cd(2) ; hflat_0lepldp_ratio_ave[1] -> SetTitle("Average QCD 0lep/LDP ratio, nb=2") ; hflat_0lepldp_ratio_ave[1] -> SetMarkerSize(1.2) ; hflat_0lepldp_ratio_ave[1] -> SetMarkerStyle(20) ; hflat_0lepldp_ratio_ave[1] -> SetMaximum(0.6) ; hflat_0lepldp_ratio_ave[1] -> SetMinimum(-0.1) ; hflat_0lepldp_ratio_ave[1]->DrawCopy("e1") ; hflat_0lepldp_ratio_ave_withRMSerror[1]->SetMarkerStyle() ; hflat_0lepldp_ratio_ave_withRMSerror[1]->SetLineColor(4) ; hflat_0lepldp_ratio_ave_withRMSerror[1]->DrawCopy("samee1") ; hflat_0lepldp_ratio_ave[1]->DrawCopy("samee1") ; line->DrawLine(0.5,0,nbins+0.5,0) ; gPad->SetGridx(1) ; gPad->SetGridy(1) ; cqcd4 -> cd(3) ; hflat_0lepldp_ratio_ave[2] -> SetTitle("Average QCD 0lep/LDP ratio, nb>=3") ; hflat_0lepldp_ratio_ave[2] -> SetMarkerSize(1.2) ; hflat_0lepldp_ratio_ave[2] -> SetMarkerStyle(20) ; hflat_0lepldp_ratio_ave[2] -> SetMaximum(0.6) ; hflat_0lepldp_ratio_ave[2] -> SetMinimum(-0.1) ; hflat_0lepldp_ratio_ave[2]->DrawCopy("e1") ; hflat_0lepldp_ratio_ave_withRMSerror[2]->SetMarkerStyle() ; hflat_0lepldp_ratio_ave_withRMSerror[2]->SetLineColor(4) ; hflat_0lepldp_ratio_ave_withRMSerror[2]->DrawCopy("samee1") ; hflat_0lepldp_ratio_ave[2]->DrawCopy("samee1") ; line->DrawLine(0.5,0,nbins+0.5,0) ; gPad->SetGridx(1) ; gPad->SetGridy(1) ; cqcd4->Update() ; cqcd4->Draw() ; if ( savePlots ) { cqcd4 -> SaveAs("outputfiles/qcd-study1-averatio.png") ; cqcd4 -> SaveAs("outputfiles/qcd-study1-averatio.pdf") ; } //--- Draw the QCD scale factor with MC stat error and total error. TCanvas* cqcd5 = (TCanvas*) gDirectory->FindObject("cqcd5") ; if ( cqcd5 == 0x0 ) { cqcd5 = new TCanvas("cqcd5", "qcd study", 1700, 600 ) ; } gStyle->SetEndErrorSize(5) ; cqcd5->Clear() ; cqcd5->Divide(3,1) ; cqcd5 -> cd(1) ; hflat_scale_factor[0] -> SetTitle("QCD Scale Factor, nb=1") ; hflat_scale_factor[0] -> SetMarkerSize(1.2) ; hflat_scale_factor[0] -> SetMarkerStyle(20) ; hflat_scale_factor[0] -> SetMaximum(2.6) ; hflat_scale_factor[0] -> SetMinimum(-0.1) ; hflat_scale_factor[0]->DrawCopy("e1") ; hflat_scale_factor_withRMSerror[0]->SetMarkerStyle() ; hflat_scale_factor_withRMSerror[0]->SetLineColor(4) ; hflat_scale_factor_withRMSerror[0]->DrawCopy("samee1") ; hflat_scale_factor[0]->DrawCopy("samee1") ; line->DrawLine(0.5,0,nbins+0.5,0) ; gPad->SetGridx(1) ; gPad->SetGridy(1) ; cqcd5 -> cd(2) ; hflat_scale_factor[1] -> SetTitle("QCD Scale Factor, nb=2") ; hflat_scale_factor[1] -> SetMarkerSize(1.2) ; hflat_scale_factor[1] -> SetMarkerStyle(20) ; hflat_scale_factor[1] -> SetMaximum(2.6) ; hflat_scale_factor[1] -> SetMinimum(-0.1) ; hflat_scale_factor[1]->DrawCopy("e1") ; hflat_scale_factor_withRMSerror[1]->SetMarkerStyle() ; hflat_scale_factor_withRMSerror[1]->SetLineColor(4) ; hflat_scale_factor_withRMSerror[1]->DrawCopy("samee1") ; hflat_scale_factor[1]->DrawCopy("samee1") ; line->DrawLine(0.5,0,nbins+0.5,0) ; gPad->SetGridx(1) ; gPad->SetGridy(1) ; cqcd5 -> cd(3) ; hflat_scale_factor[2] -> SetTitle("QCD Scale Factor, nb>=3") ; hflat_scale_factor[2] -> SetMarkerSize(1.2) ; hflat_scale_factor[2] -> SetMarkerStyle(20) ; hflat_scale_factor[2] -> SetMaximum(2.6) ; hflat_scale_factor[2] -> SetMinimum(-0.1) ; hflat_scale_factor[2]->DrawCopy("e1") ; hflat_scale_factor_withRMSerror[2]->SetMarkerStyle() ; hflat_scale_factor_withRMSerror[2]->SetLineColor(4) ; hflat_scale_factor_withRMSerror[2]->DrawCopy("samee1") ; hflat_scale_factor[2]->DrawCopy("samee1") ; line->DrawLine(0.5,0,nbins+0.5,0) ; gPad->SetGridx(1) ; gPad->SetGridy(1) ; cqcd5->Update() ; cqcd5->Draw() ; if ( savePlots ) { cqcd5 -> SaveAs("outputfiles/qcd-study1-scalefactor.png") ; cqcd5 -> SaveAs("outputfiles/qcd-study1-scalefactor.pdf") ; } } // qcd_study.
void plotDistribution( TChain* data , TChain *mc , TCut sel , TCut vtxweight , char* var , int nbins , float xmin , float xmax , char* xtitle , char* plottitle = "" , bool printplot = false , bool residual = false , bool log = false ){ //-------------------------------------- // define histograms and TGraphs //-------------------------------------- TH1F* hdata = new TH1F(Form("hdata_%i" , iplot),Form("hdata_%i" , iplot),nbins,xmin,xmax); TH1F* hmc = new TH1F(Form("hmc_%i" , iplot),Form("hmc_%i" , iplot),nbins,xmin,xmax); TH1F* hmc_novtx = new TH1F(Form("hmc_novtx_%i" , iplot),Form("hmc_novtx%i" , iplot),nbins,xmin,xmax); hdata->Sumw2(); hmc->Sumw2(); TGraphAsymmErrors* grdata = new TGraphAsymmErrors(); TGraphAsymmErrors* grmc = new TGraphAsymmErrors(); TH1F* hdata_denom = new TH1F(Form("hdata_denom_%i",iplot),"",nbins,xmin,xmax); TH1F* hmc_denom = new TH1F(Form("hmc_denom_%i" ,iplot),"",nbins,xmin,xmax); //-------------------------------------- // set up canvas and pads //-------------------------------------- TCanvas *can = new TCanvas(Form("can_%i",iplot),Form("can_%i",iplot),600,600); can->cd(); if( log ) gPad->SetLogy(); TPad *mainpad = new TPad("mainpad","mainpad",0.0,0.0,1.0,0.8); if( residual ){ mainpad->Draw(); mainpad->cd(); if( log ) mainpad->SetLogy(); } //-------------------------------------- // fill histos and TGraphs //-------------------------------------- data->Draw(Form("min(%s,%f)>>hdata_%i" , var,xmax-0.0001,iplot),sel); mc ->Draw(Form("min(%s,%f)>>hmc_%i" , var,xmax-0.0001,iplot),sel*vtxweight); mc ->Draw(Form("min(%s,%f)>>hmc_novtx_%i" , var,xmax-0.0001,iplot),sel); for( int ibin = 1 ; ibin <= nbins ; ibin++ ){ hdata_denom->SetBinContent(ibin,hdata->Integral()); hmc_denom->SetBinContent(ibin,hmc->Integral()); } grdata->BayesDivide(hdata,hdata_denom); grmc->BayesDivide(hmc_novtx,hmc_denom); //-------------------------------------- // get efficiencies and errors //-------------------------------------- /* float ndata1 = (float) hdata->GetBinContent(1); float ndata = (float) hdata->Integral(); float effdata = 1-ndata1 / ndata; // TGraphAsymmErrors* grdata_temp = new TGraphAsymmErrors(); // TH1F* hdata_num_temp = new TH1F(Form("hdata_num_temp_%i",iplot),"",1,0,1); // TH1F* hdata_den_temp = new TH1F(Form("hdata_den_temp_%i",iplot),"",1,0,1); // hdata_num_temp->SetBinContent(1,ndata-ndata1); // hdata_den_temp->SetBinContent(1,ndata); // grdata_temp->BayesDivide(hdata_num_temp,hdata_den_temp); //float effdataerr = sqrt(ndata1) / ndata; float effdataerr = 0.5 * ( grdata->GetErrorYlow(0) + grdata->GetErrorYhigh(0) ); //float effdataerr = 0.5 * ( grdata_temp->GetErrorYlow(0) + grdata_temp->GetErrorYhigh(0) ); float nmc1 = (float) hmc->GetBinContent(1); float nmc = (float) hmc->Integral(); float effmc = 1-nmc1 / nmc; //float effmcerr = hmc->GetBinError(1) / nmc; float effmcerr = 0.5 * ( grmc->GetErrorYlow(0) + grmc->GetErrorYhigh(0) ); float datatot = hdata->Integral(); float mctot = hmc->Integral(); cout << endl; cout << plottitle << endl; cout << "Data eff " << Form("%.2f +/- %.3f",effdata,effdataerr) << endl; cout << "MC eff " << Form("%.2f +/- %.3f",effmc ,effmcerr) << endl; cout << "Data/MC " << Form("%.2f +/- %.2f",ratio ,ratioerr) << endl; */ float ndata = hdata->Integral(); float ndata1 = hdata->Integral(2,20); float ndata2 = hdata->Integral(3,20); float ndata3 = hdata->Integral(4,20); float ndata4 = hdata->Integral(5,20); float ndata5 = hdata->Integral(6,20); float nmc = hmc->Integral(); float nmc1 = hmc->Integral(2,20); float nmc2 = hmc->Integral(3,20); float nmc3 = hmc->Integral(4,20); float nmc4 = hmc->Integral(5,20); float nmc5 = hmc->Integral(6,20); float effdata1 = ndata1/ndata; float effdata2 = ndata2/ndata; float effdata3 = ndata3/ndata; float effdata4 = ndata4/ndata; float effdata5 = ndata5/ndata; float effmc1 = nmc1/nmc; float effmc2 = nmc2/nmc; float effmc3 = nmc3/nmc; float effmc4 = nmc4/nmc; float effmc5 = nmc5/nmc; float effdata1err = getBinomialError(ndata1,ndata); float effdata2err = getBinomialError(ndata2,ndata); float effdata3err = getBinomialError(ndata3,ndata); float effdata4err = getBinomialError(ndata4,ndata); float effdata5err = getBinomialError(ndata5,ndata); float effmc1err = getBinomialError(nmc1,nmc); float effmc2err = getBinomialError(nmc2,nmc); float effmc3err = getBinomialError(nmc3,nmc); float effmc4err = getBinomialError(nmc4,nmc); float effmc5err = getBinomialError(nmc5,nmc); float ratio1 = effdata1/effmc1; float ratio2 = effdata2/effmc2; float ratio3 = effdata3/effmc3; float ratio4 = effdata4/effmc4; float ratio5 = effdata5/effmc5; float ratio1err = ratio1 * sqrt(pow(effdata1err/effdata1,2)+pow(effmc1err/effmc1,2)); float ratio2err = ratio2 * sqrt(pow(effdata2err/effdata2,2)+pow(effmc2err/effmc2,2)); float ratio3err = ratio3 * sqrt(pow(effdata3err/effdata3,2)+pow(effmc3err/effmc3,2)); float ratio4err = ratio4 * sqrt(pow(effdata4err/effdata4,2)+pow(effmc4err/effmc4,2)); float ratio5err = ratio5 * sqrt(pow(effdata5err/effdata5,2)+pow(effmc5err/effmc5,2)); cout << endl << endl << plottitle << endl; int left = 20; // char* delimstart = "|"; // char* delim = "|"; // char* delimend = "|"; // char* pm = "+/-"; char* delimstart = ""; char* delim = "&"; char* delimend = "\\\\"; char* pm = "$\\pm$"; cout << delimstart << setw(10) << "" << setw(4) << delim << setw(left) << "$>$ 1 GeV" << setw(4) << delim << setw(left) << "$>$ 2 GeV" << setw(4) << delim << setw(left) << "$>$ 3 GeV" << setw(4) << delim << setw(left) << "$>$ 4 GeV" << setw(4) << delim << setw(left) << "$>$ 5 GeV" << setw(4) << delimend << endl; cout << delimstart << setw(10) << "data" << setw(4) << delim << setw(left) << Form("%.3f %s %.4f",effdata1,pm,effdata1err) << setw(4) << delim << setw(left) << Form("%.3f %s %.4f",effdata2,pm,effdata2err) << setw(4) << delim << setw(left) << Form("%.3f %s %.4f",effdata3,pm,effdata3err) << setw(4) << delim << setw(left) << Form("%.3f %s %.4f",effdata4,pm,effdata4err) << setw(4) << delim << setw(left) << Form("%.3f %s %.4f",effdata5,pm,effdata5err) << setw(4) << delimend << endl; cout << delimstart << setw(10) << "mc" << setw(4) << delim << setw(left) << Form("%.3f %s %.4f",effmc1,pm,effmc1err) << setw(4) << delim << setw(left) << Form("%.3f %s %.4f",effmc2,pm,effmc2err) << setw(4) << delim << setw(left) << Form("%.3f %s %.4f",effmc3,pm,effmc3err) << setw(4) << delim << setw(left) << Form("%.3f %s %.4f",effmc4,pm,effmc4err) << setw(4) << delim << setw(left) << Form("%.3f %s %.4f",effmc5,pm,effmc5err) << setw(4) << delimend << endl; cout << delimstart << setw(10) << "data/mc" << setw(4) << delim << setw(left) << Form("%.2f %s %.2f",ratio1,pm,ratio1err) << setw(4) << delim << setw(left) << Form("%.2f %s %.2f",ratio2,pm,ratio2err) << setw(4) << delim << setw(left) << Form("%.2f %s %.2f",ratio3,pm,ratio3err) << setw(4) << delim << setw(left) << Form("%.2f %s %.2f",ratio4,pm,ratio4err) << setw(4) << delim << setw(left) << Form("%.2f %s %.2f",ratio5,pm,ratio5err) << setw(4) << delimend << endl; //-------------------------------------- // draw stuff //-------------------------------------- hdata->Scale(1.0/hdata->Integral()); hmc->Scale(1.0/hmc->Integral()); if( log ) hmc->GetYaxis()->SetRangeUser(0.0001,5); else hmc->GetYaxis()->SetRangeUser(0.0,1); hmc->GetXaxis()->SetTitle(xtitle); hmc->SetLineColor(2); hmc->SetMarkerColor(2); hmc->DrawNormalized("hist"); hmc->DrawNormalized("sameE1"); hdata->SetLineColor(4); hdata->SetMarkerColor(4); hdata->Draw("sameE1"); grdata->SetLineColor(6); grmc->SetLineColor(7); //grdata->Draw("sameP"); //grmc->Draw("sameP"); TLegend *leg = new TLegend(0.6,0.7,0.8,0.9); leg->AddEntry(hdata , "data" , "lp"); leg->AddEntry(hmc , "MC" , "lp"); leg->SetBorderSize(0); leg->SetFillColor(0); leg->Draw(); TLatex *t = new TLatex(); t->SetNDC(); if( TString(plottitle).Contains("el") ) t->DrawLatex(0.6,0.6,"electrons"); if( TString(plottitle).Contains("mu") ) t->DrawLatex(0.6,0.6,"muons"); if( TString(plottitle).Contains("0j") ) t->DrawLatex(0.6,0.5,"n_{jets} #geq 0"); if( TString(plottitle).Contains("1j") ) t->DrawLatex(0.6,0.5,"n_{jets} #geq 1"); if( TString(plottitle).Contains("2j") ) t->DrawLatex(0.6,0.5,"n_{jets} #geq 2"); if( TString(plottitle).Contains("3j") ) t->DrawLatex(0.6,0.5,"n_{jets} #geq 3"); if( TString(plottitle).Contains("4j") ) t->DrawLatex(0.6,0.5,"n_{jets} #geq 4"); //-------------------------------------- // draw residual plots //-------------------------------------- if( residual ){ can->cd(); TPad *respad = new TPad("respad","respad",0.0,0.8,1.0,1.0); respad->Draw(); respad->cd(); respad->SetGridy(); TH1F* hratio = (TH1F*) hdata->Clone(Form("hratio_%i",iplot)); hratio->Divide(hmc); hratio->SetMarkerColor(1); hratio->SetLineColor(1); hratio->Draw(); hratio->GetYaxis()->SetRangeUser(0.5,1.5); hratio->GetYaxis()->SetNdivisions(5); hratio->GetYaxis()->SetLabelSize(0.2); hratio->GetXaxis()->SetLabelSize(0.0); TLine line; line.DrawLine(xmin,1.0,xmax,1.0); } //data->Scan("run:lumi:event:probe->pt():probe->eta():tkisonew:met:mt:njets:nbl:nbm",sel+"tkisonew>20"); //data->Scan("run:lumi:event:probe->pt():probe->eta():tkisonew:met:mt:njets:nbl:nbm",sel); if( printplot ) can->Print(Form("plots/%s.pdf",plottitle)); iplot++; // TCanvas *c2 = new TCanvas(); // c2->cd(); // grdata->Draw("AP"); }
void HiggsPlot::PlotExclusion(int iDecay, double tBmH_max, TString Option){ //_varyRD = 0; if(iDecay<0 || iDecay>3) {cout<<"iDecay must be 0, 1, 2 or 3"<<endl; return;} styles style; style.setPadsStyle(-1); style.setDefaultStyle(); int nBins = 1000, nBins2D = 400; double LikelytBmH=-1, Pvalue, Pmin=1; TString hName, epsName = "public_html/Higgs_Exclusion1D_TEMP_BaBar.eps",label; TCanvas can("can","Exclusion 2HDM"); TH1F h1D("h1D","",nBins,0,tBmH_max); h1D.GetXaxis()->SetTitle("tan#beta/m_{H^{+}} (GeV^{-1})"); h1D.GetYaxis()->SetTitle("Exclusion probability (%)"); double tBmH; for(int bin=1; bin<=nBins; bin++){ tBmH = h1D.GetBinCenter(bin); Pvalue = ProbChi2(iDecay, tBmH); if(Pvalue<Pmin) {LikelytBmH = tBmH; Pmin=Pvalue;} h1D.SetBinContent(bin, 100*Pvalue); } h1D.Draw("c"); Pvalue = ProbChi2(iDecay, 0); label = "#splitline{SM excluded at "; label += RoundNumber(sqrt(2)*TMath::ErfInverse(Pvalue),1); label +=" #sigma}{"; label += "Most likely tan#beta/m_{H^{+}} = "; label += RoundNumber(LikelytBmH,2); label += "}"; TLatex latex; latex.SetNDC(kTRUE); latex.SetTextAlign(31); latex.SetTextSize(style.TitleSize); double xLabel = 1-style.PadRightMargin-0.02; if(iDecay==2) { xLabel = style.PadLeftMargin+0.03; latex.SetTextAlign(11); } latex.DrawLatex(xLabel,style.PadBottomMargin+0.1,label); ////////////////// Plot 2D /////////////////////// int nSigmas[] = {2,3,4, 5}, Nsig=4; double dl[5]; for(int ns=0; ns<Nsig+1; ns++) dl[ns] = IntG(0,1,-nSigmas[ns],nSigmas[ns]); TLine line; line.SetLineStyle(2); line.SetLineColor(1); line.SetLineWidth(1); line.DrawLine(0,dl[3]*100,tBmH_max,dl[3]*100); line.DrawLine(0,dl[0]*100,tBmH_max,dl[0]*100); epsName.ReplaceAll("TEMP",DecayName[iDecay]); can.SaveAs(epsName); int colors[] = {kBlue-10, kBlue-9, kBlue-7, kBlue-4, 0}; gStyle->SetPalette(Nsig, colors); TH2F h2D("h2D","",nBins2D,15,1000,nBins2D,0,110); h2D.GetYaxis()->CenterTitle(true); h2D.GetXaxis()->CenterTitle(true); h2D.GetYaxis()->SetTitle("tan#beta"); h2D.GetXaxis()->SetTitle("m_{H^{+}} (GeV)"); // h2D.GetYaxis()->SetTitle("B"); h2D.GetXaxis()->SetTitle("M"); for(int binH=1; binH<=nBins2D; binH++){ for(int binB=1; binB<=nBins2D; binB++){ tBmH = h2D.GetYaxis()->GetBinCenter(binB)/h2D.GetXaxis()->GetBinCenter(binH); h2D.SetCellContent(binH, binB, ProbChi2(iDecay, tBmH)); } } h2D.SetContour(Nsig,dl); h2D.Draw(Option); TH1F *histo[5]; double legW = 0.134, legH = 0.37; double legX = 1-style.PadRightMargin-0.02, legY = style.PadBottomMargin+legH+0.04; TLegend *leg = new TLegend(legX-legW, legY-legH, legX, legY); leg->SetTextSize(0.075); leg->SetFillColor(0); leg->SetTextFont(style.nFont); histo[4] = new TH1F("WhiteH","",10,0,10); histo[4]->SetLineColor(10);histo[4]->SetFillColor(10); leg->AddEntry(histo[4],""); for(int ileg=0; ileg<Nsig; ileg++) { TString labhisto = "histo"; labhisto += ileg+1; histo[ileg] = new TH1F(labhisto,"histo",10,0,10); histo[ileg]->SetLineColor(colors[ileg]);histo[ileg]->SetFillColor(colors[ileg]); labhisto = " "; labhisto += nSigmas[ileg]; labhisto += "#sigma"; leg->AddEntry(histo[ileg],labhisto); } leg->Draw(); latex.SetTextSize(style.TitleSize*1.1); latex.SetTextAlign(13); latex.DrawLatex(legX-legW+0.015, legY-0.02, "Excl. at"); epsName.ReplaceAll("1D","2D"); can.SaveAs(epsName); for(int his=0; his<Nsig; his++) histo[his]->Delete(); }
void HiggsPlot::PlotgSLTauNu(double b, double tBmH_max){ styles style; style.setPadsStyle(-2); style.PadBottomMargin = 2*b/(1+b); style.setDefaultStyle(); int nBins = 1000; double PadLimit[2][2] = {{(1-b)/2.,1}, {0, (1+b)/2.}}; double maxRD[] = {45, 45}, minRD[] = {0., 0.}, TopMargin[] = {0.01, 0}; TString hName, epsName = "public_html/Higgs_TauNu_gSL.eps", label, padName; TString TagDecay[] = {"BF(B#rightarrow#tau#nu) (10^{-5})", "BF(B#rightarrow#tau#nu) (10^{-5})"}; TBox box; box.SetLineColor(4);box.SetFillColor(4); TLine line; line.SetLineStyle(1); line.SetLineColor(4); line.SetLineWidth(3); TCanvas can("can","RD Vs Higgs"); TPad *Pads[2]; TH1F *hBF[4][2]; for(int his=0; his<1; his++) { for(int isDs=0; isDs<4; isDs++){ hName = "hBF"; hName += his; hName += isDs; hBF[isDs][his] = new TH1F(hName,"",nBins,0,tBmH_max); } } Vub[1] = 0.0003; double tBmH, BF[2], gSL; for(int isDs=0; isDs<2; isDs++){ can.cd(0); if(isDs==0) Vub[0] = 0.00313; else Vub[0] = 0.00431; padName = "Pad"; padName += isDs; Pads[isDs] = new TPad(padName,"",0,PadLimit[isDs][0], 1, PadLimit[isDs][1]); Pads[isDs]->SetTopMargin(TopMargin[isDs]); Pads[isDs]->Draw(); Pads[isDs]->cd(); for(int bin=1; bin<=nBins; bin++){ gSL = hBF[isDs][0]->GetBinCenter(bin); tBmH = sqrt(gSL/4.2); Compute(tBmH,BF,0); hBF[isDs][0]->SetBinContent(bin, BF[0]); hBF[isDs][0]->SetBinError(bin, BF[1]); } hBF[isDs][0]->SetFillColor(2); hBF[isDs][0]->SetLineColor(2); hName += isDs; hBF[isDs][1] = static_cast<TH1F*>(hBF[isDs][0]->Clone(hName)); for(int bin=1; bin<=nBins; bin++)hBF[isDs][1]->SetBinError(bin,0); hBF[isDs][1]->SetFillColor(0);hBF[isDs][1]->SetLineColor(1); hBF[isDs][1]->SetLineWidth(2); hBF[isDs][0]->SetMinimum(minRD[isDs]); hBF[isDs][0]->SetMaximum(maxRD[isDs]); hBF[isDs][0]->Draw("e3"); box.SetFillStyle(3002); box.DrawBox(0,Measurement[0][0]-Measurement[0][1], tBmH_max,Measurement[0][0]+Measurement[0][1]); line.DrawLine(0,Measurement[0][0],tBmH_max,Measurement[0][0]); hBF[isDs][0]->Draw("e3 same"); hBF[isDs][1]->Draw("c same"); _isgS = -1; for(int bin=1; bin<=nBins; bin++){ gSL = hBF[isDs+2][0]->GetBinCenter(bin); tBmH = sqrt(gSL/4.2); Compute(tBmH,BF,0); hBF[isDs+2][0]->SetBinContent(bin, BF[0]); hBF[isDs+2][0]->SetBinError(bin, BF[1]); } hBF[isDs+2][0]->SetFillColor(8); hBF[isDs][0]->SetLineColor(8); hName += isDs+2; hBF[isDs+2][1] = static_cast<TH1F*>(hBF[isDs+2][0]->Clone(hName)); for(int bin=1; bin<=nBins; bin++)hBF[isDs+2][1]->SetBinError(bin,0); hBF[isDs+2][1]->SetFillColor(0);hBF[isDs+2][1]->SetLineColor(1); hBF[isDs+2][1]->SetLineWidth(2); hBF[isDs][0]->SetMinimum(minRD[isDs]); hBF[isDs][0]->SetMaximum(maxRD[isDs]); hBF[isDs+2][0]->Draw("e3 same"); hBF[isDs+2][0]->Draw("e3 same"); hBF[isDs+2][1]->Draw("c same"); _isgS = 1; style.setTitles(hBF[isDs][0],"-g (GeV^{-1})",TagDecay[isDs]); } can.SaveAs(epsName); for(int isDs=0; isDs<4; isDs++){ //Pads[isDs]->Delete(); for(int his=0; his<2; his++) hBF[isDs][his]->Delete(); } }
void get_expected_limit() { std::cout << "Inside get_expected_limit " << std::endl; Char_t mass_dir[200]; Char_t mass_dir_exp[200]; Char_t file_title[200]; Char_t file_title_exp[200]; Char_t file_title_2[200]; Char_t file_title_3[200]; int mass_min=500; int mass_inter_0=1000; int mass_inter_1=1500; int mass_inter_2=2500; int mass_inter_3=3000; int mass_inter_4=4000; int mass_max=5000; int binning_0=500; int binning_1=500; int binning_2=1000; int binning_3=500; int binning_4=500; int binning_5=500; ///// Expected Limit ///// int mass_min_exp=500; int mass_inter_0_exp=1500; int mass_inter_1_exp=2500; int mass_inter_2_exp=3000; int mass_max_exp=5000; int binning_0_exp=500; int binning_1_exp=1000; int binning_2_exp=500; int binning_3_exp=500; ////////////////////////// int mass=mass_min; TFile* outfile=new TFile("outfile_RPV_limits.root","recreate"); ofstream median; median.open ("median.txt"); ofstream upper_68; upper_68.open ("upper_68.txt"); ofstream lower_68; lower_68.open ("lower_68.txt"); ofstream upper_95; upper_95.open ("upper_95.txt"); ofstream lower_95; lower_95.open ("lower_95.txt"); ofstream observed_limit; observed_limit.open ("observed.txt"); ofstream observed_limit_mass_kM; observed_limit_mass_kM.open ("observed_limit_mass_kM.txt"); ofstream expected_limit_mass_kM; expected_limit_mass_kM.open ("expected_limit_mass_kM.txt"); ofstream observed_limit_xsec; observed_limit_xsec.open ("observed_limit_xsec.txt"); ofstream expected_limit_xsec; expected_limit_xsec.open ("expected_limit_xsec.txt"); double expected[200]; double observed[200]; double expected_68_up[200]; double expected_68_down[200]; double expected_95_up[200]; double expected_95_down[200]; double xs_expected[200]; double xs_observed[200]; double xs_expected_68_up[200]; double xs_expected_68_down[200]; double xs_expected_95_up[200]; double xs_expected_95_down[200]; double masses[200]; double masses_exp[200]; double xsec_NLO[200]; double xsec_NLO_exp[200]; double xsec_NLO_2[200]; double xsec_NLO_3[200]; std::cout << "Will initialize" << std::endl; for(int k=0; k<200; k++) { expected[k]=0.; observed[k]=0.; expected_68_up[k]=0.; expected_68_down[k]=0.; expected_95_up[k]=0.; expected_95_down[k]=0.; masses[k]=0.; masses_exp[k]=0.; //xsec[k]=0.; xsec_NLO[k]=0.; xsec_NLO_exp[k]=0.; xsec_NLO_2[k]=0.; xsec_NLO_3[k]=0.; xs_expected[k]=0.; xs_observed[k]=0.; xs_expected_68_up[k]=0.; xs_expected_68_down[k]=0.; xs_expected_95_up[k]=0.; xs_expected_95_down[k]=0.; } int counter_masses=0; int counter_masses_exp=0; double kM=0.; double kM_exp=0.; while(mass<=mass_max) { // std::cout << "Will do file_title_2" << std::endl; sprintf(file_title_2,"dim_1_mass%d_QBH",(int)mass); get_environment(file_title_2); xsec_NLO_2[counter_masses]=BGcrosssection*1000;//*BGweight; // std::cout << "Read xs for 0.01 coupling for mass " << mass << std::endl; counter_masses++; if(mass<mass_inter_0){mass+=binning_0;} else { if(mass<mass_inter_1) mass+=binning_1; else { if(mass<mass_inter_2)mass+=binning_2; else { if(mass<mass_inter_3) mass+=binning_3; else { if(mass<mass_inter_4) mass+=binning_4; else mass+=binning_5; } } } } } counter_masses=0; mass=mass_min; while(mass<=mass_max) { // std::cout << "Will do file_title_3" << std::endl; sprintf(file_title_3,"dim_4_mass%d_QBH",(int)mass); get_environment(file_title_3); xsec_NLO_3[counter_masses]=BGcrosssection*1000;//*BGweight; // std::cout << "Read xs for 0.01 coupling for mass " << mass << std::endl; counter_masses++; if(mass<mass_inter_0){mass+=binning_0;} else { if(mass<mass_inter_1) mass+=binning_1; else { if(mass<mass_inter_2)mass+=binning_2; else { if(mass<mass_inter_3) mass+=binning_3; else { if(mass<mass_inter_4) mass+=binning_4; else mass+=binning_5; } } } } } // counter_masses=0; mass=mass_min; // std::cout << "Will do observed ! " << std::endl; ////////// observed ////////// /* while(mass<=mass_max) { masses[counter_masses]=mass; sprintf(file_title,"LQD_01_LLE_01_MSnl_scale_down_%d",(int)mass); get_environment(file_title); xsec_NLO[counter_masses]=BGcrosssection*BGweight; //this is in fb , 0.4 is BR, 0.1 is coupling kM=(BGcrosssection/0.4)*1./pow(0.1,2); sprintf(mass_dir,"/merged/Mass%i.root",mass); TString basedir="/user/mukherjee/out/RPVObservedLimit/"; TString *massdir=new TString(mass_dir); TString filename_observed = basedir+*massdir; double limit; TFile *observed_file=new TFile(filename_observed); delete massdir; TTree *tree_observed = (TTree*)observed_file->Get("limit"); tree_observed->ResetBranchAddresses(); tree_observed->SetBranchAddress("limit",&limit); int nrEntries = tree_observed->GetEntries(); for(int entryNr=0;entryNr<nrEntries;entryNr++){ tree_observed->GetEntry(entryNr); observed_limit << limit << endl; } observed[counter_masses]=limit; // cout << "Mass: " << mass << " observed limit: " << limit ; // xs_expected[counter_masses]=expected[counter_masses]*xsec_NLO[counter_masses]; ///Aeff[counter_masses]; xs_observed[counter_masses]=observed[counter_masses]*xsec_NLO[counter_masses]; ///Aeff[counter_masses]; //xs_expected_68_up[counter_masses]=expected_68_up[counter_masses]*xsec_NLO[counter_masses]; //xs_expected_68_down[counter_masses]=expected_68_down[counter_masses]*xsec_NLO[counter_masses]; //xs_expected_95_up[counter_masses]=expected_95_up[counter_masses]*xsec_NLO[counter_masses]; //xs_expected_95_down[counter_masses]=expected_95_down[counter_masses]*xsec_NLO[counter_masses]; observed_limit_xsec << limit*xsec_NLO[counter_masses] << endl; //expected_limit_xsec << xs_expected[counter_masses] << endl; observed_limit_mass_kM << mass << " " << kM << " " << limit*xsec_NLO[counter_masses] << endl; //expected_limit_mass_kM << mass << " " << kM << " " << xs_expected[counter_masses] << endl; cout << mass << " & " << xs_observed[counter_masses] << " \\\\ " << endl; // std::cout << "Mass " << mass << " " << xs_expected[counter_masses] << "=" << expected[counter_masses] << "*" <<xsec_NLO[counter_masses] << std::endl; counter_masses++; if(mass<mass_inter_0){mass+=binning_0;} else { if(mass<mass_inter_1) mass+=binning_1; else { if(mass<mass_inter_2)mass+=binning_2; else { if(mass<mass_inter_3) mass+=binning_3; else { if(mass<mass_inter_4) mass+=binning_4; else mass+=binning_5; } } } } } */ observed_limit.close(); observed_limit_xsec.close(); observed_limit_mass_kM.close(); // counter_masses=0; mass=mass_min_exp; std::cout << "Will do expected ! " << std::endl ; ////////// expected ////////// while(mass<=mass_max_exp) { masses_exp[counter_masses_exp]=mass; sprintf(file_title_exp,"dim_6_mass%d_QBH",(int)mass); get_environment(file_title_exp); //xsec[counter_masses]=BGcrosssection*1000.*BGweight; xsec_NLO_exp[counter_masses_exp]=BGcrosssection*1000; //*BGweight; //std::cout<< "Read xs for 0.1 coupling for mass " << mass << std::endl; //this is in fb , 0.4 is BR, 0.1 is coupling kM_exp=(BGcrosssection/0.4)*1./pow(0.1,2); sprintf(mass_dir_exp,"/merged/Mass%i.root",mass); TString basedir_exp="/user/mukherjee/out/Nov_6_EMU2016_v2_QBH_S4/"; TString *massdir_exp=new TString(mass_dir_exp); TString filename=basedir_exp+*massdir_exp; // TString filename_observed = basedir+in_dir+*massdir+"/condor/observed.root"; double limit; TFile *expected_file=new TFile(filename); // TFile *observed_file=new TFile(filename_observed); TTree *tree = (TTree*)expected_file->Get("limit"); tree->ResetBranchAddresses(); tree->SetBranchAddress("limit",&limit); int nrEntries = tree->GetEntries(); double limits[10000]; for(int entryNr=0;entryNr<nrEntries;entryNr++){ tree->GetEntry(entryNr); limits[entryNr]=limit; } tree->ResetBranchAddresses(); std::sort(limits, limits + nrEntries); median << limits[Nint(nrEntries*0.5)] << "\n"; upper_68 << limits[Nint(nrEntries*0.841344746)] << "\n"; lower_68 << limits[Nint(nrEntries*0.158655254)] << "\n"; upper_95 << limits[Nint(nrEntries*0.977249868)] << "\n"; lower_95 << limits[Nint(nrEntries*0.022750132)] << "\n"; expected[counter_masses_exp]=limits[Nint(nrEntries*0.5)]; expected_68_up[counter_masses_exp]=limits[Nint(nrEntries*0.841344746)]; expected_68_down[counter_masses_exp]=limits[Nint(nrEntries*0.158655254)]; expected_95_up[counter_masses_exp]=limits[Nint(nrEntries*0.977249868)]; expected_95_down[counter_masses_exp]=limits[Nint(nrEntries*0.022750132)]; delete tree; delete expected_file; delete massdir_exp; //TTree *tree_observed = (TTree*)observed_file->Get("limit"); //tree_observed->ResetBranchAddresses(); //tree_observed->SetBranchAddress("limit",&limit); //nrEntries = tree_observed->GetEntries(); //for(int entryNr=0;entryNr<nrEntries;entryNr++){ // tree_observed->GetEntry(entryNr); // observed_limit << limit << endl; // } //observed[counter_masses]=limit; // cout << "Mass: " << mass << " observed limit: " << limit ; xs_expected[counter_masses_exp]=expected[counter_masses_exp]*xsec_NLO_2[counter_masses_exp]; ///Aeff[counter_masses]; //xs_observed[counter_masses]=observed[counter_masses]*xsec_NLO[counter_masses]; ///Aeff[counter_masses]; xs_expected_68_up[counter_masses_exp]=expected_68_up[counter_masses_exp]*xsec_NLO_2[counter_masses_exp]; xs_expected_68_down[counter_masses_exp]=expected_68_down[counter_masses_exp]*xsec_NLO_2[counter_masses_exp]; xs_expected_95_up[counter_masses_exp]=expected_95_up[counter_masses_exp]*xsec_NLO_2[counter_masses_exp]; xs_expected_95_down[counter_masses_exp]=expected_95_down[counter_masses_exp]*xsec_NLO_2[counter_masses_exp]; //observed_limit_xsec << limit*xsec_NLO[counter_masses] << endl; expected_limit_xsec << xs_expected[counter_masses_exp] << endl; //observed_limit_mass_kM << mass << " " << kM << " " << limit*xsec_NLO[counter_masses] << endl; expected_limit_mass_kM << mass << " " << kM_exp << " " << xs_expected[counter_masses_exp] << endl; cout << mass << " & " << xs_expected[counter_masses_exp] << " \\\\ " << endl; // std::cout << "Mass " << mass << " " << xs_expected[counter_masses] << "=" << expected[counter_masses] << "*" <<xsec_NLO[counter_masses] << std::endl; counter_masses_exp++; if(mass<mass_inter_0_exp){mass+=binning_0_exp;} else { if(mass<mass_inter_1_exp) mass+=binning_1_exp; else { if(mass<mass_inter_2_exp)mass+=binning_2_exp; else mass+=binning_3_exp; //{ //if(mass<mass_inter_3)mass+=binning_3; //else mass+=binning_4; //} //} } } } median.close(); upper_68.close(); lower_68.close(); upper_95.close(); lower_95.close(); // observed_limit.close(); // observed_limit_xsec.close(); expected_limit_xsec.close(); expected_limit_mass_kM.close(); // observed_limit_mass_kM.close(); //limits have been written, now produce the corresponding plots gStyle->SetPadLeftMargin(0.15); gStyle->SetPadRightMargin(0.05); gStyle->SetPadBottomMargin(0.15); gStyle->SetPadTopMargin(0.05); gStyle->SetTitleXSize(0.05); gStyle->SetTitleXOffset(1.05); gStyle->SetTitleYSize(0.05); gStyle->SetTitleYOffset(1.05); TCanvas* ratio = new TCanvas("ratio","ratio",800,800); ratio->cd(); ratio->SetLogy(); /* TGraph *graph_observed = new TGraph(counter_masses,masses,observed); graph_observed->GetXaxis()->SetRangeUser(mass_min,mass_max); graph_observed->GetYaxis()->SetRangeUser(0.1,10); //gPad->SetLogy(); graph_observed->SetTitle(""); graph_observed->SetMarkerStyle(0); graph_observed->SetMarkerSize(1.8); graph_observed->SetMarkerColor(1); graph_observed->SetLineColor(1); graph_observed->SetLineWidth(3); graph_observed->GetXaxis()->SetTitle("M_{#tilde{#nu_{#tau}}} (GeV)"); graph_observed->GetYaxis()->SetTitle("#frac{#sigma_{95%CL}}{#sigma_{sig}#timesBR}"); */ TGraph *graph_expected = new TGraph(counter_masses_exp,masses_exp,expected); graph_expected->GetXaxis()->SetRangeUser(mass_min_exp,mass_max_exp); graph_expected->GetYaxis()->SetRangeUser(0.1,10); //gPad->SetLogy(); graph_expected->SetTitle(""); graph_expected->SetMarkerStyle(0); graph_expected->SetMarkerColor(kBlack); graph_expected->SetLineColor(kBlack); graph_expected->SetLineWidth(2); graph_expected->SetLineStyle(2); //graph_expected->GetXaxis()->SetTitle("M_{#tilde{#nu_{#tau}}} [TeV]"); //graph_expetced->GetYaxis()->SetTitle("#frac{#sigma_{95%CL}}{#sigma_{sig}}"); // graph_observed->Draw("Apc"); graph_expected->GetXaxis()->SetTitleFont(42); graph_expected->GetYaxis()->SetTitleFont(42); graph_expected->GetXaxis()->SetLabelFont(42); graph_expected->GetYaxis()->SetLabelFont(42); // graph_expected->GetXaxis()->SetTitle("M_{#tilde{#nu_{#tau}}} (GeV)"); graph_expected->GetXaxis()->SetTitle("M_{QBH} (GeV)"); graph_expected->GetYaxis()->SetTitle("#frac{#sigma_{95% CL}}{#sigma_{signal}}"); graph_expected->GetXaxis()->SetRangeUser(mass_min,mass_max); graph_expected->GetYaxis()->SetRangeUser(10,80.); graph_expected->Draw("Apl"); TGraph *graph_expected_68_up = new TGraph(counter_masses_exp,masses_exp,expected_68_up); //graph_expected_68_up->Draw("pl,same"); TGraph *graph_expected_68_down = new TGraph(counter_masses_exp,masses_exp,expected_68_down); //graph_expected_68_down->Draw("pl,same"); TGraph *grshade_95 = new TGraph(2*counter_masses_exp); for (int i=0;i<counter_masses_exp;i++) { grshade_95->SetPoint(i,masses_exp[i],expected_95_up[i]); grshade_95->SetPoint(counter_masses_exp+i,masses_exp[counter_masses_exp-i-1],expected_95_down[counter_masses_exp-i-1]); } grshade_95->SetFillStyle(1001); grshade_95->SetFillColor(kYellow); grshade_95->Draw("f"); TGraph *grshade_68 = new TGraph(2*counter_masses_exp); for (int i=0;i<counter_masses_exp;i++) { grshade_68->SetPoint(i,masses_exp[i],expected_68_up[i]); grshade_68->SetPoint(counter_masses_exp+i,masses_exp[counter_masses_exp-i-1],expected_68_down[counter_masses_exp-i-1]); } grshade_68->SetFillStyle(1001); grshade_68->SetFillColor(kGreen); grshade_68->Draw("f"); graph_expected->Draw("pl,same"); //graph_observed->Draw("pc,same"); TLine *borderline = new TLine(0.,1.,2000.,1.); borderline->SetLineWidth(2); borderline->SetLineColor(kBlue); borderline->DrawLine(200.,1.,2000.,1.); TLegend *leg_example = new TLegend(0.5,0.75,0.5,0.9); leg_example->SetFillColor(0); leg_example->SetTextFont(42); //leg_example->AddEntry(graph_observed, "observed limit","pl"); // leg_example->AddEntry(graph_observed, "95% CL limit","pl"); leg_example->AddEntry(graph_expected, "median expected limit","pl"); leg_example->AddEntry(grshade_68, "68% expected","f"); leg_example->AddEntry(grshade_95, "95% expected","f"); //leg_example->AddEntry(borderline, "","l"); leg_example->Draw("same"); //cross section limit TCanvas* total = new TCanvas("total","total",800,800); total->cd(); total->SetLogy(); /* TGraph *graph_observed_total = new TGraph(counter_masses,masses,xs_observed); graph_observed->GetXaxis()->SetRangeUser(mass_min,mass_max); graph_observed->GetYaxis()->SetRangeUser(1,1000.); //gPad->SetLogy(); graph_observed_total->SetTitle(""); graph_observed_total->SetMarkerStyle(0); graph_observed_total->SetMarkerSize(1.1); graph_observed_total->SetMarkerColor(1); graph_observed_total->SetLineColor(1); graph_observed_total->SetLineWidth(3); graph_observed->GetXaxis()->SetTitle("M_{#tilde{#nu_{#tau}}} (GeV)"); graph_observed->GetYaxis()->SetTitle("#frac{#sigma_{95%CL}}{#sigma_{sig}#timesBR}"); */ TGraph *graph_expected_total = new TGraph(counter_masses_exp,masses_exp,xs_expected); graph_expected_total->GetXaxis()->SetRangeUser(mass_min_exp,mass_max_exp); graph_expected_total->GetYaxis()->SetRangeUser(0.1,1000000.); //gPad->SetLogy(); graph_expected_total->SetTitle(""); graph_expected_total->SetMarkerStyle(0); graph_expected_total->SetMarkerColor(kBlack); graph_expected_total->SetLineColor(kBlack); graph_expected_total->SetLineWidth(2); graph_expected_total->SetLineStyle(2); //graph_expected->GetXaxis()->SetTitle("M_{#tilde{#nu_{#tau}}} [TeV]"); //graph_expetced->GetYaxis()->SetTitle("#frac{#sigma_{95%CL}}{#sigma_{sig}}"); // graph_observed->Draw("Apc"); graph_expected_total->GetXaxis()->SetTitleFont(42); graph_expected_total->GetYaxis()->SetTitleFont(42); graph_expected_total->GetXaxis()->SetLabelFont(42); graph_expected_total->GetYaxis()->SetLabelFont(42); // graph_expected_total->GetXaxis()->SetTitle("M_{#tilde{#nu}_{#tau}} (GeV)"); // graph_expected_total->GetYaxis()->SetTitle("#sigma^{prod}_{#tilde{#nu_{#tau}}} #times BR ( #tilde{#nu_{#tau}} #rightarrow e#mu ) (fb)"); graph_expected_total->GetXaxis()->SetTitle("M_{QBH} (GeV)"); graph_expected_total->GetYaxis()->SetTitle("#sigma^{prod}_{QBH} #times BR (QBH #rightarrow e#mu ) (fb)"); graph_expected_total->GetXaxis()->SetRangeUser(mass_min_exp,mass_max_exp); graph_expected_total->GetYaxis()->SetRangeUser(0.1,1000000.); graph_expected_total->Draw("Apl"); TGraph *graph_expected_68_up_total = new TGraph(counter_masses_exp,masses_exp,xs_expected_68_up); //graph_expected_68_up->Draw("pl,same"); TGraph *graph_expected_68_down_total = new TGraph(counter_masses_exp,masses,xs_expected_68_down); //graph_expected_68_down->Draw("pl,same"); TGraph *grshade_95_total = new TGraph(2*counter_masses_exp); for (int i=0;i<counter_masses_exp;i++) { grshade_95_total->SetPoint(i,masses_exp[i],xs_expected_95_up[i]); grshade_95_total->SetPoint(counter_masses_exp+i,masses_exp[counter_masses_exp-i-1],xs_expected_95_down[counter_masses_exp-i-1]); } grshade_95_total->SetFillStyle(1001); grshade_95_total->SetFillColor(kYellow); grshade_95_total->Draw("f"); TGraph *grshade_68_total = new TGraph(2*counter_masses_exp); for (int i=0;i<counter_masses_exp;i++) { grshade_68_total->SetPoint(i,masses_exp[i],xs_expected_68_up[i]); grshade_68_total->SetPoint(counter_masses_exp+i,masses_exp[counter_masses_exp-i-1],xs_expected_68_down[counter_masses_exp-i-1]); } grshade_68_total->SetFillStyle(1001); grshade_68_total->SetFillColor(kGreen); grshade_68_total->Draw("f"); graph_expected_total->Draw("pl,same"); // graph_observed_total->Draw("pc,same"); std::cout<< "Prepare to draw graph 1" << std::endl; TGraph *graph_xsec= new TGraph(counter_masses,masses_exp,xsec_NLO_exp); graph_xsec->SetTitle(""); graph_xsec->SetMarkerStyle(0); graph_xsec->SetMarkerSize(1.4); graph_xsec->SetMarkerColor(kBlue); graph_xsec->SetLineColor(kBlue); graph_xsec->SetLineWidth(2); // graph_xsec->GetXaxis()->SetTitle("M_{#tilde{#nu_{#tau}}} [TeV]"); graph_xsec->GetXaxis()->SetTitle("M_{QBH} [TeV]"); graph_xsec->GetYaxis()->SetTitle("95%CL #sigma_{sig}xBR / fb"); graph_xsec->Draw("pl,same"); //g_xsec_scale_up->Draw("l,same"); //g_xsec_scale_down->Draw("l,same"); //fit_xsec_Zprime->Draw("pl,same"); TSpline3 *s3 = new TSpline3("s3",graph_xsec->GetX(),graph_xsec->GetY(),graph_xsec->GetN()); s3->SetLineColor(kRed); //s3->Draw("l same"); // std::cout<< "Prepare to draw graph 2" << std::endl; TGraph *graph_xsec_2= new TGraph(counter_masses_exp,masses_exp,xsec_NLO_2); graph_xsec_2->SetTitle(""); graph_xsec_2->SetMarkerStyle(0); graph_xsec_2->SetMarkerSize(1.4); graph_xsec_2->SetMarkerColor(kRed+2); graph_xsec_2->SetLineColor(kRed+2); graph_xsec_2->SetLineWidth(2); // graph_xsec_2->GetXaxis()->SetTitle("M_{#tilde{#nu_{#tau}}} [TeV]"); graph_xsec_2->GetYaxis()->SetTitle("95%CL #sigma_{sig}xBR / fb"); graph_xsec_2->Draw("pl,same"); //g_xsec_scale_up->Draw("l,same"); //g_xsec_scale_down->Draw("l,same"); //fit_xsec_Zprime->Draw("pl,same"); TSpline3 *s4 = new TSpline3("s4",graph_xsec_2->GetX(),graph_xsec_2->GetY(),graph_xsec_2->GetN()); s4->SetLineColor(kRed+2); //s3->Draw("l same"); TGraph *graph_xsec_3= new TGraph(counter_masses_exp,masses_exp,xsec_NLO_3); graph_xsec_3->SetTitle(""); graph_xsec_3->SetMarkerStyle(0); graph_xsec_3->SetMarkerSize(1.4); graph_xsec_3->SetMarkerColor(kPink+1); graph_xsec_3->SetLineColor(kPink+1); graph_xsec_3->SetLineWidth(2); // graph_xsec_3->GetXaxis()->SetTitle("M_{#tilde{#nu_{#tau}}} [TeV]"); graph_xsec_3->GetYaxis()->SetTitle("95%CL #sigma_{sig}xBR / fb"); graph_xsec_3->Draw("pl,same"); //g_xsec_scale_up->Draw("l,same"); //g_xsec_scale_down->Draw("l,same"); //fit_xsec_Zprime->Draw("pl,same"); TSpline3 *s5 = new TSpline3("s5",graph_xsec_3->GetX(),graph_xsec_3->GetY(),graph_xsec_3->GetN()); s5->SetLineColor(kRed+2); //s3->Draw("l same"); /* TF1* fit_xsec=new TF1("fit_xsec","[0]/([1]+[2]*x+[3]*pow(x,2))",400,2000); fit_xsec->SetParameter(0,242580); fit_xsec->SetParameter(1,87191.4); fit_xsec->SetParameter(2,-440.933); fit_xsec->SetParameter(3,0.609692); graph_xsec->Fit(fit_xsec,"","",400,2000); */ std::cout<< "Prepare to draw legend" << std::endl; TLegend *leg_total = new TLegend(0.65,0.55,0.95,0.95); leg_total->SetFillColor(0); leg_total->SetTextFont(42); leg_total->SetTextSize(0.032); // leg_total->AddEntry(graph_observed, "observed limit","pl"); // leg_total->AddEntry(graph_observed, "95% CL limit","pl"); leg_total->AddEntry(graph_expected, "median expected limit","pl"); leg_total->AddEntry(grshade_68, "68% expected","f"); leg_total->AddEntry(grshade_95, "95% expected","f"); //leg_total->AddEntry(graph_xsec, "#splitline{RPV signal (NLO)}{#lambda^{I}_{311}=#lambda_{132}=0.01}","l"); leg_total->AddEntry(graph_xsec, "QBH signal",""); // leg_total->AddEntry(graph_xsec_2, "#lambda^{I}_{311}=#lambda_{132}=#lambda_{231}=0.01","l"); // leg_total->AddEntry(graph_xsec, "#lambda^{I}_{311}=#lambda_{132}=#lambda_{231}=0.1","l"); // leg_total->AddEntry(graph_xsec_3, "#lambda^{I}_{311}=#lambda_{132}=#lambda_{231}=0.2","l"); leg_total->AddEntry(graph_xsec_2, "Dim 1","l"); leg_total->AddEntry(graph_xsec_3, "Dim 4","l"); leg_total->AddEntry(graph_xsec, "Dim 6","l"); //leg_total->AddEntry(fit_xsec_Zprime,"Z'/a' (LO)","l"); //leg_total->AddEntry(borderline," ",""); leg_total->Draw("same"); //TLatex* CMS_text = new TLatex(0.20,0.88,"CMS"); TLatex* CMS_text = new TLatex(0.24,0.88,"CMS"); CMS_text->SetNDC(); CMS_text->SetTextSize(0.05); CMS_text->SetTextAngle(0); CMS_text->Draw("same"); TLatex* text_1 = new TLatex(0.46,0.68,"EE"); text_1->SetNDC(); text_1->SetTextSize(0.03); text_1->SetTextAngle(0); text_1->Draw("same"); TLatex* CMS_text_2 = new TLatex(0.24,0.83,"Preliminary"); //TLatex* CMS_text_2 = new TLatex(0.20,0.83," "); CMS_text_2->SetNDC(); CMS_text_2->SetTextFont(42); CMS_text_2->SetTextSize(0.05); CMS_text_2->SetTextAngle(0); CMS_text_2->Draw("same"); TLatex* lumiText = new TLatex(0.95,0.975,"6.32 fb^{-1} (13 TeV)"); lumiText->SetNDC(); lumiText->SetTextFont(42); lumiText->SetTextSize(0.04); lumiText->SetTextAlign(32); lumiText->Draw("same"); total->Print("limit.pdf"); }
void drawHisto(TCanvas* C,TString Group1,TFile* F1,TString Group2,TFile* F2,TString channel,TString category,TString sample,bool PrintDiff){ C->Clear(); TH1F* H1 = (TH1F*) F1->Get(channel+"_"+category+"/"+sample); TH1F* H2 = (TH1F*) F2->Get(channel+"_"+category+"/"+sample); if(!H1||!H2||H1->Integral()!=H1->Integral()||H2->Integral()!=H2->Integral()){ if(H1&&H1->Integral()==H1->Integral())H1->Draw("histpe"); if(H2&&H2->Integral()==H2->Integral())H2->Draw("histpe"); TText cat; cat.DrawTextNDC(.2,.5,channel+"_"+category+"/"+sample); if(!H1||H1->Integral()!=H1->Integral()) cat.DrawTextNDC(.2,.4,Group1+" is missing or 0"); if(!H2||H2->Integral()!=H2->Integral()) cat.DrawTextNDC(.2,.4,Group2+" is missing or 0"); if(PrintDiff)printf("| %.1f ",100); C->Print(TString(C->GetName())+".pdf"); return; } // cout<<channel<<" "<<category<<" "<<sample<<endl; // cout<<H1->Integral()<<" "<<H2->Integral()<<endl; // TText cat; // cat.DrawTextNDC(.2,.5,channel+"_"+category+"/"+sample); // C->Print(TString(C->GetName())+".pdf"); // return; TPad pad1("pad1","",0,0.2,1,1); TPad pad2("pad2","",0,0,1,0.2); //////////////////////////////////////////// pad1.cd(); //H1->SetTitle(""); H1->SetTitle(channel+" "+category+" "+sample); H1->GetXaxis()->SetTitle("mass"); H1->GetYaxis()->SetTitle(""); H1->GetYaxis()->SetRangeUser(0,(H1->GetMaximum()>H2->GetMaximum() ? H1->GetMaximum() : H2->GetMaximum())*1.2); H1->SetLineWidth(3); H1->SetLineColor(1); H1->SetFillColor(0); H1->Draw("histpe"); H2->SetMarkerSize(0.01); H2->SetLineWidth(3); H2->SetLineColor(2); H2->SetFillColor(0); H2->Draw("histesame"); TText TXmine; TXmine.SetTextColor(1); TXmine.SetTextSize(.04); TText TXother; TXother.SetTextColor(2); TXother.SetTextSize(.04); TText TXdiff; TXdiff.SetTextColor(4); TXdiff.SetTextSize(.03); char yield1[100]; sprintf(yield1,"%.2f",H1->Integral(1,H1->GetNbinsX())); char yield2[100]; sprintf(yield2,"%.2f",H2->Integral(1,H2->GetNbinsX())); TXmine.DrawTextNDC(.55,.845,Group1+" : "+yield1); TXother.DrawTextNDC(.55,.81,Group2+" : "+yield2); char txt[100]; float diff=100*2*fabs(H1->Integral(1,H1->GetNbinsX())-H2->Integral(1,H2->GetNbinsX()))/(H1->Integral(1,H1->GetNbinsX())+H2->Integral(1,H2->GetNbinsX())); sprintf(txt,"Difference = %.1f",diff); TXdiff.DrawTextNDC(.25,.85,TString(txt)+"%"); //////////////////////////////////////////// pad2.cd(); ///Draw the ratio of the historgrams TH1F*HDiff=(TH1F*)H2->Clone("HDiff"); HDiff->Divide(H1); HDiff->GetYaxis()->SetRangeUser(0.8,1.2); HDiff->GetYaxis()->SetNdivisions(3); HDiff->GetYaxis()->SetLabelSize(0.1); HDiff->GetYaxis()->SetTitleSize(0.1); HDiff->GetYaxis()->SetTitleOffset(0.5); //HDiff->GetYaxis()->SetTitle(myGroup + " / " + group); HDiff->GetYaxis()->SetTitle("Ratio"); HDiff->GetXaxis()->SetNdivisions(-1); HDiff->GetXaxis()->SetTitle(""); HDiff->GetXaxis()->SetLabelSize(0.0001); HDiff->SetMarkerSize(0.1); HDiff->Draw("histpe"); TLine line; line.DrawLine(HDiff->GetXaxis()->GetXmin(),1,HDiff->GetXaxis()->GetXmax(),1); C->Clear(); pad1.Draw(); pad2.Draw(); //cout<<setiosflags(ios::fixed)<<precision(2); //cout<<"| "<<diff<<" "<<endl; //if(PrintDiff)printf("| %.1f ",diff); C->Print(TString(C->GetName())+".pdf"); //delete H1; //delete H2; delete HDiff; }
void sobWeightedPlot(TString filename,const char* dataset , const char* channel,const char* cat) { TFile F((TString("Plot_")+filename+".root").Data(),"READ"); gROOT->cd(); TH1F* data=(TH1F*)F.Get("data_obs"); TH1F* Ztt=(TH1F*)F.Get("Ztt"); TH1F* ggH=(TH1F*)F.Get("ggH"); TH1F* sig=(TH1F*)F.Get("signal"); TH1F* tt=(TH1F*)F.Get("ttbar"); TH1F* ewk=(TH1F*)F.Get("EWK"); TH1F* fakes=(TH1F*)F.Get("Fakes"); if(!sig){cout<<"No input histograms in file: "<<filename.Data()<<endl; return;} float xmininset=60; float xmaxinset=180; //float xmininset=0; float xmaxinset=340;//full range ////Format the histograms Ztt->GetYaxis()->SetRangeUser(0.,1.3*findMaxY(data,0)); Ztt->GetXaxis()->SetTitle("#bf{m_{#tau#tau} [GeV]}"); Ztt->GetYaxis()->SetTitle("#bf{S/B Weighted dN/dm_{#tau#tau} [1/GeV]}"); Ztt->SetTitleOffset(1.300, "Y"); Ztt->SetTitleOffset(1.000, "X"); Ztt->SetNdivisions(505); for(Int_t b=0;b<=sig->GetNbinsX()+1;b++){ //remove red line on top of y axis in plot if(sig->GetBinCenter(b)<xmininset||xmaxinset<sig->GetBinCenter(b)){ sig->SetBinContent(b,0); sig->SetBinError(b,0); } } sig->SetName("sig"); sig->SetFillStyle(3353);//1001=solid , 3004,3005=diagonal sig->SetFillColor(2); sig->SetLineColor(2); sig->SetLineStyle(1); sig->SetLineWidth(0.); ggH->SetBinContent(0,0);//remove red line on top of y axis in plot ggH->SetBinContent(ggH->GetNbinsX()+1,0); ggH->SetBinError(0,0); ggH->SetBinError(ggH->GetNbinsX()+1,0); ggH->SetName("ggH"); ggH->SetFillStyle(3353);//1001=solid , 3004,3005=diagonal ggH->SetFillColor(2); ggH->SetLineColor(2); ggH->SetLineStyle(1); ggH->SetLineWidth(0.); TH1F* errorBand = (TH1F*)Ztt->Clone("errorBand"); errorBand->SetMarkerSize(0); errorBand->SetFillColor(1); errorBand->SetFillStyle(3013); errorBand->SetLineWidth(1); TLegend legend; TString higgslabel="H(125 GeV)#rightarrow#tau#tau"; legend.SetFillStyle(0); legend.SetFillColor(0); legend.SetBorderSize(0); legend.AddEntry(ggH,higgslabel,"F"); legend.AddEntry(data,"observed","LP"); legend.AddEntry(Ztt,"Z#rightarrow#tau#tau","F"); legend.AddEntry(tt,"t#bar{t}","F"); legend.AddEntry(ewk,"electroweak","F"); legend.AddEntry(fakes,"QCD","F"); legend.SetX1NDC(0.63); legend.SetX2NDC(1.05); legend.SetY1NDC(0.27); legend.SetY2NDC(0.48); legend.SetTextSize(.028); legend.SetTextAlign( 12 ); //TH1F* dataDiff=diffPlot(data,Ztt,2); TH1F* dataDiff=diffPlot(data,Ztt,1); TH1F* errBand=getErrorBand(Ztt); errBand->SetFillStyle(3013);//1001=solid , 3004,3005=diagonal, 3013=hatched official for H->tau tau errBand->SetFillColor(1); errBand->SetLineStyle(1); errBand->SetLineColor(1); errBand->SetLineWidth(1); TH1F errBandFrame("errBandFrame","",(xmaxinset-xmininset)/dataDiff->GetBinWidth(1),xmininset,xmaxinset); errBandFrame.GetYaxis()->SetTitle(""); errBandFrame.GetYaxis()->SetRangeUser(-1.1*findMinY(dataDiff,0,xmininset,xmaxinset),2.0*findMaxY(dataDiff,0,xmininset,xmaxinset)); errBandFrame.GetYaxis()->SetNdivisions(5); errBandFrame.GetYaxis()->SetLabelSize(0.06); errBandFrame.GetXaxis()->SetTitle("#bf{m_{#tau#tau} [GeV]} "); errBandFrame.GetXaxis()->SetTitleColor(kBlack); errBandFrame.GetXaxis()->SetTitleSize(0.07); errBandFrame.GetXaxis()->SetTitleOffset(0.95); errBandFrame.GetXaxis()->SetLabelSize(0.06); errBandFrame.SetNdivisions(505); TLegend legendDiff; legendDiff.SetFillStyle(0); legendDiff.SetFillColor(0); legendDiff.SetBorderSize(0); legendDiff.AddEntry(sig,higgslabel,"F"); legendDiff.AddEntry(dataDiff,"Data - Background","LP"); legendDiff.AddEntry(errBand,"Bkg. Uncertainty","F"); legendDiff.SetX1NDC(0.45); legendDiff.SetX2NDC(0.88); legendDiff.SetY1NDC(0.67); legendDiff.SetY2NDC(0.88); legendDiff.SetTextSize(.045); legendDiff.SetTextAlign(12); TCanvas C(filename,"",600,600); TPad padBack("padBack","padBack",0.57,0.58,0.975,0.956);//TPad must be created after TCanvas otherwise ROOT crashes padBack.SetFillColor(0); TPad pad("diff","diff",0.45,0.5,0.9765,0.957);//TPad must be created after TCanvas otherwise ROOT crashes pad.cd(); pad.SetFillColor(0); pad.SetFillStyle(0); errBandFrame.Draw(); errBand->Draw("e2lsame"); sig->Draw("histsame"); TLine line; line.DrawLine(xmininset,0,xmaxinset,0); dataDiff->Draw("pesame"); legendDiff.Draw(); pad.RedrawAxis(); C.cd(); Ztt->Draw("hist"); ggH->Draw("histsame"); Ztt->Draw("histsame"); errorBand->Draw("e2same"); tt->Draw("histsame"); ewk->Draw("histsame"); fakes->Draw("histsame"); data->Draw("pesame"); legend.Draw(); C.RedrawAxis(); padBack.Draw();//clear the background axes pad.Draw(); CMSPrelim(dataset,channel,cat); C.Print(TString("Plot_")+filename+".eps"); C.Print(TString("Plot_")+filename+".png"); C.Print(TString("Plot_")+filename+".pdf"); delete errorBand; delete dataDiff; delete errBand; }
void drawplot(int ipt=0, int ic=0){ sprintf(name,"cpt%d_c%d",ipt,ic); c = new TCanvas(name,name,730,420); Divide(c,2,1,0,0); for(int qs=0;qs<2;qs++){ c->cd(qs+1); if(qs!=0) continue; double mmax = hCorr_1D[ic][ipt][1]->GetMaximum(); double mmin = hCorr_1D[ic][ipt][1]->GetMinimum(); double del = mmax-mmin; cout<<mmax<<" "<<mmin<<endl; hCorr_1D[ic][ipt][0]->SetMaximum(mmax+0.65*del); hCorr_1D[ic][ipt][0]->SetMinimum(mmin-0.12*del); cout<<hCorr_1D[ic][ipt][0]->GetMaximum()<<" "<<hCorr_1D[ic][ipt][0]->GetMinimum()<<endl; setstyle(hCorr_1D[ic][ipt][0]); hCorr_1D[ic][ipt][0]->SetXTitle("#Delta#phi [rad]"); hCorr_1D[ic][ipt][0]->SetYTitle("C(#Delta#phi)"); hCorr_1D[ic][ipt][0]->DrawCopy(); // txt.DrawCopyLatex(0.6,0.2,"ATLAS internal"); //hCorr_1D[ic][ipt][0]->GetYaxis()->SetRangeUser(mmin-0.3*del, mmax+0.45*del); if(qs==1){ hCorr_1D[ic][ipt][0]->SetMaximum(hCorr_1D[ic][ipt][0]->GetMaximum()); hCorr_1D[ic][ipt][0]->SetMinimum(hCorr_1D[ic][ipt][0]->GetMinimum()); } line.DrawLine(-0.5*PI,1,1.5*PI,1); hCorr_1D[ic][ipt][1]->DrawCopy("same"); hCorr_1D[ic][ipt][2]->DrawCopy("same"); hCorr_1D[ic][ipt][3]->DrawCopy("same"); //hcor[ic][ipt][3]->Draw("same"); //hcor[ic][ipt][4]->Draw("same"); float xs=-0.4,ys=-0.; lab1.DrawLatex(xs+0.63,ys+0.92,"ATLAS"); lab2.DrawLatex(xs+0.79,ys+0.92,"Internal"); lab3.DrawLatex(xs+0.63, ys+0.85,"#sqrt{s_{NN}}=5.02 TeV"); // lab3.DrawLatex(xs+0.65,ys+0.78,"L_{int} = 7 #mub^{-1}"); // if(qs==0) text1.DrawLatex(0.21,0.93,"(a)"); if(qs==1) text1.DrawLatex(0.21,0.93,"(b)"); int icbin = cbins[ic]; sprintf(name,"Centrality %d-%d%%",icbin*5,icbin*5+5); lab3.DrawLatex(0.6,0.92,name); l = new TLegend(0.53,0.70,1,0.91); l->SetTextFont(43); l->SetTextSize(15); l->SetFillStyle(0); l->SetBorderSize(0); if(qs==0){ l->AddEntry(hCorr_1D[ic][ipt][1],"v_{2} trigger ","pl"); l->AddEntry(hCorr_1D[ic][ipt][2],"v_{3} trigger","pl"); l->AddEntry(hCorr_1D[ic][ipt][3],"large v_{2} & v_{3} trigger","pl"); }else{ l->AddEntry(hCorr_1D[ic][ipt][0],"largest 10% q_{3}","pl"); l->AddEntry(hCorr_1D[ic][ipt][1],"smallest 10% q_{3}","pl"); } l->AddEntry(hCorr_1D[ic][ipt][0],"MiniBias","pl"); l->Draw(); lab2.DrawLatex(0.65,0.2,ptnames[ipt]); lab2.DrawLatex(0.31,0.2,"2<|#Delta#eta|<4.8"); }//qs for(int qs=0;qs<2;qs++){ c->cd(qs+1); if(qs!=1) continue; ic = ic+1; double mmax = hCorr_1D[ic][ipt][1]->GetMaximum(); double mmin = hCorr_1D[ic][ipt][1]->GetMinimum(); double del = mmax-mmin; cout<<ic<<endl; cout<<mmax<<" "<<mmin<<endl; hCorr_1D[ic][ipt][0]->SetMaximum(mmax+0.65*del); hCorr_1D[ic][ipt][0]->SetMinimum(mmin-0.12*del); cout<<hCorr_1D[ic][ipt][0]->GetMaximum()<<" "<<hCorr_1D[ic][ipt][0]->GetMinimum()<<endl; setstyle(hCorr_1D[ic][ipt][0]); hCorr_1D[ic][ipt][0]->SetXTitle("#Delta#phi [rad]"); hCorr_1D[ic][ipt][0]->SetYTitle("C(#Delta#phi)"); hCorr_1D[ic][ipt][0]->DrawCopy(); // txt.DrawCopyLatex(0.6,0.2,"ATLAS internal"); //hCorr_1D[ic][ipt][0]->GetYaxis()->SetRangeUser(mmin-0.3*del, mmax+0.45*del); if(qs==1){ // hCorr_1D[ic][ipt][0]->SetMaximum(hCorr_1D[ic][ipt][0]->GetMaximum()); // hCorr_1D[ic][ipt][0]->SetMinimum(hCorr_1D[ic][ipt][0]->GetMinimum()); } line.DrawLine(-0.5*PI,1,1.5*PI,1); hCorr_1D[ic][ipt][1]->DrawCopy("same"); hCorr_1D[ic][ipt][2]->DrawCopy("same"); hCorr_1D[ic][ipt][3]->DrawCopy("same"); //hcor[ic][ipt][3]->Draw("same"); //hcor[ic][ipt][4]->Draw("same"); float xs=-0.35,ys=-0.; lab1.DrawLatex(xs+0.63,ys+0.92,"ATLAS"); lab2.DrawLatex(xs+0.79,ys+0.92,"Internal"); lab3.DrawLatex(xs+0.63, ys+0.85,"#sqrt{s_{NN}}=5.02 TeV"); // lab3.DrawLatex(xs+0.65,ys+0.78,"L_{int} = 7 #mub^{-1}"); // if(qs==0) text1.DrawLatex(0.21,0.93,"(a)"); if(qs==1) text1.DrawLatex(0.21,0.93,"(b)"); int icbin = cbins[ic]; sprintf(name,"Centrality %d-%d%%",icbin*5,icbin*5+5); lab3.DrawLatex(0.6,0.92,name); l = new TLegend(0.55,0.70,1,0.91); l->SetTextFont(43); l->SetTextSize(15); l->SetFillStyle(0); l->SetBorderSize(0); if(qs==1){ l->AddEntry(hCorr_1D[ic][ipt][1],"v_{2} trigger ","pl"); l->AddEntry(hCorr_1D[ic][ipt][2],"v_{3} trigger","pl"); l->AddEntry(hCorr_1D[ic][ipt][3],"large v_{2} & v_{3} trigger","pl"); }else{ // l->AddEntry(hCorr_1D[ic][ipt][0],"largest 10% q_{3}","pl"); // l->AddEntry(hCorr_1D[ic][ipt][1],"smallest 10% q_{3}","pl"); } l->AddEntry(hCorr_1D[ic][ipt][0],"MiniBias","pl"); l->Draw(); lab2.DrawLatex(0.65,0.2,ptnames[ipt]); lab2.DrawLatex(0.31,0.2,"2<|#Delta#eta|<4.8"); }//qs sprintf(name,"%s.eps", c->GetName()); c->Print(name); sprintf(name,"%s.pdf", c->GetName()); c->Print(name); }
void event(){ TCanvas *c1 = new TCanvas("c1","ROOT Event description",700,500); c1->Range(0,0,14,15.5); TPaveText *event = new TPaveText(1,13,3,15); event->SetFillColor(11); event->Draw(); event->AddText("Event"); TLine *line = new TLine(1.1,13,1.1,1.5); line->SetLineWidth(2); line->Draw(); line->DrawLine(1.3,13,1.3,3.5); line->DrawLine(1.5,13,1.5,5.5); line->DrawLine(1.7,13,1.7,7.5); line->DrawLine(1.9,13,1.9,9.5); line->DrawLine(2.1,13,2.1,11.5); TArrow *arrow = new TArrow(1.1,1.5,3.9,1.5,0.02,"|>"); arrow->SetFillStyle(1001); arrow->SetFillColor(1); arrow->Draw(); arrow->DrawArrow(1.3,3.5,3.9,3.5,0.02,"|>"); arrow->DrawArrow(1.5,5.5,3.9,5.5,0.02,"|>"); arrow->DrawArrow(1.7,7.5,3.9,7.5,0.02,"|>"); arrow->DrawArrow(1.9,9.5,3.9,9.5,0.02,"|>"); arrow->DrawArrow(2.1,11.5,3.9,11.5,0.02,"|>"); TPaveText *p1 = new TPaveText(4,1,11,2); p1->SetTextAlign(12); p1->SetFillColor(42); p1->AddText("1 Mbyte"); p1->Draw(); TPaveText *p2 = new TPaveText(4,3,10,4); p2->SetTextAlign(12); p2->SetFillColor(42); p2->AddText("100 Kbytes"); p2->Draw(); TPaveText *p3 = new TPaveText(4,5,9,6); p3->SetTextAlign(12); p3->SetFillColor(42); p3->AddText("10 Kbytes"); p3->Draw(); TPaveText *p4 = new TPaveText(4,7,8,8); p4->SetTextAlign(12); p4->SetFillColor(42); p4->AddText("1 Kbytes"); p4->Draw(); TPaveText *p5 = new TPaveText(4,9,7,10); p5->SetTextAlign(12); p5->SetFillColor(42); p5->AddText("100 bytes"); p5->Draw(); TPaveText *p6 = new TPaveText(4,11,6,12); p6->SetTextAlign(12); p6->SetFillColor(42); p6->AddText("10 bytes"); p6->Draw(); TText *text = new TText(); text->SetTextAlign(12); text->SetTextSize(0.04); text->SetTextFont(72); text->DrawText(6.2,11.5,"Header:Event_flag"); text->DrawText(7.2,9.5,"Trigger_Info"); text->DrawText(8.2,7.5,"Muon_Detector: TOF"); text->DrawText(9.2,5.5,"Calorimeters"); text->DrawText(10.2,3.5,"Forward_Detectors"); text->DrawText(11.2,1.5,"TPCs"); }