Belle II Software development
TruthSegmentPairRelationVarSet.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/trackFindingCDC/filters/segmentPairRelation/TruthSegmentPairRelationVarSet.h>
9
10#include <tracking/trackFindingCDC/mclookup/CDCMCSegment2DLookUp.h>
11#include <tracking/trackFindingCDC/mclookup/CDCMCTrackStore.h>
12
13#include <tracking/trackFindingCDC/eventdata/tracks/CDCSegmentPair.h>
14#include <tracking/trackFindingCDC/eventdata/segments/CDCSegment2D.h>
15
16using namespace Belle2;
17using namespace TrackFindingCDC;
18
20{
21 if (not ptrSegmentPairRelation) return false;
22
23 const Relation<const CDCSegmentPair>& segmentPairRelation = *ptrSegmentPairRelation;
24
25 const CDCSegmentPair* ptrFromSegmentPair = segmentPairRelation.getFrom();
26 const CDCSegmentPair* ptrToSegmentPair = segmentPairRelation.getTo();
27
28 const CDCSegmentPair& fromSegmentPair = *ptrFromSegmentPair;
29 const CDCSegmentPair& toSegmentPair = *ptrToSegmentPair;
30
31 const CDCSegment2D& startSegment = *fromSegmentPair.getFromSegment();
32 const CDCSegment2D& middleSegment = *fromSegmentPair.getToSegment();
33 const CDCSegment2D& endSegment = *toSegmentPair.getToSegment();
34
36 const CDCMCTrackStore& mcTrackStore = CDCMCTrackStore::getInstance();
37 const std::map<ITrackType, CDCMCTrackStore::CDCHitVector>& mcTracks =
38 mcTrackStore.getMCTracksByMCParticleIdx();
39
40 CDCTrajectory3D trueTrajectory = mcSegmentLookUp.getTrajectory3D(&middleSegment);
41 var<named("truth_curv")>() = trueTrajectory.getCurvatureXY();
42 var<named("truth_tanl")>() = trueTrajectory.getTanLambda();
43 var<named("truth_z")>() = trueTrajectory.getSupport().z();
44
45 ITrackType startTrackId = mcSegmentLookUp.getMCTrackId(&startSegment);
46 double startMCTrackSize = 0;
47 if (mcTracks.count(startTrackId)) {
48 startMCTrackSize = mcTracks.find(startTrackId)->second.size();
49 }
50
51 ITrackType middleTrackId = mcSegmentLookUp.getMCTrackId(&middleSegment);
52 double middleMCTrackSize = 0;
53 if (mcTracks.count(middleTrackId)) {
54 middleMCTrackSize = mcTracks.find(middleTrackId)->second.size();
55 }
56
57 ITrackType endTrackId = mcSegmentLookUp.getMCTrackId(&endSegment);
58 double endMCTrackSize = 0;
59 if (mcTracks.count(endTrackId)) {
60 endMCTrackSize = mcTracks.find(endTrackId)->second.size();
61 }
62
63 double trackFraction =
64 startSegment.size() / startMCTrackSize +
65 middleSegment.size() / middleMCTrackSize +
66 endSegment.size() / endMCTrackSize;
67
68 var<named("truth_track_fraction")>() = trackFraction;
69 var<named("__weight__")>() = std::isfinite(trackFraction) ? trackFraction : 0;
70 return true;
71}
ITrackType getMCTrackId(const ACDCHitCollection *ptrHits) const
Getter for the Monte Carlo track id matched to this collection of hits.
CDCTrajectory3D getTrajectory3D(const ACDCHitCollection *ptrHits) const
Returns the trajectory of the collection of hits.
Specialisation of the lookup for the truth values of two dimensional segments.
static const CDCMCSegment2DLookUp & getInstance()
Getter for the singletone instance.
Class to organize and present the monte carlo hit information.
static const CDCMCTrackStore & getInstance()
Getter for the singletone instance.
const std::map< ITrackType, Belle2::TrackFindingCDC::CDCMCTrackStore::CDCHitVector > & getMCTracksByMCParticleIdx() const
Getter for the stored Monte Carlo tracks ordered by their Monte Carlo Id.
A reconstructed sequence of two dimensional hits in one super layer.
Definition: CDCSegment2D.h:39
Class representing a pair of one reconstructed axial segment and one stereo segment in adjacent super...
const CDCSegment2D * getToSegment() const
Getter for the to segment.
const CDCSegment2D * getFromSegment() const
Getter for the from segment.
Particle full three dimensional trajectory.
double getCurvatureXY() const
Getter for the curvature as seen from the xy projection.
double getTanLambda() const
Getter for the slope of z over the transverse travel distance s.
Vector3D getSupport() const
Getter for the support point of the trajectory in global coordinates, where arcLength2D = 0.
Type for two related objects.
Definition: Relation.h:21
From * getFrom() const
Getter for the pointer to the from side object.
Definition: Relation.h:59
To * getTo() const
Getter for the pointer to the to side object.
Definition: Relation.h:65
bool extract(const Relation< const CDCSegmentPair > *ptrSegmentPairRelation) final
Generate and assign the contained variables.
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
double z() const
Getter for the z coordinate.
Definition: Vector3D.h:496
Abstract base class for different kinds of events.