Created
February 9, 2023 21:42
-
-
Save ram1123/4348b88ab85c8f134a055f1e7c5d4f10 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ROOT | |
def SignificanceScan(var="evalDNN_HH"): | |
sigFile = "/eos/user/r/rasharma/post_doc_ihep/double-higgs/ntuples/January_2021_Production/DNN_Evaluate_HHWWyyDNN_NewModel6_E700_LR10em4_B150_VarMixV1MaxBRmvCorr_Trial1_BalanceYields/GluGluToHHTo2G4Q_node_cHHH1_2017.root" | |
# bkgFiles = ["/eos/user/r/rasharma/post_doc_ihep/double-higgs/ntuples/January_2021_Production/DNN_Evaluate_HHWWyyDNN_NewModel6_E700_LR10em4_B150_VarMixV1MaxBRmvCorr_Trial1_BalanceYields/Data_2017.root"] | |
bkgFiles = ["/eos/user/r/rasharma/post_doc_ihep/double-higgs/ntuples/January_2021_Production/DNN_Evaluate_HHWWyyDNN_NewModel6_E700_LR10em4_B150_VarMixV1MaxBRmvCorr_Trial1_BalanceYields/Data_2017.root", "/eos/user/r/rasharma/post_doc_ihep/double-higgs/ntuples/January_2021_Production/DNN_Evaluate_HHWWyyDNN_NewModel6_E700_LR10em4_B150_VarMixV1MaxBRmvCorr_Trial1_BalanceYields/Data_2018.root"] | |
fileCount = 0 | |
# Open the input ROOT file | |
f = ROOT.TFile.Open(sigFile) | |
# Get the tree from the file | |
t = f.Get("GluGluToHHTo2G4Q_node_cHHH1_13TeV_HHWWggTag_1") | |
fBkg = ROOT.TFile.Open(bkgFiles[fileCount]) | |
fBkg2 = ROOT.TFile.Open(bkgFiles[fileCount+1]) | |
tBkg = fBkg.Get("Data_13TeV_HHWWggTag_1") | |
tBkg2 = fBkg2.Get("Data_13TeV_HHWWggTag_1") | |
# Create a histogram to store the values of the branch | |
h = ROOT.TH1D("h", "evalDNN_HH", 25, 0, 1) | |
hBkg = ROOT.TH1D("hBkg", "evalDNN_HH", 25, 0, 1) | |
# Fill the histogram with the values of the branch | |
t.Draw("%s>>h" % var, "weight") | |
tBkg.Draw("%s>>+hBkg" % var, "(1)") | |
tBkg2.Draw("%s>>+hBkg" % var, "(1)") | |
# hBkg.Print() | |
# for file in bkgFiles: | |
# fBkgLoop = ROOT.TFile.Open(file) | |
# tBkgLoop = fBkgLoop.Get("Data_13TeV_HHWWggTag_1") | |
# tBkgLoop.Draw("%s>>hBkg" % var, "(1)","") | |
# print(file,tBkgLoop.GetEntries()) | |
# hBkg.Print() | |
h.Print() | |
hBkg.Print() | |
g = ROOT.TGraph() | |
for i in range(1, h.GetNbinsX() + 1): | |
S = h.GetBinContent(i) | |
B = hBkg.GetBinContent(i) | |
X = h.GetBinCenter(i) | |
Z = 0.0 | |
if S + B != 0: | |
Z = S / ROOT.TMath.Sqrt(S + B) | |
g.SetPoint(i - 1, X, Z) | |
# Draw the histogram | |
c = ROOT.TCanvas("c", "Significance Scan", 1200, 600) | |
g.SetTitle("Significance Scan") | |
g.GetXaxis().SetTitle(var) | |
g.GetYaxis().SetTitle("Significance (S / #sqrt{S+B})") | |
g.SetLineColor(2) | |
g.SetLineWidth(-802) | |
g.SetMarkerColor(4) | |
g.SetMarkerStyle(21) | |
g.Draw("APL") | |
c.SaveAs("XYS.pdf") | |
SignificanceScan("evalDNN_HH") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment