7 from AthenaConfiguration.ComponentAccumulator 
import ComponentAccumulator
 
    8 from AthenaConfiguration.ComponentFactory 
import CompFactory
 
    9 from AthenaConfiguration.Enums 
import MetadataCategory
 
   11 BPHYDerivationName = 
"BPHY1" 
   12 streamName = 
"StreamDAOD_BPHY1" 
   14 OniaContainerName = 
"BPHY1OniaCandidates" 
   17     from DerivationFrameworkBPhys.commonBPHYMethodsCfg 
import (BPHY_V0ToolCfg,  BPHY_InDetDetailedTrackSelectorToolCfg, BPHY_VertexPointEstimatorCfg, BPHY_TrkVKalVrtFitterCfg)
 
   19     doLRT = flags.Tracking.doLargeD0
 
   20     BPHY1_AugOriginalCounts = CompFactory.DerivationFramework.AugOriginalCounts(
 
   21        name = 
"BPHY1_AugOriginalCounts",
 
   22        VertexContainer = 
"PrimaryVertices",
 
   23        TrackContainer = 
"InDetTrackParticles",
 
   24        TrackLRTContainer = 
"InDetLargeD0TrackParticles" if doLRT 
else "" )
 
   25     mainMuonInput = 
"StdWithLRTMuons" if doLRT 
else "Muons" 
   26     mainIDInput   = 
"InDetWithLRTTrackParticles" if doLRT 
else "InDetTrackParticles" 
   28         from DerivationFrameworkLLP.LLPToolsConfig 
import LRTMuonMergerAlg
 
   29         from AthenaConfiguration.Enums 
import LHCPeriod
 
   31                                     PromptMuonLocation    = 
"Muons",
 
   32                                     LRTMuonLocation       = 
"MuonsLRT",
 
   33                                     OutputMuonLocation    = mainMuonInput,
 
   34                                     CreateViewCollection  = 
True,
 
   35                                     UseRun3WP = flags.GeoModel.Run == LHCPeriod.Run3))
 
   36         from DerivationFrameworkInDet.InDetToolsConfig 
import InDetLRTMergeCfg
 
   39     toRelink = [
"InDetTrackParticles", 
"InDetLargeD0TrackParticles"] 
if doLRT 
else []
 
   40     MuonReLink = [ 
"Muons", 
"MuonsLRT" ] 
if doLRT 
else []
 
   42     V0Tools = acc.popToolsAndMerge(
BPHY_V0ToolCfg(flags, BPHYDerivationName))
 
   44     acc.addPublicTool(vkalvrt)
 
   45     acc.addPublicTool(V0Tools)
 
   47     acc.addPublicTool(TrackSelector)
 
   49     acc.addPublicTool(vpest)
 
   50     BPHY1JpsiFinder = CompFactory.Analysis.JpsiFinder(
 
   51            name                        = 
"BPHY1JpsiFinder",
 
   54            TrackAndTrack               = 
False,
 
   56            invMassUpper                = 100000.0,
 
   59            oppChargesOnly               = 
True,
 
   60            atLeastOneComb              = 
True,
 
   61            useCombinedMeasurement      = 
False, 
 
   62            muonCollectionKey           = mainMuonInput,
 
   63            TrackParticleCollection     = mainIDInput,
 
   65            TrkVertexFitterTool         = vkalvrt,
 
   66            V0VertexFitterTool          = 
None,
 
   67            TrackSelectorTool           = TrackSelector,
 
   68            VertexPointEstimator        = vpest,
 
   71     from JpsiUpsilonTools.JpsiUpsilonToolsConfig 
import PrimaryVertexRefittingToolCfg
 
   72     BPHY1_Reco_mumu = CompFactory.DerivationFramework.Reco_Vertex(
 
   73             name                   = 
"BPHY1_Reco_mumu",
 
   74             VertexSearchTool       = BPHY1JpsiFinder,
 
   75             OutputVtxContainerName = OniaContainerName,
 
   76             PVContainerName        = 
"PrimaryVertices",
 
   77             RefPVContainerName     = 
"BPHY1RefittedPrimaryVertices",
 
   81             RelinkTracks  =  toRelink,
 
   82             RelinkMuons   =  MuonReLink,
 
   86     BPHY1_Select_Jpsi2mumu =CompFactory.DerivationFramework.Select_onia2mumu(
 
   87             name                  = 
"BPHY1_Select_Jpsi2mumu",
 
   88             HypothesisName        = 
"Jpsi",
 
   89             InputVtxContainerName = 
"BPHY1OniaCandidates",
 
   91             VtxMassHypo           = 3096.916,
 
   96     BPHY1_Select_Psi2mumu = CompFactory.DerivationFramework.Select_onia2mumu(
 
   97           name                  = 
"BPHY1_Select_Psi2mumu",
 
   98           HypothesisName        = 
"Psi",
 
   99           InputVtxContainerName = 
"BPHY1OniaCandidates",
 
  101           VtxMassHypo           = 3686.09,
 
  106     BPHY1_Select_Upsi2mumu = CompFactory.DerivationFramework.Select_onia2mumu(
 
  107           name                  = 
"BPHY1_Select_Upsi2mumu",
 
  108           HypothesisName        = 
"Upsi",
 
  109           InputVtxContainerName = 
"BPHY1OniaCandidates",
 
  111           VtxMassHypo           = 9460.30,
 
  116     augTools = [BPHY1_AugOriginalCounts, BPHY1_Reco_mumu, BPHY1_Select_Jpsi2mumu, BPHY1_Select_Psi2mumu,  BPHY1_Select_Upsi2mumu]
 
  117     for t 
in [BPHY1JpsiFinder] + augTools : acc.addPublicTool(t)
 
  120     BPHY1Thin_vtxTrk = CompFactory.DerivationFramework.Thin_vtxTrk(
 
  121           name                       = 
"BPHY1Thin_vtxTrk",
 
  122           TrackParticleContainerName = 
"InDetTrackParticles",
 
  123           StreamName = streamName,
 
  124           VertexContainerNames       = [
"BPHY1OniaCandidates"],
 
  125           PassFlags                  = [
"passed_Jpsi", 
"passed_Psi", 
"passed_Upsi"] )
 
  126     BPHY1MuonTPThinningTool = CompFactory.DerivationFramework.MuonTrackParticleThinning(name      = 
"BPHY1MuonTPThinningTool",
 
  128                                                                          StreamName = streamName,
 
  129                                                                          InDetTrackParticlesKey  = 
"InDetTrackParticles")
 
  130     BPHY1ThinningTools = [BPHY1Thin_vtxTrk, BPHY1MuonTPThinningTool]
 
  131     if flags.Input.isMC :
 
  132         TruthSelection =
"TruthParticles.pdgId == 443 || TruthParticles.pdgId == 100443 || TruthParticles.pdgId == 553 || TruthParticles.pdgId == 100553 || TruthParticles.pdgId == 200553" 
  133         BPHY1TruthThinTool = CompFactory.DerivationFramework.GenericTruthThinning(name = 
"BPHY1TruthThinTool",
 
  134                                StreamName = streamName,
 
  135                                ParticleSelectionString = TruthSelection,
 
  136                                PreserveDescendants     = 
True,
 
  137                                PreserveAncestors      = 
True)
 
  138         BPHY1ThinningTools.append(BPHY1TruthThinTool)
 
  141     SelectExpression = 
"count(BPHY1OniaCandidates.passed_Jpsi) > 0 || count(BPHY1OniaCandidates.passed_Psi) > 0 || count(BPHY1OniaCandidates.passed_Upsi) > 0" 
  142     BPHY1_SelectEvent = CompFactory.DerivationFramework.xAODStringSkimmingTool(name = 
"BPHY1_SelectEvent", expression = SelectExpression)
 
  143     acc.addPublicTool(BPHY1_SelectEvent)
 
  144     acc.addEventAlgo(CompFactory.DerivationFramework.DerivationKernel(
"BPHY1Kernel",
 
  145                             SkimmingTools = [BPHY1_SelectEvent],
 
  146                             ThinningTools     = BPHY1ThinningTools,
 
  147                             AugmentationTools = augTools))
 
  148     for tool 
in BPHY1ThinningTools : acc.addPublicTool(tool)
 
  152     doLRT = flags.Tracking.doLargeD0
 
  154     from OutputStreamAthenaPool.OutputStreamConfig 
import OutputStreamCfg
 
  155     from xAODMetaDataCnv.InfileMetaDataConfig 
import SetupMetaDataForStreamCfg
 
  156     from DerivationFrameworkCore.SlimmingHelper 
import SlimmingHelper
 
  157     from DerivationFrameworkBPhys.commonBPHYMethodsCfg 
import getDefaultAllVariables
 
  163     AllVariables += [
"PrimaryVertices"]
 
  164     StaticContent += [
"xAOD::VertexContainer#BPHY1RefittedPrimaryVertices"]
 
  165     StaticContent += [
"xAOD::VertexAuxContainer#BPHY1RefittedPrimaryVerticesAux."]
 
  168     AllVariables += [
"InDetTrackParticles", 
"InDetLargeD0TrackParticles"] 
if doLRT 
else [
"InDetTrackParticles"]
 
  173     AllVariables += [
"CombinedMuonTrackParticles"]
 
  174     AllVariables += [
"ExtrapolatedMuonTrackParticles"]
 
  177     AllVariables += [
"Muons", 
"MuonsLRT"] 
if doLRT 
else [
"Muons"]
 
  180     StaticContent += [
"xAOD::VertexContainer#%s"        % OniaContainerName]
 
  182     StaticContent += [
"xAOD::VertexAuxContainer#%sAux.-vxTrackAtVertex" % OniaContainerName]
 
  185     if flags.Input.isMC :
 
  186         AllVariables += [
"TruthEvents",
"TruthParticles",
"TruthVertices",
"MuonTruthParticles"]
 
  188     BPHY1SlimmingHelper = 
SlimmingHelper(
"BPHY1SlimmingHelper", NamesAndTypes = flags.Input.TypedCollections, flags = flags)
 
  190     BPHY1SlimmingHelper.IncludeMuonTriggerContent = 
True 
  191     BPHY1SlimmingHelper.IncludeBPhysTriggerContent = 
True 
  193     BPHY1SlimmingHelper.AllVariables = AllVariables
 
  194     BPHY1SlimmingHelper.StaticContent = StaticContent
 
  195     BPHY1ItemList = BPHY1SlimmingHelper.GetItemList()
 
  197     acc.merge(
OutputStreamCfg(flags, 
"DAOD_BPHY1", ItemList=BPHY1ItemList, AcceptAlgs=[
"BPHY1Kernel"]))
 
  198     acc.merge(
SetupMetaDataForStreamCfg(flags, 
"DAOD_BPHY1", AcceptAlgs=[
"BPHY1Kernel"], createMetadata=[MetadataCategory.CutFlowMetaData]))
 
  199     acc.printConfig(withDetails=
True, summariseProps=
True, onlyComponents = [], printDefaults=
True)