void graph() { //Draw a simple graph // To see the output of this macro, click begin_html <a href="gif/graph.gif">here</a>. end_html //Author: Rene Brun TCanvas *c1 = new TCanvas("c1","A Simple Graph Example",200,10,700,500); c1->SetFillColor(42); c1->SetGrid(); const Int_t n = 20; Double_t x[n], y[n]; for (Int_t i=0;i<n;i++) { x[i] = i*0.1; y[i] = 10*sin(x[i]+0.2); printf(" i %i %f %f \n",i,x[i],y[i]); } auto gr = new TGraph(n,x,y); gr->SetLineColor(2); gr->SetLineWidth(4); gr->SetMarkerColor(4); gr->SetMarkerStyle(21); gr->SetTitle("a simple graph"); gr->GetXaxis()->SetTitle("X title"); gr->GetYaxis()->SetTitle("Y title"); gr->Draw("ACP"); // TCanvas::Update() draws the frame, after which one can change it c1->Update(); c1->GetFrame()->SetFillColor(21); c1->GetFrame()->SetBorderSize(12); c1->Modified(); }
void MuReco( ) { TCut CPdg = "_tracks_Pdg==13||_tracks_Pdg==211"; TFile *inFileMC; //gStyle->SetOptStat(0); inFileMC = new TFile("ERAnaOneToOneMuReco.root"); inFileMC->cd(); TTree* _algoMuMC_tree = (TTree*)(inFileMC->Get("_ana1to1_tree")); TCanvas *C1 = new TCanvas("C1","C1",600,600); C1->cd(); auto cut2 = new TH1D("cut2","Muon deposited Energy; E_{#mu} [MeV];Count",20,0,800); _algoMuMC_tree->Draw("_tracks_DepEnFromLength>>cut2",CPdg,""); cut2->SetLineWidth(3); cut2->SetLineColor(kRed); cut2->GetYaxis()->SetTitleOffset(1.5); C1->SaveAs("MuRecoEn.png"); // TFile *inFileReco; // inFileReco = new TFile("ERAnaOneToOneMuMC.root"); // inFileReco->cd(); // TTree* _algoMuReco_tree = (TTree*)(inFileReco->Get("_ProtonSel_tree")); }
CRectangle::CRectangle(Ñoordinate const & pos, Size const & size, StrColor const & fillColor, StrColor const & lineColor) : m_width(size.first) , m_height(size.second) { m_pos = std::make_unique<CPoint>(pos.first, pos.second, fillColor); SetFillColor(fillColor); SetLineColor(lineColor); }
CPolyLineDrawing::CPolyLineDrawing(int Thickness, COLORREF lineColor, COLORREF fillColor, CPoint startpt) { vXYpoints.push_back(startpt); SetType("PolyLine"); SetThickness(Thickness); SetLineColor(lineColor); SetFillColor(fillColor); }
TH1F *getH(TString name,int bins, float xmin, float xmax, int color = kBlue) { // histcounter++; // TString name = "hist"+TString::Itoa(histcounter,10); auto h = new TH1F(name,name,bins,xmin,xmax); h->SetLineColor(color); h->SetMarkerColor(color); h->Sumw2(); return h; }
CCircle::CCircle(Ñoordinate const & pos, float const & radius, StrColor const & fillColor, StrColor const & lineColor) : m_radius(radius) { m_pos = std::make_unique<CPoint>(pos.first, pos.second, fillColor); SetFillColor(fillColor); SetLineColor(lineColor); }
bool CTransparentStaticLine::Create(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) { bool bRetVal = wxPanel::Create(parent, id, pos, size, style|wxTRANSPARENT_WINDOW, name); SetBackgroundColour(parent->GetBackgroundColour()); SetForegroundColour(parent->GetForegroundColour()); SetLineColor(GetForegroundColour()); return bRetVal; }
CTriangle::CTriangle(Ñoordinate const & pos1, Ñoordinate const & pos2, Ñoordinate const & pos3, StrColor const & fillColor, StrColor const & lineColor) { m_pick1 = std::make_unique<CPoint>(pos1.first, pos1.second, lineColor); m_pick2 = std::make_unique<CPoint>(pos2.first, pos2.second, lineColor); m_pick3 = std::make_unique<CPoint>(pos3.first, pos3.second, lineColor); m_side1 = std::make_unique<CLineSegment>(pos1, pos2, lineColor); m_side2 = std::make_unique<CLineSegment>(pos2, pos3, lineColor); m_side3 = std::make_unique<CLineSegment>(pos3, pos1, lineColor); SetFillColor(fillColor); SetLineColor(lineColor); }
void fillrandom() { TCanvas *c1 = new TCanvas("c1","The FillRandom example",200,10,700,900); auto pad1 = new TPad("pad1","The pad with the function",0.05,0.50,0.95,0.95); auto pad2 = new TPad("pad2","The pad with the histogram",0.05,0.05,0.95,0.45); pad1->Draw(); pad2->Draw(); pad1->cd(); gBenchmark->Start("fillrandom"); // // A function (any dimension) or a formula may reference // an already defined formula // auto form1 = new TFormula("form1","abs(sin(x)/x)"); auto sqroot = new TF1("sqroot","x*gaus(0) + [3]*form1",0,10); sqroot->SetParameters(10,4,1,20); pad1->SetGridx(); pad1->SetGridy(); pad1->GetFrame()->SetBorderMode(-1); pad1->GetFrame()->SetBorderSize(5); sqroot->SetLineColor(4); sqroot->SetLineWidth(6); sqroot->Draw(); auto lfunction = new TPaveLabel(5,39,9.8,46,"The sqroot function"); lfunction->Draw(); c1->Update(); // // Create a one dimensional histogram (one float per bin) // and fill it following the distribution in function sqroot. // pad2->cd(); pad2->GetFrame()->SetBorderMode(-1); pad2->GetFrame()->SetBorderSize(5); auto h1f = new TH1F("h1f","Test random numbers",200,0,10); h1f->SetFillColor(45); h1f->FillRandom("sqroot",10000); h1f->Draw(); c1->Update(); // // Open a ROOT file and save the formula, function and histogram // TFile myfile("fillrandom.root","RECREATE"); form1->Write(); sqroot->Write(); h1f->Write(); gBenchmark->Show("fillrandom"); }
void CMenuElementUI::SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue) { if( _tcsicmp(pstrName, _T("icon")) == 0){ SetIcon(pstrValue); } else if( _tcsicmp(pstrName, _T("iconsize")) == 0 ) { LPTSTR pstr = NULL; LONG cx = 0, cy = 0; cx = _tcstol(pstrValue, &pstr, 10); ASSERT(pstr); cy = _tcstol(pstr + 1, &pstr, 10); ASSERT(pstr); SetIconSize(cx, cy); } else if( _tcsicmp(pstrName, _T("checkitem")) == 0 ) { SetCheckItem(_tcsicmp(pstrValue, _T("true")) == 0 ? true : false); } else if( _tcsicmp(pstrName, _T("ischeck")) == 0 ) { if (CMenuWnd::GetGlobalContextMenuObserver().GetMenuCheckInfo() != NULL && CMenuWnd::GetGlobalContextMenuObserver().GetMenuCheckInfo()->find(GetName()) == CMenuWnd::GetGlobalContextMenuObserver().GetMenuCheckInfo()->end()) { SetChecked(_tcsicmp(pstrValue, _T("true")) == 0 ? true : false); } } else if( _tcsicmp(pstrName, _T("linetype")) == 0){ if (_tcsicmp(pstrValue, _T("true")) == 0) SetLineType(); } else if( _tcsicmp(pstrName, _T("expland")) == 0 ) { SetShowExplandIcon(_tcsicmp(pstrValue, _T("true")) == 0 ? true : false); } else if( _tcsicmp(pstrName, _T("linecolor")) == 0){ if( *pstrValue == _T('#')) pstrValue = ::CharNext(pstrValue); LPTSTR pstr = NULL; SetLineColor(_tcstoul(pstrValue, &pstr, 16)); } else if( _tcsicmp(pstrName, _T("linepadding")) == 0 ) { RECT rcInset = { 0 }; LPTSTR pstr = NULL; rcInset.left = _tcstol(pstrValue, &pstr, 10); ASSERT(pstr); rcInset.top = _tcstol(pstr + 1, &pstr, 10); ASSERT(pstr); rcInset.right = _tcstol(pstr + 1, &pstr, 10); ASSERT(pstr); rcInset.bottom = _tcstol(pstr + 1, &pstr, 10); ASSERT(pstr); SetLinePadding(rcInset); } else if ( _tcsicmp(pstrName, _T("height")) == 0){ SetFixedHeight(_ttoi(pstrValue)); } else CListContainerElementUI::SetAttribute(pstrName, pstrValue); }
void CToolsCtlPanelText::UpdateCalendarTextControls(CAGSymCalendar* pCalendarSym) { CAGSpec* pAGSpec = pCalendarSym->GetActiveSpec(); if (!pAGSpec) return; // Update the FillType control SetFillType(pAGSpec->m_FillType); // Update the FillColor control SetFillColor(pAGSpec->m_FillColor); // Update the FillColor2 control SetFillColor2(pAGSpec->m_FillColor2); // Update the LineWidth control SetLineWidth(pAGSpec->m_LineWidth); // Update the LineColor control SetLineColor(pAGSpec->m_LineColor); // Update the Title control //SetTitleText(pCalendarSym->GetActivePanelTitle()); //UpdateFillCtrls(); //UpdateLineCtrls(); ShowHideColors(); // Update the TextSize control SetTextSize(abs(pAGSpec->m_Font.lfHeight)); // Update the Font control LOGFONT& SymFont = pAGSpec->m_Font; SetFontControl(&pAGSpec->m_Font, true/*bClearIfBad*/); // Update the text style controls m_ButtonBold.Check(SymFont.lfWeight != FW_NORMAL); m_ButtonItalic.Check(!!SymFont.lfItalic); m_ButtonUnderline.Check(!!SymFont.lfUnderline); // Update the Vertical adjustment controls UpdateTextAlignCtrls(pCalendarSym); }
void CToolsCtlPanelGraphics::UpdateControls() { CDocWindow* pDocWindow = m_pCtp->GetDocWindow(); CAGDoc* pAGDoc = (!pDocWindow ? NULL : pDocWindow->GetDoc()); CAGSym* pSym = m_pCtp->m_pDocWindow->GetSelectedItem(); if (!pSym) return; if (pSym->IsGraphic()) { CAGSymGraphic* pGraphicSym = (CAGSymGraphic*)pSym; if (pSym->IsRectangle()) SetShapeName("Rectangle"); else if (pSym->IsEllipse()) SetShapeName("Circle/Ellipse"); else if (pSym->IsLine()) SetShapeName("Line"); else if (pSym->IsShape()) { SetShapeName(((CAGSymDrawing*)pSym)->GetShapeName()); } // Update the Fill controls SetFillType(pGraphicSym->GetFillType()); SetFillColor(pGraphicSym->GetFillColor()); SetFillColor2(pGraphicSym->GetFillColor2()); // Update the Line control SetLineWidth(pGraphicSym->GetLineWidth()); SetLineColor(pGraphicSym->GetLineColor()); //UpdateFillCtrls(); //UpdateLineCtrls(); ShowHideColors(); } }
void CToolsPanelText2::UpdateCalendarTextControls(CAGSymCalendar* pCalendarSym) { CAGSpec* pAGSpec = pCalendarSym->GetActiveSpec(); if (!pAGSpec) return; // Update the FillType control SetFillType(pAGSpec->m_FillType); // Update the FillColor control SetFillColor(pAGSpec->m_FillColor); // Update the FillColor2 control SetFillColor2(pAGSpec->m_FillColor2); // Update the LineWidth control SetLineWidth(pAGSpec->m_LineWidth); // Update the LineColor control SetLineColor(pAGSpec->m_LineColor); ShowHideColors(); }
void ChebyshevPol() { auto legend = new TLegend(0.88,0.4,1.,1.); int colors[] = { kRed, kRed+3, kMagenta, kMagenta+3, kBlue, kBlue+3, kCyan+3, kGreen, kGreen+3, kYellow, kOrange }; for (int degree=0; degree <=10; ++degree) { auto f1 = new TF1("f1",TString::Format("cheb%d",degree),-1,1); // all parameters are zero apart from the one corresponding to the degree f1->SetParameter(degree,1); f1->SetLineColor( colors[degree]); f1->SetMinimum(-1.2); f1->SetMaximum(1.2); TString opt = (degree == 0) ? "" : "same"; //f1->Print("V"); f1->SetNpx(1000); f1->SetTitle("Chebyshev Polynomial"); f1->Draw(opt); legend->AddEntry(f1,TString::Format("N=%d",degree),"L"); } legend->Draw(); }
// draw a box, with an optional shadow & connectors void _box(int top, int left, int bottom, int right, int style, int attribute, int fill, int box_flags, int connector) { int width; int v_zoom_top, v_zoom_bottom, h_zoom_left, h_zoom_right; int row_diff, col_diff, row_inc, col_inc, fWait = 0; // zoom the window? if (box_flags & BOX_ZOOMED) { fWait = 1; // zooming requires a fill color; use default if none specified if (fill == -1) GetAtt((unsigned int *)&fill,(unsigned int *)&v_zoom_top); v_zoom_top = v_zoom_bottom = (top + bottom) / 2; h_zoom_left = h_zoom_right = (left + right) / 2; // get the increment for each zoom // (This makes the zoom smooth in all dimensions) if ((row_diff = v_zoom_top - top) <= 0) row_diff = 1; if ((col_diff = h_zoom_left - left) <= 0) col_diff = 1; if (row_diff > col_diff) { // tall skinny box row_inc = (row_diff / col_diff); col_inc = 1; } else { // short wide box col_inc = (col_diff / row_diff); row_inc = 1; } } else { v_zoom_top = top; v_zoom_bottom = bottom; h_zoom_left = left; h_zoom_right = right; } do { if (box_flags & BOX_ZOOMED) { // if zooming, increment the box size v_zoom_top -= row_inc; if (v_zoom_top < top) v_zoom_top = top; v_zoom_bottom += row_inc; if (v_zoom_bottom > bottom) v_zoom_bottom = bottom; h_zoom_left -= col_inc; if (h_zoom_left < left) h_zoom_left = left; h_zoom_right += col_inc; if (h_zoom_right > right) h_zoom_right = right; } // clear the box to the specified attribute if (fill != -1) Scroll(v_zoom_top,h_zoom_left,v_zoom_bottom,h_zoom_right,0,fill); if (style == 0) width = 0; else if ((style == 2) || (style == 4)) width = 2; else width = 1; // draw the two horizontals & the two verticals _line(v_zoom_top,h_zoom_left,(h_zoom_right-h_zoom_left)+1,width,0,attribute,connector); _line(v_zoom_bottom,h_zoom_left,(h_zoom_right-h_zoom_left)+1,width,0,attribute,connector); if (style == 3) width = 2; else if (style == 4) width = 1; _line(v_zoom_top,h_zoom_left,(v_zoom_bottom-v_zoom_top)+1,width,1,attribute,connector); _line(v_zoom_top,h_zoom_right,(v_zoom_bottom-v_zoom_top)+1,width,1,attribute,connector); // if on a fast system, slow things down a bit if (fWait) SysBeep(0,1); } while ((box_flags & BOX_ZOOMED) && ((v_zoom_top > top) || (v_zoom_bottom < bottom) || (h_zoom_left > left) || (h_zoom_right < right))); // check for a shadow if (box_flags & BOX_SHADOWED) { left += 2; right++; if ( left >= right ) left = right - 1; // read the character and attribute, and change // the attribute to black background, low intensity // foreground SetLineColor(++bottom,left,(right-left),7); // shadow the right side of the window for (top++; (top <= bottom); top++) SetLineColor(top,right,2,7); } }
// draw a box, with an optional shadow & connectors void PASCAL _box( register int nTop, int nLeft, int nBottom, int nRight, int nStyle, int nAttribute, int nFill, int nFlags, int nConnector ) { register int nWidth; int nZoomTop, nZoomBottom, nZoomLeft, nZoomRight; int nRowDiff, nColumnDiff, nRowInc = 0, nColumnInc = 0; // zoom the window? if ( nFlags & BOX_ZOOMED ) { // zooming requires a fill color; use default if none specified if ( nFill == -1 ) GetAtt( (unsigned int *)&nFill, (unsigned int *)&nZoomTop ); nZoomTop = nZoomBottom = ( nTop + nBottom ) / 2; nZoomLeft = nZoomRight = ( nLeft + nRight ) / 2; // get the increment for each zoom // (This makes the zoom smooth in all dimensions) if (( nRowDiff = nZoomTop - nTop ) <= 0 ) nRowDiff = 1; if (( nColumnDiff = nZoomLeft - nLeft ) <= 0 ) nColumnDiff = 1; if ( nRowDiff > nColumnDiff ) { // tall skinny box nRowInc = ( nRowDiff / nColumnDiff ); nColumnInc = 1; } else { // short wide box nColumnInc = ( nColumnDiff / nRowDiff ); nRowInc = 1; } } else { nZoomTop = nTop; nZoomBottom = nBottom; nZoomLeft = nLeft; nZoomRight = nRight; } do { if ( nFlags & BOX_ZOOMED ) { // if zooming, increment the box size nZoomTop -= nRowInc; if ( nZoomTop < nTop ) nZoomTop = nTop; nZoomBottom += nRowInc; if ( nZoomBottom > nBottom ) nZoomBottom = nBottom; nZoomLeft -= nColumnInc; if ( nZoomLeft < nLeft ) nZoomLeft = nLeft; nZoomRight += nColumnInc; if ( nZoomRight > nRight ) nZoomRight = nRight; } // clear the box to the specified attribute if ( nFill != -1 ) Scroll( nZoomTop, nZoomLeft, nZoomBottom, nZoomRight, 0, nFill ); if ( nStyle == 0 ) nWidth = 0; else if (( nStyle == 2 ) || ( nStyle == 4 )) nWidth = 2; else nWidth = 1; // draw the two horizontals & the two verticals _line( nZoomTop, nZoomLeft, (nZoomRight-nZoomLeft)+1, nWidth, 0, nAttribute, nConnector ); _line( nZoomBottom, nZoomLeft, (nZoomRight-nZoomLeft)+1, nWidth, 0, nAttribute, nConnector ); if ( nStyle == 3 ) nWidth = 2; else if ( nStyle == 4 ) nWidth = 1; _line( nZoomTop, nZoomLeft, (nZoomBottom-nZoomTop)+1, nWidth, 1, nAttribute, nConnector ); _line( nZoomTop, nZoomRight, (nZoomBottom-nZoomTop)+1, nWidth, 1, nAttribute, nConnector ); // slow things down a bit SysBeep( 0, 1 ); } while (( nFlags & BOX_ZOOMED ) && (( nZoomTop > nTop ) || ( nZoomBottom < nBottom ) || ( nZoomLeft > nLeft ) || ( nZoomRight < nRight ))); // check for a shadow if ( nFlags & BOX_SHADOWED ) { nLeft += 2; nRight++; if ( nLeft >= nRight ) nLeft = nRight - 1; // read the character and attribute, and change // the attribute to black background, low intensity // foreground SetLineColor( ++nBottom, nLeft, (nRight-nLeft), 7 ); // shadow the right side of the window for ( nTop++; ( nTop <= nBottom ); nTop++ ) SetLineColor( nTop, nRight, 2, 7 ); } }
void checkclosure() { vector<TH1F *>hsig(Nbins); vector<TH1F *>hasd(Nbins); vector<TH1F *>hbkg(Nbins); vector<TH1F *>hsub(Nbins); vector<TH1F *>hhyj(Nbins); vector<TH1F *>hshj(Nbins); vector<TH1F *>hsbn(Nbins); for (int i=0;i<Nbins;i++) { seth(10,0,1); hsig[i] = geth(Form("hsig%d",i),Form("Signal away-side %s;x_{J}",binnames[i].Data())) ; hasd[i] = geth(Form("hasd%d",i),Form("Measured away-side %s;x_{J}",binnames[i].Data())); hbkg[i] = geth(Form("hbkg%d",i),Form("Near-side %s;x_{J}",binnames[i].Data())); hhyj[i] = geth(Form("hhyj%d",i),Form("Near-side hydjet %s;x_{J}",binnames[i].Data())); hsub[i] = geth(Form("hsub%d",i),Form("Subtracted NS %s;x_{J}",binnames[i].Data())); hshj[i] = geth(Form("hshj%d",i),Form("Subtracted Hydjet %s;x_{J}",binnames[i].Data())); hsbn[i] = geth(Form("hsbn%d",i),Form("Subtracted Naive %s;x_{J}",binnames[i].Data())); } auto fmcPb = config.getfile_djt("mcPbbfa"); Fill(fmcPb,{"pthat","weight","jtpt1","refpt1","bProdCode","jtptSL","refptSL","dphiSL1","refparton_flavorForB1","subidSL","bin","pairCodeSL1","discr_csvV1_1","jteta1","jtetaSL"},[&] (dict d) { if (d["pthat"]<pthatcut) return; if (d["jtpt1"]>pt1cut && d["refpt1"]>50 && abs(d["refparton_flavorForB1"])==5 && d["jtptSL"]>pt2cut) { int bin = getbinindex(d["bin"]); float xj = d["jtptSL"]/d["jtpt1"]; float w = weight1SLPbPb(d); if (AwaySide(d)) hasd[bin]->Fill(xj, w); if (AwaySide(d) && IsSignal(d)) hsig[bin]->Fill(xj,w); if (NearSide(d)) hbkg[bin]->Fill(xj,w); if (NearSide(d) && !IsSignal(d)) hhyj[bin]->Fill(xj,w); } }); for (int i=0;i<Nbins;i++) { hsub[i]->Add(hasd[i],hbkg[i],1,-1*bkgfractionInNearSide[i]); hsbn[i]->Add(hasd[i],hbkg[i],1,-1); hshj[i]->Add(hasd[i],hhyj[i],1,-1); } // for (int i=0;i<Nbins;i++) // hincsub[i]->Add(hincasd[i],hincbkg[i],1,-1); seth(bins);//Nbins,0,100); auto hcentrSubSIG = geth("hcentrSubSIG","Signal;bin;#LTx_{J}#GT"); auto hcentrSubASD = geth("hcentrSubASD","Unsubtracted;bin;#LTx_{J}#GT"); auto hcentrSubBKS = geth("hcentrSubBKS","Subtracted w/o bkg scaling;bin;#LTx_{J}#GT"); auto hcentrSubCLS = geth("hcentrSubCLS","Subtracted with bkg scaling;bin;#LTx_{J}#GT"); auto hcentrSubHJS = geth("hcentrSubHJS","Subtracted Hydjet;bin;#LTx_{J}#GT"); plotlegendpos = BottomRight; for (int i=0;i<Nbins;i++) { hcentrSubSIG->SetBinContent(i+1,hsig[i]->GetMean());hcentrSubSIG->SetBinError(i+1,hsig[i]->GetMeanError()); hcentrSubASD->SetBinContent(i+1,hasd[i]->GetMean());hcentrSubASD->SetBinError(i+1,hasd[i]->GetMeanError()); hcentrSubBKS->SetBinContent(i+1,hsbn[i]->GetMean());hcentrSubBKS->SetBinError(i+1,hsbn[i]->GetMeanError()); hcentrSubCLS->SetBinContent(i+1,hsub[i]->GetMean());hcentrSubCLS->SetBinError(i+1,hsub[i]->GetMeanError()); hcentrSubHJS->SetBinContent(i+1,hshj[i]->GetMean());hcentrSubHJS->SetBinError(i+1,hshj[i]->GetMeanError()); Draw({hsig[i],hsub[i],hshj[i]}); } plotymin = 0.55;//0.4; plotymax = 0.7;//0.8; plotlegendpos = BottomRight; aktstring = ""; plotputmean = false; //hcentrSubHJS - hydjet only subtraction // SetMC({hcentrSubSIG, hcentrSubBKS, hcentrSubASD}); // SetData({hcentrSubCLS}); hcentrSubSIG->SetMarkerStyle(kOpenSquare); hcentrSubBKS->SetMarkerStyle(kOpenSquare); hcentrSubASD->SetMarkerStyle(kOpenSquare); hcentrSubCLS->SetMarkerStyle(kFullCircle); hcentrSubSIG->SetMarkerColor(TColor::GetColorDark(2)); hcentrSubSIG->SetLineColor(TColor::GetColorDark(2)); hcentrSubBKS->SetMarkerColor(TColor::GetColorDark(3)); hcentrSubBKS->SetLineColor(TColor::GetColorDark(3)); hcentrSubASD->SetMarkerColor(TColor::GetColorDark(4)); hcentrSubASD->SetLineColor(TColor::GetColorDark(4)); hcentrSubCLS->SetMarkerColor(TColor::GetColorDark(3)); hcentrSubCLS->SetLineColor(TColor::GetColorDark(3)); plotoverwritecolors = false; plotlegenddx = -0.15; Draw({hcentrSubSIG,hcentrSubASD, hcentrSubBKS, hcentrSubCLS}); auto syst = (TH1F *)hcentrSubSIG->Clone("syst"); syst->Add(hcentrSubCLS,-1); map<TString,float> m; for (unsigned i=0;i<bins.size()-1;i++) { float misclosure = syst->GetBinContent(i+1); float err = hcentrSubCLS->GetBinError(i+1); m[Form("closure%d%d",(int)bins[i],(int)bins[i+1])]=sqrt(misclosure*misclosure+err*err); } WriteToFile(plotfoldername+"/hydjetclosuresyst.root",m); }
void CToolsCtlPanelText::UpdateTextControls(CAGText* pText) { scTypeSpecList tsList; pText->GetSelTSList(tsList); int nNumItems = tsList.NumItems(); if (!nNumItems) return; CAGSpec* pAGSpec = (CAGSpec*)(tsList[0].ptr()); LOGFONT SymFont = pAGSpec->m_Font; int SymTextSize = abs(pAGSpec->m_Font.lfHeight); FillType Fill = pAGSpec->m_FillType; COLORREF FillColor = pAGSpec->m_FillColor; COLORREF FillColor2 = pAGSpec->m_FillColor2; int LineWidth = pAGSpec->m_LineWidth; COLORREF LineColor = pAGSpec->m_LineColor; bool bSameFont = true; bool bSameBold = true; bool bSameItalic = true; bool bSameUnderline = true; bool bSameTextSize = true; bool bSameFillType = true; bool bSameFillColor = true; bool bSameFillColor2 = true; bool bSameLineWidth = true; bool bSameLineColor = true; for (int i = 1; i < nNumItems; i++) { pAGSpec = (CAGSpec*)(tsList[i].ptr()); if (lstrcmp(SymFont.lfFaceName, pAGSpec->m_Font.lfFaceName)) bSameFont = false; if (SymFont.lfWeight != pAGSpec->m_Font.lfWeight) bSameBold = false; if (!SymFont.lfItalic != !pAGSpec->m_Font.lfItalic) bSameItalic = false; if (!SymFont.lfUnderline != !pAGSpec->m_Font.lfUnderline) bSameUnderline = false; int nTextSize = abs(pAGSpec->m_Font.lfHeight); if (SymTextSize != nTextSize) bSameTextSize = false; if (Fill != pAGSpec->m_FillType) bSameFillType = false; if (FillColor != pAGSpec->m_FillColor) bSameFillColor = false; if (FillColor2 != pAGSpec->m_FillColor2) bSameFillColor2 = false; if (LineWidth != pAGSpec->m_LineWidth) bSameLineWidth = false; if (LineColor != pAGSpec->m_LineColor) bSameLineColor = false; } // Update the FillType control if (!bSameFillType) Fill = (FillType)-1; SetFillType(Fill); // Update the FillColor control if (!bSameFillColor) FillColor = CLR_NONE; SetFillColor(FillColor); // Update the FillColor2 control if (!bSameFillColor2) FillColor2 = CLR_NONE; SetFillColor2(FillColor2); // Update the LineWidth control if (!bSameLineWidth) LineWidth = -999; SetLineWidth(LineWidth); // Update the LineColor control if (!bSameLineColor) LineColor = CLR_NONE; SetLineColor(LineColor); // Update the Text Control //SetTitleText("Text"); //UpdateFillCtrls(); //UpdateLineCtrls(); ShowHideColors(); // Update the TextSize control if (!bSameTextSize) SymTextSize = -1; SetTextSize(SymTextSize); // Update the Font control LOGFONT* pFont = &SymFont; if (!bSameFont) pFont = NULL; SetFontControl(pFont, true/*bClearIfBad*/); // Update the text style controls m_ButtonBold.Check(bSameBold ? SymFont.lfWeight != FW_NORMAL : false); m_ButtonItalic.Check(bSameItalic ? !!SymFont.lfItalic : false); m_ButtonUnderline.Check(bSameUnderline ? !!SymFont.lfUnderline : false); // Update the Vertical adjustment controls eVertJust SpecVertJust = pText->GetVertJust(); m_ButtonTop.Check(SpecVertJust == eVertTop); m_ButtonMiddle.Check(SpecVertJust == eVertCentered); m_ButtonBottom.Check(SpecVertJust == eVertBottom); // Get the spec to determine Horizontal alignment scTypeSpecList tsListPara; pText->GetSelParaTSList(tsListPara); nNumItems = tsListPara.NumItems(); pAGSpec = (CAGSpec*)(tsListPara[0].ptr()); // Update the Horizontal adjustment controls eTSJust SpecHorzJust = pAGSpec->m_HorzJust; for (i = 1; i < nNumItems; i++) { pAGSpec = (CAGSpec*)(tsListPara[i].ptr()); if (SpecHorzJust != pAGSpec->m_HorzJust) { SpecHorzJust = eNoRag; break; } } m_ButtonLeft.Check(SpecHorzJust == eFlushLeft); m_ButtonCenter.Check(SpecHorzJust == eRagCentered); m_ButtonRight.Check(SpecHorzJust == eFlushRight); }
void CToolsPanelText2::UpdateTextControls(CAGText* pText) { scTypeSpecList tsList; pText->GetSelTSList(tsList); int nNumItems = tsList.NumItems(); if (!nNumItems) return; CAGSpec* pAGSpec = (CAGSpec*)(tsList[0].ptr()); FillType Fill = pAGSpec->m_FillType; COLORREF FillColor = pAGSpec->m_FillColor; COLORREF FillColor2 = pAGSpec->m_FillColor2; int LineWidth = pAGSpec->m_LineWidth; COLORREF LineColor = pAGSpec->m_LineColor; bool bSameFillType = true; bool bSameFillColor = true; bool bSameFillColor2 = true; bool bSameLineWidth = true; bool bSameLineColor = true; for (int i = 1; i < nNumItems; i++) { pAGSpec = (CAGSpec*)(tsList[i].ptr()); if (Fill != pAGSpec->m_FillType) bSameFillType = false; if (FillColor != pAGSpec->m_FillColor) bSameFillColor = false; if (FillColor2 != pAGSpec->m_FillColor2) bSameFillColor2 = false; if (LineWidth != pAGSpec->m_LineWidth) bSameLineWidth = false; if (LineColor != pAGSpec->m_LineColor) bSameLineColor = false; } // Update the FillType control if (!bSameFillType) Fill = (FillType)-1; SetFillType(Fill); // Update the FillColor control if (!bSameFillColor) FillColor = CLR_NONE; SetFillColor(FillColor); // Update the FillColor2 control if (!bSameFillColor2) FillColor2 = CLR_NONE; SetFillColor2(FillColor2); // Update the LineWidth control if (!bSameLineWidth) LineWidth = -999; SetLineWidth(LineWidth); // Update the LineColor control if (!bSameLineColor) LineColor = CLR_NONE; SetLineColor(LineColor); ShowHideColors(); }
CLineSegment::CLineSegment(Ñoordinate const & beginPos, Ñoordinate const & endPos, StrColor const & color) { SetLineColor(color); m_beginPoint = std::make_unique<CPoint>(beginPos.first, beginPos.second, color); m_endPoint = std::make_unique<CPoint>(endPos.first, endPos.second, color); }
void findfunc() { //dijet case // auto fmcppbjt = config.getfile_djt("mcppbfa"); // auto nt = (TTree *)fmcppbjt->Get("nt"); // seth(18,40,220); // auto hd = geth("hd"); // auto hn = geth("hn"); // nt->Project("hd","jtpt2","weight*(pthat>80 && jtpt1>100 && abs(refparton_flavorForB1)==5 && abs(refparton_flavorForB2)!=5 && dphi21>2.1)"); // nt->Project("hn","jtpt2","weight*(pthat>80 && jtpt1>100 && abs(refparton_flavorForB1)==5 && abs(refparton_flavorForB2)!=5 && dphi21>2.1 && discr_csvV1_2>0.9)"); // hn->Divide(hn,hd,1,1,"B") // hn->Fit(f) auto fpp = new TF1("fpp","expo",40,200); auto f1 = new TF1("fPb1","expo",40,200); auto f2 = new TF1("fPb2","expo",40,200); auto f3 = new TF1("fPb3","expo",40,200); seth(18,40,200); auto ntpp = (TTree *)config.getfile_inc("mcppqcd")->Get("nt"); auto hd = geth("hd"); auto hn = geth("hn",";p_{T} [GeV];mistag probability"); ntpp->Project("hd","jtpt","weight*(pthat>50 && refpt>20 && abs(refparton_flavorForB)!=5)"); ntpp->Project("hn","jtpt","weight*(pthat>50 && refpt>20 && abs(refparton_flavorForB)!=5 && discr_csvV1>0.9)"); hn->Divide(hn,hd,1,1,"B"); // hn->Scale(1/hn->Integral()); hn->Fit(fpp); auto nt = (TTree *)config.getfile_inc("mcPbqcd")->Get("nt"); auto hd1 = geth("hd1"); auto hn1 = geth("hn1",";p_{T} [GeV];mistag probability"); nt->Project("hd1","jtpt","weight*(pthat>50 && refpt>20 && bin < 20 && abs(refparton_flavorForB)!=5)"); nt->Project("hn1","jtpt","weight*(pthat>50 && refpt>20 && bin < 20 && abs(refparton_flavorForB)!=5 && discr_csvV1>0.9)"); hn1->Divide(hn1,hd1,1,1,"B"); // hn1->Scale(1/hn1->Integral()); hn1->Fit(f1); auto hd2 = geth("hd2"); auto hn2 = geth("hn2",";p_{T} [GeV];mistag probability"); nt->Project("hd2","jtpt","weight*(pthat>50 && refpt>20 && bin>=20 && bin<60 && abs(refparton_flavorForB)!=5)"); nt->Project("hn2","jtpt","weight*(pthat>50 && refpt>20 && bin>=20 && bin<60 && abs(refparton_flavorForB)!=5 && discr_csvV1>0.9)"); hn2->Divide(hn2,hd2,1,1,"B"); // hn2->Scale(1/hn2->Integral()); hn2->Fit(f2); auto hd3 = geth("hd3"); auto hn3 = geth("hn3",";p_{T} [GeV];mistag probability"); nt->Project("hd3","jtpt","weight*(pthat>50 && refpt>20 && bin>=60 && abs(refparton_flavorForB)!=5)"); nt->Project("hn3","jtpt","weight*(pthat>50 && refpt>20 && bin>=60 && abs(refparton_flavorForB)!=5 && discr_csvV1>0.9)"); hn3->Divide(hn3,hd3,1,1,"B"); // hn3->Scale(1/hn3->Integral()); hn3->Fit(f3); // because of backward imcompatibility with root version on polui cout<<"auto fpp = new TF1(\"fpp\",\"expo\","<<fpp->GetXmin()<<","<<fpp->GetXmax()<<");"<<endl; cout<<"auto fPb1 = new TF1(\"fPb1\",\"expo\","<<f1->GetXmin()<<","<<f1->GetXmax()<<");"<<endl; cout<<"auto fPb2 = new TF1(\"fPb2\",\"expo\","<<f2->GetXmin()<<","<<f2->GetXmax()<<");"<<endl; cout<<"auto fPb3 = new TF1(\"fPb3\",\"expo\","<<f3->GetXmin()<<","<<f3->GetXmax()<<");"<<endl; cout<<"fpp->SetParameters("<<fpp->GetParameter(0)<<","<<fpp->GetParameter(1)<<");"<<endl; cout<<"fPb1->SetParameters("<<f1->GetParameter(0)<<","<<f1->GetParameter(1)<<");"<<endl; cout<<"fPb2->SetParameters("<<f2->GetParameter(0)<<","<<f2->GetParameter(1)<<");"<<endl; cout<<"fPb3->SetParameters("<<f3->GetParameter(0)<<","<<f3->GetParameter(1)<<");"<<endl; // hn->SetMinimum(0); // hn1->SetMinimum(0); // hn2->SetMinimum(0); // hn3->SetMinimum(0); auto fout = new TFile("../correctionfiles/BXmistagfunc.root","recreate"); fout->cd(); fpp->Write(); f1->Write(); f2->Write(); f3->Write(); hn->Write(); hn1->Write(); hn2->Write(); hn3->Write(); auto c = getc(); f1->SetLineColor(kRed); f2->SetLineColor(kGreen); f3->SetLineColor(kOrange); fpp->SetLineColor(kBlue); auto l = getLegend(); l->AddEntry(fpp,"pp","L"); l->AddEntry(f1,"bin<20","L"); l->AddEntry(f2,"20<bin<60","L"); l->AddEntry(f3,"bin>60","L"); f1->GetXaxis()->SetTitle("p_{T} [GeV]"); f1->GetYaxis()->SetTitle("mistag probability"); f1->Draw(); f2->Draw("same"); f3->Draw("same"); fpp->Draw("same"); l->Draw(); SavePlot(c,"func"); float x = 0.55; float y = 0.75; auto t= new TLatex(); auto cpp = getc(); hn->Draw(); fpp->Draw("same"); t->DrawLatexNDC(x,y,"pp"); SavePlot(cpp,"pp"); auto c1 = getc(); hn1->Draw(); f1->Draw("same"); t->DrawLatexNDC(x,y,"PbPb 0-10%"); SavePlot(c1,"bin_0_20"); auto c2 = getc(); hn2->Draw(); f2->Draw("same"); t->DrawLatexNDC(x,y,"PbPb 10-30%"); SavePlot(c2,"bin_20_60"); auto c3 = getc(); hn3->Draw(); f3->Draw("same"); t->DrawLatexNDC(x,y,"PbPb 30-100%"); SavePlot(c3,"bin_60"); fout->Close(); }
CPoint::CPoint(float const & x, float const & y, StrColor const& color) : m_xPos(x) , m_yPos(y) { SetLineColor(color); }
void derivefromNS(bool data = false) { // float shift = mode == 2 ? -2 : mode*2; //mode = 0,1,2 shift = 0,2,-2 // cout<<"shift = "<<shift<<endl; auto file = config.getfile_djt(data ? "dtPbjcl" : "mcPbqcd"); auto nt = (TTree *)file->Get("nt"); for (unsigned i=1;i<binbounds.size();i++) { int b1 = binbounds[i-1]; int b2 = binbounds[i]; seth(71,38,180); //71,38 auto h = geth(Form("h%d%d",b1,b2)); //allowing one more bin for overflow seth(b2-b1,b1,b2); auto hb = geth(Form("hb%d%d",b1,b2)); TString mcappendix = data ? "" : "&& pthat>50";//"&& subid2!=0 && pthat>50"; //"&& pthat>50";//"&& !(subid2==0 && refpt2>20) && pthat>50"; //"&& pthat>80";// //Form("jtpt2+%f",shift) nt->Project(h->GetName(),"jtpt2", Form("weight*(jtpt1>100&&bin>=%d && bin<%d && dphi21<1.05 %s)",b1,b2,mcappendix.Data())); nt->Project(hb->GetName(),"bin", Form("weight*(jtpt1>100&&bin>=%d && bin<%d && dphi21<1.05 %s)",b1,b2,mcappendix.Data())); ScaleVisibleBins(h,NSfrac[i-1]); h->SetBinContent(1,h->GetBinContent(0)+h->GetBinContent(1)); // auto p = new TProfile(Form("p%d%d",b1,b2),Form("prof"),71,38,180); // nt->Project(p->GetName(),"(subid2 == 0 && refpt2 > 20):jtptSignal2",Form("weight*(jtpt1>100&&bin>=%d && bin<%d && dphiSignal21<1.05 && !(subid2==0 && refpt2>20) && pthat>80)",b1,b2)); auto g = getCDFgraph(h); g->GetXaxis()->SetTitle("p_{T,2} threshold [GeV]"); g->GetYaxis()->SetTitle("found fraction"); auto gtemp = getCDFgraph(h); meanb.push_back(hb->GetMean()); prob.push_back(gtemp->Eval(pt)); float c0=g->Eval(50); cout<<"prob at 50: "<<c0<<endl; auto gf = new TFile("graph.root","recreate"); gtemp->Write(); gf->Close(); // auto f = new TF1(Form("f%d%d",b1,b2),"1-[0]*exp(-[1]*(x-40))",40,180); // f->SetParameters(0.1,0.1); // // f->FixParameter(1,0.08); // auto f = new TF1(Form("f%d%d",b1,b2),"TMath::Erf((x-[0])/[1])",40,180); // f->SetParameters(40,10); // f->FixParameter(1,25); auto f = new TF1(Form("f%d%d",b1,b2),"exp(-[0]*exp(-[1]*x))",40,180); f->SetParameters(100,0.1); // f->FixParameter(1,0.11); //!!!!!!!!!! f->SetLineColor(kRed); f->SetLineWidth(2); g->Fit(f,"RM"); fs.push_back(f); binmean.push_back(hb->GetMean()); float median = -1/f->GetParameter(1)*log(-1/f->GetParameter(0)*log(0.5)); Draw({h}); // h->Rebin(2); auto gcoarse = getCDFgraph(h); auto c = getc(); TLatex *Tl = new TLatex(); gcoarse->SetMinimum(0);g->SetMaximum(1); gcoarse->Draw("AP"); f->Draw("same"); Tl->DrawLatexNDC(0.6,0.55,"y=e^{-a e^{-b x} }"); Tl->DrawLatexNDC(0.6,0.50,Form("a = %.1f",f->GetParameter(0))); Tl->DrawLatexNDC(0.6,0.45,Form("b = %.2f",f->GetParameter(1))); Tl->DrawLatexNDC(0.6,0.4,Form("PbPb bin %d-%d",b1,b2)); Tl->DrawLatexNDC(0.6,0.35,Form("median = %.2f",median)); TLine *l1 = new TLine(median,0,median, f->Eval(median)); l1->Draw(); TLine *l2 = new TLine(0,0.5,median, f->Eval(median)); l2->Draw(); // p->SetMarkerColor(kRed); // p->SetMarkerSize(1); // p->Draw("same"); SavePlot(c,Form("fit%d%d",b1,b2));//return; } }