diff --git a/LumiBlock/LumiBlockComps/LumiBlockComps/CoolQuery.h b/LumiBlock/LumiBlockComps/LumiBlockComps/CoolQuery.h
deleted file mode 100644
index 8271ff83ea82d9e28dfa284077b1bafdc12a7099..0000000000000000000000000000000000000000
--- a/LumiBlock/LumiBlockComps/LumiBlockComps/CoolQuery.h
+++ /dev/null
@@ -1,460 +0,0 @@
-/*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
-*/
-
-#ifndef COOLQUERY_H
-#define COOLQUERY_H
-
-// Cool access
-#include "CoolKernel/Exception.h"
-#include "CoolKernel/FolderSpecification.h"
-#include "CoolKernel/IDatabaseSvc.h"
-#include "CoolKernel/IDatabase.h"
-#include "CoolKernel/IFolder.h"
-#include "CoolKernel/IFolderSet.h"
-#include "CoolKernel/IObject.h"
-#include "CoolKernel/IObjectIterator.h"
-#include "CoolKernel/Exception.h"
-#include "CoolKernel/pointers.h"
-#include "CoolKernel/IDatabaseSvc.h"
-#include "CoolApplication/DatabaseSvcFactory.h"
-#include "LumiBlockComps/ReplicaSorter.h"
-
-#include "RelationalAccess/IConnectionServiceConfiguration.h"
-#include "RelationalAccess/ConnectionService.h"
-#include "RelationalAccess/ISessionProxy.h"
-#include "RelationalAccess/ITransaction.h"
-#include "RelationalAccess/ISchema.h"
-#include "RelationalAccess/ITable.h"
-#include "RelationalAccess/IQuery.h"
-#include "RelationalAccess/ICursor.h"
-
-// LumiBlock includes
-#include "LumiBlockComps/ILumiCalcSvc.h"
-#include "LumiBlockData/LumiBlockCollection.h"
-#include "AthenaKernel/IOVRange.h"
-#include "AthenaKernel/IOVTime.h"
-
-// stl includes
-#include <iomanip>
-#include <iostream>
-#include <string>
-#include <vector>
-#include <map>
-
-// boost includes
-//#include <boost/unordered_map.hpp>
-
-// logger
-#include "GoodRunsLists/TMsgLogger.h"
-
-// magic includes
-//#include <magic.h>
-
-//================================================
-// Simple class to hold
-
-// Simple class to hold IOV-based data efficiently
-template <class T>
-class IOVData {
-
- public:
-  IOVData() {
-    clear();
-  }
-
-  ~IOVData() {
-    clear();
-  }
-
-  void clear() {
-    data.clear();
-    last = data.begin();
-    lastData = false;
-  }
-
-  // Main access function, returns value at specific time
-  T getValue(IOVTime time);
-
-  // Useful for LAr calculation, returns list of IOV-data pairs which intersect given range
-  typename std::list<std::pair<IOVRange, T > > getOverlap(IOVRange range);
-
-  // Insert element
-  void add(IOVRange range, T val);
-
-  // Data list
-  typename std::list<std::pair<IOVRange, T > > data;
-
- private:
-  bool lastData;
-
-  // Cant use a map as IOVRange objects have no order
-  typename std::list<std::pair<IOVRange, T > >::iterator last;
-
-};
-
-template <class T> 
-void IOVData<T>::add(IOVRange range, T val) {
-  data.push_back(std::pair<IOVRange, T>(range, val));
-  last = data.begin();
-  lastData = false;
-}
-
-template <class T> 
-T IOVData<T>::getValue(IOVTime time) {
-
-  // bool verbose = false;
-  // if (verbose) {
-  //   cout << endl << "getValue(" << time << ")" << endl;
-  //   cout << "Data Size: " << data.size() << endl;
-  // }
-
-  if (data.empty()) return T(-1);
-
-  typename std::list<std::pair<IOVRange, T> >::iterator it;
-
-  // if (verbose) {
-  //   for (it = data.begin(); it != data.end(); it++)
-  //     cout << "(" << it->first << ", " << it->second << ")" << endl;
-  //   cout << "Last is valid - " << lastData << endl;
-  // }
-
-  // Check if previous value is still good
-  if (lastData) {
-    // if (verbose) {
-    //   cout << "Check previous " << last->first << endl;
-    // }
-
-    if ((last->first).isInRange(time)) return last->second;
-
-    // Previous not good, try next as best guess
-    if (++(last) != data.end()) {
-      // if (verbose) cout << "Check next " << last->first << endl;
-      if ((last->first).isInRange(time)) return last->second;
-    }
-  } else {
-    last = data.begin();
-  }
-
-  lastData = false;
-
-  // OK, suck it up and find the best value by stepping through entire list
-  if ( last->first.stop() < time && last != data.end()) {
-
-    // if (verbose) cout << "Search upwards" << endl;
-    for (++last; last != data.end(); last++) {
-      // if (verbose) cout << last->first << endl;
-      if ((lastData = (last->first).isInRange(time))) return last->second;
-    }
-
-  } else if ( last->first.start() > time && last != data.begin()) {
-
-    // if (verbose) cout << "Search downwards" << endl;
-    do {
-      --last;
-      // if (verbose) cout << last->first << endl;
-      if ((lastData = (last->first).isInRange(time))) return last->second;
-    } while (last != data.begin());
-
-  } else {
-
-    if ((lastData = last->first.isInRange(time))) return last->second;
-
-  } 
-
-  // Set to valid data if we didn't find anything
-  last = data.begin();
-  lastData = false;
-
-  // If we got to here, we didn't find it
-  return T(-1);
-}
-
-template <class T> 
-std::list<std::pair<IOVRange, T> > IOVData<T>::getOverlap(IOVRange range) {
-
-  std::list<std::pair<IOVRange, T> > mydata;
-  mydata.clear();
-
-  // Find first time
-  IOVTime firsttime = range.start();
-  IOVTime lasttime = range.stop();
-
-  // Use this to efficiently set the 'last' pointer
-  getValue(firsttime);
-
-  // Pointer to found element
-  typename std::list<std::pair<IOVRange, T> >::iterator elem;
-
-  std::pair<IOVRange, T> val;
-
-  // Loop over elements
-  for (elem = last; elem != data.end(); elem++) {
-
-    val = *elem;
-
-    // Truncate this if necessary
-    if (val.first.start() < firsttime || val.first.stop() > lasttime) {
-      IOVTime iovstart((val.first.start() < firsttime ? firsttime : val.first.start()));
-      IOVTime iovstop((val.first.stop() > lasttime ? lasttime : val.first.stop()));
-      val.first = IOVRange(iovstart, iovstop);
-    }
-    mydata.push_back(val);
-
-    // Check if we are done
-    if (elem->first.isInRange(lasttime)) break;
-  }
-
-  return mydata;
-}
-
-/***************************************
- * This class serves as a common engine
- * for Cool Query by fetching 
- * up basic values from COOL for a single
- * trigger chain, trigger db and lumi db
- ****************************************/
-
-class CoolQuery{
- public:
-
-  // constructor
-  CoolQuery(const std::string& database, const std::string& triggerchain);
-
-  // destructor
-  ~CoolQuery();
-
-  // Set trigger database
-  void setDb(const std::string& database){m_database = database;}
-
-  // Set trigger
-  void setTrigger(const std::string& triggerchain){m_triggerchain = triggerchain;}
-
-
-  // Opens database connection
-  bool openDbConn();
-
-  // set the "central" IOV range to this time (presumable this comes from some LumiBlockCollection's IOVRange
-  // but one in general can create one such object via e.g.:
-  //
-  // LumiBlockCollection * iovc = new LumiBlockCollection();
-  // iovc->push_back(new IOVRange(IOVTime(runnumber, LBstart), IOVTime(runnumber,LBend)));
-  // LumiBlockCollection::const_iterator i = iovc->begin();
-  //  
-  // then use it via
-  //
-  // mycoolquery->setIOV(iovr->start().re_time(), iovr->stop().re_time());
-  //
-  void setIOV(const cool::ValidityKey start, const cool::ValidityKey stop);
-
-  void setIOVForRun(unsigned int runnum);
-
-  // returns HLT channelId of trigger "trigger" in folder "folder_name"
-  cool::ChannelId getHLTChannelId(const std::string& trigger, const std::string& folder_name);
-
-  // returns L1 channelId of trigger "trigger" in folder "folder_name"
-  cool::ChannelId getL1ChannelId(const std::string& trigger, const std::string& folder_name);
-
-  // returns Lumi channelId for lumimethod in folder_name
-  cool::ChannelId getLumiChannelId(const std::string& lumimethod, const std::string& folder_name);
-
-  // utility to indicate whether ChannelID returned by any of the above is valid
-  bool channelIdValid();
-
-  // returns "LowerChainName" of "trigger" in "folder_name" folder
-  std::string getHLTLowerChainName(const std::string& trigger, const std::string& folder_name);
-
-  // handy function  to get quickly prescale
-  cool::Int32 getL1PrescaleFromChannelId(const std::string& folder_name, const cool::ChannelId& id );
-
-  // handy function  to get quickly prescale
-  cool::Float getHLTPrescaleFromChannelId(const std::string& folder_name, const cool::ChannelId& id );
-
-  // Print list of triggers
-  void printL1Triggers(const std::string& folder_name);
-  void printHLTTriggers(const std::string& folder_name);
-
-  // note this is mainly for trigger dependent variables, counters, prescales, etc.
-  template <class T>
-    std::map<cool::ValidityKey, T> getObjMapFromFolderAtChan(const std::string& obj_name, const std::string& folder_name, const cool::ChannelId& id);
-
-  template <class T>
-    std::map<cool::ValidityKey, T> getTrigObjMapFromFolderByName(const std::string& obj_name, const std::string& folder_name, const std::string& trigger);
-
-  // same but giving an (unordered) map with IOVRange key
-  //  template <class T>
-  //  unordered_map<IOVRange, T> getTrigObjMapFromFolderByNameIOV(const std::string& obj_name, const std::string& folder_name, const std::string& trigger);
-
-  template <class T>
-    std::map<cool::ValidityKey, T> getLumiIterator(const std::string& luminame, const std::string& folder_name, const std::string& tag, const cool::ChannelId& id );
-
-  // returns numerical 1/2/3 values for trigger "triggername" 
-  unsigned int getTriggerLevel(std::string triggername);    
-
-  // Retrieve all lumi data at once
-  struct LumiFolderData {
-    float LBAvInstLumi;
-    float LBAvEvtsPerBX;
-    cool::UInt32 Valid;
-    LumiFolderData() : LBAvInstLumi(), LBAvEvtsPerBX(), Valid() {}
-  };
-
-  std::map<cool::ValidityKey, LumiFolderData> 
-    getLumiFolderData(const std::string& folder_name, const std::string& tag, const cool::ChannelId& id );
-
-  // Retrieve all L1 counter data at once
-  struct L1CountFolderData {
-    cool::UInt63 BeforePrescale;
-    cool::UInt63 AfterPrescale;
-    cool::UInt63 L1Accept;  // After L1 veto
-  };
-
-  std::map<cool::ValidityKey, L1CountFolderData> 
-    getL1CountFolderData(const std::string& folder_name, const cool::ChannelId& id);
-
-  // Retrieve prescale data into cached data object
-  template <class T>
-    IOVData<T> getIOVData(const std::string& name, const std::string& folder_name, const cool::ChannelId& id, const std::string& tag="");
- 
- private:
-  std::string transConn(const std::string& inconn);
-
-  coral::ConnectionService m_coralsvc;  
-  ReplicaSorter* m_repsort;
-  cool::IDatabasePtr m_sourceDbPtr;
-  std::string m_database;
-  std::string m_triggerchain;
-  cool::ValidityKey m_VKstart;
-  cool::ValidityKey m_VKstop;
-  
-  Root::TMsgLogger m_logger;
-
-  bool m_valid;
-};
-
-/* template <class T> */
-/* unordered_map<IOVRange, T> CoolQuery::getTrigObjMapFromFolderByNameIOV(const std::string& obj_name, const std::string& folder_name, const std::string& trigger){ */
-/*   unordered_map<IOVRange, T> test; */
-/*   return test; */
-
-/* } */
-
-
-
-//===========================================================================
-template <class T>
-std::map<cool::ValidityKey, T> CoolQuery::getTrigObjMapFromFolderByName(const std::string& obj_name, const std::string& folder_name, const std::string& trigger){
-  // m_logger << Root::kWARNING << "Getting object [" << obj_name << "] from folder [" << folder_name << "], in LB range: " << (m_VKstart >> 32) << ", " << (m_VKstart & 0xFFFFFFFF) << " - " << (m_VKstop >> 32) << ","<< (m_VKstop & 0xFFFFFFFF)  << Root::GEndl;
-  std::map<cool::ValidityKey, T> mymap;
-  bool found = false;
-  cool::IFolderPtr folder_ptr = m_sourceDbPtr->getFolder(folder_name);
-  cool::IObjectIteratorPtr obj_itr=folder_ptr->browseObjects(m_VKstart,m_VKstart, cool::ChannelSelection::all());
-  // loop through all triggers
-  while (obj_itr->goToNext()){
-
-    const cool::IRecord& payload=obj_itr->currentRef().payload();
-    //    std::cout << "ChainNames: " << payload["ChainName"].data<std::string>() << std::endl;
-
-    if(payload["ChainName"].data<std::string>() == trigger){
-      found = true;
-      const cool::IRecord& payload=obj_itr->currentRef().payload();
-      //      std::cout << "Inserting: " << (obj_itr->currentRef().since() >> 32) << " - " << (obj_itr->currentRef().since() & 0xFFFFFF) << ", " << payload[obj_name].data<T>() << std::endl;
-      mymap.insert( std::pair<cool::ValidityKey, T>(obj_itr->currentRef().since() ,payload[obj_name].data<T>()));
-    }
-  }
-
-  if(!found){
-    m_logger << Root::kERROR << "Couldn't find HLT trigger [" << trigger << "] in folder [" << folder_name << "]" << Root::GEndl;
-  }
-
-  return  mymap;
-}
-
-
-//===========================================================================
-template <class T>
-std::map<cool::ValidityKey, T> CoolQuery::getObjMapFromFolderAtChan(const std::string& obj_name, const std::string& folder_name, const cool::ChannelId& id){
-  //  m_logger << Root::kWARNING << "Getting object [" << obj_name << "] from folder [" << folder_name << "], in channel: " << id << ", in LB range: " << (m_VKstart >> 32) << ", " << (m_VKstart & 0xFFFFFFFF) << " - " << (m_VKstop >> 32) << ","<< (m_VKstop & 0xFFFFFFFF)  << Root::GEndl;
-  std::map<cool::ValidityKey, T> mymap;
-  cool::IFolderPtr folder_ptr = m_sourceDbPtr->getFolder(folder_name);
-  cool::ChannelSelection chsel(id);
-  if(folder_ptr->existsChannel(id)){
-    cool::IObjectIteratorPtr itr = folder_ptr->browseObjects(m_VKstart, m_VKstop,chsel);
-    while (itr->goToNext()) {
-      const cool::IRecord& payload=itr->currentRef().payload();
-      //     std::cout << "Inserting: " << (itr->currentRef().since() >> 32) << " - " << (itr->currentRef().since() & 0xFFFFFF) << ", " << payload[obj_name].data<T>() << std::endl;
-      mymap.insert( std::pair<cool::ValidityKey, T>(itr->currentRef().since() ,payload[obj_name].data<T>()));
-    }
-  }else{
-    m_logger << Root::kWARNING << "Channel " << id << " does not exist in database." << Root::GEndl; 
-/*     const std::map<cool::ChannelId,std::string> list = folder_ptr->listChannelsWithNames(); */
-  }
-  return  mymap;
-}
-
-
-//===========================================================================
-template <class T>
-std::map<cool::ValidityKey, T> CoolQuery::getLumiIterator(const std::string& luminame, const std::string& folder_name, const std::string& tag, const cool::ChannelId& id ){
-
-  std::map<cool::ValidityKey, T> mymap;
-  cool::IFolderPtr folder_ptr = m_sourceDbPtr->getFolder(folder_name);
-  //  m_logger << Root::kWARNING << "Getting from database " << m_database << " tag " << tag << Root::GEndl; 
-  if(folder_ptr->existsChannel(id) && folder_ptr->existsUserTag(tag)){
-    cool::IObjectIteratorPtr itr = folder_ptr->browseObjects(m_VKstart, m_VKstop, id, tag);
-    while (itr->goToNext()) {
-      const cool::IRecord& payload=itr->currentRef().payload();
-      mymap.insert( std::pair<cool::ValidityKey, T>(itr->currentRef().since() ,payload[luminame].data<T>()));
-    }
-  }else if(folder_ptr->existsChannel(id) && !folder_ptr->existsUserTag(tag)){
-    // ok, tag doesn't exist, still try to use an untagged way of accessing data
-    mymap = CoolQuery::getObjMapFromFolderAtChan<T>(luminame, folder_name,id);
-  }else{
-    m_logger << Root::kWARNING << "Lumi tag " << tag << " does not exist, or Lumi channel id " << id << " does not exist in database." << Root::GEndl;
-  }
-  return mymap;
-
-}
-
-//===========================================================================
-template <class T>
-IOVData<T>
-CoolQuery::getIOVData(const std::string& obj_name, const std::string& folder_name, const cool::ChannelId& id, const std::string& tag) {
-
-  IOVData<T> mydata;
-
-  cool::IFolderPtr folder_ptr = m_sourceDbPtr->getFolder(folder_name);
-  cool::ChannelSelection chsel(id);
-  if(!folder_ptr->existsChannel(id)){
-    m_logger << Root::kWARNING << "Channel " << id << " does not exist in database " << folder_name << "!" << Root::GEndl; 
-    return mydata;
-  }
-
-  // Try with or without tag
-  cool::IObjectIteratorPtr itr;
-  if (folder_ptr->existsUserTag(tag)) {
-    itr = folder_ptr->browseObjects(m_VKstart, m_VKstop, id, tag);
-  } else {
-    itr = folder_ptr->browseObjects(m_VKstart, m_VKstop, id);
-  }
-
-  while (itr->goToNext()) {
-    IOVTime since, until;
-    since.setRETime(itr->currentRef().since());
-    until.setRETime(itr->currentRef().until());
-
-    IOVRange range(since, until);
-
-    const cool::IRecord& payload=itr->currentRef().payload();
-
-    mydata.add( range, payload[obj_name].data<T>() );
-  }
-
-  return  mydata;
-}
-
-
-
-#endif //> COOLQUERY_H
-
-
diff --git a/LumiBlock/LumiBlockComps/LumiBlockComps/CreateAANTFromLumiBlockCollection.h b/LumiBlock/LumiBlockComps/LumiBlockComps/CreateAANTFromLumiBlockCollection.h
deleted file mode 100755
index 7e3d69b1fd7aa285f2fa3ecd72c6bd3760bde805..0000000000000000000000000000000000000000
--- a/LumiBlock/LumiBlockComps/LumiBlockComps/CreateAANTFromLumiBlockCollection.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
-*/
-
-#ifndef CREATEAANTFROMLUMIBLOCKCOLLECTION_H
-#define CREATEAANTFROMLUMIBLOCKCOLLECTION_H
-
-// *****************************************************************
-//
-// Algorithm:  CreateAANTFromLumiBlockCollection.hh
-// Author: Balint Radics <radbal@cern.ch>
-// Created: May 2009
-// Description:
-//     This algorithm is used to create an LumiBlockCollection_p1
-//     in an output Root file using THistSvc
-//
-// *********************************************************************
-
-
-// LumiBlock and IOV includes
-#include "AthenaKernel/IOVTime.h"
-#include "LumiBlockData/LumiBlockCollection.h"
-#include "LumiBlockTPCnv/LumiBlockCollection_p1.h"
-#include "LumiBlockTPCnv/LumiBlockCollectionCnv_p1.h"
-#include "LumiBlockTPCnv/LumiBlockRange_p1.h"
-#include "LumiBlockTPCnv/LumiBlockRangeCnv_p1.h"
-
-// STL includes
-#include <vector>
-#include <stdint.h>
-
-// Framework includes
-#include "GaudiKernel/ITHistSvc.h" 
-#include "GaudiKernel/Algorithm.h"
-
-
-// ROOT includes
-#include "TTree.h"
-
-class StoreGateSvc;
-
-class CreateAANTFromLumiBlockCollection:public Algorithm {
-public:
-  CreateAANTFromLumiBlockCollection (const std::string& name, ISvcLocator* pSvcLocator);
-  StatusCode initialize();
-  StatusCode execute();
-  StatusCode clear();
-  StatusCode finalize();
-
-private:
-
-  StringProperty  m_LBColl_name;
-
-  StoreGateSvc* m_storeGate;    //cache the StoreGateSvc ptr for efficiency
-  StoreGateSvc* m_metaStore;    //cache the StoreGateSvc ptr for efficiency
-  ITHistSvc * tHistSvc;
-
-  LumiBlockCollection*  m_tempLBColl;
-
-  LumiBlockCollectionCnv_p1 m_lbc_conv;
-  LumiBlockRangeCnv_p1 m_lbr_conv;
-  
-  LumiBlockCollection_p1 *m_lbc;
-  LumiBlockRange_p1 *m_lbr;
-
-  std::vector<double> * m_vectord;
-
-  TTree * MetaDataTree;
-  TTree * UserDataTree;
-
-};
-
-#endif // end of CREATEAANTFROMLUMIBLOCKCOLLECTION_H
diff --git a/LumiBlock/LumiBlockComps/LumiBlockComps/CreateLumiBlockCollectionFromFile.h b/LumiBlock/LumiBlockComps/LumiBlockComps/CreateLumiBlockCollectionFromFile.h
index 19a79c05dedcb4d648bb4c1735ae5656293a29d2..99532f15bfd454ea072853e4d158ba8c938bfcb8 100755
--- a/LumiBlock/LumiBlockComps/LumiBlockComps/CreateLumiBlockCollectionFromFile.h
+++ b/LumiBlock/LumiBlockComps/LumiBlockComps/CreateLumiBlockCollectionFromFile.h
@@ -19,6 +19,8 @@
 #include "GaudiKernel/Algorithm.h"
 #include "AthenaKernel/IOVTime.h"
 #include <vector>
+#include <map>
+#include <utility>
 #include <stdint.h>
 
 #include "LumiBlockData/LumiBlockCollection.h"
@@ -33,7 +35,7 @@ public:
   StatusCode initialize();
   StatusCode execute();
   StatusCode finalize();
-  StatusCode fillLumiBlockCollection(std::vector<IOVTime>* coll, std::string key);
+  StatusCode fillLumiBlockCollection();
 
   /// Incident service handle listening for BeginFile and EndFile.
   void handle(const Incident& incident);
@@ -43,17 +45,23 @@ protected:
   /// Fill metaDataStore and ntuples
   void finishUp();
 
-  std::vector<IOVTime> m_LumiBlockColl;  //collection of (run,lumiblock) pairs
-  std::vector<IOVTime> m_cacheLBColl;  //collection of (run,lumiblock) pairs
-                                       //for files that have closed properly 
- 
+  // Here is the transient storage of the LB metadata
+  typedef std::pair<uint32_t,uint32_t> inOut;
+  typedef std::map<IOVTime,inOut> RLBMap;
+  RLBMap m_LumiBlockInfo;
+
   uint32_t m_lastRun;           // remember run from last event
   uint32_t m_lastLumiBlock;     // remember lumiBlock from last event
+  IOVTime m_lastIOVTime;        // could remake from the previous 2, but for efficiency save it
+  bool m_checkEventsExpected;   
+
   StoreGateSvc* m_storeGate;    //cache the StoreGateSvc ptr for efficiency
   StoreGateSvc* m_metaStore;    //cache the StoreGateSvc ptr for efficiency
  
   StringProperty  m_LBColl_name;
   StringProperty  m_unfinishedLBColl_name;
+  StringProperty  m_suspectLBColl_name;
 };
 
+
 #endif // end of CREATELUMIBLOCKCOLLECTIONFROMFILE_H
diff --git a/LumiBlock/LumiBlockComps/LumiBlockComps/ILuminosityTool.h b/LumiBlock/LumiBlockComps/LumiBlockComps/ILuminosityTool.h
index 5a0d2e4323118f99a1d860b412928e2f243f1faf..0276da703b5ca9b4aa3d11b0afb162dc62277fb5 100644
--- a/LumiBlock/LumiBlockComps/LumiBlockComps/ILuminosityTool.h
+++ b/LumiBlock/LumiBlockComps/LumiBlockComps/ILuminosityTool.h
@@ -53,7 +53,7 @@ class ILuminosityTool: virtual public IAlgTool {
   virtual float lbLuminosityPerBCID(unsigned int bcid) = 0;
 
   // Conversion factor from OLC.  lumiPerBCID/muToLumi = interactionsPerCrossingPerBCID
-  virtual float muToLumi() const = 0;
+  virtual float muToLumi() = 0;
 
   // Callback function called when any cached data is invalidated, 
   // Can be used to provide callbacks to other functions
diff --git a/LumiBlock/LumiBlockComps/LumiBlockComps/LumiBlockCollectionConverter.h b/LumiBlock/LumiBlockComps/LumiBlockComps/LumiBlockCollectionConverter.h
deleted file mode 100644
index b35131b4f20a3af91121858f08bf5881ab815deb..0000000000000000000000000000000000000000
--- a/LumiBlock/LumiBlockComps/LumiBlockComps/LumiBlockCollectionConverter.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
-*/
-
-
-/**********************************************************************************
- * Class  : LumiBlockCollectionConverter                                                       *
- *                                                                                *
- * Authors (alphabetical):                                                        *
- *      Max Baak <mbaak@cern.ch> - CERN, Switzerland                              *
- **********************************************************************************/
-
-#ifndef __LumiBlockCollectionConverter__
-#define __LumiBlockCollectionConverter__
-
-#include <map>
-#include <vector>
-#include "TString.h"
-
-namespace Root {
-  class TGoodRunsList;
-  class TGRLCollection;
-  class TGoodRunsListReader;
-  class TGoodRunsListWriter;
-}
-
-class LumiBlockCollection;
-
-typedef std::map<TString,TString> grlmetadatamap;
-
-class LumiBlockCollectionConverter {
-   
- public:
-
-  LumiBlockCollectionConverter();      
-  virtual ~LumiBlockCollectionConverter();
-
-  LumiBlockCollection* GetLumiBlockCollection(const Root::TGoodRunsList& grl, std::map<TString,TString>& metadata, TString& version) ;
-  LumiBlockCollection* GetLumiBlockCollection(const Root::TGoodRunsList& grl) const;
-  LumiBlockCollection* GetLumiBlockCollection(const char* xmlfile) const;
-  LumiBlockCollection* GetLumiBlockCollectionFromString( const TString& xmlstring ) const;
-
-  void CreateXMLFile(const Root::TGoodRunsList& grl, const TString& xmlfilename="", const TString& prefix="" ) const;
-  void CreateXMLFile(const Root::TGRLCollection& grlcollection, const char* xmlfilename) const;
-  void CreateXMLFile(const LumiBlockCollection& lbc, const grlmetadatamap& metadata = grlmetadatamap(), const char* version="", 
-                     const TString& xmlfilename="", const TString& prefix="" ) const;
-  void CreateXMLFiles(const Root::TGRLCollection& grlcollection, const char* prefix) const;
-
-  const TString GetXMLString(const Root::TGoodRunsList& grl) const;
-  const TString GetXMLString(const Root::TGRLCollection& grlcollection) const;
-  const TString GetXMLString(const LumiBlockCollection& lbc, const grlmetadatamap& metadata = grlmetadatamap(), const char* version="" ) const;
-  const std::vector<TString> GetXMLStrings(const Root::TGRLCollection& grlcollection) const;
-
-  Root::TGoodRunsList* GetGRLObject( const LumiBlockCollection& lbc, const grlmetadatamap& metadata = grlmetadatamap(), const char* version="" ) const;
-  Root::TGoodRunsList* GetGRLObject( const char* xmlfile ) const;
-  Root::TGoodRunsList* GetGRLObjectFromString( const TString& xmlstring ) const;
-
-  Root::TGRLCollection* GetGRLCollection( const char* xmlfile ) const;
-  Root::TGRLCollection* GetGRLCollectionFromString( const TString& xmlstring ) const;
-
-  const TString GetSuggestedName( const LumiBlockCollection& lbc ) const ;
-
- private:
-
-  Root::TGoodRunsListReader* m_reader;   
-  Root::TGoodRunsListWriter* m_writer;
-
-};
-
-#endif
-
diff --git a/LumiBlock/LumiBlockComps/LumiBlockComps/LumiBlockCompsDict.h b/LumiBlock/LumiBlockComps/LumiBlockComps/LumiBlockCompsDict.h
index 772620f71af973d66727bf2c26af69017628c0e2..ceb3b4a4989663628039252900b12a97c6a9eaa4 100644
--- a/LumiBlock/LumiBlockComps/LumiBlockComps/LumiBlockCompsDict.h
+++ b/LumiBlock/LumiBlockComps/LumiBlockComps/LumiBlockCompsDict.h
@@ -4,3 +4,6 @@
 
 #include "LumiBlockComps/ILumiCalcSvc.h"
 #include "LumiBlockComps/ILumiBlockMetaDataTool.h"
+#include "LumiBlockComps/ILuminosityTool.h"
+#include "LumiBlockComps/ILumiBlockMuTool.h"
+#include "LumiBlockComps/ITrigLivefractionTool.h"
diff --git a/LumiBlock/LumiBlockComps/LumiBlockComps/LumiBlockMuWriter.h b/LumiBlock/LumiBlockComps/LumiBlockComps/LumiBlockMuWriter.h
index 8b5bce28bd5b6da434fdc8a8115daec8aff1a43a..396f7ed42a6ba2135db5306f9736f33d88bf2a9a 100644
--- a/LumiBlock/LumiBlockComps/LumiBlockComps/LumiBlockMuWriter.h
+++ b/LumiBlock/LumiBlockComps/LumiBlockComps/LumiBlockMuWriter.h
@@ -14,7 +14,7 @@
 #include "AthenaBaseComps/AthAlgorithm.h"
 #include "GaudiKernel/ToolHandle.h"
 #include "LumiBlockComps/ILuminosityTool.h"
-#include "LumiBlockComps/CoolQuery.h"
+#include "LumiCalc/CoolQuery.h"
 
 #include <string>
 
diff --git a/LumiBlock/LumiBlockComps/src/LumiCalcSvc.h b/LumiBlock/LumiBlockComps/LumiBlockComps/LumiCalcSvc.h
similarity index 97%
rename from LumiBlock/LumiBlockComps/src/LumiCalcSvc.h
rename to LumiBlock/LumiBlockComps/LumiBlockComps/LumiCalcSvc.h
index 75f99ab0c50be2b258434d65445bf39d7248e69a..9967c49feab77963767345356188e1ffb7f2a4f1 100644
--- a/LumiBlock/LumiBlockComps/src/LumiCalcSvc.h
+++ b/LumiBlock/LumiBlockComps/LumiBlockComps/LumiCalcSvc.h
@@ -24,7 +24,8 @@
 #include "GaudiKernel/ISvcLocator.h"
 #include "GaudiKernel/ITHistSvc.h" 
 #include "AthenaBaseComps/AthService.h"
-#include "LumiCalculator.h"
+#include "LumiCalc/LumiCalculator.h"
+#include "LumiBlockComps/ILumiCalcSvc.h"
 
 class TTree;
 class ILumiCalcSvc;
diff --git a/LumiBlock/LumiBlockComps/src/LumiCalibrator.h b/LumiBlock/LumiBlockComps/LumiBlockComps/LumiCalibrator.h
similarity index 100%
rename from LumiBlock/LumiBlockComps/src/LumiCalibrator.h
rename to LumiBlock/LumiBlockComps/LumiBlockComps/LumiCalibrator.h
diff --git a/LumiBlock/LumiBlockComps/src/LuminosityTool.h b/LumiBlock/LumiBlockComps/LumiBlockComps/LuminosityTool.h
similarity index 84%
rename from LumiBlock/LumiBlockComps/src/LuminosityTool.h
rename to LumiBlock/LumiBlockComps/LumiBlockComps/LuminosityTool.h
index e12c69fe9f274d77a45af0531650feb7a73bf423..11475015d2b95b2c5f4d05d5b56ada9fd70eb2ac 100644
--- a/LumiBlock/LumiBlockComps/src/LuminosityTool.h
+++ b/LumiBlock/LumiBlockComps/LumiBlockComps/LuminosityTool.h
@@ -18,7 +18,12 @@
 #include "StoreGate/DataHandle.h"
 
 #include "LumiBlockComps/ILuminosityTool.h"
-#include "LumiCalibrator.h"
+
+#include "GaudiKernel/ToolHandle.h"
+#include "CoolLumiUtilities/IFillParamsTool.h"
+#include "CoolLumiUtilities/IBunchGroupTool.h"
+#include "CoolLumiUtilities/IBunchLumisTool.h"
+#include "CoolLumiUtilities/IOnlineLumiCalibrationTool.h"
 
 #include <string>
 #include <vector>
@@ -60,7 +65,7 @@ class LuminosityTool: public AthAlgTool, virtual public ILuminosityTool {
   float lbLuminosityPerBCID(unsigned int bcid);
 
   // Conversion factor from OLC.  lumiPerBCID/muToLumi = interactionsPerCrossingPerBCID
-  float muToLumi() const;
+  float muToLumi();
 
   // Functions
   StatusCode initialize();
@@ -74,9 +79,6 @@ class LuminosityTool: public AthAlgTool, virtual public ILuminosityTool {
 
   // Callback functions
   virtual StatusCode updateAvgLumi(IOVSVC_CALLBACK_ARGS);
-  virtual StatusCode updateCalibrations(IOVSVC_CALLBACK_ARGS);
-  virtual StatusCode updateFillparams(IOVSVC_CALLBACK_ARGS);
-  virtual StatusCode updateBunchgroup(IOVSVC_CALLBACK_ARGS);
   virtual StatusCode updateLBLB(IOVSVC_CALLBACK_ARGS);
 
   // Per-BCID Luminosity update function
@@ -100,11 +102,18 @@ class LuminosityTool: public AthAlgTool, virtual public ILuminosityTool {
   std::string m_lumiFolderName; // Default to /TRIGGER/OFLLUMI/LBLESTOFL 
   unsigned long m_lumiChannel;  // Default to 0 - preferred
 
+  //std::string m_fillparamsFolderName;
+  ToolHandle<IFillParamsTool> m_fillParamsTool;
+
+  //std::string m_bunchlumisFolderName;
+  ToolHandle<IBunchLumisTool> m_bunchLumisTool;
+
+  //std::string m_bunchgroupFolderName;
+  ToolHandle<IBunchGroupTool> m_bunchGroupTool;
+
   // Folders for per-BCID calculation
-  std::string m_calibrationFolderName;
-  std::string m_fillparamsFolderName;
-  std::string m_bunchlumisFolderName;
-  std::string m_bunchgroupFolderName;
+  ToolHandle<IOnlineLumiCalibrationTool> m_onlineLumiCalibrationTool;
+
   std::string m_lblbFolderName;
 
   // Flag to indicate that cached data has changed
@@ -117,12 +126,8 @@ class LuminosityTool: public AthAlgTool, virtual public ILuminosityTool {
   unsigned int m_luminousBunches;
   std::vector<unsigned int> m_luminousBunchesVec;
 
-  // Bunchgroup data
-  unsigned int m_bgBunches;
-  std::vector<unsigned int> m_bgBunchesVec;
-
   // Calibration data
-  std::map<unsigned int, LumiCalibrator> m_cali;
+  // std::map<unsigned int, LumiCalibrator> m_cali;
 
 };
 
diff --git a/LumiBlock/LumiBlockComps/LumiBlockComps/ReplicaSorter.h b/LumiBlock/LumiBlockComps/LumiBlockComps/ReplicaSorter.h
deleted file mode 100644
index 272c9de2c2e1df9530d3ed115c29b0929d76268f..0000000000000000000000000000000000000000
--- a/LumiBlock/LumiBlockComps/LumiBlockComps/ReplicaSorter.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
-*/
-
-// ReplicaSorter - class implementing CORAL IReplicaSortingAlgorithm 
-// for AtlCoolCopy, analogue of Athena DBReplicaSvc
-// Richard Hawkings, 26/11/07
-
-#include <string>
-#include "RelationalAccess/IReplicaSortingAlgorithm.h"
-
-class ReplicaSorter : virtual public coral::IReplicaSortingAlgorithm {
- public:
-  ReplicaSorter();
-  void sort(std::vector<const coral::IDatabaseServiceDescription*>& 
-	    replicaSet);
- private:
-  bool readConfig();
-  FILE* findFile(const std::string filename, const std::string pathvar);
-  std::string m_hostname;
-  typedef std::pair<std::string,int> ServerPair;
-  typedef std::vector< ServerPair > ServerMap;
-  ServerMap m_servermap;
-  bool m_frontiergen;
-};
diff --git a/LumiBlock/LumiBlockComps/src/TrigLivefractionTool.h b/LumiBlock/LumiBlockComps/LumiBlockComps/TrigLivefractionTool.h
similarity index 100%
rename from LumiBlock/LumiBlockComps/src/TrigLivefractionTool.h
rename to LumiBlock/LumiBlockComps/LumiBlockComps/TrigLivefractionTool.h
diff --git a/LumiBlock/LumiBlockComps/LumiBlockComps/selection.xml b/LumiBlock/LumiBlockComps/LumiBlockComps/selection.xml
index 90340cd74c9dc6cd07ef208174f51a736245c8b5..1241df958124680da66a276afdd02702f6ec36ac 100644
--- a/LumiBlock/LumiBlockComps/LumiBlockComps/selection.xml
+++ b/LumiBlock/LumiBlockComps/LumiBlockComps/selection.xml
@@ -2,5 +2,8 @@
 
    <class name="ILumiCalcSvc"/>
    <class name="ILumiBlockMetaDataTool"/>
+   <class name="ILuminosityTool"/>
+   <class name="ILumiBlockMuTool"/>
+   <class name="ITrigLivefractionTool"/>
 
 </lcgdict>
diff --git a/LumiBlock/LumiBlockComps/README.command_line b/LumiBlock/LumiBlockComps/README.command_line
deleted file mode 100644
index a64f228abb9c569c936dde437e2327bb6dbec008..0000000000000000000000000000000000000000
--- a/LumiBlock/LumiBlockComps/README.command_line
+++ /dev/null
@@ -1,9 +0,0 @@
-These instructions explain how to change the iLumiCalc.exe command-line options.
-
-The code for the command-line switches are generated automatically using the gengetopt utility.
-
-1) Modify src/iLumiCalc_flags.ggo as necessary
-2) run gengetopt < iLumiCalc_flags.ggo
-3) Copy resulting cmdline.c to cmdline.cxx
-4) Add code to iLumiCalc.cxx to handle switch
-5) Proceed with cmt as usual
\ No newline at end of file
diff --git a/LumiBlock/LumiBlockComps/cmt/requirements b/LumiBlock/LumiBlockComps/cmt/requirements
index 98f64591195c84ab70803f4b60ca9d45795f6cf2..e27564ec8c6877475b8d987221e1f62d3238d098 100755
--- a/LumiBlock/LumiBlockComps/cmt/requirements
+++ b/LumiBlock/LumiBlockComps/cmt/requirements
@@ -2,58 +2,42 @@ package LumiBlockComps
 
 author Marjorie Shapiro <mdshapiro@lbl.gov>
 
-#use MinimalRunTime              MinimalRunTime-*        Control
 use AtlasPolicy			AtlasPolicy-*
 
 branches run
 
 use GaudiInterface              GaudiInterface-*     External
-use AthenaKernel                AthenaKernel-*       Control
 use LumiBlockData               LumiBlockData-*      LumiBlock
 use AthenaPoolKernel            AthenaPoolKernel-*   Database/AthenaPOOL
 use AtlasROOT                   AtlasROOT-*          External
 use LumiBlockTPCnv		LumiBlockTPCnv-*     LumiBlock/LumiBlockPers
-use GoodRunsLists		GoodRunsLists-*	     DataQuality
-use AtlasCOOL  			AtlasCOOL-*  		External
-use AtlasCORAL 			AtlasCORAL-* 		External
 use AthenaBaseComps             AthenaBaseComps-*       Control
-#use AtlasBoost                  AtlasBoost-*         External               
+use AthenaKernel                AthenaKernel-*       Control
+use AtlasCORAL 			AtlasCORAL-* 	     External
+use StoreGate                   StoreGate-*             Control
+use LumiCalc			LumiCalc-*		LumiBlock
+use CoolLumiUtilities		CoolLumiUtilities-*	Database
 
 private
-use StoreGate                   StoreGate-*          Control
+use AtlasCOOL  			AtlasCOOL-*  	     External
 use AthenaPoolUtilities         AthenaPoolUtilities-*   Database/AthenaPOOL
 use CoraCool   			CoraCool-*   		Database -no_auto_imports
 use CoolConvUtilities		CoolConvUtilities-*	Database -no_auto_imports
 use DBDataModel                 DBDataModel-*           Database/AthenaPOOL
-use EventInfo                   EventInfo-*          Event
-
-use AtlasPOOL                   AtlasPOOL-*             External
-
-public
-
-# Create a named installed library
-library LumiBlockCoolQuery CoolQuery.cxx LumiBlockCollectionConverter.cxx LumiCalculator.cxx ReplicaSorter.cxx
-apply_pattern named_installed_library library=LumiBlockCoolQuery
+use EventInfo                   EventInfo-*             Event
+use GoodRunsLists		GoodRunsLists-*	     DataQuality
 
-# Create a component library
-library LumiBlockComps CreateAANTFromLumiBlockCollection.cxx CreateLumiBlockCollectionFromFile.cxx ILumiCalcSvc.cxx LumiBlockMetaDataTool.cxx LumiCalcSvc.cxx LumiBlockMuTool.cxx LumiBlockMuWriter.cxx LumiCalibrator.cxx LuminosityTool.cxx TrigLivefractionTool.cxx LumiBlockTester.cxx components/*.cxx
-macro_append LumiBlockComps_dependencies " LumiBlockCoolQuery"
-apply_pattern component_library
+# Create a dual_use library since the lcgdict pattern doesn't work with component libraries using cmake.
+# This pollutes the linkopts for clients, but is otherwise harmless.
+apply_pattern dual_use_library files=*.cxx
 
 apply_pattern declare_python_modules files="*.py"
-#apply_pattern declare_joboptions files="CreateLumiBlocks_jobOptions.py QueryExample.py"
 apply_pattern declare_joboptions files="*.py"
-apply_pattern declare_scripts files="LumiCalc.py"
-
-# Create a binary executable
-application iLumiCalc iLumiCalc.cxx cmdline.cxx CoolQuery.cxx LumiBlockCollectionConverter.cxx LumiCalculator.cxx ReplicaSorter.cxx
-macro_append iLumiCalc_dependencies " LumiBlockCoolQuery"
-macro_append iLumiCalc_use_linkopts " -L$(ROOTSYS)/lib -lCintex"
+#apply_pattern declare_scripts files="LumiCalc.py"
 
 # Create dictionary for LumiBlockComps
 private
-use AtlasReflex  AtlasReflex-*  External -no_auto_imports
+use AtlasReflex  AtlasReflex-*  External
 
-##apply_pattern lcgdict dict=LumiBlockComps selectionfile=selection.xml options=" -I$(LUMIBLOCKCOMPSROOT)/src" headerfiles="../LumiBlockComps/ILumiCalcSvc.h"
 apply_pattern lcgdict dict=LumiBlockComps selectionfile=selection.xml options=" -I$(LUMIBLOCKCOMPSROOT)/src" headerfiles="../LumiBlockComps/LumiBlockCompsDict.h"
 
diff --git a/LumiBlock/LumiBlockComps/python/LuminosityToolDefault.py b/LumiBlock/LumiBlockComps/python/LuminosityToolDefault.py
index 0947ae5326408530de4440143d1fdadab41ee3e2..3aaa02791bfbcd9ae20104ffee10dd36e08bb211 100644
--- a/LumiBlock/LumiBlockComps/python/LuminosityToolDefault.py
+++ b/LumiBlock/LumiBlockComps/python/LuminosityToolDefault.py
@@ -6,46 +6,119 @@ from AthenaCommon.AppMgr import ServiceMgr as svcMgr
 
 from LumiBlockComps.LumiBlockCompsConf import LuminosityTool
 
-class LuminosityToolDefault(LuminosityTool):
-    """Default LuminosityTool for offline"""
-    
-    __slots__ = []
-    def __init__(self, name='LuminosityTool'):
-        super (LuminosityToolDefault, self).__init__(name)
-        
-        mlog = logging.getLogger(name)
-
-        # Set up DB configuration
-        from IOVDbSvc.CondDB import conddb
-        from InDetRecExample.InDetJobProperties import InDetFlags
-
-        # Check if this is express stream or bulk
-        if not InDetFlags.useBeamConstraint():
-            folder  = "/TRIGGER/LUMI/LBLESTONL"
-            conddb.addFolder('TRIGGER_ONL', folder)
-        else:
-            folder = "/TRIGGER/OFLLUMI/LBLESTOFL"
-            conddb.addFolder('TRIGGER_OFL', folder)
-
-        # Folders for per-BCID calculation (all online folders)
-        conddb.addFolder('TDAQ', '/TDAQ/OLC/CALIBRATIONS')
-        conddb.addFolder('TDAQ', '/TDAQ/OLC/LHC/FILLPARAMS')
-        conddb.addFolder('TDAQ', '/TDAQ/OLC/BUNCHLUMIS')  # This is now in COMP200
-        # conddb.addFolder('', '<db>COOLONL_TDAQ/MONP200</db> /TDAQ/OLC/BUNCHLUMIS')
+# Wrapper script to provide existing offline tool if defined or new tool if not
+def LuminosityToolDefault(name="LuminosityTool"):
+    mlog = logging.getLogger(name)
 
-        # Mistakenly created as multi-version folder, must specify HEAD
-        if not conddb.folderRequested( '/TRIGGER/LVL1/BunchGroupContent' ):
-            conddb.addFolderWithTag('TRIGGER', '/TRIGGER/LVL1/BunchGroupContent', 'HEAD')
-            pass
+    if hasattr(svcMgr.ToolSvc, name):
+        # re-use previously supported tool
+        mlog.info("LuminosityToolDefault returning existing tool %s" % name)
+        return getattr(svcMgr.ToolSvc, name)
 
-        # Other folders needed by LuminosityTool
-        conddb.addFolder('TRIGGER', '/TRIGGER/LUMI/LBLB')
+    from IOVDbSvc.CondDB import conddb
+    if conddb.dbdata == "COMP200":
+        return LuminosityToolOfflineRun1(name)
 
-        self.LumiFolderName = folder
+    elif conddb.dbdata == "CONDBR2":
+        return LuminosityToolOfflineRun2(name)
 
-        mlog.info("Created default %s using folder %s" % (name, folder))
+    else:
+        mlog.warning("LuminosityToolDefault can't resolve conddb.dbdata = %s, assume Run2!" % conddb.dbdata)
+        return LuminosityToolOfflineRun2(name)
 
+# Configuration for offline default tool used in Run1
+# Change logic so that folders names are blank by default and must be configured
+def LuminosityToolOfflineRun1(name="LuminosityTool"):
+        
+    mlog = logging.getLogger(name)
+
+    # Instantiate new tool
+    lumiTool = LuminosityTool(name)
+
+    # Now configure DB based on the environment
+    from IOVDbSvc.CondDB import conddb
+    from InDetRecExample.InDetJobProperties import InDetFlags
+
+    # Check if this is express stream or bulk
+    if not InDetFlags.useBeamConstraint():
+        lumiFolder  = "/TRIGGER/LUMI/LBLESTONL"
+        if not conddb.folderRequested( lumiFolder ):
+            conddb.addFolder('TRIGGER_ONL', lumiFolder)
+            mlog.info("LuminosityToolDefault requested %s", lumiFolder)
+
+    else:
+        lumiFolder = "/TRIGGER/OFLLUMI/LBLESTOFL"
+        if not conddb.folderRequested( lumiFolder ):
+            conddb.addFolder('TRIGGER_OFL', lumiFolder)
+            mlog.info("LuminosityToolDefault requested %s", lumiFolder)
+
+    lumiTool.LumiFolderName = lumiFolder
+
+    # Other folders needed by LuminosityTool
+    folder = "/TRIGGER/LUMI/LBLB"
+    if not conddb.folderRequested( folder ):
+        conddb.addFolder('TRIGGER', folder)
+        mlog.info("LuminosityToolDefault requested %s", folder)
+
+    lumiTool.LBLBFolderName = folder
+
+
+    # Configure tools
+    toolName = "FillParamsTool"
+    lumiTool.FillParamsTool = toolName
+    if not hasattr(svcMgr.ToolSvc, toolName):
+        from CoolLumiUtilities.FillParamsToolDefault import FillParamsToolDefault
+        svcMgr.ToolSvc += FillParamsToolDefault(toolName)
+        mlog.info("LuminosityToolDefault added tool %s", toolName)
+
+    toolName = "BunchLumisTool"
+    lumiTool.BunchLumisTool = toolName
+    if not hasattr(svcMgr.ToolSvc, toolName):
+        from CoolLumiUtilities.BunchLumisToolDefault import BunchLumisToolDefault
+        svcMgr.ToolSvc += BunchLumisToolDefault(toolName)
+        mlog.info("LuminosityToolDefault added tool %s", toolName)
+
+    toolName = "BunchGroupTool"
+    lumiTool.BunchGroupTool = toolName
+    if not hasattr(svcMgr.ToolSvc, toolName):
+        from CoolLumiUtilities.BunchGroupToolDefault import BunchGroupToolDefault
+        svcMgr.ToolSvc += BunchGroupToolDefault(toolName)
+        mlog.info("LuminosityToolDefault added tool %s", toolName)
+
+    toolName = "OnlineLumiCalibrationTool"
+    lumiTool.OnlineLumiCalibrationTool = toolName
+    if not hasattr(svcMgr.ToolSvc, toolName):
+        from CoolLumiUtilities.OnlineLumiCalibrationToolDefault import OnlineLumiCalibrationToolDefault
+        svcMgr.ToolSvc += OnlineLumiCalibrationToolDefault(toolName)
+        mlog.info("LuminosityToolDefault added tool %s", toolName)
+
+
+    mlog.info("Created Run1 %s using folder %s" % (name, lumiFolder))
+    return lumiTool
+
+# Configuration for offline default tool used in Run2
+def LuminosityToolOfflineRun2(name="LuminosityTool"):
+        
+    mlog = logging.getLogger(name)
+
+    # Set up DB configuration
+    #from IOVDbSvc.CondDB import conddb
+    #from InDetRecExample.InDetJobProperties import InDetFlags
+
+    # Will eventually use our new online/offline folder, but not ready
+    # Set up with dummy configuration for now (this is also now the default)
+    lumiTool = LuminosityTool(name)
+    lumiTool.LBLBFolderName = ''
+
+    lumiTool.LumiFolderName = ''
+    lumiTool.FillParamsTool = ''
+    lumiTool.BunchLumisTool = ''
+    lumiTool.BunchGroupTool = ''
+    lumiTool.OnlineLumiCalibrationTool = ''
+    
+    mlog.info("Created Run2 %s using a dummy Run2 configuration!" % name)
 
+    return lumiTool
 
 class LuminosityToolOnline(LuminosityTool):
     """LuminosityTool for use in the online/HLT"""
@@ -57,16 +130,30 @@ class LuminosityToolOnline(LuminosityTool):
         mlog = logging.getLogger(name)
         
         from IOVDbSvc.CondDB import conddb
+        if conddb.dbdata == "COMP200": # Run1
+            folder  = "/TRIGGER/LUMI/LBLESTONL"
+            conddb.addFolder('TRIGGER_ONL', folder)
+            #conddb.addFolder('TDAQ', '/TDAQ/OLC/CALIBRATIONS')
+            #conddb.addFolder('TDAQ', '/TDAQ/OLC/BUNCHLUMIS')
+
+            self.LumiFolderName = folder
+            self.LBLBFolderName = ''
 
-        folder  = "/TRIGGER/LUMI/LBLESTONL"
+            self.FillParamsTool = ''
+            self.BunchLumisTool = ''
+            self.BunchGroupTool = ''
+            self.OnlineLumiCalibrationTool = ''
         
-        conddb.addFolder('TRIGGER_ONL', folder)
-        conddb.addFolder('TDAQ', '/TDAQ/OLC/CALIBRATIONS')
-        conddb.addFolder('TDAQ', '/TDAQ/OLC/BUNCHLUMIS')
-
-        self.LumiFolderName = folder
-        self.FillparamsFolderName = ''
-        self.BunchgroupFolderName = ''
-        self.LBLBFolderName = ''
+            mlog.info("Created online %s using folder %s" % (name, folder))
+
         
-        mlog.info("Created online %s using folder %s" % (name, folder))
+        elif conddb.dbdata == "CONDBR2": # Run2
+            # Folder names are now blank by default
+            mlog.info("Created online %s using a dummy Run2 configuration!" % name)
+
+        else:
+            mlog.warning("LuminosityToolDefault can't resolve conddb.dbdata = %s, assume Run2!" % conddb.dbdata)
+            mlog.info("Created online %s using a dummy Run2 configuration!" % name)
+
+
+
diff --git a/LumiBlock/LumiBlockComps/python/TrigLivefractionToolDefault.py b/LumiBlock/LumiBlockComps/python/TrigLivefractionToolDefault.py
index 3f732f0e2a768cdde48a510ecfb2e8753f0d2ce4..ae679e0a491db59408d5d4a3fc63896a9c8025c5 100644
--- a/LumiBlock/LumiBlockComps/python/TrigLivefractionToolDefault.py
+++ b/LumiBlock/LumiBlockComps/python/TrigLivefractionToolDefault.py
@@ -2,21 +2,44 @@
 
 from AthenaCommon.Logging import logging
 from AthenaCommon.SystemOfUnits import *
+from AthenaCommon.AppMgr import ServiceMgr as svcMgr
 
 # Configuration for LivefractionTool
 # Also needs LuminosityTool to be configured (should be in RecExCommon) 
-def TrigLivefractionToolDefault(name='TrigLivefractionToolDefault'):
+def TrigLivefractionToolDefault(name='TrigLivefractionTool'):
     mlog = logging.getLogger(name)
     # mlog.warning("TrigLivefractionToolDefault called")
 
+    # Check if tool already exists
+    if hasattr(svcMgr.ToolSvc, name):
+        # re-use previously configured tool
+        mlog.info("TrigLivefractionToolDefault returning existing tool %s" % name)
+        return getattr(svcMgr.ToolSvc, name)
+
     # Set up DB configuration
     from IOVDbSvc.CondDB import conddb
     
-    # Mistakenly created as multi-version folder, must specify HEAD
-    conddb.addFolderWithTag('TRIGGER', '/TRIGGER/LUMI/PerBcidDeadtime', 'HEAD')
 
     # Add the luminosity tool as a public tool
     from LumiBlockComps.LumiBlockCompsConf import TrigLivefractionTool
-    liveTool = TrigLivefractionTool("TrigLivefractionTool")
+    liveTool = TrigLivefractionTool(name)
+
+    if conddb.dbdata == "COMP200":
+        liveTool.DeadtimeFolderName = '/TRIGGER/LUMI/PerBcidDeadtime'
+        # Mistakenly created as multi-version folder, must specify HEAD
+        conddb.addFolderWithTag('TRIGGER', '/TRIGGER/LUMI/PerBcidDeadtime', 'HEAD')
+        liveTool.LuminosityTool = 'LuminosityTool'
+
+    elif conddb.dbdata == "CONDBR2":
+        liveTool.DeadtimeFolderName = ''
+        liveTool.LuminosityTool = ''
+
+    else:
+        mlog.warning("TrigLivefractionToolDefault can't resolve conddb.dbdata = %s, assume Run2!" % conddb.dbdata)
+        liveTool.DeadtimeFolderName = ''
+        liveTool.LuminosityTool = ''
+
+
 
     return liveTool
+
diff --git a/LumiBlock/LumiBlockComps/share/LumiBlockTesterExample.py b/LumiBlock/LumiBlockComps/share/LumiBlockTesterExample.py
index 984375186413e914b5b26291401002770dec97ab..c4d3958368ab233173ba9483bcc9a0e031a6e3c5 100644
--- a/LumiBlock/LumiBlockComps/share/LumiBlockTesterExample.py
+++ b/LumiBlock/LumiBlockComps/share/LumiBlockTesterExample.py
@@ -7,7 +7,9 @@ from AthenaCommon.AthenaCommonFlags import athenaCommonFlags as af
 af.FilesInput = [
 #    "/afs/cern.ch/user/j/jboyd/gencomm/ForEric/data11_7TeV.00186156.express_express.recon.AOD.f391._lb0535._SFO-ALL._0001.1"
 #    "/afs/cern.ch/atlas/maxidisk/d36/lumiJuly2010/data10_7TeV.00152166.physics_MinBias.merge.AOD.r1239_p134_tid129143_00/AOD.129143._000120.pool.root.1"
-    "root://eosatlas///eos/atlas/atlasdatadisk/data11_7TeV/AOD/f413_m1019/data11_7TeV.00191381.physics_JetTauEtmiss.merge.AOD.f413_m1019/data11_7TeV.00191381.physics_JetTauEtmiss.merge.AOD.f413_m1019._lb0502-lb0521._0001.1"
+#    "root://eosatlas///eos/atlas/atlasdatadisk/data11_7TeV/AOD/f413_m1019/data11_7TeV.00191381.physics_JetTauEtmiss.merge.AOD.f413_m1019/data11_7TeV.00191381.physics_JetTauEtmiss.merge.AOD.f413_m1019._lb0502-lb0521._0001.1"
+#"root://eosatlas///eos/atlas/atlasdatadisk/data12_8TeV/AOD/r4768/data12_8TeV.00200805.physics_MinBias.recon.AOD.r4768_tid01304347_00/AOD.01304347._003283.pool.root.1"
+"root://eosatlas///eos/atlas/atlasproddisk/data12_8TeV/AOD/r4065/data12_8TeV.00213900.physics_Bphysics.recon.AOD.r4065_tid01228278_00/AOD.01228278._003644.pool.root.1"
 ]
 
 #af.EvtMax=-1 # number of event to process
@@ -18,14 +20,14 @@ af.EvtMax=100 # number of event to process
 from RecExConfig.RecFlags import rec
 rec.AutoConfiguration = ['everything']
 rec.readRDO = False
-rec.readESD = True
+rec.readESD = False
 rec.readAOD = True
 rec.doCBNT = False
 rec.doWriteESD = False
 rec.doWriteAOD = False
 rec.doWriteTAG = False
-rec.doDPD = True
-rec.doFileMetaData = True
+rec.doDPD = False
+rec.doFileMetaData = False
 
 # Output log setting
 OutputLevel = INFO
@@ -33,22 +35,35 @@ OutputLevel = INFO
 # main jobOption - must always be included
 include ("RecExCommon/RecExCommon_topOptions.py")
 
+# Get tools from toolSvc or create
+from AthenaCommon.AppMgr import ToolSvc
+
 # Must do tool configuration here for DB access to be autoconfigured from RecExCommon
-from LumiBlockComps.LuminosityToolDefault import LuminosityToolDefault
-lumiTool = LuminosityToolDefault()
-lumiTool.OutputLevel = DEBUG
-ToolSvc += lumiTool
+name = "LuminosityTool"
+if not hasattr(ToolSvc, name):
+    from LumiBlockComps.LuminosityToolDefault import LuminosityToolDefault
+    ToolSvc += LuminosityToolDefault(name)
+
+ToolSvc.LuminosityTool.OutputLevel = DEBUG
+# ToolSvc.LuminosityTool.FillParamsTool = ""  # Try turning something off
+
+if not hasattr(ToolSvc, "TrigLivefractionTool"):
+    from LumiBlockComps.TrigLivefractionToolDefault import TrigLivefractionToolDefault
+    ToolSvc += TrigLivefractionToolDefault("TrigLivefractionTool")
 
-from LumiBlockComps.TrigLivefractionToolDefault import TrigLivefractionToolDefault
-liveTool = TrigLivefractionToolDefault()
-liveTool.OutputLevel = DEBUG
-ToolSvc += liveTool
+#liveTool = getattr(ToolSvc, "TrigLivefractionTool")
+ToolSvc.TrigLivefractionTool.OutputLevel = DEBUG
 
+# Make some other things debug
+ToolSvc.OnlineLumiCalibrationTool.OutputLevel = DEBUG
+ToolSvc.BunchLumisTool.OutputLevel = DEBUG
+ToolSvc.FillParamsTool.OutputLevel = DEBUG
+        
 # add LumiCalcMuWriter, should only be done in RAW->ESD transform
 from LumiBlockComps.LumiBlockCompsConf import LumiBlockTester
 muTester = LumiBlockTester("LumiBlockTester")
 muTester.OutputLevel = DEBUG
-        
+
 from AthenaCommon.AlgSequence import AlgSequence
 topSequence = AlgSequence()
 topSequence += muTester
diff --git a/LumiBlock/LumiBlockComps/src/CoolQuery.cxx b/LumiBlock/LumiBlockComps/src/CoolQuery.cxx
deleted file mode 100644
index 044d4a8daac7c783f053a539e2c88a3d292a9183..0000000000000000000000000000000000000000
--- a/LumiBlock/LumiBlockComps/src/CoolQuery.cxx
+++ /dev/null
@@ -1,341 +0,0 @@
-/*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
-*/
-
-#include <limits.h>
-#include "LumiBlockComps/CoolQuery.h"
-
-//===========================================================================
-CoolQuery::CoolQuery(const std::string& database, const std::string& triggerchain): 
-  m_repsort(0),
-  m_database(database), 
-  m_triggerchain(triggerchain),
-  m_logger( "CoolQuery" ),
-  m_valid(false)
-{
-
-}
-
-//===========================================================================
-CoolQuery::~CoolQuery() {
-  if ( m_sourceDbPtr.use_count()>0 && m_sourceDbPtr->isOpen() ) {
-     m_logger << Root::kINFO << "Closing database '" << m_sourceDbPtr->databaseName() << Root::GEndl;
-     m_sourceDbPtr->closeDatabase();
-  }
-}
-
-//===========================================================================
-bool CoolQuery::openDbConn() {
-
-  m_logger << Root::kINFO << "Trying to connect to database " << m_database << "..." << Root::GEndl;
-
-  //  CoraCoolDatabaseSvc& corasvc = CoraCoolDatabaseSvcFactory::databaseService();
-
-  cool::IDatabaseSvc& databasesvc = cool::DatabaseSvcFactory::databaseService();
-  //std::cout << "Done the CoraCool initialisation" << std::endl;
-  //std::cout << "Opening CORAL database" << std::endl;
-  try {
-    m_repsort=new ReplicaSorter();
-    coral::IConnectionServiceConfiguration& csconfig=m_coralsvc.configuration();
-    csconfig.setReplicaSortingAlgorithm(*m_repsort);
-
-    m_sourceDbPtr = databasesvc.openDatabase(m_database,true);// true --> readonly
-    //    m_sourceCoraPtr=corasvc.openDatabase(m_database,true);// true --> readonly
-    //std::cout << "....database connections open OK" << std::endl;
-    return true;
-   }
-  catch (std::exception&e) {
-    m_logger << Root::kERROR << "Problem opening CORAL database: " << e.what() << Root::GEndl;
-    return false;
-  }
-  //  std::cout << "Done the database opening" << std::endl;
-  
-  // list the COOL folders found in the database
-
-//    const std::vector<std::string>& folders=m_sourceDbPtr->listAllNodes();
-//    std::cout << "COOL database has " << folders.size() << " folders defined"
-//  	    << std::endl;
-//    for (std::vector<std::string>::const_iterator itr=folders.begin();
-//         itr!=folders.end();++itr) std::cout << *itr << std::endl;
-
-  return false;
-
-}
-
-//===========================================================================
-std::string CoolQuery::transConn(const std::string& inconn) {
-  // translate simple connection string (no slash) to mycool.db with given                                                                                                              
-  // instance name, all others are left alone                                                                                                                                           
-  if (inconn.find("/")==std::string::npos) {
-    return "sqlite://X;schema=mycool.db;dbname="+inconn;
-  } else {
-    return inconn;
-  }
-}
-
-//===========================================================================
-unsigned int CoolQuery::getTriggerLevel(std::string triggername){
-
-  size_t found = triggername.find_first_of("_");
-  if(found != std::string::npos){
-    std::string s_lvl = triggername.substr(0,found);
-    if(s_lvl == "EF")return 3;
-    if(s_lvl == "L2")return 2;
-    if(s_lvl == "L1")return 1;
-  }
-
-  // Indicate no valid trigger name passed
-  return 0;
-    
-}
-
-//===========================================================================
-void CoolQuery::setIOV(const cool::ValidityKey start, const cool::ValidityKey stop){
-  m_VKstart = start;
-  m_VKstop = stop;
-}
-  
-void CoolQuery::setIOVForRun(unsigned int runnum) {
-  cool::ValidityKey run = runnum;
-  m_VKstart = (run << 32);
-  m_VKstop = ((run+1) << 32) - 1;
-}
-
-cool::Int32 CoolQuery::getL1PrescaleFromChannelId(const std::string& folder_name, const cool::ChannelId& id ){
-
-  cool::IFolderPtr folder_ptr = m_sourceDbPtr->getFolder(folder_name);
-  cool::IObjectIteratorPtr itr = folder_ptr->browseObjects(m_VKstart, m_VKstop,id);
-  itr->goToNext();
-  const cool::IRecord& payload=itr->currentRef().payload();    
-
-  return payload["Lvl1Prescale"].data<cool::Int32>();
-  
-
-}
-
-cool::Float CoolQuery::getHLTPrescaleFromChannelId(const std::string& folder_name, const cool::ChannelId& id ){
-
-  cool::IFolderPtr folder_ptr = m_sourceDbPtr->getFolder(folder_name);
-  cool::IObjectIteratorPtr itr = folder_ptr->browseObjects(m_VKstart, m_VKstop,id);
-  itr->goToNext();
-  const cool::IRecord& payload=itr->currentRef().payload();    
-
-  return payload["Prescale"].data<cool::Float>();
-
-}
-
-cool::ChannelId CoolQuery::getL1ChannelId(const std::string& trigger, const std::string& folder_name){
-
-  //  m_logger << Root::kINFO << "Getting channel id for L1 trigger [" << trigger << "] from folder [" << folder_name << "]" << Root::GEndl;
-
-  m_valid = false;
-
-  if (trigger == "") return UINT_MAX;
- 
-  cool::IFolderPtr folder_ptr = m_sourceDbPtr->getFolder(folder_name);
-  cool::IObjectIteratorPtr obj_itr=folder_ptr->browseObjects(m_VKstart,m_VKstart, cool::ChannelSelection::all());
-  // loop through all triggers
-  while (obj_itr->goToNext()){
-    const cool::IRecord& payload=obj_itr->currentRef().payload();
-    // find the L1 trigger chain
-    if(payload["ItemName"].data<std::string>() == trigger){
-      m_valid = true;
-      //      cout << "Channel id: " << obj_itr->currentRef().channelId() << endl;
-      return obj_itr->currentRef().channelId();
-    }
-  }
-
-  if(!m_valid){
-    m_logger << Root::kERROR << "Couldn't find L1 trigger [" << trigger << "] in folder [" << folder_name << "]" << Root::GEndl;
-  }
-
-
-  // Nonsense value
-  return UINT_MAX;
-}
-
-//===========================================================================
-cool::ChannelId CoolQuery::getLumiChannelId(const std::string& lumimethod, const std::string& folder_name){
-
-  m_valid = false;
-
-  if (lumimethod == "") return UINT_MAX;
- 
-  // m_logger << Root::kINFO << "Getting channel id for Lumi method: " << lumimethod << " in folder " << folder_name << Root::GEndl;
-
-  cool::IFolderPtr folder_ptr = m_sourceDbPtr->getFolder(folder_name);
-  if(folder_ptr->existsChannel(lumimethod)){
-    m_valid = true;
-    return folder_ptr->channelId(lumimethod);
-  }else{
-    m_logger << Root::kWARNING << "Couldn't find lumimethod: " << lumimethod << " in COOL database!" << Root::GEndl;
-  }
-
-  // Nonsense value
-  return UINT_MAX;
-}
-
-//===========================================================================
-cool::ChannelId CoolQuery::getHLTChannelId(const std::string& trigger, const std::string& folder_name){
-
-  // m_logger << Root::kINFO << "Getting channel id for HLT trigger [" << trigger << "] from folder [" << folder_name << "]" << Root::GEndl;
-
-  m_valid = false;
-
-  if (trigger == "") return UINT_MAX;
-
-  cool::IFolderPtr folder_ptr = m_sourceDbPtr->getFolder(folder_name);
-  cool::IObjectIteratorPtr obj_itr=folder_ptr->browseObjects(m_VKstart,m_VKstart, cool::ChannelSelection::all());
-  // loop through all triggers
-  // loop through all triggers
-  while (obj_itr->goToNext()){
-    const cool::IRecord& payload=obj_itr->currentRef().payload();
-    if(payload["ChainName"].data<std::string>() == trigger){
-      m_valid = true;
-      // m_logger << Root::kINFO << "Found channel id: " << payload["ChainCounter"].data<cool::UInt32>() << Root::GEndl;
-      return payload["ChainCounter"].data<cool::UInt32>();
-    }
-  }
-  
-  if(!m_valid){
-    m_logger << Root::kERROR << "Couldn't find HLT trigger [" << trigger << "] in folder [" << folder_name << "]" << Root::GEndl;
-  }
-
-  // Nonsense value
-  return UINT_MAX;
-}
-
-void
-CoolQuery::printL1Triggers(const std::string& folder_name) {
-
-  m_logger << Root::kINFO << "Listing available triggers [triggername(prescale, chanid)]: " << Root::GEndl;
-
-  cool::IFolderPtr folder_ptr = m_sourceDbPtr->getFolder(folder_name);
-  cool::IObjectIteratorPtr obj_itr=folder_ptr->browseObjects(m_VKstart,m_VKstart, cool::ChannelSelection::all());
-  while (obj_itr->goToNext()){
-    const cool::IRecord& payload=obj_itr->currentRef().payload();
-    m_logger << Root::kINFO << payload["ItemName"].data<std::string>()  << "(" << this->getL1PrescaleFromChannelId("/TRIGGER/LVL1/Prescales",this->getL1ChannelId(payload["ItemName"].data<std::string>(), folder_name)) << ", " << obj_itr->currentRef().channelId() << "), ";
-  }
-  m_logger << Root::kINFO << Root::GEndl;
-}
-
-void
-CoolQuery::printHLTTriggers(const std::string& folder_name) {
-
-  m_logger << Root::kINFO << "Listing available triggers [triggername(prescale, chanid)]: " << Root::GEndl;
-
-  cool::IFolderPtr folder_ptr = m_sourceDbPtr->getFolder(folder_name);
-  cool::IObjectIteratorPtr obj_itr2=folder_ptr->browseObjects(m_VKstart,m_VKstart, cool::ChannelSelection::all());
-  while (obj_itr2->goToNext()){
-    const cool::IRecord& payload2=obj_itr2->currentRef().payload();
-    //      m_logger << Root::kINFO << payload2["ChainName"].data<std::string>()  << ", ";
-    m_logger << Root::kINFO << payload2["ChainName"].data<std::string>()  << "(" << payload2["Prescale"].data<cool::Float>() << ", " << payload2["ChainCounter"].data<cool::UInt32>() << "), ";
-  }
-  m_logger << Root::kINFO << Root::GEndl;
-}
-
-bool
-CoolQuery::channelIdValid() {
-  // m_logger << Root::kINFO << "channelIdValid = " << m_valid << Root::GEndl;
-  return m_valid;
-}
-
-//===========================================================================
-std::string CoolQuery::getHLTLowerChainName(const std::string& trigger, const std::string& folder_name){
-
-  //  cout << "Getting lower chain name for trigger [" << trigger << "] from folder [" << folder_name << "] " << endl;
-  bool found = false;
-  cool::IFolderPtr folder_ptr = m_sourceDbPtr->getFolder(folder_name);
-  cool::IObjectIteratorPtr obj_itr=folder_ptr->browseObjects(m_VKstart,m_VKstart, cool::ChannelSelection::all());
-  // loop through all triggers
-  while (obj_itr->goToNext()){
-    const cool::IRecord& payload=obj_itr->currentRef().payload();
-    if(payload["ChainName"].data<std::string>() == trigger){
-      found = true;
-      return payload["LowerChainName"].data<std::string>();
-
-    }
-  }
-
-  if (!found) {
-    m_logger << Root::kERROR << "Couldn't find HLT trigger [" << trigger << "] in folder [" << folder_name << "]" << Root::GEndl;
-
-    //    m_logger << Root::kINFO << "List of triggers, hth: " << Root::GEndl;
-    //    cool::IObjectIteratorPtr obj_itr2=folder_ptr->browseObjects(m_VKstart,m_VKstart, cool::ChannelSelection::all());
-    //    while (obj_itr2->goToNext()){
-    //      const cool::IRecord& payload2=obj_itr2->currentRef().payload();
-    //      m_logger << Root::kINFO << payload2["ChainName"].data<std::string>()  << ", ";
-    //    }
-    //    m_logger << Root::kINFO << Root::GEndl;
-  }
-
-  return "";
-
-}
-
-//===========================================================================
-std::map<cool::ValidityKey, CoolQuery::LumiFolderData> 
-CoolQuery::getLumiFolderData(const std::string& folder_name, const std::string& tag, const cool::ChannelId& id ){
-
-  std::map<cool::ValidityKey, LumiFolderData> mymap;
-  LumiFolderData folderData;
-
-  cool::IFolderPtr folder_ptr = m_sourceDbPtr->getFolder(folder_name);
-  //  m_logger << Root::kWARNING << "Getting from database " << m_database << " tag " << tag << Root::GEndl; 
-  if (!folder_ptr->existsChannel(id)) {
-    m_logger << Root::kWARNING << "Lumi channel id " << id << " does not exist in database " << folder_name << "!" << Root::GEndl;
-    return mymap;
-  }
-
-  cool::IObjectIteratorPtr itr;
-  if(folder_ptr->existsUserTag(tag)) {
-    itr = folder_ptr->browseObjects(m_VKstart, m_VKstop, id, tag);
-  } else {
-    // Try without specifying tag
-    itr = folder_ptr->browseObjects(m_VKstart, m_VKstop, id);
-  }
-
-  while (itr->goToNext()) {
-    const cool::IRecord& payload=itr->currentRef().payload();
-    folderData.LBAvInstLumi = payload["LBAvInstLumi"].data<float>();
-    folderData.LBAvEvtsPerBX = payload["LBAvEvtsPerBX"].data<float>();
-    folderData.Valid = payload["Valid"].data<cool::UInt32>();
-    mymap.insert( std::pair<cool::ValidityKey, LumiFolderData>(itr->currentRef().since(), folderData));
-  }
-  
-  return mymap;
-
-}
-
-//===========================================================================
-std::map<cool::ValidityKey, CoolQuery::L1CountFolderData> 
-CoolQuery::getL1CountFolderData(const std::string& folder_name, const cool::ChannelId& id ){
-
-  std::map<cool::ValidityKey, L1CountFolderData> mymap;
-  L1CountFolderData folderData;
-
-  cool::IFolderPtr folder_ptr = m_sourceDbPtr->getFolder(folder_name);
-  //  m_logger << Root::kWARNING << "Getting from database " << m_database << " tag " << tag << Root::GEndl; 
-  if (!folder_ptr->existsChannel(id)) {
-    m_logger << Root::kWARNING << "Lumi channel id " << id << " does not exist in database " << folder_name << "!" << Root::GEndl;
-    return mymap;
-  }
-
-  cool::IObjectIteratorPtr itr;
-
-  itr = folder_ptr->browseObjects(m_VKstart, m_VKstop, id);
-
-  while (itr->goToNext()) {
-    const cool::IRecord& payload=itr->currentRef().payload();
-    folderData.BeforePrescale = payload["BeforePrescale"].data<cool::UInt63>();
-    folderData.AfterPrescale = payload["AfterPrescale"].data<cool::UInt63>();
-    folderData.L1Accept = payload["L1Accept"].data<cool::UInt63>();
-    mymap.insert( std::pair<cool::ValidityKey, L1CountFolderData>(itr->currentRef().since(), folderData));
-  }
-  
-  return mymap;
-
-}
-
-
-
diff --git a/LumiBlock/LumiBlockComps/src/CreateAANTFromLumiBlockCollection.cxx b/LumiBlock/LumiBlockComps/src/CreateAANTFromLumiBlockCollection.cxx
deleted file mode 100755
index 90fe2d00482ef9e2f9bfdf397fdd6e0c0674c739..0000000000000000000000000000000000000000
--- a/LumiBlock/LumiBlockComps/src/CreateAANTFromLumiBlockCollection.cxx
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
-*/
-
-#include "LumiBlockComps/CreateAANTFromLumiBlockCollection.h"
-#include "GaudiKernel/MsgStream.h"
-#include "GaudiKernel/ISvcLocator.h"
-#include "EventInfo/EventInfo.h"
-#include "EventInfo/EventID.h"
-#include "StoreGate/StoreGateSvc.h"
-
-CreateAANTFromLumiBlockCollection::CreateAANTFromLumiBlockCollection(const std::string& name, ISvcLocator* pSvcLocator) :
-// *****************************************************
-  Algorithm(name, pSvcLocator)
-{
-
-  declareProperty("LBCollName",m_LBColl_name = "LumiBlocks");
-
-   m_tempLBColl = new LumiBlockCollection();          // Temp storage while reading the file
-
-}
-
-StatusCode CreateAANTFromLumiBlockCollection::initialize(){
-//*******************************************************
-
-  MsgStream log(msgSvc(), name());
-  log << MSG::INFO << "initialize()" << endreq;
-                                                                                 
-  // Locate the StoreGateSvc and initialize our local ptr
-  // ****************************************************
-  StatusCode sc = service("StoreGateSvc", m_storeGate);
-  if (!sc.isSuccess() || 0 == m_storeGate) {
-      log << MSG::ERROR << "Could not find StoreGateSvc" << endreq;
-      return StatusCode::FAILURE;
-  } 
-  sc = service("StoreGateSvc/InputMetaDataStore", m_metaStore);
-  if (!sc.isSuccess() || 0 == m_metaStore) {
-      log << MSG::ERROR << "Could not find MetaDataStore" << endreq;
-      return StatusCode::FAILURE;
-  } 
-
-
-  // Initialize histogram service
-  sc = serviceLocator()->service("THistSvc", tHistSvc);
-  if (sc.isFailure()) {
-    log << MSG::ERROR << "Unable to retrieve pointer to THistSvc!" << endreq;
-    return sc;
-  }
-  
-  // Create MetaData TTree
-  MetaDataTree = new TTree("MetaData","MetaData");
-  sc=tHistSvc->regTree("/AANT/MetaData",MetaDataTree);
-  if(sc.isFailure()){
-    log << MSG::ERROR << "Cannot register MetaDataTree" << endreq;
-  }
-  // create branch for LumiBlockCollection
-  MetaDataTree->Bronch("LumiBlockCollection_p1_LumiBlocks", "LumiBlockCollection_p1", &m_lbc);
-
-  // Create UserData Tree
-  UserDataTree = new TTree("UserData","UserData");
-  sc=tHistSvc->regTree("/AANT/UserData",UserDataTree);
-  if(sc.isFailure()){
-    log << MSG::ERROR << "Cannot register UserDataTree" << endreq;
-  }
-  // create branch for LumiBlockCollection
-  UserDataTree->Branch("vectord", &m_vectord);
-
-  return StatusCode::SUCCESS;
-}
-
-
-StatusCode CreateAANTFromLumiBlockCollection::execute() {
-//*******************************************************
-
-  MsgStream log(msgSvc(), name());
-  log << MSG::DEBUG << "execute()" << endreq;
-
-  m_vectord->push_back(123.0);
-  m_vectord->push_back(456.0);
-  UserDataTree->Fill();  
-
-  return (StatusCode::SUCCESS);
-}
-
-
-//*****************************************************
-StatusCode CreateAANTFromLumiBlockCollection::clear() {
-// *****************************************************
-
-  MsgStream log(msgSvc(), name());
-  log << MSG::DEBUG << "clear()" << endreq;
-
-  m_vectord->clear();
-
-  return StatusCode::SUCCESS;
-}
-
-//*****************************************************
-StatusCode CreateAANTFromLumiBlockCollection::finalize() {
-// *****************************************************
-
-  MsgStream log(msgSvc(), name());
-  log << MSG::DEBUG << "finalize()" << endreq;
-
-  // Look for LB information on input store and transfer it to temporay cache
-  // ===========================================================================
-  const DataHandle<LumiBlockCollection> iovc;
-  StatusCode sc = m_metaStore->retrieve(iovc, m_LBColl_name);
-  if (!sc.isSuccess()) {
-    log << MSG::ERROR << "Could not find LumiBlockColl in input metatdata store" << endreq;
-    return StatusCode::FAILURE;
-  }
-  else {
-    log << MSG::DEBUG << " Found LumiBlockColl in input metadata store: " << endreq;
-  }
-  
-  // Now cache it locally                                                                                            
-  m_tempLBColl->reserve(m_tempLBColl->size()+iovc->size());
-  LumiBlockCollection::const_iterator i(iovc->begin()), ie(iovc->end());
-  while (i != ie) {m_tempLBColl->push_back(new IOVRange(*(*i++)));}
-  
-  // try to persistify it
-  m_lbc = m_lbc_conv.createPersistent( m_tempLBColl, log);
-  log << MSG::INFO << "Hello World! m_lbs: " << m_lbc << endreq;
-
-  MetaDataTree->Fill();
-
-  sc=StatusCode::SUCCESS;
-
-  return sc;
-}
- 
-
diff --git a/LumiBlock/LumiBlockComps/src/CreateLumiBlockCollectionFromFile.cxx b/LumiBlock/LumiBlockComps/src/CreateLumiBlockCollectionFromFile.cxx
index 53d37e9df6147db12d18a228f53d35ed723d2056..5b1a985f34f187c7dd5958363e3de0b1ee209ef4 100755
--- a/LumiBlock/LumiBlockComps/src/CreateLumiBlockCollectionFromFile.cxx
+++ b/LumiBlock/LumiBlockComps/src/CreateLumiBlockCollectionFromFile.cxx
@@ -12,12 +12,15 @@
 #include "StoreGate/StoreGateSvc.h"
 
 CreateLumiBlockCollectionFromFile::CreateLumiBlockCollectionFromFile(const std::string& name, ISvcLocator* pSvcLocator) :
-// *****************************************************
-  Algorithm(name, pSvcLocator), m_lastRun(9999999), m_lastLumiBlock(9999999),
+// ********************************************************************************************************************
+  Algorithm(name, pSvcLocator), m_lastRun(9999999), m_lastLumiBlock(9999999), m_lastIOVTime(0),
   m_storeGate(0), m_metaStore(0)
 {
   declareProperty("LBCollName",m_LBColl_name = "LumiBlocks");
   declareProperty("unfinishedLBCollName",m_unfinishedLBColl_name = "IncompleteLumiBlocks");
+  declareProperty("suspectLBCollName",m_suspectLBColl_name = "SuspectLumiBlocks");
+
+  declareProperty("checkEventsExpected",m_checkEventsExpected=false);
 }
 
 StatusCode CreateLumiBlockCollectionFromFile::initialize(){
@@ -53,8 +56,7 @@ StatusCode CreateLumiBlockCollectionFromFile::initialize(){
   incSvc->addListener(this, "LastInputFile", 50); // pri has to be > 20 to be 
                                                   // before MetaDataSvc and AthenaOutputStream.
 
-  m_LumiBlockColl.clear();
-  m_cacheLBColl.clear();
+  m_LumiBlockInfo.clear();
 
   return StatusCode::SUCCESS;
 }
@@ -84,11 +86,34 @@ StatusCode CreateLumiBlockCollectionFromFile::execute() {
 
    if(m_lastRun!=evt->event_ID()->run_number() || 
       m_lastLumiBlock!=evt->event_ID()->lumi_block()) { 
-       IOVTime iov(evt->event_ID()->run_number(),evt->event_ID()->lumi_block());
-       m_LumiBlockColl.push_back(iov);
-       m_lastRun=evt->event_ID()->run_number();
-       m_lastLumiBlock=evt->event_ID()->lumi_block();
+
+       IOVTime iovtime(evt->event_ID()->run_number(),evt->event_ID()->lumi_block());
+       RLBMap::iterator mitr;
+       mitr=m_LumiBlockInfo.find(iovtime);
+       if (mitr==m_LumiBlockInfo.end()) {
+
+       // Here is where we should access the database
+       // ==============================================
+       unsigned int expectedEvents = 0;
+       if(m_checkEventsExpected) {
+         log << MSG::WARNING << "Database access to number of expected events not implemented" << endreq;
+         expectedEvents = 8;  // JUST FOR TESTING
+       }
+       inOut lbInOut(expectedEvents,1);
+       m_LumiBlockInfo[iovtime] = lbInOut;
+       }
+       else {
+         m_LumiBlockInfo[iovtime].second++;
+       }
+   
+     m_lastRun=evt->event_ID()->run_number();
+     m_lastLumiBlock=evt->event_ID()->lumi_block();
+     m_lastIOVTime=iovtime;
+   }
+   else {
+     m_LumiBlockInfo[m_lastIOVTime].second++;
    }
+
   
   return (StatusCode::SUCCESS);
 }
@@ -104,52 +129,87 @@ StatusCode CreateLumiBlockCollectionFromFile::finalize() {
 }
  
 
-//**********************************************************************
-StatusCode CreateLumiBlockCollectionFromFile::fillLumiBlockCollection(std::vector<IOVTime>* coll, std::string key )
-// *********************************************************************
+//*********************************************************************
+StatusCode CreateLumiBlockCollectionFromFile::fillLumiBlockCollection()
+// ********************************************************************
 {
   MsgStream log(msgSvc(), name());
   // Create the LumiBlockCollection
-  LumiBlockCollection* piovc = new LumiBlockCollection();
-  // Sort the collection and then remove duplicates
-  sort(coll->begin(),coll->end());
-  coll->erase( unique( coll->begin(), coll->end() ), coll->end() );
-
-  // Iterate through the collection of IOV and create LumiBlockCollection 
-  // Note:  the IOVTime contains run and lumiblock even though the method
-  // names are run() and event()
-  std::vector<IOVTime>::iterator it, ibeg, iend;
-  ibeg = coll->begin();
-  iend = ibeg;
-  for(it=coll->begin(); it<coll->end(); it++) {
-    // If run number changes or lumiblock number is not contiguous, make new
-    // IOVRange object
-    if(it->run()!=iend->run() || it->event()>(iend->event()+1)) {
-      IOVRange* iov = new IOVRange(IOVTime(ibeg->run(),ibeg->event()),
-                     IOVTime(iend->run(),iend->event()));
-      piovc->push_back(iov);
-      ibeg=it;
+  LumiBlockCollection* piovComplete = new LumiBlockCollection();
+  LumiBlockCollection* piovUnfinished = new LumiBlockCollection();
+  LumiBlockCollection* piovSuspect = new LumiBlockCollection();
+
+
+  for(RLBMap::iterator mitr=m_LumiBlockInfo.begin(); mitr!=m_LumiBlockInfo.end(); mitr++) {
+    // Create our LB_IOVRange object
+    // Looks a bit wierd, but our map is <iovTime, pair<unit32_t,uint32_t> >
+    LB_IOVRange* iovr = new LB_IOVRange(mitr->first,mitr->first);
+    iovr->setNumExpected(mitr->second.first);
+    iovr->setNumSeen(mitr->second.second);
+
+
+    // Decide which collection it goes into depending on whether the LB is complete
+    // =============================================================================
+    // Suspect LB's have more events read than the DB says should be there
+    if(!m_checkEventsExpected || mitr->second.second == mitr->second.first) {
+      piovComplete->push_back(iovr);
     }
-    iend=it;
-  } 
-  // We need to store the last one since it is left hanging by the above loop
-  IOVRange* iov = new IOVRange(IOVTime(ibeg->run(),ibeg->event()),
-                     IOVTime(iend->run(),iend->event()));
-  piovc->push_back(iov);
+    else if(mitr->second.second > mitr->second.first) {
+      piovSuspect->push_back(iovr);
+    }
+    else {
+      piovUnfinished->push_back(iovr);
+    }
+  }
+
   log << MSG::INFO << "Summary of LumiBlock Info:"  << endreq ;
-  piovc->dump(std::cout);
+  if(piovComplete->size()>0) {
+    log << MSG::INFO << "Complete LumiBlocks:" << endreq;
+     piovComplete->dump(std::cout);
+  }
+
+  if(piovUnfinished->size()>0) {
+    log << MSG::INFO << "Unfinished LumiBlocks:" << endreq;
+    piovUnfinished->dump(std::cout);
+  }
+
+  if(piovUnfinished->size()>0) {
+    log << MSG::INFO << "Suspect LumiBlocks:" << endreq;
+    piovSuspect->dump(std::cout);
+  }
+
+  /*
 
   // Store the LumiBlockCollection in the metadata store
+  // =======================================================
+  StatusCode sc;
+  if(piovComplete->size()>0) {
+    sc = m_metaStore->record(piovComplete, m_LBColl_name);
+    if (sc.isFailure()) {
+       log << MSG::ERROR << "could not register complete LumiBlockCollection" << endreq;
+       return(StatusCode::FAILURE);
+    }
+  }
 
-  StatusCode sc = m_metaStore->record(piovc, key);
-  if (sc.isFailure()) {
-     log << MSG::ERROR << "could not register LumiBlockCollection" << endreq;
-     return(StatusCode::FAILURE);
-   }   
+  if(piovUnfinished->size()>0) {
+    sc = m_metaStore->record(piovUnfinished,  m_unfinishedLBColl_name);
+    if (sc.isFailure()) {
+       log << MSG::ERROR << "could not register incomplete  LumiBlockCollection" << endreq;
+       return(StatusCode::FAILURE);
+    }
+  }
 
-  // Then clear m_LumiBlockColl.  This is in case we decide to store the 
+  if(piovSuspect->size()>0) {
+    sc = m_metaStore->record(piovSuspect, m_suspectLBColl_name);
+    if (sc.isFailure()) {
+       log << MSG::ERROR << "could not register suspect LumiBlockCollection" << endreq;
+       return(StatusCode::FAILURE);
+    }
+  }
+  // Then clear m_LumiBlockInfo.  This is in case we decide to store the 
   // LBColl separately for each input or output file.
-  coll->clear();
+  */
+  m_LumiBlockInfo.clear();
   return StatusCode::SUCCESS;
 }
 // *******************************************************************
@@ -164,7 +224,7 @@ void CreateLumiBlockCollectionFromFile::handle(const Incident& inc) {
     if (fileInc == 0) { fileName = "Undefined "; }
     else { fileName = fileInc->fileName();}
     log <<  MSG::DEBUG << "BeginInputFile: " << fileName << endreq;
-    if(m_LumiBlockColl.size()>0) {
+    if(m_LumiBlockInfo.size()>0) {
       log << MSG::WARNING << " BeginInputFile handle detects non-zero size Cached LumiBlockColl" << endreq;
     }
   }
@@ -174,13 +234,6 @@ void CreateLumiBlockCollectionFromFile::handle(const Incident& inc) {
     // Therefore we can transfer the list of LB to the cached collection of good LB's
     // ***************************************************************************************************
     log <<  MSG::DEBUG << "EndInputFile incident detected" << endreq;  
-    std::vector<IOVTime>::iterator it, ibeg, iend;
-    ibeg = m_LumiBlockColl.begin();
-    iend = ibeg;
-    for(it=m_LumiBlockColl.begin(); it<m_LumiBlockColl.end(); it++) {
-      m_cacheLBColl.push_back(*it);
-    }
-    m_LumiBlockColl.clear();
   }
   else if(inc.type() == "LastInputFile") {
     finishUp();
@@ -197,17 +250,10 @@ void CreateLumiBlockCollectionFromFile:: finishUp() {
 
    MsgStream log(msgSvc(), name());
    log << MSG::INFO <<  " finishUp: write lumiblocks to meta data store " << endreq;
-
-    if(m_cacheLBColl.size()>0) {
-        StatusCode sc=fillLumiBlockCollection(&m_cacheLBColl,m_LBColl_name);
-        if (sc.isFailure()) {
-            log << MSG::ERROR << "Could not fill lumiblock collection for full files" << endreq;
-        }
-    }
-    if(m_LumiBlockColl.size()>0) {
-      StatusCode sc=fillLumiBlockCollection(&m_LumiBlockColl,m_unfinishedLBColl_name);
+    if(m_LumiBlockInfo.size()>0) {
+      StatusCode sc=fillLumiBlockCollection();
         if (sc.isFailure()) {
-            log << MSG::ERROR << "Could not fill lumiblock collection for unfinished files" << endreq;
+            log << MSG::ERROR << "Could not fill lumiblock collections in finishUp()" << endreq;
         }
     }
 }
diff --git a/LumiBlock/LumiBlockComps/src/LumiBlockCollectionConverter.cxx b/LumiBlock/LumiBlockComps/src/LumiBlockCollectionConverter.cxx
deleted file mode 100644
index 54444703709d95a6b85eebb20926e27540eb5520..0000000000000000000000000000000000000000
--- a/LumiBlock/LumiBlockComps/src/LumiBlockCollectionConverter.cxx
+++ /dev/null
@@ -1,251 +0,0 @@
-/*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
-*/
-
-#include "LumiBlockComps/LumiBlockCollectionConverter.h"
-#include "LumiBlockData/LumiBlockCollection.h"
-#include "AthenaKernel/IOVRange.h"
-
-#include "GoodRunsLists/TLumiBlockRange.h"
-#include "GoodRunsLists/TGoodRun.h"
-#include "GoodRunsLists/TGoodRunsList.h"
-#include "GoodRunsLists/TGRLCollection.h"
-#include "GoodRunsLists/TGoodRunsListReader.h"
-#include "GoodRunsLists/TGoodRunsListWriter.h"
-
-#include "TROOT.h"
-
-#include <stdlib.h>
-
-LumiBlockCollectionConverter::LumiBlockCollectionConverter()
- : m_reader(new Root::TGoodRunsListReader())
- , m_writer(new Root::TGoodRunsListWriter())
-{
-}
-
-
-LumiBlockCollectionConverter::~LumiBlockCollectionConverter()
-{
-  if (m_reader!=0) { delete m_reader; m_reader=0; }
-  if (m_writer!=0) { delete m_writer; m_writer=0; }
-}
-
-
-LumiBlockCollection* 
-LumiBlockCollectionConverter::GetLumiBlockCollection(const Root::TGoodRunsList& grl, std::map<TString,TString>& metadata, TString& version) 
-{
-  metadata = grl.GetMetaData();
-  version = grl.GetVersion();
-  return this->GetLumiBlockCollection( grl );
-}
-
-
-LumiBlockCollection* 
-LumiBlockCollectionConverter::GetLumiBlockCollection(const Root::TGoodRunsList& grl) const 
-{
-  LumiBlockCollection* iovc = new LumiBlockCollection();
-
-  Root::TGoodRun goodrun;
-  std::map<Int_t, Root::TGoodRun>::const_iterator it;
-  std::vector< Root::TLumiBlockRange >::const_iterator itlbr;
-  int RunNumber(-1), LumiBlockStart(-1), LumiBlockEnd(-1);
-
-  for(it = grl.begin(); it != grl.end(); ++it) {
-    RunNumber = it->first;
-    goodrun = it->second;
-    for(itlbr = goodrun.begin(); itlbr != goodrun.end(); ++itlbr) {
-      LumiBlockStart = itlbr->Begin();
-      LumiBlockEnd = itlbr->End();
-      iovc->push_back(new IOVRange(IOVTime(RunNumber, LumiBlockStart), IOVTime(RunNumber,LumiBlockEnd)));
-    }
-  }
-  iovc->sort(LumiBlockCollection::SortIOVRangeByStart());
-
-  return iovc;
-}
-
-
-LumiBlockCollection* 
-LumiBlockCollectionConverter::GetLumiBlockCollection(const char* xmlfile) const
-{
-  Root::TGoodRunsList* pgrl = this->GetGRLObject( xmlfile );
-  LumiBlockCollection* iovc = this->GetLumiBlockCollection( *pgrl );
-  delete pgrl;
-  return iovc;
-}
-
-
-LumiBlockCollection* 
-LumiBlockCollectionConverter::GetLumiBlockCollectionFromString( const TString& xmlstring ) const
-{
-  m_reader->SetXMLString( xmlstring );
-  (void) m_reader->Interpret();
-  return this->GetLumiBlockCollection( m_reader->GetMergedGoodRunsList() );
-}
-
-
-void 
-LumiBlockCollectionConverter::CreateXMLFile(const Root::TGRLCollection& grlcollection, const char* xmlfilename) const
-{
-  m_writer->SetGRLCollection( grlcollection ) ;
-  m_writer->SetFilename( xmlfilename ) ;
-  m_writer->WriteXMLFile() ;
-}
-
-
-void
-LumiBlockCollectionConverter::CreateXMLFile(const Root::TGoodRunsList& grl, const TString& xmlfilename, const TString& prefix) const
-{
-  m_writer->SetGoodRunsList( grl ) ;
-  TString xmlfile = ( xmlfilename.IsNull() ? prefix + grl.GetSuggestedName() + ".xml" : xmlfilename );
-  m_writer->SetFilename( xmlfile.Data() ) ;
-  m_writer->WriteXMLFile() ;
-}
-
-
-void 
-LumiBlockCollectionConverter::CreateXMLFile(const LumiBlockCollection& lbc, const grlmetadatamap& metadata, const char* version, 
-                                            const TString& xmlfilename, const TString& prefix ) const
-{
-  Root::TGoodRunsList* pgrl = this->GetGRLObject(lbc,metadata,version);
-  m_writer->SetGoodRunsList( *pgrl ) ;
-  TString xmlfile = ( xmlfilename.IsNull() ? prefix+pgrl->GetSuggestedName()+".xml" : xmlfilename );
-  m_writer->SetFilename( xmlfile.Data() ) ;
-  m_writer->WriteXMLFile() ;  
-  delete pgrl;
-}
-
-
-void
-LumiBlockCollectionConverter::CreateXMLFiles(const Root::TGRLCollection& grlcollection, const char* prefix) const
-{
-  m_writer->SetGRLCollection( grlcollection ) ;
-  m_writer->SetPrefix( prefix ) ;
-  m_writer->WriteXMLFiles() ;
-}
-
-
-const TString 
-LumiBlockCollectionConverter::GetXMLString(const Root::TGoodRunsList& grl) const
-{
-  m_writer->SetGoodRunsList( grl ) ;
-  return m_writer->GetXMLString() ;
-}
-
-
-const TString
-LumiBlockCollectionConverter::GetXMLString(const Root::TGRLCollection& grlcollection) const
-{
-  m_writer->SetGRLCollection( grlcollection ) ;
-  return m_writer->GetXMLString() ;
-}
-
-
-const std::vector<TString> 
-LumiBlockCollectionConverter::GetXMLStrings(const Root::TGRLCollection& grlcollection) const
-{
-  m_writer->SetGRLCollection( grlcollection ) ;
-  return m_writer->GetXMLStrings() ;
-}
-
-
-const TString 
-LumiBlockCollectionConverter::GetXMLString( const LumiBlockCollection& lbc, const std::map<TString,TString>& metadata, const char* version ) const
-{
-  Root::TGoodRunsList* pgrl = this->GetGRLObject(lbc,metadata,version);
-  m_writer->SetGoodRunsList( *pgrl ) ;
-  TString xmlstring = m_writer->GetXMLString() ;
-  delete pgrl;
-  return xmlstring;
-}
-
-
-Root::TGoodRunsList* 
-LumiBlockCollectionConverter::GetGRLObject( const LumiBlockCollection& lbc, const std::map<TString,TString>& metadata, const char* version ) const
-{
-  Root::TGoodRunsList* grl = new Root::TGoodRunsList();
-  grl->SetVersion(version);
-  grl->SetMetaData(metadata);
-
-  if (!lbc.empty()) {
-    Root::TGoodRun goodrun;
-    int prev_runnbr(-1), cur_runnbr(-1), cur_lbstart(-1), cur_lbstop(-1);
-  
-    for( LumiBlockCollection::const_iterator it=lbc.begin(); it != lbc.end(); ++it ) {
-      const IOVRange* iovr = (*it);
-      cur_runnbr = iovr->start().run();
-      cur_lbstart = iovr->start().event();
-      cur_lbstop = iovr->stop().event();
-      // store previous run and reset
-      if (prev_runnbr!=cur_runnbr) {
-        if (prev_runnbr>=0) { (*grl)[prev_runnbr]=goodrun; }
-        goodrun.clear();
-        goodrun.SetRunNumber(cur_runnbr);
-      }
-      // store lumiblock range
-      goodrun.push_back( Root::TLumiBlockRange(cur_lbstart,cur_lbstop) ) ;
-      prev_runnbr = cur_runnbr;
-    } // loop over lbs
-    (*grl)[prev_runnbr]=goodrun; // also store last goodrun
-  } // lbc !empty
-
-
-  grl->Compress();
-  return grl;
-}
-
-
-Root::TGoodRunsList* 
-LumiBlockCollectionConverter::GetGRLObject( const char* xmlfile ) const
-{
-  m_reader->SetXMLFile( xmlfile );
-  (void) m_reader->Interpret();
-  return (new Root::TGoodRunsList( m_reader->GetMergedGoodRunsList() )); 
-}
-
-
-Root::TGoodRunsList* 
-LumiBlockCollectionConverter::GetGRLObjectFromString( const TString& xmlstring ) const
-{
-  m_reader->SetXMLString( xmlstring );
-  (void) m_reader->Interpret();
-  return (new Root::TGoodRunsList( m_reader->GetMergedGoodRunsList() ));
-}
-
-
-Root::TGRLCollection*
-LumiBlockCollectionConverter::GetGRLCollection( const char* xmlfile ) const
-{
-  m_reader->SetXMLFile( xmlfile );
-  (void) m_reader->Interpret();
-  return (new Root::TGRLCollection( m_reader->GetMergedGRLCollection() ));
-} 
-
-
-Root::TGRLCollection*
-LumiBlockCollectionConverter::GetGRLCollectionFromString( const TString& xmlstring ) const
-{
-  m_reader->SetXMLString( xmlstring );
-  (void) m_reader->Interpret();
-  return (new Root::TGRLCollection( m_reader->GetMergedGRLCollection() ));
-}
-
-
-const TString
-LumiBlockCollectionConverter::GetSuggestedName( const LumiBlockCollection& lbc ) const
-{
-  if (lbc.empty()) return "grl_empty";
-
-  Int_t beginrun(-1), endrun(-1), beginlb(-1), endlb(-1);
-
-  LumiBlockCollection::const_iterator itb=lbc.begin();
-  LumiBlockCollection::const_reverse_iterator ite=lbc.rbegin();
-
-  beginrun = (*itb)->start().run();
-  beginlb  = (*itb)->start().event();
-  endrun = (*ite)->stop().run();
-  endlb  = (*ite)->stop().event();
-
-  return Form("grl_%d.%d-%d.%d",beginrun,beginlb,endrun,endlb);
-}
-
diff --git a/LumiBlock/LumiBlockComps/src/LumiBlockMetaDataTool.cxx b/LumiBlock/LumiBlockComps/src/LumiBlockMetaDataTool.cxx
index 42819c9afd3a958be6dc8f3b428ef50d652d9793..439fdcba0a494030718ccfd6c9858a5a57c16f22 100755
--- a/LumiBlock/LumiBlockComps/src/LumiBlockMetaDataTool.cxx
+++ b/LumiBlock/LumiBlockComps/src/LumiBlockMetaDataTool.cxx
@@ -12,7 +12,7 @@
 #include "GoodRunsLists/IGoodRunsListSelectorTool.h"
 #include "GoodRunsLists/TGoodRunsListReader.h"
 #include "GoodRunsLists/ITriggerRegistryTool.h"
-#include "LumiBlockComps/LumiBlockCollectionConverter.h"
+#include "LumiCalc/LumiBlockCollectionConverter.h"
 #include "LumiBlockComps/ILumiCalcSvc.h"
 
 // the user data-class defintions
@@ -261,9 +261,9 @@ void LumiBlockMetaDataTool::handle(const Incident& inc) {
            LumiBlockCollection::const_iterator ilast(lbc->begin());
            // Now cache it locally
            m_tempLBColl->reserve(m_tempLBColl->size()+lbc->size());
-           if(i!=ie) m_tempLBColl->push_back(new IOVRange(*(*i++)));
+           if(i!=ie) m_tempLBColl->push_back(new LB_IOVRange(*(*i++)));
            while (i != ie) {
-	     if(**i!=**ilast ) { m_tempLBColl->push_back(new IOVRange(*(*i))); }
+	     if(**i!=**ilast ) { m_tempLBColl->push_back(new LB_IOVRange(*(*i))); }
              else {
 	       log << MSG::DEBUG << "Remove duplicate with range " << **i << endreq;
 	     }
@@ -289,10 +289,10 @@ void LumiBlockMetaDataTool::handle(const Incident& inc) {
           LumiBlockCollection::const_iterator i(lbc->begin()), ie(lbc->end());
           LumiBlockCollection::const_iterator ilast(lbc->begin());
           // Now cache it locally
-          m_tempLBColl->reserve(m_unfinishedLBColl->size()+lbc->size());
-          if(i!=ie) m_unfinishedLBColl->push_back(new IOVRange(*(*i++)));
+          m_unfinishedLBColl->reserve(m_unfinishedLBColl->size()+lbc->size());
+          if(i!=ie) m_unfinishedLBColl->push_back(new LB_IOVRange(*(*i++)));
           while (i != ie) {
-	    if(**i!=**ilast ) { m_unfinishedLBColl->push_back(new IOVRange(*(*i))); }
+	    if(**i!=**ilast ) { m_unfinishedLBColl->push_back(new LB_IOVRange(*(*i))); }
             else {
 	      log << MSG::DEBUG << "Remove duplicate in unfinished collection with range " << **i << endreq;
 	    }
@@ -309,7 +309,7 @@ void LumiBlockMetaDataTool::handle(const Incident& inc) {
      if(m_tempLBColl->size() >0 ) {
       m_cacheLBColl->reserve(m_cacheLBColl->size()+m_tempLBColl->size());
       LumiBlockCollection::const_iterator i(m_tempLBColl->begin()), ie(m_tempLBColl->end());
-      while (i != ie) {m_cacheLBColl->push_back(new IOVRange(*(*i++)));}
+      while (i != ie) {m_cacheLBColl->push_back(new LB_IOVRange(*(*i++)));}
       m_tempLBColl->clear();
      }
       m_fileCurrentlyOpened=false;
@@ -348,9 +348,9 @@ void  LumiBlockMetaDataTool::finishUp() {
 //    We have to do this because the copy constructor of DataVector only
 //    copies the pointers...
       LumiBlockCollection::const_iterator i(m_cacheLBColl->begin()), ie(m_cacheLBColl->end());
-      tmpColl->push_back(new IOVRange(*(*i++)));
+      tmpColl->push_back(new LB_IOVRange(*(*i++)));
       while (i != ie) { 
-        tmpColl->push_back(new IOVRange(*(*i))); 
+        tmpColl->push_back(new LB_IOVRange(*(*i))); 
         i++;
       }
 
@@ -395,9 +395,9 @@ void  LumiBlockMetaDataTool::finishUp() {
       LumiBlockCollection* tmp2Coll = new LumiBlockCollection();
       if (m_tempLBColl->size()>0 || m_unfinishedLBColl->size()>0) {
         LumiBlockCollection::const_iterator i(m_tempLBColl->begin()), ie(m_tempLBColl->end());
-        while (i != ie) { tmp2Coll->push_back(new IOVRange(*(*i++)));}
+        while (i != ie) { tmp2Coll->push_back(new LB_IOVRange(*(*i++)));}
         LumiBlockCollection::const_iterator j(m_unfinishedLBColl->begin()), je(m_unfinishedLBColl->end());
-        while (j != je) { tmp2Coll->push_back(new IOVRange(*(*j++)));}
+        while (j != je) { tmp2Coll->push_back(new LB_IOVRange(*(*j++)));}
         tmp2Coll->sort(LumiBlockCollection::SortIOVRangeByStart());
       }
 
@@ -456,7 +456,7 @@ LumiBlockMetaDataTool::GetCopyOfCollection( const LumiBlockCollection& lbc )
 {
   LumiBlockCollection* copyColl = new LumiBlockCollection();
   LumiBlockCollection::const_iterator itr(lbc.begin()), end(lbc.end());
-  for (; itr!=end; ++itr) { copyColl->push_back(new IOVRange(*(*itr))); }
+  for (; itr!=end; ++itr) { copyColl->push_back(new LB_IOVRange(*(*itr))); }
   copyColl->sort(LumiBlockCollection::SortIOVRangeByStart());
 
   return copyColl;
@@ -474,7 +474,7 @@ LumiBlockMetaDataTool::FilterOnDQFlags( const LumiBlockCollection& lbc,
   int lastoklbnr(-1), cur_runnbr(-1), cur_lbstart(-1), cur_lbstop(-1);
 
   for( LumiBlockCollection::const_iterator it=lbc.begin(); it != lbc.end(); ++it ) {
-    const IOVRange* iovr = (*it);
+    const LB_IOVRange* iovr = (*it);
     cur_runnbr = iovr->start().run();
     cur_lbstart = iovr->start().event();
     cur_lbstop = iovr->stop().event();
@@ -489,13 +489,13 @@ LumiBlockMetaDataTool::FilterOnDQFlags( const LumiBlockCollection& lbc,
 	  cur_lbstart = lbnr;
         }
       } else if (somethingtostore) {
-        iovc->push_back( new IOVRange(IOVTime(cur_runnbr, cur_lbstart),IOVTime(cur_runnbr, lastoklbnr)) );
+        iovc->push_back( new LB_IOVRange(IOVTime(cur_runnbr, cur_lbstart),IOVTime(cur_runnbr, lastoklbnr)) );
         somethingtostore=false;
       }
     }
     // store remaining good iovrange
     if (somethingtostore) {
-      iovc->push_back( new IOVRange(IOVTime(cur_runnbr, cur_lbstart),IOVTime(cur_runnbr, lastoklbnr)) );
+      iovc->push_back( new LB_IOVRange(IOVTime(cur_runnbr, cur_lbstart),IOVTime(cur_runnbr, lastoklbnr)) );
       somethingtostore=false;
     }
   } 
@@ -544,7 +544,7 @@ StatusCode LumiBlockMetaDataTool::fillFromXML(LumiBlockCollection* lbc_target,
       // Iterate over lumiblock ranges for that run and fill LumiBlockCollection argument
       log << MSG::INFO << "About to fill LBCollection with " << it->second.size() << "items" << endreq;
       for (std::vector<Root::TLumiBlockRange>::const_iterator lbrit = it->second.begin(); lbrit != it->second.end(); lbrit++) {
-         lbc_target->push_back(new IOVRange(IOVTime(run, lbrit->Begin()), IOVTime(run, lbrit->End())));
+         lbc_target->push_back(new LB_IOVRange(IOVTime(run, lbrit->Begin()), IOVTime(run, lbrit->End())));
       }
       // Ready for next LumiBlockCollection
    } // grl loop
diff --git a/LumiBlock/LumiBlockComps/src/LumiBlockMuWriter.cxx b/LumiBlock/LumiBlockComps/src/LumiBlockMuWriter.cxx
index f12729ea0e57f1ae8216b81d081666d0768a334a..0d66d9f135eff30603a131ed46ca076ec690329e 100644
--- a/LumiBlock/LumiBlockComps/src/LumiBlockMuWriter.cxx
+++ b/LumiBlock/LumiBlockComps/src/LumiBlockMuWriter.cxx
@@ -3,6 +3,7 @@
 */
 
 #include "LumiBlockComps/LumiBlockMuWriter.h"
+
 #include "EventInfo/EventID.h"
 #include "EventInfo/EventInfo.h"
 #include "EventInfo/PileUpEventInfo.h"
diff --git a/LumiBlock/LumiBlockComps/src/LumiBlockTester.cxx b/LumiBlock/LumiBlockComps/src/LumiBlockTester.cxx
index b27d7310796480e5e5df4213cd520e783cf3289f..4810e156dab35214ec27946b3ea7853f8e331940 100644
--- a/LumiBlock/LumiBlockComps/src/LumiBlockTester.cxx
+++ b/LumiBlock/LumiBlockComps/src/LumiBlockTester.cxx
@@ -11,8 +11,8 @@
 //--------------------------------------------------
 LumiBlockTester::LumiBlockTester(const std::string& name, ISvcLocator* pSvcLocator):
   AthAlgorithm(name,pSvcLocator),
-  m_lumiTool("LuminosityTool", this),
-  m_liveTool("TrigLivefractionTool", this)
+  m_lumiTool("LuminosityTool"),
+  m_liveTool("TrigLivefractionTool")
 {
   declareProperty("LuminosityTool", m_lumiTool);
   declareProperty("TrigLivefractionTool", m_liveTool);
@@ -52,6 +52,8 @@ LumiBlockTester::execute()
 
   if (m_lumiTool->muToLumi() > 0.)
     instmu = m_lumiTool->lbLuminosityPerBCID()/m_lumiTool->muToLumi(); 
+  else
+    ATH_MSG_DEBUG(" Lumi: " << m_lumiTool->lbLuminosityPerBCID() << " muToLumi: " << m_lumiTool->muToLumi() << "!");
 
   float live = m_liveTool->livefractionPerBCID();
   float lumilive = m_liveTool->lbAverageLivefraction();
diff --git a/LumiBlock/LumiBlockComps/src/LumiCalcSvc.cxx b/LumiBlock/LumiBlockComps/src/LumiCalcSvc.cxx
index 1277b329ffa49c137cab3d06deb380ed7128cb55..99d0afd9b81da71abf080c3c4f6f8f96f1715c7e 100644
--- a/LumiBlock/LumiBlockComps/src/LumiCalcSvc.cxx
+++ b/LumiBlock/LumiBlockComps/src/LumiCalcSvc.cxx
@@ -41,7 +41,7 @@
 #include <iomanip>
 #include <iostream>
 
-#include "LumiCalcSvc.h"
+#include "LumiBlockComps/LumiCalcSvc.h"
 
 LumiCalcSvc::LumiCalcSvc(const std::string& name, 
 		       ISvcLocator* pSvcLocator ) : 
@@ -50,6 +50,7 @@ LumiCalcSvc::LumiCalcSvc(const std::string& name,
   p_detstore(0),
   p_inputstore(0),
   p_metadatastore(0),
+  tHistSvc(0),
   m_sourcedb("COOLONL_TRIGGER/OFLP200"),
   m_parlumiestfolder("/TRIGGER/LUMI/LBLEST"),
   m_parlumilvl1folder("/TRIGGER/LUMI/LVL1COUNTERS"),
@@ -307,7 +308,7 @@ StatusCode LumiCalcSvc::stop(){
 //===========================================================================
 void LumiCalcSvc::printTree(){
 
-  if(LumiTree != 0 || LumiTree != NULL)LumiTree->Scan("*");
+  if(LumiTree != NULL)LumiTree->Scan("*");
 
 }
 
diff --git a/LumiBlock/LumiBlockComps/src/LumiCalculator.cxx b/LumiBlock/LumiBlockComps/src/LumiCalculator.cxx
deleted file mode 100644
index 0d34f2e62dbcf26d3e704e86c17623d740a105b3..0000000000000000000000000000000000000000
--- a/LumiBlock/LumiBlockComps/src/LumiCalculator.cxx
+++ /dev/null
@@ -1,1424 +0,0 @@
-/*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
-*/
-
-#include "LumiCalculator.h"
-
-// GoodRunsLists
-#include "GoodRunsLists/TMsgLogger.h"
-#include "GoodRunsLists/TGoodRunsList.h"
-#include "GoodRunsLists/TGoodRunsListWriter.h"
-
-// ROOT
-#include "TTree.h"
-#include "TFile.h"
-#include "TString.h"
-#include "TROOT.h"
-
-// MB 20100115: turn off for now, RootGraphics lib crashes on some non-cern sites.
-//#include "TCanvas.h"
-
-// stl includes
-#include <iomanip>
-#include <iostream>
-#include <set>
-#include <regex.h>
-
-LumiCalculator::LumiCalculator()
- : m_logger( "LumiCalculator" )
- //, m_effxsec = 47.134 
- , m_effxsec(1.)
- , m_l1rate(0.)
- , m_l2rate(0.)
- , m_l3rate(0.)
- , m_l1ratediveffxsec(0.)
- , m_total_l1ratediveffxsec(0.)
- , m_total_l1ratediveffxsecRun(0.)
- , m_l1ratediveffxsec_recorded(0.)
- , m_total_l1ratediveffxsec_recorded(0.)
- , m_total_l1ratediveffxsecRun_recorded(0.)
- , m_mintrigrate(5./120.)
- , m_collsgrl(0)
- , m_ntrigplb(0)
- , m_trigrateplb(0)
- , m_lumiplb(0)
- , m_lumitrigrateplb(0)
- , m_intlumi(0)
- , m_intlumitrigrate(0)
- , m_lumitrigrateplb_recorded(0)
- , m_intlumitrigrate_recorded(0)
- , m_intlumiruns(0)
- , m_intlumitrigrateruns(0)
- , m_intlumitrigrateruns_recorded(0)
- , m_avgintperbx(0)
- , m_makePlots(false)
- , m_makecollList(false)
- , m_onlinelumi(false)
- , m_uselar(false)
- , m_usebs(false)
-{
-
-  m_trigger="COOLONL_TRIGGER/";
-  m_lumioff="COOLOFL_TRIGGER/";
-  m_lumionl="COOLONL_TRIGGER/";
-  m_laroff="COOLOFL_LAR/"; 
-  m_bsonl="COOLONL_INDET/";
-
-  m_data_db="COMP200";
-  m_parofflumiestfolder = "/TRIGGER/OFLLUMI/LBLESTOFL";
-  m_paronllumiestfolder = "/TRIGGER/LUMI/LBLESTOFL";
-  m_parlumiestfolder = "/TRIGGER/OFLLUMI/LBLESTOFL";
-  m_parlvl1menufolder = "/TRIGGER/LVL1/Menu";
-  m_parhltmenufolder = "/TRIGGER/HLT/Menu";// ChainCounter is here for COOLONL_TRIGGER/COMP20
-  m_parhltprescalesfolder = "/TRIGGER/HLT/Prescales";// ChainCounter is here for COOLONL_TRIGGER/COMP20
-  m_parlumilvl1folder = "/TRIGGER/LUMI/LVL1COUNTERS";
-  m_parlumihltfolder = "/TRIGGER/LUMI/HLTCOUNTERS";
-  m_parlvl1prescalesfolder = "/TRIGGER/LVL1/Prescales";
-  m_parlvl1lblbfolder = "/TRIGGER/LUMI/LBLB";// for time information
-  m_parlareventvetofolder = "/LAR/BadChannelsOfl/EventVeto"; // For LAr event veto
-  m_paronlbeamspotfolder = "/Indet/Onl/Beampos"; // For invalid online beamspot
-
-  m_uselivetrigger = false;
-  m_verbose = false;
-  m_lbcollname = "LumiBlocks";
-
-  m_bstag="IndetBeamposOnl-HLT-UPD1-001-00";
-
-  // by default we use the "offline data" database name
-  lumi_database = m_lumioff + m_data_db;
-  trig_database = m_trigger + m_data_db;
-  lar_database = m_laroff + m_data_db;
-  bs_database = m_bsonl + m_data_db;
-
-  m_lumitag = "OflLumi-8TeV-002";// for offline:  OflLumi_CosmicFake, OflLumi_TopMix
-  m_lumichannel = 0;
-  m_lumimethod = "ATLAS_PREFERRED";// offline channels: ATLAS_PREFERRED, OflLumi_Fake0, OflLumi_Fake:, TopMixLumi 
-  m_State = true;
-  m_LumiTree = 0;
-  
-}
-
-
-LumiCalculator::~LumiCalculator(){
-
-  // delete collisions grl
-  if (m_collsgrl!=0) { delete m_collsgrl; m_collsgrl=0; }
-
-  std::vector<TH1F*>::iterator itr;
-  for (itr=m_ntrigplbVec.begin(); itr!=m_ntrigplbVec.end(); ++itr) { delete *itr; }
-  for (itr=m_trigrateplbVec.begin(); itr!=m_trigrateplbVec.end(); ++itr) { delete *itr; }
-  for (itr=m_lumiplbVec.begin(); itr!=m_lumiplbVec.end(); ++itr) { delete *itr; }
-  for (itr=m_lumitrigrateplbVec.begin(); itr!=m_lumitrigrateplbVec.end(); ++itr) { delete *itr; }
-  for (itr=m_intlumiVec.begin(); itr!=m_intlumiVec.end(); ++itr) { delete *itr; }
-  for (itr=m_intlumitrigrateVec.begin(); itr!=m_intlumitrigrateVec.end(); ++itr) { delete *itr; }
-  for (itr=m_lumitrigrateplb_recordedVec.begin(); itr!=m_lumitrigrateplb_recordedVec.end(); ++itr) { delete *itr; }
-  for (itr=m_intlumitrigrate_recordedVec.begin(); itr!=m_intlumitrigrate_recordedVec.end(); ++itr) { delete *itr; }
-
-  m_ntrigplbVec.clear();
-  m_trigrateplbVec.clear();
-  m_lumiplbVec.clear();
-  m_lumitrigrateplbVec.clear();
-  m_intlumiVec.clear();
-  m_intlumitrigrateVec.clear();
-  m_lumitrigrateplb_recordedVec.clear();
-  m_intlumitrigrate_recordedVec.clear();
-
-  if (m_intlumiruns!=0) { delete m_intlumiruns; m_intlumiruns=0; }
-  if (m_intlumitrigrateruns!=0) { delete m_intlumitrigrateruns; m_intlumitrigrateruns=0; }
-  if (m_intlumitrigrateruns_recorded!=0) { delete m_intlumitrigrateruns_recorded; m_intlumitrigrateruns_recorded=0; }
-  if (m_avgintperbx != 0) { delete m_avgintperbx; m_avgintperbx = 0; }
-
-}
-
-void LumiCalculator::setTree(TTree * tree){
-  // Register branches
-  m_LumiTree = tree;
-  if(m_LumiTree != 0){
-
-    m_LumiTree->Branch("Trigger", &m_triggerchain);
-    m_LumiTree->Branch("LBCollection", &m_lbcollname);
-    m_LumiTree->Branch("RunNbr", &m_runnbr);
-    m_LumiTree->Branch("IOVRStart", &m_lbstart);
-    m_LumiTree->Branch("IOVREnd", &m_lbstop);
-    m_LumiTree->Branch("LBStart", &m_clumiblocknbr);
-    //  m_LumiTree->Branch("LBEnd", &m_clumiblocknbrend);
-    m_LumiTree->Branch("Inst_m_Lumi", &m_instLumi);
-    m_LumiTree->Branch("LiveTime", &m_livetime);
-    m_LumiTree->Branch("L1Presc", &m_l1prescale);
-    m_LumiTree->Branch("L2Presc", &m_l2prescale);
-    m_LumiTree->Branch("L3Presc", &m_l3prescale);
-    m_LumiTree->Branch("L1Count", &m_l1acc);
-    m_LumiTree->Branch("L1CountOverFlow", &m_l1accof);
-    m_LumiTree->Branch("L2Count", &m_l2acc);
-    m_LumiTree->Branch("L3Count", &m_l3acc);
-    m_LumiTree->Branch("L1AfterPrescale", &m_afterprescale);
-    m_LumiTree->Branch("L1AfterPrescaleOverFlow", &m_afterprescaleof);
-    m_LumiTree->Branch("L1BeforePrescale", &m_beforeprescale);
-    m_LumiTree->Branch("L1BeforePrescaleOverFlow", &m_beforeprescaleof);
-    m_LumiTree->Branch("Livefrac", &m_livefrac);
-    m_LumiTree->Branch("LArfrac", &m_larfrac);
-    m_LumiTree->Branch("DeltaT", &m_deltaT);
-    m_LumiTree->Branch("L1Rate", &m_l1rate);
-    m_LumiTree->Branch("IntLumi",&m_intLumi);
-    m_LumiTree->Branch("L1Ratediveffxsec",&m_l1ratediveffxsec);
-    m_LumiTree->Branch("TotalLumi",&m_totalL);
-    m_LumiTree->Branch("Total_L1Ratediveffxsec",&m_total_l1ratediveffxsec);
-    m_LumiTree->Branch("TotalLumiRun",&m_totalLRun);
-    m_LumiTree->Branch("Total_L1RatediveffxsecRun",&m_total_l1ratediveffxsecRun);
-    m_LumiTree->Branch("L1RatediveffxsecRecorded",&m_l1ratediveffxsec_recorded);
-    m_LumiTree->Branch("Total_L1RatediveffxsecRecorded",&m_total_l1ratediveffxsec_recorded);
-    m_LumiTree->Branch("Total_L1RatediveffxsecRunRecorded",&m_total_l1ratediveffxsecRun_recorded);
-    m_LumiTree->Branch("AvergeInteractionPerXing",&m_AvEvtsPerBX);
-    m_LumiTree->Branch("BSValid", &m_bsvalid);
-  }
- 
-}
-
-
-void LumiCalculator::SetCollName(const std::string& lbcollname){
-  m_lbcollname = lbcollname;
-}
-
-
-void LumiCalculator::Verbose(bool verbose){
-  m_verbose = verbose;
-}
-
-void LumiCalculator::UseMC(bool mc){
-
-  // Print warning
-  if (mc) 
-    m_logger << Root::kWARNING << "Monte Carlo mode no longer supported!" << Root::GEndl;
-
-}
-
-void LumiCalculator::UseOnlineLumi(bool online){
-
-  if(online == true){
-    m_onlinelumi = true;
-    lumi_database = m_lumionl + m_data_db;
-    m_parlumiestfolder = "/TRIGGER/LUMI/LBLESTONL";
-  }
-}
-
-void LumiCalculator::UseLumiTag(const std::string& tag){
-  m_lumitag = tag;
-}
-
-void LumiCalculator::UseLumiMethod(const std::string& method){
-  m_lumimethod = method;
-}
-
-void LumiCalculator::UseLumiChannel(int chan){
-  m_lumichannel = chan;
-  m_lumimethod = "";
-}
-
-
-void LumiCalculator::UseLiveTrigger(bool live, std::string& livetrigger){
-  m_uselivetrigger = live;
-  m_livetrigger = livetrigger;
-}
-
-void LumiCalculator::UseLArNoiseDB(bool lar, const std::string& lartag) {
-  m_uselar = lar;
-  m_lartag = lartag;
-}
-
-void LumiCalculator::UseBeamspot(bool bs, const std::string& bstag) {
-  m_usebs = bs;
-  m_bstag = bstag;
-}
-
-TTree * LumiCalculator::getTree(){
-  if(m_LumiTree != 0)return m_LumiTree;
-  return 0;
-}
-
-//______________________________________________________________________________
-void  LumiCalculator::IntegrateLumi(const LumiBlockCollection * iovc, const std::string& triggerchain){
-
-
-  CoolQuery * cq_lumi = NULL;
-  CoolQuery * cq_trigger = NULL;
-  CoolQuery* cq_lar = NULL;
-  CoolQuery* cq_bs = NULL;
-
-  m_logger << Root::kINFO << "Luminosity database: " << lumi_database << Root::GEndl;
-  m_logger << Root::kINFO << "Trigger database: " << trig_database << Root::GEndl;
-
-  cq_lumi = new CoolQuery(lumi_database, triggerchain);
-  if (!cq_lumi->openDbConn()) {
-    delete cq_lumi;
-    return;
-  }
-
-  cq_trigger = new CoolQuery(trig_database, triggerchain);
-  if (!cq_trigger->openDbConn()) {
-    delete cq_trigger;
-    return;
-  }
-
-  if (m_uselar) {
-    m_logger << Root::kINFO << "LAr database: " << lar_database << Root::GEndl;
-
-    cq_lar = new CoolQuery(lar_database, triggerchain);
-    if (!cq_lar->openDbConn()) {
-      delete cq_lar;
-      return;
-    }
-  }
-
-  if (m_usebs) {
-    m_logger << Root::kINFO << "Onl beamspot database: " << bs_database << Root::GEndl;
-
-    cq_bs = new CoolQuery(bs_database, triggerchain);
-    if (!cq_bs->openDbConn()) {
-      delete cq_bs;
-      return;
-    }
-  }
-
-  // initialize
-  m_totalDelL = 0.;
-  m_totalL = 0.;
-  m_totalLRun = 0.;
-  m_totaltime = 0.;
-  m_instLumi = 0.;
-  m_delLumi = 0.;
-  m_intLumi = 0.;
-  m_deltaT = 0.;
-  m_totalPrescaleWLiveTime = 0.;
-  m_totalPrescale = 0.;
-  m_lumiWOPrescale = 0.;
-  m_lumiLAr = 0.;
-  m_TotaldeltaT = 0.;
-  m_livefrac = 0.;
-  m_livetime = 0.;
-  m_lartime = 0.;
-  m_larfrac = 0.;
-  m_bsvalid = 0.;
-  m_livetime_l1acc = 0;
-  m_l1acc = 0;
-  m_l2acc = 0;
-  m_l3acc = 0;
-  m_totall1acc = 0;
-  m_livtrig_totall1acc = 0;
-  m_totall2acc = 0;
-  m_totall3acc = 0;
-  m_l1prescale = 1.;
-  m_l2prescale = 1.;
-  m_l3prescale = 1.;
-  m_livetime_beforeprescale = 0;
-  m_livetime_afterprescale = 0;
-  m_afterprescale = 0;
-  m_beforeprescale = 0;
-  m_totall1befpresc = 0;
-  m_runnbr = 0;
-  m_lbstart = 0;
-  m_lbstop = 0;
-  m_lbstart_prev = 0;
-  m_lbstop_prev = 0;
-  m_totalgoodblock = 0;
-  m_totalbadblock = 0;
-  m_clumiblocknbr = 0;
-  m_clumiblocknbrend =0;
-  m_triglevel = 0;
-  m_lbcollectionname = "LumiBlocks";
-  m_triggerchain = triggerchain;
-  m_l1rate = 0.;
-  m_l2rate = 0.;
-  m_l3rate = 0.;
-  m_l1ratediveffxsec = 0.;
-  m_total_l1ratediveffxsec = 0.;
-  m_total_l1ratediveffxsecRun = 0.;
-  m_l1ratediveffxsec_recorded = 0.;
-  m_total_l1ratediveffxsec_recorded = 0.;
-  m_total_l1ratediveffxsecRun_recorded = 0.;
-  m_runnbr_prev = 0;
-
-  // Set to extreme values, to be updated below
-  m_minrun = 99999999;
-  m_maxrun = 0;
-
-  bool firstL1Missing = true;
-  bool firstHLTMissing = true;
-
-  std::set<cool::ValidityKey> lbrunset;
-  lbrunset.clear();
- 
-  // collisions xml file settings
-  if (m_collsgrl!=0) { delete m_collsgrl; m_collsgrl=0; }
-  if (m_makecollList) {
-    m_collsgrl = new Root::TGoodRunsList();
-    m_collsgrl->SetVersion("30"); // lumicalc signature
-    m_collsgrl->AddMetaData("Query","Generated by LumiCalculator");
-  }
- 
-  // Figure out trigger level  
-  m_triglevel = cq_lumi->getTriggerLevel(triggerchain);
-  if (m_triglevel == 0){
-    // Check if on purpose, otherwise, give a warning
-    if (triggerchain == "None") {
-      m_logger << Root::kINFO << "No trigger specified!" << Root::GEndl;
-    } else {
-      m_logger << Root::kWARNING << "Invalid trigger: [" << triggerchain << "] - will proceed with no trigger defined!" << Root::GEndl;
-    }
-  }
-
-  // Look for b-jet triggers
-  regex_t regex;
-  int reti = regcomp(&regex, "_[[:digit:]]?b[[:digit:]]+_", REG_EXTENDED);
-  if (reti) m_logger << Root::kWARNING << "Could not compile regex!" << Root::GEndl;
-
-  reti = regexec(&regex, triggerchain.c_str(), 0, NULL, 0);
-  if ( !reti && !m_usebs) {
-    m_logger << Root::kWARNING << "Trigger: [" << triggerchain << "] appears to be a b-jet trigger, but online beamspot validity not included in livefraction!" << Root::GEndl;
-    m_logger << Root::kWARNING << "Probably need to specify --beamspot to get accurate luminosity!" << Root::GEndl;
-  }
-  regfree(&regex);
-
-  // get lumi channel id (this never changes)
-  if (m_lumimethod != "") {
-    Lumiid = cq_lumi->getLumiChannelId(m_lumimethod, m_parlumiestfolder);
-  } else {
-    Lumiid = m_lumichannel;
-  }
-
-
-  // do main LumiBlock loop
-  //==============================
-
-  IOVData<cool::Int32> L1preObj;
-  IOVData<cool::Float> L2preObj;
-  IOVData<cool::Float> L3preObj;
-  IOVData<cool::UInt32> LArObj;
-  IOVData<cool::Int32> BSObj;
-
-  std::map<cool::ValidityKey, CoolQuery::LumiFolderData> LumiDataMap;
-
-  // UTC nanoseconds since 1970
-  std::map<cool::ValidityKey, cool::UInt63> L1starttime_map;
-  std::map<cool::ValidityKey, cool::UInt63> L1endtime_map;
-
-  // Livetime maps
-  std::map<cool::ValidityKey, CoolQuery::L1CountFolderData> Livetime_map;
-  std::map<cool::ValidityKey, CoolQuery::L1CountFolderData> L1accept_map;
-
-  for(LumiBlockCollection::const_iterator it = iovc->begin(); it != iovc->end(); ++it){
-    const IOVRange * iovr = (*it);
-    
-    // Bookkeeping temporary results
-    mt_totalDelL = 0.;
-    mt_totalL = 0.;
-    mt_totalLRun = 0.;
-    mt_totaltime = 0.;
-    mt_deltaT = 0.;
-    mt_l1acc = 0;
-    mt_l2acc = 0;
-    mt_l3acc = 0;
-    mt_totalgoodblock = 0;
-    mt_totalbadblock = 0;
-    mt_totall1befpresc = 0;    
-    mt_totalPrescaleWLiveTime = 0.;
-    mt_totalPrescale = 0.;
-    mt_lumiWOPrescale = 0. ;
-    mt_lumiLAr = 0.;
-  
-    m_runnbr = iovr->start().run();
-    m_lbstart = iovr->start().event();
-    m_lbstop = iovr->stop().event();
-
-    // Look for duplicate run/LB 
-    if(m_lbstart_prev == m_lbstart && m_lbstop_prev == m_lbstop && m_runnbr_prev == m_runnbr){
-      m_logger << Root::kWARNING << "Skipping multiply stored IOVRange: [" << m_lbstart << "-" << m_lbstop << "]" << Root::GEndl;
-      continue;
-    }
-
-    // new run, reset its lumi and reload the trigger channels
-    if ( m_runnbr!=m_runnbr_prev ) {
-
-      if (m_runnbr < m_minrun) m_minrun = m_runnbr;
-      if (m_runnbr > m_maxrun) m_maxrun = m_runnbr;
-
-      m_totalLRun=0.;
-      m_total_l1ratediveffxsecRun=0.;
-      m_total_l1ratediveffxsecRun_recorded=0.;
-
-      // Set IOV range for full run
-      cq_trigger->setIOVForRun (m_runnbr);
-      cq_lumi->setIOVForRun(m_runnbr);
-
-      // get trigger channel ids
-      L1Valid = false;
-      L2Valid = false;
-      L3Valid = false;
-      LiveValid = false;
-      m_triggerlowerchains.clear();
-
-      std::string lowerch = "";
-
-      // This is really inefficient...
-      if(m_triglevel == 3){
-	L3id = cq_trigger->getHLTChannelId(triggerchain, m_parhltmenufolder);
-	L3Valid = cq_trigger->channelIdValid();
-
-	lowerch =  cq_trigger->getHLTLowerChainName(triggerchain, m_parhltmenufolder); 
-	m_triggerlowerchains.push_back(lowerch); 
-	L2id = cq_trigger->getHLTChannelId(lowerch, m_parhltmenufolder);
-	L2Valid = cq_trigger->channelIdValid();
-
-	lowerch = cq_trigger->getHLTLowerChainName(lowerch, m_parhltmenufolder); 
-	m_triggerlowerchains.push_back(lowerch);
-	L1id = cq_trigger->getL1ChannelId(lowerch, m_parlvl1menufolder );
-	L1Valid = cq_trigger->channelIdValid();
-
-      }else if(m_triglevel == 2){
-	lowerch =  cq_trigger->getHLTLowerChainName(triggerchain, m_parhltmenufolder); 
-	m_triggerlowerchains.push_back(lowerch);
-	L2id = cq_trigger->getHLTChannelId(triggerchain, m_parhltmenufolder);
-	L2Valid = cq_trigger->channelIdValid();
-
-	L1id = cq_trigger->getL1ChannelId(lowerch, m_parlvl1menufolder); 
-	L1Valid = cq_trigger->channelIdValid();
-
-      }else if(m_triglevel == 1){
-	L1id = cq_trigger->getL1ChannelId(triggerchain, m_parlvl1menufolder);
-	L1Valid = cq_trigger->channelIdValid();
-	
-      }
-
-      if (!firstL1Missing && (!L1Valid && m_triglevel > 0)) {
-	firstL1Missing = false;
-	cq_trigger->printL1Triggers(m_parlvl1menufolder);
-      }
-
-      if (!firstHLTMissing && ((!L2Valid && m_triglevel > 1) || (!L3Valid && m_triglevel > 2)) ) {
-	firstHLTMissing = false;
-	cq_trigger->printHLTTriggers(m_parhltmenufolder);
-      }
-
-      // Should we check here for btag trigger and onl beamspot?
-
-      // Do we use dedicated livetime trigger?
-      if(m_uselivetrigger){
-	LiveL1id = cq_trigger->getL1ChannelId(m_livetrigger, m_parlvl1menufolder);
-	LiveValid = cq_trigger->channelIdValid();
-      }else{
-	// then fall back to the original trigger
-	LiveL1id = L1id;
-	LiveValid = L1Valid;
-      }
-
-      if (!LiveValid) {
-	if (m_uselivetrigger)
-	  m_logger << Root::kWARNING << "Runnumber: [" << m_runnbr << "] can't find livefraction trigger [" << m_livetrigger << "]!  Livefraction won't be calculated!" << Root::GEndl;
-	else
-	  m_logger << Root::kWARNING << "Runnumber: [" << m_runnbr << "] can't find trigger [" << triggerchain << "]!  Livefraction won't be calculated!" << Root::GEndl;
-      }
-
-      // Also load all deadtime counters here
-
-      // Need to fix this for non-MC.  HLT counters now available, but not used here...
- 
-      //-------------------------
-      // Load livetime information
-      Livetime_map.clear();
-      L1accept_map.clear();
-
-      if (LiveValid) 
-	Livetime_map = cq_trigger->getL1CountFolderData(m_parlumilvl1folder, LiveL1id);
-
-      
-      if (L1Valid && m_triglevel >= 1) 
-	L1accept_map = cq_trigger->getL1CountFolderData(m_parlumilvl1folder, L1id);
-
-      // UTC nanoseconds since 1970
-      L1starttime_map.clear();
-      L1endtime_map.clear();
-      L1starttime_map = cq_trigger->getObjMapFromFolderAtChan<cool::UInt63>("StartTime", m_parlvl1lblbfolder, 0);
-      L1endtime_map = cq_trigger->getObjMapFromFolderAtChan<cool::UInt63>("EndTime", m_parlvl1lblbfolder, 0);
-
-      //---------------------------
-      // Load LAr defects
-      LArObj.clear();
-
-      if (m_uselar) {
-	cool::ValidityKey runstarttime = L1starttime_map.begin()->second;
-	cool::ValidityKey runendtime = L1endtime_map.rbegin()->second;
-
-	cq_lar->setIOV(runstarttime, runendtime); 
-	LArObj = cq_lar->getIOVData<cool::UInt32>("EventVeto", m_parlareventvetofolder, 0, m_lartag);
-      }
-
-      //---------------------------
-      // Load Onl beamspot
-      BSObj.clear();
-
-      if (m_usebs) {
-	cq_bs->setIOVForRun(m_runnbr);
-	BSObj = cq_bs->getIOVData<cool::Int32>("status", m_paronlbeamspotfolder, 0, m_bstag);
-      }
-
-
-      //-----------------------------
-      // Load luminosity for this run
-      LumiDataMap.clear();
-      LumiDataMap = cq_lumi->getLumiFolderData(m_parlumiestfolder, m_lumitag, Lumiid); 
-
-    
-    } // End of new run stuff
-
-    m_lbstart_prev = m_lbstart;
-    m_lbstop_prev = m_lbstop;
-    m_runnbr_prev = m_runnbr;
-    
-    // Update DB for this specific IOV range
-    cq_trigger->setIOV(iovr->start().re_time(), iovr->stop().re_time());
-
-    //----------------------------
-    // Load prescales for this IOV
-    L1preObj.clear();
-    L2preObj.clear();
-    L3preObj.clear();
-    
-    if(L1Valid) {
-      L1preObj = cq_trigger->getIOVData<cool::Int32>("Lvl1Prescale", m_parlvl1prescalesfolder, L1id);
-    }
-      
-    if(L2Valid) {
-      L2preObj = cq_trigger->getIOVData<cool::Float>("Prescale", m_parhltprescalesfolder, 2*L2id);
-    }    
-      
-    if(L3Valid) {
-      L3preObj = cq_trigger->getIOVData<cool::Float>("Prescale", m_parhltprescalesfolder, 2*L3id+1);
-    }
-
-    // Reload the time map to get the ATLAS range
-    L1starttime_map.clear();
-    L1endtime_map.clear();
-    L1starttime_map = cq_trigger->getObjMapFromFolderAtChan<cool::UInt63>("StartTime", m_parlvl1lblbfolder, 0);
-    L1endtime_map = cq_trigger->getObjMapFromFolderAtChan<cool::UInt63>("EndTime", m_parlvl1lblbfolder, 0);
-
-    // Print this here (will be output for each contiguous LB range in XML file)
-    m_logger << Root::kINFO << std::left << "-----------------------------------" << Root::GEndl;
-    m_logger << Root::kINFO << "Beginning calculation for ";
-    if (m_triglevel > 0) {
-      m_logger << Root::kINFO << "Trigger " << m_triggerchain;
-      if(m_triggerlowerchains.size() > 0){
-	m_logger << Root::kINFO << "["; 
-	for(std::vector<std::string>::iterator sit = m_triggerlowerchains.begin(); sit != m_triggerlowerchains.end(); ++sit){
-	  m_logger << Root::kINFO << "==>" << *sit;
-	}
-	m_logger << Root::kINFO << "], "; 
-      }
-    }
-    m_logger << Root::kINFO << "Run " << m_runnbr << " LB [" << m_lbstart << "-" << m_lbstop << "]" << Root::GEndl;
-
-    // Restrict lb range if necessary based on actual ATLAS run/lb values
-    if (L1starttime_map.begin()->first > iovr->start().re_time() || L1starttime_map.rbegin()->first < iovr->stop().re_time()) {
-      m_lbstart = (L1starttime_map.begin()->first & 0xFFFFFFFF);
-      m_lbstop = (L1starttime_map.rbegin()->first & 0xFFFFFFFF);
-      m_logger << Root::kINFO << "Restricting to valid ATLAS lumi block range [" << m_lbstart << "-" << m_lbstop << "]" << Root::GEndl;
-    }
-
-
-    //
-    // Dont assume that all lumi blocks in this range are present in the lumi DB.
-    // Loop over all lumi blocks specifically and flag any missing lumi entries as bad lumi blocks.
-    //
-
-    // Counters to check for missing LB ranges
-    int firstMissing = -1;
-    int lastMissing = -1;
-
-    for (cool::ValidityKey currentVK = L1starttime_map.begin()->first; currentVK <= L1starttime_map.rbegin()->first; currentVK++) {
-      //for(; itOL != LumiDataMap.end(); ++itOL){
-
-      // Current ValidityKey:
-      //cool::ValidityKey currentVK = itOL->first;
-	  
-      // Current IOVTime
-      IOVTime curIOV;
-      curIOV.setRETime(currentVK);
-
-      //m_clumiblocknbr = (itOL->first & 0xFFFFFFFF);
-      //m_clumiblocknbrend = ((itOL->first & 0xFFFFFFFF) + 1);
-      m_clumiblocknbr = curIOV.event();
-      m_clumiblocknbrend = curIOV.event()+1;
-
-      // Check here for duplicate lumi blocks by explicitly keeping track of every run/lb seen
-      if (lbrunset.count(curIOV.re_time()) != 0) {
-	m_logger << Root::kWARNING << "Skipping duplicate [run,lumiblock]: " << curIOV << " !" << Root::GEndl;
-	continue;
-      } else {
-	lbrunset.insert(curIOV.re_time());
-      }
-      
-      // Not really good, just all seen
-      m_totalgoodblock += 1;
-      mt_totalgoodblock += 1;
-      
-      // Find luminosity record
-      std::map<cool::ValidityKey, CoolQuery::LumiFolderData>::iterator itOL = LumiDataMap.find(currentVK);
-
-      // Check if we didn't find anything
-      if (itOL == LumiDataMap.end()) {
-
-	mt_totalbadblock++;
-	m_totalbadblock++;
-
-	if (firstMissing < 0) {
-	  // Is this the first missing one?  If so, make a note of it and go on
-	  firstMissing = curIOV.event();
-	  lastMissing = firstMissing;
-	} else if (int(curIOV.event()) == (lastMissing+1)) {
-	  // Is this a contiguous missing lumi block?
-	  lastMissing = curIOV.event();
-	} else {
-	  // Not contiguous, print previous
-	  if (firstMissing == lastMissing) {
-	    m_logger << Root::kWARNING << "Luminosity info not found for Run " << m_runnbr << " LB " << firstMissing << " !" << Root::GEndl;
-	  } else {
-	    m_logger << Root::kWARNING << "Luminosity info not found for Run " << m_runnbr << " LB [" << firstMissing << "-" << lastMissing << "] !" << Root::GEndl;
-	  }
-	  firstMissing = curIOV.event();
-	  lastMissing = firstMissing;
-	}
-
-	// If last time through loop, print this also
-	if (currentVK == L1starttime_map.rbegin()->first) {
-	  if (firstMissing == lastMissing) {
-	    m_logger << Root::kWARNING << "Luminosity info not found for Run " << m_runnbr << " LB " << firstMissing << " !" << Root::GEndl;
-	  } else {
-	    m_logger << Root::kWARNING << "Luminosity info not found for Run " << m_runnbr << " LB [" << firstMissing << "-" << lastMissing << "] !" << Root::GEndl;
-	  }
-	  firstMissing = -1;
-	  lastMissing = -1;
-	}
-
-	// Skip rest of this LB
-	continue;
-
-      } else {
-
-	// Check if we had previous missing block
-	if (firstMissing >= 0) {
-	  if (firstMissing == lastMissing) {
-	    m_logger << Root::kWARNING << "Luminosity info not found for Run " << m_runnbr << " LB " << firstMissing << " !" << Root::GEndl;
-	  } else {
-	    m_logger << Root::kWARNING << "Luminosity info not found for Run " << m_runnbr << " LB [" << firstMissing << "-" << lastMissing << "] !" << Root::GEndl;
-	  }
-
-	  firstMissing = -1;
-	  lastMissing = -1;
-	}
-
-      }
-
-
-      // given in units of ub^{-1} = 10^{30} cm^{-2}
-      m_instLumi = (itOL->second).LBAvInstLumi;
-      m_AvEvtsPerBX = (itOL->second).LBAvEvtsPerBX;
-      m_Valid = (itOL->second).Valid;
-	  
-
-      // Clear values in case trigger isn't defined
-      m_l1acc = 0.;
-      m_beforeprescale = 0.;
-      m_afterprescale = 0.;
-      m_l2acc = 0.;
-      m_l3acc = 0.;
-      
-      // Store dummy prescale values at start
-      m_l1prescale = -1.;
-      m_l2prescale = -1.;
-      m_l3prescale = -1.;
-      
-      // Some trigger is defined.  Get prescales and values here
-       if(L1Valid && m_triglevel > 0) {
-	
-	 // Get L1 prescale
-	 m_l1prescale = L1preObj.getValue(curIOV);
-
-	if (m_triglevel >=2) {
-	  if(L2Valid) {
-
-	    // Get L2 prescale
-	    m_l2prescale = L2preObj.getValue(curIOV);
-
-	  }
-	  // Else, prescale stays at -1.
-	  
-	} else {
-	  // Force L2 'passthrough'
-	  m_l2prescale = 1.;
-	}
-	
-	if(m_triglevel == 3){
-	  if (L3Valid) {
-
-	    // Get L3 prescale
-	    m_l3prescale = L3preObj.getValue(curIOV);
-
-	  }
-	  // Else, L3 prescale stays at -1.
-	} else {
-	  // Force L3 'passthrough'
-	  m_l3prescale = 1.;
-	}
-      }
-      
-      //-------------------------------
-      // Calculate livetime from a dedicated not rare trigger if user requested
-      CoolQuery::L1CountFolderData l1count = Livetime_map.find(currentVK)->second;
-
-      m_livetime_beforeprescale = l1count.BeforePrescale;
-      m_livetime_afterprescale = l1count.AfterPrescale;
-      m_livetime_l1acc = l1count.L1Accept;
-      if(m_livetime_afterprescale > 0.){
-	m_livefrac = m_livetime_l1acc/(float)m_livetime_afterprescale;
-      }else{
-	m_livefrac = 0.0;
-      }
-      
-      // Check for low statistics in afterprescale counts
-      if(m_livetime_beforeprescale > 0 && m_livetime_afterprescale <= 0 ){
-	std::string ttrig = "";
-	ttrig = triggerchain;
-	if(m_uselivetrigger)ttrig = m_livetrigger;
-	m_logger << Root::kWARNING << "L1 counts after prescale (before veto) are 0.0 for trigger " << ttrig << "! Livefraction set to zero!" << Root::GEndl;
-	m_logger << Root::kWARNING << "Try using a high rate L1 trigger for livetime calculation: --livetrigger=<high rate L1 trigger> " << Root::GEndl;
-	m_logger << Root::kINFO << m_runnbr << "[" << m_clumiblocknbr << "]: L1Acc: " << m_l1acc << ", AfterPrescale: " << m_afterprescale  << ", L1Presc: " << m_l1prescale << Root::GEndl;
-      }	    
-
-      //------------------------
-      // Calculate LAr veto time
-
-      cool::ValidityKey lbstarttime = L1starttime_map.find(currentVK)->second;
-      cool::ValidityKey lbendtime = L1endtime_map.find(currentVK)->second;
-
-      m_lartime = 0.; // Time to exclude in seconds
-      if (m_uselar) {
-
-	IOVTime lbstart, lbend;
-	lbstart.setRETime(lbstarttime);
-	lbend.setRETime(lbendtime);
-	IOVRange range(lbstart, lbend);
-
-	std::list<std::pair<IOVRange, cool::UInt32> > larlist;
-	larlist = LArObj.getOverlap(range);
-
-	for (std::list<std::pair<IOVRange, cool::UInt32> >::iterator it = larlist.begin(); it != larlist.end(); it++) {
-	  if (it->second == 0) continue;
-	  float dtime = (it->first.stop().re_time() - it->first.start().re_time())/1.E9;
-	  m_lartime += dtime;
-	}
-      }
-
-      //------------------------
-      // Check for online BS
-      m_bsvalid = 1.;
-      if (m_usebs) {
-
-	// Read beamspot validity
-	bool valid = true;
-	int status = BSObj.getValue(curIOV);
-	//m_logger << Root::kINFO << "Found online beamspot status = " << status << Root::GEndl;
-
-	if (status != 7) valid = false;
-
-	if (!valid) {
-	  m_bsvalid = 0.0;
-	  m_livefrac = 0.0;
-	  if(m_verbose == true){
-	    m_logger << Root::kINFO << m_runnbr << "[" << m_clumiblocknbr << "]: Online beamspot invalid with Lumi=" << m_instLumi << " 10^30 cm-2 s-1" << Root::GEndl;
-	  }
-	}
-      }
-
-      //-------------------------------
-
-      l1count = L1accept_map.find(currentVK)->second;
-      m_beforeprescale = l1count.BeforePrescale;
-      m_beforeprescaleof = false;
-      m_afterprescale = l1count.AfterPrescale;
-      m_afterprescaleof = false;
-      m_l1acc = l1count.L1Accept;
-      m_l1accof = false;
-      
-      m_deltaT = (lbendtime-lbstarttime)/1.E9;
-
-      if (m_deltaT > 0.) m_larfrac = 1.-m_lartime/m_deltaT;
-
-      // For online lumi database case one needs to make some changes:
-      if(m_onlinelumi == true){
-	// In Valid UInt32 type value some information is encoded:
-	// see: https://twiki.cern.ch/twiki/bin/view/Atlas/CoolOnlineData#Folder_TRIGGER_LUMI_LBLESTONL 
-	cool::UInt32 tempValid = (m_Valid & 1023);
-	    
-	if(tempValid == 10){
-	  // in this bits, Value 301 and 302 means MBTS and LUCID lumi for which some care is needed
-	  if((m_Valid >> 22) == 301
-	     || (m_Valid >> 22) == 302 
-	     || (m_Valid >> 22) == 101
-	     || (m_Valid >> 22) == 102
-	     || (m_Valid >> 22) == 103
-	     || (m_Valid >> 22) == 104
-	     ){
-	    m_Valid = 0;
-	  }else{
-	    m_Valid = tempValid;
-	  }
-	}else{
-	  m_Valid = tempValid;
-	}
-	
-      } else {
-	
-	// For offline, we also need to strip out the preferred channel value from the validity word
-	// if (Lumiid == 0) m_Valid &= 0x3FF;
-	m_Valid &= 0x3FF;
-      }
-
-      // Dump out debugging information
-      if(m_verbose == true){
-	m_logger << Root::kINFO << m_runnbr << "[" << m_clumiblocknbr << "]: L1Acc: " << m_l1acc;
-	if(m_uselivetrigger) m_logger << ", Livetime trigger L1Acc: " << m_livetime_l1acc;
-	m_logger << ", InstLumi: " << m_instLumi << ", deltaT: " << m_deltaT << ", AvEvtsPerBX: " << m_AvEvtsPerBX << ", BeforePrescale: " << m_beforeprescale << ", AfterPrescale: " << m_afterprescale;
-	if (m_uselivetrigger) m_logger  << ", Livetime trigger BeforePrescale: " << m_livetime_beforeprescale << " Livetime trigger AfterPrescale: " << m_livetime_afterprescale;
-	m_logger  << ", Livefrac: " << m_livefrac << ", L1Presc: " << m_l1prescale << ", L2Presc: " << m_l2prescale << ", L3Presc: " << m_l3prescale <<  ", Valid: " << m_Valid;
-	if (m_uselar) m_logger << ", LAr ready fraction: " << m_larfrac;
-	m_logger << Root::GEndl;
-      }
-
-      // Check if we have valid luminosity
-      // Just need to check lowest digit.  10 -> BCID blind, 100 -> mu not valid
-      if(m_Valid%10 != 0){
-	  
-	// Invalid luminosity entry, call it bad
-	m_instLumi = 0.0;
-	m_totalbadblock += 1;
-	mt_totalbadblock += 1;
-	if(m_verbose == true)m_logger << Root::kWARNING << "Skipping lumiblock " <<  m_runnbr << "[" << m_clumiblocknbr << "] with invalid inst. lumi.!" << Root::GEndl;
-	
-      } else if ((m_triglevel > 0) && (m_l1prescale < 0. || m_l2prescale < 0. || m_l3prescale < 0.)) {
-	
-	// Disabled trigger, call bad but still record delivered luminosity
-	m_totalbadblock += 1;
-	mt_totalbadblock += 1;
-	if(m_verbose == true)m_logger << Root::kWARNING << "Lumiblock " <<  m_runnbr << "[" << m_clumiblocknbr << "] has a disabled or incorrectly specified trigger.! " << Root::GEndl;
-	
-      }
-
-      //========================================================//
-      //   L U M I N O S I T Y  C A L C U L A T I O N  H E R E  //
-      //========================================================//
-      // The actual calculation of integrated luminosity and 
-      // accumulation of some variables
-      m_totalDelL += (m_deltaT*m_instLumi); // delivered lumi
-      mt_totalDelL += (m_deltaT*m_instLumi); // delivered lumi
-      mt_deltaT += m_deltaT;
-      
-      // Count up everything
-      m_totall1acc += m_l1acc;
-      m_livtrig_totall1acc += m_livetime_l1acc;
-      mt_l1acc += m_l1acc;
-      m_totall1befpresc += m_beforeprescale;
-      mt_totall1befpresc += m_beforeprescale;
-      m_totall2acc += m_l2acc;
-      mt_l2acc += m_l2acc;
-      m_totall3acc += m_l3acc;
-      mt_l3acc += m_l3acc;
-      m_livetime = m_livefrac*m_deltaT;
-      m_totaltime += m_livetime;
-      mt_totaltime += m_livetime;
-      
-      double totalPrescale = m_l1prescale * m_l2prescale * m_l3prescale;
-	
-      // Check for disabled triggers
-      if (m_l1prescale < 0. ) totalPrescale = 0.;
-      if (m_l2prescale < 0. ) totalPrescale = 0.;
-      if (m_l3prescale < 0. ) totalPrescale = 0.;
-      
-      // Check also for no trigger
-      if (m_triglevel == 0) totalPrescale = 1.;
-	
-      m_intLumi = 0.;
-
-      m_lumiWOPrescale += m_livetime*m_instLumi ;
-      mt_lumiWOPrescale += m_livetime*m_instLumi ;
-
-      m_lumiLAr += m_livetime*m_larfrac*m_instLumi;
-      mt_lumiLAr += m_livetime*m_larfrac*m_instLumi;
-
-      if (totalPrescale > 0.) {
-	m_totalPrescaleWLiveTime += m_livetime/totalPrescale; 
-	mt_totalPrescaleWLiveTime += m_livetime/totalPrescale; 
-	m_totalPrescale += 1./totalPrescale;
-	mt_totalPrescale += 1./totalPrescale;
-	m_intLumi = m_larfrac * m_livetime * m_instLumi/totalPrescale; // <<<---  T H E  F O R M U L A
-      } 
-
-
-      m_totalL += m_intLumi;
-      mt_totalL += m_intLumi; 
-      m_totalLRun += m_intLumi;
-
-      
-      // MB: trigger rates, note that livefrac drops out of ratio
-      m_l1rate = ( m_livetime>0 ? m_l1acc / m_livetime : 0. );
-      m_l2rate = ( m_livetime>0 ? m_l2acc / m_livetime : 0. );
-      m_l3rate = ( m_livetime>0 ? m_l3acc / m_livetime : 0. );
-      
-      // MB: delivered lumi
-      m_l1ratediveffxsec = (float)m_afterprescale/( m_deltaT*m_effxsec );
-      m_total_l1ratediveffxsec += (float)m_afterprescale / m_effxsec ;
-      m_total_l1ratediveffxsecRun += (float)m_afterprescale / m_effxsec ;
-      
-      // MB: recorded lumi
-      m_l1ratediveffxsec_recorded = (float)m_l1acc /( m_deltaT*m_effxsec );
-      m_total_l1ratediveffxsec_recorded += (float)m_l1acc / m_effxsec ;
-      m_total_l1ratediveffxsecRun_recorded += (float)m_l1acc / m_effxsec ;
-      
-      if (m_collsgrl!=0) {
-	if ( m_l1rate>=m_mintrigrate )
-	  m_collsgrl->AddRunLumiBlock(m_runnbr,m_clumiblocknbr);
-      }
-      
-      if (m_verbose) {
-	if (m_effxsec!=1.0)
-	  m_logger << Root::kINFO << "L1rate a/ prescale: " << m_afterprescale << ", Delivered LumiFromL1rate (/ub): " << m_l1ratediveffxsec << ", Delivered TotalLumiFromL1rate (/ub): " << m_total_l1ratediveffxsec
-		   << Root::GEndl;
-      }
-      
-      if(m_LumiTree != 0)m_LumiTree->Fill();
-    } // End of loop over lumi blocks
-
-    // Print IOV summary
-    m_logger << Root::kINFO << std::left << "-----------------------------------" << Root::GEndl;
-    m_logger << Root::kINFO<< std::setw(10) << std::left << ">== Trigger  : " << triggerchain << Root::GEndl;
-    m_logger << Root::kINFO<< std::setw(10) << std::right << "Run" <<  std::setw(10) << std::right << "L1-Acc" << std::setw(10) << std::right << "L2-Acc" << std::setw(10) << std::right <<  "L3-Acc" << std::setw(10) << std::right <<  "LiveTime" << std::setw(18) << std::right <<  "IntL rec.(ub^-1)" << std::setw(18) << std::right <<  "IntL del.(ub^-1)" << Root::GEndl;
-    m_logger << Root::kINFO<< std::setw(10) << std::right << m_runnbr << std::setw(10) << std::right << mt_l1acc << std::setw(10) << std::right << mt_l2acc << std::setw(10) << std::right << mt_l3acc << std::setw(10) << std::right << mt_totaltime << std::setw(18) << std::right << mt_totalL << std::setw(18) << std::right << mt_totalDelL << Root::GEndl;
-    //    m_logger << Root::kINFO << std::setw(10) << std::right << "BeforePrescale" << std::setw(10) << std::right << m_totall1befpresc << std::setw(10) << std::right << "" << std::setw(10) << std::right << "" << std::setw(10) << std::right << "" << std::setw(10) << std::right << "" << std::setw(10) << std::right << "" << std::setw(10) << m_TotaldeltaT << std::setw(14) << std::right << m_totalL << Root::GEndl;
-    
-    m_logger << Root::kINFO<< std::setw(10) << std::left << "L1/2/3 accept: " <<  std::setw(10) << std::left << mt_l1acc <<  std::setw(10) << std::left << mt_l2acc <<  std::setw(10) << std::left << mt_l3acc << Root::GEndl;
-    m_logger << Root::kINFO << std::setw(10) << std::left << "L1BeforePresc: " << std::setw(10) << std::left << mt_totall1befpresc << Root::GEndl;
-    m_logger << Root::kINFO << std::setw(10) << std::left << "Livetime     : " << mt_totaltime << Root::GEndl;
-    m_logger << Root::kINFO << std::setw(10) << std::left << "Prescale Weighted Livetime: " <<  mt_totalPrescaleWLiveTime << Root::GEndl; 
-    m_logger << Root::kINFO<< std::setw(10)  << std::left << "Good LBs     : " << mt_totalgoodblock - mt_totalbadblock << Root::GEndl;
-    m_logger << Root::kINFO<< std::setw(10)  << std::left << "Bad LBs      : " << mt_totalbadblock << Root::GEndl;
-    
-    if ( m_effxsec==1.0 ) {
-      m_logger << Root::kINFO << std::setw(10) << std::left << "IntL delivered (ub^-1) : " << mt_totalDelL << Root::GEndl;
-      m_logger << Root::kINFO << std::setw(10) << std::left << "IntL after livefraction (ub^-1):  " <<  mt_lumiWOPrescale << Root::GEndl;
-      if (m_uselar)
-	m_logger << Root::kINFO << std::setw(10) << std::left << "IntL after LAr fraction (ub^-1):  " <<  mt_lumiLAr << Root::GEndl;
-      m_logger << Root::kINFO << std::setw(10) << std::left << "IntL recorded after prescale (ub^-1) : " << mt_totalL << Root::GEndl;
-    } else {
-      m_logger << Root::kINFO << std::setw(10) << std::left << "IntL delived  (ub^-1) : " << m_total_l1ratediveffxsec << Root::GEndl;
-      m_logger << Root::kINFO << std::setw(10) << std::left << "IntL recorded (ub^-1) : " << m_total_l1ratediveffxsec_recorded << Root::GEndl;
-    }
-
-    // Print prescales as range of actual lumi blocks these apply to
-    if(m_triglevel >= 1){
-      // Print L1 Prescale values:
-      m_logger << Root::kINFO << std::setw(10) << std::left << "L1 Prescales: ";
-
-      std::list< std::pair<IOVRange, cool::Int32> >::iterator it;
-      for(it = L1preObj.data.begin(); it != L1preObj.data.end(); it++) {
-	m_logger << Root::kINFO << std::setw(1) << std::left << "[" << it->first.start().event() << "," << it->first.stop().event()-1 << "]:" << it->second <<  ", "; 
-      }
-      m_logger << Root::kINFO << Root::GEndl;
-    }
-    
-    if(m_triglevel >= 2){
-      // Print L2 Prescale values:
-      m_logger << Root::kINFO << std::setw(10) << std::left << "L2 Prescales: ";
-
-      std::list< std::pair<IOVRange, cool::Float> >::iterator it;
-      for(it = L2preObj.data.begin(); it != L2preObj.data.end(); it++) {
-	m_logger << Root::kINFO << std::setw(1) << std::left << "[" << it->first.start().event() << "," << it->first.stop().event()-1 << "]:" << it->second <<  ", "; 
-      }
-      m_logger << Root::kINFO << Root::GEndl;
-    }
-    
-    if(m_triglevel == 3){
-      // Print L3 Prescale values:
-      m_logger << Root::kINFO << std::setw(10) << std::left << "L3 Prescales: ";
-
-      std::list< std::pair<IOVRange, cool::Float> >::iterator it;
-      for(it = L3preObj.data.begin(); it != L3preObj.data.end(); it++) {
-	m_logger << Root::kINFO << std::setw(1) << std::left << "[" << it->first.start().event() << "," << it->first.stop().event()-1 << "]:" << it->second <<  ", "; 
-      }
-      m_logger << Root::kINFO << Root::GEndl;
-    }  
-
-  } // end lb collection loop
-
-
-  // ------------------------------------------------------------------------------------------------
-  // MB : Print total only at end of LB loop:
-  m_logger << Root::kINFO << std::left << "-----------------------------------" << Root::GEndl;
-  m_logger << Root::kINFO << std::left << "  LumiCalculator summary" << Root::GEndl;
-  m_logger << Root::kINFO << std::left << "-----------------------------------" << Root::GEndl;
-  m_logger << Root::kINFO<< std::setw(10) << std::right << "Total" <<  std::setw(10) << std::right << "L1-Acc" << std::setw(10) << std::right << "L2-Acc" << std::setw(10) << std::right <<  "L3-Acc" <<
-              std::setw(10) << std::right <<  "LiveTime" << std::setw(18) << std::right <<  "IntL rec.(ub^-1)" << std::setw(18) << std::right <<  "IntL del.(ub^-1)" << Root::GEndl;
-  m_logger << Root::kINFO<< std::setw(10) << std::right << "" << std::setw(10) << std::right << m_totall1acc << std::setw(10) << std::right << m_totall2acc << std::setw(10) << std::right 
-           << m_totall3acc << std::setw(10) << std::right << m_totaltime << std::setw(18) << std::right << m_totalL << std::setw(18) << std::right << m_totalDelL << Root::GEndl;
-  m_logger << Root::kINFO<< std::setw(10) << std::left << "Total L1/2/3 accept: " <<  std::setw(10) << std::left << m_totall1acc <<  std::setw(10) << std::left << m_totall2acc <<  std::setw(10) 
-           << std::left << m_totall3acc << Root::GEndl;
-  if(m_uselivetrigger)m_logger << Root::kINFO<< std::setw(10) << std::left << "Total L1 livetime trigger accept: " <<  std::setw(10) << std::left << m_livtrig_totall1acc << Root::GEndl;
-
-  m_logger << Root::kINFO << std::setw(10) << std::left << "First Run: " << std::setw(10) << std::left << m_minrun << Root::GEndl;
-  m_logger << Root::kINFO << std::setw(10) << std::left << "Last Run: " << std::setw(10) << std::left << m_maxrun << Root::GEndl;
-  m_logger << Root::kINFO << std::setw(10) << std::left << "Total L1BeforePresc: " << std::setw(10) << std::left << m_totall1befpresc << Root::GEndl;
-  m_logger << Root::kINFO<< std::setw(10) << std::left  << "Total Livetime     : " << m_totaltime << Root::GEndl;
-  m_logger << Root::kINFO << std::setw(10) << std::left << "Total prescale weighted Livetime: " <<  m_totalPrescaleWLiveTime << Root::GEndl;
-  m_logger << Root::kINFO<< std::setw(10) << std::left  << "Total Good LBs     : " << m_totalgoodblock - m_totalbadblock << Root::GEndl;
-  m_logger << Root::kINFO<< std::setw(10) << std::left  << "Total Bad LBs     : " << m_totalbadblock << Root::GEndl;
-  m_logger << Root::kINFO << std::setw(10) << std::left << "Total IntL delivered (ub^-1) : " << m_totalDelL << Root::GEndl;
-  m_logger << Root::kINFO << std::setw(10) << std::left << "Total IntL after livefraction (ub^-1):  " <<  m_lumiWOPrescale << Root::GEndl;
-  if (m_uselar)
-    m_logger << Root::kINFO << std::setw(10) << std::left << "Total IntL after LAr fraction (ub^-1):  " <<  m_lumiLAr << Root::GEndl;
-  m_logger << Root::kINFO << std::setw(10) << std::left << "Total IntL recorded (ub^-1) : " << m_totalL << Root::GEndl;
-
-  // ------------------------------------------------------------------------------------------------
-
-  if(m_makecollList == true){
-    // store collisions xml file on demand
-    if (m_collsgrl!=0) {
-      TString collisionsxml = "collisions_" + m_collsgrl->GetSuggestedName() + ".xml";
-      Root::TGoodRunsListWriter writer; 
-      writer.SetGoodRunsList( *m_collsgrl );
-      writer.SetFilename( collisionsxml.Data() );
-      writer.WriteXMLFile();
-      // can now delete grl
-      delete m_collsgrl; m_collsgrl=0;
-    }
-  }
-
-
-  // Creating monitoring plots on demand
-  if(m_makePlots == true) { this->MakePlots(triggerchain); }
-
-  delete cq_trigger;
-  delete cq_lumi;
-  delete cq_lar;
-  delete cq_bs;
-}
-
-// ---------------------------------------------------------------------------------
-// Utility to print lumicalc summary results
-void
-LumiCalculator::printSummary(std::ostream& os) {
-
-  os << std::left << "-----------------------------------" << std::endl;
-  os << std::left << "  LumiCalculator summary" << std::endl;
-  os << std::left << "-----------------------------------" << std::endl;
-  os << std::setw(10) << std::left << "Trigger: " << std::setw(10) << std::left << m_triggerchain << std::endl;
-  os << std::setw(10) << std::left << "First Run: " << std::setw(10) << std::left << m_minrun << std::endl;
-  os << std::setw(10) << std::left << "Last Run: " << std::setw(10) << std::left << m_maxrun << std::endl;
-  os << std::setw(10) << std::left << "Total L1BeforePresc: " << std::setw(10) << std::left << m_totall1befpresc << std::endl;
-  os << std::setw(10) << std::left  << "Total Livetime     : " << m_totaltime << std::endl;
-  os << std::setw(10) << std::left << "Total prescale weighted Livetime: " <<  m_totalPrescaleWLiveTime << std::endl;
-  os << std::setw(10) << std::left  << "Total Good LBs     : " << m_totalgoodblock - m_totalbadblock << std::endl;
-  os << std::setw(10) << std::left  << "Total Bad LBs     : " << m_totalbadblock << std::endl;
-  os << std::setw(10) << std::left << "Total IntL delivered (ub^-1) : " << m_totalDelL << std::endl;
-  os << std::setw(10) << std::left << "Total IntL after livefraction (ub^-1):  " <<  m_lumiWOPrescale << std::endl;
-  if (m_uselar)
-    os << std::setw(10) << std::left << "Total IntL after LAr fraction (ub^-1):  " <<  m_lumiLAr << std::endl;
-  os << std::setw(10) << std::left << "Total IntL recorded (ub^-1) : " << m_totalL << std::endl;
-
-}
-
-void 
-LumiCalculator::DoHistogramAdmin(const uint32_t& runnbr, const TString& trigName, const float& effxsec)
-{
-  // rebin the histograms once number of LBs is known
-  int maxlb = 5000;
-
-  m_ntrigplbVec.push_back(        new TH1F(Form("run%d_ntrigplb",runnbr),            Form("Run %d",runnbr) , maxlb, 0., float(maxlb)) );
-  m_trigrateplbVec.push_back(     new TH1F(Form("run%d_trigrateplb",runnbr),         Form("Run %d",runnbr) , maxlb, 0., float(maxlb)) );
-  m_lumiplbVec.push_back(         new TH1F(Form("run%d_peaklumiplb",runnbr),         Form("Run %d",runnbr) , maxlb, 0., float(maxlb)) );
-  m_lumitrigrateplbVec.push_back( new TH1F(Form("run%d_peaklumitrigrateplb",runnbr), Form("Run %d",runnbr) , maxlb, 0., float(maxlb)) );
-  m_intlumiVec.push_back(         new TH1F(Form("run%d_intlumi",runnbr),             Form("Run %d",runnbr) , maxlb, 0., float(maxlb)) );
-  m_intlumitrigrateVec.push_back( new TH1F(Form("run%d_intlumitrigrate",runnbr),     Form("Run %d",runnbr) , maxlb, 0., float(maxlb)) );
-  m_lumitrigrateplb_recordedVec.push_back( new TH1F(Form("run%d_peakrecordedlumitrigrateplb",runnbr), Form("Run %d",runnbr) , maxlb, 0., float(maxlb)) );
-  m_intlumitrigrate_recordedVec.push_back( new TH1F(Form("run%d_intrecordedlumitrigrate",runnbr),     Form("Run %d",runnbr) , maxlb, 0., float(maxlb)) );
-
-  m_ntrigplb        = *(m_ntrigplbVec.rbegin());
-  m_trigrateplb     = *(m_trigrateplbVec.rbegin());
-  m_lumiplb         = *(m_lumiplbVec.rbegin());
-  m_lumitrigrateplb = *(m_lumitrigrateplbVec.rbegin());
-  m_intlumi         = *(m_intlumiVec.rbegin());
-  m_intlumitrigrate = *(m_intlumitrigrateVec.rbegin());
-  m_lumitrigrateplb_recorded = *(m_lumitrigrateplb_recordedVec.rbegin());
-  m_intlumitrigrate_recorded = *(m_intlumitrigrate_recordedVec.rbegin());
-
-  this->SetHistogramStyle(m_ntrigplb,        Form("Run = %d",runnbr), "Luminosity block number", Form("# %s triggers / LB",trigName.Data()));
-  this->SetHistogramStyle(m_trigrateplb,     Form("Run = %d",runnbr), "Luminosity block number", Form("%s trigger rate / LB",trigName.Data()));
-  this->SetHistogramStyle(m_lumiplb,         Form("Run = %d",runnbr), "Luminosity block number", "Delivered luminosity (#mub^{-1}/s)");
-  this->SetHistogramStyle(m_lumitrigrateplb, Form("Efficiency * x-sec = %.1f #mub, Run = %d",effxsec,runnbr), "Luminosity block number", Form("%s luminosity (#mub^{-1}/s)",trigName.Data()));
-  this->SetHistogramStyle(m_intlumi,         Form("Run = %d",runnbr), "Luminosity block number", "Integrated delivered luminosity (#mub^{-1})");
-  this->SetHistogramStyle(m_intlumitrigrate, Form("Efficiency * x-sec = %.1f #mub, Run = %d",effxsec,runnbr), "Luminosity block number", Form("%s Integrated luminosity (#mub^{-1})",trigName.Data()));
-  this->SetHistogramStyle(m_lumitrigrateplb_recorded, Form("Efficiency * x-sec = %.1f #mub, Run = %d",effxsec,runnbr), "Luminosity block number", Form("%s Recorded luminosity (#mub^{-1}/s)",trigName.Data()));
-  this->SetHistogramStyle(m_intlumitrigrate_recorded, Form("Efficiency * x-sec = %.1f #mub, Run = %d",effxsec,runnbr), "Luminosity block number", Form("%s Integrated recorded luminosity (#mub^{-1})",trigName.Data()));
-}
-
-
-void
-LumiCalculator::RebinHistograms(const int& nbins, const double& start, const double& end)
-{
-  m_ntrigplb->SetBins(nbins,start,end);        
-  m_trigrateplb->SetBins(nbins,start,end);     
-  m_lumiplb->SetBins(nbins,start,end);         
-  m_lumitrigrateplb->SetBins(nbins,start,end); 
-  m_intlumi->SetBins(nbins,start,end);         
-  m_intlumitrigrate->SetBins(nbins,start,end); 
-  m_lumitrigrateplb_recorded->SetBins(nbins,start,end);
-  m_intlumitrigrate_recorded->SetBins(nbins,start,end);
-}
-
-
-void 
-LumiCalculator::SetHistogramStyle(TH1F* hist, const char* title, const char* xaxis, const char* yaxis)
-{
-  hist->SetFillColor(33); // light grey, blueish
-  if (title!=0) hist->SetTitle(title);
-  if (xaxis!=0) hist->GetXaxis()->SetTitle(xaxis);
-  if (yaxis!=0) hist->GetYaxis()->SetTitle(yaxis);
-
-  hist->GetXaxis()->SetLabelFont(52);
-  hist->GetXaxis()->SetLabelSize(0.04);
-  hist->GetXaxis()->SetTitleSize(0.05);
-  hist->GetXaxis()->SetTitleOffset(1.28);
-  hist->GetXaxis()->SetTitleFont(42);
-
-  hist->GetYaxis()->SetLabelFont(52);
-  hist->GetYaxis()->SetLabelSize(0.04);
-  hist->GetYaxis()->SetTitleSize(0.05);
-  hist->GetYaxis()->SetTitleOffset(1.25);
-  hist->GetYaxis()->SetTitleFont(42);
-
-  hist->SetStats(false);
-
-  hist->SetLineWidth(2);
-}
-
-
-/*
-// MB 20100115: turn off for now, RootGraphics lib crashes on some non-cern sites.
-TCanvas* 
-LumiCalculator::GetNiceCanvas(const char* name, const char* title)
-{
-  TCanvas *tcan = new TCanvas(name,title,4,45,800,600);
-  //gStyle->SetOptStat(0);
-  //tcan->SetHighLightColor(1);
-  tcan->Range(500.0, 100.0, 1000.,1000.);
-  //Int_t ci = TColor::GetColor("#ffffff");
-  tcan->SetFillColor(0);
-  tcan->SetBorderMode(0);
-  tcan->SetBorderSize(0);
-  tcan->SetGridx();
-  tcan->SetGridy();
-  tcan->SetLeftMargin(0.14);
-  tcan->SetRightMargin(0.14);
-  tcan->SetBottomMargin(0.15);
-  tcan->SetFrameFillColor(0);
-
-  return tcan;
-}
-*/
-
-void
-LumiCalculator::MakePlots(const std::string& triggerchain)
-{
-  if(m_LumiTree != 0){
-    // rebin and fill histograms:
-    m_LumiTree->SetBranchAddress("LBStart", &m_clumiblocknbr);
-    m_LumiTree->SetBranchAddress("L1AfterPrescale", &m_afterprescale);
-    m_LumiTree->SetBranchAddress("L1Rate", &m_l1rate);
-    m_LumiTree->SetBranchAddress("IntLumi",&m_intLumi);
-    m_LumiTree->SetBranchAddress("L1Ratediveffxsec",&m_l1ratediveffxsec);
-    m_LumiTree->SetBranchAddress("TotalLumi",&m_totalL);
-    m_LumiTree->SetBranchAddress("Total_L1Ratediveffxsec",&m_total_l1ratediveffxsec);
-    m_LumiTree->SetBranchAddress("TotalLumiRun",&m_totalLRun);
-    m_LumiTree->SetBranchAddress("Total_L1RatediveffxsecRun",&m_total_l1ratediveffxsecRun);
-    m_LumiTree->SetBranchAddress("RunNbr", &m_runnbr);
-    m_LumiTree->SetBranchAddress("L1RatediveffxsecRecorded",&m_l1ratediveffxsec_recorded);
-    m_LumiTree->SetBranchAddress("Total_L1RatediveffxsecRecorded",&m_total_l1ratediveffxsec_recorded);
-    m_LumiTree->SetBranchAddress("Total_L1RatediveffxsecRunRecorded",&m_total_l1ratediveffxsecRun_recorded);
-    m_LumiTree->SetBranchAddress("AvergeInteractionPerXing",&m_AvEvtsPerBX);
-    
-    // get first and last run number
-    m_LumiTree->GetEntry(0); 
-    int runnbrstart = m_runnbr;
-    m_LumiTree->GetEntry(m_LumiTree->GetEntries()-1); 
-    int runnbrend = m_runnbr;
-    
-    // makeup of integrated lumi histograms
-    m_intlumiruns = new TH1F("intlumiruns","Luminosity",1,0.,1.);
-    m_intlumitrigrateruns = new TH1F("intlumitrigrateruns","Delivered luminosity",1,0.,1.);
-    m_intlumitrigrateruns_recorded = new TH1F("intlumitrigrateruns_recorded","Recorded luminosity",1,0.,1.);
-    m_intlumiruns->SetBins(runnbrend-runnbrstart+10,float(runnbrstart),float(runnbrend+10));
-    m_intlumitrigrateruns->SetBins(runnbrend-runnbrstart+10,float(runnbrstart),float(runnbrend+10));
-    m_intlumitrigrateruns_recorded->SetBins(runnbrend-runnbrstart+10,float(runnbrstart),float(runnbrend+10));
-
-    // Lumi-weighted average interactions per crossing
-    m_avgintperbx = new TH1F("avgintperbx", "Avg Int/BX", 500, 0., 50.);
-    m_avgintperbx->SetTitle("Lumi-weighted Interactions per BX");
-    this->SetHistogramStyle(m_avgintperbx, "Lumi-weighted Average Interactions per BX", "Average Interactions per BX", "Recorded Luminosity (mb-1)");
- 
-    // loop over the lumi tree    
-    m_runnbr_prev = 0;
-    int nlbs(0);
-    float totalL(0.), total_l1ratediveffxsec(0.), total_l1ratediveffxsec_recorded(0.), totalLRun(0.), total_l1ratediveffxsecRun(0.), total_l1ratediveffxsecRun_recorded(0.);
-    for(int i=0; i < m_LumiTree->GetEntries(); i++){
-      m_LumiTree->GetEntry(i);
-      
-      // do histogram admin first
-      if ( m_runnbr!=m_runnbr_prev ) {
-	// first rebin prev histograms
-	if (m_runnbr_prev>0) { 
-	  m_intlumi->SetTitle(Form("Delivered luminosity = %.1f /#mu b, Run = %d",totalLRun,m_runnbr_prev));
-	  m_intlumitrigrate->SetTitle(Form("Delivered luminosity = %.1f /#mu b, Efficiency * x-sec = %.1f #mu b, Run = %d",total_l1ratediveffxsecRun,m_effxsec,m_runnbr_prev));
-	  m_intlumitrigrate_recorded->SetTitle(Form("Recorded luminosity = %.1f /#mu b, Efficiency * x-sec = %.1f #mu b, Run = %d",total_l1ratediveffxsecRun_recorded,m_effxsec,m_runnbr_prev));
-	  this->RebinHistograms(nlbs+10,0,double(nlbs+10)); 
-	}
-	// create new histograms
-	this->DoHistogramAdmin(m_runnbr,triggerchain,m_effxsec);
-	// fill cullumative luminosity
-	if (m_runnbr_prev>0) {
-	  for (uint32_t j=m_runnbr_prev; j<m_runnbr; ++j) {
-	    m_intlumiruns->Fill(j,totalL);
-	    m_intlumitrigrateruns->Fill(j,total_l1ratediveffxsec);
-	    m_intlumitrigrateruns_recorded->Fill(j,total_l1ratediveffxsec_recorded);
-	  }
-	}
-	m_runnbr_prev = m_runnbr ;
-      }
-      totalL = m_totalL;
-      totalLRun = m_totalLRun;
-      total_l1ratediveffxsec = m_total_l1ratediveffxsec;
-      total_l1ratediveffxsecRun = m_total_l1ratediveffxsecRun;      
-      total_l1ratediveffxsec_recorded = m_total_l1ratediveffxsec_recorded;
-      total_l1ratediveffxsecRun_recorded = m_total_l1ratediveffxsecRun_recorded;
-      nlbs = m_clumiblocknbr;
-      
-      m_ntrigplb->Fill(m_clumiblocknbr,(float)m_afterprescale);
-      m_trigrateplb->Fill(m_clumiblocknbr,m_l1rate);
-      m_lumiplb->Fill(m_clumiblocknbr,m_instLumi);
-      m_lumitrigrateplb->Fill(m_clumiblocknbr,m_l1ratediveffxsec);
-      m_intlumi->Fill(m_clumiblocknbr,m_totalLRun);
-      m_intlumitrigrate->Fill(m_clumiblocknbr,m_total_l1ratediveffxsecRun);
-      m_lumitrigrateplb_recorded->Fill(m_clumiblocknbr,m_l1ratediveffxsec_recorded);
-      m_intlumitrigrate_recorded->Fill(m_clumiblocknbr,m_total_l1ratediveffxsecRun_recorded);
-      m_avgintperbx->Fill(m_AvEvtsPerBX, m_intLumi);  // Lumi-weighted mu
-
-    } // end tree loop
-    m_intlumiruns->Fill(runnbrend,totalL);
-    m_intlumitrigrateruns->Fill(runnbrend,total_l1ratediveffxsec);
-    m_intlumitrigrateruns_recorded->Fill(runnbrend,total_l1ratediveffxsec_recorded);
-    
-    // finish histograms make-up
-    m_intlumiruns->SetMinimum(0.);
-    m_intlumitrigrateruns->SetMinimum(0.);
-    this->RebinHistograms(nlbs+10,0,double(nlbs+10));
-    this->SetHistogramStyle(m_intlumiruns, Form("Delivered luminosity = %.1f /ub",totalL), "Run number", "Luminosity (#mu b^{-1})");
-    this->SetHistogramStyle(m_intlumitrigrateruns, Form("Delivered luminosity = %.1f /#mu b, Recorded luminosity = %.1f /#mu b", //, Efficiency * x-sec = %.1f mb",
-							total_l1ratediveffxsec,total_l1ratediveffxsec_recorded/*,m_effxsec*/), "Run number", Form("%s Luminosity (#mu b^{-1})",triggerchain.c_str()));
-    this->SetHistogramStyle(m_intlumitrigrateruns_recorded, Form("Delivered luminosity = %.1f /#mub, Recorded luminosity = %.1f /#mub", //, Efficiency * x-sec = %.1f #mub",
-								 total_l1ratediveffxsec,total_l1ratediveffxsec_recorded/*,m_effxsec*/), "Run number", Form("%s Luminosity (#mu b^{-1})",triggerchain.c_str()));
-    
-    std::vector<TH1F*>::iterator itr, itr2;
-    
-    /*
-    // MB 20100115: turn off for now, RootGraphics lib crashes on some non-cern sites.
-    // save pictures
-    m_logger << Root::kINFO << "Saving plots (this may take a while)." << Root::GEndl;
-    gROOT->SetBatch(true); // batch mode, don't draw pictures
-    TCanvas* tcan = GetNiceCanvas(); tcan->cd();
-    if (m_effxsec==1.0) {
-    m_intlumiruns->Draw(); tcan->SaveAs(Form("%s.png",m_intlumiruns->GetName()));
-    for (itr=m_lumiplbVec.begin(); itr!=m_lumiplbVec.end(); ++itr)                 { (*itr)->Draw(); tcan->SaveAs(Form("%s.png",(*itr)->GetName())); }
-    for (itr=m_intlumiVec.begin(); itr!=m_intlumiVec.end(); ++itr)                 { (*itr)->Draw(); tcan->SaveAs(Form("%s.png",(*itr)->GetName())); }
-    }
-    for (itr=m_ntrigplbVec.begin(); itr!=m_ntrigplbVec.end(); ++itr)                 { (*itr)->Draw(); tcan->SaveAs(Form("%s.png",(*itr)->GetName())); }
-    for (itr=m_trigrateplbVec.begin(); itr!=m_trigrateplbVec.end(); ++itr)           { (*itr)->Draw(); tcan->SaveAs(Form("%s.png",(*itr)->GetName())); }
-    if (m_effxsec!=1.0) { // results only make sense when proper xsec is provided externally
-    m_intlumitrigrateruns->SetFillColor(0);
-    m_intlumitrigrateruns->Draw(); //tcan->SaveAs(Form("%s.png",m_intlumitrigrateruns->GetName()));
-    m_intlumitrigrateruns_recorded->Draw("SAME"); tcan->SaveAs(Form("%s.png",m_intlumitrigrateruns->GetName()));
-    for (itr=m_lumitrigrateplbVec.begin(), itr2=m_lumitrigrateplb_recordedVec.begin(); itr!=m_lumitrigrateplbVec.end(); ++itr, ++itr2) { 
-    (*itr)->SetFillColor(0);
-  (*itr)->Draw(); //tcan->SaveAs(Form("%s.png",(*itr)->GetName())); 
-  (*itr2)->Draw("SAME"); tcan->SaveAs(Form("%s.png",(*itr)->GetName()));
-  }
-  for (itr=m_intlumitrigrateVec.begin(), itr2=m_intlumitrigrate_recordedVec.begin(); itr!=m_intlumitrigrateVec.end(); ++itr, ++itr2) { 
-  (*itr)->SetFillColor(0);
-  (*itr)->Draw(); //tcan->SaveAs(Form("%s.png",(*itr)->GetName())); 
-  (*itr2)->Draw("SAME"); tcan->SaveAs(Form("%s.png",(*itr)->GetName()));
-  }
-  }
-  delete tcan;
-    */
-  
-  // and store the histograms
-  TString histFileName = TString("ilumicalc_histograms_") + TString(triggerchain) + ( runnbrstart==runnbrend ? Form("_%d.root",runnbrstart) : Form("_%d-%d.root",runnbrstart,runnbrend) );
-  TFile *ff = new TFile(histFileName.Data(),"recreate");
-  m_avgintperbx->Write();
-  if (m_effxsec==1.0) {
-    m_intlumiruns->Write();
-    for (itr=m_lumiplbVec.begin(); itr!=m_lumiplbVec.end(); ++itr)                 { (*itr)->Write(); }
-    for (itr=m_intlumiVec.begin(); itr!=m_intlumiVec.end(); ++itr)                 { (*itr)->Write(); }
-  }
-  for (itr=m_ntrigplbVec.begin(); itr!=m_ntrigplbVec.end(); ++itr)                 { (*itr)->Write(); }
-  for (itr=m_trigrateplbVec.begin(); itr!=m_trigrateplbVec.end(); ++itr)           { (*itr)->Write(); }
-  if (m_effxsec!=1.0) { // results only make sense when proper xsec is provided externally
-    m_intlumitrigrateruns->Write();
-    m_intlumitrigrateruns_recorded->Write();
-    for (itr=m_lumitrigrateplbVec.begin(); itr!=m_lumitrigrateplbVec.end(); ++itr) { (*itr)->Write(); }
-    for (itr=m_intlumitrigrateVec.begin(); itr!=m_intlumitrigrateVec.end(); ++itr) { (*itr)->Write(); }
-    for (itr=m_lumitrigrateplb_recordedVec.begin(); itr!=m_lumitrigrateplb_recordedVec.end(); ++itr) { (*itr)->Write(); }
-    for (itr=m_intlumitrigrate_recordedVec.begin(); itr!=m_intlumitrigrate_recordedVec.end(); ++itr) { (*itr)->Write(); }
-  }
-  m_LumiTree->Write();
-  ff->Close();
-  delete ff;
-  m_logger << Root::kINFO << "Histograms stored as          : " << histFileName << Root::GEndl;
-
-  }else{
-    m_logger << Root::kWARNING << "LumiTree pointer does not exist!          : " << Root::GEndl;
-  }
-
-
-}
-
-// 	  // Reporting also lumi algorithm - for future...
-// 	  std::map<int, std::string> m_lumialgo_chan;
-	  
-// 	  m_lumialgo_chan.insert(std::pair<int, std::string>(0, "ATLAS_PREFERRED")); 
-// 	  m_lumialgo_chan.insert(std::pair<int, std::string>(1, "LHC")); 
-// 	  m_lumialgo_chan.insert(std::pair<int, std::string>(101, "LUCID_ZEROS_OR"));
-// 	  m_lumialgo_chan.insert(std::pair<int, std::string>(102, "LUCID_ZEROS_AND"));
-// 	  m_lumialgo_chan.insert(std::pair<int, std::string>(103, "LUCID_HITS_OR"));
-// 	  m_lumialgo_chan.insert(std::pair<int, std::string>(104, "LUCID_HITS_AND"));
-// 	  m_lumialgo_chan.insert(std::pair<int, std::string>(201, "BCM_H_ZEROS_AND"));
-// 	  m_lumialgo_chan.insert(std::pair<int, std::string>(202, "BCM_H_EVENTS_AND"));
-// 	  m_lumialgo_chan.insert(std::pair<int, std::string>(203, "BCM_H_XORA"));
-// 	  m_lumialgo_chan.insert(std::pair<int, std::string>(204, "BCM_H_EVENTS_XORC"));
-// 	  m_lumialgo_chan.insert(std::pair<int, std::string>(301, "MBTS_ZEROS_AND"));
-// 	  m_lumialgo_chan.insert(std::pair<int, std::string>(302, "MBTS_ZEROS_OR"));
-// 	  m_lumialgo_chan.insert(std::pair<int, std::string>(303, "MBTS_HITS_OR"));
-// 	  m_lumialgo_chan.insert(std::pair<int, std::string>(401, "ZDC_EVENTS_AND"));
-// 	  m_lumialgo_chan.insert(std::pair<int, std::string>(402, "ZDC_EVENTS_ORA")); 
-// 	  m_lumialgo_chan.insert(std::pair<int, std::string>(403, "ZDC_EVENTS_ORC"));
-// 	  m_lumialgo_chan.insert(std::pair<int, std::string>(501, "FCAL"));
-// 	  m_lumialgo_chan.insert(std::pair<int, std::string>(601, "HLT"));
-// 	  m_lumialgo_chan.insert(std::pair<int, std::string>(901, "OflLumi_LArTime_Events"));
-// 	  m_lumialgo_chan.insert(std::pair<int, std::string>(998, "OflLumi_Fake0"));
-// 	  m_lumialgo_chan.insert(std::pair<int, std::string>(999, "OflLumi_Fake1"));
-	  
-//	  m_logger << Root::kINFO << "Algorithm: " << m_lumialgo_chan.find((m_Valid >> 22))->second << Root::GEndl;
-	  
diff --git a/LumiBlock/LumiBlockComps/src/LumiCalculator.h b/LumiBlock/LumiBlockComps/src/LumiCalculator.h
deleted file mode 100644
index 340ed6dffc5fa34a9c5bca951283ef1e175ecfd9..0000000000000000000000000000000000000000
--- a/LumiBlock/LumiBlockComps/src/LumiCalculator.h
+++ /dev/null
@@ -1,245 +0,0 @@
-/*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
-*/
-
-#ifndef LUMICALCULATOR_H
-#define LUMICACLULATOR_H
-
-
-#include "LumiBlockComps/CoolQuery.h"
-#include "LumiBlockComps/LumiBlockCollectionConverter.h"
-#include <vector>
-#include "TH1F.h"
-#include "TTree.h"
-
-namespace Root {
-  class TGoodRunsList;
-}
-
-//class TTree;
-// MB 20100115: turn off for now, RootGraphics lib crashes on some non-cern sites.
-//class TCanvas;
-
-class LumiCalculator{
-
- public:
-  LumiCalculator();
-  ~LumiCalculator();
-
-  void UseMC(bool mc = true); // No longer supported
-  void UseLArNoiseDB(bool lar, const std::string& lardb); // Calculate LAr defect fraction 
-  void UseBeamspot(bool bs, const std::string& bstag); // Calculate online beamspot validity fraction
-  void UseOnlineLumi(bool online);
-  void Verbose(bool verbose = true);
-  void UseLumiTag(const std::string& tag);// i.e. COOL Folder tag
-  void UseLumiMethod(const std::string& method);// i.e. COOL Folder channel
-  void UseLumiChannel(int chan);
-  void UseLiveTrigger(bool live, std::string& livetrigger);
-  void IntegrateLumi(const LumiBlockCollection * iovc, const std::string& triggerchain);
-  void SetCollName(const std::string& lbcollname);
-  void setTree(TTree * tree = 0);
-
-  TTree *getTree();
-
-  inline void MakePlots(bool plots) { m_makePlots = plots; }
-  inline void MakeCollList(bool collList) { m_makecollList = collList; }
-  inline void ScaleL1TrigRate( const float& rate ) { m_effxsec=1./rate; }
-  inline void SetMinL1TrigRate( const float& mintrigrate ) { m_mintrigrate=mintrigrate; }
-
-  // Print terse summary of results
-  void printSummary(std::ostream& os);
-
- private:
-
-  void DoHistogramAdmin(const uint32_t& runnbr, const TString& trigName, const float& effxsec);
-  void SetHistogramStyle(TH1F* hist, const char* title=0, const char* xaxis=0, const char* yaxis=0);
-  void RebinHistograms(const int& nbins, const double& start, const double& end);
-  void MakePlots(const std::string& triggerchain);
-
-  void LoadChannelIds();
-
-  //TCanvas* GetNiceCanvas(const char* name="tcan", const char* title="tcan");
-
-  // A TTree to bookkeep the calculation
-  TTree * m_LumiTree;
-  bool m_recordTTree;
-
-  // State of LumiCalculator: True - OK, False - something went bad..
-  bool m_State;
-
-
-  std::string lumi_database;
-  std::string trig_database;
-  std::string lar_database;
-  std::string bs_database;
-
-  std::string m_trigger;
-  std::string m_livetrigger;
-  std::string m_lumioff;
-  std::string m_lumionl;
-  std::string m_data_db;
-  std::string m_lumitag;
-  std::string m_lumimethod;
-  std::string m_laroff;
-  std::string m_lartag;
-  std::string m_bsonl;
-  std::string m_bstag;
-  int m_lumichannel;
-  std::vector<uint32_t> lbstart;
-  std::vector<uint32_t> lbend;
-
-  std::string m_parofflumiestfolder;
-  std::string m_paronllumiestfolder;
-  std::string m_parlumiestfolder;
-  std::string m_parlvl1menufolder;
-  std::string m_parhltmenufolder;
-  std::string m_parhltprescalesfolder;
-  std::string m_parlumilvl1folder;
-  std::string m_parlumihltfolder;
-  std::string m_parlvl1prescalesfolder;
-  std::string m_parlvl1lblbfolder;
-  std::string m_parlareventvetofolder;
-  std::string m_paronlbeamspotfolder;
-
-  Root::TMsgLogger m_logger;
-  std::string m_lbcollname;
-  bool m_uselivetrigger;
-  bool m_verbose;
-  
-
-
-  // Internal variables
-
-  float m_totalDelL;
-  float m_totalL;
-  float m_totalLRun;
-  float m_totaltime;
-  float m_instLumi;
-  float m_AvEvtsPerBX;
-  cool::UInt32 m_Valid;
-  float m_delLumi;
-  float m_intLumi;
-  float m_deltaT;
-  float m_TotaldeltaT;
-  float m_livefrac;
-  float m_livetime;
-  unsigned int m_l1acc;
-  unsigned int m_livetime_l1acc;
-  bool m_l1accof;
-  unsigned int m_l2acc;
-  unsigned int m_l3acc;
-  unsigned int m_totall1acc;
-  unsigned int m_livtrig_totall1acc;
-  unsigned int m_totall1befpresc;
-  unsigned int m_totall2acc;
-  unsigned int m_totall3acc;
-  float m_l1prescale;
-  float m_l2prescale;
-  float m_l3prescale;
-  ULong64_t m_afterprescale;
-  ULong64_t m_livetime_beforeprescale;
-  ULong64_t m_livetime_afterprescale;
-  bool m_afterprescaleof;
-  ULong64_t m_beforeprescale;
-  bool m_beforeprescaleof;
-  uint32_t m_runnbr;
-  uint32_t m_lbstart;
-  uint32_t m_lbstop;
-  uint32_t m_lbstart_prev;
-  uint32_t m_lbstop_prev;
-  uint32_t m_runnbr_prev;
-  unsigned int m_totalgoodblock;
-  unsigned int m_totalbadblock;
-  uint32_t m_clumiblocknbr;
-  uint32_t m_clumiblocknbrend;
-  unsigned int m_triglevel;
-  float m_totalPrescaleWLiveTime;
-  float mt_totalPrescaleWLiveTime;
-  float m_totalPrescale;
-  float mt_totalPrescale;
-  float m_lumiWOPrescale;
-  float mt_lumiWOPrescale;
-  float m_lumiLAr;
-  float mt_lumiLAr;
-  float mt_totalDelL;
-  float mt_totalL;
-  float mt_totalLRun;
-  float mt_totaltime;
-  float mt_deltaT;
-  unsigned int mt_l1acc;
-  unsigned int mt_l2acc;
-  unsigned int mt_l3acc;
-  unsigned int mt_totalgoodblock;
-  unsigned int mt_totalbadblock;
-  unsigned int mt_totall1befpresc;    
-  float m_lartime;
-  float m_larfrac;
-  float m_bsvalid;
-  
-  std::string m_triggerchain;
-  std::vector<std::string> m_triggerlowerchains;
-  std::string m_L1triggerchain;
-  std::string m_lbcollectionname;
-
-  float m_effxsec;
-  float m_l1rate;
-  float m_l2rate;
-  float m_l3rate;
-  float m_l1ratediveffxsec;
-  float m_total_l1ratediveffxsec;
-  float m_total_l1ratediveffxsecRun;
-  float m_l1ratediveffxsec_recorded;
-  float m_total_l1ratediveffxsec_recorded;
-  float m_total_l1ratediveffxsecRun_recorded;
-  float m_mintrigrate;
-
-  Root::TGoodRunsList* m_collsgrl;
-
-  TH1F* m_ntrigplb;
-  TH1F* m_trigrateplb;
-  TH1F* m_lumiplb;
-  TH1F* m_lumitrigrateplb;
-  TH1F* m_intlumi;
-  TH1F* m_intlumitrigrate;
-  TH1F* m_lumitrigrateplb_recorded;
-  TH1F* m_intlumitrigrate_recorded;
-
-  TH1F* m_intlumiruns;
-  TH1F* m_intlumitrigrateruns;
-  TH1F* m_intlumitrigrateruns_recorded;
-
-  TH1F* m_avgintperbx;
-
-  std::vector<TH1F*> m_ntrigplbVec;
-  std::vector<TH1F*> m_trigrateplbVec;
-  std::vector<TH1F*> m_lumiplbVec;
-  std::vector<TH1F*> m_lumitrigrateplbVec;
-  std::vector<TH1F*> m_intlumiVec;
-  std::vector<TH1F*> m_intlumitrigrateVec;
-  std::vector<TH1F*> m_lumitrigrateplb_recordedVec;
-  std::vector<TH1F*> m_intlumitrigrate_recordedVec;
-
-  bool m_makePlots;
-  bool m_makecollList;
-
-  cool::ChannelId Lumiid;
-  cool::ChannelId L3id;
-  cool::ChannelId L2id;
-  cool::ChannelId L1id;
-  cool::ChannelId LiveL1id;
-
-  bool L1Valid;
-  bool L2Valid;
-  bool L3Valid;
-  bool LiveValid;
-
-  bool m_onlinelumi;
-  bool m_uselar;
-  bool m_usebs;
-
-  unsigned int m_minrun;
-  unsigned int m_maxrun;
-};
-
-
-#endif //> LUMICALCULATOR_H
diff --git a/LumiBlock/LumiBlockComps/src/LumiCalibrator.cxx b/LumiBlock/LumiBlockComps/src/LumiCalibrator.cxx
index 165e1cc4501e82f5f73806a84e1c6326d9da4a59..2a68f69017a7e5928e3f1150366ab45415d8684e 100644
--- a/LumiBlock/LumiBlockComps/src/LumiCalibrator.cxx
+++ b/LumiBlock/LumiBlockComps/src/LumiCalibrator.cxx
@@ -2,7 +2,7 @@
   Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
 */
 
-#include "LumiCalibrator.h"
+#include "LumiBlockComps/LumiCalibrator.h"
 
 #include "CoralBase/Attribute.h"
 #include "CoralBase/Blob.h"
diff --git a/LumiBlock/LumiBlockComps/src/LuminosityTool.cxx b/LumiBlock/LumiBlockComps/src/LuminosityTool.cxx
index aa5e3776ee8c98ed41ad72d233a731accd3630f0..32eb646ec689c5e4c8223630103a44dab9de35e5 100644
--- a/LumiBlock/LumiBlockComps/src/LuminosityTool.cxx
+++ b/LumiBlock/LumiBlockComps/src/LuminosityTool.cxx
@@ -2,7 +2,7 @@
   Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
 */
 
-#include "LuminosityTool.h"
+#include "LumiBlockComps/LuminosityTool.h"
 
 #include "EventInfo/EventID.h"
 #include "EventInfo/EventInfo.h"
@@ -24,25 +24,24 @@ LuminosityTool::LuminosityTool(const std::string& type,
 				 const std::string& name,
 				 const IInterface* parent)
   : AthAlgTool(type, name, parent),
-    m_lumiFolderName("/TRIGGER/OFLLUMI/LBLESTOFL"),
+    m_lumiFolderName(""), // "/TRIGGER/OFLLUMI/LBLESTOFL"),
     m_lumiChannel(0),
-    m_calibrationFolderName("/TDAQ/OLC/CALIBRATIONS"),
-    m_fillparamsFolderName("/TDAQ/OLC/LHC/FILLPARAMS"),
-    m_bunchlumisFolderName("/TDAQ/OLC/BUNCHLUMIS"),
-    m_bunchgroupFolderName("/TRIGGER/LVL1/BunchGroupContent"),
-    m_lblbFolderName("/TRIGGER/LUMI/LBLB"),
+    m_fillParamsTool(""), //FillParamsTool"),
+    m_bunchLumisTool(""), //BunchLumisTool"),
+    m_bunchGroupTool(""), //BunchGroupTool"),
+    m_onlineLumiCalibrationTool(""), //OnlineLumiCalibrationTool"),
+    m_lblbFolderName(""), ///TRIGGER/LUMI/LBLB"),
     m_recalcPerBCIDLumi(true),
     m_preferredChannel(0),
-    m_luminousBunches(0),
-    m_bgBunches(0)
+    m_luminousBunches(0)
 {
   declareInterface<ILuminosityTool>(this);
   declareProperty("LumiFolderName", m_lumiFolderName);
   declareProperty("LumiChannelNumber", m_lumiChannel);
-  declareProperty("CalibrationFolderName", m_calibrationFolderName);
-  declareProperty("FillparamsFolderName", m_fillparamsFolderName);
-  declareProperty("BunchlumisFolderName", m_bunchlumisFolderName);
-  declareProperty("BunchgroupFolderName", m_bunchgroupFolderName);
+  declareProperty("FillParamsTool", m_fillParamsTool);
+  declareProperty("BunchLumisTool", m_bunchLumisTool);
+  declareProperty("BunchGroupTool", m_bunchGroupTool);
+  declareProperty("OnlineLumiCalibrationTool", m_onlineLumiCalibrationTool);
   declareProperty("LBLBFolderName", m_lblbFolderName);
 
   m_LBAvInstLumi = 0.;
@@ -51,13 +50,10 @@ LuminosityTool::LuminosityTool(const std::string& type,
 
   m_LBDuration = 0.;
 
-  m_LBInstLumi = std::vector<float>(TOTAL_LHC_BCIDS, 0.);
   m_MuToLumi = 0.;
+  m_LBInstLumi.assign(TOTAL_LHC_BCIDS, 0.);
 
   m_luminousBunchesVec.clear();
-  m_bgBunchesVec.clear();
-
-  m_cali.clear();
 }
 
 StatusCode
@@ -73,7 +69,10 @@ LuminosityTool::initialize()
   // their own callbacks.
 
   // Setup callback
-  if (detStore()->contains<CondAttrListCollection>(m_lumiFolderName)) {
+  if (m_lumiFolderName.empty()) {
+    ATH_MSG_INFO( "LumiFolderName is empty, skipping" );
+
+  } else if (detStore()->contains<CondAttrListCollection>(m_lumiFolderName)) {
 
     const DataHandle<CondAttrListCollection> aptr;
 
@@ -81,64 +80,72 @@ LuminosityTool::initialize()
     CHECK(detStore()->regFcn(&LuminosityTool::updateAvgLumi, this, &ILuminosityTool::updateCache, dynamic_cast<ILuminosityTool*>(this)));
 
     ATH_MSG_INFO( " Registered a callback for " << m_lumiFolderName << " COOL folder " );
-  } else if (!m_lumiFolderName.empty()) {
+  } else {
     ATH_MSG_ERROR( " cannot find " << m_lumiFolderName << " in DetectorStore" );
   }
 
-  // Calibrations folder
-  if (detStore()->contains<CondAttrListCollection>(m_calibrationFolderName)) {
-
-    const DataHandle<CondAttrListCollection> aptr;
-
-    CHECK(detStore()->regFcn(&LuminosityTool::updateCalibrations, this , aptr, m_calibrationFolderName));
-    CHECK(detStore()->regFcn(&LuminosityTool::updateCalibrations, this , &ILuminosityTool::updateCache, dynamic_cast<ILuminosityTool*>(this)));
-
-    ATH_MSG_INFO( " Registered a callback for " << m_calibrationFolderName << " COOL folder " );
+  //
+  // Calibration folder
+  if (m_onlineLumiCalibrationTool.empty()) {
+    // May not be configured, could be OK
+    ATH_MSG_INFO( "OnlineLumiCalibrationTool.empty() is TRUE, skipping..." );
   } else {
-    ATH_MSG_ERROR( " cannot find " << m_calibrationFolderName << " in DetectorStore" );
+    ATH_MSG_INFO( "Retrieving OnlineLumiCalibrationTool handle" );
+    CHECK(m_onlineLumiCalibrationTool.retrieve());
+
+    // Setup callback on OnlineLumiCalibrationTool change
+    ATH_MSG_INFO( "Registering callback on IOnlineLumiCalibrationTool::updateCache" );
+    CHECK(detStore()->regFcn(&IOnlineLumiCalibrationTool::updateCache, dynamic_cast<IOnlineLumiCalibrationTool*>(&(*m_onlineLumiCalibrationTool)), &ILuminosityTool::updateCache, dynamic_cast<ILuminosityTool*>(this)));
   }
 
+  //
   // Fillparams folder
-  if (detStore()->contains<AthenaAttributeList>(m_fillparamsFolderName)) {
-
-    const DataHandle<AthenaAttributeList> aptr;
-
-    CHECK(detStore()->regFcn(&LuminosityTool::updateFillparams, this , aptr, m_fillparamsFolderName));
-    CHECK(detStore()->regFcn(&LuminosityTool::updateFillparams, this , &ILuminosityTool::updateCache, dynamic_cast<ILuminosityTool*>(this)));
+  if (m_fillParamsTool.empty()) {
+    // May not be configured, could be OK
+    ATH_MSG_INFO( "FillParamsTool.empty() is TRUE, skipping..." );
+  } else {
+    ATH_MSG_INFO( "Retrieving FillParamsTool handle" );
+    CHECK(m_fillParamsTool.retrieve());
 
-    ATH_MSG_INFO( " Registered a callback for " << m_fillparamsFolderName << " COOL folder " );
-  } else if (!m_fillparamsFolderName.empty()) {
-    ATH_MSG_ERROR( " cannot find " << m_fillparamsFolderName << " in DetectorStore" );
+    // Setup callback on FillParamsTool change
+    ATH_MSG_INFO( "Registering callback on IFillParamsTool::updateCache" );
+    CHECK(detStore()->regFcn(&IFillParamsTool::updateCache, dynamic_cast<IFillParamsTool*>(&(*m_fillParamsTool)), &ILuminosityTool::updateCache, dynamic_cast<ILuminosityTool*>(this)));
   }
 
+  //
   // Bunchlumis folder
-  if (detStore()->contains<CondAttrListCollection>(m_bunchlumisFolderName)) {
-
-    const DataHandle<CondAttrListCollection> aptr;
-
-    // No explicit function, just trigger cache update 
-    CHECK(detStore()->regFcn(&ILuminosityTool::updateCache, dynamic_cast<ILuminosityTool*>(this) , aptr, m_bunchlumisFolderName));
-
-    ATH_MSG_INFO( " Registered a callback for " << m_bunchlumisFolderName << " COOL folder " );
+  if (m_bunchLumisTool.empty()) {
+    // May not be configured, could be OK
+    ATH_MSG_INFO( "BunchLumisTool.empty() is TRUE, skipping..." );
   } else {
-    ATH_MSG_ERROR( " cannot find " << m_bunchlumisFolderName << " in DetectorStore" );
+    ATH_MSG_INFO( "Retrieving BunchLumisTool handle" );
+    CHECK(m_bunchLumisTool.retrieve());
+
+    // Setup callback on BunchLumisTool change
+    ATH_MSG_INFO( "Registering callback on IBunchLumisTool::updateCache" );
+    CHECK(detStore()->regFcn(&IBunchLumisTool::updateCache, dynamic_cast<IBunchLumisTool*>(&(*m_bunchLumisTool)), &ILuminosityTool::updateCache, dynamic_cast<ILuminosityTool*>(this)));
   }
 
+  //
   // BunchGroup folder
-  if (detStore()->contains<AthenaAttributeList>(m_bunchgroupFolderName)) {
-
-    const DataHandle<AthenaAttributeList> aptr;
-
-    CHECK(detStore()->regFcn(&LuminosityTool::updateBunchgroup, this , aptr, m_bunchgroupFolderName));
-    CHECK(detStore()->regFcn(&LuminosityTool::updateBunchgroup, this , &ILuminosityTool::updateCache, dynamic_cast<ILuminosityTool*>(this)));
+  if (m_bunchGroupTool.empty()) {
+    // May not be configured, could be OK
+    ATH_MSG_INFO( "BunchGroupTool.empty() is TRUE, skipping..." );
+  } else {
+    ATH_MSG_INFO( "Retrieving BunchGroupTool handle" );
+    CHECK(m_bunchGroupTool.retrieve());
 
-    ATH_MSG_INFO( " Registered a callback for " << m_bunchgroupFolderName << " COOL folder " );
-  } else if (!m_bunchgroupFolderName.empty()) {
-    ATH_MSG_ERROR( " cannot find " << m_bunchgroupFolderName << " in DetectorStore" );
+    // Setup callback on BunchGroupTool change
+    ATH_MSG_INFO( "Registering callback on IBunchGroupTool::updateCache" );
+    CHECK(detStore()->regFcn(&IBunchGroupTool::updateCache, dynamic_cast<IBunchGroupTool*>(&(*m_bunchGroupTool)), &ILuminosityTool::updateCache, dynamic_cast<ILuminosityTool*>(this)));
   }
 
+  //
   // LBLB folder
-  if (detStore()->contains<AthenaAttributeList>(m_lblbFolderName)) {
+  if (m_lblbFolderName.empty()) {
+    ATH_MSG_INFO("LBLBFolderName is empty, skipping...");
+
+  } else if (detStore()->contains<AthenaAttributeList>(m_lblbFolderName)) {
 
     const DataHandle<AthenaAttributeList> aptr;
 
@@ -146,7 +153,7 @@ LuminosityTool::initialize()
     CHECK(detStore()->regFcn(&LuminosityTool::updateLBLB, this , &ILuminosityTool::updateCache, dynamic_cast<ILuminosityTool*>(this)));
 
     ATH_MSG_INFO( " Registered a callback for " << m_lblbFolderName << " COOL folder " );
-  } else if (!m_lblbFolderName.empty()) {
+  } else {
     ATH_MSG_ERROR( " cannot find " << m_lblbFolderName << " in DetectorStore" );
   }
 
@@ -216,7 +223,9 @@ LuminosityTool::lbLuminosityPerBCID(unsigned int bcid) {
 }
 
 float
-LuminosityTool::muToLumi() const {
+LuminosityTool::muToLumi() {
+  // Make sure this is up to date
+  if (m_recalcPerBCIDLumi) recalculatePerBCIDLumi();
   return m_MuToLumi;
 }
 
@@ -226,6 +235,7 @@ LuminosityTool::muToLumi() const {
 StatusCode
 LuminosityTool::updateCache( IOVSVC_CALLBACK_ARGS_P(/*idx*/, /*keys*/) )
 {
+  ATH_MSG_DEBUG( "in updateCache() " );
   m_recalcPerBCIDLumi = true;  
   return StatusCode::SUCCESS;
 }
@@ -241,6 +251,10 @@ LuminosityTool::updateAvgLumi( IOVSVC_CALLBACK_ARGS_P(/*idx*/, /*keys*/) )
   m_Valid = 0xFFFFFFFF;
   m_preferredChannel = 0;
 
+  // Check if we have anything to do
+  // Shouldn't actually get a callback if this folder doesn't exist...
+  if (m_lumiFolderName.empty()) return StatusCode::SUCCESS;
+
   const CondAttrListCollection* attrListColl = 0;
   CHECK(detStore()->retrieve(attrListColl, m_lumiFolderName));
 
@@ -302,142 +316,13 @@ LuminosityTool::updateAvgLumi( IOVSVC_CALLBACK_ARGS_P(/*idx*/, /*keys*/) )
     m_LBAvEvtsPerBX=0.;
   }
 
-  return StatusCode::SUCCESS;
-}
-
-StatusCode
-LuminosityTool::updateCalibrations( IOVSVC_CALLBACK_ARGS_P(/*idx*/, /*keys*/) )
-{
-  ATH_MSG_DEBUG( "in updateCalibrations() " );
-
-  // Should be set in updateCache, but do it here just to make sure
-  m_recalcPerBCIDLumi = true;  
-
-  // Clear old data
-  m_cali.clear();
-
-  const CondAttrListCollection* attrListColl = 0;
-  CHECK(detStore()->retrieve(attrListColl, m_calibrationFolderName));
-
-  // Loop over collection and save all channels
-  CondAttrListCollection::const_iterator first = attrListColl->begin();
-  CondAttrListCollection::const_iterator last  = attrListColl->end();
-  for (; first != last; ++first) {
-    cool::UInt32 channel = (*first).first;
-    const coral::AttributeList& attrList = (*first).second;
-    LumiCalibrator lc;
-    if (!lc.setCalibration(attrList)) {
-      ATH_MSG_WARNING( "error processing calibration for channel " << channel );
-    } else{
-      ATH_MSG_DEBUG( "Calibration for channel " << channel << ": " << lc );
-      m_cali[channel] = lc;
-    }
-  }
-
-  // And set muToLumi
-  m_MuToLumi = m_cali[0].getMuToLumi();
+  // Also update muToLumi as this may have changed with the channel number
+  if (!m_onlineLumiCalibrationTool.empty())
+    m_MuToLumi = m_onlineLumiCalibrationTool->getMuToLumi(m_preferredChannel);
 
   return StatusCode::SUCCESS;
 }
 
-StatusCode
-LuminosityTool::updateFillparams( IOVSVC_CALLBACK_ARGS_P(/*idx*/, /*keys*/) )
-{
-  ATH_MSG_DEBUG( "in updateFillparams() " );
-
-  // Should be set in updateCache, but do it here just to make sure
-  m_recalcPerBCIDLumi = true;  
-
-  // Clear old data
-  m_luminousBunches = 0;
-  m_luminousBunchesVec.clear(); 
-
-  const AthenaAttributeList* attrList = 0;
-  CHECK(detStore()->retrieve(attrList, m_fillparamsFolderName));
-
-  if ((*attrList)["BCIDmasks"].isNull()) {
-    ATH_MSG_WARNING( "BCIDmasks is NULL in " << m_fillparamsFolderName << "!" );
-    return StatusCode::SUCCESS;
-  }
-
-  cool::UInt32 nb1 = (*attrList)["Beam1Bunches"].data<cool::UInt32>();
-  cool::UInt32 nb2 = (*attrList)["Beam2Bunches"].data<cool::UInt32>();
-  cool::UInt32 ncol = (*attrList)["LuminousBunches"].data<cool::UInt32>();
-
-  ATH_MSG_DEBUG( "LuminousBunches: " << ncol );
-
-  const coral::Blob& blob = (*attrList)["BCIDmasks"].data<coral::Blob>();
-
-  // Verify length
-  if ( static_cast<cool::UInt32>( blob.size() ) != 2 * (nb1 + nb2 + ncol)) {
-    ATH_MSG_WARNING( "BCIDmasks length " << blob.size() << " != 2 * " << (nb1+nb2+ncol) );
-    return StatusCode::SUCCESS;
-  }
-
-  const uint16_t* p=static_cast<const uint16_t*>(blob.startingAddress());
-  p += (nb1+nb2); // Skip past beam1 and beam2 
-  if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "LuminousBunch list: ";
-  for (unsigned int i = 0; i < ncol; i++, p++) {
-    m_luminousBunchesVec.push_back(*p);
-    if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << *p << " "; 
-  }
-  if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << endreq;
-
-  m_luminousBunches = m_luminousBunchesVec.size();
-
-  return StatusCode::SUCCESS;
-}
-
-StatusCode
-LuminosityTool::updateBunchgroup( IOVSVC_CALLBACK_ARGS_P(/*idx*/, /*keys*/) )
-{
-  ATH_MSG_DEBUG( "in updateBunchgroup() " );
-
-  // Should be set in updateCache, but do it here just to make sure
-  m_recalcPerBCIDLumi = true;  
-
-  // Clear old data
-  m_bgBunches = 0;
-  m_bgBunchesVec.clear(); 
-
-  const AthenaAttributeList* attrList = 0;
-  CHECK(detStore()->retrieve(attrList, m_bunchgroupFolderName));
-
-  if ((*attrList)["BunchCode"].isNull()) {
-    ATH_MSG_WARNING( "BunchCode is NULL in " << m_bunchgroupFolderName << "!" );
-    return StatusCode::SUCCESS;
-  }
-
-  const coral::Blob& blob = (*attrList)["BunchCode"].data<coral::Blob>();
-
-  ATH_MSG_DEBUG( "Bunchgroup blob length: " << blob.size() );
-
-  // Check that we have enough data.
-  // There have been many bugs in filling this folder, so just require at least TOTAL_LHC_BCIDS
-  if (static_cast<cool::UInt32>(blob.size()) < TOTAL_LHC_BCIDS) {
-    ATH_MSG_WARNING( "BunchCode length: " << blob.size() << " shorter than " << TOTAL_LHC_BCIDS << "!" );
-    return StatusCode::SUCCESS;
-  }
-
-  if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "BunchGroup list: ";
-  const unsigned char* p = static_cast<const unsigned char*>(blob.startingAddress());
-  for (size_t bcid = 0; bcid < static_cast<size_t>(TOTAL_LHC_BCIDS); ++bcid,++p) {
-  
-    // Read 8-bits at a time and decode 
-    unsigned char mask = (*p);
-    if (mask & 0x2) {    // Just look for physics bunch group
-      m_bgBunchesVec.push_back(bcid);
-      if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << bcid << " ";
-    }
-  }
-  if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << endreq;
-
-  m_bgBunches = m_bgBunchesVec.size();
-
-  ATH_MSG_DEBUG( "Physics Bunch Group entries: " << m_bgBunches );
-  return StatusCode::SUCCESS;
-}
-
 StatusCode
 LuminosityTool::updateLBLB( IOVSVC_CALLBACK_ARGS_P(/*idx*/, /*keys*/) )
 {
@@ -446,6 +331,9 @@ LuminosityTool::updateLBLB( IOVSVC_CALLBACK_ARGS_P(/*idx*/, /*keys*/) )
   // Ensure zero on error
   m_LBDuration = 0.;
 
+  // Protect against no data
+  if (m_lblbFolderName.empty()) return StatusCode::SUCCESS;
+
   const AthenaAttributeList* attrList = 0;
   CHECK(detStore()->retrieve(attrList, m_lblbFolderName));
 
@@ -486,188 +374,40 @@ LuminosityTool::recalculatePerBCIDLumi()
   m_recalcPerBCIDLumi = false;
 
   // Clear the calibrated luminosity data
-  m_LBInstLumi = std::vector<float>(TOTAL_LHC_BCIDS, 0.);
+  m_LBInstLumi.assign(TOTAL_LHC_BCIDS, 0.);
 
   // Make some sanity checks that we have everyting we need
   if (m_preferredChannel == 0) return;
   if (m_LBAvInstLumi == 0.) return;
 
-  // Check if we have data
-  if (m_cali.count(m_preferredChannel) == 0) {
-    ATH_MSG_WARNING( " dont have calibration information for preferred channel " << m_preferredChannel << "!" );
+  // Nothing to do if we don't have the ingredients
+  if (m_onlineLumiCalibrationTool.empty()) {
+    ATH_MSG_DEBUG( "OnlineLumiCalibrationTool.empty() is TRUE, skipping..." );
     return;
   }
-
-  // Get the raw data for the preferred channel
-  const CondAttrListCollection* attrListColl = 0;
-  StatusCode sc = detStore()->retrieve(attrListColl, m_bunchlumisFolderName);
-  if (sc.isFailure() || !attrListColl) {
-    ATH_MSG_WARNING( "attrListColl not found for " << m_bunchlumisFolderName );
-    return;
-  }
-
-  // Loop over collection and find preferred channel
-  CondAttrListCollection::const_iterator first = attrListColl->begin();
-  CondAttrListCollection::const_iterator last  = attrListColl->end();
-  for (; first != last; ++first) {
-    cool::UInt32 channel = (*first).first;
-    if (channel != m_preferredChannel) continue;
-    break;
-  }
-
-  // Check if we didn't find the preferred channel
-  if (first == last) {
-    ATH_MSG_WARNING( "BUNCHLUMI data not found for channel " << m_preferredChannel << "!" <<endreq;
+  if (m_bunchLumisTool.empty()) {
+    ATH_MSG_DEBUG( "BunchLumisTool.empty() is TRUE, skipping..." );
     return;
   }
-
-  // attrList is the payload of /TDAQ/OLC/BUNCHLUMIS
-  const coral::AttributeList& attrList = (*first).second;
-
-  // Make sure the blob exists
-  if (attrList["BunchRawInstLum"].isNull()) {
-    ATH_MSG_WARNING( "BunchRawInstLumi blob not found for channel " << m_preferredChannel << "!" );
+  if (m_bunchGroupTool.empty()) {
+    ATH_MSG_DEBUG( "BunchGroupTool.empty() is TRUE, skipping..." );
     return;
   }
-
-  const coral::Blob& blob = attrList["BunchRawInstLum"].data<coral::Blob>();
-  if (blob.size() == 0) {
-    ATH_MSG_WARNING( "BunchRawInstLumi blob found with zero size for channel " << m_preferredChannel << "!" );
+  if (m_fillParamsTool.empty()) {
+    ATH_MSG_DEBUG( "FillParamsTool.empty() is TRUE, skipping..." );
     return;
   }
 
-  // Make sure the scale factor exists (needed below to unpack integer blob schemes)
-  if (attrList["AverageRawInstLum"].isNull()) {
-    ATH_MSG_WARNING( "AverageRawInstLum value not found for channel " << m_preferredChannel << "!" );
-    return;
-  }
-  float scaleFactor = attrList["AverageRawInstLum"].data<cool::Float>(); 
+  // Update data from FillParamsTool
+  m_luminousBunches = m_fillParamsTool->nLuminousBunches();
+  m_luminousBunchesVec = m_fillParamsTool->luminousBunches();
 
-  // Don't need to check validity as average value would already be invalid?  Or data wouldn't exist?  we will see
+  ATH_MSG_DEBUG( "N LuminousBunches:" << m_luminousBunches );
+  //ATH_MSG_DEBUG( m_luminousBunchesVec[0] << " " <<  m_luminousBunchesVec[1] );
 
-  //
-  // Unpack raw luminosity data blob here
-  //
-
-  // Figure out Mika's blob packing mode (should really have a utility for this)
-  // See description: https://twiki.cern.ch/twiki/bin/viewauth/Atlas/CoolOnlineData#Folder_TDAQ_OLC_BUNCHLUMIS
- 
-  const char* pchar = static_cast<const char*>(blob.startingAddress()); // First byte holds storage size and mode
-  unsigned int bss = ((*pchar) % 100) / 10;  // Byte storage size
-  unsigned int smod = ((*pchar) % 10);       // Storage mode
-
-  ATH_MSG_DEBUG( "BunchRawInstLumi blob found with storage mode " << smod << " and byte storage size " << bss );
-
-  // Check blob length and point pchar to start of raw lumi data
-  unsigned int bloblength = 0;
-  unsigned int nbcids = 0;
-
-  // Used below for smod==2 scheme, also advance pchar past first byte
-  const uint16_t* p16 = (const uint16_t*)(++pchar);  
-
-  // Treat different storage modes independently
-  switch (smod) {
-  case 0:
-    // Packed according to luminousBunches
-    nbcids = m_luminousBunches;
-    bloblength = bss * nbcids + 1;
-    break;
-
-  case 1:
-    // Full orbit stored
-    nbcids = TOTAL_LHC_BCIDS;
-    bloblength = bss * nbcids + 1;
-    break;
-
-  case 2:
-    // Self describing length, with 2-byte length followed by 2-byte BCID vector, then data
-    nbcids = *p16++;
-    bloblength = (2+bss)*nbcids + 3;  // 2-bytes for vector plus bss plus 2 bytes for vector length, plus one byte for packing
-    pchar += 2*(nbcids+1); // Advance pchar past bicd vector list to raw data, p16 used below to get BCID vector list
-    // ATH_MSG_DEBUG( "Found mode 2 with " << nbcids << " BCIDs" );
-    break;
-
-  default:
-    ATH_MSG_WARNING( "BunchRawInstLumi blob found with unknown storage mode " << smod << "!" );
-    return;
-  }
-
-  // Check blob size against needed length.  Give up if these don't match
-  if (static_cast<cool::UInt32>(blob.size()) != bloblength) {
-    ATH_MSG_WARNING( "BunchRawInstLumi blob found with length" << blob.size() << "in storage mode" << smod <<  ", expecting " << bloblength << "!" );
-    return;
-  }
-
-  // Length is correct, read raw data according to packing scheme
-  // Some schemes are relative and must be renormalized, while the float/double schemes are absolute values - *pay attention!*
-  std::vector<float> rawLumi;
-  rawLumi.clear();
-
-  // Must define pointers outside of switch
-  const uint16_t* p2 = (const uint16_t*) pchar;
-  const float* p4 = (const float*) pchar;
-  const double* p8 = (const double*) pchar;
-
-  // Different depending upon bytes allocated (this is ugly, but it works)
-  // pchar is pointing to the start of the data (past first byte of blob)
-  switch (bss) {
-
-  case 1: // 1-byte integers, just use pchar
-    for (unsigned int i=0; i<nbcids; i++, pchar++) {
-      float val = (*pchar) * scaleFactor / pow(100, bss);
-      rawLumi.push_back(val);
-    }
-    break;
-
-  case 2: // 2-byte integers
-    for (unsigned int i=0; i<nbcids; i++, p2++) {
-      float val = (*p2) * scaleFactor / pow(100, bss);
-      rawLumi.push_back(val);
-    }
-    break;
-
-  case 4: // 4-byte floats
-    for (unsigned int i=0; i<nbcids; i++, p4++) rawLumi.push_back(*p4);
-    break;
-
-  case 8: // 8-byte doubles
-    for (unsigned int i=0; i<nbcids; i++, p8++) rawLumi.push_back(*p8);
-    break;
-
-  default:
-    ATH_MSG_WARNING( "BunchRawInstLumi blob found with unknown byte storage size " << bss << "!" );
-    return;
-  }
-
-  // Now figure which BCIDs these values belong to and fill into temporary vector indexed by BCID
-  // (not all BCIDs will end up in m_LBInstLumi)
-  std::vector<float> rawLumiVec(TOTAL_LHC_BCIDS, 0.);
-
-  // Remember, nbcids was set before and the blob size was checked
-  switch (smod) {
-  case 0:
-    // Packed according to luminous bunches, fill accordingly
-    for (unsigned int i=0; i<nbcids; i++) 
-      rawLumiVec[m_luminousBunchesVec[i]] = rawLumi[i]; 
-    break;
-
-  case 1:
-    // Packed according to full turn, just copy
-    rawLumiVec = rawLumi;
-    break;
-
-  case 2:
-    // Packed according to private list, must read here.  p16 points to start of this data
-    for (unsigned int i=0; i<nbcids; i++, p16++) {
-      rawLumiVec[*p16] = rawLumi[i];
-      // ATH_MSG_DEBUG( "BCID: " << *p16 << " Lumi= " << rawLumi[i] );
-    }
-    break;
-
-  default:
-    // This error condition was delt with before
-    return;
-  }
+  // Get the raw data for the preferred channel
+  m_bunchLumisTool->setChannel(m_preferredChannel);
+  std::vector<float> rawLumiVec = m_bunchLumisTool->rawLuminosity();
 
 
   //
@@ -679,31 +419,33 @@ LuminosityTool::recalculatePerBCIDLumi()
   // to agree to whatever offline tag we are using.
   std::vector<float> calLumiVec(TOTAL_LHC_BCIDS, 0.);
 
-  // Calibrator to use
-  LumiCalibrator& lc = m_cali[m_preferredChannel];
+  // Update muToLumi while we are at it (also check that calibration exists)
+  m_MuToLumi = m_onlineLumiCalibrationTool->getMuToLumi(m_preferredChannel);
+  if (m_MuToLumi <= 0.) {
+    ATH_MSG_WARNING( " dont have calibration information for preferred channel " << m_preferredChannel << "!" );
+    return;
+  }
 
   double lumiSum = 0.;
   for (unsigned int i = 0; i<m_luminousBunches; i++) {
     unsigned int bcid = m_luminousBunchesVec[i];
 
-    if (msgLvl(MSG::DEBUG)) 
-      msg(MSG::DEBUG) << "Calibrate BCID " << bcid << " with raw " << rawLumiVec[bcid];
-
     // Don't waste time on zero lumi 
     if (rawLumiVec[bcid] <= 0.) {
-      if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << endreq; 
+      ATH_MSG_DEBUG( "Calibrate BCID " << bcid << " with raw " << rawLumiVec[bcid] << " -> skipping" );
       continue;
     }
 
     // Calibrate
-    if (!lc.calibrateLumi(rawLumiVec[bcid], calLumiVec[bcid])) {
-      if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << " -> Calibration failed!" << endreq;
+    if (!m_onlineLumiCalibrationTool->calibrateLumi(m_preferredChannel, rawLumiVec[bcid], calLumiVec[bcid])) {
+      ATH_MSG_DEBUG( "Calibrate BCID " << bcid << " with raw " << rawLumiVec[bcid] << " -> calibration failed!" );
       ATH_MSG_WARNING( "Per-BCID calibration failed for bcid " << bcid << " with raw lumi = " << rawLumiVec[bcid] );
       continue;
     }
 
     lumiSum += calLumiVec[bcid];
-    if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << " -> " << calLumiVec[bcid] );
+
+    ATH_MSG_DEBUG( "Calibrate BCID " << bcid << " with raw " << rawLumiVec[bcid] << " -> " << calLumiVec[bcid] );
   }
 
   // Work out scale factor between offline and online estimate
@@ -712,16 +454,21 @@ LuminosityTool::recalculatePerBCIDLumi()
 
   ATH_MSG_DEBUG( " Offline/Online scale factor: " << m_LBAvInstLumi << " / " << lumiSum << " = " << offlineOnlineRatio );
 
-  // Also calibrate any luminosities in the physics bunch group (not already handled above)
-  for (unsigned int i = 0; i<m_bgBunches; i++) {
-    unsigned int bcid = m_bgBunchesVec[i];
+  // Make sure we have values for all BCIDs in the physics bunch group
+  // std::vector<unsigned int> m_bgBunchesVec = m_bunchGroupTool->bunchGroup1();
+  for (unsigned int i = 0; i<m_bunchGroupTool->nBunchGroup1(); i++) {
+    unsigned int bcid = m_bunchGroupTool->bunchGroup1()[i];
 
     // Don't repeat if value already exists
     if (calLumiVec[bcid] > 0.) continue;
     if (rawLumiVec[bcid] <= 0.) continue;
 
     // Calibrate
-    lc.calibrateLumi(rawLumiVec[bcid], calLumiVec[bcid]);
+    if (!m_onlineLumiCalibrationTool->calibrateLumi(m_preferredChannel, rawLumiVec[bcid], calLumiVec[bcid])) {
+      if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << " -> Calibration failed!" << endreq;
+      ATH_MSG_WARNING( "Per-BCID calibration failed for bcid " << bcid << " with raw lumi = " << rawLumiVec[bcid] );
+      continue;
+    }
   }
 
   // Almost done, now we apply the scale factor to all BCIDs
@@ -731,6 +478,7 @@ LuminosityTool::recalculatePerBCIDLumi()
   // And finally assign this vector to our final data location
   m_LBInstLumi = calLumiVec;
 
+  ATH_MSG_DEBUG( "finished recalculatePerBCIDLumi() for alg: " << m_preferredChannel );
   return;
 }
 
diff --git a/LumiBlock/LumiBlockComps/src/ReplicaSorter.cxx b/LumiBlock/LumiBlockComps/src/ReplicaSorter.cxx
deleted file mode 100644
index 2ac40ae95ef1bd2469935e14f8a96b511a63e955..0000000000000000000000000000000000000000
--- a/LumiBlock/LumiBlockComps/src/ReplicaSorter.cxx
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
-*/
-
-// ReplicaSorter.cxx
-// Richard Hawkings, 26/11/07
-
-#include <stdlib.h>
-#include <iostream>
-#include <fstream>
-#include <map>
-#include <cstring>
-#include "RelationalAccess/IDatabaseServiceDescription.h"
-#include "LumiBlockComps/ReplicaSorter.h"
-
-ReplicaSorter::ReplicaSorter() :
-  m_frontiergen(false) {
-  readConfig();
-}
-
-void ReplicaSorter::sort(std::vector<
-	  const coral::IDatabaseServiceDescription*>& replicaSet) {
-  // loop through all the offered replicas
-  std::map<int,const coral::IDatabaseServiceDescription*> primap;
-  for (std::vector<const coral::IDatabaseServiceDescription*>::const_iterator 
-	 itr=replicaSet.begin();itr!=replicaSet.end();++itr) {
-    const std::string conn=(**itr).connectionString();
-    // do not use SQLite files
-    if (conn.find("sqlite_file")==std::string::npos) {
-      // extract the server name (assuming URLs "techno://server/schema")
-      std::string::size_type ipos1=conn.find("://");
-      std::string::size_type ipos2=conn.find("/",ipos1+3);
-      if (ipos1!=std::string::npos && ipos2!=std::string::npos) {
-        const std::string server=conn.substr(ipos1+3,ipos2-ipos1-3);
-        // check if this server is on list of replicas to use for domain
-        // if so, add it with its associated priority
-        for (ServerMap::const_iterator sitr=m_servermap.begin();
-	     sitr!=m_servermap.end();++sitr) {
-          if (sitr->first==server) 
-            primap[sitr->second]=*itr;
-	}
-      }
-    }
-  }
-  // now create sorted list
-  replicaSet.clear();
-  for (std::map<int,const coral::IDatabaseServiceDescription*>::const_iterator 
-	   itr=primap.begin();itr!=primap.end();++itr) {
-    replicaSet.push_back(itr->second);
-    std::cout << "Allowed replica to try (priority " << itr->first 
-	      << ") : " << (itr->second)->connectionString() << std::endl;
-  }
-  if (replicaSet.empty())
-    std::cout << "No matching replicas found" << std::endl;
-}
-
-bool ReplicaSorter::readConfig() {
-  // determine the hostname from ATLAS_CONDDB, HOSTNAME or hostname -fqdn
-  m_hostname="";
-  const char* chost=getenv("ATLAS_CONDDB");
-  if (chost) m_hostname=chost;
-  if (m_hostname.empty()) {
-    const char* chost=getenv("HOSTNAME");
-    if (chost) m_hostname=chost;
-    // check if the returned host has a .
-    if (m_hostname.find(".")==std::string::npos) {
-      m_hostname="unknown";
-      system("hostname --fqdn > hostnamelookup.tmp");
-      std::ifstream infile;
-      infile.open("hostnamelookup.tmp");
-      if (infile) { 
-        infile >> m_hostname; 
-      } else {
-	m_hostname="unknown";
-      }
-    }
-  }
-  std::cout << "Using machine hostname " << m_hostname << 
-    " for DB replica resolution" << std::endl;
-  // check if FRONTIER_SERVER is set, if so, allow generic replicas
-  const char* cfrontier=getenv("FRONTIER_SERVER");
-  if (cfrontier && strcmp(cfrontier,"")!=0) {
-    std::cout << "Frontier server at " << cfrontier << " will be considered"
-	      << std::endl;
-    m_frontiergen=true;
-  }
- 
-  // try to locate configuration file using pathresolver
-  FILE* p_inp=0;
-  const char* datapath=getenv("DATAPATH");
-  if (datapath!=0) p_inp=findFile("dbreplica.config",datapath);
-  if (p_inp==0) {
-    std::cout << "Cannot open/locate configuration file dbreplica.config" 
-	      << std::endl;
-    return false;
-  }
-  // buffer for reading line
-  unsigned int bufsize=999;
-  char* p_buf=new char[bufsize];
-  while (!feof(p_inp)) {
-    char* p_line=fgets(p_buf,bufsize,p_inp);
-    if (p_line!=NULL && p_line[0]!='#') {
-      std::string buf=std::string(p_line);
-      std::string::size_type iofs1=0;
-      // analyse based on spaces as seperator
-      bool sequal=false;
-      std::vector<std::string> domains;
-      std::vector<std::string> servers;
-      while (iofs1<buf.size()) {
-        std::string::size_type iofs2=buf.find(" ",iofs1);
-        // allow for trailing linefeed
-        if (iofs2==std::string::npos) iofs2=buf.size()-1;
-        std::string token=buf.substr(iofs1,iofs2-iofs1);
-	// skip empty or space tokens
-	if (token!="" && token!=" ") {
-          if (token=="=") {
-  	    sequal=true;
-          } else if (!sequal) {
- 	    // token is a domain name
-	    domains.push_back(token);
-          } else {
-  	    // token is a server name
-	    // only add Frontier ATLF server if FRONTIER_CLIENT set
-	    if (token!="ATLF" || m_frontiergen) servers.push_back(token);
-          }
-	}
-        iofs1=iofs2+1;
-      }
-      // check the list of domains against the hostname to see if this
-      // set of servers is appropriate
-      bool useit=false;
-      unsigned int bestlen=0;
-      for (std::vector<std::string>::const_iterator itr=domains.begin();
-	   itr!=domains.end();++itr) {
-        std::string::size_type len=(itr->size());
-	std::string::size_type hlen=m_hostname.size();
-        if (hlen>=len && *itr==m_hostname.substr(hlen-len,len)) {
-	  if (len>bestlen) {
-	    useit=true;
- 	    bestlen=len;
-	  }
-	}
-	// for 'default' domain name, add the servers as a last resort
-	// if nothing has been found so far
-	if ("default"==*itr && m_servermap.empty()) {
-	  std::cout <<
-            "No specific match for domain found - use default fallback"
-		    << std::endl;
-	  useit=true;
-	  bestlen=0;
-	}
-      }
-      if (useit) {
-	// assign these servers, priority based on position in list
-	// and length of match of domain name
-	for (unsigned int i=0;i<servers.size();++i) {
-	  int priority=i-100*bestlen;
-	  m_servermap.push_back(ServerPair(servers[i],priority));
-	}
-      }
-    }
-  }
-  fclose(p_inp);
-  delete [] p_buf;
-  std::cout << "Total of " << m_servermap.size() << 
-    " servers found for host " << m_hostname << std::endl;
-  return true;
-}
-
-FILE* ReplicaSorter::findFile(const std::string filename,
-			const std::string pathvar) {
-  // behave like pathresolver
-  std::string::size_type iofs1,iofs2,len;
-  FILE* fptr=0;
-  iofs1=0;
-  len=pathvar.size();
-  std::string name;
-  while (!fptr && iofs1<len) {
-    iofs2=pathvar.find(":",iofs1);
-    if (iofs2==std::string::npos) iofs2=len;
-    name=pathvar.substr(iofs1,iofs2-iofs1)+"/"+filename;
-    fptr=fopen(name.c_str(),"r");
-    iofs1=iofs2+1;
-  }
-  return fptr;
-}
diff --git a/LumiBlock/LumiBlockComps/src/ReplicaSorter.h b/LumiBlock/LumiBlockComps/src/ReplicaSorter.h
deleted file mode 100644
index 272c9de2c2e1df9530d3ed115c29b0929d76268f..0000000000000000000000000000000000000000
--- a/LumiBlock/LumiBlockComps/src/ReplicaSorter.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
-*/
-
-// ReplicaSorter - class implementing CORAL IReplicaSortingAlgorithm 
-// for AtlCoolCopy, analogue of Athena DBReplicaSvc
-// Richard Hawkings, 26/11/07
-
-#include <string>
-#include "RelationalAccess/IReplicaSortingAlgorithm.h"
-
-class ReplicaSorter : virtual public coral::IReplicaSortingAlgorithm {
- public:
-  ReplicaSorter();
-  void sort(std::vector<const coral::IDatabaseServiceDescription*>& 
-	    replicaSet);
- private:
-  bool readConfig();
-  FILE* findFile(const std::string filename, const std::string pathvar);
-  std::string m_hostname;
-  typedef std::pair<std::string,int> ServerPair;
-  typedef std::vector< ServerPair > ServerMap;
-  ServerMap m_servermap;
-  bool m_frontiergen;
-};
diff --git a/LumiBlock/LumiBlockComps/src/TrigLivefractionTool.cxx b/LumiBlock/LumiBlockComps/src/TrigLivefractionTool.cxx
index c952cdd640122d5d38845a3473370ef966a4a87d..ded66380597d8a6de8d2a0c52814a7324d047de9 100644
--- a/LumiBlock/LumiBlockComps/src/TrigLivefractionTool.cxx
+++ b/LumiBlock/LumiBlockComps/src/TrigLivefractionTool.cxx
@@ -2,7 +2,7 @@
   Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
 */
 
-#include "TrigLivefractionTool.h"
+#include "LumiBlockComps/TrigLivefractionTool.h"
 
 #include "EventInfo/EventID.h"
 #include "EventInfo/EventInfo.h"
@@ -22,18 +22,19 @@ TrigLivefractionTool::TrigLivefractionTool(const std::string& type,
 				 const IInterface* parent)
   : AthAlgTool(type, name, parent),
     m_recalcLumiLivefraction(true),
-    m_lumiTool("LuminosityTool"),
+    m_lumiTool(""), // "LuminosityTool"),
     m_turnCounter(0),
-    m_deadtimeFolderName("/TRIGGER/LUMI/PerBcidDeadtime"),
-    m_lumiLiveFractionLo(0.),
-    m_lumiLiveFractionHi(0.)
+    m_deadtimeFolderName(""), // "/TRIGGER/LUMI/PerBcidDeadtime"),
+    m_lumiLiveFractionLo(1.),
+    m_lumiLiveFractionHi(1.)
 {
   declareInterface<ITrigLivefractionTool>(this);
   declareProperty("DeadtimeFolderName", m_deadtimeFolderName);
   declareProperty("LuminosityTool", m_lumiTool);
 
-  m_livefractionHigh = std::vector<float>(TOTAL_LHC_BCIDS, 0.);
-  m_livefractionLow  = std::vector<float>(TOTAL_LHC_BCIDS, 0.);
+  // Initialize to 1 so we don't have divide by zero if there is no data
+  m_livefractionHigh = std::vector<float>(TOTAL_LHC_BCIDS, 1.);
+  m_livefractionLow  = std::vector<float>(TOTAL_LHC_BCIDS, 1.);
 }
 
 StatusCode
@@ -41,37 +42,47 @@ TrigLivefractionTool::initialize()
 {
   ATH_MSG_DEBUG("TrigLivefractionTool::initialize() begin");
 
-  ATH_MSG_INFO("TrigLivefractionTool::initialize() registering " << m_deadtimeFolderName);
+  if (m_deadtimeFolderName.empty()) {
+    // May not be configured, could be OK
+    ATH_MSG_INFO("DeadtimeFolderName.empty is TRUE, skipping...");
+  } else {
+    ATH_MSG_INFO("TrigLivefractionTool::initialize() registering " << m_deadtimeFolderName);
 
-  // In addition to local, private callback functions, also set up callbacks to updateCache any time
-  // the local cached data changes.
-  // This must be done with the interface (ILuminosityTool) so external code can use this to trigger
-  // their own callbacks.
+    // In addition to local, private callback functions, also set up callbacks to updateCache any time
+    // the local cached data changes.
+    // This must be done with the interface (ILuminosityTool) so external code can use this to trigger
+    // their own callbacks.
 
-  // Setup callback
-  if (detStore()->contains<AthenaAttributeList>(m_deadtimeFolderName)) {
+    // Setup callback
+    if (detStore()->contains<AthenaAttributeList>(m_deadtimeFolderName)) {
 
-    const DataHandle<AthenaAttributeList> aptr;
+      const DataHandle<AthenaAttributeList> aptr;
 
-    // Causes updateLivefraction to be called when m_deadtimeFolderName changes
-    CHECK(detStore()->regFcn(&TrigLivefractionTool::updateLivefraction, this, aptr, m_deadtimeFolderName));
-    // Causes updateCache to be called when updateLivefraction is called 
-    CHECK(detStore()->regFcn(&TrigLivefractionTool::updateLivefraction, this, &ITrigLivefractionTool::updateCache, dynamic_cast<ITrigLivefractionTool*>(this)));
+      // Causes updateLivefraction to be called when m_deadtimeFolderName changes
+      CHECK(detStore()->regFcn(&TrigLivefractionTool::updateLivefraction, this, aptr, m_deadtimeFolderName));
+      // Causes updateCache to be called when updateLivefraction is called 
+      CHECK(detStore()->regFcn(&TrigLivefractionTool::updateLivefraction, this, &ITrigLivefractionTool::updateCache, dynamic_cast<ITrigLivefractionTool*>(this)));
 
-    //    CHECK(detStore()->regFcn(&ITrigLivefractionTool::updateCache, dynamic_cast<ITrigLivefractionTool*>(this) , aptr, m_deadtimeFolderName));
+      //    CHECK(detStore()->regFcn(&ITrigLivefractionTool::updateCache, dynamic_cast<ITrigLivefractionTool*>(this) , aptr, m_deadtimeFolderName));
 
-    ATH_MSG_INFO( " Registered a callback for " << m_deadtimeFolderName << " COOL folder " );
-  } else {
-    ATH_MSG_ERROR( " cannot find " << m_deadtimeFolderName << " in DetectorStore" );
+      ATH_MSG_INFO( " Registered a callback for " << m_deadtimeFolderName << " COOL folder " );
+    } else {
+      ATH_MSG_ERROR( " cannot find " << m_deadtimeFolderName << " in DetectorStore" );
+    }
   }
 
   // Get the luminosity tool
-  ATH_MSG_INFO( "Retrieving luminosity tool handle" );
-  CHECK(m_lumiTool.retrieve());
+  if (m_lumiTool.empty()) {
+    // May not be configured, could be OK
+    ATH_MSG_INFO( "LuminosityTool.empty() is TRUE, skipping...");
+  } else {
+    ATH_MSG_INFO( "Retrieving luminosity tool handle" );
+    CHECK(m_lumiTool.retrieve());
 
-  // Also set up a callback on luminosityTool change
-  ATH_MSG_INFO( "Registering callback on ILuminosityTool::updateCache" );
-  CHECK(detStore()->regFcn(&ILuminosityTool::updateCache, dynamic_cast<ILuminosityTool*>(&(*m_lumiTool)), &ITrigLivefractionTool::updateCache, dynamic_cast<ITrigLivefractionTool*>(this)));
+    // Also set up a callback on luminosityTool change
+    ATH_MSG_INFO( "Registering callback on ILuminosityTool::updateCache" );
+    CHECK(detStore()->regFcn(&ILuminosityTool::updateCache, dynamic_cast<ILuminosityTool*>(&(*m_lumiTool)), &ITrigLivefractionTool::updateCache, dynamic_cast<ITrigLivefractionTool*>(this)));
+  }
 
   ATH_MSG_DEBUG( "TrigLivefractionTool::initialize() end" );
   return StatusCode::SUCCESS;
@@ -157,10 +168,15 @@ TrigLivefractionTool::updateLivefraction( IOVSVC_CALLBACK_ARGS_P(/*idx*/, /*keys
   // Should be set in updateCache, but do it here just to make sure
   m_recalcLumiLivefraction = true;  
 
-  // Ensure zero on error
+  // Ensure value won't crash monitoring on error
   m_turnCounter = 0;
-  m_livefractionHigh = std::vector<float>(TOTAL_LHC_BCIDS, 0.);
-  m_livefractionLow  = std::vector<float>(TOTAL_LHC_BCIDS, 0.);
+  m_livefractionHigh = std::vector<float>(TOTAL_LHC_BCIDS, 1.);
+  m_livefractionLow  = std::vector<float>(TOTAL_LHC_BCIDS, 1.);
+
+  if (m_deadtimeFolderName.empty()) {
+    ATH_MSG_WARNING( "updateLiveFraction called with DeadtimeFolderName.empty() = True!" );
+    return StatusCode::SUCCESS;
+  }
 
   const AthenaAttributeList* attrList = 0;
   CHECK(detStore()->retrieve(attrList, m_deadtimeFolderName));
@@ -174,7 +190,7 @@ TrigLivefractionTool::updateLivefraction( IOVSVC_CALLBACK_ARGS_P(/*idx*/, /*keys
 
   // Nothing to do if turn counter is zero
   if (m_turnCounter == 0) {
-    ATH_MSG_INFO( "TurnCounter = " << m_turnCounter << " ... setting livefraction to 0");
+    ATH_MSG_INFO( "TurnCounter = " << m_turnCounter << " ... setting livefraction to 1");
     return StatusCode::SUCCESS;
   }
 
@@ -184,7 +200,7 @@ TrigLivefractionTool::updateLivefraction( IOVSVC_CALLBACK_ARGS_P(/*idx*/, /*keys
 
   // Check data availability
   if ((*attrList)["LowPriority"].isNull() || (*attrList)["HighPriority"].isNull()) {
-    ATH_MSG_WARNING( " NULL veto counter information in database ... set livefraction to 0 " );
+    ATH_MSG_WARNING( " NULL veto counter information in database ... set livefraction to 1 " );
     return StatusCode::SUCCESS;
   }
 
@@ -241,8 +257,14 @@ TrigLivefractionTool::recalculateLumiLivefraction()
   m_recalcLumiLivefraction = false;
 
   // One more thing, lets calculate the lumi-weighted live fraction
-  m_lumiLiveFractionLo = 0.;
-  m_lumiLiveFractionHi = 0.;
+  m_lumiLiveFractionLo = 1.;
+  m_lumiLiveFractionHi = 1.;
+
+  if (m_lumiTool.empty()) {
+    // May not be configured, could be OK
+    ATH_MSG_WARNING( "recalculateLumiLivefraction called with LuminosityTool.empty() == TRUE!");
+    return;
+  }
 
   double numsumlo = 0.;
   double numsumhi = 0.;
diff --git a/LumiBlock/LumiBlockComps/src/cmdline.cxx b/LumiBlock/LumiBlockComps/src/cmdline.cxx
deleted file mode 100644
index d908f6ae6dae1b5a5446968ab36ce35b76341d0d..0000000000000000000000000000000000000000
--- a/LumiBlock/LumiBlockComps/src/cmdline.cxx
+++ /dev/null
@@ -1,1498 +0,0 @@
-/*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
-*/
-
-/*
-  File autogenerated by gengetopt version 2.22.4
-  generated with the following command:
-  gengetopt 
-
-  The developers of gengetopt consider the fixed text that goes in all
-  gengetopt output files to be in the public domain:
-  we make no copyright claims on it.
-*/
-
-/* If we use autoconf.  */
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#ifndef FIX_UNUSED
-#define FIX_UNUSED(X) (void) (X) /* avoid warnings for unused params */
-#endif
-
-#include <getopt.h>
-
-#include "cmdline.h"
-
-const char *gengetopt_args_info_purpose = "";
-
-const char *gengetopt_args_info_usage = "Usage: iLumiCalc.exe [OPTIONS]...";
-
-const char *gengetopt_args_info_description = "";
-
-const char *gengetopt_args_info_help[] = {
-  "  -h, --help                  Print help and exit",
-  "      --version               Print version and exit",
-  "\nFlags to specify data sample:",
-  "  -r, --runnumber=STRING      Run number, range, or comma separated list, e.g. \n                                177986-178109,179710",
-  "      --lbstart=INT           LumiBlock number begin",
-  "      --lbend=INT             LumiBlock number end",
-  "  -x, --xml=STRING            Input XML file name",
-  "      --xml_blacklist=STRING  Input XML file of blacklist",
-  "  -T, --tag=STRING            Input TAG file name",
-  "      --root=STRING           Input ROOT file name",
-  "      --tree=STRING           Name of TTree in input ROOT file to which Lumi \n                                string is attached",
-  "      --d3pd_dir=STRING       Name of TDirectory in input ROOT file where Lumi \n                                string is stored",
-  "\nFlags to control luminosity calculation:",
-  "      --lumitag=STRING        Offline luminosity database tag  \n                                (default=`OflLumi-8TeV-002')",
-  "      --online                Use online luminosity estimates instead of \n                                offline database  (default=off)",
-  "      --lumichannel=INT       Luminosity estimate method by value  \n                                (default=`0')",
-  "      --lumimethod=STRING     Luminosity estimate method by string  \n                                (default=`ATLAS_PREFERRED')",
-  "  -t, --trigger=STRING        Trigger chain name used for prescale calculation",
-  "      --livetrigger=STRING    L1 Trigger used for livetime calculation  \n                                (default=`L1_EM30')",
-  "      --lar                   Calculate LAr defect fraction  (default=off)",
-  "      --lartag=STRING         LAr noise burst database tag  \n                                (default=`LARBadChannelsOflEventVeto-UPD4-01')",
-  "      --beamspot              Require online beamspot valid in trigger \n                                livefraction  (default=off)",
-  "      --beamspottag=STRING    Online beamspot database tag  \n                                (default=`IndetBeamposOnl-HLT-UPD1-001-00')",
-  "      --scale_lumi=DOUBLE     Scale luminosity with a constant value  \n                                (default=`1.0')",
-  "\nFlags to control output:",
-  "      --xml_out=STRING        Output XML file name",
-  "      --xml_collisionlist     Output XML file of lists of collision candidates  \n                                (default=off)",
-  "      --plots                 Create some plots on demand  (default=off)",
-  "  -V, --verbose               Verbose output level  (default=off)",
-  "      --quiet                 Quiet output level  (default=off)",
-    0
-};
-
-typedef enum {ARG_NO
-  , ARG_FLAG
-  , ARG_STRING
-  , ARG_INT
-  , ARG_DOUBLE
-} cmdline_parser_arg_type;
-
-static
-void clear_given (struct gengetopt_args_info *args_info);
-static
-void clear_args (struct gengetopt_args_info *args_info);
-
-static int
-cmdline_parser_internal (int argc, char **argv, struct gengetopt_args_info *args_info,
-                        struct cmdline_parser_params *params, const char *additional_error);
-
-static int
-cmdline_parser_required2 (struct gengetopt_args_info *args_info, const char *prog_name, const char *additional_error);
-
-static char *
-gengetopt_strdup (const char *s);
-
-static
-void clear_given (struct gengetopt_args_info *args_info)
-{
-  args_info->help_given = 0 ;
-  args_info->version_given = 0 ;
-  args_info->runnumber_given = 0 ;
-  args_info->lbstart_given = 0 ;
-  args_info->lbend_given = 0 ;
-  args_info->xml_given = 0 ;
-  args_info->xml_blacklist_given = 0 ;
-  args_info->tag_given = 0 ;
-  args_info->root_given = 0 ;
-  args_info->tree_given = 0 ;
-  args_info->d3pd_dir_given = 0 ;
-  args_info->lumitag_given = 0 ;
-  args_info->online_given = 0 ;
-  args_info->lumichannel_given = 0 ;
-  args_info->lumimethod_given = 0 ;
-  args_info->trigger_given = 0 ;
-  args_info->livetrigger_given = 0 ;
-  args_info->lar_given = 0 ;
-  args_info->lartag_given = 0 ;
-  args_info->beamspot_given = 0 ;
-  args_info->beamspottag_given = 0 ;
-  args_info->scale_lumi_given = 0 ;
-  args_info->xml_out_given = 0 ;
-  args_info->xml_collisionlist_given = 0 ;
-  args_info->plots_given = 0 ;
-  args_info->verbose_given = 0 ;
-  args_info->quiet_given = 0 ;
-}
-
-static
-void clear_args (struct gengetopt_args_info *args_info)
-{
-  FIX_UNUSED (args_info);
-  args_info->runnumber_arg = NULL;
-  args_info->runnumber_orig = NULL;
-  args_info->lbstart_arg = NULL;
-  args_info->lbstart_orig = NULL;
-  args_info->lbend_arg = NULL;
-  args_info->lbend_orig = NULL;
-  args_info->xml_arg = NULL;
-  args_info->xml_orig = NULL;
-  args_info->xml_blacklist_arg = NULL;
-  args_info->xml_blacklist_orig = NULL;
-  args_info->tag_arg = NULL;
-  args_info->tag_orig = NULL;
-  args_info->root_arg = NULL;
-  args_info->root_orig = NULL;
-  args_info->tree_arg = NULL;
-  args_info->tree_orig = NULL;
-  args_info->d3pd_dir_arg = NULL;
-  args_info->d3pd_dir_orig = NULL;
-  args_info->lumitag_arg = gengetopt_strdup ("OflLumi-8TeV-002");
-  args_info->lumitag_orig = NULL;
-  args_info->online_flag = 0;
-  args_info->lumichannel_arg = 0;
-  args_info->lumichannel_orig = NULL;
-  args_info->lumimethod_arg = gengetopt_strdup ("ATLAS_PREFERRED");
-  args_info->lumimethod_orig = NULL;
-  args_info->trigger_arg = NULL;
-  args_info->trigger_orig = NULL;
-  args_info->livetrigger_arg = gengetopt_strdup ("L1_EM30");
-  args_info->livetrigger_orig = NULL;
-  args_info->lar_flag = 0;
-  args_info->lartag_arg = gengetopt_strdup ("LARBadChannelsOflEventVeto-UPD4-01");
-  args_info->lartag_orig = NULL;
-  args_info->beamspot_flag = 0;
-  args_info->beamspottag_arg = gengetopt_strdup ("IndetBeamposOnl-HLT-UPD1-001-00");
-  args_info->beamspottag_orig = NULL;
-  args_info->scale_lumi_arg = 1.0;
-  args_info->scale_lumi_orig = NULL;
-  args_info->xml_out_arg = NULL;
-  args_info->xml_out_orig = NULL;
-  args_info->xml_collisionlist_flag = 0;
-  args_info->plots_flag = 0;
-  args_info->verbose_flag = 0;
-  args_info->quiet_flag = 0;
-  
-}
-
-static
-void init_args_info(struct gengetopt_args_info *args_info)
-{
-
-
-  args_info->help_help = gengetopt_args_info_help[0] ;
-  args_info->version_help = gengetopt_args_info_help[1] ;
-  args_info->runnumber_help = gengetopt_args_info_help[3] ;
-  args_info->runnumber_min = 0;
-  args_info->runnumber_max = 0;
-  args_info->lbstart_help = gengetopt_args_info_help[4] ;
-  args_info->lbstart_min = 0;
-  args_info->lbstart_max = 0;
-  args_info->lbend_help = gengetopt_args_info_help[5] ;
-  args_info->lbend_min = 0;
-  args_info->lbend_max = 0;
-  args_info->xml_help = gengetopt_args_info_help[6] ;
-  args_info->xml_min = 0;
-  args_info->xml_max = 0;
-  args_info->xml_blacklist_help = gengetopt_args_info_help[7] ;
-  args_info->tag_help = gengetopt_args_info_help[8] ;
-  args_info->tag_min = 0;
-  args_info->tag_max = 0;
-  args_info->root_help = gengetopt_args_info_help[9] ;
-  args_info->root_min = 0;
-  args_info->root_max = 0;
-  args_info->tree_help = gengetopt_args_info_help[10] ;
-  args_info->d3pd_dir_help = gengetopt_args_info_help[11] ;
-  args_info->lumitag_help = gengetopt_args_info_help[13] ;
-  args_info->online_help = gengetopt_args_info_help[14] ;
-  args_info->lumichannel_help = gengetopt_args_info_help[15] ;
-  args_info->lumimethod_help = gengetopt_args_info_help[16] ;
-  args_info->trigger_help = gengetopt_args_info_help[17] ;
-  args_info->trigger_min = 0;
-  args_info->trigger_max = 0;
-  args_info->livetrigger_help = gengetopt_args_info_help[18] ;
-  args_info->lar_help = gengetopt_args_info_help[19] ;
-  args_info->lartag_help = gengetopt_args_info_help[20] ;
-  args_info->beamspot_help = gengetopt_args_info_help[21] ;
-  args_info->beamspottag_help = gengetopt_args_info_help[22] ;
-  args_info->scale_lumi_help = gengetopt_args_info_help[23] ;
-  args_info->xml_out_help = gengetopt_args_info_help[25] ;
-  args_info->xml_collisionlist_help = gengetopt_args_info_help[26] ;
-  args_info->plots_help = gengetopt_args_info_help[27] ;
-  args_info->verbose_help = gengetopt_args_info_help[28] ;
-  args_info->quiet_help = gengetopt_args_info_help[29] ;
-  
-}
-
-void
-cmdline_parser_print_version (void)
-{
-  printf ("%s %s\n",
-     (strlen(CMDLINE_PARSER_PACKAGE_NAME) ? CMDLINE_PARSER_PACKAGE_NAME : CMDLINE_PARSER_PACKAGE),
-     CMDLINE_PARSER_VERSION);
-}
-
-static void print_help_common(void) {
-  cmdline_parser_print_version ();
-
-  if (strlen(gengetopt_args_info_purpose) > 0)
-    printf("\n%s\n", gengetopt_args_info_purpose);
-
-  if (strlen(gengetopt_args_info_usage) > 0)
-    printf("\n%s\n", gengetopt_args_info_usage);
-
-  printf("\n");
-
-  if (strlen(gengetopt_args_info_description) > 0)
-    printf("%s\n\n", gengetopt_args_info_description);
-}
-
-void
-cmdline_parser_print_help (void)
-{
-  int i = 0;
-  print_help_common();
-  while (gengetopt_args_info_help[i])
-    printf("%s\n", gengetopt_args_info_help[i++]);
-}
-
-void
-cmdline_parser_init (struct gengetopt_args_info *args_info)
-{
-  clear_given (args_info);
-  clear_args (args_info);
-  init_args_info (args_info);
-}
-
-void
-cmdline_parser_params_init(struct cmdline_parser_params *params)
-{
-  if (params)
-    { 
-      params->override = 0;
-      params->initialize = 1;
-      params->check_required = 1;
-      params->check_ambiguity = 0;
-      params->print_errors = 1;
-    }
-}
-
-struct cmdline_parser_params *
-cmdline_parser_params_create(void)
-{
-  struct cmdline_parser_params *params = 
-    (struct cmdline_parser_params *)malloc(sizeof(struct cmdline_parser_params));
-  cmdline_parser_params_init(params);  
-  return params;
-}
-
-static void
-free_string_field (char **s)
-{
-  if (*s)
-    {
-      free (*s);
-      *s = 0;
-    }
-}
-
-/** @brief generic value variable */
-union generic_value {
-    int int_arg;
-    double double_arg;
-    char *string_arg;
-    const char *default_string_arg;
-};
-
-/** @brief holds temporary values for multiple options */
-struct generic_list
-{
-  union generic_value arg;
-  char *orig;
-  struct generic_list *next;
-};
-
-/**
- * @brief add a node at the head of the list 
- */
-static void add_node(struct generic_list **list) {
-  struct generic_list *new_node = (struct generic_list *) malloc (sizeof (struct generic_list));
-  new_node->next = *list;
-  *list = new_node;
-  new_node->arg.string_arg = 0;
-  new_node->orig = 0;
-}
-
-/**
- * The passed arg parameter is NOT set to 0 from this function
- */
-static void
-free_multiple_field(unsigned int len, void *arg, char ***orig)
-{
-  unsigned int i;
-  if (arg) {
-    for (i = 0; i < len; ++i)
-      {
-        free_string_field(&((*orig)[i]));
-      }
-
-    free (arg);
-    free (*orig);
-    *orig = 0;
-  }
-}
-
-static void
-free_multiple_string_field(unsigned int len, char ***arg, char ***orig)
-{
-  unsigned int i;
-  if (*arg) {
-    for (i = 0; i < len; ++i)
-      {
-        free_string_field(&((*arg)[i]));
-        free_string_field(&((*orig)[i]));
-      }
-    free_string_field(&((*arg)[0])); /* free default string */
-
-    free (*arg);
-    *arg = 0;
-    free (*orig);
-    *orig = 0;
-  }
-}
-
-static void
-cmdline_parser_release (struct gengetopt_args_info *args_info)
-{
-
-  free_multiple_string_field (args_info->runnumber_given, &(args_info->runnumber_arg), &(args_info->runnumber_orig));
-  free_multiple_field (args_info->lbstart_given, (void *)(args_info->lbstart_arg), &(args_info->lbstart_orig));
-  args_info->lbstart_arg = 0;
-  free_multiple_field (args_info->lbend_given, (void *)(args_info->lbend_arg), &(args_info->lbend_orig));
-  args_info->lbend_arg = 0;
-  free_multiple_string_field (args_info->xml_given, &(args_info->xml_arg), &(args_info->xml_orig));
-  free_string_field (&(args_info->xml_blacklist_arg));
-  free_string_field (&(args_info->xml_blacklist_orig));
-  free_multiple_string_field (args_info->tag_given, &(args_info->tag_arg), &(args_info->tag_orig));
-  free_multiple_string_field (args_info->root_given, &(args_info->root_arg), &(args_info->root_orig));
-  free_string_field (&(args_info->tree_arg));
-  free_string_field (&(args_info->tree_orig));
-  free_string_field (&(args_info->d3pd_dir_arg));
-  free_string_field (&(args_info->d3pd_dir_orig));
-  free_string_field (&(args_info->lumitag_arg));
-  free_string_field (&(args_info->lumitag_orig));
-  free_string_field (&(args_info->lumichannel_orig));
-  free_string_field (&(args_info->lumimethod_arg));
-  free_string_field (&(args_info->lumimethod_orig));
-  free_multiple_string_field (args_info->trigger_given, &(args_info->trigger_arg), &(args_info->trigger_orig));
-  free_string_field (&(args_info->livetrigger_arg));
-  free_string_field (&(args_info->livetrigger_orig));
-  free_string_field (&(args_info->lartag_arg));
-  free_string_field (&(args_info->lartag_orig));
-  free_string_field (&(args_info->beamspottag_arg));
-  free_string_field (&(args_info->beamspottag_orig));
-  free_string_field (&(args_info->scale_lumi_orig));
-  free_string_field (&(args_info->xml_out_arg));
-  free_string_field (&(args_info->xml_out_orig));
-  
-  
-
-  clear_given (args_info);
-}
-
-
-static void
-write_into_file(FILE *outfile, const char *opt, const char *arg, const char *values[])
-{
-  FIX_UNUSED (values);
-  if (arg) {
-    fprintf(outfile, "%s=\"%s\"\n", opt, arg);
-  } else {
-    fprintf(outfile, "%s\n", opt);
-  }
-}
-
-static void
-write_multiple_into_file(FILE *outfile, int len, const char *opt, char **arg, const char *values[])
-{
-  int i;
-  
-  for (i = 0; i < len; ++i)
-    write_into_file(outfile, opt, (arg ? arg[i] : 0), values);
-}
-
-int
-cmdline_parser_dump(FILE *outfile, struct gengetopt_args_info *args_info)
-{
-  int i = 0;
-
-  if (!outfile)
-    {
-      fprintf (stderr, "%s: cannot dump options to stream\n", CMDLINE_PARSER_PACKAGE);
-      return EXIT_FAILURE;
-    }
-
-  if (args_info->help_given)
-    write_into_file(outfile, "help", 0, 0 );
-  if (args_info->version_given)
-    write_into_file(outfile, "version", 0, 0 );
-  write_multiple_into_file(outfile, args_info->runnumber_given, "runnumber", args_info->runnumber_orig, 0);
-  write_multiple_into_file(outfile, args_info->lbstart_given, "lbstart", args_info->lbstart_orig, 0);
-  write_multiple_into_file(outfile, args_info->lbend_given, "lbend", args_info->lbend_orig, 0);
-  write_multiple_into_file(outfile, args_info->xml_given, "xml", args_info->xml_orig, 0);
-  if (args_info->xml_blacklist_given)
-    write_into_file(outfile, "xml_blacklist", args_info->xml_blacklist_orig, 0);
-  write_multiple_into_file(outfile, args_info->tag_given, "tag", args_info->tag_orig, 0);
-  write_multiple_into_file(outfile, args_info->root_given, "root", args_info->root_orig, 0);
-  if (args_info->tree_given)
-    write_into_file(outfile, "tree", args_info->tree_orig, 0);
-  if (args_info->d3pd_dir_given)
-    write_into_file(outfile, "d3pd_dir", args_info->d3pd_dir_orig, 0);
-  if (args_info->lumitag_given)
-    write_into_file(outfile, "lumitag", args_info->lumitag_orig, 0);
-  if (args_info->online_given)
-    write_into_file(outfile, "online", 0, 0 );
-  if (args_info->lumichannel_given)
-    write_into_file(outfile, "lumichannel", args_info->lumichannel_orig, 0);
-  if (args_info->lumimethod_given)
-    write_into_file(outfile, "lumimethod", args_info->lumimethod_orig, 0);
-  write_multiple_into_file(outfile, args_info->trigger_given, "trigger", args_info->trigger_orig, 0);
-  if (args_info->livetrigger_given)
-    write_into_file(outfile, "livetrigger", args_info->livetrigger_orig, 0);
-  if (args_info->lar_given)
-    write_into_file(outfile, "lar", 0, 0 );
-  if (args_info->lartag_given)
-    write_into_file(outfile, "lartag", args_info->lartag_orig, 0);
-  if (args_info->beamspot_given)
-    write_into_file(outfile, "beamspot", 0, 0 );
-  if (args_info->beamspottag_given)
-    write_into_file(outfile, "beamspottag", args_info->beamspottag_orig, 0);
-  if (args_info->scale_lumi_given)
-    write_into_file(outfile, "scale_lumi", args_info->scale_lumi_orig, 0);
-  if (args_info->xml_out_given)
-    write_into_file(outfile, "xml_out", args_info->xml_out_orig, 0);
-  if (args_info->xml_collisionlist_given)
-    write_into_file(outfile, "xml_collisionlist", 0, 0 );
-  if (args_info->plots_given)
-    write_into_file(outfile, "plots", 0, 0 );
-  if (args_info->verbose_given)
-    write_into_file(outfile, "verbose", 0, 0 );
-  if (args_info->quiet_given)
-    write_into_file(outfile, "quiet", 0, 0 );
-  
-
-  i = EXIT_SUCCESS;
-  return i;
-}
-
-int
-cmdline_parser_file_save(const char *filename, struct gengetopt_args_info *args_info)
-{
-  FILE *outfile;
-  int i = 0;
-
-  outfile = fopen(filename, "w");
-
-  if (!outfile)
-    {
-      fprintf (stderr, "%s: cannot open file for writing: %s\n", CMDLINE_PARSER_PACKAGE, filename);
-      return EXIT_FAILURE;
-    }
-
-  i = cmdline_parser_dump(outfile, args_info);
-  fclose (outfile);
-
-  return i;
-}
-
-void
-cmdline_parser_free (struct gengetopt_args_info *args_info)
-{
-  cmdline_parser_release (args_info);
-}
-
-/** @brief replacement of strdup, which is not standard */
-char *
-gengetopt_strdup (const char *s)
-{
-  char *result = 0;
-  if (!s)
-    return result;
-
-  result = (char*)malloc(strlen(s) + 1);
-  if (result == (char*)0)
-    return (char*)0;
-  strcpy(result, s);
-  return result;
-}
-
-static char *
-get_multiple_arg_token(const char *arg)
-{
-  const char *tok;
-  char *ret;
-  size_t len, num_of_escape, i, j;
-
-  if (!arg)
-    return 0;
-
-  tok = strchr (arg, ',');
-  num_of_escape = 0;
-
-  /* make sure it is not escaped */
-  while (tok)
-    {
-      if (*(tok-1) == '\\')
-        {
-          /* find the next one */
-          tok = strchr (tok+1, ',');
-          ++num_of_escape;
-        }
-      else
-        break;
-    }
-
-  if (tok)
-    len = (size_t)(tok - arg + 1);
-  else
-    len = strlen (arg) + 1;
-
-  len -= num_of_escape;
-
-  ret = (char *) malloc (len);
-
-  i = 0;
-  j = 0;
-  while (arg[i] && (j < len-1))
-    {
-      if (arg[i] == '\\' && 
-	  arg[ i + 1 ] && 
-	  arg[ i + 1 ] == ',')
-        ++i;
-
-      ret[j++] = arg[i++];
-    }
-
-  ret[len-1] = '\0';
-
-  return ret;
-}
-
-static const char *
-get_multiple_arg_token_next(const char *arg)
-{
-  const char *tok;
-
-  if (!arg)
-    return 0;
-
-  tok = strchr (arg, ',');
-
-  /* make sure it is not escaped */
-  while (tok)
-    {
-      if (*(tok-1) == '\\')
-        {
-          /* find the next one */
-          tok = strchr (tok+1, ',');
-        }
-      else
-        break;
-    }
-
-  if (! tok || strlen(tok) == 1)
-    return 0;
-
-  return tok+1;
-}
-
-static int
-check_multiple_option_occurrences(const char *prog_name, unsigned int option_given, unsigned int min, unsigned int max, const char *option_desc);
-
-int
-check_multiple_option_occurrences(const char *prog_name, unsigned int option_given, unsigned int min, unsigned int max, const char *option_desc)
-{
-  int error = 0;
-
-  if (option_given && (min > 0 || max > 0))
-    {
-      if (min > 0 && max > 0)
-        {
-          if (min == max)
-            {
-              /* specific occurrences */
-              if (option_given != (unsigned int) min)
-                {
-                  fprintf (stderr, "%s: %s option occurrences must be %d\n",
-                    prog_name, option_desc, min);
-                  error = 1;
-                }
-            }
-          else if (option_given < (unsigned int) min
-                || option_given > (unsigned int) max)
-            {
-              /* range occurrences */
-              fprintf (stderr, "%s: %s option occurrences must be between %d and %d\n",
-                prog_name, option_desc, min, max);
-              error = 1;
-            }
-        }
-      else if (min > 0)
-        {
-          /* at least check */
-          if (option_given < min)
-            {
-              fprintf (stderr, "%s: %s option occurrences must be at least %d\n",
-                prog_name, option_desc, min);
-              error = 1;
-            }
-        }
-      else if (max > 0)
-        {
-          /* at most check */
-          if (option_given > max)
-            {
-              fprintf (stderr, "%s: %s option occurrences must be at most %d\n",
-                prog_name, option_desc, max);
-              error = 1;
-            }
-        }
-    }
-    
-  return error;
-}
-int
-cmdline_parser (int argc, char **argv, struct gengetopt_args_info *args_info)
-{
-  return cmdline_parser2 (argc, argv, args_info, 0, 1, 1);
-}
-
-int
-cmdline_parser_ext (int argc, char **argv, struct gengetopt_args_info *args_info,
-                   struct cmdline_parser_params *params)
-{
-  int result;
-  result = cmdline_parser_internal (argc, argv, args_info, params, 0);
-
-  if (result == EXIT_FAILURE)
-    {
-      cmdline_parser_free (args_info);
-      exit (EXIT_FAILURE);
-    }
-  
-  return result;
-}
-
-int
-cmdline_parser2 (int argc, char **argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required)
-{
-  int result;
-  struct cmdline_parser_params params;
-  
-  params.override = override;
-  params.initialize = initialize;
-  params.check_required = check_required;
-  params.check_ambiguity = 0;
-  params.print_errors = 1;
-
-  result = cmdline_parser_internal (argc, argv, args_info, &params, 0);
-
-  if (result == EXIT_FAILURE)
-    {
-      cmdline_parser_free (args_info);
-      exit (EXIT_FAILURE);
-    }
-  
-  return result;
-}
-
-int
-cmdline_parser_required (struct gengetopt_args_info *args_info, const char *prog_name)
-{
-  int result = EXIT_SUCCESS;
-
-  if (cmdline_parser_required2(args_info, prog_name, 0) > 0)
-    result = EXIT_FAILURE;
-
-  if (result == EXIT_FAILURE)
-    {
-      cmdline_parser_free (args_info);
-      exit (EXIT_FAILURE);
-    }
-  
-  return result;
-}
-
-int
-cmdline_parser_required2 (struct gengetopt_args_info *args_info, const char *prog_name, const char *additional_error)
-{
-  int error = 0;
-  FIX_UNUSED (additional_error);
-
-  /* checks for required options */
-  if (check_multiple_option_occurrences(prog_name, args_info->runnumber_given, args_info->runnumber_min, args_info->runnumber_max, "'--runnumber' ('-r')"))
-     error = 1;
-  
-  if (check_multiple_option_occurrences(prog_name, args_info->lbstart_given, args_info->lbstart_min, args_info->lbstart_max, "'--lbstart'"))
-     error = 1;
-  
-  if (check_multiple_option_occurrences(prog_name, args_info->lbend_given, args_info->lbend_min, args_info->lbend_max, "'--lbend'"))
-     error = 1;
-  
-  if (check_multiple_option_occurrences(prog_name, args_info->xml_given, args_info->xml_min, args_info->xml_max, "'--xml' ('-x')"))
-     error = 1;
-  
-  if (check_multiple_option_occurrences(prog_name, args_info->tag_given, args_info->tag_min, args_info->tag_max, "'--tag' ('-T')"))
-     error = 1;
-  
-  if (check_multiple_option_occurrences(prog_name, args_info->root_given, args_info->root_min, args_info->root_max, "'--root'"))
-     error = 1;
-  
-  if (check_multiple_option_occurrences(prog_name, args_info->trigger_given, args_info->trigger_min, args_info->trigger_max, "'--trigger' ('-t')"))
-     error = 1;
-  
-  
-  /* checks for dependences among options */
-
-  return error;
-}
-
-
-static char *package_name = 0;
-
-/**
- * @brief updates an option
- * @param field the generic pointer to the field to update
- * @param orig_field the pointer to the orig field
- * @param field_given the pointer to the number of occurrence of this option
- * @param prev_given the pointer to the number of occurrence already seen
- * @param value the argument for this option (if null no arg was specified)
- * @param possible_values the possible values for this option (if specified)
- * @param default_value the default value (in case the option only accepts fixed values)
- * @param arg_type the type of this option
- * @param check_ambiguity @see cmdline_parser_params.check_ambiguity
- * @param override @see cmdline_parser_params.override
- * @param no_free whether to free a possible previous value
- * @param multiple_option whether this is a multiple option
- * @param long_opt the corresponding long option
- * @param short_opt the corresponding short option (or '-' if none)
- * @param additional_error possible further error specification
- */
-static
-int update_arg(void *field, char **orig_field,
-               unsigned int *field_given, unsigned int *prev_given, 
-               char *value, const char *possible_values[],
-               const char *default_value,
-               cmdline_parser_arg_type arg_type,
-               int check_ambiguity, int override,
-               int no_free, int multiple_option,
-               const char *long_opt, char short_opt,
-               const char *additional_error)
-{
-  char *stop_char = 0;
-  const char *val = value;
-  int found;
-  char **string_field;
-  FIX_UNUSED (field);
-
-  stop_char = 0;
-  found = 0;
-
-  if (!multiple_option && prev_given && (*prev_given || (check_ambiguity && *field_given)))
-    {
-      if (short_opt != '-')
-        fprintf (stderr, "%s: `--%s' (`-%c') option given more than once%s\n", 
-               package_name, long_opt, short_opt,
-               (additional_error ? additional_error : ""));
-      else
-        fprintf (stderr, "%s: `--%s' option given more than once%s\n", 
-               package_name, long_opt,
-               (additional_error ? additional_error : ""));
-      return 1; /* failure */
-    }
-
-  FIX_UNUSED (default_value);
-    
-  if (field_given && *field_given && ! override)
-    return 0;
-  if (prev_given)
-    (*prev_given)++;
-  if (field_given)
-    (*field_given)++;
-  if (possible_values)
-    val = possible_values[found];
-
-  switch(arg_type) {
-  case ARG_FLAG:
-    *((int *)field) = !*((int *)field);
-    break;
-  case ARG_INT:
-    if (val) *((int *)field) = strtol (val, &stop_char, 0);
-    break;
-  case ARG_DOUBLE:
-    if (val) *((double *)field) = strtod (val, &stop_char);
-    break;
-  case ARG_STRING:
-    if (val) {
-      string_field = (char **)field;
-      if (!no_free && *string_field)
-        free (*string_field); /* free previous string */
-      *string_field = gengetopt_strdup (val);
-    }
-    break;
-  default:
-    break;
-  };
-
-  /* check numeric conversion */
-  switch(arg_type) {
-  case ARG_INT:
-  case ARG_DOUBLE:
-    if (val && !(stop_char && *stop_char == '\0')) {
-      fprintf(stderr, "%s: invalid numeric value: %s\n", package_name, val);
-      return 1; /* failure */
-    }
-    break;
-  default:
-    ;
-  };
-
-  /* store the original value */
-  switch(arg_type) {
-  case ARG_NO:
-  case ARG_FLAG:
-    break;
-  default:
-    if (value && orig_field) {
-      if (no_free) {
-        *orig_field = value;
-      } else {
-        if (*orig_field)
-          free (*orig_field); /* free previous string */
-        *orig_field = gengetopt_strdup (value);
-      }
-    }
-  };
-
-  return 0; /* OK */
-}
-
-/**
- * @brief store information about a multiple option in a temporary list
- * @param list where to (temporarily) store multiple options
- */
-static
-int update_multiple_arg_temp(struct generic_list **list,
-               unsigned int *prev_given, const char *val,
-               const char *possible_values[], const char *default_value,
-               cmdline_parser_arg_type arg_type,
-               const char *long_opt, char short_opt,
-               const char *additional_error)
-{
-  /* store single arguments */
-  char *multi_token;
-  const char *multi_next;
-
-  if (arg_type == ARG_NO) {
-    (*prev_given)++;
-    return 0; /* OK */
-  }
-
-  multi_token = get_multiple_arg_token(val);
-  multi_next = get_multiple_arg_token_next (val);
-
-  while (1)
-    {
-      add_node (list);
-      if (update_arg((void *)&((*list)->arg), &((*list)->orig), 0,
-          prev_given, multi_token, possible_values, default_value, 
-          arg_type, 0, 1, 1, 1, long_opt, short_opt, additional_error)) {
-        if (multi_token) free(multi_token);
-        return 1; /* failure */
-      }
-
-      if (multi_next)
-        {
-          multi_token = get_multiple_arg_token(multi_next);
-          multi_next = get_multiple_arg_token_next (multi_next);
-        }
-      else
-        break;
-    }
-
-  return 0; /* OK */
-}
-
-/**
- * @brief free the passed list (including possible string argument)
- */
-static
-void free_list(struct generic_list *list, short string_arg)
-{
-  if (list) {
-    struct generic_list *tmp;
-    while (list)
-      {
-        tmp = list;
-        if (string_arg && list->arg.string_arg)
-          free (list->arg.string_arg);
-        if (list->orig)
-          free (list->orig);
-        list = list->next;
-        free (tmp);
-      }
-  }
-}
-
-/**
- * @brief updates a multiple option starting from the passed list
- */
-static
-void update_multiple_arg(void *field, char ***orig_field,
-               unsigned int field_given, unsigned int prev_given, union generic_value *default_value,
-               cmdline_parser_arg_type arg_type,
-               struct generic_list *list)
-{
-  int i;
-  struct generic_list *tmp;
-
-  if (prev_given && list) {
-    *orig_field = (char **) realloc (*orig_field, (field_given + prev_given) * sizeof (char *));
-
-    switch(arg_type) {
-    case ARG_INT:
-      *((int **)field) = (int *)realloc (*((int **)field), (field_given + prev_given) * sizeof (int)); break;
-    case ARG_DOUBLE:
-      *((double **)field) = (double *)realloc (*((double **)field), (field_given + prev_given) * sizeof (double)); break;
-    case ARG_STRING:
-      *((char ***)field) = (char **)realloc (*((char ***)field), (field_given + prev_given) * sizeof (char *)); break;
-    default:
-      break;
-    };
-    
-    for (i = (prev_given - 1); i >= 0; --i)
-      {
-        tmp = list;
-        
-        switch(arg_type) {
-        case ARG_INT:
-          (*((int **)field))[i + field_given] = tmp->arg.int_arg; break;
-        case ARG_DOUBLE:
-          (*((double **)field))[i + field_given] = tmp->arg.double_arg; break;
-        case ARG_STRING:
-          (*((char ***)field))[i + field_given] = tmp->arg.string_arg; break;
-        default:
-          break;
-        }        
-        (*orig_field) [i + field_given] = list->orig;
-        list = list->next;
-        free (tmp);
-      }
-  } else { /* set the default value */
-    if (default_value && ! field_given) {
-      switch(arg_type) {
-      case ARG_INT:
-        if (! *((int **)field)) {
-          *((int **)field) = (int *)malloc (sizeof (int));
-          (*((int **)field))[0] = default_value->int_arg; 
-        }
-        break;
-      case ARG_DOUBLE:
-        if (! *((double **)field)) {
-          *((double **)field) = (double *)malloc (sizeof (double));
-          (*((double **)field))[0] = default_value->double_arg;
-        }
-        break;
-      case ARG_STRING:
-        if (! *((char ***)field)) {
-          *((char ***)field) = (char **)malloc (sizeof (char *));
-          (*((char ***)field))[0] = gengetopt_strdup(default_value->string_arg);
-        }
-        break;
-      default: break;
-      }
-      if (!(*orig_field)) {
-        *orig_field = (char **) malloc (sizeof (char *));
-        (*orig_field)[0] = 0;
-      }
-    }
-  }
-}
-
-int
-cmdline_parser_internal (
-  int argc, char **argv, struct gengetopt_args_info *args_info,
-                        struct cmdline_parser_params *params, const char *additional_error)
-{
-  int c;	/* Character of the parsed option.  */
-
-  struct generic_list * runnumber_list = NULL;
-  struct generic_list * lbstart_list = NULL;
-  struct generic_list * lbend_list = NULL;
-  struct generic_list * xml_list = NULL;
-  struct generic_list * tag_list = NULL;
-  struct generic_list * root_list = NULL;
-  struct generic_list * trigger_list = NULL;
-  int error = 0;
-  struct gengetopt_args_info local_args_info;
-  
-  int override;
-  int initialize;
-  int check_required;
-  int check_ambiguity;
-  
-  package_name = argv[0];
-  
-  override = params->override;
-  initialize = params->initialize;
-  check_required = params->check_required;
-  check_ambiguity = params->check_ambiguity;
-
-  if (initialize)
-    cmdline_parser_init (args_info);
-
-  cmdline_parser_init (&local_args_info);
-
-  optarg = 0;
-  optind = 0;
-  opterr = params->print_errors;
-  optopt = '?';
-
-  while (1)
-    {
-      int option_index = 0;
-
-      static struct option long_options[] = {
-        { "help",	0, NULL, 'h' },
-        { "version",	0, NULL, 0 },
-        { "runnumber",	1, NULL, 'r' },
-        { "lbstart",	1, NULL, 0 },
-        { "lbend",	1, NULL, 0 },
-        { "xml",	1, NULL, 'x' },
-        { "xml_blacklist",	1, NULL, 0 },
-        { "tag",	1, NULL, 'T' },
-        { "root",	1, NULL, 0 },
-        { "tree",	1, NULL, 0 },
-        { "d3pd_dir",	1, NULL, 0 },
-        { "lumitag",	1, NULL, 0 },
-        { "online",	0, NULL, 0 },
-        { "lumichannel",	1, NULL, 0 },
-        { "lumimethod",	1, NULL, 0 },
-        { "trigger",	1, NULL, 't' },
-        { "livetrigger",	1, NULL, 0 },
-        { "lar",	0, NULL, 0 },
-        { "lartag",	1, NULL, 0 },
-        { "beamspot",	0, NULL, 0 },
-        { "beamspottag",	1, NULL, 0 },
-        { "scale_lumi",	1, NULL, 0 },
-        { "xml_out",	1, NULL, 0 },
-        { "xml_collisionlist",	0, NULL, 0 },
-        { "plots",	0, NULL, 0 },
-        { "verbose",	0, NULL, 'V' },
-        { "quiet",	0, NULL, 0 },
-        { 0,  0, 0, 0 }
-      };
-
-      c = getopt_long (argc, argv, "hr:x:T:t:V", long_options, &option_index);
-
-      if (c == -1) break;	/* Exit from `while (1)' loop.  */
-
-      switch (c)
-        {
-        case 'h':	/* Print help and exit.  */
-          cmdline_parser_print_help ();
-          cmdline_parser_free (&local_args_info);
-          exit (EXIT_SUCCESS);
-
-        case 'r':	/* Run number, range, or comma separated list, e.g. 177986-178109,179710.  */
-        
-          if (update_multiple_arg_temp(&runnumber_list, 
-              &(local_args_info.runnumber_given), optarg, 0, 0, ARG_STRING,
-              "runnumber", 'r',
-              additional_error))
-            goto failure;
-        
-          break;
-        case 'x':	/* Input XML file name.  */
-        
-          if (update_multiple_arg_temp(&xml_list, 
-              &(local_args_info.xml_given), optarg, 0, 0, ARG_STRING,
-              "xml", 'x',
-              additional_error))
-            goto failure;
-        
-          break;
-        case 'T':	/* Input TAG file name.  */
-        
-          if (update_multiple_arg_temp(&tag_list, 
-              &(local_args_info.tag_given), optarg, 0, 0, ARG_STRING,
-              "tag", 'T',
-              additional_error))
-            goto failure;
-        
-          break;
-        case 't':	/* Trigger chain name used for prescale calculation.  */
-        
-          if (update_multiple_arg_temp(&trigger_list, 
-              &(local_args_info.trigger_given), optarg, 0, 0, ARG_STRING,
-              "trigger", 't',
-              additional_error))
-            goto failure;
-        
-          break;
-        case 'V':	/* Verbose output level.  */
-        
-        
-          if (update_arg((void *)&(args_info->verbose_flag), 0, &(args_info->verbose_given),
-              &(local_args_info.verbose_given), optarg, 0, 0, ARG_FLAG,
-              check_ambiguity, override, 1, 0, "verbose", 'V',
-              additional_error))
-            goto failure;
-        
-          break;
-
-        case 0:	/* Long option with no short option */
-          if (strcmp (long_options[option_index].name, "version") == 0) {
-            cmdline_parser_print_version ();
-            cmdline_parser_free (&local_args_info);
-            exit (EXIT_SUCCESS);
-          }
-
-          /* LumiBlock number begin.  */
-          if (strcmp (long_options[option_index].name, "lbstart") == 0)
-          {
-          
-            if (update_multiple_arg_temp(&lbstart_list, 
-                &(local_args_info.lbstart_given), optarg, 0, 0, ARG_INT,
-                "lbstart", '-',
-                additional_error))
-              goto failure;
-          
-          }
-          /* LumiBlock number end.  */
-          else if (strcmp (long_options[option_index].name, "lbend") == 0)
-          {
-          
-            if (update_multiple_arg_temp(&lbend_list, 
-                &(local_args_info.lbend_given), optarg, 0, 0, ARG_INT,
-                "lbend", '-',
-                additional_error))
-              goto failure;
-          
-          }
-          /* Input XML file of blacklist.  */
-          else if (strcmp (long_options[option_index].name, "xml_blacklist") == 0)
-          {
-          
-          
-            if (update_arg( (void *)&(args_info->xml_blacklist_arg), 
-                 &(args_info->xml_blacklist_orig), &(args_info->xml_blacklist_given),
-                &(local_args_info.xml_blacklist_given), optarg, 0, 0, ARG_STRING,
-                check_ambiguity, override, 0, 0,
-                "xml_blacklist", '-',
-                additional_error))
-              goto failure;
-          
-          }
-          /* Input ROOT file name.  */
-          else if (strcmp (long_options[option_index].name, "root") == 0)
-          {
-          
-            if (update_multiple_arg_temp(&root_list, 
-                &(local_args_info.root_given), optarg, 0, 0, ARG_STRING,
-                "root", '-',
-                additional_error))
-              goto failure;
-          
-          }
-          /* Name of TTree in input ROOT file to which Lumi string is attached.  */
-          else if (strcmp (long_options[option_index].name, "tree") == 0)
-          {
-          
-          
-            if (update_arg( (void *)&(args_info->tree_arg), 
-                 &(args_info->tree_orig), &(args_info->tree_given),
-                &(local_args_info.tree_given), optarg, 0, 0, ARG_STRING,
-                check_ambiguity, override, 0, 0,
-                "tree", '-',
-                additional_error))
-              goto failure;
-          
-          }
-          /* Name of TDirectory in input ROOT file where Lumi string is stored.  */
-          else if (strcmp (long_options[option_index].name, "d3pd_dir") == 0)
-          {
-          
-          
-            if (update_arg( (void *)&(args_info->d3pd_dir_arg), 
-                 &(args_info->d3pd_dir_orig), &(args_info->d3pd_dir_given),
-                &(local_args_info.d3pd_dir_given), optarg, 0, 0, ARG_STRING,
-                check_ambiguity, override, 0, 0,
-                "d3pd_dir", '-',
-                additional_error))
-              goto failure;
-          
-          }
-          /* Offline luminosity database tag.  */
-          else if (strcmp (long_options[option_index].name, "lumitag") == 0)
-          {
-          
-          
-            if (update_arg( (void *)&(args_info->lumitag_arg), 
-                 &(args_info->lumitag_orig), &(args_info->lumitag_given),
-                &(local_args_info.lumitag_given), optarg, 0, "OflLumi-8TeV-002", ARG_STRING,
-                check_ambiguity, override, 0, 0,
-                "lumitag", '-',
-                additional_error))
-              goto failure;
-          
-          }
-          /* Use online luminosity estimates instead of offline database.  */
-          else if (strcmp (long_options[option_index].name, "online") == 0)
-          {
-          
-          
-            if (update_arg((void *)&(args_info->online_flag), 0, &(args_info->online_given),
-                &(local_args_info.online_given), optarg, 0, 0, ARG_FLAG,
-                check_ambiguity, override, 1, 0, "online", '-',
-                additional_error))
-              goto failure;
-          
-          }
-          /* Luminosity estimate method by value.  */
-          else if (strcmp (long_options[option_index].name, "lumichannel") == 0)
-          {
-          
-          
-            if (update_arg( (void *)&(args_info->lumichannel_arg), 
-                 &(args_info->lumichannel_orig), &(args_info->lumichannel_given),
-                &(local_args_info.lumichannel_given), optarg, 0, "0", ARG_INT,
-                check_ambiguity, override, 0, 0,
-                "lumichannel", '-',
-                additional_error))
-              goto failure;
-          
-          }
-          /* Luminosity estimate method by string.  */
-          else if (strcmp (long_options[option_index].name, "lumimethod") == 0)
-          {
-          
-          
-            if (update_arg( (void *)&(args_info->lumimethod_arg), 
-                 &(args_info->lumimethod_orig), &(args_info->lumimethod_given),
-                &(local_args_info.lumimethod_given), optarg, 0, "ATLAS_PREFERRED", ARG_STRING,
-                check_ambiguity, override, 0, 0,
-                "lumimethod", '-',
-                additional_error))
-              goto failure;
-          
-          }
-          /* L1 Trigger used for livetime calculation.  */
-          else if (strcmp (long_options[option_index].name, "livetrigger") == 0)
-          {
-          
-          
-            if (update_arg( (void *)&(args_info->livetrigger_arg), 
-                 &(args_info->livetrigger_orig), &(args_info->livetrigger_given),
-                &(local_args_info.livetrigger_given), optarg, 0, "L1_EM30", ARG_STRING,
-                check_ambiguity, override, 0, 0,
-                "livetrigger", '-',
-                additional_error))
-              goto failure;
-          
-          }
-          /* Calculate LAr defect fraction.  */
-          else if (strcmp (long_options[option_index].name, "lar") == 0)
-          {
-          
-          
-            if (update_arg((void *)&(args_info->lar_flag), 0, &(args_info->lar_given),
-                &(local_args_info.lar_given), optarg, 0, 0, ARG_FLAG,
-                check_ambiguity, override, 1, 0, "lar", '-',
-                additional_error))
-              goto failure;
-          
-          }
-          /* LAr noise burst database tag.  */
-          else if (strcmp (long_options[option_index].name, "lartag") == 0)
-          {
-          
-          
-            if (update_arg( (void *)&(args_info->lartag_arg), 
-                 &(args_info->lartag_orig), &(args_info->lartag_given),
-                &(local_args_info.lartag_given), optarg, 0, "LARBadChannelsOflEventVeto-UPD4-01", ARG_STRING,
-                check_ambiguity, override, 0, 0,
-                "lartag", '-',
-                additional_error))
-              goto failure;
-          
-          }
-          /* Require online beamspot valid in trigger livefraction.  */
-          else if (strcmp (long_options[option_index].name, "beamspot") == 0)
-          {
-          
-          
-            if (update_arg((void *)&(args_info->beamspot_flag), 0, &(args_info->beamspot_given),
-                &(local_args_info.beamspot_given), optarg, 0, 0, ARG_FLAG,
-                check_ambiguity, override, 1, 0, "beamspot", '-',
-                additional_error))
-              goto failure;
-          
-          }
-          /* Online beamspot database tag.  */
-          else if (strcmp (long_options[option_index].name, "beamspottag") == 0)
-          {
-          
-          
-            if (update_arg( (void *)&(args_info->beamspottag_arg), 
-                 &(args_info->beamspottag_orig), &(args_info->beamspottag_given),
-                &(local_args_info.beamspottag_given), optarg, 0, "IndetBeamposOnl-HLT-UPD1-001-00", ARG_STRING,
-                check_ambiguity, override, 0, 0,
-                "beamspottag", '-',
-                additional_error))
-              goto failure;
-          
-          }
-          /* Scale luminosity with a constant value.  */
-          else if (strcmp (long_options[option_index].name, "scale_lumi") == 0)
-          {
-          
-          
-            if (update_arg( (void *)&(args_info->scale_lumi_arg), 
-                 &(args_info->scale_lumi_orig), &(args_info->scale_lumi_given),
-                &(local_args_info.scale_lumi_given), optarg, 0, "1.0", ARG_DOUBLE,
-                check_ambiguity, override, 0, 0,
-                "scale_lumi", '-',
-                additional_error))
-              goto failure;
-          
-          }
-          /* Output XML file name.  */
-          else if (strcmp (long_options[option_index].name, "xml_out") == 0)
-          {
-          
-          
-            if (update_arg( (void *)&(args_info->xml_out_arg), 
-                 &(args_info->xml_out_orig), &(args_info->xml_out_given),
-                &(local_args_info.xml_out_given), optarg, 0, 0, ARG_STRING,
-                check_ambiguity, override, 0, 0,
-                "xml_out", '-',
-                additional_error))
-              goto failure;
-          
-          }
-          /* Output XML file of lists of collision candidates.  */
-          else if (strcmp (long_options[option_index].name, "xml_collisionlist") == 0)
-          {
-          
-          
-            if (update_arg((void *)&(args_info->xml_collisionlist_flag), 0, &(args_info->xml_collisionlist_given),
-                &(local_args_info.xml_collisionlist_given), optarg, 0, 0, ARG_FLAG,
-                check_ambiguity, override, 1, 0, "xml_collisionlist", '-',
-                additional_error))
-              goto failure;
-          
-          }
-          /* Create some plots on demand.  */
-          else if (strcmp (long_options[option_index].name, "plots") == 0)
-          {
-          
-          
-            if (update_arg((void *)&(args_info->plots_flag), 0, &(args_info->plots_given),
-                &(local_args_info.plots_given), optarg, 0, 0, ARG_FLAG,
-                check_ambiguity, override, 1, 0, "plots", '-',
-                additional_error))
-              goto failure;
-          
-          }
-          /* Quiet output level.  */
-          else if (strcmp (long_options[option_index].name, "quiet") == 0)
-          {
-          
-          
-            if (update_arg((void *)&(args_info->quiet_flag), 0, &(args_info->quiet_given),
-                &(local_args_info.quiet_given), optarg, 0, 0, ARG_FLAG,
-                check_ambiguity, override, 1, 0, "quiet", '-',
-                additional_error))
-              goto failure;
-          
-          }
-          
-          break;
-        case '?':	/* Invalid option.  */
-          /* `getopt_long' already printed an error message.  */
-          goto failure;
-
-        default:	/* bug: option not considered.  */
-          fprintf (stderr, "%s: option unknown: %c%s\n", CMDLINE_PARSER_PACKAGE, c, (additional_error ? additional_error : ""));
-          abort ();
-        } /* switch */
-    } /* while */
-
-
-  update_multiple_arg((void *)&(args_info->runnumber_arg),
-    &(args_info->runnumber_orig), args_info->runnumber_given,
-    local_args_info.runnumber_given, 0,
-    ARG_STRING, runnumber_list);
-  update_multiple_arg((void *)&(args_info->lbstart_arg),
-    &(args_info->lbstart_orig), args_info->lbstart_given,
-    local_args_info.lbstart_given, 0,
-    ARG_INT, lbstart_list);
-  update_multiple_arg((void *)&(args_info->lbend_arg),
-    &(args_info->lbend_orig), args_info->lbend_given,
-    local_args_info.lbend_given, 0,
-    ARG_INT, lbend_list);
-  update_multiple_arg((void *)&(args_info->xml_arg),
-    &(args_info->xml_orig), args_info->xml_given,
-    local_args_info.xml_given, 0,
-    ARG_STRING, xml_list);
-  update_multiple_arg((void *)&(args_info->tag_arg),
-    &(args_info->tag_orig), args_info->tag_given,
-    local_args_info.tag_given, 0,
-    ARG_STRING, tag_list);
-  update_multiple_arg((void *)&(args_info->root_arg),
-    &(args_info->root_orig), args_info->root_given,
-    local_args_info.root_given, 0,
-    ARG_STRING, root_list);
-  update_multiple_arg((void *)&(args_info->trigger_arg),
-    &(args_info->trigger_orig), args_info->trigger_given,
-    local_args_info.trigger_given, 0,
-    ARG_STRING, trigger_list);
-
-  args_info->runnumber_given += local_args_info.runnumber_given;
-  local_args_info.runnumber_given = 0;
-  args_info->lbstart_given += local_args_info.lbstart_given;
-  local_args_info.lbstart_given = 0;
-  args_info->lbend_given += local_args_info.lbend_given;
-  local_args_info.lbend_given = 0;
-  args_info->xml_given += local_args_info.xml_given;
-  local_args_info.xml_given = 0;
-  args_info->tag_given += local_args_info.tag_given;
-  local_args_info.tag_given = 0;
-  args_info->root_given += local_args_info.root_given;
-  local_args_info.root_given = 0;
-  args_info->trigger_given += local_args_info.trigger_given;
-  local_args_info.trigger_given = 0;
-  
-  if (check_required)
-    {
-      error += cmdline_parser_required2 (args_info, argv[0], additional_error);
-    }
-
-  cmdline_parser_release (&local_args_info);
-
-  if ( error )
-    return (EXIT_FAILURE);
-
-  return 0;
-
-failure:
-  free_list (runnumber_list, 1 );
-  free_list (lbstart_list, 0 );
-  free_list (lbend_list, 0 );
-  free_list (xml_list, 1 );
-  free_list (tag_list, 1 );
-  free_list (root_list, 1 );
-  free_list (trigger_list, 1 );
-  
-  cmdline_parser_release (&local_args_info);
-  return (EXIT_FAILURE);
-}
diff --git a/LumiBlock/LumiBlockComps/src/cmdline.h b/LumiBlock/LumiBlockComps/src/cmdline.h
deleted file mode 100644
index 9db7204a1fe712cf757e6352c063fd45119d92a7..0000000000000000000000000000000000000000
--- a/LumiBlock/LumiBlockComps/src/cmdline.h
+++ /dev/null
@@ -1,282 +0,0 @@
-/*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
-*/
-
-/** @file cmdline.h
- *  @brief The header file for the command line option parser
- *  generated by GNU Gengetopt version 2.22.4
- *  http://www.gnu.org/software/gengetopt.
- *  DO NOT modify this file, since it can be overwritten
- *  @author GNU Gengetopt by Lorenzo Bettini */
-
-#ifndef CMDLINE_H
-#define CMDLINE_H
-
-/* If we use autoconf.  */
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <stdio.h> /* for FILE */
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-#ifndef CMDLINE_PARSER_PACKAGE
-/** @brief the program name (used for printing errors) */
-#define CMDLINE_PARSER_PACKAGE "iLumiCalc.exe"
-#endif
-
-#ifndef CMDLINE_PARSER_PACKAGE_NAME
-/** @brief the complete program name (used for help and version) */
-#define CMDLINE_PARSER_PACKAGE_NAME "iLumiCalc.exe"
-#endif
-
-#ifndef CMDLINE_PARSER_VERSION
-/** @brief the program version */
-#define CMDLINE_PARSER_VERSION "00-00-00"
-#endif
-
-/** @brief Where the command line options are stored */
-struct gengetopt_args_info
-{
-  const char *help_help; /**< @brief Print help and exit help description.  */
-  const char *version_help; /**< @brief Print version and exit help description.  */
-  char ** runnumber_arg;	/**< @brief Run number, range, or comma separated list, e.g. 177986-178109,179710.  */
-  char ** runnumber_orig;	/**< @brief Run number, range, or comma separated list, e.g. 177986-178109,179710 original value given at command line.  */
-  unsigned int runnumber_min; /**< @brief Run number, range, or comma separated list, e.g. 177986-178109,179710's minimum occurreces */
-  unsigned int runnumber_max; /**< @brief Run number, range, or comma separated list, e.g. 177986-178109,179710's maximum occurreces */
-  const char *runnumber_help; /**< @brief Run number, range, or comma separated list, e.g. 177986-178109,179710 help description.  */
-  int* lbstart_arg;	/**< @brief LumiBlock number begin.  */
-  char ** lbstart_orig;	/**< @brief LumiBlock number begin original value given at command line.  */
-  unsigned int lbstart_min; /**< @brief LumiBlock number begin's minimum occurreces */
-  unsigned int lbstart_max; /**< @brief LumiBlock number begin's maximum occurreces */
-  const char *lbstart_help; /**< @brief LumiBlock number begin help description.  */
-  int* lbend_arg;	/**< @brief LumiBlock number end.  */
-  char ** lbend_orig;	/**< @brief LumiBlock number end original value given at command line.  */
-  unsigned int lbend_min; /**< @brief LumiBlock number end's minimum occurreces */
-  unsigned int lbend_max; /**< @brief LumiBlock number end's maximum occurreces */
-  const char *lbend_help; /**< @brief LumiBlock number end help description.  */
-  char ** xml_arg;	/**< @brief Input XML file name.  */
-  char ** xml_orig;	/**< @brief Input XML file name original value given at command line.  */
-  unsigned int xml_min; /**< @brief Input XML file name's minimum occurreces */
-  unsigned int xml_max; /**< @brief Input XML file name's maximum occurreces */
-  const char *xml_help; /**< @brief Input XML file name help description.  */
-  char * xml_blacklist_arg;	/**< @brief Input XML file of blacklist.  */
-  char * xml_blacklist_orig;	/**< @brief Input XML file of blacklist original value given at command line.  */
-  const char *xml_blacklist_help; /**< @brief Input XML file of blacklist help description.  */
-  char ** tag_arg;	/**< @brief Input TAG file name.  */
-  char ** tag_orig;	/**< @brief Input TAG file name original value given at command line.  */
-  unsigned int tag_min; /**< @brief Input TAG file name's minimum occurreces */
-  unsigned int tag_max; /**< @brief Input TAG file name's maximum occurreces */
-  const char *tag_help; /**< @brief Input TAG file name help description.  */
-  char ** root_arg;	/**< @brief Input ROOT file name.  */
-  char ** root_orig;	/**< @brief Input ROOT file name original value given at command line.  */
-  unsigned int root_min; /**< @brief Input ROOT file name's minimum occurreces */
-  unsigned int root_max; /**< @brief Input ROOT file name's maximum occurreces */
-  const char *root_help; /**< @brief Input ROOT file name help description.  */
-  char * tree_arg;	/**< @brief Name of TTree in input ROOT file to which Lumi string is attached.  */
-  char * tree_orig;	/**< @brief Name of TTree in input ROOT file to which Lumi string is attached original value given at command line.  */
-  const char *tree_help; /**< @brief Name of TTree in input ROOT file to which Lumi string is attached help description.  */
-  char * d3pd_dir_arg;	/**< @brief Name of TDirectory in input ROOT file where Lumi string is stored.  */
-  char * d3pd_dir_orig;	/**< @brief Name of TDirectory in input ROOT file where Lumi string is stored original value given at command line.  */
-  const char *d3pd_dir_help; /**< @brief Name of TDirectory in input ROOT file where Lumi string is stored help description.  */
-  char * lumitag_arg;	/**< @brief Offline luminosity database tag (default='OflLumi-8TeV-002').  */
-  char * lumitag_orig;	/**< @brief Offline luminosity database tag original value given at command line.  */
-  const char *lumitag_help; /**< @brief Offline luminosity database tag help description.  */
-  int online_flag;	/**< @brief Use online luminosity estimates instead of offline database (default=off).  */
-  const char *online_help; /**< @brief Use online luminosity estimates instead of offline database help description.  */
-  int lumichannel_arg;	/**< @brief Luminosity estimate method by value (default='0').  */
-  char * lumichannel_orig;	/**< @brief Luminosity estimate method by value original value given at command line.  */
-  const char *lumichannel_help; /**< @brief Luminosity estimate method by value help description.  */
-  char * lumimethod_arg;	/**< @brief Luminosity estimate method by string (default='ATLAS_PREFERRED').  */
-  char * lumimethod_orig;	/**< @brief Luminosity estimate method by string original value given at command line.  */
-  const char *lumimethod_help; /**< @brief Luminosity estimate method by string help description.  */
-  char ** trigger_arg;	/**< @brief Trigger chain name used for prescale calculation.  */
-  char ** trigger_orig;	/**< @brief Trigger chain name used for prescale calculation original value given at command line.  */
-  unsigned int trigger_min; /**< @brief Trigger chain name used for prescale calculation's minimum occurreces */
-  unsigned int trigger_max; /**< @brief Trigger chain name used for prescale calculation's maximum occurreces */
-  const char *trigger_help; /**< @brief Trigger chain name used for prescale calculation help description.  */
-  char * livetrigger_arg;	/**< @brief L1 Trigger used for livetime calculation (default='L1_EM30').  */
-  char * livetrigger_orig;	/**< @brief L1 Trigger used for livetime calculation original value given at command line.  */
-  const char *livetrigger_help; /**< @brief L1 Trigger used for livetime calculation help description.  */
-  int lar_flag;	/**< @brief Calculate LAr defect fraction (default=off).  */
-  const char *lar_help; /**< @brief Calculate LAr defect fraction help description.  */
-  char * lartag_arg;	/**< @brief LAr noise burst database tag (default='LARBadChannelsOflEventVeto-UPD4-01').  */
-  char * lartag_orig;	/**< @brief LAr noise burst database tag original value given at command line.  */
-  const char *lartag_help; /**< @brief LAr noise burst database tag help description.  */
-  int beamspot_flag;	/**< @brief Require online beamspot valid in trigger livefraction (default=off).  */
-  const char *beamspot_help; /**< @brief Require online beamspot valid in trigger livefraction help description.  */
-  char * beamspottag_arg;	/**< @brief Online beamspot database tag (default='IndetBeamposOnl-HLT-UPD1-001-00').  */
-  char * beamspottag_orig;	/**< @brief Online beamspot database tag original value given at command line.  */
-  const char *beamspottag_help; /**< @brief Online beamspot database tag help description.  */
-  double scale_lumi_arg;	/**< @brief Scale luminosity with a constant value (default='1.0').  */
-  char * scale_lumi_orig;	/**< @brief Scale luminosity with a constant value original value given at command line.  */
-  const char *scale_lumi_help; /**< @brief Scale luminosity with a constant value help description.  */
-  char * xml_out_arg;	/**< @brief Output XML file name.  */
-  char * xml_out_orig;	/**< @brief Output XML file name original value given at command line.  */
-  const char *xml_out_help; /**< @brief Output XML file name help description.  */
-  int xml_collisionlist_flag;	/**< @brief Output XML file of lists of collision candidates (default=off).  */
-  const char *xml_collisionlist_help; /**< @brief Output XML file of lists of collision candidates help description.  */
-  int plots_flag;	/**< @brief Create some plots on demand (default=off).  */
-  const char *plots_help; /**< @brief Create some plots on demand help description.  */
-  int verbose_flag;	/**< @brief Verbose output level (default=off).  */
-  const char *verbose_help; /**< @brief Verbose output level help description.  */
-  int quiet_flag;	/**< @brief Quiet output level (default=off).  */
-  const char *quiet_help; /**< @brief Quiet output level help description.  */
-  
-  unsigned int help_given ;	/**< @brief Whether help was given.  */
-  unsigned int version_given ;	/**< @brief Whether version was given.  */
-  unsigned int runnumber_given ;	/**< @brief Whether runnumber was given.  */
-  unsigned int lbstart_given ;	/**< @brief Whether lbstart was given.  */
-  unsigned int lbend_given ;	/**< @brief Whether lbend was given.  */
-  unsigned int xml_given ;	/**< @brief Whether xml was given.  */
-  unsigned int xml_blacklist_given ;	/**< @brief Whether xml_blacklist was given.  */
-  unsigned int tag_given ;	/**< @brief Whether tag was given.  */
-  unsigned int root_given ;	/**< @brief Whether root was given.  */
-  unsigned int tree_given ;	/**< @brief Whether tree was given.  */
-  unsigned int d3pd_dir_given ;	/**< @brief Whether d3pd_dir was given.  */
-  unsigned int lumitag_given ;	/**< @brief Whether lumitag was given.  */
-  unsigned int online_given ;	/**< @brief Whether online was given.  */
-  unsigned int lumichannel_given ;	/**< @brief Whether lumichannel was given.  */
-  unsigned int lumimethod_given ;	/**< @brief Whether lumimethod was given.  */
-  unsigned int trigger_given ;	/**< @brief Whether trigger was given.  */
-  unsigned int livetrigger_given ;	/**< @brief Whether livetrigger was given.  */
-  unsigned int lar_given ;	/**< @brief Whether lar was given.  */
-  unsigned int lartag_given ;	/**< @brief Whether lartag was given.  */
-  unsigned int beamspot_given ;	/**< @brief Whether beamspot was given.  */
-  unsigned int beamspottag_given ;	/**< @brief Whether beamspottag was given.  */
-  unsigned int scale_lumi_given ;	/**< @brief Whether scale_lumi was given.  */
-  unsigned int xml_out_given ;	/**< @brief Whether xml_out was given.  */
-  unsigned int xml_collisionlist_given ;	/**< @brief Whether xml_collisionlist was given.  */
-  unsigned int plots_given ;	/**< @brief Whether plots was given.  */
-  unsigned int verbose_given ;	/**< @brief Whether verbose was given.  */
-  unsigned int quiet_given ;	/**< @brief Whether quiet was given.  */
-
-} ;
-
-/** @brief The additional parameters to pass to parser functions */
-struct cmdline_parser_params
-{
-  int override; /**< @brief whether to override possibly already present options (default 0) */
-  int initialize; /**< @brief whether to initialize the option structure gengetopt_args_info (default 1) */
-  int check_required; /**< @brief whether to check that all required options were provided (default 1) */
-  int check_ambiguity; /**< @brief whether to check for options already specified in the option structure gengetopt_args_info (default 0) */
-  int print_errors; /**< @brief whether getopt_long should print an error message for a bad option (default 1) */
-} ;
-
-/** @brief the purpose string of the program */
-extern const char *gengetopt_args_info_purpose;
-/** @brief the usage string of the program */
-extern const char *gengetopt_args_info_usage;
-/** @brief all the lines making the help output */
-extern const char *gengetopt_args_info_help[];
-
-/**
- * The command line parser
- * @param argc the number of command line options
- * @param argv the command line options
- * @param args_info the structure where option information will be stored
- * @return 0 if everything went fine, NON 0 if an error took place
- */
-int cmdline_parser (int argc, char **argv,
-  struct gengetopt_args_info *args_info);
-
-/**
- * The command line parser (version with additional parameters - deprecated)
- * @param argc the number of command line options
- * @param argv the command line options
- * @param args_info the structure where option information will be stored
- * @param override whether to override possibly already present options
- * @param initialize whether to initialize the option structure my_args_info
- * @param check_required whether to check that all required options were provided
- * @return 0 if everything went fine, NON 0 if an error took place
- * @deprecated use cmdline_parser_ext() instead
- */
-int cmdline_parser2 (int argc, char **argv,
-  struct gengetopt_args_info *args_info,
-  int override, int initialize, int check_required);
-
-/**
- * The command line parser (version with additional parameters)
- * @param argc the number of command line options
- * @param argv the command line options
- * @param args_info the structure where option information will be stored
- * @param params additional parameters for the parser
- * @return 0 if everything went fine, NON 0 if an error took place
- */
-int cmdline_parser_ext (int argc, char **argv,
-  struct gengetopt_args_info *args_info,
-  struct cmdline_parser_params *params);
-
-/**
- * Save the contents of the option struct into an already open FILE stream.
- * @param outfile the stream where to dump options
- * @param args_info the option struct to dump
- * @return 0 if everything went fine, NON 0 if an error took place
- */
-int cmdline_parser_dump(FILE *outfile,
-  struct gengetopt_args_info *args_info);
-
-/**
- * Save the contents of the option struct into a (text) file.
- * This file can be read by the config file parser (if generated by gengetopt)
- * @param filename the file where to save
- * @param args_info the option struct to save
- * @return 0 if everything went fine, NON 0 if an error took place
- */
-int cmdline_parser_file_save(const char *filename,
-  struct gengetopt_args_info *args_info);
-
-/**
- * Print the help
- */
-void cmdline_parser_print_help(void);
-/**
- * Print the version
- */
-void cmdline_parser_print_version(void);
-
-/**
- * Initializes all the fields a cmdline_parser_params structure 
- * to their default values
- * @param params the structure to initialize
- */
-void cmdline_parser_params_init(struct cmdline_parser_params *params);
-
-/**
- * Allocates dynamically a cmdline_parser_params structure and initializes
- * all its fields to their default values
- * @return the created and initialized cmdline_parser_params structure
- */
-struct cmdline_parser_params *cmdline_parser_params_create(void);
-
-/**
- * Initializes the passed gengetopt_args_info structure's fields
- * (also set default values for options that have a default)
- * @param args_info the structure to initialize
- */
-void cmdline_parser_init (struct gengetopt_args_info *args_info);
-/**
- * Deallocates the string fields of the gengetopt_args_info structure
- * (but does not deallocate the structure itself)
- * @param args_info the structure to deallocate
- */
-void cmdline_parser_free (struct gengetopt_args_info *args_info);
-
-/**
- * Checks that all the required options were specified
- * @param args_info the structure to check
- * @param prog_name the name of the program that will be used to print
- *   possible errors
- * @return
- */
-int cmdline_parser_required (struct gengetopt_args_info *args_info,
-  const char *prog_name);
-
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-#endif /* CMDLINE_H */
diff --git a/LumiBlock/LumiBlockComps/src/components/LumiBlockComps_entries.cxx b/LumiBlock/LumiBlockComps/src/components/LumiBlockComps_entries.cxx
index c8588370184df3cd6a0c4f2cf39d399f738fb90e..bef79cc8c10d8f0a67738ddc6cae9c5d49d8416b 100755
--- a/LumiBlock/LumiBlockComps/src/components/LumiBlockComps_entries.cxx
+++ b/LumiBlock/LumiBlockComps/src/components/LumiBlockComps_entries.cxx
@@ -1,16 +1,16 @@
+#include "GaudiKernel/DeclareFactoryEntries.h"
 #include "LumiBlockComps/CreateLumiBlockCollectionFromFile.h"
-#include "LumiBlockComps/CreateAANTFromLumiBlockCollection.h"
+//#include "LumiBlockComps/CreateAANTFromLumiBlockCollection.h"
 #include "LumiBlockComps/LumiBlockMetaDataTool.h"
 #include "LumiBlockComps/LumiBlockMuTool.h"
-#include "../LuminosityTool.h"
-#include "../TrigLivefractionTool.h"
-#include "../LumiCalcSvc.h"
-#include "GaudiKernel/DeclareFactoryEntries.h"
+#include "LumiBlockComps/LuminosityTool.h"
+#include "LumiBlockComps/TrigLivefractionTool.h"
+#include "LumiBlockComps/LumiCalcSvc.h"
 #include "LumiBlockComps/LumiBlockMuWriter.h"
 #include "LumiBlockComps/LumiBlockTester.h"
 
 DECLARE_ALGORITHM_FACTORY( CreateLumiBlockCollectionFromFile )
-DECLARE_ALGORITHM_FACTORY( CreateAANTFromLumiBlockCollection )
+//DECLARE_ALGORITHM_FACTORY( CreateAANTFromLumiBlockCollection )
 DECLARE_ALGORITHM_FACTORY( LumiBlockMuWriter )
 DECLARE_ALGORITHM_FACTORY( LumiBlockTester )
 DECLARE_TOOL_FACTORY( LumiBlockMetaDataTool )
@@ -21,7 +21,7 @@ DECLARE_SERVICE_FACTORY( LumiCalcSvc )
 
 DECLARE_FACTORY_ENTRIES(LumiBlockComps) {
   DECLARE_ALGORITHM( CreateLumiBlockCollectionFromFile );
-  DECLARE_ALGORITHM( CreateAANTFromLumiBlockCollection );
+  //  DECLARE_ALGORITHM( CreateAANTFromLumiBlockCollection );
   DECLARE_ALGORITHM( LumiBlockMuWriter );
   DECLARE_ALGORITHM( LumiBlockTester );
   DECLARE_ALGTOOL( LumiBlockMetaDataTool);
diff --git a/LumiBlock/LumiBlockComps/src/iLumiCalc.cxx b/LumiBlock/LumiBlockComps/src/iLumiCalc.cxx
deleted file mode 100644
index 0e4883c2976420f6c1a0625148910f3d23b6075a..0000000000000000000000000000000000000000
--- a/LumiBlock/LumiBlockComps/src/iLumiCalc.cxx
+++ /dev/null
@@ -1,724 +0,0 @@
-/*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
-*/
-
-#include "iLumiCalc.h"
-#include <typeinfo>
-#include <TKey.h>
-#include "CollectionBase/CollectionService.h"
-#include "CollectionBase/ICollection.h"
-#include "CollectionBase/ICollectionMetadata.h"
-
-#include "TTree.h"
-#include "TList.h"
-#include "TObjString.h"
-#include "TString.h"
-#include "Cintex/Cintex.h"
-
-#include <list>
-
-// ToDo: make this whole code in
-//       object oriented way...
-
-//______________________________________________________________________________
-int main(int argc, char * argv[]){
-
-  if (argc == 1)print_usage();
-
-  // enable cintex for proper stl functioning in combo with ROOT
-  ROOT::Cintex::Cintex::Enable();
-
-  // schedule for time info 
-  TStopwatch timer;
-  timer.Start();
-
-  // Parse command-line options
-  // ==========================
-
-  gengetopt_args_info args_info;
-  cmdline_parser (argc, argv, &args_info);
-
-  // Output Level
-  bool m_verbose = args_info.verbose_flag;
-  bool m_quiet = args_info.quiet_flag;
-  if (m_verbose && m_quiet) {
-    m_logger << Root::kWARNING << "Can't specify verbose and quiet, using verbose" << Root::GEndl;
-    m_quiet = false;
-  }
-
-  if (m_verbose) Root::TMsgLogger::SetMinLevel(Root::kDEBUG);
-  if (m_quiet) Root::TMsgLogger::SetMinLevel(Root::kWARNING);
-
-  // Other flags
-  bool m_makeplots = args_info.plots_flag;
-  bool m_collisionlists = args_info.xml_collisionlist_flag;
-
-  // parse for any output xml file name
-  m_xmloutfile = "";
-  if(args_info.xml_out_given){
-    m_xmloutfile = args_info.xml_out_arg;
-  }
-
-  //
-  // Parameters to control luminosty calculation
-  // ===========================================
-
-  float m_scalel1trigrate = float(args_info.scale_lumi_arg); // = 1 by default
-  if (m_scalel1trigrate != 1.) {
-    m_logger << Root::kWARNING << "Luminoisty scaled by factor: " << m_scalel1trigrate << Root::GEndl;
-  }
-
-  // Use online folder
-  bool m_online = args_info.online_flag;
-  if (m_online) {
-    m_logger << Root::kINFO << "Luminosity read from online folders" << Root::GEndl;
-  }
-
-  // Luminosity tag
-  std::string m_lumitag = args_info.lumitag_arg;
-  if (m_online) {
-    m_logger << Root::kWARNING << "Lumitag: " << m_lumitag << " ignored due to --online " << Root::GEndl;
-  } else {
-    m_logger << Root::kINFO << "Lumitag: " << m_lumitag << Root::GEndl;
-  }
-
-  // LAr noise bursts
-  bool m_lar = args_info.lar_flag;
-  std::string m_lartag = args_info.lartag_arg;
-  if (m_lar) {
-    m_logger << Root::kINFO << "LAr noise burst inefficiency will be calculated from " << m_lartag << Root::GEndl;
-  }
-
-  // Online Beamspot validity
-  bool m_beamspot = args_info.beamspot_flag;
-  std::string m_beamspottag = args_info.beamspottag_arg;
-  if (m_beamspot) {
-    m_logger << Root::kINFO << "Livetime will include online beamspot validity requirement from " << m_beamspottag << Root::GEndl;
-  }
-
-  // Luminosity channel
-  // ==================
-
-  std::string m_lumimethod;
-  int m_lumichannel = -1;
-
-  // Check for online exceptions
-  if (m_online && args_info.lumimethod_given){
-    m_logger << Root::kERROR << "Sorry, the online database doesn't have luminosity method names, use --lumichannel instead!" << Root::GEndl;
-    exit(-1);
-  }
-
-  if (args_info.lumimethod_given && args_info.lumichannel_given == 0) {
-    m_lumimethod  =     args_info.lumimethod_arg;
-    m_logger << Root::kINFO << "Lumimethod: " << m_lumimethod << Root::GEndl;
-  } else if (args_info.lumimethod_given == 0 && args_info.lumichannel_given) {
-    m_lumichannel = args_info.lumichannel_arg;
-    m_logger << Root::kINFO << "Lumichannel: " << m_lumichannel << Root::GEndl;
-  } else if (args_info.lumimethod_given && args_info.lumichannel_given) {
-    m_lumichannel = args_info.lumichannel_arg;
-    m_logger << Root::kINFO << "Both lumimethod and lumichannel is given, defaulting to Lumichannel: " << m_lumichannel << Root::GEndl;
-  } else if (args_info.lumimethod_given == 0 && args_info.lumichannel_given == 0) {
-    if (m_online) {
-      m_lumichannel = args_info.lumichannel_arg;
-      m_logger << Root::kINFO << "No lumimethod or lumichannel is given, defaulting to Lumichannel: " << m_lumichannel << Root::GEndl;
-    } else {
-      m_lumimethod = args_info.lumimethod_arg;
-      m_logger << Root::kINFO << "No lumimethod or lumichannel is given, defaulting to Lumimethod: " << m_lumimethod << Root::GEndl;
-    }
-  }
-
-
-  // Handle triggers
-  // ===============
-  if(args_info.trigger_given == 0) {
-    m_logger << Root::kINFO << "No trigger specified, proceeding with --trigger=None" << Root::GEndl;
-    m_triggerchain.push_back("None");
-  } else {
-    if (args_info.trigger_given > 1) {
-      m_logger << Root::kINFO << "Processing Triggers: ";
-    } else {
-      m_logger << Root::kINFO << "Processing Trigger: ";
-    }
-
-    for(unsigned int i = 0; i < args_info.trigger_given; ++i){
-      m_triggerchain.push_back(args_info.trigger_arg[i]);
-      m_logger << Root::kINFO << args_info.trigger_arg[i] << ", ";
-    }
-    m_logger << Root::GEndl;
-  }
-
-  // Livetime triggers
-  // =================
-  bool m_uselivetrigger = false;
-  m_livetrigger = args_info.livetrigger_arg;   // Default if not specified on command line
-
-  if (args_info.livetrigger_given || !args_info.trigger_given) {
-    // Either livetime trigger specified, or no prescale triggers specified
-    m_uselivetrigger = true;
-    m_logger << Root::kINFO << "Trigger used for livetime: " << m_livetrigger << Root::GEndl;
-  } else {
-    // Prescale not specified AND trigger list given 
-    m_logger << Root::kINFO << "Prescale trigger chains will be used for livetime " << Root::GEndl;
-  }
-
-
-  // Parse the run number list
-  // =========================
-
-  // Run list has pair of first, last allowed run inclusive
-  std::list<std::pair<unsigned int, unsigned int> > runList;
-  runList.clear();
-
-  // Comma-separated lists already get split by options parser.  Just need to look for ranges here.
-  for (unsigned int i=0; i<args_info.runnumber_given; i++) {
-
-    // Split by hyphens to find run range
-    std::string full(args_info.runnumber_arg[i]);
-
-    size_t found = full.find('-');
-
-    unsigned int val1, val2;
-    if (found != std::string::npos) {
-      val1 = atoi(full.substr(0, found).c_str());
-      val2 = atoi(full.substr(found+1, std::string::npos).c_str());
-    } else {
-      val1 = atoi(full.c_str());
-      val2 = val1;
-    }
-    if (val1 == 0) val1 = minrunnum; // Set to min run number
-    if (val2 == 0) val2 = maxrunnum; // Set to max run number
-
-    // std::cout << "Parsed [" << full << "] into (" << val1 << ", " << val2 << ")" << std::endl;
-    runList.push_back( std::pair<unsigned int, unsigned int>(val1, val2) );
-  }
-
-  // std::cout << "Parsed Run List:" << std::endl;
-  // for (std::list<std::pair<unsigned int, unsigned int> >::iterator it = runList.begin(); it != runList.end(); it++)
-  // std::cout << it->first << " " << it->second << std::endl;
-
-  // Now determine the input data source
-  // ===================================
-
-  // what shall be the resource for LumiBlockCollection
-  unsigned int runtype = 0; // 0 - no input file --> COOL, 1 - TAG input file, 2 - AOD input file, 3 - XML input file, 4 - ROOT input file
-
-  // TAG File
-  //============================================
-  if(args_info.tag_given > 0 && args_info.xml_given == 0 && args_info.root_given == 0){
-    runtype = 1;
-    std::cout << args_info.tag_given << " TAG file(s) is given..." << std::endl;
-    for(unsigned int i = 0; i < args_info.tag_given; ++i){
-      tagfile.push_back(args_info.tag_arg[i]);
-    }
-    // Try to see if file(s) exist
-    for(std::vector<std::string>::iterator it = tagfile.begin(); it != tagfile.end(); ++it){
-      if(!FileExists((*it))){
-	m_logger << Root::kWARNING << "Problem: file ["<< (*it)  <<"] may not exist.  Will try anyways..." << Root::GEndl;
-      }
-    }
-    //std::cout << "RunType: " << runtype << std::endl; 
-
-  }
-
-  // XML File
-  //============================================
-  if(args_info.tag_given == 0 && args_info.xml_given > 0 && args_info.root_given == 0){
-    runtype = 3;
-    for(unsigned int i = 0; i < args_info.xml_given; ++i){
-      xmlfile.push_back(args_info.xml_arg[i]);
-    }
-    // Try to see if file(s) exist
-    for(std::vector<std::string>::iterator it = xmlfile.begin(); it != xmlfile.end(); ++it){
-      if(! FileExists((*it))){
-	m_logger << Root::kWARNING << "Problem: file ["<< (*it)  <<"] may not exist.  Will try anyways..." << Root::GEndl;
-      }
-    }
-  //std::cout << "RunType: " << runtype << std::endl;
-  }
-
-  // ROOT File -- ttree attached mode
-  //============================================
-  if((args_info.root_given >0 || args_info.tree_given > 0) && args_info.d3pd_dir_given == 0 && args_info.xml_given == 0 && args_info.tag_given == 0){
-    if((args_info.root_given == 0 && args_info.tree_given > 0) || (args_info.root_given > 0 && args_info.tree_given == 0 )){
-      m_logger << Root::kERROR << "Please provide BOTH --root=\"myfile.root\" AND --tree=\"mytreename\" OR --d3pd_dir=\"mydirname\" options " << Root::GEndl;
-      exit(-1);
-    }
-    
-    runtype = 4;
-    for(unsigned int i = 0; i < args_info.root_given; ++i){
-      rootfile.push_back(args_info.root_arg[i]);
-    }
-    if(args_info.tree_given){
-      m_treename = args_info.tree_arg;
-    }else{
-      m_logger << Root::kERROR << "In Root file mode Tree name (--d3p_dir=\"mytreename\") must also be provided" << Root::GEndl;
-    }
-    for(std::vector<std::string>::iterator it = rootfile.begin(); it != rootfile.end(); ++it){
-      if(!FileExists((*it))){
-	m_logger << Root::kWARNING << "Problem: file ["<< (*it)  <<"] may not exist.  Will try anyways..." << Root::GEndl;
-      }
-    }
-  }
-
-  // ROOT File -- d3pd TDirectory mode
-  //============================================
-  if((args_info.root_given >0 || args_info.d3pd_dir_given > 0) && args_info.tree_given == 0 && args_info.xml_given == 0 && args_info.tag_given == 0){
-    if((args_info.root_given == 0 && args_info.d3pd_dir_given > 0) || (args_info.root_given > 0 && args_info.d3pd_dir_given == 0 )){
-      m_logger << Root::kERROR << "Please provide BOTH --root=\"myfile.root\" AND --d3pd_dir=\"myd3pddirname\" options" << Root::GEndl;
-      exit(-1);
-    }
-
-    runtype = 5;
-    for(unsigned int i = 0; i < args_info.root_given; ++i){
-      rootfile.push_back(args_info.root_arg[i]);
-    }
-    if(args_info.d3pd_dir_given){
-      m_d3pddirname = args_info.d3pd_dir_arg;
-    }else{
-      m_logger << Root::kWARNING << "In D3PD Root file mode Directory name (--d3pd_dir=\"mylumidir\") must also be provided" << Root::GEndl;
-      m_logger << Root::kWARNING << "Ommitted, using default name \"Lumi\"" << Root::GEndl;
-      m_d3pddirname= "Lumi";
-    }
-
-    for(std::vector<std::string>::iterator it = rootfile.begin(); it != rootfile.end(); ++it){
-      if(!FileExists((*it))){
-	m_logger << Root::kWARNING << "Problem: file ["<< (*it)  <<"] may not exist.  Will try anyways..." << Root::GEndl;
-      }
-    }
-  }
-
-  // Full command line mode
-  //============================================
-  if (runtype == 0) {
-
-    // Nothing else specified, try run numbers
-    if (!args_info.runnumber_given) {
-      m_logger << Root::kERROR << "No input data specified!" << Root::GEndl;
-      exit(-1);
-    }
-
-    std::list<std::pair<unsigned int, unsigned int> >::iterator itr = runList.begin();
-
-    // Decode run IOV pairs
-    for (; itr != runList.end(); itr++) {
-      // Dont allow open-ended IOVs
-      if ((itr->first == minrunnum) || (itr->second == maxrunnum)) {
-	m_logger << Root::kERROR << "Can't use open-ended run ranges to specify sample!" << Root::GEndl;
-	exit(-1);
-      }
-
-      for (unsigned int runnum = itr->first; runnum <= itr->second; runnum++) 
-	runnumber.push_back(runnum);
-
-    }
-
-    // Also add in lumi block ranges
-    if (args_info.lbstart_given ==0) {
-      for (unsigned int i=0; i<runnumber.size(); i++) {
-	lbstart.push_back(minlbstart);
-      }
-    } else {
-      for (unsigned int i=0; i<args_info.lbstart_given; i++) {
-	lbstart.push_back(args_info.lbstart_arg[i]);
-      }
-    }
-
-    if (args_info.lbend_given ==0) {
-      for (unsigned int i=0; i<runnumber.size(); i++) {
-	lbend.push_back(maxlbend);
-      }
-    } else {
-      for (unsigned int i=0; i<args_info.lbend_given; i++) {
-	lbend.push_back(args_info.lbend_arg[i]);
-      }
-    }
-
-  }
-
-
-  // Finish parsing
-  //============================================
-  cmdline_parser_free (&args_info); /* release allocated memory */
-
-
-  //==========================================================================
-  // Set up LumiBlockCollection for the different scenarios
-  std::vector< LumiBlockCollection* > iovcVec;
-  std::vector< std::vector<std::string> > m_triggerchainVec;
-  Root::TGRLCollection m_grlcollection;
-  LumiBlockCollectionConverter m_converter;
-  TString m_version("30"); // [0-10): ATLRunQuery, [10-20): ntuple production, [20-30): xml merging, [30-40): LumiCalc
-
-  //==========================================================================
-  // User defined IOVRange in command line
-  if (runtype == 0) {
-
-    m_logger << Root::kINFO << "Proceeding with command-line run list" << Root::GEndl;
-    if (lbstart.size() != lbend.size()) {
-      m_logger << Root::kERROR << "number of lbstart and lbend values must match!" << Root::GEndl;
-      exit(-1); 
-    }
-
-    if (runnumber.size() > 1 && (runnumber.size() != lbstart.size())) {
-      m_logger << Root::kERROR << "number of lbstart and lbend values must match number of runs with multiple runs specified!" << Root::GEndl;
-      exit(-1);
-    }
-
-    /*
-    std::cout << "runlist length: " << runnumber.size() << std::endl;
-    for (unsigned int i=0; i<runnumber.size(); i++) {
-      std::cout << runnumber[i] << std::endl;
-    }
-    */
-
-    uint32_t _lbstart;
-    uint32_t _lbend;
-
-    LumiBlockCollection* iovc = new LumiBlockCollection();
-    
-    std::vector<uint32_t>::iterator itstart;
-    std::vector<uint32_t>::iterator itend;
-    std::vector<uint32_t>::iterator itrun;
-
-    if (runnumber.size() == 1) {
-
-	m_logger << Root::kINFO << "Runnumber [" << runnumber[0] <<  "]" << Root::GEndl;
-	for(itstart = lbstart.begin(), itend = lbend.begin(); 
-	    itstart != lbstart.end() && itend != lbend.end(); ++itstart,++itend) {
-	  _lbstart = (*itstart);
-	  _lbend = (*itend);
-	  m_logger << Root::kINFO << "lbstart-lbend [" << _lbstart << "-" << _lbend << "]" << Root::GEndl; 
-	  if (_lbstart > _lbend) {
-	    m_logger << Root::kERROR << "lbstart > lbend! Should be: lbstart < = lbend" << Root::GEndl;
-	    exit(-1);
-	  } else {
-	    iovc->push_back(new IOVRange(IOVTime(runnumber[0], _lbstart), IOVTime(runnumber[0], _lbend)));
-	  }
-	}
-
-    } else if (runnumber.size() > 1) {
-
-      for(itrun = runnumber.begin(), itstart = lbstart.begin(), itend = lbend.begin(); 
-	  itrun != runnumber.end() && itstart != lbstart.end() && itend != lbend.end();
-	  ++itrun, ++itstart, ++itend) {
-	m_logger << Root::kINFO << "Runnumbers [" << *itrun <<  "]" << Root::GEndl;
-	m_logger << Root::kINFO << "lbstart-lbend [" << *itstart << "-" << *itend << "]" << Root::GEndl; 
-	iovc->push_back(new IOVRange(IOVTime(*itrun, *itstart), IOVTime(*itrun, *itend)));
-      }
-    }
-
-    iovcVec.push_back(iovc); // take over iovc for usage below
-    m_triggerchainVec.push_back(m_triggerchain); // cmd-line triggerchain
-    std::map<TString,TString> m_metadata;
-    for (unsigned int j=0; j<m_triggerchain.size(); ++j)
-      m_metadata[Form("TriggerName%d",j)] = TString(m_triggerchain[j]);
-    m_grlcollection.push_back( *m_converter.GetGRLObject(*iovc,m_metadata,m_version) );
-  }
-  
-
-  //==========================================================================
-  // Fetch up LumiBlockCollection from input TAG file
-  if (runtype == 1) {
-    // open TAG files to build LumiBlockCollection
-    m_logger << Root::kINFO << "Being in TAG file mode..." << Root::GEndl;
-
-    Root::TGoodRunsListReader m_reader;
-    std::string connection ="";
-    std::string type = "RootCollection";
-    bool readOnly(true);
-    for(std::vector<std::string>::iterator it = tagfile.begin(); it != tagfile.end(); ++it){
-      m_logger << Root::kINFO << "Processing file: <" << (*it) << ">" <<  Root::GEndl;
-      int n = (*it).find(".root");
-      std::string tagfilename =  (*it).substr(0,n);
-
-      // get Value for a Key
-      pool::CollectionService collectionService;
-      pool::ICollection* collection = collectionService.handle(tagfilename, type, connection, readOnly);
-      if(collection == NULL) {
-         m_logger << Root::kERROR << "ICollection is NULL, exiting... " << Root::GEndl;
-         exit(-1);
-      }
-
-      // MB : Reading incomplete LBs with tag. Request from Tulay
-      const char* value = collection->metadata().getValueForKey("OutputLumirange");
-      if(value == NULL) {         
-         m_logger << Root::kERROR << "The collection has no such key of OutputLumirange in metadata, try with OutputIncompleteLumirange key" << Root::GEndl;
-         value = collection->metadata().getValueForKey("OutputIncompleteLumirange");
-         if (value != NULL) m_logger << Root::kINFO << "OutputIncompleteLumirange key is OK, reading the value..."  << Root::GEndl;
-         else exit(-1);
-      }
-
-      if(m_verbose == true) m_logger << Root::kINFO << "Value :  " << value << Root::GEndl;
-      // add xml string to TGoodRunsListReader. Sort out strings below
-      m_reader.AddXMLString(value);
-    }
-    // do sorting of all grl objects
-    m_reader.Interpret();
-    m_grlcollection = m_reader.GetMergedGRLCollection();
-    
-    for (unsigned int j=0; j<m_grlcollection.size(); ++j) {
-      iovcVec.push_back( m_converter.GetLumiBlockCollection(m_grlcollection[j]) );
-      // default: trigger names taken from xml metadata. Overwrite any existing cmd-line triggers.
-      if ( m_grlcollection[j].HasTriggerInfo() ) {
-        m_triggerchainVec.push_back(m_grlcollection[j].GetTriggerList()); // use existing trigger names
-        if (!m_triggerchain.empty())
-          m_logger << Root::kWARNING << "Input goodruns-list(s) <" << m_grlcollection[j].GetName() 
-                   << "> already contain trigger names. Cmd-line triggers are ignored!" << Root::GEndl;
-      } else { // use cmdline trigger names
-        m_triggerchainVec.push_back(m_triggerchain) ;
-        for (unsigned int k=0; k<m_triggerchain.size(); ++k)
-          m_grlcollection[j].AddMetaData( Form("TriggerName%d",k),TString(m_triggerchain[k]) );
-      }
-    }
-  }
-
-  //==========================================================================
-  // Fetch up LumiBlockCollection from input XML file
-  if(runtype == 3){
-    // open XML files to build LumiBlockCollection
-    m_logger << Root::kINFO << "Being in XML file mode..." << Root::GEndl;
-    Root::TGoodRunsListReader m_reader;
-    // looping over XML files
-    for(std::vector<std::string>::iterator it = xmlfile.begin(); it != xmlfile.end(); ++it){
-      m_logger << Root::kINFO << "Processing file: <" << (*it) << ">" << Root::GEndl;
-      m_reader.AddXMLFile(*it);
-    }
-    m_reader.Interpret();
-    m_grlcollection = m_reader.GetMergedGRLCollection();
-
-    for (unsigned int j=0; j<m_grlcollection.size(); ++j) {
-      iovcVec.push_back( m_converter.GetLumiBlockCollection(m_grlcollection[j]) );
-      // default: trigger names taken from xml metadata. Overwrite any existing cmd-line triggers.
-      if ( m_grlcollection[j].HasTriggerInfo() ) {
-        m_triggerchainVec.push_back(m_grlcollection[j].GetTriggerList()); // use existing trigger names
-        if (!m_triggerchain.empty())
-          m_logger << Root::kWARNING << "Input goodruns-list(s) <" << m_grlcollection[j].GetName() 
-                   << "> already contain trigger names. Cmd-line triggers are ignored!" << Root::GEndl;
-      } else { // use cmdline trigger names
-        m_triggerchainVec.push_back(m_triggerchain) ;
-        for (unsigned int k=0; k<m_triggerchain.size(); ++k)
-          m_grlcollection[j].AddMetaData( Form("TriggerName%d",k),TString(m_triggerchain[k]) );
-      }
-    }
-  }
-
-
-  //==========================================================================
-  // Fetch up LumiBlockCollection from input ROOT files - Tree mode
-  if(runtype == 4){
-    // open ntuples to fetch xmlstrings
-    m_logger << Root::kINFO << "Being in ROOT ntuple file mode..." << Root::GEndl;
-    
-    Root::TGoodRunsListReader m_reader;
-    
-    for(std::vector<std::string>::iterator it = rootfile.begin(); it != rootfile.end(); ++it){
-      m_logger << Root::kINFO << "Processing root file: <" << (*it) << ">" <<  Root::GEndl;
-      std::string filename = (*it);
-      TFile* file = TFile::Open(filename.c_str());
-      TTree * tree = NULL;
-      TList * list = NULL;
-      tree = dynamic_cast<TTree*>(file->Get(m_treename.c_str()));
-      if(tree == 0){
-	m_logger << Root::kERROR << "Tree: " << m_treename << " doesn't exist in file " << filename << Root::GEndl;
-	exit(-1);
-      }else{
-	list = tree->GetUserInfo() ;
-	
-	// add xml string to TGoodRunsListReader. Sort out strings below
-	for(int j=0; j<list->GetEntries();++j) {
-	  TObjString* objstr = dynamic_cast<TObjString*>(list->At(j));
-	  if ((objstr==0)) continue;
-	  if ( objstr->GetString().BeginsWith("<?xml version=\"1.0\"?") &&
-	       objstr->GetString().Contains("DOCTYPE LumiRangeCollection") ) // xml identifier
-	    m_reader.AddXMLString(objstr->GetString());
-	}
-      }
-      file->Close();
-    }
-
-    // do sorting of all grl objects
-    m_reader.Interpret();
-    m_grlcollection = m_reader.GetMergedGRLCollection();
-    
-    for (unsigned int j=0; j<m_grlcollection.size(); ++j) {
-      iovcVec.push_back( m_converter.GetLumiBlockCollection(m_grlcollection[j]) );
-      // default: trigger names taken from xml metadata. Overwrite any existing cmd-line triggers.
-      if ( m_grlcollection[j].HasTriggerInfo() ) {
-	m_triggerchainVec.push_back(m_grlcollection[j].GetTriggerList()); // use existing trigger names
-	if (!m_triggerchain.empty())
-	  m_logger << Root::kWARNING << "Input goodruns-list(s) <" << m_grlcollection[j].GetName()
-		   << "> already contain trigger names. Cmd-line triggers are ignored!" << Root::GEndl;
-      } else { // use cmdline trigger names
-	m_triggerchainVec.push_back(m_triggerchain) ;
-	for (unsigned int k=0; k<m_triggerchain.size(); ++k)
-	  m_grlcollection[j].AddMetaData( Form("TriggerName%d",k),TString(m_triggerchain[k]) );
-      }
-    }
-  }
-  
-  //==========================================================================
-  // Fetch up LumiBlockCollection from input ROOT files - D3PD mode
-  if(runtype == 5){
-    // open ntuples to fetch xmlstrings
-    m_logger << Root::kINFO << "Being in ROOT D3PD ntuple file mode..." << Root::GEndl;
-
-    Root::TGoodRunsListReader m_reader;
-
-    for(std::vector<std::string>::iterator it = rootfile.begin(); it != rootfile.end(); ++it){
-      m_logger << Root::kINFO << "Processing root file: <" << (*it) << ">" <<  Root::GEndl;
-      std::string filename = (*it);
-      TList* list = NULL;
-      TFile* file = TFile::Open(filename.c_str()); 
-      TDirectoryFile * dir = NULL;
-      m_logger << Root::kINFO << "Using Directory name: " << m_d3pddirname.c_str() << Root::GEndl;
-      dir = dynamic_cast<TDirectoryFile*>(file->GetDirectory(m_d3pddirname.c_str()));
-      if(!dir){
-	m_logger << Root::kERROR << "Directory [" << m_d3pddirname << "] doesn't exist in file " << filename << Root::GEndl;
-	exit(-1);
-      }else{
-        TObjString* objstr = 0;
-        std::map<TString,int> keymap;
-	list = dir->GetListOfKeys(); 
-	// add xml string to TGoodRunsListReader. Sort out strings below
-	for(int j=0; j<list->GetEntries();j++) {
-          if ( keymap.find(list->At(j)->GetName())==keymap.end() ) { keymap[list->At(j)->GetName()] = 1; } 
-          else { keymap[list->At(j)->GetName()] = keymap[list->At(j)->GetName()]+1; }
-          if(m_verbose)m_logger << Root::kINFO << "Found obj key: \"" << Form("%s;%d",list->At(j)->GetName(),keymap[list->At(j)->GetName()]) << "\"" << Root::GEndl;
-	  objstr = dynamic_cast<TObjString*>(dir->Get( Form("%s;%d",list->At(j)->GetName(),keymap[list->At(j)->GetName()]) )); 
-	  if (objstr!=0){
-	    if(m_verbose)m_logger << Root::kINFO << "with obj: " << objstr->GetString() << Root::GEndl;
-	    if ( objstr->GetString().BeginsWith("<?xml version=\"1.0\"?") &&
-		 objstr->GetString().Contains("DOCTYPE LumiRangeCollection") ){ // xml identifier
-	      m_reader.AddXMLString(objstr->GetString()); 
-	    }else{
-	      m_logger << Root::kERROR << "XML string is not in expected format: " << objstr->GetString() << ". Skipped." << Root::GEndl;
-	      //exit(-1);
-	    }
-	  }else{
-	    m_logger << Root::kERROR << "No obj found with key \"" << list->At(j)->GetName() << "\"" << Root::GEndl;
-	    exit(-1);
-	  }
-	}// end for cycle
-      }
-      file->Close();
-    }
-    // do sorting of all grl objects
-
-    m_reader.Interpret();
-    m_grlcollection = m_reader.GetMergedGRLCollection();
-    for (unsigned int j=0; j<m_grlcollection.size(); ++j) {
-      iovcVec.push_back( m_converter.GetLumiBlockCollection(m_grlcollection[j]) );
-      // default: trigger names taken from xml metadata. Overwrite any existing cmd-line triggers.
-      if ( m_grlcollection[j].HasTriggerInfo() ) {
-        m_triggerchainVec.push_back(m_grlcollection[j].GetTriggerList()); // use existing trigger names
-        if (!m_triggerchain.empty())
-          m_logger << Root::kWARNING << "Input goodruns-list(s) <" << m_grlcollection[j].GetName() 
-                   << "> already contain trigger names. Cmd-line triggers are ignored!" << Root::GEndl;
-      } else { // use cmdline trigger names
-        m_triggerchainVec.push_back(m_triggerchain) ;
-        for (unsigned int k=0; k<m_triggerchain.size(); ++k)
-          m_grlcollection[j].AddMetaData( Form("TriggerName%d",k),TString(m_triggerchain[k]) );
-      }
-    }
-  }
-
-  //==========================================================================
-  // Run Lumi Calculation is all is well - i.e. runtype != 999
-  if(runtype != 999){
-
-    // 
-    // If runtype != 0 and a run range has been specified, use that to filter runs
-    // ===========================================================================
-    if (runtype != 0 && runList.size() > 0) {
-      std::vector<LumiBlockCollection*>::iterator iovIt = iovcVec.begin();
-      // std::vector<std::vector<std::string> >::iterator trigIt = m_triggerchainVec.begin();
-
-      for (;iovIt != iovcVec.end(); iovIt++) {
-
-	LumiBlockCollection::iterator it = (*iovIt)->begin();
-	while (it != (*iovIt)->end()) {
-
-	  IOVRange * iovr = *it;
-	  unsigned int runnum = iovr->start().run();
-
-	  bool found = false;
-	  std::list<std::pair<unsigned int, unsigned int> >::iterator runIt = runList.begin();
-	  for (; runIt != runList.end(); runIt++) {
-	    if (runnum < runIt->first) continue;
-	    if (runnum > runIt->second) continue;
-	    found = true;
-	    break;
-	  }
-
-	  if (!found) {
-	    m_logger << Root::kDEBUG << "Skipping run " << iovr->start().run() << " LB [" << iovr->start().event() << "-" << iovr->stop().event() << "] due to command-line run range" << Root::GEndl;
-	    (*iovIt)->erase(it);
-
-	    it = (*iovIt)->begin();
-
-	  } else {
-	    // m_logger << Root::kDEBUG << "Keeping run  " << runnum << " due to command-line run range" << Root::GEndl;
-	    it++;
-	  }
-	}
-
-      }
-
-    }
-
-
-    LumiCalculator m_lumicalc;
-    for (unsigned int j=0; j<iovcVec.size(); ++j) {
-      LumiBlockCollection* iovc = iovcVec[j];
-      m_triggerchain = m_triggerchainVec[j];
-      
-      for(std::vector<std::string>::iterator it = m_triggerchain.begin(); it != m_triggerchain.end(); ++it){
-	if(!iovc->empty()){
-	  m_logger << Root::kINFO << "--------------------------------------------" << Root::GEndl;
-	  TTree tree("LumiMetaData","LumiMetaData");
-	  m_lumicalc.setTree(&tree);
-	  m_lumicalc.UseLumiTag(m_lumitag);
-	  if(m_lumimethod != "")m_lumicalc.UseLumiMethod(m_lumimethod);
-	  if(m_lumichannel != -1)m_lumicalc.UseLumiChannel(m_lumichannel);
-	  m_lumicalc.UseMC(false);
-	  m_lumicalc.UseOnlineLumi(m_online);
-	  m_lumicalc.Verbose(m_verbose);
-	  m_lumicalc.MakePlots(m_makeplots);
-	  m_lumicalc.MakeCollList(m_collisionlists);
-          m_lumicalc.ScaleL1TrigRate(m_scalel1trigrate);
-	  m_lumicalc.UseLiveTrigger(m_uselivetrigger, m_livetrigger);
-	  m_lumicalc.UseLArNoiseDB(m_lar, m_lartag);
-	  m_lumicalc.UseBeamspot(m_beamspot, m_beamspottag);
-	  m_lumicalc.IntegrateLumi(iovc, (*it));
-	  m_logger << Root::kINFO << "--------------------------------------------" << Root::GEndl;
-
-	  // Write out some summary information for 'quiet' mode
-	  if (m_quiet) {
-	    m_lumicalc.printSummary(std::cout);
-	  }
-	}
-      }
-    }
-
-    //==========================================================================
-    // write out complete xml file for all lb collections together
-    m_grlcollection.SetVersion(m_version);
-    if(!m_grlcollection.empty()){
-      TString xmlfile = "ilumicalc_merged_";
-      if (m_xmloutfile.empty()) {
-        if (m_grlcollection.size()==1) { xmlfile += m_grlcollection[0].GetSuggestedName() + ".xml"; }
-        else { xmlfile += "grls.xml"; }
-      } else { xmlfile = m_xmloutfile; }
-      m_converter.CreateXMLFile(m_grlcollection,xmlfile);
-    }
-  }
-
-  //==========================================================================
-  // Print timing info 
-  timer.Stop();
-  m_logger << Root::kINFO << "Real time: " << std::setw(5) << timer.RealTime() << " s" << Root::GEndl;
-  m_logger << Root::kINFO << "CPU time:  " << std::setw(5) << timer.CpuTime() << " s" << Root::GEndl;
-
-  return 0;
-
-}   
diff --git a/LumiBlock/LumiBlockComps/src/iLumiCalc.h b/LumiBlock/LumiBlockComps/src/iLumiCalc.h
deleted file mode 100644
index a42b9073856bf5033c9a57afbe6ab61626ada212..0000000000000000000000000000000000000000
--- a/LumiBlock/LumiBlockComps/src/iLumiCalc.h
+++ /dev/null
@@ -1,211 +0,0 @@
-/*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
-*/
-
-#include "cmdline.h"
-#include "LumiCalculator.h"
-#include "LumiBlockComps/CoolQuery.h"
-#include "LumiBlockComps/LumiBlockCollectionConverter.h"
-#include "GoodRunsLists/TGoodRunsListReader.h"
-#include "GoodRunsLists/TGoodRunsList.h"
-#include "GoodRunsLists/TGRLCollection.h"
-#include "GoodRunsLists/TMsgLogger.h"
-#include "DBDataModel/CollectionMetadata.h"
-#include <iomanip>
-#include <TROOT.h>
-#include <TStopwatch.h>
-#include <TString.h>
-#include <TFile.h>
-#include <TTree.h>
-#include <stdio.h>
-#include <sys/stat.h> 
-#include <sys/types.h>
-
-static std::vector<std::string> tagfile;
-static std::vector<std::string> aodfile;
-static std::vector<std::string> xmlfile;
-static std::vector<std::string> rootfile;
-static std::string m_treename = "tree";
-static std::string m_d3pddirname = "Lumi";
-static std::string m_xmloutfile = "out.xml";
-static std::vector<std::string> m_triggerchain;
-static std::string m_livetrigger;
-static Root::TMsgLogger m_logger( "iLumiCalc" );
-static std::vector<uint32_t> runnumber;
-static std::vector<uint32_t> lbstart;
-static std::vector<uint32_t> lbend;
-static uint32_t minlbstart = cool::ValidityKeyMin & 0xFFFFFFFF;
-static uint32_t maxlbend = (cool::ValidityKeyMax & 0xFFFFFFFF)/2;
-static uint32_t minrunnum = (cool::ValidityKeyMin >> 32);
-static uint32_t maxrunnum = (cool::ValidityKeyMax >> 32);
-
-//______________________________________________________________
-// Mini progress bar implementation, reduced version of
-// the one from TMVA/Timer class implementation
-class ProgressBar : public TStopwatch {
-
- public:
-  ProgressBar( Int_t, Int_t, const char * prefix = "" );
-  ~ProgressBar();
-  
-  void Reset();
-  void DrawProgressBar( Int_t );
-  TString SecToText( Double_t );
-  Double_t ElapsedSeconds();
-  TString GetElapsedTime();
-  TString GetLeftTime( Int_t );
-
-  Int_t   pbNbins; 
-  Int_t   Ncounts;
-  TString Prefix;
-
-};
-
-//_______________________________________________________________________
-ProgressBar::ProgressBar(Int_t ncounts, Int_t nbins, const char * prefix)
-  : pbNbins(nbins), Ncounts(ncounts), Prefix(TString(prefix))
-{
-  Reset();
-}
-
-//_______________________________________________________________________
-ProgressBar::~ProgressBar()
-{}
-
-//_______________________________________________________________________
-void ProgressBar::Reset() 
-{
-  TStopwatch::Start( kTRUE );
-}
-
-//_______________________________________________________________________
-Double_t ProgressBar::ElapsedSeconds() 
-{
-  // computes elapsed time in seconds
-  Double_t rt = TStopwatch::RealTime(); TStopwatch::Start( kFALSE );
-  return rt;
-}
-//_______________________________________________________________________
-
-TString ProgressBar::GetElapsedTime() 
-{
-  // returns string with elapsed time
-  return SecToText( ElapsedSeconds());
-}
-
-//_______________________________________________________________________
-TString ProgressBar::GetLeftTime( Int_t icounts ) 
-{
-  // returns pretty string with time left
-  Double_t leftTime = ( icounts <= 0 ? -1 :
-			icounts > Ncounts ? -1 :
-			Double_t(Ncounts - icounts)/Double_t(icounts)*ElapsedSeconds() );
-
-  return SecToText( leftTime );
-}
-
-//_______________________________________________________________________
-TString ProgressBar::SecToText(  Double_t seconds )
-{
-
-  TString out = "";
-  if (seconds <  0  ) out = "unknown";
-  else if (seconds <= 300) out = Form( "%i sec", Int_t(seconds) );
-  else {
-    if (seconds > 3600) {
-      Int_t h = Int_t(seconds/3600);
-      if (h <= 1) out = Form( "%i hr : ", h );
-      else        out = Form( "%i hrs : ", h );
-      
-      seconds = Int_t(seconds)%3600;
-    }
-    Int_t m = Int_t(seconds/60);
-    if (m <= 1) out += Form( "%i min", m );
-    else        out += Form( "%i mins", m );
-  }
-
-  return out;
-}
-
-//_______________________________________________________________________
-void ProgressBar::DrawProgressBar( Int_t i )
-{
-
-  // check for consistency:
-  if (i > Ncounts-1) i = Ncounts-1;
-  if (i < 0         ) i = 0;
-  Int_t ic = Int_t(Float_t(i)/Float_t(Ncounts)*pbNbins);
-  
-  std::clog << Prefix << " ";
-  
-  // re-print the actual bar
-  std::clog << "[";
-  for (Int_t it = 0; it<ic; it++){
-    std::clog << ">";
-  }
-  
-  for (Int_t it = ic+1; it<pbNbins; it++){
-    std::clog << " ";
-  }
-  std::clog << "]";
-
-  // print timing information
-  std::clog <<  "(" << Int_t((100*(i+1))/Float_t(Ncounts)) << "%" 
-	    << ", " << "time left: " << this->GetLeftTime( i ) << ") ";
-  std::clog << "\r" << std::flush;
-}
-
-
-//______________________________________________________________
-bool FileExists(std::string strFilename) { 
-  struct stat stFileInfo; 
-  bool blnReturn; 
-  int intStat; 
-
-  // Attempt to get the file attributes 
-  intStat = stat(strFilename.c_str(),&stFileInfo); 
-  if(intStat == 0) { 
-    // We were able to get the file attributes 
-    // so the file obviously exists. 
-
-
-    blnReturn = true; 
-  } else { 
-    // We were not able to get the file attributes. 
-    // This may mean that we don't have permission to 
-    // access the folder which contains this file. If you 
-    // need to do that level of checking, lookup the 
-    // return values of stat which will give you 
-    // more details on why stat failed. 
-    blnReturn = false; 
-  } 
-   
-  return(blnReturn); 
-}
-
-//______________________________________________________________
-void print_usage(){
-
-  std::cout << std::endl;
-  std::cout << " --->>> i L U M I C A L C . E X E <<<---"<< std::endl;
-  std::cout << std::endl;
-  std::cout << "iLumiCalc.exe: this c++ program calculates integrated luminosity" << std::endl ;
-  std::cout << "by looping over a list of lumiblocks, given a set of input options." << std::endl;
-  std::cout << "Input file can be either an xml file, or a TAG file." << std::endl;
-  std::cout << std::endl;
-  std::cout << "Type: iLumiCalc.exe --help for the complete list of options" << std::endl ;
-  std::cout << std::endl;
-  std::cout << "Further help: https://twiki.cern.ch/twiki/bin/view/Atlas/CoolLumiCalc"<< std::endl;
-  std::cout << std::endl;
-  exit(-1);
-
-}
-
-
-//______________________________________________________________
-void print_credits(){
-  std::cout << "ATLAS - A Toroidal LHC Aparatus" << std::endl;
-  exit(-1);
-}
-
-
diff --git a/LumiBlock/LumiBlockComps/src/iLumiCalc_flags.ggo b/LumiBlock/LumiBlockComps/src/iLumiCalc_flags.ggo
deleted file mode 100644
index a26dc6819ef9336f657220b510c46eb7c0688429..0000000000000000000000000000000000000000
--- a/LumiBlock/LumiBlockComps/src/iLumiCalc_flags.ggo
+++ /dev/null
@@ -1,102 +0,0 @@
-#
-# This file describes the command-line options for iLumiCalc.exe
-# This must be processed using gengetopt < iLumiCalc_flags.ggo before compiling.
-# 
-# The resulting cmdline.c file needs to be copied to cmdline.cxx
-# 
-# Name of your program
-package "iLumiCalc.exe" # don't use package if you're using automake
-# Version of your program
-version "00-00-00"   # don't use version if you're using automake
-
-
-# Description of options
-
-#section "The following flags are required"
-
-section "The following flags are optional"
-
-section "Flags to specify data sample"
-
-option  "runnumber"		r "Run number, range, or comma separated list, e.g. 177986-178109,179710" string optional multiple
-
-option  "lbstart"		- "LumiBlock number begin" int optional multiple
-
-option  "lbend"			- "LumiBlock number end" int optional multiple
-
-option  "xml"			x "Input XML file name"	string  optional multiple
-
-option  "xml_blacklist"		- "Input XML file of blacklist" string optional
-
-option  "tag" 			T "Input TAG file name"	string optional multiple
-
-option  "root"			- "Input ROOT file name" string optional multiple
-
-option  "tree"			- "Name of TTree in input ROOT file to which Lumi string is attached" string optional
-
-option  "d3pd_dir"		- "Name of TDirectory in input ROOT file where Lumi string is stored" string optional
-
-
-section "Flags to control luminosity calculation"
-
-# Option
-option  "lumitag"               - "Offline luminosity database tag" string default="OflLumi-8TeV-002" optional
-
-option  "online"		- "Use online luminosity estimates instead of offline database" flag off 
-
-option  "lumichannel"           - "Luminosity estimate method by value" int default="0" optional
-
-option  "lumimethod"            - "Luminosity estimate method by string" string default="ATLAS_PREFERRED" optional
-
-option  "trigger"		t "Trigger chain name used for prescale calculation" string optional multiple
-
-option  "livetrigger"		- "L1 Trigger used for livetime calculation" string default="L1_EM30" optional 
-
-option  "lar"                   - "Calculate LAr defect fraction" flag off 
-
-option 	"lartag"		- "LAr noise burst database tag" string default="LARBadChannelsOflEventVeto-UPD4-01" optional
-
-option 	"beamspot"		- "Require online beamspot valid in trigger livefraction" flag off
- 
-option 	"beamspottag"		- "Online beamspot database tag" string default="IndetBeamposOnl-HLT-UPD1-001-00" optional
-
-option  "scale_lumi"		- "Scale luminosity with a constant value" double default="1.0" optional	
-
-section "Flags to control output"
-
-option  "xml_out"               - "Output XML file name" string optional
-
-option  "xml_collisionlist"	- "Output XML file of lists of collision candidates" flag off
-
-option  "plots"  		- "Create some plots on demand" flag off 
-
-option  "verbose"               V "Verbose output level" flag off
-
-option  "quiet"                 - "Quiet output level" flag off
-
-############################################################
-# option  "my-opt"          m "Another integer option, \
-# this time the description of the option should be \"quite\" long to \
-# require wrapping... possibly more than one wrapping :-) \
-# especially if I\nrequire a line break"      int     optional
-#
-# option  "int-opt"         i "A int option"         int        yes
-# section "more involved options"
-#      sectiondesc="the following options\nare more complex"
-# text ""
-# 
-# option  "flag-opt"        - "A flag option"        flag       off
-# option  "funct-opt"       F "A function option"    optional
-#
-# section "last option section"
-# option  "long-opt"        - "A long option"        long       optional
-# option  "def-opt"         - "A string option with default"
-#     string default="Hello" optional
-# option  "enum-opt"         - "A string option with list of values"
-#     values="foo","bar","hello","bye" default="hello" optional
-# option  "secret"         S "hidden option will not appear in --help"
-#     int optional hidden
-# option  "dependant"         D
-#     "option that depends on str-opt" int optional dependon="str-opt"
-# text "\nAn ending text."
-     
\ No newline at end of file