10 #include <tracking/trackFindingVXD/variableExtractors/VariableExtractor.h>
11 #include <tracking/dataobjects/RecoTrack.h>
12 #include <tracking/dataobjects/RecoHitInformation.h>
14 #include <genfit/KalmanFitterInfo.h>
15 #include <genfit/TrackPoint.h>
35 addVariable(
"N_TrackPoints_without_KalmanFitterInfo", variableSet);
36 addVariable(
"N_Hits_without_TrackPoint", variableSet);
47 std::vector<const genfit::KalmanFitterInfo*> kalmanFitterInfos;
48 kalmanFitterInfos.reserve(recoHitInformations.size());
50 int n_no_trackPoint = 0;
51 int n_no_KalmanFitterInfo = 0;
56 if (kalmanFitterInfo) {
57 kalmanFitterInfos.push_back(kalmanFitterInfo);
59 n_no_KalmanFitterInfo++;
65 m_variables.at(
"N_Hits_without_TrackPoint") = n_no_trackPoint;
66 m_variables.at(
"N_TrackPoints_without_KalmanFitterInfo") = n_no_KalmanFitterInfo;
70 const auto hitHasKalmanInfoAndIsFromDetector =
71 [&recoTrack,
this](
const auto & recoHitInformation,
74 and (recoHitInformation->getTrackingDetector() == trackingDetector));
76 const auto hitHasKalmanInfoAndIsFromCDC = std::bind(hitHasKalmanInfoAndIsFromDetector,
77 std::placeholders::_1,
78 RecoHitInformation::c_CDC);
79 const auto hitHasKalmanInfoAndIsFromSVD = std::bind(hitHasKalmanInfoAndIsFromDetector,
80 std::placeholders::_1,
81 RecoHitInformation::c_SVD);
84 const auto firstHitWithCDCKalmanInfoIter = std::find_if(recoHitInformations.begin(),
85 recoHitInformations.end(),
86 hitHasKalmanInfoAndIsFromCDC);
87 std::optional<float> weight_firstCDCHit;
88 std::optional<float> smoothedChi2_firstCDCHit;
89 if (firstHitWithCDCKalmanInfoIter != recoHitInformations.end()) {
91 weight_firstCDCHit = kalmanFitterInfo->
getWeights().front();
98 const auto lastHitWithSVDKalmanInfoIter = std::find_if(recoHitInformations.rbegin(),
99 recoHitInformations.rend(),
100 hitHasKalmanInfoAndIsFromSVD);
101 std::optional<float> weight_lastSVDHit;
102 std::optional<float> smoothedChi2_lastSVDHit;
103 if (lastHitWithSVDKalmanInfoIter != recoHitInformations.rend()) {
105 weight_lastSVDHit = kalmanFitterInfo->
getWeights().front();
111 std::vector<float> fitWeights;
112 std::vector<float> chi2Values;
113 fitWeights.reserve(kalmanFitterInfos.size());
114 chi2Values.reserve(kalmanFitterInfos.size());
115 for (
const auto& kalmanFitterInfo : kalmanFitterInfos) {
116 fitWeights.push_back(kalmanFitterInfo->getWeights().front());
120 setStats(
"smoothedChi2", chi2Values);
133 addVariable(identifier +
"_firstCDCHit", variables);
134 addVariable(identifier +
"_lastSVDHit", variables);
139 (
const std::string& identifier, std::vector<float>& values)
141 int size = values.size();
142 if (values.size() == 0) {
154 std::sort(values.begin(), values.end());
156 float sum = std::accumulate(values.begin(), values.end(), 0.0);
157 float mean = sum / size;
161 for (
float value : values) {
162 variance += (value - mean) * (value - mean);
167 variance /= size - 1;
168 float stddev = std::sqrt(variance);
170 m_variables.at(identifier +
"_min") = values.front();
171 m_variables.at(identifier +
"_max") = values.back();
174 float median = (size % 2) ? values[size / 2] : 0.5 * (values[size / 2] + values[size / 2 - 1]);
195 return kalmanFitterInfo->getSmoothedChi2();
196 }
catch (
const std::exception& e) {
197 B2WARNING(
"HitInfoExtractor: Caught exception in kalmanFitterInfos[i]->getSmoothedChi2() \n"
198 <<
"-->" << e.what());
This is the Reconstruction Event-Data Model Track.
const genfit::TrackPoint * getCreatedTrackPoint(const RecoHitInformation *recoHitInformation) const
Get a pointer to the TrackPoint that was created from this hit.
std::vector< RecoHitInformation * > getRecoHitInformations(bool getSorted=false) const
Return a list of all RecoHitInformations associated with the RecoTrack.
Collects information needed and produced by a AbsKalmanFitter implementations and is specific to one ...
std::vector< double > getWeights() const
Get weights of measurements.
Object containing AbsMeasurement and AbsFitterInfo objects.
KalmanFitterInfo * getKalmanFitterInfo(const AbsTrackRep *rep=nullptr) const
Helper to avoid casting.
Abstract base class for different kinds of events.