diff --git a/build-coatjava.sh b/build-coatjava.sh index 667dfbac5a..a57d623139 100755 --- a/build-coatjava.sh +++ b/build-coatjava.sh @@ -1,29 +1,39 @@ #!/bin/bash -OPTIONS=n -LONGOPTIONS=nospotbugs -PARSED=$(getopt --options=$OPTIONS --longoptions=$LONGOPTIONS --name "$0" -- "$@") -eval set -- "$PARSED" - runSpotBugs="yes" - -while true; do - case "$1" in - -n|--nospotbugs) - runSpotBugs="no" - shift - ;; - --) - shift - break - ;; - *) - echo "Programming error" - exit 3 - ;; - esac +for xx in $@ +do + if [ "$xx" == "--nospotbugs" ] + then + runSpotBugs="no" + elif [ "$xx" == "-n" ] + then + runSpotBugs="no" + fi done +# this doesn't work on some systems: +#OPTIONS=n +#LONGOPTIONS=nospotbugs +#PARSED=$(getopt --options=$OPTIONS --longoptions=$LONGOPTIONS --name "$0" -- "$@") +#eval set -- "$PARSED" +#while true; do +# case "$1" in +# -n|--nospotbugs) +# runSpotBugs="no" +# shift +# ;; +# --) +# shift +# break +# ;; +# *) +# echo "Programming error" +# exit 3 +# ;; +# esac +#done + rm -rf coatjava mkdir -p coatjava cp -r bin coatjava/ 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 1288a75d66..3aaa86cf7d 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 @@ -85,50 +85,49 @@ public DetectorParticle(int charge, double px, double py, double pz, detectorTrack = new DetectorTrack(charge,px,py,pz,vx,vy,vz); } - public static DetectorParticle createNeutral(double x, double y, double z){ - Vector3D dir = new Vector3D(x,y,z); + public static DetectorParticle createNeutral( + double x, double y, double z, + double vx, double vy, double vz){ + + Vector3D dir = new Vector3D(x-vx,y-vy,z-vz); dir.unit(); + DetectorTrack track = new DetectorTrack(0,1.0); + track.addCross(x, y, z, dir.x(),dir.y(),dir.z()); + track.setVector(dir.x(), dir.y(), dir.z()); - track.setPath(Math.sqrt(x*x+y*y+z*z)); + + track.setVertex(vx,vy,vz); + + track.setPath(Math.sqrt(Math.pow(x-vx,2)+Math.pow(y-vy,2)+Math.pow(z-vz,2))); + track.setTrackEnd(x, y, z); + return new DetectorParticle(track); } + public static DetectorParticle createNeutral(double x, double y, double z){ + return createNeutral(x,y,z,0,0,0); + } + public static DetectorParticle createNeutral(DetectorResponse resp){ - Vector3D dir = new Vector3D(resp.getPosition().x(), - resp.getPosition().y(),resp.getPosition().z()); - dir.unit(); - DetectorTrack track = new DetectorTrack(0,1.0); - track.addCross(resp.getPosition().x(), - resp.getPosition().y(),resp.getPosition().z(), - dir.x(),dir.y(),dir.z()); - track.setVector(dir.x(), dir.y(), dir.z()); - track.setVertex(0.0, 0.0, 0.0); - track.setPath(resp.getPosition().mag()); - track.setTrackEnd(resp.getPosition().x(), - resp.getPosition().y(),resp.getPosition().z()); - DetectorParticle particle = new DetectorParticle(track); + DetectorParticle particle = createNeutral( + resp.getPosition().x(), + resp.getPosition().y(), + resp.getPosition().z()); particle.addResponse(resp); return particle; } - - public static DetectorParticle createNeutral(CalorimeterResponse resp){ - Vector3D dir = new Vector3D(resp.getPosition().x(), - resp.getPosition().y(),resp.getPosition().z()); - dir.unit(); - DetectorTrack track = new DetectorTrack(0,1.0); - track.addCross(resp.getPosition().x(), - resp.getPosition().y(),resp.getPosition().z(), - dir.x(),dir.y(),dir.z()); - track.setVector(dir.x(), dir.y(), dir.z()); - track.setVertex(0.0, 0.0, 0.0); - track.setPath(resp.getPosition().mag()); - track.setTrackEnd(resp.getPosition().x(), - resp.getPosition().y(),resp.getPosition().z()); - DetectorParticle particle = new DetectorParticle(track); -// particle.addCalorimeterResponse(resp); + + public static DetectorParticle createNeutral(DetectorResponse resp,Vector3 vertex){ + DetectorParticle particle = createNeutral( + resp.getPosition().x(), + resp.getPosition().y(), + resp.getPosition().z(), + vertex.x(), + vertex.y(), + vertex.z()); particle.addResponse(resp); return particle; } @@ -175,16 +174,6 @@ public List getCherenkovResponse(){ return this.cherenkovStore; } - - -// public List getCalorimeterResponse(){ -// return this.calorimeterStore; -// } - -// public List getScintillatorResponse(){ -// return this.scintillatorStore; -// } - public void addCherenkovResponse(CherenkovResponse res){ this.cherenkovStore.add(res); } @@ -193,10 +182,6 @@ public void addTaggerResponse(TaggerResponse res) { this.taggerStore.add(res); } -// public void addCalorimeterResponse(CalorimeterResponse res){ -// this.calorimeterStore.add(res); -// } - public void addResponse(DetectorResponse res, boolean match){ this.responseStore.add(res); if(match==true){ 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 2ca31d0aac..448566eb98 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 @@ -49,6 +49,12 @@ public boolean processDataEvent(DataEvent de) { EventBuilder eb = new EventBuilder(); eb.initEvent(head); // clear particles + EBMatching ebm = new EBMatching(eb); + + // Process RF: + EBRadioFrequency rf = new EBRadioFrequency(); + eb.getEvent().getEventHeader().setRfTime(rf.getTime(de)+EBCCDBConstants.getDouble(EBCCDBEnum.RF_OFFSET)); + List responseECAL = CalorimeterResponse.readHipoEvent(de, "ECAL::clusters", DetectorType.ECAL,"ECAL::moments"); List responseFTOF = ScintillatorResponse.readHipoEvent(de, "FTOF::hits", DetectorType.FTOF); List responseCTOF = ScintillatorResponse.readHipoEvent(de, "CTOF::hits", DetectorType.CTOF); @@ -74,23 +80,21 @@ public boolean processDataEvent(DataEvent de) { eb.getPindexMap().put(0, tracks.size()); eb.getPindexMap().put(1, ctracks.size()); - // Process tracks: + // Process tracks-hit matching: eb.processHitMatching(); + + // Assign trigger/startTime particle: + eb.assignTrigger(); + + // Create neutrals: + // (after assigning trigger particle, to get vertex/momentum right): eb.processNeutralTracks(); List centralParticles = eb.getEvent().getCentralParticles(); - EBMatching ebm = new EBMatching(eb); - ebm.processCentralParticles(de,"CVTRec::Tracks","CTOF::hits","CND::hits", centralParticles, responseCTOF, responseCND); - eb.assignTrigger(); - - // Process RF: - EBRadioFrequency rf = new EBRadioFrequency(); - eb.getEvent().getEventHeader().setRfTime(rf.getTime(de)+EBCCDBConstants.getDouble(EBCCDBEnum.RF_OFFSET)); - // Do PID etc: EBAnalyzer analyzer = new EBAnalyzer(); analyzer.processEvent(eb.getEvent()); diff --git a/reconstruction/eb/src/main/java/org/jlab/service/eb/EBMatching.java b/reconstruction/eb/src/main/java/org/jlab/service/eb/EBMatching.java index d7d3967ace..d3fe835891 100644 --- a/reconstruction/eb/src/main/java/org/jlab/service/eb/EBMatching.java +++ b/reconstruction/eb/src/main/java/org/jlab/service/eb/EBMatching.java @@ -4,6 +4,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import org.jlab.clas.physics.Vector3; import org.jlab.clas.detector.DetectorParticle; import org.jlab.clas.detector.DetectorResponse; import org.jlab.clas.detector.DetectorTrack; @@ -145,8 +146,13 @@ public List findNeutrals(int ecalLayer) { List responsesECAL = eventBuilder.getUnmatchedResponses(null, DetectorType.ECAL, ecalLayer); + Vector3 vertex = new Vector3(0,0,0); + if (eventBuilder.getEvent().getParticles().size()>0) { + vertex.copy(eventBuilder.getEvent().getParticle(0).vertex()); + } + for (DetectorResponse r : responsesECAL) - parts.add(DetectorParticle.createNeutral(r)); + parts.add(DetectorParticle.createNeutral(r,vertex)); // add other responses: this.addResponsesECAL(parts,otherEcalLayers); @@ -170,6 +176,11 @@ public void processCentralParticles(DataEvent de, List ctofHits, List cndHits) { + Vector3 vertex = new Vector3(0,0,0); + if (eventBuilder.getEvent().getParticles().size()>0) { + vertex.copy(eventBuilder.getEvent().getParticle(0).vertex()); + } + // Make a neutral particle for each CND hit without an // associated track. if (de.hasBank(cndBankName)==true) { @@ -180,7 +191,7 @@ public void processCentralParticles(DataEvent de, final int trkid=cndBank.getInt("trkID",icnd); if (trkid==-1) { // make neutral particle - DetectorParticle p = DetectorParticle.createNeutral(cndHits.get(icnd)); + DetectorParticle p = DetectorParticle.createNeutral(cndHits.get(icnd),vertex); this.eventBuilder.getEvent().addParticle(p); cnd_count = cnd_count + 1; } 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 95b5b3847f..057884c3e6 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 @@ -293,15 +293,18 @@ public void processNeutralTracks() { // set particle kinematics: for(DetectorParticle p : particles) { - final double energy = p.getEnergy(DetectorType.ECAL); - final double px = p.vector().x(); - final double py = p.vector().y(); - final double pz = p.vector().z(); - final double sf = EBUtil.getExpectedSamplingFraction(energy); + final double visEnergy = p.getEnergy(DetectorType.ECAL); + final double sampFract = EBUtil.getExpectedSamplingFraction(visEnergy); + final double corEnergy = visEnergy / sampFract; + + // direction cosines: + final double cx = p.vector().x(); + final double cy = p.vector().y(); + final double cz = p.vector().z(); p.setCharge(0); - p.vector().setXYZ(px*energy/sf,py*energy/sf,pz*energy/sf); - + p.vector().setXYZ(cx*corEnergy,cy*corEnergy,cz*corEnergy); + final int pcalCount = p.countResponses(DetectorType.ECAL,1); final int caloCount = pcalCount + p.countResponses(DetectorType.ECAL,4) +