Belle II Software development
NonIPCrossingStateFilter.icc.h
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#include <tracking/ckf/general/filters/NonIPCrossingStateFilter.dcl.h>
9
10#include <tracking/trackFindingCDC/eventdata/trajectories/CDCTrajectory2D.h>
11#include <tracking/trackFindingCDC/geometry/Vector3D.h>
12#include <tracking/trackFindingCDC/utilities/StringManipulation.h>
13
14#include <tracking/ckf/general/utilities/SearchDirection.h>
15
16#include <tracking/spacePointCreation/SpacePoint.h>
17#include <tracking/dataobjects/RecoTrack.h>
18
19#include <framework/core/ModuleParamList.h>
20
21namespace Belle2 {
26 template <class AllStateFilter>
28 {
29 if (std::isnan(AllStateFilter::operator()(pair))) {
30 return NAN;
31 }
32
33 const auto& previousStates = pair.first;
34 auto* state = pair.second;
35
36 const RecoTrack* cdcTrack = previousStates.front()->getSeed();
37 B2ASSERT("Path without seed?", cdcTrack);
38
39 const SpacePoint* spacePoint = state->getHit();
40 B2ASSERT("Path without hit?", spacePoint);
41
42 const genfit::MeasuredStateOnPlane& firstMeasurement = [&state, &previousStates]() {
43 if (state->mSoPSet()) {
44 return state->getMeasuredStateOnPlane();
45 } else {
46 B2ASSERT("Previous state was not fitted?", previousStates.back()->mSoPSet());
47 return previousStates.back()->getMeasuredStateOnPlane();
48 }
49 }();
50
51 const TrackFindingCDC::Vector3D& position = static_cast<TrackFindingCDC::Vector3D>(firstMeasurement.getPos());
52 const TrackFindingCDC::Vector3D& momentum = static_cast<TrackFindingCDC::Vector3D>(firstMeasurement.getMom());
53
54 const TrackFindingCDC::CDCTrajectory2D trajectory2D(position.xy(), 0, momentum.xy(), cdcTrack->getChargeSeed());
55
56 const TrackFindingCDC::Vector3D& hitPosition = static_cast<TrackFindingCDC::Vector3D>(spacePoint->getPosition());
57 const TrackFindingCDC::Vector2D origin(0, 0);
58
59 const double deltaArcLengthHitOrigin = trajectory2D.calcArcLength2DBetween(hitPosition.xy(), origin);
60 const double deltaArcLengthTrackHit = trajectory2D.calcArcLength2D(hitPosition.xy());
61
62 if (not arcLengthInRightDirection(deltaArcLengthTrackHit, m_param_direction) or
63 not arcLengthInRightDirection(deltaArcLengthHitOrigin, m_param_direction)) {
64 return NAN;
65 }
66
67 return 1.0;
68 }
69
70 template <class AllStateFilter>
71 void NonIPCrossingStateFilter<AllStateFilter>::exposeParameters(ModuleParamList* moduleParamList, const std::string& prefix)
72 {
73 moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "direction"), m_param_directionAsString,
74 "The direction where the extrapolation will happen.");
75 }
76
77 template <class AllStateFilter>
79 {
80 Super::initialize();
81 m_param_direction = fromString(m_param_directionAsString);
82 }
84}
The Module parameter list class.
typename AllStateFilter::Object Object
The object to filter.
This is the Reconstruction Event-Data Model Track.
Definition: RecoTrack.h:79
short int getChargeSeed() const
Return the charge seed stored in the reco track. ATTENTION: This is not the fitted charge.
Definition: RecoTrack.h:508
SpacePoint typically is build from 1 PXDCluster or 1-2 SVDClusters.
Definition: SpacePoint.h:42
const B2Vector3D & getPosition() const
return the position vector in global coordinates
Definition: SpacePoint.h:138
Particle trajectory as it is seen in xy projection represented as a circle.
double calcArcLength2D(const Vector2D &point) const
Calculate the travel distance from the start position of the trajectory.
double calcArcLength2DBetween(const Vector2D &fromPoint, const Vector2D &toPoint) const
Calculate the travel distance between the two given positions Returns the travel distance on the traj...
A two dimensional vector which is equipped with functions for correct handling of orientation relate...
Definition: Vector2D.h:32
A three dimensional vector.
Definition: Vector3D.h:33
const Vector2D & xy() const
Getter for the xy projected vector ( reference ! )
Definition: Vector3D.h:508
void addParameter(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module list.
TrackFindingCDC::Weight operator()(const Object &pair) final
Main function testing the object for the direction.
void initialize() final
Copy the string direction parameter to the enum.
TrackFindingCDC::EForwardBackward fromString(const std::string &directionString)
Helper function to turn a direction string into a valid forward backward information.
constexpr bool arcLengthInRightDirection(double arcLength2D, TrackFindingCDC::EForwardBackward forwardBackward)
Given the calculated arc length between a start point and an end point, checks if the travelled path ...
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) override
Expose the direction parameter.
Abstract base class for different kinds of events.