From f30e7b2ece42d5b05c5eeddbf8e801d09fa52032 Mon Sep 17 00:00:00 2001 From: gavalian Date: Wed, 26 Jul 2023 13:23:27 -0400 Subject: [PATCH 1/2] added a monitoring service for pion reconstruction --- .../org/jlab/display/ec/ECRECMonitor.java | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 reconstruction/ec/src/main/java/org/jlab/display/ec/ECRECMonitor.java diff --git a/reconstruction/ec/src/main/java/org/jlab/display/ec/ECRECMonitor.java b/reconstruction/ec/src/main/java/org/jlab/display/ec/ECRECMonitor.java new file mode 100644 index 000000000..c2962574a --- /dev/null +++ b/reconstruction/ec/src/main/java/org/jlab/display/ec/ECRECMonitor.java @@ -0,0 +1,71 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package org.jlab.display.ec; + +import org.jlab.clas.physics.LorentzVector; +import org.jlab.clas.reco.ReconstructionEngine; +import org.jlab.groot.data.H1F; +import org.jlab.groot.ui.TGCanvas; +import org.jlab.io.base.DataBank; +import org.jlab.io.base.DataEvent; + +/** + * + * @author gavalian + */ +public class ECRECMonitor extends ReconstructionEngine { + TGCanvas canvas = null; + H1F pion = null; + + public ECRECMonitor(){ + super("ECMon","gavalian","1.0"); + } + + @Override + public boolean processDataEvent(DataEvent event) { + if(event.hasBank("REC::Particle")==true){ + DataBank bank = event.getBank("REC::Particle"); + int index1 = this.index(bank, 22, 0); + int index2 = this.index(bank, 22, 1); + LorentzVector vL_g1 = this.getVector(bank, index1, 0.0); + LorentzVector vL_g2 = this.getVector(bank, index2, 0.0); + if(vL_g1.p()>1.0&&vL_g2.p()>1.0){ + vL_g1.add(vL_g2); + pion.fill(vL_g1.mass()); + } + } + return true; + } + + private LorentzVector getVector(DataBank b, int index, double mass){ + LorentzVector v = new LorentzVector(); + v.setPxPyPzM(b.getFloat("px", index), + b.getFloat("py", index), + b.getFloat("pz", index), + mass); + return v; + } + + private int index(DataBank b, int pid, int skip){ + int nrows = b.rows(); + int skipped = 0; + for(int r = 0; r < nrows; r++){ + int id = b.getInt("pid", r); + if(id==pid){ + if(skipped==skip) return r; + skipped++; + } + } + return -1; + } + @Override + public boolean init() { + canvas = new TGCanvas("c","EC Engine Monitoring",500,500); + canvas.getCanvas().initTimer(5000); + pion = new H1F("pion",120,0.005,0.6); + return true; + } + +} From 83713295453800f4628f5f30866bc70243a5020e Mon Sep 17 00:00:00 2001 From: gavalian Date: Wed, 26 Jul 2023 13:30:41 -0400 Subject: [PATCH 2/2] fixed a bug --- .../main/java/org/jlab/display/ec/ECRECMonitor.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/reconstruction/ec/src/main/java/org/jlab/display/ec/ECRECMonitor.java b/reconstruction/ec/src/main/java/org/jlab/display/ec/ECRECMonitor.java index c2962574a..7d8d8fe68 100644 --- a/reconstruction/ec/src/main/java/org/jlab/display/ec/ECRECMonitor.java +++ b/reconstruction/ec/src/main/java/org/jlab/display/ec/ECRECMonitor.java @@ -29,11 +29,13 @@ public boolean processDataEvent(DataEvent event) { DataBank bank = event.getBank("REC::Particle"); int index1 = this.index(bank, 22, 0); int index2 = this.index(bank, 22, 1); - LorentzVector vL_g1 = this.getVector(bank, index1, 0.0); - LorentzVector vL_g2 = this.getVector(bank, index2, 0.0); - if(vL_g1.p()>1.0&&vL_g2.p()>1.0){ - vL_g1.add(vL_g2); - pion.fill(vL_g1.mass()); + if(index1>0&&index2>0){ + LorentzVector vL_g1 = this.getVector(bank, index1, 0.0); + LorentzVector vL_g2 = this.getVector(bank, index2, 0.0); + if(vL_g1.p()>1.0&&vL_g2.p()>1.0){ + vL_g1.add(vL_g2); + pion.fill(vL_g1.mass()); + } } } return true;