From b403b34fb85dba9632c22700a72dcb4d5a669335 Mon Sep 17 00:00:00 2001 From: Kunihiro Nagano <Kunihiro.Nagano@cern.ch> Date: Sat, 30 Jul 2011 16:33:15 +0200 Subject: [PATCH] removed CERNLIB dependency (TrigmuRoI-00-00-04) --- Trigger/TrigAlgorithms/TrigmuRoI/Changelog | 21 ++ .../TrigmuRoI/TrigmuRoI/TrigmuRoI.h | 65 +++++ .../TrigAlgorithms/TrigmuRoI/cmt/requirements | 29 ++ .../TrigmuRoI/python/TrigmuRoIConfig.py | 26 ++ .../TrigmuRoI/python/TrigmuRoIMonitoring.py | 43 +++ .../TrigmuRoI/src/TrigmuRoI.cxx | 249 ++++++++++++++++++ .../src/components/TrigmuRoI_entries.cxx | 11 + .../src/components/TrigmuRoI_load.cxx | 3 + 8 files changed, 447 insertions(+) create mode 100644 Trigger/TrigAlgorithms/TrigmuRoI/Changelog create mode 100644 Trigger/TrigAlgorithms/TrigmuRoI/TrigmuRoI/TrigmuRoI.h create mode 100755 Trigger/TrigAlgorithms/TrigmuRoI/cmt/requirements create mode 100755 Trigger/TrigAlgorithms/TrigmuRoI/python/TrigmuRoIConfig.py create mode 100755 Trigger/TrigAlgorithms/TrigmuRoI/python/TrigmuRoIMonitoring.py create mode 100644 Trigger/TrigAlgorithms/TrigmuRoI/src/TrigmuRoI.cxx create mode 100755 Trigger/TrigAlgorithms/TrigmuRoI/src/components/TrigmuRoI_entries.cxx create mode 100755 Trigger/TrigAlgorithms/TrigmuRoI/src/components/TrigmuRoI_load.cxx diff --git a/Trigger/TrigAlgorithms/TrigmuRoI/Changelog b/Trigger/TrigAlgorithms/TrigmuRoI/Changelog new file mode 100644 index 00000000000..4c2b15a9b6f --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigmuRoI/Changelog @@ -0,0 +1,21 @@ +2011-07-30 Kunihiro Nagano <nagano@mail.cern.ch> + * Tag as TrigmuRoI-00-00-04 + * Remove CERNLIB dependency from requirements + +2010-07-07 Alessandro Di Mattia <dimattia@mail.cern.ch> + * Tag as TrigmuRoI-00-00-03 + * fix for gaudi v21. + +2010-07-06 Alessandro Di Mattia <dimattia@mail.cern.ch> + * Tag as TrigmuRoI-00-00-02 + * DEBUG printouts put under condition. + * Monitoring variables cleared for allowing + correct start/stop/start operations. + +2010-06-29 Alessandro Di Mattia <dimattia@mail.cern.ch> + * Tag as TrigmuRoI-00-00-01 + * INFO printouts in execute replaced by DEBUG + +2010-06-29 Alessandro Di Mattia <dimattia@mail.cern.ch> + * Tag as TrigmuRoI-00-00-00 + * first implementation diff --git a/Trigger/TrigAlgorithms/TrigmuRoI/TrigmuRoI/TrigmuRoI.h b/Trigger/TrigAlgorithms/TrigmuRoI/TrigmuRoI/TrigmuRoI.h new file mode 100644 index 00000000000..be2386c91d2 --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigmuRoI/TrigmuRoI/TrigmuRoI.h @@ -0,0 +1,65 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRIGMUROI_H +#define TRIGMUROI_H + +#include "GaudiKernel/Algorithm.h" +#include "GaudiKernel/ServiceHandle.h" +#include "TrigInterfaces/AllTEAlgo.h" + +#include "GaudiKernel/ToolHandle.h" + +#include "TrigT1Interfaces/RecMuonRoiSvc.h" + +#include "TrigMuonRoITools/ITrigMuonRoITool.h" + +#include <string> +#include <stdint.h> + +class StoreGateSvc; + + +namespace HLT { + class TriggerElement; +} + +class TrigmuRoI : public HLT::AllTEAlgo +{ + public: + + TrigmuRoI(const std::string& name, ISvcLocator* pSvcLocator); //!< std Gaudi algorthm constructor + + HLT::ErrorCode hltInitialize(); + HLT::ErrorCode hltFinalize() { return HLT::OK; } //!< hlt finalize + + HLT::ErrorCode hltExecute(std::vector<std::vector<HLT::TriggerElement*> >& /*input*/, + unsigned int output); + + bool reset(); + private: + + MsgStream m_log; + + /// Source identifiers for ROB fragments + IntegerProperty m_daqCTPROBid ; + IntegerProperty m_daqMuCTPiROBid ; + + IntegerProperty m_minValueForOutOfTimeBC; + IntegerProperty m_maxValueForOutOfTimeBC; + + bool m_executed; + + ToolHandle<ITrigMuonRoITool> m_trigMuonRoITool; + ServiceHandle<LVL1::RecMuonRoiSvc> m_recRPCRoiSvc; + ServiceHandle<LVL1::RecMuonRoiSvc> m_recTGCRoiSvc; + + std::vector<int> m_RpcOutOfTime; + std::vector<int> m_TgcOutOfTime; + + std::vector<float> m_etaOutOfTime; + std::vector<float> m_phiOutOfTime; +}; + +#endif diff --git a/Trigger/TrigAlgorithms/TrigmuRoI/cmt/requirements b/Trigger/TrigAlgorithms/TrigmuRoI/cmt/requirements new file mode 100755 index 00000000000..28f32f5c1f5 --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigmuRoI/cmt/requirements @@ -0,0 +1,29 @@ +package TrigmuRoI + +author Alessandro Di Mattia <dimattia@cern.ch> + + +use AtlasPolicy AtlasPolicy-01-* +use GaudiInterface GaudiInterface-01-* External + +use TrigT1Interfaces TrigT1Interfaces-* Trigger/TrigT1 +use TrigInterfaces TrigInterfaces-* Trigger/TrigSteer +use TrigSteeringEvent TrigSteeringEvent-* Trigger/TrigEvent + +use TrigMuonRoITools TrigMuonRoITools-* Trigger/TrigTools + + +private +use TrigT1Result TrigT1Result-00-* Trigger/TrigT1 +use TrigNavigation TrigNavigation-* Trigger/TrigEvent +end_private + +######################################################### +# ATHENA librariy build # +######################################################### + + +library TrigmuRoI *.cxx -s=../src/components *.cxx +apply_pattern component_library + +apply_pattern declare_python_modules files="*.py" diff --git a/Trigger/TrigAlgorithms/TrigmuRoI/python/TrigmuRoIConfig.py b/Trigger/TrigAlgorithms/TrigmuRoI/python/TrigmuRoIConfig.py new file mode 100755 index 00000000000..ae5f3f18180 --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigmuRoI/python/TrigmuRoIConfig.py @@ -0,0 +1,26 @@ +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + +from TrigmuRoI.TrigmuRoIConf import * +from TrigmuRoI.TrigmuRoIMonitoring import * +from TrigTimeMonitor.TrigTimeHistToolConfig import TrigTimeHistToolConfig + +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 ) + + validation = TrigmuRoIValidationMonitoring() + online = TrigmuRoIOnlineMonitoring() + cosmic = TrigmuRoICosmicMonitoring() + + time = TrigTimeHistToolConfig("Time") + time.TimerHistLimits = [0, 5] + #time.NumberOfHistBins = 50 + + self.AthenaMonTools = [ validation, online, cosmic, time ] diff --git a/Trigger/TrigAlgorithms/TrigmuRoI/python/TrigmuRoIMonitoring.py b/Trigger/TrigAlgorithms/TrigmuRoI/python/TrigmuRoIMonitoring.py new file mode 100755 index 00000000000..56566d7e9c4 --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigmuRoI/python/TrigmuRoIMonitoring.py @@ -0,0 +1,43 @@ +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + +from TrigMonitorBase.TrigGenericMonitoringToolConfig import defineHistogram, TrigGenericMonitoringToolConfig + +class TrigmuRoIValidationMonitoring(TrigGenericMonitoringToolConfig): + def __init__ (self, name="TrigmuRoIValidationMonitoring"): + super(TrigmuRoIValidationMonitoring, self).__init__(name) + self.defineTarget("Validation") + + self.Histograms = [ 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.Histograms += [ 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.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 TrigmuRoIOnlineMonitoring(TrigGenericMonitoringToolConfig): + def __init__ (self, name="TrigmuRoIOnlineMonitoring"): + super(TrigmuRoIOnlineMonitoring, self).__init__(name) + self.defineTarget("Online") + + self.Histograms = [ 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.Histograms += [ 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.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 TrigmuRoICosmicMonitoring(TrigGenericMonitoringToolConfig): + def __init__ (self, name="TrigmuFastCosmicMonitoring"): + super(TrigmuRoICosmicMonitoring, self).__init__(name) + self.defineTarget("Cosmic") + + self.Histograms = [ 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.Histograms += [ 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.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 ) ] diff --git a/Trigger/TrigAlgorithms/TrigmuRoI/src/TrigmuRoI.cxx b/Trigger/TrigAlgorithms/TrigmuRoI/src/TrigmuRoI.cxx new file mode 100644 index 00000000000..f4ccb5b1e44 --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigmuRoI/src/TrigmuRoI.cxx @@ -0,0 +1,249 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +//#include "StoreGate/StoreGateSvc.h" +#include "TrigNavigation/TriggerElement.h" +#include "TrigT1Result/RoIBResult.h" + +#include "TrigT1Interfaces/RecMuonRoI.h" +#include "TrigSteeringEvent/TrigRoiDescriptor.h" +#include "TrigmuRoI/TrigmuRoI.h" + + +unsigned int 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; +} + + + +// ================================================================================ +// ================================================================================ + +TrigmuRoI::TrigmuRoI(const std::string& name, ISvcLocator* pSvcLocator) + : HLT::AllTEAlgo(name, pSvcLocator), + m_log(msgSvc(), name), + m_executed(false), + m_trigMuonRoITool( "TrigMuonRoITool" ), + m_recRPCRoiSvc("LVL1RPC::RPCRecRoiSvc",""), + m_recTGCRoiSvc("LVL1TGC::TGCRecRoiSvc","") +{ + declareProperty("DaqCTPROBid", m_daqCTPROBid=0x770000); + declareProperty("DaqMuCTPiROBid", m_daqMuCTPiROBid=0x760000); + + // mode choice + declareProperty("MinValueForOutOfTimeBC", m_minValueForOutOfTimeBC=-9999); + declareProperty("MaxValueForOutOfTimeBC", m_maxValueForOutOfTimeBC= 9999); + + // monitoring + declareMonitoredStdContainer("RpcOutOfTime", m_RpcOutOfTime, AutoClear); + declareMonitoredStdContainer("TgcOutOfTime", m_TgcOutOfTime, AutoClear); + declareMonitoredStdContainer("EtaOutOfTime", m_etaOutOfTime, AutoClear); + declareMonitoredStdContainer("PhiOutOfTime", m_phiOutOfTime, AutoClear); +} + + +// ================================================================================ +// ================================================================================ + +HLT::ErrorCode TrigmuRoI::hltInitialize() +{ + m_log.setLevel(outputLevel()); + + m_log << MSG::INFO << "initialize()" << endreq; + +#ifdef ATLAS_GAUDI_V21 + SmartIF<IService> tmp_msgSvc(msgSvc()); + if(tmp_msgSvc.isValid()) { + m_log << MSG::INFO << " Algorithm = " << name() << " is connected to Message Service = " + << tmp_msgSvc->name() << endreq; + } +#else + Service* tmp_msgSvc = dynamic_cast<Service*> (msgSvc()); + if(tmp_msgSvc != 0) { + m_log << MSG::INFO << " Algorithm = " << name() << " is connected to Message Service = " + << tmp_msgSvc->name() << endreq; + } +#endif + + m_log << MSG::INFO << " ROB ID: DAQ CTP = " << m_daqCTPROBid + << std::setw(6) << " (=0x" << MSG::hex << m_daqCTPROBid.value() << MSG::dec << ")" << endreq; + m_log << MSG::INFO << " ROB ID: DAQ muCTPi = " << m_daqMuCTPiROBid + << std::setw(6) << " (=0x" << MSG::hex << m_daqMuCTPiROBid.value() << MSG::dec << ")" << endreq; + + m_log << MSG::INFO << m_minValueForOutOfTimeBC << endreq; + m_log << MSG::INFO << m_maxValueForOutOfTimeBC << endreq; + + + // Retrieve the MuonRoITool + StatusCode sc = m_trigMuonRoITool.retrieve(); + if ( sc.isFailure() ) { + m_log << MSG::ERROR << "Could not retrieve " << m_trigMuonRoITool << endreq; + return HLT::ERROR; + } else { + m_log << MSG::INFO << "Retrieved tool " << m_trigMuonRoITool << endreq; + } + + sc = m_recRPCRoiSvc.retrieve(); + if ( sc.isFailure() ) { + m_log << MSG::ERROR << "Couldn't connect to " << m_recRPCRoiSvc << endreq; + return HLT::ERROR; + } else { + m_log << MSG::INFO << "Retrieved Service " << m_recRPCRoiSvc << endreq; + } + + sc = m_recTGCRoiSvc.retrieve(); + if ( sc.isFailure() ) { + m_log << MSG::ERROR << "Couldn't connect to " << m_recTGCRoiSvc << endreq; + return HLT::ERROR; + } else { + m_log << MSG::INFO << "Retrieved Service " << m_recTGCRoiSvc << endreq; + } + + m_log << MSG::DEBUG << "initialization - done" << endreq; + + return HLT::OK; +} + +// ================================================================================ +// ================================================================================ + +HLT::ErrorCode TrigmuRoI::hltExecute(std::vector<std::vector<HLT::TriggerElement*> >& /*tes_in*/, + unsigned int type_out) +{ + + // clear montioring variables + m_RpcOutOfTime.clear(); + m_TgcOutOfTime.clear(); + + + // execute only once + if ( m_executed ) return HLT::OK; + m_executed = true; + + beforeExecMonitors().ignore(); + + if ( m_log.level() <= MSG::DEBUG) { + msg() << MSG::DEBUG << "Executing TrigmuRoI (" << name() + << ")" << endreq; + } + + int roi_id = 0; + + //-------------------------------------------------------------------------- + // Gather the Muon RoIs out of time by the + //-------------------------------------------------------------------------- + int BCID_diff = distance(m_trigMuonRoITool->begin_OutOfTimeRoIs(),m_trigMuonRoITool->end_OutOfTimeRoIs()); + + if(m_log.level() <= MSG::DEBUG) { + m_log << MSG::DEBUG << "=====================================================" << endreq; + m_log << MSG::DEBUG << " RoIs out of time with event BCID: Number of RoIs = " + << BCID_diff << endreq; + m_log << MSG::DEBUG << "=====================================================" << endreq; + } + + std::vector< std::pair<ROIB::MuCTPIRoI,int> >::const_iterator it_begin_ot, it_end_ot; + + if(m_log.level() <= MSG::DEBUG) + m_log << MSG::DEBUG << "===> execute() TrigMuonRoITool Test Algorithm: get begin in time iterator" << endreq; + + it_begin_ot = m_trigMuonRoITool->begin_OutOfTimeRoIs(); + + if(m_log.level() <= MSG::DEBUG) + m_log << MSG::DEBUG << "===> execute() TrigMuonRoITool Test Algorithm: get end in time iterator" << endreq; + + it_end_ot = m_trigMuonRoITool->end_OutOfTimeRoIs(); + + if(m_log.level() <= MSG::DEBUG) + m_log << MSG::DEBUG << "===> execute() TrigMuonRoITool Test Algorithm: print out of time RoIs" << endreq; + + for (std::vector< std::pair<ROIB::MuCTPIRoI,int> >::const_iterator it = m_trigMuonRoITool->begin_OutOfTimeRoIs(); + it != m_trigMuonRoITool->end_OutOfTimeRoIs(); ++it) { + + if(m_log.level() <= MSG::DEBUG) { + m_log << MSG::DEBUG << " Difference(RoI(BCID) - Event(BCID)) = " << (*it).second << endreq; + m_log << MSG::DEBUG << " ------------------------------------- " << endreq; + m_log << MSG::DEBUG << "RoIB word : 0x" << MSG::hex << ((*it).first).roIWord() << MSG::dec << endreq; + m_log << MSG::DEBUG << "Threshold : pt" << ((*it).first).pt() << endreq; + m_log << MSG::DEBUG << "Sector ID : " << ((*it).first).getSectorID() << endreq; + m_log << MSG::DEBUG << "Sector addr : 0x" << MSG::hex << ((*it).first).getSectorAddress() << MSG::dec << endreq; + m_log << MSG::DEBUG << "Sector overflow : " << ((*it).first).getSectorOverflow() << endreq; + m_log << MSG::DEBUG << "RoI overflow : " << ((*it).first).getRoiOverflow() << endreq; + m_log << MSG::DEBUG << "RoI number : " << ((*it).first).getRoiNumber() << endreq; + m_log << MSG::DEBUG << "IsHighestPt : " << ((*it).first).getCandidateIsHighestPt() << endreq; + m_log << MSG::DEBUG << "=================================================" << endreq; + } + + 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 ) m_RpcOutOfTime.push_back((*it).second); + else m_TgcOutOfTime.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(); + m_etaOutOfTime.push_back(eta); + m_phiOutOfTime.push_back(phi); + + + if ((*it).second >= m_minValueForOutOfTimeBC && + (*it).second <= m_maxValueForOutOfTimeBC ) { + HLT::TriggerElement* te; + TrigRoiDescriptor* roiDescriptor = + new TrigRoiDescriptor( ((*it).first).roIWord(), 0, roi_id, eta, phi, 0); + te = addRoI(type_out, roiDescriptor); + te->setActiveState(true); + if(m_log.level() <= MSG::DEBUG) { + m_log << MSG::DEBUG << "New RoI descriptor for " + << region << " created from word 0x" + << MSG::hex << ((*it).first).roIWord() << MSG::dec + << endreq; + } + } + roi_id += 1; + } + + + afterExecMonitors().ignore(); + + // everything's ok + return HLT::OK; +} + +// ================================================================================ +// ================================================================================ + +bool TrigmuRoI::reset() { + m_executed = false; + return AllTEAlgo::reset(); +} diff --git a/Trigger/TrigAlgorithms/TrigmuRoI/src/components/TrigmuRoI_entries.cxx b/Trigger/TrigAlgorithms/TrigmuRoI/src/components/TrigmuRoI_entries.cxx new file mode 100755 index 00000000000..2ee519828f3 --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigmuRoI/src/components/TrigmuRoI_entries.cxx @@ -0,0 +1,11 @@ +#include "TrigmuRoI/TrigmuRoI.h" + +#include "GaudiKernel/DeclareFactoryEntries.h" + + +DECLARE_ALGORITHM_FACTORY( TrigmuRoI ) + + +DECLARE_FACTORY_ENTRIES(TrigmuRoI) { + DECLARE_ALGORITHM( TrigmuRoI ) +} diff --git a/Trigger/TrigAlgorithms/TrigmuRoI/src/components/TrigmuRoI_load.cxx b/Trigger/TrigAlgorithms/TrigmuRoI/src/components/TrigmuRoI_load.cxx new file mode 100755 index 00000000000..ae747b726de --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigmuRoI/src/components/TrigmuRoI_load.cxx @@ -0,0 +1,3 @@ +#include "GaudiKernel/LoadFactoryEntries.h" + +LOAD_FACTORY_ENTRIES(TrigmuRoI) -- GitLab