diff --git a/InnerDetector/InDetConditions/TRT_ConditionsAlgs/src/TRTActiveCondAlg.cxx b/InnerDetector/InDetConditions/TRT_ConditionsAlgs/src/TRTActiveCondAlg.cxx index acbf1baa196d581105abdfa8fe58968ec5d6d800..53d4f1982c087c8560c0140221c7d7efc30f632a 100644 --- a/InnerDetector/InDetConditions/TRT_ConditionsAlgs/src/TRTActiveCondAlg.cxx +++ b/InnerDetector/InDetConditions/TRT_ConditionsAlgs/src/TRTActiveCondAlg.cxx @@ -154,7 +154,7 @@ StatusCode TRTActiveCondAlg::execute() float etaMax = etaCheck[1]; int etaMinBin = writeCdo->findEtaBin( etaMin ); int etaMaxBin = writeCdo->findEtaBin( etaMax ); - if (etaMin>=etaMax) ATH_MSG_WARNING("TRTCond::ActiveFractionSvc: etaMaxBin<etaMinBin " << etaMin << " " << etaMax << " " << thetaMin << " " << thetaMax); + if (etaMin>=etaMax) ATH_MSG_WARNING("TRTCond::ActiveFraction: etaMaxBin<etaMinBin " << etaMin << " " << etaMax << " " << thetaMin << " " << thetaMax); if (etaMinBin<0 && etaMaxBin<0) { ATH_MSG_WARNING("TRTCond::ActiveFraction: etaMaxBin<etaMinBin " << thetaMin << " " << thetaMax << " " << etaMin << " " << etaMax << " " << etaMinBin << " " << etaMaxBin << ", side: " << side); @@ -188,7 +188,7 @@ StatusCode TRTActiveCondAlg::execute() << ", count dead straws: " << countDead << " (" << deadStrawFraction << "%), straws skipped due to invalid phi, eta range: " << countPhiSkipped << " " << countEtaSkipped ); - if (countInvalidEtaValues) ATH_MSG_WARNING("TRT_ActiveFractionSvc: found invalid eta range, check: " << countInvalidEtaValues); + if (countInvalidEtaValues) ATH_MSG_WARNING("TRT_ActiveFraction: found invalid eta range, check: " << countInvalidEtaValues); diff --git a/InnerDetector/InDetConditions/TRT_RecoConditionsServices/ATLAS_CHECK_THREAD_SAFETY b/InnerDetector/InDetConditions/TRT_RecoConditionsServices/ATLAS_CHECK_THREAD_SAFETY deleted file mode 100644 index d54bf4021b97d227139146d7ab5acfb5d3a7009f..0000000000000000000000000000000000000000 --- a/InnerDetector/InDetConditions/TRT_RecoConditionsServices/ATLAS_CHECK_THREAD_SAFETY +++ /dev/null @@ -1 +0,0 @@ -InnerDetector/InDetConditions/TRT_RecoConditionsServices diff --git a/InnerDetector/InDetConditions/TRT_RecoConditionsServices/CMakeLists.txt b/InnerDetector/InDetConditions/TRT_RecoConditionsServices/CMakeLists.txt deleted file mode 100644 index 13d81215e34df8ae1cc17280fa8d415f9d95ab8f..0000000000000000000000000000000000000000 --- a/InnerDetector/InDetConditions/TRT_RecoConditionsServices/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration - -# Declare the package name: -atlas_subdir( TRT_RecoConditionsServices ) - -# Component(s) in the package: -atlas_add_component( TRT_RecoConditionsServices - src/*.cxx src/components/*.cxx - LINK_LIBRARIES GaudiKernel AthenaBaseComps StoreGateLib InDetIdentifier TRT_ReadoutGeometry TRT_ConditionsServicesLib InDetRecToolInterfaces ) diff --git a/InnerDetector/InDetConditions/TRT_RecoConditionsServices/src/TRT_ActiveFractionSvc.cxx b/InnerDetector/InDetConditions/TRT_RecoConditionsServices/src/TRT_ActiveFractionSvc.cxx deleted file mode 100644 index f5632411a78bf00ed49e96c590affe1f2d1e3a99..0000000000000000000000000000000000000000 --- a/InnerDetector/InDetConditions/TRT_RecoConditionsServices/src/TRT_ActiveFractionSvc.cxx +++ /dev/null @@ -1,239 +0,0 @@ -/* - Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration -*/ - -/*--------------------------------------------------------- - * @file TRT_ActiveFractionSvc.cxx - * @Service to provide active straw fraction in an eta-phi bin - * @author Denver Whittington <Denver.Whittington@cern.ch> - * @author Sasa Fratina <Sasa.Fratina@cern.ch> - *///------------------------------------------------------ - -// Header Includes -#include "TRT_ActiveFractionSvc.h" -#include "TRT_ConditionsServices/ITRT_StrawStatusSummaryTool.h" -#include "GaudiKernel/IIncidentSvc.h" - -#include "StoreGate/StoreGateSvc.h" -#include "InDetIdentifier/TRT_ID.h" -#include "TRT_ReadoutGeometry/TRT_BaseElement.h" - -#include "StoreGate/ReadCondHandle.h" -#include <cmath> - -////// -/// Constructor -TRT_ActiveFractionSvc::TRT_ActiveFractionSvc( const std::string& name, - ISvcLocator* pSvcLocator ) : - AthService( name, pSvcLocator ), - m_incSvc("IncidentSvc",name), - m_detStore("DetectorStore",name), - m_deadStrawTool("TRT_StrawStatusSummaryTool",this), - m_nBinsPhi(96) -{ - // Get properties from job options - declareProperty( "EtaBins", m_etaBins ); - declareProperty( "nBinsPhi", m_nBinsPhi ); - - // Build the eta bin list (if not specified in job options) - if ( m_etaBins.empty() ) { - // Default eta bins - m_etaBins.emplace_back(-2.1,-1.75 ); - m_etaBins.emplace_back(-1.75,-1.3 ); - m_etaBins.emplace_back(-1.3,-1.07 ); - m_etaBins.emplace_back(-1.07,-0.65 ); - m_etaBins.emplace_back(-0.65,-0.1 ); - m_etaBins.emplace_back(-0.1,0. ); - m_etaBins.emplace_back(0.,0.1 ); - m_etaBins.emplace_back(0.1,0.65 ); - m_etaBins.emplace_back(0.65,1.07 ); - m_etaBins.emplace_back(1.07,1.3 ); - m_etaBins.emplace_back(1.3,1.75 ); - m_etaBins.emplace_back(1.75,2.1 ); - } -} - -////// -/// Destructor -TRT_ActiveFractionSvc::~TRT_ActiveFractionSvc() {} - -////// -/// Initialize -StatusCode TRT_ActiveFractionSvc::initialize() { - StatusCode sc(StatusCode::SUCCESS); - - ATH_MSG_INFO( "TRT_ActiveFractionSvc:initialize()" ); - - // Get the TRT_StrawStatusSummarySvc - ATH_CHECK( m_deadStrawTool.retrieve()); - - // Register a callback to create the active fraction table at "BeginRun" - sc = m_incSvc.retrieve(); - if ( sc.isFailure() ) { - ATH_MSG_ERROR( "Couldn't get " << m_incSvc ); - return sc; - } - m_incSvc->addListener( this, std::string("BeginRun") ); - - ATH_CHECK(m_trtDetEleContKey.initialize()); - - // Build the phi bin list (equal bin widths) - double phiEdgeLow = -1. * M_PI; // Check this to be sure... - double deltaPhi = 2. * M_PI / (1. * m_nBinsPhi) ; - for ( int i = 0; i < m_nBinsPhi; ++i ) { - m_phiBins.emplace_back( phiEdgeLow + i*deltaPhi, phiEdgeLow + (i+1)*deltaPhi ); - } - // Initialize the table with 1.'s - std::vector<double> dummyPhiVec( m_phiBins.size(), 1. ); - std::vector<std::vector<double> > dummyTable( m_etaBins.size(), dummyPhiVec ); - m_activeFracTable = dummyTable; - - return sc; -} - -////// -/// IncidentSvc handler -void TRT_ActiveFractionSvc::handle( const Incident& inc ) { - - // BeginRun handler - if ( inc.type() == "BeginRun" ) { - /* - * Sasa July 22, 2009 - */ - if (msgLvl(MSG::INFO)) msg(MSG::INFO) << "TRT_ActiveFractionSvc: initialize TRT_ActiveFractionSvc table (BeginRun), N phi, eta bins: " - << m_phiBins.size() << ", " << m_etaBins.size() << endmsg; - - for (unsigned int i=0; i<m_etaBins.size(); i++) { - double etaMin = m_etaBins[i].first; - double etaMax = m_etaBins[i].second; - int bin = findEtaBin( (etaMin+etaMax)/2. ); - if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "TRT_ActiveFractionSvc: findEtaBin( "<< etaMin << ", " << etaMax << " ] = " << bin << endmsg; - } - - for (unsigned int i=0; i<m_phiBins.size(); i++) { - double phiMin = m_phiBins[i].first; - double phiMax = m_phiBins[i].second; - int bin = findPhiBin( (phiMin+phiMax)/2. ); - if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "TRT_ActiveFractionSvc: findPhiBin( "<< phiMin << ", " << phiMax << " ] = " << bin << endmsg; - } - - std::vector<int> dummyPhiVec( m_phiBins.size(), 0 ); - std::vector<std::vector<int> > dummyTableCountAll( m_etaBins.size(), dummyPhiVec ); - std::vector<std::vector<int> > dummyTableCountDead( m_etaBins.size(), dummyPhiVec ); - - StatusCode sc = m_detStore.retrieve(); - if ( sc.isFailure() ) { - if (msgLvl(MSG::ERROR)) msg(MSG::ERROR) << "TRT_ActiveFractionSvc::handle: Unable to retrieve DetectorStore" << endmsg; - return; - } - - - SG::ReadCondHandle<InDetDD::TRT_DetElementContainer> trtDetEleHandle(m_trtDetEleContKey); - const InDetDD::TRT_DetElementCollection* elements(trtDetEleHandle->getElements()); - if (not trtDetEleHandle.isValid() or elements==nullptr) { - ATH_MSG_FATAL(m_trtDetEleContKey.fullKey() << " is not available."); - return; - } - - const TRT_ID *TRTHelper = nullptr; - sc = m_detStore->retrieve(TRTHelper, "TRT_ID"); - if ( sc.isFailure() ) { - if (msgLvl(MSG::ERROR)) msg(MSG::ERROR) << "TRT_ActiveFractionSvc::handle: Could not get TRT ID helper, TRT_ActiveFraction == 1" << endmsg; - return; - } - - double rMinEndcap = 617.; - double rMaxEndcap = 1106.; - int countAll(0), countDead(0), countSaved(0), countPhiSkipped(0), countEtaSkipped(0), countInvalidEtaValues(0); - for (std::vector<Identifier>::const_iterator it = TRTHelper->straw_layer_begin(); it != TRTHelper->straw_layer_end(); ++it ) { - int nStrawsInLayer = TRTHelper->straw_max(*it); - for (int i=0; i<=nStrawsInLayer; i++) { - - Identifier id = TRTHelper->straw_id(*it, i); - // Make sure it is a straw_layer id - Identifier strawLayerId = TRTHelper->layer_id(id); - IdentifierHash hashId = TRTHelper->straw_layer_hash(strawLayerId); - bool status = m_deadStrawTool->get_status(id); - countAll++; if (status) countDead++; - - const Amg::Vector3D &strawPosition = elements->getDetectorElement(hashId)->center(id); - double phi = std::atan2( strawPosition.y(), strawPosition.x() ); - int phiBin = findPhiBin( phi ); - if (phiBin<0) { if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "TRT_ActiveFractionSvc::handle phiBin<0: " << phi << " " << phiBin << endmsg; countPhiSkipped++; continue; } - - // calculate etaMin, etaMax - int side = TRTHelper->barrel_ec(id); - double z = std::abs( strawPosition.z() ); - double thetaMin(0.), thetaMax(0.); - if (abs(side)==1) { // barrel - double zRange = 360.; // straw length / 2 - if ( TRTHelper->layer_or_wheel(id) == 0 && TRTHelper->straw_layer(id) < 9 ) zRange = 160.; // short straws - double r = std::sqrt( std::pow(strawPosition.x(), 2) + std::pow(strawPosition.y(), 2) ); - thetaMin = std::atan( r / (z+zRange) ); - thetaMax = ((z-zRange)>0.) ? std::atan( r / (z-zRange) ) : 1.57; // M_PI_2 - epsilon - } else { // endcap - thetaMin = std::atan( rMinEndcap / z ); - thetaMax = std::atan( rMaxEndcap / z ); - } - if (side<0) { // theta -> M_PI - theta - double thetaDummy = thetaMin; - thetaMin = M_PI - thetaMax; - thetaMax = M_PI - thetaDummy; - } - - double thetaCheck[] = {thetaMax, thetaMin}; - double etaCheck[] = {0., 0.}; - for (int ti=0; ti<2; ti++) { - if (thetaCheck[ti]<=0.||thetaCheck[ti]>=M_PI) if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "TRT_ActiveFractionSvc: theta " << ti << " " << thetaCheck[ti] << endmsg; - double tanTheta = std::tan(thetaCheck[ti]/2.); - if (tanTheta<=0.) { if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "TRT_ActiveFractionSvc: theta tan " << ti << " " << tanTheta << endmsg; countInvalidEtaValues++; continue; } - etaCheck[ti] = -std::log( tanTheta ); - } - double etaMin = etaCheck[0]; - double etaMax = etaCheck[1]; - - int etaMinBin = findEtaBin( etaMin ); - int etaMaxBin = findEtaBin( etaMax ); - if (etaMin>=etaMax) if (msgLvl(MSG::WARNING)) msg(MSG::WARNING) << "TRT_ActiveFractionSvc::handle etaMaxBin<etaMinBin " << etaMin << " " << etaMax << " " << thetaMin << " " << thetaMax << endmsg; - if (etaMinBin<0 && etaMaxBin<0) { - if (msgLvl(MSG::WARNING)) msg(MSG::WARNING) << "TRT_ActiveFractionSvc::handle etaMaxBin<etaMinBin " << thetaMin << " " << thetaMax - << " " << etaMin << " " << etaMax << " " << etaMinBin << " " << etaMaxBin << ", side: " << side << endmsg; - countEtaSkipped++; continue; - } - if (etaMinBin<0) etaMinBin = 0; - if (etaMaxBin<0) etaMaxBin = m_etaBins.size() - 1; - if (etaMaxBin<etaMinBin) if (msgLvl(MSG::WARNING)) msg(MSG::WARNING) << "TRT_ActiveFractionSvc::handle etaMaxBin<etaMinBin " << etaMinBin << " " << etaMaxBin << ", side: " << side << endmsg; - - countSaved++; // now save straw info for these bins - for (int iEta = etaMinBin; iEta <= etaMaxBin; iEta++) { - dummyTableCountAll[iEta][phiBin]++; - if (status) dummyTableCountDead[iEta][phiBin]++; - } - - } - } // end straw Identifier loop - - for (unsigned int i = 0; i < m_etaBins.size(); ++i) // fill the table - for (unsigned int j = 0; j < m_phiBins.size(); ++j) { - double deadFraction = 1. * dummyTableCountDead[i][j]; - if (dummyTableCountAll[i][j]>0) deadFraction /= (1. * dummyTableCountAll[i][j]); - m_activeFracTable[i][j] = 1. - deadFraction; - if ( msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "dummyTableCountDead: " << i << ", " << j << ", count " << dummyTableCountAll[i][j] << " dead " << deadFraction << endmsg; - } - - double deadStrawFraction = (1.*countDead) / (1.*countAll); - if (msgLvl(MSG::INFO)) msg(MSG::INFO) << "TRT_ActiveFractionSvc: initialize TRT_ActiveFractionSvc table finished, count all TRT straws: " << countAll - << ", count dead straws: " << countDead << " (" << deadStrawFraction << "%), straws skipped due to invalid phi, eta range: " - << countPhiSkipped << " " << countEtaSkipped << endmsg; - - if (countInvalidEtaValues && msgLvl(MSG::WARNING)) msg(MSG::WARNING) << "TRT_ActiveFractionSvc: found invalid eta range, check: " << countInvalidEtaValues << endmsg; - } // end if BeginRun - - return; -} - -////// -/// Finalize -StatusCode TRT_ActiveFractionSvc::finalize() { - return StatusCode::SUCCESS; -} diff --git a/InnerDetector/InDetConditions/TRT_RecoConditionsServices/src/TRT_ActiveFractionSvc.h b/InnerDetector/InDetConditions/TRT_RecoConditionsServices/src/TRT_ActiveFractionSvc.h deleted file mode 100644 index 7ac78bb1f1dee8ae0a7f6af2b77f44f7f32a2036..0000000000000000000000000000000000000000 --- a/InnerDetector/InDetConditions/TRT_RecoConditionsServices/src/TRT_ActiveFractionSvc.h +++ /dev/null @@ -1,132 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef TRT_ActiveFractionSvc_H -#define TRT_ActiveFractionSvc_H - -/*---------------------------------------------------------- - * @file TRT_ActiveFractionSvc.h - * @Service to provide active straw fraction in an eta-phi bin - * @author Denver Whittington <Denver.Whittington@cern.ch> - * @author Sasa Fratina <Sasa.Fratina@cern.ch> - *///------------------------------------------------------- - -// Header Includes -#include "InDetRecToolInterfaces/ITRT_ActiveFractionSvc.h" -#include "AthenaBaseComps/AthService.h" -#include "GaudiKernel/IIncidentListener.h" -#include "GaudiKernel/ToolHandle.h" -#include "GaudiKernel/ServiceHandle.h" -#include "TRT_ReadoutGeometry/TRT_DetElementContainer.h" -#include "StoreGate/ReadCondHandleKey.h" - -class StoreGateSvc; -class ITRT_StrawStatusSummaryTool; -class IIncidentSvc; - -/// Service to provide active straw fraction in an eta-phi bin -class TRT_ActiveFractionSvc : public AthService, - virtual public ITRT_ActiveFractionSvc, - virtual public IIncidentListener -{ - - public: - - TRT_ActiveFractionSvc( const std::string&, ISvcLocator* ); - virtual ~TRT_ActiveFractionSvc(); - - virtual StatusCode initialize(); - virtual StatusCode finalize(); - - virtual StatusCode queryInterface( const InterfaceID&, void** ); - - /// Returns the fraction of active straws in an eta-phi bin - double getActiveFraction( const Trk::TrackParameters* ); - - /// Handle IncidentSvc callbacks - void handle( const Incident& ); - - private: - - int findEtaBin( double ); - int findPhiBin( double ); - - /// Incident service - ServiceHandle<IIncidentSvc> m_incSvc; - - /// Dead/noisy straw service - ServiceHandle<StoreGateSvc> m_detStore; - ToolHandle<ITRT_StrawStatusSummaryTool> m_deadStrawTool; - - int m_nBinsPhi; - std::vector<std::pair<double,double> > m_etaBins; - std::vector<std::pair<double,double> > m_phiBins; - std::vector<std::vector<double> > m_activeFracTable; // [etaBin,phiBin] - - SG::ReadCondHandleKey<InDetDD::TRT_DetElementContainer> m_trtDetEleContKey{this, "TRTDetEleContKey", "TRT_DetElementContainer", "Key of TRT_DetElementContainer for TRT"}; - -}; - -////// -/// Query Interface -inline StatusCode TRT_ActiveFractionSvc::queryInterface( const InterfaceID& riid, void** ppvIf ) -{ - if ( ITRT_ActiveFractionSvc::interfaceID() == riid ) { - *ppvIf = dynamic_cast<ITRT_ActiveFractionSvc*>(this); - addRef(); - } else { - return AthService::queryInterface( riid, ppvIf ); - } - return StatusCode::SUCCESS; -} - -////// -/// Get Active Fraction -inline double TRT_ActiveFractionSvc::getActiveFraction( const Trk::TrackParameters* trkPar ) { - - double eta = trkPar->momentum().eta(); - double phi = trkPar->momentum().phi(); - - int etaBin = findEtaBin(eta); - if ( etaBin < 0 ) return 1.; - int phiBin = findPhiBin(phi); - if ( phiBin < 0 ) return 1.; - - // Get the fraction - return m_activeFracTable[etaBin][phiBin]; -} - -////// -/// Find eta bin number -inline int TRT_ActiveFractionSvc::findEtaBin(double eta) { - // Get the eta bin number - int etaBin = 0; - for ( ; etaBin < (int)m_etaBins.size(); ++etaBin ) { - std::pair<double,double> theBin = m_etaBins.at(etaBin); - if ( eta > theBin.first && eta <= theBin.second ) break; - } - if ( etaBin == (int)m_etaBins.size() ) { - ATH_MSG_DEBUG( "No eta bin defined contiaining this eta." ); - return -1; - } - return etaBin; -} - -////// -/// Find phi bin number -inline int TRT_ActiveFractionSvc::findPhiBin(double phi) { - // Get the phi bin number - int phiBin = 0; - for ( ; phiBin < (int)m_phiBins.size(); ++phiBin ) { - std::pair<double,double> theBin = m_phiBins.at(phiBin); - if ( phi > theBin.first && phi <= theBin.second ) break; - } - if ( phiBin == (int)m_phiBins.size() ) { - ATH_MSG_DEBUG( "No phi bin defined containing this eta." ); - return -1; - } - return phiBin; -} - -#endif // TRT_ActiveFractionSvc_H diff --git a/InnerDetector/InDetConditions/TRT_RecoConditionsServices/src/components/TRT_RecoConditionsServices_entries.cxx b/InnerDetector/InDetConditions/TRT_RecoConditionsServices/src/components/TRT_RecoConditionsServices_entries.cxx deleted file mode 100644 index 6dce9be491e00e387f98aa291178d6789792c390..0000000000000000000000000000000000000000 --- a/InnerDetector/InDetConditions/TRT_RecoConditionsServices/src/components/TRT_RecoConditionsServices_entries.cxx +++ /dev/null @@ -1,4 +0,0 @@ -#include "src/TRT_ActiveFractionSvc.h" - -DECLARE_COMPONENT( TRT_ActiveFractionSvc ) - diff --git a/InnerDetector/InDetRecTools/InDetRecToolInterfaces/InDetRecToolInterfaces/ITRT_ActiveFractionSvc.h b/InnerDetector/InDetRecTools/InDetRecToolInterfaces/InDetRecToolInterfaces/ITRT_ActiveFractionSvc.h deleted file mode 100644 index c410056a00c48e96491c402a94bbe62992d1146f..0000000000000000000000000000000000000000 --- a/InnerDetector/InDetRecTools/InDetRecToolInterfaces/InDetRecToolInterfaces/ITRT_ActiveFractionSvc.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef ITRT_ActiveFractionSvc_H -#define ITRT_ActiveFractionSvc_H - -/*---------------------------------------------------------- - * @file ITRT_ActiveFractionSvc.h - * @Service Interface for TRT_ActiveFractionSvc - * @author Denver Whittington <Denver.Whittington@cern.ch> - * @author Sasa Fratina <Sasa.Fratina@cern.ch> - *///------------------------------------------------------- - -// Header Includes -#include "GaudiKernel/IService.h" -#include "TrkParameters/TrackParameters.h" - -// Interface definition -class ITRT_ActiveFractionSvc : virtual public IService { - - public: - - /// Returns the fraction of active straws in an eta-phi bin - virtual double getActiveFraction( const Trk::TrackParameters* ) = 0; - - /// Interface ID declaration - static const InterfaceID& interfaceID(); - -}; - -/// Interface ID for this Service -inline const InterfaceID& ITRT_ActiveFractionSvc::interfaceID() { - static const InterfaceID IID("ITRT_ActiveFractionSvc",1,0); - return IID; -} - -#endif // ITRT_ActiveFractionSvc_H