Skip to content
Snippets Groups Projects
Commit 5ed763e1 authored by Duc Ta's avatar Duc Ta
Browse files

Merge branch 'tstreble-24.0-patch-c9fd' into '24.0'

Clean up JetValidation legacy configs

See merge request !69182
parents ca8a1a20 b10ab993
No related branches found
No related tags found
2 merge requests!692142024-02-24: merge of 24.0 into main,!69182Clean up JetValidation legacy configs
# Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
from JetMonitoring.JetHistoTools import jhm, selectionAndHistos
from JetMonitoring.JetMonitoringConf import JetMonitoringTool, JetKinematicHistos, JetContainerHistoFiller, JetSubStructureHistos
from AthenaCommon.AppMgr import ServiceMgr as svcMgr
from PyUtils.MetaReader import read_metadata
input_file = svcMgr.EventSelector.InputCollections[0]
metadata = read_metadata(input_file) # opens the first file from the InputCollections list
metadata = metadata[input_file] # promote keys stored under input_file key one level up to access them directly
# this is a dict of dicts, take a look at what's available! Below are some examples:
isMC = 'IS_SIMULATION' in metadata['eventTypes']
beam_energy = metadata['beam_energy']
conditions_tag = metadata['IOVDbGlobalTag'] #useful for figuring out which mc production this is
print ("PhysicsValidationHistos: isMC=",isMC, " beam=",beam_energy," conditions_tag=",conditions_tag)
def commonPhysValTool(container, refcontainer="", onlyKinematics = False, globalSelection= ""):
containerfiller = JetContainerHistoFiller(container+"HistoFiller",JetContainer = container)
filler = containerfiller
if globalSelection !="":
# here we create an intermediate selection tool, we'll pass it the histo builders
# instead of passing them to containerfiller
# Create the intermediate tool and attach it to containerfiller:
containerfiller.HistoTools = [ selectionAndHistos( globalSelection,
[] , # no histo builders, will be set below
histoNameSuffix= "none", # same histo names as without global selection
)
]
# attach the selection :
filler = containerfiller.HistoTools[0]
containerfiller.OutputLevel = 2
filler.OutputLevel = 2
# Give a list of predefined tools from jhm or a combination of such tools
filler.HistoTools = [
# build a special tool without 2D hists :
JetKinematicHistos("kinematics",PlotOccupancy=False, PlotAveragePt=False, PlotNJet=True) ,
]
if onlyKinematics:
# return now
return containerfiller
filler.HistoTools += [
# Draw a set of histo for a particular jet selection :
selectionAndHistos( "leadingjet" , [ "basickinematics", ] ),
selectionAndHistos( "subleadingjet" , [ "basickinematics"] ),
selectionAndHistos("40000<pt<50000",["pt"]),
# distances between 2 leading jets.
jhm.leadingjetrel,
]
if ( ("Topo" in container or "PFlow" in container) and "Trimmed" not in container) and "SoftDrop" not in container:
filler.HistoTools += [
jhm.Width,
# jet states
jhm.basickinematics_emscale,
#track variables
jhm.tool("JVF[0]"),
jhm.JVF,
jhm.JVFCorr,
jhm.Jvt,
jhm.JvtRpt,
# calo variables
jhm.NegativeE,
jhm.Timing,
jhm.LArQuality,
]
if "Topo" in container or "PFlow" in container or "UFO" in container:
filler.HistoTools += [
# jet states
jhm.basickinematics_constscale,
# track variables
jhm.SumPtTrkPt500,
jhm.tool("SumPtTrkPt500[0]"),
jhm.tool("NumTrkPt500[0]"),
jhm.tool("NumTrkPt1000[0]"),
jhm.tool("TrackWidthPt1000[0]"),
jhm.GhostTrackCount,
jhm.GhostTruthAssociationFraction,
jhm.GhostMuonSegmentCount,
# calo variables
jhm.EMFrac,
jhm.HECFrac,
jhm.EMB2,
jhm.EMB3,
jhm.EME2,
jhm.EME3,
jhm.HEC2,
jhm.HEC3,
jhm.FCAL0,
jhm.FCAL1,
jhm.TileBar0,
jhm.TileBar1,
jhm.TileExt0,
jhm.TileExt1
]
if "PFlow" in container:
filler.HistoTools += [
jhm.tool("SumPtChargedPFOPt500[0]"),
jhm.tool("NumChargedPFOPt500[0]"),
jhm.tool("NumChargedPFOPt1000[0]"),
jhm.tool("ChargedPFOWidthPt1000[0]"),
jhm.DFCommonJets_QGTagger_NTracks,
jhm.DFCommonJets_QGTagger_TracksWidth,
jhm.DFCommonJets_QGTagger_TracksC1,
jhm.DFCommonJets_fJvt,
]
if refcontainer:
# efficiency
filler.HistoTools += [jhm.effresponse,]
filler.HistoTools['effresponse'].RefContainer = refcontainer
if "SoftDrop" in container:
filler.HistoTools += [
jhm.rg,
jhm.zg,
]
elif "Trimmed" in container:
filler.HistoTools += [
jhm.NTrimSubjets,
jhm.TrackSumPt,
jhm.TrackSumMass,
]
if "Trimmed" in container or "SoftDrop" in container:
filler.HistoTools += [
#main list of substrcture variables
JetSubStructureHistos("substructure"),
jhm.DetectorEta,
jhm.ECF1,
jhm.ECF2,
jhm.ECF3,
jhm.Tau1_wta,
jhm.Tau2_wta,
jhm.Tau3_wta,
jhm.Split12,
jhm.Split23,
jhm.Qw,
jhm.PlanarFlow,
jhm.FoxWolfram0,
jhm.FoxWolfram2,
jhm.Angularity,
jhm.Aplanarity,
jhm.KtDR,
jhm.ZCut12,
jhm.ZCut23,
jhm.ZCut34,
jhm.Split34,
jhm.ThrustMin,
jhm.ThrustMaj,
jhm.FoxWolfram1,
jhm.FoxWolfram3,
jhm.FoxWolfram4,
jhm.Sphericity,
jhm.Charge
]
if 'PV0Track' in container:
filler.HistoTools += [
jhm.HadronConeExclTruthLabelID,
jhm.HadronConeExclExtendedTruthLabelID,
jhm.HadronGhostTruthLabelID,
jhm.HadronGhostExtendedTruthLabelID,
]
#filler.OutputLevel =2
return containerfiller
from RecExConfig.RecFlags import rec
akt4refContainer = "AntiKt4TruthJets" if rec.doTruth() else ""
#globalSelection = "0.7<JVF[0]"
globalSelection = ""
##
# necessary updates for validation directories
###
athenaMonTool = JetMonitoringTool(HistoTools = [
commonPhysValTool( "AntiKt4LCTopoJets", akt4refContainer ,globalSelection = globalSelection),
commonPhysValTool( "AntiKt4EMTopoJets", akt4refContainer ,globalSelection = globalSelection),
commonPhysValTool( "AntiKt4EMPFlowJets", akt4refContainer ,globalSelection = globalSelection ),
commonPhysValTool( "AntiKt4TruthJets" ),
commonPhysValTool( "AntiKt10LCTopoTrimmedPtFrac5SmallR20Jets" ),
commonPhysValTool( "AntiKt10UFOCSSKSoftDropBeta100Zcut10Jets" ),
commonPhysValTool( "AntiKt10TruthTrimmedPtFrac5SmallR20Jets" ),
commonPhysValTool( "AntiKt10TruthSoftDropBeta100Zcut10Jets" ),
commonPhysValTool( "AntiKtVR30Rmax4Rmin02PV0TrackJets"),
], IntervalType=8) # 8 == HistoGroupBase::all
if not isMC:
athenaMonTool = JetMonitoringTool(HistoTools = [
commonPhysValTool( "AntiKt4LCTopoJets", akt4refContainer ,globalSelection = globalSelection),
commonPhysValTool( "AntiKt4EMTopoJets", akt4refContainer ,globalSelection = globalSelection),
commonPhysValTool( "AntiKt4EMPFlowJets" ),
commonPhysValTool( "AntiKt10LCTopoTrimmedPtFrac5SmallR20Jets" ),
commonPhysValTool( "AntiKt10UFOCSSKSoftDropBeta100Zcut10Jets" ),
commonPhysValTool( "AntiKtVR30Rmax4Rmin02PV0TrackJets"),
], IntervalType=8) # 8 == HistoGroupBase::all
#ToolSvc += athenaMonTool
def athenaPhysValTool():
return athenaMonTool
# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
containerToRebuild = ["AntiKt4LCTopoJetsTest", "AntiKt10LCTopoJetsTest",]
def scheduleRTTJetTests():
global containerToRebuild
from JetRec.JetRecFlags import jetFlags
from RecExConfig.RecFlags import rec
jetFlags.useTruth = rec.doTruth()
from JetRec.JetRecStandard import jtm
from JetRec.JetRecConf import JetAlgorithm
from JetRec.JetRecUtils import interpretJetName
#calibarg = 'calib' if jetFlags.applyCalibrationName()!="none" else None
#calibarg = 'calib' if jetFlags.applyCalibrationName!= "none" else "none"
# arguments to give to addJetFinder
# format is 'input' : dict_of_args
inputArgs = { 'LCTopo' : dict(gettersin='lctopo', modifiersin='calib' ,ghostArea=0.01, ),
'EMTopo' : dict(gettersin='emtopo', modifiersin='calib' ,ghostArea=0.01, ),
'ZTrack' : {},
}
fullnameArgs = {
"AntiKt4LCTopoJetsTest" : dict( ptminFilter=7000, calibOpt='ar'),
"AntiKt4EMTopoJetsTest" : dict( ptminFilter=5000, calibOpt='ar'),
"AntiKt10LCTopoJetsTest": dict( ptminFilter=50000, calibOpt='a'),
"CamKt12LCTopoJetsTest" : dict( ptminFilter=50000, calibOpt='a'),
}
tools = []
for jname in containerToRebuild:
# decompose arg name
finder, mainParam, input = interpretJetName(jname)
args = fullnameArgs[jname]
args.update( inputArgs[input] )
# call addJetFinderArgs with the relavant args for this collection
t=jtm.addJetFinder(jname, finder, mainParam, ptmin=2000,
**args
)
tools.append( t )
from AthenaCommon.AlgSequence import AlgSequence
topSequence= AlgSequence()
if jetFlags.useTruth:
from JetRec.JetFlavorAlgs import scheduleCopyTruthParticles
tools = [ jtm.truthpartcopy, jtm.truthpartcopywz ] + scheduleCopyTruthParticles() + tools
topSequence += JetAlgorithm( "JetAlgorithmTest", Tools = [jtm.tracksel, jtm.tvassoc, ]+tools )
def saveJetContainers():
global containerToRebuild
from AthenaCommon.AppMgr import theApp
StreamAOD = theApp.getOutputStream( "StreamAOD" )
for jname in containerToRebuild:
StreamAOD.ItemList += ["xAOD::JetContainer_v1#"+jname, "xAOD::JetAuxContainer_v1#"+jname+"Aux."]
# if we need customized one-line call, let's define them here :
def scheduleRDOtoESD():
return scheduleRTTJetTests()
def scheduleESDtoAOD():
return scheduleRTTJetTests()
def scheduleTest():
return scheduleRTTJetTests(["AntiKt4LCTopoJetsTest"],[])
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment