ATLAS Offline Software
MatchDCWithLine.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 namespace TrkDriftCircleMath {
8 
10  // clear cached information
11  reset();
12  DCCit it = dcs.begin();
13  DCCit it_end = dcs.end();
14  for (; it != it_end; ++it) {
15  double dline = m_resWithLine.residual(it->position());
16  double rhit = it->r() < 0. ? -it->r() : it->r();
17  if (dline < 0.) dline *= -1.;
18 
19  double res = dline - rhit;
20 
21  DCOnTrack dcOnTrack(*it, res);
22 
23  matchDC(dcOnTrack, res, dline);
24 
25  if (dcOnTrack.state() != DCOnTrack::OutsideRoad) {
30  if (!m_dcOnTrackVec.empty() && m_dcOnTrackVec.back().id() == it->id()) {
31  // take the hit with the smallest residual
32  if (fabs(m_dcOnTrackVec.back().residual()) > fabs(res)) {
33  // exchange the two hits
34  m_dcOnTrackVec.pop_back();
35  m_dcOnTrackVec.push_back(dcOnTrack);
36  }
37  } else {
38  m_dcOnTrackVec.push_back(dcOnTrack);
39  }
40  }
41  }
42  return m_dcOnTrackVec;
43  }
44 
45  const DCOnTrackVec& MatchDCWithLine::match(const DCOnTrackVec& dcs, const HitSelection* selection, bool recoverMdtHits,
46  bool usePrecise) {
47  // clear cached information
48  reset();
49 
50  DCOnTrackCit it = dcs.begin();
51  DCOnTrackCit it_end = dcs.end();
52  unsigned int index = 0;
53  for (; it != it_end; ++it, ++index) {
54  double dline = m_resWithLine.residual(it->position());
55  double rhit = it->r() < 0. ? -it->r() : it->r();
56  if (dline < 0.) dline *= -1.;
57 
58  double res = dline - rhit;
59 
60  DCOnTrack dcOnTrack(*it, res);
61  dcOnTrack.errorTrack(it->errorTrack());
62 
63  // check whether any DCOnTracks change state from or to OnTrack with respect to the old selection
64  if ((dcOnTrack.state() == DCOnTrack::OnTrack || it->state() == DCOnTrack::OnTrack) && dcOnTrack.state() != it->state())
66 
67  if (selection) {
68  if ((*selection)[index] == 0) {
69  matchDC(dcOnTrack, res, dline, true, false, usePrecise);
70  } else if (recoverMdtHits) {
71  matchDC(dcOnTrack, res, dline, false, false, usePrecise);
72  } else {
73  matchDC(dcOnTrack, res, dline, false, true, usePrecise);
74  }
75  } else {
76  matchDC(dcOnTrack, res, dline, false, false, usePrecise);
77  }
78 
79  if (dcOnTrack.state() != DCOnTrack::OutsideRoad) m_dcOnTrackVec.push_back(dcOnTrack);
80  }
81  return m_dcOnTrackVec;
82  }
83 
84  void MatchDCWithLine::matchDC(DCOnTrack& dcOnTrack, double& res, double& dline, bool forceOnTrack, bool forceOffTrack,
85  bool usePrecise) {
86  // check whether hit within range
87  double error = usePrecise ? dcOnTrack.drPrecise() : dcOnTrack.dr();
88  if (forceOnTrack || (!forceOffTrack && (dcOnTrack.driftState() == DriftCircle::InTime && select(res, error)))) {
89  ++m_onTracks;
90  ++m_passedTubes;
91  if (dcOnTrack.id().ml() == 0)
92  ++m_ml1;
93  else
94  ++m_ml2;
95  dcOnTrack.state(DCOnTrack::OnTrack);
96  } else {
97  if (dline < m_tubeRadius) {
98  if (res < 0. || dcOnTrack.driftState() == DriftCircle::LateHit) {
99  dcOnTrack.state(DCOnTrack::OutOfTime);
100  ++m_outOfTimes;
101  } else {
102  dcOnTrack.state(DCOnTrack::Delta);
103  ++m_deltas;
104  }
105  ++m_passedTubes;
106  } else {
107  if (dline < m_closeByCut) {
108  dcOnTrack.state(DCOnTrack::CloseDC);
109  ++m_closeHits;
110  } else {
111  dcOnTrack.state(DCOnTrack::OutsideRoad);
112  }
113  if (dline < m_showerCut) { ++m_showerHits; }
114  }
115  }
116  }
117 
118  bool MatchDCWithLine::select(double residual, double error) const {
119  if (residual < 0.) residual *= -1.;
120  switch (m_strategy) {
121  case Road: return residual < m_deltaCut;
122  case Pull: return residual < m_deltaCut * error;
123  default: return false;
124  }
125  }
126 
128  // clear cache
129  m_dcOnTrackVec.clear();
130 
131  m_outOfTimes = 0;
132  m_deltas = 0;
133  m_onTracks = 0;
134  m_passedTubes = 0;
135  m_ml1 = 0;
136  m_ml2 = 0;
137  m_closeHits = 0;
138  m_showerHits = 0;
139  m_matchDifference = 0;
140  }
141 
142 } // namespace TrkDriftCircleMath
TrkDriftCircleMath::MatchDCWithLine::match
const DCOnTrackVec & match(const DCVec &dcs)
Definition: MatchDCWithLine.cxx:9
TrkDriftCircleMath::MatchDCWithLine::m_dcOnTrackVec
DCOnTrackVec m_dcOnTrackVec
Definition: MatchDCWithLine.h:80
TrkDriftCircleMath::MatchDCWithLine::m_ml1
unsigned int m_ml1
Definition: MatchDCWithLine.h:73
TrkDriftCircleMath::MatchDCWithLine::matchDC
void matchDC(DCOnTrack &dc, double &res, double &dline, bool forceOnTrack=false, bool forceOffTrack=false, bool usePreciseErrors=false)
Definition: MatchDCWithLine.cxx:84
TrkDriftCircleMath::DriftCircle::LateHit
@ LateHit
drift time compatible with drift spectrum
Definition: DriftCircle.h:28
TrkDriftCircleMath::DCOnTrackVec
std::vector< DCOnTrack > DCOnTrackVec
Definition: DCOnTrack.h:59
TrkDriftCircleMath::MatchDCWithLine::m_ml2
unsigned int m_ml2
Definition: MatchDCWithLine.h:74
TrkDriftCircleMath::DCOnTrack::Delta
@ Delta
used in fit
Definition: DCOnTrack.h:21
ClusterSeg::residual
@ residual
Definition: ClusterNtuple.h:20
MatchDCWithLine.h
index
Definition: index.py:1
TrkDriftCircleMath::MatchDCWithLine::m_tubeRadius
double m_tubeRadius
Definition: MatchDCWithLine.h:64
TrkDriftCircleMath::HitSelection
std::vector< bool > HitSelection
Definition: HitSelection.h:9
TrkDriftCircleMath::MatchDCWithLine::Pull
@ Pull
Definition: MatchDCWithLine.h:18
skel.it
it
Definition: skel.GENtoEVGEN.py:396
TrkDriftCircleMath::MatchDCWithLine::m_deltaCut
double m_deltaCut
Definition: MatchDCWithLine.h:67
TrkDriftCircleMath::ResidualWithLine::residual
double residual(const LocVec2D &pos) const
Definition: ResidualWithLine.h:21
TrkDriftCircleMath
Function object to check whether two Segments are sub/super sets or different.
Definition: IMdtSegmentFinder.h:13
TrkDriftCircleMath::DriftCircle::dr
double dr() const
access to error drift radius
Definition: DriftCircle.h:89
TrkDriftCircleMath::MatchDCWithLine::m_passedTubes
unsigned int m_passedTubes
Definition: MatchDCWithLine.h:72
TrkDriftCircleMath::DCOnTrack::OutOfTime
@ OutOfTime
delta electron
Definition: DCOnTrack.h:22
TrkDriftCircleMath::DCOnTrack::state
void state(DCOnTrackState st)
set DCOnTrack state
Definition: DCOnTrack.h:47
TrkDriftCircleMath::MatchDCWithLine::m_deltas
unsigned int m_deltas
Definition: MatchDCWithLine.h:69
TrkDriftCircleMath::MdtId::ml
int ml() const
Definition: MdtId.h:31
TrkDriftCircleMath::MatchDCWithLine::reset
void reset()
Definition: MatchDCWithLine.cxx:127
TrkDriftCircleMath::DCOnTrack::errorTrack
void errorTrack(double error)
set track error
Definition: DCOnTrack.h:41
TrkDriftCircleMath::MatchDCWithLine::m_matchDifference
unsigned int m_matchDifference
Definition: MatchDCWithLine.h:77
TrkDriftCircleMath::DCVec
std::vector< DriftCircle > DCVec
Definition: DriftCircle.h:117
TrkDriftCircleMath::MatchDCWithLine::m_strategy
MatchStrategy m_strategy
Definition: MatchDCWithLine.h:68
TrkDriftCircleMath::MatchDCWithLine::m_showerHits
unsigned int m_showerHits
Definition: MatchDCWithLine.h:76
TrkDriftCircleMath::DriftCircle::driftState
const DriftState & driftState() const
access to drift state
Definition: DriftCircle.h:95
TrkDriftCircleMath::DCOnTrack::OutsideRoad
@ OutsideRoad
inside road but too far to be on track
Definition: DCOnTrack.h:24
res
std::pair< std::vector< unsigned int >, bool > res
Definition: JetGroupProductTest.cxx:14
TrkDriftCircleMath::DCOnTrackCit
DCOnTrackVec::const_iterator DCOnTrackCit
Definition: DCOnTrack.h:61
TrkDriftCircleMath::MatchDCWithLine::m_outOfTimes
unsigned int m_outOfTimes
Definition: MatchDCWithLine.h:70
TrkDriftCircleMath::DCOnTrack::OnTrack
@ OnTrack
Definition: DCOnTrack.h:20
TrkDriftCircleMath::MatchDCWithLine::m_closeHits
unsigned int m_closeHits
Definition: MatchDCWithLine.h:75
selection
const std::string selection
Definition: fbtTestBasics.cxx:74
TrkDriftCircleMath::DCCit
DCVec::const_iterator DCCit
Definition: DriftCircle.h:119
TrkDriftCircleMath::MatchDCWithLine::select
bool select(double residual, double error) const
Definition: MatchDCWithLine.cxx:118
TrkDriftCircleMath::MatchDCWithLine::Road
@ Road
Definition: MatchDCWithLine.h:18
TrkDriftCircleMath::MatchDCWithLine::m_showerCut
double m_showerCut
Definition: MatchDCWithLine.h:66
DeMoScan.index
string index
Definition: DeMoScan.py:364
TrkDriftCircleMath::DCOnTrack
class representing a drift circle meaurement on segment
Definition: DCOnTrack.h:16
TrkDriftCircleMath::MatchDCWithLine::m_resWithLine
ResidualWithLine m_resWithLine
Definition: MatchDCWithLine.h:63
TrkDriftCircleMath::MatchDCWithLine::m_closeByCut
double m_closeByCut
Definition: MatchDCWithLine.h:65
get_generator_info.error
error
Definition: get_generator_info.py:40
TrkDriftCircleMath::DriftCircle::id
const MdtId & id() const
access to identifier
Definition: DriftCircle.h:77
error
Definition: IImpactPoint3dEstimator.h:70
TrkDriftCircleMath::DriftCircle::drPrecise
double drPrecise() const
access to precise error drift radius
Definition: DriftCircle.h:92
TrkDriftCircleMath::DCOnTrack::CloseDC
@ CloseDC
too large drift time
Definition: DCOnTrack.h:23
TrkDriftCircleMath::DriftCircle::InTime
@ InTime
drift time too small to be compatible with drift spectrum
Definition: DriftCircle.h:27
TrkDriftCircleMath::MatchDCWithLine::m_onTracks
unsigned int m_onTracks
Definition: MatchDCWithLine.h:71