From 6fbad42f119ce895b0368ea5831b0dea35be168c Mon Sep 17 00:00:00 2001
From: Eric Jansen <ejansen@cern.ch>
Date: Fri, 26 Mar 2010 22:21:46 +0100
Subject: [PATCH] Tagging EventDisplayFilters-00-03-04
 (EventDisplayFilters-00-03-04)

---
 .../EventDisplayFilters/FilterUsingMBTS.h     |  29 +++++
 .../FilterUsingMBTSTiming.h                   |  40 +++++++
 .../FilterUsingSpacePoints.h                  |  26 +++++
 graphics/EventDisplayFilters/cmt/requirements |  22 ++++
 .../python/PublicStreamFilter.py              |  77 +++++++++++++
 .../EventDisplayFilters/python/__init__.py    |   2 +
 .../share/MBTSTimingFilter_DefaultConfig.py   |  22 ++++
 .../share/MBTSTriggerFilter_DefaultConfig.py  |  23 ++++
 .../share/PublicStreamFilter_DefaultConfig.py |  15 +++
 .../SpacePointEventFilter_DefaultConfig.py    |  22 ++++
 .../src/FilterUsingMBTS.cxx                   | 106 ++++++++++++++++++
 .../src/FilterUsingMBTSTiming.cxx             | 101 +++++++++++++++++
 .../src/FilterUsingSpacePoints.cxx            |  75 +++++++++++++
 .../EventDisplayFilters_entries.cxx           |  11 ++
 .../components/EventDisplayFilters_load.cxx   |   2 +
 15 files changed, 573 insertions(+)
 create mode 100644 graphics/EventDisplayFilters/EventDisplayFilters/FilterUsingMBTS.h
 create mode 100644 graphics/EventDisplayFilters/EventDisplayFilters/FilterUsingMBTSTiming.h
 create mode 100644 graphics/EventDisplayFilters/EventDisplayFilters/FilterUsingSpacePoints.h
 create mode 100644 graphics/EventDisplayFilters/cmt/requirements
 create mode 100644 graphics/EventDisplayFilters/python/PublicStreamFilter.py
 create mode 100644 graphics/EventDisplayFilters/python/__init__.py
 create mode 100644 graphics/EventDisplayFilters/share/MBTSTimingFilter_DefaultConfig.py
 create mode 100644 graphics/EventDisplayFilters/share/MBTSTriggerFilter_DefaultConfig.py
 create mode 100644 graphics/EventDisplayFilters/share/PublicStreamFilter_DefaultConfig.py
 create mode 100644 graphics/EventDisplayFilters/share/SpacePointEventFilter_DefaultConfig.py
 create mode 100644 graphics/EventDisplayFilters/src/FilterUsingMBTS.cxx
 create mode 100644 graphics/EventDisplayFilters/src/FilterUsingMBTSTiming.cxx
 create mode 100644 graphics/EventDisplayFilters/src/FilterUsingSpacePoints.cxx
 create mode 100644 graphics/EventDisplayFilters/src/components/EventDisplayFilters_entries.cxx
 create mode 100644 graphics/EventDisplayFilters/src/components/EventDisplayFilters_load.cxx

diff --git a/graphics/EventDisplayFilters/EventDisplayFilters/FilterUsingMBTS.h b/graphics/EventDisplayFilters/EventDisplayFilters/FilterUsingMBTS.h
new file mode 100644
index 00000000000..0894a94ef37
--- /dev/null
+++ b/graphics/EventDisplayFilters/EventDisplayFilters/FilterUsingMBTS.h
@@ -0,0 +1,29 @@
+/*
+  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+*/
+
+#ifndef FILTER_USING_MBTS_H
+#define FILTER_USING_MBTS_H
+
+#include "GaudiKernel/Algorithm.h"
+#include "StoreGate/StoreGateSvc.h"
+
+class FilterUsingMBTS : public Algorithm
+{
+	public:
+		FilterUsingMBTS(const std::string& name, ISvcLocator* pSvcLocator);
+
+		StatusCode initialize();
+		StatusCode finalize();
+		StatusCode execute();
+
+	private:
+		unsigned int m_nA_required; // Number of A side triggers required for pass
+		unsigned int m_nC_required; // Number of C side triggers required for pass
+		unsigned int m_ctpOffset; // ctpID for L1_MBTSA0
+		std::vector<unsigned int> m_ctpID;
+		std::vector<std::string>  m_counterLabel;
+
+		StoreGateSvc* m_eventStore;
+};
+#endif
diff --git a/graphics/EventDisplayFilters/EventDisplayFilters/FilterUsingMBTSTiming.h b/graphics/EventDisplayFilters/EventDisplayFilters/FilterUsingMBTSTiming.h
new file mode 100644
index 00000000000..76695e09d10
--- /dev/null
+++ b/graphics/EventDisplayFilters/EventDisplayFilters/FilterUsingMBTSTiming.h
@@ -0,0 +1,40 @@
+/*
+  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+*/
+
+#ifndef FILTERUSINGMBTSTIMING_H
+#define FILTERUSINGMBTSTIMING_H
+
+#include "AthenaBaseComps/AthAlgorithm.h"
+
+//Forward declarations
+class TileTBID;
+
+class FilterUsingMBTSTiming : public AthAlgorithm {
+
+  public:
+ 
+    //Constructor
+    FilterUsingMBTSTiming (const std::string& name, ISvcLocator* pSvcLocator);
+
+    //Default Athena algorithm methods
+    StatusCode initialize();
+    StatusCode execute();
+    StatusCode finalize();
+
+  private:
+
+    /** @name Configurable options */  
+    //@{
+    ///MBTSContainer", "StoreGate key of the MBTS container (default=\"MBTSContainer\")");
+    std::string m_mbtsContainerName;
+    ///Only count cell above this threshold (default = 40/222[pC])");
+    float m_MBTSThreshold;
+    ///Maximum difference of the average time of hits on A and C-side (default=10[ns])");
+    float m_maxTimeDifference;
+    //@}
+
+    // Handle to the Tile identifier helper
+    const TileTBID* m_tileTBID;
+};
+#endif
diff --git a/graphics/EventDisplayFilters/EventDisplayFilters/FilterUsingSpacePoints.h b/graphics/EventDisplayFilters/EventDisplayFilters/FilterUsingSpacePoints.h
new file mode 100644
index 00000000000..dff242373bc
--- /dev/null
+++ b/graphics/EventDisplayFilters/EventDisplayFilters/FilterUsingSpacePoints.h
@@ -0,0 +1,26 @@
+/*
+  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+*/
+
+#ifndef FILTER_USING_SPACEPOINTS_H
+#define FILTER_USING_SPACEPOINTS_H
+
+#include "GaudiKernel/Algorithm.h"
+#include "StoreGate/StoreGateSvc.h"
+
+class FilterUsingSpacePoints : public Algorithm
+{
+	public:
+		FilterUsingSpacePoints(const std::string& name, ISvcLocator* pSvcLocator);
+
+		StatusCode initialize();
+		StatusCode finalize();
+		StatusCode execute();
+
+	private:
+		unsigned int m_SpacePoints_required; // Number of A side triggers required for pass
+    std::string m_SpacePointContainerName;  //SpacePointContainer to use
+
+		StoreGateSvc* m_eventStore;
+};
+#endif
diff --git a/graphics/EventDisplayFilters/cmt/requirements b/graphics/EventDisplayFilters/cmt/requirements
new file mode 100644
index 00000000000..68f6c4dc5ab
--- /dev/null
+++ b/graphics/EventDisplayFilters/cmt/requirements
@@ -0,0 +1,22 @@
+#################################################
+package EventDisplayFilters
+author Sebastian Boeser, Brian Thomas Martin
+
+use AtlasPolicy          AtlasPolicy-01-*
+use GaudiInterface       GaudiInterface-01-*   External
+use AthenaBaseComps      AthenaBaseComps-*     Control
+
+use StoreGate            StoreGate-*           Control
+
+library EventDisplayFilters *.cxx -s=components *.cxx
+apply_pattern component_library
+apply_pattern declare_joboptions files="*.py"
+apply_pattern declare_python_modules files="*.py"
+
+private
+use TrigT1Result         TrigT1Result-*        Trigger/TrigT1
+use TrkSpacePoint        TrkSpacePoint-*       Tracking/TrkEvent
+use TileIdentifier       TileIdentifier-*      TileCalorimeter
+use TileEvent            TileEvent-*           TileCalorimeter
+#################################################
+
diff --git a/graphics/EventDisplayFilters/python/PublicStreamFilter.py b/graphics/EventDisplayFilters/python/PublicStreamFilter.py
new file mode 100644
index 00000000000..0d4fa35d4d0
--- /dev/null
+++ b/graphics/EventDisplayFilters/python/PublicStreamFilter.py
@@ -0,0 +1,77 @@
+# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+
+__doc__ = """Module that filters public events for Atlas-Live based on IS information
+"""
+__version__ = "0.1"
+__author__  = "Eric Jansen <eric.jansen@cern.ch>"
+
+from AthenaPython import PyAthena
+from AthenaPython.PyAthena import StatusCode
+from PyAnalysisCore import PyEventTools
+
+from ipc import IPCPartition
+from ispy import ISObject, ISInfoDictionary, ISInfoAny
+
+import time
+
+class PublicStreamFilter( PyAthena.Alg ):
+
+	def __init__(self, name = "PublicStreamFilter", **kw):
+		kw['name'] = name
+		super(PublicStreamFilter,self).__init__(**kw)
+
+		self.checkready = kw.get("CheckReadyForPhysics", True)
+		self.checkrun = kw.get("CheckRunNumber", True)
+		self.t0project = kw.get("Tier0Project", "data10_7TeV")
+	
+	def initialize(self):
+		return StatusCode.Success
+
+	def execute(self):
+		if self.checkrun:
+			try:
+				eventInfo = PyEventTools.getEventInfo("")
+			except LookupError, err:
+				self.msg.warning("Could not retrieve EventInfo: %s" % err)
+				self.setFilterPassed(False)
+
+		try:
+			partition = IPCPartition("ATLAS")
+
+			dictionary = ISInfoDictionary(partition)
+			readyForPhysics = ISInfoAny()
+			dictionary.getValue("RunParams.Ready4Physics", readyForPhysics)
+			ready = readyForPhysics.get()
+			
+			runParams = ISObject(partition, 'RunParams.RunParams','RunParams')
+			runParams.checkout()
+
+		except UserWarning, err:
+			self.msg.warning("Could not retrieve data from IS: %s" % err)
+			self.setFilterPassed(False)
+			time.sleep(5)
+
+		self.msg.debug("IS publishes T0_project_tag %s and readyForPhysics %s for run %d" % (runParams.T0_project_tag, ready, runParams.run_number))
+
+		if self.checkready and not ready:
+			self.msg.info("ReadyForPhysics not set... rejecting event");
+			self.setFilterPassed(False);
+			time.sleep(1)
+
+		elif runParams.T0_project_tag != self.t0project:
+			self.msg.info("T0_project_tag is not %s (%s)... rejecting event" % (self.t0project, runParams.T0_project_tag))
+			self.setFilterPassed(False)
+			time.sleep(1)
+
+		elif self.checkrun and runParams.run_number != eventInfo.event_ID().run_number():
+			self.msg.info("Information in IS is not for this run (%d != %d)... rejecting event" % (runParams.run_number, eventInfo.event_ID().run_number()))
+			self.setFilterPassed(False)
+
+		else:
+			self.msg.info("Good event, passing into the public stream...");
+			self.setFilterPassed(True)
+
+		return StatusCode.Success
+
+	def finalize(self):
+		return StatusCode.Success
diff --git a/graphics/EventDisplayFilters/python/__init__.py b/graphics/EventDisplayFilters/python/__init__.py
new file mode 100644
index 00000000000..74583d364ec
--- /dev/null
+++ b/graphics/EventDisplayFilters/python/__init__.py
@@ -0,0 +1,2 @@
+# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+
diff --git a/graphics/EventDisplayFilters/share/MBTSTimingFilter_DefaultConfig.py b/graphics/EventDisplayFilters/share/MBTSTimingFilter_DefaultConfig.py
new file mode 100644
index 00000000000..e21cb926185
--- /dev/null
+++ b/graphics/EventDisplayFilters/share/MBTSTimingFilter_DefaultConfig.py
@@ -0,0 +1,22 @@
+#####################################################################################
+# Add a filter algorithm that cuts on timing difference of the hits on MBTS A and C side
+#####################################################################################
+from EventDisplayFilters.EventDisplayFiltersConf import FilterUsingMBTSTiming
+MBTSTimingFilter = FilterUsingMBTSTiming("FilterUsingMBTSTiming",OutputLevel=DEBUG)
+
+# Default filter configuration
+MBTSTimingFilter.OutputLevel = DEBUG
+MBTSTimingFilter.MaxTimeDifference = 10 # Set maximum timing difference to 10ns
+MBTSTimingFilter.CellChargeThreshold = 40./222. # set the cell charge threshold in pC
+
+#Append in proper place, i.e. after Trigger-Bytestream decoding
+index=0
+for alg in topSequence:
+  #count position
+  index += 1
+  #find index in the TrigBSExtraction in topSequence
+  if (alg.getType() == 'CaloCellMaker'):
+    topSequence.insert(index, MBTSTimingFilter)
+
+#Make sure filtering is accepted
+topSequence.StopOverride=False
diff --git a/graphics/EventDisplayFilters/share/MBTSTriggerFilter_DefaultConfig.py b/graphics/EventDisplayFilters/share/MBTSTriggerFilter_DefaultConfig.py
new file mode 100644
index 00000000000..a9e06fb6115
--- /dev/null
+++ b/graphics/EventDisplayFilters/share/MBTSTriggerFilter_DefaultConfig.py
@@ -0,0 +1,23 @@
+#####################################################################################
+# Add a filter algorithm that cuts on the multiplicity of MBTS hits
+#####################################################################################
+from EventDisplayFilters.EventDisplayFiltersConf import FilterUsingMBTS
+MBTSFilter = FilterUsingMBTS("FilterUsingMBTS")
+
+# Default filter configuration
+MBTSFilter.OutputLevel = DEBUG
+MBTSFilter.NumberOfAsideHits = 2 # Number of MBTSA triggers required for a pass
+MBTSFilter.NumberOfCsideHits = 2 # Number of MBTSC triggers required for a pass
+MBTSFilter.FirstMbtsCtpId    = 30 # ctpId of L1_MBTSA0  (30 is good for 20082009 beam)
+
+#Append in proper place, i.e. after Trigger-Bytestream decoding
+index=0
+for alg in topSequence:
+  #count position
+  index += 1
+  #find index in the TrigBSExtraction in topSequence
+  if (alg.getType() == 'TrigBSExtraction'):
+    topSequence.insert(index, MBTSFilter)
+
+#Make sure filtering is accepted
+topSequence.StopOverride=False
diff --git a/graphics/EventDisplayFilters/share/PublicStreamFilter_DefaultConfig.py b/graphics/EventDisplayFilters/share/PublicStreamFilter_DefaultConfig.py
new file mode 100644
index 00000000000..9db2c388d9d
--- /dev/null
+++ b/graphics/EventDisplayFilters/share/PublicStreamFilter_DefaultConfig.py
@@ -0,0 +1,15 @@
+#####################################################################################
+# Add a filter algorithm that cuts on IS parameters for the public stream
+#####################################################################################
+from EventDisplayFilters.PublicStreamFilter import *
+
+PublicStreamFilter = PublicStreamFilter(
+    name = "PublicStreamFilter",
+    OutputLevel = DEBUG,
+    CheckReadyForPhysics = True,
+    CheckRunNumber = True,
+    Tier0Project = "data10_7TeV"
+)
+
+topSequence.insert(0, PublicStreamFilter)
+topSequence.StopOverride=False
diff --git a/graphics/EventDisplayFilters/share/SpacePointEventFilter_DefaultConfig.py b/graphics/EventDisplayFilters/share/SpacePointEventFilter_DefaultConfig.py
new file mode 100644
index 00000000000..a3d180e10e5
--- /dev/null
+++ b/graphics/EventDisplayFilters/share/SpacePointEventFilter_DefaultConfig.py
@@ -0,0 +1,22 @@
+#####################################################################################
+# Add a filter algorithm that cuts on the number of SpacePoints
+#####################################################################################
+from EventDisplayFilters.EventDisplayFiltersConf import FilterUsingSpacePoints
+SpacePointFilter = FilterUsingSpacePoints("FilterUsingSpacePoints")
+
+# Default filter configuration
+SpacePointFilter.OutputLevel = DEBUG
+SpacePointFilter.NumberOfSpacePoints = 5 # Number of SpacePoints required
+
+#Append in proper place, i.e. after Trigger-Bytestream decoding
+index=0
+for alg in topSequence:
+  #count position
+  index += 1
+  #find index in the TrigBSExtraction in topSequence
+  if (alg.name() == 'InDetSiTrackerSpacePointFinder'):
+    topSequence.insert(index, SpacePointFilter)
+
+
+#Make sure filtering is accepted
+topSequence.StopOverride=False
diff --git a/graphics/EventDisplayFilters/src/FilterUsingMBTS.cxx b/graphics/EventDisplayFilters/src/FilterUsingMBTS.cxx
new file mode 100644
index 00000000000..a418f4ed35d
--- /dev/null
+++ b/graphics/EventDisplayFilters/src/FilterUsingMBTS.cxx
@@ -0,0 +1,106 @@
+/*
+  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+*/
+
+#include "EventDisplayFilters/FilterUsingMBTS.h"
+#include "GaudiKernel/MsgStream.h"
+#include "TrigT1Result/CTP_RDO.h"
+#include "TrigT1Result/CTP_Decoder.h"
+
+#include <sstream>
+
+/****
+ * simple filter for splash events based on MBTS multiplicites
+ * @author: Brian Thomas Martin
+ ****/
+
+	FilterUsingMBTS::FilterUsingMBTS(const std::string& name, ISvcLocator* pSvcLocator)  :  Algorithm(name, pSvcLocator)
+{
+	declareProperty("NumberOfAsideHits", m_nA_required=4);
+	declareProperty("NumberOfCsideHits", m_nC_required=4);
+	declareProperty("FirstMbtsCtpId",    m_ctpOffset=30);
+}
+
+StatusCode FilterUsingMBTS::initialize()
+{
+	MsgStream log(msgSvc(), name());
+	StatusCode sc;
+	log << MSG::INFO << "Initializing " << name() << endreq;
+	  sc = service( "StoreGateSvc", m_eventStore);
+	  if( sc.isFailure() ) {
+		  log << MSG::FATAL << name() << ": Unable to locate Service StoreGateSvc" << endreq;
+		  return sc;
+	  }
+	
+	// Set trigger mapping and build labels
+	for(int c=0;c<32;c++)
+	{
+		m_ctpID.push_back(m_ctpOffset+c);
+		std::ostringstream ss;
+		ss << "L1_MBTS" << ((c<16) ? "A" : "C") << ((c<16) ? c : (c-16)) ;
+		m_counterLabel.push_back(ss.str());
+	}
+	
+	return StatusCode::SUCCESS;
+}
+
+StatusCode FilterUsingMBTS::execute()
+{
+	MsgStream log(msgSvc(), name());
+	StatusCode sc;
+	// Decode CTP RDO
+	const DataHandle < CTP_RDO > theCTP_RDO = 0;
+	sc = m_eventStore->retrieve(theCTP_RDO, "CTP_RDO");
+	if (sc.isFailure()) {
+		log << MSG::WARNING
+			<< "Could not find \"CTP_RDO\" in StoreGate" << endreq;
+		return sc;
+	}
+	CTP_Decoder ctp;
+	ctp.setRDO(theCTP_RDO);
+	uint32_t numberBC = theCTP_RDO->getNumberOfBunches();
+
+  unsigned int m_nA=0; // Number of A side triggers per event
+  unsigned int m_nC=0; // Number of C side triggers per event
+
+	if (numberBC > 0) 
+	{
+		short l1aBC = theCTP_RDO->getL1AcceptBunchPosition();
+		const std::vector < CTP_BC > &BCs = ctp.getBunchCrossings();
+		const CTP_BC & bunch = BCs[l1aBC];
+		unsigned int l1aBCID = bunch.getBCID();
+		log <<  MSG::DEBUG << "Number of Bunches in CTP window: " << numberBC << endreq;
+		log <<  MSG::DEBUG << "Level 1 Accept Bunch: " << l1aBC   << endreq;
+		log <<  MSG::DEBUG << "Level 1 Accept BCID: "  << l1aBCID << endreq;
+		const std::bitset < 256 > TBP(bunch.getTBP());
+		for(int c=0;c<32;c++)  // Loop over MBTS counters
+		{
+			// Check the L1 result for each MBTS counter
+			if (TBP.test(m_ctpID[c]))
+			{
+				log << MSG::INFO << "Trigger fired for : " << m_counterLabel[c] << endreq;
+				if(c<16) m_nA++;
+				else     m_nC++;
+			}
+		} // end MBTS counter loop
+	} // end if nBC>0
+
+	// Check if filter is passed
+	if( (m_nA >= m_nA_required) && (m_nC >= m_nC_required) )
+	{
+		log << MSG::INFO << "MBTS filter passed" << endreq;
+		this->setFilterPassed(true);
+	}
+	else
+	{
+		log << MSG::INFO << "MBTS filter failed" << endreq;
+		this->setFilterPassed(false);
+	}	
+	
+	return sc;
+}
+
+StatusCode FilterUsingMBTS::finalize()
+{
+	return StatusCode::SUCCESS;
+}
diff --git a/graphics/EventDisplayFilters/src/FilterUsingMBTSTiming.cxx b/graphics/EventDisplayFilters/src/FilterUsingMBTSTiming.cxx
new file mode 100644
index 00000000000..244c060c129
--- /dev/null
+++ b/graphics/EventDisplayFilters/src/FilterUsingMBTSTiming.cxx
@@ -0,0 +1,101 @@
+/*
+  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+*/
+
+#include "EventDisplayFilters/FilterUsingMBTSTiming.h"
+
+#include "TileIdentifier/TileTBID.h"
+#include "TileEvent/TileContainer.h"
+
+/****
+ * Simple filter for collisions based on the difference of the average MBTS hit time
+ * @author: Sebastian Boeser, Emily Nurse
+ ****/
+
+FilterUsingMBTSTiming::FilterUsingMBTSTiming(const std::string& name, ISvcLocator* pSvcLocator)  :  AthAlgorithm(name, pSvcLocator)
+{
+  declareProperty("StoreGateKey", m_mbtsContainerName = "MBTSContainer", "StoreGate key of the MBTS container (default=\"MBTSContainer\")");
+	declareProperty("CellChargeThreshold", m_MBTSThreshold= 40./222. ,"Only count cell above this threshold (default = 40/222[pC])");
+	declareProperty("MaxTimeDifference", m_maxTimeDifference=10., "Maximum difference of the average time of hits on A and C-side (default=10[ns])");
+}
+
+StatusCode FilterUsingMBTSTiming::initialize()
+{
+
+  //Get tile identifier helper
+  if (detStore()->retrieve(m_tileTBID).isFailure()){
+    msg(MSG::ERROR) << "Unable to retrieve TileTBID helper" << endreq;
+    return StatusCode::FAILURE;
+  }
+    
+	
+	return StatusCode::SUCCESS;
+}
+
+StatusCode FilterUsingMBTSTiming::execute()
+{
+
+  //Retrieve container from StoreGate
+  const TileCellContainer *tileCellCnt = NULL;
+  if (evtStore()->retrieve(tileCellCnt, m_mbtsContainerName).isFailure()) {
+    msg(MSG::WARNING) << "Unable to retrieving MBTS container with name " << m_mbtsContainerName << endreq;
+    return StatusCode::SUCCESS;
+  }
+
+  //Calculate average time for A and C side
+  float timeA = 0.;
+  float timeC = 0.;
+  unsigned int countA = 0;
+  unsigned int countC = 0;
+
+  //Loop over tile cells
+  TileCellContainer::const_iterator MBTSCellItr = tileCellCnt->begin();
+  TileCellContainer::const_iterator MBTSCellsEnd = tileCellCnt->end();
+  for (; MBTSCellItr != MBTSCellsEnd; ++MBTSCellItr) {
+
+    // Discriminate the signals
+	  if ((*MBTSCellItr)->energy() < m_MBTSThreshold) continue ;
+
+	  msg(MSG::DEBUG) << "Energy = " << (*MBTSCellItr)->energy() << " pC\t";
+	  msg(MSG::DEBUG) << "Time = " << (*MBTSCellItr)->time() << " ns\t";
+    msg(MSG::DEBUG) << "Side = " << (( m_tileTBID->type((*MBTSCellItr)->ID()) > 0 ) ? "A" : "C") << endreq;
+
+	  // cache type, module and channel
+	  // MBTS Id type is  "side"  +/- 1
+	  if (m_tileTBID->type((*MBTSCellItr)->ID()) > 0)  {
+	    timeA +=  (*MBTSCellItr)->time();
+	    countA++ ; 
+	  } else {	
+	    timeC +=  (*MBTSCellItr)->time();
+	    countC++;
+	  }
+  } 
+		
+  //Make sure we have a least n hits on each side
+  if ( countA < 1 || countC < 1 ){
+    msg(MSG::INFO) << "Need at least one hit on each side" << endreq;
+    setFilterPassed(false);
+    msg(MSG::INFO ) << "Event is rejected" << endreq;
+    return StatusCode::SUCCESS;
+  }
+
+  // Calculate the time difference
+  float timeDiff = fabs(timeA/countA - timeC/countC);
+  msg(MSG::INFO) << "Calculated time difference of " << timeDiff << " ns" << endreq;
+
+  //And cut
+  if (timeDiff <= m_maxTimeDifference) {
+    setFilterPassed(true);
+    msg(MSG::INFO ) << "Event is accepted" << endreq;
+  } else {
+    setFilterPassed(false);
+    msg(MSG::INFO ) << "Event is rejected" << endreq;
+  }
+
+	return StatusCode::SUCCESS;
+}
+
+StatusCode FilterUsingMBTSTiming::finalize()
+{
+	return StatusCode::SUCCESS;
+}
diff --git a/graphics/EventDisplayFilters/src/FilterUsingSpacePoints.cxx b/graphics/EventDisplayFilters/src/FilterUsingSpacePoints.cxx
new file mode 100644
index 00000000000..5faef87bf8f
--- /dev/null
+++ b/graphics/EventDisplayFilters/src/FilterUsingSpacePoints.cxx
@@ -0,0 +1,75 @@
+/*
+  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+*/
+
+#include "EventDisplayFilters/FilterUsingSpacePoints.h"
+#include "GaudiKernel/MsgStream.h"
+#include "TrkSpacePoint/SpacePointContainer.h"
+
+#include <sstream>
+
+/****
+ * simple filter for splash events based on MBTS multiplicites
+ * @author: Brian Thomas Martin
+ ****/
+
+	FilterUsingSpacePoints::FilterUsingSpacePoints(const std::string& name, ISvcLocator* pSvcLocator)  :  Algorithm(name, pSvcLocator)
+{
+	declareProperty("NumberOfSpacePoints", m_SpacePoints_required=4);
+	declareProperty("SpacePointContainer", m_SpacePointContainerName="SCT_SpacePoints");
+}
+
+StatusCode FilterUsingSpacePoints::initialize()
+{
+	MsgStream log(msgSvc(), name());
+	StatusCode sc;
+	log << MSG::INFO << "Initializing " << name() << endreq;
+	  sc = service( "StoreGateSvc", m_eventStore);
+	  if( sc.isFailure() ) {
+		  log << MSG::FATAL << name() << ": Unable to locate Service StoreGateSvc" << endreq;
+		  return sc;
+	  }
+	
+	return StatusCode::SUCCESS;
+}
+
+StatusCode FilterUsingSpacePoints::execute()
+{
+	MsgStream log(msgSvc(), name());
+
+  //Get the space point container
+  const SpacePointContainer* m_SpacePointContainer;
+
+  if ( m_eventStore->retrieve(m_SpacePointContainer,  m_SpacePointContainerName).isFailure() ){
+     log << MSG::INFO << "Unable to retrieve SpacePoint container with name " << m_SpacePointContainerName << endreq;
+     return StatusCode::FAILURE;
+  }
+  
+
+  unsigned long NSpacePoints = 0;
+
+  //Get an iterator over the SpacePoint container itself  
+  SpacePointContainer::const_iterator SpacePointCollItr = m_SpacePointContainer->begin();
+  for (; SpacePointCollItr!=  m_SpacePointContainer->end(); ++SpacePointCollItr)
+       NSpacePoints += (**SpacePointCollItr).size();
+
+
+  //be verbose
+  log << MSG::DEBUG << "Number of SpacePoints is " << NSpacePoints << endreq;
+
+  //And cut
+  if (NSpacePoints >= m_SpacePoints_required) {
+    setFilterPassed(true);
+    log << MSG::INFO << "Event is accepted" << endreq;
+  } else {
+    setFilterPassed(false);
+    log << MSG::INFO << "Event is rejected" << endreq;
+  }
+
+	return StatusCode::SUCCESS;
+}
+
+StatusCode FilterUsingSpacePoints::finalize()
+{
+	return StatusCode::SUCCESS;
+}
diff --git a/graphics/EventDisplayFilters/src/components/EventDisplayFilters_entries.cxx b/graphics/EventDisplayFilters/src/components/EventDisplayFilters_entries.cxx
new file mode 100644
index 00000000000..8bb72a9eee1
--- /dev/null
+++ b/graphics/EventDisplayFilters/src/components/EventDisplayFilters_entries.cxx
@@ -0,0 +1,11 @@
+#include "GaudiKernel/DeclareFactoryEntries.h"
+#include "EventDisplayFilters/FilterUsingMBTS.h"
+#include "EventDisplayFilters/FilterUsingMBTSTiming.h"
+#include "EventDisplayFilters/FilterUsingSpacePoints.h"
+DECLARE_ALGORITHM_FACTORY( FilterUsingMBTS )
+DECLARE_ALGORITHM_FACTORY( FilterUsingMBTSTiming )
+DECLARE_ALGORITHM_FACTORY( FilterUsingSpacePoints )
+DECLARE_FACTORY_ENTRIES( EventDisplayFilters ) {
+  DECLARE_ALGORITHM( FilterUsingMBTSTiming )
+  DECLARE_ALGORITHM( FilterUsingSpacePoints )
+}
diff --git a/graphics/EventDisplayFilters/src/components/EventDisplayFilters_load.cxx b/graphics/EventDisplayFilters/src/components/EventDisplayFilters_load.cxx
new file mode 100644
index 00000000000..c83aa3a0c56
--- /dev/null
+++ b/graphics/EventDisplayFilters/src/components/EventDisplayFilters_load.cxx
@@ -0,0 +1,2 @@
+#include "GaudiKernel/LoadFactoryEntries.h"
+LOAD_FACTORY_ENTRIES(EventDisplayFilters)
-- 
GitLab