Belle II Software development
FlipRecoTrackExtractor.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 <mdst/dataobjects/HitPatternCDC.h>
19#include <framework/gearbox/Const.h>
20
21namespace Belle2 {
28 public:
29
31 explicit FlipRecoTrackExtractor(std::vector<Named<float*>>& variableSet, const std::string& prefix = ""):
33 {
35 addVariable(prefix + "seed_pz_estimate", variableSet);
36 addVariable(prefix + "seed_pz_variance", variableSet);
37 addVariable(prefix + "seed_z_estimate", variableSet);
38 addVariable(prefix + "seed_tan_lambda_estimate", variableSet);
39 addVariable(prefix + "seed_pt_estimate", variableSet);
40 addVariable(prefix + "seed_x_estimate", variableSet);
41 addVariable(prefix + "seed_y_estimate", variableSet);
42 addVariable(prefix + "seed_py_variance", variableSet);
43 addVariable(prefix + "seed_d0_estimate", variableSet);
44 addVariable(prefix + "seed_omega_variance", variableSet);
45 addVariable(prefix + "svd_layer6_clsTime", variableSet);
46 addVariable(prefix + "seed_tan_lambda_variance", variableSet);
47 addVariable(prefix + "seed_z_variance", variableSet);
48 addVariable(prefix + "n_svd_hits", variableSet);
49 addVariable(prefix + "n_cdc_hits", variableSet);
50 addVariable(prefix + "svd_layer3_positionSigma", variableSet);
51 addVariable(prefix + "first_cdc_layer", variableSet);
52 addVariable(prefix + "last_cdc_layer", variableSet);
53 addVariable(prefix + "InOutArmTimeDifference", variableSet);
54 addVariable(prefix + "InOutArmTimeDifferenceError", variableSet);
55 addVariable(prefix + "inGoingArmTime", variableSet);
56 addVariable(prefix + "inGoingArmTimeError", variableSet);
57 addVariable(prefix + "outGoingArmTime", variableSet);
58 addVariable(prefix + "outGoingArmTimeError", variableSet);
59
60 }
61
63 void extractVariables(RecoTrack& recoTrack)
64 {
65 // Set all values to NaN to make sure that no values from previous recoTrack are used accidentally
67
68 const auto& cdcHitList = recoTrack.getSortedCDCHitList();
69 const RecoTrack* svdcdcRecoTrack = recoTrack.getRelated<RecoTrack>("SVDCDCRecoTracks");
70 // In case the CDC hit list is empty, or there is no svdcdcRecoTrack, set arbitrary default value and return
71 if (not svdcdcRecoTrack) {
72 return;
73 }
74
75 m_variables.at(m_prefix + "InOutArmTimeDifference") = static_cast<float>(recoTrack.getInOutArmTimeDifference());
76 m_variables.at(m_prefix + "InOutArmTimeDifferenceError") = static_cast<float>(recoTrack.getInOutArmTimeDifferenceError());
77 m_variables.at(m_prefix + "inGoingArmTime") = static_cast<float>(recoTrack.getIngoingArmTime());
78 m_variables.at(m_prefix + "inGoingArmTimeError") = static_cast<float>(recoTrack.getIngoingArmTimeError());
79 m_variables.at(m_prefix + "outGoingArmTime") = static_cast<float>(recoTrack.getOutgoingArmTime());
80 m_variables.at(m_prefix + "outGoingArmTimeError") = static_cast<float>(recoTrack.getOutgoingArmTimeError());
81
82 if (cdcHitList.size() > 0) {
83 m_variables.at(m_prefix + "first_cdc_layer") = static_cast<float>(cdcHitList.front()->getICLayer());
84 m_variables.at(m_prefix + "last_cdc_layer") = static_cast<float>(cdcHitList.back()->getICLayer());
85 }
86
87 m_variables.at(m_prefix + "n_svd_hits") = static_cast<float>(recoTrack.getNumberOfSVDHits());
88 m_variables.at(m_prefix + "n_cdc_hits") = static_cast<float>(recoTrack.getNumberOfCDCHits());
89
90 const auto& svdcdcRecoTrackCovariance = svdcdcRecoTrack->getSeedCovariance();
91 const auto& svdcdcRecoTrackMomentum = svdcdcRecoTrack->getMomentumSeed();
92 const auto& svdcdcRecoTrackPosition = svdcdcRecoTrack->getPositionSeed();
93 const float svdcdcRecoTrackChargeSign = svdcdcRecoTrack->getChargeSeed() > 0 ? 1.0f : -1.0f;
94 const float bFieldValue = static_cast<float>(BFieldManager::getFieldInTesla(svdcdcRecoTrackPosition).Z());
95 const uint16_t svdcdcNDF = 0xffff;
96 const auto& svdcdcFitResult = TrackFitResult(svdcdcRecoTrackPosition, svdcdcRecoTrackMomentum, svdcdcRecoTrackCovariance,
97 svdcdcRecoTrackChargeSign, Const::pion, 0, bFieldValue, 0, 0,
98 svdcdcNDF);
99
100 m_variables.at(m_prefix + "seed_pz_variance") = static_cast<float>(svdcdcRecoTrackCovariance(5, 5));
101 m_variables.at(m_prefix + "seed_pz_estimate") = static_cast<float>(svdcdcRecoTrackMomentum.Z());
102 m_variables.at(m_prefix + "seed_z_estimate") = static_cast<float>(svdcdcRecoTrackPosition.Z());
103 m_variables.at(m_prefix + "seed_tan_lambda_estimate") = static_cast<float>(svdcdcFitResult.getCotTheta());
104
105 m_variables.at(m_prefix + "seed_pt_estimate") = static_cast<float>(svdcdcRecoTrackMomentum.Rho());
106 m_variables.at(m_prefix + "seed_x_estimate") = static_cast<float>(svdcdcRecoTrackPosition.X());
107 m_variables.at(m_prefix + "seed_y_estimate") = static_cast<float>(svdcdcRecoTrackPosition.Y());
108 m_variables.at(m_prefix + "seed_py_variance") = static_cast<float>(svdcdcRecoTrackCovariance(4, 4));
109 m_variables.at(m_prefix + "seed_d0_estimate") = static_cast<float>(svdcdcFitResult.getD0());
110 m_variables.at(m_prefix + "seed_omega_variance") = static_cast<float>(svdcdcFitResult.getCov()[9]);
111 m_variables.at(m_prefix + "seed_tan_lambda_variance") = static_cast<float>(svdcdcFitResult.getCov()[14]);
112 m_variables.at(m_prefix + "seed_z_variance") = static_cast<float>(svdcdcRecoTrackCovariance(2, 2));
113
114 for (const auto* svdHit : recoTrack.getSVDHitList()) {
115 if (svdHit->getSensorID().getLayerNumber() == 3) {
116 m_variables.at(m_prefix + "svd_layer3_positionSigma") = static_cast<float>(svdHit->getPositionSigma());
117 }
118 if (svdHit->getSensorID().getLayerNumber() == 6) {
119 m_variables.at(m_prefix + "svd_layer6_clsTime") = static_cast<float>(svdHit->getClsTime());
120 }
121 }
122 }
123
124
125 protected:
127 std::string m_prefix;
128 private:
131 {
132 m_variables.at(m_prefix + "InOutArmTimeDifference") = Const::floatNaN;
133 m_variables.at(m_prefix + "InOutArmTimeDifferenceError") = Const::floatNaN;
134 m_variables.at(m_prefix + "inGoingArmTime") = Const::floatNaN;
135 m_variables.at(m_prefix + "inGoingArmTimeError") = Const::floatNaN;
136 m_variables.at(m_prefix + "outGoingArmTime") = Const::floatNaN;
137 m_variables.at(m_prefix + "outGoingArmTimeError") = Const::floatNaN;
138 m_variables.at(m_prefix + "first_cdc_layer") = Const::floatNaN;
139 m_variables.at(m_prefix + "last_cdc_layer") = Const::floatNaN;
140 m_variables.at(m_prefix + "n_svd_hits") = Const::floatNaN;
141 m_variables.at(m_prefix + "n_cdc_hits") = Const::floatNaN;
142 m_variables.at(m_prefix + "seed_pz_variance") = Const::floatNaN;
143 m_variables.at(m_prefix + "seed_pz_estimate") = Const::floatNaN;
144 m_variables.at(m_prefix + "seed_z_estimate") = Const::floatNaN;
145 m_variables.at(m_prefix + "seed_tan_lambda_estimate") = Const::floatNaN;
146 m_variables.at(m_prefix + "seed_pt_estimate") = Const::floatNaN;
147 m_variables.at(m_prefix + "seed_x_estimate") = Const::floatNaN;
148 m_variables.at(m_prefix + "seed_y_estimate") = Const::floatNaN;
149 m_variables.at(m_prefix + "seed_py_variance") = Const::floatNaN;
150 m_variables.at(m_prefix + "seed_d0_estimate") = Const::floatNaN;
151 m_variables.at(m_prefix + "seed_omega_variance") = Const::floatNaN;
152 m_variables.at(m_prefix + "seed_tan_lambda_variance") = Const::floatNaN;
153 m_variables.at(m_prefix + "seed_z_variance") = Const::floatNaN;
154 m_variables.at(m_prefix + "svd_layer3_positionSigma") = Const::floatNaN;
155 m_variables.at(m_prefix + "svd_layer6_clsTime") = Const::floatNaN;
156 }
157 };
158
160}
static ROOT::Math::XYZVector getFieldInTesla(const ROOT::Math::XYZVector &pos)
return the magnetic field at a given position in Tesla.
Definition: BFieldManager.h:61
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.
void extractVariables(RecoTrack &recoTrack)
extract the actual variables and write into a variable set
FlipRecoTrackExtractor(std::vector< Named< float * > > &variableSet, const std::string &prefix="")
Define names of variables that get extracted.
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
const TMatrixDSym & getSeedCovariance() const
Return the covariance matrix of the seed. ATTENTION: This is not the fitted covariance.
Definition: RecoTrack.h:611
float getInOutArmTimeDifference()
Return the difference between the track times of the ingoing and outgoing arms.
Definition: RecoTrack.h:542
float getOutgoingArmTime()
Return the track time of the outgoing arm.
Definition: RecoTrack.h:514
std::vector< Belle2::RecoTrack::UsedSVDHit * > getSVDHitList() const
Return an unsorted list of svd hits.
Definition: RecoTrack.h:452
std::vector< Belle2::RecoTrack::UsedCDCHit * > getSortedCDCHitList() const
Return a sorted list of cdc hits. Sorted by the sortingParameter.
Definition: RecoTrack.h:470
ROOT::Math::XYZVector getPositionSeed() const
Return the position seed stored in the reco track. ATTENTION: This is not the fitted position.
Definition: RecoTrack.h:480
unsigned int getNumberOfSVDHits() const
Return the number of svd hits.
Definition: RecoTrack.h:424
unsigned int getNumberOfCDCHits() const
Return the number of cdc hits.
Definition: RecoTrack.h:427
float getIngoingArmTimeError()
Return the error of the track time of the ingoing arm.
Definition: RecoTrack.h:535
float getOutgoingArmTimeError()
Return the error of the track time of the outgoing arm.
Definition: RecoTrack.h:521
float getIngoingArmTime()
Return the track time of the ingoing arm.
Definition: RecoTrack.h:528
float getInOutArmTimeDifferenceError()
Return the error of the difference between the track times of the ingoing and outgoing arms.
Definition: RecoTrack.h:549
short int getChargeSeed() const
Return the charge seed stored in the reco track. ATTENTION: This is not the fitted charge.
Definition: RecoTrack.h:508
ROOT::Math::XYZVector getMomentumSeed() const
Return the momentum seed stored in the reco track. ATTENTION: This is not the fitted momentum.
Definition: RecoTrack.h:487
T * getRelated(const std::string &name="", const std::string &namedRelation="") const
Get the object to or from which this object has a relation.
Values of the result of a track fit with a given particle hypothesis.
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.