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/trackingUtilities/eventdata/trajectories/CDCTrajectory3D.h>
12#include <tracking/trackingUtilities/eventdata/trajectories/CDCTrajectory2D.h>
13#include <tracking/trackingUtilities/eventdata/trajectories/CDCTrajectorySZ.h>
14
15#include <tracking/spacePointCreation/SpacePoint.h>
16#include <tracking/dataobjects/RecoTrack.h>
17
18#include <Math/Vector3D.h>
19#include <Math/Vector2D.h>
20
21using namespace Belle2;
22using namespace TrackingUtilities;
23
25{
26 const std::vector<TrackingUtilities::WithWeight<const CKFToSVDState*>>& previousStates = pair->first;
27 CKFToSVDState* state = pair->second;
28
29 const RecoTrack* cdcTrack = previousStates.front()->getSeed();
30 B2ASSERT("Path without seed?", cdcTrack);
31
32 const SpacePoint* spacePoint = state->getHit();
33 B2ASSERT("Path without hit?", spacePoint);
34
35 genfit::MeasuredStateOnPlane firstMeasurement;
36 if (state->mSoPSet()) {
37 firstMeasurement = state->getMeasuredStateOnPlane();
38 } else {
39 B2ASSERT("Previous state was not fitted?", previousStates.back()->mSoPSet());
40 firstMeasurement = previousStates.back()->getMeasuredStateOnPlane();
41 }
42
43 const ROOT::Math::XYZVector position = ROOT::Math::XYZVector(firstMeasurement.getPos());
44 const ROOT::Math::XYZVector momentum = ROOT::Math::XYZVector(firstMeasurement.getMom());
45
46 const CDCTrajectory3D trajectory(position, 0, momentum, cdcTrack->getChargeSeed());
47
48 const ROOT::Math::XYZVector& hitPosition = spacePoint->getPosition();
49
50 const double arcLength = trajectory.calcArcLength2D(hitPosition);
51 const ROOT::Math::XYVector& trackPositionAtHit2D = trajectory.getTrajectory2D().getPos2DAtArcLength2D(arcLength);
52 double trackPositionAtHitZ = trajectory.getTrajectorySZ().mapSToZ(arcLength);
53
54 ROOT::Math::XYZVector trackPositionAtHit(trackPositionAtHit2D.X(), trackPositionAtHit2D.Y(), trackPositionAtHitZ);
55 ROOT::Math::XYZVector distance = trackPositionAtHit - hitPosition;
56
57 var<named("distance")>() = static_cast<Float_t>(distance.R());
58 var<named("xy_distance")>() = static_cast<Float_t>(distance.Rho());
59 var<named("z_distance")>() = static_cast<Float_t>(distance.z());
60
61 ROOT::Math::XYZVector mSoP_distance = position - hitPosition;
62
63 var<named("mSoP_distance")>() = static_cast<Float_t>(mSoP_distance.R());
64 var<named("mSoP_xy_distance")>() = static_cast<Float_t>(mSoP_distance.Rho());
65 var<named("mSoP_z_distance")>() = static_cast<Float_t>(mSoP_distance.z());
66
67 var<named("same_hemisphere")>() = fabs(position.Phi() - hitPosition.Phi()) < TMath::PiOver2();
68
69 var<named("arcLengthOfHitPosition")>() = static_cast<Float_t>(trajectory.calcArcLength2D(hitPosition));
70 var<named("arcLengthOfCenterPosition")>() = static_cast<Float_t>(trajectory.calcArcLength2D(ROOT::Math::XYZVector(0, 0, 0)));
71
72 var<named("pt")>() = static_cast<Float_t>(momentum.Rho());
73 var<named("tan_lambda")>() = static_cast<Float_t>(trajectory.getTanLambda());
74 var<named("phi")>() = static_cast<Float_t>(momentum.Phi());
75
76 const VxdID& sensorInfo = spacePoint->getVxdID();
77 var<named("layer")>() = sensorInfo.getLayerNumber();
78 var<named("number")>() = previousStates.size();
79 var<named("ladder")>() = sensorInfo.getLadderNumber();
80 var<named("sensor")>() = sensorInfo.getSensorNumber();
81 var<named("segment")>() = sensorInfo.getSegmentNumber();
82 var<named("id")>() = sensorInfo.getID();
83
84
85 const auto& clusters = spacePoint->getRelationsTo<SVDCluster>();
86 B2ASSERT("Must be related to exactly 2 clusters", clusters.size() == 2);
87 const SVDCluster* firstCluster = clusters[0];
88 const SVDCluster* secondCluster = clusters[1];
89 var<named("cluster_1_time")>() = firstCluster->getClsTime();
90 var<named("cluster_2_time")>() = secondCluster->getClsTime();
91
92 var<named("last_layer")>() = 0;
93 var<named("last_ladder")>() = 0;
94 var<named("last_sensor")>() = 0;
95 var<named("last_segment")>() = 0;
96 var<named("last_id")>() = 0;
97 var<named("last_cluster_1_time")>() = -999.9;
98 var<named("last_cluster_2_time")>() = -999.9;
99
100 const CKFToSVDState* parent = previousStates.back();
101 const SpacePoint* parentSpacePoint = parent->getHit();
102 if (parentSpacePoint) {
103 const VxdID& parentSensorInfo = parentSpacePoint->getVxdID();
104
105 var<named("last_layer")>() = parentSensorInfo.getLayerNumber();
106 var<named("last_ladder")>() = parentSensorInfo.getLadderNumber();
107 var<named("last_sensor")>() = parentSensorInfo.getSensorNumber();
108 var<named("last_segment")>() = parentSensorInfo.getSegmentNumber();
109 var<named("last_id")>() = parentSensorInfo.getID();
110
111 const auto& parentclusters = parentSpacePoint->getRelationsTo<SVDCluster>();
112 B2ASSERT("Must be related to exactly 2 clusters", parentclusters.size() == 2);
113 const SVDCluster* parentfirstCluster = parentclusters[0];
114 const SVDCluster* parentsecondCluster = parentclusters[1];
115 var<named("last_cluster_1_time")>() = parentfirstCluster->getClsTime();
116 var<named("last_cluster_2_time")>() = parentsecondCluster->getClsTime();
117 }
118
119 const double residual = m_kalmanStepper.calculateResidual(firstMeasurement, *state);
120 var<named("residual")>() = residual;
121
122 if (state->isFitted()) {
123 var<named("chi2")>() = static_cast<Float_t>(state->getChi2());
124 } else {
125 var<named("chi2")>() = -999;
126 }
127
128 const TMatrixDSym& cov5 = firstMeasurement.getCov();
129 const Float_t sigmaUV = std::sqrt(std::max(cov5(4, 4), cov5(3, 3)));
130 var<named("sigma_uv")>() = sigmaUV;
131 var<named("residual_over_sigma")>() = residual / sigmaUV;
132
133 return true;
134}
const genfit::MeasuredStateOnPlane & getMeasuredStateOnPlane() const
Get the mSoP if already set during extrapolation (or fitting)
Definition CKFState.h:93
const Hit * getHit() const
Return the SP this state is related to. May be nullptr.
Definition CKFState.h:66
double getChi2() const
Return the chi2 set during fitting. Is only valid after fitting.
Definition CKFState.h:72
bool isFitted() const
Check if state was already fitted.
Definition CKFState.h:100
bool mSoPSet() const
Is the mSoP already set? (= state was already extrapolated)
Definition CKFState.h:106
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
ROOT::Math::XYVector getPos2DAtArcLength2D(double arcLength2D)
Getter for the position at a given two dimensional arc length.
Particle full three dimensional 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 calcArcLength2D(const ROOT::Math::XYZVector &point) const
Calculate the travel distance from the start position of the trajectory.
double mapSToZ(const double s=0) const
Translates the travel distance to the z coordinate.
std::pair< const std::vector< TrackingUtilities::WithWeight< const CKFToSVDState * > >, CKFToSVDState * > Object
Definition Filter.dcl.h:35
static constexpr int named(const char *name)
Definition VarSet.h:78
Class to uniquely identify a any structure of the PXD and SVD.
Definition VxdID.h:32
baseType getID() const
Get the unique id.
Definition VxdID.h:93
baseType getSensorNumber() const
Get the sensor id.
Definition VxdID.h:99
baseType getSegmentNumber() const
Get the sensor segment.
Definition VxdID.h:101
baseType getLadderNumber() const
Get the ladder id.
Definition VxdID.h:97
baseType getLayerNumber() const
Get the layer id.
Definition VxdID.h:95
Abstract base class for different kinds of events.