diff --git a/Trigger/TrigAlgorithms/TrigmuRoI/CMakeLists.txt b/Trigger/TrigAlgorithms/TrigmuRoI/CMakeLists.txt index 71280c4f9a3dd58d63f5a749ef7dc67de8100b50..5579879234d2aadc2930bd9a919c3076e75e2ecc 100644 --- a/Trigger/TrigAlgorithms/TrigmuRoI/CMakeLists.txt +++ b/Trigger/TrigAlgorithms/TrigmuRoI/CMakeLists.txt @@ -21,7 +21,7 @@ atlas_depends_on_subdirs( PUBLIC atlas_add_component( TrigmuRoI src/*.cxx src/components/*.cxx - LINK_LIBRARIES GaudiKernel TrigSteeringEvent TrigInterfacesLib TrigT1Interfaces TrigNavigationLib TrigT1Result ) + LINK_LIBRARIES AthenaMonitoringLib GaudiKernel TrigSteeringEvent TrigInterfacesLib TrigT1Interfaces TrigNavigationLib TrigT1Result ) # Install files from the package: atlas_install_headers( TrigmuRoI ) diff --git a/Trigger/TrigAlgorithms/TrigmuRoI/python/TrigmuRoIConfig.py b/Trigger/TrigAlgorithms/TrigmuRoI/python/TrigmuRoIConfig.py index ae5f3f18180c3079f980d3138ff81ea8b3fd3bf1..46bcc7b6e0a6fff43ed2b52d35582eebfce8562d 100755 --- a/Trigger/TrigAlgorithms/TrigmuRoI/python/TrigmuRoIConfig.py +++ b/Trigger/TrigAlgorithms/TrigmuRoI/python/TrigmuRoIConfig.py @@ -1,4 +1,4 @@ -# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration from TrigmuRoI.TrigmuRoIConf import * from TrigmuRoI.TrigmuRoIMonitoring import * @@ -8,9 +8,6 @@ class TrigmuRoIConfig (TrigmuRoI): __slots__ = [] - #def __new__( cls, *args, **kwargs ): - # newargs = ['%s_%s' % (cls.getType(),args[0]) ] + list(args) - # return super( TrigmuFastConfig, cls ).__new__( cls, *newargs, **kwargs ) def __init__( self, name="TrigmuRoI" ): super( TrigmuRoIConfig, self ).__init__( name ) @@ -24,3 +21,12 @@ class TrigmuRoIConfig (TrigmuRoI): #time.NumberOfHistBins = 50 self.AthenaMonTools = [ validation, online, cosmic, time ] + +class TrigmuRoIMTConfig (TrigmuRoIMT): + + __slots__ = [] + + def __init__( self, name="TrigmuRoIMT" ): + super( TrigmuRoIMTConfig, self ).__init__( name ) + + self.MonTool = TrigmuRoIMTMonitoring() diff --git a/Trigger/TrigAlgorithms/TrigmuRoI/python/TrigmuRoIMonitoring.py b/Trigger/TrigAlgorithms/TrigmuRoI/python/TrigmuRoIMonitoring.py index 56566d7e9c4c5fd69c1f4ee36f589ebe12062447..c57b0a3e01305d00843d56e544cc4b4093770adb 100755 --- a/Trigger/TrigAlgorithms/TrigmuRoI/python/TrigmuRoIMonitoring.py +++ b/Trigger/TrigAlgorithms/TrigmuRoI/python/TrigmuRoIMonitoring.py @@ -1,6 +1,7 @@ -# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration from TrigMonitorBase.TrigGenericMonitoringToolConfig import defineHistogram, TrigGenericMonitoringToolConfig +from AthenaMonitoring.GenericMonitoringTool import GenericMonitoringTool class TrigmuRoIValidationMonitoring(TrigGenericMonitoringToolConfig): def __init__ (self, name="TrigmuRoIValidationMonitoring"): @@ -41,3 +42,12 @@ class TrigmuRoICosmicMonitoring(TrigGenericMonitoringToolConfig): xbins=21, xmin=-10.5, xmax=10.5) ] self.Histograms += [ defineHistogram('EtaOutOfTime, PhiOutOfTime', type='TH2F', title="Eta vs Phi of the Mupon RoI out of time; Eta; Phi", xbins=108, xmin=-2.7, xmax=2.7, ybins=96, ymin=-3.1416, ymax=3.1416 ) ] + +class TrigmuRoIMTMonitoring(GenericMonitoringTool): + def __init__ (self, name = "TrigmuRoIMTMonitoring"): + super(TrigmuRoIMTMonitoring, self).__init__( name ) + + self.HistPath = name + self.defineHistogram('RpcOutOfTime', type='TH1F', title="Distribution of the BCID difference for the Rpc RoI out of Time; (Muon RoI BCID - Event BCID)",xbins=21, xmin=-10.5, xmax=10.5) + self.defineHistogram('TgcOutOfTime', type='TH1F', title="Distribution of the BCID difference for the Tgc RoI out of Time; (Muon RoI BCID - Event BCID)",xbins=21, xmin=-10.5, xmax=10.5) + self.defineHistogram('EtaOutOfTime, PhiOutOfTime', type='TH2F', title="Eta vs Phi of the Mupon RoI out of time; Eta; Phi",bins=108, xmin=-2.7, xmax=2.7, ybins=96, ymin=-3.1416, ymax=3.1416 ) diff --git a/Trigger/TrigAlgorithms/TrigmuRoI/src/TrigmuRoIMT.cxx b/Trigger/TrigAlgorithms/TrigmuRoI/src/TrigmuRoIMT.cxx new file mode 100644 index 0000000000000000000000000000000000000000..b83ee4803624f88d955e50bd725086057091dad4 --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigmuRoI/src/TrigmuRoIMT.cxx @@ -0,0 +1,152 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#include "TrigmuRoIMT.h" +#include "TrigT1Result/RoIBResult.h" +#include "TrigT1Interfaces/RecMuonRoI.h" +#include "CxxUtils/phihelper.h" + +// ================================================================================ +// ================================================================================ + +TrigmuRoIMT::TrigmuRoIMT(const std::string& name, ISvcLocator* pSvcLocator) + : AthAlgorithm(name, pSvcLocator), + m_trigMuonRoITool( "TrigMuonRoITool" ), + m_recRPCRoiSvc("LVL1RPC::RPCRecRoiSvc",""), + m_recTGCRoiSvc("LVL1TGC::TGCRecRoiSvc","") +{ +} + + +// ================================================================================ +// ================================================================================ + +StatusCode TrigmuRoIMT::initialize() +{ + + ATH_MSG_DEBUG("MinValueForOutOfTimeBC: "<<m_minValueForOutOfTimeBC); + ATH_MSG_DEBUG("MaxValueForOutOfTimeBC: "<<m_maxValueForOutOfTimeBC); + + // Retrieve the tools/services + ATH_CHECK(m_trigMuonRoITool.retrieve()); + ATH_CHECK(m_recRPCRoiSvc.retrieve()); + ATH_CHECK(m_recTGCRoiSvc.retrieve()); + ATH_CHECK(m_roisWriteHandleKey.initialize()); + + if (!m_monTool.empty()) { + ATH_MSG_DEBUG("Retrieving monTool"); + CHECK(m_monTool.retrieve()); + } else { + ATH_MSG_INFO("No monTool configured => NO MONITORING"); + } + + return StatusCode::SUCCESS; +} + +// ================================================================================ +// ================================================================================ + +unsigned int TrigmuRoIMT::getBitMaskValue( const unsigned int uintValue, const unsigned int mask ) { + unsigned int result; + unsigned int maskcopy; + maskcopy = mask; + result = uintValue & mask; + if ( mask != 0 ) { + while ( ( maskcopy & 0x00000001 ) == 0 ) { + maskcopy = maskcopy >> 1; + result = result >> 1; + } + } + return result; +} + +// ================================================================================ +// ================================================================================ + +StatusCode TrigmuRoIMT::execute() +{ + + std::vector<int> outOfTimeRpc, outOfTimeTgc; + std::vector<float> etaRoI, phiRoI; + auto rpcOutOfTime = Monitored::Collection("RpcOutOfTime", outOfTimeRpc); + auto tgcOutOfTime = Monitored::Collection("TgcOutOfTime", outOfTimeTgc); + auto etaOutOfTimeRoI = Monitored::Collection("EtaOutOfTime", etaRoI); + auto phiOutOfTimeRoI = Monitored::Collection("PhiOutOfTime", phiRoI); + + auto mon = Monitored::Group(m_monTool, rpcOutOfTime, tgcOutOfTime, etaOutOfTimeRoI, phiOutOfTimeRoI); + + int roi_id = 0; + + //-------------------------------------------------------------------------- + // Gather the Muon RoIs out of time by the + //-------------------------------------------------------------------------- + + SG::WriteHandle<TrigRoiDescriptorCollection> wh_roiCollection(m_roisWriteHandleKey); + ATH_CHECK(wh_roiCollection.record(std::make_unique<TrigRoiDescriptorCollection>())); + auto roiColl = wh_roiCollection.ptr(); + + for (std::vector< std::pair<ROIB::MuCTPIRoI,int> >::const_iterator it = m_trigMuonRoITool->begin_OutOfTimeRoIs(); + it != m_trigMuonRoITool->end_OutOfTimeRoIs(); ++it) { + + ATH_MSG_DEBUG(" Difference(RoI(BCID) - Event(BCID)) = " << (*it).second); + ATH_MSG_DEBUG(" ------------------------------------- "); + ATH_MSG_DEBUG("RoIB word : 0x" << MSG::hex << ((*it).first).roIWord() << MSG::dec); + ATH_MSG_DEBUG("Threshold : pt" << ((*it).first).pt()); + ATH_MSG_DEBUG("Sector ID : " << ((*it).first).getSectorID()); + ATH_MSG_DEBUG("Sector addr : 0x" << MSG::hex << ((*it).first).getSectorAddress() << MSG::dec); + ATH_MSG_DEBUG("Sector overflow : " << ((*it).first).getSectorOverflow()); + ATH_MSG_DEBUG("RoI overflow : " << ((*it).first).getRoiOverflow()); + ATH_MSG_DEBUG("RoI number : " << ((*it).first).getRoiNumber()); + ATH_MSG_DEBUG("IsHighestPt : " << ((*it).first).getCandidateIsHighestPt()); + ATH_MSG_DEBUG("================================================="); + + unsigned int temp_sysID = getBitMaskValue(((*it).first).getSectorAddress(), LVL1::SysIDMask ); + unsigned int sysID = 0; // Barrel + if( temp_sysID & 0x2 ) sysID = 1; // Endcap + else if( temp_sysID & 0x1 ) sysID = 2; // Forward + + + if ( sysID == 0 ) outOfTimeRpc.push_back((*it).second); + else outOfTimeTgc.push_back((*it).second); + + const LVL1::RecMuonRoiSvc* recMuonRoiSvc = 0; + std::string region = ""; + if( sysID == 0 ) { + recMuonRoiSvc = &(*m_recRPCRoiSvc); + region = "Barrel region"; + } else if ( sysID == 1 ){ + recMuonRoiSvc = &(*m_recTGCRoiSvc); + region = "Endcap region"; + } else { + recMuonRoiSvc = &(*m_recTGCRoiSvc); + region = "Forward region"; + } + + recMuonRoiSvc->reconstruct( ((*it).first).roIWord() ); + // create new trigger element for this out of time RoI + double eta = recMuonRoiSvc->eta(); + double phi = recMuonRoiSvc->phi(); + etaRoI.push_back(eta); + phiRoI.push_back(phi); + + double etamin = eta - 0.2; + double etamax = eta + 0.2; + double phimin = CxxUtils::wrapToPi(phi - 0.2); + double phimax = CxxUtils::wrapToPi(phi + 0.2); + + if ((*it).second >= m_minValueForOutOfTimeBC && + (*it).second <= m_maxValueForOutOfTimeBC ) { + + // generic TrigRoiDescriptor + auto roiDescriptor = new TrigRoiDescriptor( ((*it).first).roIWord(), 0, roi_id, eta, etamin, etamax, phi, phimin, phimax,0,-255,255); + roiColl->push_back(roiDescriptor); + + ATH_MSG_DEBUG("Created RoI descriptor with id, eta, phi: "<<roi_id<<" "<<eta<<" "<<phi); + } + roi_id += 1; + } + + return StatusCode::SUCCESS; +} + diff --git a/Trigger/TrigAlgorithms/TrigmuRoI/src/TrigmuRoIMT.h b/Trigger/TrigAlgorithms/TrigmuRoI/src/TrigmuRoIMT.h new file mode 100644 index 0000000000000000000000000000000000000000..70e77f6cfd4629ddb17452d7aa41fae6a1f33378 --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigmuRoI/src/TrigmuRoIMT.h @@ -0,0 +1,38 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRIGMUROIMT_H +#define TRIGMUROIMT_H + +#include "TrigT1Interfaces/RecMuonRoiSvc.h" +#include "TrigMuonRoITools/ITrigMuonRoITool.h" +#include "TrigSteeringEvent/TrigRoiDescriptorCollection.h" + +#include "AthenaBaseComps/AthAlgorithm.h" +#include "AthenaMonitoring/Monitored.h" + +class TrigmuRoIMT : public AthAlgorithm +{ + public: + + TrigmuRoIMT(const std::string& name, ISvcLocator* pSvcLocator); //!< std Gaudi algorthm constructor + virtual StatusCode initialize() override; + virtual StatusCode execute() override; + + private: + + ToolHandle<ITrigMuonRoITool> m_trigMuonRoITool; + ServiceHandle<LVL1::RecMuonRoiSvc> m_recRPCRoiSvc; + ServiceHandle<LVL1::RecMuonRoiSvc> m_recTGCRoiSvc; + + SG::WriteHandleKey<TrigRoiDescriptorCollection> m_roisWriteHandleKey {this,"RoisWriteHandleKey","Unspecified", "Output collection of RoIs"}; + + ToolHandle<GenericMonitoringTool> m_monTool{this,"MonTool","","Monitoring tool"}; + Gaudi::Property<int> m_minValueForOutOfTimeBC{this, "MinValueForOutOfTimeBC", -9999, "Min value for out of time bunch crossing"}; + Gaudi::Property<int> m_maxValueForOutOfTimeBC{this, "MaxValueForOutOfTimeBC", 9999, "Max value for out of time bunch crossing"}; + + unsigned int getBitMaskValue( const unsigned int uintValue, const unsigned int mask ); +}; + +#endif diff --git a/Trigger/TrigAlgorithms/TrigmuRoI/src/components/TrigmuRoI_entries.cxx b/Trigger/TrigAlgorithms/TrigmuRoI/src/components/TrigmuRoI_entries.cxx index 36a0d048b17d49d24073a3064c5f8da8e4b13149..aa5190a5038c29a7d2a0ec5a3bb99662538763f4 100644 --- a/Trigger/TrigAlgorithms/TrigmuRoI/src/components/TrigmuRoI_entries.cxx +++ b/Trigger/TrigAlgorithms/TrigmuRoI/src/components/TrigmuRoI_entries.cxx @@ -1,6 +1,8 @@ #include "TrigmuRoI/TrigmuRoI.h" +#include "src/TrigmuRoIMT.h" DECLARE_COMPONENT( TrigmuRoI ) +DECLARE_COMPONENT( TrigmuRoIMT )