From 630d0c15ff1c0b7d27c634a6cc37231cd24a6729 Mon Sep 17 00:00:00 2001
From: Pavol Strizenec <pavol.strizenec@cern.ch>
Date: Thu, 2 Jul 2020 16:01:51 +0000
Subject: [PATCH] LArCellsMon config

---
 .../python/CaloBaselineMonAlg.py              |  37 +++---
 .../python/CaloMonitoringConfig.py            |   4 +
 .../CaloMonitoring/python/LArCellMonAlg.py    | 107 ++++++++++++------
 .../share/CaloNewMonitoring_jobOptions.py     |  12 ++
 .../CaloMonitoring/src/CaloBaselineMonAlg.cxx |   3 +-
 .../share/DataQualitySteering_jobOptions.py   |   1 +
 .../python/LArClusterCollisionTimeConfig.py   |  17 +++
 .../python/LArCollisionTimeMonAlg.py          |  39 +++++--
 .../LArMonitoring/python/LArDigitMonAlg.py    |   2 +-
 .../share/LArMonitoring_jobOption.py          |   9 +-
 10 files changed, 162 insertions(+), 69 deletions(-)
 create mode 100644 Calorimeter/CaloMonitoring/share/CaloNewMonitoring_jobOptions.py
 create mode 100644 LArCalorimeter/LArClusterRec/python/LArClusterCollisionTimeConfig.py

diff --git a/Calorimeter/CaloMonitoring/python/CaloBaselineMonAlg.py b/Calorimeter/CaloMonitoring/python/CaloBaselineMonAlg.py
index 4b9d1f8ac7e..62c682f42f9 100644
--- a/Calorimeter/CaloMonitoring/python/CaloBaselineMonAlg.py
+++ b/Calorimeter/CaloMonitoring/python/CaloBaselineMonAlg.py
@@ -3,6 +3,7 @@
 #
 
 from __future__ import print_function
+from AthenaConfiguration.ComponentFactory import CompFactory
 
 def CaloBaselineMonConfig(inputFlags, isTopLevel=True):
 
@@ -28,15 +29,7 @@ def CaloBaselineMonConfig(inputFlags, isTopLevel=True):
     from CaloTools.CaloNoiseCondAlgConfig import CaloNoiseCondAlgCfg
     cfg.merge(CaloNoiseCondAlgCfg(inputFlags))
 
-    from LumiBlockComps.LuminosityCondAlgConfig import  LuminosityCondAlgCfg
-    cfg.merge(LuminosityCondAlgCfg(inputFlags))
-
-
-    from AthenaMonitoring.BadLBFilterTool import GetLArBadLBFilterTool
-    from AthenaMonitoring.AtlasReadyFilterTool import GetAtlasReadyFilterTool
-
-    from CaloMonitoring.CaloMonitoringConf import CaloBaselineMonAlg
-    caloBaselineMonAlg = helper.addAlgorithm(CaloBaselineMonAlg,'caloBaselineMonAlg')
+    caloBaselineMonAlg = helper.addAlgorithm(CompFactory.CaloBaselineMonAlg,'caloBaselineMonAlg')
 
     GroupName="CaloBaseLineMon"
     caloBaselineMonAlg.MonGroupName = GroupName
@@ -52,8 +45,6 @@ def CaloBaselineMonConfig(inputFlags, isTopLevel=True):
     maxEta = [3.2,5.]
     caloBaselineMonAlg.maximumEta = maxEta
 
-    from TrigBunchCrossingTool.BunchCrossingTool import BunchCrossingTool
-
     # config settings based on flags
     tmp_CaloBaselineMon = {"useBadLBTool":False,
                         "useReadyFilterTool":False,
@@ -79,11 +70,15 @@ def CaloBaselineMonConfig(inputFlags, isTopLevel=True):
     #tmp_CaloBaselineMon["TriggerChain"] = "HLT_noalg_zb_L1ZB"
     tmp_CaloBaselineMon["TriggerChain"] = ""
 
+    from AthenaMonitoring.AtlasReadyFilterConfig import AtlasReadyFilterCfg
+    from AthenaMonitoring.BadLBFilterToolConfig import LArBadLBFilterToolCfg
+
     caloBaselineMonAlg.useBadLBTool = tmp_CaloBaselineMon["useBadLBTool"]
-    caloBaselineMonAlg.BadLBTool = GetLArBadLBFilterTool()
-    caloBaselineMonAlg.BunchCrossingTool = BunchCrossingTool("TrigConf" if not inputFlags.Input.isMC else "MC")
+    caloBaselineMonAlg.BadLBTool = cfg.popToolsAndMerge(LArBadLBFilterToolCfg(inputFlags))
+    # FIXME Do not have yet new config for BunchCrossingTool, shoulkd be put back once available
+    #caloBaselineMonAlg.BunchCrossingTool = BunchCrossingTool("TrigConf" if not inputFlags.Input.isMC else "MC")
     caloBaselineMonAlg.useReadyFilterTool = tmp_CaloBaselineMon["useReadyFilterTool"]
-    caloBaselineMonAlg.ReadyFilterTool = GetAtlasReadyFilterTool()
+    caloBaselineMonAlg.ReadyFilterTool = cfg.popToolsAndMerge(AtlasReadyFilterCfg(inputFlags))
     caloBaselineMonAlg.useLArCollisionFilterTool = tmp_CaloBaselineMon["useLArCollisionFilter"]
     caloBaselineMonAlg.useLArNoisyAlg = tmp_CaloBaselineMon["useLArNoisyAlg"]
     caloBaselineMonAlg.useBeamBackgroundRemoval = tmp_CaloBaselineMon["useBeamBackgroundRemoval"]
@@ -187,11 +182,11 @@ def CaloBaselineMonConfig(inputFlags, isTopLevel=True):
        idx=idx+1
 
 
-    if isTopLevel:
-       cfg.merge(helper.result())
-       return cfg
-    else:   
-       return helper.result()
+    #if isTopLevel:
+    cfg.merge(helper.result())
+    return cfg
+    #else:   
+    #   return helper.result()
     
 
 if __name__=='__main__':
@@ -223,8 +218,8 @@ if __name__=='__main__':
     from AthenaConfiguration.MainServicesConfig import MainServicesCfg 
     cfg = MainServicesCfg(ConfigFlags)
 
-    from CaloRec.CaloRecoConfig import CaloRecoCfg
-    cfg.merge(CaloRecoCfg(ConfigFlags))
+    #from CaloRec.CaloRecoConfig import CaloRecoCfg
+    #cfg.merge(CaloRecoCfg(ConfigFlags))
 
     cfg.merge(CaloBaselineMonConfig(ConfigFlags,False)) 
 
diff --git a/Calorimeter/CaloMonitoring/python/CaloMonitoringConfig.py b/Calorimeter/CaloMonitoring/python/CaloMonitoringConfig.py
index 544a541d884..39618c487ad 100644
--- a/Calorimeter/CaloMonitoring/python/CaloMonitoringConfig.py
+++ b/Calorimeter/CaloMonitoring/python/CaloMonitoringConfig.py
@@ -27,6 +27,10 @@ def CaloMonitoringCfg(flags):
         from CaloMonitoring.LArCellMonAlg import LArCellMonConfig
         acc.merge( LArCellMonConfig(flags) )
 
+        # FIXME could not be included yet, some trigger configurations are missing
+        #from CaloMonitoring.CaloBaselineMonAlg import CaloBaselineMonConfig
+        #acc.merge( CaloBaselineMonConfig(flags,False) )
+
     return acc
 
 
diff --git a/Calorimeter/CaloMonitoring/python/LArCellMonAlg.py b/Calorimeter/CaloMonitoring/python/LArCellMonAlg.py
index 3c0dfdf8791..7473ec77d58 100644
--- a/Calorimeter/CaloMonitoring/python/LArCellMonAlg.py
+++ b/Calorimeter/CaloMonitoring/python/LArCellMonAlg.py
@@ -2,13 +2,39 @@
 #  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
 #
 
+def LArCellMonConfigOld(inputFlags):
+    from AthenaMonitoring.AthMonitorCfgHelper import AthMonitorCfgHelperOld
+    from CaloMonitoring.CaloMonitoringConf import  LArCellMonAlg
+
+    helper = AthMonitorCfgHelperOld(inputFlags, 'LArCellMonAlgOldCfg')
+    from AthenaCommon.BeamFlags import jobproperties
+    if jobproperties.Beam.beamType() == 'cosmics':
+       isCosmics=True
+    else:
+       isCosmics=False
+
+    from AthenaCommon.GlobalFlags  import globalflags
+    if globalflags.DataSource() == 'data':
+       isMC=False
+    else:
+       isMC=True
+
+    LArCellMonConfigCore(helper, LArCellMonAlg,inputFlags,isCosmics, isMC)
+
+    from AthenaMonitoring.AtlasReadyFilterTool import GetAtlasReadyFilterTool
+    helper.monSeq.LArCellMonAlg.ReadyFilterTool = GetAtlasReadyFilterTool()
+    from AthenaMonitoring.BadLBFilterTool import GetLArBadLBFilterTool
+    helper.monSeq.LArCellMonAlg.BadLBTool = GetLArBadLBFilterTool()
+
+    return helper.result()
 
 def LArCellMonConfig(inputFlags):
 
     from AthenaCommon.Logging import logging
     mlog = logging.getLogger( 'LArCellMonConfig' )
-    from AthenaMonitoring import AthMonitorCfgHelper
-    helper = AthMonitorCfgHelper(inputFlags,'LArCellMonCfg')
+
+    from AthenaMonitoring.AthMonitorCfgHelper import AthMonitorCfgHelper
+    helper = AthMonitorCfgHelper(inputFlags,'LArCellMonAlgCfg')
 
     if not inputFlags.DQ.enableLumiAccess:
        mlog.warning('This algo needs Lumi access, returning empty config')
@@ -35,45 +61,63 @@ def LArCellMonConfig(inputFlags):
       from LumiBlockComps.LuminosityCondAlgConfig import  LuminosityCondAlgCfg
       cfg.merge(LuminosityCondAlgCfg(inputFlags))
 
-    isCosmics = ( inputFlags.Beam.Type == 'cosmics' ) #will use this switch many times later
-
     from AthenaConfiguration.ComponentFactory import CompFactory
-    LArCellMonAlg=CompFactory.LArCellMonAlg
+    lArCellMonAlg=CompFactory.LArCellMonAlg
+
     algname='LArCellMonAlg'
-    if isCosmics:
+    if inputFlags.Beam.Type == 'cosmics':
         algname=algname+'Cosmics'
-    LArCellMonAlg = helper.addAlgorithm(LArCellMonAlg,algname)
 
-    from LArBadChannelTool.LArBadChannelConfig import LArBadChannelMaskerCfg
+    isCosmics = ( inputFlags.Beam.Type == 'cosmics' )
+    LArCellMonConfigCore(helper, lArCellMonAlg,inputFlags, isCosmics, inputFlags.Input.isMC)
+
+    acc=helper.result()
+
+    from AthenaMonitoring.AtlasReadyFilterConfig import AtlasReadyFilterCfg
+    acc.getEventAlgo(algname).ReadyFilterTool = cfg.popToolsAndMerge(AtlasReadyFilterCfg(inputFlags))
+
+    if not inputFlags.Input.isMC:
+       from AthenaMonitoring.BadLBFilterToolConfig import LArBadLBFilterToolCfg
+       acc.getEventAlgo(algname).BadLBTool=cfg.popToolsAndMerge(LArBadLBFilterToolCfg(inputFlags))
+
+    cfg.merge(acc)
+
+    return cfg
+
+
+def LArCellMonConfigCore(helper, alginstance, inputFlags, isCosmics=False, isMC=False):
+
+
+    LArCellMonAlg = helper.addAlgorithm(alginstance, 'LArCellMonAlg')
 
     if isCosmics:
-        badChanMaskProblems=["deadReadout","deadPhys","short","sporadicBurstNoise","highNoiseHG","highNoiseMG","highNoiseLG"]
+       badChanMaskProblems=["deadReadout","deadPhys","short","sporadicBurstNoise","highNoiseHG","highNoiseMG","highNoiseLG"]
     else: 
-        badChanMaskProblems=["deadReadout","deadPhys","almostDead","short","sporadicBurstNoise","unstableNoiseLG","unstableNoiseMG","unstableNoiseHG","highNoiseHG","highNoiseMG","highNoiseLG"]
-        pass
+       badChanMaskProblems=["deadReadout","deadPhys","almostDead","short","sporadicBurstNoise","unstableNoiseLG","unstableNoiseMG","unstableNoiseHG","highNoiseHG","highNoiseMG","highNoiseLG"]
 
-    acc= LArBadChannelMaskerCfg(inputFlags,problemsToMask=badChanMaskProblems,ToolName="BadLArRawChannelMask")
-    LArCellMonAlg.LArBadChannelMask=acc.popPrivateTools()
-    cfg.merge(acc)
+    from AthenaConfiguration.ComponentFactory import isRun3Cfg
+    if isRun3Cfg():
+       from LArBadChannelTool.LArBadChannelConfig import LArBadChannelMaskerCfg
 
-    if not isCosmics and not inputFlags.Input.isMC:
-        from AthenaMonitoring.AtlasReadyFilterConfig import AtlasReadyFilterCfg
-        #LArCellMonAlg.FilterTools.append(cfg.popToolsAndMerge(AtlasReadyFilterCfg(inputFlags)))
+       acc= LArBadChannelMaskerCfg(inputFlags,problemsToMask=badChanMaskProblems,ToolName="BadLArRawChannelMask")
+       LArCellMonAlg.LArBadChannelMask=acc.popPrivateTools()
+       helper.resobj.merge(acc)
+    else:
+       from LArBadChannelTool.LArBadChannelToolConf import LArBadChannelMasker
+       theLArBadChannelsMasker=LArBadChannelMasker("BadLArRawChannelMask")
+       theLArBadChannelsMasker.DoMasking=True
+       theLArBadChannelsMasker.ProblemsToMask=badChanMaskProblems
+       LArCellMonAlg.LArBadChannelMask=theLArBadChannelsMasker
 
-        # why is there this parallel mechanism to the standard DQ filter chain?
-        LArCellMonAlg.ReadyFilterTool=cfg.popToolsAndMerge(AtlasReadyFilterCfg(inputFlags))
+    if not isCosmics and not isMC:
         LArCellMonAlg.useReadyFilterTool=True
     else:
         LArCellMonAlg.useReadyFilterTool=False
 
-    if not inputFlags.Input.isMC:
-        from AthenaMonitoring.BadLBFilterToolConfig import LArBadLBFilterToolCfg
-        #LArCellMonAlg.FilterTools.append(cfg.popToolsAndMerge(LArBadLBFilterToolCfg(inputFlags)))
-        # similar to above
-        LArCellMonAlg.BadLBTool=cfg.popToolsAndMerge(LArBadLBFilterToolCfg(inputFlags))
-        LArCellMonAlg.useBadLBTool=True
-    else:
+    if isMC:
         LArCellMonAlg.useBadLBTool=False
+    else:
+        LArCellMonAlg.useBadLBTool=True
 
 # FIXME: to be added:    if isCosmics or rec.triggerStream()!='CosmicCalo':
     LArCellMonAlg.useBeamBackgroundRemoval = False
@@ -227,7 +271,7 @@ def LArCellMonConfig(inputFlags):
     cellMonGroup = helper.addGroup(
         LArCellMonAlg,
         GroupName,
-        '/CaloMonitoring/LArCellMon_NoTrigSel/'
+        '/CaloMonitoring/LArCellMon_NoTrigSelNewAlg/'
 
     )
 
@@ -255,7 +299,7 @@ def LArCellMonConfig(inputFlags):
     # En.
     LArCellMonAlg.doUnnormalized1DEnergy=True
     energy_hist_path='Energy/'
-    if inputFlags.Beam.Type == 'collisions':
+    if not isCosmics:
         for part in LArCellMonAlg.LayerNames:
             cellMonGroup.defineHistogram('cellEnergy_'+part+';CellEnergy_'+part,
                                          title='Cell Energy in ' +part+' with CSC veto;Cell Energy [MeV];Cell Events',
@@ -302,7 +346,7 @@ def LArCellMonConfig(inputFlags):
     cellMonGroupPerJob = helper.addGroup(
         LArCellMonAlg,
         LArCellMonAlg.MonGroupName_perJob,
-        '/CaloMonitoring/LArCellMon_NoTrigSel/'
+        '/CaloMonitoring/LArCellMon_NoTrigSelNewAlg/'
     )
 
     LArCellMonAlg.doKnownBadChannelsVsEtaPhi = True
@@ -347,7 +391,7 @@ def LArCellMonConfig(inputFlags):
 
     #--- group array for threshold dependent histograms
     allMonArray = helper.addArray([LArCellMonAlg.LayerNames, LArCellMonAlg.ThresholdType], LArCellMonAlg, "allMon", 
-                                    "/CaloMonitoring/LArCellMon_NoTrigSel/")
+                                    "/CaloMonitoring/LArCellMon_NoTrigSelNewAlg/")
 
 
     #now histograms
@@ -439,9 +483,6 @@ def LArCellMonConfig(inputFlags):
                                 treedef='sporadicCellE/F:sporadicCellTime/F:sporadicCellQuality/s:sporadicCellID/l:lumiBlock/i')
 
 
-    cfg.merge(helper.result())
-    return cfg
-    
 
 if __name__=='__main__':
 
diff --git a/Calorimeter/CaloMonitoring/share/CaloNewMonitoring_jobOptions.py b/Calorimeter/CaloMonitoring/share/CaloNewMonitoring_jobOptions.py
new file mode 100644
index 00000000000..eef7a0d5f28
--- /dev/null
+++ b/Calorimeter/CaloMonitoring/share/CaloNewMonitoring_jobOptions.py
@@ -0,0 +1,12 @@
+# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
+
+include.block("CaloMonitoring/CaloNewMonitoring_jobOptions.py")
+
+#Create the set of flags
+from AthenaMonitoring.DQMonFlags import DQMonFlags
+
+
+if DQMonFlags.monManEnvironment() != 'AOD':
+  from CaloMonitoring.LArCellMonAlg import LArCellMonConfigOld
+  topSequence += LArCellMonConfigOld(DQMonFlags)
+
diff --git a/Calorimeter/CaloMonitoring/src/CaloBaselineMonAlg.cxx b/Calorimeter/CaloMonitoring/src/CaloBaselineMonAlg.cxx
index 9d726abcf0c..499704b28c0 100644
--- a/Calorimeter/CaloMonitoring/src/CaloBaselineMonAlg.cxx
+++ b/Calorimeter/CaloMonitoring/src/CaloBaselineMonAlg.cxx
@@ -34,10 +34,9 @@ StatusCode CaloBaselineMonAlg::initialize() {
 
   StatusCode sc = m_bunchCrossingTool.retrieve();
   if (sc.isFailure()) {
-    ATH_MSG_ERROR( "Unable to retrieve bunchCrossingTool. Switch off CaloBaselineMon" );
+    ATH_MSG_WARNING( "Unable to retrieve bunchCrossingTool. Switch off CaloBaselineMon" );
     m_pedestalMon_BCIDmin = -1;
     m_bcidtoolMon_BCIDmax = -1; 
-    return sc;
   }
 
   if (m_pedestalMon_BCIDmin > 0) m_bool_pedestalMon = true;
diff --git a/Control/AthenaMonitoring/share/DataQualitySteering_jobOptions.py b/Control/AthenaMonitoring/share/DataQualitySteering_jobOptions.py
index 783cbad9b3d..e26b8959944 100644
--- a/Control/AthenaMonitoring/share/DataQualitySteering_jobOptions.py
+++ b/Control/AthenaMonitoring/share/DataQualitySteering_jobOptions.py
@@ -142,6 +142,7 @@ if DQMonFlags.doMonitoring():
    if DQMonFlags.doCaloMon():
       try:
          include("CaloMonitoring/CaloAllMonitoring_jobOptions.py")
+         include("CaloMonitoring/CaloNewMonitoring_jobOptions.py")
       except Exception:
          treatException("DataQualitySteering_jobOptions.py: exception when setting up Calo monitoring")
 
diff --git a/LArCalorimeter/LArClusterRec/python/LArClusterCollisionTimeConfig.py b/LArCalorimeter/LArClusterRec/python/LArClusterCollisionTimeConfig.py
new file mode 100644
index 00000000000..ab3af9ab737
--- /dev/null
+++ b/LArCalorimeter/LArClusterRec/python/LArClusterCollisionTimeConfig.py
@@ -0,0 +1,17 @@
+# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
+
+# python fragment to configure LAr cluster collision time algo
+
+from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
+from AthenaConfiguration.ComponentFactory import CompFactory
+
+def LArClusterCollisionTimeCfg(configFlags):
+
+   result=ComponentAccumulator()
+
+   LArClusterCollisionTimeAlg=CompFactory.LArClusterCollisionTimeAlg
+   result.addEventAlgo(LArClusterCollisionTimeAlg("LArClusterCollisionTimeAlg", 
+                                                  OutputName="ClusterCollTime",InputName="LArClusterEM"))
+
+   return result   
+
diff --git a/LArCalorimeter/LArMonitoring/python/LArCollisionTimeMonAlg.py b/LArCalorimeter/LArMonitoring/python/LArCollisionTimeMonAlg.py
index 5804bce3526..8f45137d261 100644
--- a/LArCalorimeter/LArMonitoring/python/LArCollisionTimeMonAlg.py
+++ b/LArCalorimeter/LArMonitoring/python/LArCollisionTimeMonAlg.py
@@ -6,9 +6,16 @@ def LArCollisionTimeMonConfigOld(inputFlags):
     from AthenaMonitoring.AthMonitorCfgHelper import AthMonitorCfgHelperOld
     from LArMonitoring.LArMonitoringConf import LArCollisionTimeMonAlg
     
+    larColTime_hist_path='LArCollisionTimeNewAlg'
 
     helper = AthMonitorCfgHelperOld(inputFlags, 'LArCollisionTimeMonAlgOldCfg')
-    LArCollisionTimeMonConfigCore(helper, LArCollisionTimeMonAlg,inputFlags)
+    LArCollisionTimeMonConfigCore(helper, LArCollisionTimeMonAlg,inputFlags,larColTime_hist_path)
+
+    larColTime_hist_path='LArClusterCollisionTimeNewAlg'
+    LArCollisionTimeMonConfigCore(helper, LArCollisionTimeMonAlg,inputFlags,larColTime_hist_path)
+    helper.monSeq.LArClusterCollisionTimeMonAlg.Key = "ClusterCollTime"
+    helper.monSeq.LArClusterCollisionTimeMonAlg.nCells = 0
+
     return helper.result()
 
 def LArCollisionTimeMonConfig(inputFlags):
@@ -22,16 +29,25 @@ def LArCollisionTimeMonConfig(inputFlags):
     from LArCellRec.LArCollisionTimeConfig import LArCollisionTimeCfg
     cfg = LArCollisionTimeCfg(inputFlags)
 
+    larColTime_hist_path='LArCollisionTimeNewAlg'
+
     from AthenaConfiguration.ComponentFactory import CompFactory
-    LArCollisionTimeMonConfigCore(helper, CompFactory.LArCollisionTimeMonAlg,inputFlags)
+    LArCollisionTimeMonConfigCore(helper, CompFactory.LArCollisionTimeMonAlg,inputFlags,larColTime_hist_path)
+
+    larClusColTime_hist_path='LArClusterCollisionTimeNewAlg'
+    LArCollisionTimeMonConfigCore(helper, CompFactory.LArCollisionTimeMonAlg('LArClusterCollisionTimeMonAlg'),inputFlags,larClusColTime_hist_path)
+    for algo in helper.monSeq.Members:
+       if algo.name == 'LArClusterCollisionTimeMonAlg':
+           algo.Key = "ClusterCollTime"
+           algo.nCells = 0
 
     cfg.merge(helper.result())
     return cfg
 
-def LArCollisionTimeMonConfigCore(helper, algoinstance,inputFlags):
+def LArCollisionTimeMonConfigCore(helper, algoinstance,inputFlags,larColTime_hist_path):
 
 
-    larCollTimeMonAlg = helper.addAlgorithm(algoinstance,'larCollTimeMonAlg')
+    larCollTimeMonAlg = helper.addAlgorithm(algoinstance,larColTime_hist_path[0:-6]+'MonAlg')
 
 
     collTimeGroupName="LArCollisionTimeMonGroup"
@@ -53,7 +69,6 @@ def LArCollisionTimeMonConfigCore(helper, algoinstance,inputFlags):
     from LArMonitoring.GlobalVariables import lArDQGlobals
 
 
-    larColTime_hist_path='LArCollisionTimeNewAlg/'
     timeUnitName='ps'
     if timeUnit == Units.nanosecond:
         timeUnitName='ns'
@@ -256,15 +271,23 @@ if __name__=='__main__':
     from LArCellRec.LArCollisionTimeConfig import LArCollisionTimeCfg
     cfg.merge(LArCollisionTimeCfg(ConfigFlags))
     cfg.getEventAlgo("LArCollisionTimeAlg").cutIteration=False
+    # add cluster collision time algo
+    # cluster config is still missing
+    #from LArClusterRec.LArClusterSwConfig import LArClusterSwConfig
+    #cfg.merge(LArClusterSwConfig(ConfigFlags))
+    from LArClusterRec.LArClusterCollisionTimeConfig import LArClusterCollisionTimeCfg
+    cfg.merge(LArClusterCollisionTimeCfg(ConfigFlags))
 
     from LumiBlockComps.BunchCrossingCondAlgConfig import BunchCrossingCondAlgCfg
     cfg.merge(BunchCrossingCondAlgCfg(ConfigFlags))
 
     import AthenaCommon.SystemOfUnits as Units
     collmon=LArCollisionTimeMonConfig(ConfigFlags)
-    collmon.getEventAlgo("larCollTimeMonAlg").timeDiffCut=5.0*Units.nanosecond
-    collmon.getEventAlgo("larCollTimeMonAlg").nCells=1
-    collmon.getEventAlgo("larCollTimeMonAlg").TrainFrontDistance=int(30*Units.nanosecond)
+    collmon.getEventAlgo("LArCollisionTimeMonAlg").timeDiffCut=5.0*Units.nanosecond
+    collmon.getEventAlgo("LArCollisionTimeMonAlg").nCells=1
+    collmon.getEventAlgo("LArCollisionTimeMonAlg").TrainFrontDistance=int(30*Units.nanosecond)
+    collmon.getEventAlgo("LArClusterCollisionTimeMonAlg").nCells=0
+    collmon.getEventAlgo("LArClusterCollisionTimeMonAlg").TrainFrontDistance=int(30*Units.nanosecond)
     cfg.merge(collmon) 
 
     ConfigFlags.dump()
diff --git a/LArCalorimeter/LArMonitoring/python/LArDigitMonAlg.py b/LArCalorimeter/LArMonitoring/python/LArDigitMonAlg.py
index 2a1fef90b09..a9e1abd40f6 100644
--- a/LArCalorimeter/LArMonitoring/python/LArDigitMonAlg.py
+++ b/LArCalorimeter/LArMonitoring/python/LArDigitMonAlg.py
@@ -2,7 +2,7 @@
 #
 #  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
 #
-def LArDigitMonConfigOld(inputFlags, topSequence):
+def LArDigitMonConfigOld(inputFlags):
     from AthenaMonitoring.AthMonitorCfgHelper import AthMonitorCfgHelperOld
     from LArMonitoring.LArMonitoringConf import LArDigitMonAlg
 
diff --git a/LArCalorimeter/LArMonitoring/share/LArMonitoring_jobOption.py b/LArCalorimeter/LArMonitoring/share/LArMonitoring_jobOption.py
index 6eeca6d65fc..22a18d270a6 100644
--- a/LArCalorimeter/LArMonitoring/share/LArMonitoring_jobOption.py
+++ b/LArCalorimeter/LArMonitoring/share/LArMonitoring_jobOption.py
@@ -6,11 +6,12 @@ from AthenaMonitoring.DQMonFlags import DQMonFlags
 from AthenaCommon.GlobalFlags import globalflags
 
 #Add colltime algo to sequence
+print "LArMonitoring_jobOption ", DQMonFlags.monManEnvironment()
 
 from LumiBlockComps.BunchCrossingCondAlgDefault import BunchCrossingCondAlgDefault
 BunchCrossingCondAlgDefault()
 
-if DQMonFlags.monManEnvironment() == 'tier0ESD':
+if 'ESD' not in DQMonFlags.monManEnvironment():
     include ("LArCellRec/LArCollisionTime_jobOptions.py")
     from LArMonitoring.LArCollisionTimeMonAlg import LArCollisionTimeMonConfigOld
     topSequence +=LArCollisionTimeMonConfigOld(DQMonFlags)
@@ -18,7 +19,7 @@ if DQMonFlags.monManEnvironment() == 'tier0ESD':
         from LArMonitoring.LArAffectedRegionsAlg import LArAffectedRegionsConfigOld
         topSequence +=LArAffectedRegionsConfigOld(DQMonFlags)
 
-if DQMonFlags.monManEnvironment() == 'tier0Raw':
+if 'ESD' not in DQMonFlags.monManEnvironment():
     from LArMonitoring.LArNoisyROMonAlg import LArNoisyROMonConfigOld
     topSequence += LArNoisyROMonConfigOld(DQMonFlags)
 
@@ -26,9 +27,9 @@ if globalflags.DataSource == 'data':
     from LArMonitoring.LArHVCorrMonAlg import LArHVCorrMonConfigOld
     topSequence += LArHVCorrMonConfigOld(DQMonFlags)
 
-if DQMonFlags.monManEnvironment() == 'tier0Raw' and globalflags.DataSource == 'data':
+if 'ESD' not in DQMonFlags.monManEnvironment() and globalflags.DataSource == 'data':
     from LArMonitoring.LArDigitMonAlg import LArDigitMonConfigOld
-    topSequence +=LArDigitMonConfigOld(DQMonFlags, topSequence)
+    topSequence +=LArDigitMonConfigOld(DQMonFlags)
 
     from LArMonitoring.LArRODMonAlg import LArRODMonConfigOld
     topSequence +=LArRODMonConfigOld(DQMonFlags)
-- 
GitLab