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 27 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 31 of file SubRecoTrackExtractor.h.

31 :
32 VariableExtractor()
33 {
34 addVariable("CDC_QI", variableSet);
35 addVariable("SVD_QI", variableSet);
36 addVariable("PXD_QI", variableSet);
37
38 addVariable("SVD_has_SPTC", variableSet);
39 addVariable("SVD_FitSuccessful", variableSet);
40 addVariable("CDC_FitSuccessful", variableSet);
41
42 initializeStats("SVD_CDC_CDCwall_Pos", variableSet);
43 initializeStats("SVD_CDC_CDCwall_Mom", variableSet);
44 initializeStats("SVD_CDC_POCA_Pos", variableSet);
45 initializeStats("SVD_CDC_POCA_Mom", variableSet);
46
47 addVariable("SVD_CDC_CDCwall_Chi2", variableSet);
48 }
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 51 of file SubRecoTrackExtractor.h.

54 {
55 if (PXDRecoTrack) {
56 const float pxdQI = PXDRecoTrack->getQualityIndicator();
57 m_variables.at("PXD_QI") = std::isnan(pxdQI) ? 0. : pxdQI;
58 } else {
59 m_variables.at("PXD_QI") = -1.;
60 }
61
62 if (CDCRecoTrack) {
63 const float cdcQI = CDCRecoTrack->getQualityIndicator();
64 m_variables.at("CDC_QI") = std::isnan(cdcQI) ? 0. : cdcQI;
65 m_variables.at("CDC_FitSuccessful") = (float)CDCRecoTrack->wasFitSuccessful();
66 } else {
67 m_variables.at("CDC_QI") = -1.;
68 m_variables.at("CDC_FitSuccessful") = -1.;
69 }
70
71 if (SVDRecoTrack) {
72 m_variables.at("SVD_QI") = SVDRecoTrack->getQualityIndicator();
73 m_variables.at("SVD_FitSuccessful") = (float)SVDRecoTrack->wasFitSuccessful();
74 m_variables.at("SVD_has_SPTC") = (float)bool(SVDRecoTrack->getRelatedTo<SpacePointTrackCand>("SPTrackCands"));
75 } else {
76 m_variables.at("SVD_QI") = -1.;
77 m_variables.at("SVD_has_SPTC") = -1.;
78 m_variables.at("SVD_FitSuccessful") = -1.;
79 }
80
81 if (SVDRecoTrack and CDCRecoTrack and SVDRecoTrack->wasFitSuccessful() and CDCRecoTrack->wasFitSuccessful()) {
82 extractVariablesAtExtrapolationToCDCWall(CDCRecoTrack, SVDRecoTrack);
83 extractVariablesAtExtrapolationToPOCA(CDCRecoTrack, SVDRecoTrack);
84 } else {
85 setCDCSVDTrackDifferenceVariables("SVD_CDC_CDCwall_Pos", nullptr, nullptr);
86 setCDCSVDTrackDifferenceVariables("SVD_CDC_CDCwall_Mom", nullptr, nullptr);
87 m_variables.at("SVD_CDC_CDCwall_Chi2") = -1.;
88 setCDCSVDTrackDifferenceVariables("SVD_CDC_POCA_Pos", nullptr, nullptr);
89 setCDCSVDTrackDifferenceVariables("SVD_CDC_POCA_Mom", nullptr, nullptr);
90 }
91
92 }
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 131 of file SubRecoTrackExtractor.h.

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

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

◆ 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 96 of file SubRecoTrackExtractor.h.

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

◆ 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 107 of file SubRecoTrackExtractor.h.

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

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 216 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: