ATLAS Offline Software
Loading...
Searching...
No Matches
MuonHitTimingTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "MuonHitTimingTool.h"
8
9
10namespace Muon {
11
12 MuonHitTimingTool::MuonHitTimingTool(const std::string& t, const std::string& n, const IInterface* p):
13 base_class(t,n,p),
14 m_hitTimingTools(this) {
15 using namespace MuonStationIndex;
16 for( int tech = 0;tech< toInt(TechnologyIndex::TechnologyIndexMax);++tech ){
17 if( tech == toInt(TechnologyIndex::RPC) ) m_hitTimingTools.push_back(ToolHandle<IMuonHitTimingTool>("Muon::RPC_TimingTool/RPC_TimingTool"));
18 else m_hitTimingTools.push_back(ToolHandle<IMuonHitTimingTool>(""));
19 }
20
21 }
22
24
25 ATH_CHECK(m_idHelperSvc.retrieve());
26 using namespace MuonStationIndex;
27 // ensure that the number of tool handles corresponds to the number of technologies
28 if( static_cast<int>(m_hitTimingTools.size()) != toInt(TechnologyIndex::TechnologyIndexMax) ){
29 ATH_MSG_ERROR(" The MuonHitTimingTool ToolHandleArray SHOULD contain exactly "
30 << toInt(TechnologyIndex::TechnologyIndexMax) << " ToolHandles (they can be empty). ");
31 return StatusCode::FAILURE;
32 }
33
34 // loop over timing tool handles and check that they handle the technology they are supposed to, if not return a FAILURE
35 for( int tech = 0;tech<toInt(TechnologyIndex::TechnologyIndexMax);++tech ){
36 // get handle, accept empty handles
37 auto& toolHandle = m_hitTimingTools[tech];
38 ATH_MSG_DEBUG(" tech " << technologyName(static_cast<MuonStationIndex::TechnologyIndex>(tech)) << " " << toolHandle);
39 if( toolHandle.empty() ) continue;
40 ATH_CHECK(toolHandle.retrieve());
41 }
42 return StatusCode::SUCCESS;
43 }
44
45 IMuonHitTimingTool::TimingResult MuonHitTimingTool::calculateTimingResult( const std::vector<const MuonClusterOnTrack*>& hits ) const {
46
47 // treat case of no hits and the case the first pointer is zero (should not happen)
48 if( hits.empty() || !hits.front()) return {};
49
50 // for now assume that all hits are of the same technolgy
51 Identifier id = hits.front()->identify();
52 using namespace MuonStationIndex;
53 TechnologyIndex tech = m_idHelperSvc->technologyIndex(id);
54
55 // get handle and use it if it is not empty
56 const ToolHandle<IMuonHitTimingTool>& toolHandle = m_hitTimingTools[toInt(tech)];
57 if( toolHandle.empty() ) {
58 ATH_MSG_VERBOSE("Unable to fill timing, timing tool missing. Tech = " << technologyName(tech) );
59 return {};
60 }
61 return toolHandle->calculateTimingResult(hits);
62 }
63}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
virtual StatusCode initialize() override final
standard initialization method
ToolHandleArray< IMuonHitTimingTool > m_hitTimingTools
virtual TimingResult calculateTimingResult(const std::vector< const MuonClusterOnTrack * > &hits) const override final
Calculate the time offset of a given set of hits wrt to the current bunch.
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
MuonHitTimingTool(const std::string &, const std::string &, const IInterface *)
TechnologyIndex
enum to classify the different layers in the muon spectrometer
constexpr int toInt(const EnumType enumVal)
const std::string & technologyName(TechnologyIndex index)
convert LayerIndex into a string
NRpcCablingAlg reads raw condition data and writes derived condition data to the condition store.
simple struct holding the result of the tool