ATLAS Offline Software
Loading...
Searching...
No Matches
Muon::NSWSeed Struct Reference

#include <MuonNSWSegmentFinderTool.h>

Collaboration diagram for Muon::NSWSeed:

Classes

struct  SeedMeasurement
 Struct caching the MuonClusterOnTrack and providing the orientation of the strip in addtion. More...

Public Types

enum class  SeedOR { NoOverlap , Same , SubSet , SuperSet }
using MeasVec = std::vector<SeedMeasurement>
 Returns the contained measurements.

Public Member Functions

 NSWSeed ()=default
 NSWSeed (const MuonNSWSegmentFinderTool *parent, const std::array< SeedMeasurement, 4 > &seed, const std::array< double, 2 > &lengths)
 NSWSeed (const MuonNSWSegmentFinderTool *parent, const SeedMeasurement &first, const SeedMeasurement &second)
 NSWSeed (const MuonNSWSegmentFinderTool *parent, const Muon::MuonSegment &seg)
 Constructor to build a seed from an existing segment.
 NSWSeed (const MuonNSWSegmentFinderTool *parent, const Amg::Vector3D &pos, const Amg::Vector3D &dir)
double chi2 () const
size_t size () const
 Returns the number of measurements.
const Amg::Vector3Dpos () const
 Returns the position of the seed.
const Amg::Vector3Ddir () const
 Returns the direction of the seed.
MeasVec measurements () const
bool add (SeedMeasurement meas, double max_uncert)
 Tries to add the measurement to the seeds. Returns false if the measurement is incompatible with the seed or the seed is invalid.
const Muon::MuonClusterOnTracknewCalibClust (std::unique_ptr< const Muon::MuonClusterOnTrack > new_clust)
 Adds a calibrated cluster to the garbage collection.
SeedOR overlap (const NSWSeed &other) const

Private Types

using SeedMeasCache = std::array<SeedMeasurement, 16>
 Helper pair to cache the measurements with the respective distances.

Private Member Functions

int channel (const SeedMeasurement &meas) const
 Returns the channel of the measurement on the layer.
bool find (const SeedMeasurement &meas) const
 Checks whether the measurement is already part of the seed.
double distance (const SeedMeasurement &meas) const
 Calculates the minimal distance between seed and measurement.
bool insert (const Muon::MuonClusterOnTrack *cl)
bool insert (SeedMeasurement meas)

Private Attributes

const MuonNSWSegmentFinderToolm_parent {nullptr}
SeedMeasCache m_measurements {}
 Cache the eta measurements.
SeedMeasCache m_phiMeasurements {}
 Cache the phi measurements.
SeedMeasCache m_padMeasurements {}
 Cache the sTGC pad measurements.
Amg::Vector3D m_pos {Amg::Vector3D::Zero()}
 Starting position of the seed.
Amg::Vector3D m_dir {Amg::Vector3D::Zero()}
 Seed direction.
double m_width {0.}
 seed width
double m_chi2 {0.}
 Chi2.
size_t m_size {0}
 Added measurements on track.
std::set< std::shared_ptr< const Muon::MuonClusterOnTrack > > m_calibClust {}
 Garbage container per seed.

Detailed Description

Definition at line 29 of file MuonNSWSegmentFinderTool.h.

Member Typedef Documentation

◆ MeasVec

Returns the contained measurements.

Definition at line 82 of file MuonNSWSegmentFinderTool.h.

◆ SeedMeasCache

using Muon::NSWSeed::SeedMeasCache = std::array<SeedMeasurement, 16>
private

Helper pair to cache the measurements with the respective distances.

Definition at line 105 of file MuonNSWSegmentFinderTool.h.

Member Enumeration Documentation

◆ SeedOR

enum class Muon::NSWSeed::SeedOR
strong
Enumerator
NoOverlap 
Same 
SubSet 
SuperSet 

Definition at line 89 of file MuonNSWSegmentFinderTool.h.

89{ NoOverlap, Same, SubSet, SuperSet };

Constructor & Destructor Documentation

◆ NSWSeed() [1/5]

Muon::NSWSeed::NSWSeed ( )
default

◆ NSWSeed() [2/5]

Muon::NSWSeed::NSWSeed ( const MuonNSWSegmentFinderTool * parent,
const std::array< SeedMeasurement, 4 > & seed,
const std::array< double, 2 > & lengths )

Insert the measurements

Definition at line 107 of file MuonNSWSegmentFinderTool.cxx.

108 :
110 m_pos{seed[0].pos() + lengths[0] * seed[0].dir()} {
111
112 const Amg::Vector3D un_dir = (seed[1].pos() + lengths[1] *seed[1].dir() - m_pos);
113 m_dir = un_dir.unit()*(un_dir.z() * seed[0].pos().z() > 0 ? 1 : -1);
114
115 if (m_parent->msgLvl(MSG::VERBOSE))
116 m_parent->msgStream() << MSG::VERBOSE << m_parent->printSeed(seed)<<" is a valid seed "<<to_string(m_pos) <<" pointing to "<<to_string(m_dir)<<"."<<endmsg;
117
119 for (const SeedMeasurement& cl : seed) {
120 insert(cl);
121 m_width = std::hypot(m_width, Amg::error(cl->localCovariance(), Trk::locX));
122 }
123 m_width /= std::sqrt(3);
124 }
#define endmsg
static std::string to_string(const std::vector< T > &v)
#define z
double error(const Amg::MatrixX &mat, int index)
return diagonal error of the matrix caller should ensure the matrix is symmetric and the index is in ...
Eigen::Matrix< double, 3, 1 > Vector3D
@ locX
Definition ParamDefs.h:37
cl
print [x.__class__ for x in toList(dqregion.getSubRegions()) ]
Struct caching the MuonClusterOnTrack and providing the orientation of the strip in addtion.
const Amg::Vector3D & pos() const
Returns the position of the seed.
Amg::Vector3D m_dir
Seed direction.
Amg::Vector3D m_pos
Starting position of the seed.
const MuonNSWSegmentFinderTool * m_parent
bool insert(const Muon::MuonClusterOnTrack *cl)
double m_width
seed width
const Amg::Vector3D & dir() const
Returns the direction of the seed.

◆ NSWSeed() [3/5]

Muon::NSWSeed::NSWSeed ( const MuonNSWSegmentFinderTool * parent,
const SeedMeasurement & first,
const SeedMeasurement & second )

Definition at line 125 of file MuonNSWSegmentFinderTool.cxx.

126 :
127 m_parent{parent}, m_pos{first.pos()} {
128 m_dir = (second.pos() - m_pos).unit();
129 m_width = std::hypot(Amg::error(first->localCovariance(), Trk::locX),
130 Amg::error(second->localCovariance(), Trk::locX)) / std::sqrt(2);
131 insert(first);
132 insert(second);
133 }
bool first
Definition DeMoScan.py:534

◆ NSWSeed() [4/5]

Muon::NSWSeed::NSWSeed ( const MuonNSWSegmentFinderTool * parent,
const Muon::MuonSegment & seg )

Constructor to build a seed from an existing segment.

Definition at line 134 of file MuonNSWSegmentFinderTool.cxx.

134 :
136 for (const Trk::MeasurementBase* meas : seg.containedMeasurements()) {
137 const Muon::MuonClusterOnTrack* clus = dynamic_cast<const Muon::MuonClusterOnTrack*>(meas);
138 if (!clus) continue;
139 insert(clus);
140 m_width = std::hypot(m_width, Amg::error(clus->localCovariance(), Trk::locX));
141 }
142 m_width /= std::sqrt(size());
143 }
virtual const Amg::Vector3D & globalPosition() const override final
global position
const Amg::MatrixX & localCovariance() const
Interface method to get the localError.
const std::vector< const Trk::MeasurementBase * > & containedMeasurements() const
returns the vector of Trk::MeasurementBase objects
size_t size() const
Returns the number of measurements.

◆ NSWSeed() [5/5]

Muon::NSWSeed::NSWSeed ( const MuonNSWSegmentFinderTool * parent,
const Amg::Vector3D & pos,
const Amg::Vector3D & dir )

Definition at line 144 of file MuonNSWSegmentFinderTool.cxx.

144 :
size_t m_size
Added measurements on track.

Member Function Documentation

◆ add()

bool Muon::NSWSeed::add ( SeedMeasurement meas,
double max_uncert )

Tries to add the measurement to the seeds. Returns false if the measurement is incompatible with the seed or the seed is invalid.

Definition at line 160 of file MuonNSWSegmentFinderTool.cxx.

160 {
161 if (!size() || !meas) return false;
162 if (find(meas)) return true;
163 Trk::Intersection intersect = meas->associatedSurface().straightLineIntersection(pos(), dir(), false, false);
164 Amg::Vector2D lpos_seed{Amg::Vector2D::Zero()};
165 if (!meas->associatedSurface().globalToLocal(intersect.position, dir(), lpos_seed)) return false;
166 // Dont allow seeds outside of active areas to create seeds
167 // Happens rarely but is good protection to reduce wrong channel to track association
168 if (!meas->associatedSurface().insideBounds(lpos_seed)) return false;
169
170 // Dont save sTGC wires in inner Q1
171 if (m_parent->isWire(meas)) {
172 const sTgcPrepData* prd = static_cast<const sTgcPrepData*>(meas->prepRawData());
173 if (prd->detectorElement()->isEtaZero(prd->identify(), lpos_seed)) return false;
174 }
175
176 if (m_parent->isPad(meas)) {
177 const sTgcPrepData* prd = dynamic_cast<const sTgcPrepData*>(meas->prepRawData());
178 if (!prd) return false;
179 const MuonGM::MuonPadDesign* design = prd->detectorElement()->getPadDesign(prd->identify());
180 if (!design) return false;
181 Amg::Vector2D padDist = design->distanceToPad(lpos_seed, channel(meas));
182 const double dist = std::hypot(padDist.x(), padDist.y());
183 meas.setDistance(dist);
184 const double uncertD = std::max(1., m_width);
185 return (meas.distance() / uncertD < max_uncert) && insert(meas);
186 }
187 meas.setDistance(distance(meas));
188 const double uncertD = std::max(1.,std::hypot(m_width, Amg::error(meas->localCovariance(), Trk::locX)));
189 if (m_parent->msgLvl(MSG::VERBOSE)) {
190 m_parent->msgStream() << MSG::VERBOSE << m_parent->print(meas) << " is separated from "
191 << to_string(pos())<<" + lambda " <<to_string(dir())<<" " << meas.distance()
192 << ". covariance: " << (meas.distance() / uncertD) << endmsg;
193 }
194 return (meas.distance() / uncertD < max_uncert) && insert(meas);
195 }
std::optional< double > intersect(const AmgVector(N)&posA, const AmgVector(N)&dirA, const AmgVector(N)&posB, const AmgVector(N)&dirB)
Calculates the point B' along the line B that's closest to a second line A.
Eigen::Matrix< double, 2, 1 > Vector2D
Amg::Vector2D distanceToPad(const Amg::Vector2D &pos, int channel) const
bool find(const SeedMeasurement &meas) const
Checks whether the measurement is already part of the seed.
int channel(const SeedMeasurement &meas) const
Returns the channel of the measurement on the layer.
double distance(const SeedMeasurement &meas) const
Calculates the minimal distance between seed and measurement.

◆ channel()

int Muon::NSWSeed::channel ( const SeedMeasurement & meas) const
private

Returns the channel of the measurement on the layer.

Definition at line 146 of file MuonNSWSegmentFinderTool.cxx.

146{return m_parent->channel(meas);}

◆ chi2()

double Muon::NSWSeed::chi2 ( ) const
inline

Definition at line 73 of file MuonNSWSegmentFinderTool.h.

73{return m_chi2;}

◆ dir()

const Amg::Vector3D & Muon::NSWSeed::dir ( ) const
inline

Returns the direction of the seed.

Definition at line 79 of file MuonNSWSegmentFinderTool.h.

79{ return m_dir; }

◆ distance()

double Muon::NSWSeed::distance ( const SeedMeasurement & meas) const
private

Calculates the minimal distance between seed and measurement.

Definition at line 147 of file MuonNSWSegmentFinderTool.cxx.

147 {
148 const Amg::Vector3D& A = pos();
149 const Amg::Vector3D& B = dir();
150 const Amg::Vector3D& C = meas.pos();
151 const Amg::Vector3D& D = meas.dir();
152 const double BdotD = B.dot(D);
153 const double divisor = (1. - std::pow(BdotD, 2));
154 const Amg::Vector3D diff = C - A;
155 if (std::abs(divisor) < std::numeric_limits<double>::epsilon()) return diff.mag();
156 const double beta = (diff.dot(B) - diff.dot(D) * BdotD) / divisor;
157 const double delta = (diff.dot(B) * BdotD - diff.dot(D)) / divisor;
158 return (beta * B - delta * D - diff).mag();
159 }
void diff(const Jet &rJet1, const Jet &rJet2, std::map< std::string, double > varDiff)
Difference between jets - Non-Class function required by trigger.
Definition Jet.cxx:631
struct color C

◆ find()

bool Muon::NSWSeed::find ( const SeedMeasurement & meas) const
private

Checks whether the measurement is already part of the seed.

Definition at line 248 of file MuonNSWSegmentFinderTool.cxx.

248 {
249 const int lay = m_parent->layerNumber(meas);
250 if (m_parent->isPad(meas)) return m_padMeasurements[lay] == meas;
251 if (m_parent->idHelper()->measuresPhi(meas->identify())) return m_phiMeasurements[lay] == meas;
252 return m_measurements[lay] == meas;
253 }
SeedMeasCache m_phiMeasurements
Cache the phi measurements.
SeedMeasCache m_measurements
Cache the eta measurements.
SeedMeasCache m_padMeasurements
Cache the sTGC pad measurements.

◆ insert() [1/2]

bool Muon::NSWSeed::insert ( const Muon::MuonClusterOnTrack * cl)
private

Definition at line 226 of file MuonNSWSegmentFinderTool.cxx.

226 {
227 SeedMeasurement meas{cl};
228 meas.setDistance(distance(meas));
229 return insert(std::move(meas));
230 }

◆ insert() [2/2]

bool Muon::NSWSeed::insert ( SeedMeasurement meas)
private

Definition at line 231 of file MuonNSWSegmentFinderTool.cxx.

231 {
232 SeedMeasCache& seed_vec = m_parent->idHelper()->measuresPhi(meas->identify()) ?
234 SeedMeasurement& seed = seed_vec[m_parent->layerNumber(meas)];
235 if (!seed || meas.distance() < seed.distance()) {
236 m_size += !seed;
237 m_chi2 += meas.distance() / Amg::error(meas->localCovariance(), Trk::locX);
238 // From this point the measurement is now the old one
239 std::swap(seed, meas);
240 if (meas) m_chi2 -= meas.distance() / Amg::error(meas->localCovariance(), Trk::locX);
241 return true;
242 }
243 return false;
244 }
void swap(ElementLinkVector< DOBJ > &lhs, ElementLinkVector< DOBJ > &rhs)
std::array< SeedMeasurement, 16 > SeedMeasCache
Helper pair to cache the measurements with the respective distances.

◆ measurements()

MeasVec Muon::NSWSeed::measurements ( ) const

Definition at line 213 of file MuonNSWSegmentFinderTool.cxx.

213 {
214 MeasVec meas;
215 meas.reserve(size());
216 for (size_t m = 0; m < m_measurements.size(); ++m) {
217 if (m_measurements[m]) meas.push_back(m_measurements[m]);
218 if (m_phiMeasurements[m]) meas.push_back(m_phiMeasurements[m]);
219 if (m_padMeasurements[m]) meas.push_back(m_padMeasurements[m]);
220 }
221 std::sort(meas.begin(), meas.end(), [](const SeedMeasurement& a, const SeedMeasurement& b) {
222 return std::abs(a->globalPosition().z()) < std::abs(b->globalPosition().z());
223 });
224 return meas;
225 }
static Double_t a
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
std::vector< SeedMeasurement > MeasVec
Returns the contained measurements.

◆ newCalibClust()

const Muon::MuonClusterOnTrack * Muon::NSWSeed::newCalibClust ( std::unique_ptr< const Muon::MuonClusterOnTrack > new_clust)

Adds a calibrated cluster to the garbage collection.

Definition at line 245 of file MuonNSWSegmentFinderTool.cxx.

245 {
246 return m_calibClust.emplace(std::move(new_clust)).first->get();
247 }
std::set< std::shared_ptr< const Muon::MuonClusterOnTrack > > m_calibClust
Garbage container per seed.

◆ overlap()

NSWSeed::SeedOR Muon::NSWSeed::overlap ( const NSWSeed & other) const

Definition at line 196 of file MuonNSWSegmentFinderTool.cxx.

196 {
198 unsigned int only_th{0}, only_oth{0};
199 for (size_t m = 0; m < m_measurements.size(); ++m) {
200 if (m_measurements[m]== other.m_measurements[m] &&
201 m_phiMeasurements[m] == other.m_phiMeasurements[m])
202 continue;
204 if (!m_measurements[m]) ++only_oth;
205 if (!m_phiMeasurements[m]) ++only_oth;
206 if (!other.m_measurements[m]) ++only_th;
207 if (!other.m_phiMeasurements[m]) ++only_th;
208 }
209 if (only_oth && !only_th) return SeedOR::SubSet;
210 if (only_th && !only_oth) return SeedOR::SuperSet;
211 return res;
212 }
std::pair< std::vector< unsigned int >, bool > res

◆ pos()

const Amg::Vector3D & Muon::NSWSeed::pos ( ) const
inline

Returns the position of the seed.

Definition at line 77 of file MuonNSWSegmentFinderTool.h.

77{ return m_pos; }

◆ size()

size_t Muon::NSWSeed::size ( ) const
inline

Returns the number of measurements.

Definition at line 75 of file MuonNSWSegmentFinderTool.h.

75{ return m_size; }

Member Data Documentation

◆ m_calibClust

std::set<std::shared_ptr<const Muon::MuonClusterOnTrack> > Muon::NSWSeed::m_calibClust {}
private

Garbage container per seed.

Definition at line 123 of file MuonNSWSegmentFinderTool.h.

123{};

◆ m_chi2

double Muon::NSWSeed::m_chi2 {0.}
private

Chi2.

Definition at line 119 of file MuonNSWSegmentFinderTool.h.

119{0.};

◆ m_dir

Amg::Vector3D Muon::NSWSeed::m_dir {Amg::Vector3D::Zero()}
private

Seed direction.

Definition at line 115 of file MuonNSWSegmentFinderTool.h.

115{Amg::Vector3D::Zero()};

◆ m_measurements

SeedMeasCache Muon::NSWSeed::m_measurements {}
private

Cache the eta measurements.

Definition at line 107 of file MuonNSWSegmentFinderTool.h.

107{};

◆ m_padMeasurements

SeedMeasCache Muon::NSWSeed::m_padMeasurements {}
private

Cache the sTGC pad measurements.

Definition at line 111 of file MuonNSWSegmentFinderTool.h.

111{};

◆ m_parent

const MuonNSWSegmentFinderTool* Muon::NSWSeed::m_parent {nullptr}
private

Definition at line 103 of file MuonNSWSegmentFinderTool.h.

103{nullptr};

◆ m_phiMeasurements

SeedMeasCache Muon::NSWSeed::m_phiMeasurements {}
private

Cache the phi measurements.

Definition at line 109 of file MuonNSWSegmentFinderTool.h.

109{};

◆ m_pos

Amg::Vector3D Muon::NSWSeed::m_pos {Amg::Vector3D::Zero()}
private

Starting position of the seed.

Definition at line 113 of file MuonNSWSegmentFinderTool.h.

113{Amg::Vector3D::Zero()};

◆ m_size

size_t Muon::NSWSeed::m_size {0}
private

Added measurements on track.

Definition at line 121 of file MuonNSWSegmentFinderTool.h.

121{0};

◆ m_width

double Muon::NSWSeed::m_width {0.}
private

seed width

Definition at line 117 of file MuonNSWSegmentFinderTool.h.

117{0.};

The documentation for this struct was generated from the following files: