11 #include <tracking/trackFindingCDC/hough/trees/SimpleBoxDivisionHoughTree.h>
25 namespace TrackFindingCDC {
28 template<
class AHitPtr,
class AInBoxAlgorithm,
size_t divisionX,
size_t divisionY>
29 class DebugableSimpleBoxDivisionHoughTree :
30 public SimpleBoxDivisionHoughTree<AHitPtr, AInBoxAlgorithm, divisionX, divisionY> {
33 using Super = SimpleBoxDivisionHoughTree<AHitPtr, AInBoxAlgorithm, divisionX, divisionY>;
48 TFile openedRootFile(filename.c_str(),
"RECREATE");
49 TTree weightTTree(
"weightTree",
"A tree with the weights of the box items.");
50 TTree eventTTree(
"eventTree",
"A tree with event information.");
52 double lowerX, upperX, lowerY, upperY, weight, level;
53 weightTTree.Branch(
"lowerX", &lowerX);
54 weightTTree.Branch(
"upperY", &upperY);
55 weightTTree.Branch(
"lowerY", &lowerY);
56 weightTTree.Branch(
"upperX", &upperX);
57 weightTTree.Branch(
"weight", &weight);
58 weightTTree.Branch(
"level", &level);
65 eventTTree.Branch(
"lowerLimX", &lowerLimX);
66 eventTTree.Branch(
"upperLimX", &upperLimX);
67 eventTTree.Branch(
"lowerLimY", &lowerLimY);
68 eventTTree.Branch(
"upperLimY", &upperLimY);
69 eventTTree.Branch(
"maxLevel", &maxLevel);
73 auto walker = [&](
const typename Super::Node * node) ->
bool {
75 lowerX = node->getLowerX();
77 upperX = node->getUpperX();
79 lowerY = node->getLowerY();
81 upperY = node->getUpperY();
83 weight = node->getWeight();
85 level = node->getLevel();
95 openedRootFile.Write();
96 openedRootFile.Close();
101 const std::vector<CDCRecoHit3D>& foundHits,
102 const typename AInBoxAlgorithm::HoughBox& node)
104 TGraph* allHitsGraph =
new TGraph();
105 allHitsGraph->SetLineWidth(2);
106 allHitsGraph->SetLineColor(9);
109 const Vector3D& recoPos3D = recoHit3D.getRecoPos3D();
110 const double R = std::sqrt(recoPos3D.
x() * recoPos3D.
x() + recoPos3D.
y() * recoPos3D.
y());
111 const double Z = recoPos3D.
z();
112 allHitsGraph->SetPoint(allHitsGraph->GetN(), R, Z);
115 static int nevent(0);
116 TCanvas canv(
"trackCanvas",
"CDC stereo hits in an event", 0, 0, 1600, 1200);
118 allHitsGraph->Draw(
"APL*");
119 allHitsGraph->GetXaxis()->SetLimits(0, 120);
120 allHitsGraph->GetYaxis()->SetRangeUser(-180, 180);
122 TGraph* foundHitsGraph =
new TGraph();
123 foundHitsGraph->SetMarkerStyle(8);
124 foundHitsGraph->SetMarkerColor(2);
127 const Vector3D& recoPos3D = recoHit3D.getRecoPos3D();
128 const double R = std::sqrt(recoPos3D.
x() * recoPos3D.
x() + recoPos3D.
y() * recoPos3D.
y());
129 const double Z = recoPos3D.
z();
130 foundHitsGraph->SetPoint(foundHitsGraph->GetN(), R, Z);
132 foundHitsGraph->Draw(
"P");
134 const double xMean = (node.getLowerX() + node.getUpperX()) / 2.0;
135 const double yMean = (node.getLowerY() + node.getUpperY()) / 2.0;
136 const double xLow = node.getLowerX();
137 const double yLow = node.getLowerY();
138 const double xHigh = node.getUpperX();
139 const double yHigh = node.getUpperY();
141 TF1* candidateLL =
new TF1(
"candLL", AInBoxAlgorithm::BoxAlgorithm::debugLine(), 0, 120);
142 TF1* candidateLH =
new TF1(
"candLH", AInBoxAlgorithm::BoxAlgorithm::debugLine(), 0, 120);
143 TF1* candidateHL =
new TF1(
"candHL", AInBoxAlgorithm::BoxAlgorithm::debugLine(), 0, 120);
144 TF1* candidateHH =
new TF1(
"candHH", AInBoxAlgorithm::BoxAlgorithm::debugLine(), 0, 120);
145 TF1* candidateMean =
new TF1(
"candMean", AInBoxAlgorithm::BoxAlgorithm::debugLine(), 0, 120);
147 candidateLL->SetParameters(xLow, yLow);
148 candidateLH->SetParameters(xLow, yHigh);
149 candidateHL->SetParameters(xHigh, yLow);
150 candidateHH->SetParameters(xHigh, yHigh);
151 candidateMean->SetParameters(xMean, yMean);
153 candidateLL->SetLineColor(9);
154 candidateLH->SetLineColor(30);
155 candidateHL->SetLineColor(46);
156 candidateHH->SetLineColor(41);
157 candidateMean->SetLineColor(2);
159 candidateLL->Draw(
"same");
160 candidateHL->Draw(
"same");
161 candidateLH->Draw(
"same");
162 candidateHH->Draw(
"same");
163 candidateMean->Draw(
"same");
164 canv.SaveAs(Form(
"CDCRLHits_%i.png", nevent));
175 AInBoxAlgorithm inBoxAlgorithm;
177 auto isLeaf = [
this](
typename Super::Node * node) {