From 989e34283328124e270bfea09e4f9a7edaec4c51 Mon Sep 17 00:00:00 2001
From: williams <sarah.louise.williams@cern.ch>
Date: Tue, 7 Apr 2020 19:41:23 +0100
Subject: [PATCH] Update to configuration

---
 .../METReconstruction/METCaloRegionsTool.h    |  2 +
 .../Root/METCaloRegionsTool.cxx               | 15 +++++--
 .../METReconstruction/Root/METTruthTool.cxx   |  2 +-
 .../python/METAssocConfig.py                  | 13 +-----
 .../python/METCfg_Associator.py               | 43 ++++++++-----------
 .../METReconstruction/python/METCfg_Truth.py  | 29 +++++++++++++
 .../METReconstruction/share/METRecConfig.py   |  2 +-
 7 files changed, 65 insertions(+), 41 deletions(-)
 create mode 100644 Reconstruction/MET/METReconstruction/python/METCfg_Truth.py

diff --git a/Reconstruction/MET/METReconstruction/METReconstruction/METCaloRegionsTool.h b/Reconstruction/MET/METReconstruction/METReconstruction/METCaloRegionsTool.h
index bc27b932fe88..41dc936f6bb5 100644
--- a/Reconstruction/MET/METReconstruction/METReconstruction/METCaloRegionsTool.h
+++ b/Reconstruction/MET/METReconstruction/METReconstruction/METCaloRegionsTool.h
@@ -127,6 +127,8 @@ namespace met{
     #else
     SG::ReadCondHandleKey<CaloNoise> m_noiseCDOKey{this,"CaloNoiseKey","totalNoise","SG Key of CaloNoise data object"};
     #endif
+    SG::ReadHandleKey<xAOD::CaloClusterContainer> m_caloClusterKey{this,"CaloClusterKey","","SG Key of Calo Cluster Collection"};
+    SG::ReadHandleKey<CaloCellContainer> m_caloCellKey{this,"CaloCellKey","","SG Key of Calo Cell Container"};
   }; 
 
 }
diff --git a/Reconstruction/MET/METReconstruction/Root/METCaloRegionsTool.cxx b/Reconstruction/MET/METReconstruction/Root/METCaloRegionsTool.cxx
index 4a45221c9732..10e2e88e4e65 100644
--- a/Reconstruction/MET/METReconstruction/Root/METCaloRegionsTool.cxx
+++ b/Reconstruction/MET/METReconstruction/Root/METCaloRegionsTool.cxx
@@ -75,7 +75,15 @@ namespace met {
     #else
     ATH_CHECK( m_noiseCDOKey.initialize() );
     #endif
-
+    // Either Cells or Clusters
+    if(m_calo_useCells) {
+      ATH_CHECK( m_caloCellKey.assign(m_input_data_key));
+      ATH_CHECK( m_caloCellKey.initialize() );
+    } else {
+      ATH_CHECK( m_caloClusterKey.assign(m_input_data_key));
+      ATH_CHECK( m_caloClusterKey.initialize() );    
+    } // end if use clusters if/else
+    
     return StatusCode::SUCCESS;
   }
 
@@ -137,11 +145,12 @@ namespace met {
     // Either Cells or Clusters
     if(m_calo_useCells) {
       // Retrieve the cell container
-      SG::ReadHandle<CaloCellContainer> caloCellCont(m_input_data_key);
+      SG::ReadHandle<CaloCellContainer> caloCellCont(m_caloCellKey);
 
       #if defined(XAOD_STANDALONE) || defined(XAOD_ANALYSIS)
       #else
       if (!caloCellCont.isValid()) {
+        ATH_MSG_WARNING("Couldn't set up ReadHandle for Calo Cell Container "<<m_input_data_key);
         ATH_MSG_WARNING("Unable to retrieve input cell cluster container");
           return StatusCode::SUCCESS;
 
@@ -151,7 +160,7 @@ namespace met {
       sc = fillCellMet(metCont,caloCellCont.cptr());
     } else {
       // Retrieve the calo container
-      SG::ReadHandle<CaloClusterContainer> caloClusCont(m_input_data_key);
+      SG::ReadHandle<CaloClusterContainer> caloClusCont(m_caloClusterKey);
       if (!caloClusCont.isValid()) {
         ATH_MSG_WARNING("Unable to retrieve input calo cluster container");
           return StatusCode::SUCCESS;
diff --git a/Reconstruction/MET/METReconstruction/Root/METTruthTool.cxx b/Reconstruction/MET/METReconstruction/Root/METTruthTool.cxx
index 6b9fc3474935..bfa50b931109 100644
--- a/Reconstruction/MET/METReconstruction/Root/METTruthTool.cxx
+++ b/Reconstruction/MET/METReconstruction/Root/METTruthTool.cxx
@@ -120,7 +120,7 @@ namespace met {
   {
     // Apply cuts 
     ATH_MSG_VERBOSE("Check if truth particle is accepted");
-
+    if(object==NULL){return false;}
     if(object->type() != xAOD::Type::TruthParticle) { 
       ATH_MSG_WARNING("METTruthTool::accept given an object of type" << object->type());
       return false;
diff --git a/Reconstruction/MET/METReconstruction/python/METAssocConfig.py b/Reconstruction/MET/METReconstruction/python/METAssocConfig.py
index 29e27fd9519c..b4b2ba606308 100644
--- a/Reconstruction/MET/METReconstruction/python/METAssocConfig.py
+++ b/Reconstruction/MET/METReconstruction/python/METAssocConfig.py
@@ -225,22 +225,11 @@ def getMETAssocTool(topconfig,msglvl):
     return assocTool
 
 # Allow user to configure reco tools directly or get more default configurations
-def getMETAssocAlg(algName='METAssociation',configs={},tools=[],msglvl=INFO):
+def getMETAssocAlg(algName='METAssociation',tools=[],msglvl=INFO):
 
     assocTools = []
     assocTools += tools
 
-    from METReconstruction.METRecoFlags import metFlags
-    if configs=={} and tools==[]:
-        print (prefix, 'Taking configurations from METRecoFlags')
-        configs = metFlags.METAssocConfigs()
-        print (configs)
-    for key,conf in six.iteritems(configs):
-        print (prefix, 'Generate METAssocTool for MET_'+key)
-        assoctool = getMETAssocTool(conf,msglvl)
-        assocTools.append(assoctool)
-        metFlags.METAssocTools()[key] = assoctool
-
     for tool in assocTools:
         print (prefix, 'Added METAssocTool \''+tool.name()+'\' to alg '+algName)
 
diff --git a/Reconstruction/MET/METReconstruction/python/METCfg_Associator.py b/Reconstruction/MET/METReconstruction/python/METCfg_Associator.py
index 4740e22f29de..8c41ffe52a36 100644
--- a/Reconstruction/MET/METReconstruction/python/METCfg_Associator.py
+++ b/Reconstruction/MET/METReconstruction/python/METCfg_Associator.py
@@ -26,7 +26,6 @@ def METAssociator_Cfg(configFlags):
     ############################################################################
     # AntiKt4LCTopo
     JetType = 'LCJet'
-
     associators = [AssocConfig(JetType),
                    AssocConfig('Muon'),
                    AssocConfig('Ele'),
@@ -39,15 +38,8 @@ def METAssociator_Cfg(configFlags):
                                 modConstKey=modConstKey,
                                 modClusColls=modClusColls
                                 )
-
-    assoctool_akt4lc = getMETAssocTool(cfg_akt4lc)
-    assocAlg_akt4lc = getMETAssocAlg(algName='METAssociation_LCJets',tools=[assoctool_akt4lc])
-    components.addEventAlgo(assocAlg_akt4lc,sequencename)
-    makerAlg_akt4lc= getMETMakerAlg('AntiKt4LCTopo')
-    components.addEventAlgo(makerAlg_akt4lc,'METAssociation')
-    
-    #metFlags.METAssocConfigs()[cfg_akt4lc.suffix] = cfg_akt4lc
-    #metFlags.METAssocOutputList().append(cfg_akt4lc.suffix)
+    components_akt4lc= getAssocCA(cfg_akt4lc,sequencename='METAssoc_AntiKt4LCTopo',METName='AntiKt4LCTopo')
+    components.merge(components_akt4lc)
 
     ############################################################################
     # AntiKt4EMTopo
@@ -65,13 +57,8 @@ def METAssociator_Cfg(configFlags):
                                 modConstKey=modConstKey,
                                 modClusColls=modClusColls
                                 )
-    assoctool_akt4em = getMETAssocTool(cfg_akt4em)
-    assocAlg_akt4em = getMETAssocAlg(algName='METAssociation_EMJets',tools=[assoctool_akt4em])
-    components.addEventAlgo(assocAlg_akt4em,sequencename)
-    makerAlg_akt4em= getMETMakerAlg('AntiKt4EMTopo')
-    components.addEventAlgo(makerAlg_akt4em,'METAssociation')   
-    #metFlags.METAssocConfigs()[cfg_akt4em.suffix] = cfg_akt4em
-    #metFlags.METAssocOutputList().append(cfg_akt4em.suffix)
+    components_akt4em= getAssocCA(cfg_akt4em,sequencename='METAssoc_AntiKt4EMTopo',METName='AntiKt4EMTopo')
+    components.merge(components_akt4em)                            
 
     ############################################################################
     # PFlow
@@ -88,11 +75,19 @@ def METAssociator_Cfg(configFlags):
                                     associators,
                                     doPFlow=True
                                     )
-	assoctool_akt4pf = getMETAssocTool(cfg_akt4pf)
-        #metFlags.METAssocConfigs()[cfg_akt4pf.suffix] = cfg_akt4pf
-        #metFlags.METAssocOutputList().append(cfg_akt4pf.suffix)
-    	assocAlg_akt4pf = getMETAssocAlg(algName='METAssociation_PFlowJets',tools=[assoctool_akt4pf])
-    	components.addEventAlgo(assocAlg_akt4em,sequencename)
-        makerAlg_akt4pf= getMETMakerAlg('AntiKt4EMPFlow')
-        components.addEventAlgo(makerAlg_akt4pf,'METAssociation')   
+        components_akt4pf= getAssocCA(cfg_akt4pf,sequencename='METAssoc_AntiKt4EMPFlow',METName='AntiKt4EMPFlow')         
+        components.merge(components_akt4pf)
+    return components
+    
+    
+def getAssocCA(config,sequencename='METAssociation',METName=''):
+    components = ComponentAccumulator()
+    from AthenaCommon.AlgSequence import AthSequencer
+    components.addSequence( AthSequencer(sequencename) )
+    assoctool = getMETAssocTool(config)
+    assocAlg = getMETAssocAlg(algName='METAssociation_LCJets',tools=[assoctool])
+    components.addEventAlgo(assocAlg,sequencename)
+    if not METName=='':
+    	makerAlg=getMETMakerAlg(METName)
+        components.addEventAlgo(makerAlg,sequencename)
     return components
diff --git a/Reconstruction/MET/METReconstruction/python/METCfg_Truth.py b/Reconstruction/MET/METReconstruction/python/METCfg_Truth.py
new file mode 100644
index 000000000000..bec873e708f3
--- /dev/null
+++ b/Reconstruction/MET/METReconstruction/python/METCfg_Truth.py
@@ -0,0 +1,29 @@
+# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+
+from METReconstruction.METRecoFlags import metFlags
+from METReconstruction.METRecoCfg import BuildConfig, METConfig,getMETRecoAlg,getMETRecoTool
+from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
+from AthenaCommon import CfgMgr
+
+
+def METTruth_Cfg(configFlags):
+    sequencename = "METReconstruction_Truth"
+
+    components = ComponentAccumulator()
+    from AthenaCommon.AlgSequence import AthSequencer
+    components.addSequence( AthSequencer(sequencename) )
+    ## Simple truth terms
+
+    cfg_truth = METConfig('Truth',
+                          [BuildConfig('NonInt'),
+                           BuildConfig('Int'),
+                           BuildConfig('IntOut'),
+                           BuildConfig('IntMuons')],
+                          doRegions=True
+                          )
+
+    recotool = getMETRecoTool(cfg_truth)
+    recoAlg=getMETRecoAlg(algName='METRecoAlg_Truth',tools=[recotool])
+    components.addEventAlgo(recoAlg, sequencename)
+    return components
+
diff --git a/Reconstruction/MET/METReconstruction/share/METRecConfig.py b/Reconstruction/MET/METReconstruction/share/METRecConfig.py
index 037069470ee9..33a09df03484 100644
--- a/Reconstruction/MET/METReconstruction/share/METRecConfig.py
+++ b/Reconstruction/MET/METReconstruction/share/METRecConfig.py
@@ -1 +1 @@
-from AthenaCommon import Logging
from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator


if __name__=="__main__":

    # Setting needed for the ComponentAccumulator to do its thing
    from AthenaCommon.Configurable import Configurable
    Configurable.configurableRun3Behavior=True
    
    # Set message levels
    from AthenaCommon import Constants
    msgLvl = "VERBOSE"
    from AthenaCommon.Logging import log
    log.setLevel(msgLvl)


    
    # Config flags steer the job at various levels
    from AthenaConfiguration.AllConfigFlags import ConfigFlags
    ConfigFlags.Input.isMC  = True
    ConfigFlags.Input.Files = ["/cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/ASG/mc16_13TeV.410501.PowhegPythia8EvtGen_A14_ttbar_hdamp258p75_nonallhad.merge.AOD.e5458_s3126_r9364_r9315/AOD.11182705._000001.pool.root.1"]
    # Flags relating to multithreaded execution


    nthreads=0
    ConfigFlags.Concurrency.NumThreads =nthreads
    if nthreads>0:
    	ConfigFlags.Concurrency.NumThreads = 1
    	ConfigFlags.Concurrency.NumConcurrentEvents = 1
    ConfigFlags.MET.UseTracks = True
    ConfigFlags.MET.DoPFlow = True
    if ConfigFlags.Beam.Type == 'cosmics' or ConfigFlags.Beam.Type == 'singlebeam':# used to have " or not rec.doInDet()" on the end
        ConfigFlags.MET.UseTracks = False
        ConfigFlags.MET.DoPFlow = False
        print "METReconstruction_jobOptions: detected cosmics/single-beam configuration -- switch off track-based MET reco"
 

    ConfigFlags.lock()

    # Get a ComponentAccumulator setting up the fundamental Athena job
    from AthenaConfiguration.MainServicesConfig import MainServicesThreadedCfg 
    cfg=MainServicesThreadedCfg(ConfigFlags) 

    # Add the components for reading in pool files
    from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
    cfg.merge(PoolReadCfg(ConfigFlags))
    print "CHECKPOINT 1"

    from StoreGate.StoreGateConf import StoreGateSvc
    cfg.addService(StoreGateSvc("DetectorStore"))

    #Setup up general geometry
    modelConfig=ComponentAccumulator()
    from AtlasGeoModel.GeoModelConfig import GeoModelCfg
    modelConfig=GeoModelCfg(ConfigFlags)
    cfg.merge(modelConfig)

    from MagFieldServices.MagFieldServicesConfig import MagneticFieldSvcCfg
    cfg.merge(MagneticFieldSvcCfg(ConfigFlags))

    from TrkConfig.AtlasTrackingGeometrySvcConfig import TrackingGeometrySvcCfg
    cfg.merge(TrackingGeometrySvcCfg(ConfigFlags))

    from MuonConfig.MuonGeometryConfig import MuonGeoModelCfg
    cfg.merge(MuonGeoModelCfg(ConfigFlags))  
    
    # Get Jet Inputs
    from JetRecConfig.StandardJetDefs import EMTopoOrigin, LCTopoOrigin, CHSPFlow
    from JetRecConfig import JetRecConfig
    cfg1 = JetRecConfig.JetInputCfg( [EMTopoOrigin], ConfigFlags)
    cfg.merge( cfg1 )
    cfg2 = JetRecConfig.JetInputCfg( [LCTopoOrigin], ConfigFlags)
    cfg.merge( cfg2 )
    cfg3 = JetRecConfig.JetInputCfg( [CHSPFlow], ConfigFlags)
    cfg.merge( cfg3 )

    # Need to rename the collections in the xAOD in order to avoid conflicts
    from SGComps.AddressRemappingConfig import InputRenameCfg
    remap_track=InputRenameCfg('xAOD::MissingETContainer','MET_Track','MET_Track_Old')
    remap_trackaux=InputRenameCfg('xAOD::MissingETAuxContainer','MET_TrackAux.','MET_Track_OldAux.')
    cfg.merge(remap_track)
    cfg.merge(remap_trackaux)    
    remap_emt=InputRenameCfg('xAOD::MissingETContainer','MET_EMTopo','MET_EMTopo_Old')
    remap_emtaux=InputRenameCfg('xAOD::MissingETAuxContainer','MET_EMTopoAux.','MET_EMTopo_OldAux.')
    cfg.merge(remap_emt)
    cfg.merge(remap_emtaux)    
    remap_lht=InputRenameCfg('xAOD::MissingETContainer','MET_LocHadTopo','MET_LocHadTopo_Old')
    remap_lhtaux=InputRenameCfg('xAOD::MissingETAuxContainer','MET_LocHadTopoAux.','MET_LocHadTopo_OldAux.')
    cfg.merge(remap_lht)
    cfg.merge(remap_lhtaux)    
    
    from METReconstruction.METCfg_Track import METTrack_Cfg
    cfg4=METTrack_Cfg(ConfigFlags)
    cfg.merge(cfg4)

    from METReconstruction.METCfg_Calo import METCalo_Cfg
    cfg5=METCalo_Cfg(ConfigFlags)
    cfg.merge(cfg5)

    from METReconstruction.METCfg_Associator import METAssociator_Cfg
    cfg6=METAssociator_Cfg(ConfigFlags)
    cfg.merge(cfg6)
            
    # Start by just trying to add in MET Reconstruction based on METReconstruction_jobOptions.py
    #from METReconstruction.METRecoFlags import metFlags
    # from AthenaCommon.BeamFlags import jobproperties NO LONGER ALLOWED
    # from RecExConfig.RecFlags import rec NO LONGER ALLOWED
    #NEED TO CHANGE THIS TO DEPEND ON ConfigFlags.Beam.Type => for now ignore
 
   # TJ: Best to start each of these from scratch as a new CA module,
   # Can e.g. make files called METCaloConfig.py that just put the
   # old alg into a CA.
   
   # Rather than have N reco tools that get thrown into one alg later,
   # have each CA generate its own METRecoAlg and add this to the sequence.
   
    """
    import METReconstruction.METConfig_Calo
    import METReconstruction.METConfig_Track
    if rec.doTruth():
        import METReconstruction.METConfig_Truth
    
    from METReconstruction.METRecoConfig import getMETRecoAlg
    print "PICKING UP CHANGES"

    metAlg = getMETRecoAlg('METReconstruction')
    """


   # Probably want to define one CA each for EMTopo, LCTopo and PFlow,
   # then have a higher level one that merges in all three,
   # then the top-level (i.e. this) can just pull in the all-associators CA
    """
    components_metAlg = ComponentAccumulator()
    from AthenaCommon.AlgSequence import AthSequencer
    components_metAlg.addSequence( AthSequencer('METReconstruction') ) #technically don't need a new sequence name for it
    components_metAlg.addEventAlgo(metAlg,'METReconstruction')
    cfg.merge(components_metAlg)

    # Set up default configurations
    import METReconstruction.METConfig_Associator
    from METReconstruction.METAssocConfig import getMETAssocAlg

    # Get the configuration directly from METRecoFlags
    # Can also provide a dict of configurations or list of RecoTools or both
    assocAlg = getMETAssocAlg('METAssociation')
    components_assocAlg = ComponentAccumulator()
    components_assocAlg.addSequence(AthSequencer('METAssociation') )
    components_assocAlg.addEventAlgo(assocAlg,'METAssociation')
    cfg.merge(components_assocAlg)


    from METUtilities.METMakerConfig import getMETMakerAlg
    for key,conf in metFlags.METAssocConfigs().iteritems():
        if not conf.doTruth:
            makerAlg = getMETMakerAlg(conf.suffix)
            components_makerAlg=ComponentAccumulator()
            components_makerAlg.addSequence(AthSequencer(conf.suffix) )
            components_makerAlg.addEventAlgo(makerAlg,conf.suffix)	
            cfg.merge(components_makerAlg)
    """
    outputlist = ["EventInfo#*"]
    """
    originaljets = ["AntiKt4EMPFlowJets","AntiKt4EMTopoJets"]
    for jetcoll in originaljets:
      outputlist += ["xAOD::JetContainer#"+jetcoll,"xAOD::JetAuxContainer#"+jetcoll+"Aux."]
    """
    outputlist+=["xAOD::MissingETContainer#"+"MET_Track","xAOD::MissingETAuxContainer#"+"MET_Track"+"Aux."]
    outputlist+=["xAOD::MissingETContainer#"+"MET_Track_Old","xAOD::MissingETAuxContainer#"+"MET_Track_Old"+"Aux."]
    outputlist+=["xAOD::MissingETContainer#"+"MET_EMTopo","xAOD::MissingETAuxContainer#"+"MET_EMTopo"+"Aux."]
    outputlist+=["xAOD::MissingETContainer#"+"MET_EMTopo_Old","xAOD::MissingETAuxContainer#"+"MET_EMTopo_Old"+"Aux."]
    outputlist+=["xAOD::MissingETContainer#"+"MET_AntiKt4EMPFlow","xAOD::MissingETAuxContainer#"+"MET_AntiKt4EMPFlow"+"Aux."]
    from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
    cfg.merge(OutputStreamCfg(ConfigFlags,"xAOD",ItemList=outputlist))
    
    # Optionally, print the contents of the store every event
    cfg.getService("StoreGateSvc").Dump = True
    print "Running final component accumulator"
    cfg.printConfig()
    cfg.run(maxEvents=20)
    StoreGateSvc.Dump=True
\ No newline at end of file
+from AthenaCommon import Logging
from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator


if __name__=="__main__":

    # Setting needed for the ComponentAccumulator to do its thing
    from AthenaCommon.Configurable import Configurable
    Configurable.configurableRun3Behavior=True
    
    # Set message levels
    from AthenaCommon import Constants
    msgLvl = "WARNING"
    from AthenaCommon.Logging import log
    log.setLevel(msgLvl)


    
    # Config flags steer the job at various levels
    from AthenaConfiguration.AllConfigFlags import ConfigFlags
    ConfigFlags.Input.isMC  = True
    ConfigFlags.Input.Files = ["/cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/ASG/mc16_13TeV.410501.PowhegPythia8EvtGen_A14_ttbar_hdamp258p75_nonallhad.merge.AOD.e5458_s3126_r9364_r9315/AOD.11182705._000001.pool.root.1"]
    # Flags relating to multithreaded execution


    nthreads=0
    ConfigFlags.Concurrency.NumThreads =nthreads
    if nthreads>0:
    	ConfigFlags.Concurrency.NumThreads = 1
    	ConfigFlags.Concurrency.NumConcurrentEvents = 1
    ConfigFlags.MET.UseTracks = True
    ConfigFlags.MET.DoPFlow = True
    if ConfigFlags.Beam.Type == 'cosmics' or ConfigFlags.Beam.Type == 'singlebeam':# used to have " or not rec.doInDet()" on the end
        ConfigFlags.MET.UseTracks = False
        ConfigFlags.MET.DoPFlow = False
        print "METReconstruction_jobOptions: detected cosmics/single-beam configuration -- switch off track-based MET reco"
 

    ConfigFlags.lock()

    # Get a ComponentAccumulator setting up the fundamental Athena job
    from AthenaConfiguration.MainServicesConfig import MainServicesThreadedCfg 
    cfg=MainServicesThreadedCfg(ConfigFlags) 

    # Add the components for reading in pool files
    from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
    cfg.merge(PoolReadCfg(ConfigFlags))

    from StoreGate.StoreGateConf import StoreGateSvc
    cfg.addService(StoreGateSvc("DetectorStore"))

    #Setup up general geometry
    modelConfig=ComponentAccumulator()
    from AtlasGeoModel.GeoModelConfig import GeoModelCfg
    modelConfig=GeoModelCfg(ConfigFlags)
    cfg.merge(modelConfig)

    from MagFieldServices.MagFieldServicesConfig import MagneticFieldSvcCfg
    cfg.merge(MagneticFieldSvcCfg(ConfigFlags))

    from TrkConfig.AtlasTrackingGeometrySvcConfig import TrackingGeometrySvcCfg
    cfg.merge(TrackingGeometrySvcCfg(ConfigFlags))

    from MuonConfig.MuonGeometryConfig import MuonGeoModelCfg
    cfg.merge(MuonGeoModelCfg(ConfigFlags))  
    
    # Get Jet Inputs
    from JetRecConfig.StandardJetDefs import EMTopoOrigin, LCTopoOrigin, CHSPFlow
    from JetRecConfig import JetRecConfig
    cfg1 = JetRecConfig.JetInputCfg( [EMTopoOrigin], ConfigFlags)
    cfg.merge( cfg1 )
    cfg2 = JetRecConfig.JetInputCfg( [LCTopoOrigin], ConfigFlags)
    cfg.merge( cfg2 )
    cfg3 = JetRecConfig.JetInputCfg( [CHSPFlow], ConfigFlags)
    cfg.merge( cfg3 )

    # Need to rename the collections in the xAOD in order to avoid conflicts
    from SGComps.AddressRemappingConfig import InputRenameCfg
    remap_track=InputRenameCfg('xAOD::MissingETContainer','MET_Track','MET_Track_Old')
    remap_trackaux=InputRenameCfg('xAOD::MissingETAuxContainer','MET_TrackAux.','MET_Track_OldAux.')
    cfg.merge(remap_track)
    cfg.merge(remap_trackaux)    
    remap_emt=InputRenameCfg('xAOD::MissingETContainer','MET_EMTopo','MET_EMTopo_Old')
    remap_emtaux=InputRenameCfg('xAOD::MissingETAuxContainer','MET_EMTopoAux.','MET_EMTopo_OldAux.')
    cfg.merge(remap_emt)
    cfg.merge(remap_emtaux)    
    remap_lht=InputRenameCfg('xAOD::MissingETContainer','MET_LocHadTopo','MET_LocHadTopo_Old')
    remap_lhtaux=InputRenameCfg('xAOD::MissingETAuxContainer','MET_LocHadTopoAux.','MET_LocHadTopo_OldAux.')
    cfg.merge(remap_lht)
    cfg.merge(remap_lhtaux)    
    
    from METReconstruction.METCfg_Track import METTrack_Cfg
    cfg4=METTrack_Cfg(ConfigFlags)
    cfg.merge(cfg4)

    from METReconstruction.METCfg_Calo import METCalo_Cfg
    cfg5=METCalo_Cfg(ConfigFlags)
    cfg.merge(cfg5)
    
    # Need to understand how to access the doTruth flag in the current reconstruction SW.
    doTruth=True
    if doTruth:
    	from METReconstruction.METCfg_Truth import METTruth_Cfg
    	cfg.merge(METTruth_Cfg(ConfigFlags))
    from METReconstruction.METCfg_Associator import METAssociator_Cfg
    cfg6=METAssociator_Cfg(ConfigFlags)
    cfg.merge(cfg6)
            
    # Start by just trying to add in MET Reconstruction based on METReconstruction_jobOptions.py
    #from METReconstruction.METRecoFlags import metFlags
    # from AthenaCommon.BeamFlags import jobproperties NO LONGER ALLOWED
    # from RecExConfig.RecFlags import rec NO LONGER ALLOWED
    #NEED TO CHANGE THIS TO DEPEND ON ConfigFlags.Beam.Type => for now ignore
 
   # TJ: Best to start each of these from scratch as a new CA module,
   # Can e.g. make files called METCaloConfig.py that just put the
   # old alg into a CA.
   
   # Rather than have N reco tools that get thrown into one alg later,
   # have each CA generate its own METRecoAlg and add this to the sequence.
   
   # Probably want to define one CA each for EMTopo, LCTopo and PFlow,
   # then have a higher level one that merges in all three,
   # then the top-level (i.e. this) can just pull in the all-associators CA


    outputlist = ["EventInfo#*"]
    outputlist+=["xAOD::MissingETContainer#"+"MET_Track","xAOD::MissingETAuxContainer#"+"MET_Track"+"Aux."]
    outputlist+=["xAOD::MissingETContainer#"+"MET_Track_Old","xAOD::MissingETAuxContainer#"+"MET_Track_Old"+"Aux."]
    outputlist+=["xAOD::MissingETContainer#"+"MET_EMTopo","xAOD::MissingETAuxContainer#"+"MET_EMTopo"+"Aux."]
    outputlist+=["xAOD::MissingETContainer#"+"MET_EMTopo_Old","xAOD::MissingETAuxContainer#"+"MET_EMTopo_Old"+"Aux."]
    outputlist+=["xAOD::MissingETContainer#"+"MET_AntiKt4EMPFlow","xAOD::MissingETAuxContainer#"+"MET_AntiKt4EMPFlow"+"Aux."]
    from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
    cfg.merge(OutputStreamCfg(ConfigFlags,"xAOD",ItemList=outputlist))
    
    # Optionally, print the contents of the store every event
    cfg.getService("StoreGateSvc").Dump = False
    #print "Running final component accumulator"
    #cfg.printConfig()
    cfg.run(maxEvents=20)
\ No newline at end of file
-- 
GitLab