go-hep.org/x/hep@v0.38.1/groot/riofs/gendata/gen-tconflvl.go (about) 1 // Copyright ©2022 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", "test-tconfidence-level.root", "output ROOT file") 18 ) 19 20 func main() { 21 flag.Parse() 22 23 out, err := rtests.RunCxxROOT("gentconflvl", []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 #include <vector> 31 #include "TConfidenceLevel.h" 32 #include "TEfficiency.h" 33 #include "TF1.h" 34 35 void gentconflvl(const char* fname) { 36 auto f = TFile::Open(fname, "RECREATE"); 37 auto lvl = new TConfidenceLevel(3); 38 39 auto xs = std::vector<Double_t>{1, 2, 3}; 40 41 lvl->SetTSD(3); 42 lvl->SetTSB(xs.data()); 43 lvl->SetTSS(xs.data()); 44 lvl->SetLRS(xs.data()); 45 lvl->SetLRB(xs.data()); 46 lvl->SetBtot(3); 47 lvl->SetStot(2); 48 lvl->SetDtot(5); 49 50 f->WriteTObject(lvl, "clvl"); 51 52 auto limit = new TLimit; 53 f->WriteObjectAny(limit, "TLimit", "limit"); 54 55 auto dsrc = new TLimitDataSource; 56 f->WriteTObject(dsrc, "dsrc"); 57 58 auto eff = new TEfficiency("eff", "efficiency;x;y", 20, 0, 10); 59 eff->GetListOfFunctions()->AddFirst(new TF1("f1", "gaus", 0, 10)); 60 eff->SetBetaBinParameters(1, 1, 2); 61 eff->SetBetaBinParameters(2, 2, 3); 62 f->WriteTObject(eff, "eff"); 63 64 f->Write(); 65 f->Close(); 66 67 exit(0); 68 } 69 `