Belle II Software  release-06-02-00
SVDResultVarSet.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/svd/filters/results/SVDResultVarSet.h>
9 
10 #include <tracking/spacePointCreation/SpacePoint.h>
11 #include <tracking/dataobjects/RecoTrack.h>
12 #include <framework/core/ModuleParamList.templateDetails.h>
13 
14 using namespace std;
15 using namespace Belle2;
16 using namespace TrackFindingCDC;
17 
18 SVDResultVarSet::SVDResultVarSet() : Super()
19 {
20  addProcessingSignalListener(&m_advancer);
21 }
22 
23 void SVDResultVarSet::initialize()
24 {
25  ModuleParamList moduleParamList;
26  m_advancer.exposeParameters(&moduleParamList, "");
27  moduleParamList.getParameter<std::string>("direction").setValue("both");
28 
30 }
31 
33 {
34  const TVector3& resultMomentum = result->getMomentum();
35  var<named("pt")>() = resultMomentum.Pt();
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  if (spacePoints.empty()) {
62  var<named("last_hit_layer")>() = -1;
63  var<named("first_hit_layer")>() = -1;
64  } else {
65  var<named("last_hit_layer")>() = spacePoints.back()->getVxdID().getLayerNumber();
66  var<named("first_hit_layer")>() = spacePoints.front()->getVxdID().getLayerNumber();
67  }
68 
69  const RecoTrack* cdcTrack = result->getSeed();
70  const auto& cdcHits = cdcTrack->getCDCHitList();
71  B2ASSERT("CDC hits must be present", not cdcHits.empty());
72 
73  const auto sortByCDCLayer = [](const CDCHit * lhs, const CDCHit * rhs) {
74  return lhs->getICLayer() < rhs->getICLayer();
75  };
76 
77  const auto& firstCDCHitIterator = std::min_element(cdcHits.begin(), cdcHits.end(), sortByCDCLayer);
78  var<named("cdc_lowest_layer")>() = (*firstCDCHitIterator)->getICLayer();
79 
80  genfit::MeasuredStateOnPlane mSoP = result->getMSoP();
81  const genfit::MeasuredStateOnPlane& firstCDCHit = result->getSeedMSoP();
82  m_advancer.extrapolateToPlane(mSoP, firstCDCHit.getPlane());
83 
84  const auto& distance = mSoP.getPos() - firstCDCHit.getPos();
85  var<named("distance_to_cdc_track")>() = distance.Mag();
86  var<named("distance_to_cdc_track_xy")>() = distance.Pt();
87 
88  var<named("chi2")>() = result->getChi2();
89  var<named("chi2_vxd_max")>() = result->getMaximalChi2();
90  var<named("chi2_vxd_min")>() = result->getMinimalChi2();
91  var<named("chi2_cdc")>() = cdcTrack->getTrackFitStatus()->getChi2();
92  var<named("weight_sum")>() = result->getWeightSum();
93  return true;
94 }
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
Class containing the result of the unpacker in raw data and the result of the digitizer in simulation...
Definition: CDCHit.h:40
unsigned short getICLayer() const
Getter for iCLayer (0-55).
Definition: CDCHit.h:178
Specialized CKF Result for extrapolating into the SVD.
The Module parameter list class.
This is the Reconstruction Event-Data Model Track.
Definition: RecoTrack.h:76
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:536
std::vector< Belle2::RecoTrack::UsedCDCHit * > getCDCHitList() const
Return an unsorted list of cdc hits.
Definition: RecoTrack.h:445
bool extract(const CKFToSVDResult *object) final
Generate and assign the variables from the object.
SVDAdvancer m_advancer
Findlet for advancing.
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.