Belle II Software  release-05-01-25
SVDResultVarSet.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2017 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Nils Braun *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 #include <tracking/ckf/svd/filters/results/SVDResultVarSet.h>
11 
12 #include <tracking/spacePointCreation/SpacePoint.h>
13 #include <tracking/dataobjects/RecoTrack.h>
14 #include <framework/core/ModuleParamList.templateDetails.h>
15 
16 using namespace std;
17 using namespace Belle2;
18 using namespace TrackFindingCDC;
19 
20 SVDResultVarSet::SVDResultVarSet() : Super()
21 {
22  addProcessingSignalListener(&m_advancer);
23 }
24 
26 {
27  ModuleParamList moduleParamList;
28  m_advancer.exposeParameters(&moduleParamList, "");
29  moduleParamList.getParameter<std::string>("direction").setValue("both");
30 
32 }
33 
35 {
36  const TVector3& resultMomentum = result->getMomentum();
37  var<named("pt")>() = resultMomentum.Pt();
38  var<named("theta")>() = resultMomentum.Theta();
39 
40  const std::vector<const SpacePoint*>& spacePoints = result->getHits();
41 
42  var<named("number_of_hits")>() = spacePoints.size();
43 
44  std::vector<bool> layerUsed;
45  layerUsed.resize(7, false);
46 
47  for (const SpacePoint* spacePoint : spacePoints) {
48  layerUsed[spacePoint->getVxdID().getLayerNumber()] = true;
49  }
50  var<named("number_of_holes")>() = std::count(layerUsed.begin(), layerUsed.end(), true);
51 
52  var<named("has_missing_layer_1")>() = layerUsed[1] == 0;
53  var<named("has_missing_layer_2")>() = layerUsed[2] == 0;
54  var<named("has_missing_layer_3")>() = layerUsed[3] == 0;
55  var<named("has_missing_layer_4")>() = layerUsed[4] == 0;
56  var<named("has_missing_layer_5")>() = layerUsed[5] == 0;
57  var<named("has_missing_layer_6")>() = layerUsed[6] == 0;
58 
59  if (spacePoints.empty()) {
60  var<named("last_hit_layer")>() = -1;
61  var<named("first_hit_layer")>() = -1;
62  } else {
63  var<named("last_hit_layer")>() = spacePoints.back()->getVxdID().getLayerNumber();
64  var<named("first_hit_layer")>() = spacePoints.front()->getVxdID().getLayerNumber();
65  }
66 
67  const RecoTrack* cdcTrack = result->getSeed();
68  const auto& cdcHits = cdcTrack->getCDCHitList();
69  B2ASSERT("CDC hits must be present", not cdcHits.empty());
70 
71  const auto sortByCDCLayer = [](const CDCHit * lhs, const CDCHit * rhs) {
72  return lhs->getICLayer() < rhs->getICLayer();
73  };
74 
75  const auto& firstCDCHitIterator = std::min_element(cdcHits.begin(), cdcHits.end(), sortByCDCLayer);
76  var<named("cdc_lowest_layer")>() = (*firstCDCHitIterator)->getICLayer();
77 
78  genfit::MeasuredStateOnPlane mSoP = result->getMSoP();
79  const genfit::MeasuredStateOnPlane& firstCDCHit = result->getSeedMSoP();
80  m_advancer.extrapolateToPlane(mSoP, firstCDCHit.getPlane());
81 
82  const auto& distance = mSoP.getPos() - firstCDCHit.getPos();
83  var<named("distance_to_cdc_track")>() = distance.Mag();
84  var<named("distance_to_cdc_track_xy")>() = distance.Pt();
85 
86  var<named("chi2")>() = result->getChi2();
87  var<named("chi2_vxd_max")>() = result->getMaximalChi2();
88  var<named("chi2_vxd_min")>() = result->getMinimalChi2();
89  var<named("chi2_cdc")>() = cdcTrack->getTrackFitStatus()->getChi2();
90  var<named("weight_sum")>() = result->getWeightSum();
91  return true;
92 }
Belle2::RecoTrack::getTrackFitStatus
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:537
genfit::FitStatus::getChi2
double getChi2() const
Get chi^2 of the fit.
Definition: FitStatus.h:120
Belle2::Advancer::extrapolateToPlane
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:24
genfit::MeasuredStateOnPlane
#StateOnPlane with additional covariance matrix.
Definition: MeasuredStateOnPlane.h:39
Belle2::CDCHit
Class containing the result of the unpacker in raw data and the result of the digitizer in simulation...
Definition: CDCHit.h:51
Belle2::RecoTrack::getCDCHitList
std::vector< Belle2::RecoTrack::UsedCDCHit * > getCDCHitList() const
Return an unsorted list of cdc hits.
Definition: RecoTrack.h:446
Belle2::ModuleParamList::getParameter
ModuleParam< T > & getParameter(const std::string &name) const
Returns a reference to a parameter.
Definition: ModuleParamList.templateDetails.h:90
Belle2::CDCHit::getICLayer
unsigned short getICLayer() const
Getter for iCLayer (0-55).
Definition: CDCHit.h:189
Belle2::TrackFindingCDC::CompositeProcessingSignalListener::addProcessingSignalListener
void addProcessingSignalListener(ProcessingSignalListener *psl)
Register a processing signal listener to be notified.
Definition: CompositeProcessingSignalListener.cc:57
Belle2::TrackFindingCDC::CompositeProcessingSignalListener::initialize
void initialize() override
Receive and dispatch signal before the start of the event processing.
Definition: CompositeProcessingSignalListener.cc:17
Belle2::SpacePoint
SpacePoint typically is build from 1 PXDCluster or 1-2 SVDClusters.
Definition: SpacePoint.h:52
Belle2::RecoTrack
This is the Reconstruction Event-Data Model Track.
Definition: RecoTrack.h:78
Belle2::SVDResultVarSet::initialize
void initialize() override
Receive signal before the start of the event processing.
Definition: SVDResultVarSet.cc:25
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::CKFToSVDResult
Specialized CKF Result for extrapolating into the SVD.
Definition: CKFToSVDResult.h:33
Belle2::SVDResultVarSet::extract
bool extract(const CKFToSVDResult *object) final
Generate and assign the variables from the object.
Definition: SVDResultVarSet.cc:34
Belle2::TrackFindingCDC::VarSet< SVDResultVarNames >::named
constexpr static int named(const char *name)
Getter for the index from the name.
Definition: VarSet.h:88
Belle2::TrackFindingCDC::VarSet< SVDResultVarNames >::var
Float_t & var()
Reference getter for the value of the ith variable. Static version.
Definition: VarSet.h:103
Belle2::ModuleParamList
The Module parameter list class.
Definition: ModuleParamList.h:46
Belle2::Advancer::exposeParameters
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix)
Expose the parameters.
Definition: Advancer.cc:54
Belle2::SVDResultVarSet::m_advancer
SVDAdvancer m_advancer
Findlet for advancing.
Definition: SVDResultVarSet.h:98