Drawing a histogram from a root file in pyroot

Dear Py-rooters !
I want to draw a python equivalent code(pyroot) for the following attached root code(C++). It is basically drawing a histogram from a root file.
The C++ code is:

{
  TCanvas c1("c1","plots",10,10,700,900);
  TChain ch1("track");
  ch1.Add("/home/souvik/tracking/rho/all/recon_*.root");
  double aMbc,asignal ;
  ch1.SetBranchAddress("Mbc",&aMbc);
  ch1.SetBranchAddress("isSignal",&asignal);
   TH1F *hist1 = new TH1F("hist1","",100, 5.2,5.29);
  for(Int_t i=0; i < ch1.GetEntries(); ++i){
    ch1.GetEntry(i);  
    if(asignal==1)
      hist1->Fill(aMbc);
  }
  hist1->GetYaxis()->SetRangeUser(0,5000);
  hist1->GetXaxis()->SetTitle("M_{bc} in GeV/C^{2}");
  hist1->SetLineColor(kBlue);
  hist1->SetLineWidth(2);
  hist1->SetFillColor(kBlue);
  hist1->SetFillStyle(3004);
  hist1->Draw();
}

Thanks in Advance.


Please read tips for efficient and successful posting and posting code

ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided


Have a look at the pyroot tutorials, for instance the hsimple tutorial could be helpful.

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