go-hep.org/x/hep@v0.38.1/groot/riofs/gendata/gen-dir.go (about)

     1  // Copyright ©2018 The go-hep Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  //go:build ignore
     6  
     7  package main
     8  
     9  import (
    10  	"flag"
    11  	"log"
    12  
    13  	"go-hep.org/x/hep/groot/internal/rtests"
    14  )
    15  
    16  var (
    17  	root = flag.String("f", "dirs.root", "output ROOT file")
    18  )
    19  
    20  func main() {
    21  	flag.Parse()
    22  
    23  	out, err := rtests.RunCxxROOT("gendirs", []byte(script), *root)
    24  	if err != nil {
    25  		log.Fatalf("could not run ROOT macro:\noutput:\n%v\nerror: %+v", string(out), err)
    26  	}
    27  }
    28  
    29  const script = `
    30  void gendirs(const char* fname) {
    31  	auto f = TFile::Open(fname, "RECREATE");
    32  
    33  	auto dir1 = f->mkdir("dir1");
    34  	f->mkdir("dir2");
    35  	f->mkdir("dir3");
    36  
    37  	dir1->cd();
    38  	auto dir11 = dir1->mkdir("dir11");
    39  	dir11->cd();
    40  
    41  	auto h1 = new TH1F("h1", "h1", 100, 0, 100);
    42  	h1->FillRandom("gaus", 5);
    43  
    44  	f->Write();
    45  	f->Close();
    46  
    47  	exit(0);
    48  }
    49  `