9#include <tracking/trackFindingCDC/hough/trees/SimpleBoxDivisionHoughTree.h>
23 namespace TrackFindingCDC {
26 template<
class AHitPtr,
class AInBoxAlgorithm,
size_t divisionX,
size_t divisionY>
46 TFile openedRootFile(filename.c_str(),
"RECREATE");
47 TTree weightTTree(
"weightTree",
"A tree with the weights of the box items.");
48 TTree eventTTree(
"eventTree",
"A tree with event information.");
50 double lowerX, upperX, lowerY, upperY, weight, level;
51 weightTTree.Branch(
"lowerX", &lowerX);
52 weightTTree.Branch(
"upperY", &upperY);
53 weightTTree.Branch(
"lowerY", &lowerY);
54 weightTTree.Branch(
"upperX", &upperX);
55 weightTTree.Branch(
"weight", &weight);
56 weightTTree.Branch(
"level", &level);
63 eventTTree.Branch(
"lowerLimX", &lowerLimX);
64 eventTTree.Branch(
"upperLimX", &upperLimX);
65 eventTTree.Branch(
"lowerLimY", &lowerLimY);
66 eventTTree.Branch(
"upperLimY", &upperLimY);
67 eventTTree.Branch(
"maxLevel", &maxLevel);
71 auto walker = [&](
const typename Super::Node * node) ->
bool {
73 lowerX = node->getLowerX();
75 upperX = node->getUpperX();
77 lowerY = node->getLowerY();
79 upperY = node->getUpperY();
81 weight = node->getWeight();
83 level = node->getLevel();
93 openedRootFile.Write();
94 openedRootFile.Close();
99 const std::vector<CDCRecoHit3D>& foundHits,
100 const typename AInBoxAlgorithm::HoughBox& node)
102 TGraph* allHitsGraph =
new TGraph();
103 allHitsGraph->SetLineWidth(2);
104 allHitsGraph->SetLineColor(9);
107 const Vector3D& recoPos3D = recoHit3D.getRecoPos3D();
108 const double R = std::sqrt(recoPos3D.
x() * recoPos3D.
x() + recoPos3D.
y() * recoPos3D.
y());
109 const double Z = recoPos3D.
z();
110 allHitsGraph->SetPoint(allHitsGraph->GetN(),
R, Z);
113 static int nevent(0);
114 TCanvas canv(
"trackCanvas",
"CDC stereo hits in an event", 0, 0, 1600, 1200);
116 allHitsGraph->Draw(
"APL*");
117 allHitsGraph->GetXaxis()->SetLimits(0, 120);
118 allHitsGraph->GetYaxis()->SetRangeUser(-180, 180);
120 TGraph* foundHitsGraph =
new TGraph();
121 foundHitsGraph->SetMarkerStyle(8);
122 foundHitsGraph->SetMarkerColor(2);
125 const Vector3D& recoPos3D = recoHit3D.getRecoPos3D();
126 const double R = std::sqrt(recoPos3D.
x() * recoPos3D.
x() + recoPos3D.
y() * recoPos3D.
y());
127 const double Z = recoPos3D.
z();
128 foundHitsGraph->SetPoint(foundHitsGraph->GetN(),
R, Z);
130 foundHitsGraph->Draw(
"P");
132 const double xMean = (node.getLowerX() + node.getUpperX()) / 2.0;
133 const double yMean = (node.getLowerY() + node.getUpperY()) / 2.0;
134 const double xLow = node.getLowerX();
135 const double yLow = node.getLowerY();
136 const double xHigh = node.getUpperX();
137 const double yHigh = node.getUpperY();
139 TF1* candidateLL =
new TF1(
"candLL", AInBoxAlgorithm::BoxAlgorithm::debugLine(), 0, 120);
140 TF1* candidateLH =
new TF1(
"candLH", AInBoxAlgorithm::BoxAlgorithm::debugLine(), 0, 120);
141 TF1* candidateHL =
new TF1(
"candHL", AInBoxAlgorithm::BoxAlgorithm::debugLine(), 0, 120);
142 TF1* candidateHH =
new TF1(
"candHH", AInBoxAlgorithm::BoxAlgorithm::debugLine(), 0, 120);
143 TF1* candidateMean =
new TF1(
"candMean", AInBoxAlgorithm::BoxAlgorithm::debugLine(), 0, 120);
145 candidateLL->SetParameters(xLow, yLow);
146 candidateLH->SetParameters(xLow, yHigh);
147 candidateHL->SetParameters(xHigh, yLow);
148 candidateHH->SetParameters(xHigh, yHigh);
149 candidateMean->SetParameters(xMean, yMean);
151 candidateLL->SetLineColor(9);
152 candidateLH->SetLineColor(30);
153 candidateHL->SetLineColor(46);
154 candidateHH->SetLineColor(41);
155 candidateMean->SetLineColor(2);
157 candidateLL->Draw(
"same");
158 candidateHL->Draw(
"same");
159 candidateLH->Draw(
"same");
160 candidateHH->Draw(
"same");
161 candidateMean->Draw(
"same");
162 canv.SaveAs(Form(
"CDCRLHits_%i.png", nevent));
173 AInBoxAlgorithm inBoxAlgorithm;
175 auto isLeaf = [
this](
typename Super::Node * node) {
A fast hough algorithm with rectangular boxes, which are split linearly by a fixed number of division...
typename HoughTree::Node Node
Type of the nodes used in the tree for the search.
int getMaxLevel() const
Getter for the currently set maximal level.
HoughTree * getTree() const
Getter for the tree used in the search in the hough plane.
Class representing a three dimensional reconstructed hit.
A convenience class for adding debug information to a Simple Hough Tree.
void fillAll()
Fill the tree till all nodes are touched once.
void writeDebugInfoToFile(const std::string &filename)
Write out some debug information to a ROOT file with the given name.
void drawDebugPlot(const std::vector< CDCRecoHit3D > &allHits, const std::vector< CDCRecoHit3D > &foundHits, const typename AInBoxAlgorithm::HoughBox &node)
Draw the results to a ROOT TCanvas.
void walk(AWalker &walker)
Forward walk to the top node.
Convenience class for the typical usage-case: A box divisioned hough tree with maximum and minimum va...
float getMaximumY() const
Return the maximum value in y direction.
float getMaximumX() const
Return the maximum value in x direction.
A three dimensional vector.
double x() const
Getter for the x coordinate.
double y() const
Getter for the y coordinate.
double z() const
Getter for the z coordinate.
void fillWalk(AItemInDomainMeasure &weightItemInDomain, AIsLeafPredicate &isLeaf)
Walk through the children and fill them if necessary until isLeaf returns true.
Abstract base class for different kinds of events.