From 79e047c34c1e7273e5adf40d3b789ac0219e98cd Mon Sep 17 00:00:00 2001 From: Nathan Baltzell Date: Mon, 14 Aug 2017 16:36:26 -0400 Subject: [PATCH 01/49] PhysicsConstants.java: more sigfigs on electron mass --- .../src/main/java/org/jlab/clas/pdg/PhysicsConstants.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common-tools/clas-physics/src/main/java/org/jlab/clas/pdg/PhysicsConstants.java b/common-tools/clas-physics/src/main/java/org/jlab/clas/pdg/PhysicsConstants.java index 256a992d26..e6f418ab23 100644 --- a/common-tools/clas-physics/src/main/java/org/jlab/clas/pdg/PhysicsConstants.java +++ b/common-tools/clas-physics/src/main/java/org/jlab/clas/pdg/PhysicsConstants.java @@ -25,7 +25,7 @@ public static double massNeutron(){ } public static double massElectron(){ - return 0.0005; + return 0.000511; } public static double massPionCharged(){ From 0eb78ae1dbb1e6be6765a15655c873e58b0d030e Mon Sep 17 00:00:00 2001 From: Nathan Baltzell Date: Mon, 14 Aug 2017 16:37:06 -0400 Subject: [PATCH 02/49] .gitignores: ignore compiled, ide, and editor stuffs --- .gitignore | 16 +++++++++++++++- validation/advanced-tests/.gitignore | 7 +++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 validation/advanced-tests/.gitignore diff --git a/.gitignore b/.gitignore index a41c2f4f8f..cfb6f6c404 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,8 @@ +# installed: +/coatjava +/myLocalMvnRepo +/reconstruction + *.class *lundfiles*.dat @@ -10,4 +15,13 @@ *.ear # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml -hs_err_pid* \ No newline at end of file +hs_err_pid* + +# editor tmp files: +*.swp +*~ + +# ide stuff: +*.iml +.idea + diff --git a/validation/advanced-tests/.gitignore b/validation/advanced-tests/.gitignore new file mode 100644 index 0000000000..3669828635 --- /dev/null +++ b/validation/advanced-tests/.gitignore @@ -0,0 +1,7 @@ +/clara_installation +/cook.clara +/files.list +/*.hipo +/*.evio +/*.evio.tar.gz + From 618fd14310a620eca4bf14ee594dab63508f6610 Mon Sep 17 00:00:00 2001 From: Nathan Baltzell Date: Mon, 14 Aug 2017 16:38:45 -0400 Subject: [PATCH 03/49] reconstruction/eb and clas-reco/detector: formatting, unused removals, use org.jlab.clas.pdg --- .../clas/detector/CalorimeterResponse.java | 17 +- .../jlab/clas/detector/CherenkovResponse.java | 74 ++--- .../org/jlab/clas/detector/DetectorData.java | 16 +- .../org/jlab/clas/detector/DetectorEvent.java | 13 - .../jlab/clas/detector/DetectorHeader.java | 5 - .../jlab/clas/detector/DetectorParticle.java | 182 +++++------ .../jlab/clas/detector/DetectorResponse.java | 18 +- .../org/jlab/clas/detector/DetectorTrack.java | 15 +- .../clas/detector/ScintillatorResponse.java | 9 - .../jlab/clas/detector/TaggerResponse.java | 28 +- .../java/org/jlab/service/eb/EBAnalyzer.java | 178 ++++------- .../java/org/jlab/service/eb/EBConstants.java | 8 +- .../java/org/jlab/service/eb/EBEngine.java | 32 +- .../java/org/jlab/service/eb/EBHBEngine.java | 5 - .../org/jlab/service/eb/EBRadioFrequency.java | 5 - .../java/org/jlab/service/eb/EBTBEngine.java | 5 - .../main/java/org/jlab/service/eb/EBio.java | 62 ++-- .../org/jlab/service/eb/EventBuilder.java | 287 ++++++++---------- 18 files changed, 362 insertions(+), 597 deletions(-) diff --git a/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/CalorimeterResponse.java b/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/CalorimeterResponse.java index 789864ae68..fc2ff87429 100644 --- a/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/CalorimeterResponse.java +++ b/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/CalorimeterResponse.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.clas.detector; import java.util.ArrayList; @@ -17,19 +12,17 @@ * @author jnewton */ public class CalorimeterResponse extends DetectorResponse { - - + public CalorimeterResponse(){ super(); } - + public CalorimeterResponse(int sector, int layer, int component){ this.getDescriptor().setSectorLayerComponent(sector, layer, component); } - - + public static List readHipoEvent(DataEvent event, - String bankName, DetectorType type){ + String bankName, DetectorType type){ List responseList = new ArrayList(); if(event.hasBank(bankName)==true){ DataBank bank = event.getBank(bankName); @@ -49,10 +42,8 @@ public static List readHipoEvent(DataEvent event, responseList.add(response); } } - return responseList; } - } diff --git a/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/CherenkovResponse.java b/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/CherenkovResponse.java index 8fccf39ac1..90c3de5c37 100644 --- a/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/CherenkovResponse.java +++ b/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/CherenkovResponse.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.clas.detector; import java.util.ArrayList; @@ -22,33 +17,32 @@ * @author gavalian */ public class CherenkovResponse { - - private double hitTime = 0.0; - private double hitTheta = 0.0; - private double hitPhi = 0.0; - private int hitNphe = 0; - private double hitDeltaPhi = 0.0; + + private double hitTime = 0.0; + private double hitTheta = 0.0; + private double hitPhi = 0.0; + private int hitNphe = 0; + private double hitDeltaPhi = 0.0; private double hitDeltaTheta = 0.0; - private int association = -1; - private int hitIndex = -1; - + private int hitIndex = -1; + private int association = -1; + private DetectorType cherenkovType = DetectorType.HTCC; private Point3D hitPosition = new Point3D(); - //private Sphere3D private DetectorDescriptor desc = new DetectorDescriptor(); - + public CherenkovResponse(double theta, double phi, double dtheta, double dphi){ hitTheta = theta; hitPhi = phi; hitDeltaTheta = dtheta; hitDeltaPhi = dphi; } - + public CherenkovResponse setTime(double time) { hitTime = time; return this;} public CherenkovResponse setEnergy(int energy) { hitNphe = energy; return this;} public void setAssociation(int assoc) {this.association = assoc;} public void setHitIndex(int index){this.hitIndex = index;} - + public double getTime(){ return hitTime;} public int getHitIndex(){return hitIndex;} public int getEnergy(){ return hitNphe;} @@ -57,15 +51,15 @@ public CherenkovResponse(double theta, double phi, double dtheta, double dphi){ public double getDeltaTheta(){ return this.hitDeltaTheta;} public double getDeltaPhi() {return this.hitDeltaPhi;} public int getAssociation() {return this.association;} - + public Point3D getHitPosition(){ return this.hitPosition; } - + public void setHitPosition(double x, double y, double z){ this.hitPosition.set(x, y, z); } - + public Point3D getIntersection(Line3D line){ Vector3D vec = new Vector3D(this.hitPosition.x(),this.hitPosition.y(),this.hitPosition.z()); vec.unit(); @@ -74,22 +68,22 @@ public Point3D getIntersection(Line3D line){ plane.intersection(line, intersect); return intersect; } - + public boolean match(Line3D particletrack){ Point3D intersection = this.getIntersection(particletrack); Vector3D vecRec = intersection.toVector3D(); Vector3D vecHit = this.hitPosition.toVector3D(); //System.out.println(particletrack); //System.out.println(this.hitPosition); -// System.out.println("Calculated Theta Difference (Degrees)" + Math.abs(vecHit.theta()-vecRec.theta())*57.2958); -// System.out.println("Expected Theta Difference (Degrees)" + this.hitDeltaTheta*57.2958); -// System.out.println(" "); -// System.out.println("Calculated Phi Difference (Degrees)" + Math.abs(vecHit.phi()-vecRec.phi())*57.2958); -// System.out.println("Expected Phi Difference (Degrees)" + this.hitDeltaPhi*57.2958); -// System.out.println(" "); - -//System.out.println(Math.abs(vecHit.theta()-vecRec.theta())*57.2958 + " " + -// Math.abs(vecHit.phi()-vecRec.phi())*57.2958); + //System.out.println("Calculated Theta Difference (Degrees)" + Math.abs(vecHit.theta()-vecRec.theta())*57.2958); + //System.out.println("Expected Theta Difference (Degrees)" + this.hitDeltaTheta*57.2958); + //System.out.println(" "); + //System.out.println("Calculated Phi Difference (Degrees)" + Math.abs(vecHit.phi()-vecRec.phi())*57.2958); + //System.out.println("Expected Phi Difference (Degrees)" + this.hitDeltaPhi*57.2958); + //System.out.println(" "); + + //System.out.println(Math.abs(vecHit.theta()-vecRec.theta())*57.2958 + " " + + //Math.abs(vecHit.phi()-vecRec.phi())*57.2958); return (Math.abs(vecHit.theta()-vecRec.theta())<10.0/57.2958 && Math.abs(vecHit.phi()-vecRec.phi()) readHipoEvent(DataEvent event, - String bankName, DetectorType type){ + String bankName, DetectorType type){ List responseList = new ArrayList(); if(event.hasBank(bankName)==true){ DataBank bank = event.getBank(bankName); @@ -124,14 +118,12 @@ public static List readHipoEvent(DataEvent event, double y = bank.getFloat("y",row); double z = bank.getFloat("z",row); double time = bank.getFloat("time",row); - CherenkovResponse che = new CherenkovResponse(theta,phi,dtheta,dphi); - che.setHitPosition(x, y, z); - //System.out.println(che.getHitPosition()); - //System.out.println("hello there is cherenkov"); - che.setHitIndex(row); - che.setEnergy(nphe); - che.setTime(time); - che.setCherenkovType(DetectorType.HTCC); + CherenkovResponse che = new CherenkovResponse(theta,phi,dtheta,dphi); + che.setHitPosition(x, y, z); + che.setHitIndex(row); + che.setEnergy(nphe); + che.setTime(time); + che.setCherenkovType(DetectorType.HTCC); responseList.add(che); } diff --git a/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorData.java b/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorData.java index 90724d112b..7ef0bc1310 100644 --- a/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorData.java +++ b/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorData.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.clas.detector; import java.util.ArrayList; @@ -200,7 +195,6 @@ public static DataBank getCalorimeterResponseBank(List respons DataBank bank = event.createBank(bank_name, responses.size()); for(int row = 0; row < responses.size(); row++){ DetectorResponse r = responses.get(row); - bank.setShort("index", row, (short) r.getHitIndex()); bank.setShort("pindex", row, (short) r.getAssociation()); bank.setByte("detector", row, (byte) r.getDescriptor().getType().getDetectorId()); @@ -458,23 +452,23 @@ public static List readTaggerTracks(DataEvent event, String bank if(event.hasBank(bank_name)==true){ DataBank bank = event.getBank(bank_name); int nrows = bank.rows(); - + for(int row = 0; row < nrows; row++){ int charge = bank.getInt("q", row); float cx = bank.getFloat("c_x", row); float cy = bank.getFloat("c_y" , row); float cz = bank.getFloat("c_z", row); float energy = bank.getFloat("energy", row); - + Vector3D pvec = new Vector3D(cx*energy,cy*energy,cz*energy); - + DetectorTrack track = new DetectorTrack(charge,pvec.mag()); track.setVertex(0.0, 0.0, 0.0); track.setVector(cx*energy, cy*energy, cz*energy); track.setTime(bank.getFloat("time", row)); track.setID(bank.getInt("id",row)); - - tracks.add(track); + + tracks.add(track); } } return tracks; diff --git a/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorEvent.java b/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorEvent.java index ef72660751..9714afdf7e 100644 --- a/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorEvent.java +++ b/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorEvent.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.clas.detector; import java.util.ArrayList; @@ -13,7 +8,6 @@ import org.jlab.io.base.DataEvent; - /** * * @author gavalian @@ -25,16 +19,10 @@ public class DetectorEvent { private PhysicsEvent reconstructedEvent = new PhysicsEvent(); private DetectorHeader eventHeader = new DetectorHeader(); -// private double RF_OFFSET = 0.0; -// private double RF_BUNCH = 2.004; -// private int RF_SHIFT = 800; - - public DetectorEvent(){ } - public static DetectorEvent readDetectorEvent(DataEvent event){ return DetectorData.readDetectorEvent(event); } @@ -62,7 +50,6 @@ public DetectorParticle matchedParticle(Particle p){ int index = -1; for(int i = 0; i < particleList.size();i++){ if(p.charge()==particleList.get(i).getCharge()){ - //System.out.println("index = " + i + " compare = " + particleList.get(i).compare(p.vector().vect())); if(particleList.get(i).compare(p.vector().vect())3){ - sf = 0.0004*p + 0.2738; - } - return sf; - } + + public double ParametrizedSF() { + double sf = 0.0; + double p = this.vector().mag(); + if (p <= 3) { + sf = -0.0035*pow(p,4) + 0.0271*pow(p,3) - 0.077*pow(p,2) + 0.0985*pow(p,1) + 0.2241; + } + else { + sf = 0.0004*p + 0.2738; + } + return sf; + } public double ParametrizedSigma(){ - double p = this.vector().mag(); - double sigma = 0.02468*pow(p,-0.51); - - return sigma; - + double p = this.vector().mag(); + double sigma = 0.02468*pow(p,-0.51); + return sigma; } - - public double getTheoryBeta(int id){ + + public double getTheoryBeta(int id){ double beta = 0.0; double p = detectorTrack.getVector().mag(); + //double mass = PDGDatabase.getParticleById(id); // map lookup if(id==11 || id==-11){ - beta = p/sqrt(p*p + 0.00051*0.00051); - //beta = 1.0; - //System.out.println("Beta is " + beta); + beta = p/sqrt(p*p + pow(PhysicsConstants.massElectron(),2));//0.00051*0.00051); } - if(id==-211 || id==211){ - beta = p/sqrt(p*p + 0.13957*0.13957); + else if(id==-211 || id==211){ + beta = p/sqrt(p*p + pow(PhysicsConstants.massPionCharged(),2));//0.13957*0.13957); } - if(id==2212 || id==-2212){ - beta = p/sqrt(p*p + 0.938*0.938); - //System.out.println("Beta is " + beta); + else if(id==2212 || id==-2212){ + beta = p/sqrt(p*p + pow(PhysicsConstants.massProton(),2));//0.938*0.938); } - if(id==-321 || id==321){ - beta = p/sqrt(p*p + 0.493667*0.493667); + else if(id==-321 || id==321){ + beta = p/sqrt(p*p + pow(PhysicsConstants.massKaonCharged(),2));//0.493667*0.493667); } return beta; } - - public int getNphe(DetectorType type){ - int nphe = 0; - for(CherenkovResponse c : this.cherenkovStore){ - if(c.getCherenkovType()==type){ - nphe = c.getEnergy(); - } - } - return nphe; - } - - public double getVertexTime(DetectorType type, int layer){ - double vertex_time = this.getTime(type,layer) - this.getPathLength(type, layer)/(this.getTheoryBeta(this.getPid())*29.9792); - return vertex_time; - } - + + public int getNphe(DetectorType type){ + int nphe = 0; + for(CherenkovResponse c : this.cherenkovStore){ + if(c.getCherenkovType()==type){ + nphe = c.getEnergy(); + } + } + return nphe; + } + + public double getVertexTime(DetectorType type, int layer){ + double vertex_time = this.getTime(type,layer) - this.getPathLength(type, layer)/(this.getTheoryBeta(this.getPid())*29.9792); + return vertex_time; + } + public double getVertexTime(DetectorType type, int layer, int pid){ - double vertex_time = this.getTime(type,layer) - this.getPathLength(type, layer)/(this.getTheoryBeta(pid)*29.9792); - return vertex_time; - } - - public int getCherenkovSignal(List cherenkovs, DetectorType type){ - - int bestIndex = -1; - if(cherenkovs.size()>0){ - // System.out.println("There are here???"); - for(int loop = 0; loop < cherenkovs.size(); loop++) { - if(cherenkovs.get(loop).getCherenkovType()==type){ - boolean matchtruth = cherenkovs.get(loop).match(this.detectorTrack.getFirstCross()); - //System.out.println(matchtruth); - if(matchtruth==true){ - bestIndex = loop; - } - } - } - } - return bestIndex; - } - - public double getTime(DetectorType type, int layer) { - DetectorResponse response = this.getHit(type,layer); - if(response==null) return -1.0; + double vertex_time = this.getTime(type,layer) - this.getPathLength(type, layer)/(this.getTheoryBeta(pid)*29.9792); + return vertex_time; + } + + public int getCherenkovSignal(List cherenkovs, DetectorType type){ + + int bestIndex = -1; + if(cherenkovs.size()>0){ + for(int loop = 0; loop < cherenkovs.size(); loop++) { + if(cherenkovs.get(loop).getCherenkovType()==type){ + boolean matchtruth = cherenkovs.get(loop).match(this.detectorTrack.getFirstCross()); + if(matchtruth==true){ + bestIndex = loop; + } + } + } + } + return bestIndex; + } + + public double getTime(DetectorType type, int layer) { + DetectorResponse response = this.getHit(type,layer); + if(response==null) return -1.0; return response.getTime(); } - + public double getPathLength(DetectorType type, int layer){ DetectorResponse response = this.getHit(type,layer); if(response==null) return -1.0; @@ -819,7 +793,7 @@ public int getSoftwareTriggerScore() { public int compareTo(Object o) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + throw new UnsupportedOperationException("Not supported yet."); } } diff --git a/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorResponse.java b/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorResponse.java index 4943c3d6b0..7f897e05ea 100644 --- a/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorResponse.java +++ b/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorResponse.java @@ -1,11 +1,5 @@ -/* - * 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.detector; - import java.util.ArrayList; import java.util.List; import org.jlab.clas.physics.Vector3; @@ -25,21 +19,19 @@ public class DetectorResponse { private DetectorDescriptor descriptor = new DetectorDescriptor(); - private Vector3D hitPosition = new Vector3D(); - //private Point3D hitPosition = new Vector3(); - private Vector3D hitPositionMatched = new Vector3D(); + private Vector3D hitPosition = new Vector3D(); + //private Point3D hitPosition = new Vector3(); + private Vector3D hitPositionMatched = new Vector3D(); private Double detectorTime = 0.0; private Double detectorEnergy = 0.0; private Double particlePath = 0.0; private int association = -1; - private int hitIndex = -1; + private int hitIndex = -1; public DetectorResponse(){ super(); } - - public DetectorResponse(int sector, int layer, int component){ descriptor.setSectorLayerComponent(sector, layer, component); } @@ -127,8 +119,6 @@ public static List readHipoEvent(DataEvent event, } return responseList; } - - /** * Reads a HIPO event, constructs list of detector responses then returns only diff --git a/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorTrack.java b/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorTrack.java index 11de4640e3..815c8d51cc 100644 --- a/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorTrack.java +++ b/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorTrack.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.clas.detector; import java.util.ArrayList; @@ -19,12 +14,12 @@ public class DetectorTrack { private int trackCharge = 0; - private double trackMom = 0.0; - private double trackPath = 0.0; - private double taggerTime = 0.0; - private int taggerID = 0; - private Vector3D trackEnd = new Vector3D(); + private double trackMom = 0.0; + private double trackPath = 0.0; + private double taggerTime = 0.0; + private int taggerID = 0; + private Vector3D trackEnd = new Vector3D(); private Vector3 trackP = new Vector3(); private Vector3 trackVertex = new Vector3(); // private Point3D trackIntersect = new Point3D(); diff --git a/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/ScintillatorResponse.java b/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/ScintillatorResponse.java index 35dd1d8649..5c700a1bb3 100644 --- a/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/ScintillatorResponse.java +++ b/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/ScintillatorResponse.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.clas.detector; import java.util.ArrayList; @@ -18,7 +13,6 @@ */ public class ScintillatorResponse extends DetectorResponse { - public ScintillatorResponse(){ super(); } @@ -27,7 +21,6 @@ public ScintillatorResponse(int sector, int layer, int component){ this.getDescriptor().setSectorLayerComponent(sector, layer, component); } - public static List readHipoEvent(DataEvent event, String bankName, DetectorType type){ List responseList = new ArrayList(); @@ -50,9 +43,7 @@ public static List readHipoEvent(DataEvent event, responseList.add(response); } } - return responseList; } - } diff --git a/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/TaggerResponse.java b/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/TaggerResponse.java index 001d9c53cb..c6c297b7e0 100644 --- a/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/TaggerResponse.java +++ b/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/TaggerResponse.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.clas.detector; import java.util.ArrayList; @@ -23,11 +18,11 @@ */ public class TaggerResponse { - private double hitTime = 0.0; + private double hitTime = 0.0; private int hitID = -1; - private int hitCharge = -1; - private double hitEnergy = 0.0; - private int association = -1; + private int hitCharge = -1; + private double hitEnergy = 0.0; + private int association = -1; private Vector3D hitMomentum = new Vector3D(); @@ -51,8 +46,6 @@ public void setMomentum(double px, double py, double pz){ this.hitMomentum.setXYZ(px, py, pz); } - - public static List readHipoEvent(DataEvent event, String bankName){ List responseList = new ArrayList(); @@ -67,13 +60,12 @@ public static List readHipoEvent(DataEvent event, float cz = bank.getFloat("cz",row); float time = bank.getFloat("time",row); float energy = bank.getFloat("energy",row); - TaggerResponse ft = new TaggerResponse(); - ft.setCharge(charge); - ft.setID(id); - ft.setEnergy(energy); - ft.setTime(time); - ft.setMomentum(cx*energy, cy*energy, cz*energy); - //System.out.println("FT Energy " + energy); + TaggerResponse ft = new TaggerResponse(); + ft.setCharge(charge); + ft.setID(id); + ft.setEnergy(energy); + ft.setTime(time); + ft.setMomentum(cx*energy, cy*energy, cz*energy); responseList.add(ft); } } diff --git a/reconstruction/eb/src/main/java/org/jlab/service/eb/EBAnalyzer.java b/reconstruction/eb/src/main/java/org/jlab/service/eb/EBAnalyzer.java index 51f5156770..0f3550fae5 100644 --- a/reconstruction/eb/src/main/java/org/jlab/service/eb/EBAnalyzer.java +++ b/reconstruction/eb/src/main/java/org/jlab/service/eb/EBAnalyzer.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.eb; import static java.lang.Math.abs; @@ -12,120 +7,93 @@ import org.jlab.clas.detector.DetectorParticle; import org.jlab.detector.base.DetectorType; +import org.jlab.clas.pdg.PhysicsConstants; /** * * @author gavalian */ public class EBAnalyzer { - - private int[] pidPositive = new int[]{ -11, 211, 321, 2212}; + + private int[] pidPositive = new int[]{-11, 211, 321, 2212}; private int[] pidNegative = new int[]{ 11, -211,-321,-2212}; - + public EBAnalyzer(){ - + } - + public void processEvent(DetectorEvent event) { if(event.getParticles().size()>0){ DetectorParticle trigger = event.getParticle(0); - - //System.out.println(" trigger pid = " + trigger.getPid()); + if(trigger.getPid()==11 || trigger.getPid()==-11){ trigger.setBeta(1.0); - trigger.setMass(0.0005); - + trigger.setMass(PhysicsConstants.massElectron()); + double time = 0.0; double path = 0.0; - + if(trigger.hasHit(DetectorType.FTOF, 1)==true){ - //System.out.println("There is a FTOF1A hit!!!"); time = trigger.getTime(DetectorType.FTOF, 1); path = trigger.getPathLength(DetectorType.FTOF, 1); } - + if(trigger.hasHit(DetectorType.FTOF, 2)==true){ - //System.out.println("There is a FTOF1B hit!!!"); time = trigger.getTime(DetectorType.FTOF, 2); path = trigger.getPathLength(DetectorType.FTOF, 2); } double tof = path/EBConstants.SPEED_OF_LIGHT; double start_time = time - tof; - double deltatr = - start_time + event.getEventHeader().getRfTime() /* - (trigger.vertex().z() - - (EBConstants.TARGET_POSITION))/(EBConstants.SPEED_OF_LIGHT)*/ - + (EBConstants.RF_LARGE_INTEGER+0.5)*EBConstants.RF_BUCKET_LENGTH + EBConstants.RF_OFFSET; + double deltatr = - start_time + event.getEventHeader().getRfTime() + + (EBConstants.RF_LARGE_INTEGER+0.5)*EBConstants.RF_BUCKET_LENGTH + EBConstants.RF_OFFSET; + //double deltatr = - start_time + event.getEventHeader().getRfTime() /* - (trigger.vertex().z() + // - (EBConstants.TARGET_POSITION))/(EBConstants.SPEED_OF_LIGHT)*/ + // + (EBConstants.RF_LARGE_INTEGER+0.5)*EBConstants.RF_BUCKET_LENGTH + EBConstants.RF_OFFSET; double rfcorr = deltatr%EBConstants.RF_BUCKET_LENGTH - EBConstants.RF_BUCKET_LENGTH/2;//RF correction term event.getEventHeader().setStartTime(start_time + rfcorr); - //System.out.println(event.getEventHeader().getRfTime() - start_time); - //System.out.println(rfcorr + " " + (124.25- time + tof)); - //System.out.println(" TIME = " + tof + " time from TOF = " + time); - //System.out.println(" PATH = " + path + " " ); - //System.out.println(" SET START TIME = " + start_time + " ACTUAL TIME = " + event.getEventHeader().getStartTime()); - - //System.out.println(start_time - event.getEventHeader().getRfTime()); - + this.assignMasses(event); this.assignPids(event); - - } - + if(trigger.getPid()==0 || trigger.getPid()==22) { - - event.getEventHeader().setStartTime(124.25); + event.getEventHeader().setStartTime(EBConstants.GEMC_STARTTIME); this.assignMasses(event); this.assignPids(event); - } - + } } - - + + public void assignMasses(DetectorEvent event){ - + int np = event.getParticles().size(); - //System.out.println("======================= ANALYSIS"); for(int i = 1; i < np; i++) { DetectorParticle p = event.getParticle(i); double start_time = event.getEventHeader().getStartTime(); double beta = 0.0; double mass = 0.0; - + if(p.hasHit(DetectorType.FTOF, 1)==true){ - //System.out.println("1A"); beta = p.getBeta(DetectorType.FTOF,1, start_time); mass = p.getMass2(DetectorType.FTOF,1, start_time); p.setBeta(beta); - - //System.out.println(String.format("PARTICLE %3d (Layer 1) p = %8.3f beta = %8.3f mass2 = %8.3f", - // i,p.vector().mag(),beta,mass)); } if(p.hasHit(DetectorType.FTOF, 2)==true){ - //System.out.println("1B"); beta = p.getBeta(DetectorType.FTOF, 2,start_time); mass = p.getMass2(DetectorType.FTOF, 2,start_time); p.setBeta(beta); - //System.out.println(String.format("PARTICLE %3d (Layer 2) p = %8.3f beta = %8.3f mass2 = %8.3f", - // i,p.vector().mag(),beta,mass)); } if(p.hasHit(DetectorType.CTOF, 0)==true){ -// //System.out.println("CTOF"); beta = p.getBeta(DetectorType.CTOF ,start_time); mass = p.getMass2(DetectorType.CTOF,start_time); p.setBeta(beta); -// //System.out.println(String.format("PARTICLE %3d (Layer 2) p = %8.3f beta = %8.3f mass2 = %8.3f", -// // i,p.vector().mag(),beta,mass)); } - //System.out.println("----------------"); - - - - //p.getBeta(DetectorType.BST, start_time) } } - + public void assignPids(DetectorEvent event) { int np = event.getParticles().size(); PIDHypothesis pidHyp = new PIDHypothesis(); @@ -134,12 +102,10 @@ public void assignPids(DetectorEvent event) { if(p.getCharge()==0) break; if(p.getCharge()>0){ for(int b = 0; b < this.pidPositive.length; b++){ - //System.out.println(this.pidPositive[b]); pidHyp.setEvent(event); pidHyp.PIDMatch(p, this.pidPositive[b]); //pidHyp.PIDQuality(p,this.pidPositive[b],event); } - //p.setPid(pidHyp.get(0).getPid()); } else { for(int b = 0; b < this.pidNegative.length; b++){ @@ -148,51 +114,44 @@ public void assignPids(DetectorEvent event) { //pidHyp.PIDQuality(p, this.pidNegative[b],event); } //Collections.sort(pidHyp); - // System.out.println(pidHyp.get(0).getPid()); //p.setPid(pidHyp.get(0).getPid()); } - //System.out.println(" "); } } - -public class PIDHypothesis { - + + public class PIDHypothesis { + private int theoryPID = -1; private double PIDquality = 0.0; private DetectorEvent event; - - - + public PIDHypothesis() { - - } - + + } + public void setEvent(DetectorEvent e) {event = e;} - + public void PIDMatch(DetectorParticle p, int pid) { - + double beta = p.getTheoryBeta(pid); double vertex_index = optimalVertexTime(p); - + int pidCandidate = pid; boolean vertexCheck = (abs(pid)==211 && vertex_index==1 && p.getBeta()>0.0) || - (abs(pid)==2212 && vertex_index==0 && p.getBeta()>0.0) || - (abs(pid)==321 && vertex_index==2 && p.getBeta()>0.0); + (abs(pid)==2212 && vertex_index==0 && p.getBeta()>0.0) || + (abs(pid)==321 && vertex_index==2 && p.getBeta()>0.0); boolean sfCheck = p.getEnergyFraction(DetectorType.EC)>EBConstants.ECAL_SAMPLINGFRACTION_CUT; boolean htccSignalCheck = p.getNphe(DetectorType.HTCC)>EBConstants.HTCC_NPHE_CUT; boolean ltccSignalCheck = p.getNphe(DetectorType.LTCC)>EBConstants.LTCC_NPHE_CUT; boolean htccPionThreshold = p.vector().mag()>EBConstants.HTCC_PION_THRESHOLD; boolean ltccPionThreshold = p.vector().mag()EBConstants.LTCC_LOWER_PION_THRESHOLD; - -// System.out.println(sfCheck + " " + htccSignalCheck); - + && p.vector().mag()>EBConstants.LTCC_LOWER_PION_THRESHOLD; + switch(abs(pid)) { case 11: if(htccSignalCheck==true && sfCheck==true){ - //System.out.println("Positron detected"); this.finalizePID(p, pid); break; } @@ -205,22 +164,22 @@ public void PIDMatch(DetectorParticle p, int pid) { && htccPionThreshold==true) { this.finalizePID(p, pid); break; - } + } if(vertexCheck==false && htccSignalCheck==true && sfCheck==false && htccPionThreshold==true) { this.finalizePID(p, pid); break; - } + } if(vertexCheck==true && ltccSignalCheck==true && sfCheck==false && ltccPionThreshold==true) { this.finalizePID(p, pid); break; - } + } if(vertexCheck==false && ltccSignalCheck==true && sfCheck==false && ltccPionThreshold==true) { this.finalizePID(p, pid); break; - } + } case 321: if(vertexCheck==true && sfCheck==false && htccSignalCheck==false){ this.finalizePID(p, pid); @@ -234,39 +193,39 @@ public void PIDMatch(DetectorParticle p, int pid) { } } - + public int optimalVertexTime(DetectorParticle p) { int vertex_index = 0; HashMap vertexDiffs = new HashMap(); double vertex_time_hypothesis = 0.0; double event_start_time = event.getEventHeader().getStartTime(); - + if(p.hasHit(DetectorType.FTOF,1)==true) { - vertexDiffs.put(0,abs(p.getVertexTime(DetectorType.FTOF, 1, 2212)-event_start_time)); - vertexDiffs.put(1,abs(p.getVertexTime(DetectorType.FTOF, 1, 211)-event_start_time)); - vertexDiffs.put(2,abs(p.getVertexTime(DetectorType.FTOF, 1, 321)-event_start_time)); + vertexDiffs.put(0,abs(p.getVertexTime(DetectorType.FTOF, 1, 2212)-event_start_time)); + vertexDiffs.put(1,abs(p.getVertexTime(DetectorType.FTOF, 1, 211)-event_start_time)); + vertexDiffs.put(2,abs(p.getVertexTime(DetectorType.FTOF, 1, 321)-event_start_time)); } - + if(p.hasHit(DetectorType.FTOF,2)==true) { - vertexDiffs.put(0,abs(p.getVertexTime(DetectorType.FTOF, 2, 2212)-event_start_time)); - vertexDiffs.put(1,abs(p.getVertexTime(DetectorType.FTOF, 2, 211)-event_start_time)); - vertexDiffs.put(2,abs(p.getVertexTime(DetectorType.FTOF, 2, 321)-event_start_time)); + vertexDiffs.put(0,abs(p.getVertexTime(DetectorType.FTOF, 2, 2212)-event_start_time)); + vertexDiffs.put(1,abs(p.getVertexTime(DetectorType.FTOF, 2, 211)-event_start_time)); + vertexDiffs.put(2,abs(p.getVertexTime(DetectorType.FTOF, 2, 321)-event_start_time)); } - + if(vertexDiffs.size()>0) { - double min = vertexDiffs.get(0); + double min = vertexDiffs.get(0); - for (int i = 0; i <= 2; i++) { - if (vertexDiffs.get(i) < min) { - min = vertexDiffs.get(i); - vertex_index = i; + for (int i = 0; i <= 2; i++) { + if (vertexDiffs.get(i) < min) { + min = vertexDiffs.get(i); + vertex_index = i; + } } } - } return vertex_index; } - - + + public double PIDQuality(DetectorParticle p, int pid, DetectorEvent event) { double delta_t = abs(p.getVertexTime(DetectorType.FTOF, 2, pid)-event.getEventHeader().getStartTime()); double sigma = 0.08; @@ -274,21 +233,16 @@ public double PIDQuality(DetectorParticle p, int pid, DetectorEvent event) { return q; } - + public void finalizePID(DetectorParticle p, int pid) { - p.setPid(pid); - theoryPID = pid; - PIDquality = this.PIDQuality(p, pid, event); - p.setPidQuality(PIDquality); + p.setPid(pid); + theoryPID = pid; + PIDquality = this.PIDQuality(p, pid, event); + p.setPidQuality(PIDquality); } - - - - } - } diff --git a/reconstruction/eb/src/main/java/org/jlab/service/eb/EBConstants.java b/reconstruction/eb/src/main/java/org/jlab/service/eb/EBConstants.java index 5de758c899..6e98de8737 100644 --- a/reconstruction/eb/src/main/java/org/jlab/service/eb/EBConstants.java +++ b/reconstruction/eb/src/main/java/org/jlab/service/eb/EBConstants.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.eb; import org.jlab.geom.prim.Vector3D; @@ -56,7 +51,8 @@ public class EBConstants { public static final double LTCC_UPPER_PION_THRESHOLD = 5.0; public static final int TRIGGER_ID = 11; - + + public static final double GEMC_STARTTIME = 124.25; } diff --git a/reconstruction/eb/src/main/java/org/jlab/service/eb/EBEngine.java b/reconstruction/eb/src/main/java/org/jlab/service/eb/EBEngine.java index bd77c85468..abe1e95ad9 100644 --- a/reconstruction/eb/src/main/java/org/jlab/service/eb/EBEngine.java +++ b/reconstruction/eb/src/main/java/org/jlab/service/eb/EBEngine.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.eb; @@ -63,47 +58,26 @@ public boolean processDataEvent(DataEvent de) { eb.addCherenkovResponses(responseHTCC); eb.addCherenkovResponses(responseLTCC); - - - // Add tracks List tracks = DetectorData.readDetectorTracks(de, trackType); eb.addTracks(tracks); List ctracks = DetectorData.readCentralDetectorTracks(de, "CVTRec::Tracks"); eb.addTracks(ctracks); - - + // Process tracks: eb.processHitMatching(); eb.addTaggerTracks(trackFT); - eb.processNeutralTracks(); + eb.processNeutralTracks(); + eb.assignTrigger(); EBRadioFrequency rf = new EBRadioFrequency(); eb.getEvent().getEventHeader().setRfTime(rf.getTime(de)+EBConstants.RF_OFFSET); - //eb.getEvent().setRfTime(rf); - - //System.out.println(eb.getEvent().toString()); - - -// for(int i = 0; i < eb.getEvent().getParticles().size(); i++) { -// System.out.println("Particle " + i); -// for(int j = 0 ; j < eb.getEvent().getParticles().get(i).getDetectorResponses().size() ; j++){ -// System.out.println("Point " + eb.getEvent().getParticles().get(i).getDetectorResponses().get(j).getMatchedDistance()); -// } -// } - EBAnalyzer analyzer = new EBAnalyzer(); - //System.out.println("analyzing"); analyzer.processEvent(eb.getEvent()); - - //System.out.println(eb.getEvent().toString()); - - - if(eb.getEvent().getParticles().size()>0){ DataBank bankP = DetectorData.getDetectorParticleBank(eb.getEvent().getParticles(), de, particleBank); de.appendBanks(bankP); diff --git a/reconstruction/eb/src/main/java/org/jlab/service/eb/EBHBEngine.java b/reconstruction/eb/src/main/java/org/jlab/service/eb/EBHBEngine.java index fccf3d7cb3..b0f41240e4 100644 --- a/reconstruction/eb/src/main/java/org/jlab/service/eb/EBHBEngine.java +++ b/reconstruction/eb/src/main/java/org/jlab/service/eb/EBHBEngine.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.eb; diff --git a/reconstruction/eb/src/main/java/org/jlab/service/eb/EBRadioFrequency.java b/reconstruction/eb/src/main/java/org/jlab/service/eb/EBRadioFrequency.java index 62cd9a8c98..e629333094 100644 --- a/reconstruction/eb/src/main/java/org/jlab/service/eb/EBRadioFrequency.java +++ b/reconstruction/eb/src/main/java/org/jlab/service/eb/EBRadioFrequency.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.eb; import java.util.ArrayList; diff --git a/reconstruction/eb/src/main/java/org/jlab/service/eb/EBTBEngine.java b/reconstruction/eb/src/main/java/org/jlab/service/eb/EBTBEngine.java index 9d6847f553..a095266bf8 100644 --- a/reconstruction/eb/src/main/java/org/jlab/service/eb/EBTBEngine.java +++ b/reconstruction/eb/src/main/java/org/jlab/service/eb/EBTBEngine.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.eb; diff --git a/reconstruction/eb/src/main/java/org/jlab/service/eb/EBio.java b/reconstruction/eb/src/main/java/org/jlab/service/eb/EBio.java index 59a65112e3..b4796ec7a6 100644 --- a/reconstruction/eb/src/main/java/org/jlab/service/eb/EBio.java +++ b/reconstruction/eb/src/main/java/org/jlab/service/eb/EBio.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.eb; import java.util.ArrayList; @@ -89,7 +84,7 @@ public static List readTracks(DataEvent event, int type){ bank.getDouble("c1_uy", i), bank.getDouble("c1_uz", i) ); - // System.out.println(p.getLowerCross()); + // System.out.println(p.getLowerCross()); p.setPath(bank.getDouble("pathlength", i)); p.setCharge(bank.getInt("q", i)); dpList.add(p); @@ -132,8 +127,6 @@ public static List readCentralTracks(DataEvent event){ public static boolean isTimeBased(DataEvent de){ boolean tb = false; - //System.out.println(" HAS BANK = " + de.hasBank("TimeBasedTrkg::TBHits") - //+ " HB = " + de.hasBank("HitBasedTrkg::HBTracks")); if(de.hasBank("TimeBasedTrkg::TBHits")==true){ //de.show(); return true; @@ -223,42 +216,35 @@ public static DataBank writeResponses(List responses, int type } return bank; } - + public static DataBank writeCherenkovResponses(List responses, int type ) { - String bankName = "EVENTHB::particle"; - + String bankName = "EVENTHB::particle"; + switch (type){ case 1 : bankName = "EVENTHB::cherenkov"; break; case 2 : bankName = "EVENTTB::cherenkov"; break; default: break; } EvioDataBank bank = EvioFactory.createBank(bankName, responses.size()); - for(int i = 0; i < responses.size();i++){ + for(int i = 0; i < responses.size();i++){ bank.setInt("pindex", i,responses.get(i).getAssociation()); bank.setInt("index", i,i); - bank.setFloat("X", i, (float) responses.get(i).getHitPosition().x()); bank.setFloat("Y", i, (float) responses.get(i).getHitPosition().y()); bank.setFloat("Z", i, (float) responses.get(i).getHitPosition().z()); - - bank.setFloat("time", i, (float) responses.get(i).getTime()); bank.setFloat("nphe", i, (float) responses.get(i).getEnergy()); - } return bank; } - - public static DataBank writeTrigger(DetectorEvent event){ - String bankName = "Trigger::info"; - + public static DataBank writeTrigger(DetectorEvent event){ + String bankName = "Trigger::info"; EvioDataBank bank = EvioFactory.createBank(bankName, 1); //bank.setDouble("starttime", 0, event.getEventTrigger().getStartTime()); //bank.setDouble("vertextime",0, event.getEventTrigger().getVertexTime()); //bank.setDouble("rftime", 0, event.getEventTrigger().getRFTime()); //bank.setInt("id",0,event.getEventTrigger().getTriggerID()); - return bank; } @@ -267,7 +253,6 @@ public static List readECAL(DataEvent event){ if(event.hasBank("ECDetector::clusters")==true){ EvioDataBank bank = (EvioDataBank) event.getBank("ECDetector::clusters"); int nrows = bank.rows(); - //System.out.println("*************************\n\n\n\n ECAL " + nrows); for(int i = 0; i < nrows; i++){ int sector = bank.getInt("sector", i); int layer = bank.getInt("layer", i); @@ -275,16 +260,13 @@ public static List readECAL(DataEvent event){ resp.getDescriptor().setType(DetectorType.EC); resp.getDescriptor().setSectorLayerComponent(sector, layer, 0); resp.setPosition( - bank.getDouble("X", i),bank.getDouble("Y", i), - bank.getDouble("Z", i) - ); - resp.setTime(bank.getDouble("time", i)); - resp.setEnergy(bank.getDouble("energy", i)); - - ecal.add(resp); + bank.getDouble("X", i),bank.getDouble("Y", i), + bank.getDouble("Z", i) + ); + resp.setTime(bank.getDouble("time", i)); + resp.setEnergy(bank.getDouble("energy", i)); + ecal.add(resp); } - } else { - //System.out.println("\n\n\n\n NO ECAL"); } return ecal; } @@ -308,7 +290,6 @@ public static List readFTOF(DataEvent event){ ); resp.setTime(bank.getFloat("time", i)); resp.setEnergy(bank.getFloat("energy", i)); - ftof.add(resp); } } @@ -331,17 +312,14 @@ public static List readHTCC(DataEvent event) { double x = bank.getDouble("x",i); double y = bank.getDouble("y",i); double z = bank.getDouble("z",i); - // System.out.println(bank.getFloat("x")); double time = bank.getFloat("time",i); - // System.out.println("nphe" + nphe); - CherenkovResponse che = new CherenkovResponse(theta,phi,dtheta,dphi); - che.setHitPosition(x, y, z); - che.setEnergy(nphe); - che.setTime(time); - che.setCherenkovType(DetectorType.HTCC); - // System.out.println(che.getHitPosition()); - htcc.add(che); - + CherenkovResponse che = new CherenkovResponse(theta,phi,dtheta,dphi); + che.setHitPosition(x, y, z); + che.setEnergy(nphe); + che.setTime(time); + che.setCherenkovType(DetectorType.HTCC); + htcc.add(che); + } } return htcc; diff --git a/reconstruction/eb/src/main/java/org/jlab/service/eb/EventBuilder.java b/reconstruction/eb/src/main/java/org/jlab/service/eb/EventBuilder.java index b53df668ee..65442f75e3 100644 --- a/reconstruction/eb/src/main/java/org/jlab/service/eb/EventBuilder.java +++ b/reconstruction/eb/src/main/java/org/jlab/service/eb/EventBuilder.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.eb; import static java.lang.Math.abs; @@ -25,17 +20,17 @@ * @author gavalian */ public class EventBuilder { - + private DetectorEvent detectorEvent = new DetectorEvent(); private List detectorResponses = new ArrayList(); private List cherenkovResponses = new ArrayList(); private List taggerResponses = new ArrayList(); private int[] TriggerList = new int[]{11,-11,0}; - + public EventBuilder(){ - + } - + public void initEvent() { detectorEvent.clear(); } @@ -47,7 +42,7 @@ public void initEvent(DetectorHeader head) { public void addDetectorResponses(List responses){ detectorResponses.addAll(responses); } - + public void addCherenkovResponses(List responses){ cherenkovResponses.addAll(responses); } @@ -61,9 +56,6 @@ public void addTaggerResponses(List responses){ * and added to the detector event. * @param tracks */ - //public void addTracks(List tracks){ - - public void addTracks(List tracks) { //for(DetectorTrack track : tracks){ for(int i = 0 ; i < tracks.size(); i++){ @@ -104,9 +96,7 @@ public void processHitMatching(){ //List responseFTOF1A = DetectorResponse.getListByLayer(detectorResponses, DetectorType.FTOF, 1); //List responseFTOF1B = DetectorResponse.getListByLayer(detectorResponses, DetectorType.FTOF, 2); - //System.out.println("Detector response store size = " + this.detectorResponses.size()); int np = detectorEvent.getParticles().size(); - //System.out.println("Number of Particles = " + np); for(int n = 0; n < np; n++){ DetectorParticle p = this.detectorEvent.getParticle(n); @@ -116,10 +106,7 @@ public void processHitMatching(){ * set with a particle needed. */ - - int index = p.getDetectorHit(this.detectorResponses, DetectorType.FTOF, 1, EBConstants.FTOF_MATCHING_1A); - //System.out.println("index FTOF-1A = " + index); if(index>=0){ p.addResponse(detectorResponses.get(index), true); detectorResponses.get(index).setAssociation(n); @@ -128,7 +115,6 @@ public void processHitMatching(){ * Matching tracks to FTOF layer 1B detector. Added to the particle and association is */ index = p.getDetectorHit(this.detectorResponses, DetectorType.FTOF, 2, EBConstants.FTOF_MATCHING_1B); - //System.out.println("index FTOF-1B = " + index); if(index>=0){ p.addResponse(detectorResponses.get(index), true); detectorResponses.get(index).setAssociation(n); @@ -138,7 +124,6 @@ public void processHitMatching(){ * Matching tracks to FTOF layer 2 detector. Added to the particle and association is */ index = p.getDetectorHit(this.detectorResponses, DetectorType.FTOF, 3, EBConstants.FTOF_MATCHING_2); - //System.out.println("index FTOF-1B = " + index); if(index>=0){ p.addResponse(detectorResponses.get(index), true); detectorResponses.get(index).setAssociation(n); @@ -147,7 +132,6 @@ public void processHitMatching(){ * Matching tracks to CTOF detector. Added to the particle and association is */ index = p.getDetectorHit(this.detectorResponses, DetectorType.CTOF, 0, EBConstants.CTOF_Matching); -// //System.out.println("index CTOF = " + index); if(index>=0){ p.addResponse(detectorResponses.get(index), true); detectorResponses.get(index).setAssociation(n); @@ -202,8 +186,6 @@ public void processHitMatching(){ public void processNeutralTracks(){ - - List responsesPCAL = this.getUnmatchedResponses((List) detectorResponses, DetectorType.EC, 1); List particles = new ArrayList(); @@ -248,7 +230,6 @@ public void processNeutralTracks(){ } detectorEvent.setAssociation(); - //System.out.println(" PCAL RESPONSES = " + responsesPCAL.size()); } public List getUnmatchedResponses(List list, DetectorType type, int layer){ @@ -277,155 +258,151 @@ public void assignTrigger() { int i = 0; boolean hasTrigger=false; while(hasTrigger==false) { - - if(TriggerList[i]==11){ - ElectronTriggerOption electron = new ElectronTriggerOption(); - hasTrigger = electron.assignSoftwareTrigger(detectorEvent); - } - if(TriggerList[i]==-11){ - PositronTriggerOption positron = new PositronTriggerOption(); - hasTrigger= positron.assignSoftwareTrigger(detectorEvent); - } - if(TriggerList[i]==-211){ - NegPionTriggerOption negpion = new NegPionTriggerOption(); - hasTrigger = negpion.assignSoftwareTrigger(detectorEvent); - } - if(TriggerList[i]==211){ - PosPionTriggerOption pospion = new PosPionTriggerOption(); - hasTrigger = pospion.assignSoftwareTrigger(detectorEvent); - } - if(TriggerList[i]==0){ - hasTrigger = true; - } - - - i = i + 1; + + if(TriggerList[i]==11){ + ElectronTriggerOption electron = new ElectronTriggerOption(); + hasTrigger = electron.assignSoftwareTrigger(detectorEvent); + } + if(TriggerList[i]==-11){ + PositronTriggerOption positron = new PositronTriggerOption(); + hasTrigger= positron.assignSoftwareTrigger(detectorEvent); + } + if(TriggerList[i]==-211){ + NegPionTriggerOption negpion = new NegPionTriggerOption(); + hasTrigger = negpion.assignSoftwareTrigger(detectorEvent); + } + if(TriggerList[i]==211){ + PosPionTriggerOption pospion = new PosPionTriggerOption(); + hasTrigger = pospion.assignSoftwareTrigger(detectorEvent); + } + if(TriggerList[i]==0){ + hasTrigger = true; + } + + + i = i + 1; } } - - public DetectorEvent getEvent(){return this.detectorEvent;} - + public void show(){ int np = this.detectorEvent.getParticles().size(); System.out.println(">>>>>>>>> DETECTOR EVENT WITH PARTICLE COUNT # " + np); System.out.println(this.detectorEvent.toString()); - /* - for(int n = 0; n < np; n++){ - System.out.println(detectorEvent.getParticle(n)); - }*/ + //for(int n = 0; n < np; n++){ + // System.out.println(detectorEvent.getParticle(n)); + //} } } - class TriggerOptions { - - public int id; - public int score_requirement; - public int charge; - - TriggerOptions() { - initID(); - } - - public void initID() { - //Initialize parameters - } - - public void setID(int pid) { - this.id = pid; - } - - public void setScoreRequirement(int sc) { - this.score_requirement = sc; - } - - public void setCharge(int ch) { - this.charge = ch; - } - - public boolean assignSoftwareTrigger(DetectorEvent event) { - boolean flag = false; - int npart = event.getParticles().size(); - for(int i = 0; i < npart; i++){ - DetectorParticle p = event.getParticle(i); - if(p.getSoftwareTriggerScore()>=this.score_requirement) { //Possible Electron - //System.out.println("The requirements is " + this.score_requirement); - if(this.charge==p.getCharge()){ - p.setPid(this.id); - } - - - } - } - - int index = -1; - double best_p = 0.0; - for(int i = 0; i < npart; i++){ - if(event.getParticle(i).getPid()==this.id){ - if(event.getParticle(i).vector().mag()>best_p){ //Sorting the Momentum - best_p = event.getParticle(i).vector().mag(); - index = i; - } +class TriggerOptions { + + public int id; + public int score_requirement; + public int charge; + + TriggerOptions() { + initID(); + } + + public void initID() { + //Initialize parameters + } + + public void setID(int pid) { + this.id = pid; + } + + public void setScoreRequirement(int sc) { + this.score_requirement = sc; + } + + public void setCharge(int ch) { + this.charge = ch; + } + + public boolean assignSoftwareTrigger(DetectorEvent event) { + boolean flag = false; + int npart = event.getParticles().size(); + for(int i = 0; i < npart; i++){ + DetectorParticle p = event.getParticle(i); + if(p.getSoftwareTriggerScore()>=this.score_requirement) { //Possible Electron + //System.out.println("The requirements is " + this.score_requirement); + if(this.charge==p.getCharge()){ + p.setPid(this.id); } } - - if(index>0){ - event.moveUp(index); - if(event.getParticle(0).getPid()==this.id){ - flag = true; - } - } - + } + - return flag; + int index = -1; + double best_p = 0.0; + for(int i = 0; i < npart; i++){ + if(event.getParticle(i).getPid()==this.id){ + if(event.getParticle(i).vector().mag()>best_p){ //Sorting the Momentum + best_p = event.getParticle(i).vector().mag(); + index = i; + } } + } + if(index>0){ + event.moveUp(index); + if(event.getParticle(0).getPid()==this.id){ + flag = true; + } } - class ElectronTriggerOption extends TriggerOptions { - - @Override - public void initID() { - this.setID(11); - this.setScoreRequirement(110); - this.setCharge(-1); - } - - } - - class PositronTriggerOption extends TriggerOptions { - - @Override - public void initID() { - this.setID(-11); - this.setScoreRequirement(110); - this.setCharge(1); - } - - } - - class NegPionTriggerOption extends TriggerOptions { - - @Override - public void initID() { - this.setID(-211); - this.setScoreRequirement(10); - this.setCharge(-1); - } - - } - - class PosPionTriggerOption extends TriggerOptions { - - @Override - public void initID() { - this.setID(211); - this.setScoreRequirement(10); - this.setCharge(1); - } - - } + + return flag; + } + +} + +class ElectronTriggerOption extends TriggerOptions { + + @Override + public void initID() { + this.setID(11); + this.setScoreRequirement(110); + this.setCharge(-1); + } + +} + +class PositronTriggerOption extends TriggerOptions { + + @Override + public void initID() { + this.setID(-11); + this.setScoreRequirement(110); + this.setCharge(1); + } + +} + +class NegPionTriggerOption extends TriggerOptions { + + @Override + public void initID() { + this.setID(-211); + this.setScoreRequirement(10); + this.setCharge(-1); + } + +} + +class PosPionTriggerOption extends TriggerOptions { + + @Override + public void initID() { + this.setID(211); + this.setScoreRequirement(10); + this.setCharge(1); + } + +} From 0ee1362174c60ff823e51f1f1d7dcc7b44cc9cb9 Mon Sep 17 00:00:00 2001 From: Nathan Baltzell Date: Mon, 14 Aug 2017 17:08:16 -0400 Subject: [PATCH 04/49] build-coatjava.sh: silence mkdir warning --- build-coatjava.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-coatjava.sh b/build-coatjava.sh index f902b60a55..2ec375347e 100755 --- a/build-coatjava.sh +++ b/build-coatjava.sh @@ -1,6 +1,6 @@ #!/bin/bash -mkdir coatjava +mkdir -p coatjava cp -r bin coatjava/ cp -r etc coatjava/ mkdir -p coatjava/lib/clas From 53421b0b0eee87abdb1fa7aae6928f40793a0925 Mon Sep 17 00:00:00 2001 From: Nathan Baltzell Date: Mon, 14 Aug 2017 17:08:59 -0400 Subject: [PATCH 05/49] DetectorParticle.java: reinsert setPath for EBio, for now --- .../main/java/org/jlab/clas/detector/DetectorParticle.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorParticle.java b/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorParticle.java index b369dd63b1..bdd8d5b2b6 100644 --- a/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorParticle.java +++ b/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorParticle.java @@ -32,6 +32,7 @@ public class DetectorParticle implements Comparable { private Double particleBeta = 0.0; private Double particleMass = 0.0; private Double particleIDQuality = 0.0; + private Double particlePath = 0.0; private int particleScore = 0; // scores are assigned detector hits private double particleScoreChi2 = 0.0; // chi2 for particle score @@ -619,7 +620,10 @@ public Line3D getDistance(DetectorResponse response){ return dist; } - + public void setPath(double path){ + this.particlePath = path; + } + @Override public String toString(){ StringBuilder str = new StringBuilder(); From c6a72d253c1a4b356722805af1f83799009348cb Mon Sep 17 00:00:00 2001 From: baltzell Date: Mon, 14 Aug 2017 20:20:30 -0400 Subject: [PATCH 06/49] global .gitignore: no .log files --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index cfb6f6c404..d48d83c273 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,6 @@ hs_err_pid* *.iml .idea +# no log files: +*.log + From 408195e0338157196ca5e66ef4728da54de753c4 Mon Sep 17 00:00:00 2001 From: baltzell Date: Mon, 14 Aug 2017 20:21:33 -0400 Subject: [PATCH 07/49] validation: start to setup eb tests, use bash functinos to reduce code duplication in old tests --- validation/advanced-tests/run-eb-tests.sh | 69 ++++++++ .../src/eb/simplePidTest.groovy | 153 ++++++++++++++++++ validation/unit-tests/run-unit-tests.sh | 75 +++++---- .../src/eb/EBReconstructionTest.java | 74 +++++++++ 4 files changed, 337 insertions(+), 34 deletions(-) create mode 100755 validation/advanced-tests/run-eb-tests.sh create mode 100644 validation/advanced-tests/src/eb/simplePidTest.groovy create mode 100644 validation/unit-tests/src/eb/EBReconstructionTest.java diff --git a/validation/advanced-tests/run-eb-tests.sh b/validation/advanced-tests/run-eb-tests.sh new file mode 100755 index 0000000000..1efcab7552 --- /dev/null +++ b/validation/advanced-tests/run-eb-tests.sh @@ -0,0 +1,69 @@ +#!/bin/sh -f + +# coatjava must already be built at ../../coatjava/ + +# set up environment +CLARA_HOME=$PWD/clara_installation/ ; export CLARA_HOME +COAT=$CLARA_HOME/plugins/clas12/ +classPath="$COAT/lib/services/*:$COAT/lib/clas/*:$COAT/lib/utils/*:../lib/*:src/" + +webDir=http://clasweb.jlab.org/clas12offline/distribution/coatjava/validation_files/eb/v0/ +webFileStub=electronproton +#webFileStub=electronpion +#webFileStub=electronkaon + +# tar the local coatjava build so it can be installed with clara +cd ../.. +tar -zcvf coatjava-local.tar.gz coatjava +mv coatjava-local.tar.gz validation/advanced-tests/ +cd - + +# install clara +if ! [ -d clara_installation ] +then + wget --no-check-certificate https://claraweb.jlab.org/clara/_downloads/install-claracre-clas.sh + chmod +x install-claracre-clas.sh + ./install-claracre-clas.sh -l local + if [ $? != 0 ] ; then echo "clara installation error" ; exit 1 ; fi + rm install-claracre-clas.sh +fi + +# download test files +if ! [ -e ${webFileStub}.evio.gz ] +then + wget --no-check-certificate $webDir/${webFileStub}.evio.gz + if [ $? != 0 ] ; then echo "wget validation files failure" ; exit 1 ; fi + gunzip -f ${webFileStub}.evio.gz +fi + +rm -f ${webFileStub}.hipo +rm -f out_${webFileStub}.hipo + +# run decoder +$COAT/bin/decoder -t -0.5 -s 0.0 -i ./${webFileStub}.evio -o ./${webFileStub}.hipo -c 2 + +# run reconstruction with clara +echo "set inputDir $PWD/" > cook.clara +echo "set outputDir $PWD/" >> cook.clara +echo "set threads 2" >> cook.clara +echo "set javaMemory 2" >> cook.clara +echo "set session s_cook" >> cook.clara +echo "set description d_cook" >> cook.clara +ls ${webFileStub}.hipo > files.list +echo "set fileList $PWD/files.list" >> cook.clara +echo "run local" >> cook.clara +echo "exit" >> cook.clara +$CLARA_HOME/bin/clara-shell cook.clara + +# RUN NUMBER PROBLEM (run=0) + +# compile test codes +#javac -cp $classPath src/kpptracking/KppTrackingTest.java +#if [ $? != 0 ] ; then echo "KppTrackingTest compilation failure" ; exit 1 ; fi + +# run KppTracking junit tests +#java -DCLAS12DIR="$COAT" -Xmx1536m -Xms1024m -cp $classPath org.junit.runner.JUnitCore kpptracking.KppTrackingTest +#if [ $? != 0 ] ; then echo "KppTracking unit test failure" ; exit 1 ; else echo "KppTracking passed unit tests" ; fi + +exit 0 + diff --git a/validation/advanced-tests/src/eb/simplePidTest.groovy b/validation/advanced-tests/src/eb/simplePidTest.groovy new file mode 100644 index 0000000000..823ba110c7 --- /dev/null +++ b/validation/advanced-tests/src/eb/simplePidTest.groovy @@ -0,0 +1,153 @@ +import java.util.ArrayList; +import org.jlab.groot.data.H1F; +import org.jlab.groot.data.H2F; +import org.jlab.groot.math.F1D; +import org.jlab.groot.ui.TCanvas; +import org.jlab.io.base.DataBank; +import org.jlab.io.base.DataEvent; +import org.jlab.io.hipo.HipoDataSource; +import org.jlab.clas.physics.LorentzVector; +import org.jlab.groot.ui.TCanvas; +import org.jlab.groot.data.GraphErrors; +import org.jlab.geom.prim.Point3D; +import org.jlab.geom.prim.Vector3D; +import org.jlab.clas.detector.DetectorParticle; + + +HipoDataSource reader = new HipoDataSource(); +reader.open(args[0]); + + +int dc_electron_total = 0; +int eb_electron_total = 0; + +int dc_hadron_total = 0; +int eb_hadron_total = 0; + + +thelist = fillInvariantMassData(reader); +if(thelist.size()==4) { +dc_electron_total = dc_electron_total + thelist.get(0); +eb_electron_total = eb_electron_total + thelist.get(1); +dc_hadron_total = dc_hadron_total + thelist.get(2); +eb_hadron_total = eb_hadron_total + thelist.get(3); +} + + + +System.out.println("Generated electrons " + dc_electron_total); +System.out.println("Reconstructed electrons " + eb_electron_total); +System.out.println("Generated hadrons " + dc_hadron_total); +System.out.println("Reconstructed hadrons " + eb_hadron_total); + + +List fillInvariantMassData(HipoDataSource read) { + +List list = new ArrayList<>(); +int generated_electron = 0; +int reconstructed_electron = 0; +int generated_hadron = 0; +int reconstructed_hadron = 0; + + +while(read.hasEvent()) +{ + + DataEvent event = read.getNextEvent(); + + ArrayList eb_electrons = new ArrayList<>(); + ArrayList eb_hadrons = new ArrayList<>(); + + ArrayList electrons = new ArrayList<>(); + ArrayList hadrons = new ArrayList<>(); + + + + if(event.hasBank("REC::Particle")) + { + DataBank bank = event.getBank("REC::Particle"); + for(int k = 0; k < bank.rows(); k++) + { + int charge = bank.getInt("charge", k); + int pid = bank.getInt("pid", k); + float px = bank.getFloat("px", k); + float py = bank.getFloat("py", k); + float pz = bank.getFloat("pz", k); + float beta = bank.getFloat("beta", k ); + Vector3D vec = new Vector3D(px,py,pz); + double theta = vec.theta()*57.2958; + double phi = vec.phi()*57.2958; + double energy; + + if(pid==11) { + energy = Math.sqrt(px*px + py*py + pz*pz + 0.0005*0.0005); + eb_electrons.add(new LorentzVector(px, py, pz, energy)); + } + + + if(pid==2212) { + energy = Math.sqrt(px*px + py*py + pz*pz + 0.938*0.938); + eb_hadrons.add(new LorentzVector(px, py, pz, energy)); + } + + if(charge<0) { + energy = Math.sqrt(px*px + py*py + pz*pz + 0.0005*0.0005); + electrons.add(new LorentzVector(px, py, pz, energy)); + } + + + if(charge>0) { + energy = Math.sqrt(px*px + py*py + pz*pz + 0.938*0.938); + hadrons.add(new LorentzVector(px, py, pz, energy)); + } + + + + }//end of for loop + + + + }//end of if (REC::Particle) loop + + + + +//++++++++++++++++++++++Efficiency Analysis++++++++++++++++++++++++++++++++++++++++++ + + + +if(electrons.size()>0){ + generated_electron = generated_electron + 1; + } + + +if(eb_electrons.size()>0) { + reconstructed_electron = reconstructed_electron + 1; +} + +if(hadrons.size()>0){ + generated_hadron = generated_hadron + 1; + } + + +if(eb_hadrons.size()>0) { + reconstructed_hadron = reconstructed_hadron + 1; +} + + +} + + + +//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + +if(generated_electron>0 && reconstructed_electron>0) { +list.add(generated_electron); +list.add(reconstructed_electron); +list.add(generated_hadron); +list.add(reconstructed_hadron); +} +return list; +} + diff --git a/validation/unit-tests/run-unit-tests.sh b/validation/unit-tests/run-unit-tests.sh index 06d44921f8..6e08aa1e7e 100755 --- a/validation/unit-tests/run-unit-tests.sh +++ b/validation/unit-tests/run-unit-tests.sh @@ -4,38 +4,45 @@ # set environment COAT="../../coatjava/" -classPath="$COAT/lib/services/*:$COAT/lib/clas/*:$COAT/lib/utils/*:../lib/*:src/" +CLASSPATH="$COAT/lib/services/*:$COAT/lib/clas/*:$COAT/lib/utils/*:../lib/*:src/" + +function compileTest +{ + path=$1 + stub=${path##*/} + stub=${stub%%.java} + javac -cp $CLASSPATH $path + if [ $? != 0 ] + then + echo "$stub compilation failure" + exit 1 + fi +} + +function runTest +{ + class=$1 + stub=${class%%.*} + java -DCLAS12DIR="$COAT" -Xmx1536m -Xms1024m -cp $CLASSPATH org.junit.runner.JUnitCore $class + if [ $? != 0 ] + then + echo "$stub unit test failure" + exit 1 + else + echo "$stub passed unit tests" + fi +} + +# compile codes: +compileTest src/events/TestEvent.java +compileTest src/dc/DCReconstructionTest.java +compileTest src/cvt/CVTReconstructionTest.java +compileTest src/ec/ECReconstructionTest.java +compileTest src/eb/EBReconstructionTest.java + +# run unit tests: +runTest dc.DCReconstructionTest +runTest cvt.CVTReconstructionTest +runTest ec.ECReconstructionTest +runTest eb.EBReconstructionTest - -# compile codes -javac -cp $classPath src/events/TestEvent.java -if [ $? != 0 ] ; then echo "TestEvent compilation failure" ; exit 1 ; fi - -javac -cp $classPath src/events/RandomEventGenerator.java -if [ $? != 0 ] ; then echo "RandomEventGenerator compilation failure" ; exit 1 ; fi - -javac -cp $classPath src/dc/DCReconstructionTest.java -if [ $? != 0 ] ; then echo "DCReconstructionTest compilation failure" ; exit 1 ; fi - -javac -cp $classPath src/cvt/CVTReconstructionTest.java -if [ $? != 0 ] ; then echo "CVTReconstructionTest compilation failure" ; exit 1 ; fi - -javac -cp $classPath src/ec/ECReconstructionTest.java -if [ $? != 0 ] ; then echo "ECReconstructionTest compilation failure" ; exit 1 ; fi - - -# run dc junit tests -java -DCLAS12DIR="$COAT" -Xmx1536m -Xms1024m -cp $classPath org.junit.runner.JUnitCore dc.DCReconstructionTest -if [ $? != 0 ] ; then echo "dc unit test failure" ; exit 1 ; else echo "dc passed unit tests" ; fi - -# run cvt junit tests -java -DCLAS12DIR="$COAT" -Xmx1536m -Xms1024m -cp $classPath org.junit.runner.JUnitCore cvt.CVTReconstructionTest -if [ $? != 0 ] ; then echo "cvt unit test failure" ; exit 1 ; else echo "cvt passed unit tests" ; fi - -# run ec junit tests -java -DCLAS12DIR="$COAT" -Xmx1536m -Xms1024m -cp $classPath org.junit.runner.JUnitCore ec.ECReconstructionTest -if [ $? != 0 ] ; then echo "ec unit test failure" ; exit 1 ; else echo "ec passed unit tests" ; fi - - -# run event generator -#java -DCLAS12DIR="$COAT" -Xmx1536m -Xms1024m -cp $classPath events.RandomEventGenerator diff --git a/validation/unit-tests/src/eb/EBReconstructionTest.java b/validation/unit-tests/src/eb/EBReconstructionTest.java new file mode 100644 index 0000000000..3005f04362 --- /dev/null +++ b/validation/unit-tests/src/eb/EBReconstructionTest.java @@ -0,0 +1,74 @@ +package eb; + +import org.junit.Test; +import static org.junit.Assert.*; + +import events.TestEvent; + +import org.jlab.io.base.DataEvent; +import org.jlab.service.ec.ECEngine; +import org.jlab.service.ftof.FTOFEngine; +import org.jlab.service.htcc.HTCCReconstructionService; +import org.jlab.service.ltcc.LTCCEngine; +import org.jlab.service.eb.EBHBEngine; +import org.jlab.service.eb.EBTBEngine; + +/** + * + * @author nbaltzell + */ +public class EBReconstructionTest { + + public void processAllEngines(DataEvent ev) { + + ECEngine engineEC = new ECEngine(); + engineEC.init(); + engineEC.processDataEvent(ev); + + FTOFEngine engineFTOF = new FTOFEngine(); + engineFTOF.init(); + engineFTOF.processDataEvent(ev); + + // htcc has different class naming scheme, ugh. + HTCCReconstructionService engineHTCC = new HTCCReconstructionService(); + engineHTCC.init(); + engineHTCC.processDataEvent(ev); + + LTCCEngine engineLTCC = new LTCCEngine(); + engineLTCC.init(); + engineLTCC.processDataEvent(ev); + + EBHBEngine engineEBHB = new EBHBEngine(); + engineEBHB.init(); + engineEBHB.processDataEvent(ev); + + EBTBEngine engineEBTB = new EBTBEngine(); + engineEBTB.init(); + engineEBTB.processDataEvent(ev); + } + + @Test + public void testEBReconstruction() { + + DataEvent photonEvent = TestEvent.getECSector1PhotonEvent(); + + //DataEvent electronEvent = TestEvent.getECSector1ElectronEvent(); + + processAllEngines(photonEvent); + + //testEvent.show(); + + // check bank existence: + assertEquals(photonEvent.hasBank("RECHB::Event"), true); + assertEquals(photonEvent.hasBank("RECHB::Particle"), true); + assertEquals(photonEvent.hasBank("RECHB::Calorimeter"), true); + assertEquals(photonEvent.hasBank("REC::Event"), true); + assertEquals(photonEvent.hasBank("REC::Particle"), true); + assertEquals(photonEvent.hasBank("REC::Calorimeter"), true); + + // photon event doesn't pass this: + //assertEquals(photonEvent.hasBank("REC::Cherenkov"), true); + //assertEquals(photonEvent.hasBank("REC::Scintillator"), true); + + } +} From 5d287cfaaf83c7b5b4aa487598783d45eb521c54 Mon Sep 17 00:00:00 2001 From: baltzell Date: Mon, 14 Aug 2017 21:03:46 -0400 Subject: [PATCH 08/49] run-unit-tests.sh: add some printouts to debug travis --- validation/unit-tests/run-unit-tests.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/validation/unit-tests/run-unit-tests.sh b/validation/unit-tests/run-unit-tests.sh index 6e08aa1e7e..c2feb62c12 100755 --- a/validation/unit-tests/run-unit-tests.sh +++ b/validation/unit-tests/run-unit-tests.sh @@ -1,5 +1,9 @@ #!/bin/sh -f +echo ------------------------------------ +echo run-unit-tests.sh +echo ------------------------------------ + # coatjava must already be built at ../../coatjava/ # set environment @@ -8,9 +12,11 @@ CLASSPATH="$COAT/lib/services/*:$COAT/lib/clas/*:$COAT/lib/utils/*:../lib/*:src/ function compileTest { + echo TravisCompileTest $1 path=$1 stub=${path##*/} stub=${stub%%.java} + echo javac -cp $CLASSPATH $path javac -cp $CLASSPATH $path if [ $? != 0 ] then @@ -21,8 +27,10 @@ function compileTest function runTest { + echo TravisRunTest $1 class=$1 stub=${class%%.*} + echo java -DCLAS12DIR="$COAT" -Xmx1536m -Xms1024m -cp $CLASSPATH org.junit.runner.JUnitCore $class java -DCLAS12DIR="$COAT" -Xmx1536m -Xms1024m -cp $CLASSPATH org.junit.runner.JUnitCore $class if [ $? != 0 ] then From a1dff83de3c34935b9ad53adda05b949211e06d8 Mon Sep 17 00:00:00 2001 From: baltzell Date: Mon, 14 Aug 2017 21:12:39 -0400 Subject: [PATCH 09/49] run-unit-tests.sh: revert to make travis happy --- validation/unit-tests/run-unit-tests.sh | 93 ++++++++++++------------- 1 file changed, 44 insertions(+), 49 deletions(-) diff --git a/validation/unit-tests/run-unit-tests.sh b/validation/unit-tests/run-unit-tests.sh index c2feb62c12..affab42439 100755 --- a/validation/unit-tests/run-unit-tests.sh +++ b/validation/unit-tests/run-unit-tests.sh @@ -1,56 +1,51 @@ #!/bin/sh -f -echo ------------------------------------ -echo run-unit-tests.sh -echo ------------------------------------ - # coatjava must already be built at ../../coatjava/ # set environment COAT="../../coatjava/" -CLASSPATH="$COAT/lib/services/*:$COAT/lib/clas/*:$COAT/lib/utils/*:../lib/*:src/" - -function compileTest -{ - echo TravisCompileTest $1 - path=$1 - stub=${path##*/} - stub=${stub%%.java} - echo javac -cp $CLASSPATH $path - javac -cp $CLASSPATH $path - if [ $? != 0 ] - then - echo "$stub compilation failure" - exit 1 - fi -} - -function runTest -{ - echo TravisRunTest $1 - class=$1 - stub=${class%%.*} - echo java -DCLAS12DIR="$COAT" -Xmx1536m -Xms1024m -cp $CLASSPATH org.junit.runner.JUnitCore $class - java -DCLAS12DIR="$COAT" -Xmx1536m -Xms1024m -cp $CLASSPATH org.junit.runner.JUnitCore $class - if [ $? != 0 ] - then - echo "$stub unit test failure" - exit 1 - else - echo "$stub passed unit tests" - fi -} - -# compile codes: -compileTest src/events/TestEvent.java -compileTest src/dc/DCReconstructionTest.java -compileTest src/cvt/CVTReconstructionTest.java -compileTest src/ec/ECReconstructionTest.java -compileTest src/eb/EBReconstructionTest.java - -# run unit tests: -runTest dc.DCReconstructionTest -runTest cvt.CVTReconstructionTest -runTest ec.ECReconstructionTest -runTest eb.EBReconstructionTest +classPath="$COAT/lib/services/*:$COAT/lib/clas/*:$COAT/lib/utils/*:../lib/*:src/" + + +# compile codes +javac -cp $classPath src/events/TestEvent.java +if [ $? != 0 ] ; then echo "TestEvent compilation failure" ; exit 1 ; fi + +javac -cp $classPath src/events/RandomEventGenerator.java +if [ $? != 0 ] ; then echo "RandomEventGenerator compilation failure" ; exit 1 ; fi + +javac -cp $classPath src/dc/DCReconstructionTest.java +if [ $? != 0 ] ; then echo "DCReconstructionTest compilation failure" ; exit 1 ; fi + +javac -cp $classPath src/cvt/CVTReconstructionTest.java +if [ $? != 0 ] ; then echo "CVTReconstructionTest compilation failure" ; exit 1 ; fi + +javac -cp $classPath src/ec/ECReconstructionTest.java +if [ $? != 0 ] ; then echo "ECReconstructionTest compilation failure" ; exit 1 ; fi + +javac -cp $classPath src/eb/EBReconstructionTest.java +if [ $? != 0 ] ; then echo "EBReconstructionTest compilation failure" ; exit 1 ; fi + + + +# run dc junit tests +java -DCLAS12DIR="$COAT" -Xmx1536m -Xms1024m -cp $classPath org.junit.runner.JUnitCore dc.DCReconstructionTest +if [ $? != 0 ] ; then echo "dc unit test failure" ; exit 1 ; else echo "dc passed unit tests" ; fi + +# run cvt junit tests +java -DCLAS12DIR="$COAT" -Xmx1536m -Xms1024m -cp $classPath org.junit.runner.JUnitCore cvt.CVTReconstructionTest +if [ $? != 0 ] ; then echo "cvt unit test failure" ; exit 1 ; else echo "cvt passed unit tests" ; fi + +# run ec junit tests +java -DCLAS12DIR="$COAT" -Xmx1536m -Xms1024m -cp $classPath org.junit.runner.JUnitCore ec.ECReconstructionTest +if [ $? != 0 ] ; then echo "ec unit test failure" ; exit 1 ; else echo "ec passed unit tests" ; fi + +# run eb junit tests +java -DCLAS12DIR="$COAT" -Xmx1536m -Xms1024m -cp $classPath org.junit.runner.JUnitCore eb.EBReconstructionTest +if [ $? != 0 ] ; then echo "eb unit test failure" ; exit 1 ; else echo "eb passed unit tests" ; fi + + +# run event generator +#java -DCLAS12DIR="$COAT" -Xmx1536m -Xms1024m -cp $classPath events.RandomEventGenerator + From 6e81d27b2c5f0e56498f18b5790773d3cef92a26 Mon Sep 17 00:00:00 2001 From: Nathan Baltzell Date: Wed, 16 Aug 2017 08:44:57 -0400 Subject: [PATCH 10/49] validation: small eb upgrades --- validation/advanced-tests/.gitignore | 4 +++ validation/unit-tests/run-unit-tests.sh | 5 ++++ .../src/eb/EBReconstructionTest.java | 25 +++++++++++++------ 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/validation/advanced-tests/.gitignore b/validation/advanced-tests/.gitignore index 3669828635..b038532423 100644 --- a/validation/advanced-tests/.gitignore +++ b/validation/advanced-tests/.gitignore @@ -4,4 +4,8 @@ /*.hipo /*.evio /*.evio.tar.gz +/*.evio.gz +/*.hipo.gz +/*.hipo +/coatjava-local.tar.gz diff --git a/validation/unit-tests/run-unit-tests.sh b/validation/unit-tests/run-unit-tests.sh index affab42439..f246c8c874 100755 --- a/validation/unit-tests/run-unit-tests.sh +++ b/validation/unit-tests/run-unit-tests.sh @@ -1,5 +1,10 @@ #!/bin/sh -f +# try to find out what shell travis is really using: +ls -l /bin/sh +ls -l /bin/bash +ls -l /bin/dash + # coatjava must already be built at ../../coatjava/ # set environment diff --git a/validation/unit-tests/src/eb/EBReconstructionTest.java b/validation/unit-tests/src/eb/EBReconstructionTest.java index 3005f04362..ffabc96ec0 100644 --- a/validation/unit-tests/src/eb/EBReconstructionTest.java +++ b/validation/unit-tests/src/eb/EBReconstructionTest.java @@ -6,6 +6,8 @@ import events.TestEvent; import org.jlab.io.base.DataEvent; +import org.jlab.service.dc.DCHBEngine; +import org.jlab.service.dc.DCTBEngine; import org.jlab.service.ec.ECEngine; import org.jlab.service.ftof.FTOFEngine; import org.jlab.service.htcc.HTCCReconstructionService; @@ -21,6 +23,14 @@ public class EBReconstructionTest { public void processAllEngines(DataEvent ev) { + DCHBEngine engineDCHB = new DCHBEngine(); + engineDCHB.init(); + engineDCHB.processDataEvent(ev); + + DCTBEngine engineDCTB = new DCTBEngine(); + engineDCTB.init(); + engineDCTB.processDataEvent(ev); + ECEngine engineEC = new ECEngine(); engineEC.init(); engineEC.processDataEvent(ev); @@ -51,13 +61,8 @@ public void processAllEngines(DataEvent ev) { public void testEBReconstruction() { DataEvent photonEvent = TestEvent.getECSector1PhotonEvent(); - - //DataEvent electronEvent = TestEvent.getECSector1ElectronEvent(); - processAllEngines(photonEvent); - //testEvent.show(); - // check bank existence: assertEquals(photonEvent.hasBank("RECHB::Event"), true); assertEquals(photonEvent.hasBank("RECHB::Particle"), true); @@ -66,9 +71,13 @@ public void testEBReconstruction() { assertEquals(photonEvent.hasBank("REC::Particle"), true); assertEquals(photonEvent.hasBank("REC::Calorimeter"), true); - // photon event doesn't pass this: - //assertEquals(photonEvent.hasBank("REC::Cherenkov"), true); - //assertEquals(photonEvent.hasBank("REC::Scintillator"), true); + DataEvent electronEvent = TestEvent.getDCSector1ElectronEvent(); + processAllEngines(electronEvent); + assertEquals(electronEvent.hasBank("REC::Event"), true); + assertEquals(electronEvent.hasBank("REC::Particle"), true); + //assertEquals(electronEvent.hasBank("REC::Tracks"), true); + //assertEquals(electronEvent.hasBank("REC::Cherenkov"), true); + //assertEquals(electronEvent.hasBank("REC::Scintillator"), true); } } From 3b41855a27b265d9c9a72308aa16eb9e558f8951 Mon Sep 17 00:00:00 2001 From: baltzell Date: Wed, 16 Aug 2017 11:55:34 -0400 Subject: [PATCH 11/49] validation: improving eb tests --- validation/advanced-tests/run-eb-tests.sh | 12 ++-- .../advanced-tests/src/eb/EBSimpleTest.java | 64 +++++++++++++++++++ validation/unit-tests/run-unit-test.sh | 19 ++++++ validation/unit-tests/run-unit-tests.sh | 5 -- .../src/eb/EBReconstructionTest.java | 5 +- 5 files changed, 90 insertions(+), 15 deletions(-) create mode 100644 validation/advanced-tests/src/eb/EBSimpleTest.java create mode 100755 validation/unit-tests/run-unit-test.sh diff --git a/validation/advanced-tests/run-eb-tests.sh b/validation/advanced-tests/run-eb-tests.sh index 1efcab7552..43f2bc7227 100755 --- a/validation/advanced-tests/run-eb-tests.sh +++ b/validation/advanced-tests/run-eb-tests.sh @@ -39,8 +39,7 @@ fi rm -f ${webFileStub}.hipo rm -f out_${webFileStub}.hipo -# run decoder -$COAT/bin/decoder -t -0.5 -s 0.0 -i ./${webFileStub}.evio -o ./${webFileStub}.hipo -c 2 +$COAT/bin/evio2hipo -o ${webFileStub}.hipo ${webFileStub}.evio # run reconstruction with clara echo "set inputDir $PWD/" > cook.clara @@ -55,15 +54,14 @@ echo "run local" >> cook.clara echo "exit" >> cook.clara $CLARA_HOME/bin/clara-shell cook.clara -# RUN NUMBER PROBLEM (run=0) # compile test codes -#javac -cp $classPath src/kpptracking/KppTrackingTest.java -#if [ $? != 0 ] ; then echo "KppTrackingTest compilation failure" ; exit 1 ; fi +javac -cp $classPath src/eb/EBSimpleTest.java +if [ $? != 0 ] ; then echo "EBSimpleTest compilation failure" ; exit 1 ; fi # run KppTracking junit tests -#java -DCLAS12DIR="$COAT" -Xmx1536m -Xms1024m -cp $classPath org.junit.runner.JUnitCore kpptracking.KppTrackingTest -#if [ $? != 0 ] ; then echo "KppTracking unit test failure" ; exit 1 ; else echo "KppTracking passed unit tests" ; fi +java -DCLAS12DIR="$COAT" -Xmx1536m -Xms1024m -cp $classPath org.junit.runner.JUnitCore eb.EBSimpleTest +if [ $? != 0 ] ; then echo "EBSimpleTest unit test failure" ; exit 1 ; else echo "EBSimpleTest passed unit tests" ; fi exit 0 diff --git a/validation/advanced-tests/src/eb/EBSimpleTest.java b/validation/advanced-tests/src/eb/EBSimpleTest.java new file mode 100644 index 0000000000..d97945a523 --- /dev/null +++ b/validation/advanced-tests/src/eb/EBSimpleTest.java @@ -0,0 +1,64 @@ +package eb; + +import org.junit.Test; +import static org.junit.Assert.*; + +import org.jlab.io.base.DataBank; +import org.jlab.io.base.DataEvent; +import org.jlab.io.hipo.HipoDataSource; + +/** + * + */ +public class EBSimpleTest { + + @Test + public void testKppTracking() { + + HipoDataSource reader = new HipoDataSource(); + reader.open("out_electronproton.hipo"); + //reader.open("out_electronpion.hipo"); + //reader.open("out_electronkaon.hipo"); + + int nEvents = 0; + int twoTrackCount = 0; + int epCount = 0; + int eCount = 0; + while(reader.hasEvent()) { + nEvents++; + DataEvent event = reader.getNextEvent(); + if(event.hasBank("REC::Particle")) { + DataBank recBank = event.getBank("REC::Particle"); + boolean foundElectron = false; + boolean foundCharged = false; + boolean foundProton = false; + for(int k = 0; k < recBank.rows(); k++) { + byte charge = recBank.getByte("charge", k); + int pid = recBank.getInt("pid", k); + if(foundElectron == false && pid == 11) foundElectron = true; + else if(charge != 0) foundCharged = true; + if (pid==2212) foundProton=true; + } + if(foundElectron && foundCharged) twoTrackCount++; + if(foundElectron && foundProton) epCount++; + if(foundElectron) eCount++; + + } + } + + reader.close(); + + double protonEff = (double)epCount / eCount; + double epEff = (double)epCount / nEvents; + double eEff = (double)eCount / nEvents; + + System.out.println("# Events = "+nEvents); + System.out.println("eEff = "+eEff); + System.out.println("pEff = "+protonEff); + System.out.println("epEff = "+epEff); + +//assertEquals(twoTrackCount > 100, true); // this should be stricter! + + } + +} diff --git a/validation/unit-tests/run-unit-test.sh b/validation/unit-tests/run-unit-test.sh new file mode 100755 index 0000000000..fc1e22d92a --- /dev/null +++ b/validation/unit-tests/run-unit-test.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env dash + +pathToTest=$1 +testName=${pathToTest##*/} +testName=${testName%.java} +package=`head -1 $pathToTest | awk '{print$2}' | sed 's/;//'` + +# coatjava must already be built at ../../coatjava/ +COAT="../../coatjava/" +classPath="$COAT/lib/services/*:$COAT/lib/clas/*:$COAT/lib/utils/*:../lib/*:src/" + +# compile the test: +javac -cp $classPath $pathToTest +if [ $? != 0 ] ; then echo "$testName compilation failure" ; exit 1 ; fi + +# run the test: +java -DCLAS12DIR="$COAT" -Xmx1536m -Xms1024m -cp $classPath org.junit.runner.JUnitCore $package.$testName +if [ $? != 0 ] ; then echo "$package unit test failure" ; exit 1 ; else echo "$package passed unit tests" ; fi + diff --git a/validation/unit-tests/run-unit-tests.sh b/validation/unit-tests/run-unit-tests.sh index f246c8c874..affab42439 100755 --- a/validation/unit-tests/run-unit-tests.sh +++ b/validation/unit-tests/run-unit-tests.sh @@ -1,10 +1,5 @@ #!/bin/sh -f -# try to find out what shell travis is really using: -ls -l /bin/sh -ls -l /bin/bash -ls -l /bin/dash - # coatjava must already be built at ../../coatjava/ # set environment diff --git a/validation/unit-tests/src/eb/EBReconstructionTest.java b/validation/unit-tests/src/eb/EBReconstructionTest.java index ffabc96ec0..6d6784a5e4 100644 --- a/validation/unit-tests/src/eb/EBReconstructionTest.java +++ b/validation/unit-tests/src/eb/EBReconstructionTest.java @@ -39,7 +39,6 @@ public void processAllEngines(DataEvent ev) { engineFTOF.init(); engineFTOF.processDataEvent(ev); - // htcc has different class naming scheme, ugh. HTCCReconstructionService engineHTCC = new HTCCReconstructionService(); engineHTCC.init(); engineHTCC.processDataEvent(ev); @@ -55,6 +54,8 @@ public void processAllEngines(DataEvent ev) { EBTBEngine engineEBTB = new EBTBEngine(); engineEBTB.init(); engineEBTB.processDataEvent(ev); + + ev.show(); } @Test @@ -62,8 +63,6 @@ public void testEBReconstruction() { DataEvent photonEvent = TestEvent.getECSector1PhotonEvent(); processAllEngines(photonEvent); - //testEvent.show(); - // check bank existence: assertEquals(photonEvent.hasBank("RECHB::Event"), true); assertEquals(photonEvent.hasBank("RECHB::Particle"), true); assertEquals(photonEvent.hasBank("RECHB::Calorimeter"), true); From 0eb9acd760f9d26a4950649708b56e134913857e Mon Sep 17 00:00:00 2001 From: Nathan Baltzell Date: Thu, 17 Aug 2017 15:42:29 -0400 Subject: [PATCH 12/49] validation: more eb analysis tests --- validation/advanced-tests/run-eb-tests.sh | 105 +++++---- .../advanced-tests/src/eb/EBSimpleTest.java | 64 ------ .../advanced-tests/src/eb/EBTwoTrackTest.java | 211 ++++++++++++++++++ 3 files changed, 272 insertions(+), 108 deletions(-) delete mode 100644 validation/advanced-tests/src/eb/EBSimpleTest.java create mode 100644 validation/advanced-tests/src/eb/EBTwoTrackTest.java diff --git a/validation/advanced-tests/run-eb-tests.sh b/validation/advanced-tests/run-eb-tests.sh index 43f2bc7227..732e0a71ba 100755 --- a/validation/advanced-tests/run-eb-tests.sh +++ b/validation/advanced-tests/run-eb-tests.sh @@ -2,66 +2,83 @@ # coatjava must already be built at ../../coatjava/ +# if first argument is -t, only run the test, +# don't redownload dependencies, don't run reconstruction. +runTestOnly=0 +if [ "$1" = "-t" ] +then + runTestOnly=1 +fi + +# last argument is input file stub: +webFileStub="${@: -1}" + +# valid input file stubs: +#webFileStub=electronproton +#webFileStub=electronpion +#webFileStub=electronkaon + # set up environment CLARA_HOME=$PWD/clara_installation/ ; export CLARA_HOME COAT=$CLARA_HOME/plugins/clas12/ classPath="$COAT/lib/services/*:$COAT/lib/clas/*:$COAT/lib/utils/*:../lib/*:src/" webDir=http://clasweb.jlab.org/clas12offline/distribution/coatjava/validation_files/eb/v0/ -webFileStub=electronproton -#webFileStub=electronpion -#webFileStub=electronkaon -# tar the local coatjava build so it can be installed with clara -cd ../.. -tar -zcvf coatjava-local.tar.gz coatjava -mv coatjava-local.tar.gz validation/advanced-tests/ -cd - +# compile test codes before anything else: +javac -cp $classPath src/eb/EBTwoTrackTest.java +if [ $? != 0 ] ; then echo "EBTwoTrackTest compilation failure" ; exit 1 ; fi -# install clara -if ! [ -d clara_installation ] +# download and setup dependencies, run reconstruction: +if [ $runTestOnly -eq 0 ] then - wget --no-check-certificate https://claraweb.jlab.org/clara/_downloads/install-claracre-clas.sh - chmod +x install-claracre-clas.sh - ./install-claracre-clas.sh -l local - if [ $? != 0 ] ; then echo "clara installation error" ; exit 1 ; fi - rm install-claracre-clas.sh -fi + # tar the local coatjava build so it can be installed with clara + cd ../.. + tar -zcvf coatjava-local.tar.gz coatjava + mv coatjava-local.tar.gz validation/advanced-tests/ + cd - -# download test files -if ! [ -e ${webFileStub}.evio.gz ] -then - wget --no-check-certificate $webDir/${webFileStub}.evio.gz - if [ $? != 0 ] ; then echo "wget validation files failure" ; exit 1 ; fi - gunzip -f ${webFileStub}.evio.gz -fi - -rm -f ${webFileStub}.hipo -rm -f out_${webFileStub}.hipo + # install clara + if ! [ -d clara_installation ] + then + wget --no-check-certificate https://claraweb.jlab.org/clara/_downloads/install-claracre-clas.sh + chmod +x install-claracre-clas.sh + ./install-claracre-clas.sh -l local + if [ $? != 0 ] ; then echo "clara installation error" ; exit 1 ; fi + rm install-claracre-clas.sh + fi -$COAT/bin/evio2hipo -o ${webFileStub}.hipo ${webFileStub}.evio + # download test files + if ! [ -e ${webFileStub}.evio.gz ] + then + wget --no-check-certificate $webDir/${webFileStub}.evio.gz + if [ $? != 0 ] ; then echo "wget validation files failure" ; exit 1 ; fi + gunzip -f ${webFileStub}.evio.gz + fi -# run reconstruction with clara -echo "set inputDir $PWD/" > cook.clara -echo "set outputDir $PWD/" >> cook.clara -echo "set threads 2" >> cook.clara -echo "set javaMemory 2" >> cook.clara -echo "set session s_cook" >> cook.clara -echo "set description d_cook" >> cook.clara -ls ${webFileStub}.hipo > files.list -echo "set fileList $PWD/files.list" >> cook.clara -echo "run local" >> cook.clara -echo "exit" >> cook.clara -$CLARA_HOME/bin/clara-shell cook.clara + rm -f ${webFileStub}.hipo + rm -f out_${webFileStub}.hipo + # convert to hipo + $COAT/bin/evio2hipo -o ${webFileStub}.hipo ${webFileStub}.evio -# compile test codes -javac -cp $classPath src/eb/EBSimpleTest.java -if [ $? != 0 ] ; then echo "EBSimpleTest compilation failure" ; exit 1 ; fi + # run reconstruction with clara + echo "set inputDir $PWD/" > cook.clara + echo "set outputDir $PWD/" >> cook.clara + echo "set threads 7" >> cook.clara + echo "set javaMemory 2" >> cook.clara + echo "set session s_cook" >> cook.clara + echo "set description d_cook" >> cook.clara + ls ${webFileStub}.hipo > files.list + echo "set fileList $PWD/files.list" >> cook.clara + echo "run local" >> cook.clara + echo "exit" >> cook.clara + $CLARA_HOME/bin/clara-shell cook.clara +fi # run KppTracking junit tests -java -DCLAS12DIR="$COAT" -Xmx1536m -Xms1024m -cp $classPath org.junit.runner.JUnitCore eb.EBSimpleTest -if [ $? != 0 ] ; then echo "EBSimpleTest unit test failure" ; exit 1 ; else echo "EBSimpleTest passed unit tests" ; fi +java -DCLAS12DIR="$COAT" -Xmx1536m -Xms1024m -cp $classPath -DINPUTFILE=out_${webFileStub}.hipo org.junit.runner.JUnitCore eb.EBTwoTrackTest +if [ $? != 0 ] ; then echo "EBTwoTrackTest unit test failure" ; exit 1 ; else echo "EBTwoTrackTest passed unit tests" ; fi exit 0 diff --git a/validation/advanced-tests/src/eb/EBSimpleTest.java b/validation/advanced-tests/src/eb/EBSimpleTest.java deleted file mode 100644 index d97945a523..0000000000 --- a/validation/advanced-tests/src/eb/EBSimpleTest.java +++ /dev/null @@ -1,64 +0,0 @@ -package eb; - -import org.junit.Test; -import static org.junit.Assert.*; - -import org.jlab.io.base.DataBank; -import org.jlab.io.base.DataEvent; -import org.jlab.io.hipo.HipoDataSource; - -/** - * - */ -public class EBSimpleTest { - - @Test - public void testKppTracking() { - - HipoDataSource reader = new HipoDataSource(); - reader.open("out_electronproton.hipo"); - //reader.open("out_electronpion.hipo"); - //reader.open("out_electronkaon.hipo"); - - int nEvents = 0; - int twoTrackCount = 0; - int epCount = 0; - int eCount = 0; - while(reader.hasEvent()) { - nEvents++; - DataEvent event = reader.getNextEvent(); - if(event.hasBank("REC::Particle")) { - DataBank recBank = event.getBank("REC::Particle"); - boolean foundElectron = false; - boolean foundCharged = false; - boolean foundProton = false; - for(int k = 0; k < recBank.rows(); k++) { - byte charge = recBank.getByte("charge", k); - int pid = recBank.getInt("pid", k); - if(foundElectron == false && pid == 11) foundElectron = true; - else if(charge != 0) foundCharged = true; - if (pid==2212) foundProton=true; - } - if(foundElectron && foundCharged) twoTrackCount++; - if(foundElectron && foundProton) epCount++; - if(foundElectron) eCount++; - - } - } - - reader.close(); - - double protonEff = (double)epCount / eCount; - double epEff = (double)epCount / nEvents; - double eEff = (double)eCount / nEvents; - - System.out.println("# Events = "+nEvents); - System.out.println("eEff = "+eEff); - System.out.println("pEff = "+protonEff); - System.out.println("epEff = "+epEff); - -//assertEquals(twoTrackCount > 100, true); // this should be stricter! - - } - -} diff --git a/validation/advanced-tests/src/eb/EBTwoTrackTest.java b/validation/advanced-tests/src/eb/EBTwoTrackTest.java new file mode 100644 index 0000000000..3c63bdbee4 --- /dev/null +++ b/validation/advanced-tests/src/eb/EBTwoTrackTest.java @@ -0,0 +1,211 @@ +package eb; + +import java.io.File; +import org.junit.Test; +import static org.junit.Assert.*; + +import org.jlab.io.base.DataBank; +import org.jlab.io.base.DataEvent; +import org.jlab.io.hipo.HipoDataSource; + +import org.jlab.analysis.math.ClasMath; + +/** + * + * Analyze EB efficiencies based on Joseph's two-particle (e-X) FD events. + * Need to write a more general purpose one based on MC::Particle bank. + * + * @author baltzell + */ +public class EBTwoTrackTest { + + static final boolean debug=false; + + // these correspond to Joseph's two-particle event generater: + static final int electronSector=1; + static final int hadronSector=3; + + int nNegTrackEvents = 0; + int nTwoTrackEvents = 0; + int nEvents = 0; + int epCount = 0; + int eCount = 0; + int eposCount = 0; + int epiCount = 0; + int ekCount = 0; + int nMisid = 0; + int nMissing = 0; + int nElectronsSector[]={0,0,0,0,0,0}; + int nHadronsSector[]={0,0,0,0,0,0}; + int hadronPDG; + + @Test + public void main() { + String fileName=System.getProperty("INPUTFILE"); + File file = new File(fileName); + if (!file.exists() || file.isDirectory()) { + System.err.println("Cannot find input file."); + assertEquals(false, true); + } + + if (fileName.indexOf("proton")>=0) hadronPDG=2212; + else if (fileName.indexOf("pion")>0) hadronPDG=211; + else if (fileName.indexOf("kaon")>0) hadronPDG=321; + else { + System.err.println("Cannot find particle type in filename."); + assertEquals(false, true); + } + processFile(fileName); + checkResults(); + } + + private void checkResults() { + + final double twoTrackFrac = (double)nTwoTrackEvents / nEvents; + + final double eEff = (double)eCount / nNegTrackEvents; + final double pEff = (double)epCount / eposCount; + final double piEff = (double)epiCount / eposCount; + final double kEff = (double)ekCount / eposCount; + + final double epEff = (double)epCount / nTwoTrackEvents; + final double epiEff = (double)epiCount / nTwoTrackEvents; + final double ekEff = (double)ekCount / nTwoTrackEvents; + + System.out.println("\n#############################################################"); + System.out.println(String.format("\n# Events = %d",nEvents)); + System.out.print("\nElectrons Sectors: "); + for (int k=0; k<6; k++) System.out.print(String.format(" %4d",nElectronsSector[k])); + System.out.print("\nHadrons Sectors: "); + for (int k=0; k<6; k++) System.out.print(String.format(" %4d",nHadronsSector[k])); + System.out.println("\n"); + System.out.println(String.format("2-Track Frac = %.3f\n",twoTrackFrac)); + System.out.println(String.format("eEff = %.3f",eEff)); + System.out.println(String.format("pEff = %.3f",pEff)); + System.out.println(String.format("piEff = %.3f",piEff)); + System.out.println(String.format("kEff = %.3f\n",kEff)); + System.out.println(String.format("epEff = %.3f",epEff)); + System.out.println(String.format("epiEff = %.3f",epiEff)); + System.out.println(String.format("ekEff = %.3f\n",ekEff)); + System.out.println(String.format("misid = %.3f",(float)nMisid/eposCount)); + System.out.println(String.format("missing = %.3f",(float)nMissing/eposCount)); + System.out.println("\n#############################################################"); + + // some global efficiency tests: + assertEquals(eEff>0.9,true); + if (hadronPDG==2212) assertEquals(pEff>0.80,true); + else if (hadronPDG==321) assertEquals(kEff>0.42,true); + else if (hadronPDG==211) assertEquals(piEff>0.75,true); + } + + private void processFile(String fileName) { + + HipoDataSource reader = new HipoDataSource(); + reader.open(fileName); + + while (reader.hasEvent()) { + + nEvents++; + + DataEvent event = reader.getNextEvent(); + + // get banks: + DataBank trkBank=null,tofBank=null,recBank=null,mcBank=null; + if (event.hasBank("FTOF::clusters")) + tofBank=event.getBank("FTOF::clusters"); + if (event.hasBank("TimeBasedTrkg::TBTracks")) + trkBank = event.getBank("TimeBasedTrkg::TBTracks"); + if(event.hasBank("REC::Particle")) + recBank = event.getBank("REC::Particle"); + if(event.hasBank("MC::Particle")) + mcBank = event.getBank("MC::Particle"); + + //if (mcBank!=null) mcBank.show(); + + // no tracking bank, discard event: + if (trkBank==null) continue; + + // count number of TBTracks: + int nPosTracks=0,nNegTracks=0; + for (int ii=0; ii0) nPosTracks++; + else if (trkBank.getInt("q",ii)<0) nPosTracks++; + } + } + + // no possible electron tracks, discard event: + if (nNegTracks==0) continue; + + nNegTrackEvents++; + if (nPosTracks>0) nTwoTrackEvents++; + + boolean foundElectron = false; + boolean foundProton = false; + boolean foundKaon = false; + boolean foundPion = false; + + // check particle bank: + if (recBank!=null) { + for(int ii = 0; ii < recBank.rows(); ii++) { + + final byte charge = recBank.getByte("charge", ii); + final int pid = recBank.getInt("pid", ii); + final double px=recBank.getFloat("px",ii); + final double py=recBank.getFloat("py",ii); + final int sector = ClasMath.getSectorFromPhi(Math.atan2(py,px)); + + if (pid==11 && sector==electronSector) { + if (!foundElectron) nElectronsSector[sector-1]++; + foundElectron=true; + } + else if (sector==hadronSector) { + if (pid==2212) { + if (!foundProton) nHadronsSector[sector-1]++; + foundProton=true; + } + else if (Math.abs(pid)==211) foundPion=true; + else if (Math.abs(pid)==321) foundKaon=true; + } + + } + } + + // pid counting: + if (foundElectron) { + + eCount++; + + if (nPosTracks>0) { + + eposCount++; + + if (foundProton) epCount++; + if (foundKaon) ekCount++; + if (foundPion) epiCount++; + + if (!foundProton) { + if (foundPion || foundKaon) nMisid++; + else { + nMissing++; + if (debug) { + recBank.show(); + tofBank.show(); + } + } + } + } + } + + // CVT tracks could make this happen: + //if (foundProton && nPosTracks==0) { + // System.err.println("WHAT"); + //} + } + reader.close(); + } + +} From 51c26e57261622fa906825c2d180c590015cc1c5 Mon Sep 17 00:00:00 2001 From: baltzell Date: Thu, 17 Aug 2017 20:08:39 -0400 Subject: [PATCH 13/49] validation/eb: fix misid bug for non-protons --- .../advanced-tests/src/eb/EBTwoTrackTest.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/validation/advanced-tests/src/eb/EBTwoTrackTest.java b/validation/advanced-tests/src/eb/EBTwoTrackTest.java index 3c63bdbee4..76738e1575 100644 --- a/validation/advanced-tests/src/eb/EBTwoTrackTest.java +++ b/validation/advanced-tests/src/eb/EBTwoTrackTest.java @@ -144,6 +144,7 @@ else if (trkBank.getInt("sector",ii)==hadronSector) { if (nPosTracks>0) nTwoTrackEvents++; boolean foundElectron = false; + boolean foundHadron = false; boolean foundProton = false; boolean foundKaon = false; boolean foundPion = false; @@ -163,10 +164,11 @@ else if (trkBank.getInt("sector",ii)==hadronSector) { foundElectron=true; } else if (sector==hadronSector) { - if (pid==2212) { - if (!foundProton) nHadronsSector[sector-1]++; - foundProton=true; + if (Math.abs(pid)==hadronPDG) { + if (!foundHadron) nHadronsSector[sector-1]++; + foundHadron=true; } + if (pid==2212) foundProton=true; else if (Math.abs(pid)==211) foundPion=true; else if (Math.abs(pid)==321) foundKaon=true; } @@ -187,8 +189,14 @@ else if (sector==hadronSector) { if (foundKaon) ekCount++; if (foundPion) epiCount++; - if (!foundProton) { - if (foundPion || foundKaon) nMisid++; + // FIXME + if ( (hadronPDG==2212 && !foundProton) || + (hadronPDG==321 && !foundKaon) || + (hadronPDG==211 && !foundPion) ) { + + if (hadronPDG==2212 && (foundPion || foundKaon)) nMisid++; + else if (hadronPDG==321 && (foundProton || foundPion)) nMisid++; + else if (hadronPDG==211 && (foundProton || foundKaon)) nMisid++; else { nMissing++; if (debug) { From c038b4a7e53638c7da383fc7e6d03af186f6ef18 Mon Sep 17 00:00:00 2001 From: baltzell Date: Thu, 17 Aug 2017 20:36:34 -0400 Subject: [PATCH 14/49] reconstruction/eb: move EBConstants from services to rec, prepping for reading ccdb --- .../src/main/java/org/jlab/{service => rec}/eb/EBConstants.java | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename reconstruction/eb/src/main/java/org/jlab/{service => rec}/eb/EBConstants.java (100%) diff --git a/reconstruction/eb/src/main/java/org/jlab/service/eb/EBConstants.java b/reconstruction/eb/src/main/java/org/jlab/rec/eb/EBConstants.java similarity index 100% rename from reconstruction/eb/src/main/java/org/jlab/service/eb/EBConstants.java rename to reconstruction/eb/src/main/java/org/jlab/rec/eb/EBConstants.java From 5b77713e448303670baa8e07209b0ceabf3c1344 Mon Sep 17 00:00:00 2001 From: baltzell Date: Thu, 17 Aug 2017 20:40:55 -0400 Subject: [PATCH 15/49] reconstructin/eb/monitor: remove more junk headers --- .../java/org/jlab/monitor/eb/ParticleReconstruction.java | 5 ----- .../src/main/java/org/jlab/monitor/eb/ReactionAnalysis.java | 5 ----- .../main/java/org/jlab/monitor/eb/ReconstructionMonitor.java | 5 ----- 3 files changed, 15 deletions(-) diff --git a/reconstruction/eb/src/main/java/org/jlab/monitor/eb/ParticleReconstruction.java b/reconstruction/eb/src/main/java/org/jlab/monitor/eb/ParticleReconstruction.java index 7aba7c991a..7a90fed29f 100644 --- a/reconstruction/eb/src/main/java/org/jlab/monitor/eb/ParticleReconstruction.java +++ b/reconstruction/eb/src/main/java/org/jlab/monitor/eb/ParticleReconstruction.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.monitor.eb; import org.jlab.clas.pdg.PDGDatabase; diff --git a/reconstruction/eb/src/main/java/org/jlab/monitor/eb/ReactionAnalysis.java b/reconstruction/eb/src/main/java/org/jlab/monitor/eb/ReactionAnalysis.java index fdf037dfa8..0fd5be8fc4 100644 --- a/reconstruction/eb/src/main/java/org/jlab/monitor/eb/ReactionAnalysis.java +++ b/reconstruction/eb/src/main/java/org/jlab/monitor/eb/ReactionAnalysis.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.monitor.eb; import org.jlab.clas.physics.EventFilter; diff --git a/reconstruction/eb/src/main/java/org/jlab/monitor/eb/ReconstructionMonitor.java b/reconstruction/eb/src/main/java/org/jlab/monitor/eb/ReconstructionMonitor.java index 0cc7fe56ec..c0a3c882de 100644 --- a/reconstruction/eb/src/main/java/org/jlab/monitor/eb/ReconstructionMonitor.java +++ b/reconstruction/eb/src/main/java/org/jlab/monitor/eb/ReconstructionMonitor.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.monitor.eb; import java.util.ArrayList; From ed28aafd5a4fc7301eecd26ef6a99c8197174fcc Mon Sep 17 00:00:00 2001 From: Nathan Baltzell Date: Fri, 18 Aug 2017 08:49:57 -0400 Subject: [PATCH 16/49] .gitignore: add target --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index d48d83c273..591c854639 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,7 @@ # installed: /coatjava /myLocalMvnRepo -/reconstruction +target *.class *lundfiles*.dat From e2bf6274d22fd2924d2d652234ff7774908f4e1c Mon Sep 17 00:00:00 2001 From: Nathan Baltzell Date: Fri, 18 Aug 2017 19:07:20 -0400 Subject: [PATCH 17/49] DetectorParticle.java: note some methods to move to eb --- .../main/java/org/jlab/clas/detector/DetectorParticle.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorParticle.java b/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorParticle.java index bdd8d5b2b6..fcf1757e13 100644 --- a/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorParticle.java +++ b/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorParticle.java @@ -667,6 +667,9 @@ public String toString(){ //Joseph's additions + /* + * + * These should not be in DetectorParticle, probably eb/rec makes sense public double CalculatedSF() { return this.getEnergy(DetectorType.EC)/this.vector().mag(); } @@ -687,7 +690,8 @@ public double ParametrizedSigma(){ double p = this.vector().mag(); double sigma = 0.02468*pow(p,-0.51); return sigma; - } + } + */ public double getTheoryBeta(int id){ double beta = 0.0; From ef6e7bfb5ab085bc1a6a1da216ab6bb1329b4e0a Mon Sep 17 00:00:00 2001 From: Nathan Baltzell Date: Fri, 18 Aug 2017 19:08:44 -0400 Subject: [PATCH 18/49] run-unit-test.sh: dash->sh --- validation/unit-tests/run-unit-test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/validation/unit-tests/run-unit-test.sh b/validation/unit-tests/run-unit-test.sh index fc1e22d92a..b26b2ab6bc 100755 --- a/validation/unit-tests/run-unit-test.sh +++ b/validation/unit-tests/run-unit-test.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env dash +#!/bin/sh pathToTest=$1 testName=${pathToTest##*/} From 972e8730f31b290b135608fa5c2ae56a96a78708 Mon Sep 17 00:00:00 2001 From: Nathan Baltzell Date: Fri, 18 Aug 2017 19:10:43 -0400 Subject: [PATCH 19/49] eb: get speed of light from org.jlab.clas.pdg and remove from EBConstants --- .../eb/src/main/java/org/jlab/rec/eb/EBConstants.java | 2 -- .../eb/src/main/java/org/jlab/service/eb/EBAnalyzer.java | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/reconstruction/eb/src/main/java/org/jlab/rec/eb/EBConstants.java b/reconstruction/eb/src/main/java/org/jlab/rec/eb/EBConstants.java index 6e98de8737..c51f83cac3 100644 --- a/reconstruction/eb/src/main/java/org/jlab/rec/eb/EBConstants.java +++ b/reconstruction/eb/src/main/java/org/jlab/rec/eb/EBConstants.java @@ -30,8 +30,6 @@ public class EBConstants { public static final double RF_TDC2TIME = 0.0234358; public static final int RF_LARGE_INTEGER = 800; - public static final double SPEED_OF_LIGHT = 29.9792; - public static final Vector3D PCAL_hitRes = new Vector3D(0.0,0.0,0.0); public static final Vector3D ECIN_hitRes = new Vector3D(0.0,0.0,0.0); public static final Vector3D ECOUT_hitRes = new Vector3D(0.0,0.0,0.0); diff --git a/reconstruction/eb/src/main/java/org/jlab/service/eb/EBAnalyzer.java b/reconstruction/eb/src/main/java/org/jlab/service/eb/EBAnalyzer.java index 0f3550fae5..d819de77f5 100644 --- a/reconstruction/eb/src/main/java/org/jlab/service/eb/EBAnalyzer.java +++ b/reconstruction/eb/src/main/java/org/jlab/service/eb/EBAnalyzer.java @@ -43,12 +43,12 @@ public void processEvent(DetectorEvent event) { path = trigger.getPathLength(DetectorType.FTOF, 2); } - double tof = path/EBConstants.SPEED_OF_LIGHT; + double tof = path/PhysicsConstants.speedOfLight(); double start_time = time - tof; double deltatr = - start_time + event.getEventHeader().getRfTime() + (EBConstants.RF_LARGE_INTEGER+0.5)*EBConstants.RF_BUCKET_LENGTH + EBConstants.RF_OFFSET; //double deltatr = - start_time + event.getEventHeader().getRfTime() /* - (trigger.vertex().z() - // - (EBConstants.TARGET_POSITION))/(EBConstants.SPEED_OF_LIGHT)*/ + // - (EBConstants.TARGET_POSITION))/(PhysicsConstants.speedOfLight())*/ // + (EBConstants.RF_LARGE_INTEGER+0.5)*EBConstants.RF_BUCKET_LENGTH + EBConstants.RF_OFFSET; double rfcorr = deltatr%EBConstants.RF_BUCKET_LENGTH - EBConstants.RF_BUCKET_LENGTH/2;//RF correction term event.getEventHeader().setStartTime(start_time + rfcorr); From 935ff6c7601cf07a4e746077d437a330bf765592 Mon Sep 17 00:00:00 2001 From: Nathan Baltzell Date: Fri, 18 Aug 2017 20:19:56 -0400 Subject: [PATCH 20/49] eb: starting to read from ccdb --- .../java/org/jlab/rec/eb/EBCCDBConstants.java | 227 ++++++++++++++++++ .../main/java/org/jlab/rec/eb/EBCCDBEnum.java | 54 +++++ .../rec/eb/EBDatabaseConstantProvider.java | 36 +++ .../java/org/jlab/service/eb/EBEngine.java | 13 +- 4 files changed, 328 insertions(+), 2 deletions(-) create mode 100644 reconstruction/eb/src/main/java/org/jlab/rec/eb/EBCCDBConstants.java create mode 100644 reconstruction/eb/src/main/java/org/jlab/rec/eb/EBCCDBEnum.java create mode 100644 reconstruction/eb/src/main/java/org/jlab/rec/eb/EBDatabaseConstantProvider.java diff --git a/reconstruction/eb/src/main/java/org/jlab/rec/eb/EBCCDBConstants.java b/reconstruction/eb/src/main/java/org/jlab/rec/eb/EBCCDBConstants.java new file mode 100644 index 0000000000..763ec13a56 --- /dev/null +++ b/reconstruction/eb/src/main/java/org/jlab/rec/eb/EBCCDBConstants.java @@ -0,0 +1,227 @@ +package org.jlab.rec.eb; + +import java.util.List; +import java.util.ArrayList; +import java.util.Map; +import java.util.HashMap; + +import org.jlab.detector.calib.utils.ConstantsManager; +import org.jlab.utils.groups.IndexedTable; +import org.jlab.geom.prim.Vector3D; + +public class EBCCDBConstants { + + public static boolean LOADED = false; + + public static final String ebTablePrefix="/calibration/eb/"; + + public static final String[] ebTableNames={ + "electron_sf", + "photon_sf", + "neutron_beta", + "pid", + "ecal_matching", + "ftof_matching", + "ctof_matching", + "cnd_matching", + "htcc_matching", + "ltcc_matching" + }; + + public static final String[] otherTableNames={ + "/geometry/target", + "/calibration/rf/offset" + }; + + public static List getAllTableNames() { + List ret=new ArrayList (); + for (String ss : ebTableNames) ret.add(ebTablePrefix+ss); + for (String ss : otherTableNames) ret.add(ss); + return ret; + } + + private static Map tables = new HashMap(); + private static Map dbDoubles = new HashMap(); + private static Map dbIntegers = new HashMap(); + private static Map dbVector3Ds = new HashMap(); + private static Map dbArrays = new HashMap(); + + static EBDatabaseConstantProvider DBP = new EBDatabaseConstantProvider(10,"default"); + + // fill maps: + public static synchronized void setDouble(EBCCDBEnum key,Double value) { + dbDoubles.put(key,value); + } + public static synchronized void setVector3D(EBCCDBEnum key,Vector3D value) { + dbVector3Ds.put(key,value); + } + public static synchronized void setInteger(EBCCDBEnum key,int value) { + dbIntegers.put(key,value); + } + public static synchronized void setArray(EBCCDBEnum key,Double[] value) { + dbArrays.put(key,value); + } + + // read maps: + public static synchronized double getDouble(EBCCDBEnum key) { + if (!dbDoubles.containsKey(key)) + throw new RuntimeException("Missing Double Key: "+key); + return dbDoubles.get(key); + } + public static synchronized Vector3D getVector3D(EBCCDBEnum key) { + if (!dbVector3Ds.containsKey(key)) + throw new RuntimeException("Missing Vector3D Key: "+key); + return dbVector3Ds.get(key); + } + public static synchronized int getInteger(EBCCDBEnum key) { + if (!dbIntegers.containsKey(key)) + throw new RuntimeException("Missing Integer Key: "+key); + return dbIntegers.get(key); + } + public static synchronized Double[] getArray(EBCCDBEnum key) { + if (!dbArrays.containsKey(key)) + throw new RuntimeException("Missing Integer Key: "+key); + return dbArrays.get(key); + } + + // read ccdb tables: + private static synchronized void loadTable( + int run, + ConstantsManager manager, + String fullTableName) { + tables.put(fullTableName,manager.getConstants(run,fullTableName)); + } + private static synchronized void loadEbTable( + int run, + ConstantsManager manager, + String shortTableName) { + tables.put(shortTableName,manager.getConstants(run,ebTablePrefix+shortTableName)); + } + + // read ccdb values, fill maps: + private static synchronized void loadDouble( + EBCCDBEnum key, + String tableName, + String columnName, + int sector,int layer,int component) { + double value=tables.get(tableName).getDoubleValue(columnName,sector,layer,component); + setDouble(key,value); + } + private static synchronized void loadInteger( + EBCCDBEnum key, + String tableName, + String columnName, + int sector,int layer,int component) { + int value=tables.get(tableName).getIntValue(columnName,sector,layer,component); + setInteger(key,value); + } + private static synchronized void loadVector3D( + EBCCDBEnum key, + String tableName, + String colName1, String colName2, String colName3, + int sector,int layer,int component) { + double val1=tables.get(tableName).getDoubleValue(colName1,sector,layer,component); + double val2=tables.get(tableName).getDoubleValue(colName2,sector,layer,component); + double val3=tables.get(tableName).getDoubleValue(colName3,sector,layer,component); + setVector3D(key,new Vector3D(val1,val2,val3)); + } + private static synchronized void loadArray( + EBCCDBEnum key, + String tableName, + String[] colNames, + int sector,int layer,int component) { + Double vals[]=new Double[colNames.length]; + for (int ii=0; ii integerContainer=new HashMap(); + private HashMap doubleContainer=new HashMap(); + + EBDatabaseConstantProvider() { super(); } + EBDatabaseConstantProvider(int run, String var) { super(run,var); } + + int createIntegers (String table,int key) { + final int len=this.length(table); + Integer vals[]=new Integer[len]; + for (int ii=0; ii event builder is ready...."); return true; } From 229a443d8c42248843024fcc20a1b0a9d555c91a Mon Sep 17 00:00:00 2001 From: Joseph Newton Date: Sat, 19 Aug 2017 19:16:44 -0400 Subject: [PATCH 21/49] Hello --- reconstruction/eb/src/main/java/org/jlab/service/eb/joseph.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 reconstruction/eb/src/main/java/org/jlab/service/eb/joseph.txt diff --git a/reconstruction/eb/src/main/java/org/jlab/service/eb/joseph.txt b/reconstruction/eb/src/main/java/org/jlab/service/eb/joseph.txt new file mode 100644 index 0000000000..e965047ad7 --- /dev/null +++ b/reconstruction/eb/src/main/java/org/jlab/service/eb/joseph.txt @@ -0,0 +1 @@ +Hello From ccda2d86ee2d572df532cc7d22423f6d5a596123 Mon Sep 17 00:00:00 2001 From: Joseph Newton Date: Sat, 19 Aug 2017 21:09:30 -0400 Subject: [PATCH 22/49] remove the file --- reconstruction/eb/src/main/java/org/jlab/service/eb/joseph.txt | 1 - 1 file changed, 1 deletion(-) delete mode 100644 reconstruction/eb/src/main/java/org/jlab/service/eb/joseph.txt diff --git a/reconstruction/eb/src/main/java/org/jlab/service/eb/joseph.txt b/reconstruction/eb/src/main/java/org/jlab/service/eb/joseph.txt deleted file mode 100644 index e965047ad7..0000000000 --- a/reconstruction/eb/src/main/java/org/jlab/service/eb/joseph.txt +++ /dev/null @@ -1 +0,0 @@ -Hello From 95cb386a3608de6224912c33b9e3836e76d35522 Mon Sep 17 00:00:00 2001 From: Joseph Newton Date: Sat, 19 Aug 2017 21:19:30 -0400 Subject: [PATCH 23/49] Some Changes --- .../src/main/java/org/jlab/service/eb/EBEngine.java | 4 ++-- .../main/java/org/jlab/service/eb/EventBuilder.java | 13 +++++-------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/reconstruction/eb/src/main/java/org/jlab/service/eb/EBEngine.java b/reconstruction/eb/src/main/java/org/jlab/service/eb/EBEngine.java index abe1e95ad9..b74dc915fd 100644 --- a/reconstruction/eb/src/main/java/org/jlab/service/eb/EBEngine.java +++ b/reconstruction/eb/src/main/java/org/jlab/service/eb/EBEngine.java @@ -60,9 +60,9 @@ public boolean processDataEvent(DataEvent de) { // Add tracks List tracks = DetectorData.readDetectorTracks(de, trackType); - eb.addTracks(tracks); + eb.addForwardTracks(tracks); List ctracks = DetectorData.readCentralDetectorTracks(de, "CVTRec::Tracks"); - eb.addTracks(ctracks); + eb.addCentralTracks(ctracks); // Process tracks: eb.processHitMatching(); diff --git a/reconstruction/eb/src/main/java/org/jlab/service/eb/EventBuilder.java b/reconstruction/eb/src/main/java/org/jlab/service/eb/EventBuilder.java index 65442f75e3..553f2253e4 100644 --- a/reconstruction/eb/src/main/java/org/jlab/service/eb/EventBuilder.java +++ b/reconstruction/eb/src/main/java/org/jlab/service/eb/EventBuilder.java @@ -56,7 +56,7 @@ public void addTaggerResponses(List responses){ * and added to the detector event. * @param tracks */ - public void addTracks(List tracks) { + public void addForwardTracks(List tracks) { //for(DetectorTrack track : tracks){ for(int i = 0 ; i < tracks.size(); i++){ DetectorParticle particle = new DetectorParticle(tracks.get(i)); @@ -64,16 +64,13 @@ public void addTracks(List tracks) { } } - /* - public void addTBTracks(List tracks, List covMatrices) { - detectorEvent.clear(); + public void addCentralTracks(List tracks) { //for(DetectorTrack track : tracks){ for(int i = 0 ; i < tracks.size(); i++){ - DetectorParticle particle = new DetectorParticle(tracks.get(i), covMatrices.get(i)); + DetectorParticle particle = new DetectorParticle(tracks.get(i)); detectorEvent.addParticle(particle); } - - }*/ + } public void addTaggerTracks(List taggers) { //for(DetectorTrack track : tracks){ @@ -224,7 +221,7 @@ public void processNeutralTracks(){ pz*energy/EBConstants.ECAL_SAMPLINGFRACTION); int calorimeter_count = responsesPCAL.size() + responsesECIN.size() + responsesECOUT.size(); int scintillator_count = responsesFTOF1A.size() + responsesFTOF1B.size() + responsesFTOF2.size(); - if(calorimeter_count>1 && scintillator_count==0){ + if(calorimeter_count>0 && scintillator_count==0){ detectorEvent.addParticle(p); } } From 5b739cc6b9c3cbf219009697d315b0fd800d12c9 Mon Sep 17 00:00:00 2001 From: Joseph Newton Date: Mon, 21 Aug 2017 08:52:54 -0400 Subject: [PATCH 24/49] FT and Track Bank Changes --- .../org/jlab/clas/detector/DetectorData.java | 89 ++++++++++--------- .../jlab/clas/detector/DetectorParticle.java | 61 +++++-------- .../jlab/clas/detector/TaggerResponse.java | 62 ++++++++++--- 3 files changed, 117 insertions(+), 95 deletions(-) diff --git a/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorData.java b/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorData.java index 7ef0bc1310..5612541bae 100644 --- a/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorData.java +++ b/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorData.java @@ -269,23 +269,27 @@ public static DataBank getCherenkovResponseBank(List response return bank; } - public static DataBank getForwardTaggerBank(List responses, DataEvent event, String bank_name){ - DataBank bank = event.createBank(bank_name, responses.size()); - for(int row = 0; row < responses.size(); row++){ - TaggerResponse ft = responses.get(row); - bank.setShort("index", row, (short) 0); - bank.setShort("pindex", row, (short) 0); - bank.setShort("size", row, (short) 0); - bank.setFloat("x", row, (float) 0.0); - bank.setFloat("y", row, (float) 0.0); - bank.setFloat("z", row, (float) 0.0); - bank.setFloat("dx", row, (float) 0.0); - bank.setFloat("dy", row, (float) 0.0); - bank.setFloat("radius", row, (float) 0.0); + public static DataBank getForwardTaggerBank(List particles, DataEvent event, String bank_name, int rows){ + DataBank bank = event.createBank(bank_name, rows); + int row = 0; + for(int i = 0; i < particles.size(); i++){ + if(particles.get(i).getStatus()==100) { + DetectorParticle p = particles.get(i); + bank.setShort("index", row, (short) p.getTaggerIndex()); + bank.setShort("pindex", row, (short) i); + bank.setShort("size", row, (short) p.getTaggerSize()); + bank.setFloat("x", row, (float) p.getTaggerPosition().x()); + bank.setFloat("y", row, (float) p.getTaggerPosition().y()); + bank.setFloat("z", row, (float) p.getTaggerPosition().z()); + bank.setFloat("dx", row, (float) p.getTaggerPositionWidth().x()); + bank.setFloat("dy", row, (float) p.getTaggerPositionWidth().y()); + bank.setFloat("radius", row, (float) p.getTaggerRadius()); bank.setFloat("path", row, (float) 0.0); - bank.setFloat("time", row, (float) 0.0); - bank.setInt("energy", row, (int) 0.0); + bank.setFloat("time", row, (float) p.getTaggerTime()); + bank.setInt("energy", row, (int) p.getTaggerEnergy()); bank.setFloat("chi2", row, (float) 0.0); + row = row + 1; + } } return bank; } @@ -300,6 +304,30 @@ public static DataBank getEventBank(DetectorEvent detectorEvent, DataEvent event return bank; } + + public static DataBank getTracksBank(List particles, DataEvent event, String bank_name, int rows) { + DataBank bank = event.createBank(bank_name, rows); + int row = 0; + for(int i = 0 ; i < particles.size(); i++) { + DetectorParticle p = particles.get(row); + if(p.getStatus()==1) { + bank.setInt("index", row, p.getTrackIndex()); + bank.setInt("pindex", row, i); + bank.setInt("q", row, p.getCharge()); + bank.setFloat("chi2", row, (float) p.getChi2()); + bank.setFloat("ndf", row, (float) p.getNDF()); + bank.setFloat("px_nomm", row, (float) p.vector().x()); + bank.setFloat("py_nomm", row, (float) p.vector().y()); + bank.setFloat("pz_nomm", row, (float) p.vector().z()); + bank.setFloat("vx_nomm", row, (float) p.vertex().x()); + bank.setFloat("vy_nomm", row, (float) p.vertex().y()); + bank.setFloat("vz_nomom", row, (float) p.vertex().z()); + row = row + 1; + } + } + return bank; + } + public static DataBank getCrossBank(List particles, DataEvent event, String bank_name) { DataBank bank = event.createBank(bank_name, particles.size()); for(int row = 0 ; row < particles.size(); row++){ @@ -388,7 +416,7 @@ public static List readDetectorTracks(DataEvent event, String ba Vector3D pvec = DetectorData.readVector(bank, row, "p0_x", "p0_y", "p0_z"); Vector3D vertex = DetectorData.readVector(bank, row, "Vtx0_x", "Vtx0_y", "Vtx0_z"); - DetectorTrack track = new DetectorTrack(charge,pvec.mag()); + DetectorTrack track = new DetectorTrack(charge,pvec.mag(), (row+1)); track.setVector(pvec.x(), pvec.y(), pvec.z()); track.setVertex(vertex.x(), vertex.y(), vertex.z()); track.setPath(bank.getFloat("pathlength", row)); @@ -401,6 +429,10 @@ public static List readDetectorTracks(DataEvent event, String ba track.addCross(lc_vec.x(), lc_vec.y(), lc_vec.z(), lc_dir.x(), lc_dir.y(), lc_dir.z()); track.addCross(hc_vec.x(), hc_vec.y(), hc_vec.z(), hc_dir.x(), hc_dir.y(), hc_dir.z()); + track.setNDF(bank.getInt("ndf",row)); + track.setchi2(bank.getFloat("chi2",row)); + track.setStatus(bank.getInt("status",row)); + tracks.add(track); } } @@ -447,32 +479,7 @@ public static List readCentralDetectorTracks(DataEvent event, St return tracks; } - public static List readTaggerTracks(DataEvent event, String bank_name){ - List tracks = new ArrayList(); - if(event.hasBank(bank_name)==true){ - DataBank bank = event.getBank(bank_name); - int nrows = bank.rows(); - - for(int row = 0; row < nrows; row++){ - int charge = bank.getInt("q", row); - float cx = bank.getFloat("c_x", row); - float cy = bank.getFloat("c_y" , row); - float cz = bank.getFloat("c_z", row); - float energy = bank.getFloat("energy", row); - - Vector3D pvec = new Vector3D(cx*energy,cy*energy,cz*energy); - - DetectorTrack track = new DetectorTrack(charge,pvec.mag()); - track.setVertex(0.0, 0.0, 0.0); - track.setVector(cx*energy, cy*energy, cz*energy); - track.setTime(bank.getFloat("time", row)); - track.setID(bank.getInt("id",row)); - tracks.add(track); - } - } - return tracks; - } } diff --git a/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorParticle.java b/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorParticle.java index bdd8d5b2b6..acce0f904b 100644 --- a/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorParticle.java +++ b/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorParticle.java @@ -29,13 +29,15 @@ public class DetectorParticle implements Comparable { private Integer particlePID = 0; private Integer particleStatus = 1; + private Integer particleTrackIndex = -1; private Double particleBeta = 0.0; private Double particleMass = 0.0; private Double particleIDQuality = 0.0; - private Double particlePath = 0.0; + private Double particlePath = 0.0; private int particleScore = 0; // scores are assigned detector hits private double particleScoreChi2 = 0.0; // chi2 for particle score + private Vector3 particleCrossPosition = new Vector3(); private Vector3 particleCrossDirection = new Vector3(); @@ -67,8 +69,8 @@ public DetectorParticle(DetectorTrack track){ detectorTrack = track; } - public DetectorParticle(TaggerResponse taggers) { - taggerTrack = taggers; + public DetectorParticle(TaggerResponse tagger) { + taggerTrack = tagger; } public DetectorParticle(DetectorTrack track, double[] covMat) { @@ -178,43 +180,7 @@ public void addResponse(DetectorResponse res, boolean match){ res.setPath(this.getPathLength(res.getPosition())); } } - -// public void addResponse(CalorimeterResponse res, boolean match){ -// this.calorimeterStore.add(res); -// if(match==true){ -// Line3D distance = this.getDistance(res); -// -// res.getMatchedPosition().setXYZ( -// distance.midpoint().x(), -// distance.midpoint().y(),distance.midpoint().z()); -// -// /*Vector3D vec = new Vector3D( -// this.particleCrossPosition.x(), -// particleCrossPosition.y(), -// particleCrossPosition.z()); -// */ -// res.setPath(this.getPathLength(res.getPosition())); -// } -// } -// -// -// public void addResponse(ScintillatorResponse res, boolean match){ -// this.scintillatorStore.add(res); -// if(match==true){ -// Line3D distance = this.getDistance(res); -// -// res.getMatchedPosition().setXYZ( -// distance.midpoint().x(), -// distance.midpoint().y(),distance.midpoint().z()); -// -// /*Vector3D vec = new Vector3D( -// this.particleCrossPosition.x(), -// particleCrossPosition.y(), -// particleCrossPosition.z()); -// */ -// res.setPath(this.getPathLength(res.getPosition())); -// } -// } + public Particle getPhysicsParticle(int pid){ Particle particle = new Particle(pid, @@ -240,6 +206,10 @@ public Line3D getLowerCross(){ return this.driftChamberEnter; } + public int getTrackIndex() { + return this.detectorTrack.getTrackIndex(); + } + public double[] getTBCovariantMatrix() { return this.covMAT; } @@ -353,12 +323,23 @@ public DetectorResponse getHit(DetectorType type, int layer){ public double getBeta(){ return this.particleBeta;} + public double getNDF() {return this.detectorTrack.getNDF();} + public double getTrackChi2() {return this.detectorTrack.getchi2();} public int getStatus(){ return this.particleStatus;} public double getMass(){ return this.particleMass;} public int getPid(){ return this.particlePID;} public double getPidQuality() {return this.particleIDQuality;} public void setPidQuality(double q) {this.particleIDQuality = q;} + public Point3D getTaggerPosition() {return this.taggerTrack.getPosition();} + public Point3D getTaggerPositionWidth() {return this.taggerTrack.getPositionWidth();} + public double getTaggerRadius() {return this.taggerTrack.getRadius();} + public double getTaggerSize() {return this.taggerTrack.getSize();} + public double getTaggerIndex() {return this.taggerTrack.getHitIndex();} + public double getTaggerTime() {return this.taggerTrack.getTime();} + public double getTaggerEnergy() {return this.taggerTrack.getEnergy();} + + public Path3D getTrajectory(){ Path3D path = new Path3D(); //path.addPoint(this.particleCrossPosition.x(), diff --git a/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/TaggerResponse.java b/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/TaggerResponse.java index c6c297b7e0..41cf928e07 100644 --- a/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/TaggerResponse.java +++ b/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/TaggerResponse.java @@ -18,25 +18,37 @@ */ public class TaggerResponse { + + + private double hitTime = 0.0; private int hitID = -1; - private int hitCharge = -1; + private int hitSize = -1; + private double hitRadius = 0.0; private double hitEnergy = 0.0; private int association = -1; + private int hitIndex = -1; + private DetectorDescriptor descriptor = new DetectorDescriptor(); private Vector3D hitMomentum = new Vector3D(); - - public TaggerResponse setTime(double time) { hitTime = time; return this;} + private Point3D hitPosition = new Point3D(); + private Point3D hitWidth = new Point3D(); + public void setID(int id){ hitID = id;} - public void setCharge(int q){hitCharge = q;} + public void setTime(double time) {hitTime = time;} + public void setSize(int q){hitSize = q;} public void setEnergy(double energy) { hitEnergy = energy;} public void setAssociation(int assoc) {this.association = assoc;} + public void setHitIndex(int index) {this.hitIndex = index;} + public void setRadius(double r) {hitRadius = r;} - public int getCharge(){return hitCharge;} + public int getSize(){return hitSize;} public int getID(){return hitID;} public double getTime(){ return hitTime;} public double getEnergy(){ return hitEnergy;} public int getAssociation() {return this.association;} + public int getHitIndex() {return this.hitIndex;} + public double getRadius() {return this.hitRadius;} public Vector3D getMomentum(){ return this.hitMomentum; @@ -46,26 +58,48 @@ public void setMomentum(double px, double py, double pz){ this.hitMomentum.setXYZ(px, py, pz); } + public Point3D getPosition(){ + return this.hitPosition; + } + + public void setPosition(double x, double y, double z){ + this.hitPosition.set(x, y, z); + } + + public Point3D getPositionWidth(){ + return this.hitPosition; + } + + public void setPositionWidth(double x, double y, double z){ + this.hitWidth.set(x, y, z); + } + public static List readHipoEvent(DataEvent event, - String bankName){ + String bankName, DetectorType type){ List responseList = new ArrayList(); if(event.hasBank(bankName)==true){ DataBank bank = event.getBank(bankName); int nrows = bank.rows(); for(int row = 0; row < nrows; row++){ int id = bank.getInt("id", row); - int charge = bank.getInt("charge", row); - float cx = bank.getFloat("cx",row); - float cy = bank.getFloat("cy",row); - float cz = bank.getFloat("cz",row); - float time = bank.getFloat("time",row); - float energy = bank.getFloat("energy",row); + int size = bank.getInt("size", row); + double x = bank.getFloat("x",row); + double y = bank.getFloat("y",row); + double z = bank.getFloat("z",row); + double dx = bank.getFloat("widthX",row); + double dy = bank.getFloat("widthY",row); + double radius = bank.getFloat("radius", row); + double time = bank.getFloat("time",row); + double energy = bank.getFloat("energy",row); TaggerResponse ft = new TaggerResponse(); - ft.setCharge(charge); + + ft.setSize(size); ft.setID(id); ft.setEnergy(energy); + ft.setRadius(radius); ft.setTime(time); - ft.setMomentum(cx*energy, cy*energy, cz*energy); + ft.setHitIndex(row); + ft.setPosition(x, y, z); responseList.add(ft); } } From a7b0d8144f9b65dccb08113e09e122bd71b91761 Mon Sep 17 00:00:00 2001 From: Joseph Newton Date: Mon, 21 Aug 2017 08:54:31 -0400 Subject: [PATCH 25/49] FT and Track Bank --- .../eb/src/main/java/org/jlab/service/eb/EBEngine.java | 2 +- .../eb/src/main/java/org/jlab/service/eb/EventBuilder.java | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/reconstruction/eb/src/main/java/org/jlab/service/eb/EBEngine.java b/reconstruction/eb/src/main/java/org/jlab/service/eb/EBEngine.java index b74dc915fd..564b328326 100644 --- a/reconstruction/eb/src/main/java/org/jlab/service/eb/EBEngine.java +++ b/reconstruction/eb/src/main/java/org/jlab/service/eb/EBEngine.java @@ -50,7 +50,7 @@ public boolean processDataEvent(DataEvent de) { List responseHTCC = CherenkovResponse.readHipoEvent(de,"HTCC::rec",DetectorType.HTCC); List responseLTCC = CherenkovResponse.readHipoEvent(de,"LTCC::rec",DetectorType.LTCC); - List trackFT = TaggerResponse.readHipoEvent(de, "FT::particles"); + List trackFT = TaggerResponse.readHipoEvent(de, "FTCAL::clusters", DetectorType.FTCAL); eb.addDetectorResponses(responseFTOF); eb.addDetectorResponses(responseCTOF); diff --git a/reconstruction/eb/src/main/java/org/jlab/service/eb/EventBuilder.java b/reconstruction/eb/src/main/java/org/jlab/service/eb/EventBuilder.java index 553f2253e4..7206808f9f 100644 --- a/reconstruction/eb/src/main/java/org/jlab/service/eb/EventBuilder.java +++ b/reconstruction/eb/src/main/java/org/jlab/service/eb/EventBuilder.java @@ -13,6 +13,7 @@ import org.jlab.clas.detector.CherenkovResponse; import org.jlab.clas.detector.ScintillatorResponse; import org.jlab.clas.detector.TaggerResponse; +import org.jlab.clas.physics.Vector3; import org.jlab.geom.prim.Vector3D; /** @@ -75,10 +76,8 @@ public void addCentralTracks(List tracks) { public void addTaggerTracks(List taggers) { //for(DetectorTrack track : tracks){ for(int i = 0 ; i < taggers.size(); i++){ - int charge = taggers.get(i).getCharge(); - int id = taggers.get(i).getID(); - Vector3D momentum = taggers.get(i).getMomentum(); - DetectorParticle particle = new DetectorParticle(id,charge,momentum.x(),momentum.y(),momentum.z()); + DetectorParticle particle = new DetectorParticle(taggers.get(i)); + particle.setStatus(100); detectorEvent.addParticle(particle); } } From 90f8b43a31684b9baf10678fabb56cda57884aa2 Mon Sep 17 00:00:00 2001 From: Joseph Newton Date: Tue, 22 Aug 2017 11:19:52 -0400 Subject: [PATCH 26/49] FT and Tracks Bank --- .../java/org/jlab/service/eb/EBEngine.java | 21 ++++++++++++++++++- .../java/org/jlab/service/eb/EBHBEngine.java | 1 + .../java/org/jlab/service/eb/EBTBEngine.java | 1 + 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/reconstruction/eb/src/main/java/org/jlab/service/eb/EBEngine.java b/reconstruction/eb/src/main/java/org/jlab/service/eb/EBEngine.java index 564b328326..3f05955f11 100644 --- a/reconstruction/eb/src/main/java/org/jlab/service/eb/EBEngine.java +++ b/reconstruction/eb/src/main/java/org/jlab/service/eb/EBEngine.java @@ -25,6 +25,7 @@ public class EBEngine extends ReconstructionEngine { String crossBank = null; String matrixBank = null; String trackType = null; + String ftBank = null; public EBEngine(String name){ super(name,"gavalian","1.0"); @@ -68,7 +69,7 @@ public boolean processDataEvent(DataEvent de) { eb.processHitMatching(); eb.addTaggerTracks(trackFT); eb.processNeutralTracks(); - + //System.out.println("# of tracks " + tracks.size()); eb.assignTrigger(); EBRadioFrequency rf = new EBRadioFrequency(); @@ -77,6 +78,9 @@ public boolean processDataEvent(DataEvent de) { EBAnalyzer analyzer = new EBAnalyzer(); analyzer.processEvent(eb.getEvent()); + //System.out.println(eb.getEvent().toString()); + + if(eb.getEvent().getParticles().size()>0){ DataBank bankP = DetectorData.getDetectorParticleBank(eb.getEvent().getParticles(), de, particleBank); @@ -98,6 +102,17 @@ public boolean processDataEvent(DataEvent de) { DataBank bankChe = DetectorData.getCherenkovResponseBank(cherenkovs, de, cherenkovBank); de.appendBanks(bankChe); } + + if (ftBank!=null && trackFT.size()>0) { + DataBank bankForwardTagger = DetectorData.getForwardTaggerBank(eb.getEvent().getParticles(), de, trackBank, trackFT.size()); + de.appendBanks(bankForwardTagger); + } + + if (trackBank!=null && tracks.size()>0) { + DataBank bankTrack = DetectorData.getTracksBank(eb.getEvent().getParticles(), de, trackBank, tracks.size()); + de.appendBanks(bankTrack); + } + if(matrixBank!=null) { DataBank bankMat = DetectorData.getTBCovMatBank(eb.getEvent().getParticles(), de, matrixBank); de.appendBanks(bankMat); @@ -131,6 +146,10 @@ public void setCherenkovBank(String cherenkovBank) { public void setTrackBank(String trackBank) { this.trackBank = trackBank; } + + public void setFTBank(String ftBank) { + this.ftBank = ftBank; + } public void setCrossBank(String crossBank) { this.crossBank = crossBank; diff --git a/reconstruction/eb/src/main/java/org/jlab/service/eb/EBHBEngine.java b/reconstruction/eb/src/main/java/org/jlab/service/eb/EBHBEngine.java index b0f41240e4..ba260fbec8 100644 --- a/reconstruction/eb/src/main/java/org/jlab/service/eb/EBHBEngine.java +++ b/reconstruction/eb/src/main/java/org/jlab/service/eb/EBHBEngine.java @@ -22,6 +22,7 @@ public void initBankNames() { this.setTrackBank("RECHB::Track"); this.setCrossBank("RECHB::TrackCross"); this.setTrackType("HitBasedTrkg::HBTracks"); + this.setFTBank("RECHB::ForwardTagger"); } } diff --git a/reconstruction/eb/src/main/java/org/jlab/service/eb/EBTBEngine.java b/reconstruction/eb/src/main/java/org/jlab/service/eb/EBTBEngine.java index a095266bf8..e4e1c59a22 100644 --- a/reconstruction/eb/src/main/java/org/jlab/service/eb/EBTBEngine.java +++ b/reconstruction/eb/src/main/java/org/jlab/service/eb/EBTBEngine.java @@ -22,6 +22,7 @@ public void initBankNames() { this.setTrackBank("REC::Track"); this.setCrossBank("REC::TrackCross"); this.setTrackType("TimeBasedTrkg::TBTracks"); + this.setFTBank("REC::ForwardTagger"); } } From 3b85d291f47f88df13dcb00e79a0c05556d37069 Mon Sep 17 00:00:00 2001 From: Joseph Newton Date: Tue, 22 Aug 2017 12:21:24 -0400 Subject: [PATCH 27/49] DetectorTrack issue fixed --- .../org/jlab/clas/detector/DetectorTrack.java | 44 ++++++++++++------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorTrack.java b/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorTrack.java index 815c8d51cc..cbe1aa5d7a 100644 --- a/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorTrack.java +++ b/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorTrack.java @@ -13,22 +13,23 @@ */ public class DetectorTrack { + private int trackAssociation = -1; + private int trackIndex = -1; private int trackCharge = 0; private double trackMom = 0.0; private double trackPath = 0.0; private double taggerTime = 0.0; private int taggerID = 0; + private double trackchi2 = 0.0; + private int ndf = 0; + private int trackStatus = 0; private Vector3D trackEnd = new Vector3D(); private Vector3 trackP = new Vector3(); private Vector3 trackVertex = new Vector3(); // private Point3D trackIntersect = new Point3D(); - - private double variable1 = 0.0; - private int variable2 = -1; - - + private List trackCrosses = new ArrayList(); // private List ctofIntersects = new ArrayList(); @@ -37,15 +38,18 @@ public class DetectorTrack { public DetectorTrack(int charge){ this.trackCharge = charge; } - - public double getVariable1() { - return variable1; - } + public DetectorTrack(int charge, double mom){ this.trackMom = mom; this.trackCharge = charge; } + + public DetectorTrack(int charge, double mom, int index){ + this.trackMom = mom; + this.trackCharge = charge; + this.trackIndex = index; + } // public DetectorTrack(int charge, double mom, Point3D ctofintersect){ // this.trackMom = mom; @@ -111,20 +115,22 @@ public DetectorTrack setTrackEnd(double x, double y, double z){ return this; } -// public void setTrackIntersect(Point3D inter) { -// this.trackIntersect = inter; -// } - -// public Point3D getTrackIntersect() { -// return this.ctofIntersects.get(0); -// } + public void setNDF(int x) {this.ndf = x;} + public void setStatus(int x) {this.trackStatus = x;} + public void setchi2(double x) {this.trackchi2 = x;} + public void setAssociation(int x) {this.trackAssociation = x;} public int getCharge() { return trackCharge;} - public double getP() { return trackP.mag();} + public int getNDF() {return ndf;} + public int getStatus() {return trackStatus;} + public double getchi2() {return trackchi2;} + public double getP() { return trackP.mag();} + public int getID() {return this.taggerID;} public double getPath() { return trackPath;} public Vector3 getVector() { return this.trackP;} public Vector3 getVertex() { return this.trackVertex;} public Vector3D getTrackEnd() { return trackEnd;} + public int getAssociation() {return trackAssociation;} public void addCross(double x, double y, double z, @@ -153,6 +159,10 @@ public Line3D getFirstCross(){ return trackCrosses.get(0); } + public int getTrackIndex() { + return this.trackIndex; + } + public Line3D getLastCross(){ return this.trackCrosses.get(this.trackCrosses.size()-1); } From 8d8deb2cd5f0fa7a4752f5e5bf031118e4e37cf2 Mon Sep 17 00:00:00 2001 From: Joseph Newton Date: Tue, 22 Aug 2017 14:37:15 -0400 Subject: [PATCH 28/49] EB Update --- .../eb/src/main/java/org/jlab/service/eb/EventBuilder.java | 1 + 1 file changed, 1 insertion(+) diff --git a/reconstruction/eb/src/main/java/org/jlab/service/eb/EventBuilder.java b/reconstruction/eb/src/main/java/org/jlab/service/eb/EventBuilder.java index 7206808f9f..f37bd17fe9 100644 --- a/reconstruction/eb/src/main/java/org/jlab/service/eb/EventBuilder.java +++ b/reconstruction/eb/src/main/java/org/jlab/service/eb/EventBuilder.java @@ -61,6 +61,7 @@ public void addForwardTracks(List tracks) { //for(DetectorTrack track : tracks){ for(int i = 0 ; i < tracks.size(); i++){ DetectorParticle particle = new DetectorParticle(tracks.get(i)); + particle.setStatus(1); detectorEvent.addParticle(particle); } } From 7feb3ed0a655b3eeff6c7f26227aa1eced068e96 Mon Sep 17 00:00:00 2001 From: Joseph Newton Date: Tue, 22 Aug 2017 15:43:41 -0400 Subject: [PATCH 29/49] DetectorData.java --- .../java/org/jlab/clas/detector/DetectorData.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorData.java b/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorData.java index 5612541bae..a0580c9810 100644 --- a/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorData.java +++ b/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorData.java @@ -309,19 +309,20 @@ public static DataBank getTracksBank(List particles, DataEvent DataBank bank = event.createBank(bank_name, rows); int row = 0; for(int i = 0 ; i < particles.size(); i++) { + //System.err.println(particles.size() + " " + rows + " " + i + " " + row); DetectorParticle p = particles.get(row); if(p.getStatus()==1) { - bank.setInt("index", row, p.getTrackIndex()); - bank.setInt("pindex", row, i); - bank.setInt("q", row, p.getCharge()); + bank.setShort("index", row, (short) p.getTrackIndex()); + bank.setShort("pindex", row, (short) i); + bank.setByte("q", row, (byte) p.getCharge()); bank.setFloat("chi2", row, (float) p.getChi2()); - bank.setFloat("ndf", row, (float) p.getNDF()); + bank.setShort("NDF", row, (short) p.getNDF()); bank.setFloat("px_nomm", row, (float) p.vector().x()); bank.setFloat("py_nomm", row, (float) p.vector().y()); bank.setFloat("pz_nomm", row, (float) p.vector().z()); bank.setFloat("vx_nomm", row, (float) p.vertex().x()); bank.setFloat("vy_nomm", row, (float) p.vertex().y()); - bank.setFloat("vz_nomom", row, (float) p.vertex().z()); + bank.setFloat("vz_nomm", row, (float) p.vertex().z()); row = row + 1; } } From 1b8873c216977cff5066d99d5574b06a0e1cace1 Mon Sep 17 00:00:00 2001 From: Joseph Newton Date: Wed, 23 Aug 2017 14:27:44 -0400 Subject: [PATCH 30/49] DetectorTrack.java --- .../src/main/java/org/jlab/clas/detector/DetectorData.java | 4 +++- .../main/java/org/jlab/clas/detector/DetectorParticle.java | 1 + .../src/main/java/org/jlab/clas/detector/DetectorTrack.java | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorData.java b/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorData.java index a0580c9810..b932189bb9 100644 --- a/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorData.java +++ b/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorData.java @@ -311,13 +311,14 @@ public static DataBank getTracksBank(List particles, DataEvent for(int i = 0 ; i < particles.size(); i++) { //System.err.println(particles.size() + " " + rows + " " + i + " " + row); DetectorParticle p = particles.get(row); - if(p.getStatus()==1) { + if(p.getTrackDetector()==13) { bank.setShort("index", row, (short) p.getTrackIndex()); bank.setShort("pindex", row, (short) i); bank.setByte("q", row, (byte) p.getCharge()); bank.setFloat("chi2", row, (float) p.getChi2()); bank.setShort("NDF", row, (short) p.getNDF()); bank.setFloat("px_nomm", row, (float) p.vector().x()); + System.out.println("Px is " + p.vector().x()); bank.setFloat("py_nomm", row, (float) p.vector().y()); bank.setFloat("pz_nomm", row, (float) p.vector().z()); bank.setFloat("vx_nomm", row, (float) p.vertex().x()); @@ -433,6 +434,7 @@ public static List readDetectorTracks(DataEvent event, String ba track.setNDF(bank.getInt("ndf",row)); track.setchi2(bank.getFloat("chi2",row)); track.setStatus(bank.getInt("status",row)); + track.setDetectorID(13); tracks.add(track); } diff --git a/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorParticle.java b/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorParticle.java index fed4075e13..8ba4eed06b 100644 --- a/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorParticle.java +++ b/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorParticle.java @@ -326,6 +326,7 @@ public DetectorResponse getHit(DetectorType type, int layer){ public double getNDF() {return this.detectorTrack.getNDF();} public double getTrackChi2() {return this.detectorTrack.getchi2();} public int getStatus(){ return this.particleStatus;} + public int getTrackDetector() {return this.detectorTrack.getDetectorID();} public double getMass(){ return this.particleMass;} public int getPid(){ return this.particlePID;} public double getPidQuality() {return this.particleIDQuality;} diff --git a/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorTrack.java b/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorTrack.java index cbe1aa5d7a..179b661b60 100644 --- a/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorTrack.java +++ b/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorTrack.java @@ -23,6 +23,7 @@ public class DetectorTrack { private double trackchi2 = 0.0; private int ndf = 0; private int trackStatus = 0; + private int trackDetectorID = -1; private Vector3D trackEnd = new Vector3D(); private Vector3 trackP = new Vector3(); @@ -119,6 +120,7 @@ public DetectorTrack setTrackEnd(double x, double y, double z){ public void setStatus(int x) {this.trackStatus = x;} public void setchi2(double x) {this.trackchi2 = x;} public void setAssociation(int x) {this.trackAssociation = x;} + public void setDetectorID(int id) {this.trackDetectorID = id;} public int getCharge() { return trackCharge;} public int getNDF() {return ndf;} @@ -131,6 +133,7 @@ public DetectorTrack setTrackEnd(double x, double y, double z){ public Vector3 getVertex() { return this.trackVertex;} public Vector3D getTrackEnd() { return trackEnd;} public int getAssociation() {return trackAssociation;} + public int getDetectorID() {return trackDetectorID;} public void addCross(double x, double y, double z, From 7274c6ace83768a4136fb65889aeb2b79198072b Mon Sep 17 00:00:00 2001 From: Nathan Baltzell Date: Thu, 24 Aug 2017 10:43:28 -0400 Subject: [PATCH 31/49] unit-tests: enable check on REC::Track --- validation/unit-tests/src/eb/EBReconstructionTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/validation/unit-tests/src/eb/EBReconstructionTest.java b/validation/unit-tests/src/eb/EBReconstructionTest.java index 6d6784a5e4..14cd2b4a88 100644 --- a/validation/unit-tests/src/eb/EBReconstructionTest.java +++ b/validation/unit-tests/src/eb/EBReconstructionTest.java @@ -74,7 +74,7 @@ public void testEBReconstruction() { processAllEngines(electronEvent); assertEquals(electronEvent.hasBank("REC::Event"), true); assertEquals(electronEvent.hasBank("REC::Particle"), true); - //assertEquals(electronEvent.hasBank("REC::Tracks"), true); + assertEquals(electronEvent.hasBank("REC::Track"), true); //assertEquals(electronEvent.hasBank("REC::Cherenkov"), true); //assertEquals(electronEvent.hasBank("REC::Scintillator"), true); From 29a964a88a6ab87465ad49892aa11e579e1d88ed Mon Sep 17 00:00:00 2001 From: Nathan Baltzell Date: Thu, 24 Aug 2017 10:46:22 -0400 Subject: [PATCH 32/49] run-eb-test.sh: run recon outside of clara, do NOT use clas12 libs that come with clara --- validation/advanced-tests/run-eb-tests.sh | 50 +++++++++++++++-------- 1 file changed, 33 insertions(+), 17 deletions(-) diff --git a/validation/advanced-tests/run-eb-tests.sh b/validation/advanced-tests/run-eb-tests.sh index 732e0a71ba..94cbb6b124 100755 --- a/validation/advanced-tests/run-eb-tests.sh +++ b/validation/advanced-tests/run-eb-tests.sh @@ -12,18 +12,31 @@ fi # last argument is input file stub: webFileStub="${@: -1}" - -# valid input file stubs: -#webFileStub=electronproton -#webFileStub=electronpion -#webFileStub=electronkaon +case $webFileStub in + electronproton) + ;; + electronkaon) + ;; + electronpion) + ;; + *) + echo Invalid input evio file: $webFileStub + exit 1 +esac # set up environment CLARA_HOME=$PWD/clara_installation/ ; export CLARA_HOME -COAT=$CLARA_HOME/plugins/clas12/ + +# Do NOT use whatever clas12 libraries come with CLARA for testing: +#COAT=$CLARA_HOME/plugins/clas12/ + +# Use the ones in this clas12 build for testing: +COAT=../../coatjava + classPath="$COAT/lib/services/*:$COAT/lib/clas/*:$COAT/lib/utils/*:../lib/*:src/" webDir=http://clasweb.jlab.org/clas12offline/distribution/coatjava/validation_files/eb/v0/ + # compile test codes before anything else: javac -cp $classPath src/eb/EBTwoTrackTest.java @@ -62,18 +75,21 @@ then # convert to hipo $COAT/bin/evio2hipo -o ${webFileStub}.hipo ${webFileStub}.evio + # run reconstruction without clara + ../../coatjava/bin/notsouseful-util -i ${webFileStub}.hipo -o out_${webFileStub}.hipo -c 2 + # run reconstruction with clara - echo "set inputDir $PWD/" > cook.clara - echo "set outputDir $PWD/" >> cook.clara - echo "set threads 7" >> cook.clara - echo "set javaMemory 2" >> cook.clara - echo "set session s_cook" >> cook.clara - echo "set description d_cook" >> cook.clara - ls ${webFileStub}.hipo > files.list - echo "set fileList $PWD/files.list" >> cook.clara - echo "run local" >> cook.clara - echo "exit" >> cook.clara - $CLARA_HOME/bin/clara-shell cook.clara + #echo "set inputDir $PWD/" > cook.clara + #echo "set outputDir $PWD/" >> cook.clara + #echo "set threads 7" >> cook.clara + #echo "set javaMemory 2" >> cook.clara + #echo "set session s_cook" >> cook.clara + #echo "set description d_cook" >> cook.clara + #ls ${webFileStub}.hipo > files.list + #echo "set fileList $PWD/files.list" >> cook.clara + #echo "run local" >> cook.clara + #echo "exit" >> cook.clara + #$CLARA_HOME/bin/clara-shell cook.clara fi # run KppTracking junit tests From 22a426fd251b2466f98b2295b5abca54a008113b Mon Sep 17 00:00:00 2001 From: Joseph Newton Date: Thu, 24 Aug 2017 11:18:04 -0400 Subject: [PATCH 33/49] EventBuilder.java --- .../eb/src/main/java/org/jlab/service/eb/EventBuilder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reconstruction/eb/src/main/java/org/jlab/service/eb/EventBuilder.java b/reconstruction/eb/src/main/java/org/jlab/service/eb/EventBuilder.java index f37bd17fe9..d59fd5fa92 100644 --- a/reconstruction/eb/src/main/java/org/jlab/service/eb/EventBuilder.java +++ b/reconstruction/eb/src/main/java/org/jlab/service/eb/EventBuilder.java @@ -61,7 +61,7 @@ public void addForwardTracks(List tracks) { //for(DetectorTrack track : tracks){ for(int i = 0 ; i < tracks.size(); i++){ DetectorParticle particle = new DetectorParticle(tracks.get(i)); - particle.setStatus(1); + //particle.setStatus(1); detectorEvent.addParticle(particle); } } From 1b5a28e7395bf8bda4c017581db01d2c49adf144 Mon Sep 17 00:00:00 2001 From: Joseph Newton Date: Thu, 24 Aug 2017 11:27:00 -0400 Subject: [PATCH 34/49] DetectorData.java --- .../src/main/java/org/jlab/clas/detector/DetectorData.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorData.java b/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorData.java index b932189bb9..3cefaa81c4 100644 --- a/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorData.java +++ b/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorData.java @@ -318,7 +318,7 @@ public static DataBank getTracksBank(List particles, DataEvent bank.setFloat("chi2", row, (float) p.getChi2()); bank.setShort("NDF", row, (short) p.getNDF()); bank.setFloat("px_nomm", row, (float) p.vector().x()); - System.out.println("Px is " + p.vector().x()); + //System.out.println("Px is " + p.vector().x()); bank.setFloat("py_nomm", row, (float) p.vector().y()); bank.setFloat("pz_nomm", row, (float) p.vector().z()); bank.setFloat("vx_nomm", row, (float) p.vertex().x()); @@ -418,7 +418,7 @@ public static List readDetectorTracks(DataEvent event, String ba Vector3D pvec = DetectorData.readVector(bank, row, "p0_x", "p0_y", "p0_z"); Vector3D vertex = DetectorData.readVector(bank, row, "Vtx0_x", "Vtx0_y", "Vtx0_z"); - DetectorTrack track = new DetectorTrack(charge,pvec.mag(), (row+1)); + DetectorTrack track = new DetectorTrack(charge,pvec.mag(), (row)); track.setVector(pvec.x(), pvec.y(), pvec.z()); track.setVertex(vertex.x(), vertex.y(), vertex.z()); track.setPath(bank.getFloat("pathlength", row)); From f94bd08b2de8086efc315b78de4e7d423d7d83aa Mon Sep 17 00:00:00 2001 From: Joseph Newton Date: Thu, 24 Aug 2017 11:42:21 -0400 Subject: [PATCH 35/49] DetectorData.java --- .../src/main/java/org/jlab/clas/detector/DetectorData.java | 1 + 1 file changed, 1 insertion(+) diff --git a/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorData.java b/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorData.java index 3cefaa81c4..16efcdb452 100644 --- a/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorData.java +++ b/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorData.java @@ -314,6 +314,7 @@ public static DataBank getTracksBank(List particles, DataEvent if(p.getTrackDetector()==13) { bank.setShort("index", row, (short) p.getTrackIndex()); bank.setShort("pindex", row, (short) i); + bank.setByte("detector", row, (byte) p.getTrackDetector()); bank.setByte("q", row, (byte) p.getCharge()); bank.setFloat("chi2", row, (float) p.getChi2()); bank.setShort("NDF", row, (short) p.getNDF()); From 89db2b589de01fd8410e6dc83e4d077bbedac21f Mon Sep 17 00:00:00 2001 From: Joseph Newton Date: Thu, 24 Aug 2017 12:29:38 -0400 Subject: [PATCH 36/49] DetectorData.java --- .../src/main/java/org/jlab/clas/detector/DetectorData.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorData.java b/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorData.java index 16efcdb452..f4939cdeb2 100644 --- a/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorData.java +++ b/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorData.java @@ -310,7 +310,7 @@ public static DataBank getTracksBank(List particles, DataEvent int row = 0; for(int i = 0 ; i < particles.size(); i++) { //System.err.println(particles.size() + " " + rows + " " + i + " " + row); - DetectorParticle p = particles.get(row); + DetectorParticle p = particles.get(i); if(p.getTrackDetector()==13) { bank.setShort("index", row, (short) p.getTrackIndex()); bank.setShort("pindex", row, (short) i); From a2fa59783f12bddb9adb78c552f542efb807e72b Mon Sep 17 00:00:00 2001 From: Nathan Baltzell Date: Thu, 24 Aug 2017 14:23:25 -0400 Subject: [PATCH 37/49] unit-tests: add eb test on index pointer validity --- .../src/eb/EBReconstructionTest.java | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/validation/unit-tests/src/eb/EBReconstructionTest.java b/validation/unit-tests/src/eb/EBReconstructionTest.java index 14cd2b4a88..77b69f8a30 100644 --- a/validation/unit-tests/src/eb/EBReconstructionTest.java +++ b/validation/unit-tests/src/eb/EBReconstructionTest.java @@ -5,6 +5,7 @@ import events.TestEvent; +import org.jlab.io.base.DataBank; import org.jlab.io.base.DataEvent; import org.jlab.service.dc.DCHBEngine; import org.jlab.service.dc.DCTBEngine; @@ -58,6 +59,35 @@ public void processAllEngines(DataEvent ev) { ev.show(); } + /** + * + * Check that index references are within valid range + * + * bankNameFrom - bank containing the index + * bankNameTo - bank to which the index refers + * idxVarName - name of the index variable + * + */ + public boolean hasValidRefs(DataEvent ev, + String bankNameFrom, + String bankNameTo, + String idxVarName) { + DataBank bFrom=ev.getBank(bankNameFrom); + DataBank bTo=ev.getBank(bankNameTo); + for (int ii=0; ii=bTo.rows() || ref<0) { + bFrom.show(); + bTo.show(); + System.err.println(String.format( + "\bnhasValidRefs: failed on (%s0>%s) %d->%d\n", + bankNameFrom,bankNameTo,ii,ref)); + return false; + } + } + return true; + } + @Test public void testEBReconstruction() { @@ -69,12 +99,14 @@ public void testEBReconstruction() { assertEquals(photonEvent.hasBank("REC::Event"), true); assertEquals(photonEvent.hasBank("REC::Particle"), true); assertEquals(photonEvent.hasBank("REC::Calorimeter"), true); + assertEquals(hasValidRefs(photonEvent,"REC::Calorimeter","REC::Particle","pindex"),true); DataEvent electronEvent = TestEvent.getDCSector1ElectronEvent(); processAllEngines(electronEvent); assertEquals(electronEvent.hasBank("REC::Event"), true); assertEquals(electronEvent.hasBank("REC::Particle"), true); assertEquals(electronEvent.hasBank("REC::Track"), true); + assertEquals(hasValidRefs(photonEvent,"REC::Track","TimeBasedTrkg::TBTracks","index"),true); //assertEquals(electronEvent.hasBank("REC::Cherenkov"), true); //assertEquals(electronEvent.hasBank("REC::Scintillator"), true); From df67d82e107002a49e1fee431a60d084aa0f58ca Mon Sep 17 00:00:00 2001 From: baltzell Date: Thu, 24 Aug 2017 18:28:15 -0400 Subject: [PATCH 38/49] EBCCDBConstants.java: FTOF Panel2 is layer=3 --- .../eb/src/main/java/org/jlab/rec/eb/EBCCDBConstants.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reconstruction/eb/src/main/java/org/jlab/rec/eb/EBCCDBConstants.java b/reconstruction/eb/src/main/java/org/jlab/rec/eb/EBCCDBConstants.java index 763ec13a56..cd9c945fc7 100644 --- a/reconstruction/eb/src/main/java/org/jlab/rec/eb/EBCCDBConstants.java +++ b/reconstruction/eb/src/main/java/org/jlab/rec/eb/EBCCDBConstants.java @@ -179,7 +179,7 @@ public static final synchronized void load(int run,ConstantsManager manager) { loadDouble(EBCCDBEnum.FTOF_MATCHING_2,"ftof_matching","dx",0,0,0); loadVector3D(EBCCDBEnum.FTOF1A_hitRes,"ftof_matching","dx","dy","dz",0,1,0); loadVector3D(EBCCDBEnum.FTOF1B_hitRes,"ftof_matching","dx","dy","dz",0,2,0); - loadVector3D(EBCCDBEnum.FTOF2_hitRes,"ftof_matching","dx","dy","dz",0,0,0); + loadVector3D(EBCCDBEnum.FTOF2_hitRes,"ftof_matching","dx","dy","dz",0,3,0); loadDouble(EBCCDBEnum.HTCC_TimingRes,"htcc_matching","dt",0,0,0); loadDouble(EBCCDBEnum.HTCC_NPHE_CUT,"htcc_matching","nphe",0,0,0); From 28ce6397cf188774511bc1b7488951d6bb933b49 Mon Sep 17 00:00:00 2001 From: baltzell Date: Thu, 24 Aug 2017 20:57:58 -0400 Subject: [PATCH 39/49] eb: defunct neutral trigger for now --- .../jlab/clas/detector/DetectorHeader.java | 2 +- .../java/org/jlab/service/eb/EBAnalyzer.java | 87 +++++++++++++------ .../advanced-tests/src/eb/EBTwoTrackTest.java | 2 +- 3 files changed, 61 insertions(+), 30 deletions(-) diff --git a/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorHeader.java b/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorHeader.java index 33400e3850..2b76d129a0 100644 --- a/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorHeader.java +++ b/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorHeader.java @@ -10,7 +10,7 @@ public class DetectorHeader { private int event = 0; private int trigger = 0; private double rfTime = 0.0; - private double startTime = 0.0; + private double startTime = -1000.0; public DetectorHeader() { } diff --git a/reconstruction/eb/src/main/java/org/jlab/service/eb/EBAnalyzer.java b/reconstruction/eb/src/main/java/org/jlab/service/eb/EBAnalyzer.java index d819de77f5..949209794c 100644 --- a/reconstruction/eb/src/main/java/org/jlab/service/eb/EBAnalyzer.java +++ b/reconstruction/eb/src/main/java/org/jlab/service/eb/EBAnalyzer.java @@ -10,39 +10,59 @@ import org.jlab.clas.pdg.PhysicsConstants; /** - * * @author gavalian + * @author jnewton + * @author devita + * @author baltzell */ public class EBAnalyzer { private int[] pidPositive = new int[]{-11, 211, 321, 2212}; private int[] pidNegative = new int[]{ 11, -211,-321,-2212}; - public EBAnalyzer(){ - - } + public EBAnalyzer(){} public void processEvent(DetectorEvent event) { - if(event.getParticles().size()>0){ - DetectorParticle trigger = event.getParticle(0); - if(trigger.getPid()==11 || trigger.getPid()==-11){ - trigger.setBeta(1.0); - trigger.setMass(PhysicsConstants.massElectron()); + // abort, rely on default init of DetectorEvent: + if (event.getParticles().size() <= 0) return; - double time = 0.0; - double path = 0.0; + // first particle is designated as the "trigger" particle: + // TODO: reference the code that actually does the sorting + DetectorParticle trigger = event.getParticle(0); - if(trigger.hasHit(DetectorType.FTOF, 1)==true){ - time = trigger.getTime(DetectorType.FTOF, 1); - path = trigger.getPathLength(DetectorType.FTOF, 1); - } + // priority is to identify a trigger time: + boolean foundTriggerTime=false; + double startTime=-1000; - if(trigger.hasHit(DetectorType.FTOF, 2)==true){ - time = trigger.getTime(DetectorType.FTOF, 2); - path = trigger.getPathLength(DetectorType.FTOF, 2); - } + // electron/positron is trigger particle: + if (trigger.getPid()==11 || trigger.getPid()==-11) { + + trigger.setBeta(1.0); + trigger.setMass(PhysicsConstants.massElectron()); + double time = 0.0; + double path = 0.0; + + // TODO: get these hardcoded FTOF "layer" 1/2/3 constants out of here. + // Should be from DetectorType instead, and similarly for for ECAL/PCAL's 1/4/7 (e.g. in EBCCDB) + + // prefer FTOF Panel 1B: + if (trigger.hasHit(DetectorType.FTOF, 2)==true){ + time = trigger.getTime(DetectorType.FTOF, 2); + path = trigger.getPathLength(DetectorType.FTOF, 2); + foundTriggerTime = true; + } + + // else use FTOF Panel 1A: + else if (trigger.hasHit(DetectorType.FTOF, 1)==true){ + time = trigger.getTime(DetectorType.FTOF, 1); + path = trigger.getPathLength(DetectorType.FTOF, 1); + foundTriggerTime = true; + } + + // set startTime based on FTOF: + if (foundTriggerTime) { double tof = path/PhysicsConstants.speedOfLight(); double start_time = time - tof; double deltatr = - start_time + event.getEventHeader().getRfTime() @@ -51,19 +71,30 @@ public void processEvent(DetectorEvent event) { // - (EBConstants.TARGET_POSITION))/(PhysicsConstants.speedOfLight())*/ // + (EBConstants.RF_LARGE_INTEGER+0.5)*EBConstants.RF_BUCKET_LENGTH + EBConstants.RF_OFFSET; double rfcorr = deltatr%EBConstants.RF_BUCKET_LENGTH - EBConstants.RF_BUCKET_LENGTH/2;//RF correction term - event.getEventHeader().setStartTime(start_time + rfcorr); - - this.assignMasses(event); - this.assignPids(event); + startTime = start_time + rfcorr; } + } - if(trigger.getPid()==0 || trigger.getPid()==22) { - event.getEventHeader().setStartTime(EBConstants.GEMC_STARTTIME); - this.assignMasses(event); - this.assignPids(event); - } + // neutral is trigger particle: + else if (trigger.getPid()==0 || trigger.getPid()==22) { + trigger.setBeta(1.0); + trigger.setMass(0.0); + // TODO: implement full neutral trigger start time + //startTime = EBConstants.GEMC_STARTTIME; + //foundTriggerTime=true; + } + + // trigger particle is unkown: + else { + } + // we found event start time, so set it and do pid: + if (foundTriggerTime) { + event.getEventHeader().setStartTime(startTime); + this.assignMasses(event); + this.assignPids(event); } + } diff --git a/validation/advanced-tests/src/eb/EBTwoTrackTest.java b/validation/advanced-tests/src/eb/EBTwoTrackTest.java index 76738e1575..54044743f3 100644 --- a/validation/advanced-tests/src/eb/EBTwoTrackTest.java +++ b/validation/advanced-tests/src/eb/EBTwoTrackTest.java @@ -93,7 +93,7 @@ private void checkResults() { // some global efficiency tests: assertEquals(eEff>0.9,true); - if (hadronPDG==2212) assertEquals(pEff>0.80,true); + if (hadronPDG==2212) assertEquals(pEff>0.77,true); else if (hadronPDG==321) assertEquals(kEff>0.42,true); else if (hadronPDG==211) assertEquals(piEff>0.75,true); } From 41f00687b4b665fdd5efa797a5c65ccfbc4dab4e Mon Sep 17 00:00:00 2001 From: Nathan Baltzell Date: Thu, 31 Aug 2017 19:10:12 -0400 Subject: [PATCH 40/49] CherenkovResponse.java: cast nphe->float for HTCC, remove hardcoded DetectorType=HTCC, temporary kludges to unify LTCC/HTCC, choose cross differently for HTCC/LTCC --- .../jlab/clas/detector/CherenkovResponse.java | 63 ++++++++++++------- .../jlab/clas/detector/DetectorParticle.java | 18 +++++- 2 files changed, 57 insertions(+), 24 deletions(-) diff --git a/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/CherenkovResponse.java b/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/CherenkovResponse.java index 90c3de5c37..1349fd7ae5 100644 --- a/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/CherenkovResponse.java +++ b/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/CherenkovResponse.java @@ -21,7 +21,7 @@ public class CherenkovResponse { private double hitTime = 0.0; private double hitTheta = 0.0; private double hitPhi = 0.0; - private int hitNphe = 0; + private double hitNphe = 0; private double hitDeltaPhi = 0.0; private double hitDeltaTheta = 0.0; private int hitIndex = -1; @@ -39,13 +39,13 @@ public CherenkovResponse(double theta, double phi, double dtheta, double dphi){ } public CherenkovResponse setTime(double time) { hitTime = time; return this;} - public CherenkovResponse setEnergy(int energy) { hitNphe = energy; return this;} + public CherenkovResponse setEnergy(double energy) { hitNphe = energy; return this;} public void setAssociation(int assoc) {this.association = assoc;} public void setHitIndex(int index){this.hitIndex = index;} public double getTime(){ return hitTime;} public int getHitIndex(){return hitIndex;} - public int getEnergy(){ return hitNphe;} + public double getEnergy(){ return hitNphe;} public double getTheta() {return this.hitTheta;} public double getPhi() {return this.hitPhi;} public double getDeltaTheta(){ return this.hitDeltaTheta;} @@ -73,18 +73,10 @@ public boolean match(Line3D particletrack){ Point3D intersection = this.getIntersection(particletrack); Vector3D vecRec = intersection.toVector3D(); Vector3D vecHit = this.hitPosition.toVector3D(); - //System.out.println(particletrack); - //System.out.println(this.hitPosition); - //System.out.println("Calculated Theta Difference (Degrees)" + Math.abs(vecHit.theta()-vecRec.theta())*57.2958); - //System.out.println("Expected Theta Difference (Degrees)" + this.hitDeltaTheta*57.2958); - //System.out.println(" "); - //System.out.println("Calculated Phi Difference (Degrees)" + Math.abs(vecHit.phi()-vecRec.phi())*57.2958); - //System.out.println("Expected Phi Difference (Degrees)" + this.hitDeltaPhi*57.2958); - //System.out.println(" "); - - //System.out.println(Math.abs(vecHit.theta()-vecRec.theta())*57.2958 + " " + - //Math.abs(vecHit.phi()-vecRec.phi())*57.2958); - + // FIXME: + // 1. remove hardcoded constant (10 degrees) + // 2. either use both dphi and dtheta from detector bank (only + // exists for HTCC), or get both from CCDB return (Math.abs(vecHit.theta()-vecRec.theta())<10.0/57.2958 && Math.abs(vecHit.phi()-vecRec.phi()) readHipoEvent(DataEvent event, DataBank bank = event.getBank(bankName); int nrows = bank.rows(); for(int row = 0; row < nrows; row++){ - int nphe = bank.getInt("nphe", row); - double theta = bank.getFloat("theta", row); - double dtheta = bank.getFloat("dtheta",row); - double phi = bank.getFloat("phi",row); - double dphi = bank.getFloat("dphi",row); + double x = bank.getFloat("x",row); double y = bank.getFloat("y",row); double z = bank.getFloat("z",row); double time = bank.getFloat("time",row); + + // FIXME: unify LTCC/HTCC detector banks + // Here we have to treat them differently: + // 1. nphe really shouldn't be an integer + // 2. either add dtheta/dphi to LTCC, or ignore HTCC's and use CCDB for both + // 3. HTCC provides both x/y/z and theta/phi, while LTCC provides only x/y/z. + // The current convention in EB is to use only x/y/z, while theta/phi is + // just propogated. + + double nphe,theta=0,phi=0,dtheta=0,dphi=0; + + if (type==DetectorType.HTCC) { + nphe = (double)bank.getInt("nphe", row); + dtheta = bank.getFloat("dtheta",row); + dphi = bank.getFloat("dphi",row); + theta = bank.getFloat("theta", row); + phi = bank.getFloat("phi",row); + } + + else if (type==DetectorType.LTCC) { + nphe = bank.getFloat("nphe", row); + // Hardcode some dtheta/dphi values for now (for matching): + dtheta = 10*3.14159/180; + dphi = 10*3.14159/180; + // Fill theta/phi: + // Not yet. + } + + else { + throw new RuntimeException( + "CherenkovResponse::readHipoEvent: invalid DetectorType: "+type); + } + CherenkovResponse che = new CherenkovResponse(theta,phi,dtheta,dphi); che.setHitPosition(x, y, z); che.setHitIndex(row); che.setEnergy(nphe); che.setTime(time); - che.setCherenkovType(DetectorType.HTCC); + che.setCherenkovType(type); responseList.add(che); } diff --git a/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorParticle.java b/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorParticle.java index 8ba4eed06b..429ba60aa1 100644 --- a/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorParticle.java +++ b/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorParticle.java @@ -694,8 +694,8 @@ else if(id==-321 || id==321){ return beta; } - public int getNphe(DetectorType type){ - int nphe = 0; + public double getNphe(DetectorType type){ + double nphe = 0; for(CherenkovResponse c : this.cherenkovStore){ if(c.getCherenkovType()==type){ nphe = c.getEnergy(); @@ -716,13 +716,25 @@ public double getVertexTime(DetectorType type, int layer, int pid){ public int getCherenkovSignal(List cherenkovs, DetectorType type){ + // choose cross based on detector type: + Line3D cross; + if (type==DetectorType.HTCC) + cross=this.detectorTrack.getFirstCross(); + else if (type==DetectorType.LTCC) + cross=this.detectorTrack.getLastCross(); + else throw new RuntimeException( + "DetectorParticle:getCheckr5noSignal: invalid type: "+type); + + // find the best match: int bestIndex = -1; if(cherenkovs.size()>0){ for(int loop = 0; loop < cherenkovs.size(); loop++) { if(cherenkovs.get(loop).getCherenkovType()==type){ - boolean matchtruth = cherenkovs.get(loop).match(this.detectorTrack.getFirstCross()); + boolean matchtruth = cherenkovs.get(loop).match(cross); if(matchtruth==true){ bestIndex = loop; + // FIXME keep the first match! + break; } } } From fbaf6127d2dece3ea6b6524aea0c7d76757f51cc Mon Sep 17 00:00:00 2001 From: Nathan Baltzell Date: Thu, 31 Aug 2017 19:11:01 -0400 Subject: [PATCH 41/49] EBCCDBConstants: enable all currently working tables --- .../java/org/jlab/rec/eb/EBCCDBConstants.java | 27 +++++++------------ 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/reconstruction/eb/src/main/java/org/jlab/rec/eb/EBCCDBConstants.java b/reconstruction/eb/src/main/java/org/jlab/rec/eb/EBCCDBConstants.java index cd9c945fc7..257819131b 100644 --- a/reconstruction/eb/src/main/java/org/jlab/rec/eb/EBCCDBConstants.java +++ b/reconstruction/eb/src/main/java/org/jlab/rec/eb/EBCCDBConstants.java @@ -148,14 +148,6 @@ public static final synchronized void load(int run,ConstantsManager manager) { String[] sfs={"sfs1","sfs2","sfs3","sfs4"}; loadArray(EBCCDBEnum.ELEC_SF,"electron_sf",sf,0,0,0); - /* - for (EBCCDBEnum key : dbArrays.keySet()) { - for (Double dd : dbArrays.get(key)) { - System.err.println(key+" "+dd); - } - } - */ - loadArray(EBCCDBEnum.PHOT_SF,"photon_sf", sf,0,0,0); loadArray(EBCCDBEnum.ELEC_SFS,"electron_sf",sfs,0,0,0); loadArray(EBCCDBEnum.PHOT_SFS,"photon_sf", sfs,0,0,0); @@ -179,7 +171,7 @@ public static final synchronized void load(int run,ConstantsManager manager) { loadDouble(EBCCDBEnum.FTOF_MATCHING_2,"ftof_matching","dx",0,0,0); loadVector3D(EBCCDBEnum.FTOF1A_hitRes,"ftof_matching","dx","dy","dz",0,1,0); loadVector3D(EBCCDBEnum.FTOF1B_hitRes,"ftof_matching","dx","dy","dz",0,2,0); - loadVector3D(EBCCDBEnum.FTOF2_hitRes,"ftof_matching","dx","dy","dz",0,3,0); + loadVector3D(EBCCDBEnum.FTOF2_hitRes,"ftof_matching","dx","dy","dz",0,0,0); loadDouble(EBCCDBEnum.HTCC_TimingRes,"htcc_matching","dt",0,0,0); loadDouble(EBCCDBEnum.HTCC_NPHE_CUT,"htcc_matching","nphe",0,0,0); @@ -199,24 +191,25 @@ public static final synchronized void load(int run,ConstantsManager manager) { loadDouble(EBCCDBEnum.CND_DPHI,"cnd_matching","dphi",0,0,0); loadDouble(EBCCDBEnum.CND_DZ,"cnd_matching","dz",0,0,0); - //oadDouble(EBCCDBEnum.HTCC_PION_THRESHOLD, - //loadDouble(EBCCDBEnum.LTCC_LOWER_PION_THRESHOLD, - //loadDouble(EBCCDBEnum.LTCC_UPPER_PION_THRESHOLD, + loadDouble(EBCCDBEnum.NEUTRON_maxBeta,"neutron_beta","neutron_beta",0,0,0); - loadDouble(EBCCDBEnum.TARGET_POSITION,"/geometry/target","position",0,0,0); + // FIXME: debug why this one doesn't load + //loadDouble(EBCCDBEnum.TARGET_POSITION,"/geometry/target","position",0,0,0); + //loadDouble(EBCCDBEnum.HTCC_PION_THRESHOLD, + //loadDouble(EBCCDBEnum.LTCC_LOWER_PION_THRESHOLD, + //loadDouble(EBCCDBEnum.LTCC_UPPER_PION_THRESHOLD, + + // FIXME: pending RF CCDB tables: //loadDouble(EBCCDBEnum.RF_BUCKET_LENGTH, //loadDouble(EBCCDBEnum.RF_OFFSET, //loadDouble(EBCCDBEnum.RF_TDC2TIME, - //loadDouble(EBCCDBEnum.RF_CYCLES, //loadDouble(EBCCDBEnum.RF_ID, //loadDouble(EBCCDBEnum.RF_LARGE_INTEGER, - // + //loadDouble(EBCCDBEnum.TRIGGER_ID, - loadDouble(EBCCDBEnum.NEUTRON_maxBeta,"neutron_beta","neutron_beta",0,0,0); - LOADED = true; setDB(DBP); } From 22366cbe7b965b85077f70b06676897a8d0cde41 Mon Sep 17 00:00:00 2001 From: Nathan Baltzell Date: Thu, 31 Aug 2017 19:11:51 -0400 Subject: [PATCH 42/49] EBEngine: fix LTCC cluster bank name, enable loading from CCDB --- .../java/org/jlab/service/eb/EBEngine.java | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/reconstruction/eb/src/main/java/org/jlab/service/eb/EBEngine.java b/reconstruction/eb/src/main/java/org/jlab/service/eb/EBEngine.java index ceb4f443e1..92504fd6c4 100644 --- a/reconstruction/eb/src/main/java/org/jlab/service/eb/EBEngine.java +++ b/reconstruction/eb/src/main/java/org/jlab/service/eb/EBEngine.java @@ -9,6 +9,7 @@ import org.jlab.io.base.DataBank; import org.jlab.clas.detector.CherenkovResponse; import org.jlab.rec.eb.EBCCDBConstants; +import org.jlab.rec.eb.EBCCDBEnum; /** * @@ -50,7 +51,7 @@ public boolean processDataEvent(DataEvent de) { List responseCTOF = ScintillatorResponse.readHipoEvent(de, "CTOF::hits", DetectorType.CTOF); List responseHTCC = CherenkovResponse.readHipoEvent(de,"HTCC::rec",DetectorType.HTCC); - List responseLTCC = CherenkovResponse.readHipoEvent(de,"LTCC::rec",DetectorType.LTCC); + List responseLTCC = CherenkovResponse.readHipoEvent(de,"LTCC::clusters",DetectorType.LTCC); List trackFT = TaggerResponse.readHipoEvent(de, "FTCAL::clusters", DetectorType.FTCAL); @@ -70,24 +71,26 @@ public boolean processDataEvent(DataEvent de) { eb.processHitMatching(); eb.addTaggerTracks(trackFT); eb.processNeutralTracks(); - //System.out.println("# of tracks " + tracks.size()); + eb.assignTrigger(); + // Process RF: EBRadioFrequency rf = new EBRadioFrequency(); eb.getEvent().getEventHeader().setRfTime(rf.getTime(de)+EBConstants.RF_OFFSET); + // Do PID etc: EBAnalyzer analyzer = new EBAnalyzer(); analyzer.processEvent(eb.getEvent()); - //System.out.println(eb.getEvent().toString()); - - - + // create REC:detector banks: if(eb.getEvent().getParticles().size()>0){ + DataBank bankP = DetectorData.getDetectorParticleBank(eb.getEvent().getParticles(), de, particleBank); de.appendBanks(bankP); + DataBank bankEve = DetectorData.getEventBank(eb.getEvent(), de, eventBank); de.appendBanks(bankEve); + List calorimeters = eb.getEvent().getCalorimeterResponseList(); if(calorimeterBank!=null && calorimeters.size()>0) { DataBank bankCal = DetectorData.getCalorimeterResponseBank(calorimeters, de, calorimeterBank); @@ -164,13 +167,16 @@ public void setTrackType(String trackType) { @Override public boolean init() { - - /* - * preparing for reading from ccdb: + + // load EB constants from CCDB: requireConstants(EBCCDBConstants.getAllTableNames()); this.getConstantsManager().setVariation("default"); + // FIXME: check run number in processDataEvent, reload from CCDB if changed. + // For now we just use hard-coded run number: EBCCDBConstants.load(10,this.getConstantsManager()); - */ + + // Example of retrieveing values from EBCCDBConstants: + //Double[] t=EBCCDBConstants.getArray(EBCCDBEnum.ELEC_SF); System.out.println("[EB::] --> event builder is ready...."); return true; From 351dc729fcd26c24057749a00ab1bcb3e6c043b9 Mon Sep 17 00:00:00 2001 From: Nathan Baltzell Date: Thu, 31 Aug 2017 19:12:49 -0400 Subject: [PATCH 43/49] EventBuilder.java: add comments --- .../java/org/jlab/service/eb/EventBuilder.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/reconstruction/eb/src/main/java/org/jlab/service/eb/EventBuilder.java b/reconstruction/eb/src/main/java/org/jlab/service/eb/EventBuilder.java index d59fd5fa92..3933641722 100644 --- a/reconstruction/eb/src/main/java/org/jlab/service/eb/EventBuilder.java +++ b/reconstruction/eb/src/main/java/org/jlab/service/eb/EventBuilder.java @@ -98,16 +98,17 @@ public void processHitMatching(){ DetectorParticle p = this.detectorEvent.getParticle(n); double quality = 0.0; + /** * Matching tracks to FTOF layer 1A detector. Added to the particle and association is * set with a particle needed. */ - int index = p.getDetectorHit(this.detectorResponses, DetectorType.FTOF, 1, EBConstants.FTOF_MATCHING_1A); if(index>=0){ p.addResponse(detectorResponses.get(index), true); detectorResponses.get(index).setAssociation(n); } + /** * Matching tracks to FTOF layer 1B detector. Added to the particle and association is */ @@ -125,6 +126,7 @@ public void processHitMatching(){ p.addResponse(detectorResponses.get(index), true); detectorResponses.get(index).setAssociation(n); } + /** * Matching tracks to CTOF detector. Added to the particle and association is */ @@ -133,20 +135,20 @@ public void processHitMatching(){ p.addResponse(detectorResponses.get(index), true); detectorResponses.get(index).setAssociation(n); } + /** * Matching tracks to PCAL (first layer of ECAL) and adding to the particle if reasonable match * is found, and proper association is set. */ - index = p.getDetectorHit(this.detectorResponses, DetectorType.EC, 1, EBConstants.PCAL_MATCHING); - if(index>=0){ p.addResponse(detectorResponses.get(index), true); detectorResponses.get(index).setAssociation(n); //quality = p.getDetectorHitQuality(detectorResponses, index, EBConstants.PCAL_hitRes); //detectorResponses.get(index).setHitQuality(quality); } - + + // Matching tracks to EC Inner: index = p.getDetectorHit(this.detectorResponses, DetectorType.EC, 4, EBConstants.ECIN_MATCHING); if(index>=0){ p.addResponse(detectorResponses.get(index), true); @@ -155,6 +157,7 @@ public void processHitMatching(){ //detectorResponses.get(index).setHitQuality(quality); } + // Matching tracks to EC Outer: index = p.getDetectorHit(this.detectorResponses, DetectorType.EC, 7, EBConstants.ECOUT_MATCHING); if(index>=0){ p.addResponse(detectorResponses.get(index), true); @@ -162,15 +165,16 @@ public void processHitMatching(){ //quality = p.getDetectorHitQuality(detectorResponses, index, EBConstants.ECOUT_hitRes); //detectorResponses.get(index).setHitQuality(quality); } - + + // Matching tracks to HTCC: index = p.getCherenkovSignal(this.cherenkovResponses,DetectorType.HTCC); - //System.out.println("HTCC Matching Index " + index); //double = p.getCherenkovSignalQuality() if(index>=0){ p.addCherenkovResponse(cherenkovResponses.get(index)); cherenkovResponses.get(index).setAssociation(n); } + // Matching tracks to LTCC: index = p.getCherenkovSignal(this.cherenkovResponses,DetectorType.LTCC); //double = p.getCherenkovSignalQuality() if(index>=0){ From 47a7f4262678bab0422a3f10ba6c5aedde8e7d4e Mon Sep 17 00:00:00 2001 From: Nathan Baltzell Date: Thu, 31 Aug 2017 19:13:34 -0400 Subject: [PATCH 44/49] validation/EBTwoTrackTest: add banks, add debuggin --- .../advanced-tests/src/eb/EBTwoTrackTest.java | 31 +++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/validation/advanced-tests/src/eb/EBTwoTrackTest.java b/validation/advanced-tests/src/eb/EBTwoTrackTest.java index 54044743f3..70d59218bf 100644 --- a/validation/advanced-tests/src/eb/EBTwoTrackTest.java +++ b/validation/advanced-tests/src/eb/EBTwoTrackTest.java @@ -110,7 +110,9 @@ private void processFile(String fileName) { DataEvent event = reader.getNextEvent(); // get banks: - DataBank trkBank=null,tofBank=null,recBank=null,mcBank=null; + DataBank trkBank=null,tofBank=null,htccBank=null,ltccBank=null; + DataBank recBank=null,mcBank=null,cheBank=null; + if (event.hasBank("FTOF::clusters")) tofBank=event.getBank("FTOF::clusters"); if (event.hasBank("TimeBasedTrkg::TBTracks")) @@ -119,12 +121,37 @@ private void processFile(String fileName) { recBank = event.getBank("REC::Particle"); if(event.hasBank("MC::Particle")) mcBank = event.getBank("MC::Particle"); + if(event.hasBank("REC::Cherenkov")) + cheBank = event.getBank("REC::Cherenkov"); + if (event.hasBank("LTCC::clusters")) + ltccBank = event.getBank("LTCC::clusters"); + if (event.hasBank("HTCC::rec")) + htccBank = event.getBank("HTCC::rec"); //if (mcBank!=null) mcBank.show(); // no tracking bank, discard event: if (trkBank==null) continue; - +/* + if (cheBank!=null) { + for (int ii=0; ii Date: Thu, 31 Aug 2017 19:39:40 -0400 Subject: [PATCH 45/49] DetectorType: reminder to add layer conventions --- .../src/main/java/org/jlab/detector/base/DetectorType.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/common-tools/clas-detector/src/main/java/org/jlab/detector/base/DetectorType.java b/common-tools/clas-detector/src/main/java/org/jlab/detector/base/DetectorType.java index e1f2121e72..c81fd31990 100644 --- a/common-tools/clas-detector/src/main/java/org/jlab/detector/base/DetectorType.java +++ b/common-tools/clas-detector/src/main/java/org/jlab/detector/base/DetectorType.java @@ -36,6 +36,11 @@ public enum DetectorType { SC (114, "SC"), CC (115, "CC"), SVT (220, "SVT"); + + // FIXME add layer conventions here, e.g.: + // (or maybe they are defined somewhere else?) + // FTOF2/1A/1B = 0/1/2 + // PCAL/Inner/Outer = 0/4/7 private final int detectorId; private final String detectorName; From e4f4895ca8434fae30980888e15aa871184380cd Mon Sep 17 00:00:00 2001 From: Nathan Baltzell Date: Thu, 31 Aug 2017 19:40:02 -0400 Subject: [PATCH 46/49] DetectorType: reminder to add layer conventions --- .../src/main/java/org/jlab/detector/base/DetectorType.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/common-tools/clas-detector/src/main/java/org/jlab/detector/base/DetectorType.java b/common-tools/clas-detector/src/main/java/org/jlab/detector/base/DetectorType.java index c81fd31990..292ffc71dd 100644 --- a/common-tools/clas-detector/src/main/java/org/jlab/detector/base/DetectorType.java +++ b/common-tools/clas-detector/src/main/java/org/jlab/detector/base/DetectorType.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.detector.base; /** From 448d08b3f30ea0442fb4f9ac49157606779d7941 Mon Sep 17 00:00:00 2001 From: Nathan Baltzell Date: Thu, 31 Aug 2017 19:51:37 -0400 Subject: [PATCH 47/49] DetectorData: remove hardcoded constants in favor of DetectorType, fix indentation, add a FIXME --- .../org/jlab/clas/detector/DetectorData.java | 270 +++++++++--------- 1 file changed, 136 insertions(+), 134 deletions(-) diff --git a/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorData.java b/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorData.java index f4939cdeb2..a6f2d4436c 100644 --- a/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorData.java +++ b/common-tools/clas-reco/src/main/java/org/jlab/clas/detector/DetectorData.java @@ -22,7 +22,6 @@ public class DetectorData { */ public static List readDetectorResponses(DataEvent event, String bank_name){ List responses = new ArrayList(); - //System.out.println(" RESPONESE BANK EXISTS = " + event.hasBank(bank_name)); if(event.hasBank(bank_name)==true){ DataBank bank = event.getBank(bank_name); @@ -223,7 +222,7 @@ public static DataBank getCalorimeterResponseBank(List respons return bank; } - public static DataBank getScintillatorResponseBank(List responses, DataEvent event, String bank_name){ + public static DataBank getScintillatorResponseBank(List responses, DataEvent event, String bank_name){ DataBank bank = event.createBank(bank_name, responses.size()); for(int row = 0; row < responses.size(); row++){ DetectorResponse r = responses.get(row); @@ -247,7 +246,7 @@ public static DataBank getScintillatorResponseBank(List respon return bank; } - public static DataBank getCherenkovResponseBank(List responses, DataEvent event, String bank_name){ + public static DataBank getCherenkovResponseBank(List responses, DataEvent event, String bank_name){ DataBank bank = event.createBank(bank_name, responses.size()); for(int row = 0; row < responses.size(); row++){ CherenkovResponse c = responses.get(row); @@ -269,114 +268,115 @@ public static DataBank getCherenkovResponseBank(List response return bank; } - public static DataBank getForwardTaggerBank(List particles, DataEvent event, String bank_name, int rows){ + public static DataBank getForwardTaggerBank(List particles, DataEvent event, String bank_name, int rows){ DataBank bank = event.createBank(bank_name, rows); int row = 0; for(int i = 0; i < particles.size(); i++){ + // FIXME: + // 1. remove this hardcoded constant 100, instead use DetectorType class + // 2. use REC::Particle.detector for identifying detector, NOT "status" if(particles.get(i).getStatus()==100) { - DetectorParticle p = particles.get(i); - bank.setShort("index", row, (short) p.getTaggerIndex()); - bank.setShort("pindex", row, (short) i); - bank.setShort("size", row, (short) p.getTaggerSize()); - bank.setFloat("x", row, (float) p.getTaggerPosition().x()); - bank.setFloat("y", row, (float) p.getTaggerPosition().y()); - bank.setFloat("z", row, (float) p.getTaggerPosition().z()); - bank.setFloat("dx", row, (float) p.getTaggerPositionWidth().x()); - bank.setFloat("dy", row, (float) p.getTaggerPositionWidth().y()); - bank.setFloat("radius", row, (float) p.getTaggerRadius()); - bank.setFloat("path", row, (float) 0.0); - bank.setFloat("time", row, (float) p.getTaggerTime()); - bank.setInt("energy", row, (int) p.getTaggerEnergy()); - bank.setFloat("chi2", row, (float) 0.0); - row = row + 1; + DetectorParticle p = particles.get(i); + bank.setShort("index", row, (short) p.getTaggerIndex()); + bank.setShort("pindex", row, (short) i); + bank.setShort("size", row, (short) p.getTaggerSize()); + bank.setFloat("x", row, (float) p.getTaggerPosition().x()); + bank.setFloat("y", row, (float) p.getTaggerPosition().y()); + bank.setFloat("z", row, (float) p.getTaggerPosition().z()); + bank.setFloat("dx", row, (float) p.getTaggerPositionWidth().x()); + bank.setFloat("dy", row, (float) p.getTaggerPositionWidth().y()); + bank.setFloat("radius", row, (float) p.getTaggerRadius()); + bank.setFloat("path", row, (float) 0.0); + bank.setFloat("time", row, (float) p.getTaggerTime()); + bank.setInt("energy", row, (int) p.getTaggerEnergy()); + bank.setFloat("chi2", row, (float) 0.0); + row = row + 1; } } return bank; } - public static DataBank getEventBank(DetectorEvent detectorEvent, DataEvent event, String bank_name){ + public static DataBank getEventBank(DetectorEvent detectorEvent, DataEvent event, String bank_name){ DataBank bank = event.createBank(bank_name, 1); - bank.setInt("NRUN", 0, detectorEvent.getEventHeader().getRun()); - bank.setInt("NEVENT", 0, detectorEvent.getEventHeader().getEvent()); - bank.setInt("TRG", 0, detectorEvent.getEventHeader().getTrigger()); - bank.setFloat("STTime", 0, (float) detectorEvent.getEventHeader().getStartTime()); - bank.setFloat("RFTime", 0, (float) detectorEvent.getEventHeader().getRfTime()); + bank.setInt("NRUN", 0, detectorEvent.getEventHeader().getRun()); + bank.setInt("NEVENT", 0, detectorEvent.getEventHeader().getEvent()); + bank.setInt("TRG", 0, detectorEvent.getEventHeader().getTrigger()); + bank.setFloat("STTime", 0, (float) detectorEvent.getEventHeader().getStartTime()); + bank.setFloat("RFTime", 0, (float) detectorEvent.getEventHeader().getRfTime()); return bank; } + public static DataBank getTracksBank(List particles, DataEvent event, String bank_name, int rows) { + DataBank bank = event.createBank(bank_name, rows); + int row = 0; + for(int i = 0 ; i < particles.size(); i++) { + DetectorParticle p = particles.get(i); + // FIXME: is this supposed to work for CVT too? + if(p.getTrackDetector()==DetectorType.DC.getDetectorId()) { + bank.setShort("index", row, (short) p.getTrackIndex()); + bank.setShort("pindex", row, (short) i); + bank.setByte("detector", row, (byte) p.getTrackDetector()); + bank.setByte("q", row, (byte) p.getCharge()); + bank.setFloat("chi2", row, (float) p.getChi2()); + bank.setShort("NDF", row, (short) p.getNDF()); + bank.setFloat("px_nomm", row, (float) p.vector().x()); + bank.setFloat("py_nomm", row, (float) p.vector().y()); + bank.setFloat("pz_nomm", row, (float) p.vector().z()); + bank.setFloat("vx_nomm", row, (float) p.vertex().x()); + bank.setFloat("vy_nomm", row, (float) p.vertex().y()); + bank.setFloat("vz_nomm", row, (float) p.vertex().z()); + row = row + 1; + } + } + return bank; + } - public static DataBank getTracksBank(List particles, DataEvent event, String bank_name, int rows) { - DataBank bank = event.createBank(bank_name, rows); - int row = 0; - for(int i = 0 ; i < particles.size(); i++) { - //System.err.println(particles.size() + " " + rows + " " + i + " " + row); - DetectorParticle p = particles.get(i); - if(p.getTrackDetector()==13) { - bank.setShort("index", row, (short) p.getTrackIndex()); - bank.setShort("pindex", row, (short) i); - bank.setByte("detector", row, (byte) p.getTrackDetector()); - bank.setByte("q", row, (byte) p.getCharge()); - bank.setFloat("chi2", row, (float) p.getChi2()); - bank.setShort("NDF", row, (short) p.getNDF()); - bank.setFloat("px_nomm", row, (float) p.vector().x()); - //System.out.println("Px is " + p.vector().x()); - bank.setFloat("py_nomm", row, (float) p.vector().y()); - bank.setFloat("pz_nomm", row, (float) p.vector().z()); - bank.setFloat("vx_nomm", row, (float) p.vertex().x()); - bank.setFloat("vy_nomm", row, (float) p.vertex().y()); - bank.setFloat("vz_nomm", row, (float) p.vertex().z()); - row = row + 1; - } - } - return bank; - } - - public static DataBank getCrossBank(List particles, DataEvent event, String bank_name) { - DataBank bank = event.createBank(bank_name, particles.size()); - for(int row = 0 ; row < particles.size(); row++){ - DetectorParticle p = particles.get(row); - bank.setShort("pindex", row, (short) row); - bank.setFloat("c_x", row, (float) p.getCross().x()); - bank.setFloat("c_y", row, (float) p.getCross().y()); - bank.setFloat("c_z", row, (float) p.getCross().z()); - bank.setFloat("c_ux", row, (float) p.getCrossDir().x()); - bank.setFloat("c_uy", row, (float) p.getCrossDir().y()); - bank.setFloat("c_uz", row, (float) p.getCrossDir().z()); - - } - return bank; - } + public static DataBank getCrossBank(List particles, DataEvent event, String bank_name) { + DataBank bank = event.createBank(bank_name, particles.size()); + for(int row = 0 ; row < particles.size(); row++){ + DetectorParticle p = particles.get(row); + bank.setShort("pindex", row, (short) row); + bank.setFloat("c_x", row, (float) p.getCross().x()); + bank.setFloat("c_y", row, (float) p.getCross().y()); + bank.setFloat("c_z", row, (float) p.getCross().z()); + bank.setFloat("c_ux", row, (float) p.getCrossDir().x()); + bank.setFloat("c_uy", row, (float) p.getCrossDir().y()); + bank.setFloat("c_uz", row, (float) p.getCrossDir().z()); + + } + return bank; + } public static List readTBCovMat(DataEvent event, String bank_name) { List covMat = new ArrayList(); - if(event.hasBank(bank_name)==true){ - DataBank bank = event.getBank(bank_name); - int nrows = bank.rows(); - for(int row = 0; row < nrows; row++){ - double[] covariance = new double[15]; - covariance[0] = bank.getFloat("C11", row); - covariance[1] = bank.getFloat("C12", row); - covariance[2] = bank.getFloat("C13", row); - covariance[3] = bank.getFloat("C14", row); - covariance[4] = bank.getFloat("C15", row); - covariance[5] = bank.getFloat("C22", row); - covariance[6] = bank.getFloat("C23", row); - covariance[7] = bank.getFloat("C24", row); - covariance[8] = bank.getFloat("C25", row); - covariance[9] = bank.getFloat("C33", row); - covariance[10] = bank.getFloat("C34", row); - covariance[11] = bank.getFloat("C35", row); - covariance[12] = bank.getFloat("C44", row); - covariance[13] = bank.getFloat("C45", row); - covariance[14] = bank.getFloat("C55", row); - covMat.add(covariance); - } - } + if(event.hasBank(bank_name)==true){ + DataBank bank = event.getBank(bank_name); + int nrows = bank.rows(); + for(int row = 0; row < nrows; row++){ + double[] covariance = new double[15]; + covariance[0] = bank.getFloat("C11", row); + covariance[1] = bank.getFloat("C12", row); + covariance[2] = bank.getFloat("C13", row); + covariance[3] = bank.getFloat("C14", row); + covariance[4] = bank.getFloat("C15", row); + covariance[5] = bank.getFloat("C22", row); + covariance[6] = bank.getFloat("C23", row); + covariance[7] = bank.getFloat("C24", row); + covariance[8] = bank.getFloat("C25", row); + covariance[9] = bank.getFloat("C33", row); + covariance[10] = bank.getFloat("C34", row); + covariance[11] = bank.getFloat("C35", row); + covariance[12] = bank.getFloat("C44", row); + covariance[13] = bank.getFloat("C45", row); + covariance[14] = bank.getFloat("C55", row); + covMat.add(covariance); + } + } return covMat; } - public static DataBank getTBCovMatBank(List particles, DataEvent event, String bank_name) { + public static DataBank getTBCovMatBank(List particles, DataEvent event, String bank_name) { DataBank bank = event.createBank(bank_name, particles.size()); for(int row = 0; row < particles.size(); row++){ DetectorParticle p = particles.get(row); @@ -412,31 +412,31 @@ public static List readDetectorTracks(DataEvent event, String ba if(event.hasBank(bank_name)==true){ DataBank bank = event.getBank(bank_name); int nrows = bank.rows(); - + for(int row = 0; row < nrows; row++){ int charge = bank.getByte("q", row); - //System.out.println("DC charge " + bank.getByte("q",row)); Vector3D pvec = DetectorData.readVector(bank, row, "p0_x", "p0_y", "p0_z"); Vector3D vertex = DetectorData.readVector(bank, row, "Vtx0_x", "Vtx0_y", "Vtx0_z"); - + DetectorTrack track = new DetectorTrack(charge,pvec.mag(), (row)); track.setVector(pvec.x(), pvec.y(), pvec.z()); track.setVertex(vertex.x(), vertex.y(), vertex.z()); track.setPath(bank.getFloat("pathlength", row)); - + Vector3D lc_vec = DetectorData.readVector(bank, row, "c1_x", "c1_y", "c1_z"); Vector3D lc_dir = DetectorData.readVector(bank, row, "c1_ux", "c1_uy", "c1_uz"); - + Vector3D hc_vec = DetectorData.readVector(bank, row, "c3_x", "c3_y", "c3_z"); Vector3D hc_dir = DetectorData.readVector(bank, row, "c3_ux", "c3_uy", "c3_uz"); track.addCross(lc_vec.x(), lc_vec.y(), lc_vec.z(), lc_dir.x(), lc_dir.y(), lc_dir.z()); track.addCross(hc_vec.x(), hc_vec.y(), hc_vec.z(), hc_dir.x(), hc_dir.y(), hc_dir.z()); - + track.setNDF(bank.getInt("ndf",row)); track.setchi2(bank.getFloat("chi2",row)); track.setStatus(bank.getInt("status",row)); - track.setDetectorID(13); - + + track.setDetectorID(DetectorType.DC.getDetectorId()); + tracks.add(track); } } @@ -444,44 +444,46 @@ public static List readDetectorTracks(DataEvent event, String ba } - public static List readCentralDetectorTracks(DataEvent event, String bank_name){ - List tracks = new ArrayList(); - if(event.hasBank(bank_name)==true){ - DataBank bank = event.getBank(bank_name); - int nrows = bank.rows(); - - for(int row = 0; row < nrows; row++){ - int charge = bank.getInt("q", row); - double p = bank.getFloat("p",row); - double pt = bank.getFloat("pt",row); - double phi0 = bank.getFloat("phi0",row); - double tandip = bank.getFloat("tandip", row); - double z0 = bank.getFloat("z0", row); - double d0 = bank.getFloat("d0", row); - - double pz = pt*tandip; - double py = pt*Math.sin(phi0); - double px = pt*Math.cos(phi0); - - double vx = d0*Math.cos(phi0); - double vy = d0*Math.sin(phi0); - - DetectorTrack track = new DetectorTrack(charge,p); - track.setVector(px, py, pz); - track.setVertex(vx, vy, z0); - track.setPath(bank.getFloat("pathlength", row)); - + public static List readCentralDetectorTracks(DataEvent event, String bank_name){ + List tracks = new ArrayList(); + if(event.hasBank(bank_name)==true){ + DataBank bank = event.getBank(bank_name); + int nrows = bank.rows(); + + for(int row = 0; row < nrows; row++){ + int charge = bank.getInt("q", row); + double p = bank.getFloat("p",row); + double pt = bank.getFloat("pt",row); + double phi0 = bank.getFloat("phi0",row); + double tandip = bank.getFloat("tandip", row); + double z0 = bank.getFloat("z0", row); + double d0 = bank.getFloat("d0", row); + + double pz = pt*tandip; + double py = pt*Math.sin(phi0); + double px = pt*Math.cos(phi0); + + double vx = d0*Math.cos(phi0); + double vy = d0*Math.sin(phi0); + + DetectorTrack track = new DetectorTrack(charge,p); + track.setVector(px, py, pz); + track.setVertex(vx, vy, z0); + track.setPath(bank.getFloat("pathlength", row)); + //track.addCTOFPoint(x,y,z); - //System.out.println("track intersect is..." + trackIntersect); - Vector3D hc_vec = DetectorData.readVector(bank, row, "c_x", "c_y", "c_z"); - Vector3D hc_dir = DetectorData.readVector(bank, row, "c_ux", "c_uy", "c_uz"); - track.addCross(hc_vec.x(), hc_vec.y(), hc_vec.z(), hc_dir.x(), hc_dir.y(), hc_dir.z()); + Vector3D hc_vec = DetectorData.readVector(bank, row, "c_x", "c_y", "c_z"); + Vector3D hc_dir = DetectorData.readVector(bank, row, "c_ux", "c_uy", "c_uz"); + track.addCross(hc_vec.x(), hc_vec.y(), hc_vec.z(), hc_dir.x(), hc_dir.y(), hc_dir.z()); - tracks.add(track); - } - } - return tracks; - } + // FIXME: define a convetion on DetectorType for central tracks + track.setDetectorID(DetectorType.SVT.getDetectorId()); + + tracks.add(track); + } + } + return tracks; + } From 04fe92b983560b3cfa4b8710cb0f652655ad369b Mon Sep 17 00:00:00 2001 From: Nathan Baltzell Date: Thu, 31 Aug 2017 20:07:04 -0400 Subject: [PATCH 48/49] EventBuilder.java: add some FIXME comments, more hardcoded constants --- .../org/jlab/detector/base/DetectorType.java | 2 +- .../org/jlab/service/eb/EventBuilder.java | 28 ++++++++++++------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/common-tools/clas-detector/src/main/java/org/jlab/detector/base/DetectorType.java b/common-tools/clas-detector/src/main/java/org/jlab/detector/base/DetectorType.java index 292ffc71dd..8286ce7d84 100644 --- a/common-tools/clas-detector/src/main/java/org/jlab/detector/base/DetectorType.java +++ b/common-tools/clas-detector/src/main/java/org/jlab/detector/base/DetectorType.java @@ -35,7 +35,7 @@ public enum DetectorType { // FIXME add layer conventions here, e.g.: // (or maybe they are defined somewhere else?) // FTOF2/1A/1B = 0/1/2 - // PCAL/Inner/Outer = 0/4/7 + // PCAL/Inner/Outer = 1/4/7 private final int detectorId; private final String detectorName; diff --git a/reconstruction/eb/src/main/java/org/jlab/service/eb/EventBuilder.java b/reconstruction/eb/src/main/java/org/jlab/service/eb/EventBuilder.java index 3933641722..2b6a6fb8e5 100644 --- a/reconstruction/eb/src/main/java/org/jlab/service/eb/EventBuilder.java +++ b/reconstruction/eb/src/main/java/org/jlab/service/eb/EventBuilder.java @@ -186,23 +186,31 @@ public void processHitMatching(){ } public void processNeutralTracks(){ - - List responsesPCAL = this.getUnmatchedResponses((List) detectorResponses, DetectorType.EC, 1); - + + // get all unmatched calorimeter responses: + List responsesPCAL = this.getUnmatchedResponses(detectorResponses, DetectorType.EC, 1); + List responsesECIN = this.getUnmatchedResponses(detectorResponses, DetectorType.EC, 4); + List responsesECOUT = this.getUnmatchedResponses(detectorResponses, DetectorType.EC, 7); + + // FIXME: is this really 1/2/3, or should it really be 1/2/0: + // Critical to use DetectorType for this, instead of hardcoded constants everywhere. + List responsesFTOF1A = this.getUnmatchedResponses(detectorResponses, DetectorType.FTOF, 1); + List responsesFTOF1B = this.getUnmatchedResponses(detectorResponses, DetectorType.FTOF, 2); + List responsesFTOF2 = this.getUnmatchedResponses(detectorResponses, DetectorType.FTOF, 3); + + // setup the empty list of neutral particles: List particles = new ArrayList(); - + + // add a new neutral particle for each unmatched PCAL response: + // TODO: Neutrals should not require any ECAL layer, but just one. for(DetectorResponse r : responsesPCAL){ DetectorParticle p = DetectorParticle.createNeutral(r); particles.add(p); } - List responsesECIN = this.getUnmatchedResponses(detectorResponses, DetectorType.EC, 4); - List responsesECOUT = this.getUnmatchedResponses(detectorResponses, DetectorType.EC, 7); - List responsesFTOF1A = this.getUnmatchedResponses(detectorResponses, DetectorType.FTOF, 1); - List responsesFTOF1B = this.getUnmatchedResponses(detectorResponses, DetectorType.FTOF, 2); - List responsesFTOF2 = this.getUnmatchedResponses(detectorResponses, DetectorType.FTOF, 3); - + for(int i = 0; i < particles.size(); i++){ DetectorParticle p = particles.get(i); + // FIXME: again, layer idices should be gotten from DetectorType int index = p.getDetectorHit(responsesECIN, DetectorType.EC, 4, EBConstants.ECIN_MATCHING); if(index>=0){ p.addResponse(responsesECIN.get(index), true); responsesECIN.get(index).setAssociation(i);} index = p.getDetectorHit(responsesECOUT, DetectorType.EC, 7, EBConstants.ECOUT_MATCHING); From 014380780ffd406c9178f6ebe6b72ed066ddcb7a Mon Sep 17 00:00:00 2001 From: Nathan Baltzell Date: Thu, 31 Aug 2017 20:19:41 -0400 Subject: [PATCH 49/49] validation/adv/EBTwoTrackTest: more debugging stuff --- validation/advanced-tests/src/eb/EBTwoTrackTest.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/validation/advanced-tests/src/eb/EBTwoTrackTest.java b/validation/advanced-tests/src/eb/EBTwoTrackTest.java index 70d59218bf..8fec3b0c63 100644 --- a/validation/advanced-tests/src/eb/EBTwoTrackTest.java +++ b/validation/advanced-tests/src/eb/EBTwoTrackTest.java @@ -111,7 +111,7 @@ private void processFile(String fileName) { // get banks: DataBank trkBank=null,tofBank=null,htccBank=null,ltccBank=null; - DataBank recBank=null,mcBank=null,cheBank=null; + DataBank recBank=null,mcBank=null,cheBank=null,rectrkBank=null;; if (event.hasBank("FTOF::clusters")) tofBank=event.getBank("FTOF::clusters"); @@ -127,11 +127,16 @@ private void processFile(String fileName) { ltccBank = event.getBank("LTCC::clusters"); if (event.hasBank("HTCC::rec")) htccBank = event.getBank("HTCC::rec"); + if (event.hasBank("REC::Track")) + rectrkBank = event.getBank("REC::Track"); //if (mcBank!=null) mcBank.show(); // no tracking bank, discard event: if (trkBank==null) continue; + + //if (rectrkBank!=null) rectrkBank.show(); + /* if (cheBank!=null) { for (int ii=0; ii