ATLAS Offline Software
TruthSegmentMaker.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 #ifndef MUONTRUTHSEGMENTMAKER_TRUTHSEGMENTMAKER_H
5 #define MUONTRUTHSEGMENTMAKER_TRUTHSEGMENTMAKER_H
6 
7 
12 #include "StoreGate/WriteHandle.h"
14 
15 
22 
24 
25 namespace MuonR4{
26  /*** @brief The TruthSegmentMaker collects hits inside the chamber stemming from the same HepMC::GenParticle.
27  * The particle state at the first sim hit is propagated via a simple straight line onto the plane
28  * z=0 in the sector frame. The parameters are then translated into the global frame and a xAOD::MuonSegment
29  * is created. The segment hit summary is written based on the sim hit type. If a gasGap has eta & phi measurements,
30  * the counters in the respective categories are each increased for the given sim hit. Finally, a vector of ElementLinks
31  * pointing to the sim hits is decorated to the segment. */
33  public:
34  using AthReentrantAlgorithm::AthReentrantAlgorithm;
35 
36  ~TruthSegmentMaker() = default;
37 
38  StatusCode initialize() override final;
39  StatusCode execute(const EventContext& ctx) const override;
40 
41  private:
46  const Identifier& chanId) const;
47 
52 
53 
54 
56  using HitLinkVec_t = std::vector<EleLink_t>;
57  using LinkDecor_t = SG::WriteDecorHandle<xAOD::MuonSegmentContainer, HitLinkVec_t>;
58  using FloatDecor_t = SG::WriteDecorHandle<xAOD::MuonSegmentContainer, float>;
59 
60  using SegPars_t = xAOD::MeasVector<SegmentFit::toInt(SegmentFit::ParamDefs::nPars)>;
61  using SegParDecor_t = SG::WriteDecorHandle<xAOD::MuonSegmentContainer, SegPars_t>;
62 
71  const EventContext& ctx):
72  segments{outContainer},
73  paramDecor{parent.m_locParKey, ctx},
74  hitLinkDecor{parent.m_eleLinkKey, ctx},
75  chargeDecor{parent.m_qKey, ctx},
76  ptDecor{parent.m_ptKey, ctx} {}
88  };
96  xAOD::MuonSegment* constructSegmentFromHits(const EventContext& ctx,
97  const Amg::Transform3D& locToGlob,
98  const SimHitVec_t& hits,
99  WriteDecorHolder& writeShip) const;
109  void buildSegmentsFromBkg(const EventContext& ctx,
110  const Amg::Transform3D& locToGlob,
111  const SimHitVec_t& simHits,
112  WriteDecorHolder& writeShip) const;
113 
115  float muonPt(const xAOD::MuonSimHit& hit, const Amg::Vector3D& globDir) const;
121  float hitUncertainty(const EventContext& ctx, const xAOD::MuonSimHit& hit) const;
123  ServiceHandle<Muon::IMuonIdHelperSvc> m_idHelperSvc{this, "IdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"};
127  SG::ReadHandleKey<ActsGeometryContext> m_geoCtxKey{this, "AlignmentKey", "ActsAlignment", "cond handle key"};
129  SG::WriteHandleKey<xAOD::MuonSegmentContainer> m_segmentKey{this, "WriteKey", "TruthSegmentsR4"};
139  Gaudi::Property<bool> m_useOnlyMuonHits{this, "useOnlyMuonHits", true};
141  Gaudi::Property<bool> m_includePileUpHits{this, "includePileUpHits", true};
143  Gaudi::Property<float> m_pileUpHitMinE{this, "energyThresholdPileUp", 1.*Gaudi::Units::GeV};
145  Gaudi::Property<float> m_pileUpHitELoss{this, "pileUpHitELoss", 5.*Gaudi::Units::MeV};
147  Gaudi::Property<float> m_pileUpHitAngleCone{this, "pileUpHitAngleCone", 1.*Gaudi::Units::deg};
149  Gaudi::Property<float> m_pileUpHitDistance{this, "pileUpHitDistance", 2.*Gaudi::Units::m};
151  Gaudi::Property<float> m_idCylinderR{this, "IdCylinderR", 1.1*Gaudi::Units::m};
153  Gaudi::Property<float> m_idCylinderHalfZ{this, "IdCylinderHalfZ", 3.2*Gaudi::Units::m};
158  "Conditions object containing the calibrations"};
160  SG::ReadCondHandleKey<NswErrorCalibData> m_nswUncertKey{this, "NswErrorKey", "NswUncertData",
161  "Key of the parametrized NSW uncertainties"};
162  };
163 }
164 #endif
ReadHandleKeyArray.h
SG::WriteDecorHandleKey< xAOD::MuonSegmentContainer >
xAOD::MuonSimHit_v1
Definition: MuonSimHit_v1.h:18
MuonR4::TruthSegmentMaker::m_eleLinkKey
SG::WriteDecorHandleKey< xAOD::MuonSegmentContainer > m_eleLinkKey
Decoration key of the associated sim hit links.
Definition: TruthSegmentMaker.h:131
MuonR4::SegmentFit::ParamDefs
ParamDefs
This file defines the parameter enums in the Trk namespace.
Definition: MuonHoughDefs.h:29
GeV
#define GeV
Definition: PhysicsAnalysis/TauID/TauAnalysisTools/Root/HelperFunctions.cxx:18
TRTCalib_Extractor.hits
hits
Definition: TRTCalib_Extractor.py:35
SG
Forward declaration.
Definition: CaloCellPacker_400_500.h:32
MuonR4::TruthSegmentMaker::m_geoCtxKey
SG::ReadHandleKey< ActsGeometryContext > m_geoCtxKey
Key to the geometry context.
Definition: TruthSegmentMaker.h:127
MuonGMR4::MuonDetectorManager
Definition: MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/MuonReadoutGeometryR4/MuonDetectorManager.h:62
MuonR4::TruthSegmentMaker::buildSegmentsFromBkg
void buildSegmentsFromBkg(const EventContext &ctx, const Amg::Transform3D &locToGlob, const SimHitVec_t &simHits, WriteDecorHolder &writeShip) const
Attempts to assemble truth segments from a list of loose sim hits, i.e., the hits are stemming from a...
Definition: TruthSegmentMaker.cxx:111
MdtCalibDataContainer.h
MuonR4::TruthSegmentMaker::SimHitVec_t
std::vector< HitPosTuple_t > SimHitVec_t
Definition: TruthSegmentMaker.h:51
MuonR4::TruthSegmentMaker::execute
StatusCode execute(const EventContext &ctx) const override
Definition: TruthSegmentMaker.cxx:281
MuonR4::TruthSegmentMaker::m_idCylinderR
Gaudi::Property< float > m_idCylinderR
ID / ITk cylinder radius.
Definition: TruthSegmentMaker.h:151
deg
#define deg
Definition: SbPolyhedron.cxx:17
xAOD::MuonSegment_v1
Class describing a MuonSegment.
Definition: MuonSegment_v1.h:33
SG::HandleKeyArray
Definition: StoreGate/StoreGate/HandleKeyArray.h:38
xAOD
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Definition: ICaloAffectedTool.h:24
MuonR4::TruthSegmentMaker::m_detMgr
const MuonGMR4::MuonDetectorManager * m_detMgr
Pointer to the muon readout geometry.
Definition: TruthSegmentMaker.h:155
MuonR4::TruthSegmentMaker::m_pileUpHitMinE
Gaudi::Property< float > m_pileUpHitMinE
Minimum energy threshold for pile up hits to be converted
Definition: TruthSegmentMaker.h:143
MuonR4::TruthSegmentMaker::m_qKey
SG::WriteDecorHandleKey< xAOD::MuonSegmentContainer > m_qKey
Decoration key of the muon charge
Definition: TruthSegmentMaker.h:137
const
bool const RAWDATA *ch2 const
Definition: LArRodBlockPhysicsV0.cxx:560
SG::ReadHandleKey< ActsGeometryContext >
MuonR4::TruthSegmentMaker::WriteDecorHolder::segments
xAOD::MuonSegmentContainer & segments
Reference to the mutable segment container.
Definition: TruthSegmentMaker.h:78
MuonR4::TruthSegmentMaker::WriteDecorHolder::hitLinkDecor
LinkDecor_t hitLinkDecor
Decorator to define the links to the sim hits building the truth segment.
Definition: TruthSegmentMaker.h:83
MuonR4::TruthSegmentMaker::SegPars_t
xAOD::MeasVector< SegmentFit::toInt(SegmentFit::ParamDefs::nPars)> SegPars_t
Definition: TruthSegmentMaker.h:60
MuonR4::TruthSegmentMaker::m_ptKey
SG::WriteDecorHandleKey< xAOD::MuonSegmentContainer > m_ptKey
Decoration key of the associated particle pt.
Definition: TruthSegmentMaker.h:133
MuonSegmentContainer.h
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:74
python.SystemOfUnits.MeV
float MeV
Definition: SystemOfUnits.py:172
MuonR4::TruthSegmentMaker::WriteDecorHolder
Helper struct to ship the write DecorHandles and the reference to the output segment container throug...
Definition: TruthSegmentMaker.h:65
MuonR4::TruthSegmentMaker::constructSegmentFromHits
xAOD::MuonSegment * constructSegmentFromHits(const EventContext &ctx, const Amg::Transform3D &locToGlob, const SimHitVec_t &hits, WriteDecorHolder &writeShip) const
Takes a list of related sim hits and transforms them into a truth segment.
Definition: TruthSegmentMaker.cxx:176
MuonR4::TruthSegmentMaker::m_useOnlyMuonHits
Gaudi::Property< bool > m_useOnlyMuonHits
Build segments from muon hits only.
Definition: TruthSegmentMaker.h:139
MuonR4::TruthSegmentMaker::m_locParKey
SG::WriteDecorHandleKey< xAOD::MuonSegmentContainer > m_locParKey
Decoration key of the local parameters.
Definition: TruthSegmentMaker.h:135
WriteHandle.h
Handle class for recording to StoreGate.
MuonR4::TruthSegmentMaker::m_idCylinderHalfZ
Gaudi::Property< float > m_idCylinderHalfZ
ID / Itk cylinder half length.
Definition: TruthSegmentMaker.h:153
MuonR4::TruthSegmentMaker
Definition: TruthSegmentMaker.h:32
SG::WriteHandleKey< xAOD::MuonSegmentContainer >
WriteDecorHandleKey.h
Property holding a SG store/key/clid/attr name from which a WriteDecorHandle is made.
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
vector
Definition: MultiHisto.h:13
MuonR4::TruthSegmentMaker::HitLinkVec_t
std::vector< EleLink_t > HitLinkVec_t
Definition: TruthSegmentMaker.h:56
SG::WriteDecorHandle< xAOD::MuonSegmentContainer, HitLinkVec_t >
Amg::Transform3D
Eigen::Affine3d Transform3D
Definition: GeoPrimitives.h:46
MuonR4::TruthSegmentMaker::m_pileUpHitDistance
Gaudi::Property< float > m_pileUpHitDistance
Maximum separation between two pile-up hits.
Definition: TruthSegmentMaker.h:149
WriteDecorHandle.h
Handle class for adding a decoration to an object.
MuonDetectorManager.h
test_pyathena.parent
parent
Definition: test_pyathena.py:15
MuonSimHitContainer.h
NswErrorCalibData.h
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
ActsGeometryContext
Include the GeoPrimitives which need to be put first.
Definition: ActsGeometryContext.h:27
xAOD::MuonSegmentContainer
MuonSegmentContainer_v1 MuonSegmentContainer
Definition of the current "MuonSegment container version".
Definition: MuonSegmentContainer.h:14
xAOD::MeasVector
Eigen::Matrix< float, N, 1 > MeasVector
Abrivation of the Matrix & Covariance definitions.
Definition: MeasurementDefs.h:53
AthReentrantAlgorithm.h
WriteHandleKey.h
Property holding a SG store/key/clid from which a WriteHandle is made.
MuonHoughDefs.h
MuonR4::TruthSegmentMaker::m_pileUpHitELoss
Gaudi::Property< float > m_pileUpHitELoss
Maximum energy loss between two pile-up hits.
Definition: TruthSegmentMaker.h:145
Amg
Definition of ATLAS Math & Geometry primitives (Amg)
Definition: AmgStringHelpers.h:19
MuonR4::SegmentFit::toInt
constexpr int toInt(const ParamDefs p)
Definition: MuonHoughDefs.h:42
MuonR4::TruthSegmentMaker::WriteDecorHolder::chargeDecor
FloatDecor_t chargeDecor
Decorate the segment's charge.
Definition: TruthSegmentMaker.h:85
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
MuonR4::TruthSegmentMaker::initialize
StatusCode initialize() override final
Definition: TruthSegmentMaker.cxx:31
MuonR4
This header ties the generic definitions in this package.
Definition: HoughEventData.h:16
SG::ReadCondHandleKey< MuonCalib::MdtCalibDataContainer >
MuonR4::TruthSegmentMaker::m_includePileUpHits
Gaudi::Property< bool > m_includePileUpHits
Construct segments from pile-up hits without GenParticleLink.
Definition: TruthSegmentMaker.h:141
MuonR4::TruthSegmentMaker::toChamber
Amg::Transform3D toChamber(const ActsGeometryContext &gctx, const Identifier &chanId) const
Returns the transform from the local simHit frame -> chamber frame.
Definition: TruthSegmentMaker.cxx:101
MuonR4::TruthSegmentMaker::m_readKeys
SG::ReadHandleKeyArray< xAOD::MuonSimHitContainer > m_readKeys
List of sim hit containers from which the truth segments shall be retrieved.
Definition: TruthSegmentMaker.h:125
MuonR4::TruthSegmentMaker::WriteDecorHolder::WriteDecorHolder
WriteDecorHolder(xAOD::MuonSegmentContainer &outContainer, const TruthSegmentMaker &parent, const EventContext &ctx)
Constructor taking the reference to the mutable output container storing the truth segments,...
Definition: TruthSegmentMaker.h:69
MuonR4::TruthSegmentMaker::m_pileUpHitAngleCone
Gaudi::Property< float > m_pileUpHitAngleCone
Maximum scattering angle between two pile-up hits.
Definition: TruthSegmentMaker.h:147
MuonR4::TruthSegmentMaker::WriteDecorHolder::paramDecor
SegParDecor_t paramDecor
Decorator to assign the local segment parameters.
Definition: TruthSegmentMaker.h:80
MuonR4::TruthSegmentMaker::WriteDecorHolder::ptDecor
FloatDecor_t ptDecor
Decorate the particle's pt at that place.
Definition: TruthSegmentMaker.h:87
MuonR4::TruthSegmentMaker::HitPosTuple_t
std::tuple< const xAOD::MuonSimHit *, Amg::Vector3D, Amg::Vector3D > HitPosTuple_t
Tuple consisting out of pointer to the sim hit and the position & direction expressed in the chamber'...
Definition: TruthSegmentMaker.h:50
private
#define private
Definition: xAODTruthCnvAlg.h:20
MuonR4::TruthSegmentMaker::m_segmentKey
SG::WriteHandleKey< xAOD::MuonSegmentContainer > m_segmentKey
Key under which the segment Container will be recorded in StoreGate.
Definition: TruthSegmentMaker.h:129
MuonR4::TruthSegmentMaker::m_idHelperSvc
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
IdHelperSvc to decode the Identifiers.
Definition: TruthSegmentMaker.h:123
MuonR4::TruthSegmentMaker::m_nswUncertKey
SG::ReadCondHandleKey< NswErrorCalibData > m_nswUncertKey
Data dependency on the Nsw calibration container to estimate the uncertaintys.
Definition: TruthSegmentMaker.h:160
MuonR4::TruthSegmentMaker::m_mdtCalibKey
SG::ReadCondHandleKey< MuonCalib::MdtCalibDataContainer > m_mdtCalibKey
Data dependency on the Mdt calibration container to calculate the uncertainty.
Definition: TruthSegmentMaker.h:157
MuonR4::TruthSegmentMaker::hitUncertainty
float hitUncertainty(const EventContext &ctx, const xAOD::MuonSimHit &hit) const
Evaluates the hit uncertainty.
Definition: TruthSegmentMaker.cxx:52
MuonR4::TruthSegmentMaker::muonPt
float muonPt(const xAOD::MuonSimHit &hit, const Amg::Vector3D &globDir) const
Returns the muon pt from the sim hit.
Definition: TruthSegmentMaker.cxx:93
MuonR4::TruthSegmentMaker::~TruthSegmentMaker
~TruthSegmentMaker()=default
xAOD::MuonSimHitContainer
MuonSimHitContainer_v1 MuonSimHitContainer
Define the version of the pixel cluster container.
Definition: MuonSimHitContainer.h:14
xAOD::MuonSimHit
MuonSimHit_v1 MuonSimHit
Defined the version of the MuonSimHit.
Definition: MuonSimHit.h:12
IMuonIdHelperSvc.h
python.SystemOfUnits.m
float m
Definition: SystemOfUnits.py:106
ServiceHandle< Muon::IMuonIdHelperSvc >
Identifier
Definition: IdentifierFieldParser.cxx:14