9#include "GaudiKernel/SystemOfUnits.h"
16#include <unordered_map>
20 constexpr int encodeId(
const int8_t stName,
const int8_t stEta,
21 const int8_t sector) {
22 return (sector <<16 |stEta << 8| stName);
24 constexpr double precCutOff(
const double value,
const double cutOff = 1.e-15) {
25 return Acts::abs(value) > cutOff ?
value : 0.;
39 return StatusCode::SUCCESS;
44 if (truthHits.size()) {
45 return m_detMgr->getSectorEnvelope((*truthHits.begin())->identify());
50 ATH_MSG_WARNING(
"No matching hits were found. Neither the simulated ones or the reconstructed");
55 const EventContext & ctx = Gaudi::Hive::currentContext();
56 std::ofstream
file{std::format(
"event-{:09}-MuonTruthSegment.csv", ++
m_event)};
57 constexpr std::string_view delim =
",";
58 file<<
"sectorId"<<delim;
59 file<<
"globalPositionX"<<delim;
60 file<<
"globalPositionY"<<delim;
61 file<<
"globalPositionZ"<<delim;
63 file<<
"globalDirectionX"<<delim;
64 file<<
"globalDirectionY"<<delim;
65 file<<
"globalDirectionZ"<<delim;
68 file<<
"localPositionX"<<delim;
69 file<<
"localPositionY"<<delim;
70 file<<
"localPositionZ"<<delim;
72 file<<
"localDirectionX"<<delim;
73 file<<
"localDirectionY"<<delim;
74 file<<
"localDirectionZ"<<delim;
77 file<<
"timeError"<<delim;
78 file<<
"chiSquared"<<delim;
80 file<<
"precisionHits"<<delim;
81 file<<
"phiLayers"<<delim;
82 file<<
"trigEtaLayers"<<delim;
104 const int secId = encodeId(
static_cast<int8_t
>(sector->
chamberIndex()),
108 float seg_t0 = segment->t0();
109 float seg_t0error = segment->t0error();
112 float seg_chiSquared = segment->chiSquared();
113 float seg_numberDoF = segment->numberDoF();
116 int seg_PrecisionHits = segment->nPrecisionHits();
117 int seg_PhiLayers = segment->nPhiLayers();
118 int seg_TrigEtaLayers = segment->nTrigEtaLayers();
127 ATH_MSG_VERBOSE(
"chiSquared: "<<seg_chiSquared<<
" numberDoF: "<<seg_numberDoF);
128 ATH_MSG_VERBOSE(
"nPrecisionHits: "<<seg_PrecisionHits<<
" nPhiLayers: "<<seg_PhiLayers<<
" nTrigEtaLayers: "<<seg_TrigEtaLayers);
132 file<<precCutOff(globPos.x())<<delim;
133 file<<precCutOff(globPos.y())<<delim;
134 file<<precCutOff(globPos.z())<<delim;
135 file<<precCutOff(globDir.x())<<delim;
136 file<<precCutOff(globDir.y())<<delim;
137 file<<precCutOff(globDir.z())<<delim;
139 file<<precCutOff(locPos.x())<<delim;
140 file<<precCutOff(locPos.y())<<delim;
141 file<<precCutOff(locPos.z())<<delim;
142 file<<precCutOff(locDir.x())<<delim;
143 file<<precCutOff(locDir.y())<<delim;
144 file<<precCutOff(locDir.z())<<delim;
147 file<<precCutOff(seg_t0)<<delim;
148 file<<precCutOff(seg_t0error)<<delim;
149 file<<precCutOff(seg_chiSquared)<<delim;
150 file<<seg_numberDoF<<delim;
151 file<<seg_PrecisionHits<<delim;
152 file<<seg_PhiLayers<<delim;
153 file<<seg_TrigEtaLayers<<delim;
156 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
const ServiceHandle< StoreGateSvc > & detStore() const
A spectrometer sector forms the envelope of all chambers that are placed in the same MS sector & laye...
int8_t side() const
Returns the side of the MS-sector 1 -> A side ; -1 -> C side.
Amg::Transform3D globalToLocalTrans(const ActsTrk::GeometryContext &gctx) const
Returns the global -> local transformation from the ATLAS global.
int sector() const
Returns the sector of the MS-sector.
Muon::MuonStationIndex::ChIndex chamberIndex() const
Returns the chamber index scheme.
const MuonGMR4::SpectrometerSector * msSector(const xAOD::MuonSegment &segment) const
SG::ReadHandleKey< xAOD::MuonSegmentContainer > m_inSegmentKey
SG::ReadHandleKey< ActsTrk::GeometryContext > m_geoCtxKey
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
StatusCode initialize() override
ServiceHandle< Muon::IMuonEDMHelperSvc > m_edmHelperSvc
const MuonGMR4::MuonDetectorManager * m_detMgr
StatusCode execute() override
This is the common class for 3D segments used in the muon spectrometer.
const ElementLink< ::Trk::SegmentCollection > & muonSegment() const
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
Eigen::Affine3d Transform3D
Eigen::Matrix< double, 3, 1 > Vector3D
This header ties the generic definitions in this package.
std::unordered_set< const xAOD::MuonSimHit * > getMatchingSimHits(const xAOD::MuonSegment &segment)
: Returns all sim hits matched to a xAOD::MuonSegment
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
MuonSegmentContainer_v1 MuonSegmentContainer
Definition of the current "MuonSegment container version".
MuonSegment_v1 MuonSegment
Reference the current persistent version: