// histograms filled and drawn in a loop void hsum() { // // To see the output of this macro, click begin_html <a href="gif/hsum.gif" >here</a> end_html // Simple example illustrating how to use the C++ interpreter // to fill histograms in a loop and show the graphics results //Author: Rene Brun TCanvas *c1 = new TCanvas("c1","The HSUM example",200,10,600,400); c1->SetGrid(); gBenchmark->Start("hsum"); // Create some histograms. auto total = new TH1F("total","This is the total distribution",100,-4,4); auto main = new TH1F("main","Main contributor",100,-4,4); auto s1 = new TH1F("s1","This is the first signal",100,-4,4); auto s2 = new TH1F("s2","This is the second signal",100,-4,4); total->Sumw2(); // store the sum of squares of weights total->SetMarkerStyle(21); total->SetMarkerSize(0.7); main->SetFillColor(16); s1->SetFillColor(42); s2->SetFillColor(46); TSlider *slider = 0; // Fill histograms randomly gRandom->SetSeed(); const Int_t kUPDATE = 500; Float_t xs1, xs2, xmain; for ( Int_t i=0; i<10000; i++) { xmain = gRandom->Gaus(-1,1.5); xs1 = gRandom->Gaus(-0.5,0.5); xs2 = gRandom->Landau(1,0.15); main->Fill(xmain); s1->Fill(xs1,0.3); s2->Fill(xs2,0.2); total->Fill(xmain); total->Fill(xs1,0.3); total->Fill(xs2,0.2); if (i && (i%kUPDATE) == 0) { if (i == kUPDATE) { total->Draw("e1p"); main->Draw("same"); s1->Draw("same"); s2->Draw("same"); c1->Update(); slider = new TSlider("slider", "test",4.2,0,4.6,total->GetMaximum(),38); slider->SetFillColor(46); } if (slider) slider->SetRange(0,Float_t(i)/10000.); c1->Modified(); c1->Update(); } } slider->SetRange(0,1); total->Draw("sameaxis"); // to redraw axis hidden by the fill area c1->Modified(); gBenchmark->Show("hsum"); }
void nuiDrawContext::DrawPoint(float x, float y) { nuiShape shp; shp.AddCircle(x, y, mCurrentState.mLineWidth); nuiColor col(mCurrentState.mFillColor); SetFillColor(mCurrentState.mStrokeColor); DrawShape(&shp, eFillShape); SetFillColor(col); }
void nuiDrawContext::DrawShape(nuiShape* pShape, nuiShapeMode Mode, float Quality) { NGL_ASSERT(pShape != NULL); PushState(); switch (Mode) { case eStrokeShape: { nuiRenderObject* pObject = pShape->Outline(Quality, mCurrentState.mLineWidth, mCurrentState.mLineJoin, mCurrentState.mLineCap); SetFillColor(GetStrokeColor()); SetTexture(mpAATexture); EnableTexturing(true); EnableBlending(true); SetBlendFunc(nuiBlendTransp);//GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); DrawObject(*pObject); delete pObject; } break; case eFillShape: { nuiTessellator* pTess = new nuiTessellator(pShape); pTess->SetFill(true); nuiRenderObject* pObject = pTess->Generate(Quality); DrawObject(*pObject); delete pObject; delete pTess; } break; case eStrokeAndFillShape: { { nuiRenderObject* pObject = pShape->Fill(Quality); DrawObject(*pObject); delete pObject; } { nuiRenderObject* pObject = pShape->Outline(Quality, mCurrentState.mLineWidth, mCurrentState.mLineJoin, mCurrentState.mLineCap); SetFillColor(GetStrokeColor()); SetTexture(mpAATexture); EnableTexturing(true); EnableBlending(true); SetBlendFunc(nuiBlendTransp);//GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); DrawObject(*pObject); delete pObject; } } break; case eDefault: //? break; } PopState(); }
static void DOCX_Circle(double x, double y, double r, const pGEcontext gc, pDevDesc dev) { DOCDesc *pd = (DOCDesc *) dev->deviceSpecific; int idx = get_idx(dev); fprintf(pd->dmlFilePointer, docx_elt_tag_start); if( pd->editable > 0 ) fprintf(pd->dmlFilePointer, "<wps:cNvPr id=\"%d\" name=\"Point %d\" />%s", idx, idx, docx_unlock_properties); else fprintf(pd->dmlFilePointer, "<wps:cNvPr id=\"%d\" name=\"Point %d\" />%s", idx, idx, docx_lock_properties); fprintf(pd->dmlFilePointer, "<wps:spPr>"); fprintf(pd->dmlFilePointer, "<a:xfrm>"); fprintf(pd->dmlFilePointer, "<a:off x=\"%.0f\" y=\"%.0f\"/>", p2e_(pd->offx + x - r), p2e_(pd->offy + y - r)); fprintf(pd->dmlFilePointer, "<a:ext cx=\"%.0f\" cy=\"%.0f\"/>", p2e_(r * 2), p2e_(r * 2)); fprintf(pd->dmlFilePointer, "</a:xfrm>"); fprintf(pd->dmlFilePointer, "<a:prstGeom prst=\"ellipse\"><a:avLst /></a:prstGeom>"); SetFillColor(dev, gc); SetLineSpec(dev, gc); fprintf(pd->dmlFilePointer, "</wps:spPr>"); fprintf(pd->dmlFilePointer, "<wps:bodyPr />"); fprintf(pd->dmlFilePointer, docx_elt_tag_end); fprintf(pd->dmlFilePointer, "\n"); fflush(pd->dmlFilePointer); }
void CReportEntityBox::Copy( CDiagramEntity * obj ) /* ============================================================ Function : CReportEntityBox::Copy Description : Copies the data from "obj" to this object. Access : Public Return : void Parameters : CDiagramEntity * obj - Object to copy from Usage : Call to copy data from "obj" ============================================================*/ { CDiagramEntity::Copy( obj ); CReportEntityBox* copy = static_cast< CReportEntityBox* >( obj ); SetBorderThickness( copy->GetBorderThickness() ); SetBorderStyle( copy->GetBorderStyle() ); SetBorderColor( copy->GetBorderColor() ); SetFill( copy->GetFill() ); SetFillColor( copy->GetFillColor() ); }
void nuiGLDrawContext::BlurRect(const nuiRect& rRect, uint Strength) { nuiRect Rect = rRect; if (mClippingRect.mEnabled) Rect.Intersect(mClippingRect,rRect); nuiRect size = Rect.Size(); nuiTexture* pScratchPad = GetScratchPad(ToZero(size.GetWidth()), ToZero(size.GetHeight())); if (!pScratchPad) return; SetTexture(pScratchPad); glPushMatrix(); glLoadIdentity(); EnableBlending(true); EnableTexture2D(true); SetBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); do { glCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, ToZero(rRect.mLeft), ToZero(mHeight) - 1 - ToZero(rRect.mTop) - ToZero(rRect.GetHeight()), ToZero(rRect.GetWidth()), ToZero(rRect.GetHeight()) ); SetFillColor(nuiColor(1,1,1,.15f)); nuiRect rect = Rect; rect.Move(-1,-1); DrawImage(rect,size); rect.Move(1,0); DrawImage(rect,size); rect.Move(1,0); DrawImage(rect,size); rect.Move(-2,1); DrawImage(rect,size); rect.Move(1,0); DrawImage(rect,size); rect.Move(1,0); DrawImage(rect,size); rect.Move(-2,1); DrawImage(rect,size); rect.Move(0,1); DrawImage(rect,size); rect.Move(0,1); DrawImage(rect,size); } while ((long)(Strength--) > 0); EnableBlending(false); EnableTexture2D(false); glPopMatrix(); }
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); }
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); }
CPolyLineDrawing::CPolyLineDrawing(int Thickness, COLORREF lineColor, COLORREF fillColor, CPoint startpt) { vXYpoints.push_back(startpt); SetType("PolyLine"); SetThickness(Thickness); SetLineColor(lineColor); SetFillColor(fillColor); }
UIStatusBar::UIStatusBar() : UIElement(0, UI_HEIGHT - UI_STATUS_BAR_HEIGHT, UI_STATUS_BAR_WIDTH, UI_STATUS_BAR_HEIGHT) { SetDrawBorder(false); SetFillColor(ILI9341_LIGHTGREY); this->x = 0; this->y = 0; this->last_time = millis(); }
void exampleBigaus() { int n = 100000; int nbins = 50; double xmin = -10; double xmax = 10; TH2 * h2 = new TH2D("h1","h2",nbins,xmin,xmax, nbins, xmin, xmax); // for the ROOT master and 6.07.06 #if ROOT_VERSION_CODE >= ROOT_VERSION(6,7,6) TF2 * f2 = new TF2("bigaus","bigaus"); #else // for older ROOT version TF2 * f2 = new TF2("bigaus",bigaus_function,xmin,xmax,xmin,xmax,6); #endif f2->SetParameters(1,2,2,-1,3,0.3); h2->FillRandom("bigaus"); f2->SetParameters(100,2,2,-1,3,0.3); h2->Fit("bigaus"); h2->Draw("COLZ"); // draw contours of fit result for sigmax and sigmay auto fitter = (TBackCompFitter *) TVirtualFitter::GetFitter(); int par1 = 2; // index of sigmax int par2 = 4; // index of sigmax // make contour at desired CL double cl1 = 0.68; // make a contour with 80 points auto gr1 = new TGraph( 80 ); fitter->Contour( par1, par2, gr1, cl1); new TCanvas(); gr1->SetFillColor(42); auto gr2 = new TGraph( 80 ); double cl2 = 0.95; fitter->Contour( par1, par2, gr2, cl2); gr2->SetFillColor(38); gr2->Draw("ALF"); gr1->Draw("LF"); }
void CReportEntityBox::Serialize(CArchive& ar) { typedef struct { int a_f; int b_f; } BOX_RESERVE_FIELDS; BOX_RESERVE_FIELDS box_reserve; memset(&box_reserve,0,sizeof(BOX_RESERVE_FIELDS)); CDiagramEntity::Serialize(ar); if (ar.IsStoring()) { // —охран¤ем double thickness = CUnitConversion::PixelsToInches( GetBorderThickness() ); ar.Write(&thickness,sizeof(double)); unsigned int bst = GetBorderStyle( ); ar.Write(&bst,sizeof(unsigned int)); unsigned int brC = GetBorderColor( ); ar.Write(&brC,sizeof(unsigned int)); BOOL gf = GetFill(); ar.Write(&gf, sizeof(BOOL)); brC = GetFillColor(); ar.Write(&brC,sizeof(unsigned int)); ar.Write(&box_reserve,sizeof(BOX_RESERVE_FIELDS)); } else { // „итаем double bordhickness; ar.Read(&bordhickness,sizeof(double)); unsigned int bordst; ar.Read(&bordst,sizeof(unsigned int)); unsigned int linecolor; ar.Read(&linecolor,sizeof(unsigned int)); BOOL fil; ar.Read(&fil,sizeof(BOOL)); unsigned int filcolor; ar.Read(&filcolor,sizeof(unsigned int)); ar.Read(&box_reserve,sizeof(BOX_RESERVE_FIELDS)); int bt = CUnitConversion::InchesToPixels( bordhickness ); SetBorderThickness( bt ); SetBorderStyle( bordst ); SetBorderColor( linecolor ); SetFill( fil ); SetFillColor( filcolor ); } }
//背景擦出消息处理函数 static ptu32_t HmiErasebkgnd(struct WindowMsg *pMsg) { HWND hwnd; HDC hdc; RECT rc0; hwnd =pMsg->hwnd; hdc =(HDC)pMsg->Param1; GetClientRect(hwnd,&rc0); SetFillColor(hdc,RGB(200,200,200)); FillRect(hdc,&rc0); return true; }
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"); }
//创建窗口信息 static ptu32_t HmiCreate(struct WindowMsg *pMsg) { HWND hwnd; RECT rc0; HDC hdc; hwnd =pMsg->hwnd; text_align_idx =0; hdc=BeginPaint(hwnd); GetClientRect(hwnd,&rc0); SetFillColor(hdc,RGB(250,250,250)); FillRect(hdc,&rc0); prog1_val=0; prog2_val=0; prog1_inc=1; prog2_inc=1; pb1.Flag =PBF_SHOWTEXT|PBF_ORG_LEFT; pb1.Range =100; pb1.Pos =prog1_val; pb1.FGColor =RGB(0,160,0); pb1.BGColor =RGB(10,10,10); pb1.TextColor =RGB(240,240,240); pb1.DrawTextFlag =DT_VCENTER|DT_CENTER; pb2.Flag =PBF_SHOWTEXT|PBF_ORG_BOTTOM; pb2.Range =100; pb2.Pos =prog1_val; pb2.FGColor =RGB(200,0,0); pb2.BGColor =RGB(10,10,200); pb2.TextColor =RGB(1,1,1); pb2.DrawTextFlag =DT_VCENTER|DT_CENTER; GetClientRect(hwnd,&rc0); CreateButton("关闭",WS_CHILD|BS_NORMAL|WS_BORDER|WS_VISIBLE,RectW(&rc0)-64,RectH(&rc0)-28,60,24,hwnd,ID_CLOSE,NULL,NULL); CreateProgressBar("水平进度条1",WS_CHILD|PBS_HOR|WS_VISIBLE,8,36,128,28,hwnd,ID_PROGBAR1,&pb1,NULL); CreateProgressBar("垂直进度条2",WS_CHILD|PBS_VER|WS_VISIBLE,160,36,28,128,hwnd,ID_PROGBAR2,&pb2,NULL); GDD_CreateTimer(hwnd,1,3000,TMR_START); GDD_CreateTimer(hwnd,2,100,TMR_START); return true; }
static void DOCX_Rect(double x0, double y0, double x1, double y1, const pGEcontext gc, pDevDesc dev) { double tmp; DOCDesc *pd = (DOCDesc *) dev->deviceSpecific; int idx = get_idx(dev); if (x0 >= x1) { tmp = x0; x0 = x1; x1 = tmp; } if (y0 >= y1) { tmp = y0; y0 = y1; y1 = tmp; } // fprintf(pd->dmlFilePointer, docx_elt_tag_start); if( pd->editable < 1 ) fprintf(pd->dmlFilePointer, "<wps:cNvPr id=\"%d\" name=\"Rectangle %d\" />%s", idx, idx, docx_lock_properties); else fprintf(pd->dmlFilePointer, "<wps:cNvPr id=\"%d\" name=\"Rectangle %d\" />%s", idx, idx, docx_unlock_properties); fprintf(pd->dmlFilePointer, "<wps:spPr>"); fprintf(pd->dmlFilePointer, "<a:xfrm>"); fprintf(pd->dmlFilePointer, "<a:off x=\"%.0f\" y=\"%.0f\"/>", p2e_(pd->offx + x0), p2e_(pd->offy + y0)); fprintf(pd->dmlFilePointer, "<a:ext cx=\"%.0f\" cy=\"%.0f\"/>", p2e_(x1 - x0), p2e_(y1 - y0)); fprintf(pd->dmlFilePointer, "</a:xfrm>"); fprintf(pd->dmlFilePointer, "<a:prstGeom prst=\"rect\"><a:avLst /></a:prstGeom>"); SetFillColor(dev, gc); SetLineSpec(dev, gc); fprintf(pd->dmlFilePointer, "</wps:spPr>"); fprintf(pd->dmlFilePointer, "<wps:bodyPr />"); fprintf(pd->dmlFilePointer, docx_elt_tag_end); fprintf(pd->dmlFilePointer, "\n"); fflush(pd->dmlFilePointer); //return; }
OP_STATUS SVGCanvasState::SetDecorationPaint() { SVGCanvasState* decostate = GetDecorationState(); if (decostate == this) return OpStatus::OK; if (decostate != NULL) { SetFillColor(decostate->m_fillcolor); switch (decostate->m_use_fill) { #ifdef SVG_SUPPORT_PAINTSERVERS case USE_PSERVER: SVGPaintServer::IncRef(decostate->m_fill_pserver); SetFillPaintServer(decostate->m_fill_pserver); break; #endif // SVG_SUPPORT_PAINTSERVERS } EnableFill(decostate->m_use_fill); SetStrokeColor(decostate->m_strokecolor); switch (decostate->m_use_stroke) { #ifdef SVG_SUPPORT_PAINTSERVERS case USE_PSERVER: SVGPaintServer::IncRef(decostate->m_stroke_pserver); SetStrokePaintServer(decostate->m_stroke_pserver); break; #endif // SVG_SUPPORT_PAINTSERVERS } EnableStroke(decostate->m_use_stroke); } else { // Use default paint EnableFill(SVGCanvasState::USE_COLOR); SetFillColorRGB(0,0,0); SetFillOpacity(0xff); EnableStroke(SVGCanvasState::USE_NONE); } return OpStatus::OK; }
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(); } }
Mover () : Sketch () { width = 8.0; velocity = Vect (0, 0, 0); top_speed = 3.0; // store feld dimenions and orientation SpaceFeld *f = Feld (); loc = f -> Loc (); over = f -> Over (); up = f -> Up (); norm = f -> Norm (); wid = f -> Width (); hei = f -> Height (); SlapOnFeld (); // draw SetStroked (false); SetFillColor (Color (1, 1, 1)); DrawEllipse (Vect (0, 0, 0), width, width); }
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 doPlotXJ(TString outname, int inc_or_bjet=1, bool useMC = true, bool addppunc = false) { macro m(outname); // bool useMC = true; // bool addppunc = false; TFile *fin = new TFile("results_redoana_default/xJdphi.root"); TFile *fpps1 = new TFile("results_redoana_ppsmear1/xJdphi.root"); TFile *fpps2 = new TFile("results_redoana_ppsmear2/xJdphi.root"); TFile *fpps3 = new TFile("results_redoana_ppsmear3/xJdphi.root"); string species = "inc"; if(inc_or_bjet) species = "bjt"; TH1F *hData010 = (TH1F*) fin->Get(Form("xJ_data_%s_0_10",species.c_str())); TH1F *hData1030 = (TH1F*) fin->Get(Form("xJ_data_%s_10_30",species.c_str())); TH1F *hData30100 = (TH1F*) fin->Get(Form("xJ_data_%s_30_100",species.c_str())); TH1F *hDataPP = (TH1F*) fin->Get(Form("xJ_data_%s_pp",species.c_str())); TH1F *hMC010; TH1F *hMC1030; TH1F *hMC30100; TH1F *hMCPP = (TH1F*) fin->Get(Form("xJ_mc_%s_pp",species.c_str())); if (useMC) { hMC010 = (TH1F*) fin->Get(Form("xJ_mc_%s_0_10",species.c_str())); hMC1030 = (TH1F*) fin->Get(Form("xJ_mc_%s_10_30",species.c_str())); hMC30100 = (TH1F*) fin->Get(Form("xJ_mc_%s_30_100",species.c_str())); } else { hMC010 = (TH1F*) fpps1->Get(Form("xJ_data_%s_pp",species.c_str())); hMC1030 = (TH1F*) fpps2->Get(Form("xJ_data_%s_pp",species.c_str())); hMC30100 = (TH1F*) fpps3->Get(Form("xJ_data_%s_pp",species.c_str())); } // if(inc_or_bjet) hMCPP = (TH1F*) fin->Get(Form("xJ_mc_%s_pp;1",species.c_str())); Normalize({hMC010,hMC1030,hMC30100,hMCPP}); //temporary fix vector<float> syserr; if (inc_or_bjet) syserr = {0.023,0.018,0.014,0.008}; //0-10%, 10-30%, 30-100%, pp else syserr = {0.023,0.016,0.010,0.007}; int syscolor = inc_or_bjet ? kredLight : kblueLight; int color = kblue; if(inc_or_bjet) color=kred; auto hData010sys = makesysplot(hData010,syserr[0],syscolor); auto hData1030sys = makesysplot(hData1030,syserr[1],syscolor); auto hData30100sys = makesysplot(hData30100,syserr[2],syscolor); auto hDataPPsys = makesysplot(hDataPP,syserr[3],syscolor); auto hSmPP010sys = makesysplot(hMC010,syserr[3],syscolor); auto hSmPP1030sys = makesysplot(hMC1030,syserr[3],syscolor); auto hSmPP30100sys = makesysplot(hMC30100,syserr[3],syscolor); hSmPP30100sys->SetFillStyle(3005); hSmPP30100sys->SetFillColor(color); hSmPP1030sys->SetFillStyle(3005); hSmPP1030sys->SetFillColor(color); hSmPP010sys->SetFillStyle(3005); hSmPP010sys->SetFillColor(color); lumi_sqrtS = lumi_sqrtSPbPb; TCanvas *c1=new TCanvas("c1","c1",600,600); hData010->SetMarkerColor(color); hData010->SetLineColor(color); hMC010->SetLineColor(color); hData010->GetXaxis()->CenterTitle(1); hData010->GetYaxis()->CenterTitle(1); hData010->SetYTitle("Event fraction"); hData010->Draw(); hData010sys->Draw("e2,same"); if (addppunc) hSmPP010sys->Draw("e2,same"); hData010->Draw("same"); //b/c systematics should be on the back hMC010->SetMarkerSize(0); hMC010->Draw("h,same"); CMS_lumi(c1, iPeriod, iPos ); TLegend *l =new TLegend(0.43,0.63,0.9,0.81); l->AddEntry(hData010,"Data","P"); l->AddEntry(hMC010,useMC ? "Pythia6" : "pp-based reference","l"); if(inc_or_bjet)l->SetHeader("b dijets"); else l->SetHeader("Inclusive dijets"); l->SetFillStyle(0); l->Draw(); SavePlot(c1,"xJ010"+species); TCanvas *c2=new TCanvas("c2","c2",600,600); hData1030->SetMarkerColor(color); hData1030->SetLineColor(color); hMC1030->SetLineColor(color); hData1030->GetXaxis()->CenterTitle(1); hData1030->GetYaxis()->CenterTitle(1); hData1030->SetYTitle("Event fraction"); hData1030->Draw(); hData1030sys->Draw("e2,same"); if (addppunc) hSmPP1030sys->Draw("e2,same"); hData1030->Draw("same"); hMC1030->SetMarkerSize(0); hMC1030->Draw("h,same"); CMS_lumi(c2, iPeriod, iPos ); l->Draw(); SavePlot(c2,"xJ1030"+species); TCanvas *c3=new TCanvas("c3","c3",600,600); hData30100->SetMarkerColor(color); hData30100->SetLineColor(color); hMC30100->SetLineColor(color); hData30100->GetXaxis()->CenterTitle(1); hData30100->GetYaxis()->CenterTitle(1); hData30100->SetYTitle("Event fraction"); hData30100->Draw(); hData30100sys->Draw("e2,same"); if (addppunc) hSmPP30100sys->Draw("e2,same"); hData30100->Draw("same"); hMC30100->SetMarkerSize(0); hMC30100->Draw("h,same"); CMS_lumi(c3, iPeriod, iPos ); l->Draw(); SavePlot(c3,"xJ30100"+species); lumi_sqrtS = lumi_sqrtSpp; TCanvas *c4=new TCanvas("c4","c4",600,600); hDataPP->SetMarkerColor(color); hDataPP->SetLineColor(color); hMCPP->SetLineColor(color); hDataPP->GetXaxis()->CenterTitle(1); hDataPP->GetYaxis()->CenterTitle(1); hDataPP->SetYTitle("Event fraction"); hDataPP->Draw(); hDataPPsys->Draw("e2,same"); hDataPP->Draw("same"); hMCPP->SetMarkerSize(0); hMCPP->Draw("h,same"); CMS_lumi(c4, iPeriod, iPos ); l->Clear(); l->AddEntry(hDataPP,"Data","P"); l->AddEntry(hMCPP,"Pythia6","l"); if(inc_or_bjet)l->SetHeader("b dijets"); else l->SetHeader("Inclusive dijets"); l->Draw(); SavePlot(c4,"xJpp"+species); }
static void DOCX_Polygon(int n, double *x, double *y, const pGEcontext gc, pDevDesc dev) { DOCDesc *pd = (DOCDesc *) dev->deviceSpecific; int idx = get_idx(dev); int i; double maxx = 0, maxy = 0; for (i = 0; i < n; i++) { if (x[i] > maxx) maxx = x[i]; if (y[i] > maxy) maxy = y[i]; } double minx = maxx, miny = maxy; for (i = 0; i < n; i++) { if (x[i] < minx) minx = x[i]; if (y[i] < miny) miny = y[i]; } // fprintf(pd->dmlFilePointer, docx_elt_tag_start); if( pd->editable < 1 ) fprintf(pd->dmlFilePointer, "<wps:cNvPr id=\"%d\" name=\"Polygon %d\" />%s", idx, idx, docx_lock_properties); else fprintf(pd->dmlFilePointer, "<wps:cNvPr id=\"%d\" name=\"Polygon %d\" />%s", idx, idx, docx_unlock_properties); fprintf(pd->dmlFilePointer, "<wps:spPr>"); fprintf(pd->dmlFilePointer, "<a:xfrm>"); fprintf(pd->dmlFilePointer, "<a:off x=\"%.0f\" y=\"%.0f\"/>", p2e_(pd->offx + minx), p2e_(pd->offy + miny)); fprintf(pd->dmlFilePointer, "<a:ext cx=\"%.0f\" cy=\"%.0f\"/>", p2e_(maxx - minx), p2e_(maxy - miny)); fprintf(pd->dmlFilePointer, "</a:xfrm>"); fprintf(pd->dmlFilePointer, "<a:custGeom>"); fprintf(pd->dmlFilePointer, "<a:pathLst>"); fprintf(pd->dmlFilePointer, "<a:path w=\"%.0f\" h=\"%.0f\">", p2e_(maxx-minx), p2e_(maxy-miny)); fprintf(pd->dmlFilePointer, "<a:moveTo><a:pt x=\"%.0f\" y=\"%.0f\" /></a:moveTo>", p2e_(x[0] - minx), p2e_(y[0] - miny)); for (i = 1; i < n; i++) { fprintf(pd->dmlFilePointer, "<a:lnTo><a:pt x=\"%.0f\" y=\"%.0f\" /></a:lnTo>", p2e_(x[i] - minx), p2e_(y[i] - miny)); } fprintf(pd->dmlFilePointer, "<a:close/>"); fprintf(pd->dmlFilePointer, "</a:path>"); fprintf(pd->dmlFilePointer, "</a:pathLst>"); fprintf(pd->dmlFilePointer, "</a:custGeom>"); SetFillColor(dev, gc); SetLineSpec(dev, gc); fprintf(pd->dmlFilePointer, "</wps:spPr>"); fprintf(pd->dmlFilePointer, "<wps:bodyPr />"); fprintf(pd->dmlFilePointer, docx_elt_tag_end); fprintf(pd->dmlFilePointer, "\n"); fflush(pd->dmlFilePointer); //return; }
ezQtGroupBoxBase* ezQtPropertyContainerWidget::CreateElement(QWidget* pParent) { auto pBox = new ezQtCollapsibleGroupBox(pParent); pBox->SetFillColor(palette().window().color()); return pBox; }
static u32 win_proc(MSG *pMsg) { HWND hwnd; HDC hdc; RECT rc,rc0; u32 i,x,y; hwnd =pMsg->hwnd; switch(pMsg->Code) { case MSG_CREATE: cfg_idx =0; bBorder=TRUE; bBKGND=TRUE; bColor=TRUE; for(i=0;i<8;i++) { timer_count[i] =0; timer_run[i] =FALSE; } GetClientRect(hwnd,&rc0); CreateWindow(BUTTON,"关闭",WS_CHILD|BS_NORMAL|WS_BORDER|WS_VISIBLE,RectW(&rc0)-64,RectH(&rc0)-28,60,24,hwnd,ID_CLOSE,NULL); y=20; x=128+8; CreateWindow(BUTTON,"运行",WS_CHILD|BS_HOLD|WS_VISIBLE,x,y+0*28,60,24,hwnd,ID_START_1,NULL); CreateWindow(BUTTON,"运行",WS_CHILD|BS_HOLD|WS_VISIBLE,x,y+1*28,60,24,hwnd,ID_START_2,NULL); CreateWindow(BUTTON,"运行",WS_CHILD|BS_HOLD|WS_VISIBLE,x,y+2*28,60,24,hwnd,ID_START_3,NULL); CreateWindow(BUTTON,"运行",WS_CHILD|BS_HOLD|WS_VISIBLE,x,y+3*28,60,24,hwnd,ID_START_4,NULL); y=20; x=128+8+64; CreateWindow(BUTTON,"清零",WS_CHILD|WS_VISIBLE,x,y+0*28,60,24,hwnd,ID_CLR_1,NULL); CreateWindow(BUTTON,"清零",WS_CHILD|WS_VISIBLE,x,y+1*28,60,24,hwnd,ID_CLR_2,NULL); CreateWindow(BUTTON,"清零",WS_CHILD|WS_VISIBLE,x,y+2*28,60,24,hwnd,ID_CLR_3,NULL); CreateWindow(BUTTON,"清零",WS_CHILD|WS_VISIBLE,x,y+3*28,60,24,hwnd,ID_CLR_4,NULL); GDD_CreateTimer(hwnd,0,timer_interval[0],0); GDD_CreateTimer(hwnd,1,timer_interval[1],0); GDD_CreateTimer(hwnd,2,timer_interval[2],0); GDD_CreateTimer(hwnd,3,timer_interval[3],0); GDD_CreateTimer(hwnd,7,500,TMR_START); break; //// case MSG_TIMER: { i =pMsg->Param1&0xFF; timer_count[i]++; InvalidateWindow(hwnd); } break; case MSG_NOTIFY: { u16 event,id; event =HI16(pMsg->Param1); id =LO16(pMsg->Param1); switch(event) { case BTN_DOWN: //按钮按下 if(id>=ID_START_1 && id<=ID_START_4) { i =id&0xF; timer_run[i] =TRUE; GDD_ResetTimer(GDD_FindTimer(hwnd,i),timer_interval[i],TMR_START); } if(id>=ID_CLR_1 && id<=ID_CLR_4) { i =id&0xF; timer_count[i] =0; InvalidateWindow(hwnd); } break; //// case BTN_UP: //按钮弹起 if(id==ID_CLOSE) { PostMessage(hwnd,MSG_CLOSE,0,0); } if(id>=ID_START_1 && id<=ID_START_4) { i =id&0xF; timer_run[i] =FALSE; GDD_ResetTimer(GDD_FindTimer(hwnd,i),timer_interval[i],0); } break; //// } } break; //// case MSG_PAINT: { char wbuf[32]; hdc =BeginPaint(hwnd); GetClientRect(hwnd,&rc0); SetFillColor(hdc,RGB(100,100,100)); FillRect(hdc,&rc0); SetRect(&rc,4,20,128,24); for(i=0;i<4;i++) { SetTextColor(hdc,DrawText_Color_Tbl[i].text_color); SetDrawColor(hdc,DrawText_Color_Tbl[i].bd_color); SetFillColor(hdc,DrawText_Color_Tbl[i].bk_color); sprintf(wbuf," 定时器%d: %d",i+1,timer_count[i]); if(timer_run[i]!=FALSE) { DrawText(hdc,wbuf,-1,&rc,DT_LEFT|DT_VCENTER|DT_BORDER|DT_BKGND); } else { if(timer_count[7]&0x01) { DrawText(hdc,wbuf,-1,&rc,DT_LEFT|DT_VCENTER|DT_BORDER|DT_BKGND); } else { DrawText(hdc,wbuf,-1,&rc,DT_LEFT|DT_VCENTER|DT_BKGND); } } OffsetRect(&rc,0,28); } EndPaint(hwnd,hdc); } break; //// default: return DefWindowProc(pMsg); } return 0; }
//----CheckBox绘制函数---------------------------------------------------------- //功能:这是CheckBox控件的MSG_PAINT消息响应函数 //参数:pMsg,消息指针 //返回:固定true //----------------------------------------------------------------------------- static bool_t CheckBox_Paint(struct WindowMsg *pMsg) { HWND hwnd; HDC hdc; RECT rc; RECT rc0; hwnd=pMsg->hwnd; hdc =BeginPaint(hwnd); if(NULL!=hdc) { GetClientRect(hwnd,&rc0); SetTextColor(hdc,RGB(1,1,1)); SetDrawColor(hdc,RGB(40,40,40)); SetFillColor(hdc,RGB(200,200,200)); FillRect(hdc,&rc0); if(hwnd->Style&CBS_SELECTED) { CopyRect(&rc,&rc0); rc.right =rc.left+RectH(&rc0); InflateRect(&rc,-2,-2); SetDrawColor(hdc,RGB(70,70,70)); DrawRect(hdc,&rc); InflateRect(&rc,-1,-1); SetDrawColor(hdc,RGB(110,110,110)); DrawRect(hdc,&rc); InflateRect(&rc,-1,-1); SetFillColor(hdc,RGB(240,240,240)); FillRect(hdc,&rc); InflateRect(&rc,-4,-4); SetDrawColor(hdc,RGB(150,150,240)); DrawRect(hdc,&rc); InflateRect(&rc,-1,-1); SetDrawColor(hdc,RGB(100,100,220)); DrawRect(hdc,&rc); InflateRect(&rc,-1,-1); SetFillColor(hdc,RGB(50,50,200)); FillRect(hdc,&rc); } else { CopyRect(&rc,&rc0); rc.right =rc.left+RectH(&rc0); InflateRect(&rc,-2,-2); SetDrawColor(hdc,RGB(100,100,100)); DrawRect(hdc,&rc); InflateRect(&rc,-1,-1); SetDrawColor(hdc,RGB(160,160,160)); DrawRect(hdc,&rc); InflateRect(&rc,-1,-1); SetFillColor(hdc,RGB(220,220,220)); FillRect(hdc,&rc); } CopyRect(&rc,&rc0); InflateRectEx(&rc,-RectH(&rc),0,0,0); DrawText(hdc,hwnd->Text,-1,&rc,DT_LEFT|DT_VCENTER); EndPaint(hwnd,hdc); } return true; }
static u32 win_proc(MSG *pMsg) { HWND hwnd; HDC hdc; RECT rc,rc0; u32 i; hwnd =pMsg->hwnd; switch(pMsg->Code) { case MSG_CREATE: cfg_idx =0; bBorder=TRUE; bBKGND=TRUE; bColor=TRUE; GetClientRect(hwnd,&rc0); CreateWindow(BUTTON,"关闭",WS_CHILD|BS_NORMAL|WS_BORDER|WS_VISIBLE,RectW(&rc0)-64,RectH(&rc0)-28,60,24,hwnd,ID_CLOSE,NULL); i=RectH(&rc0)-(3*30); CreateWindow(CHECKBOX,"绘制边框",WS_CHILD|CBS_SELECTED|WS_VISIBLE,4,i+0*32,128,24,hwnd,ID_BORDER,NULL); CreateWindow(CHECKBOX,"绘制背景",WS_CHILD|CBS_SELECTED|WS_VISIBLE,4,i+1*32,128,24,hwnd,ID_BKGND,NULL); CreateWindow(CHECKBOX,"改变颜色",WS_CHILD|CBS_SELECTED|WS_VISIBLE,4,i+2*32,128,24,hwnd,ID_COLOR,NULL); GDD_CreateTimer(hwnd,1,3000,TMR_START); GDD_CreateTimer(hwnd,2,1000,TMR_START); break; //// case MSG_TIMER: { switch(pMsg->Param1) { case 1: cfg_idx++; if(DrawText_Cfg_Tbl[cfg_idx].text==NULL) { cfg_idx=0; } InvalidateWindow(hwnd); break; ///// case 2: if(bColor!=FALSE) { color_idx++; if(color_idx>=8) { color_idx=0; } InvalidateWindow(hwnd); } break; ///// } } break; case MSG_NOTIFY: { u16 event,id; event =HI16(pMsg->Param1); id =LO16(pMsg->Param1); if(id==ID_CLOSE) { if(event==BTN_UP) { PostMessage(hwnd,MSG_CLOSE,0,0); } InvalidateWindow(hwnd); } if(id==ID_BORDER) { if(event==CBN_SELECTED) { bBorder =TRUE; } if(event==CBN_UNSELECTED) { bBorder =FALSE; } InvalidateWindow(hwnd); } if(id==ID_BKGND) { if(event==CBN_SELECTED) { bBKGND =TRUE; } if(event==CBN_UNSELECTED) { bBKGND =FALSE; } InvalidateWindow(hwnd); } if(id==ID_COLOR) { if(event==CBN_SELECTED) { bColor =TRUE; } if(event==CBN_UNSELECTED) { bColor =FALSE; } InvalidateWindow(hwnd); } } break; //// case MSG_PAINT: { hdc =BeginPaint(hwnd); GetClientRect(hwnd,&rc0); SetFillColor(hdc,RGB(200,200,200)); FillRect(hdc,&rc0); SetRect(&rc,4,10,RectW(&rc0)-4*2,60); SetTextColor(hdc,DrawText_Color_Tbl[color_idx].text_color); SetDrawColor(hdc,DrawText_Color_Tbl[color_idx].bd_color); SetFillColor(hdc,DrawText_Color_Tbl[color_idx].bk_color); i=DrawText_Cfg_Tbl[cfg_idx].flag; if(bBorder) { i |= DT_BORDER; } if(bBKGND) { i |= DT_BKGND; } DrawText(hdc,DrawText_Cfg_Tbl[cfg_idx].text,-1,&rc,i); // DrawText(hdc,"DrawText\r\n**绘制字符串**",-1,&rc,DT_BORDER|DT_BKGND|DT_VCENTER|DT_CENTER); EndPaint(hwnd,hdc); } break; //// default: return DefWindowProc(pMsg); } return 0; }
bool nuiPopupMenu::DrawTree(nuiDrawContext* pContext, nuiTreeNode* pTree, uint depth) { nuiTreeNode* pChildNode; nuiTreeNode* pOpenedNode = NULL; nuiWidget* pChildWidget; nuiRect WidgetRect; NGL_ASSERT(depth < mRects.size()); nuiMenuRect* pRect= mRects[depth]; NGL_ASSERT(pTree); nuiTheme* pTheme = GetTheme(); NGL_ASSERT(pTheme); if (pTree != mpTree) // then Draw a new rect for this depth { pTheme->DrawMenuWindow(pContext, pRect->mRect, this); if (pRect->mpSBar->IsVisible(false)) DrawChild(pContext, pRect->mpSBar); } uint32 count = pTree->GetChildrenCount(); for (uint32 i = 0; i < count; i++) { pChildNode = dynamic_cast<nuiTreeNode*>(pTree->GetChild(i)); pChildWidget = pChildNode->GetElement(); WidgetRect = pChildWidget->GetRect(); if (pChildNode->IsSelected() || pChildNode->IsOpened()) { nuiSize TreeHandleSize = pRect->mHasNonEmpty ? NUI_POPUP_TREE_HANDLE_SIZE : 0.f; nuiRect r = WidgetRect; r.SetSize(WidgetRect.GetWidth()+TreeHandleSize, WidgetRect.GetHeight()); pTheme->DrawSelectionBackground(pContext, r, this); } if (!pChildNode->IsEmpty()) { nuiRect r = WidgetRect; r.Move(WidgetRect.GetWidth(), 0); r.SetSize(NUI_POPUP_TREE_HANDLE_SIZE-4.f, r.GetHeight()); pContext->SetFillColor(GetColor(eTreeViewHandle)); pTheme->DrawTreeHandle(pContext, r, false, NUI_POPUP_TREE_HANDLE_SIZE-4.f); } DrawChild(pContext, pChildWidget); if (pChildNode->IsSelected() || pChildNode->IsOpened()) { nuiSize TreeHandleSize = pRect->mHasNonEmpty ? NUI_POPUP_TREE_HANDLE_SIZE : 0.f; nuiRect r = WidgetRect; r.SetSize(WidgetRect.GetWidth()+TreeHandleSize, WidgetRect.GetHeight()); pTheme->DrawSelectionForeground(pContext, r, this); } if (pChildNode->IsOpened()) { pOpenedNode = pChildNode; } } if (pRect->mpSBar->IsVisible(false)) { SetFillColor(pContext, eMenuBg); SetStrokeColor(pContext, eNormalTextFg); pContext->EnableBlending(true); nuiGradient grad; nuiColor bg(GetColor(eMenuBg)); grad.AddStop(bg, 1); bg.Multiply(0); grad.AddStop(bg, 0); if (pRect->mpSBar->GetRange().GetValue() + pRect->mpSBar->GetRange().GetPageSize() < pRect->mpSBar->GetRange().GetMaximum()) { nuiRect r(pRect->mRect.Left() + 2, mRect.Bottom() - AUTOSCROLL_HEIGHT * 2, pRect->mRect.GetWidth() - SB_WIDTH - 2, AUTOSCROLL_HEIGHT * 2); pContext->DrawGradient(grad, r, 0, mRect.Bottom() - AUTOSCROLL_HEIGHT * 2, 0, mRect.Bottom()); float w = pRect->mRect.GetWidth() - SB_WIDTH; float x = pRect->mRect.Left(); float y = mRect.Bottom() - AUTOSCROLL_HEIGHT; float s = 8; pContext->DrawLine(x + w/2 - s, y + 4, x + w/2 + s, y + 4); pContext->DrawLine(x + w/2 + s, y + 4, x + w/2, y + 4 + s); pContext->DrawLine(x + w/2, y + 4 + s, x + w/2 - s, y + 4); } if (pRect->mpSBar->GetRange().GetValue() > pRect->mpSBar->GetRange().GetMinimum()) { nuiRect r(pRect->mRect.Left() + 2, 0.0f, pRect->mRect.GetWidth() - SB_WIDTH - 2, AUTOSCROLL_HEIGHT * 2); pContext->DrawGradient(grad, r, 0, AUTOSCROLL_HEIGHT * 2, 0, 0); float w = pRect->mRect.GetWidth() - SB_WIDTH; float x = pRect->mRect.Left(); float s = 8; pContext->DrawLine(x + w/2, 4, x + w/2 - s, 4 + s); pContext->DrawLine(x + w/2 - s, 4 + s, x + w/2 + s, 4 + s); pContext->DrawLine(x + w/2 + s, 4 + s, x + w/2, 4); } pContext->EnableBlending(false); } if (pOpenedNode) DrawTree(pContext, pOpenedNode, depth+1); pTheme->Release(); return true; }
TGraphErrors *makesysplot(TH1F *h, float dmu, int color) { auto h1 = (TH1F *)h->Clone("h1"); auto h2 = (TH1F *)h->Clone("h2"); //if (h->GetTitle()=="Data b-jets 12") h->SetTitle("Data b-jets"); h1->SetTitle("variation up"); h2->SetTitle("variation down"); float mu = h->GetMean(); int n = round(mu*10); float i1=h->Integral(1,n); float w1 = weightedsum(h,1,n); float t = (mu-w1)/(1-i1); float alpha1 = (mu-dmu-t)/(w1-t*i1)-1; float beta1 = (1-(1+alpha1)*i1)/(1-i1)-1; float alpha2 = (mu+dmu-t)/(w1-t*i1)-1; float beta2 = (1-(1+alpha2)*i1)/(1-i1)-1; auto hbar = (TH1F *)h->Clone("hbar"); for (int i=1;i<=h->GetNbinsX();i++) { float p = i>n ? 1+alpha1 : 1+beta1; h1->SetBinContent(i,h->GetBinContent(i)*p); p = i>n ? 1+alpha2 : 1+beta2; h2->SetBinContent(i,h->GetBinContent(i)*p); } Normalize({h1,h2}); //in principle it is not needed for (int i=1;i<=h->GetNbinsX();i++) hbar->SetBinError(i,fabs(h2->GetBinContent(i)-h1->GetBinContent(i))/2); hbar->SetFillColor(color); plotlegendpos = TopLeft; // plotsecondline = Form("%.3f,%.3f",h1->GetMean()-mu,mu-h2->GetMean()); //check means // plotthirdline = Form("%.3f",dmu); TGraphErrors *sys = new TGraphErrors(hbar->GetNbinsX()); sys->SetFillColor(color); for (int i=1;i<=hbar->GetNbinsX();i++) { sys->SetPoint(i,hbar->GetBinCenter(i),hbar->GetBinContent(i)); sys->SetPointError(i,0.05,hbar->GetBinError(i)); } //draw true value, variation1 and variation2 plotytitle = "Event fractions"; // Draw({h,h1,h2},{"E1","hist","hist","e1p"}); // auto c2 = getc(); // h->Draw("e1"); // sys->Draw("e2"); // h->Draw("e1,same"); // SavePlot(c2,Form("%ssys2",h->GetName())); return sys; //draw cdf (for fun) // auto hint = h->GetIntegral(); // auto h1int = h1->GetIntegral(); // auto h2int = h2->GetIntegral(); // vector<double> xaxis; // for (int i=1;i<=h->GetNbinsX()+1;i++) xaxis.push_back(h->GetBinLowEdge(i)); // auto g = new TGraph(xaxis.size()+1,&xaxis[0],hint); g->SetLineColor(kRed); // auto g1 = new TGraph(xaxis.size()+1,&xaxis[0],h1int); g1->SetLineColor(kGreen); // auto g2 = new TGraph(xaxis.size()+1,&xaxis[0],h2int); g2->SetLineColor(kBlue); // auto c = getc(); // g->SetMinimum(0);g->SetMaximum(1); // g->Draw(); // g1->Draw("same"); // g2->Draw("same"); // g->GetXaxis()->SetTitle("x_{J}"); // g->GetXaxis()->SetTitle("prob"); // SavePlots(c,"cum"); }