ATLAS Offline Software
Loading...
Searching...
No Matches
TrkDriftCircleMath::MdtChamberGeometry Class Reference

#include <MdtChamberGeometry.h>

Inheritance diagram for TrkDriftCircleMath::MdtChamberGeometry:
Collaboration diagram for TrkDriftCircleMath::MdtChamberGeometry:

Public Member Functions

 MdtChamberGeometry ()
 MdtChamberGeometry (const Identifier &id, const Muon::IMuonIdHelperSvc *idHelperSvc, unsigned int nml, unsigned int nlay, unsigned int ntubesml0, unsigned int ntubesml1, const LocVec2D &tube0ml0, const LocVec2D &tube0ml1, double tubeDist, double tubeStage, double layDist, double stationTheta)
virtual ~MdtChamberGeometry ()=default
void init ()
void setGeometry (unsigned int nml, unsigned int nlay, unsigned int ntubesml0, unsigned int ntubesml1, const LocVec2D &tube0ml0, const LocVec2D &tube0ml1, double tubeDist, double tubeStage, double layDist, double stationTheta)
unsigned int nml () const
unsigned int nlay () const override
unsigned int ntubesml0 () const
unsigned int ntubesml1 () const
const IdentifierstationId () const override
const LocVec2DfirstTubeMl0 () const
const LocVec2DfirstTubeMl1 () const
double tubeDist () const
double tubeStage () const
double layerDist () const
double stationTheta () const override
double tubeRadius () const override
LocVec2D tubePosition (unsigned int ml, unsigned int lay, unsigned int tube) const override
DCVec tubesPassedByLine (const Line &line, int ml) const
DCVec tubesPassedByLine (const Line &line) const override
 Retrieves the vector of drift circles traveresed by the line.
void tubesPassedByLine (const Line &line, int ml, DCVec &crossedTubes) const
 methods taking reference to output vector to reduce memory usage
void tubesPassedByLine (const Line &line, DCVec &crossedTubes) const
void isSecondMultiLayer (bool isSecond)
 set that this is the second multi layer instead of the first, used in case the first ML is dead
bool validGeometry () const override
void print (MsgStream &msg) const override
bool validId (unsigned int ml, unsigned int lay, unsigned int tube) const

Private Member Functions

double xPosTube (unsigned int ml, unsigned int lay, unsigned int tube) const
double yPosTube (unsigned int ml, unsigned int lay) const

Private Attributes

Identifier m_id {}
bool m_sMdt {false}
bool m_isBarrel {false}
unsigned int m_nml {0}
unsigned int m_nlay {0}
std::vector< unsigned int > m_ntubesml {}
double m_tubeDist {0}
double m_tubeRad {0}
double m_tubeStage {0}
double m_layDist {0}
double m_stationTheta {0}
std::vector< bool > m_wasInit {}
std::vector< LocVec2Dm_firstTube {}
bool m_validGeometry {false}
bool m_isSecondMultiLayer {false}

Detailed Description

Definition at line 18 of file MdtChamberGeometry.h.

Constructor & Destructor Documentation

◆ MdtChamberGeometry() [1/2]

TrkDriftCircleMath::MdtChamberGeometry::MdtChamberGeometry ( )

◆ MdtChamberGeometry() [2/2]

TrkDriftCircleMath::MdtChamberGeometry::MdtChamberGeometry ( const Identifier & id,
const Muon::IMuonIdHelperSvc * idHelperSvc,
unsigned int nml,
unsigned int nlay,
unsigned int ntubesml0,
unsigned int ntubesml1,
const LocVec2D & tube0ml0,
const LocVec2D & tube0ml1,
double tubeDist,
double tubeStage,
double layDist,
double stationTheta )

Definition at line 22 of file MdtChamberGeometry.cxx.

24 :
25 m_id{id} {
26
27 m_sMdt = idHelperSvc->issMdt(id);
28 m_isBarrel = idHelperSvc->mdtIdHelper().isBarrel(id);
29 init();
30 setGeometry(nml, nlay, ntubesml0, ntubesml1, tube0ml0, tube0ml1, tubeDist, tubeStage, layDist, stationTheta);
31 }
bool isBarrel(const Identifier &id) const
virtual bool issMdt(const Identifier &id) const =0
returns whether this is a sMDT Identifier or not
virtual const MdtIdHelper & mdtIdHelper() const =0
access to MdtIdHelper
void setGeometry(unsigned int nml, unsigned int nlay, unsigned int ntubesml0, unsigned int ntubesml1, const LocVec2D &tube0ml0, const LocVec2D &tube0ml1, double tubeDist, double tubeStage, double layDist, double stationTheta)
unsigned int nlay() const override

◆ ~MdtChamberGeometry()

virtual TrkDriftCircleMath::MdtChamberGeometry::~MdtChamberGeometry ( )
virtualdefault

Member Function Documentation

◆ firstTubeMl0()

const LocVec2D & TrkDriftCircleMath::MdtChamberGeometry::firstTubeMl0 ( ) const
inline

Definition at line 39 of file MdtChamberGeometry.h.

39{ return m_firstTube[0]; }

◆ firstTubeMl1()

const LocVec2D & TrkDriftCircleMath::MdtChamberGeometry::firstTubeMl1 ( ) const
inline

Definition at line 40 of file MdtChamberGeometry.h.

40{ return m_firstTube[1]; }

◆ init()

void TrkDriftCircleMath::MdtChamberGeometry::init ( )

Definition at line 61 of file MdtChamberGeometry.cxx.

61 {
62 m_validGeometry = true;
63 if (m_sMdt) {
64 m_tubeRad = 7.1;
65 } else {
66 m_tubeRad = 14.6;
67 }
68 // initialize first tubes to zero
69 m_ntubesml.push_back(0);
70 m_ntubesml.push_back(0);
71 m_firstTube.emplace_back(0., 0.);
72 m_firstTube.emplace_back(0., 0.);
73 m_wasInit.push_back(true);
74 m_wasInit.push_back(true);
75 }
std::vector< unsigned int > m_ntubesml

◆ isSecondMultiLayer()

void TrkDriftCircleMath::MdtChamberGeometry::isSecondMultiLayer ( bool isSecond)
inline

set that this is the second multi layer instead of the first, used in case the first ML is dead

Definition at line 61 of file MdtChamberGeometry.h.

◆ layerDist()

double TrkDriftCircleMath::MdtChamberGeometry::layerDist ( ) const
inline

Definition at line 44 of file MdtChamberGeometry.h.

◆ nlay()

unsigned int TrkDriftCircleMath::MdtChamberGeometry::nlay ( ) const
inlineoverridevirtual

Implements TrkDriftCircleMath::ChamberGeometry.

Definition at line 33 of file MdtChamberGeometry.h.

◆ nml()

unsigned int TrkDriftCircleMath::MdtChamberGeometry::nml ( ) const
inline

Definition at line 32 of file MdtChamberGeometry.h.

◆ ntubesml0()

unsigned int TrkDriftCircleMath::MdtChamberGeometry::ntubesml0 ( ) const
inline

Definition at line 34 of file MdtChamberGeometry.h.

34{ return m_ntubesml[0]; }

◆ ntubesml1()

unsigned int TrkDriftCircleMath::MdtChamberGeometry::ntubesml1 ( ) const
inline

Definition at line 35 of file MdtChamberGeometry.h.

35{ return m_ntubesml[1]; }

◆ print()

void TrkDriftCircleMath::MdtChamberGeometry::print ( MsgStream & msg) const
overridevirtual

Implements TrkDriftCircleMath::ChamberGeometry.

Definition at line 166 of file MdtChamberGeometry.cxx.

166 {
167 msg << MSG::ALWAYS << " MdtChamberGeometry " << m_id <<std::endl
168 << " nml " << m_nml << " nlay " << m_nlay << " ntube1 " << m_ntubesml[0] << " ntube2 " << m_ntubesml[1] << std::endl
169 << " pos ml1 " << m_firstTube[0] << " ml2 " << m_firstTube[1] << std::endl
170 << " tubeDist " << m_tubeDist << " tubeStage " << m_tubeStage << " layDist " << m_layDist << " tubeRad " << m_tubeRad
171 << endmsg;
172 }
#define endmsg
MsgStream & msg
Definition testRead.cxx:32

◆ setGeometry()

void TrkDriftCircleMath::MdtChamberGeometry::setGeometry ( unsigned int nml,
unsigned int nlay,
unsigned int ntubesml0,
unsigned int ntubesml1,
const LocVec2D & tube0ml0,
const LocVec2D & tube0ml1,
double tubeDist,
double tubeStage,
double layDist,
double stationTheta )

Definition at line 33 of file MdtChamberGeometry.cxx.

35 {
36 m_nml = nml;
37 m_nlay = nlay;
38 m_ntubesml.clear();
39 m_ntubesml.push_back(ntubesml0);
40 m_ntubesml.push_back(ntubesml1);
43 m_layDist = layDist;
44
45 m_firstTube[0] = tube0ml0;
46 m_firstTube[1] = tube0ml1;
47
49 THROW_EXCEPTION("MdtChamberGeometry::setGeometry() - got called with nml="<<m_nml<<" which is definitely out of range.");
51 THROW_EXCEPTION("MdtChamberGeometry::setGeometry() - got called with nlay="<<m_nlay<<" which is definitely out of range");
52 if (ntubesml0 < 1 || ntubesml0 > maxNTubesPerLayer)
53 THROW_EXCEPTION("MdtChamberGeometry::setGeometry() - got called with ntubesml0="<<ntubesml0<<" which is definitely out of range");
54 // there can be chambers with only 1 multilayer. Then, the second multilayer will have ntubesml1=0
55 if (ntubesml1 > maxNTubesPerLayer)
56 THROW_EXCEPTION("MdtChamberGeometry::setGeometry() - got called with ntubesml1="<<ntubesml1<<" which is definitely out of range");
57
59 }
#define THROW_EXCEPTION(MESSAGE)
Definition throwExcept.h:10

◆ stationId()

const Identifier & TrkDriftCircleMath::MdtChamberGeometry::stationId ( ) const
inlineoverridevirtual

Implements TrkDriftCircleMath::ChamberGeometry.

Definition at line 37 of file MdtChamberGeometry.h.

37{ return m_id; }

◆ stationTheta()

double TrkDriftCircleMath::MdtChamberGeometry::stationTheta ( ) const
inlineoverridevirtual

Implements TrkDriftCircleMath::ChamberGeometry.

Definition at line 46 of file MdtChamberGeometry.h.

46{ return m_stationTheta; }

◆ tubeDist()

double TrkDriftCircleMath::MdtChamberGeometry::tubeDist ( ) const
inline

Definition at line 42 of file MdtChamberGeometry.h.

42{ return m_tubeDist; }

◆ tubePosition()

LocVec2D TrkDriftCircleMath::MdtChamberGeometry::tubePosition ( unsigned int ml,
unsigned int lay,
unsigned int tube ) const
overridevirtual

Implements TrkDriftCircleMath::ChamberGeometry.

Definition at line 173 of file MdtChamberGeometry.cxx.

173 {
174 if (!validId(ml, lay, tube)) {
175 THROW_EXCEPTION("Combination of multilayer ml: "<<ml<<", layer: "<<lay<<" and tube: "<<tube<<" given ");
176 }
177 LocVec2D tube_vec{xPosTube(ml, lay, tube), yPosTube(ml, lay)};
178 return tube_vec;
179 }
double xPosTube(unsigned int ml, unsigned int lay, unsigned int tube) const
bool validId(unsigned int ml, unsigned int lay, unsigned int tube) const
double yPosTube(unsigned int ml, unsigned int lay) const

◆ tubeRadius()

double TrkDriftCircleMath::MdtChamberGeometry::tubeRadius ( ) const
inlineoverridevirtual

Implements TrkDriftCircleMath::ChamberGeometry.

Definition at line 48 of file MdtChamberGeometry.h.

48{ return m_tubeRad; }

◆ tubesPassedByLine() [1/4]

DCVec TrkDriftCircleMath::MdtChamberGeometry::tubesPassedByLine ( const Line & line) const
inlineoverridevirtual

Retrieves the vector of drift circles traveresed by the line.

Implements TrkDriftCircleMath::ChamberGeometry.

Definition at line 53 of file MdtChamberGeometry.h.

53{ return tubesPassedByLine(line, -1); }
DCVec tubesPassedByLine(const Line &line, int ml) const

◆ tubesPassedByLine() [2/4]

void TrkDriftCircleMath::MdtChamberGeometry::tubesPassedByLine ( const Line & line,
DCVec & crossedTubes ) const
inline

Definition at line 57 of file MdtChamberGeometry.h.

57{ return tubesPassedByLine(line, -1, crossedTubes); }

◆ tubesPassedByLine() [3/4]

DCVec TrkDriftCircleMath::MdtChamberGeometry::tubesPassedByLine ( const Line & line,
int ml ) const

Definition at line 156 of file MdtChamberGeometry.cxx.

156 {
157 DCVec crossedTubes;
158
159 if (!m_validGeometry) return crossedTubes;
160
161 tubesPassedByLine(line, inMultilayer, crossedTubes);
162
163 std::stable_sort(crossedTubes.begin(), crossedTubes.end(), SortDcsByY());
164 return crossedTubes;
165 }
std::vector< DriftCircle > DCVec
void stable_sort(DataModel_detail::iterator< DVL > beg, DataModel_detail::iterator< DVL > end)
Specialization of stable_sort for DataVector/List.

◆ tubesPassedByLine() [4/4]

void TrkDriftCircleMath::MdtChamberGeometry::tubesPassedByLine ( const Line & line,
int ml,
DCVec & crossedTubes ) const

methods taking reference to output vector to reduce memory usage

Definition at line 99 of file MdtChamberGeometry.cxx.

99 {
100 crossedTubes.reserve(50);
101 ResidualWithLine resLine{line};
102 const LocVec2D& linepos = line.position();
103 const LocVec2D& linedir = line.direction();
104 double dxdy = std::abs(linedir.y()) > 0.0001 ? linedir.x() / linedir.y() : linedir.x() / 0.0001;
105 for (unsigned int ml = 0; ml < m_nml; ++ml) {
106 // check whether geometry was initialized for given multilayer
107 if (!m_wasInit[ml]) continue;
108
109 // if indicated only scan single multilayer
110 if (inMultilayer != -1 && inMultilayer != (int)ml) { continue; }
111 for (unsigned int lay = 0; lay < m_nlay; ++lay) {
112 double ylay = yPosTube(ml, lay);
113 double xfirsttube = xPosTube(ml, lay, 0);
114 double xintersect = dxdy * (ylay - linepos.y()) + linepos.x();
115 double relpos = (xintersect - xfirsttube) / m_tubeDist;
116 int ctube = (int)relpos;
117 if (ctube < 0) ctube = 0;
118 if (ctube >= (int)m_ntubesml[ml]) ctube = m_ntubesml[ml] - 1;
119
120 if (inMultilayer != -1)
121
122 for (int i = ctube - 1; i >= 0; --i) {
123 const LocVec2D& lp = tubePosition(ml, lay, i);
124 double res = resLine.residual(lp);
125 if (std::abs(res) > m_tubeRad) {
126 if (m_tubeDist > 0) {
127 if (res > m_tubeRad) break;
128 } else {
129 if (res < -m_tubeRad) break;
130 }
131 } else {
132 // if this is a chamber with only the second ml, set the ml index accordingly
133 unsigned int actualMl = m_isSecondMultiLayer ? 1 : ml;
134 crossedTubes.emplace_back(lp, m_tubeRad, res, DriftCircle::EmptyTube, MdtId(m_isBarrel, actualMl, lay, i),
135 nullptr);
136 }
137 }
138 for (int i = ctube; i < (int)m_ntubesml[ml]; ++i) {
139 const LocVec2D& lp = tubePosition(ml, lay, i);
140 double res = resLine.residual(lp);
141 if (std::abs(res) > m_tubeRad) {
142 if (m_tubeDist > 0) {
143 if (res < -m_tubeRad) break;
144 } else {
145 if (res > m_tubeRad) break;
146 }
147 } else {
148 unsigned int actualMl = m_isSecondMultiLayer ? 1 : ml;
149 crossedTubes.emplace_back(lp, m_tubeRad, res, DriftCircle::EmptyTube, MdtId(m_isBarrel, actualMl, lay, i), nullptr);
150 }
151 }
152 }
153 }
154 }
std::pair< std::vector< unsigned int >, bool > res
@ EmptyTube
drift time too large to be compatible with drift spectrum
Definition DriftCircle.h:29
LocVec2D tubePosition(unsigned int ml, unsigned int lay, unsigned int tube) const override

◆ tubeStage()

double TrkDriftCircleMath::MdtChamberGeometry::tubeStage ( ) const
inline

Definition at line 43 of file MdtChamberGeometry.h.

43{ return m_tubeStage; }

◆ validGeometry()

bool TrkDriftCircleMath::MdtChamberGeometry::validGeometry ( ) const
inlineoverridevirtual

Implements TrkDriftCircleMath::ChamberGeometry.

Definition at line 63 of file MdtChamberGeometry.h.

63{ return m_validGeometry; }

◆ validId()

bool TrkDriftCircleMath::MdtChamberGeometry::validId ( unsigned int ml,
unsigned int lay,
unsigned int tube ) const

Definition at line 77 of file MdtChamberGeometry.cxx.

77 {
78 if (!m_validGeometry) return false;
79 if (ml > 1) {
80 MsgStream msg{Athena::getMessageSvc(), "MdtChamberGeometry::validId"};
81 msg <<MSG::ERROR << " Wrong index: ml " << ml << " max " << m_nml << endmsg;
82 print(msg);
83
84 return false;
85 } else if (lay > m_nlay) {
86 MsgStream msg{Athena::getMessageSvc(), "MdtChamberGeometry::validId"};
87 msg <<MSG::ERROR <<" Wrong index: lay " << lay << " max " << m_nlay << endmsg;
88 print(msg);
89 return false;
90 } else if (tube > m_ntubesml[ml]) {
91 MsgStream msg{Athena::getMessageSvc(), "MdtChamberGeometry::validId"};
92 msg << " wrong index: tube " << tube << " max " << m_ntubesml[ml] << endmsg;
93 print(msg);
94 return false;
95 }
96 return true;
97 }
void print(MsgStream &msg) const override
IMessageSvc * getMessageSvc(bool quiet=false)

◆ xPosTube()

double TrkDriftCircleMath::MdtChamberGeometry::xPosTube ( unsigned int ml,
unsigned int lay,
unsigned int tube ) const
inlineprivate

Definition at line 181 of file MdtChamberGeometry.cxx.

181 {
182 double xpos = tube * m_tubeDist + m_firstTube[ml].x();
183
184 // In most cases, staggering between multilayers has the same sign, this is to take care of the exceptions where that is not the case
185 // Stagerring only happens for the 2nd and 4th layers (in this case indexing from 0)
186 if (lay % 2 == 1 ) {
187 if (m_nlay == 4 && ml == 1 && !m_sMdt)
188 xpos -= m_tubeStage;
189 else
190 xpos += m_tubeStage;
191
192 }
193
194 return xpos;
195 }

◆ yPosTube()

double TrkDriftCircleMath::MdtChamberGeometry::yPosTube ( unsigned int ml,
unsigned int lay ) const
private

Definition at line 197 of file MdtChamberGeometry.cxx.

197{ return lay * m_layDist + m_firstTube[ml].y(); }

Member Data Documentation

◆ m_firstTube

std::vector<LocVec2D> TrkDriftCircleMath::MdtChamberGeometry::m_firstTube {}
private

Definition at line 86 of file MdtChamberGeometry.h.

86{};

◆ m_id

Identifier TrkDriftCircleMath::MdtChamberGeometry::m_id {}
private

Definition at line 73 of file MdtChamberGeometry.h.

73{};

◆ m_isBarrel

bool TrkDriftCircleMath::MdtChamberGeometry::m_isBarrel {false}
private

Definition at line 75 of file MdtChamberGeometry.h.

75{false};

◆ m_isSecondMultiLayer

bool TrkDriftCircleMath::MdtChamberGeometry::m_isSecondMultiLayer {false}
private

Definition at line 88 of file MdtChamberGeometry.h.

88{false};

◆ m_layDist

double TrkDriftCircleMath::MdtChamberGeometry::m_layDist {0}
private

Definition at line 82 of file MdtChamberGeometry.h.

82{0};

◆ m_nlay

unsigned int TrkDriftCircleMath::MdtChamberGeometry::m_nlay {0}
private

Definition at line 77 of file MdtChamberGeometry.h.

77{0};

◆ m_nml

unsigned int TrkDriftCircleMath::MdtChamberGeometry::m_nml {0}
private

Definition at line 76 of file MdtChamberGeometry.h.

76{0};

◆ m_ntubesml

std::vector<unsigned int> TrkDriftCircleMath::MdtChamberGeometry::m_ntubesml {}
private

Definition at line 78 of file MdtChamberGeometry.h.

78{};

◆ m_sMdt

bool TrkDriftCircleMath::MdtChamberGeometry::m_sMdt {false}
private

Definition at line 74 of file MdtChamberGeometry.h.

74{false};

◆ m_stationTheta

double TrkDriftCircleMath::MdtChamberGeometry::m_stationTheta {0}
private

Definition at line 83 of file MdtChamberGeometry.h.

83{0};

◆ m_tubeDist

double TrkDriftCircleMath::MdtChamberGeometry::m_tubeDist {0}
private

Definition at line 79 of file MdtChamberGeometry.h.

79{0};

◆ m_tubeRad

double TrkDriftCircleMath::MdtChamberGeometry::m_tubeRad {0}
private

Definition at line 80 of file MdtChamberGeometry.h.

80{0};

◆ m_tubeStage

double TrkDriftCircleMath::MdtChamberGeometry::m_tubeStage {0}
private

Definition at line 81 of file MdtChamberGeometry.h.

81{0};

◆ m_validGeometry

bool TrkDriftCircleMath::MdtChamberGeometry::m_validGeometry {false}
private

Definition at line 87 of file MdtChamberGeometry.h.

87{false};

◆ m_wasInit

std::vector<bool> TrkDriftCircleMath::MdtChamberGeometry::m_wasInit {}
private

Definition at line 85 of file MdtChamberGeometry.h.

85{};

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