def checkMomentAvailability(jetcollname, momentList, jetAlgConfigDict={}):
    """ Input :  a jet collection name (jetcollname), list of moment keys (momentList), a jet alg configuration dict (as in JetRec.JetAlgConfiguration)
    returns a filtered list of moment keys where moments incompatible with the jet collection or the job conditions are removed.
    """
    # we'll need to know what the input file is
    from JetRec.JetGetters import guessInputFileType
    inputFileType = guessInputFileType()



    from AthenaCommon.DetFlags import DetFlags
    from AthenaCommon.AppMgr import ToolSvc
    from AthenaCommon.GlobalFlags  import globalflags
    from JetRec.TrackSelectionForJets import tracksAvailableForJets

    TestWithMsg.jetcollname = jetcollname
    # short cut flags
    # use TestWithMsg rather than simply bool only to be able to display a reason for the rejection of the moment.
    accessCells = TestWithMsg( (inputFileType=="RDO") or (inputFileType=="ESD") , "No CaloCell available") 
    caloJet     = TestWithMsg( ("Topo" in jetcollname) or ("Tower" in jetcollname), "Not calo jets")
    topoJet     = TestWithMsg( "Topo" in jetcollname, "Not TopoCluster jets")
    lctopoJet   = TestWithMsg( "LCTopo" in jetcollname, "Not LC TopoCluster jets")
    notTruthJet = TestWithMsg( 'Truth' not in jetcollname, "Is Truth jets")
    tracksAvailable = TestWithMsg( tracksAvailableForJets(), "Tracks selection for jets impossible")

    trueTest = TestWithMsg(True,"")

    # build the conditions at which moments can be built
    compatibilityDict = {
        'area'        : TestWithMsg('Cone' not in jetcollname, "no area for cone jets"),
        'ghostAssoc'  : notTruthJet,
        'width' : trueTest,
        'numTowerJet' : topoJet & accessCells,
        'quality'     : caloJet,
        'badChanCorr' : caloJet & accessCells,
        'constitCalib': lctopoJet &  TestWithMsg( not jetAlgConfigDict.get('calibName','').startswith("LC:CONST") , "Calibration differ from LC:CONST") ,
        'jvf'         : caloJet & tracksAvailable,
        'larHV'       : caloJet & TestWithMsg( (inputFileType=='RDO') and DetFlags.dcs.LAr_on() and globalflags.DataSource()=='data', "No proper LAr info available"),
        'eInSampling' : (caloJet & accessCells) | (topoJet), 
        'truthMF'     : TestWithMsg( rec.doTruth() , "Truth not available") & notTruthJet,
        'trackMF'     : notTruthJet & tracksAvailable,
        'trackMoments': notTruthJet & tracksAvailable,
        
        }

    # filter moments :
    availableMoments = set([ m for m in momentList if compatibilityDict.get(m, trueTest).check(m) ])
    return availableMoments
Beispiel #2
0
def retrieveAODList():
    from JetRec.JetRecFlags import jetFlags
    from RecExConfig.RecFlags import rec

    if rec.doESD():
        return jetFlags.jetAODList()
    # then we are merging or doing a AOD ?
    # We can not simply copy what we have from input since some
    # jobs starts from empty files. See ATEAM-191.
    # We hard code the list here while waiting for a more robust solution
    l = [
        # event shape objects
        'xAOD::EventShape#Kt4EMPFlowEventShape',                    'xAOD::EventShapeAuxInfo#Kt4EMPFlowEventShapeAux.',
        'xAOD::EventShape#Kt4EMTopoEventShape',                     'xAOD::EventShapeAuxInfo#Kt4EMTopoEventShapeAux.',
        'xAOD::EventShape#Kt4LCTopoEventShape',                     'xAOD::EventShapeAuxInfo#Kt4LCTopoEventShapeAux.',
        'xAOD::EventShape#NeutralParticleFlowIsoCentralEventShape', 'xAOD::EventShapeAuxInfo#NeutralParticleFlowIsoCentralEventShapeAux.',
        'xAOD::EventShape#NeutralParticleFlowIsoForwardEventShape', 'xAOD::EventShapeAuxInfo#NeutralParticleFlowIsoForwardEventShapeAux.',
        'xAOD::EventShape#ParticleFlowIsoCentralEventShape',        'xAOD::EventShapeAuxInfo#ParticleFlowIsoCentralEventShapeAux.',
        'xAOD::EventShape#ParticleFlowIsoForwardEventShape',        'xAOD::EventShapeAuxInfo#ParticleFlowIsoForwardEventShapeAux.',
        'xAOD::EventShape#TopoClusterIsoCentralEventShape',         'xAOD::EventShapeAuxInfo#TopoClusterIsoCentralEventShapeAux.',
        'xAOD::EventShape#TopoClusterIsoForwardEventShape',         'xAOD::EventShapeAuxInfo#TopoClusterIsoForwardEventShapeAux.',

        'xAOD::JetContainer#AntiKt10LCTopoJets',                    'xAOD::JetAuxContainer#AntiKt10LCTopoJetsAux.',
        'xAOD::JetContainer#AntiKt2PV0TrackJets',                   'xAOD::JetAuxContainer#AntiKt2PV0TrackJetsAux.', 
        'xAOD::JetContainer#AntiKt3PV0TrackJets',                   'xAOD::JetAuxContainer#AntiKt3PV0TrackJetsAux.', 
        'xAOD::JetContainer#AntiKt4EMPFlowJets',                    'xAOD::JetAuxContainer#AntiKt4EMPFlowJetsAux.',
        'xAOD::JetContainer#AntiKt4EMTopoJets',                     'xAOD::JetAuxContainer#AntiKt4EMTopoJetsAux.',
        'xAOD::JetContainer#AntiKt4LCTopoJets',                     'xAOD::JetAuxContainer#AntiKt4LCTopoJetsAux.',
        'xAOD::JetContainer#AntiKt4PV0TrackJets',                   'xAOD::JetAuxContainer#AntiKt4PV0TrackJetsAux.', 
        'xAOD::JetContainer#CamKt12LCTopoJets',                     'xAOD::JetAuxContainer#CamKt12LCTopoJetsAux.',

        'xAOD::CaloClusterContainer#EMOriginTopoClusters',          'xAOD::ShallowAuxContainer#EMOriginTopoClustersAux.',
        'xAOD::CaloClusterContainer#LCOriginTopoClusters' ,         'xAOD::ShallowAuxContainer#LCOriginTopoClustersAux.',
        ]

    if rec.doTruth():
        l += [
            'xAOD::JetContainer#AntiKt10TruthJets',                 'xAOD::JetAuxContainer#AntiKt10TruthJetsAux.',
            'xAOD::JetContainer#AntiKt10TruthWZJets',               'xAOD::JetAuxContainer#AntiKt10TruthWZJetsAux.',
            'xAOD::JetContainer#AntiKt4TruthJets',                  'xAOD::JetAuxContainer#AntiKt4TruthJetsAux.',
            'xAOD::JetContainer#AntiKt4TruthWZJets',                'xAOD::JetAuxContainer#AntiKt4TruthWZJetsAux.',
            'xAOD::JetContainer#CamKt12TruthJets',                  'xAOD::JetAuxContainer#CamKt12TruthJetsAux.',
            'xAOD::JetContainer#CamKt12TruthWZJets',                'xAOD::JetAuxContainer#CamKt12TruthWZJetsAux.',
            ]

    return l 
Beispiel #3
0
from JetRec.JetRecFlags import jetFlags

# Function to display flag value and status.
def sflagstat(flag):
  return str(flag()) + " (status=" + str(flag.statusOn) + ")"

# Import the jet reconstruction control flags.
from JetRec.JetRecFlags import jetFlags
from RecExConfig.ObjKeyStore import cfgKeyStore
from AthenaCommon import Logging
jetlog = Logging.logging.getLogger('JetRec_jobOptions')

# Skip truth if rec says it is absent.
# No action if someone has already set the flag.
print myname + "Initial useTruth: " + sflagstat(jetFlags.useTruth)
print myname + "     rec.doTruth: " + str(rec.doTruth())
if not jetFlags.useTruth.statusOn:
  jetFlags.useTruth = rec.doTruth()
print myname + "  Final useTruth: " + sflagstat(jetFlags.useTruth)

# Skip use of topoclusters if not built
# No action if someone has already set the flag.
print myname + "Initial use topoclusters: " + str(jetFlags.useTopo())
if not jetFlags.useTopo.statusOn:
  jetFlags.useTopo = rec.doCalo()
print myname + "  Final use topoclusters: " + str(jetFlags.useTopo())

# Skip tracks if tracks or vertices are not present in the job.
# No action if someone has already set the flag.
haveTracks = cfgKeyStore.isInTransient('xAOD::TrackParticleContainer','InDetTrackParticles')
haveVertices = cfgKeyStore.isInTransient("xAOD::VertexContainer","PrimaryVertices")
Beispiel #4
0
def JetD3PD(file,
            level=4,
            tuplename='jet',
            seq=topSequence,
            D3PDSvc='D3PD::RootD3PDSvc'):

    egammaUserDataConfig(seq)
    if rec.doTruth():
        truthParticleConfig(seq)

    JetIncludes = ['AssocTrackCont']

    alg = D3PDMakerCoreComps.MakerAlg(tuplename,
                                      seq,
                                      file=file,
                                      D3PDSvc=D3PDSvc)
    #-- General
    alg += EventInfoD3PDObject(level)
    alg += ElectronD3PDObject(0)
    alg += PhotonD3PDObject(0)
    alg += MuonD3PDObject(0)
    alg += PrimaryxAODVertexD3PDObject(4,
                                       allowMissing=True,
                                       sgkey=D3PDMakerFlags.VertexSGKey(),
                                       prefix='vxp_')
    #-- JET
    alg += JetD3PDObject(level,
                         sgkey='AntiKt4H1TopoJets',
                         include=JetIncludes,
                         prefix='AntiKt4H1Topo_')
    alg += JetD3PDObject(level,
                         sgkey='AntiKt6H1TopoJets',
                         include=JetIncludes,
                         prefix='AntiKt6H1Topo_')

    #alg += JetD3PDObject (level, sgkey='Cone4H1TopoJets',    include = JetIncludes, prefix='Cone4H1Topo_'   )

    #-- MET
    alg += RefFinalMETD3PDObject(level)
    alg += MuonMETD3PDObject(level)
    alg += MuonBoyMETD3PDObject(level)
    alg += FinalMETD3PDObject(level)
    alg += CryoMETD3PDObject(level)
    alg += CryoConeMETD3PDObject(level)
    alg += RefEleMETD3PDObject(level)
    alg += RefJetMETD3PDObject(level)
    alg += RefGammaMETD3PDObject(level)
    alg += RefTauMETD3PDObject(level)
    alg += CellOutMETD3PDObject(level)
    alg += BaseMETD3PDObject(level)
    alg += Base0METD3PDObject(level)
    alg += CalibMETD3PDObject(level)
    alg += MuonBoySpectroMETD3PDObject(level)
    alg += MuonBoyTrackMETD3PDObject(level)
    alg += TopoMETD3PDObject(level)
    alg += CorrTopoMETD3PDObject(level)
    alg += LocHadTopoMETD3PDObject(level)
    alg += TopoObjMETD3PDObject(level)

    #-- Trigger
    if D3PDMakerFlags.DoTrigger():
        alg += jetMETTriggerBitsD3PDObject(level)

    #-- Truth
    if rec.doTruth():
        alg += GenEventD3PDObject(1)
        #alg += TruthParticleD3PDObject (level)
        #alg += JetD3PDObject (level, sgkey='Cone4TruthJets'  , prefix='Cone4Truth_'    )
        alg += JetD3PDObject(3,
                             sgkey='AntiKt4TruthJets',
                             prefix='AntiKt4Truth_')
        #alg += JetD3PDObject (3, sgkey='AntiKt6TruthJets', prefix='AntiKt6Truth_'  )

    #-- Meta Data
    alg.MetadataTools += [LBMetadataConfig()]
    return alg
Beispiel #5
0
def MuonLayerHoughTool(name='MuonLayerHoughTool', extraFlags=None, **kwargs):
    if TriggerFlags.MuonSlice.doTrigMuonConfig:
        kwargs.setdefault("DoTruth", False)
    else:
        kwargs.setdefault("DoTruth", rec.doTruth())
    return CfgMgr.Muon__MuonLayerHoughTool(name, **kwargs)
Beispiel #6
0
def egammaD3PD(alg=None,
               trigalg=None,
               level=10,
               file='egamma.root',
               tuplename='egamma',
               **kw):

    preseq = AlgSequence(D3PDMakerFlags.PreD3PDAlgSeqName())
    createxAOD(preseq)

    if not cfgKeyStore.isInInput('xAOD::ElectronContainer', 'AllElectrons'):
        preseq += MergeElectrons()

    # Core algorithm
    # By default the user of this function should have created an algorithm already.
    # But for backwards compatibility let the function create its own algorithm if
    # needed...
    if not alg:
        from OutputStreamAthenaPool.MultipleStreamManager import MSMgr
        alg = MSMgr.NewRootStream(tuplename, file)

    alg += EventInfoD3PDObject(**_args(level, 'EventInfo', kw))

    # Segregate trigger decision flags in a separate tree.
    if not trigalg:
        from OutputStreamAthenaPool.MultipleStreamManager import MSMgr
        trigalg = MSMgr.NewRootStream(tuplename + ':' + tuplename + 'TrigDec',
                                      FileName=file,
                                      TreeName=tuplename + 'TrigDec')

    trigalg += EventInfoD3PDObject(0)
    alg.Stream.trigDecisionTree = trigalg

    # Add bunch structure metadata.
    from TriggerD3PDMaker.BunchStructureMetadata \
         import addBunchStructureMetadata
    addBunchStructureMetadata(alg)

    alg += LArCollisionTimeD3PDObject(**_args(level, 'LArCollisionTime', kw))
    alg += ElectronD3PDObject(**_args(
        level, 'Electron', kw, EgammaJetSignedIPAndPTRel_target='jet_'))
    alg += PhotonD3PDObject(**_args(level, 'Photon', kw))

    # # Additional muon variables for Zg skims.
    # if not MuonD3PDObject.allBlocknames().has_key("MuonScatteringAngleSignificance"):
    #     from AthenaCommon.AppMgr import ToolSvc
    #     muonScatteringSigTool=None
    #     if hasattr(ToolSvc, "MuonScatteringSigTool"):
    #         muonScatteringSigTool=ToolSvc.MuonScatteringSigTool
    #     from JetTagD3PDMaker import MuonScatteringAngleSignificanceFillerTool
    #     MuonD3PDObject.defineBlock (100, "MuonScatteringAngleSignificance",
    #                                 MuonScatteringAngleSignificanceFillerTool,
    #                                 ScatteringSigTool=muonScatteringSigTool)
    alg += MuonD3PDObject(**_args(
        10,
        'Muons',
        kw,
        sgkey='StacoMuonCollection,Muons',
        prefix='mu_',
        include=[
            "EFCBInfoIndex", "EFMGInfoIndex", "EFMEInfoIndex", "L2CBInfoIndex",
            "L1InfoIndex", "MuonScatteringAngleSignificance"
        ],
        exclude=["EFCBInfo", "EFMGInfo", "EFMEInfo", "L2CBInfo", "L1Info"],
        allowMissing=True))

    alg += JetD3PDObject(
        **_args(0, 'Jet', kw, include=['JetQual', 'DQMoments']))
    alg += MBTSD3PDObject(**_args(level, 'MBTS', kw))
    alg += MBTSTimeD3PDObject(**_args(level, 'MBTSTime', kw))
    # alg += MBTSTriggerBitsD3PDObject  (**_args (level, 'MBTSTriggerBits', kw))
    # alg += ZDCTriggerBitsD3PDObject   (**_args (level, 'ZDCTriggerBits', kw))
    alg += CollisionDecisionD3PDObject(**_args(level, 'CollisionDecision', kw))
    alg += MissingETD3PDObject(**_args(level,
                                       'MissingET',
                                       kw,
                                       sgkey='MET_Core_AntiKt4EMTopo',
                                       prefix='MET_RefFinal_'))
    if D3PDMakerFlags.DoTrigger():
        from TriggerD3PDMaker.TrigDecisionD3PDObject \
             import TrigDecisionD3PDObject
        alg += TrigDecisionD3PDObject(**_args(2, 'TrigDecision', kw))
        #TrigEgammaD3PDObjects (alg, **_args (1, 'TrigEgamma', kw,
        #                                     TrigEMCluster_level = 2))

    #     from TriggerD3PDMaker.EnergySumROID3PDObject import EnergySumROID3PDObject
    #     from TrigMissingETD3PDMaker.TrigMETD3PDObject import TrigMETD3PDObject

    #     alg += EnergySumROID3PDObject(**_args (level, 'EnergySumROI', kw,
    #                                            prefix = "trig_L1_esum_",
    #                                            allowMissing = True))

    #     # The LVL2 information:
    #     alg += TrigMETD3PDObject(**_args( level, 'TrigMETL2', kw,
    #                                       prefix = "trig_L2_met_",
    #                                       sgkey = "HLT_T2MissingET" ))
    #     if cfgKeyStore.isInInputFile( "TrigMissingETContainer", "HLT_L2MissingET_FEB" ):
    #         alg += TrigMETD3PDObject(**_args( level, 'TrigMETL2_FEB', kw,
    #                                           prefix = "trig_L2_feb_met_",
    #                                           sgkey = "HLT_L2MissingET_FEB" ))

    #     # The EF information:
    #     alg += TrigMETD3PDObject(**_args ( level, 'TrigMETEF', kw,
    #                                        prefix = "trig_EF_met_",
    #                                        sgkey = "HLT_TrigEFMissingET" ))

    #     from TriggerD3PDMaker.BGCodeD3PDObject import BGCodeD3PDObject
    #     alg += BGCodeD3PDObject (**_args (2, 'BGCode', kw))

    # May be missing in single-beam data.
    alg += PrimaryxAODVertexD3PDObject(**_args(
        1,
        'PrimaryVertex',
        kw,
        #allowMissing = True,
        sgkey=D3PDMakerFlags.VertexSGKey(),
        prefix='vxp_',
        storeVertexTrackIndexAssociation=False,
        storeVertexTrackAssociation=True,
        storeDiagonalCovarianceAsErrors=True))

    if rec.doTruth():
        from MuonD3PDMaker.TruthMuonD3PDObject import TruthMuonD3PDObject
        alg += TruthMuonD3PDObject(**_args(level, 'TruthMuon', kw))
        alg += TruthEventD3PDObject(**_args(1, 'TruthEvent', kw))
        alg += TruthParticleD3PDObject(**_args(level, 'TruthParticle', kw))

    # alg.MetadataTools += [LBMetadataConfig()]

    # if D3PDMakerFlags.FilterCollCand():
    #     from CaloD3PDMaker.CollisionFilterAlg import CollisionFilterAlg
    #     alg.filterSeq += CollisionFilterAlg (tuplename + '_CollCandFilter')

    return alg
Beispiel #7
0
# FIXME functionality is needed !!!
##    try:
##       if rec.doLowPt:
##          include ("InDetRecExample/ConfiguredInDetCutValues.py")
##          InDetCutValues=ConfiguredInDetCutValues(minPT=0.1*GeV)

##       include ( "InDetRecExample/ConfiguredInDetFlags.py" )
##    except Exception:
##       logRecExCommon_flags.warning("ConfiguredInDetFlags unavailable. ")
##       doNotLoadInDetFlags=True

#if not doNotLoadInDetFlags:

try:
    from InDetRecExample.InDetJobProperties import InDetFlags
    if not rec.doTruth():
        InDetFlags.doTruth = False
except Exception:
    treatException("Could not instantiate InDetFlags=>switch off ID ")
    DetFlags.ID_setOff()

##    if rec.doAODall() and oneTrackingAlg :
##       if recAlgs.donewTracking() + recAlgs.doiPatRec() +recAlgs.doxKalman() <= 1 :
##          logRecExCommon_flags.warning('doAODall=True :  more than one tracking alg should be enabled ! So switching doAODall=False')
##          rec.doAODall=False
##       else:
##          InDetFlags.setAODall()

if not rec.doTruth() or (globalflags.DetDescrVersion()[0:3] == "DC1"
                         or globalflags.DetDescrVersion()[0:3] == "DC2"):
    logRecExCommon_flags.info("TrackRecordFilter alg switched off ")
Beispiel #8
0
def SMTrilepD3PD(
        alg=None,
        #fileName              = 'smtrilep.root',
        tuplename='physics',
        #streamname           = 'NTUP_SMTRILEP',
        stdElectronContainer='None',
        gsfElectronContainer='None',
        stacoMuonContainer='None',
        muidMuonContainer='None',
        caloMuonContainer='None',
        thirdMuonContainer='None',
        photonContainer='None',
        jetContainer='None',
        jetLC4Container='None',
        clusterContainer='None',
        tauContainer='None',
        trackContainer='None',
        addHadronicRecoil=False,
        **kw):

    preseq = AlgSequence(D3PDMakerFlags.PreD3PDAlgSeqName())

    # perform recoil calculation
    if addHadronicRecoil:
        import HadronicRecoil.Configurables as hrc
        preseq = hrc.add_hadronic_recoil_filters(preseq)

    # configure the D3PD
    if not alg:
        from AthenaCommon.JobProperties import jobproperties
        prodFlags = jobproperties.D3PDProdFlags
        from PrimaryDPDMaker.PrimaryDPDHelpers import buildFileName
        fileName = buildFileName(prodFlags.WriteSMTRILEPD3PD)
        streamName = prodFlags.WriteSMTRILEPD3PD.StreamName

        alg = MSMgr.NewRootStream(StreamName=streamname,
                                  FileName=fileName,
                                  TreeName=tuplename)

    alg += EventInfoD3PDObject(**_args(10, 'EventInfo', kw))
    alg += LArCollisionTimeD3PDObject(**_args(10, 'LArCollisionTime', kw))

    from TriggerD3PDMaker.BunchStructureMetadata import addBunchStructureMetadata
    addBunchStructureMetadata(alg)

    # Electron/Photon blocks
    electron_excludes = [
        #'EMTrackFit',
        #'EMTrackFitDetailsBrem',
        #'EMTrackFitDetailsRefit',
        'EMTrackFitDetailsRefitCov',
        #'TopoClusterIsolationCones',
        'UDTopoCones',
        'Rings',
        'TrackIsoIP',
        'ElecDiscrim',
        'TraversedMaterial',
        'TrkCovDiag',
        'TrkCovOffDiag',
        'TrackSummaryPID',
        'UnrefitTrk',
        'ElectronPointingVariables',
        'MVAIso',
        'IsIso',
        'ElectronClusterQuantities'
    ]

    if stdElectronContainer != 'None':
        alg += ElectronD3PDObject(**_args(10,
                                          'Electron',
                                          kw,
                                          sgkey=stdElectronContainer,
                                          prefix='el_',
                                          exclude=electron_excludes,
                                          allowMissing=True))

    if (gsfElectronContainer != 'None') and testSGKey('ElectronContainer',
                                                      gsfElectronContainer):
        alg += GSFElectronD3PDObject(**_args(1,
                                             'GSFElectron',
                                             kw,
                                             sgkey=gsfElectronContainer,
                                             prefix='el_gsf_',
                                             exclude=electron_excludes,
                                             allowMissing=True))

    D3PDMakerFlags.DoPAU = False
    if photonContainer != 'None':
        alg += PhotonD3PDObject(**_args(0,
                                        'Photon',
                                        kw,
                                        sgkey=photonContainer,
                                        prefix='ph_',
                                        exclude=['OQRecalc'],
                                        allowMissing=True))

    # Muon blocks

    # ... add the scattering significance filler - to be removed when added in the MuonD3PDMaker
    if not MuonD3PDObject.allBlocknames().has_key(
            "MuonScatteringAngleSignificance"):
        from AthenaCommon.AppMgr import ToolSvc
        muonScatteringSigTool = None
        if hasattr(ToolSvc, "MuonScatteringSigTool"):
            muonScatteringSigTool = ToolSvc.MuonScatteringSigTool
        from JetTagD3PDMaker import MuonScatteringAngleSignificanceFillerTool
        MuonD3PDObject.defineBlock(100,
                                   "MuonScatteringAngleSignificance",
                                   MuonScatteringAngleSignificanceFillerTool,
                                   ScatteringSigTool=muonScatteringSigTool)

    std_muon_excludes = [
        'EFCBInfo', 'EFMGInfo', 'EFMEInfo', 'L2CBInfo', 'L1Info',
        'MuonTimingFillerTool', 'Likelihood', 'MuonTimingFillerTool',
        'PrimaryTrackDiagonalCovarianceAtPV',
        'PrimaryTrackOffDiagonalCovarianceAtPV',
        'IDTrackDiagonalCovarianceAtPV', 'IDTrackOffDiagonalCovarianceAtPV',
        'METrackDiagonalCovarianceAtPV', 'METrackOffDiagonalCovarianceAtPV',
        'TrkCovDiag', 'TrkCovOffDiag'
    ]
    calo_muon_excludes = [
        'EFCBInfo', 'EFMGInfo', 'EFMEInfo', 'L2CBInfo', 'L1Info',
        'MuonTimingFillerTool', 'Likelihood', 'MuonTimingFillerTool',
        'PrimaryTrackDiagonalCovarianceAtPV',
        'PrimaryTrackOffDiagonalCovarianceAtPV',
        'IDTrackDiagonalCovarianceAtPV', 'IDTrackOffDiagonalCovarianceAtPV',
        'METrackDiagonalCovarianceAtPV', 'METrackOffDiagonalCovarianceAtPV',
        'TrkCovDiag', 'TrkCovOffDiag', 'MGTrackDetails', 'MuGirlTrackBasics',
        'CBTrackDetails', 'CombinedTrackBasics', 'MuonSpectrometerHitSummary'
    ]

    if stacoMuonContainer != 'None':
        alg += MuonD3PDObject(**_args(
            10,
            'StacoMuon',
            kw,
            sgkey=stacoMuonContainer,
            prefix='mu_staco_',
            #include = ['EFCBInfoIndex', 'EFMGInfoIndex', 'EFMEInfoIndex',
            #'MuonScatteringAngleSignificance'],
            exclude=std_muon_excludes,
            allowMissing=True))

    if muidMuonContainer != 'None':
        alg += MuonD3PDObject(**_args(10,
                                      'MuidMuon',
                                      kw,
                                      sgkey=muidMuonContainer,
                                      prefix='mu_muid_',
                                      exclude=std_muon_excludes,
                                      allowMissing=True))

    if thirdMuonContainer != 'None':
        alg += MuonD3PDObject(**_args(10,
                                      'ThirdMuon',
                                      kw,
                                      sgkey=thirdMuonContainer,
                                      prefix='mu_',
                                      exclude=std_muon_excludes,
                                      allowMissing=True))

    if caloMuonContainer != 'None':
        alg += MuonD3PDObject(**_args(10,
                                      'CaloMuon',
                                      kw,
                                      sgkey=caloMuonContainer,
                                      prefix='mu_calo_',
                                      exclude=calo_muon_excludes,
                                      allowMissing=True))

    # Jet block

    from JetTagD3PDMaker.JetTagD3PDMakerFlags import JetTagD3PDFlags
    from JetTagD3PDMaker.JetTagD3PDMakerKeys import JetTagD3PDKeys

    if jetContainer != 'None':
        alg += JetD3PDObject(**_args(3,
                                     'AK4TopoEMJet',
                                     kw,
                                     sgkey=jetContainer,
                                     allowMissing=True,
                                     prefix='jet_AntiKt4TopoEM_',
                                     JetVertexFraction_FromUD=True,
                                     JetVertexFraction_FillFullJVF=True,
                                     include=[
                                         JetTagD3PDKeys.BTagWeightsBlockName(),
                                         JetTagD3PDKeys.TruthInfoBlockName()
                                     ]))

    if jetLC4Container != 'None':
        alg += JetD3PDObject(**_args(3,
                                     'AK4LCJet',
                                     kw,
                                     sgkey=jetContainer,
                                     allowMissing=True,
                                     prefix='jet_AntiKt4LCTopo_',
                                     JetVertexFraction_FromUD=True,
                                     JetVertexFraction_FillFullJVF=True,
                                     include=[
                                         JetTagD3PDKeys.BTagWeightsBlockName(),
                                         JetTagD3PDKeys.TruthInfoBlockName()
                                     ]))

    # Tau block

    if tauContainer != 'None':
        alg += TauD3PDObject(
            **_args(0, 'Tau', kw, allowMissing=True, sgkey=tauContainer))

    # HF overlap removal (ALPGEN)

    from TopInputsD3PDMaker.HforD3PDObject import HforD3PDObject
    alg += HforD3PDObject(**_args(0, 'HforInfo', kw))

    # MET blocks
    # a whole mess to remove x,y components separately for all flavours

    alg += MissingETD3PDObject(**_args(
        10,
        'MissingET',
        kw,
        exclude=[
            'MET_Base', 'MET_Base0', 'MET_Truth', 'MET_RefFinal_Comps',
            'MET_RefFinal_Regions', 'MET_LocHadTopo_Comps',
            'MET_LocHadTopo_Regions', 'MET_CellOut_Comps',
            'MET_CellOut_Regions', 'MET_Calib', 'MET_CorrTopo', 'MET_Cryo',
            'MET_CryoCone', 'MET_Final', 'MET_LocHadTopoObj', 'MET_Muid',
            'MET_Muid_Spectro', 'MET_Muid_Track', 'MET_MuonBoy',
            'MET_MuonBoy_Spectro', 'MET_MuonBoy_Track', 'MET_MuonMuid',
            'MET_Muon', 'MET_Muon_Isol_Muid', 'MET_Muon_Isol_Staco',
            'MET_Muon_NonIsol_Muid', 'MET_Muon_NonIsol_Staco',
            'MET_Muon_Total_Muid', 'MET_Muon_Total_Staco', 'MET_RefEle_Comps',
            'MET_RefEle_Regions', 'MET_RefEle_em_Comps',
            'MET_RefEle_em_Regions', 'MET_RefGamma_Comps',
            'MET_RefGamma_Regions', 'MET_RefGamma_em_Comps',
            'MET_RefGamma_em_Regions', 'MET_RefJet_Comps',
            'MET_RefJet_Regions', 'MET_RefJet_em_Comps',
            'MET_RefJet_em_Regions', 'MET_RefMuon_Comps',
            'MET_RefMuon_Regions', 'MET_RefMuon_Muid_Comps',
            'MET_RefMuon_Muid_Regions', 'MET_RefMuon_Staco_Comps',
            'MET_RefMuon_Staco_Regions', 'MET_RefMuon_Track_Muid_Comps',
            'MET_RefMuon_Track_Muid_Regions', 'MET_RefMuon_Track_Staco_Comps',
            'MET_RefMuon_Track_Staco_Regions', 'MET_RefMuon_Track_em_Comps',
            'MET_RefMuon_Track_em_Regions', 'MET_RefMuon_Track_Comps',
            'MET_RefMuon_Track_Regions', 'MET_RefMuon_em_Comps',
            'MET_RefMuon_em_Regions', 'MET_RefTau_Comps', 'MET_RefTau_Regions',
            'MET_RefTau_em_Comps', 'MET_RefTau_em_Regions',
            'MET_SoftJets_Comps', 'MET_SoftJets_Regions',
            'MET_SoftJets_em_Comps', 'MET_SoftJets_em_Regions', 'MET_Topo',
            'MET_TopoObj_Comps', 'MET_TopoObj_Regions', 'MET_Track_Comps',
            'MET_Track_Regions', 'MET_Comps', 'MET_Track_Weights',
            'MET_Cluster_Weights', 'MET_Regions', 'MET_Composition'
        ],
        allowMissing=True))

    # HadronicRecoil blocks

    if addHadronicRecoil:

        alg += ElectronD3PDObject(0,
                                  sgkey='HR_selectedElectrons',
                                  prefix='hr_el_',
                                  allowMissing=True)
        alg += MuonD3PDObject(0,
                              sgkey='HR_selectedMuons',
                              prefix='hr_mu_',
                              allowMissing=True)

        # ... DR = 0.15

        alg += MissingETD3PDObject(0,
                                   sgkey='RoughRecoil_15',
                                   prefix='hr_roughRecoil_15',
                                   exclude=['MET_Regions', 'MET_Comps'],
                                   allowMissing=True)
        alg += MissingETD3PDObject(0,
                                   sgkey='ueCorrection_15',
                                   prefix='hr_ueCorrection_15',
                                   exclude=['MET_Regions', 'MET_Comps'],
                                   allowMissing=True)
        alg += MissingETD3PDObject(0,
                                   sgkey='RefinedRecoil_15',
                                   prefix='hr_corrRecoil_15',
                                   exclude=['MET_Regions', 'MET_Comps'],
                                   allowMissing=True)
        alg += MissingETD3PDObject(0,
                                   sgkey='MET_HR_15',
                                   prefix='hr_MET_15',
                                   exclude=['MET_Regions', 'MET_Comps'],
                                   allowMissing=True)

        alg += MissingETD3PDObject(0,
                                   sgkey='RoughRecoil_Eflow_15',
                                   prefix='hr_roughRecoil_Eflow_15',
                                   exclude=['MET_Regions', 'MET_Comps'],
                                   allowMissing=True)
        alg += MissingETD3PDObject(0,
                                   sgkey='ueCorrection_Eflow_15',
                                   prefix='hr_ueCorrection_Eflow_15',
                                   exclude=['MET_Regions', 'MET_Comps'],
                                   allowMissing=True)
        alg += MissingETD3PDObject(0,
                                   sgkey='RefinedRecoil_Eflow_15',
                                   prefix='hr_corrRecoil_Eflow_15',
                                   exclude=['MET_Regions', 'MET_Comps'],
                                   allowMissing=True)
        alg += MissingETD3PDObject(0,
                                   sgkey='MET_HR_Eflow_15',
                                   prefix='hr_MET_Eflow_15',
                                   exclude=['MET_Regions', 'MET_Comps'],
                                   allowMissing=True)

        alg += MissingETD3PDObject(0,
                                   sgkey="RoughRecoil_track_15",
                                   prefix="hr_roughRecoil_track_15",
                                   exclude=['MET_Regions', 'MET_Comps'])
        alg += MissingETD3PDObject(0,
                                   sgkey="ueCorrection_track_15",
                                   prefix="hr_ueCorrection_track_15",
                                   exclude=['MET_Regions', 'MET_Comps'])
        alg += MissingETD3PDObject(0,
                                   sgkey="RefinedRecoil_track_15",
                                   prefix="hr_corrRecoil_track_15",
                                   exclude=['MET_Regions', 'MET_Comps'])
        alg += MissingETD3PDObject(0,
                                   sgkey="MET_HR_track_15",
                                   prefix="hr_MET_track_15",
                                   exclude=['MET_Regions', 'MET_Comps'])

        # ... DR = 0.20

        alg += MissingETD3PDObject(0,
                                   sgkey='RoughRecoil_20',
                                   prefix='hr_roughRecoil_20',
                                   exclude=['MET_Regions', 'MET_Comps'],
                                   allowMissing=True)
        alg += MissingETD3PDObject(0,
                                   sgkey='ueCorrection_20',
                                   prefix='hr_ueCorrection_20',
                                   exclude=['MET_Regions', 'MET_Comps'],
                                   allowMissing=True)
        alg += MissingETD3PDObject(0,
                                   sgkey='RefinedRecoil_20',
                                   prefix='hr_corrRecoil_20',
                                   exclude=['MET_Regions', 'MET_Comps'],
                                   allowMissing=True)
        alg += MissingETD3PDObject(0,
                                   sgkey='MET_HR_20',
                                   prefix='hr_MET_20',
                                   exclude=['MET_Regions', 'MET_Comps'],
                                   allowMissing=True)

        alg += MissingETD3PDObject(0,
                                   sgkey='RoughRecoil_track_20',
                                   prefix='hr_roughRecoil_track_20',
                                   exclude=['MET_Regions', 'MET_Comps'],
                                   allowMissing=True)
        alg += MissingETD3PDObject(0,
                                   sgkey='ueCorrection_track_20',
                                   prefix='hr_ueCorrection_track_20',
                                   exclude=['MET_Regions', 'MET_Comps'],
                                   allowMissing=True)
        alg += MissingETD3PDObject(0,
                                   sgkey='RefinedRecoil_track_20',
                                   prefix='hr_corrRecoil_track_20',
                                   exclude=['MET_Regions', 'MET_Comps'],
                                   allowMissing=True)
        alg += MissingETD3PDObject(0,
                                   sgkey='MET_HR_track_20',
                                   prefix='hr_MET_track_20',
                                   exclude=['MET_Regions', 'MET_Comps'],
                                   allowMissing=True)

        alg += MissingETD3PDObject(0,
                                   sgkey='RoughRecoil_clusNoTrack_20',
                                   prefix='hr_roughRecoil_clusNoTrack_20',
                                   exclude=['MET_Regions', 'MET_Comps'],
                                   allowMissing=True)
        alg += MissingETD3PDObject(0,
                                   sgkey='ueCorrection_clusNoTrack_20',
                                   prefix='hr_ueCorrection_clusNoTrack_20',
                                   exclude=['MET_Regions', 'MET_Comps'],
                                   allowMissing=True)
        alg += MissingETD3PDObject(0,
                                   sgkey='RefinedRecoil_clusNoTrack_20',
                                   prefix='hr_corrRecoil_clusNoTrack_20',
                                   exclude=['MET_Regions', 'MET_Comps'],
                                   allowMissing=True)
        alg += MissingETD3PDObject(0,
                                   sgkey='MET_HR_clusNoTrack_20',
                                   prefix='hr_MET_clusNoTrack_20',
                                   exclude=['MET_Regions', 'MET_Comps'],
                                   allowMissing=True)

        alg += MissingETD3PDObject(0,
                                   sgkey='RoughRecoil_Eflow_20',
                                   prefix='hr_roughRecoil_Eflow_20',
                                   exclude=['MET_Regions', 'MET_Comps'],
                                   allowMissing=True)
        alg += MissingETD3PDObject(0,
                                   sgkey='ueCorrection_Eflow_20',
                                   prefix='hr_ueCorrection_Eflow_20',
                                   exclude=['MET_Regions', 'MET_Comps'],
                                   allowMissing=True)
        alg += MissingETD3PDObject(0,
                                   sgkey='RefinedRecoil_Eflow_20',
                                   prefix='hr_corrRecoil_Eflow_20',
                                   exclude=['MET_Regions', 'MET_Comps'],
                                   allowMissing=True)
        alg += MissingETD3PDObject(0,
                                   sgkey='MET_HR_Eflow_20',
                                   prefix='hr_MET_Eflow_20',
                                   exclude=['MET_Regions', 'MET_Comps'],
                                   allowMissing=True)

        # ... DR = 0.25

        alg += MissingETD3PDObject(0,
                                   sgkey='RoughRecoil_25',
                                   prefix='hr_roughRecoil_25',
                                   exclude=['MET_Regions', 'MET_Comps'],
                                   allowMissing=True)
        alg += MissingETD3PDObject(0,
                                   sgkey='ueCorrection_25',
                                   prefix='hr_ueCorrection_25',
                                   exclude=['MET_Regions', 'MET_Comps'],
                                   allowMissing=True)
        alg += MissingETD3PDObject(0,
                                   sgkey='RefinedRecoil_25',
                                   prefix='hr_corrRecoil_25',
                                   exclude=['MET_Regions', 'MET_Comps'],
                                   allowMissing=True)
        alg += MissingETD3PDObject(0,
                                   sgkey='MET_HR_25',
                                   prefix='hr_MET_25',
                                   exclude=['MET_Regions', 'MET_Comps'],
                                   allowMissing=True)

        alg += MissingETD3PDObject(0,
                                   sgkey='RoughRecoil_Eflow_25',
                                   prefix='hr_roughRecoil_Eflow_25',
                                   exclude=['MET_Regions', 'MET_Comps'],
                                   allowMissing=True)
        alg += MissingETD3PDObject(0,
                                   sgkey='ueCorrection_Eflow_25',
                                   prefix='hr_ueCorrection_Eflow_25',
                                   exclude=['MET_Regions', 'MET_Comps'],
                                   allowMissing=True)
        alg += MissingETD3PDObject(0,
                                   sgkey='RefinedRecoil_Eflow_25',
                                   prefix='hr_corrRecoil_Eflow_25',
                                   exclude=['MET_Regions', 'MET_Comps'],
                                   allowMissing=True)
        alg += MissingETD3PDObject(0,
                                   sgkey='MET_HR_Eflow_25',
                                   prefix='hr_MET_Eflow_25',
                                   exclude=['MET_Regions', 'MET_Comps'],
                                   allowMissing=True)

        alg += MissingETD3PDObject(0,
                                   sgkey="RoughRecoil_track_25",
                                   prefix="hr_roughRecoil_track_25",
                                   exclude=['MET_Regions', 'MET_Comps'])
        alg += MissingETD3PDObject(0,
                                   sgkey="ueCorrection_track_25",
                                   prefix="hr_ueCorrection_track_25",
                                   exclude=['MET_Regions', 'MET_Comps'])
        alg += MissingETD3PDObject(0,
                                   sgkey="RefinedRecoil_track_25",
                                   prefix="hr_corrRecoil_track_25",
                                   exclude=['MET_Regions', 'MET_Comps'])
        alg += MissingETD3PDObject(0,
                                   sgkey="MET_HR_track_25",
                                   prefix="hr_MET_track_25",
                                   exclude=['MET_Regions', 'MET_Comps'])

        # HR using truth leptons
        if rec.doTruth():

            ## ... DR = 0.15

            alg += MissingETD3PDObject(0,
                                       sgkey="RoughRecoil_TruthLep_15",
                                       prefix="hr_roughRecoil_trLep_15",
                                       exclude=['MET_Regions', 'MET_Comps'])
            alg += MissingETD3PDObject(0,
                                       sgkey="ueCorrection_TruthLep_15",
                                       prefix="hr_ueCorrection_trLep_15",
                                       exclude=['MET_Regions', 'MET_Comps'])
            alg += MissingETD3PDObject(0,
                                       sgkey="RefinedRecoil_TruthLep_15",
                                       prefix="hr_corrRecoil_trLep_15",
                                       exclude=['MET_Regions', 'MET_Comps'])
            alg += MissingETD3PDObject(0,
                                       sgkey="RefinedRecoil_TruthLep_15",
                                       prefix="hr_MET_trLep_15",
                                       exclude=['MET_Regions', 'MET_Comps'])

            alg += MissingETD3PDObject(0,
                                       sgkey="RoughRecoil_TruthLep_Eflow_15",
                                       prefix="hr_roughRecoil_trLep_Eflow_15",
                                       exclude=['MET_Regions', 'MET_Comps'])
            alg += MissingETD3PDObject(0,
                                       sgkey="ueCorrection_TruthLep_Eflow_15",
                                       prefix="hr_ueCorrection_trLep_Eflow_15",
                                       exclude=['MET_Regions', 'MET_Comps'])
            alg += MissingETD3PDObject(0,
                                       sgkey="RefinedRecoil_TruthLep_Eflow_15",
                                       prefix="hr_corrRecoil_trLep_Eflow_15",
                                       exclude=['MET_Regions', 'MET_Comps'])
            alg += MissingETD3PDObject(0,
                                       sgkey="RefinedRecoil_TruthLep_Eflow_15",
                                       prefix="hr_MET_trLep_Eflow_15",
                                       exclude=['MET_Regions', 'MET_Comps'])

            alg += MissingETD3PDObject(0,
                                       sgkey="RoughRecoil_TruthLep_track_15",
                                       prefix="hr_roughRecoil_trLep_track_15",
                                       exclude=['MET_Regions', 'MET_Comps'])
            alg += MissingETD3PDObject(0,
                                       sgkey="ueCorrection_TruthLep_track_15",
                                       prefix="hr_ueCorrection_trLep_track_15",
                                       exclude=['MET_Regions', 'MET_Comps'])
            alg += MissingETD3PDObject(0,
                                       sgkey="RefinedRecoil_TruthLep_track_15",
                                       prefix="hr_corrRecoil_trLep_track_15",
                                       exclude=['MET_Regions', 'MET_Comps'])
            alg += MissingETD3PDObject(0,
                                       sgkey="RefinedRecoil_TruthLep_track_15",
                                       prefix="hr_MET_trLep_track_15",
                                       exclude=['MET_Regions', 'MET_Comps'])

            ## ... DR = 0.20

            alg += MissingETD3PDObject(0,
                                       sgkey="RoughRecoil_TruthLep_20",
                                       prefix="hr_roughRecoil_trLep_20",
                                       exclude=['MET_Regions', 'MET_Comps'])
            alg += MissingETD3PDObject(0,
                                       sgkey="ueCorrection_TruthLep_20",
                                       prefix="hr_ueCorrection_trLep_20",
                                       exclude=['MET_Regions', 'MET_Comps'])
            alg += MissingETD3PDObject(0,
                                       sgkey="RefinedRecoil_TruthLep_20",
                                       prefix="hr_corrRecoil_trLep_20",
                                       exclude=['MET_Regions', 'MET_Comps'])
            alg += MissingETD3PDObject(0,
                                       sgkey="RefinedRecoil_TruthLep_20",
                                       prefix="hr_MET_trLep_20",
                                       exclude=['MET_Regions', 'MET_Comps'])

            alg += MissingETD3PDObject(0,
                                       sgkey="RoughRecoil_TruthLep_Eflow_20",
                                       prefix="hr_roughRecoil_trLep_Eflow_20",
                                       exclude=['MET_Regions', 'MET_Comps'])
            alg += MissingETD3PDObject(0,
                                       sgkey="ueCorrection_TruthLep_Eflow_20",
                                       prefix="hr_ueCorrection_trLep_Eflow_20",
                                       exclude=['MET_Regions', 'MET_Comps'])
            alg += MissingETD3PDObject(0,
                                       sgkey="RefinedRecoil_TruthLep_Eflow_20",
                                       prefix="hr_corrRecoil_trLep_Eflow_20",
                                       exclude=['MET_Regions', 'MET_Comps'])
            alg += MissingETD3PDObject(0,
                                       sgkey="RefinedRecoil_TruthLep_Eflow_20",
                                       prefix="hr_MET_trLep_Eflow_20",
                                       exclude=['MET_Regions', 'MET_Comps'])

            alg += MissingETD3PDObject(0,
                                       sgkey="RoughRecoil_TruthLep_track_20",
                                       prefix="hr_roughRecoil_trLep_track_20",
                                       exclude=['MET_Regions', 'MET_Comps'])
            alg += MissingETD3PDObject(0,
                                       sgkey="ueCorrection_TruthLep_track_20",
                                       prefix="hr_ueCorrection_trLep_track_20",
                                       exclude=['MET_Regions', 'MET_Comps'])
            alg += MissingETD3PDObject(0,
                                       sgkey="RefinedRecoil_TruthLep_track_20",
                                       prefix="hr_corrRecoil_trLep_track_20",
                                       exclude=['MET_Regions', 'MET_Comps'])
            alg += MissingETD3PDObject(0,
                                       sgkey="RefinedRecoil_TruthLep_track_20",
                                       prefix="hr_MET_trLep_track_20",
                                       exclude=['MET_Regions', 'MET_Comps'])

            ## ... DR = 0.25

            alg += MissingETD3PDObject(0,
                                       sgkey="RoughRecoil_TruthLep_25",
                                       prefix="hr_roughRecoil_trLep_25",
                                       exclude=['MET_Regions', 'MET_Comps'])
            alg += MissingETD3PDObject(0,
                                       sgkey="ueCorrection_TruthLep_25",
                                       prefix="hr_ueCorrection_trLep_25",
                                       exclude=['MET_Regions', 'MET_Comps'])
            alg += MissingETD3PDObject(0,
                                       sgkey="RefinedRecoil_TruthLep_25",
                                       prefix="hr_corrRecoil_trLep_25",
                                       exclude=['MET_Regions', 'MET_Comps'])
            alg += MissingETD3PDObject(0,
                                       sgkey="RefinedRecoil_TruthLep_25",
                                       prefix="hr_MET_trLep_25",
                                       exclude=['MET_Regions', 'MET_Comps'])

            alg += MissingETD3PDObject(0,
                                       sgkey="RoughRecoil_TruthLep_Eflow_25",
                                       prefix="hr_roughRecoil_trLep_Eflow_25",
                                       exclude=['MET_Regions', 'MET_Comps'])
            alg += MissingETD3PDObject(0,
                                       sgkey="ueCorrection_TruthLep_Eflow_25",
                                       prefix="hr_ueCorrection_trLep_Eflow_25",
                                       exclude=['MET_Regions', 'MET_Comps'])
            alg += MissingETD3PDObject(0,
                                       sgkey="RefinedRecoil_TruthLep_Eflow_25",
                                       prefix="hr_corrRecoil_trLep_Eflow_25",
                                       exclude=['MET_Regions', 'MET_Comps'])
            alg += MissingETD3PDObject(0,
                                       sgkey="RefinedRecoil_TruthLep_Eflow_25",
                                       prefix="hr_MET_trLep_Eflow_25",
                                       exclude=['MET_Regions', 'MET_Comps'])

            alg += MissingETD3PDObject(0,
                                       sgkey="RoughRecoil_TruthLep_track_25",
                                       prefix="hr_roughRecoil_trLep_track_25",
                                       exclude=['MET_Regions', 'MET_Comps'])
            alg += MissingETD3PDObject(0,
                                       sgkey="ueCorrection_TruthLep_track_25",
                                       prefix="hr_ueCorrection_trLep_track_25",
                                       exclude=['MET_Regions', 'MET_Comps'])
            alg += MissingETD3PDObject(0,
                                       sgkey="RefinedRecoil_TruthLep_track_25",
                                       prefix="hr_corrRecoil_trLep_track_25",
                                       exclude=['MET_Regions', 'MET_Comps'])
            alg += MissingETD3PDObject(0,
                                       sgkey="RefinedRecoil_TruthLep_track_25",
                                       prefix="hr_MET_trLep_track_25",
                                       exclude=['MET_Regions', 'MET_Comps'])

    # Cluster block

    # ... all clusters, very low LOD

    if clusterContainer != 'None':
        alg += ClusterD3PDObject(**_args(0,
                                         'Clusters',
                                         kw,
                                         sgkey=clusterContainer,
                                         exclude='SamplingBasics',
                                         allowMissing=True))

    # Track block

    # ... good tracks only (nSCT>=6; no pt cut)

    if trackContainer != 'None':
        alg += TrackParticleD3PDObject(**_args(3,
                                               'Tracks',
                                               kw,
                                               sgkey=trackContainer,
                                               label='trk',
                                               prefix='trk_',
                                               allowMissing=True))

    # Primary vertex block - May be missing in single-beam data.

    alg += PrimaryVertexD3PDObject(**_args(1,
                                           'PrimaryVertex',
                                           kw,
                                           sgkey=D3PDMakerFlags.VertexSGKey(),
                                           prefix='vxp_',
                                           allowMissing=True))

    # Truth

    if rec.doTruth():

        from TruthD3PDMaker.TruthParticleD3PDObject import TruthParticleD3PDObject
        from MuonD3PDMaker.TruthMuonD3PDObject import TruthMuonD3PDObject
        alg += TruthMuonD3PDObject(**_args(2, 'TruthMuon', kw))

        from AthenaCommon.AppMgr import ToolSvc
        from TruthD3PDAnalysis.TruthD3PDAnalysisConf import D3PD__GenObjectsFilterTool

        # ... remove empty GenEvents

        smlightGenEvtFilterTool = D3PD__GenObjectsFilterTool(
            "smlightGenEvtFilterTool")
        ToolSvc += smlightGenEvtFilterTool
        smlightGenEvtFilterTool.RemoveDummyEvents = True
        smlightGenEvtFilterTool.RemoveInTimePileUp = True
        smlightGenEvtFilterTool.Remove2BCPileUp = True
        smlightGenEvtFilterTool.Remove800nsPileUp = True
        smlightGenEvtFilterTool.RemoveCavernBkg = True
        smlightGenEvtFilterTool.RemoveEmptyEvents = True

        from TruthD3PDMaker.GenEventD3PDObject import GenEventD3PDObject
        alg += GenEventD3PDObject(
            **_args(0, 'GenEvent', kw, filter=smlightGenEvtFilterTool))

        # ... leptonic W/Z truth information

        smlightLepWZFilterTool = D3PD__GenObjectsFilterTool(
            "smlightLepWZFilterTool")
        ToolSvc += smlightLepWZFilterTool

        smlightLepWZFilterTool.RemoveInTimePileUp = True
        smlightLepWZFilterTool.Remove2BCPileUp = True
        smlightLepWZFilterTool.Remove800nsPileUp = True
        smlightLepWZFilterTool.RemoveCavernBkg = True
        smlightLepWZFilterTool.RemoveEmptyEvents = True
        smlightLepWZFilterTool.RemoveDummyEvents = True
        smlightLepWZFilterTool.RemoveUnrequestedParticles = True
        smlightLepWZFilterTool.KeepLeptonicWZBosons = True
        smlightLepWZFilterTool.KeepLeptonicWZBosonDecayChains = True
        smlightLepWZFilterTool.KeepLeptonicWZBosonsParents = True

        from TruthD3PDMaker.GenParticleD3PDObject import GenParticleD3PDObject
        alg += GenParticleD3PDObject(**_args(
            10,
            "lepwzgenparticle",
            kw,
            prefix='mclepwzpart_',
            filter=smlightLepWZFilterTool,
            label="LepWZTruthD3PDObject",
            exclude=["GenPartProdVertexAssoc", "GenPartDecayVertexAssoc"],
            GenParticle_WriteMotherType=False,
            GenParticle_WriteMotherBarcode=False,
            GenPartMotherAssoc_target="LepWZTruthD3PDObject",
            GenPartChildAssoc_target="LepWZTruthD3PDObject"))

    if not rec.doTruth():
        alg += BeamSpotD3PDObject(10)

    # Trigger

    if D3PDMakerFlags.DoTrigger():

        #        RedefineTriggerBits(alg, 'EF*')
        #        alg += SMTrilepTriggerBitsD3PDObject      (**_args (10, 'SMTrilepTriggerBits', kw))

        alg += TrigDecisionD3PDObject(**_args(10, 'TrigDecision', kw))
        addTrigConfMetadata(alg)

        # Bunch group info

        alg += BGCodeD3PDObject(**_args(2, 'BGCode', kw))

        # Egamma and Mu

        TrigEgammaD3PDObjects(alg, 1)
        TrigMuonD3PDObjects(alg, 1)

# Event metadata

    alg.MetadataTools += [LBMetadataConfig()]

    if D3PDMakerFlags.FilterCollCand():
        from CaloD3PDMaker.CollisionFilterAlg import CollisionFilterAlg
        alg.filterSeq += CollisionFilterAlg(tuplename + '_CollCandFilter')

    return alg
def MuonLayerHoughTool(name='MuonLayerHoughTool',extraFlags=None,**kwargs):
    kwargs.setdefault("DoTruth", rec.doTruth() )
    return CfgMgr.Muon__MuonLayerHoughTool(name,**kwargs)
Beispiel #10
0
    def __init__(self,
                 name=Configurable.DefaultName,
                 configureForTrigger=False,
                 doStau=True):
        super(MuGirlRecoConfig, self).__init__(name)
        self.MuGirlParticleCreatorTool = None

        global ToolSvc
        if configureForTrigger:
            print "MuGirlRecoConfig: configuring for trigger"

        self.doNTuple = muGirlFlags.doNTuple()
        self.doTruth = rec.doTruth() and muGirlFlags.doNTuple()
        self.PtLowerLimit = muGirlFlags.PtLowerLimit()
        self.doStau = doStau

        from MuGirlCandidate.MuGirlCandidateConfig import MuGirlNS__CandidateToolConfig
        if configureForTrigger:
            MuGirlCandidateTool = MuGirlNS__CandidateToolConfig(
                name='TrigMuGirlCandidateTool')
        else:
            MuGirlCandidateTool = MuGirlNS__CandidateToolConfig(
                name='MuGirlCandidateTool')
        ToolSvc += MuGirlCandidateTool
        MuGirlCandidateTool.doCSC = muonRecFlags.doCSCs()
        self.MuGirlCandidate = MuGirlCandidateTool
        if configureForTrigger:
            CaloEnergyTool = getPublicTool("TMEF_CaloEnergyTool")
            self.doLHR = False
        else:
            CaloEnergyTool = ToolSvc.MuidCaloEnergyTool
            self.CaloMuonLikelihoodTool = getPublicTool(
                "CaloMuonLikelihoodTool")
        MuGirlCandidateTool.MuidCaloEnergy = CaloEnergyTool

        from MuGirlPerformanceTools.MuGirlPerformanceToolsConf import MuGirlNS__PerformanceTruthTool
        MuGirlPerformanceTruthTool = MuGirlNS__PerformanceTruthTool(
            name='MuGirlPerformanceTruthTool')
        MuGirlPerformanceTruthTool.TrackRecordCollection = "MuonEntryLayer"
        ToolSvc += MuGirlPerformanceTruthTool
        self.PerformanceTruthTool = MuGirlPerformanceTruthTool

        from MuGirlParticleCreatorTool.MuGirlParticleCreatorToolConf import MuGirlNS__MuGirlParticleCreatorTool
        MuGirlParticleCreatorTool = MuGirlNS__MuGirlParticleCreatorTool(
            name='MuGirlParticleCreatorTool')
        MuGirlParticleCreatorTool.doNTuple = self.doNTuple
        MuGirlParticleCreatorTool.doTruth = self.doTruth
        MuGirlParticleCreatorTool.PerformanceTruthTool = MuGirlPerformanceTruthTool
        MuGirlParticleCreatorTool.MuidCaloEnergyTool = CaloEnergyTool
        if beamFlags.beamType() == 'cosmics':
            MuGirlParticleCreatorTool.inDetTrackParticlesLocation = 'TrackParticleCandidate_split'
        ToolSvc += MuGirlParticleCreatorTool
        self.MuGirlParticleCreatorTool = MuGirlParticleCreatorTool

        from MuGirlGlobalFit.MuGirlGlobalFitConf import MuGirlNS__GlobalFitTool
        GlobalFitTool = MuGirlNS__GlobalFitTool(name='GlobalFitTool')
        if configureForTrigger:
            GlobalFitTool.trackFitter = getPublicTool(
                "TMEF_CombinedMuonTrackBuilder")
        ToolSvc += GlobalFitTool
        self.MuGirlGlobalFitTool = GlobalFitTool

        if doStau:
            from MuGirlStau.MuGirlStauConfig import MuGirlNS__StauToolConfig
            if configureForTrigger:
                StauTool = MuGirlNS__StauToolConfig(name='TrigMuGirlStauTool')
            else:
                StauTool = MuGirlNS__StauToolConfig(name='MuGirlStauTool')

            ToolSvc += StauTool
            self.MuGirlStauTool = StauTool
            StauTool.StauGlobalFitTool = GlobalFitTool

        from MuGirlSelection.MuGirlSelectionConf import MuGirlNS__ANNSelectionTool
        MuGirlSelectionTool = MuGirlNS__ANNSelectionTool("MuGirlSelectionTool")
        ToolSvc += MuGirlSelectionTool
        MuGirlSelectionTool.CandidateTool = MuGirlCandidateTool
        self.ANNSelectionTool = MuGirlSelectionTool

        print "MuGirlRecoConfig: momentum, pt thresholds %s" % self.PtLowerLimit
Beispiel #11
0
from MissingEtDQA.MissingEtDQAConf import MissingEtDQA__PhysValMET
tool1 = MissingEtDQA__PhysValMET()
tool1.EnableLumi = False
tool1.OutputLevel = WARNING
tool1.DetailLevel = 10
from RecExConfig.RecFlags import rec as recFlags
if recFlags.doTruth():
    tool1.DoTruth = True

from AthenaCommon import CfgMgr
jvtToolEMTopo = CfgMgr.JetVertexTaggerTool('JVTToolEMTopo')
jvtToolPFlow = CfgMgr.JetVertexTaggerTool('JVTToolPFlow')
tool1.JVTToolEMTopo = jvtToolEMTopo
tool1.JVTToolEMPFlow = jvtToolPFlow
tool1.JVTToolEMTopo.JetContainer = "AntiKt4EMTopoJets"
tool1.JVTToolEMPFlow.JetContainer = "AntiKt4EMPFlowJets"

mettoolTopo = CfgMgr.met__METMaker('METMaker_AntiKt4Topo',
                                   JetSelection="Default",
                                   JetJvtMomentName="NewJvt",
                                   DoPFlow=False)
tool1.METMakerTopo = mettoolTopo

mettoolPFlow = CfgMgr.met__METMaker('METMaker_AntiKt4PFlow',
                                    JetSelection="PFlow",
                                    JetJvtMomentName="NewJvt",
                                    DoPFlow=True)
tool1.METMakerPFlow = mettoolPFlow

museltool = CfgMgr.CP__MuonSelectionTool(
    "MuonSelectionTool",
Beispiel #12
0
#################################################################
#
# InnerDetector (iPatRec requirements) jobOptions fragment
#
#==============================================================

#--------------------------------------------------------------
# set InDet defaults
#--------------------------------------------------------------

# --- setup InDetJobProperties
from InDetRecExample.InDetJobProperties import InDetFlags
from RecExConfig.RecFlags import rec
InDetFlags.doTruth = rec.doTruth()
InDetFlags.doStatistics = False

# --- uncomment to disable one of the following tracking algorithms
InDetFlags.doNewTracking = False
InDetFlags.doxKalman = False
#InDetFlags.doiPatRec     = False

#
# ----------- lock and printout the setup
#
InDetFlags.init()
InDetFlags.printInfo()
InDetFlags.print_JobProperties()

if not 'InDetNewTrackingCuts' in dir():
    #
    # --- setup physics cuts with default values
Beispiel #13
0
         Vars = [
         'nbCells_s0LowGain',
         'nbCells_s0MedGain',
         'nbCells_s0HighGain',
         'nbCells_s1LowGain',
         'nbCells_s1MedGain',
         'nbCells_s1HighGain',
         'nbCells_s2LowGain',
         'nbCells_s2MedGain',
         'nbCells_s2HighGain',
         'nbCells_s3LowGain',
         'nbCells_s3MedGain',
         'nbCells_s3HighGain',
         ])

if rec.doTruth():
    from TruthD3PDMaker.MCTruthClassifierConfig \
         import D3PDMCTruthClassifier
    ElectronD3PDObject.defineBlock(
        1,
        'TruthClassification',
        egammaD3PDMaker.egammaTruthClassificationFillerTool,
        DoBkgElecOrigin=True,
        Classifier=D3PDMCTruthClassifier)
    ElectronTruthPartAssoc = SimpleAssociation \
        (ElectronD3PDObject,
         egammaD3PDMaker.egammaGenParticleAssociationTool,
         prefix = 'truth_',
         matched = 'matched',
         blockname = 'TruthAssoc',
         Classifier = D3PDMCTruthClassifier)
Beispiel #14
0
 def get_Value(self):
     if self.statusOn:
         return JobProperty.get_Value(self)
     else:
         from RecExConfig.RecFlags import rec
         return rec.doTruth()
Beispiel #15
0
    def __init__(self, name="ConfiguredFTK_DataProviderSvc"):
        print "In FTK_DataProviderSvc_Config.py"
        FTK_DataProviderSvc.__init__(self, name)
        # Track Fitter
        from TrkGlobalChi2Fitter.TrkGlobalChi2FitterConf import Trk__GlobalChi2Fitter
        from InDetTrigRecExample.InDetTrigConfigRecLoadTools import InDetTrigExtrapolator, InDetTrigNavigator, InDetTrigPropagator, InDetTrigRefitRotCreator,InDetTrigBroadInDetRotCreator, \
             InDetTrigUpdator, InDetTrigMaterialUpdator, InDetTrigUpdator, InDetTrigMaterialUpdator
        from TrkDetDescrSvc.AtlasTrackingGeometrySvc import AtlasTrackingGeometrySvc

        from TrkDistributedKalmanFilter.DistributedKalmanFilter_Config import ConfiguredDistributedKalmanFilter

        FTK_TrackFitter = Trk__GlobalChi2Fitter(
            name="FTK_TrackFitter",
            ExtrapolationTool=InDetTrigExtrapolator,
            NavigatorTool=InDetTrigNavigator,
            PropagatorTool=InDetTrigPropagator,
            RotCreatorTool=InDetTrigRefitRotCreator,
            BroadRotCreatorTool=InDetTrigBroadInDetRotCreator,
            MeasurementUpdateTool=InDetTrigUpdator,
            TrackingGeometrySvc=AtlasTrackingGeometrySvc,
            MaterialUpdateTool=InDetTrigMaterialUpdator,
            StraightLine=False,
            OutlierCut=4,
            SignedDriftRadius=True,
            RecalibrateSilicon=True,
            RecalibrateTRT=True,
            ReintegrateOutliers=True,
            TrackChi2PerNDFCut=7,
            TRTExtensionCuts=False,
            MaxIterations=40,
            Acceleration=True,
            Momentum=1000.,
        )
        from AthenaCommon.AppMgr import ToolSvc

        print "printing FTK_TrackFitter configured with DKF"
        print FTK_TrackFitter
        ToolSvc += FTK_TrackFitter
        print "added FTK_TrackFitter to ToolSvc"

        from InDetTrigRecExample.InDetTrigConfigRecLoadTools import InDetTrigExtrapolator, InDetTrigTrackSelectorTool, InDetTrigHoleSearchTool
        from InDetTrigRecExample.InDetTrigConfigRecLoadTools import InDetTrigTrackSummaryToolSharedHits, InDetTrigPrdAssociationTool

        from InDetTrackSummaryHelperTool.InDetTrackSummaryHelperToolConf import InDet__InDetTrackSummaryHelperTool
        FTK_TrackSummaryHelperTool = InDet__InDetTrackSummaryHelperTool(
            name="FTK_TrackSummaryHelperTool",
            AssoTool=InDetTrigPrdAssociationTool,
            DoSharedHits=False,
            HoleSearch=InDetTrigHoleSearchTool,
            TestBLayerTool=None,
            PixelToTPIDTool=None,
            usePixel=True,
            useSCT=True,
            useTRT=False)

        ToolSvc += FTK_TrackSummaryHelperTool
        print "added FTK_TrackSummaryHelperTool to ToolSvc"

        from TrkTrackSummaryTool.TrkTrackSummaryToolConf import Trk__TrackSummaryTool
        FTK_TrackSummaryTool = Trk__TrackSummaryTool(
            name="FTK_TrackSummaryTool",
            InDetSummaryHelperTool=FTK_TrackSummaryHelperTool,
            InDetHoleSearchTool=None,
            doSharedHits=False,
            TRT_ElectronPidTool=None)
        ToolSvc += FTK_TrackSummaryTool
        print "added FTK_TrackSummaryTool to ToolSvc"

        from TrkParticleCreator.TrkParticleCreatorConf import Trk__TrackParticleCreatorTool

        FTK_TrackParticleCreatorTool = Trk__TrackParticleCreatorTool(
            name="FTK_ParticleCreatorTool",
            Extrapolator=InDetTrigExtrapolator,
            TrackSummaryTool=FTK_TrackSummaryTool,
            KeepParameters=True,
            ForceTrackSummaryUpdate=
            False,  #summary update moved (in the slimmer now)
        )

        ToolSvc += FTK_TrackParticleCreatorTool
        print FTK_TrackParticleCreatorTool
        print " added FTK_TrackParticleCreatorTool to ToolSvc"

        from TrigInDetConf.TrigInDetRecVtxTools import InDetTrigLinFactory, InDetTrigVxEdmCnv
        from TrigInDetConf.TrigInDetRecVtxTools import InDetTrigLinFactory, InDetTrigVxEdmCnv

        from TrkVertexSeedFinderTools.TrkVertexSeedFinderToolsConf import Trk__ZScanSeedFinder
        FTK_VtxSeedFinder = Trk__ZScanSeedFinder(
            name="FTK_ZScanSeedFinder"
            #Mode1dFinder = # default, no setting needed
        )
        ToolSvc += FTK_VtxSeedFinder

        from TrkVertexFitterUtils.TrkVertexFitterUtilsConf import Trk__ImpactPoint3dEstimator, Trk__DetAnnealingMaker

        FTK_ImpactPoint3dEstimator = Trk__ImpactPoint3dEstimator(
            name="FTK_TrkImpactPoint3dEstimator",
            Extrapolator=InDetTrigExtrapolator,
        )

        ToolSvc += FTK_ImpactPoint3dEstimator

        FTK_AnnealingMaker = Trk__DetAnnealingMaker(
            name="FTK_TrkAnnealingMaker")
        FTK_AnnealingMaker.SetOfTemperatures = [64., 16., 4., 2., 1.5,
                                                1.]  # not default
        ToolSvc += FTK_AnnealingMaker

        from TrkVertexFitters.TrkVertexFittersConf import Trk__SequentialVertexSmoother
        FTK_VertexSmoother = Trk__SequentialVertexSmoother(
            name="FTK_SequentialVertexSmoother")
        ToolSvc += FTK_VertexSmoother

        from TrkVertexFitters.TrkVertexFittersConf import Trk__AdaptiveVertexFitter
        FTK_VxFitterTool = Trk__AdaptiveVertexFitter(
            name="FTK_AdaptiveVxFitterTool",
            SeedFinder=FTK_VtxSeedFinder,
            LinearizedTrackFactory=InDetTrigLinFactory,
            ImpactPoint3dEstimator=FTK_ImpactPoint3dEstimator,
            AnnealingMaker=FTK_AnnealingMaker,
            #TrackCompatibilityEstimator =
            VertexSmoother=FTK_VertexSmoother,
            #VertexUpdator = ,  #does not use any tools?
            #onlyzseed = ,
        )

        FTK_VxFitterTool.XAODConverter = InDetTrigVxEdmCnv
        ToolSvc += FTK_VxFitterTool

        from InDetPriVxFinderTool.InDetPriVxFinderToolConf import InDet__InDetIterativePriVxFinderTool
        FTK_PriVxFinderTool = InDet__InDetIterativePriVxFinderTool(
            name="FTK_PriVxFinderTool",
            VertexFitterTool=FTK_VxFitterTool,
            TrackSelector=InDetTrigTrackSelectorTool,
            SeedFinder=FTK_VtxSeedFinder,
            ImpactPoint3dEstimator=FTK_ImpactPoint3dEstimator,
            LinearizedTrackFactory=InDetTrigLinFactory,
            useBeamConstraint=True,
            significanceCutSeeding=12,
            maximumChi2cutForSeeding=49,
            maxVertices=200,
            InternalEdmFactory=InDetTrigVxEdmCnv)
        ToolSvc += FTK_PriVxFinderTool

        from FTK_DataProviderSvc.FTK_DataProviderSvcConf import FTK_UncertaintyTool
        theFTK_UncertaintyTool = FTK_UncertaintyTool(
            name="FTK_UncertaintyTool")
        ToolSvc += theFTK_UncertaintyTool

        from FTK_RecTools.FTK_RecToolsConf import FTK_VertexFinderTool
        FTK_RawVertexFinderTool = FTK_VertexFinderTool(
            name="FTK_RawVertexFinderTool",
            VertexInternalEdmFactory=InDetTrigVxEdmCnv)
        ToolSvc += FTK_RawVertexFinderTool

        self.TrackCollectionName = "FTK_TrackCollection"
        self.TrackParticleContainerName = "FTK_TrackParticleContainer"
        self.VxContainerName = "FTK_VxContainer"
        self.VertexContainerName = "FTK_VertexContainer"
        self.PixelTruthName = "FTK_PRD_MultiTruthPixel"
        self.SctTruthName = "FTK_PRD_MultiTruthSCT"
        self.PixelClusterContainerName = "FTK_PixelClusterContainer"
        self.SCT_ClusterContainerName = "FTK_SCT_ClusterContainer"

        self.TrackFitter = FTK_TrackFitter
        self.UncertaintyTool = theFTK_UncertaintyTool
        self.TrackSummaryTool = FTK_TrackSummaryTool
        self.TrackParticleCreatorTool = FTK_TrackParticleCreatorTool
        self.RawVertexFinderTool = FTK_RawVertexFinderTool
        self.VertexFinderTool = FTK_PriVxFinderTool
        from RecExConfig.RecFlags import rec

        self.doTruth = rec.doTruth()
        self.TrainingBeamspotX = 0.0
        self.TrainingBeamspotY = 0.0
        self.TrainingBeamspotZ = 0.0
        self.TrainingBeamspotTiltX = 0.0
        self.TrainingBeamspotTiltY = 0.0
        self.PixelBarrelPhiOffsets = [0.0, 0.0, 0.0, 0.0]
        self.PixelBarrelEtaOffsets = [0.0, 0.0, 0.0, 0.0]
        self.PixelEndCapPhiOffsets = [0.0, 0.0, 0.0]
        self.PixelEndCapEtaOffsets = [0.0, 0.0, 0.0]
def JSD3PD(jetsToWrite,
           alg=None,
           scheduleOnly=False,
           level=10,
           file='js.root',
           tuplename='js'):

    if not alg:
        from OutputStreamAthenaPool.MultipleStreamManager import MSMgr
        alg = MSMgr.NewRootStream(tuplename, file, asAlg=True)

    commonExcludeList = [
        'El02Match', 'Mu02Match', 'L1Info', 'L2Info', 'EFInfo'
    ]
    commonIncludeList = []

    import re
    JetAlgPattern = re.compile(
        r'^(\D+)(\d{1,2})(\D+)Jets')  #assuming standard notation
    ars = JetAlgPattern.match(jetsToWrite[0]).groups()

    parentJets = ''.join(ars)  #remove the 'Jets' at the end
    groomedJetsList = jetsToWrite[1]

    parentJetsWithoutJS = parentJets
    if parentJets[-2:] == 'JS': parentJetsWithoutJS = parentJets[:-2]

    parentJetsWithoutJSForGrooming = parentJetsWithoutJS
    if scheduleOnly: parentJetsWithoutJS += "Jets"
    filteredSequence = AlgSequence('TopWGFilter')

    theZeroLevel = 0
    if not scheduleOnly:
        MyJetD3PDObject = getJetD3PDObject(objectname='MyJetD3PDObject')
        MyJetD3PDObject._hookArgs['seq'] = filteredSequence
    else:
        from TopInputsD3PDMaker.topInputsD3PD import JetD3PDObject
        MyJetD3PDObject = JetD3PDObject
        mylod = myLOD('jet_' + parentJetsWithoutJS + '_')
        theZeroLevel = mylod._prefixLOD

    MyGroomedJetD3PDObject = getJetD3PDObject(
        objectname='MyGroomedJetD3PDObject')
    MyGroomedJetD3PDObject._hookArgs['seq'] = filteredSequence

    ## Electron LC cluster overlap map
    if ('LCTopo' in parentJets) and (not hasattr(
            alg, 'ElecTopoClusterAssoc_Filler')):
        MyJetAssocD3PDObject = make_SGDataVector_D3PDObject(
            'DataVector<INavigable4Momentum>',
            'ElectronAODCollection_CaloCalTopoCluster_jetsubstructure_electrons',
            'ElecTopoClusterAssoc_', 'myJetAssocD3PDObject')
        AddAssocConstitIndex(MyJetAssocD3PDObject)
        AddAssocConstitIndex(MyJetAssocD3PDObject, 'CaloCluster', 'cl_')
        alg += MyJetAssocD3PDObject(0)

    if 'Track' in parentJets:
        AddConstitIndex(MyGroomedJetD3PDObject,
                        typename='Rec::TrackParticle',
                        target='trk')
        AddConstitIndex(MyJetD3PDObject,
                        typename='Rec::TrackParticle',
                        target='trk',
                        level=theZeroLevel)
        AddLeptonicInfo(MyJetD3PDObject, level=theZeroLevel)
        AddLeptonicInfo(MyGroomedJetD3PDObject, 99)
    elif 'Topo' in parentJets:
        AddConstitIndex(MyGroomedJetD3PDObject)
        AddConstitIndex(MyJetD3PDObject, level=theZeroLevel)
        AddLeptonicInfo(MyJetD3PDObject, level=theZeroLevel)
        AddLeptonicInfo(MyGroomedJetD3PDObject, 99)
    elif 'Truth' in parentJets:
        if ars[1] == '4':
            from JetD3PDMaker.JetD3PDMakerConf import D3PD__JetShapeFillerTool
            from JetD3PDMaker.JetD3PDMakerConf import D3PD__JetTrueTagFillerTool
            MyJetD3PDObject.defineBlock(theZeroLevel, 'myJetShape',
                                        D3PD__JetShapeFillerTool)
            MyJetD3PDObject.defineBlock(theZeroLevel, 'TrueFlavorComponents',
                                        D3PD__JetTrueTagFillerTool)
        AddConstitTruthIndex(MyJetD3PDObject, level=theZeroLevel)
        AddTruthLeptonicInfo(MyJetD3PDObject, level=theZeroLevel)
        AddTruthLeptonicInfo(MyGroomedJetD3PDObject, level=99)
        AddConstitTruthIndex(MyGroomedJetD3PDObject)

    if 'Track' not in parentJets and 'Truth' not in parentJets:
        AddAssocJetsIndex(MyJetD3PDObject,
                          'TrackJets',
                          'jet_' + ars[0] + ars[1] + 'TrackZ_',
                          level=theZeroLevel)
        if rec.doTruth():
            AddAssocJetsIndex(MyJetD3PDObject,
                              'TruthJets',
                              'jet_' + ars[0] + ars[1] + 'Truth_',
                              level=theZeroLevel)

    JetQualInclude = []

    if 'Topo' in parentJets:
        commonIncludeList += ['ConstituentScale', 'EMScale']
        if not scheduleOnly:
            AddHadronicInfo(MyJetD3PDObject, [
                'OriginIndex', 'nTrk', 'sumPtTrk', 'EtaOrigin', 'PhiOrigin',
                'MOrigin'
            ],
                            theblockname='OriginIndexBlock')
        AddHadronicInfo(MyGroomedJetD3PDObject,
                        ['EtaOrigin', 'PhiOrigin', 'MOrigin'],
                        theblockname='OriginIndexBlock',
                        level=99)
        if (parentJetsWithoutJS == 'AntiKt10LCTopo') or (parentJetsWithoutJS
                                                         == 'CamKt12LCTopo'):
            AddHadronicInfo(MyJetD3PDObject,
                            ['LCJES', 'LCJES_EtaCorr', 'LCJES_MassCorr'],
                            theblockname='LCJESBlock',
                            level=theZeroLevel)
            AddHadronicInfo(MyGroomedJetD3PDObject,
                            ['LCJES', 'LCJES_EtaCorr', 'LCJES_MassCorr'],
                            theblockname='LCJESBlock')
        if ars[1] == '4' or ars[1] == '6':
            if not scheduleOnly:
                AddHadronicInfo(MyJetD3PDObject, ['EMJES', 'EMJES_EtaCorr'],
                                theblockname='EMJESBlock',
                                level=99)
                AddHadronicInfo(MyJetD3PDObject, ['LCJES', 'LCJES_EtaCorr'],
                                theblockname='LCJESBlock',
                                level=99)
                AddHadronicInfo(MyJetD3PDObject, [
                    'Timing', 'LArQuality', 'HECQuality', 'NegativeE',
                    'AverageLArQF'
                ],
                                theblockname='QMomentsBlock')
            if 'TopoEM' in ars[2]:
                JetQualInclude += ['EMJESBlock', 'JetQual']
            elif 'LCTopo' in ars[2]:
                JetQualInclude += ['LCJESBlock', 'JetQual']

    VtxInclude = []
    if 'Topo' in parentJets:
        VtxInclude += ['JVtx', 'JetVertexFraction']
    elif 'Track' in parentJets:
        VtxInclude += ['JVtx']

    AddAssocJetsIndex(MyGroomedJetD3PDObject, 'Parent',
                      'jet_' + parentJetsWithoutJS + '_')
    for gr in groomedJetsList:
        AddAssocJetsIndex(MyJetD3PDObject,
                          gr,
                          'jet_' + parentJetsWithoutJSForGrooming + gr + '_',
                          level=theZeroLevel)

    MyGroomedJetCollectionD3PDObject = getJetCollectionD3PDObject(
        objectname="MyGroomedJetCollectionD3PDObject")
    AddUniqueMoments(MyGroomedJetCollectionD3PDObject, ['SmallR', 'PtFrac'],
                     theblockname='TrimConfigMoments',
                     level=99)
    #AddUniqueMoments(MyGroomedJetCollectionD3PDObject,   ['NSubjets','ktycut2','massFraction','minRfilt','minSplitR'], theblockname = 'FiltConfigMoments', level = 99)
    #AddUniqueMoments(MyGroomedJetCollectionD3PDObject,   ['RcutFactor', 'Zcut'], theblockname = 'PrunConfigMoments', level = 99)

    AddHadronicInfo(MyGroomedJetD3PDObject, ['CORE_RBB', 'CORE_RFILT'],
                    theblockname='FiltMoments',
                    level=99)

    listOfMoments = [
        'Tau1', 'Tau2', 'Tau3', 'SPLIT12', 'SPLIT23', 'SPLIT34', 'ZCUT12',
        'ZCUT23', 'ZCUT34', 'QW', 'PullMag', 'PullPhi', 'Pull_C00', 'Pull_C01',
        'Pull_C10', 'Pull_C11', 'WIDTH'
    ]

    if not scheduleOnly: listOfMoments_ = listOfMoments
    else: listOfMoments_ = listOfMoments[:-1]  # without WIDTH

    AddHadronicInfo(MyGroomedJetD3PDObject,
                    listOfMoments,
                    theblockname='jsObsblock',
                    level=99)
    AddHadronicInfo(MyJetD3PDObject,
                    listOfMoments_,
                    theblockname='jsObsblock',
                    level=theZeroLevel)

    if not scheduleOnly:
        alg += MyJetD3PDObject(0,
                               prefix='jet_' + parentJetsWithoutJS + '_',
                               sgkey=parentJets + 'Jets',
                               exclude=commonExcludeList,
                               include=commonIncludeList + VtxInclude +
                               JetQualInclude)
    for gr in groomedJetsList:
        includelist = []
        includelist_unique = []
        if 'Trim' in gr:
            includelist_unique += ['TrimConfigMoments']
            includelist += ['jsObsblock']
            if 'Topo' in parentJets:
                includelist += [
                    'OriginIndexBlock', 'EMScale', 'ConstituentScale',
                    'elecblockindex', 'muonblockindex'
                ]
            elif 'Truth' in parentJets:
                includelist += ['TruthParticleLeptonblockindex']
            elif 'Track' in parentJets:
                includelist += ['elecblockindex', 'muonblockindex']

            alg += MyGroomedJetCollectionD3PDObject(
                0,
                prefix='jet_' + parentJetsWithoutJSForGrooming + gr +
                '_config_',
                sgkey=parentJets + gr + 'Jets',
                include=includelist_unique)
        elif 'Filt' in gr:
            includelist += ['FiltMoments', 'jsObsblock']
            #includelist_unique += ['FiltConfigMoments']
        elif 'Prun' in gr:
            #includelist_unique += ['PrunConfigMoments']
            includelist += ['jsObsblock']

        alg += MyGroomedJetD3PDObject(
            0,
            prefix='jet_' + parentJetsWithoutJSForGrooming + gr + '_',
            sgkey=parentJets + gr + 'Jets',
            include=includelist,
            exclude=commonExcludeList)

    return alg
def addStandardMoments(jetcollname, moments=standardMoments, seq = AlgSequence(), jetAlgConfigDict={}):
    """Add a list of jet moment calculation for a given jet collection
      - jetcollname : string, the name of the jetcollection
      - moments     : list of string or function. string are expected to be some of the defaultMoment shortcuts. functions must return a configured moment tool
      - seq         : the AlgSequence to which the calculation is attached
      (- jetAlgConfigDict : dictionnary, used to pass JetAlgorithm configuration options when this addStandardMoments is called while configuring the JetAlgorithm.)
      Returns nothing.
      Effect : retrieve (or invoke if needed) the moment calculation algorithm dedicated to jetcollname (this can be a JetAlgorithm or a JetMomentCalculator),
               then add to this algorithm the moments requested in defaultMoment (only if they are not already scheduled).
    """

    if moments == []:
        # nothing to do. Return now to avoid any inconvenience
        return 
    
    # retrieve the main algorithm for this jet collection
    alg, existing_moments = findMainAlgForJetCollection(jetcollname, seq)


    # check if the alg is usable ---------
    if alg == 'unusable':
        _momlog.info("No usable algorithm for "+jetcollname+". No jet moments added")
        return
    if alg is None :
        # didn't find any alg. We can't add moments
        _momlog.error("Can't create momens for "+jetcollname+" : no such collection in input or no algorithms scheduled for it")
        _momlog.error("  ---> possible solution, invoke make_StandardJetGetter() before to schedule a JetAlgorithm for "+jetcollname)
        return

    isJetMomentCalc = isinstance(alg, JetMomentCalculator)
    
    # filter moment list according to jet collection and other conditions
    missing_moments =  checkMomentAvailability( jetcollname, set(moments) - existing_moments , jetAlgConfigDict )

    # enforce ghostAssoc, thus jet refinding, if area requested (could separate the 2 options with more config) when using a JetMomentCalculator
    if 'area' in missing_moments and ('ghostAssoc' not in existing_moments) and isJetMomentCalc:
        missing_moments.add('ghostAssoc')


    jetfinder = None
    # ghost association is very particular since it needs jet finding.  
    if 'ghostAssoc' in missing_moments:
        gAssoc = []
        from JetRec.TrackSelectionForJets import tracksAvailableForJets
        if tracksAvailableForJets() :
            gAssoc += ["TrackAssoc"]
        if rec.doTruth():
            gAssoc+=[ "TruthAssoc"]
        if isJetMomentCalc:
            from JetMomentTools.GhostAssociation import setupGhostAssociationTool
            gtool = setupGhostAssociationTool(jetcollname, gAssoc, seq=seq)
            tmpL = alg.CalculatorTools
            alg.CalculatorTools = [gtool] + tmpL
        else: # it's a JetAlgorithm
            tmpL = list(alg.AlgTools)
            from JetRec.JetGetters import adaptToolListToGhostAssociation
            alg.AlgTools = adaptToolListToGhostAssociation(tmpL, gAssoc, seq)
        if rec.doTruth():
            checkTruthParticleFilterPosition( seq, alg)

        jetfinder = alg.CalculatorTools['JetGhostAsso'].JetFindingSequence["JetFastJetFinder"] if isJetMomentCalc \
                    else alg.AlgTools[0].JetFindingSequence["JetFastJetFinder"]

        # we are done with ghostAssoc
        missing_moments.remove('ghostAssoc')
        existing_moments.add('ghostAssoc')
    else: # still need to retrieve the jetfinder
        if 'ghostAssoc' in existing_moments:
            jetfinder = alg.CalculatorTools['JetGhostAsso'].JetFindingSequence["JetFastJetFinder"] if isJetMomentCalc \
                        else alg.AlgTools[0].JetFindingSequence["JetFastJetFinder"]
        else:
            jetfinder = retrieveFinderTool( alg.CalculatorTools if isJetMomentCalc else alg.AlgTools)
        
    momentTools = []
    # Loop over requested moment types and set-up the related tools
    for momentType in missing_moments:
        if callable(momentType):
            # then assume a function returning a tool has been supplied
            func = momentType
        else:
            func = defaultMoments[momentType]
        # call the setup function, add the returned tool to the sequence 
        tool =  func( jetcollname, jetfinder, alg, seq, jetAlgConfigDict)
        if tool is not None: # some function just adapts existing tools
            momentTools.append(tool)

    # add the moment tools list to the relevant alg :
    if isJetMomentCalc:
        alg.CalculatorTools += momentTools
    else:
        alg.AlgTools += momentTools
    
    _specialMomentAlgDict[jetcollname] = (alg, missing_moments.union(existing_moments) )
    return alg
Beispiel #18
0
    egammaToolsConf.egammaCheckEnergyDepositTool,
    UseThrFmax=True,
    ThrF0max=0.9,
    ThrF1max=0.8,
    ThrF2max=0.98,
    ThrF3max=0.8)

from EMBremCollectionBuilder import egammaBremCollectionBuilder
from egammaTrackTools.egammaTrackToolsFactories import EMExtrapolationTools
EMBremCollectionBuilder = ToolFactory(
    egammaBremCollectionBuilder,
    name='EMBremCollectionBuilder',
    ExtrapolationTool=EMExtrapolationTools,
    OutputTrackContainerName=egammaKeys.outputTrackKey(),
    ClusterContainerName=egammaKeys.inputClusterKey(),
    DoTruth=rec.doTruth())

EMConversionBuilder = ToolFactory(
    egammaToolsConf.EMConversionBuilder,
    egammaRecContainerName=egammaKeys.outputEgammaRecKey(),
    ConversionContainerName=egammaKeys.outputConversionKey(),
    ExtrapolationTool=EMExtrapolationTools)

from ElectronPhotonSelectorTools import ElectronPhotonSelectorToolsConf
EGammaAmbiguityTool = ToolFactory(
    ElectronPhotonSelectorToolsConf.EGammaAmbiguityTool)

EMFourMomBuilder = ToolFactory(egammaToolsConf.EMFourMomBuilder)

#Tools for doing superclustering.
Beispiel #19
0
def truthParticleConfig (seq = AlgSequence(D3PDMakerFlags.PreD3PDAlgSeqName()),
                         sgkey = D3PDMakerFlags.TruthParticlesSGKey(),
                         prefix = '',
                         doPileup      = D3PDMakerFlags.TruthDoPileup(),
                         writePartons  = D3PDMakerFlags.TruthWritePartons(),
                         writeHadrons  = D3PDMakerFlags.TruthWriteHadrons(),
                         writeGeant    = D3PDMakerFlags.TruthWriteGeant(),
                         writeBHadrons = D3PDMakerFlags.TruthWriteBHadrons(),
                         writeBosons   = D3PDMakerFlags.TruthWriteBosons(),
                         writeBSM      = D3PDMakerFlags.TruthWriteBSM(),
                         writeTauHad   = D3PDMakerFlags.TruthWriteTauHad(),
                         writeEverything     = D3PDMakerFlags.TruthWriteEverything(),
                         writeFirstN         = D3PDMakerFlags.TruthWriteFirstN(),
                         writeBosonProducts  = D3PDMakerFlags.TruthWriteBosonProducts(),
                         writeBSMProducts    = D3PDMakerFlags.TruthWriteBSMProducts(),
                         writeTopAndDecays   = D3PDMakerFlags.TruthWriteTopAndDecays(),
                         writeAllLeptons     = D3PDMakerFlags.TruthWriteAllLeptons(),
                         writeStatus3        = D3PDMakerFlags.TruthWriteStatus3(),
                         geantPhotonPtThresh = D3PDMakerFlags.TruthGeantPhotonPtThresh(),
                         partonPtThresh      = D3PDMakerFlags.TruthPartonPtThresh(),):

    if not rec.doTruth():
        return

    # Is the container already in SG?
    if cfgKeyStore.isInInput ('TruthParticleContainer', sgkey):
        return

    algname = prefix + sgkey + 'Builder'
    if hasattr (seq, algname):
        return

    filtname = prefix + sgkey + 'Filter'

    seq += createMcAodBuilder\
           (algname,
            inMcEvtCollection = D3PDMakerFlags.TruthSGKey(),
            outMcEvtCollection = sgkey + '_GEN_D3PD',
            outTruthParticles = sgkey,
            filterTool = TruthD3PDAnalysis.TruthParticleFilterTool
              (filtname,
               DoPileup     = doPileup,
               WritePartons = writePartons,
               WriteHadrons = writeHadrons,
               WriteBHadrons = writeBHadrons,
               WriteGeant   = writeGeant,
               WriteBSM     = writeBSM,
               WriteBosons  = writeBosons,
               WriteTauHad  = writeTauHad,
               WriteEverything = writeEverything,
               WriteFirstN     = writeFirstN,
               WriteBosonProducts = writeBosonProducts,
               WriteBSMProducts = writeBSMProducts,
               WriteTopAndDecays = writeTopAndDecays,
               WriteAllLeptons = writeAllLeptons,
               WriteStatus3 = writeStatus3,
               GeantPhotonPtThresh = geantPhotonPtThresh,
               PartonPtThresh = partonPtThresh,
               ),
            cnvTool = CfgMgr.TruthParticleCnvTool('D3PDTruthParticleCnvTool'),
            )

    cfgKeyStore.addTransient ('TruthParticleContainer', sgkey)
    return
Beispiel #20
0
        jobproperties.egammaRecFlags.doEgammaForwardSeeded=False    
        treatException("Could not set up egammaForwardGetter. Switch it off !")
        egammaForwardGetter(disable=True)
else:
    jobproperties.egammaRecFlags.doEgammaForwardSeeded=False    
    try:
        from egammaRec.egammaForwardGetter import egammaForwardGetter
        egammaForwardGetter(disable=True)
    except Exception:
        pass

####################################################################
# Run association between true and reco objects
# It requires Truth and some of the above to be actually there

if not rec.doTruth(): 
  jobproperties.egammaRecFlags.doEgammaTruthAssociation = False

if jobproperties.egammaRecFlags.doEgammaTruthAssociation() and jobproperties.egammaRecFlags.doEgammaCaloSeeded() :
    try:
        from egammaRec.egammaTruthAssociationAlg import egammaTruthAssociationGetter
        egammaTruthAssociationGetter(ignoreExistingDataObject=True)
    except Exception:
        treatException("Could not set up egammaTruthAssociationAlg. Switched off !")
        egammaTruthAssociationGetter(disable=True)

####################################################################
# Lock egamma containers
if rec.doESD():

    #Decorate cluster with links to Topo clusters (when not superclusters)
Beispiel #21
0
from RecExConfig.RecFlags import rec 
from InDetRecExample.InDetJobProperties import InDetFlags
from JetRecFlags import jetFlags

# Function to display flag value and status.
def sflagstat(flag):
  return str(flag()) + " (status=" + str(flag.statusOn) + ")"

# Import the jet reconstruction control flags.
from JetRecFlags import jetFlags
from RecExConfig.ObjKeyStore import cfgKeyStore

# Skip truth if rec says it is absent.
# No action if someone has already set the flag.
jetlog.info( myname + "Initial useTruth: " + sflagstat(jetFlags.useTruth))
jetlog.info( myname + "     rec.doTruth: " + str(rec.doTruth()) )
if not jetFlags.useTruth.statusOn:
  jetFlags.useTruth = rec.doTruth()
jetlog.info( myname + "  Final useTruth: " + sflagstat(jetFlags.useTruth))

# Skip use of topoclusters if not built
# No action if someone has already set the flag.
jetlog.info( myname + "Initial use topoclusters: " + str(jetFlags.useTopo()))
if not jetFlags.useTopo.statusOn:
  jetFlags.useTopo = rec.doCalo()
jetlog.info( myname + "  Final use topoclusters: " + str(jetFlags.useTopo()))

# Skip tracks if tracks or vertices are not present in the job.
# No action if someone has already set the flag.
haveTracks = cfgKeyStore.isInTransient('xAOD::TrackParticleContainer','InDetTrackParticles')
haveVertices = cfgKeyStore.isInTransient("xAOD::VertexContainer","PrimaryVertices")
Beispiel #22
0
def configure(config):
    """Configure the calibration input and output.
    If both segmentsKey and segmentCombisKey are defined, segmentsKey has priority."""
    global topSequence, ToolSvc, MdtCalibTool, MuonSegmentToCalibSegment, MuonCalibAlg, MuonCalibTool, MuonCalibExtraTreeAlg, muonRecFlags
    log.info("Configuring with %s", config)

    calibMode = muonCalibFlags.Mode()
    #
    # Configure MuonSegmentToCalibSegment
    #
    try:
        MuonSegmentToCalibSegment = topSequence.MuonSegmentToCalibSegment
    except AttributeError:
        from MuonCalibPatRec.MuonCalibPatRecConf import MuonCalib__MuonSegmentToCalibSegment
        MuonSegmentToCalibSegment = MuonCalib__MuonSegmentToCalibSegment(
            "MuonSegmentToCalibSegment")
        topSequence += MuonSegmentToCalibSegment
    MuonSegmentToCalibSegment.UseCscSegments = muonRecFlags.doCSCs()

    # segmentsKey
    try:
        segmentsKey = config.segmentsKey
    except AttributeError:
        MuonSegmentToCalibSegment.ReadSegments = False
    else:
        MuonSegmentToCalibSegment.SegmentLocation = segmentsKey
        MuonSegmentToCalibSegment.ReadSegments = True
    # segmentCombisKey
    try:
        segmentCombisKey = config.segmentCombisKey
    except AttributeError:
        pass
    else:
        MuonSegmentToCalibSegment.SegmentCombiLocation = segmentCombisKey

    #
    # MuonCalibAlg
    #
    try:
        MuonCalibAlg = topSequence.MuonCalibAlg
    except AttributeError:
        from MuonCalibAlgs.MuonCalibAlgsConf import MuonCalib__MuonCalibAlg
        MuonCalibAlg = MuonCalib__MuonCalibAlg("MuonCalibAlg")
        topSequence += MuonCalibAlg
    if beamFlags.beamType() == 'singlebeam' or beamFlags.beamType(
    ) == 'cosmics':
        MuonCalibAlg.addTriggerTag = False
    else:
        MuonCalibAlg.addTriggerTag = recFlags.doTrigger()
    MuonCalibAlg.doMDTs = muonRecFlags.doMDTs()
    MuonCalibAlg.doCSCs = muonRecFlags.doCSCs()
    MuonCalibAlg.doRPCs = muonRecFlags.doRPCs()
    MuonCalibAlg.doTGCs = muonRecFlags.doTGCs()
    try:
        eventTag = config.eventTag
    except AttributeError:
        pass
    else:
        MuonCalibAlg.EventTag = eventTag

    MuonCalibAlg.doTruth = recFlags.doTruth()

    if calibMode == 'ntuple' or calibMode == 'trackNtuple':
        from MuonCalibTools.MuonCalibToolsConf import MuonCalib__PatternNtupleMaker
        MuonCalibTool = MuonCalib__PatternNtupleMaker()
        if calibMode == 'trackNtuple':
            if muonRecFlags.doSegmentsOnly():
                log.warning(
                    "Making ntuple instead of trackNtuple because making segments only"
                )
                muonCalibFlags.Mode = 'ntuple'
            else:
                MuonCalibTool.DelayFinish = True
                try:
                    MuonCalibExtraTreeAlg = topSequence.MuonCalibExtraTreeAlg
                except AttributeError:
                    from MuonCalibExtraTreeAlg.MuonCalibExtraTreeAlgConf import MuonCalib__MuonCalibExtraTreeAlg
                    MuonCalibExtraTreeAlg = MuonCalib__MuonCalibExtraTreeAlg(
                        "MuonCalibExtraTreeAlg")
                    MuonCalibExtraTreeAlg.NtupleName = "PatternNtupleMaker"
                    topSequence += MuonCalibExtraTreeAlg

                # doPhi
                try:
                    doPhi = config.doPhi
                except AttributeError:
                    doPhi = False
                MuonCalibExtraTreeAlg.doPhi = doPhi
                # doTracks
                try:
                    doTracks = config.doTracks
                except AttributeError:
                    doTracks = False
                MuonCalibExtraTreeAlg.doTracks = doTracks
                # patternsKey
                try:
                    patternsKey = config.patternsKey
                except AttributeError:
                    pass
                else:
                    MuonCalibExtraTreeAlg.PatternLocation = patternsKey
                # tracksKey
                try:
                    tracksKey = config.tracksKey
                except AttributeError:
                    pass
                else:
                    MuonCalibExtraTreeAlg.TrackLocation = tracksKey

    else:  # other calib modes
        from MdtCalibTools.MdtCalibToolsConf import MuonCalib__MdtCalibTool
        MuonCalibTool = MuonCalib__MdtCalibTool()
        if calibMode == 'regionNtuple':
            from MdtCalibTools.MdtCalibToolsConf import MuonCalib__MdtCalibNtupleMakerTool
            MdtCalibTool = MuonCalib__MdtCalibNtupleMakerTool()
        else:
            raise RuntimeError("Unknown Muon Calibration Mode: %r" % calibMode)

        ToolSvc += MdtCalibTool
        MuonCalibTool.MdtCalibTool = MdtCalibTool

    ToolSvc += MuonCalibTool
    MuonCalibAlg.MuonCalibTool = MuonCalibTool
Beispiel #23
0
"""
Setup Vertex Group D3PD options for various objects.
"""

from RecExConfig.RecFlags import rec
from InDetD3PDMaker.VertexD3PDAnalysisFlags import VertexD3PDAnalysisFlags
from InDetD3PDMaker.VertexD3PDAnalysisKeys import VertexD3PDAnalysisKeys

from D3PDMakerConfig.D3PDMakerFlags  import D3PDMakerFlags
from TrackD3PDMaker.TrackD3PDMakerFlags import TrackD3PDFlags

### Set flags of D3PD fillers, etc..
## First our own flags
# Set truth flag
VertexD3PDAnalysisFlags.useTruth = rec.doTruth()
# Set storegate collection names (where default may be wrong)
from InDetRecExample.InDetKeys import InDetKeys
if rec.readESD():
  InDetKeys.UnslimmedTracks              = 'Tracks'
  InDetKeys.UnslimmedTracksTruth         = 'TrackTruthCollection'
if rec.readAOD():
  InDetKeys.Tracks = InDetKeys.TrackParticles()
  InDetKeys.TracksTruth = InDetKeys.TrackParticlesTruth()
  #print "InDetKeys.Tracks = "+InDetKeys.Tracks()
  #print "InDetKeys.TracksTruth = "+InDetKeys.TracksTruth()  
  InDetKeys.McEventCollection = 'GEN_AOD'
#print D3PDMakerFlags

# Set default prefix for existing vertex collection
from InDetRecExample.InDetJobProperties import InDetFlags
Beispiel #24
0
def muonD3PD(file,
             tuplename='muon',
             seq=topSequence,
             D3PDSvc='D3PD::RootD3PDSvc',
             streamNameRoot=None,
             **kw):

    alg = D3PDMakerCoreComps.MakerAlg(tuplename,
                                      seq,
                                      file=file,
                                      D3PDSvc=D3PDSvc,
                                      streamNameRoot=streamNameRoot)
    alg += EventInfoD3PDObject(**_args(10, 'EventInfo', kw))

    if D3PDMakerFlags.DoTrigger():

        # Segregate trigger decision flags in a separate tree.
        trigalg = D3PDMakerCoreComps.MakerAlg(tuplename + 'TrigDec',
                                              seq,
                                              file=file,
                                              D3PDSvc=D3PDSvc,
                                              streamNameRoot=streamNameRoot)
        trigalg += EventInfoD3PDObject(0)
        alg.trigDecisionTree = trigalg

    # Muon blocks
    alg += MuonD3PDObject(**_args(
        10, 'Muons', kw, sgkey='Muons', prefix='mu_', allowMissing=True))

    if not MuonD3PDFlags.doNewChainOnly():

        alg += MuonD3PDObject(**_args(10,
                                      'MuidMuon',
                                      kw,
                                      sgkey='MuidMuonCollection',
                                      prefix='mu_muid_',
                                      allowMissing=True))
        alg += MuonD3PDObject(**_args(10,
                                      'StacoMuon',
                                      kw,
                                      sgkey='StacoMuonCollection',
                                      prefix='mu_staco_',
                                      allowMissing=True))
        alg += MuonD3PDObject(**_args(10,
                                      'CaloMuon',
                                      kw,
                                      sgkey='CaloMuonCollection',
                                      prefix='mu_calo_',
                                      allowMissing=True))

    # Muon segments
    alg += MuonSegmentD3PDObject(**_args(10,
                                         'MuonSeg',
                                         kw,
                                         sgkey='MuonSegments',
                                         prefix='muonseg_',
                                         include=['MuonSegmentT0'],
                                         exclude=['MuonboySegmentT0'],
                                         allowMissing=True))

    if not MuonD3PDFlags.doNewChainOnly():

        alg += MuonSegmentD3PDObject(**_args(10,
                                             'MooreSeg',
                                             kw,
                                             sgkey='MooreSegments',
                                             prefix='mooreseg_',
                                             include=['MooreSegmentT0'],
                                             exclude=['MuonboySegmentT0'],
                                             allowMissing=True))

        alg += MuonSegmentD3PDObject(**_args(10,
                                             'MboySeg',
                                             kw,
                                             sgkey='ConvertedMBoySegments',
                                             prefix='mboyseg_',
                                             include=['MuonboySegmentT0'],
                                             exclude=['MooreSegmentT0'],
                                             allowMissing=True))

        alg += MuonSegmentD3PDObject(**_args(10,
                                             'MuGirlSeg',
                                             kw,
                                             sgkey='MuGirlSegments',
                                             prefix='mgseg_',
                                             include=['MooreSegmentT0'],
                                             exclude=['MuonboySegmentT0'],
                                             allowMissing=True))

    from MuonD3PDMaker.MuonSpShowerD3PDObject import MuonSpShowerD3PDObject
    alg += MuonSpShowerD3PDObject(
        **_args(10, 'MuonSpShower', kw, allowMissing=True))

    # Truth
    if rec.doTruth():
        from MuonD3PDMaker.TruthMuonD3PDObject import TruthMuonD3PDObject
        alg += TruthMuonD3PDObject(
            **_args(2, 'TruthMuon', kw, allowMissing=True))

        from MuonD3PDMaker.TrackRecordD3PDObject import TrackRecordD3PDObject
        alg += TrackRecordD3PDObject(**_args(10, 'MuonEntryLayerFilter', kw))

    # Trigger
    if D3PDMakerFlags.DoTrigger():
        alg += MuonTriggerBitsD3PDObject(**_args(2, 'MuonTriggerBits', kw))

    alg.MetadataTools += [LBMetadataConfig()]

    return alg
Beispiel #25
0
AODFlags.FastTrackParticle = False
AODFlags.Tau = False
AODFlags.Trigger = False
AODFlags.ParticleJet = False

#if primDPD.WritePreselectElectronStreamFromESDInput.writeAODContent :
#    rec.doAOD.set_Value_and_Lock(True)
#    rec.doAODCaloCells.set_Value_and_Lock(True)
#    AODFlags.Photon             = True
#    AODFlags.Electron           = True
#    AODFlags.egammaTrackSlimmer = True
#    pass

#These containers do not exists in the ESD. They have to be created on the fly if using AOD-based tools later on.
#AODFlags.Muon        = True
AODFlags.TruthParticleJet = rec.doTruth()
AODFlags.SpclMC = rec.doTruth()

#==================================
# Mandatory for ESD->DPD
#==================================
rec.doDPD = True
rec.readESD = True
rec.readAOD = False
rec.readRDO = False
rec.DPDMakerScripts.append("PrimaryDPDMaker/PrimaryDPDMaker.py")

## Write the used options to the log file
print(AODFlags)
print(rec)
Beispiel #26
0
from QcdD3PDMaker.QcdD3PDMakerFlags import QcdD3PDMakerFlags
from BTagging.BTaggingFlags import BTaggingFlags
from JetRec.JetRecFlags import jetFlags
from RecExConfig.RecFlags import rec

BTaggingFlags.Jets = []
#BTaggingFlags.Jets += ['AntiKt4TopoEMJets','AntiKt6TopoEMJets',
#                       'AntiKt4LCTopoJets','AntiKt6LCTopoJets'] # for the default jets
if rec.doTruth():
    BTaggingFlags.Jets += ['AntiKt4Truth']
if rec.doTruth() and QcdD3PDMakerFlags.doRecTruthJet():
    BTaggingFlags.Jets += [
        'AntiKt4TruthNew', 'AntiKt5TruthNew', 'AntiKt6TruthNew',
        'AntiKt4TruthWithNoInt', 'AntiKt6TruthWithNoInt',
        'AntiKt4TruthWithMuNoInt', 'AntiKt6TruthWithMuNoInt'
    ]
if QcdD3PDMakerFlags.doRecJet() and QcdD3PDMakerFlags.doTopoEMJet():
    BTaggingFlags.Jets += ['AntiKt4TopoEMNew', 'AntiKt6TopoEMNew']
if QcdD3PDMakerFlags.doRecJet() and QcdD3PDMakerFlags.doLCTopoJet():
    BTaggingFlags.Jets += [
        'AntiKt4LCTopoNew', 'AntiKt5LCTopoNew', 'AntiKt6LCTopoNew'
    ]

BTaggingFlags.JetsWithInfoPlus = BTaggingFlags.Jets[:]
#BTaggingFlags.CalibrationTag="BTagCalibALL-07-02" # up to now it is not linked to the global flag

BTaggingFlags.CalibrationChannelAliases += [
    'AntiKt4Truth->AntiKt4TopoEM',
    'AntiKt4TruthNew->AntiKt4TopoEM',
    'AntiKt5TruthNew->AntiKt4TopoEM',
    'AntiKt6TruthNew->AntiKt6TopoEM',
Beispiel #27
0
def TrackD3PDObject(_label='trkTrack',
                    _prefix='trkTrack_',
                    _sgkey='Tracks',
                    _object_name='TrackD3PDObject',
                    typeName='TrackCollection',
                    vertexTarget='vx',
                    vertexPrefix='vx_',
                    vertexSGKey='VxPrimaryCandidate',
                    truthTarget='mc',
                    truthPrefix='mc_',
                    detailedTruthPrefix='detailed_mc_',
                    truthMapKey='TrackTruthCollection',
                    SGKeyForTruth='Tracks',
                    detailedTruthMapKey='DetailedTrackTruth',
                    SGKeyForDetailedTruth='Tracks',
                    flags=TrackD3PDFlags):

    object = make_SGDataVector_D3PDObject (
        typeName,
        _sgkey,
        _prefix,
        _object_name,
        default_allowMissing = True,
        default_label = _label,
        allow_args = ['GenParticleTarget',
                      'TruthParticleTarget',
                      'storeTruthInfo',
                      'storeTrackMomentum',
                      'trackParametersAtGlobalPerigeeLevelOfDetails',
                      'trackParametersAtPrimaryVertexLevelOfDetails',
                      'trackParametersAtBeamSpotLevelOfDetails',
                      'trackParameterAtBeamLineLevelOfDetails',
                      'storeDiagonalCovarianceAsErrors',
                      'storeTrackParametersAtCalo',
                      'storeTrackParametersAtCalo2ndLayer',
                      'storeTrackFitQuality',
                      'storeTrackPredictionAtBLayer',
                      'storeTrackInfo',
                      'storeVertexAssociation',
                      'storeDetailedTruth',
                      'storeBLayerHitsOnTrack',
                      'storePixelHitsOnTrack',
                      'storeSCTHitsOnTrack',
                      'storeTRTHitsOnTrack',
                      'storeMDTHitsOnTrack',
                      'storeCSCHitsOnTrack',
                      'storeRPCHitsOnTrack',
                      'storeTGCHitsOnTrack',
                      'storeBLayerOutliersOnTrack',
                      'storePixelOutliersOnTrack',
                      'storeSCTOutliersOnTrack',
                      'storeTRTOutliersOnTrack',
                      'storeMDTOutliersOnTrack',
                      'storeCSCOutliersOnTrack',
                      'storeRPCOutliersOnTrack',
                      'storeTGCOutliersOnTrack',
                      'storeBLayerHolesOnTrack',
                      'storePixelHolesOnTrack',
                      'storeSCTHolesOnTrack',
                      'storeTRTHolesOnTrack',
                      'storeMDTHolesOnTrack',
                      'storeCSCHolesOnTrack',
                      'storeRPCHolesOnTrack',
                      'storeTGCHolesOnTrack',
                      'storePullsAndResiduals',
                      'storeTrackUnbiasedIPAtPV',
                      'storeHitTruthMatching',
                      'storeTrackSummary',
                      'doTruth',
                      ])

    if typeName=='TrackCollection':
        PerigeeAssociationTool       = TrackD3PDMaker.TrkTrackPerigeeAssociationTool
        PerigeeAtPVAssociationTool   = TrackD3PDMaker.TrkTrackPerigeeAtPVAssociationTool
        PerigeeAtBSAssociationTool   = TrackD3PDMaker.TrkTrackPerigeeAtBSAssociationTool
        FitQualityAssociationTool    = TrackD3PDMaker.TrkTrackFitQualityAssociationTool
        TrackSummaryAssociationTool  = TrackD3PDMaker.TrkTrackTrackSummaryAssociationTool
        TrackInfoAssociationTool     = TrackD3PDMaker.TrkTrackInfoAssociationTool
        HitAssociationTool           = TrackD3PDMaker.TrkTrackTSOAssociationTool
        VertexAssociationTool        = TrackD3PDMaker.TrkTrackVertexAssociationTool
        TruthAssociationTool         = TrackD3PDMaker.TrkTrackTruthAssociationTool
        DetailedTruthAssociationTool = TrackD3PDMaker.TrkTrackDetailedTruthAssociationTool
        ParametersAtBLFillerTool     = TrackD3PDMaker.TrkTrackParametersAtBLFillerTool
        
    if typeName=='Rec::TrackParticleContainer':
        PerigeeAssociationTool       = TrackD3PDMaker.TrackParticlePerigeeAtOOAssociationTool
        PerigeeAtPVAssociationTool   = TrackD3PDMaker.TrackParticlePerigeeAtPVAssociationTool
        PerigeeAtBSAssociationTool   = TrackD3PDMaker.TrackParticlePerigeeAtBSAssociationTool
        FitQualityAssociationTool    = TrackD3PDMaker.TrackParticleFitQualityAssociationTool
        TrackSummaryAssociationTool  = TrackD3PDMaker.TrackParticleTrackSummaryAssociationTool
        TrackInfoAssociationTool     = TrackD3PDMaker.TrackParticleInfoAssociationTool
        HitAssociationTool           = TrackD3PDMaker.TrackParticleTSOAssociationTool
        VertexAssociationTool        = TrackD3PDMaker.TrackParticleVertexAssociationTool
        TruthAssociationTool         = TrackD3PDMaker.TrackParticleTruthAssociationTool
        DetailedTruthAssociationTool = TrackD3PDMaker.TrackParticleDetailedTruthAssociationTool
        ParametersAtBLFillerTool     = TrackD3PDMaker.TrackParticleParametersAtBLFillerTool

    # This generates ERROR messages.  Disabled for now.
    #object.defineBlock(1, "Isolation", TrackD3PDMaker.TrackIsolationFillerTool)


    ## default perigee (at (0,0,0))
    PerigeeAssoc = PerigeeAssociation\
                   (object,
                    PerigeeAssociationTool, "GlobalPerigee",
                    fillMomName = 'storeTrackMomentum',
                    levelName = 'trackParametersAtGlobalPerigeeLevelOfDetails')

    # Unbiased impact parameters at PV
    PerigeeAssoc.defineBlock (flagTestLOD('storeTrackUnbiasedIPAtPV',
                                          flags, _get_estimator),
                              _prefix+"IPEstimate",
                              TrackD3PDMaker.PerigeeUnbiasedIPAtPVFillerTool,
                              # Filled in by LOD function.
                              TrackToVertexIPEstimator=None,
                              Prefix = 'IPEstimate_',
                              Suffix = '_wrtPV')

    # perigee at Primary Vertex
    PerigeeAtPVAssoc = PerigeeAssociation\
                       (object,
                        PerigeeAtPVAssociationTool, "PerigeeAtPV",
                        suffix='_wrtPV',
                        levelName = 'trackParametersAtPrimaryVertexLevelOfDetails')

    # perigee at Beam Spot
    PerigeeAtBSAssoc = PerigeeAssociation\
                       (object,
                        PerigeeAtBSAssociationTool, "PerigeeAtBS",
                        suffix='_wrtBS', 
                        levelName = 'trackParametersAtBeamSpotLevelOfDetails')

    # perigee at Beam Line
    from TrackD3PDMaker.PerigeeAssociation import perigeeLOD
    # Not implemented in TrackToVertex.
    #object.defineBlock(perigeeLOD ('trackParametersAtBeamLineLevelOfDetails>0',
    #                               flags),
    #                   _prefix+"ParametersAtBL",
    #                   ParametersAtBLFillerTool,
    #                   levelOfDetails = deferFlag ('trackParametersAtBeamLineLevelOfDetails', flags))

    # parameters at Calo
    object.defineBlock(flagTestLOD('storeTrackParametersAtCalo', flags),
                       _prefix+"ParametersAtCalo",
                       ParametersAtCaloFillerTool)

    # parameters at Calo 2nd layer
    object.defineBlock(flagTestLOD('storeTrackParametersAtCalo2ndLayer', flags),
                       _prefix+"ParametersAtCalo2ndLayer",
                       ParametersAtCaloFillerTool,
                       Sampling = 1,
                       Suffix = '2ndLayer')

    # Fit Quality
    FitQualityAssoc = SimpleAssociation\
                      (object,
                       FitQualityAssociationTool,
                       level = flagTestLOD('storeTrackFitQuality', flags))
        
    FitQualityAssoc.defineBlock(flagTestLOD('storeTrackFitQuality', flags),
                                _prefix+'FitQuality',
                                TrackD3PDMaker.TrackFitQualityFillerTool)

    # Track Summary
    TrackSummaryAssoc = SimpleAssociation\
                        (object,
                         TrackSummaryAssociationTool,
                         level = flagTestLOD('storeTrackSummary', flags))

    TrackSummaryAssoc.defineBlock(flagTestLOD('storeTrackSummary', flags),
                                  _prefix+'TrackSummary',
                                  TrackD3PDMaker.TrackTrackSummaryFillerTool,
                                  FullInfo = flags.storeTrackSummary.FullInfo,
                                  IDHits = flags.storeTrackSummary.IDHits,
                                  IDHoles = flags.storeTrackSummary.IDHoles,
                                  IDSharedHits = flags.storeTrackSummary.IDSharedHits,
                                  IDOutliers = flags.storeTrackSummary.IDOutliers,
                                  PixelInfoPlus = flags.storeTrackSummary.PixelInfoPlus,
                                  SCTInfoPlus = flags.storeTrackSummary.SCTInfoPlus,
                                  TRTInfoPlus = flags.storeTrackSummary.TRTInfoPlus,
                                  InfoPlus = flags.storeTrackSummary.InfoPlus,
                                  MuonHits = flags.storeTrackSummary.MuonHits,
                                  MuonHoles = flags.storeTrackSummary.MuonHoles,
                                  ExpectBLayer = flags.storeTrackSummary.ExpectBLayer,
                                  HitSum = flags.storeTrackSummary.HitSum,
                                  HoleSum = flags.storeTrackSummary.HoleSum,
                                  HitPattern = flags.storeTrackSummary.HitPattern,
                                  SiHits = flags.storeTrackSummary.SiHits,
                                  TRTRatio = flags.storeTrackSummary.TRTRatio,
                                  PixeldEdx = flags.storeTrackSummary.PixeldEdx,
                                  ElectronPID = flags.storeTrackSummary.ElectronPID)
        
    # Track Info
    TrackInfoAssoc = SimpleAssociation\
                     (object,
                      TrackInfoAssociationTool,
                      level = flagTestLOD('storeTrackInfo', flags))
        
    TrackInfoAssoc.defineBlock(flagTestLOD('storeTrackInfo', flags),
                               _prefix+'TrackInfo',
                               TrackD3PDMaker.TrackInfoFillerTool)

    ## B-Layer predictions
    from AthenaCommon.AppMgr import ToolSvc
    if hasattr(ToolSvc, 'InDetRecTestBLayerTool'):
        BLayerPredictionAssoc = SimpleAssociation\
                                (object,
                                 PerigeeAssociationTool,
                                 prefix = 'blayerPrediction_',
                                 blockname = _prefix+'BLayerInfoAssoc',
                                 level = flagTestLOD('storeTrackPredictionAtBLayer', flags))

        BLayerPredictionAssoc.defineBlock (flagTestLOD('storeTrackPredictionAtBLayer', flags),
                                           _prefix+'BLayerInfo',
                                           TrackD3PDMaker.PerigeeBLPredictionFillerTool,
                                           InDetTestBLayerTool = ToolSvc.InDetRecTestBLayerTool)

    tsos_table = [
        ('storeBLayerHitsOnTrack', 'BLayer_hit_', 'getBLayerMeasurements'),
        ('storePixelHitsOnTrack',  'Pixel_hit_',  'getPixelMeasurements'),
        ('storeSCTHitsOnTrack',    'SCT_hit_',    'getSCTMeasurements'),
        ('storeTRTHitsOnTrack',    'TRT_hit_',    'getTRTMeasurements'),
        ('storeMDTHitsOnTrack',    'MDT_hit_',    'getMDTMeasurements'),
        ('storeCSCHitsOnTrack',    'CSC_hit_',    'getCSCMeasurements'),
        ('storeRPCHitsOnTrack',    'RPC_hit_',    'getRPCMeasurements'),
        ('storeTGCHitsOnTrack',    'TGC_hit_',    'getTGCMeasurements'),

        ('storeBLayerOutliersOnTrack', 'BLayer_outlier_', 'getBLayerOutliers'),
        ('storePixelOutliersOnTrack',  'Pixel_outlier_',  'getPixelOutliers'),
        ('storeSCTOutliersOnTrack',    'SCT_outlier_',    'getSCTOutliers'),
        ('storeTRTOutliersOnTrack',    'TRT_outlier_',    'getTRTOutliers'),
        ('storeMDTOutliersOnTrack',    'MDT_outlier_',    'getMDTOutliers'),
        ('storeCSCOutliersOnTrack',    'CSC_outlier_',    'getCSCOutliers'),
        ('storeRPCOutliersOnTrack',    'RPC_outlier_',    'getRPCOutliers'),
        ('storeTGCOutliersOnTrack',    'TGC_outlier_',    'getTGCOutliers'),

        ('storeBLayerHolesOnTrack',    'BLayer_hole_',    'getBLayerHoles'),
        ('storePixelHolesOnTrack',     'Pixel_hole_',     'getPixelHoles'),
        ('storeSCTHolesOnTrack',       'SCT_hole_',       'getSCTHoles'),
        ('storeTRTHolesOnTrack',       'TRT_hole_',       'getTRTHoles'),
        ('storeMDTHolesOnTrack',       'MDT_hole_',       'getMDTHoles'),
        ('storeCSCHolesOnTrack',       'CSC_hole_',       'getCSCHoles'),
        ('storeRPCHolesOnTrack',       'RPC_hole_',       'getRPCHoles'),
        ('storeTGCHolesOnTrack',       'TGC_hole_',       'getTGCHoles'),
        ]

    for flag, pref, opt in tsos_table:
        TrackStateOnSurfaceAssociation (object,
                                        HitAssociationTool,
                                        pref, _prefix + pref,
                                        flagTestLOD(flag, flags),
                                        fillPullsName = 'storePullsAndResiduals' if flag.find('Holes')<0 else 'False',
                                        **{opt : True})


    # Vertex association
    VertexAssoc = IndexAssociation  (
        object,
        VertexAssociationTool, vertexTarget,
        prefix = vertexPrefix,
        VxSGKey = vertexSGKey,
        level = flagTestLOD('storeVertexAssociation', flags))

    # Truth matching
    if rec.doTruth():
        # Simple truth matching

        # Allow associating to either GenParticles or TruthParticles.
        def _levelAssocToGP (reqlev, args, hookargs):
            if reqlev < 1: return False
            if hookargs.get ('TruthParticleTarget'): return False
            if hookargs.get ('GenParticleTarget'):
                args['Target'] = hookargs.get ('GenParticleTarget')
            return True
        def _levelAssocToTP (reqlev, args, hookargs):
            if reqlev < 1: return False
            tpt = hookargs.get ('TruthParticleTarget')
            if not tpt: return False
            args['Target'] = tpt
            return True

        TruthAssoc = SimpleAssociation\
                     (object,
                      TruthAssociationTool,
                      prefix = truthPrefix,
                      SGKey = SGKeyForTruth,
                      MapKey = truthMapKey,
                      level = flagTestLOD('doTruth and storeHitTruthMatching', flags))
        TruthAssoc.defineBlock (_levelAssocToGP,
                                'TruthAssocIndex',
                                D3PDMakerCoreComps.IndexFillerTool,
                                Target = truthTarget)

#        TruthAssocTP = SimpleAssociation\
#                       (TruthAssoc,
#                        TruthD3PDMaker.GenParticleTruthParticleAssociationTool,
#                        level = _levelAssocToTP)
#        TruthAssocTP.defineBlock (_levelAssocToTP,
#                                  'TruthAssocIndexTP',
#                                  D3PDMakerCoreComps.IndexFillerTool,
#                                  Target = truthTarget)

#        _levelTruthInfo = flagTestLOD ('doTruth and storeHitTruthMatching and reqlev>=2 and storeTruthInfo', flags)


#        TruthAssoc.defineBlock (_levelTruthInfo,
#                                'TruthPerigee',
#                                TruthD3PDMaker.GenParticlePerigeeFillerTool)
#
#        if typeName == 'Rec::TrackParticleContainer':
#            from TruthD3PDMaker.MCTruthClassifierConfig import \
#                 D3PDMCTruthClassifier
#            object.defineBlock \
#                   (_levelTruthInfo,
#                    'MCClassification',
#                    TrackD3PDMaker.TrackParticleMCClassifierFillerTool,
#                    prefix = 'mc_',
#                    Classifier = D3PDMCTruthClassifier)


        # Detailed truth matching
        DetailedTruthAssoc = IndexMultiAssociation (
            object,
            DetailedTruthAssociationTool, truthTarget,
            prefix = detailedTruthPrefix,
            level = flagTestLOD('doTruth and storeDetailedTruth and reqlev>=1', flags),
            SGKey = SGKeyForDetailedTruth,
            MapKey = detailedTruthMapKey)
    
#    if typeName == 'Rec::TrackParticleContainer':

#        from TrackD3PDMaker.trackIsolationTool import \
#             trackIsolationTool_500MeV, \
#             trackIsolationTool_1GeV, \
#             trackIsolationTool_2GeV, \
#             trackIsolationTool_3GeV, \
#             trackIsolationTool_4GeV, \
#             trackIsolationTool_5GeV, \
#             trackIsolationTool_3GeV_hitschi

#        from TrackD3PDMaker.addTrackIsolationCones import addTrackIsolationCones
#        addTrackIsolationCones (
#            object, 'Isolation', level=999,
#            sizes = [0.2, 0.3, 0.4],
#            caloIsoVar = 'cone%%_caloIso',
#            trackIsoVar = 'cone%%_trackIso',
#            nTrackIsoVar = 'cone%%_nTrackIso',
#            isolationTool = DeferArg('tool()',
#                                    tool=trackIsolationTool_500MeV))

#        iso4blocks = [[trackIsolationTool_1GeV, '1GeV', 'ptmin1gev_'],
#                      [trackIsolationTool_2GeV, '2GeV', 'ptmin2gev_'],
#                      [trackIsolationTool_3GeV, '3GeV', 'ptmin3gev_'],
#                      [trackIsolationTool_3GeV_hitschi, '3GeV_hitschi', 'ptmin3gev_hitschi_'],
#                      [trackIsolationTool_4GeV, '4GeV', 'ptmin4gev_'],
#                      [trackIsolationTool_5GeV, '5GeV', 'ptmin5gev_'],
#                      ]
#        for (tool, blksuff, varsuff) in iso4blocks:
#            object.defineBlock (999, 'Isolation_40_' + blksuff,
#                                TrackD3PDMaker.TrackIsolationFillerTool,
#                                ConeSize = 0.4,
#                                prefix = 'cone40_' + varsuff,
#                                TrackIsolationTool = DeferArg('tool()',
#                                                              tool=tool))

    return object
Beispiel #28
0
from AthenaCommon.CfgGetter import getPublicTool
getPublicTool("MuonCombinedInDetDetailedTrackSelectorTool")

from MuonPhysValMonitoring.MuonPhysValMonitoringConf import MuonPhysValMonitoring__MuonPhysValMonitoringTool
from RecExConfig.RecFlags import rec as recFlags

tool1 = MuonPhysValMonitoring__MuonPhysValMonitoringTool(name='slowmuphysval')
tool1.IsData = not recFlags.doTruth()

#
tool1.MuonContainerName = ''
# Must be blank for SlowMuons
tool1.SlowMuonContainerName = 'SlowMuons'
tool1.MuonTruthParticleContainerName = 'MuonTruthParticles'
tool1.DoBinnedResolutionPlots = False

tool1.TrackContainerName = ''
tool1.FwdTrackContainerName = ''
tool1.MuonTrackContainerName = ''
tool1.MuonExtrapolatedTrackContainerName = ''
tool1.MuonOnlyExtrapolatedTrackContainerName = ''
tool1.MuonSegmentContainerName = ''

#Select Muon Working Points... (empty: all, -1: None, 0: Tight, 1: Medium, 2: Loose, 3: VeryLoose)
tool1.SelectMuonWorkingPoints = [-1]

#Select Muon Authors... (empty: all authors, 0: None, 1: combined, 2: STACO, 4: MuTagIMO, 5: Standalone, 6: MuGirl, 8: CaloTag)
tool1.SelectMuonAuthors = [
    0
]  # only one author is defined in this case... no need to specify
from RecExConfig.RecFlags import rec as recFlags
from MuonTrackPerformance.MuonTrackPerformanceConf import MuonMakeTrackNtuple, MuonMakeSegmentNtuple
from MuonRecExample import MuonRecTools
MuonRecTools.loadAll()

CBNT_AthenaAware += MuonMakeTrackNtuple(doTruth=recFlags.doTruth())
CBNT_AthenaAware += MuonMakeSegmentNtuple()
Beispiel #30
0
def evgenD3PD(file,
              tuplename='evgen',
              seq=topSequence,
              D3PDSvc='D3PD::RootD3PDSvc'):

    #--------------------------------------------------------------------------
    # Configuration
    #--------------------------------------------------------------------------
    if rec.doTruth():
        # compatibility with jets
        from JetRec.JetRecFlags import jobproperties as jobpropjet
        jobpropjet.JetRecFlags.inputFileType = "GEN"

        # Build list of particles stored in D3PD
        truthParticleConfig(seq)

        # Build list of particles used to jet building
        # Be careful, if doExcludeWZdecays == True,
        # then W and Z decays (including electrons, QCD FSRs) are excluded from jet building
        doExcludeWZdecays = True
        mysuffix = 'WZ' if doExcludeWZdecays else ''
        TruthJetFilterConfig(seq,
                             writePartons=True,
                             writeHadrons=True,
                             excludeWZdecays=doExcludeWZdecays)

        # PartonJetConfig is used to build parton-level jets
        # PartonJetConfig requires JetSimTools-00-01-22 or higher
        PartonJetConfig(doPythia=True,
                        doHerwig=False,
                        finder='AntiKt',
                        size=0.4,
                        suffix=mysuffix,
                        inputCollections=['FilteredD3PDTruth'])
        PartonJetConfig(doPythia=True,
                        doHerwig=False,
                        finder='AntiKt',
                        size=0.6,
                        suffix=mysuffix,
                        inputCollections=['FilteredD3PDTruth'])

        # Build truth particle (hadron-level) jets
        # flags for AOD
        from ParticleBuilderOptions.AODFlags import AODFlags
        AODFlags.MissingEtTruth = True
        AODFlags.TruthParticleJet = True
        AODFlags.McEventKey = "GEN_EVENT"
        # The function that makes the truth jets, with appropriate arguments
        antikt4truthAlg = make_StandardJetGetter(
            'AntiKt',
            0.4,
            'Truth',
            globalSuff=mysuffix,
            disable=False,
            includeMuons=True,
            useInteractingOnly=False).jetAlgorithmHandle()
        antikt4truthAlg.AlgTools['InputToJet'].InputCollectionKeys = [
            'FilteredD3PDTruth'
        ]
        antikt6truthAlg = make_StandardJetGetter(
            'AntiKt',
            0.6,
            'Truth',
            globalSuff=mysuffix,
            disable=False,
            includeMuons=True,
            useInteractingOnly=False).jetAlgorithmHandle()
        antikt6truthAlg.AlgTools['InputToJet'].InputCollectionKeys = [
            'FilteredD3PDTruth'
        ]
        if doExcludeWZdecays:
            # Reconstruct standard ATLAS truth jets
            antikt4truthAlgStd = make_StandardJetGetter(
                'AntiKt', 0.4, 'Truth', disable=False).jetAlgorithmHandle()
            antikt6truthAlgStd = make_StandardJetGetter(
                'AntiKt', 0.6, 'Truth', disable=False).jetAlgorithmHandle()

    #--------------------------------------------------------------------------
    # Make the D3PD
    #--------------------------------------------------------------------------
    alg = D3PDMakerCoreComps.MakerAlg(tuplename,
                                      seq,
                                      file=file,
                                      D3PDSvc=D3PDSvc)
    alg += EventInfoD3PDObject(10)

    if rec.doTruth():
        alg += GenEventD3PDObject(1)
        alg += TruthParticleD3PDObject(1)
        alg += TruthMETD3PDObject(level=10)
        alg += TruthJetD3PDObject(level=10,
                                  sgkey='AntiKt4Truth' + mysuffix + 'Jets',
                                  prefix='jet_antikt4truth' + mysuffix +
                                  'jets_')
        alg += TruthJetD3PDObject(level=10,
                                  sgkey='AntiKt6Truth' + mysuffix + 'Jets',
                                  prefix='jet_antikt6truth' + mysuffix +
                                  'jets_')
        if doExcludeWZdecays:
            alg += TruthJetD3PDObject(level=10,
                                      sgkey='AntiKt4TruthJets',
                                      prefix='jet_antikt4truthjets_')
            alg += TruthJetD3PDObject(level=10,
                                      sgkey='AntiKt6TruthJets',
                                      prefix='jet_antikt6truthjets_')
        alg += TruthJetD3PDObject(
            level=10,
            sgkey='AntiKt4TruthParton' + mysuffix + 'Jets',
            prefix='jet_antikt4truthparton' + mysuffix + 'jets_')
        alg += TruthJetD3PDObject(
            level=10,
            sgkey='AntiKt6TruthParton' + mysuffix + 'Jets',
            prefix='jet_antikt6truthparton' + mysuffix + 'jets_')

    return alg
#
# functionality : isolation for egamma and combined muon
#
pdr.flag_domain('egmiso')
if rec.doESD() and (rec.doMuonCombined() or rec.doEgamma()):
    try:
        from IsolationAlgs.IsoGetter import isoGetter
        isoGetter()
    except Exception:
        treatException("Could not set up isolation. Switched off !")

if rec.doESD() and rec.doEgamma():
    try:
        from egammaRec.egammaLocker import egammaLocker
        topSequence +=egammaLocker(name= "egLocker",
                                   doTruth=rec.doTruth(),
                                   doFinalizeClusters =jobproperties.egammaRecFlags.doEgammaCaloSeeded(),
                                   doEgammaForwardSeeded=jobproperties.egammaRecFlags.doEgammaForwardSeeded(),
                                   doEgammaCaloSeeded=jobproperties.egammaRecFlags.doEgammaCaloSeeded(),
                                   outputClusterKey=egammaKeys.outputClusterKey(),
                                   egammakeys=egammaKeysDict.outputs.items())
    except:
        treatException("Could not set up egammaLocker. Switched off !")

#AODFix_postMuonCombinedRec()
#
# functionality : CaloTower protojets + preclustering + KT algorithm + CombinedJetAlg
#
pdr.flag_domain('jet')
jetOK=False
if rec.doJetMissingETTag():
Beispiel #32
0
    FTK_RDO_Reader.GetRefitTrackParticles=True
    if (jobproperties.Beam.beamType() == 'cosmics'):
        FTK_RDO_Reader.GetVertex=False
        FTK_RDO_Reader.GetRefitVertex=False
    else:
        FTK_RDO_Reader.GetVertex=True
        FTK_RDO_Reader.GetRefitVertex=True
    FTK_RDO_Reader.GetTruthVertex=False

    from AthenaCommon.AlgSequence import AlgSequence

    alg = AlgSequence() 
    alg += FTK_RDO_Reader 
    

    if rec.doTruth() and (rec.doWriteAOD() or rec.doWriteESD()):
        include ('FTK_RecExample/ConfiguredFTK_TrackTruth.py')
        FTK_TracksTruth = ConfiguredFTK_TrackTruth(Tracks="FTK_TrackCollection",
                                                TracksTruth = "FTK_Tracks_TruthCollection",
                                                DetailedTruth = "FTK_Tracks_DetailedTruthCollection")
        FTK_RefitTracksTruth = ConfiguredFTK_TrackTruth(Tracks="FTK_TrackCollectionRefit", 
                                                     TracksTruth = "FTK_RefitTracks_TruthCollection",
                                                     DetailedTruth = "FTK_RefitTracks_DetailedTruthCollection")
        from xAODTrackingCnv.xAODTrackingCnvConf import xAODMaker__TrackParticleCnvAlg

        FTKTrackParticleCnvAlg = xAODMaker__TrackParticleCnvAlg("FTKTrackParticleCnvAlg")
        FTKTrackParticleCnvAlg.xAODTrackParticlesFromTracksContainerName = "Converted_FTKTrackParticleContainer"
        FTKTrackParticleCnvAlg.TrackContainerName = "FTK_TrackCollection"
        FTKTrackParticleCnvAlg.ConvertTrackParticles = False
        FTKTrackParticleCnvAlg.ConvertTracks = True
        FTKTrackParticleCnvAlg.AddTruthLink = True
Beispiel #33
0
############################################################################
# SHOULD BE MIGRATED TO MUON ALGORITHMS

from METReconstruction.METRecoFlags import metFlags
from AthenaCommon.BeamFlags import jobproperties
from RecExConfig.RecFlags import rec
if jobproperties.Beam.beamType == 'cosmics' or jobproperties.Beam.beamType == 'singlebeam' or not rec.doInDet(
):
    metFlags.UseTracks.set_Value(False)
    metFlags.DoPFlow.set_Value(False)
    print "METReconstruction_jobOptions: detected cosmics/single-beam configuration -- switch off track-based MET reco"

import METReconstruction.METConfig_Calo
import METReconstruction.METConfig_Track
if rec.doTruth():
    import METReconstruction.METConfig_Truth

from METReconstruction.METRecoConfig import getMETRecoAlg

metAlg = getMETRecoAlg('METReconstruction')
topSequence += metAlg

# Set up default configurations
import METReconstruction.METConfig_Associator
from METReconstruction.METAssocConfig import getMETAssocAlg

# Get the configuration directly from METRecoFlags
# Can also provide a dict of configurations or list of RecoTools or both
assocAlg = getMETAssocAlg('METAssociation')
from AthenaCommon.AlgSequence import AlgSequence
Beispiel #34
0
# List for of keys to be written to AOD.
# All egammaKeys.outputs but EgammaRec and TopoSeededCellLink
AOD_outputs = [
    i for i, j in egammaKeysDict.outputs.items()
    if i not in ('EgammaRec', 'TopoSeededCellLink', 'FwdClusterCellLink')
]

# Define egammaAODList in the proper format (<type>#<key><option>),
# including aux containers
egammaAODList = []
egammaESDList = []
for i in AOD_outputs:
    cType, cKey, auxOptionAll, auxOptionAOD = egammaKeysDict.outputs[i]

    # Skip truth if doTruth = False
    if not rec.doTruth() and 'Truth' in cKey:
        continue

    # Skip Trk::Tracks in xAOD
    if egammaKeys.outputTrackType() in cType:
        continue

    addContainer(egammaAODList, cType, cKey)
    addContainer(egammaESDList, cType, cKey)

    # Add aux containers for xAOD containers
    if 'xAOD::' in cType:
        addAuxContainer(egammaAODList, cType, cKey, auxOptionAll, auxOptionAOD)
        addAuxContainer(egammaESDList, cType, cKey, auxOptionAll)

# Add the non xAOD kind of  collection in the ESD
Beispiel #35
0
from TrigMuonD3PDMaker.TrigMuonD3PD import TrigMuonD3PDObjects
#from D3PDMakerConfig.CommonTrigMuonD3PD                      import CommonTrigMuonD3PDObjects
from TrigBJetD3PDMaker.TrigBJetD3PD import TrigBJetD3PDObjects
from TrigDecisionTool.TrigDecisionToolConf import Trig__TrigDecisionTool
from TriggerD3PDMaker.defineTriggerBits import defineTriggerBits
from CaloD3PDMaker.MBTSTriggerBitsD3PDObject import MBTSTriggerBitsD3PDObject
from TrigCaloD3PDMaker.TrigEMClusterD3PDObject import TrigEMClusterD3PDObject
from TrigInDetD3PDMaker.TrigInDetTrackD3PDObject import TrigInDetTrackD3PDObject
from MissingETD3PDMaker.MissingETD3PDTriggerBitsObject import METD3PDTriggerBitsObject
from D3PDMakerCoreComps.IndexMultiAssociation import IndexMultiAssociation
import JetSubstructureD3PDMaker
import TauD3PDMaker
from D3PDMakerCoreComps.IndexAssociation import IndexAssociation
from D3PDMakerCoreComps.SimpleAssociation import SimpleAssociation

if rec.doTruth():
    from egammaD3PDMaker.egammaTruthD3PDObject import egammaTruthD3PDObject
    from EventCommonD3PDMaker.DRIndexMultiAssociation import DRIndexMultiAssociation
    import TruthD3PDMaker
    from TruthD3PDMaker.TruthParticleD3PDObject import TruthParticleD3PDObject
    from MuonD3PDMaker.TruthMuonD3PDObject import TruthMuonD3PDObject
    from TruthD3PDMaker.GenEventD3PDObject import GenEventD3PDObject
    from TruthD3PDMaker.GenVertexD3PDObject import GenVertexD3PDObject
    from TruthD3PDMaker.GenParticleD3PDObject import GenParticleD3PDObject
    from TruthD3PDMaker.GenParticleD3PDObject import GenTruthTrackD3PDObject
    from TruthD3PDMaker.MCTruthClassifierConfig import D3PDMCTruthClassifier

#-------------------------------------
# SUSY imports
#-------------------------------------
from SUSYD3PDMaker.SUSYD3PDMakerConf import *
Beispiel #36
0
    def configure(self):

        log = logging.getLogger("HLTTriggerResultGetter.py")
        from RecExConfig.ObjKeyStore import objKeyStore

        # set EDMDecodingVersion
        EDMDecodingVersion()

        # Set AODFULL for data unless it was set explicitly already
        if TriggerFlags.AODEDMSet.isDefault() and globalflags.DataSource(
        ) == 'data':
            TriggerFlags.AODEDMSet = 'AODFULL'

        from AthenaCommon.AlgSequence import AlgSequence
        topSequence = AlgSequence()
        log.info("BS unpacking (TF.readBS): %d", TriggerFlags.readBS())
        if TriggerFlags.readBS():
            if TriggerFlags.EDMDecodingVersion() <= 2:
                bs = ByteStreamUnpackGetterRun2()  # noqa: F841
            else:
                bs = ByteStreamUnpackGetter()  # noqa: F841

        xAODContainers = {}
        #        if not recAlgs.doTrigger():      #only convert when running on old data
        if TriggerFlags.EDMDecodingVersion() == 1:
            xaodcnvrt = xAODConversionGetter()
            xAODContainers = xaodcnvrt.xaodlist

        if recAlgs.doTrigger() or TriggerFlags.doTriggerConfigOnly():
            if TriggerFlags.EDMDecodingVersion() <= 2:
                tdt = TrigDecisionGetterRun2()  # noqa: F841
            else:
                tdt = TrigDecisionGetter()  # noqa: F841

        # Temporary hack to add Run-3 navigation to ESD and AOD
        if (rec.doESD()
                or rec.doAOD()) and TriggerFlags.EDMDecodingVersion() == 3:
            # The hack with wildcards is needed for BS->ESD because we don't know the exact keys
            # of HLT navigation containers before unpacking them from the BS event.
            objKeyStore._store['streamESD'].allowWildCard(True)
            objKeyStore._store['streamAOD'].allowWildCard(True)
            objKeyStore.addManyTypesStreamESD([
                'xAOD::TrigCompositeContainer#HLTNav*',
                'xAOD::TrigCompositeAuxContainer#HLTNav*'
            ])
            objKeyStore.addManyTypesStreamAOD([
                'xAOD::TrigCompositeContainer#HLTNav*',
                'xAOD::TrigCompositeAuxContainer#HLTNav*'
            ])

        # TrigJetRec additions
        if rec.doWriteESD():
            objKeyStore.addStreamESD("JetKeyDescriptor", "JetKeyMap")
            objKeyStore.addStreamESD("JetMomentMap", "TrigJetRecMomentMap")

        if rec.doWriteAOD():
            objKeyStore.addStreamAOD("JetKeyDescriptor", "JetKeyMap")
            objKeyStore.addStreamAOD("JetMomentMap", "TrigJetRecMomentMap")

        # ID truth
        if not rec.readESD() and (not rec.readAOD()) and TriggerFlags.doID() \
                and rec.doTruth():
            try:
                from TrigInDetTruthAlgs.TrigInDetTruthAlgsConfig import \
                    TrigIDTruthMaker
                topSequence += TrigIDTruthMaker()
            except Exception:
                log.warning("Couldn't set up the trigger ID truth maker")
                pass

        if rec.doESD() or rec.doAOD():
            from TrigEDMConfig.TriggerEDM import getTrigIDTruthList
            objKeyStore.addManyTypesStreamESD(
                getTrigIDTruthList(TriggerFlags.ESDEDMSet()))
            objKeyStore.addManyTypesStreamAOD(
                getTrigIDTruthList(TriggerFlags.AODEDMSet()))

        if (rec.doESD() or rec.doAOD()) and TriggerFlags.writeL1TopoValData():
            objKeyStore.addManyTypesStreamESD([
                'xAOD::TrigCompositeContainer#HLT_xAOD__TrigCompositeContainer_L1TopoValData',
                'xAOD::TrigCompositeAuxContainer#HLT_xAOD__TrigCompositeContainer_L1TopoValDataAux.'
            ])
            objKeyStore.addManyTypesStreamAOD([
                'xAOD::TrigCompositeContainer#HLT_xAOD__TrigCompositeContainer_L1TopoValData',
                'xAOD::TrigCompositeAuxContainer#HLT_xAOD__TrigCompositeContainer_L1TopoValDataAux.'
            ])
            log.debug(
                "HLT_xAOD__TrigCompositeContainer_L1TopoValData(Aux.) for L1Topo validation added to the data."
            )

        if rec.doAOD() or rec.doWriteAOD():
            # schedule the RoiDescriptorStore conversion
            # log.warning( "HLTTriggerResultGetter - setting up RoiWriter" )
            roiWriter = RoiWriter()
            # Add fictional input to ensure data dependency in AthenaMT
            roiWriter.ExtraInputs += [("TrigBSExtractionOutput",
                                       "StoreGateSvc+TrigBSExtractionOutput")]
            topSequence += roiWriter
            # write out the RoiDescriptorStores
            from TrigEDMConfig.TriggerEDMRun2 import TriggerRoiList
            objKeyStore.addManyTypesStreamAOD(TriggerRoiList)

        #Are we adding operational info objects in ESD?
        added = self._AddOPIToESD()
        if added:
            log.debug(
                "Operational Info object HLT_EXPRESS_OPI_HLT with extra information about express stream prescaling added to the data."
            )

        # ESD objects definitions
        _TriggerESDList = {}

        from TrigEDMConfig.TriggerEDM import getTriggerEDMList
        # we have to store xAOD containers in the root file, NOT AOD,
        # if the xAOD container list is not empty
        if (xAODContainers):
            _TriggerESDList.update(xAODContainers)
        else:
            _TriggerESDList.update(
                getTriggerEDMList(TriggerFlags.ESDEDMSet(),
                                  TriggerFlags.EDMDecodingVersion()))

        log.info(
            "ESD content set according to the ESDEDMSet flag: %s and EDM version %d",
            TriggerFlags.ESDEDMSet(), TriggerFlags.EDMDecodingVersion())

        # AOD objects choice
        _TriggerAODList = {}

        #from TrigEDMConfig.TriggerEDM import getAODList
        _TriggerAODList.update(
            getTriggerEDMList(TriggerFlags.AODEDMSet(),
                              TriggerFlags.EDMDecodingVersion()))

        log.info(
            "AOD content set according to the AODEDMSet flag: %s and EDM version %d",
            TriggerFlags.AODEDMSet(), TriggerFlags.EDMDecodingVersion())

        log.debug("ESD EDM list: %s", _TriggerESDList)
        log.debug("AOD EDM list: %s", _TriggerAODList)

        # Highlight what is in AOD list but not in ESD list, as this can cause
        # the "different number of entries in branch" problem, when it is in the
        # AOD list but the empty container per event is not created
        # Just compares keys of dicts, which are the class names, not their string keys in StoreGate
        not_in = [
            element for element in _TriggerAODList
            if element not in _TriggerESDList
        ]
        if (len(not_in) > 0):
            log.warning("In AOD list but not in ESD list: ")
            log.warning(not_in)
        else:
            log.info("AOD list is subset of ESD list - good.")

        def _addSlimming(stream, edm):
            from TrigNavTools.TrigNavToolsConfig import navigationThinningSvc

            edmlist = list(y.split('-')[0] for x in edm.values()
                           for y in x)  #flatten names

            svc = navigationThinningSvc({
                'name': 'HLTNav_%s' % stream,
                'mode': 'cleanup',
                'result': 'HLTResult_HLT',
                'features': edmlist
            })

            from OutputStreamAthenaPool.CreateOutputStreams import registerTrigNavThinningSvc
            registerTrigNavThinningSvc(stream, svc)

            log.info("Configured slimming of HLT for %s", stream)
            print(svc)  # noqa: ATL901
            del edmlist

        if TriggerFlags.doNavigationSlimming() and rec.readRDO(
        ) and rec.doWriteAOD():
            _addSlimming('StreamAOD',
                         _TriggerESDList)  #Use ESD item list also for AOD!
            log.info("configured navigation slimming for AOD output")

        if TriggerFlags.doNavigationSlimming() and rec.readRDO(
        ) and rec.doWriteESD():
            _addSlimming('StreamESD', _TriggerESDList)
            log.info("configured navigation slimming for ESD output")

        objKeyStore.addManyTypesStreamESD(_TriggerESDList)
        objKeyStore.addManyTypesStreamAOD(_TriggerAODList)

        return True
### require trigger filter?
#include("RPVDispVrt/RPVFilter_jobOptions.py")

print "-=-=-=- rec flacs -=-=-=-="
print rec

print "-=-=-=- recAlgs flacs -=-=-=-="
print recAlgs

### run reconstruction
include("RecExCommon/RecExCommon_topOptions.py")


topSequence.InDetCopyAlg.AliasName='NewTracks'
if rec.doTruth():
    topSequence.DetailedTrackTruthMaker.TrackCollectionName='NewTracks'
    topSequence.InDetParticleTruthMaker.tracksName='NewTracks'
    pass
topSequence.InDetPriVxFinder.TracksName='NewTracks'
topSequence.InDetParticleCreator_PRD_Association.TracksName=['NewTracks']
topSequence.InDetParticleCreation.TracksName='NewTracks'


topSequence.InDetTrackCollectionMerger.TracksLocation=['Tracks','ExtendedHighD0Tracks'] # do not want to use TRTStandaloneTracks here. They are useless... Change this if one want to do reco without 2nd step.

#### FOR EXPRESS STREAM
if doExpressStream:
    topSequence.InDetTrackCollectionMerger.OutputTracksLocation="MergedTracks"
    topSequence.InDetCopyAlg.CollectionName='MergedTracks'
    pass
Beispiel #38
0
def HSG2physicsD3PD (name,file,
                     tuplename = 'physics',
                     **kw):

    from AthenaCommon.AlgSequence import AlgSequence  # needed for attila's code
    from D3PDMakerConfig.D3PDMakerFlags import D3PDMakerFlags # needed for attila's code
    
    # define track and cluster filters
    filter1 = makeTrackFilterAlg(TracksName = D3PDMakerFlags.TrackSGKey(),
                                 OutputTracksName='GoodTracks'+name,
                                 ptCut=0.,nSCTPix=4)

    filter2 = makeTrackFilterAlg(TracksName = D3PDMakerFlags.TrackSGKey(),
                                 OutputTracksName='HighPtTracks'+name,
                                 ptCut=5000.,nSCTPix=4)
    
    preseq = AlgSequence (D3PDMakerFlags.PreD3PDAlgSeqName())
    preseq += filter1
    preseq += filter2

    # now configure the D3PD 
    from OutputStreamAthenaPool.MultipleStreamManager import MSMgr
    alg = MSMgr.NewRootStream( name, file, TreeName=tuplename)
    
    
    #alg = D3PDMakerCoreComps.MakerAlg(tuplename, seq,
    #                                  file = file,
    #                                  D3PDSvc = D3PDSvc,
    #                                  streamNameRoot = streamNameRoot)
    
    alg += EventInfoD3PDObject        (**_args (10, 'EventInfo', kw))
    alg += LArCollisionTimeD3PDObject (**_args (10, 'LArCollisionTime', kw))


    from D3PDMakerCoreComps.D3PDObject         import make_SG_D3PDObject

    import EventCommonD3PDMaker

    # Electron/Photon block
    alg += ElectronD3PDObject         (**_args (10, 'Electron', kw,
                                                exclude = ['L1Index', 'L2Index' ,'EMTrackFitDetails','EgammaJetSignedIPAndPTRelKin']))
    # Photon block
    alg += PhotonD3PDObject           (**_args (10, 'Photon', kw))

    
    # Muon blocks
    alg += MuonD3PDObject             (**_args (10, 'MuidMuon', kw,
                                                sgkey='MuidMuonCollection', prefix='mu_muid_',
                                                include = ["EFCBInfoIndex","EFMGInfoIndex", "EFMEInfoIndex" ],
                                                exclude = ["EFCBInfo", "EFMGInfo", "EFMEInfo", "L2CBInfo", "L1Info"],
                                                allowMissing = True
                                                ))
    alg += MuonD3PDObject             (**_args (10, 'StacoMuon', kw,
                                                sgkey='StacoMuonCollection', prefix='mu_staco_',
                                                include = ["EFCBInfoIndex","EFMGInfoIndex", "EFMEInfoIndex"],
                                                exclude = ["EFCBInfo", "EFMGInfo", "EFMEInfo", "L2CBInfo", "L1Info"],
                                                allowMissing = True
                                                ))
    alg += MuonD3PDObject             (**_args (10, 'CaloMuon', kw,
                                                sgkey='CaloMuonCollection', prefix='mu_calo_',
                                                include = ["EFCBInfoIndex","EFMGInfoIndex", "EFMEInfoIndex"],
                                                exclude = ["EFCBInfo", "EFMGInfo", "EFMEInfo", "L2CBInfo", "L1Info"],
                                                allowMissing = True
                                                ))
    
    alg += MuonD3PDObject             (**_args (10, 'Muons', kw,
                                                sgkey='Muons', prefix='mu_muon_',
                                                include = ["EFCBInfoIndex","EFMGInfoIndex", "EFMEInfoIndex"],
                                                exclude = ["EFCBInfo", "EFMGInfo", "EFMEInfo", "L2CBInfo", "L1Info"],
                                                allowMissing = True
                                                ))
    # Quadruplet vertex block
    from AthenaCommon.AlgSequence import AlgSequence  
    from D3PDMakerConfig.D3PDMakerFlags import D3PDMakerFlags 
    from HSG2VertexCreation.HSG2VertexReconstruction import HSG2VertexReconstruction 
    HSG2VertexReconstruction( "HSG2VertexReconstruction", 
                              AlgSequence( D3PDMakerFlags.PreD3PDAlgSeqName() )) 
    
    from HiggsD3PDMaker.HSG2VertexReconstruction import addHSG2VertexReconstruction
    addHSG2VertexReconstruction( alg, electron_target = "el_",
                                 muid_target = "mu_muid_",
                                 staco_target = "mu_staco_",
                                 calo_target = "mu_calo_" ,
                                 muon_target = "mu_muon_" )
    
    # Tau block
    alg += TauD3PDObject              (**_args ( 1, 'Tau', kw)) 
    

    # Jet blocks
    alg += JetD3PDObject              (**_args ( 3, 'AK4TopoEMJet', kw,
                                                 sgkey='AntiKt4TopoEMJets'+JetTagD3PD_CollectionPostfix, prefix='jet_akt4topoem_',
                                                 #include = ['BTag','TrueFlavorComponents','BTagComponents'],
                                                 include = [JetTagD3PDKeys.BTagWeightsBlockName(),
                                                            JetTagD3PDKeys.JetFitterCharmTagInfoBlockName(),
                                                            JetTagD3PDKeys.JetFitterCharmInfoBaseBlockName(), 
                                                            JetTagD3PDKeys.JetFitterCombInfoBaseBlockName(),
                                                            JetTagD3PDKeys.TruthInfoBlockName(),
                                                            "Constituents",
                                                            'TracksMoments', 'Samplings', # For GSC corrections
                                                            ],
                                                 allowMissing = True))
    # For VBF and ZH(->inv) analyses  
    alg += JetD3PDObject              (**_args ( 3, 'AK4LCTopoJet', kw,
                                                 sgkey='AntiKt4LCTopoJets'+JetTagD3PD_CollectionPostfix, prefix='jet_AntiKt4LCTopo_',
                                                 include = [JetTagD3PDKeys.BTagWeightsBlockName(),
                                                            JetTagD3PDKeys.JetFitterCharmTagInfoBlockName(),
                                                            JetTagD3PDKeys.JetFitterCharmInfoBaseBlockName(), 
                                                            JetTagD3PDKeys.JetFitterCombInfoBaseBlockName(),
                                                            JetTagD3PDKeys.TruthInfoBlockName(),                      
                                                            "Constituents",
                                                            "ConstituentScale", # For ZH(->inv) analysis
                                                            'TracksMoments', 'Samplings', # For GSC corrections
                                                            ],
                                                 allowMissing = True))

    # MET blocks
    # a whole mess to remove x,y components separately for all flavours
    alg += MissingETD3PDObject        (**_args (10, 'MissingET', kw,
                                                exclude=['MET_Base', 'MET_Base0', 'MET_Truth_Int',
                                                         'MET_RefFinal_Comps','MET_Calib_Comps','MET_CellOut_Comps',
                                                         'MET_CorrTopo_Comps','MET_Cryo_Comps','MET_CryoCone_Comps',
                                                         'MET_Final_Comps','MET_LocHadTopo_Comps',
                                                         'MET_LocHadTopoObj_Comps','MET_Muid_Comps',
                                                         'MET_Muid_Spectro_Comps','MET_Muid_Track_Comps',
                                                         'MET_MuonBoy_Comps','MET_MuonBoy_Spectro_Comps',
                                                         'MET_MuonBoy_Track_Comps','MET_MuonMuid_Comps',
                                                         'MET_Muon_Comps','MET_Muon_Isol_Muid_Comps',
                                                         'MET_Muon_Isol_Staco_Comps','MET_Muon_NonIsol_Muid_Comps',
                                                         'MET_Muon_NonIsol_Staco_Comps','MET_Muon_Total_Muid_Comps',
                                                         'MET_Muon_Total_Staco_Comps','MET_RefEle_Comps',
                                                         'MET_RefEle_em_Comps','MET_RefGamma_Comps',
                                                         'MET_RefGamma_em_Comps','MET_RefJet_Comps',
                                                         'MET_RefJet_em_Comps','MET_RefMuon_Comps',
                                                         'MET_RefMuon_Muid_Comps','MET_RefMuon_Staco_Comps',
                                                         'MET_RefMuon_Track_Muid_Comps','MET_RefMuon_Track_Staco_Comps',
                                                         'MET_RefMuon_Track_em_Comps','MET_RefMuon_Track_Comps',
                                                         'MET_RefMuon_em_Comps','MET_RefTau_Comps',
                                                         'MET_RefTau_em_Comps','MET_SoftJets_Comps',
                                                         'MET_SoftJets_em_Comps','MET_Topo_Comps',
                                                         'MET_TopoObj_Comps','MET_Track_Comps'],
                                                allowMissing=True))

    # Pileup-subtracted MET RefFinal for ZH(->inv) analysis 
    alg += MissingETCompositionD3PDObject ( level=4, sgkey = 'MET_RefComposition_STVF', suffix='STVF_', allowMissing =True,
                                            jetSGKey='AntiKt4LCTopoJets'+JetTagD3PD_CollectionPostfix, jetPrefix='jet_AntiKt4LCTopo_MET_') 

    # For H->ZZ->llqq analysis
    # PhysicsAnalysis/D3PDMaker/PhysicsD3PDMaker/python/SMWZD3PD.py
    from MissingET.METRefGetter_plup import *
    METRefAlg_HSG5 = make_METRefAlg(_suffix='_HSG5')
    METRefAlg_HSG5.sequence                    = AlgSequence( D3PDMakerFlags.PreD3PDAlgSeqName() )
    METRefAlg_HSG5.jet_JetInputCollectionKey   = "AntiKt4TopoEMJets"+JetTagD3PD_CollectionPostfix
    METRefAlg_HSG5.jet_JetPtCut                = 20.0*GeV
    METRefAlg_HSG5.jet_ApplyJetScale           = "No"
    METRefAlg_HSG5.jet_UseJetMomentForScale    = True
    METRefAlg_HSG5.jet_JetMomentForScale       = "EMJES"
    METRefAlg_HSG5.jet_RunSoftJetsTool         = False
    METRefAlg_HSG5.jet_SoftJetsPtCut           = 7.0*GeV
    METRefAlg_HSG5.jet_SoftJetsMaxPtCut        = 20.0*GeV
    METRefAlg_HSG5.photon_doPhotonTool         = False
    METRefAlg_HSG5.tau_doTauTool               = False
    METRefAlg_HSG5.jet_SoftJetsCalibType       = "EmScale"
    METRefAlg_HSG5.jet_ApplySoftJetsScale      = "No"
    METRefAlg_HSG5.jet_calibType               = "ExclRefCalib"
    METRefAlg_HSG5.ele_calibType               = "RefCalib"
    METRefAlg_HSG5.gamma_calibType             = "EmScale"
    METRefAlg_HSG5.cellout_calibType           = "Eflow"
    METRefAlg_HSG5.tau_calibType               = "EmScale"
    METRefAlg_HSG5.cryo_ApplyCorrection        = "Off"
    METRefAlg_HSG5.muon_container              = "StacoMuonCollection"
    METRefAlg_HSG5.muon_algorithm              = "Staco"
    METRefAlg_HSG5.muon_isolationAlg           = "dRJet"
    #    METRefAlg_HSG5.jet_ApplyJetJVF             = "Yes"
    #    METRefAlg_HSG5.plupSuppCorr                ='STVF'
    #    METRefAlg_HSG5.celloutCorrection           ='STVF'
    print METRefAlg_HSG5
    METRefAlg_HSG5()

    customMETs = ['MET_RefFinal', 'MET_RefGamma', 'MET_RefEle', 'MET_RefTau', 'MET_RefJet',
                  'MET_CellOut', 'MET_Cryo', 'MET_SoftJets',
                  'MET_RefJet_JVF', 'MET_RefJet_JVFCut',
                  'MET_CellOut_Eflow_STVF', 'MET_CellOut_Eflow_JetArea',
                  'MET_RefFinal_STVF' ]
    for custom in customMETs:
        alg += MissingETD3PDObject (level=0, sgkey = custom+'_HSG5',prefix='MET_HSG5_'+custom[4:],
                                    exclude=['MET_Base', 'MET_Base0', 'MET_Truth_Int',
                                             'MET_RefFinal_Comps','MET_Calib_Comps','MET_CellOut_Comps',
                                             'MET_CorrTopo_Comps','MET_Cryo_Comps','MET_CryoCone_Comps',
                                             'MET_Final_Comps','MET_LocHadTopo_Comps',
                                             'MET_LocHadTopoObj_Comps','MET_Muid_Comps',
                                             'MET_Muid_Spectro_Comps','MET_Muid_Track_Comps',
                                             'MET_MuonBoy_Comps','MET_MuonBoy_Spectro_Comps',
                                             'MET_MuonBoy_Track_Comps','MET_MuonMuid_Comps',
                                             'MET_Muon_Comps','MET_Muon_Isol_Muid_Comps',
                                             'MET_Muon_Isol_Staco_Comps','MET_Muon_NonIsol_Muid_Comps',
                                             'MET_Muon_NonIsol_Staco_Comps','MET_Muon_Total_Muid_Comps',
                                             'MET_Muon_Total_Staco_Comps','MET_RefEle_Comps',
                                             'MET_RefEle_em_Comps','MET_RefGamma_Comps',
                                             'MET_RefGamma_em_Comps','MET_RefJet_Comps',
                                             'MET_RefJet_em_Comps','MET_RefMuon_Comps',
                                             'MET_RefMuon_Muid_Comps','MET_RefMuon_Staco_Comps',
                                             'MET_RefMuon_Track_Muid_Comps','MET_RefMuon_Track_Staco_Comps',
                                             'MET_RefMuon_Track_em_Comps','MET_RefMuon_Track_Comps',
                                             'MET_RefMuon_em_Comps','MET_RefTau_Comps',
                                             'MET_RefTau_em_Comps','MET_SoftJets_Comps',
                                             'MET_SoftJets_em_Comps','MET_Topo_Comps',
                                             'MET_TopoObj_Comps','MET_Track_Comps'],
                                    allowMissing=True)
    alg += MissingETCompositionD3PDObject ( level=4, sgkey = 'MET_RefComposition_HSG5', suffix='HSG5_', allowMissing =True,
                                            jetSGKey='AntiKt4TopoEMJets'+JetTagD3PD_CollectionPostfix, jetPrefix='jet_AntiKt4TopoEM_MET_')

    ### large-R jets
    ### Copied from D3PDMaker/QcdD3PDMaker/share/JetMetD3PD_prodJobOFragment.py
    from RecExConfig.ObjKeyStore import objKeyStore
    if objKeyStore.isInInput("CaloClusterContainer","CaloCalTopoCluster"):
        preseqLRJ = AlgSequence (D3PDMakerFlags.PreD3PDAlgSeqName())
        from QcdD3PDMaker.JSjets import createJSJets
        from QcdD3PDMaker.JSD3PD import JSD3PD
        from HSG2DPDUtils.GroomedJetsConfig import getGroomedJetsConfig
        dictsConfig = getGroomedJetsConfig()
        for dC in dictsConfig:
            xx = createJSJets(dC[0], dC[1], preseqLRJ)
            if xx[0] != None and xx[1] != None:
                JSD3PD(xx, alg)

    # ... good tracks only (nSCT>3; no pt cut)
    alg += TrackParticleD3PDObject    (**_args ( 3, 'Tracks1', kw,
                                                 sgkey  = 'GoodTracks'+name,
                                                 label  = 'trk',
                                                 prefix = 'trk_'))

    # ... high-pt tracks (nSCT>3; pt>5 GeV)
    from TrackD3PDMaker.TrackD3PDMakerFlags                import TrackD3PDFlags as highPtFlags
    highPtFlags.doTruth = True
    highPtFlags.storeDiagonalCovarianceAsErrors = True
    highPtFlags.storeHitTruthMatching = True
    highPtFlags.storePixelHitsOnTrack = False
    highPtFlags.storePixelHolesOnTrack = False
    highPtFlags.storePixelOutliersOnTrack = False
    highPtFlags.storeSCTHitsOnTrack = False
    highPtFlags.storeSCTHolesOnTrack = False
    highPtFlags.storeSCTOutliersOnTrack = False
    highPtFlags.storeTRTHitsOnTrack = False
    highPtFlags.storeTRTHolesOnTrack = False
    highPtFlags.storeTRTOutliersOnTrack = False
    highPtFlags.storeTrackFitQuality = True
    highPtFlags.storeTrackMomentum = True
    highPtFlags.storeTrackSummary = True
    highPtFlags.trackParametersAtBeamSpotLevelOfDetails = 0
    highPtFlags.trackParametersAtGlobalPerigeeLevelOfDetails = 2
    highPtFlags.trackParametersAtPrimaryVertexLevelOfDetails = 3
    
    alg += TrackParticleD3PDObject(**_args ( 3, 'Tracks2', kw,
                                             sgkey  = 'HighPtTracks'+name,
                                             label  = 'trkpt5',
                                             prefix = 'trkpt5_'))

    
    # Primary vertex block - May be missing in single-beam data.
    alg += PrimaryVertexD3PDObject (**_args (1, 'PrimaryVertex', kw,
                                             allowMissing = True,
                                             sgkey = D3PDMakerFlags.VertexSGKey(),
                                             prefix = 'vxp_'))
    
    # Truth
    if rec.doTruth():

        from TruthD3PDMaker.GenEventD3PDObject                 import GenEventD3PDObject
        from TruthD3PDMaker.TruthParticleD3PDObject            import TruthParticleD3PDObject
        from MuonD3PDMaker.TruthMuonD3PDObject                 import TruthMuonD3PDObject

        alg += TruthMuonD3PDObject    (**_args ( 2, 'TruthMuon', kw))
        alg += GenEventD3PDObject     (**_args ( 1, 'GenEvent', kw))
        alg += TruthParticleD3PDObject(**_args ( 1, 'TruthParticle', kw))

        # TruthJets
        alg += JetD3PDObject          (**_args ( 1, 'AK4TruthJet', kw,
                                                 sgkey='AntiKt4TruthJets',prefix='jet_antikt4truth_', allowMissing=True))

        # add Heavy flavour overlap
        from TopInputsD3PDMaker.HforD3PDObject import HforD3PDObject
        alg += HforD3PDObject(**_args ( 0, 'HforD3PD', kw))

        # add mcVx information 
        from TrackD3PDMaker.TruthVertexD3PDObject import TruthVertexD3PDObject
        alg += TruthVertexD3PDObject(**_args (0, 'TruthVertex', kw))  

    if not rec.doTruth():
        alg += BeamSpotD3PDObject(10)
    
    
    
    if D3PDMakerFlags.DoTrigger():
                
        # Trigger Decision + metadata
        alg += TrigDecisionD3PDObject  (**_args(10, 'TrigDecision', kw))
        addTrigConfMetadata(alg)

        
        from TrigMissingETD3PDMaker.TrigMETD3PD import TrigMETD3PDObjects
        TrigMETD3PDObjects( alg )

        from TrigEgammaD3PDMaker.TrigEgammaD3PD       import TrigEgammaD3PDObjects
        TrigMuonD3PDObjects( alg, 1)
        TrigEgammaD3PDObjects (alg, level=10)


    # Event metadata
    alg.MetadataTools += [LBMetadataConfig()]

    from EventCommonD3PDMaker.CutFlowMetadataConfig        import CutFlowMetadataConfig
    alg.MetadataTools += [CutFlowMetadataConfig(alg)]

    # Bunch train information
    from TriggerD3PDMaker.BunchStructureMetadata import addBunchStructureMetadata
    addBunchStructureMetadata( alg )

    ## Silence the trigger navigation warnings about missing containers:
    from AthenaCommon.AppMgr import ToolSvc
    if not hasattr( ToolSvc, "TrigDecisionTool" ):
        from TrigDecisionTool.TrigDecisionToolConf import Trig__TrigDecisionTool
        ToolSvc += Trig__TrigDecisionTool( "TrigDecisionTool" )
        pass
    ToolSvc.TrigDecisionTool.Navigation.OutputLevel=5

    
    # EventShape variables
    # https://twiki.cern.ch/twiki/bin/viewauth/AtlasProtected/D3PDVariablesForPileup#EventShape_variables
    from QcdD3PDMaker.QcdEventShapeD3PDObject import EventShapeD3PDObject
    alg += EventShapeD3PDObject(**_args(0, 'rho', kw))

    return alg