11#include <RtypesCore.h>
21#include <initializer_list>
32 void PicTree::AddLink(std::initializer_list<Int_t> depths, std::initializer_list<Int_t> ids, Int_t style) {
33 fLinks.push_back(link(depths, ids, style));
36 fCircles.push_back(circle(depth, number, style, ratio));
40 Bool_t batch = gROOT->IsBatch();
41 gROOT->SetBatch(kTRUE);
42 TCanvas* c1 =
new TCanvas(
"canv",
"canv", fWindowWidth, fWindowHeight);
43 c1->Range(0, 0, fWindowWidth, fWindowHeight);
45 for (
int i = 0; i < fMaxExpDepth; i++) {
46 for (
auto& acirc : fCircles) {
47 if (acirc.sDepth == i) fDepthMax = i;
51 fPoints.resize(fDepthMax);
52 for (
int i = 0; i < fDepthMax; i++) {
53 int tiers[] = {0, 0, 0, 0};
54 for (
auto& acirc : fCircles) {
55 if (acirc.sDepth == i) tiers[acirc.sStyles]++;
58 for (
int j = 0; j < 4; j++) {
59 if (maxLev < tiers[j]) maxLev = tiers[j];
61 fPoints[i].resize(maxLev);
63 for (
int i = 0; i < fDepthMax; i++) {
64 int maxLev = fPoints[i].size();
65 double depth = (double) i;
66 double maxNo = (double) maxLev;
67 for (
int j = 0; j < fPoints[i].size(); j++) {
68 double collection = j;
69 Double_t Y_step = fWindowHeight / maxNo;
70 Double_t X_step = fWindowWidth / (double) fDepthMax;
71 Double_t X_center = X_step * (depth + 0.5);
72 Double_t Y_center = fWindowHeight - Y_step * (collection + 0.5);
73 fPoints[i][j].first = X_center;
74 fPoints[i][j].second = Y_center;
78 std::sort(fLinks.begin(), fLinks.end(), [](
const link& a,
const link& b) { return a.sStyles > b.sStyles; });
79 std::sort(fCircles.begin(), fCircles.end(), [](
const circle& a,
const circle& b) { return a.sStyles > b.sStyles; });
82 for (
auto& aline : fLinks) {
85 for (
auto& acirc : fCircles) {
89 c1->SaveAs(path.Data());
90 gROOT->SetBatch(batch);
93 PicTree::link::link(std::initializer_list<Int_t> depths, std::initializer_list<Int_t> ids, Int_t style) {
96 auto vec = Hal::Std::GetVector(depths);
99 auto vec2 = Hal::Std::GetVector(ids);
100 sFromNumber = vec2[0];
105 void PicTree::link::Draw(
const PicTree& tree) {
107 Double_t X1 = tree.GetCoords()[sFromDepth][sFromNumber].first;
108 Double_t Y1 = tree.GetCoords()[sFromDepth][sFromNumber].second;
110 Double_t X2 = tree.GetCoords()[sToDepth][sToNumber].first;
111 Double_t Y2 = tree.GetCoords()[sToDepth][sToNumber].second;
112 TLine* line =
new TLine(X1, Y1, X2, Y2);
113 line->SetLineWidth(4.0);
116 line->SetLineWidth(2);
117 line->SetLineStyle(1);
118 line->SetLineColor(kBlack);
121 line->SetLineWidth(4);
122 line->SetLineStyle(9);
123 line->SetLineColor(kBlue);
132void Hal::PicTree::circle::Draw(
const PicTree& tree) {
134 Double_t angle_pass = 360.0 * sRatio;
135 const Double_t X_coor = tree.GetCoords()[sDepth][sNumber].first;
136 const Double_t Y_coor = tree.GetCoords()[sDepth][sNumber].second;
139 TArc* b2 =
new TArc(X_coor, Y_coor, 40, 0, 360);
140 b2->SetFillColor(kRed);
142 if (sRatio > 0.001) {
143 auto b1 =
new TArc(X_coor, Y_coor, 40, 90, 90 - angle_pass);
144 b1->SetFillColor(kGreen);
150 TArc* b2 =
new TArc(X_coor, Y_coor, 50, 0, 360);
151 b2->SetFillColor(kRed + 2);
153 if (sRatio > 0.001) {
154 auto b1 =
new TArc(X_coor, Y_coor, 50, 90, 90 - angle_pass);
155 b1->SetFillColor(kGreen + 2);
163 t.DrawText(X_coor - 10, Y_coor - 12, Form(
"%i", sNumber));
165 t.DrawText(X_coor - 15, Y_coor - 17, Form(
"%i", sNumber));
void AddPoint(Int_t depth, Int_t number, Int_t style, Double_t ratio)
void AddLink(std::initializer_list< Int_t > depths, std::initializer_list< Int_t > ids, Int_t style)
void SaveAs(TString path)