Exemple #1
0
 def addJetTrimmer(self, output, rclus, ptfrac, input, modifiersin ="groomed",
                   pseudojetRetriever ="jpjretriever",
                   isTrigger =False, useTriggerStore =False, doArea =True):
   from JetRec.JetRecConf import JetTrimmer
   from JetRec.JetRecConf import JetRecTool
   groomer = JetTrimmer(output + "Groomer")
   groomer.RClus = rclus
   groomer.PtFrac = ptfrac
   if doArea:
     groomer.JetBuilder = self.jetBuilderWithArea
   else:
     groomer.JetBuilder = self.jetBuilderWithoutArea
   self += groomer
   jetrec = JetRecTool(output)
   jetrec.JetGroomer = groomer
   jetrec.InputContainer = input
   jetrec.OutputContainer = output
   jetrec.JetModifiers = self.getModifiers(modifiersin)
   jetrec.Trigger = isTrigger or useTriggerStore
   jetrec.Timer = jetFlags.timeJetRecTool()
   if pseudojetRetriever in self.tools:
     jetrec.JetPseudojetRetriever = self.tools[pseudojetRetriever]
   else:
     jetlog.info( "Requested jet pseudojet retriever is not a registered tool: " \
           + pseudojetRetriever )
     raise KeyError
   self += jetrec
   if isTrigger:
     self.trigjetrecs += [jetrec]
   else:
     self.jetrecs += [jetrec]
   self.jetcons += [output]
   return jetrec
Exemple #2
0
 def addJetReclusterer(self, output, alg, radius, input, modifiersin =None,
                       consumers =None, ivtx =None,
                       ghostArea =0.0, ptmin =0.0, ptminFilter =0.0, rndseed =1,
                       isTrigger =False, useTriggerStore =False,
                       variableRMinRadius =-1.0, variableRMassScale =-1.0,
                       calibOpt ="", jetPseudojetCopier =""):
   self.msg(2, "Adding reclusterer")
   from JetRec.JetRecConf import JetRecTool
   from JetRec.JetRecConf import JetReclusterer
   # Retrieve/build the jet finder.
   lofinder,hifinder = self.addJetFinderTool(output+"Finder", alg, radius, ivtx, ghostArea, ptmin, rndseed, 
                                             variableRMinRadius, variableRMassScale)
   reclname = output + "Reclusterer"
   groomer = JetReclusterer(
     reclname,
     JetConstituentsRetriever = self.tools["jconretriever"],
     JetFinder = hifinder
   )
   self += groomer
   jetrec = JetRecTool(output)
   jetrec.InputContainer = input
   jetrec.OutputContainer = output
   jetrec.JetGroomer = groomer
   jetrec.JetModifiers = self.getModifiers(modifiersin)
   if consumers != None:
     jetrec.JetConsumers = consumers
   jetrec.Trigger = isTrigger or useTriggerStore
   jetrec.Timer = jetFlags.timeJetRecTool()
   self += jetrec
   if isTrigger:
     self.trigjetrecs += [jetrec]
   else:
     self.jetrecs += [jetrec]
   self.jetcons += [output]
   return jetrec
Exemple #3
0
 def addJetReclusterer(self, output, alg, radius, input, modifiersin =None,
                       consumers =None, ivtx =None,
                       ghostArea =0.0, ptmin =0.0, ptminFilter =0.0, rndseed =1,
                       isTrigger =False, useTriggerStore =False,
                       variableRMinRadius =-1.0, variableRMassScale =-1.0,
                       calibOpt ="", jetPseudojetCopier =""):
   self.msg(2, "Adding reclusterer")
   from JetRec.JetRecConf import JetRecTool
   from JetRec.JetRecConf import JetReclusterer
   # Retrieve/build the jet finder.
   lofinder,hifinder = self.addJetFinderTool(output+"Finder", alg, radius, ivtx, ghostArea, ptmin, rndseed, 
                                             variableRMinRadius, variableRMassScale)
   reclname = output + "Reclusterer"
   groomer = JetReclusterer(
     reclname,
     JetConstituentsRetriever = self.tools["jconretriever"],
     JetFinder = hifinder
   )
   self += groomer
   jetrec = JetRecTool(output)
   jetrec.InputContainer = input
   jetrec.OutputContainer = output
   jetrec.JetGroomer = groomer
   jetrec.JetModifiers = self.getModifiers(modifiersin)
   if consumers != None:
     jetrec.JetConsumers = consumers
   jetrec.Trigger = isTrigger or useTriggerStore
   jetrec.Timer = jetFlags.timeJetRecTool()
   self += jetrec
   if isTrigger:
     self.trigjetrecs += [jetrec]
   else:
     self.jetrecs += [jetrec]
   self.jetcons += [output]
   return jetrec
Exemple #4
0
 def addJetSplitter(self,
                    output,
                    mumax,
                    ymin,
                    input,
                    modifiersin="groomed",
                    isTrigger=False,
                    useTriggerStore=False,
                    doArea=True):
     from JetRec.JetRecConf import JetSplitter
     from JetRec.JetRecConf import JetRecTool
     groomer = JetSplitter(output + "Groomer")
     groomer.MuMax = mumax
     groomer.YMin = ymin
     groomer.BDRS = False
     groomer.NSubjetMax = 3
     if doArea:
         groomer.JetBuilder = self.jetBuilderWithArea
     else:
         groomer.JetBuilder = self.jetBuilderWithoutArea
     self += groomer
     jetrec = JetRecTool(output)
     jetrec.JetGroomer = groomer
     jetrec.InputContainer = input
     jetrec.OutputContainer = output
     jetrec.JetModifiers = self.getModifiers(modifiersin)
     jetrec.Trigger = isTrigger or useTriggerStore
     jetrec.Timer = jetFlags.timeJetRecTool()
     self += jetrec
     if isTrigger:
         self.trigjetrecs += [jetrec]
     else:
         self.jetrecs += [jetrec]
     self.jetcons += [output]
     return jetrec
Exemple #5
0
 def addJetTrimmer(self, output, rclus, ptfrac, input, modifiersin ="groomed",
                   pseudojetRetriever ="jpjretriever",
                   isTrigger =False, useTriggerStore =False, doArea =True):
   from JetRec.JetRecConf import JetTrimmer
   from JetRec.JetRecConf import JetRecTool
   groomer = JetTrimmer(output + "Groomer")
   groomer.RClus = rclus
   groomer.PtFrac = ptfrac
   if doArea:
     groomer.JetBuilder = self.jetBuilderWithArea
   else:
     groomer.JetBuilder = self.jetBuilderWithoutArea
   self += groomer
   jetrec = JetRecTool(output)
   jetrec.JetGroomer = groomer
   jetrec.InputContainer = input
   jetrec.OutputContainer = output
   jetrec.JetModifiers = self.getModifiers(modifiersin)
   jetrec.Trigger = isTrigger or useTriggerStore
   jetrec.Timer = jetFlags.timeJetRecTool()
   if pseudojetRetriever in self.tools:
     jetrec.JetPseudojetRetriever = self.tools[pseudojetRetriever]
   else:
     print "Requested jet pseudojet retriever is not a registered tool: " \
           + pseudojetRetriever
     raise KeyError
   self += jetrec
   if isTrigger:
     self.trigjetrecs += [jetrec]
   else:
     self.jetrecs += [jetrec]
   self.jetcons += [output]
   return jetrec
Exemple #6
0
 def addJetPruner(self,
                  output,
                  rcut,
                  zcut,
                  input,
                  modifiersin="groomed",
                  isTrigger=False,
                  useTriggerStore=False,
                  doArea=True):
     from JetRec.JetRecConf import JetPruner
     from JetRec.JetRecConf import JetRecTool
     groomer = JetPruner(output + "Groomer")
     groomer.RCut = rcut
     groomer.ZCut = zcut
     if doArea:
         groomer.JetBuilder = self.jetBuilderWithArea
     else:
         groomer.JetBuilder = self.jetBuilderWithoutArea
     self += groomer
     jetrec = JetRecTool(output)
     jetrec.JetGroomer = groomer
     jetrec.InputContainer = input
     jetrec.OutputContainer = output
     jetrec.JetModifiers = self.getModifiers(modifiersin)
     jetrec.Trigger = isTrigger or useTriggerStore
     jetrec.Timer = jetFlags.timeJetRecTool()
     self += jetrec
     if isTrigger:
         self.trigjetrecs += [jetrec]
     else:
         self.jetrecs += [jetrec]
     self.jetcons += [output]
     return jetrec
Exemple #7
0
def addKmeansCollection(nsubjet, recordNameAppendix = "", ToolSvc = ToolSvc, Sequencer = FTAG5Seq):
  global KmeansJetCollection__SubJet

  output = []
  for JetCollectionKmeans in KmeansJetCollection__FatJet:
      # build KmeansbbTagTool instance
      (KmeansbbTagToolInstance, SubjetContainerName) = buildKmeansSubjets(JetCollectionKmeans, nsubjet, recordNameAppendix, ToolSvc)
      KmeansJetCollection__SubJet += [SubjetContainerName]
      output += [SubjetContainerName]

      # build subjet collection through JetRecTool
      from JetRec.JetRecConf import JetRecTool
      jetrec = JetRecTool(
                           name = "JetRecTool_Kmeansbb%i%s_%s" % (nsubjet, recordNameAppendix, JetCollectionKmeans),
                           OutputContainer = JetCollectionKmeans,
                           InputContainer = JetCollectionKmeans,
                           JetModifiers = [KmeansbbTagToolInstance],
                         )

      ToolSvc += jetrec
      Sequencer += JetAlgorithm(
                                name = "JetAlgorithm_Kmeansbb%i%s_%s" % (nsubjet, recordNameAppendix, JetCollectionKmeans),
                                Tools = [jetrec],
                               )

  return output
Exemple #8
0
 def addJetSplitter(self, output, mumax, ymin, input, modifiersin ="groomed",
                    isTrigger =False, useTriggerStore =False):
   if self.m_jetBuilder == None:
     self.msg(0, "Jet builder must be specified")
   from JetRec.JetRecConf import JetSplitter
   from JetRec.JetRecConf import JetRecTool
   groomer = JetSplitter(output + "Groomer")
   groomer.MuMax = mumax
   groomer.YMin = ymin
   groomer.BDRS = False
   groomer.NSubjetMax = 3
   groomer.JetBuilder = self.m_jetBuilder
   self += groomer
   jetrec = JetRecTool(output)
   jetrec.JetGroomer = groomer
   jetrec.InputContainer = input
   jetrec.OutputContainer = output
   jetrec.JetModifiers = self.getModifiers(modifiersin)
   jetrec.Trigger = isTrigger or useTriggerStore
   jetrec.Timer = self.timer
   self += jetrec
   if isTrigger:
     self.trigjetrecs += [jetrec]
   else:
     self.jetrecs += [jetrec]
   self.jetcons += [output]
   return jetrec
Exemple #9
0
 def addJetSplitter(self, output, mumax, ymin, input, modifiersin ="groomed",
                    isTrigger =False, useTriggerStore =False, doArea =True):
   from JetRec.JetRecConf import JetSplitter
   from JetRec.JetRecConf import JetRecTool
   groomer = JetSplitter(output + "Groomer")
   groomer.MuMax = mumax
   groomer.YMin = ymin
   groomer.BDRS = False
   groomer.NSubjetMax = 3
   if doArea:
     groomer.JetBuilder = self.jetBuilderWithArea
   else:
     groomer.JetBuilder = self.jetBuilderWithoutArea
   self += groomer
   jetrec = JetRecTool(output)
   jetrec.JetGroomer = groomer
   jetrec.InputContainer = input
   jetrec.OutputContainer = output
   jetrec.JetModifiers = self.getModifiers(modifiersin)
   jetrec.Trigger = isTrigger or useTriggerStore
   jetrec.Timer = jetFlags.timeJetRecTool()
   self += jetrec
   if isTrigger:
     self.trigjetrecs += [jetrec]
   else:
     self.jetrecs += [jetrec]
   self.jetcons += [output]
   return jetrec
Exemple #10
0
 def addJetPruner(self, output, rcut, zcut, input, modifiersin ="groomed",
                  isTrigger =False, useTriggerStore =False):
   if self.m_jetBuilder == None:
     self.msg(0, "Jet builder must be specified")
   from JetRec.JetRecConf import JetPruner
   from JetRec.JetRecConf import JetRecTool
   groomer = JetPruner(output + "Groomer")
   groomer.RCut = rcut
   groomer.ZCut = zcut
   groomer.JetBuilder = self.m_jetBuilder
   self += groomer
   jetrec = JetRecTool(output)
   jetrec.JetGroomer = groomer
   jetrec.InputContainer = input
   jetrec.OutputContainer = output
   jetrec.JetModifiers = self.getModifiers(modifiersin)
   jetrec.Trigger = isTrigger or useTriggerStore
   jetrec.Timer = self.timer
   self += jetrec
   if isTrigger:
     self.trigjetrecs += [jetrec]
   else:
     self.jetrecs += [jetrec]
   self.jetcons += [output]
   return jetrec
Exemple #11
0
 def addJetPruner(self, output, rcut, zcut, input, modifiersin ="groomed",
                  isTrigger =False, useTriggerStore =False, doArea =True):
   from JetRec.JetRecConf import JetPruner
   from JetRec.JetRecConf import JetRecTool
   groomer = JetPruner(output + "Groomer")
   groomer.RCut = rcut
   groomer.ZCut = zcut
   if doArea:
     groomer.JetBuilder = self.jetBuilderWithArea
   else:
     groomer.JetBuilder = self.jetBuilderWithoutArea
   self += groomer
   jetrec = JetRecTool(output)
   jetrec.JetGroomer = groomer
   jetrec.InputContainer = input
   jetrec.OutputContainer = output
   jetrec.JetModifiers = self.getModifiers(modifiersin)
   jetrec.Trigger = isTrigger or useTriggerStore
   jetrec.Timer = jetFlags.timeJetRecTool()
   self += jetrec
   if isTrigger:
     self.trigjetrecs += [jetrec]
   else:
     self.jetrecs += [jetrec]
   self.jetcons += [output]
   return jetrec
Exemple #12
0
  def addJetFinder(self, output, alg, radius, gettersin, modifiersin =None,
                   consumers =None, ivtxin =None,
                   ghostArea =0.0, ptmin =0.0, ptminFilter =0.0, rndseed =1,
                   isTrigger =False, useTriggerStore =False,
                   variableRMinRadius =-1.0, variableRMassScale =-1.0,
                   calibOpt ="", jetPseudojetCopier ="",
                   warnIfDuplicate=True,
                   overwrite=False):
    self.msg(2, "Adding finder")
    from JetRec.JetRecConf import JetRecTool
    if type(gettersin) == str:
      getters = self.gettersMap[gettersin]
    else:
      getters = gettersin
    # If jet finding by vertex is not specified, check for special input type names
    ivtx = ivtxin
    if ivtx == None:
      if gettersin == "ztrack": ivtx = -1        # Find tracs separatesly for each vertex
      elif gettersin == "pv0track": ivtx = 0     # Find tracks only for 1st vertex
    # Retrieve/build the jet finder.
    lofinder,hifinder = self.addJetFinderTool(output+"Finder", alg, radius, ivtx, ghostArea, ptmin, rndseed, 
                                            variableRMinRadius, variableRMassScale)
    jetrec = JetRecTool(output)
    jetrec.PseudoJetGetters = getters
    jetrec.JetFinder = hifinder
    jetrec.OutputContainer = output
    ptminSave = self.ptminFilter
    if ptminFilter > 0.0: self.ptminFilter = ptminFilter
    jetrec.JetModifiers = self.buildModifiers(modifiersin, lofinder, getters, gettersin, output, calibOpt)
    if consumers != None:
      jetrec.JetConsumers = consumers
    self.ptminFilter = ptminSave
    jetrec.Trigger = isTrigger or useTriggerStore
    jetrec.Timer = jetFlags.timeJetRecTool()
    jetrec.WarnIfDuplicate = warnIfDuplicate
    jetrec.Overwrite = overwrite

    self += jetrec
    if isTrigger:
      self.trigjetrecs += [jetrec]
    else:
      self.jetrecs += [jetrec]
    self.jetcons += [output]
    return jetrec
Exemple #13
0
    def addJetCopier(self,
                     output,
                     input,
                     modifiersin,
                     ptminFilter=0.0,
                     radius=0.0,
                     alg="",
                     inp="",
                     isTrigger=False,
                     useTriggerStore=False,
                     calibOpt="",
                     shallow=True):
        from JetRec.JetRecConf import JetRecTool
        jetrec = JetRecTool(output)
        jetrec.InputContainer = input
        jetrec.OutputContainer = output
        ptminSave = self.ptminFilter
        if ptminFilter > 0.0: self.ptminFilter = ptminFilter

        class finder:
            JetRadius = radius
            JetAlgorithm = alg

        class get:
            Label = inp

        getters = [get]
        jetrec.JetModifiers = self.buildModifiers(modifiersin, finder, getters,
                                                  None, output, calibOpt)
        self.ptminFilter = ptminSave
        jetrec.Trigger = isTrigger or useTriggerStore
        jetrec.Timer = jetFlags.timeJetRecTool()
        jetrec.ShallowCopy = shallow
        self += jetrec
        if isTrigger:
            self.trigjetrecs += [jetrec]
        else:
            self.jetrecs += [jetrec]
        self.jetcons += [output]
        return jetrec
Exemple #14
0
    def addJetRecursiveSoftDrop(self,
                                output,
                                beta,
                                zcut,
                                N,
                                r0,
                                input,
                                modifiersin="groomed",
                                isTrigger=False,
                                useTriggerStore=False,
                                doArea=True):
        from JetRec.JetRecConf import JetRecursiveSoftDrop
        from JetRec.JetRecConf import JetRecTool

        groomer = JetRecursiveSoftDrop(output + "Groomer")
        groomer.ZCut = zcut
        groomer.Beta = beta
        groomer.N = N
        groomer.R0 = r0
        if doArea:
            groomer.JetBuilder = self.jetBuilderWithArea
        else:
            groomer.JetBuilder = self.jetBuilderWithoutArea
        self += groomer
        jetrec = JetRecTool(output)
        jetrec.JetGroomer = groomer
        jetrec.InputContainer = input
        jetrec.OutputContainer = output
        jetrec.JetModifiers = self.getModifiers(modifiersin)
        self.autoconfigureModifiers(jetrec.JetModifiers, output)
        jetrec.Trigger = isTrigger or useTriggerStore
        jetrec.Timer = jetFlags.timeJetRecTool()
        self += jetrec
        if isTrigger:
            self.trigjetrecs += [jetrec]
        else:
            self.jetrecs += [jetrec]
        self.jetcons += [output]
        return jetrec
Exemple #15
0
def addCopyJet(FTAG5Seq, ToolSvc, InputJetCollectionName,
               OutputJetCollectionName, **options):
    doShallowCopy = options.pop("ShallowCopy", False)

    from JetRec.JetRecConf import JetRecTool
    jetrec = JetRecTool(name="JetRecTool_CopyJet_%s_%s" %
                        (InputJetCollectionName, OutputJetCollectionName),
                        OutputContainer=OutputJetCollectionName,
                        InputContainer=InputJetCollectionName,
                        ShallowCopy=doShallowCopy,
                        **options)

    ToolSvc += jetrec
    FTAG5Seq += JetAlgorithm(
        name="JetAlgorithm_CopyJet_%s_%s" %
        (InputJetCollectionName, OutputJetCollectionName),
        Tools=[jetrec],
    )

    return OutputJetCollectionName
Exemple #16
0
 def addJetCopier(self, output, input, modifiersin, ptminFilter =0.0, radius =0.0, alg ="", inp ="",
                  isTrigger=False, useTriggerStore=False, calibOpt ="", shallow =True):
   from JetRec.JetRecConf import JetRecTool
   jetrec = JetRecTool(output)
   jetrec.InputContainer = input
   jetrec.OutputContainer = output
   ptminSave = self.ptminFilter
   if ptminFilter > 0.0: self.ptminFilter = ptminFilter
   class finder:
     JetRadius = radius
     JetAlgorithm = alg
   class get:
     Label = inp
   getters = [get]
   jetrec.JetModifiers = self.buildModifiers(modifiersin, finder, getters, None, output, calibOpt)
   self.ptminFilter = ptminSave
   jetrec.Trigger = isTrigger or useTriggerStore
   jetrec.Timer = jetFlags.timeJetRecTool()
   jetrec.ShallowCopy = shallow
   self += jetrec
   self.jetrecs += [jetrec]
   self.jetcons += [output]
   return jetrec
Exemple #17
0
    return (ExKtbbTagToolInstance, SubjetContainerName)

ExKtJetCollection__FatJet = ["AntiKt10LCTopoTrimmedPtFrac5SmallR20Jets", "AntiKt10TrackJets"]
# ExKtJetCollection__FatJet = ["AntiKt10LCTopoTrimmedPtFrac5SmallR20Jets"]
ExKtJetCollection__SubJet = []
for JetCollectionExKt in ExKtJetCollection__FatJet:
    # build ExKtbbTagTool instance
    (ExKtbbTagToolInstance, SubjetContainerName) = buildExclusiveSubjets(JetCollectionExKt, 2)
    ExKtJetCollection__SubJet += [SubjetContainerName]

    # build subjet collection through JetRecTool
    from JetRec.JetRecConf import JetRecTool
    jetrec = JetRecTool(
                         name = "JetRecTool_ExKtbb_%s" % (JetCollectionExKt),
                         OutputContainer = JetCollectionExKt,
                         InputContainer = JetCollectionExKt,
                         JetModifiers = [ExKtbbTagToolInstance],
                       )

    ToolSvc += jetrec
    FTAG5Seq += JetAlgorithm(
                             name = "JetAlgorithm_ExKtbb_%s" % (JetCollectionExKt),
                             Tools = [jetrec],
                            )

#===================================================================
# Run b-tagging
#===================================================================

defaultTaggers = ['IP2D', 'IP3D', 'SV0', 'MultiSVbb1', 'MultiSVbb2', 'SV1', 'BasicJetFitter', 'JetFitterTag', 'JetFitterNN', 'GbbNNTag', 'MV2c00', 'MV2c10', 'MV2c20', 'MV2c100', 'MV2m']
specialTaggers = ['ExKtbb_Hbb_MV2Only', 'ExKtbb_Hbb_MV2andJFDRSig', 'ExKtbb_Hbb_MV2andTopos']
Exemple #18
0
# Dump before reco.
if 1:
  from JetRec.JetRecConf import JetDumper
  ToolSvc += JetDumper("inpdmp")
  inpdmp = ToolSvc.inpdmp
  inpdmp.ContainerName = "JetClusters"
  inpdmp.Detail = 1
  inpdmp.MaxObject = 20
  inpdmp.OutputLevel = INFO
  jetalg.Tools += [inpdmp]

# JetRec tool for finding.
if 0:
  from JetRec.JetRecConf import JetRecTool
  ToolSvc += JetRecTool("jetrec")
  jetrec = ToolSvc.jetrec
  jetrec.OutputContainer = "MyNewJets"
  jetrec.OutputLevel = INFO
  jetalg.Tools += [jetrec]

# Find jet inputs.
if 0:
  from JetRec.JetRecConf import PseudoJetGetter
  ToolSvc += PseudoJetGetter("psjget")
  psjget = ToolSvc.psjget
  psjget.InputContainer = clname
  psjget.Label = "Cluster"
  psjget.OutputContainer = "PseudoJetClusters"
  psjget.OutputLevel = INFO
  psjget.SkipNegativeEnergy = True
Exemple #19
0
    def addJetFinder(self,
                     output,
                     alg,
                     radius,
                     gettersin,
                     modifiersin=None,
                     consumers=None,
                     ivtxin=None,
                     ghostArea=0.0,
                     ptmin=0.0,
                     ptminFilter=0.0,
                     rndseed=1,
                     isTrigger=False,
                     useTriggerStore=False,
                     variableRMinRadius=-1.0,
                     variableRMassScale=-1.0,
                     calibOpt="",
                     jetPseudojetCopier="",
                     constmods=[]):
        self.msg(2, "Adding finder")
        from JetRec.JetRecConf import JetRecTool
        if type(gettersin) == str:
            getters = self.gettersMap[gettersin]
        else:
            getters = gettersin

        # Accumulate all PseudoJetGetters such that we can schedule all
        # needed PseudoJetAlgorithms before jet building
        self.allGetters += [
            getter for getter in getters if not getter in self.allGetters
        ]
        # If jet finding by vertex is not specified, check for special input type names
        ivtx = ivtxin
        if ivtx == None:
            if gettersin == "ztrack":
                ivtx = -1  # Find tracs separatesly for each vertex
            elif gettersin == "pv0track":
                ivtx = 0  # Find tracks only for 1st vertex
        # Retrieve/build the jet finder.
        lofinder, hifinder = self.addJetFinderTool(output + "Finder",
                                                   alg,
                                                   radius,
                                                   ivtx,
                                                   ghostArea,
                                                   ptmin,
                                                   rndseed,
                                                   variableRMinRadius,
                                                   variableRMassScale,
                                                   constmods=constmods)
        jetrec = JetRecTool(output)
        jetrec.InputPseudoJets = [getter.OutputContainer for getter in getters]
        jetrec.JetFinder = hifinder
        jetrec.OutputContainer = output
        ptminSave = self.ptminFilter
        if ptminFilter > 0.0: self.ptminFilter = ptminFilter
        jetrec.JetModifiers = self.buildModifiers(modifiersin,
                                                  lofinder,
                                                  getters,
                                                  gettersin,
                                                  output,
                                                  calibOpt,
                                                  constmods=constmods)
        self.autoconfigureModifiers(jetrec.JetModifiers, output)
        if consumers != None:
            jetrec.JetConsumers = consumers
        self.ptminFilter = ptminSave
        jetrec.Trigger = isTrigger or useTriggerStore
        jetrec.Timer = jetFlags.timeJetRecTool()
        #jetrec.WarnIfDuplicate = warnIfDuplicate
        #jetrec.Overwrite = overwrite
        # JetRecTool.OutputLevel = VERBOSE
        self += jetrec
        if isTrigger:
            self.trigjetrecs += [jetrec]
        else:
            self.jetrecs += [jetrec]
        self.jetcons += [output]
        return jetrec
Exemple #20
0
    def other_postSystemRec(self, topSequence):
        """
        Please seperate out this function into multiple functions
        """
        from AthenaCommon.AppMgr import ToolSvc

        if self.isMC:

            from ParticleJetTools.ParticleJetToolsConf import CopyFlavorLabelTruthParticles
            from ParticleJetTools.ParticleJetToolsConf import ParticleJetDeltaRLabelTool

            ptypes = ["TausFinal", "BHadronsFinal", "CHadronsFinal"]
            for ptype in ptypes:
                AODFix_ctp = CopyFlavorLabelTruthParticles(
                    "AODFix_CopyTruthTag" + ptype)
                AODFix_ctp.ParticleType = ptype
                AODFix_ctp.OutputName = "AODFix_TruthLabel" + ptype
                ToolSvc += AODFix_ctp

            AODFix_JetDeltaRLabelTool = ParticleJetDeltaRLabelTool(
                "AODFix_jetdrlabeler",
                LabelName="HadronConeExclTruthLabelID",
                BLabelName="ConeExclBHadronsFinal",
                CLabelName="ConeExclCHadronsFinal",
                TauLabelName="ConeExclTausFinal",
                BParticleCollection="AODFix_TruthLabelBHadronsFinal",
                CParticleCollection="AODFix_TruthLabelCHadronsFinal",
                TauParticleCollection="AODFix_TruthLabelTausFinal",
                PartPtMin=5000.0,
                JetPtMin=0.0,
                DRMax=0.3,
                MatchMode="MinDR")
            ToolSvc += AODFix_JetDeltaRLabelTool

            AODFix_FatJetDeltaRLabelTool = ParticleJetDeltaRLabelTool(
                "AODFix_fatjetdrlabeler",
                LabelName="HadronConeExclTruthLabelID",
                BLabelName="ConeExclBHadronsFinal",
                CLabelName="ConeExclCHadronsFinal",
                TauLabelName="ConeExclTausFinal",
                BParticleCollection="AODFix_TruthLabelBHadronsFinal",
                CParticleCollection="AODFix_TruthLabelCHadronsFinal",
                TauParticleCollection="AODFix_TruthLabelTausFinal",
                PartPtMin=5000.0,
                JetPtMin=0.0,
                DRMax=1.0,
                MatchMode="MinDR")
            ToolSvc += AODFix_FatJetDeltaRLabelTool

            AODFix_TrackJetDeltaRLabelTool = ParticleJetDeltaRLabelTool(
                "AODFix_trackjetdrlabeler",
                LabelName="HadronConeExclTruthLabelID",
                BLabelName="ConeExclBHadronsFinal",
                CLabelName="ConeExclCHadronsFinal",
                TauLabelName="ConeExclTausFinal",
                BParticleCollection="AODFix_TruthLabelBHadronsFinal",
                CParticleCollection="AODFix_TruthLabelCHadronsFinal",
                TauParticleCollection="AODFix_TruthLabelTausFinal",
                PartPtMin=5000.0,
                JetPtMin=4500.0,
                DRMax=0.3,
                MatchMode="MinDR")

            ToolSvc += AODFix_TrackJetDeltaRLabelTool

            from JetRec.JetRecConf import JetRecTool
            JetRecTool_AntiKt4EMTopo = JetRecTool(
                "AODFix_AntiKt4EMTopoJets",
                InputContainer="AntiKt4EMTopoJets",
                OutputContainer="AntiKt4EMTopoJets",
                JetModifiers=[ToolSvc.AODFix_jetdrlabeler])
            ToolSvc += JetRecTool_AntiKt4EMTopo
            JetRecTool_AntiKt4LCTopo = JetRecTool(
                "AODFix_AntiKt4LCTopoJets",
                InputContainer="AntiKt4LCTopoJets",
                OutputContainer="AntiKt4LCTopoJets",
                JetModifiers=[ToolSvc.AODFix_jetdrlabeler])
            ToolSvc += JetRecTool_AntiKt4LCTopo
            JetRecTool_AntiKt10LCTopo = JetRecTool(
                "AODFix_AntiKt10LCTopoJets",
                InputContainer="AntiKt10LCTopoJets",
                OutputContainer="AntiKt10LCTopoJets",
                JetModifiers=[ToolSvc.AODFix_fatjetdrlabeler])
            ToolSvc += JetRecTool_AntiKt10LCTopo
            JetRecTool_AntiKt2PV0Track = JetRecTool(
                "AODFix_AntiKt2PV0TrackJets",
                InputContainer="AntiKt2PV0TrackJets",
                OutputContainer="AntiKt2PV0TrackJets",
                JetModifiers=[ToolSvc.AODFix_trackjetdrlabeler])
            ToolSvc += JetRecTool_AntiKt2PV0Track
            JetRecTool_AntiKt3PV0Track = JetRecTool(
                "AODFix_AntiKt3PV0TrackJets",
                InputContainer="AntiKt3PV0TrackJets",
                OutputContainer="AntiKt3PV0TrackJets",
                JetModifiers=[ToolSvc.AODFix_trackjetdrlabeler])
            ToolSvc += JetRecTool_AntiKt3PV0Track
            JetRecTool_AntiKt4PV0Track = JetRecTool(
                "AODFix_AntiKt4PV0TrackJets",
                InputContainer="AntiKt4PV0TrackJets",
                OutputContainer="AntiKt4PV0TrackJets",
                JetModifiers=[ToolSvc.AODFix_trackjetdrlabeler])
            ToolSvc += JetRecTool_AntiKt4PV0Track

            from JetRec.JetRecConf import JetAlgorithm
            topSequence += JetAlgorithm(
                "jetalgAODFix",
                Tools=[
                    ToolSvc.AODFix_CopyTruthTagCHadronsFinal,
                    ToolSvc.AODFix_CopyTruthTagBHadronsFinal,
                    ToolSvc.AODFix_CopyTruthTagTausFinal,
                    ToolSvc.AODFix_AntiKt2PV0TrackJets,
                    ToolSvc.AODFix_AntiKt3PV0TrackJets,
                    ToolSvc.AODFix_AntiKt4PV0TrackJets,
                    ToolSvc.AODFix_AntiKt4EMTopoJets,
                    ToolSvc.AODFix_AntiKt4LCTopoJets,
                    ToolSvc.AODFix_AntiKt10LCTopoJets
                ])

        JetCollectionList = [
            'AntiKt4EMTopoJets', 'AntiKt4LCTopoJets', 'AntiKt2TrackJets',
            'AntiKt3TrackJets', 'AntiKt4TrackJets'
        ]

        SA = 'AODFix_'
        from BTagging.BTaggingConfiguration import getConfiguration
        BTagConf = getConfiguration("AODFix")
        BTagConf.PrefixxAODBaseName(False)
        BTagConf.PrefixVertexFinderxAODBaseName(False)

        BTagConf.doNotCheckForTaggerObstacles()
        from BTagging.BTaggingConf import Analysis__StandAloneJetBTaggerAlg as StandAloneJetBTaggerAlg

        btag = "BTagging_"
        AuthorSubString = [btag + name[:-4] for name in JetCollectionList]
        for i, jet in enumerate(JetCollectionList):
            try:
                btagger = BTagConf.setupJetBTaggerTool(ToolSvc,
                                                       JetCollection=jet[:-4],
                                                       AddToToolSvc=True,
                                                       SetupScheme="Retag",
                                                       TaggerList=[
                                                           'IP3D', 'MV2c00',
                                                           'MV2c10', 'MV2c20',
                                                           'MV2c100', 'MV2m',
                                                           'MV2c10hp',
                                                           'MV2cl100', 'MVb'
                                                       ])
                jet = jet.replace("Track", "PV0Track")
                SAbtagger = StandAloneJetBTaggerAlg(
                    name=SA + AuthorSubString[i].lower(),
                    JetBTaggerTool=btagger,
                    JetCollectionName=jet,
                )

                topSequence += SAbtagger
            except AttributeError as error:
                print '#BTAG# --> ' + str(error)
                print '#BTAG# --> ' + jet
                print '#BTAG# --> ' + AuthorSubString[i]

        # MET AODFix
        from METReconstruction.METAssocConfig import AssocConfig, getAssociator
        from METReconstruction.METReconstructionConf import METBadTrackEventFilter
        from AthenaCommon.AlgSequence import AthSequencer
        METMapSequence = AthSequencer("MET_LCEM_SelectionSequence_AODFix")
        topSequence += METMapSequence

        from AthenaCommon import CfgMgr
        newtrkseltool = CfgMgr.InDet__InDetTrackSelectionTool(
            "IDTrkSel_METAssoc_AODFix",
            CutLevel="TightPrimary",
            maxZ0SinTheta=3,
            maxD0overSigmaD0=2)
        ToolSvc += newtrkseltool

        METMapSequence += METBadTrackEventFilter(
            "METBadTrackEventFilter_AODFix", TrackSelectorTool=newtrkseltool)

        LCtermlist = ['LCJet', 'Muon', 'Ele', 'Gamma', 'Tau', 'Soft']
        LCAssociators = [
            getAssociator(AssocConfig(config),
                          suffix='AntiKt4LCTopo',
                          doPFlow=False,
                          trkseltool=newtrkseltool) for config in LCtermlist
        ]
        LCAssocTool = CfgMgr.met__METAssociationTool(
            'MET_AssociationTool_AntiKt4LCTopo_AODFix',
            METAssociators=LCAssociators,
            METSuffix='AntiKt4LCTopo',
            AllowOverwrite=True,
            TCSignalState=1)  # LC clusters
        ToolSvc += LCAssocTool

        EMtermlist = ['EMJet', 'Muon', 'Ele', 'Gamma', 'Tau', 'Soft']
        EMAssociators = [
            getAssociator(AssocConfig(config),
                          suffix='AntiKt4EMTopo',
                          doPFlow=False,
                          trkseltool=newtrkseltool) for config in EMtermlist
        ]
        EMAssocTool = CfgMgr.met__METAssociationTool(
            'MET_AssociationTool_AntiKt4EMTopo_AODFix',
            METAssociators=EMAssociators,
            METSuffix='AntiKt4EMTopo',
            AllowOverwrite=True,
            TCSignalState=0)  # EM clusters
        ToolSvc += EMAssocTool

        METAssocAlg_LCEM = CfgMgr.met__METRecoAlg(
            name='METAssociation_LCEM_AODFix',
            RecoTools=[LCAssocTool, EMAssocTool])
        METMapSequence += METAssocAlg_LCEM

        from METUtilities.METMakerConfig import getMETMakerAlg
        METMakerAlg_LC = getMETMakerAlg('AntiKt4LCTopo', confsuffix="_AODFix")
        METMakerAlg_LC.AllowOverwrite = True
        METMakerAlg_EM = getMETMakerAlg('AntiKt4EMTopo', confsuffix="_AODFix")
        METMakerAlg_EM.AllowOverwrite = True
        METMapSequence += METMakerAlg_LC
        METMapSequence += METMakerAlg_EM

        #Only run pflow AOD fix if input file contains AntKt4EMPFlowJets - should be the case for all samples, except HI samples
        from RecExConfig.ObjKeyStore import cfgKeyStore
        if cfgKeyStore.isInInputFile("xAOD::JetContainer",
                                     "AntiKt4EMPFlowJets"):

            #Now we need to rerun the particle flow jet finding

            #This configuration should be identical to the AntiKt4EMPflowJets configured in:
            #http://acode-browser2.usatlas.bnl.gov/lxr-rel20/source/atlas/Reconstruction/Jet/JetRec/share/JetRec_jobOptions.py
            #with the addJetFinder function (in the svn tag for 20.7)
            particleFlowJetFinder_AntiKt4 = CfgMgr.JetFinder(
                "AntiKt4EMPFlowJetsFinder_AODFix")
            particleFlowJetFinder_AntiKt4.JetAlgorithm = "AntiKt"
            particleFlowJetFinder_AntiKt4.JetRadius = 0.4
            particleFlowJetFinder_AntiKt4.GhostArea = 0.01
            particleFlowJetFinder_AntiKt4.PtMin = 2000

            #Then we setup a jet builder to calculate the areas needed for the rho subtraction
            particleFlowJetBuilder_AntiKt4 = CfgMgr.JetFromPseudojet(
                "jblda_AODFix", Attributes=["ActiveArea", "ActiveArea4vec"])
            ToolSvc += particleFlowJetBuilder_AntiKt4
            particleFlowJetFinder_AntiKt4.JetBuilder = particleFlowJetBuilder_AntiKt4
            ToolSvc += particleFlowJetFinder_AntiKt4

            #Now we setup a JetRecTool which will use the above JetFinder
            particleFlowJetRecTool = CfgMgr.JetRecTool(
                "AntiKt4EMPFlowJets_AODFix")
            particleFlowJetRecTool.JetFinder = particleFlowJetFinder_AntiKt4
            ToolSvc += particleFlowJetRecTool

            jpjretriever = CfgMgr.JetPseudojetRetriever("jpjretriever")
            ToolSvc += jpjretriever

            pflowRetriever = CfgMgr.CP__RetrievePFOTool(
                "pflowretriever_AODFix")
            ToolSvc += pflowRetriever

            trk_trackselloose = CfgMgr.InDet__InDetTrackSelectionTool(
                "trk_trackselloose_AODFix", CutLevel="Loose")
            ToolSvc += trk_trackselloose

            trackselloose = CfgMgr.JetTrackSelectionTool(
                "trackselloose",
                InputContainer="InDetTrackParticles",
                OutputContainer="JetSelectedTracks",
                Selector=trk_trackselloose)
            ToolSvc += trackselloose

            tracksel = CfgMgr.JetTrackSelectionTool(
                "tracksel_AODFix",
                InputContainer="InDetTrackParticles",
                OutputContainer="JetSelectedTracks_AODFix",
                Selector=trk_trackselloose)
            ToolSvc += tracksel

            tighttva = CfgMgr.CP__TightTrackVertexAssociationTool(
                "jetTighTVAtool_AODFix", dzSinTheta_cut=3, doPV=True)
            ToolSvc += tighttva

            tvassoc = CfgMgr.TrackVertexAssociationTool(
                "tvassoc_AODFix",
                TrackParticleContainer="InDetTrackParticles",
                TrackVertexAssociation="JetTrackVtxAssoc_AODFix",
                VertexContainer="PrimaryVertices",
                TrackVertexAssoTool=tighttva,
            )
            ToolSvc += tvassoc

            # Ghost tracks.
            ghostScaleFactor = 1e-40
            gtrackget = CfgMgr.TrackPseudoJetGetter(
                "gtrackget_AODFix",
                InputContainer=tracksel.OutputContainer,
                Label="GhostTrack",
                OutputContainer="PseudoJetGhostTracks_AODFix",
                TrackVertexAssociation=tvassoc.TrackVertexAssociation,
                SkipNegativeEnergy=True,
                GhostScale=ghostScaleFactor)
            ToolSvc += gtrackget

            # Muon segments
            gmusegget = CfgMgr.MuonSegmentPseudoJetGetter(
                "gmusegget_AODFix",
                InputContainer="MuonSegments",
                Label="GhostMuonSegment",
                OutputContainer="PseudoJetGhostMuonSegment_AODFix",
                Pt=1.e-20)
            ToolSvc += gmusegget

            # AntiKt2 track jets.
            gakt2trackget = CfgMgr.PseudoJetGetter(
                "gakt2trackget_AODFix",  # give a unique name
                InputContainer="AntiKt2PV0TrackJets",  # SG key
                Label=
                "GhostAntiKt2TrackJet",  # this is the name you'll use to retrieve associated ghosts
                OutputContainer="PseudoJetGhostAntiKt2TrackJet_AODFix",
                SkipNegativeEnergy=True,
                GhostScale=
                ghostScaleFactor,  # This makes the PseudoJet Ghosts, and thus the reco flow will treat them as so.
            )
            ToolSvc += gakt2trackget

            # AntiKt3 track jets.
            gakt3trackget = CfgMgr.PseudoJetGetter(
                "gakt3trackget_AODFix",  # give a unique name
                InputContainer="AntiKt3PV0TrackJets",  # SG key
                Label=
                "GhostAntiKt3TrackJet",  # this is the name you'll use to retrieve associated ghosts
                OutputContainer="PseudoJetGhostAntiKt3TrackJet_AODFix",
                SkipNegativeEnergy=True,
                GhostScale=
                ghostScaleFactor,  # This makes the PseudoJet Ghosts, and thus the reco flow will treat them as so.
            )
            ToolSvc += gakt3trackget

            # AntiKt4 track jets.
            gakt4trackget = CfgMgr.PseudoJetGetter(
                "gakt4trackget_AODFix",  # give a unique name
                InputContainer="AntiKt4PV0TrackJets",  # SG key
                Label=
                "GhostAntiKt4TrackJet",  # this is the name you'll use to retrieve associated ghosts
                OutputContainer="PseudoJetGhostAntiKt4TrackJet_AODFix",
                SkipNegativeEnergy=True,
                GhostScale=
                ghostScaleFactor,  # This makes the PseudoJet Ghosts, and thus the reco flow will treat them as so.
            )
            ToolSvc += gakt4trackget

            # Truth.
            mctc = None
            truthpartcopy = None
            gtruthget = None
            gtruthgetters = []
            rtools = []
            rtools += [tracksel, tvassoc]
            if self.isMC:
                mctc = CfgMgr.MCTruthClassifier(
                    name="JetMCTruthClassifier_AODFix",
                    ParticleCaloExtensionTool="")
                ToolSvc += mctc

                truthpartcopy = CfgMgr.CopyTruthJetParticles(
                    "truthpartcopy_AODFix",
                    OutputName="JetInputTruthParticles_AODFix",
                    MCTruthClassifier=mctc)
                ToolSvc += truthpartcopy

                gtruthget = CfgMgr.PseudoJetGetter(
                    "gtruthget_AODFix",
                    Label="GhostTruth",
                    InputContainer=truthpartcopy.OutputName,
                    OutputContainer="PseudoJetGhostTruth_AODFix",
                    GhostScale=ghostScaleFactor,
                    SkipNegativeEnergy=True,
                )
                ToolSvc += gtruthget

                # Truth flavor tags.
                truthFlavourTags = [
                    "BHadronsInitial",
                    "BHadronsFinal",
                    "BQuarksFinal",
                    "CHadronsInitial",
                    "CHadronsFinal",
                    "CQuarksFinal",
                    "TausFinal",
                    "WBosons",
                    "ZBosons",
                    "HBosons",
                    "TQuarksFinal",
                    "Partons",
                ]
                for ptype in truthFlavourTags:
                    gtruthgetters.append(
                        CfgMgr.PseudoJetGetter(
                            "gtruthget_" + ptype + "_AODFix",
                            InputContainer="TruthLabel" + ptype + "_AODFix",
                            Label="Ghost" + ptype,
                            OutputContainer="PseudoJetGhost" + ptype +
                            "_AODFix",
                            SkipNegativeEnergy=True,
                            GhostScale=ghostScaleFactor,
                        ))
                    ToolSvc += gtruthgetters[-1]

                    toolname = "CopyTruthTag" + ptype + "_AODFix"
                    print "Scheduling " + toolname
                    ptmin = 5000
                    if ptype == "Partons":
                        ctp = CfgMgr.CopyTruthPartons(toolname)
                    elif ptype in [
                            "WBosons", "ZBosons", "HBosons", "TQuarksFinal"
                    ]:
                        ctp = CfgMgr.CopyBosonTopLabelTruthParticles(toolname)
                        ctp.ParticleType = ptype
                        ptmin = 100000
                    else:
                        ctp = CfgMgr.CopyFlavorLabelTruthParticles(toolname)
                        ctp.ParticleType = ptype
                    ctp.OutputName = "TruthLabel" + ptype + "_AODFix"
                    ctp.PtMin = ptmin
                    ToolSvc += ctp
                    rtools.append(ctp)

                # build truth jet input :
                rtools += [truthpartcopy]

            jetrun = CfgMgr.JetToolRunner(
                "jetrun_AODFix",
                Tools=rtools,
            )
            ToolSvc += jetrun

            #Setup a pseudojetgetter to deal with input objects
            empflowget = CfgMgr.PFlowPseudoJetGetter(
                "empflowget_AODFix",
                Label="EMPFlow",
                OutputContainer="PseudoJetEMPFlow_AODFix",
                RetrievePFOTool=pflowRetriever,
                InputIsEM=True,
                CalibratePFO=False,
                SkipNegativeEnergy=True,
                UseVertices=True)
            ToolSvc += empflowget

            empfgetters = [
                empflowget, gtrackget, gmusegget, gakt2trackget, gakt3trackget,
                gakt4trackget
            ]
            if self.isMC:
                empfgetters += [gtruthget] + gtruthgetters

            particleFlowJetRecTool.PseudoJetGetters = empfgetters
            particleFlowJetRecTool.Overwrite = True
            particleFlowJetRecTool.OutputContainer = "AntiKt4EMPFlowJets"

            #setup calibration tools - only want to do area subtraction (as is done in Tier0)
            jetdefn = particleFlowJetFinder_AntiKt4.JetAlgorithm + str(
                int(10 * particleFlowJetFinder_AntiKt4.JetRadius +
                    0.1)) + empflowget.Label
            pflowJetCalibToolName_AODFix = "calib_" + jetdefn + "_pflow_A_AODFix"
            ToolSvc += CfgMgr.JetCalibrationTool(
                "pflowJetCalibTool_AODFix",
                JetCollection=jetdefn,
                ConfigFile="PFlowJES_September2014.config",
                CalibSequence="JetArea",
                RhoKey="Kt4EMPFlowEventShape")
            particleFlowJetRecTool.JetModifiers = [
                ToolSvc.pflowJetCalibTool_AODFix
            ]

            #now we setup the other modifiers we need
            ToolSvc += CfgMgr.JetFilterTool("jetFilter_AODFix", PtMin=5000)
            particleFlowJetRecTool.JetModifiers += [ToolSvc.jetFilter_AODFix]

            #common_ungroomed_modifiers start here
            ToolSvc += CfgMgr.JetWidthTool("width_AODFix")
            particleFlowJetRecTool.JetModifiers += [ToolSvc.width_AODFix]

            ToolSvc += CfgMgr.JetIsolationTool(
                "jetisol_AODFix",
                IsolationCalculations=["IsoDelta:2:SumPt", "IsoDelta:3:SumPt"])
            particleFlowJetRecTool.JetModifiers += [ToolSvc.jetisol_AODFix]

            ToolSvc += CfgMgr.KtDeltaRTool("ktdr_AODFix", JetRadius=0.4)
            particleFlowJetRecTool.JetModifiers += [ToolSvc.ktdr_AODFix]

            ToolSvc += CfgMgr.NSubjettinessTool("nsubjettiness_AODFix",
                                                Alpha=1.0)
            particleFlowJetRecTool.JetModifiers += [
                ToolSvc.nsubjettiness_AODFix
            ]

            ToolSvc += CfgMgr.KTSplittingScaleTool("ktsplitter_AODFix")
            particleFlowJetRecTool.JetModifiers += [ToolSvc.ktsplitter_AODFix]

            ToolSvc += CfgMgr.AngularityTool("angularity_AODFix")
            particleFlowJetRecTool.JetModifiers += [ToolSvc.angularity_AODFix]

            ToolSvc += CfgMgr.DipolarityTool("dipolarity_AODFix",
                                             SubJetRadius=0.3)
            particleFlowJetRecTool.JetModifiers += [ToolSvc.dipolarity_AODFix]

            ToolSvc += CfgMgr.PlanarFlowTool("planarflow_AODFix")
            particleFlowJetRecTool.JetModifiers += [ToolSvc.planarflow_AODFix]

            ToolSvc += CfgMgr.KtMassDropTool("ktmassdrop_AODFix")
            particleFlowJetRecTool.JetModifiers += [ToolSvc.ktmassdrop_AODFix]

            ToolSvc += CfgMgr.EnergyCorrelatorTool("encorr_AODFix", Beta=1.0)
            particleFlowJetRecTool.JetModifiers += [ToolSvc.encorr_AODFix]

            ToolSvc += CfgMgr.CenterOfMassShapesTool("comshapes_AODFix")
            particleFlowJetRecTool.JetModifiers += [ToolSvc.comshapes_AODFix]

            #common_ungroomed_modifiers that are for MC only

            ## (JM) Now introduced an isMC flag, so can remove this suff.
            # #First we check if the file is MC or data using the metadata (not allowed to use reco flags om AODFix)
            # from AthenaCommon.AthenaCommonFlags import athenaCommonFlags
            # theInputFile_AODFix = athenaCommonFlags.PoolAODInput.get_Value()[0]
            # import PyUtils.AthFile as af
            # haveParticleJetTools_AODFix = False
            # f = af.fopen(theInputFile_AODFix)
            # if 'evt_type' in f.infos.keys():
            #     import re
            #     if re.match(str(f.infos['evt_type'][0]), 'IS_SIMULATION') :
            #         try:
            #             haveParticleJetTools_AODFix = True
            #         except:
            #             haveParticleJetTools_AODFix = False

            #         if haveParticleJetTools_AODFix:
            #             ToolSvc += CfgMgr.Analysis__JetPartonTruthLabel("partontruthlabel_AODFix")
            #             particleFlowJetRecTool.JetModifiers += [ToolSvc.partontruthlabel_AODFix]

            #             ToolSvc += CfgMgr.Analysis__JetQuarkLabel("jetquarklabel_AODFix",McEventCollection = "TruthEvents")
            #             ToolSvc += CfgMgr.Analysis__JetConeLabeling("truthpartondr_AODFix",JetTruthMatchTool = ToolSvc.jetquarklabel_AODFix)
            #             particleFlowJetRecTool.JetModifiers += [ToolSvc.truthpartondr_AODFix]

            #This is the replacement
            if self.isMC:
                ToolSvc += CfgMgr.Analysis__JetPartonTruthLabel(
                    "partontruthlabel_AODFix")
                particleFlowJetRecTool.JetModifiers += [
                    ToolSvc.partontruthlabel_AODFix
                ]

                ToolSvc += CfgMgr.Analysis__JetQuarkLabel(
                    "jetquarklabel_AODFix", McEventCollection="TruthEvents")
                ToolSvc += CfgMgr.Analysis__JetConeLabeling(
                    "truthpartondr_AODFix",
                    JetTruthMatchTool=ToolSvc.jetquarklabel_AODFix)
                particleFlowJetRecTool.JetModifiers += [
                    ToolSvc.truthpartondr_AODFix
                ]
            ## end of JM modificatoin

            #common_ungroomed_modifiers end here

            # Modifiers for topo (and pflow) jets.
            jetens = CfgMgr.JetCaloEnergies("jetens_AODFix")
            ToolSvc += jetens

            larhvcorr = CfgMgr.JetLArHVTool("larhvcorr_AODFix")
            ToolSvc += larhvcorr

            caloqual_cluster = CfgMgr.JetCaloQualityTool(
                "caloqual_cluster_AODFix",
                TimingCuts=[5, 10],
                Calculations=[
                    "LArQuality", "N90Constituents", "FracSamplingMax",
                    "NegativeE", "Timing", "HECQuality", "Centroid",
                    "AverageLArQF", "BchCorrCell"
                ],
            )
            ToolSvc += caloqual_cluster

            # Jet vertex fraction with selection.
            jvf = CfgMgr.JetVertexFractionTool(
                "jvf_AODFix",
                VertexContainer="PrimaryVertices",
                AssociatedTracks="GhostTrack",
                TrackVertexAssociation=tvassoc.TrackVertexAssociation,
                TrackSelector=trackselloose,
                JVFName="JVF")
            ToolSvc += jvf

            # Jet vertex tagger.
            jvt = CfgMgr.JetVertexTaggerTool(
                "jvt_AODFix",
                VertexContainer="PrimaryVertices",
                TrackParticleContainer="InDetTrackParticles",
                AssociatedTracks="GhostTrack",
                TrackVertexAssociation=tvassoc.TrackVertexAssociation,
                TrackSelector=trackselloose,
                JVTName="Jvt",
                K_JVFCorrScale=0.01,
                Z0Cut=3.0,
                PUTrkPtCut=30000.0)
            ToolSvc += jvt

            # Jet track info.
            trkmoms = CfgMgr.JetTrackMomentsTool(
                "trkmoms_AODFix",
                VertexContainer="PrimaryVertices",
                AssociatedTracks="GhostTrack",
                TrackVertexAssociation=tvassoc.TrackVertexAssociation,
                TrackMinPtCuts=[500, 1000],
                TrackSelector=trackselloose)
            ToolSvc += trkmoms

            charge = CfgMgr.JetChargeTool("charge_AODFix", K=1.0)
            ToolSvc += charge

            particleFlowJetRecTool.JetModifiers += [
                jetens, larhvcorr, caloqual_cluster, jvf, jvt, trkmoms, charge
            ]

            if self.isMC:
                truthassoc = CfgMgr.JetPtAssociationTool(
                    "truthassoc_AntiKt4_AODFix",
                    InputContainer="AntiKt4TruthJets",
                    AssociationName="GhostTruth")
                ToolSvc += truthassoc

                jetdrlabeler = CfgMgr.ParticleJetDeltaRLabelTool(
                    "jetdrlabeler_AODFix",
                    LabelName="HadronConeExclTruthLabelID",
                    BLabelName="ConeExclBHadronsFinal",
                    CLabelName="ConeExclCHadronsFinal",
                    TauLabelName="ConeExclTausFinal",
                    BParticleCollection="TruthLabelBHadronsFinal_AODFix",
                    CParticleCollection="TruthLabelCHadronsFinal_AODFix",
                    TauParticleCollection="TruthLabelTausFinal_AODFix",
                    PartPtMin=5000.0,
                    JetPtMin=4500.0,
                    DRMax=0.3,
                    MatchMode="MinDR")
                ToolSvc += jetdrlabeler

                particleFlowJetRecTool.JetModifiers += [
                    truthassoc, jetdrlabeler
                ]

            JetType = 'PFlowJet'
            PFtermlist = ['PFlowJet', 'Muon', 'Ele', 'Gamma', 'Tau', 'Soft']
            newpfotool = CfgMgr.CP__RetrievePFOTool('MET_PFOTool_AODFix')
            ToolSvc += newpfotool

            PFAssociators = [
                getAssociator(AssocConfig(config),
                              suffix='AntiKt4EMPFlow',
                              doPFlow=True,
                              trkseltool=newtrkseltool,
                              pfotool=newpfotool) for config in PFtermlist
            ]
            PFAssocTool = CfgMgr.met__METAssociationTool(
                'MET_AssociationTool_AntiKt4EMPFlow_AODFix',
                METAssociators=PFAssociators,
                METSuffix='AntiKt4EMPFlow',
                AllowOverwrite=True)
            ToolSvc += PFAssocTool

            METAssocAlg_PFlow = CfgMgr.met__METRecoAlg(
                name='METAssociation_PFlow_AODFix', RecoTools=[PFAssocTool])
            METMakerAlg_PF = getMETMakerAlg('AntiKt4EMPFlow',
                                            confsuffix="_AODFix")
            METMakerAlg_PF.AllowOverwrite = True

            #Set up our own sequence
            ParticleFlowJetSequence = AthSequencer(
                "ParticleFlowSelectionSequence")
            topSequence += ParticleFlowJetSequence

            #Add an event filter to our sequence
            ParticleFlowJetSequence += CfgMgr.ParticleFlowEventFilter_r207(
                "ParticleFlowEventFilter_r207")
            #Add the particle flow jet finding to our sequence
            ParticleFlowJetSequence += CfgMgr.JetAlgorithm(
                "pflowJetAlg_AODFix",
                Tools=[jetrun, ToolSvc.AntiKt4EMPFlowJets_AODFix])
            #Add MET map builder to our sequence
            ParticleFlowJetSequence += METAssocAlg_PFlow
            #Build the reference MET container
            ParticleFlowJetSequence += METMakerAlg_PF
Exemple #21
0
def addExKtCoM(sequence,
               ToolSvc,
               JetCollectionExCoM,
               nSubjets,
               doTrackSubJet,
               doGhostAssoc=False,
               ExGhostLabels=[
                   "GhostBHadronsFinal", "GhostCHadronsFinal", "GhostTrack"
               ],
               min_subjet_pt_mev=0,
               subjetAlgName="Kt"):
    if (subjetAlgName != "Kt" and subjetAlgName != "CoM"):
        print("WARNING:  Subjet type must be Kt or CoM.  Using Kt as default!")
        subjetAlgName = "Kt"
    from JetRec.JetRecStandard import jtm
    ExCoMJetCollection__SubJet = []

    (ExCoMbbTagToolInstance, SubjetContainerName) = buildExclusiveSubjets(
        ToolSvc, JetCollectionExCoM, subjetAlgName, nSubjets, doGhostAssoc,
        doTrackSubJet, ExGhostLabels, min_subjet_pt_mev)

    ExCoMJetCollection__SubJet += [SubjetContainerName]

    excomELresetName = "ELreset_subjet_%s" % (SubjetContainerName.replace(
        "Jets", ""))
    excomELresetNameLJet = "ELreset_Large_%sjet_%s" % (
        SubjetContainerName.replace(
            "Jets", ""), JetCollectionExCoM.replace("Jets", ""))
    excomAlgName = "jfind_%s" % (SubjetContainerName)
    excomJetRecToolName = "%s" % (SubjetContainerName)
    excomBTagName = "BTagging_%s" % (SubjetContainerName.replace("Jets", ""))

    if excomAlgName in DFJetAlgs:
        print(" Algorithm Ex%s " % subjetAlgName, excomAlgName,
              "already built before sequence ", sequence)

        if hasattr(sequence, excomAlgName):
            print(" sequence Ex%s " % subjetAlgName, sequence,
                  "already has an instance of algorithm", excomAlgName)
        else:
            print(" Add algorithm Ex%s " % subjetAlgName, excomAlgName,
                  "to sequence", sequence)
            sequence += DFJetAlgs[excomAlgName]
            sequence += CfgMgr.xAODMaker__ElementLinkResetAlg(
                excomELresetName, SGKeys=[SubjetContainerName + "Aux."])
            sequence += DFJetAlgs[excomAlgName + "_btag"]
            sequence += CfgMgr.xAODMaker__ElementLinkResetAlg(
                excomELresetNameLJet, SGKeys=[JetCollectionExCoM + "Aux."])
    else:
        print(" Algorithm Ex%s " % subjetAlgName, excomAlgName,
              " to be built sequence ", sequence)
        if hasattr(jtm, excomJetRecToolName):
            print(" Ex%sJetRecTool " % subjetAlgName, excomJetRecToolName,
                  " already built sequence ", sequence)
            jetrec = jtm[excomJetRecToolName]
        else:
            print(" Ex%s tool " % subjetAlgName, excomJetRecToolName,
                  " to be built sequence ", sequence)
            from JetRec.JetRecConf import JetRecTool
            jetrec = JetRecTool(
                name=excomJetRecToolName,
                OutputContainer=JetCollectionExCoM,
                InputContainer=JetCollectionExCoM,
                JetModifiers=[ExCoMbbTagToolInstance],
            )
            jtm.add(jetrec)
            ToolSvc += jetrec

        excomJetRecBTagToolName = str("%s_sub" % excomJetRecToolName)
        if hasattr(jtm, excomJetRecBTagToolName):
            print(" Ex%sJetRecBTagTool " % subjetAlgName,
                  excomJetRecBTagToolName, " already built sequence ",
                  sequence)
            jetrec_btagging = jtm[excomJetRecBTagToolName]
        else:
            print(" Ex%sJetRecBTagTool " % subjetAlgName,
                  excomJetRecBTagToolName, " to be built sequence ", sequence)

            #make the btagging tool for excom jets
            from BTagging.BTaggingFlags import BTaggingFlags
            btag_excom = ConfInst.setupJetBTaggerTool(
                ToolSvc,
                JetCollection=excomJetRecToolName.replace("Jets", ""),
                AddToToolSvc=True,
                Verbose=True,
                options={
                    "name": excomBTagName.lower(),
                    "BTagName": excomBTagName,
                    "BTagJFVtxName": "JFVtx",
                    "BTagSVName": "SecVtx",
                },
                SetupScheme="",
                TaggerList=BTaggingFlags.StandardTaggers,
                TrackAssociatorName="GhostTrack"
                if doGhostAssoc else "MatchedTracks")
            # running association + b-tagging on subjets now
            from BTagging.BTaggingConfiguration import comTrackAssoc, comMuonAssoc, defaultTrackAssoc, defaultMuonAssoc
            mods = [defaultTrackAssoc, defaultMuonAssoc, btag_excom]
            if (subjetAlgName == "CoM"):
                mods = [comTrackAssoc, comMuonAssoc, btag_excom]
            if isMC:
                mods.append(jtm.jetdrlabeler)

            jetrec_btagging = JetRecTool(name=excomJetRecBTagToolName,
                                         InputContainer=SubjetContainerName,
                                         OutputContainer=SubjetContainerName,
                                         JetModifiers=mods)
            jtm.add(jetrec_btagging)
            ToolSvc += jetrec_btagging

        jetalg_excom = JetAlgorithm(
            name=excomAlgName,
            Tools=[jetrec],
        )
        sequence += jetalg_excom
        DFJetAlgs[excomAlgName] = jetalg_excom

        # Reset EL for ExCoM subjets after all of them are built
        # Otherwise crashing for CoM during TrackToJetAssociation due to failure of finding the large-R parent jet.
        sequence += CfgMgr.xAODMaker__ElementLinkResetAlg(
            excomELresetName, SGKeys=[SubjetContainerName + "Aux."])

        jetalg_excom_btag = JetAlgorithm(
            name=excomAlgName + "_btag",
            Tools=[jetrec_btagging],
        )
        sequence += jetalg_excom_btag
        DFJetAlgs[excomAlgName + "_btag"] = jetalg_excom_btag
        sequence += CfgMgr.xAODMaker__ElementLinkResetAlg(
            excomELresetNameLJet, SGKeys=[JetCollectionExCoM + "Aux."])

    return ExCoMJetCollection__SubJet
Exemple #22
0
    def addJetFinder(self,
                     output,
                     alg,
                     radius,
                     gettersin,
                     modifiersin=None,
                     consumers=None,
                     ivtxin=None,
                     ghostArea=0.0,
                     ptmin=0.0,
                     ptminFilter=0.0,
                     rndseed=1,
                     isTrigger=False,
                     useTriggerStore=False,
                     variableRMinRadius=-1.0,
                     variableRMassScale=-1.0,
                     calibOpt="",
                     jetPseudojetCopier="",
                     warnIfDuplicate=True,
                     overwrite=False):
        self.msg(2, "Adding finder")
        from JetRec.JetRecConf import JetRecTool
        if type(gettersin) == str:
            getters = self.gettersMap[gettersin]
        else:
            getters = gettersin
        # If jet finding by vertex is not specified, check for special input type names
        ivtx = ivtxin
        if ivtx == None:
            if gettersin == "ztrack":
                ivtx = -1  # Find tracs separatesly for each vertex
            elif gettersin == "pv0track":
                ivtx = 0  # Find tracks only for 1st vertex
        # Retrieve/build the jet finder.
        lofinder, hifinder = self.addJetFinderTool(output + "Finder", alg,
                                                   radius, ivtx, ghostArea,
                                                   ptmin, rndseed,
                                                   variableRMinRadius,
                                                   variableRMassScale)
        jetrec = JetRecTool(output)
        jetrec.PseudoJetGetters = getters
        jetrec.JetFinder = hifinder
        jetrec.OutputContainer = output
        ptminSave = self.ptminFilter
        if ptminFilter > 0.0: self.ptminFilter = ptminFilter
        jetrec.JetModifiers = self.buildModifiers(modifiersin, lofinder,
                                                  getters, gettersin, output,
                                                  calibOpt)
        if consumers != None:
            jetrec.JetConsumers = consumers
        self.ptminFilter = ptminSave
        jetrec.Trigger = isTrigger or useTriggerStore
        jetrec.Timer = jetFlags.timeJetRecTool()
        jetrec.WarnIfDuplicate = warnIfDuplicate
        jetrec.Overwrite = overwrite

        self += jetrec
        if isTrigger:
            self.trigjetrecs += [jetrec]
        else:
            self.jetrecs += [jetrec]
        self.jetcons += [output]
        return jetrec
Exemple #23
0
from JetRec.JetRecConf import PseudoJetGetter
# from JetRec.JetRecConf import JetToolRunner
from JetRec.JetRecConf import JetRecTool
from JetRec.JetRecConf import JetFinder
from JetRec.JetRecConf import JetFromPseudojet

from AthenaCommon.AppMgr import ToolSvc

#   ParticleJetMaps
# schedule one standard jetfinder on which all others depend
# the weirdo "ParticleJetMap thingy should then be existing for all. Still a race condition problem, but much less I hope...
#  Note: add dependencies in the CaloHiveDeps.py

# anti-kt 4 standardjets
jalg4 = JetAlgorithm("jetalg4")
j4 = JetRecTool("jetrectool4", OutputContainer="AntiKt4EMTopoJets")
g4 = PseudoJetGetter("emget4",
                     InputContainer="CaloTopoCluster",
                     Label="EMTopo",
                     OutputContainer="PseudoJetEMTopo4",
                     SkipNegativeEnergy=True,
                     GhostScale=0.0)
f4 = JetFinder("fastjet-4")
f4.JetAlgorithm = "AntiKt"
f4.JetRadius = 0.4
f4.GhostArea = 0.0
f4.PtMin = 10.0
o4 = JetFromPseudojet("out4")

ToolSvc += JetRecTool("jetrectool4")
ToolSvc += PseudoJetGetter("emget4")
Exemple #24
0
        # psjget.OutputLevel = INFO
        psjget.SkipNegativeEnergy = True
        ToolSvc += psjget

        # Find jets.
        from JetRec.JetRecConf import JetFinder
        jfind = JetFinder("JetFinder_" + name)
        jfind.JetAlgorithm = "AntiKt"
        jfind.JetRadius = 1.0
        jfind.GhostArea = 0.01
        jfind.PtMin = 200000.0
        #  jfind.OutputLevel = VERBOSE
        ToolSvc += jfind

        # JetRec tool for finding.
        jetrec = JetRecTool("JetRecTool_" + name)
        jetrec.OutputContainer = "AntiKt10" + name + "Jets"
        # jetrec.OutputLevel = INFO
        jetrec.PseudoJetGetters += [psjget]
        jetrec.JetFinder = jfind
        #jetrec.JetModifiers += [nsubjettiness]
        #jetrec.JetModifiers += [nsubjettinessratios]
        # jetrec.JetModifiers += [ktsplittingscale]
        # jetrec.JetModifiers += [dipolarity]
        # jetrec.JetModifiers += [angularity]
        # jetrec.JetModifiers += [ktdr]
        # jetrec.JetModifiers += [ktmassdrop]
        # jetrec.JetModifiers += [planarflow]
        # jetrec.JetModifiers += [centerofmassshapes]
        #jetrec.JetModifiers += [energycorrelator]
        #jetrec.JetModifiers += [energycorrelatorratios]
Exemple #25
0
 def addJetFinder(self, output, alg, radius, gettersin, modifiersin =None, ivtxin =None,
                  ghostArea =0.0, ptmin =0.0, ptminFilter =0.0, rndseed =1,
                  isTrigger =False, useTriggerStore =False,
                  variableRMinRadius =-1.0, variableRMassScale =-1.0,
                  calibOpt =""):
   from JetRec.JetRecConf import JetByVertexFinder
   self.msg(2, "Adding finder")
   if ghostArea == 0.0:
     self.m_jetBuilder = self.jetBuilderWithoutArea
   else:
     self.m_jetBuilder = self.jetBuilderWithArea
   if self.m_jetBuilder == None:
     self.msg(0, "Jet builder must be specified")
     raise Error
   from JetRec.JetRecConf import JetFinder
   from JetRec.JetRecConf import JetSplitter
   from JetRec.JetRecConf import JetRecTool
   if type(gettersin) == str:
     getters = self.gettersMap[gettersin]
   else:
     getters = gettersin
   areaSuffix= "Area" if ghostArea>0.0 else ""
   finder = JetFinder(output + areaSuffix+ "Finder")
   finder.JetAlgorithm = alg
   finder.JetRadius = radius
   finder.VariableRMinRadius = variableRMinRadius
   finder.VariableRMassScale = variableRMassScale
   finder.RandomOption = rndseed
   finder.GhostArea = ghostArea
   if ptmin > 0.0:
     finder.PtMin = ptmin
   else:
     finder.PtMin = self.ptminFinder
   finder.JetBuilder = self.m_jetBuilder
   self += finder
   jrfinder = finder;
   # If jet finding by vertex is not specified, check for special input type names
   ivtx = ivtxin
   if ivtx == None:
     if gettersin == "ztrack": ivtx = -1        # Find tracs separatesly for each vertex
     elif gettersin == "pv0track": ivtx = 0     # Find tracks only for 1st vertex
   # If jet finding by vertex is requested, change the finder
   if type(ivtx) is int:
     vfinder = JetByVertexFinder(
       output + "VertexFinder",
       JetFinder = finder,
       Vertex = ivtx
     )
     self += vfinder
     jrfinder = vfinder;
   jetrec = JetRecTool(output)
   jetrec.PseudoJetGetters = getters
   jetrec.JetFinder = jrfinder
   jetrec.OutputContainer = output
   ptminSave = self.ptminFilter
   if ptminFilter > 0.0: self.ptminFilter = ptminFilter
   jetrec.JetModifiers = self.buildModifiers(modifiersin, finder, getters, gettersin, output, calibOpt)
   self.ptminFilter = ptminSave
   jetrec.Trigger = isTrigger or useTriggerStore
   jetrec.Timer = self.timer
   self += jetrec
   self.finders += [finder]
   if isTrigger:
     self.trigjetrecs += [jetrec]
   else:
     self.jetrecs += [jetrec]
   self.jetcons += [output]
   return jetrec