Created
January 20, 2025 14:28
-
-
Save artlbv/546a599fc575f7780f6867f770ff4e04 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"id": "2cd087d1", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"import os\n", | |
"import numpy as np\n", | |
"import pandas as pd" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"id": "c36cb9db", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"from glob import glob" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"id": "e73e639f", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"indir = \"/eos/home-i01/a/alobanov/www/L1T/Phase2/menu/Validation/NewMenuTools/V44nano/object_performance/scalings\"" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 4, | |
"id": "79c1faef", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"[]" | |
] | |
}, | |
"execution_count": 4, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"glob(indir + \"*au*:*.yaml\")" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 5, | |
"id": "3f627cb4", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"['/eos/home-i01/a/alobanov/www/L1T/Phase2/menu/Validation/NewMenuTools/V44nano/object_performance/scalings/ElectronsTriggerBarrel_L1EG:default:barrel.yaml',\n", | |
" '/eos/home-i01/a/alobanov/www/L1T/Phase2/menu/Validation/NewMenuTools/V44nano/object_performance/scalings/ElectronsTriggerEndcap_L1EG:default:endcap.yaml']" | |
] | |
}, | |
"execution_count": 5, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"fnames = glob(\"/eos/home-i01/a/alobanov/www/L1T/Phase2/menu/Validation/NewMenuTools/V44nano/object_performance/scalings/**:*\")\n", | |
"fnames[:2]" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 6, | |
"id": "3899324b", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"# ! ls /eos/home-i01/a/alobanov/www/L1T/Phase2/menu/Validation/NewMenuTools/V44nano/object_performance/scalings/*Tau*:*" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 7, | |
"id": "0585c980", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"L1EG default barrel\n", | |
"L1EG default endcap\n", | |
"L1TrackHT HT inclusive\n", | |
"L1TrackHT MHT inclusive\n", | |
"L1TrackJet default barrel\n", | |
"L1TrackJet default endcap\n", | |
"L1TrackMET default inclusive\n", | |
"L1caloJet default barrel\n", | |
"L1caloJet default endcap\n", | |
"L1caloJet default forward\n", | |
"L1caloTau default barrel\n", | |
"L1caloTau default endcap\n", | |
"L1gmtMuon default barrel\n", | |
"L1gmtMuon default endcap\n", | |
"L1gmtMuon default overlap\n", | |
"L1gmtTkMuon Loose barrel\n", | |
"L1gmtTkMuon Loose endcap\n", | |
"L1gmtTkMuon Loose overlap\n", | |
"L1gmtTkMuon Medium barrel\n", | |
"L1gmtTkMuon Medium endcap\n", | |
"L1gmtTkMuon Medium overlap\n", | |
"L1gmtTkMuon Tight barrel\n", | |
"L1gmtTkMuon Tight endcap\n", | |
"L1gmtTkMuon Tight overlap\n", | |
"L1gmtTkMuon VLoose barrel\n", | |
"L1gmtTkMuon VLoose endcap\n", | |
"L1gmtTkMuon VLoose overlap\n", | |
"L1gmtTkMuon default barrel\n", | |
"L1gmtTkMuon default endcap\n", | |
"L1gmtTkMuon default overlap\n", | |
"L1hpsTau default barrel\n", | |
"L1hpsTau default endcap\n", | |
"L1nnCaloTau default barrel\n", | |
"L1nnCaloTau default endcap\n", | |
"L1nnPuppiTau default barrel\n", | |
"L1nnPuppiTau default endcap\n", | |
"L1puppiHistoJetSums MHT inclusive\n", | |
"L1puppiJetSC4 default barrel\n", | |
"L1puppiJetSC4 default endcap\n", | |
"L1puppiJetSC4 default forward\n", | |
"L1puppiJetSC4sums HT inclusive\n", | |
"L1puppiJetSC4sums MHT inclusive\n", | |
"L1puppiJetSC8 default barrel\n", | |
"L1puppiJetSC8 default endcap\n", | |
"L1puppiJetSC8 default forward\n", | |
"L1puppiMET default inclusive\n", | |
"L1puppiMLMET default inclusive\n", | |
"L1tkElectron Iso barrel\n", | |
"L1tkElectron Iso endcap\n", | |
"L1tkElectron NoIso barrel\n", | |
"L1tkElectron NoIso endcap\n", | |
"L1tkPhoton Iso barrel\n", | |
"L1tkPhoton Iso endcap\n", | |
"L1tkPhoton NoIso barrel\n", | |
"L1tkPhoton NoIso endcap\n" | |
] | |
} | |
], | |
"source": [ | |
"scalings_dict = {}\n", | |
"\n", | |
"for fname in fnames:\n", | |
" if \"Trigger\" in fname: continue\n", | |
" if \"Turnon\" in fname: continue\n", | |
"\n", | |
" with open(fname,\"r\") as f:\n", | |
" lines = f.readlines()\n", | |
" base_name = os.path.basename(fname)\n", | |
" base_split = base_name.split(\":\")\n", | |
" if len(base_split)==3:\n", | |
" obj,idname,region = base_name.split(\":\")\n", | |
" else:\n", | |
" print(f\"Error for {base_name}\")\n", | |
" \n", | |
" region = region.replace(\".yaml\",\"\")\n", | |
" \n", | |
" if obj not in scalings_dict:\n", | |
" scalings_dict[obj] = {idname:{region:{}}}\n", | |
" if idname not in scalings_dict[obj]:\n", | |
" scalings_dict[obj][idname] = {region:{}}\n", | |
" if region not in scalings_dict[obj][idname]:\n", | |
" scalings_dict[obj][idname][region] = {}\n", | |
" \n", | |
" for line in lines:\n", | |
" line_split = line.split(\":\")\n", | |
" scalings_dict[obj][idname][region][line_split[0]] = np.round(float(line_split[1]), 2)\n", | |
"\n", | |
" print(obj,idname, region)\n", | |
"# break" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 8, | |
"id": "bcfcfccc", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"{'L1EG': {'default': {'barrel': {'offset': 4.36, 'slope': 1.12},\n", | |
" 'endcap': {'offset': 5.22, 'slope': 1.07}}},\n", | |
" 'L1TrackHT': {'HT': {'inclusive': {'offset': -51.83, 'slope': 2.58}},\n", | |
" 'MHT': {'inclusive': {'offset': -19.41, 'slope': 2.27}}},\n", | |
" 'L1TrackJet': {'default': {'barrel': {'offset': 14.84, 'slope': 5.15},\n", | |
" 'endcap': {'offset': 30.24, 'slope': 7.12}}},\n", | |
" 'L1TrackMET': {'default': {'inclusive': {'offset': -75.85, 'slope': 8.69}}},\n", | |
" 'L1caloJet': {'default': {'barrel': {'offset': 2.27, 'slope': 1.48},\n", | |
" 'endcap': {'offset': 77.98, 'slope': 1.74},\n", | |
" 'forward': {'offset': 223.84, 'slope': 0.89}}},\n", | |
" 'L1caloTau': {'default': {'barrel': {'offset': -10.87, 'slope': 1.69},\n", | |
" 'endcap': {'offset': -45.77, 'slope': 2.54}}},\n", | |
" 'L1gmtMuon': {'default': {'barrel': {'offset': 1.08, 'slope': 1.69},\n", | |
" 'endcap': {'offset': -2.97, 'slope': 1.21},\n", | |
" 'overlap': {'offset': -1.17, 'slope': 1.35}}},\n", | |
" 'L1gmtTkMuon': {'Loose': {'barrel': {'offset': 0.96, 'slope': 1.04},\n", | |
" 'endcap': {'offset': 0.87, 'slope': 1.04},\n", | |
" 'overlap': {'offset': 1.16, 'slope': 1.03}},\n", | |
" 'Medium': {'barrel': {'offset': 0.95, 'slope': 1.04},\n", | |
" 'endcap': {'offset': 0.87, 'slope': 1.04},\n", | |
" 'overlap': {'offset': 1.16, 'slope': 1.03}},\n", | |
" 'Tight': {'barrel': {'offset': 0.94, 'slope': 1.04},\n", | |
" 'endcap': {'offset': 0.87, 'slope': 1.04},\n", | |
" 'overlap': {'offset': 1.17, 'slope': 1.03}},\n", | |
" 'VLoose': {'barrel': {'offset': 0.96, 'slope': 1.04},\n", | |
" 'endcap': {'offset': 0.94, 'slope': 1.04},\n", | |
" 'overlap': {'offset': 1.17, 'slope': 1.03}},\n", | |
" 'default': {'barrel': {'offset': 0.96, 'slope': 1.04},\n", | |
" 'endcap': {'offset': 0.87, 'slope': 1.04},\n", | |
" 'overlap': {'offset': 1.16, 'slope': 1.03}}},\n", | |
" 'L1hpsTau': {'default': {'barrel': {'offset': 1.88, 'slope': 1.74},\n", | |
" 'endcap': {'offset': 37.49, 'slope': 1.5}}},\n", | |
" 'L1nnCaloTau': {'default': {'barrel': {'offset': -0.72, 'slope': 1.31},\n", | |
" 'endcap': {'offset': -6.02, 'slope': 1.38}}},\n", | |
" 'L1nnPuppiTau': {'default': {'barrel': {'offset': 3.53, 'slope': 1.26},\n", | |
" 'endcap': {'offset': -3.15, 'slope': 1.66}}},\n", | |
" 'L1puppiHistoJetSums': {'MHT': {'inclusive': {'offset': -15.69,\n", | |
" 'slope': 1.18}}},\n", | |
" 'L1puppiJetSC4': {'default': {'barrel': {'offset': 17.33, 'slope': 1.28},\n", | |
" 'endcap': {'offset': 15.33, 'slope': 1.67},\n", | |
" 'forward': {'offset': 71.45, 'slope': 1.14}}},\n", | |
" 'L1puppiJetSC4sums': {'HT': {'inclusive': {'offset': 45.7, 'slope': 1.12}},\n", | |
" 'MHT': {'inclusive': {'offset': -12.93, 'slope': 1.16}}},\n", | |
" 'L1puppiJetSC8': {'default': {'barrel': {'offset': 23.98, 'slope': 1.37},\n", | |
" 'endcap': {'offset': 28.95, 'slope': 1.56},\n", | |
" 'forward': {'offset': 69.06, 'slope': 1.42}}},\n", | |
" 'L1puppiMET': {'default': {'inclusive': {'offset': 37.05, 'slope': 1.64}}},\n", | |
" 'L1puppiMLMET': {'default': {'inclusive': {'offset': 29.35, 'slope': 1.56}}},\n", | |
" 'L1tkElectron': {'Iso': {'barrel': {'offset': 1.16, 'slope': 1.18},\n", | |
" 'endcap': {'offset': 0.18, 'slope': 1.25}},\n", | |
" 'NoIso': {'barrel': {'offset': 1.24, 'slope': 1.18},\n", | |
" 'endcap': {'offset': 0.63, 'slope': 1.25}}},\n", | |
" 'L1tkPhoton': {'Iso': {'barrel': {'offset': 3.04, 'slope': 1.09},\n", | |
" 'endcap': {'offset': 7.73, 'slope': 0.96}},\n", | |
" 'NoIso': {'barrel': {'offset': 4.43, 'slope': 1.07},\n", | |
" 'endcap': {'offset': 5.22, 'slope': 1.07}}}}" | |
] | |
}, | |
"execution_count": 8, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"scalings_dict" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "a0739ff7", | |
"metadata": {}, | |
"source": [ | |
"From https://github.com/cms-sw/cmssw/blob/master/L1Trigger/Phase2L1GT/python/l1tGTProducer_cff.py\n", | |
"```python\n", | |
" GTTPromptJets = cms.InputTag(\"l1tTrackJetsEmulation\", \"L1TrackJets\"),\n", | |
" GTTDisplacedJets = cms.InputTag(\"l1tTrackJetsExtendedEmulation\", \"L1TrackJetsExtended\"),\n", | |
" GTTPromptHtSum = cms.InputTag(\"l1tTrackerEmuHTMiss\", \"L1TrackerEmuHTMiss\"),\n", | |
" GTTDisplacedHtSum = cms.InputTag(\"l1tTrackerEmuHTMissExtended\", \"L1TrackerEmuHTMissExtended\"),\n", | |
" GTTEtSum = cms.InputTag(\"l1tTrackerEmuEtMiss\",\"L1TrackerEmuEtMiss\"),\n", | |
" GTTPrimaryVert = cms.InputTag(\"l1tVertexFinderEmulator\", \"L1VerticesEmulation\"),\n", | |
" GMTSaPromptMuons = cms.InputTag(\"l1tSAMuonsGmt\", \"prompt\"),\n", | |
" GMTSaDisplacedMuons = cms.InputTag(\"l1tSAMuonsGmt\", \"displaced\"),\n", | |
" GMTTkMuons = cms.InputTag(\"l1tTkMuonsGmt\"),\n", | |
" CL2JetsSC4 = cms.InputTag(\"l1tSC4PFL1PuppiCorrectedEmulator\"),\n", | |
" CL2JetsSC8 = cms.InputTag(\"l1tSC8PFL1PuppiCorrectedEmulator\"),\n", | |
" CL2Electrons = cms.InputTag(\"l1tLayer2EG\", \"L1CtTkElectron\"),\n", | |
" CL2Photons = cms.InputTag(\"l1tLayer2EG\", \"L1CtTkEm\"),\n", | |
" CL2Taus = cms.InputTag(\"l1tNNTauProducerPuppi\", \"L1PFTausNN\"),\n", | |
" CL2EtSum = cms.InputTag(\"l1tMETPFProducer\"),\n", | |
" CL2HtSum = cms.InputTag(\"l1tSC4PFL1PuppiCorrectedEmulatorMHT\")\n", | |
"```" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 9, | |
"id": "4f651251", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"gt_name_map = {\n", | |
"# \"\":\"GTTPromptJets\", # = cms.InputTag(\"l1tTrackJetsEmulation\", \"L1TrackJets\"),\n", | |
"# \"\":\"GTTDisplacedJets\", # = cms.InputTag(\"l1tTrackJetsExtendedEmulation\", \"L1TrackJetsExtended\"),\n", | |
"# \"\":\"GTTPromptHtSum\", # = cms.InputTag(\"l1tTrackerEmuHTMiss\", \"L1TrackerEmuHTMiss\"),\n", | |
"# \"\":\"GTTDisplacedHtSum\", # = cms.InputTag(\"l1tTrackerEmuHTMissExtended\", \"L1TrackerEmuHTMissExtended\"),\n", | |
"# \"\":\"GTTEtSum\", # = cms.InputTag(\"l1tTrackerEmuEtMiss\",\"L1TrackerEmuEtMiss\"),\n", | |
"# \"\":\"GTTPrimaryVert\", # = cms.InputTag(\"l1tVertexFinderEmulator\", \"L1VerticesEmulation\"),\n", | |
" \"L1gmtMuon\":\"GMTSaPromptMuons\", # = cms.InputTag(\"l1tSAMuonsGmt\", \"prompt\"),\n", | |
"# \"\":\"GMTSaDisplacedMuons\", # = cms.InputTag(\"l1tSAMuonsGmt\", \"displaced\"),\n", | |
" \"L1gmtTkMuon\":\"GMTTkMuons\", # = cms.InputTag(\"l1tTkMuonsGmt\"),\n", | |
" \"L1puppiJetSC4\":\"CL2JetsSC4\", # = cms.InputTag(\"l1tSC4PFL1PuppiCorrectedEmulator\"),\n", | |
" \"L1puppiJetSC8\":\"CL2JetsSC8\", # = cms.InputTag(\"l1tSC8PFL1PuppiCorrectedEmulator\"),\n", | |
" \"L1tkElectron\":\"CL2Electrons\", # = cms.InputTag(\"l1tLayer2EG\", \"L1CtTkElectron\"),\n", | |
" \"L1tkPhoton\":\"CL2Photons\", # = cms.InputTag(\"l1tLayer2EG\", \"L1CtTkEm\"),\n", | |
" \"L1nnPuppiTau\":\"CL2Taus\", # = cms.InputTag(\"l1tNNTauProducerPuppi\", \"L1PFTausNN\"),\n", | |
" \"L1puppiMET\":\"CL2EtSum\", # = cms.InputTag(\"l1tMETPFProducer\"),\n", | |
" \"L1puppiJetSC4sums\":\"CL2HtSum\", # = cms.InputTag(\"l1tSC4PFL1PuppiCorrectedEmulatorMHT\")\n", | |
"# \"L1EG\":None,\n", | |
"}" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 28, | |
"id": "d9033f4c", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"sed -i 's/L1gmtMuon/GMTSaPromptMuons/g' *.py ;\n", | |
"sed -i 's/L1gmtTkMuon/GMTTkMuons/g' *.py ;\n", | |
"sed -i 's/L1puppiJetSC4/CL2JetsSC4/g' *.py ;\n", | |
"sed -i 's/L1puppiJetSC8/CL2JetsSC8/g' *.py ;\n", | |
"sed -i 's/L1tkElectron/CL2Electrons/g' *.py ;\n", | |
"sed -i 's/L1tkPhoton/CL2Photons/g' *.py ;\n", | |
"sed -i 's/L1nnPuppiTau/CL2Taus/g' *.py ;\n", | |
"sed -i 's/L1puppiMET/CL2EtSum/g' *.py ;\n", | |
"sed -i 's/L1puppiJetSC4sums/CL2HtSum/g' *.py ;\n" | |
] | |
} | |
], | |
"source": [ | |
"for l1name, gtname in gt_name_map.items():\n", | |
" \n", | |
" cmd = \"sed -i 's/%s/%s/g' *.py ;\" % (l1name, gtname)\n", | |
" print(cmd)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "06835a04", | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 10, | |
"id": "abfa0abb", | |
"metadata": { | |
"scrolled": true | |
}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"dict_keys(['L1EG', 'L1TrackHT', 'L1TrackJet', 'L1TrackMET', 'L1caloJet', 'L1caloTau', 'L1gmtMuon', 'L1gmtTkMuon', 'L1hpsTau', 'L1nnCaloTau', 'L1nnPuppiTau', 'L1puppiHistoJetSums', 'L1puppiJetSC4', 'L1puppiJetSC4sums', 'L1puppiJetSC8', 'L1puppiMET', 'L1puppiMLMET', 'L1tkElectron', 'L1tkPhoton'])" | |
] | |
}, | |
"execution_count": 10, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"scalings_dict.keys()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 29, | |
"id": "5fe9aaf6", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"new_dict = {}\n", | |
"\n", | |
"for k,i in scalings_dict.items():\n", | |
" if k in gt_name_map:\n", | |
" new_dict[gt_name_map[k]] = i\n", | |
" else:\n", | |
" new_dict[k] = i" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 30, | |
"id": "52159926", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"{'L1EG': {'default': {'barrel': {'offset': 4.36, 'slope': 1.12},\n", | |
" 'endcap': {'offset': 5.22, 'slope': 1.07}}},\n", | |
" 'L1TrackHT': {'HT': {'inclusive': {'offset': -51.83, 'slope': 2.58}},\n", | |
" 'MHT': {'inclusive': {'offset': -19.41, 'slope': 2.27}}},\n", | |
" 'L1TrackJet': {'default': {'barrel': {'offset': 14.84, 'slope': 5.15},\n", | |
" 'endcap': {'offset': 30.24, 'slope': 7.12}}},\n", | |
" 'L1TrackMET': {'default': {'inclusive': {'offset': -75.85, 'slope': 8.69}}},\n", | |
" 'L1caloJet': {'default': {'barrel': {'offset': 2.27, 'slope': 1.48},\n", | |
" 'endcap': {'offset': 77.98, 'slope': 1.74},\n", | |
" 'forward': {'offset': 223.84, 'slope': 0.89}}},\n", | |
" 'L1caloTau': {'default': {'barrel': {'offset': -10.87, 'slope': 1.69},\n", | |
" 'endcap': {'offset': -45.77, 'slope': 2.54}}},\n", | |
" 'GMTSaPromptMuons': {'default': {'barrel': {'offset': 1.08, 'slope': 1.69},\n", | |
" 'endcap': {'offset': -2.97, 'slope': 1.21},\n", | |
" 'overlap': {'offset': -1.17, 'slope': 1.35}}},\n", | |
" 'GMTTkMuons': {'Loose': {'barrel': {'offset': 0.96, 'slope': 1.04},\n", | |
" 'endcap': {'offset': 0.87, 'slope': 1.04},\n", | |
" 'overlap': {'offset': 1.16, 'slope': 1.03}},\n", | |
" 'Medium': {'barrel': {'offset': 0.95, 'slope': 1.04},\n", | |
" 'endcap': {'offset': 0.87, 'slope': 1.04},\n", | |
" 'overlap': {'offset': 1.16, 'slope': 1.03}},\n", | |
" 'Tight': {'barrel': {'offset': 0.94, 'slope': 1.04},\n", | |
" 'endcap': {'offset': 0.87, 'slope': 1.04},\n", | |
" 'overlap': {'offset': 1.17, 'slope': 1.03}},\n", | |
" 'VLoose': {'barrel': {'offset': 0.96, 'slope': 1.04},\n", | |
" 'endcap': {'offset': 0.94, 'slope': 1.04},\n", | |
" 'overlap': {'offset': 1.17, 'slope': 1.03}},\n", | |
" 'default': {'barrel': {'offset': 0.96, 'slope': 1.04},\n", | |
" 'endcap': {'offset': 0.87, 'slope': 1.04},\n", | |
" 'overlap': {'offset': 1.16, 'slope': 1.03}}},\n", | |
" 'L1hpsTau': {'default': {'barrel': {'offset': 1.88, 'slope': 1.74},\n", | |
" 'endcap': {'offset': 37.49, 'slope': 1.5}}},\n", | |
" 'L1nnCaloTau': {'default': {'barrel': {'offset': -0.72, 'slope': 1.31},\n", | |
" 'endcap': {'offset': -6.02, 'slope': 1.38}}},\n", | |
" 'CL2Taus': {'default': {'barrel': {'offset': 3.53, 'slope': 1.26},\n", | |
" 'endcap': {'offset': -3.15, 'slope': 1.66}}},\n", | |
" 'L1puppiHistoJetSums': {'MHT': {'inclusive': {'offset': -15.69,\n", | |
" 'slope': 1.18}}},\n", | |
" 'CL2JetsSC4': {'default': {'barrel': {'offset': 17.33, 'slope': 1.28},\n", | |
" 'endcap': {'offset': 15.33, 'slope': 1.67},\n", | |
" 'forward': {'offset': 71.45, 'slope': 1.14}}},\n", | |
" 'CL2HtSum': {'HT': {'inclusive': {'offset': 45.7, 'slope': 1.12}},\n", | |
" 'MHT': {'inclusive': {'offset': -12.93, 'slope': 1.16}}},\n", | |
" 'CL2JetsSC8': {'default': {'barrel': {'offset': 23.98, 'slope': 1.37},\n", | |
" 'endcap': {'offset': 28.95, 'slope': 1.56},\n", | |
" 'forward': {'offset': 69.06, 'slope': 1.42}}},\n", | |
" 'CL2EtSum': {'default': {'inclusive': {'offset': 37.05, 'slope': 1.64}}},\n", | |
" 'L1puppiMLMET': {'default': {'inclusive': {'offset': 29.35, 'slope': 1.56}}},\n", | |
" 'CL2Electrons': {'Iso': {'barrel': {'offset': 1.16, 'slope': 1.18},\n", | |
" 'endcap': {'offset': 0.18, 'slope': 1.25}},\n", | |
" 'NoIso': {'barrel': {'offset': 1.24, 'slope': 1.18},\n", | |
" 'endcap': {'offset': 0.63, 'slope': 1.25}}},\n", | |
" 'CL2Photons': {'Iso': {'barrel': {'offset': 3.04, 'slope': 1.09},\n", | |
" 'endcap': {'offset': 7.73, 'slope': 0.96}},\n", | |
" 'NoIso': {'barrel': {'offset': 4.43, 'slope': 1.07},\n", | |
" 'endcap': {'offset': 5.22, 'slope': 1.07}}}}" | |
] | |
}, | |
"execution_count": 30, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"new_dict" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 31, | |
"id": "3ec162d3", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"# pd.DataFrame(scalings_dict)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 33, | |
"id": "3a3762ed", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"# with open('scalings_v44.py', 'w') as outfile:\n", | |
"# # file.write('this_dict = ')\n", | |
"# outfile.write(\"scalings = \" + repr(scalings_dict))\n", | |
"# # outfile.write(repr(scalings_dict))\n", | |
"# # yaml.dump(scalings_dict, outfile, default_flow_style=False)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 34, | |
"id": "4ebdd1ea", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"# ! head scalings_v44.py" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 13, | |
"id": "e6f2e7cd", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"# import yaml" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 14, | |
"id": "4a71a53c", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"# with open('scalings_v44.yaml', 'w') as outfile:\n", | |
"# yaml.dump(scalings_dict, outfile, default_flow_style=False)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 93, | |
"id": "730cff20", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"# ! readlink -f scalings_v44.yaml" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 15, | |
"id": "56fd5a00", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"# ! cat scalings_v44.yaml" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 16, | |
"id": "da143af2", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"# ! ls /eos/home-a/alobanov/SWAN_projects/L1T-Ph2-Menu/L1Nano/scalings_v44.yaml" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "ce39a961", | |
"metadata": {}, | |
"source": [ | |
"# Save to python" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 35, | |
"id": "fa4a352b", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"import json" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 36, | |
"id": "ab5c1807", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"with open('/eos/home-a/alobanov/SWAN_projects/L1T-Ph2-Menu/L1Nano/scalings_v44.py', 'w') as file:\n", | |
" file.write(\"scalings = \" + json.dumps(new_dict, indent=4, sort_keys=True)) # use `json.loads` to do the reverse" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 37, | |
"id": "9ba40225", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"scalings = {\r\n", | |
" \"CL2Electrons\": {\r\n", | |
" \"Iso\": {\r\n", | |
" \"barrel\": {\r\n", | |
" \"offset\": 1.16,\r\n", | |
" \"slope\": 1.18\r\n", | |
" },\r\n", | |
" \"endcap\": {\r\n", | |
" \"offset\": 0.18,\r\n", | |
" \"slope\": 1.25\r\n" | |
] | |
} | |
], | |
"source": [ | |
"! head /eos/home-a/alobanov/SWAN_projects/L1T-Ph2-Menu/L1Nano/scalings_v44.py" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 24, | |
"id": "fd50b60f", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"scalings = {\r\n", | |
" \"CL2Electrons\": {\r\n", | |
" \"Iso\": {\r\n", | |
" \"barrel\": {\r\n", | |
" \"offset\": 1.16,\r\n", | |
" \"slope\": 1.18\r\n", | |
" },\r\n", | |
" \"endcap\": {\r\n", | |
" \"offset\": 0.18,\r\n", | |
" \"slope\": 1.25\r\n" | |
] | |
} | |
], | |
"source": [ | |
"! head scalings_v44.py" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 25, | |
"id": "ef2cd5f7", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"from scalings_v44 import scalings" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 35, | |
"id": "e260599b", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"{'CL2Electrons': {'Iso': {'barrel': {'offset': 1.16, 'slope': 1.18},\n", | |
" 'endcap': {'offset': 0.18, 'slope': 1.25}},\n", | |
" 'NoIso': {'barrel': {'offset': 1.24, 'slope': 1.18},\n", | |
" 'endcap': {'offset': 0.63, 'slope': 1.25}}},\n", | |
" 'CL2EtSum': {'default': {'inclusive': {'offset': 37.05, 'slope': 1.64}}},\n", | |
" 'CL2HtSum': {'HT': {'inclusive': {'offset': 45.7, 'slope': 1.12}},\n", | |
" 'MHT': {'inclusive': {'offset': -12.93, 'slope': 1.16}}},\n", | |
" 'CL2JetsSC4': {'default': {'barrel': {'offset': 17.33, 'slope': 1.28},\n", | |
" 'endcap': {'offset': 15.33, 'slope': 1.67},\n", | |
" 'forward': {'offset': 71.45, 'slope': 1.14}}},\n", | |
" 'CL2JetsSC8': {'default': {'barrel': {'offset': 23.98, 'slope': 1.37},\n", | |
" 'endcap': {'offset': 28.95, 'slope': 1.56},\n", | |
" 'forward': {'offset': 69.06, 'slope': 1.42}}},\n", | |
" 'CL2Photons': {'Iso': {'barrel': {'offset': 3.04, 'slope': 1.09},\n", | |
" 'endcap': {'offset': 7.73, 'slope': 0.96}},\n", | |
" 'NoIso': {'barrel': {'offset': 4.43, 'slope': 1.07},\n", | |
" 'endcap': {'offset': 5.22, 'slope': 1.07}}},\n", | |
" 'CL2Taus': {'default': {'barrel': {'offset': 3.53, 'slope': 1.26},\n", | |
" 'endcap': {'offset': -3.15, 'slope': 1.66}}},\n", | |
" 'GMTSaPromptMuons': {'default': {'barrel': {'offset': 1.08, 'slope': 1.69},\n", | |
" 'endcap': {'offset': -2.97, 'slope': 1.21},\n", | |
" 'overlap': {'offset': -1.17, 'slope': 1.35}}},\n", | |
" 'GMTTkMuons': {'Loose': {'barrel': {'offset': 0.96, 'slope': 1.04},\n", | |
" 'endcap': {'offset': 0.87, 'slope': 1.04},\n", | |
" 'overlap': {'offset': 1.16, 'slope': 1.03}},\n", | |
" 'Medium': {'barrel': {'offset': 0.95, 'slope': 1.04},\n", | |
" 'endcap': {'offset': 0.87, 'slope': 1.04},\n", | |
" 'overlap': {'offset': 1.16, 'slope': 1.03}},\n", | |
" 'Tight': {'barrel': {'offset': 0.94, 'slope': 1.04},\n", | |
" 'endcap': {'offset': 0.87, 'slope': 1.04},\n", | |
" 'overlap': {'offset': 1.17, 'slope': 1.03}},\n", | |
" 'VLoose': {'barrel': {'offset': 0.96, 'slope': 1.04},\n", | |
" 'endcap': {'offset': 0.94, 'slope': 1.04},\n", | |
" 'overlap': {'offset': 1.17, 'slope': 1.03}},\n", | |
" 'default': {'barrel': {'offset': 0.96, 'slope': 1.04},\n", | |
" 'endcap': {'offset': 0.87, 'slope': 1.04},\n", | |
" 'overlap': {'offset': 1.16, 'slope': 1.03}}}}" | |
] | |
}, | |
"execution_count": 35, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"scalings" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 23, | |
"id": "05ba3204", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"\n", | |
"# # as requested in comment\n", | |
"# exDict = {'exDict': exDict}\n", | |
"\n", | |
"with open('/eos/home-a/alobanov/SWAN_projects/L1T-Ph2-Menu/L1Nano/scalings_v44.json', 'w') as file:\n", | |
" file.write(json.dumps(scalings_dict, indent=4, sort_keys=True)) # use `json.loads` to do the reverse" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 24, | |
"id": "7b24953e", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"{\r\n", | |
" \"L1EG\": {\r\n", | |
" \"default\": {\r\n", | |
" \"barrel\": {\r\n", | |
" \"offset\": 4.36,\r\n", | |
" \"slope\": 1.12\r\n", | |
" },\r\n", | |
" \"endcap\": {\r\n", | |
" \"offset\": 5.22,\r\n", | |
" \"slope\": 1.07\r\n", | |
" }\r\n", | |
" }\r\n", | |
" },\r\n", | |
" \"L1TrackHT\": {\r\n", | |
" \"HT\": {\r\n", | |
" \"inclusive\": {\r\n", | |
" \"offset\": -51.83,\r\n", | |
" \"slope\": 2.58\r\n", | |
" }\r\n", | |
" },\r\n", | |
" \"MHT\": {\r\n", | |
" \"inclusive\": {\r\n", | |
" \"offset\": -19.41,\r\n", | |
" \"slope\": 2.27\r\n", | |
" }\r\n", | |
" }\r\n", | |
" },\r\n", | |
" \"L1TrackJet\": {\r\n", | |
" \"default\": {\r\n", | |
" \"barrel\": {\r\n", | |
" \"offset\": 14.84,\r\n", | |
" \"slope\": 5.15\r\n", | |
" },\r\n", | |
" \"endcap\": {\r\n", | |
" \"offset\": 30.24,\r\n", | |
" \"slope\": 7.12\r\n", | |
" }\r\n", | |
" }\r\n", | |
" },\r\n", | |
" \"L1TrackMET\": {\r\n", | |
" \"default\": {\r\n", | |
" \"inclusive\": {\r\n", | |
" \"offset\": -75.85,\r\n", | |
" \"slope\": 8.69\r\n", | |
" }\r\n", | |
" }\r\n", | |
" },\r\n", | |
" \"L1caloJet\": {\r\n", | |
" \"default\": {\r\n", | |
" \"barrel\": {\r\n", | |
" \"offset\": 2.27,\r\n", | |
" \"slope\": 1.48\r\n", | |
" },\r\n", | |
" \"endcap\": {\r\n", | |
" \"offset\": 77.98,\r\n", | |
" \"slope\": 1.74\r\n", | |
" },\r\n", | |
" \"forward\": {\r\n", | |
" \"offset\": 223.84,\r\n", | |
" \"slope\": 0.89\r\n", | |
" }\r\n", | |
" }\r\n", | |
" },\r\n", | |
" \"L1caloTau\": {\r\n", | |
" \"default\": {\r\n", | |
" \"barrel\": {\r\n", | |
" \"offset\": -10.87,\r\n", | |
" \"slope\": 1.69\r\n", | |
" },\r\n", | |
" \"endcap\": {\r\n", | |
" \"offset\": -45.77,\r\n", | |
" \"slope\": 2.54\r\n", | |
" }\r\n", | |
" }\r\n", | |
" },\r\n", | |
" \"L1gmtMuon\": {\r\n", | |
" \"default\": {\r\n", | |
" \"barrel\": {\r\n", | |
" \"offset\": 1.08,\r\n", | |
" \"slope\": 1.69\r\n", | |
" },\r\n", | |
" \"endcap\": {\r\n", | |
" \"offset\": -2.97,\r\n", | |
" \"slope\": 1.21\r\n", | |
" },\r\n", | |
" \"overlap\": {\r\n", | |
" \"offset\": -1.17,\r\n", | |
" \"slope\": 1.35\r\n", | |
" }\r\n", | |
" }\r\n", | |
" },\r\n", | |
" \"L1gmtTkMuon\": {\r\n", | |
" \"Loose\": {\r\n", | |
" \"barrel\": {\r\n", | |
" \"offset\": 0.96,\r\n", | |
" \"slope\": 1.04\r\n", | |
" },\r\n", | |
" \"endcap\": {\r\n", | |
" \"offset\": 0.87,\r\n", | |
" \"slope\": 1.04\r\n", | |
" },\r\n", | |
" \"overlap\": {\r\n", | |
" \"offset\": 1.16,\r\n", | |
" \"slope\": 1.03\r\n", | |
" }\r\n", | |
" },\r\n", | |
" \"Medium\": {\r\n", | |
" \"barrel\": {\r\n", | |
" \"offset\": 0.95,\r\n", | |
" \"slope\": 1.04\r\n", | |
" },\r\n", | |
" \"endcap\": {\r\n", | |
" \"offset\": 0.87,\r\n", | |
" \"slope\": 1.04\r\n", | |
" },\r\n", | |
" \"overlap\": {\r\n", | |
" \"offset\": 1.16,\r\n", | |
" \"slope\": 1.03\r\n", | |
" }\r\n", | |
" },\r\n", | |
" \"Tight\": {\r\n", | |
" \"barrel\": {\r\n", | |
" \"offset\": 0.94,\r\n", | |
" \"slope\": 1.04\r\n", | |
" },\r\n", | |
" \"endcap\": {\r\n", | |
" \"offset\": 0.87,\r\n", | |
" \"slope\": 1.04\r\n", | |
" },\r\n", | |
" \"overlap\": {\r\n", | |
" \"offset\": 1.17,\r\n", | |
" \"slope\": 1.03\r\n", | |
" }\r\n", | |
" },\r\n", | |
" \"VLoose\": {\r\n", | |
" \"barrel\": {\r\n", | |
" \"offset\": 0.96,\r\n", | |
" \"slope\": 1.04\r\n", | |
" },\r\n", | |
" \"endcap\": {\r\n", | |
" \"offset\": 0.94,\r\n", | |
" \"slope\": 1.04\r\n", | |
" },\r\n", | |
" \"overlap\": {\r\n", | |
" \"offset\": 1.17,\r\n", | |
" \"slope\": 1.03\r\n", | |
" }\r\n", | |
" },\r\n", | |
" \"default\": {\r\n", | |
" \"barrel\": {\r\n", | |
" \"offset\": 0.96,\r\n", | |
" \"slope\": 1.04\r\n", | |
" },\r\n", | |
" \"endcap\": {\r\n", | |
" \"offset\": 0.87,\r\n", | |
" \"slope\": 1.04\r\n", | |
" },\r\n", | |
" \"overlap\": {\r\n", | |
" \"offset\": 1.16,\r\n", | |
" \"slope\": 1.03\r\n", | |
" }\r\n", | |
" }\r\n", | |
" },\r\n", | |
" \"L1hpsTau\": {\r\n", | |
" \"default\": {\r\n", | |
" \"barrel\": {\r\n", | |
" \"offset\": 1.88,\r\n", | |
" \"slope\": 1.74\r\n", | |
" },\r\n", | |
" \"endcap\": {\r\n", | |
" \"offset\": 37.49,\r\n", | |
" \"slope\": 1.5\r\n", | |
" }\r\n", | |
" }\r\n", | |
" },\r\n", | |
" \"L1nnCaloTau\": {\r\n", | |
" \"default\": {\r\n", | |
" \"barrel\": {\r\n", | |
" \"offset\": -0.72,\r\n", | |
" \"slope\": 1.31\r\n", | |
" },\r\n", | |
" \"endcap\": {\r\n", | |
" \"offset\": -6.02,\r\n", | |
" \"slope\": 1.38\r\n", | |
" }\r\n", | |
" }\r\n", | |
" },\r\n", | |
" \"L1nnPuppiTau\": {\r\n", | |
" \"default\": {\r\n", | |
" \"barrel\": {\r\n", | |
" \"offset\": 3.53,\r\n", | |
" \"slope\": 1.26\r\n", | |
" },\r\n", | |
" \"endcap\": {\r\n", | |
" \"offset\": -3.15,\r\n", | |
" \"slope\": 1.66\r\n", | |
" }\r\n", | |
" }\r\n", | |
" },\r\n", | |
" \"L1puppiHistoJetSums\": {\r\n", | |
" \"MHT\": {\r\n", | |
" \"inclusive\": {\r\n", | |
" \"offset\": -15.69,\r\n", | |
" \"slope\": 1.18\r\n", | |
" }\r\n", | |
" }\r\n", | |
" },\r\n", | |
" \"L1puppiJetSC4\": {\r\n", | |
" \"default\": {\r\n", | |
" \"barrel\": {\r\n", | |
" \"offset\": 17.33,\r\n", | |
" \"slope\": 1.28\r\n", | |
" },\r\n", | |
" \"endcap\": {\r\n", | |
" \"offset\": 15.33,\r\n", | |
" \"slope\": 1.67\r\n", | |
" },\r\n", | |
" \"forward\": {\r\n", | |
" \"offset\": 71.45,\r\n", | |
" \"slope\": 1.14\r\n", | |
" }\r\n", | |
" }\r\n", | |
" },\r\n", | |
" \"L1puppiJetSC4sums\": {\r\n", | |
" \"HT\": {\r\n", | |
" \"inclusive\": {\r\n", | |
" \"offset\": 45.7,\r\n", | |
" \"slope\": 1.12\r\n", | |
" }\r\n", | |
" },\r\n", | |
" \"MHT\": {\r\n", | |
" \"inclusive\": {\r\n", | |
" \"offset\": -12.93,\r\n", | |
" \"slope\": 1.16\r\n", | |
" }\r\n", | |
" }\r\n", | |
" },\r\n", | |
" \"L1puppiJetSC8\": {\r\n", | |
" \"default\": {\r\n", | |
" \"barrel\": {\r\n", | |
" \"offset\": 23.98,\r\n", | |
" \"slope\": 1.37\r\n", | |
" },\r\n", | |
" \"endcap\": {\r\n", | |
" \"offset\": 28.95,\r\n", | |
" \"slope\": 1.56\r\n", | |
" },\r\n", | |
" \"forward\": {\r\n", | |
" \"offset\": 69.06,\r\n", | |
" \"slope\": 1.42\r\n", | |
" }\r\n", | |
" }\r\n", | |
" },\r\n", | |
" \"L1puppiMET\": {\r\n", | |
" \"default\": {\r\n", | |
" \"inclusive\": {\r\n", | |
" \"offset\": 37.05,\r\n", | |
" \"slope\": 1.64\r\n", | |
" }\r\n", | |
" }\r\n", | |
" },\r\n", | |
" \"L1puppiMLMET\": {\r\n", | |
" \"default\": {\r\n", | |
" \"inclusive\": {\r\n", | |
" \"offset\": 29.35,\r\n", | |
" \"slope\": 1.56\r\n", | |
" }\r\n", | |
" }\r\n", | |
" },\r\n", | |
" \"L1tkElectron\": {\r\n", | |
" \"Iso\": {\r\n", | |
" \"barrel\": {\r\n", | |
" \"offset\": 1.16,\r\n", | |
" \"slope\": 1.18\r\n", | |
" },\r\n", | |
" \"endcap\": {\r\n", | |
" \"offset\": 0.18,\r\n", | |
" \"slope\": 1.25\r\n", | |
" }\r\n", | |
" },\r\n", | |
" \"NoIso\": {\r\n", | |
" \"barrel\": {\r\n", | |
" \"offset\": 1.24,\r\n", | |
" \"slope\": 1.18\r\n", | |
" },\r\n", | |
" \"endcap\": {\r\n", | |
" \"offset\": 0.63,\r\n", | |
" \"slope\": 1.25\r\n", | |
" }\r\n", | |
" }\r\n", | |
" },\r\n", | |
" \"L1tkPhoton\": {\r\n", | |
" \"Iso\": {\r\n", | |
" \"barrel\": {\r\n", | |
" \"offset\": 3.04,\r\n", | |
" \"slope\": 1.09\r\n", | |
" },\r\n", | |
" \"endcap\": {\r\n", | |
" \"offset\": 7.73,\r\n", | |
" \"slope\": 0.96\r\n", | |
" }\r\n", | |
" },\r\n", | |
" \"NoIso\": {\r\n", | |
" \"barrel\": {\r\n", | |
" \"offset\": 4.43,\r\n", | |
" \"slope\": 1.07\r\n", | |
" },\r\n", | |
" \"endcap\": {\r\n", | |
" \"offset\": 5.22,\r\n", | |
" \"slope\": 1.07\r\n", | |
" }\r\n", | |
" }\r\n", | |
" }\r\n", | |
"}" | |
] | |
} | |
], | |
"source": [ | |
"! cat /eos/home-a/alobanov/SWAN_projects/L1T-Ph2-Menu/L1Nano/scalings_v44.json" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "35ec9776", | |
"metadata": {}, | |
"source": [ | |
"# Use scalings in P2GT config" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 105, | |
"id": "950be827", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"with open('/eos/home-a/alobanov/SWAN_projects/L1T-Ph2-Menu/L1Nano/scalings_v44.json', 'r') as file:\n", | |
"# # file.write(json.dumps(scalings_dict)) # use `json.loads` to do the reverse\n", | |
"# file.readlines(json.dumps(scalings_dict)) # use `json.loads` to do the reverse\n", | |
" scalings = json.load(file)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 106, | |
"id": "65b4b4ed", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"{'L1caloTau': {'default': {'barrel': {'offset': -10.871920725051726,\n", | |
" 'slope': 1.6910051951745764},\n", | |
" 'endcap': {'offset': -45.7691736081406, 'slope': 2.5410423155289257}}},\n", | |
" 'L1hpsTau': {'default': {'barrel': {'offset': 1.8783280710478891,\n", | |
" 'slope': 1.7408305577437153},\n", | |
" 'endcap': {'offset': 37.49301650194258, 'slope': 1.4991719967934074}}},\n", | |
" 'L1nnCaloTau': {'default': {'barrel': {'offset': -0.7156269029121916,\n", | |
" 'slope': 1.3125263109870344},\n", | |
" 'endcap': {'offset': -6.022119809604722, 'slope': 1.3755790706614288}}},\n", | |
" 'L1nnPuppiTau': {'default': {'barrel': {'offset': 3.5316970710163034,\n", | |
" 'slope': 1.2649278135977127},\n", | |
" 'endcap': {'offset': -3.1528739773353935, 'slope': 1.656044136839053}}}}" | |
] | |
}, | |
"execution_count": 106, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"scalings" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "7ef356c0", | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 107, | |
"id": "4a345621", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"# import yaml\n", | |
"# scalings_fname = \"/eos/home-a/alobanov/SWAN_projects/L1T-Ph2-Menu/L1Nano/scalings_v44.yaml\"\n", | |
"# with open(scalings_fname, \"r\") as f:\n", | |
"# scalings = yaml.safe_load(f)\n", | |
"\n", | |
"def off_to_on_thr(thr, obj, id, region, scalings = scalings):\n", | |
" offset = scalings[obj][id][region][\"offset\"]\n", | |
" slope = scalings[obj][id][region][\"slope\"]\n", | |
"\n", | |
" return (thr - offset)/slope" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 108, | |
"id": "060624d9", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"33.30398794962527" | |
] | |
}, | |
"execution_count": 108, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"off_to_on_thr(52, \"L1nnPuppiTau\",\"default\",\"endcap\")" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 109, | |
"id": "71feecd0", | |
"metadata": { | |
"scrolled": true | |
}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"38.31705051304861" | |
] | |
}, | |
"execution_count": 109, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"off_to_on_thr(52, \"L1nnPuppiTau\",\"default\",\"barrel\")" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "25b4ec6b", | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 3", | |
"language": "python", | |
"name": "python3" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.11.9" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 5 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment