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