Commit caf47153 authored by Nils Krumnack's avatar Nils Krumnack
Browse files

update to use the algorithm meta-configuration for jet selection

Not sure I got it completely correct, there was some more extensive
logic in here, but at least the tests work out.
parent d11f12cf
......@@ -110,45 +110,45 @@ def makeJetAnalysisSequence( dataType, jetCollection, postfix = '',
seq.append( alg, inputPropName = 'jets', outputPropName = 'jetsOut', stageName = 'calibration' )
# record all the selections each subfunction makes
cutlist = []
cutlength = []
seq.addMetaConfigDefault ("selectionDecorNames", [])
seq.addMetaConfigDefault ("selectionDecorCount", [])
if radius == 4:
makeSmallRJetAnalysisSequence(seq, cutlist, cutlength,
makeSmallRJetAnalysisSequence(seq,
dataType, jetCollection, jetInput=jetInput, postfix=postfix, **kwargs)
elif radius in [2, 6]:
makeRScanJetAnalysisSequence(seq, cutlist, cutlength,
makeRScanJetAnalysisSequence(seq,
dataType, jetCollection, jetInput=jetInput, radius=radius,
postfix=postfix, **kwargs)
else:
trim = match.group(3)
if trim == "":
raise ValueError("Untrimmed large-R jets are not supported!")
makeLargeRJetAnalysisSequence(seq, cutlist, cutlength,
makeLargeRJetAnalysisSequence(seq,
dataType, jetCollection, jetInput=jetInput, postfix=postfix, **kwargs)
# Set up an algorithm used to create jet selection cutflow:
if enableCutflow:
alg = createAlgorithm( 'CP::ObjectCutFlowHistAlg', 'JetCutFlowDumperAlg'+postfix )
alg.histPattern = 'jet_cflow_%SYS%'+postfix
alg.selection = cutlist
alg.selectionNCuts = cutlength
seq.append( alg, inputPropName = 'input', stageName = 'selection' )
seq.append( alg, inputPropName = 'input', stageName = 'selection',
dynConfig = {'selection' : lambda meta : meta["selectionDecorNames"][:],
'selectionNCuts' : lambda meta : meta["selectionDecorCount"][:]} )
# Set up an algorithm dumping the kinematic properties of the jets:
if enableKinematicHistograms:
alg = createAlgorithm( 'CP::KinematicHistAlg', 'JetKinematicDumperAlg'+postfix )
alg.preselection = "&&".join (cutlist)
alg.histPattern = 'jet_%VAR%_%SYS%'+postfix
seq.append( alg, inputPropName = 'input', stageName = 'selection' )
seq.append( alg, inputPropName = 'input', stageName = 'selection',
dynConfig = {'preselection' : lambda meta : "&&".join (meta["selectionDecorNames"])} )
if shallowViewOutput:
# Set up an algorithm that makes a view container using the selections
# performed previously:
alg = createAlgorithm( 'CP::AsgViewFromSelectionAlg', 'JetViewFromSelectionAlg'+postfix )
alg.selection = cutlist
seq.append( alg, inputPropName = 'input', outputPropName = 'output',
stageName = 'selection' )
stageName = 'selection',
dynConfig = {'selection' : lambda meta : meta["selectionDecorNames"][:]} )
# Set up a final deep copy making algorithm if requested:
if deepCopyOutput:
......@@ -159,7 +159,7 @@ def makeJetAnalysisSequence( dataType, jetCollection, postfix = '',
return seq
def makeSmallRJetAnalysisSequence( seq, cutlist, cutlength, dataType, jetCollection,
def makeSmallRJetAnalysisSequence( seq, dataType, jetCollection,
jetInput, postfix = '',
runJvtUpdate = True, runFJvtUpdate = True,
runJvtSelection = True, runFJvtSelection = True,
......@@ -169,8 +169,6 @@ def makeSmallRJetAnalysisSequence( seq, cutlist, cutlength, dataType, jetCollect
Keyword arguments
seq -- The sequence to add the algorithms to
cutlist -- Insert any cuts into this
cutlength -- Insert the lengths of any cuts into this
dataType -- The data type to run on ("data", "mc" or "afii")
jetCollection -- The jet container to run on.
jetInput -- The type of input used, read from the collection name.
......@@ -302,16 +300,14 @@ def makeSmallRJetAnalysisSequence( seq, cutlist, cutlength, dataType, jetCollect
affectingSystematics = fjvtSysts, stageName = 'selection')
# Return the sequence:
return seq, cutlist, cutlength
return seq
def makeRScanJetAnalysisSequence( seq, cutlist, cutlength, dataType, jetCollection,
def makeRScanJetAnalysisSequence( seq, dataType, jetCollection,
jetInput, radius, postfix = '' ):
"""Add algorithms for the R-scan jets.
Keyword arguments
seq -- The sequence to add the algorithms to
cutlist -- Insert any cuts into this
cutlength -- Insert the lengths of any cuts into this
dataType -- The data type to run on ("data", "mc" or "afii")
jetCollection -- The jet container to run on.
jetInput -- The type of input used, read from the collection name.
......@@ -336,14 +332,12 @@ def makeRScanJetAnalysisSequence( seq, cutlist, cutlength, dataType, jetCollecti
# Logging would be good
print("WARNING: uncertainties for R-Scan jets are not yet released!")
def makeLargeRJetAnalysisSequence( seq, cutlist, cutlength, dataType, jetCollection,
def makeLargeRJetAnalysisSequence( seq, dataType, jetCollection,
jetInput, postfix = '', largeRMass = "Comb"):
"""Add algorithms for the R=1.0 jets.
Keyword arguments
seq -- The sequence to add the algorithms to
cutlist -- Insert any cuts into this
cutlength -- Insert the lengths of any cuts into this
dataType -- The data type to run on ("data", "mc" or "afii")
jetCollection -- The jet container to run on.
jetInput -- The type of input used, read from the collection name.
......@@ -393,7 +387,6 @@ def makeLargeRJetAnalysisSequence( seq, cutlist, cutlength, dataType, jetCollect
alg.uncertaintiesTool.MCType = "MC16a"
alg.uncertaintiesTool.IsData = (dataType == "data")
seq.append( alg, inputPropName = 'jets', outputPropName = 'jetsOut',
affectingSystematics = largeRSysts, stageName = 'calibration' )
cutlist.append('outOfValidity')
cutlength.append(1)
affectingSystematics = largeRSysts, stageName = 'calibration',
metaConfig = {'selectionDecorNames' : ['outOfValidity'],
'selectionDecorCount' : [1]} )
......@@ -5,7 +5,6 @@ from AnaAlgorithm.AnaAlgSequence import AnaAlgSequence
from AnaAlgorithm.DualUseConfig import createAlgorithm
def makeJetJvtAnalysisSequence( dataType, jetCollection,
preselection = '',
disableFJvt = False,
globalSF = True,
runSelection = True,
......@@ -32,15 +31,14 @@ def makeJetJvtAnalysisSequence( dataType, jetCollection,
# Define a list of cuts to apply later on and the
# number of bits in the corresponding TAccept
cutlist = []
cutlength = []
seq.addMetaConfigDefault ("selectionDecorNames", [])
seq.addMetaConfigDefault ("selectionDecorCount", [])
# Set up the per-event jet efficiency scale factor calculation algorithm
if dataType != 'data' and globalSF:
from JetAnalysisSequence import jvtSysts, fjvtSysts
alg = createAlgorithm( 'CP::AsgEventScaleFactorAlg', 'JvtEventScaleFactorAlg' )
alg.preselection = preselection + '&&no_jvt' if preselection else 'no_jvt'
alg.scaleFactorInputDecoration = 'jvt_effSF_%SYS%'
alg.scaleFactorInputDecorationRegex = jvtSysts
alg.scaleFactorOutputDecoration = 'jvt_effSF_%SYS%'
......@@ -48,11 +46,11 @@ def makeJetJvtAnalysisSequence( dataType, jetCollection,
seq.append( alg,
affectingSystematics = jvtSysts,
inputPropName = { 'jets' : 'particles',
'eventInfo' : 'eventInfo' } )
'eventInfo' : 'eventInfo' },
dynConfig = {'preselection' : lambda meta : "&&".join (meta["selectionDecorNames"])} )
if not disableFJvt:
alg = createAlgorithm( 'CP::AsgEventScaleFactorAlg', 'ForwardJvtEventScaleFactorAlg' )
alg.preselection = preselection + '&&no_fjvt' if preselection else 'no_fjvt'
alg.scaleFactorInputDecoration = 'fjvt_effSF_%SYS%'
alg.scaleFactorInputDecorationRegex = fjvtSysts
alg.scaleFactorOutputDecoration = 'fjvt_effSF_%SYS%'
......@@ -60,30 +58,29 @@ def makeJetJvtAnalysisSequence( dataType, jetCollection,
seq.append( alg,
affectingSystematics = fjvtSysts,
inputPropName = { 'jets' : 'particles',
'eventInfo' : 'eventInfo' } )
'eventInfo' : 'eventInfo' },
metaConfig = {'selectionDecorNames' : ['fjvt_selection'] if runSelection else [],
'selectionDecorCount' : [1] if runSelection else [] },
dynConfig = {'preselection' : lambda meta : "&&".join (meta["selectionDecorNames"] + ['no_fjvt'])} )
if runSelection:
cutlist.append('jvt_selection')
cutlength.append(1)
if not disableFJvt:
cutlist.append('fjvt_selection')
cutlength.append(1)
seq.addMetaConfigDefault ("selectionDecorNames", ['jvt_selection'])
seq.addMetaConfigDefault ("selectionDecorCount", [1])
# Set up an algorithm used to create jet JVT selection cutflow:
if enableCutflow:
alg = createAlgorithm( 'CP::ObjectCutFlowHistAlg', 'JetJvtCutFlowDumperAlg' )
alg.histPattern = 'jet_cflow_jvt_%SYS%'
alg.selection = cutlist
alg.selectionNCuts = cutlength
seq.append( alg, inputPropName = { 'jets' : 'input' })
seq.append( alg, inputPropName = { 'jets' : 'input' },
dynConfig = {'selection' : lambda meta : meta["selectionDecorNames"][:],
'selectionNCuts' : lambda meta : meta["selectionDecorCount"][:]})
# Set up an algorithm that makes a view container using the selections
# performed previously:
alg = createAlgorithm( 'CP::AsgViewFromSelectionAlg', 'JetJvtViewFromSelectionAlg' )
alg.selection = cutlist
seq.append( alg, inputPropName = { 'jets' : 'input' },
outputPropName = { 'jets' : 'output' } )
outputPropName = { 'jets' : 'output' },
dynConfig = {'selection' : lambda meta : meta["selectionDecorNames"][:]} )
# Return the sequence:
return seq
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment