Anonymous avatar Anonymous committed c5908c5

first import of (incomplete) Go-bindings to HERWIG

Comments (0)

Files changed (2)

+// go wrapper around the c-herwig library
+package herwig
+
+/*
+ #include <stdlib.h>
+ #include <stdio.h>
+
+ #include "c-herwig/herwig.h"
+
+ #cgo LDFLAGS: -lc_herwig
+*/
+import "C"
+import "unsafe"
+
+type hwproc int
+// placeholder for
+// COMMON/HWPROC/EBEAM1,EBEAM2,PBEAM1,PBEAM2,IPROC,MAXEV
+var Hwproc hwproc
+
+func (self *hwproc) SetEbeam1(ene float64) {
+	C.hwproc.EBEAM1 = C.double(ene)
+}
+
+func (self *hwproc) SetEbeam2(ene float64) {
+	C.hwproc.EBEAM2 = C.double(ene)
+}
+
+func (self *hwproc) SetPbeam1(ene float64) {
+	C.hwproc.PBEAM1 = C.double(ene)
+}
+
+func (self *hwproc) SetPbeam2(ene float64) {
+	C.hwproc.PBEAM2 = C.double(ene)
+}
+
+func (self *hwproc) SetIproc(proc int) {
+	C.hwproc.IPROC = C.int(proc)
+}
+
+func (self *hwproc) SetMaxev(n int) {
+	C.hwproc.MAXEV = C.int(n)
+}
+
+func (h *hwproc) Ebeam1() float64 {
+	return float64(C.hwproc.EBEAM1)
+}
+
+func (h *hwproc) Ebeam2() float64 {
+	return float64(C.hwproc.EBEAM2)
+}
+
+func (h *hwproc) Pbeam1() float64 {
+	return float64(C.hwproc.PBEAM1)
+}
+
+func (h *hwproc) Pbeam2() float64 {
+	return float64(C.hwproc.PBEAM2)
+}
+
+func (h *hwproc) Iproc() int {
+	return int(C.hwproc.IPROC)
+}
+
+func (h *hwproc) Maxev() int {
+	return int(C.hwproc.MAXEV)
+}
+
+
+type hwbeam int
+// placeholder for:
+// COMMON/HWBEAM/IPART1,IPART2
+var Hwbeam hwbeam
+
+func (h *hwbeam) SetIpart1(id int) {
+	C.hwbeam.IPART1 = C.int(id)
+}
+
+func (h *hwbeam) SetIpart2(id int) {
+	C.hwbeam.IPART2 = C.int(id)
+}
+
+func (h *hwbeam) Ipart1() int {
+	return int(C.hwbeam.IPART1)
+}
+
+func (h *hwbeam) Ipart2() int {
+	return int(C.hwbeam.IPART2)
+}
+
+
+type hwbmch int
+// placeholder for:
+// CHARACTER*8 PART1,PART2
+// COMMON/HWBMCH/PART1,PART2
+var Hwbmch hwbmch
+
+func (h *hwbmch) SetPart1(idx int, p string) {
+	if idx>=8 || idx<0{
+		panic("invalid index into hwbmch.PART1")
+	}
+
+	c_str := C.CString(p)
+	defer C.free(unsafe.Pointer(c_str))
+	C.hwbmch.PART1[C.int(idx)] = *c_str
+}
+
+func (h *hwbmch) SetPart2(idx int, p string) {
+	if idx>=8 || idx<0{
+		panic("invalid index into hwbmch.PART2")
+	}
+
+	c_str := C.CString(p)
+	defer C.free(unsafe.Pointer(c_str))
+	C.hwbmch.PART2[C.int(idx)] = *c_str
+}
+
+func (h *hwbmch) Part1(idx int) string {
+	if idx>=8 || idx<0{
+		panic("invalid index into hbmch.PART1")
+	}
+	return C.GoString(&C.hwbmch.PART1[idx])
+}
+
+func (h *hwbmch) Part2(idx int) string {
+	if idx>=8 || idx<0{
+		panic("invalid index into hbmch.PART2")
+	}
+	return C.GoString(&C.hwbmch.PART2[idx])
+}
+
+type hwevnt int
+// placeholder for:
+// COMMON/HWEVNT/AVWGT,EVWGT,GAMWT,TLOUT,WBIGST,WGTMAX,WGTSUM,WSQSUM,
+//       & IDHW(NMXHEP),IERROR,ISTAT,LWEVT,MAXER,MAXPR,NOWGT,NRN(2),NUMER,
+//       & NUMERU,NWGTS,GENSOF
+var Hwevnt hwevnt
+// FIXME: getters/setters
+
+func (h *hwevnt) SetMaxpr(nevts int) {
+	C.hwevnt.MAXPR = C.int(nevts)
+}
+
+func (h *hwevnt) Maxpr() int {
+	return int(C.hwevnt.MAXPR)
+}
+
+type hwpram int
+// placeholder for:
+//  C Basic parameters (and quantities derived from them)
+//        COMMON/HWPRAM/AFCH(16,2),ALPHEM,B1LIM,BETAF,BTCLM,CAFAC,CFFAC,
+//       & CLMAX,CLPOW,CLSMR(2),CSPEED,ENSOF,ETAMIX,F0MIX,F1MIX,F2MIX,GAMH,
+//       & GAMW,GAMZ,GAMZP,GEV2NB,H1MIX,PDIQK,PGSMX,PGSPL(4),PHIMIX,PIFAC,
+//       & PRSOF,PSPLT(2),PTRMS,PXRMS,QCDL3,QCDL5,QCDLAM,QDIQK,QFCH(16),QG,
+//       & QSPAC,QV,SCABI,SWEIN,TMTOP,VFCH(16,2),VCKM(3,3),VGCUT,VQCUT,
+//       & VPCUT,ZBINM,EFFMIN,OMHMIX,ET2MIX,PH3MIX,GCUTME,
+//       & IOPREM,IPRINT,ISPAC,LRSUD,LWSUD,MODPDF(2),NBTRY,NCOLO,NCTRY,
+//       & NDTRY,NETRY,NFLAV,NGSPL,NSTRU,NSTRY,NZBIN,IOP4JT(2),NPRFMT,
+//       & AZSOFT,AZSPIN,CLDIR(2),HARDME,NOSPAC,PRNDEC,PRVTX,SOFTME,ZPRIME,
+//       & PRNDEF,PRNTEX,PRNWEB
+var Hwpram hwpram
+// FIXME: getters/setters
+
+// herwig rountines ----------------------------------------------------------
+
+// initialise other common blocks
+func Hwigin() {
+	C.hwigin()
+}
+
+// initialise HepUP run common block
+func Hwigup() {
+	C.hwigup()
+}
+
+// compute parameter-dependent constants
+func Hwuinc() {
+	C.hwuinc()
+}
+
+// call hwusta to make any particle stable
+func Hwusta(name string) {
+	c_str := C.CString(name)
+	defer C.free(unsafe.Pointer(c_str))
+	sz := C.int(len(name)+1)
+
+	C.hwusta(c_str, sz)
+}
+
+// initialise elementary process
+func Hweini() {
+	C.hweini()
+}
+
+// initialise event
+func Hwuine() {
+	C.hwuine()
+}
+
+// generate HERWIG hard subprocess
+func Hwepro() {
+	C.hwepro()
+}
+
+// read USER hard subprocess from HepUP event common
+func Hwupro() {
+	C.hwupro()
+}
+
+// generate parton cascades
+func Hwbgen() {
+	C.hwbgen()
+}
+
+// do heavy object decays
+func Hwdhob() {
+	C.hwdhob()
+}
+
+// do cluster hadronization
+func Hwcfor() {
+	C.hwcfor()
+}
+
+// do cluster decay
+func Hwcdec() {
+	C.hwcdec()
+}
+
+// do unstable particle decays
+func Hwdhad() {
+	C.hwdhad()
+}
+
+// do heavy flavour decays
+func Hwdhvy() {
+	C.hwdhvy()
+}
+
+// add soft underlying event if needed 
+func Hwmevt() {
+	C.hwmevt()
+}
+
+// event generation completed, wrap up event .... 
+func Hwufne() {
+	C.hwufne()
+}
+
+// terminate elementary process
+func Hwefin() {
+	C.hwefin()
+}
+
+// prints out particle/decay properties
+func Hwudpr() {
+	C.hwudpr()
+}
+
+// prints out event data
+func Hwuepr() {
+	C.hwuepr()
+}
+
+// prints out HepEUP user common block event data
+func Hwupup() {
+	C.hwupup()
+}
+
+// terminal calculations to replace HWEFIN for HepUP
+func Hwegup() {
+	C.hwegup()
+}
+
+//--------------------------------------------------------------------------
+// HERWIG block data
+// ( with gcc it works to initialize the block data by calling 
+//   "hwudat();" at beginning. )
+func Hwudat() {
+	C.hwudat()
+}
+
+#
+
+top = '.'
+out = '__build__'
+
+def options(ctx):
+    ctx.load('go')
+    pass
+
+def configure(ctx):
+    ctx.load('go')
+    ctx.load('gcc')
+    ctx.load('c')
+    
+def build(ctx):
+
+    ctx(
+        features='cgopackage',
+        name='go-herwig',
+        source='pkg/herwig.go',
+        target='herwig',
+        use=['herwig65','c_hepevt','c_herwig'],
+        )
+        
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.