7 from AthenaConfiguration.ComponentAccumulator 
import ComponentAccumulator
 
    8 from AthenaConfiguration.ComponentFactory 
import CompFactory
 
    9 from AthenaConfiguration.Enums 
import MetadataCategory
 
   11 BPHYDerivationName = 
"BPHY2" 
   12 streamName = 
"StreamDAOD_BPHY2" 
   16     from DerivationFrameworkBPhys.commonBPHYMethodsCfg 
import (BPHY_V0ToolCfg,  BPHY_InDetDetailedTrackSelectorToolCfg, BPHY_VertexPointEstimatorCfg, BPHY_TrkVKalVrtFitterCfg)
 
   17     from JpsiUpsilonTools.JpsiUpsilonToolsConfig 
import PrimaryVertexRefittingToolCfg
 
   19     BPHY2_AugOriginalCounts = CompFactory.DerivationFramework.AugOriginalCounts(
 
   20        name = 
"BPHY2_AugOriginalCounts",
 
   21        VertexContainer = 
"PrimaryVertices",
 
   22        TrackContainer = 
"InDetTrackParticles" )
 
   23     isSimulation = flags.Input.isMC
 
   25     V0Tools = acc.popToolsAndMerge(
BPHY_V0ToolCfg(flags, BPHYDerivationName))
 
   27     acc.addPublicTool(vkalvrt)
 
   28     acc.addPublicTool(V0Tools)
 
   30     acc.addPublicTool(trackselect)
 
   32     acc.addPublicTool(vpest)
 
   33     BPHY2JpsiFinder = CompFactory.Analysis.JpsiFinder(name           = 
"BPHY2JpsiFinder",
 
   36                                          TrackAndTrack               = 
False,
 
   38                                          invMassUpper                = 4700.0,
 
   39                                          invMassLower                = 2600.0,
 
   41                                          oppChargesOnly              = 
True,
 
   43                                          atLeastOneComb              = 
False,
 
   44                                          useCombinedMeasurement      = 
False, 
 
   45                                          muonCollectionKey           = 
"Muons",
 
   46                                          TrackParticleCollection     = 
"InDetTrackParticles",
 
   47                                          V0VertexFitterTool          = 
None,             
 
   49                                          TrkVertexFitterTool         = vkalvrt,        
 
   50                                          TrackSelectorTool           = trackselect,
 
   51                                          VertexPointEstimator        = vpest,
 
   54     BPHY2JpsiSelectAndWrite = CompFactory.DerivationFramework.Reco_Vertex(name           = 
"BPHY2JpsiSelectAndWrite",
 
   55                                                         VertexSearchTool       = BPHY2JpsiFinder,
 
   56                                                         OutputVtxContainerName = 
"BPHY2JpsiCandidates",
 
   57                                                         PVContainerName        = 
"PrimaryVertices",
 
   58                                                         RefPVContainerName     = 
"SHOULDNOTBEUSED",
 
   63     BPHY2BsJpsiKK = CompFactory.Analysis.JpsiPlus2Tracks(name = 
"BPHY2BsJpsiKK",
 
   64                                          kaonkaonHypothesis      = 
True,
 
   65                                          pionpionHypothesis      = 
False,
 
   66                                          kaonpionHypothesis      = 
False,
 
   67                                          trkThresholdPt          = 800.0,
 
   71                                          DiTrackMassUpper = 1019.445 + 100.,
 
   72                                          DiTrackMassLower = 1019.445 - 100.,
 
   74                                          TrkQuadrupletMassUpper      = 6000.0,
 
   75                                          TrkQuadrupletMassLower      = 4800.0,
 
   76                                          JpsiContainerKey        = 
"BPHY2JpsiCandidates",
 
   77                                          TrackParticleCollection = 
"InDetTrackParticles",
 
   78                                          MuonsUsedInJpsi         = 
"Muons",
 
   79                                          TrkVertexFitterTool     = vkalvrt,
 
   80                                          TrackSelectorTool       = trackselect,
 
   81                                          UseMassConstraint       = 
False)
 
   83     BPHY2BsKKSelectAndWrite = CompFactory.DerivationFramework.Reco_Vertex(name   = 
"BPHY2BsKKSelectAndWrite",
 
   84                                                            VertexSearchTool       = BPHY2BsJpsiKK,
 
   85                                                            OutputVtxContainerName   = 
"BPHY2BsJpsiKKCandidates",
 
   86                                                            PVContainerName          = 
"PrimaryVertices",
 
   87                                                            RefPVContainerName       = 
"BPHY2RefittedPrimaryVertices",
 
   91                                                            MaxPVrefit               = 10000, DoVertexType = 7)
 
   93     BPHY2_Select_Psi2mumu = CompFactory.DerivationFramework.Select_onia2mumu(
 
   94       name                  = 
"BPHY2_Select_Psi2mumu",
 
   95       HypothesisName        = 
"Psi",
 
   96       InputVtxContainerName = 
"BPHY2JpsiCandidates",
 
   98       VtxMassHypo           = 3686.09,
 
  104     BPHY2_Select_Jpsi2mumu = CompFactory.DerivationFramework.Select_onia2mumu(
 
  105       name                  = 
"BPHY2_Select_Jpsi2mumu",
 
  106       HypothesisName        = 
"Jpsi",
 
  107       InputVtxContainerName = 
"BPHY2JpsiCandidates",
 
  109       VtxMassHypo           = 3096.916,
 
  115     BPHY2_Select_Bs2JpsiKK = CompFactory.DerivationFramework.Select_onia2mumu(
 
  116       name                       = 
"BPHY2_Select_Bs2JpsiKK",
 
  117       HypothesisName             = 
"Bs",
 
  118       InputVtxContainerName      = 
"BPHY2BsJpsiKKCandidates",
 
  120       TrkMasses                  = [105.658, 105.658, 493.677, 493.677],
 
  121       VtxMassHypo                = 5366.3,
 
  128     BPHY2_thinningTool_Tracks = CompFactory.DerivationFramework.Thin_vtxTrk(
 
  129       name                       = 
"BPHY2_thinningTool_Tracks",
 
  130       TrackParticleContainerName = 
"InDetTrackParticles",
 
  131       StreamName = streamName,
 
  132       VertexContainerNames       = [
"BPHY2BsJpsiKKCandidates"],
 
  133       PassFlags                  = [
"passed_Bs"] )
 
  136     BPHY2_thinningTool_TracksPsi = CompFactory.DerivationFramework.Thin_vtxTrk(
 
  137       name                       = 
"BPHY2_thinningTool_TracksPsi",
 
  138       TrackParticleContainerName = 
"InDetTrackParticles",
 
  139       StreamName = streamName,
 
  140       VertexContainerNames       = [
"BPHY2JpsiCandidates"],
 
  141       PassFlags                  = [
"passed_Psi", 
"passed_Jpsi"] )
 
  143     BPHY2_thinningTool_PV = CompFactory.DerivationFramework.BPhysPVThinningTool(
 
  144        name                       = 
"BPHY2_thinningTool_PV",
 
  145        CandidateCollections       = [
"BPHY2BsJpsiKKCandidates"],
 
  146        StreamName = streamName,
 
  149     BPHY2MuonTPThinningTool = CompFactory.DerivationFramework.MuonTrackParticleThinning(name     = 
"BPHY2MuonTPThinningTool",
 
  151                                                                          StreamName = streamName,
 
  152                                                                          InDetTrackParticlesKey  = 
"InDetTrackParticles")
 
  154        BPHY2_SelectBsJpsiKKEvent = CompFactory.DerivationFramework.xAODStringSkimmingTool(
 
  155        name = 
"BPHY2_SelectBsJpsiKKEvent",
 
  156        expression = 
"count(BPHY2BsJpsiKKCandidates.passed_Bs > 0) > 0")
 
  161        BPHY2SkimmingOR = CompFactory.DerivationFramework.FilterCombinationOR(
"BPHY2SkimmingOR",
 
  162                                                                     FilterList = [BPHY2_SelectBsJpsiKKEvent ])
 
  163        acc.addPublicTool(BPHY2SkimmingOR)
 
  166     thiningCollection = [BPHY2_thinningTool_Tracks, BPHY2_thinningTool_TracksPsi, BPHY2_thinningTool_PV, BPHY2MuonTPThinningTool]
 
  167     augCollection = [ BPHY2JpsiSelectAndWrite, BPHY2BsKKSelectAndWrite, BPHY2_Select_Psi2mumu, BPHY2_Select_Jpsi2mumu, BPHY2_Select_Bs2JpsiKK, BPHY2_AugOriginalCounts]
 
  168     acc.addEventAlgo(CompFactory.DerivationFramework.DerivationKernel(
"BPHY2Kernel",
 
  169                                                      AugmentationTools = augCollection,
 
  171                                                      SkimmingTools     = [BPHY2SkimmingOR] 
if not isSimulation 
else [],
 
  172                                                      ThinningTools     = thiningCollection))
 
  174     for t 
in  augCollection + thiningCollection : acc.addPublicTool(t)
 
  175     from DerivationFrameworkCore.SlimmingHelper 
import SlimmingHelper
 
  176     from OutputStreamAthenaPool.OutputStreamConfig 
import OutputStreamCfg
 
  177     from xAODMetaDataCnv.InfileMetaDataConfig 
import SetupMetaDataForStreamCfg
 
  178     BPHY2SlimmingHelper = 
SlimmingHelper(
"BPHY2SlimmingHelper", NamesAndTypes = flags.Input.TypedCollections, flags = flags)
 
  179     from DerivationFrameworkBPhys.commonBPHYMethodsCfg 
import getDefaultAllVariables
 
  184     BPHY2SlimmingHelper.IncludeMuonTriggerContent  = 
True 
  185     BPHY2SlimmingHelper.IncludeBPhysTriggerContent = 
True 
  188     SmartVar  += [
"PrimaryVertices"]
 
  189     StaticContent += [
"xAOD::VertexContainer#BPHY2RefittedPrimaryVertices"]
 
  190     StaticContent += [
"xAOD::VertexAuxContainer#BPHY2RefittedPrimaryVerticesAux."]
 
  193     AllVariables += [
"InDetTrackParticles"]
 
  198     AllVariables += [
"CombinedMuonTrackParticles"]
 
  201     SmartVar += [
"Muons"]
 
  204     StaticContent += [
"xAOD::VertexContainer#%s"        %                 BPHY2JpsiSelectAndWrite.OutputVtxContainerName]
 
  206     StaticContent += [
"xAOD::VertexAuxContainer#%sAux.-vxTrackAtVertex" % BPHY2JpsiSelectAndWrite.OutputVtxContainerName]
 
  208     StaticContent += [
"xAOD::VertexContainer#%s"        %                 BPHY2BsKKSelectAndWrite.OutputVtxContainerName]
 
  209     StaticContent += [
"xAOD::VertexAuxContainer#%sAux.-vxTrackAtVertex" % BPHY2BsKKSelectAndWrite.OutputVtxContainerName]
 
  212     AllVariables += [
"MuonSpectrometerTrackParticles" ]
 
  216         AllVariables += [
"TruthEvents",
"TruthParticles",
"TruthVertices",
"MuonTruthParticles" ]
 
  218     BPHY2SlimmingHelper.AllVariables = AllVariables
 
  219     BPHY2SlimmingHelper.StaticContent = StaticContent
 
  220     BPHY2SlimmingHelper.SmartCollections = SmartVar
 
  221     BPHY2ItemList = BPHY2SlimmingHelper.GetItemList()
 
  222     acc.merge(
OutputStreamCfg(flags, 
"DAOD_BPHY2", ItemList=BPHY2ItemList, AcceptAlgs=[
"BPHY2Kernel"]))
 
  223     acc.merge(
SetupMetaDataForStreamCfg(flags, 
"DAOD_BPHY2", AcceptAlgs=[
"BPHY2Kernel"], createMetadata=[MetadataCategory.CutFlowMetaData]))
 
  224     acc.printConfig(withDetails=
True, summariseProps=
True, onlyComponents = [], printDefaults=
True)