How to create ROOT histograms out of a 3 column .d

2019-09-15 15:58发布

I currently have a .dat file with format:

Format: Log(10,s22th13) deltacp chi^2

-4 0 0.098127

-4 4 0.093642

-4 8 0.089323

-4 12 0.085185

-4 16 0.081242 ....

How would I create a plot using ROOT, keeping the labels specified at the top of the .dat file?

1条回答
别忘想泡老子
2楼-- · 2019-09-15 16:43

The easiest way would be to read your file using TTree class:

    TTree *T = new TTree("ntuple","data from csv file");
    Long64_t nlines = T->ReadFile("data.csv");
    printf("found %lld points\n",nlines);

Your header will be used as names for branches. Then you can draw/save histograms using something like that:

    TH1F *hist = new TH1F("name","title", nbinsx,xlow,xup);
    T->Draw("branch>>name","","");
查看更多
登录 后发表回答