Belle II Software  release-05-01-25
SegmentInPhi0CurvBox.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2015 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Oliver Frost *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 #pragma once
11 
12 #include <tracking/trackFindingCDC/eventdata/segments/CDCSegment2D.h>
13 #include <tracking/trackFindingCDC/eventdata/trajectories/CDCTrajectory2D.h>
14 #include <tracking/trackFindingCDC/hough/phi0_curv/Phi0CurvBox.h>
15 #include <tracking/trackFindingCDC/geometry/Vector2D.h>
16 
17 namespace Belle2 {
22  namespace TrackFindingCDC {
23 
28  class SegmentInPhi0CurvBox {
29 
37  Weight operator()(const CDCSegment2D* segment,
38  const Phi0CurvBox* phi0CurvBox)
39  {
40  if (segment->empty()) return NAN;
41  const CDCTrajectory2D& trajectory2D = segment->getTrajectory2D();
42  Weight weight = operator()(&trajectory2D, phi0CurvBox);
43  return weight * segment->size();
44  }
45 
50  Weight operator()(const CDCTrajectory2D* trajectory2D,
51  const Phi0CurvBox* phi0CurvBox)
52  {
53  double curvature = trajectory2D->getCurvature();
54  const Vector2D& phi0Vec = trajectory2D->getStartUnitMom2D();
55 
56  bool in = isPhi0CurvPointIn(phi0Vec, curvature, phi0CurvBox);
57  return in ? 1 : NAN;
58  }
59 
60 
65  Weight operator()(const CDCFacet* facet,
66  const Phi0CurvBox* phi0CurvBox)
67  {
68  const ParameterLine2D& line = facet->getStartToEndLine();
69 
70  const Vector2D pos2D = facet->getMiddleRecoPos2D();
71  const Vector2D phiVec = line.tangential().unit();
72 
73  // Calculate the curvature and phi0 of the circle through the origin
74  // that touches the position pos2D under the angle phiVec.
75  double curvature = 2 * pos2D.cross(phiVec) / pos2D.normSquared();
76  Vector2D phi0Vec = phiVec.flippedOver(pos2D);
77 
78  bool in = isPhi0CurvPointIn(phi0Vec, curvature, phi0CurvBox);
79  return in ? 1 : NAN;
80  // All facets are currently worth the same weight
81  // Facets contain three hits but in general contribute only one
82  // additional hit due to overlaps with neighboring facets.
83  // Hence we stick with 1 as weight here.
84  }
85 
87  bool isPhi0CurvPointIn(const Vector2D& phi0Vec,
88  const double curvature,
89  const Phi0CurvBox* phi0CurvBox)
90  {
91 
92  const Vector2D& lowerPhi0Vec = phi0CurvBox->getLowerPhi0Vec();
93  const Vector2D& upperPhi0Vec = phi0CurvBox->getUpperPhi0Vec();
94 
95  // Allow containment to keep the reversal symmetry
96  if (phi0CurvBox->isIn<1>(curvature)) {
97  return phi0Vec.isBetween(lowerPhi0Vec, upperPhi0Vec);
98 
99  } else if (phi0CurvBox->isIn<1>(-curvature)) {
100  return (-phi0Vec).isBetween(lowerPhi0Vec, upperPhi0Vec);
101 
102  } else {
103  return false;
104 
105  }
106 
107  }
108  };
109 
110  }
112 }
Belle2::TrackFindingCDC::CDCFacet::getStartToEndLine
ParameterLine2D getStartToEndLine() const
Getter for the tangential line from the first to the third hit.
Definition: CDCFacet.cc:96
Belle2::TrackFindingCDC::Vector2D::flippedOver
Vector2D flippedOver(const Vector2D &reflectionLine) const
Reflects this vector over line designated by the given vector.
Definition: Vector2D.h:385
Belle2::TrackFindingCDC::Vector2D
A two dimensional vector which is equipped with functions for correct handeling of orientation relat...
Definition: Vector2D.h:37
Belle2::TrackFindingCDC::SegmentInPhi0CurvBox::operator()
Weight operator()(const CDCSegment2D *segment, const Phi0CurvBox *phi0CurvBox)
Checks if the segment is contained in a phi0 curv hough space.
Definition: SegmentInPhi0CurvBox.h:45
Belle2::TrackFindingCDC::Vector2D::normSquared
double normSquared() const
Calculates .
Definition: Vector2D.h:183
Belle2::TrackFindingCDC::Vector2D::isBetween
bool isBetween(const Vector2D &lower, const Vector2D &upper) const
Checks if this vector is between two other vectors Between means here that when rotating the lower ve...
Definition: Vector2D.h:539
Belle2::TrackFindingCDC::CDCTrajectory2D::getCurvature
double getCurvature() const
Getter for the curvature as seen from the xy projection.
Definition: CDCTrajectory2D.h:432
Belle2::TrackFindingCDC::ParameterLine2D
A line with a support point and tangential vector.
Definition: ParameterLine2D.h:48
Belle2::TrackFindingCDC::CDCTrajectory2D
Particle trajectory as it is seen in xy projection represented as a circle.
Definition: CDCTrajectory2D.h:46
Belle2::TrackFindingCDC::Vector2D::cross
double cross(const Vector2D &rhs) const
Calculated the two dimensional cross product.
Definition: Vector2D.h:177
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::TrackFindingCDC::CDCFacet
Class representing a triple of neighboring oriented wire with additional trajectory information.
Definition: CDCFacet.h:42
Belle2::TrackFindingCDC::CDCFacet::getMiddleRecoPos2D
Vector2D getMiddleRecoPos2D() const
Getter for the reconstructed position at the second hit on the fit line.
Definition: CDCFacet.cc:78
Belle2::TrackFindingCDC::SegmentInPhi0CurvBox::isPhi0CurvPointIn
bool isPhi0CurvPointIn(const Vector2D &phi0Vec, const double curvature, const Phi0CurvBox *phi0CurvBox)
Predicate checking if the phi0 vector and curvature are contained in the given box.
Definition: SegmentInPhi0CurvBox.h:95