Belle II Software  release-08-01-10
FlipRecoTrackExtractor.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 <mdst/dataobjects/HitPatternCDC.h>
19 #include <framework/gearbox/Const.h>
20 
21 namespace Belle2 {
28  public:
29 
31  explicit FlipRecoTrackExtractor(std::vector<Named<float*>>& variableSet, const std::string& prefix = ""):
32  VariableExtractor(), m_prefix(prefix)
33  {
35  addVariable(prefix + "seed_pz_estimate", variableSet);
36  addVariable(prefix + "seed_pz_variance", variableSet);
37  addVariable(prefix + "seed_z_estimate", variableSet);
38  addVariable(prefix + "seed_tan_lambda_estimate", variableSet);
39  addVariable(prefix + "seed_pt_estimate", variableSet);
40  addVariable(prefix + "seed_x_estimate", variableSet);
41  addVariable(prefix + "seed_y_estimate", variableSet);
42  addVariable(prefix + "seed_py_variance", variableSet);
43  addVariable(prefix + "seed_d0_estimate", variableSet);
44  addVariable(prefix + "seed_omega_variance", variableSet);
45  addVariable(prefix + "svd_layer6_clsTime", variableSet);
46  addVariable(prefix + "seed_tan_lambda_variance", variableSet);
47  addVariable(prefix + "seed_z_variance", variableSet);
48  addVariable(prefix + "n_svd_hits", variableSet);
49  addVariable(prefix + "n_cdc_hits", variableSet);
50  addVariable(prefix + "svd_layer3_positionSigma", variableSet);
51  addVariable(prefix + "first_cdc_layer", variableSet);
52  addVariable(prefix + "last_cdc_layer", variableSet);
53  addVariable(prefix + "InOutArmTimeDifference", variableSet);
54  addVariable(prefix + "InOutArmTimeDifferenceError", variableSet);
55  addVariable(prefix + "inGoingArmTime", variableSet);
56  addVariable(prefix + "inGoingArmTimeError", variableSet);
57  addVariable(prefix + "outGoingArmTime", variableSet);
58  addVariable(prefix + "outGoingArmTimeError", variableSet);
59 
60  }
61 
63  void extractVariables(RecoTrack& recoTrack)
64  {
65 
66  m_variables.at(m_prefix + "InOutArmTimeDifference") = recoTrack.getInOutArmTimeDifference();
67  m_variables.at(m_prefix + "InOutArmTimeDifferenceError") = recoTrack.getInOutArmTimeDifferenceError();
68  m_variables.at(m_prefix + "inGoingArmTime") = recoTrack.getIngoingArmTime();
69  m_variables.at(m_prefix + "inGoingArmTimeError") = recoTrack.getIngoingArmTimeError();
70  m_variables.at(m_prefix + "outGoingArmTime") = recoTrack.getOutgoingArmTime();
71  m_variables.at(m_prefix + "outGoingArmTimeError") = recoTrack.getOutgoingArmTimeError();
72 
73  auto cdc_list = recoTrack.getSortedCDCHitList();
74  if (cdc_list.size() > 0) {
75  auto first_cdc_list = cdc_list.front();
76  auto last_cdc_list = cdc_list.back();
77  m_variables.at(m_prefix + "first_cdc_layer") = first_cdc_list->getICLayer();
78  m_variables.at(m_prefix + "last_cdc_layer") = last_cdc_list->getICLayer();
79  }
80 
81  m_variables.at(m_prefix + "n_svd_hits") = recoTrack.getNumberOfSVDHits();
82  m_variables.at(m_prefix + "n_cdc_hits") = recoTrack.getNumberOfCDCHits();
83 
84  RecoTrack* svdcdc_recoTrack = recoTrack.getRelated<RecoTrack>("SVDCDCRecoTracks");
85  if (svdcdc_recoTrack) {
86  auto svdcdc_cov = svdcdc_recoTrack->getSeedCovariance();
87  auto svdcdc_mom = svdcdc_recoTrack->getMomentumSeed();
88  auto svdcdc_pos = svdcdc_recoTrack->getPositionSeed();
89  auto svdcdc_charge_sign = svdcdc_recoTrack->getChargeSeed() > 0 ? 1 : -1;
90  auto svdcdc_b_field = BFieldManager::getFieldInTesla(svdcdc_pos).Z();
91  const uint16_t svdcdc_NDF = 0xffff;
92  auto svdcdc_FitResult = TrackFitResult(svdcdc_pos, svdcdc_mom, svdcdc_cov,
93  svdcdc_charge_sign, Const::pion, 0, svdcdc_b_field, 0, 0,
94  svdcdc_NDF);
95 
96  m_variables.at(m_prefix + "seed_pz_variance") = svdcdc_cov(5, 5);
97  m_variables.at(m_prefix + "seed_pz_estimate") = svdcdc_mom.Z();
98  m_variables.at(m_prefix + "seed_z_estimate") = svdcdc_pos.Z() ;
99  m_variables.at(m_prefix + "seed_tan_lambda_estimate") = svdcdc_FitResult.getCotTheta();
100 
101  float seed_pt_estimate = svdcdc_mom.Rho();
102 
103  m_variables.at(m_prefix + "seed_pt_estimate") = seed_pt_estimate;
104  m_variables.at(m_prefix + "seed_x_estimate") = svdcdc_pos.X();
105  m_variables.at(m_prefix + "seed_y_estimate") = svdcdc_pos.Y();
106  m_variables.at(m_prefix + "seed_py_variance") = svdcdc_cov(4, 4);
107  m_variables.at(m_prefix + "seed_d0_estimate") = svdcdc_FitResult.getD0();
108  m_variables.at(m_prefix + "seed_omega_variance") = svdcdc_FitResult.getCov()[9];
109  m_variables.at(m_prefix + "seed_tan_lambda_variance") = svdcdc_FitResult.getCov()[14];
110  m_variables.at(m_prefix + "seed_z_variance") = svdcdc_cov(2, 2);
111 
112  }
113 
114  for (auto* svdHit : recoTrack.getSVDHitList()) {
115  if (svdHit->getSensorID().getLayerNumber() == 3) {
116  m_variables.at(m_prefix + "svd_layer3_positionSigma") = svdHit->getPositionSigma();
117  }
118  if (svdHit->getSensorID().getLayerNumber() == 6) {
119  m_variables.at(m_prefix + "svd_layer6_clsTime") = svdHit->getClsTime();
120  }
121  }
122  }
123 
124 
125  protected:
127  std::string m_prefix;
128  };
129 
131 }
static ROOT::Math::XYZVector getFieldInTesla(const ROOT::Math::XYZVector &pos)
return the magnetic field at a given position in Tesla.
Definition: BFieldManager.h:61
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
FlipRecoTrackExtractor(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 getInOutArmTimeDifference()
Return the difference between the track times of the ingoing and outgoing arms.
Definition: RecoTrack.h:542
float getOutgoingArmTime()
Return the track time of the outgoing arm.
Definition: RecoTrack.h:514
std::vector< Belle2::RecoTrack::UsedSVDHit * > getSVDHitList() const
Return an unsorted list of svd hits.
Definition: RecoTrack.h:452
ROOT::Math::XYZVector getPositionSeed() const
Return the position seed stored in the reco track. ATTENTION: This is not the fitted position.
Definition: RecoTrack.h:480
unsigned int getNumberOfSVDHits() const
Return the number of svd hits.
Definition: RecoTrack.h:424
unsigned int getNumberOfCDCHits() const
Return the number of cdc hits.
Definition: RecoTrack.h:427
float getIngoingArmTimeError()
Return the error of the track time of the ingoing arm.
Definition: RecoTrack.h:535
float getOutgoingArmTimeError()
Return the error of the track time of the outgoing arm.
Definition: RecoTrack.h:521
float getIngoingArmTime()
Return the track time of the ingoing arm.
Definition: RecoTrack.h:528
float getInOutArmTimeDifferenceError()
Return the error of the difference between the track times of the ingoing and outgoing arms.
Definition: RecoTrack.h:549
const TMatrixDSym & getSeedCovariance() const
Return the covariance matrix of the seed. ATTENTION: This is not the fitted covariance.
Definition: RecoTrack.h:611
short int getChargeSeed() const
Return the charge seed stored in the reco track. ATTENTION: This is not the fitted charge.
Definition: RecoTrack.h:508
ROOT::Math::XYZVector getMomentumSeed() const
Return the momentum seed stored in the reco track. ATTENTION: This is not the fitted momentum.
Definition: RecoTrack.h:487
std::vector< Belle2::RecoTrack::UsedCDCHit * > getSortedCDCHitList() const
Return a sorted list of cdc hits. Sorted by the sortingParameter.
Definition: RecoTrack.h:470
T * getRelated(const std::string &name="", const std::string &namedRelation="") const
Get the object to or from which this object has a relation.
Values of the result of a track fit with a given particle hypothesis.
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.