From b0ccad8591a4045db257cb7bc329ce8f29297bed Mon Sep 17 00:00:00 2001
From: Peter Onyisi <ponyisi@utexas.edu>
Date: Tue, 20 Sep 2016 16:10:35 +0200
Subject: [PATCH] Reintegration of 02-02-00-branch (AthenaMonitoring-02-03-04)

	* Reintegration of 02-02-00-branch (changelogs below)
	* Tag AthenaMonitoring-02-03-04

2016-09-08 Peter Onyisi <ponyisi AT cern.ch>
	* Enable HI monitoring for HIP runs
	* Tag AthenaMonitoring-02-02-00-08

2016-08-11 Peter Onyisi <ponyisi AT cern.ch>
	* Enable pixel monitoring in ZeroBias obo Yosuke Takubo
	* Tag AthenaMonitoring-02-02-00-07

2016-06-21 Peter Onyisi <ponyisi AT cern.ch>
	* Fix ATLASRECTS-3216
	* Other changes obo Benjamin Trocme
	* Tag AthenaMonitoring-02-02-00-06

2016-06-20 Peter Onyisi <ponyisi AT cern.ch>
	* Enable plot X axis extension when plot is vs LB (only TH1 derivatives)
	* Fix bug in histogram output areas when LB is skipped
	* Actually switch TDT to global instance
...
(Long ChangeLog diff - truncated)


Former-commit-id: eef3609de1c06b6d59eca188818092ceaaaa462e
---
 .../AthenaMonitoring/AthenaMonManager.h       |   2 +-
 .../AthenaMonitoring/ManagedMonitorToolBase.h |   7 +-
 Control/AthenaMonitoring/python/DQMonFlags.py |   4 +-
 .../share/AtlasReadyFilterTool_jobOptions.py  |   2 +
 .../share/DQMonFlagsConfig_jobOptions.py      |  94 +++++++--
 .../share/DataQualitySteering_jobOptions.py   |  13 +-
 .../share/TrigDecTool_jobOptions.py           |   5 +-
 Control/AthenaMonitoring/src/AthenaMon.cxx    |  38 ++--
 .../AthenaMonitoring/src/AthenaMonManager.cxx | 132 ++++++------
 .../src/FastPhysMonToolBase.cxx               |  10 +-
 .../src/ManagedMonitorToolBase.cxx            | 188 +++++++++++-------
 .../AthenaMonitoring/src/MonitorToolBase.cxx  |  24 +--
 12 files changed, 309 insertions(+), 210 deletions(-)

diff --git a/Control/AthenaMonitoring/AthenaMonitoring/AthenaMonManager.h b/Control/AthenaMonitoring/AthenaMonitoring/AthenaMonManager.h
index 5241118f473..32160adfd4d 100755
--- a/Control/AthenaMonitoring/AthenaMonitoring/AthenaMonManager.h
+++ b/Control/AthenaMonitoring/AthenaMonitoring/AthenaMonManager.h
@@ -45,7 +45,7 @@ class AthenaMonManager : public AthAlgorithm {
        * transform or during the ESD --> AOD transform (but not both!)
        * Strings of the same names may be given as jobOptions.
        */
-      enum Environment_t { user = 0, noOutput, online, tier0, tier0Raw, tier0ESD, altprod, AOD };
+      enum Environment_t { user = 0, noOutput, online, tier0, tier0Raw, tier0ESD, AOD, altprod };
 
       /**
        * An enumeration of the different types of data the
diff --git a/Control/AthenaMonitoring/AthenaMonitoring/ManagedMonitorToolBase.h b/Control/AthenaMonitoring/AthenaMonitoring/ManagedMonitorToolBase.h
index f52e5eacd82..f9b94b5e255 100755
--- a/Control/AthenaMonitoring/AthenaMonitoring/ManagedMonitorToolBase.h
+++ b/Control/AthenaMonitoring/AthenaMonitoring/ManagedMonitorToolBase.h
@@ -791,17 +791,21 @@ class ManagedMonitorToolBase : public AthAlgTool, virtual public IMonitorToolBas
          public:
         OfflineStream( const std::string& fileKey, AthenaMonManager::DataType_t /*dataType*/,
                        AthenaMonManager::Environment_t /*environment*/ )
-               : m_fileKey(fileKey) { }
+               : m_fileKey(fileKey),
+                 m_prev_run_number(0),
+                 m_prev_lumi_block(0) { }
 
             virtual ~OfflineStream() { }
             virtual std::string getStreamName( const ManagedMonitorToolBase* tool, const MonGroup& group, const std::string& objName, bool usePreviousInterval=false );
             virtual std::string getDirectoryName( const ManagedMonitorToolBase* tool, const MonGroup& group, const std::string& objName, const bool usePreviousInterval );
+	    void updateRunLB();
 
          private:
             OfflineStream() { }
             const std::string                m_fileKey;
             //AthenaMonManager::DataType_t     m_dataType;
             //AthenaMonManager::Environment_t  m_environment;
+            uint32_t m_prev_run_number, m_prev_lumi_block;
             std::set<std::string> m_ebNames;
             void getLBrange(int*,int*,int,int);
       };
@@ -920,6 +924,7 @@ protected:
       bool m_hasRetrievedLumiTool;
       bool m_bookHistogramsInitial;
       bool m_useLumi;
+      float m_defaultLBDuration;
       //int m_cycleNum;
       std::set<Interval_t> m_supportedIntervalsForRebooking;
 
diff --git a/Control/AthenaMonitoring/python/DQMonFlags.py b/Control/AthenaMonitoring/python/DQMonFlags.py
index 161a246c517..8e600e918b4 100644
--- a/Control/AthenaMonitoring/python/DQMonFlags.py
+++ b/Control/AthenaMonitoring/python/DQMonFlags.py
@@ -234,7 +234,7 @@ class doStreamAwareMon(JobProperty):
     """ Switch for stream-aware monitoring """
     statusOn=True
     allowedTypes=['bool']
-    StoredValue=False
+    StoredValue=True
 list+=[doStreamAwareMon]
 
 class monType(JobProperty):
@@ -353,7 +353,7 @@ class nameTrigDecTool(JobProperty):
     """ name of trigger decision tool """
     statusOn     = True
     allowedTypes = ['str']
-    StoredValue  = 'monTrigDecTool'
+    StoredValue  = 'TrigDecisionTool'
 list+=[nameTrigDecTool]
 
 class nameTrigTransTool(JobProperty):
diff --git a/Control/AthenaMonitoring/share/AtlasReadyFilterTool_jobOptions.py b/Control/AthenaMonitoring/share/AtlasReadyFilterTool_jobOptions.py
index c05eacabd4e..8ec92fcebbe 100644
--- a/Control/AthenaMonitoring/share/AtlasReadyFilterTool_jobOptions.py
+++ b/Control/AthenaMonitoring/share/AtlasReadyFilterTool_jobOptions.py
@@ -1,3 +1,5 @@
+include.block('AthenaMonitoring/AtlasReadyFilterTool_jobOptions.py')
+
 # Set up the ATLAS Ready filter tool
 from AthenaCommon.Logging import logging
 
diff --git a/Control/AthenaMonitoring/share/DQMonFlagsConfig_jobOptions.py b/Control/AthenaMonitoring/share/DQMonFlagsConfig_jobOptions.py
index 6e0258c0d3c..df9728e0a04 100644
--- a/Control/AthenaMonitoring/share/DQMonFlagsConfig_jobOptions.py
+++ b/Control/AthenaMonitoring/share/DQMonFlagsConfig_jobOptions.py
@@ -23,7 +23,7 @@ if rec.doTrigger() == False:
 # Set the data type based on beamType/HI flag
 if globalflags.DataSource.get_Value() == 'geant4':
    DQMonFlags.monManDataType = 'monteCarlo'
-elif rec.doHeavyIon():
+elif (rec.doHeavyIon() or rec.doHIP()):
    DQMonFlags.monManDataType = 'heavyioncollisions'
    DQMonFlags.doHIMon = True
 elif jobproperties.Beam.beamType()   == 'cosmics':
@@ -145,6 +145,7 @@ else:
       DQMonFlags.doMuonCombinedMon=False
       DQMonFlags.doLucidMon=False
       DQMonFlags.doJetTagMon=False
+      DQMonFlags.doJetMon=False
       
    # switch off monitoring if reco is off during BS reading
    if rec.readRDO() and not 'DetFlags' in dir():
@@ -259,17 +260,53 @@ if DQMonFlags.doStreamAwareMon:
    # So set them as false by default. Turn them on as needed
    LArMonFlags.doLArRODMonTool=False            # savannah bug report #83390
    LArMonFlags.doLArRawMonitorSignal=False
+   LArMonFlags.doLArRawChannelMon=False
+   LArMonFlags.doLArCollisionTimeMon=False
+   LArMonFlags.doLArAffectedRegions=False
+   LArMonFlags.doLArHVCorrectionMonTool=False
+   LArMonFlags.doLArCoverage=False
+   doCaloCellVecMon=False
+
+   # The following are ON except for certain streams
+   LArMonFlags.doLArDigitMon=True
+   LArMonFlags.doLArNoisyROMon=True
 
    # All monitoring turned on for express stream (except LArRawChannelMon)
    # HIP runs will use the express settings for MinBias, MinBiasOverlay, HardProbes, bulk, and UPC
-   if (rec.triggerStream()=='express' or 
+   if (rec.triggerStream()=='express' or rec.triggerStream()=='Main' or
        (rec.doHIP() and rec.triggerStream() in ['MinBias', 'MinBiasOverlay', 'HardProbes', 'bulk', 'UPC'])):
-      LArMonFlags.doLArRawChannelMon=False
+      LArMonFlags.doLArCollisionTimeMon=True
+      LArMonFlags.doLArAffectedRegions=True
+      LArMonFlags.doLArHVCorrectionMonTool=True
+      LArMonFlags.doLArCoverage=True
       LArMonFlags.doLArRODMonTool=True          # savannah bug report #83390
+      if (rec.triggerStream()=='express' or rec.triggerStream()=='Main'):
+         doCaloCellVecMon=True
 
    elif (rec.triggerStream()=='CosmicCalo'):
+      LArMonFlags.doLArRawChannelMon=True
       LArMonFlags.doLArRawMonitorSignal=True
+      LArMonFlags.doLArAffectedRegions=True
+      LArMonFlags.doLArHVCorrectionMonTool=True
+      LArMonFlags.doLArCoverage=True
+      LArMonFlags.doLArDigitMon=False
+      doCaloCellVecMon=True
       HLTMonFlags.doBjet=False
+      HLTMonFlags.doEgamma=False
+      HLTMonFlags.doTau=False
+      HLTMonFlags.doJet=False
+      HLTMonFlags.doCalo=False
+      HLTMonFlags.doMuon=False
+      DQMonFlags.doTauMon=False
+      DQMonFlags.doPixelMon=False
+      DQMonFlags.doMuonRawMon=False
+      DQMonFlags.doMuonTrackMon=False
+      DQMonFlags.doMuonAlignMon=False
+      DQMonFlags.doMuonCombinedMon=False
+      DQMonFlags.doMuonSegmentMon=False
+      DQMonFlags.doMuonPhysicsMon=False
+      DQMonFlags.doMuonTrkPhysMon=False
+      DQMonFlags.doTRTMon=False
       DQMonFlags.doJetTagMon=False
    elif (rec.triggerStream()=='JetTauEtmiss'):
       DQMonFlags.doEgammaMon=False
@@ -334,16 +371,10 @@ if DQMonFlags.doStreamAwareMon:
       DQMonFlags.doMuonPhysicsMon=False
       DQMonFlags.doCaloMon=False
       DQMonFlags.doJetTagMon=False
-      LArMonFlags.doLArRawChannelMon=False
-      LArMonFlags.doLArCollisionTimeMon=False
-      LArMonFlags.doLArAffectedRegions=False
       #LArMonFlags.doLArFEBMon=False
-      LArMonFlags.doLArHVCorrectionMonTool=False
-      LArMonFlags.doLArCoverage=False
-      LArMonFlags.doLArDigitMon=False
-      LArMonFlags.doLArNoisyROMon=False
+      #LArMonFlags.doLArDigitMon=False
+      #LArMonFlags.doLArNoisyROMon=False
    elif (rec.triggerStream()=='ZeroBias'):
-      DQMonFlags.doEgammaMon=False
       DQMonFlags.doTauMon=False
       HLTMonFlags.doBjet=False
       HLTMonFlags.doEgamma=False
@@ -351,7 +382,7 @@ if DQMonFlags.doStreamAwareMon:
       HLTMonFlags.doJet=False
       HLTMonFlags.doCalo=False
       HLTMonFlags.doMuon=False
-      DQMonFlags.doPixelMon=False
+      DQMonFlags.doPixelMon=True
       DQMonFlags.doMuonRawMon=False
       DQMonFlags.doMuonTrackMon=False
       DQMonFlags.doMuonAlignMon=False
@@ -361,19 +392,34 @@ if DQMonFlags.doStreamAwareMon:
       DQMonFlags.doMuonTrkPhysMon=False
       DQMonFlags.doTRTMon=False
       DQMonFlags.doJetTagMon=False
-      LArMonFlags.doLArRawChannelMon=False
-      LArMonFlags.doLArCollisionTimeMon=False
-      LArMonFlags.doLArAffectedRegions=False
+      #LArMonFlags.doLArRawChannelMon=False
+      #LArMonFlags.doLArCollisionTimeMon=False
+      #LArMonFlags.doLArAffectedRegions=False
       #LArMonFlags.doLArFEBMon=False
-      LArMonFlags.doLArHVCorrectionMonTool=False
-      LArMonFlags.doLArCoverage=False
-      LArMonFlags.doLArDigitMon=False
-      LArMonFlags.doLArNoisyROMon=False
-      LArMonFlags.doLArRODMonTool=True          # savannah bug report #83390
+      #LArMonFlags.doLArHVCorrectionMonTool=False
+      #LArMonFlags.doLArCoverage=False
+      #LArMonFlags.doLArDigitMon=False
+      #LArMonFlags.doLArNoisyROMon=False
+      #LArMonFlags.doLArRODMonTool=True          # savannah bug report #83390
+
+   elif (rec.triggerStream()=='L1Calo' or rec.triggerStream()=='L1Topo'):
+      HLTMonFlags.doBjet=False
+      HLTMonFlags.doMuon=False
+      DQMonFlags.doPixelMon=False
+      DQMonFlags.doMuonRawMon=False
+      DQMonFlags.doMuonTrackMon=False
+      DQMonFlags.doMuonAlignMon=False
+      DQMonFlags.doMuonCombinedMon=False
+      DQMonFlags.doMuonSegmentMon=False
+      DQMonFlags.doMuonPhysicsMon=False
+      DQMonFlags.doMuonTrkPhysMon=False
+      DQMonFlags.doTRTMon=False
+      DQMonFlags.doJetTagMon=False
 
    # Default stream-aware settings for unspecified streams
    # Only run a select few set of tools
    else:
+      #LArMonFlags.doLArRawChannelMon=False
       DQMonFlags.doEgammaMon=False
       DQMonFlags.doJetMon=False
       DQMonFlags.doMissingEtMon=False
@@ -392,8 +438,12 @@ if DQMonFlags.doStreamAwareMon:
 else:
    local_logger.info("Stream-Aware monitoring is turned OFF")
 
-# disabled until further notice 20140401 - PUEO
-# DQMonFlags.doMuonRawMon=False
+# If data type is '*comm' disable ATLAS Ready filter by default
+if (rec.projectName.get_Value().endswith('_comm') and 
+    not DQMonFlags.disableAtlasReadyFilter()
+    ):
+   local_logger.info("This is a commissioning project tag, will attempt to disable ATLAS Ready filter for monitoring tools. To really enable it, use DQMonFlags.disableAtlasReadyFilter.set_Value_and_Lock(False).")
+   DQMonFlags.disableAtlasReadyFilter=True
 
 DQMonFlags.lock_JobProperties()
 DQMonFlags.print_JobProperties()
diff --git a/Control/AthenaMonitoring/share/DataQualitySteering_jobOptions.py b/Control/AthenaMonitoring/share/DataQualitySteering_jobOptions.py
index 1f80b7d5685..cac005f471c 100644
--- a/Control/AthenaMonitoring/share/DataQualitySteering_jobOptions.py
+++ b/Control/AthenaMonitoring/share/DataQualitySteering_jobOptions.py
@@ -4,7 +4,7 @@
 # $Id: DataQualitySteering_jobOptions.py,v 1.15 2009-05-05 08:20:08 sschaetz Exp $
 # ********************************************************************************
 
-# disable InDetPerformanceMonitoring, JetMonitoring until further notice 
+# disable TRTEleMon until further notice
 # - PUEO 20140401
 TRTELEMON=False
 
@@ -248,19 +248,22 @@ if DQMonFlags.doMonitoring():
    local_logger.debug('DQ Post-Setup Configuration')
    for tool in monToolSet_after-monToolSet_before:
       # stop lumi access if we're in MC or enableLumiAccess == False
-      if globalflags.DataSource.get_Value() == 'geant4' or not DQMonFlags.enableLumiAccess():
-         if 'EnableLumi' in dir(tool):
+      if 'EnableLumi' in dir(tool):
+         if globalflags.DataSource.get_Value() == 'geant4' or not DQMonFlags.enableLumiAccess():
             tool.EnableLumi = False
+         else:
+            tool.EnableLumi = True
       # if we have the FilterTools attribute, assume this is in fact a
       # monitoring tool
       if hasattr(tool, 'FilterTools'):
          # if express: use ATLAS Ready filter
-         local_logger.warning('Processing for tool %s', tool)
+         local_logger.debug('Setting up filters for tool %s', tool)
          if rec.triggerStream()=='express':
-            local_logger.warning('Stream is express and we will add ready tool')
+            local_logger.info('Stream is express and we will add ready tool for %s', tool)
             tool.FilterTools += [monAtlasReadyFilterTool]
          # give all the tools the trigger translator
          if DQMonFlags.useTrigger():
+            tool.TrigDecisionTool = monTrigDecTool
             tool.TriggerTranslatorTool = monTrigTransTool
 
          if DQMonFlags.monToolPostExec():
diff --git a/Control/AthenaMonitoring/share/TrigDecTool_jobOptions.py b/Control/AthenaMonitoring/share/TrigDecTool_jobOptions.py
index 4933f86038e..3f329cd3a3c 100644
--- a/Control/AthenaMonitoring/share/TrigDecTool_jobOptions.py
+++ b/Control/AthenaMonitoring/share/TrigDecTool_jobOptions.py
@@ -20,7 +20,7 @@ if DQMonFlags.useTrigger():
          from TriggerJobOpts.TriggerConfigGetter import TriggerConfigGetter
          cfg = TriggerConfigGetter()
 
-   if not hasattr(ToolSvc, DQMonFlags.nameTrigDecTool()):
+   if not hasattr(ToolSvc, DQMonFlags.nameTrigDecTool().split('/')[-1]):
       from TrigDecisionTool.TrigDecisionToolConf import Trig__TrigDecisionTool
       monTrigDecTool = Trig__TrigDecisionTool(name=DQMonFlags.nameTrigDecTool(),
                                               OutputLevel=ERROR,
@@ -30,6 +30,9 @@ if DQMonFlags.useTrigger():
                                                                   }
                                              )
       ToolSvc += monTrigDecTool
+   else:
+      monTrigDecTool = getattr(ToolSvc, DQMonFlags.nameTrigDecTool().split('/')[-1])
+   tdt_local_logger.info('Scheduled monitoring TDT %s', monTrigDecTool)
 
    tdt_local_logger.info('Scheduling the trigger translator')
    # Look up all monitoring menu lists, shove into trigger translator
diff --git a/Control/AthenaMonitoring/src/AthenaMon.cxx b/Control/AthenaMonitoring/src/AthenaMon.cxx
index 1950ddbd555..0018033979d 100755
--- a/Control/AthenaMonitoring/src/AthenaMon.cxx
+++ b/Control/AthenaMonitoring/src/AthenaMon.cxx
@@ -45,14 +45,14 @@ StatusCode AthenaMon::initialize()
 /*---------------------------------------------------------------*/
 {
   MsgStream log(msgSvc(), name());
-  log << MSG::INFO << "initialize AthenaMon algorithm" << endreq;
+  log << MSG::INFO << "initialize AthenaMon algorithm" << endmsg;
 
   std::vector<std::string>::iterator it = m_monToolNames.begin();
   IToolSvc* p_toolSvc;
   StatusCode sc = service("ToolSvc",p_toolSvc);
 
   if (sc.isFailure()) {
-    log << MSG::FATAL << " Tool Service not found " << endreq;
+    log << MSG::FATAL << " Tool Service not found " << endmsg;
     return StatusCode::FAILURE;
   }
 
@@ -66,18 +66,18 @@ StatusCode AthenaMon::initialize()
     sc = p_toolSvc->retrieveTool(mytool.type(), mytool.name(), p_tool);
     if(sc.isFailure()) {
       log << MSG::FATAL << "Unable to create " << toolname
-	  << " AlgTool" << endreq;
+	  << " AlgTool" << endmsg;
       return StatusCode::FAILURE;
     } else {
       
       log << MSG::INFO
 	  << "Tool Name = " << toolname
-	  << endreq;
+	  << endmsg;
       
       sc = p_tool->setupOutputStreams(m_THistSvc_streamnameMapping);
       if(sc.isFailure()) {
 	log << MSG::WARNING << "Unable to setup the OutPutStreams in "
-	    << toolname << endreq;
+	    << toolname << endmsg;
       }
       
       // shall I book histograms now ?
@@ -87,7 +87,7 @@ StatusCode AthenaMon::initialize()
 	  // dynamic booking, it should define bookHists as empty.
 	  sc = p_tool->bookHists();
 	  if(sc.isFailure()) {
-	    log << MSG::WARNING << "Unable to book in " << toolname << endreq;
+	    log << MSG::WARNING << "Unable to book in " << toolname << endmsg;
 	  }
 	}
       m_monTools.push_back(p_tool);
@@ -102,7 +102,7 @@ StatusCode AthenaMon::execute()
 {
   MsgStream log(msgSvc(), name());
   
-  log << MSG::DEBUG << "executing AthenaMon algorithm" << endreq;
+  log << MSG::DEBUG << "executing AthenaMon algorithm" << endmsg;
   
   //Invoke all declared alg monitoring tools to fill their histograms
   std::vector<IMonitorToolBase*>::iterator it = m_monTools.begin();
@@ -110,7 +110,7 @@ StatusCode AthenaMon::execute()
   for (; it < m_monTools.end(); it++)  {
     if((*it)->preSelector())
       if((*it)->fillHists().isFailure())  {
-	log << MSG::WARNING << "Error Filling Histograms" << endreq;
+	log << MSG::WARNING << "Error Filling Histograms" << endmsg;
 	// return StatusCode::FAILURE;
       }
   }
@@ -119,10 +119,10 @@ StatusCode AthenaMon::execute()
     it = m_monTools.begin();
     
     for (; it < m_monTools.end(); it++)  {
-      log << MSG::INFO << "calling checkHists of tool " << endreq;
+      log << MSG::INFO << "calling checkHists of tool " << endmsg;
       StatusCode sc = (*it)->checkHists(false);
       if(sc.isFailure())  {
-	log << MSG::WARNING << "Can\'t call checkHists of tool." << endreq;
+	log << MSG::WARNING << "Can\'t call checkHists of tool." << endmsg;
 	// return StatusCode::FAILURE;
       }
     }
@@ -137,16 +137,16 @@ StatusCode AthenaMon::finalize()
 {
   MsgStream log(msgSvc(), name());
   
-  log << MSG::INFO << "finalizing AthenaMon algorithm" << endreq;
+  log << MSG::INFO << "finalizing AthenaMon algorithm" << endmsg;
   
   //Invoke all declared alg monitoring tools to finalize their histograms
   std::vector<IMonitorToolBase*>::iterator it = m_monTools.begin();
   
   for (; it < m_monTools.end(); it++)  {
-    log << MSG::INFO << "finalizing tool " << endreq;
+    log << MSG::INFO << "finalizing tool " << endmsg;
     StatusCode sc = (*it)->finalHists();
     if(sc.isFailure())  {
-      log << MSG::WARNING << "Can\'t finalize a tool." << endreq;
+      log << MSG::WARNING << "Can\'t finalize a tool." << endmsg;
       // return StatusCode::FAILURE;
     }
   }
@@ -154,10 +154,10 @@ StatusCode AthenaMon::finalize()
   it = m_monTools.begin();
   
   for (; it < m_monTools.end(); it++)  {
-    log << MSG::INFO << "calling checkHists of tool " << endreq;
+    log << MSG::INFO << "calling checkHists of tool " << endmsg;
     StatusCode sc = (*it)->checkHists(true);
     if(sc.isFailure())  {
-      log << MSG::WARNING << "Can\'t call checkHists of tool." << endreq;
+      log << MSG::WARNING << "Can\'t call checkHists of tool." << endmsg;
       // return StatusCode::FAILURE;
     }
   }
@@ -169,7 +169,7 @@ StatusCode AthenaMon::finalize()
 StatusCode AthenaMon::beginRun()
 {
   MsgStream log(msgSvc(), name());
-  log << MSG::INFO << "beginRun()" << endreq;
+  log << MSG::INFO << "beginRun()" << endmsg;
   
   // histograms already booked
   if(m_bookHistsinInitialize)
@@ -178,7 +178,7 @@ StatusCode AthenaMon::beginRun()
   std::vector<IMonitorToolBase*>::iterator it = m_monTools.begin();
   for (; it < m_monTools.end(); it++)
     if((*it)->bookHists().isFailure())
-      log << MSG::WARNING << "Error Filling Histograms" << endreq;
+      log << MSG::WARNING << "Error Filling Histograms" << endmsg;
   
   return StatusCode::SUCCESS;
 }
@@ -187,12 +187,12 @@ StatusCode AthenaMon::beginRun()
 StatusCode AthenaMon::endRun()
 {
   MsgStream log(msgSvc(), name());
-  log << MSG::INFO << "endRun()" << endreq;
+  log << MSG::INFO << "endRun()" << endmsg;
   
   std::vector<IMonitorToolBase*>::iterator it = m_monTools.begin();
   for (; it < m_monTools.end(); it++)
     if((*it)->runStat().isFailure())
-      log << MSG::WARNING << "Error calling runStat" << endreq;
+      log << MSG::WARNING << "Error calling runStat" << endmsg;
   
   return StatusCode::SUCCESS;
 }
diff --git a/Control/AthenaMonitoring/src/AthenaMonManager.cxx b/Control/AthenaMonitoring/src/AthenaMonManager.cxx
index 120be5cbe46..b4dcc0abe09 100755
--- a/Control/AthenaMonitoring/src/AthenaMonManager.cxx
+++ b/Control/AthenaMonitoring/src/AthenaMonManager.cxx
@@ -138,15 +138,15 @@ public:
         AthMonBench m_bench_algfin_convertLWHists;
         void report(AthenaMonManager*a) {
             MSG::Level l(AthMonBench::s_resourceMonThreshold);
-            a->msg(l)<<"Init ResourceSummary ["<<m_theTool->name()<<"] --> load/create/initialize : "<<m_bench_alginit_retrieve<<endreq;
+            a->msg(l)<<"Init ResourceSummary ["<<m_theTool->name()<<"] --> load/create/initialize : "<<m_bench_alginit_retrieve<<endmsg;
             m_bench_algexec_checkHists.setUnitCount();
             m_bench_algexec_bookHists.setUnitCount();
-            a->msg(l)<<"Exec ResourceSummary ["<<m_theTool->name()<<"] --> book : "<<m_bench_algexec_bookHists<<endreq;
-            a->msg(l)<<"Exec ResourceSummary ["<<m_theTool->name()<<"] --> check : "<<m_bench_algexec_checkHists<<endreq;
-            a->msg(l)<<"Exec ResourceSummary ["<<m_theTool->name()<<"] --> fill : "<<m_bench_algexec_fillHists<<endreq;
-            a->msg(l)<<"Fin ResourceSummary ["<<m_theTool->name()<<"] --> finalHists : "<<m_bench_algfin_finalHists<<endreq;
-            a->msg(l)<<"Fin ResourceSummary ["<<m_theTool->name()<<"] --> checkHists(fromFinalize==true) : "<<m_bench_algfin_checkHists<<endreq;
-            a->msg(l)<<"Fin ResourceSummary ["<<m_theTool->name()<<"] --> final LWHist conversion+writeout : "<<m_bench_algfin_convertLWHists<<endreq;
+            a->msg(l)<<"Exec ResourceSummary ["<<m_theTool->name()<<"] --> book : "<<m_bench_algexec_bookHists<<endmsg;
+            a->msg(l)<<"Exec ResourceSummary ["<<m_theTool->name()<<"] --> check : "<<m_bench_algexec_checkHists<<endmsg;
+            a->msg(l)<<"Exec ResourceSummary ["<<m_theTool->name()<<"] --> fill : "<<m_bench_algexec_fillHists<<endmsg;
+            a->msg(l)<<"Fin ResourceSummary ["<<m_theTool->name()<<"] --> finalHists : "<<m_bench_algfin_finalHists<<endmsg;
+            a->msg(l)<<"Fin ResourceSummary ["<<m_theTool->name()<<"] --> checkHists(fromFinalize==true) : "<<m_bench_algfin_checkHists<<endmsg;
+            a->msg(l)<<"Fin ResourceSummary ["<<m_theTool->name()<<"] --> final LWHist conversion+writeout : "<<m_bench_algfin_convertLWHists<<endmsg;
         }
 
     };
@@ -234,12 +234,12 @@ AthenaMonManager::
 ~AthenaMonManager()
 {
     if (m_d->m_nActiveLWHists)
-        msg(MSG::WARNING) << m_d->m_nActiveLWHists<< " LW histograms were created but never deleted" << endreq;
+        msg(MSG::WARNING) << m_d->m_nActiveLWHists<< " LW histograms were created but never deleted" << endmsg;
     /*
     if (m_d->m_nMonGroupCopies)
       msg(MSG::WARNING) << "Usage of MonGroup copy constructor or assignment operator detected in associated tools "
     	      << m_d->m_nMonGroupCopies<<" time(s). This usually happens when tools pass MonGroup's around by"
-    	      <<" value. This behaviour will be forbidden at the compilation stage soon, so please fix your packages!" << endreq;
+    	      <<" value. This behaviour will be forbidden at the compilation stage soon, so please fix your packages!" << endmsg;
     */
     delete m_d;
 
@@ -277,7 +277,7 @@ envStringToEnum( const std::string& str )
         if( sc.isSuccess() ) {
             MsgStream log( ms, "AthenaMonManager::envStringToEnum()" );
             log << MSG::WARNING << "Unknown AthenaMonManager::Environment_t \""
-                << str << "\", returning \"user\"" << endreq;
+                << str << "\", returning \"user\"" << endmsg;
         }
     }
 
@@ -308,7 +308,7 @@ dataTypeStringToEnum( const std::string& str )
         if( sc.isSuccess() ) {
             MsgStream log( ms, "AthenaMonManager::dataTypeStringToEnum()" );
             log << MSG::WARNING << "Unknown AthenaMonManager::DataType_t \""
-                << str << "\", returning \"userDefined\"" << endreq;
+                << str << "\", returning \"userDefined\"" << endmsg;
         }
     }
 
@@ -374,7 +374,7 @@ initialize()
     //typedef std::vector<IMonitorToolBase*> MonList_t;
     //typedef MonList_t::iterator            MonIter_t;
 
-    if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "AthenaMonManager::initialize():" << endreq;
+    if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "AthenaMonManager::initialize():" << endmsg;
 
     if (Imp::s_svcLocator->service("SGAudSvc", m_d->m_sgAudSvc, false/*do not create*/).isFailure())
         m_d->m_sgAudSvc=0;
@@ -387,15 +387,15 @@ initialize()
 
     sc = service( "THistSvc", m_THistSvc, true );
     if( !sc.isSuccess() ) {
-        msg(MSG::ERROR) << "!! Unable to locate the THistSvc service !!" << endreq;
+        msg(MSG::ERROR) << "!! Unable to locate the THistSvc service !!" << endmsg;
         return sc;
     }
 
     if( !Imp::s_staticDataAreInit ) {
-        if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "  --> Initializing static data" << endreq;
+        if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "  --> Initializing static data" << endmsg;
 
         if (msgLvl(MSG::DEBUG)) {
-            msg(MSG::DEBUG) << "      * \"ManualDataTypeSetup\" = " << m_d->m_manualDataTypeSetupProp << endreq;
+            msg(MSG::DEBUG) << "      * \"ManualDataTypeSetup\" = " << m_d->m_manualDataTypeSetupProp << endmsg;
         }
 
 #if 0  // The two branches of the conditional are identical.
@@ -410,35 +410,35 @@ initialize()
             Imp::s_dataType = dataTypeStringToEnum( m_d->m_dataTypeProp );
         }
 
-        if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "      * \"DataType\" = " << Imp::s_dataType << endreq;
+        if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "      * \"DataType\" = " << Imp::s_dataType << endmsg;
 
         Imp::s_environmentStr = m_d->m_environmentProp;
         Imp::s_environment = envStringToEnum( m_d->m_environmentProp );
 
-        if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "      * \"Environment\" = " << Imp::s_environment << endreq;
+        if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "      * \"Environment\" = " << Imp::s_environment << endmsg;
 
         Imp::s_LBsLowStat = m_d->m_LBsLowStatProp;
         Imp::s_LBsMedStat = m_d->m_LBsMedStatProp;
         Imp::s_LBsHigStat = m_d->m_LBsHigStatProp;
         if (msgLvl(MSG::DEBUG)) {
-            msg(MSG::DEBUG) << "      * \"LBsInLowStatInterval\" = " << Imp::s_LBsLowStat << endreq;
-            msg(MSG::DEBUG) << "      * \"LBsInMediumStatInterval\" = " << Imp::s_LBsMedStat << endreq;
-            msg(MSG::DEBUG) << "      * \"LBsInHighStatInterval\" = " << Imp::s_LBsHigStat << endreq;
+            msg(MSG::DEBUG) << "      * \"LBsInLowStatInterval\" = " << Imp::s_LBsLowStat << endmsg;
+            msg(MSG::DEBUG) << "      * \"LBsInMediumStatInterval\" = " << Imp::s_LBsMedStat << endmsg;
+            msg(MSG::DEBUG) << "      * \"LBsInHighStatInterval\" = " << Imp::s_LBsHigStat << endmsg;
         }
 
         m_d->m_isPrimaryManager = true;
         Imp::s_staticDataAreInit = true;
 
-        if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "      * \"ManualRunLBSetup\" = " << m_d->m_manualRunLBProp << endreq;
+        if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "      * \"ManualRunLBSetup\" = " << m_d->m_manualRunLBProp << endmsg;
 
         if( m_d->m_manualRunLBProp ) {
             Imp::s_run = m_d->m_runProp;
             Imp::s_lumiBlock = m_d->m_lumiBlockProp;
             if (msgLvl(MSG::DEBUG))
-                msg(MSG::DEBUG) << "          --> using run = " << Imp::s_run << ", lumiBlock = " << Imp::s_lumiBlock << endreq;
+                msg(MSG::DEBUG) << "          --> using run = " << Imp::s_run << ", lumiBlock = " << Imp::s_lumiBlock << endmsg;
         } else {
             if (msgLvl(MSG::DEBUG))
-                msg(MSG::DEBUG) << "          --> using run = " << Imp::s_run << ", lumiBlock = " << Imp::s_lumiBlock << endreq;
+                msg(MSG::DEBUG) << "          --> using run = " << Imp::s_run << ", lumiBlock = " << Imp::s_lumiBlock << endmsg;
         }
     }
 
@@ -450,7 +450,7 @@ initialize()
     IJobOptionsSvc* joSvc = 0;
     sc = service( "JobOptionsSvc", joSvc );
     if( !sc.isSuccess() ) {
-        msg(MSG::ERROR) << "!! Unable to locate the JobOptionsSvc service !!" << endreq;
+        msg(MSG::ERROR) << "!! Unable to locate the JobOptionsSvc service !!" << endmsg;
         return sc;
     }
     ATH_MSG_DEBUG("  --> Found service \"JobOptionsSvc\"");
@@ -462,7 +462,7 @@ initialize()
     StatusCode sc3 = joSvc->addPropertyToCatalogue( client, StringProperty("Environment",m_d->m_environmentProp) );
     joSvc->release();
     if( !(sc1.isSuccess() && sc2.isSuccess() && sc3.isSuccess()) ) {
-        msg(MSG::ERROR) << "!! Unable to add properties to JobOptionsSvc service !!" << endreq;
+        msg(MSG::ERROR) << "!! Unable to add properties to JobOptionsSvc service !!" << endmsg;
         return StatusCode::FAILURE;
     }
     ATH_MSG_DEBUG("  --> Added Properties");
@@ -477,10 +477,10 @@ initialize()
 //    if( m_monTools.size() > 0 ) {
 //       sc = m_monTools.retrieve();
 //       if( !sc.isSuccess() ) {
-//          msg(MSG::ERROR) << "!! Unable to retrieve monitoring tool " << m_monTools << endreq;
+//          msg(MSG::ERROR) << "!! Unable to retrieve monitoring tool " << m_monTools << endmsg;
 //          return sc;
 //       }
-//       if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "  --> Retrieved AthenaMonTools" << endreq;
+//       if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "  --> Retrieved AthenaMonTools" << endmsg;
 //    }
 
     m_d->m_eventCounter = m_d->m_everyNevents;
@@ -497,11 +497,11 @@ initialize()
             bench_tmp.finishMeasurement();
         m_d->toolAudEnd();
         if( sc_toolret.isFailure() ) {
-            msg(MSG::ERROR) << "Failed to retrieve monitoring tool " << tool << endreq;
+            msg(MSG::ERROR) << "Failed to retrieve monitoring tool " << tool << endmsg;
             return StatusCode::FAILURE;
         }
         else {
-            msg(MSG::INFO) << "Retrieved tool " << tool << endreq;
+            msg(MSG::INFO) << "Retrieved tool " << tool << endmsg;
         }
         IMonitorToolBase* mon = tool.operator->();
         ManagedMonitorToolBase* managed = dynamic_cast<ManagedMonitorToolBase*>( mon );
@@ -514,7 +514,7 @@ initialize()
         }
 
     }
-    if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "  --> Exiting successfully" << endreq;
+    if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "  --> Exiting successfully" << endmsg;
 
     return StatusCode::SUCCESS;
 }
@@ -525,13 +525,13 @@ AthenaMonManager::
 execute()
 {
     Imp::LWHistLeakChecker lc(m_d);
-    if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "AthenaMonManager::execute():" << endreq;
+    if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "AthenaMonManager::execute():" << endmsg;
 
     StatusCode sc;
     sc.setChecked();
 
     if( !m_d->m_manualRunLBProp ) {
-        if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "  --> Calling setEventInfo()" << endreq;
+        if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "  --> Calling setEventInfo()" << endmsg;
         setEventInfo();
     }
 
@@ -543,7 +543,7 @@ execute()
         if (m_d->m_doResourceMon)
             bench_tmp.startMeasurement();
         if( tool->preSelector() ) {
-            //if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "  --> The tool is preSelector" << endreq;
+            //if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "  --> The tool is preSelector" << endmsg;
 
             // Uncomment to test luminosity tools
             // I don't know where exactly it must be placed exactly
@@ -553,35 +553,35 @@ execute()
             ManagedMonitorToolBase* managed = dynamic_cast<ManagedMonitorToolBase*>( mon );
 
             float avgmu = managed->lbAverageInteractionsPerCrossing();
-            if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << " Test, Average mu: " << avgmu << endreq;
+            if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << " Test, Average mu: " << avgmu << endmsg;
 
             float instmu = managed->lbInteractionsPerCrossing();
-            if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << " Test, Instantaneous mu: " << instmu << endreq;
+            if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << " Test, Instantaneous mu: " << instmu << endmsg;
 
             float avglumi = managed->lbAverageLuminosity();
-            if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << " Test, Average lumi: " << avglumi << endreq;
+            if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << " Test, Average lumi: " << avglumi << endmsg;
 
             float instlumi = managed->lbLuminosityPerBCID();
-            if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << " Test, Instantaneous lumi: " << instlumi << endreq;
+            if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << " Test, Instantaneous lumi: " << instlumi << endmsg;
 
             double duration = managed->lbDuration();
-            if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << " Test, Lumiblock duration: " << duration << endreq;
+            if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << " Test, Lumiblock duration: " << duration << endmsg;
 
             double live = managed->livefractionPerBCID();
-            if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << " Test, lumiinst livefraction: " << live << endreq;
+            if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << " Test, lumiinst livefraction: " << live << endmsg;
 
             float lumilive = managed->lbAverageLivefraction();
-            if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << " Test, lumiavg livefraction: " << lumilive << endreq;
+            if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << " Test, lumiavg livefraction: " << lumilive << endmsg;
 
             double lumiweight = managed->lbLumiWeight();
-            if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << " Test, Lumiblock weight: " << lumiweight << endreq;
+            if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << " Test, Lumiblock weight: " << lumiweight << endmsg;
             */
             // Yuriy - end
 
             sc = tool->fillHists();
 
             if( !sc.isSuccess() ) {
-                if (msgLvl(MSG::WARNING)) msg(MSG::WARNING) << "IMonitorToolBase::fillHists() unsuccessful" << endreq;
+                if (msgLvl(MSG::WARNING)) msg(MSG::WARNING) << "IMonitorToolBase::fillHists() unsuccessful" << endmsg;
             }
         }
 
@@ -590,11 +590,11 @@ execute()
             bench_tmp.finishMeasurement();
             Imp::ToolBench* tb =  m_d->getToolBench(tool.operator->());
             tb->m_bench_algexec_fillHists += bench_tmp;//fixme: count events and subdivide
-            if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "  --> m_doResourceMon is True" << endreq;
+            if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "  --> m_doResourceMon is True" << endmsg;
         }
         m_d->toolAudEnd();
     }
-    if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "  --> Done calling IMonitorToolBase::fillHists()" << endreq;
+    if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "  --> Done calling IMonitorToolBase::fillHists()" << endmsg;
 
     if( m_d->m_eventCounter > 0 ) {
         m_d->m_eventCounter--;
@@ -614,15 +614,15 @@ execute()
                 tb->m_bench_algexec_checkHists += bench_tmp;//fixme: count events and subdivide
             }
             if( !sc.isSuccess() ) {
-                if (msgLvl(MSG::WARNING)) msg(MSG::WARNING) << "IMonitorToolBase::checkHists() unsuccessful" << endreq;
+                if (msgLvl(MSG::WARNING)) msg(MSG::WARNING) << "IMonitorToolBase::checkHists() unsuccessful" << endmsg;
             }
             m_d->toolAudEnd();
         }
-        if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "  --> Done calling IMonitorToolBase::checkHists()" << endreq;
+        if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "  --> Done calling IMonitorToolBase::checkHists()" << endmsg;
 
         m_d->m_eventCounter = m_d->m_everyNevents;
     }
-    if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "  --> Exiting successfully" << endreq;
+    if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "  --> Exiting successfully" << endmsg;
 
     return StatusCode::SUCCESS;
 }
@@ -640,7 +640,7 @@ AthenaMonManager::
 stop()
 {
     Imp::LWHistLeakChecker lc(m_d);
-    if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "AthenaMonManager::finalize():" << endreq;
+    if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "AthenaMonManager::finalize():" << endmsg;
 
     StatusCode sc;
     sc.setChecked();
@@ -656,7 +656,7 @@ stop()
         if (tb)
             tb->m_bench_algfin_finalHists.finishMeasurement();
         if( !sc.isSuccess() ) {
-            if (msgLvl(MSG::WARNING)) msg(MSG::WARNING) << "IMonitorToolBase::finalHists() unsuccessful" << endreq;
+            if (msgLvl(MSG::WARNING)) msg(MSG::WARNING) << "IMonitorToolBase::finalHists() unsuccessful" << endmsg;
         }
         if (tb)
             tb->m_bench_algfin_checkHists.startMeasurement();
@@ -664,7 +664,7 @@ stop()
         if (tb)
             tb->m_bench_algfin_checkHists.finishMeasurement();
         if( !sc.isSuccess() ) {
-            if (msgLvl(MSG::WARNING)) msg(MSG::WARNING) << "IMonitorToolBase::checkHists() unsuccessful" << endreq;
+            if (msgLvl(MSG::WARNING)) msg(MSG::WARNING) << "IMonitorToolBase::checkHists() unsuccessful" << endmsg;
         }
         if (tb)
             tb->m_bench_algfin_convertLWHists.startMeasurement();
@@ -672,15 +672,15 @@ stop()
         if (tb)
             tb->m_bench_algfin_convertLWHists.finishMeasurement();
         if( !sc.isSuccess() ) {
-            if (msgLvl(MSG::WARNING)) msg(MSG::WARNING) << "IMonitorToolBase::convertLWHists() unsuccessful" << endreq;
+            if (msgLvl(MSG::WARNING)) msg(MSG::WARNING) << "IMonitorToolBase::convertLWHists() unsuccessful" << endmsg;
         }
         if (tb)
             tb->report(this);
         m_d->toolAudEnd();
     }
     if (msgLvl(MSG::DEBUG)) {
-        msg(MSG::DEBUG) << "  --> Done calling IMonitorToolBase::finalHists() and IMonitorToolBase::checkHists()" << endreq;
-        msg(MSG::DEBUG) << "  --> Exiting successfully" << endreq;
+        msg(MSG::DEBUG) << "  --> Done calling IMonitorToolBase::finalHists() and IMonitorToolBase::checkHists()" << endmsg;
+        msg(MSG::DEBUG) << "  --> Exiting successfully" << endmsg;
     }
     return StatusCode::SUCCESS;
 }
@@ -691,7 +691,7 @@ AthenaMonManager::
 beginRun()
 {
     Imp::LWHistLeakChecker lc(m_d);
-    if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "AthenaMonManager::beginRun():" << endreq;
+    if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "AthenaMonManager::beginRun():" << endmsg;
 
     StatusCode sc;
     sc.setChecked();
@@ -710,13 +710,13 @@ beginRun()
             tb->m_bench_algexec_bookHists += bench_tmp;
         }
         if( !sc.isSuccess() ) {
-            if (msgLvl(MSG::WARNING)) msg(MSG::WARNING) << "IMonitorToolBase::bookHists() unsuccessful" << endreq;
+            if (msgLvl(MSG::WARNING)) msg(MSG::WARNING) << "IMonitorToolBase::bookHists() unsuccessful" << endmsg;
         }
         m_d->toolAudEnd();
     }
     if (msgLvl(MSG::DEBUG)) {
-        msg(MSG::DEBUG) << "  --> Done calling IMonitorToolBase::bookHists()" << endreq;
-        msg(MSG::DEBUG) << "  --> Exiting successfully" << endreq;
+        msg(MSG::DEBUG) << "  --> Done calling IMonitorToolBase::bookHists()" << endmsg;
+        msg(MSG::DEBUG) << "  --> Exiting successfully" << endmsg;
     }
 
     return StatusCode::SUCCESS;
@@ -728,7 +728,7 @@ AthenaMonManager::
 endRun()
 {
     Imp::LWHistLeakChecker lc(m_d);
-    if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "AthenaMonManager::endRun():" << endreq;
+    if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "AthenaMonManager::endRun():" << endmsg;
 
     StatusCode sc;
     sc.setChecked();
@@ -739,13 +739,13 @@ endRun()
         m_d->toolAudStart(tool);
         sc = tool->runStat();
         if( !sc.isSuccess() ) {
-            if (msgLvl(MSG::WARNING)) msg(MSG::WARNING) << "IMonitorToolBase::runStat() unsuccessful" << endreq;
+            if (msgLvl(MSG::WARNING)) msg(MSG::WARNING) << "IMonitorToolBase::runStat() unsuccessful" << endmsg;
         }
         m_d->toolAudEnd();
     }
     if (msgLvl(MSG::DEBUG)) {
-        msg(MSG::DEBUG) << "  --> Done calling IMonitorToolBase::runStat()" << endreq;
-        msg(MSG::DEBUG) << "  --> Exiting successfully" << endreq;
+        msg(MSG::DEBUG) << "  --> Done calling IMonitorToolBase::runStat()" << endmsg;
+        msg(MSG::DEBUG) << "  --> Exiting successfully" << endmsg;
     }
     return StatusCode::SUCCESS;
 }
@@ -839,7 +839,7 @@ writeAndDeleteLWHist( const std::string& key, const std::string& streamName )
                 StatusCode sc = m_THistSvc->deReg( h );
                 if( !sc.isSuccess() )
                 {
-                    if (msgLvl(MSG::WARNING)) msg(MSG::WARNING) << "AthenaMonManager::WriteAndDeleteHist(): Failure to deReg( TObject* )" << endreq;
+                    if (msgLvl(MSG::WARNING)) msg(MSG::WARNING) << "AthenaMonManager::WriteAndDeleteHist(): Failure to deReg( TObject* )" << endmsg;
                 }
 
                 m_d->m_objMapLW.erase( iLW );
@@ -898,7 +898,7 @@ writeAndResetLWHist( const std::string& key, const std::string& streamName )
                 StatusCode sc = m_THistSvc->deReg( h );
                 if( !sc.isSuccess() )
                 {
-                    if (msgLvl(MSG::WARNING)) msg(MSG::WARNING) << "AthenaMonManager::WriteAndDeleteHist(): Failure to deReg( TObject* )" << endreq;
+                    if (msgLvl(MSG::WARNING)) msg(MSG::WARNING) << "AthenaMonManager::WriteAndDeleteHist(): Failure to deReg( TObject* )" << endmsg;
                 }
 
                 m_d->m_objMapLW.erase( iLW );
@@ -949,7 +949,7 @@ writeAndDelete( const std::string& key )
 
             StatusCode sc = m_THistSvc->deReg( h );
             if( !sc.isSuccess() ) {
-                if (msgLvl(MSG::WARNING)) msg(MSG::WARNING) << "AthenaMonManager::WriteAndDeleteHist(): Failure to deReg( TObject* )" << endreq;
+                if (msgLvl(MSG::WARNING)) msg(MSG::WARNING) << "AthenaMonManager::WriteAndDeleteHist(): Failure to deReg( TObject* )" << endmsg;
             }
             delete o;
             gROOT->SetMustClean(doRecursiveReferenceDelete);
@@ -972,7 +972,7 @@ setEventInfo()
         StatusCode sc = evtStore()->retrieve( evt, evtEnd );
 
         if( !sc.isSuccess() ) {
-            msg(MSG::ERROR) << "!! Unable to retrieve Event from StoreGate !!" << endreq;
+            msg(MSG::ERROR) << "!! Unable to retrieve Event from StoreGate !!" << endmsg;
             return;
         }
 
@@ -980,7 +980,7 @@ setEventInfo()
         Imp::s_lumiBlock = evt->event_ID()->lumi_block();
 
         if (msgLvl(MSG::DEBUG))
-            msg(MSG::DEBUG) << "          --> setEventInfo: run = " << Imp::s_run << ", lumiBlock = " << Imp::s_lumiBlock << endreq;
+            msg(MSG::DEBUG) << "          --> setEventInfo: run = " << Imp::s_run << ", lumiBlock = " << Imp::s_lumiBlock << endmsg;
 
     }
 }
diff --git a/Control/AthenaMonitoring/src/FastPhysMonToolBase.cxx b/Control/AthenaMonitoring/src/FastPhysMonToolBase.cxx
index fdd3b160811..37c591ef1e6 100644
--- a/Control/AthenaMonitoring/src/FastPhysMonToolBase.cxx
+++ b/Control/AthenaMonitoring/src/FastPhysMonToolBase.cxx
@@ -24,7 +24,7 @@ StatusCode FastPhysMonToolBase::initialize() {
   //Register Incident-handler
   ServiceHandle<IIncidentSvc> incSvc("IncidentSvc",this->name());
   if (incSvc.retrieve().isFailure()) {
-    msg(MSG::ERROR) << "Can't retrieve IIncidentSvc" << endreq;
+    msg(MSG::ERROR) << "Can't retrieve IIncidentSvc" << endmsg;
     return StatusCode::FAILURE;
   }
  
@@ -41,7 +41,7 @@ void FastPhysMonToolBase::handle(const Incident&) {
   ATH_MSG_DEBUG("In incident handler...");
   const EventInfo* eventInfo;
   if (evtStore()->retrieve(eventInfo).isFailure()) {
-    msg(MSG::ERROR) << "Can't retrieve EventInfo object" << endreq;
+    msg(MSG::ERROR) << "Can't retrieve EventInfo object" << endmsg;
     return;
   }
 
@@ -71,7 +71,7 @@ StatusCode  FastPhysMonToolBase::regFPMTree(TTree* tree,const std::string& syste
   ATH_MSG_DEBUG("Registering FPM Tree with name " << tree->GetName() << " with system name " << systemName);
 
   if (ManagedMonitorToolBase::regTree(tree,systemName,all, ManagedMonitorToolBase::ATTRIB_UNMANAGED, chain, merge).isFailure()) {
-    msg(MSG::ERROR) << "Failed to register Tree with name " << tree->GetName() << " with system name " << systemName << endreq;
+    msg(MSG::ERROR) << "Failed to register Tree with name " << tree->GetName() << " with system name " << systemName << endmsg;
     return StatusCode::FAILURE;
   }
 
@@ -89,7 +89,7 @@ StatusCode  FastPhysMonToolBase::bookHistograms() {
   
   StatusCode sc=this->bookNtuple();
   if (sc.isFailure()) {
-    msg(MSG::ERROR) << "bookNtuple method failed!" << endreq;
+    msg(MSG::ERROR) << "bookNtuple method failed!" << endmsg;
     return StatusCode::FAILURE;
   }
 
@@ -100,6 +100,6 @@ StatusCode  FastPhysMonToolBase::bookHistograms() {
 
 
 StatusCode  FastPhysMonToolBase::bookNtuple() {
-  msg(MSG::ERROR) << "No bookNtuple() method implemented for this FastPhysMonTool!" << endreq;
+  msg(MSG::ERROR) << "No bookNtuple() method implemented for this FastPhysMonTool!" << endmsg;
   return StatusCode::FAILURE;
 }
diff --git a/Control/AthenaMonitoring/src/ManagedMonitorToolBase.cxx b/Control/AthenaMonitoring/src/ManagedMonitorToolBase.cxx
index 10aa8fde1d1..7724d03a801 100755
--- a/Control/AthenaMonitoring/src/ManagedMonitorToolBase.cxx
+++ b/Control/AthenaMonitoring/src/ManagedMonitorToolBase.cxx
@@ -160,14 +160,14 @@ void ManagedMonitorToolBase::Imp::benchFinalReport()
 {
   if (!m_doResourceMon)
     return;
-  m_theclass->msg(AthMonBench::s_resourceMonThreshold) << "ResourceSummary --> Result of dedicated mon-tool resource monitoring:"<<endreq;
-  m_theclass->msg(AthMonBench::s_resourceMonThreshold) << "ResourceSummary --> Book        : "<<m_bench_book << endreq;
-  m_theclass->msg(AthMonBench::s_resourceMonThreshold) << "ResourceSummary --> First Fill  : "<<m_bench_fillfirst << endreq;
-  m_theclass->msg(AthMonBench::s_resourceMonThreshold) << "ResourceSummary --> Last Fill   : "<<m_bench_filllast << endreq;
-  m_theclass->msg(AthMonBench::s_resourceMonThreshold) << "ResourceSummary --> Other Fills : "<<m_bench_fillall << endreq;
-  m_theclass->msg(AthMonBench::s_resourceMonThreshold) << "ResourceSummary --> Proc        : "<<m_bench_proc << endreq;
+  m_theclass->msg(AthMonBench::s_resourceMonThreshold) << "ResourceSummary --> Result of dedicated mon-tool resource monitoring:"<<endmsg;
+  m_theclass->msg(AthMonBench::s_resourceMonThreshold) << "ResourceSummary --> Book        : "<<m_bench_book << endmsg;
+  m_theclass->msg(AthMonBench::s_resourceMonThreshold) << "ResourceSummary --> First Fill  : "<<m_bench_fillfirst << endmsg;
+  m_theclass->msg(AthMonBench::s_resourceMonThreshold) << "ResourceSummary --> Last Fill   : "<<m_bench_filllast << endmsg;
+  m_theclass->msg(AthMonBench::s_resourceMonThreshold) << "ResourceSummary --> Other Fills : "<<m_bench_fillall << endmsg;
+  m_theclass->msg(AthMonBench::s_resourceMonThreshold) << "ResourceSummary --> Proc        : "<<m_bench_proc << endmsg;
   m_bench_total.setUnitCount();//to avoid dividing by number of measurements
-  m_theclass->msg(AthMonBench::s_resourceMonThreshold) << "ResourceSummary --> Grand Total : "<<m_bench_total << endreq;
+  m_theclass->msg(AthMonBench::s_resourceMonThreshold) << "ResourceSummary --> Grand Total : "<<m_bench_total << endmsg;
   //NB: Needs total also!
 }
 
@@ -418,6 +418,7 @@ ManagedMonitorToolBase( const std::string & type, const std::string & name,
    , m_hasRetrievedLumiTool(false)
    , m_bookHistogramsInitial(false)
    , m_useLumi(false)
+   , m_defaultLBDuration(60.)
     //, m_cycleNum(0)
    , m_d(new Imp(this))
 {
@@ -449,6 +450,9 @@ ManagedMonitorToolBase( const std::string & type, const std::string & name,
    // How detailed should the monitoring be?
    declareProperty( "DetailLevel", m_detailLevel );
 
+   // If we don't know how long an LB is, here's the default
+   declareProperty( "DefaultLBDuration", m_defaultLBDuration );
+
    // Properties that are overridden in initialize()---settings via jobOptions are ignored!
    declareProperty( "FileKey", m_fileKey );
    declareProperty( "DataType", m_dataTypeStr );
@@ -487,10 +491,10 @@ ManagedMonitorToolBase::
 streamNameFunction()
 {
    if( m_streamNameFcn == 0 ) {
-      msg(MSG::ERROR) << "!! streamNameFunction() has not been initialized !!" << endreq;
-      msg(MSG::ERROR) << "  --> neither ManagedMonitorToolBase::initialize() nor" << endreq;
-      msg(MSG::ERROR) << "  --> ManagedMonitorToolBase::setMonManager() has been called." << endreq;
-      msg(MSG::ERROR) << "  --> Correct configuration cannot be guaranteed from this point." << endreq;
+      msg(MSG::ERROR) << "!! streamNameFunction() has not been initialized !!" << endmsg;
+      msg(MSG::ERROR) << "  --> neither ManagedMonitorToolBase::initialize() nor" << endmsg;
+      msg(MSG::ERROR) << "  --> ManagedMonitorToolBase::setMonManager() has been called." << endmsg;
+      msg(MSG::ERROR) << "  --> Correct configuration cannot be guaranteed from this point." << endmsg;
       m_streamNameFcn = getNewStreamNameFcn();
    }
    return m_streamNameFcn;
@@ -558,7 +562,7 @@ levelOfDetailStringToEnum( const std::string& str )
       if( sc.isSuccess() ) {
          MsgStream log( ms, "ManagedMonitorToolBase::levelOfDetailStringToEnum()" );
          log << MSG::WARNING << "Unknown ManagedMonitorToolBase::LevelOfDetail_t \""
-            << str << "\", returning \"transient\"" << endreq;
+            << str << "\", returning \"transient\"" << endmsg;
       }
    }
 
@@ -640,7 +644,7 @@ intervalStringToEnum( const std::string& str )
       if( sc.isSuccess() ) {
          MsgStream log( ms, "ManagedMonitorToolBase::intervalStringToEnum()" );
          log << MSG::WARNING << "Unknown ManagedMonitorToolBase::Interval_t \""
-            << str << "\", returning \"file\"" << endreq;
+            << str << "\", returning \"file\"" << endmsg;
       }
    }
 
@@ -664,7 +668,7 @@ initialize()
 
    sc = m_THistSvc.retrieve();
    if( !sc.isSuccess() ) {
-      msg(MSG::ERROR) << "!! Unable to locate the THistSvc service !!" << endreq;
+      msg(MSG::ERROR) << "!! Unable to locate the THistSvc service !!" << endmsg;
       return sc;
    }
    ATH_MSG_DEBUG("  --> Found service \"THistSvc\"");
@@ -672,7 +676,7 @@ initialize()
    if( !m_trigDecTool.empty() ) {
       sc = m_trigDecTool.retrieve();
       if( !sc.isSuccess() ) {
-         msg(MSG::ERROR) << "!! Unable to retrieve the TrigDecisionTool !!" << endreq;
+         msg(MSG::ERROR) << "!! Unable to retrieve the TrigDecisionTool !!" << endmsg;
          return sc;
       }
       ATH_MSG_DEBUG("  --> Found AlgTool \"TrigDecisionTool\"");
@@ -680,7 +684,7 @@ initialize()
       if( !m_trigTranslator.empty() ) {
 	sc = m_trigTranslator.retrieve();
 	if ( !sc.isSuccess() ) {
-	  ATH_MSG_ERROR(" Unable to retrieve the TrigTranslatorTool!" << endreq);
+	  ATH_MSG_ERROR(" Unable to retrieve the TrigTranslatorTool!" << endmsg);
 	  return sc;
 	}
       }
@@ -689,7 +693,7 @@ initialize()
 	ATH_MSG_DEBUG("  --> Found nonempty trigger chain list");
          sc=parseList(m_triggerChainProp, m_vTrigChainNames);
          if(!sc.isSuccess()) {
-            msg(MSG::WARNING) << "Error parsing the trigger chain list, using empty list" << endreq;
+            msg(MSG::WARNING) << "Error parsing the trigger chain list, using empty list" << endmsg;
             m_vTrigChainNames.clear();
          }
 	 if (!m_trigTranslator.empty()) {
@@ -703,7 +707,7 @@ initialize()
 	ATH_MSG_DEBUG("  --> Found nonempty trigger group list");
          sc=parseList(m_triggerGroupProp, m_vTrigGroupNames);
          if(!sc.isSuccess()) {
-            msg(MSG::WARNING) << "Error parsing the trigger group names list, using empty list" << endreq;
+            msg(MSG::WARNING) << "Error parsing the trigger group names list, using empty list" << endmsg;
             m_vTrigGroupNames.clear();
          }
 	 if (!m_trigTranslator.empty()) {
@@ -727,7 +731,7 @@ initialize()
    ServiceHandle<IJobOptionsSvc> joSvc( "JobOptionsSvc", name() );
    sc = joSvc.retrieve();
    if( !sc.isSuccess() ) {
-      msg(MSG::ERROR) << "!! Unable to locate the JobOptionsSvc service !!" << endreq;
+      msg(MSG::ERROR) << "!! Unable to locate the JobOptionsSvc service !!" << endmsg;
       return StatusCode::FAILURE;
    }
    ATH_MSG_DEBUG("  --> Found service \"JobOptionsSvc\"");
@@ -736,7 +740,7 @@ initialize()
    ATH_MSG_DEBUG("  --> Asking for properties " << client);
    sc = joSvc->setMyProperties( client, this );
    if( !sc.isSuccess() ) {
-      msg(MSG::ERROR) << "!! Unable to set properties in JobOptionsSvc !!" << endreq;
+      msg(MSG::ERROR) << "!! Unable to set properties in JobOptionsSvc !!" << endmsg;
    }
    ATH_MSG_DEBUG("  --> Set Properties in \"JobOptionsSvc\"");
 
@@ -795,7 +799,7 @@ fillHists()
 
    if (m_d->m_warnAboutMissingInitialize) {
        m_d->m_warnAboutMissingInitialize = false;
-       msg(MSG::WARNING) << "ManagedMonitorToolBase::initialize() never called from reimplementation!" << endreq;
+       msg(MSG::WARNING) << "ManagedMonitorToolBase::initialize() never called from reimplementation!" << endmsg;
    }
 
 
@@ -843,7 +847,7 @@ fillHists()
          int LBsHigStat = m_manager->getLBsHigStat();
 
          if( LBsLowStat*LBsMedStat*LBsHigStat == 0) {
-            msg(MSG::WARNING) << "zero LBs requested for interval" << endreq;
+            msg(MSG::WARNING) << "zero LBs requested for interval" << endmsg;
          }
          else {
             if( ((currentLB-1)/LBsLowStat) != m_lastLowStatInterval ) m_newLowStatInterval = true;
@@ -885,7 +889,7 @@ fillHists()
    newLowStat = m_newLowStatInterval; 
 
    if( m_newEventsBlock || m_newLumiBlock || m_newRun ) {
-
+     ATH_MSG_DEBUG("Interval transition processing");
       // Process histograms from the previous lumiBlock/run
       if( m_nEvents != 1 ) {
 	     m_d->benchPreProcHistograms();
@@ -912,6 +916,22 @@ fillHists()
             sc1 = regManagedLWHistograms(m_templateLWHistograms[interval]);     
           }
       }
+      for (const auto& interval: std::vector<Interval_t>{ eventsBlock, lumiBlock, lowStat, run }) {
+	for (const auto& it: m_templateHistograms[interval]) {
+	  //ATH_MSG_WARNING("Oi, considering " << it.m_templateHist->GetName() << it.m_group.histo_mgmt());
+	  // is histogram too small in x axis for LB range?
+	  if (it.m_group.histo_mgmt() == ATTRIB_X_VS_LB) {
+	    //ATH_MSG_WARNING("We are rebinning for " << it.m_templateHist->GetName());
+	    while ( it.m_templateHist->GetXaxis()->GetXmax() <= AthenaMonManager::lumiBlockNumber() ) {
+	      it.m_templateHist->LabelsInflate("X");
+	    }
+	  }
+	}
+      }
+
+      if (auto streamname = dynamic_cast<OfflineStream*>(streamNameFunction())) {
+	streamname->updateRunLB();
+      }
       
       sc3 = bookHistogramsRecurrent( );
       
@@ -1014,7 +1034,7 @@ regManagedHistograms(std::vector< MgmtParams<TH1> >& templateHistograms)
       bool allIsOk = true;  
    
       for( std::vector< MgmtParams<TH1> >::iterator it = templateHistograms.begin(); it != templateHistograms.end(); ++it ) {
-          MonGroup group = (*it).m_group;
+          MonGroup& group = (*it).m_group;
 
           // Get a handle to the histogram
           TH1* theHist = (*it).m_templateHist;
@@ -1260,7 +1280,8 @@ finalHists()
      endOfRun = true;
 
      StatusCode sc = procHistograms();
-     
+
+/*
      StatusCode sc1( StatusCode::SUCCESS );
      sc1.setChecked();
 
@@ -1274,7 +1295,7 @@ finalHists()
        //sc1 = regManagedLWHistograms(m_templateLWHistograms[interval], false, true);
        sc1.setChecked();
      }
-#endif
+*/
 
      m_d->benchPostProcHistograms();
      return sc;
@@ -1374,48 +1395,53 @@ regHist( TH1* h, const MonGroup& group )
 {
 //   ManagedMonitorToolBase_addHistStatistics(this,h);
 
-   if (!h)
-      return StatusCode::FAILURE;
-
-   // This part of the code deals with MANAGED type
-   if ( (group.histo_mgmt() & ATTRIB_UNMANAGED) == 0 ) {
-       /* 
-          Create an unmanaged group based on the original MonGroup instance passed
-          It is needed because managed histogram is presented as a number of unmanaged
-          histograms (one per each interval)
-        */
-       MonGroup group_unmanaged( this, group.system(), group.interval(), ATTRIB_UNMANAGED, group.chain(), group.merge());
-
-       if (m_supportedIntervalsForRebooking.count(group.interval())) {
-         m_templateHistograms[group.interval()].push_back( MgmtParams<TH1>(h, group_unmanaged) );
-       } else {
-	       ATH_MSG_ERROR("Attempt to book managed histogram " << h->GetName() << " with invalid interval type " << intervalEnumToString(group.interval()));
+  if (!h)
+    return StatusCode::FAILURE;
+  
+  // This part of the code deals with MANAGED type
+  if ( group.histo_mgmt() != ATTRIB_UNMANAGED ) {
+    /* 
+       Create an unmanaged group based on the original MonGroup instance passed
+       It is needed because managed histogram is presented as a number of unmanaged
+       histograms (one per each interval)
+       Update (PUEO) - I don't think it actually matters, and need to keep 
+       track of "proper" attribute for X_VS_LB
+    */
+    
+    if (group.histo_mgmt() == ATTRIB_X_VS_LB && group.merge() == "") {
+      ATH_MSG_WARNING("HEY! You're attempting to register " << h->GetName() << " as a per-LB histogram, but you're not setting the merge algorithm! This is a SUPER-BAD idea! Use \"merge\", at least.");
+    }
+    
+    if (m_supportedIntervalsForRebooking.count(group.interval())) {
+      m_templateHistograms[group.interval()].push_back( MgmtParams<TH1>(h, group) );
+    } else {
+      ATH_MSG_ERROR("Attempt to book managed histogram " << h->GetName() << " with invalid interval type " << intervalEnumToString(group.interval()));
 	       return StatusCode::FAILURE;
-       }
-
-       std::string hName = h->GetName();
-       std::string streamName = streamNameFunction()->getStreamName( this, group_unmanaged, hName, false );
-	   StatusCode smd = registerMetadata(streamName, hName, group);
-       smd.setChecked();
-       return m_THistSvc->regHist( streamName, h );
-   }
-
-
-   // This part of the code deals with UNMANAGED type
-   std::string hName = h->GetName();
-
-   if( m_manager != 0 ) {
-      std::string genericName = NoOutputStream().getStreamName( this, group, hName );
-      m_manager->writeAndDelete( genericName );
-      m_manager->passOwnership( h, genericName );
-   }
-
-   std::string streamName = streamNameFunction()->getStreamName( this, group, hName, false );
-
-   StatusCode smd = registerMetadata(streamName, hName, group);
-   if (smd != StatusCode::SUCCESS) return StatusCode::FAILURE;
-
-   return m_THistSvc->regHist( streamName, h );
+    }
+    
+    std::string hName = h->GetName();
+    MonGroup group_unmanaged( this, group.system(), group.interval(), ATTRIB_UNMANAGED, group.chain(), group.merge());
+    std::string streamName = streamNameFunction()->getStreamName( this, group_unmanaged, hName, false );
+    StatusCode smd = registerMetadata(streamName, hName, group);
+    smd.setChecked();
+    return m_THistSvc->regHist( streamName, h );
+  }
+  
+  // This part of the code deals with UNMANAGED type
+  std::string hName = h->GetName();
+  
+  if( m_manager != 0 ) {
+    std::string genericName = NoOutputStream().getStreamName( this, group, hName );
+    m_manager->writeAndDelete( genericName );
+    m_manager->passOwnership( h, genericName );
+  }
+  
+  std::string streamName = streamNameFunction()->getStreamName( this, group, hName, false );
+  
+  StatusCode smd = registerMetadata(streamName, hName, group);
+  if (smd != StatusCode::SUCCESS) return StatusCode::FAILURE;
+  
+  return m_THistSvc->regHist( streamName, h );
 }
 
 StatusCode ManagedMonitorToolBase::regHist( LWHist* h,const std::string& system,
@@ -1435,7 +1461,7 @@ StatusCode ManagedMonitorToolBase::regHist( LWHist* h, const MonGroup& group )
 
    if (!m_bookHistogramsInitial) {
            ATH_MSG_DEBUG("Yura: very first time");
-	   if ( (group.histo_mgmt() & ATTRIB_UNMANAGED) == 0 ) {
+	   if ( group.histo_mgmt() != ATTRIB_UNMANAGED ) {
 
                ATH_MSG_DEBUG("Yura: we have managed histograms");
 	       if (m_supportedIntervalsForRebooking.count(group.interval())) {
@@ -1462,7 +1488,7 @@ StatusCode ManagedMonitorToolBase::regHist( LWHist* h, const MonGroup& group )
             std::set<LWHist*>::iterator it =  m_lwhists.find(prevLWHist);
             if (it!=m_lwhists.end())
             {
-                if ( (group.histo_mgmt() & ATTRIB_UNMANAGED) == 0 ) {
+                if ( group.histo_mgmt() != ATTRIB_UNMANAGED ) {
                     m_manager->writeAndResetLWHist( genericName, LWHistAthMonWrapper::streamName(prevLWHist) );
                 } else {
                     m_manager->writeAndDeleteLWHist( genericName, LWHistAthMonWrapper::streamName(prevLWHist) );
@@ -1570,7 +1596,7 @@ regGraph( TGraph* g, const MonGroup& group )
       return StatusCode::FAILURE;
 
    // This part of the code deals with MANAGED type
-   if ( (group.histo_mgmt() & ATTRIB_UNMANAGED) == 0 ) {
+   if ( group.histo_mgmt() != ATTRIB_UNMANAGED ) {
        // Create an unmanaged group based on the original MonGroup instance passed
        // This is needed because managed graph is presented as a number of unmanaged
        // graphs (one per each interval)
@@ -1625,7 +1651,7 @@ regTree( TTree* t, const MonGroup& group )
 {
 
    // This part of the code deals with MANAGED type
-   if ( (group.histo_mgmt() & ATTRIB_UNMANAGED) == 0 ) {
+   if ( group.histo_mgmt() != ATTRIB_UNMANAGED ) {
        // Create an unmanaged group based on the original MonGroup instance passed
        // This is needed because managed tree is presented as a number of unmanaged
        // trees (one per each interval)
@@ -1907,12 +1933,15 @@ double
 ManagedMonitorToolBase::
 lbDuration()
 {
+    if ( m_environment == AthenaMonManager::online ) {
+        return m_defaultLBDuration;
+    }
     if ( m_hasRetrievedLumiTool ) {
         return m_lumiTool->lbDuration();
     } else {
         //ATH_MSG_FATAL("! Luminosity tool has been disabled ! lbDuration() can't work properly! ");
         ATH_MSG_DEBUG("Warning: lbDuration() - luminosity tools are not retrieved or turned on (i.e. EnableLumi = False)");
-        return -1.0;
+        return m_defaultLBDuration;
     }
     // not reached
 }
@@ -2100,7 +2129,7 @@ getStreamName( const ManagedMonitorToolBase* tool, const MonGroup& group, const
 
    if( useRunFolders ) {
       if (usePreviousInterval && (group.interval() == ManagedMonitorToolBase::run) )
-          streamName << "run_" << AthenaMonManager::runNumber() - 1 << "/";
+          streamName << "run_" << m_prev_run_number << "/";
       else
           streamName << "run_" << AthenaMonManager::runNumber() << "/";
    }
@@ -2108,14 +2137,14 @@ getStreamName( const ManagedMonitorToolBase* tool, const MonGroup& group, const
    int currentLB = AthenaMonManager::lumiBlockNumber();
    if( useLBFolders ) {
       if (usePreviousInterval && (group.interval() == ManagedMonitorToolBase::lumiBlock) )
-          streamName << "lb_" << currentLB - 1 << "/";
+          streamName << "lb_" << m_prev_lumi_block << "/";
       else
           streamName << "lb_" << currentLB << "/";
    }
    else if( useLowStatInterval ) {
       int start, end;
       if (usePreviousInterval && (group.interval() == ManagedMonitorToolBase::lowStat) )
-          getLBrange(&start, &end, currentLB - 1, AthenaMonManager::getLBsLowStat());
+          getLBrange(&start, &end, m_prev_lumi_block, AthenaMonManager::getLBsLowStat());
       else
           getLBrange(&start, &end, currentLB, AthenaMonManager::getLBsLowStat());
       streamName << "lowStat_LB" << start << "-" << end << "/";
@@ -2170,6 +2199,13 @@ getDirectoryName( const ManagedMonitorToolBase* tool, const MonGroup& group, con
     return rem;
 }
 
+void
+ManagedMonitorToolBase::OfflineStream::
+updateRunLB() {
+  m_prev_run_number = AthenaMonManager::runNumber();
+  m_prev_lumi_block = AthenaMonManager::lumiBlockNumber();
+}
+
 bool 
 ManagedMonitorToolBase::
 trigChainsArePassed(std::vector<std::string>& vTrigNames) 
@@ -2204,7 +2240,7 @@ parseList(const std::string& line, std::vector<std::string>& result) {
       result.push_back(item);
    }
 
-   msg(MSG::DEBUG) << endreq;
+   msg(MSG::DEBUG) << endmsg;
    return StatusCode::SUCCESS;
 }
 
diff --git a/Control/AthenaMonitoring/src/MonitorToolBase.cxx b/Control/AthenaMonitoring/src/MonitorToolBase.cxx
index 97200e62f47..66d602d0ef7 100755
--- a/Control/AthenaMonitoring/src/MonitorToolBase.cxx
+++ b/Control/AthenaMonitoring/src/MonitorToolBase.cxx
@@ -61,7 +61,7 @@ MonitorToolBase::~MonitorToolBase()
 /*---------------------------------------------------------*/
 {
   MsgStream log(msgSvc(), name());
-  log << MSG::INFO << "destructor has been called" << endreq;
+  log << MSG::INFO << "destructor has been called" << endmsg;
 }
 
 /*---------------------------------------------------------*/
@@ -76,7 +76,7 @@ MonitorToolBase::getStreamName(unsigned int number, bool useDefault /* =true */
       {
 	MsgStream log(msgSvc(), name ());
 	log << MSG::ERROR
-	    << "Could not setup Outputstreams !" << endreq;
+	    << "Could not setup Outputstreams !" << endmsg;
       }
   
   // valid entry in vector ?
@@ -103,7 +103,7 @@ MonitorToolBase::getStreamName(std::string stream, bool useDefault /* = true */
       {
 	MsgStream log(msgSvc(), name ());
 	log << MSG::ERROR
-	    << "Could not setup Outputstreams !" << endreq;
+	    << "Could not setup Outputstreams !" << endmsg;
       }
   
   // valid entry in map ?
@@ -145,7 +145,7 @@ MonitorToolBase::setupOutputStreams(std::vector<std::string> Mapping
 	{
 	  log << MSG::ERROR
 	      << "No '/' found in StreamName " << *itr
-	      << " ! Will not use this stream !" << endreq;
+	      << " ! Will not use this stream !" << endmsg;
 	  itr = m_THistSvc_streamnameMapping.erase(itr);
 	  continue;
 	}
@@ -160,7 +160,7 @@ MonitorToolBase::setupOutputStreams(std::vector<std::string> Mapping
 	      << iter->first << iter->second << "\" with \""
 	      << itr->substr(0,location)
 	      << itr->substr(location) << "\" !!"
-	      << endreq;
+	      << endmsg;
 	  iter->second=itr->substr(location);
 	}else{
 	  m_map_THistSvc_streamnames[itr->substr(0,location)]=itr->substr(location);
@@ -173,7 +173,7 @@ MonitorToolBase::setupOutputStreams(std::vector<std::string> Mapping
     {
       log << MSG::INFO
 	  << "Using following mapping of mnemonics to streams (in alphabetical order):"
-	  << endreq;
+	  << endmsg;
       for( map_type::const_iterator iter = m_map_THistSvc_streamnames.begin();
 	   iter != m_map_THistSvc_streamnames.end(); iter++ )
 	log << MSG::INFO 
@@ -181,7 +181,7 @@ MonitorToolBase::setupOutputStreams(std::vector<std::string> Mapping
 	    << iter->first << " writes to "
 	    << std::setw(20)
 	    << iter->second
-	    << endreq;
+	    << endmsg;
     }
   // don't call again
   m_setupStreamMap=true;
@@ -223,7 +223,7 @@ StatusCode MonitorToolBase::finalHists() // Default finalHists(): do nothing.
 /*---------------------------------------------------------*/
 {
   MsgStream log(msgSvc(), name());
-  log << MSG::INFO << "default finalHists() called." << endreq;
+  log << MSG::INFO << "default finalHists() called." << endmsg;
   return StatusCode::SUCCESS;
 }
 
@@ -243,9 +243,9 @@ StatusCode MonitorToolBase::checkHists(bool fromFinalize) // Default checkHists(
     log.setFormat(m_FormatString);
   
   if(fromFinalize)
-    log << MSG::INFO << "default checkHists() called from finalize()." << endreq;
+    log << MSG::INFO << "default checkHists() called from finalize()." << endmsg;
   else
-    log << MSG::INFO << "default checkHists() called periodically." << endreq;
+    log << MSG::INFO << "default checkHists() called periodically." << endmsg;
   return StatusCode::SUCCESS;
 }
 /*---------------------------------------------------------*/
@@ -256,7 +256,7 @@ IHistogramSvc* MonitorToolBase::ToolHistoSvc()
  
   StatusCode sc = service("HistogramDataSvc",m_histsvc, true);
   if( sc.isFailure() ) {
-    log << MSG::WARNING << ">>> Unable to locate the Histogram service" << endreq;
+    log << MSG::WARNING << ">>> Unable to locate the Histogram service" << endmsg;
   }
 
   return m_histsvc;
@@ -269,7 +269,7 @@ ITHistSvc* MonitorToolBase::ToolRootHistSvc()
  
   StatusCode sc = service("THistSvc",m_rootsvc, true);
   if( sc.isFailure() ) {
-    log << MSG::WARNING << ">>> Unable to locate the Histogram service" << endreq;
+    log << MSG::WARNING << ">>> Unable to locate the Histogram service" << endmsg;
   }
   
   return m_rootsvc;
-- 
GitLab