TrigMultiTrkHypoConfig.py 4.43 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration

from TrigBphysHypo.TrigBphysHypoConf import TrigMultiTrkHypo, TrigMultiTrkHypoTool
from TrigBphysHypo.TrigMultiTrkHypoMonitoringConfig import TrigMultiTrkHypoMonitoring, TrigMultiTrkHypoToolMonitoring

from AthenaCommon.Logging import logging
log = logging.getLogger('TrigMultiTrkHypoConfig')


def TrigMultiTrkHypoToolFromDict(chainDict):
    config = TrigMultiTrkHypoConfig()
    tool = config.ConfigurationHypoTool(chainDict)
    return tool


class TrigMultiTrkHypoConfig(object):

    def ConfigurationHypo(self, trigSequenceName='Dimu', trigLevel='L2', trackCollection='', muonCollection=''):

        trigLevelDict = {'L2':0, 'EF':1}

        try:
            value = trigLevelDict[trigLevel]
24
            log.debug('TrigMultiTrkHypo.trigLevel = %s ', value)
25
        except KeyError:
26
            log.error('TrigMultiTrkHypo.trigLevel should be L2 or EF, but %s provided.', trigLevel)
27

28
        from TrkExTools.AtlasExtrapolator import AtlasExtrapolator
29
30
31
32
33
        from TrkVKalVrtFitter.TrkVKalVrtFitterConf import Trk__TrkVKalVrtFitter
        VertexFitter = Trk__TrkVKalVrtFitter(
            name = 'TrigBphysFitter_'+trigSequenceName+trigLevel,
            FirstMeasuredPoint = False,
            MakeExtendedVertex = False,
34
            Extrapolator = AtlasExtrapolator())
35
36
37
38
39
40
41
42
43
44
45

        from InDetConversionFinderTools.InDetConversionFinderToolsConf import InDet__VertexPointEstimator
        VertexPointEstimator = InDet__VertexPointEstimator(
            name = 'VertexPointEstimator_'+trigSequenceName+trigLevel,
            MinDeltaR = [-10000., -10000., -10000.],
            MaxDeltaR = [ 10000.,  10000.,  10000.],
            MaxPhi    = [ 10000.,  10000.,  10000.],
            MaxChi2OfVtxEstimation = 2000.)

        tool = TrigMultiTrkHypo(
            name = trigSequenceName+'HypoAlg'+trigLevel,
46
47
48
49
            trigLevel = trigLevel,
            nTracks = 2,
            massRanges = [ (100., 20000.) ],
            TrackCollectionKey = trackCollection,
50
            MuonCollectionKey = muonCollection,
51
            TrigBphysCollectionKey = ('TrigBphys' if trigLevel == 'L2' else 'TrigBphysEF') + trigSequenceName,
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
            VertexFitter = VertexFitter,
            VertexPointEstimator = VertexPointEstimator,
            MonTool = TrigMultiTrkHypoMonitoring('TrigMultiTrkHypoMonitoring_'+trigSequenceName+trigLevel))

        return tool

    def ConfigurationHypoTool(self, chainDict):

        topoAlgs = chainDict['chainName']
        log.debug("Set for algorithm %s", topoAlgs)

        tool = TrigMultiTrkHypoTool(topoAlgs)

        if 'nocut' in topoAlgs:
            tool.AcceptAll = True

        if 'noos' in topoAlgs:
69
            tool.TotChargeCut = -100 #Negative number to indicate no charge cut
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125

        tool.ApplyUpperMassCut = True
        tool.ApplyChi2Cut = True
        tool.Chi2VtxCut = 20
        tool.nBphysObjects = 1
        tool.trkPtThresholds = getBphysThresholds(chainDict)

        if 'bJpsimumu' in topoAlgs:
            tool.LowerMassCut =  2500 #MeV
            tool.UpperMassCut =  4300 #MeV

        elif 'bUpsimumu' in topoAlgs:
            tool.LowerMassCut =  8000 #MeV
            tool.UpperMassCut = 12000 #MeV

        elif 'bBmumu' in topoAlgs:
            tool.LowerMassCut =  4000 #MeV
            tool.UpperMassCut =  8500 #MeV
            tool.Chi2VtxCut = 60

        elif 'bDimu' in topoAlgs:
            tool.LowerMassCut =   100 #MeV
            tool.UpperMassCut = 14000 #MeV

        tool.MonTool = TrigMultiTrkHypoToolMonitoring('MonTool')
        return tool


def getBphysThresholds(chainDict):
    mult = 0
    trkmuons = []

    for part in chainDict['chainParts']:
        mult = mult + int(part['multiplicity'])

    for dictpart in chainDict['chainParts']:
        if 'mu' in dictpart['trigType']:
            for x in range(0,int(dictpart['multiplicity'])):
                if dictpart['threshold']!='0':
                    dthr = float(dictpart['threshold'] )
                    thr= dthr * 1000.  # in MeV;

                    #lower to match EF muon threshols
                    if dthr < 9.5 :
                        thr = thr - 350.
                    elif dthr < 11.5 :
                        thr = thr - 550.
                    elif dthr < 21.5  :
                        thr = thr - 750.
                    else :
                        thr = thr - 1000.

                else :
                    thr = 900.
                trkmuons.append(thr)
    return trkmuons