Fork me on GitHub

Changes between Version 3 and Version 4 of WorkBook/Tutorials/Hefei


Ignore:
Timestamp:
Nov 20, 2018, 11:42:59 AM (6 years ago)
Author:
Michele Selvaggi
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • WorkBook/Tutorials/Hefei

    v3 v4  
    68682) Interactively draw the muon multiplicity and the jet multiplicity. Do you understand these distributions?
    6969
     70{{{
     71Delphes->Draw("Muon_size");
     72Delphes->Draw("Jet_size");
     73}}}
     74
    7075== III) Write a simple analysis macro ==
    7176
     
    8085This Example1.py macro does not produce anything interesting here (it most likely produce an empty plot). The above command is simply shown as an example for how to run a macro. You should open Example1.py with a text editor, and write a small analysis that first selects events with two muons and then reconstructs and plot the recoil Higgs mass using the formula found in III.1)
    8186
     87
     88Solution:
     89
     90{{{
     91# Recoil Mass macro
     92#!/usr/bin/env python
     93
     94import sys
     95import ROOT
     96
     97if len(sys.argv) < 2:
     98  print " Usage: python examples/MissingMass.py delphes_ee_zh_zmumu.root hist_mrec.root"
     99  sys.exit(1)
     100
     101ROOT.gSystem.Load("libDelphes")
     102
     103try:
     104  ROOT.gInterpreter.Declare('#include "classes/SortableObject.h"')
     105  ROOT.gInterpreter.Declare('#include "classes/DelphesClasses.h"')
     106  ROOT.gInterpreter.Declare('#include "external/ExRootAnalysis/ExRootTreeReader.h"')
     107except:
     108  pass
     109
     110inputFile = sys.argv[1]
     111outputFile = sys.argv[2]
     112
     113# Create chain of root trees
     114chain = ROOT.TChain("Delphes")
     115chain.Add(inputFile)
     116
     117# Create object of class ExRootTreeReader
     118treeReader = ROOT.ExRootTreeReader(chain)
     119numberOfEntries = treeReader.GetEntries()
     120
     121# Get pointers to branches used in this analysis
     122branchMuon = treeReader.UseBranch("Muon")
     123
     124# Book histograms
     125histMass = ROOT.TH1F("mass", "M_{recoil} [GeV]", 60, 100.0, 160.0)
     126
     127ptot = ROOT.TLorentzVector(0.,0.,0.,240.)
     128# Loop over all events
     129for entry in range(0, numberOfEntries):
     130  # Load selected branches with data from specified event
     131  treeReader.ReadEntry(entry)
     132
     133  # If event contains at least 2 muons
     134  if branchMuon.GetEntries() > 1:
     135
     136    mu1 = branchMuon.At(0)
     137    mu2 = branchMuon.At(1)
     138
     139    pll = mu1.P4() + mu2.P4()
     140    ph = ptot - pll
     141
     142    histMass.Fill(ph.M())
     143
     144out_root = ROOT.TFile(outputFile,"RECREATE")
     145histMass.Write()
     146}}}
    82147
    83148== IV) Modify the Delphes detector card ==