Belle II Software development
SVDStateBasicVarSet.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#include <tracking/ckf/svd/filters/states/SVDStateBasicVarSet.h>
10
11#include <tracking/trackFindingCDC/eventdata/trajectories/CDCTrajectory3D.h>
12#include <tracking/trackFindingCDC/eventdata/trajectories/CDCTrajectory2D.h>
13#include <tracking/trackFindingCDC/eventdata/trajectories/CDCTrajectorySZ.h>
14#include <tracking/trackFindingCDC/geometry/Vector3D.h>
15
16#include <tracking/spacePointCreation/SpacePoint.h>
17#include <tracking/dataobjects/RecoTrack.h>
18
19using namespace Belle2;
20using namespace TrackFindingCDC;
21
23{
24 const std::vector<TrackFindingCDC::WithWeight<const CKFToSVDState*>>& previousStates = pair->first;
25 CKFToSVDState* state = pair->second;
26
27 const RecoTrack* cdcTrack = previousStates.front()->getSeed();
28 B2ASSERT("Path without seed?", cdcTrack);
29
30 const SpacePoint* spacePoint = state->getHit();
31 B2ASSERT("Path without hit?", spacePoint);
32
33 genfit::MeasuredStateOnPlane firstMeasurement;
34 if (state->mSoPSet()) {
35 firstMeasurement = state->getMeasuredStateOnPlane();
36 } else {
37 B2ASSERT("Previous state was not fitted?", previousStates.back()->mSoPSet());
38 firstMeasurement = previousStates.back()->getMeasuredStateOnPlane();
39 }
40
41 Vector3D position = Vector3D(firstMeasurement.getPos());
42 Vector3D momentum = Vector3D(firstMeasurement.getMom());
43
44 const CDCTrajectory3D trajectory(position, 0, momentum, cdcTrack->getChargeSeed());
45
46 const Vector3D& hitPosition = static_cast<Vector3D>(spacePoint->getPosition());
47
48 const double arcLength = trajectory.calcArcLength2D(hitPosition);
49 const Vector2D& trackPositionAtHit2D = trajectory.getTrajectory2D().getPos2DAtArcLength2D(arcLength);
50 double trackPositionAtHitZ = trajectory.getTrajectorySZ().mapSToZ(arcLength);
51
52 Vector3D trackPositionAtHit(trackPositionAtHit2D, trackPositionAtHitZ);
53 Vector3D distance = trackPositionAtHit - hitPosition;
54
55 var<named("distance")>() = static_cast<Float_t>(distance.norm());
56 var<named("xy_distance")>() = static_cast<Float_t>(distance.xy().norm());
57 var<named("z_distance")>() = static_cast<Float_t>(distance.z());
58
59 Vector3D mSoP_distance = position - hitPosition;
60
61 var<named("mSoP_distance")>() = static_cast<Float_t>(mSoP_distance.norm());
62 var<named("mSoP_xy_distance")>() = static_cast<Float_t>(mSoP_distance.xy().norm());
63 var<named("mSoP_z_distance")>() = static_cast<Float_t>(mSoP_distance.z());
64
65 var<named("same_hemisphere")>() = fabs(position.phi() - hitPosition.phi()) < TMath::PiOver2();
66
67 var<named("arcLengthOfHitPosition")>() = static_cast<Float_t>(trajectory.calcArcLength2D(hitPosition));
68 var<named("arcLengthOfCenterPosition")>() = static_cast<Float_t>(trajectory.calcArcLength2D(Vector3D(0, 0, 0)));
69
70 var<named("pt")>() = static_cast<Float_t>(momentum.xy().norm());
71 var<named("tan_lambda")>() = static_cast<Float_t>(trajectory.getTanLambda());
72 var<named("phi")>() = static_cast<Float_t>(momentum.phi());
73
74 const VxdID& sensorInfo = spacePoint->getVxdID();
75 var<named("layer")>() = sensorInfo.getLayerNumber();
76 var<named("number")>() = previousStates.size();
77 var<named("ladder")>() = sensorInfo.getLadderNumber();
78 var<named("sensor")>() = sensorInfo.getSensorNumber();
79 var<named("segment")>() = sensorInfo.getSegmentNumber();
80 var<named("id")>() = sensorInfo.getID();
81
82
83 const auto& clusters = spacePoint->getRelationsTo<SVDCluster>();
84 B2ASSERT("Must be related to exactly 2 clusters", clusters.size() == 2);
85 const SVDCluster* firstCluster = clusters[0];
86 const SVDCluster* secondCluster = clusters[1];
87 var<named("cluster_1_time")>() = firstCluster->getClsTime();
88 var<named("cluster_2_time")>() = secondCluster->getClsTime();
89
90 var<named("last_layer")>() = 0;
91 var<named("last_ladder")>() = 0;
92 var<named("last_sensor")>() = 0;
93 var<named("last_segment")>() = 0;
94 var<named("last_id")>() = 0;
95 var<named("last_cluster_1_time")>() = -999.9;
96 var<named("last_cluster_2_time")>() = -999.9;
97
98 const CKFToSVDState* parent = previousStates.back();
99 const SpacePoint* parentSpacePoint = parent->getHit();
100 if (parentSpacePoint) {
101 const VxdID& parentSensorInfo = parentSpacePoint->getVxdID();
102
103 var<named("last_layer")>() = parentSensorInfo.getLayerNumber();
104 var<named("last_ladder")>() = parentSensorInfo.getLadderNumber();
105 var<named("last_sensor")>() = parentSensorInfo.getSensorNumber();
106 var<named("last_segment")>() = parentSensorInfo.getSegmentNumber();
107 var<named("last_id")>() = parentSensorInfo.getID();
108
109 const auto& parentclusters = parentSpacePoint->getRelationsTo<SVDCluster>();
110 B2ASSERT("Must be related to exactly 2 clusters", parentclusters.size() == 2);
111 const SVDCluster* parentfirstCluster = parentclusters[0];
112 const SVDCluster* parentsecondCluster = parentclusters[1];
113 var<named("last_cluster_1_time")>() = parentfirstCluster->getClsTime();
114 var<named("last_cluster_2_time")>() = parentsecondCluster->getClsTime();
115 }
116
117 const double residual = m_kalmanStepper.calculateResidual(firstMeasurement, *state);
118 var<named("residual")>() = residual;
119
120 if (state->isFitted()) {
121 var<named("chi2")>() = static_cast<Float_t>(state->getChi2());
122 } else {
123 var<named("chi2")>() = -999;
124 }
125
126 const TMatrixDSym& cov5 = firstMeasurement.getCov();
127 const Float_t sigmaUV = std::sqrt(std::max(cov5(4, 4), cov5(3, 3)));
128 var<named("sigma_uv")>() = sigmaUV;
129 var<named("residual_over_sigma")>() = residual / sigmaUV;
130
131 return true;
132}
Specialized CKF State for extrapolating into the SVD.
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
RelationVector< TO > getRelationsTo(const std::string &name="", const std::string &namedRelation="") const
Get the relations that point from this object to another store array.
The SVD Cluster class This class stores all information about reconstructed SVD clusters.
Definition SVDCluster.h:29
float getClsTime() const
Get average of waveform maximum times of cluster strip signals.
Definition SVDCluster.h:134
SVDKalmanStepper m_kalmanStepper
Kalman stepper (CKF) for SVD.
virtual bool extract(const BaseSVDStateFilter::Object *pair) override
Generate and assign the variables from the VXD-CDC-pair.
SpacePoint typically is build from 1 PXDCluster or 1-2 SVDClusters.
Definition SpacePoint.h:42
VxdID getVxdID() const
Return the VxdID of the sensor on which the the cluster of the SpacePoint lives.
Definition SpacePoint.h:148
const B2Vector3D & getPosition() const
return the position vector in global coordinates
Definition SpacePoint.h:138
Vector2D getPos2DAtArcLength2D(double arcLength2D)
Getter for the position at a given two dimensional arc length.
Particle full three dimensional trajectory.
double calcArcLength2D(const Vector3D &point) const
Calculate the travel distance from the start position of the trajectory.
CDCTrajectory2D getTrajectory2D() const
Getter for the two dimensional trajectory.
CDCTrajectorySZ getTrajectorySZ() const
Getter for the sz trajectory.
double getTanLambda() const
Getter for the slope of z over the transverse travel distance s.
double mapSToZ(const double s=0) const
Translates the travel distance to the z coordinate.
std::pair< const std::vector< TrackFindingCDC::WithWeight< const CKFToSVDState * > >, CKFToSVDState * > Object
Definition Filter.dcl.h:35
static constexpr int named(const char *name)
Definition VarSet.h:78
A two dimensional vector which is equipped with functions for correct handling of orientation relate...
Definition Vector2D.h:32
Class to uniquely identify a any structure of the PXD and SVD.
Definition VxdID.h:33
baseType getID() const
Get the unique id.
Definition VxdID.h:94
baseType getSensorNumber() const
Get the sensor id.
Definition VxdID.h:100
baseType getSegmentNumber() const
Get the sensor segment.
Definition VxdID.h:102
baseType getLadderNumber() const
Get the ladder id.
Definition VxdID.h:98
baseType getLayerNumber() const
Get the layer id.
Definition VxdID.h:96
STL class.
HepGeom::Vector3D< double > Vector3D
3D Vector
Definition Cell.h:34
Abstract base class for different kinds of events.