コード例 #1
0
        def __init__(self, **kwargs):
            super(InDetPhysValMonitoringTool.InDetPhysValMonitoringTool,self)\
                          .__init__(**_args( kwargs,
                                             name = self.__class__.__name__))

            # special parameters of the default InDetPhysValMonitoringTool
            self.useTrackSelection = False
            self.EnableLumi = False

            # create the HistogramDefinitionSvc
            # at the moment there can only be one HistogramDefinitionSvc
            from InDetPhysValMonitoring.HistogramDefinitionSvc import HistogramDefinitionSvc
            #self.HistogramDefinitionSvc =
            serviceFactory(HistogramDefinitionSvc.HistogramDefinitionSvc)

            from InDetPhysValMonitoring.InDetPhysValJobProperties import isMC, InDetPhysValFlags
            if isMC():
                self.TruthParticleContainerName = "TruthParticles"
                if InDetPhysValFlags.doValidateTracksInJets():
                    self.jetContainerName = 'AntiKt4TruthJets'
                    self.FillTrackInJetPlots = True
                    from InDetPhysValMonitoring.addTruthJets import addTruthJetsIfNotExising
                    addTruthJetsIfNotExising(self.jetContainerName)
                else:
                    self.jetContainerName = ''
                    self.FillTrackInJetPlots = False

            else:
                # disable truth monitoring for data
                self.TruthParticleContainerName = ''
                # the jet container is actually meant to be a truth jet container
                self.jetContainerName = ''

            # hack to remove example phyval monitor
            from RecExConfig.AutoConfiguration import IsInInputFile
            if not IsInInputFile('xAOD::JetContainer', 'AntiKt4EMTopoJets'):
                from RecExConfig.RecFlags import rec
                rec.UserExecs += [
                    'from InDetPhysValMonitoring.InDetPhysValMonitoringTool import removePhysValExample;removePhysValExample();'
                ]
コード例 #2
0
def getInDetPhysValMonitoringTool(**kwargs):
    kwargs = setDefaults(kwargs, useTrackSelection=False, EnableLumi=False)

    # create the HistogramDefinitionSvc
    # at the moment there can only be one HistogramDefinitionSvc
    from InDetPhysValMonitoring.HistogramDefinitionSvc import getHistogramDefinitionSvc
    #self.HistogramDefinitionSvc =
    serviceFactory(getHistogramDefinitionSvc)

    from InDetPhysValMonitoring.InDetPhysValJobProperties import isMC, InDetPhysValFlags
    if isMC():
        from InDetPhysValMonitoring.InDetPhysValDecoration import getInDetRttTruthSelectionTool
        kwargs = setDefaults(kwargs,
                             TruthParticleContainerName="TruthParticles")
        if 'TruthSelectionTool' not in kwargs:
            kwargs = setDefaults(
                kwargs, TruthSelectionTool=getInDetRttTruthSelectionTool())
        if InDetPhysValFlags.doValidateTracksInJets():
            jets_name = 'AntiKt4LCTopoJets'
            kwargs = setDefaults(kwargs,
                                 JetContainerName=jets_name,
                                 FillTrackInJetPlots=True)
            from InDetPhysValMonitoring.addTruthJets import addTruthJetsIfNotExising
            addTruthJetsIfNotExising(jets_name)
            if InDetPhysValFlags.doValidateTracksInBJets():
                kwargs = setDefaults(kwargs, FillTrackInBJetPlots=True)

        else:
            kwargs = setDefaults(kwargs,
                                 JetContainerName='',
                                 FillTrackInJetPlots=False)

        #adding the VeretxTruthMatchingTool
        from InDetTruthVertexValidation.InDetTruthVertexValidationConf import InDetVertexTruthMatchTool
        kwargs = setDefaults(
            kwargs,
            useVertexTruthMatchTool=True,
            VertexTruthMatchTool=toolFactory(InDetVertexTruthMatchTool))

        #Options for Truth Strategy : Requires full pile-up truth containers for some
        if InDetPhysValFlags.setTruthStrategy(
        ) == 'All' or InDetPhysValFlags.setTruthStrategy() == 'PileUp':
            from RecExConfig.AutoConfiguration import IsInInputFile
            if IsInInputFile('xAOD::TruthPileupEventContainer',
                             'TruthPileupEvents'):
                kwargs = setDefaults(
                    kwargs, PileupSwitch=InDetPhysValFlags.setTruthStrategy())
            else:
                print(
                    'WARNING Truth Strategy for InDetPhysValMonitoring set to %s but TruthPileupEvents are missing in the input; resetting to HardScatter only'
                    % (InDetPhysValFlags.setTruthStrategy()))
        elif InDetPhysValFlags.setTruthStrategy() != 'HardScatter':
            print(
                'WARNING Truth Strategy for for InDetPhysValMonitoring set to invalid option %s; valid flags are ["HardScatter", "All", "PileUp"]'
                % (InDetPhysValFlags.setTruthStrategy()))

    else:
        # disable truth monitoring for data
        kwargs = setDefaults(
            kwargs,
            TruthParticleContainerName='',
            TruthVertexContainerName='',
            TruthEvents='',
            TruthPileupEvents='',
            TruthSelectionTool='',
            # the jet container is actually meant to be a truth jet container
            JetContainerName='',
            FillTrackInJetPlots=False,
            FillTrackInBJetPlots=False)

    # Control the number of output histograms
    if InDetPhysValFlags.doPhysValOutput():
        kwargs = setDefaults(kwargs, SkillLevel=100)

    elif InDetPhysValFlags.doExpertOutput():
        kwargs = setDefaults(kwargs, SkillLevel=200)

    # hack to remove example physval monitor
    from RecExConfig.AutoConfiguration import IsInInputFile
    if not IsInInputFile('xAOD::JetContainer', 'AntiKt4EMTopoJets'):
        add_remover = True
        from RecExConfig.RecFlags import rec
        try:
            for elm in rec.UserExecs:
                if elm.find('removePhysValExample') > 0:
                    add_remover = False
                    break
        except:
            pass
        if add_remover:
            rec.UserExecs += [
                'from InDetPhysValMonitoring.InDetPhysValMonitoringTool import removePhysValExample;removePhysValExample();'
            ]

    return InDetPhysValMonitoring.InDetPhysValMonitoringConf.InDetPhysValMonitoringTool(
        **kwargs)