go-hep.org/x/hep@v0.38.1/groot/rphys/feldmancousins.go (about) 1 // Copyright ©2020 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 package rphys 6 7 import ( 8 "reflect" 9 10 "go-hep.org/x/hep/groot/rbase" 11 "go-hep.org/x/hep/groot/rbytes" 12 "go-hep.org/x/hep/groot/root" 13 "go-hep.org/x/hep/groot/rtypes" 14 "go-hep.org/x/hep/groot/rvers" 15 ) 16 17 type FeldmanCousins struct { 18 obj rbase.Object 19 20 CL float64 // confidence level as a fraction [e.g. 90% = 0.9] 21 UpLim float64 // calculated upper limit 22 LoLim float64 // calculated lower limit 23 Nobs float64 // input number of observed events 24 Nbkg float64 // input number of background events 25 MuMin float64 // minimum value of signal to use in calculating the tables 26 MuMax float64 // maximum value of signal to use in calculating the tables 27 MuStep float64 // step in signal to use when generating tables 28 NMuStep int32 29 NMax int32 30 Quick int32 31 } 32 33 func NewFeldmanCousins() *FeldmanCousins { 34 return &FeldmanCousins{ 35 obj: *rbase.NewObject(), 36 } 37 } 38 39 func (*FeldmanCousins) RVersion() int16 { 40 return rvers.FeldmanCousins 41 } 42 43 func (*FeldmanCousins) Class() string { 44 return "TFeldmanCousins" 45 } 46 47 func (fc *FeldmanCousins) MarshalROOT(w *rbytes.WBuffer) (int, error) { 48 if w.Err() != nil { 49 return 0, w.Err() 50 } 51 52 hdr := w.WriteHeader(fc.Class(), fc.RVersion()) 53 w.WriteObject(&fc.obj) 54 w.WriteF64(fc.CL) 55 w.WriteF64(fc.UpLim) 56 w.WriteF64(fc.LoLim) 57 w.WriteF64(fc.Nobs) 58 w.WriteF64(fc.Nbkg) 59 w.WriteF64(fc.MuMin) 60 w.WriteF64(fc.MuMax) 61 w.WriteF64(fc.MuStep) 62 w.WriteI32(fc.NMuStep) 63 w.WriteI32(fc.NMax) 64 w.WriteI32(fc.Quick) 65 66 return w.SetHeader(hdr) 67 } 68 69 func (fc *FeldmanCousins) UnmarshalROOT(r *rbytes.RBuffer) error { 70 if r.Err() != nil { 71 return r.Err() 72 } 73 74 hdr := r.ReadHeader(fc.Class(), fc.RVersion()) 75 76 r.ReadObject(&fc.obj) 77 fc.CL = r.ReadF64() 78 fc.UpLim = r.ReadF64() 79 fc.LoLim = r.ReadF64() 80 fc.Nobs = r.ReadF64() 81 fc.Nbkg = r.ReadF64() 82 fc.MuMin = r.ReadF64() 83 fc.MuMax = r.ReadF64() 84 fc.MuStep = r.ReadF64() 85 fc.NMuStep = r.ReadI32() 86 fc.NMax = r.ReadI32() 87 fc.Quick = r.ReadI32() 88 89 r.CheckHeader(hdr) 90 return r.Err() 91 } 92 93 func init() { 94 { 95 f := func() reflect.Value { 96 o := NewFeldmanCousins() 97 return reflect.ValueOf(o) 98 } 99 rtypes.Factory.Add("TFeldmanCousins", f) 100 } 101 } 102 103 var ( 104 _ root.Object = (*FeldmanCousins)(nil) 105 _ rbytes.Marshaler = (*FeldmanCousins)(nil) 106 _ rbytes.Unmarshaler = (*FeldmanCousins)(nil) 107 )