ATLAS Offline Software
SpacePointTesterModule.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 #include "StoreGate/ReadHandle.h"
7 namespace MuonValR4{
9  const std::string& inContainer,
10  MSG::Level msgLvl,
11  const std::string& collName) :
12  TesterModuleBase{tree, inContainer + collName, msgLvl},
13  m_collName{collName},
14  m_key{inContainer}{}
15 
16  unsigned int SpacePointTesterModule::push_back(const MuonR4::SpacePoint& spacePoint) {
17  if (!m_internalFill) {
18  m_applyFilter = true;
19  }
20  auto insert_itr = m_spacePointIdx.insert(std::make_pair(&spacePoint, m_spacePointIdx.size()));
21  // Space point added before return the index of the space point
22  if (!insert_itr.second) {
23  return insert_itr.first->second;
24  }
25 
27  m_driftR.push_back(spacePoint.driftRadius());
28 
29 
30  const AmgSymMatrix(2)& cov{spacePoint.covariance()};
35 
36  m_measEta.push_back(spacePoint.measuresEta());
37  m_measPhi.push_back(spacePoint.measuresPhi());
38  m_nEtaInstances.push_back(spacePoint.measuresEta() ? spacePoint.nEtaInstanceCounts() : 0);
39  m_nPhiInstances.push_back(spacePoint.measuresPhi() ? spacePoint.nPhiInstanceCounts() : 0);
40 
41 
42  using TechIndex = Muon::MuonStationIndex::TechnologyIndex;
43  const Identifier id = spacePoint.identify();
44  const TechIndex techIdx = idHelperSvc()->technologyIndex(id);
45  m_techIdx.push_back(static_cast<int>(techIdx));
47  int phiChannel{-1};
48  switch (techIdx) {
49  case TechIndex::MDT: {
50  const MdtIdHelper& idHelper{idHelperSvc()->mdtIdHelper()};
51  m_layer.push_back((idHelper.multilayer(id) -1)*idHelper.tubeLayerMax(id) +
52  idHelper.tubeLayer(id));
53  m_channel.push_back(idHelper.tube(id));
54  }
55  break;
56  case TechIndex::RPC: {
57  const RpcIdHelper& idHelper{idHelperSvc()->rpcIdHelper()};
58  m_layer.push_back( (idHelper.doubletR(id) -1) * idHelper.gasGapMax(id) +
59  idHelper.gasGap(id));
60  m_channel.push_back(idHelper.channel(id));
61  if (spacePoint.secondaryMeasurement()) {
62  phiChannel = idHelper.channel(xAOD::identify(spacePoint.secondaryMeasurement()));
63  }
64  }
65  break;
66  case TechIndex::TGC: {
67  const TgcIdHelper& idHelper{idHelperSvc()->tgcIdHelper()};
68  m_layer.push_back(idHelper.gasGap(id));
69  m_channel.push_back(idHelper.channel(id));
70  if (spacePoint.secondaryMeasurement()) {
71  phiChannel = idHelper.channel(xAOD::identify(spacePoint.secondaryMeasurement()));
72  }
73  }
74  break;
75  case TechIndex::STGC: {
76  const sTgcIdHelper& idHelper{idHelperSvc()->stgcIdHelper()};
77  m_layer.push_back( (idHelper.multilayer(id) -1) * 4 + idHelper.gasGap(id));
78  m_channel.push_back(idHelper.channel(id));
79  if (spacePoint.secondaryMeasurement()) {
80  phiChannel = idHelper.channel(xAOD::identify(spacePoint.secondaryMeasurement()));
81  }
82  }
83  break;
84  case TechIndex::MM: {
85  const MmIdHelper& idHelper{idHelperSvc()->mmIdHelper()};
86  m_layer.push_back( (idHelper.multilayer(id) -1) * 4 + idHelper.gasGap(id));
87  m_channel.push_back(idHelper.channel(id));
88  }
89  break;
90  default:
91  ATH_MSG_WARNING("Dude you can't have CSCs in R4 "<<idHelperSvc()->toString(id));
92  };
93  m_phiChannel.push_back(phiChannel);
94  return insert_itr.first->second;
95  }
97  if (!m_internalFill) {
98  m_applyFilter = true;
99  } else if (m_applyFilter) {
100  auto find_itr = m_bucketIdx.find(&bucket);
101  return find_itr != m_bucketIdx.end() ? find_itr->second : m_bucketIdx.size();
102  }
103  auto insert_itr = m_bucketIdx.insert(std::make_pair(&bucket, m_bucketIdx.size()));
104  // Bucket has been added before. Bail out
105  if (!insert_itr.second) {
106  return insert_itr.first->second;
107  }
108 
109 
111  m_bucketId.push_back(bucket.msSector()->chambers().front()->readoutEles().front()->identify());
112  m_bucketMin.push_back(bucket.coveredMin());
113  m_bucketMax.push_back(bucket.coveredMax());
114  std::vector<uint16_t>& spacePoints = m_bucketPoints[m_bucketPoints.size()];
115  for (const auto& spacePoint : bucket) {
116  spacePoints.push_back(push_back(*spacePoint));
117  }
118 
119  return insert_itr.first->second;
120  }
122  return declare_dependency(m_key);
123  }
124  bool SpacePointTesterModule::fill(const EventContext& ctx) {
125  m_internalFill = true;
126  SG::ReadHandle container{m_key, ctx};
127  if (!container.isPresent()) {
128  ATH_MSG_FATAL("Failed to retrieve container "<<m_key.fullKey());
129  return false;
130  }
131  for (const auto& bucket : *container) {
132  push_back(*bucket);
133  }
134  m_internalFill = false;
135  m_spacePointIdx.clear();
136  m_bucketIdx.clear();
137  return true;
138  }
139 }
TGC
@ TGC
Definition: RegSelEnums.h:33
MuonValR4::SpacePointTesterModule::m_phiChannel
VectorBranch< int16_t > & m_phiChannel
Channel of the secondary measurment.
Definition: SpacePointTesterModule.h:69
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:61
STGC
@ STGC
Definition: RegSelEnums.h:39
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
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:36
MuonR4::SpacePointBucket::coveredMin
double coveredMin() const
lower interval value covered by the bucket
Definition: MuonSpectrometer/MuonPhaseII/Event/MuonSpacePoint/MuonSpacePoint/SpacePointContainer.h:32
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
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
MuonValR4::SpacePointTesterModule::SpacePointTesterModule
SpacePointTesterModule(MuonTesterTree &tree, const std::string &inContainer, MSG::Level msgLvl=MSG::Level::INFO, const std::string &collName="")
Definition: SpacePointTesterModule.cxx:8
MuonGMR4::SpectrometerSector::chambers
const ChamberSet & chambers() const
Returns the associated chambers with this sector.
Definition: SpectrometerSector.cxx:50
MuonValR4::SpacePointTesterModule::m_covXX
VectorBranch< float > & m_covXX
Covariance of the space point.
Definition: SpacePointTesterModule.h:47
MuonValR4::SpacePointTesterModule::m_globPos
ThreeVectorBranch m_globPos
Space point position.
Definition: SpacePointTesterModule.h:43
MuonR4::SpacePointBucket::bucketId
unsigned int bucketId() const
Returns the Identifier in the context of the MuonChamber.
Definition: MuonSpectrometer/MuonPhaseII/Event/MuonSpacePoint/MuonSpacePoint/SpacePointContainer.h:46
MuonValR4::SpacePointTesterModule::m_applyFilter
bool m_applyFilter
: Flag whether the module is operated in filter mode
Definition: SpacePointTesterModule.h:76
tree
TChain * tree
Definition: tile_monitor.h:30
Amg::y
@ y
Definition: GeoPrimitives.h:35
plotBeamSpotVxVal.cov
cov
Definition: plotBeamSpotVxVal.py:201
MuonValR4::SpacePointTesterModule::m_nPhiInstances
VectorBranch< unsigned int > & m_nPhiInstances
Definition: SpacePointTesterModule.h:57
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:124
MuonR4::SpacePoint::secondaryMeasurement
const xAOD::UncalibratedMeasurement * secondaryMeasurement() const
Definition: MuonSpectrometer/MuonPhaseII/Event/MuonSpacePoint/src/SpacePoint.cxx:110
MuonValR4::SpacePointTesterModule::m_layer
VectorBranch< unsigned char > & m_layer
Measurement layer.
Definition: SpacePointTesterModule.h:65
MuonValR4::SpacePointTesterModule::m_channel
VectorBranch< uint16_t > & m_channel
Measurement channel.
Definition: SpacePointTesterModule.h:67
Muon::IMuonIdHelperSvc::mmIdHelper
virtual const MmIdHelper & mmIdHelper() const =0
access to CscIdHelper
RpcIdHelper
Definition: RpcIdHelper.h:51
AmgSymMatrix
#define AmgSymMatrix(dim)
Definition: EventPrimitives.h:50
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:134
MuonValR4::SpacePointTesterModule::m_nEtaInstances
VectorBranch< unsigned int > & m_nEtaInstances
How many other spacepoints were built with the same eta /phi prd.
Definition: SpacePointTesterModule.h:56
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:34
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
MuonValR4::SpacePointTesterModule::m_spacePointId
MuonIdentifierBranch m_spacePointId
Station Identifier.
Definition: SpacePointTesterModule.h:61
Amg::x
@ x
Definition: GeoPrimitives.h:34
MuonValR4::SpacePointTesterModule::m_covYY
VectorBranch< float > & m_covYY
Definition: SpacePointTesterModule.h:50
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
MuonValR4::SpacePointTesterModule::m_measPhi
VectorBranch< bool > & m_measPhi
Definition: SpacePointTesterModule.h:54
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:18
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
RPC
@ RPC
Definition: RegSelEnums.h:32
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:53
Muon::IMuonIdHelperSvc::tgcIdHelper
virtual const TgcIdHelper & tgcIdHelper() const =0
access to TgcIdHelper
SpacePointTesterModule.h
MuonValR4::SpacePointTesterModule::m_covYX
VectorBranch< float > & m_covYX
Definition: SpacePointTesterModule.h:49
MuonValR4::SpacePointTesterModule::declare_keys
bool declare_keys() override final
Definition: SpacePointTesterModule.cxx:121
MuonR4::SpacePoint::positionInChamber
const Amg::Vector3D & positionInChamber() const
Definition: MuonSpectrometer/MuonPhaseII/Event/MuonSpacePoint/src/SpacePoint.cxx:119
MuonR4::SpacePoint::nPhiInstanceCounts
unsigned int nPhiInstanceCounts() const
How many space points have been built in total with the same phi prd
Definition: MuonSpectrometer/MuonPhaseII/Event/MuonSpacePoint/src/SpacePoint.cxx:159
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:72
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:137
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
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:63
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:96
MuonR4::SpacePoint::driftRadius
double driftRadius() const
: Returns the size of the drift radius
Definition: MuonSpectrometer/MuonPhaseII/Event/MuonSpacePoint/src/SpacePoint.cxx:143
MuonVal::VectorBranch::size
size_t size() const
Returns the number of actual saved elements.
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:74
MuonValR4::SpacePointTesterModule::m_covXY
VectorBranch< float > & m_covXY
Definition: SpacePointTesterModule.h:48
MuonValR4::SpacePointTesterModule::m_internalFill
bool m_internalFill
: Flag toggling whether the module is in internal filling mode
Definition: SpacePointTesterModule.h:78
Muon::MuonStationIndex::TechnologyIndex
TechnologyIndex
enum to classify the different layers in the muon spectrometer
Definition: MuonStationIndex.h:54
MuonR4::SpacePoint::identify
const Identifier & identify() const
: Identifier of the primary measurement
Definition: MuonSpectrometer/MuonPhaseII/Event/MuonSpacePoint/src/SpacePoint.cxx:140
MuonR4::SpacePoint::nEtaInstanceCounts
unsigned int nEtaInstanceCounts() const
How many space points have been built in total with the same eta prd.
Definition: MuonSpectrometer/MuonPhaseII/Event/MuonSpacePoint/src/SpacePoint.cxx:158
MDT
@ MDT
Definition: RegSelEnums.h:31
Muon::IMuonIdHelperSvc::rpcIdHelper
virtual const RpcIdHelper & rpcIdHelper() const =0
access to RpcIdHelper
Identifier
Definition: IdentifierFieldParser.cxx:14