Belle II Software  release-05-02-19
LowHitsAxialTrackUtil.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2018 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Dmitrii Neverov *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 #include <tracking/trackFindingCDC/processing/LowHitsAxialTrackUtil.h>
11 
12 #include <tracking/trackFindingCDC/eventdata/tracks/CDCTrack.h>
13 #include <tracking/trackFindingCDC/eventdata/hits/CDCWireHit.h>
14 
15 #include <tracking/trackFindingCDC/fitting/CDCRiemannFitter.h>
16 #include <tracking/trackFindingCDC/eventdata/trajectories/CDCTrajectorySZ.h>
17 #include <tracking/trackFindingCDC/eventdata/trajectories/CDCTrajectory2D.h>
18 
19 using namespace Belle2;
20 using namespace TrackFindingCDC;
21 
22 void LowHitsAxialTrackUtil::addCandidateFromHits(const std::vector<const CDCWireHit*>& foundAxialWireHits,
23  const std::vector<const CDCWireHit*>& allAxialWireHits,
24  std::vector<CDCTrack>& axialTracks,
25  bool fromOrigin,
26  bool straight,
27  bool withPostprocessing)
28 {
29  if (foundAxialWireHits.empty()) return;
30 
31  // New track
32  CDCTrack track;
33 
34  // Fit trajectory
35  const CDCRiemannFitter& fitter = CDCRiemannFitter::getFitter(fromOrigin, straight);
36  CDCTrajectory2D trajectory2D = fitter.fit(foundAxialWireHits);
37  track.setStartTrajectory3D(CDCTrajectory3D(trajectory2D, CDCTrajectorySZ::basicAssumption()));
38 
39  // Reconstruct and add hits
40  for (const CDCWireHit* wireHit : foundAxialWireHits) {
41  AutomatonCell& automatonCell = wireHit->getAutomatonCell();
42  if (automatonCell.hasTakenFlag()) continue;
43  CDCRecoHit3D recoHit3D = CDCRecoHit3D::reconstructNearest(wireHit, trajectory2D);
44  track.push_back(std::move(recoHit3D));
45 
46  automatonCell.setTakenFlag(true);
47  }
48  track.sortByArcLength2D();
49 
50  // Change everything again in the postprocessing, if desired
51  bool success = withPostprocessing ? postprocessTrack(track, allAxialWireHits) : true;
52  if (success) {
54  for (const CDCRecoHit3D& recoHit3D : track) {
55  recoHit3D.getWireHit().getAutomatonCell().setTakenFlag(true);
56  }
57  axialTracks.emplace_back(std::move(track));
58  } else {
60  for (const CDCRecoHit3D& recoHit3D : track) {
61  recoHit3D.getWireHit().getAutomatonCell().setMaskedFlag(true);
62  recoHit3D.getWireHit().getAutomatonCell().setTakenFlag(false);
63  }
64  }
65 }
66 
67 bool LowHitsAxialTrackUtil::postprocessTrack([[maybe_unused]] CDCTrack& track, [[maybe_unused]] const
68  std::vector<const CDCWireHit*>& allAxialWireHits)
69 {
70  // No postprocessing yet
71  return true;
72 }
Belle2::TrackFindingCDC::CDCRecoHit3D
Class representing a three dimensional reconstructed hit.
Definition: CDCRecoHit3D.h:62
Belle2::TrackFindingCDC::CDCRiemannFitter
Class implementing the Riemann fit for two dimensional trajectory circle.
Definition: CDCRiemannFitter.h:34
Belle2::TrackFindingCDC::LowHitsAxialTrackUtil::addCandidateFromHits
static void addCandidateFromHits(const std::vector< const CDCWireHit * > &foundAxialWireHits, const std::vector< const CDCWireHit * > &allAxialWireHits, std::vector< CDCTrack > &axialTracks, bool fromOrigin=true, bool straight=true, bool withPostprocessing=true)
Create CDCTrack using CDCWireHit hits and store it in the list.
Definition: LowHitsAxialTrackUtil.cc:22
Belle2::TrackFindingCDC::CDCTrack
Class representing a sequence of three dimensional reconstructed hits.
Definition: CDCTrack.h:51
Belle2::TrackFindingCDC::AutomatonCell::setTakenFlag
void setTakenFlag(bool setTo=true)
Sets the taken flag to the given value. Default value true.
Definition: AutomatonCell.h:234
Belle2::TrackFindingCDC::CDCTrajectorySZ::basicAssumption
static CDCTrajectorySZ basicAssumption()
Constucts a basic assumption, what the z0 start position and the sz slope are, including some broad v...
Definition: CDCTrajectorySZ.cc:29
Belle2::TrackFindingCDC::LowHitsAxialTrackUtil::postprocessTrack
static bool postprocessTrack(CDCTrack &track, const std::vector< const CDCWireHit * > &allAxialWireHits)
Perform all track postprocessing - return whether the track is considered good after the postprocessi...
Definition: LowHitsAxialTrackUtil.cc:67
Belle2::TrackFindingCDC::CDCTrajectory2D
Particle trajectory as it is seen in xy projection represented as a circle.
Definition: CDCTrajectory2D.h:46
Belle2::TrackFindingCDC::CDCRecoHit3D::reconstructNearest
static CDCRecoHit3D reconstructNearest(const CDCWireHit *axialWireHit, const CDCTrajectory2D &trajectory2D)
Reconstruct a three dimensional hit from a wire hit (as in reconstruct(rlWireHit, trajectory2D)),...
Definition: CDCRecoHit3D.cc:132
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::TrackFindingCDC::AutomatonCell
Cell used by the cellular automata.
Definition: AutomatonCell.h:39
Belle2::TrackFindingCDC::AutomatonCell::hasTakenFlag
bool hasTakenFlag() const
Gets the current state of the taken marker flag.
Definition: AutomatonCell.h:249
Belle2::TrackFindingCDC::CDCRiemannFitter::getFitter
static const CDCRiemannFitter & getFitter()
Static getter for a general Riemann fitter.
Definition: CDCRiemannFitter.cc:22
Belle2::TrackFindingCDC::CDCWireHit
Class representing a hit wire in the central drift chamber.
Definition: CDCWireHit.h:65
Belle2::TrackFindingCDC::CDCTrajectory3D
Particle full three dimensional trajectory.
Definition: CDCTrajectory3D.h:47