Belle II Software  release-08-01-10
PXDResultVarSet.cc
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 #include <tracking/ckf/pxd/filters/results/PXDResultVarSet.h>
9 
10 #include <tracking/spacePointCreation/SpacePoint.h>
11 #include <tracking/dataobjects/RecoTrack.h>
12 
13 #include <framework/core/ModuleParamList.templateDetails.h>
14 
15 using namespace Belle2;
16 using namespace TrackFindingCDC;
17 
18 PXDResultVarSet::PXDResultVarSet() : Super()
19 {
20  addProcessingSignalListener(&m_advancer);
21 }
22 
23 void PXDResultVarSet::initialize()
24 {
25  ModuleParamList moduleParamList;
26  m_advancer.exposeParameters(&moduleParamList, "");
27  moduleParamList.getParameter<std::string>("direction").setValue("both");
28 
30 }
31 
33 {
34  const ROOT::Math::XYZVector& resultMomentum = result->getMomentum();
35  var<named("pt")>() = resultMomentum.Rho();
36  var<named("theta")>() = resultMomentum.Theta();
37 
38  const std::vector<const SpacePoint*>& spacePoints = result->getHits();
39 
40  var<named("number_of_hits")>() = spacePoints.size();
41 
42  std::vector<bool> layerUsed;
43  layerUsed.resize(7, false);
44 
45  for (const SpacePoint* spacePoint : spacePoints) {
46  layerUsed[spacePoint->getVxdID().getLayerNumber()] = true;
47  }
48  // Counting the occurences of 'true' rather counts the number of layers used,
49  // not the number of holes. But renaming this variable would break the MVA-based result filter.
50  // Could be renamed if the weight file for the MVA result filter was retrained afterwards and
51  // the new weight file was then uploaded to the DB and would replace the current one.
52  var<named("number_of_holes")>() = std::count(layerUsed.begin(), layerUsed.end(), true);
53 
54  var<named("has_missing_layer_1")>() = layerUsed[1] == 0;
55  var<named("has_missing_layer_2")>() = layerUsed[2] == 0;
56  var<named("has_missing_layer_3")>() = layerUsed[3] == 0;
57  var<named("has_missing_layer_4")>() = layerUsed[4] == 0;
58  var<named("has_missing_layer_5")>() = layerUsed[5] == 0;
59  var<named("has_missing_layer_6")>() = layerUsed[6] == 0;
60 
61  // Since the vector layerUsed only contains bool values, there can be no number 2, so this
62  // variable is basically useless. But also here, just removing the variable would likely break
63  // the MVA-based result filter, so this could only be removed in case the MVA is retrained and
64  // the new weight file was uploaded to the DB.
65  var<named("number_of_overlap_hits")>() = std::count(layerUsed.begin(), layerUsed.end(), 2);
66 
67  if (spacePoints.empty()) {
68  var<named("last_hit_layer")>() = -1;
69  var<named("first_hit_layer")>() = -1;
70  } else {
71  var<named("last_hit_layer")>() = spacePoints.back()->getVxdID().getLayerNumber();
72  var<named("first_hit_layer")>() = spacePoints.front()->getVxdID().getLayerNumber();
73  }
74 
75  genfit::MeasuredStateOnPlane mSoP = result->getMSoP();
76  const genfit::MeasuredStateOnPlane& firstCDCHit = result->getSeedMSoP();
77  m_advancer.extrapolateToPlane(mSoP, firstCDCHit.getPlane());
78 
79  const auto& distance = mSoP.getPos() - firstCDCHit.getPos();
80  var<named("distance_to_seed_track")>() = distance.Mag();
81  var<named("distance_to_seed_track_xy")>() = distance.Pt();
82 
83  const RecoTrack* seedTrack = result->getSeed();
84 
85  var<named("chi2")>() = result->getChi2();
86  var<named("chi2_vxd_max")>() = result->getMaximalChi2();
87  var<named("chi2_vxd_min")>() = result->getMinimalChi2();
88  var<named("chi2_seed")>() = seedTrack->getTrackFitStatus()->getChi2();
89  var<named("weight_sum")>() = result->getWeightSum();
90  return true;
91 }
double extrapolateToPlane(genfit::MeasuredStateOnPlane &measuredStateOnPlane, const genfit::SharedPlanePtr &plane) const
Extrapolate the mSoP of one plane to another plane and return the traveled distance or NAN,...
Definition: Advancer.cc:22
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix)
Expose the parameters.
Definition: Advancer.cc:52
Specialized CKF Result for extrapolating into the PXD.
The Module parameter list class.
PXDAdvancer m_advancer
Findlet for advancing.
bool extract(const CKFToPXDResult *object) final
Generate and assign the variables from the object.
This is the Reconstruction Event-Data Model Track.
Definition: RecoTrack.h:79
const genfit::FitStatus * getTrackFitStatus(const genfit::AbsTrackRep *representation=nullptr) const
Return the track fit status for the given representation or for the cardinal one. You are not allowed...
Definition: RecoTrack.h:621
SpacePoint typically is build from 1 PXDCluster or 1-2 SVDClusters.
Definition: SpacePoint.h:42
void initialize() override
Receive and dispatch signal before the start of the event processing.
constexpr static int named(const char *name)
Getter for the index from the name.
Definition: VarSet.h:78
Float_t & var()
Reference getter for the value of the ith variable. Static version.
Definition: VarSet.h:93
double getChi2() const
Get chi^2 of the fit.
Definition: FitStatus.h:120
#StateOnPlane with additional covariance matrix.
ModuleParam< T > & getParameter(const std::string &name) const
Returns a reference to a parameter.
Abstract base class for different kinds of events.