Commits

Anonymous committed 28ad996

new layout

Comments (0)

Files changed (3)

pkg/herwig.go

-// go wrapper around the c-herwig library
-package herwig
-
-/*
- #include <stdlib.h>
- #include <stdio.h>
-
- #include "c-herwig/herwig.h"
-
- #cgo LDFLAGS: -lc-hepevt -lf-hepevt -lc-herwig -lherwig65 -lgfortran
-*/
-import "C"
-
-import (
-	"unsafe"
-	"math"
-)
-
-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
-
-// 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)
-}
-
-func (h *hwevnt) Maxer() int {
-	return int(C.hwevnt.MAXER)
-}
-
-func (h *hwevnt) SetMaxpr(nevts int) {
-	C.hwevnt.MAXPR = C.int(nevts)
-}
-
-func (h *hwevnt) Maxpr() int {
-	return int(C.hwevnt.MAXPR)
-}
-
-func (h *hwevnt) SetNrn(idx, seed int) {
-	C.hwevnt.NRN[C.int(idx)] = C.int(seed)
-}
-
-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
-// 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
-
-type hwprop int
-// placeholder for:
-// C Arrays for particle properties (NMXRES = max no of particles defined)
-//       PARAMETER(NMXRES=500)
-//       COMMON/HWPROP/RLTIM(0:NMXRES),RMASS(0:NMXRES),RSPIN(0:NMXRES),
-//      & ICHRG(0:NMXRES),IDPDG(0:NMXRES),IFLAV(0:NMXRES),NRES,
-//      & VTOCDK(0:NMXRES),VTORDK(0:NMXRES),
-//      & QORQQB(0:NMXRES),QBORQQ(0:NMXRES)
-var Hwprop hwprop
-
-func (h *hwprop) SetRmass(idx int, val float64) {
-	C.hwprop.RMASS[C.int(idx)] = C.double(val)
-}
-
-func (h *hwprop) Rmass(idx int) float64 {
-	return float64(C.hwprop.RMASS[C.int(idx)])
-}
-// FIXME: more getter/setter
-
-// 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()
-}
-

pkg/herwig/herwig.go

+// go wrapper around the c-herwig library
+package herwig
+
+/*
+ #include <stdlib.h>
+ #include <stdio.h>
+
+ #include "c-herwig/herwig.h"
+
+ #cgo LDFLAGS: -lc-hepevt -lf-hepevt -lc-herwig -lherwig65 -lgfortran
+*/
+import "C"
+
+import (
+	"unsafe"
+	"math"
+)
+
+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
+
+// 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)
+}
+
+func (h *hwevnt) Maxer() int {
+	return int(C.hwevnt.MAXER)
+}
+
+func (h *hwevnt) SetMaxpr(nevts int) {
+	C.hwevnt.MAXPR = C.int(nevts)
+}
+
+func (h *hwevnt) Maxpr() int {
+	return int(C.hwevnt.MAXPR)
+}
+
+func (h *hwevnt) SetNrn(idx, seed int) {
+	C.hwevnt.NRN[C.int(idx)] = C.int(seed)
+}
+
+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
+// 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
+
+type hwprop int
+// placeholder for:
+// C Arrays for particle properties (NMXRES = max no of particles defined)
+//       PARAMETER(NMXRES=500)
+//       COMMON/HWPROP/RLTIM(0:NMXRES),RMASS(0:NMXRES),RSPIN(0:NMXRES),
+//      & ICHRG(0:NMXRES),IDPDG(0:NMXRES),IFLAV(0:NMXRES),NRES,
+//      & VTOCDK(0:NMXRES),VTORDK(0:NMXRES),
+//      & QORQQB(0:NMXRES),QBORQQ(0:NMXRES)
+var Hwprop hwprop
+
+func (h *hwprop) SetRmass(idx int, val float64) {
+	C.hwprop.RMASS[C.int(idx)] = C.double(val)
+}
+
+func (h *hwprop) Rmass(idx int) float64 {
+	return float64(C.hwprop.RMASS[C.int(idx)])
+}
+// FIXME: more getter/setter
+
+// 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()
+}
+
     ctx(
         features='cgopackage',
         name='go-herwig',
-        source='pkg/herwig.go',
-        target='herwig',
+        source='pkg/herwig/herwig.go',
+        target='bitbucket.org/binet/go-herwig/pkg/herwig',
         use=['c-hepevt','c-herwig', 'herwig65', 'f-hepevt'],
         lib=['gfortran','m'],
         )