Commit 2975a301 authored by David Blyth's avatar David Blyth

Updates across the board

parent 0ff99d4f
......@@ -2,4 +2,3 @@
*.proio
*.pdf
*.png
go.sum
......@@ -44,6 +44,7 @@ func main() {
p.X.Label.Text = "Mass (GeV)"
p.X.Tick.Marker = eicplot.PreciseTicks{NSuggestedTicks: 5}
p.Y.Tick.Marker = eicplot.PreciseTicks{NSuggestedTicks: 5}
p.Legend.Top = true
for i, filename := range flag.Args() {
hist := makeInvMassHist(filename)
......@@ -65,6 +66,7 @@ func main() {
}
p.Add(h)
p.Legend.Add(hist.Name(), h)
}
p.Save(6*vg.Inch, 4*vg.Inch, *output)
......@@ -72,6 +74,7 @@ func main() {
func makeInvMassHist(filename string) *hbook.H1D {
invMassHist := hbook.NewH1D(50, 2.9, 3.3)
invMassHist.Ann["name"] = filename
reader, err := proio.Open(filename)
if err != nil {
......
......@@ -4,24 +4,24 @@ require (
github.com/ajstarks/svgo v0.0.0-20181006003313-6ce6a3bcf6cd // indirect
github.com/awalterschulze/gographviz v0.0.0-20181013152038-b2885df04310 // indirect
github.com/cznic/mathutil v0.0.0-20181021201202-eba54fb065b7 // indirect
github.com/go-gl/gl v0.0.0-20181020191150-629e6eb0370b // indirect
github.com/go-gl/gl v0.0.0-20181026044259-55b76b7df9d2 // indirect
github.com/go-gl/glfw v0.0.0-20181014061658-691ee1b84c51 // indirect
github.com/hanwen/go-fuse v0.0.0-20181015130005-a53ed6b9b54d // indirect
github.com/google/shlex v0.0.0-20181106134648-c34317bd91bf // indirect
github.com/hanwen/go-fuse v0.0.0-20181027161220-c029b69a13a7 // indirect
github.com/llgcode/draw2d v0.0.0-20180825133448-f52c8a71aff0 // indirect
github.com/pborman/uuid v1.2.0 // indirect
github.com/pierrec/lz4 v2.0.5+incompatible // indirect
github.com/pkg/profile v1.2.1
github.com/proio-org/go-proio v0.4.0
github.com/proio-org/go-proio-pb v0.0.0-20181010213421-017d1def0591
github.com/ulikunitz/xz v0.5.5 // indirect
go-hep.org/x/hep v0.15.0
golang.org/x/crypto v0.0.0-20181024171144-74cb1d3d52f4 // indirect
golang.org/x/exp v0.0.0-20181022080537-42ba7d4b6eb2 // indirect
golang.org/x/image v0.0.0-20181023232108-9b1e201e7c4c // indirect
golang.org/x/mobile v0.0.0-20181010163405-92f3b9caf7ba // indirect
golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519 // indirect
golang.org/x/sys v0.0.0-20181024145615-5cd93ef61a7c // indirect
golang.org/x/tools v0.0.0-20181024171208-a2dc47679d30 // indirect
gonum.org/v1/gonum v0.0.0-20181019200927-f0982070f509 // indirect
gonum.org/v1/netlib v0.0.0-20181018051557-57e1e4db57a7 // indirect
gonum.org/v1/plot v0.0.0-20181024024241-4632fe2bf7c6
golang.org/x/crypto v0.0.0-20181106171534-e4dc69e5b2fd // indirect
golang.org/x/exp v0.0.0-20181106170214-d68db9428509 // indirect
golang.org/x/image v0.0.0-20181102021609-63626fb251ce // indirect
golang.org/x/mobile v0.0.0-20181026062114-a27dd33d354d // indirect
golang.org/x/sys v0.0.0-20181106135930-3a76605856fd // indirect
golang.org/x/tools v0.0.0-20181105230042-78dc5bac0cac // indirect
gonum.org/v1/gonum v0.0.0-20181106105144-6439751d3175 // indirect
gonum.org/v1/netlib v0.0.0-20181029234149-ec6d1f5cefe6 // indirect
gonum.org/v1/plot v0.0.0-20181106102004-0582252c54f6
)
This diff is collapsed.
......@@ -19,7 +19,7 @@ import (
)
func printUsage() {
fmt.Fprintf(os.Stderr, `Usage: `+os.Args[0]+` [options] <proio-input-file>
fmt.Fprintf(os.Stderr, `Usage: `+os.Args[0]+` [options] <proio-input-files>...
options:
`,
......@@ -45,11 +45,16 @@ func main() {
p.X.Tick.Marker = eicplot.PreciseTicks{NSuggestedTicks: 5}
p.Y.Tick.Marker = eicplot.LogTicks{}
p.Y.Scale = eicplot.LogScale{}
p.Legend.Top = true
var hists []*hbook.H1D
for _, filename := range flag.Args() {
for i, filename := range flag.Args() {
if i < len(flag.Args())-1 {
hists = append(hists, makeHists(filename)[0])
} else {
hists = append(hists, makeHists(filename)...)
}
}
for i, hist := range hists {
lineColor := color.RGBA{A: 255}
......@@ -68,6 +73,7 @@ func main() {
h.Infos.Style = hplot.HInfoNone
p.Add(h)
p.Legend.Add(hist.Name(), h)
}
p.Save(6*vg.Inch, 4*vg.Inch, *output)
......@@ -77,7 +83,9 @@ const jpsiMass = 3.096916
func makeHists(filename string) []*hbook.H1D {
deltaPTHist := hbook.NewH1D(50, 0, 4)
deltaPTHist.Ann["name"] = filename + ": reconstructed"
deltaPTTruthHist := hbook.NewH1D(50, 0, 4)
deltaPTTruthHist.Ann["name"] = "truth"
reader, err := proio.Open(filename)
if err != nil {
......@@ -120,5 +128,5 @@ func makeHists(filename string) []*hbook.H1D {
}
reader.Close()
return []*hbook.H1D{deltaPTTruthHist, deltaPTHist}
return []*hbook.H1D{deltaPTHist, deltaPTTruthHist}
}
package main
import (
"flag"
"fmt"
"image/color"
"log"
"math"
"os"
"github.com/proio-org/go-proio"
"github.com/proio-org/go-proio-pb/model/eic"
"go-hep.org/x/hep/hbook"
"go-hep.org/x/hep/hplot"
"gonum.org/v1/plot"
"gonum.org/v1/plot/vg"
"eicweb.phy.anl.gov/EIC/eicplot"
)
func printUsage() {
fmt.Fprintf(os.Stderr, `Usage: `+os.Args[0]+` [options] <proio-input-files>...
options:
`,
)
flag.PrintDefaults()
}
func main() {
var (
title = flag.String("title", "", "plot title")
output = flag.String("output", "out.png", "output file")
)
flag.Usage = printUsage
flag.Parse()
if flag.NArg() < 1 {
printUsage()
log.Fatal("Invalid arguments")
}
p, _ := plot.New()
p.Title.Text = *title
p.X.Label.Text = "p_T^2 of J/Psi (GeV^2)"
p.X.Tick.Marker = eicplot.PreciseTicks{NSuggestedTicks: 5}
p.Y.Tick.Marker = eicplot.LogTicks{}
p.Y.Scale = eicplot.LogScale{}
p.Legend.Top = true
var hists []*hbook.H1D
for i, filename := range flag.Args() {
if i < len(flag.Args())-1 {
hists = append(hists, makeHists(filename)[0])
} else {
hists = append(hists, makeHists(filename)...)
}
}
for i, hist := range hists {
lineColor := color.RGBA{A: 255}
switch i {
case 1:
lineColor = color.RGBA{G: 255, A: 255}
case 2:
lineColor = color.RGBA{B: 255, A: 255}
case 3:
lineColor = color.RGBA{R: 255, B: 127, G: 127, A: 255}
}
h := hplot.NewH1D(hist)
h.FillColor = nil
h.LineStyle.Color = lineColor
h.Infos.Style = hplot.HInfoNone
p.Add(h)
p.Legend.Add(hist.Name(), h)
}
p.Save(6*vg.Inch, 4*vg.Inch, *output)
}
const jpsiMass = 3.096916
func makeHists(filename string) []*hbook.H1D {
jPsiPTHist := hbook.NewH1D(50, -1, 4)
jPsiPTHist.Ann["name"] = filename + ": reconstructed"
reader, err := proio.Open(filename)
if err != nil {
log.Fatal(err)
}
for event := range reader.ScanEvents(10) {
// reconstructed
ids := event.TaggedEntries("Reconstructed")
tracks := []*eic.Track{}
for _, id := range ids {
track, ok := event.GetEntry(id).(*eic.Track)
if ok && len(track.Segment) > 0 {
tracks = append(tracks, track)
}
}
if len(tracks) == 2 {
var p [2]float64
for _, track := range tracks {
p[0] += *track.Segment[0].Poq.X
p[1] += *track.Segment[0].Poq.Y
}
t := math.Pow(p[0], 2) + math.Pow(p[1], 2)
jPsiPTHist.Fill(t, 1)
}
}
reader.Close()
return []*hbook.H1D{jPsiPTHist}
}
func pSquareD(p *eic.XYZD) float64 {
px2 := math.Pow(float64(*p.X), 2)
py2 := math.Pow(float64(*p.Y), 2)
pz2 := math.Pow(float64(*p.Z), 2)
return px2 + py2 + pz2
}
func pSquareF(p *eic.XYZF) float64 {
px2 := math.Pow(float64(*p.X), 2)
py2 := math.Pow(float64(*p.Y), 2)
pz2 := math.Pow(float64(*p.Z), 2)
return px2 + py2 + pz2
}
......@@ -19,7 +19,7 @@ import (
)
func printUsage() {
fmt.Fprintf(os.Stderr, `Usage: `+os.Args[0]+` [options] <proio-input-file>
fmt.Fprintf(os.Stderr, `Usage: `+os.Args[0]+` [options] <proio-input-files>...
options:
`,
......@@ -45,11 +45,16 @@ func main() {
p.X.Tick.Marker = eicplot.PreciseTicks{NSuggestedTicks: 5}
p.Y.Tick.Marker = eicplot.LogTicks{}
p.Y.Scale = eicplot.LogScale{}
p.Legend.Top = true
var hists []*hbook.H1D
for _, filename := range flag.Args() {
for i, filename := range flag.Args() {
if i < len(flag.Args())-1 {
hists = append(hists, makeHists(filename)[0])
} else {
hists = append(hists, makeHists(filename)...)
}
}
for i, hist := range hists {
lineColor := color.RGBA{A: 255}
......@@ -68,6 +73,7 @@ func main() {
h.Infos.Style = hplot.HInfoNone
p.Add(h)
p.Legend.Add(hist.Name(), h)
}
p.Save(6*vg.Inch, 4*vg.Inch, *output)
......@@ -77,8 +83,9 @@ const jpsiMass = 3.096916
func makeHists(filename string) []*hbook.H1D {
tHist := hbook.NewH1D(50, -1, 4)
tPTruthHist := hbook.NewH1D(50, -1, 4)
tETruthHist := hbook.NewH1D(50, -1, 4)
tHist.Ann["name"] = filename + ": reconstructed"
tTruthHist := hbook.NewH1D(50, -1, 4)
tTruthHist.Ann["name"] = "truth"
reader, err := proio.Open(filename)
if err != nil {
......@@ -110,44 +117,36 @@ func makeHists(filename string) []*hbook.H1D {
tHist.Fill(t, 1)
}
// truth
ids = event.TaggedEntries("GenStable")
protons := []*eic.Particle{}
leptons := []*eic.Particle{}
nonprotons := []*eic.Particle{}
for _, id := range ids {
part, ok := event.GetEntry(id).(*eic.Particle)
if ok {
if *part.Pdg == 2212 {
protons = append(protons, part)
} else if *part.Pdg == 11 || *part.Pdg == -11 {
leptons = append(leptons, part)
}
if *part.Pdg != 2212 {
nonprotons = append(nonprotons, part)
}
}
if len(protons) == 1 {
t := math.Pow(float64(*protons[0].P.X), 2) + math.Pow(float64(*protons[0].P.Y), 2) + math.Pow(float64(*protons[0].P.Z-100.), 2) // 100 GeV p+ beam
t -= math.Pow(math.Sqrt(pSquareF(protons[0].P)+math.Pow(float64(*protons[0].Mass), 2))-100., 2)
tPTruthHist.Fill(t, 1)
}
if len(leptons) == 3 {
if len(nonprotons) == 3 {
var p [4]float64
p[2] += 5. // 5 GeV e- beam
p[3] -= 5.
for _, lepton := range leptons {
p[0] += float64(*lepton.P.X)
p[1] += float64(*lepton.P.Y)
p[2] += float64(*lepton.P.Z)
p[3] += math.Sqrt(pSquareF(lepton.P))
for _, part := range nonprotons {
p[0] += float64(*part.P.X)
p[1] += float64(*part.P.Y)
p[2] += float64(*part.P.Z)
p[3] += math.Sqrt(pSquareF(part.P) + math.Pow(float64(*part.Mass), 2))
}
t := math.Pow(p[0], 2) + math.Pow(p[1], 2) + math.Pow(p[2], 2)
t -= math.Pow(p[3], 2)
tETruthHist.Fill(t, 1)
tTruthHist.Fill(t, 1)
}
}
reader.Close()
return []*hbook.H1D{tPTruthHist, tETruthHist, tHist}
return []*hbook.H1D{tHist, tTruthHist}
}
func pSquareD(p *eic.XYZD) float64 {
......
package main
import (
"flag"
"fmt"
"image/color"
"log"
"math"
"os"
"github.com/proio-org/go-proio"
"github.com/proio-org/go-proio-pb/model/eic"
"go-hep.org/x/hep/hbook"
"go-hep.org/x/hep/hplot"
"gonum.org/v1/plot"
"gonum.org/v1/plot/vg"
"eicweb.phy.anl.gov/EIC/eicplot"
)
func printUsage() {
fmt.Fprintf(os.Stderr, `Usage: `+os.Args[0]+` [options] <proio-input-files>...
options:
`,
)
flag.PrintDefaults()
}
func main() {
var (
title = flag.String("title", "", "plot title")
output = flag.String("output", "out.png", "output file")
)
flag.Usage = printUsage
flag.Parse()
if flag.NArg() < 1 {
printUsage()
log.Fatal("Invalid arguments")
}
p, _ := plot.New()
p.Title.Text = *title
p.X.Label.Text = "Mass (GeV)"
p.X.Tick.Marker = eicplot.PreciseTicks{NSuggestedTicks: 5}
p.Y.Tick.Marker = eicplot.PreciseTicks{NSuggestedTicks: 5}
for i, filename := range flag.Args() {
hist := makeInvMassHist(filename)
lineColor := color.RGBA{A: 255}
switch i {
case 1:
lineColor = color.RGBA{G: 255, A: 255}
case 2:
lineColor = color.RGBA{B: 255, A: 255}
case 3:
lineColor = color.RGBA{R: 255, B: 127, G: 127, A: 255}
}
h := hplot.NewH1D(hist)
h.LineStyle.Color = lineColor
if len(flag.Args()) == 1 {
h.Infos.Style = hplot.HInfoSummary
}
p.Add(h)
}
p.Save(6*vg.Inch, 4*vg.Inch, *output)
}
func makeInvMassHist(filename string) *hbook.H1D {
invMassHist := hbook.NewH1D(50, 2.9, 3.3)
reader, err := proio.Open(filename)
if err != nil {
log.Fatal(err)
}
for event := range reader.ScanEvents(10) {
ids := event.TaggedEntries("Reconstructed")
tracks := []*eic.Track{}
for _, id := range ids {
track, ok := event.GetEntry(id).(*eic.Track)
if ok && len(track.Segment) > 0 {
tracks = append(tracks, track)
}
}
for i := 0; i < len(tracks); i++ {
for j := i + 1; j < len(tracks); j++ {
if (*tracks[i].Segment[0].Chargesign)*(*tracks[j].Segment[0].Chargesign) > 0 {
continue
}
poqi := tracks[i].Segment[0].Poq
poqj := tracks[j].Segment[0].Poq
p := []float64{*poqi.X + *poqj.X, *poqi.Y + *poqj.Y, *poqi.Z + *poqj.Z}
p2 := math.Pow(p[0], 2) + math.Pow(p[1], 2) + math.Pow(p[2], 2)
Ei := math.Sqrt(math.Pow(*poqi.X, 2) + math.Pow(*poqi.Y, 2) + math.Pow(*poqi.Z, 2) + math.Pow(0.105658, 2))
Ej := math.Sqrt(math.Pow(*poqj.X, 2) + math.Pow(*poqj.Y, 2) + math.Pow(*poqj.Z, 2) + math.Pow(0.105658, 2))
E2 := math.Pow(Ei+Ej, 2)
// eta := math.Atanh(p[2] / math.Sqrt(p2))
invMass := math.Sqrt(E2 - p2)
if invMass > 2.9 && invMass < 3.3 {
invMassHist.Fill(invMass, 1)
}
}
}
}
reader.Close()
return invMassHist
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment