8#include <tracking/trackFindingCDC/eventdata/tracks/CDCTrack.h>
10#include <tracking/trackFindingCDC/eventdata/tracks/CDCSegmentTriple.h>
11#include <tracking/trackFindingCDC/eventdata/tracks/CDCSegmentPair.h>
12#include <tracking/trackFindingCDC/eventdata/segments/CDCSegment3D.h>
13#include <tracking/trackFindingCDC/eventdata/segments/CDCSegment2D.h>
15#include <tracking/trackFindingCDC/eventdata/hits/CDCRecoHit3D.h>
16#include <tracking/trackFindingCDC/eventdata/hits/CDCRecoHit2D.h>
17#include <tracking/trackFindingCDC/eventdata/hits/CDCWireHit.h>
19#include <tracking/trackFindingCDC/eventdata/trajectories/CDCTrajectory3D.h>
20#include <tracking/trackFindingCDC/eventdata/trajectories/CDCTrajectory2D.h>
22#include <tracking/trackFindingCDC/topology/ISuperLayer.h>
24#include <tracking/trackFindingCDC/geometry/PerigeeCircle.h>
25#include <tracking/trackFindingCDC/geometry/UncertainPerigeeCircle.h>
26#include <tracking/trackFindingCDC/geometry/Vector3D.h>
28#include <tracking/trackFindingCDC/ca/AutomatonCell.h>
30#include <tracking/trackFindingCDC/numerics/FloatComparing.h>
32#include <tracking/trackFindingCDC/utilities/MayBePtr.h>
34#include <framework/logging/Logger.h>
45 namespace TrackFindingCDC {
52using namespace TrackFindingCDC;
61 B2ASSERT(
"Did not expect segment == nullptr", segment);
66 track.back().shiftArcLength2D(perpSOffset);
83 double appendReconstructedAverage(
const CDCSegment2D* segment,
89 B2ASSERT(
"Did not expect segment == nullptr", segment);
101 double parallelFirstPerpS = parallelFirstRecoHit3D.
getArcLength2D();
103 double parallelPerpSOffSet = firstPerpS + perpSOffset - parallelFirstPerpS;
127 double newPrepSOffset = track.back().getArcLength2D() - parallelLastRecoHit3D.
getArcLength2D();
129 return newPrepSOffset;
139 m_startTrajectory3D(segment.getTrajectory2D()),
140 m_endTrajectory3D(segment.getTrajectory2D())
142 if (segment.empty())
return;
155 const CDCRLWireHit& rlWireHit = recoHit2D.getRLWireHit();
156 Vector3D recoPos3D(recoHit2D.getRecoPos2D(), 0.0);
166 if (trackPath.empty()) {
168 }
else if (trackPath.size() == 1) {
172 for (
const CDCTrack* track : trackPath) {
174 result.push_back(recoHit3D);
179 CDCTrajectory3D startTrajectory3D = trackPath.front()->getStartTrajectory3D();
180 CDCTrajectory3D endTrajectory3D = trackPath.back()->getStartTrajectory3D();
182 double resetPerpSOffset =
184 result.setStartTrajectory3D(startTrajectory3D);
187 result.setEndTrajectory3D(endTrajectory3D);
201 if (segmentTriplePath.empty())
return track;
203 Path<const CDCSegmentTriple>::const_iterator itSegmentTriple = segmentTriplePath.begin();
210 double perpSOffset = 0.0;
220 while (itSegmentTriple != segmentTriplePath.end()) {
223 B2ASSERT(
"Two segment triples do not overlap in their axial segments",
226 perpSOffset = appendReconstructedAverage(firstSegmentTriple->
getEndSegment(),
236 firstSegmentTriple = secondSegmentTriple;
250 double resetPerpSOffset = startTrajectory3D.
setLocalOrigin(track.front().getRecoPos3D());
251 track.setStartTrajectory3D(startTrajectory3D);
254 track.setEndTrajectory3D(endTrajectory3D);
268 if (segmentPairPath.empty())
return track;
270 Path<const CDCSegmentPair>::const_iterator itSegmentPair = segmentPairPath.begin();
277 double perpSOffset = 0.0;
282 while (itSegmentPair != segmentPairPath.end()) {
286 B2ASSERT(
"Two segment pairs do not overlap in their segments",
289 perpSOffset = appendReconstructedAverage(firstSegmentPair->
getToSegment(),
295 firstSegmentPair = secondSegmentPair;
307 double resetPerpSOffset = startTrajectory3D.
setLocalOrigin(track.front().getRecoPos3D());
308 track.setStartTrajectory3D(startTrajectory3D);
312 track.setEndTrajectory3D(endTrajectory3D);
323 vector<CDCSegment3D> result;
324 ISuperLayer lastISuperLayer = -1;
327 if (result.empty() or lastISuperLayer != iSuperLayer) {
328 result.emplace_back();
330 result.back().push_back(recoHit3D);
331 lastISuperLayer = iSuperLayer;
357 std::reverse(begin(), end());
364 return reversedTrack;
369 auto hasWireHit = [&wireHit](
const CDCRecoHit3D & recoHit3D) {
372 auto itRecoHit3D = std::find_if(this->begin(), this->end(), hasWireHit);
373 return itRecoHit3D == this->end() ? nullptr : &*itRecoHit3D;
414 std::stable_sort(begin(),
419 return lessFloatHighNaN(arcLength, otherArcLength);
426 if (doForAllTracks or startTrajectory2D.
isCurler(1.1)) {
428 if (std::isfinite(shiftValue)) {
void setTakenFlag(bool setTo=true)
Sets the taken flag to the given value. Default value true.
void setMaskedFlag(bool setTo=true)
Sets the masked flag to the given value. Default value true.
void unsetMaskedFlag()
Resets the masked flag to false.
bool hasMaskedFlag() const
Gets the current state of the masked marker flag.
Class representing an oriented hit wire including a hypotheses whether the causing track passes left ...
Class representing a two dimensional reconstructed hit in the central drift chamber.
Vector2D getRecoPos2D() const
Getter for the position in the reference plane.
Class representing a three dimensional reconstructed hit.
static CDCRecoHit3D average(const CDCRecoHit3D &first, const CDCRecoHit3D &second)
Constructs the average of two reconstructed hit positions.
const CDCWireHit & getWireHit() const
Getter for the wire hit.
const Vector3D & getRecoPos3D() const
Getter for the 3d position of the hit.
ISuperLayer getISuperLayer() const
Getter for the superlayer id.
void shiftArcLength2D(double arcLength2DOffSet)
Adjust the travel distance by the given value.
void reverse()
Turns the orientation in place.
static CDCRecoHit3D reconstruct(const CDCRecoHit2D &recoHit2D, const CDCTrajectory2D &trajectory2D)
Reconstructs the three dimensional hit from the two dimensional and the two dimensional trajectory.
double getArcLength2D() const
Getter for the travel distance in the xy projection.
bool hasWireHit(const CDCWireHit &wireHit) const
Checks if the reconstructed hit is associated with the give wire hit.
void setArcLength2D(const double arcLength2D)
Setter for the travel distance in the xy projection.
A reconstructed sequence of two dimensional hits in one super layer.
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.
CDCTrajectory3D & getTrajectory3D() const
Getter for the three dimensional trajectory.
const CDCSegment2D * getFromSegment() const
Getter for the from segment.
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.
const CDCTrajectory3D & getTrajectory3D() const
Getter for the three dimensional helix trajectory.
const CDCAxialSegment2D * getStartSegment() const
Getter for the start axial segment.
Class representing a sequence of three dimensional reconstructed hits.
std::vector< CDCSegment3D > splitIntoSegments() const
Splits the track into segments.
CDCTrack reversed() const
Return a reversed copy of the track.
void reverse()
Reverse the track inplace.
const CDCTrajectory3D & getStartTrajectory3D() const
Getter for the two dimensional trajectory.
void forwardTakenFlag(bool takenFlag=true) const
Set the taken flag of all hits belonging to this track to the given value (default true),...
AutomatonCell & getAutomatonCell() const
Mutable getter for the automaton cell.
void sortByArcLength2D()
Sort the recoHits according to their perpS information.
void shiftToPositiveArcLengths2D(bool doForAllTracks=false)
Set all arcLengths to have positive values by shifting them by pi*radius if they are negative.
void setAndForwardMaskedFlag() const
Set the masked flag of the automaton cell of this segment and forward the masked flag to all containe...
CDCTrajectory3D m_startTrajectory3D
Memory for the three dimensional trajectory at the start of the track.
void unsetAndForwardMaskedFlag() const
Unset the masked flag of the automaton cell of this segment and of all contained wire hits.
MayBePtr< const CDCRecoHit3D > find(const CDCWireHit &wireHit) const
Finds the first CDCRecoHit3D that is based on the given wire hit - nullptr if none.
static CDCTrack condense(const Path< const CDCTrack > &trackPath)
concatenates several tracks from a path
CDCTrajectory3D m_endTrajectory3D
Memory for the three dimensional trajectory at the end of the track.
void receiveMaskedFlag() const
Check all contained wire hits if one has the masked flag.
CDCTrack()=default
Default constructor for ROOT compatibility.
Particle trajectory as it is seen in xy projection represented as a circle.
bool isCurler(double factor=1) const
Checks if the trajectory leaves the outer radius of the CDC times the given tolerance factor.
const UncertainPerigeeCircle & getLocalCircle() const
Getter for the circle in local coordinates.
Particle full three dimensional trajectory.
double calcArcLength2D(const Vector3D &point) const
Calculate the travel distance from the start position of the trajectory.
void reverse()
Reverses the trajectory in place.
CDCTrajectory2D getTrajectory2D() const
Getter for the two dimensional trajectory.
double setLocalOrigin(const Vector3D &localOrigin)
Setter for the origin of the local coordinate system.
Class representing a hit wire in the central drift chamber.
AutomatonCell & getAutomatonCell() const
Mutable getter for the automaton cell.
double arcLengthPeriod() const
Getter for the arc length for a full round of the circle.
A three dimensional vector.
Abstract base class for different kinds of events.