Belle II Software  release-05-01-25
TruthAxialSegmentPairVarSet.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/axialSegmentPair/TruthAxialSegmentPairVarSet.h>
11 
12 #include <tracking/trackFindingCDC/mclookup/CDCMCHitLookUp.h>
13 #include <tracking/trackFindingCDC/mclookup/CDCMCSegment2DLookUp.h>
14 #include <tracking/trackFindingCDC/mclookup/CDCMCTrackStore.h>
15 
16 #include <tracking/trackFindingCDC/mclookup/CDCMCManager.h>
17 
18 #include <tracking/trackFindingCDC/eventdata/tracks/CDCAxialSegmentPair.h>
19 #include <tracking/trackFindingCDC/eventdata/segments/CDCSegment2D.h>
20 #include <tracking/trackFindingCDC/eventdata/hits/CDCRecoHit2D.h>
21 #include <tracking/trackFindingCDC/eventdata/hits/CDCWireHit.h>
22 #include <tracking/trackFindingCDC/eventdata/trajectories/CDCTrajectory3D.h>
23 
24 #include <tracking/trackFindingCDC/numerics/Angle.h>
25 
26 #include <cdc/dataobjects/CDCSimHit.h>
27 
28 using namespace Belle2;
29 using namespace TrackFindingCDC;
30 
32 {
35 }
36 
38 {
41 }
42 
44 {
45  if (not ptrAxialSegmentPair) return false;
46 
47  const CDCAxialSegmentPair& segmentPair = *ptrAxialSegmentPair;
48 
49  const CDCSegment2D* ptrFromSegment = segmentPair.getStartSegment();
50  const CDCSegment2D* ptrToSegment = segmentPair.getEndSegment();
51 
52  const CDCSegment2D& fromSegment = *ptrFromSegment;
53  const CDCSegment2D& toSegment = *ptrToSegment;
54 
55  const CDCMCHitLookUp& mcHitLookUp = CDCMCHitLookUp::getInstance();
57  const CDCMCTrackStore& mcTrackStore = CDCMCTrackStore::getInstance();
58  const std::map<ITrackType, CDCMCTrackStore::CDCHitVector>& mcTracks =
59  mcTrackStore.getMCTracksByMCParticleIdx();
60 
61  CDCTrajectory3D trueTrajectory = mcSegmentLookUp.getTrajectory3D(&toSegment);
62  var<named("truth_curv")>() = trueTrajectory.getCurvatureXY();
63  var<named("truth_tanl")>() = trueTrajectory.getTanLambda();
64  var<named("truth_z")>() = trueTrajectory.getSupport().z();
65 
66  // Hits
67  const CDCRecoHit2D& fromLastHit = fromSegment.back();
68  const CDCRecoHit2D& toFirstHit = toSegment.front();
69 
70  const CDCSimHit* fromSimHit = mcHitLookUp.getClosestPrimarySimHit(fromLastHit.getWireHit().getHit());
71  const CDCSimHit* toSimHit = mcHitLookUp.getClosestPrimarySimHit(toFirstHit.getWireHit().getHit());
72  if (fromSimHit and toSimHit) {
73  double truthFromAlpha = -fromSimHit->getPosTrack().DeltaPhi(fromSimHit->getMomentum());
74  double truthToAlpha = -toSimHit->getPosTrack().DeltaPhi(toSimHit->getMomentum());
75  var<named("truth_from_alpha")>() = truthFromAlpha;
76  var<named("truth_to_alpha")>() = truthToAlpha;
77  var<named("truth_delta_alpha")>() = AngleUtil::normalised(truthToAlpha - truthFromAlpha);
78  } else {
79  var<named("truth_from_alpha")>() = NAN;
80  var<named("truth_to_alpha")>() = NAN;
81  var<named("truth_delta_alpha")>() = NAN;
82  }
83 
84  ITrackType fromTrackId = mcSegmentLookUp.getMCTrackId(&fromSegment);
85  double fromMCTrackSize = 0;
86  if (mcTracks.count(fromTrackId)) {
87  fromMCTrackSize = mcTracks.find(fromTrackId)->second.size();
88  }
89 
90  ITrackType toTrackId = mcSegmentLookUp.getMCTrackId(&toSegment);
91  double toMCTrackSize = 0;
92  if (mcTracks.count(toTrackId)) {
93  toMCTrackSize = mcTracks.find(toTrackId)->second.size();
94  }
95 
96  double trackFraction = fromSegment.size() / fromMCTrackSize + toSegment.size() / toMCTrackSize;
97  var<named("truth_track_fraction")>() = trackFraction;
98 
99  double fromRLPurity = mcSegmentLookUp.getRLPurity(&fromSegment);
100  double toRLPurity = mcSegmentLookUp.getRLPurity(&toSegment);
101  if (fromRLPurity < 0.5) fromRLPurity = 0;
102  if (toRLPurity < 0.5) toRLPurity = 0;
103 
104  EForwardBackward pairFBInfo = mcSegmentLookUp.areAlignedInMCTrack(&fromSegment, &toSegment);
105 
106  // False combinations have always full weight - true combinations are down weighted for their rl purity
107  double weight = pairFBInfo != EForwardBackward::c_Invalid ? fromRLPurity * toRLPurity : 1;
108  var<named("__weight__")>() = weight;
109 
110  return true;
111 }
Belle2::TrackFindingCDC::TruthAxialSegmentPairVarSet::beginEvent
void beginEvent() final
Signal the begin of a new event.
Definition: TruthAxialSegmentPairVarSet.cc:37
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::CDCAxialSegmentPair::getStartSegment
const CDCAxialSegment2D * getStartSegment() const
Getter for the start segment.
Definition: CDCAxialSegmentPair.h:99
Belle2::CDCSimHit::getPosTrack
TVector3 getPosTrack() const
The method to get position on the track.
Definition: CDCSimHit.h:234
Belle2::TrackFindingCDC::CDCTrajectory3D::getCurvatureXY
double getCurvatureXY() const
Getter for the curvature as seen from the xy projection.
Definition: CDCTrajectory3D.h:305
Belle2::TrackFindingCDC::CDCMCHitLookUp::getClosestPrimarySimHit
const CDCSimHit * getClosestPrimarySimHit(const CDCHit *ptrHit) const
Getter for the closest simulated hit of a primary particle to the given hit - may return nullptr of n...
Definition: CDCMCHitLookUp.cc:103
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::CDCWireHit::getHit
const CDCHit * getHit() const
Getter for the CDCHit pointer into the StoreArray.
Definition: CDCWireHit.h:167
Belle2::TrackFindingCDC::NForwardBackward::EForwardBackward
EForwardBackward
Enumeration to represent the distinct possibilities of the right left passage information.
Definition: EForwardBackward.h:35
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::CDCSimHit
Example Detector.
Definition: CDCSimHit.h:33
Belle2::TrackFindingCDC::TruthAxialSegmentPairVarSet::extract
bool extract(const CDCAxialSegmentPair *ptrAxialSegmentPair) final
Generate and assign the contained variables.
Definition: TruthAxialSegmentPairVarSet.cc:43
Belle2::TrackFindingCDC::CompositeProcessingSignalListener::initialize
void initialize() override
Receive and dispatch signal before the start of the event processing.
Definition: CompositeProcessingSignalListener.cc:17
Belle2::TrackFindingCDC::CDCMCManager::requireTruthInformation
void requireTruthInformation()
Require the mc information store arrays.
Definition: CDCMCManager.cc:117
Belle2::TrackFindingCDC::CDCAxialSegmentPair::getEndSegment
const CDCAxialSegment2D * getEndSegment() const
Getter for the end segment.
Definition: CDCAxialSegmentPair.h:111
Belle2::TrackFindingCDC::CDCMCManager::fill
void fill()
Fill Monte Carlo look up maps from the DataStore.
Definition: CDCMCManager.cc:137
Belle2::TrackFindingCDC::CDCMCHitCollectionLookUp::areAlignedInMCTrack
EForwardBackward areAlignedInMCTrack(const ACDCHitCollection *ptrFromHits, const ACDCHitCollection *ptrToHits) const
Returns if the second collection of hits follows the first collection of hits in their common Monte C...
Definition: CDCMCHitCollectionLookUp.icc.h:210
Belle2::TrackFindingCDC::CDCRecoHit2D
Class representing a two dimensional reconstructed hit in the central drift chamber.
Definition: CDCRecoHit2D.h:57
Belle2::TrackFindingCDC::CDCAxialSegmentPair
Class representing a pair of reconstructed axial segements in adjacent superlayer.
Definition: CDCAxialSegmentPair.h:41
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::TrackFindingCDC::CDCMCHitLookUp
Interface class to the Monte Carlo information for individual hits.
Definition: CDCMCHitLookUp.h:41
Belle2::TrackFindingCDC::CDCMCTrackStore::getInstance
static const CDCMCTrackStore & getInstance()
Getter for the singletone instance.
Definition: CDCMCTrackStore.cc:29
Belle2::TrackFindingCDC::CDCMCManager::getInstance
static CDCMCManager & getInstance()
Getter for the singletone instance.
Definition: CDCMCManager.cc:76
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::CompositeProcessingSignalListener::beginEvent
void beginEvent() override
Receive and dispatch signal for the start of a new event.
Definition: CompositeProcessingSignalListener.cc:33
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::CDCMCHitLookUp::getInstance
static const CDCMCHitLookUp & getInstance()
Getter for the singletone instance.
Definition: CDCMCHitLookUp.cc:32
Belle2::TrackFindingCDC::CDCSegment2D
A reconstructed sequence of two dimensional hits in one super layer.
Definition: CDCSegment2D.h:40
Belle2::TrackFindingCDC::VarSet< TruthAxialSegmentPairVarNames >::named
constexpr static int named(const char *name)
Getter for the index from the name.
Definition: VarSet.h:88
Belle2::TrackFindingCDC::Vector3D::z
double z() const
Getter for the z coordinate.
Definition: Vector3D.h:488
Belle2::CDCSimHit::getMomentum
TVector3 getMomentum() const
The method to get momentum.
Definition: CDCSimHit.h:210
Belle2::TrackFindingCDC::VarSet< TruthAxialSegmentPairVarNames >::var
Float_t & var()
Reference getter for the value of the ith variable. Static version.
Definition: VarSet.h:103
Belle2::TrackFindingCDC::CDCMCHitCollectionLookUp::getRLPurity
double getRLPurity(const ACDCHitCollection *ptrHits) const
Getter for the right left passge purity which respects the forward backward reconstruction.
Definition: CDCMCHitCollectionLookUp.icc.h:129
Belle2::TrackFindingCDC::TruthAxialSegmentPairVarSet::initialize
void initialize() final
Require the Monte Carlo information before the event processing starts.
Definition: TruthAxialSegmentPairVarSet.cc:31
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
Belle2::TrackFindingCDC::CDCRecoHit2D::getWireHit
const CDCWireHit & getWireHit() const
Getter for the wire hit assoziated with the reconstructed hit.
Definition: CDCRecoHit2D.h:203
Belle2::TrackFindingCDC::AngleUtil::normalised
static double normalised(const double angle)
Normalise an angle to lie in the range from [-pi, pi].
Definition: Angle.h:43