#!/usr/bin/env python

import copy
import math
import os
import re
import sys
import logging
import string
import time

import ROOT


#-------------------------------------------------------------------------
def makeCanvas(name):
    
    ROOT.gStyle.SetPadRightMargin (0.12) 
    ROOT.gStyle.SetPadBottomMargin (0.16) 
    can = ROOT.TCanvas(name, name, 900, 550)
    
    return can

#---------------------------------------------------------------------------------------------
def plotHist(can):

    hist = ROOT.TH1F('hist', "", 10, 0, 10)
    hist.SetBinContent(3,6);
    hist.SetBinError(3,2.44949);
    hist.SetEntries(6);
    hist.SetName('NLepton')
    hist.GetXaxis().SetTitle('Number of leptons');
    hist.GetXaxis().CenterTitle(True);
    hist.GetXaxis().SetNdivisions(505);
    hist.GetXaxis().SetLabelFont(42);
    hist.GetXaxis().SetLabelSize(0.065);
    hist.GetXaxis().SetTitleSize(0.065);
    hist.GetXaxis().SetTitleFont(42);
    hist.GetYaxis().SetNdivisions(505);
    hist.GetYaxis().SetLabelFont(42);
    hist.GetYaxis().SetLabelSize(0.065);
    hist.GetYaxis().SetTitleSize(0.065);
    hist.GetYaxis().SetTitleOffset(1.15);
    hist.GetYaxis().SetTitleFont(42);
    hist.GetZaxis().SetNdivisions(505);
    hist.GetZaxis().SetLabelFont(42);
    hist.GetZaxis().SetLabelSize(0.065);
    hist.GetZaxis().SetTitleSize(0.065);
    hist.GetZaxis().SetTitleFont(42);
    hist.Draw('');
    can.Modified();
    can.cd()
    can.Print('%s.png' %hist.GetName())

#-------------------------------------------------------------------------
def main():

    print 'Main '
    timeStart = time.time()
    print 'Current time: %s' %(time.asctime(time.localtime()))

    can = makeCanvas('can')    
     
    plotHist(can)

    print 'Current time: %s' %(time.asctime(time.localtime()))
    print 'Total job time: %.1fs' %(time.time()-timeStart)
#================================================================================
if __name__ == '__main__':
    main()
    print 'All is done'
