The binning of the histogram hist = ROOT.TH2F("hist", "hist",10, 65, 765, 8, 0, 400) is taken from the original code used in the paper. To make the same histogram with almost the same color gradient I used a color pick tool:
# Number of points in gradient
nRGBs = 5
# Stop points at 0, 0.2, 0.3, 0.4, and 0.6
stops = array('d', [0.0, 0.2, 0.3, 0.4, 0.6])
# RGB values for the colors at the stops (scaled between 0 and 1)
red = array('d', [236/255.0, 97/255.0, 33/255.0, 30/255.0, 21/255.0])
green = array('d', [228/255.0, 203/255.0, 191/255.0, 172/255.0, 121/255.0])
blue = array('d', [241/255.0, 221/255.0, 212/255.0, 190/255.0, 133/255.0])
# Create the gradient color table
ROOT.TColor.CreateGradientColorTable(nRGBs, stops, red, green, blue, 255)
ROOT.gStyle.SetNumberContours(255)
hist = ROOT.TH2F("hist", "hist",10, 65, 765, 8, 0, 400)
hist.SetStats(0)
Pt = []
d0 = []
eff = []
# Read the JSON file
file_path = "2.json"
with open(file_path, 'r') as f:
json_data = json.load(f)
values_data = json_data.get('values', None)
for entry in values_data:
Pt.append(float(entry['x'][0]['value']))
d0.append(float(entry['x'][1]['value']))
eff.append(float(entry['y'][0]['value']))
# Fill the histogram
for i in range(len(Pt)):
# Adding 1 to ensure we start from bin 1
x_bin = hist.GetXaxis().FindBin(Pt[i])
y_bin = hist.GetYaxis().FindBin(d0[i])
hist.SetBinContent(x_bin, y_bin, eff[i])
# Draw the histogram
c = ROOT.TCanvas("canvas", "Pt-do eff", 800, 600)
hist.GetXaxis().SetTitle("Pt (GeV)")
hist.GetYaxis().SetTitle("d0 (mm)")
hist.SetTitle("Muon reconstruction efficiency")
hist.Draw("COLZ")
c.Update()
This is an assurance that we have populated the histogram correctly.
Number of passed events is: 2275 event
Number of expected events: 8.255053624999999
Where Ntotal is the total number of the generated events we started with in our MC simulation (i.e. MadGraph)
BUT, there is an issue here.
Any muon with a momentum of ~ 765 GeV or more does not have an efficiency in the table or the histogram.
The histogram has 10 bins for the x-axis (Pt), and the GetBin method returns bin number 11 for any +765 GeV muon.
This is the case with any empty bin in the histogram too, e.g. Pt of 592.6 GeV and do of 166.5 mm
The binning of the histogram
hist = ROOT.TH2F("hist", "hist",10, 65, 765, 8, 0, 400)
is taken from the original code used in the paper. To make the same histogram with almost the same color gradient I used a color pick tool:This is an assurance that we have populated the histogram correctly.
Applying the efficiency selection code (did not have time to make it cleaner):
Where Ntotal is the total number of the generated events we started with in our MC simulation (i.e. MadGraph)
BUT, there is an issue here.
Any muon with a momentum of ~ 765 GeV or more does not have an efficiency in the table or the histogram. The histogram has 10 bins for the x-axis (Pt), and the GetBin method returns bin number 11 for any +765 GeV muon.
This is the case with any empty bin in the histogram too, e.g. Pt of 592.6 GeV and do of 166.5 mm