ATLAS Offline Software
MuonSpectrometer/MuonPhaseII/Event/MuonSpacePoint/src/UtilFunctions.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
5 #include <GeoModelKernel/throwExcept.h>
7 #include <GaudiKernel/SystemOfUnits.h>
8 namespace MuonR4{
9 
11  return contract(mat,a,a);
12  }
14  return std::visit([&a,&b](const auto& cov) ->double{
15  using CovType = std::decay_t<decltype(cov)>;
16  if constexpr(std::is_same_v<CovType, AmgSymMatrix(2)>) {
17  return a.block<2,1>(0,0).dot(cov*b.block<2,1>(0,0));
18  } else if constexpr(std::is_same_v<CovType, AmgSymMatrix(3)>){
19  return a.dot(static_cast<const CovType&>(cov)*b);
20  }
21  return 0.;
22  }, mat);
23  }
25  return contract(mat,a,a);
26  }
28  return std::visit([&a,&b](const auto& cov) ->double {
29  using CovType = std::decay_t<decltype(cov)>;
30  if constexpr(std::is_same_v<CovType, AmgSymMatrix(2)>) {
31  return a.dot(cov*b);
32  } else {
33  THROW_EXCEPTION("Cannot perform the bilinear product between "<<Amg::toString(a)
34  <<", "<<Amg::toString(cov)<<", "<<Amg::toString(b));
35  }
36  return 0.;
37  }, mat);
38  }
39 
42  std::visit([&v, &result](const auto&cov) ->void {
43  using CovType = std::decay_t<decltype(cov)>;
44  if constexpr(std::is_same_v<CovType, AmgSymMatrix(2)>) {
45  result.block<2,1>(0,0) = cov * v.block<2,1>(0,0);
46  } else{
47  result = cov * v;
48  }
49  },mat);
50  return result;
51  }
54  std::visit([&v, &result](const auto&cov) ->void {
55  using CovType = std::decay_t<decltype(cov)>;
56  if constexpr(std::is_same_v<CovType, AmgSymMatrix(2)>) {
57  result.block<2,1>(0,0) = cov * v.block<2,1>(0,0);
58  } else {
59  THROW_EXCEPTION("Cannot multiply "<<Amg::toString(cov)<<" with "<<Amg::toString(v));
60  }
61  }, mat);
62  return result;
63  }
64 
66  return std::visit([](const auto& cov)-> CalibratedSpacePoint::Covariance_t {
67  using CovType = std::decay_t<decltype(cov)>;
68  if constexpr(std::is_same_v<CovType, AmgSymMatrix(2)>) {
69  return AmgSymMatrix(2){cov.inverse()};
70  } else {
71  return AmgSymMatrix(3){cov.inverse()};
72  }
73  }, mat);
74  }
76  return std::visit([](const auto& cov)-> std::string {
77  return Amg::toString(cov);
78  }, mat);
79  }
80 }
get_generator_info.result
result
Definition: get_generator_info.py:21
Amg::Vector2D
Eigen::Matrix< double, 2, 1 > Vector2D
Definition: GeoPrimitives.h:48
MuonR4::multiply
Amg::Vector3D multiply(const CalibratedSpacePoint::Covariance_t &mat, const Amg::Vector3D &v)
Multiplies a 3D vector with the covariance matrix which can be either 2x2 or 3x3 matrix.
Definition: MuonSpectrometer/MuonPhaseII/Event/MuonSpacePoint/src/UtilFunctions.cxx:40
mat
GeoMaterial * mat
Definition: LArDetectorConstructionTBEC.cxx:55
plotBeamSpotVxVal.cov
cov
Definition: plotBeamSpotVxVal.py:201
MuonR4::toString
std::string toString(const CalibratedSpacePoint::Covariance_t &mat)
Returns the matrix in string.
Definition: MuonSpectrometer/MuonPhaseII/Event/MuonSpacePoint/src/UtilFunctions.cxx:75
Amg::toString
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
Definition: GeoPrimitivesToStringConverter.h:40
MuonR4::inverse
CalibratedSpacePoint::Covariance_t inverse(const CalibratedSpacePoint::Covariance_t &mat)
Inverts the parsed matrix.
Definition: MuonSpectrometer/MuonPhaseII/Event/MuonSpacePoint/src/UtilFunctions.cxx:65
UtilFunctions.h
dot.dot
def dot(G, fn, nodesToHighlight=[])
Definition: dot.py:5
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
THROW_EXCEPTION
#define THROW_EXCEPTION(MESSAGE)
Definition: throwExcept.h:10
MuonR4
This header ties the generic definitions in this package.
Definition: HoughEventData.h:16
python.PyAthena.v
v
Definition: PyAthena.py:154
a
TList * a
Definition: liststreamerinfos.cxx:10
GeoPrimitivesToStringConverter.h
MuonR4::AmgSymMatrix
const AmgSymMatrix(2) &SpacePoint
Definition: MuonSpectrometer/MuonPhaseII/Event/MuonSpacePoint/src/SpacePoint.cxx:150
generate::Zero
void Zero(TH1D *hin)
Definition: generate.cxx:32
MuonR4::CalibratedSpacePoint::Covariance_t
std::variant< AmgSymMatrix(2), AmgSymMatrix(3)> Covariance_t
The spatial covariance matrix of the calibrated space point.
Definition: CalibratedSpacePoint.h:49
MuonR4::contract
double contract(const CalibratedSpacePoint::Covariance_t &mat, const Amg::Vector3D &a, const Amg::Vector3D &b)
Definition: MuonSpectrometer/MuonPhaseII/Event/MuonSpacePoint/src/UtilFunctions.cxx:13