Beispiel #1
0
func (svc *hsvc) BookH1D(name string, nbins int, low, high float64) (fwk.H1D, error) {
	var err error
	var h fwk.H1D

	if !(fsm.Configured < svc.FSMState() && svc.FSMState() < fsm.Running) {
		return h, fwk.Errorf("fwk: can not book histograms during FSM-state %v", svc.FSMState())
	}

	stream, hid := svc.split(name)
	h = fwk.H1D{
		ID:   fwk.HID(hid),
		Hist: hbook.NewH1D(nbins, low, high),
	}

	switch stream {
	case "":
		// ok, temporary histo.
	default:
		sname := "/" + stream
		str, ok := svc.streams[sname]
		if !ok {
			return h, fwk.Errorf("fwk: no stream [%s] declared", sname)
		}
		switch str.Mode {
		case Read:
			r, ok := svc.r[sname]
			if !ok {
				return h, fwk.Errorf("fwk: no read-stream [%s] declared", sname)
			}
			err = r.read(hid, h.Hist)
			if err != nil {
				return h, err
			}

			r.objs = append(r.objs, h)
			svc.r[sname] = r

		case Write:
			w, ok := svc.w[sname]
			if !ok {
				return h, fwk.Errorf("fwk: no write-stream [%s] declared: %v", sname, svc.w)
			}
			w.objs = append(w.objs, h)
			svc.w[sname] = w
		default:
			return h, fwk.Errorf("%s: invalid stream mode (%d)", svc.Name(), str.Mode)
		}
	}

	hh := &h1d{H1D: h}
	svc.h1ds[h.ID] = hh
	return hh.H1D, err
}
Beispiel #2
0
func (svc *hsvc) BookH1D(name string, nbins int, low, high float64) (fwk.H1D, error) {
	var err error
	h := fwk.H1D{
		ID:   fwk.HID(name),
		Hist: hbook.NewH1D(nbins, low, high),
	}

	if !(svc.FSMState() < fsm.Running) {
		return h, fwk.Errorf("fwk: can not book histograms during FSM-state %v", svc.FSMState())
	}

	hh := &h1d{H1D: h}
	svc.h1ds[h.ID] = hh
	return hh.H1D, err
}