ATLAS Offline Software
Loading...
Searching...
No Matches
MuonNSWSegmentFinderTool.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef MUONNSWSEGMENTFINDERTOOL_H
6#define MUONNSWSEGMENTFINDERTOOL_H
7
8#include <utility>
9#include <vector>
10
26namespace Muon {
27
29 struct NSWSeed {
30
34 SeedMeasurement() = default;
35 explicit SeedMeasurement(const Muon::MuonClusterOnTrack* cl) ;
37 const Muon::MuonClusterOnTrack* get() const{return m_cl;}
38 const Muon::MuonClusterOnTrack* operator->() const{return get();}
39 operator const Muon::MuonClusterOnTrack* () const { return get(); }
40
41 bool operator==(const SeedMeasurement& other) const {return get() == other.get();}
42 bool operator!() const {return !get();}
43 operator bool() const {return get();}
44
45 const Amg::Vector3D& dir() const {return m_dir;}
46 const Amg::Vector3D& pos() const {return m_cl->globalPosition();}
47
48 double dirDot(const SeedMeasurement& other) const {return dirDot(other.dir());}
49 double dirDot(const Amg::Vector3D& v) const { return dir().dot(v); }
50
51 void setDistance(double d){m_distance = d;}
52 double distance() const {return m_distance;}
53
54 private:
56 Amg::Vector3D m_dir {Amg::Vector3D::Zero()};
57 double m_distance{0.};
58 };
59
60 NSWSeed() = default;
61
63 NSWSeed(const MuonNSWSegmentFinderTool* parent, const std::array<SeedMeasurement, 4>& seed,
64 const std::array<double, 2>& lengths);
65
67 NSWSeed(const MuonNSWSegmentFinderTool* parent, const SeedMeasurement& first, const SeedMeasurement& second);
69 NSWSeed(const MuonNSWSegmentFinderTool* parent, const Muon::MuonSegment& seg);
72
73 double chi2() const {return m_chi2;}
75 size_t size() const { return m_size; }
77 const Amg::Vector3D& pos() const { return m_pos; }
79 const Amg::Vector3D& dir() const { return m_dir; }
80
82 using MeasVec = std::vector<SeedMeasurement>;
83 MeasVec measurements() const;
85 bool add(SeedMeasurement meas, double max_uncert);
87 const Muon::MuonClusterOnTrack* newCalibClust(std::unique_ptr<const Muon::MuonClusterOnTrack> new_clust);
88
89 enum class SeedOR { NoOverlap, Same, SubSet, SuperSet };
90 SeedOR overlap(const NSWSeed& other) const;
91
92 private:
94 int channel(const SeedMeasurement& meas) const;
96 bool find(const SeedMeasurement& meas) const;
98 double distance(const SeedMeasurement& meas) const;
99 bool insert(const Muon::MuonClusterOnTrack* cl);
100
101 bool insert(SeedMeasurement meas);
102
105 using SeedMeasCache = std::array<SeedMeasurement, 16>;
113 Amg::Vector3D m_pos{Amg::Vector3D::Zero()};
115 Amg::Vector3D m_dir{Amg::Vector3D::Zero()};
117 double m_width{0.};
119 double m_chi2{0.};
121 size_t m_size{0};
123 std::set<std::shared_ptr<const Muon::MuonClusterOnTrack>> m_calibClust{};
124 };
125
127 public:
129 MuonNSWSegmentFinderTool(const std::string& type, const std::string& name, const IInterface* parent);
131 virtual ~MuonNSWSegmentFinderTool() = default;
132
133 virtual StatusCode initialize() override;
134
135 private:
137 this,
138 "MuonIdHelperSvc",
139 "Muon::MuonIdHelperSvc/MuonIdHelperSvc",
140 };
142 this,
143 "edmHelper",
144 "Muon::MuonEDMHelperSvc/MuonEDMHelperSvc",
145 "Handle to the service providing the IMuonEDMHelperSvc interface",
146 }; //<! Id helper tool
147
148 ToolHandle<Trk::ITrackAmbiguityProcessorTool> m_ambiTool{
149 this,
150 "SegmentAmbiguityTool",
151 "Trk::SimpleAmbiguityProcessorTool/MuonAmbiProcessor",
152 };
153 ToolHandle<Trk::ITrackFitter> m_slTrackFitter{
154 this,
155 "SLFitter",
156 "Trk::GlobalChi2Fitter/MCTBSLFitter",
157 }; //<! fitter, always use straightline
158 ToolHandle<IMuonTrackToSegmentTool> m_trackToSegmentTool{
159 this,
160 "TrackToSegmentTool",
161 "Muon::MuonTrackToSegmentTool/MuonTrackToSegmentTool",
162 }; //<! track to segment converter
163 PublicToolHandle<MuonEDMPrinterTool> m_printer{
164 this,
165 "Printer",
166 "Muon::MuonEDMPrinterTool/MuonEDMPrinterTool",
167 };
168 ToolHandle<IMuonTrackCleaner> m_trackCleaner{
169 this,
170 "TrackCleaner",
171 "Muon::MuonTrackCleaner/MuonTrackCleaner",
172 };
173 ToolHandle<Trk::ITrackSummaryTool> m_trackSummary{
174 this,
175 "TrackSummaryTool",
176 "Trk::TrackSummaryTool/MuidTrackSummaryTool",
177 };
178
179 ToolHandle<IMuonClusterOnTrackCreator> m_muonClusterCreator{this, "MuonClusterCreator", ""};
180
181 Gaudi::Property<bool> m_ipConstraint{this, "IPConstraint", true}; // use a ip perigee(0,0) constraint in the segment fit
182
184 Gaudi::Property<bool> m_caloConstraint{this, "CaloConstraint", false};
185 Gaudi::Property<double> m_maxClustDist{this, "ClusterDistance", 5.};
186 Gaudi::Property<int> m_nOfSeedLayers{this, "NOfSeedLayers", 1};
187
188
189 Gaudi::Property<bool> m_useStereoSeeding{this, "SeedMMStereos", true};
190 Gaudi::Property<bool> m_usesTGCSeeding{this, "SeedWithsTGCS", true};
191
193 Gaudi::Property<unsigned int> m_ocupMmBinWidth{this, "MmOccupancyBinWidth", 100,
194 "Size of the channel window to group the MicroMegaCluster"};
195 Gaudi::Property<unsigned int> m_ocupMmNumPerBin{this, "MmOccupancySingleCut", 5,
196 "Cut on the number of MicroMega clusters in a particular occupancy bin"};
197 Gaudi::Property<unsigned int> m_ocupMmNumPerPair{this, "MmOccupancyPairCut", 7,
198 "Cut on the number of MicroMega clusters in two neighbouring occupancy bins"};
199 Gaudi::Property<uint> m_maxInputPads{this, "maxInputPads", 40, "Maximum number of pads per wedge layer."};
200
201 public:
204 using LayerMeasVec = std::vector<MeasVec>;
205
206
207 // find segments given a list of MuonCluster
208 // segments can be added directly to a SegmentCollection, if they are to be written to SG, or returned in a list for
209 // further processing
210 void find(const EventContext& ctx, SegmentMakingCache& cache) const override;
211
212 int wedgeNumber(const Muon::MuonClusterOnTrack* cluster) const;
213 int layerNumber(const Muon::MuonClusterOnTrack* cluster) const;
215 int channel(const Muon::MuonClusterOnTrack* cluster) const;
216
217 const IMuonIdHelperSvc* idHelper() const;
218 bool isPad(const Muon::MuonClusterOnTrack* clust) const;
219 bool isStrip(const Muon::MuonClusterOnTrack* clust) const;
220 bool isWire(const Muon::MuonClusterOnTrack* clust) const;
221 template <size_t N>
222 std::string printSeed(const std::array<SeedMeasurement, N>& seed) const;
223 std::string print(const SeedMeasurement& meas) const;
224 std::string print(const MeasVec& clusters) const;
225 std::string print(const LayerMeasVec& sortedVec) const;
226
227
228
229 private:
230 enum HitType { Eta = 1, Phi = 1 << 1, Wire = 1 << 2, Pad = 1 << 3 };
231
238 std::vector<std::unique_ptr<Muon::MuonSegment>> findStereoSegments(const EventContext& ctx,
239 const std::vector<const Muon::MuonClusterOnTrack*>& allClusts,
240 int singleWedge = 0) const;
241
243 std::vector<std::unique_ptr<Muon::MuonSegment>> findStgcPrecisionSegments(const EventContext& ctx,
244 const std::vector<const Muon::MuonClusterOnTrack*>& MuonClusters,
245 int singleWedge = 0) const;
246 // recontruct 3D segments
247 std::vector<std::unique_ptr<Muon::MuonSegment>> find3DSegments(const EventContext& ctx,
248 const std::vector<const Muon::MuonClusterOnTrack*>& MuonClusters,
249 std::vector<std::unique_ptr<Muon::MuonSegment>>& etaSegs,
250 int singleWedge = 0) const;
251 // clean the clusters
252 MeasVec cleanClusters(const std::vector<const Muon::MuonClusterOnTrack*>& MuonClusters,
253 int hit_sel, int singleWedge) const;
254
255 // classify clusters by layer (one vector per layer)
256 LayerMeasVec classifyByLayer(const MeasVec& clusters, int hit_sel) const;
257
258 // find segment seeds
259 std::vector<NSWSeed> segmentSeedFromStgc(const LayerMeasVec& orderedClusters,
260 bool usePhi) const;
261
262 std::vector<NSWSeed> segmentSeedFromMM(const LayerMeasVec& orderedClusters) const;
263 std::vector<NSWSeed> segmentSeedFromMM(const LayerMeasVec& orderedClusters,
264 std::array<unsigned int,4> selLayers,
265 unsigned int& trial_counter) const;
266
267
268 std::vector<NSWSeed> segmentSeedFromPads(const LayerMeasVec& orderedClusters,
269 const Muon::MuonSegment& etaSeg) const;
270
271 std::vector<std::pair<double, double>> getPadPhiOverlap(const std::vector<std::vector<const Muon::sTgcPrepData*>>& pads) const;
272
273 // associate clusters to the segment seeds
274 int getClustersOnSegment(const LayerMeasVec& orderedclusters, NSWSeed& seed,
275 const std::set<unsigned int>& exclude, bool useStereo=true ) const;
276
277 // get the clusters after calibration
279
280 // fit eta and phi hits and fill the track collection
281 bool hitsToTrack(const EventContext& ctx, const MeasVec& etaHitVec,
282 const MeasVec& phiHitVec, const Trk::TrackParameters& startpar,
283 TrackCollection& segTrkColl) const;
284
286 std::unique_ptr<Trk::PseudoMeasurementOnTrack> ipConstraint(const EventContext& ctx) const;
287 std::unique_ptr<Trk::PseudoMeasurementOnTrack> caloConstraint(const Trk::TrackParameters& startpar) const;
288
289
290 std::vector<NSWSeed> resolveAmbiguities(std::vector<NSWSeed>&& unresolved) const;
291 std::vector<std::unique_ptr<Muon::MuonSegment>> resolveAmbiguities(const EventContext& ctx,
292 const TrackCollection& segColl,
293 const Trk::Segment::Author a) const;
294 std::unique_ptr<Trk::Track> fit(const EventContext& ctx, const std::vector<const Trk::MeasurementBase*>& fit_meas,
295 const Trk::TrackParameters& perigee) const;
296
297
304
305 ChannelConstraint compatiblyFromIP(const SeedMeasurement& meas1, const SeedMeasurement& meas2) const;
307 std::pair<double, double> coveredRadii(const SeedMeasurement& meas) const;
308
310 MeasVec vetoBursts( MeasVec && clustInLay ) const;
311
312 };
313
314} // namespace Muon
315#endif // MUONROADFINDERTOOL_H
static Double_t a
DataVector< Trk::Track > TrackCollection
This typedef represents a collection of Trk::Track objects.
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
Interface for Helper service that creates muon Identifiers and can be used to print Identifiers.
Base class for Muon cluster RIO_OnTracks.
bool hitsToTrack(const EventContext &ctx, const MeasVec &etaHitVec, const MeasVec &phiHitVec, const Trk::TrackParameters &startpar, TrackCollection &segTrkColl) const
std::pair< double, double > coveredRadii(const SeedMeasurement &meas) const
Returns the minimal & maximal radial distance of a measurement.
MeasVec getCalibratedClusters(NSWSeed &seed) const
MeasVec cleanClusters(const std::vector< const Muon::MuonClusterOnTrack * > &MuonClusters, int hit_sel, int singleWedge) const
int layerNumber(const Muon::MuonClusterOnTrack *cluster) const
MuonNSWSegmentFinderTool(const std::string &type, const std::string &name, const IInterface *parent)
default constructor
std::string printSeed(const std::array< SeedMeasurement, N > &seed) const
std::vector< std::unique_ptr< Muon::MuonSegment > > findStereoSegments(const EventContext &ctx, const std::vector< const Muon::MuonClusterOnTrack * > &allClusts, int singleWedge=0) const
Runs the NSW segment maker by combining 4 Micromega layers to a stereo seed.
std::unique_ptr< Trk::PseudoMeasurementOnTrack > caloConstraint(const Trk::TrackParameters &startpar) const
virtual StatusCode initialize() override
std::vector< NSWSeed > resolveAmbiguities(std::vector< NSWSeed > &&unresolved) const
ToolHandle< Trk::ITrackSummaryTool > m_trackSummary
std::vector< NSWSeed > segmentSeedFromPads(const LayerMeasVec &orderedClusters, const Muon::MuonSegment &etaSeg) const
std::string print(const SeedMeasurement &meas) const
ServiceHandle< IMuonIdHelperSvc > m_idHelperSvc
void find(const EventContext &ctx, SegmentMakingCache &cache) const override
Gaudi::Property< bool > m_caloConstraint
Use a virtual point at the calorimeter exit with same Z as constraint...
const IMuonIdHelperSvc * idHelper() const
std::vector< NSWSeed > segmentSeedFromMM(const LayerMeasVec &orderedClusters) const
std::vector< NSWSeed > segmentSeedFromStgc(const LayerMeasVec &orderedClusters, bool usePhi) const
Gaudi::Property< unsigned int > m_ocupMmNumPerPair
std::vector< std::unique_ptr< Muon::MuonSegment > > findStgcPrecisionSegments(const EventContext &ctx, const std::vector< const Muon::MuonClusterOnTrack * > &MuonClusters, int singleWedge=0) const
Combines 2 sTgc strip layers to find 2D segments constraining the muon in the eta direction.
LayerMeasVec classifyByLayer(const MeasVec &clusters, int hit_sel) const
std::unique_ptr< Trk::PseudoMeasurementOnTrack > ipConstraint(const EventContext &ctx) const
creates the IP constraint
int channel(const Muon::MuonClusterOnTrack *cluster) const
Returns the channel of the measurement on the layer.
Gaudi::Property< double > m_maxClustDist
ServiceHandle< IMuonEDMHelperSvc > m_edmHelperSvc
PublicToolHandle< MuonEDMPrinterTool > m_printer
bool isStrip(const Muon::MuonClusterOnTrack *clust) const
int wedgeNumber(const Muon::MuonClusterOnTrack *cluster) const
ToolHandle< Trk::ITrackAmbiguityProcessorTool > m_ambiTool
Tool for ambiguity solving.
MeasVec vetoBursts(MeasVec &&clustInLay) const
Removes clusters from high activity areas in the detector.
int getClustersOnSegment(const LayerMeasVec &orderedclusters, NSWSeed &seed, const std::set< unsigned int > &exclude, bool useStereo=true) const
ToolHandle< IMuonTrackToSegmentTool > m_trackToSegmentTool
ToolHandle< IMuonClusterOnTrackCreator > m_muonClusterCreator
ToolHandle< IMuonTrackCleaner > m_trackCleaner
Gaudi::Property< unsigned int > m_ocupMmNumPerBin
Gaudi::Property< unsigned int > m_ocupMmBinWidth
Protection against slobbering Micromega events.
ToolHandle< Trk::ITrackFitter > m_slTrackFitter
std::unique_ptr< Trk::Track > fit(const EventContext &ctx, const std::vector< const Trk::MeasurementBase * > &fit_meas, const Trk::TrackParameters &perigee) const
virtual ~MuonNSWSegmentFinderTool()=default
destructor
std::vector< std::unique_ptr< Muon::MuonSegment > > find3DSegments(const EventContext &ctx, const std::vector< const Muon::MuonClusterOnTrack * > &MuonClusters, std::vector< std::unique_ptr< Muon::MuonSegment > > &etaSegs, int singleWedge=0) const
std::vector< std::pair< double, double > > getPadPhiOverlap(const std::vector< std::vector< const Muon::sTgcPrepData * > > &pads) const
bool isWire(const Muon::MuonClusterOnTrack *clust) const
ChannelConstraint compatiblyFromIP(const SeedMeasurement &meas1, const SeedMeasurement &meas2) const
Checks whether the two measurements are compatible within the IP constraint.
bool isPad(const Muon::MuonClusterOnTrack *clust) const
This is the common class for 3D segments used in the muon spectrometer.
Author
enum to identify who created the segment.
std::set< std::string > exclude
list of directories to be excluded
Definition hcg.cxx:98
Eigen::Matrix< double, 3, 1 > Vector3D
NRpcCablingAlg reads raw condition data and writes derived condition data to the condition store.
NSWSeed::MeasVec MeasVec
Stereo seeds can be formed using hits from 4 independent layers by solving the following system of eq...
ParametersBase< TrackParametersDim, Charged > TrackParameters
Struct caching the MuonClusterOnTrack and providing the orientation of the strip in addtion.
const Amg::Vector3D & dir() const
bool operator==(const SeedMeasurement &other) const
const Muon::MuonClusterOnTrack * m_cl
double dirDot(const Amg::Vector3D &v) const
const Muon::MuonClusterOnTrack * operator->() const
const Muon::MuonClusterOnTrack * get() const
Accomodations of the interface to make the changes as transparent as possible.
const Amg::Vector3D & pos() const
double dirDot(const SeedMeasurement &other) const
NSWSeed()=default
const Muon::MuonClusterOnTrack * newCalibClust(std::unique_ptr< const Muon::MuonClusterOnTrack > new_clust)
Adds a calibrated cluster to the garbage collection.
SeedOR overlap(const NSWSeed &other) const
size_t m_size
Added measurements on track.
SeedMeasCache m_phiMeasurements
Cache the phi measurements.
std::array< SeedMeasurement, 16 > SeedMeasCache
Helper pair to cache the measurements with the respective distances.
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.
bool find(const SeedMeasurement &meas) const
Checks whether the measurement is already part of the seed.
SeedMeasCache m_measurements
Cache the eta measurements.
SeedMeasCache m_padMeasurements
Cache the sTGC pad measurements.
std::set< std::shared_ptr< const Muon::MuonClusterOnTrack > > m_calibClust
Garbage container per seed.
size_t size() const
Returns the number of measurements.
const MuonNSWSegmentFinderTool * m_parent
bool insert(const Muon::MuonClusterOnTrack *cl)
double m_width
seed width
int channel(const SeedMeasurement &meas) const
Returns the channel of the measurement on the layer.
const Amg::Vector3D & dir() const
Returns the direction of the seed.
bool add(SeedMeasurement meas, double max_uncert)
Tries to add the measurement to the seeds. Returns false if the measurement is incompatible with the ...
double distance(const SeedMeasurement &meas) const
Calculates the minimal distance between seed and measurement.
std::vector< SeedMeasurement > MeasVec
Returns the contained measurements.