Commits

Anonymous committed 4f0f0aa

extend exposed API to get/set seeds, x-sect/x-sect-err and get generation error-code\nTODO: return os.Error when Ierror()!=0

Comments (0)

Files changed (1)

  #cgo LDFLAGS: -lc-hepevt -lf-hepevt -lc-herwig -lherwig65 -lgfortran
 */
 import "C"
-import "unsafe"
+
+import (
+	"unsafe"
+	"math"
+)
 
 type hwproc int
 // placeholder for
 var Hwevnt hwevnt
 // FIXME: getters/setters
 
+// average cross-section (nanobarn)
+func (h *hwevnt) Avwgt() float64 {
+	return float64(C.hwevnt.AVWGT)
+}
+
+func (h *hwevnt) Evwgt() float64 {
+	return float64(C.hwevnt.EVWGT)
+}
+
+func (h *hwevnt) Wsqsum() float64 {
+	return float64(C.hwevnt.WSQSUM)
+}
+
+func (h *hwevnt) Ierror() int {
+	return int(C.hwevnt.IERROR)
+}
+
 func (h *hwevnt) SetMaxer(nevts int) {
 	C.hwevnt.MAXER = C.int(nevts)
 }
 	C.hwevnt.NRN[C.int(idx)] = C.int(seed)
 }
 
-func (h *hwevnt) Nrn(idx int) int {
-	return int(C.hwevnt.NRN[C.int(idx)])
+func (h *hwevnt) Nrn() []int {
+	nrn := []int{
+		int(C.hwevnt.NRN[C.int(0)]),
+		int(C.hwevnt.NRN[C.int(1)]),
+	}
+	return nrn
+}
+
+func (h *hwevnt) Nwgts() int {
+	return int(C.hwevnt.NWGTS)
+}
+
+// compute the cross-section and its associated statistical error
+// units are nanobarns
+func (h *hwevnt) XSect() []float64 {
+	xsect := h.Avwgt()
+	xsect_err := float64(-1.)
+
+	// taken from herwig6510.f
+	// note: this works for standard herwig (NOT for Les Houches)
+	rnwgt := 1. / float64(h.Nwgts())
+	spwgt := h.Wsqsum()*rnwgt - xsect*xsect
+	if spwgt < 0. {
+		spwgt = 0.0
+	}
+	spwgt = math.Sqrt(spwgt)
+	xsect_err = spwgt * math.Sqrt(rnwgt)
+	return []float64{xsect, xsect_err}
 }
 
 type hwpram int
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.