Belle II Software  release-08-01-10
Flip2ndRecoTrackExtractor.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 <framework/gearbox/Const.h>
19 
20 namespace Belle2 {
27  public:
28 
30  explicit FlipRecoTrackExtractor2nd(std::vector<Named<float*>>& variableSet, const std::string& prefix = ""):
31  VariableExtractor(), m_prefix(prefix)
32  {
33  addVariable(prefix + "flipped_pz_estimate", variableSet);
34  addVariable(prefix + "tan_lambda_estimate", variableSet);
35  addVariable(prefix + "d0_variance", variableSet);
36  addVariable(prefix + "z_estimate", variableSet);
37  addVariable(prefix + "px_variance", variableSet);
38  addVariable(prefix + "p_value", variableSet);
39  addVariable(prefix + "pt_estimate", variableSet);
40  addVariable(prefix + "y_estimate", variableSet);
41  addVariable(prefix + "d0_estimate", variableSet);
42  addVariable(prefix + "x_estimate", variableSet);
43  addVariable(prefix + "pz_variance", variableSet);
44  addVariable(prefix + "omega_estimate", variableSet);
45  addVariable(prefix + "px_estimate", variableSet);
46  addVariable(prefix + "flipped_z_estimate", variableSet);
47  addVariable(prefix + "py_estimate", variableSet);
48  addVariable(prefix + "outGoingArmTime", variableSet);
49  addVariable(prefix + "quality_flip_indicator", variableSet);
50  addVariable(prefix + "inGoingArmTime", variableSet);
51  }
53  void extractVariables(RecoTrack& recoTrack)
54  {
55 
56  m_variables.at(m_prefix + "inGoingArmTime") = recoTrack.getIngoingArmTime();
57  m_variables.at(m_prefix + "outGoingArmTime") = recoTrack.getOutgoingArmTime();
58 
59  auto genfitTrack = recoTrack.getRelated<Track>("Tracks");
60 
61  if (genfitTrack) {
62  auto trackFitResult = genfitTrack->getTrackFitResultWithClosestMass(Const::pion);
63 
64  RecoTrack* RecoTrack_flipped = recoTrack.getRelatedFrom<RecoTrack>("RecoTracks_flipped");
65  if (RecoTrack_flipped) {
66  Track* b2track_flipped = RecoTrack_flipped->getRelatedFrom<Track>("Tracks_flipped");
67  if (b2track_flipped) {
68  auto fitTrack_flipped = b2track_flipped->getTrackFitResultWithClosestMassByName(Const::pion, "TrackFitResults_flipped");
69  if (trackFitResult && fitTrack_flipped) {
70  auto cov6 = trackFitResult->getCovariance6();
71  auto mom = trackFitResult->getMomentum();
72  auto pos = trackFitResult->getPosition();
73 
74  auto cov6_flipped = fitTrack_flipped->getCovariance6();
75  auto mom_flipped = fitTrack_flipped->getMomentum();
76  auto pos_flipped = fitTrack_flipped->getPosition();
77 
78  m_variables.at(m_prefix + "flipped_pz_estimate") = mom_flipped.Z();
79  m_variables.at(m_prefix + "tan_lambda_estimate") = trackFitResult->getCotTheta();
80  m_variables.at(m_prefix + "d0_variance") = trackFitResult->getCov()[0];
81  m_variables.at(m_prefix + "z_estimate") = pos.Z();
82  m_variables.at(m_prefix + "px_variance") = cov6(3, 3);
83  m_variables.at(m_prefix + "p_value") = trackFitResult->getPValue();
84  m_variables.at(m_prefix + "pt_estimate") = mom.Rho();
85  m_variables.at(m_prefix + "y_estimate") = pos.Y();
86  m_variables.at(m_prefix + "d0_estimate") = trackFitResult->getD0();
87  m_variables.at(m_prefix + "x_estimate") = pos.X();
88  m_variables.at(m_prefix + "pz_variance") = cov6(5, 5);
89  m_variables.at(m_prefix + "omega_estimate") = trackFitResult->getOmega();
90  m_variables.at(m_prefix + "quality_flip_indicator") = recoTrack.getFlipQualityIndicator();
91  m_variables.at(m_prefix + "px_estimate") = mom.X();
92  m_variables.at(m_prefix + "flipped_z_estimate") = pos_flipped.Z();
93  m_variables.at(m_prefix + "py_estimate") = mom.Y();
94 
95  }
96  }
97  }
98  }
99 
100  }
101  protected:
103  std::string m_prefix;
104  };
106 }
static const ChargedStable pion
charged pion particle
Definition: Const.h:652
class to extract results from qualityEstimation
std::string m_prefix
prefix for RecoTrack extracted variables
void extractVariables(RecoTrack &recoTrack)
extract the actual variables and write into a variable set
FlipRecoTrackExtractor2nd(std::vector< Named< float * >> &variableSet, const std::string &prefix="")
Define names of variables that get extracted.
This is the Reconstruction Event-Data Model Track.
Definition: RecoTrack.h:79
float getOutgoingArmTime()
Return the track time of the outgoing arm.
Definition: RecoTrack.h:514
float getIngoingArmTime()
Return the track time of the ingoing arm.
Definition: RecoTrack.h:528
float getFlipQualityIndicator() const
Get the 1st flipping quality attached to this RecoTrack as a reference for flipping.
Definition: RecoTrack.h:853
FROM * getRelatedFrom(const std::string &name="", const std::string &namedRelation="") const
Get the object from which this object has a relation.
T * getRelated(const std::string &name="", const std::string &namedRelation="") const
Get the object to or from which this object has a relation.
TMatrixDSym getCovariance6() const
Position and Momentum Covariance Matrix.
Class that bundles various TrackFitResults.
Definition: Track.h:25
const TrackFitResult * getTrackFitResultWithClosestMassByName(const Const::ChargedStable &requestedType, const std::string trackFitResultsName) const
Return the track fit (from TrackFitResult with specified name) for a fit hypothesis with the closest ...
Definition: Track.cc:80
const TrackFitResult * getTrackFitResultWithClosestMass(const Const::ChargedStable &requestedType) const
Return the track fit for a fit hypothesis with the closest mass.
Definition: Track.cc:104
class to extract individual variables
std::unordered_map< std::string, float > m_variables
unordered_map to associate float value with a string name
void addVariable(const std::string &identifier, std::vector< Named< float * >> &variables)
add a variable to the variable set
Abstract base class for different kinds of events.