Belle II Software  release-05-01-25
TruthSegmentPairRelationVarSet.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2015 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Oliver Frost *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 #include <tracking/trackFindingCDC/filters/segmentPairRelation/TruthSegmentPairRelationVarSet.h>
11 
12 #include <tracking/trackFindingCDC/mclookup/CDCMCSegment2DLookUp.h>
13 #include <tracking/trackFindingCDC/mclookup/CDCMCTrackStore.h>
14 
15 #include <tracking/trackFindingCDC/eventdata/tracks/CDCSegmentPair.h>
16 #include <tracking/trackFindingCDC/eventdata/segments/CDCSegment2D.h>
17 
18 using namespace Belle2;
19 using namespace TrackFindingCDC;
20 
22 {
23  if (not ptrSegmentPairRelation) return false;
24 
25  const Relation<const CDCSegmentPair>& segmentPairRelation = *ptrSegmentPairRelation;
26 
27  const CDCSegmentPair* ptrFromSegmentPair = segmentPairRelation.getFrom();
28  const CDCSegmentPair* ptrToSegmentPair = segmentPairRelation.getTo();
29 
30  const CDCSegmentPair& fromSegmentPair = *ptrFromSegmentPair;
31  const CDCSegmentPair& toSegmentPair = *ptrToSegmentPair;
32 
33  const CDCSegment2D& startSegment = *fromSegmentPair.getFromSegment();
34  const CDCSegment2D& middleSegment = *fromSegmentPair.getToSegment();
35  const CDCSegment2D& endSegment = *toSegmentPair.getToSegment();
36 
38  const CDCMCTrackStore& mcTrackStore = CDCMCTrackStore::getInstance();
39  const std::map<ITrackType, CDCMCTrackStore::CDCHitVector>& mcTracks =
40  mcTrackStore.getMCTracksByMCParticleIdx();
41 
42  CDCTrajectory3D trueTrajectory = mcSegmentLookUp.getTrajectory3D(&middleSegment);
43  var<named("truth_curv")>() = trueTrajectory.getCurvatureXY();
44  var<named("truth_tanl")>() = trueTrajectory.getTanLambda();
45  var<named("truth_z")>() = trueTrajectory.getSupport().z();
46 
47  ITrackType startTrackId = mcSegmentLookUp.getMCTrackId(&startSegment);
48  double startMCTrackSize = 0;
49  if (mcTracks.count(startTrackId)) {
50  startMCTrackSize = mcTracks.find(startTrackId)->second.size();
51  }
52 
53  ITrackType middleTrackId = mcSegmentLookUp.getMCTrackId(&middleSegment);
54  double middleMCTrackSize = 0;
55  if (mcTracks.count(middleTrackId)) {
56  middleMCTrackSize = mcTracks.find(middleTrackId)->second.size();
57  }
58 
59  ITrackType endTrackId = mcSegmentLookUp.getMCTrackId(&endSegment);
60  double endMCTrackSize = 0;
61  if (mcTracks.count(endTrackId)) {
62  endMCTrackSize = mcTracks.find(endTrackId)->second.size();
63  }
64 
65  double trackFraction =
66  startSegment.size() / startMCTrackSize +
67  middleSegment.size() / middleMCTrackSize +
68  endSegment.size() / endMCTrackSize;
69 
70  var<named("truth_track_fraction")>() = trackFraction;
71  var<named("__weight__")>() = std::isfinite(trackFraction) ? trackFraction : 0;
72  return true;
73 }
Belle2::TrackFindingCDC::Relation::getFrom
From * getFrom() const
Getter for the pointer to the from side object.
Definition: Relation.h:69
Belle2::TrackFindingCDC::CDCTrajectory3D::getTanLambda
double getTanLambda() const
Getter for the slope of z over the transverse travel distance s.
Definition: CDCTrajectory3D.h:299
Belle2::TrackFindingCDC::Relation
Type for two related objects.
Definition: CDCSegment2D.h:37
Belle2::TrackFindingCDC::CDCSegmentPair
Class representing a pair of one reconstructed axial segement and one stereo segment in adjacent supe...
Definition: CDCSegmentPair.h:44
Belle2::TrackFindingCDC::CDCTrajectory3D::getCurvatureXY
double getCurvatureXY() const
Getter for the curvature as seen from the xy projection.
Definition: CDCTrajectory3D.h:305
Belle2::TrackFindingCDC::CDCMCSegment2DLookUp
Specialisation of the lookup for the truth values of two dimensional segments.
Definition: CDCMCSegment2DLookUp.h:33
Belle2::TrackFindingCDC::CDCMCTrackStore
Class to organize and present the monte carlo hit information.
Definition: CDCMCTrackStore.h:38
Belle2::TrackFindingCDC::CDCMCHitCollectionLookUp::getMCTrackId
ITrackType getMCTrackId(const ACDCHitCollection *ptrHits) const
Getter for the Monte Carlo track id matched to this collection of hits.
Definition: CDCMCHitCollectionLookUp.icc.h:101
Belle2::TrackFindingCDC::CDCMCSegment2DLookUp::getInstance
static const CDCMCSegment2DLookUp & getInstance()
Getter for the singletone instance.
Definition: CDCMCSegment2DLookUp.cc:23
Belle2::TrackFindingCDC::CDCSegmentPair::getToSegment
const CDCSegment2D * getToSegment() const
Getter for the to segment.
Definition: CDCSegmentPair.h:132
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::TrackFindingCDC::CDCMCTrackStore::getInstance
static const CDCMCTrackStore & getInstance()
Getter for the singletone instance.
Definition: CDCMCTrackStore.cc:29
Belle2::TrackFindingCDC::CDCMCTrackStore::getMCTracksByMCParticleIdx
const std::map< ITrackType, Belle2::TrackFindingCDC::CDCMCTrackStore::CDCHitVector > & getMCTracksByMCParticleIdx() const
Getter for the stored Monte Carlo tracks ordered by their Monte Carlo Id.
Definition: CDCMCTrackStore.h:66
Belle2::TrackFindingCDC::CDCTrajectory3D::getSupport
Vector3D getSupport() const
Getter for the support point of the trajectory in global coordinates, where arcLength2D = 0.
Definition: CDCTrajectory3D.h:229
Belle2::TrackFindingCDC::CDCSegment2D
A reconstructed sequence of two dimensional hits in one super layer.
Definition: CDCSegment2D.h:40
Belle2::TrackFindingCDC::VarSet< TruthSegmentPairRelationVarNames >::named
constexpr static int named(const char *name)
Getter for the index from the name.
Definition: VarSet.h:88
Belle2::TrackFindingCDC::TruthSegmentPairRelationVarSet::extract
bool extract(const Relation< const CDCSegmentPair > *ptrSegmentPairRelation) final
Generate and assign the contained variables.
Definition: TruthSegmentPairRelationVarSet.cc:21
Belle2::TrackFindingCDC::Relation::getTo
To * getTo() const
Getter for the pointer to the to side object.
Definition: Relation.h:75
Belle2::TrackFindingCDC::Vector3D::z
double z() const
Getter for the z coordinate.
Definition: Vector3D.h:488
Belle2::TrackFindingCDC::VarSet< TruthSegmentPairRelationVarNames >::var
Float_t & var()
Reference getter for the value of the ith variable. Static version.
Definition: VarSet.h:103
Belle2::TrackFindingCDC::CDCSegmentPair::getFromSegment
const CDCSegment2D * getFromSegment() const
Getter for the from segment.
Definition: CDCSegmentPair.h:120
Belle2::TrackFindingCDC::CDCTrajectory3D
Particle full three dimensional trajectory.
Definition: CDCTrajectory3D.h:47
Belle2::TrackFindingCDC::CDCMCHitCollectionLookUp::getTrajectory3D
CDCTrajectory3D getTrajectory3D(const ACDCHitCollection *ptrHits) const
Returns the trajectory of the collection of hits.
Definition: CDCMCHitCollectionLookUp.icc.h:359