func tree0(f croot.File) { t := f.GetTree("tree") e := &Event{} t.SetBranchAddress("evt", e) // fill some events with random numbers nevents := int64(*evtmax) if nevents < 0 || nevents > int64(t.GetEntries()) { nevents = int64(t.GetEntries()) } for iev := int64(0); iev != nevents; iev++ { if iev%1000 == 0 { fmt.Printf(":: processing event %d...\n", iev) } if t.GetEntry(iev, 1) <= 0 { panic("error") } if iev%1000 == 0 { fmt.Printf("ievt: %d\n", iev) fmt.Printf("evt.a.e= %8.3f\n", e.A.E) fmt.Printf("evt.a.t= %8.3f\n", e.A.T) fmt.Printf("evt.b.e= %8.3f\n", e.B.E) fmt.Printf("evt.b.t= %8.3f\n", e.B.T) } } }
func tree0(f croot.File) { // create a tree tree := croot.NewTree("tree", "tree", 32) e := &Event{} const bufsiz = 32000 tree.Branch("evt", e, bufsiz, 0) // fill some events with random numbers nevents := *evtmax for iev := 0; iev != nevents; iev++ { if iev%1000 == 0 { fmt.Printf(":: processing event %d...\n", iev) } // the two energies follow a gaussian distribution e.A.E = rand.NormFloat64() //ea e.B.E = rand.NormFloat64() //eb e.A.T = croot.GRandom.Rndm(1) e.B.T = e.A.T * croot.GRandom.Gaus(0., 1.) if iev%1000 == 0 { fmt.Printf("ievt: %d\n", iev) fmt.Printf("evt.a.e= %8.3f\n", e.A.E) fmt.Printf("evt.a.t= %8.3f\n", e.A.T) fmt.Printf("evt.b.e= %8.3f\n", e.B.E) fmt.Printf("evt.b.t= %8.3f\n", e.B.T) } tree.Fill() } f.Write("", 0, 0) }