Belle II Software development
RecoTrackExtractor Class Reference

class to extract results from qualityEstimation More...

#include <RecoTrackExtractor.h>

Inheritance diagram for RecoTrackExtractor:
VariableExtractor

Public Member Functions

 RecoTrackExtractor (std::vector< Named< float * > > &variableSet, const std::string &prefix="")
 Define names of variables that get extracted.
 
void extractVariables (const RecoTrack &recoTrack)
 extract the actual variables and write into a variable set
 

Protected Member Functions

void addVariable (const std::string &identifier, std::vector< Named< float * > > &variables)
 add a variable to the variable set
 

Protected Attributes

std::string m_prefix
 prefix for RecoTrack extracted variables
 
std::unordered_map< std::string, float > m_variables
 unordered_map to associate float value with a string name
 

Detailed Description

class to extract results from qualityEstimation

Definition at line 28 of file RecoTrackExtractor.h.

Constructor & Destructor Documentation

◆ RecoTrackExtractor()

RecoTrackExtractor ( std::vector< Named< float * > > &  variableSet,
const std::string &  prefix = "" 
)
inlineexplicit

Define names of variables that get extracted.

Definition at line 32 of file RecoTrackExtractor.h.

32 :
33 VariableExtractor(), m_prefix(prefix)
34 {
35 addVariable(prefix + "pdg_ID", variableSet);
36 addVariable(prefix + "pdg_ID_Mother", variableSet);
37 addVariable(prefix + "is_Vzero_Daughter", variableSet);
38 addVariable(prefix + "is_Primary", variableSet);
39
40 addVariable(prefix + "z0", variableSet);
41 addVariable(prefix + "d0", variableSet);
42
43 addVariable(prefix + "seed_Charge", variableSet);
44
45 addVariable(prefix + "seed_Pos_Pt", variableSet);
46 addVariable(prefix + "seed_Pos_Z", variableSet);
47 addVariable(prefix + "seed_Pos_Mag", variableSet);
48 addVariable(prefix + "seed_Pos_Theta", variableSet);
49 addVariable(prefix + "seed_Pos_Phi", variableSet);
50
51 addVariable(prefix + "seed_Mom_Pt", variableSet);
52 addVariable(prefix + "seed_Mom_Z", variableSet);
53 addVariable(prefix + "seed_Mom_Mag", variableSet);
54 addVariable(prefix + "seed_Mom_Theta", variableSet);
55 addVariable(prefix + "seed_Mom_Phi", variableSet);
56
57 addVariable(prefix + "seed_Time", variableSet);
58
59 addVariable(prefix + "N_tracking_hits", variableSet);
60 addVariable(prefix + "N_CDC_hits", variableSet);
61 addVariable(prefix + "N_SVD_hits", variableSet);
62 addVariable(prefix + "N_PXD_hits", variableSet);
63
64 addVariable(prefix + "Fit_Charge", variableSet);
65 addVariable(prefix + "Fit_Chi2", variableSet);
66 addVariable(prefix + "Fit_Ndf", variableSet);
67 addVariable(prefix + "Fit_NFailedPoints", variableSet);
68 addVariable(prefix + "Fit_PVal", variableSet);
69 addVariable(prefix + "Fit_Successful", variableSet);
70
71 addVariable(prefix + "POCA_Pos_Pt", variableSet);
72 addVariable(prefix + "POCA_Pos_Z", variableSet);
73 addVariable(prefix + "POCA_Pos_Mag", variableSet);
74 addVariable(prefix + "POCA_Pos_Theta", variableSet);
75 addVariable(prefix + "POCA_Pos_Phi", variableSet);
76
77 addVariable(prefix + "POCA_Mom_Pt", variableSet);
78 addVariable(prefix + "POCA_Mom_Z", variableSet);
79 addVariable(prefix + "POCA_Mom_Mag", variableSet);
80 addVariable(prefix + "POCA_Mom_Theta", variableSet);
81 addVariable(prefix + "POCA_Mom_Phi", variableSet);
82 }
std::string m_prefix
prefix for RecoTrack extracted variables
void addVariable(const std::string &identifier, std::vector< Named< float * > > &variables)
add a variable to the variable set

Member Function Documentation

◆ addVariable()

void addVariable ( const std::string &  identifier,
std::vector< Named< float * > > &  variables 
)
inlineprotectedinherited

add a variable to the variable set

Definition at line 27 of file VariableExtractor.h.

28 {
29 //todo: verify if it is faster to check explicitly or not
30 auto value = m_variables.emplace(identifier, NAN).first;
31 variables.emplace_back(identifier, &(value->second));
32 }
std::unordered_map< std::string, float > m_variables
unordered_map to associate float value with a string name

◆ extractVariables()

void extractVariables ( const RecoTrack recoTrack)
inline

extract the actual variables and write into a variable set

Definition at line 85 of file RecoTrackExtractor.h.

86 {
87 float pdgID = 0;
88 float pdgIDMother = 0;
89 float isVzeroDaughter = -1;
90 float isPrimary = -1;
91 auto mcparticle = recoTrack.getRelated<MCParticle>();
92 if (mcparticle) {
93 pdgID = static_cast<float>(mcparticle->getPDG());
94 pdgIDMother = static_cast<float>(mcparticle->getMother()->getPDG());
95 isPrimary = static_cast<float>(mcparticle->isPrimaryParticle());
96 if (abs(pdgIDMother) == 310 || abs(pdgIDMother) == 3122) {
97 isVzeroDaughter = 1;
98 } else {
99 isVzeroDaughter = 0;
100 }
101 }
102 float z0 = -999;
103 float d0 = -999;
104 auto genfitTrack = recoTrack.getRelated<Track>("MDSTTracks");
105 if (genfitTrack) {
106 auto trackFitResult = genfitTrack->getTrackFitResultWithClosestMass(Const::pion);
107 if (trackFitResult) {
108 z0 = trackFitResult->getZ0();
109 d0 = trackFitResult->getD0();
110 }
111 }
112 m_variables.at(m_prefix + "pdg_ID") = pdgID;
113 m_variables.at(m_prefix + "pdg_ID_Mother") = pdgIDMother;
114 m_variables.at(m_prefix + "is_Vzero_Daughter") = isVzeroDaughter;
115 m_variables.at(m_prefix + "is_Primary") = isPrimary;
116
117 m_variables.at(m_prefix + "z0") = z0;
118 m_variables.at(m_prefix + "d0") = d0;
119
120 m_variables.at(m_prefix + "seed_Charge") = recoTrack.getChargeSeed();
121
122 m_variables.at(m_prefix + "seed_Pos_Pt") = recoTrack.getPositionSeed().Rho();
123 m_variables.at(m_prefix + "seed_Pos_Z") = recoTrack.getPositionSeed().Z();
124 m_variables.at(m_prefix + "seed_Pos_Mag") = recoTrack.getPositionSeed().R();
125 m_variables.at(m_prefix + "seed_Pos_Theta") = recoTrack.getPositionSeed().Theta();
126 m_variables.at(m_prefix + "seed_Pos_Phi") = recoTrack.getPositionSeed().Phi();
127
128 m_variables.at(m_prefix + "seed_Mom_Pt") = recoTrack.getMomentumSeed().Rho();
129 m_variables.at(m_prefix + "seed_Mom_Z") = recoTrack.getMomentumSeed().Z();
130 m_variables.at(m_prefix + "seed_Mom_Mag") = recoTrack.getMomentumSeed().R();
131 m_variables.at(m_prefix + "seed_Mom_Theta") = recoTrack.getMomentumSeed().Theta();
132 m_variables.at(m_prefix + "seed_Mom_Phi") = recoTrack.getMomentumSeed().Phi();
133
134 m_variables.at(m_prefix + "seed_Time") = recoTrack.getTimeSeed();
135
136 m_variables.at(m_prefix + "N_tracking_hits") = recoTrack.getNumberOfTrackingHits();
137 m_variables.at(m_prefix + "N_CDC_hits") = recoTrack.getNumberOfCDCHits();
138 m_variables.at(m_prefix + "N_SVD_hits") = recoTrack.getNumberOfSVDHits();
139 m_variables.at(m_prefix + "N_PXD_hits") = recoTrack.getNumberOfPXDHits();
140
141 const genfit::FitStatus* rt_TrackFitStatus = recoTrack.getTrackFitStatus();
142 if (rt_TrackFitStatus) {
143 m_variables.at(m_prefix + "Fit_Charge") = rt_TrackFitStatus->getCharge();
144 m_variables.at(m_prefix + "Fit_Chi2") = rt_TrackFitStatus->getChi2();
145 m_variables.at(m_prefix + "Fit_Ndf") = rt_TrackFitStatus->getNdf();
146 m_variables.at(m_prefix + "Fit_NFailedPoints") = rt_TrackFitStatus->getNFailedPoints();
147 m_variables.at(m_prefix + "Fit_PVal") = rt_TrackFitStatus->getPVal();
148 } else {
149 m_variables.at(m_prefix + "Fit_Charge") = -std::numeric_limits<float>::max();
150 m_variables.at(m_prefix + "Fit_Chi2") = -1.;
151 m_variables.at(m_prefix + "Fit_Ndf") = -1.;
152 m_variables.at(m_prefix + "Fit_NFailedPoints") = -1.;
153 m_variables.at(m_prefix + "Fit_PVal") = -1.;
154 }
155
156 m_variables.at(m_prefix + "Fit_Successful") = (float)recoTrack.wasFitSuccessful();
157
158 if (recoTrack.wasFitSuccessful()) {
159 B2Vector3D linePoint(0., 0., 0.);
160 B2Vector3D lineDirection(0., 0., 1.);
161
162 genfit::MeasuredStateOnPlane reco_sop;
163 try {
164 reco_sop = recoTrack.getMeasuredStateOnPlaneFromFirstHit();
165 reco_sop.extrapolateToLine(linePoint, lineDirection);
166 m_variables.at(m_prefix + "POCA_Pos_Pt") = reco_sop.getPos().Pt();
167 m_variables.at(m_prefix + "POCA_Pos_Z") = reco_sop.getPos().Z();
168 m_variables.at(m_prefix + "POCA_Pos_Mag") = reco_sop.getPos().Mag();
169 m_variables.at(m_prefix + "POCA_Pos_Theta") = reco_sop.getPos().Theta();
170 m_variables.at(m_prefix + "POCA_Pos_Phi") = reco_sop.getPos().Phi();
171
172 m_variables.at(m_prefix + "POCA_Mom_Pt") = reco_sop.getMom().Pt();
173 m_variables.at(m_prefix + "POCA_Mom_Z") = reco_sop.getMom().Z();
174 m_variables.at(m_prefix + "POCA_Mom_Mag") = reco_sop.getMom().Mag();
175 m_variables.at(m_prefix + "POCA_Mom_Theta") = reco_sop.getMom().Theta();
176 m_variables.at(m_prefix + "POCA_Mom_Phi") = reco_sop.getMom().Phi();
177 } catch (genfit::Exception const& e) {
178 // extrapolation not possible, skip this track
179 B2WARNING("RecoTrackExtractor: recoTrack BeamPipe POCA extrapolation failed!\n"
180 << "-->" << e.what());
181 m_variables.at(m_prefix + "POCA_Pos_Pt") = -1;
182 m_variables.at(m_prefix + "POCA_Pos_Z") = -std::numeric_limits<float>::max();
183 m_variables.at(m_prefix + "POCA_Pos_Mag") = -1;
184 m_variables.at(m_prefix + "POCA_Pos_Theta") = -10;
185 m_variables.at(m_prefix + "POCA_Pos_Phi") = -10;
186
187 m_variables.at(m_prefix + "POCA_Mom_Pt") = -1;
188 m_variables.at(m_prefix + "POCA_Mom_Z") = -std::numeric_limits<float>::max();
189 m_variables.at(m_prefix + "POCA_Mom_Mag") = -1;
190 m_variables.at(m_prefix + "POCA_Mom_Theta") = -10;
191 m_variables.at(m_prefix + "POCA_Mom_Phi") = -10;
192 }
193 } else {
194 m_variables.at(m_prefix + "POCA_Pos_Pt") = -1;
195 m_variables.at(m_prefix + "POCA_Pos_Z") = -std::numeric_limits<float>::max();
196 m_variables.at(m_prefix + "POCA_Pos_Mag") = -1;
197 m_variables.at(m_prefix + "POCA_Pos_Theta") = -10;
198 m_variables.at(m_prefix + "POCA_Pos_Phi") = -10;
199
200 m_variables.at(m_prefix + "POCA_Mom_Pt") = -1;
201 m_variables.at(m_prefix + "POCA_Mom_Z") = -std::numeric_limits<float>::max();
202 m_variables.at(m_prefix + "POCA_Mom_Mag") = -1;
203 m_variables.at(m_prefix + "POCA_Mom_Theta") = -10;
204 m_variables.at(m_prefix + "POCA_Mom_Phi") = -10;
205 }
206
207 }
static const ChargedStable pion
charged pion particle
Definition: Const.h:661
B2Vector3< double > B2Vector3D
typedef for common usage with double
Definition: B2Vector3.h:516

Member Data Documentation

◆ m_prefix

std::string m_prefix
protected

prefix for RecoTrack extracted variables

Definition at line 211 of file RecoTrackExtractor.h.

◆ m_variables

std::unordered_map<std::string, float> m_variables
protectedinherited

unordered_map to associate float value with a string name

Definition at line 35 of file VariableExtractor.h.


The documentation for this class was generated from the following file: