try: ROOT.gInterpreter.Declare('#include "classes/DelphesClasses.h"') ROOT.gInterpreter.Declare('#include "external/ExRootAnalysis/ExRootTreeReader.h"') except: pass # Read & Write File inputFile = args.infile if args.save: outputFile = root_open("W-mass.root","recreate") # Create chain of root trees chain = ROOT.TChain("Delphes") chain.Add(inputFile) # Create object of class ExRootTreeReader treeReader = ROOT.ExRootTreeReader(chain) numberOfEntries = treeReader.GetEntries() # Get pointers to branches used in this analysis branchMET = treeReader.UseBranch("MissingET") branchElectron = treeReader.UseBranch("Electron") # Define histograms histMass = ROOT.TH1F("mass", "W^{+} Transverse Mass",100, 0, 300.0)
'#include "/home/twkim/MG5_aMC_v2_7_3/ExRootAnalysis/ExRootAnalysis/ExRootClasses.h"' ) ROOT.gInterpreter.Declare( '#include "/home/twkim/MG5_aMC_v2_7_3/ExRootAnalysis/ExRootAnalysis/ExRootTreeReader.h"' ) except: pass # Read & Write File inputFile = sys.argv[1] outputFile = ROOT.TFile.Open("BKG_ttbar_bpt.root", "recreate") ### <- Set Your output file name # Create chain of root trees chain = ROOT.TChain("LHEF") chain.Add(inputFile) # Create object of class ExRootTreeReader treeReader = ROOT.ExRootTreeReader(chain) numberOfEntries = treeReader.GetEntries() # Get pointers to branches used in this analysis branchParticle = treeReader.UseBranch("Particle") # branchElectron = treeReader.UseBranch("Electron") # Define histograms histPT = ROOT.TH1F("pt", "p_{T} distribution", 80, 0, 400.0) histEta = ROOT.TH1F("eta", "eta distribution", 100, -10, 10) histPhi = ROOT.TH1F("phi", "phi distribution", 100, -10, 10)
def total_entries(files, tree): from rootpy import ROOT chain = ROOT.TChain(tree) for _file in files: chain.Add(_file) return chain.GetEntries()
try: ROOT.gInterpreter.Declare('#include "/home/twkim/Delphes3.4.2/classes/DelphesClasses.h"') ROOT.gInterpreter.Declare('#include "/home/twkim/MG5_aMC_v2_7_3/ExRootAnalysis/ExRootAnalysis/ExRootTreeReader.h"') except: pass # Read & Write File inputFile = args.infile if args.save: outputFile = root_open("delph_tt_METlo.root","recreate") # Create chain of root trees chain = ROOT.TChain("Delphes;1") chain.Add(inputFile) # Create object of class ExRootTreeReader treeReader = ROOT.ExRootTreeReader(chain) numberOfEntries = treeReader.GetEntries() # Get pointers to branches used in this analysis # branchElec = treeReader.UseBranch("Electron") # branchMuon = treeReader.UseBranch("Muon") branchMET = treeReader.UseBranch("MissingET") # Define histograms # histElecPT = ROOT.TH1F("ept", "P_{T} distribution",100, 0, 400.0) # histMuonPT = ROOT.TH1F("mpt", "P_{T} distribution",100, 0, 400.0)