JetJvtAnalysisSequence.py 4.28 KB
Newer Older
1
2
3
4
5
6
7
# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration

# AnaAlgorithm import(s):
from AnaAlgorithm.AnaAlgSequence import AnaAlgSequence
from AnaAlgorithm.DualUseConfig import createAlgorithm

def makeJetJvtAnalysisSequence( dataType, jetCollection,
8
9
                                preselection = '',
                                systematicsAwarePreselection = '',
10
                                enableFJvt = False,
11
12
13
14
15
16
17
18
                                globalSF = True,
                                runSelection = True,
                                enableCutflow = False ):
    """Create a jet JVT analysis algorithm sequence

    Keyword arguments:
      dataType -- The data type to run on ("data", "mc" or "afii")
      jetCollection -- The jet container to run on
19
      enableFJvt -- Whether to enable forward JVT calculations
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
      globalSF -- Whether to calculate per event scale factors
      runSelection -- Whether to run selection
      enableCutflow -- Whether or not to dump the cutflow
    """

    if dataType not in ["data", "mc", "afii"] :
        raise ValueError ("invalid data type: " + dataType)

    if runSelection and not globalSF :
        raise ValueError ("per-event scale factors needs to be computed when doing a JVT selection")

    # Create the analysis algorithm sequence object:
    seq = AnaAlgSequence( "JetJVTAnalysisSequence" )

    # Define a list of cuts to apply later on and the
    # number of bits in the corresponding TAccept
36
37
    seq.addMetaConfigDefault ("selectionDecorNames", [])
    seq.addMetaConfigDefault ("selectionDecorCount", [])
38
39
40
41

    # Set up the per-event jet efficiency scale factor calculation algorithm
    if dataType != 'data' and globalSF:
        alg = createAlgorithm( 'CP::AsgEventScaleFactorAlg', 'JvtEventScaleFactorAlg' )
42
43
        alg.preselection = preselection + '&&no_jvt' if preselection else 'no_jvt'
        alg.inputSelectionDecoration = systematicsAwarePreselection
44
45
46
47
48
        alg.scaleFactorInputDecoration = 'jvt_effSF_%SYS%'
        alg.scaleFactorOutputDecoration = 'jvt_effSF_%SYS%'

        seq.append( alg,
                    inputPropName = { 'jets' : 'particles',
49
50
                                      'eventInfo' : 'eventInfo' },
                    dynConfig = {'preselection' : lambda meta : "&&".join (meta["selectionDecorNames"])} )
51

52
        if enableFJvt:
53
            alg = createAlgorithm( 'CP::AsgEventScaleFactorAlg', 'ForwardJvtEventScaleFactorAlg' )
54
55
            alg.preselection = preselection + '&&no_fjvt' if preselection else 'no_fjvt'
            alg.inputSelectionDecoration = systematicsAwarePreselection
56
57
58
59
60
            alg.scaleFactorInputDecoration = 'fjvt_effSF_%SYS%'
            alg.scaleFactorOutputDecoration = 'fjvt_effSF_%SYS%'

            seq.append( alg,
                        inputPropName = { 'jets' : 'particles',
61
62
63
64
                                          'eventInfo' : 'eventInfo' },
                        metaConfig = {'selectionDecorNames' : ['fjvt_selection'] if runSelection else [],
                                      'selectionDecorCount' : [1] if runSelection else [] },
                        dynConfig = {'preselection' : lambda meta : "&&".join (meta["selectionDecorNames"] + ['no_fjvt'])} )
65
66

    if runSelection:
67
68
        seq.addMetaConfigDefault ("selectionDecorNames", ['jvt_selection'])
        seq.addMetaConfigDefault ("selectionDecorCount", [1])
69
70
71
72
73

        # Set up an algorithm used to create jet JVT selection cutflow:
        if enableCutflow:
            alg = createAlgorithm( 'CP::ObjectCutFlowHistAlg', 'JetJvtCutFlowDumperAlg' )
            alg.histPattern = 'jet_cflow_jvt_%SYS%'
74
75
76
            seq.append( alg, inputPropName = { 'jets' : 'input' },
                        dynConfig = {'selection' : lambda meta : meta["selectionDecorNames"][:],
                                     'selectionNCuts' : lambda meta : meta["selectionDecorCount"][:]})
77
78
79
80
81

        # Set up an algorithm that makes a view container using the selections
        # performed previously:
        alg = createAlgorithm( 'CP::AsgViewFromSelectionAlg', 'JetJvtViewFromSelectionAlg' )
        seq.append( alg, inputPropName = { 'jets' : 'input' },
82
83
                    outputPropName = { 'jets' : 'output' },
                    dynConfig = {'selection' : lambda meta : meta["selectionDecorNames"][:]} )
84
85
86

    # Return the sequence:
    return seq