Belle II Software development
TrackInspector.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/TrackInspector.h>
9
10#include <tracking/trackingUtilities/eventdata/tracks/CDCTrack.h>
11
12#include <framework/core/ModuleParamList.templateDetails.h>
13#include <tracking/trackingUtilities/utilities/StringManipulation.h>
14
15#include <TMultiGraph.h>
16#include <TGraph.h>
17#include <TCanvas.h>
18#include <TAxis.h>
19#include <vector>
20
21using namespace Belle2;
22using namespace TrackFindingCDC;
23using namespace TrackingUtilities;
24
26{
27 return "Findlet for printing out CDCtracks";
28}
29
30void TrackInspector::exposeParameters(ModuleParamList* moduleParamList, const std::string& prefix)
31{
32 moduleParamList->addParameter(prefixed(prefix, "debugDraw"),
34 "Draw found hit positions of the track",
36}
37
38void TrackInspector::apply(std::vector<CDCTrack>& tracks)
39{
41 static int nevent(0);
42 if (tracks.size() == 0) {
43 nevent++;
44 return; //Nothing to draw
45 }
46 if (not m_param_debugDraw) return; //Nothing to draw
47 TCanvas canvA("axialCanvas", "CDC axial hits in an event", 0, 0, 1440, 1080);
48 TCanvas canvS("stereoCanvas", "CDC stereo hits in an event", 0, 0, 1440, 1080);
49 TMultiGraph* mgA = new TMultiGraph("axialTracks", "CDC axial tracks in the event;X, cm;Y, cm");
50 TMultiGraph* mgS = new TMultiGraph("stereoTracks", "CDC stereo tracks in the event;Z, cm;R, cm");
51 for (CDCTrack& track : tracks) {
52 TGraph* grA = new TGraph();
53 TGraph* grS = new TGraph();
54 grA->SetLineWidth(2);
55 grA->SetLineColor(9);
56 grS->SetLineWidth(2);
57 grS->SetLineColor(9);
58 for (CDCRecoHit3D& hit : track) {
59 Vector3D pos = hit.getRecoPos3D();
60 const double R = std::sqrt(pos.x() * pos.x() + pos.y() * pos.y());
61 const double X = pos.x();
62 const double Y = pos.y();
63 const double Z = pos.z();
64 if (Z == 0 and hit.isAxial()) { // axial hits have no z information
65 grA->SetPoint(grA->GetN(), X, Y);
66 } else {
67 grS->SetPoint(grS->GetN(), Z, R);
68 }
69 }
70 mgA->Add(grA);
71 mgS->Add(grS);
72 }
73 canvA.cd();
74 mgA->Draw("APL*");
75 canvS.cd();
76 mgS->Draw("APL*");
77 canvA.Update();
78 canvS.Update();
79 if (mgA->GetXaxis()) {
80 mgA->GetXaxis()->SetLimits(-120, 120);
81 mgA->GetYaxis()->SetRangeUser(-120, 120);
82 canvA.SaveAs(Form("CDCaxialTracks_%i.png", nevent));
83 }
84 if (mgS->GetXaxis()) {
85 mgS->GetXaxis()->SetLimits(-180, 180);
86 mgS->GetYaxis()->SetRangeUser(0, 120);
87 canvS.SaveAs(Form("CDCstereoTracks_%i.png", nevent));
88 }
89 nevent++;
90}
91
92void TrackInspector::removeIncompleteTracks(std::vector<CDCTrack>& tracks)
93{
94 for (auto it = tracks.begin(); it != tracks.end();) {
95 bool stereoHitsPresent =
96 false; //If stereo hit matcher can't find more hits than its threshold, it doesn't add any, but keeps the track
97 for (CDCRecoHit3D& hit : *it) {
98 if (not hit.isAxial()) stereoHitsPresent = true;
99 }
100 if (not stereoHitsPresent) {
101 it = tracks.erase(it); //TODO mask hits or something?
102 } else {
103 ++it;
104 }
105 }
106}
double R
typedef autogenerated by FFTW
The Module parameter list class.
void apply(std::vector< TrackingUtilities::CDCTrack > &tracks) final
Print the tracks.
void removeIncompleteTracks(std::vector< TrackingUtilities::CDCTrack > &tracks)
Remove tracks with no stereo hits.
std::string getDescription() final
Short description of the findlet.
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) final
Access parameters.
bool m_param_debugDraw
Flag to draw the CDCTrack (true) or not (false)
Class representing a three dimensional reconstructed hit.
Class representing a sequence of three dimensional reconstructed hits.
Definition CDCTrack.h:39
void addParameter(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module list.
HepGeom::Vector3D< double > Vector3D
3D Vector
Definition Cell.h:34
Abstract base class for different kinds of events.