Belle II Software development
SubRecoTrackExtractor Class Reference

class to extract results from qualityEstimation More...

#include <SubRecoTrackExtractor.h>

Inheritance diagram for SubRecoTrackExtractor:
VariableExtractor

Public Member Functions

 SubRecoTrackExtractor (std::vector< Named< float * > > &variableSet)
 Define names of variables that get extracted.
 
void extractVariables (RecoTrack const *CDCRecoTrack, RecoTrack const *SVDRecoTrack, RecoTrack const *PXDRecoTrack)
 extract the actual variables and write into a variable set
 

Protected Member Functions

void initializeStats (const std::string &prefix, std::vector< Named< float * > > &variables)
 initialize statistics subsets of variables from clusters that get combined for SPTC
 
void setCDCSVDTrackDifferenceVariables (const std::string &prefix, const ROOT::Math::XYZVector *svdTrackVector, const ROOT::Math::XYZVector *cdcTrackVector)
 calculated differences and saves them in variable set
 
void extractVariablesAtExtrapolationToCDCWall (RecoTrack const *CDCRecoTrack, RecoTrack const *SVDRecoTrack)
 Extrapolate fitted RecoTracks from CDC standalone and VXDTF2 tracking to the CDC wall and extract the difference variables there.
 
void extractVariablesAtExtrapolationToPOCA (RecoTrack const *CDCRecoTrack, RecoTrack const *SVDRecoTrack)
 Extrapolate fitted RecoTracks from CDC standalone and VXDTF2 tracking to the POCA and extract the difference variables there.
 
void addVariable (const std::string &identifier, std::vector< Named< float * > > &variables)
 add a variable to the variable set
 

Protected Attributes

std::unordered_map< std::string, float > m_variables
 unordered_map to associate float value with a string name
 

Private Attributes

const double m_CDC_wall_radius = 16.25
 Radius of the inner CDC wall in centimeters.
 

Detailed Description

class to extract results from qualityEstimation

Definition at line 25 of file SubRecoTrackExtractor.h.

Constructor & Destructor Documentation

◆ SubRecoTrackExtractor()

SubRecoTrackExtractor ( std::vector< Named< float * > > &  variableSet)
inlineexplicit

Define names of variables that get extracted.

Definition at line 29 of file SubRecoTrackExtractor.h.

29 :
30 VariableExtractor()
31 {
32 addVariable("CDC_QI", variableSet);
33 addVariable("SVD_QI", variableSet);
34 addVariable("PXD_QI", variableSet);
35
36 addVariable("SVD_has_SPTC", variableSet);
37 addVariable("SVD_FitSuccessful", variableSet);
38 addVariable("CDC_FitSuccessful", variableSet);
39
40 initializeStats("SVD_CDC_CDCwall_Pos", variableSet);
41 initializeStats("SVD_CDC_CDCwall_Mom", variableSet);
42 initializeStats("SVD_CDC_POCA_Pos", variableSet);
43 initializeStats("SVD_CDC_POCA_Mom", variableSet);
44
45 addVariable("SVD_CDC_CDCwall_Chi2", variableSet);
46 }
void initializeStats(const std::string &prefix, std::vector< Named< float * > > &variables)
initialize statistics subsets of variables from clusters that get combined for SPTC
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 ( RecoTrack const *  CDCRecoTrack,
RecoTrack const *  SVDRecoTrack,
RecoTrack const *  PXDRecoTrack 
)
inline

extract the actual variables and write into a variable set

Definition at line 49 of file SubRecoTrackExtractor.h.

52 {
53 if (PXDRecoTrack) {
54 const float pxdQI = PXDRecoTrack->getQualityIndicator();
55 m_variables.at("PXD_QI") = isnan(pxdQI) ? 0. : pxdQI;
56 } else {
57 m_variables.at("PXD_QI") = -1.;
58 }
59
60 if (CDCRecoTrack) {
61 const float cdcQI = CDCRecoTrack->getQualityIndicator();
62 m_variables.at("CDC_QI") = isnan(cdcQI) ? 0. : cdcQI;
63 m_variables.at("CDC_FitSuccessful") = (float)CDCRecoTrack->wasFitSuccessful();
64 } else {
65 m_variables.at("CDC_QI") = -1.;
66 m_variables.at("CDC_FitSuccessful") = -1.;
67 }
68
69 if (SVDRecoTrack) {
70 m_variables.at("SVD_QI") = SVDRecoTrack->getQualityIndicator();
71 m_variables.at("SVD_FitSuccessful") = (float)SVDRecoTrack->wasFitSuccessful();
72 m_variables.at("SVD_has_SPTC") = (float)bool(SVDRecoTrack->getRelatedTo<SpacePointTrackCand>("SPTrackCands"));
73 } else {
74 m_variables.at("SVD_QI") = -1.;
75 m_variables.at("SVD_has_SPTC") = -1.;
76 m_variables.at("SVD_FitSuccessful") = -1.;
77 }
78
79 if (SVDRecoTrack and CDCRecoTrack and SVDRecoTrack->wasFitSuccessful() and CDCRecoTrack->wasFitSuccessful()) {
80 extractVariablesAtExtrapolationToCDCWall(CDCRecoTrack, SVDRecoTrack);
81 extractVariablesAtExtrapolationToPOCA(CDCRecoTrack, SVDRecoTrack);
82 } else {
83 setCDCSVDTrackDifferenceVariables("SVD_CDC_CDCwall_Pos", nullptr, nullptr);
84 setCDCSVDTrackDifferenceVariables("SVD_CDC_CDCwall_Mom", nullptr, nullptr);
85 m_variables.at("SVD_CDC_CDCwall_Chi2") = -1.;
86 setCDCSVDTrackDifferenceVariables("SVD_CDC_POCA_Pos", nullptr, nullptr);
87 setCDCSVDTrackDifferenceVariables("SVD_CDC_POCA_Mom", nullptr, nullptr);
88 }
89
90 }
void setCDCSVDTrackDifferenceVariables(const std::string &prefix, const ROOT::Math::XYZVector *svdTrackVector, const ROOT::Math::XYZVector *cdcTrackVector)
calculated differences and saves them in variable set
void extractVariablesAtExtrapolationToPOCA(RecoTrack const *CDCRecoTrack, RecoTrack const *SVDRecoTrack)
Extrapolate fitted RecoTracks from CDC standalone and VXDTF2 tracking to the POCA and extract the dif...
void extractVariablesAtExtrapolationToCDCWall(RecoTrack const *CDCRecoTrack, RecoTrack const *SVDRecoTrack)
Extrapolate fitted RecoTracks from CDC standalone and VXDTF2 tracking to the CDC wall and extract the...

◆ extractVariablesAtExtrapolationToCDCWall()

void extractVariablesAtExtrapolationToCDCWall ( RecoTrack const *  CDCRecoTrack,
RecoTrack const *  SVDRecoTrack 
)
inlineprotected

Extrapolate fitted RecoTracks from CDC standalone and VXDTF2 tracking to the CDC wall and extract the difference variables there.

Definition at line 129 of file SubRecoTrackExtractor.h.

130 {
131 // position and momentum used for extrapolations to the CDC Wall
132 B2Vector3D center(0., 0., 0.);
133 B2Vector3D direction(0., 0., 1.);
134
135 genfit::MeasuredStateOnPlane svdTrackStateOnPlane;
136 genfit::MeasuredStateOnPlane cdcTrackStateOnPlane;
137 try {
138 // do extrapolation of SVD and CDC onto CDCwall
139 svdTrackStateOnPlane = SVDRecoTrack->getMeasuredStateOnPlaneFromLastHit();
140 cdcTrackStateOnPlane = CDCRecoTrack->getMeasuredStateOnPlaneFromFirstHit();
141 cdcTrackStateOnPlane.extrapolateToCylinder(m_CDC_wall_radius, center, direction);
142 svdTrackStateOnPlane.extrapolateToPlane(cdcTrackStateOnPlane.getPlane());
143 } catch (genfit::Exception const& e) {
144 // extrapolation not possible, skip this track
145 B2WARNING("SubRecoTrackExtractor: SVDRecoTrack and/or CDCRecoTrack extrapolation to the CDCwall failed!\n"
146 << "-->" << e.what());
147 setCDCSVDTrackDifferenceVariables("SVD_CDC_CDCwall_Pos", nullptr, nullptr);
148 setCDCSVDTrackDifferenceVariables("SVD_CDC_CDCwall_Mom", nullptr, nullptr);
149 m_variables.at("SVD_CDC_CDCwall_Chi2") = -1.;
150 return;
151 }
152
153 // set differences in Position and Momentum
154 const ROOT::Math::XYZVector svdTrackPositionOnPlaneAtCDCWall = ROOT::Math::XYZVector(svdTrackStateOnPlane.getPos());
155 const ROOT::Math::XYZVector svdTrackMomentumOnPlaneAtCDCWall = ROOT::Math::XYZVector(svdTrackStateOnPlane.getMom());
156 const ROOT::Math::XYZVector cdcTrackPositionOnPlaneAtCDCWall = ROOT::Math::XYZVector(cdcTrackStateOnPlane.getPos());
157 const ROOT::Math::XYZVector cdcTrackMomentumOnPlaneAtCDCWall = ROOT::Math::XYZVector(cdcTrackStateOnPlane.getMom());
158 setCDCSVDTrackDifferenceVariables("SVD_CDC_CDCwall_Pos", &svdTrackPositionOnPlaneAtCDCWall, &cdcTrackPositionOnPlaneAtCDCWall);
159 setCDCSVDTrackDifferenceVariables("SVD_CDC_CDCwall_Mom", &svdTrackMomentumOnPlaneAtCDCWall, &cdcTrackMomentumOnPlaneAtCDCWall);
160 try {
161 // calculate chi2 between SVD and CDC (like in VXDCDCTrackMerger)
162 const TMatrixDSym invCovariance = (svdTrackStateOnPlane.getCov() + cdcTrackStateOnPlane.getCov()).Invert();
163 TVectorD stateDifference = cdcTrackStateOnPlane.getState() - svdTrackStateOnPlane.getState();
164 stateDifference *= invCovariance;
165 const float chi2 = stateDifference * (cdcTrackStateOnPlane.getState() - svdTrackStateOnPlane.getState());
166 m_variables.at("SVD_CDC_CDCwall_Chi2") = chi2;
167
168 } catch (genfit::Exception const& e) {
169 // extrapolation not possible, skip this track
170 B2WARNING("SubRecoTrackExtractor: Matrix is singular!\n"
171 << "-->" << e.what());
172 m_variables.at("SVD_CDC_CDCwall_Chi2") = -1.;
173 return;
174 }
175 }
const double m_CDC_wall_radius
Radius of the inner CDC wall in centimeters.
B2Vector3< double > B2Vector3D
typedef for common usage with double
Definition: B2Vector3.h:516

◆ extractVariablesAtExtrapolationToPOCA()

void extractVariablesAtExtrapolationToPOCA ( RecoTrack const *  CDCRecoTrack,
RecoTrack const *  SVDRecoTrack 
)
inlineprotected

Extrapolate fitted RecoTracks from CDC standalone and VXDTF2 tracking to the POCA and extract the difference variables there.

Definition at line 180 of file SubRecoTrackExtractor.h.

181 {
182 // position and momentum used for extrapolations to the CDC Wall
183 const B2Vector3D linePoint(0., 0., 0.);
184 const B2Vector3D lineDirection(0., 0., 1.);
185
186 genfit::MeasuredStateOnPlane svdTrackStateOnPlane;
187 genfit::MeasuredStateOnPlane cdcTrackStateOnPlane;
188 try {
189 // do extrapolation of SVD and CDC onto CDCwall
190 svdTrackStateOnPlane = SVDRecoTrack->getMeasuredStateOnPlaneFromFirstHit();
191 cdcTrackStateOnPlane = CDCRecoTrack->getMeasuredStateOnPlaneFromFirstHit();
192 cdcTrackStateOnPlane.extrapolateToLine(linePoint, lineDirection);
193 svdTrackStateOnPlane.extrapolateToLine(linePoint, lineDirection);
194 } catch (genfit::Exception const& e) {
195 // extrapolation not possible, skip this track
196 B2WARNING("SubRecoTrackExtractor: SVDRecoTrack and/or CDCRecoTrack extrapolation to POCA failed!\n"
197 << "-->" << e.what());
198 setCDCSVDTrackDifferenceVariables("SVD_CDC_POCA_Pos", nullptr, nullptr);
199 setCDCSVDTrackDifferenceVariables("SVD_CDC_POCA_Mom", nullptr, nullptr);
200 return;
201 }
202
203 // set differences in Position and Momentum
204 const ROOT::Math::XYZVector svdTrackPositionOnPlaneAtPOCA = ROOT::Math::XYZVector(svdTrackStateOnPlane.getPos());
205 const ROOT::Math::XYZVector svdTrackMomentumOnPlaneAtPOCA = ROOT::Math::XYZVector(svdTrackStateOnPlane.getMom());
206 const ROOT::Math::XYZVector cdcTrackPositionOnPlaneAtPOCA = ROOT::Math::XYZVector(cdcTrackStateOnPlane.getPos());
207 const ROOT::Math::XYZVector cdcTrackMomentumOnPlaneAtPOCA = ROOT::Math::XYZVector(cdcTrackStateOnPlane.getMom());
208 setCDCSVDTrackDifferenceVariables("SVD_CDC_POCA_Pos", &svdTrackPositionOnPlaneAtPOCA, &cdcTrackPositionOnPlaneAtPOCA);
209 setCDCSVDTrackDifferenceVariables("SVD_CDC_POCA_Mom", &svdTrackMomentumOnPlaneAtPOCA, &cdcTrackMomentumOnPlaneAtPOCA);
210 }

◆ initializeStats()

void initializeStats ( const std::string &  prefix,
std::vector< Named< float * > > &  variables 
)
inlineprotected

initialize statistics subsets of variables from clusters that get combined for SPTC

Definition at line 94 of file SubRecoTrackExtractor.h.

95 {
96 addVariable(prefix + "_diff_Z", variables);
97 addVariable(prefix + "_diff_Pt", variables);
98 addVariable(prefix + "_diff_Theta", variables);
99 addVariable(prefix + "_diff_Phi", variables);
100 addVariable(prefix + "_diff_Mag", variables);
101 addVariable(prefix + "_diff_Eta", variables);
102 }

◆ setCDCSVDTrackDifferenceVariables()

void setCDCSVDTrackDifferenceVariables ( const std::string &  prefix,
const ROOT::Math::XYZVector *  svdTrackVector,
const ROOT::Math::XYZVector *  cdcTrackVector 
)
inlineprotected

calculated differences and saves them in variable set

Definition at line 105 of file SubRecoTrackExtractor.h.

108 {
109 if (not(svdTrackVector and cdcTrackVector)) {
110 m_variables.at(prefix + "_diff_Z") = -1.;
111 m_variables.at(prefix + "_diff_Pt") = -1.;
112 m_variables.at(prefix + "_diff_Theta") = -1.;
113 m_variables.at(prefix + "_diff_Phi") = -1.;
114 m_variables.at(prefix + "_diff_Mag") = -1.;
115 m_variables.at(prefix + "_diff_Eta") = -1.;
116 return;
117 }
118 m_variables.at(prefix + "_diff_Z") = fabs(cdcTrackVector->Z() - svdTrackVector->Z());
119 m_variables.at(prefix + "_diff_Pt") = fabs(cdcTrackVector->Rho() - svdTrackVector->Rho());
120 m_variables.at(prefix + "_diff_Theta") = fabs(cdcTrackVector->Theta() - svdTrackVector->Theta());
121 m_variables.at(prefix + "_diff_Phi") = fabs(cdcTrackVector->Phi() - svdTrackVector->Phi());
122 m_variables.at(prefix + "_diff_Mag") = fabs(cdcTrackVector->R() - svdTrackVector->R());
123 m_variables.at(prefix + "_diff_Eta") = fabs(cdcTrackVector->Eta() - svdTrackVector->Eta());
124 }

Member Data Documentation

◆ m_CDC_wall_radius

const double m_CDC_wall_radius = 16.25
private

Radius of the inner CDC wall in centimeters.

Definition at line 214 of file SubRecoTrackExtractor.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: