Esempio n. 1
0
def getCaloQualityTool(computeFromCluster = False,doCellBasedVars = False,addJetQualityMoments=False):

    from JetMomentTools.JetMomentToolsConf import JetCaloQualityTool
    caloQualityT = JetCaloQualityTool("JetCaloQualityTool")
    caloQualityT.doCellBasedVariables = doCellBasedVars
    caloQualityT.cutOnLAr = 4000
    caloQualityT.doLArQuality = True
    caloQualityT.doTiming = True
    caloQualityT.doHECQuality = True
    caloQualityT.doNegativeE = True
    caloQualityT.doTileQuality = False
    caloQualityT.doAverageLArQF = True        
    #caloQualityT.timingMomentCells     = [5,10]  # produces jet moments: ootFracCells5, ootFracCells10 (names built on the fly from caloQualityT.timingMomentCellsName)
    caloQualityT.timingMomentClusters  = [5,10]  #
    caloQualityT.timingMomentCells = []
    caloQualityT.doJetCentroid = True
    
    caloQualityT.ComputeVariableFromCluster = computeFromCluster

    if addJetQualityMoments :
        caloQualityT.doConstituentBasedVariables = True
        caloQualityT.doSamplingBasedVariables = True
        caloQualityT.cutOnTile = 254
        caloQualityT.doTileQuality = True


    return caloQualityT
Esempio n. 2
0
def declareDefaultTools():

  from JetRecConfig.JetRecFlags import jetFlags
  from JetRecConfig.JetRecStandardToolManager import jtm
  try:
    from JetMomentTools.JetMomentToolsConf import JetCaloCellQualityTool
    jtm.haveJetCaloCellQualityTool = True
  except ImportError:
    jtm.haveJetCaloCellQualityTool = False

  try:
    from JetMomentTools.JetMomentToolsConf import JetJetBadChanCorrTool
    jtm.haveJetBadChanCorrTool = True
  except ImportError:
    jtm.haveJetBadChanCorrTool = False

  from JetRecTools.JetRecToolsConf import TrackVertexAssociationTool
  from JetRec.JetRecConf import PseudoJetGetter
  from JetRecTools.JetRecToolsConf import TrackPseudoJetGetter
  from InDetTrackSelectionTool.InDetTrackSelectionToolConf import InDet__InDetTrackSelectionTool
  from JetRecTools.JetRecToolsConf import JetTrackSelectionTool
  from JetRecTools.JetRecToolsConf import SimpleJetTrackSelectionTool

  #--------------------------------------------------------------
  # Non-substructure moment builders.
  #--------------------------------------------------------------

  # Quality from clusters.
  jtm += JetCaloQualityTool(
    "caloqual_cluster",
    TimingCuts = [5, 10],
    Calculations = ["LArQuality", "N90Constituents", "FracSamplingMax",  "NegativeE", "Timing", "HECQuality", "Centroid", "AverageLArQF", "BchCorrCell"],
  )

  # Quality from cells.
  if jtm.haveJetCaloCellQualityTool:
    jtm += JetCaloCellQualityTool(
      "caloqual_cell",
      LArQualityCut = 4000,
      TileQualityCut = 254,
      TimingCuts = [5, 10],
      Calculations = ["LArQuality", "N90Cells", "FracSamplingMax",  "NegativeE", "Timing", "HECQuality", "Centroid", "AverageLArQF"]
    )

  # Jet width.
  jtm += JetWidthTool("width", WeightPFOToolEM=jtm.pflowweighter, WeightPFOToolLC=jtm.pflowweighterLC)

  # Calo layer energies.
  jtm += JetCaloEnergies("jetens")

  # Read in missing cell map (needed for the following)
  # commented out : incompatible with trigger : ATR-9696
  ## if jtm.haveJetRecCalo:
  ##     def missingCellFileReader(): 
  ##       import os
  ##       dataPathList = os.environ[ 'DATAPATH' ].split(os.pathsep)
  ##       dataPathList.insert(0, os.curdir)
  ##       from AthenaCommon.Utils.unixtools import FindFile
  ##       RefFileName = FindFile( "JetBadChanCorrTool.root" ,dataPathList, os.R_OK )
  ##       from AthenaCommon.AppMgr import ServiceMgr
  ##       if not hasattr(ServiceMgr, 'THistSvc'):
  ##         from GaudiSvc.GaudiSvcConf import THistSvc
  ##         ServiceMgr += THistSvc()
  ##       ServiceMgr.THistSvc.Input += ["JetBadChanCorrTool DATAFILE=\'%s\' OPT=\'READ\'" % RefFileName]
  ##       missingCellFileReader.called = True 

  ##     missingCellFileReader()

  ##     jtm += MissingCellListTool(
  ##       "missingcells",
  ##       AddCellList = [],
  ##       RemoveCellList = [],
  ##       AddBadCells = True,
  ##       DeltaRmax = 1.0,
  ##       AddCellFromTool = False,
  ##       LArMaskBit = 608517,
  ##       TileMaskBit = 1,
  ##       MissingCellMapName = "MissingCaloCellsMap"
  ## )

  ## # Bad channel corrections from cells
  ## if jtm.haveJetBadChanCorrTool:
  ##   jtm += JetBadChanCorrTool(
  ##     "bchcorrcell",
  ##     NBadCellLimit = 10000,
  ##     StreamName = "/JetBadChanCorrTool/",
  ##     ProfileName = "JetBadChanCorrTool.root",
  ##     ProfileTag = "",
  ##     UseCone = True,
  ##     UseCalibScale = False,
  ##     MissingCellMap = "MissingCaloCellsMap",
  ##     ForceMissingCellCheck = False,
  ##     UseClusters = False,
  ##   )

  ##   # Bad channel corrections from clusters
  ##   jtm += JetBadChanCorrTool(
  ##     "bchcorrclus",
  ##     NBadCellLimit = 0,
  ##     StreamName = "",
  ##     ProfileName = "",
  ##     ProfileTag = "",
  ##     UseCone = True,
  ##     UseCalibScale = False,
  ##     MissingCellMap = "",
  ##     ForceMissingCellCheck = False,
  ##     UseClusters = True
  ##   )

  # Bad LAr fractions.
  jtm += JetECPSFractionTool(
    "ecpsfrac",
  )

  #--------------------------------------------------------------
  # Track-vertex association.
  #--------------------------------------------------------------
  from TrackVertexAssociationTool.TrackVertexAssociationToolConf import CP__TightTrackVertexAssociationTool
  jtm += CP__TightTrackVertexAssociationTool("jetTighTVAtool", dzSinTheta_cut=3, doPV=True)

  jtm += TrackVertexAssociationTool(
    "tvassoc",
    TrackParticleContainer  = jtm.trackContainer,
    TrackVertexAssociation  = "JetTrackVtxAssoc",
    VertexContainer         = jtm.vertexContainer,
    TrackVertexAssoTool     = jtm.jetTighTVAtool,
  )

  jtm += TrackVertexAssociationTool(
    "tvassoc_old",
    TrackParticleContainer  = jtm.trackContainer,
    TrackVertexAssociation  = "JetTrackVtxAssoc_old",
    VertexContainer         = jtm.vertexContainer,
    MaxTransverseDistance   = 1.5,
    MaxLongitudinalDistance = 1.0e7,
    MaxZ0SinTheta = 1.5
  )

  #--------------------------------------------------------------
  # Track selection.
  #--------------------------------------------------------------

  # This is the InDet loose selection from
  # https://twiki.cern.ch/twiki/bin/view/AtlasProtected/InDetTrackingPerformanceGuidelines
  # October 28, 2014
  #jtm += InDet__InDetDetailedTrackSelectionTool(
  jtm += InDet__InDetTrackSelectionTool(
    "trk_trackselloose",
    CutLevel                = "Loose"
  )

  jtm += JetTrackSelectionTool(
    "trackselloose",
    InputContainer  = jtm.trackContainer,
    OutputContainer = "JetSelectedTracks",
    Selector        = jtm.trk_trackselloose
  )

  jtm += InDet__InDetTrackSelectionTool(
    "trk_trackselloose_trackjets",
    CutLevel                = "Loose"
  )

  jtm += JetTrackSelectionTool(
     "trackselloose_trackjets",
    InputContainer  = jtm.trackContainer,
    OutputContainer = "JetSelectedTracks_LooseTrackJets",
    Selector        = jtm.trk_trackselloose_trackjets
  )

  if jetFlags.useInDetTrackSelection():
    jtm += JetTrackSelectionTool(
      "tracksel",
      InputContainer  = jtm.trackContainer,
      OutputContainer = "JetSelectedTracks",
      Selector        = jtm.trk_trackselloose
    )
  else:
    jtm += SimpleJetTrackSelectionTool(
      "tracksel",
      PtMin = 500.0,
      InputContainer  = jtm.trackContainer,
      OutputContainer = "JetSelectedTracks",
    )


  # Tracks.
  jtm += TrackPseudoJetGetter(
    "trackget",
    InputContainer = jtm.trackselloose_trackjets.OutputContainer,
    Label = "Track",
    OutputContainer = "PseudoJetTracks",
    TrackVertexAssociation = jtm.tvassoc.TrackVertexAssociation,
    SkipNegativeEnergy = True,
    GhostScale = 0.0
  )


  # Ghost tracks.
  jtm += TrackPseudoJetGetter(
    "gtrackget",
    InputContainer = jtm.tracksel.OutputContainer,
    Label = "GhostTrack",
    OutputContainer = "PseudoJetGhostTracks",
    TrackVertexAssociation = jtm.tvassoc.TrackVertexAssociation,
    SkipNegativeEnergy = True,
    GhostScale = 1e-20
  )


  # Jet vertex fraction.
  jtm += JetVertexFractionTool(
    "jvfold",
    VertexContainer = jtm.vertexContainer,
    AssociatedTracks = "GhostTrack",
    TrackVertexAssociation = jtm.tvassoc.TrackVertexAssociation,
    JVFName = "JVFOld"
  )

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

  # Jet vertex tagger.
  jtm += JetVertexTaggerTool(
    "jvt",
    VertexContainer = jtm.vertexContainer,
    TrackParticleContainer  = jtm.trackContainer,
    AssociatedTracks = "GhostTrack",
    TrackVertexAssociation = jtm.tvassoc.TrackVertexAssociation,
    TrackSelector = jtm.trackselloose,
    JVTName = "Jvt",
    K_JVFCorrScale = 0.01,
    Z0Cut = 3.0,
    PUTrkPtCut = 30000.0
  )

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

  # Jet track vector sum info
  jtm += JetTrackSumMomentsTool(
    "trksummoms",
    VertexContainer = jtm.vertexContainer,
    AssociatedTracks = "GhostTrack",
    TrackVertexAssociation = jtm.tvassoc.TrackVertexAssociation,
    RequireTrackPV = True,
    TrackSelector = jtm.trackselloose
  )

  # Jet cluster info.
  jtm += JetClusterMomentsTool(
    "clsmoms",
    DoClsPt = True,
    DoClsSecondLambda = True,
    DoClsCenterLambda = True,
    DoClsSecondR = True
  )


  jtm += JetVoronoiMomentsTool(
    "voromoms",
    AreaXmin= -5.,
    AreaXmax=  5.,
    AreaYmin= -3.141592,
    AreaYmax=  3.141592
  )

  # Isolations.
  # Note absence of PseudoJetGetter property means the jet inputs
  # are obtained according to the InputType property of the jet.
  jtm += JetIsolationTool(
    "jetisol",
    IsolationCalculations = ["IsoDelta:2:SumPt", "IsoDelta:3:SumPt"],
  )
  jtm += JetIsolationTool(
    "run1jetisol",
    IsolationCalculations = ["IsoKR:11:Perp", "IsoKR:11:Par", "IsoFixedCone:6:SumPt",],
  )


  # Bad LAr fractions.
  jtm += JetLArHVTool("larhvcorr")


  # Jet origin correction.
  jtm += JetOriginCorrectionTool(
    "jetorigincorr",
    VertexContainer = jtm.vertexContainer,
    OriginCorrectedName = "JetOriginConstitScaleMomentum"
  )

  # Just set the PV without applying origin correction
  jtm += JetOriginCorrectionTool(
    "jetorigin_setpv",
    VertexContainer = jtm.vertexContainer,
    OriginCorrectedName = "",
    OnlyAssignPV = True,
  )

  # Load the xAODCaloEvent dictionary for cluster scale enum
  import cppyy
  try: cppyy.loadDictionary('xAODCaloEventDict')
  except: pass
  from ROOT import xAOD
  # Touch an unrelated class so the dictionary is loaded
  # and therefore the CaloCluster version typedef is recognised
  xAOD.CaloVertexedTopoCluster
Esempio n. 3
0
#--------------------------------------------------------------

jtm.addJetBuilderWithArea(
    JetFromPseudojet("jblda", Attributes=["ActiveArea", "ActiveArea4vec"]))

jtm.addJetBuilderWithoutArea(JetFromPseudojet("jbldna", Attributes=[]))

#--------------------------------------------------------------
# Non-substructure moment builders.
#--------------------------------------------------------------

# Quality from clusters.
jtm += JetCaloQualityTool(
    "caloqual_cluster",
    TimingCuts=[5, 10],
    Calculations=[
        "LArQuality", "N90Constituents", "FracSamplingMax", "NegativeE",
        "Timing", "HECQuality", "Centroid", "AverageLArQF", "BchCorrCell"
    ],
)

# Quality from cells.
if jtm.haveJetCaloCellQualityTool:
    jtm += JetCaloCellQualityTool("caloqual_cell",
                                  LArQualityCut=4000,
                                  TileQualityCut=254,
                                  TimingCuts=[5, 10],
                                  Calculations=[
                                      "LArQuality", "N90Cells",
                                      "FracSamplingMax", "NegativeE", "Timing",
                                      "HECQuality", "Centroid", "AverageLArQF"
                                  ])
Esempio n. 4
0
def getCaloQualityTool(computeFromCluster=False,
                       doCellBasedVars=False,
                       addJetQualityMoments=False):

    from JetMomentTools.JetMomentToolsConf import JetCaloQualityTool
    caloQualityT = JetCaloQualityTool("JetCaloQualityTool")
    caloQualityT.doCellBasedVariables = doCellBasedVars
    caloQualityT.cutOnLAr = 4000
    caloQualityT.doLArQuality = True
    caloQualityT.doTiming = True
    caloQualityT.doHECQuality = True
    caloQualityT.doNegativeE = True
    caloQualityT.doTileQuality = False
    caloQualityT.doAverageLArQF = True
    #caloQualityT.timingMomentCells     = [5,10]  # produces jet moments: ootFracCells5, ootFracCells10 (names built on the fly from caloQualityT.timingMomentCellsName)
    caloQualityT.timingMomentClusters = [5, 10]  #
    caloQualityT.timingMomentCells = []
    caloQualityT.doJetCentroid = True

    caloQualityT.ComputeVariableFromCluster = computeFromCluster

    if addJetQualityMoments:
        caloQualityT.doConstituentBasedVariables = True
        caloQualityT.doSamplingBasedVariables = True
        caloQualityT.cutOnTile = 254
        caloQualityT.doTileQuality = True

    return caloQualityT
Esempio n. 5
0
def JetVarToolConfig(seq=AlgSequence):

    from RecExConfig.ObjKeyStore import cfgKeyStore
    if (cfgKeyStore.isInInput('CaloCellContainer', 'AllCalo')
            and cfgKeyStore.isInInput('CaloCellLinkContainer',
                                      'CaloCalTopoCluster_Link')):

        from JetRec.JetMomentGetter import make_JetMomentGetter
        from JetRec.JetRecFlags import jetFlags

        from CaloClusterCorrection.StandardCellWeightCalib import getCellWeightTool
        cellcalibtool = getCellWeightTool('Kt',
                                          0.4,
                                          'Topo',
                                          onlyCellWeight=True)

        jetFlags.doJVF = False  ##the following jet getter seems to fail if we don't deactivate the jet vertex finder.
        #make_StandardJetGetter('AntiKt',0.4,'Topo',disable=False, doCalib=True, calibName='H1NumInv', outputCollectionName='AntiKt4TopoJets',seq=seq)
        #make_StandardJetGetter('AntiKt',0.6,'Topo',disable=False, doCalib=True, calibName='H1NumInv', outputCollectionName='AntiKt6TopoJets',seq=seq)
        # MB: April 19, 2011, Suggested fix from SS
        make_StandardJetGetter('AntiKt',
                               0.4,
                               'Topo',
                               disable=False,
                               doCalib=True,
                               calibName='EM:H1NumInv',
                               outputCollectionName='AntiKt4TopoJets',
                               seq=seq)
        make_StandardJetGetter('AntiKt',
                               0.6,
                               'Topo',
                               disable=False,
                               doCalib=True,
                               calibName='EM:H1NumInv',
                               outputCollectionName='AntiKt6TopoJets',
                               seq=seq)

        # MB: April 7, 2011 : Suggested fix from SS
        from JetMomentTools.JetMomentToolsConf import \
             JetBadChanCorrTool, JetBadCellCorrTool, JetCaloQualityTool
        atool4 = JetBadChanCorrTool("JetBadChanCorrTool_anti04",
                                    ConeDr=0.4,
                                    UseCalibScale=False)
        atool4.CellCalibrator = cellcalibtool
        atool6 = JetBadChanCorrTool("JetBadChanCorrTool_anti06",
                                    ConeDr=0.6,
                                    UseCalibScale=False)
        atool6.CellCalibrator = cellcalibtool

        #atool4 = JetBadChanCorrTool("JetBadChanCorrTool_anti04",UpdateEvery=False,ConeDr=0.4,UseCalibScale=False)
        #atool4.CellCalibrator = cellcalibtool
        #atool6 = JetBadChanCorrTool("JetBadChanCorrTool_anti06",UpdateEvery=False,ConeDr=0.6,UseCalibScale=False)
        #atool6.CellCalibrator = cellcalibtool

        cqual_tool = JetCaloQualityTool("CaloQualTool")
        cqual_tool.doSamplingBasedVariables = True
        cqual_tool.doCellBasedVariables = True

        BadCellCorrT = JetBadCellCorrTool("JetBadCellCorrTool")

        BadCellCorrT.CellCalibrator = cellcalibtool
        ##print BadCellCorrT
        ##toolist += [BadCellCorrT]

        make_JetMomentGetter("AntiKt4TopoJets",
                             [atool4, cqual_tool, BadCellCorrT],
                             seq=seq)
        make_JetMomentGetter("AntiKt6TopoJets",
                             [atool6, cqual_tool, BadCellCorrT],
                             seq=seq)
    else:
        from AthenaCommon.Logging import logging
        log = logging.getLogger('MissingETGoodness')
        log.warning('No cells; not rebuilding jets.')

    ###############################################

    jet_collection_key = 'AntiKt4TopoJets'
    if cfgKeyStore.isInInput('JetCollection', 'AntiKt4TopoEMJets'):
        jet_collection_key = 'AntiKt4TopoEMJets'

    truth_jet_collection_key = 'Cone4TruthJets'
    if cfgKeyStore.isInInput('JetCollection', 'AntiKt4TruthJets'):
        truth_jet_collection_key = 'AntiKt4TruthJets'

    from MissingETGoodness.MissingETGoodnessConf import JetVarTool as ConfiguredJetVarTool
    JetVarTool = ConfiguredJetVarTool(
        JetCollectionKey=jet_collection_key,
        JetTruthCollectionKey=truth_jet_collection_key,
        TrackParticleContainerKey='TrackParticleCandidate',
    )
    from AthenaCommon.AppMgr import ToolSvc
    ToolSvc += JetVarTool
    print JetVarTool