Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update for D0 jets #857

Merged
merged 1 commit into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 31 additions & 5 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,11 +14,11 @@

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

class AnalyzerJets(Analyzer):
class AnalyzerJets(Analyzer): # pylint: disable=too-many-instance-attributes
species = "analyzer"

def __init__(self, datap, case, typean, period):
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()
Loading