Belle II Software development
MCSegmentTripleFilter.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/segmentTriple/MCSegmentTripleFilter.h>
9
10#include <tracking/trackFindingCDC/mclookup/CDCMCSegment2DLookUp.h>
11
12#include <tracking/trackFindingCDC/eventdata/tracks/CDCSegmentTriple.h>
13#include <tracking/trackFindingCDC/eventdata/tracks/CDCAxialSegmentPair.h>
14
15#include <tracking/trackFindingCDC/eventdata/segments/CDCSegment2D.h>
16#include <tracking/trackFindingCDC/eventdata/trajectories/CDCTrajectory3D.h>
17#include <tracking/trackFindingCDC/eventdata/trajectories/CDCTrajectorySZ.h>
18
19#include <tracking/trackFindingCDC/filters/base/MCSymmetricFilter.icc.h>
20
21#include <framework/logging/Logger.h>
22
23using namespace Belle2;
24using namespace TrackFindingCDC;
25
27
29 Super(allowReverse),
30 m_mcAxialSegmentPairFilter(allowReverse)
31{
33}
34
36 const std::string& prefix)
37{
38 m_mcAxialSegmentPairFilter.exposeParameters(moduleParamList, prefix);
39}
40
42{
45}
46
48{
49 const CDCAxialSegment2D* ptrStartSegment = segmentTriple.getStartSegment();
50 const CDCStereoSegment2D* ptrMiddleSegment = segmentTriple.getMiddleSegment();
51 const CDCAxialSegment2D* ptrEndSegment = segmentTriple.getEndSegment();
52
53 const CDCAxialSegment2D& startSegment = *ptrStartSegment;
54 const CDCAxialSegment2D& middleSegment = *ptrMiddleSegment;
55 const CDCAxialSegment2D& endSegment = *ptrEndSegment;
56
58 Weight pairWeight =
59 m_mcAxialSegmentPairFilter(CDCAxialSegmentPair(ptrStartSegment, ptrEndSegment));
60
61 if (std::isnan(pairWeight)) return NAN;
62
64
65 // Check if the segments are aligned correctly along the Monte Carlo track
66 EForwardBackward startToMiddleFBInfo = mcSegmentLookUp.areAlignedInMCTrack(ptrStartSegment, ptrMiddleSegment);
67 if (startToMiddleFBInfo == EForwardBackward::c_Invalid) return NAN;
68
69 EForwardBackward middleToEndFBInfo = mcSegmentLookUp.areAlignedInMCTrack(ptrMiddleSegment, ptrEndSegment);
70 if (middleToEndFBInfo == EForwardBackward::c_Invalid) return NAN;
71
72
73 if (startToMiddleFBInfo != middleToEndFBInfo) return NAN;
74
75
76 if ((startToMiddleFBInfo == EForwardBackward::c_Forward and middleToEndFBInfo == EForwardBackward::c_Forward) or
77 (getAllowReverse() and startToMiddleFBInfo == EForwardBackward::c_Backward and middleToEndFBInfo == EForwardBackward::c_Backward)) {
78
79 // Do fits
80 setTrajectoryOf(segmentTriple);
81
82 Weight cellWeight = startSegment.size() + middleSegment.size() + endSegment.size();
83 return startToMiddleFBInfo > 0 ? cellWeight : -cellWeight;
84 }
85
86 return NAN;
87}
88
89
90
92{
93 if (segmentTriple.getTrajectorySZ().isFitted()) {
94 // SZ trajectory has been fitted before. Skipping
95 // A fit sz trajectory implies a 2d trajectory to be fitted, but not the other way around
96 return;
97 }
98
99 const CDCAxialSegment2D* ptrStartSegment = segmentTriple.getStartSegment();
100 if (not ptrStartSegment) {
101 B2WARNING("Start segment of segmentTriple is nullptr. Could not set fits.");
102 return;
103 }
104
106
107 CDCTrajectory3D trajectory3D = mcSegmentLookUp.getTrajectory3D(ptrStartSegment);
108 segmentTriple.setTrajectory3D(trajectory3D);
109}
The Module parameter list class.
Class representing a pair of reconstructed axial segements in adjacent superlayer.
CDCTrajectory3D getTrajectory3D(const ACDCHitCollection *ptrHits) const
Returns the trajectory of the collection of hits.
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...
Specialisation of the lookup for the truth values of two dimensional segments.
static const CDCMCSegment2DLookUp & getInstance()
Getter for the singletone instance.
A reconstructed sequence of two dimensional hits in one super layer.
Definition: CDCSegment2D.h:39
Class representing a triple of reconstructed segements in adjacent superlayer.
const CDCStereoSegment2D * getMiddleSegment() const
Getter for the middle stereo segment.
const CDCAxialSegment2D * getEndSegment() const
Getter for the end axial segment.
void setTrajectory3D(const CDCTrajectory3D &trajectory3D) const
Setter for the three dimensional helix trajectory.
CDCTrajectorySZ getTrajectorySZ() const
Getter for the linear trajectory in the sz direction.
const CDCAxialSegment2D * getStartSegment() const
Getter for the start axial segment.
Particle full three dimensional trajectory.
bool isFitted() const
Indicates if the line has been fitted.
void addProcessingSignalListener(ProcessingSignalListener *psl)
Register a processing signal listener to be notified.
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) final
Expose the set of parameters of the filter to the module parameter list.
MCAxialSegmentPairFilter m_mcAxialSegmentPairFilter
Instance of the cell filter to reject neighborhoods of false cells.
void initialize() final
Initialize the before event processing.
Weight operator()(const CDCSegmentTriple &segmentTriple) final
Check if the segment triple is aligned in the Monte Carlo track. Signals NAN if not.
void setTrajectoryOf(const CDCSegmentTriple &segmentTriple) const
Sets the trajectories of the segment triple from Monte Carlo information. Is executed for good segmen...
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) final
Expose the parameters to a module.
void setAllowReverse(bool allowReverse) override
Setter for the allow reverse parameter.
MCSegmentTripleFilter(bool allowReverse=true)
Constructor initializing the symmetry flag.
Mixin for filters that use Monte Carlo information.
void initialize() override
Initialize the before event processing.
bool getAllowReverse() const
Getter for the allow reverse parameter.
EForwardBackward
Enumeration to represent the distinct possibilities of the right left passage information.
Abstract base class for different kinds of events.