Belle II Software development
SimpleSegmentTripleFilter.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/SimpleSegmentTripleFilter.h>
9
10#include <tracking/trackFindingCDC/eventdata/tracks/CDCSegmentTriple.h>
11#include <tracking/trackFindingCDC/eventdata/segments/CDCSegment3D.h>
12#include <tracking/trackFindingCDC/eventdata/segments/CDCSegment2D.h>
13
14#include <tracking/trackFindingCDC/eventdata/trajectories/CDCTrajectorySZ.h>
15
16#include <tracking/trackFindingCDC/topology/CDCWire.h>
17
18#include <framework/logging/Logger.h>
19
20using namespace Belle2;
21using namespace TrackFindingCDC;
22
24{
25 const CDCAxialSegment2D* ptrStartSegment = segmentTriple.getStartSegment();
26 const CDCStereoSegment2D* ptrMiddleSegment = segmentTriple.getMiddleSegment();
27 const CDCAxialSegment2D* ptrEndSegment = segmentTriple.getEndSegment();
28
29 assert(ptrStartSegment);
30 assert(ptrMiddleSegment);
31 assert(ptrEndSegment);
32
33 const CDCAxialSegment2D& startSegment = *ptrStartSegment;
34 const CDCStereoSegment2D& middleSegment = *ptrMiddleSegment;
35 const CDCAxialSegment2D& endSegment = *ptrEndSegment;
36
37 const double toleranceFraction = 0.0;
38
39 // Check if the middle segment lies within the acceptable bounds in angular deviation
40 {
41 //get the remembered fits
42 const CDCTrajectory2D& startFit = startSegment.getTrajectory2D();
43 const CDCTrajectory2D& endFit = endSegment.getTrajectory2D();
44
45 //use only the first and last hit for this check
46 const CDCRecoHit2D& firstHit = middleSegment.front();
47 const CDCRecoHit2D& lastHit = middleSegment.back();
48
49 Vector3D firstRecoPos = firstHit.reconstruct3D(startFit);
50 Vector3D lastRecoPos = lastHit.reconstruct3D(endFit);
51
52 const CDCWire& firstWire = firstHit.getWire();
53 const CDCWire& lastWire = lastHit.getWire();
54
55 const bool agrees =
56 firstWire.isInCellZBounds(firstRecoPos, toleranceFraction) and
57 lastWire.isInCellZBounds(lastRecoPos, toleranceFraction);
58
59 if (not agrees) return NAN;
60 }
61
62 // make more complex judgement on fitness
63
64 // Get the combined fit of start and end axial segment
65 CDCTrajectory2D trajectory2D = getFitter2D().fit(*(segmentTriple.getStartSegment()),
66 *(segmentTriple.getEndSegment()));
67
68 // Check if the middle segment is actually coaligned with the trajectory
69 EForwardBackward fbInfo = trajectory2D.isForwardOrBackwardTo(middleSegment);
70 if (fbInfo != EForwardBackward::c_Forward) return NAN;
71
72 // Reconstruct the middle stereo segment
73 CDCSegment3D reconstructedMiddle;
74 for (const CDCRecoHit2D& recoHit2D : middleSegment) {
75 reconstructedMiddle.push_back(CDCRecoHit3D::reconstruct(recoHit2D, trajectory2D));
76 if (not reconstructedMiddle.back().isInCellZBounds(toleranceFraction)) {
77 B2DEBUG(25, " RecoHit out of CDC");
78 return NAN;
79 }
80 }
81
82 // Fit the sz slope and intercept
83 CDCTrajectorySZ trajectorySZ;
84 getSZFitter().update(trajectorySZ, middleSegment, trajectory2D);
85 segmentTriple.setTrajectory3D(CDCTrajectory3D(trajectory2D, trajectorySZ));
86
87 Weight result = startSegment.size() + middleSegment.size() + endSegment.size();
88
89 return result;
90}
CDCTrajectory2D fit(const CDCObservations2D &observations2D) const
Fits a collection of observation drift circles.
Class representing a two dimensional reconstructed hit in the central drift chamber.
Definition: CDCRecoHit2D.h:47
Vector3D reconstruct3D(const CDCTrajectory2D &trajectory2D, const double z=0) const
Reconstruct the three dimensional position (especially of stereo hits) by determining the z coordinat...
const CDCWire & getWire() const
Getter for the wire the reconstructed hit associated to.
Definition: CDCRecoHit2D.h:175
static CDCRecoHit3D reconstruct(const CDCRecoHit2D &recoHit2D, const CDCTrajectory2D &trajectory2D)
Reconstructs the three dimensional hit from the two dimensional and the two dimensional trajectory.
Definition: CDCRecoHit3D.cc:56
void update(const CDCSegmentPair &segmentPair) const
Updates the trajectory of the axial stereo segment pair inplace.
Definition: CDCSZFitter.cc:163
A reconstructed sequence of two dimensional hits in one super layer.
Definition: CDCSegment2D.h:39
A segment consisting of three dimensional reconstructed hits.
Definition: CDCSegment3D.h:26
Class representing a triple of reconstructed segments 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.
const CDCAxialSegment2D * getStartSegment() const
Getter for the start axial segment.
CDCTrajectory2D & getTrajectory2D() const
Getter for the two dimensional trajectory fitted to the segment.
Definition: CDCSegment.h:69
Particle trajectory as it is seen in xy projection represented as a circle.
EForwardBackward isForwardOrBackwardTo(const AHits &hits) const
Calculates if this trajectory and the hits are coaligned Returns:
Particle full three dimensional trajectory.
Linear trajectory in sz space.
Class representing a sense wire in the central drift chamber.
Definition: CDCWire.h:58
bool isInCellZBounds(const Vector3D &pos3D, const double factor=1) const
Checks whether the position is in the z bounds of the drift cell (scaled by the factor) surrounding t...
Definition: CDCWire.h:295
const CDCSZFitter & getSZFitter() const
Returns the sz fitter instance that is used by this filter.
Weight operator()(const CDCSegmentTriple &segmentTriple) final
Checks if a triple of axial, stereo and axial segments is a good combination to be stored.
const CDCRiemannFitter & getFitter2D() const
Returns the xy fitter instance that is used by this filter.
A three dimensional vector.
Definition: Vector3D.h:33
EForwardBackward
Enumeration to represent the distinct possibilities of the right left passage information.
Abstract base class for different kinds of events.