#! /usr/local/bin/python3.6

import ROOT
from ROOT import TFile, TTree, TH1F
import os

def RootTutorial1():
  # Get the data file
  print("[root_tutorial_1] Getting data file")
  print("The current working directory is", os.getcwd())
  f=TFile("./zjet.root")

  # Get the tree from the file
  print("[root_tutorial_1] Getting TTree from file")
  t =f.Get( "Tdata" )

  # Create a 1D histogram
  print("[root_tutorial_1] Creating histogram object (TH1F)")
  h_px = TH1F("h_px","h_px",100,-1500,1500)

  # Fill the histogram using information from the "px" branch from the tree
  print("[root_tutorial_1] Filling histogram and drawing it")
  t.Draw("px>>h_px")

  input("Press q to exit program (and say goodbye to your beautiful histogram)...")

if __name__ == "__main__":
    RootTutorial1()

