Skip to content

Commit

Permalink
groot/riofs: add generation of TLorentzVector testdata
Browse files Browse the repository at this point in the history
  • Loading branch information
sbinet committed Dec 16, 2021
1 parent c117054 commit e370fce
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 0 deletions.
61 changes: 61 additions & 0 deletions groot/riofs/gendata/gen-tlv-tree.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// Copyright ©2021 The go-hep Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build ignore
// +build ignore

package main

import (
"flag"
"log"

"go-hep.org/x/hep/groot/internal/rtests"
)

var (
root = flag.String("f", "tlv.root", "output ROOT file")
split = flag.Int("split", 0, "default split-level for TTree")
)

func main() {
flag.Parse()

out, err := rtests.RunCxxROOT("gentree", []byte(script), *root, *split)
if err != nil {
log.Fatalf("could not run ROOT macro:\noutput:\n%v\nerror: %+v", string(out), err)
}
}

const script = `
#include "TLorentzVector.h"
void gentree(const char* fname, int splitlvl = 99) {
int bufsize = 32000;
int evtmax = 10;
auto f = TFile::Open(fname, "RECREATE");
auto t = new TTree("tree", "my tree title");
{
TLorentzVector *p4 = new TLorentzVector;
p4->SetPxPyPzE(10, 20, 30, 40);
f->WriteTObject(p4, "tlv");
}
TLorentzVector *tlv = new TLorentzVector;
t->Branch("p4", &tlv, bufsize, splitlvl);
for (int i = 0; i != evtmax; i++) {
tlv->SetPxPyPzE(0+i, 1+i, 2+i, 3+i);
t->Fill();
}
f->Write();
f->Close();
exit(0);
}
`
3 changes: 3 additions & 0 deletions groot/riofs/riofs.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ import (
//go:generate go run ./gendata/gen-multi-leaves-tree.go -f ../testdata/padding.root
//go:generate go run ./gendata/gen-join-trees.go -d ../testdata
//go:generate go run ./gendata/gen-bitset-tree.go -f ../testdata/std-bitset.root
//go:generate go run ./gendata/gen-tlv.go -f ../testdata/tlv-split00.root -split=0
//go:generate go run ./gendata/gen-tlv.go -f ../testdata/tlv-split01.root -split=1
//go:generate go run ./gendata/gen-tlv.go -f ../testdata/tlv-split99.root -split=99

// Directory describes a ROOT directory structure in memory.
type Directory interface {
Expand Down
Binary file added groot/testdata/tlv-split00.root
Binary file not shown.
Binary file added groot/testdata/tlv-split01.root
Binary file not shown.
Binary file added groot/testdata/tlv-split99.root
Binary file not shown.

0 comments on commit e370fce

Please sign in to comment.