ATLAS Offline Software
Loading...
Searching...
No Matches
TileMuonTrackDistance.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
5/********************************************************************
6 *
7 * NAME: TileMuonTrackDistance
8 * PACKAGE: offline/TileCalorimeter/TileCosmicAlgs
9 *
10 * AUTHOR : J. Maneira
11 * CREATED: 10-Jul-2006
12 *
13 * PURPOSE: Minuit fit function for TileMuonFitter
14 * Supplies summed distance from cells to track
15 *
16 * Input: Cells
17 * Output: Track parameters
18 *
19 ********************************************************************/
20//
22
23using CLHEP::Hep3Vector;
24
25namespace ROOT {
26 namespace Minuit2 {
27
29 m_meanX = m_meanY = m_meanZ = 0.;
30 double eSum = 0.;
31 int ncells = m_theX.size();
32
33 if (m_doWeighted) {
34 for (int i = 0; i < ncells; i++) {
35 m_meanX += m_theE[i] * m_theX[i];
36 m_meanY += m_theE[i] * m_theY[i];
37 m_meanZ += m_theE[i] * m_theZ[i];
38 eSum += m_theE[i];
39 }
40 if (eSum > 0) {
41 m_meanX /= eSum;
42 m_meanY /= eSum;
43 m_meanZ /= eSum;
44 } else {
45 m_meanX = 0;
46 m_meanY = 0;
47 m_meanZ = 0;
48 }
49 } else {
50 for (int i = 0; i < ncells; i++) {
51 m_meanX += m_theX[i];
52 m_meanY += m_theY[i];
53 m_meanZ += m_theZ[i];
54 }
55 m_meanX /= (double) (ncells);
56 m_meanY /= (double) (ncells);
57 m_meanZ /= (double) (ncells);
58 }
59
60 }
61 /*==========================================================================*/
62 double TileMuonTrackDistance::operator()(const std::vector<double>& par) const
63 {
64 double distSum2 = 0;
65 std::vector<double> fourPar;
66
67 fourPar.push_back(m_meanY - par[0] * m_meanX);
68 fourPar.push_back(par[0]);
69 fourPar.push_back(m_meanZ - par[1] * m_meanX);
70 fourPar.push_back(par[1]);
71
72 for (int i = 0; i < (int) (m_theX.size()); i++) {
73 if (m_doWeighted) {
74 distSum2 += m_theE[i] * Distance2SinglePoint(m_theX[i], m_theY[i], m_theZ[i], fourPar);
75 } else {
76 distSum2 += Distance2SinglePoint(m_theX[i], m_theY[i], m_theZ[i], fourPar);
77 }
78 }
79
80 return distSum2;
81
82 }
83 /*==========================================================================*/
84 double TileMuonTrackDistance::Distance2SinglePoint(double x, double y, double z,
85 const std::vector<double>& par) const {
86
87 Hep3Vector dataP(x, y, z);
88 Hep3Vector lineP(ClosestPoint(&dataP, par));
89
90 return (dataP - lineP).mag2();
91 }
92 /*==========================================================================*/
93 Hep3Vector TileMuonTrackDistance::ClosestPoint(Hep3Vector *dataPoint, const std::vector<double>& par) const {
94
95 double aa, bb, cc, dd;
96 double xort = 0;
97 Hep3Vector linePoint;
98
99 aa = par[0];
100 bb = par[1];
101 cc = par[2];
102 dd = par[3];
103
104 xort = dataPoint->getX() + bb * (dataPoint->getY() - aa) + dd * (dataPoint->getZ() - cc);
105 xort /= (1 + bb * bb + dd * dd);
106 linePoint.setX(xort);
107 linePoint.setY(aa + bb * xort);
108 linePoint.setZ(cc + dd * xort);
109
110 return linePoint;
111 }
112
113 } //namespace Minuit2
114
115} //namespace ROOT
116
#define y
#define x
#define z
virtual double operator()(const std::vector< double > &) const override
Provides Chi-square in function of parameter vector.
double Distance2SinglePoint(double x, double y, double z, const std::vector< double > &par) const
Returns squared distance from point to track defined by par.
void Means()
Calculates means (weighted or not) of cell positions.
std::vector< double > m_theX
Vector of cell center X coordinates.
std::vector< double > m_theZ
Vector of cell center Z coordinates.
std::vector< double > m_theY
Vector of cell center Y coordinates.
CLHEP::Hep3Vector ClosestPoint(CLHEP::Hep3Vector *dataPoint, const std::vector< double > &par) const
Returns point in track defined by par closest to dataPoint.
std::vector< double > m_theE
Vector of cell energies.
Selection rules: declare transient members.
Definition DataVector.h:581