ATLAS Offline Software
Loading...
Searching...
No Matches
MuPatTrack.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef MUPATTRACK_H
6#define MUPATTRACK_H
7
8#include <mutex>
9#include <set>
10#include <string>
11#include <vector>
12
17#include "TrkTrack/Track.h"
19
20namespace Muon {
21
37 class MuPatTrack : public MuPatCandidateBase, public Trk::ObjectCounter<MuPatTrack> {
38 friend class MuPatCandidateTool;
39
40 public:
61
63 static const std::string& processingStageString(ProcessingStage stage);
64
66 static unsigned int processingStageStringMaxLen();
67
70 MuPatTrack(const std::vector<MuPatSegment*>& segments, std::unique_ptr<Trk::Track>& track, MuPatSegment* seedSeg = 0);
71
74 MuPatTrack(MuPatSegment* segment, std::unique_ptr<Trk::Track>& track);
75
78 MuPatTrack(MuPatSegment* segment1, MuPatSegment* segment2, std::unique_ptr<Trk::Track>& track, MuPatSegment* seedSeg = 0);
79
82
85 MuPatTrack(const MuPatTrack& can);
86
89 MuPatTrack& operator=(const MuPatTrack& can);
90
92 Trk::Track& track() const;
94 void updateTrack(std::unique_ptr<Trk::Track>& newTrack);
95
97 const std::vector<MuPatSegment*>& segments() const;
98
100 MuPatSegment* seedSegment() const;
101
103 const std::vector<MuPatSegment*>& excludedSegments() const;
104
106 void addSegment(MuPatSegment* segment, std::unique_ptr<Trk::Track>& newTrack);
107
109 void addExcludedSegment(MuPatSegment* segment);
111 bool isSegmentExcluded(const MuPatSegment* segment) const;
112
114 const Trk::TrackParameters& entryPars() const;
115
117 bool hasMomentum() const;
118
120 std::vector<MuonStationIndex::StIndex> stationsInOrder();
121
123 bool resetChambersOnCandidate(const std::set<MuonStationIndex::ChIndex>& chambers);
124
126 std::string segmentNames() const;
127
128 private:
129 //
130 // private member functions
131 //
133 static std::vector<std::string> initProcessingStageStrings();
135 static const std::vector<std::string>& processingStageStrings();
136
138 void updateSegments(bool add);
139
140 public:
141 //
142 // public data members
143 //
146
147 private:
148
149
151 void modifySegmentCounters(int change);
152
154 static bool hasMomentum(const Trk::Track& track) ;
155
156 std::vector<MuPatSegment*> m_segments{}; //<! list of associated segments
157 std::vector<MuPatSegment*> m_excludedSegments{}; //<! list of associated segments
158 std::unique_ptr<Trk::Track> m_track{}; //<! associated track
160
161 }; // class MuPatTrack
162
163
164 //
165 // inline member functions implementations
166 //
167 inline const std::vector<MuPatSegment*>& MuPatTrack::segments() const { return m_segments; }
168
170 return m_seedSeg; // could be a null pointer - do not dereference immediately!!
171 }
172
173 inline const std::vector<MuPatSegment*>& MuPatTrack::excludedSegments() const { return m_excludedSegments; }
174
175 inline Trk::Track& MuPatTrack::track() const { return *m_track; }
176
178 const Trk::Perigee* pp = m_track->perigeeParameters();
179 if (pp) { return *pp; }
180 assert(!m_track->trackParameters() || m_track->trackParameters()->empty());
181 return *m_track->trackParameters()->front();
182 }
183
185 public:
186 bool operator()(const MuPatTrack* c1, const MuPatTrack* c2) {
187 // prefer candidates with more segments
188 if (c1->segments().size() > c2->segments().size()) return true;
189 if (c1->segments().size() < c2->segments().size()) return false;
190
191 // prefer tracks with fit quality (always expected)
192 const Trk::FitQuality* fq1 = c1->track().fitQuality();
193 const Trk::FitQuality* fq2 = c2->track().fitQuality();
194 if (!fq1) return false;
195 if (!fq2) return true;
196
197 if (fq1->numberDoF() > fq2->numberDoF()) return true;
198 if (fq1->numberDoF() < fq2->numberDoF()) return false;
199
200 // select candidate with smallest chi2
201 double chi2Ndof1 = fq1->chiSquared() / fq1->numberDoF();
202 double chi2Ndof2 = fq2->chiSquared() / fq2->numberDoF();
203 return chi2Ndof1 < chi2Ndof2;
204 }
205 };
206
207} // namespace Muon
208
209#endif
MuPatCandidateBase()=default
constructor.
const std::set< MuonStationIndex::ChIndex > & chambers() const
returns set with contained chamberIndices
segment candidate object.
track candidate object.
Definition MuPatTrack.h:37
bool isSegmentExcluded(const MuPatSegment *segment) const
loops over the excluded segment collection and checks whether the pointer is in there
static const std::vector< std::string > & processingStageStrings()
Return list of processing stage strings.
void addExcludedSegment(MuPatSegment *segment)
add segment that does not match the track
std::vector< MuonStationIndex::StIndex > stationsInOrder()
returns vector with contained stationIndices in the order they were added
Trk::Track & track() const
access to track
Definition MuPatTrack.h:175
void updateSegments(bool add)
update segment/track association, if add == true ,will add track to segments else remove it
MuPatSegment * m_seedSeg
The special segment for this track.
Definition MuPatTrack.h:159
ProcessingStage created
Definition MuPatTrack.h:144
static std::vector< std::string > initProcessingStageStrings()
Initialize s_processingStageStrings & s_processingStageStringMaxLen.
static const std::string & processingStageString(ProcessingStage stage)
Convert enum to string.
bool hasMomentum() const
returns whether canditate has a momentum measurement
friend class MuPatCandidateTool
Definition MuPatTrack.h:38
MuPatTrack & operator=(const MuPatTrack &can)
assignment operator.
ProcessingStage
enum to keep track of the life of candidates
Definition MuPatTrack.h:42
@ AmbiguityCreateCandidateFromSeeds
Definition MuPatTrack.h:50
void updateTrack(std::unique_ptr< Trk::Track > &newTrack)
update track.
void addSegment(MuPatSegment *segment, std::unique_ptr< Trk::Track > &newTrack)
add segment + the associated new track.
ProcessingStage lastSegmentChange
Definition MuPatTrack.h:145
~MuPatTrack()
destructor, decrease the usedInFit counter of all MuPatSegment objects by one
void modifySegmentCounters(int change)
increase the segment counters by the passed number
MuPatSegment * seedSegment() const
Return pointer to the seed segment.
Definition MuPatTrack.h:169
MuPatTrack(const std::vector< MuPatSegment * > &segments, std::unique_ptr< Trk::Track > &track, MuPatSegment *seedSeg=0)
constructor taking a vector of MuPatSegment object, the candidate takes ownership of the track It wil...
const std::vector< MuPatSegment * > & excludedSegments() const
access to segments
Definition MuPatTrack.h:173
std::vector< MuPatSegment * > m_segments
Definition MuPatTrack.h:156
std::vector< MuPatSegment * > m_excludedSegments
Definition MuPatTrack.h:157
bool resetChambersOnCandidate(const std::set< MuonStationIndex::ChIndex > &chambers)
reset chambers on the candidate.
static unsigned int processingStageStringMaxLen()
maximum width of the strings corresponding to the ProcessingStage
std::unique_ptr< Trk::Track > m_track
Definition MuPatTrack.h:158
std::string segmentNames() const
string containing the names of the segments on the candidate
const Trk::TrackParameters & entryPars() const
returns first track parameters
Definition MuPatTrack.h:177
const std::vector< MuPatSegment * > & segments() const
access to segments
Definition MuPatTrack.h:167
bool operator()(const MuPatTrack *c1, const MuPatTrack *c2)
Definition MuPatTrack.h:186
Class to represent and store fit qualities from track reconstruction in terms of and number of degre...
Definition FitQuality.h:97
int numberDoF() const
returns the number of degrees of freedom of the overall track or vertex fit as integer
Definition FitQuality.h:60
double chiSquared() const
returns the of the overall track fit
Definition FitQuality.h:56
Helper to enable counting number of instantiations in debug builds.
bool add(const std::string &hname, TKey *tobj)
Definition fastadd.cxx:55
NRpcCablingAlg reads raw condition data and writes derived condition data to the condition store.
ParametersT< TrackParametersDim, Charged, PerigeeSurface > Perigee
ParametersBase< TrackParametersDim, Charged > TrackParameters