Skip to content

Commit

Permalink
groot/{rhist,rjson}: implement TGraph-v5
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastien Binet <binet@cern.ch>
  • Loading branch information
sbinet committed Jun 20, 2024
1 parent 0466a8c commit 7aea471
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 4 deletions.
7 changes: 7 additions & 0 deletions groot/rhist/graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type tgraph struct {
histo *H1F
min float64
max float64
opt string
}

func newGraph(n int) *tgraph {
Expand All @@ -46,6 +47,7 @@ func newGraph(n int) *tgraph {
x: make([]float64, n),
y: make([]float64, n),
funcs: rcont.NewList("", nil),
opt: "",
}
}

Expand Down Expand Up @@ -141,6 +143,7 @@ func (g *tgraph) MarshalROOT(w *rbytes.WBuffer) (int, error) {
w.WriteF64(g.min)
w.WriteF64(g.max)
}
w.WriteString(g.opt)

return w.SetHeader(hdr)
}
Expand Down Expand Up @@ -201,6 +204,9 @@ func (g *tgraph) UnmarshalROOT(r *rbytes.RBuffer) error {
g.min = r.ReadF64()
g.max = r.ReadF64()
}
if hdr.Vers > 4 {
g.opt = r.ReadString()
}

r.CheckHeader(hdr)
return r.Err()
Expand All @@ -219,6 +225,7 @@ func (g *tgraph) RMembers() (mbrs []rbytes.Member) {
{Name: "fHistogram", Value: &g.histo},
{Name: "fMinimum", Value: &g.min},
{Name: "fMaximum", Value: &g.max},
{Name: "fOption", Value: &g.opt},
}...)

return mbrs
Expand Down
2 changes: 1 addition & 1 deletion groot/rjson/testdata/graph_golden.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"_typename": "TGraph", "fUniqueID": 0, "fBits": 50331648, "fName": "s2", "fTitle": "my title", "fLineColor": 602, "fLineStyle": 1, "fLineWidth": 1, "fFillColor": 0, "fFillStyle": 1001, "fMarkerColor": 1, "fMarkerStyle": 1, "fMarkerSize": 1, "fNpoints": 3, "fX": [1,2,3], "fY": [2,4,6], "fFunctions": {"_typename": "TList", "name": "", "arr": [], "opt": []}, "fHistogram": null, "fMinimum": 2, "fMaximum": 6}
{"_typename": "TGraph", "fUniqueID": 0, "fBits": 50331648, "fName": "s2", "fTitle": "my title", "fLineColor": 602, "fLineStyle": 1, "fLineWidth": 1, "fFillColor": 0, "fFillStyle": 1001, "fMarkerColor": 1, "fMarkerStyle": 1, "fMarkerSize": 1, "fNpoints": 3, "fX": [1,2,3], "fY": [2,4,6], "fFunctions": {"_typename": "TList", "name": "", "arr": [], "opt": []}, "fHistogram": null, "fMinimum": 2, "fMaximum": 6, "fOption": ""}
2 changes: 1 addition & 1 deletion groot/rjson/testdata/tgae_golden.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"_typename": "TGraphAsymmErrors", "fUniqueID": 0, "fBits": 50331648, "fName": "s2", "fTitle": "my title", "fLineColor": 602, "fLineStyle": 1, "fLineWidth": 1, "fFillColor": 0, "fFillStyle": 1001, "fMarkerColor": 1, "fMarkerStyle": 1, "fMarkerSize": 1, "fNpoints": 3, "fX": [1,2,3], "fY": [2,4,6], "fFunctions": {"_typename": "TList", "name": "", "arr": [], "opt": []}, "fHistogram": null, "fMinimum": 2, "fMaximum": 6, "fEXlow": [10,20,30], "fEXhigh": [20,30,40], "fEYlow": [11,12,13], "fEYhigh": [22,23,24]}
{"_typename": "TGraphAsymmErrors", "fUniqueID": 0, "fBits": 50331648, "fName": "s2", "fTitle": "my title", "fLineColor": 602, "fLineStyle": 1, "fLineWidth": 1, "fFillColor": 0, "fFillStyle": 1001, "fMarkerColor": 1, "fMarkerStyle": 1, "fMarkerSize": 1, "fNpoints": 3, "fX": [1,2,3], "fY": [2,4,6], "fFunctions": {"_typename": "TList", "name": "", "arr": [], "opt": []}, "fHistogram": null, "fMinimum": 2, "fMaximum": 6, "fOption": "", "fEXlow": [10,20,30], "fEXhigh": [20,30,40], "fEYlow": [11,12,13], "fEYhigh": [22,23,24]}
2 changes: 1 addition & 1 deletion groot/rjson/testdata/tge_golden.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"_typename": "TGraphErrors", "fUniqueID": 0, "fBits": 50331648, "fName": "s2", "fTitle": "my title", "fLineColor": 602, "fLineStyle": 1, "fLineWidth": 1, "fFillColor": 0, "fFillStyle": 1001, "fMarkerColor": 1, "fMarkerStyle": 1, "fMarkerSize": 1, "fNpoints": 3, "fX": [1,2,3], "fY": [2,4,6], "fFunctions": {"_typename": "TList", "name": "", "arr": [], "opt": []}, "fHistogram": null, "fMinimum": 2, "fMaximum": 6, "fEX": [10,20,30], "fEY": [11,12,13]}
{"_typename": "TGraphErrors", "fUniqueID": 0, "fBits": 50331648, "fName": "s2", "fTitle": "my title", "fLineColor": 602, "fLineStyle": 1, "fLineWidth": 1, "fFillColor": 0, "fFillStyle": 1001, "fMarkerColor": 1, "fMarkerStyle": 1, "fMarkerSize": 1, "fNpoints": 3, "fX": [1,2,3], "fY": [2,4,6], "fFunctions": {"_typename": "TList", "name": "", "arr": [], "opt": []}, "fHistogram": null, "fMinimum": 2, "fMaximum": 6, "fOption": "", "fEX": [10,20,30], "fEY": [11,12,13]}
2 changes: 1 addition & 1 deletion groot/rjson/testdata/tgme_golden.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"_typename": "TGraphMultiErrors", "fUniqueID": 0, "fBits": 50331648, "fName": "s2", "fTitle": "my title", "fLineColor": 602, "fLineStyle": 1, "fLineWidth": 1, "fFillColor": 0, "fFillStyle": 1001, "fMarkerColor": 1, "fMarkerStyle": 1, "fMarkerSize": 1, "fNpoints": 3, "fX": [1,2,3], "fY": [2,4,6], "fFunctions": {"_typename": "TList", "name": "", "arr": [], "opt": []}, "fHistogram": null, "fMinimum": 2, "fMaximum": 6, "fNYErrors": 1, "fSumErrorsMode": 0, "fExL": [10,20,30], "fExH": [20,30,40], "fEyL": [[11,12,13]], "fEyH": [[22,23,24]], "fAttFill": [{"_typename": "TAttFill", "fFillColor": 0, "fFillStyle": 0},{"_typename": "TAttFill", "fFillColor": 0, "fFillStyle": 0},{"_typename": "TAttFill", "fFillColor": 0, "fFillStyle": 0}], "fAttLine": [{"_typename": "TAttLine", "fLineColor": 0, "fLineStyle": 0, "fLineWidth": 0},{"_typename": "TAttLine", "fLineColor": 0, "fLineStyle": 0, "fLineWidth": 0},{"_typename": "TAttLine", "fLineColor": 0, "fLineStyle": 0, "fLineWidth": 0}]}
{"_typename": "TGraphMultiErrors", "fUniqueID": 0, "fBits": 50331648, "fName": "s2", "fTitle": "my title", "fLineColor": 602, "fLineStyle": 1, "fLineWidth": 1, "fFillColor": 0, "fFillStyle": 1001, "fMarkerColor": 1, "fMarkerStyle": 1, "fMarkerSize": 1, "fNpoints": 3, "fX": [1,2,3], "fY": [2,4,6], "fFunctions": {"_typename": "TList", "name": "", "arr": [], "opt": []}, "fHistogram": null, "fMinimum": 2, "fMaximum": 6, "fOption": "", "fNYErrors": 1, "fSumErrorsMode": 0, "fExL": [10,20,30], "fExH": [20,30,40], "fEyL": [[11,12,13]], "fEyH": [[22,23,24]], "fAttFill": [{"_typename": "TAttFill", "fFillColor": 0, "fFillStyle": 0},{"_typename": "TAttFill", "fFillColor": 0, "fFillStyle": 0},{"_typename": "TAttFill", "fFillColor": 0, "fFillStyle": 0}], "fAttLine": [{"_typename": "TAttLine", "fLineColor": 0, "fLineStyle": 0, "fLineWidth": 0},{"_typename": "TAttLine", "fLineColor": 0, "fLineStyle": 0, "fLineWidth": 0},{"_typename": "TAttLine", "fLineColor": 0, "fLineStyle": 0, "fLineWidth": 0}]}

0 comments on commit 7aea471

Please sign in to comment.