ATLAS Offline Software
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 
6 #include "StoreGate/ReadHandle.h"
7 
8 using namespace Muon::MuonStationIndex;
9 namespace MuonValR4{
10  SpacePointTesterModule::SpacePointTesterModule(MuonTesterTree& tree,
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 
45  using TechIndex = Muon::MuonStationIndex::TechnologyIndex;
46  const Identifier id = spacePoint.identify();
47  const TechIndex techIdx = idHelperSvc()->technologyIndex(id);
48  m_techIdx.push_back(Acts::toUnderlying(techIdx));
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 
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  }
125  return declare_dependency(m_key);
126  }
127  bool SpacePointTesterModule::fill(const EventContext& ctx) {
128  m_internalFill = true;
129  const MuonR4::SpacePointContainer* container{nullptr};
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 }
TGC
@ TGC
Definition: RegSelEnums.h:33
MuonValR4::SpacePointTesterModule::m_phiChannel
VectorBranch< int16_t > & m_phiChannel
Channel of the secondary measurment.
Definition: SpacePointTesterModule.h:67
xAOD::identify
const Identifier & identify(const UncalibratedMeasurement *meas)
Returns the associated identifier from the muon measurement.
Definition: MuonSpectrometer/MuonPhaseII/Event/xAOD/xAODMuonPrepData/Root/UtilFunctions.cxx:82
STGC
@ STGC
Definition: RegSelEnums.h:39
Muon::IMuonIdHelperSvc::stgcIdHelper
virtual const sTgcIdHelper & stgcIdHelper() const =0
access to TgcIdHelper
MuonR4::SpacePointBucket
: The muon space point bucket represents a collection of points that will bre processed together in t...
Definition: MuonSpectrometer/MuonPhaseII/Event/MuonSpacePoint/MuonSpacePoint/SpacePointContainer.h:21
MuonR4::SpacePointBucket::msSector
const MuonGMR4::SpectrometerSector * msSector() const
returns th associated muonChamber
Definition: MuonSpectrometer/MuonPhaseII/Event/MuonSpacePoint/MuonSpacePoint/SpacePointContainer.h:33
Muon::MuonStationIndex
Definition: MuonStationIndex.h:13
MuonR4::SpacePointBucket::coveredMin
double coveredMin() const
lower interval value covered by the bucket
Definition: MuonSpectrometer/MuonPhaseII/Event/MuonSpacePoint/MuonSpacePoint/SpacePointContainer.h:29
MuonValR4::SpacePointTesterModule::m_bucketId
MuonIdentifierBranch m_bucketId
stationIndex / stationEta / stationPhi of the bucket chamber
Definition: SpacePointTesterModule.h:34
TgcIdHelper
Definition: TgcIdHelper.h:50
MuonValR4::SpacePointTesterModule::m_driftR
VectorBranch< float > & m_driftR
Space point drift radius.
Definition: SpacePointTesterModule.h:45
MuonGMR4::SpectrometerSector::chambers
const ChamberSet & chambers() const
Returns the associated chambers with this sector.
Definition: SpectrometerSector.cxx:71
MuonR4::SpacePoint::CovIdx::timeCov
@ timeCov
MuonR4::SpacePointBucket::bucketId
unsigned int bucketId() const
Returns the Identifier in the context of the MuonChamber.
Definition: MuonSpectrometer/MuonPhaseII/Event/MuonSpacePoint/MuonSpacePoint/SpacePointContainer.h:40
MuonValR4::SpacePointTesterModule::m_applyFilter
bool m_applyFilter
: Flag whether the module is operated in filter mode
Definition: SpacePointTesterModule.h:74
tree
TChain * tree
Definition: tile_monitor.h:30
Muon::MuonStationIndex::TechnologyIndex
TechnologyIndex
enum to classify the different layers in the muon spectrometer
Definition: MuonStationIndex.h:54
plotBeamSpotVxVal.cov
cov
Definition: plotBeamSpotVxVal.py:200
MuonValR4::SpacePointTesterModule::m_nPhiInstances
VectorBranch< unsigned int > & m_nPhiInstances
Definition: SpacePointTesterModule.h:55
MM
@ MM
Definition: RegSelEnums.h:38
MuonValR4::SpacePointTesterModule::fill
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...
Definition: SpacePointTesterModule.cxx:127
MuonR4::SpacePoint::secondaryMeasurement
const xAOD::UncalibratedMeasurement * secondaryMeasurement() const
Definition: MuonSpectrometer/MuonPhaseII/Event/MuonSpacePoint/src/SpacePoint.cxx:78
MuonValR4::SpacePointTesterModule::m_layer
VectorBranch< unsigned char > & m_layer
Measurement layer.
Definition: SpacePointTesterModule.h:63
MuonValR4::SpacePointTesterModule::m_channel
VectorBranch< uint16_t > & m_channel
Measurement channel.
Definition: SpacePointTesterModule.h:65
MuonR4::SpacePoint::CovIdx::etaCov
@ etaCov
Muon::IMuonIdHelperSvc::mmIdHelper
virtual const MmIdHelper & mmIdHelper() const =0
access to CscIdHelper
RpcIdHelper
Definition: RpcIdHelper.h:51
MuonVal::MuonTesterBranch::tree
TTree * tree() override final
Returns the underlying TTree object.
Definition: MuonTesterBranch.cxx:53
MuonR4::SpacePoint::measuresPhi
bool measuresPhi() const
: Does the space point contain a phi measurement
Definition: MuonSpectrometer/MuonPhaseII/Event/MuonSpacePoint/src/SpacePoint.cxx:91
MuonValR4::SpacePointTesterModule::m_nEtaInstances
VectorBranch< unsigned int > & m_nEtaInstances
How many other spacepoints were built with the same eta /phi prd.
Definition: SpacePointTesterModule.h:54
MuonVal::MuonTesterBranch::declare_dependency
bool declare_dependency(Key &key)
Declares the ReadHandle/ ReadCondHandleKey as data dependency of the algorithm.
MuonR4::SpacePointBucket::coveredMax
double coveredMax() const
upper interval value covered by the bucket
Definition: MuonSpectrometer/MuonPhaseII/Event/MuonSpacePoint/MuonSpacePoint/SpacePointContainer.h:31
MuonVal::ThreeVectorBranch::push_back
void push_back(const Amg::Vector3D &vec)
interface using the Amg::Vector3D
Definition: ThreeVectorBranch.cxx:23
Amg::toString
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
Definition: GeoPrimitivesToStringConverter.h:40
TrigConf::MSGTC::Level
Level
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:21
AthMessaging::msgLvl
bool msgLvl(const MSG::Level lvl) const
Test the output level.
Definition: AthMessaging.h:151
MuonVal::MuonTesterTree
Definition: MuonTesterTree.h:30
MuonValR4::SpacePointTesterModule::m_bucketMin
VectorBranch< float > & m_bucketMin
Range of the space point bucket.
Definition: SpacePointTesterModule.h:36
SG::get
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
Definition: ReadCondHandle.h:287
MuonValR4::SpacePointTesterModule::m_spacePointId
MuonIdentifierBranch m_spacePointId
Station Identifier.
Definition: SpacePointTesterModule.h:59
MuonVal::MuonIdentifierBranch::push_back
virtual void push_back(const Identifier &id)
Definition: IdentifierBranch.cxx:14
MuonValR4::TesterModuleBase::idHelperSvc
const Muon::IMuonIdHelperSvc * idHelperSvc() const
Definition: TesterModuleBase.cxx:18
MdtIdHelper
Definition: MdtIdHelper.h:61
MuonValR4::SpacePointTesterModule::m_bucketPoints
MatrixBranch< uint16_t > & m_bucketPoints
associated space points
Definition: SpacePointTesterModule.h:39
MuonR4::SpacePoint::covariance
const Cov_t & covariance() const
Returns the covariance array.
Definition: MuonSpectrometer/MuonPhaseII/Event/MuonSpacePoint/src/SpacePoint.cxx:61
F600IntegrationConfig.spacePoints
spacePoints
Definition: F600IntegrationConfig.py:122
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
MuonValR4::SpacePointTesterModule::m_measPhi
VectorBranch< bool > & m_measPhi
Definition: SpacePointTesterModule.h:52
MuonValR4::TesterModuleBase
Definition: TesterModuleBase.h:15
MuonVal::VectorBranch::push_back
void push_back(const T &value)
Adds a new element at the end of the vector.
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:24
MuonValR4
Lightweight algorithm to read xAOD MDT sim hits and (fast-digitised) drift circles from SG and fill a...
Definition: IPatternVisualizationTool.h:23
Muon::IMuonIdHelperSvc::technologyIndex
virtual MuonStationIndex::TechnologyIndex technologyIndex(const Identifier &id) const =0
calculate layer index from Identifier
MuonValR4::SpacePointTesterModule::m_covX
VectorBranch< float > & m_covX
Covariance of the space point.
Definition: SpacePointTesterModule.h:47
RPC
@ RPC
Definition: RegSelEnums.h:32
MuonR4::SpacePoint::CovIdx::phiCov
@ phiCov
Muon::IMuonIdHelperSvc::mdtIdHelper
virtual const MdtIdHelper & mdtIdHelper() const =0
access to MdtIdHelper
sTgcIdHelper
Definition: sTgcIdHelper.h:55
MuonValR4::SpacePointTesterModule::m_measEta
VectorBranch< bool > & m_measEta
Does the space point measure phi or eta.
Definition: SpacePointTesterModule.h:51
Muon::IMuonIdHelperSvc::tgcIdHelper
virtual const TgcIdHelper & tgcIdHelper() const =0
access to TgcIdHelper
SpacePointTesterModule.h
MuonValR4::SpacePointTesterModule::declare_keys
bool declare_keys() override final
Definition: SpacePointTesterModule.cxx:124
MuonR4::SpacePoint::localPosition
const Amg::Vector3D & localPosition() const
Definition: MuonSpectrometer/MuonPhaseII/Event/MuonSpacePoint/src/SpacePoint.cxx:50
MuonR4::SpacePoint::nPhiInstanceCounts
unsigned nPhiInstanceCounts() const
How many space points have been built in total with the same phi prd
Definition: MuonSpectrometer/MuonPhaseII/Event/MuonSpacePoint/src/SpacePoint.cxx:106
MuonValR4::SpacePointTesterModule::m_spacePointIdx
std::unordered_map< const MuonR4::SpacePoint *, unsigned int > m_spacePointIdx
: Keep track when a spacepoint is filled into the tree
Definition: SpacePointTesterModule.h:70
MuonValR4::SpacePointTesterModule::m_covY
VectorBranch< float > & m_covY
Definition: SpacePointTesterModule.h:48
MmIdHelper
Definition: MmIdHelper.h:54
MuonR4::SpacePoint::measuresEta
bool measuresEta() const
: Does the space point contain an eta measurement
Definition: MuonSpectrometer/MuonPhaseII/Event/MuonSpacePoint/src/SpacePoint.cxx:94
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
MuonValR4::SpacePointTesterModule::m_covT
VectorBranch< float > & m_covT
Definition: SpacePointTesterModule.h:49
MuonValR4::SpacePointTesterModule::m_key
SG::ReadHandleKey< MuonR4::SpacePointContainer > m_key
Definition: SpacePointTesterModule.h:30
MuonValR4::SpacePointTesterModule::m_techIdx
VectorBranch< unsigned char > & m_techIdx
Technology index of the space point.
Definition: SpacePointTesterModule.h:61
MuonValR4::SpacePointTesterModule::m_bucketNumber
VectorBranch< uint16_t > & m_bucketNumber
Space point bucket information.
Definition: SpacePointTesterModule.h:32
MuonValR4::SpacePointTesterModule::m_bucketMax
VectorBranch< float > & m_bucketMax
Definition: SpacePointTesterModule.h:37
MuonValR4::SpacePointTesterModule::push_back
unsigned int push_back(const MuonR4::SpacePointBucket &bucket)
Definition: SpacePointTesterModule.cxx:99
MuonR4::SpacePoint::driftRadius
double driftRadius() const
: Returns the size of the drift radius
Definition: MuonSpectrometer/MuonPhaseII/Event/MuonSpacePoint/src/SpacePoint.cxx:54
MuonVal::VectorBranch::size
size_t size() const
Returns the number of actual saved elements.
MuonR4::SpacePoint::CovIdx
CovIdx
Definition: MuonSpectrometer/MuonPhaseII/Event/MuonSpacePoint/MuonSpacePoint/SpacePoint.h:30
ReadHandle.h
Handle class for reading from StoreGate.
MuonValR4::SpacePointTesterModule::m_bucketIdx
std::unordered_map< const MuonR4::SpacePointBucket *, unsigned int > m_bucketIdx
: Keep tarck when a space point bucket is filled into the tree
Definition: SpacePointTesterModule.h:72
MuonValR4::SpacePointTesterModule::m_internalFill
bool m_internalFill
: Flag toggling whether the module is in internal filling mode
Definition: SpacePointTesterModule.h:76
MuonValR4::SpacePointTesterModule::m_spPos
ThreeVectorBranch m_spPos
Space point position.
Definition: SpacePointTesterModule.h:43
MuonR4::SpacePoint::identify
const Identifier & identify() const
: Identifier of the primary measurement
Definition: MuonSpectrometer/MuonPhaseII/Event/MuonSpacePoint/src/SpacePoint.cxx:97
MuonR4::SpacePoint::nEtaInstanceCounts
unsigned nEtaInstanceCounts() const
How many space points have been built in total with the same eta prd.
Definition: MuonSpectrometer/MuonPhaseII/Event/MuonSpacePoint/src/SpacePoint.cxx:105
MDT
@ MDT
Definition: RegSelEnums.h:31
Muon::IMuonIdHelperSvc::rpcIdHelper
virtual const RpcIdHelper & rpcIdHelper() const =0
access to RpcIdHelper
Identifier
Definition: IdentifierFieldParser.cxx:14