go-hep.org/x/hep@v0.38.1/groot/rhist/limit.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/rcont"
    13  	"go-hep.org/x/hep/groot/root"
    14  	"go-hep.org/x/hep/groot/rtypes"
    15  	"go-hep.org/x/hep/groot/rvers"
    16  )
    17  
    18  type Limit struct{}
    19  
    20  func (*Limit) Class() string {
    21  	return "TLimit"
    22  }
    23  
    24  func (*Limit) RVersion() int16 {
    25  	return rvers.Limit
    26  }
    27  
    28  // MarshalROOT implements rbytes.Marshaler
    29  func (o *Limit) MarshalROOT(w *rbytes.WBuffer) (int, error) {
    30  	if w.Err() != nil {
    31  		return 0, w.Err()
    32  	}
    33  
    34  	hdr := w.WriteHeader(o.Class(), o.RVersion())
    35  	return w.SetHeader(hdr)
    36  }
    37  
    38  // UnmarshalROOT implements rbytes.Unmarshaler
    39  func (o *Limit) UnmarshalROOT(r *rbytes.RBuffer) error {
    40  	if r.Err() != nil {
    41  		return r.Err()
    42  	}
    43  
    44  	hdr := r.ReadHeader(o.Class(), o.RVersion())
    45  
    46  	r.CheckHeader(hdr)
    47  	return r.Err()
    48  }
    49  
    50  type LimitDataSource struct {
    51  	base     rbase.Object   `groot:"BASE-TObject"`       // base class
    52  	sig      rcont.ObjArray `groot:"fSignal"`            // packed input signal
    53  	bkg      rcont.ObjArray `groot:"fBackground"`        // packed input background
    54  	data     rcont.ObjArray `groot:"fCandidates"`        // packed input candidates (data)
    55  	sigErr   rcont.ObjArray `groot:"fErrorOnSignal"`     // packed error sources for signal
    56  	bkgErr   rcont.ObjArray `groot:"fErrorOnBackground"` // packed error sources for background
    57  	ids      rcont.ObjArray `groot:"fIds"`               // packed IDs for the different error sources
    58  	dummyTA  rcont.ObjArray `groot:"fDummyTA"`           // array of dummy object (used for bookeeping)
    59  	dummyIDs rcont.ObjArray `groot:"fDummyIds"`          // array of dummy object (used for bookeeping)
    60  }
    61  
    62  func (*LimitDataSource) Class() string {
    63  	return "TLimitDataSource"
    64  }
    65  
    66  func (*LimitDataSource) RVersion() int16 {
    67  	return rvers.LimitDataSource
    68  }
    69  
    70  // MarshalROOT implements rbytes.Marshaler
    71  func (o *LimitDataSource) MarshalROOT(w *rbytes.WBuffer) (int, error) {
    72  	if w.Err() != nil {
    73  		return 0, w.Err()
    74  	}
    75  
    76  	hdr := w.WriteHeader(o.Class(), o.RVersion())
    77  
    78  	w.WriteObject(&o.base)
    79  	w.WriteObject(&o.sig)
    80  	w.WriteObject(&o.bkg)
    81  	w.WriteObject(&o.data)
    82  	w.WriteObject(&o.sigErr)
    83  	w.WriteObject(&o.bkgErr)
    84  	w.WriteObject(&o.ids)
    85  	w.WriteObject(&o.dummyTA)
    86  	w.WriteObject(&o.dummyIDs)
    87  
    88  	return w.SetHeader(hdr)
    89  }
    90  
    91  // UnmarshalROOT implements rbytes.Unmarshaler
    92  func (o *LimitDataSource) UnmarshalROOT(r *rbytes.RBuffer) error {
    93  	if r.Err() != nil {
    94  		return r.Err()
    95  	}
    96  
    97  	hdr := r.ReadHeader(o.Class(), o.RVersion())
    98  
    99  	r.ReadObject(&o.base)
   100  	r.ReadObject(&o.sig)
   101  	r.ReadObject(&o.bkg)
   102  	r.ReadObject(&o.data)
   103  	r.ReadObject(&o.sigErr)
   104  	r.ReadObject(&o.bkgErr)
   105  	r.ReadObject(&o.ids)
   106  	r.ReadObject(&o.dummyTA)
   107  	r.ReadObject(&o.dummyIDs)
   108  
   109  	r.CheckHeader(hdr)
   110  	return r.Err()
   111  }
   112  
   113  func init() {
   114  	{
   115  		f := func() reflect.Value {
   116  			var o LimitDataSource
   117  			return reflect.ValueOf(&o)
   118  		}
   119  		rtypes.Factory.Add("TLimitDataSource", f)
   120  	}
   121  
   122  	{
   123  		f := func() reflect.Value {
   124  			var o Limit
   125  			return reflect.ValueOf(&o)
   126  		}
   127  		rtypes.Factory.Add("TLimit", f)
   128  	}
   129  }
   130  
   131  var (
   132  	_ root.Object        = (*Limit)(nil)
   133  	_ rbytes.RVersioner  = (*Limit)(nil)
   134  	_ rbytes.Marshaler   = (*Limit)(nil)
   135  	_ rbytes.Unmarshaler = (*Limit)(nil)
   136  
   137  	_ root.Object        = (*LimitDataSource)(nil)
   138  	_ rbytes.RVersioner  = (*LimitDataSource)(nil)
   139  	_ rbytes.Marshaler   = (*LimitDataSource)(nil)
   140  	_ rbytes.Unmarshaler = (*LimitDataSource)(nil)
   141  )