diff --git a/common-tools/clas-physics/src/main/java/org/jlab/clas/physics/EventFilter.java b/common-tools/clas-physics/src/main/java/org/jlab/clas/physics/EventFilter.java deleted file mode 100644 index 5eba0fe358..0000000000 --- a/common-tools/clas-physics/src/main/java/org/jlab/clas/physics/EventFilter.java +++ /dev/null @@ -1,343 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package org.jlab.clas.physics; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.Set; -import org.jlab.clas.pdg.PDGDatabase; -import org.jlab.clas.pdg.PDGParticle; - -/** - * - * @author gavalian - */ -public class EventFilter { - - HashMap pParticleIDS; - //ArrayList pOperationCuts; - - int nNegativeParticlesWithPid; - int nPositiveParticlesWithPid; - int nNeutralParticlesWithPid; - - int nNegativeParticlesCount; - int nPositiveParticlesCount; - int nNeutralParticlesCount; - - int nNegativeParticlesAny; - int nPositiveParticlesAny; - int nNeutralParticlesAny; - - int nPositiveParticles; - int nNegativeParticles; - int nNeutralParticles; - - - long numberOfChecks = 0; - long numberOfChecksPassed = 0; - private String filterString = ""; - - public EventFilter(String filter){ - pParticleIDS = new HashMap(); - //pOperationCuts = new ArrayList(); - this.setFilter(filter); - } - - public EventFilter() - { - pParticleIDS = new HashMap(); - //pOperationCuts = new ArrayList(); - } - - - public void addCut(String name, String particle, double min, double max) - { - //pOperationCuts.add(new ParticleOperation(name,particle,min,max)); - } - - public boolean checkFinalState(PhysicsEvent event) - { - boolean filter = true; - - int pc = event.countByCharge(+1); - int pm = event.countByCharge(-1); - int pn = event.countByCharge( 0); - - if(pcthis.getMaximumByCharge(+1)) - return false; - if(pmthis.getMaximumByCharge(-1)) - return false; - if(pnthis.getMaximumByCharge( 0)) - return false; - - Set pKeys = this.getIdKeys(); - Iterator it = pKeys.iterator(); - while(it.hasNext()) - { - Integer key = (Integer) it.next(); - int idcount = this.getIdCount(key); - if(event.countByPid(key)this.getMaximumByCharge(+1)) - return false; - if(pmthis.getMaximumByCharge(-1)) - return false; - if(pnthis.getMaximumByCharge( 0)) - return false; - - Set pKeys = this.getIdKeys(); - Iterator it = pKeys.iterator(); - while(it.hasNext()) - { - Integer key = (Integer) it.next(); - int idcount = this.getIdCount(key); - if(plist.countByPid(key)0){ - nPositiveParticlesWithPid += 1; - } else { - nNegativeParticlesWithPid += 1; - } - //increaseCharge(charge,1); - } - } - - public void parseChargedSign(String charge) - { - int clen = charge.length(); - char ctrail = charge.charAt(clen-1); - int count = 0; - - if(clen==1) - { - count =1; - } else { - char pctrail = charge.charAt(clen-2); - if(pctrail=='X'){ - setInclusive(ctrail); - return; - } - count = Integer.parseInt(charge.substring(0, clen-1)); - } - - increaseChargeString(ctrail,count); - } - - public int getIdCount(Integer pidKey) - { - return pParticleIDS.get(pidKey); - } - - public Set getIdKeys() - { - return pParticleIDS.keySet(); - } - - public void setInclusive(char charge) - { - switch (charge) - { - case '+': nPositiveParticlesAny = -1; - break; - case '-': nNegativeParticlesAny = -1; - break; - case 'n': nNeutralParticlesAny = -1; - break; - default: break; - } - } - - public void increaseChargeString(char charge, int weight) - { - switch (charge) - { - case '+': nPositiveParticlesCount += weight;//increaseCharge(1,weight); - break; - case '-': nNegativeParticlesCount += weight;//increaseCharge(-1,weight); - break; - case 'n': nNeutralParticlesCount += weight;//increaseCharge(0,weight); - break; - default: break; - } - } - - public void increaseCharge(int charge, int weight) - { - switch (charge){ - case 1: if(nPositiveParticles>=0) nPositiveParticles+=weight; - break; - case -1: if(nNegativeParticles>=0) nNegativeParticles+=weight; - break; - case 0: if(nNeutralParticles>=0) nNeutralParticles+=weight; - break; - default: break; - } - } - - public final void setFilter(String opt) - { - this.filterString = opt; - clear(); - String[] tokens = opt.split(":"); - for(int loop = 0; loop < tokens.length; loop++) - { - int tokenLen = tokens[loop].length(); - if(tokenLen>0) - { - char trailingChar = tokens[loop].charAt(tokenLen-1); - if(trailingChar=='+'||trailingChar=='-'||trailingChar=='n') - { - parseChargedSign(tokens[loop]); - } else { - addPid(tokens[loop]); - } - } - } - this.numberOfChecks = 0; - this.numberOfChecksPassed = 0; - } - - public int getMinimumByCharge(int charge) - { - if(charge==0) - { - return (nNeutralParticlesWithPid + nNeutralParticlesCount); - } else if(charge > 0) { - return (nPositiveParticlesWithPid + nPositiveParticlesCount); - } - - return (nNegativeParticlesWithPid + nNegativeParticlesCount); - } - - public int getMaximumByCharge(int charge) - { - if(charge==0) - { - if(nNeutralParticlesAny<0){ - return 100; - } else { - return getMinimumByCharge(0); - } - } - - if(charge>0){ - if(nPositiveParticlesAny<0) - { - return 100; - } else { - return getMinimumByCharge(1); - } - } - - if(nNegativeParticlesAny<0) - { - return 100; - } else { - return getMinimumByCharge(-1); - } - } - - public int getCountByCharge(int charge) - { - if(charge==0) - { - return nNeutralParticles; - } else if(charge>0) return nPositiveParticles; - return nNegativeParticles; - } - - @Override - public String toString() - { - StringBuilder str = new StringBuilder(); - str.append(String.format("FILTER:---> POSITIVE : %6d %6d, NEGATIVE : %6d %6d , " - + "NEUTRAL : %6d %6d", - getMinimumByCharge( 1),getMaximumByCharge( 1), - getMinimumByCharge(-1),getMaximumByCharge(-1), - getMinimumByCharge( 0),getMaximumByCharge( 0))); - //nPositiveParticles, nNegativeParticles, nNeutralParticles)); - return str.toString(); - } - -} diff --git a/common-tools/clas-physics/src/main/java/org/jlab/clas/physics/LorentzVector.java b/common-tools/clas-physics/src/main/java/org/jlab/clas/physics/LorentzVector.java index 2b20b5bd1f..71cddc16d8 100644 --- a/common-tools/clas-physics/src/main/java/org/jlab/clas/physics/LorentzVector.java +++ b/common-tools/clas-physics/src/main/java/org/jlab/clas/physics/LorentzVector.java @@ -1,7 +1,3 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ package org.jlab.clas.physics; /** diff --git a/common-tools/clas-physics/src/main/java/org/jlab/clas/physics/Particle.java b/common-tools/clas-physics/src/main/java/org/jlab/clas/physics/Particle.java index 29b95fcc20..65c8e718ec 100644 --- a/common-tools/clas-physics/src/main/java/org/jlab/clas/physics/Particle.java +++ b/common-tools/clas-physics/src/main/java/org/jlab/clas/physics/Particle.java @@ -1,7 +1,3 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ package org.jlab.clas.physics; import java.util.HashMap; diff --git a/common-tools/clas-physics/src/main/java/org/jlab/clas/physics/ParticleFinder.java b/common-tools/clas-physics/src/main/java/org/jlab/clas/physics/ParticleFinder.java deleted file mode 100644 index 2e2992e821..0000000000 --- a/common-tools/clas-physics/src/main/java/org/jlab/clas/physics/ParticleFinder.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.jlab.clas.physics; - -import java.util.ArrayList; -import java.util.List; -import org.jlab.clas.pdg.PDGDatabase; - -/** - * - * @author gavalian - */ -public class ParticleFinder { - private final List particleOperations = new ArrayList(); - - public ParticleFinder(){ - - } - - public void generate(PhysicsEvent event){ - particleOperations.clear(); - int nphotons = event.countByPid(22); - if(nphotons<2) return; - for(int i = 0; i < nphotons; i++){ - for(int k = 0; k < nphotons;k++){ - if(i!=k){ - particleOperations.add(String.format("[22,%d]+[22,%d]", i,k)); - } - } - } - } - - public Particle getPion(PhysicsEvent event){ - this.generate(event); - - double mass = PDGDatabase.getParticleById(111).mass(); - double distance = 1.0; - Particle pion = null; - for(String selection : particleOperations){ - Particle candidate = event.getParticle(selection); - if(Math.abs(candidate.vector().mass()-mass) < distance){ - distance = Math.abs(candidate.vector().mass()-mass); - pion = candidate; - } - } - return pion; - } -} diff --git a/common-tools/clas-physics/src/main/java/org/jlab/clas/physics/ParticleGenerator.java b/common-tools/clas-physics/src/main/java/org/jlab/clas/physics/ParticleGenerator.java deleted file mode 100644 index 7238af9259..0000000000 --- a/common-tools/clas-physics/src/main/java/org/jlab/clas/physics/ParticleGenerator.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ - -package org.jlab.clas.physics; - -/** - * - * @author gavalian - */ -public class ParticleGenerator { - private int particleID = 11; - private double pCosThetaMin = -1.0; - private double pCosThetaMax = 1.0; - private double pPhiMin = -180.0; - private double pPhiMax = -180.0; - private double pMomentumMin = 1.0; - private double pMomentumMax = 5.0; - private final Vector3 vertexConstrains = new Vector3(0.0,0.0,0.0); - - public ParticleGenerator(int pid){ - particleID = pid; - } - - public ParticleGenerator(int pid, double pmin, double pmax, double thmin, double thmax, - double phimin, double phimax){ - particleID = pid; - this.setRange(pmin, pmax, thmin, thmax, phimin, phimax); - } - - public final void setRange(double pmin, double pmax, double thmin, double thmax, - double phimin, double phimax){ - this.setMomRange(pmin, pmax); - this.setThetaRange(thmin, thmax); - this.setPhiRange(phimin, phimax); - } - - public ParticleGenerator setMomRange(double pmin, double pmax){ - pMomentumMin = pmin; - pMomentumMax = pmax; - return this; - } - - public ParticleGenerator setPhiRange(double pmin, double pmax){ - pPhiMin = pmin; - pPhiMax = pmax; - return this; - } - - public ParticleGenerator setThetaRange(double tmin, double tmax){ - pCosThetaMin = Math.cos(Math.toRadians(tmin)); - pCosThetaMax = Math.cos(Math.toRadians(tmax)); - return this; - } - - public Particle getParticle(){ - double p = pMomentumMin + Math.random()*(pMomentumMax-pMomentumMin); - double theta = Math.acos(pCosThetaMin + Math.random()*(pCosThetaMax-pCosThetaMin)); - double phi = Math.toRadians(pPhiMin + Math.random()*(pPhiMax-pPhiMin)); - //Vector3 pvector = new Vector3(p*Math.sin(theta)*Math.cos(phi), - //p*Math.sin(theta)*Math.sin(phi),p*Math.cos(theta)); - Particle part = new Particle(particleID, - p*Math.sin(theta)*Math.cos(phi), - p*Math.sin(theta)*Math.sin(phi), - p*Math.cos(theta),0.0,0.0,0.0); - return part; - } - -} diff --git a/common-tools/clas-physics/src/main/java/org/jlab/clas/physics/ParticleList.java b/common-tools/clas-physics/src/main/java/org/jlab/clas/physics/ParticleList.java deleted file mode 100644 index 944eff28b9..0000000000 --- a/common-tools/clas-physics/src/main/java/org/jlab/clas/physics/ParticleList.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.jlab.clas.physics; - -import java.util.ArrayList; -import java.util.List; - -/** - * - * @author gavalian - */ -public class ParticleList { - - private List particles = new ArrayList(); - - public ParticleList(){ - - } - - - public void add(Particle p){ - this.particles.add(p); - } - - public void clear(){ particles.clear();} - - public int count(){ return particles.size();} - /** - * returns number of particles of given charge - * @param charge charge of the particle - * @return count - */ - public int countByCharge(int charge){ - int count = 0; - for(Particle p : particles){ - if(p.charge()==charge) count++; - } - return count; - } - /** - * returns number of particles with given particle id (lund id) - * @param pid particle id - * @return count - */ - public int countByPid(int pid){ - int count = 0; - for(Particle p : particles){ - if(p.pid()==pid) count++; - } - return count; - } - /** - * returns particle with id = pid and skips 'skip' particles - * @param pid - * @param skip - * @return - */ - public Particle getByPid(int pid, int skip){ - int skipped = 0; - for(int i = 0; i < particles.size();i++){ - if(particles.get(i).pid()==pid){ - if(skipped==skip){ - return particles.get(i); - } else { - skipped++; - } - } - } - return null; - } - /** - * returns particles by charge skipping skip particles. - * @param charge - * @param skip - * @return - */ - public Particle getByCharge(int charge, int skip){ - int skipped = 0; - for(int i = 0; i < particles.size();i++){ - if(particles.get(i).charge()==charge){ - if(skipped==skip){ - return particles.get(i); - } else { - skipped++; - } - } - } - return null; - } - - public String toLundString(){ - StringBuilder str = new StringBuilder(); - for(int loop = 0; loop < particles.size(); loop++){ - str.append(String.format("%5d", loop+1)); - str.append(particles.get(loop).toLundString()); - str.append("\n"); - } - /* - str.append(String.format("%10d %9.5f %9.5f\n",eventParticles.size(),eventBeam.vector().e(), - eventTarget.vector().mass())); - for(int loop = 0; loop < eventParticles.size(); loop++){ - str.append(eventParticles.get(loop).toString()); - str.append("\n"); - }*/ - return str.toString(); - } -} diff --git a/common-tools/clas-physics/src/main/java/org/jlab/clas/physics/ParticleNotFoundException.java b/common-tools/clas-physics/src/main/java/org/jlab/clas/physics/ParticleNotFoundException.java deleted file mode 100644 index 80faaf4e5f..0000000000 --- a/common-tools/clas-physics/src/main/java/org/jlab/clas/physics/ParticleNotFoundException.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.jlab.clas.physics; - -/** - * - * @author gavalian - */ -public class ParticleNotFoundException extends Exception { - String message = ""; - - public ParticleNotFoundException(String msg){ - super(msg); - this.message = msg; - } - - public ParticleNotFoundException(Throwable cause){ - super(cause); - } - - @Override - public String toString(){ - return message; - } - - @Override - public String getMessage(){ - return message; - } -} diff --git a/common-tools/clas-physics/src/main/java/org/jlab/clas/physics/PhysicsEvent.java b/common-tools/clas-physics/src/main/java/org/jlab/clas/physics/PhysicsEvent.java deleted file mode 100644 index 23553ba2dd..0000000000 --- a/common-tools/clas-physics/src/main/java/org/jlab/clas/physics/PhysicsEvent.java +++ /dev/null @@ -1,405 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package org.jlab.clas.physics; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - -import org.jlab.clas.pdg.PDGDatabase; -import org.jlab.clas.pdg.PDGParticle; -import org.jlab.physics.base.EventSelector; - -/** - * - * @author gavalian - */ -public class PhysicsEvent { - - Particle eventBeam; - Particle eventTarget; - private EventSelector eventSelector = new EventSelector(); - List eventParticles; - List generatedParticles; - HashMap eventProperties; - - private ParticleList mcEvent = new ParticleList(); - private double matchThresholdResolution = 0.02; - private double matchThresholdAngle = 0.998; - - public PhysicsEvent() { - eventBeam = new Particle(11, 0., 0., 5.017, 0., 0., 0.); - eventTarget = new Particle(2212, 0., 0., 0., 0., 0., 0.); - eventParticles = new ArrayList(); - generatedParticles = new ArrayList(); - eventProperties = new HashMap(); - } - - public PhysicsEvent(double be) { - eventBeam = new Particle(11, 0., 0., be, 0., 0., 0.); - eventTarget = new Particle(2212, 0., 0., 0., 0., 0., 0.); - eventParticles = new ArrayList(); - generatedParticles = new ArrayList(); - eventProperties = new HashMap(); - } - - public void addProperty(String name, double value) { - eventProperties.put(name, value); - } - - public boolean hasProperty(String name) { - return eventProperties.containsKey(name); - } - - /** - * returns generated event - * - * @return - */ - public ParticleList mc() { - return this.mcEvent; - } - - /** - * returns particle from reconstructed event that matches particle selected from generated event. - * - * @param pid - * pid of the particle in generated event - * @param skip - * order of particle in generated event - * @return particle from reconstructed event - */ - public Particle getParticleMatchByPid(int pid, int skip) { - Particle p = this.mcEvent.getByPid(pid, skip); - Particle result = new Particle(); - double bestCos = 0.5; - double bestRes = 0.5; - // System.out.println(" LOOKING FOR MATCH WITH = " + p.toLundString()); - for (int i = 0; i < this.eventParticles.size(); i++) { - if (p.charge() == this.eventParticles.get(i).charge()) { - double cosTheta = p.cosTheta(eventParticles.get(i)); - double resolution = Math.abs((p.p() - eventParticles.get(i).p()) / p.p()); - // System.out.println(i + " " + " cos = " + cosTheta + " res = " + resolution); - if (cosTheta > bestCos && resolution < bestRes) { - if (cosTheta >= this.matchThresholdAngle && resolution < this.matchThresholdResolution) { - bestCos = cosTheta; - bestRes = resolution; - // System.out.println(" THIS IS A GOOD PARTICLE = " + eventParticles.get(i).toLundString()); - result.copy(eventParticles.get(i)); - } - } - } - } - return result; - } - - public double getProperty(String name) { - return eventProperties.get(name); - } - - public void clear() { - eventParticles.clear(); - eventProperties.clear(); - generatedParticles.clear(); - } - - public int count() { - return eventParticles.size(); - } - - public int countGenerated() { - return generatedParticles.size(); - } - - public int countByCharge(int charge) { - int icount = 0; - // System.out.println("countainer size = " + eventParticles.size()); - for (int loop = 0; loop < eventParticles.size(); loop++) { - // System.out.println("Particle pid = " + eventParticles.get(loop).pid() - // + " charge = " + eventParticles.get(loop).charge()); - if (eventParticles.get(loop).charge() == charge) - icount++; - } - // System.out.println("particles with charge " + charge + " = " + icount); - return icount; - } - - /** - * returns number of particles with given PID (Lund id), if generated flag==true the count in generated particles is returned. - * - * @param pid - * @param generated - * @return - */ - public int countByPid(int pid, boolean generated) { - if (generated == false) - return countByPid(pid); - int icount = 0; - for (int loop = 0; loop < generatedParticles.size(); loop++) - if (generatedParticles.get(loop).pid() == pid) - icount++; - return icount; - } - - public int countByPid(int pid) { - int icount = 0; - for (int loop = 0; loop < eventParticles.size(); loop++) - if (eventParticles.get(loop).pid() == pid) - icount++; - return icount; - } - - public void addGeneratedParticle(Particle part) { - generatedParticles.add(part); - } - - public void addGeneratedParticle(int pid, double px, double py, double pz, double vx, double vy, double vz) { - generatedParticles.add(new Particle(pid, px, py, pz, vx, vy, vz)); - } - - public void addParticle(Particle part) { - eventParticles.add(part); - } - - public void addParticle(int pid, double px, double py, double pz, double vx, double vy, double vz) { - eventParticles.add(new Particle(pid, px, py, pz, vx, vy, vz)); - } - - public void setBeam(String particle, double mom_z) { - PDGParticle partInfo = PDGDatabase.getParticleByName(particle); - if (partInfo != null) { - this.eventBeam.setVector(partInfo.pid(), 0.0, 0.0, mom_z, 0.0, 0.0, -100.0); - } - } - - public void setBeam(double mom_z) { - this.eventBeam = new Particle(11, 0.0, 0.0, mom_z, 0.0, 0.0, -100.0); - } - - public void setBeamParticle(Particle p) { - eventBeam.copyParticle(p); - } - - public void setTargetParticle(Particle p) { - eventTarget.copyParticle(p); - } - - public Particle beamParticle() { - return eventBeam; - } - - public Particle targetParticle() { - return eventTarget; - } - - public int getParticleIndex(int pid, int skip) { - int skiped = 0; - for (int loop = 0; loop < eventParticles.size(); loop++) { - // System.err.println("searching ----> " + CLASParticles.get(loop).getPid() - // + " " + skip + " " + skiped); - if (eventParticles.get(loop).pid() == pid) { - if (skip == skiped) - return loop; - else - skiped++; - } - } - return -1; - } - - public void removeParticleByPid(int pid, int skip) { - int index = getParticleIndex(pid, skip); - if (index < 0 || index >= this.count()) { - System.out.println("----> error. paritcle does not exist pid=" + pid + " skip=" + skip); - } else { - this.removeParticle(index); - } - } - - public void removeParticle(int index) { - eventParticles.remove(index); - } - - public Particle getParticleByCharge(int charge, int skip) { - int skiped = 0; - for (int loop = 0; loop < eventParticles.size(); loop++) { - // System.err.println("searching ----> " + CLASParticles.get(loop).getPid() - // + " " + skip + " " + skiped); - if (eventParticles.get(loop).charge() == charge) { - if (skip == skiped) - return eventParticles.get(loop); - else - skiped++; - } - } - return null; - } - - public Particle getParticleByCharge(int charge, int skip, int pid) { - int skiped = 0; - for (int loop = 0; loop < eventParticles.size(); loop++) { - // System.err.println("searching ----> " + CLASParticles.get(loop).getPid() - // + " " + skip + " " + skiped); - if (eventParticles.get(loop).charge() == charge) { - if (skip == skiped) { - Particle ref = eventParticles.get(loop); - Particle part = new Particle(pid, ref.vector().px(), ref.vector().py(), ref.vector().pz(), ref.vertex().x(), - ref.vertex().y(), ref.vertex().z()); - return part; - } else - skiped++; - } - } - return null; - } - - public Particle getParticleByPid(int pid, int skip) { - if (pid == 5000) - return this.beamParticle(); - if (pid == 5001) - return this.targetParticle(); - - int index = this.getParticleIndex(pid, skip); - if (index < 0 || index >= this.count()) { - return new Particle(pid, 0., 0., 0., 0., 0., 0.); - } - return eventParticles.get(index); - } - - public Particle getGeneratedParticle(int index) { - if (index < 0 || index >= generatedParticles.size()) - return null; - return generatedParticles.get(index); - } - - public Particle getParticle(int index) { - if (index < 0 || index >= eventParticles.size()) - return null; - return eventParticles.get(index); - } - - public Particle getParticle(String selector) { - EventSelector evt_selector = new EventSelector(selector); - return evt_selector.get(this); - /* - * eventSelector.parse(selector); return eventSelector.get(this); - */ - } - - /* public Particle getParticleByPid(int pid, int skip) { - if (pid == 5000) - return this.beamParticle(); - if (pid == 5001) - return this.targetParticle(); - - int index = this.getParticleIndex(pid, skip); - if (index < 0 || index >= this.count()) { - return new Particle(pid, 0., 0., 0., 0., 0., 0.); - } - return eventParticles.get(index); - }*/ - - public String toLundStringGenerated() { - StringBuilder str = new StringBuilder(); - str.append(String.format("%12d %2d. %2d. %2d %2d %5.3f %7.3f %7.3f %7.3f %7.3f\n", generatedParticles.size(), (int) 1, (int) 1, - (int) 1, (int) 1, (float) 0.0, (float) 0.0, eventBeam.vector().e(), (float) 0.0, (float) 0.0)); - for (int loop = 0; loop < generatedParticles.size(); loop++) { - str.append(String.format("%5d", loop + 1)); - str.append(generatedParticles.get(loop).toLundString()); - str.append("\n"); - } - return str.toString(); - } - - public String toLundString() { - StringBuilder str = new StringBuilder(); - str.append(String.format("%12d %2d. %2d. %2d %2d %5.3f %7.3f %7.3f %7.3f %7.3f\n", eventParticles.size(), (int) 1, (int) 1, (int) 1, - (int) 1, (float) 0.0, (float) 0.0, eventBeam.vector().e(), (float) 0.0, (float) 0.0)); - for (int loop = 0; loop < eventParticles.size(); loop++) { - str.append(String.format("%5d", loop + 1)); - str.append(eventParticles.get(loop).toLundString()); - str.append("\n"); - } - /* - * str.append(String.format("%10d %9.5f %9.5f\n",eventParticles.size(),eventBeam.vector().e(), eventTarget.vector().mass())); for(int loop = 0; loop < - * eventParticles.size(); loop++){ str.append(eventParticles.get(loop).toString()); str.append("\n"); } - */ - return str.toString(); - } - - @Override - public String toString() { - StringBuilder str = new StringBuilder(); - str.append(String.format("%12d %2d. %2d. %2d %2d %5.3f %7.3f %7.3f %7.3f %7.3f\n", eventParticles.size(), (int) 1, (int) 1, (int) 1, - (int) 1, (float) 0.0, (float) 0.0, eventBeam.vector().e(), (float) 0.0, (float) 0.0)); - for (int loop = 0; loop < eventParticles.size(); loop++) { - str.append(String.format("%5d", loop + 1)); - str.append(eventParticles.get(loop).toString()); - str.append("\n"); - } - return str.toString(); - } - - public Particle closestParticle(Particle child) { - Particle part = new Particle(); - double minCos = -1.0; - int index = -2; - int icounter = 0; - for (Particle p : eventParticles) { - double cth = p.cosTheta(child); - if (cth > minCos) { - minCos = cth; - index = icounter; - } - icounter++; - } - if (index >= 0) - part.copyParticle(eventParticles.get(index)); - return part; - } - - public Vector3 primaryVertex() { - Particle proton = this.getParticleByPid(2212, 0); - if (proton.vector().p() > 0) { - return this.beamParticle().particleDoca(proton); - } - return new Vector3(); - } - - Vector3 reactionVertexThreeParticles(int index[]) { - if (index.length == 2) { - - } - return new Vector3(); - } - - Vector3 reactionVertexTwoParticles(int index[]) { - if (index.length == 2) { - - } - return new Vector3(); - } - - public List getParticleListByPid(int... pids_order) { - ArrayList plist = new ArrayList(); - for (int loop = 0; loop < pids_order.length; loop += 2) { - Particle part = this.getParticleByPid(pids_order[loop], pids_order[loop + 1]); - if (part != null) { - plist.add(part); - } - } - return plist; - } - - public List getParticlesByPid(int pid){ - List plist = new ArrayList(); - for(Particle part: eventParticles){ - if(part.pid()==pid){ - plist.add(part); - } - } - return plist; - } -} diff --git a/common-tools/clas-physics/src/main/java/org/jlab/clas/physics/PhysicsKinematics.java b/common-tools/clas-physics/src/main/java/org/jlab/clas/physics/PhysicsKinematics.java deleted file mode 100644 index 1e69d5ff64..0000000000 --- a/common-tools/clas-physics/src/main/java/org/jlab/clas/physics/PhysicsKinematics.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.jlab.clas.physics; - -import org.jlab.clas.reactions.DecayKinematics; - -/** - * - * @author gavalian - */ -public class PhysicsKinematics { - - public static Particle getParticleUnBoosted(Particle frame, Particle part){ - Vector3 boost = frame.vector().boostVector(); - boost.negative(); - LorentzVector vecL = new LorentzVector(); - vecL.copy(part.vector()); - vecL.boost(boost); - Vector3 partBoosted = new Vector3(); - partBoosted.copy(vecL.vect()); - Vector3 partInFrame = DecayKinematics.vectorToFrame(frame.vector().vect(), partBoosted); - Particle result = new Particle(); - result.setParticleWithMass(part.mass(), (byte) part.charge(), - partInFrame.x(),partInFrame.y(),partInFrame.z(), - part.vertex().x(),part.vertex().y(),part.vertex().z()); - return result; - } - - public static Particle getParticleUnBoosted(Particle frame, Particle part, Boolean isBoosted){ - Vector3 boost = frame.vector().boostVector(); - boost.negative(); - LorentzVector vecL = new LorentzVector(); - vecL.copy(part.vector()); - if(isBoosted==true){ - vecL.boost(boost); - } - Vector3 partBoosted = new Vector3(); - partBoosted.copy(vecL.vect()); - Vector3 partInFrame = DecayKinematics.vectorToFrame(frame.vector().vect(), partBoosted); - Particle result = new Particle(); - result.setParticleWithMass(part.mass(), (byte) part.charge(), - partInFrame.x(),partInFrame.y(),partInFrame.z(), - part.vertex().x(),part.vertex().y(),part.vertex().z()); - return result; - } - -} diff --git a/common-tools/clas-physics/src/main/java/org/jlab/clas/physics/Vector3.java b/common-tools/clas-physics/src/main/java/org/jlab/clas/physics/Vector3.java index 35cc04c4e8..e30dfe1722 100644 --- a/common-tools/clas-physics/src/main/java/org/jlab/clas/physics/Vector3.java +++ b/common-tools/clas-physics/src/main/java/org/jlab/clas/physics/Vector3.java @@ -1,7 +1,3 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ package org.jlab.clas.physics; /** diff --git a/common-tools/clas-physics/src/main/java/org/jlab/clas/reactions/DecayKinematics.java b/common-tools/clas-physics/src/main/java/org/jlab/clas/reactions/DecayKinematics.java deleted file mode 100644 index eba541f9b4..0000000000 --- a/common-tools/clas-physics/src/main/java/org/jlab/clas/reactions/DecayKinematics.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package org.jlab.clas.reactions; - -import org.jlab.clas.physics.Vector3; -import org.jlab.clas.physics.LorentzVector; -/** - * - * @author gavalian - */ -public class DecayKinematics { - - public static TransMatrix trMatrix = DecayKinematics.initMatrix(); - - public DecayKinematics() - { - - } - - public static TransMatrix initMatrix() - { - return new TransMatrix(); - } - - public static Vector3 vectorToLab(Vector3 frame, Vector3 vec) - { - DecayKinematics.trMatrix.compose(frame); - DecayKinematics.trMatrix.inverse(); - return DecayKinematics.trMatrix.mult(vec); - } - - public static Vector3 vectorToFrame(Vector3 frame, Vector3 vec) - { - DecayKinematics.trMatrix.compose(frame); - return DecayKinematics.trMatrix.mult(vec); - } - - public static double TwoBodyDecayMomentum(double M, double m1, double m2) - { - double mult1 = M*M - (m1+m2)*(m1+m2); - double mult2 = M*M - (m1-m2)*(m1-m2); - double mult = mult1*mult2; - if(mult<0) - { - System.err.println("Decay:: error. particle with Mass="+M - + " can not decay to particles with masses ( " + m1 - + " , " + m2 + " )"); - return -1.0; - } - return Math.sqrt(mult)/(2.0*M); - } - - public static LorentzVector[] getDecayParticles(LorentzVector parent, - double m1, double m2, double theta_rf, double phi_rf) - { - LorentzVector[] pd = new LorentzVector[2]; - for(int loop=0;loop<2;loop++) pd[loop] = new LorentzVector(); - double momentum = DecayKinematics.TwoBodyDecayMomentum(parent.mass(), m1, m2); - Vector3 vz = new Vector3(0.,0.,0.); - Vector3 v1 = new Vector3(); - Vector3 v2 = new Vector3(); - - v1.setMagThetaPhi(momentum, theta_rf, phi_rf); - vz.sub(v1); - v2.setMagThetaPhi(momentum, Math.PI-theta_rf, 2.0*Math.PI-phi_rf); - pd[0].setVectM(v1, m1); - pd[1].setVectM(vz, m2); - return pd; - } - - public static LorentzVector[] getDecayParticlesLab(LorentzVector parent, - double m1, double m2, double theta_rf, double phi_rf) - { - LorentzVector[] vectD = DecayKinematics.getDecayParticles(parent, m1, m2, theta_rf, phi_rf); - Vector3 vboost = parent.boostVector(); - vectD[0].boost(vboost); - vectD[1].boost(vboost); - return vectD; - } - -} diff --git a/common-tools/clas-physics/src/main/java/org/jlab/clas/reactions/IDecay.java b/common-tools/clas-physics/src/main/java/org/jlab/clas/reactions/IDecay.java deleted file mode 100644 index 5f567fe7d8..0000000000 --- a/common-tools/clas-physics/src/main/java/org/jlab/clas/reactions/IDecay.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package org.jlab.clas.reactions; - -import org.jlab.clas.physics.PhysicsEvent; - -/** - * - * @author gagikgavalian - */ - -public interface IDecay { - void init(); - void setDecayParticle(int id); - void setDecayParticle(String name); - void setDecayProducts(int pid1, int pid2); - void setDecayProducts(String name1, String name2); - void setDecayProducts(int pid1, int pid2, int pid3); - void setDecayProducts(String name1, String name2, String name3); - void decayParticles(PhysicsEvent event); -} diff --git a/common-tools/clas-physics/src/main/java/org/jlab/clas/reactions/TransMatrix.java b/common-tools/clas-physics/src/main/java/org/jlab/clas/reactions/TransMatrix.java deleted file mode 100644 index f55bb6997c..0000000000 --- a/common-tools/clas-physics/src/main/java/org/jlab/clas/reactions/TransMatrix.java +++ /dev/null @@ -1,205 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package org.jlab.clas.reactions; - -import org.jlab.clas.physics.Vector3; - -/** - * - * @author gagikgavalian - */ -public class TransMatrix { - double[][] tMatrix; - double[] partialMatrix; - - Vector3[] LabV; - Vector3[] PrimeV; - - Vector3 Lab1; - Vector3 Lab2; - Vector3 Lab3; - Vector3 Prime1; - Vector3 Prime2; - Vector3 Prime3; - - public TransMatrix() - { - tMatrix = new double[3][3]; - partialMatrix = new double[4]; - - LabV = new Vector3[3]; - PrimeV = new Vector3[3]; - - for(int loop = 0; loop < 3; loop++) - { - LabV[loop] = new Vector3(); - PrimeV[loop] = new Vector3(); - } - - LabV[0].setXYZ(1.0, 0.0, 0.0); - LabV[1].setXYZ(0.0, 1.0, 0.0); - LabV[2].setXYZ(0.0, 0.0, 1.0); - - PrimeV[0].setXYZ(1.0, 0.0, 0.0); - PrimeV[1].setXYZ(0.0, 1.0, 0.0); - PrimeV[2].setXYZ(0.0, 0.0, 1.0); - - Lab1 = new Vector3(1.0, 0.0, 0.0); - Lab2 = new Vector3(0.0, 1.0, 0.0); - Lab3 = new Vector3(0.0, 0.0, 1.0); - Prime1 = new Vector3(1.0, 0.0, 0.0); - Prime2 = new Vector3(0.0, 1.0, 0.0); - Prime3 = new Vector3(0.0, 0.0, 1.0); - } - - public double get(int row, int col) - { - return tMatrix[row][col]; - } - - public void set(int row, int col, double val) - { - tMatrix[row][col] = val; - } - - double partialDet(int exrow, int excol) - { - int index = 0; - for(int ir = 0; ir < 3; ir++) - for(int ic = 0; ic < 3; ic++) - { - if(ir!=exrow&&ic!=excol) - { - partialMatrix[index] = get(ir,ic); - index++; - } - } - return (partialMatrix[3]*partialMatrix[0]-partialMatrix[1]*partialMatrix[2]); - } - - public double det() - { - double determ = 0.0; - double factor = +1.0; - for(int ir=0;ir<3;ir++) - { - factor = +1.0; - if(ir==1) factor = -1.0; - determ += get(ir,0)*factor*partialDet(ir,0); - } - return determ; - } - - double epsilon(int i, int j) - { - double e = 0.0; - if(i==0||i==2){ - if(j==1){ - e = -1.; - } else { - e = +1.; - } - } - - if(i==1){ - if(j==1){ - e = +1.; - } else { - e = -1.; - } - } - return e; - } - public void unit() - { - for(int ir = 0; ir < 3; ir++) - for(int ic = 0; ic < 3; ic++) - set(ir,ic,0.0); - set(0,0,1.0); - set(1,1,1.0); - set(2,2,1.0); - } - public void setRow(int row, double v1, double v2, double v3) - { - set(row,0,v1); - set(row,1,v2); - set(row,2,v3); - } - - public void compose(Vector3 vec) - { - PrimeV[1] = LabV[2].cross(vec); - if(PrimeV[1].mag()==0) - { - //System.out.println("set prime vector to lab direction"); - PrimeV[1].setXYZ(0.0, 1.0, 0.0); - } - //System.out.println(" Mag = " + PrimeV[1].mag()); - PrimeV[1].unit(); - //System.out.println(" Mag unit = " + PrimeV[1].mag()); - PrimeV[2].setXYZ(vec.x(), vec.y(), vec.z()); - PrimeV[2].unit(); - PrimeV[0] = PrimeV[1].cross(PrimeV[2]); - - //System.out.println("-------> prime vector"); - /*for(int j = 0; j < 3; j++) - System.out.println(PrimeV[j].x() + " " + PrimeV[j].y() + " " + PrimeV[j].z() + " " + PrimeV[j].mag()); - System.out.println("-------> lab vector"); - for(int j = 0; j < 3; j++) - System.out.println(LabV[j].x() + " " + LabV[j].y() + " " + LabV[j].z()); - */ - for(int ir = 0; ir < 3; ir++) - for(int ic=0;ic<3;ic++) - this.set(ir, ic, PrimeV[ir].dot(LabV[ic])); - } - - public Vector3 mult(Vector3 v) - { - Vector3 trvec = new Vector3(); - trvec.setXYZ(get(0,0)*v.x()+get(0,1)*v.y()+get(0,2)*v.z(), - get(1,0)*v.x()+get(1,1)*v.y()+get(1,2)*v.z(), - get(2,0)*v.x()+get(2,1)*v.y()+get(2,2)*v.z() - ); - return trvec; - } - - public void inverse() - { - double[][] matRes = new double[3][3]; - double determ = this.det(); - if(determ==0.0) - { - System.err.println("----> error in transmatrix deteminant is 0.0 and it can not be inversed."); - return; - } - - double rvalue; - - for(int ir = 0; ir < 3; ir++) - for(int ic = 0; ic < 3; ic++) - { - // Check this later if the reversed index is correct for epsilon. - rvalue = this.epsilon(ic, ir)*partialDet(ir,ic)/determ; - //rvalue = partialDet(ir,ic)/determ; - matRes[ir][ic] = rvalue; - } - - for(int ir = 0; ir < 3; ir++) - for(int ic = 0; ic < 3; ic++) - { - this.set(ir,ic,matRes[ic][ir]); - //this.set(ir,ic,matRes[ir][ic]); - } - } - - public void print() - { - System.out.println("\n"); - for(int ir = 0; ir < 3; ir++) - System.out.println(String.format("%8.5f,%8.5f,%8.5f", - get(ir,0),get(ir,1),get(ir,2))); - - } -} diff --git a/common-tools/clas-physics/src/main/java/org/jlab/clas/reactions/TwoBodyDecay.java b/common-tools/clas-physics/src/main/java/org/jlab/clas/reactions/TwoBodyDecay.java deleted file mode 100644 index d4d5216558..0000000000 --- a/common-tools/clas-physics/src/main/java/org/jlab/clas/reactions/TwoBodyDecay.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package org.jlab.clas.reactions; - -import org.jlab.clas.pdg.PDGDatabase; -import org.jlab.clas.pdg.PDGParticle; -import org.jlab.clas.physics.LorentzVector; -import org.jlab.clas.physics.Particle; -import org.jlab.clas.physics.PhysicsEvent; -import org.jlab.clas.physics.Vector3; - - -/** - * - * @author gavalian - */ -public class TwoBodyDecay implements IDecay { - - int decayParticleID1; - int decayParticleID2; - int parentParticleID; - LorentzVector decayProd1; - LorentzVector decayProd2; - - public TwoBodyDecay() - { - this.setDecayParticle(111); - this.setDecayProducts(22,22); - } - - public TwoBodyDecay(int parentID, int childid1, int childid2) - { - decayProd1 = new LorentzVector(); - decayProd2 = new LorentzVector(); - this.setDecayParticle(parentID); - this.setDecayProducts(childid1,childid2); - } - - public TwoBodyDecay(String parent, String child1, String child2) - { - this.setDecayParticle(parent); - this.setDecayProducts(child1, child2); - } - - public void init() { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public void setDecayParticle(int id) { - this.parentParticleID = id; - } - - public void setDecayParticle(String name) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public void setDecayProducts(int pid1, int pid2) { - this.decayParticleID1 = pid1; - this.decayParticleID2 = pid2; - } - - public void setDecayProducts(String name1, String name2) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public void setDecayProducts(int pid1, int pid2, int pid3) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public void setDecayProducts(String name1, String name2, String name3) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - private double getCosThetaRandom(){ - return Math.random()*2.0-1.0; - } - - private double getPhiRandom(){ - return Math.random()*2.0*Math.PI-Math.PI; - } - - public void decayParticles(PhysicsEvent event) { - double cosTheta = this.getCosThetaRandom(); - double phi = this.getPhiRandom(); - - PDGParticle p1 = PDGDatabase.getParticleById(decayParticleID1); - PDGParticle p2 = PDGDatabase.getParticleById(decayParticleID2); - - Particle mother = event.getParticleByPid(parentParticleID, 0); - LorentzVector vector = new LorentzVector(); - vector.copy(mother.vector()); - - LorentzVector[] vec = DecayKinematics.getDecayParticles(vector, - p1.mass(), p2.mass(), Math.acos(cosTheta), phi); - Vector3 vectBoost = vector.boostVector(); - vec[0].boost(vectBoost); - vec[1].boost(vectBoost); - decayProd1.copy(vec[0]); - decayProd2.copy(vec[1]); - - int index = event.getParticleIndex(parentParticleID, 0); - event.removeParticle(index); - - event.addParticle(new Particle(decayParticleID1, - vec[0].px(), vec[0].py(), vec[0].pz(), - mother.vertex().x(),mother.vertex().y(),mother.vertex().z() - )); - - event.addParticle(new Particle(decayParticleID2, - vec[1].px(), vec[1].py(), vec[1].pz(), - mother.vertex().x(),mother.vertex().y(),mother.vertex().z() - )); - } - -} diff --git a/common-tools/clas-physics/src/main/java/org/jlab/physics/analysis/EventOperator.java b/common-tools/clas-physics/src/main/java/org/jlab/physics/analysis/EventOperator.java deleted file mode 100644 index 8412e7f2c7..0000000000 --- a/common-tools/clas-physics/src/main/java/org/jlab/physics/analysis/EventOperator.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.jlab.physics.analysis; - -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import org.jlab.clas.physics.EventFilter; -import org.jlab.clas.physics.PhysicsEvent; - -/** - * - * @author gavalian - */ -public class EventOperator { - - private String operatorName = "EV"; - private final Map operatorObservables = new LinkedHashMap(); - private final EventFilter eventFilter = new EventFilter(); - - public EventOperator(){ - - } - - public EventFilter getFilter(){return eventFilter;} - - public String getName(){ return operatorName; } - public EventOperator setName(String name){operatorName = name;return this;} - public EventOperator setFilter(String filter){eventFilter.setFilter(filter);return this;} - - public EventOperator setObservables(String... obsnames){ - operatorObservables.clear(); - for(String n : obsnames){ - operatorObservables.put(n, (Double) 0.0); - } - return this; - } - - public void reset(){ - Set keys = this.operatorObservables.keySet(); - for(String key : keys) this.operatorObservables.put(key, (Double) 0.0); - } - - public void operate(PhysicsEvent event){ - - } - - public Map observableMap(){ - return this.operatorObservables; - } - - public List observableList(){ - Set oset = operatorObservables.keySet(); - List names = new ArrayList(); - for(String on : oset){ - names.add(on); - } - return names; - } - - @Override - public String toString(){ - StringBuilder str = new StringBuilder(); - List names = observableList(); - str.append(String.format(" %12s :", getName())); - for(String n : names){ - str.append(String.format("\t %s : ", n)); - str.append(this.operatorObservables.get(n)); - str.append("\n"); - } - return str.toString(); - } -} diff --git a/common-tools/clas-physics/src/main/java/org/jlab/physics/analysis/GenericEventOperator.java b/common-tools/clas-physics/src/main/java/org/jlab/physics/analysis/GenericEventOperator.java deleted file mode 100644 index bffc0f4b7a..0000000000 --- a/common-tools/clas-physics/src/main/java/org/jlab/physics/analysis/GenericEventOperator.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.jlab.physics.analysis; - -import java.util.List; -import org.jlab.clas.physics.Particle; -import org.jlab.clas.physics.PhysicsEvent; - -/** - * - * @author gavalian - */ -public class GenericEventOperator extends EventOperator { - - private String operator = ""; - - public GenericEventOperator(String name, String op, String... vars){ - setName(name); - operator = op; - setObservables(vars); - } - - @Override - public void operate(PhysicsEvent event){ - reset(); - if(getFilter().isValid(event)==false) return; - Particle part = event.getParticle(operator); - List obs = observableList(); - for(String o : obs){ - double value = part.getProperty(o); - observableMap().put(o, value); - } - } -} diff --git a/common-tools/clas-physics/src/main/java/org/jlab/physics/analysis/PhysicsAnalysis.java b/common-tools/clas-physics/src/main/java/org/jlab/physics/analysis/PhysicsAnalysis.java deleted file mode 100644 index b29d97d3e8..0000000000 --- a/common-tools/clas-physics/src/main/java/org/jlab/physics/analysis/PhysicsAnalysis.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.jlab.physics.analysis; - -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import org.jlab.clas.physics.Particle; -import org.jlab.clas.physics.PhysicsEvent; - -/** - * - * @author gavalian - */ -public class PhysicsAnalysis { - - private Map descriptors = new LinkedHashMap(); - private Map observableMap = new LinkedHashMap(); - private String projectName = "defaultProject"; - - public PhysicsAnalysis(){ - - } - - public void addObservable(String descriptor, String observale){ - if(descriptors.containsKey(descriptor)==true){ - descriptors.get(descriptor).addObservable(observale); - } - } - - public void addDescriptor(ParticleDescriptor desc){ - this.descriptors.put(desc.getName(), desc); - } - - public void addDescriptor(String name, String operator){ - this.addDescriptor(new ParticleDescriptor(name,operator)); - } - - public void processEvent(PhysicsEvent event){ - this.observableMap.clear(); - for(Map.Entry entry : this.descriptors.entrySet()){ - Particle particle = event.getParticle(entry.getValue().getOperator()); - for(String property : entry.getValue().observableList()){ - float pvalue = (float) particle.get(property); - this.observableMap.put(entry.getKey()+":"+property, pvalue); - } - } - } - - public Map getObservables(){ - return this.observableMap; - } - - public String toTupleString(){ - StringBuilder str = new StringBuilder(); - for(Map.Entry entry : this.observableMap.entrySet()){ - str.append(String.format(" %f ", entry.getValue())); - } - return str.toString(); - } - - @Override - public String toString(){ - StringBuilder str = new StringBuilder(); - for(Map.Entry entry : this.descriptors.entrySet()){ - str.append(entry.getValue().toString()); - str.append("\n"); - } - return str.toString(); - } - - public static class ParticleDescriptor { - - String descriptorName = ""; - String descriptorOperator = ""; - List observables = new ArrayList(); - - public ParticleDescriptor(String name, String operator){ - descriptorName = name; - descriptorOperator = operator; - } - - public String getName(){ - return descriptorName; - } - - public String getOperator(){ - return this.descriptorOperator; - } - - public void addObservable(String ob){ - this.observables.add(ob); - } - - public List observableList(){ - return this.observables; - } - - @Override - public String toString(){ - StringBuilder str = new StringBuilder(); - str.append(String.format("%12s : %24s ", getName(),getOperator())); - for(String obs : observables){ - str.append(String.format(" : %s ", obs)); - } - return str.toString(); - } - } - -} diff --git a/common-tools/clas-physics/src/main/java/org/jlab/physics/analysis/PhysicsDataObject.java b/common-tools/clas-physics/src/main/java/org/jlab/physics/analysis/PhysicsDataObject.java deleted file mode 100644 index 4286cf61d3..0000000000 --- a/common-tools/clas-physics/src/main/java/org/jlab/physics/analysis/PhysicsDataObject.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.jlab.physics.analysis; - -import java.util.ArrayList; -import java.util.List; - -/** - * - * @author gavalian - */ -public class PhysicsDataObject { - - List descriptors = new ArrayList(); - - public PhysicsDataObject(){ - - } - - public void addDescriptor(DataObjectDescriptor desc){ - this.descriptors.add(desc); - } - - public void addDescriptor(String observable, String... cutList){ - DataObjectDescriptor desc = new DataObjectDescriptor(observable); - for(String cut : cutList){ - desc.getDataCuts().add(cut); - } - addDescriptor(desc); - } - - public class DataObjectDescriptor { - - String dataObservable = ""; - List dataCuts = new ArrayList(); - - public DataObjectDescriptor(String obs){ - this.dataObservable = obs; - } - - public String getDataObservable(){ - return this.dataObservable; - } - - public List getDataCuts(){ - return dataCuts; - } - - } -} diff --git a/common-tools/clas-physics/src/main/java/org/jlab/physics/base/DimensionSpace.java b/common-tools/clas-physics/src/main/java/org/jlab/physics/base/DimensionSpace.java deleted file mode 100644 index 42b70b11ac..0000000000 --- a/common-tools/clas-physics/src/main/java/org/jlab/physics/base/DimensionSpace.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.jlab.physics.base; - -import java.awt.FlowLayout; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.JSlider; - -/** - * - * @author gavalian - */ -public class DimensionSpace { - - - String dimName = "unknown"; - double dimValue = 0.5; - double dimMinimum = 0.0; - double dimMaximum = 1.0; - double constrainUpper = 1.0; - double constrainLower = 0.0; - int numberOfBins = 1; - - JPanel dimPanel = null; - - public DimensionSpace(){ - - } - - public DimensionSpace(String name, double min, double max){ - this.set(name, min, max); - } - - public final void set(String name, double min, double max){ - this.dimName = name; - this.dimMinimum = min; - this.dimMaximum = max; - this.dimValue = min + 0.5*(max-min); - } - - public void reset(){ - this.constrainUpper = 1.0; - this.constrainLower = 0.0; - } - - public void setContsrains(double lower, double upper){ - this.constrainUpper = upper; - this.constrainLower = lower; - } - - public double getRandom(){ - double rndm = Math.random(); - double low = this.dimMinimum + (this.dimMaximum - this.dimMinimum)*this.constrainLower; - double max = this.dimMinimum + (this.dimMaximum - this.dimMinimum)*this.constrainUpper; - return low + rndm*(max-low); - } - - public void setRandom(){ - this.dimValue = this.getRandom(); - } - - public int getBin(){ - double delta = (this.dimMaximum-this.dimMinimum)/this.numberOfBins; - double w = (this.dimValue-this.dimMinimum)/delta; - int bin = (int) w; - return bin; - } - - public int getNBins(){ - return this.numberOfBins; - } - - public void setNBins(int bins){ - this.numberOfBins = bins; - } - - public String getName(){ return this.dimName;} - - public void setValue(double value){ this.dimValue = value;} - - public void setValueNormalized(double value){ - if(value<0.0||value>1.0){ - System.out.println("error: normalized value has to be 0.0-1.0"); - } else { - this.dimValue = this.dimMinimum + value*(this.dimMaximum-this.dimMinimum); - } - } - - public double getValue() { return this.dimValue;} - public double getMin() { return this.dimMinimum;} - public double getMax() { return this.dimMaximum;} - - public void createPanel(){ - this.dimPanel = new JPanel(); - this.dimPanel.setLayout(new FlowLayout()); - JLabel nameLabel = new JLabel(this.dimName); - JSlider jsUpper = new JSlider(JSlider.HORIZONTAL, - 0, 100, 0); - JSlider jsLower = new JSlider(JSlider.HORIZONTAL, - 0, 100, 100); - - this.dimPanel.add(nameLabel); - this.dimPanel.add(jsUpper); - this.dimPanel.add(jsLower); - } - - public JPanel getPanel(){ return this.dimPanel;} - - @Override - public String toString(){ - StringBuilder str = new StringBuilder(); - str.append(String.format("* %-24s * %12.6f * %12.6f * %12.6f * ", - this.dimName,this.dimMinimum,this.dimMaximum,this.dimValue)); - return str.toString(); - } -} diff --git a/common-tools/clas-physics/src/main/java/org/jlab/physics/base/EventOperation.java b/common-tools/clas-physics/src/main/java/org/jlab/physics/base/EventOperation.java deleted file mode 100644 index 2e981748cd..0000000000 --- a/common-tools/clas-physics/src/main/java/org/jlab/physics/base/EventOperation.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.jlab.physics.base; - -import java.util.ArrayList; -import java.util.List; -import org.jlab.clas.physics.Particle; -import org.jlab.clas.physics.PhysicsEvent; - -/** - * - * @author gavalian - */ -public abstract class EventOperation { - - public List operators = new ArrayList(); - public List particles = new ArrayList(); - public List properties = new ArrayList(); - - public EventOperation(){ - - } - - public void init(String... oper){ - this.operators.clear(); - for(String item : oper){ - operators.add(item); - } - } - - abstract void processEvent(PhysicsEvent event); - - public void initParticles(PhysicsEvent event){ - - } - - public double getProperty(){ - return 0.0; - } - -} diff --git a/common-tools/clas-physics/src/main/java/org/jlab/physics/base/EventSelector.java b/common-tools/clas-physics/src/main/java/org/jlab/physics/base/EventSelector.java deleted file mode 100644 index 8c5cefa34c..0000000000 --- a/common-tools/clas-physics/src/main/java/org/jlab/physics/base/EventSelector.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ - -package org.jlab.physics.base; - -import java.util.ArrayList; -import java.util.List; -import org.jlab.clas.physics.Particle; -import org.jlab.clas.physics.ParticleNotFoundException; -import org.jlab.clas.physics.PhysicsEvent; - -/** - * - * @author gavalian - */ -public class EventSelector { - private final ArrayList pSelectors = new ArrayList(); - private String selectorFormat = ""; - private final String openBracket = "["; - private final String closeBracket = "]"; - - public EventSelector(){ - - } - - public EventSelector(String format){ - this.parse(format); - } - - public final void parse(String format){ - pSelectors.clear(); - ParticleStringParser parser = new ParticleStringParser(); - List operators = parser.parse(format); - selectorFormat = format.replaceAll("\\s+", ""); - - for(String item : operators){ - ParticleSelector selector = new ParticleSelector(item); - pSelectors.add(selector); - } - /* - selectorFormat = format.replaceAll("\\s+", ""); - int position = selectorFormat.indexOf(this.closeBracket, 0); - int lastposition = 0; - while(position>0&&position plist = this.getParticleList(event); - if(plist.isEmpty()) return null; - - Particle part = new Particle(); - part.copy(plist.get(0)); - for(int loop =1 ; loop < plist.size(); loop++){ - part.combine(plist.get(loop), 1); - } - return part; - } catch (ParticleNotFoundException e){ - return new Particle(); - } - } - - public List getParticleList(PhysicsEvent event) throws ParticleNotFoundException{ - ArrayList plist = new ArrayList(); - for(ParticleSelector sel : pSelectors){ - Particle part = new Particle(); - boolean status = sel.getParticle(event,part); - if(status==false){ - throw new ParticleNotFoundException("[EventSelector::ERROR] event does no contain " - + "particle for selector \n" + sel.toString()); - /*System.err.println("[EventSelector::ERROR] event does no contain " - + "particle for selector \n" + sel.toString());*/ - } else { - plist.add(part); - } - } - return plist; - } - - @Override - public String toString(){ - StringBuilder str = new StringBuilder(); - str.append(String.format("EVENT SELECTOR : (%s)\n", this.selectorFormat)); - for(ParticleSelector psel : pSelectors){ - str.append(psel.toString()); - str.append("\n"); - } - return str.toString(); - } - - public static void main(String[] args){ - EventSelector selector = new EventSelector("[b]+[t]+(211)-{2212,0}-[2212,1]"); - System.out.println(selector); - } -} diff --git a/common-tools/clas-physics/src/main/java/org/jlab/physics/base/IEventFilter.java b/common-tools/clas-physics/src/main/java/org/jlab/physics/base/IEventFilter.java deleted file mode 100644 index 639a23a8da..0000000000 --- a/common-tools/clas-physics/src/main/java/org/jlab/physics/base/IEventFilter.java +++ /dev/null @@ -1,18 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ - -package org.jlab.physics.base; - -import org.jlab.clas.physics.PhysicsEvent; - -/** - * - * @author gavalian - */ -public interface IEventFilter { - void init(String format); - Boolean isValid(PhysicsEvent event); -} diff --git a/common-tools/clas-physics/src/main/java/org/jlab/physics/base/IPhysicsCut.java b/common-tools/clas-physics/src/main/java/org/jlab/physics/base/IPhysicsCut.java deleted file mode 100644 index ad1f634f27..0000000000 --- a/common-tools/clas-physics/src/main/java/org/jlab/physics/base/IPhysicsCut.java +++ /dev/null @@ -1,18 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ - -package org.jlab.physics.base; - -import org.jlab.clas.physics.PhysicsEvent; - -/** - * - * @author gavalian - */ -public interface IPhysicsCut { - void init(String format); - Boolean isValid(PhysicsEvent event); -} diff --git a/common-tools/clas-physics/src/main/java/org/jlab/physics/base/ParameterSpace.java b/common-tools/clas-physics/src/main/java/org/jlab/physics/base/ParameterSpace.java deleted file mode 100644 index 5382a2e693..0000000000 --- a/common-tools/clas-physics/src/main/java/org/jlab/physics/base/ParameterSpace.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.jlab.physics.base; - -import java.util.LinkedHashMap; -import java.util.Map; - -/** - * - * @author gavalian - */ -public class ParameterSpace { - Map parameters = new LinkedHashMap(); - public ParameterSpace(){ - - } - - public ParameterSpace addParameter(String name, double min, double max){ - parameters.put(name, new DimensionSpace(name,min,max)); - return this; - } - - public ParameterSpace setValue(String name, double value){ - parameters.get(name).setValue(value); - return this; - } - - public double getValue(String name){ - return this.parameters.get(name).getValue(); - } -} diff --git a/common-tools/clas-physics/src/main/java/org/jlab/physics/base/ParticleSelector.java b/common-tools/clas-physics/src/main/java/org/jlab/physics/base/ParticleSelector.java deleted file mode 100644 index 3db11302f7..0000000000 --- a/common-tools/clas-physics/src/main/java/org/jlab/physics/base/ParticleSelector.java +++ /dev/null @@ -1,337 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ - -package org.jlab.physics.base; - -import org.jlab.clas.pdg.PDGDatabase; -import org.jlab.clas.pdg.PDGParticle; -import org.jlab.clas.physics.Particle; -import org.jlab.clas.physics.PhysicsEvent; - -/** - * - * @author gavalian - */ -public class ParticleSelector { - - public static int TYPE_GENERATED = 1; - public static int TYPE_RECONSTRUCED = 2; - public static int TYPE_MATCHED = 3; - public static int TYPE_DETECTOR_PARTICLE = 4; - - private Integer particleID = 11; - private Integer particleSkip = 0; - private Integer particleSign = 1; - private String particleType = "11"; - private Integer particleSelectionType = ParticleSelector.TYPE_RECONSTRUCED; - private Boolean overridePid = false; - private Integer overrideParticleID = 11; - private String selectorFormat = "[11,0]"; - - private char bracketsOpen = '('; - private char bracketsClose = ')'; - - private final char[] bracketTypes = new char[]{'(',')','[',']','{','}'}; - - public ParticleSelector(String format, int type){ - - if(type>0&&type<4){ - bracketsOpen = bracketTypes[ (type-1)*2]; - bracketsClose = bracketTypes[ (type-1)*2 + 1]; - this.particleSelectionType = type; - this.parse(format); - } - } - - - public ParticleSelector(String format){ - - int type = 1; - if(format.charAt(format.length()-1)==')') type = 1; - if(format.charAt(format.length()-1)==']') type = 2; - if(format.charAt(format.length()-1)=='}') type = 3; - - if(type>0&&type<4){ - bracketsOpen = bracketTypes[ (type-1)*2]; - bracketsClose = bracketTypes[ (type-1)*2 + 1]; - this.particleSelectionType = type; - this.parse(format); - } - } - - public ParticleSelector(){ - - } - - public ParticleSelector(int pid, int skip, int sign){ - particleID = pid; - particleSkip = skip; - particleSign = sign; - } - - private boolean parseParticleID(String text){ - //System.err.println("[DEBUG] ---> parsing particle ID = " + text); - if(text.length()==1&&(text.compareTo("+")==0 - ||text.compareTo("-")==0||text.compareTo("n")==0)){ - particleID = 0; - particleType = text; - return true; - } - - if(text.compareTo("b")==0){ - particleID = 5000; - particleType = "beam"; - return true; - } - - if(text.compareTo("t")==0){ - particleID = 5001; - particleType = "target"; - return true; - } - - //System.err.println("TEXT = " + text + " Check = " + text.matches("[0-9]+")); - - if (text.matches("-?[0-9]+") == true && text.length() > 0){ - particleID = Integer.parseInt(text); - particleType = text; - return true; - } else { - PDGParticle particle = PDGDatabase.getParticleByName(text); - if(particle!=null){ - particleID = particle.pid(); - particleType = text; - return true; - } else { - return false; - } - //System.err.println("Parsing as number : " + text); - } - } - - private void reset(){ - this.overridePid = false; - this.overrideParticleID = 11; - this.particleID = 11; - this.particleType = "e-"; - this.particleSkip = 0; - this.particleSign = 1; - } - - public final void parse(String options){ - this.reset(); - selectorFormat = options.replaceAll("\\s+", ""); - String trimmed; - if(selectorFormat.charAt(1)==this.bracketsOpen&& - selectorFormat.charAt(selectorFormat.length()-1)==this.bracketsClose){ - - if(selectorFormat.charAt(0)=='-'){ - this.particleSign = -1; - } else {this.particleSign = 1;} - trimmed = selectorFormat.substring(2, selectorFormat.length()-1); - } else if(selectorFormat.charAt(0)==this.bracketsOpen&& - selectorFormat.charAt(selectorFormat.length()-1)==this.bracketsClose){ - trimmed = selectorFormat.substring(1, selectorFormat.length()-1); - this.particleSign = 1; - } else { - System.err.println("[ParticleSelector] ---> Syntax error. in string (" - +this.selectorFormat + ")."); - return; - } - - //trimmed = selectorFormat.substring(2, selectorFormat.length()-1); - //System.err.println("[DEBUG]--> trimmed string = (" + trimmed + ")"); - String[] tokens = trimmed.split(","); - if(tokens.length>0){ - this.parseParticleID(tokens[0]); - this.overrideParticleID = this.particleID; - } - - if(tokens.length>1){ - particleSkip = Integer.parseInt(tokens[1]); - } else { - particleSkip = 0; - } - - if(tokens.length>2){ - overrideParticleID = Integer.parseInt(tokens[2]); - this.overridePid = true; - } - - } - - public int pid(){return particleID;} - public int skip(){return particleSkip;} - - public boolean getParticle(PhysicsEvent event, Particle p){ - - p.setParticleWithMass(0.0,(byte) 0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0); - try { - - if(particleID==5000){ - p.copyParticle(event.beamParticle()); - return true; - } - if(particleID==5001){ - p.copyParticle(event.targetParticle()); - return true; - } - - } catch (Exception ex){ - System.out.println("ERROR: getting particle beam or target has failed"); - } - - - if(this.particleSelectionType==ParticleSelector.TYPE_RECONSTRUCED&&event.countByPid(particleID)>>>>> COPY IS DONE ON " + fromEvent.toString()); - if(this.particleSign<0) p.vector().invert(); - return true; - } - p.initParticle(this.overrideParticleID, - fromEvent.px(), - fromEvent.py(), - fromEvent.pz(), - fromEvent.vertex().x(), - fromEvent.vertex().y(), - fromEvent.vertex().z() - ); - if(this.particleSign<0) p.vector().invert(); - return true; - } catch (Exception e){ - - } - return false; - } - - public Particle getParticle(PhysicsEvent event){ - try { - if(particleID==5000) return event.beamParticle(); - if(particleID==5001) return event.targetParticle(); - - if(particleType.compareTo("-")==0){ - Particle fromEvent = event.getParticleByCharge(-1,particleSkip); - Particle npart = new Particle(this.overrideParticleID, - fromEvent.px(), - fromEvent.py(), - fromEvent.pz(), - fromEvent.vertex().x(), - fromEvent.vertex().y(), - fromEvent.vertex().z() - ); - if(this.particleSign<0) npart.vector().invert(); - return npart; - - } - - if(particleType.compareTo("+")==0){ - Particle fromEvent = event.getParticleByCharge(1,particleSkip); - Particle npart = new Particle(this.overrideParticleID, - fromEvent.px(), - fromEvent.py(), - fromEvent.pz(), - fromEvent.vertex().x(), - fromEvent.vertex().y(), - fromEvent.vertex().z() - ); - if(this.particleSign<0) npart.vector().invert(); - return npart; - } - - if(particleType.compareTo("n")==0){ - Particle fromEvent = event.getParticleByCharge(0,particleSkip); - Particle npart = new Particle(this.overrideParticleID, - fromEvent.px(), - fromEvent.py(), - fromEvent.pz(), - fromEvent.vertex().x(), - fromEvent.vertex().y(), - fromEvent.vertex().z() - ); - if(this.particleSign<0) npart.vector().invert(); - return npart; - - } - - if(event.countByPid(particleID) idx = new ArrayList(); - for(int i = 0; i < index.length; i++){ - if(index[i]>=0) idx.add(index[i]); - } - - int idxSize = idx.size(); - - switch (idxSize){ - case 0: return -1; - case 1: return idx.get(0); - case 2: return Math.min(idx.get(0), idx.get(1)); - case 3: return Math.min(idx.get(2),Math.min(idx.get(0), idx.get(1))); - default: return -1; - } - } - - private int getPositionOpen(String str, int start_index){ - int[] bracket_index = new int[3]; - bracket_index[0] = str.indexOf(ParticleStringParser.CURLY_BRACKET_OPEN, start_index); - bracket_index[1] = str.indexOf(ParticleStringParser.SQUARE_BRACKET_OPEN, start_index); - bracket_index[2] = str.indexOf(ParticleStringParser.ROUND_BRACKET_OPEN, start_index); - return this.minIndex(bracket_index); - } - - private int getPositionClose(String str, int start_index){ - int[] bracket_index = new int[3]; - bracket_index[0] = str.indexOf(ParticleStringParser.CURLY_BRACKET_CLOSE, start_index); - bracket_index[1] = str.indexOf(ParticleStringParser.SQUARE_BRACKET_CLOSE, start_index); - bracket_index[2] = str.indexOf(ParticleStringParser.ROUND_BRACKET_CLOSE, start_index); - return this.minIndex(bracket_index); - } - - private int getBracketType(String str, int pstart, int pend){ - char bstart = str.charAt(pstart); - char bend = str.charAt(pend); - if(bstart=='{'&&bend=='}'){ - return ParticleStringParser.BRACKET_TYPE_CURLY; - } - if(bstart=='['&&bend==']'){ - return ParticleStringParser.BRACKET_TYPE_SQUARE; - } - if(bstart=='('&&bend==')'){ - return ParticleStringParser.BRACKET_TYPE_ROUND; - } - return ParticleStringParser.BRACKET_TYPE_UNKNOWN; - } - - public List parse(String strOperation){ - - int start_position = 0; - String operation = strOperation.replaceAll("\\s+", ""); - List operands = new ArrayList(); - - while(start_position>=0&&start_position : " + item); - } - } -} diff --git a/common-tools/clas-physics/src/main/java/org/jlab/physics/base/PhaseSpace.java b/common-tools/clas-physics/src/main/java/org/jlab/physics/base/PhaseSpace.java deleted file mode 100644 index e0ea96e3ad..0000000000 --- a/common-tools/clas-physics/src/main/java/org/jlab/physics/base/PhaseSpace.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.jlab.physics.base; - -import java.awt.FlowLayout; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.Set; -import javax.swing.JFrame; -import javax.swing.JPanel; - -/** - * - * @author gavalian - */ -public class PhaseSpace { - - Map params = new LinkedHashMap(); - JPanel spacePanel = null; - - public PhaseSpace(){ - - } - - public Set getKeys(){ - return params.keySet(); - } - - public void add(DimensionSpace space){ - this.params.put(space.getName(), space); - } - - public void add(String name, double min, double max){ - this.add(new DimensionSpace(name,min,max)); - } - - public void add(String name, double value, double min, double max){ - DimensionSpace dim = new DimensionSpace(name,min,max); - dim.setValue(value); - this.add(dim); - } - - public DimensionSpace getDimension(String name){ - return this.params.get(name); - } - - public JPanel createPanel(){ - this.spacePanel = new JPanel(); - this.spacePanel.setLayout(new FlowLayout()); - for(Map.Entry item : this.params.entrySet()){ - item.getValue().createPanel(); - JPanel panel = item.getValue().getPanel(); - this.spacePanel.add(panel); - } - return this.spacePanel; - } - - @Override - public String toString(){ - StringBuilder str = new StringBuilder(); - for(int c = 0; c < 73; c++) str.append("*"); - str.append("\n"); - str.append(String.format("* %-24s * %12s * %12s * %12s * ", - "Name", "Min","Max","Value")); - str.append("\n"); - for(int c = 0; c < 73; c++) str.append("*"); - str.append("\n"); - for(Map.Entry item : this.params.entrySet()){ - str.append(item.getValue().toString()); - str.append("\n"); - } - for(int c = 0; c < 73; c++) str.append("*"); - str.append("\n"); - return str.toString(); - } - - public void show(){ - System.out.println(this.toString()); - } - - public void setRandom(){ - for(Map.Entry entry : this.params.entrySet()){ - entry.getValue().setRandom(); - } - } - - public PhaseSpace copy(){ - PhaseSpace space = new PhaseSpace(); - for(Map.Entry entry : this.params.entrySet()){ - space.add(entry.getKey(), entry.getValue().getMin(), entry.getValue().getMax()); - } - return space; - } - - public static void main(String[] args){ - PhaseSpace space = new PhaseSpace(); - space.add("x" , 0.0, 1.0); - space.add("pt" , 0.5, 1.5); - - System.out.println(space); - - JFrame frame = new JFrame(); - frame.add(space.createPanel()); - frame.pack(); - frame.setVisible(true); - } -} diff --git a/common-tools/clas-physics/src/main/java/org/jlab/physics/io/LundReader.java b/common-tools/clas-physics/src/main/java/org/jlab/physics/io/LundReader.java deleted file mode 100644 index 94aa31437e..0000000000 --- a/common-tools/clas-physics/src/main/java/org/jlab/physics/io/LundReader.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ - -package org.jlab.physics.io; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.IOException; -import java.util.ArrayList; -import java.util.logging.Level; -import java.util.logging.Logger; - -import org.jlab.clas.physics.Particle; -import org.jlab.clas.physics.PhysicsEvent; - -/** - * - * @author gavalian - */ -public class LundReader { - private final ArrayList inputFiles = new ArrayList(); - private BufferedReader reader = null; - private PhysicsEvent physEvent = new PhysicsEvent(); - - public LundReader() { - - } - - public LundReader(String file) { - this.addFile(file); - this.open(); - } - - public void addFile(String file) { - inputFiles.add(file); - } - - public void open() { - this.openFile(0); - } - - private Boolean openFile(int counter) { - try { - File file = new File(inputFiles.get(counter)); - reader = new BufferedReader(new FileReader(file)); - } catch (FileNotFoundException ex) { - Logger.getLogger(LundReader.class.getName()).log(Level.SEVERE, null, ex); - } - return true; - } - - public PhysicsEvent getEvent() { - return physEvent; - } - - public Boolean next() { - try { - physEvent.clear(); - String header = reader.readLine(); - if (header == null) - return false; - String[] tokens = header.trim().split("\\s+"); - // System.err.println("TOKENS size = " + tokens.length); - // for(int loop = 0; loop < tokens.length; loop++){ - // System.err.println(" token " + loop + " = " + tokens[loop]); - // } - if (tokens.length != 10) - return false; - Integer nrows = Integer.parseInt(tokens[0]); - if (nrows < 1) - return false; - physEvent.addProperty("nPart", nrows); - physEvent.addProperty("nTarNucl", Double.parseDouble(tokens[1])); - physEvent.addProperty("nTarProt", Double.parseDouble(tokens[2])); - physEvent.addProperty("tarPol", Double.parseDouble(tokens[3])); - physEvent.addProperty("beamPol", Double.parseDouble(tokens[4])); - physEvent.addProperty("x", Double.parseDouble(tokens[5])); - physEvent.addProperty("y", Double.parseDouble(tokens[6])); - physEvent.addProperty("W", Double.parseDouble(tokens[7])); - physEvent.addProperty("Q2", Double.parseDouble(tokens[8])); - physEvent.addProperty("nu", Double.parseDouble(tokens[9])); - - for (int loop = 0; loop < nrows; loop++) { - String particleLine = reader.readLine(); - if (particleLine != null) { - String[] params = particleLine.trim().split("\\s+"); - // System.err.println("PARAMS LENGTH = " + params.length); - if (params.length == 14) { - - int pid = Integer.parseInt(params[3]); - // System.err.println("PID = " + pid); - int status = Integer.parseInt(params[2]); - double px = Double.parseDouble(params[6]); - double py = Double.parseDouble(params[7]); - double pz = Double.parseDouble(params[8]); - double vx = Double.parseDouble(params[11]); - double vy = Double.parseDouble(params[12]); - double vz = Double.parseDouble(params[13]); - if (status == 1) { - physEvent.addParticle(new Particle(pid, px, py, pz, vx, vy, vz)); - } - } - } - } - return true; - } catch (IOException ex) { - Logger.getLogger(LundReader.class.getName()).log(Level.SEVERE, null, ex); - } - return false; - } -} diff --git a/common-tools/clas-physics/src/main/java/org/jlab/physics/oper/PhysicsCutDescriptor.java b/common-tools/clas-physics/src/main/java/org/jlab/physics/oper/PhysicsCutDescriptor.java deleted file mode 100644 index f9169c6030..0000000000 --- a/common-tools/clas-physics/src/main/java/org/jlab/physics/oper/PhysicsCutDescriptor.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.jlab.physics.oper; - -import java.util.Map; - -/** - * - * @author gavalian - */ -public class PhysicsCutDescriptor { - - private String operator = ""; - private String variable = ""; - private double variableMin = 0.0; - private double variableMax = 100.0; - private String cutName = "default"; - - public PhysicsCutDescriptor(String name, String variable, double min, double max){ - this.cutName = name; - this.setVariable(variable); - this.setMinMax(min, max); - } - - public final void setName(String name){ this.cutName = name; } - public String getName() { return this.cutName;} - - public final void setVariable(String var){ - this.variable = var; - } - - public final void setMinMax(double min, double max){ - this.variableMin = min; - this.variableMax = max; - } - - public double getMin(){ return this.variableMin; } - public double getMax(){ return this.variableMax;} - - public boolean isValid(Map map){ - if(map.containsKey(this.variable)==false) return false; - double value = map.get(this.variable).getValue(); - return (value>=this.variableMin&&value<=this.variableMax); - } - - @Override - public String toString(){ - StringBuilder str = new StringBuilder(); - str.append(String.format("* %-12s * %-12s * (%12.5f, %12.5f) *\n", - this.cutName,this.variable, - this.variableMin,this.variableMax)); - return str.toString(); - } -} diff --git a/common-tools/clas-physics/src/main/java/org/jlab/physics/oper/PhysicsEventOperator.java b/common-tools/clas-physics/src/main/java/org/jlab/physics/oper/PhysicsEventOperator.java deleted file mode 100644 index 9efcc3dcd5..0000000000 --- a/common-tools/clas-physics/src/main/java/org/jlab/physics/oper/PhysicsEventOperator.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.jlab.physics.oper; - -import java.util.ArrayList; -import java.util.List; -import org.jlab.clas.physics.Particle; -import org.jlab.clas.physics.PhysicsEvent; - -/** - * - * @author gavalian - */ -public class PhysicsEventOperator { - - private String operatorName = "unknown"; - private Double varMinimum = 0.0; - private Double varMaximum = 0.0; - private String particleSelector = "[b]"; - private String particleVariable = "mom"; - private Double currentValue = 0.0; - private ArrayList operatorCuts = new ArrayList(); - - public PhysicsEventOperator(String name, String variable, String particle, - double min, double max){ - this.set(name, variable, particle); - this.setLimits(min, max); - } - - public final void set(String name, String variable, String particle){ - this.operatorName = name; - this.particleVariable = variable; - this.particleSelector = particle; - } - - public final void setLimits(double min, double max){ - this.varMinimum = min; - this.varMaximum = max; - } - - public void apply(PhysicsEvent event){ - Particle part = event.getParticle(this.particleSelector); - this.currentValue = part.get(this.particleVariable); - } - - public boolean isValid(){ - return (this.currentValue>=this.varMinimum&&this.currentValue getCuts(){return this.operatorCuts;} - public double getValue(){ return this.currentValue;}; - - @Override - public String toString(){ - return this.stringValue(); - } -} diff --git a/common-tools/clas-physics/src/main/java/org/jlab/physics/oper/PhysicsEventProcessor.java b/common-tools/clas-physics/src/main/java/org/jlab/physics/oper/PhysicsEventProcessor.java deleted file mode 100644 index f524f2eee7..0000000000 --- a/common-tools/clas-physics/src/main/java/org/jlab/physics/oper/PhysicsEventProcessor.java +++ /dev/null @@ -1,201 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.jlab.physics.oper; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.TreeMap; -import org.jlab.clas.physics.EventFilter; -import org.jlab.clas.physics.Particle; -import org.jlab.clas.physics.PhysicsEvent; - -/** - * - * @author gavalian - */ -public class PhysicsEventProcessor { - - private final TreeMap operators = new TreeMap(); - private final TreeMap particleDescriptors = - new TreeMap(); - private final TreeMap cutDescriptors = - new TreeMap(); - - private final TreeMap histDescriptors = - new TreeMap(); - - private Particle beamParticle = new Particle(11,0.0,0.0,11.0,0.0,0.0,0.0); - private EventFilter eventFilter = new EventFilter(); - - - public PhysicsEventProcessor(double energy, String filter){ - beamParticle.setVector(11, 0.0,0.0,energy,0.0,0.0,0.0); - eventFilter.setFilter(filter); - } - - - public void addParticle(String name,String particle, String variable){ - this.particleDescriptors.put(name, new PhysicsParticleDescriptor(name,particle,variable)); - } - - public void addCut(String cutname, String variable, double min, double max){ - this.cutDescriptors.put(cutname, new PhysicsCutDescriptor(cutname,variable,min,max)); - } - - public void parseLine(String line){ - String[] tokens = line.split("\\s+"); - - if(tokens.length>0){ - - if(tokens[0].compareTo("PARTICLE")==0){ - this.addParticle(tokens[1], tokens[2], tokens[3]); - } - - if(tokens[0].compareTo("CUT")==0){ - this.addCut(tokens[1], tokens[2], - Double.parseDouble(tokens[3]), - Double.parseDouble(tokens[4]) - ); - } - - if(tokens[0].compareTo("HIST")==0){ - this.addHistogram(tokens[1], Integer.parseInt(tokens[2]), - Double.parseDouble(tokens[3]), - Double.parseDouble(tokens[4]), - tokens[5],tokens[6] - ); - } - } - } - - public void addHistogram(String name, int nbins, double min, double max, - String var, String cuts){ - String[] tokens = cuts.split("&"); - - if(this.particleDescriptors.containsKey(var)==false){ - System.out.println("[PHYS-PROC] ---> warning : adding histogram [" - + name + "] unsuccessful. no variable [" + var + "] is defined"); - return; - } - - PhysicsHistogramDescriptor desc = new PhysicsHistogramDescriptor( - name,nbins,min,max,var,""); - //System.out.println("ADDING CUTS SIZE TOKENS = " + tokens.length); - desc.getCuts().clear(); - for(String item : tokens){ - if(this.cutDescriptors.containsKey(item)==true){ - desc.addCut(item); - //System.out.println(" adding cut ["+item+"]"); - } else { - System.out.println("[PHYS-PROC] ---> warning : adding " - + " cut ["+ item+"] to histogram ["+name+"] failed. not cut with that name found"); - } - } - this.histDescriptors.put(name, desc); - } - - public void addOperator(PhysicsEventOperator oper){ - this.operators.put(oper.getName(), oper); - } - - public boolean isEventValid(PhysicsEvent event){ - return eventFilter.isValid(event); - } - - public void apply(PhysicsEvent event){ - //for(Map.Entry entry : this.operators.entrySet()){ - // entry.getValue().apply(event); - //} - event.setBeamParticle(beamParticle); - for(Map.Entry desc : this.particleDescriptors.entrySet()){ - desc.getValue().applyEvent(event); - } - - } - - public PhysicsEventOperator getOperator(String name){ - return this.operators.get(name); - } - - public boolean processCuts(List cutList){ - for(int loop = 0; loop < cutList.size(); loop++){ - if(this.cutDescriptors.get(cutList.get(loop)).isValid(particleDescriptors)==false) - return false; - } - return true; - } - - public List getOperatorList(){ - ArrayList opList = new ArrayList (); - for(Map.Entry entry : this.operators.entrySet()){ - opList.add(entry.getKey()); - } - return opList; - } - - public double[] getOperatorValues(){ - double[] values = new double[this.operators.size()]; - int counter = 0; - for(Map.Entry entry : this.operators.entrySet()){ - values[counter] = entry.getValue().getValue(); - counter++; - } - return values; - } - - public boolean isValid(String oper){ - if(this.operators.containsKey(oper)==false) return false; - PhysicsEventOperator evOper = this.operators.get(oper); - for(String cut : evOper.getCuts()){ - if(this.operators.containsKey(cut)==true){ - if(this.operators.get(cut).isValid()==false) return false; - } else { - System.out.println("[PhysicsEventProcessor] ERROR : processing operator [" - + oper + "]. Could not find cut named [" + cut + "]" ); - } - } - return true; - } - public void showData(){ - StringBuilder str = new StringBuilder(); - //for(Map.Entry entry : this.operators.entrySet()){ - // str.append(entry.getValue().stringValue()); - // str.append("\n"); - //} - for(Map.Entry desc : this.particleDescriptors.entrySet()){ - str.append(String.format("* %-14s * %-12s * %32s * %12.5f *\n", - desc.getValue().getName(), - desc.getValue().getVariable(), - desc.getValue().getParticle(),desc.getValue().getValue())); - } - System.out.println(str.toString()); - } - @Override - public String toString(){ - StringBuilder str = new StringBuilder(); - //for(Map.Entry entry : this.operators.entrySet()){ - // str.append(entry.getValue().stringValue()); - // str.append("\n"); - //} - for(Map.Entry desc : this.particleDescriptors.entrySet()){ - str.append("[VAR ] --> "); - str.append(desc.getValue().toString()); - } - - for(Map.Entry desc : this.cutDescriptors.entrySet()){ - str.append("[CUT ] --> "); - str.append(desc.getValue().toString()); - } - - for(Map.Entry desc : this.histDescriptors.entrySet()){ - str.append("[HIST] --> "); - str.append(desc.getValue().toString()); - } - - return str.toString(); - } -} diff --git a/common-tools/clas-physics/src/main/java/org/jlab/physics/oper/PhysicsHistogramDescriptor.java b/common-tools/clas-physics/src/main/java/org/jlab/physics/oper/PhysicsHistogramDescriptor.java deleted file mode 100644 index 9ea8c0e55b..0000000000 --- a/common-tools/clas-physics/src/main/java/org/jlab/physics/oper/PhysicsHistogramDescriptor.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.jlab.physics.oper; - -import java.util.ArrayList; -import java.util.List; - -/** - * - * @author gavalian - */ -public class PhysicsHistogramDescriptor { - private String histName = ""; - private int numberOfBins = 100; - private double histMin = 0.0; - private double histMax = 1.0; - private String variable = "a"; - private List cutList = new ArrayList(); - - public PhysicsHistogramDescriptor(String name, int bins, double min, double max - ,String var, String cuts){ - this.histName = name; - this.numberOfBins = bins; - this.histMin = min; - this.histMax = max; - this.variable = var; - this.setCuts(cuts); - } - - public final void setCuts(String cuts){ - this.cutList.clear(); - String[] tokens = cuts.split(":"); - for(String item : tokens){ - this.cutList.add(item); - } - } - - public void addCut(String cut){ - this.cutList.add(cut); - } - - public List getCuts() { return this.cutList;} - public String getName(){ return this.histName;} - public String getVariable(){ return this.variable;} - public double getMin(){ return this.histMin;} - public double getMax(){ return this.histMax;} - - @Override - public String toString(){ - StringBuilder str = new StringBuilder(); - str.append(String.format("* %-12s * %-12s * (%5d, %12.5f, %12.5f) * NCUTS = %d", - this.histName,this.variable,this.numberOfBins, - this.histMin,this.histMax,this.cutList.size())); - for(String item : this.cutList){ - str.append(item); - str.append("&"); - } - str.append(" *\n"); - return str.toString(); - } -} diff --git a/common-tools/clas-physics/src/main/java/org/jlab/physics/oper/PhysicsParticleDescriptor.java b/common-tools/clas-physics/src/main/java/org/jlab/physics/oper/PhysicsParticleDescriptor.java deleted file mode 100644 index 635f878045..0000000000 --- a/common-tools/clas-physics/src/main/java/org/jlab/physics/oper/PhysicsParticleDescriptor.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.jlab.physics.oper; - -import org.jlab.clas.physics.Particle; -import org.jlab.clas.physics.PhysicsEvent; - -/** - * - * @author gavalian - */ -public class PhysicsParticleDescriptor { - private String particleString = "[b]"; - private String particleVariable = "mass"; - private double descriptorValue = 0.0; - private String descName = "unknown"; - - public PhysicsParticleDescriptor(String name,String particle, String variable){ - this.descName = name; - this.setParticle(particle); - this.setVariable(variable); - } - - public final void setName(String name) { this.descName = name; } - public String getName() { return this.descName;} - - public final void setParticle(String part){ - this.particleString = part; - } - - public final void setVariable(String var){ - this.particleVariable = var; - } - - public void applyEvent(PhysicsEvent event){ - Particle part = event.getParticle(this.particleString); - if(part!=null){ - this.descriptorValue = part.get(this.particleVariable); - } - } - - public String getParticle(){ return this.particleString; } - public String getVariable(){ return this.particleVariable; } - public double getValue() { return this.descriptorValue; } - - @Override - public String toString(){ - StringBuilder str = new StringBuilder(); - str.append(String.format("* %-12s * %-12s * %-45s *\n", - this.descName, this.particleVariable,this.particleString)); - return str.toString(); - } -} diff --git a/common-tools/clas-physics/src/main/java/org/jlab/physics/process/DVCSProcess.java b/common-tools/clas-physics/src/main/java/org/jlab/physics/process/DVCSProcess.java deleted file mode 100644 index 177a8417c8..0000000000 --- a/common-tools/clas-physics/src/main/java/org/jlab/physics/process/DVCSProcess.java +++ /dev/null @@ -1,266 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.jlab.physics.process; - -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import org.jlab.clas.pdg.PDGDatabase; -import org.jlab.clas.physics.LorentzVector; -import org.jlab.clas.physics.Particle; -import org.jlab.clas.physics.PhysicsEvent; -import org.jlab.clas.physics.Vector3; -import org.jlab.physics.base.PhaseSpace; - -/** - * - * @author gavalian - */ -public class DVCSProcess implements IPhysicsProcess { - - private static final double MP = 0.93827; - - public PhysicsEvent getEvent(PhaseSpace kinematics) { - PhysicsEvent event = new PhysicsEvent(); - event.setBeam(kinematics.getDimension("E").getValue()); - - Particle electron = KinematicsFactory.getElectron( - kinematics.getDimension("E").getValue(), - kinematics.getDimension("Q2").getValue(), - kinematics.getDimension("xb").getValue()); - - double E = kinematics.getDimension("E").getValue(); - double q2 = kinematics.getDimension("Q2").getValue(); - double xb = kinematics.getDimension("xb").getValue(); - double t = kinematics.getDimension("t").getValue(); - double phi = kinematics.getDimension("phi").getValue(); - - double min_t = this.t_min(q2, xb); - double max_t = this.t_max(q2, xb); - double xmin = q2/(2.0*MP*E); - /*System.out.println(" t = " + t + " t-min = " - + this.t_min(q2, xb) + " t-max = " + this.t_max(q2, xb) + - " xmin = " + xmin); - */ - if(tmax_t){ - return event; - } - - event.addParticle(electron); - - List protonGamma = this.getDvcsPhoton(E, q2, xb, t, 0.0, phi); - //System.out.println(" PROTON " + protonGamma.get(0)); - //System.out.println(" PHOTON " + protonGamma.get(1)); - if(protonGamma.size()<2){ - event.clear(); - return event; - } - - Particle proton = new Particle(2212, - protonGamma.get(0).x(), - protonGamma.get(0).y(), - protonGamma.get(0).z() - ); - - Particle photon = new Particle(22, - protonGamma.get(1).x(), - protonGamma.get(1).y(), - protonGamma.get(1).z() - ); - - event.addParticle(proton); - event.addParticle(photon); - /* - Vector3 norm = new Vector3(0.0,1.0,0.0); - - Particle q2p = event.getParticle("[b]-[11]"); - LorentzVector cm = new LorentzVector(q2p.vector()); - LorentzVector pr = new LorentzVector(0.0,0.0,0.0,0.938); - cm.add(pr); - System.out.println("*****************************"); - System.out.println(q2p.toLundString()); - cm.print(); - */ - return event; - } - - public PhaseSpace getPhaseSpace() { - PhaseSpace space = new PhaseSpace(); - space.add("E" , 6.0, 4.0, 11.0); - space.add("Q2" , 2.4, 1.5, 5.0); - space.add("xb" , 0.35, 0.0, 1.0); - space.add("t" , 0.25, 0.0, 11.0); - space.add("phi" , 0.0, -Math.PI,Math.PI); - return space; - } - - public Map getKinematics() { - Map kinematics = new LinkedHashMap(); - /*kinematics.put("E" , 6.0); - kinematics.put("Q2", 2.5); - kinematics.put("xb", 0.35); - kinematics.put("t" , 0.2); - kinematics.put("phi", 0.0);*/ - return kinematics; - } - - public double getProperty(String key, PhysicsEvent event){ - - if(key.compareTo("Q2")==0){ - Particle q2p = event.getParticle("[b]-[11]"); - return -q2p.vector().mass2(); - } - - if(key.compareTo("W2")==0){ - Particle w2p = event.getParticle("[b]+[t]-[11]"); - return w2p.vector().mass2(); - } - - if(key.compareTo("t")==0){ - Particle delta = event.getParticle("[t]-[2212]"); - return -delta.vector().mass2(); - } - - if(key.compareTo("xb")==0){ - Particle q2p = event.getParticle("[b]-[11]"); - Particle ep = event.getParticle("[11]"); - Particle beam = event.getParticle("[b]"); - double nu = beam.vector().e()-ep.vector().e(); - double q2 = -q2p.vector().mass2(); - return q2/(2.0*MP*nu); - } - - if(key.compareTo("phi")==0){ - Particle beam = event.getParticle("[b]"); - Particle electron = event.getParticle("[11]"); - Vector3 normE = beam.vector().vect().cross(electron.vector().vect()); - normE.unit(); - Particle proton = event.getParticle("[2212]"); - Particle gamma = event.getParticle("[22]"); - Vector3 normH = proton.vector().vect().cross(gamma.vector().vect()); - //return delta.vector().mass2(); - } - - return 0.0; - } - - public double t_min(double q2, double xb){ - double eps = KinematicsFactory.getEpsilon(q2, xb); - double nomin = 2.0*(1.0-xb)*(1.0-Math.sqrt(1+eps*eps)) + eps*eps; - double denom = 4.0*xb*(1.0-xb) + eps*eps; - return q2*(nomin/denom); - } - - public double t_max(double q2, double xb){ - double eps = KinematicsFactory.getEpsilon(q2, xb); - double nomin = 2.0*(1.0-xb)*(1.0+Math.sqrt(1+eps*eps)) + eps*eps; - double denom = 4.0*xb*(1.0-xb) + eps*eps; - return q2*(nomin/denom); - } - - public Particle getProton(PhysicsEvent event, double q2, double xb,double t){ - Particle q2p = event.getParticle("[b]-[11]"); - LorentzVector cm = new LorentzVector(q2p.vector()); - LorentzVector pr = new LorentzVector(0.0,0.0,0.0,0.938); - cm.add(pr); - double min_t = this.t_min(q2, xb); - double max_t = this.t_max(q2, xb); - double scale = (max_t - min_t)/Math.PI; - return new Particle(2212,0.0,0.0,0.0,0.0,0.0,0.0); - //return 1.0; - } - - public List getDvcsPhoton(double E, double q2, double xb, double t, double phield, double phigd){ - - double nu = q2/(2.0*MP*xb); - double qmod = Math.sqrt(nu*nu + q2); - double esc = E - nu; - double costel = 1.0 - q2/(2.0*E*esc); - double sintel = Math.sqrt(1.0 - costel*costel); - - if(esc<0.0) return new ArrayList(); - - double Ep = MP + t/(2.0*MP); - double Egam = nu - t/(2.0*MP); - - double cosphe = Math.cos(phield); - double sinphe = Math.sin(phield); - Vector3 vecQ = new Vector3(0.0,0.0,E); - Vector3 vecEP = new Vector3(esc*sintel*cosphe,esc*sintel*sinphe,esc*costel); - vecQ.sub(vecEP); - /*System.out.println(" Q2 VECTOR = " + "ESC = " + nu + " " + vecQ); - System.out.println(" EP / EGAM = " + Ep + " " + Egam + " VEC " + vecQ); - System.out.println("******* " + nu + " " + Egam + " " + q2);*/ - /*double a1 = 2.0*Egam*(MP + nu) + q2; - double a2 = - 2.0*MP*nu ; - double a3 = 2.0*Egam*qmod; - */ - //System.out.println("a1/a2/a3 = " + a1 + " " + a2 + " " + a3); - /*System.out.println(" NU = " + nu);*/ - - double costVq = vecQ.z()/qmod; - double sintVq = Math.sqrt(1.0 - costVq*costVq); - double costgg = (2.0*Egam*(MP + nu) + q2 - 2.0*MP*nu )/(2.0*Egam*qmod); - if(costgg>1.0) return new ArrayList(); - //double costgg = (2.0*Egam*(nu) + q2 - 2.0*MP*nu )/(2.0*Egam*qmod); - double sintgg = Math.sqrt(1.0 - costgg*costgg); - double Vgx = Egam*sintgg*Math.cos(phigd); - double Vgy = Egam*sintgg*Math.sin(phigd); - double Vgz = Egam*costgg; - - Vector3 vecG = new Vector3( - Vgx * costVq * cosphe - Vgz*sintVq*cosphe - Vgy*sinphe, - Vgx * costVq * sinphe - Vgz*sintVq*sinphe + Vgy*cosphe, - Vgx * sintVq + Vgz*costVq - ); - /*System.out.println(" cos VQ " + costVq + " costgg = " + costgg - + " qmod = " + qmod + " Nu = " + nu);*/ - //System.out.println(" PHOTON VECT = " + vecG); - List protonGamma = new ArrayList(); - vecQ.sub(vecG); - - protonGamma.add(vecQ); - protonGamma.add(vecG); - - return protonGamma; - } - - public static void main(String[] args){ - //PDGDatabase.show(); - DVCSProcess dvcs = new DVCSProcess(); - PhaseSpace kinematics = dvcs.getPhaseSpace(); - - //kinematics.show(); - - kinematics.getDimension("phi").setValue(Math.toRadians(30.0)); - PhysicsEvent event = dvcs.getEvent(kinematics); - - /* - Particle q2 = event.getParticle("[b]-[11]"); - Particle e = event.getParticle("[11]"); - double q2m = 4*6.0*e.vector().e()*Math.sin(e.theta()/2.0)*Math.sin(e.theta()/2.0); - System.out.println(q2.mass()*q2.mass() + " q2 mass = " + q2m); - */ - - //System.out.println(event.toLundString()); - - Particle mt = event.getParticle("[t]-[2212]"); - Particle mtg = event.getParticle("[b]-[11]-[22]"); - System.out.println(" -t = " + mt.vector().mass2()); - System.out.println(" -tg = " + mtg.vector().mass2()); - - /* - for(double xb = 0.1 ; xb < 0.6; xb += 0.05){ - kinematics.getDimension("xb").setValue(xb); - event = dvcs.getEvent(kinematics); - }*/ - } - - public double getWeight(PhaseSpace kinematics) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } -} diff --git a/common-tools/clas-physics/src/main/java/org/jlab/physics/process/IPhysicsProcess.java b/common-tools/clas-physics/src/main/java/org/jlab/physics/process/IPhysicsProcess.java deleted file mode 100644 index 7ff7459601..0000000000 --- a/common-tools/clas-physics/src/main/java/org/jlab/physics/process/IPhysicsProcess.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.jlab.physics.process; - -import java.util.Map; -import org.jlab.clas.physics.PhysicsEvent; -import org.jlab.physics.base.PhaseSpace; - -/** - * - * @author gavalian - */ -public interface IPhysicsProcess { - - PhysicsEvent getEvent(PhaseSpace kinematics); - PhaseSpace getPhaseSpace(); - double getWeight(PhaseSpace kinematics); -} diff --git a/common-tools/clas-physics/src/main/java/org/jlab/physics/process/KinematicsFactory.java b/common-tools/clas-physics/src/main/java/org/jlab/physics/process/KinematicsFactory.java deleted file mode 100644 index 10e9759156..0000000000 --- a/common-tools/clas-physics/src/main/java/org/jlab/physics/process/KinematicsFactory.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.jlab.physics.process; - -import org.jlab.clas.pdg.PDGDatabase; -import org.jlab.clas.physics.Particle; -import org.jlab.clas.physics.Vector3; - -/** - * - * @author gavalian - */ -public class KinematicsFactory { - - public static double MP = 0.93827; - /** - * returns mu for given kinematics variables - * @param q2 transferred momentum - * @param xb Bjorken x - * @return - */ - public static double getMu(double q2, double xb){ - //double pmass = PDGDatabase.getParticleMass(2212); - return q2/(2.0*0.93827*xb); - } - /** - * returns E' for given energy and kinematics variables. - * @param E initial electron energy - * @param q2 transferred momentum to proton - * @param xb Bjorken x - * @return - */ - public static double getEprime(double E, double q2, double xb){ - return E - KinematicsFactory.getMu(q2, xb); - } - /** - * returns scattered electron angle for given kinematics - * @param E initial electron energy - * @param q2 transfered 4 momentum - * @param xb Bjorken x - * @return - */ - public static double getTheta(double E, double q2, double xb){ - double eprime = KinematicsFactory.getEprime(E, q2, xb); - double left_side = q2/(4.0*E*eprime); - double value = Math.sqrt(left_side); - return 2.0*Math.asin(value); - } - - public static double getEpsilon(double q2, double xb){ - return 2.0*xb*0.93827/q2; - } - - public static double getQ2(double E, double x, double y){ - return 2.0*MP*E*y*x; - } - - /** - * returns an electron for given beam energy, q2 and xb - * @param E - * @param q2 - * @param xb - * @return - */ - public static Particle getElectron(double E, double q2, double xb){ - double eprime = KinematicsFactory.getEprime( E, q2, xb); - double theta = KinematicsFactory.getTheta( E, q2, xb); - //System.out.println("E-prime = " + eprime + " theta = " + Math.toDegrees(theta)); - Vector3 vec = new Vector3(); - vec.setMagThetaPhi(eprime, theta, 0.0); - return new Particle(11,vec.x(),vec.y(),vec.z(),0.0,0.0,0.0); - } - /** - * returns magnetic moment of the proton - * @param del2 - * @return - */ - public static double getGM_p(double del2){ - double denom = (1.0-del2/(0.84*0.84)); - double dipol = 1.0/(denom*denom); - return (1.0+1.79)*dipol; - } - /** - * returns magnetic moment for neutron - * @param del2 - * @return - */ - public static double getGM_n(double del2){ - double denom = (1.0-del2/(0.84*0.84)); - double dipol = 1.0/(denom*denom); - return -1.91*dipol; - } - /** - * returns electric moment of neutron, it's - * always 0, unless something has changed since - * writing of this code. - * @param del2 - * @return - */ - public static double getGE_n(double del2){ - return 0; - } - /** - * returns electric moment of the proton - * @param del2 - * @return - */ - public static double getGE_p(double del2){ - double denom = (1.0-del2/(0.84*0.84)); - double dipol = 1.0/(denom*denom); - return dipol; - } - /** - * Returns F1 function for U quark - * @param del2 - * @return - */ - public static double getF1_u(double del2){ - double delim = del2/(4.0*MP*MP); - double f1pn_1 = (KinematicsFactory.getGE_p(del2) - - delim*KinematicsFactory.getGM_p(del2))/(1.0-delim); - double f1pn_2 = (KinematicsFactory.getGE_n(del2) - - delim*KinematicsFactory.getGM_n(del2))/(1.0-delim); - return 2.0*f1pn_1 + f1pn_2; - } - /** - * returns F1 function for d quark - * @param del2 - * @return - */ - public static double getF1_d(double del2){ - double delim = del2/(4.0*MP*MP); - double f1pn_1 = (KinematicsFactory.getGE_p(del2) - - delim*KinematicsFactory.getGM_p(del2))/(1.0-delim); - double f1pn_2 = (KinematicsFactory.getGE_n(del2) - - delim*KinematicsFactory.getGM_n(del2))/(1.0-delim); - return 2.0*f1pn_2 + f1pn_1; - } -} diff --git a/common-tools/clas-reco/src/main/java/org/jlab/clas/fastmc/Clas12FastMC.java b/common-tools/clas-reco/src/main/java/org/jlab/clas/fastmc/Clas12FastMC.java index 7396e099e1..9374fe6654 100644 --- a/common-tools/clas-reco/src/main/java/org/jlab/clas/fastmc/Clas12FastMC.java +++ b/common-tools/clas-reco/src/main/java/org/jlab/clas/fastmc/Clas12FastMC.java @@ -7,7 +7,6 @@ import java.util.TreeMap; import org.jlab.clas.physics.Particle; -import org.jlab.clas.physics.PhysicsEvent; import org.jlab.geom.DetectorHit; import org.jlab.geom.base.Detector; import org.jlab.geom.prim.Path3D; @@ -19,14 +18,13 @@ public class Clas12FastMC { private ParticleSwimmer particleSwimmer = null; - List mcSensitivity = new ArrayList(); - Map mcDetectors = new LinkedHashMap(); + List mcSensitivity = new ArrayList<>(); + Map mcDetectors = new LinkedHashMap<>(); private double torusScale = 0.0; private double solenoidScale = 0.0; // For smearing - private final TreeMap pResolutions = new TreeMap(); + private final TreeMap pResolutions = new TreeMap<>(); public boolean isSmeared = false; - private int debugMode = 0; /** * constructor initialized part Monte-Carlo module module. arguments given are field strengths for torus and solenoid magnets. The scale value -1.0 is for @@ -103,15 +101,6 @@ public void addFilter(int charge, String[] d, int[] res) { this.mcSensitivity.add(sensitivity); } - /** - * set debug mode to control printout of the fast MC. - * - * @param mode - */ - public void setDebugMode(int mode) { - this.debugMode = mode; - } - /** * Swims particle through magnetic field and checks if all detector requirements are passed. returns false if any detector cut required is not satisfied. * @@ -141,39 +130,8 @@ public boolean checkParticle(Particle part) { return false; } - public PhysicsEvent getEvent(PhysicsEvent event) { - - PhysicsEvent recEvent = new PhysicsEvent(); - recEvent.setBeamParticle(event.beamParticle()); - recEvent.setTargetParticle(event.targetParticle()); - - int ncount = event.count(); - for (int i = 0; i < ncount; i++) { - Particle genPart = event.getParticle(i); - if (this.checkParticle(genPart) == true) { - Particle recParticle = new Particle(); - recParticle.copy(genPart); - recEvent.addParticle(recParticle); - } - } - /** - * Apply resolution smearing if the flag is set. - */ - if (this.isSmeared == true) { - for (int p = 0; p < recEvent.count(); p++) { - int pid = recEvent.getParticle(p).pid(); - int charge = recEvent.getParticle(p).charge(); - if (this.pResolutions.containsKey(pid) == true) { - this.pResolutions.get(pid).apply(recEvent.getParticle(p), this.torusScale, this.solenoidScale); - } - } - } - - return recEvent; - } - public Map getDetectorResponses(Particle part) { - Map detectors = new LinkedHashMap(); + Map detectors = new LinkedHashMap<>(); Path3D particlePath = this.particleSwimmer.getParticlePath(part); for (Map.Entry entry : mcDetectors.entrySet()) { List hits = entry.getValue().getLayerHits(particlePath); @@ -210,7 +168,7 @@ public void show() { */ public static class DetectorSensitivity { - Map detectorHits = new LinkedHashMap(); + Map detectorHits = new LinkedHashMap<>(); int charge = 0; public DetectorSensitivity(int pch, String[] dnames, int[] hits) { diff --git a/reconstruction/band/src/main/java/org/jlab/service/band/BANDEngine.java b/reconstruction/band/src/main/java/org/jlab/service/band/BANDEngine.java index 3bc81fac92..744bf98ba1 100644 --- a/reconstruction/band/src/main/java/org/jlab/service/band/BANDEngine.java +++ b/reconstruction/band/src/main/java/org/jlab/service/band/BANDEngine.java @@ -5,8 +5,6 @@ import org.jlab.clas.reco.ReconstructionEngine; import org.jlab.io.base.DataBank; import org.jlab.io.base.DataEvent; -import org.jlab.io.hipo.HipoDataSource; -import org.jlab.io.hipo.HipoDataSync; import org.jlab.rec.band.constants.CalibrationConstantsLoader; import org.jlab.rec.band.constants.Parameters; import org.jlab.rec.band.banks.HitReader; @@ -102,39 +100,4 @@ public void setRunConditionsParameters(DataEvent event) { } } - - public static void main (String arg[]) { - - BANDEngine en = new BANDEngine(); - en.init(); - - - String input = "bandtest.hipo"; - - HipoDataSource reader = new HipoDataSource(); - reader.open(input); - String outputFile="test.hipo"; - HipoDataSync writer = new HipoDataSync(); - writer.open(outputFile); - - int nevent = 0; - - while(reader.hasEvent() && nevent<2) { - DataEvent event = (DataEvent) reader.getNextEvent(); - //System.out.println("*********** NEXT EVENT ************"); - //event.show(); - //if (event.hasBank("band::adc") && event.hasBank("band::tdc")){ - // event.getBank("band::adc").show(); - // event.getBank("band::tdc").show(); - //} - en.processDataEventUser(event); - writer.writeEvent(event); - //event.getBank("band::hits").show(); - nevent++; - - } - writer.close(); - - - } } diff --git a/reconstruction/cnd/src/main/java/org/jlab/service/cnd/CNDCalibrationEngine.java b/reconstruction/cnd/src/main/java/org/jlab/service/cnd/CNDCalibrationEngine.java index 902e1f0565..68d670059d 100644 --- a/reconstruction/cnd/src/main/java/org/jlab/service/cnd/CNDCalibrationEngine.java +++ b/reconstruction/cnd/src/main/java/org/jlab/service/cnd/CNDCalibrationEngine.java @@ -7,8 +7,6 @@ import org.jlab.clas.reco.ReconstructionEngine; import org.jlab.io.base.DataBank; import org.jlab.io.base.DataEvent; -import org.jlab.io.hipo.HipoDataSource; -import org.jlab.io.hipo.HipoDataSync; import org.jlab.rec.cnd.constants.CalibrationConstantsLoader; import org.jlab.rec.cnd.banks.HitReader; import org.jlab.rec.cnd.banks.RecoBankWriter; @@ -33,16 +31,8 @@ public CNDCalibrationEngine() { } RecoBankWriter rbc; - static int enb =0; - static int ecnd=0; - static int hcvt=0; - static int match=0; - static int posmatch=0; - static int ctof=0; - static int ctoftot=0; private AtomicInteger Run = new AtomicInteger(0); - private int newRun = 0; @Override public boolean processDataEventUser(DataEvent event) { @@ -62,18 +52,15 @@ public boolean processDataEventUser(DataEvent event) { } CalibrationConstantsLoader constantsLoader = new CalibrationConstantsLoader(newRun, this.getConstantsManager()); - ArrayList halfhits = new ArrayList(); - ArrayList hits = new ArrayList(); - - halfhits = HitReader.getCndHalfHits(event, constantsLoader); + ArrayList halfhits = HitReader.getCndHalfHits(event, constantsLoader); //1) exit if halfhit list is empty - if(halfhits.size()==0 ){ + if(halfhits.isEmpty() ){ return true; } //2) find the CND hits from these half-hits CndHitFinder hitFinder = new CndHitFinder(); - hits = hitFinder.findHits(halfhits,0, constantsLoader); + ArrayList hits = hitFinder.findHits(halfhits,0, constantsLoader); CvtGetHTrack cvttry = new CvtGetHTrack(); cvttry.getCvtHTrack(event,constantsLoader); // get the list of helix associated with the event @@ -90,7 +77,7 @@ public boolean processDataEventUser(DataEvent event) { CNDClusterFinder cndclusterFinder = new CNDClusterFinder(); ArrayList cndclusters = cndclusterFinder.findClusters(hits,constantsLoader); - if(hits.size()!=0){ + if(!hits.isEmpty()){ rbc.appendCNDBanks(event,hits,cndclusters); } @@ -109,83 +96,5 @@ public boolean init() { @Override public void detectorChanged(int runNumber) {} - public static void main (String arg[]) { - CNDCalibrationEngine en = new CNDCalibrationEngine(); - - en.init(); - //String input = "/Users/ziegler/Workdir/Files/GEMC/ForwardTracks/pi-.r100.evio"; - //String input = "/projet/nucleon/silvia/test.hipo"; - //String input = "/projet/nucleon/silvia/ctof_pion.rec.hipo"; - //String input = "/projet/nucleon/silvia/out_ep.hipo"; - //String input = "/projet/nucleon/silvia/out_out_bis.hipo"; - //String input = "/projet/nucleon/silvia/out_bis.hipo"; - //String input = "/projet/nucleon/silvia/test.rec.hipo"; - //String input = "/projet/nucleon/pierre/test_out3.hipo"; - //String input = "/projet/nucleon/silvia/test.hipo"; - String input = "/projet/nucleon/pierre/RecCND/clas_002227.evio.18.hipo"; - //String input = "/projet/nucleon/pierre/RecCND/test.hipo"; - //String input = "/projet/nucleon/silvia/CLARA/out_clasdispr_small.00849.hipo"; - HipoDataSource reader = new HipoDataSource(); - reader.open(input); - String outputFile="/projet/nucleon/pierre/RecCND/test1.hipo"; - HipoDataSync writer = new HipoDataSync(); - writer.open(outputFile); - - while(reader.hasEvent()) { - enb++; - DataEvent event = (DataEvent) reader.getNextEvent(); - //event.show(); - //System.out.println("event nb "+enb); - - // System.out.println("event avant process "); - // event.show(); - - //event.getBank("MC::Particle").show(); - //if(event.hasBank("CVT::Tracks")){event.getBank("CVT::Tracks").show();}; - en.processDataEventUser(event); - - // System.out.println("event après process "); - // event.show(); - - //System.out.println("avant write "); - writer.writeEvent(event); - //System.out.println("après write "); - -// if(event.hasBank("CND::hits")){ -// //event.show(); -// System.out.println("event nb "+enb); -// event.getBank("CND::hits").show(); -// event.getBank("CND::adc").show(); -// event.getBank("CND::tdc").show(); -// } - - - - if(enb==30) break; - - } - writer.close(); - - //some statitics on cvt/cnd matching - System.out.println("enb "+enb); - System.out.println("ecnd "+ecnd); - System.out.println("hcvt "+hcvt); - System.out.println("posmatch "+posmatch); - System.out.println("match "+match); - System.out.println("%match cnd "+100.*match/posmatch); - System.out.println("Done"); - - - HipoDataSource sortie = new HipoDataSource(); - sortie.open(outputFile); - - System.out.println("Fichier de sortie : "); - while(sortie.hasEvent()) { - - DataEvent event = (DataEvent) sortie.getNextEvent(); - //event.show(); - - } - } } diff --git a/reconstruction/ec/pom.xml b/reconstruction/ec/pom.xml index 7a7ec1c37d..3f676b6814 100644 --- a/reconstruction/ec/pom.xml +++ b/reconstruction/ec/pom.xml @@ -44,11 +44,6 @@ clas-io 14.1.2-SNAPSHOT - - org.jlab.clas - clas-physics - 14.1.2-SNAPSHOT - org.jlab.clas clas-geometry diff --git a/reconstruction/ec/src/main/java/org/jlab/display/ec/ECDisplay.java b/reconstruction/ec/src/main/java/org/jlab/display/ec/ECDisplay.java deleted file mode 100644 index 717815300c..0000000000 --- a/reconstruction/ec/src/main/java/org/jlab/display/ec/ECDisplay.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.jlab.display.ec; - -import java.awt.BorderLayout; -import java.util.List; -import javax.swing.JFrame; -import javax.swing.JPanel; -import org.jlab.detector.base.DetectorType; -import org.jlab.detector.base.GeometryFactory; -import org.jlab.detector.view.DetectorPane2D; -import org.jlab.detector.view.DetectorShape2D; -import org.jlab.geom.base.Detector; -import org.jlab.io.base.DataEvent; -import org.jlab.io.task.DataSourceProcessorPane; -import org.jlab.io.task.IDataEventListener; -import org.jlab.service.ec.ECCluster; -import org.jlab.service.ec.ECCommon; -import org.jlab.service.ec.ECEngine; -import org.jlab.service.ec.ECPeak; -import org.jlab.service.ec.ECStrip; - -/** - * - * @author gavalian - */ -public class ECDisplay extends JPanel implements IDataEventListener { - - DetectorPane2D detectorView = null; - DataSourceProcessorPane processorPane = null; - ECEngine detectorEngine = new ECEngine(); - Detector ecDetector = null; - - public ECDisplay(){ - super(); - this.setLayout(new BorderLayout()); - detectorView = new DetectorPane2D(); - processorPane = new DataSourceProcessorPane(); - - this.add(detectorView,BorderLayout.CENTER); - this.add(processorPane,BorderLayout.PAGE_END); - processorPane.addEventListener(this); - detectorEngine.init(); - ecDetector = GeometryFactory.getDetector(DetectorType.ECAL); - } - - - public void dataEventAction(DataEvent de) { - detectorEngine.processDataEvent(de); - - detectorView.getView().removeLayer("PCAL"); - detectorView.getView().removeLayer("ECIN"); - detectorView.getView().removeLayer("ECOUT"); - - detectorView.getView().addLayer("PCAL"); - - - - List ecStrips = ECCommon.initEC(de, detectorEngine.getConstantsManager()); - List ecPeaksALL = ECCommon.createPeaks(ecStrips); - List ecPeaks = ECCommon.processPeaks(ecPeaksALL); - - DetectorShape2D shapeP = new DetectorShape2D(DetectorType.ECAL,0,0,0); - - shapeP.createBarXY(900,900); - detectorView.getView().addShape("PCAL", shapeP); - System.out.println("***********************************************"); - System.out.println("Adding shapes " + ecStrips.size()); - - for(ECPeak s : ecPeaks){ - - DetectorShape2D shape = new DetectorShape2D( - DetectorType.ECAL, - s.getDescriptor().getSector(),s.getDescriptor().getLayer(), - s.getMaxStrip()); - System.out.println(s); - shape.getShapePath().addPoint(s.getLine().origin()); - shape.getShapePath().addPoint(s.getLine().end()); - //System.out.println(s.getLine()); - if(shape.getDescriptor().getLayer()<4) - detectorView.getView().addShape("PCAL", shape); - - } - System.out.println("***************** CLUSTERS "); - List cPCAL = ECCommon.createClusters(ecPeaks,1); - for(ECCluster c : cPCAL){ - System.out.println(c); - } - detectorView.repaint(); - } - - public void timerUpdate() { - //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public void resetEventListener() { - //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - - public static void main(String[] args){ - JFrame frame = new JFrame(); - frame.setSize(800, 800); - ECDisplay display = new ECDisplay(); - frame.add(display); - frame.setVisible(true); - } - -} diff --git a/reconstruction/ec/src/main/java/org/jlab/display/ec/ECMonitor.java b/reconstruction/ec/src/main/java/org/jlab/display/ec/ECMonitor.java deleted file mode 100644 index 2dc222794d..0000000000 --- a/reconstruction/ec/src/main/java/org/jlab/display/ec/ECMonitor.java +++ /dev/null @@ -1,153 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.jlab.display.ec; - -import java.awt.BorderLayout; -import java.util.ArrayList; -import java.util.List; -import javax.swing.JFrame; -import javax.swing.JPanel; -import org.jlab.detector.decode.DetectorDecoderView; -import org.jlab.groot.data.H1F; -import org.jlab.groot.data.H2F; -import org.jlab.groot.graphics.EmbeddedCanvasTabbed; -import org.jlab.io.base.DataBank; -import org.jlab.io.base.DataEvent; -import org.jlab.io.task.DataSourceProcessorPane; -import org.jlab.io.task.IDataEventListener; -import org.jlab.service.ec.ECEngine; - -/** - * - * @author gavalian - */ -public class ECMonitor implements IDataEventListener { - - - DataSourceProcessorPane processorPane = null; - JPanel monitorPane = null; - EmbeddedCanvasTabbed tabCanvas = null; - ECPionFinder pionFinder = new ECPionFinder(); - ECEngine pionEngine = new ECEngine(); - - H1F H100_PION_MASS = null; - List histOccupancy = new ArrayList(); - List histClusters = new ArrayList(); - - public ECMonitor(){ - initUI(); - initData(); - pionEngine.init(); - } - - - private void initUI(){ - - monitorPane = new JPanel(); - monitorPane.setLayout(new BorderLayout()); - processorPane = new DataSourceProcessorPane(); - processorPane.addEventListener(this); - tabCanvas = new EmbeddedCanvasTabbed("Views","Ocupancy","Pion"); - - tabCanvas.getCanvas("Pion").initTimer(3000); - tabCanvas.getCanvas("Ocupancy").initTimer(3000); - tabCanvas.getCanvas("Views").initTimer(3000); - - monitorPane.add(tabCanvas,BorderLayout.CENTER); - monitorPane.add(processorPane,BorderLayout.PAGE_END); - } - - private void initData(){ - H100_PION_MASS = new H1F("PionMass",120,0.02,0.45); - H100_PION_MASS.setFillColor(43); - this.tabCanvas.getCanvas("Pion").draw(H100_PION_MASS); - - tabCanvas.getCanvas("Ocupancy").divide(2, 3); - tabCanvas.getCanvas("Views").divide(2, 3); - - for(int i = 0; i < 6; i++){ - H2F h2 = new H2F("HOCUP_S"+(i+1),80,0.5,78.5,9,0.5,9.5); - this.histOccupancy.add(h2); - tabCanvas.getCanvas("Ocupancy").cd(i); - tabCanvas.getCanvas("Ocupancy").draw(h2); - - H1F h1 = new H1F("CLUSTERS_S"+(i+1),9,0.5,9.5); - this.histClusters.add(h1); - - tabCanvas.getCanvas("Views").cd(i); - tabCanvas.getCanvas("Views").draw(h1); - } - - - } - - public JPanel getPanel(){ return this.monitorPane;} - - @Override - public void dataEventAction(DataEvent de) { - - try { - - this.pionEngine.processDataEvent(de); - this.pionFinder.processEvent(de); - //de.show(); - double mass = this.pionFinder.printMass(); - H100_PION_MASS.fill(mass); - - if(de.hasBank("ECAL::adc")==true){ - DataBank bank = de.getBank("ECAL::adc"); - int rows = bank.rows(); - for(int i = 0; i < rows; i++){ - int sector = bank.getByte("sector", i); - int layer = bank.getByte("layer", i); - int paddle = bank.getShort("component", i); - this.histOccupancy.get(sector-1).fill(paddle, layer); - } - } - - if(de.hasBank("ECAL::clusters")==true){ - DataBank bank = de.getBank("ECAL::clusters"); - int rows = bank.rows(); - for(int i = 0; i < rows; i++){ - int sector = bank.getByte("sector", i); - int layer = bank.getByte("layer", i); - //int paddle = bank.getShort("component", i); - this.histClusters.get(sector-1).fill(layer); - } - } - } catch (Exception e) { - System.out.println("-----> error with the event....."); - e.printStackTrace(); - } - } - - @Override - public void timerUpdate() { - //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public void resetEventListener() { - System.out.println("\n >>>> reset ec monitor"); - this.H100_PION_MASS.reset(); - for(H2F h : this.histOccupancy){ - h.reset(); - } - for(H1F h : this.histClusters){ - h.reset(); - } - //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - public static void main(String[] args){ - JFrame frame = new JFrame(); - frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - ECMonitor viewer = new ECMonitor(); - frame.add(viewer.getPanel()); - frame.setSize(900, 600); - frame.setVisible(true); - } -} diff --git a/reconstruction/ec/src/main/java/org/jlab/display/ec/ECPion.java-DISABLED b/reconstruction/ec/src/main/java/org/jlab/display/ec/ECPion.java-DISABLED deleted file mode 100644 index 096d3bb306..0000000000 --- a/reconstruction/ec/src/main/java/org/jlab/display/ec/ECPion.java-DISABLED +++ /dev/null @@ -1,238 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.jlab.display.ec; - -import java.util.ArrayList; -import java.util.List; -import org.jlab.clas.detector.DetectorParticle; -import org.jlab.clas.detector.DetectorResponse; -import org.jlab.clas.physics.GenericKinematicFitter; -import org.jlab.clas.physics.Particle; -import org.jlab.clas.physics.PhysicsEvent; -import org.jlab.clas.physics.Vector3; -import org.jlab.detector.base.DetectorType; -import org.jlab.geom.prim.Line3D; -import org.jlab.io.evio.EvioDataBank; -import org.jlab.io.evio.EvioDataEvent; -import org.jlab.io.evio.EvioSource; - -/** - * - * @author gavalian - */ -public class ECPion { - - public static List readEC(EvioDataEvent event){ - List ecResponse = new ArrayList(); - if(event.hasBank("ECDetector::clusters")==true){ - EvioDataBank ecCL = (EvioDataBank) event.getBank("ECDetector::clusters"); - int nrows = ecCL.rows(); - for(int i = 0; i < nrows; i++){ - DetectorResponse response = new DetectorResponse(); - response.getDescriptor().setType(DetectorType.ECAL); - response.getDescriptor().setSectorLayerComponent( - ecCL.getByte("sector", i),ecCL.getByte("layer", i),0 - ); - response.setPosition( - ecCL.getFloat("X", i), - ecCL.getFloat("Y", i), - ecCL.getFloat("Z", i) - ); - response.setEnergy(ecCL.getFloat("energy", i)); - ecResponse.add(response); - } - } - return ecResponse; - } - - public static List getResponseForLayer(List res, int layer){ - List ecr = new ArrayList(); - for(DetectorResponse r : res){ - if(r.getDescriptor().getLayer()==layer){ - ecr.add(r); - } - } - return ecr; - } - - public static void getPion(EvioDataEvent event){ - List ecResponses = ECPion.readEC(event); - - List rPCAL = ECPion.getResponseForLayer(ecResponses, 1); - - if(rPCAL.size()!=2) return; - List particles = new ArrayList(); - - for(int i = 0; i < rPCAL.size(); i++){ - DetectorParticle p = new DetectorParticle(); - p.setCross(0.0, 0.0, 0.0, - rPCAL.get(i).getPosition().x(), - rPCAL.get(i).getPosition().y(), - rPCAL.get(i).getPosition().z() - ); - p.addResponse(rPCAL.get(i)); - particles.add(p); - //System.out.println(p); - } - - List rECIN = ECPion.getResponseForLayer(ecResponses, 4); - List rECOUT = ECPion.getResponseForLayer(ecResponses, 7); - - int index_ecin = particles.get(0).getDetectorHitIndex(rECIN); - - if(index_ecin>=0&&index_ecin=0&&index_ecout=0&&index_ecin=0&&index_ecout ecResponses = ECPion.readEC(event); - List rPCAL = ECPion.getResponseForLayer(ecResponses, 1); - List rECIN = ECPion.getResponseForLayer(ecResponses, 4); - List rECOUT = ECPion.getResponseForLayer(ecResponses, 7); - - if(rPCAL.size()!=1) return; - List particles = new ArrayList(); - - DetectorParticle g = new DetectorParticle(); - g.setCross(0.0, 0.0, 0.0, - rPCAL.get(0).getPosition().x(), - rPCAL.get(0).getPosition().y(), - rPCAL.get(0).getPosition().z() - ); - g.addResponse(rPCAL.get(0)); - - int index_ecin = g.getDetectorHitIndex(rECIN); - int index_ecout = g.getDetectorHitIndex(rECOUT); - - if(index_ecin>=0&&rECIN.size()>0) g.addResponse(rECIN.get(index_ecin)); - if(index_ecout>=0&&rECOUT.size()>0) g.addResponse(rECOUT.get(index_ecout)); - double energy = g.getEnergy(DetectorType.ECAL)/0.27; - - Vector3 dir = g.getCrossDir(); - dir.unit(); - /* - System.out.println(" INDEX = " + index_ecin + " " + index_ecout - + " energy = " + g.getEnergy(DetectorType.ECAL) - + " " + energy + " " + String.format("%8.5f %8.5f", dir.theta()*57.29,dir.phi()*57.29)); - */ - - //System.out.println(g); - - GenericKinematicFitter fitter = new GenericKinematicFitter(11); - PhysicsEvent gen = fitter.getGeneratedEvent(event); - //System.out.println(gen); - Particle gamma = gen.getParticle("[22]"); - System.out.println(String.format("%8.5f %8.5f %8.5f %8.5f %8.5f %8.5f", energy, - dir.theta()*57.29,dir.phi()*57.29,gamma.vector().p(), - gamma.vector().theta()*57.29,gamma.vector().phi()*57.29)); - - - } - - public static void main(String[] args){ - EvioSource reader = new EvioSource(); - reader.open(args[0]); - - GenericKinematicFitter fitter = new GenericKinematicFitter(11); - - while(reader.hasEvent()){ - EvioDataEvent event = (EvioDataEvent) reader.getNextEvent(); - //ECPion.getPion(event); - ECPion.getPhoton(event); - - //PhysicsEvent gen = fitter.getGeneratedEvent(event); - //Particle pion = gen.getParticle("[22]+[22,1]"); - //System.out.println("---> " + pion.mass()); - } - } -} diff --git a/reconstruction/ec/src/main/java/org/jlab/display/ec/ECPionFinder.java b/reconstruction/ec/src/main/java/org/jlab/display/ec/ECPionFinder.java deleted file mode 100644 index 928c67949f..0000000000 --- a/reconstruction/ec/src/main/java/org/jlab/display/ec/ECPionFinder.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.jlab.display.ec; - -import java.util.ArrayList; -import java.util.List; -import org.jlab.clas.detector.DetectorParticle; -import org.jlab.clas.detector.DetectorResponse; -import org.jlab.clas.physics.Particle; -import org.jlab.clas.physics.PhysicsEvent; -import org.jlab.detector.base.DetectorType; -import org.jlab.io.base.DataEvent; -import org.jlab.io.hipo.HipoDataSource; - -/** - * - * @author gavalian - */ -public class ECPionFinder { - - List detectorResponse = null; - List particles = new ArrayList(); - List goodParticles = new ArrayList(); - PhysicsEvent physicsEvent = new PhysicsEvent(); - - public ECPionFinder(){ - - } - - public void processEvent(DataEvent event){ - this.initEvent(event); - this.doMatching(); - this.assignEnergy(); - //this.show(); - } - - public PhysicsEvent getPhysicsEvent(){ return this.physicsEvent;} - - public void initEvent(DataEvent event){ - detectorResponse = DetectorResponse.readHipoEvent(event, "ECAL::clusters", DetectorType.ECAL); - List PCAL = DetectorResponse.getListByLayer(detectorResponse, DetectorType.ECAL, 1); - particles.clear(); - for(DetectorResponse res : PCAL){ - DetectorParticle p = DetectorParticle.createNeutral(res); - particles.add(p); - } - } - - public void show(){ - /*System.out.println("-----> PARTICLES "); - for(DetectorParticle p : particles){ - System.out.println(p); - } - System.out.println("-----> GOOD PARTICLES "); - for(DetectorParticle p : goodParticles){ - System.out.println(p); - }*/ - - System.out.println(physicsEvent.toLundString()); - } - - public void assignEnergy(){ - goodParticles.clear(); - for(DetectorParticle p : particles){ - if(p.getDetectorResponses().size()>1){ - double energy = p.getEnergy(DetectorType.ECAL)/0.245; - p.vector().setMagThetaPhi(energy, p.vector().theta(), p.vector().phi()); - goodParticles.add(p); - } - } - physicsEvent.clear(); - physicsEvent.setBeam(11.0); - for(DetectorParticle p : goodParticles){ - physicsEvent.addParticle(p.getPhysicsParticle(22)); - } - } - - public double printMass(){ - int nrows = physicsEvent.countByPid(22); - Particle g1 = new Particle(); - Particle g2 = new Particle(); - double best_distance = 100.0; - double best_mass = 100.0; - for(int i = 0; i < nrows; i++){ - for(int j = i+1; j < nrows; j++){ - g1.copy(physicsEvent.getParticleByPid(22, i)); - double mom = g1.vector().p(); - g2.copy(physicsEvent.getParticleByPid(22, j)); - g1.combine(g2, 1); - double mass = g1.vector().mass(); - if(Math.abs(mass-0.135) ECIN = DetectorResponse.getListByLayer(detectorResponse, DetectorType.ECAL, 4); - //System.out.println("EC INNER SIZE = " + ECIN.size() ); - int counter = 0; - for(DetectorParticle p : particles){ - int index = p.getDetectorHit(ECIN, DetectorType.ECAL, 4, 15.0); - //System.out.println( "particle = " + counter + " index = " + index); - if(index>=0){ - p.addResponse(ECIN.get(index), true); - } - counter++; - } - - List ECOUT = DetectorResponse.getListByLayer(detectorResponse, DetectorType.ECAL, 7); - for(DetectorParticle p : particles){ - int index = p.getDetectorHit(ECOUT, DetectorType.ECAL, 7, 15.0); - if(index>=0){ - p.addResponse(ECOUT.get(index), true); - } - } - } - - public static void main(String[] args){ - String inputFile = args[0];//"/Users/gavalian/Work/Software/Release-9.0/COATJAVA/bench/dis_pion_rec_full.hipo"; - HipoDataSource reader = new HipoDataSource(); - reader.open(inputFile); - - ECPionFinder pion = new ECPionFinder(); - - while(reader.hasEvent()==true){ - DataEvent event = reader.getNextEvent(); - //System.out.println("-----------------"); - pion.processEvent(event); - pion.printMass(); - } - } -} 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 deleted file mode 100644 index 12cc5a4710..0000000000 --- a/reconstruction/ec/src/main/java/org/jlab/display/ec/ECRECMonitor.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * 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 void detectorChanged(int runNumber) {} - - @Override - public boolean processDataEventUser(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); - 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; - } - - 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; - } - -} diff --git a/reconstruction/ec/src/main/java/org/jlab/display/ec/Renderer.java b/reconstruction/ec/src/main/java/org/jlab/display/ec/Renderer.java deleted file mode 100644 index fa23d292e7..0000000000 --- a/reconstruction/ec/src/main/java/org/jlab/display/ec/Renderer.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * 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; - -/** - * - * @author gavalian - */ -public class Renderer { - public static Character[] block = new Character[]{ - '\u2581','\u2582','\u2583','\u2584', - '\u2585','\u2586' ,'\u2587' , '\u2588' }; - - DataRow[] rows = null; - private int xSize = 0; - private int ySize = 0; - public Renderer(int xsize, int ysize){ - this.initialize(xsize, ysize); - } - - public Renderer(int height, double[] data){ - this.initialize(data.length, height); - this.setData(data); - } - - private double getMax(double[] data){ - double max = 0.0; - for(int i = 0; i < data.length; i++) max = Math.max(max, data[i]); - return max; - } - - private void initialize(int xsize, int ysize){ - rows = new DataRow[xsize]; - for(int x = 0; x < xsize; x++) rows[x] = new DataRow(ysize); - xSize = xsize; ySize = ysize; - } - - public final void setData(double[] data){ - double max = getMax(data); - this.clear(); - for(int i = 0; i < rows.length; i++) rows[i].setHeight(data[i]/max); - } - - public void clear(){ - for (DataRow row : rows) row.clear(); - } - - @Override - public String toString(){ - StringBuilder str = new StringBuilder(); - str.append(String.format("xsize = %3d, ysize = %d\n",xSize, ySize)); - for(int y = ySize-1; y >=0; y--){ - for(int x = 0; x < xSize; x++){ - str.append(rows[x].row[y]).append(" "); - } - str.append("\n"); - } - for(int i = 0; i < xSize; i++) str.append("--"); - return str.toString(); - } - - public static class DataRow { - Character[] row = null; - public DataRow(int size){ - row = new Character[size]; - } - - public void clear(){ - for(int r = 0; r < row.length; r++) row[r] = ' '; - } - - public void setHeight(double fraction){ - - double height = row.length*fraction; - double left = height - Math.floor(height); - int nBlocks = (int) Math.floor(height); - - int nOrder = (int) Math.floor(left*Renderer.block.length); - //System.out.printf("--- setting fraction %f, nblocks = %d\n",fraction, nBlocks); - for(int i = 0; i < nBlocks; i++) row[i] = Renderer.block[row.length-1]; - if(nBlocks allPeaks){ int splitIndexOne = others.get(0).getSplitIndex(ECCommon.splitMethod); int splitIndexTwo = others.get(1).getSplitIndex(ECCommon.splitMethod); - //System.out.printf("\t >>> inside the loop where matching others were found, so one = %d, two = %d\n", - // splitIndexOne, splitIndexTwo); if(splitIndexOne>=0||splitIndexTwo>=0) return split; - //System.out.printf(" I was gonna split this peak, but decided not to : this is the way\n"); - //System.out.println(peak); } return new int[]{-1,-1,-1}; } @@ -98,8 +93,6 @@ public static int[] getBestCluster(ECPeak p, List viewOne, List for(int itwo = 0; itwo < viewTwo.size(); itwo++){ Line3D line = ECCluster.getClusterGeometry(p, viewOne.get(ione),viewTwo.get(itwo)); - //System.out.println("\t" + p); - //System.out.printf("\t\t %5d %5d, distance = %9.3f\n",ione,itwo, line.length()); if(line.length() getMatchingPeaks(ECPeak p, List peaks){ int layer = p.getDescriptor().getLayer(); int[] layers = ECPeakAnalysis.otherLayers[layer]; - //System.out.printf("\t LOOKING: peak at = %d , looking for %d %d\n",layer, layers[0], layers[1]); List one = ECPeakAnalysis.getListForSectorLayer(peaks, sector, layers[0]); List two = ECPeakAnalysis.getListForSectorLayer(peaks, sector, layers[1]); - //System.out.printf("\t LOOKING: peak at = %d , looking for %d %d and got count %d,%d\n", - // layer, layers[0], layers[1], one.size(), two.size()); int[] cluster = ECPeakAnalysis.getBestCluster(p, one, two); if(cluster[0]>=0&&cluster[1]>=0) return Arrays.asList(one.get(cluster[0]),two.get(cluster[1])); - return new ArrayList(); + return new ArrayList<>(); } public static void splitPeaksAlternative(List peaks){ @@ -130,7 +120,6 @@ public static void splitPeaksAlternative(List peaks){ current.addAll(peaks); peaks.clear(); - //System.out.printf("--- split peaks start current = %d, peaks = %d\n",current.size(), peaks.size()); while(!current.isEmpty()){ ECPeak peak = current.get(0); current.remove(0); @@ -139,90 +128,13 @@ public static void splitPeaksAlternative(List peaks){ List result = peak.splitPeak(split[0]); double en1 = result.get(0).getMaxECStrip().getEnergy(); double en2 = result.get(1).getMaxECStrip().getEnergy(); - - double en11 = Math.max(en1, en2); - double en22 = Math.min(en1, en2); - double ens = peak.getStripEnergy(split[0]); - - /*Renderer r = new Renderer(8,peak.getEnergies()); - System.out.println(r); - System.out.printf(">>> SPLIT : %9.5f %9.5f %9.5f, RATIO = \"%.5f, %.5f %.5f\" %s\n", - en11,en22,ens,en22/en11,ens/en11,ens/en22 ,peak.getString()); - */ - peaks.addAll(peak.splitPeak(split[0])); } else { peaks.add(peak); } } - //System.out.printf("--- split peaks end current = %d, peaks = %d\n",current.size(), peaks.size()); - /* - while(true){ //repeat processing all peaks until no split found - if(ECCommon.debugSplit) System.out.println(" "); - int[] split = getPeakSplitIndex(peaks); - if(ECCommon.debugSplit) System.out.println("New Iteration "+split[0]+" "+split[1]); - if(split[2]<0){ - return; // no split was found in any peak. Exit. - } else { - ECPeak peak = peaks.get(split[2]); //retrieve tagged peak with split candidate - peaks.remove(split[2]); //tagged peak removed from list - peaks.addAll(peak.splitPeak(split[0])); //two split peaks returned to list - } - }*/ } - - public static void splitPeaksAlternative3(List peaks){ - - List current = new ArrayList<>(); - List whole = new ArrayList<>(); - - current.addAll(peaks); - whole.addAll(peaks); - - peaks.clear(); - //System.out.printf("--- split peaks start current = %d, peaks = %d\n",current.size(), peaks.size()); - - while(!current.isEmpty()){ - ECPeak peak = current.get(0); current.remove(0); - int[] split = ECPeakAnalysis.getPeakSplitIndex(peak, whole); - if(split[0]>=0){ - List result = peak.splitPeak(split[0]); - double en1 = result.get(0).getMaxECStrip().getEnergy(); - double en2 = result.get(1).getMaxECStrip().getEnergy(); - - double en11 = Math.max(en1, en2); - double en22 = Math.min(en1, en2); - double ens = peak.getStripEnergy(split[0]); - - Renderer r = new Renderer(8,peak.getEnergies()); - System.out.println(r); - System.out.printf(">>> SPLIT : %9.5f %9.5f %9.5f, RATIO = \"%.5f, %.5f %.5f\" %s\n", - en11,en22,ens,en22/en11,ens/en11,ens/en22 ,peak.getString()); - - - peaks.addAll(peak.splitPeak(split[0])); - } else { - peaks.add(peak); - } - } - //System.out.printf("--- split peaks end current = %d, peaks = %d\n",current.size(), peaks.size()); - /* - while(true){ //repeat processing all peaks until no split found - if(ECCommon.debugSplit) System.out.println(" "); - int[] split = getPeakSplitIndex(peaks); - if(ECCommon.debugSplit) System.out.println("New Iteration "+split[0]+" "+split[1]); - if(split[2]<0){ - return; // no split was found in any peak. Exit. - } else { - ECPeak peak = peaks.get(split[2]); //retrieve tagged peak with split candidate - peaks.remove(split[2]); //tagged peak removed from list - peaks.addAll(peak.splitPeak(split[0])); //two split peaks returned to list - } - }*/ - } - - - + public static void splitPeaksAlternative2(List peaks){ ECPeakSplitterMargin m = new ECPeakSplitterMargin(); @@ -233,7 +145,6 @@ public static void splitPeaksAlternative2(List peaks){ current.addAll(peaks); whole.addAll(peaks); peaks.clear(); - //System.out.printf("--- split peaks start current = %d, peaks = %d\n",current.size(), peaks.size()); while(!current.isEmpty()){ ECPeak peak = current.get(0); current.remove(0); @@ -247,18 +158,11 @@ public static void splitPeaksAlternative2(List peaks){ List one = ECPeakAnalysis.getListForSectorLayer(whole, sector, layers[0]); List two = ECPeakAnalysis.getListForSectorLayer(whole, sector, layers[1]); - - //int[] cluster = ECPeakAnalysis.getBestCluster(peak, one, two); - List others = ECPeakAnalysis.getMatchingPeaks(peak, whole); if(others.size()==2){ List oneView = m.split(others.get(0)); List twoView = m.split(others.get(1)); - //Renderer r = new Renderer(8,peak.getEnergies()); - //System.out.println(r); - //System.out.printf(" >>> found splittable peak : others = %d %d (%d %d) \n", - // oneView.size(),twoView.size(), one.size(), two.size()); if(oneView.size()==1&&twoView.size()==1){ if(one.size()>1&&two.size()>1){ peaks.addAll(splitPeaks); @@ -273,13 +177,9 @@ public static void splitPeaksAlternative2(List peaks){ } else { peaks.add(peak); } - - } - } - public static void splitPeaksAlternative5(List peaks){ ECPeakSplitterOriginal mo = new ECPeakSplitterOriginal(); @@ -290,7 +190,6 @@ public static void splitPeaksAlternative5(List peaks){ current.addAll(peaks); whole.addAll(peaks); peaks.clear(); - //System.out.printf("--- split peaks start current = %d, peaks = %d\n",current.size(), peaks.size()); while(!current.isEmpty()){ ECPeak peak = current.get(0); current.remove(0); @@ -301,7 +200,6 @@ public static void splitPeaksAlternative5(List peaks){ public static void splitPeaksAlternative4(List peaks){ - ECPeakSplitterMargin mm = new ECPeakSplitterMargin(); ECPeakSplitterOriginal mo = new ECPeakSplitterOriginal(); List current = new ArrayList<>(); @@ -310,14 +208,12 @@ public static void splitPeaksAlternative4(List peaks){ current.addAll(peaks); whole.addAll(peaks); peaks.clear(); - //System.out.printf("--- split peaks start current = %d, peaks = %d\n",current.size(), peaks.size()); while(!current.isEmpty()){ ECPeak peak = current.get(0); current.remove(0); List splitPeaks = mo.split(peak); - if(splitPeaks.size()==2){ int sector = peak.getDescriptor().getSector(); @@ -327,30 +223,12 @@ public static void splitPeaksAlternative4(List peaks){ List one = ECPeakAnalysis.getListForSectorLayer(whole, sector, layers[0]); List two = ECPeakAnalysis.getListForSectorLayer(whole, sector, layers[1]); - //int[] cluster = ECPeakAnalysis.getBestCluster(peak, one, two); - List others = ECPeakAnalysis.getMatchingPeaks(peak, whole); if(others.size()==2){ List oneView = mo.split(others.get(0)); List twoView = mo.split(others.get(1)); - //Renderer r = new Renderer(8,peak.getEnergies()); - //System.out.println(r); - //System.out.printf(" >>> found splittable peak : others = %d %d (%d %d) \n", - // oneView.size(),twoView.size(), one.size(), two.size()); - int type = 0; - List newMethod = mm.split(peak); - - /*System.out.printf(" M (%d) energy (%8.5f %8.5f) distance = %8.5f (%8.5f %8.5f) - others = %d %d are splittable (%3d %3d)\n", - newMethod.size(), splitPeaks.get(0).getEnergy()/peak.getEnergy(), - splitPeaks.get(1).getEnergy()/peak.getEnergy(), - ECCluster.getDistance(peak, others.get(0),others.get(1)), - ECCluster.getDistance(splitPeaks.get(0), - others.get(0),others.get(1)), - ECCluster.getDistance(splitPeaks.get(1), others.get(0),others.get(1)) - , one.size(),two.size(), oneView.size(), twoView.size()); - */ int is_s_1 = oneView.size(); int is_s_2 = twoView.size(); @@ -361,14 +239,12 @@ public static void splitPeaksAlternative4(List peaks){ double dist_12 = ECCluster.getDistance(splitPeaks.get(0), others.get(0),others.get(1)); double dist_13 = ECCluster.getDistance(splitPeaks.get(1) ,others.get(0),others.get(1)); - //System.out.printf(">>>> %f %f %f\n",dist123,dist_12, dist_13); double best_dist_23 = Math.min(Math.abs(dist_13), Math.abs(dist_12)); double best_dist = Math.min(Math.abs(dist123), best_dist_23); double best_ratio = best_dist/Math.abs(dist123); double best_ratio_23 = best_dist_23/Math.abs(dist123); - int should_split = 0; if(is_s_1==1&&is_s_2==1){ @@ -385,30 +261,6 @@ public static void splitPeaksAlternative4(List peaks){ } } - Renderer r1 = new Renderer(8,peak.getEnergies()); - Renderer r2 = new Renderer(8,others.get(0).getEnergies()); - Renderer r3 = new Renderer(8,others.get(1).getEnergies()); - - - /*System.out.printf(" M (%d) energy (%8.5f %8.5f) distance = %8.5f (%8.5f %8.5f) - others = %d %d are splittable (%3d %3d), best dist = %8.5f r = %8.5f, should split = %d\n", - newMethod.size(), splitPeaks.get(0).getEnergy()/peak.getEnergy(), - splitPeaks.get(1).getEnergy()/peak.getEnergy(), - ECCluster.getDistance(peak, others.get(0),others.get(1)), - ECCluster.getDistance(splitPeaks.get(0), - others.get(0),others.get(1)), - ECCluster.getDistance(splitPeaks.get(1), others.get(0),others.get(1)) - , one.size(),two.size(), oneView.size(), twoView.size(),best_dist, best_ratio,should_split); - System.out.println(r1); - System.out.println(r2); - System.out.println(r3);*/ - /*if(oneView.size()==1&&twoView.size()==1){ - if(one.size()>1&&two.size()>1){ - peaks.addAll(splitPeaks); - } else { peaks.add(peak);} - } else { - peaks.addAll(splitPeaks); - }*/ - if(should_split>0){ peaks.addAll(splitPeaks); } else { @@ -422,13 +274,9 @@ public static void splitPeaksAlternative4(List peaks){ } else { peaks.add(peak); } - - } - } - public static int findMatchForCluster(ECCluster c, List list){ for(int i = 0; i < list.size(); i++){ ECCluster l = list.get(i); @@ -461,21 +309,15 @@ public static void doClusterCleanup(List clusters){ tmp.remove(index); l.getClusterGeometry(); c.getClusterGeometry(); - //System.out.println(" found a sharing cluster..."); if(c.getClusterSize() peaks){ ECPeakSplitterMargin m = new ECPeakSplitterMargin(); for(int i = 0; i < peaks.size(); i++){ diff --git a/reconstruction/ec/src/main/java/org/jlab/service/ec/ECPeakSplitter.java b/reconstruction/ec/src/main/java/org/jlab/service/ec/ECPeakSplitter.java index 86f39975fa..68d3a99238 100644 --- a/reconstruction/ec/src/main/java/org/jlab/service/ec/ECPeakSplitter.java +++ b/reconstruction/ec/src/main/java/org/jlab/service/ec/ECPeakSplitter.java @@ -1,13 +1,8 @@ -/* - * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license - * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Interface.java to edit this template - */ package org.jlab.service.ec; import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import org.jlab.display.ec.Renderer; /** * diff --git a/reconstruction/fmt/src/main/java/org/jlab/rec/fmt/hit/Hit.java b/reconstruction/fmt/src/main/java/org/jlab/rec/fmt/hit/Hit.java index f70be409f0..6d4120ffa4 100644 --- a/reconstruction/fmt/src/main/java/org/jlab/rec/fmt/hit/Hit.java +++ b/reconstruction/fmt/src/main/java/org/jlab/rec/fmt/hit/Hit.java @@ -6,7 +6,6 @@ import org.jlab.detector.banks.RawDataBank; import org.jlab.geom.prim.Line3D; import org.jlab.geom.prim.Point3D; -import org.jlab.io.base.DataBank; import org.jlab.io.base.DataEvent; import org.jlab.rec.fmt.Constants; import org.jlab.utils.groups.IndexedTable; diff --git a/reconstruction/ft/pom.xml b/reconstruction/ft/pom.xml index 64434b96a1..46e11ae687 100644 --- a/reconstruction/ft/pom.xml +++ b/reconstruction/ft/pom.xml @@ -17,6 +17,7 @@ org.jlab groot + test org.jlab.clas diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEBEngine.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEBEngine.java index 0369d8cdb3..1589ecb702 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEBEngine.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEBEngine.java @@ -2,33 +2,11 @@ import java.util.Arrays; import java.util.List; - -import javax.swing.JFrame; -import org.jlab.clas.detector.DetectorData; -import org.jlab.clas.detector.DetectorEvent; - import org.jlab.clas.reco.ReconstructionEngine; -import org.jlab.detector.base.DetectorLayer; -import org.jlab.geom.prim.Line3D; -import org.jlab.geom.prim.Point3D; -import org.jlab.geom.prim.Vector3D; -import org.jlab.groot.data.H1F; -import org.jlab.groot.data.H2F; -import org.jlab.groot.data.DataLine; -import org.jlab.groot.math.F1D; -import org.jlab.groot.fitter.DataFitter; -import org.jlab.groot.graphics.EmbeddedCanvas; import org.jlab.io.base.DataBank; import org.jlab.io.base.DataEvent; import org.jlab.io.evio.EvioDataBank; import org.jlab.io.evio.EvioDataEvent; -import org.jlab.io.hipo.HipoDataSource; -import org.jlab.rec.ft.cal.FTCALConstantsLoader; -import org.jlab.rec.ft.cal.FTCALEngine; -import org.jlab.rec.ft.hodo.FTHODOEngine; -import org.jlab.rec.ft.trk.FTTRKEngine; -import org.jlab.rec.ft.trk.FTTRKConstantsLoader; -import org.jlab.rec.ft.trk.FTTRKReconstruction; public class FTEBEngine extends ReconstructionEngine { diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/cal/FTCALEngine.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/cal/FTCALEngine.java index 530fe94e31..749b908d47 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/cal/FTCALEngine.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/cal/FTCALEngine.java @@ -3,17 +3,11 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import javax.swing.JFrame; import org.jlab.clas.reco.ReconstructionEngine; -import org.jlab.geom.prim.Vector3D; -import org.jlab.groot.data.H1F; -import org.jlab.groot.data.H2F; -import org.jlab.groot.graphics.EmbeddedCanvas; import org.jlab.io.base.DataBank; import org.jlab.io.base.DataEvent; import org.jlab.io.evio.EvioDataBank; import org.jlab.io.evio.EvioDataEvent; -import org.jlab.io.hipo.HipoDataSource; public class FTCALEngine extends ReconstructionEngine { @@ -88,71 +82,4 @@ public int setRunConditionsParameters(DataEvent event) { return run; } - - public static void main (String arg[]) { - FTCALEngine cal = new FTCALEngine(); - cal.init(); - // String input = "/Users/devita/Work/clas12/simulations/clas12Tags/4.4.0/out.hipo"; -// String input = "/home/filippi/clas/ForwardTracker/DATA/out_realGeo_noMagField.data"; -// String input = "/home/filippi/clas/gemc/electronGun/gemc.hipo"; - String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/ft_005038.evio.01231.hipo"; - HipoDataSource reader = new HipoDataSource(); -// String input = "/Users/devita/Work/clas12/simulations/tests/detectors/clas12/ft/out_header.ev"; -// EvioSource reader = new EvioSource(); - reader.open(input); - - // initialize histos - H1F h1 = new H1F("Cluster Energy",100, 0.,5.); - h1.setOptStat(Integer.parseInt("1111")); h1.setTitleX("Cluster Energy (GeV)"); - H1F h2 = new H1F("Energy Resolution",100, -1, 1); - h2.setOptStat(Integer.parseInt("1111")); h2.setTitleX("Energy Resolution(GeV)"); - H1F h3 = new H1F("Theta Resolution",100, -2, 2); - h3.setOptStat(Integer.parseInt("1111")); h3.setTitleX("Theta Resolution(deg)"); - H1F h4 = new H1F("Phi Resolution",100, -10, 10); - h4.setOptStat(Integer.parseInt("1111")); h4.setTitleX("Phi Resolution(deg)"); -// H1F h5 = new H1F("Time Resolution",100, -10, 10); - H1F h5 = new H1F("Time Resolution",100, -100, 300); - h5.setOptStat(Integer.parseInt("1111")); h5.setTitleX("Time Resolution(ns)"); - H2F h6 = new H2F("cluster xy", 100, -15., 15., 100, -15., 15.); - h6.setTitleX("cluster x"); h6.setTitleY("cluster y"); - - while(reader.hasEvent()){ -// for(int nev=0; nev<2; nev++){ - DataEvent event = (DataEvent) reader.getNextEvent(); - cal.processDataEvent(event); - - if(event.hasBank("FTCAL::clusters")) { - DataBank bank = event.getBank("FTCAL::clusters"); - int nrows = bank.rows(); - for(int i=0; i=0) { - // get hits fron banks - List allHits = reco.initFTHODO(event,this.getConstantsManager(), run); - // select good hits and order them by energy - List selectedHits = reco.selectHits(allHits); - // create clusters - List clusters = reco.findClusters(selectedHits); - // write output banks - reco.writeBanks(event, selectedHits, clusters); - } - return true; - } - + + @Override + public boolean processDataEventUser(DataEvent event) { + + // update calibration constants based on run number if changed + int run = setRunConditionsParameters(event); + + if(run>=0) { + // get hits fron banks + List allHits = reco.initFTHODO(event,this.getConstantsManager(), run); + // select good hits and order them by energy + List selectedHits = reco.selectHits(allHits); + // create clusters + List clusters = reco.findClusters(selectedHits); + // write output banks + reco.writeBanks(event, selectedHits, clusters); + } + return true; + } + public int setRunConditionsParameters(DataEvent event) { int run = -1; if(event.hasBank("RUN::config")==false) { - System.out.println("RUN CONDITIONS NOT READ!"); - } - + System.out.println("RUN CONDITIONS NOT READ!"); + } + if(event instanceof EvioDataEvent) { EvioDataBank bank = (EvioDataBank) event.getBank("RUN::config"); run = bank.getInt("Run",0); @@ -77,59 +69,6 @@ public int setRunConditionsParameters(DataEvent event) { DataBank bank = event.getBank("RUN::config"); run = bank.getInt("run",0); } - return run; + return run; } - - - public static void main (String arg[]) { - FTHODOEngine cal = new FTHODOEngine(); - cal.init(); -// String input = "/Users/devita/data/out_clasdispr.00.e11.000.emn0.75tmn.09.xs65.61nb.dis.1.V5.hipo"; -// HipoDataSource reader = new HipoDataSource(); - String input = "/Users/devita/test4.hipo"; - HipoDataSource reader = new HipoDataSource(); - reader.open(input); - - // initialize histos - H1F h1 = new H1F("Cluster Energy",100, 0.,5.); - h1.setOptStat(Integer.parseInt("1111")); h1.setTitleX("Cluster Energy (GeV)"); - H1F h2 = new H1F("Energy Resolution",100, -1, 1); - h2.setOptStat(Integer.parseInt("1111")); h2.setTitleX("Energy Resolution(GeV)"); - H1F h3 = new H1F("Theta Resolution",100, -2, 2); - h3.setOptStat(Integer.parseInt("1111")); h3.setTitleX("Theta Resolution(deg)"); - H1F h4 = new H1F("Phi Resolution",100, -10, 10); - h4.setOptStat(Integer.parseInt("1111")); h4.setTitleX("Phi Resolution(deg)"); - H1F h5 = new H1F("Time Resolution",100, -10, 10); - h5.setOptStat(Integer.parseInt("1111")); h5.setTitleX("Time Resolution(ns)"); - - while(reader.hasEvent()){ - DataEvent event = (DataEvent) reader.getNextEvent(); - cal.processDataEventUser(event); - - if(event.hasBank("FTHODO::clusters")) { - DataBank bank = event.getBank("FTHODO::clusters"); - int nrows = bank.rows(); - for(int i=0; i=1) System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~ processing event ~~~~~~~~~~~ " + nev); - - ArrayList clusters = trk.processDataEventAndGetClusters(event); - int nStripsInClusters = 0; - - double maxcomp1=-100, maxcomp2=-100, maxcomp3=-100, maxcomp4=-100; - int imax1 = -1, imax2 = -1, imax3 = -1, imax4 = -1; - if(event.hasBank("FTTRK::hits")) { - DataBank bank = event.getBank("FTTRK::hits"); - int nrows = bank.rows(); - for(int i=0; imaxcomp1){ - maxcomp1 = energy; - imax1 = i; - } - break; - case DetectorLayer.FTTRK_LAYER2: - hOccupancy2.fill(comp); - if(energy>maxcomp2){ - maxcomp2 = energy; - imax2 = i; - } - break; - case DetectorLayer.FTTRK_LAYER3: - hOccupancy3.fill(comp); - if(energy>maxcomp3){ - maxcomp3 = energy; - imax3 = i; - } - break; - case DetectorLayer.FTTRK_LAYER4: - hOccupancy4.fill(comp); - if(energy>maxcomp4){ - maxcomp4 = energy; - imax4 = i; - } - break; - default: - } - } - } - - canvasCl.draw(hHitL1); // dummy histogram - // iterate along the cluster list for every event - if(debug>=1) System.out.println("clusters size --- " + clusters.size()); - if(!clusters.isEmpty()){ - // get one cluster and iterate over all the strips contained in it - for(int i = 0; i < clusters.size(); i++){ - // get a single cluster and count its strip, extract the information on extremal points of the segment - FTTRKCluster singleCluster = clusters.get(i); - int nst = singleCluster.size(); - for(int j=0; j=1) System.out.println("nStripsInCluster " + nStripsInClusters); - canvasCl.draw(segment[nStripsInClusters]); - h1clEn.fill(singleCluster.get_TotalEnergy()); - nStripsInClusters++; - } - } - } - - if(event.hasBank("FTTRK::crosses")){ - DataBank crossBank = event.getBank("FTTRK::crosses"); - int nrows = crossBank.rows(); - float x[]; - float y[]; - float z[]; - byte det[]; - x = new float[nrows]; - y = new float[nrows]; - z = new float[nrows]; - det = new byte[nrows]; - for(int i=0; i=1) System.out.println("number of crosses " + nrows + " detector " + det[i] + " x " + x[i] + " y " + y[i]); - - if(det[i]==(DetectorLayer.FTTRK_MODULE1 - 1)) {hHitL1.fill(x[i], y[i]); nc1++;} - if(det[i]==(DetectorLayer.FTTRK_MODULE2 - 1)) {hHitL2.fill(x[i], y[i]); nc2++;} - } - /// loop on all crosses on detector 1 and 2 and find the one with better matching - double minDistance = 1000; - double minDiffPhi = 1000.; - int iBest = -1, jBest = -1; - if(nrows>1){ - double diffPhi = 1000; - for(int i=0; ii; j--){ - if(det[i]!=det[j]){ - double distance = Math.sqrt((x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j])); - double phiCross1 = Math.atan2(y[i],x[i]); - double phiCross2 = Math.atan2(y[j],x[j]); - diffPhi = Math.abs(phiCross1-phiCross2); - if(Math.abs(phiCross1-phiCross2)-1 && jBest>-1){ - double r1 = Math.sqrt(x[iBest]*x[iBest]+y[iBest]*y[iBest]); - double r2 = Math.sqrt(x[jBest]*x[jBest]+y[jBest]*y[jBest]); - double diffRadii = r1-r2; - double diffTheta = Math.atan2(r1,z[iBest])- Math.atan2(r2,z[jBest]); - if(minDiffPhi < diffPhiTolerance && - Math.abs(diffRadii)org.jlab.jnp jnp-hipo - - org.jlab - groot - org.jlab.clas swim-tools diff --git a/reconstruction/mu/src/main/java/org/jlab/rec/mucal/MUCALEngine.java b/reconstruction/mu/src/main/java/org/jlab/rec/mucal/MUCALEngine.java index 5c659ce735..44fdec2bb5 100644 --- a/reconstruction/mu/src/main/java/org/jlab/rec/mucal/MUCALEngine.java +++ b/reconstruction/mu/src/main/java/org/jlab/rec/mucal/MUCALEngine.java @@ -1,87 +1,73 @@ package org.jlab.rec.mucal; -import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import javax.swing.JFrame; -import org.jlab.clas.detector.DetectorData; -import org.jlab.clas.detector.DetectorEvent; -import org.jlab.clas.physics.PhysicsEvent; import org.jlab.clas.reco.ReconstructionEngine; -import org.jlab.geom.prim.Vector3D; -import org.jlab.groot.data.H1F; -import org.jlab.groot.data.H2F; -import org.jlab.groot.graphics.EmbeddedCanvas; import org.jlab.io.base.DataBank; import org.jlab.io.base.DataEvent; import org.jlab.io.evio.EvioDataBank; import org.jlab.io.evio.EvioDataEvent; -import org.jlab.io.hipo.HipoDataSource; - public class MUCALEngine extends ReconstructionEngine { - - public MUCALEngine() { - super("MUCAL", "devita", "3.0"); - } - - MUCALReconstruction reco; - - @Override - public boolean init() { - reco = new MUCALReconstruction(); - reco.debugMode=0; - - String[] tables = new String[]{ - "/calibration/ft/ftcal/charge_to_energy", - "/calibration/ft/ftcal/time_offsets", - "/calibration/ft/ftcal/time_walk", - "/calibration/ft/ftcal/status", - "/calibration/ft/ftcal/thresholds", - "/calibration/ft/ftcal/cluster", - "/calibration/ft/ftcal/energycorr" - }; - requireConstants(Arrays.asList(tables)); - this.getConstantsManager().setVariation("default"); - - this.registerOutputBank("MUCAL::hits","MUCAL::clusters"); - - return true; - } - + + public MUCALEngine() { + super("MUCAL", "devita", "3.0"); + } + + MUCALReconstruction reco; + + @Override + public boolean init() { + reco = new MUCALReconstruction(); + reco.debugMode=0; + + String[] tables = new String[]{ + "/calibration/ft/ftcal/charge_to_energy", + "/calibration/ft/ftcal/time_offsets", + "/calibration/ft/ftcal/time_walk", + "/calibration/ft/ftcal/status", + "/calibration/ft/ftcal/thresholds", + "/calibration/ft/ftcal/cluster", + "/calibration/ft/ftcal/energycorr" + }; + requireConstants(Arrays.asList(tables)); + this.getConstantsManager().setVariation("default"); + + this.registerOutputBank("MUCAL::hits","MUCAL::clusters"); + + return true; + } + @Override public void detectorChanged(int run) {} - - @Override - public boolean processDataEventUser(DataEvent event) { - List allHits = new ArrayList(); - List selectedHits = new ArrayList(); - List clusters = new ArrayList(); - - // update calibration constants based on run number if changed - int run = setRunConditionsParameters(event); - - if(run>=0) { - // get hits fron banks - allHits = reco.initMUCAL(event,this.getConstantsManager(), run); - // select good hits and order them by energy - selectedHits = reco.selectHits(allHits,this.getConstantsManager(), run); - // create clusters - clusters = reco.findClusters(selectedHits, this.getConstantsManager(), run); - // set cluster status - reco.selectClusters(clusters, this.getConstantsManager(), run); - // write output banks - reco.writeBanks(event, selectedHits, clusters, this.getConstantsManager(), run); - } - return true; - } - + + @Override + public boolean processDataEventUser(DataEvent event) { + + // update calibration constants based on run number if changed + int run = setRunConditionsParameters(event); + + if(run>=0) { + // get hits fron banks + List allHits = reco.initMUCAL(event,this.getConstantsManager(), run); + // select good hits and order them by energy + List selectedHits = reco.selectHits(allHits,this.getConstantsManager(), run); + // create clusters + List clusters = reco.findClusters(selectedHits, this.getConstantsManager(), run); + // set cluster status + reco.selectClusters(clusters, this.getConstantsManager(), run); + // write output banks + reco.writeBanks(event, selectedHits, clusters, this.getConstantsManager(), run); + } + return true; + } + public int setRunConditionsParameters(DataEvent event) { int run = -1; if(event.hasBank("RUN::config")==false) { - System.out.println("RUN CONDITIONS NOT READ!"); + System.out.println("RUN CONDITIONS NOT READ!"); } - + if(event instanceof EvioDataEvent) { EvioDataBank bank = (EvioDataBank) event.getBank("RUN::config"); run = bank.getInt("Run",0); @@ -90,76 +76,7 @@ public int setRunConditionsParameters(DataEvent event) { DataBank bank = event.getBank("RUN::config"); run = bank.getInt("run",0); } - + return run; } - - - public static void main (String arg[]) { - MUCALEngine cal = new MUCALEngine(); - cal.init(); - // String input = "/Users/devita/Work/clas12/simulations/clas12Tags/4.4.0/out.hipo"; -// String input = "/home/filippi/clas/ForwardTracker/DATA/out_realGeo_noMagField.data"; -// String input = "/home/filippi/clas/gemc/electronGun/gemc.hipo"; - String input = "/home/filippi/clas12/fttrkDev/clas12-offline-software-6.5.13-fttrkDev/ft_005038.evio.01231.hipo"; - HipoDataSource reader = new HipoDataSource(); -// String input = "/Users/devita/Work/clas12/simulations/tests/detectors/clas12/ft/out_header.ev"; -// EvioSource reader = new EvioSource(); - reader.open(input); - - // initialize histos - H1F h1 = new H1F("Cluster Energy",100, 0.,5.); - h1.setOptStat(Integer.parseInt("1111")); h1.setTitleX("Cluster Energy (GeV)"); - H1F h2 = new H1F("Energy Resolution",100, -1, 1); - h2.setOptStat(Integer.parseInt("1111")); h2.setTitleX("Energy Resolution(GeV)"); - H1F h3 = new H1F("Theta Resolution",100, -2, 2); - h3.setOptStat(Integer.parseInt("1111")); h3.setTitleX("Theta Resolution(deg)"); - H1F h4 = new H1F("Phi Resolution",100, -10, 10); - h4.setOptStat(Integer.parseInt("1111")); h4.setTitleX("Phi Resolution(deg)"); -// H1F h5 = new H1F("Time Resolution",100, -10, 10); - H1F h5 = new H1F("Time Resolution",100, -100, 300); - h5.setOptStat(Integer.parseInt("1111")); h5.setTitleX("Time Resolution(ns)"); - H2F h6 = new H2F("cluster xy", 100, -15., 15., 100, -15., 15.); - h6.setTitleX("cluster x"); h6.setTitleY("cluster y"); - - while(reader.hasEvent()){ -// for(int nev=0; nev<2; nev++){ - DataEvent event = (DataEvent) reader.getNextEvent(); - cal.processDataEvent(event); - - if(event.hasBank("MUCAL::clusters")) { - DataBank bank = event.getBank("MUCAL::clusters"); - int nrows = bank.rows(); - for(int i=0; i=0) { - // get hits fron banks - List allHits = reco.initMUHD(event,this.getConstantsManager(), run); - // select good hits and order them by energy - List selectedHits = reco.selectHits(allHits); - // create clusters - List clusters = reco.findClusters(selectedHits); - // write output banks - reco.writeBanks(event, selectedHits, clusters); - } - return true; - } - + + @Override + public boolean processDataEventUser(DataEvent event) { + + // update calibration constants based on run number if changed + int run = setRunConditionsParameters(event); + + if(run>=0) { + // get hits fron banks + List allHits = reco.initMUHD(event,this.getConstantsManager(), run); + // select good hits and order them by energy + List selectedHits = reco.selectHits(allHits); + // create clusters + List clusters = reco.findClusters(selectedHits); + // write output banks + reco.writeBanks(event, selectedHits, clusters); + } + return true; + } + public int setRunConditionsParameters(DataEvent event) { int run = -1; if(event.hasBank("RUN::config")==false) { - System.out.println("RUN CONDITIONS NOT READ!"); - } - + System.out.println("RUN CONDITIONS NOT READ!"); + } + if(event instanceof EvioDataEvent) { EvioDataBank bank = (EvioDataBank) event.getBank("RUN::config"); run = bank.getInt("Run",0); @@ -80,61 +71,7 @@ public int setRunConditionsParameters(DataEvent event) { DataBank bank = event.getBank("RUN::config"); run = bank.getInt("run",0); } - return run; + return run; } - - public static void main (String arg[]) { - MUHDEngine cal = new MUHDEngine(); - cal.init(); -// String input = "/Users/devita/data/out_clasdispr.00.e11.000.emn0.75tmn.09.xs65.61nb.dis.1.V5.hipo"; -// HipoDataSource reader = new HipoDataSource(); - String input = "/Users/devita/test4.hipo"; - HipoDataSource reader = new HipoDataSource(); - reader.open(input); - - // initialize histos - H1F h1 = new H1F("Cluster Energy",100, 0.,5.); - h1.setOptStat(Integer.parseInt("1111")); h1.setTitleX("Cluster Energy (GeV)"); - H1F h2 = new H1F("Energy Resolution",100, -1, 1); - h2.setOptStat(Integer.parseInt("1111")); h2.setTitleX("Energy Resolution(GeV)"); - H1F h3 = new H1F("Theta Resolution",100, -2, 2); - h3.setOptStat(Integer.parseInt("1111")); h3.setTitleX("Theta Resolution(deg)"); - H1F h4 = new H1F("Phi Resolution",100, -10, 10); - h4.setOptStat(Integer.parseInt("1111")); h4.setTitleX("Phi Resolution(deg)"); - H1F h5 = new H1F("Time Resolution",100, -10, 10); - h5.setOptStat(Integer.parseInt("1111")); h5.setTitleX("Time Resolution(ns)"); - - while(reader.hasEvent()){ - DataEvent event = (DataEvent) reader.getNextEvent(); - cal.processDataEvent(event); - - //DetectorEvent detectorEvent = DetectorData.readDetectorEvent(event); - //PhysicsEvent gen = detectorEvent.getGeneratedEvent(); - if(event.hasBank("MUHD::clusters")) { - DataBank bank = event.getBank("MUHD::clusters"); - int nrows = bank.rows(); - for(int i=0; i - - org.jlab - groot - org.jlab.clas clas-reco diff --git a/reconstruction/raster/src/main/java/org/jlab/service/raster/RasterEngine.java b/reconstruction/raster/src/main/java/org/jlab/service/raster/RasterEngine.java index 7776206e03..df6539d0d0 100644 --- a/reconstruction/raster/src/main/java/org/jlab/service/raster/RasterEngine.java +++ b/reconstruction/raster/src/main/java/org/jlab/service/raster/RasterEngine.java @@ -3,13 +3,9 @@ import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; -import javax.swing.JFrame; import org.jlab.clas.reco.ReconstructionEngine; -import org.jlab.groot.data.H2F; -import org.jlab.groot.graphics.EmbeddedCanvas; import org.jlab.io.base.DataEvent; import org.jlab.io.base.DataBank; -import org.jlab.io.hipo.HipoDataSource; import org.jlab.utils.groups.IndexedTable; /* @@ -107,59 +103,4 @@ private double convertADC(IndexedTable adc2pos, int component, int ADC) { return pos; } - public static void main(String arg[]) { - - RasterEngine engine = new RasterEngine(); - engine.init(); - - // open hipo file - String input = "/vol0/pilleux-l/Bureau/dev_COATJAVA/rastersoftware/out_rastersoftware_eventsRndm9mm_updated_16.hipo"; - HipoDataSource reader = new HipoDataSource(); - reader.open(input); - - // initialize histos - H2F hx = new H2F("x","", 100, -1000, 1000, 100, -1, 1); - hx.setTitleX("ADC X"); - hx.setTitleY("x (cm)"); - H2F hy = new H2F("y","", 100, -1000, 1000, 100, -1, 1); - hy.setTitleX("ADC Y"); - hy.setTitleY("y (cm)"); - - // loop through events - while(reader.hasEvent()){ - DataEvent event = (DataEvent) reader.getNextEvent(); - - // for comparison - DataBank MC_Part = event.getBank("MC::Particle"); - System.out.print("MC position read : " + MC_Part.getFloat("vx",0) +"\n"); - - // run the raster engine - engine.processDataEventUser(event); - - // read the output bank and fill the histograms - if(event.hasBank("RASTER::position")) { - DataBank bank = event.getBank("RASTER::position"); - double xpos = bank.getFloat("x", 0); - double ypos = bank.getFloat("y", 0); - // fill histograms - System.out.print("Raster position : " + xpos + "\n"); - hx.fill(bank.getInt("ped",0), xpos); - hy.fill(bank.getInt("ped",1), ypos); - } - - } - - reader.close(); - - JFrame frame = new JFrame("Raster"); - frame.setSize(800,400); - EmbeddedCanvas canvas = new EmbeddedCanvas(); - canvas.divide(2,1); - canvas.cd(0); canvas.draw(hx); - canvas.cd(1); canvas.draw(hy); - frame.add(canvas); - frame.setLocationRelativeTo(null); - frame.setVisible(true); - - } } diff --git a/reconstruction/rtpc/src/main/java/org/jlab/service/rtpc/RTPCEngine.java b/reconstruction/rtpc/src/main/java/org/jlab/service/rtpc/RTPCEngine.java index 42a5316c93..33aea011f4 100644 --- a/reconstruction/rtpc/src/main/java/org/jlab/service/rtpc/RTPCEngine.java +++ b/reconstruction/rtpc/src/main/java/org/jlab/service/rtpc/RTPCEngine.java @@ -1,11 +1,9 @@ package org.jlab.service.rtpc; -import java.io.File; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.HashMap; -import org.jlab.clas.reco.EngineProcessor; import org.jlab.clas.reco.ReconstructionEngine; import org.jlab.clas.tracking.kalmanfilter.Units; @@ -171,69 +169,6 @@ public boolean processDataEventUser(DataEvent event) { return true; } - public static void main(String[] args){ - - System.setProperty("CLAS12DIR", "/Users/davidpayette/Desktop/newrtpcbranch/clas12-offline-software"); - double starttime = System.nanoTime(); - - File f = new File("/Users/davidpayette/Desktop/SignalStudies/sig.txt"); - f.delete(); - f = new File("/Users/davidpayette/Desktop/SignalStudies/trackenergy.txt"); - f.delete(); - f = new File("/Users/davidpayette/Desktop/SignalStudies/timespectra.txt"); - f.delete(); - f = new File("/Users/davidpayette/Desktop/SignalStudies/sigafter.txt"); - f.delete(); - f = new File("/Users/davidpayette/Desktop/SignalStudies/sigTF.txt"); - f.delete(); - f = new File("/Users/davidpayette/Desktop/SignalStudies/timeenergy.txt"); - f.delete(); - f = new File("/Users/davidpayette/Desktop/SignalStudies/signalbins.txt"); - f.delete(); - - - //String inputFile = "/Users/davidpayette/Desktop/6b.2.0/myClara/good.hipo"; - //String inputFile = "/Users/davidpayette/Desktop/6b.2.0/myClara/cosmics.hipo"; - //String inputFile = "/Users/davidpayette/Desktop/6b.2.0/myClara/ctest.hipo"; - //String inputFile = "/Users/davidpayette/Desktop/6b.2.0/myClara/new40p.hipo"; - //String inputFile = "/Users/davidpayette/Desktop/rtpcbranch/1ep.hipo"; - //String inputFile = "/Users/davidpayette/Desktop/6b.2.0/myClara/plugins/clas12/340_40p.hipo"; - String inputFile = "/Users/davidpayette/Desktop/newrtpcbranch/input.hipo"; - String outputFile = "/Users/davidpayette/Desktop/6b.2.0/myClara/out_cosmic.hipo"; - - System.err.println(" \n[PROCESSING FILE] : " + inputFile); - - RTPCEngine en = new RTPCEngine(); - en.init(); - - - EngineProcessor processor = new EngineProcessor(); - processor.addEngine("RTPC", en); - processor.processFile(inputFile, outputFile); - - /* - HipoDataSource reader = new HipoDataSource(); - HipoDataSync writer = reader.createWriter(); - - reader.open(inputFile); - writer.open(outputFile); - //System.out.println("starting " + starttime); - int eventcount = 0; - int eventselect = 144; //144 - while(reader.hasEvent()){ - DataEvent event = reader.getNextEvent(); - //if(eventcount == eventselect){ - en.processDataEventUser(event); - writer.writeEvent(event); - //}else if(eventcount > eventselect) break; - eventcount ++; - } - - writer.close(); - */ - System.out.println("finished " + (System.nanoTime() - starttime)*Math.pow(10,-9)); - } - private static HashMap generateMaterials() { Units units = Units.CM; diff --git a/reconstruction/tof/src/main/java/org/jlab/service/ctof/CTOFEngine.java b/reconstruction/tof/src/main/java/org/jlab/service/ctof/CTOFEngine.java index c079a59686..c803b05836 100644 --- a/reconstruction/tof/src/main/java/org/jlab/service/ctof/CTOFEngine.java +++ b/reconstruction/tof/src/main/java/org/jlab/service/ctof/CTOFEngine.java @@ -13,8 +13,6 @@ import org.jlab.geom.base.ConstantProvider; import org.jlab.io.base.DataBank; import org.jlab.io.base.DataEvent; -import org.jlab.io.hipo.HipoDataSource; -import org.jlab.io.hipo.HipoDataSync; import org.jlab.rec.ctof.Constants; import org.jlab.rec.tof.banks.ctof.HitReader; import org.jlab.rec.tof.banks.ctof.RecoBankWriter; @@ -184,43 +182,4 @@ public boolean processDataEventUser(DataEvent event) { return true; } - - public static void main(String[] args) { - - String inputFile = "/Users/ziegler/Desktop/Work/Files/GEMC/CTOF/pions1degphi80degtheta.hipo"; - String outputFile = "/Users/ziegler/Desktop/Work/Files/GEMC/CTOF/pions1degphi80degthetaRECWithNewCCDB.hipo"; - - // String inputFile = args[0]; - // String outputFile = args[1]; - - System.err.println(" \n[PROCESSING FILE] : " + inputFile); - - CTOFEngine en = new CTOFEngine(); - en.init(); - - HipoDataSource reader = new HipoDataSource(); - HipoDataSync writer = new HipoDataSync(); - writer.open(outputFile); - - int counter = 0; - reader.open(inputFile); - long t1 = System.currentTimeMillis(); - while (reader.hasEvent()) { - - counter++; - DataEvent event = reader.getNextEvent(); - - en.processDataEventUser(event); - writer.writeEvent(event); - if (counter > 3) { - break; - } - // if(counter%100==0) - System.out.println("run " + counter + " events"); - - } - double t = System.currentTimeMillis() - t1; - System.out.println("TOTAL PROCESSING TIME = " + t); - writer.close(); - } } diff --git a/reconstruction/tof/src/main/java/org/jlab/service/ftof/FTOFEngine.java b/reconstruction/tof/src/main/java/org/jlab/service/ftof/FTOFEngine.java index eb08d82226..504140449d 100644 --- a/reconstruction/tof/src/main/java/org/jlab/service/ftof/FTOFEngine.java +++ b/reconstruction/tof/src/main/java/org/jlab/service/ftof/FTOFEngine.java @@ -13,8 +13,6 @@ import org.jlab.geom.base.ConstantProvider; import org.jlab.io.base.DataBank; import org.jlab.io.base.DataEvent; -import org.jlab.io.hipo.HipoDataSource; -import org.jlab.io.hipo.HipoDataSync; import org.jlab.rec.ftof.Constants; import org.jlab.rec.tof.banks.ftof.HitReader; import org.jlab.rec.tof.banks.ftof.RecoBankWriter; @@ -213,55 +211,4 @@ public boolean processDataEventUser(DataEvent event) { return true; } - public static void main(String arg[]) { - FTOFHBEngine en = new FTOFHBEngine(); - en.init(); - - int counter = 0; - String inputFile = "/Users/ziegler/Desktop/Work/Files/GEMC/out_gemc_orig.hipo"; - - // String inputFile = args[0]; - // String outputFile = args[1]; - - System.err.println(" \n[PROCESSING FILE] : " + inputFile); - - HipoDataSource reader = new HipoDataSource(); - reader.open(inputFile); - - HipoDataSync writer = new HipoDataSync(); - // Writer - String outputFile = "/Users/ziegler/Desktop/Work/Files/GEMC/out_gemc_orig_rec.hipo"; - writer.open(outputFile); - - long t1 = 0; - while (reader.hasEvent() && counter<10) { - - counter++; - - DataEvent event = reader.getNextEvent(); - if (counter > 0) { - t1 = System.currentTimeMillis(); - } - - //en0.processDataEventUser(event); - // if (counter > 3062) - //en0.processDataEventUser(event); - //en1.processDataEventUser(event); - en.processDataEventUser(event); - System.out.println(" EVENT " + counter); - //if (counter > 3066) - // break; - // event.show(); - // if(counter%100==0) - //System.out.println("run " + counter + " events"); - //if (event.hasBank("HitBasedTrkg::HBTracks")) { - // - //} - writer.writeEvent(event); - } - writer.close(); - double t = System.currentTimeMillis() - t1; - System.out.println(t1 + " TOTAL PROCESSING TIME = " - + (t / (float) counter)); - } } diff --git a/reconstruction/tof/src/main/java/org/jlab/service/ftof/FTOFHBEngine.java b/reconstruction/tof/src/main/java/org/jlab/service/ftof/FTOFHBEngine.java index ae2b024fcb..2c76fc7758 100644 --- a/reconstruction/tof/src/main/java/org/jlab/service/ftof/FTOFHBEngine.java +++ b/reconstruction/tof/src/main/java/org/jlab/service/ftof/FTOFHBEngine.java @@ -1,8 +1,3 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ package org.jlab.service.ftof; /** diff --git a/reconstruction/urwt/src/main/java/org/jlab/service/urwt/URWTEngine.java b/reconstruction/urwt/src/main/java/org/jlab/service/urwt/URWTEngine.java index 4473edf913..681a605aeb 100644 --- a/reconstruction/urwt/src/main/java/org/jlab/service/urwt/URWTEngine.java +++ b/reconstruction/urwt/src/main/java/org/jlab/service/urwt/URWTEngine.java @@ -4,20 +4,13 @@ import java.util.Optional; import java.util.logging.Level; import java.util.logging.Logger; -import javax.swing.JFrame; import org.jlab.clas.reco.ReconstructionEngine; -import org.jlab.detector.base.DetectorType; -import org.jlab.detector.calib.utils.DatabaseConstantProvider; import org.jlab.detector.geant4.v2.MPGD.URWT.URWTStripFactory; -import org.jlab.geom.prim.Point3D; import org.jlab.groot.data.H1F; import org.jlab.groot.fitter.DataFitter; -import org.jlab.groot.graphics.EmbeddedCanvas; -import org.jlab.groot.group.DataGroup; import org.jlab.groot.math.F1D; import org.jlab.io.base.DataEvent; import org.jlab.io.base.DataBank; -import org.jlab.io.hipo.HipoDataSource; /** * @@ -155,94 +148,4 @@ public static void fitGauss(H1F histo) { } } - public static void main (String arg[]) { - - URWTEngine engine = new URWTEngine(); - engine.init(); - - String input = "/Users/devita/urwell3d.hipo"; - - DataGroup dg = new DataGroup(3, 2); - String[] axes = {"x", "y"}; - for(int il=0; il