ATLAS Offline Software
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
MuonCalib::MuCCaFitter Class Reference

#include <MuCCaFitter.h>

Inheritance diagram for MuonCalib::MuCCaFitter:
Collaboration diagram for MuonCalib::MuCCaFitter:

Public Types

typedef std::vector< unsigned int > HitSelection
 

Public Member Functions

bool fit (MuonCalibSegment &seg) const
 fit using all hits More...
 
bool fit (MuonCalibSegment &seg, HitSelection selection) const
 fit subset of the hits. More...
 
void printLevel (int level)
 set print level More...
 

Private Member Functions

double getY (const Amg::Vector3D &p) const
 these methods are needed to change the reference frame between the local one of the hit and one used by the fitter: apparently the 2 frames are the same ... More...
 
double getX (const Amg::Vector3D &p) const
 
double getZ (const Amg::Vector3D &p) const
 
Amg::Vector3D getVec (double x, double y, double z) const
 

Private Attributes

bool m_debug
 

Detailed Description

Interface to the straight line fitter for drift circles used by Calib

Author
Fabri.nosp@m.zio..nosp@m.Petru.nosp@m.cci@.nosp@m.cern..nosp@m.ch

Definition at line 29 of file MuCCaFitter.h.

Member Typedef Documentation

◆ HitSelection

typedef std::vector<unsigned int> MuonCalib::IMdtSegmentFitter::HitSelection
inherited

Definition at line 32 of file IMdtSegmentFitter.h.

Member Function Documentation

◆ fit() [1/2]

bool MuonCalib::MuCCaFitter::fit ( MuonCalibSegment seg) const
virtual

fit using all hits

Implements MuonCalib::IMdtSegmentFitter.

Definition at line 18 of file MuCCaFitter.cxx.

18  {
19  // select all hits
20  HitSelection selection(seg.mdtHitsOnTrack(), 0);
21  // call fit function
22  return fit(seg, selection);
23  }

◆ fit() [2/2]

bool MuonCalib::MuCCaFitter::fit ( MuonCalibSegment seg,
HitSelection  selection 
) const
virtual

fit subset of the hits.

If the HitSelection vector contains a 0 for a given hit the hit is used else the hit is not included in the fit. The size of the HitSelection vector should be equal to the number of hits on track else no fit is performed.

Implements MuonCalib::IMdtSegmentFitter.

Definition at line 25 of file MuCCaFitter.cxx.

25  {
26  MsgStream log(Athena::getMessageSvc(), "MuCCaFitter");
27  if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << "fit() New seg:" << endmsg;
28 
29  int N = seg.mdtHitsOnTrack();
30 
31  if (N < 2) { return false; }
32 
33  if ((int)selection.size() != N) {
34  selection.clear();
35  selection.assign(N, 0);
36  } else {
37  int used(0);
38  for (int i = 0; i < N; ++i) {
39  if (selection[i] == 0) ++used;
40  }
41  if (used < 2) {
42  log << MSG::WARNING << "fit() TO FEW HITS SELECTED" << endmsg;
43  return false;
44  }
45  }
46 
47  const Amg::Vector3D& pos = seg.position();
48 
49  double S(0), Sy(0), Sz(0), Zc{0}, Yc{0};
50  std::vector<double> y(N), x(N), z(N);
51  std::vector<double> r(N), sr(N), w(N), rw(N);
52  int ii{0}, jj{0};
53  {
54  for (const MuonCalibSegment::MdtHitPtr& hit : seg.mdtHOT()) {
55  const MdtCalibHitBase& h = *hit;
56  y[ii] = getY(h.localPosition());
57  z[ii] = getZ(h.localPosition());
58  r[ii] = std::abs(h.driftRadius());
59 
60  if (h.sigma2DriftRadius() > 0) {
61  w[ii] = 1. / (h.sigma2DriftRadius());
62  sr[ii] = std::sqrt(h.sigma2DriftRadius());
63  } else {
64  w[ii] = 0.;
65  sr[ii] = 0.;
66  }
67  if (log.level() <= MSG::DEBUG)
68  log << MSG::DEBUG << "fit() MuCCaFitter: (" << x[ii] << "," << y[ii] << ") R = " << r[ii] << " W " << w[ii] << endmsg;
69  rw[ii] = r[ii] * w[ii];
70  if (selection[jj]) {
71  ++jj;
72  continue;
73  }
74  S += w[ii];
75  Sz += w[ii] * z[ii];
76  Sy += w[ii] * y[ii];
77  ++ii;
78  ++jj;
79  }
80  }
81  Zc = Sz / S;
82  Yc = Sy / S;
83 
84  std::unique_ptr<MuCCaFitterImplementation> Fitter = std::make_unique<MuCCaFitterImplementation>();
85  if (log.level() <= MSG::DEBUG) {
86  for (int i = 0; i != ii; i++) {
87  log << MSG::DEBUG << "fit() MuCCaFitter hits passed to computepam Z=" << x[i] << " phi=" << y[i] << " zzz=" << z[i]
88  << " drift=" << r[i] << " error=" << w[i] << endmsg;
89  }
90  }
91  Fitter->Computeparam3(ii, z, y, r, sr);
92  if (log.level() <= MSG::DEBUG) {
93  log << MSG::DEBUG << "fit() MuCCaFitter computed track a=" << Fitter->get_a() << " da= " << Fitter->get_da()
94  << " b= " << Fitter->get_b() << " db= " << Fitter->get_db() << " corrab= " << Fitter->get_corrab()
95  << " chi2f= " << Fitter->get_chi2f() << endmsg;
96  }
97 
98  double afit = Fitter->get_a();
99  double chi2f = Fitter->get_chi2f();
100 
101  std::vector<double> dist(N), ddist(N);
102  double R, dis;
103  double theta = std::atan(afit);
104  if (theta < 0.) theta = M_PI + theta;
105  double sinus = std::sin(theta);
106  double cosin = std::cos(theta);
107  double d = -(getZ(pos) - Zc) * sinus + (getY(pos) - Yc) * cosin;
108  if (log.level() <= MSG::DEBUG) {
109  log << MSG::DEBUG << "fit() MuCCaFitter>>> theta= " << theta << " sinus= " << sinus << " cosin= " << cosin << endmsg;
110  log << MSG::DEBUG << "fit() MuCCaFitter>>> getZ( pos )= " << getZ(pos) << " getY( pos )= " << getY(pos) << " Zc= " << Zc
111  << " Yc= " << Yc << endmsg;
112  }
113  double Syy(0), Szy(0), Syyzz(0), Att(0);
114  R = 0;
115  for (int i = 0; i < N; ++i) {
116  if (selection[i]) continue;
117  Syy += (y[i] - Yc) * (y[i] - Yc) * w[i];
118  Szy += (y[i] - Yc) * (z[i] - Zc) * w[i];
119  Syyzz += ((y[i] - Yc) - (z[i] - Zc)) * ((y[i] - Yc) + (z[i] - Zc)) * w[i];
120  dis = (y[i] - Yc) * cosin - (z[i] - Zc) * sinus;
121  if (dis > d) {
122  R -= rw[i];
123  } else {
124  R += rw[i];
125  }
126  }
127  Att = Syy + cosin * (2 * sinus * Szy - cosin * Syyzz);
128  d = R / S;
129  if (log.level() <= MSG::DEBUG)
130  log << MSG::DEBUG << "fit() MuCCaFitter>>> d= " << d << " R= " << R << " S= " << S << " Att= " << Att << endmsg;
131  for (int i = 0; i < N; ++i) {
132  if (selection[i]) continue;
133  dist[i] = cosin * (y[i] - Yc) - sinus * (z[i] - Zc) - d;
134  double dth = -(sinus * (y[i] - Yc) + cosin * (z[i] - Zc)) * (std::sqrt(1. / Att));
135  ddist[i] = std::sqrt(dth * dth + (1. / S));
136  }
137  if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << "fit() Transforming back to real world" << endmsg;
138  Amg::Vector3D ndir = getVec(0., sinus, cosin);
139  Amg::Vector3D npos = getVec(0., Yc + cosin * d, Zc - sinus * d);
140 
141  if (log.level() <= MSG::DEBUG)
142  log << MSG::DEBUG << "fit() New line: position " << npos << " direction " << ndir << " chi2f " << chi2f << endmsg;
143 
144  seg.set(chi2f / (N - 2), npos, ndir);
145 
146  int i{0};
147  for (const MuonCalibSegment::MdtHitPtr& hit_ptr : seg.mdtHOT()) {
148  hit_ptr->setDistanceToTrack(dist[i], ddist[i]);
149  ++i;
150  }
151 
152  if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << "fit() fit done" << endmsg;
153  return true;
154  }

◆ getVec()

Amg::Vector3D MuonCalib::MuCCaFitter::getVec ( double  x,
double  y,
double  z 
) const
inlineprivate

Definition at line 59 of file MuCCaFitter.h.

59 { return Amg::Vector3D(x, z, y); }

◆ getX()

double MuonCalib::MuCCaFitter::getX ( const Amg::Vector3D p) const
inlineprivate

Definition at line 57 of file MuCCaFitter.h.

57 { return p.x(); }

◆ getY()

double MuonCalib::MuCCaFitter::getY ( const Amg::Vector3D p) const
inlineprivate

these methods are needed to change the reference frame between the local one of the hit and one used by the fitter: apparently the 2 frames are the same ...

TO BE CHECKED!!!

Definition at line 56 of file MuCCaFitter.h.

56 { return p.z(); }

◆ getZ()

double MuonCalib::MuCCaFitter::getZ ( const Amg::Vector3D p) const
inlineprivate

Definition at line 58 of file MuCCaFitter.h.

58 { return p.y(); }

◆ printLevel()

void MuonCalib::MuCCaFitter::printLevel ( int  level)
virtual

set print level

Implements MuonCalib::IMdtSegmentFitter.

Definition at line 14 of file MuCCaFitter.cxx.

14  {
15  if (level > 0) m_debug = true;
16  }

Member Data Documentation

◆ m_debug

bool MuonCalib::MuCCaFitter::m_debug
private

Definition at line 46 of file MuCCaFitter.h.


The documentation for this class was generated from the following files:
used
beamspotman.r
def r
Definition: beamspotman.py:676
MuonCalib::MuCCaFitter::getZ
double getZ(const Amg::Vector3D &p) const
Definition: MuCCaFitter.h:58
hist_file_dump.d
d
Definition: hist_file_dump.py:137
M_PI
#define M_PI
Definition: ActiveFraction.h:11
JetTiledMap::N
@ N
Definition: TiledEtaPhiMap.h:44
drawFromPickle.cos
cos
Definition: drawFromPickle.py:36
MuonCalib::MuCCaFitter::fit
bool fit(MuonCalibSegment &seg) const
fit using all hits
Definition: MuCCaFitter.cxx:18
checkFileSG.rw
rw
Definition: checkFileSG.py:124
x
#define x
JetTiledMap::S
@ S
Definition: TiledEtaPhiMap.h:44
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
drawFromPickle.atan
atan
Definition: drawFromPickle.py:36
python.iconfTool.models.loaders.level
level
Definition: loaders.py:20
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
python.SystemOfUnits.sr
int sr
Definition: SystemOfUnits.py:113
lumiFormat.i
int i
Definition: lumiFormat.py:85
z
#define z
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
AnalysisUtils::Delta::R
double R(const INavigable4Momentum *p1, const double v_eta, const double v_phi)
Definition: AnalysisMisc.h:49
jobOption.theta
theta
Definition: jobOption.ParticleGun_fwd_sequence.py:13
selection
std::string selection
Definition: fbtTestBasics.cxx:75
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
MuonCalib::MuCCaFitter::getVec
Amg::Vector3D getVec(double x, double y, double z) const
Definition: MuCCaFitter.h:59
MuonCalib::MuCCaFitter::m_debug
bool m_debug
Definition: MuCCaFitter.h:46
y
#define y
h
DEBUG
#define DEBUG
Definition: page_access.h:11
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
MuonCalib::MuCCaFitter::getY
double getY(const Amg::Vector3D &p) const
these methods are needed to change the reference frame between the local one of the hit and one used ...
Definition: MuCCaFitter.h:56
drawFromPickle.sin
sin
Definition: drawFromPickle.py:36
python.IoTestsLib.w
def w
Definition: IoTestsLib.py:200
MuonCalib::MuonCalibSegment::MdtHitPtr
std::shared_ptr< MdtCalibHitBase > MdtHitPtr
typedef for a collection of MdtCalibHitBase s
Definition: MuonCalibSegment.h:44
MuonCalib::IMdtSegmentFitter::HitSelection
std::vector< unsigned int > HitSelection
Definition: IMdtSegmentFitter.h:32