参考ROOT学习——绘制第一条轮廓线并单独显示在另一个画布中(FirstContour.C)_root marker style-CSDN博客
提供c++ python的两种写法
void test()
{
TH2D *h = new TH2D("h","h",50,0,50,50,0,50);
TCutG *cutg = new TCutG("CUTG",4);
cutg->SetVarX("cutx");
cutg->SetVarY("cuty");
cutg->SetTitle("Graph");
cutg->SetFillStyle(1000);
cutg->SetPoint(0,10.,10.);
cutg->SetPoint(1,10.,40.);
cutg->SetPoint(2,40.,40.);
cutg->SetPoint(3,40.,10.);
for(int k=0;k<=50;k++)
{
for(int j=0;j<=50;j++)
{
if(cutg->IsInside(k,j))//判断是否属于cutg的范围
{
h->Fill(k,j);
}
}
}
h->Draw("colz");
}
import numpy as np
import ROOT as root
from ROOT import TCutG, TH2D
import matplotlib.pyplot as plt
cutg = TCutG("cutg",18)
cutg.SetVarX("s")
cutg.SetVarY("f")
cutg.SetTitle("Graph")
cutg.SetFillStyle(1000)
cutg.SetPoint(0,10,10)
cutg.SetPoint(1,10,40)
cutg.SetPoint(2,40,40)
cutg.SetPoint(3,40,10)
h = TH2D("h","h",50,0,50,50,0,50)
for k in range(50):
for j in range(50):
if cutg.IsInside(k,j)==1:
h.Fill(k,j)
h.Draw("colz")