ATLAS Offline Software
SpacePointMakerAlg.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 MUONSPACEPOINTFORMATION_MUONSPACEPOINTMAKERALG_H
5 #define MUONSPACEPOINTFORMATION_MUONSPACEPOINTMAKERALG_H
6 
9 
13 
14 
15 
24 
25 
26 namespace MuonR4{
28  public:
29  using AthReentrantAlgorithm::AthReentrantAlgorithm;
30 
31  ~SpacePointMakerAlg() = default;
32 
33  StatusCode execute(const EventContext& ctx) const override;
34  StatusCode initialize() override;
35  StatusCode finalize() override;
36 
37  private:
41  template<class MeasType> Amg::Transform3D toChamberTransform(const ActsGeometryContext& gctx,
42  const Amg::Transform3D& sectorTrans,
43  const MeasType* meas) const;
47  template<class MeasType> Amg::Vector3D positionInChamber(const MeasType* meas,
48  const Amg::Transform3D& toChamberTrans) const;
52  template<class MeasType> Amg::Vector3D channelDirInChamber(const MeasType* meas,
53  const Amg::Transform3D& toChamberTrans) const;
58  template<class MeasType> Amg::Vector3D channelNormalInChamber(const MeasType* meas,
59  const Amg::Transform3D& toChamberTrans) const;
64  template<class MeasType> AmgSymMatrix(2) computeCov(const MeasType* primaryMeas,
72  AmgSymMatrix(2) computeCov(const xAOD::UncalibratedMeasurement* primaryMeas,
73  const xAOD::UncalibratedMeasurement* secondaryMeas,
74  const Amg::Vector3D& nor1,
75  const Amg::Vector3D& nor2) const;
80  template <class MeasType> void fillSpacePoint (std::vector<SpacePoint>& pointColl,
81  const MeasType* primaryMeas,
82  const Amg::Transform3D& toChamberTrans) const;
89  template <class MeasType> void fillSpacePoint (std::vector<SpacePoint>& pointColl,
90  const MeasType* primaryMeas,
91  const MeasType* secondaryMeas,
92  const Amg::Transform3D& toChamberTrans_eta,
93  const Amg::Transform3D& toChamberTrans_phi) const;
94 
102  public:
107 
109  void addToStat(const std::vector<SpacePoint>& spacePoints);
112  void dumpStatisics(MsgStream& msg) const;
113 
114  private:
117  struct StatField{
119  unsigned int measEtaPhi{0};
121  unsigned int measEta{0};
123  unsigned int measPhi{0};
126  unsigned int allHits() const;
127  };
129  struct FieldKey{
132  StIdx_t stIdx{StIdx_t::StUnknown};
133  TechIdx_t techIdx{TechIdx_t::TechnologyUnknown};
134  int eta{0};
135  bool operator<(const FieldKey& other) const;
136  };
137 
139  std::mutex m_mutex{};
140  using StatMap_t = std::map<FieldKey, StatField>;
141  StatMap_t m_map{};
142  };
148  std::vector<SpacePoint> etaHits{};
150  std::vector<SpacePoint> phiHits{};
151  };
153  using PreSortedSpacePointMap = std::unordered_map<const MuonGMR4::SpectrometerSector*, SpacePointsPerChamber>;
154 
155 
165  template <class ContType>
166  StatusCode loadContainerAndSort(const EventContext& ctx,
169 
171  using SpacePointBucketVec = std::vector<SpacePointBucket>;
172 
182  void distributePointsAndStore(SpacePointsPerChamber&& hitsPerChamber,
183  SpacePointContainer& finalContainer) const;
189  void distributePrimaryPoints(std::vector<SpacePoint>&& spacePoints,
190  SpacePointBucketVec& splittedContainer) const;
195  void distributePhiPoints(std::vector<SpacePoint>&& spacePoints,
196  SpacePointBucketVec& splittedContainer) const;
197 
201  bool splitBucket(const SpacePoint& spacePoint,
202  const double firstSpPos,
203  const SpacePointBucketVec& sortedPoints) const;
208  void newBucket(const SpacePoint& refSp,
209  SpacePointBucketVec& sortedPoints) const;
217  template <class PrdType>
218  bool passOccupancy2D(const std::vector<const PrdType*>& etaHits,
219  const std::vector<const PrdType*>& phiHits) const;
220 
221  SG::ReadHandleKey<xAOD::MdtDriftCircleContainer> m_mdtKey{this, "MdtKey", "xMdtMeasurements",
222  "Key to the uncalibrated Drift circle measurements"};
223 
224  SG::ReadHandleKey<xAOD::RpcMeasurementContainer> m_rpcKey{this, "RpcKey", "xRpcMeasurements",
225  "Key to the uncalibrated 1D rpc hits"};
226 
228  "Key to the uncalibrated 1D tgc hits"};
229 
230  SG::ReadHandleKey<xAOD::MMClusterContainer> m_mmKey{this, "MmKey", "xAODMMClusters",
231  "Key to the uncalibrated 1D Mm hits"};
232 
233  SG::ReadHandleKey<xAOD::sTgcMeasContainer> m_stgcKey{this, "sTgcKey", "xAODsTgcMeasurements"};
234 
235 
236  SG::ReadHandleKey<ActsGeometryContext> m_geoCtxKey{this, "AlignmentKey", "ActsAlignment", "cond handle key"};
237 
238  ServiceHandle<Muon::IMuonIdHelperSvc> m_idHelperSvc{this, "IdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"};
239 
240  SG::WriteHandleKey<SpacePointContainer> m_writeKey{this, "WriteKey", "MuonSpacePoints"};
241 
242  Gaudi::Property<double> m_spacePointWindow{this, "spacePointWindowSize", 0.8*Gaudi::Units::m,
243  "Maximal distance between consecutive hits in a bucket"};
244 
245  Gaudi::Property<double> m_maxBucketLength{this, "maxBucketLength", 2.*Gaudi::Units::m,
246  "Maximal size of a space point bucket"};
247 
248  Gaudi::Property<double> m_spacePointOverlap{this, "spacePointOverlap", 25.*Gaudi::Units::cm,
249  "Hits that are within <spacePointOverlap> of the bucket margin. "
250  "Are copied to the next bucket"};
251 
252  Gaudi::Property<bool> m_doStat{this, "doStats", false,
253  "If enabled the algorithm keeps track how many hits have been made" };
254 
255  Gaudi::Property<unsigned int> m_capacityBucket{this,"CapacityBucket" , 50};
256  std::unique_ptr<SpacePointStatistics> m_statCounter ATLAS_THREAD_SAFE{};
257 
258  Gaudi::Property<double> m_maxOccRpcEta{this, "maxRpcEtaOccupancy", 0.1,
259  "Maximum occpancy of Rpc eta hits in a gasGap"};
260  Gaudi::Property<double> m_maxOccRpcPhi{this, "maxRpcPhiOccupancy", 0.1,
261  "Maximum occpancy of Rpc phi hits in a gasGap"};
262 
263  Gaudi::Property<double> m_maxOccTgcEta{this, "maxTgcEtaOccupancy", 0.1,
264  "Maximum occpancy of Tgc eta hits in a gasGap"};
265  Gaudi::Property<double> m_maxOccTgcPhi{this, "maxTgcPhiOccupancy", 0.1,
266  "Maximum occpancy of Tgc phi hits in a gasGap"};
267 
268  Gaudi::Property<double> m_maxOccStgcEta{this, "maxSTGCEtaOccupancy", 0.1,
269  "Maximum occpancy of sTgc eta hits in a gasGap"};
270  Gaudi::Property<double> m_maxOccStgcPhi{this, "maxSTGCPhiOccupancy", 0.1,
271  "Maximum occpancy of sTgc phi hits in a gasGap"};
272 
273  };
274 }
275 
276 
277 #endif
MuonR4::SpacePointMakerAlg::PreSortedSpacePointMap
std::unordered_map< const MuonGMR4::SpectrometerSector *, SpacePointsPerChamber > PreSortedSpacePointMap
Container abrivation of the presorted space point container per MuonChambers.
Definition: SpacePointMakerAlg.h:153
MuonR4::SpacePointMakerAlg::SpacePointStatistics::FieldKey::operator<
bool operator<(const FieldKey &other) const
MuonR4::SpacePointMakerAlg::m_stgcKey
SG::ReadHandleKey< xAOD::sTgcMeasContainer > m_stgcKey
Definition: SpacePointMakerAlg.h:233
ActsGeometryContext.h
BeamSpot::mutex
std::mutex mutex
Definition: InDetBeamSpotVertex.cxx:18
MuonR4::SpacePointMakerAlg::const
const Amg::Vector3D const Amg::Vector3D &nor const
Definition: SpacePointMakerAlg.h:66
MuonR4::SpacePointMakerAlg::initialize
StatusCode initialize() override
Definition: SpacePointMakerAlg.cxx:298
MuonR4::SpacePointMakerAlg::execute
StatusCode execute(const EventContext &ctx) const override
Definition: SpacePointMakerAlg.cxx:482
MuonR4::SpacePointMakerAlg::distributePrimaryPoints
void distributePrimaryPoints(std::vector< SpacePoint > &&spacePoints, SpacePointBucketVec &splittedContainer) const
Distributes the vector of primary eta or eta + phi space points and fills them into the buckets.
Definition: SpacePointMakerAlg.cxx:588
MuonR4::SpacePointMakerAlg::splitBucket
bool splitBucket(const SpacePoint &spacePoint, const double firstSpPos, const SpacePointBucketVec &sortedPoints) const
Returns whether the space point is beyond the bucket boundary.
Definition: SpacePointMakerAlg.cxx:550
Muon::MuonStationIndex::TechnologyIndex
TechnologyIndex
enum to classify the different layers in the muon spectrometer
Definition: MuonStationIndex.h:54
xAOD::UncalibratedMeasurement
UncalibratedMeasurement_v1 UncalibratedMeasurement
Define the version of the uncalibrated measurement class.
Definition: UncalibratedMeasurement.h:13
MuonR4::SpacePointMakerAlg::AmgSymMatrix
AmgSymMatrix(2) computeCov(const MeasType *primaryMeas
Helper function to calculate the covariance for spacepoints having only one measurement.
MuonR4::SpacePointMakerAlg::m_maxOccStgcPhi
Gaudi::Property< double > m_maxOccStgcPhi
Definition: SpacePointMakerAlg.h:270
taskman.template
dictionary template
Definition: taskman.py:316
MuonR4::SpacePointMakerAlg::ATLAS_THREAD_SAFE
std::unique_ptr< SpacePointStatistics > m_statCounter ATLAS_THREAD_SAFE
Definition: SpacePointMakerAlg.h:256
MuonR4::SpacePointMakerAlg::SpacePointsPerChamber::etaHits
std::vector< SpacePoint > etaHits
Vector of all hits that contain an eta measurement including the ones which are combined with phi mea...
Definition: SpacePointMakerAlg.h:148
SpacePoint.h
MuonR4::SpacePointMakerAlg::m_rpcKey
SG::ReadHandleKey< xAOD::RpcMeasurementContainer > m_rpcKey
Definition: SpacePointMakerAlg.h:224
xAOD
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Definition: ICaloAffectedTool.h:24
MuonR4::SpacePointMakerAlg::SpacePointStatistics::StatField::allHits
unsigned int allHits() const
Helper method returning the sum of the three space point type counts.
MuonR4::SpacePointMakerAlg::distributePhiPoints
void distributePhiPoints(std::vector< SpacePoint > &&spacePoints, SpacePointBucketVec &splittedContainer) const
Distributs the vector phi space points into the buckets.
Definition: SpacePointMakerAlg.cxx:535
SG::ReadHandleKey
Property holding a SG store/key/clid from which a ReadHandle is made.
Definition: StoreGate/StoreGate/ReadHandleKey.h:39
sTgcMeasContainer.h
MuonR4::SpacePointMakerAlg::m_mmKey
SG::ReadHandleKey< xAOD::MMClusterContainer > m_mmKey
Definition: SpacePointMakerAlg.h:230
MuonR4::SpacePointMakerAlg::SpacePointStatistics::StatMap_t
std::map< FieldKey, StatField > StatMap_t
Definition: SpacePointMakerAlg.h:140
MuonR4::SpacePointMakerAlg::newBucket
void newBucket(const SpacePoint &refSp, SpacePointBucketVec &sortedPoints) const
Closes the current processed bucket and creates a new one.
Definition: SpacePointMakerAlg.cxx:564
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:74
RpcMeasurementContainer.h
cm
const double cm
Definition: Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/tools/FCAL_ChannelMap.cxx:25
GeoPrimitives.h
MuonR4::SpacePointMakerAlg::SpacePointBucketVec
std::vector< SpacePointBucket > SpacePointBucketVec
Abrivation of a MuonSapcePoint bucket vector.
Definition: SpacePointMakerAlg.h:171
MuonR4::SpacePointMakerAlg::SpacePointsPerChamber
: Helper struct to collect the space point per muon chamber, which are later sorted into the space po...
Definition: SpacePointMakerAlg.h:145
MuonR4::SpacePointMakerAlg::m_tgcKey
SG::ReadHandleKey< xAOD::TgcStripContainer > m_tgcKey
Definition: SpacePointMakerAlg.h:227
MuonR4::SpacePointMakerAlg::m_writeKey
SG::WriteHandleKey< SpacePointContainer > m_writeKey
Definition: SpacePointMakerAlg.h:240
MuonR4::SpacePointMakerAlg::m_maxOccStgcEta
Gaudi::Property< double > m_maxOccStgcEta
Definition: SpacePointMakerAlg.h:268
SG::WriteHandleKey< SpacePointContainer >
MuonR4::SpacePointMakerAlg::SpacePointStatistics
Helper class to keep track of how many eta+phi, eta and phi only space points are built in various de...
Definition: SpacePointMakerAlg.h:101
MuonR4::SpacePointMakerAlg::~SpacePointMakerAlg
~SpacePointMakerAlg()=default
TgcStripContainer.h
MuonR4::SpacePointMakerAlg::SpacePointStatistics::StatField
Helper struct to count the space-points in each detector category.
Definition: SpacePointMakerAlg.h:117
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
vector
Definition: MultiHisto.h:13
Amg::Transform3D
Eigen::Affine3d Transform3D
Definition: GeoPrimitives.h:46
MuonR4::SpacePointMakerAlg::SpacePointsPerChamber::phiHits
std::vector< SpacePoint > phiHits
Vector of all space points that are built from single phi hits.
Definition: SpacePointMakerAlg.h:150
MuonR4::SpacePointMakerAlg::m_maxOccTgcEta
Gaudi::Property< double > m_maxOccTgcEta
Definition: SpacePointMakerAlg.h:263
MuonDetectorManager.h
MMClusterContainer.h
MuonR4::SpacePointMakerAlg::positionInChamber
Amg::Vector3D positionInChamber(const MeasType *meas, const Amg::Transform3D &toChamberTrans) const
Returns the position of the uncalibrated muon measurement in the sector frame.
Definition: SpacePointMakerAlg.cxx:48
F600IntegrationConfig.spacePoints
spacePoints
Definition: F600IntegrationConfig.py:122
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
MuonR4::SpacePointMakerAlg::m_maxOccTgcPhi
Gaudi::Property< double > m_maxOccTgcPhi
Definition: SpacePointMakerAlg.h:265
ActsGeometryContext
Include the GeoPrimitives which need to be put first.
Definition: ActsGeometryContext.h:27
MuonR4::SpacePoint
The muon space point is the combination of two uncalibrated measurements one of them measures the eta...
Definition: MuonSpectrometer/MuonPhaseII/Event/MuonSpacePoint/MuonSpacePoint/SpacePoint.h:19
MuonR4::SpacePointMakerAlg::m_idHelperSvc
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Definition: SpacePointMakerAlg.h:238
Muon::MuonStationIndex::StIndex
StIndex
enum to classify the different station layers in the muon spectrometer
Definition: MuonStationIndex.h:23
AthReentrantAlgorithm.h
MdtDriftCircleContainer.h
WriteHandleKey.h
Property holding a SG store/key/clid from which a WriteHandle is made.
NSWL1::PadTriggerAdapter::fillContainer
StatusCode fillContainer(const std::unique_ptr< Muon::NSW_PadTriggerDataContainer > &out, const std::vector< std::unique_ptr< NSWL1::PadTrigger >> &triggers, const uint32_t l1id)
Definition: PadTriggerAdapter.cxx:17
Amg
Definition of ATLAS Math & Geometry primitives (Amg)
Definition: AmgStringHelpers.h:19
MuonR4::SpacePointMakerAlg::channelDirInChamber
Amg::Vector3D channelDirInChamber(const MeasType *meas, const Amg::Transform3D &toChamberTrans) const
Returns the direction of the measurement channel in the sector frame.
Definition: SpacePointMakerAlg.cxx:75
MuonR4::SpacePointMakerAlg::loadContainerAndSort
StatusCode loadContainerAndSort(const EventContext &ctx, const SG::ReadHandleKey< ContType > &key, PreSortedSpacePointMap &fillContainer) const
Retrieve an uncalibrated measurement container <ContType> and fill the hits into the presorted space ...
Definition: SpacePointMakerAlg.cxx:346
MuonR4::SpacePointMakerAlg::channelNormalInChamber
Amg::Vector3D channelNormalInChamber(const MeasType *meas, const Amg::Transform3D &toChamberTrans) const
Returns the direction, in the sector frame, of the precision axis of the measurement,...
Definition: SpacePointMakerAlg.cxx:98
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
MuonR4::SpacePointMakerAlg::m_mdtKey
SG::ReadHandleKey< xAOD::MdtDriftCircleContainer > m_mdtKey
Definition: SpacePointMakerAlg.h:221
MuonR4
This header ties the generic definitions in this package.
Definition: HoughEventData.h:16
MuonR4::SpacePointMakerAlg::passOccupancy2D
bool passOccupancy2D(const std::vector< const PrdType * > &etaHits, const std::vector< const PrdType * > &phiHits) const
: Check whether the occupancy cuts of hits in a gasGap are surpassed.
MuonR4::SpacePointMakerAlg::m_maxBucketLength
Gaudi::Property< double > m_maxBucketLength
Definition: SpacePointMakerAlg.h:245
MuonR4::SpacePointMakerAlg::m_spacePointWindow
Gaudi::Property< double > m_spacePointWindow
Definition: SpacePointMakerAlg.h:242
MuonR4::SpacePointMakerAlg::SpacePointStatistics::SpacePointStatistics
SpacePointStatistics(const Muon::IMuonIdHelperSvc *idHelperSvc)
Standard constructor.
InDetDD::other
@ other
Definition: InDetDD_Defs.h:16
SpacePointContainer.h
MuonR4::SpacePointMakerAlg::finalize
StatusCode finalize() override
Definition: SpacePointMakerAlg.cxx:292
AthCommonMsg< Gaudi::Algorithm >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
MuonR4::SpacePointMakerAlg::dir
const Amg::Vector3D & dir
Definition: SpacePointMakerAlg.h:65
Muon::IMuonIdHelperSvc
Interface for Helper service that creates muon Identifiers and can be used to print Identifiers.
Definition: IMuonIdHelperSvc.h:27
MuonR4::SpacePointMakerAlg::m_doStat
Gaudi::Property< bool > m_doStat
Definition: SpacePointMakerAlg.h:252
MuonR4::SpacePointMakerAlg::m_geoCtxKey
SG::ReadHandleKey< ActsGeometryContext > m_geoCtxKey
Definition: SpacePointMakerAlg.h:236
MuonR4::SpacePointMakerAlg::m_maxOccRpcEta
Gaudi::Property< double > m_maxOccRpcEta
Definition: SpacePointMakerAlg.h:258
MuonR4::SpacePointMakerAlg::fillSpacePoint
void fillSpacePoint(std::vector< SpacePoint > &pointColl, const MeasType *primaryMeas, const MeasType *secondaryMeas, const Amg::Transform3D &toChamberTrans_eta, const Amg::Transform3D &toChamberTrans_phi) const
Helper function that creates the spacepoint and populates it, when having two measurement.
MuonR4::SpacePointMakerAlg::m_capacityBucket
Gaudi::Property< unsigned int > m_capacityBucket
Definition: SpacePointMakerAlg.h:255
MuonR4::SpacePointMakerAlg::distributePointsAndStore
void distributePointsAndStore(SpacePointsPerChamber &&hitsPerChamber, SpacePointContainer &finalContainer) const
Distribute the premade spacepoints per chamber into their individual SpacePoint buckets.
Definition: SpacePointMakerAlg.cxx:500
MuonR4::SpacePointMakerAlg::toChamberTransform
Amg::Transform3D toChamberTransform(const ActsGeometryContext &gctx, const Amg::Transform3D &sectorTrans, const MeasType *meas) const
Returns the transform from the attached Muon chamber frame to the sector frame.
Definition: SpacePointMakerAlg.cxx:34
MuonR4::SpacePointMakerAlg::SpacePointStatistics::FieldKey
Helper struct to define the counting categories.
Definition: SpacePointMakerAlg.h:129
IMuonIdHelperSvc.h
MuonR4::SpacePointMakerAlg::m_spacePointOverlap
Gaudi::Property< double > m_spacePointOverlap
Definition: SpacePointMakerAlg.h:248
python.SystemOfUnits.m
float m
Definition: SystemOfUnits.py:106
MuonR4::SpacePointMakerAlg
Definition: SpacePointMakerAlg.h:27
ServiceHandle< Muon::IMuonIdHelperSvc >
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37
MuonR4::SpacePointMakerAlg::m_maxOccRpcPhi
Gaudi::Property< double > m_maxOccRpcPhi
Definition: SpacePointMakerAlg.h:260