ATLAS Offline Software
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 
23 using CLHEP::Hep3Vector;
24 
25 namespace 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 
ROOT::Minuit2::TileMuonTrackDistance::m_meanY
double m_meanY
Definition: TileMuonTrackDistance.h:132
ROOT::Minuit2::TileMuonTrackDistance::m_doWeighted
bool m_doWeighted
Weight/no-weight flag.
Definition: TileMuonTrackDistance.h:129
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
ROOT::Minuit2::TileMuonTrackDistance::m_theZ
std::vector< double > m_theZ
Vector of cell center Z coordinates.
Definition: TileMuonTrackDistance.h:124
x
#define x
ROOT::Minuit2::TileMuonTrackDistance::Distance2SinglePoint
double Distance2SinglePoint(double x, double y, double z, const std::vector< double > &par) const
Returns squared distance from point to track defined by par.
Definition: TileMuonTrackDistance.cxx:84
ROOT::Minuit2::TileMuonTrackDistance::m_theE
std::vector< double > m_theE
Vector of cell energies.
Definition: TileMuonTrackDistance.h:126
lumiFormat.i
int i
Definition: lumiFormat.py:85
z
#define z
xAOD::double
double
Definition: CompositeParticle_v1.cxx:159
ROOT::Minuit2::TileMuonTrackDistance::Means
void Means()
Calculates means (weighted or not) of cell positions.
Definition: TileMuonTrackDistance.cxx:28
TileMuonTrackDistance.h
ROOT::Minuit2::TileMuonTrackDistance::m_theY
std::vector< double > m_theY
Vector of cell center Y coordinates.
Definition: TileMuonTrackDistance.h:122
createCoolChannelIdFile.par
par
Definition: createCoolChannelIdFile.py:29
library_scraper.dd
list dd
Definition: library_scraper.py:46
ROOT::Minuit2::TileMuonTrackDistance::ClosestPoint
CLHEP::Hep3Vector ClosestPoint(CLHEP::Hep3Vector *dataPoint, const std::vector< double > &par) const
Returns point in track defined by par closest to dataPoint.
Definition: TileMuonTrackDistance.cxx:93
y
#define y
ROOT::Minuit2::TileMuonTrackDistance::m_meanZ
double m_meanZ
Definition: TileMuonTrackDistance.h:133
ROOT::Minuit2::TileMuonTrackDistance::m_meanX
double m_meanX
Definition: TileMuonTrackDistance.h:131
ROOT::Minuit2::TileMuonTrackDistance::m_theX
std::vector< double > m_theX
Vector of cell center X coordinates.
Definition: TileMuonTrackDistance.h:120
ROOT::Minuit2::TileMuonTrackDistance::operator()
virtual double operator()(const std::vector< double > &) const override
Provides Chi-square in function of parameter vector.
Definition: TileMuonTrackDistance.cxx:62
test_AnalysisBaseEventLoopJob.aa
aa
Definition: test_AnalysisBaseEventLoopJob.py:37
ROOT
Selection rules: declare transient members.
Definition: DataVector.h:580
python.handimod.cc
int cc
Definition: handimod.py:523