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