Belle II Software development
Flip2ndRecoTrackExtractor.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
9#pragma once
10
11#include <tracking/trackFindingVXD/variableExtractors/VariableExtractor.h>
12#include <tracking/dataobjects/RecoTrack.h>
13#include <tracking/dataobjects/RecoHitInformation.h>
14
15#include <genfit/FitStatus.h>
16#include <mdst/dataobjects/Track.h>
17#include <mdst/dataobjects/MCParticle.h>
18#include <framework/gearbox/Const.h>
19
20namespace Belle2 {
27 public:
28
30 explicit FlipRecoTrackExtractor2nd(std::vector<Named<float*>>& variableSet, const std::string& prefix = ""):
32 {
33 addVariable(prefix + "flipped_pz_estimate", variableSet);
34 addVariable(prefix + "tan_lambda_estimate", variableSet);
35 addVariable(prefix + "d0_variance", variableSet);
36 addVariable(prefix + "z_estimate", variableSet);
37 addVariable(prefix + "px_variance", variableSet);
38 addVariable(prefix + "p_value", variableSet);
39 addVariable(prefix + "pt_estimate", variableSet);
40 addVariable(prefix + "y_estimate", variableSet);
41 addVariable(prefix + "d0_estimate", variableSet);
42 addVariable(prefix + "x_estimate", variableSet);
43 addVariable(prefix + "pz_variance", variableSet);
44 addVariable(prefix + "omega_estimate", variableSet);
45 addVariable(prefix + "px_estimate", variableSet);
46 addVariable(prefix + "flipped_z_estimate", variableSet);
47 addVariable(prefix + "py_estimate", variableSet);
48 addVariable(prefix + "outGoingArmTime", variableSet);
49 addVariable(prefix + "quality_flip_indicator", variableSet);
50 addVariable(prefix + "inGoingArmTime", variableSet);
51 }
53 void extractVariables(RecoTrack& recoTrack)
54 {
55 // Set all values to NaN to make sure that no values from previous recoTrack are used accidentally
57
58 const Track* track = recoTrack.getRelated<Track>("Tracks");
59 const RecoTrack* flippedRecoTrack = recoTrack.getRelatedFrom<RecoTrack>("RecoTracks_flipped");
60 if (not track or not flippedRecoTrack) {
61 // Don't have track or flippedRecoTrack -> return
62 return;
63 }
64 const Track* flippedTrack = flippedRecoTrack->getRelatedFrom<Track>("Tracks_flipped");
65 if (not flippedTrack) {
66 // Don't have flippedTrack -> return
67 return;
68 }
69 const TrackFitResult* trackFitResult = track->getTrackFitResultWithClosestMass(Const::pion);
70 const TrackFitResult* flippedTrackFitResult =
71 flippedTrack->getTrackFitResultWithClosestMassByName(Const::pion, "TrackFitResults_flipped");
72 if (not trackFitResult or not flippedTrackFitResult) {
73 // Don't have trackFitResult or flippedTrackFitResult -> return
74 return;
75 }
76
77 const auto& unflippedCovariance = trackFitResult->getCovariance6();
78 const auto& unflippedMomentum = trackFitResult->getMomentum();
79 const auto& unflippedPosition = trackFitResult->getPosition();
80
81 const auto& flippedMomentum = flippedTrackFitResult->getMomentum();
82 const auto& flippedPosition = flippedTrackFitResult->getPosition();
83
84 m_variables.at(m_prefix + "flipped_pz_estimate") = static_cast<float>(flippedMomentum.Z());
85 m_variables.at(m_prefix + "tan_lambda_estimate") = static_cast<float>(trackFitResult->getCotTheta());
86 m_variables.at(m_prefix + "d0_variance") = static_cast<float>(trackFitResult->getCov()[0]);
87 m_variables.at(m_prefix + "z_estimate") = static_cast<float>(unflippedPosition.Z());
88 m_variables.at(m_prefix + "px_variance") = static_cast<float>(unflippedCovariance(3, 3));
89 m_variables.at(m_prefix + "p_value") = static_cast<float>(trackFitResult->getPValue());
90 m_variables.at(m_prefix + "pt_estimate") = static_cast<float>(unflippedMomentum.Rho());
91 m_variables.at(m_prefix + "y_estimate") = static_cast<float>(unflippedPosition.Y());
92 m_variables.at(m_prefix + "d0_estimate") = static_cast<float>(trackFitResult->getD0());
93 m_variables.at(m_prefix + "x_estimate") = static_cast<float>(unflippedPosition.X());
94 m_variables.at(m_prefix + "pz_variance") = static_cast<float>(unflippedCovariance(5, 5));
95 m_variables.at(m_prefix + "omega_estimate") = static_cast<float>(trackFitResult->getOmega());
96 m_variables.at(m_prefix + "quality_flip_indicator") = static_cast<float>(recoTrack.getFlipQualityIndicator());
97 m_variables.at(m_prefix + "px_estimate") = static_cast<float>(unflippedMomentum.X());
98 m_variables.at(m_prefix + "flipped_z_estimate") = static_cast<float>(flippedPosition.Z());
99 m_variables.at(m_prefix + "py_estimate") = static_cast<float>(unflippedMomentum.Y());
100 m_variables.at(m_prefix + "inGoingArmTime") = static_cast<float>(recoTrack.getIngoingArmTime());
101 m_variables.at(m_prefix + "outGoingArmTime") = static_cast<float>(recoTrack.getOutgoingArmTime());
102 }
103
104 protected:
106 std::string m_prefix;
107 private:
110 {
111 m_variables.at(m_prefix + "flipped_pz_estimate") = Const::floatNaN;
112 m_variables.at(m_prefix + "tan_lambda_estimate") = Const::floatNaN;
113 m_variables.at(m_prefix + "d0_variance") = Const::floatNaN;
114 m_variables.at(m_prefix + "z_estimate") = Const::floatNaN;
115 m_variables.at(m_prefix + "px_variance") = Const::floatNaN;
116 m_variables.at(m_prefix + "p_value") = Const::floatNaN;
117 m_variables.at(m_prefix + "pt_estimate") = Const::floatNaN;
118 m_variables.at(m_prefix + "y_estimate") = Const::floatNaN;
119 m_variables.at(m_prefix + "d0_estimate") = Const::floatNaN;
120 m_variables.at(m_prefix + "x_estimate") = Const::floatNaN;
121 m_variables.at(m_prefix + "pz_variance") = Const::floatNaN;
122 m_variables.at(m_prefix + "omega_estimate") = Const::floatNaN;
123 m_variables.at(m_prefix + "px_estimate") = Const::floatNaN;
124 m_variables.at(m_prefix + "flipped_z_estimate") = Const::floatNaN;
125 m_variables.at(m_prefix + "py_estimate") = Const::floatNaN;
126 m_variables.at(m_prefix + "outGoingArmTime") = Const::floatNaN;
127 m_variables.at(m_prefix + "quality_flip_indicator") = Const::floatNaN;
128 m_variables.at(m_prefix + "inGoingArmTime") = Const::floatNaN;
129 }
130 };
132}
static const float floatNaN
quiet_NaN
Definition: Const.h:704
static const ChargedStable pion
charged pion particle
Definition: Const.h:661
class to extract results from qualityEstimation
std::string m_prefix
prefix for RecoTrack extracted variables
void setDefaultValues()
Set all variables to default error value.
FlipRecoTrackExtractor2nd(std::vector< Named< float * > > &variableSet, const std::string &prefix="")
Define names of variables that get extracted.
void extractVariables(RecoTrack &recoTrack)
extract the actual variables and write into a variable set
A mixin class to attach a name to an object. Based on class with same name in CDC package.
Definition: Named.h:21
This is the Reconstruction Event-Data Model Track.
Definition: RecoTrack.h:79
float getOutgoingArmTime()
Return the track time of the outgoing arm.
Definition: RecoTrack.h:514
float getIngoingArmTime()
Return the track time of the ingoing arm.
Definition: RecoTrack.h:528
float getFlipQualityIndicator() const
Get the 1st flipping quality attached to this RecoTrack as a reference for flipping.
Definition: RecoTrack.h:853
T * getRelated(const std::string &name="", const std::string &namedRelation="") const
Get the object to or from which this object has a relation.
FROM * getRelatedFrom(const std::string &name="", const std::string &namedRelation="") const
Get the object from which this object has a relation.
Values of the result of a track fit with a given particle hypothesis.
double getPValue() const
Getter for Chi2 Probability of the track fit.
TMatrixDSym getCovariance6() const
Position and Momentum Covariance Matrix.
double getCotTheta() const
Getter for tanLambda with CDF naming convention.
double getOmega() const
Getter for omega.
std::vector< float > getCov() const
Getter for all covariance matrix elements of perigee parameters.
double getD0() const
Getter for d0.
ROOT::Math::XYZVector getMomentum() const
Getter for vector of momentum at closest approach of track in r/phi projection.
ROOT::Math::XYZVector getPosition() const
Getter for vector of position at closest approach of track in r/phi projection.
Class that bundles various TrackFitResults.
Definition: Track.h:25
const TrackFitResult * getTrackFitResultWithClosestMassByName(const Const::ChargedStable &requestedType, const std::string trackFitResultsName) const
Return the track fit (from TrackFitResult with specified name) for a fit hypothesis with the closest ...
Definition: Track.cc:80
class to extract individual variables
void addVariable(const std::string &identifier, std::vector< Named< float * > > &variables)
add a variable to the variable set
std::unordered_map< std::string, float > m_variables
unordered_map to associate float value with a string name
Abstract base class for different kinds of events.