Skip to content

fix bug in ConfigureJets

Khawla Jaffel requested to merge kjaffel/bamboo:_4thCAThackathon into master

Hi,

This code here seems buggy. I'm unsure why it needs to be so complicated with a try-except statement. There are only two options for run2 and run3, so shouldn't it work with just an if statement? This merge request will fix the issue.

To provide more details, I'm running a run3 analysis and encountering the following error:

(bamboovenv105) [kjaffel@lxplus937 python]$ bambooRun -m hhto4b.py:controlPlotter  -o test ../config/analysis.yml --samples ../config/fullanalysisRun3_nanov12.yml --test
WARNING:bamboo.workflow:6505 untracked files found in /afs/cern.ch/user/k/kjaffel/eos/hhto4b-run3
INFO:bamboo.analysisutils:Read config from file /afs/cern.ch/user/k/kjaffel/.config/bamboorc
ERROR:bamboo.workflow:Your working tree for config and module is dirty! Please commit, tag, and push for reproducible results
INFO:HH4b plotter:No signal sample found for testing, falling back on background sample
INFO:HH4b plotter:Found MC sample for testing: QCD-4Jets_HT-100to200_TuneCP5_13p6TeV_madgraphMLM-pythia8__2022EEUL
WARNING:HH4b plotter:No data sample found for testing!
INFO:HH4b plotter:Testing mode: only using one file; only running on era 2022EEUL; using data: None; using MC: QCD-4Jets_HT-100to200_TuneCP5_13p6TeV_madgraphMLM-pythia8__2022EEUL
WARNING:bamboo.workflow:Output directory test/results exists, previous results may be overwritten
WARNING:bamboo.workflow:Overwriting test/version.yml, but if not all results are overwritten the version will not be consistent
WARNING:bamboo.analysismodules:Only processing first 1 of 141 files for sample QCD-4Jets_HT-100to200_TuneCP5_13p6TeV_madgraphMLM-pythia8__2022EEUL
TClass::Init:0: RuntimeWarning: no dictionary for class edm::Hash<1> is available
TClass::Init:0: RuntimeWarning: no dictionary for class edm::ProcessHistory is available
TClass::Init:0: RuntimeWarning: no dictionary for class edm::ProcessConfiguration is available
TClass::Init:0: RuntimeWarning: no dictionary for class edm::ParameterSetBlob is available
TClass::Init:0: RuntimeWarning: no dictionary for class pair<edm::Hash<1>,edm::ParameterSetBlob> is available
INFO:bamboo.workflow:Sequential mode: processing sample QCD-4Jets_HT-100to200_TuneCP5_13p6TeV_madgraphMLM-pythia8__2022EEUL with module hhto4b.py:controlPlotter. (['root://cms-xrd-global.cern.ch///store/mc/Run3Summer22EENanoAODv12/QCD-4Jets_HT-100to200_TuneCP5_13p6TeV_madgraphMLM-pythia8/NANOAODSIM/130X_mcRun3_2022_realistic_postEE_v6-v2/40000/1afac2da-8386-4cc9-85bb-3f0423d7cabb.root'], test/results/QCD-4Jets_HT-100to200_TuneCP5_13p6TeV_madgraphMLM-pythia8__2022EEUL.root, tree=Events, sample=QCD-4Jets_HT-100to200_TuneCP5_13p6TeV_madgraphMLM-pythia8__2022EEUL
Traceback (most recent call last):
  File "/eos/user/k/kjaffel/bamboodev/bamboovenv105/bin/bambooRun", line 8, in <module>
    sys.exit(main())
  File "/eos/user/k/kjaffel/bamboodev/bamboovenv105/lib/python3.9/site-packages/bamboo/scripts/bambooRun.py", line 75, in main
    modInst.run()
  File "/eos/user/k/kjaffel/bamboodev/bamboovenv105/lib/python3.9/site-packages/bamboo/analysismodules.py", line 313, in run
    run_notworker(self)
  File "/eos/user/k/kjaffel/bamboodev/bamboovenv105/lib/python3.9/site-packages/bamboo/workflow.py", line 738, in run_notworker
    processOne(mod, task.inputFiles, output, sampleCfg=task.config,
  File "/eos/user/k/kjaffel/bamboodev/bamboovenv105/lib/python3.9/site-packages/bamboo/workflow.py", line 449, in processOne
    backend, plotList = mod.makeBackendAndPlotList(
  File "/eos/user/k/kjaffel/bamboodev/bamboovenv105/lib/python3.9/site-packages/bamboo/analysismodules.py", line 400, in makeBackendAndPlotList
    tree, noSel, backend, runAndLS = self.prepareTree(tup, sample=sample, sampleCfg=sampleCfg,
  File "/eos/user/k/kjaffel/hhto4b-run3/python/recoBaseHH4bPlotter.py", line 38, in prepareTree
    defs.configureJetMETCorrections(tree, era, isNotWorker, self.isMC(sample), be, sample, splitJER=not self.args.no_split_jer, jesScheme=self.args.jes_scheme)
  File "/eos/user/k/kjaffel/hhto4b-run3/python/definitions.py", line 137, in configureJetMETCorrections
    configureJets(tree._Jet, jetType="AK4PFPuppi", **cmJMEArgs)
  File "/eos/user/k/kjaffel/bamboodev/bamboovenv105/lib/python3.9/site-packages/bamboo/analysisutils.py", line 888, in configureJets
    raise RuntimeError(f"None of the attributes {rho_names} found.")
RuntimeError: None of the attributes ['fixedGridRhoFastjetAll', 'Rho_fixedGridRhoFastjetAll'] found.

'Rho_fixedGridRhoFastjetAll' does exist in the file I am trying to process. Here’s a test case, but the code I mentioned above bypasses it.

import uproot

f='root://cms-xrd-global.cern.ch///store/mc/Run3Summer22EENanoAODv12/QCD-4Jets_HT-100to200_TuneCP5_13p6TeV_madgraphMLM-pythia8/NANOAODSIM/130X_mcRun3_2022_realistic_postEE_v6-v2/40000/1afac2da-8386-4cc9-85bb-3f0423d7cabb.root'

file = uproot.open(f)
events_tree = file["Events"]
branches = events_tree.keys()
for branch in branches:
    if 'Rho' in branch:
        print(branch)

I have tested the merge request, and it works. Could you please check this?

PS: I have no idea how to fix these whitespaces that build_102 is complaining about!

Merge request reports