Belle II Software  release-05-01-25
TrackQualityAsserter.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2015 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Nils Braun *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 #include <tracking/trackFindingCDC/findlets/minimal/TrackQualityAsserter.h>
11 
12 #include <tracking/trackFindingCDC/processing/TrackQualityTools.h>
13 #include <tracking/trackFindingCDC/eventdata/tracks/CDCTrack.h>
14 #include <tracking/trackFindingCDC/eventdata/hits/CDCWireHit.h>
15 
16 #include <tracking/trackFindingCDC/utilities/Algorithms.h>
17 #include <tracking/trackFindingCDC/utilities/StringManipulation.h>
18 
19 #include <framework/core/ModuleParamList.templateDetails.h>
20 
21 using namespace Belle2;
22 using namespace TrackFindingCDC;
23 
25  : m_param_corrections( {"LayerBreak", "LargeAngle", "OneSuperlayer", "Small"})
26 , m_param_onlyNotFittedTracks(false)
27 {
28 }
29 
31 {
32  return "Many tracks in the CDC can not be fitted. For fitting them, we remove "
33  "parts of the hits or maybe the whole track.";
34 }
35 
37  const std::string& prefix)
38 {
39  moduleParamList->addParameter(prefixed(prefix, "corrections"),
41  "The list of corrections to apply. "
42  "Choose from LayerBreak, LargeAngle, "
43  "LargeBreak2, OneSuperlayer, Small, B2B, "
44  "MoveToNextAxial, None, Split, and "
45  "ArcLength2D.",
47 
48  moduleParamList->addParameter(prefixed(prefix, "onlyNotFittedTracks"),
50  "Flag to apply the corrections only to not fitted tracks.",
52 }
53 
54 void TrackQualityAsserter::apply(std::vector<CDCTrack>& tracks)
55 {
56  // Only use the not fitted tracks if set - was unused
57  /*
58  if (m_param_onlyNotFittedTracks) {
59  tracks.erase(std::remove_if(tracks.begin(), tracks.end(), [](const CDCTrack & track) {
60  const genfit::TrackCand* trackCand = track.getRelatedGenfitTrackCandidate();
61  if (trackCand == nullptr) {
62  B2WARNING("Can not decide whether to correct this track or not, as it has no related genfit::TrackCand. Skipping.");
63  return true;
64  }
65  RecoTrack* recoTrack = DataStore::Instance().getRelated<RecoTrack>(trackCand, "GF2Tracks");
66  if (recoTrack == nullptr) {
67  B2WARNING("Can not decide whether to correct this track or not, as it has no related RecoTrack. Skipping.");
68  return true;
69  }
70 
71  return false;
72  }), tracks.end());
73  }
74  */
75 
76  std::vector<CDCTrack> splittedTracks;
77 
78  for (CDCTrack& track : tracks) {
79  // Reset all hits to not have a background hit (what they should not have anyway)
81 
82  for (const std::string& correctorFunction : m_param_corrections) {
83  if (correctorFunction == "LayerBreak") {
84  // GOOD
86  } else if (correctorFunction == "LargeAngle") {
87  // GOOD
89  } else if (correctorFunction == "LargeBreak2") {
90  // GOOD
92  } else if (correctorFunction == "OneSuperlayer") {
93  // GOOD
95  } else if (correctorFunction == "Small") {
96  // GOOD
98  } else if (correctorFunction == "B2B") {
99  // GOOD
101  } else if (correctorFunction == "MoveToNextAxial") {
102  // GOOD
104  } else if (correctorFunction == "None") {
105  // GOOD :-)
106  ;
107  } else if (correctorFunction == "Split") {
108  // Working, but makes it not better
109  TrackQualityTools::splitSecondHalfOfTrack(track, splittedTracks);
110  } else if (correctorFunction == "ArcLength2D") {
111  // ???
113  } else if (correctorFunction == "CDCWall") {
114  // BAD
115  B2FATAL("Do not use this function as it is not working probably.");
117  } else {
118  B2FATAL("Do not know corrector function " << correctorFunction);
119  }
120 
121  // Delete all hits that were marked
122  erase_remove_if(track, [](const CDCRecoHit3D & recoHit3D) -> bool {
123  AutomatonCell& automatonCell = recoHit3D.getWireHit().getAutomatonCell();
124  if (automatonCell.hasAssignedFlag())
125  {
126  automatonCell.unsetTakenFlag();
127  return true;
128  }
129  return false;
130  });
131 
133  } // correctorFunction
134  } // track
135 
136  erase_remove_if(tracks, [](const CDCTrack & track) -> bool { return track.size() < 3; });
137 
138  for (const CDCTrack& splittedTrack : splittedTracks) {
139  tracks.push_back(splittedTrack);
140  }
141 }
Belle2::TrackFindingCDC::TrackQualityTools::removeArcLength2DHoles
static void removeArcLength2DHoles(CDCTrack &track, double m_maximumArcLength2DDistance=10)
Remove all hits that come after a large hole in the two dimensional arc length.
Definition: TrackQualityTools.cc:339
Belle2::TrackFindingCDC::TrackQualityAsserter::m_param_onlyNotFittedTracks
bool m_param_onlyNotFittedTracks
Parameter : Flag to use the corrections only for not fitted tracks.
Definition: TrackQualityAsserter.h:74
Belle2::TrackFindingCDC::TrackQualityTools::removeHitsOnTheWrongSide
static void removeHitsOnTheWrongSide(CDCTrack &track)
Remove all hits that are on the wrong side of the detector (so to say: "beyond the IP").
Definition: TrackQualityTools.cc:323
Belle2::TrackFindingCDC::CDCRecoHit3D
Class representing a three dimensional reconstructed hit.
Definition: CDCRecoHit3D.h:62
Belle2::TrackFindingCDC::AutomatonCell::hasAssignedFlag
bool hasAssignedFlag() const
Gets the current state of the already assigned marker flag.
Definition: AutomatonCell.h:150
Belle2::TrackFindingCDC::CDCTrack
Class representing a sequence of three dimensional reconstructed hits.
Definition: CDCTrack.h:51
Belle2::TrackFindingCDC::TrackQualityTools::splitSecondHalfOfTrack
static void splitSecondHalfOfTrack(CDCTrack &track, std::vector< CDCTrack > &tracks)
Trasan did output curlers in split two halves - this method can be used to mimic this.
Definition: TrackQualityTools.cc:27
Belle2::TrackFindingCDC::TrackQualityTools::removeHitsAfterCDCWall
static void removeHitsAfterCDCWall(CDCTrack &track, double outerCylindricalRFactor=1.1)
Remove all hits which can not belong to the track, as the particle can not exit and enter the CDC aga...
Definition: TrackQualityTools.cc:118
Belle2::TrackFindingCDC::CDCRecoHit3D::getWireHit
const CDCWireHit & getWireHit() const
Getter for the wire hit.
Definition: CDCRecoHit3D.h:248
Belle2::TrackFindingCDC::TrackQualityAsserter::exposeParameters
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) final
Expose the parameters to a module.
Definition: TrackQualityAsserter.cc:36
Belle2::TrackFindingCDC::TrackQualityAsserter::m_param_corrections
std::vector< std::string > m_param_corrections
Parameter : The corrections to use.
Definition: TrackQualityAsserter.h:71
Belle2::TrackFindingCDC::TrackQualityTools::normalizeHitsAndResetTrajectory
static void normalizeHitsAndResetTrajectory(CDCTrack &track)
Update all hits to have a positive perpS, a taken flag and no background flag Also set the trajectory...
Definition: TrackQualityTools.cc:55
Belle2::TrackFindingCDC::TrackQualityTools::removeHitsAfterLayerBreak
static void removeHitsAfterLayerBreak(CDCTrack &track, double m_maximumArcLength2DDistance=10)
Delete all hits after a large layer break.
Definition: TrackQualityTools.cc:198
Belle2::TrackFindingCDC::TrackQualityTools::moveToNextAxialLayer
static void moveToNextAxialLayer(CDCTrack &track)
Delete hits of the first superlayer if it is a stereo one (fitting does not work very well when start...
Definition: TrackQualityTools.cc:16
Belle2::TrackFindingCDC::TrackQualityAsserter::getDescription
std::string getDescription() override
Get the description of the findlet.
Definition: TrackQualityAsserter.cc:30
Belle2::ModuleParamList::addParameter
void addParameter(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module list.
Definition: ModuleParamList.templateDetails.h:38
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::TrackFindingCDC::TrackQualityTools::removeHitsAfterLayerBreak2
static void removeHitsAfterLayerBreak2(CDCTrack &track)
Delete all hits after a large layer break.
Definition: TrackQualityTools.cc:154
Belle2::TrackFindingCDC::AutomatonCell
Cell used by the cellular automata.
Definition: AutomatonCell.h:39
Belle2::TrackFindingCDC::TrackQualityTools::removeHitsIfSmall
static void removeHitsIfSmall(CDCTrack &track, unsigned int minimalHits=7)
Delete a track fully of the number of hits is below minimalHits.
Definition: TrackQualityTools.cc:264
Belle2::TrackFindingCDC::TrackQualityAsserter::TrackQualityAsserter
TrackQualityAsserter()
Constructor setting up the default parameters.
Definition: TrackQualityAsserter.cc:24
Belle2::TrackFindingCDC::TrackQualityTools::removeHitsIfOnlyOneSuperLayer
static void removeHitsIfOnlyOneSuperLayer(CDCTrack &track)
Remove the whole track if it only consists of one superlayer.
Definition: TrackQualityTools.cc:301
Belle2::ModuleParamList
The Module parameter list class.
Definition: ModuleParamList.h:46
Belle2::TrackFindingCDC::TrackQualityAsserter::apply
void apply(std::vector< CDCTrack > &tracks) final
Main function to clean up the tracks.
Definition: TrackQualityAsserter.cc:54
Belle2::TrackFindingCDC::TrackQualityTools::removeHitsInTheBeginningIfAngleLarge
static void removeHitsInTheBeginningIfAngleLarge(CDCTrack &track, double maximalAngle=0.7)
If the angle between two following hits is larger than maximalAngle, delete all hits before (!...
Definition: TrackQualityTools.cc:275