void UReporterGraph::Draw(UCanvas* Canvas) { if(!bVisible) { return; } DrawBackground(Canvas); switch(DataStyle) { case EGraphDataStyle::Lines: { // order doesn't *really* matter, as they're lines DrawAxes(Canvas); DrawData(Canvas); } break; case EGraphDataStyle::Filled: { // draw data first and overlay axes DrawData(Canvas); DrawAxes(Canvas); } break; } DrawLegend(Canvas); DrawThresholds(Canvas); }
bool SVGPlotter::Save(const char *fname) { sx = width/(xMax-xMin); sy = height/(yMax-yMin); bool retval = false; const char *ext = GetFileExtension(fname); FILE *fout = fopen(fname, "w"); if(!fout) { fprintf(stderr, "Failed to open '%s' for writing plot\n", fname); return false; } if(!strcmp(ext, "svg") || !strcmp(ext, "SVG")) { retval = SaveHeader(fout) && SaveStyles(fout) && DrawPlots(fout) && DrawAxis(fout) && DrawLegend(fout) && SaveFooter(fout); } else if(!strcmp(ext, "m") || !strcmp(ext, "M")) { retval = SaveHeaderMatlab(fout) && DrawPlotsMatlab(fout) && DrawLegendMatlab(fout); } else { fprintf(stderr, "Error: plotter only supports file format .m or .svg\n"); retval = false; } fclose(fout); return retval; }
//*******************************************************************************************************/ //* FileName: clPlot.cpp //* //* Contents: Implementation of clPlot, axis, legend, serie and timeaxis //* //* NOTE 1: Only a minimum of parameter validation is implemented to save time since this plot is //* time critical. //* //* NOTE 2: All functionality is not fully implemented. //* //* Author: Jan Vidar Berger //*******************************************************************************************************/ //* 12.feb.98 Jan Vidar Berger Implemented flicker free drawing. Thanks to John Kim for providing //* the CGridMemDC and to Keith Rule, the author of CMemDC. //*******************************************************************************************************/ #include "stdafx.h" #include "clPlot.h" #include "GridMemDC.h" #include "malloc.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif long clPlot::m_lMaxDataPrSerie; // max allowed data pr. serie. long clPlot::m_lMaxDataTotal; // max allowed data total. //*******************************************************************************************************/ //* time axis threshold. contains grid and label intervals to be used within specified //* seconds pr. pixels thresholds. The array is terminated by a 'bIAmInUse'=FALSE. //*******************************************************************************************************/ struct{ BOOL bIAmInUse; // indicate valid entry, last=FALSE long lgridinterval; // grid line interval in seconds long llabelinterval; // time label interval in seconds long lmodethreshold; // mode threshold in seconds pr. pixel }gridsetting[]={ TRUE, 1, 4, 0, // 0: pr. second FALSE, 1, 1,0, // last entry in table }; //*******************************************************************************************************/ //* Function: serie::serie //*******************************************************************************************************/ serie::serie() { m_bIAmInUse = FALSE; m_color = RGB(0,0,0); m_iLineStyle = PS_SOLID; m_bRightAxisAlign = FALSE; m_lNoValues = 0; m_lbegin = 0; m_lend = 0; m_pvalues = NULL; } //*******************************************************************************************************/ //* Function: serie::~serie //*******************************************************************************************************/ serie::~serie() { if(m_pvalues !=NULL) free(m_pvalues); } //*******************************************************************************************************/ //* Function: serie::AddPoint //* //* Description: AddPoint add new data to the end of a data serie. It will simply append the data, //* update the list index and get out. //* //* This function will also call realloc or malloc to re-size or create the plot array as //* needed. //* //* The nice thing about circular lists is that they are multi thread enabled as is. You //* must however implement a syncronization mechanism if more than one thread is supposed //* to enter data into the plot. //* //* Parameters: valuetime Time (x value). //* y y value //* //* Return Value: -none- //* //* Author: Jan Vidar Berger //*******************************************************************************************************/ void serie::AddPoint(CTime &valuetime , double &y) { if(m_lNoValues > 0) m_pvalues = (value*)realloc(m_pvalues, (m_lNoValues+1)*sizeof(value)); else m_pvalues = (value*)malloc((m_lNoValues+1)*sizeof(value)); m_pvalues[m_lend].ValueTime = valuetime; m_pvalues[m_lend].dValue = y; m_lNoValues++; m_lend++; if(m_lend >= clPlot::m_lMaxDataPrSerie) m_lend=0; if(m_lbegin == m_lend){ m_lbegin++; if(m_lbegin >= clPlot::m_lMaxDataPrSerie) m_lbegin=0; } } //*******************************************************************************************************/ //* Function: serie::Reset //* //* Description: Reset the serie. Remove data and reset indexes and pointers. //* //* Parameters: -none- //* //* Return Value: -none- //* //* Author: Jan Vidar Berger //*******************************************************************************************************/ void serie::Reset() { m_lNoValues=0; if(m_pvalues !=NULL) free(m_pvalues); m_pvalues = NULL; m_lbegin = 0; m_lend = 0; } //*******************************************************************************************************/ //*******************************************************************************************************/ clPlot::clPlot() { m_ctlBkColor = RGB(255,255,255); m_plotBkColor = RGB(255,255,255); m_legendBkColor = RGB(255,255,255); m_gridColor = RGB(127,127,127); m_bctlBorder = TRUE; m_bplotBorder = TRUE; m_blegendBorder = TRUE; m_bPrimaryLegend = FALSE; m_bSecondaryLegend = FALSE; m_bAxisLY = TRUE; m_bAxisRY = TRUE; m_bAxisBX = TRUE; m_bAutoScrollX = FALSE; m_bSimMode = FALSE; m_lMaxDataPrSerie = 10000; m_lMaxDataTotal = 100000; m_dNoData = 0.0; m_dzoom = 1.0; lArraySize = 1000; // only points with differebt x,y will be put into the array pLineArray = new CPoint[lArraySize]; SetBXRange(CTime::GetCurrentTime()-CTimeSpan(60),CTime::GetCurrentTime()); m_logFont.lfHeight = -13; m_logFont.lfWidth = 0; m_logFont.lfEscapement = 0; m_logFont.lfOrientation = 0; m_logFont.lfWeight = 400; m_logFont.lfItalic = FALSE; m_logFont.lfUnderline = FALSE; m_logFont.lfStrikeOut = FALSE; m_logFont.lfCharSet = ANSI_CHARSET; m_logFont.lfOutPrecision = OUT_DEFAULT_PRECIS; m_logFont.lfClipPrecision = CLIP_DEFAULT_PRECIS; m_logFont.lfQuality = PROOF_QUALITY; m_logFont.lfPitchAndFamily = DEFAULT_PITCH; wcscpy(m_logFont.lfFaceName,_T("Ariel")); m_zoomFont.lfHeight = -13; m_zoomFont.lfWidth = 0; m_zoomFont.lfEscapement = 0; m_zoomFont.lfOrientation = 0; m_zoomFont.lfWeight = 400; m_zoomFont.lfItalic = FALSE; m_zoomFont.lfUnderline = FALSE; m_zoomFont.lfStrikeOut = FALSE; m_zoomFont.lfCharSet = ANSI_CHARSET; m_zoomFont.lfOutPrecision = OUT_DEFAULT_PRECIS; m_zoomFont.lfClipPrecision = CLIP_DEFAULT_PRECIS; m_zoomFont.lfQuality = PROOF_QUALITY; m_zoomFont.lfPitchAndFamily = DEFAULT_PITCH; wcscpy(m_zoomFont.lfFaceName,_T("Ariel")); m_font.CreateFontIndirect(&m_zoomFont); } //*******************************************************************************************************/ //*******************************************************************************************************/ clPlot::~clPlot() { delete [] pLineArray; } //*******************************************************************************************************/ //*******************************************************************************************************/ BEGIN_MESSAGE_MAP(clPlot, CWnd) //{{AFX_MSG_MAP(clPlot) ON_WM_PAINT() //}}AFX_MSG_MAP END_MESSAGE_MAP() //*******************************************************************************************************/ //*******************************************************************************************************/ BOOL clPlot::Create(DWORD dwstyle, CRect &rect, CWnd *pParent, UINT id) { DWORD style = dwstyle & (~WS_BORDER); if(dwstyle & WS_BORDER) m_bctlBorder=TRUE; else m_bctlBorder=FALSE; if(!CWnd::Create(NULL, _T(""), style, rect, pParent, id, NULL)) return FALSE; m_ctlRect = rect; pParent->ClientToScreen(m_ctlRect); ScreenToClient(m_ctlRect); ComputeRects(TRUE); return TRUE; } //*******************************************************************************************************/ //* Function : clPlot::ComputeRects //* //* Description : Compute rects used for internal possitioning of different objects. This function is //* called when the plot is created or sized. //* //* Return type : void //* //* Parameter(s) : bInitialization indicate wherever parameters that can be changed abu the user //* also should be computed. //* //* Author : Jan Vidar Berger //*******************************************************************************************************/ void clPlot::ComputeRects(BOOL bInitialization) { // adjust the client rect for borders //GetClientRect(m_ctlRect); CClientDC dc(this); int w = 0; int n=0; CSize z=dc.GetTextExtent(CString("A")); // m_TextHeight = z.cy; m_dzoom = ((double)m_ctlRect.Height()/(double)z.cy) / 25.0; m_zoomFont.lfWidth = (int)(m_logFont.lfWidth * m_dzoom); m_zoomFont.lfHeight = (int)(m_logFont.lfHeight * m_dzoom); m_font.Detach(); m_font.CreateFontIndirect(&m_zoomFont); CFont *oFont = dc.SelectObject(&m_font); // SetFont(&m_font); z=dc.GetTextExtent(CString("A")); m_TextHeight = z.cy; if(m_bctlBorder){ m_clientRect.left = m_ctlRect.left+2; m_clientRect.right = m_ctlRect.right-2; m_clientRect.top = m_ctlRect.top+2; m_clientRect.bottom = m_ctlRect.bottom-2; }else{ m_clientRect = m_ctlRect; } if(bInitialization) { m_iMtop = m_iMbottom = m_clientRect.Height()/10; m_iMleft = m_iMright = m_clientRect.Width()/10; } // compute plot rect. m_plotRect.left = m_clientRect.left + m_iMleft; m_plotRect.right = m_clientRect.right - m_iMright; m_plotRect.top = m_clientRect.top + m_iMtop; m_plotRect.bottom = m_clientRect.bottom - m_iMbottom; // compute default legend possition if(bInitialization) { m_legendRect.left = m_plotRect.left + (m_iMleft/5); m_legendRect.right = m_plotRect.left + (m_plotRect.Width()/5); m_legendRect.top = m_plotRect.top - (m_iMtop/2); m_legendRect.bottom = m_plotRect.top + (m_iMtop); int w = 0; int n=0; for(int x = 0; x< MAXLEGENDS;x++){ if(m_primarylegends[x].m_bIAmInUse){ n++; z=dc.GetTextExtent(CString(m_primarylegends[x].m_szTitle)); if(z.cx > w ) w=z.cx; // m_TextHeight = z.cy; } } m_legendRect.right = m_legendRect.left + 40 + w; m_legendRect.bottom = m_legendRect.top + 10 + (m_TextHeight*n); } // compute left axis area m_axisLYRect.left = m_clientRect.left + (m_iMleft/5); m_axisLYRect.right = m_plotRect.left; m_axisLYRect.top = m_plotRect.top; m_axisLYRect.bottom = m_plotRect.bottom; // compute right axis area m_axisRYRect.left = m_plotRect.left; m_axisRYRect.right = m_clientRect.right - (m_iMright/5); m_axisRYRect.top = m_plotRect.top; m_axisRYRect.bottom = m_plotRect.bottom; // compute bottom axis area m_axisBXRect.left = m_plotRect.left; m_axisBXRect.right = m_plotRect.right; m_axisBXRect.top = m_plotRect.bottom; m_axisBXRect.bottom = m_clientRect.bottom - (m_iMbottom/5); // if(bInitialization) // { m_timeaxis.m_dSecondsPrPixel = ((double)(m_timeaxis.m_maxtime.GetTime() - m_timeaxis.m_mintime.GetTime())) / (double)m_plotRect.Width(); m_leftaxis.m_dValuePrPixel = ((double)(m_leftaxis.maxrange- m_leftaxis.minrange) / (double)m_plotRect.Height()); m_rightaxis.m_dValuePrPixel = ((double)(m_rightaxis.maxrange- m_rightaxis.minrange) / (double)m_plotRect.Height()); // } dc.SelectObject(oFont); } //*******************************************************************************************************/ //* Function: clPlot::OnPaint //* //* Description: This function will create a memory image, call Draw to draw the plot on it, and when //* copy the image into memory. //* //* This is fast and provides flicker free plot update. //* //* Author: Jan Vidar Berger //*******************************************************************************************************/ void clPlot::OnPaint() { CPaintDC dc(this); // device context for painting CGridMemDC pdc(&dc); // non flickering painting Draw(&pdc); // Do not call CWnd::OnPaint() for painting messages } BOOL clPlot::OnEraseBkgnd(CDC* pDC) { return FALSE; } //*******************************************************************************************************/ //*******************************************************************************************************/ void clPlot::Draw(CDC * dc) { CFont *oFont = dc->SelectObject(&m_font); DrawBasic(dc); DrawGrid(dc); DrawPlot(dc); DrawLegend(dc); dc->SelectObject(oFont); }
void do_redraw(char *userdata, GraphWin * wi) { if ( TransformCompute(wi) ) { DrawTitle(userdata, wi); DrawLegend(userdata, wi); DrawGridAndAxis(userdata, wi); DrawData(userdata, wi); DrawLabel(userdata, wi); } }
void AxisPlot::DrawData(wxDC &dc, wxRect rc) { wxRect rcData; wxRect rcLegend; CalcDataArea(dc, rc, rcData, rcLegend); m_dataBackground->Draw(dc, rcData); DrawAxes(dc, rc, rcData); DrawDataArea(dc, rcData); DrawLegend(dc, rcLegend); }
static bool LegWCallBack(t_x11 *x11, XEvent *event, Window /*w*/, void *data) { t_legendwin *lw; lw = (t_legendwin *)data; switch (event->type) { case Expose: DrawLegend(x11, &lw->wd); break; default: break; } return false; }
void CPlot::RefreshPlot(CDC* pDC) { // 更新布局 RefreshLayout(); // 绘制背景 DrawBackground(pDC); // 绘制坐标轴 DrawAxises(pDC); // 绘制网格 DrawGrids(pDC); // 绘制图例 DrawLegend(pDC,m_rectLegend); // 绘制标题 DrawTile(pDC,m_rectTitle); // 绘制曲线 DrawLines(pDC); }
//------------------------------------------------------------------------------ // DrawHistogram //------------------------------------------------------------------------------ void DrawHistogram(TString hname, TString xtitle, Int_t ngroup = -1, Int_t precision = 1, TString units = "NULL", Double_t xmin = -999, Double_t xmax = 999, Bool_t moveOverflow = true) { //TCanvas* canvas = new TCanvas(hname, hname, 550, 720); TCanvas* canvas = new TCanvas(hname, hname, 800, 800); TPad* pad1 = new TPad("pad1", "pad1", 0, 0.3, 1, 1.0); TPad* pad2 = new TPad("pad2", "pad2", 0, 0.0, 1, 0.3); pad1->SetTopMargin (0.08); pad1->SetBottomMargin(0.02); pad1->Draw(); pad2->SetTopMargin (0.08); pad2->SetBottomMargin(0.35); pad2->Draw(); //---------------------------------------------------------------------------- // pad1 //---------------------------------------------------------------------------- pad1->cd(); pad1->SetLogy(_setLogy); THStack* hstack = new THStack(hname, hname); TH1F* hist[nProcesses]; //Save histograms to root file TFile* outfile; //TString fname = Form("files/%s_%djet.root", hname.Data(),_njet); TString fname = "files/0jet_"+hname+".root"; if(_njet==1) fname = "files/1jet_"+hname+".root"; outfile = new TFile(fname, "create"); TH1F* data; TH1F* top; TH1F* tW; TH1F* WW; TH1F* WZ; TH1F* ZZ; TH1F* Wg; TH1F* WgSMu; TH1F* WgSEl; TH1F* Wjets; TH1F* Zjets; TH1F* DYtau; TH1F* Zgamma; TH1F* ggH; for (UInt_t ip=0; ip<nProcesses; ip++) { hist[ip] = (TH1F*)input[ip]->Get(hname); hist[ip]->SetName(hname + process[ip]); hist[ip]->SetTitle(""); if(ip == iData) data = (TH1F*)hist[iData]->Clone("Data"); //data -> Sumw2(); if(ip == itt) top = (TH1F*)hist[itt]->Clone("top"); //top -> Sumw2(); if(ip == itW) tW = (TH1F*)hist[itW]->Clone("tW"); //tW -> Sumw2(); if(ip == iWW) WW = (TH1F*)hist[iWW]->Clone("WW"); //WW -> Sumw2(); if(ip == iWZ) WZ = (TH1F*)hist[iWZ]->Clone("WZ"); //VV -> Sumw2(); if(ip == iZZ) ZZ = (TH1F*)hist[iZZ]->Clone("ZZ"); //ZZ -> Sumw2(); if(ip == iWg) Wg = (TH1F*)hist[iWg]->Clone("Wg"); //Wg -> Sumw2(); if(ip == iWgSMu){ WgSMu = (TH1F*)hist[iWgSMu]->Clone("WgSMu"); //WgSMu -> Sumw2(); hist[iWgSMu]->Scale(1.5); } if(ip == iWgSEl){ WgSEl = (TH1F*)hist[iWgSEl]->Clone("WgSEl"); //WgSel -> Sumw2(); hist[iWgSEl]->Scale(1.5); //WgSel -> Sumw2(); } if(ip == iWj) Wjets = (TH1F*)hist[iWj]->Clone("W+jets"); //Wjets -> Sumw2(); if(ip == iDY) Zjets = (TH1F*)hist[iDY]->Clone("Z+jets"); //Zjets -> Sumw2(); if(ip == iDYtau) DYtau = (TH1F*)hist[iDYtau]->Clone("DYtau"); //DYtau -> Sumw2(); if(ip == iZgamma) Zgamma = (TH1F*)hist[iZgamma]->Clone("Zgamma"); //Zgamma -> Sumw2(); if(ip == iH125) ggH = (TH1F*)hist[iH125]->Clone("ggH"); //ggH -> Sumw2(); if (moveOverflow) MoveOverflowBins (hist[ip], xmin, xmax); else ZeroOutOfRangeBins(hist[ip], xmin, xmax); if (ngroup > 0) hist[ip]->Rebin(ngroup); if (ip == iWg) { //hist[ip]->Scale(0.01); } if (ip == iData) { hist[ip]->SetMarkerStyle(kFullCircle); } else { hist[ip]->SetFillColor(color[ip]); hist[ip]->SetFillStyle(1001); hist[ip]->SetLineColor(color[ip]); if (_dataDriven && ip == itt) hist[ip]->Scale(ttScale[_njet]); if (_dataDriven && ip == itW) hist[ip]->Scale(tWScale[_njet]); if (_dataDriven && ip == iWW) hist[ip]->Scale(WWScale[_njet]); if (_dataDriven && ip == iDY) hist[ip]->Scale(ZjScale[_njet]); if (_dataDriven && ip == iDYtau) hist[ip]->Scale(ZjScale[_njet]); if( ip != iZZ ) hstack->Add(hist[ip]);//TODO something wrong with ZZ } } if (_dataDriven) { top->Scale(ttScale[_njet]); tW->Scale(tWScale[_njet]); WW->Scale(WWScale[_njet]); Zjets->Scale(ZjScale[_njet]); DYtau->Scale(ZjScale[_njet]); } top ->Add(tW); //VV ->Add(ZZ); //VV ->Add(Wg); //Zjets->Add(DYtau); //Zjets->Add(Zgamma); data -> Write(); top -> Write(); WW -> Write(); //VV -> Write(); //Wjets -> Write(); //Zjets -> Write(); ggH -> Write(); outfile->Close(); // All MC //---------------------------------------------------------------------------- TH1F* allmc = (TH1F*)hist[iData]->Clone("allmc"); allmc->SetFillColor (kGray+2); allmc->SetFillStyle ( 3345); allmc->SetLineColor (kGray+2); allmc->SetMarkerColor(kGray+2); allmc->SetMarkerSize ( 0); for (UInt_t ibin=1; ibin<=allmc->GetNbinsX(); ibin++) { Double_t binValue = 0; Double_t binError = 0; for (UInt_t ip=0; ip<nProcesses; ip++) { if (ip == iData) continue; if (ip == iZZ) continue; Double_t binContent = hist[ip]->GetBinContent(ibin); binValue += binContent; binError += (hist[ip]->GetBinError(ibin) * hist[ip]->GetBinError(ibin)); //We need to calculate systematic uncertainty for ggH case // if (_dataDriven) // binError += (systError[ip]*binContent * systError[ip]*binContent); } binError = sqrt(binError); allmc->SetBinContent(ibin, binValue); allmc->SetBinError (ibin, binError); } // Axis labels //------------------------------------------------------------------ TAxis* xaxis = hist[iData]->GetXaxis(); TAxis* yaxis = hist[iData]->GetYaxis(); TString ytitle = Form("entries / %s.%df", "%", precision); xaxis->SetTitle(xtitle); yaxis->SetTitle(Form(ytitle.Data(), hist[iData]->GetBinWidth(0))); yaxis->SetTitleOffset(1.6); if (!units.Contains("NULL")) { xaxis->SetTitle(Form("%s [%s]", xaxis->GetTitle(), units.Data())); yaxis->SetTitle(Form("%s %s", yaxis->GetTitle(), units.Data())); } // Draw //-------------------------------------------------------------------- xaxis->SetRangeUser(xmin, xmax); hist[iData]->Draw("ep"); hstack ->Draw("hist,same"); allmc ->Draw("e2,same"); hist[iData]->Draw("ep,same"); // Adjust scale //---------------------------------------------------------------------------- Float_t theMax = GetMaximumIncludingErrors(hist[iData], xmin, xmax); Float_t theMaxMC = GetMaximumIncludingErrors(allmc, xmin, xmax); if (theMaxMC > theMax) theMax = theMaxMC; if (pad1->GetLogy()) { theMax = TMath::Power(10, TMath::Log10(theMax) + 2.7); hist[iData]->SetMinimum(0.05); } else theMax *= 1.55; hist[iData]->SetMaximum(theMax); // Legend //---------------------------------------------------------------------- Double_t x0 = 0.720; Double_t y0 = 0.834; Double_t yoffset = 0.048; Double_t delta = yoffset + 0.001; Double_t ndelta = 0; Double_t YieldTop = Yield(hist[itt]) + Yield(hist[itW]); Double_t YieldWZ = Yield(hist[iWZ]); Double_t YieldVV = Yield(hist[iWZ]) + Yield(hist[iZZ]) + Yield(hist[iWg]); //Double_t YieldZJets = Yield(hist[iDY]) + Yield(hist[iDYtau]); Double_t YieldZJets = Yield(hist[iDY]) + Yield(hist[iDYtau]) + Yield(hist[iZgamma]); DrawLegend(x0 - 0.49, y0 - ndelta, hist[iData], Form(" data (%.0f)", Yield(hist[iData])), "lp", 0.03, 0.2, yoffset); ndelta += delta; //DrawLegend(x0 - 0.23, y0 - ndelta, hist[itt], Form(" tt (%.0f)", Yield(hist[itt])), "f", 0.03, 0.2, yoffset); ndelta += delta; //DrawLegend(x0 - 0.23, y0 - ndelta, hist[itW], Form(" tW (%.0f)", Yield(hist[itW])), "f", 0.03, 0.2, yoffset); ndelta += delta; //DrawLegend(x0 - 0.49, y0 - ndelta, allmc, Form(" all (%.0f)", Yield(allmc)), "f", 0.03, 0.2, yoffset); ndelta += delta; DrawLegend(x0 - 0.49, y0 - ndelta, hist[iWW], Form(" WW (%.0f)", Yield(hist[iWW])), "f", 0.03, 0.2, yoffset); ndelta += delta; DrawLegend(x0 - 0.49, y0 - ndelta, hist[iWZ], Form(" WZ (%.0f)", Yield(hist[iWZ])), "f", 0.03, 0.2, yoffset); ndelta += delta; DrawLegend(x0 - 0.49, y0 - ndelta, hist[iWg], Form(" Wg (%.0f)", Yield(hist[iWg])), "f", 0.03, 0.2, yoffset); ndelta += delta; DrawLegend(x0 - 0.49, y0 - ndelta, hist[iWgSMu], Form(" Wg*Mu (%.0f)", Yield(hist[iWgSMu])), "f", 0.03, 0.2, yoffset); ndelta += delta; DrawLegend(x0 - 0.49, y0 - ndelta, hist[iWgSEl], Form(" Wg*El (%.0f)", Yield(hist[iWgSEl])), "f", 0.03, 0.2, yoffset); ndelta += delta; DrawLegend(x0 - 0.49, y0 - ndelta, hist[iWj], Form(" W+jets (%.0f)",Yield(hist[iWj])), "f", 0.03, 0.2, yoffset); ndelta += delta; DrawLegend(x0 - 0.49, y0 - ndelta, hist[iZZ], Form(" ZZ (%.0f)", Yield(hist[iZZ])), "f", 0.03, 0.2, yoffset); ndelta += delta; ndelta = 0; DrawLegend(x0 - 0.23, y0 - ndelta, hist[iDY], Form(" DY (%.0f)", Yield(hist[iDY])), "f", 0.03, 0.2, yoffset); ndelta += delta; DrawLegend(x0 - 0.23, y0 - ndelta, hist[iDYtau], Form(" DYtau (%.0f)", Yield(hist[iDYtau])),"f", 0.03, 0.2, yoffset); ndelta += delta; DrawLegend(x0 - 0.23, y0 - ndelta, hist[iZgamma],Form(" Zg (%.0f)", Yield(hist[iZgamma])),"f", 0.03, 0.2, yoffset); ndelta += delta; //DrawLegend(x0 - 0.23, y0 - ndelta, hist[iDY], Form(" Z+jets (%.0f)", YieldZJets), "f", 0.03, 0.2, yoffset); ndelta += delta; //DrawLegend(x0 - 0.23, y0 - ndelta, hist[iH125], Form(" Higgs (%.0f)", Yield(hist[iH125])), "f", 0.03, 0.2, yoffset); ndelta += delta; DrawLegend(x0 - 0.23, y0 - ndelta, hist[iH125], Form(" ggH (%.0f)", Yield(hist[iH125])), "f", 0.03, 0.2, yoffset); ndelta += delta; DrawLegend(x0 - 0.23, y0 - ndelta, hist[itt], Form(" tt (%.0f)", Yield(hist[itt])), "f", 0.03, 0.2, yoffset); ndelta += delta; DrawLegend(x0 - 0.23, y0 - ndelta, hist[itW], Form(" tW (%.0f)", Yield(hist[itW])), "f", 0.03, 0.2, yoffset); ndelta += delta; // Additional titles //---------------------------------------------------------------------------- //TString channelLabel = "ee/#mu#mu/e#mu/#mue"; TString channelLabel = ""; //if (_channel == "EE") channelLabel = "ee"; //if (_channel == "MuMu") channelLabel = "#mu#mu"; //if (_channel == "EMu") channelLabel = "e#mu"; //if (_channel == "MuE") channelLabel = "#mue"; //if (_channel == "SF") channelLabel = "ee/#mu#mu"; //if (_channel == "OF") channelLabel = "e#mu/#mue"; channelLabel += Form(" %d", _njet); if (_njet == 0) channelLabel += "-jets"; if (_njet == 1) channelLabel += "-jet"; if (_njet >= 2) channelLabel += "-jets"; double nBin; double binWidth; nBin = allmc->GetSize(); nBin -=2; binWidth = allmc->GetBinWidth(2); int Z1bin=70/binWidth; int Z2bin=110/binWidth; cout<<"number of bin: "<<nBin<<endl; cout<<"Z bin1: "<<Z1bin<<" Z bin2: "<<Z2bin<<endl; double nMcZ, nDataZ; nMcZ = allmc->Integral(Z1bin,Z2bin); nDataZ = hist[iData]->Integral(Z1bin,Z2bin); double effiCorr; effiCorr=nDataZ/nMcZ; cout<<"efficiency correction factor: "<<effiCorr<<endl; double nMcGstar, nDataGstar, nMcGamma; nMcGstar = hist[iWgSMu]->Integral(1,2); nMcGamma = hist[iWg]->Integral(1,2); //nMcGstar = allmc->Integral(1,2); nMcGstar *= effiCorr; nMcGamma *= effiCorr; nDataGstar = hist[iData]->Integral(1,2); double Kfactor; double KfactorErr; nDataGstar -= nMcGamma; Kfactor = nDataGstar/nMcGstar; KfactorErr =Kfactor* TMath::Sqrt(nDataGstar/nDataGstar/nDataGstar + nMcGstar/nMcGstar/nMcGstar); KfactorErr += 0.1; cout<<"Kfactor: "<<Kfactor<<"+"<<KfactorErr<<endl; //DrawTLatex(0.185, 0.975, 0.05, 13, channelLabel.Data(),""); DrawTLatex(0.940, 0.983, 0.05, 33, Form("L = %.1f fb^{-1}", _luminosity/1e3),""); DrawTLatex(0.45, 0.48, 0.04, 13, Form("K factor (Data/Wg*) = %.2f #pm %.2f", Kfactor, KfactorErr ),""); DrawTLatex(0.45, 0.43, 0.04, 13, Form("0< InvM(#mu^{+}#mu^{-}) <4 GeV"),""); //---------------------------------------------------------------------------- // pad2 //---------------------------------------------------------------------------- pad2->cd(); TH1F* ratio = (TH1F*)hist[iData]->Clone("ratio"); TH1F* uncertainty = (TH1F*)allmc->Clone("uncertainty"); for (UInt_t ibin=1; ibin<=ratio->GetNbinsX(); ibin++) { Double_t mcValue = allmc->GetBinContent(ibin); Double_t mcError = allmc->GetBinError (ibin); Double_t dtValue = ratio->GetBinContent(ibin); Double_t dtError = ratio->GetBinError (ibin); Double_t ratioValue = (mcValue > 0) ? dtValue/mcValue : 0.0; Double_t ratioError = (mcValue > 0) ? dtError/mcValue : 0.0; Double_t uncertaintyError = (mcValue > 0) ? mcError/mcValue : 0.0; ratio->SetBinContent(ibin, ratioValue); ratio->SetBinError (ibin, ratioError); uncertainty->SetBinContent(ibin, 1.0); uncertainty->SetBinError (ibin, uncertaintyError); } TAxis* uaxis = (TAxis*)uncertainty->GetXaxis(); uaxis->SetRangeUser(xmin, xmax); uncertainty->Draw("e2"); ratio ->Draw("ep,same"); uncertainty->GetYaxis()->SetRangeUser(0, 2.5); // Save //---------------------------------------------------------------------- pad2->cd(); SetAxis(uncertainty, hist[iData]->GetXaxis()->GetTitle(), "data / prediction", 0.10, 0.8); pad1->cd(); SetAxis(hist[iData], "", hist[iData]->GetYaxis()->GetTitle(), 0.05, 1.6); canvas->cd(); TString suffixLogy = (_setLogy) ? "_Log" : "_Lin"; canvas->SaveAs(Form("%s/%s%s.%s", _output.Data(), hname.Data(), suffixLogy.Data(), _format.Data())); }
//------------------------------------------------------------------------------ // DrawHistogram //------------------------------------------------------------------------------ void DrawHistogram(TString hname, TString xtitle, Int_t ngroup = -1, Int_t precision = 1, TString units = "NULL", Double_t xmin = -999, Double_t xmax = 999, Bool_t moveOverflow = true) { //TCanvas* canvas = new TCanvas(hname, hname, 550, 720); TCanvas* canvas = new TCanvas(hname, hname, 800, 800); TPad* pad1 = new TPad("pad1", "pad1", 0, 0.3, 1, 1.0); TPad* pad2 = new TPad("pad2", "pad2", 0, 0.0, 1, 0.3); pad1->SetTopMargin (0.08); pad1->SetBottomMargin(0.02); pad1->Draw(); pad2->SetTopMargin (0.08); pad2->SetBottomMargin(0.35); pad2->Draw(); //---------------------------------------------------------------------------- // pad1 //---------------------------------------------------------------------------- pad1->cd(); pad1->SetLogy(_setLogy); THStack* hstack = new THStack(hname, hname); TH1F* hist[nProcesses]; TH1F* hist_0[nProcesses]; // 0-jet TH1F* hist_1[nProcesses]; // 1-jet for (UInt_t ip=0; ip<nProcesses; ip++) { if( _njet == 10 ){ hist_0[ip] = (TH1F*)input_0[ip]->Get(hname); hist_1[ip] = (TH1F*)input_1[ip]->Get(hname); }else{ //hist[ip] = (TH1F*)input[ip]->Get(hname); //hist[ip]->SetName(hname + process[ip]); } if (moveOverflow){ if(_njet ==10){ MoveOverflowBins (hist_0[ip], xmin, xmax); MoveOverflowBins (hist_1[ip], xmin, xmax); }else{ //MoveOverflowBins (hist[ip], xmin, xmax); } }else{ if(_njet == 10){ ZeroOutOfRangeBins(hist_0[ip], xmin, xmax); ZeroOutOfRangeBins(hist_1[ip], xmin, xmax); }else{ //ZeroOutOfRangeBins(hist[ip], xmin, xmax); } } if (ngroup > 0){ if(_njet == 10){ hist_0[ip]->Rebin(ngroup); hist_1[ip]->Rebin(ngroup); }else{ //hist[ip]->Rebin(ngroup); } } // Add 0, 1 jet if (ip == iData) { if(_njet == 10 ){ hist[ip] = (TH1F*)hist_0[ip]->Clone(hname+process[ip]); hist[ip]->Add(hist_1[ip]); hist[ip]->SetMarkerStyle(kFullCircle); }else{ //hist[ip]->SetMarkerStyle(kFullCircle); } } else { if(_njet == 10){ if (_dataDriven && ip == itt) hist_0[ip]->Scale(ttScale[0]); if (_dataDriven && ip == itW) hist_0[ip]->Scale(tWScale[0]); if (_dataDriven && ip == iWW) hist_0[ip]->Scale(WWScale[0]); if (_dataDriven && ip == iDY) hist_0[ip]->Scale(ZjScale[0]); if (_dataDriven && ip == iDYtau) hist_0[ip]->Scale(ZjScale[0]); if (_dataDriven && ip == itt) hist_1[ip]->Scale(ttScale[1]); if (_dataDriven && ip == itW) hist_1[ip]->Scale(tWScale[1]); if (_dataDriven && ip == iWW) hist_1[ip]->Scale(WWScale[1]); if (_dataDriven && ip == iDY) hist_1[ip]->Scale(ZjScale[1]); if (_dataDriven && ip == iDYtau) hist_1[ip]->Scale(ZjScale[1]); hist[ip] = (TH1F*)hist_0[ip]->Clone(hname+process[ip]); hist[ip]->Add(hist_1[ip]); hist[ip]->SetFillColor(color[ip]); hist[ip]->SetFillStyle(1001); hist[ip]->SetLineColor(color[ip]); }else{ //hist[ip]->SetFillColor(color[ip]); //hist[ip]->SetFillStyle(1001); //hist[ip]->SetLineColor(color[ip]); //if (_dataDriven && ip == itt) hist[ip]->Scale(ttScale[_njet]); //if (_dataDriven && ip == itW) hist[ip]->Scale(tWScale[_njet]); //if (_dataDriven && ip == iWW) hist[ip]->Scale(WWScale[_njet]); //if (_dataDriven && ip == iDY) hist[ip]->Scale(ZjScale[_njet]); //if (_dataDriven && ip == iDYtau) hist[ip]->Scale(ZjScale[_njet]); } hstack->Add(hist[ip]); } } //========================================================= //Save histograms to root file to draw paper style plots //========================================================= //TFile* outfile; //TString fname = Form("files/%s_%djet.root", hname.Data(),_njet); //TString fname = "files/0jet_"+hname+".root"; //if(_njet==1) fname = "files/1jet_"+hname+".root"; //if(_njet==10) fname = "files/10jet_"+hname+".root"; //outfile = new TFile(fname, "create"); //if(ip == iData) TH1F* data = (TH1F*)hist[iData]->Clone("Data"); //data -> Sumw2(); //if(ip == itt) TH1F* top = (TH1F*)hist[itt]->Clone("top"); //top -> Sumw2(); //if(ip == itW) TH1F* tW = (TH1F*)hist[itW]->Clone("tW"); //tW -> Sumw2(); //if(ip == iWW) TH1F* WW = (TH1F*)hist[iWW]->Clone("WW"); //WW -> Sumw2(); //if(ip == iWZ) TH1F* VVandVVV = (TH1F*)hist[iWZ]->Clone("VVandVVV"); //VV -> Sumw2(); //if(ip == iZZ) TH1F* ZZ = (TH1F*)hist[iZZ]->Clone("ZZ"); //ZZ -> Sumw2(); //if(ip == iWg) TH1F* Wg = (TH1F*)hist[iWg]->Clone("Wg"); //Wg -> Sumw2(); //if(ip == iWj) TH1F* Wjets = (TH1F*)hist[iWj]->Clone("W+jets"); //Wjets -> Sumw2(); //if(ip == iDY) TH1F* Zjets = (TH1F*)hist[iDY]->Clone("Z+jets"); //Zjets -> Sumw2(); //if(ip == iDYtau) TH1F* DYtau = (TH1F*)hist[iDYtau]->Clone("DYtau"); //DYtau -> Sumw2(); //if(ip == iZgamma) TH1F* Zgamma = (TH1F*)hist[iZgamma]->Clone("Zgamma"); //Zgamma -> Sumw2(); //if(ip == iH125) TH1F* ggH = (TH1F*)hist[iH125]->Clone("ggH"); //ggH -> Sumw2(); // //top -> Add(tW); //VVandVVV -> Add(ZZ); //VVandVVV -> Add(Wg); //Zjets -> Add(DYtau); //Zjets -> Add(Zgamma); // //data -> Write(); //top -> Write(); //WW -> Write(); //VVandVVV -> Write(); //Wjets -> Write(); //Zjets -> Write(); //ggH -> Write(); // //outfile -> Close(); // //========================================================= //Draw paper style plots //========================================================= //Use LatinoPlotTools. //As input root file, use above saved root file "outfile" //Run the following executable file: //https://github.com/latinos/LatinoPlotTools/blob/master/WWRunI/scripts/doHWidth_Top_control.sh // All MC //---------------------------------------------------------------------------- TH1F* allmc = (TH1F*)hist[iData]->Clone("allmc"); allmc->SetFillColor (kGray+2); allmc->SetFillStyle ( 3345); allmc->SetLineColor (kGray+2); allmc->SetMarkerColor(kGray+2); allmc->SetMarkerSize ( 0); for (UInt_t ibin=1; ibin<=allmc->GetNbinsX(); ibin++) { Double_t binValue = 0; Double_t binError = 0; for (UInt_t ip=0; ip<nProcesses; ip++) { if (ip == iData) continue; Double_t binContent = hist[ip]->GetBinContent(ibin); binValue += binContent; binError += (hist[ip]->GetBinError(ibin) * hist[ip]->GetBinError(ibin)); //We need to calculate systematic uncertainty for ggH case // if (_dataDriven) // binError += (systError[ip]*binContent * systError[ip]*binContent); } binError = sqrt(binError); allmc->SetBinContent(ibin, binValue); allmc->SetBinError (ibin, binError); } // Axis labels //---------------------------------------------------------------------------- TAxis* xaxis = hist[iData]->GetXaxis(); TAxis* yaxis = hist[iData]->GetYaxis(); TString ytitle = Form("entries / %s.%df", "%", precision); xaxis->SetTitle(xtitle); yaxis->SetTitle(Form(ytitle.Data(), hist[iData]->GetBinWidth(0))); yaxis->SetTitleOffset(1.6); if (!units.Contains("NULL")) { xaxis->SetTitle(Form("%s [%s]", xaxis->GetTitle(), units.Data())); yaxis->SetTitle(Form("%s %s", yaxis->GetTitle(), units.Data())); } // Draw //---------------------------------------------------------------------------- xaxis->SetRangeUser(xmin, xmax); hist[iData]->Draw("ep"); hstack ->Draw("hist,same"); allmc ->Draw("e2,same"); hist[iData]->Draw("ep,same"); // Adjust scale //---------------------------------------------------------------------------- Float_t theMax = GetMaximumIncludingErrors(hist[iData], xmin, xmax); Float_t theMaxMC = GetMaximumIncludingErrors(allmc, xmin, xmax); if (theMaxMC > theMax) theMax = theMaxMC; if (pad1->GetLogy()) { theMax = TMath::Power(10, TMath::Log10(theMax) + 2.7); hist[iData]->SetMinimum(0.05); } else theMax *= 1.55; hist[iData]->SetMaximum(theMax); // Legend //---------------------------------------------------------------------------- Double_t x0 = 0.720; Double_t y0 = 0.834; Double_t yoffset = 0.048; Double_t delta = yoffset + 0.001; Double_t ndelta = 0; Double_t YieldTop = Yield(hist[itt]) + Yield(hist[itW]); Double_t YieldVV = Yield(hist[iWZ]) + Yield(hist[iZZ]) + Yield(hist[iWg]); //Double_t YieldZJets = Yield(hist[iDY]) + Yield(hist[iDYtau]); Double_t YieldZJets = Yield(hist[iDY]) + Yield(hist[iDYtau]) + Yield(hist[iZgamma]); DrawLegend(x0 - 0.49, y0 - ndelta, hist[iData], Form(" data (%.0f)", Yield(hist[iData])), "lp", 0.03, 0.2, yoffset); ndelta += delta; DrawLegend(x0 - 0.49, y0 - ndelta, allmc, Form(" all (%.0f)", Yield(allmc)), "f", 0.03, 0.2, yoffset); ndelta += delta; DrawLegend(x0 - 0.49, y0 - ndelta, hist[iWW], Form(" WW (%.0f)", Yield(hist[iWW])), "f", 0.03, 0.2, yoffset); ndelta += delta; DrawLegend(x0 - 0.49, y0 - ndelta, hist[iWZ], Form(" VV (%.0f)", YieldVV), "f", 0.03, 0.2, yoffset); ndelta += delta; ndelta = 0; DrawLegend(x0 - 0.23, y0 - ndelta, hist[iDY], Form(" Z+jets (%.0f)", YieldZJets), "f", 0.03, 0.2, yoffset); ndelta += delta; DrawLegend(x0 - 0.23, y0 - ndelta, hist[iWj], Form(" W+jets (%.0f)", Yield(hist[iWj])), "f", 0.03, 0.2, yoffset); ndelta += delta; DrawLegend(x0 - 0.23, y0 - ndelta, hist[itt], Form(" top (%.0f)", YieldTop), "f", 0.03, 0.2, yoffset); ndelta += delta; //DrawLegend(x0 - 0.23, y0 - ndelta, hist[iH125], Form(" Higgs (%.0f)", Yield(hist[iH125])), "f", 0.03, 0.2, yoffset); ndelta += delta; DrawLegend(x0 - 0.23, y0 - ndelta, hist[iH125], Form(" ggH (%.0f)", Yield(hist[iH125])), "f", 0.03, 0.2, yoffset); ndelta += delta; // Additional titles //---------------------------------------------------------------------------- //TString channelLabel = "ee/#mu#mu/e#mu/#mue"; TString channelLabel = ""; //if (_channel == "EE") channelLabel = "ee"; //if (_channel == "MuMu") channelLabel = "#mu#mu"; //if (_channel == "EMu") channelLabel = "e#mu"; //if (_channel == "MuE") channelLabel = "#mue"; //if (_channel == "SF") channelLabel = "ee/#mu#mu"; //if (_channel == "OF") channelLabel = "e#mu/#mue"; if( _njet != 10) channelLabel += Form(" %d", _njet); if (_njet == 0) channelLabel += "-jets"; if (_njet == 1) channelLabel += "-jet"; if (_njet >= 2 && _njet!= 10) channelLabel += "-jets"; if ( _njet== 10) channelLabel += "SS 0+1 jets"; DrawTLatex(0.185, 0.975, 0.05, 13, channelLabel.Data()); DrawTLatex(0.940, 0.983, 0.05, 33, Form("L = %.1f fb^{-1}", _luminosity/1e3)); //---------------------------------------------------------------------------- // pad2 //---------------------------------------------------------------------------- pad2->cd(); TH1F* ratio = hist[iData]->Clone("ratio"); TH1F* uncertainty = allmc->Clone("uncertainty"); for (UInt_t ibin=1; ibin<=ratio->GetNbinsX(); ibin++) { Double_t mcValue = allmc->GetBinContent(ibin); Double_t mcError = allmc->GetBinError (ibin); Double_t dtValue = ratio->GetBinContent(ibin); Double_t dtError = ratio->GetBinError (ibin); Double_t ratioValue = (mcValue > 0) ? dtValue/mcValue : 0.0; Double_t ratioError = (mcValue > 0) ? dtError/mcValue : 0.0; Double_t uncertaintyError = (mcValue > 0) ? mcError/mcValue : 0.0; ratio->SetBinContent(ibin, ratioValue); ratio->SetBinError (ibin, ratioError); uncertainty->SetBinContent(ibin, 1.0); uncertainty->SetBinError (ibin, uncertaintyError); } TAxis* uaxis = (TAxis*)uncertainty->GetXaxis(); uaxis->SetRangeUser(xmin, xmax); uncertainty->Draw("e2"); ratio ->Draw("ep,same"); uncertainty->GetYaxis()->SetRangeUser(0, 2.5); // Save //---------------------------------------------------------------------------- pad2->cd(); SetAxis(uncertainty, hist[iData]->GetXaxis()->GetTitle(), "data / prediction", 0.10, 0.8); pad1->cd(); SetAxis(hist[iData], "", hist[iData]->GetYaxis()->GetTitle(), 0.05, 1.6); canvas->cd(); TString suffixLogy = (_setLogy) ? "_Log" : "_Lin"; canvas->SaveAs(Form("%s/%s%s.%s", _output.Data(), hname.Data(), suffixLogy.Data(), _format.Data())); }
void drawFigure4a(TString var="Njets") { gInterpreter->ExecuteMacro("GoodStyle.C"); gROOT->LoadMacro("tdrstyle.C"); setTDRStyle(); TString variable = "p_{T,max}^{#font[12]{l}}"; std::ostringstream filename, madname; filename<<"rootfiles/all_unfolding_"<<var<<".root"; TFile* file = new TFile(filename.str().c_str(), "read"); madname<<"hGenXs"<<var<<"_1"; std::cout<<madname.str().c_str()<<std::endl; TH1F* xsValue = (TH1F*)(file->Get("hComb_diff")->Clone("xsValue")); TH1F* xsValue_Madgraph = (TH1F*)(file->Get(madname.str().c_str())->Clone("xsValue_Madgraph")); TH1F* xsValue_MCnlo = (TH1F*)(file->Get("mcfm_tot")->Clone("xsValue_MCnlo")); // Set the data errors- I don't need this because I already have complete error in my plot //---------------------------------------------------------------------------- // Data cosmetics //---------------------------------------------------------------------------- xsValue->SetLineWidth(1); xsValue->SetMarkerSize(_msize); xsValue->SetMarkerStyle(kFullCircle); xsValue->SetMarkerColor(kBlack); xsValue->SetLineColor(kBlack); xsValue->SetFillStyle(1001); xsValue->SetFillColor(kWhite); // Madgraph cosmetics //---------------------------------------------------------------------------- xsValue_Madgraph->SetFillColor(kOrange); //xsValue_Madgraph->SetFillColor(kWhite); xsValue_Madgraph->SetFillStyle(1001); xsValue_Madgraph->SetLineColor(kOrange+7); xsValue_Madgraph->SetLineWidth(1); xsValue_Madgraph->SetMarkerColor(kOrange+7); xsValue_Madgraph->SetMarkerSize(_msize); xsValue_Madgraph->SetMarkerStyle(21); // MCNLO cosmetics //---------------------------------------------------------------------------- xsValue_MCnlo->SetFillColor(kAzure-9); //xsValue_MCnlo->SetFillColor(kWhite); xsValue_MCnlo->SetFillStyle(1001); xsValue_MCnlo->SetLineColor(kAzure); xsValue_MCnlo->SetLineWidth(1); xsValue_MCnlo->SetMarkerColor(kAzure); xsValue_MCnlo->SetMarkerSize(_msize); // xsValue_MCnlo->SetMarkerStyle(21); xsValue_MCnlo->SetMarkerStyle(24); // TCanvas * c1=new TCanvas("c1", "c1"); //xsValue_MCnlo->Draw("pey0"); // Set the canvas and pads //---------------------------------------------------------------------------- TCanvas* canvas = new TCanvas("wwxs", "wwxs", 600, 600); // TCanvas* canvas = new TCanvas("wwxs", "wwxs"); //defalut //TCanvas* canvas = new TCanvas("wwxs", "wwxs", 600, 850); // TPad* pad1 = new TPad("pad1", "pad1", 0, 0.55, 1, 1.000); //TPad* pad2 = new TPad("pad2", "pad2", 0, 0.39, 1, 0.552); //TPad* pad3 = new TPad("pad3", "pad3", 0, 0.23, 1, 0.392); TPad* pad1 = new TPad("pad1", "pad1", 0, 0.49, 1, 1.000); TPad* pad2 = new TPad("pad2", "pad2", 0, 0.33, 1, 0.492); TPad* pad3 = new TPad("pad3", "pad3", 0, 0, 1, 0.332); pad1->SetTopMargin(0.09); pad2->SetTopMargin(0); pad3->SetTopMargin(0); pad1->SetBottomMargin(0); pad2->SetBottomMargin(0); // pad3->SetBottomMargin(0.15); pad3->SetBottomMargin(0.45); pad1->SetLeftMargin(0.16); pad2->SetLeftMargin(0.16); pad3->SetLeftMargin(0.16); pad1->SetRightMargin(0.06); pad2->SetRightMargin(0.06); pad3->SetRightMargin(0.06); // pad1 //---------------------------------------------------------------------------- pad1->Draw(); pad1->cd(); pad1->SetLogy(); // Draw //---------------------------------------------------------------------------- AxisFonts(xsValue->GetXaxis(), variable + " (GeV)"); if (var=="Zpt") AxisFonts(xsValue->GetYaxis(), "d#sigma(WZ#rightarrow3l#nu)/dp_{T}^{Z}"); if (var=="LeadingJetPt") AxisFonts(xsValue->GetYaxis(), "d#sigma(WZ#rightarrow3l#nu)/dp_{T}^{LeadingJet}"); //TH1F* hpowError = (TH1F*)xsValue_Powheg->Clone(); // TH1F* hmadError = (TH1F*)xsValue_Madgraph->Clone(); //TH1F* hmcError = (TH1F*)xsValue_MCnlo->Clone(); xsValue ->Draw("pe"); xsValue_Madgraph->Draw("p,same"); xsValue_MCnlo ->Draw("p,same"); xsValue->SetMinimum(1.1e-4); // Legend //---------------------------------------------------------------------------- DrawLegend(0.718, 0.80, xsValue, " Data", "lp"); DrawLegend(0.718, 0.74, xsValue_Madgraph, " Madgraph", "flp"); DrawLegend(0.718, 0.68, xsValue_MCnlo, " MCFM", "flp"); // Draw text //---------------------------------------------------------------------------- DrawLatex(_cmsTextFont, 0.173, 0.935, 0.065, 11, "CMS"); DrawLatex(_extraTextFont, 0.268, 0.935, 0.035, 11, "Preliminary"); DrawLatex(_lumiTextFont, 0.940, 0.935, 0.050, 31, "19.6 fb^{-1} (8 TeV)"); // Prepare the ratios //---------------------------------------------------------------------------- TH1F* ratio_mad = xsValue_Madgraph->Clone("ratio"); TH1F* ratio_mcnlo = xsValue_Madgraph->Clone("ratio"); // TH1F* ratio_mcnlo = xsValue_MCnlo->Clone("ratio"); TH1F* hratio_mad = xsValue_Madgraph->Clone("ratio"); TH1F* hratio_mcnlo = xsValue_MCnlo->Clone("ratio"); TH1F* ratioErr = xsValue->Clone("ratio"); ratioErr->SetFillColor (kGray+2); ratioErr->SetFillStyle ( 3004); ratioErr->SetLineColor (kGray+2); ratioErr->SetMarkerColor(kGray+2); ratioErr->SetMarkerSize ( 0); // Set the bin content //---------------------------------------------------------------------------- for (UInt_t ibin=1; ibin<=ratio->GetNbinsX(); ibin++) { Double_t madValue = xsValue_Madgraph->GetBinContent(ibin); //Double_t madError = xsValue_Madgraph->GetBinError (ibin); Double_t mcnloValue = xsValue_MCnlo->GetBinContent(ibin); //Double_t mcnloError = xsValue_MCnlo->GetBinError (ibin); Double_t dataValue = xsValue->GetBinContent(ibin); Double_t dataError = xsValue->GetBinError(ibin); Double_t ratioValue_mad = (madValue > 0) ? madValue / dataValue : 0.0; //Double_t ratioError_mad = (madValue > 0) ? madError / dataValue : 0.0; Double_t ratioError_mad = madValue/pow(dataValue,2)*dataError; Double_t ratioValue_mcnlo = (mcnloValue > 0) ? mcnloValue / dataValue : 0.0; // Double_t ratioError_mcnlo = (mcnloValue > 0) ? mcnloError / dataValue : 0.0; Double_t ratioError_mcnlo = mcnloValue/pow(dataValue,2)*dataError; Double_t uncertaintyError = (dataValue > 0) ? dataError / dataValue : 0.0; ratio_mad ->SetBinContent(ibin, ratioValue_mad); hratio_mad->SetBinContent(ibin, ratioValue_mad); hratio_mad->SetBinError (ibin, ratioError_mad); ratio_mcnlo ->SetBinContent(ibin, ratioValue_mcnlo); hratio_mcnlo->SetBinContent(ibin, ratioValue_mcnlo); hratio_mcnlo->SetBinError (ibin, ratioError_mcnlo); ratioErr->SetBinContent(ibin, 1.0); ratioErr->SetBinError (ibin, uncertaintyError); //??? ovo nije bas jasno sto je } // AxisFontsRatio(ratioErr->GetYaxis(), "y", "Theory / Data"); //AxisFontsRatio(ratioErr->GetXaxis(), "x", variable + " (GeV)"); AxisFontsRatio(ratio_mad->GetYaxis(), "y", "Theory / Data"); //AxisFontsRatio(ratio_mad->GetXaxis(), "x", variable + " (GeV)"); AxisFontsRatio(ratio_mcnlo->GetYaxis(), "y", "Theory / Data"); if (var=="Zpt") AxisFontsRatio(ratio_mcnlo->GetXaxis(), "x", "p_{T}^{Z} (GeV)"); if (var=="LeadingJetPt") AxisFontsRatio(ratio_mcnlo->GetXaxis(), "x", "p_{T}^{LeadingJet} (GeV)"); ratio_mcnlo->SetFillColor(kAzure-9); //xsValue_MCnlo->SetFillColor(kWhite); ratio_mcnlo->SetFillStyle(1001); ratio_mcnlo->SetLineColor(kAzure); ratio_mcnlo->SetLineWidth(1); ratio_mcnlo->SetMarkerColor(kAzure); ratio_mcnlo->SetMarkerSize(_msize); // xsValue_MCnlo->SetMarkerStyle(21); ratio_mcnlo->SetMarkerStyle(24); // Draw pad2 //---------------------------------------------------------------------------- canvas->cd(); pad2->Draw(); pad2->cd(); //ratioErr ->Draw("e2"); ratio_mad ->Draw("pz"); hratio_mad->Draw("e2,same"); ratio_mad ->Draw("p, same"); ratio_mad->GetYaxis()->SetRangeUser(0.1, 2.3); pad2->Modified(); DrawLatex(43, 0.2, 0.79, 15.0, 11, "Madgraph+Pythia normalized to #sigma_{NLO}"); // Draw pad3 //---------------------------------------------------------------------------- canvas->cd(); pad3->Draw(); pad3->cd(); std::cout<<"Default option: "<<ratio_mcnlo->GetOption()<<std::endl; //ratioErr ->Draw("e2"); ratio_mcnlo->Draw("pz"); hratio_mcnlo->Draw("e2,same"); ratio_mcnlo ->Draw("pz, same"); ratio_mcnlo->GetYaxis()->SetRangeUser(0.1, 2.3); //ratio_mcnlo->GetYaxis()->SetRangeUser(0.0, 0.5); pad3->Modified(); DrawLatex(43, 0.2, 0.89, 15.0, 11, "MCFM"); // Save //---------------------------------------------------------------------------- pad1->cd(); pad1->GetFrame()->DrawClone(); pad2->cd(); pad2->GetFrame()->DrawClone(); pad3->cd(); pad3->GetFrame()->DrawClone(); canvas->cd(); std::ostringstream saveName, saveName2; saveName << "pdf/unfolded_"<<var<<".pdf"; saveName2 << "png/unfolded_"<<var<<".png"; canvas->SaveAs(saveName.str().c_str()); canvas->SaveAs(saveName2.str().c_str()); }
void CGraph::DrawGraph(CDC* pDC) { CString tickLabel; CWnd* graphWnd = pDC->GetWindow(); CRect graphRect; graphWnd->GetClientRect(&graphRect); maxHeight = graphRect.Height() - 20; //for frame window and status bar maxWidth = graphRect.Width() - 5; //for frame window //We will leave 5 pixels blank on all sides of the graph. So //top-left side of graph is at 5,5 and the bottom-right side of //graph is at ((maxHeight - 5), (maxWidth - 5)) //these settings are altered by axis labels and legends. //draw graph title CFont titleFont; titleFont.CreateFont(28, 0, 0, 0, 700, FALSE, FALSE, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_ROMAN,_T("Arial")); CFont* pOldFont = (CFont*) pDC->SelectObject(&titleFont); pDC->TextOut((maxWidth / 2) - ((graphTitle.GetLength() * 16) / 2), 10, graphTitle); pDC->SelectObject(pOldFont); if(graphType == 2) //pie { //since pie has not axis lines, set to full size minus 5 on each side //these are needed for legend to plot itself xAxisWidth = maxWidth - 10; yAxisHeight = maxHeight - 20; //10 buffer and 20 for title xApexPoint = 5; yApexPoint = maxHeight - 5; } else { //X-axis will be raised by 20 pixels for tick-labels //Y-axis will be shifted by (max(tick-label size) * 10) + label * 10 tickLabel.Format(_T("%d"), tickRange); //determine axis specifications //tick label offset is 4 (for the tick) + 6 (total 10) from axis line xApexPoint = 5 + (tickLabel.GetLength() * 8) + 10 + 30/*(axisYLabel.GetLength() * 8)*/ + 5; //allowing 8 pixels per char in tick label //y apex based on 5 + 15 (x label) + 4 (for the tick) + 4 (text below tick) + 12 (tick label) + 10 if(!xAxisAlign) //horizontal yApexPoint = (maxHeight - 5) - 45; //apex points are the cross section of axis lines else yApexPoint = (maxHeight - 5) - (xAxisLabelLength * 12) - 10; yAxisHeight = yApexPoint - 40; xAxisWidth = (maxWidth - 5) - xApexPoint; } //draw legend if(graphHasLegend) DrawLegend(pDC); if(graphType != 2) //pie { //draw axis lines DrawAxis(pDC); } //draw series data and labels DrawSeries(pDC); }
void Unfolded ( bool drawRatio = 1, int differential = 0, int nsel = 0, int ReBin = 1, TString XTitle = "p_{T,max}^{l} (GeV)", TString units = "", TString plotName = "data/XSLeadingPt_AN.root", TString outputName = "WW_LeadingPt_final", bool isLogY = false, double lumi = 19.5 ) { gInterpreter->ExecuteMacro("GoodStyle.C"); std::cout << "reading " << plotName << std::endl ; TFile* file = new TFile(plotName, "read"); //---- prepare the object that is making the plots //---- ---- ---- ---- ---- ---- ---- ---- ---- ---- std::cout << "setting up the plot object " << std::endl ; TH1F* xsValue = (TH1F*) xsValue->Clone(); TH1F* xsValue_Powheg = (TH1F*) xsValue_Powheg->Clone(); TH1F* xsValue_Madgraph = (TH1F*) xsValue_Madgraph->Clone(); TH1F* xsValue_MCnlo = (TH1F*) xsValue_MCnlo->Clone(); TH1F* systHisto = (TH1F*) systHisto->Clone(); TCanvas* canvas ; TPad *pad1, *pad2, *pad3, *pad4; if (drawRatio) { canvas = new TCanvas("wwxs", "wwxs", 600, 850); gStyle->SetOptStat(0); gStyle->SetOptTitle(0); canvas->SetHighLightColor(2); canvas->Range(0,0,1,1); canvas->SetFillColor(0); canvas->SetBorderMode(0); canvas->SetBorderSize(2); canvas->SetTickx(1); canvas->SetTicky(1); canvas->SetLeftMargin(0.16); canvas->SetRightMargin(0.02); canvas->SetTopMargin(0.05); canvas->SetBottomMargin(0.13); canvas->SetFrameFillStyle(0); canvas->SetFrameBorderMode(0); pad1 = new TPad("pad1", "pad1",0.01,0.55,0.99,0.99); pad1->Draw(); pad1->cd(); pad1->Range(-147.2973,-5.811723,960.8108,2.535539); pad1->SetFillColor(0); pad1->SetBorderMode(0); pad1->SetBorderSize(2); pad1->SetLogy(); pad1->SetTickx(1); pad1->SetTicky(1); pad1->SetLeftMargin(0.16); pad1->SetBottomMargin(0); pad1->SetFrameFillStyle(0); pad1->SetFrameBorderMode(0); pad1->SetFrameFillStyle(0); pad1->SetFrameBorderMode(0); } else { canvas = new TCanvas("wwxs", "wwxs", 550, 550); } if (drawRatio) pad1->cd(); std::cout << " now plot " << std::endl; //Plot Data xsValue->SetLineWidth(1); xsValue->SetMarkerSize(1.0); int NBins = xsValue->GetNbinsX(); for(int i=1; i <NBins; i++) { float err_stat = xsValue->GetBinError(i); float err_syst = systHisto->GetBinError(i); float err_total = sqrt(err_stat*err_stat + err_syst*err_syst); xsValue->SetBinError(i, err_total); } //-- Plot Powheg TH1F *hpowError = (TH1F*) xsValue_Powheg->Clone(); xsValue_Powheg->SetMarkerColor(kGreen+2); xsValue_Powheg->SetLineWidth(1); xsValue_Powheg->SetLineColor(kGreen+2); xsValue_Powheg->SetMarkerStyle(22); xsValue_Powheg->SetMarkerSize(1.2); hpowError->SetLineWidth(0); hpowError->SetMarkerSize ( 0); hpowError->SetFillColor (kGreen-7); //-- Plot Madgraph TH1F *hmadError = (TH1F*) xsValue_Madgraph->Clone(); xsValue_Madgraph->SetMarkerColor(kMagenta); xsValue_Madgraph->SetLineWidth(1); xsValue_Madgraph->SetLineStyle(1); xsValue_Madgraph->SetMarkerStyle(21); xsValue_Madgraph->SetMarkerSize(1.0); hmadError->SetLineWidth(0); hmadError->SetMarkerSize ( 0); hmadError->SetFillColor (kMagenta-10); //-- Plot MCNLO TH1F *hmcError = (TH1F*) xsValue_MCnlo->Clone(); xsValue_MCnlo->SetMarkerColor(kRed); xsValue_MCnlo->SetLineColor(kRed); xsValue_MCnlo->SetLineWidth(1); xsValue_MCnlo->SetLineStyle(1); xsValue_MCnlo->SetMarkerStyle(24); xsValue_MCnlo->SetMarkerSize(1.0); hmcError->SetLineWidth(0); hmcError->SetMarkerSize ( 0); hmcError->SetFillColor (kOrange); //-- Plot Data xsValue->SetMarkerStyle(kFullCircle); if (differential == 0) AxisFonts (xsValue->GetYaxis(), "#frac{1}{#sigma} d#sigma(WW#rightarrow#mu#nue#nu + < 1 jet)/dp_{T,max}^{l}"); if (differential == 1) AxisFonts (xsValue->GetYaxis(), "#frac{1}{#sigma} d#sigma(WW#rightarrow#mu#nue#nu + < 1 jet)/dp_{T}(ll)}"); if (differential == 2) AxisFonts (xsValue->GetYaxis(), "#frac{1}{#sigma} d#sigma(WW#rightarrow#mu#nue#nu + < 1 jet)/dm_{#font[12]{ll}}"); if (differential == 3) AxisFonts (xsValue->GetYaxis(), "#frac{1}{#sigma} d#sigma(WW#rightarrow#mu#nue#nu + < 1 jet)/d#Delta#phi_{ll}"); // if (differential == 0) AxisFonts (xsValue->GetYaxis(), "#frac{1}{#sigma} #frac{d#sigma}{dp_{T,max}^{l}}"); // if (differential == 1) AxisFonts (xsValue->GetYaxis(), "#frac{1}{#sigma} #frac{d#sigma}{dp_{T}(ll)}"); // if (differential == 2) AxisFonts (xsValue->GetYaxis(), "#frac{1}{#sigma} #frac{d#sigma}{dm_{#font[12]{ll}}}"); // if (differential == 3) AxisFonts (xsValue->GetYaxis(), "#frac{1}{#sigma} #frac{d#sigma}{d#Delta#phi_{ll}}"); AxisFonts (xsValue->GetXaxis(), XTitle); xsValue->Draw("p"); hmadError->Draw("e2,same"); xsValue_Madgraph->Draw("pe1,same"); hmcError->Draw("e2,same"); xsValue_MCnlo->Draw("pe1,same"); hpowError->Draw("e2,same"); xsValue_Powheg->Draw("pe1,same"); //systHisto->Draw("e2, same"); xsValue->Draw("pe1,same"); // Legend //---------------------------------------------------------------------------- DrawLegend (0.65, 0.85, xsValue, "Data", "P"); DrawLegend (0.65, 0.80, hpowError, "", "F"); DrawLegend (0.65, 0.80, xsValue_Madgraph, "Madgraph", "PL"); DrawLegend (0.65, 0.75, hmadError, "", "F"); DrawLegend (0.65, 0.75, xsValue_MCnlo, "MCNLO", "LP"); DrawLegend (0.65, 0.70, hmcError, "", "F"); DrawLegend (0.65, 0.70, xsValue_Powheg, "Powheg", "PL"); canvas->GetFrame()->DrawClone(); // Draw text //---------------------------------------------------------------------------- TLatex * tex = new TLatex(0.17,0.96,"CMS #sqrt{s} = 8 TeV 19.4 fb^{-1}"); tex->SetNDC(); tex->SetTextAlign(12); tex->SetTextFont(42); tex->SetTextSize(0.07); tex->SetLineWidth(2); tex->Draw(); // TLatex * CMSLabel = new TLatex (0.18, 0.96, "#bf{CMS}"); // CMSLabel->SetNDC (); // CMSLabel->SetTextAlign (10); // CMSLabel->SetTextFont (42); // CMSLabel->SetTextSize (_tsize); // CMSLabel->Draw ("same") ; // // // TLatex * _lumiLabel = new TLatex (0.95, 0.96, "19.4fb#lower[0.3]{^{-1}} (8 TeV)"); // _lumiLabel->SetNDC (); // _lumiLabel->SetTextAlign (30); // _lumiLabel->SetTextFont (42); // _lumiLabel->SetTextSize (_tsize); // _lumiLabel->Draw ("same") ; // Draw also ratio //---------------------------------------------------------------------------- if (drawRatio) { //---- prepare the distributions TH1F* ratio_pow = xsValue_Powheg->Clone("ratio"); TH1F* ratio_mad = xsValue_Madgraph->Clone("ratio"); TH1F* ratio_mcnlo = xsValue_MCnlo->Clone("ratio"); TH1F* hratio_pow = xsValue_Powheg->Clone("ratio"); TH1F* hratio_mad = xsValue_Madgraph->Clone("ratio"); TH1F* hratio_mcnlo = xsValue_MCnlo->Clone("ratio"); TH1F* ratioErr = xsValue->Clone("ratio"); for (UInt_t ibin=1; ibin<=ratio->GetNbinsX(); ibin++) { Double_t powValue = xsValue_Powheg->GetBinContent(ibin); Double_t powError = xsValue_Powheg->GetBinError (ibin); Double_t madValue = xsValue_Madgraph->GetBinContent(ibin); Double_t madError = xsValue_Madgraph->GetBinError (ibin); Double_t mcnloValue = xsValue_MCnlo->GetBinContent(ibin); Double_t mcnloError = xsValue_MCnlo->GetBinError (ibin); Double_t dataValue = xsValue->GetBinContent(ibin); Double_t statError = xsValue->GetBinError (ibin); Double_t systError = systHisto->GetBinError(ibin); Double_t dataError = systError; Double_t ratioValue_pow = (powValue > 0) ? powValue/dataValue : 0.0; Double_t ratioError_pow = (powValue > 0) ? powError / dataValue : 0.0; Double_t ratioValue_mad = (madValue > 0) ? madValue/dataValue : 0.0; Double_t ratioError_mad = (madValue > 0) ? madError/dataValue : 0.0; Double_t ratioValue_mcnlo = (mcnloValue > 0) ? mcnloValue/dataValue : 0.0; Double_t ratioError_mcnlo = (mcnloValue > 0) ? mcnloError/dataValue : 0.0; Double_t uncertaintyError = (dataValue > 0) ? dataError/dataValue : 0.0; //dataError/dataValue ratio_pow->SetBinContent(ibin, ratioValue_pow); hratio_pow->SetBinContent(ibin, ratioValue_pow); hratio_pow->SetBinError (ibin, ratioError_pow); ratio_mad->SetBinContent(ibin, ratioValue_mad); hratio_mad->SetBinContent(ibin, ratioValue_mad); hratio_mad->SetBinError (ibin, ratioError_mad); ratio_mcnlo->SetBinContent(ibin, ratioValue_mcnlo); hratio_mcnlo->SetBinContent(ibin, ratioValue_mcnlo); hratio_mcnlo->SetBinError (ibin, ratioError_mcnlo); ratioErr->SetBinContent(ibin, 1.0); ratioErr->SetBinError (ibin, uncertaintyError); } ratioErr->SetTitle(""); ratioErr->SetFillColor (kGray+2); ratioErr->SetFillStyle ( 3004); // ratioErr->SetFillStyle ( 3345); ratioErr->SetLineColor (kGray+2); ratioErr->SetMarkerColor(kGray+2); ratioErr->SetMarkerSize ( 0); //---- now draw canvas->cd(); pad2 = new TPad("pad2", "pad2",0.01,0.39,0.99,0.55); pad2->Draw(); pad2->cd(); pad2->Range(-147.2973,0.2,960.8108,1.8); pad2->SetFillColor(0); pad2->SetBorderMode(0); pad2->SetBorderSize(2); pad2->SetTickx(1); pad2->SetTicky(1); pad2->SetLeftMargin(0.16); pad2->SetTopMargin(0); pad2->SetBottomMargin(0); pad2->SetFrameFillStyle(0); pad2->SetFrameBorderMode(0); pad2->SetFrameFillStyle(0); pad2->SetFrameBorderMode(0); ratioErr ->Draw("e2"); ratio_mad ->SetLineColor(kMagenta); ratio_mad ->SetMarkerSize(1.0); ratio_mad ->SetLineWidth(1); ratio_mad ->SetMarkerStyle(21); hratio_mad ->SetLineWidth(0); hratio_mad ->SetMarkerSize ( 0); hratio_mad ->SetFillColor (kMagenta-10); hratio_mad ->SetFillStyle (1001); hratio_mad ->Draw("e2,same"); ratio_mad ->Draw("e1p,same"); AxisFontsRatio (ratioErr->GetYaxis(), "y", "Theory/data"); AxisFontsRatio (ratioErr->GetXaxis(), "x", XTitle); ratioErr->Draw("sameaxis"); ratioErr->GetYaxis()->SetRangeUser(0.4, 1.6); pad2->Modified(); TLatex* tex_mad = new TLatex(0.2,0.1,"Madgraph+Pythia, normalized to #sigma_{NNLO}"); tex_mad->SetNDC(); tex_mad->SetTextAlign(12); tex_mad->SetTextFont(42); tex_mad->SetTextSize(0.1); tex_mad->SetLineWidth(2); tex_mad->Draw(); canvas->cd(); pad3 = new TPad("pad3", "pad3",0.01,0.23,0.99,0.39); pad3->Draw(); pad3->cd(); pad3->Range(-147.2973,0.2,960.8108,1.8); pad3->SetFillColor(0); pad3->SetBorderMode(0); pad3->SetBorderSize(2); pad3->SetTickx(1); pad3->SetTicky(1); pad3->SetLeftMargin(0.16); pad3->SetTopMargin(0); pad3->SetBottomMargin(0); pad3->SetFrameFillStyle(0); pad3->SetFrameBorderMode(0); pad3->SetFrameFillStyle(0); pad3->SetFrameBorderMode(0); ratioErr ->Draw("e2"); ratio_mcnlo ->SetLineColor(kRed); ratio_mcnlo ->SetMarkerSize(1.0); ratio_mcnlo ->SetLineWidth(1); ratio_mcnlo ->SetMarkerStyle(24); hratio_mcnlo ->SetLineWidth(0); hratio_mcnlo ->SetMarkerSize ( 0); hratio_mcnlo ->SetFillColor (kOrange); hratio_mcnlo ->SetFillStyle (1001); hratio_mcnlo ->Draw("e2,same"); ratio_mcnlo ->Draw("ep,same"); // AxisFontsRatio (ratioErr->GetYaxis(), "y", "Theory/data"); // AxisFontsRatio (ratioErr->GetXaxis(), "x", XTitle); ratioErr->Draw("sameaxis"); ratioErr->GetYaxis()->SetRangeUser(0.4, 1.6); pad3->Modified(); TLatex* tex_mcnlo = new TLatex(0.2,0.1,"MC@NLO+Herwig, normalized to #sigma_{NNLO}"); tex_mcnlo->SetNDC(); tex_mcnlo->SetTextAlign(12); tex_mcnlo->SetTextFont(42); tex_mcnlo->SetTextSize(0.1); tex_mcnlo->SetLineWidth(2); tex_mcnlo->Draw(); canvas->cd(); pad4 = new TPad("pad4", "pad4",0.01,0.01,0.99,0.23); pad4->Draw(); pad4->cd(); pad4->Range(-147.2973,-0.4857143,960.8108,1.8); pad4->SetFillColor(0); pad4->SetBorderMode(0); pad4->SetBorderSize(2); pad4->SetTickx(1); pad4->SetTicky(1); pad4->SetLeftMargin(0.16); pad4->SetTopMargin(0); pad4->SetBottomMargin(0.3); pad4->SetFrameFillStyle(0); pad4->SetFrameBorderMode(0); pad4->SetFrameFillStyle(0); pad4->SetFrameBorderMode(0); ratioErr ->Draw("e2"); ratio_pow ->SetLineColor(kGreen+2); ratio_pow ->SetMarkerSize(1.2); ratio_pow ->SetLineWidth(1); ratio_pow ->SetMarkerStyle(22); hratio_pow ->SetLineWidth(0); hratio_pow ->SetMarkerSize ( 0); hratio_pow ->SetFillColor (kGreen-7); hratio_pow ->SetFillStyle (1001); hratio_pow ->Draw("e2,same"); ratio_pow ->Draw("e1p,same"); // AxisFontsRatio (ratioErr->GetYaxis(), "y", "Theory/data", 1); // AxisFontsRatio (ratioErr->GetXaxis(), "x", XTitle); ratioErr->Draw("sameaxis"); ratioErr->GetYaxis()->SetRangeUser(0.4, 1.6); pad4->Modified(); TLatex* tex_pow = new TLatex(0.2,0.39,"Powheg+Pythia, normalized to #sigma_{NNLO}"); tex_pow->SetNDC(); tex_pow->SetTextAlign(12); tex_pow->SetTextFont(42); tex_pow->SetTextSize(0.1); tex_pow->SetLineWidth(2); tex_pow->Draw(); canvas->cd(); } }
void Draw(const int &rebin=1) { Color_t _sampleColor[nSamples]; //_sampleColor[iHWW ] = kRed+1; //_sampleColor[iWW ] = kAzure-9; //_sampleColor[iZJets] = kGreen+2; //_sampleColor[iZTau] = kGreen+2; //_sampleColor[iTop ] = kYellow; //_sampleColor[iWZ ] = kAzure-2; //_sampleColor[iWJets] = kGray+1; //_sampleColor[iWJets] = kViolet-9; //_sampleColor[iWJets] = kCyan; _sampleColor[itH ] = kRed; _sampleColor[iWZ ] = kAzure-9; _sampleColor[iZZ ] = kAzure-5; _sampleColor[iWW ] = kAzure-1; _sampleColor[itt ] = kGray; _sampleColor[ittw ] = kOrange+7; _sampleColor[ittz ] = kOrange+1; _sampleColor[iwww ] = kSpring+9; _sampleColor[iwwz ] = kSpring+3; _sampleColor[iwzz ] = kSpring-7; _sampleColor[idyl ] = kViolet-1; _sampleColor[idy ] = kViolet-1; //setUpStyle(); if(!gPad) new TCanvas(); THStack* hstack = new THStack(); for (int i=0; i<nSamples; i++) { // in case the user doesn't set it if( !_hist[i] ) continue; _hist[i]->Rebin(rebin); _hist[i]->SetLineColor(_sampleColor[i]); // signal gets overlaid if (i == itH) continue; _hist[i]->SetFillColor(_sampleColor[i]); _hist[i]->SetFillStyle(1001); hstack->Add(_hist[i]); } if(_hist[itH]) _hist[itH]->SetLineWidth(3); if(_data) _data->Rebin(rebin); if(_data) _data->SetLineColor (kBlack); if(_data) _data->SetMarkerStyle(kFullCircle); if(_nostack) { for(int ihist=0;ihist<(int)_hist.size();ihist++) { _hist[ihist]->SetFillStyle(0); _hist[ihist]->SetLineWidth(2); } hstack->Draw("hist,nostack"); if(_hist[itH]) _hist[itH]->Draw("hist,same"); if(_data) _data->Draw("ep,same"); } else { hstack->Draw("hist"); if(_hist[itH]) _hist[itH]->Draw("hist,same"); if(_data) _data->Draw("ep,same"); } //hstack->SetTitle("CMS preliminary"); Float_t theMax = hstack->GetMaximum(); Float_t theMin = hstack->GetMinimum(); theMax = 1.0; //Float_t theMin = hstack->GetMinimum(); if (_hist[itH]) { if (_hist[itH]->GetMaximum() > theMax) theMax = _hist[itH]->GetMaximum(); if (_hist[itH]->GetMinimum() < theMin) theMin = _hist[itH]->GetMinimum(); } if (_data) { Float_t dataMax = GetMaximumIncludingErrors(_data); if (dataMax > theMax) theMax = dataMax; } if (gPad->GetLogy()) { hstack->SetMaximum(500 * theMax); hstack->SetMinimum(0.05); } else { hstack->SetMaximum(1.55 * theMax); } if(_breakdown) { THStackAxisFonts(hstack, "y", "entries"); hstack->GetHistogram()->LabelsOption("v"); } else { THStackAxisFonts(hstack, "x", TString::Format("%s [%s]",_xLabel.Data(),_units.Data())); if(_units.Sizeof() == 1) { THStackAxisFonts(hstack, "x", _xLabel.Data()); THStackAxisFonts(hstack, "y", "entries"); } else { THStackAxisFonts(hstack, "x", TString::Format("%s [%s]",_xLabel.Data(),_units.Data())); THStackAxisFonts(hstack, "y", TString::Format("entries / %.0f %s", _hist[iWZ]->GetBinWidth(0),_units.Data())); } } // total mess to get it nice, should be redone size_t j=0; TString higgsLabel = " tH x 100"; //if(_mass != 0) higgsLabel.Form(" m_{H}=%d",_mass); if(_data ) { DrawLegend(xPos[j], 0.84 - yOff[j]*_yoffset, _data, " data", "lp"); j++; } if(_hist[itH ]) { DrawLegend(xPos[j], 0.84 - yOff[j]*_yoffset, _hist[itH ], higgsLabel, "l" ); j++; } if(_hist[iWZ ]) { DrawLegend(xPos[j], 0.84 - yOff[j]*_yoffset, _hist[iWZ ], " WZ", "f" ); j++; } if(_hist[iZZ ]) { DrawLegend(xPos[j], 0.84 - yOff[j]*_yoffset, _hist[iZZ ], " ZZ", "f" ); j++; } if(_hist[iWW ]) { DrawLegend(xPos[j], 0.84 - yOff[j]*_yoffset, _hist[iWW ], " WW", "f" ); j++; } if(_hist[itt ]) { DrawLegend(xPos[j], 0.84 - yOff[j]*_yoffset, _hist[itt ], " tt", "f" ); j++; } if(_hist[ittw ]) { DrawLegend(xPos[j], 0.84 - yOff[j]*_yoffset, _hist[ittw ], " ttW", "f" ); j++; } if(_hist[ittz ]) { DrawLegend(xPos[j], 0.84 - yOff[j]*_yoffset, _hist[ittz ], " ttZ", "f" ); j++; } if(_hist[iwww ]) { DrawLegend(xPos[j], 0.84 - yOff[j]*_yoffset, _hist[iwww ], " WWW", "f" ); j++; } if(_hist[iwwz ]) { DrawLegend(xPos[j], 0.84 - yOff[j]*_yoffset, _hist[iwwz ], " WWZ", "f" ); j++; } if(_hist[iwzz ]) { DrawLegend(xPos[j], 0.84 - yOff[j]*_yoffset, _hist[iwzz ], " WZZ", "f" ); j++; } if(_hist[idy ]) { DrawLegend(xPos[j], 0.84 - yOff[j]*_yoffset, _hist[idy ], " Drell-Yan","f" ); j++; } //TLatex* luminosity = new TLatex(0.9, 0.815, TString::Format("L = %.1f fb^{-1}",_lumi)); TLatex* luminosity = new TLatex(0.9, 0.95, TString::Format("CMS Preliminary \\sqrt{s} = 8 TeV, L = %.1f fb^{-1}",_lumi)); luminosity->SetNDC(); luminosity->SetTextAlign(32); luminosity->SetTextFont(42); luminosity->SetTextSize(_tsize); luminosity->Draw("same"); // if(_extraLabel) _extraLabel->Draw("same"); // return hstack->GetHistogram(); }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // root -l computeDrellYanPtllWeight.C+ // root -l -b -q computeDrellYanPtllWeight.C+ // //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ void computeDrellYanPtllWeight(TString fname = "h_pt2l_mm") { gInterpreter->ExecuteMacro("PaperStyle.C"); TFile* file = TFile::Open("figures/Control/01_DY/" + fname + ".root"); TH1D* ratio = (TH1D*)file->Get("ratio"); // Draw the ratio //---------------------------------------------------------------------------- TCanvas* c1 = new TCanvas("c1", "c1"); ratio->SetMinimum(0.85); ratio->SetMaximum(1.20); ratio->Draw("ep"); TString ytitle = Form("data / MC ratio / %.0f GeV", ratio->GetBinWidth(0)); SetAxis(ratio, ratio->GetXaxis()->GetTitle(), ytitle, 1.7, 1.8); // Draw the old function //---------------------------------------------------------------------------- TF1* fOld = new TF1("fOld", "[3]*(0.95 - [0]*TMath::Erf((x-[1])/[2]))", 0, 90); fOld->SetLineColor (kGreen+2); fOld->SetMarkerColor(kGreen+2); // https://github.com/latinos/PlotsConfigurations/blob/master/Configurations/ggH/nuisances_iteos.py#L969-L977 fOld->SetParameter(0, 0.1); fOld->SetParameter(1, 14.0); fOld->SetParameter(2, 8.8); fOld->SetParameter(3, 1.08683); fOld->Draw("same"); // Draw the old function error band //------------------------------------------------------------------------------ if (errorband) { TF1* fOld_down = (TF1*)fOld->Clone("fOld_down"); TF1* fOld_up = (TF1*)fOld->Clone("fOld_up"); fOld_down->SetParameter(0, 13.6); fOld_down->SetParameter(1, 8.6); fOld_up->SetParameter(0, 14.4); fOld_up->SetParameter(1, 9.0); fOld_down->Draw("same"); fOld_up ->Draw("same"); } // Update the fit parameters of the old function // // 1 p0 6.85257e-02 2.99341e-01 1.42129e-05 4.16760e-04 // 2 p1 1.24518e+01 4.76906e+01 3.55312e-03 6.41625e-07 // 3 p2 5.40627e+00 7.83907e+01 6.49546e-03 -1.96376e-06 // 4 p3 1.05396e+00 3.48880e-01 1.58779e-05 -3.97115e-05 // //---------------------------------------------------------------------------- TF1* fNew = new TF1("fNew", "[3]*(0.95 - [0]*TMath::Erf((x-[1])/[2]))", 0, 90); fNew->SetLineColor (kRed+1); fNew->SetMarkerColor(kRed+1); fNew->SetParameter(0, 0.1); fNew->SetParameter(1, 10); fNew->SetParameter(2, 1); fNew->SetParameter(3, 1); ratio->Fit(fNew, "mlr0"); fNew->Draw("same"); // Draw the updated error band //------------------------------------------------------------------------------ if (errorband) { TF1* fNew_down = (TF1*)fNew->Clone("fNew_down"); TF1* fNew_up = (TF1*)fNew->Clone("fNew_up"); fNew_down->SetParameter(0, 0.97 * fNew->GetParameter(0)); fNew_down->SetParameter(1, 0.97 * fNew->GetParameter(1)); fNew_up->SetParameter(0, 1.03 * fNew->GetParameter(0)); fNew_up->SetParameter(1, 1.03 * fNew->GetParameter(1)); fNew_down->Draw("same"); fNew_up ->Draw("same"); } // Fit Lorenzo's function // // 1 p0 1.17864e-01 7.44869e-01 1.03478e-05 1.79528e-03 // 2 p1 1.34231e+01 6.10789e+01 2.78074e-03 6.38697e-06 // 3 p2 9.76801e+00 1.03947e+02 5.51661e-03 -2.28998e-06 // 4 p3 1.01367e+00 6.56154e-01 1.29644e-05 -1.36428e-04 // 5 p4 2.50141e-03 2.62347e-02 1.53669e-07 -1.11290e-01 // 6 p5 1.10637e-05 1.42769e-04 1.32442e-09 1.17953e+01 // //---------------------------------------------------------------------------- TF1* fLo = new TF1("fLo", "([3] + [4]*x - [5]*x*x) * (0.95 - [0]*TMath::Erf((x-[1])/[2]))", 0, 150); fLo->SetLineColor (kBlue); fLo->SetMarkerColor(kBlue); fLo->SetParameter(0, 0.131835); fLo->SetParameter(1, 14.1972); fLo->SetParameter(2, 10.1525); fLo->SetParameter(3, 0.876979); fLo->SetParameter(4, 4.11598e-03); fLo->SetParameter(5, 2.35520e-05); ratio->Fit(fLo, "mlr0"); // Get the point where the first derivative is closest to zero // // fLo = 0.9608 and d(fLo)/d(ptll) = -0.000110 for ptll = 119 GeV // //---------------------------------------------------------------------------- float smallest_derivative_value = 999; float smallest_derivative_x = 999; for (int x=90; x<120; x++) { if (fLo->Derivative(x) < smallest_derivative_value) { smallest_derivative_value = fLo->Derivative(x); smallest_derivative_x = x; } } printf("\n fLo = %.4f and d(fLo)/d(ptll) = %f for ptll = %.0f GeV\n\n", fLo->Eval(smallest_derivative_x), fLo->Derivative(smallest_derivative_x), smallest_derivative_x); // Draw Lorenzo's function in two ranges //---------------------------------------------------------------------------- fLo->SetRange(0, smallest_derivative_x); fLo->Draw("same"); TF1* fHi = new TF1("fHi", "[0]", smallest_derivative_x, 150); fHi->SetLineColor (kBlue); fHi->SetMarkerColor(kBlue); fHi->SetParameter(0, fLo->Eval(smallest_derivative_x)); fHi->Draw("same"); // Legend //---------------------------------------------------------------------------- DrawLegend(0.69, 0.83, (TObject*)fOld, " old fit"); DrawLegend(0.69, 0.77, (TObject*)fNew, " new fit"); DrawLegend(0.69, 0.71, (TObject*)fLo, " Lorenzo's fit"); // Save //---------------------------------------------------------------------------- ratio->Draw("ep,same"); c1->SaveAs(fname + "_ratio_fit.png"); }
//------------------------------------------------------------------------------ //Subtraction //------------------------------------------------------------------------------ void Subtraction(TString hname, TString xtitle, Int_t ngroup = -1, Int_t precision = 1, TString units = "NULL", Double_t xmin = -999, Double_t xmax = 999, Bool_t moveOverflow = true) { TCanvas* canvas = new TCanvas(hname, hname, 800, 800); TPad* pad1 = new TPad("pad1", "pad1", 0, 0.0, 1, 1.0); pad1->SetTopMargin (0.08); //pad1->SetBottomMargin(0.02); pad1->Draw(); //---------------------------------------------------------------------------- // pad1 //---------------------------------------------------------------------------- pad1->cd(); pad1->SetLogy(_setLogy); TH1F* hist[nProcesses]; for (UInt_t ip=0; ip<nProcesses; ip++) { hist[ip] = (TH1F*)input[ip]->Get(hname); hist[ip]->SetName(hname + process[ip]); if (moveOverflow) MoveOverflowBins (hist[ip], xmin, xmax); else ZeroOutOfRangeBins(hist[ip], xmin, xmax); if (ngroup > 0) hist[ip]->Rebin(ngroup); if (_dataDriven && ip == iWW) hist[ip]->Scale(WWScale[_njet]); if (_dataDriven && ip == iDY) hist[ip]->Scale(ZjScale[_njet]); if (_dataDriven && ip == iDYtau) hist[ip]->Scale(ZjScale[_njet]); } // Data subtraction for Top background estimation //---------------------------------------------------------------------------- TH1F* subData = (TH1F*)hist[iData]->Clone("subData"); for (UInt_t ip=0; ip<nProcesses; ip++) { if (ip == itt) continue; if (ip == itW) continue; if (ip == iData ) continue; subData->Add(hist[ip],-1); } subData->SetLineColor(kRed+1); Double_t subData_Yield = subData->Integral(); //subData->SetLineColor(); // Top background //---------------------------------------------------------------------------- TH1F* Top = (TH1F*)hist[itt]->Clone("Top"); Top->Add(hist[itW]); Top->SetLineColor(kBlue+1); Double_t Top_Yield = Top->Integral(); // Axis labels //---------------------------------------------------------------------------- TAxis* xaxis = subData->GetXaxis(); TAxis* yaxis = subData->GetYaxis(); TString ytitle = Form("entries / %s.%df", "%", precision); xaxis->SetTitle(xtitle); yaxis->SetTitle(Form(ytitle.Data(), subData->GetBinWidth(0))); yaxis->SetTitleOffset(1.6); if (!units.Contains("NULL")) { xaxis->SetTitle(Form("%s [%s]", xaxis->GetTitle(), units.Data())); yaxis->SetTitle(Form("%s %s", yaxis->GetTitle(), units.Data())); } // Draw //---------------------------------------------------------------------------- xaxis->SetRangeUser(xmin, xmax); subData->Draw("hist"); Top->Draw("hist same"); // Adjust scale //---------------------------------------------------------------------------- subData->SetMinimum(0.0); Float_t theMax = GetMaximumIncludingErrors(subData, xmin, xmax); Float_t theMaxMC = GetMaximumIncludingErrors(Top, xmin, xmax); if (theMaxMC > theMax) theMax = theMaxMC; if (pad1->GetLogy()) { theMax = TMath::Power(10, TMath::Log10(theMax) + 2.7); subData->SetMinimum(0.05); } else theMax *= 1.55; subData->SetMaximum(theMax); // Legend //---------------------------------------------------------------------------- Double_t x0 = 0.720; Double_t y0 = 0.834; Double_t yoffset = 0.048; Double_t delta = yoffset + 0.001; Double_t ndelta = 0; DrawLegend(x0 - 0.49, y0 - ndelta, subData, Form(" Data Subtraction (MC without Top) (%.0f)", Yield(subData)), "l", 0.03, 0.2, yoffset); ndelta += delta; DrawLegend(x0 - 0.49, y0 - ndelta, Top, Form(" Top (%.0f)", Yield(Top)), "l", 0.03, 0.2, yoffset); ndelta += delta; // Additional titles //---------------------------------------------------------------------------- //TString channelLabel = "ee/#mu#mu/e#mu/#mue"; TString channelLabel = ""; //if (_channel == "EE") channelLabel = "ee"; //if (_channel == "MuMu") channelLabel = "#mu#mu"; //if (_channel == "EMu") channelLabel = "e#mu"; //if (_channel == "MuE") channelLabel = "#mue"; //if (_channel == "SF") channelLabel = "ee/#mu#mu"; //if (_channel == "OF") channelLabel = "e#mu/#mue"; channelLabel += Form(" %d", _njet); if (_njet == 0) channelLabel += "-jets"; if (_njet == 1) channelLabel += "-jet"; if (_njet >= 2) channelLabel += "-jets"; DrawTLatex(0.185, 0.975, 0.05, 13, channelLabel.Data(),""); DrawTLatex(0.940, 0.983, 0.05, 33, Form("L = %.1f fb^{-1}", _luminosity/1e3),""); if (Top_Yield!=0){ cout << "subData_Yield = "<<subData_Yield<<", Top_Yield = "<<Top_Yield<<", Ratio = "<< subData_Yield/Top_Yield <<endl; TLatex *tex3 = new TLatex(0.250, 0.75, "Scale Factor"); tex3->SetNDC(); tex3->SetTextSize(0.035); tex3->Draw(); TLatex *tex4 = new TLatex(0.250, 0.7, Form("%.0f / %.0f = %3.3f",subData_Yield ,Top_Yield ,subData_Yield/Top_Yield)); tex4->SetNDC(); tex4->SetTextSize(0.035); tex4->Draw(); } // Save //---------------------------------------------------------------------------- pad1->cd(); //SetAxis(subData, "", subData->GetYaxis()->GetTitle(), 0.05, 1.6); canvas->cd(); TString suffixLogy = (_setLogy) ? "_Log" : "_Lin"; canvas->SaveAs(Form("%s/%s%s_sub.%s", _output.Data(), hname.Data(), suffixLogy.Data(), _format.Data())); }
void GainPlot() { gROOT->Reset(); setTDRStyle(); gStyle->SetPadTopMargin (0.05); gStyle->SetPadBottomMargin(0.10); gStyle->SetPadRightMargin (0.18); gStyle->SetPadLeftMargin (0.13); gStyle->SetTitleSize(0.04, "XYZ"); gStyle->SetTitleXOffset(1.1); gStyle->SetTitleYOffset(1.35); gStyle->SetPalette(1); gStyle->SetCanvasColor(0); gStyle->SetBarOffset(0); unsigned int tree_Index; unsigned int tree_DetId; unsigned char tree_APVId; unsigned char tree_SubDet; float tree_x; float tree_y; float tree_z; float tree_Eta; float tree_R; float tree_Phi; float tree_Thickness; float tree_FitMPV; float tree_FitMPVErr; float tree_FitWidth; float tree_FitWidthErr; float tree_FitChi2NDF; double tree_Gain; double tree_PrevGain; double tree_NEntries; TFile* f1 = new TFile("file:../Gains_Tree.root"); TTree *t1 = (TTree*)GetObjectFromPath(f1,"SiStripCalib/APVGain"); t1->SetBranchAddress("Index" ,&tree_Index ); t1->SetBranchAddress("DetId" ,&tree_DetId ); t1->SetBranchAddress("APVId" ,&tree_APVId ); t1->SetBranchAddress("SubDet" ,&tree_SubDet ); t1->SetBranchAddress("x" ,&tree_x ); t1->SetBranchAddress("y" ,&tree_y ); t1->SetBranchAddress("z" ,&tree_z ); t1->SetBranchAddress("Eta" ,&tree_Eta ); t1->SetBranchAddress("R" ,&tree_R ); t1->SetBranchAddress("Phi" ,&tree_Phi ); t1->SetBranchAddress("Thickness" ,&tree_Thickness ); t1->SetBranchAddress("FitMPV" ,&tree_FitMPV ); t1->SetBranchAddress("FitMPVErr" ,&tree_FitMPVErr ); t1->SetBranchAddress("FitWidth" ,&tree_FitWidth ); t1->SetBranchAddress("FitWidthErr" ,&tree_FitWidthErr); t1->SetBranchAddress("FitChi2NDF" ,&tree_FitChi2NDF ); t1->SetBranchAddress("Gain" ,&tree_Gain ); t1->SetBranchAddress("PrevGain" ,&tree_PrevGain ); t1->SetBranchAddress("NEntries" ,&tree_NEntries ); TH2D* ChargeDistrib = (TH2D*)GetObjectFromPath(f1,"SiStripCalib/Charge_Vs_Index"); TH2D* ChargeDistribA = (TH2D*)GetObjectFromPath(f1,"SiStripCalib/Charge_Vs_Index_Absolute"); TH2D* Charge_Vs_PathlengthTIB = (TH2D*)GetObjectFromPath(f1,"SiStripCalib/Charge_Vs_PathlengthTIB"); TH2D* Charge_Vs_PathlengthTOB = (TH2D*)GetObjectFromPath(f1,"SiStripCalib/Charge_Vs_PathlengthTOB"); TH2D* Charge_Vs_PathlengthTIDP = (TH2D*)GetObjectFromPath(f1,"SiStripCalib/Charge_Vs_PathlengthTIDP"); TH2D* Charge_Vs_PathlengthTIDM = (TH2D*)GetObjectFromPath(f1,"SiStripCalib/Charge_Vs_PathlengthTIDM"); TH2D* Charge_Vs_PathlengthTID = (TH2D*)Charge_Vs_PathlengthTIDP->Clone("Charge_Vs_PathlengthTID"); Charge_Vs_PathlengthTID ->Add(Charge_Vs_PathlengthTIDM); TH2D* Charge_Vs_PathlengthTECP1 = (TH2D*)GetObjectFromPath(f1,"SiStripCalib/Charge_Vs_PathlengthTECP1"); TH2D* Charge_Vs_PathlengthTECP2 = (TH2D*)GetObjectFromPath(f1,"SiStripCalib/Charge_Vs_PathlengthTECP2"); TH2D* Charge_Vs_PathlengthTECM1 = (TH2D*)GetObjectFromPath(f1,"SiStripCalib/Charge_Vs_PathlengthTECM1"); TH2D* Charge_Vs_PathlengthTECM2 = (TH2D*)GetObjectFromPath(f1,"SiStripCalib/Charge_Vs_PathlengthTECM2"); TH2D* Charge_Vs_PathlengthTECP = (TH2D*)Charge_Vs_PathlengthTECP1->Clone("Charge_Vs_PathlengthTECP"); Charge_Vs_PathlengthTECP ->Add(Charge_Vs_PathlengthTECP2); TH2D* Charge_Vs_PathlengthTECM = (TH2D*)Charge_Vs_PathlengthTECM1->Clone("Charge_Vs_PathlengthTECM"); Charge_Vs_PathlengthTECM ->Add(Charge_Vs_PathlengthTECM2); TH2D* Charge_Vs_PathlengthTEC1 = (TH2D*)Charge_Vs_PathlengthTECP1->Clone("Charge_Vs_PathlengthTEC1"); Charge_Vs_PathlengthTEC1 ->Add(Charge_Vs_PathlengthTECM1); TH2D* Charge_Vs_PathlengthTEC2 = (TH2D*)Charge_Vs_PathlengthTECP2->Clone("Charge_Vs_PathlengthTEC2"); Charge_Vs_PathlengthTEC2 ->Add(Charge_Vs_PathlengthTECM2); TH2D* Charge_Vs_PathlengthTEC = (TH2D*)Charge_Vs_PathlengthTECP ->Clone("Charge_Vs_PathlengthTEC"); Charge_Vs_PathlengthTEC ->Add(Charge_Vs_PathlengthTECM ); TH2D* Charge_Vs_PathlengthThin = (TH2D*)Charge_Vs_PathlengthTEC1->Clone("Charge_Vs_PathlengthThin"); Charge_Vs_PathlengthThin ->Add(Charge_Vs_PathlengthTIB ); Charge_Vs_PathlengthThin ->Add(Charge_Vs_PathlengthTID ); TH2D* Charge_Vs_PathlengthThick = (TH2D*)Charge_Vs_PathlengthTEC2->Clone("Charge_Vs_PathlengthThin"); Charge_Vs_PathlengthThick ->Add(Charge_Vs_PathlengthTOB ); TH1D* MPV_Vs_PathlengthTIB = ChargeToMPV(Charge_Vs_PathlengthTIB ,"MPV_Vs_PathlengthTIB" , true); TH1D* MPV_Vs_PathlengthTID = ChargeToMPV(Charge_Vs_PathlengthTID ,"MPV_Vs_PathlengthTID" , true); // TH1D* MPV_Vs_PathlengthTIDP = ChargeToMPV(Charge_Vs_PathlengthTIDP ,"MPV_Vs_PathlengthTIDP" , true); // TH1D* MPV_Vs_PathlengthTIDM = ChargeToMPV(Charge_Vs_PathlengthTIDM ,"MPV_Vs_PathlengthTIDM" , true); TH1D* MPV_Vs_PathlengthTOB = ChargeToMPV(Charge_Vs_PathlengthTOB ,"MPV_Vs_PathlengthTOB" , true); // TH1D* MPV_Vs_PathlengthTEC = ChargeToMPV(Charge_Vs_PathlengthTEC ,"MPV_Vs_PathlengthTEC" , true); // TH1D* MPV_Vs_PathlengthTECP = ChargeToMPV(Charge_Vs_PathlengthTECP ,"MPV_Vs_PathlengthTECP" , true); // TH1D* MPV_Vs_PathlengthTECM = ChargeToMPV(Charge_Vs_PathlengthTECM ,"MPV_Vs_PathlengthTECM" , true); TH1D* MPV_Vs_PathlengthTEC1 = ChargeToMPV(Charge_Vs_PathlengthTEC1 ,"MPV_Vs_PathlengthTEC1" , true); TH1D* MPV_Vs_PathlengthTEC2 = ChargeToMPV(Charge_Vs_PathlengthTEC2 ,"MPV_Vs_PathlengthTEC2" , true); // TH1D* MPV_Vs_PathlengthTECP1 = ChargeToMPV(Charge_Vs_PathlengthTECP1,"MPV_Vs_PathlengthTECP1", true); // TH1D* MPV_Vs_PathlengthTECP2 = ChargeToMPV(Charge_Vs_PathlengthTECP2,"MPV_Vs_PathlengthTECP2", true); // TH1D* MPV_Vs_PathlengthTECM1 = ChargeToMPV(Charge_Vs_PathlengthTECM1,"MPV_Vs_PathlengthTECM1", true); // TH1D* MPV_Vs_PathlengthTECM2 = ChargeToMPV(Charge_Vs_PathlengthTECM2,"MPV_Vs_PathlengthTECM2", true); TH1D* MPV_Vs_PathlengthThin = ChargeToMPV(Charge_Vs_PathlengthThin ,"MPV_Vs_PathlengthThin" , true); TH1D* MPV_Vs_PathlengthThick = ChargeToMPV(Charge_Vs_PathlengthThick,"MPV_Vs_PathlengthThick", true); TH2D* MPV_Vs_EtaTIB = new TH2D("MPV_Vs_EtaTIB" ,"MPV_Vs_EtaTIB" , 50, -3.0, 3.0, 300, 0, 600); TH2D* MPV_Vs_EtaTID = new TH2D("MPV_Vs_EtaTID" ,"MPV_Vs_EtaTID" , 50, -3.0, 3.0, 300, 0, 600); TH2D* MPV_Vs_EtaTOB = new TH2D("MPV_Vs_EtaTOB" ,"MPV_Vs_EtaTOB" , 50, -3.0, 3.0, 300, 0, 600); TH2D* MPV_Vs_EtaTEC = new TH2D("MPV_Vs_EtaTEC" ,"MPV_Vs_EtaTEC" , 50, -3.0, 3.0, 300, 0, 600); TH2D* MPV_Vs_EtaTEC1 = new TH2D("MPV_Vs_EtaTEC1","MPV_Vs_EtaTEC1", 50, -3.0, 3.0, 300, 0, 600); TH2D* MPV_Vs_EtaTEC2 = new TH2D("MPV_Vs_EtaTEC2","MPV_Vs_EtaTEC2", 50, -3.0, 3.0, 300, 0, 600); TH2D* MPV_Vs_PhiTIB = new TH2D("MPV_Vs_PhiTIB" ,"MPV_Vs_PhiTIB" , 50, -3.4, 3.4, 300, 0, 600); TH2D* MPV_Vs_PhiTID = new TH2D("MPV_Vs_PhiTID" ,"MPV_Vs_PhiTID" , 50, -3.4, 3.4, 300, 0, 600); TH2D* MPV_Vs_PhiTOB = new TH2D("MPV_Vs_PhiTOB" ,"MPV_Vs_PhiTOB" , 50, -3.4, 3.4, 300, 0, 600); TH2D* MPV_Vs_PhiTEC = new TH2D("MPV_Vs_PhiTEC" ,"MPV_Vs_PhiTEC" , 50, -3.4, 3.4, 300, 0, 600); TH2D* MPV_Vs_PhiTEC1 = new TH2D("MPV_Vs_PhiTEC1","MPV_Vs_PhiTEC1", 50, -3.4, 3.4, 300, 0, 600); TH2D* MPV_Vs_PhiTEC2 = new TH2D("MPV_Vs_PhiTEC2","MPV_Vs_PhiTEC2", 50, -3.4, 3.4, 300, 0, 600); TH2D* NoMPV = new TH2D("NoMPV" ,"NoMPV" ,350, -350, 350, 240, 0, 120); TH1D* MPVs = new TH1D("MPVs" ,"MPVs" , 300, 0, 600); TH1D* MPVs320 = new TH1D("MPVs320" ,"MPVs320" , 300, 0, 600); TH1D* MPVs500 = new TH1D("MPVs500" ,"MPVs500" , 300, 0, 600); TH1D* MPVError = new TH1D("MPVError" ,"MPVError" , 150, 0, 150); TH2D* MPVErrorVsMPV = new TH2D("MPVErrorVsMPV" ,"MPVErrorVsMPV" ,300, 0, 600, 150, 0, 150); TH2D* MPVErrorVsEta = new TH2D("MPVErrorVsEta" ,"MPVErrorVsEta" , 50, -3.0, 3.0, 150, 0, 150); TH2D* MPVErrorVsPhi = new TH2D("MPVErrorVsPhi" ,"MPVErrorVsPhi" , 50, -3.4, 3.4, 150, 0, 150); TH2D* MPVErrorVsN = new TH2D("MPVErrorVsN" ,"MPVErrorVsN" ,500, 0,1000, 150, 0, 150); TH1D* ChargeTIB = new TH1D("ChargeTIB" ,"ChargeTIB" , 1000, 0,2000); TH1D* ChargeTID = new TH1D("ChargeTID" ,"ChargeTID" , 1000, 0,2000); TH1D* ChargeTIDP = new TH1D("ChargeTIDP" ,"ChargeTIDP" , 1000, 0,2000); TH1D* ChargeTIDM = new TH1D("ChargeTIDM" ,"ChargeTIDM" , 1000, 0,2000); TH1D* ChargeTOB = new TH1D("ChargeTOB" ,"ChargeTOB" , 1000, 0,2000); TH1D* ChargeTEC = new TH1D("ChargeTEC" ,"ChargeTEC" , 1000, 0,2000); TH1D* ChargeTECP = new TH1D("ChargeTECP" ,"ChargeTECP" , 1000, 0,2000); TH1D* ChargeTECM = new TH1D("ChargeTECM" ,"ChargeTECM" , 1000, 0,2000); TH1D* ChargeTEC1 = new TH1D("ChargeTEC1" ,"ChargeTEC1" , 1000, 0,2000); TH1D* ChargeTEC2 = new TH1D("ChargeTEC2" ,"ChargeTEC2" , 1000, 0,2000); TH1D* ChargeTECP1 = new TH1D("ChargeTECP1" ,"ChargeTECP1" , 1000, 0,2000); TH1D* ChargeTECP2 = new TH1D("ChargeTECP2" ,"ChargeTECP2" , 1000, 0,2000); TH1D* ChargeTECM1 = new TH1D("ChargeTECM1" ,"ChargeTECM1" , 1000, 0,2000); TH1D* ChargeTECM2 = new TH1D("ChargeTECM2" ,"ChargeTECM2" , 1000, 0,2000); TH1D* ChargeAbsTIB = new TH1D("ChargeAbsTIB" ,"ChargeAbsTIB" , 500, 0,2000); TH1D* ChargeAbsTID = new TH1D("ChargeAbsTID" ,"ChargeAbsTID" , 500, 0,2000); TH1D* ChargeAbsTIDP = new TH1D("ChargeAbsTIDP" ,"ChargeAbsTIDP" , 500, 0,2000); TH1D* ChargeAbsTIDM = new TH1D("ChargeAbsTIDM" ,"ChargeAbsTIDM" , 500, 0,2000); TH1D* ChargeAbsTOB = new TH1D("ChargeAbsTOB" ,"ChargeAbsTOB" , 500, 0,2000); TH1D* ChargeAbsTEC = new TH1D("ChargeAbsTEC" ,"ChargeAbsTEC" , 500, 0,2000); TH1D* ChargeAbsTECP = new TH1D("ChargeAbsTECP" ,"ChargeAbsTECP" , 500, 0,2000); TH1D* ChargeAbsTECM = new TH1D("ChargeAbsTECM" ,"ChargeAbsTECM" , 500, 0,2000); TH1D* ChargeAbsTEC1 = new TH1D("ChargeAbsTEC1" ,"ChargeAbsTEC1" , 500, 0,2000); TH1D* ChargeAbsTEC2 = new TH1D("ChargeAbsTEC2" ,"ChargeAbsTEC2" , 500, 0,2000); TH1D* ChargeAbsTECP1 = new TH1D("ChargeAbsTECP1","ChargeAbsTECP1", 500, 0,2000); TH1D* ChargeAbsTECP2 = new TH1D("ChargeAbsTECP2","ChargeAbsTECP2", 500, 0,2000); TH1D* ChargeAbsTECM1 = new TH1D("ChargeAbsTECM1","ChargeAbsTECM1", 500, 0,2000); TH1D* ChargeAbsTECM2 = new TH1D("ChargeAbsTECM2","ChargeAbsTECM2", 500, 0,2000); printf("Progressing Bar :0%% 20%% 40%% 60%% 80%% 100%%\n"); printf("Looping on the Tree :"); int TreeStep = t1->GetEntries()/50;if(TreeStep==0)TreeStep=1; for (unsigned int ientry = 0; ientry < t1->GetEntries(); ientry++) { if(ientry%TreeStep==0){printf(".");fflush(stdout);} t1->GetEntry(ientry); TH1D* Proj = ChargeDistrib ->ProjectionY("proj" ,tree_Index, tree_Index); TH1D* ProjAbsolute = ChargeDistribA->ProjectionY("projA",tree_Index, tree_Index); if(tree_SubDet==3 ) MPV_Vs_EtaTIB ->Fill(tree_Eta,tree_FitMPV); if(tree_SubDet==4 ) MPV_Vs_EtaTID ->Fill(tree_Eta,tree_FitMPV); if(tree_SubDet==5 ) MPV_Vs_EtaTOB ->Fill(tree_Eta,tree_FitMPV); if(tree_SubDet==6 ) MPV_Vs_EtaTEC ->Fill(tree_Eta,tree_FitMPV); if(tree_SubDet==6 && tree_Thickness<0.04) MPV_Vs_EtaTEC1->Fill(tree_Eta,tree_FitMPV); if(tree_SubDet==6 && tree_Thickness>0.04) MPV_Vs_EtaTEC2->Fill(tree_Eta,tree_FitMPV); if(tree_SubDet==3 ) MPV_Vs_PhiTIB ->Fill(tree_Phi,tree_FitMPV); if(tree_SubDet==4 ) MPV_Vs_PhiTID ->Fill(tree_Phi,tree_FitMPV); if(tree_SubDet==5 ) MPV_Vs_PhiTOB ->Fill(tree_Phi,tree_FitMPV); if(tree_SubDet==6 ) MPV_Vs_PhiTEC ->Fill(tree_Phi,tree_FitMPV); if(tree_SubDet==6 && tree_Thickness<0.04) MPV_Vs_PhiTEC1->Fill(tree_Phi,tree_FitMPV); if(tree_SubDet==6 && tree_Thickness>0.04) MPV_Vs_PhiTEC2->Fill(tree_Phi,tree_FitMPV); MPVs ->Fill( tree_FitMPV); if( tree_Thickness<0.04) MPVs320 ->Fill( tree_FitMPV); if( tree_Thickness>0.04) MPVs500 ->Fill( tree_FitMPV); if(tree_FitMPV<0 ) NoMPV ->Fill(tree_z ,tree_R); MPVError ->Fill( tree_FitMPVErr); MPVErrorVsMPV ->Fill(tree_FitMPV,tree_FitMPVErr); MPVErrorVsEta ->Fill(tree_Eta,tree_FitMPVErr); MPVErrorVsPhi ->Fill(tree_Phi,tree_FitMPVErr); MPVErrorVsN ->Fill(tree_NEntries,tree_FitMPVErr); if(tree_SubDet==3 ) ChargeTIB ->Add(Proj,1); if(tree_SubDet==4 ) ChargeTID ->Add(Proj,1); if(tree_SubDet==4 && tree_Eta<0 ) ChargeTIDM ->Add(Proj,1); if(tree_SubDet==4 && tree_Eta>0 ) ChargeTIDP ->Add(Proj,1); if(tree_SubDet==5 ) ChargeTOB ->Add(Proj,1); if(tree_SubDet==6 ) ChargeTEC ->Add(Proj,1); if(tree_SubDet==6 && tree_Thickness<0.04) ChargeTEC1 ->Add(Proj,1); if(tree_SubDet==6 && tree_Thickness>0.04) ChargeTEC2 ->Add(Proj,1); if(tree_SubDet==6 && tree_Eta<0 ) ChargeTECP ->Add(Proj,1); if(tree_SubDet==6 && tree_Eta>0 ) ChargeTECM ->Add(Proj,1); if(tree_SubDet==6 && tree_Eta<0 && tree_Thickness<0.04) ChargeTECM1 ->Add(Proj,1); if(tree_SubDet==6 && tree_Eta<0 && tree_Thickness>0.04) ChargeTECM2 ->Add(Proj,1); if(tree_SubDet==6 && tree_Eta>0 && tree_Thickness<0.04) ChargeTECP1 ->Add(Proj,1); if(tree_SubDet==6 && tree_Eta>0 && tree_Thickness>0.04) ChargeTECP2 ->Add(Proj,1); if(tree_SubDet==3 ) ChargeAbsTIB ->Add(ProjAbsolute,1); if(tree_SubDet==4 ) ChargeAbsTID ->Add(ProjAbsolute,1); if(tree_SubDet==4 && tree_Eta<0 ) ChargeAbsTIDM ->Add(ProjAbsolute,1); if(tree_SubDet==4 && tree_Eta>0 ) ChargeAbsTIDP ->Add(ProjAbsolute,1); if(tree_SubDet==5 ) ChargeAbsTOB ->Add(ProjAbsolute,1); if(tree_SubDet==6 ) ChargeAbsTEC ->Add(ProjAbsolute,1); if(tree_SubDet==6 && tree_Thickness<0.04) ChargeAbsTEC1 ->Add(ProjAbsolute,1); if(tree_SubDet==6 && tree_Thickness>0.04) ChargeAbsTEC2 ->Add(ProjAbsolute,1); if(tree_SubDet==6 && tree_Eta<0 ) ChargeAbsTECP ->Add(ProjAbsolute,1); if(tree_SubDet==6 && tree_Eta>0 ) ChargeAbsTECM ->Add(ProjAbsolute,1); if(tree_SubDet==6 && tree_Eta<0 && tree_Thickness<0.04) ChargeAbsTECM1 ->Add(ProjAbsolute,1); if(tree_SubDet==6 && tree_Eta<0 && tree_Thickness>0.04) ChargeAbsTECM2 ->Add(ProjAbsolute,1); if(tree_SubDet==6 && tree_Eta>0 && tree_Thickness<0.04) ChargeAbsTECP1 ->Add(ProjAbsolute,1); if(tree_SubDet==6 && tree_Eta>0 && tree_Thickness>0.04) ChargeAbsTECP2 ->Add(ProjAbsolute,1); delete Proj; delete ProjAbsolute; }printf("\n"); TCanvas* c1; TObject** Histos = new TObject*[10]; std::vector<char*> legend; c1 = new TCanvas("c1","c1,",600,600); legend.clear(); Histos[0] = MPV_Vs_EtaTEC; legend.push_back("TEC"); Histos[1] = MPV_Vs_EtaTIB; legend.push_back("TIB"); Histos[2] = MPV_Vs_EtaTID; legend.push_back("TID"); Histos[3] = MPV_Vs_EtaTOB; legend.push_back("TOB"); DrawTH2D((TH2D**)Histos,legend, "", "module #eta", "MPV (ADC/mm)", -3.0,3.0, 0,500); DrawLegend (Histos,legend,"","P"); DrawStatBox(Histos,legend,false); SaveCanvas(c1,"Pictures/MPV_Vs_EtaSubDet"); delete c1; c1 = new TCanvas("c1","c1,",600,600); legend.clear(); Histos[0] = MPV_Vs_PhiTEC; legend.push_back("TEC"); Histos[1] = MPV_Vs_PhiTIB; legend.push_back("TIB"); Histos[2] = MPV_Vs_PhiTID; legend.push_back("TID"); Histos[3] = MPV_Vs_PhiTOB; legend.push_back("TOB"); DrawTH2D((TH2D**)Histos,legend, "", "module #phi", "MPV (ADC/mm)", -3.4,3.4, 0,500); DrawLegend(Histos,legend,"","P"); DrawStatBox(Histos,legend,false); SaveCanvas(c1,"Pictures/MPV_Vs_PhiSubDet"); delete c1; c1 = new TCanvas("c1","c1,",600,600); legend.clear(); Histos[0] = NoMPV; legend.push_back("NoMPV"); DrawTH2D((TH2D**)Histos,legend, "", "z (cm)", "R (cms)", 0,0, 0,0); SaveCanvas(c1,"Pictures/NoMPV", true); delete c1; c1 = new TCanvas("c1","c1,",600,600); legend.clear(); ChargeDistrib->GetXaxis()->SetNdivisions(5+500); Histos[0] = ChargeDistrib; legend.push_back("Charge Vs Index"); //DrawTH2D((TH2D**)Histos,legend, "COLZ", "APV Index", "Charge (ADC/mm)", 0,0, 0,0); //c1->SetLogz(true); //SaveCanvas(c1,"Pictures/Charge", true); delete c1; c1 = new TCanvas("c1","c1,",600,600); legend.clear(); Histos[0] = MPVs320; legend.push_back("320 #mum"); Histos[1] = MPVs500; legend.push_back("500 #mum"); Histos[2] = MPVs; legend.push_back("320 + 500 #mum"); DrawSuperposedHistos((TH1D**)Histos, legend, "", "MPV (ADC/mm)", "#APVs", 0,500, 0,0); DrawLegend(Histos,legend,"","L"); DrawStatBox(Histos,legend,true); SaveCanvas(c1,"Pictures/MPVs"); delete c1; c1 = new TCanvas("c1","c1,",600,600); legend.clear(); Histos[0] = MPVError; legend.push_back("MPV Error"); DrawSuperposedHistos((TH1D**)Histos, legend, "", "Error on MPV (ADC/mm)", "#APVs", 0,500, 0,0); DrawStatBox(Histos,legend,true); c1->SetLogy(true); SaveCanvas(c1,"Pictures/Error"); delete c1; c1 = new TCanvas("c1","c1,",600,600); legend.clear(); Histos[0] = MPVErrorVsMPV; legend.push_back("Error Vs MPV"); DrawTH2D((TH2D**)Histos,legend, "COLZ", "MPV (ADC/mm)", "Error on MPV (ADC/mm)", 0,0, 0,0); c1->SetLogz(true); SaveCanvas(c1,"Pictures/Error_Vs_MPV", true); delete c1; c1 = new TCanvas("c1","c1,",600,600); legend.clear(); Histos[0] = MPVErrorVsEta; legend.push_back("Error Vs Eta"); DrawTH2D((TH2D**)Histos,legend, "COLZ", "module #eta", "Error on MPV (ADC/mm)", 0,0, 0,0); c1->SetLogz(true); SaveCanvas(c1,"Pictures/Error_Vs_Eta", true); delete c1; c1 = new TCanvas("c1","c1,",600,600); legend.clear(); Histos[0] = MPVErrorVsPhi; legend.push_back("Error Vs Phi"); DrawTH2D((TH2D**)Histos,legend, "COLZ", "module #phi", "Error on MPV (ADC/mm)", 0,0, 0,0); c1->SetLogz(true); SaveCanvas(c1,"Pictures/Error_Vs_Phi", true); delete c1; c1 = new TCanvas("c1","c1,",600,600); legend.clear(); Histos[0] = MPVErrorVsN; legend.push_back("Error Vs Entries"); DrawTH2D((TH2D**)Histos,legend, "COLZ", "Number of Entries", "Error on MPV (ADC/mm)", 0,0, 0,0); c1->SetLogz(true); SaveCanvas(c1,"Pictures/Error_Vs_N", true); delete c1; c1 = new TCanvas("c1","c1,",600,600); legend.clear(); Histos[0] = ChargeTEC; legend.push_back("TEC"); Histos[1] = ChargeTIB; legend.push_back("TIB"); Histos[2] = ChargeTID; legend.push_back("TID"); Histos[3] = ChargeTOB; legend.push_back("TOB"); DrawSuperposedHistos((TH1D**)Histos, legend, "", "Charge (ADC/mm)", "#clusters", 0,800 , 0,0); DrawLegend(Histos,legend,"","L"); DrawStatBox(Histos,legend,true, 0.6, 0.7); SaveCanvas(c1,"Pictures/Charge"); delete c1; c1 = new TCanvas("c1","c1,",600,600); legend.clear(); Histos[0] = ChargeTECP; legend.push_back("TEC+"); Histos[1] = ChargeTECM; legend.push_back("TEC-"); DrawSuperposedHistos((TH1D**)Histos, legend, "", "Charge (ADC/mm)", "#clusters", 0,800 , 0,0); DrawLegend(Histos,legend,"","L"); DrawStatBox(Histos,legend,true, 0.6, 0.7); SaveCanvas(c1,"Pictures/ChargeTECSide"); delete c1; c1 = new TCanvas("c1","c1,",600,600); legend.clear(); Histos[0] = ChargeTEC1; legend.push_back("TEC Thin"); Histos[1] = ChargeTEC2; legend.push_back("TEC Thick"); DrawSuperposedHistos((TH1D**)Histos, legend, "", "Charge (ADC/mm)", "#clusters", 0,800 , 0,0); DrawLegend(Histos,legend,"","L"); DrawStatBox(Histos,legend,true, 0.6, 0.7); SaveCanvas(c1,"Pictures/ChargeTECThickness"); delete c1; c1 = new TCanvas("c1","c1,",600,600); legend.clear(); Histos[0] = ChargeTIDP; legend.push_back("TID+"); Histos[1] = ChargeTIDM; legend.push_back("TID-"); DrawSuperposedHistos((TH1D**)Histos, legend, "", "Charge (ADC/mm)", "#clusters", 0,800 , 0,0); DrawLegend(Histos,legend,"","L"); DrawStatBox(Histos,legend,true, 0.6, 0.7); SaveCanvas(c1,"Pictures/ChargeTIDSide"); delete c1; c1 = new TCanvas("c1","c1,",600,600); legend.clear(); Histos[0] = ChargeAbsTEC; legend.push_back("TEC"); Histos[1] = ChargeAbsTIB; legend.push_back("TIB"); Histos[2] = ChargeAbsTID; legend.push_back("TID"); Histos[3] = ChargeAbsTOB; legend.push_back("TOB"); DrawSuperposedHistos((TH1D**)Histos, legend, "", "Charge (ADC)", "#clusters", 0,800 , 0,0); DrawLegend(Histos,legend,"","L"); DrawStatBox(Histos,legend,true, 0.6, 0.7); SaveCanvas(c1,"Pictures/ChargeAbs"); delete c1; c1 = new TCanvas("c1","c1,",600,600); legend.clear(); Histos[0] = ChargeAbsTECP; legend.push_back("TEC+"); Histos[1] = ChargeAbsTECM; legend.push_back("TEC-"); DrawSuperposedHistos((TH1D**)Histos, legend, "", "Charge (ADC)", "#clusters", 0,800 , 0,0); DrawLegend(Histos,legend,"","L"); DrawStatBox(Histos,legend,true, 0.6, 0.7); SaveCanvas(c1,"Pictures/ChargeAbsTECSide"); delete c1; c1 = new TCanvas("c1","c1,",600,600); legend.clear(); Histos[0] = ChargeAbsTEC1; legend.push_back("TEC Thin"); Histos[1] = ChargeAbsTEC2; legend.push_back("TEC Thick"); DrawSuperposedHistos((TH1D**)Histos, legend, "", "Charge (ADC)", "#clusters", 0,800 , 0,0); DrawLegend(Histos,legend,"","L"); DrawStatBox(Histos,legend,true, 0.6, 0.7); SaveCanvas(c1,"Pictures/ChargeAbsTECThickness"); delete c1; c1 = new TCanvas("c1","c1,",600,600); legend.clear(); Histos[0] = ChargeAbsTIDP; legend.push_back("TID+"); Histos[1] = ChargeAbsTIDM; legend.push_back("TID-"); DrawSuperposedHistos((TH1D**)Histos, legend, "", "Charge (ADC)", "#clusters", 0,800 , 0,0); DrawLegend(Histos,legend,"","L"); DrawStatBox(Histos,legend,true, 0.6, 0.7); SaveCanvas(c1,"Pictures/ChargeAbsTIDSide"); delete c1; c1 = new TCanvas("c1","c1,",600,600); legend.clear(); Histos[0] = MPV_Vs_PathlengthThin; legend.push_back("320 #mum"); Histos[1] = MPV_Vs_PathlengthThick; legend.push_back("500 #mum"); DrawSuperposedHistos((TH1D**)Histos, legend, "HIST", "pathlength (mm)", "MPV (ADC/mm)", 0,0 , 230,380); DrawLegend(Histos,legend,"","L"); SaveCanvas(c1,"Pictures/MPV_Vs_Path"); delete c1; c1 = new TCanvas("c1","c1,",600,600); legend.clear(); Histos[0] = MPV_Vs_PathlengthTIB; legend.push_back("TIB (320 #mum)"); Histos[1] = MPV_Vs_PathlengthTID; legend.push_back("TID (320 #mum)"); Histos[2] = MPV_Vs_PathlengthTOB; legend.push_back("TOB (500 #mum)"); Histos[3] = MPV_Vs_PathlengthTEC1; legend.push_back("TEC (320 #mum)"); Histos[4] = MPV_Vs_PathlengthTEC2; legend.push_back("TEC (500 #mum)"); DrawSuperposedHistos((TH1D**)Histos, legend, "HIST", "pathlength (mm)", "MPV (ADC/mm)", 0,0 , 230,380); DrawLegend(Histos,legend,"","L"); SaveCanvas(c1,"Pictures/MPV_Vs_PathSubDet"); delete c1; }
//------------------------------------------------------------------------------ // // drawXS // //------------------------------------------------------------------------------ void drawXS(UInt_t theCharge = WInclusive) { gStyle->SetEndErrorSize(5); // 7 TeV inclusive //---------------------------------------------------------------------------- xs_value[WInclusive][EEE] = 23.00; xs_value[WInclusive][EEM] = 19.67; xs_value[WInclusive][MME] = 19.81; xs_value[WInclusive][MMM] = 21.02; xs_value[WInclusive][all] = 20.76; xs_stat[WInclusive][EEE] = 3.10; xs_stat[WInclusive][EEM] = 2.73; xs_stat[WInclusive][MME] = 2.60; xs_stat[WInclusive][MMM] = 2.30; xs_stat[WInclusive][all] = 1.32; xs_syst[WInclusive][EEE] = 1.39; xs_syst[WInclusive][EEM] = 1.50; xs_syst[WInclusive][MME] = 1.55; xs_syst[WInclusive][MMM] = 1.47; xs_syst[WInclusive][all] = 1.13; xs_lumi[WInclusive][EEE] = 0.51; xs_lumi[WInclusive][EEM] = 0.43; xs_lumi[WInclusive][MME] = 0.44; xs_lumi[WInclusive][MMM] = 0.46; xs_lumi[WInclusive][all] = 0.46; // 7 TeV W+ //---------------------------------------------------------------------------- xs_value[WPlus][EEE] = 13.39; xs_value[WPlus][EEM] = 13.18; xs_value[WPlus][MME] = 14.14; xs_value[WPlus][MMM] = 11.43; xs_value[WPlus][all] = 12.73; xs_stat[WPlus][EEE] = 2.39; xs_stat[WPlus][EEM] = 2.24; xs_stat[WPlus][MME] = 2.19; xs_stat[WPlus][MMM] = 1.71; xs_stat[WPlus][all] = 1.04; xs_syst[WPlus][EEE] = 0.75; xs_syst[WPlus][EEM] = 0.64; xs_syst[WPlus][MME] = 0.74; xs_syst[WPlus][MMM] = 0.53; xs_syst[WPlus][all] = 0.59; xs_lumi[WPlus][EEE] = 0.29; xs_lumi[WPlus][EEM] = 0.29; xs_lumi[WPlus][MME] = 0.31; xs_lumi[WPlus][MMM] = 0.25; xs_lumi[WPlus][all] = 0.28; // 7 TeV W- //---------------------------------------------------------------------------- xs_value[WMinus][EEE] = 9.49; xs_value[WMinus][EEM] = 6.51; xs_value[WMinus][MME] = 5.73; xs_value[WMinus][MMM] = 9.48; xs_value[WMinus][all] = 7.46; xs_stat[WMinus][EEE] = 1.95; xs_stat[WMinus][EEM] = 1.58; xs_stat[WMinus][MME] = 1.40; xs_stat[WMinus][MMM] = 1.52; xs_stat[WMinus][all] = 0.79; xs_syst[WMinus][EEE] = 0.60; xs_syst[WMinus][EEM] = 0.37; xs_syst[WMinus][MME] = 0.37; xs_syst[WMinus][MMM] = 0.50; xs_syst[WMinus][all] = 0.40; xs_lumi[WMinus][EEE] = 0.21; xs_lumi[WMinus][EEM] = 0.14; xs_lumi[WMinus][MME] = 0.13; xs_lumi[WMinus][MMM] = 0.21; xs_lumi[WMinus][all] = 0.16; // Do the work //---------------------------------------------------------------------------- TGraphErrors* gStat = new TGraphErrors(nChannel); TGraphErrors* gSyst = new TGraphErrors(nChannel); TGraphErrors* gLumi = new TGraphErrors(nChannel); for (UInt_t i=0; i<nChannel; i++) { Double_t errorSquared = (xs_stat[theCharge][i] * xs_stat[theCharge][i]); gStat->SetPointError(i, sqrt(errorSquared) / xs_nlo[theCharge], 0.0); errorSquared += (xs_syst[theCharge][i] * xs_syst[theCharge][i]); gSyst->SetPointError(i, sqrt(errorSquared) / xs_nlo[theCharge], 0.0); errorSquared += (xs_lumi[theCharge][i] * xs_lumi[theCharge][i]); gLumi->SetPointError(i, sqrt(errorSquared) / xs_nlo[theCharge], 0.0); gStat->SetPoint(i, xs_value[theCharge][i] / xs_nlo[theCharge], nChannel-i-1); gSyst->SetPoint(i, xs_value[theCharge][i] / xs_nlo[theCharge], nChannel-i-1); gLumi->SetPoint(i, xs_value[theCharge][i] / xs_nlo[theCharge], nChannel-i-1); } // Cosmetics //---------------------------------------------------------------------------- gStat->SetLineWidth (2); gStat->SetMarkerSize (1.3); gStat->SetMarkerStyle(kFullCircle); gSyst->SetLineColor (kRed); gSyst->SetLineWidth (2); gSyst->SetMarkerSize (1.3); gSyst->SetMarkerStyle(kFullCircle); gLumi->SetLineColor (kBlue); gLumi->SetLineWidth (2); gLumi->SetMarkerSize (1.3); gLumi->SetMarkerStyle(kFullCircle); // Draw //---------------------------------------------------------------------------- TString suffix = "7TeV_" + sCharge[theCharge]; TCanvas* canvas = new TCanvas("ratioNLO_" + suffix, "ratioNLO_" + suffix); canvas->SetLeftMargin(canvas->GetRightMargin()); Double_t xmin = 0.0; Double_t xmax = 2.0; Double_t ylegend = 1.2; Double_t ymin = -0.6; Double_t ymax = nChannel + ymin + ylegend; TH2F* h2 = new TH2F("h2_" + suffix, "", 100, xmin, xmax, 100, ymin, ymax); h2->Draw(); // NLO WZ cross-section //---------------------------------------------------------------------------- TBox* nlo = new TBox(1. - xs_nlo_left [theCharge] / xs_nlo[theCharge], ymin, 1. + xs_nlo_right[theCharge] / xs_nlo[theCharge], ymax - ylegend); nlo->SetLineColor(0); nlo->SetFillColor(kGray); nlo->SetFillStyle(1001); nlo->Draw("e2,same"); TLine* line = new TLine(1., ymin, 1., ymax - ylegend); line->SetLineColor(kGray+1); line->SetLineWidth(2); line->Draw("same"); // Cross sections //---------------------------------------------------------------------------- gLumi->Draw("p,same"); gSyst->Draw("p,same"); gStat->Draw("p,same"); // Labels //---------------------------------------------------------------------------- for (UInt_t i=0; i<nChannel; i++) { Double_t x = gStat->GetX()[i]; Double_t y = gStat->GetY()[i]; Double_t gStatError = gStat->GetErrorX(i); Double_t gSystError = gSyst->GetErrorX(i); Double_t gLumiError = gLumi->GetErrorX(i); DrawTLatex(42, xmin+0.06, y+0.15, 0.035, 12, Form("%s %.2f #pm %.2f", lChannel[i].Data(), x, gLumiError), 0); gLumiError = sqrt(gLumiError*gLumiError - gSystError*gSystError); gSystError = sqrt(gSystError*gSystError - gStatError*gStatError); DrawTLatex(42, xmin+0.06, y-0.15, 0.025, 12, Form("%.2f #pm %.2f #pm %.2f #pm %.2f", x, gStatError, gSystError, gLumiError), 0); } DrawTLatex(42, 0.050, 0.975, _bigLabelSize, 13, "CMS Preliminary"); DrawTLatex(42, 0.940, 0.983, _bigLabelSize, 33, Form("#sqrt{s} = 7 TeV, L = %.1f fb^{-1}", luminosity/1e3)); TString swz = ""; if (theCharge == WPlus) swz = "W^{+}Z"; else if (theCharge == WMinus) swz = "W^{-}Z"; else swz = "W^{#pm}Z"; h2->GetXaxis()->CenterTitle(); h2->GetXaxis()->SetTitleOffset(1.4); h2->GetXaxis()->SetTitle(Form("#sigma_{%s}^{exp} / #sigma_{%s}^{theory}", swz.Data(), swz.Data())); h2->GetYaxis()->SetTitle(""); // Remove y-axis labels //---------------------------------------------------------------------------- TAxis* yaxis = h2->GetYaxis(); for (Int_t j=1; j<yaxis->GetNbins(); j++) yaxis->SetBinLabel(j, ""); // Additional legend //---------------------------------------------------------------------------- DrawLegend(0.645, 0.840, gStat, " stat.", "lp"); DrawLegend(0.645, 0.795, nlo, " theory", "f"); DrawLegend(0.800, 0.840, gSyst, " syst.", "l"); DrawLegend(0.800, 0.795, gLumi, " lumi.", "l"); // Save //---------------------------------------------------------------------------- canvas->Update(); canvas->GetFrame()->DrawClone(); canvas->RedrawAxis(); canvas->SaveAs(Form("pdf/ratioNLO_%s.pdf", suffix.Data())); canvas->SaveAs(Form("png/ratioNLO_%s.png", suffix.Data())); }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // drawFigures4and5 // // Zpt // LeadingJetPt // Njets // //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ void drawFigures4and5(TString var = "Zpt") { gSystem->mkdir("pdf", kTRUE); gSystem->mkdir("png", kTRUE); gInterpreter->ExecuteMacro("WZPaperStyle.C"); Bool_t drawMcfm = (var.EqualTo("Zpt")) ? true : false; TString variable; TString xtitle; TString ytitle; if (var.EqualTo("Zpt")) variable = "Z"; if (var.EqualTo("LeadingJetPt")) variable = "leading jet"; if (var.EqualTo("Njets")) variable = "N_{jets}"; if (var.EqualTo("Njets")) { xtitle = variable; ytitle = "d#sigma(WZ#rightarrow3l#nu)/d" + variable + " (pb)"; } else { xtitle = "p_{T}^{" + variable + "} (GeV)"; ytitle = "d#sigma(WZ#rightarrow3l#nu)/dp_{T}^{" + variable + "} (pb/GeV)"; } TFile* file = new TFile("rootfiles/all_unfolding_" + var + ".root", "read"); TH1D* xsValue = (TH1D*)file->Get("hComb_diff"); TH1D* xsValue_Madgraph = (TH1D*)file->Get("hGenXs" + var + "_1"); TH1D* xsValue_MCnlo; if (drawMcfm) xsValue_MCnlo = (TH1D*)file->Get("mcfm_tot"); // Data cosmetics //---------------------------------------------------------------------------- xsValue->SetFillColor ( kWhite); xsValue->SetFillStyle ( 1001); xsValue->SetLineColor ( kBlack); xsValue->SetLineWidth ( 1); xsValue->SetMarkerColor( kBlack); xsValue->SetMarkerSize ( _msize); xsValue->SetMarkerStyle(kFullCircle); // Madgraph cosmetics //---------------------------------------------------------------------------- xsValue_Madgraph->SetFillColor ( kOrange); xsValue_Madgraph->SetFillStyle ( 1001); xsValue_Madgraph->SetLineColor ( kOrange+7); xsValue_Madgraph->SetLineWidth ( 1); xsValue_Madgraph->SetMarkerColor( kOrange+7); xsValue_Madgraph->SetMarkerSize ( _msize); xsValue_Madgraph->SetMarkerStyle(kFullSquare); // MCNLO cosmetics //---------------------------------------------------------------------------- if (drawMcfm) { xsValue_MCnlo->SetFillColor ( kAzure-9); xsValue_MCnlo->SetFillStyle ( 1001); xsValue_MCnlo->SetLineColor ( kAzure); xsValue_MCnlo->SetLineWidth ( 1); xsValue_MCnlo->SetMarkerColor( kAzure); xsValue_MCnlo->SetMarkerSize ( _msize); xsValue_MCnlo->SetMarkerStyle(kOpenCircle); } // Set the canvas and pads //---------------------------------------------------------------------------- TCanvas* canvas = new TCanvas(var, var); TPad* pad1; TPad* pad2; TPad* pad3; if (drawMcfm) { pad1 = new TPad("pad1" + var, "pad1" + var, 0, 0.49, 1, 1.000); pad2 = new TPad("pad2" + var, "pad2" + var, 0, 0.33, 1, 0.492); pad3 = new TPad("pad3" + var, "pad3" + var, 0, 0.00, 1, 0.332); pad1->SetTopMargin(0.09); pad2->SetTopMargin(0); pad3->SetTopMargin(0); pad1->SetBottomMargin(0); pad2->SetBottomMargin(0); pad3->SetBottomMargin(0.45); pad1->SetLeftMargin(0.16); pad2->SetLeftMargin(0.16); pad3->SetLeftMargin(0.16); pad1->SetRightMargin(0.06); pad2->SetRightMargin(0.06); pad3->SetRightMargin(0.06); } else { pad1 = new TPad("pad1" + var, "pad1" + var, 0, 0.33, 1, 1.000); pad2 = new TPad("pad2" + var, "pad2" + var, 0, 0.00, 1, 0.332); pad1->SetTopMargin(0.09); pad2->SetTopMargin(0); pad1->SetBottomMargin(0); pad2->SetBottomMargin(0.45); pad1->SetLeftMargin(0.16); pad2->SetLeftMargin(0.16); pad1->SetRightMargin(0.06); pad2->SetRightMargin(0.06); } // Draw pad1 //---------------------------------------------------------------------------- pad1->Draw(); pad1->cd(); pad1->SetLogy(); AxisFonts(xsValue->GetXaxis(), xtitle); AxisFonts(xsValue->GetYaxis(), ytitle); xsValue->SetTitle(""); xsValue->Draw("pe"); xsValue_Madgraph->Draw("p,same"); if (drawMcfm) xsValue_MCnlo->Draw("p,same"); xsValue->Draw("pe,same"); if (var.EqualTo("Zpt")) xsValue->SetMinimum(1.1e-4); if (var.EqualTo("LeadingJetPt")) xsValue->SetMinimum(5e-4); if (var.EqualTo("Njets")) xsValue->SetMinimum(2e-2); DrawLatex(_cmsTextFont, 0.173, 0.935, 0.065, 11, "CMS"); DrawLatex(_lumiTextFont, 0.940, 0.935, 0.050, 31, "19.6 fb^{-1} (8 TeV)"); // Legend //---------------------------------------------------------------------------- if (drawMcfm) { DrawLegend(0.72, 0.80, xsValue, " Data", "lp"); DrawLegend(0.72, 0.73, xsValue_Madgraph, " MadGraph", "flp"); DrawLegend(0.72, 0.66, xsValue_MCnlo, " MCFM", "flp"); } else { DrawLegend(0.68, 0.81, xsValue, " Data", "lp"); DrawLegend(0.68, 0.74, xsValue_Madgraph, " MadGraph", "flp"); } // Prepare the ratios //---------------------------------------------------------------------------- TH1D* ratio_mad = (TH1D*)xsValue_Madgraph->Clone("ratio_mad"); TH1D* hratio_mad = (TH1D*)xsValue_Madgraph->Clone("hratio_mad"); TH1D* ratio_mcnlo; TH1D* hratio_mcnlo; if (drawMcfm) { ratio_mcnlo = (TH1D*)xsValue_MCnlo->Clone("ratio_mcnlo"); hratio_mcnlo = (TH1D*)xsValue_MCnlo->Clone("hratio_mcnlo"); } // Set the bin content //---------------------------------------------------------------------------- for (UInt_t ibin=1; ibin<=ratio_mad->GetNbinsX(); ibin++) { Double_t madValue = xsValue_Madgraph->GetBinContent(ibin); Double_t dataValue = xsValue->GetBinContent(ibin); Double_t dataError = xsValue->GetBinError(ibin); Double_t ratioValue_mad = (madValue > 0) ? madValue / dataValue : 0.0; Double_t ratioError_mad = madValue / pow(dataValue,2)*dataError; ratio_mad->SetBinContent(ibin, ratioValue_mad); ratio_mad->SetBinError (ibin, 1e-9); hratio_mad->SetBinContent(ibin, ratioValue_mad); hratio_mad->SetBinError (ibin, ratioError_mad); if (drawMcfm) { Double_t mcnloValue = xsValue_MCnlo->GetBinContent(ibin); Double_t ratioValue_mcnlo = (mcnloValue > 0) ? mcnloValue / dataValue : 0.0; Double_t ratioError_mcnlo = mcnloValue / pow(dataValue,2)*dataError; ratio_mcnlo->SetBinContent(ibin, ratioValue_mcnlo); ratio_mcnlo->SetBinError (ibin, 1e-9); hratio_mcnlo->SetBinContent(ibin, ratioValue_mcnlo); hratio_mcnlo->SetBinError (ibin, ratioError_mcnlo); } } // Draw pad2 //---------------------------------------------------------------------------- AxisFontsRatio(ratio_mad->GetYaxis(), "y", "#frac{Theory}{Data}"); AxisFontsRatio(ratio_mad->GetXaxis(), "x", xtitle); canvas->cd(); pad2->Draw(); pad2->cd(); ratio_mad->SetTitle(""); ratio_mad ->Draw("ep"); hratio_mad->Draw("e2,same"); ratio_mad ->Draw("ep,same"); TLine* line2 = new TLine(ratio_mad->GetXaxis()->GetXmin(), 1.0, ratio_mad->GetXaxis()->GetXmax(), 1.0); line2->SetLineStyle(3); line2->Draw("same"); ratio_mad->GetYaxis()->SetRangeUser(0.01, 2.3); if (drawMcfm) DrawLatex(43, 0.20, 0.785, 15.0, 11, "MadGraph+Pythia normalized to #sigma_{NLO}"); else DrawLatex(43, 0.19, 0.845, 15.0, 11, "MadGraph+Pythia normalized to #sigma_{NLO}"); // Draw pad3 //---------------------------------------------------------------------------- if (drawMcfm) { AxisFontsRatio(ratio_mcnlo->GetYaxis(), "y", "#frac{Theory}{Data}"); AxisFontsRatio(ratio_mcnlo->GetXaxis(), "x", xtitle); canvas->cd(); pad3->Draw(); pad3->cd(); ratio_mcnlo->SetTitle(""); ratio_mcnlo ->Draw("ep"); hratio_mcnlo->Draw("e2,same"); ratio_mcnlo ->Draw("ep,same"); TLine* line3 = new TLine(ratio_mcnlo->GetXaxis()->GetXmin(), 1.0, ratio_mcnlo->GetXaxis()->GetXmax(), 1.0); line3->SetLineStyle(3); line3->Draw("same"); ratio_mcnlo->GetYaxis()->SetRangeUser(0.1, 2.3); pad3->Modified(); DrawLatex(43, 0.2, 0.885, 15.0, 11, "MCFM"); } // Save //---------------------------------------------------------------------------- pad1->cd(); pad1->RedrawAxis(); pad1->GetFrame()->DrawClone(); pad2->cd(); pad2->RedrawAxis(); pad2->GetFrame()->DrawClone(); if (drawMcfm) { pad3->cd(); pad3->RedrawAxis(); pad3->GetFrame()->DrawClone(); } canvas->cd(); canvas->Update(); canvas->SaveAs("pdf/unfolded_" + var + ".pdf"); canvas->SaveAs("png/unfolded_" + var + ".png"); }
void finalPlot(bool drawRatio = 1, int differential = 0, int nsel = 0, int ReBin = 1, TString XTitle = "p_{T,max}^{l} (GeV)", TString units = "", TString plotName = "XSLeadingPt_AN.root", TString outputName = "WW_LeadingPt_final", bool isLogY = false, double lumi = 19.5) { gInterpreter->ExecuteMacro("GoodStyle.C"); TFile* file = new TFile(plotName.Data(), "read"); TH1F* xsValue = (TH1F*) xsValue->Clone(); TH1F* xsValue_Powheg = (TH1F*) xsValue_Powheg->Clone(); TH1F* xsValue_Madgraph = (TH1F*) xsValue_Madgraph->Clone(); TH1F* xsValue_MCnlo = (TH1F*) xsValue_MCnlo->Clone(); TH1F* systHisto = (TH1F*) systHisto->Clone(); TCanvas* canvas ; TPad *pad1, *pad2; if (drawRatio) { canvas = new TCanvas("wwxs", "wwxs", 550, 1.2*600); pad1 = new TPad("pad1", "pad1", 0, 0.3, 1, 1); pad1->SetTopMargin (0.05); pad1->SetBottomMargin(0.02); pad1->Draw(); pad2 = new TPad("pad2", "pad2", 0, 0, 1, 0.31); pad2->SetTopMargin (0.08); pad2->SetBottomMargin(0.35); pad2->Draw(); } else { canvas = new TCanvas("wwxs", "wwxs", 550, 550); } if (drawRatio) pad1->cd(); //Plot Data xsValue->SetLineWidth(1); xsValue->SetMarkerSize(1.0); int NBins = xsValue->GetNbinsX(); for(int i=1; i <NBins; i++) { float err_stat = xsValue->GetBinError(i); float err_syst = systHisto->GetBinError(i); float err_total = sqrt(err_stat*err_stat + err_syst*err_syst); xsValue->SetBinError(i, err_total); } //-- Plot Powheg TH1F *hpowError = (TH1F*) xsValue_Powheg->Clone(); xsValue_Powheg->SetMarkerColor(kAzure-3); xsValue_Powheg->SetLineWidth(1); xsValue_Powheg->SetLineColor(kBlue+2); xsValue_Powheg->SetMarkerStyle(22); xsValue_Powheg->SetMarkerSize(1.2); hpowError->SetLineWidth(0); hpowError->SetMarkerSize ( 0); hpowError->SetFillColor (kAzure-9); //-- Plot Madgraph TH1F *hmadError = (TH1F*) xsValue_Madgraph->Clone(); xsValue_Madgraph->SetMarkerColor(kPink-9); xsValue_Madgraph->SetLineWidth(1); xsValue_Madgraph->SetLineStyle(1); xsValue_Madgraph->SetMarkerStyle(21); xsValue_Madgraph->SetMarkerSize(1.0); hmadError->SetLineWidth(0); hmadError->SetMarkerSize ( 0); hmadError->SetFillColor (kPink+1); //-- Plot MCNLO TH1F *hmcError = (TH1F*) xsValue_MCnlo->Clone(); xsValue_MCnlo->SetMarkerColor(kRed); xsValue_MCnlo->SetLineColor(kRed); xsValue_MCnlo->SetLineWidth(1); xsValue_MCnlo->SetLineStyle(1); xsValue_MCnlo->SetMarkerStyle(24); xsValue_MCnlo->SetMarkerSize(1.0); hmcError->SetLineWidth(0); hmcError->SetMarkerSize ( 0); hmcError->SetFillColor (kOrange); //-- Plot Data xsValue->SetMarkerStyle(kFullCircle); if (differential == 0) AxisFonts (xsValue->GetYaxis(), "#frac{1}{#sigma} #frac{d#sigma}{dp_{T,max}^{l}}"); if (differential == 1) AxisFonts (xsValue->GetYaxis(), "#frac{1}{#sigma} #frac{d#sigma}{dp_{T}(ll)}"); if (differential == 2) AxisFonts (xsValue->GetYaxis(), "#frac{1}{#sigma} #frac{d#sigma}{dm_{#font[12]{ll}}}"); if (differential == 3) AxisFonts (xsValue->GetYaxis(), "#frac{1}{#sigma} #frac{d#sigma}{d#Delta#phi_{ll}}"); AxisFonts (xsValue->GetXaxis(), XTitle); xsValue->Draw("p"); hmadError->Draw("e2,same"); xsValue_Madgraph->Draw("pe1,same"); hmcError->Draw("e2,same"); xsValue_MCnlo->Draw("pe1,same"); hpowError->Draw("e2,same"); xsValue_Powheg->Draw("pe1,same"); //systHisto->Draw("e2, same"); xsValue->Draw("pe1,same"); // Legend //---------------------------------------------------------------------------- DrawLegend (0.65, 0.85, xsValue, "Data", "P"); DrawLegend (0.65, 0.80, hpowError, "", "F"); DrawLegend (0.65, 0.80, xsValue_Powheg, "Powheg", "PL"); DrawLegend (0.65, 0.75, hmadError, "", "F"); DrawLegend (0.65, 0.75, xsValue_Madgraph, "Madgraph", "PL"); DrawLegend (0.65, 0.70, hmcError, "", "F"); DrawLegend (0.65, 0.70, xsValue_MCnlo, "MCNLO", "LP"); canvas->GetFrame()->DrawClone(); // Draw text //---------------------------------------------------------------------------- TLatex * CMSLabel = new TLatex (0.18, 0.96, "#bf{CMS}"); CMSLabel->SetNDC (); CMSLabel->SetTextAlign (10); CMSLabel->SetTextFont (42); CMSLabel->SetTextSize (_tsize); CMSLabel->Draw ("same") ; TLatex * _lumiLabel = new TLatex (0.95, 0.96, "19.4fb#lower[0.3]{^{-1}} (8 TeV)"); _lumiLabel->SetNDC (); _lumiLabel->SetTextAlign (30); _lumiLabel->SetTextFont (42); _lumiLabel->SetTextSize (_tsize); _lumiLabel->Draw ("same") ; // Draw also ratio //---------------------------------------------------------------------------- if (drawRatio) { pad2->cd(); TH1F* ratio_pow = xsValue_Powheg->Clone("ratio"); TH1F* ratio_mad = xsValue_Madgraph->Clone("ratio"); TH1F* ratio_mcnlo = xsValue_MCnlo->Clone("ratio"); TH1F* hratio_pow = xsValue_Powheg->Clone("ratio"); TH1F* hratio_mad = xsValue_Madgraph->Clone("ratio"); TH1F* hratio_mcnlo = xsValue_MCnlo->Clone("ratio"); TH1F* ratioErr = xsValue->Clone("ratio"); for (UInt_t ibin=1; ibin<=ratio->GetNbinsX(); ibin++) { Double_t powValue = xsValue_Powheg->GetBinContent(ibin); Double_t powError = xsValue_Powheg->GetBinError (ibin); Double_t madValue = xsValue_Madgraph->GetBinContent(ibin); Double_t madError = xsValue_Madgraph->GetBinError (ibin); Double_t mcnloValue = xsValue_MCnlo->GetBinContent(ibin); Double_t mcnloError = xsValue_MCnlo->GetBinError (ibin); Double_t dataValue = xsValue->GetBinContent(ibin); Double_t statError = xsValue->GetBinError (ibin); Double_t systError = systHisto->GetBinError(ibin); Double_t dataError = systError; Double_t ratioValue_pow = (powValue > 0) ? powValue/dataValue : 0.0; Double_t ratioError_pow = (powValue > 0) ? powError / dataValue : 0.0; Double_t ratioValue_mad = (madValue > 0) ? madValue/dataValue : 0.0; Double_t ratioError_mad = (madValue > 0) ? madError/dataValue : 0.0; Double_t ratioValue_mcnlo = (mcnloValue > 0) ? mcnloValue/dataValue : 0.0; Double_t ratioError_mcnlo = (mcnloValue > 0) ? mcnloError/dataValue : 0.0; Double_t uncertaintyError = (dataValue > 0) ? dataError/dataValue : 0.0; //dataError/dataValue ratio_pow->SetBinContent(ibin, ratioValue_pow); hratio_pow->SetBinContent(ibin, ratioValue_pow); hratio_pow->SetBinError (ibin, ratioError_pow); ratio_mad->SetBinContent(ibin, ratioValue_mad); hratio_mad->SetBinContent(ibin, ratioValue_mad); hratio_mad->SetBinError (ibin, ratioError_mad); ratio_mcnlo->SetBinContent(ibin, ratioValue_mcnlo); hratio_mcnlo->SetBinContent(ibin, ratioValue_mcnlo); hratio_mcnlo->SetBinError (ibin, ratioError_mcnlo); ratioErr->SetBinContent(ibin, 1.0); ratioErr->SetBinError (ibin, uncertaintyError); } ratioErr->SetTitle(""); ratioErr ->Draw("e2"); ratio_mad ->SetLineColor(kPink-9); ratio_mad ->SetMarkerSize(1.0); ratio_mad ->SetLineWidth(1); ratio_mad ->SetMarkerStyle(21); hratio_mad ->SetLineWidth(0); hratio_mad ->SetMarkerSize ( 0); hratio_mad ->SetFillColor (kPink+1); hratio_mad ->SetFillStyle (1001); hratio_mad ->Draw("e2,same"); ratio_mad ->Draw("e1p,same"); ratio_mcnlo ->SetLineColor(kRed); ratio_mcnlo ->SetMarkerSize(1.0); ratio_mcnlo ->SetLineWidth(1); ratio_mcnlo ->SetMarkerStyle(24); hratio_mcnlo ->SetLineWidth(0); hratio_mcnlo ->SetMarkerSize ( 0); hratio_mcnlo ->SetFillColor (kOrange); hratio_mcnlo ->SetFillStyle (1001); hratio_mcnlo ->Draw("e2,same"); ratio_mcnlo ->Draw("ep,same"); ratio_pow ->SetLineColor(kAzure-3); ratio_pow ->SetMarkerSize(1.2); ratio_pow ->SetLineWidth(1); ratio_pow ->SetMarkerStyle(22); hratio_pow ->SetLineWidth(0); hratio_pow ->SetMarkerSize ( 0); hratio_pow ->SetFillColor (kAzure-9); hratio_pow ->SetFillStyle (1001); hratio_pow ->Draw("e2,same"); ratio_pow ->Draw("e1p,same"); ratioErr->SetFillColor (kGray+2); ratioErr->SetFillStyle ( 3345); ratioErr->SetLineColor (kGray+2); ratioErr->SetMarkerColor(kGray+2); ratioErr->SetMarkerSize ( 0); ratioErr->Draw("sameaxis"); ratioErr->GetYaxis()->SetRangeUser(0.4, 1.6); AxisFontsRatio (ratioErr->GetYaxis(), "y", "MC/data"); AxisFontsRatio (ratioErr->GetXaxis(), "x", XTitle); } }
void isoOpt2012db(){ // gROOT->LoadMacro("tdrStyle.C"); gROOT->LoadMacro("tdrstyle.C"); setTDRStyle(); TString srcDir ="/afs/cern.ch/work/t/taeyeon/cmssw/CMGTools/CMSSW_5_3_3_patch3/src/KoPFA/IsoAnalyzer/test/MuonOut/MuMuDec25/"; // 2 bJets // TString srcDir2 ="/afs/cern.ch/work/t/taeyeon/cmssw/CMGTools/CMSSW_5_3_3_patch3/src/KoPFA/IsoAnalyzer/test/MuonOut/MuMuDec26TTbarbtag1/"; // TString srcDir2 ="/afs/cern.ch/work/t/taeyeon/cmssw/CMGTools/CMSSW_5_3_3_patch3/src/KoPFA/IsoAnalyzer/test/MuonOut/MuMuDec30TTbar2jets/"; // TString plots ="./plots_isoOpt2012db/"; //TFile * fSIG = new TFile(srcDir+"vallot_ZJets.root"); //TFile * fQCDmc = new TFile(srcDir+"vallot_QCDMuon.root"); //TFile * fSIG = new TFile(srcDir+"MuonIso_Run2012MuMu.root"); TFile * fSIG = new TFile(srcDir2+"vallot_TTbarTuneZ2.root"); TFile * fRD = new TFile(srcDir+"MuonIso_Run2012MuMu.root"); //////////////////////////////////////////////////////////////////////////////// TCanvas *c0=new TCanvas("c0","2dQCDiso",400,400); TH2F * h2_QCD_iso = (TH2F*) fRD->Get("MuonAnalysis/h2_QCDMuonsIso03"); h2_QCD_iso->GetXaxis()->SetTitleSize(0.05); h2_QCD_iso->GetYaxis()->SetTitleSize(0.05); h2_QCD_iso->GetXaxis()->SetTitle("Relative Isolation (Leg1)"); h2_QCD_iso->GetYaxis()->SetTitle("Relative Isolation (Leg2)"); h2_QCD_iso->Draw("colZ"); c0->Print(plots+"2dQCDiso.png"); c0->Print(plots+"2dQCDiso.pdf"); //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// TCanvas *c1=new TCanvas("c1","2dQCDpt",400,400); TH2F * h2_QCD_pt = (TH2F*) fRD->Get("MuonAnalysis/h2_QCDMuonsPt"); h2_QCD_pt->GetXaxis()->SetTitleSize(0.05); h2_QCD_pt->GetYaxis()->SetTitleSize(0.05); h2_QCD_pt->GetXaxis()->SetTitle("P_{T} (Leg1)(GeV/c)"); h2_QCD_pt->GetYaxis()->SetTitle("P_{T} (Leg2)(GeV/c)"); h2_QCD_pt->Draw("colZ"); c1->Print(plots+"2dQCDpt.png"); c1->Print(plots+"2dQCDpt.pdf"); //////////////////////////////////////////////////////////////////////////////// TCanvas *c2=new TCanvas("c2","QCD_",400,400); c2->SetLogy(); c2->Divide(2,2); TH2F * h2_QCD_pfRelIso02 = (TH2F*) fRD->Get("MuonAnalysis/QCD/IDLoose/h2_pfRelIso02_vtx"); TH2F * h2_QCD_pfRelIso03 = (TH2F*) fRD->Get("MuonAnalysis/QCD/IDLoose/h2_pfRelIso03_vtx"); TH2F * h2_QCD_pfRelIso04 = (TH2F*) fRD->Get("MuonAnalysis/QCD/IDLoose/h2_pfRelIso04_vtx"); TH1D* hQCD_pfRelIso02_lowPU = h2_QCD_pfRelIso02->ProjectionY("hQCD_pfRelIso02_lowPU",1,14); TH1D* hQCD_pfRelIso03_lowPU = h2_QCD_pfRelIso03->ProjectionY("hQCD_pfRelIso03_lowPU",1,14); TH1D* hQCD_pfRelIso04_lowPU = h2_QCD_pfRelIso04->ProjectionY("hQCD_pfRelIso04_lowPU",1,14); TH1D* hQCD_pfRelIso02_hiPU = h2_QCD_pfRelIso02->ProjectionY("hQCD_pfRelIso02_hiPU",15,50); TH1D* hQCD_pfRelIso03_hiPU = h2_QCD_pfRelIso03->ProjectionY("hQCD_pfRelIso03_hiPU",15,50); TH1D* hQCD_pfRelIso04_hiPU = h2_QCD_pfRelIso04->ProjectionY("hQCD_pfRelIso04_hiPU",15,50); hQCD_pfRelIso02_lowPU->GetXaxis()->SetRangeUser(0,1.0); hQCD_pfRelIso03_lowPU->GetXaxis()->SetRangeUser(0,1.0); hQCD_pfRelIso04_lowPU->GetXaxis()->SetRangeUser(0,1.0); hQCD_pfRelIso02_hiPU->GetXaxis()->SetRangeUser(0,1.0); hQCD_pfRelIso03_hiPU->GetXaxis()->SetRangeUser(0,1.0); hQCD_pfRelIso04_hiPU->GetXaxis()->SetRangeUser(0,1.0); c2->cd(1); gPad->SetLogy(); hQCD_pfRelIso02_lowPU->SetLineColor(1); hQCD_pfRelIso02_lowPU->Draw(); hQCD_pfRelIso02_hiPU->SetLineColor(6); hQCD_pfRelIso02_hiPU->Draw("same"); c2->cd(2); gPad->SetLogy(); hQCD_pfRelIso03_lowPU->SetLineColor(2); hQCD_pfRelIso03_lowPU->Draw(); hQCD_pfRelIso03_hiPU->SetLineColor(28); hQCD_pfRelIso03_hiPU->Draw("same"); c2->cd(3); gPad->SetLogy(); hQCD_pfRelIso04_lowPU->SetLineColor(4); hQCD_pfRelIso04_lowPU->Draw(); hQCD_pfRelIso04_hiPU->SetLineColor(8); hQCD_pfRelIso04_hiPU->Draw("same"); c2->cd(4); gPad->SetLogy(); hQCD_pfRelIso02_lowPU->Draw(); hQCD_pfRelIso03_lowPU->Draw("same"); hQCD_pfRelIso04_lowPU->Draw("same"); hQCD_pfRelIso02_hiPU->Draw("same"); hQCD_pfRelIso03_hiPU->Draw("same"); hQCD_pfRelIso04_hiPU->Draw("same"); c2->Print(plots+"QCD.png"); c2->Print(plots+"QCD.pdf"); TCanvas *c22=new TCanvas("c22","QCD()",400,400); gPad->SetLogy(); hQCD_pfRelIso04_lowPU->Draw(); hQCD_pfRelIso03_lowPU->Draw("same"); hQCD_pfRelIso02_lowPU->Draw("same"); hQCD_pfRelIso02_lowPU->GetXaxis()->SetTitle("RelIso"); hQCD_pfRelIso03_lowPU->GetXaxis()->SetTitle("RelIso"); hQCD_pfRelIso04_lowPU->GetXaxis()->SetTitle("RelIso"); c22->Print(plots+"PUQCD2.png"); c22->Print(plots+"PUQCD2.pdf"); //////////////////////////////////////////////////////////////////////////////// TCanvas *c2db=new TCanvas("c2db","QCD_db",400,400); c2db->SetLogy(); c2db->Divide(2,2); TH2F * h2_QCD_pfRelIso02db = (TH2F*) fRD->Get("MuonAnalysis/QCD/IDLoose/h2_pfRelIso02db_vtx"); TH2F * h2_QCD_pfRelIso03db = (TH2F*) fRD->Get("MuonAnalysis/QCD/IDLoose/h2_pfRelIso03db_vtx"); TH2F * h2_QCD_pfRelIso04db = (TH2F*) fRD->Get("MuonAnalysis/QCD/IDLoose/h2_pfRelIso04db_vtx"); TH1D* hQCD_pfRelIso02db_lowPU = h2_QCD_pfRelIso02db->ProjectionY("hQCD_pfRelIso02db_lowPU",1,14); TH1D* hQCD_pfRelIso03db_lowPU = h2_QCD_pfRelIso03db->ProjectionY("hQCD_pfRelIso03db_lowPU",1,14); TH1D* hQCD_pfRelIso04db_lowPU = h2_QCD_pfRelIso04db->ProjectionY("hQCD_pfRelIso04db_lowPU",1,14); TH1D* hQCD_pfRelIso02db_hiPU = h2_QCD_pfRelIso02db->ProjectionY("hQCD_pfRelIso02db_hiPU",15,50); TH1D* hQCD_pfRelIso03db_hiPU = h2_QCD_pfRelIso03db->ProjectionY("hQCD_pfRelIso03db_hiPU",15,50); TH1D* hQCD_pfRelIso04db_hiPU = h2_QCD_pfRelIso04db->ProjectionY("hQCD_pfRelIso04db_hiPU",15,50); hQCD_pfRelIso02db_lowPU->GetXaxis()->SetRangeUser(0,1.0); hQCD_pfRelIso03db_lowPU->GetXaxis()->SetRangeUser(0,1.0); hQCD_pfRelIso04db_lowPU->GetXaxis()->SetRangeUser(0,1.0); hQCD_pfRelIso02db_hiPU->GetXaxis()->SetRangeUser(0,1.0); hQCD_pfRelIso03db_hiPU->GetXaxis()->SetRangeUser(0,1.0); hQCD_pfRelIso04db_hiPU->GetXaxis()->SetRangeUser(0,1.0); c2db->cd(1); gPad->SetLogy(); hQCD_pfRelIso02db_lowPU->SetLineColor(1); hQCD_pfRelIso02db_lowPU->Draw(); hQCD_pfRelIso02db_hiPU->SetLineColor(6); hQCD_pfRelIso02db_hiPU->Draw("same"); c2db->cd(2); gPad->SetLogy(); hQCD_pfRelIso03db_lowPU->SetLineColor(2); hQCD_pfRelIso03db_lowPU->Draw(); hQCD_pfRelIso03db_hiPU->SetLineColor(28); hQCD_pfRelIso03db_hiPU->Draw("same"); c2db->cd(3); gPad->SetLogy(); hQCD_pfRelIso04db_lowPU->SetLineColor(4); hQCD_pfRelIso04db_lowPU->Draw(); hQCD_pfRelIso04db_hiPU->SetLineColor(8); hQCD_pfRelIso04db_hiPU->Draw("same"); c2db->cd(4); gPad->SetLogy(); hQCD_pfRelIso02db_lowPU->Draw(); hQCD_pfRelIso03db_lowPU->Draw("same"); hQCD_pfRelIso04db_lowPU->Draw("same"); hQCD_pfRelIso02db_hiPU->Draw("same"); hQCD_pfRelIso03db_hiPU->Draw("same"); hQCD_pfRelIso04db_hiPU->Draw("same"); c2db->Print(plots+"QCDdb.png"); c2db->Print(plots+"QCDdb.pdf"); TCanvas *c2db2=new TCanvas("c2db2","QCD(db)",400,400); gPad->SetLogy(); hQCD_pfRelIso04db_lowPU->Draw(); hQCD_pfRelIso03db_lowPU->Draw("same"); hQCD_pfRelIso02db_lowPU->Draw("same"); hQCD_pfRelIso02db_lowPU->GetXaxis()->SetTitle("RelIso"); hQCD_pfRelIso03db_lowPU->GetXaxis()->SetTitle("RelIso"); hQCD_pfRelIso04db_lowPU->GetXaxis()->SetTitle("RelIso"); c2db2->Print(plots+"PUQCDdb2.png"); c2db2->Print(plots+"PUQCDdb2.pdf"); //////////////////////////////////////////////////////////////////////////////// TCanvas *c4db=new TCanvas("c4db","SIG_db",400,400); c4db->SetLogy(); c4db->Divide(2,2); TH2F * h2_SIG_pfRelIso02db = (TH2F*) fSIG->Get("MuonAnalysis/Signal/IDLoose/h2_pfRelIso02db_vtx"); TH2F * h2_SIG_pfRelIso03db = (TH2F*) fSIG->Get("MuonAnalysis/Signal/IDLoose/h2_pfRelIso03db_vtx"); TH2F * h2_SIG_pfRelIso04db = (TH2F*) fSIG->Get("MuonAnalysis/Signal/IDLoose/h2_pfRelIso04db_vtx"); TH1D* hSIG_pfRelIso02db_lowPU = h2_SIG_pfRelIso02db->ProjectionY("hSIG_pfRelIso02db_lowPU",1,14); TH1D* hSIG_pfRelIso03db_lowPU = h2_SIG_pfRelIso03db->ProjectionY("hSIG_pfRelIso03db_lowPU",1,14); TH1D* hSIG_pfRelIso04db_lowPU = h2_SIG_pfRelIso04db->ProjectionY("hSIG_pfRelIso04db_lowPU",1,14); TH1D* hSIG_pfRelIso02db_hiPU = h2_SIG_pfRelIso02db->ProjectionY("hSIG_pfRelIso02db_hiPU",15,50); TH1D* hSIG_pfRelIso03db_hiPU = h2_SIG_pfRelIso03db->ProjectionY("hSIG_pfRelIso03db_hiPU",15,50); TH1D* hSIG_pfRelIso04db_hiPU = h2_SIG_pfRelIso04db->ProjectionY("hSIG_pfRelIso04db_hiPU",15,50); hSIG_pfRelIso02db_lowPU->GetXaxis()->SetRangeUser(0,1.0); hSIG_pfRelIso03db_lowPU->GetXaxis()->SetRangeUser(0,1.0); hSIG_pfRelIso04db_lowPU->GetXaxis()->SetRangeUser(0,1.0); hSIG_pfRelIso02db_hiPU->GetXaxis()->SetRangeUser(0,1.0); hSIG_pfRelIso03db_hiPU->GetXaxis()->SetRangeUser(0,1.0); hSIG_pfRelIso04db_hiPU->GetXaxis()->SetRangeUser(0,1.0); c4db->cd(1); gPad->SetLogy(); hSIG_pfRelIso02db_lowPU->SetLineColor(1); hSIG_pfRelIso02db_lowPU->Draw(); hSIG_pfRelIso02db_hiPU->SetLineColor(6); hSIG_pfRelIso02db_hiPU->Draw("same"); c4db->cd(2); gPad->SetLogy(); hSIG_pfRelIso03db_lowPU->SetLineColor(2); hSIG_pfRelIso03db_lowPU->Draw(); hSIG_pfRelIso03db_hiPU->SetLineColor(28); hSIG_pfRelIso03db_hiPU->Draw("same"); c4db->cd(3); gPad->SetLogy(); hSIG_pfRelIso04db_lowPU->SetLineColor(4); hSIG_pfRelIso04db_lowPU->Draw(); hSIG_pfRelIso04db_hiPU->SetLineColor(8); hSIG_pfRelIso04db_hiPU->Draw("same"); c4db->cd(4); gPad->SetLogy(); hSIG_pfRelIso02db_lowPU->Draw(); hSIG_pfRelIso03db_lowPU->Draw("same"); hSIG_pfRelIso04db_lowPU->Draw("same"); hSIG_pfRelIso02db_hiPU->Draw("same"); hSIG_pfRelIso03db_hiPU->Draw("same"); hSIG_pfRelIso04db_hiPU->Draw("same"); c4db->Print(plots+"signaldb.png"); c4db->Print(plots+"signaldb.pdf"); TCanvas *c4db2=new TCanvas("c4db2","SIG(db)",400,400); gPad->SetLogy(); hSIG_pfRelIso04db_lowPU->Draw(); hSIG_pfRelIso03db_lowPU->Draw("same"); hSIG_pfRelIso02db_lowPU->Draw("same"); hSIG_pfRelIso02db_lowPU->GetXaxis()->SetTitle("RelIso"); hSIG_pfRelIso03db_lowPU->GetXaxis()->SetTitle("RelIso"); hSIG_pfRelIso04db_lowPU->GetXaxis()->SetTitle("RelIso"); c4db2->Print(plots+"PUsignaldb2.png"); c4db2->Print(plots+"PUsignaldb2.pdf"); //////////////////////////////////////////////////////////////////////////////// TCanvas *c4=new TCanvas("c4","SIG_",400,400); c4->SetLogy(); c4->Divide(2,2); TH2F * h2_SIG_pfRelIso02 = (TH2F*) fSIG->Get("MuonAnalysis/Signal/IDLoose/h2_pfRelIso02_vtx"); TH2F * h2_SIG_pfRelIso03 = (TH2F*) fSIG->Get("MuonAnalysis/Signal/IDLoose/h2_pfRelIso03_vtx"); TH2F * h2_SIG_pfRelIso04 = (TH2F*) fSIG->Get("MuonAnalysis/Signal/IDLoose/h2_pfRelIso04_vtx"); TH1D* hSIG_pfRelIso02_lowPU = h2_SIG_pfRelIso02->ProjectionY("hSIG_pfRelIso02_lowPU",1,14); TH1D* hSIG_pfRelIso03_lowPU = h2_SIG_pfRelIso03->ProjectionY("hSIG_pfRelIso03_lowPU",1,14); TH1D* hSIG_pfRelIso04_lowPU = h2_SIG_pfRelIso04->ProjectionY("hSIG_pfRelIso04_lowPU",1,14); TH1D* hSIG_pfRelIso02_hiPU = h2_SIG_pfRelIso02->ProjectionY("hSIG_pfRelIso02_hiPU",15,50); TH1D* hSIG_pfRelIso03_hiPU = h2_SIG_pfRelIso03->ProjectionY("hSIG_pfRelIso03_hiPU",15,50); TH1D* hSIG_pfRelIso04_hiPU = h2_SIG_pfRelIso04->ProjectionY("hSIG_pfRelIso04_hiPU",15,50); hSIG_pfRelIso02_lowPU->GetXaxis()->SetRangeUser(0,1.0); hSIG_pfRelIso03_lowPU->GetXaxis()->SetRangeUser(0,1.0); hSIG_pfRelIso04_lowPU->GetXaxis()->SetRangeUser(0,1.0); hSIG_pfRelIso02_hiPU->GetXaxis()->SetRangeUser(0,1.0); hSIG_pfRelIso03_hiPU->GetXaxis()->SetRangeUser(0,1.0); hSIG_pfRelIso04_hiPU->GetXaxis()->SetRangeUser(0,1.0); c4->cd(1); gPad->SetLogy(); hSIG_pfRelIso02_lowPU->SetLineColor(1); hSIG_pfRelIso02_lowPU->Draw(); hSIG_pfRelIso02_hiPU->SetLineColor(6); hSIG_pfRelIso02_hiPU->Draw("same"); c4->cd(2); gPad->SetLogy(); hSIG_pfRelIso03_lowPU->SetLineColor(2); hSIG_pfRelIso03_lowPU->Draw(); hSIG_pfRelIso03_hiPU->SetLineColor(28); hSIG_pfRelIso03_hiPU->Draw("same"); c4->cd(3); gPad->SetLogy(); hSIG_pfRelIso04_lowPU->SetLineColor(4); hSIG_pfRelIso04_lowPU->Draw(); hSIG_pfRelIso04_hiPU->SetLineColor(8); hSIG_pfRelIso04_hiPU->Draw("same"); c4->cd(4); gPad->SetLogy(); hSIG_pfRelIso02_lowPU->Draw(); hSIG_pfRelIso03_lowPU->Draw("same"); hSIG_pfRelIso04_lowPU->Draw("same"); hSIG_pfRelIso02_hiPU->Draw("same"); hSIG_pfRelIso03_hiPU->Draw("same"); hSIG_pfRelIso04_hiPU->Draw("same"); c4->Print(plots+"signal.png"); c4->Print(plots+"signal.pdf"); TCanvas *c42=new TCanvas("c42","SIG()",400,400); gPad->SetLogy(); hSIG_pfRelIso04_lowPU->Draw(); hSIG_pfRelIso03_lowPU->Draw("same"); hSIG_pfRelIso02_lowPU->Draw("same"); hSIG_pfRelIso02_lowPU->GetXaxis()->SetTitle("RelIso"); hSIG_pfRelIso03_lowPU->GetXaxis()->SetTitle("RelIso"); hSIG_pfRelIso04_lowPU->GetXaxis()->SetTitle("RelIso"); c42->Print(plots+"PUsignal2.png"); c42->Print(plots+"PUsignal2.pdf"); //////////////////////////////////////////////////////////////////////////////// TCanvas *c5 = new TCanvas("c5","ROC-SIG_QCD",400,400); c5->SetTickx(); c5->SetTicky(); gROC_SIG03_lowPU = ROC(hSIG_pfRelIso03_lowPU, hQCD_pfRelIso03_lowPU); gROC_SIG04_lowPU = ROC(hSIG_pfRelIso04_lowPU, hQCD_pfRelIso04_lowPU); gROC_SIG03_hiPU = ROC(hSIG_pfRelIso03_hiPU, hQCD_pfRelIso03_hiPU); gROC_SIG04_hiPU = ROC(hSIG_pfRelIso04_hiPU, hQCD_pfRelIso04_hiPU); GraphStyle(gROC_SIG03_lowPU, 2, 23); GraphStyle(gROC_SIG04_lowPU, 4, 22); GraphStyle(gROC_SIG03_hiPU, 28, 2); GraphStyle(gROC_SIG04_hiPU, 8, 5); gROC_SIG04_lowPU->GetXaxis()->SetRangeUser(0,0.15); gROC_SIG04_lowPU->SetMaximum(0.96); gROC_SIG04_lowPU->SetMinimum(0.6); gROC_SIG04_lowPU->Draw("ACP"); gROC_SIG03_lowPU->Draw("CPsame"); gROC_SIG04_hiPU->Draw("CPsame"); gROC_SIG03_hiPU->Draw("CPsame"); TLegend *l= new TLegend(0.45,0.38,0.83,0.18); DrawLegend(gROC_SIG03_lowPU, l, "Cone R=0.3 (low PU)","PL"); DrawLegend(gROC_SIG04_lowPU, l, "Cone R=0.4 (low PU)","PL"); DrawLegend(gROC_SIG03_hiPU, l, "Cone R=0.3 (high PU)","PL"); DrawLegend(gROC_SIG04_hiPU, l, "Cone R=0.4 (high PU)","PL"); TGraphAsymmErrors* gr03_lowPU = new TGraphAsymmErrors(); TGraphAsymmErrors* gr04_lowPU = new TGraphAsymmErrors(); TGraphAsymmErrors* gr03_hiPU = new TGraphAsymmErrors(); TGraphAsymmErrors* gr04_hiPU = new TGraphAsymmErrors(); double effQcd3,effSignal3,effQcd4,effSignal4; double effQcd3high,effSignal3high,effQcd4high,effSignal4high; gROC_SIG03_lowPU->GetPoint(14,effQcd3,effSignal3); gROC_SIG04_lowPU->GetPoint(19,effQcd4,effSignal4); gROC_SIG03_hiPU->GetPoint(14,effQcd3high,effSignal3high); gROC_SIG04_hiPU->GetPoint(19,effQcd4high,effSignal4high); gr03_lowPU->SetPoint(1, effQcd3,effSignal3); gr04_lowPU->SetPoint(1, effQcd4,effSignal4); gr03_hiPU->SetPoint(1, effQcd3high,effSignal3high); gr04_hiPU->SetPoint(1, effQcd4high,effSignal4high); gr03_lowPU->SetMarkerStyle(34); gr03_lowPU->SetMarkerSize(2.5); gr03_lowPU->SetMarkerColor(2); gr03_lowPU->SetLineWidth(3); gr04_lowPU->SetMarkerStyle(34); gr04_lowPU->SetMarkerSize(2.5); gr04_lowPU->SetMarkerColor(4); gr04_lowPU->SetLineWidth(3); gr03_hiPU->SetMarkerStyle(34); gr03_hiPU->SetMarkerSize(2.5); gr03_hiPU->SetMarkerColor(28); gr03_hiPU->SetLineWidth(3); gr04_hiPU->SetMarkerStyle(34); gr04_hiPU->SetMarkerSize(2.5); gr04_hiPU->SetMarkerColor(8); gr04_hiPU->SetLineWidth(3); gr03_lowPU->Draw("P"); gr04_lowPU->Draw("Psame"); gr03_hiPU->Draw("Psame"); gr04_hiPU->Draw("Psame"); TLatex *label= new TLatex; label->SetNDC(); label->SetTextSize(0.04); label->DrawLatex(0.45,0.40,"No Delta-beta Correction"); label->Draw(); c5->Print(plots+"PUroc.png"); c5->Print(plots+"PUroc.pdf"); //////////////////////////////////////////////////////////////////////////////// TCanvas *c5db = new TCanvas("c5db","ROC-SIG_QCD-db",400,400); c5db->SetTickx(); c5db->SetTicky(); gROC_SIG03_lowPUdb = ROC(hSIG_pfRelIso03db_lowPU, hQCD_pfRelIso03db_lowPU); gROC_SIG04_lowPUdb = ROC(hSIG_pfRelIso04db_lowPU, hQCD_pfRelIso04db_lowPU); gROC_SIG03_hiPUdb = ROC(hSIG_pfRelIso03db_hiPU, hQCD_pfRelIso03db_hiPU); gROC_SIG04_hiPUdb = ROC(hSIG_pfRelIso04db_hiPU, hQCD_pfRelIso04db_hiPU); GraphStyle(gROC_SIG03_lowPUdb, 2, 23); GraphStyle(gROC_SIG04_lowPUdb, 4, 22); GraphStyle(gROC_SIG03_hiPUdb, 28, 2); GraphStyle(gROC_SIG04_hiPUdb, 8, 5); gROC_SIG04_lowPUdb->GetXaxis()->SetRangeUser(0,0.15); gROC_SIG04_lowPUdb->SetMaximum(0.96); gROC_SIG04_lowPUdb->SetMinimum(0.6); gROC_SIG04_lowPUdb->Draw("ACP"); gROC_SIG03_lowPUdb->Draw("CPsame"); gROC_SIG04_hiPUdb->Draw("CPsame"); gROC_SIG03_hiPUdb->Draw("CPsame"); TLegend *l= new TLegend(0.45,0.38,0.83,0.18); DrawLegend(gROC_SIG03_lowPUdb, l, "Cone R=0.3 (low PU)","PL"); DrawLegend(gROC_SIG04_lowPUdb, l, "Cone R=0.4 (low PU)","PL"); DrawLegend(gROC_SIG03_hiPUdb, l, "Cone R=0.3 (high PU)","PL"); DrawLegend(gROC_SIG04_hiPUdb, l, "Cone R=0.4 (high PU)","PL"); TGraphAsymmErrors* gr03_lowPUdb = new TGraphAsymmErrors(); TGraphAsymmErrors* gr04_lowPUdb = new TGraphAsymmErrors(); TGraphAsymmErrors* gr03_hiPUdb = new TGraphAsymmErrors(); TGraphAsymmErrors* gr04_hiPUdb = new TGraphAsymmErrors(); double effQcd3,effSignal3,effQcd4,effSignal4; double effQcd3high,effSignal3high,effQcd4high,effSignal4high; gROC_SIG03_lowPUdb->GetPoint(14,effQcd3,effSignal3); gROC_SIG04_lowPUdb->GetPoint(19,effQcd4,effSignal4); gROC_SIG03_hiPUdb->GetPoint(14,effQcd3high,effSignal3high); gROC_SIG04_hiPUdb->GetPoint(19,effQcd4high,effSignal4high); gr03_lowPUdb->SetPoint(1, effQcd3,effSignal3); gr04_lowPUdb->SetPoint(1, effQcd4,effSignal4); gr03_hiPUdb->SetPoint(1, effQcd3high,effSignal3high); gr04_hiPUdb->SetPoint(1, effQcd4high,effSignal4high); gr03_lowPUdb->SetMarkerStyle(34); gr03_lowPUdb->SetMarkerSize(2.5); gr03_lowPUdb->SetMarkerColor(2); gr03_lowPUdb->SetLineWidth(3); gr04_lowPUdb->SetMarkerStyle(34); gr04_lowPUdb->SetMarkerSize(2.5); gr04_lowPUdb->SetMarkerColor(4); gr04_lowPUdb->SetLineWidth(3); gr03_hiPUdb->SetMarkerStyle(34); gr03_hiPUdb->SetMarkerSize(2.5); gr03_hiPUdb->SetMarkerColor(28); gr03_hiPUdb->SetLineWidth(3); gr04_hiPUdb->SetMarkerStyle(34); gr04_hiPUdb->SetMarkerSize(2.5); gr04_hiPUdb->SetMarkerColor(8); gr04_hiPUdb->SetLineWidth(3); gr03_lowPUdb->Draw("P"); gr04_lowPUdb->Draw("Psame"); gr03_hiPUdb->Draw("Psame"); gr04_hiPUdb->Draw("Psame"); TLatex *label= new TLatex; label->SetNDC(); label->SetTextSize(0.04); label->DrawLatex(0.45,0.40,"Delta-beta Correction"); label->Draw(); c5db->Print(plots+"PUrocdb.png"); c5db->Print(plots+"PUrocdb.pdf"); //////////////////////////////////////////////////////////////////////////////// TCanvas *c5low = new TCanvas("c5low","ROC-SIG_QCD-low",400,400); c5low->SetTickx(); c5low->SetTicky(); gROC_SIG03_lowPU = ROC(hSIG_pfRelIso03_lowPU, hQCD_pfRelIso03_lowPU); gROC_SIG04_lowPU = ROC(hSIG_pfRelIso04_lowPU, hQCD_pfRelIso04_lowPU); gROC_SIG03_lowPUdb = ROC(hSIG_pfRelIso03db_lowPU, hQCD_pfRelIso03db_lowPU); gROC_SIG04_lowPUdb = ROC(hSIG_pfRelIso04db_lowPU, hQCD_pfRelIso04db_lowPU); GraphStyle(gROC_SIG03_lowPU, 2, 23); GraphStyle(gROC_SIG04_lowPU, 4, 22); GraphStyle(gROC_SIG03_lowPUdb, 28, 2); GraphStyle(gROC_SIG04_lowPUdb, 8, 5); gROC_SIG04_lowPU->GetXaxis()->SetRangeUser(0,0.15); gROC_SIG04_lowPU->SetMaximum(0.96); gROC_SIG04_lowPU->SetMinimum(0.6); gROC_SIG04_lowPU->Draw("ACP"); gROC_SIG03_lowPU->Draw("CPsame"); gROC_SIG04_lowPUdb->Draw("CPsame"); gROC_SIG03_lowPUdb->Draw("CPsame"); TLegend *l= new TLegend(0.45,0.53,0.83,0.43); DrawLegend(gROC_SIG03_lowPU, l, "Cone R=0.3 (low PU)","PL"); DrawLegend(gROC_SIG04_lowPU, l, "Cone R=0.4 (low PU)","PL"); TLegend *l2= new TLegend(0.45,0.33,0.83,0.23); DrawLegend(gROC_SIG03_lowPUdb, l2, "Cone R=0.3 (low PU)","PL"); DrawLegend(gROC_SIG04_lowPUdb, l2, "Cone R=0.4 (low PU)","PL"); TGraphAsymmErrors* gr03_lowPU = new TGraphAsymmErrors(); TGraphAsymmErrors* gr04_lowPU = new TGraphAsymmErrors(); TGraphAsymmErrors* gr03_lowPUdb = new TGraphAsymmErrors(); TGraphAsymmErrors* gr04_lowPUdb = new TGraphAsymmErrors(); double effQcd3,effSignal3,effQcd4,effSignal4; double effQcd3high,effSignal3high,effQcd4high,effSignal4high; gROC_SIG03_lowPU->GetPoint(14,effQcd3,effSignal3); gROC_SIG04_lowPU->GetPoint(19,effQcd4,effSignal4); gROC_SIG03_lowPUdb->GetPoint(14,effQcd3high,effSignal3high); gROC_SIG04_lowPUdb->GetPoint(19,effQcd4high,effSignal4high); gr03_lowPU->SetPoint(1, effQcd3,effSignal3); gr04_lowPU->SetPoint(1, effQcd4,effSignal4); gr03_lowPUdb->SetPoint(1, effQcd3high,effSignal3high); gr04_lowPUdb->SetPoint(1, effQcd4high,effSignal4high); gr03_lowPU->SetMarkerStyle(34); gr03_lowPU->SetMarkerSize(2.5); gr03_lowPU->SetMarkerColor(2); gr03_lowPU->SetLineWidth(3); gr04_lowPU->SetMarkerStyle(34); gr04_lowPU->SetMarkerSize(2.5); gr04_lowPU->SetMarkerColor(4); gr04_lowPU->SetLineWidth(3); gr03_lowPUdb->SetMarkerStyle(34); gr03_lowPUdb->SetMarkerSize(2.5); gr03_lowPUdb->SetMarkerColor(28); gr03_lowPUdb->SetLineWidth(3); gr04_lowPUdb->SetMarkerStyle(34); gr04_lowPUdb->SetMarkerSize(2.5); gr04_lowPUdb->SetMarkerColor(8); gr04_lowPUdb->SetLineWidth(3); gr03_lowPU->Draw("P"); gr04_lowPU->Draw("Psame"); gr03_lowPUdb->Draw("Psame"); gr04_lowPUdb->Draw("Psame"); TLatex *label= new TLatex; label->SetNDC(); label->SetTextSize(0.04); label->DrawLatex(0.45,0.55,"No Delta-beta Correction"); label->Draw(); TLatex *label2= new TLatex; label2->SetNDC(); label2->SetTextSize(0.04); label2->DrawLatex(0.45,0.35,"Delta-beta Correction"); label2->Draw(); c5low->Print(plots+"PUroclow.png"); c5low->Print(plots+"PUroclow.pdf"); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// TCanvas *c5high = new TCanvas("c5high","ROC-SIG_QCD-high",400,400); c5high->SetTickx(); c5high->SetTicky(); gROC_SIG03_hiPU = ROC(hSIG_pfRelIso03_hiPU, hQCD_pfRelIso03_hiPU); gROC_SIG04_hiPU = ROC(hSIG_pfRelIso04_hiPU, hQCD_pfRelIso04_hiPU); gROC_SIG03_hiPUdb = ROC(hSIG_pfRelIso03db_hiPU, hQCD_pfRelIso03db_hiPU); gROC_SIG04_hiPUdb = ROC(hSIG_pfRelIso04db_hiPU, hQCD_pfRelIso04db_hiPU); GraphStyle(gROC_SIG03_hiPU, 2, 23); GraphStyle(gROC_SIG04_hiPU, 4, 22); GraphStyle(gROC_SIG03_hiPUdb, 28, 2); GraphStyle(gROC_SIG04_hiPUdb, 8, 5); gROC_SIG04_hiPU->GetXaxis()->SetRangeUser(0,0.15); gROC_SIG04_hiPU->SetMaximum(0.96); gROC_SIG04_hiPU->SetMinimum(0.6); gROC_SIG04_hiPU->Draw("ACP"); gROC_SIG03_hiPU->Draw("CPsame"); gROC_SIG04_hiPUdb->Draw("CPsame"); gROC_SIG03_hiPUdb->Draw("CPsame"); TLegend *l= new TLegend(0.45,0.53,0.83,0.43); DrawLegend(gROC_SIG03_hiPU, l, "Cone R=0.3 (high PU)","PL"); DrawLegend(gROC_SIG04_hiPU, l, "Cone R=0.4 (high PU)","PL"); TLegend *l2= new TLegend(0.45,0.33,0.83,0.23); DrawLegend(gROC_SIG03_hiPUdb, l2, "Cone R=0.3 (high PU)","PL"); DrawLegend(gROC_SIG04_hiPUdb, l2, "Cone R=0.4 (high PU)","PL"); TGraphAsymmErrors* gr03_hiPU = new TGraphAsymmErrors(); TGraphAsymmErrors* gr04_hiPU = new TGraphAsymmErrors(); TGraphAsymmErrors* gr03_hiPUdb = new TGraphAsymmErrors(); TGraphAsymmErrors* gr04_hiPUdb = new TGraphAsymmErrors(); double effQcd3,effSignal3,effQcd4,effSignal4; double effQcd3high,effSignal3high,effQcd4high,effSignal4high; gROC_SIG03_hiPU->GetPoint(14,effQcd3,effSignal3); gROC_SIG04_hiPU->GetPoint(19,effQcd4,effSignal4); gROC_SIG03_hiPUdb->GetPoint(14,effQcd3high,effSignal3high); gROC_SIG04_hiPUdb->GetPoint(19,effQcd4high,effSignal4high); gr03_hiPU->SetPoint(1, effQcd3,effSignal3); gr04_hiPU->SetPoint(1, effQcd4,effSignal4); gr03_hiPUdb->SetPoint(1, effQcd3high,effSignal3high); gr04_hiPUdb->SetPoint(1, effQcd4high,effSignal4high); gr03_hiPU->SetMarkerStyle(34); gr03_hiPU->SetMarkerSize(2.5); gr03_hiPU->SetMarkerColor(2); gr03_hiPU->SetLineWidth(3); gr04_hiPU->SetMarkerStyle(34); gr04_hiPU->SetMarkerSize(2.5); gr04_hiPU->SetMarkerColor(4); gr04_hiPU->SetLineWidth(3); gr03_hiPUdb->SetMarkerStyle(34); gr03_hiPUdb->SetMarkerSize(2.5); gr03_hiPUdb->SetMarkerColor(28); gr03_hiPUdb->SetLineWidth(3); gr04_hiPUdb->SetMarkerStyle(34); gr04_hiPUdb->SetMarkerSize(2.5); gr04_hiPUdb->SetMarkerColor(8); gr04_hiPUdb->SetLineWidth(3); gr03_hiPU->Draw("P"); gr04_hiPU->Draw("Psame"); gr03_hiPUdb->Draw("Psame"); gr04_hiPUdb->Draw("Psame"); TLatex *label= new TLatex; label->SetNDC(); label->SetTextSize(0.04); label->DrawLatex(0.45,0.55,"No Delta-beta Correction"); label->Draw(); TLatex *label2= new TLatex; label2->SetNDC(); label2->SetTextSize(0.04); label2->DrawLatex(0.45,0.35,"Delta-beta Correction"); label2->Draw(); c5high->Print(plots+"PUrochigh.png"); c5high->Print(plots+"PUrochigh.pdf"); //////////////////////////////////////////////////////////////////////////////// TCanvas *c5eff = new TCanvas("c5eff","IsoEff-SIG",400,400); c5eff->SetTickx(); c5eff->SetTicky(); gEFF_SIG03_lowPU = EFF(hSIG_pfRelIso03_lowPU); gEFF_SIG04_lowPU = EFF(hSIG_pfRelIso04_lowPU); gEFF_SIG03_hiPU = EFF(hSIG_pfRelIso03_hiPU); gEFF_SIG04_hiPU = EFF(hSIG_pfRelIso04_hiPU); GraphStyleEff(gEFF_SIG03_lowPU, 2, 23); GraphStyleEff(gEFF_SIG04_lowPU, 4, 22); GraphStyleEff(gEFF_SIG03_hiPU, 28, 2); GraphStyleEff(gEFF_SIG04_hiPU, 8, 5); gEFF_SIG04_lowPU->GetXaxis()->SetRangeUser(0,0.4); gEFF_SIG04_lowPU->SetMinimum(0.3); gEFF_SIG04_lowPU->SetMaximum(1); gEFF_SIG04_lowPU->Draw("ACP"); gEFF_SIG03_lowPU->Draw("CPsame"); gEFF_SIG04_hiPU->Draw("CPsame"); gEFF_SIG03_hiPU->Draw("CPsame"); TLegend *l= new TLegend(0.45,0.38,0.83,0.18); DrawLegend(gEFF_SIG03_lowPU, l, "Cone R=0.3 (low PU)","PL"); DrawLegend(gEFF_SIG04_lowPU, l, "Cone R=0.4 (low PU)","PL"); DrawLegend(gEFF_SIG03_hiPU, l, "Cone R=0.3 (high PU)","PL"); DrawLegend(gEFF_SIG04_hiPU, l, "Cone R=0.4 (high PU)","PL"); TLatex *label= new TLatex; label->SetNDC(); label->SetTextSize(0.04); label->DrawLatex(0.45,0.40,"No Delta-beta Correction"); label->Draw(); c5eff->Print(plots+"PUSIG_efficiency.png"); c5eff->Print(plots+"PUSIG_efficiency.pdf"); //////////////////////////////////////////////////////////////////////////////// TCanvas *c5effdb = new TCanvas("c5effdb","IsoEff-SIGdb",400,400); c5effdb->SetTickx(); c5effdb->SetTicky(); gEFF_SIG03db_lowPU = EFF(hSIG_pfRelIso03db_lowPU); gEFF_SIG04db_lowPU = EFF(hSIG_pfRelIso04db_lowPU); gEFF_SIG03db_hiPU = EFF(hSIG_pfRelIso03db_hiPU); gEFF_SIG04db_hiPU = EFF(hSIG_pfRelIso04db_hiPU); GraphStyleEff(gEFF_SIG03db_lowPU, 2, 23); GraphStyleEff(gEFF_SIG04db_lowPU, 4, 22); GraphStyleEff(gEFF_SIG03db_hiPU, 28, 2); GraphStyleEff(gEFF_SIG04db_hiPU, 8, 5); gEFF_SIG04db_lowPU->GetXaxis()->SetRangeUser(0,0.4); gEFF_SIG04db_lowPU->SetMinimum(0.3); gEFF_SIG04db_lowPU->SetMaximum(1); gEFF_SIG04db_lowPU->Draw("ACP"); gEFF_SIG03db_lowPU->Draw("CPsame"); gEFF_SIG04db_hiPU->Draw("CPsame"); gEFF_SIG03db_hiPU->Draw("CPsame"); TLegend *l= new TLegend(0.45,0.38,0.83,0.18); DrawLegend(gEFF_SIG03db_lowPU, l, "Cone R=0.3 (low PU)","PL"); DrawLegend(gEFF_SIG04db_lowPU, l, "Cone R=0.4 (low PU)","PL"); DrawLegend(gEFF_SIG03db_hiPU, l, "Cone R=0.3 (high PU)","PL"); DrawLegend(gEFF_SIG04db_hiPU, l, "Cone R=0.4 (high PU)","PL"); TLatex *label= new TLatex; label->SetNDC(); label->SetTextSize(0.04); label->DrawLatex(0.45,0.40,"Delta-beta Correction"); label->Draw(); c5effdb->Print(plots+"PUSIGdb_efficiency.png"); c5effdb->Print(plots+"PUSIGdb_efficiency.pdf"); //////////////////////////////////////////////////////////////////////////////// TCanvas *c5effQCD = new TCanvas("c5effQCD","IsoEff-QCD",400,400); c5effQCD->SetTickx(); c5effQCD->SetTicky(); gEFF_QCD03_lowPU = EFF(hQCD_pfRelIso03_lowPU); gEFF_QCD04_lowPU = EFF(hQCD_pfRelIso04_lowPU); gEFF_QCD03_hiPU = EFF(hQCD_pfRelIso03_hiPU); gEFF_QCD04_hiPU = EFF(hQCD_pfRelIso04_hiPU); GraphStyleEff(gEFF_QCD03_lowPU, 2, 23); GraphStyleEff(gEFF_QCD04_lowPU, 4, 22); GraphStyleEff(gEFF_QCD03_hiPU, 28, 2); GraphStyleEff(gEFF_QCD04_hiPU, 8, 5); gEFF_QCD04_lowPU->GetXaxis()->SetRangeUser(0,0.4); gEFF_QCD04_lowPU->SetMinimum(0); gEFF_QCD04_lowPU->SetMaximum(1); gEFF_QCD04_lowPU->Draw("ACP"); gEFF_QCD03_lowPU->Draw("CPsame"); gEFF_QCD04_hiPU->Draw("CPsame"); gEFF_QCD03_hiPU->Draw("CPsame"); TLegend *l= new TLegend(0.22,0.62,0.60,0.82); DrawLegend(gEFF_QCD03_lowPU, l, "Cone R=0.3 (low PU)","PL"); DrawLegend(gEFF_QCD04_lowPU, l, "Cone R=0.4 (low PU)","PL"); DrawLegend(gEFF_QCD03_hiPU, l, "Cone R=0.3 (high PU)","PL"); DrawLegend(gEFF_QCD04_hiPU, l, "Cone R=0.4 (high PU)","PL"); TLatex *label= new TLatex; label->SetNDC(); label->SetTextSize(0.04); label->DrawLatex(0.22,0.84,"No Delta-beta Correction"); label->Draw(); c5effQCD->Print(plots+"PUQCD_efficiency.png"); c5effQCD->Print(plots+"PUQCD_efficiency.pdf"); //////////////////////////////////////////////////////////////////////////////// TCanvas *c5effQCDdb = new TCanvas("c5effQCDdb","IsoEff-QCDdb",400,400); c5effQCDdb->SetTickx(); c5effQCDdb->SetTicky(); gEFF_QCD03db_lowPU = EFF(hQCD_pfRelIso03db_lowPU); gEFF_QCD04db_lowPU = EFF(hQCD_pfRelIso04db_lowPU); gEFF_QCD03db_hiPU = EFF(hQCD_pfRelIso03db_hiPU); gEFF_QCD04db_hiPU = EFF(hQCD_pfRelIso04db_hiPU); GraphStyleEff(gEFF_QCD03db_lowPU, 2, 23); GraphStyleEff(gEFF_QCD04db_lowPU, 4, 22); GraphStyleEff(gEFF_QCD03db_hiPU, 28, 2); GraphStyleEff(gEFF_QCD04db_hiPU, 8, 5); gEFF_QCD04db_lowPU->GetXaxis()->SetRangeUser(0,0.4); gEFF_QCD04db_lowPU->SetMinimum(0); gEFF_QCD04db_lowPU->SetMaximum(1); gEFF_QCD04db_lowPU->Draw("ACP"); gEFF_QCD03db_lowPU->Draw("CPsame"); gEFF_QCD04db_hiPU->Draw("CPsame"); gEFF_QCD03db_hiPU->Draw("CPsame"); TLegend *l= new TLegend(0.22,0.62,0.60,0.82); DrawLegend(gEFF_QCD03db_lowPU, l, "Cone R=0.3 (low PU)","PL"); DrawLegend(gEFF_QCD04db_lowPU, l, "Cone R=0.4 (low PU)","PL"); DrawLegend(gEFF_QCD03db_hiPU, l, "Cone R=0.3 (high PU)","PL"); DrawLegend(gEFF_QCD04db_hiPU, l, "Cone R=0.4 (high PU)","PL"); TLatex *label= new TLatex; label->SetNDC(); label->SetTextSize(0.04); label->DrawLatex(0.22,0.84,"Delta-beta Correction"); label->Draw(); c5effQCDdb->Print(plots+"PUQCDdb_efficiency.png"); c5effQCDdb->Print(plots+"PUQCDdb_efficiency.pdf"); /////////////////////////////////////////////////////////////////////////////// TCanvas *c5sig = new TCanvas("c5sig","RDSignificance S/sqrt(S+B)",400,400); double xmax =0.4; double ymin=0.85; double ymax=0.905; TH1F* h3=new TH1F("h3","Significance for cone 0.3",40,0,xmax); TH1F* h4=new TH1F("h4","Significance for cone 0.4",40,0,xmax); TH1F* h33=new TH1F("h33","Significance for cone 0.3",40,0,xmax); TH1F* h44=new TH1F("h44","Significance for cone 0.4",40,0,xmax); for (int i=0; i<41;i++){ double eff_signal3low,eff_signal4low; double eff_qcd3low,eff_qcd4low; double eff_signal3hi,eff_signal4hi; double eff_qcd3hi,eff_qcd4hi; gROC_SIG03_lowPU->GetPoint(i,eff_qcd3low,eff_signal3low); gROC_SIG04_lowPU->GetPoint(i,eff_qcd4low,eff_signal4low); gROC_SIG03_hiPU->GetPoint(i,eff_qcd3hi,eff_signal3hi); gROC_SIG04_hiPU->GetPoint(i,eff_qcd4hi,eff_signal4hi); double soverb3low = eff_signal3low/sqrt(eff_signal3low+eff_qcd3low); double soverb4low = eff_signal4low/sqrt(eff_signal4low+eff_qcd4low); double soverb3hi = eff_signal3hi/sqrt(eff_signal3hi+eff_qcd3hi); double soverb4hi = eff_signal4hi/sqrt(eff_signal4hi+eff_qcd4hi); h3->SetBinContent(i,soverb3low); h4->SetBinContent(i,soverb4low); h33->SetBinContent(i,soverb3hi); h44->SetBinContent(i,soverb4hi); } ///// // gPad->SetGridx(); // gPad->SetGridy(); h3->SetLineColor(2); h4->SetLineColor(4); h33->SetLineColor(28); h44->SetLineColor(8); h4->SetMinimum(ymin); h4->SetMaximum(ymax); h4->GetXaxis()->SetTitle("Isolation Threshold"); h4->GetYaxis()->SetTitle("S/#sqrt{S+B}"); h4->Draw(); h3->Draw("same"); h33->Draw("same"); h44->Draw("same"); TLegend *l= new TLegend(0.45,0.38,0.88,0.18); DrawLegendHisto(h3, l, "Cone R=0.3 (low PU)","L"); DrawLegendHisto(h4, l, "Cone R=0.4 (low PU)","L"); DrawLegendHisto(h33, l, "Cone R=0.3 (high PU)","L"); DrawLegendHisto(h44, l, "Cone R=0.4 (high PU)","L"); TLatex *label= new TLatex; label->SetNDC(); label->SetTextSize(0.04); label->DrawLatex(0.45,0.40,"No Delta-beta Correction"); label->Draw(); c5sig->Print(plots+"PUsignificance.png"); c5sig->Print(plots+"PUsignificance.pdf"); /////////////////////////////////////////////////////////////////////////////// TCanvas *c5sigdb = new TCanvas("c5sigdb","RDSignificancedb S/sqrt(S+B)",400,400); double xmax =0.4; double ymin=0.85; double ymax=0.905; TH1F* h3db=new TH1F("h3db","Significance for cone 0.3",40,0,xmax); TH1F* h4db=new TH1F("h4db","Significance for cone 0.4",40,0,xmax); TH1F* h33db=new TH1F("h33db","Significance for cone 0.3",40,0,xmax); TH1F* h44db=new TH1F("h44db","Significance for cone 0.4",40,0,xmax); for (int i=0; i<41;i++){ double eff_signal3low,eff_signal4low; double eff_qcd3low,eff_qcd4low; double eff_signal3hi,eff_signal4hi; double eff_qcd3hi,eff_qcd4hi; gROC_SIG03_lowPUdb->GetPoint(i,eff_qcd3low,eff_signal3low); gROC_SIG04_lowPUdb->GetPoint(i,eff_qcd4low,eff_signal4low); gROC_SIG03_hiPUdb->GetPoint(i,eff_qcd3hi,eff_signal3hi); gROC_SIG04_hiPUdb->GetPoint(i,eff_qcd4hi,eff_signal4hi); double soverb3low = eff_signal3low/sqrt(eff_signal3low+eff_qcd3low); double soverb4low = eff_signal4low/sqrt(eff_signal4low+eff_qcd4low); double soverb3hi = eff_signal3hi/sqrt(eff_signal3hi+eff_qcd3hi); double soverb4hi = eff_signal4hi/sqrt(eff_signal4hi+eff_qcd4hi); h3db->SetBinContent(i,soverb3low); h4db->SetBinContent(i,soverb4low); h33db->SetBinContent(i,soverb3hi); h44db->SetBinContent(i,soverb4hi); } ///// // gPad->SetGridx(); // gPad->SetGridy(); h3db->SetLineColor(2); h4db->SetLineColor(4); h33db->SetLineColor(28); h44db->SetLineColor(8); h4db->SetMinimum(ymin); h4db->SetMaximum(ymax); h4db->GetXaxis()->SetTitle("Isolation Threshold"); h4db->GetYaxis()->SetTitle("S/#sqrt{S+B}"); h4db->Draw(); h3db->Draw("same"); h33db->Draw("same"); h44db->Draw("same"); TLegend *l= new TLegend(0.45,0.38,0.88,0.18); DrawLegendHisto(h3db, l, "Cone R=0.3 (low PU)","L"); DrawLegendHisto(h4db, l, "Cone R=0.4 (low PU)","L"); DrawLegendHisto(h33db, l, "Cone R=0.3 (high PU)","L"); DrawLegendHisto(h44db, l, "Cone R=0.4 (high PU)","L"); TLatex *label= new TLatex; label->SetNDC(); label->SetTextSize(0.04); label->DrawLatex(0.45,0.40,"Delta-beta Correction"); label->Draw(); c5sigdb->Print(plots+"PUsignificancedb.png"); c5sigdb->Print(plots+"PUsignificancedb.pdf"); /////////////////////////////////////////////////////////////////////////////// TCanvas *c5siglow = new TCanvas("c5siglow","RDSignificance S/sqrt(S+B) low pile-up",400,400); double xmax =0.4; double ymin=0.85; double ymax=0.905; TH1F* h3=new TH1F("h3","Significance for cone 0.3",40,0,xmax); TH1F* h4=new TH1F("h4","Significance for cone 0.4",40,0,xmax); TH1F* h33=new TH1F("h33","Significance for cone 0.3",40,0,xmax); TH1F* h44=new TH1F("h44","Significance for cone 0.4",40,0,xmax); for (int i=0; i<41;i++){ double eff_signal3low,eff_signal4low; double eff_qcd3low,eff_qcd4low; double eff_signal3lowdb,eff_signal4lowdb; double eff_qcd3lowdb,eff_qcd4lowdb; gROC_SIG03_lowPU->GetPoint(i,eff_qcd3low,eff_signal3low); gROC_SIG04_lowPU->GetPoint(i,eff_qcd4low,eff_signal4low); gROC_SIG03_lowPUdb->GetPoint(i,eff_qcd3lowdb,eff_signal3lowdb); gROC_SIG04_lowPUdb->GetPoint(i,eff_qcd4lowdb,eff_signal4lowdb); double soverb3low = eff_signal3low/sqrt(eff_signal3low+eff_qcd3low); double soverb4low = eff_signal4low/sqrt(eff_signal4low+eff_qcd4low); double soverb3lowdb = eff_signal3lowdb/sqrt(eff_signal3lowdb+eff_qcd3lowdb); double soverb4lowdb = eff_signal4lowdb/sqrt(eff_signal4lowdb+eff_qcd4lowdb); h3->SetBinContent(i,soverb3low); h4->SetBinContent(i,soverb4low); h33->SetBinContent(i,soverb3lowdb); h44->SetBinContent(i,soverb4lowdb); } ///// // gPad->SetGridx(); // gPad->SetGridy(); h3->SetLineColor(2); h4->SetLineColor(4); h33->SetLineColor(28); h44->SetLineColor(8); h4->SetMinimum(ymin); h4->SetMaximum(ymax); h4->GetXaxis()->SetTitle("Isolation Threshold"); h4->GetYaxis()->SetTitle("S/#sqrt{S+B}"); h4->Draw(); h3->Draw("same"); h33->Draw("same"); h44->Draw("same"); TLegend *l= new TLegend(0.45,0.53,0.83,0.43); DrawLegendHisto(h3, l, "Cone R=0.3 (low PU)","L"); DrawLegendHisto(h4, l, "Cone R=0.4 (low PU)","L"); TLegend *l2= new TLegend(0.45,0.33,0.83,0.23); DrawLegendHisto(h33, l2, "Cone R=0.3 (low PU)","L"); DrawLegendHisto(h44, l2, "Cone R=0.4 (low PU)","L"); TLatex *label= new TLatex; label->SetNDC(); label->SetTextSize(0.04); label->DrawLatex(0.45,0.55,"No Delta-beta Correction"); label->Draw(); TLatex *label2= new TLatex; label2->SetNDC(); label2->SetTextSize(0.04); label2->DrawLatex(0.45,0.35,"Delta-beta Correction"); label2->Draw(); c5siglow->Print(plots+"PUsignificancelow.png"); c5siglow->Print(plots+"PUsignificancelow.pdf"); /////////////////////////////////////////////////////////////////////////////// TCanvas *c5sighigh = new TCanvas("c5sighigh","RDSignificance S/sqrt(S+B) high pile-up",400,400); double xmax =0.4; double ymin=0.85; double ymax=0.905; TH1F* h3=new TH1F("h3","Significance for cone 0.3",40,0,xmax); TH1F* h4=new TH1F("h4","Significance for cone 0.4",40,0,xmax); TH1F* h33=new TH1F("h33","Significance for cone 0.3",40,0,xmax); TH1F* h44=new TH1F("h44","Significance for cone 0.4",40,0,xmax); for (int i=0; i<41;i++){ double eff_signal3hi,eff_signal4hi; double eff_qcd3hi,eff_qcd4hi; double eff_signal3hidb,eff_signal4hidb; double eff_qcd3hidb,eff_qcd4hidb; gROC_SIG03_hiPU->GetPoint(i,eff_qcd3hi,eff_signal3hi); gROC_SIG04_hiPU->GetPoint(i,eff_qcd4hi,eff_signal4hi); gROC_SIG03_hiPUdb->GetPoint(i,eff_qcd3hidb,eff_signal3hidb); gROC_SIG04_hiPUdb->GetPoint(i,eff_qcd4hidb,eff_signal4hidb); double soverb3hi = eff_signal3hi/sqrt(eff_signal3hi+eff_qcd3hi); double soverb4hi = eff_signal4hi/sqrt(eff_signal4hi+eff_qcd4hi); double soverb3hidb = eff_signal3hidb/sqrt(eff_signal3hidb+eff_qcd3hidb); double soverb4hidb = eff_signal4hidb/sqrt(eff_signal4hidb+eff_qcd4hidb); h3->SetBinContent(i,soverb3hi); h4->SetBinContent(i,soverb4hi); h33->SetBinContent(i,soverb3hidb); h44->SetBinContent(i,soverb4hidb); } ///// // gPad->SetGridx(); // gPad->SetGridy(); h3->SetLineColor(2); h4->SetLineColor(4); h33->SetLineColor(28); h44->SetLineColor(8); h4->SetMinimum(ymin); h4->SetMaximum(ymax); h4->GetXaxis()->SetTitle("Isolation Threshold"); h4->GetYaxis()->SetTitle("S/#sqrt{S+B}"); h4->Draw(); h3->Draw("same"); h33->Draw("same"); h44->Draw("same"); TLegend *l= new TLegend(0.45,0.53,0.83,0.43); DrawLegendHisto(h3, l, "Cone R=0.3 (high PU)","L"); DrawLegendHisto(h4, l, "Cone R=0.4 (high PU)","L"); TLegend *l2= new TLegend(0.45,0.33,0.83,0.23); DrawLegendHisto(h33, l2, "Cone R=0.3 (high PU)","L"); DrawLegendHisto(h44, l2, "Cone R=0.4 (high PU)","L"); TLatex *label= new TLatex; label->SetNDC(); label->SetTextSize(0.04); label->DrawLatex(0.45,0.55,"No Delta-beta Correction"); label->Draw(); TLatex *label2= new TLatex; label2->SetNDC(); label2->SetTextSize(0.04); label2->DrawLatex(0.45,0.35,"Delta-beta Correction"); label2->Draw(); c5sighigh->Print(plots+"PUsignificancehigh.png"); c5sighigh->Print(plots+"PUsignificancehigh.pdf"); //////////////////////////////////////////////////////////////////////////////// }
void BasePlot::DrawLabels() { // total mess to get it nice, should be redone size_t j=0; TString higgsLabel = " HWW"; if(_mass != 0) higgsLabel.Form(" m_{H}=%d",_mass); float *pos,*off; int sampCount = GetSampCount(); if(sampCount == 12 || sampCount == 15) { pos = xPosA; off = yOffA; } else if(sampCount == 11 ) { pos = xPosB; off = yOffB; } else { pos = xPos; off = yOff; } if(_data ) { DrawLegend(pos[j], _legendStart - off[j]*_yoffset, _data, " data", "lp"); j++; } if(_hist[iHWW ]) { DrawLegend(pos[j], _legendStart - off[j]*_yoffset, _hist[iHWW ] , higgsLabel, "l" ); j++; } if(_hist[iWW ]) { DrawLegend(pos[j], _legendStart - off[j]*_yoffset, _hist[iWW ] , " WW", "f" ); j++; } if(_hist[iZJets]) { DrawLegend(pos[j], _legendStart - off[j]*_yoffset, _hist[iZJets] , " DY", "f" ); j++; } if(_hist[iTop ]) { DrawLegend(pos[j], _legendStart - off[j]*_yoffset, _hist[iTop ] , " top", "f" ); j++; } if(_hist[iTT ]) { DrawLegend(pos[j], _legendStart - off[j]*_yoffset, _hist[iTT ] , " t#bar{t}", "f" ); j++; } if(_hist[iTW ]) { DrawLegend(pos[j], _legendStart - off[j]*_yoffset, _hist[iTW ] , " tW", "f" ); j++; } if(_hist[iVV ]) { DrawLegend(pos[j], _legendStart - off[j]*_yoffset, _hist[iVV ] , " WZ/ZZ", "f" ); j++; } if(_hist[iWJets]) { DrawLegend(pos[j], _legendStart - off[j]*_yoffset, _hist[iWJets] , " W+jets", "f" ); j++; } if(_hist[iWZ ]) { DrawLegend(pos[j], _legendStart - off[j]*_yoffset, _hist[iWZ ] , " WZ", "f" ); j++; } if(_hist[iZZ ]) { DrawLegend(pos[j], _legendStart - off[j]*_yoffset, _hist[iZZ ] , " ZZ", "f" ); j++; } if(_hist[iFakes]) { DrawLegend(pos[j], _legendStart - off[j]*_yoffset, _hist[iFakes] , " fakes", "f" ); j++; } for(size_t i=0;i<_autreHists.size();++i) { DrawLegend(pos[j], _legendStart - off[j]*_yoffset, _autreHists[i].second , _autreHists[i].first, "f" ); j++; } TLatex* luminosity = new TLatex(0.896, _legendStart-0.4*_yoffset, TString::Format("L = %.1f fb^{-1}",_lumi).Data()); // _extraLabel = new TLatex(0.9, , TString(s)); luminosity->SetNDC(); luminosity->SetTextAlign(32); luminosity->SetTextFont(42); luminosity->SetTextSize(_legendTextSize*0.95); luminosity->Draw("same"); if(_extraLabel) _extraLabel->Draw("same"); }
bool iupPlot::Render(cdCanvas* canvas) { if (!mRedraw) return true; // Shift the drawing area to the plot viewport cdCanvasOrigin(canvas, mViewport.mX, mViewport.mY); // There are no additional transformations set in the CD canvas, // all transformations are done here. cdCanvasClip(canvas, CD_CLIPAREA); // Draw the background, axis and grid restricted only by the viewport cdCanvasClipArea(canvas, 0, mViewport.mWidth - 1, 0, mViewport.mHeight - 1); // draw entire plot viewport DrawBackground(canvas); if (!mDataSetListCount) return true; cdCanvasNativeFont(canvas, IupGetAttribute(ih, "FONT")); ConfigureAxis(); if (!CalculateAxisRange()) return false; if (!CheckRange(mAxisX)) return false; if (!CheckRange(mAxisY)) return false; CalculateTitlePos(); // Must be before calculate margins CalculateTickSize(canvas, mAxisX.mTick); CalculateTickSize(canvas, mAxisY.mTick); CalculateMargins(canvas); iupPlotRect theDatasetArea; theDatasetArea.mX = mBack.mMargin.mLeft; theDatasetArea.mY = mBack.mMargin.mBottom; theDatasetArea.mWidth = mViewport.mWidth - mBack.mMargin.mLeft - mBack.mMargin.mRight; theDatasetArea.mHeight = mViewport.mHeight - mBack.mMargin.mTop - mBack.mMargin.mBottom; if (!CalculateTickSpacing(theDatasetArea, canvas)) return false; if (!CalculateXTransformation(theDatasetArea)) return false; if (!CalculateYTransformation(theDatasetArea)) return false; IFnC pre_cb = (IFnC)IupGetCallback(ih, "PREDRAW_CB"); if (pre_cb) pre_cb(ih, canvas); if (mBack.GetImage()) DrawBackgroundImage(canvas); if (!mGrid.DrawX(mAxisX.mTickIter, mAxisX.mTrafo, theDatasetArea, canvas)) return false; if (mGrid.mShowX) mGridMinor.DrawX(mAxisX.mTickIter, mAxisX.mTrafo, theDatasetArea, canvas); if (!mGrid.DrawY(mAxisY.mTickIter, mAxisY.mTrafo, theDatasetArea, canvas)) return false; if (mGrid.mShowY) mGridMinor.DrawY(mAxisY.mTickIter, mAxisY.mTrafo, theDatasetArea, canvas); if (!mAxisX.DrawX(theDatasetArea, canvas, mAxisY)) return false; if (!mAxisY.DrawY(theDatasetArea, canvas, mAxisX)) return false; if (mBox.mShow) mBox.Draw(theDatasetArea, canvas); // draw the datasets, legend, crosshair and selection restricted to the dataset area cdCanvasClipArea(canvas, theDatasetArea.mX, theDatasetArea.mX + theDatasetArea.mWidth - 1, theDatasetArea.mY, theDatasetArea.mY + theDatasetArea.mHeight - 1); IFniiddi drawsample_cb = (IFniiddi)IupGetCallback(ih, "DRAWSAMPLE_CB"); for (int ds = 0; ds < mDataSetListCount; ds++) { iupPlotDataSet* dataset = mDataSetList[ds]; if (drawsample_cb) { iupPlotSampleNotify inNotify = { ih, ds, drawsample_cb }; dataset->DrawData(mAxisX.mTrafo, mAxisY.mTrafo, canvas, &inNotify); } else dataset->DrawData(mAxisX.mTrafo, mAxisY.mTrafo, canvas, NULL); } if (mCrossHairH) DrawCrossHairH(theDatasetArea, canvas); else if (mCrossHairV) DrawCrossHairV(theDatasetArea, canvas); if (mShowSelectionBand) { if (mSelectionBand.mX < theDatasetArea.mX) { mSelectionBand.mWidth = mSelectionBand.mX + mSelectionBand.mWidth - theDatasetArea.mX; mSelectionBand.mX = theDatasetArea.mX; } if (mSelectionBand.mY < theDatasetArea.mY) { mSelectionBand.mHeight = mSelectionBand.mY + mSelectionBand.mHeight - theDatasetArea.mY; mSelectionBand.mY = theDatasetArea.mY; } if (mSelectionBand.mX + mSelectionBand.mWidth > theDatasetArea.mX + theDatasetArea.mWidth) mSelectionBand.mWidth = theDatasetArea.mX + theDatasetArea.mWidth - mSelectionBand.mX; if (mSelectionBand.mY + mSelectionBand.mHeight > theDatasetArea.mY + theDatasetArea.mHeight) mSelectionBand.mHeight = theDatasetArea.mY + theDatasetArea.mHeight - mSelectionBand.mY; mBox.Draw(mSelectionBand, canvas); } IFnC post_cb = (IFnC)IupGetCallback(ih, "POSTDRAW_CB"); if (post_cb) post_cb(ih, canvas); if (!DrawLegend(theDatasetArea, canvas, mLegend.mPos)) return false; // Draw title restricted only by the viewport cdCanvasClipArea(canvas, 0, mViewport.mWidth - 1, 0, mViewport.mHeight - 1); DrawTitle(canvas); if (!IupGetInt(ih, "ACTIVE")) DrawInactive(canvas); mRedraw = false; return true; }
void MyGraph::DrawGraph(CDC& dc) { VALIDATE; ASSERT_VALID(&dc); if (GetMaxSeriesSize()) { dc.SetBkMode(TRANSPARENT); // Populate the colors as a group of evenly spaced colors of maximum // saturation. int nColorsDelta(240 / GetMaxSeriesSize()); int baseColorL = 120; int diffColorL = 60; DWORD backgroundColor = ::GetSysColor(COLOR_WINDOW); // If graph is a non-stacked line graph, use darker colors if system window color is light. #if 0 if (m_eGraphType == MyGraph::Line && !m_bStackedGraph) { int backgroundLuma = (GetRValue(backgroundColor) + GetGValue(backgroundColor) + GetBValue(backgroundColor)) / 3; if (backgroundLuma > 128) { baseColorL = 70; diffColorL = 50; } } #endif for (WORD nGroup = 0; nGroup < GetMaxSeriesSize(); ++nGroup) { WORD colorH = (WORD)(nColorsDelta * nGroup); WORD colorL = (WORD)(baseColorL+(diffColorL*(nGroup%2))); WORD colorS = (WORD)(180)+(30*((1-nGroup%2)*(nGroup%3))); COLORREF cr(MyGraph::HLStoRGB(colorH, colorL, colorS)); // Populate colors cleverly m_dwaColors.SetAtGrow(nGroup, cr); } // Reduce the graphable area by the frame window and status bar. We will // leave GAP_PIXELS pixels blank on all sides of the graph. So top-left // side of graph is at GAP_PIXELS,GAP_PIXELS and the bottom-right side // of graph is at (m_rcGraph.Height() - GAP_PIXELS), (m_rcGraph.Width() - // GAP_PIXELS). These settings are altered by axis labels and legends. CRect rcWnd; GetClientRect(&rcWnd); m_rcGraph.left = GAP_PIXELS; m_rcGraph.top = GAP_PIXELS; m_rcGraph.right = rcWnd.Width() - GAP_PIXELS; m_rcGraph.bottom = rcWnd.Height() - GAP_PIXELS; CBrush br; VERIFY(br.CreateSolidBrush(backgroundColor)); dc.FillRect(rcWnd, &br); br.DeleteObject(); // Draw graph title. DrawTitle(dc); // Set the axes and origin values. SetupAxes(dc); // Draw legend if there is one and there's enough space. if (m_saLegendLabels.GetSize() && m_rcGraph.right-m_rcGraph.left > LEGEND_VISIBILITY_THRESHOLD) { DrawLegend(dc); } else{ m_rcLegend.SetRectEmpty(); } // Draw axes unless it's a pie. if (m_eGraphType != MyGraph::PieChart) { DrawAxes(dc); } // Draw series data and labels. switch (m_eGraphType) { case MyGraph::Bar: DrawSeriesBar(dc); break; case MyGraph::Line: if (m_bStackedGraph) DrawSeriesLineStacked(dc); else DrawSeriesLine(dc); break; case MyGraph::PieChart: DrawSeriesPie(dc); break; default: _ASSERTE(! "Bad default case"); break; } } }