How to SetBinContent?


i’m quite new to ROOT so please spare me with this,
I have created 5 different .root files, let’s say cut1.root, cut2.root, …,cut5.root
Each file of the above has 2 pull distributions from which I want to extract the N and σ (with their errors) and then create two new plots (one for N and one for σ) with N (σ) on y axis over cut1,2,3,4,5 on x axis
How can i proceed with this?
I mean, how should i use the SetBinContent(); so that i’ll have cut1 in bin (x axis) no.1, cut2 in bin no.2 etc?

Thanks in advance

for(int i=1; i<6; i++){
  TFile *f = TFile::Open("cut5.root", "READ");
  TFile *outf = TFile::Open("plotcut5.root", "RECREATE");

  TH1F *h_pullSig = (TH1F*)f->Get("h_pullSig");

 h_NSignpull->SetBinContent(i, ???);

I know many things are wrong with the code above,
how can i tell my script to open every cut.root file and get the info i need and then create a single plot that hold the info from all these values i’ve got from the cut.root files?
Sorry if it’s too complicated :slight_smile:

That depends on the representation you want at the end. Maybe you want a THStack or maybe you just need to add the histogram (TH1::Add)?


This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.