Belle II Software  release-05-01-25
NonIPCrossingStateFilter.icc.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2017 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Nils Braun *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 #include <tracking/ckf/general/filters/NonIPCrossingStateFilter.dcl.h>
11 
12 #include <tracking/trackFindingCDC/eventdata/trajectories/CDCTrajectory2D.h>
13 #include <tracking/trackFindingCDC/geometry/Vector3D.h>
14 #include <tracking/trackFindingCDC/utilities/StringManipulation.h>
15 
16 #include <tracking/ckf/general/utilities/SearchDirection.h>
17 
18 #include <tracking/spacePointCreation/SpacePoint.h>
19 #include <tracking/dataobjects/RecoTrack.h>
20 
21 #include <framework/core/ModuleParamList.h>
22 
23 namespace Belle2 {
28  template <class AllStateFilter>
29  TrackFindingCDC::Weight NonIPCrossingStateFilter<AllStateFilter>::operator()(const Object& pair)
30  {
31  if (std::isnan(AllStateFilter::operator()(pair))) {
32  return NAN;
33  }
34 
35  const auto& previousStates = pair.first;
36  auto* state = pair.second;
37 
38  const RecoTrack* cdcTrack = previousStates.front()->getSeed();
39  B2ASSERT("Path without seed?", cdcTrack);
40 
41  const SpacePoint* spacePoint = state->getHit();
42  B2ASSERT("Path without hit?", spacePoint);
43 
44  const genfit::MeasuredStateOnPlane& firstMeasurement = [&state, &previousStates]() {
45  if (state->mSoPSet()) {
46  return state->getMeasuredStateOnPlane();
47  } else {
48  B2ASSERT("Previous state was not fitted?", previousStates.back()->mSoPSet());
49  return previousStates.back()->getMeasuredStateOnPlane();
50  }
51  }();
52 
53  const TrackFindingCDC::Vector3D& position = static_cast<TrackFindingCDC::Vector3D>(firstMeasurement.getPos());
54  const TrackFindingCDC::Vector3D& momentum = static_cast<TrackFindingCDC::Vector3D>(firstMeasurement.getMom());
55 
56  const TrackFindingCDC::CDCTrajectory2D trajectory2D(position.xy(), 0, momentum.xy(), cdcTrack->getChargeSeed());
57 
58  const TrackFindingCDC::Vector3D& hitPosition = static_cast<TrackFindingCDC::Vector3D>(spacePoint->getPosition());
59  const TrackFindingCDC::Vector2D origin(0, 0);
60 
61  const double deltaArcLengthHitOrigin = trajectory2D.calcArcLength2DBetween(hitPosition.xy(), origin);
62  const double deltaArcLengthTrackHit = trajectory2D.calcArcLength2D(hitPosition.xy());
63 
64  if (not arcLengthInRightDirection(deltaArcLengthTrackHit, m_param_direction) or
65  not arcLengthInRightDirection(deltaArcLengthHitOrigin, m_param_direction)) {
66  return NAN;
67  }
68 
69  return 1.0;
70  }
71 
72  template <class AllStateFilter>
73  void NonIPCrossingStateFilter<AllStateFilter>::exposeParameters(ModuleParamList* moduleParamList, const std::string& prefix)
74  {
75  moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "direction"), m_param_directionAsString,
76  "The direction where the extrapolation will happen.");
77  }
78 
79  template <class AllStateFilter>
81  {
82  Super::initialize();
83  m_param_direction = fromString(m_param_directionAsString);
84  }
86 }
Belle2::fromString
TrackFindingCDC::EForwardBackward fromString(const std::string &directionString)
Helper function to turn a direction string into a valid forward backward information.
Definition: SearchDirection.h:46
Belle2::Vector3D
HepGeom::Vector3D< double > Vector3D
3D Vector
Definition: Cell.h:35
genfit::MeasuredStateOnPlane
#StateOnPlane with additional covariance matrix.
Definition: MeasuredStateOnPlane.h:39
Belle2::arcLengthInRightDirection
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 ...
Definition: SearchDirection.h:40
Belle2::SpacePoint
SpacePoint typically is build from 1 PXDCluster or 1-2 SVDClusters.
Definition: SpacePoint.h:52
Belle2::SpacePoint::getPosition
const B2Vector3< double > & getPosition() const
return the position vector in global coordinates
Definition: SpacePoint.h:148
Belle2::RecoTrack
This is the Reconstruction Event-Data Model Track.
Definition: RecoTrack.h:78
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::NonIPCrossingStateFilter::initialize
void initialize() final
Copy the string direction parameter to the enum.
Definition: NonIPCrossingStateFilter.icc.h:88
Belle2::NonIPCrossingStateFilter::operator()
TrackFindingCDC::Weight operator()(const Object &pair) final
Main function testing the object for the direction.
Definition: NonIPCrossingStateFilter.icc.h:37
Belle2::NonIPCrossingStateFilter::exposeParameters
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) override
Expose the direction parameter.
Definition: NonIPCrossingStateFilter.icc.h:81
Belle2::RecoTrack::getChargeSeed
short int getChargeSeed() const
Return the charge seed stored in the reco track. ATTENTION: This is not the fitted charge.
Definition: RecoTrack.h:497