ROOT学习——TCutG用法

参考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")

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值