From 19c10a751639af4d9d463ffd61ef0e819a558ce2 Mon Sep 17 00:00:00 2001 From: Jochen Klein Date: Fri, 1 Mar 2024 16:11:07 +0100 Subject: [PATCH] Update for D0 jets --- .../analysis/analyzer_jets.py | 34 ++++++++++++++++--- machine_learning_hep/processer_jet.py | 12 +++++++ 2 files changed, 42 insertions(+), 4 deletions(-) diff --git a/machine_learning_hep/analysis/analyzer_jets.py b/machine_learning_hep/analysis/analyzer_jets.py index eb7c0d97fb..9b0df3c9e1 100644 --- a/machine_learning_hep/analysis/analyzer_jets.py +++ b/machine_learning_hep/analysis/analyzer_jets.py @@ -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 ## @@ -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 @@ -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') diff --git a/machine_learning_hep/processer_jet.py b/machine_learning_hep/processer_jet.py index cece44f635..4ea9b77a69 100644 --- a/machine_learning_hep/processer_jet.py +++ b/machine_learning_hep/processer_jet.py @@ -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()