Ejemplo n.º 1
0
def setupCaloJets(myjetfinder, myjetdr, myjetinput, GroomedDicts, theseq):

    myGroomingTools, catNames = getGroomingTools(GroomedDicts)

    catNames_trimmed = list(x for x in catNames if 'Trimmed' in x)

    sortertool = JetSorterTool('myJetSorter',
                               SortOrder="ByPtDown",
                               OutputLevel=3)
    wrapped_sortertool = JetSubStructure.JetAlgToolWrapper(
        "JetSorterWrapper",
        JetAlgTool=sortertool,
        GroomedjetsAuthor=catNames_trimmed)

    widthtool = JetWidthTool('JS_JetWidthTool')

    grjets_calib = []

    from JetSubStructure.mySetupJetCalibrators import doEtaMassJESCorrection
    from JetCalibTools.MakeCalibSequences import calibTags
    calibTags['ETAMASSJES'] = doEtaMassJESCorrection

    ## Origin correction

    mydoCalib = False
    mycalibName = ''

    if 'LCTopo' in myjetinput:
        mydoCalib = False
        if (myjetfinder + '%d' %
            (myjetdr * 10) == 'AntiKt10') or (myjetfinder + '%d' %
                                              (myjetdr * 10) == 'CamKt12'):
            mycalibName = 'LC:ORIGIN_ETAMASSJES'
        else:
            mycalibName = 'LC:ORIGIN'

        stdcaliblist = []
        allowedcalib = [
            'AntiKt10LCTopoTrimmedJets',
            'AntiKt10LCTopoTrimmedPtFrac3SmallR30Jets',
            'AntiKt10LCTopoTrimmedPtFrac5SmallR30Jets',
            'CamKt12LCTopoTrimmedPtFrac5SmallR30Jets'
        ]
        for x in catNames:
            author = myjetfinder + '%d' % (myjetdr *
                                           10) + myjetinput + x + 'Jets'
            #if author in allowedcalib :
            #grjets_calib += [JetSubStructure.JetAlgToolWrapper(name = 'calibtool_origin_etamassjes_'+x,
            #                                                    JetAlgTool = getStandardCalibTool(myjetfinder,myjetdr, myjetinput+x, doCalib=True, calibName='LC:ORIGIN_ETAMASSJES')[0],
            #                                                    GroomedjetsAuthor = [x] )]
            #elif 'Trimmed' in x:
            #    stdcaliblist += [x]

        #if stdcaliblist != [] :
        #grjets_calib += [JetSubStructure.JetAlgToolWrapper(name = 'calibtool_origin',
        #                                                    JetAlgTool = getStandardCalibTool(myjetfinder,myjetdr, myjetinput, doCalib=True, calibName='LC:ORIGIN')[0],
        #                                                    GroomedjetsAuthor = stdcaliblist )]
    elif 'Topo' in myjetinput:
        mydoCalib = True
        mycalibName = 'EM:ORIGIN'
        grjets_calib += [
            JetSubStructure.JetAlgToolWrapper(
                name='calibtool_origin',
                JetAlgTool=getStandardCalibTool(myjetfinder,
                                                myjetdr,
                                                myjetinput,
                                                doCalib=True,
                                                calibName='EM:ORIGIN')[0],
                GroomedjetsAuthor=catNames_trimmed)
        ]

    truthcontname = 'none'
    if rec.doTruth():
        if myjetdr < 0.9:  #need to use truth collection on disk for smaller R jets for the TrueFlavorComponent block
            truthcontname = myjetfinder + '%dTruthJets' % (myjetdr * 10)
        else:
            truthcontname = myjetfinder + '%dTruthJSJets' % (myjetdr * 10)

    trackjetcontname = myjetfinder + '%dTrackZJets' % (myjetdr * 10)

    assoc_tools = []

    trkj_assoc = JetSubStructure.JetJetAssociatorTool(
        "Trk_JetJetAssociatorTool",
        ContainerName=trackjetcontname,
        AssociationName="TrackJets",
        MatchOrigin=True)
    assoc_tools += [trkj_assoc]

    if rec.doTruth():
        truthj_assoc = JetSubStructure.JetJetAssociatorTool(
            "Truth_JetJetAssociatorTool",
            ContainerName=truthcontname,
            AssociationName="TruthJets",
            MatchOrigin=False)
        assoc_tools += [truthj_assoc]

    e_assoc = JetSubStructure.ElectronJetAssociatorTool(
        "JSEAssoc",
        ContainerName='ElectronAODCollection',
        UseCluster=True,
        UseTrack=False,
        dR=myjetdr,
        ResolveCluster=True,
        OutputLevel=3)

    e_assoc.METClusterResolver.MaximumRadialDistance = 0.2
    e_assoc.METClusterResolver.LongitudinalExtension = 1.0
    e_assoc.METClusterResolver.RadialExtension = 1.0
    e_assoc.METClusterResolver.EnergyFractionThreshold = 0.1
    e_assoc.METClusterResolver.OutputLevel = 3

    mu_assoc = JetSubStructure.MuonJetAssociatorTool(
        "JSMuAssoc",
        ContainerName='MuidMuonCollection',
        UseTrack=False,
        dR=myjetdr,
        OutputLevel=3)
    assoc_tools += [e_assoc, mu_assoc]

    assoc_tool = JetSubStructure.JetAssociationTool(
        name='JetAssocTool',
        AssociatorTools=assoc_tools,
        GroomingTools=myGroomingTools,
        UsedSignalState=2,
        JetAlgTools=grjets_calib + [wrapped_sortertool, widthtool],
        OutputLevel=5)

    jetsubstructure_tool = JetSubStructure.JetSubstructureTool(
        name='JetSubstructureTool',
        UsedSignalState=2,
        OutputLevel=3,
        SubstructureTools=[
            JetSubStructure.NSubjettinessTool(
                "myNSubjettinessTool",
                N=[1, 2, 3],
                R0=myjetdr,
                GroomedjetsAuthor=catNames_trimmed),
            JetSubStructure.KtHadSubstructureTool(
                "myhadtool", GroomedjetsAuthor=catNames_trimmed),
            JetSubStructure.KtElectronSubstructureTool("myelectool",
                                                       GroomedjetsAuthor=[]),
            JetSubStructure.KtMuonSubstructureTool("mymuontool",
                                                   GroomedjetsAuthor=[]),
            JetSubStructure.JetPullVectorTool(
                "myJetPullVectorTool", GroomedjetsAuthor=catNames_trimmed)
        ])

    outkey = myjetfinder + '%d' % (myjetdr * 10) + myjetinput
    if myjetinput == 'Topo':
        outkey += 'EM'
    outkey += 'Jets'  #'JSJets' for rebuilding on the fly

    myjetgetter = make_StandardJetGetter(myjetfinder,
                                         myjetdr,
                                         myjetinput,
                                         seq=theseq,
                                         doCalib=mydoCalib,
                                         calibName=mycalibName,
                                         addDefaultMoment=False,
                                         outputCollectionName=outkey)

    contname = myjetgetter.outputKey()

    extra_moments_list = []
    if myjetgetter.jetAlgorithmHandle(
    ) == None:  # JetCollection already in AOD
        if contname == None:
            contname = myjetgetter.buildName()

        if contname == 'AntiKt4LCTopoJets':
            contname = 'AntiKt4LCTopoJetsReTagged'
    else:
        extra_moments_list += [widthtool]

    # ------------------------------------------------
    # Associate a vertex and set the JVF moment. Must be placed AFTER vertex correction
    # ------------------------------------------------
    from AthenaCommon.DetFlags import DetFlags
    from AthenaCommon.AppMgr import ToolSvc
    noVertex = jobproperties.Beam.beamType == 'cosmics' or jobproperties.Beam.beamType == 'singlebeam'
    if DetFlags.detdescr.ID_on() and jetFlags.doJVF(
    ) and 'Truth' not in myjetinput and not noVertex and myjetdr >= 0.7:
        from JetSubStructure.mySetupJetMomentTools import mygetJetVertexAssociationTool
        myjvatool = mygetJetVertexAssociationTool(myjetfinder, myjetdr,
                                                  myjetinput,
                                                  'Custom%d' % (myjetdr * 10))
        #add_jetMoments_to_JetAlg(myjetgetter, [myjvatool])
        extra_moments_list += [myjvatool]

    make_JetMomentGetter(
        contname, extra_moments_list + [assoc_tool, jetsubstructure_tool],
        theseq)

    ## for lepton assoc
    jetcont = contname[:-4]  #removing the 'Jets'
    if contname == 'AntiKt4LCTopoJetsReTagged':
        jetcont = 'AntiKt4LCTopo'

    for x in catNames_trimmed:
        make_JetMomentGetter(jetcont + x + 'Jets', [
            JetSubStructure.JetAssociationTool(
                'JetAssocToolGr',
                AssociatorTools=[e_assoc, mu_assoc],
                GroomingTools=[],
                UsedSignalState=2,
                JetAlgTools=[],
                OutputLevel=5),
            JetSubStructure.JetSubstructureTool(
                'JetSubstructureToolGr',
                UsedSignalState=2,
                SubstructureTools=[
                    JetSubStructure.KtElectronSubstructureTool(
                        "myelectool", GroomedjetsAuthor=[]),
                    JetSubStructure.KtMuonSubstructureTool(
                        "mymuontool", GroomedjetsAuthor=[])
                ])
        ], theseq)

    return [contname, catNames]
Ejemplo n.º 2
0
def setupCaloJets(myjetfinder, myjetdr, myjetinput, GroomedDicts, theseq):

  myGroomingTools, catNames = getGroomingTools(GroomedDicts)

  sortertool = JetSorterTool('JS_JetSorter', SortOrder="ByPtDown", OutputLevel=3 )
  widthtool = JetWidthTool('JS_JetWidthTool')

  grjets_calib = []

  ## Origin correction

  mydoCalib = False
  mycalibName = ''

  from JetSubStructure.mySetupJetCalibrators import doEtaMassJESCorrection
  from JetCalibTools.MakeCalibSequences import calibTags
  calibTags['ETAMASSJES'] = doEtaMassJESCorrection

  if 'LCTopo' in myjetinput:
    #mydoCalib =	True
    mydoCalib =	False
    if (myjetfinder + '%d'%(myjetdr*10) == 'AntiKt10') or (myjetfinder + '%d'%(myjetdr*10) == 'CamKt12'):
       mycalibName = 'LC:ORIGIN_ETAMASSJES'
    else:
       mycalibName = 'LC:ORIGIN'

    stdcaliblist = []
    allowedcalib = ['AntiKt10LCTopoTrimmedJets', 'AntiKt10LCTopoTrimmedPtFrac3SmallR30Jets','AntiKt10LCTopoTrimmedPtFrac5SmallR30Jets','CamKt12LCTopoTrimmedPtFrac5SmallR30Jets']
    for x in catNames:
       author  = myjetfinder + '%d'%(myjetdr*10) + myjetinput + x + 'Jets'
       if author in allowedcalib :
           #grjets_calib += [JetSubStructure.JetAlgToolWrapper(name = 'calibtool_origin_etamassjes_'+x, JetAlgTool = getStandardCalibTool(myjetfinder,myjetdr, myjetinput+x, doCalib=True, calibName='LC:ORIGIN_ETAMASSJES')[0], GroomedjetsAuthor = stdcaliblist )]
           #grjets_calib += [JetSubStructure.JetAlgToolWrapper(name = 'calibtool_origin_etamassjes_'+x, JetAlgTool = getStandardCalibTool(myjetfinder,myjetdr, myjetinput+x, doCalib=False)[0], GroomedjetsAuthor = stdcaliblist) ]
           pass
       else:
           stdcaliblist += [x]

    if stdcaliblist != [] :
        #grjets_calib += [JetSubStructure.JetAlgToolWrapper(name = 'calibtool_origin',JetAlgTool = getStandardCalibTool(myjetfinder,myjetdr, myjetinput, doCalib=False, calibName='LC:ORIGIN')[0], GroomedjetsAuthor = stdcaliblist )]
        pass
  elif 'Topo' in myjetinput:
    #mydoCalib = True
    mydoCalib = False
    mycalibName = 'EM:ORIGIN'
    #grjets_calib += getStandardCalibTool(myjetfinder,myjetdr, myjetinput, doCalib=True, calibName='EM:ORIGIN')
    grjets_calib += getStandardCalibTool(myjetfinder,myjetdr, myjetinput, doCalib=False, calibName='EM:ORIGIN')
 

  truthcontname = 'none'
  if rec.doTruth():
    truthcontname = myjetfinder + '%dTruthJets' % (myjetdr*10)
  trackjetcontname =  myjetfinder + '%dTrackZJets' % (myjetdr*10)


  assoc_tools = []

  trkj_assoc = JetSubStructure.JetJetAssociatorTool("Trk_JetJetAssociatorTool", ContainerName = trackjetcontname,
                                                                               AssociationName = "TrackJets",
                                                                               MatchOrigin = True)
  assoc_tools += [ trkj_assoc ]

  if rec.doTruth():
    truthj_assoc = JetSubStructure.JetJetAssociatorTool("Truth_JetJetAssociatorTool", ContainerName = truthcontname,
                                                                               AssociationName = "TruthJets",
                                                                               MatchOrigin = False)
    assoc_tools += [ truthj_assoc ]

  doArea = False
  if 'LCTopo' in myjetinput:
    doArea = True
    assoc_tools += [ JetSubStructure.GhostJetJetAssociatorTool("myGhostJetJetAssociatorTool", JetdR = myjetdr, JetFinder = myjetfinder, JetInputTool = getStandardInputTools(input=myjetinput)[0],OutputLevel=3) ]

  assoc_tool = JetSubStructure.JetAssociationTool(                                                                                  
                      name = 'JetAssocTool',
                      AssociatorTools = assoc_tools, 
                      GroomingTools = myGroomingTools, UsedSignalState = 2, Area = doArea,
                      JetAlgTools = grjets_calib +  [sortertool, widthtool], OutputLevel = 3
                     )

  jetsubstructure_tool = JetSubStructure.JetSubstructureTool(
                           name = 'JetSubstructureTool', UsedSignalState = 2, OutputLevel=3,
                           SubstructureTools = [JetSubStructure.NSubjettinessTool("myNSubjettinessTool", N=[1,2,3], R0=myjetdr, GroomedjetsAuthor = catNames),
                                       JetSubStructure.KtHadSubstructureTool("myhadtool", GroomedjetsAuthor = catNames),
                                       JetSubStructure.DipolarityTool("myDipolarityTool",GroomedjetsAuthor = catNames),
                                       JetSubStructure.JetVoronoiAreaCalcTool("myVoronoiArea", GroomedjetsAuthor = catNames, JetdR = myjetdr, JetInputTool = getStandardInputTools(input=myjetinput)[0]) ])


  outkey = myjetfinder + '%d'%(myjetdr*10) + myjetinput
  if myjetinput == 'Topo':
     outkey += 'EM'
  outkey += 'Jets'
 
  myjetgetter = make_StandardJetGetter(myjetfinder, myjetdr, myjetinput, seq = theseq, doCalib=mydoCalib, calibName=mycalibName,addDefaultMoment=False, minPt=30*GeV,
                                       outputCollectionName = outkey)
  contname = myjetgetter.outputKey()

  extra_moments_list = []
  if myjetgetter.jetAlgorithmHandle() == None:     # JetCollection already in AOD
      if contname == None:
         contname=myjetgetter.buildName()
      print 'yo2: ', contname
  else:
      extra_moments_list += [widthtool] 


  #add_jetMoments_to_JetAlg(myjetgetter, [JetWidthTool()])

  # ------------------------------------------------
  # Associate a vertex and set the JVF moment. Must be placed AFTER vertex correction
  # ------------------------------------------------
  from AthenaCommon.DetFlags import DetFlags
  from AthenaCommon.AppMgr import ToolSvc
  noVertex = jobproperties.Beam.beamType == 'cosmics' or jobproperties.Beam.beamType == 'singlebeam'
  if DetFlags.detdescr.ID_on() and jetFlags.doJVF() and 'Truth' not in myjetinput and not noVertex:
     from JetSubStructure.mySetupJetMomentTools import mygetJetVertexAssociationTool
     myjvatool = mygetJetVertexAssociationTool(myjetfinder, myjetdr,myjetinput,'Custom%d'%(myjetdr*10))
     #add_jetMoments_to_JetAlg(myjetgetter, [myjvatool])
     extra_moments_list += [myjvatool]

  make_JetMomentGetter(contname , extra_moments_list + [assoc_tool, jetsubstructure_tool], theseq )

  return [ contname, catNames ]
Ejemplo n.º 3
0
def setupCaloJets(myjetfinder, myjetdr, myjetinput, GroomedDicts, theseq):

    myGroomingTools, catNames = getGroomingTools(GroomedDicts)

    #catNames_trimmed = list(x for x in catNames if 'Trimmed' in x)
    #catNames_trimmed += list(x for x in catNames if 'Filter' in x)
    #catNames_trimmed = catNames
    catNames_trimmed = list(x for x in catNames if 'Subjet' not in x)

    sortertool = JetSorterTool('myJetSorter',
                               SortOrder="ByPtDown",
                               OutputLevel=3)
    wrapped_sortertool = JetSubStructure.JetAlgToolWrapper(
        "JetSorterWrapper",
        JetAlgTool=sortertool,
        GroomedjetsAuthor=catNames_trimmed)

    widthtool = JetWidthTool('JS_JetWidthTool')

    grjets_calib = []

    from JetSubStructure.mySetupJetCalibrators import doEtaMassJESCorrection
    from JetCalibTools.MakeCalibSequences import calibTags
    calibTags['ETAMASSJES'] = doEtaMassJESCorrection

    ## Origin correction

    mydoCalib = False
    mycalibName = ''

    if 'LCTopo' in myjetinput:
        mydoCalib = True
        if (myjetfinder + '%d' %
            (myjetdr * 10) == 'AntiKt10') or (myjetfinder + '%d' %
                                              (myjetdr * 10) == 'CamKt12'):
            mycalibName = 'LC:ORIGIN_ETAMASSJES'
        else:
            mycalibName = 'LC:ORIGIN'
        # overwrite with latest offset substraction
        mycalibName = "LC:ApplyAreaOffset"

        stdcaliblist = []
        #allowedcalib = ['AntiKt10LCTopoTrimmedJets', 'AntiKt10LCTopoTrimmedPtFrac3SmallR30Jets','AntiKt10LCTopoTrimmedPtFrac5SmallR30Jets','CamKt12LCTopoTrimmedPtFrac5SmallR30Jets']
        allowedcalib = []  # etamassjes is currently obsolete for these jets
        for x in catNames:
            author = myjetfinder + '%d' % (myjetdr *
                                           10) + myjetinput + x + 'Jets'
            if author in allowedcalib:
                grjets_calib += [
                    JetSubStructure.JetAlgToolWrapper(
                        name='calibtool_origin_etamassjes_' + x,
                        JetAlgTool=getStandardCalibTool(
                            myjetfinder,
                            myjetdr,
                            myjetinput + x,
                            doCalib=True,
                            calibName='LC:ORIGIN_ETAMASSJES')[0],
                        GroomedjetsAuthor=[x])
                ]
            #elif 'Trimmed' in x:
            else:
                stdcaliblist += [x]

        if stdcaliblist != []:
            grjets_calib += [
                JetSubStructure.JetAlgToolWrapper(
                    name='calibtool_origin',
                    JetAlgTool=getStandardCalibTool(myjetfinder,
                                                    myjetdr,
                                                    myjetinput,
                                                    doCalib=True,
                                                    calibName='LC:ORIGIN')[0],
                    GroomedjetsAuthor=stdcaliblist)
            ]
    elif 'Topo' in myjetinput:
        mydoCalib = True
        #mycalibName = 'EM:ORIGIN'
        # overwrite with latest offset substraction
        mycalibName = "EM:ApplyAreaOffset"

        grjets_calib += [
            JetSubStructure.JetAlgToolWrapper(
                name='calibtool_origin',
                JetAlgTool=getStandardCalibTool(myjetfinder,
                                                myjetdr,
                                                myjetinput,
                                                doCalib=True,
                                                calibName='EM:ORIGIN')[0],
                GroomedjetsAuthor=catNames_trimmed)
        ]
        #grjets_calib += getStandardCalibTool(myjetfinder,myjetdr, myjetinput, doCalib=True, calibName='EM:ORIGIN')

    truthcontname = 'none'
    if rec.doTruth():
        if myjetdr < 0.9:  #need to use truth collection on disk for smaller R jets for the TrueFlavorComponent block
            truthcontname = myjetfinder + '%dTruthJets' % (myjetdr * 10)
        else:
            truthcontname = myjetfinder + '%dTruthJSJets' % (myjetdr * 10)

    trackjetcontname = myjetfinder + '%dTrackZJets' % (myjetdr * 10)

    assoc_tools = []

    trkj_assoc = JetSubStructure.JetJetAssociatorTool(
        "Trk_JetJetAssociatorTool",
        ContainerName=trackjetcontname,
        AssociationName="TrackJets",
        MatchOrigin=True)
    assoc_tools += [trkj_assoc]

    if rec.doTruth():
        truthj_assoc = JetSubStructure.JetJetAssociatorTool(
            "Truth_JetJetAssociatorTool",
            ContainerName=truthcontname,
            AssociationName="TruthJets",
            MatchOrigin=False)
        assoc_tools += [truthj_assoc]

    e_assoc = JetSubStructure.ElectronJetAssociatorTool(
        "JSEAssoc",
        ContainerName='ElectronAODCollection',
        UseCluster=True,
        UseTrack=False,
        dR=myjetdr,
        ResolveCluster=True,
        OutputLevel=3)

    e_assoc.METClusterResolver.MaximumRadialDistance = 0.2
    e_assoc.METClusterResolver.LongitudinalExtension = 1.0
    e_assoc.METClusterResolver.RadialExtension = 1.0
    e_assoc.METClusterResolver.EnergyFractionThreshold = 0.1
    e_assoc.METClusterResolver.OutputLevel = 3

    mu_assoc = JetSubStructure.MuonJetAssociatorTool(
        "JSMuAssoc",
        ContainerName='MuidMuonCollection',
        UseTrack=False,
        dR=myjetdr,
        OutputLevel=3)
    assoc_tools += [e_assoc, mu_assoc]

    assoc_tool_ghost = JetSubStructure.GhostJetJetAssociatorTool(
        "myGhostJetJetAssociatorTool",
        JetdR=myjetdr,
        JetFinder=myjetfinder,
        JetInputTool=getStandardInputTools(input=myjetinput)[0],
        OutputLevel=3)

    ## btgging ##
    subjets_names = [x for x in catNames if "Subjets" in x]

    btag_tool = []
    if subjets_names != []:
        from JetRec.JetGetters import getStandardBTaggerTool
        jetFlags.doBTagging = True
        _btag_tool = getStandardBTaggerTool('AntiKt', 0.4, 'LCTopo')
        if len(_btag_tool) > 0:
            btag_tool += [
                JetSubStructure.JetAlgToolWrapper(
                    name='JetBTagger_' + ''.join(subjets_names),
                    JetAlgTool=_btag_tool[0],
                    GroomedjetsAuthor=subjets_names)
            ]
        jetFlags.doBTagging = True
    ## btagging end ##

    assoc_tool = JetSubStructure.JetAssociationTool(
        name='JetAssocTool',
        AssociatorTools=assoc_tools + [assoc_tool_ghost],
        GroomingTools=myGroomingTools,
        UsedSignalState=2,
        Area=True,
        JetAlgTools=grjets_calib + [wrapped_sortertool, widthtool] + btag_tool,
        OutputLevel=5)

    jetsubstructure_tool = JetSubStructure.JetSubstructureTool(
        name='JetSubstructureTool',
        UsedSignalState=2,
        OutputLevel=3,
        SubstructureTools=[
            JetSubStructure.NSubjettinessTool(
                "myNSubjettinessTool",
                N=[1, 2, 3],
                R0=myjetdr,
                GroomedjetsAuthor=catNames_trimmed),
            JetSubStructure.KtHadSubstructureTool(
                "myhadtool", GroomedjetsAuthor=catNames_trimmed),
            JetSubStructure.KtElectronSubstructureTool("myelectool",
                                                       GroomedjetsAuthor=[]),
            JetSubStructure.KtMuonSubstructureTool("mymuontool",
                                                   GroomedjetsAuthor=[]),
            JetSubStructure.DipolarityTool("myDipolarityTool",
                                           GroomedjetsAuthor=catNames_trimmed),
            JetSubStructure.JetVoronoiAreaCalcTool(
                "myVoronoiArea",
                GroomedjetsAuthor=catNames_trimmed,
                JetdR=myjetdr,
                JetInputTool=getStandardInputTools(input=myjetinput)[0]),
            JetSubStructure.JetShapesSubstructureTool(
                "myJetShapesTool", GroomedjetsAuthor=catNames_trimmed),
            JetSubStructure.JetPullVectorTool(
                "myJetPullVectorTool", GroomedjetsAuthor=catNames_trimmed)
        ])

    outkey = myjetfinder + '%d' % (myjetdr * 10) + myjetinput
    if myjetinput == 'Topo':
        outkey += 'EM'
    outkey += 'Jets'  #'JSJets' for rebuilding on the fly

    myjetgetter = make_StandardJetGetter(myjetfinder,
                                         myjetdr,
                                         myjetinput,
                                         seq=theseq,
                                         doCalib=mydoCalib,
                                         calibName=mycalibName,
                                         addDefaultMoment=False,
                                         outputCollectionName=outkey,
                                         minPt=50 * GeV)

    contname = myjetgetter.outputKey()

    extra_moments_list = []
    if myjetgetter.jetAlgorithmHandle(
    ) == None:  # JetCollection already in AOD
        if contname == None:
            contname = myjetgetter.buildName()

        #if contname == 'AntiKt4LCTopoJets':
        #   contname = 'AntiKt4LCTopoJetsReTagged'
    else:
        extra_moments_list += [widthtool]

    # ------------------------------------------------
    # Associate a vertex and set the JVF moment. Must be placed AFTER vertex correction
    # ------------------------------------------------
    from AthenaCommon.DetFlags import DetFlags
    from AthenaCommon.AppMgr import ToolSvc
    noVertex = jobproperties.Beam.beamType == 'cosmics' or jobproperties.Beam.beamType == 'singlebeam'
    if DetFlags.detdescr.ID_on() and jetFlags.doJVF(
    ) and 'Truth' not in myjetinput and not noVertex and myjetdr >= 0.7:
        from JetSubStructure.mySetupJetMomentTools import mygetJetVertexAssociationTool
        myjvatool = mygetJetVertexAssociationTool(myjetfinder, myjetdr,
                                                  myjetinput,
                                                  'Custom%d' % (myjetdr * 10))
        #add_jetMoments_to_JetAlg(myjetgetter, [myjvatool])
        extra_moments_list += [myjvatool]

    ## Ghost Track Matching
    from JetMomentTools.GhostAssociation import setupGhostAssociationTool
    t = setupGhostAssociationTool(contname, ["TrackAssoc"])
    t.GhostAssociators[0].AssociationName = "TrackAssocTmp"
    t.CopyJetFindingMoment = False
    extra_moments_list += [t]

    make_JetMomentGetter(
        contname, extra_moments_list + [assoc_tool, jetsubstructure_tool],
        theseq)

    ## for lepton assoc
    jetcont = contname[:-4]  #removing the 'Jets'

    if contname == 'AntiKt4LCTopoJetsReTagged' or contname == 'AntiKt4LCTopoNewJets':
        jetcont = 'AntiKt4LCTopo'

    for x in catNames_trimmed:
        make_JetMomentGetter(jetcont + x + 'Jets', [
            JetSubStructure.JetAssociationTool(
                'JetAssocToolGr',
                AssociatorTools=[e_assoc, mu_assoc],
                GroomingTools=[],
                UsedSignalState=2,
                Area=True,
                JetAlgTools=[],
                OutputLevel=5),
            JetSubStructure.JetSubstructureTool(
                'JetSubstructureToolGr',
                UsedSignalState=2,
                SubstructureTools=[
                    JetSubStructure.KtElectronSubstructureTool(
                        "myelectool", GroomedjetsAuthor=[]),
                    JetSubStructure.KtMuonSubstructureTool(
                        "mymuontool", GroomedjetsAuthor=[])
                ])
        ], theseq)

    jetFlags.doBTagging = True

    return [contname, catNames]
Ejemplo n.º 4
0
def setupCaloJets(myjetfinder, myjetdr, myjetinput, GroomedDicts, theseq):

    myGroomingTools, catNames = getGroomingTools(GroomedDicts)

    sortertool = JetSorterTool('myJetSorter',
                               SortOrder="ByPtDown",
                               OutputLevel=3)

    grjets_calib = []

    ## Origin correction / Eta-Mass-JES hack

    from JetSubStructure.mySetupJetCalibrators import doEtaMassJESCorrection
    from JetCalibTools.MakeCalibSequences import calibTags
    calibTags['ETAMASSJES'] = doEtaMassJESCorrection

    mydoCalib = False
    mycalibName = ''

    if 'LCTopo' in myjetinput:
        mydoCalib = True
        if (myjetfinder + '%d' %
            (myjetdr * 10) == 'AntiKt10') or (myjetfinder + '%d' %
                                              (myjetdr * 10) == 'CamKt12'):
            mycalibName = 'LC:ORIGIN_ETAMASSJES'
        else:
            mycalibName = 'LC:ORIGIN'

        stdcaliblist = []
        allowedcalib = [
            'AntiKt10LCTopoTrimmedJets',
            'AntiKt10LCTopoTrimmedPtFrac3SmallR30Jets',
            'AntiKt10LCTopoTrimmedPtFrac5SmallR30Jets',
            'CamKt12LCTopoTrimmedPtFrac5SmallR30Jets'
        ]
        for x in catNames:
            author = myjetfinder + '%d' % (myjetdr *
                                           10) + myjetinput + x + 'Jets'
            if author in allowedcalib:
                grjets_calib += [
                    JetSubStructure.JetAlgToolWrapper(
                        name='calibtool_origin_etamassjes_' + x,
                        JetAlgTool=getStandardCalibTool(
                            myjetfinder,
                            myjetdr,
                            myjetinput + x,
                            doCalib=True,
                            calibName='LC:ORIGIN_ETAMASSJES')[0],
                        GroomedjetsAuthor=[x])
                ]
            else:
                stdcaliblist += [x]

        if stdcaliblist != []:
            grjets_calib += [
                JetSubStructure.JetAlgToolWrapper(
                    name='calibtool_origin',
                    JetAlgTool=getStandardCalibTool(myjetfinder,
                                                    myjetdr,
                                                    myjetinput,
                                                    doCalib=True,
                                                    calibName='LC:ORIGIN')[0],
                    GroomedjetsAuthor=stdcaliblist)
            ]
    elif 'Topo' in myjetinput:
        mydoCalib = True
        mycalibName = 'EM:ORIGIN'
        grjets_calib += getStandardCalibTool(myjetfinder,
                                             myjetdr,
                                             myjetinput,
                                             doCalib=True,
                                             calibName='EM:ORIGIN')

    assoc_tools = []
    if rec.doTruth():
        truthcontname = myjetfinder + '%dTruthJets' % (myjetdr * 10)
        if hasattr(theseq, truthcontname):
            truthj_assoc = JetSubStructure.JetJetAssociatorTool(
                "Truth_JetJetAssociatorTool",
                ContainerName=truthcontname,
                AssociationName="TruthJets",
                MatchOrigin=False)

    trackjetcontname = myjetfinder + '%dTrackZJets' % (myjetdr * 10)
    if hasattr(theseq, trackjetcontname):
        trkj_assoc = JetSubStructure.JetJetAssociatorTool(
            "Trk_JetJetAssociatorTool",
            ContainerName=trackjetcontname,
            AssociationName="TrackJets",
            MatchOrigin=True)

    ## batgging ##
    subjets_names = [x for x in catNames if "Subjets" in x]
    btag_tool = []
    if subjets_names != '':
        from JetRec.JetGetters import getStandardBTaggerTool
        from JetRec.JetRecFlags import jetFlags
        jetFlags.doBTagging = True
        _btag_tool = getStandardBTaggerTool('AntiKt', 0.4, 'LCTopo')
        if len(_btag_tool) > 0:
            btag_tool += [
                JetSubStructure.JetAlgToolWrapper(
                    name='JetBTagger_' + ''.join(subjets_names),
                    JetAlgTool=_btag_tool[0],
                    GroomedjetsAuthor=subjets_names)
            ]
        jetFlags.doBTagging = False

    ## btagging end ##

    assoc_tool = JetSubStructure.JetAssociationTool(
        name='JetAssocTool',
        AssociatorTools=assoc_tools,
        GroomingTools=myGroomingTools,
        UsedSignalState=2,
        JetAlgTools=grjets_calib + [sortertool] + btag_tool,
        OutputLevel=3)

    myjetgetter = make_StandardJetGetter(myjetfinder,
                                         myjetdr,
                                         myjetinput,
                                         seq=theseq,
                                         doCalib=mydoCalib,
                                         calibName=mycalibName,
                                         addDefaultMoment=False)
    contname = myjetgetter.outputKey()

    # ------------------------------------------------
    # Associate a vertex and set the JVF moment. Must be placed AFTER vertex correction
    # ------------------------------------------------
    from AthenaCommon.DetFlags import DetFlags
    from AthenaCommon.AppMgr import ToolSvc
    noVertex = jobproperties.Beam.beamType == 'cosmics' or jobproperties.Beam.beamType == 'singlebeam'
    if DetFlags.detdescr.ID_on() and jetFlags.doJVF(
    ) and 'Truth' not in myjetinput and not noVertex:
        from JetSubStructure.mySetupJetMomentTools import mygetJetVertexAssociationTool
        myjvatool = mygetJetVertexAssociationTool(myjetfinder, myjetdr,
                                                  myjetinput,
                                                  'Custom%d' % (myjetdr * 10))
        add_jetMoments_to_JetAlg(myjetgetter, [myjvatool])

    make_JetMomentGetter(contname, [assoc_tool], theseq)

    return [contname, catNames]