ATLAS Offline Software
Loading...
Searching...
No Matches
SpacePointTesterModule.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
7
8using namespace Muon::MuonStationIndex;
9namespace MuonValR4{
11 const std::string& inContainer,
12 MSG::Level msgLvl,
13 const std::string& collName) :
14 TesterModuleBase{tree, inContainer + collName, msgLvl},
15 m_collName{collName},
16 m_key{inContainer}{}
17
18 unsigned int SpacePointTesterModule::push_back(const MuonR4::SpacePoint& spacePoint) {
19 if (!m_internalFill) {
20 m_applyFilter = true;
21 }
22 auto insert_itr = m_spacePointIdx.insert(std::make_pair(&spacePoint, m_spacePointIdx.size()));
23 // Space point added before return the index of the space point
24 if (!insert_itr.second) {
25 return insert_itr.first->second;
26 }
27
28 m_spPos.push_back(spacePoint.localPosition());
29 m_driftR.push_back(spacePoint.driftRadius());
30
31
32 const auto& cov{spacePoint.covariance()};
34 m_covX.push_back(cov[Acts::toUnderlying(CovIdx::phiCov)]);
35 m_covY.push_back(cov[Acts::toUnderlying(CovIdx::etaCov)]);
36 m_covT.push_back(cov[Acts::toUnderlying(CovIdx::timeCov)]);
37
38
39 m_measEta.push_back(spacePoint.measuresEta());
40 m_measPhi.push_back(spacePoint.measuresPhi());
41 m_nEtaInstances.push_back(spacePoint.measuresEta() ? spacePoint.nEtaInstanceCounts() : 0);
42 m_nPhiInstances.push_back(spacePoint.measuresPhi() ? spacePoint.nPhiInstanceCounts() : 0);
43
44
46 const Identifier id = spacePoint.identify();
47 const TechIndex techIdx = idHelperSvc()->technologyIndex(id);
48 m_techIdx.push_back(Acts::toUnderlying(techIdx));
49 m_spacePointId.push_back(id);
50 int phiChannel{-1};
51 switch (techIdx) {
52 case TechIndex::MDT: {
53 const MdtIdHelper& idHelper{idHelperSvc()->mdtIdHelper()};
54 m_layer.push_back((idHelper.multilayer(id) -1)*idHelper.tubeLayerMax(id) +
55 idHelper.tubeLayer(id));
56 m_channel.push_back(idHelper.tube(id));
57 }
58 break;
59 case TechIndex::RPC: {
60 const RpcIdHelper& idHelper{idHelperSvc()->rpcIdHelper()};
61 m_layer.push_back( (idHelper.doubletR(id) -1) * idHelper.gasGapMax(id) +
62 idHelper.gasGap(id));
63 m_channel.push_back(idHelper.channel(id));
64 if (spacePoint.secondaryMeasurement()) {
65 phiChannel = idHelper.channel(xAOD::identify(spacePoint.secondaryMeasurement()));
66 }
67 }
68 break;
69 case TechIndex::TGC: {
70 const TgcIdHelper& idHelper{idHelperSvc()->tgcIdHelper()};
71 m_layer.push_back(idHelper.gasGap(id));
72 m_channel.push_back(idHelper.channel(id));
73 if (spacePoint.secondaryMeasurement()) {
74 phiChannel = idHelper.channel(xAOD::identify(spacePoint.secondaryMeasurement()));
75 }
76 }
77 break;
78 case TechIndex::STGC: {
79 const sTgcIdHelper& idHelper{idHelperSvc()->stgcIdHelper()};
80 m_layer.push_back( (idHelper.multilayer(id) -1) * 4 + idHelper.gasGap(id));
81 m_channel.push_back(idHelper.channel(id));
82 if (spacePoint.secondaryMeasurement()) {
83 phiChannel = idHelper.channel(xAOD::identify(spacePoint.secondaryMeasurement()));
84 }
85 }
86 break;
87 case TechIndex::MM: {
88 const MmIdHelper& idHelper{idHelperSvc()->mmIdHelper()};
89 m_layer.push_back( (idHelper.multilayer(id) -1) * 4 + idHelper.gasGap(id));
90 m_channel.push_back(idHelper.channel(id));
91 }
92 break;
93 default:
94 ATH_MSG_WARNING("Dude you can't have CSCs in R4 "<<idHelperSvc()->toString(id));
95 };
96 m_phiChannel.push_back(phiChannel);
97 return insert_itr.first->second;
98 }
100 if (!m_internalFill) {
101 m_applyFilter = true;
102 } else if (m_applyFilter) {
103 auto find_itr = m_bucketIdx.find(&bucket);
104 return find_itr != m_bucketIdx.end() ? find_itr->second : m_bucketIdx.size();
105 }
106 auto insert_itr = m_bucketIdx.insert(std::make_pair(&bucket, m_bucketIdx.size()));
107 // Bucket has been added before. Bail out
108 if (!insert_itr.second) {
109 return insert_itr.first->second;
110 }
111
112
113 m_bucketNumber.push_back(bucket.bucketId());
114 m_bucketId.push_back(bucket.msSector()->chambers().front()->readoutEles().front()->identify());
115 m_bucketMin.push_back(bucket.coveredMin());
116 m_bucketMax.push_back(bucket.coveredMax());
117 std::vector<uint16_t>& spacePoints = m_bucketPoints[m_bucketPoints.size()];
118 for (const auto& spacePoint : bucket) {
119 spacePoints.push_back(push_back(*spacePoint));
120 }
121
122 return insert_itr.first->second;
123 }
127 bool SpacePointTesterModule::fill(const EventContext& ctx) {
128 m_internalFill = true;
130 if (!SG::get(container, m_key, ctx).isSuccess()) {
131 return false;
132 }
133 for (const MuonR4::SpacePointBucket* bucket : *container) {
134 push_back(*bucket);
135 }
136 m_internalFill = false;
137 m_spacePointIdx.clear();
138 m_bucketIdx.clear();
139 return true;
140 }
141}
#define ATH_MSG_WARNING(x)
Handle class for reading from StoreGate.
bool msgLvl(const MSG::Level lvl) const
Test the output level.
int multilayer(const Identifier &id) const
Access to components of the ID.
int tube(const Identifier &id) const
static int tubeLayerMax()
int tubeLayer(const Identifier &id) const
int channel(const Identifier &id) const override
int gasGap(const Identifier &id) const override
get the hashes
int multilayer(const Identifier &id) const
const ChamberSet & chambers() const
Returns the associated chambers with this sector.
: The muon space point bucket represents a collection of points that will bre processed together in t...
const MuonGMR4::SpectrometerSector * msSector() const
returns th associated muonChamber
unsigned int bucketId() const
Returns the Identifier in the context of the MuonChamber.
The muon space point is the combination of two uncalibrated measurements one of them measures the eta...
bool measuresPhi() const
: Does the space point contain a phi measurement
double driftRadius() const
: Returns the size of the drift radius
bool measuresEta() const
: Does the space point contain an eta measurement
unsigned nEtaInstanceCounts() const
How many space points have been built in total with the same eta prd.
const xAOD::UncalibratedMeasurement * secondaryMeasurement() const
unsigned nPhiInstanceCounts() const
How many space points have been built in total with the same phi prd.
const Identifier & identify() const
: Identifier of the primary measurement
const Cov_t & covariance() const
Returns the covariance array.
VectorBranch< float > & m_driftR
Space point drift radius.
VectorBranch< uint16_t > & m_bucketNumber
Space point bucket information.
VectorBranch< unsigned int > & m_nEtaInstances
How many other spacepoints were built with the same eta /phi prd.
ThreeVectorBranch m_spPos
Space point position.
VectorBranch< bool > & m_measEta
Does the space point measure phi or eta.
bool m_applyFilter
: Flag whether the module is operated in filter mode
MuonIdentifierBranch m_spacePointId
Station Identifier.
VectorBranch< unsigned int > & m_nPhiInstances
SG::ReadHandleKey< MuonR4::SpacePointContainer > m_key
bool fill(const EventContext &ctx) override final
The fill method checks if enough information is provided such that the branch is cleared from the inf...
VectorBranch< float > & m_covX
Covariance of the space point.
VectorBranch< uint16_t > & m_channel
Measurement channel.
VectorBranch< unsigned char > & m_layer
Measurement layer.
unsigned int push_back(const MuonR4::SpacePointBucket &bucket)
std::unordered_map< const MuonR4::SpacePoint *, unsigned int > m_spacePointIdx
: Keep track when a spacepoint is filled into the tree
VectorBranch< unsigned char > & m_techIdx
Technology index of the space point.
VectorBranch< float > & m_bucketMin
Range of the space point bucket.
VectorBranch< int16_t > & m_phiChannel
Channel of the secondary measurment.
SpacePointTesterModule(MuonTesterTree &tree, const std::string &inContainer, MSG::Level msgLvl=MSG::Level::INFO, const std::string &collName="")
MuonIdentifierBranch m_bucketId
stationIndex / stationEta / stationPhi of the bucket chamber
MatrixBranch< uint16_t > & m_bucketPoints
associated space points
bool m_internalFill
: Flag toggling whether the module is in internal filling mode
std::unordered_map< const MuonR4::SpacePointBucket *, unsigned int > m_bucketIdx
: Keep tarck when a space point bucket is filled into the tree
const Muon::IMuonIdHelperSvc * idHelperSvc() const
TesterModuleBase(MuonTesterTree &tree, const std::string &grp_name, MSG::Level msglvl=MSG::Level::INFO)
bool declare_dependency(Key &key)
Declares the ReadHandle/ ReadCondHandleKey as data dependency of the algorithm.
TTree * tree() override final
Returns the underlying TTree object.
virtual const MmIdHelper & mmIdHelper() const =0
access to CscIdHelper
virtual const RpcIdHelper & rpcIdHelper() const =0
access to RpcIdHelper
virtual const sTgcIdHelper & stgcIdHelper() const =0
access to TgcIdHelper
virtual const TgcIdHelper & tgcIdHelper() const =0
access to TgcIdHelper
virtual MuonStationIndex::TechnologyIndex technologyIndex(const Identifier &id) const =0
calculate layer index from Identifier
virtual const MdtIdHelper & mdtIdHelper() const =0
access to MdtIdHelper
int gasGap(const Identifier &id) const override
get the hashes
int gasGapMax() const
int channel(const Identifier &id) const override
int doubletR(const Identifier &id) const
int channel(const Identifier &id) const override
int gasGap(const Identifier &id) const override
get the hashes
int multilayer(const Identifier &id) const
int channel(const Identifier &id) const override
int gasGap(const Identifier &id) const override
get the hashes
std::string toString(const Parameters &pars)
Dumps the parameters into a string with labels in front of each number.
SpacePoint::CovIdx CovIdx
########################################## SpacePointMakerAlg #######################################...
DataVector< SpacePointBucket > SpacePointContainer
Abrivation of the space point container type.
Lightweight algorithm to read xAOD MDT sim hits and (fast-digitised) drift circles from SG and fill a...
TechnologyIndex
enum to classify the different layers in the muon spectrometer
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
const Identifier & identify(const UncalibratedMeasurement *meas)
Returns the associated identifier from the muon measurement.