Belle II Software development
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
14using namespace Belle2;
15using namespace TrackFindingCDC;
16
17SVDResultVarSet::SVDResultVarSet() : Super()
18{
19 addProcessingSignalListener(&m_advancer);
20}
21
23{
24 ModuleParamList moduleParamList;
25 m_advancer.exposeParameters(&moduleParamList, "");
26 moduleParamList.getParameter<std::string>("direction").setValue("both");
27
29}
30
32{
33 const ROOT::Math::XYZVector& resultMomentum = result->getMomentum();
34 var<named("pt")>() = resultMomentum.Rho();
35 var<named("theta")>() = resultMomentum.Theta();
36
37 const std::vector<const SpacePoint*>& spacePoints = result->getHits();
38
39 var<named("number_of_hits")>() = spacePoints.size();
40
41 std::vector<bool> layerUsed;
42 layerUsed.resize(7, false);
43
44 for (const SpacePoint* spacePoint : spacePoints) {
45 layerUsed[spacePoint->getVxdID().getLayerNumber()] = true;
46 }
47 // Counting the occurences of 'true' rather counts the number of layers used,
48 // not the number of holes. But renaming this variable would break the MVA-based result filter.
49 // Could be renamed if the weight file for the MVA result filter was retrained afterwards and
50 // the new weight file was then uploaded to the DB and would replace the current one.
51 var<named("number_of_holes")>() = std::count(layerUsed.begin(), layerUsed.end(), true);
52
53 var<named("has_missing_layer_1")>() = layerUsed[1] == 0;
54 var<named("has_missing_layer_2")>() = layerUsed[2] == 0;
55 var<named("has_missing_layer_3")>() = layerUsed[3] == 0;
56 var<named("has_missing_layer_4")>() = layerUsed[4] == 0;
57 var<named("has_missing_layer_5")>() = layerUsed[5] == 0;
58 var<named("has_missing_layer_6")>() = layerUsed[6] == 0;
59
60 if (spacePoints.empty()) {
61 var<named("last_hit_layer")>() = -1;
62 var<named("first_hit_layer")>() = -1;
63 } else {
64 var<named("last_hit_layer")>() = spacePoints.back()->getVxdID().getLayerNumber();
65 var<named("first_hit_layer")>() = spacePoints.front()->getVxdID().getLayerNumber();
66 }
67
68 const RecoTrack* cdcTrack = result->getSeed();
69 const auto& cdcHits = cdcTrack->getCDCHitList();
70 B2ASSERT("CDC hits must be present", not cdcHits.empty());
71
72 const auto sortByCDCLayer = [](const CDCHit * lhs, const CDCHit * rhs) {
73 return lhs->getICLayer() < rhs->getICLayer();
74 };
75
76 const auto& firstCDCHitIterator = std::min_element(cdcHits.begin(), cdcHits.end(), sortByCDCLayer);
77 var<named("cdc_lowest_layer")>() = (*firstCDCHitIterator)->getICLayer();
78
79 genfit::MeasuredStateOnPlane mSoP = result->getMSoP();
80 const genfit::MeasuredStateOnPlane& firstCDCHit = result->getSeedMSoP();
81 m_advancer.extrapolateToPlane(mSoP, firstCDCHit.getPlane());
82
83 const auto& distance = mSoP.getPos() - firstCDCHit.getPos();
84 var<named("distance_to_cdc_track")>() = distance.Mag();
85 var<named("distance_to_cdc_track_xy")>() = distance.Pt();
86
87 var<named("chi2")>() = result->getChi2();
88 var<named("chi2_vxd_max")>() = result->getMaximalChi2();
89 var<named("chi2_vxd_min")>() = result->getMinimalChi2();
90 var<named("chi2_cdc")>() = cdcTrack->getTrackFitStatus()->getChi2();
91 var<named("weight_sum")>() = result->getWeightSum();
92 return true;
93}
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:79
std::vector< Belle2::RecoTrack::UsedCDCHit * > getCDCHitList() const
Return an unsorted list of cdc hits.
Definition: RecoTrack.h:455
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
bool extract(const CKFToSVDResult *object) final
Generate and assign the variables from the object.
void initialize() override
Receive signal before the start of the event processing.
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.
static constexpr 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
ModuleParam< T > & getParameter(const std::string &name) const
Returns a reference to a parameter.
Abstract base class for different kinds of events.