Skip to content

Commit

Permalink
Update for D0 jets
Browse files Browse the repository at this point in the history
  • Loading branch information
qgp committed Mar 1, 2024
1 parent 2033df3 commit 19c10a7
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 4 deletions.
34 changes: 30 additions & 4 deletions machine_learning_hep/analysis/analyzer_jets.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#############################################################################
## © Copyright CERN 0238. All rights not expressly granted are reserved. ##
## © Copyright CERN 2023. All rights not expressly granted are reserved. ##
## ##
## This program is free software: you can redistribute it and/or modify it ##
## under the terms of the GNU General Public License as published by the ##
Expand All @@ -14,7 +14,7 @@

import os
import munch # pylint: disable=import-error, no-name-in-module
from ROOT import TFile # pylint: disable=import-error, no-name-in-module
from ROOT import TFile, TCanvas # pylint: disable=import-error, no-name-in-module

from machine_learning_hep.analysis.analyzer import Analyzer

Expand Down Expand Up @@ -46,12 +46,38 @@ def __init__(self, datap, case, typean, period):
self.n_fileresp = datap["files_names"]["respfilename"]
self.n_fileresp = os.path.join(self.d_resultsallpmc_proc, self.n_fileresp)

def qa(self): # pylint: disable=too-many-branches, too-many-locals
def qa(self): # pylint: disable=too-many-branches, too-many-locals, invalid-name
self.logger.info("Running D0 jet qa")

print(self.n_filemass)
with TFile(self.n_filemass) as rfile:
histonorm = rfile.Get("histonorm")
if not histonorm:
self.logger.critical('histonorm not found')
p_nevents = histonorm.GetBinContent(1)
self.logger.debug(f'Number of selected event: {p_nevents}')
self.logger.debug('Number of selected event: %d', p_nevents)

for ipt in range(7):
c = TCanvas("Candidate mass")
h_invmass = rfile.Get(f'hmass_{ipt}')
if not h_invmass:
self.logger.critical('hmass not found')
h_invmass.Print()
h_invmass.Draw()
c.SaveAs(f'hmass_{ipt}.png')

c = TCanvas("Candidate pt")
h_candpt = rfile.Get(f'hcandpt_{ipt}')
if not h_candpt:
self.logger.critical('hcandpt not found')
h_candpt.Print()
h_candpt.Draw()
c.SaveAs(f'hcandpt_{ipt}.png')

c = TCanvas("Jet pt")
h_jetpt = rfile.Get(f'hjetpt_{ipt}')
if not h_jetpt:
self.logger.critical('hjetpt not found')
h_jetpt.Print()
h_jetpt.Draw()
c.SaveAs(f'hjetpt_{ipt}.png')
12 changes: 12 additions & 0 deletions machine_learning_hep/processer_jet.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,15 @@ def process_histomass_single(self, index):
self.p_num_bins, self.p_mass_fit_lim[0], self.p_mass_fit_lim[1])
fill_hist(h_invmass_all, df.fM)
h_invmass_all.Write()

h_candpt_all = TH1F(
f'hcandpt_{ipt}', "",
self.p_num_bins, 0., 50.)
fill_hist(h_candpt_all, df.fPt)
h_candpt_all.Write()

h_jetpt_all = TH1F(
f'hjetpt_{ipt}', "",
self.p_num_bins, 0., 50.)
fill_hist(h_jetpt_all, df.fJetPt)
h_jetpt_all.Write()

0 comments on commit 19c10a7

Please sign in to comment.