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 a6f2d4436c..95d29ac39a 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 @@ -288,8 +288,10 @@ public static DataBank getForwardTaggerBank(List particles, Da 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("energy", row, (float) p.getTaggerEnergy()); bank.setFloat("chi2", row, (float) 0.0); + // Using FTCAL for "detector": + bank.setByte("detector",row,(byte)DetectorType.FTCAL.getDetectorId()); row = row + 1; } } 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 429ba60aa1..cbcf17ab34 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 @@ -16,7 +16,8 @@ import org.jlab.geom.prim.Point3D; import org.jlab.geom.prim.Vector3D; -//import org.jlab.clas.pdg.PDGDatabase; +import org.jlab.clas.pdg.PDGDatabase; +import org.jlab.clas.pdg.PDGParticle; import org.jlab.clas.pdg.PhysicsConstants; //import org.jlab.service.pid.PIDResult; @@ -68,11 +69,7 @@ public DetectorParticle(){ public DetectorParticle(DetectorTrack track){ detectorTrack = track; } - - public DetectorParticle(TaggerResponse tagger) { - taggerTrack = tagger; - } - + public DetectorParticle(DetectorTrack track, double[] covMat) { detectorTrack = track; covMAT = covMat; @@ -139,6 +136,40 @@ public static DetectorParticle createNeutral(CalorimeterResponse resp){ return particle; } + public static DetectorParticle createFTparticle(TaggerResponse tagger) { + + // FIXME: + // + // This "taggerTrack" naming is not good: + // Any "track" should be a DetectorTrack (or at least inherit from it). + // + // TaggerResponse should be based on FT::particle, not just FT::cluster + + Point3D xyz = tagger.getPosition(); + Vector3D mom = tagger.getMomentum(); + Vector3D dir=new Vector3D(mom); + dir.unit(); + + // copied from createNeutral / processNeutralTracks: + DetectorTrack track = new DetectorTrack(0,1.0); + track.addCross(xyz.x(), xyz.y(), xyz.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(xyz.distance(new Point3D(0,0,0))); + track.setTrackEnd(xyz.x(),xyz.y(),xyz.z()); + track.setVector(mom.x(),mom.y(),mom.z()); + track.setP(mom.r()); + + DetectorParticle particle = new DetectorParticle(track); + particle.taggerTrack=tagger; + + // FIXME: Use FT::particle instead of FT::cluster, then stop assuming charge=0, pid=22 + particle.setPid(22); + + return particle; + } + + public void clear(){ this.responseStore.clear(); } @@ -331,7 +362,8 @@ public DetectorResponse getHit(DetectorType type, int layer){ public int getPid(){ return this.particlePID;} public double getPidQuality() {return this.particleIDQuality;} public void setPidQuality(double q) {this.particleIDQuality = q;} - + + public TaggerResponse getTaggerResponse(){ return this.taggerTrack; } public Point3D getTaggerPosition() {return this.taggerTrack.getPosition();} public Point3D getTaggerPositionWidth() {return this.taggerTrack.getPositionWidth();} public double getTaggerRadius() {return this.taggerTrack.getRadius();} @@ -339,7 +371,7 @@ public DetectorResponse getHit(DetectorType type, int layer){ 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(); @@ -411,10 +443,6 @@ public double getEnergy(DetectorType type){ energy += r.getEnergy(); } } - /* - DetectorResponse response = this.getHit(type); - if(response==null) return -1.0; - return response.getEnergy();*/ return energy; } 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 179b661b60..d494f725b0 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 @@ -64,11 +64,13 @@ public DetectorTrack(int charge, double px, double py, double pz){ } public DetectorTrack(int id, int charge, double px, double py, double pz){ + // FIXME + // Woah, DetectorTrack should not have a taggerID, or a taggerAnything!!! this.taggerID = id; this.trackCharge = charge; this.trackP.setXYZ(px, py, pz); } - + public DetectorTrack(int charge, double px, double py, double pz, double vx, double vy, double vz){ this.trackCharge = charge; 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 41cf928e07..d93e682241 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 @@ -42,6 +42,7 @@ public class TaggerResponse { public void setHitIndex(int index) {this.hitIndex = index;} public void setRadius(double r) {hitRadius = r;} + public DetectorDescriptor getDescriptor(){ return this.descriptor;} public int getSize(){return hitSize;} public int getID(){return hitID;} public double getTime(){ return hitTime;} @@ -92,7 +93,14 @@ public static List readHipoEvent(DataEvent event, double time = bank.getFloat("time",row); double energy = bank.getFloat("energy",row); TaggerResponse ft = new TaggerResponse(); - + + double z0 = 0; // FIXME vertex + double path = Math.sqrt(x*x+y*y+(z-z0)*(z-z0)); + double cx = x / path; + double cy = y / path; + double cz = (z-z0) / path; + ft.setMomentum(energy*cx,energy*cy,energy*cz); + ft.setSize(size); ft.setID(id); ft.setEnergy(energy); @@ -100,6 +108,9 @@ public static List readHipoEvent(DataEvent event, ft.setTime(time); ft.setHitIndex(row); ft.setPosition(x, y, z); + + ft.getDescriptor().setType(type); + responseList.add(ft); } } 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 257819131b..c8216f99fd 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 @@ -195,6 +195,7 @@ public static final synchronized void load(int run,ConstantsManager manager) { // FIXME: debug why this one doesn't load //loadDouble(EBCCDBEnum.TARGET_POSITION,"/geometry/target","position",0,0,0); + setDouble(EBCCDBEnum.TARGET_POSITION,0.0); //loadDouble(EBCCDBEnum.HTCC_PION_THRESHOLD, //loadDouble(EBCCDBEnum.LTCC_LOWER_PION_THRESHOLD, 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 92504fd6c4..441a0a750e 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 @@ -52,7 +52,8 @@ public boolean processDataEvent(DataEvent de) { List responseHTCC = CherenkovResponse.readHipoEvent(de,"HTCC::rec",DetectorType.HTCC); List responseLTCC = CherenkovResponse.readHipoEvent(de,"LTCC::clusters",DetectorType.LTCC); - + + // FIXME We should be starting with FT::particle, not clusters List trackFT = TaggerResponse.readHipoEvent(de, "FTCAL::clusters", DetectorType.FTCAL); eb.addDetectorResponses(responseFTOF); @@ -108,7 +109,7 @@ public boolean processDataEvent(DataEvent de) { } if (ftBank!=null && trackFT.size()>0) { - DataBank bankForwardTagger = DetectorData.getForwardTaggerBank(eb.getEvent().getParticles(), de, trackBank, trackFT.size()); + DataBank bankForwardTagger = DetectorData.getForwardTaggerBank(eb.getEvent().getParticles(), de, "REC::ForwardTagger", trackFT.size()); de.appendBanks(bankForwardTagger); } 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 2b6a6fb8e5..2599dde78d 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 @@ -58,7 +58,6 @@ public void addTaggerResponses(List responses){ * @param 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)); //particle.setStatus(1); @@ -67,7 +66,6 @@ public void addForwardTracks(List tracks) { } public void addCentralTracks(List tracks) { - //for(DetectorTrack track : tracks){ for(int i = 0 ; i < tracks.size(); i++){ DetectorParticle particle = new DetectorParticle(tracks.get(i)); detectorEvent.addParticle(particle); @@ -75,9 +73,10 @@ public void addCentralTracks(List tracks) { } public void addTaggerTracks(List taggers) { - //for(DetectorTrack track : tracks){ for(int i = 0 ; i < taggers.size(); i++){ - DetectorParticle particle = new DetectorParticle(taggers.get(i)); + //DetectorParticle particle = new DetectorParticle(taggers.get(i)); + DetectorParticle particle = DetectorParticle.createFTparticle(taggers.get(i)); + // FIXME: get rid of hardcoded 100 particle.setStatus(100); detectorEvent.addParticle(particle); } @@ -340,7 +339,6 @@ public boolean assignSoftwareTrigger(DetectorEvent event) { 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); } diff --git a/validation/advanced-tests/run-eb-tests.sh b/validation/advanced-tests/run-eb-tests.sh index 94cbb6b124..2b065dd5e6 100755 --- a/validation/advanced-tests/run-eb-tests.sh +++ b/validation/advanced-tests/run-eb-tests.sh @@ -1,7 +1,14 @@ #!/bin/sh -f +webDir=http://clasweb.jlab.org/clas12offline/distribution/coatjava/validation_files/eb +webVersion=v0 +webDir=$webDir/$webVersion + # coatjava must already be built at ../../coatjava/ +# whether to use CLARA (0=no) +useClara=0 + # if first argument is -t, only run the test, # don't redownload dependencies, don't run reconstruction. runTestOnly=0 @@ -19,25 +26,25 @@ case $webFileStub in ;; electronpion) ;; + forwardtagger) + ;; *) echo Invalid input evio file: $webFileStub exit 1 esac # set up environment -CLARA_HOME=$PWD/clara_installation/ ; export CLARA_HOME - -# 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 +if [ $useClara -eq 0 ] +then + COAT=../../coatjava +else + CLARA_HOME=$PWD/clara_installation/ + COAT=$CLARA_HOME/plugins/clas12/ + export CLARA_HOME +fi 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 if [ $? != 0 ] ; then echo "EBTwoTrackTest compilation failure" ; exit 1 ; fi @@ -45,20 +52,24 @@ if [ $? != 0 ] ; then echo "EBTwoTrackTest compilation failure" ; exit 1 ; fi # download and setup dependencies, run reconstruction: if [ $runTestOnly -eq 0 ] then - # 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 ] + + if ! [ $useClara -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 + # 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 fi # download test files @@ -72,27 +83,29 @@ then rm -f ${webFileStub}.hipo rm -f out_${webFileStub}.hipo - # convert to hipo + # 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 + # run reconstruction: + if [ $useClara -eq 0 ] + then + ../../coatjava/bin/notsouseful-util -i ${webFileStub}.hipo -o out_${webFileStub}.hipo -c 2 + else + 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 fi -# run KppTracking junit tests +# run Event Builder tests: 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 diff --git a/validation/advanced-tests/src/eb/EBTwoTrackTest.java b/validation/advanced-tests/src/eb/EBTwoTrackTest.java index 8fec3b0c63..96c4f65b46 100644 --- a/validation/advanced-tests/src/eb/EBTwoTrackTest.java +++ b/validation/advanced-tests/src/eb/EBTwoTrackTest.java @@ -12,7 +12,10 @@ /** * - * Analyze EB efficiencies based on Joseph's two-particle (e-X) FD events. + * Analyze EB efficiencies based on Joseph's test events. + * - Two-particle (e-X) FD events + * - 1-electron FT events + * * Need to write a more general purpose one based on MC::Particle bank. * * @author baltzell @@ -25,6 +28,8 @@ public class EBTwoTrackTest { static final int electronSector=1; static final int hadronSector=3; + boolean isForwardTagger=false; + int nNegTrackEvents = 0; int nTwoTrackEvents = 0; int nEvents = 0; @@ -39,6 +44,11 @@ public class EBTwoTrackTest { int nHadronsSector[]={0,0,0,0,0,0}; int hadronPDG; + DataBank mcBank=null; + DataBank trkBank=null,tofBank=null,htccBank=null,ltccBank=null,cheBank=null; + DataBank recpartBank=null,rectrkBank=null,recftBank=null; + DataBank ftcBank=null,fthBank=null,ftpartBank=null; + @Test public void main() { String fileName=System.getProperty("INPUTFILE"); @@ -51,12 +61,42 @@ public void main() { if (fileName.indexOf("proton")>=0) hadronPDG=2212; else if (fileName.indexOf("pion")>0) hadronPDG=211; else if (fileName.indexOf("kaon")>0) hadronPDG=321; + else if (fileName.indexOf("forwardtagger")>0) isForwardTagger=true; else { System.err.println("Cannot find particle type in filename."); assertEquals(false, true); } - processFile(fileName); - checkResults(); + + HipoDataSource reader = new HipoDataSource(); + reader.open(fileName); + + if (isForwardTagger) { + processEventsFT(reader); + checkResultsFT(); + } + else { + processEvents(reader); + checkResults(); + } + } + + private void getBanks(DataEvent de) { + mcBank=null; + trkBank=null;tofBank=null;htccBank=null;ltccBank=null;cheBank=null; + recpartBank=null;mcBank=null;rectrkBank=null;recftBank=null; + ftcBank=null;fthBank=null;ftpartBank=null; + if (de.hasBank("FTOF::clusters")) tofBank=de.getBank("FTOF::clusters"); + if (de.hasBank("TimeBasedTrkg::TBTracks")) trkBank = de.getBank("TimeBasedTrkg::TBTracks"); + if(de.hasBank("REC::Particle")) recpartBank = de.getBank("REC::Particle"); + if(de.hasBank("MC::Particle")) mcBank = de.getBank("MC::Particle"); + if(de.hasBank("REC::Cherenkov")) cheBank = de.getBank("REC::Cherenkov"); + if (de.hasBank("LTCC::clusters")) ltccBank = de.getBank("LTCC::clusters"); + if (de.hasBank("HTCC::rec")) htccBank = de.getBank("HTCC::rec"); + if (de.hasBank("REC::Track")) rectrkBank = de.getBank("REC::Track"); + if (de.hasBank("REC::ForwardTagger")) recftBank = de.getBank("REC::ForwardTagger"); + if (de.hasBank("FTCAL::clusters")) ftcBank = de.getBank("FTCAL::clusters"); + if (de.hasBank("FTHODO::clusters")) fthBank = de.getBank("FTHODO::clusters"); + if (de.hasBank("FT::particles")) ftpartBank = de.getBank("FT::particles"); } private void checkResults() { @@ -97,11 +137,31 @@ private void checkResults() { else if (hadronPDG==321) assertEquals(kEff>0.42,true); else if (hadronPDG==211) assertEquals(piEff>0.75,true); } + + private void checkResultsFT() { + + assertEquals(false,true); + } - private void processFile(String fileName) { + private void processEventsFT(HipoDataSource reader) { - HipoDataSource reader = new HipoDataSource(); - reader.open(fileName); + while (reader.hasEvent()) { + + nEvents++; + + DataEvent event = reader.getNextEvent(); + + getBanks(event); + + if (mcBank!=null) mcBank.show(); + if (recpartBank!=null) recpartBank.show(); + if (recftBank!=null) recftBank.show(); + if (ftpartBank!=null) ftpartBank.show(); + if (ftcBank!=null) ftcBank.show(); + } + } + + private void processEvents(HipoDataSource reader) { while (reader.hasEvent()) { @@ -109,26 +169,7 @@ private void processFile(String fileName) { DataEvent event = reader.getNextEvent(); - // get banks: - DataBank trkBank=null,tofBank=null,htccBank=null,ltccBank=null; - DataBank recBank=null,mcBank=null,cheBank=null,rectrkBank=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(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 (event.hasBank("REC::Track")) - rectrkBank = event.getBank("REC::Track"); + getBanks(event); //if (mcBank!=null) mcBank.show(); @@ -153,7 +194,7 @@ private void processFile(String fileName) { event.getBank("LTCC::clusters").show(); if (htccBank!=null) htccBank.show(); if (cheBank!=null) cheBank.show(); - if (recBank!=null) recBank.show(); + if (recpartBank!=null) recpartBank.show(); System.out.println("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"); } */ @@ -182,13 +223,13 @@ else if (trkBank.getInt("sector",ii)==hadronSector) { boolean foundPion = false; // check particle bank: - if (recBank!=null) { - for(int ii = 0; ii < recBank.rows(); ii++) { + if (recpartBank!=null) { + for(int ii = 0; ii < recpartBank.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 byte charge = recpartBank.getByte("charge", ii); + final int pid = recpartBank.getInt("pid", ii); + final double px=recpartBank.getFloat("px",ii); + final double py=recpartBank.getFloat("py",ii); final int sector = ClasMath.getSectorFromPhi(Math.atan2(py,px)); if (pid==11 && sector==electronSector) { @@ -232,7 +273,7 @@ else if (sector==hadronSector) { else { nMissing++; if (debug) { - recBank.show(); + recpartBank.show(); tofBank.show(); } }