ATLAS Offline Software
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 
20 namespace Muon {
21 
37  class MuPatTrack : public MuPatCandidateBase, public Trk::ObjectCounter<MuPatTrack> {
38  friend class MuPatCandidateTool;
39 
40  public:
60  };
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 
81  ~MuPatTrack();
82 
85  MuPatTrack(const MuPatTrack& can);
86 
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 
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
Muon::MuPatTrack::InitialLoop
@ InitialLoop
Definition: MuPatTrack.h:44
Muon::MuPatTrack::Unknown
@ Unknown
Definition: MuPatTrack.h:43
TrackParameters.h
python.FPGATrackSimAnalysisConfig.stage
stage
Definition: FPGATrackSimAnalysisConfig.py:604
Muon::MuPatCandidateBase
track candidate entry object.
Definition: MuPatCandidateBase.h:46
Trk::Track
The ATLAS Track class.
Definition: Tracking/TrkEvent/TrkTrack/TrkTrack/Track.h:73
Muon::MuPatTrack::TrackSelector
@ TrackSelector
Definition: MuPatTrack.h:57
Muon::MuPatTrack::segmentNames
std::string segmentNames() const
string containing the names of the segments on the candidate
Definition: MuPatTrack.cxx:274
Trk::ParametersT
Dummy class used to allow special convertors to be called for surfaces owned by a detector element.
Definition: EMErrorDetail.h:25
Muon::MuPatCandidateBase::chambers
const std::set< MuonStationIndex::ChIndex > & chambers() const
returns set with contained chamberIndices
Definition: MuPatCandidateBase.cxx:31
extractSporadic.c1
c1
Definition: extractSporadic.py:134
Muon::MuPatTrack::updateSegments
void updateSegments(bool add)
update segment/track association, if add == true ,will add track to segments else remove it
Definition: MuPatTrack.cxx:285
Muon::MuPatTrack::m_track
std::unique_ptr< Trk::Track > m_track
Definition: MuPatTrack.h:158
Muon::MuPatTrack::FitWorse
@ FitWorse
Definition: MuPatTrack.h:54
TrkObjectCounter.h
MuPatCandidateBase.h
Muon::MuPatTrack::AmbiguitySelectCandidates
@ AmbiguitySelectCandidates
Definition: MuPatTrack.h:51
Muon
This class provides conversion from CSC RDO data to CSC Digits.
Definition: TrackSystemController.h:49
Muon::MuPatTrack::isSegmentExcluded
bool isSegmentExcluded(const MuPatSegment *segment) const
loops over the excluded segment collection and checks whether the pointer is in there
Definition: MuPatTrack.cxx:213
Muon::MuPatTrack::FitRemovedLayer
@ FitRemovedLayer
Definition: MuPatTrack.h:56
MuPatSegment.h
Muon::MuPatTrack::SegmentRecovery
@ SegmentRecovery
Definition: MuPatTrack.h:47
Trk::ObjectCounter
Helper to enable counting number of instantiations in debug builds.
Definition: TrkObjectCounter.h:18
Muon::MuPatTrack::initProcessingStageStrings
static std::vector< std::string > initProcessingStageStrings()
Initialize s_processingStageStrings & s_processingStageStringMaxLen.
Definition: MuPatTrack.cxx:30
Muon::MuPatTrack::addSegment
void addSegment(MuPatSegment *segment, std::unique_ptr< Trk::Track > &newTrack)
add segment + the associated new track.
Definition: MuPatTrack.cxx:216
Track.h
Muon::MuPatTrack::LayerRecovery
@ LayerRecovery
Definition: MuPatTrack.h:45
Muon::MuPatTrack::hasMomentum
bool hasMomentum() const
returns whether canditate has a momentum measurement
Definition: MuPatTrack.cxx:186
Muon::SortMuPatTrackByQuality::operator()
bool operator()(const MuPatTrack *c1, const MuPatTrack *c2)
Definition: MuPatTrack.h:186
Muon::MuPatTrack::resetChambersOnCandidate
bool resetChambersOnCandidate(const std::set< MuonStationIndex::ChIndex > &chambers)
reset chambers on the candidate.
Definition: MuPatTrack.cxx:239
PlotPulseshapeFromCool.can
can
Definition: PlotPulseshapeFromCool.py:91
Muon::MuPatTrack::operator=
MuPatTrack & operator=(const MuPatTrack &can)
assignment operator.
Definition: MuPatTrack.cxx:155
Muon::MuPatTrack::created
ProcessingStage created
Definition: MuPatTrack.h:144
Muon::MuPatTrack::processingStageStringMaxLen
static unsigned int processingStageStringMaxLen()
maximum width of the strings corresponding to the ProcessingStage
Definition: MuPatTrack.cxx:16
Muon::MuPatTrack::m_excludedSegments
std::vector< MuPatSegment * > m_excludedSegments
Definition: MuPatTrack.h:157
Muon::MuPatTrack::processingStageStrings
static const std::vector< std::string > & processingStageStrings()
Return list of processing stage strings.
Definition: MuPatTrack.cxx:54
Muon::MuPatTrack::ProcessingStage
ProcessingStage
enum to keep track of the life of candidates
Definition: MuPatTrack.h:42
Muon::MuPatTrack::FitRemovedSegment
@ FitRemovedSegment
Definition: MuPatTrack.h:48
Muon::MuPatTrack::m_seedSeg
MuPatSegment * m_seedSeg
The special segment for this track.
Definition: MuPatTrack.h:159
add
bool add(const std::string &hname, TKey *tobj)
Definition: fastadd.cxx:55
Trk::FitQuality
Class to represent and store fit qualities from track reconstruction in terms of and number of degre...
Definition: FitQuality.h:97
Trk::ParametersBase
Definition: ParametersBase.h:55
Muon::MuPatTrack::excludedSegments
const std::vector< MuPatSegment * > & excludedSegments() const
access to segments
Definition: MuPatTrack.h:173
Muon::MuPatTrack::MatchFail
@ MatchFail
Definition: MuPatTrack.h:52
Muon::MuPatTrack::stationsInOrder
std::vector< MuonStationIndex::StIndex > stationsInOrder()
returns vector with contained stationIndices in the order they were added
Definition: MuPatTrack.cxx:267
Muon::MuPatCandidateTool
class to manipulate MuPatCandidateBase objects
Definition: MuPatCandidateTool.h:49
Muon::MuPatTrack::addExcludedSegment
void addExcludedSegment(MuPatSegment *segment)
add segment that does not match the track
Definition: MuPatTrack.cxx:212
Muon::MuPatTrack::modifySegmentCounters
void modifySegmentCounters(int change)
increase the segment counters by the passed number
Definition: MuPatTrack.cxx:231
compileRPVLLRates.c2
c2
Definition: compileRPVLLRates.py:361
Muon::MuPatTrack::lastSegmentChange
ProcessingStage lastSegmentChange
Definition: MuPatTrack.h:145
Muon::MuPatTrack::updateTrack
void updateTrack(std::unique_ptr< Trk::Track > &newTrack)
update track.
Definition: MuPatTrack.cxx:210
Muon::MuPatTrack::NumberOfProcessingStages
@ NumberOfProcessingStages
Definition: MuPatTrack.h:59
Muon::MuPatSegment
segment candidate object.
Definition: MuPatSegment.h:43
Muon::MuPatTrack::entryPars
const Trk::TrackParameters & entryPars() const
returns first track parameters
Definition: MuPatTrack.h:177
Muon::MuPatTrack::processingStageString
static const std::string & processingStageString(ProcessingStage stage)
Convert enum to string.
Definition: MuPatTrack.cxx:61
Muon::MuPatTrack::seedSegment
MuPatSegment * seedSegment() const
Return pointer to the seed segment.
Definition: MuPatTrack.h:169
Muon::SortMuPatTrackByQuality
Definition: MuPatTrack.h:184
Muon::MuPatTrack::track
Trk::Track & track() const
access to track
Definition: MuPatTrack.h:175
Muon::MuPatTrack::KeptUntilEndOfCombi
@ KeptUntilEndOfCombi
Definition: MuPatTrack.h:58
Muon::MuPatTrack
track candidate object.
Definition: MuPatTrack.h:37
Muon::MuPatTrack::RefitRemovedSegment
@ RefitRemovedSegment
Definition: MuPatTrack.h:49
Muon::MuPatTrack::ExtendedWithSegment
@ ExtendedWithSegment
Definition: MuPatTrack.h:46
Trk::FitQuality::chiSquared
double chiSquared() const
returns the of the overall track fit
Definition: FitQuality.h:56
Trk::FitQuality::numberDoF
int numberDoF() const
returns the number of degrees of freedom of the overall track or vertex fit as integer
Definition: FitQuality.h:60
Muon::MuPatTrack::FitFail
@ FitFail
Definition: MuPatTrack.h:53
MuonStationIndex.h
Muon::MuPatTrack::m_segments
std::vector< MuPatSegment * > m_segments
Definition: MuPatTrack.h:156
Muon::MuPatTrack::MuPatTrack
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...
Definition: MuPatTrack.cxx:72
Muon::MuPatTrack::UnassociatedEM
@ UnassociatedEM
Definition: MuPatTrack.h:55
Muon::MuPatTrack::segments
const std::vector< MuPatSegment * > & segments() const
access to segments
Definition: MuPatTrack.h:167
Muon::MuPatTrack::AmbiguityCreateCandidateFromSeeds
@ AmbiguityCreateCandidateFromSeeds
Definition: MuPatTrack.h:50
Muon::MuPatTrack::~MuPatTrack
~MuPatTrack()
destructor, decrease the usedInFit counter of all MuPatSegment objects by one
Definition: MuPatTrack.cxx:133
NSWL1::PadTriggerAdapter::segment
Muon::NSW_PadTriggerSegment segment(const NSWL1::PadTrigger &data)
Definition: PadTriggerAdapter.cxx:5