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/trackingUtilities/eventdata/trajectories/CDCTrajectory2D.h>
11#include <tracking/trackingUtilities/geometry/VectorUtil.h>
12#include <tracking/trackingUtilities/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
21#include <Math/Vector2D.h>
22#include <Math/Vector3D.h>
23
24namespace Belle2 {
29 template <class AllStateFilter>
30 TrackingUtilities::Weight NonIPCrossingStateFilter<AllStateFilter>::operator()(const Object& pair)
31 {
32 if (std::isnan(AllStateFilter::operator()(pair))) {
33 return NAN;
34 }
35
36 const auto& previousStates = pair.first;
37 auto* state = pair.second;
39 const RecoTrack* cdcTrack = previousStates.front()->getSeed();
40 B2ASSERT("Path without seed?", cdcTrack);
42 const SpacePoint* spacePoint = state->getHit();
43 B2ASSERT("Path without hit?", spacePoint);
45 const genfit::MeasuredStateOnPlane& firstMeasurement = [&state, &previousStates]() {
46 if (state->mSoPSet()) {
47 return state->getMeasuredStateOnPlane();
48 } else {
49 B2ASSERT("Previous state was not fitted?", previousStates.back()->mSoPSet());
50 return previousStates.back()->getMeasuredStateOnPlane();
51 }
52 }();
53
54 const ROOT::Math::XYZVector& position = static_cast<ROOT::Math::XYZVector>(firstMeasurement.getPos());
55 const ROOT::Math::XYZVector& momentum = static_cast<ROOT::Math::XYZVector>(firstMeasurement.getMom());
56
57 const TrackingUtilities::CDCTrajectory2D trajectory2D(VectorUtil::getXYVector(position), 0, VectorUtil::getXYVector(momentum),
58 cdcTrack->getChargeSeed());
59
60 const ROOT::Math::XYZVector& hitPosition = spacePoint->getPosition();
61 const ROOT::Math::XYVector origin(0, 0);
62
63 const double deltaArcLengthHitOrigin = trajectory2D.calcArcLength2DBetween(VectorUtil::getXYVector(hitPosition), origin);
64 const double deltaArcLengthTrackHit = trajectory2D.calcArcLength2D(VectorUtil::getXYVector(hitPosition));
65
66 if (not arcLengthInRightDirection(deltaArcLengthTrackHit, m_param_direction) or
67 not arcLengthInRightDirection(deltaArcLengthHitOrigin, m_param_direction)) {
68 return NAN;
69 }
70
71 return 1.0;
72 }
73
74 template <class AllStateFilter>
75 void NonIPCrossingStateFilter<AllStateFilter>::exposeParameters(ModuleParamList* moduleParamList, const std::string& prefix)
76 {
77 moduleParamList->addParameter(TrackingUtilities::prefixed(prefix, "direction"), m_param_directionAsString,
78 "The direction where the extrapolation will happen.");
79 }
80
81 template <class AllStateFilter>
87
88
88}
The Module parameter list class.
typename AllStateFilter::Object Object
The object to filter.
TrackingUtilities::EForwardBackward m_param_direction
Direction parameter converted from the string parameters.
std::string m_param_directionAsString
Parameter for the distance given to the framework (can not handle EForwardBackward directly)
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.
void addParameter(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module list.
TrackingUtilities::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.
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) override
Expose the direction parameter.
TrackingUtilities::EForwardBackward fromString(const std::string &directionString)
Helper function to turn a direction string into a valid forward backward information.
constexpr bool arcLengthInRightDirection(double arcLength2D, TrackingUtilities::EForwardBackward forwardBackward)
Given the calculated arc length between a start point and an end point, checks if the travelled path ...
Abstract base class for different kinds of events.