 |
ATLAS Offline Software
|
Go to the documentation of this file.
15 #include "GeoModelHelpers/TransformSorter.h"
18 #include "CLHEP/Random/RandFlat.h"
21 struct LocalSegSorter{
26 if (
a->chamberIndex() !=
b->chamberIndex()) {
27 return a->chamberIndex() <
b->chamberIndex();
29 if (
a->sector() !=
b->sector()) {
30 return a->sector() <
b->sector();
32 if (
a->etaIndex() !=
b->etaIndex()) {
33 return a->etaIndex() <
b->etaIndex();
35 const GeoTrf::TransformSorter trfSorter{};
39 return trfSorter.compare(locParsA.cast<
double>(), locParsB.cast<
double>())<0;
65 return StatusCode::SUCCESS;
70 return StatusCode::SUCCESS;
74 const EventContext& ctx{Gaudi::Hive::currentContext()};
81 return StatusCode::SUCCESS;
88 std::set<const xAOD::MuonSegment*, LocalSegSorter>>;
90 SegmentsPerBucket_t segmentMap{};
113 CLHEP::RandFlat::shoot(rndEngine,0.,1.) >
m_fracToKeep) {
126 const Amg::Vector3D bucketPos = bucket->msSector()->localToGlobalTrans(*gctx) *
127 (0.5*(bucket->coveredMin() + bucket->coveredMax()) * Amg::Vector3D::UnitY());
133 m_bucket_truthHit = std::ranges::any_of(*bucket,[
this](
const SpacePointBucket::value_type & sp){
142 std::unordered_map<const SpacePoint*, std::vector<int16_t>> spacePointToSegment{};
143 std::set<const xAOD::MuonSegment*, LocalSegSorter> truthSegments{};
145 auto match_itr = segmentMap.find(bucket);
146 if (match_itr != segmentMap.end()) {
150 spacePointToSegment[meas->spacePoint()].push_back(
segment->index());
153 using namespace SegmentFit;
161 unsigned truthLink = -1;
163 truthLink = truthPart->index();
167 truthSegments.insert(truthSeg);
177 std::vector<unsigned int> layNumbers{};
178 std::unordered_map<const SpacePoint*, std::vector<const xAOD::MuonSegment*>> spToTrueSeg{};
180 using SegLinkVec_t = std::vector<ElementLink<xAOD::MuonSegmentContainer>>;
182 for (
const auto& sp : *bucket){
183 for (
const auto& link : segAcc(*sp->primaryMeasurement())) {
184 spToTrueSeg[sp.get()].push_back(*link);
185 truthSegments.insert(*link);
190 for(
const SpacePointBucket::value_type& sp : *bucket) {
192 const unsigned int layNum = layerSorter.sectorLayerNum(*sp);
193 if (
std::find(layNumbers.begin(), layNumbers.end(), layNum) == layNumbers.end()) {
194 layNumbers.push_back(layNum);
196 const unsigned layer = layNumbers.size()-1;
220 const std::vector<int16_t>& segIdxs = spacePointToSegment[sp.get()];
244 Amg::Vector3D globalPos = sp->msSector()->localToGlobalTrans(*gctx) * sp->localPosition();
249 using namespace SegmentFit;
260 return StatusCode::FAILURE;
264 return StatusCode::SUCCESS;
271 rngWrapper->
setSeed(rngName, ctx);
void setSeed(const std::string &algName, const EventContext &ctx)
Set the random seed using a string (e.g.
const SpacePointBucket * parentBucket() const
Returns the bucket out of which the seed was formed.
MuonVal::VectorBranch< unsigned int > & m_spoint_dimension
MuonVal::VectorBranch< float > & m_segmentLocY
MuonVal::VectorBranch< float > & m_truthSegLocTheta
CLHEP::HepRandomEngine * getRandomEngine(const EventContext &ctx) const
Scalar phi() const
phi method
: The muon space point bucket represents a collection of points that will bre processed together in t...
const xAOD::TruthParticle * getTruthMatchedParticle(const xAOD::MuonSegment &segment)
Returns the particle truth-matched to the segment.
StatusCode init(OWNER *instance)
Initialize method.
std::string find(const std::string &s)
return a remapped string
MuonVal::VectorBranch< uint16_t > & m_spoint_adc
MuonVal::ScalarBranch< float > & m_bucket_max
The SpacePointPerLayerSorter sort two given space points by their layer Identifier.
MuonVal::MuonTesterTree m_tree
virtual StatusCode execute() override final
Scalar theta() const
theta method
MuonVal::MuonIdentifierBranch m_spoint_id
const MeasVec & measurements() const
Returns the associated measurements.
MuonVal::ScalarBranch< uint8_t > & m_bucket_truthHit
Class describing a MuonSegment.
const xAOD::MuonSegment * getMatchedTruthSegment(const xAOD::MuonSegment &segment)
Returns the truth-matched segment.
MuonVal::VectorBranch< uint16_t > & m_segmentTruthIdx
MuonVal::ThreeVectorBranch m_spoint_globalPosition
SG::ReadHandleKeyArray< SpacePointContainer > m_spacePointKeys
virtual StatusCode finalize() override final
Helper class to provide constant type-safe access to aux data.
#define ATH_MSG_VERBOSE(x)
SG::ReadHandleKey< ActsGeometryContext > m_geoCtxKey
MuonVal::ScalarBranch< float > & m_bucket_min
MuonVal::VectorBranch< unsigned int > & m_spoint_nPhiInstances
MuonVal::VectorBranch< float > & m_truthSegLocY
SG::ReadHandleKeyArray< xAOD::MuonSegmentContainer > m_inSegmentKeys
@ MdtStatusDriftTime
The tube produced a vaild measurement.
ServiceHandle< IAthRNGSvc > m_rndmSvc
MuonVal::ThreeVectorBranch m_segmentPos
const Segment * detailedSegment(const xAOD::MuonSegment &seg)
Helper function to navigate from the xAOD::MuonSegment to the MuonR4::Segment.
MuonVal::VectorBranch< float > & m_spoint_covY
MuonVal::ScalarBranch< uint16_t > & m_bucket_layers
MuonVal::VectorBranch< unsigned short > & m_spoint_measuresPhi
MuonVal::VectorBranch< float > & m_segmentLocX
void push_back(const Amg::Vector3D &vec)
interface using the Amg::Vector3D
void push_back(size_t i, const T &value)
MuonVal::ThreeVectorBranch m_spoint_localPosition
MuonVal::VectorBranch< float > & m_segmentLocTheta
Gaudi::Property< bool > m_isMC
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
MuonVal::ScalarBranch< float > & m_bucket_posZ
void disableBranch(const std::string &br_name)
Skips the branch from being added to the tree.
const SegmentSeed * parent() const
Returns the seed out of which the segment was built.
::StatusCode StatusCode
StatusCode definition for legacy code.
Gaudi::Property< double > m_fracToKeep
Class describing a truth particle in the MC record.
virtual void push_back(const Identifier &id)
MuonVal::VectorBranch< unsigned short > & m_spoint_isStrip
MuonVal::VectorBranch< float > & m_segmentLocPhi
MuonVal::VectorBranch< unsigned short > & m_spoint_isMdt
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
MuonVal::VectorBranch< unsigned short > & m_spoint_measuresEta
MuonVal::MatrixBranch< int16_t > & m_spoint_mat
MuonVal::VectorBranch< unsigned short > & m_spoint_trueLabel
Include the GeoPrimitives which need to be put first.
std::string name() const override final
Returns the name of the branch.
MuonVal::ScalarBranch< Char_t > & m_bucket_side
MuonVal::VectorBranch< float > & m_spoint_driftR
void push_back(const T &value)
Adds a new element at the end of the vector.
StatusCode dumpContainer(const EventContext &ctx, const SG::ReadHandleKey< SpacePointContainer > &spacePointKey, const SG::ReadHandleKey< xAOD::MuonSegmentContainer > &segmentKey)
Dumps the space point container with the associated muon segment container.
virtual StatusCode initialize() override final
MuonVal::VectorBranch< uint16_t > & m_spoint_layer
A wrapper class for event-slot-local random engines.
MuonVal::ScalarBranch< uint8_t > & m_bucket_sector
MuonVal::ScalarBranch< float > & m_bucket_posX
MuonVal::VectorBranch< uint16_t > & m_spoint_tdc
Eigen::Matrix< double, 3, 1 > Vector3D
MuonVal::ScalarBranch< uint16_t > & m_bucket_spacePoints
MuonVal::ScalarBranch< uint16_t > & m_bucket_segments
CLHEP::HepRandomEngine * getEngine(const EventContext &ctx) const
Retrieve the random engine corresponding to the provided EventContext.
This header ties the generic definitions in this package.
std::vector< SegLink_t > SegLinkVec_t
MuonVal::VectorBranch< float > & m_segment_numberDoF
bool fill(const EventContext &ctx)
Fills the tree per call.
MuonVal::VectorBranch< float > & m_segment_chiSquared
StatusCode write()
Finally write the TTree objects.
Parameters localSegmentPars(const xAOD::MuonSegment &seg)
Returns the localSegPars decoration from a xAODMuon::Segment.
ToolHandle< MuonValR4::IPatternVisualizationTool > m_visionTool
Pattern visualization tool.
MuonVal::VectorBranch< float > & m_truthSegLocX
MuonVal::ScalarBranch< float > & m_bucket_posY
size_t size() const
Returns the number of actual saved elements.
Gaudi::Property< std::string > m_streamName
Handle class for reading from StoreGate.
https://gitlab.cern.ch/atlas/athena/-/blob/master/MuonSpectrometer/MuonReconstruction/MuonRecEvent/Mu...
decltype(auto) operator()(ObjectId< CI, CM > id) const noexcept
SG::ReadDecorHandleKeyArray< xAOD::MuonSegmentContainer > m_truthDecorKeys
MuonVal::MatrixBranch< int16_t > & m_spoint_trueSeg
MuonVal::VectorBranch< float > & m_truthSegLocPhi
float distance(const Amg::Vector3D &p1, const Amg::Vector3D &p2)
calculates the distance between two point in 3D space
MuonVal::ThreeVectorBranch m_segmentDir
MuonVal::VectorBranch< unsigned int > & m_spoint_nEtaInstances
MuonVal::VectorBranch< float > & m_spoint_covX
TTree * tree()
TTree object.
MuonVal::VectorBranch< uint16_t > & m_spoint_nSegments
MuonVal::ScalarBranch< uint8_t > & m_bucket_chamberIdx
Muon::NSW_PadTriggerSegment segment(const NSWL1::PadTrigger &data)
bool addBranch(std::shared_ptr< IMuonTesterBranch > branch)
Branch is added to the tree without transferring the ownership.