Anonymous avatar Anonymous committed a94ff8d

working reco

Comments (0)

Files changed (2)

 
 // index of 1st mother
 func FirstParent(idx int) int {
-	return int(C.hepevt_first_parent(C.int(idx+1)))
+	v := int(C.hepevt_first_parent(C.int(idx+1)))
+	//println("::firstparent",idx,v)
+	return v
 }
 
 // index of last mother
 func LastParent(idx int) int {
-	return int(C.hepevt_last_parent(C.int(idx+1)))
+	v := int(C.hepevt_last_parent(C.int(idx+1)))
+	//println("::lastparent ",idx,v)
+	return v
 }
 
 // number of parents
 
 // index of 1st daughter
 func FirstChild(idx int) int {
-	return int(C.hepevt_first_child(C.int(idx+1)))
+	v := int(C.hepevt_first_child(C.int(idx+1)))
+	//println("::firstchild:",idx,v)
+	return v
 }
 
 // index of last daughter
 func LastChild(idx int) int {
-	return int(C.hepevt_last_child(C.int(idx+1)))
+	v := int(C.hepevt_last_child(C.int(idx+1)))
+	//println("::lastchild: ",idx,v)
+	return v
 }
 
 // number of children
 //         - for index ?
 //         - for firstchild/lastchild ?
 
-// // set event number
-// func SetEventNumber(evtno int) {
-// 	C.hepevt_set_event_number(C.int(evtno))
-// }
+// set event number
+func SetEventNumber(evtno int) {
+	C.hepevt_set_event_number(C.int(evtno))
+}
 
-// // set number of entries in HEPEVT
-// func SetNumberEntries(nentries int) {
-// 	C.hepevt_set_number_entries(C.int(nentries))
-// }
+// set number of entries in HEPEVT
+func SetNumberEntries(nentries int) {
+	C.hepevt_set_number_entries(C.int(nentries))
+}
 
-// // set particle status code
-// func SetStatusCode(index, status int) {
-// 	C.hepevt_set_status_code(C.int(index), C.int(status))
-// }
+// set particle status code
+func SetStatusCode(index, status int) {
+	C.hepevt_set_status_code(C.int(index+1), C.int(status))
+}
 
-// // set particle PDG-id
-// func SetPdgId(index, id int) {
-// 	C.hepevt_set_pdg_id(C.int(index), C.int(id))
-// }
+// set particle PDG-id
+func SetPdgId(index, id int) {
+	C.hepevt_set_pdg_id(C.int(index+1), C.int(id))
+}
 
-// // define parents of a particle
-// func SetParents(index, firstparent, lastparent int) {
-// 	C.hepevt_set_parents(
-// 		C.int(index),
-// 		C.int(firstparent),
-// 		C.int(lastparent))
-// }
+// define parents of a particle
+func SetParents(index, firstparent, lastparent int) {
+	C.hepevt_set_parents(
+		C.int(index+1),
+		C.int(firstparent),
+		C.int(lastparent))
+}
 
-// // define children of a particle
-// func SetChildren(index, firstchild, lastchild int) {
-// 	C.hepevt_set_children(
-// 		C.int(index),
-// 		C.int(firstchild),
-// 		C.int(lastchild))
-// }
+// define children of a particle
+func SetChildren(index, firstchild, lastchild int) {
+	C.hepevt_set_children(
+		C.int(index+1),
+		C.int(firstchild),
+		C.int(lastchild))
+}
 
-// // set particle momentum
-// func SetMomentum(index int, px, py, pz, e float64) {
-// 	C.hepevt_set_momentum(
-// 		C.int(index),
-// 		C.double(px), C.double(py),
-// 		C.double(pz), C.double(e))
-// }
+// set particle momentum
+func SetMomentum(index int, px, py, pz, e float64) {
+	C.hepevt_set_momentum(
+		C.int(index+1),
+		C.double(px), C.double(py),
+		C.double(pz), C.double(e))
+}
 
-// // set particle mass
-// func SetMass(index int, m float64) {
-// 	C.hepevt_set_mass(C.int(index), C.double(m))
-// }
+// set particle mass
+func SetMass(index int, m float64) {
+	C.hepevt_set_mass(C.int(index+1), C.double(m))
+}
 
-// // set particle production vertex
-// func SetPosition(index int, x, y, z, t float64) {
-// 	C.hepevt_set_position(
-// 		C.int(index),
-// 		C.double(x), C.double(y),
-// 		C.double(z), C.double(t))
-// }
+// set particle production vertex
+func SetPosition(index int, x, y, z, t float64) {
+	C.hepevt_set_position(
+		C.int(index+1),
+		C.double(x), C.double(y),
+		C.double(z), C.double(t))
+}
 
 // HEPEVT floorplan ---------------------------------------------------------
 
 		evt.Idhep[i]  = PdgId(i)
 		// -1 to correct for fortran index value
 		// if return value <0 => no parent
-		evt.Jmohep[i][0] = max(0, FirstParent(i) - 1)
+		fp := FirstParent(i)-1
+		evt.Jmohep[i][0] = fp //max(0, fp)
+		//println("::firstparent#",i,evt.Jmohep[i][0])
 		// -1 to correct for fortran index value
-		evt.Jmohep[i][1] = max(0, LastParent(i) - 1)
+		lp := LastParent(i)-1
+		evt.Jmohep[i][1] = lp //max(0, lp)
 		// -1 to correct for fortran index value
 		// if return value <0 => no child
-		evt.Jdahep[i][0] = max(0, FirstChild(i) - 1)
+		fc := FirstChild(i)-1
+		evt.Jdahep[i][0] = fc //max(0, fc)
 		// -1 to correct for fortran index value
-		evt.Jdahep[i][1] = max(0, LastChild(i) - 1)
+		lc := LastChild(i)-1
+		evt.Jdahep[i][1] = lc //max(0, lc)
 		evt.Phep[i][0] = Px(i)
 		evt.Phep[i][1] = Py(i)
 		evt.Phep[i][2] = Pz(i)
 	return evt
 }
 
+func SetEvent(evt *Event) {
+	SetEventNumber(evt.Nevhep)
+	SetNumberEntries(evt.Nhep)
+	for i := 0; i < evt.Nhep; i++ {
+		SetStatusCode(i, evt.Isthep[i])
+		SetPdgId(i, evt.Idhep[i])
+		firstparent := evt.Jmohep[i][0] + 1
+		lastparent  := evt.Jmohep[i][1] + 1
+		// if firstparent != lastparent {
+		// 	firstparent += 1
+		// 	lastparent += 1
+		// }
+		SetParents(i, firstparent, lastparent)
+		firstchild := evt.Jdahep[i][0]+1
+		lastchild := evt.Jdahep[i][1]+1
+		// if firstchild != lastchild || true {
+		// 	firstchild += 1
+		// 	lastchild += 1
+		// }
+		SetChildren(i, firstchild, lastchild)
+		SetMomentum(i, 
+			evt.Phep[i][0], evt.Phep[i][1], evt.Phep[i][2], evt.Phep[i][3])
+		SetMass(i, evt.Phep[i][4])
+		SetPosition(i, 
+			evt.Vhep[i][0], evt.Vhep[i][1], evt.Vhep[i][2], evt.Vhep[i][3])
+	}
+}
 func WriteTo(enc Encoder) {
 	evt := GetEvent()
 	//fmt.Printf("--- %v ---\n",evt)
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.