go-hep.org/x/hep@v0.38.1/groot/rhist/confidence_level.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 package rhist 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 // ConfidenceLevel holds information about 95% confidence level limits. 18 type ConfidenceLevel struct { 19 base rbase.Object `groot:"BASE-TObject"` // base class 20 fNNMC int32 `groot:"fNNMC"` 21 fDtot int32 `groot:"fDtot"` 22 fStot float64 `groot:"fStot"` 23 fBtot float64 `groot:"fBtot"` 24 fTSD float64 `groot:"fTSD"` 25 fNMC float64 `groot:"fNMC"` 26 fMCL3S float64 `groot:"fMCL3S"` 27 fMCL5S float64 `groot:"fMCL5S"` 28 fTSB []float64 `groot:"fTSB,meta=[fNNMC]"` 29 fTSS []float64 `groot:"fTSS,meta=[fNNMC]"` 30 fLRS []float64 `groot:"fLRS,meta=[fNNMC]"` 31 fLRB []float64 `groot:"fLRB,meta=[fNNMC]"` 32 fISS []int32 `groot:"fISS,meta=[fNNMC]"` 33 fISB []int32 `groot:"fISB,meta=[fNNMC]"` 34 } 35 36 func (*ConfidenceLevel) Class() string { 37 return "TConfidenceLevel" 38 } 39 40 func (*ConfidenceLevel) RVersion() int16 { 41 return rvers.ConfidenceLevel 42 } 43 44 // MarshalROOT implements rbytes.Marshaler 45 func (o *ConfidenceLevel) MarshalROOT(w *rbytes.WBuffer) (int, error) { 46 if w.Err() != nil { 47 return 0, w.Err() 48 } 49 50 hdr := w.WriteHeader(o.Class(), o.RVersion()) 51 52 w.WriteObject(&o.base) 53 w.WriteI32(int32(o.fNNMC)) 54 w.WriteI32(o.fDtot) 55 w.WriteF64(o.fStot) 56 w.WriteF64(o.fBtot) 57 w.WriteF64(o.fTSD) 58 w.WriteF64(o.fNMC) 59 w.WriteF64(o.fMCL3S) 60 w.WriteF64(o.fMCL5S) 61 w.WriteI8(1) // is-array 62 w.WriteArrayF64(o.fTSB[:o.fNNMC]) 63 w.WriteI8(1) // is-array 64 w.WriteArrayF64(o.fTSS[:o.fNNMC]) 65 w.WriteI8(1) // is-array 66 w.WriteArrayF64(o.fLRS[:o.fNNMC]) 67 w.WriteI8(1) // is-array 68 w.WriteArrayF64(o.fLRB[:o.fNNMC]) 69 w.WriteI8(1) // is-array 70 w.WriteArrayI32(o.fISS[:o.fNNMC]) 71 w.WriteI8(1) // is-array 72 w.WriteArrayI32(o.fISB[:o.fNNMC]) 73 74 return w.SetHeader(hdr) 75 } 76 77 // UnmarshalROOT implements rbytes.Unmarshaler 78 func (o *ConfidenceLevel) UnmarshalROOT(r *rbytes.RBuffer) error { 79 if r.Err() != nil { 80 return r.Err() 81 } 82 83 hdr := r.ReadHeader(o.Class(), o.RVersion()) 84 85 r.ReadObject(&o.base) 86 o.fNNMC = r.ReadI32() 87 o.fDtot = r.ReadI32() 88 o.fStot = r.ReadF64() 89 o.fBtot = r.ReadF64() 90 o.fTSD = r.ReadF64() 91 o.fNMC = r.ReadF64() 92 o.fMCL3S = r.ReadF64() 93 o.fMCL5S = r.ReadF64() 94 _ = r.ReadI8() // is-array 95 o.fTSB = rbytes.ResizeF64(nil, int(o.fNNMC)) 96 r.ReadArrayF64(o.fTSB) 97 _ = r.ReadI8() // is-array 98 o.fTSS = rbytes.ResizeF64(nil, int(o.fNNMC)) 99 r.ReadArrayF64(o.fTSS) 100 _ = r.ReadI8() // is-array 101 o.fLRS = rbytes.ResizeF64(nil, int(o.fNNMC)) 102 r.ReadArrayF64(o.fLRS) 103 _ = r.ReadI8() // is-array 104 o.fLRB = rbytes.ResizeF64(nil, int(o.fNNMC)) 105 r.ReadArrayF64(o.fLRB) 106 _ = r.ReadI8() // is-array 107 o.fISS = rbytes.ResizeI32(nil, int(o.fNNMC)) 108 r.ReadArrayI32(o.fISS) 109 _ = r.ReadI8() // is-array 110 o.fISB = rbytes.ResizeI32(nil, int(o.fNNMC)) 111 r.ReadArrayI32(o.fISB) 112 113 r.CheckHeader(hdr) 114 return r.Err() 115 } 116 117 func init() { 118 f := func() reflect.Value { 119 var o ConfidenceLevel 120 return reflect.ValueOf(&o) 121 } 122 rtypes.Factory.Add("TConfidenceLevel", f) 123 } 124 125 var ( 126 _ root.Object = (*ConfidenceLevel)(nil) 127 _ rbytes.RVersioner = (*ConfidenceLevel)(nil) 128 _ rbytes.Marshaler = (*ConfidenceLevel)(nil) 129 _ rbytes.Unmarshaler = (*ConfidenceLevel)(nil) 130 )