Belle II Software development
BremFindingMatchCompute.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9/* Own header. */
10#include <ecl/modules/eclTrackBremFinder/BremFindingMatchCompute.h>
11
12/* Basf2 headers. */
13#include <framework/geometry/VectorUtil.h>
14#include <framework/utilities/Angle.h>
15#include <mdst/dataobjects/ECLCluster.h>
16
17/* Genfit headers. */
18#include <genfit/MeasuredStateOnPlane.h>
19
20/* ROOT headers. */
21#include <Math/Vector3D.h>
22
23using namespace std;
24using namespace Belle2;
25
27{
28 auto fitted_state = m_measuredStateOnPlane;
29
30 ROOT::Math::XYZVector clusterPosition = m_eclCluster->getClusterPosition();
31
32 TVector3 position = fitted_state.getPos();
33 ROOT::Math::XYZVector positionDifference(
34 clusterPosition.X() - position.X(),
35 clusterPosition.Y() - position.Y(),
36 clusterPosition.Z() - position.Z());
37 TVector3 momentum = fitted_state.getMom();
38 ROOT::Math::XYZVector fitted_mom(momentum.X(), momentum.Y(), momentum.Z());
39
40 auto cov = fitted_state.get6DCov();
41 const double err_px = cov[3][3];
42 const double err_py = cov[4][4];
43 const double err_pz = cov[5][5];
44 const double px = fitted_mom.X();
45 const double py = fitted_mom.Y();
46 const double pz = fitted_mom.Z();
47
48 const double square_perp = px * px + py * py ;
49 const double perp = std::sqrt(square_perp);
50 const double square_sum = square_perp + pz * pz;
51
52 const double err_phi = std::sqrt(pow((py / square_perp), 2) * err_px + pow((px / square_perp), 2) * err_py +
53 (py / square_perp) * (px / square_perp) * cov[3][4]);
54 const double err_theta = std::sqrt(pow(((px * pz) / (square_sum * perp)), 2) * err_px +
55 pow(((py * pz) / (square_sum * perp)), 2) * err_py +
56 pow((perp / square_sum), 2) * err_pz +
57 ((px * pz) / (square_sum * perp)) * ((py * pz) / (square_sum * perp)) * cov[3][4] +
58 ((px * pz) / (square_sum * perp)) * (perp / square_sum) * cov[3][5] +
59 ((py * pz) / (square_sum * perp)) * (perp / square_sum) * cov[4][5]);
60
61 PhiAngle hitPhi(fitted_mom.Phi(), err_phi);
62 ThetaAngle hitTheta(fitted_mom.Theta(), err_theta);
63
64 PhiAngle clusterPhi(positionDifference.Phi(), m_eclCluster->getUncertaintyPhi());
65 ThetaAngle clusterTheta(positionDifference.Theta(), m_eclCluster->getUncertaintyTheta());
66
67 if (clusterPhi.containsIn(hitPhi, m_clusterAcceptanceFactor) &&
68 clusterTheta.containsIn(hitTheta, m_clusterAcceptanceFactor)) {
69
70 ROOT::Math::XYZVector hitV;
71 VectorUtil::setMagThetaPhi(
72 hitV, 1.0, hitTheta.getAngle(), hitPhi.getAngle());
73 ROOT::Math::XYZVector clusterV;
74 VectorUtil::setMagThetaPhi(
75 clusterV, 1.0, clusterTheta.getAngle(), clusterPhi.getAngle());
76
77 ROOT::Math::XYZVector distV = hitV - clusterV;
78
79 m_distanceHitCluster = distV.R();
80
81 // set the effective acceptance factor
82 double deltaTheta = abs(hitV.Y() - clusterV.Y());
83 m_effAcceptanceFactor = deltaTheta / (err_theta + m_eclCluster->getUncertaintyTheta());
84 double deltaPhi = abs(hitV.Z() - clusterV.Z());
85 double effFactor = deltaPhi / (err_phi + m_eclCluster->getUncertaintyPhi());
86 if (effFactor > m_effAcceptanceFactor) {
87 m_effAcceptanceFactor = effFactor;
88 }
89
90 return (true);
91
92 // todo: can use weight here to signal assignment confidence
93
94 } else {
95 return (false);
96 }
97}
double getAngle() const
Getter for the angle.
Definition: Angle.h:37
bool isMatch()
Check if the angles of the cluster position and the extrapolation match.
const ECLCluster * m_eclCluster
Bremsstrahlung cluster candidate gets stored here.
float m_clusterAcceptanceFactor
Factor which is multiplied onto the cluster position error to check for matches.
double m_distanceHitCluster
Difference between the angles of extrapolation and cluster position.
genfit::MeasuredStateOnPlane const & m_measuredStateOnPlane
VXD hit.
double m_effAcceptanceFactor
The effective acceptance factor, needed to assign the radiation.
double getUncertaintyTheta() const
Return Uncertainty on Theta of Shower.
Definition: ECLCluster.h:325
ROOT::Math::XYZVector getClusterPosition() const
Return ROOT::Math::XYZVector on cluster position (x,y,z)
Definition: ECLCluster.cc:44
double getUncertaintyPhi() const
Return Uncertainty on Phi of Shower.
Definition: ECLCluster.h:328
bool containsIn(const PhiAngle &angle, double sigma) const
Check if two angles are compatible.
Definition: Angle.h:136
bool containsIn(const ThetaAngle &angle, double sigma) const
Check if two angles are compatible.
Definition: Angle.h:90
Abstract base class for different kinds of events.
STL namespace.