Belle II Software development
PXDStateBasicVarSet.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/pxd/filters/states/PXDStateBasicVarSet.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 <pxd/dataobjects/PXDCluster.h>
19
20#include <Math/Vector3D.h>
21#include <Math/Vector2D.h>
22
23using namespace Belle2;
24using namespace TrackingUtilities;
25
27{
28 const std::vector<TrackingUtilities::WithWeight<const CKFToPXDState*>>& previousStates = pair->first;
29 CKFToPXDState* state = pair->second;
30
31 const RecoTrack* seedTrack = previousStates.front()->getSeed();
32 B2ASSERT("Path without seed?", seedTrack);
33
34 const SpacePoint* spacePoint = state->getHit();
35 B2ASSERT("Path without hit?", spacePoint);
36
37 genfit::MeasuredStateOnPlane firstMeasurement;
38 if (state->mSoPSet()) {
39 firstMeasurement = state->getMeasuredStateOnPlane();
40 } else {
41 firstMeasurement = previousStates.back()->getMeasuredStateOnPlane();
42 }
43
44 ROOT::Math::XYZVector position = ROOT::Math::XYZVector(firstMeasurement.getPos());
45 ROOT::Math::XYZVector momentum = ROOT::Math::XYZVector(firstMeasurement.getMom());
46
47 const CDCTrajectory3D trajectory(position, 0, momentum, seedTrack->getChargeSeed());
48
49 const ROOT::Math::XYZVector& hitPosition = spacePoint->getPosition();
50
51 const double arcLength = trajectory.calcArcLength2D(hitPosition);
52 const ROOT::Math::XYVector& trackPositionAtHit2D = trajectory.getTrajectory2D().getPos2DAtArcLength2D(arcLength);
53 double trackPositionAtHitZ = trajectory.getTrajectorySZ().mapSToZ(arcLength);
54
55 ROOT::Math::XYZVector trackPositionAtHit(trackPositionAtHit2D.X(), trackPositionAtHit2D.Y(), trackPositionAtHitZ);
56 ROOT::Math::XYZVector distance = trackPositionAtHit - hitPosition;
57
58 var<named("distance")>() = static_cast<Float_t>(distance.R());
59 var<named("xy_distance")>() = static_cast<Float_t>(distance.Rho());
60 var<named("z_distance")>() = static_cast<Float_t>(distance.z());
61
62 ROOT::Math::XYZVector mSoP_distance = position - hitPosition;
63
64 var<named("mSoP_distance")>() = static_cast<Float_t>(mSoP_distance.R());
65 var<named("mSoP_xy_distance")>() = static_cast<Float_t>(mSoP_distance.Rho());
66 var<named("mSoP_z_distance")>() = static_cast<Float_t>(mSoP_distance.z());
67
68 var<named("same_hemisphere")>() = fabs(position.Phi() - hitPosition.Phi()) < TMath::PiOver2();
69
70 var<named("arcLengthOfHitPosition")>() = static_cast<Float_t>(trajectory.calcArcLength2D(hitPosition));
71 var<named("arcLengthOfCenterPosition")>() = static_cast<Float_t>(trajectory.calcArcLength2D(ROOT::Math::XYZVector(0, 0, 0)));
72
73 var<named("layer")>() = spacePoint->getVxdID().getLayerNumber();
74 var<named("number")>() = previousStates.size();
75
76 var<named("pt")>() = static_cast<Float_t>(momentum.Rho());
77 var<named("tan_lambda")>() = static_cast<Float_t>(trajectory.getTanLambda());
78 var<named("phi")>() = static_cast<Float_t>(momentum.Phi());
79
80 const VxdID& sensorInfo = spacePoint->getVxdID();
81
82 var<named("ladder")>() = sensorInfo.getLadderNumber();
83 var<named("sensor")>() = sensorInfo.getSensorNumber();
84 var<named("segment")>() = sensorInfo.getSegmentNumber();
85 var<named("id")>() = sensorInfo.getID();
86
87 const auto& clusters = spacePoint->getRelationsTo<PXDCluster>();
88 B2ASSERT("Must be related to exactly 1 cluster", clusters.size() == 1);
89 var<named("cluster_charge")>() = clusters[0]->getCharge();
90 var<named("cluster_seed_charge")>() = clusters[0]->getSeedCharge();
91 var<named("cluster_size")>() = clusters[0]->getSize();
92 var<named("cluster_size_u")>() = clusters[0]->getUSize();
93 var<named("cluster_size_v")>() = clusters[0]->getVSize();
94
95 var<named("last_layer")>() = 0;
96 var<named("last_ladder")>() = 0;
97 var<named("last_sensor")>() = 0;
98 var<named("last_segment")>() = 0;
99 var<named("last_id")>() = 0;
100 var<named("last_cluster_charge")>() = 0;
101 var<named("last_cluster_seed_charge")>() = 0;
102 var<named("last_cluster_size")>() = 0;
103 var<named("last_cluster_size_u")>() = 0;
104 var<named("last_cluster_size_v")>() = 0;
105
106 const CKFToPXDState* parent = previousStates.back();
107 const SpacePoint* parentSpacePoint = parent->getHit();
108 if (parentSpacePoint) {
109 const VxdID& parentSensorInfo = parentSpacePoint->getVxdID();
110
111 var<named("last_layer")>() = parentSensorInfo.getLayerNumber();
112 var<named("last_ladder")>() = parentSensorInfo.getLadderNumber();
113 var<named("last_sensor")>() = parentSensorInfo.getSensorNumber();
114 var<named("last_segment")>() = parentSensorInfo.getSegmentNumber();
115 var<named("last_id")>() = parentSensorInfo.getID();
116
117 const auto& parentclusters = parentSpacePoint->getRelationsTo<PXDCluster>();
118 B2ASSERT("Must be related to exactly 1 cluster", parentclusters.size() == 1);
119 var<named("last_cluster_charge")>() = parentclusters[0]->getCharge();
120 var<named("last_cluster_seed_charge")>() = parentclusters[0]->getSeedCharge();
121 var<named("last_cluster_size")>() = parentclusters[0]->getSize();
122 var<named("last_cluster_size_u")>() = parentclusters[0]->getUSize();
123 var<named("last_cluster_size_v")>() = parentclusters[0]->getVSize();
124 }
125
126 const double residual = m_kalmanStepper.calculateResidual(firstMeasurement, *state);
127 var<named("residual")>() = residual;
128
129 if (state->isFitted()) {
130 var<named("chi2")>() = static_cast<Float_t>(state->getChi2());
131 } else {
132 var<named("chi2")>() = -999;
133 }
134
135 const TMatrixDSym& cov5 = firstMeasurement.getCov();
136 const Float_t sigmaUV = std::sqrt(std::max(cov5(4, 4), cov5(3, 3)));
137 var<named("sigma_uv")>() = sigmaUV;
138 var<named("residual_over_sigma")>() = residual / sigmaUV;
139
140 return true;
141}
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 PXD.
The PXD Cluster class This class stores all information about reconstructed PXD clusters The position...
Definition PXDCluster.h:30
virtual bool extract(const BasePXDStateFilter::Object *pair) override
Generate and assign the variables from the VXD-CDC-pair.
PXDKalmanStepper m_kalmanStepper
Kalmap update filter used in this var set.
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.
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 CKFToPXDState * > >, CKFToPXDState * > 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.