From 93e1740b316e00ba577966935158b4378391328d Mon Sep 17 00:00:00 2001 From: dcpayette Date: Wed, 26 Jun 2019 15:55:29 -0400 Subject: [PATCH 001/235] first new branch commit --- etc/bankdefs/clas12/RTPC.xml | 3 +- etc/bankdefs/hipo/RTPC.json | 16 + etc/bankdefs/hipo4/data.json | 8 +- etc/bankdefs/hipo4/rtpc.json | 17 + reconstruction/README.md | 1 + reconstruction/pom.xml | 93 +- reconstruction/rtpc/README.md | 1 + reconstruction/rtpc/pom.xml | 81 ++ .../main/java/org/jlab/rec/rtpc/Geometry.java | 20 + .../org/jlab/rec/rtpc/banks/HitReader.java | 104 ++ .../jlab/rec/rtpc/banks/RecoBankWriter.java | 45 + .../jlab/rec/rtpc/banks/RecoBankWriter2.java | 91 ++ .../java/org/jlab/rec/rtpc/banks/package.html | 14 + .../org/jlab/rec/rtpc/hit/HelixFitJava.java | 824 +++++++++++++++ .../main/java/org/jlab/rec/rtpc/hit/Hit.java | 201 ++++ .../org/jlab/rec/rtpc/hit/HitDistance.java | 128 +++ .../org/jlab/rec/rtpc/hit/HitParameters.java | 105 ++ .../jlab/rec/rtpc/hit/HitReconstruction.java | 204 ++++ .../java/org/jlab/rec/rtpc/hit/HitVector.java | 87 ++ .../org/jlab/rec/rtpc/hit/MapCombine.java | 281 +++++ .../java/org/jlab/rec/rtpc/hit/PadAve.java | 99 ++ .../java/org/jlab/rec/rtpc/hit/PadFit.java | 118 +++ .../java/org/jlab/rec/rtpc/hit/PadHit.java | 185 ++++ .../java/org/jlab/rec/rtpc/hit/PadVector.java | 80 ++ .../org/jlab/rec/rtpc/hit/RecoHitVector.java | 94 ++ .../org/jlab/rec/rtpc/hit/ReducedTrack.java | 61 ++ .../jlab/rec/rtpc/hit/ReducedTrackMap.java | 59 ++ .../org/jlab/rec/rtpc/hit/TimeAverage.java | 389 +++++++ .../org/jlab/rec/rtpc/hit/TimeAverage2.java | 159 +++ .../java/org/jlab/rec/rtpc/hit/Track.java | 117 +++ .../org/jlab/rec/rtpc/hit/TrackFinder2.java | 994 ++++++++++++++++++ .../org/jlab/rec/rtpc/hit/TrackFinder3.java | 219 ++++ .../org/jlab/rec/rtpc/hit/TrackHitReco.java | 528 ++++++++++ .../org/jlab/rec/rtpc/hit/TrackHitReco2.java | 714 +++++++++++++ .../org/jlab/rec/rtpc/hit/TrackHitReco3.java | 649 ++++++++++++ .../java/org/jlab/rec/rtpc/hit/TrackMap.java | 60 ++ .../org/jlab/rec/rtpc/hit/TrackUtils.java | 44 + .../java/org/jlab/rec/rtpc/hit/package.html | 14 + .../main/java/org/jlab/rec/rtpc/package.html | 14 + .../org/jlab/service/rtpc/RTPCEngine.java | 179 ++++ .../org/jlab/service/rtpc/package-info.java | 8 + .../main/java/org/jlab/rec/rtpc/Geometry.java | 20 + .../org/jlab/rec/rtpc/banks/HitReader.java | 104 ++ .../jlab/rec/rtpc/banks/RecoBankWriter.java | 45 + .../jlab/rec/rtpc/banks/RecoBankWriter2.java | 91 ++ .../java/org/jlab/rec/rtpc/banks/package.html | 14 + .../org/jlab/rec/rtpc/hit/HelixFitJava.java | 824 +++++++++++++++ .../main/java/org/jlab/rec/rtpc/hit/Hit.java | 201 ++++ .../org/jlab/rec/rtpc/hit/HitDistance.java | 128 +++ .../org/jlab/rec/rtpc/hit/HitParameters.java | 105 ++ .../jlab/rec/rtpc/hit/HitReconstruction.java | 204 ++++ .../java/org/jlab/rec/rtpc/hit/HitVector.java | 87 ++ .../org/jlab/rec/rtpc/hit/MapCombine.java | 281 +++++ .../java/org/jlab/rec/rtpc/hit/PadAve.java | 99 ++ .../java/org/jlab/rec/rtpc/hit/PadFit.java | 118 +++ .../java/org/jlab/rec/rtpc/hit/PadHit.java | 185 ++++ .../java/org/jlab/rec/rtpc/hit/PadVector.java | 80 ++ .../org/jlab/rec/rtpc/hit/RecoHitVector.java | 94 ++ .../org/jlab/rec/rtpc/hit/ReducedTrack.java | 61 ++ .../jlab/rec/rtpc/hit/ReducedTrackMap.java | 59 ++ .../org/jlab/rec/rtpc/hit/TimeAverage.java | 389 +++++++ .../org/jlab/rec/rtpc/hit/TimeAverage2.java | 159 +++ .../java/org/jlab/rec/rtpc/hit/Track.java | 117 +++ .../org/jlab/rec/rtpc/hit/TrackFinder2.java | 994 ++++++++++++++++++ .../org/jlab/rec/rtpc/hit/TrackFinder3.java | 219 ++++ .../org/jlab/rec/rtpc/hit/TrackHitReco.java | 528 ++++++++++ .../org/jlab/rec/rtpc/hit/TrackHitReco2.java | 714 +++++++++++++ .../org/jlab/rec/rtpc/hit/TrackHitReco3.java | 649 ++++++++++++ .../java/org/jlab/rec/rtpc/hit/TrackMap.java | 60 ++ .../org/jlab/rec/rtpc/hit/TrackUtils.java | 44 + .../java/org/jlab/rec/rtpc/hit/package.html | 14 + .../main/java/org/jlab/rec/rtpc/package.html | 14 + .../org/jlab/service/rtpc/RTPCEngine.java | 179 ++++ .../org/jlab/service/rtpc/package-info.java | 8 + 74 files changed, 13971 insertions(+), 25 deletions(-) create mode 100644 etc/bankdefs/hipo/RTPC.json create mode 100644 etc/bankdefs/hipo4/rtpc.json create mode 100644 reconstruction/README.md create mode 100644 reconstruction/rtpc/README.md create mode 100644 reconstruction/rtpc/pom.xml create mode 100644 reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/Geometry.java create mode 100644 reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/banks/HitReader.java create mode 100644 reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/banks/RecoBankWriter.java create mode 100644 reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/banks/RecoBankWriter2.java create mode 100644 reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/banks/package.html create mode 100644 reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/HelixFitJava.java create mode 100644 reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/Hit.java create mode 100644 reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/HitDistance.java create mode 100644 reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/HitParameters.java create mode 100644 reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/HitReconstruction.java create mode 100644 reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/HitVector.java create mode 100644 reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/MapCombine.java create mode 100644 reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/PadAve.java create mode 100644 reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/PadFit.java create mode 100644 reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/PadHit.java create mode 100644 reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/PadVector.java create mode 100644 reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/RecoHitVector.java create mode 100644 reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/ReducedTrack.java create mode 100644 reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/ReducedTrackMap.java create mode 100644 reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TimeAverage.java create mode 100644 reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TimeAverage2.java create mode 100644 reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/Track.java create mode 100644 reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TrackFinder2.java create mode 100644 reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TrackFinder3.java create mode 100644 reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TrackHitReco.java create mode 100644 reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TrackHitReco2.java create mode 100644 reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TrackHitReco3.java create mode 100644 reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TrackMap.java create mode 100644 reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TrackUtils.java create mode 100644 reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/package.html create mode 100644 reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/package.html create mode 100644 reconstruction/rtpc/src/main/java/org/jlab/service/rtpc/RTPCEngine.java create mode 100644 reconstruction/rtpc/src/main/java/org/jlab/service/rtpc/package-info.java create mode 100644 reconstruction/src/main/java/org/jlab/rec/rtpc/Geometry.java create mode 100644 reconstruction/src/main/java/org/jlab/rec/rtpc/banks/HitReader.java create mode 100644 reconstruction/src/main/java/org/jlab/rec/rtpc/banks/RecoBankWriter.java create mode 100644 reconstruction/src/main/java/org/jlab/rec/rtpc/banks/RecoBankWriter2.java create mode 100644 reconstruction/src/main/java/org/jlab/rec/rtpc/banks/package.html create mode 100644 reconstruction/src/main/java/org/jlab/rec/rtpc/hit/HelixFitJava.java create mode 100644 reconstruction/src/main/java/org/jlab/rec/rtpc/hit/Hit.java create mode 100644 reconstruction/src/main/java/org/jlab/rec/rtpc/hit/HitDistance.java create mode 100644 reconstruction/src/main/java/org/jlab/rec/rtpc/hit/HitParameters.java create mode 100644 reconstruction/src/main/java/org/jlab/rec/rtpc/hit/HitReconstruction.java create mode 100644 reconstruction/src/main/java/org/jlab/rec/rtpc/hit/HitVector.java create mode 100644 reconstruction/src/main/java/org/jlab/rec/rtpc/hit/MapCombine.java create mode 100644 reconstruction/src/main/java/org/jlab/rec/rtpc/hit/PadAve.java create mode 100644 reconstruction/src/main/java/org/jlab/rec/rtpc/hit/PadFit.java create mode 100644 reconstruction/src/main/java/org/jlab/rec/rtpc/hit/PadHit.java create mode 100644 reconstruction/src/main/java/org/jlab/rec/rtpc/hit/PadVector.java create mode 100644 reconstruction/src/main/java/org/jlab/rec/rtpc/hit/RecoHitVector.java create mode 100644 reconstruction/src/main/java/org/jlab/rec/rtpc/hit/ReducedTrack.java create mode 100644 reconstruction/src/main/java/org/jlab/rec/rtpc/hit/ReducedTrackMap.java create mode 100644 reconstruction/src/main/java/org/jlab/rec/rtpc/hit/TimeAverage.java create mode 100644 reconstruction/src/main/java/org/jlab/rec/rtpc/hit/TimeAverage2.java create mode 100644 reconstruction/src/main/java/org/jlab/rec/rtpc/hit/Track.java create mode 100644 reconstruction/src/main/java/org/jlab/rec/rtpc/hit/TrackFinder2.java create mode 100644 reconstruction/src/main/java/org/jlab/rec/rtpc/hit/TrackFinder3.java create mode 100644 reconstruction/src/main/java/org/jlab/rec/rtpc/hit/TrackHitReco.java create mode 100644 reconstruction/src/main/java/org/jlab/rec/rtpc/hit/TrackHitReco2.java create mode 100644 reconstruction/src/main/java/org/jlab/rec/rtpc/hit/TrackHitReco3.java create mode 100644 reconstruction/src/main/java/org/jlab/rec/rtpc/hit/TrackMap.java create mode 100644 reconstruction/src/main/java/org/jlab/rec/rtpc/hit/TrackUtils.java create mode 100644 reconstruction/src/main/java/org/jlab/rec/rtpc/hit/package.html create mode 100644 reconstruction/src/main/java/org/jlab/rec/rtpc/package.html create mode 100644 reconstruction/src/main/java/org/jlab/service/rtpc/RTPCEngine.java create mode 100644 reconstruction/src/main/java/org/jlab/service/rtpc/package-info.java diff --git a/etc/bankdefs/clas12/RTPC.xml b/etc/bankdefs/clas12/RTPC.xml index be977d0884..c5c0edf30a 100644 --- a/etc/bankdefs/clas12/RTPC.xml +++ b/etc/bankdefs/clas12/RTPC.xml @@ -26,13 +26,14 @@ - +
+
diff --git a/etc/bankdefs/hipo/RTPC.json b/etc/bankdefs/hipo/RTPC.json new file mode 100644 index 0000000000..a357ffe6c3 --- /dev/null +++ b/etc/bankdefs/hipo/RTPC.json @@ -0,0 +1,16 @@ +[ + { + "bank": "RTPC::rec", + "group": 1720, + "info": "reconstructed RTPC hits", + "items": [ + {"name":"TID", "id":1, "type":"int16", "info":"Track ID of the hit"}, + {"name":"cellID", "id":2, "type":"int16", "info":"cell id"}, + {"name":"time", "id":3, "type":"float", "info":"Time (ns)"}, + {"name":"posX", "id":4, "type":"float", "info":"x pos (cm)"}, + {"name":"posY", "id":5, "type":"float", "info":"y pos (cm)"}, + {"name":"posZ", "id":6, "type":"float", "info":"z pos (cm)"}, + {"name":"tdiff", "id":7, "type":"float", "info":"Time shift (ns)"} + ] + } + ] diff --git a/etc/bankdefs/hipo4/data.json b/etc/bankdefs/hipo4/data.json index 98c8e36647..1648d1c568 100644 --- a/etc/bankdefs/hipo4/data.json +++ b/etc/bankdefs/hipo4/data.json @@ -343,7 +343,8 @@ { "name":"order" , "type":"B", "info":"order: 0 - ADCL , 1 - ADCR"}, { "name":"ADC" , "type":"I", "info":"ADC integral from pulse fit"}, { "name":"time" , "type":"F", "info":"time from pulse fit"}, - { "name":"ped" , "type":"S", "info":"pedestal from pulse analysis"} + { "name":"ped" , "type":"S", "info":"pedestal from pulse analysis"}, + { "name":"timeshift" , "type":"F", "info":"timeshift from gemc"} ] }, { @@ -352,13 +353,14 @@ "item" : 14, "info": "Digitized bank for the Radial TPC", "entries":[ - { "name":"step" , "type":"F", "info":"step"}, + { "name":"step" , "type":"I", "info":"step"}, { "name":"time" , "type":"F", "info":"time (ns)"}, { "name":"energy" , "type":"F", "info":"energy"}, { "name":"posx" , "type":"F", "info":"x position (mm)"}, { "name":"posy" , "type":"F", "info":"y position (mm)"}, { "name":"posz" , "type":"F", "info":"z position (mm)"}, - { "name":"phi" , "type":"F", "info":"phi (rad)"} + { "name":"phi" , "type":"F", "info":"phi (rad)"}, + { "name":"tid" , "type":"I", "info":"track id"} ] }, { diff --git a/etc/bankdefs/hipo4/rtpc.json b/etc/bankdefs/hipo4/rtpc.json new file mode 100644 index 0000000000..4482e85a31 --- /dev/null +++ b/etc/bankdefs/hipo4/rtpc.json @@ -0,0 +1,17 @@ +[ + { + "name": "RTPC::rec", + "group": 1720, + "item" : 1, + "info": "reconstructed RTPC hits", + "items": [ + {"name":"TID", "type":"I", "info":"Track ID of the hit"}, + {"name":"cellID", "type":"I, "info":"cell id"}, + {"name":"time", "type":"F", "info":"Time (ns)"}, + {"name":"posX", "type":"F", "info":"x pos (cm)"}, + {"name":"posY", "type":"F", "info":"y pos (cm)"}, + {"name":"posZ", "type":"F", "info":"z pos (cm)"}, + {"name":"tdiff", "type":"F", "info":"Time shift (ns)"} + ] + } + ] diff --git a/reconstruction/README.md b/reconstruction/README.md new file mode 100644 index 0000000000..af61df8ec2 --- /dev/null +++ b/reconstruction/README.md @@ -0,0 +1 @@ +# RTPC-Tracking-Software diff --git a/reconstruction/pom.xml b/reconstruction/pom.xml index 0e7107a161..dbf046d4f7 100644 --- a/reconstruction/pom.xml +++ b/reconstruction/pom.xml @@ -1,30 +1,81 @@ - + + 4.0.0 - org.jlab.clas - reconstruction - 6.2.0-SNAPSHOT - pom + org.jlab.clas12.detector + clas12detector-rtpc + 1.0-SNAPSHOT + jar org.jlab.clas clas12rec - ../parent/pom.xml + ../../parent/pom.xml 6.2.0-SNAPSHOT - - dc - tof - cvt - ft - ec - ltcc - htcc - cnd - rich - fvt - eb - band - - + + + clas12maven + https://clasweb.jlab.org/clas12maven + + + + + + + org.jlab.coda + jclara + 4.3-SNAPSHOT + + + + org.jlab.clas + clas-reco + 6.2.0-SNAPSHOT + + + + org.jlab.clas + clas-analysis + 6.2.0-SNAPSHOT + + + + org.jlab + groot + 2.2.0-20190308.162151-9 + + + + + + + org.apache.maven.plugins + maven-site-plugin + 3.7.1 + + + org.apache.maven.plugins + maven-project-info-reports-plugin + 3.0.0 + + + + + + + org.codehaus.mojo + findbugs-maven-plugin + + + + + + 1.8 + 1.8 + + + diff --git a/reconstruction/rtpc/README.md b/reconstruction/rtpc/README.md new file mode 100644 index 0000000000..af61df8ec2 --- /dev/null +++ b/reconstruction/rtpc/README.md @@ -0,0 +1 @@ +# RTPC-Tracking-Software diff --git a/reconstruction/rtpc/pom.xml b/reconstruction/rtpc/pom.xml new file mode 100644 index 0000000000..dbf046d4f7 --- /dev/null +++ b/reconstruction/rtpc/pom.xml @@ -0,0 +1,81 @@ + + + 4.0.0 + + org.jlab.clas12.detector + clas12detector-rtpc + 1.0-SNAPSHOT + jar + + + org.jlab.clas + clas12rec + ../../parent/pom.xml + 6.2.0-SNAPSHOT + + + + + clas12maven + https://clasweb.jlab.org/clas12maven + + + + + + + org.jlab.coda + jclara + 4.3-SNAPSHOT + + + + org.jlab.clas + clas-reco + 6.2.0-SNAPSHOT + + + + org.jlab.clas + clas-analysis + 6.2.0-SNAPSHOT + + + + org.jlab + groot + 2.2.0-20190308.162151-9 + + + + + + + org.apache.maven.plugins + maven-site-plugin + 3.7.1 + + + org.apache.maven.plugins + maven-project-info-reports-plugin + 3.0.0 + + + + + + + org.codehaus.mojo + findbugs-maven-plugin + + + + + + 1.8 + 1.8 + + + diff --git a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/Geometry.java b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/Geometry.java new file mode 100644 index 0000000000..9652c3b283 --- /dev/null +++ b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/Geometry.java @@ -0,0 +1,20 @@ +package org.jlab.rec.rtpc; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.PrintWriter; + +/*import org.jMath.Vector.threeVec; + +import trackfitter.surface.Line; +import trackfitter.track.Helix;*/ + +public class Geometry { + + public Geometry() { + + } + + + +} diff --git a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/banks/HitReader.java b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/banks/HitReader.java new file mode 100644 index 0000000000..246ae66ed4 --- /dev/null +++ b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/banks/HitReader.java @@ -0,0 +1,104 @@ +package org.jlab.rec.rtpc.banks; + +import java.util.ArrayList; +import java.util.List; + +import org.jlab.io.base.DataBank; +import org.jlab.io.base.DataEvent; +import org.jlab.rec.rtpc.hit.Hit; +/** + * @author payette + * + */ +public class HitReader { + + private List _Hits; + + /** + * + * @return a list of RTPC hits + */ + public List get_RTPCHits() { + return _Hits; + } + + /** + * sets the list of RTPC hits + * @param RTPCHits list of RTPC hits + */ + public void set_RTPCHits(List RTPCHits) { + this._Hits = RTPCHits; + } + + + + + /** + * reads the hits using clas-io methods to get the EvioBank for the RTPC and fill the values to instanciate the RTPChit and MChit classes. + * This methods fills the RTPChit and MChit list of hits. If the data is not MC, the MChit list remains empty + * @param event DataEvent + */ + public void fetch_RTPCHits(DataEvent event) { + + + + List hits = new ArrayList(); + + DataBank bankDGTZ = null; + if(event.hasBank("RTPC::adc")==true) + bankDGTZ=event.getBank("RTPC::adc"); + DataBank bankTrue = null; + if(event.hasBank("RTPC::pos")==true) + bankTrue=event.getBank("RTPC::pos"); + if(bankDGTZ==null || bankTrue==null) + return ; + + int rows = bankDGTZ.rows(); + if(bankTrue.rows()!=rows) + return; + + int[] hitnb = new int[rows]; + int[] cellID = new int[rows]; + //int[] ADC = new int[rows]; + double[] Time = new double[rows]; + int[] step = new int[rows]; + double[] posX = new double[rows]; + double[] posY = new double[rows]; + double[] posZ = new double[rows]; + //double[] phiRad = new double[rows]; + double[] Edep = new double[rows]; + double[] TShift = new double[rows]; + + for(int i = 0; i 10000) + { + Time[i] = 0; + Edep[i] = 0; + posX[i] = 0; + posY[i] = 0; + posZ[i] = 0; + } + Hit hit = new Hit(1, cellID[i], 1, Time[i]); + hit.set_EdepTrue(Edep[i]); + hit.set_PosXTrue(posX[i]); + hit.set_PosYTrue(posY[i]); + hit.set_PosZTrue(posZ[i]); + hit.set_Time(Time[i]); + hit.set_TShift(TShift[i]); + + hits.add(hit); + } + + this.set_RTPCHits(hits); + + } +} diff --git a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/banks/RecoBankWriter.java b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/banks/RecoBankWriter.java new file mode 100644 index 0000000000..aa0b849626 --- /dev/null +++ b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/banks/RecoBankWriter.java @@ -0,0 +1,45 @@ +package org.jlab.rec.rtpc.banks; + +import java.util.List; + +import org.jlab.io.base.DataBank; +import org.jlab.io.base.DataEvent; +import org.jlab.rec.rtpc.hit.Hit; + +public class RecoBankWriter { + + /** + * + * @param hitlist the list of hits that are of the type Hit. + * @return hits bank + * + */ + public DataBank fillRTPCHitsBank(DataEvent event, List hitlist) { + if(hitlist==null) + return null; + if(hitlist.size()==0) + return null; + + + DataBank bank = event.createBank("RTPC::rec", hitlist.size()); + + for(int i =0; i< hitlist.size(); i++) { + //System.out.println(hitlist.get(i).get_PosX()); + bank.setInt("id", i, hitlist.get(i).get_Id()); + bank.setInt("cellID",i, hitlist.get(i).get_cellID()); + bank.setFloat("posX",i, (float) hitlist.get(i).get_PosX()); + bank.setFloat("posY",i, (float) hitlist.get(i).get_PosY()); + bank.setFloat("posZ",i, (float) hitlist.get(i).get_PosZ()); + //bank.setDouble("Edep",i, hitlist.get(i).get_Edep()); + bank.setFloat("time", i, (float) hitlist.get(i).get_Time()); + + + } + + return bank; + + } + + + +} diff --git a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/banks/RecoBankWriter2.java b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/banks/RecoBankWriter2.java new file mode 100644 index 0000000000..924a5e21e8 --- /dev/null +++ b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/banks/RecoBankWriter2.java @@ -0,0 +1,91 @@ +package org.jlab.rec.rtpc.banks; + +import java.util.concurrent.ConcurrentHashMap; +import java.util.Vector; + +import org.jlab.clas.physics.Vector3; + +//import java.util.List; + +import org.jlab.io.base.DataBank; +import org.jlab.io.base.DataEvent; +//import org.jlab.rec.rtpc.hit.Hit; +import org.jlab.rec.rtpc.hit.HitParameters; +import org.jlab.rec.rtpc.hit.HitVector; +import org.jlab.rec.rtpc.hit.RecoHitVector; +import java.util.HashMap; + +public class RecoBankWriter2 { + + /** + * + * @param hitlist the list of hits that are of the type Hit. + * @return hits bank + * + */ + public DataBank fillRTPCHitsBank(DataEvent event, HitParameters params) { + /*if(hitlist==null) + return null; + if(hitlist.size()==0) + return null;*/ + int listsize = 0; + int row = 0; + HashMap> recohitvector = params.get_recohitvector(); + + for(int TID:recohitvector.keySet()) { + for(int i = 0; i < recohitvector.get(TID).size(); i++) { + listsize++; + } + } + + DataBank bank = event.createBank("RTPC::rec", listsize); + + if (bank == null) { + System.err.println("COULD NOT CREATE A BANK!!!!!!"); + return null; + } + + for(int TID : recohitvector.keySet()) { + for(int i = 0; i < recohitvector.get(TID).size(); i++) { + int cellID = recohitvector.get(TID).get(i).pad(); + double x_rec = recohitvector.get(TID).get(i).x(); + double y_rec = recohitvector.get(TID).get(i).y(); + double z_rec = recohitvector.get(TID).get(i).z(); + double time = recohitvector.get(TID).get(i).time(); + double tdiff = recohitvector.get(TID).get(i).dt(); + + bank.setInt("TID", row, TID); + bank.setInt("cellID", row, cellID); + bank.setFloat("time", row, (float) time); + bank.setFloat("posX", row, (float) x_rec); + bank.setFloat("posY", row, (float) y_rec); + bank.setFloat("posZ", row, (float) z_rec); + bank.setFloat("tdiff", row, (float) tdiff); + + row++; + } + } + /*for(int i =0; i< listsize; i++) { + double x_rec = alltracks.get(k + double y_rec = params.get_YVec().get(i); + double z_rec = params.get_ZVec().get(i); + double time = params.get_time().get(i); + //System.out.println(params.get_time().size()); + bank.setInt("id", i, 1); + bank.setInt("cellID",i, params.get_PadNum().get(i)); + bank.setFloat("posX",i, (float) x_rec); + bank.setFloat("posY",i, (float) y_rec); + bank.setFloat("posZ",i, (float) z_rec); + //bank.setDouble("Edep",i, hitlist.get(i).get_Edep()); + bank.setFloat("time", i, (float) time); + + + }*/ + + return bank; + + } + + + +} \ No newline at end of file diff --git a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/banks/package.html b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/banks/package.html new file mode 100644 index 0000000000..61a4c9b57d --- /dev/null +++ b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/banks/package.html @@ -0,0 +1,14 @@ + + + + + +org.jlab.rec.rtpc.banks + + +
Author:
ziegler
+ + \ No newline at end of file diff --git a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/HelixFitJava.java b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/HelixFitJava.java new file mode 100644 index 0000000000..0590eeb085 --- /dev/null +++ b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/HelixFitJava.java @@ -0,0 +1,824 @@ +package org.jlab.rec.rtpc.hit; + +public class HelixFitJava { + + void rwsmav(double r[], double a[], double v[], int n) + { + // Author: Martin Poppe. r[n] = a[n,n]*v[n] + + int i, k, ind; + // Address in triangular matrix, row ii, column kk + for(i=1; i<=n; i++) + { + r[i-1] = 0; + for(k=1; k<=n; k++) + { + if (i >= k) { ind = (i*i-i)/2 + k; r[i-1] += a[ind-1]*v[k-1];} + else { ind = (k*k-k)/2 + i; r[i-1] += a[ind-1]*v[k-1];} + } + } + + } // End of void rwsmav(...) + + void rwsmin(double v[], double b[], int n, int m, int nrank) + { + // Author: V. Blobel + + // Obtain solution of linear equations V*X = B with symmetric matrix V + // and inverse (for m=1) or matrix inversion only (for m=0). + + // V = Symmetric n-by-n matrix in symmetric storage mode + // V(1) = V11, V(2) = V12, V(3) = V22, V(4) = V13, ... + // replaced by inverse matrix + // B = n-vector (for m=0 use a dummy argument) + // replaced by a solution vector + // m = see above + + // Method of solution is by elimination selecting the pivot point on the + // diagonal each stage. The rank of the matrix is returned in nrank. + + // For nrank != n, all remaining rows and columns of the resulting matrix + // V and the corresponding elements of B are set to zero. + + + double EPSS = (double)1.0E-6; + + int i, ii, ni, k=0, kk, j, jj, jl, jk, lk, l, ij; + double vkk, d, e; /* variable 'c' in original fortran file is not used */ + double[][] dr = new double[2][200]; + + // -------- Construct table ----------- + for(i=1; i<=n; i++) dr[0][i-1] = 1; + ni = n; + ii = 0; + for(i=1; i<=n; i++) { ii += i; dr[1][i-1] = Math.abs(v[ii-1]); } + + + // --------- Loop begins ---------- + nrank = n - ni; + + for (i=1; i<=ni; i++) + { + // --- Search for pivot and test for linearity and zero matrix + k = kk = jj = 0; vkk = 0; + for (j=1; j<=n; j++) + { + jj += j; + if (dr[0][j-1] == 0) break; + if (Math.abs(v[jj-1]) <= vkk) break; + if (Math.abs(v[jj-1]) < EPSS*dr[1][j-1]) break; + vkk = Math.abs(v[jj-1]); + k=j; kk=jj; + } + if (k == 0) {break;} + + // --- Preparation for elimination --- + nrank = nrank + 1; + dr[0][k-1] = 0; + d = 1/v[kk-1]; + v[kk-1] = -d; + if (m == 1) b[k-1] *= d; + jk = kk-k; + jl = 0; + + // --- Elimination --- + for (j=1; j<=n; j++) + { + if( j-k < 0 ) jk++; + else { + if ( j-k == 0) {jk = kk; jl += j; break;} + else jk = jk +j -1; + } + + + e = v[jk-1]; + v[jk-1] = d*e; + + if (m==1) b[j-1] -= b[k-1]*e; + lk = kk-k; + for (l=1; l<=j; l++) + { + jl++; + if(l-k < 0) lk++; + else { if (l==k) {lk=kk; break;} + else lk=lk + l - 1; + } + + v[jl-1] -= v[lk-1]*e; + } + } // End of loop over j + } // End of loop over i + + if(k != 0) { + // ----------- Change sign -------------- + ij=0; + for (i=1; i<=n; i++) { + for (j=1; j<=i; j++) + { + ij++; v[ij-1] = -v[ij-1]; + } + } + return; + + } + // --------- Clear rest of the matrix ------------- + + ij=0; + for (i=1; i<=n; i++) + { + if(m == 1 && dr[0][i-1] != 0) b[i-1]=0; + for (j=1; j<=i; j++) + { + ij++; + if (dr[0][i-1] + dr[0][j-1] != 0) v[ij-1]=0; + v[ij-1] = -v[ij-1]; + } + } + + return; + } // End of void rwsmin(double v[], double b[], int n, int m, int* nrank + + + + + //------------------------------------------------------------------------- + void rwfthc(int npt, double rf[], + double pf[], double wfi[], + double zf[], double wzf[], + int iopt, + + double vv0[], double ee0[], double ch2ph, double ch2z, + double del[], double delz[]) + + + // ----- Function for fast helix fit. ----- + + // A generalization of the TFTHEL routine to allow it to be called from a + // routine that contains any list of x and y values xf,yf for a set of npt + // points to be fitted. + + // ----- Input: ----- + + // npt: Number of 3-D points to be fit + // xf[]: Array of X-values of points to be fit + // yf[]: Array of Y-values of points to be fit + // rf[]: Array of R-values of points to be fit + // pf[]: Array of PHI-values of points to be fit + // wfi[]: Array of 1/(sig(rphi))**2 for each point + // zf[]: Array of Z-values of points to be fit + // wzf[]: Array of 1/(sig(z))**2 for each point + // iopt: 0 -> Distance**2 =x**2 +y**2 minimized; + // 1 -> Weighted with 1/SIMA(R*PHI)**2 + // 2 -> Error matrix calculated + // 3 -> 3-Dimensional iteration + + // ----- Output: ----- + + // vv0[5]: [0] = 1/r*charge, positive if clockwise; + // [1] = tan(lambda) { = dz/ds} tan(angle to (X,Y) PLANE); + // [2] = phi0 {0, 2*PI} angle to X-axis at r=d0; + // [3] = d0*sign [cm] minimal distance to Z-axis, + // +ve if axis encircled; + // [4] = z0 [cm] z position at r=d0; + // ee0[15]: Inverse of error matrix in triangular form; + // ch2ph: chi squared = Sum(phi deviations / errors)^2; + // ch2z: chi squared = Sum(z deviations / errors)^2; + // del: Unknown; + // delz: Unknown. + + // Note that the number of degrees of freedom = 2*npt-5 + + // Based on subroutine CIRCLE. + // Reference: "Computer Physics Communications", Volume 33, P. 329 + // Authors: N. Chernov, G. Ososkov and M. Poppe + + // Modified by Fred Weber, 8 Jun 1989. + // Translated into C by Michael Ispiryan, 2006 + + + { + int ITMAX = 15; + int IOWRIT = 6; + double EPS = (double)1.0e-16; + double ONEPI = (double)3.1415927; + double PI = (double)3.1415927; + double TWOPI = (double)6.2831854; + double PIBY2 = (double)1.57074635; + int MAX_HITS_ON_CHAIN = 200; + + double[] sp2 = new double[MAX_HITS_ON_CHAIN], vv1 = new double[5]; + double[] sxy = new double[MAX_HITS_ON_CHAIN], ss0 = new double[MAX_HITS_ON_CHAIN]; + double[] eee = new double[MAX_HITS_ON_CHAIN]; + double[] grad = new double[5], cov= new double[15], dv= new double[5]; + double[] deln = new double[MAX_HITS_ON_CHAIN], delzn = new double[MAX_HITS_ON_CHAIN]; + + double[] xf = new double[MAX_HITS_ON_CHAIN], yf= new double[MAX_HITS_ON_CHAIN], wf= new double[MAX_HITS_ON_CHAIN]; + + double alf, a0, a1, a2, a22, bet, cur, dd, den; + double det, dy, d2, f, fact, fg, f1, g, gam, gam0; + double g1, h, h2, p2, q2, rm, rn, xa, xb = 0, xd, xi; + double xm, xx, xy, x1, x2, den2, ya, yb, yd, yi, ym; + double yy, y1, y2, wn, sa2b2, dd0, phic; + + int i, n, iter, nrank= 0; + + double chi2_here, rr0, asym, sst, ph0, check; + double aa0, ome, gg0, hh0, ff0, sums, sumss, sumz, sumsz, sumw; + double denom, dzds_here, zz0, eta, dfd, dfo, dpd, dpo, ggg, dza; + double dzd, dzo, chi1; + + //nkb added these variables for the recalculation of dz/ds + double kangle, my_phi, xc, yc, xdca; + double ydca, xbar, ybar, xpt, ypt, alpha, beta; + if (npt <= 2) + { + System.out.println("BonusHelixFit::rwfthc(): Cannot fit less than 3 points; exiting..\n"); + return; + } + if (npt > MAX_HITS_ON_CHAIN) + { + System.out.println("BonusHelixFit::rwfthc(): Cannot fit more than " + MAX_HITS_ON_CHAIN + " points; exiting..\n" ); + return; + } + for(i=0; i= ITMAX) break; + dy = a1 + xa*(a22 + xa*(4.0*xa - 12.0)); + xb = xa - ya/dy; + if (Math.abs(ya) > Math.abs(yb)) xb = 0.5*(xb+xa); + if (Math.abs(xa-xb) < EPS) break; + xa = xb; yb = ya; iter++; + } + + gam = gam0*xb; + f1 = f - gam; + g1 = g - gam; + x1 = xd*g1 - yd*h; + y1 = yd*f1 - xd*h; + det = f1*g1 - h2; den2 = 1.0/(x1*x1 + y1*y1 + gam*det*det); + if (den2 <= 0.0) {ch2ph = 1.0E+30; ch2z = 1.0E+30; return;} + den = Math.sqrt(den2); cur = det*den + 0.0000000001; + alf = -(xm*det + x1)*den; + bet = -(ym*det + y1)*den; + rm = xm*xm + ym*ym; + + // ------- Calculation of standard circle parameters. NB: cur is + // ------- always positive. + asym = bet*xm - alf*ym; + sst = 1.0; + if (asym<0.0) sst = -1.0; + rr0 = sst*cur; + if((alf*alf + bet*bet) <= 0.0) {ch2ph = 1.0E+30; ch2z = 1.0E+30; return;} + sa2b2 = 1.0/(Math.sqrt(alf*alf + bet*bet)); + dd0 = (1.0 - 1.0/sa2b2)/cur; + phic = Math.asin(alf*sa2b2) + PIBY2; + if (bet > 0.0) phic = TWOPI - phic; + ph0 = phic + PIBY2; + + if (rr0 <= 0.0) ph0 -= ONEPI; + if (ph0 > TWOPI) ph0 -= TWOPI; + if (ph0 < 0.0) ph0 += TWOPI; + + vv0[0]=rr0; vv0[2]=ph0; vv0[3]=dd0; + //printf("rr0,ph0,dd0 = %f %f %f\n",1/rr0,ph0,dd0); + check = sst*rr0*dd0; + if (check == 1.0) { dd0 -= 0.007; vv0[3] = dd0; } + + // ------- Calculate phi distances to measured points + aa0=sst; ome=rr0; gg0=ome*dd0-aa0; hh0=1.0/gg0; + for(i=0; i 1.0) ff0 = 1.0; + + del[i] = ph0 + (ss0[i]-aa0)*PIBY2 + ss0[i]*Math.asin(ff0) - pf[i]; + if (del[i] > ONEPI) del[i] -= TWOPI; + if (del[i] < -ONEPI) del[i] += TWOPI; + } + + + // -------- Fit straight line in S-Z + for(i=0; i 0.9999) + { + //quiet = FALSE; + //fprintf(stderr, "+Track circles too much for this code(eee=%f); bad dzds\n",eee[i]); + //badarg = TRUE;//break; + //printf("eee[%d] = %f\n",i,eee[i]); + eee[i] = 0.9999; + } + if (eee[i] < -0.9999) + { + //quiet = FALSE; + //fprintf(stderr, "-Track circles too much for this code(eee=%f); bad dzds\n",eee[i]); + //badarg = TRUE;//break; + //printf("eee[%d] = %f\n",i,eee[i]); + eee[i] = -0.9999; + } + + sxy[i] = 2.0*Math.asin(eee[i])/ome; + //printf("original sxy[%d] = %f\n",i,sxy[i]); + } + + //if(badarg) + { + /* + for(i=0; i2.0*PI) my_phi-=2.0*PI; + xc = -Math.sin(my_phi)*((-vv0[3])+Math.abs(1.0/vv0[0])); + yc = Math.cos(my_phi)*((-vv0[3])+Math.abs(1.0/vv0[0])); + xdca = -Math.sin(my_phi)*(-vv0[3]); + ydca = Math.cos(my_phi)*(-vv0[3]); + xbar = xdca - xc; + ybar = ydca - yc; + //printf("xdca= %.1f ydca= %.1f xc= %.1f yc= %.1f xbar= %.1f ybar= %.1f\n", + // xdca, ydca, xc, yc, xbar, ybar); + for(i=0; i 1.0) + { + //quiet = FALSE; + //printf("eee[%d] = %f, rad = %f, mydd = %f\n",i,eee[i],1/rr0,Math.sqrt(mydd)); + //getchar(); + } + sxy[i] = (1/(sst*rr0))*acos(eee[i]); + //printf("law of Math.cos sxy[%d] = %f\n",i,sxy[i]); + */ + //ksxy = sxy[i]; + xpt = xf[i] - xc; + ypt = yf[i] - yc; + alpha = Math.atan2(ypt,xpt); + beta = Math.atan2(ybar,xbar); //if(alpha > 2*PI)alpha -= 2*PI; + //if(alpha < 0) alpha += 2*PI; + //if(beta > 2*PI) beta -= 2*PI; + //if(beta < 0) beta += 2*PI; + //printf("alpha = %.2f beta = %.2f\n",alpha*180./PI,beta*180./PI); + sxy[i] = beta - alpha; + if(sxy[i] > PI) sxy[i] = sxy[i] - 2*PI; + if(sxy[i] < -PI)sxy[i] = sxy[i] + 2*PI; + //if(sxy[i] < 0) sxy[i] += 2*PI; + kangle = sxy[i]; + sxy[i] = (1/rr0)*sxy[i]; + + //printf("[%d] xf= %.1f yf= %.1f xpt= %.1f ypt= %.1f\n", + //i, xf[i], yf[i], xpt, ypt); + //HFILL(9916, ksxy - sxy[i], 0.0, 1.0); + //printf("%f\n",ksxy-sxy[i]); + } + + } + + + sums = 0.0; + sumss = 0.0; + sumz = 0.0; + sumsz = 0.0; + sumw = 0.0; + for(i=0; i= 0.0) denom = 1.0E-6; + else denom = -1.0E-6; + } + + dzds_here = (sumw*sumsz - sums*sumz) / denom; + zz0 = (sumss*sumz - sums*sumsz) / denom; + vv0[1] = dzds_here; vv0[4] = zz0; + + // --------- Calculation of chi**2 + for(i=0; i 0.9999) ff0 = 0.9999; + if (ff0 < -0.9999) ff0 = -0.9999; + eta = ss0[i] / Math.sqrt(Math.abs(1.0+ff0)*(1.0-ff0)); + dfd = (1.0 + hh0*hh0*(1.0-ome*ome*rf[i]*rf[i])) / (2.0*rf[i]); + dfo = -aa0*(rf[i]*rf[i] - dd0*dd0)*hh0*hh0 / (2.0*rf[i]); + dpd = eta*dfd; dpo = eta*dfo; + // --- Derivatives of z component + ggg = eee[i] / Math.sqrt(Math.abs( (1.0+eee[i])*(1.0-eee[i]))); + dza = sxy[i]; + check = rf[i]*rf[i] - vv0[3]*vv0[3]; + if (check == 0.0) check = 2.0*0.007; + dzd = 2.0*(vv0[1]/vv0[0]) * Math.abs(ggg) * (0.5*aa0*vv0[0] / + (1.0 - aa0*vv0[3]*vv0[0]) - vv0[3]/check); + dzo = -vv0[1]*sxy[i]/vv0[0] + vv0[1]*ggg/(vv0[0]*vv0[0]) * + (2.0 + aa0*vv0[0]*vv0[3]/(1.0 - aa0*vv0[0]*vv0[3])); + + // ---- Error matrix + ee0[0] += sp2[i]*dpo*dpo + wzf[i]*dzo*dzo; + ee0[1] += wzf[i]*dza*dzo; + ee0[2] += wzf[i]*dza*dza; + ee0[3] += sp2[i]*dpo; + ee0[5] += sp2[i]; + ee0[6] += sp2[i]*dpo*dpd + wzf[i]*dzo*dzd; + ee0[8] += sp2[i]*dpd; + ee0[9] += sp2[i]*dpd*dpd + wzf[i]*dzd*dzd; + ee0[10] += wzf[i]*dzo; + ee0[11] += wzf[i]*dza; + ee0[13] += wzf[i]*dzd; + ee0[14] += wzf[i]; + + // --- Gradient vector + grad[0] += -del[i]*sp2[i]*dpo - delz[i]*wzf[i]*dzo; + grad[1] += - delz[i]*wzf[i]*dza; + grad[2] += -del[i]*sp2[i]; + grad[3] += -del[i]*sp2[i]*dpd - delz[i]*wzf[i]*dzd; + grad[4] += - delz[i]*wzf[i]; + } // End of for(i...) + + + if (iopt < 3) return; + + + // --------------- Newton's next guess + for(i=0; i<15; i++) cov[i] = ee0[i]; + + rwsmin(cov, vv1, 5, 0, nrank); + rwsmav(dv, cov, grad, 5); + + for(i=0; i<5; i++) vv1[i] = vv0[i] + dv[i]; + + //------- New differences in phi and z + gg0 = vv1[0]*vv1[3] - aa0; + for(i=0; i 1.0) ff0 = 1.0; + if (ff0 < -1.0) ff0 = -1.0; + + deln[i] = vv1[2] + (ss0[i]-aa0)*PIBY2 + ss0[i]*Math.asin(ff0) - pf[i]; + if (deln[i] > ONEPI) deln[i] -= TWOPI; + if (deln[i] < -ONEPI) deln[i] += TWOPI; + eee[i] = 0.5*vv1[0]*Math.sqrt(Math.abs( (rf[i]*rf[i] - vv1[3]*vv1[3]) / + (1.0 - aa0*vv1[0]*vv1[3]) )); + if (eee[i] > 0.9999) eee[i] = 0.9999; + if (eee[i] < -0.9999) eee[i] = -0.9999; + sxy[i] = 2.0*Math.asin(eee[i]) / vv1[0]; + delzn[i] = vv1[4] + vv1[1]*sxy[i] - zf[i]; + } + + // ---------- Calculation of chi**2 + chi1 = ch2ph = ch2z = 0.0; + for(i=0; i24.0) R=24.; + if(R<1.5) R=1.5; + double Para_dPhiVsR[] = {0.753136, -0.391614, 0.0836029, -0.00944999, + 0.000611348, -2.26783e-05, 4.47764e-07, -3.64278e-09}; + double dPhi = Para_dPhiVsR[0]; + for(int i=1;i<=7;i++) dPhi += Para_dPhiVsR[i]*Math.pow(R,i); + Phi = Phi - dPhi; + //apply 2nd correction if R<5.5 cm + if(R<5.5) { + double Para_dPhiVsR_2nd[] = {11.0937, -17.3801, 11.0492, -3.65267, + 0.663338, -0.0628701, 0.00243461}; + double dPhi_2nd = Para_dPhiVsR_2nd[0]; + for(int i=1;i<=6;i++) dPhi_2nd += Para_dPhiVsR_2nd[i]*Math.pow(R,i); + Phi = Phi - dPhi_2nd; + } + + return; + + /****************************************** + r_hel-rho_1st:r_hel, only good for 1.014.5) R=14.5; + if(R<14.50001) { + double Para_dRVsR[] = { 8.2822, -8.35421, 3.32568, -0.685895, 0.0797764, + -0.00527024, 0.000184178, -2.64062e-06}; + double dR = Para_dRVsR[0]; + for(int i=1;i<=7;i++) dR += Para_dRVsR[i]*Math.pow(R,i); + R = R - dR; + Rho = (Rho<0)? -R : R;*/ + //std::cout<<"\t\t dR="<arg0._cellID) { + return 1; + } else { + return 0; + } + } + + +} diff --git a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/HitDistance.java b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/HitDistance.java new file mode 100644 index 0000000000..1dd2b5f470 --- /dev/null +++ b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/HitDistance.java @@ -0,0 +1,128 @@ +package org.jlab.rec.rtpc.hit; + +import java.util.HashMap; +import java.util.concurrent.ConcurrentHashMap; +import java.util.Vector; + +import javax.swing.JFrame; + +import org.jlab.clas.physics.Vector3; +import org.jlab.groot.data.H1F; +import org.jlab.groot.graphics.EmbeddedCanvas; + +public class HitDistance { + + public void FindDistance(HitParameters params) { + HashMap ADCMap = params.get_R_adc(); + Vector PadNum = params.get_PadNum(); + int Pad = 0; //initializing pad + int Pad2 = 0; + int TrigWindSize = params.get_TrigWindSize(); //Trigger Window Size = 10000 + //int StepSize = params.get_StepSize(); + int StepSize = 120; //Time stepsize + double thresh = 1e-5; //Arbitrary ADC threshold + double ADC = 0; + double ADC2 = 0; + Vector3 TempPadCoords = new Vector3(); + Vector3 CheckPadCoords = new Vector3(); + Vector3 CheckPadPrevCoords = new Vector3(); + EmbeddedCanvas c1 = new EmbeddedCanvas(); + EmbeddedCanvas c2 = new EmbeddedCanvas(); + EmbeddedCanvas c3 = new EmbeddedCanvas(); + H1F t1 = new H1F("t1","t1",100,0,50); + H1F t2 = new H1F("t2","t2",100,0,8); + H1F t3 = new H1F("t3","t3",100,0,10); + t1.setTitleX("xy in mm"); + t2.setTitleX("z in mm"); + t3.setTitleX("ellipse formula result"); + JFrame j1 = new JFrame(); + j1.setSize(800,600); + j1.setTitle("xy"); + JFrame j2 = new JFrame(); + j2.setSize(800,600); + j2.setTitle("z"); + JFrame j3 = new JFrame(); + j3.setSize(800,600); + j3.setTitle("ellipse"); + double EllipseDeltax = 0; + double EllipseDeltay = 0; + double EllipseDeltaz = 0; + double EllipseTotal = 0; + double PhiDelta = Math.pow(3, 2); + double ZDelta = Math.pow(6, 2); + for(int t = 0; t < TrigWindSize; t+=StepSize) + { + for(int p = 0; p < PadNum.size(); p ++) + { + Pad = PadNum.get(p); + ADC = ADCMap.get(Pad)[t]; + if(ADC > thresh) + { + Vector3 PadCoords = PadCoords(Pad); + for(int p2 = 0; p2 < PadNum.size(); p2++) + { + if(p2 != p) + { + Pad2 = PadNum.get(p2); + ADC2 = ADCMap.get(Pad2)[t]; + if(ADC2 > thresh) + { + CheckPadCoords = PadCoords(Pad2); + EllipseDeltax = Math.pow(Math.abs(PadCoords.x()-CheckPadCoords.x()),2); + EllipseDeltay = Math.pow(Math.abs(PadCoords.y()-CheckPadCoords.y()),2); + EllipseDeltaz = Math.pow(Math.abs(PadCoords.z()-CheckPadCoords.z()),2); + EllipseTotal = ((EllipseDeltax+EllipseDeltay)/PhiDelta) + (EllipseDeltaz/ZDelta); + t1.fill(Math.sqrt(EllipseDeltax+EllipseDeltay)); + t2.fill(Math.sqrt(EllipseDeltaz)); + t3.fill(EllipseTotal); + } + } + } + } + } + } + c1.draw(t1); + c2.draw(t2); + c3.draw(t3); + j1.add(c1); + j2.add(c2); + j3.add(c3); + j1.setVisible(true); + j2.setVisible(true); + j3.setVisible(true); + } + private Vector3 PadCoords(int cellID) { + + double PAD_W = 2.79; // in mm + double PAD_S = 80.0; //in mm + double PAD_L = 4.0; // in mm + double RTPC_L=384.0; // in mm + double phi_pad = 0; + //double Num_of_Rows = (2.0*(Math.PI)*PAD_S)/PAD_W; + double Num_of_Cols = RTPC_L/PAD_L; + double PI=Math.PI; + double z0 = -(RTPC_L/2.0); + double phi_per_pad = PAD_W/PAD_S; // in rad + double chan = (double)cellID; + double col = chan%Num_of_Cols; + double row=(chan-col)/Num_of_Cols; + double z_shift = row%4; + + phi_pad=(row*phi_per_pad)+(phi_per_pad/2.0); + + if(phi_pad>= 2.0*PI) + { + phi_pad -= 2.0*PI; + } + if(phi_pad<0) + { + phi_pad += 2.0*PI; + } + + double z_pad=z0+(col*PAD_L)+(PAD_L/2.0)+z_shift; + + Vector3 PadCoords = new Vector3(PAD_S*Math.cos(phi_pad),PAD_S*Math.sin(phi_pad),z_pad); + return PadCoords; + + } +} diff --git a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/HitParameters.java b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/HitParameters.java new file mode 100644 index 0000000000..dc2144ff9f --- /dev/null +++ b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/HitParameters.java @@ -0,0 +1,105 @@ +package org.jlab.rec.rtpc.hit; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Vector; +import java.util.concurrent.ConcurrentHashMap; + +import org.jlab.clas.physics.LorentzVector; +import org.jlab.clas.physics.Vector3; + +public class HitParameters { + + private int _StepSize = 10; + private int _BinSize = 40; + private int _NBinKept = 3; + private int _TrigWindSize = 10000; + private int _eventnum = 0; + private HashMap _R_adc = new HashMap(); + private HashMap> _TimeMap = new HashMap>(); + private HashMap> _FinalTIDMap = new HashMap>(); + private Vector _PadN = new Vector(); // used to read only cell with signal, one entry for each hit + private Vector _PadNum = new Vector();// used to read only cell with signal, one entry for each cell + private Vector _Pad = new Vector(); + private Vector _ADC = new Vector(); + private Vector _Time_o = new Vector(); + private Vector _weightave = new Vector(); + private Vector _maxinte = new Vector(); + private Vector _time = new Vector(); + private Vector _XVec = new Vector(); + private Vector _YVec = new Vector(); + private Vector _ZVec = new Vector(); + private HashMap>> _TIDMap = new HashMap>>(); + private HashMap>> _strkTIDMap = new HashMap>>(); + private HashMap> _alltracks = new HashMap>(); + private HashMap _largetmap = new HashMap(); + private HashMap> _recohitvector = new HashMap>(); + private HashMap _padmap = new HashMap(); + private TrackMap _trackmap = new TrackMap(); + private ReducedTrackMap _rtrackmap = new ReducedTrackMap(); + + public int get_StepSize(){return _StepSize;} // step size of the signal before integration (arbitrary value) + public int get_BinSize(){return _BinSize;} // electronics integrates the signal over 40 ns + public int get_NBinKept(){return _NBinKept;} // only 1 bin over 3 is kept by the daq + public int get_TrigWindSize(){return _TrigWindSize;} // Trigger window should be 10 micro + public HashMap get_R_adc(){return _R_adc;} + public HashMap> get_TimeMap(){return _TimeMap;} + public Vector get_PadN(){return _PadN;} + public Vector get_PadNum(){return _PadNum;} + public Vector get_Pad(){return _Pad;} + public Vector get_ADC(){return _ADC;} + public Vector get_Time_o(){return _Time_o;} + public int get_eventnum(){return _eventnum;} + public Vector get_weightave() {return _weightave;} + public Vector get_maxinte() {return _maxinte;} + public Vector get_time() {return _time;} + public Vector get_XVec() {return _XVec;} + public Vector get_YVec() {return _YVec;} + public Vector get_ZVec() {return _ZVec;} + public HashMap>> get_TIDMap() {return _TIDMap;} + public HashMap>> get_strkTIDMap() {return _strkTIDMap;} + public HashMap> get_FinalTIDMap() {return _FinalTIDMap;} + public HashMap> get_alltracks() {return _alltracks;} + public HashMap get_largetmap() {return _largetmap;} + public HashMap> get_recohitvector() {return _recohitvector;} + public TrackMap get_trackmap() {return _trackmap;} + public ReducedTrackMap get_rtrackmap() {return _rtrackmap;} + public PadVector get_padvector(int pad) { + if(!_padmap.containsKey(pad)) { + _padmap.put(pad, new PadVector(pad)); + } + return _padmap.get(pad); + } + + + public void set_R_adc(HashMap _R_adc){this._R_adc = _R_adc;} + public void set_TimeMap(HashMap> _TimeMap){this._TimeMap = _TimeMap;} + public void set_PadN(Vector _PadN){this._PadN = _PadN;} + public void set_PadNum(Vector _PadNum){this._PadNum = _PadNum;} + public void set_Pad(Vector _Pad){this._Pad = _Pad;} + public void set_ADC(Vector _ADC){this._ADC = _ADC;} + public void set_Time_o(Vector _Time_o){this._Time_o = _Time_o;} + public void set_eventnum(int _eventnum){this._eventnum = _eventnum;} + public void set_weightave(Vector _weightave) {this._weightave = _weightave;} + public void set_maxinte(Vector _maxinte) {this._maxinte = _maxinte;} + public void set_time(Vector _time) {this._time = _time;} + public void set_XVec(Vector _XVec) {this._XVec = _XVec;} + public void set_YVec(Vector _YVec) {this._YVec = _YVec;} + public void set_ZVec(Vector _ZVec) {this._ZVec = _ZVec;} + public void set_TIDMap(HashMap>> _TIDMap) {this._TIDMap = _TIDMap;} + public void set_strkTIDMap(HashMap>> _strkTIDMap) {this._strkTIDMap = _strkTIDMap;} + public void set_FinalTimeMap(HashMap> _finalTIDMap){this._FinalTIDMap = _finalTIDMap;} + public void set_alltracks(HashMap> _alltracks) {this._alltracks = _alltracks;} + public void set_largetmap(HashMap _largetmap) {this._largetmap = _largetmap;} + public void set_recohitvector(HashMap> _recohitvector) {this._recohitvector = _recohitvector;} + public void set_trackmap(TrackMap _trackmap) {this._trackmap = _trackmap;} + public void set_rtrackmap(ReducedTrackMap _rtrackmap) {this._rtrackmap = _rtrackmap;} + + public HitParameters() {} + + private static HitParameters INSTANCE = new HitParameters(); + + public static HitParameters getInstance() { + return HitParameters.INSTANCE; +} +} \ No newline at end of file diff --git a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/HitReconstruction.java b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/HitReconstruction.java new file mode 100644 index 0000000000..c584416380 --- /dev/null +++ b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/HitReconstruction.java @@ -0,0 +1,204 @@ +package org.jlab.rec.rtpc.hit; + +import java.util.List; +import java.util.Vector; + +public class HitReconstruction { + + public HitReconstruction() { + // TODO Auto-generated constructor stub + } + + public void Reco(HitParameters params) { + Vector PadNum = params.get_PadNum(); + Vector weightave = params.get_weightave(); + Vector maxinte = params.get_maxinte(); + Vector TimeVec = new Vector(); + Vector XVec = new Vector(); + Vector YVec = new Vector(); + Vector ZVec = new Vector(); + int p = 0; + //for(Hit hit : rawHits) { + for(p = 0; p= 2.0*PI) { + phi_pad -= 2.0*PI; + } + if(phi_pad<0) + { + phi_pad += 2.0*PI; + } + + z_pad=z0+(col*PAD_L)+(PAD_L/2.0)+z_shift; + // ----------------------------------------------------------------------- + + + // find reconstructed position of ionization from Time info + + t_s2pad = Time-t_gap; + + r_rec=((-(Math.sqrt(a_t*a_t+(4.*b_t*t_s2pad)))+a_t+(14.*b_t))/(2.*b_t))*10.0; //in mm + + + dphi=a_phi*(7.-r_rec/10.)+b_phi*(7.-r_rec/10.)*(7.-r_rec/10.); // in rad + + + dz=0; + + phi_rec=phi_pad-dphi-phi_gap; + if( phi_rec<0.0 ) + { + phi_rec+=2.0*PI; + } + if( phi_rec>2.0*PI ) + { + phi_rec-=2.0*PI; + } + + // x,y,z pos of reconstructed track + x_rec=r_rec*(Math.cos(phi_rec)); + y_rec=r_rec*(Math.sin(phi_rec)); + z_rec=z_pad-dz; + + // x,y,z pos of pad hit + //x_pad=(PAD_S)*(Math.cos(phi_pad)); + //y_pad=(PAD_S)*(Math.sin(phi_pad)); + + // actual position on pad of hits + //phi_hit=phi_rad-(row*phi_per_pad); + //z_hit=Z-z0-(col*PAD_L)-z_shift; + + // find differences (delta = generated-reconstructed) + //delta_x=X-x_rec; + //delta_y=Y-y_rec; + //delta_z=Z-z_rec; + //delta_r=r_pos-r_rec; + //delta_phi = phi_pos-phi_rec; + + + + + /*hit.set_cellID(cellID); + hit.set_Time(t_s2pad); + hit.set_Edep(Edep); + hit.set_PosX(x_rec); + hit.set_PosY(y_rec); + hit.set_PosZ(z_rec);*/ + TimeVec.add(t_s2pad); + XVec.add(x_rec); + YVec.add(y_rec); + ZVec.add(z_rec); + + + + + } + params.set_time(TimeVec); + params.set_XVec(XVec); + params.set_YVec(YVec); + params.set_ZVec(ZVec); + //System.out.println(XVec.size() + " " + PadNum.size()); + //XVec.clear(); + //YVec.clear(); + //ZVec.clear(); + //TimeVec.clear(); + + } +} diff --git a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/HitVector.java b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/HitVector.java new file mode 100644 index 0000000000..4d32d82e14 --- /dev/null +++ b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/HitVector.java @@ -0,0 +1,87 @@ +package org.jlab.rec.rtpc.hit; + +public class HitVector { + + private int pad; + private double z; + private double phi; + private double time; + private double adc; + + public HitVector() + { + pad = 0; + z = 0; + phi = 0; + time = 0; + adc = 0; + } + + public HitVector(int padnum, double hittime, double padadc) + { + pad = padnum; + z = 0; + phi = 0; + time = hittime; + adc = padadc; + } + + public HitVector(int padnum, double zpad, double phipad, double hittime, double padadc) + { + pad = padnum; + z = zpad; + phi = phipad; + time = hittime; + adc = padadc; + } + + public void setpad(int padnum) + { + pad = padnum; + } + + public void setz(double zpad) + { + z = zpad; + } + + public void setphi(double phipad) + { + phi = phipad; + } + + public void settime(double hittime) + { + time = hittime; + } + + public void setadc(double padadc) + { + adc = padadc; + } + + public int pad() + { + return pad; + } + + public double z() + { + return z; + } + + public double phi() + { + return phi; + } + + public double time() + { + return time; + } + + public double adc() + { + return adc; + } +} diff --git a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/MapCombine.java b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/MapCombine.java new file mode 100644 index 0000000000..35688c4ac9 --- /dev/null +++ b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/MapCombine.java @@ -0,0 +1,281 @@ +package org.jlab.rec.rtpc.hit; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Vector; +import java.util.concurrent.ConcurrentHashMap; + +import javax.swing.JFrame; + +import org.jlab.clas.physics.LorentzVector; +import org.jlab.clas.physics.Vector3; +import org.jlab.groot.data.GraphErrors; +import org.jlab.groot.data.H2F; +import org.jlab.groot.graphics.EmbeddedCanvas; + +public class MapCombine { + + public void MC(HitParameters params, boolean draw) { + + HashMap> TAMap = params.get_FinalTIDMap(); + HashMap>> TFMap = params.get_strkTIDMap(); + HashMap ADCMap = params.get_R_adc(); + + Vector PadList = new Vector(); + double maxvalue = 0; + double thresh = 0; + int TrigWindSize = params.get_TrigWindSize(); + double sumnumer = 0; + double sumdenom = 0; + int count = 0; + int newtid = 0; + + HashMap weightave = new HashMap(); + HashMap weightaveadc = new HashMap(); + HashMap> trTFMap = new HashMap>(); + HashMap> alltracks = new HashMap>(); + HitVector vtmp = new HitVector(); + HitVector v3tmp = new HitVector(); + HitVector hitvec = new HitVector(); + Vector toListvec = new Vector(); + double larget = 0; + int countadcvalues = 0; + + /*GraphErrors g = new GraphErrors(); + EmbeddedCanvas c = new EmbeddedCanvas(); + JFrame jf = new JFrame(); + jf.setSize(800,600);*/ + //System.out.println(TIDMap.size()); + //for(Hit hit : rawHits) { + for(int TID : TFMap.keySet()){ + //System.out.println(" "); + larget = 0; + PadList.clear(); + weightave.clear(); + for(int time : TFMap.get(TID).keySet()) + { + for(int pad = 0; pad < TFMap.get(TID).get(time).size(); pad++) + { + //System.out.println(TID + " " + time + " " + TFMap.get(TID).get(time).get(pad)); + if(!PadList.contains(TFMap.get(TID).get(time).get(pad))) + { + PadList.add(TFMap.get(TID).get(time).get(pad)); + } + } + } + + for(int pad = 0; pad < PadList.size(); pad++) + { + for(int time : TFMap.get(TID).keySet()) + { + if(TFMap.get(TID).get(time).contains(PadList.get(pad))) + { + if(ADCMap.get(PadList.get(pad))[time]>maxvalue) + { + maxvalue = ADCMap.get(PadList.get(pad))[time]; + //System.out.println(maxvalue); + } + } + } + thresh = maxvalue/2; + for(int time = 0; time < TrigWindSize; time+=120) + { + if(ADCMap.get(PadList.get(pad))[time] > thresh) + { + sumnumer += ADCMap.get(PadList.get(pad))[time]*time; + sumdenom += ADCMap.get(PadList.get(pad))[time]; + countadcvalues++; + //System.out.println(PadList.get(pad) + " " + time); + } + } + if(sumnumer/sumdenom >= larget) + { + larget = sumnumer/sumdenom; + } + //System.out.println("weightave " + PadList.get(pad) + " " + sumnumer/sumdenom); + weightave.put(PadList.get(pad), sumnumer/sumdenom); + weightaveadc.put(PadList.get(pad), sumdenom); + sumnumer = 0; + sumdenom = 0; + maxvalue = 0; + countadcvalues = 0; + //padvec = PadCoords(PadList.get(pad)); + //gZvsT.addPoint(weightave.get(PadList.get(pad)), padvec.z(), 0, 0); + //gPhivsT.addPoint(weightave.get(PadList.get(pad)), Math.atan2(padvec.y(),padvec.x()),0,0); + } + + int pad = 0; + double avetime = 0; + double adc = 0; + trTFMap.put(TID,new Vector()); + for(int p = 0; p < PadList.size(); p++) + { + pad = PadList.get(p); + avetime = weightave.get(pad); + adc = weightaveadc.get(pad); + //LorentzVector v = new LorentzVector(avetime,Math.atan2(PadCoords(pad).y(),PadCoords(pad).x()),PadCoords(pad).z(),pad); + HitVector v = new HitVector(pad,PadCoords(pad).z(),Math.atan2(PadCoords(pad).y(),PadCoords(pad).x()),avetime,adc); + + trTFMap.get(TID).add(v); + } + + + //trTFMap.put(TID, new HashMap()); + //trTFMap.get(TID).putAll(weightave); + + //System.out.println(" "); + } + for(int choosetid : trTFMap.keySet()) { + double smalltime = 0; + for(int i = 0; i < trTFMap.get(choosetid).size(); i++) + { + smalltime = trTFMap.get(choosetid).get(i).time(); + for(int j = 0; j < trTFMap.get(choosetid).size();j++) + { + if(trTFMap.get(choosetid).get(j).time() < smalltime && i!=j) + { + trTFMap.get(choosetid).insertElementAt(trTFMap.get(choosetid).get(i), j); + trTFMap.get(choosetid).remove(i+1); + break; + } + } + } + } + + for(int i : TAMap.keySet()) + { + //toListvec.clear(); + alltracks.put(newtid, new Vector()); + for(int j = 0; j < TAMap.get(i).size(); j++) + { + vtmp = TAMap.get(i).get(j); + //v3tmp = new Vector3(vtmp.pad(),vtmp.time(),0); + //System.out.println(vtmp.e() + " " + vtmp.px()); + //System.out.println(v3tmp.x() + " " + v3tmp.y()); + //toListvec.add(v3tmp); + alltracks.get(newtid).add(vtmp); + } + //System.out.println(toListvec.size()); + //System.out.println(" "); + //alltracks.put(newtid, toListvec); + + newtid++; + + } + toListvec.clear(); + //System.out.println(" "); + for(int i : trTFMap.keySet()) + { + //System.out.println(" "); + //toListvec.clear(); + alltracks.put(newtid, new Vector()); + //for(int pad : trTFMap.get(i).keySet()) + for(int j = 0; j < trTFMap.get(i).size(); j++) + { + v3tmp = trTFMap.get(i).get(j); + //System.out.println(pad); + //v3tmp = new HitVector(pad,trTFMap.get(i).get(pad),0); + //System.out.println(v3tmp.x() + " " + v3tmp.y()); + //toListvec.add(v3tmp); + alltracks.get(newtid).add(v3tmp); + } + //System.out.println(" "); + //System.out.println(toListvec.size()); + //alltracks.put(newtid, toListvec); + newtid++; + } + HashMap largetmap = new HashMap(); + larget = 0; + HashMap histmap = new HashMap(); + HashMap canvasmap = new HashMap(); + HashMap framemap = new HashMap(); + //H2F adcvst = new H2F("adcvst",500,3000,12000,500,0,10); + //System.out.println(" "); + Vector marktid = new Vector(); + for(int i : alltracks.keySet()) + { + larget = 0; + /*if(alltracks.get(i).size() < 6) { + System.out.println("removed track with " + alltracks.get(i).size() + " hits"); + marktid.add(i); + continue; + }*/ + histmap.put(i, new GraphErrors()); + //System.out.println(i); + for(int j = 0; j < alltracks.get(i).size(); j++) + { + //if(j < 3) {g.addPoint(alltracks.get(i).get(j).y(), y, 0, 0); + //System.out.println(i + " " + alltracks.get(i).get(j).time() + " " + alltracks.get(i).get(j).adc()); + histmap.get(i).addPoint(alltracks.get(i).get(j).time(), alltracks.get(i).get(j).adc(),0,0); + if(alltracks.get(i).get(j).time() > larget) + { + larget = alltracks.get(i).get(j).time(); + + } + } + canvasmap.put(i, new EmbeddedCanvas()); + canvasmap.get(i).draw(histmap.get(i)); + framemap.put(i, new JFrame()); + framemap.get(i).setSize(800, 600); + framemap.get(i).add(canvasmap.get(i)); + if(draw) framemap.get(i).setVisible(true); + largetmap.put(i, larget); + //System.out.println(" "); + } + /*for(int i = 0; i < marktid.size(); i++) { + alltracks.remove(i); + }*/ + for(int z : canvasmap.keySet()) { + //canvasmap.get(z).save(z + ".png"); + } + EmbeddedCanvas c_adcvst = new EmbeddedCanvas(); + c_adcvst.draw(histmap.get(0)); + if(draw) { + JFrame j_adcvst = new JFrame(); + j_adcvst.setSize(800, 600); + j_adcvst.add(c_adcvst); + j_adcvst.setVisible(true); + } + + //System.out.println("There are " + alltracks.size() + " tracks sorted in this event!"); + params.set_alltracks(alltracks); + params.set_largetmap(largetmap); + } + + private Vector3 PadCoords(int cellID) { + + double PAD_W = 2.79; // in mm + double PAD_S = 80.0; //in mm + double PAD_L = 4.0; // in mm + double RTPC_L= 384.0; // in mm + double phi_pad = 0; + //double Num_of_Rows = (2.0*(Math.PI)*PAD_S)/PAD_W; + double Num_of_Cols = RTPC_L/PAD_L; + double PI=Math.PI; + double z0 = -(RTPC_L/2.0); + double phi_per_pad = PAD_W/PAD_S; // in rad + double chan = (double)cellID; + double col = chan%Num_of_Cols; + double row=(chan-col)/Num_of_Cols; + double z_shift = row%4; + + phi_pad=(row*phi_per_pad)+(phi_per_pad/2.0); + + if(phi_pad>= 2.0*PI) + { + phi_pad -= 2.0*PI; + } + if(phi_pad<0) + { + phi_pad += 2.0*PI; + } + + double z_pad=z0+(col*PAD_L)+(PAD_L/2.0)+z_shift; + + Vector3 PadCoords = new Vector3(PAD_S*Math.cos(phi_pad),PAD_S*Math.sin(phi_pad),z_pad); + return PadCoords; + + } + + +} diff --git a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/PadAve.java b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/PadAve.java new file mode 100644 index 0000000000..79f5d80b13 --- /dev/null +++ b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/PadAve.java @@ -0,0 +1,99 @@ +package org.jlab.rec.rtpc.hit; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.util.concurrent.ConcurrentHashMap; +import java.util.HashMap; +import java.util.Vector; + +public class PadAve { + public void TimeAverage(HitParameters params){ + + int StepSize = params.get_StepSize(); // step size of the signal before integration (arbitrary value) + int BinSize = params.get_BinSize(); // electronics integrates the signal over 40 ns + int NBinKept = params.get_NBinKept(); // only 1 bin over 3 is kept by the daq + int TrigWindSize = params.get_TrigWindSize(); // Trigger window should be 10 micro + int NTrigSampl = TrigWindSize/BinSize; // number of time samples + double inte=0; + double inte_tot; // integral of the signal in BinSize + double max_inte=0; // maximum of the integral to help the fit + double max_t=0; + double sumnumer = 0; + double sumdenom = 0; + double weightave = 0; + double timesum = 0; + HashMap R_adc = params.get_R_adc(); + HashMap> TimeMap = params.get_TimeMap(); + Vector PadNum = params.get_PadNum(); + Vector PadN = params.get_PadN(); + Vector Pad = params.get_Pad(); + Vector ADC = params.get_ADC(); + Vector Time_o = params.get_Time_o(); + Vector weightavevec = new Vector(); + Vector maxinte = new Vector(); + boolean flag_event = false; + int eventnum = params.get_eventnum(); + //try{ + //FileWriter write2 = new FileWriter("/Users/davidpayette/Documents/FileOutput/Output.txt",true); + //write2.write("Event Number" + "\t" + "Pad Number" + "\t" + "Time Value for each bin" + "\t" + "ADC value for each bin" + "\r\n"); + + + inte=0; + for(int p=0;p0) inte+=0.5*(R_adc.get(PadNum.get(p))[t-StepSize]+R_adc.get(PadNum.get(p))[t])*StepSize; + inte_tot+=inte; + if(t%BinSize==0 && t>0){ // integration over BinSize + if(t%(BinSize*NBinKept)==0){ // one BinSize over NBinKept is read out, hence added to the histogram + if(max_inte R_adc = params.get_R_adc(); + HashMap Adcmap = new HashMap(); + Vector PadNum = params.get_PadNum(); + Vector PadN = params.get_PadN(); + Vector Pad = params.get_Pad(); + Vector ADC = params.get_ADC(); + Vector Time_o = params.get_Time_o(); + boolean flag_event = false; + int eventnum = params.get_eventnum(); + + /*JFrame j1 = new JFrame(); + GraphErrors g1 = new GraphErrors(); + g1.setMarkerSize(0); + g1.setTitleX("Time(ns)"); + g1.setTitleY("ADC"); + g1.setMarkerSize(3); + EmbeddedCanvas c1 = new EmbeddedCanvas(); + j1.setSize(800, 600); + */ + + + //F1D f1 = new F1D("f1", "[amp]*gaus(x,[mean],[sigma])",0,1); + + inte=0; + for(int p=0;p0) inte+=0.5*(R_adc.get(PadNum.get(p))[t-StepSize]+R_adc.get(PadNum.get(p))[t])*StepSize; + + inte_tot+=inte; + if(t%BinSize==0 && t>0){ // integration over BinSize + if(t%(BinSize*NBinKept)==0){ // one BinSize over NBinKept is read out, hence added to the histogram + + Adcmap.get(PadNum.get(p))[t] = inte; + + //g1.addPoint(t,inte,0,0); + if(max_inte rawHits, HitParameters params){ + + +//______________________________________________________________________________________________ +// __________________________________________ Variables _________________________________________ +//______________________________________________________________________________________________ + + int StepSize = params.get_StepSize(); // step size of the signal before integration (arbitrary value) + int BinSize = params.get_BinSize(); // electronics integrates the signal over 40 ns + int NBinKept = params.get_NBinKept(); // only 1 bin over 3 is kept by the daq + int TrigWindSize = params.get_TrigWindSize(); // Trigger window should be 10 micro + int NTrigSampl = TrigWindSize/BinSize; // number of time samples + + HashMap R_adc = params.get_R_adc();// Raw depositions for CellID, ADC + HashMap> TimeMap = params.get_TimeMap(); + + Vector PadN = params.get_PadN(); // used to read only cell with signal, one entry for each hit + //Vector PadNum = params.get_PadNum();// used to read only cell with signal, one entry for each cell + Vector PadNum = new Vector(); + Vector ADC = new Vector(); + + Vector Pad = params.get_Pad(); + //Vector ADC = params.get_ADC(); + Vector Time_o = params.get_Time_o(); + + + + +//______________________________________________________________________________________________ +// __________________________________________ Openings __________________________________________ +//______________________________________________________________________________________________ + + int CellID = 0; + double Time; + double totEdep; + int eventnum = params.get_eventnum(); + eventnum++; + double testsum = 0; + double testcount = 1; + +//______________________________________________________________________________________________ +// __________________________________________ Readings __________________________________________ +//______________________________________________________________________________________________ + +//--Creating the signal on pads with 1 ns steps. + + + // Initializations + R_adc.clear(); // Raw depositions for CellID, adc + PadN.clear(); + PadNum.clear(); + + //Pad->clear(); + //ADC->clear(); // not reliable for now as the fit fails often + //Time_o->clear(); + + //HashMap gmap = new HashMap(); + + for(Hit hit : rawHits){ + + CellID = hit.get_cellID(); + Time = hit.get_Time(); + totEdep = hit.get_EdepTrue(); + + /*try { + + File out = new File("/Users/dpaye001/Desktop/FileOutput/event" + eventnum + "/"); + if(!out.exists()) + {out.mkdirs();} + FileWriter write = new FileWriter("/Users/dpaye001/Desktop/FileOutput/event" + eventnum + "/" + "timetrue.xls",true); + write.write(Time + "\t" + CellID + "\r\n"); + write.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + }*/ + + // searches in PadN if CellID already exists + + if(PadN.contains(CellID)){ // this pad has already seen signal + for(int t=0;t()); + TimeMap.get(CellID).add(Time); + for(int t=0;t= 2.0*PI) + { + phi_pad -= 2.0*PI; + } + if(phi_pad<0) + { + phi_pad += 2.0*PI; + } + + z_pad=z0+(col*PAD_L)+(PAD_L/2.0)+z_shift; + + set_x(PAD_S*Math.cos(phi_pad)); + set_y(PAD_S*Math.sin(phi_pad)); + set_z(z_pad); + set_phi(phi_pad); + } + + private void set_x(double x){ + _x = x; + } + + private void set_y(double y){ + _y = y; + } + + private void set_z(double z){ + _z = z; + } + + private void set_phi(double phi){ + _phi = phi; + } + + public double x(){ + return _x; + } + + public double y(){ + return _y; + } + + public double z(){ + return _z; + } + + public double phi(){ + return _phi; + } +} diff --git a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/RecoHitVector.java b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/RecoHitVector.java new file mode 100644 index 0000000000..6837eee147 --- /dev/null +++ b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/RecoHitVector.java @@ -0,0 +1,94 @@ +package org.jlab.rec.rtpc.hit; + +public class RecoHitVector { + + private int pad; + private double x; + private double y; + private double z; + private double dt; + private double time; + + public RecoHitVector() + { + pad = 0; + x = 0; + y = 0; + z = 0; + dt = 0; + time = 0; + } + + public RecoHitVector(int padnum, double xrec, double yrec, double zrec, double tdiff, double t) + { + pad = padnum; + x = xrec; + y = yrec; + z = zrec; + dt = tdiff; + time = t; + } + + public void setpad(int padnum) + { + pad = padnum; + } + + public void setx(double xrec) + { + x = xrec; + } + + public void sety(double yrec) + { + y = yrec; + } + + public void setz(double zrec) + { + z = zrec; + } + + public void settime(double t) + { + time = t; + } + + public void setdt(double tdiff) + { + dt = tdiff; + } + + public int pad() + { + return pad; + } + + public double x() + { + return x; + } + + public double y() + { + return y; + } + + public double z() + { + return z; + } + + public double time() + { + return time; + } + + public double dt() + { + return dt; + } + + + +} diff --git a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/ReducedTrack.java b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/ReducedTrack.java new file mode 100644 index 0000000000..08810c5875 --- /dev/null +++ b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/ReducedTrack.java @@ -0,0 +1,61 @@ +package org.jlab.rec.rtpc.hit; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; + +public class ReducedTrack { + + private List _hits = new ArrayList(); + private boolean _flagTrack = false; + + public ReducedTrack() { + //Default Constructor + } + + public void addHit(HitVector v) { + _hits.add(v); + } + + public void sortHits() { + Collections.sort(_hits, new Comparator() { + @Override + public int compare(HitVector v1, HitVector v2) { + return Double.compare(v2.time(),v1.time()); + } + }); + } + + public double getSmallT() { + return _hits.get(_hits.size()-1).time(); + } + + public double getLargeT() { + return _hits.get(0).time(); + } + + public Set getAllPads() { + Set pads = new HashSet(); + for(HitVector v : _hits) { + pads.add(v.pad()); + } + return pads; + } + + public List getAllHits() { + return _hits; + } + + public void flagTrack() { + _flagTrack = true; + } + + public boolean isTrackFlagged() { + return _flagTrack; + } + +} diff --git a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/ReducedTrackMap.java b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/ReducedTrackMap.java new file mode 100644 index 0000000000..4ea6a3f7a1 --- /dev/null +++ b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/ReducedTrackMap.java @@ -0,0 +1,59 @@ +package org.jlab.rec.rtpc.hit; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ConcurrentHashMap; +import java.util.HashMap; + +public class ReducedTrackMap { + + private HashMap _map; + private int _trackID = 0; + + public ReducedTrackMap() { + _map = new HashMap(); + } + + public void addTrack(ReducedTrack t) { + _trackID++; + _map.put(_trackID, t); + } + + public ReducedTrack getTrack(int trackID) { + if(!_map.containsKey(trackID)) { + addTrack(new ReducedTrack()); + } + return _map.get(trackID); + } + + public void updateTrack(int trackID, ReducedTrack t) { + _map.put(trackID, t); + } + + public void removeTrack(int trackID) { + _map.remove(trackID); + } + + public List getAllTrackIDs() { + List l = new ArrayList(); + for(int i : _map.keySet()) { + if(!l.contains(i)) { l.add(i);} + } + return l; + } + + public int getLastTrackID() { + return _trackID; + } + + public void mergeTracks(int trackIDparent, int trackID) { + ReducedTrack child = getTrack(trackID); + List l = child.getAllHits(); + ReducedTrack parent = getTrack(trackIDparent); + for(HitVector v : l) { + parent.addHit(v); + } + removeTrack(trackID); + } + +} diff --git a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TimeAverage.java b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TimeAverage.java new file mode 100644 index 0000000000..85dfb5d15c --- /dev/null +++ b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TimeAverage.java @@ -0,0 +1,389 @@ +package org.jlab.rec.rtpc.hit; + +import java.util.Collections; +import java.util.HashMap; +import java.util.Vector; +import java.util.concurrent.ConcurrentHashMap; + +import javax.swing.JFrame; + +import org.jlab.clas.physics.LorentzVector; +import org.jlab.clas.physics.Vector3; +import org.jlab.groot.data.GraphErrors; +import org.jlab.groot.graphics.EmbeddedCanvas; +import org.jlab.groot.math.F1D; + +public class TimeAverage { + + public void TA(HitParameters params, boolean draw) { + + HashMap ADCMap = params.get_R_adc(); + HashMap>> TIDMap = params.get_TIDMap(); + HashMap> trTIDMap = new HashMap>(); + HashMap> FinalTIDMap = new HashMap>(); + Vector PadList = new Vector(); + HashMap> hitlist = new HashMap>(); + int TrigWindSize = params.get_TrigWindSize(); + //int choosetid = 1; + int StepSize = 120; + double thresh = 0; + Vector3 padvec = new Vector3(); + LorentzVector test4vec = new LorentzVector(); + double sumnumer = 0; + double sumdenom = 0; + double maxvalue = 0; + int countadc = 0; + int newtidcounter = 1; + int tidsum = 0; + int min_pads = 3; + double phithresh = 0.6; + double zthresh = 24; + double timethresh = 1500; + + HashMap weightave = new HashMap(); + HashMap weightaveadc = new HashMap(); + + HashMap> gZvsT = new HashMap>(); + HashMap> gPhivsT = new HashMap>(); + + EmbeddedCanvas c = new EmbeddedCanvas(); + c.divide(5, 5); + EmbeddedCanvas c2 = new EmbeddedCanvas(); + c2.divide(5, 5); + int plotcounter = 0; + + JFrame jfr = new JFrame(); + jfr.setSize(1200,1200); + JFrame jfr2 = new JFrame(); + jfr2.setSize(1200,1200); + + + boolean drawellipse = false; + + + F1D ellipse1a = new F1D("ellipse1a","sqrt([b]*[b](1-((x-[h])*(x-[h])/([a]*[a]))))+[k]",2500,4508); + F1D ellipse1b = new F1D("ellipse1b","-sqrt([b]*[b](1-((x-[h])*(x-[h])/([a]*[a]))))+[k]",2500,4508); + F1D ellipse2a = new F1D("ellipse2a","sqrt([b]*[b](1-((x-[h])*(x-[h])/([a]*[a]))))+[k]",2800,4210); + F1D ellipse2b = new F1D("ellipse2b","-sqrt([b]*[b](1-((x-[h])*(x-[h])/([a]*[a]))))+[k]",2800,4210); + ellipse1a.setParameter(0, 50); + ellipse1a.setParameter(1, 3500); + ellipse1a.setParameter(2, 1000); + ellipse1a.setParameter(3, -75); + ellipse1b.setParameter(0, 50); + ellipse1b.setParameter(1, 3500); + ellipse1b.setParameter(2, 1000); + ellipse1b.setParameter(3, -75); + + ellipse2a.setParameter(0, 75); + ellipse2a.setParameter(1, 3500); + ellipse2a.setParameter(2, 1400); + ellipse2a.setParameter(3, -75); + ellipse2b.setParameter(0, 75); + ellipse2b.setParameter(1, 3500); + ellipse2b.setParameter(2, 1400); + ellipse2b.setParameter(3, -75); + + for(int choosetid : TIDMap.keySet()) + { + + for(int time : TIDMap.get(choosetid).keySet()) + { + //System.out.println(time); + for(int pad = 0; pad < TIDMap.get(choosetid).get(time).size(); pad++) + { + if(!PadList.contains(TIDMap.get(choosetid).get(time).get(pad))) + { + PadList.add(TIDMap.get(choosetid).get(time).get(pad)); + } + } + } + + for(int pad = 0; pad < PadList.size(); pad++) + { + for(int time : TIDMap.get(choosetid).keySet()) + { + if(TIDMap.get(choosetid).get(time).contains(PadList.get(pad))) + { + if(ADCMap.get(PadList.get(pad))[time]>maxvalue) + { + maxvalue = ADCMap.get(PadList.get(pad))[time]; + } + } + } + thresh = maxvalue/2; + countadc = 0; + for(int time = 0; time < TrigWindSize; time+=120) + { + if(ADCMap.get(PadList.get(pad))[time] > thresh) + { + sumnumer += ADCMap.get(PadList.get(pad))[time]*time; + sumdenom += ADCMap.get(PadList.get(pad))[time]; + countadc++; + //System.out.println(PadList.get(pad) + " " + time); + } + } + //System.out.println("weightave " + PadList.get(pad) + " " + sumnumer/sumdenom); + weightave.put(PadList.get(pad), sumnumer/sumdenom); + weightaveadc.put(PadList.get(pad), sumdenom); + sumnumer = 0; + sumdenom = 0; + maxvalue = 0; + padvec = PadCoords(PadList.get(pad)); + //gZvsT.addPoint(weightave.get(PadList.get(pad)), padvec.z(), 0, 0); + //gPhivsT.addPoint(weightave.get(PadList.get(pad)), Math.atan2(padvec.y(),padvec.x()),0,0); + } + int pad = 0; + double avetime = 0; + double adc = 0; + trTIDMap.put(choosetid,new Vector()); + for(int p = 0; p < PadList.size(); p++) + { + pad = PadList.get(p); + avetime = weightave.get(pad); + adc = weightaveadc.get(pad); + //LorentzVector v = new LorentzVector(avetime,Math.atan2(PadCoords(pad).y(),PadCoords(pad).x()),PadCoords(pad).z(),pad); + HitVector v = new HitVector(pad,PadCoords(pad).z(),Math.atan2(PadCoords(pad).y(),PadCoords(pad).x()),avetime,adc); + + trTIDMap.get(choosetid).add(v); + } + double smalltime = 0; + for(int i = 0; i < trTIDMap.get(choosetid).size(); i++) + { + smalltime = trTIDMap.get(choosetid).get(i).time(); + for(int j = 0; j < trTIDMap.get(choosetid).size();j++) + { + if(trTIDMap.get(choosetid).get(j).time() < smalltime && i!=j) + { + trTIDMap.get(choosetid).insertElementAt(trTIDMap.get(choosetid).get(i), j); + trTIDMap.get(choosetid).remove(i+1); + break; + } + } + } + int newtid = 150; + + + HitVector padcoords = new HitVector(); + HitVector checkpadcoords = new HitVector(); + + while(trTIDMap.get(choosetid).size()!=0) + { + hitlist.put(choosetid, new Vector()); + hitlist.get(choosetid).add(0); + padcoords = trTIDMap.get(choosetid).get(0); + for(int i = 1; i < trTIDMap.get(choosetid).size(); i++) + { + checkpadcoords = trTIDMap.get(choosetid).get(i); + if(Math.abs(checkpadcoords.time() - padcoords.time()) < timethresh && (Math.abs(checkpadcoords.phi()-padcoords.phi())()); + for(int i = 0; i < hitlist.get(choosetid).size(); i++) + { + trTIDMap.get(newtid).add(trTIDMap.get(choosetid).get(hitlist.get(choosetid).get(i))); + trTIDMap.get(choosetid).set(hitlist.get(choosetid).get(i),new HitVector(0,1e10,0)); + } + for(int i = 0; i < trTIDMap.get(choosetid).size(); i ++) + { + if(trTIDMap.get(choosetid).get(i).time() == 1e10) + { + trTIDMap.get(choosetid).remove(i); + i--; + } + } + hitlist.clear(); + newtid++; + } + trTIDMap.remove(choosetid); + HashMap> mergelist = new HashMap>(); + Vector mergelistvec = new Vector(); + int mergelistindex = 0; + HitVector testvec1 = new HitVector(); + HitVector testvec2 = new HitVector(); + for(int i : trTIDMap.keySet()) + { + mergelist.put(mergelistindex, new Vector()); + for(int f = trTIDMap.get(i).size() - 1; f >= (trTIDMap.get(i).size() - 5) && f > 0; f--) + { + testvec1 = trTIDMap.get(i).get(f); + for(int j : trTIDMap.keySet()) + { + if(i!=j) + { + for(int g = trTIDMap.get(j).size() - 1; g >= (trTIDMap.get(j).size() - 5) && g > 0; g--) + { + //System.out.println(f + " " + g); + testvec2 = trTIDMap.get(j).get(g); + if((Math.abs(testvec1.time() - testvec2.time()) < timethresh) && (Math.abs(testvec1.phi()-testvec2.phi())()); + for(int f = 0; f <= 5; f++) + { + if(f < trTIDMap.get(i).size()) { + testvec1 = trTIDMap.get(i).get(f); + for(int j : trTIDMap.keySet()) + { + if(i!=j) + { + for(int g = trTIDMap.get(j).size() - 1; g >= (trTIDMap.get(j).size() - 5) && g > 0; g--) + { + //System.out.println(f + " " + g); + testvec2 = trTIDMap.get(j).get(g); + if((Math.abs(testvec1.time() - testvec2.time()) < timethresh) && (Math.abs(testvec1.phi()-testvec2.phi())1) + { + TIDtokeep = mergelist.get(i).get(0); + for(int l = 1; l < mergelist.get(i).size(); l++) + { + TIDtomerge = mergelist.get(i).get(l); + trTIDMap.get(TIDtokeep).addAll(trTIDMap.get(TIDtomerge)); + trTIDMap.remove(TIDtomerge); + } + } + } + Vector toremove = new Vector(); + for(int i : trTIDMap.keySet()) + { + if(trTIDMap.get(i).size() < min_pads) + { + toremove.add(i); + } + } + for(int i = 0; i < toremove.size(); i++) + { + trTIDMap.remove(toremove.get(i)); + } + gZvsT.put(choosetid, new HashMap()); + c.cd(plotcounter); + gPhivsT.put(choosetid, new HashMap()); + c2.cd(plotcounter); + for(int i : trTIDMap.keySet()) + { + FinalTIDMap.put(newtidcounter,new Vector()); + gZvsT.get(choosetid).put(i, new GraphErrors()); + gZvsT.get(choosetid).get(i).setTitle("Z vs T"); + gPhivsT.get(choosetid).put(i, new GraphErrors()); + gPhivsT.get(choosetid).get(i).setTitle("Phi vs T"); + for(int j = 0; j < trTIDMap.get(i).size(); j++) + { + gZvsT.get(choosetid).get(i).addPoint(trTIDMap.get(i).get(j).time(), trTIDMap.get(i).get(j).z(), 0, 0); + gPhivsT.get(choosetid).get(i).addPoint(trTIDMap.get(i).get(j).time(), trTIDMap.get(i).get(j).phi(), 0, 0); + FinalTIDMap.get(newtidcounter).add(trTIDMap.get(i).get(j)); + } + gZvsT.get(choosetid).get(i).setMarkerSize(2); + gZvsT.get(choosetid).get(i).setMarkerColor(i-149); + gPhivsT.get(choosetid).get(i).setMarkerSize(2); + gPhivsT.get(choosetid).get(i).setMarkerColor(i-149); + c.draw(gZvsT.get(choosetid).get(i),"same"); + c2.draw(gPhivsT.get(choosetid).get(i),"same"); + newtidcounter++; + } + tidsum+= trTIDMap.size(); + PadList.clear(); + weightave.clear(); + trTIDMap.clear(); + hitlist.clear(); + mergelist.clear(); + plotcounter++; + } + //System.out.println(plotcounter); + //System.out.println("tidsum " + tidsum + "final map size " + FinalTIDMap.size()); + /* + for(int i : gZvsT.keySet()) + { + c.cd(plotcounter); + for(int j : gZvsT.get(i).keySet()) + { + c.draw(gZvsT.get(i).get(j),"same"); + } + plotcounter++; + }*/ + if(draw) { + jfr.add(c); + jfr.setTitle("Time Averaged ZvsT"); + jfr.setVisible(true); + jfr2.add(c2); + jfr2.setTitle("Time Averaged PhivsT"); + jfr2.setVisible(true); + } + params.set_FinalTimeMap(FinalTIDMap); + } + + private Vector3 PadCoords(int cellID) { + + double PAD_W = 2.79; // in mm + double PAD_S = 80.0; //in mm + double PAD_L = 4.0; // in mm + double RTPC_L= 384.0; // in mm + double phi_pad = 0; + //double Num_of_Rows = (2.0*(Math.PI)*PAD_S)/PAD_W; + double Num_of_Cols = RTPC_L/PAD_L; + double PI=Math.PI; + double z0 = -(RTPC_L/2.0); + double phi_per_pad = PAD_W/PAD_S; // in rad + double chan = (double)cellID; + double col = chan%Num_of_Cols; + double row=(chan-col)/Num_of_Cols; + double z_shift = row%4; + + phi_pad=(row*phi_per_pad)+(phi_per_pad/2.0); + + if(phi_pad>= 2.0*PI) + { + phi_pad -= 2.0*PI; + } + if(phi_pad<0) + { + phi_pad += 2.0*PI; + } + + double z_pad=z0+(col*PAD_L)+(PAD_L/2.0)+z_shift; + + Vector3 PadCoords = new Vector3(PAD_S*Math.cos(phi_pad),PAD_S*Math.sin(phi_pad),z_pad); + return PadCoords; + + } + + +} diff --git a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TimeAverage2.java b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TimeAverage2.java new file mode 100644 index 0000000000..90b806119f --- /dev/null +++ b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TimeAverage2.java @@ -0,0 +1,159 @@ +//Author: David Payette + +/* This code takes the tracks from the Track Finder, and reduces the signals in the track to single + * values in time by taking a weighted average of the signal using the ADC value as the weight + * The end result is the same tracks but with hits which now have non-discritized times (not in + * 120 ns slices) This is useful for the disentangler to split merged tracks + */ + +package org.jlab.rec.rtpc.hit; + +import java.util.HashMap; +import java.util.concurrent.ConcurrentHashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import javax.swing.JFrame; + +import org.jlab.groot.data.GraphErrors; +import org.jlab.groot.graphics.EmbeddedCanvas; + +public class TimeAverage2 { + + public TimeAverage2(HitParameters params, boolean draw) { + /* + *Initializations + */ + + ReducedTrackMap RTIDMap = new ReducedTrackMap(); + ReducedTrack rtrack; + TrackMap TIDMap = params.get_trackmap(); + HashMap ADCMap = params.get_R_adc(); + List tids = TIDMap.getAllTrackIDs(); + Track track; + double adc = 0; + double adcmax = 0; + double averagetime = 0; + double adcthresh = 0; + double sumnum = 0; + double sumden = 0; + + /* + * Main Algorithm + */ + + for(int tid : tids) { + track = TIDMap.getTrack(tid); + boolean trackflag = track.isTrackFlagged(); + rtrack = new ReducedTrack(); + if(trackflag) {rtrack.flagTrack();} + Set l = track.uniquePadList(); + Set timesbypad = new HashSet(); + for(int pad : l) { + adcmax = 0; + sumnum = 0; + sumden = 0; + timesbypad = track.PadTimeList(pad); + for(int time : timesbypad) { //Loop to calculate maximum adc value + adc = ADCMap.get(pad)[time]; + if(adc > adcmax) { + adcmax = adc; + } + } + adcthresh = adcmax/2; + for(int time : timesbypad) { //Loop to calculate weighted average time using ADC values which are above half of the maximum + adc = ADCMap.get(pad)[time]; + if(adc > adcthresh) { + sumnum += adc*time; + sumden += adc; + } + } + averagetime = sumnum/sumden; + PadVector p = params.get_padvector(pad); + HitVector v = new HitVector(pad,p.z(),p.phi(),averagetime,sumden); + rtrack.addHit(v); + } + RTIDMap.addTrack(rtrack); + } + + /* + * Output + */ + + params.set_rtrackmap(RTIDMap); + + /* + * Drawing for debugging + */ + + if(draw) { + + HashMap gmapzvsphi = new HashMap(); + EmbeddedCanvas cZvsPhi = new EmbeddedCanvas(); + JFrame jZvsPhi = new JFrame(); + jZvsPhi.setSize(800,800); + + HashMap gmapphivst = new HashMap(); + EmbeddedCanvas cPhivsT = new EmbeddedCanvas(); + JFrame jPhivsT = new JFrame(); + jPhivsT.setSize(800,800); + + HashMap gmapzvst = new HashMap(); + EmbeddedCanvas cZvsT = new EmbeddedCanvas(); + JFrame jZvsT = new JFrame(); + jZvsT.setSize(800,800); + int color = 1; + int style = 1; + for(int tid : RTIDMap.getAllTrackIDs()) { + ReducedTrack t = RTIDMap.getTrack(tid); + gmapzvsphi.put(tid, new GraphErrors()); + gmapphivst.put(tid, new GraphErrors()); + gmapzvst.put(tid, new GraphErrors()); + for(HitVector v : t.getAllHits()) { + double time = v.time(); + gmapzvsphi.get(tid).addPoint(v.phi(), v.z(), 0, 0); + gmapzvst.get(tid).addPoint(time, v.z(), 0, 0); + gmapphivst.get(tid).addPoint(time, v.phi(), 0, 0); + } + gmapzvsphi.get(tid).setMarkerColor(color); + gmapzvsphi.get(tid).setMarkerSize(3); + gmapzvsphi.get(tid).setMarkerStyle(style); + + gmapzvst.get(tid).setMarkerColor(color); + gmapzvst.get(tid).setMarkerSize(3); + gmapzvst.get(tid).setMarkerStyle(style); + + gmapphivst.get(tid).setMarkerColor(color); + gmapphivst.get(tid).setMarkerSize(3); + gmapphivst.get(tid).setMarkerStyle(style); + + cZvsPhi.draw(gmapzvsphi.get(tid),"same"); + cZvsT.draw(gmapzvst.get(tid),"same"); + cPhivsT.draw(gmapphivst.get(tid),"same"); + + color++; + if(color > 8) { + color = 1; + style++; + } + + } + + jZvsPhi.setTitle("Time Average Output"); + jZvsPhi.add(cZvsPhi); + jZvsPhi.setVisible(true); + + jZvsT.setTitle("Time Average Output"); + jZvsT.add(cZvsT); + //jZvsT.setVisible(true); + + jPhivsT.setTitle("Time Average Output"); + jPhivsT.add(cPhivsT); + //jPhivsT.setVisible(true); + + } + + } + +} diff --git a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/Track.java b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/Track.java new file mode 100644 index 0000000000..2e0b62c631 --- /dev/null +++ b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/Track.java @@ -0,0 +1,117 @@ +package org.jlab.rec.rtpc.hit; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; +import java.util.HashMap; + +public class Track { + + private HashMap> _track = new HashMap>(84,1.0f); + private List _l = new ArrayList(); + //private int _padcount; + private boolean _flagTrack = false; + + public Track() { + //default constructor + } + public Track(int time, int padnum) { + if(!_track.containsKey(time)) { + addTimeSlice(time); + } + addPad(time,padnum); + } + + public void addTimeSlice(int time) { + _track.put(time, new ArrayList()); + } + + public void addTimeSlice(int time, List l) { + List templ = getTimeSlice(time); + for(int i : l) { + if(!templ.contains(i)) { + templ.add(i); + } + } + } + + public void addPad(int time, int padnum) { + _track.get(time).add(padnum); + } + + public List getTimeSlice(int time) { + if(!_track.containsKey(time)) { + addTimeSlice(time); + } + return _track.get(time); + } + + public List getAllTimeSlices(){ + List l = new ArrayList(); + for(int i : _track.keySet()) { + l.add(i); + } + return l; + } + + public boolean padExists(int time, int padnum) { + _l = getTimeSlice(time); + return _l.contains(padnum); + } + + public int padCountbyTime(int time) { + _l = getTimeSlice(time); + return _l.size(); + } + + public int padCountTotal() { + int _padcount = 0; + for(int time : _track.keySet()) { + _padcount += padCountbyTime(time); + } + return _padcount; + } + + public void flagTrack() { + _flagTrack = true; + } + + public boolean isTrackFlagged() { + return _flagTrack; + } + + public Set uniquePadList() { + List slice = new ArrayList(); + Set pads = new HashSet(); + for(int time : _track.keySet()) { + slice = getTimeSlice(time); + for(int pad : slice) { + + pads.add(pad); + + } + } + return pads; + } + + public Set PadTimeList(int pad) { + Set times = new HashSet(); + List allslices = getAllTimeSlices(); + List t = new ArrayList(); + for(int slice : allslices) { + t = getTimeSlice(slice); + if(t.contains(pad)) { + times.add(slice); + } + } + return times; + } + + public int uniquePadCountTotal() { + + return uniquePadList().size(); + + } + +} diff --git a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TrackFinder2.java b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TrackFinder2.java new file mode 100644 index 0000000000..fdfe402efb --- /dev/null +++ b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TrackFinder2.java @@ -0,0 +1,994 @@ +package org.jlab.rec.rtpc.hit; + +import java.awt.Component; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.concurrent.ConcurrentHashMap; +import java.util.List; +import java.util.Vector; +import javax.swing.JFrame; +import org.jlab.groot.data.*; +import org.jlab.groot.fitter.*; +import org.jlab.groot.graphics.*; +import org.jlab.groot.math.F1D; +import org.jlab.groot.ui.TCanvas; +//import org.jlab.clas.physics.Vector3; + + + +public class TrackFinder2 { + + /*************************************** + * Author: David Payette + * + * The function FindTrack2 is divided into 3 main parts, the sorting algorithm, the merging algorithm, + * and plotting. The sorting algorithm builds a map call TIDMap. It starts empty and will be filled with + * track IDs (TIDs), each one returning a map of time slices (120 ns) that each contain a vector of pads which were sorted + * together in this time slice. So TIDMap.get(1).get(120).get(3) will give you the fourth pad at 120 ns that has TID 1. + * The sorting algorithm contains a series of nested loops as follows: The TIMELOOP loops through values of time starting + * at 0 and moving in steps of 120 ns up to the TrigWindSize (10000 ns). Then there is a PADLOOP which loops through all + * the pads which saw a signal in the simulation. The signal shape is created in PadHit for now since GEMC does not do signal + * simulation for our purposes yet. This signal is then integrated into 120 ns bins which is based on the Dream chip timing. + * For each pad in the loop, it checks for the ADC value at the current time, + * and if it passes an ADC threshold, then it moves on to be sorted. The TIDLOOP loops through all elements of a vector TIDVec, + * which initially only contains TID 1 and will add TIDs as necessary. If the TIDMap does not contain the current TID in the + * vector then it adds it to the map. Otherwise, the current pad in the loop is checked against all other pads assigned to + * the current TID by comparing the distance between the pads to a preset ellipse formula. This check is done for the current + * time slice, and a set number (timeadj) of previous time slices. If a pad is close enough to another pad with an assigned + * TID then it is also assigned this TID. A pad is allowed to be assigned multiple TIDs at this stage, which will flag the + * merging algorithm to remember to merge these TIDs later after the sort. If a pad makes it to the end of the TIDLOOP and still + * has not been sorted then it will be assigned a new TID as the new TID is added to the map. The merging algorithm looks + * for TIDs which were flagged to be merged during sort and combines them all into the lowest numbered TID and then the + * other TIDs are removed from the map. + * + * TIMELOOP: 0->10000 in 120 ns steps + * { + * PADLOOP: All pads which have an ADC value that passes threshold for current time + * { + * TIDLOOP: Loop through TIDs in TIDVec + * if(TID is in map){ Compare pad to other pads (PADINDEXLOOP) in current and previous times (PREVTIMELOOP) and see + * if it is near enough (using ellipse formula) } + * else{ If pad has not been assigned at least one TID, assign it a new one and add it to the map } + * + * if(pad has more than one TID){ group the TIDs into MapCombine, using the smallest one as the key } + * } + * } + * + * Loop over the keys of MapCombine, and take all the TIDs assigned to each key and merge them into the key TID and + * remove them from the TIDMap. + * + * Plot a bunch of stuff for testing. + * + * The ellipse formula looks like this: + * + * (dx^2 + dy^2)/phi_0^2 + (dz^2)/z_0^2 <= adjthresh^2 + * + * dx, dy, and dz are the distances between two pads, phi_0 and z_0 are set parameters that define the ellipse, + * and adjthresh is the maximum level of adjacency we allow. This determines how many rings of adjacent pads are + * close enough. + ****************************************/ + + public void FindTrack2(HitParameters params, boolean draw){ + /*************************************** + * + * INITIALIZE VARIABLES + * + ****************************************/ + //HashMap> TIDMap = new HashMap>(); + //HashMap PadThresh = new HashMap(); + //HashMap>> FixedTIDMap = new HashMap>>(); + //double PadPhistore = 0; + //double PadZstore = 0; + //boolean PadPhiChanged = false; + //Necessary pad variables + //double PAD_W = 2.79; //in mm + //double PAD_S = 80.0; //in mm + //double Num_of_Rows = (2.0*(Math.PI)*PAD_S)/PAD_W; + //int padindexmax = 0; Not being used currently + //double time1 = System.currentTimeMillis(); + /* Not being used currently + * int maxconcpads = 0; + * int concpads = 0; + * int maxconctime = 0; + */ + + + + HashMap ADCMap = params.get_R_adc(); //Key - Cell ID, Value - Array of signal height over time slices + + /** + * TIDMap contains a HashMap of Vectors + * The key is Track ID (TID), which returns a map + * The key of the returned map is Time, which returns a vector + * The elements of the vector are pads + * This stores all pads in each time slice, and all time slices for each TID + * Example :: Track ID 1, Time 120 contains pads: 3,4,5,7 so using the call + * TIDMap.get(1).get(120).get(3) will give you pad 5 + */ + HashMap>> TIDMap = new HashMap>>(); + + /** + * strkTIDMap uses the same structure as TIDMap but is used at the end to isolate + * TIDs which only contain single tracks. This map is all TIDs not sent to the disentangler + */ + HashMap>> strkTIDMap = new HashMap>>(); + + + Vector PadNum = params.get_PadNum(); //Contains pads used in PadHit + Vector TIDVec = new Vector<>(); //Contains all TIDs and is added to throughout, + TIDVec.add(1); //Starts with TID 1 + + + int Pad = 0; //initializing pad + double ADC = 0; //initializing ADC + int TrigWindSize = params.get_TrigWindSize(); //Trigger Window Size = 10000 + //int StepSize = params.get_StepSize(); + int StepSize = 120; //Time stepsize in ns + double adcthresh = 5e-4; //Arbitrary ADC threshold + + int min_pads = 0; //Minimum number of pads required to keep as a track + + //These vectors will contain x,y,z for each pad being checked + //Vector3 TempPadCoords = new Vector3(); + //Vector3 CheckPadCoords = new Vector3(); + //Vector3 CheckPadPrevCoords = new Vector3(); + + PadVector TempPadCoords;// = new PadVector(); + PadVector CheckPadCoords; + PadVector CheckPadPrevCoords; + + int TID = 0; //initialize TID + + //used for plotting + double plotphi = 0; + double plotz = 0; + + int timeadj = 2; //How many previous time slices to check in algorithm + int event = params.get_eventnum(); //event number only used for file number + + + //Initialize Ellipse Variables used for adjacency checks + double adjthresh = 12; //sqrt(right hand side of ellipse formula) + double EllipseDeltax = 0; //dx + double EllipseDeltay = 0; //dy + double EllipseDeltaz = 0; //dz + double EllipseTotal = 0; //left hand side of ellipse formula + double PhiDelta = 16; //phi_0 + double ZDelta = 36; //z_0 + + double phithresh = 0.15; + double zthresh = 10; + + //set variables for timing cut (currently time cut is not used, cuts on time happen later) + int tmin = 0; //min timing in ns + int trange = 20000; //added to min to calculate max in ns + int tmax = tmin+trange; + + //Maps and variables used for combining TIDs later in the merge algorithm + boolean PadSorted = false; + Vector PadTIDcollect = new Vector(); + Vector TIDcombine = new Vector(); + HashMap> MapCombine = new HashMap>(); + int mapkey = 0; + + //Map of graphs of ADC vs Time + HashMap gADCvsT = new HashMap(); + + //g.setTitleX("Phi"); + //g.setTitleY("Z"); + //g.setMarkerSize(5); + + try { + File f = new File("/Users/davidpayette/Documents/FileOutput/Output" + event + ".txt"); + f.delete(); + FileWriter write2 = new FileWriter("/Users/davidpayette/Documents/FileOutput/Output" + event + ".txt",true); + //File f2 = new File("/Users/davidpayette/Documents/FileOutput/Master.txt"); + FileWriter write3 = new FileWriter("/Users/davidpayette/Documents/FileOutput/Master.txt",true); + //Collections.sort(PadNum); + //H1F t2 = new H1F("t2","t2",TrigWindSize/StepSize,0,TrigWindSize); + + GraphErrors t1 = new GraphErrors(); + int counter = 0; + HashMap countermap = new HashMap(); + + /*************************************** + * + * SORTING ALGORITHM + * + ****************************************/ + /**loop over all times in 120 ns slices**/ + TIMELOOP: //these labels are not used for the most part, but help to label the loops + for(int t = 0; t < TrigWindSize; t += StepSize) + { + //System.out.println("Time is " + t); + //concpads = 0; + + /**loop over all pads for each time slice**/ + int padloopsize = PadNum.size(); + PADLOOP: + for(int p = 0; p < padloopsize; p++) + { + + PadSorted = false; + PadTIDcollect.clear(); + Pad = PadNum.get(p); + + //System.out.println(PadNum.size() + " size"); + //System.out.println(Pad + " " + t); + + ADC = ADCMap.get(Pad)[t]; + + /**only pads which have an ADC value above threshold will be assigned a TID**/ + if(ADC > adcthresh) + { + //write3.write(ADC + "\n"); + /**This is used for testing something else**/ + if(Pad == 11091) + { + t1.addPoint(t, ADCMap.get(Pad)[t], 0, 0); + //t2.fill(t); + } + if(!countermap.containsKey(Pad)) + { + countermap.put(Pad, 1); + } + else + { + counter = countermap.get(Pad); + counter++; + countermap.put(Pad,counter); + } + + //Plots ADC vs T for each Pad + if(!gADCvsT.containsKey(Pad)) + { + gADCvsT.put(Pad, new GraphErrors()); + gADCvsT.get(Pad).addPoint(t, ADCMap.get(Pad)[t], 0, 0); + } + else + { + gADCvsT.get(Pad).addPoint(t, ADCMap.get(Pad)[t], 0, 0); + } + /*******************************************/ + //System.out.println("Pad to be checked " + Pad + " checked at time " + t); + + //returns x,y,z of the current Pad + //Vector3 PadCoords = PadCoords(Pad); + PadVector PadCoords = params.get_padvector(Pad); + + //System.out.println("Pad " + Pad + " has row and column values " + PadPhi + " " + PadZ); + //g.addPoint(PadPhi, PadZ, 0, 0); + + /**loop through all TID's in a vector which will grow to include all future TID's**/ + int tidloopsize = TIDVec.size(); + TIDLOOP: + for(int i = 0; i < tidloopsize; i++) + { + TID = TIDVec.get(i); //returns current TID to sort into + //System.out.println("Current TID " + TID); + + /**if TID is already in the map**/ + if(TIDMap.containsKey(TID)) + { + //System.out.println("TID " + TID + " is already in the map"); + + /**loop through all pads in TIDMap and compare there row and column to current Pad**/ + PADINDEXLOOP: + for(int padindex = 0; padindex < 100; padindex++) //TODO 100 is unnecessary placeholder + { + //System.out.println("Pad index is " + padindex); + if(padindex < TIDMap.get(TID).get(t).size()) + { + //CheckPadCoords = PadCoords(TIDMap.get(TID).get(t).get(padindex)); //Get the x,y,z of the pad we are checking against + CheckPadCoords = params.get_padvector(TIDMap.get(TID).get(t).get(padindex)); + //System.out.println("At TID " + TID + " time " + t + " padindex " + padindex + " the check pad's location is " + checkpadphi + " " + checkpadz); + //System.out.println("Current time " + checkpadphi + " " + PadPhi + " " + checkpadz + " " + PadZ + " " + Math.abs(checkpadphi-PadPhi) + " " + Math.abs(checkpadz - PadZ)); + //System.out.println("Current time slice " + PadPhi + " " + PadZ + " " + " " + checkpadphi + " " + checkpadz); + //System.out.println("The comparison values for the pad to be sorted at current time are " + Math.abs(checkpadphi-PadPhi) + " " + Math.abs(checkpadz - PadZ)); + + /**Check current time slice for adjacency**/ + /**Calculates the ellipse parameters**/ + EllipseDeltax = Math.abs(PadCoords.x()-CheckPadCoords.x())*Math.abs(PadCoords.x()-CheckPadCoords.x()); + EllipseDeltay = Math.abs(PadCoords.y()-CheckPadCoords.y())*Math.abs(PadCoords.y()-CheckPadCoords.y()); + EllipseDeltaz = Math.abs(PadCoords.z()-CheckPadCoords.z())*Math.abs(PadCoords.z()-CheckPadCoords.z()); + EllipseTotal = ((EllipseDeltax+EllipseDeltay)/PhiDelta) + (EllipseDeltaz/ZDelta); + //System.out.println("Ellipse is " + EllipseTotal); + + /** + * If the ellipse equation falls within the accepted size assign the + * TID of the checked pad to the current pad in the loop + **/ + //if(EllipseTotal <= adjthresh) + if((Math.abs(CheckPadCoords.phi()-PadCoords.phi())0) + { + /**Loops through a variable number (timeadj) of previous time slices to see if it is adjacent to earlier pads**/ + PREVTIMELOOP: + for(int prevtime = t - StepSize; (prevtime >= (t - (timeadj*StepSize))) && (prevtime >= 0); prevtime -= StepSize) + { + if(padindex < TIDMap.get(TID).get(prevtime).size()) + { + //CheckPadPrevCoords = PadCoords(TIDMap.get(TID).get(prevtime).get(padindex)); //Get the x,y,z of the pad we are checking against + CheckPadPrevCoords = params.get_padvector(TIDMap.get(TID).get(prevtime).get(padindex)); + /**Calculates the ellipse parameters**/ + EllipseDeltax = Math.abs(PadCoords.x()-CheckPadPrevCoords.x())*Math.abs(PadCoords.x()-CheckPadPrevCoords.x()); + EllipseDeltay = Math.abs(PadCoords.y()-CheckPadPrevCoords.y())*Math.abs(PadCoords.y()-CheckPadPrevCoords.y()); + EllipseDeltaz = Math.abs(PadCoords.z()-CheckPadPrevCoords.z())*Math.abs(PadCoords.z()-CheckPadPrevCoords.z()); + EllipseTotal = ((EllipseDeltax+EllipseDeltay)/PhiDelta) + (EllipseDeltaz/ZDelta); + //System.out.println("Ellipse is " + EllipseTotal); + + //System.out.println("Previous time slice " + PadPhi + " " + PadZ + " " + " " + checkpadphiprev + " " + checkpadzprev); + //System.out.println("The comparison values for the pad to be sorted at previous time are " + Math.abs(checkpadphiprev-PadPhi) + " " + Math.abs(checkpadzprev - PadZ)); + /** + * If the ellipse equation falls within the accepted size assign the + * TID of the checked pad to the current pad in the loop + **/ + //if(EllipseTotal <= adjthresh) + if((Math.abs(CheckPadPrevCoords.phi()-PadCoords.phi())< phithresh || (Math.abs(CheckPadPrevCoords.phi()-PadCoords.phi()-2*Math.PI) < phithresh )) && Math.abs(CheckPadPrevCoords.z()-PadCoords.z())>()); + for(int time = 0; time < TrigWindSize; time += StepSize) + { + TIDMap.get(TID).put(time, new Vector<>()); //add TID to map + } + TIDMap.get(TID).get(t).add(Pad); + //PadTIDcollect.add(TID); + TIDVec.add(TID+1); //add TID to the list + } + break TIDLOOP; //makes sure the TID loop doesn't go forever since we are adding a new TID to the list + } + } // End TIDLOOP // + + /** Pad has more than one TID in this time slice **/ + if(PadTIDcollect.size()>1) + { + + //System.out.println("PadTIDcollect is " + PadTIDcollect.size()); + /*for(int i : MapCombine.keySet()) + { + if(MapCombine.get(i).size()>0) + { + for(int jZvsPhi = 0; jZvsPhi()); + } + //System.out.println("TID to merge " + mapkey); + + /**Loops through remaining TIDs to be merged and puts them into a map together**/ + for(int i = 1; i < PadTIDcollect.size(); i++) + { + /*if(!TIDcombine.contains(PadTIDcollect.get(i))) + { + MapCombine.get(mapkey).add(PadTIDcollect.get(i)); + //TIDcombine.add(PadTIDcollect.get(i)); + }*/ + if(!MapCombine.get(mapkey).contains(PadTIDcollect.get(i))) + { + MapCombine.get(mapkey).add(PadTIDcollect.get(i)); + } + //System.out.println("TID to merge " + PadTIDcollect.get(i)); + } + //TIDcombine.clear(); + } + } + //else {System.out.println("Pad " + Pad + " failed ADC threshold at time " + t);} + } // End PADLOOP // + + } // End TIMELOOP // + System.out.println("This event has " + TIDMap.size() + " tracks"); + EmbeddedCanvas chist = new EmbeddedCanvas(); + JFrame jhist = new JFrame(); + jhist.setSize(800, 600); + if(draw == true) + { + chist.draw(t1); + jhist.add(chist); + jhist.setVisible(true); + jhist.setTitle("histo"); + } + + + /*************************************** + * + * MERGE ALGORITHM + * + ****************************************/ + + //Merge Tracks + + int TIDtomerge = 0; //TID we are putting into the TIDtokeep + int TIDtokeep = 0; + //Vector TIDtoremove = new Vector(); + //for(int i : TIDMap.keySet()) {System.out.println("all TIDs before " + i );} + + /** + * For each TID that needs other TIDs to be merged into it + * we get each TID from the Map assigned to the TIDtokeep key and merge the TIDs together + * then remove the other TIDs (TIDtomerge) from the map + */ + for(int j : MapCombine.keySet()) + { + if(MapCombine.get(j).size() == 0) {break;} + TIDtokeep = j; + for(int i = 0; i < MapCombine.get(j).size(); i++) + { + TIDtomerge = MapCombine.get(j).get(i); + //TIDtoremove.add(TIDtomerge); + for(int time = 0 ; time < TrigWindSize; time+=StepSize) + { + if(TIDMap.containsKey(TIDtomerge) && TIDMap.containsKey(TIDtokeep)) + { + if(TIDMap.get(TIDtomerge).get(time).size()>0) + { + for(int padindex = 0; padindex < TIDMap.get(TIDtomerge).get(time).size(); padindex++) + { + TIDMap.get(TIDtokeep).get(time).add(TIDMap.get(TIDtomerge).get(time).get(padindex)); + } + } + } + } + TIDMap.remove(TIDtomerge); + } + //System.out.println(MapCombine.get(jZvsPhi).size()); + } + + //for(int i = 0; i < TIDtoremove.size(); i++) {TIDMap.remove(TIDtoremove.get(i));} + //for(int i : TIDMap.keySet()) {System.out.println("all TIDs after " + i );} + + /*************************************** + * + * PLOTS + * + ****************************************/ + //TESTING STUFF + int countermax = 0; + int padmax = 0; + int howmanyhits = 0; + for(int i : countermap.keySet()) + { + howmanyhits += countermap.get(i); + if(countermap.get(i)>countermax) + { + countermax = countermap.get(i); + padmax = i; + //System.out.println("countermax " + i + " " + countermax); + } + } + System.out.println("this many hits " + howmanyhits + " this many pads " + countermap.size()); + + + HashMap gZvsPhi = new HashMap(); + //HashMap graphmap2 = new HashMap(); + //EmbeddedCanvas tcan = new EmbeddedCanvas(); + //TCanvas tcan = new TCanvas("t", 800, 600); + for(int testTID : TIDMap.keySet()) + { + for(int time = 0; time < TrigWindSize; time+=StepSize) + { + for(int pad = 0; pad < TIDMap.get(testTID).get(time).size(); pad++) + { + //TempPadCoords = PadCoords(TIDMap.get(testTID).get(time).get(pad)); //gets x,y,z + TempPadCoords = params.get_padvector(TIDMap.get(testTID).get(time).get(pad)); + //plotphi = Math.atan2(TempPadCoords.y(),TempPadCoords.x()); //Phi + plotphi = TempPadCoords.phi(); + plotz = TempPadCoords.z(); //Z + //System.out.println(plotphi + " " + plotz); + + if(!gZvsPhi.containsKey(testTID)) + { + gZvsPhi.put(testTID, new GraphErrors()); + } + + gZvsPhi.get(testTID).addPoint(plotphi, plotz, 0, 0); //Plots Phi, Z for each track + + + //write2.write(testTID + "\t" + time + "\t" + plotphi + "\t" + plotz + "\n"); + } + + + /*if(TIDMap.get(testTID).get(a1).size()>0) + { + gZvsPhi.get(testTID).addPoint(0, 0, 0, 0); + gZvsPhi.get(testTID).addPoint(6.5, 20, 0, 0); + //tcan.draw(gZvsPhi.get(testTID)); + //tcan.save("/Users/davidpayette/Desktop/Plots/" + a1 + ".jpg"); + //tcan.repaint(); + graphmap2.put(a1, new TCanvas(" ",800,600)); + graphmap2.get(a1).draw(gZvsPhi.get(testTID)); + graphmap2.get(a1).save("/Users/davidpayette/Desktop/Plots/" + a1 + ".jpg"); + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + }*/ + + } + } + + //F1D fitfunc1 = new F1D("f","[0]*x+[1]",0,9000); + //F1D fitfunc1 = new F1D("p1"); + //fitfunc1.setParameter(0, 1); + //fitfunc1.setParameter(1,0); + + //Vector3 vZvsT = new Vector3(); + GraphErrors gZvsT = new GraphErrors(); + EmbeddedCanvas cZvsT = new EmbeddedCanvas(); + Vector PadTracker = new Vector(); + JFrame jZvsT = new JFrame(); + jZvsT.setSize(800,600); + + /*int choosetid = 0; + for(int t : TIDMap.get(choosetid).keySet()) + { + //System.out.println(t); + for(int p = 0; p cADCvsT = new HashMap(); + GraphErrors gHitsvsPad = new GraphErrors(); + EmbeddedCanvas cHitsvsPad = new EmbeddedCanvas(); + JFrame jHitsvsPad = new JFrame(); + int mod25 = (PadTracker.size() - (PadTracker.size() % 25))/25; + //System.out.println(mod25); + for(int k = 0; k <= mod25; k++) + { + cADCvsT.put(k, new EmbeddedCanvas()); + cADCvsT.get(k).divide(5, 5); + } + + //System.out.println("size of PadTracker " + PadTracker.size()); + int numplots = 0; + int whichplot = 0; + for(int h = 0; h < PadTracker.size(); h++) + { + gHitsvsPad.addPoint(PadTracker.get(h), countermap.get(PadTracker.get(h)), 0, 0); + cADCvsT.get(whichplot).cd(numplots); + gADCvsT.get(PadTracker.get(h)).setTitle(""+PadTracker.get(h)); + gADCvsT.get(PadTracker.get(h)).addPoint(0, 0, 0, 0); + gADCvsT.get(PadTracker.get(h)).addPoint(9000, 0, 0, 0); + gADCvsT.get(PadTracker.get(h)).setMarkerSize(2); + cADCvsT.get(whichplot).draw(gADCvsT.get(PadTracker.get(h))); + if(h % 25 == 0 && h > 0) + { + whichplot++; + numplots=0; + } + else + { + numplots++; + } + } + if(draw == true) + { + gHitsvsPad.setMarkerSize(2); + cHitsvsPad.draw(gHitsvsPad); + jHitsvsPad.add(cHitsvsPad); + jHitsvsPad.setTitle("jHitsvsPad"); + jHitsvsPad.setSize(800, 600); + jHitsvsPad.setVisible(true); + HashMap jADCvsT = new HashMap(); + for(int k : cADCvsT.keySet()) + { + jADCvsT.put(k, new JFrame()); + jADCvsT.get(k).setSize(1200,800); + jADCvsT.get(k).setTitle("jADCvsT" + " " + k); + jADCvsT.get(k).add(cADCvsT.get(k)); + jADCvsT.get(k).setVisible(true); + } + //DataFitter.fit(fitfunc1, gZvsT, "QER"); + //System.out.println(fitfunc1.getChiSquare()); + + gZvsT.setMarkerSize(1); + cZvsT.draw(gZvsT); + //cZvsT.draw(fitfunc1,"same"); + jZvsT.add(cZvsT); + jZvsT.setVisible(true); + } + int tlargest = 0; + //System.out.println("before " + TIDMap.size()); + //int loopsize = TIDMap.size(); + Vector toremove = new Vector(); + Vector PadList = new Vector(); + for(int testTID : TIDMap.keySet()) + { + + for(int t = 0; t < TrigWindSize; t += StepSize) + { + for(int pad = 0; pad < TIDMap.get(testTID).get(t).size(); pad++) + { + if(!PadList.contains(TIDMap.get(testTID).get(t).get(pad))) + { + PadList.add(TIDMap.get(testTID).get(t).get(pad)); + } + + if(t > tlargest) + { + tlargest = t; + } + if(t>4000) + { + //System.out.println(pad + " " + t); + } + } + } + //System.out.println(tlargest); + if(tlargest < tmin || tlargest > tmax) + { + toremove.add(testTID); + //TIDMap.remove(testTID); + //gZvsPhi.remove(testTID); + + } + //System.out.println("large T " + tlargest); + tlargest = 0; + if(PadList.size() <= min_pads) + { + if(!toremove.contains(testTID)) + { + toremove.add(testTID); + } + } + PadList.clear(); + } + HashMap> padmap = new HashMap>(); + int padlook = 0; + for(int i = 0; i < toremove.size(); i++) + { + TIDMap.remove(toremove.get(i)); + } + HashMap hZvsT = new HashMap(); + HashMap hPhivsT = new HashMap(); + //Vector3 padv = new Vector3(); + PadVector padv; + double padphi = 0; + double padz = 0; + for(int tid : TIDMap.keySet()) + { + padmap.put(tid, new Vector()); + hPhivsT.put(tid, new H2F("hPhivsT","hPhivsT",80,0,9600,90,-Math.PI,Math.PI)); + hZvsT.put(tid, new H2F("hZvsT","hZvsT",80,0,9600,50,-200,200)); + + for(int time : TIDMap.get(tid).keySet()) + { + for(int p = 0; p < TIDMap.get(tid).get(time).size(); p++) + { + /*padlook = TIDMap.get(tid).get(time).get(p); + if(!padmap.get(tid).contains(padlook)) + { + padmap.get(tid).add(padlook); + }*/ + //padv = PadCoords(TIDMap.get(tid).get(time).get(p)); + padv = params.get_padvector(TIDMap.get(tid).get(time).get(p)); + //padphi = Math.atan2(padv.y(),padv.x()); + padphi = padv.phi(); + padz = padv.z(); + //System.out.println(time + " " + padz); + hZvsT.get(tid).fill((double)time, padz); + hPhivsT.get(tid).fill((double)time, padphi); + } + } + } + int pcount = 0; + toremove.clear(); + double histmaxavez = 0; + double histmaxavephi = 0; + + //System.out.println("HERE " + hZvsT.size()); + EmbeddedCanvas chZvsT = new EmbeddedCanvas(); + EmbeddedCanvas chPhivsT = new EmbeddedCanvas(); + JFrame jhZvsT = new JFrame(); + JFrame jhPhivsT = new JFrame(); + chZvsT.divide(5,5); + chPhivsT.divide(5, 5); + jhZvsT.setSize(1200,1200); + jhPhivsT.setSize(1200,1200); + jhZvsT.setTitle("Z vs T 2d Hist"); + jhPhivsT.setTitle("Phi vs T 2d Hist"); + for(int i : hZvsT.keySet()) + { + histmaxavez+=hZvsT.get(i).getMax(); + histmaxavephi+=hPhivsT.get(i).getMax(); + } + histmaxavez/=hZvsT.size(); + histmaxavephi/=hPhivsT.size(); + for(int i : hZvsT.keySet()) + { + //System.out.println(hZvsT.get(i).getMax() + " " + hPhivsT.get(i).getMax() + " " + histmaxavez + " " + histmaxavephi); + //if(hZvsT.get(i).getMax() < 10 || hPhivsT.get(i).getMax() < 10) + if(hZvsT.get(i).getMax() < histmaxavez*0.75 && hPhivsT.get(i).getMax() < histmaxavephi*0.75) + { + if(!toremove.contains(i)) + { + toremove.add(i); + } + } + chZvsT.cd(pcount); + chPhivsT.cd(pcount); + chZvsT.draw(hZvsT.get(i)); + chPhivsT.draw(hPhivsT.get(i)); + pcount++; + } + jhZvsT.add(chZvsT); + jhPhivsT.add(chPhivsT); + + if(draw) { + jhZvsT.setVisible(true); + jhPhivsT.setVisible(true); + } + //for(int i : TIDMap.keySet()) {System.out.println(i + " before");} + for(int i = 0; i < toremove.size(); i++) + { + //System.out.println(TIDMap.get(toremove.get(i)).size()); + strkTIDMap.put(toremove.get(i), TIDMap.get(toremove.get(i))); + TIDMap.remove(toremove.get(i)); + } + /*for(int i : strkTIDMap.keySet()) + { + for(int j : strkTIDMap.get(i).keySet()) + { + for(int k = 0; k < strkTIDMap.get(i).get(j).size(); k ++) + { + System.out.println(x); + } + } + }*/ + //for(int i : TIDMap.keySet()) {System.out.println(i + " after");} + //for(int i = 0; i < toremove.size()) + /*for(int tid : TIDMap.keySet()) + { + for(int p = 0; p < padmap.get(tid).size(); p++) + { + padv = PadCoords(padmap.get(tid).get(p)); + padphi = Math.atan2(padv.y(),padv.x()); + padz = padv.z(); + for(int time : TIDMap.get(tid).keySet()) + { + if(TIDMap.get(tid).get(time).contains(padmap.get(tid).get(p))) + { + + } + } + } + }*/ + + //System.out.println(tlargest); + int color = 1; + int style = 1; + + //for(int i : TIDMap.keySet()) {System.out.println(i);} + //System.out.println("after " + TIDMap.size()); + //System.out.println(maxconcpads + " " + maxconctime + " " + TIDVec.size()); + if(draw) + { + + EmbeddedCanvas cZvsPhi = new EmbeddedCanvas(); + JFrame jZvsPhi = new JFrame(); + jZvsPhi.setSize(800,600); + for(int i : TIDMap.keySet()) + { + //System.out.println(i); + //if(i == 1) + //{ + gZvsPhi.get(i).setMarkerColor(color); + if(false)//if(i == 1) + { + gZvsPhi.get(i).setMarkerSize(6); + } + else + { + gZvsPhi.get(i).setMarkerSize(2); + } + //gZvsPhi.get(i).addPoint(0, 0, 0, 0); + //gZvsPhi.get(i).addPoint(180, 100, 0, 0); + + //gZvsPhi.get(i).setMarkerStyle(style); + + cZvsPhi.draw(gZvsPhi.get(i),"same"); + //cZvsPhi.save("/Users/davidpayette/Desktop/Plots/g" + i + ".png"); + color++; + style++; + + //} + //System.out.println("key " + i + " " + TIDMap.size()); + } + jZvsPhi.setTitle("Track Finder Output"); + jZvsPhi.add(cZvsPhi); + jZvsPhi.setVisible(true); + + } + write2.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + for(int i : TIDMap.keySet()) + { + //System.out.println("TIDMap TIDs " + i); + } + for(int i : strkTIDMap.keySet()) + { + //System.out.println("strkTIDMap TIDs " + i); + } + params.set_TIDMap(TIDMap); + params.set_strkTIDMap(strkTIDMap); + //TIDMap.clear(); + //System.out.println(System.currentTimeMillis()-time1); + } + + /**Returns x, y, z as a vector, given pad number**/ + /* + private Vector3 PadCoords(int cellID) { + + double PAD_W = 2.79; // in mm + double PAD_S = 80.0; //in mm + double PAD_L = 4.0; // in mm + double RTPC_L= 384.0; // in mm + double phi_pad = 0; + //double Num_of_Rows = (2.0*(Math.PI)*PAD_S)/PAD_W; + double Num_of_Cols = RTPC_L/PAD_L; + double PI=Math.PI; + double z0 = -(RTPC_L/2.0); + double phi_per_pad = PAD_W/PAD_S; // in rad + double chan = (double)cellID; + double col = chan%Num_of_Cols; + double row=(chan-col)/Num_of_Cols; + double z_shift = row%4; + + phi_pad=(row*phi_per_pad)+(phi_per_pad/2.0); + + if(phi_pad>= 2.0*PI) + { + phi_pad -= 2.0*PI; + } + if(phi_pad<0) + { + phi_pad += 2.0*PI; + } + + double z_pad=z0+(col*PAD_L)+(PAD_L/2.0)+z_shift; + + Vector3 PadCoords = new (PAD_S*Math.cos(phi_pad),PAD_S*Math.sin(phi_pad),z_pad); + return PadCoords; + + } + + */ + + + //old functions, maybe used later + /*private double PadPhi(int cellID) { + + double PAD_W = 2.79; // in mm + double PAD_S = 80.0; //in mm + double PAD_L = 4.0; // in mm + double RTPC_L=400.0; // in mm + + double phi_pad = 0; + + double Num_of_Rows = (2.0*(Math.PI)*PAD_S)/PAD_W; + double Num_of_Cols = RTPC_L/PAD_L; + double TotChan = Num_of_Rows*Num_of_Cols; + + double PI=Math.PI; + + + + double phi_per_pad = PAD_W/PAD_S; // in rad + + double chan = (double)cellID; + double col = chan%Num_of_Cols; + double row=(chan-col)/Num_of_Cols; + + + //double z_shift = 0.; + + phi_pad=(row*phi_per_pad)+(phi_per_pad/2.0); + if(phi_pad>= 2.0*PI) { + phi_pad -= 2.0*PI; + } + if(phi_pad<0) + { + phi_pad += 2.0*PI; + } + + return phi_pad; + + } + private double PadZ(int cellID) + { + + double RTPC_L=400.0; // in mm + double PAD_L = 4.0; // in mm + double Num_of_Cols = RTPC_L/PAD_L; + double z0 = -(RTPC_L/2.0); // front of RTPC in mm at the center of the pad + double chan = (double)cellID; + double col = chan%Num_of_Cols; + double row=(chan-col)/Num_of_Cols; + double z_shift = row%4; + double z_pad = 0; + double testnum = (row-z_shift)/4; + + z_pad=z0+(col*PAD_L)+(PAD_L/2.0)+z_shift; + //if(z_shift == 0 && row > 0) {return col-1;} + //else{return col;} + return z_pad;//-testnum; + }*/ + +} diff --git a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TrackFinder3.java b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TrackFinder3.java new file mode 100644 index 0000000000..3848bdf570 --- /dev/null +++ b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TrackFinder3.java @@ -0,0 +1,219 @@ +//Author: David Payette + +/* This code sorts pad signals which have been integrated into 120 ns time slices into tracks + * based on their relative positions in space, and how close in time the signals occur + */ + +package org.jlab.rec.rtpc.hit; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.concurrent.ConcurrentHashMap; +import java.util.List; +import java.util.Vector; + +import javax.swing.JFrame; + +import org.jlab.groot.data.GraphErrors; +import org.jlab.groot.graphics.EmbeddedCanvas; + +public class TrackFinder3 { + + public TrackFinder3(HitParameters params, boolean draw) { + /* + *Initializations + */ + TrackUtils tutil = new TrackUtils(); + TrackMap TIDMap = new TrackMap(); + List TIDList; + Track track; + HashMap ADCMap = params.get_R_adc(); + Vector PadNum = params.get_PadNum(); + int TrigWindSize = params.get_TrigWindSize(); + int StepSize = 120; + double adcthresh = 5e-4; + int padloopsize = PadNum.size(); + boolean padSorted = false; + List padTIDlist = new ArrayList(); + List padlist; + int pad = 0; + double adc = 0; + int timeadjlimit = 4; + int parenttid = -1; + String method = "phiz"; + int minhitcount = 5; + + /* + * Main Algorithm + */ + TIMELOOP: //Loop over all times + for(int time = 0; time < TrigWindSize; time += StepSize) { //Steps of 120 up to TrigWindSize = 10000 + + PADLOOP: //Loop over all pads + for(int padindex = 0; padindex < padloopsize; padindex++) { + padSorted = false; //Flag to be set when the pad is assigned to a track + padTIDlist.clear(); //List of all TIDs assigned to the pad starts empty + pad = PadNum.get(padindex); + adc = ADCMap.get(pad)[time]; + + if(adc > adcthresh) { //pad adc threshold check + PadVector PadVec = params.get_padvector(pad); //initializes the x,y,z,phi for pad + TIDList = TIDMap.getAllTrackIDs(); //Retrieve list of all available TIDs + + TIDLOOP: //Loop over all Track IDs + for(int tid : TIDList) { + track = TIDMap.getTrack(tid); //Get track with current tid + + TIMECHECKLOOP: //Loop over current and former times + for(int timecheck = time; timecheck > 0 && timecheck >= time - timeadjlimit*StepSize; timecheck -= StepSize) { + padlist = track.getTimeSlice(timecheck); //Get pads assigned to current time slice + if(!padlist.contains(pad)) { //Ensures pad isn't already assigned here + PADCHECKLOOP: //Loop over pads + for(int checkpad : padlist) { + PadVector checkpadvec = params.get_padvector(checkpad); + if(tutil.comparePads(PadVec, checkpadvec, method)) { //compares the position of two pads + track.addPad(time, pad); //assign pad to track + //TIDMap.updateTrack(tid, track); + padSorted = true; //flag set + padTIDlist.add(tid); //track the TID assigned + break TIMECHECKLOOP; //no need to continue checking previous times + } //END PAD COMPARE + + } //END PADCHECKLOOP + + } else {//pad is somehow in this time slice already so lets go ahead and add it to the current time slice + track.addPad(time, pad); + //TIDMap.updateTrack(tid, track); + padSorted = true; + padTIDlist.add(tid); + break TIMECHECKLOOP; + } + + } //END TIMECHECKLOOP + + } //END TIDLOOP + + if(!padSorted) { //we need a new TID if we get here, the pad was never assigned an ID + TIDMap.addTrack(new Track(time,pad)); + } + + if(padTIDlist.size()>1) { //if a pad gets more than 1 ID let's merge the IDs + for(int tidtemp : padTIDlist) { + if(tidtemp == padTIDlist.get(0)) { + parenttid = padTIDlist.get(0); + } else { + TIDMap.mergeTracks(parenttid, tidtemp); + } + } + } + + } //END ADC THRESH CHECK + + } //END PADLOOP + + } //END TIMELOOP + + //END MAIN ALGORITHM + + /* + * Clean up and flag tracks + */ + + for(int tid : TIDMap.getAllTrackIDs()) { //We need to remove tracks with not enough pads to save time later + Track tempt = TIDMap.getTrack(tid); + if(tempt.uniquePadCountTotal() < minhitcount) { + TIDMap.removeTrack(tid); + } + } + + //System.out.println("This event has " + TIDMap.getAllTrackIDs().size() + " tracks"); + + //TODO Flag crossing tracks; for now flag all tracks + for(int tid : TIDMap.getAllTrackIDs()) { + Track t = TIDMap.getTrack(tid); + t.flagTrack(); + } + + /* + * Output + */ + + params.set_trackmap(TIDMap); + + /* + * Drawing for debugging + * To be removed + */ + + if(draw) { + + HashMap gmapzvsphi = new HashMap(); + EmbeddedCanvas cZvsPhi = new EmbeddedCanvas(); + JFrame jZvsPhi = new JFrame(); + jZvsPhi.setSize(800,600); + + HashMap gmapphivst = new HashMap(); + EmbeddedCanvas cPhivsT = new EmbeddedCanvas(); + JFrame jPhivsT = new JFrame(); + jPhivsT.setSize(800,600); + + HashMap gmapzvst = new HashMap(); + EmbeddedCanvas cZvsT = new EmbeddedCanvas(); + JFrame jZvsT = new JFrame(); + jZvsT.setSize(800,600); + int color = 1; + int style = 1; + for(int tid : TIDMap.getAllTrackIDs()) { + Track t = TIDMap.getTrack(tid); + gmapzvsphi.put(tid, new GraphErrors()); + gmapphivst.put(tid, new GraphErrors()); + gmapzvst.put(tid, new GraphErrors()); + for(int time : t.getAllTimeSlices()) { + for(int padref : t.getTimeSlice(time)) { + PadVector p = params.get_padvector(padref); + gmapzvsphi.get(tid).addPoint(p.phi(), p.z(), 0, 0); + gmapzvst.get(tid).addPoint(time, p.z(), 0, 0); + gmapphivst.get(tid).addPoint(time, p.phi(), 0, 0); + } + } + gmapzvsphi.get(tid).setMarkerColor(color); + gmapzvsphi.get(tid).setMarkerSize(3); + gmapzvsphi.get(tid).setMarkerStyle(style); + + gmapzvst.get(tid).setMarkerColor(color); + gmapzvst.get(tid).setMarkerSize(3); + gmapzvst.get(tid).setMarkerStyle(style); + + gmapphivst.get(tid).setMarkerColor(color); + gmapphivst.get(tid).setMarkerSize(3); + gmapphivst.get(tid).setMarkerStyle(style); + + cZvsPhi.draw(gmapzvsphi.get(tid),"same"); + cZvsT.draw(gmapzvst.get(tid),"same"); + cPhivsT.draw(gmapphivst.get(tid),"same"); + + color++; + if(color > 8) { + color = 1; + style++; + } + + } + + jZvsPhi.setTitle("Track Finder Output"); + jZvsPhi.add(cZvsPhi); + jZvsPhi.setVisible(true); + + jZvsT.setTitle("Track Finder Output"); + jZvsT.add(cZvsT); + jZvsT.setVisible(true); + + jPhivsT.setTitle("Track Finder Output"); + jPhivsT.add(cPhivsT); + jPhivsT.setVisible(true); + + } + + } + +} diff --git a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TrackHitReco.java b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TrackHitReco.java new file mode 100644 index 0000000000..0a3774d91b --- /dev/null +++ b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TrackHitReco.java @@ -0,0 +1,528 @@ +package org.jlab.rec.rtpc.hit; + +import java.util.concurrent.ConcurrentHashMap; +import java.util.HashMap; +import java.util.List; +import java.util.Vector; + +import javax.swing.JFrame; + +import org.jlab.groot.data.GraphErrors; +import org.jlab.groot.graphics.EmbeddedCanvas; + +public class TrackHitReco { + + public void Reco(List rawHits, HitParameters params) { + HashMap>> TIDMap = params.get_TIDMap(); + HashMap ADCMap = params.get_R_adc(); + HashMap graphmap = new HashMap(); + HashMap graphmap2 = new HashMap(); + Vector TimeVec = new Vector(); + Vector XVec = new Vector(); + Vector YVec = new Vector(); + Vector ZVec = new Vector(); + Vector Pads = new Vector(); + int p = 0; + EmbeddedCanvas c = new EmbeddedCanvas(); + EmbeddedCanvas c2 = new EmbeddedCanvas(); + EmbeddedCanvas c3 = new EmbeddedCanvas(); + JFrame j = new JFrame(); + j.setSize(800,600); + JFrame j2 = new JFrame(); + j2.setSize(800,600); + JFrame j3 = new JFrame(); + j3.setSize(800,600); + Vector PadList = new Vector(); + double maxvalue = 0; + double thresh = 0; + int TrigWindSize = params.get_TrigWindSize(); + double sumnumer = 0; + double sumdenom = 0; + HashMap weightave = new HashMap(); + //System.out.println(TIDMap.size()); + //for(Hit hit : rawHits) { + for(int TID : TIDMap.keySet()){ + PadList.clear(); + + for(int time : TIDMap.get(TID).keySet()) + { + for(int pad = 0; pad < TIDMap.get(TID).get(time).size(); pad++) + { + if(!PadList.contains(TIDMap.get(TID).get(time).get(pad))) + { + PadList.add(TIDMap.get(TID).get(time).get(pad)); + } + } + } + + for(int pad = 0; pad < PadList.size(); pad++) + { + for(int time : TIDMap.get(TID).keySet()) + { + if(TIDMap.get(TID).get(time).contains(PadList.get(pad))) + { + if(ADCMap.get(PadList.get(pad))[time]>maxvalue) + { + maxvalue = ADCMap.get(PadList.get(pad))[time]; + } + } + } + thresh = maxvalue/2; + for(int time = 0; time < TrigWindSize; time++) + { + if(ADCMap.get(PadList.get(pad))[time] > thresh) + { + sumnumer += ADCMap.get(PadList.get(pad))[time]*time; + sumdenom += ADCMap.get(PadList.get(pad))[time]; + //System.out.println(PadList.get(pad) + " " + time); + } + } + + //System.out.println("weightave " + PadList.get(pad) + " " + sumnumer/sumdenom); + weightave.put(PadList.get(pad), sumnumer/sumdenom); + sumnumer = 0; + sumdenom = 0; + maxvalue = 0; + //padvec = PadCoords(PadList.get(pad)); + //gZvsT.addPoint(weightave.get(PadList.get(pad)), padvec.z(), 0, 0); + //gPhivsT.addPoint(weightave.get(PadList.get(pad)), Math.atan2(padvec.y(),padvec.x()),0,0); + } + + graphmap.put(TID, new GraphErrors()); + graphmap2.put(TID, new GraphErrors()); + //System.out.println("hqwd" + TID); + for(int t : TIDMap.get(TID).keySet()){ + for(int padindex = 0; padindex < TIDMap.get(TID).get(t).size(); padindex++){ + + + int cellID = TIDMap.get(TID).get(t).get(padindex); + Pads.add(cellID); + double Time = (double)t; + //System.out.println(Time + " " + cellID); + + + //int NEve = 10; + + double PAD_W = 2.79; // in mm + double PAD_S = 80.0; //in mm + double PAD_L = 4.0; // in mm + double RTPC_L = 384.0; // in mm + + //double Num_of_Rows = (2.0*(Math.PI)*PAD_S)/PAD_W; + double Num_of_Cols = RTPC_L/PAD_L; + //double TotChan = Num_of_Rows*Num_of_Cols; + + double PI=Math.PI; + + double z0 = -(RTPC_L/2.0); // front of RTPC in mm at the center of the pad + + double phi_per_pad = PAD_W/PAD_S; // in rad + + + + // MagBoltz parameters + double a_t=1741.179712, b_t=-1.25E+02; // for f(x)=time(radius) + double a_phi=0.161689123, b_phi=0.023505021; // for f(x)=dphi(radius) + + double t_2GEM2 = 296.082; + double t_2GEM3 = 296.131; + double t_2PAD = 399.09; + double t_gap = t_2GEM2 + t_2GEM3 + t_2PAD; + + double phi_2GEM2 = 0.0492538; + double phi_2GEM3 = 0.0470817; + double phi_2PAD = 0.0612122; + double phi_gap = phi_2GEM2 + phi_2GEM3 + phi_2PAD; + + // find postition from Cell ID + //for (double s = 0.0; s < cellID.size(); s++) { + + double chan=0; + double t_s2pad = 0; + double dphi=0; + double dz=0; + double x_rec = 0; + double y_rec = 0; + + + double z_pad=0; + double z_rec=0; + double z_hit=0; // position of the hit on a single pad in z + double delta_z=0; + + double r_pos=0; + double r_rec=0; + double r_temp=0; + double delta_r=0; + + double phi_pad=0; + double phi_rec=0; + + + + // generated position of ionization in phi + + //phi_pos = Math.atan2(Y, X); + + // generated position of ionization in s + //r_pos=Math.sqrt(((X)*(X))+((Y)*(Y))); + + + // ------------------ find z and phi of pad from CellID ------------------ + chan = (double)cellID; + + double col = chan%Num_of_Cols; + double row=(chan-col)/Num_of_Cols; + double z_shift = row%4; + //double z_shift = 0.; + + phi_pad=(row*phi_per_pad)+(phi_per_pad/2.0); + if(phi_pad>= 2.0*PI) { + phi_pad -= 2.0*PI; + } + if(phi_pad<0) + { + phi_pad += 2.0*PI; + } + + z_pad=z0+(col*PAD_L)+(PAD_L/2.0)+z_shift; + // ----------------------------------------------------------------------- + + + // find reconstructed position of ionization from Time info + + t_s2pad = Time-t_gap; + + r_rec=((-(Math.sqrt(a_t*a_t+(4.*b_t*t_s2pad)))+a_t+(14.*b_t))/(2.*b_t))*10.0; //in mm + + + dphi=a_phi*(7.-r_rec/10.)+b_phi*(7.-r_rec/10.)*(7.-r_rec/10.); // in rad + + + dz=0; + + phi_rec=phi_pad-dphi-phi_gap; + if( phi_rec<0.0 ) + { + phi_rec+=2.0*PI; + } + if( phi_rec>2.0*PI ) + { + phi_rec-=2.0*PI; + } + + // x,y,z pos of reconstructed track + x_rec=r_rec*(Math.cos(phi_rec)); + y_rec=r_rec*(Math.sin(phi_rec)); + z_rec=z_pad-dz; + //if(r_rec > 30 && r_rec < 70) + //{ + graphmap.get(TID).addPoint(r_rec, z_rec, 0, 0); + graphmap2.get(TID).addPoint(x_rec, y_rec, 0, 0); + + //} + // x,y,z pos of pad hit + //x_pad=(PAD_S)*(Math.cos(phi_pad)); + //y_pad=(PAD_S)*(Math.sin(phi_pad)); + + // actual position on pad of hits + //phi_hit=phi_rad-(row*phi_per_pad); + //z_hit=Z-z0-(col*PAD_L)-z_shift; + + // find differences (delta = generated-reconstructed) + //delta_x=X-x_rec; + //delta_y=Y-y_rec; + //delta_z=Z-z_rec; + //delta_r=r_pos-r_rec; + //delta_phi = phi_pos-phi_rec; + + + + + /*hit.set_cellID(cellID); + hit.set_Time(t_s2pad); + hit.set_Edep(Edep); + hit.set_PosX(x_rec); + hit.set_PosY(y_rec); + hit.set_PosZ(z_rec); + TimeVec.add(t_s2pad); + XVec.add(x_rec); + YVec.add(y_rec); + ZVec.add(z_rec);*/ + + + } + } + } + GraphErrors grz = new GraphErrors(); + GraphErrors g1rz = new GraphErrors(); + GraphErrors gxy = new GraphErrors(); + GraphErrors g1xy = new GraphErrors(); + GraphErrors gerrorxvsphi = new GraphErrors(); + GraphErrors gerroryvsphi = new GraphErrors(); + int counter = 1; + for(Hit hit : rawHits) + { + if(true) { + int cellID = hit.get_cellID(); + double Time = hit.get_Time(); + double X = hit.get_PosXTrue(); + double Y = hit.get_PosYTrue(); + double Z = hit.get_PosZTrue(); + + //if(Pads.contains(cellID)) + //{ + //ystem.out.println(Time + " " + cellID); + + + //int NEve = 10; + + double PAD_W = 2.79; // in mm + double PAD_S = 80.0; //in mm + double PAD_L = 4.0; // in mm + double RTPC_L = 384.0; // in mm + + //double Num_of_Rows = (2.0*(Math.PI)*PAD_S)/PAD_W; + double Num_of_Cols = RTPC_L/PAD_L; + //double TotChan = Num_of_Rows*Num_of_Cols; + + double PI=Math.PI; + + double z0 = -(RTPC_L/2.0); // front of RTPC in mm at the center of the pad + + double phi_per_pad = PAD_W/PAD_S; // in rad + + + + // MagBoltz parameters + double a_t=1741.179712, b_t=-125; // for f(x)=time(radius) + double a_phi=0.161689123, b_phi=0.023505021; // for f(x)=dphi(radius) + + double t_2GEM2 = 296.082; + double t_2GEM3 = 296.131; + double t_2PAD = 399.09; + double t_gap = t_2GEM2 + t_2GEM3 + t_2PAD; + + double phi_2GEM2 = 0.0492538; + double phi_2GEM3 = 0.0470817; + double phi_2PAD = 0.0612122; + double phi_gap = phi_2GEM2 + phi_2GEM3 + phi_2PAD; + + // find position from Cell ID + //for (double s = 0.0; s < cellID.size(); s++) { + + double chan=0; + double t_s2pad = 0; + double dphi=0; + double dz=0; + double x_rec = 0; + double y_rec = 0; + + + double z_pad=0; + double z_rec=0; + double z_hit=0; // position of the hit on a single pad in z + double delta_z=0; + + double r_pos=0; + double r_rec=0; + double r_temp=0; + double delta_r=0; + + double phi_pad=0; + double phi_rec=0; + double phi_pos = 0; + + + // generated position of ionization in phi + + phi_pos = Math.atan2(Y, X); + + // generated position of ionization in s + r_pos=Math.sqrt(((X)*(X))+((Y)*(Y))); + + + // ------------------ find z and phi of pad from CellID ------------------ + chan = (double)cellID; + + double col = chan%Num_of_Cols; + double row=(chan-col)/Num_of_Cols; + double z_shift = row%4; + //double z_shift = 0.; + //System.out.println(row + " " + chan + " " + col + " " + phi_per_pad); + phi_pad=(row*phi_per_pad)+(phi_per_pad/2.0); + while(phi_pad >= 2*PI || phi_pad < 0) + { + if(phi_pad>= 2.0*PI) { + phi_pad -= 2.0*PI; + } + if(phi_pad<0) + { + phi_pad += 2.0*PI; + } + } + z_pad=z0+(col*PAD_L)+(PAD_L/2.0)+z_shift; + // ----------------------------------------------------------------------- + + + // find reconstructed position of ionization from Time info + + t_s2pad = Time-t_gap; + + r_rec=((-(Math.sqrt(a_t*a_t+(4*b_t*t_s2pad)))+a_t+(14*b_t))/(2*b_t))*10.0; //in mm + + + dphi=a_phi*(7-r_rec/10)+b_phi*(7-r_rec/10)*(7.-r_rec/10); // in rad + + + dz=0; + + phi_rec=phi_pad-dphi-phi_gap; + while(phi_rec < 0 || phi_rec >= 2*PI) + { + if( phi_rec<0.0 ) + { + phi_rec+=2.0*PI; + } + if( phi_rec>2.0*PI ) + { + phi_rec-=2.0*PI; + } + } + //System.out.println("reconstructed phi " + phi_rec + " actual phi " + Math.atan(Y/X)); + + // x,y,z pos of reconstructed track + x_rec=r_rec*(Math.cos(phi_rec)); + y_rec=r_rec*(Math.sin(phi_rec)); + z_rec=z_pad-dz; + //if(true) + //if(counter > 2500) + //if(z_rec > 160 && r_rec > 30 && r_rec < 55 && z_rec < 195) + if(true)//if(Math.abs(x_rec-X) < 3 && Math.abs(y_rec-Y) < 3 && Math.abs(z_rec-Z) < 3) + { + grz.addPoint(r_rec, z_rec, 0, 0); + gxy.addPoint(x_rec, y_rec, 0, 0); + //if(counter <= 53) + //{ + g1rz.addPoint(Math.sqrt(X*X+Y*Y), Z, 0, 0); + g1xy.addPoint(X, Y, 0, 0); + gerrorxvsphi.addPoint(Math.atan2(Y,X),Math.pow(Math.abs(x_rec-X),2)/X,0,0); + gerroryvsphi.addPoint(Math.atan2(Y,X),Math.pow(Math.abs(y_rec-Y),2)/Y,0,0); + //} + //System.out.println(counter); + } + else + { + grz.addPoint(0, 0, 0, 0); + g1rz.addPoint(0, 0, 0, 0); + gxy.addPoint(0, 0, 0, 0); + g1xy.addPoint(0, 0, 0, 0); + } + //} + // x,y,z pos of pad hit + //x_pad=(PAD_S)*(Math.cos(phi_pad)); + //y_pad=(PAD_S)*(Math.sin(phi_pad)); + + // actual position on pad of hits + //phi_hit=phi_rad-(row*phi_per_pad); + //z_hit=Z-z0-(col*PAD_L)-z_shift; + + // find differences (delta = generated-reconstructed) + //delta_x=X-x_rec; + //delta_y=Y-y_rec; + //delta_z=Z-z_rec; + //delta_r=r_pos-r_rec; + //delta_phi = phi_pos-phi_rec; + //System.out.println(X + " " + x_rec); + //System.out.println(r_pos + " " + r_rec); + + + + /*hit.set_cellID(cellID); + hit.set_Time(t_s2pad); + hit.set_Edep(Edep); + hit.set_PosX(x_rec); + hit.set_PosY(y_rec); + hit.set_PosZ(z_rec); + TimeVec.add(t_s2pad); + XVec.add(x_rec); + YVec.add(y_rec); + ZVec.add(z_rec);*/ + //} + counter++; + } + } + //System.out.println(counter); + GraphErrors g2 = new GraphErrors(); + double theta = 0; + double test_x = 0; + double test_y = 0; + double test_x2 = 0; + double test_y2 = 0; + while(theta <= 2*Math.PI) + { + test_x = 30 * Math.cos(theta); + test_y = 30 * Math.sin(theta); + test_x2 = 70 * Math.cos(theta); + test_y2 = 70 * Math.sin(theta); + g2.addPoint(test_x, test_y, 0, 0); + g2.addPoint(test_x2, test_y2, 0, 0); + theta+=0.01; + } + + for(int key : TIDMap.keySet()) + { + if(false) + //if(key == 1) + { + graphmap.get(key).setMarkerSize(6); + graphmap2.get(key).setMarkerSize(6); + } + else { + graphmap.get(key).setMarkerSize(2); + graphmap.get(key).setMarkerColor(4); + graphmap.get(key).setMarkerStyle(2); + + + graphmap2.get(key).setMarkerSize(2); + graphmap2.get(key).setMarkerColor(4); + graphmap2.get(key).setMarkerStyle(2); + } + c.draw(graphmap.get(key),"same"); + c2.draw(graphmap2.get(key),"same"); + + } + grz.setMarkerSize(3); + grz.setMarkerColor(1); + g1rz.setMarkerSize(1); + g1rz.setMarkerColor(5); + //grz.addPoint(30, -200, 0, 0); + //grz.addPoint(70, 200, 0, 0); + gxy.setMarkerSize(4); + gxy.setMarkerColor(2); + g1xy.setMarkerSize(0); + g1xy.setMarkerColor(5); + g2.setMarkerSize(0); + g2.setMarkerColor(3); + gerrorxvsphi.setMarkerSize(2); + gerroryvsphi.setMarkerSize(2); + c.draw(grz,"same"); + c.draw(g1rz,"same"); + c2.draw(gxy,"same"); + c2.draw(g1xy,"same"); + c2.draw(g2,"same"); + c3.divide(1, 2); + c3.cd(0); + c3.draw(gerrorxvsphi); + c3.cd(1); + c3.draw(gerroryvsphi); + j.setTitle("RZ"); + j2.setTitle("XY"); + j.add(c); + j.setVisible(true); + j2.add(c2); + j2.setVisible(true); + //j3.add(c3); + //j3.setVisible(true); + } +} diff --git a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TrackHitReco2.java b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TrackHitReco2.java new file mode 100644 index 0000000000..e65fa78d93 --- /dev/null +++ b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TrackHitReco2.java @@ -0,0 +1,714 @@ +package org.jlab.rec.rtpc.hit; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.concurrent.ConcurrentHashMap; +import java.util.HashMap; +import java.util.List; +import java.util.Vector; + +import javax.swing.JFrame; + +import org.jlab.clas.physics.Vector3; +import org.jlab.groot.data.GraphErrors; +import org.jlab.groot.data.H1F; +import org.jlab.groot.graphics.EmbeddedCanvas; +import org.jlab.rec.rtpc.hit.RecoHitVector; + +public class TrackHitReco2 { + + public void Reco(List rawHits, HitParameters params, boolean draw) { + HashMap>> TIDMap = params.get_strkTIDMap(); + HashMap ADCMap = params.get_R_adc(); + HashMap graphmap = new HashMap(); + HashMap graphmap2 = new HashMap(); + HashMap> alltracks = params.get_alltracks(); + HashMap largetmap = params.get_largetmap(); + HashMap tdiffmap = new HashMap(); + HashMap> recohitvector = new HashMap>(); + Vector TimeVec = new Vector(); + Vector XVec = new Vector(); + Vector YVec = new Vector(); + Vector ZVec = new Vector(); + Vector Pads = new Vector(); + int p = 0; + EmbeddedCanvas c = new EmbeddedCanvas(); + EmbeddedCanvas c2 = new EmbeddedCanvas(); + EmbeddedCanvas c3 = new EmbeddedCanvas(); + EmbeddedCanvas c4 = new EmbeddedCanvas(); + JFrame j = new JFrame(); + j.setSize(800,600); + JFrame j2 = new JFrame(); + j2.setSize(800,600); + JFrame j3 = new JFrame(); + j3.setSize(800,600); + JFrame j4 = new JFrame(); + j4.setSize(800,600); + + double a_t1 = -2.48491E-4; + double a_t2 = 2.21413E-4; + double a_t3 = -3.11195E-3; + double a_t4 = -2.75206E-1; + double a_t5 = 1.74281E3; + + double b_t1 = 2.48873E-5; + double b_t2 = -1.19976E-4; + double b_t3 = -3.75962E-3; + double b_t4 = 5.33100E-2; + double b_t5 = -1.25647E2; + + double a_phi1 = -3.32718E-8; + double a_phi2 = 1.92110E-7; + double a_phi3 = 2.16919E-6; + double a_phi4 = -8.10207E-5; + double a_phi5 = 1.68481E-1; + + double b_phi1 = -3.23019E-9; + double b_phi2 = -6.92075E-8; + double b_phi3 = 1.24731E-5; + double b_phi4 = 2.57684E-5; + double b_phi5 = 2.10680E-2; + + H1F largetdist = new H1F("largetdist",100,0,10000); + + double timewindow = 2000; + double smalltcut = 300; + double largetcut = 8000; + int tracksizecut = 4; + double larget = 0; + double tdiff = 0; + double Time = 0; + int cellID = 0; + int outsidedriftcounter = 0; + int allhitscounter = 0; + /*Vector PadList = new Vector(); + double maxvalue = 0; + double thresh = 0; + int TrigWindSize = params.get_TrigWindSize(); + double sumnumer = 0; + double sumdenom = 0; + int count = 0;*/ + + //HashMap weightave = new HashMap(); + //System.out.println(TIDMap.size()); + //for(Hit hit : rawHits) { + //for(int TID : TIDMap.keySet()){ + //System.out.println(alltracks.size() + " " + alltracks.get(1).size()); + for(int TID : alltracks.keySet()) { + Pads.clear(); + /*PadList.clear(); + + double larget = 0; + for(int time : TIDMap.get(TID).keySet()) + { + for(int pad = 0; pad < TIDMap.get(TID).get(time).size(); pad++) + { + if(!PadList.contains(TIDMap.get(TID).get(time).get(pad))) + { + PadList.add(TIDMap.get(TID).get(time).get(pad)); + } + } + } + + for(int pad = 0; pad < PadList.size(); pad++) + { + for(int time : TIDMap.get(TID).keySet()) + { + if(TIDMap.get(TID).get(time).contains(PadList.get(pad))) + { + if(ADCMap.get(PadList.get(pad))[time]>maxvalue) + { + maxvalue = ADCMap.get(PadList.get(pad))[time]; + } + } + } + thresh = maxvalue/2; + for(int time = 0; time < TrigWindSize; time++) + { + if(ADCMap.get(PadList.get(pad))[time] > thresh) + { + sumnumer += ADCMap.get(PadList.get(pad))[time]*time; + sumdenom += ADCMap.get(PadList.get(pad))[time]; + //System.out.println(PadList.get(pad) + " " + time); + } + } + if(sumnumer/sumdenom >= larget) + { + larget = sumnumer/sumdenom; + } + //System.out.println("weightave " + PadList.get(pad) + " " + sumnumer/sumdenom); + weightave.put(PadList.get(pad), sumnumer/sumdenom); + sumnumer = 0; + sumdenom = 0; + maxvalue = 0; + //padvec = PadCoords(PadList.get(pad)); + //gZvsT.addPoint(weightave.get(PadList.get(pad)), padvec.z(), 0, 0); + //gPhivsT.addPoint(weightave.get(PadList.get(pad)), Math.atan2(padvec.y(),padvec.x()),0,0); + }*/ + //System.out.println("large t " + larget); + larget = largetmap.get(TID); + double smallt = 1000000; + for(int i = 0; i < alltracks.get(TID).size(); i ++) + { + if(alltracks.get(TID).get(i).time() < smallt) {smallt = alltracks.get(TID).get(i).time();} + } + //double smallt = alltracks.get(TID).get(alltracks.get(TID).size()-1).time(); + + + /*try { + File f = new File("/Users/davidpayette/Documents/FileOutput/smallt.txt"); + //f.delete(); + FileWriter out = new FileWriter("/Users/davidpayette/Documents/FileOutput/smallt.txt",true); + out.write(smallt + "\n"); + out.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + }*/ + largetdist.fill(larget); + //System.out.println("large t is " + larget); + //if(TID != 2) {continue;} + //System.out.println(smallt + " small t"); + if(smallt < smalltcut || larget > largetcut || alltracks.get(TID).size() <= tracksizecut) {continue;} + //add smallt check as well for smallt too small + + graphmap.put(TID, new GraphErrors()); + graphmap2.put(TID, new GraphErrors()); + + tdiff = 6000 - larget; + //if(larget + tdiff > 7500) {continue;} + tdiffmap.put(TID, tdiff); + recohitvector.put(TID, new Vector()); + + //tdiff = 0; + //System.out.println("hqwd" + TID); + //for(int cellID : weightave.keySet()){ + //System.out.println("large t " + larget); + for(int k = 0; k < alltracks.get(TID).size(); k++) { + //for(int padindex = 0; padindex < TIDMap.get(TID).get(t).size(); padindex++){ + + allhitscounter++; + //int cellID = TIDMap.get(TID).get(t).get(padindex); + cellID = (int)alltracks.get(TID).get(k).pad(); + if(!Pads.contains(cellID)) { + Pads.add(cellID); + } + //double Time = weightave.get(cellID); + Time = alltracks.get(TID).get(k).time(); + //System.out.println("reco " + Time); + //System.out.println("tdiff " + tdiff); + Time+=tdiff; + + //System.out.println(Time + " " + cellID); + + + //int NEve = 10; + + double PAD_W = 2.79; // in mm + double PAD_S = 80.0; //in mm + double PAD_L = 4.0; // in mm + double RTPC_L = 384.0; // in mm + + //double Num_of_Rows = (2.0*(Math.PI)*PAD_S)/PAD_W; + double Num_of_Cols = RTPC_L/PAD_L; + //double TotChan = Num_of_Rows*Num_of_Cols; + + double PI=Math.PI; + + double z0 = -(RTPC_L/2.0); // front of RTPC in mm at the center of the pad + + double phi_per_pad = PAD_W/PAD_S; // in rad + + + + // MagBoltz parameters + //double a_t=1741.179712, b_t=-1.25E+02; // for f(x)=time(radius) + //double a_phi=0.161689123, b_phi=0.023505021; // for f(x)=dphi(radius) + + double t_2GEM2 = 296.082; + double t_2GEM3 = 296.131; + double t_2PAD = 399.09; + double t_gap = t_2GEM2 + t_2GEM3 + t_2PAD; + + double phi_2GEM2 = 0.0492538; + double phi_2GEM3 = 0.0470817; + double phi_2PAD = 0.0612122; + double phi_gap = phi_2GEM2 + phi_2GEM3 + phi_2PAD; + + // find postition from Cell ID + //for (double s = 0.0; s < cellID.size(); s++) { + + double chan=0; + double t_s2pad = 0; + double dphi=0; + double dz=0; + double x_rec = 0; + double y_rec = 0; + + + double z_pad=0; + double z_rec=0; + double z_hit=0; // position of the hit on a single pad in z + double delta_z=0; + + double r_pos=0; + double r_rec=0; + double r_temp=0; + double delta_r=0; + + double phi_pad=0; + double phi_rec=0; + + + + // generated position of ionization in phi + + //phi_pos = Math.atan2(Y, X); + + // generated position of ionization in s + //r_pos=Math.sqrt(((X)*(X))+((Y)*(Y))); + + + // ------------------ find z and phi of pad from CellID ------------------ + chan = (double)cellID; + + double col = chan%Num_of_Cols; + double row=(chan-col)/Num_of_Cols; + double z_shift = row%4; + //double z_shift = 0.; + + phi_pad=(row*phi_per_pad)+(phi_per_pad/2.0); + if(phi_pad>= 2.0*PI) { + phi_pad -= 2.0*PI; + } + if(phi_pad<0) + { + phi_pad += 2.0*PI; + } + + z_pad=z0+(col*PAD_L)+(PAD_L/2.0)+z_shift; + // ----------------------------------------------------------------------- + dz=0; + z_rec=z_pad-dz; + + // find reconstructed position of ionization from Time info + + t_s2pad = Time-t_gap; + //if(t_s2pad > 6000) {System.out.println("oooops");} + //System.out.println("time stuff " + t_s2pad + " " + Time); + + double a_t = get_rec_coef(a_t1,a_t2,a_t3,a_t4,a_t5,z_rec); + double b_t = get_rec_coef(b_t1,b_t2,b_t3,b_t4,b_t5,z_rec); + + r_rec=((-(Math.sqrt(a_t*a_t+(4.*b_t*t_s2pad)))+a_t+(14.*b_t))/(2.*b_t))*10.0; //in mm + + double a_phi = get_rec_coef(a_phi1,a_phi2,a_phi3,a_phi4,a_phi5,z_rec); + double b_phi = get_rec_coef(b_phi1,b_phi2,b_phi3,b_phi4,b_phi5,z_rec); + + dphi=a_phi*(7.-r_rec/10.)+b_phi*(7.-r_rec/10.)*(7.-r_rec/10.); // in rad + //System.out.println("r and phi " + r_rec + " " + dphi); + + + //System.out.println("phi stuff " + phi_pad + " " + dphi + " " + phi_gap); + phi_rec=phi_pad-dphi-phi_gap; + if( phi_rec<0.0 ) + { + phi_rec+=2.0*PI; + } + if( phi_rec>2.0*PI ) + { + phi_rec-=2.0*PI; + } + if(r_rec > 70 || r_rec < 30) + { + outsidedriftcounter++; + } + // x,y,z pos of reconstructed track + x_rec=r_rec*(Math.cos(phi_rec)); + y_rec=r_rec*(Math.sin(phi_rec)); + + + recohitvector.get(TID).add(new RecoHitVector(cellID,x_rec,y_rec,z_rec,tdiff,Time)); + //if(r_rec > 30 && r_rec < 70) + //{ + graphmap.get(TID).addPoint(r_rec, z_rec, 0, 0); + graphmap2.get(TID).addPoint(x_rec, y_rec, 0, 0); + + + + //System.out.println("TID time phi x y " + TID + " " + Time + " " + phi_rec + " " + x_rec + " " + y_rec); + //} + // x,y,z pos of pad hit + //x_pad=(PAD_S)*(Math.cos(phi_pad)); + //y_pad=(PAD_S)*(Math.sin(phi_pad)); + + // actual position on pad of hits + //phi_hit=phi_rad-(row*phi_per_pad); + //z_hit=Z-z0-(col*PAD_L)-z_shift; + + // find differences (delta = generated-reconstructed) + //delta_x=X-x_rec; + //delta_y=Y-y_rec; + //delta_z=Z-z_rec; + //delta_r=r_pos-r_rec; + //delta_phi = phi_pos-phi_rec; + + + + + /*hit.set_cellID(cellID); + hit.set_Time(t_s2pad); + hit.set_Edep(Edep); + hit.set_PosX(x_rec); + hit.set_PosY(y_rec); + hit.set_PosZ(z_rec); + TimeVec.add(t_s2pad); + XVec.add(x_rec); + YVec.add(y_rec); + ZVec.add(z_rec);*/ + + + + } + //System.out.println("num of pads " + Pads.size()); + } + GraphErrors grz = new GraphErrors(); + GraphErrors g1rz = new GraphErrors(); + GraphErrors gxy = new GraphErrors(); + GraphErrors g1xy = new GraphErrors(); + GraphErrors g2xy = new GraphErrors(); + GraphErrors gerrorxvsphi = new GraphErrors(); + GraphErrors gerroryvsphi = new GraphErrors(); + int counter = 1; + + for(Hit hit : rawHits) + { + if(true) { + cellID = hit.get_cellID(); + + Time = hit.get_Time(); + //double T_noshift = Time; + if(Time <= 0) {continue;} + Time -= hit.get_TShift(); + //System.out.println("Time " + hit.get_Time() + " " + hit.get_TShift()); + + double X = hit.get_PosXTrue(); + double Y = hit.get_PosYTrue(); + double Z = hit.get_PosZTrue(); + //double TimeNoShift = Time - hit.get_TShift(); + //if(Pads.contains(cellID)) + //{ + //ystem.out.println(Time + " " + cellID); + + + //int NEve = 10; + + double PAD_W = 2.79; // in mm + double PAD_S = 80.0; //in mm + double PAD_L = 4.0; // in mm + double RTPC_L = 384.0; // in mm + + //double Num_of_Rows = (2.0*(Math.PI)*PAD_S)/PAD_W; + double Num_of_Cols = RTPC_L/PAD_L; + //double TotChan = Num_of_Rows*Num_of_Cols; + + double PI=Math.PI; + + double z0 = -(RTPC_L/2.0); // front of RTPC in mm at the center of the pad + + double phi_per_pad = PAD_W/PAD_S; // in rad + + + + // MagBoltz parameters + //double a_t=1741.179712, b_t=-125; // for f(x)=time(radius) + //double a_phi=0.161689123, b_phi=0.023505021; // for f(x)=dphi(radius) + + double t_2GEM2 = 296.082; + double t_2GEM3 = 296.131; + double t_2PAD = 399.09; + double t_gap = t_2GEM2 + t_2GEM3 + t_2PAD; + + double phi_2GEM2 = 0.0492538; + double phi_2GEM3 = 0.0470817; + double phi_2PAD = 0.0612122; + double phi_gap = phi_2GEM2 + phi_2GEM3 + phi_2PAD; + + // find position from Cell ID + //for (double s = 0.0; s < cellID.size(); s++) { + + double chan=0; + double t_s2pad = 0; + double dphi=0; + double dz=0; + double x_rec = 0; + double y_rec = 0; + + + double z_pad=0; + double z_rec=0; + double z_hit=0; // position of the hit on a single pad in z + double delta_z=0; + + double r_pos=0; + double r_rec=0; + double r_temp=0; + double delta_r=0; + + double phi_pad=0; + double phi_rec=0; + double phi_pos = 0; + + double t_calc = 0; + + + + // generated position of ionization in phi + + phi_pos = Math.atan2(Y, X); + + // generated position of ionization in s + r_pos=Math.sqrt(((X)*(X))+((Y)*(Y))); + //System.out.println(r_pos + " " + X + " " + Y); + + + // ------------------ find z and phi of pad from CellID ------------------ + chan = (double)cellID; + + double col = chan%Num_of_Cols; + double row=(chan-col)/Num_of_Cols; + double z_shift = row%4; + //double z_shift = 0.; + //System.out.println(row + " " + chan + " " + col + " " + phi_per_pad); + phi_pad=(row*phi_per_pad)+(phi_per_pad/2.0); + while(phi_pad >= 2*PI || phi_pad < 0) + { + if(phi_pad>= 2.0*PI) { + phi_pad -= 2.0*PI; + } + if(phi_pad<0) + { + phi_pad += 2.0*PI; + } + } + z_pad=z0+(col*PAD_L)+(PAD_L/2.0)+z_shift; + // ----------------------------------------------------------------------- + dz=0; + z_rec=z_pad-dz; + + // find reconstructed position of ionization from Time info + + double a_t = get_rec_coef(a_t1,a_t2,a_t3,a_t4,a_t5,z_rec); + double b_t = get_rec_coef(b_t1,b_t2,b_t3,b_t4,b_t5,z_rec); + + + + double a_phi = get_rec_coef(a_phi1,a_phi2,a_phi3,a_phi4,a_phi5,z_rec); + double b_phi = get_rec_coef(b_phi1,b_phi2,b_phi3,b_phi4,b_phi5,z_rec); + + //System.out.println(a_t + " " + b_t + " " + a_phi + " " + b_phi + " " + z_rec); + + t_s2pad = Time-t_gap; + + r_rec = ((-(Math.sqrt(a_t*a_t+(4*b_t*t_s2pad)))+a_t+(14*b_t))/(2*b_t))*10.0; //in mm + t_calc = ((((2*b_t*r_pos*0.1)-(14*b_t)-a_t)*((2*b_t*r_pos*0.1)-14*b_t-a_t))-(a_t*a_t))*(1/(4*b_t)) + t_gap; + + + dphi=a_phi*(7-r_rec/10)+b_phi*(7-r_rec/10)*(7.-r_rec/10); // in rad + + + phi_rec=phi_pad-dphi-phi_gap; + while(phi_rec < 0 || phi_rec >= 2*PI) + { + if( phi_rec<0.0 ) + { + phi_rec+=2.0*PI; + } + if( phi_rec>2.0*PI ) + { + phi_rec-=2.0*PI; + } + } + //System.out.println("reconstructed phi " + phi_rec + " actual phi " + Math.atan(Y/X)); + + // x,y,z pos of reconstructed track + x_rec=r_rec*(Math.cos(phi_rec)); + y_rec=r_rec*(Math.sin(phi_rec)); + //System.out.println("rec " + x_rec + " " + y_rec + " " + phi_rec + " " + r_rec + " " + Time); + //if(true) + //if(counter > 2500) + //if(r_rec > 30 && r_rec < 70) + //if(Math.abs(x_rec-X) < 3 && Math.abs(y_rec-Y) < 3 && Math.abs(z_rec-Z) < 3) + //if(true) + //if(Math.abs(t_calc - Time) < timewindow) + if(hit.get_TShift() == 0) + { + //System.out.println(t_calc + " " + Time); + grz.addPoint(r_rec, z_rec, 0, 0); + gxy.addPoint(x_rec, y_rec, 0, 0); + //if(counter <= 53) + //{ + g1rz.addPoint(Math.sqrt(X*X+Y*Y), Z, 0, 0); + g1xy.addPoint(X, Y, 0, 0); + g2xy.addPoint(0, 0, 0, 0); + gerrorxvsphi.addPoint(Math.atan2(Y,X),Math.pow(Math.abs(x_rec-X),2)/X,0,0); + gerroryvsphi.addPoint(Math.atan2(Y,X),Math.pow(Math.abs(y_rec-Y),2)/Y,0,0); + //} + //System.out.println(counter); + } + else + { + //g2xy.addPoint(X, Y, 0, 0); + g2xy.addPoint(0, 0, 0, 0); + grz.addPoint(0, 0, 0, 0); + g1rz.addPoint(0, 0, 0, 0); + gxy.addPoint(0, 0, 0, 0); + g1xy.addPoint(0, 0, 0, 0); + } + //} + // x,y,z pos of pad hit + //x_pad=(PAD_S)*(Math.cos(phi_pad)); + //y_pad=(PAD_S)*(Math.sin(phi_pad)); + + // actual position on pad of hits + //phi_hit=phi_rad-(row*phi_per_pad); + //z_hit=Z-z0-(col*PAD_L)-z_shift; + + // find differences (delta = generated-reconstructed) + //delta_x=X-x_rec; + //delta_y=Y-y_rec; + //delta_z=Z-z_rec; + //delta_r=r_pos-r_rec; + //delta_phi = phi_pos-phi_rec; + //System.out.println(X + " " + x_rec); + //System.out.println(r_pos + " " + r_rec); + + + + /*hit.set_cellID(cellID); + hit.set_Time(t_s2pad); + hit.set_Edep(Edep); + hit.set_PosX(x_rec); + hit.set_PosY(y_rec); + hit.set_PosZ(z_rec); + TimeVec.add(t_s2pad); + XVec.add(x_rec); + YVec.add(y_rec); + ZVec.add(z_rec);*/ + //} + counter++; + } + } + //System.out.println(counter); + GraphErrors g2 = new GraphErrors(); + double theta = 0; + double test_x = 0; + double test_y = 0; + double test_x2 = 0; + double test_y2 = 0; + while(theta <= 2*Math.PI) + { + test_x = 30 * Math.cos(theta); + test_y = 30 * Math.sin(theta); + test_x2 = 70 * Math.cos(theta); + test_y2 = 70 * Math.sin(theta); + g2.addPoint(test_x, test_y, 0, 0); + g2.addPoint(test_x2, test_y2, 0, 0); + theta+=0.01; + } + int color = 2; + int shape = 1; + for(int key : graphmap.keySet()) + { + double szPos[][] = new double[recohitvector.get(key).size()][3]; + for(int i = 0; i < recohitvector.get(key).size(); i++) { + szPos[i][0] = recohitvector.get(key).get(i).x(); + szPos[i][1] = recohitvector.get(key).get(i).y(); + szPos[i][2] = recohitvector.get(key).get(i).z(); + } + //double R = 0; double A = 0; double B = 0; double Phi_deg = 0; double Theta_deg = 0; double Z0 = 0; int fit_track_to_beamline = 1; + //HelixFitJava hf = new HelixFitJava(); + //hf.HelixFit(recohitvector.get(key).size(), szPos, R, A, B, Phi_deg, Theta_deg, Z0, fit_track_to_beamline); + //System.out.println(key + " " + R); + if(false) + //if(key == 3) + { + graphmap.get(key).setMarkerSize(6); + graphmap2.get(key).setMarkerSize(6); + } + else { + graphmap.get(key).setMarkerSize(3); + graphmap.get(key).setMarkerColor(color); + graphmap.get(key).setMarkerStyle(shape); + + + graphmap2.get(key).setMarkerSize(3); + graphmap2.get(key).setMarkerColor(color); + graphmap2.get(key).setMarkerStyle(shape); + + } + //c.draw(graphmap.get(key),"same"); + //c2.draw(graphmap2.get(key),"same"); + color++; + if(color > 7) + { + color -= 6; + shape++; + } + } + grz.setMarkerSize(3); + grz.setMarkerColor(1); + g1rz.setMarkerSize(2); + g1rz.setMarkerColor(2); + //grz.addPoint(30, -200, 0, 0); + //grz.addPoint(70, 200, 0, 0); + gxy.setMarkerSize(2); + gxy.setMarkerColor(2); + g1xy.setMarkerSize(2); + g1xy.setMarkerColor(1); + g2xy.setMarkerSize(2); + g2xy.setMarkerColor(7); + g2.setMarkerSize(0); + g2.setMarkerColor(3); + gerrorxvsphi.setMarkerSize(2); + gerroryvsphi.setMarkerSize(2); + c.draw(grz,"same"); + c.draw(g1rz,"same"); + c2.draw(gxy,"same"); + c2.draw(g1xy,"same"); + c2.draw(g2,"same"); + c2.draw(g2xy,"same"); + c3.divide(1, 2); + c3.cd(0); + c3.draw(gerrorxvsphi); + c3.cd(1); + c3.draw(gerroryvsphi); + c4.draw(largetdist); + j.setTitle("RZ"); + j2.setTitle("XY"); + if(draw == true) { + j.add(c); + j.setVisible(true); + j2.add(c2); + j2.setVisible(true); + //j3.add(c3); + //j3.setVisible(true); + j4.add(c4); + //j4.setVisible(true); + } + + //System.out.println(outsidedriftcounter + "/" + allhitscounter); + params.set_alltracks(alltracks); + params.set_recohitvector(recohitvector); + } + + double get_rec_coef(double t1, double t2, double t3, double t4, double t5, double z2) { + double z = z2/1000; + return t1*z*z*z*z + t2*z*z*z + t3*z*z + t4*z + t5; + + } + + +} diff --git a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TrackHitReco3.java b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TrackHitReco3.java new file mode 100644 index 0000000000..de93d85a77 --- /dev/null +++ b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TrackHitReco3.java @@ -0,0 +1,649 @@ +//Author: David Payette and Nate Dzbenski + +/* This code takes the time-reduced tracks produced by the Time Average, as well as the original hits + * and uses a fit formula from garfield++ to calculate the hit's position in the drift region + * based on the time of the signal. We use the original hits to see how well the formula performs + * when we include factors such as time shifts and non-uniform magnetic fields + */ + +package org.jlab.rec.rtpc.hit; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Vector; +import java.util.concurrent.ConcurrentHashMap; + +import javax.swing.JFrame; + +import org.jlab.clas.physics.Vector3; +import org.jlab.groot.data.GraphErrors; +import org.jlab.groot.data.H1F; +import org.jlab.groot.graphics.EmbeddedCanvas; +import org.jlab.rec.rtpc.hit.RecoHitVector; + +public class TrackHitReco3 { + + public TrackHitReco3(List rawHits, HitParameters params, boolean draw) { + /* + HashMap graphmap = new HashMap(); + HashMap graphmap2 = new HashMap(); + */ + HashMap> alltracks = params.get_alltracks(); + HashMap largetmap = params.get_largetmap(); + HashMap tdiffmap = new HashMap(); + HashMap> recohitvector = new HashMap>(); + ReducedTrackMap RTIDMap = params.get_rtrackmap(); + Vector TimeVec = new Vector(); + Vector XVec = new Vector(); + Vector YVec = new Vector(); + Vector ZVec = new Vector(); + Vector Pads = new Vector(); + int p = 0; + + double a_t1 = -2.48491E-4; + double a_t2 = 2.21413E-4; + double a_t3 = -3.11195E-3; + double a_t4 = -2.75206E-1; + double a_t5 = 1.74281E3; + + double b_t1 = 2.48873E-5; + double b_t2 = -1.19976E-4; + double b_t3 = -3.75962E-3; + double b_t4 = 5.33100E-2; + double b_t5 = -1.25647E2; + + double a_phi1 = -3.32718E-8; + double a_phi2 = 1.92110E-7; + double a_phi3 = 2.16919E-6; + double a_phi4 = -8.10207E-5; + double a_phi5 = 1.68481E-1; + + double b_phi1 = -3.23019E-9; + double b_phi2 = -6.92075E-8; + double b_phi3 = 1.24731E-5; + double b_phi4 = 2.57684E-5; + double b_phi5 = 2.10680E-2; + if(draw){ + H1F largetdist = new H1F("largetdist",100,0,10000); + } + double timewindow = 2000; + double smalltcut = 300; + double largetcut = 8000; + int tracksizecut = 4; + double larget = 0; + double tdiff = 0; + double Time = 0; + int cellID = 0; + int outsidedriftcounter = 0; + int allhitscounter = 0; + + List tids = RTIDMap.getAllTrackIDs(); + for(int TID : tids) { + ReducedTrack t = RTIDMap.getTrack(TID); + Pads.clear(); + double smallt = t.getSmallT(); + larget = t.getLargeT(); + //largetdist.fill(larget); + if(draw){ + //graphmap.put(TID, new GraphErrors()); + //graphmap2.put(TID, new GraphErrors()); + } + tdiff = 6000 - larget; + tdiffmap.put(TID, tdiff); + recohitvector.put(TID, new Vector()); + + List allhits = t.getAllHits(); + for(HitVector hit : allhits) { + //for(int padindex = 0; padindex < TIDMap.get(TID).get(t).size(); padindex++){ + + allhitscounter++; + //int cellID = TIDMap.get(TID).get(t).get(padindex); + cellID = hit.pad(); + if(!Pads.contains(cellID)) { + Pads.add(cellID); + } + //double Time = weightave.get(cellID); + Time = hit.time(); + //System.out.println("reco " + Time); + //System.out.println("tdiff " + tdiff); + Time+=tdiff; + + //System.out.println(Time + " " + cellID); + + + //int NEve = 10; + + double PAD_W = 2.79; // in mm + double PAD_S = 80.0; //in mm + double PAD_L = 4.0; // in mm + double RTPC_L = 384.0; // in mm + + //double Num_of_Rows = (2.0*(Math.PI)*PAD_S)/PAD_W; + double Num_of_Cols = RTPC_L/PAD_L; + //double TotChan = Num_of_Rows*Num_of_Cols; + + double PI=Math.PI; + + double z0 = -(RTPC_L/2.0); // front of RTPC in mm at the center of the pad + + double phi_per_pad = PAD_W/PAD_S; // in rad + + + + // MagBoltz parameters + //double a_t=1741.179712, b_t=-1.25E+02; // for f(x)=time(radius) + //double a_phi=0.161689123, b_phi=0.023505021; // for f(x)=dphi(radius) + + double t_2GEM2 = 296.082; + double t_2GEM3 = 296.131; + double t_2PAD = 399.09; + double t_gap = t_2GEM2 + t_2GEM3 + t_2PAD; + + double phi_2GEM2 = 0.0492538; + double phi_2GEM3 = 0.0470817; + double phi_2PAD = 0.0612122; + double phi_gap = phi_2GEM2 + phi_2GEM3 + phi_2PAD; + + // find postition from Cell ID + //for (double s = 0.0; s < cellID.size(); s++) { + + double chan=0; + double t_s2pad = 0; + double dphi=0; + double dz=0; + double x_rec = 0; + double y_rec = 0; + + + double z_pad=0; + double z_rec=0; + double z_hit=0; // position of the hit on a single pad in z + double delta_z=0; + + double r_pos=0; + double r_rec=0; + double r_temp=0; + double delta_r=0; + + double phi_pad=0; + double phi_rec=0; + + + + // generated position of ionization in phi + + //phi_pos = Math.atan2(Y, X); + + // generated position of ionization in s + //r_pos=Math.sqrt(((X)*(X))+((Y)*(Y))); + + + // ------------------ find z and phi of pad from CellID ------------------ + chan = (double)cellID; + + double col = chan%Num_of_Cols; + double row=(chan-col)/Num_of_Cols; + double z_shift = row%4; + //double z_shift = 0.; + + phi_pad=(row*phi_per_pad)+(phi_per_pad/2.0); + if(phi_pad>= 2.0*PI) { + phi_pad -= 2.0*PI; + } + if(phi_pad<0) + { + phi_pad += 2.0*PI; + } + + z_pad=z0+(col*PAD_L)+(PAD_L/2.0)+z_shift; + // ----------------------------------------------------------------------- + dz=0; + z_rec=z_pad-dz; + + // find reconstructed position of ionization from Time info + + t_s2pad = Time-t_gap; + //if(t_s2pad > 6000) {System.out.println("oooops");} + //System.out.println("time stuff " + t_s2pad + " " + Time); + + double a_t = get_rec_coef(a_t1,a_t2,a_t3,a_t4,a_t5,z_rec); + double b_t = get_rec_coef(b_t1,b_t2,b_t3,b_t4,b_t5,z_rec); + + r_rec=((-(Math.sqrt(a_t*a_t+(4.*b_t*t_s2pad)))+a_t+(14.*b_t))/(2.*b_t))*10.0; //in mm + + double a_phi = get_rec_coef(a_phi1,a_phi2,a_phi3,a_phi4,a_phi5,z_rec); + double b_phi = get_rec_coef(b_phi1,b_phi2,b_phi3,b_phi4,b_phi5,z_rec); + + dphi=a_phi*(7.-r_rec/10.)+b_phi*(7.-r_rec/10.)*(7.-r_rec/10.); // in rad + //System.out.println("r and phi " + r_rec + " " + dphi); + + + //System.out.println("phi stuff " + phi_pad + " " + dphi + " " + phi_gap); + phi_rec=phi_pad-dphi-phi_gap; + if( phi_rec<0.0 ) + { + phi_rec+=2.0*PI; + } + if( phi_rec>2.0*PI ) + { + phi_rec-=2.0*PI; + } + if(r_rec > 70 || r_rec < 30) + { + outsidedriftcounter++; + } + // x,y,z pos of reconstructed track + x_rec=r_rec*(Math.cos(phi_rec)); + y_rec=r_rec*(Math.sin(phi_rec)); + + + recohitvector.get(TID).add(new RecoHitVector(cellID,x_rec,y_rec,z_rec,tdiff,Time)); + //if(r_rec > 30 && r_rec < 70) + //{ + if(draw){ + //graphmap.get(TID).addPoint(r_rec, z_rec, 0, 0); + //graphmap2.get(TID).addPoint(x_rec, y_rec, 0, 0); + } + + + + //System.out.println("TID time phi x y " + TID + " " + Time + " " + phi_rec + " " + x_rec + " " + y_rec); + //} + // x,y,z pos of pad hit + //x_pad=(PAD_S)*(Math.cos(phi_pad)); + //y_pad=(PAD_S)*(Math.sin(phi_pad)); + + // actual position on pad of hits + //phi_hit=phi_rad-(row*phi_per_pad); + //z_hit=Z-z0-(col*PAD_L)-z_shift; + + // find differences (delta = generated-reconstructed) + //delta_x=X-x_rec; + //delta_y=Y-y_rec; + //delta_z=Z-z_rec; + //delta_r=r_pos-r_rec; + //delta_phi = phi_pos-phi_rec; + + + + + /*hit.set_cellID(cellID); + hit.set_Time(t_s2pad); + hit.set_Edep(Edep); + hit.set_PosX(x_rec); + hit.set_PosY(y_rec); + hit.set_PosZ(z_rec); + TimeVec.add(t_s2pad); + XVec.add(x_rec); + YVec.add(y_rec); + ZVec.add(z_rec);*/ + + + + } + //System.out.println("num of pads " + Pads.size()); + } + /*GraphErrors grz = new GraphErrors(); + GraphErrors g1rz = new GraphErrors(); + GraphErrors gxy = new GraphErrors(); + GraphErrors g1xy = new GraphErrors(); + GraphErrors g2xy = new GraphErrors(); + GraphErrors gerrorxvsphi = new GraphErrors(); + GraphErrors gerroryvsphi = new GraphErrors();*/ + int counter = 1; + + for(Hit hit : rawHits) + { + if(true) { + cellID = hit.get_cellID(); + + Time = hit.get_Time(); + //double T_noshift = Time; + if(Time <= 0) {continue;} + Time -= hit.get_TShift(); + //System.out.println("Time " + hit.get_Time() + " " + hit.get_TShift()); + + double X = hit.get_PosXTrue(); + double Y = hit.get_PosYTrue(); + double Z = hit.get_PosZTrue(); + //double TimeNoShift = Time - hit.get_TShift(); + //if(Pads.contains(cellID)) + //{ + //ystem.out.println(Time + " " + cellID); + + + //int NEve = 10; + + double PAD_W = 2.79; // in mm + double PAD_S = 80.0; //in mm + double PAD_L = 4.0; // in mm + double RTPC_L = 384.0; // in mm + + //double Num_of_Rows = (2.0*(Math.PI)*PAD_S)/PAD_W; + double Num_of_Cols = RTPC_L/PAD_L; + //double TotChan = Num_of_Rows*Num_of_Cols; + + double PI=Math.PI; + + double z0 = -(RTPC_L/2.0); // front of RTPC in mm at the center of the pad + + double phi_per_pad = PAD_W/PAD_S; // in rad + + + + // MagBoltz parameters + //double a_t=1741.179712, b_t=-125; // for f(x)=time(radius) + //double a_phi=0.161689123, b_phi=0.023505021; // for f(x)=dphi(radius) + + double t_2GEM2 = 296.082; + double t_2GEM3 = 296.131; + double t_2PAD = 399.09; + double t_gap = t_2GEM2 + t_2GEM3 + t_2PAD; + + double phi_2GEM2 = 0.0492538; + double phi_2GEM3 = 0.0470817; + double phi_2PAD = 0.0612122; + double phi_gap = phi_2GEM2 + phi_2GEM3 + phi_2PAD; + + // find position from Cell ID + //for (double s = 0.0; s < cellID.size(); s++) { + + double chan=0; + double t_s2pad = 0; + double dphi=0; + double dz=0; + double x_rec = 0; + double y_rec = 0; + + + double z_pad=0; + double z_rec=0; + double z_hit=0; // position of the hit on a single pad in z + double delta_z=0; + + double r_pos=0; + double r_rec=0; + double r_temp=0; + double delta_r=0; + + double phi_pad=0; + double phi_rec=0; + double phi_pos = 0; + + double t_calc = 0; + + + + // generated position of ionization in phi + + phi_pos = Math.atan2(Y, X); + + // generated position of ionization in s + r_pos=Math.sqrt(((X)*(X))+((Y)*(Y))); + //System.out.println(r_pos + " " + X + " " + Y); + + + // ------------------ find z and phi of pad from CellID ------------------ + chan = (double)cellID; + + double col = chan%Num_of_Cols; + double row=(chan-col)/Num_of_Cols; + double z_shift = row%4; + //double z_shift = 0.; + //System.out.println(row + " " + chan + " " + col + " " + phi_per_pad); + phi_pad=(row*phi_per_pad)+(phi_per_pad/2.0); + while(phi_pad >= 2*PI || phi_pad < 0) + { + if(phi_pad>= 2.0*PI) { + phi_pad -= 2.0*PI; + } + if(phi_pad<0) + { + phi_pad += 2.0*PI; + } + } + z_pad=z0+(col*PAD_L)+(PAD_L/2.0)+z_shift; + // ----------------------------------------------------------------------- + dz=0; + z_rec=z_pad-dz; + + // find reconstructed position of ionization from Time info + + double a_t = get_rec_coef(a_t1,a_t2,a_t3,a_t4,a_t5,z_rec); + double b_t = get_rec_coef(b_t1,b_t2,b_t3,b_t4,b_t5,z_rec); + + + + double a_phi = get_rec_coef(a_phi1,a_phi2,a_phi3,a_phi4,a_phi5,z_rec); + double b_phi = get_rec_coef(b_phi1,b_phi2,b_phi3,b_phi4,b_phi5,z_rec); + + //System.out.println(a_t + " " + b_t + " " + a_phi + " " + b_phi + " " + z_rec); + + t_s2pad = Time-t_gap; + + r_rec = ((-(Math.sqrt(a_t*a_t+(4*b_t*t_s2pad)))+a_t+(14*b_t))/(2*b_t))*10.0; //in mm + t_calc = ((((2*b_t*r_pos*0.1)-(14*b_t)-a_t)*((2*b_t*r_pos*0.1)-14*b_t-a_t))-(a_t*a_t))*(1/(4*b_t)) + t_gap; + + + dphi=a_phi*(7-r_rec/10)+b_phi*(7-r_rec/10)*(7.-r_rec/10); // in rad + + + phi_rec=phi_pad-dphi-phi_gap; + while(phi_rec < 0 || phi_rec >= 2*PI) + { + if( phi_rec<0.0 ) + { + phi_rec+=2.0*PI; + } + if( phi_rec>2.0*PI ) + { + phi_rec-=2.0*PI; + } + } + //System.out.println("reconstructed phi " + phi_rec + " actual phi " + Math.atan(Y/X)); + + // x,y,z pos of reconstructed track + x_rec=r_rec*(Math.cos(phi_rec)); + y_rec=r_rec*(Math.sin(phi_rec)); + //System.out.println("rec " + x_rec + " " + y_rec + " " + phi_rec + " " + r_rec + " " + Time); + //if(true) + //if(counter > 2500) + //if(r_rec > 30 && r_rec < 70) + //if(Math.abs(x_rec-X) < 3 && Math.abs(y_rec-Y) < 3 && Math.abs(z_rec-Z) < 3) + //if(true) + //if(Math.abs(t_calc - Time) < timewindow) + /*if(draw){ + if(hit.get_TShift() == 0) + { + //System.out.println(t_calc + " " + Time); + grz.addPoint(r_rec, z_rec, 0, 0); + gxy.addPoint(x_rec, y_rec, 0, 0); + //if(counter <= 53) + //{ + g1rz.addPoint(Math.sqrt(X*X+Y*Y), Z, 0, 0); + g1xy.addPoint(X, Y, 0, 0); + g2xy.addPoint(0, 0, 0, 0); + gerrorxvsphi.addPoint(Math.atan2(Y,X),Math.pow(Math.abs(x_rec-X),2)/X,0,0); + gerroryvsphi.addPoint(Math.atan2(Y,X),Math.pow(Math.abs(y_rec-Y),2)/Y,0,0); + //} + //System.out.println(counter); + } + else + { + //g2xy.addPoint(X, Y, 0, 0); + g2xy.addPoint(0, 0, 0, 0); + grz.addPoint(0, 0, 0, 0); + g1rz.addPoint(0, 0, 0, 0); + gxy.addPoint(0, 0, 0, 0); + g1xy.addPoint(0, 0, 0, 0); + } + } + //} + // x,y,z pos of pad hit + //x_pad=(PAD_S)*(Math.cos(phi_pad)); + //y_pad=(PAD_S)*(Math.sin(phi_pad)); + + // actual position on pad of hits + //phi_hit=phi_rad-(row*phi_per_pad); + //z_hit=Z-z0-(col*PAD_L)-z_shift; + + // find differences (delta = generated-reconstructed) + //delta_x=X-x_rec; + //delta_y=Y-y_rec; + //delta_z=Z-z_rec; + //delta_r=r_pos-r_rec; + //delta_phi = phi_pos-phi_rec; + //System.out.println(X + " " + x_rec); + //System.out.println(r_pos + " " + r_rec); + + */ + + /*hit.set_cellID(cellID); + hit.set_Time(t_s2pad); + hit.set_Edep(Edep); + hit.set_PosX(x_rec); + hit.set_PosY(y_rec); + hit.set_PosZ(z_rec); + TimeVec.add(t_s2pad); + XVec.add(x_rec); + YVec.add(y_rec); + ZVec.add(z_rec);*/ + //} + counter++; + } + } + if(draw){ + /*EmbeddedCanvas c = new EmbeddedCanvas(); + EmbeddedCanvas c2 = new EmbeddedCanvas(); + EmbeddedCanvas c3 = new EmbeddedCanvas(); + EmbeddedCanvas c4 = new EmbeddedCanvas(); + //System.out.println(counter); + GraphErrors g2 = new GraphErrors(); + double theta = 0; + double test_x = 0; + double test_y = 0; + double test_x2 = 0; + double test_y2 = 0; + while(theta <= 2*Math.PI) + { + test_x = 30 * Math.cos(theta); + test_y = 30 * Math.sin(theta); + test_x2 = 70 * Math.cos(theta); + test_y2 = 70 * Math.sin(theta); + g2.addPoint(test_x, test_y, 0, 0); + g2.addPoint(test_x2, test_y2, 0, 0); + theta+=0.01; + } + int color = 2; + int shape = 1; + for(int key : graphmap.keySet()) + { + double szPos[][] = new double[recohitvector.get(key).size()][3]; + for(int i = 0; i < recohitvector.get(key).size(); i++) { + szPos[i][0] = recohitvector.get(key).get(i).x(); + szPos[i][1] = recohitvector.get(key).get(i).y(); + szPos[i][2] = recohitvector.get(key).get(i).z(); + } + //double R = 0; double A = 0; double B = 0; double Phi_deg = 0; double Theta_deg = 0; double Z0 = 0; int fit_track_to_beamline = 1; + //HelixFitJava hf = new HelixFitJava(); + //hf.HelixFit(recohitvector.get(key).size(), szPos, R, A, B, Phi_deg, Theta_deg, Z0, fit_track_to_beamline); + //System.out.println(key + " " + R); + if(false) + //if(key == 3) + { + graphmap.get(key).setMarkerSize(6); + graphmap2.get(key).setMarkerSize(6); + } + else { + graphmap.get(key).setMarkerSize(3); + graphmap.get(key).setMarkerColor(color); + graphmap.get(key).setMarkerStyle(shape); + + + graphmap2.get(key).setMarkerSize(3); + graphmap2.get(key).setMarkerColor(color); + graphmap2.get(key).setMarkerStyle(shape); + + } + c.draw(graphmap.get(key),"same"); + c2.draw(graphmap2.get(key),"same"); + color++; + if(color > 7) + { + color -= 6; + shape++; + } + } + grz.setMarkerSize(3); + grz.setMarkerColor(1); + g1rz.setMarkerSize(2); + g1rz.setMarkerColor(2); + //grz.addPoint(30, -200, 0, 0); + //grz.addPoint(70, 200, 0, 0); + gxy.setMarkerSize(2); + gxy.setMarkerColor(2); + g1xy.setMarkerSize(2); + g1xy.setMarkerColor(1); + g2xy.setMarkerSize(2); + g2xy.setMarkerColor(7); + g2.setMarkerSize(0); + g2.setMarkerColor(3); + gerrorxvsphi.setMarkerSize(2); + gerroryvsphi.setMarkerSize(2); + JFrame j = new JFrame(); + j.setSize(800,600); + JFrame j2 = new JFrame(); + j2.setSize(800,600); + JFrame j3 = new JFrame(); + j3.setSize(800,600); + JFrame j4 = new JFrame(); + j4.setSize(800,600); + c.draw(grz,"same"); + c.draw(g1rz,"same"); + c2.draw(gxy,"same"); + c2.draw(g1xy,"same"); + c2.draw(g2,"same"); + c2.draw(g2xy,"same"); + c3.divide(1, 2); + c3.cd(0); + c3.draw(gerrorxvsphi); + c3.cd(1); + c3.draw(gerroryvsphi); + //c4.draw(largetdist); + j.setTitle("RZ"); + j2.setTitle("XY"); + + + j.add(c); + j.setVisible(true); + j2.add(c2); + j2.setVisible(true); + //j3.add(c3); + //j3.setVisible(true); + j4.add(c4); + //j4.setVisible(true); + } + */ + } + //System.out.println(outsidedriftcounter + "/" + allhitscounter); + //params.set_alltracks(alltracks); + + params.set_recohitvector(recohitvector); + } + + double get_rec_coef(double t1, double t2, double t3, double t4, double t5, double z2) { + double z = z2/1000; + return t1*z*z*z*z + t2*z*z*z + t3*z*z + t4*z + t5; + + } + + +} + + + + diff --git a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TrackMap.java b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TrackMap.java new file mode 100644 index 0000000000..8f51e288b0 --- /dev/null +++ b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TrackMap.java @@ -0,0 +1,60 @@ +package org.jlab.rec.rtpc.hit; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ConcurrentHashMap; +import java.util.HashMap; + +public class TrackMap { + + private HashMap _map; + private int _trackID = 0; + + public TrackMap() { + _map = new HashMap(); + } + + public void addTrack(Track t) { + _trackID++; + _map.put(_trackID, t); + } + + public Track getTrack(int trackID) { + if(!_map.containsKey(trackID)) { + addTrack(new Track()); + } + return _map.get(trackID); + } + + public void updateTrack(int trackID, Track t) { + _map.put(trackID, t); + } + + public void removeTrack(int trackID) { + _map.remove(trackID); + } + + public List getAllTrackIDs() { + List l = new ArrayList(); + for(int i : _map.keySet()) { + if(!l.contains(i)) { l.add(i);} + } + return l; + } + + public int getLastTrackID() { + return _trackID; + } + + public void mergeTracks(int trackIDparent, int trackID) { + Track child = getTrack(trackID); + List l = child.getAllTimeSlices(); + Track parent = getTrack(trackIDparent); + for(int time : l) { + parent.addTimeSlice(time,child.getTimeSlice(time)); + } + //updateTrack(trackIDparent, parent); + removeTrack(trackID); + } + +} diff --git a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TrackUtils.java b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TrackUtils.java new file mode 100644 index 0000000000..a8bf34306f --- /dev/null +++ b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TrackUtils.java @@ -0,0 +1,44 @@ +package org.jlab.rec.rtpc.hit; + +public class TrackUtils { + private double adjthresh = 16; + private double PhiDelta = 16; + private double ZDelta = 36; + private double phithresh = 0.16; + private double zthresh = 16; + + public TrackUtils() {} + + public boolean comparePads(PadVector p1, PadVector p2, String Method) { + if(Method == "ellipse") {return ellipseMethod(p1, p2);} + if(Method == "phiz") {return phizMethod(p1,p2);} + else return false; + } + + private boolean ellipseMethod(PadVector p1, PadVector p2) { + double p1x = p1.x(); + double p1y = p1.y(); + double p1z = p1.z(); + double p2x = p2.x(); + double p2y = p2.y(); + double p2z = p2.z(); + double EllipseDeltax = Math.abs(p1x-p2x)*Math.abs(p1x-p2x); + double EllipseDeltay = Math.abs(p1y-p2y)*Math.abs(p1y-p2y); + double EllipseDeltaz = Math.abs(p1z-p2z)*Math.abs(p1z-p2z); + double EllipseTotal = ((EllipseDeltax+EllipseDeltay)/PhiDelta) + (EllipseDeltaz/ZDelta); + if(EllipseTotal < adjthresh) return true; + return false; + } + + private boolean phizMethod(PadVector p1, PadVector p2) { + double p1phi = p1.phi(); + double p2phi = p2.phi(); + double p1z = p1.z(); + double p2z = p2.z(); + double phidiff = p2phi-p1phi; + double zdiff = Math.abs(p1z-p2z); + //System.out.println(p1phi + " " + p2phi + " " + (p1phi - p2phi)); + return ((Math.abs(phidiff) + + + + +org.jlab.rec.rtpc.hit + + +
Author:
ziegler
+ + \ No newline at end of file diff --git a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/package.html b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/package.html new file mode 100644 index 0000000000..f0cd21cb47 --- /dev/null +++ b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/package.html @@ -0,0 +1,14 @@ + + + + + +org.jlab.rec.rtpc + + +
Author:
ziegler
+ + \ No newline at end of file diff --git a/reconstruction/rtpc/src/main/java/org/jlab/service/rtpc/RTPCEngine.java b/reconstruction/rtpc/src/main/java/org/jlab/service/rtpc/RTPCEngine.java new file mode 100644 index 0000000000..f55a3df89e --- /dev/null +++ b/reconstruction/rtpc/src/main/java/org/jlab/service/rtpc/RTPCEngine.java @@ -0,0 +1,179 @@ +package org.jlab.service.rtpc; + +import java.io.File; +import java.io.FileNotFoundException; + + +import java.util.ArrayList; +import java.util.List; + +import org.jlab.clas.reco.ReconstructionEngine; +//import org.jlab.coda.hipo.HipoException; +//import org.jlab.coda.jevio.EvioException; +import org.jlab.io.base.DataBank; +import org.jlab.io.base.DataEvent; +import org.jlab.io.hipo.HipoDataSource; +import org.jlab.io.hipo.HipoDataSync; +import org.jlab.rec.rtpc.banks.HitReader; +import org.jlab.rec.rtpc.banks.RecoBankWriter; +import org.jlab.rec.rtpc.banks.RecoBankWriter2; +import org.jlab.rec.rtpc.hit.Hit; +import org.jlab.rec.rtpc.hit.HitDistance; +import org.jlab.rec.rtpc.hit.HitParameters; +import org.jlab.rec.rtpc.hit.HitReconstruction; +import org.jlab.rec.rtpc.hit.MapCombine; +import org.jlab.rec.rtpc.hit.PadAve; +import org.jlab.rec.rtpc.hit.PadFit; +import org.jlab.rec.rtpc.hit.PadHit; +//import org.jlab.rec.rtpc.hit.PulseShapeAnalysis; +import org.jlab.rec.rtpc.hit.TimeAverage; +import org.jlab.rec.rtpc.hit.TimeAverage2; +//import org.jlab.rec.rtpc.hit.TrackDisentangler; +//import org.jlab.rec.rtpc.hit.TrackFinder; +import org.jlab.rec.rtpc.hit.TrackFinder2; +import org.jlab.rec.rtpc.hit.TrackFinder3; +import org.jlab.rec.rtpc.hit.TrackHitReco; +import org.jlab.rec.rtpc.hit.TrackHitReco2; +import org.jlab.rec.rtpc.hit.TrackHitReco3; + + + + +public class RTPCEngine extends ReconstructionEngine{ + + int test = 0; + int swtch = 2; + + + public RTPCEngine() { + super("RTPC","charlesg","3.0"); + } + + @Override + public boolean init() { + // TODO Auto-generated method stub + return true; + } + + @Override + public boolean processDataEvent(DataEvent event) { + HitParameters params = new HitParameters(); + HitReader hitRead = new HitReader(); + hitRead.fetch_RTPCHits(event); + + List hits = new ArrayList(); + //I) get the hits + hits = hitRead.get_RTPCHits(); + + //II) process the hits + //1) exit if hit list is empty + if(hits==null || hits.size()==0) { + return true; + } + if(event.hasBank("RTPC::pos")) + { + PadHit phit = new PadHit(); + phit.bonus_shaping(hits,params); + PadFit pfit = new PadFit(); + pfit.Fitting(params); + +// PulseShapeAnalysis psa = new PulseShapeAnalysis(); +// psa.PSA(params); + + //TrackFinder TF = new TrackFinder(); + //TF.FindTrack(params); + if(swtch == 1) //outdated build + { + HitDistance HD = new HitDistance(); + HD.FindDistance(params); + } + else if(swtch == 2) { //current build only use this one + TrackFinder3 TF = new TrackFinder3(params,false); + TimeAverage2 TA2 = new TimeAverage2(params,false); + //TrackDisentangler TD = new TrackDisentangler(params,true); + TrackHitReco3 TR3 = new TrackHitReco3(hits,params,false); + RecoBankWriter2 writer = new RecoBankWriter2(); + DataBank recoBank = writer.fillRTPCHitsBank(event, params); + event.appendBanks(recoBank); + } + else //outdated build + { + TrackFinder2 TF = new TrackFinder2(); + TF.FindTrack2(params,false); + TimeAverage TA = new TimeAverage(); + TA.TA(params,false); + MapCombine MC = new MapCombine(); + MC.MC(params,false); + /*TrackHitReco TR = new TrackHitReco(); + TR.Reco(hits,params);*/ + TrackHitReco2 TR = new TrackHitReco2(); + TR.Reco(hits,params,false); + RecoBankWriter2 writer = new RecoBankWriter2(); + DataBank recoBank = writer.fillRTPCHitsBank(event, params); + event.appendBanks(recoBank); + //recoBank.show(); + } + + } + else + { + return true; + } + + /* + for(Hit h : hits) { + System.out.println("Hit "+h.get_Id()+" CellID "+h.get_cellID()+" ADC "+h.get_ADC()+" true Edep "+h.get_EdepTrue()+" Edep "+h.get_Edep()+" Time "+h.get_Time()+" "+ + " true X "+h.get_PosXTrue()+" X "+h.get_PosX()+" true Y "+h.get_PosYTrue()+" Y "+h.get_PosY()+" true Z "+h.get_PosZTrue()+" Z "+h.get_PosZ()); + }*/ + + + + + return true; + } + + public static void main(String[] args){ + double starttime = System.nanoTime(); + //String inputFile = "/Users/davidpayette/Desktop/5c.2.3/clara/installation/plugins/clas12/2_72_516.hipo"; + //String inputFile = "/Users/davidpayette/Desktop/5c.2.3/clara/installation/plugins/clas12/1000_1_711.hipo"; + //String inputFile = "/Users/davidpayette/Desktop/5c.2.3/clara/installation/plugins/clas12/100_20_731.hipo"; + //String inputFile = "/Users/davidpayette/Desktop/5c.3.5/clara/installation/plugins/clas12/test.hipo"; + //String inputFile = "/Users/davidpayette/Desktop/5b.7.4/myClara/1212.hipo"; + //String inputFile = "/Users/davidpayette/Desktop/5b.7.4/myClara/plugins/clas12/Jantest.hipo"; + String inputFile = "/Users/davidpayette/Desktop/5b.7.4/myClara/plugins/clas12/newfeb.hipo"; + //String inputFile = "/Users/davidpayette/Desktop/Distribution/clas12-offline-software/1212again.hipo"; + //String inputFile = "/Users/davidpayette/Desktop/5c.2.3/clara/installation/plugins/clas12/100_20_802.hipo"; + //String inputFile = "/Users/davidpayette/Desktop/5c.2.3/clara/installation/plugins/clas12/10p.hipo"; + //String inputFile = args[0]; + String outputFile = "/Users/davidpayette/Desktop/5b.7.4/myClara/tout_working.hipo"; + + System.err.println(" \n[PROCESSING FILE] : " + inputFile); + + RTPCEngine en = new RTPCEngine(); + en.init(); + + + + HipoDataSource reader = new HipoDataSource(); + HipoDataSync writer = new HipoDataSync(); + reader.open(inputFile); + writer.open(outputFile); + System.out.println("starting " + starttime); + + File f1= new File("/Users/davidpayette/Documents/FileOutput/PulseShapeAll.txt"); + File f2= new File("/Users/davidpayette/Documents/FileOutput/PulseShapeMax.txt"); + File f3= new File("/Users/davidpayette/Documents/FileOutput/PulseShapeAllOverMax.txt"); + f1.delete(); + f2.delete(); + f3.delete(); + + while(reader.hasEvent()){ + + DataEvent event = reader.getNextEvent(); + en.processDataEvent(event); + writer.writeEvent(event); + } + writer.close(); + System.out.println("finished " + (System.nanoTime() - starttime)*Math.pow(10,-9)); + } +} diff --git a/reconstruction/rtpc/src/main/java/org/jlab/service/rtpc/package-info.java b/reconstruction/rtpc/src/main/java/org/jlab/service/rtpc/package-info.java new file mode 100644 index 0000000000..fb4baf2083 --- /dev/null +++ b/reconstruction/rtpc/src/main/java/org/jlab/service/rtpc/package-info.java @@ -0,0 +1,8 @@ +/** + * + */ +/** + * @author ziegler + * + */ +package org.jlab.service.rtpc; \ No newline at end of file diff --git a/reconstruction/src/main/java/org/jlab/rec/rtpc/Geometry.java b/reconstruction/src/main/java/org/jlab/rec/rtpc/Geometry.java new file mode 100644 index 0000000000..9652c3b283 --- /dev/null +++ b/reconstruction/src/main/java/org/jlab/rec/rtpc/Geometry.java @@ -0,0 +1,20 @@ +package org.jlab.rec.rtpc; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.PrintWriter; + +/*import org.jMath.Vector.threeVec; + +import trackfitter.surface.Line; +import trackfitter.track.Helix;*/ + +public class Geometry { + + public Geometry() { + + } + + + +} diff --git a/reconstruction/src/main/java/org/jlab/rec/rtpc/banks/HitReader.java b/reconstruction/src/main/java/org/jlab/rec/rtpc/banks/HitReader.java new file mode 100644 index 0000000000..246ae66ed4 --- /dev/null +++ b/reconstruction/src/main/java/org/jlab/rec/rtpc/banks/HitReader.java @@ -0,0 +1,104 @@ +package org.jlab.rec.rtpc.banks; + +import java.util.ArrayList; +import java.util.List; + +import org.jlab.io.base.DataBank; +import org.jlab.io.base.DataEvent; +import org.jlab.rec.rtpc.hit.Hit; +/** + * @author payette + * + */ +public class HitReader { + + private List _Hits; + + /** + * + * @return a list of RTPC hits + */ + public List get_RTPCHits() { + return _Hits; + } + + /** + * sets the list of RTPC hits + * @param RTPCHits list of RTPC hits + */ + public void set_RTPCHits(List RTPCHits) { + this._Hits = RTPCHits; + } + + + + + /** + * reads the hits using clas-io methods to get the EvioBank for the RTPC and fill the values to instanciate the RTPChit and MChit classes. + * This methods fills the RTPChit and MChit list of hits. If the data is not MC, the MChit list remains empty + * @param event DataEvent + */ + public void fetch_RTPCHits(DataEvent event) { + + + + List hits = new ArrayList(); + + DataBank bankDGTZ = null; + if(event.hasBank("RTPC::adc")==true) + bankDGTZ=event.getBank("RTPC::adc"); + DataBank bankTrue = null; + if(event.hasBank("RTPC::pos")==true) + bankTrue=event.getBank("RTPC::pos"); + if(bankDGTZ==null || bankTrue==null) + return ; + + int rows = bankDGTZ.rows(); + if(bankTrue.rows()!=rows) + return; + + int[] hitnb = new int[rows]; + int[] cellID = new int[rows]; + //int[] ADC = new int[rows]; + double[] Time = new double[rows]; + int[] step = new int[rows]; + double[] posX = new double[rows]; + double[] posY = new double[rows]; + double[] posZ = new double[rows]; + //double[] phiRad = new double[rows]; + double[] Edep = new double[rows]; + double[] TShift = new double[rows]; + + for(int i = 0; i 10000) + { + Time[i] = 0; + Edep[i] = 0; + posX[i] = 0; + posY[i] = 0; + posZ[i] = 0; + } + Hit hit = new Hit(1, cellID[i], 1, Time[i]); + hit.set_EdepTrue(Edep[i]); + hit.set_PosXTrue(posX[i]); + hit.set_PosYTrue(posY[i]); + hit.set_PosZTrue(posZ[i]); + hit.set_Time(Time[i]); + hit.set_TShift(TShift[i]); + + hits.add(hit); + } + + this.set_RTPCHits(hits); + + } +} diff --git a/reconstruction/src/main/java/org/jlab/rec/rtpc/banks/RecoBankWriter.java b/reconstruction/src/main/java/org/jlab/rec/rtpc/banks/RecoBankWriter.java new file mode 100644 index 0000000000..aa0b849626 --- /dev/null +++ b/reconstruction/src/main/java/org/jlab/rec/rtpc/banks/RecoBankWriter.java @@ -0,0 +1,45 @@ +package org.jlab.rec.rtpc.banks; + +import java.util.List; + +import org.jlab.io.base.DataBank; +import org.jlab.io.base.DataEvent; +import org.jlab.rec.rtpc.hit.Hit; + +public class RecoBankWriter { + + /** + * + * @param hitlist the list of hits that are of the type Hit. + * @return hits bank + * + */ + public DataBank fillRTPCHitsBank(DataEvent event, List hitlist) { + if(hitlist==null) + return null; + if(hitlist.size()==0) + return null; + + + DataBank bank = event.createBank("RTPC::rec", hitlist.size()); + + for(int i =0; i< hitlist.size(); i++) { + //System.out.println(hitlist.get(i).get_PosX()); + bank.setInt("id", i, hitlist.get(i).get_Id()); + bank.setInt("cellID",i, hitlist.get(i).get_cellID()); + bank.setFloat("posX",i, (float) hitlist.get(i).get_PosX()); + bank.setFloat("posY",i, (float) hitlist.get(i).get_PosY()); + bank.setFloat("posZ",i, (float) hitlist.get(i).get_PosZ()); + //bank.setDouble("Edep",i, hitlist.get(i).get_Edep()); + bank.setFloat("time", i, (float) hitlist.get(i).get_Time()); + + + } + + return bank; + + } + + + +} diff --git a/reconstruction/src/main/java/org/jlab/rec/rtpc/banks/RecoBankWriter2.java b/reconstruction/src/main/java/org/jlab/rec/rtpc/banks/RecoBankWriter2.java new file mode 100644 index 0000000000..924a5e21e8 --- /dev/null +++ b/reconstruction/src/main/java/org/jlab/rec/rtpc/banks/RecoBankWriter2.java @@ -0,0 +1,91 @@ +package org.jlab.rec.rtpc.banks; + +import java.util.concurrent.ConcurrentHashMap; +import java.util.Vector; + +import org.jlab.clas.physics.Vector3; + +//import java.util.List; + +import org.jlab.io.base.DataBank; +import org.jlab.io.base.DataEvent; +//import org.jlab.rec.rtpc.hit.Hit; +import org.jlab.rec.rtpc.hit.HitParameters; +import org.jlab.rec.rtpc.hit.HitVector; +import org.jlab.rec.rtpc.hit.RecoHitVector; +import java.util.HashMap; + +public class RecoBankWriter2 { + + /** + * + * @param hitlist the list of hits that are of the type Hit. + * @return hits bank + * + */ + public DataBank fillRTPCHitsBank(DataEvent event, HitParameters params) { + /*if(hitlist==null) + return null; + if(hitlist.size()==0) + return null;*/ + int listsize = 0; + int row = 0; + HashMap> recohitvector = params.get_recohitvector(); + + for(int TID:recohitvector.keySet()) { + for(int i = 0; i < recohitvector.get(TID).size(); i++) { + listsize++; + } + } + + DataBank bank = event.createBank("RTPC::rec", listsize); + + if (bank == null) { + System.err.println("COULD NOT CREATE A BANK!!!!!!"); + return null; + } + + for(int TID : recohitvector.keySet()) { + for(int i = 0; i < recohitvector.get(TID).size(); i++) { + int cellID = recohitvector.get(TID).get(i).pad(); + double x_rec = recohitvector.get(TID).get(i).x(); + double y_rec = recohitvector.get(TID).get(i).y(); + double z_rec = recohitvector.get(TID).get(i).z(); + double time = recohitvector.get(TID).get(i).time(); + double tdiff = recohitvector.get(TID).get(i).dt(); + + bank.setInt("TID", row, TID); + bank.setInt("cellID", row, cellID); + bank.setFloat("time", row, (float) time); + bank.setFloat("posX", row, (float) x_rec); + bank.setFloat("posY", row, (float) y_rec); + bank.setFloat("posZ", row, (float) z_rec); + bank.setFloat("tdiff", row, (float) tdiff); + + row++; + } + } + /*for(int i =0; i< listsize; i++) { + double x_rec = alltracks.get(k + double y_rec = params.get_YVec().get(i); + double z_rec = params.get_ZVec().get(i); + double time = params.get_time().get(i); + //System.out.println(params.get_time().size()); + bank.setInt("id", i, 1); + bank.setInt("cellID",i, params.get_PadNum().get(i)); + bank.setFloat("posX",i, (float) x_rec); + bank.setFloat("posY",i, (float) y_rec); + bank.setFloat("posZ",i, (float) z_rec); + //bank.setDouble("Edep",i, hitlist.get(i).get_Edep()); + bank.setFloat("time", i, (float) time); + + + }*/ + + return bank; + + } + + + +} \ No newline at end of file diff --git a/reconstruction/src/main/java/org/jlab/rec/rtpc/banks/package.html b/reconstruction/src/main/java/org/jlab/rec/rtpc/banks/package.html new file mode 100644 index 0000000000..61a4c9b57d --- /dev/null +++ b/reconstruction/src/main/java/org/jlab/rec/rtpc/banks/package.html @@ -0,0 +1,14 @@ + + + + + +org.jlab.rec.rtpc.banks + + +
Author:
ziegler
+ + \ No newline at end of file diff --git a/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/HelixFitJava.java b/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/HelixFitJava.java new file mode 100644 index 0000000000..0590eeb085 --- /dev/null +++ b/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/HelixFitJava.java @@ -0,0 +1,824 @@ +package org.jlab.rec.rtpc.hit; + +public class HelixFitJava { + + void rwsmav(double r[], double a[], double v[], int n) + { + // Author: Martin Poppe. r[n] = a[n,n]*v[n] + + int i, k, ind; + // Address in triangular matrix, row ii, column kk + for(i=1; i<=n; i++) + { + r[i-1] = 0; + for(k=1; k<=n; k++) + { + if (i >= k) { ind = (i*i-i)/2 + k; r[i-1] += a[ind-1]*v[k-1];} + else { ind = (k*k-k)/2 + i; r[i-1] += a[ind-1]*v[k-1];} + } + } + + } // End of void rwsmav(...) + + void rwsmin(double v[], double b[], int n, int m, int nrank) + { + // Author: V. Blobel + + // Obtain solution of linear equations V*X = B with symmetric matrix V + // and inverse (for m=1) or matrix inversion only (for m=0). + + // V = Symmetric n-by-n matrix in symmetric storage mode + // V(1) = V11, V(2) = V12, V(3) = V22, V(4) = V13, ... + // replaced by inverse matrix + // B = n-vector (for m=0 use a dummy argument) + // replaced by a solution vector + // m = see above + + // Method of solution is by elimination selecting the pivot point on the + // diagonal each stage. The rank of the matrix is returned in nrank. + + // For nrank != n, all remaining rows and columns of the resulting matrix + // V and the corresponding elements of B are set to zero. + + + double EPSS = (double)1.0E-6; + + int i, ii, ni, k=0, kk, j, jj, jl, jk, lk, l, ij; + double vkk, d, e; /* variable 'c' in original fortran file is not used */ + double[][] dr = new double[2][200]; + + // -------- Construct table ----------- + for(i=1; i<=n; i++) dr[0][i-1] = 1; + ni = n; + ii = 0; + for(i=1; i<=n; i++) { ii += i; dr[1][i-1] = Math.abs(v[ii-1]); } + + + // --------- Loop begins ---------- + nrank = n - ni; + + for (i=1; i<=ni; i++) + { + // --- Search for pivot and test for linearity and zero matrix + k = kk = jj = 0; vkk = 0; + for (j=1; j<=n; j++) + { + jj += j; + if (dr[0][j-1] == 0) break; + if (Math.abs(v[jj-1]) <= vkk) break; + if (Math.abs(v[jj-1]) < EPSS*dr[1][j-1]) break; + vkk = Math.abs(v[jj-1]); + k=j; kk=jj; + } + if (k == 0) {break;} + + // --- Preparation for elimination --- + nrank = nrank + 1; + dr[0][k-1] = 0; + d = 1/v[kk-1]; + v[kk-1] = -d; + if (m == 1) b[k-1] *= d; + jk = kk-k; + jl = 0; + + // --- Elimination --- + for (j=1; j<=n; j++) + { + if( j-k < 0 ) jk++; + else { + if ( j-k == 0) {jk = kk; jl += j; break;} + else jk = jk +j -1; + } + + + e = v[jk-1]; + v[jk-1] = d*e; + + if (m==1) b[j-1] -= b[k-1]*e; + lk = kk-k; + for (l=1; l<=j; l++) + { + jl++; + if(l-k < 0) lk++; + else { if (l==k) {lk=kk; break;} + else lk=lk + l - 1; + } + + v[jl-1] -= v[lk-1]*e; + } + } // End of loop over j + } // End of loop over i + + if(k != 0) { + // ----------- Change sign -------------- + ij=0; + for (i=1; i<=n; i++) { + for (j=1; j<=i; j++) + { + ij++; v[ij-1] = -v[ij-1]; + } + } + return; + + } + // --------- Clear rest of the matrix ------------- + + ij=0; + for (i=1; i<=n; i++) + { + if(m == 1 && dr[0][i-1] != 0) b[i-1]=0; + for (j=1; j<=i; j++) + { + ij++; + if (dr[0][i-1] + dr[0][j-1] != 0) v[ij-1]=0; + v[ij-1] = -v[ij-1]; + } + } + + return; + } // End of void rwsmin(double v[], double b[], int n, int m, int* nrank + + + + + //------------------------------------------------------------------------- + void rwfthc(int npt, double rf[], + double pf[], double wfi[], + double zf[], double wzf[], + int iopt, + + double vv0[], double ee0[], double ch2ph, double ch2z, + double del[], double delz[]) + + + // ----- Function for fast helix fit. ----- + + // A generalization of the TFTHEL routine to allow it to be called from a + // routine that contains any list of x and y values xf,yf for a set of npt + // points to be fitted. + + // ----- Input: ----- + + // npt: Number of 3-D points to be fit + // xf[]: Array of X-values of points to be fit + // yf[]: Array of Y-values of points to be fit + // rf[]: Array of R-values of points to be fit + // pf[]: Array of PHI-values of points to be fit + // wfi[]: Array of 1/(sig(rphi))**2 for each point + // zf[]: Array of Z-values of points to be fit + // wzf[]: Array of 1/(sig(z))**2 for each point + // iopt: 0 -> Distance**2 =x**2 +y**2 minimized; + // 1 -> Weighted with 1/SIMA(R*PHI)**2 + // 2 -> Error matrix calculated + // 3 -> 3-Dimensional iteration + + // ----- Output: ----- + + // vv0[5]: [0] = 1/r*charge, positive if clockwise; + // [1] = tan(lambda) { = dz/ds} tan(angle to (X,Y) PLANE); + // [2] = phi0 {0, 2*PI} angle to X-axis at r=d0; + // [3] = d0*sign [cm] minimal distance to Z-axis, + // +ve if axis encircled; + // [4] = z0 [cm] z position at r=d0; + // ee0[15]: Inverse of error matrix in triangular form; + // ch2ph: chi squared = Sum(phi deviations / errors)^2; + // ch2z: chi squared = Sum(z deviations / errors)^2; + // del: Unknown; + // delz: Unknown. + + // Note that the number of degrees of freedom = 2*npt-5 + + // Based on subroutine CIRCLE. + // Reference: "Computer Physics Communications", Volume 33, P. 329 + // Authors: N. Chernov, G. Ososkov and M. Poppe + + // Modified by Fred Weber, 8 Jun 1989. + // Translated into C by Michael Ispiryan, 2006 + + + { + int ITMAX = 15; + int IOWRIT = 6; + double EPS = (double)1.0e-16; + double ONEPI = (double)3.1415927; + double PI = (double)3.1415927; + double TWOPI = (double)6.2831854; + double PIBY2 = (double)1.57074635; + int MAX_HITS_ON_CHAIN = 200; + + double[] sp2 = new double[MAX_HITS_ON_CHAIN], vv1 = new double[5]; + double[] sxy = new double[MAX_HITS_ON_CHAIN], ss0 = new double[MAX_HITS_ON_CHAIN]; + double[] eee = new double[MAX_HITS_ON_CHAIN]; + double[] grad = new double[5], cov= new double[15], dv= new double[5]; + double[] deln = new double[MAX_HITS_ON_CHAIN], delzn = new double[MAX_HITS_ON_CHAIN]; + + double[] xf = new double[MAX_HITS_ON_CHAIN], yf= new double[MAX_HITS_ON_CHAIN], wf= new double[MAX_HITS_ON_CHAIN]; + + double alf, a0, a1, a2, a22, bet, cur, dd, den; + double det, dy, d2, f, fact, fg, f1, g, gam, gam0; + double g1, h, h2, p2, q2, rm, rn, xa, xb = 0, xd, xi; + double xm, xx, xy, x1, x2, den2, ya, yb, yd, yi, ym; + double yy, y1, y2, wn, sa2b2, dd0, phic; + + int i, n, iter, nrank= 0; + + double chi2_here, rr0, asym, sst, ph0, check; + double aa0, ome, gg0, hh0, ff0, sums, sumss, sumz, sumsz, sumw; + double denom, dzds_here, zz0, eta, dfd, dfo, dpd, dpo, ggg, dza; + double dzd, dzo, chi1; + + //nkb added these variables for the recalculation of dz/ds + double kangle, my_phi, xc, yc, xdca; + double ydca, xbar, ybar, xpt, ypt, alpha, beta; + if (npt <= 2) + { + System.out.println("BonusHelixFit::rwfthc(): Cannot fit less than 3 points; exiting..\n"); + return; + } + if (npt > MAX_HITS_ON_CHAIN) + { + System.out.println("BonusHelixFit::rwfthc(): Cannot fit more than " + MAX_HITS_ON_CHAIN + " points; exiting..\n" ); + return; + } + for(i=0; i= ITMAX) break; + dy = a1 + xa*(a22 + xa*(4.0*xa - 12.0)); + xb = xa - ya/dy; + if (Math.abs(ya) > Math.abs(yb)) xb = 0.5*(xb+xa); + if (Math.abs(xa-xb) < EPS) break; + xa = xb; yb = ya; iter++; + } + + gam = gam0*xb; + f1 = f - gam; + g1 = g - gam; + x1 = xd*g1 - yd*h; + y1 = yd*f1 - xd*h; + det = f1*g1 - h2; den2 = 1.0/(x1*x1 + y1*y1 + gam*det*det); + if (den2 <= 0.0) {ch2ph = 1.0E+30; ch2z = 1.0E+30; return;} + den = Math.sqrt(den2); cur = det*den + 0.0000000001; + alf = -(xm*det + x1)*den; + bet = -(ym*det + y1)*den; + rm = xm*xm + ym*ym; + + // ------- Calculation of standard circle parameters. NB: cur is + // ------- always positive. + asym = bet*xm - alf*ym; + sst = 1.0; + if (asym<0.0) sst = -1.0; + rr0 = sst*cur; + if((alf*alf + bet*bet) <= 0.0) {ch2ph = 1.0E+30; ch2z = 1.0E+30; return;} + sa2b2 = 1.0/(Math.sqrt(alf*alf + bet*bet)); + dd0 = (1.0 - 1.0/sa2b2)/cur; + phic = Math.asin(alf*sa2b2) + PIBY2; + if (bet > 0.0) phic = TWOPI - phic; + ph0 = phic + PIBY2; + + if (rr0 <= 0.0) ph0 -= ONEPI; + if (ph0 > TWOPI) ph0 -= TWOPI; + if (ph0 < 0.0) ph0 += TWOPI; + + vv0[0]=rr0; vv0[2]=ph0; vv0[3]=dd0; + //printf("rr0,ph0,dd0 = %f %f %f\n",1/rr0,ph0,dd0); + check = sst*rr0*dd0; + if (check == 1.0) { dd0 -= 0.007; vv0[3] = dd0; } + + // ------- Calculate phi distances to measured points + aa0=sst; ome=rr0; gg0=ome*dd0-aa0; hh0=1.0/gg0; + for(i=0; i 1.0) ff0 = 1.0; + + del[i] = ph0 + (ss0[i]-aa0)*PIBY2 + ss0[i]*Math.asin(ff0) - pf[i]; + if (del[i] > ONEPI) del[i] -= TWOPI; + if (del[i] < -ONEPI) del[i] += TWOPI; + } + + + // -------- Fit straight line in S-Z + for(i=0; i 0.9999) + { + //quiet = FALSE; + //fprintf(stderr, "+Track circles too much for this code(eee=%f); bad dzds\n",eee[i]); + //badarg = TRUE;//break; + //printf("eee[%d] = %f\n",i,eee[i]); + eee[i] = 0.9999; + } + if (eee[i] < -0.9999) + { + //quiet = FALSE; + //fprintf(stderr, "-Track circles too much for this code(eee=%f); bad dzds\n",eee[i]); + //badarg = TRUE;//break; + //printf("eee[%d] = %f\n",i,eee[i]); + eee[i] = -0.9999; + } + + sxy[i] = 2.0*Math.asin(eee[i])/ome; + //printf("original sxy[%d] = %f\n",i,sxy[i]); + } + + //if(badarg) + { + /* + for(i=0; i2.0*PI) my_phi-=2.0*PI; + xc = -Math.sin(my_phi)*((-vv0[3])+Math.abs(1.0/vv0[0])); + yc = Math.cos(my_phi)*((-vv0[3])+Math.abs(1.0/vv0[0])); + xdca = -Math.sin(my_phi)*(-vv0[3]); + ydca = Math.cos(my_phi)*(-vv0[3]); + xbar = xdca - xc; + ybar = ydca - yc; + //printf("xdca= %.1f ydca= %.1f xc= %.1f yc= %.1f xbar= %.1f ybar= %.1f\n", + // xdca, ydca, xc, yc, xbar, ybar); + for(i=0; i 1.0) + { + //quiet = FALSE; + //printf("eee[%d] = %f, rad = %f, mydd = %f\n",i,eee[i],1/rr0,Math.sqrt(mydd)); + //getchar(); + } + sxy[i] = (1/(sst*rr0))*acos(eee[i]); + //printf("law of Math.cos sxy[%d] = %f\n",i,sxy[i]); + */ + //ksxy = sxy[i]; + xpt = xf[i] - xc; + ypt = yf[i] - yc; + alpha = Math.atan2(ypt,xpt); + beta = Math.atan2(ybar,xbar); //if(alpha > 2*PI)alpha -= 2*PI; + //if(alpha < 0) alpha += 2*PI; + //if(beta > 2*PI) beta -= 2*PI; + //if(beta < 0) beta += 2*PI; + //printf("alpha = %.2f beta = %.2f\n",alpha*180./PI,beta*180./PI); + sxy[i] = beta - alpha; + if(sxy[i] > PI) sxy[i] = sxy[i] - 2*PI; + if(sxy[i] < -PI)sxy[i] = sxy[i] + 2*PI; + //if(sxy[i] < 0) sxy[i] += 2*PI; + kangle = sxy[i]; + sxy[i] = (1/rr0)*sxy[i]; + + //printf("[%d] xf= %.1f yf= %.1f xpt= %.1f ypt= %.1f\n", + //i, xf[i], yf[i], xpt, ypt); + //HFILL(9916, ksxy - sxy[i], 0.0, 1.0); + //printf("%f\n",ksxy-sxy[i]); + } + + } + + + sums = 0.0; + sumss = 0.0; + sumz = 0.0; + sumsz = 0.0; + sumw = 0.0; + for(i=0; i= 0.0) denom = 1.0E-6; + else denom = -1.0E-6; + } + + dzds_here = (sumw*sumsz - sums*sumz) / denom; + zz0 = (sumss*sumz - sums*sumsz) / denom; + vv0[1] = dzds_here; vv0[4] = zz0; + + // --------- Calculation of chi**2 + for(i=0; i 0.9999) ff0 = 0.9999; + if (ff0 < -0.9999) ff0 = -0.9999; + eta = ss0[i] / Math.sqrt(Math.abs(1.0+ff0)*(1.0-ff0)); + dfd = (1.0 + hh0*hh0*(1.0-ome*ome*rf[i]*rf[i])) / (2.0*rf[i]); + dfo = -aa0*(rf[i]*rf[i] - dd0*dd0)*hh0*hh0 / (2.0*rf[i]); + dpd = eta*dfd; dpo = eta*dfo; + // --- Derivatives of z component + ggg = eee[i] / Math.sqrt(Math.abs( (1.0+eee[i])*(1.0-eee[i]))); + dza = sxy[i]; + check = rf[i]*rf[i] - vv0[3]*vv0[3]; + if (check == 0.0) check = 2.0*0.007; + dzd = 2.0*(vv0[1]/vv0[0]) * Math.abs(ggg) * (0.5*aa0*vv0[0] / + (1.0 - aa0*vv0[3]*vv0[0]) - vv0[3]/check); + dzo = -vv0[1]*sxy[i]/vv0[0] + vv0[1]*ggg/(vv0[0]*vv0[0]) * + (2.0 + aa0*vv0[0]*vv0[3]/(1.0 - aa0*vv0[0]*vv0[3])); + + // ---- Error matrix + ee0[0] += sp2[i]*dpo*dpo + wzf[i]*dzo*dzo; + ee0[1] += wzf[i]*dza*dzo; + ee0[2] += wzf[i]*dza*dza; + ee0[3] += sp2[i]*dpo; + ee0[5] += sp2[i]; + ee0[6] += sp2[i]*dpo*dpd + wzf[i]*dzo*dzd; + ee0[8] += sp2[i]*dpd; + ee0[9] += sp2[i]*dpd*dpd + wzf[i]*dzd*dzd; + ee0[10] += wzf[i]*dzo; + ee0[11] += wzf[i]*dza; + ee0[13] += wzf[i]*dzd; + ee0[14] += wzf[i]; + + // --- Gradient vector + grad[0] += -del[i]*sp2[i]*dpo - delz[i]*wzf[i]*dzo; + grad[1] += - delz[i]*wzf[i]*dza; + grad[2] += -del[i]*sp2[i]; + grad[3] += -del[i]*sp2[i]*dpd - delz[i]*wzf[i]*dzd; + grad[4] += - delz[i]*wzf[i]; + } // End of for(i...) + + + if (iopt < 3) return; + + + // --------------- Newton's next guess + for(i=0; i<15; i++) cov[i] = ee0[i]; + + rwsmin(cov, vv1, 5, 0, nrank); + rwsmav(dv, cov, grad, 5); + + for(i=0; i<5; i++) vv1[i] = vv0[i] + dv[i]; + + //------- New differences in phi and z + gg0 = vv1[0]*vv1[3] - aa0; + for(i=0; i 1.0) ff0 = 1.0; + if (ff0 < -1.0) ff0 = -1.0; + + deln[i] = vv1[2] + (ss0[i]-aa0)*PIBY2 + ss0[i]*Math.asin(ff0) - pf[i]; + if (deln[i] > ONEPI) deln[i] -= TWOPI; + if (deln[i] < -ONEPI) deln[i] += TWOPI; + eee[i] = 0.5*vv1[0]*Math.sqrt(Math.abs( (rf[i]*rf[i] - vv1[3]*vv1[3]) / + (1.0 - aa0*vv1[0]*vv1[3]) )); + if (eee[i] > 0.9999) eee[i] = 0.9999; + if (eee[i] < -0.9999) eee[i] = -0.9999; + sxy[i] = 2.0*Math.asin(eee[i]) / vv1[0]; + delzn[i] = vv1[4] + vv1[1]*sxy[i] - zf[i]; + } + + // ---------- Calculation of chi**2 + chi1 = ch2ph = ch2z = 0.0; + for(i=0; i24.0) R=24.; + if(R<1.5) R=1.5; + double Para_dPhiVsR[] = {0.753136, -0.391614, 0.0836029, -0.00944999, + 0.000611348, -2.26783e-05, 4.47764e-07, -3.64278e-09}; + double dPhi = Para_dPhiVsR[0]; + for(int i=1;i<=7;i++) dPhi += Para_dPhiVsR[i]*Math.pow(R,i); + Phi = Phi - dPhi; + //apply 2nd correction if R<5.5 cm + if(R<5.5) { + double Para_dPhiVsR_2nd[] = {11.0937, -17.3801, 11.0492, -3.65267, + 0.663338, -0.0628701, 0.00243461}; + double dPhi_2nd = Para_dPhiVsR_2nd[0]; + for(int i=1;i<=6;i++) dPhi_2nd += Para_dPhiVsR_2nd[i]*Math.pow(R,i); + Phi = Phi - dPhi_2nd; + } + + return; + + /****************************************** + r_hel-rho_1st:r_hel, only good for 1.014.5) R=14.5; + if(R<14.50001) { + double Para_dRVsR[] = { 8.2822, -8.35421, 3.32568, -0.685895, 0.0797764, + -0.00527024, 0.000184178, -2.64062e-06}; + double dR = Para_dRVsR[0]; + for(int i=1;i<=7;i++) dR += Para_dRVsR[i]*Math.pow(R,i); + R = R - dR; + Rho = (Rho<0)? -R : R;*/ + //std::cout<<"\t\t dR="<arg0._cellID) { + return 1; + } else { + return 0; + } + } + + +} diff --git a/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/HitDistance.java b/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/HitDistance.java new file mode 100644 index 0000000000..1dd2b5f470 --- /dev/null +++ b/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/HitDistance.java @@ -0,0 +1,128 @@ +package org.jlab.rec.rtpc.hit; + +import java.util.HashMap; +import java.util.concurrent.ConcurrentHashMap; +import java.util.Vector; + +import javax.swing.JFrame; + +import org.jlab.clas.physics.Vector3; +import org.jlab.groot.data.H1F; +import org.jlab.groot.graphics.EmbeddedCanvas; + +public class HitDistance { + + public void FindDistance(HitParameters params) { + HashMap ADCMap = params.get_R_adc(); + Vector PadNum = params.get_PadNum(); + int Pad = 0; //initializing pad + int Pad2 = 0; + int TrigWindSize = params.get_TrigWindSize(); //Trigger Window Size = 10000 + //int StepSize = params.get_StepSize(); + int StepSize = 120; //Time stepsize + double thresh = 1e-5; //Arbitrary ADC threshold + double ADC = 0; + double ADC2 = 0; + Vector3 TempPadCoords = new Vector3(); + Vector3 CheckPadCoords = new Vector3(); + Vector3 CheckPadPrevCoords = new Vector3(); + EmbeddedCanvas c1 = new EmbeddedCanvas(); + EmbeddedCanvas c2 = new EmbeddedCanvas(); + EmbeddedCanvas c3 = new EmbeddedCanvas(); + H1F t1 = new H1F("t1","t1",100,0,50); + H1F t2 = new H1F("t2","t2",100,0,8); + H1F t3 = new H1F("t3","t3",100,0,10); + t1.setTitleX("xy in mm"); + t2.setTitleX("z in mm"); + t3.setTitleX("ellipse formula result"); + JFrame j1 = new JFrame(); + j1.setSize(800,600); + j1.setTitle("xy"); + JFrame j2 = new JFrame(); + j2.setSize(800,600); + j2.setTitle("z"); + JFrame j3 = new JFrame(); + j3.setSize(800,600); + j3.setTitle("ellipse"); + double EllipseDeltax = 0; + double EllipseDeltay = 0; + double EllipseDeltaz = 0; + double EllipseTotal = 0; + double PhiDelta = Math.pow(3, 2); + double ZDelta = Math.pow(6, 2); + for(int t = 0; t < TrigWindSize; t+=StepSize) + { + for(int p = 0; p < PadNum.size(); p ++) + { + Pad = PadNum.get(p); + ADC = ADCMap.get(Pad)[t]; + if(ADC > thresh) + { + Vector3 PadCoords = PadCoords(Pad); + for(int p2 = 0; p2 < PadNum.size(); p2++) + { + if(p2 != p) + { + Pad2 = PadNum.get(p2); + ADC2 = ADCMap.get(Pad2)[t]; + if(ADC2 > thresh) + { + CheckPadCoords = PadCoords(Pad2); + EllipseDeltax = Math.pow(Math.abs(PadCoords.x()-CheckPadCoords.x()),2); + EllipseDeltay = Math.pow(Math.abs(PadCoords.y()-CheckPadCoords.y()),2); + EllipseDeltaz = Math.pow(Math.abs(PadCoords.z()-CheckPadCoords.z()),2); + EllipseTotal = ((EllipseDeltax+EllipseDeltay)/PhiDelta) + (EllipseDeltaz/ZDelta); + t1.fill(Math.sqrt(EllipseDeltax+EllipseDeltay)); + t2.fill(Math.sqrt(EllipseDeltaz)); + t3.fill(EllipseTotal); + } + } + } + } + } + } + c1.draw(t1); + c2.draw(t2); + c3.draw(t3); + j1.add(c1); + j2.add(c2); + j3.add(c3); + j1.setVisible(true); + j2.setVisible(true); + j3.setVisible(true); + } + private Vector3 PadCoords(int cellID) { + + double PAD_W = 2.79; // in mm + double PAD_S = 80.0; //in mm + double PAD_L = 4.0; // in mm + double RTPC_L=384.0; // in mm + double phi_pad = 0; + //double Num_of_Rows = (2.0*(Math.PI)*PAD_S)/PAD_W; + double Num_of_Cols = RTPC_L/PAD_L; + double PI=Math.PI; + double z0 = -(RTPC_L/2.0); + double phi_per_pad = PAD_W/PAD_S; // in rad + double chan = (double)cellID; + double col = chan%Num_of_Cols; + double row=(chan-col)/Num_of_Cols; + double z_shift = row%4; + + phi_pad=(row*phi_per_pad)+(phi_per_pad/2.0); + + if(phi_pad>= 2.0*PI) + { + phi_pad -= 2.0*PI; + } + if(phi_pad<0) + { + phi_pad += 2.0*PI; + } + + double z_pad=z0+(col*PAD_L)+(PAD_L/2.0)+z_shift; + + Vector3 PadCoords = new Vector3(PAD_S*Math.cos(phi_pad),PAD_S*Math.sin(phi_pad),z_pad); + return PadCoords; + + } +} diff --git a/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/HitParameters.java b/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/HitParameters.java new file mode 100644 index 0000000000..dc2144ff9f --- /dev/null +++ b/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/HitParameters.java @@ -0,0 +1,105 @@ +package org.jlab.rec.rtpc.hit; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Vector; +import java.util.concurrent.ConcurrentHashMap; + +import org.jlab.clas.physics.LorentzVector; +import org.jlab.clas.physics.Vector3; + +public class HitParameters { + + private int _StepSize = 10; + private int _BinSize = 40; + private int _NBinKept = 3; + private int _TrigWindSize = 10000; + private int _eventnum = 0; + private HashMap _R_adc = new HashMap(); + private HashMap> _TimeMap = new HashMap>(); + private HashMap> _FinalTIDMap = new HashMap>(); + private Vector _PadN = new Vector(); // used to read only cell with signal, one entry for each hit + private Vector _PadNum = new Vector();// used to read only cell with signal, one entry for each cell + private Vector _Pad = new Vector(); + private Vector _ADC = new Vector(); + private Vector _Time_o = new Vector(); + private Vector _weightave = new Vector(); + private Vector _maxinte = new Vector(); + private Vector _time = new Vector(); + private Vector _XVec = new Vector(); + private Vector _YVec = new Vector(); + private Vector _ZVec = new Vector(); + private HashMap>> _TIDMap = new HashMap>>(); + private HashMap>> _strkTIDMap = new HashMap>>(); + private HashMap> _alltracks = new HashMap>(); + private HashMap _largetmap = new HashMap(); + private HashMap> _recohitvector = new HashMap>(); + private HashMap _padmap = new HashMap(); + private TrackMap _trackmap = new TrackMap(); + private ReducedTrackMap _rtrackmap = new ReducedTrackMap(); + + public int get_StepSize(){return _StepSize;} // step size of the signal before integration (arbitrary value) + public int get_BinSize(){return _BinSize;} // electronics integrates the signal over 40 ns + public int get_NBinKept(){return _NBinKept;} // only 1 bin over 3 is kept by the daq + public int get_TrigWindSize(){return _TrigWindSize;} // Trigger window should be 10 micro + public HashMap get_R_adc(){return _R_adc;} + public HashMap> get_TimeMap(){return _TimeMap;} + public Vector get_PadN(){return _PadN;} + public Vector get_PadNum(){return _PadNum;} + public Vector get_Pad(){return _Pad;} + public Vector get_ADC(){return _ADC;} + public Vector get_Time_o(){return _Time_o;} + public int get_eventnum(){return _eventnum;} + public Vector get_weightave() {return _weightave;} + public Vector get_maxinte() {return _maxinte;} + public Vector get_time() {return _time;} + public Vector get_XVec() {return _XVec;} + public Vector get_YVec() {return _YVec;} + public Vector get_ZVec() {return _ZVec;} + public HashMap>> get_TIDMap() {return _TIDMap;} + public HashMap>> get_strkTIDMap() {return _strkTIDMap;} + public HashMap> get_FinalTIDMap() {return _FinalTIDMap;} + public HashMap> get_alltracks() {return _alltracks;} + public HashMap get_largetmap() {return _largetmap;} + public HashMap> get_recohitvector() {return _recohitvector;} + public TrackMap get_trackmap() {return _trackmap;} + public ReducedTrackMap get_rtrackmap() {return _rtrackmap;} + public PadVector get_padvector(int pad) { + if(!_padmap.containsKey(pad)) { + _padmap.put(pad, new PadVector(pad)); + } + return _padmap.get(pad); + } + + + public void set_R_adc(HashMap _R_adc){this._R_adc = _R_adc;} + public void set_TimeMap(HashMap> _TimeMap){this._TimeMap = _TimeMap;} + public void set_PadN(Vector _PadN){this._PadN = _PadN;} + public void set_PadNum(Vector _PadNum){this._PadNum = _PadNum;} + public void set_Pad(Vector _Pad){this._Pad = _Pad;} + public void set_ADC(Vector _ADC){this._ADC = _ADC;} + public void set_Time_o(Vector _Time_o){this._Time_o = _Time_o;} + public void set_eventnum(int _eventnum){this._eventnum = _eventnum;} + public void set_weightave(Vector _weightave) {this._weightave = _weightave;} + public void set_maxinte(Vector _maxinte) {this._maxinte = _maxinte;} + public void set_time(Vector _time) {this._time = _time;} + public void set_XVec(Vector _XVec) {this._XVec = _XVec;} + public void set_YVec(Vector _YVec) {this._YVec = _YVec;} + public void set_ZVec(Vector _ZVec) {this._ZVec = _ZVec;} + public void set_TIDMap(HashMap>> _TIDMap) {this._TIDMap = _TIDMap;} + public void set_strkTIDMap(HashMap>> _strkTIDMap) {this._strkTIDMap = _strkTIDMap;} + public void set_FinalTimeMap(HashMap> _finalTIDMap){this._FinalTIDMap = _finalTIDMap;} + public void set_alltracks(HashMap> _alltracks) {this._alltracks = _alltracks;} + public void set_largetmap(HashMap _largetmap) {this._largetmap = _largetmap;} + public void set_recohitvector(HashMap> _recohitvector) {this._recohitvector = _recohitvector;} + public void set_trackmap(TrackMap _trackmap) {this._trackmap = _trackmap;} + public void set_rtrackmap(ReducedTrackMap _rtrackmap) {this._rtrackmap = _rtrackmap;} + + public HitParameters() {} + + private static HitParameters INSTANCE = new HitParameters(); + + public static HitParameters getInstance() { + return HitParameters.INSTANCE; +} +} \ No newline at end of file diff --git a/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/HitReconstruction.java b/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/HitReconstruction.java new file mode 100644 index 0000000000..c584416380 --- /dev/null +++ b/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/HitReconstruction.java @@ -0,0 +1,204 @@ +package org.jlab.rec.rtpc.hit; + +import java.util.List; +import java.util.Vector; + +public class HitReconstruction { + + public HitReconstruction() { + // TODO Auto-generated constructor stub + } + + public void Reco(HitParameters params) { + Vector PadNum = params.get_PadNum(); + Vector weightave = params.get_weightave(); + Vector maxinte = params.get_maxinte(); + Vector TimeVec = new Vector(); + Vector XVec = new Vector(); + Vector YVec = new Vector(); + Vector ZVec = new Vector(); + int p = 0; + //for(Hit hit : rawHits) { + for(p = 0; p= 2.0*PI) { + phi_pad -= 2.0*PI; + } + if(phi_pad<0) + { + phi_pad += 2.0*PI; + } + + z_pad=z0+(col*PAD_L)+(PAD_L/2.0)+z_shift; + // ----------------------------------------------------------------------- + + + // find reconstructed position of ionization from Time info + + t_s2pad = Time-t_gap; + + r_rec=((-(Math.sqrt(a_t*a_t+(4.*b_t*t_s2pad)))+a_t+(14.*b_t))/(2.*b_t))*10.0; //in mm + + + dphi=a_phi*(7.-r_rec/10.)+b_phi*(7.-r_rec/10.)*(7.-r_rec/10.); // in rad + + + dz=0; + + phi_rec=phi_pad-dphi-phi_gap; + if( phi_rec<0.0 ) + { + phi_rec+=2.0*PI; + } + if( phi_rec>2.0*PI ) + { + phi_rec-=2.0*PI; + } + + // x,y,z pos of reconstructed track + x_rec=r_rec*(Math.cos(phi_rec)); + y_rec=r_rec*(Math.sin(phi_rec)); + z_rec=z_pad-dz; + + // x,y,z pos of pad hit + //x_pad=(PAD_S)*(Math.cos(phi_pad)); + //y_pad=(PAD_S)*(Math.sin(phi_pad)); + + // actual position on pad of hits + //phi_hit=phi_rad-(row*phi_per_pad); + //z_hit=Z-z0-(col*PAD_L)-z_shift; + + // find differences (delta = generated-reconstructed) + //delta_x=X-x_rec; + //delta_y=Y-y_rec; + //delta_z=Z-z_rec; + //delta_r=r_pos-r_rec; + //delta_phi = phi_pos-phi_rec; + + + + + /*hit.set_cellID(cellID); + hit.set_Time(t_s2pad); + hit.set_Edep(Edep); + hit.set_PosX(x_rec); + hit.set_PosY(y_rec); + hit.set_PosZ(z_rec);*/ + TimeVec.add(t_s2pad); + XVec.add(x_rec); + YVec.add(y_rec); + ZVec.add(z_rec); + + + + + } + params.set_time(TimeVec); + params.set_XVec(XVec); + params.set_YVec(YVec); + params.set_ZVec(ZVec); + //System.out.println(XVec.size() + " " + PadNum.size()); + //XVec.clear(); + //YVec.clear(); + //ZVec.clear(); + //TimeVec.clear(); + + } +} diff --git a/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/HitVector.java b/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/HitVector.java new file mode 100644 index 0000000000..4d32d82e14 --- /dev/null +++ b/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/HitVector.java @@ -0,0 +1,87 @@ +package org.jlab.rec.rtpc.hit; + +public class HitVector { + + private int pad; + private double z; + private double phi; + private double time; + private double adc; + + public HitVector() + { + pad = 0; + z = 0; + phi = 0; + time = 0; + adc = 0; + } + + public HitVector(int padnum, double hittime, double padadc) + { + pad = padnum; + z = 0; + phi = 0; + time = hittime; + adc = padadc; + } + + public HitVector(int padnum, double zpad, double phipad, double hittime, double padadc) + { + pad = padnum; + z = zpad; + phi = phipad; + time = hittime; + adc = padadc; + } + + public void setpad(int padnum) + { + pad = padnum; + } + + public void setz(double zpad) + { + z = zpad; + } + + public void setphi(double phipad) + { + phi = phipad; + } + + public void settime(double hittime) + { + time = hittime; + } + + public void setadc(double padadc) + { + adc = padadc; + } + + public int pad() + { + return pad; + } + + public double z() + { + return z; + } + + public double phi() + { + return phi; + } + + public double time() + { + return time; + } + + public double adc() + { + return adc; + } +} diff --git a/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/MapCombine.java b/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/MapCombine.java new file mode 100644 index 0000000000..35688c4ac9 --- /dev/null +++ b/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/MapCombine.java @@ -0,0 +1,281 @@ +package org.jlab.rec.rtpc.hit; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Vector; +import java.util.concurrent.ConcurrentHashMap; + +import javax.swing.JFrame; + +import org.jlab.clas.physics.LorentzVector; +import org.jlab.clas.physics.Vector3; +import org.jlab.groot.data.GraphErrors; +import org.jlab.groot.data.H2F; +import org.jlab.groot.graphics.EmbeddedCanvas; + +public class MapCombine { + + public void MC(HitParameters params, boolean draw) { + + HashMap> TAMap = params.get_FinalTIDMap(); + HashMap>> TFMap = params.get_strkTIDMap(); + HashMap ADCMap = params.get_R_adc(); + + Vector PadList = new Vector(); + double maxvalue = 0; + double thresh = 0; + int TrigWindSize = params.get_TrigWindSize(); + double sumnumer = 0; + double sumdenom = 0; + int count = 0; + int newtid = 0; + + HashMap weightave = new HashMap(); + HashMap weightaveadc = new HashMap(); + HashMap> trTFMap = new HashMap>(); + HashMap> alltracks = new HashMap>(); + HitVector vtmp = new HitVector(); + HitVector v3tmp = new HitVector(); + HitVector hitvec = new HitVector(); + Vector toListvec = new Vector(); + double larget = 0; + int countadcvalues = 0; + + /*GraphErrors g = new GraphErrors(); + EmbeddedCanvas c = new EmbeddedCanvas(); + JFrame jf = new JFrame(); + jf.setSize(800,600);*/ + //System.out.println(TIDMap.size()); + //for(Hit hit : rawHits) { + for(int TID : TFMap.keySet()){ + //System.out.println(" "); + larget = 0; + PadList.clear(); + weightave.clear(); + for(int time : TFMap.get(TID).keySet()) + { + for(int pad = 0; pad < TFMap.get(TID).get(time).size(); pad++) + { + //System.out.println(TID + " " + time + " " + TFMap.get(TID).get(time).get(pad)); + if(!PadList.contains(TFMap.get(TID).get(time).get(pad))) + { + PadList.add(TFMap.get(TID).get(time).get(pad)); + } + } + } + + for(int pad = 0; pad < PadList.size(); pad++) + { + for(int time : TFMap.get(TID).keySet()) + { + if(TFMap.get(TID).get(time).contains(PadList.get(pad))) + { + if(ADCMap.get(PadList.get(pad))[time]>maxvalue) + { + maxvalue = ADCMap.get(PadList.get(pad))[time]; + //System.out.println(maxvalue); + } + } + } + thresh = maxvalue/2; + for(int time = 0; time < TrigWindSize; time+=120) + { + if(ADCMap.get(PadList.get(pad))[time] > thresh) + { + sumnumer += ADCMap.get(PadList.get(pad))[time]*time; + sumdenom += ADCMap.get(PadList.get(pad))[time]; + countadcvalues++; + //System.out.println(PadList.get(pad) + " " + time); + } + } + if(sumnumer/sumdenom >= larget) + { + larget = sumnumer/sumdenom; + } + //System.out.println("weightave " + PadList.get(pad) + " " + sumnumer/sumdenom); + weightave.put(PadList.get(pad), sumnumer/sumdenom); + weightaveadc.put(PadList.get(pad), sumdenom); + sumnumer = 0; + sumdenom = 0; + maxvalue = 0; + countadcvalues = 0; + //padvec = PadCoords(PadList.get(pad)); + //gZvsT.addPoint(weightave.get(PadList.get(pad)), padvec.z(), 0, 0); + //gPhivsT.addPoint(weightave.get(PadList.get(pad)), Math.atan2(padvec.y(),padvec.x()),0,0); + } + + int pad = 0; + double avetime = 0; + double adc = 0; + trTFMap.put(TID,new Vector()); + for(int p = 0; p < PadList.size(); p++) + { + pad = PadList.get(p); + avetime = weightave.get(pad); + adc = weightaveadc.get(pad); + //LorentzVector v = new LorentzVector(avetime,Math.atan2(PadCoords(pad).y(),PadCoords(pad).x()),PadCoords(pad).z(),pad); + HitVector v = new HitVector(pad,PadCoords(pad).z(),Math.atan2(PadCoords(pad).y(),PadCoords(pad).x()),avetime,adc); + + trTFMap.get(TID).add(v); + } + + + //trTFMap.put(TID, new HashMap()); + //trTFMap.get(TID).putAll(weightave); + + //System.out.println(" "); + } + for(int choosetid : trTFMap.keySet()) { + double smalltime = 0; + for(int i = 0; i < trTFMap.get(choosetid).size(); i++) + { + smalltime = trTFMap.get(choosetid).get(i).time(); + for(int j = 0; j < trTFMap.get(choosetid).size();j++) + { + if(trTFMap.get(choosetid).get(j).time() < smalltime && i!=j) + { + trTFMap.get(choosetid).insertElementAt(trTFMap.get(choosetid).get(i), j); + trTFMap.get(choosetid).remove(i+1); + break; + } + } + } + } + + for(int i : TAMap.keySet()) + { + //toListvec.clear(); + alltracks.put(newtid, new Vector()); + for(int j = 0; j < TAMap.get(i).size(); j++) + { + vtmp = TAMap.get(i).get(j); + //v3tmp = new Vector3(vtmp.pad(),vtmp.time(),0); + //System.out.println(vtmp.e() + " " + vtmp.px()); + //System.out.println(v3tmp.x() + " " + v3tmp.y()); + //toListvec.add(v3tmp); + alltracks.get(newtid).add(vtmp); + } + //System.out.println(toListvec.size()); + //System.out.println(" "); + //alltracks.put(newtid, toListvec); + + newtid++; + + } + toListvec.clear(); + //System.out.println(" "); + for(int i : trTFMap.keySet()) + { + //System.out.println(" "); + //toListvec.clear(); + alltracks.put(newtid, new Vector()); + //for(int pad : trTFMap.get(i).keySet()) + for(int j = 0; j < trTFMap.get(i).size(); j++) + { + v3tmp = trTFMap.get(i).get(j); + //System.out.println(pad); + //v3tmp = new HitVector(pad,trTFMap.get(i).get(pad),0); + //System.out.println(v3tmp.x() + " " + v3tmp.y()); + //toListvec.add(v3tmp); + alltracks.get(newtid).add(v3tmp); + } + //System.out.println(" "); + //System.out.println(toListvec.size()); + //alltracks.put(newtid, toListvec); + newtid++; + } + HashMap largetmap = new HashMap(); + larget = 0; + HashMap histmap = new HashMap(); + HashMap canvasmap = new HashMap(); + HashMap framemap = new HashMap(); + //H2F adcvst = new H2F("adcvst",500,3000,12000,500,0,10); + //System.out.println(" "); + Vector marktid = new Vector(); + for(int i : alltracks.keySet()) + { + larget = 0; + /*if(alltracks.get(i).size() < 6) { + System.out.println("removed track with " + alltracks.get(i).size() + " hits"); + marktid.add(i); + continue; + }*/ + histmap.put(i, new GraphErrors()); + //System.out.println(i); + for(int j = 0; j < alltracks.get(i).size(); j++) + { + //if(j < 3) {g.addPoint(alltracks.get(i).get(j).y(), y, 0, 0); + //System.out.println(i + " " + alltracks.get(i).get(j).time() + " " + alltracks.get(i).get(j).adc()); + histmap.get(i).addPoint(alltracks.get(i).get(j).time(), alltracks.get(i).get(j).adc(),0,0); + if(alltracks.get(i).get(j).time() > larget) + { + larget = alltracks.get(i).get(j).time(); + + } + } + canvasmap.put(i, new EmbeddedCanvas()); + canvasmap.get(i).draw(histmap.get(i)); + framemap.put(i, new JFrame()); + framemap.get(i).setSize(800, 600); + framemap.get(i).add(canvasmap.get(i)); + if(draw) framemap.get(i).setVisible(true); + largetmap.put(i, larget); + //System.out.println(" "); + } + /*for(int i = 0; i < marktid.size(); i++) { + alltracks.remove(i); + }*/ + for(int z : canvasmap.keySet()) { + //canvasmap.get(z).save(z + ".png"); + } + EmbeddedCanvas c_adcvst = new EmbeddedCanvas(); + c_adcvst.draw(histmap.get(0)); + if(draw) { + JFrame j_adcvst = new JFrame(); + j_adcvst.setSize(800, 600); + j_adcvst.add(c_adcvst); + j_adcvst.setVisible(true); + } + + //System.out.println("There are " + alltracks.size() + " tracks sorted in this event!"); + params.set_alltracks(alltracks); + params.set_largetmap(largetmap); + } + + private Vector3 PadCoords(int cellID) { + + double PAD_W = 2.79; // in mm + double PAD_S = 80.0; //in mm + double PAD_L = 4.0; // in mm + double RTPC_L= 384.0; // in mm + double phi_pad = 0; + //double Num_of_Rows = (2.0*(Math.PI)*PAD_S)/PAD_W; + double Num_of_Cols = RTPC_L/PAD_L; + double PI=Math.PI; + double z0 = -(RTPC_L/2.0); + double phi_per_pad = PAD_W/PAD_S; // in rad + double chan = (double)cellID; + double col = chan%Num_of_Cols; + double row=(chan-col)/Num_of_Cols; + double z_shift = row%4; + + phi_pad=(row*phi_per_pad)+(phi_per_pad/2.0); + + if(phi_pad>= 2.0*PI) + { + phi_pad -= 2.0*PI; + } + if(phi_pad<0) + { + phi_pad += 2.0*PI; + } + + double z_pad=z0+(col*PAD_L)+(PAD_L/2.0)+z_shift; + + Vector3 PadCoords = new Vector3(PAD_S*Math.cos(phi_pad),PAD_S*Math.sin(phi_pad),z_pad); + return PadCoords; + + } + + +} diff --git a/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/PadAve.java b/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/PadAve.java new file mode 100644 index 0000000000..79f5d80b13 --- /dev/null +++ b/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/PadAve.java @@ -0,0 +1,99 @@ +package org.jlab.rec.rtpc.hit; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.util.concurrent.ConcurrentHashMap; +import java.util.HashMap; +import java.util.Vector; + +public class PadAve { + public void TimeAverage(HitParameters params){ + + int StepSize = params.get_StepSize(); // step size of the signal before integration (arbitrary value) + int BinSize = params.get_BinSize(); // electronics integrates the signal over 40 ns + int NBinKept = params.get_NBinKept(); // only 1 bin over 3 is kept by the daq + int TrigWindSize = params.get_TrigWindSize(); // Trigger window should be 10 micro + int NTrigSampl = TrigWindSize/BinSize; // number of time samples + double inte=0; + double inte_tot; // integral of the signal in BinSize + double max_inte=0; // maximum of the integral to help the fit + double max_t=0; + double sumnumer = 0; + double sumdenom = 0; + double weightave = 0; + double timesum = 0; + HashMap R_adc = params.get_R_adc(); + HashMap> TimeMap = params.get_TimeMap(); + Vector PadNum = params.get_PadNum(); + Vector PadN = params.get_PadN(); + Vector Pad = params.get_Pad(); + Vector ADC = params.get_ADC(); + Vector Time_o = params.get_Time_o(); + Vector weightavevec = new Vector(); + Vector maxinte = new Vector(); + boolean flag_event = false; + int eventnum = params.get_eventnum(); + //try{ + //FileWriter write2 = new FileWriter("/Users/davidpayette/Documents/FileOutput/Output.txt",true); + //write2.write("Event Number" + "\t" + "Pad Number" + "\t" + "Time Value for each bin" + "\t" + "ADC value for each bin" + "\r\n"); + + + inte=0; + for(int p=0;p0) inte+=0.5*(R_adc.get(PadNum.get(p))[t-StepSize]+R_adc.get(PadNum.get(p))[t])*StepSize; + inte_tot+=inte; + if(t%BinSize==0 && t>0){ // integration over BinSize + if(t%(BinSize*NBinKept)==0){ // one BinSize over NBinKept is read out, hence added to the histogram + if(max_inte R_adc = params.get_R_adc(); + HashMap Adcmap = new HashMap(); + Vector PadNum = params.get_PadNum(); + Vector PadN = params.get_PadN(); + Vector Pad = params.get_Pad(); + Vector ADC = params.get_ADC(); + Vector Time_o = params.get_Time_o(); + boolean flag_event = false; + int eventnum = params.get_eventnum(); + + /*JFrame j1 = new JFrame(); + GraphErrors g1 = new GraphErrors(); + g1.setMarkerSize(0); + g1.setTitleX("Time(ns)"); + g1.setTitleY("ADC"); + g1.setMarkerSize(3); + EmbeddedCanvas c1 = new EmbeddedCanvas(); + j1.setSize(800, 600); + */ + + + //F1D f1 = new F1D("f1", "[amp]*gaus(x,[mean],[sigma])",0,1); + + inte=0; + for(int p=0;p0) inte+=0.5*(R_adc.get(PadNum.get(p))[t-StepSize]+R_adc.get(PadNum.get(p))[t])*StepSize; + + inte_tot+=inte; + if(t%BinSize==0 && t>0){ // integration over BinSize + if(t%(BinSize*NBinKept)==0){ // one BinSize over NBinKept is read out, hence added to the histogram + + Adcmap.get(PadNum.get(p))[t] = inte; + + //g1.addPoint(t,inte,0,0); + if(max_inte rawHits, HitParameters params){ + + +//______________________________________________________________________________________________ +// __________________________________________ Variables _________________________________________ +//______________________________________________________________________________________________ + + int StepSize = params.get_StepSize(); // step size of the signal before integration (arbitrary value) + int BinSize = params.get_BinSize(); // electronics integrates the signal over 40 ns + int NBinKept = params.get_NBinKept(); // only 1 bin over 3 is kept by the daq + int TrigWindSize = params.get_TrigWindSize(); // Trigger window should be 10 micro + int NTrigSampl = TrigWindSize/BinSize; // number of time samples + + HashMap R_adc = params.get_R_adc();// Raw depositions for CellID, ADC + HashMap> TimeMap = params.get_TimeMap(); + + Vector PadN = params.get_PadN(); // used to read only cell with signal, one entry for each hit + //Vector PadNum = params.get_PadNum();// used to read only cell with signal, one entry for each cell + Vector PadNum = new Vector(); + Vector ADC = new Vector(); + + Vector Pad = params.get_Pad(); + //Vector ADC = params.get_ADC(); + Vector Time_o = params.get_Time_o(); + + + + +//______________________________________________________________________________________________ +// __________________________________________ Openings __________________________________________ +//______________________________________________________________________________________________ + + int CellID = 0; + double Time; + double totEdep; + int eventnum = params.get_eventnum(); + eventnum++; + double testsum = 0; + double testcount = 1; + +//______________________________________________________________________________________________ +// __________________________________________ Readings __________________________________________ +//______________________________________________________________________________________________ + +//--Creating the signal on pads with 1 ns steps. + + + // Initializations + R_adc.clear(); // Raw depositions for CellID, adc + PadN.clear(); + PadNum.clear(); + + //Pad->clear(); + //ADC->clear(); // not reliable for now as the fit fails often + //Time_o->clear(); + + //HashMap gmap = new HashMap(); + + for(Hit hit : rawHits){ + + CellID = hit.get_cellID(); + Time = hit.get_Time(); + totEdep = hit.get_EdepTrue(); + + /*try { + + File out = new File("/Users/dpaye001/Desktop/FileOutput/event" + eventnum + "/"); + if(!out.exists()) + {out.mkdirs();} + FileWriter write = new FileWriter("/Users/dpaye001/Desktop/FileOutput/event" + eventnum + "/" + "timetrue.xls",true); + write.write(Time + "\t" + CellID + "\r\n"); + write.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + }*/ + + // searches in PadN if CellID already exists + + if(PadN.contains(CellID)){ // this pad has already seen signal + for(int t=0;t()); + TimeMap.get(CellID).add(Time); + for(int t=0;t= 2.0*PI) + { + phi_pad -= 2.0*PI; + } + if(phi_pad<0) + { + phi_pad += 2.0*PI; + } + + z_pad=z0+(col*PAD_L)+(PAD_L/2.0)+z_shift; + + set_x(PAD_S*Math.cos(phi_pad)); + set_y(PAD_S*Math.sin(phi_pad)); + set_z(z_pad); + set_phi(phi_pad); + } + + private void set_x(double x){ + _x = x; + } + + private void set_y(double y){ + _y = y; + } + + private void set_z(double z){ + _z = z; + } + + private void set_phi(double phi){ + _phi = phi; + } + + public double x(){ + return _x; + } + + public double y(){ + return _y; + } + + public double z(){ + return _z; + } + + public double phi(){ + return _phi; + } +} diff --git a/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/RecoHitVector.java b/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/RecoHitVector.java new file mode 100644 index 0000000000..6837eee147 --- /dev/null +++ b/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/RecoHitVector.java @@ -0,0 +1,94 @@ +package org.jlab.rec.rtpc.hit; + +public class RecoHitVector { + + private int pad; + private double x; + private double y; + private double z; + private double dt; + private double time; + + public RecoHitVector() + { + pad = 0; + x = 0; + y = 0; + z = 0; + dt = 0; + time = 0; + } + + public RecoHitVector(int padnum, double xrec, double yrec, double zrec, double tdiff, double t) + { + pad = padnum; + x = xrec; + y = yrec; + z = zrec; + dt = tdiff; + time = t; + } + + public void setpad(int padnum) + { + pad = padnum; + } + + public void setx(double xrec) + { + x = xrec; + } + + public void sety(double yrec) + { + y = yrec; + } + + public void setz(double zrec) + { + z = zrec; + } + + public void settime(double t) + { + time = t; + } + + public void setdt(double tdiff) + { + dt = tdiff; + } + + public int pad() + { + return pad; + } + + public double x() + { + return x; + } + + public double y() + { + return y; + } + + public double z() + { + return z; + } + + public double time() + { + return time; + } + + public double dt() + { + return dt; + } + + + +} diff --git a/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/ReducedTrack.java b/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/ReducedTrack.java new file mode 100644 index 0000000000..08810c5875 --- /dev/null +++ b/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/ReducedTrack.java @@ -0,0 +1,61 @@ +package org.jlab.rec.rtpc.hit; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; + +public class ReducedTrack { + + private List _hits = new ArrayList(); + private boolean _flagTrack = false; + + public ReducedTrack() { + //Default Constructor + } + + public void addHit(HitVector v) { + _hits.add(v); + } + + public void sortHits() { + Collections.sort(_hits, new Comparator() { + @Override + public int compare(HitVector v1, HitVector v2) { + return Double.compare(v2.time(),v1.time()); + } + }); + } + + public double getSmallT() { + return _hits.get(_hits.size()-1).time(); + } + + public double getLargeT() { + return _hits.get(0).time(); + } + + public Set getAllPads() { + Set pads = new HashSet(); + for(HitVector v : _hits) { + pads.add(v.pad()); + } + return pads; + } + + public List getAllHits() { + return _hits; + } + + public void flagTrack() { + _flagTrack = true; + } + + public boolean isTrackFlagged() { + return _flagTrack; + } + +} diff --git a/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/ReducedTrackMap.java b/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/ReducedTrackMap.java new file mode 100644 index 0000000000..4ea6a3f7a1 --- /dev/null +++ b/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/ReducedTrackMap.java @@ -0,0 +1,59 @@ +package org.jlab.rec.rtpc.hit; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ConcurrentHashMap; +import java.util.HashMap; + +public class ReducedTrackMap { + + private HashMap _map; + private int _trackID = 0; + + public ReducedTrackMap() { + _map = new HashMap(); + } + + public void addTrack(ReducedTrack t) { + _trackID++; + _map.put(_trackID, t); + } + + public ReducedTrack getTrack(int trackID) { + if(!_map.containsKey(trackID)) { + addTrack(new ReducedTrack()); + } + return _map.get(trackID); + } + + public void updateTrack(int trackID, ReducedTrack t) { + _map.put(trackID, t); + } + + public void removeTrack(int trackID) { + _map.remove(trackID); + } + + public List getAllTrackIDs() { + List l = new ArrayList(); + for(int i : _map.keySet()) { + if(!l.contains(i)) { l.add(i);} + } + return l; + } + + public int getLastTrackID() { + return _trackID; + } + + public void mergeTracks(int trackIDparent, int trackID) { + ReducedTrack child = getTrack(trackID); + List l = child.getAllHits(); + ReducedTrack parent = getTrack(trackIDparent); + for(HitVector v : l) { + parent.addHit(v); + } + removeTrack(trackID); + } + +} diff --git a/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/TimeAverage.java b/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/TimeAverage.java new file mode 100644 index 0000000000..85dfb5d15c --- /dev/null +++ b/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/TimeAverage.java @@ -0,0 +1,389 @@ +package org.jlab.rec.rtpc.hit; + +import java.util.Collections; +import java.util.HashMap; +import java.util.Vector; +import java.util.concurrent.ConcurrentHashMap; + +import javax.swing.JFrame; + +import org.jlab.clas.physics.LorentzVector; +import org.jlab.clas.physics.Vector3; +import org.jlab.groot.data.GraphErrors; +import org.jlab.groot.graphics.EmbeddedCanvas; +import org.jlab.groot.math.F1D; + +public class TimeAverage { + + public void TA(HitParameters params, boolean draw) { + + HashMap ADCMap = params.get_R_adc(); + HashMap>> TIDMap = params.get_TIDMap(); + HashMap> trTIDMap = new HashMap>(); + HashMap> FinalTIDMap = new HashMap>(); + Vector PadList = new Vector(); + HashMap> hitlist = new HashMap>(); + int TrigWindSize = params.get_TrigWindSize(); + //int choosetid = 1; + int StepSize = 120; + double thresh = 0; + Vector3 padvec = new Vector3(); + LorentzVector test4vec = new LorentzVector(); + double sumnumer = 0; + double sumdenom = 0; + double maxvalue = 0; + int countadc = 0; + int newtidcounter = 1; + int tidsum = 0; + int min_pads = 3; + double phithresh = 0.6; + double zthresh = 24; + double timethresh = 1500; + + HashMap weightave = new HashMap(); + HashMap weightaveadc = new HashMap(); + + HashMap> gZvsT = new HashMap>(); + HashMap> gPhivsT = new HashMap>(); + + EmbeddedCanvas c = new EmbeddedCanvas(); + c.divide(5, 5); + EmbeddedCanvas c2 = new EmbeddedCanvas(); + c2.divide(5, 5); + int plotcounter = 0; + + JFrame jfr = new JFrame(); + jfr.setSize(1200,1200); + JFrame jfr2 = new JFrame(); + jfr2.setSize(1200,1200); + + + boolean drawellipse = false; + + + F1D ellipse1a = new F1D("ellipse1a","sqrt([b]*[b](1-((x-[h])*(x-[h])/([a]*[a]))))+[k]",2500,4508); + F1D ellipse1b = new F1D("ellipse1b","-sqrt([b]*[b](1-((x-[h])*(x-[h])/([a]*[a]))))+[k]",2500,4508); + F1D ellipse2a = new F1D("ellipse2a","sqrt([b]*[b](1-((x-[h])*(x-[h])/([a]*[a]))))+[k]",2800,4210); + F1D ellipse2b = new F1D("ellipse2b","-sqrt([b]*[b](1-((x-[h])*(x-[h])/([a]*[a]))))+[k]",2800,4210); + ellipse1a.setParameter(0, 50); + ellipse1a.setParameter(1, 3500); + ellipse1a.setParameter(2, 1000); + ellipse1a.setParameter(3, -75); + ellipse1b.setParameter(0, 50); + ellipse1b.setParameter(1, 3500); + ellipse1b.setParameter(2, 1000); + ellipse1b.setParameter(3, -75); + + ellipse2a.setParameter(0, 75); + ellipse2a.setParameter(1, 3500); + ellipse2a.setParameter(2, 1400); + ellipse2a.setParameter(3, -75); + ellipse2b.setParameter(0, 75); + ellipse2b.setParameter(1, 3500); + ellipse2b.setParameter(2, 1400); + ellipse2b.setParameter(3, -75); + + for(int choosetid : TIDMap.keySet()) + { + + for(int time : TIDMap.get(choosetid).keySet()) + { + //System.out.println(time); + for(int pad = 0; pad < TIDMap.get(choosetid).get(time).size(); pad++) + { + if(!PadList.contains(TIDMap.get(choosetid).get(time).get(pad))) + { + PadList.add(TIDMap.get(choosetid).get(time).get(pad)); + } + } + } + + for(int pad = 0; pad < PadList.size(); pad++) + { + for(int time : TIDMap.get(choosetid).keySet()) + { + if(TIDMap.get(choosetid).get(time).contains(PadList.get(pad))) + { + if(ADCMap.get(PadList.get(pad))[time]>maxvalue) + { + maxvalue = ADCMap.get(PadList.get(pad))[time]; + } + } + } + thresh = maxvalue/2; + countadc = 0; + for(int time = 0; time < TrigWindSize; time+=120) + { + if(ADCMap.get(PadList.get(pad))[time] > thresh) + { + sumnumer += ADCMap.get(PadList.get(pad))[time]*time; + sumdenom += ADCMap.get(PadList.get(pad))[time]; + countadc++; + //System.out.println(PadList.get(pad) + " " + time); + } + } + //System.out.println("weightave " + PadList.get(pad) + " " + sumnumer/sumdenom); + weightave.put(PadList.get(pad), sumnumer/sumdenom); + weightaveadc.put(PadList.get(pad), sumdenom); + sumnumer = 0; + sumdenom = 0; + maxvalue = 0; + padvec = PadCoords(PadList.get(pad)); + //gZvsT.addPoint(weightave.get(PadList.get(pad)), padvec.z(), 0, 0); + //gPhivsT.addPoint(weightave.get(PadList.get(pad)), Math.atan2(padvec.y(),padvec.x()),0,0); + } + int pad = 0; + double avetime = 0; + double adc = 0; + trTIDMap.put(choosetid,new Vector()); + for(int p = 0; p < PadList.size(); p++) + { + pad = PadList.get(p); + avetime = weightave.get(pad); + adc = weightaveadc.get(pad); + //LorentzVector v = new LorentzVector(avetime,Math.atan2(PadCoords(pad).y(),PadCoords(pad).x()),PadCoords(pad).z(),pad); + HitVector v = new HitVector(pad,PadCoords(pad).z(),Math.atan2(PadCoords(pad).y(),PadCoords(pad).x()),avetime,adc); + + trTIDMap.get(choosetid).add(v); + } + double smalltime = 0; + for(int i = 0; i < trTIDMap.get(choosetid).size(); i++) + { + smalltime = trTIDMap.get(choosetid).get(i).time(); + for(int j = 0; j < trTIDMap.get(choosetid).size();j++) + { + if(trTIDMap.get(choosetid).get(j).time() < smalltime && i!=j) + { + trTIDMap.get(choosetid).insertElementAt(trTIDMap.get(choosetid).get(i), j); + trTIDMap.get(choosetid).remove(i+1); + break; + } + } + } + int newtid = 150; + + + HitVector padcoords = new HitVector(); + HitVector checkpadcoords = new HitVector(); + + while(trTIDMap.get(choosetid).size()!=0) + { + hitlist.put(choosetid, new Vector()); + hitlist.get(choosetid).add(0); + padcoords = trTIDMap.get(choosetid).get(0); + for(int i = 1; i < trTIDMap.get(choosetid).size(); i++) + { + checkpadcoords = trTIDMap.get(choosetid).get(i); + if(Math.abs(checkpadcoords.time() - padcoords.time()) < timethresh && (Math.abs(checkpadcoords.phi()-padcoords.phi())()); + for(int i = 0; i < hitlist.get(choosetid).size(); i++) + { + trTIDMap.get(newtid).add(trTIDMap.get(choosetid).get(hitlist.get(choosetid).get(i))); + trTIDMap.get(choosetid).set(hitlist.get(choosetid).get(i),new HitVector(0,1e10,0)); + } + for(int i = 0; i < trTIDMap.get(choosetid).size(); i ++) + { + if(trTIDMap.get(choosetid).get(i).time() == 1e10) + { + trTIDMap.get(choosetid).remove(i); + i--; + } + } + hitlist.clear(); + newtid++; + } + trTIDMap.remove(choosetid); + HashMap> mergelist = new HashMap>(); + Vector mergelistvec = new Vector(); + int mergelistindex = 0; + HitVector testvec1 = new HitVector(); + HitVector testvec2 = new HitVector(); + for(int i : trTIDMap.keySet()) + { + mergelist.put(mergelistindex, new Vector()); + for(int f = trTIDMap.get(i).size() - 1; f >= (trTIDMap.get(i).size() - 5) && f > 0; f--) + { + testvec1 = trTIDMap.get(i).get(f); + for(int j : trTIDMap.keySet()) + { + if(i!=j) + { + for(int g = trTIDMap.get(j).size() - 1; g >= (trTIDMap.get(j).size() - 5) && g > 0; g--) + { + //System.out.println(f + " " + g); + testvec2 = trTIDMap.get(j).get(g); + if((Math.abs(testvec1.time() - testvec2.time()) < timethresh) && (Math.abs(testvec1.phi()-testvec2.phi())()); + for(int f = 0; f <= 5; f++) + { + if(f < trTIDMap.get(i).size()) { + testvec1 = trTIDMap.get(i).get(f); + for(int j : trTIDMap.keySet()) + { + if(i!=j) + { + for(int g = trTIDMap.get(j).size() - 1; g >= (trTIDMap.get(j).size() - 5) && g > 0; g--) + { + //System.out.println(f + " " + g); + testvec2 = trTIDMap.get(j).get(g); + if((Math.abs(testvec1.time() - testvec2.time()) < timethresh) && (Math.abs(testvec1.phi()-testvec2.phi())1) + { + TIDtokeep = mergelist.get(i).get(0); + for(int l = 1; l < mergelist.get(i).size(); l++) + { + TIDtomerge = mergelist.get(i).get(l); + trTIDMap.get(TIDtokeep).addAll(trTIDMap.get(TIDtomerge)); + trTIDMap.remove(TIDtomerge); + } + } + } + Vector toremove = new Vector(); + for(int i : trTIDMap.keySet()) + { + if(trTIDMap.get(i).size() < min_pads) + { + toremove.add(i); + } + } + for(int i = 0; i < toremove.size(); i++) + { + trTIDMap.remove(toremove.get(i)); + } + gZvsT.put(choosetid, new HashMap()); + c.cd(plotcounter); + gPhivsT.put(choosetid, new HashMap()); + c2.cd(plotcounter); + for(int i : trTIDMap.keySet()) + { + FinalTIDMap.put(newtidcounter,new Vector()); + gZvsT.get(choosetid).put(i, new GraphErrors()); + gZvsT.get(choosetid).get(i).setTitle("Z vs T"); + gPhivsT.get(choosetid).put(i, new GraphErrors()); + gPhivsT.get(choosetid).get(i).setTitle("Phi vs T"); + for(int j = 0; j < trTIDMap.get(i).size(); j++) + { + gZvsT.get(choosetid).get(i).addPoint(trTIDMap.get(i).get(j).time(), trTIDMap.get(i).get(j).z(), 0, 0); + gPhivsT.get(choosetid).get(i).addPoint(trTIDMap.get(i).get(j).time(), trTIDMap.get(i).get(j).phi(), 0, 0); + FinalTIDMap.get(newtidcounter).add(trTIDMap.get(i).get(j)); + } + gZvsT.get(choosetid).get(i).setMarkerSize(2); + gZvsT.get(choosetid).get(i).setMarkerColor(i-149); + gPhivsT.get(choosetid).get(i).setMarkerSize(2); + gPhivsT.get(choosetid).get(i).setMarkerColor(i-149); + c.draw(gZvsT.get(choosetid).get(i),"same"); + c2.draw(gPhivsT.get(choosetid).get(i),"same"); + newtidcounter++; + } + tidsum+= trTIDMap.size(); + PadList.clear(); + weightave.clear(); + trTIDMap.clear(); + hitlist.clear(); + mergelist.clear(); + plotcounter++; + } + //System.out.println(plotcounter); + //System.out.println("tidsum " + tidsum + "final map size " + FinalTIDMap.size()); + /* + for(int i : gZvsT.keySet()) + { + c.cd(plotcounter); + for(int j : gZvsT.get(i).keySet()) + { + c.draw(gZvsT.get(i).get(j),"same"); + } + plotcounter++; + }*/ + if(draw) { + jfr.add(c); + jfr.setTitle("Time Averaged ZvsT"); + jfr.setVisible(true); + jfr2.add(c2); + jfr2.setTitle("Time Averaged PhivsT"); + jfr2.setVisible(true); + } + params.set_FinalTimeMap(FinalTIDMap); + } + + private Vector3 PadCoords(int cellID) { + + double PAD_W = 2.79; // in mm + double PAD_S = 80.0; //in mm + double PAD_L = 4.0; // in mm + double RTPC_L= 384.0; // in mm + double phi_pad = 0; + //double Num_of_Rows = (2.0*(Math.PI)*PAD_S)/PAD_W; + double Num_of_Cols = RTPC_L/PAD_L; + double PI=Math.PI; + double z0 = -(RTPC_L/2.0); + double phi_per_pad = PAD_W/PAD_S; // in rad + double chan = (double)cellID; + double col = chan%Num_of_Cols; + double row=(chan-col)/Num_of_Cols; + double z_shift = row%4; + + phi_pad=(row*phi_per_pad)+(phi_per_pad/2.0); + + if(phi_pad>= 2.0*PI) + { + phi_pad -= 2.0*PI; + } + if(phi_pad<0) + { + phi_pad += 2.0*PI; + } + + double z_pad=z0+(col*PAD_L)+(PAD_L/2.0)+z_shift; + + Vector3 PadCoords = new Vector3(PAD_S*Math.cos(phi_pad),PAD_S*Math.sin(phi_pad),z_pad); + return PadCoords; + + } + + +} diff --git a/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/TimeAverage2.java b/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/TimeAverage2.java new file mode 100644 index 0000000000..90b806119f --- /dev/null +++ b/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/TimeAverage2.java @@ -0,0 +1,159 @@ +//Author: David Payette + +/* This code takes the tracks from the Track Finder, and reduces the signals in the track to single + * values in time by taking a weighted average of the signal using the ADC value as the weight + * The end result is the same tracks but with hits which now have non-discritized times (not in + * 120 ns slices) This is useful for the disentangler to split merged tracks + */ + +package org.jlab.rec.rtpc.hit; + +import java.util.HashMap; +import java.util.concurrent.ConcurrentHashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import javax.swing.JFrame; + +import org.jlab.groot.data.GraphErrors; +import org.jlab.groot.graphics.EmbeddedCanvas; + +public class TimeAverage2 { + + public TimeAverage2(HitParameters params, boolean draw) { + /* + *Initializations + */ + + ReducedTrackMap RTIDMap = new ReducedTrackMap(); + ReducedTrack rtrack; + TrackMap TIDMap = params.get_trackmap(); + HashMap ADCMap = params.get_R_adc(); + List tids = TIDMap.getAllTrackIDs(); + Track track; + double adc = 0; + double adcmax = 0; + double averagetime = 0; + double adcthresh = 0; + double sumnum = 0; + double sumden = 0; + + /* + * Main Algorithm + */ + + for(int tid : tids) { + track = TIDMap.getTrack(tid); + boolean trackflag = track.isTrackFlagged(); + rtrack = new ReducedTrack(); + if(trackflag) {rtrack.flagTrack();} + Set l = track.uniquePadList(); + Set timesbypad = new HashSet(); + for(int pad : l) { + adcmax = 0; + sumnum = 0; + sumden = 0; + timesbypad = track.PadTimeList(pad); + for(int time : timesbypad) { //Loop to calculate maximum adc value + adc = ADCMap.get(pad)[time]; + if(adc > adcmax) { + adcmax = adc; + } + } + adcthresh = adcmax/2; + for(int time : timesbypad) { //Loop to calculate weighted average time using ADC values which are above half of the maximum + adc = ADCMap.get(pad)[time]; + if(adc > adcthresh) { + sumnum += adc*time; + sumden += adc; + } + } + averagetime = sumnum/sumden; + PadVector p = params.get_padvector(pad); + HitVector v = new HitVector(pad,p.z(),p.phi(),averagetime,sumden); + rtrack.addHit(v); + } + RTIDMap.addTrack(rtrack); + } + + /* + * Output + */ + + params.set_rtrackmap(RTIDMap); + + /* + * Drawing for debugging + */ + + if(draw) { + + HashMap gmapzvsphi = new HashMap(); + EmbeddedCanvas cZvsPhi = new EmbeddedCanvas(); + JFrame jZvsPhi = new JFrame(); + jZvsPhi.setSize(800,800); + + HashMap gmapphivst = new HashMap(); + EmbeddedCanvas cPhivsT = new EmbeddedCanvas(); + JFrame jPhivsT = new JFrame(); + jPhivsT.setSize(800,800); + + HashMap gmapzvst = new HashMap(); + EmbeddedCanvas cZvsT = new EmbeddedCanvas(); + JFrame jZvsT = new JFrame(); + jZvsT.setSize(800,800); + int color = 1; + int style = 1; + for(int tid : RTIDMap.getAllTrackIDs()) { + ReducedTrack t = RTIDMap.getTrack(tid); + gmapzvsphi.put(tid, new GraphErrors()); + gmapphivst.put(tid, new GraphErrors()); + gmapzvst.put(tid, new GraphErrors()); + for(HitVector v : t.getAllHits()) { + double time = v.time(); + gmapzvsphi.get(tid).addPoint(v.phi(), v.z(), 0, 0); + gmapzvst.get(tid).addPoint(time, v.z(), 0, 0); + gmapphivst.get(tid).addPoint(time, v.phi(), 0, 0); + } + gmapzvsphi.get(tid).setMarkerColor(color); + gmapzvsphi.get(tid).setMarkerSize(3); + gmapzvsphi.get(tid).setMarkerStyle(style); + + gmapzvst.get(tid).setMarkerColor(color); + gmapzvst.get(tid).setMarkerSize(3); + gmapzvst.get(tid).setMarkerStyle(style); + + gmapphivst.get(tid).setMarkerColor(color); + gmapphivst.get(tid).setMarkerSize(3); + gmapphivst.get(tid).setMarkerStyle(style); + + cZvsPhi.draw(gmapzvsphi.get(tid),"same"); + cZvsT.draw(gmapzvst.get(tid),"same"); + cPhivsT.draw(gmapphivst.get(tid),"same"); + + color++; + if(color > 8) { + color = 1; + style++; + } + + } + + jZvsPhi.setTitle("Time Average Output"); + jZvsPhi.add(cZvsPhi); + jZvsPhi.setVisible(true); + + jZvsT.setTitle("Time Average Output"); + jZvsT.add(cZvsT); + //jZvsT.setVisible(true); + + jPhivsT.setTitle("Time Average Output"); + jPhivsT.add(cPhivsT); + //jPhivsT.setVisible(true); + + } + + } + +} diff --git a/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/Track.java b/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/Track.java new file mode 100644 index 0000000000..2e0b62c631 --- /dev/null +++ b/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/Track.java @@ -0,0 +1,117 @@ +package org.jlab.rec.rtpc.hit; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; +import java.util.HashMap; + +public class Track { + + private HashMap> _track = new HashMap>(84,1.0f); + private List _l = new ArrayList(); + //private int _padcount; + private boolean _flagTrack = false; + + public Track() { + //default constructor + } + public Track(int time, int padnum) { + if(!_track.containsKey(time)) { + addTimeSlice(time); + } + addPad(time,padnum); + } + + public void addTimeSlice(int time) { + _track.put(time, new ArrayList()); + } + + public void addTimeSlice(int time, List l) { + List templ = getTimeSlice(time); + for(int i : l) { + if(!templ.contains(i)) { + templ.add(i); + } + } + } + + public void addPad(int time, int padnum) { + _track.get(time).add(padnum); + } + + public List getTimeSlice(int time) { + if(!_track.containsKey(time)) { + addTimeSlice(time); + } + return _track.get(time); + } + + public List getAllTimeSlices(){ + List l = new ArrayList(); + for(int i : _track.keySet()) { + l.add(i); + } + return l; + } + + public boolean padExists(int time, int padnum) { + _l = getTimeSlice(time); + return _l.contains(padnum); + } + + public int padCountbyTime(int time) { + _l = getTimeSlice(time); + return _l.size(); + } + + public int padCountTotal() { + int _padcount = 0; + for(int time : _track.keySet()) { + _padcount += padCountbyTime(time); + } + return _padcount; + } + + public void flagTrack() { + _flagTrack = true; + } + + public boolean isTrackFlagged() { + return _flagTrack; + } + + public Set uniquePadList() { + List slice = new ArrayList(); + Set pads = new HashSet(); + for(int time : _track.keySet()) { + slice = getTimeSlice(time); + for(int pad : slice) { + + pads.add(pad); + + } + } + return pads; + } + + public Set PadTimeList(int pad) { + Set times = new HashSet(); + List allslices = getAllTimeSlices(); + List t = new ArrayList(); + for(int slice : allslices) { + t = getTimeSlice(slice); + if(t.contains(pad)) { + times.add(slice); + } + } + return times; + } + + public int uniquePadCountTotal() { + + return uniquePadList().size(); + + } + +} diff --git a/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/TrackFinder2.java b/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/TrackFinder2.java new file mode 100644 index 0000000000..fdfe402efb --- /dev/null +++ b/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/TrackFinder2.java @@ -0,0 +1,994 @@ +package org.jlab.rec.rtpc.hit; + +import java.awt.Component; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.concurrent.ConcurrentHashMap; +import java.util.List; +import java.util.Vector; +import javax.swing.JFrame; +import org.jlab.groot.data.*; +import org.jlab.groot.fitter.*; +import org.jlab.groot.graphics.*; +import org.jlab.groot.math.F1D; +import org.jlab.groot.ui.TCanvas; +//import org.jlab.clas.physics.Vector3; + + + +public class TrackFinder2 { + + /*************************************** + * Author: David Payette + * + * The function FindTrack2 is divided into 3 main parts, the sorting algorithm, the merging algorithm, + * and plotting. The sorting algorithm builds a map call TIDMap. It starts empty and will be filled with + * track IDs (TIDs), each one returning a map of time slices (120 ns) that each contain a vector of pads which were sorted + * together in this time slice. So TIDMap.get(1).get(120).get(3) will give you the fourth pad at 120 ns that has TID 1. + * The sorting algorithm contains a series of nested loops as follows: The TIMELOOP loops through values of time starting + * at 0 and moving in steps of 120 ns up to the TrigWindSize (10000 ns). Then there is a PADLOOP which loops through all + * the pads which saw a signal in the simulation. The signal shape is created in PadHit for now since GEMC does not do signal + * simulation for our purposes yet. This signal is then integrated into 120 ns bins which is based on the Dream chip timing. + * For each pad in the loop, it checks for the ADC value at the current time, + * and if it passes an ADC threshold, then it moves on to be sorted. The TIDLOOP loops through all elements of a vector TIDVec, + * which initially only contains TID 1 and will add TIDs as necessary. If the TIDMap does not contain the current TID in the + * vector then it adds it to the map. Otherwise, the current pad in the loop is checked against all other pads assigned to + * the current TID by comparing the distance between the pads to a preset ellipse formula. This check is done for the current + * time slice, and a set number (timeadj) of previous time slices. If a pad is close enough to another pad with an assigned + * TID then it is also assigned this TID. A pad is allowed to be assigned multiple TIDs at this stage, which will flag the + * merging algorithm to remember to merge these TIDs later after the sort. If a pad makes it to the end of the TIDLOOP and still + * has not been sorted then it will be assigned a new TID as the new TID is added to the map. The merging algorithm looks + * for TIDs which were flagged to be merged during sort and combines them all into the lowest numbered TID and then the + * other TIDs are removed from the map. + * + * TIMELOOP: 0->10000 in 120 ns steps + * { + * PADLOOP: All pads which have an ADC value that passes threshold for current time + * { + * TIDLOOP: Loop through TIDs in TIDVec + * if(TID is in map){ Compare pad to other pads (PADINDEXLOOP) in current and previous times (PREVTIMELOOP) and see + * if it is near enough (using ellipse formula) } + * else{ If pad has not been assigned at least one TID, assign it a new one and add it to the map } + * + * if(pad has more than one TID){ group the TIDs into MapCombine, using the smallest one as the key } + * } + * } + * + * Loop over the keys of MapCombine, and take all the TIDs assigned to each key and merge them into the key TID and + * remove them from the TIDMap. + * + * Plot a bunch of stuff for testing. + * + * The ellipse formula looks like this: + * + * (dx^2 + dy^2)/phi_0^2 + (dz^2)/z_0^2 <= adjthresh^2 + * + * dx, dy, and dz are the distances between two pads, phi_0 and z_0 are set parameters that define the ellipse, + * and adjthresh is the maximum level of adjacency we allow. This determines how many rings of adjacent pads are + * close enough. + ****************************************/ + + public void FindTrack2(HitParameters params, boolean draw){ + /*************************************** + * + * INITIALIZE VARIABLES + * + ****************************************/ + //HashMap> TIDMap = new HashMap>(); + //HashMap PadThresh = new HashMap(); + //HashMap>> FixedTIDMap = new HashMap>>(); + //double PadPhistore = 0; + //double PadZstore = 0; + //boolean PadPhiChanged = false; + //Necessary pad variables + //double PAD_W = 2.79; //in mm + //double PAD_S = 80.0; //in mm + //double Num_of_Rows = (2.0*(Math.PI)*PAD_S)/PAD_W; + //int padindexmax = 0; Not being used currently + //double time1 = System.currentTimeMillis(); + /* Not being used currently + * int maxconcpads = 0; + * int concpads = 0; + * int maxconctime = 0; + */ + + + + HashMap ADCMap = params.get_R_adc(); //Key - Cell ID, Value - Array of signal height over time slices + + /** + * TIDMap contains a HashMap of Vectors + * The key is Track ID (TID), which returns a map + * The key of the returned map is Time, which returns a vector + * The elements of the vector are pads + * This stores all pads in each time slice, and all time slices for each TID + * Example :: Track ID 1, Time 120 contains pads: 3,4,5,7 so using the call + * TIDMap.get(1).get(120).get(3) will give you pad 5 + */ + HashMap>> TIDMap = new HashMap>>(); + + /** + * strkTIDMap uses the same structure as TIDMap but is used at the end to isolate + * TIDs which only contain single tracks. This map is all TIDs not sent to the disentangler + */ + HashMap>> strkTIDMap = new HashMap>>(); + + + Vector PadNum = params.get_PadNum(); //Contains pads used in PadHit + Vector TIDVec = new Vector<>(); //Contains all TIDs and is added to throughout, + TIDVec.add(1); //Starts with TID 1 + + + int Pad = 0; //initializing pad + double ADC = 0; //initializing ADC + int TrigWindSize = params.get_TrigWindSize(); //Trigger Window Size = 10000 + //int StepSize = params.get_StepSize(); + int StepSize = 120; //Time stepsize in ns + double adcthresh = 5e-4; //Arbitrary ADC threshold + + int min_pads = 0; //Minimum number of pads required to keep as a track + + //These vectors will contain x,y,z for each pad being checked + //Vector3 TempPadCoords = new Vector3(); + //Vector3 CheckPadCoords = new Vector3(); + //Vector3 CheckPadPrevCoords = new Vector3(); + + PadVector TempPadCoords;// = new PadVector(); + PadVector CheckPadCoords; + PadVector CheckPadPrevCoords; + + int TID = 0; //initialize TID + + //used for plotting + double plotphi = 0; + double plotz = 0; + + int timeadj = 2; //How many previous time slices to check in algorithm + int event = params.get_eventnum(); //event number only used for file number + + + //Initialize Ellipse Variables used for adjacency checks + double adjthresh = 12; //sqrt(right hand side of ellipse formula) + double EllipseDeltax = 0; //dx + double EllipseDeltay = 0; //dy + double EllipseDeltaz = 0; //dz + double EllipseTotal = 0; //left hand side of ellipse formula + double PhiDelta = 16; //phi_0 + double ZDelta = 36; //z_0 + + double phithresh = 0.15; + double zthresh = 10; + + //set variables for timing cut (currently time cut is not used, cuts on time happen later) + int tmin = 0; //min timing in ns + int trange = 20000; //added to min to calculate max in ns + int tmax = tmin+trange; + + //Maps and variables used for combining TIDs later in the merge algorithm + boolean PadSorted = false; + Vector PadTIDcollect = new Vector(); + Vector TIDcombine = new Vector(); + HashMap> MapCombine = new HashMap>(); + int mapkey = 0; + + //Map of graphs of ADC vs Time + HashMap gADCvsT = new HashMap(); + + //g.setTitleX("Phi"); + //g.setTitleY("Z"); + //g.setMarkerSize(5); + + try { + File f = new File("/Users/davidpayette/Documents/FileOutput/Output" + event + ".txt"); + f.delete(); + FileWriter write2 = new FileWriter("/Users/davidpayette/Documents/FileOutput/Output" + event + ".txt",true); + //File f2 = new File("/Users/davidpayette/Documents/FileOutput/Master.txt"); + FileWriter write3 = new FileWriter("/Users/davidpayette/Documents/FileOutput/Master.txt",true); + //Collections.sort(PadNum); + //H1F t2 = new H1F("t2","t2",TrigWindSize/StepSize,0,TrigWindSize); + + GraphErrors t1 = new GraphErrors(); + int counter = 0; + HashMap countermap = new HashMap(); + + /*************************************** + * + * SORTING ALGORITHM + * + ****************************************/ + /**loop over all times in 120 ns slices**/ + TIMELOOP: //these labels are not used for the most part, but help to label the loops + for(int t = 0; t < TrigWindSize; t += StepSize) + { + //System.out.println("Time is " + t); + //concpads = 0; + + /**loop over all pads for each time slice**/ + int padloopsize = PadNum.size(); + PADLOOP: + for(int p = 0; p < padloopsize; p++) + { + + PadSorted = false; + PadTIDcollect.clear(); + Pad = PadNum.get(p); + + //System.out.println(PadNum.size() + " size"); + //System.out.println(Pad + " " + t); + + ADC = ADCMap.get(Pad)[t]; + + /**only pads which have an ADC value above threshold will be assigned a TID**/ + if(ADC > adcthresh) + { + //write3.write(ADC + "\n"); + /**This is used for testing something else**/ + if(Pad == 11091) + { + t1.addPoint(t, ADCMap.get(Pad)[t], 0, 0); + //t2.fill(t); + } + if(!countermap.containsKey(Pad)) + { + countermap.put(Pad, 1); + } + else + { + counter = countermap.get(Pad); + counter++; + countermap.put(Pad,counter); + } + + //Plots ADC vs T for each Pad + if(!gADCvsT.containsKey(Pad)) + { + gADCvsT.put(Pad, new GraphErrors()); + gADCvsT.get(Pad).addPoint(t, ADCMap.get(Pad)[t], 0, 0); + } + else + { + gADCvsT.get(Pad).addPoint(t, ADCMap.get(Pad)[t], 0, 0); + } + /*******************************************/ + //System.out.println("Pad to be checked " + Pad + " checked at time " + t); + + //returns x,y,z of the current Pad + //Vector3 PadCoords = PadCoords(Pad); + PadVector PadCoords = params.get_padvector(Pad); + + //System.out.println("Pad " + Pad + " has row and column values " + PadPhi + " " + PadZ); + //g.addPoint(PadPhi, PadZ, 0, 0); + + /**loop through all TID's in a vector which will grow to include all future TID's**/ + int tidloopsize = TIDVec.size(); + TIDLOOP: + for(int i = 0; i < tidloopsize; i++) + { + TID = TIDVec.get(i); //returns current TID to sort into + //System.out.println("Current TID " + TID); + + /**if TID is already in the map**/ + if(TIDMap.containsKey(TID)) + { + //System.out.println("TID " + TID + " is already in the map"); + + /**loop through all pads in TIDMap and compare there row and column to current Pad**/ + PADINDEXLOOP: + for(int padindex = 0; padindex < 100; padindex++) //TODO 100 is unnecessary placeholder + { + //System.out.println("Pad index is " + padindex); + if(padindex < TIDMap.get(TID).get(t).size()) + { + //CheckPadCoords = PadCoords(TIDMap.get(TID).get(t).get(padindex)); //Get the x,y,z of the pad we are checking against + CheckPadCoords = params.get_padvector(TIDMap.get(TID).get(t).get(padindex)); + //System.out.println("At TID " + TID + " time " + t + " padindex " + padindex + " the check pad's location is " + checkpadphi + " " + checkpadz); + //System.out.println("Current time " + checkpadphi + " " + PadPhi + " " + checkpadz + " " + PadZ + " " + Math.abs(checkpadphi-PadPhi) + " " + Math.abs(checkpadz - PadZ)); + //System.out.println("Current time slice " + PadPhi + " " + PadZ + " " + " " + checkpadphi + " " + checkpadz); + //System.out.println("The comparison values for the pad to be sorted at current time are " + Math.abs(checkpadphi-PadPhi) + " " + Math.abs(checkpadz - PadZ)); + + /**Check current time slice for adjacency**/ + /**Calculates the ellipse parameters**/ + EllipseDeltax = Math.abs(PadCoords.x()-CheckPadCoords.x())*Math.abs(PadCoords.x()-CheckPadCoords.x()); + EllipseDeltay = Math.abs(PadCoords.y()-CheckPadCoords.y())*Math.abs(PadCoords.y()-CheckPadCoords.y()); + EllipseDeltaz = Math.abs(PadCoords.z()-CheckPadCoords.z())*Math.abs(PadCoords.z()-CheckPadCoords.z()); + EllipseTotal = ((EllipseDeltax+EllipseDeltay)/PhiDelta) + (EllipseDeltaz/ZDelta); + //System.out.println("Ellipse is " + EllipseTotal); + + /** + * If the ellipse equation falls within the accepted size assign the + * TID of the checked pad to the current pad in the loop + **/ + //if(EllipseTotal <= adjthresh) + if((Math.abs(CheckPadCoords.phi()-PadCoords.phi())0) + { + /**Loops through a variable number (timeadj) of previous time slices to see if it is adjacent to earlier pads**/ + PREVTIMELOOP: + for(int prevtime = t - StepSize; (prevtime >= (t - (timeadj*StepSize))) && (prevtime >= 0); prevtime -= StepSize) + { + if(padindex < TIDMap.get(TID).get(prevtime).size()) + { + //CheckPadPrevCoords = PadCoords(TIDMap.get(TID).get(prevtime).get(padindex)); //Get the x,y,z of the pad we are checking against + CheckPadPrevCoords = params.get_padvector(TIDMap.get(TID).get(prevtime).get(padindex)); + /**Calculates the ellipse parameters**/ + EllipseDeltax = Math.abs(PadCoords.x()-CheckPadPrevCoords.x())*Math.abs(PadCoords.x()-CheckPadPrevCoords.x()); + EllipseDeltay = Math.abs(PadCoords.y()-CheckPadPrevCoords.y())*Math.abs(PadCoords.y()-CheckPadPrevCoords.y()); + EllipseDeltaz = Math.abs(PadCoords.z()-CheckPadPrevCoords.z())*Math.abs(PadCoords.z()-CheckPadPrevCoords.z()); + EllipseTotal = ((EllipseDeltax+EllipseDeltay)/PhiDelta) + (EllipseDeltaz/ZDelta); + //System.out.println("Ellipse is " + EllipseTotal); + + //System.out.println("Previous time slice " + PadPhi + " " + PadZ + " " + " " + checkpadphiprev + " " + checkpadzprev); + //System.out.println("The comparison values for the pad to be sorted at previous time are " + Math.abs(checkpadphiprev-PadPhi) + " " + Math.abs(checkpadzprev - PadZ)); + /** + * If the ellipse equation falls within the accepted size assign the + * TID of the checked pad to the current pad in the loop + **/ + //if(EllipseTotal <= adjthresh) + if((Math.abs(CheckPadPrevCoords.phi()-PadCoords.phi())< phithresh || (Math.abs(CheckPadPrevCoords.phi()-PadCoords.phi()-2*Math.PI) < phithresh )) && Math.abs(CheckPadPrevCoords.z()-PadCoords.z())>()); + for(int time = 0; time < TrigWindSize; time += StepSize) + { + TIDMap.get(TID).put(time, new Vector<>()); //add TID to map + } + TIDMap.get(TID).get(t).add(Pad); + //PadTIDcollect.add(TID); + TIDVec.add(TID+1); //add TID to the list + } + break TIDLOOP; //makes sure the TID loop doesn't go forever since we are adding a new TID to the list + } + } // End TIDLOOP // + + /** Pad has more than one TID in this time slice **/ + if(PadTIDcollect.size()>1) + { + + //System.out.println("PadTIDcollect is " + PadTIDcollect.size()); + /*for(int i : MapCombine.keySet()) + { + if(MapCombine.get(i).size()>0) + { + for(int jZvsPhi = 0; jZvsPhi()); + } + //System.out.println("TID to merge " + mapkey); + + /**Loops through remaining TIDs to be merged and puts them into a map together**/ + for(int i = 1; i < PadTIDcollect.size(); i++) + { + /*if(!TIDcombine.contains(PadTIDcollect.get(i))) + { + MapCombine.get(mapkey).add(PadTIDcollect.get(i)); + //TIDcombine.add(PadTIDcollect.get(i)); + }*/ + if(!MapCombine.get(mapkey).contains(PadTIDcollect.get(i))) + { + MapCombine.get(mapkey).add(PadTIDcollect.get(i)); + } + //System.out.println("TID to merge " + PadTIDcollect.get(i)); + } + //TIDcombine.clear(); + } + } + //else {System.out.println("Pad " + Pad + " failed ADC threshold at time " + t);} + } // End PADLOOP // + + } // End TIMELOOP // + System.out.println("This event has " + TIDMap.size() + " tracks"); + EmbeddedCanvas chist = new EmbeddedCanvas(); + JFrame jhist = new JFrame(); + jhist.setSize(800, 600); + if(draw == true) + { + chist.draw(t1); + jhist.add(chist); + jhist.setVisible(true); + jhist.setTitle("histo"); + } + + + /*************************************** + * + * MERGE ALGORITHM + * + ****************************************/ + + //Merge Tracks + + int TIDtomerge = 0; //TID we are putting into the TIDtokeep + int TIDtokeep = 0; + //Vector TIDtoremove = new Vector(); + //for(int i : TIDMap.keySet()) {System.out.println("all TIDs before " + i );} + + /** + * For each TID that needs other TIDs to be merged into it + * we get each TID from the Map assigned to the TIDtokeep key and merge the TIDs together + * then remove the other TIDs (TIDtomerge) from the map + */ + for(int j : MapCombine.keySet()) + { + if(MapCombine.get(j).size() == 0) {break;} + TIDtokeep = j; + for(int i = 0; i < MapCombine.get(j).size(); i++) + { + TIDtomerge = MapCombine.get(j).get(i); + //TIDtoremove.add(TIDtomerge); + for(int time = 0 ; time < TrigWindSize; time+=StepSize) + { + if(TIDMap.containsKey(TIDtomerge) && TIDMap.containsKey(TIDtokeep)) + { + if(TIDMap.get(TIDtomerge).get(time).size()>0) + { + for(int padindex = 0; padindex < TIDMap.get(TIDtomerge).get(time).size(); padindex++) + { + TIDMap.get(TIDtokeep).get(time).add(TIDMap.get(TIDtomerge).get(time).get(padindex)); + } + } + } + } + TIDMap.remove(TIDtomerge); + } + //System.out.println(MapCombine.get(jZvsPhi).size()); + } + + //for(int i = 0; i < TIDtoremove.size(); i++) {TIDMap.remove(TIDtoremove.get(i));} + //for(int i : TIDMap.keySet()) {System.out.println("all TIDs after " + i );} + + /*************************************** + * + * PLOTS + * + ****************************************/ + //TESTING STUFF + int countermax = 0; + int padmax = 0; + int howmanyhits = 0; + for(int i : countermap.keySet()) + { + howmanyhits += countermap.get(i); + if(countermap.get(i)>countermax) + { + countermax = countermap.get(i); + padmax = i; + //System.out.println("countermax " + i + " " + countermax); + } + } + System.out.println("this many hits " + howmanyhits + " this many pads " + countermap.size()); + + + HashMap gZvsPhi = new HashMap(); + //HashMap graphmap2 = new HashMap(); + //EmbeddedCanvas tcan = new EmbeddedCanvas(); + //TCanvas tcan = new TCanvas("t", 800, 600); + for(int testTID : TIDMap.keySet()) + { + for(int time = 0; time < TrigWindSize; time+=StepSize) + { + for(int pad = 0; pad < TIDMap.get(testTID).get(time).size(); pad++) + { + //TempPadCoords = PadCoords(TIDMap.get(testTID).get(time).get(pad)); //gets x,y,z + TempPadCoords = params.get_padvector(TIDMap.get(testTID).get(time).get(pad)); + //plotphi = Math.atan2(TempPadCoords.y(),TempPadCoords.x()); //Phi + plotphi = TempPadCoords.phi(); + plotz = TempPadCoords.z(); //Z + //System.out.println(plotphi + " " + plotz); + + if(!gZvsPhi.containsKey(testTID)) + { + gZvsPhi.put(testTID, new GraphErrors()); + } + + gZvsPhi.get(testTID).addPoint(plotphi, plotz, 0, 0); //Plots Phi, Z for each track + + + //write2.write(testTID + "\t" + time + "\t" + plotphi + "\t" + plotz + "\n"); + } + + + /*if(TIDMap.get(testTID).get(a1).size()>0) + { + gZvsPhi.get(testTID).addPoint(0, 0, 0, 0); + gZvsPhi.get(testTID).addPoint(6.5, 20, 0, 0); + //tcan.draw(gZvsPhi.get(testTID)); + //tcan.save("/Users/davidpayette/Desktop/Plots/" + a1 + ".jpg"); + //tcan.repaint(); + graphmap2.put(a1, new TCanvas(" ",800,600)); + graphmap2.get(a1).draw(gZvsPhi.get(testTID)); + graphmap2.get(a1).save("/Users/davidpayette/Desktop/Plots/" + a1 + ".jpg"); + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + }*/ + + } + } + + //F1D fitfunc1 = new F1D("f","[0]*x+[1]",0,9000); + //F1D fitfunc1 = new F1D("p1"); + //fitfunc1.setParameter(0, 1); + //fitfunc1.setParameter(1,0); + + //Vector3 vZvsT = new Vector3(); + GraphErrors gZvsT = new GraphErrors(); + EmbeddedCanvas cZvsT = new EmbeddedCanvas(); + Vector PadTracker = new Vector(); + JFrame jZvsT = new JFrame(); + jZvsT.setSize(800,600); + + /*int choosetid = 0; + for(int t : TIDMap.get(choosetid).keySet()) + { + //System.out.println(t); + for(int p = 0; p cADCvsT = new HashMap(); + GraphErrors gHitsvsPad = new GraphErrors(); + EmbeddedCanvas cHitsvsPad = new EmbeddedCanvas(); + JFrame jHitsvsPad = new JFrame(); + int mod25 = (PadTracker.size() - (PadTracker.size() % 25))/25; + //System.out.println(mod25); + for(int k = 0; k <= mod25; k++) + { + cADCvsT.put(k, new EmbeddedCanvas()); + cADCvsT.get(k).divide(5, 5); + } + + //System.out.println("size of PadTracker " + PadTracker.size()); + int numplots = 0; + int whichplot = 0; + for(int h = 0; h < PadTracker.size(); h++) + { + gHitsvsPad.addPoint(PadTracker.get(h), countermap.get(PadTracker.get(h)), 0, 0); + cADCvsT.get(whichplot).cd(numplots); + gADCvsT.get(PadTracker.get(h)).setTitle(""+PadTracker.get(h)); + gADCvsT.get(PadTracker.get(h)).addPoint(0, 0, 0, 0); + gADCvsT.get(PadTracker.get(h)).addPoint(9000, 0, 0, 0); + gADCvsT.get(PadTracker.get(h)).setMarkerSize(2); + cADCvsT.get(whichplot).draw(gADCvsT.get(PadTracker.get(h))); + if(h % 25 == 0 && h > 0) + { + whichplot++; + numplots=0; + } + else + { + numplots++; + } + } + if(draw == true) + { + gHitsvsPad.setMarkerSize(2); + cHitsvsPad.draw(gHitsvsPad); + jHitsvsPad.add(cHitsvsPad); + jHitsvsPad.setTitle("jHitsvsPad"); + jHitsvsPad.setSize(800, 600); + jHitsvsPad.setVisible(true); + HashMap jADCvsT = new HashMap(); + for(int k : cADCvsT.keySet()) + { + jADCvsT.put(k, new JFrame()); + jADCvsT.get(k).setSize(1200,800); + jADCvsT.get(k).setTitle("jADCvsT" + " " + k); + jADCvsT.get(k).add(cADCvsT.get(k)); + jADCvsT.get(k).setVisible(true); + } + //DataFitter.fit(fitfunc1, gZvsT, "QER"); + //System.out.println(fitfunc1.getChiSquare()); + + gZvsT.setMarkerSize(1); + cZvsT.draw(gZvsT); + //cZvsT.draw(fitfunc1,"same"); + jZvsT.add(cZvsT); + jZvsT.setVisible(true); + } + int tlargest = 0; + //System.out.println("before " + TIDMap.size()); + //int loopsize = TIDMap.size(); + Vector toremove = new Vector(); + Vector PadList = new Vector(); + for(int testTID : TIDMap.keySet()) + { + + for(int t = 0; t < TrigWindSize; t += StepSize) + { + for(int pad = 0; pad < TIDMap.get(testTID).get(t).size(); pad++) + { + if(!PadList.contains(TIDMap.get(testTID).get(t).get(pad))) + { + PadList.add(TIDMap.get(testTID).get(t).get(pad)); + } + + if(t > tlargest) + { + tlargest = t; + } + if(t>4000) + { + //System.out.println(pad + " " + t); + } + } + } + //System.out.println(tlargest); + if(tlargest < tmin || tlargest > tmax) + { + toremove.add(testTID); + //TIDMap.remove(testTID); + //gZvsPhi.remove(testTID); + + } + //System.out.println("large T " + tlargest); + tlargest = 0; + if(PadList.size() <= min_pads) + { + if(!toremove.contains(testTID)) + { + toremove.add(testTID); + } + } + PadList.clear(); + } + HashMap> padmap = new HashMap>(); + int padlook = 0; + for(int i = 0; i < toremove.size(); i++) + { + TIDMap.remove(toremove.get(i)); + } + HashMap hZvsT = new HashMap(); + HashMap hPhivsT = new HashMap(); + //Vector3 padv = new Vector3(); + PadVector padv; + double padphi = 0; + double padz = 0; + for(int tid : TIDMap.keySet()) + { + padmap.put(tid, new Vector()); + hPhivsT.put(tid, new H2F("hPhivsT","hPhivsT",80,0,9600,90,-Math.PI,Math.PI)); + hZvsT.put(tid, new H2F("hZvsT","hZvsT",80,0,9600,50,-200,200)); + + for(int time : TIDMap.get(tid).keySet()) + { + for(int p = 0; p < TIDMap.get(tid).get(time).size(); p++) + { + /*padlook = TIDMap.get(tid).get(time).get(p); + if(!padmap.get(tid).contains(padlook)) + { + padmap.get(tid).add(padlook); + }*/ + //padv = PadCoords(TIDMap.get(tid).get(time).get(p)); + padv = params.get_padvector(TIDMap.get(tid).get(time).get(p)); + //padphi = Math.atan2(padv.y(),padv.x()); + padphi = padv.phi(); + padz = padv.z(); + //System.out.println(time + " " + padz); + hZvsT.get(tid).fill((double)time, padz); + hPhivsT.get(tid).fill((double)time, padphi); + } + } + } + int pcount = 0; + toremove.clear(); + double histmaxavez = 0; + double histmaxavephi = 0; + + //System.out.println("HERE " + hZvsT.size()); + EmbeddedCanvas chZvsT = new EmbeddedCanvas(); + EmbeddedCanvas chPhivsT = new EmbeddedCanvas(); + JFrame jhZvsT = new JFrame(); + JFrame jhPhivsT = new JFrame(); + chZvsT.divide(5,5); + chPhivsT.divide(5, 5); + jhZvsT.setSize(1200,1200); + jhPhivsT.setSize(1200,1200); + jhZvsT.setTitle("Z vs T 2d Hist"); + jhPhivsT.setTitle("Phi vs T 2d Hist"); + for(int i : hZvsT.keySet()) + { + histmaxavez+=hZvsT.get(i).getMax(); + histmaxavephi+=hPhivsT.get(i).getMax(); + } + histmaxavez/=hZvsT.size(); + histmaxavephi/=hPhivsT.size(); + for(int i : hZvsT.keySet()) + { + //System.out.println(hZvsT.get(i).getMax() + " " + hPhivsT.get(i).getMax() + " " + histmaxavez + " " + histmaxavephi); + //if(hZvsT.get(i).getMax() < 10 || hPhivsT.get(i).getMax() < 10) + if(hZvsT.get(i).getMax() < histmaxavez*0.75 && hPhivsT.get(i).getMax() < histmaxavephi*0.75) + { + if(!toremove.contains(i)) + { + toremove.add(i); + } + } + chZvsT.cd(pcount); + chPhivsT.cd(pcount); + chZvsT.draw(hZvsT.get(i)); + chPhivsT.draw(hPhivsT.get(i)); + pcount++; + } + jhZvsT.add(chZvsT); + jhPhivsT.add(chPhivsT); + + if(draw) { + jhZvsT.setVisible(true); + jhPhivsT.setVisible(true); + } + //for(int i : TIDMap.keySet()) {System.out.println(i + " before");} + for(int i = 0; i < toremove.size(); i++) + { + //System.out.println(TIDMap.get(toremove.get(i)).size()); + strkTIDMap.put(toremove.get(i), TIDMap.get(toremove.get(i))); + TIDMap.remove(toremove.get(i)); + } + /*for(int i : strkTIDMap.keySet()) + { + for(int j : strkTIDMap.get(i).keySet()) + { + for(int k = 0; k < strkTIDMap.get(i).get(j).size(); k ++) + { + System.out.println(x); + } + } + }*/ + //for(int i : TIDMap.keySet()) {System.out.println(i + " after");} + //for(int i = 0; i < toremove.size()) + /*for(int tid : TIDMap.keySet()) + { + for(int p = 0; p < padmap.get(tid).size(); p++) + { + padv = PadCoords(padmap.get(tid).get(p)); + padphi = Math.atan2(padv.y(),padv.x()); + padz = padv.z(); + for(int time : TIDMap.get(tid).keySet()) + { + if(TIDMap.get(tid).get(time).contains(padmap.get(tid).get(p))) + { + + } + } + } + }*/ + + //System.out.println(tlargest); + int color = 1; + int style = 1; + + //for(int i : TIDMap.keySet()) {System.out.println(i);} + //System.out.println("after " + TIDMap.size()); + //System.out.println(maxconcpads + " " + maxconctime + " " + TIDVec.size()); + if(draw) + { + + EmbeddedCanvas cZvsPhi = new EmbeddedCanvas(); + JFrame jZvsPhi = new JFrame(); + jZvsPhi.setSize(800,600); + for(int i : TIDMap.keySet()) + { + //System.out.println(i); + //if(i == 1) + //{ + gZvsPhi.get(i).setMarkerColor(color); + if(false)//if(i == 1) + { + gZvsPhi.get(i).setMarkerSize(6); + } + else + { + gZvsPhi.get(i).setMarkerSize(2); + } + //gZvsPhi.get(i).addPoint(0, 0, 0, 0); + //gZvsPhi.get(i).addPoint(180, 100, 0, 0); + + //gZvsPhi.get(i).setMarkerStyle(style); + + cZvsPhi.draw(gZvsPhi.get(i),"same"); + //cZvsPhi.save("/Users/davidpayette/Desktop/Plots/g" + i + ".png"); + color++; + style++; + + //} + //System.out.println("key " + i + " " + TIDMap.size()); + } + jZvsPhi.setTitle("Track Finder Output"); + jZvsPhi.add(cZvsPhi); + jZvsPhi.setVisible(true); + + } + write2.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + for(int i : TIDMap.keySet()) + { + //System.out.println("TIDMap TIDs " + i); + } + for(int i : strkTIDMap.keySet()) + { + //System.out.println("strkTIDMap TIDs " + i); + } + params.set_TIDMap(TIDMap); + params.set_strkTIDMap(strkTIDMap); + //TIDMap.clear(); + //System.out.println(System.currentTimeMillis()-time1); + } + + /**Returns x, y, z as a vector, given pad number**/ + /* + private Vector3 PadCoords(int cellID) { + + double PAD_W = 2.79; // in mm + double PAD_S = 80.0; //in mm + double PAD_L = 4.0; // in mm + double RTPC_L= 384.0; // in mm + double phi_pad = 0; + //double Num_of_Rows = (2.0*(Math.PI)*PAD_S)/PAD_W; + double Num_of_Cols = RTPC_L/PAD_L; + double PI=Math.PI; + double z0 = -(RTPC_L/2.0); + double phi_per_pad = PAD_W/PAD_S; // in rad + double chan = (double)cellID; + double col = chan%Num_of_Cols; + double row=(chan-col)/Num_of_Cols; + double z_shift = row%4; + + phi_pad=(row*phi_per_pad)+(phi_per_pad/2.0); + + if(phi_pad>= 2.0*PI) + { + phi_pad -= 2.0*PI; + } + if(phi_pad<0) + { + phi_pad += 2.0*PI; + } + + double z_pad=z0+(col*PAD_L)+(PAD_L/2.0)+z_shift; + + Vector3 PadCoords = new (PAD_S*Math.cos(phi_pad),PAD_S*Math.sin(phi_pad),z_pad); + return PadCoords; + + } + + */ + + + //old functions, maybe used later + /*private double PadPhi(int cellID) { + + double PAD_W = 2.79; // in mm + double PAD_S = 80.0; //in mm + double PAD_L = 4.0; // in mm + double RTPC_L=400.0; // in mm + + double phi_pad = 0; + + double Num_of_Rows = (2.0*(Math.PI)*PAD_S)/PAD_W; + double Num_of_Cols = RTPC_L/PAD_L; + double TotChan = Num_of_Rows*Num_of_Cols; + + double PI=Math.PI; + + + + double phi_per_pad = PAD_W/PAD_S; // in rad + + double chan = (double)cellID; + double col = chan%Num_of_Cols; + double row=(chan-col)/Num_of_Cols; + + + //double z_shift = 0.; + + phi_pad=(row*phi_per_pad)+(phi_per_pad/2.0); + if(phi_pad>= 2.0*PI) { + phi_pad -= 2.0*PI; + } + if(phi_pad<0) + { + phi_pad += 2.0*PI; + } + + return phi_pad; + + } + private double PadZ(int cellID) + { + + double RTPC_L=400.0; // in mm + double PAD_L = 4.0; // in mm + double Num_of_Cols = RTPC_L/PAD_L; + double z0 = -(RTPC_L/2.0); // front of RTPC in mm at the center of the pad + double chan = (double)cellID; + double col = chan%Num_of_Cols; + double row=(chan-col)/Num_of_Cols; + double z_shift = row%4; + double z_pad = 0; + double testnum = (row-z_shift)/4; + + z_pad=z0+(col*PAD_L)+(PAD_L/2.0)+z_shift; + //if(z_shift == 0 && row > 0) {return col-1;} + //else{return col;} + return z_pad;//-testnum; + }*/ + +} diff --git a/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/TrackFinder3.java b/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/TrackFinder3.java new file mode 100644 index 0000000000..3848bdf570 --- /dev/null +++ b/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/TrackFinder3.java @@ -0,0 +1,219 @@ +//Author: David Payette + +/* This code sorts pad signals which have been integrated into 120 ns time slices into tracks + * based on their relative positions in space, and how close in time the signals occur + */ + +package org.jlab.rec.rtpc.hit; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.concurrent.ConcurrentHashMap; +import java.util.List; +import java.util.Vector; + +import javax.swing.JFrame; + +import org.jlab.groot.data.GraphErrors; +import org.jlab.groot.graphics.EmbeddedCanvas; + +public class TrackFinder3 { + + public TrackFinder3(HitParameters params, boolean draw) { + /* + *Initializations + */ + TrackUtils tutil = new TrackUtils(); + TrackMap TIDMap = new TrackMap(); + List TIDList; + Track track; + HashMap ADCMap = params.get_R_adc(); + Vector PadNum = params.get_PadNum(); + int TrigWindSize = params.get_TrigWindSize(); + int StepSize = 120; + double adcthresh = 5e-4; + int padloopsize = PadNum.size(); + boolean padSorted = false; + List padTIDlist = new ArrayList(); + List padlist; + int pad = 0; + double adc = 0; + int timeadjlimit = 4; + int parenttid = -1; + String method = "phiz"; + int minhitcount = 5; + + /* + * Main Algorithm + */ + TIMELOOP: //Loop over all times + for(int time = 0; time < TrigWindSize; time += StepSize) { //Steps of 120 up to TrigWindSize = 10000 + + PADLOOP: //Loop over all pads + for(int padindex = 0; padindex < padloopsize; padindex++) { + padSorted = false; //Flag to be set when the pad is assigned to a track + padTIDlist.clear(); //List of all TIDs assigned to the pad starts empty + pad = PadNum.get(padindex); + adc = ADCMap.get(pad)[time]; + + if(adc > adcthresh) { //pad adc threshold check + PadVector PadVec = params.get_padvector(pad); //initializes the x,y,z,phi for pad + TIDList = TIDMap.getAllTrackIDs(); //Retrieve list of all available TIDs + + TIDLOOP: //Loop over all Track IDs + for(int tid : TIDList) { + track = TIDMap.getTrack(tid); //Get track with current tid + + TIMECHECKLOOP: //Loop over current and former times + for(int timecheck = time; timecheck > 0 && timecheck >= time - timeadjlimit*StepSize; timecheck -= StepSize) { + padlist = track.getTimeSlice(timecheck); //Get pads assigned to current time slice + if(!padlist.contains(pad)) { //Ensures pad isn't already assigned here + PADCHECKLOOP: //Loop over pads + for(int checkpad : padlist) { + PadVector checkpadvec = params.get_padvector(checkpad); + if(tutil.comparePads(PadVec, checkpadvec, method)) { //compares the position of two pads + track.addPad(time, pad); //assign pad to track + //TIDMap.updateTrack(tid, track); + padSorted = true; //flag set + padTIDlist.add(tid); //track the TID assigned + break TIMECHECKLOOP; //no need to continue checking previous times + } //END PAD COMPARE + + } //END PADCHECKLOOP + + } else {//pad is somehow in this time slice already so lets go ahead and add it to the current time slice + track.addPad(time, pad); + //TIDMap.updateTrack(tid, track); + padSorted = true; + padTIDlist.add(tid); + break TIMECHECKLOOP; + } + + } //END TIMECHECKLOOP + + } //END TIDLOOP + + if(!padSorted) { //we need a new TID if we get here, the pad was never assigned an ID + TIDMap.addTrack(new Track(time,pad)); + } + + if(padTIDlist.size()>1) { //if a pad gets more than 1 ID let's merge the IDs + for(int tidtemp : padTIDlist) { + if(tidtemp == padTIDlist.get(0)) { + parenttid = padTIDlist.get(0); + } else { + TIDMap.mergeTracks(parenttid, tidtemp); + } + } + } + + } //END ADC THRESH CHECK + + } //END PADLOOP + + } //END TIMELOOP + + //END MAIN ALGORITHM + + /* + * Clean up and flag tracks + */ + + for(int tid : TIDMap.getAllTrackIDs()) { //We need to remove tracks with not enough pads to save time later + Track tempt = TIDMap.getTrack(tid); + if(tempt.uniquePadCountTotal() < minhitcount) { + TIDMap.removeTrack(tid); + } + } + + //System.out.println("This event has " + TIDMap.getAllTrackIDs().size() + " tracks"); + + //TODO Flag crossing tracks; for now flag all tracks + for(int tid : TIDMap.getAllTrackIDs()) { + Track t = TIDMap.getTrack(tid); + t.flagTrack(); + } + + /* + * Output + */ + + params.set_trackmap(TIDMap); + + /* + * Drawing for debugging + * To be removed + */ + + if(draw) { + + HashMap gmapzvsphi = new HashMap(); + EmbeddedCanvas cZvsPhi = new EmbeddedCanvas(); + JFrame jZvsPhi = new JFrame(); + jZvsPhi.setSize(800,600); + + HashMap gmapphivst = new HashMap(); + EmbeddedCanvas cPhivsT = new EmbeddedCanvas(); + JFrame jPhivsT = new JFrame(); + jPhivsT.setSize(800,600); + + HashMap gmapzvst = new HashMap(); + EmbeddedCanvas cZvsT = new EmbeddedCanvas(); + JFrame jZvsT = new JFrame(); + jZvsT.setSize(800,600); + int color = 1; + int style = 1; + for(int tid : TIDMap.getAllTrackIDs()) { + Track t = TIDMap.getTrack(tid); + gmapzvsphi.put(tid, new GraphErrors()); + gmapphivst.put(tid, new GraphErrors()); + gmapzvst.put(tid, new GraphErrors()); + for(int time : t.getAllTimeSlices()) { + for(int padref : t.getTimeSlice(time)) { + PadVector p = params.get_padvector(padref); + gmapzvsphi.get(tid).addPoint(p.phi(), p.z(), 0, 0); + gmapzvst.get(tid).addPoint(time, p.z(), 0, 0); + gmapphivst.get(tid).addPoint(time, p.phi(), 0, 0); + } + } + gmapzvsphi.get(tid).setMarkerColor(color); + gmapzvsphi.get(tid).setMarkerSize(3); + gmapzvsphi.get(tid).setMarkerStyle(style); + + gmapzvst.get(tid).setMarkerColor(color); + gmapzvst.get(tid).setMarkerSize(3); + gmapzvst.get(tid).setMarkerStyle(style); + + gmapphivst.get(tid).setMarkerColor(color); + gmapphivst.get(tid).setMarkerSize(3); + gmapphivst.get(tid).setMarkerStyle(style); + + cZvsPhi.draw(gmapzvsphi.get(tid),"same"); + cZvsT.draw(gmapzvst.get(tid),"same"); + cPhivsT.draw(gmapphivst.get(tid),"same"); + + color++; + if(color > 8) { + color = 1; + style++; + } + + } + + jZvsPhi.setTitle("Track Finder Output"); + jZvsPhi.add(cZvsPhi); + jZvsPhi.setVisible(true); + + jZvsT.setTitle("Track Finder Output"); + jZvsT.add(cZvsT); + jZvsT.setVisible(true); + + jPhivsT.setTitle("Track Finder Output"); + jPhivsT.add(cPhivsT); + jPhivsT.setVisible(true); + + } + + } + +} diff --git a/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/TrackHitReco.java b/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/TrackHitReco.java new file mode 100644 index 0000000000..0a3774d91b --- /dev/null +++ b/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/TrackHitReco.java @@ -0,0 +1,528 @@ +package org.jlab.rec.rtpc.hit; + +import java.util.concurrent.ConcurrentHashMap; +import java.util.HashMap; +import java.util.List; +import java.util.Vector; + +import javax.swing.JFrame; + +import org.jlab.groot.data.GraphErrors; +import org.jlab.groot.graphics.EmbeddedCanvas; + +public class TrackHitReco { + + public void Reco(List rawHits, HitParameters params) { + HashMap>> TIDMap = params.get_TIDMap(); + HashMap ADCMap = params.get_R_adc(); + HashMap graphmap = new HashMap(); + HashMap graphmap2 = new HashMap(); + Vector TimeVec = new Vector(); + Vector XVec = new Vector(); + Vector YVec = new Vector(); + Vector ZVec = new Vector(); + Vector Pads = new Vector(); + int p = 0; + EmbeddedCanvas c = new EmbeddedCanvas(); + EmbeddedCanvas c2 = new EmbeddedCanvas(); + EmbeddedCanvas c3 = new EmbeddedCanvas(); + JFrame j = new JFrame(); + j.setSize(800,600); + JFrame j2 = new JFrame(); + j2.setSize(800,600); + JFrame j3 = new JFrame(); + j3.setSize(800,600); + Vector PadList = new Vector(); + double maxvalue = 0; + double thresh = 0; + int TrigWindSize = params.get_TrigWindSize(); + double sumnumer = 0; + double sumdenom = 0; + HashMap weightave = new HashMap(); + //System.out.println(TIDMap.size()); + //for(Hit hit : rawHits) { + for(int TID : TIDMap.keySet()){ + PadList.clear(); + + for(int time : TIDMap.get(TID).keySet()) + { + for(int pad = 0; pad < TIDMap.get(TID).get(time).size(); pad++) + { + if(!PadList.contains(TIDMap.get(TID).get(time).get(pad))) + { + PadList.add(TIDMap.get(TID).get(time).get(pad)); + } + } + } + + for(int pad = 0; pad < PadList.size(); pad++) + { + for(int time : TIDMap.get(TID).keySet()) + { + if(TIDMap.get(TID).get(time).contains(PadList.get(pad))) + { + if(ADCMap.get(PadList.get(pad))[time]>maxvalue) + { + maxvalue = ADCMap.get(PadList.get(pad))[time]; + } + } + } + thresh = maxvalue/2; + for(int time = 0; time < TrigWindSize; time++) + { + if(ADCMap.get(PadList.get(pad))[time] > thresh) + { + sumnumer += ADCMap.get(PadList.get(pad))[time]*time; + sumdenom += ADCMap.get(PadList.get(pad))[time]; + //System.out.println(PadList.get(pad) + " " + time); + } + } + + //System.out.println("weightave " + PadList.get(pad) + " " + sumnumer/sumdenom); + weightave.put(PadList.get(pad), sumnumer/sumdenom); + sumnumer = 0; + sumdenom = 0; + maxvalue = 0; + //padvec = PadCoords(PadList.get(pad)); + //gZvsT.addPoint(weightave.get(PadList.get(pad)), padvec.z(), 0, 0); + //gPhivsT.addPoint(weightave.get(PadList.get(pad)), Math.atan2(padvec.y(),padvec.x()),0,0); + } + + graphmap.put(TID, new GraphErrors()); + graphmap2.put(TID, new GraphErrors()); + //System.out.println("hqwd" + TID); + for(int t : TIDMap.get(TID).keySet()){ + for(int padindex = 0; padindex < TIDMap.get(TID).get(t).size(); padindex++){ + + + int cellID = TIDMap.get(TID).get(t).get(padindex); + Pads.add(cellID); + double Time = (double)t; + //System.out.println(Time + " " + cellID); + + + //int NEve = 10; + + double PAD_W = 2.79; // in mm + double PAD_S = 80.0; //in mm + double PAD_L = 4.0; // in mm + double RTPC_L = 384.0; // in mm + + //double Num_of_Rows = (2.0*(Math.PI)*PAD_S)/PAD_W; + double Num_of_Cols = RTPC_L/PAD_L; + //double TotChan = Num_of_Rows*Num_of_Cols; + + double PI=Math.PI; + + double z0 = -(RTPC_L/2.0); // front of RTPC in mm at the center of the pad + + double phi_per_pad = PAD_W/PAD_S; // in rad + + + + // MagBoltz parameters + double a_t=1741.179712, b_t=-1.25E+02; // for f(x)=time(radius) + double a_phi=0.161689123, b_phi=0.023505021; // for f(x)=dphi(radius) + + double t_2GEM2 = 296.082; + double t_2GEM3 = 296.131; + double t_2PAD = 399.09; + double t_gap = t_2GEM2 + t_2GEM3 + t_2PAD; + + double phi_2GEM2 = 0.0492538; + double phi_2GEM3 = 0.0470817; + double phi_2PAD = 0.0612122; + double phi_gap = phi_2GEM2 + phi_2GEM3 + phi_2PAD; + + // find postition from Cell ID + //for (double s = 0.0; s < cellID.size(); s++) { + + double chan=0; + double t_s2pad = 0; + double dphi=0; + double dz=0; + double x_rec = 0; + double y_rec = 0; + + + double z_pad=0; + double z_rec=0; + double z_hit=0; // position of the hit on a single pad in z + double delta_z=0; + + double r_pos=0; + double r_rec=0; + double r_temp=0; + double delta_r=0; + + double phi_pad=0; + double phi_rec=0; + + + + // generated position of ionization in phi + + //phi_pos = Math.atan2(Y, X); + + // generated position of ionization in s + //r_pos=Math.sqrt(((X)*(X))+((Y)*(Y))); + + + // ------------------ find z and phi of pad from CellID ------------------ + chan = (double)cellID; + + double col = chan%Num_of_Cols; + double row=(chan-col)/Num_of_Cols; + double z_shift = row%4; + //double z_shift = 0.; + + phi_pad=(row*phi_per_pad)+(phi_per_pad/2.0); + if(phi_pad>= 2.0*PI) { + phi_pad -= 2.0*PI; + } + if(phi_pad<0) + { + phi_pad += 2.0*PI; + } + + z_pad=z0+(col*PAD_L)+(PAD_L/2.0)+z_shift; + // ----------------------------------------------------------------------- + + + // find reconstructed position of ionization from Time info + + t_s2pad = Time-t_gap; + + r_rec=((-(Math.sqrt(a_t*a_t+(4.*b_t*t_s2pad)))+a_t+(14.*b_t))/(2.*b_t))*10.0; //in mm + + + dphi=a_phi*(7.-r_rec/10.)+b_phi*(7.-r_rec/10.)*(7.-r_rec/10.); // in rad + + + dz=0; + + phi_rec=phi_pad-dphi-phi_gap; + if( phi_rec<0.0 ) + { + phi_rec+=2.0*PI; + } + if( phi_rec>2.0*PI ) + { + phi_rec-=2.0*PI; + } + + // x,y,z pos of reconstructed track + x_rec=r_rec*(Math.cos(phi_rec)); + y_rec=r_rec*(Math.sin(phi_rec)); + z_rec=z_pad-dz; + //if(r_rec > 30 && r_rec < 70) + //{ + graphmap.get(TID).addPoint(r_rec, z_rec, 0, 0); + graphmap2.get(TID).addPoint(x_rec, y_rec, 0, 0); + + //} + // x,y,z pos of pad hit + //x_pad=(PAD_S)*(Math.cos(phi_pad)); + //y_pad=(PAD_S)*(Math.sin(phi_pad)); + + // actual position on pad of hits + //phi_hit=phi_rad-(row*phi_per_pad); + //z_hit=Z-z0-(col*PAD_L)-z_shift; + + // find differences (delta = generated-reconstructed) + //delta_x=X-x_rec; + //delta_y=Y-y_rec; + //delta_z=Z-z_rec; + //delta_r=r_pos-r_rec; + //delta_phi = phi_pos-phi_rec; + + + + + /*hit.set_cellID(cellID); + hit.set_Time(t_s2pad); + hit.set_Edep(Edep); + hit.set_PosX(x_rec); + hit.set_PosY(y_rec); + hit.set_PosZ(z_rec); + TimeVec.add(t_s2pad); + XVec.add(x_rec); + YVec.add(y_rec); + ZVec.add(z_rec);*/ + + + } + } + } + GraphErrors grz = new GraphErrors(); + GraphErrors g1rz = new GraphErrors(); + GraphErrors gxy = new GraphErrors(); + GraphErrors g1xy = new GraphErrors(); + GraphErrors gerrorxvsphi = new GraphErrors(); + GraphErrors gerroryvsphi = new GraphErrors(); + int counter = 1; + for(Hit hit : rawHits) + { + if(true) { + int cellID = hit.get_cellID(); + double Time = hit.get_Time(); + double X = hit.get_PosXTrue(); + double Y = hit.get_PosYTrue(); + double Z = hit.get_PosZTrue(); + + //if(Pads.contains(cellID)) + //{ + //ystem.out.println(Time + " " + cellID); + + + //int NEve = 10; + + double PAD_W = 2.79; // in mm + double PAD_S = 80.0; //in mm + double PAD_L = 4.0; // in mm + double RTPC_L = 384.0; // in mm + + //double Num_of_Rows = (2.0*(Math.PI)*PAD_S)/PAD_W; + double Num_of_Cols = RTPC_L/PAD_L; + //double TotChan = Num_of_Rows*Num_of_Cols; + + double PI=Math.PI; + + double z0 = -(RTPC_L/2.0); // front of RTPC in mm at the center of the pad + + double phi_per_pad = PAD_W/PAD_S; // in rad + + + + // MagBoltz parameters + double a_t=1741.179712, b_t=-125; // for f(x)=time(radius) + double a_phi=0.161689123, b_phi=0.023505021; // for f(x)=dphi(radius) + + double t_2GEM2 = 296.082; + double t_2GEM3 = 296.131; + double t_2PAD = 399.09; + double t_gap = t_2GEM2 + t_2GEM3 + t_2PAD; + + double phi_2GEM2 = 0.0492538; + double phi_2GEM3 = 0.0470817; + double phi_2PAD = 0.0612122; + double phi_gap = phi_2GEM2 + phi_2GEM3 + phi_2PAD; + + // find position from Cell ID + //for (double s = 0.0; s < cellID.size(); s++) { + + double chan=0; + double t_s2pad = 0; + double dphi=0; + double dz=0; + double x_rec = 0; + double y_rec = 0; + + + double z_pad=0; + double z_rec=0; + double z_hit=0; // position of the hit on a single pad in z + double delta_z=0; + + double r_pos=0; + double r_rec=0; + double r_temp=0; + double delta_r=0; + + double phi_pad=0; + double phi_rec=0; + double phi_pos = 0; + + + // generated position of ionization in phi + + phi_pos = Math.atan2(Y, X); + + // generated position of ionization in s + r_pos=Math.sqrt(((X)*(X))+((Y)*(Y))); + + + // ------------------ find z and phi of pad from CellID ------------------ + chan = (double)cellID; + + double col = chan%Num_of_Cols; + double row=(chan-col)/Num_of_Cols; + double z_shift = row%4; + //double z_shift = 0.; + //System.out.println(row + " " + chan + " " + col + " " + phi_per_pad); + phi_pad=(row*phi_per_pad)+(phi_per_pad/2.0); + while(phi_pad >= 2*PI || phi_pad < 0) + { + if(phi_pad>= 2.0*PI) { + phi_pad -= 2.0*PI; + } + if(phi_pad<0) + { + phi_pad += 2.0*PI; + } + } + z_pad=z0+(col*PAD_L)+(PAD_L/2.0)+z_shift; + // ----------------------------------------------------------------------- + + + // find reconstructed position of ionization from Time info + + t_s2pad = Time-t_gap; + + r_rec=((-(Math.sqrt(a_t*a_t+(4*b_t*t_s2pad)))+a_t+(14*b_t))/(2*b_t))*10.0; //in mm + + + dphi=a_phi*(7-r_rec/10)+b_phi*(7-r_rec/10)*(7.-r_rec/10); // in rad + + + dz=0; + + phi_rec=phi_pad-dphi-phi_gap; + while(phi_rec < 0 || phi_rec >= 2*PI) + { + if( phi_rec<0.0 ) + { + phi_rec+=2.0*PI; + } + if( phi_rec>2.0*PI ) + { + phi_rec-=2.0*PI; + } + } + //System.out.println("reconstructed phi " + phi_rec + " actual phi " + Math.atan(Y/X)); + + // x,y,z pos of reconstructed track + x_rec=r_rec*(Math.cos(phi_rec)); + y_rec=r_rec*(Math.sin(phi_rec)); + z_rec=z_pad-dz; + //if(true) + //if(counter > 2500) + //if(z_rec > 160 && r_rec > 30 && r_rec < 55 && z_rec < 195) + if(true)//if(Math.abs(x_rec-X) < 3 && Math.abs(y_rec-Y) < 3 && Math.abs(z_rec-Z) < 3) + { + grz.addPoint(r_rec, z_rec, 0, 0); + gxy.addPoint(x_rec, y_rec, 0, 0); + //if(counter <= 53) + //{ + g1rz.addPoint(Math.sqrt(X*X+Y*Y), Z, 0, 0); + g1xy.addPoint(X, Y, 0, 0); + gerrorxvsphi.addPoint(Math.atan2(Y,X),Math.pow(Math.abs(x_rec-X),2)/X,0,0); + gerroryvsphi.addPoint(Math.atan2(Y,X),Math.pow(Math.abs(y_rec-Y),2)/Y,0,0); + //} + //System.out.println(counter); + } + else + { + grz.addPoint(0, 0, 0, 0); + g1rz.addPoint(0, 0, 0, 0); + gxy.addPoint(0, 0, 0, 0); + g1xy.addPoint(0, 0, 0, 0); + } + //} + // x,y,z pos of pad hit + //x_pad=(PAD_S)*(Math.cos(phi_pad)); + //y_pad=(PAD_S)*(Math.sin(phi_pad)); + + // actual position on pad of hits + //phi_hit=phi_rad-(row*phi_per_pad); + //z_hit=Z-z0-(col*PAD_L)-z_shift; + + // find differences (delta = generated-reconstructed) + //delta_x=X-x_rec; + //delta_y=Y-y_rec; + //delta_z=Z-z_rec; + //delta_r=r_pos-r_rec; + //delta_phi = phi_pos-phi_rec; + //System.out.println(X + " " + x_rec); + //System.out.println(r_pos + " " + r_rec); + + + + /*hit.set_cellID(cellID); + hit.set_Time(t_s2pad); + hit.set_Edep(Edep); + hit.set_PosX(x_rec); + hit.set_PosY(y_rec); + hit.set_PosZ(z_rec); + TimeVec.add(t_s2pad); + XVec.add(x_rec); + YVec.add(y_rec); + ZVec.add(z_rec);*/ + //} + counter++; + } + } + //System.out.println(counter); + GraphErrors g2 = new GraphErrors(); + double theta = 0; + double test_x = 0; + double test_y = 0; + double test_x2 = 0; + double test_y2 = 0; + while(theta <= 2*Math.PI) + { + test_x = 30 * Math.cos(theta); + test_y = 30 * Math.sin(theta); + test_x2 = 70 * Math.cos(theta); + test_y2 = 70 * Math.sin(theta); + g2.addPoint(test_x, test_y, 0, 0); + g2.addPoint(test_x2, test_y2, 0, 0); + theta+=0.01; + } + + for(int key : TIDMap.keySet()) + { + if(false) + //if(key == 1) + { + graphmap.get(key).setMarkerSize(6); + graphmap2.get(key).setMarkerSize(6); + } + else { + graphmap.get(key).setMarkerSize(2); + graphmap.get(key).setMarkerColor(4); + graphmap.get(key).setMarkerStyle(2); + + + graphmap2.get(key).setMarkerSize(2); + graphmap2.get(key).setMarkerColor(4); + graphmap2.get(key).setMarkerStyle(2); + } + c.draw(graphmap.get(key),"same"); + c2.draw(graphmap2.get(key),"same"); + + } + grz.setMarkerSize(3); + grz.setMarkerColor(1); + g1rz.setMarkerSize(1); + g1rz.setMarkerColor(5); + //grz.addPoint(30, -200, 0, 0); + //grz.addPoint(70, 200, 0, 0); + gxy.setMarkerSize(4); + gxy.setMarkerColor(2); + g1xy.setMarkerSize(0); + g1xy.setMarkerColor(5); + g2.setMarkerSize(0); + g2.setMarkerColor(3); + gerrorxvsphi.setMarkerSize(2); + gerroryvsphi.setMarkerSize(2); + c.draw(grz,"same"); + c.draw(g1rz,"same"); + c2.draw(gxy,"same"); + c2.draw(g1xy,"same"); + c2.draw(g2,"same"); + c3.divide(1, 2); + c3.cd(0); + c3.draw(gerrorxvsphi); + c3.cd(1); + c3.draw(gerroryvsphi); + j.setTitle("RZ"); + j2.setTitle("XY"); + j.add(c); + j.setVisible(true); + j2.add(c2); + j2.setVisible(true); + //j3.add(c3); + //j3.setVisible(true); + } +} diff --git a/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/TrackHitReco2.java b/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/TrackHitReco2.java new file mode 100644 index 0000000000..e65fa78d93 --- /dev/null +++ b/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/TrackHitReco2.java @@ -0,0 +1,714 @@ +package org.jlab.rec.rtpc.hit; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.concurrent.ConcurrentHashMap; +import java.util.HashMap; +import java.util.List; +import java.util.Vector; + +import javax.swing.JFrame; + +import org.jlab.clas.physics.Vector3; +import org.jlab.groot.data.GraphErrors; +import org.jlab.groot.data.H1F; +import org.jlab.groot.graphics.EmbeddedCanvas; +import org.jlab.rec.rtpc.hit.RecoHitVector; + +public class TrackHitReco2 { + + public void Reco(List rawHits, HitParameters params, boolean draw) { + HashMap>> TIDMap = params.get_strkTIDMap(); + HashMap ADCMap = params.get_R_adc(); + HashMap graphmap = new HashMap(); + HashMap graphmap2 = new HashMap(); + HashMap> alltracks = params.get_alltracks(); + HashMap largetmap = params.get_largetmap(); + HashMap tdiffmap = new HashMap(); + HashMap> recohitvector = new HashMap>(); + Vector TimeVec = new Vector(); + Vector XVec = new Vector(); + Vector YVec = new Vector(); + Vector ZVec = new Vector(); + Vector Pads = new Vector(); + int p = 0; + EmbeddedCanvas c = new EmbeddedCanvas(); + EmbeddedCanvas c2 = new EmbeddedCanvas(); + EmbeddedCanvas c3 = new EmbeddedCanvas(); + EmbeddedCanvas c4 = new EmbeddedCanvas(); + JFrame j = new JFrame(); + j.setSize(800,600); + JFrame j2 = new JFrame(); + j2.setSize(800,600); + JFrame j3 = new JFrame(); + j3.setSize(800,600); + JFrame j4 = new JFrame(); + j4.setSize(800,600); + + double a_t1 = -2.48491E-4; + double a_t2 = 2.21413E-4; + double a_t3 = -3.11195E-3; + double a_t4 = -2.75206E-1; + double a_t5 = 1.74281E3; + + double b_t1 = 2.48873E-5; + double b_t2 = -1.19976E-4; + double b_t3 = -3.75962E-3; + double b_t4 = 5.33100E-2; + double b_t5 = -1.25647E2; + + double a_phi1 = -3.32718E-8; + double a_phi2 = 1.92110E-7; + double a_phi3 = 2.16919E-6; + double a_phi4 = -8.10207E-5; + double a_phi5 = 1.68481E-1; + + double b_phi1 = -3.23019E-9; + double b_phi2 = -6.92075E-8; + double b_phi3 = 1.24731E-5; + double b_phi4 = 2.57684E-5; + double b_phi5 = 2.10680E-2; + + H1F largetdist = new H1F("largetdist",100,0,10000); + + double timewindow = 2000; + double smalltcut = 300; + double largetcut = 8000; + int tracksizecut = 4; + double larget = 0; + double tdiff = 0; + double Time = 0; + int cellID = 0; + int outsidedriftcounter = 0; + int allhitscounter = 0; + /*Vector PadList = new Vector(); + double maxvalue = 0; + double thresh = 0; + int TrigWindSize = params.get_TrigWindSize(); + double sumnumer = 0; + double sumdenom = 0; + int count = 0;*/ + + //HashMap weightave = new HashMap(); + //System.out.println(TIDMap.size()); + //for(Hit hit : rawHits) { + //for(int TID : TIDMap.keySet()){ + //System.out.println(alltracks.size() + " " + alltracks.get(1).size()); + for(int TID : alltracks.keySet()) { + Pads.clear(); + /*PadList.clear(); + + double larget = 0; + for(int time : TIDMap.get(TID).keySet()) + { + for(int pad = 0; pad < TIDMap.get(TID).get(time).size(); pad++) + { + if(!PadList.contains(TIDMap.get(TID).get(time).get(pad))) + { + PadList.add(TIDMap.get(TID).get(time).get(pad)); + } + } + } + + for(int pad = 0; pad < PadList.size(); pad++) + { + for(int time : TIDMap.get(TID).keySet()) + { + if(TIDMap.get(TID).get(time).contains(PadList.get(pad))) + { + if(ADCMap.get(PadList.get(pad))[time]>maxvalue) + { + maxvalue = ADCMap.get(PadList.get(pad))[time]; + } + } + } + thresh = maxvalue/2; + for(int time = 0; time < TrigWindSize; time++) + { + if(ADCMap.get(PadList.get(pad))[time] > thresh) + { + sumnumer += ADCMap.get(PadList.get(pad))[time]*time; + sumdenom += ADCMap.get(PadList.get(pad))[time]; + //System.out.println(PadList.get(pad) + " " + time); + } + } + if(sumnumer/sumdenom >= larget) + { + larget = sumnumer/sumdenom; + } + //System.out.println("weightave " + PadList.get(pad) + " " + sumnumer/sumdenom); + weightave.put(PadList.get(pad), sumnumer/sumdenom); + sumnumer = 0; + sumdenom = 0; + maxvalue = 0; + //padvec = PadCoords(PadList.get(pad)); + //gZvsT.addPoint(weightave.get(PadList.get(pad)), padvec.z(), 0, 0); + //gPhivsT.addPoint(weightave.get(PadList.get(pad)), Math.atan2(padvec.y(),padvec.x()),0,0); + }*/ + //System.out.println("large t " + larget); + larget = largetmap.get(TID); + double smallt = 1000000; + for(int i = 0; i < alltracks.get(TID).size(); i ++) + { + if(alltracks.get(TID).get(i).time() < smallt) {smallt = alltracks.get(TID).get(i).time();} + } + //double smallt = alltracks.get(TID).get(alltracks.get(TID).size()-1).time(); + + + /*try { + File f = new File("/Users/davidpayette/Documents/FileOutput/smallt.txt"); + //f.delete(); + FileWriter out = new FileWriter("/Users/davidpayette/Documents/FileOutput/smallt.txt",true); + out.write(smallt + "\n"); + out.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + }*/ + largetdist.fill(larget); + //System.out.println("large t is " + larget); + //if(TID != 2) {continue;} + //System.out.println(smallt + " small t"); + if(smallt < smalltcut || larget > largetcut || alltracks.get(TID).size() <= tracksizecut) {continue;} + //add smallt check as well for smallt too small + + graphmap.put(TID, new GraphErrors()); + graphmap2.put(TID, new GraphErrors()); + + tdiff = 6000 - larget; + //if(larget + tdiff > 7500) {continue;} + tdiffmap.put(TID, tdiff); + recohitvector.put(TID, new Vector()); + + //tdiff = 0; + //System.out.println("hqwd" + TID); + //for(int cellID : weightave.keySet()){ + //System.out.println("large t " + larget); + for(int k = 0; k < alltracks.get(TID).size(); k++) { + //for(int padindex = 0; padindex < TIDMap.get(TID).get(t).size(); padindex++){ + + allhitscounter++; + //int cellID = TIDMap.get(TID).get(t).get(padindex); + cellID = (int)alltracks.get(TID).get(k).pad(); + if(!Pads.contains(cellID)) { + Pads.add(cellID); + } + //double Time = weightave.get(cellID); + Time = alltracks.get(TID).get(k).time(); + //System.out.println("reco " + Time); + //System.out.println("tdiff " + tdiff); + Time+=tdiff; + + //System.out.println(Time + " " + cellID); + + + //int NEve = 10; + + double PAD_W = 2.79; // in mm + double PAD_S = 80.0; //in mm + double PAD_L = 4.0; // in mm + double RTPC_L = 384.0; // in mm + + //double Num_of_Rows = (2.0*(Math.PI)*PAD_S)/PAD_W; + double Num_of_Cols = RTPC_L/PAD_L; + //double TotChan = Num_of_Rows*Num_of_Cols; + + double PI=Math.PI; + + double z0 = -(RTPC_L/2.0); // front of RTPC in mm at the center of the pad + + double phi_per_pad = PAD_W/PAD_S; // in rad + + + + // MagBoltz parameters + //double a_t=1741.179712, b_t=-1.25E+02; // for f(x)=time(radius) + //double a_phi=0.161689123, b_phi=0.023505021; // for f(x)=dphi(radius) + + double t_2GEM2 = 296.082; + double t_2GEM3 = 296.131; + double t_2PAD = 399.09; + double t_gap = t_2GEM2 + t_2GEM3 + t_2PAD; + + double phi_2GEM2 = 0.0492538; + double phi_2GEM3 = 0.0470817; + double phi_2PAD = 0.0612122; + double phi_gap = phi_2GEM2 + phi_2GEM3 + phi_2PAD; + + // find postition from Cell ID + //for (double s = 0.0; s < cellID.size(); s++) { + + double chan=0; + double t_s2pad = 0; + double dphi=0; + double dz=0; + double x_rec = 0; + double y_rec = 0; + + + double z_pad=0; + double z_rec=0; + double z_hit=0; // position of the hit on a single pad in z + double delta_z=0; + + double r_pos=0; + double r_rec=0; + double r_temp=0; + double delta_r=0; + + double phi_pad=0; + double phi_rec=0; + + + + // generated position of ionization in phi + + //phi_pos = Math.atan2(Y, X); + + // generated position of ionization in s + //r_pos=Math.sqrt(((X)*(X))+((Y)*(Y))); + + + // ------------------ find z and phi of pad from CellID ------------------ + chan = (double)cellID; + + double col = chan%Num_of_Cols; + double row=(chan-col)/Num_of_Cols; + double z_shift = row%4; + //double z_shift = 0.; + + phi_pad=(row*phi_per_pad)+(phi_per_pad/2.0); + if(phi_pad>= 2.0*PI) { + phi_pad -= 2.0*PI; + } + if(phi_pad<0) + { + phi_pad += 2.0*PI; + } + + z_pad=z0+(col*PAD_L)+(PAD_L/2.0)+z_shift; + // ----------------------------------------------------------------------- + dz=0; + z_rec=z_pad-dz; + + // find reconstructed position of ionization from Time info + + t_s2pad = Time-t_gap; + //if(t_s2pad > 6000) {System.out.println("oooops");} + //System.out.println("time stuff " + t_s2pad + " " + Time); + + double a_t = get_rec_coef(a_t1,a_t2,a_t3,a_t4,a_t5,z_rec); + double b_t = get_rec_coef(b_t1,b_t2,b_t3,b_t4,b_t5,z_rec); + + r_rec=((-(Math.sqrt(a_t*a_t+(4.*b_t*t_s2pad)))+a_t+(14.*b_t))/(2.*b_t))*10.0; //in mm + + double a_phi = get_rec_coef(a_phi1,a_phi2,a_phi3,a_phi4,a_phi5,z_rec); + double b_phi = get_rec_coef(b_phi1,b_phi2,b_phi3,b_phi4,b_phi5,z_rec); + + dphi=a_phi*(7.-r_rec/10.)+b_phi*(7.-r_rec/10.)*(7.-r_rec/10.); // in rad + //System.out.println("r and phi " + r_rec + " " + dphi); + + + //System.out.println("phi stuff " + phi_pad + " " + dphi + " " + phi_gap); + phi_rec=phi_pad-dphi-phi_gap; + if( phi_rec<0.0 ) + { + phi_rec+=2.0*PI; + } + if( phi_rec>2.0*PI ) + { + phi_rec-=2.0*PI; + } + if(r_rec > 70 || r_rec < 30) + { + outsidedriftcounter++; + } + // x,y,z pos of reconstructed track + x_rec=r_rec*(Math.cos(phi_rec)); + y_rec=r_rec*(Math.sin(phi_rec)); + + + recohitvector.get(TID).add(new RecoHitVector(cellID,x_rec,y_rec,z_rec,tdiff,Time)); + //if(r_rec > 30 && r_rec < 70) + //{ + graphmap.get(TID).addPoint(r_rec, z_rec, 0, 0); + graphmap2.get(TID).addPoint(x_rec, y_rec, 0, 0); + + + + //System.out.println("TID time phi x y " + TID + " " + Time + " " + phi_rec + " " + x_rec + " " + y_rec); + //} + // x,y,z pos of pad hit + //x_pad=(PAD_S)*(Math.cos(phi_pad)); + //y_pad=(PAD_S)*(Math.sin(phi_pad)); + + // actual position on pad of hits + //phi_hit=phi_rad-(row*phi_per_pad); + //z_hit=Z-z0-(col*PAD_L)-z_shift; + + // find differences (delta = generated-reconstructed) + //delta_x=X-x_rec; + //delta_y=Y-y_rec; + //delta_z=Z-z_rec; + //delta_r=r_pos-r_rec; + //delta_phi = phi_pos-phi_rec; + + + + + /*hit.set_cellID(cellID); + hit.set_Time(t_s2pad); + hit.set_Edep(Edep); + hit.set_PosX(x_rec); + hit.set_PosY(y_rec); + hit.set_PosZ(z_rec); + TimeVec.add(t_s2pad); + XVec.add(x_rec); + YVec.add(y_rec); + ZVec.add(z_rec);*/ + + + + } + //System.out.println("num of pads " + Pads.size()); + } + GraphErrors grz = new GraphErrors(); + GraphErrors g1rz = new GraphErrors(); + GraphErrors gxy = new GraphErrors(); + GraphErrors g1xy = new GraphErrors(); + GraphErrors g2xy = new GraphErrors(); + GraphErrors gerrorxvsphi = new GraphErrors(); + GraphErrors gerroryvsphi = new GraphErrors(); + int counter = 1; + + for(Hit hit : rawHits) + { + if(true) { + cellID = hit.get_cellID(); + + Time = hit.get_Time(); + //double T_noshift = Time; + if(Time <= 0) {continue;} + Time -= hit.get_TShift(); + //System.out.println("Time " + hit.get_Time() + " " + hit.get_TShift()); + + double X = hit.get_PosXTrue(); + double Y = hit.get_PosYTrue(); + double Z = hit.get_PosZTrue(); + //double TimeNoShift = Time - hit.get_TShift(); + //if(Pads.contains(cellID)) + //{ + //ystem.out.println(Time + " " + cellID); + + + //int NEve = 10; + + double PAD_W = 2.79; // in mm + double PAD_S = 80.0; //in mm + double PAD_L = 4.0; // in mm + double RTPC_L = 384.0; // in mm + + //double Num_of_Rows = (2.0*(Math.PI)*PAD_S)/PAD_W; + double Num_of_Cols = RTPC_L/PAD_L; + //double TotChan = Num_of_Rows*Num_of_Cols; + + double PI=Math.PI; + + double z0 = -(RTPC_L/2.0); // front of RTPC in mm at the center of the pad + + double phi_per_pad = PAD_W/PAD_S; // in rad + + + + // MagBoltz parameters + //double a_t=1741.179712, b_t=-125; // for f(x)=time(radius) + //double a_phi=0.161689123, b_phi=0.023505021; // for f(x)=dphi(radius) + + double t_2GEM2 = 296.082; + double t_2GEM3 = 296.131; + double t_2PAD = 399.09; + double t_gap = t_2GEM2 + t_2GEM3 + t_2PAD; + + double phi_2GEM2 = 0.0492538; + double phi_2GEM3 = 0.0470817; + double phi_2PAD = 0.0612122; + double phi_gap = phi_2GEM2 + phi_2GEM3 + phi_2PAD; + + // find position from Cell ID + //for (double s = 0.0; s < cellID.size(); s++) { + + double chan=0; + double t_s2pad = 0; + double dphi=0; + double dz=0; + double x_rec = 0; + double y_rec = 0; + + + double z_pad=0; + double z_rec=0; + double z_hit=0; // position of the hit on a single pad in z + double delta_z=0; + + double r_pos=0; + double r_rec=0; + double r_temp=0; + double delta_r=0; + + double phi_pad=0; + double phi_rec=0; + double phi_pos = 0; + + double t_calc = 0; + + + + // generated position of ionization in phi + + phi_pos = Math.atan2(Y, X); + + // generated position of ionization in s + r_pos=Math.sqrt(((X)*(X))+((Y)*(Y))); + //System.out.println(r_pos + " " + X + " " + Y); + + + // ------------------ find z and phi of pad from CellID ------------------ + chan = (double)cellID; + + double col = chan%Num_of_Cols; + double row=(chan-col)/Num_of_Cols; + double z_shift = row%4; + //double z_shift = 0.; + //System.out.println(row + " " + chan + " " + col + " " + phi_per_pad); + phi_pad=(row*phi_per_pad)+(phi_per_pad/2.0); + while(phi_pad >= 2*PI || phi_pad < 0) + { + if(phi_pad>= 2.0*PI) { + phi_pad -= 2.0*PI; + } + if(phi_pad<0) + { + phi_pad += 2.0*PI; + } + } + z_pad=z0+(col*PAD_L)+(PAD_L/2.0)+z_shift; + // ----------------------------------------------------------------------- + dz=0; + z_rec=z_pad-dz; + + // find reconstructed position of ionization from Time info + + double a_t = get_rec_coef(a_t1,a_t2,a_t3,a_t4,a_t5,z_rec); + double b_t = get_rec_coef(b_t1,b_t2,b_t3,b_t4,b_t5,z_rec); + + + + double a_phi = get_rec_coef(a_phi1,a_phi2,a_phi3,a_phi4,a_phi5,z_rec); + double b_phi = get_rec_coef(b_phi1,b_phi2,b_phi3,b_phi4,b_phi5,z_rec); + + //System.out.println(a_t + " " + b_t + " " + a_phi + " " + b_phi + " " + z_rec); + + t_s2pad = Time-t_gap; + + r_rec = ((-(Math.sqrt(a_t*a_t+(4*b_t*t_s2pad)))+a_t+(14*b_t))/(2*b_t))*10.0; //in mm + t_calc = ((((2*b_t*r_pos*0.1)-(14*b_t)-a_t)*((2*b_t*r_pos*0.1)-14*b_t-a_t))-(a_t*a_t))*(1/(4*b_t)) + t_gap; + + + dphi=a_phi*(7-r_rec/10)+b_phi*(7-r_rec/10)*(7.-r_rec/10); // in rad + + + phi_rec=phi_pad-dphi-phi_gap; + while(phi_rec < 0 || phi_rec >= 2*PI) + { + if( phi_rec<0.0 ) + { + phi_rec+=2.0*PI; + } + if( phi_rec>2.0*PI ) + { + phi_rec-=2.0*PI; + } + } + //System.out.println("reconstructed phi " + phi_rec + " actual phi " + Math.atan(Y/X)); + + // x,y,z pos of reconstructed track + x_rec=r_rec*(Math.cos(phi_rec)); + y_rec=r_rec*(Math.sin(phi_rec)); + //System.out.println("rec " + x_rec + " " + y_rec + " " + phi_rec + " " + r_rec + " " + Time); + //if(true) + //if(counter > 2500) + //if(r_rec > 30 && r_rec < 70) + //if(Math.abs(x_rec-X) < 3 && Math.abs(y_rec-Y) < 3 && Math.abs(z_rec-Z) < 3) + //if(true) + //if(Math.abs(t_calc - Time) < timewindow) + if(hit.get_TShift() == 0) + { + //System.out.println(t_calc + " " + Time); + grz.addPoint(r_rec, z_rec, 0, 0); + gxy.addPoint(x_rec, y_rec, 0, 0); + //if(counter <= 53) + //{ + g1rz.addPoint(Math.sqrt(X*X+Y*Y), Z, 0, 0); + g1xy.addPoint(X, Y, 0, 0); + g2xy.addPoint(0, 0, 0, 0); + gerrorxvsphi.addPoint(Math.atan2(Y,X),Math.pow(Math.abs(x_rec-X),2)/X,0,0); + gerroryvsphi.addPoint(Math.atan2(Y,X),Math.pow(Math.abs(y_rec-Y),2)/Y,0,0); + //} + //System.out.println(counter); + } + else + { + //g2xy.addPoint(X, Y, 0, 0); + g2xy.addPoint(0, 0, 0, 0); + grz.addPoint(0, 0, 0, 0); + g1rz.addPoint(0, 0, 0, 0); + gxy.addPoint(0, 0, 0, 0); + g1xy.addPoint(0, 0, 0, 0); + } + //} + // x,y,z pos of pad hit + //x_pad=(PAD_S)*(Math.cos(phi_pad)); + //y_pad=(PAD_S)*(Math.sin(phi_pad)); + + // actual position on pad of hits + //phi_hit=phi_rad-(row*phi_per_pad); + //z_hit=Z-z0-(col*PAD_L)-z_shift; + + // find differences (delta = generated-reconstructed) + //delta_x=X-x_rec; + //delta_y=Y-y_rec; + //delta_z=Z-z_rec; + //delta_r=r_pos-r_rec; + //delta_phi = phi_pos-phi_rec; + //System.out.println(X + " " + x_rec); + //System.out.println(r_pos + " " + r_rec); + + + + /*hit.set_cellID(cellID); + hit.set_Time(t_s2pad); + hit.set_Edep(Edep); + hit.set_PosX(x_rec); + hit.set_PosY(y_rec); + hit.set_PosZ(z_rec); + TimeVec.add(t_s2pad); + XVec.add(x_rec); + YVec.add(y_rec); + ZVec.add(z_rec);*/ + //} + counter++; + } + } + //System.out.println(counter); + GraphErrors g2 = new GraphErrors(); + double theta = 0; + double test_x = 0; + double test_y = 0; + double test_x2 = 0; + double test_y2 = 0; + while(theta <= 2*Math.PI) + { + test_x = 30 * Math.cos(theta); + test_y = 30 * Math.sin(theta); + test_x2 = 70 * Math.cos(theta); + test_y2 = 70 * Math.sin(theta); + g2.addPoint(test_x, test_y, 0, 0); + g2.addPoint(test_x2, test_y2, 0, 0); + theta+=0.01; + } + int color = 2; + int shape = 1; + for(int key : graphmap.keySet()) + { + double szPos[][] = new double[recohitvector.get(key).size()][3]; + for(int i = 0; i < recohitvector.get(key).size(); i++) { + szPos[i][0] = recohitvector.get(key).get(i).x(); + szPos[i][1] = recohitvector.get(key).get(i).y(); + szPos[i][2] = recohitvector.get(key).get(i).z(); + } + //double R = 0; double A = 0; double B = 0; double Phi_deg = 0; double Theta_deg = 0; double Z0 = 0; int fit_track_to_beamline = 1; + //HelixFitJava hf = new HelixFitJava(); + //hf.HelixFit(recohitvector.get(key).size(), szPos, R, A, B, Phi_deg, Theta_deg, Z0, fit_track_to_beamline); + //System.out.println(key + " " + R); + if(false) + //if(key == 3) + { + graphmap.get(key).setMarkerSize(6); + graphmap2.get(key).setMarkerSize(6); + } + else { + graphmap.get(key).setMarkerSize(3); + graphmap.get(key).setMarkerColor(color); + graphmap.get(key).setMarkerStyle(shape); + + + graphmap2.get(key).setMarkerSize(3); + graphmap2.get(key).setMarkerColor(color); + graphmap2.get(key).setMarkerStyle(shape); + + } + //c.draw(graphmap.get(key),"same"); + //c2.draw(graphmap2.get(key),"same"); + color++; + if(color > 7) + { + color -= 6; + shape++; + } + } + grz.setMarkerSize(3); + grz.setMarkerColor(1); + g1rz.setMarkerSize(2); + g1rz.setMarkerColor(2); + //grz.addPoint(30, -200, 0, 0); + //grz.addPoint(70, 200, 0, 0); + gxy.setMarkerSize(2); + gxy.setMarkerColor(2); + g1xy.setMarkerSize(2); + g1xy.setMarkerColor(1); + g2xy.setMarkerSize(2); + g2xy.setMarkerColor(7); + g2.setMarkerSize(0); + g2.setMarkerColor(3); + gerrorxvsphi.setMarkerSize(2); + gerroryvsphi.setMarkerSize(2); + c.draw(grz,"same"); + c.draw(g1rz,"same"); + c2.draw(gxy,"same"); + c2.draw(g1xy,"same"); + c2.draw(g2,"same"); + c2.draw(g2xy,"same"); + c3.divide(1, 2); + c3.cd(0); + c3.draw(gerrorxvsphi); + c3.cd(1); + c3.draw(gerroryvsphi); + c4.draw(largetdist); + j.setTitle("RZ"); + j2.setTitle("XY"); + if(draw == true) { + j.add(c); + j.setVisible(true); + j2.add(c2); + j2.setVisible(true); + //j3.add(c3); + //j3.setVisible(true); + j4.add(c4); + //j4.setVisible(true); + } + + //System.out.println(outsidedriftcounter + "/" + allhitscounter); + params.set_alltracks(alltracks); + params.set_recohitvector(recohitvector); + } + + double get_rec_coef(double t1, double t2, double t3, double t4, double t5, double z2) { + double z = z2/1000; + return t1*z*z*z*z + t2*z*z*z + t3*z*z + t4*z + t5; + + } + + +} diff --git a/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/TrackHitReco3.java b/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/TrackHitReco3.java new file mode 100644 index 0000000000..de93d85a77 --- /dev/null +++ b/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/TrackHitReco3.java @@ -0,0 +1,649 @@ +//Author: David Payette and Nate Dzbenski + +/* This code takes the time-reduced tracks produced by the Time Average, as well as the original hits + * and uses a fit formula from garfield++ to calculate the hit's position in the drift region + * based on the time of the signal. We use the original hits to see how well the formula performs + * when we include factors such as time shifts and non-uniform magnetic fields + */ + +package org.jlab.rec.rtpc.hit; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Vector; +import java.util.concurrent.ConcurrentHashMap; + +import javax.swing.JFrame; + +import org.jlab.clas.physics.Vector3; +import org.jlab.groot.data.GraphErrors; +import org.jlab.groot.data.H1F; +import org.jlab.groot.graphics.EmbeddedCanvas; +import org.jlab.rec.rtpc.hit.RecoHitVector; + +public class TrackHitReco3 { + + public TrackHitReco3(List rawHits, HitParameters params, boolean draw) { + /* + HashMap graphmap = new HashMap(); + HashMap graphmap2 = new HashMap(); + */ + HashMap> alltracks = params.get_alltracks(); + HashMap largetmap = params.get_largetmap(); + HashMap tdiffmap = new HashMap(); + HashMap> recohitvector = new HashMap>(); + ReducedTrackMap RTIDMap = params.get_rtrackmap(); + Vector TimeVec = new Vector(); + Vector XVec = new Vector(); + Vector YVec = new Vector(); + Vector ZVec = new Vector(); + Vector Pads = new Vector(); + int p = 0; + + double a_t1 = -2.48491E-4; + double a_t2 = 2.21413E-4; + double a_t3 = -3.11195E-3; + double a_t4 = -2.75206E-1; + double a_t5 = 1.74281E3; + + double b_t1 = 2.48873E-5; + double b_t2 = -1.19976E-4; + double b_t3 = -3.75962E-3; + double b_t4 = 5.33100E-2; + double b_t5 = -1.25647E2; + + double a_phi1 = -3.32718E-8; + double a_phi2 = 1.92110E-7; + double a_phi3 = 2.16919E-6; + double a_phi4 = -8.10207E-5; + double a_phi5 = 1.68481E-1; + + double b_phi1 = -3.23019E-9; + double b_phi2 = -6.92075E-8; + double b_phi3 = 1.24731E-5; + double b_phi4 = 2.57684E-5; + double b_phi5 = 2.10680E-2; + if(draw){ + H1F largetdist = new H1F("largetdist",100,0,10000); + } + double timewindow = 2000; + double smalltcut = 300; + double largetcut = 8000; + int tracksizecut = 4; + double larget = 0; + double tdiff = 0; + double Time = 0; + int cellID = 0; + int outsidedriftcounter = 0; + int allhitscounter = 0; + + List tids = RTIDMap.getAllTrackIDs(); + for(int TID : tids) { + ReducedTrack t = RTIDMap.getTrack(TID); + Pads.clear(); + double smallt = t.getSmallT(); + larget = t.getLargeT(); + //largetdist.fill(larget); + if(draw){ + //graphmap.put(TID, new GraphErrors()); + //graphmap2.put(TID, new GraphErrors()); + } + tdiff = 6000 - larget; + tdiffmap.put(TID, tdiff); + recohitvector.put(TID, new Vector()); + + List allhits = t.getAllHits(); + for(HitVector hit : allhits) { + //for(int padindex = 0; padindex < TIDMap.get(TID).get(t).size(); padindex++){ + + allhitscounter++; + //int cellID = TIDMap.get(TID).get(t).get(padindex); + cellID = hit.pad(); + if(!Pads.contains(cellID)) { + Pads.add(cellID); + } + //double Time = weightave.get(cellID); + Time = hit.time(); + //System.out.println("reco " + Time); + //System.out.println("tdiff " + tdiff); + Time+=tdiff; + + //System.out.println(Time + " " + cellID); + + + //int NEve = 10; + + double PAD_W = 2.79; // in mm + double PAD_S = 80.0; //in mm + double PAD_L = 4.0; // in mm + double RTPC_L = 384.0; // in mm + + //double Num_of_Rows = (2.0*(Math.PI)*PAD_S)/PAD_W; + double Num_of_Cols = RTPC_L/PAD_L; + //double TotChan = Num_of_Rows*Num_of_Cols; + + double PI=Math.PI; + + double z0 = -(RTPC_L/2.0); // front of RTPC in mm at the center of the pad + + double phi_per_pad = PAD_W/PAD_S; // in rad + + + + // MagBoltz parameters + //double a_t=1741.179712, b_t=-1.25E+02; // for f(x)=time(radius) + //double a_phi=0.161689123, b_phi=0.023505021; // for f(x)=dphi(radius) + + double t_2GEM2 = 296.082; + double t_2GEM3 = 296.131; + double t_2PAD = 399.09; + double t_gap = t_2GEM2 + t_2GEM3 + t_2PAD; + + double phi_2GEM2 = 0.0492538; + double phi_2GEM3 = 0.0470817; + double phi_2PAD = 0.0612122; + double phi_gap = phi_2GEM2 + phi_2GEM3 + phi_2PAD; + + // find postition from Cell ID + //for (double s = 0.0; s < cellID.size(); s++) { + + double chan=0; + double t_s2pad = 0; + double dphi=0; + double dz=0; + double x_rec = 0; + double y_rec = 0; + + + double z_pad=0; + double z_rec=0; + double z_hit=0; // position of the hit on a single pad in z + double delta_z=0; + + double r_pos=0; + double r_rec=0; + double r_temp=0; + double delta_r=0; + + double phi_pad=0; + double phi_rec=0; + + + + // generated position of ionization in phi + + //phi_pos = Math.atan2(Y, X); + + // generated position of ionization in s + //r_pos=Math.sqrt(((X)*(X))+((Y)*(Y))); + + + // ------------------ find z and phi of pad from CellID ------------------ + chan = (double)cellID; + + double col = chan%Num_of_Cols; + double row=(chan-col)/Num_of_Cols; + double z_shift = row%4; + //double z_shift = 0.; + + phi_pad=(row*phi_per_pad)+(phi_per_pad/2.0); + if(phi_pad>= 2.0*PI) { + phi_pad -= 2.0*PI; + } + if(phi_pad<0) + { + phi_pad += 2.0*PI; + } + + z_pad=z0+(col*PAD_L)+(PAD_L/2.0)+z_shift; + // ----------------------------------------------------------------------- + dz=0; + z_rec=z_pad-dz; + + // find reconstructed position of ionization from Time info + + t_s2pad = Time-t_gap; + //if(t_s2pad > 6000) {System.out.println("oooops");} + //System.out.println("time stuff " + t_s2pad + " " + Time); + + double a_t = get_rec_coef(a_t1,a_t2,a_t3,a_t4,a_t5,z_rec); + double b_t = get_rec_coef(b_t1,b_t2,b_t3,b_t4,b_t5,z_rec); + + r_rec=((-(Math.sqrt(a_t*a_t+(4.*b_t*t_s2pad)))+a_t+(14.*b_t))/(2.*b_t))*10.0; //in mm + + double a_phi = get_rec_coef(a_phi1,a_phi2,a_phi3,a_phi4,a_phi5,z_rec); + double b_phi = get_rec_coef(b_phi1,b_phi2,b_phi3,b_phi4,b_phi5,z_rec); + + dphi=a_phi*(7.-r_rec/10.)+b_phi*(7.-r_rec/10.)*(7.-r_rec/10.); // in rad + //System.out.println("r and phi " + r_rec + " " + dphi); + + + //System.out.println("phi stuff " + phi_pad + " " + dphi + " " + phi_gap); + phi_rec=phi_pad-dphi-phi_gap; + if( phi_rec<0.0 ) + { + phi_rec+=2.0*PI; + } + if( phi_rec>2.0*PI ) + { + phi_rec-=2.0*PI; + } + if(r_rec > 70 || r_rec < 30) + { + outsidedriftcounter++; + } + // x,y,z pos of reconstructed track + x_rec=r_rec*(Math.cos(phi_rec)); + y_rec=r_rec*(Math.sin(phi_rec)); + + + recohitvector.get(TID).add(new RecoHitVector(cellID,x_rec,y_rec,z_rec,tdiff,Time)); + //if(r_rec > 30 && r_rec < 70) + //{ + if(draw){ + //graphmap.get(TID).addPoint(r_rec, z_rec, 0, 0); + //graphmap2.get(TID).addPoint(x_rec, y_rec, 0, 0); + } + + + + //System.out.println("TID time phi x y " + TID + " " + Time + " " + phi_rec + " " + x_rec + " " + y_rec); + //} + // x,y,z pos of pad hit + //x_pad=(PAD_S)*(Math.cos(phi_pad)); + //y_pad=(PAD_S)*(Math.sin(phi_pad)); + + // actual position on pad of hits + //phi_hit=phi_rad-(row*phi_per_pad); + //z_hit=Z-z0-(col*PAD_L)-z_shift; + + // find differences (delta = generated-reconstructed) + //delta_x=X-x_rec; + //delta_y=Y-y_rec; + //delta_z=Z-z_rec; + //delta_r=r_pos-r_rec; + //delta_phi = phi_pos-phi_rec; + + + + + /*hit.set_cellID(cellID); + hit.set_Time(t_s2pad); + hit.set_Edep(Edep); + hit.set_PosX(x_rec); + hit.set_PosY(y_rec); + hit.set_PosZ(z_rec); + TimeVec.add(t_s2pad); + XVec.add(x_rec); + YVec.add(y_rec); + ZVec.add(z_rec);*/ + + + + } + //System.out.println("num of pads " + Pads.size()); + } + /*GraphErrors grz = new GraphErrors(); + GraphErrors g1rz = new GraphErrors(); + GraphErrors gxy = new GraphErrors(); + GraphErrors g1xy = new GraphErrors(); + GraphErrors g2xy = new GraphErrors(); + GraphErrors gerrorxvsphi = new GraphErrors(); + GraphErrors gerroryvsphi = new GraphErrors();*/ + int counter = 1; + + for(Hit hit : rawHits) + { + if(true) { + cellID = hit.get_cellID(); + + Time = hit.get_Time(); + //double T_noshift = Time; + if(Time <= 0) {continue;} + Time -= hit.get_TShift(); + //System.out.println("Time " + hit.get_Time() + " " + hit.get_TShift()); + + double X = hit.get_PosXTrue(); + double Y = hit.get_PosYTrue(); + double Z = hit.get_PosZTrue(); + //double TimeNoShift = Time - hit.get_TShift(); + //if(Pads.contains(cellID)) + //{ + //ystem.out.println(Time + " " + cellID); + + + //int NEve = 10; + + double PAD_W = 2.79; // in mm + double PAD_S = 80.0; //in mm + double PAD_L = 4.0; // in mm + double RTPC_L = 384.0; // in mm + + //double Num_of_Rows = (2.0*(Math.PI)*PAD_S)/PAD_W; + double Num_of_Cols = RTPC_L/PAD_L; + //double TotChan = Num_of_Rows*Num_of_Cols; + + double PI=Math.PI; + + double z0 = -(RTPC_L/2.0); // front of RTPC in mm at the center of the pad + + double phi_per_pad = PAD_W/PAD_S; // in rad + + + + // MagBoltz parameters + //double a_t=1741.179712, b_t=-125; // for f(x)=time(radius) + //double a_phi=0.161689123, b_phi=0.023505021; // for f(x)=dphi(radius) + + double t_2GEM2 = 296.082; + double t_2GEM3 = 296.131; + double t_2PAD = 399.09; + double t_gap = t_2GEM2 + t_2GEM3 + t_2PAD; + + double phi_2GEM2 = 0.0492538; + double phi_2GEM3 = 0.0470817; + double phi_2PAD = 0.0612122; + double phi_gap = phi_2GEM2 + phi_2GEM3 + phi_2PAD; + + // find position from Cell ID + //for (double s = 0.0; s < cellID.size(); s++) { + + double chan=0; + double t_s2pad = 0; + double dphi=0; + double dz=0; + double x_rec = 0; + double y_rec = 0; + + + double z_pad=0; + double z_rec=0; + double z_hit=0; // position of the hit on a single pad in z + double delta_z=0; + + double r_pos=0; + double r_rec=0; + double r_temp=0; + double delta_r=0; + + double phi_pad=0; + double phi_rec=0; + double phi_pos = 0; + + double t_calc = 0; + + + + // generated position of ionization in phi + + phi_pos = Math.atan2(Y, X); + + // generated position of ionization in s + r_pos=Math.sqrt(((X)*(X))+((Y)*(Y))); + //System.out.println(r_pos + " " + X + " " + Y); + + + // ------------------ find z and phi of pad from CellID ------------------ + chan = (double)cellID; + + double col = chan%Num_of_Cols; + double row=(chan-col)/Num_of_Cols; + double z_shift = row%4; + //double z_shift = 0.; + //System.out.println(row + " " + chan + " " + col + " " + phi_per_pad); + phi_pad=(row*phi_per_pad)+(phi_per_pad/2.0); + while(phi_pad >= 2*PI || phi_pad < 0) + { + if(phi_pad>= 2.0*PI) { + phi_pad -= 2.0*PI; + } + if(phi_pad<0) + { + phi_pad += 2.0*PI; + } + } + z_pad=z0+(col*PAD_L)+(PAD_L/2.0)+z_shift; + // ----------------------------------------------------------------------- + dz=0; + z_rec=z_pad-dz; + + // find reconstructed position of ionization from Time info + + double a_t = get_rec_coef(a_t1,a_t2,a_t3,a_t4,a_t5,z_rec); + double b_t = get_rec_coef(b_t1,b_t2,b_t3,b_t4,b_t5,z_rec); + + + + double a_phi = get_rec_coef(a_phi1,a_phi2,a_phi3,a_phi4,a_phi5,z_rec); + double b_phi = get_rec_coef(b_phi1,b_phi2,b_phi3,b_phi4,b_phi5,z_rec); + + //System.out.println(a_t + " " + b_t + " " + a_phi + " " + b_phi + " " + z_rec); + + t_s2pad = Time-t_gap; + + r_rec = ((-(Math.sqrt(a_t*a_t+(4*b_t*t_s2pad)))+a_t+(14*b_t))/(2*b_t))*10.0; //in mm + t_calc = ((((2*b_t*r_pos*0.1)-(14*b_t)-a_t)*((2*b_t*r_pos*0.1)-14*b_t-a_t))-(a_t*a_t))*(1/(4*b_t)) + t_gap; + + + dphi=a_phi*(7-r_rec/10)+b_phi*(7-r_rec/10)*(7.-r_rec/10); // in rad + + + phi_rec=phi_pad-dphi-phi_gap; + while(phi_rec < 0 || phi_rec >= 2*PI) + { + if( phi_rec<0.0 ) + { + phi_rec+=2.0*PI; + } + if( phi_rec>2.0*PI ) + { + phi_rec-=2.0*PI; + } + } + //System.out.println("reconstructed phi " + phi_rec + " actual phi " + Math.atan(Y/X)); + + // x,y,z pos of reconstructed track + x_rec=r_rec*(Math.cos(phi_rec)); + y_rec=r_rec*(Math.sin(phi_rec)); + //System.out.println("rec " + x_rec + " " + y_rec + " " + phi_rec + " " + r_rec + " " + Time); + //if(true) + //if(counter > 2500) + //if(r_rec > 30 && r_rec < 70) + //if(Math.abs(x_rec-X) < 3 && Math.abs(y_rec-Y) < 3 && Math.abs(z_rec-Z) < 3) + //if(true) + //if(Math.abs(t_calc - Time) < timewindow) + /*if(draw){ + if(hit.get_TShift() == 0) + { + //System.out.println(t_calc + " " + Time); + grz.addPoint(r_rec, z_rec, 0, 0); + gxy.addPoint(x_rec, y_rec, 0, 0); + //if(counter <= 53) + //{ + g1rz.addPoint(Math.sqrt(X*X+Y*Y), Z, 0, 0); + g1xy.addPoint(X, Y, 0, 0); + g2xy.addPoint(0, 0, 0, 0); + gerrorxvsphi.addPoint(Math.atan2(Y,X),Math.pow(Math.abs(x_rec-X),2)/X,0,0); + gerroryvsphi.addPoint(Math.atan2(Y,X),Math.pow(Math.abs(y_rec-Y),2)/Y,0,0); + //} + //System.out.println(counter); + } + else + { + //g2xy.addPoint(X, Y, 0, 0); + g2xy.addPoint(0, 0, 0, 0); + grz.addPoint(0, 0, 0, 0); + g1rz.addPoint(0, 0, 0, 0); + gxy.addPoint(0, 0, 0, 0); + g1xy.addPoint(0, 0, 0, 0); + } + } + //} + // x,y,z pos of pad hit + //x_pad=(PAD_S)*(Math.cos(phi_pad)); + //y_pad=(PAD_S)*(Math.sin(phi_pad)); + + // actual position on pad of hits + //phi_hit=phi_rad-(row*phi_per_pad); + //z_hit=Z-z0-(col*PAD_L)-z_shift; + + // find differences (delta = generated-reconstructed) + //delta_x=X-x_rec; + //delta_y=Y-y_rec; + //delta_z=Z-z_rec; + //delta_r=r_pos-r_rec; + //delta_phi = phi_pos-phi_rec; + //System.out.println(X + " " + x_rec); + //System.out.println(r_pos + " " + r_rec); + + */ + + /*hit.set_cellID(cellID); + hit.set_Time(t_s2pad); + hit.set_Edep(Edep); + hit.set_PosX(x_rec); + hit.set_PosY(y_rec); + hit.set_PosZ(z_rec); + TimeVec.add(t_s2pad); + XVec.add(x_rec); + YVec.add(y_rec); + ZVec.add(z_rec);*/ + //} + counter++; + } + } + if(draw){ + /*EmbeddedCanvas c = new EmbeddedCanvas(); + EmbeddedCanvas c2 = new EmbeddedCanvas(); + EmbeddedCanvas c3 = new EmbeddedCanvas(); + EmbeddedCanvas c4 = new EmbeddedCanvas(); + //System.out.println(counter); + GraphErrors g2 = new GraphErrors(); + double theta = 0; + double test_x = 0; + double test_y = 0; + double test_x2 = 0; + double test_y2 = 0; + while(theta <= 2*Math.PI) + { + test_x = 30 * Math.cos(theta); + test_y = 30 * Math.sin(theta); + test_x2 = 70 * Math.cos(theta); + test_y2 = 70 * Math.sin(theta); + g2.addPoint(test_x, test_y, 0, 0); + g2.addPoint(test_x2, test_y2, 0, 0); + theta+=0.01; + } + int color = 2; + int shape = 1; + for(int key : graphmap.keySet()) + { + double szPos[][] = new double[recohitvector.get(key).size()][3]; + for(int i = 0; i < recohitvector.get(key).size(); i++) { + szPos[i][0] = recohitvector.get(key).get(i).x(); + szPos[i][1] = recohitvector.get(key).get(i).y(); + szPos[i][2] = recohitvector.get(key).get(i).z(); + } + //double R = 0; double A = 0; double B = 0; double Phi_deg = 0; double Theta_deg = 0; double Z0 = 0; int fit_track_to_beamline = 1; + //HelixFitJava hf = new HelixFitJava(); + //hf.HelixFit(recohitvector.get(key).size(), szPos, R, A, B, Phi_deg, Theta_deg, Z0, fit_track_to_beamline); + //System.out.println(key + " " + R); + if(false) + //if(key == 3) + { + graphmap.get(key).setMarkerSize(6); + graphmap2.get(key).setMarkerSize(6); + } + else { + graphmap.get(key).setMarkerSize(3); + graphmap.get(key).setMarkerColor(color); + graphmap.get(key).setMarkerStyle(shape); + + + graphmap2.get(key).setMarkerSize(3); + graphmap2.get(key).setMarkerColor(color); + graphmap2.get(key).setMarkerStyle(shape); + + } + c.draw(graphmap.get(key),"same"); + c2.draw(graphmap2.get(key),"same"); + color++; + if(color > 7) + { + color -= 6; + shape++; + } + } + grz.setMarkerSize(3); + grz.setMarkerColor(1); + g1rz.setMarkerSize(2); + g1rz.setMarkerColor(2); + //grz.addPoint(30, -200, 0, 0); + //grz.addPoint(70, 200, 0, 0); + gxy.setMarkerSize(2); + gxy.setMarkerColor(2); + g1xy.setMarkerSize(2); + g1xy.setMarkerColor(1); + g2xy.setMarkerSize(2); + g2xy.setMarkerColor(7); + g2.setMarkerSize(0); + g2.setMarkerColor(3); + gerrorxvsphi.setMarkerSize(2); + gerroryvsphi.setMarkerSize(2); + JFrame j = new JFrame(); + j.setSize(800,600); + JFrame j2 = new JFrame(); + j2.setSize(800,600); + JFrame j3 = new JFrame(); + j3.setSize(800,600); + JFrame j4 = new JFrame(); + j4.setSize(800,600); + c.draw(grz,"same"); + c.draw(g1rz,"same"); + c2.draw(gxy,"same"); + c2.draw(g1xy,"same"); + c2.draw(g2,"same"); + c2.draw(g2xy,"same"); + c3.divide(1, 2); + c3.cd(0); + c3.draw(gerrorxvsphi); + c3.cd(1); + c3.draw(gerroryvsphi); + //c4.draw(largetdist); + j.setTitle("RZ"); + j2.setTitle("XY"); + + + j.add(c); + j.setVisible(true); + j2.add(c2); + j2.setVisible(true); + //j3.add(c3); + //j3.setVisible(true); + j4.add(c4); + //j4.setVisible(true); + } + */ + } + //System.out.println(outsidedriftcounter + "/" + allhitscounter); + //params.set_alltracks(alltracks); + + params.set_recohitvector(recohitvector); + } + + double get_rec_coef(double t1, double t2, double t3, double t4, double t5, double z2) { + double z = z2/1000; + return t1*z*z*z*z + t2*z*z*z + t3*z*z + t4*z + t5; + + } + + +} + + + + diff --git a/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/TrackMap.java b/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/TrackMap.java new file mode 100644 index 0000000000..8f51e288b0 --- /dev/null +++ b/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/TrackMap.java @@ -0,0 +1,60 @@ +package org.jlab.rec.rtpc.hit; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ConcurrentHashMap; +import java.util.HashMap; + +public class TrackMap { + + private HashMap _map; + private int _trackID = 0; + + public TrackMap() { + _map = new HashMap(); + } + + public void addTrack(Track t) { + _trackID++; + _map.put(_trackID, t); + } + + public Track getTrack(int trackID) { + if(!_map.containsKey(trackID)) { + addTrack(new Track()); + } + return _map.get(trackID); + } + + public void updateTrack(int trackID, Track t) { + _map.put(trackID, t); + } + + public void removeTrack(int trackID) { + _map.remove(trackID); + } + + public List getAllTrackIDs() { + List l = new ArrayList(); + for(int i : _map.keySet()) { + if(!l.contains(i)) { l.add(i);} + } + return l; + } + + public int getLastTrackID() { + return _trackID; + } + + public void mergeTracks(int trackIDparent, int trackID) { + Track child = getTrack(trackID); + List l = child.getAllTimeSlices(); + Track parent = getTrack(trackIDparent); + for(int time : l) { + parent.addTimeSlice(time,child.getTimeSlice(time)); + } + //updateTrack(trackIDparent, parent); + removeTrack(trackID); + } + +} diff --git a/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/TrackUtils.java b/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/TrackUtils.java new file mode 100644 index 0000000000..a8bf34306f --- /dev/null +++ b/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/TrackUtils.java @@ -0,0 +1,44 @@ +package org.jlab.rec.rtpc.hit; + +public class TrackUtils { + private double adjthresh = 16; + private double PhiDelta = 16; + private double ZDelta = 36; + private double phithresh = 0.16; + private double zthresh = 16; + + public TrackUtils() {} + + public boolean comparePads(PadVector p1, PadVector p2, String Method) { + if(Method == "ellipse") {return ellipseMethod(p1, p2);} + if(Method == "phiz") {return phizMethod(p1,p2);} + else return false; + } + + private boolean ellipseMethod(PadVector p1, PadVector p2) { + double p1x = p1.x(); + double p1y = p1.y(); + double p1z = p1.z(); + double p2x = p2.x(); + double p2y = p2.y(); + double p2z = p2.z(); + double EllipseDeltax = Math.abs(p1x-p2x)*Math.abs(p1x-p2x); + double EllipseDeltay = Math.abs(p1y-p2y)*Math.abs(p1y-p2y); + double EllipseDeltaz = Math.abs(p1z-p2z)*Math.abs(p1z-p2z); + double EllipseTotal = ((EllipseDeltax+EllipseDeltay)/PhiDelta) + (EllipseDeltaz/ZDelta); + if(EllipseTotal < adjthresh) return true; + return false; + } + + private boolean phizMethod(PadVector p1, PadVector p2) { + double p1phi = p1.phi(); + double p2phi = p2.phi(); + double p1z = p1.z(); + double p2z = p2.z(); + double phidiff = p2phi-p1phi; + double zdiff = Math.abs(p1z-p2z); + //System.out.println(p1phi + " " + p2phi + " " + (p1phi - p2phi)); + return ((Math.abs(phidiff) + + + + +org.jlab.rec.rtpc.hit + + +
Author:
ziegler
+ + \ No newline at end of file diff --git a/reconstruction/src/main/java/org/jlab/rec/rtpc/package.html b/reconstruction/src/main/java/org/jlab/rec/rtpc/package.html new file mode 100644 index 0000000000..f0cd21cb47 --- /dev/null +++ b/reconstruction/src/main/java/org/jlab/rec/rtpc/package.html @@ -0,0 +1,14 @@ + + + + + +org.jlab.rec.rtpc + + +
Author:
ziegler
+ + \ No newline at end of file diff --git a/reconstruction/src/main/java/org/jlab/service/rtpc/RTPCEngine.java b/reconstruction/src/main/java/org/jlab/service/rtpc/RTPCEngine.java new file mode 100644 index 0000000000..f55a3df89e --- /dev/null +++ b/reconstruction/src/main/java/org/jlab/service/rtpc/RTPCEngine.java @@ -0,0 +1,179 @@ +package org.jlab.service.rtpc; + +import java.io.File; +import java.io.FileNotFoundException; + + +import java.util.ArrayList; +import java.util.List; + +import org.jlab.clas.reco.ReconstructionEngine; +//import org.jlab.coda.hipo.HipoException; +//import org.jlab.coda.jevio.EvioException; +import org.jlab.io.base.DataBank; +import org.jlab.io.base.DataEvent; +import org.jlab.io.hipo.HipoDataSource; +import org.jlab.io.hipo.HipoDataSync; +import org.jlab.rec.rtpc.banks.HitReader; +import org.jlab.rec.rtpc.banks.RecoBankWriter; +import org.jlab.rec.rtpc.banks.RecoBankWriter2; +import org.jlab.rec.rtpc.hit.Hit; +import org.jlab.rec.rtpc.hit.HitDistance; +import org.jlab.rec.rtpc.hit.HitParameters; +import org.jlab.rec.rtpc.hit.HitReconstruction; +import org.jlab.rec.rtpc.hit.MapCombine; +import org.jlab.rec.rtpc.hit.PadAve; +import org.jlab.rec.rtpc.hit.PadFit; +import org.jlab.rec.rtpc.hit.PadHit; +//import org.jlab.rec.rtpc.hit.PulseShapeAnalysis; +import org.jlab.rec.rtpc.hit.TimeAverage; +import org.jlab.rec.rtpc.hit.TimeAverage2; +//import org.jlab.rec.rtpc.hit.TrackDisentangler; +//import org.jlab.rec.rtpc.hit.TrackFinder; +import org.jlab.rec.rtpc.hit.TrackFinder2; +import org.jlab.rec.rtpc.hit.TrackFinder3; +import org.jlab.rec.rtpc.hit.TrackHitReco; +import org.jlab.rec.rtpc.hit.TrackHitReco2; +import org.jlab.rec.rtpc.hit.TrackHitReco3; + + + + +public class RTPCEngine extends ReconstructionEngine{ + + int test = 0; + int swtch = 2; + + + public RTPCEngine() { + super("RTPC","charlesg","3.0"); + } + + @Override + public boolean init() { + // TODO Auto-generated method stub + return true; + } + + @Override + public boolean processDataEvent(DataEvent event) { + HitParameters params = new HitParameters(); + HitReader hitRead = new HitReader(); + hitRead.fetch_RTPCHits(event); + + List hits = new ArrayList(); + //I) get the hits + hits = hitRead.get_RTPCHits(); + + //II) process the hits + //1) exit if hit list is empty + if(hits==null || hits.size()==0) { + return true; + } + if(event.hasBank("RTPC::pos")) + { + PadHit phit = new PadHit(); + phit.bonus_shaping(hits,params); + PadFit pfit = new PadFit(); + pfit.Fitting(params); + +// PulseShapeAnalysis psa = new PulseShapeAnalysis(); +// psa.PSA(params); + + //TrackFinder TF = new TrackFinder(); + //TF.FindTrack(params); + if(swtch == 1) //outdated build + { + HitDistance HD = new HitDistance(); + HD.FindDistance(params); + } + else if(swtch == 2) { //current build only use this one + TrackFinder3 TF = new TrackFinder3(params,false); + TimeAverage2 TA2 = new TimeAverage2(params,false); + //TrackDisentangler TD = new TrackDisentangler(params,true); + TrackHitReco3 TR3 = new TrackHitReco3(hits,params,false); + RecoBankWriter2 writer = new RecoBankWriter2(); + DataBank recoBank = writer.fillRTPCHitsBank(event, params); + event.appendBanks(recoBank); + } + else //outdated build + { + TrackFinder2 TF = new TrackFinder2(); + TF.FindTrack2(params,false); + TimeAverage TA = new TimeAverage(); + TA.TA(params,false); + MapCombine MC = new MapCombine(); + MC.MC(params,false); + /*TrackHitReco TR = new TrackHitReco(); + TR.Reco(hits,params);*/ + TrackHitReco2 TR = new TrackHitReco2(); + TR.Reco(hits,params,false); + RecoBankWriter2 writer = new RecoBankWriter2(); + DataBank recoBank = writer.fillRTPCHitsBank(event, params); + event.appendBanks(recoBank); + //recoBank.show(); + } + + } + else + { + return true; + } + + /* + for(Hit h : hits) { + System.out.println("Hit "+h.get_Id()+" CellID "+h.get_cellID()+" ADC "+h.get_ADC()+" true Edep "+h.get_EdepTrue()+" Edep "+h.get_Edep()+" Time "+h.get_Time()+" "+ + " true X "+h.get_PosXTrue()+" X "+h.get_PosX()+" true Y "+h.get_PosYTrue()+" Y "+h.get_PosY()+" true Z "+h.get_PosZTrue()+" Z "+h.get_PosZ()); + }*/ + + + + + return true; + } + + public static void main(String[] args){ + double starttime = System.nanoTime(); + //String inputFile = "/Users/davidpayette/Desktop/5c.2.3/clara/installation/plugins/clas12/2_72_516.hipo"; + //String inputFile = "/Users/davidpayette/Desktop/5c.2.3/clara/installation/plugins/clas12/1000_1_711.hipo"; + //String inputFile = "/Users/davidpayette/Desktop/5c.2.3/clara/installation/plugins/clas12/100_20_731.hipo"; + //String inputFile = "/Users/davidpayette/Desktop/5c.3.5/clara/installation/plugins/clas12/test.hipo"; + //String inputFile = "/Users/davidpayette/Desktop/5b.7.4/myClara/1212.hipo"; + //String inputFile = "/Users/davidpayette/Desktop/5b.7.4/myClara/plugins/clas12/Jantest.hipo"; + String inputFile = "/Users/davidpayette/Desktop/5b.7.4/myClara/plugins/clas12/newfeb.hipo"; + //String inputFile = "/Users/davidpayette/Desktop/Distribution/clas12-offline-software/1212again.hipo"; + //String inputFile = "/Users/davidpayette/Desktop/5c.2.3/clara/installation/plugins/clas12/100_20_802.hipo"; + //String inputFile = "/Users/davidpayette/Desktop/5c.2.3/clara/installation/plugins/clas12/10p.hipo"; + //String inputFile = args[0]; + String outputFile = "/Users/davidpayette/Desktop/5b.7.4/myClara/tout_working.hipo"; + + System.err.println(" \n[PROCESSING FILE] : " + inputFile); + + RTPCEngine en = new RTPCEngine(); + en.init(); + + + + HipoDataSource reader = new HipoDataSource(); + HipoDataSync writer = new HipoDataSync(); + reader.open(inputFile); + writer.open(outputFile); + System.out.println("starting " + starttime); + + File f1= new File("/Users/davidpayette/Documents/FileOutput/PulseShapeAll.txt"); + File f2= new File("/Users/davidpayette/Documents/FileOutput/PulseShapeMax.txt"); + File f3= new File("/Users/davidpayette/Documents/FileOutput/PulseShapeAllOverMax.txt"); + f1.delete(); + f2.delete(); + f3.delete(); + + while(reader.hasEvent()){ + + DataEvent event = reader.getNextEvent(); + en.processDataEvent(event); + writer.writeEvent(event); + } + writer.close(); + System.out.println("finished " + (System.nanoTime() - starttime)*Math.pow(10,-9)); + } +} diff --git a/reconstruction/src/main/java/org/jlab/service/rtpc/package-info.java b/reconstruction/src/main/java/org/jlab/service/rtpc/package-info.java new file mode 100644 index 0000000000..fb4baf2083 --- /dev/null +++ b/reconstruction/src/main/java/org/jlab/service/rtpc/package-info.java @@ -0,0 +1,8 @@ +/** + * + */ +/** + * @author ziegler + * + */ +package org.jlab.service.rtpc; \ No newline at end of file From 6c71df29cd0a34d5e24f3efbf5754260ac39dca2 Mon Sep 17 00:00:00 2001 From: dcpayette Date: Wed, 26 Jun 2019 16:00:39 -0400 Subject: [PATCH 002/235] fixing poms --- etc/services/reconstruction.yaml | 2 + reconstruction/pom.xml | 94 ++++++++------------------------ reconstruction/rtpc/pom.xml | 2 +- 3 files changed, 25 insertions(+), 73 deletions(-) diff --git a/etc/services/reconstruction.yaml b/etc/services/reconstruction.yaml index 9520bb9186..a2840a8d0d 100644 --- a/etc/services/reconstruction.yaml +++ b/etc/services/reconstruction.yaml @@ -42,6 +42,8 @@ services: name: FTOFTB - class: org.jlab.service.eb.EBTBEngine name: EBTB + - class: org.jlab.service.rtpc.RTPCEngine + name: RTPC configuration: io-services: writer: diff --git a/reconstruction/pom.xml b/reconstruction/pom.xml index dbf046d4f7..9faa6a3795 100644 --- a/reconstruction/pom.xml +++ b/reconstruction/pom.xml @@ -1,81 +1,31 @@ - - + 4.0.0 - org.jlab.clas12.detector - clas12detector-rtpc - 1.0-SNAPSHOT - jar + org.jlab.clas + reconstruction + 6.2.0-SNAPSHOT + pom org.jlab.clas clas12rec - ../../parent/pom.xml + ../parent/pom.xml 6.2.0-SNAPSHOT - - - clas12maven - https://clasweb.jlab.org/clas12maven - - - - - - - org.jlab.coda - jclara - 4.3-SNAPSHOT - - - - org.jlab.clas - clas-reco - 6.2.0-SNAPSHOT - - - - org.jlab.clas - clas-analysis - 6.2.0-SNAPSHOT - - - - org.jlab - groot - 2.2.0-20190308.162151-9 - - - - - - - org.apache.maven.plugins - maven-site-plugin - 3.7.1 - - - org.apache.maven.plugins - maven-project-info-reports-plugin - 3.0.0 - - - - - - - org.codehaus.mojo - findbugs-maven-plugin - - - - - - 1.8 - 1.8 - - - + + dc + tof + cvt + ft + ec + ltcc + htcc + cnd + rich + fvt + eb + band + rtpc + + diff --git a/reconstruction/rtpc/pom.xml b/reconstruction/rtpc/pom.xml index dbf046d4f7..70a1b526c5 100644 --- a/reconstruction/rtpc/pom.xml +++ b/reconstruction/rtpc/pom.xml @@ -5,7 +5,7 @@ 4.0.0 org.jlab.clas12.detector - clas12detector-rtpc + rtpc 1.0-SNAPSHOT jar From 6045dcc739ca817462d46de64e2b21ca54ecc5f8 Mon Sep 17 00:00:00 2001 From: baltzell Date: Sun, 30 Jun 2019 15:03:34 -0400 Subject: [PATCH 003/235] restructure trajectory storage --- .../org/jlab/clas/detector/DetectorData.java | 33 ++++----- .../jlab/clas/detector/DetectorParticle.java | 2 +- .../org/jlab/clas/detector/DetectorTrack.java | 68 +++++++++++++++---- 3 files changed, 71 insertions(+), 32 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 c3d24bd4ee..780a5b8b54 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 @@ -380,33 +380,30 @@ public static DataBank getTrajectoriesBank(List particles, Dat DataBank bank=null; if (bank_name!=null) { + int nrows = 0; for(int i = 0 ; i < particles.size(); i++) { - if(particles.get(i).getTrackDetector()==DetectorType.DC.getDetectorId() || - particles.get(i).getTrackDetector()==DetectorType.CVT.getDetectorId() ) { - nrows += particles.get(i).getTrackTrajectory().size(); - } + nrows += particles.get(i).getTrackTrajectory().size(); } - bank = event.createBank(bank_name, nrows); + int row = 0; for(int i = 0 ; i < particles.size(); i++) { DetectorParticle p = particles.get(i); - if(p.getTrackDetector()==DetectorType.DC.getDetectorId() || - p.getTrackDetector()==DetectorType.CVT.getDetectorId() ) { - List traj = p.getTrackTrajectory(); - for (int j=0; j getTrackTrajectory() { + public DetectorTrack.Trajectory getTrackTrajectory() { return detectorTrack.getTrajectory(); } 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 fa9a536d57..61a124e346 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,7 +1,10 @@ package org.jlab.clas.detector; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; +import java.util.Set; import org.jlab.clas.physics.Vector3; import org.jlab.geom.prim.Line3D; import org.jlab.geom.prim.Vector3D; @@ -37,6 +40,51 @@ public TrajectoryPoint(int detId,int layId,Line3D traj) { public float getBField() { return bField; } public float getPathLength() { return pathLength; } } + + public class Trajectory { + + private int size=0; + private Map < Integer, Map > traj = new HashMap<>(); + + public void add(int detId,int layId,Line3D traj,float bField,float pathLength) { + if (!this.traj.containsKey(detId)) { + this.traj.put(detId,new HashMap<>()); + } + if (this.traj.get(detId).containsKey(layId)) { + throw new RuntimeException("Duplicate detector type/layer: "+detId+"/"+layId); + } + this.traj.get(detId).put(layId,new TrajectoryPoint(detId,layId,traj,bField,pathLength)); + this.size++; + } + + public void add(int detId,int layId,Line3D traj) { + this.add(detId,layId,traj,0.0f,-1.0f); + } + + public Set getDetectors() { + return this.traj.keySet(); + } + + public Set getLayers(int detId) { + if (traj.containsKey(detId)) { + return traj.get(detId).keySet(); + } + return null; + } + + public TrajectoryPoint get(int detId,int layId) { + if (this.traj.containsKey(detId)) { + if (this.traj.get(detId).containsKey(layId)) { + return this.traj.get(detId).get(layId); + } + } + return null; + } + + public int size() { + return this.size; + } + } private int trackSector = 0; private int trackAssociation = -1; @@ -56,9 +104,9 @@ public TrajectoryPoint(int detId,int layId,Line3D traj) { private Vector3 trackVertex = new Vector3(); private float[][] covMatrix = new float[5][5]; - private List trackCrosses = new ArrayList(); - - private List trajectory = new ArrayList<>(); + private List trackCrosses = new ArrayList<>(); + + private Trajectory trajectory=new Trajectory(); private double MAX_LINE_LENGTH = 1500.0; @@ -115,23 +163,17 @@ public DetectorTrack(int charge, double px, double py, double pz, } public void addTrajectoryPoint(int detId,int layId,Line3D traj,float bField,float pathLength) { - this.trajectory.add(new TrajectoryPoint(detId,layId,traj,bField,pathLength)); + this.trajectory.add(detId,layId,traj,bField,pathLength); } public void addTrajectoryPoint(int detId,int layId,Line3D traj) { - this.trajectory.add(new TrajectoryPoint(detId,layId,traj)); + this.addTrajectoryPoint(detId,layId,traj,0.0f,-1.0f); } public Line3D getTrajectoryPoint(int detId,int layId) { - for (int ii=0; ii getTrajectory() { + public Trajectory getTrajectory() { return this.trajectory; } From 5b416a5596529628296335421b5f281cbfddc9ab Mon Sep 17 00:00:00 2001 From: dcpayette Date: Wed, 3 Jul 2019 14:02:43 -0400 Subject: [PATCH 004/235] update converter --- .../org/jlab/clas/reco/io/EvioHipoEvent.java | 45 ++++++++++--------- .../org/jlab/clas/reco/io/EvioHipoEvent4.java | 44 +++++++++--------- 2 files changed, 48 insertions(+), 41 deletions(-) diff --git a/common-tools/clas-reco/src/main/java/org/jlab/clas/reco/io/EvioHipoEvent.java b/common-tools/clas-reco/src/main/java/org/jlab/clas/reco/io/EvioHipoEvent.java index 930543caef..9c0dbd62a5 100644 --- a/common-tools/clas-reco/src/main/java/org/jlab/clas/reco/io/EvioHipoEvent.java +++ b/common-tools/clas-reco/src/main/java/org/jlab/clas/reco/io/EvioHipoEvent.java @@ -223,31 +223,34 @@ public void fillHipoEventDC(HipoDataEvent hipoEvent, EvioDataEvent evioEvent){ } } - public void fillHipoEventRTPC(HipoDataEvent hipoEvent, EvioDataEvent evioEvent){ - if(evioEvent.hasBank("RTPC::dgtz")==true){ - EvioDataBank evioBank = (EvioDataBank) evioEvent.getBank("RTPC::dgtz"); - HipoDataBank hipoADC = (HipoDataBank) hipoEvent.createBank("RTPC::adc", evioBank.rows()); -// HipoDataBank hipoPOS = (HipoDataBank) hipoEvent.createBank("RTPC::pos", evioBank.rows()); - for(int i = 0; i < evioBank.rows(); i++){ + public void fillHipoEventRTPC(HipoDataEvent hipoEvent, EvioDataEvent evioEvent){ + if(evioEvent.hasBank("RTPC::dgtz")==true){ + //System.out.println("found RTPC dgtz bank"); + EvioDataBank evioBankdgtz = (EvioDataBank) evioEvent.getBank("RTPC::dgtz"); + EvioDataBank evioBanktrue = (EvioDataBank) evioEvent.getBank("RTPC::true"); + HipoDataBank hipoADC = (HipoDataBank) hipoEvent.createBank("RTPC::adc", evioBankdgtz.rows()); + HipoDataBank hipoPOS = (HipoDataBank) hipoEvent.createBank("RTPC::pos", evioBanktrue.rows()); + for(int i = 0; i < evioBanktrue.rows(); i++){ hipoADC.setByte("sector", i, (byte) 1); hipoADC.setByte("layer", i, (byte) 1); - hipoADC.setShort("component", i, (short) evioBank.getInt("CellID",i)); + hipoADC.setShort("component", i, (short) evioBankdgtz.getInt("CellID",i)); hipoADC.setByte("order", i, (byte) 0); - hipoADC.setInt("ADC", i, (int) evioBank.getDouble("ADC", i)); - hipoADC.setFloat("time", i, (float) evioBank.getDouble("Time", i)); -// double tdc = evioBank.getDouble("TDC", i); -// hipoADC.setFloat("time", i, (float) tdc); -// hipoADC.setShort("ped", i, (short) 0); -// hipoPOS.setInt("step", i, (byte) evioBank.getInt("step", i)); -// hipoPOS.setFloat("time", i, (float) tdc); -// hipoPOS.setFloat("energy", i, (float) evioBank.getDouble("EDep", i)); -// hipoPOS.setFloat("posx", i, (float) evioBank.getDouble("PosX", i)); -// hipoPOS.setFloat("posy", i, (float) evioBank.getDouble("PosY", i)); -// hipoPOS.setFloat("posz", i, (float) evioBank.getDouble("PosZ", i)); -// hipoPOS.setFloat("phi", i, (float) evioBank.getDouble("phiRad", i)); + hipoADC.setInt("ADC", i, (int) evioBankdgtz.getDouble("ADC", i)); + double tdc = evioBankdgtz.getDouble("Time", i); + hipoADC.setFloat("time", i, (float) tdc); + hipoADC.setShort("ped", i, (short) 0); + hipoADC.setFloat("timeshift", i, (float) evioBankdgtz.getDouble("TimeShift", i)); + hipoPOS.setInt("step", i, (byte) 1); + hipoPOS.setFloat("time", i, (float) tdc); + hipoPOS.setFloat("energy", i, (float) evioBanktrue.getDouble("totEdep", i)); + hipoPOS.setFloat("posx", i, (float) evioBanktrue.getDouble("avgX", i)); + hipoPOS.setFloat("posy", i, (float) evioBanktrue.getDouble("avgY", i)); + hipoPOS.setFloat("posz", i, (float) evioBanktrue.getDouble("avgZ", i)); + hipoPOS.setInt("tid", i, evioBanktrue.getInt("tid", i)); + hipoPOS.setFloat("phi", i, (float) 0.0); + //hipoPOS.setFloat("phi", i, (float) evioBank.getDouble("phiRad", i)); } -// hipoEvent.appendBanks(hipoADC,hipoPOS); - hipoEvent.appendBanks(hipoADC); + hipoEvent.appendBanks(hipoADC,hipoPOS); } } diff --git a/common-tools/clas-reco/src/main/java/org/jlab/clas/reco/io/EvioHipoEvent4.java b/common-tools/clas-reco/src/main/java/org/jlab/clas/reco/io/EvioHipoEvent4.java index b71da48793..9f252ba2da 100644 --- a/common-tools/clas-reco/src/main/java/org/jlab/clas/reco/io/EvioHipoEvent4.java +++ b/common-tools/clas-reco/src/main/java/org/jlab/clas/reco/io/EvioHipoEvent4.java @@ -236,31 +236,35 @@ public void fillHipoEventDC(Event hipoEvent, EvioDataEvent evioEvent){ } } - public void fillHipoEventRTPC(Event hipoEvent, EvioDataEvent evioEvent){ - if(evioEvent.hasBank("RTPC::dgtz")==true){ - EvioDataBank evioBank = (EvioDataBank) evioEvent.getBank("RTPC::dgtz"); - Bank hipoADC = new Bank(schemaFactory.getSchema("RTPC::adc"), evioBank.rows()); -// Bank hipoPOS = new Bank(schemaFactory.getSchema(("RTPC::pos"), evioBank.rows()); - for(int i = 0; i < evioBank.rows(); i++){ + public void fillHipoEventRTPC(Event hipoEvent, EvioDataEvent evioEvent){ + if(evioEvent.hasBank("RTPC::dgtz")==true){ + //System.out.println("found RTPC dgtz bank"); + EvioDataBank evioBankdgtz = (EvioDataBank) evioEvent.getBank("RTPC::dgtz"); + EvioDataBank evioBanktrue = (EvioDataBank) evioEvent.getBank("RTPC::true"); + Bank hipoADC = new Bank(schemaFactory.getSchema("RTPC::adc"), evioBankdgtz.rows()); + Bank hipoPOS = new Bank(schemaFactory.getSchema("RTPC::pos"), evioBanktrue.rows()); + for(int i = 0; i < evioBanktrue.rows(); i++){ hipoADC.putByte("sector", i, (byte) 1); hipoADC.putByte("layer", i, (byte) 1); - hipoADC.putShort("component", i, (short) evioBank.getInt("CellID",i)); + hipoADC.putShort("component", i, (short) evioBankdgtz.getInt("CellID",i)); hipoADC.putByte("order", i, (byte) 0); - hipoADC.putInt("ADC", i, (int) evioBank.getDouble("ADC", i)); - hipoADC.putFloat("time", i, (float) evioBank.getDouble("Time", i)); -// double tdc = evioBank.getDouble("TDC", i); -// hipoADC.putFloat("time", i, (float) tdc); -// hipoADC.putShort("ped", i, (short) 0); -// hipoPOS.putInt("step", i, (byte) evioBank.getInt("step", i)); -// hipoPOS.putFloat("time", i, (float) tdc); -// hipoPOS.putFloat("energy", i, (float) evioBank.getDouble("EDep", i)); -// hipoPOS.putFloat("posx", i, (float) evioBank.getDouble("PosX", i)); -// hipoPOS.putFloat("posy", i, (float) evioBank.getDouble("PosY", i)); -// hipoPOS.putFloat("posz", i, (float) evioBank.getDouble("PosZ", i)); -// hipoPOS.putFloat("phi", i, (float) evioBank.getDouble("phiRad", i)); + hipoADC.putInt("ADC", i, (int) evioBankdgtz.getDouble("ADC", i)); + double tdc = evioBankdgtz.getDouble("Time", i); + hipoADC.putFloat("time", i, (float) tdc); + hipoADC.putShort("ped", i, (short) 0); + hipoADC.putFloat("timeshift", i, (float) evioBankdgtz.getDouble("TimeShift", i)); + hipoPOS.putInt("step", i, (byte) 1); + hipoPOS.putFloat("time", i, (float) tdc); + hipoPOS.putFloat("energy", i, (float) evioBanktrue.getDouble("totEdep", i)); + hipoPOS.putFloat("posx", i, (float) evioBanktrue.getDouble("avgX", i)); + hipoPOS.putFloat("posy", i, (float) evioBanktrue.getDouble("avgY", i)); + hipoPOS.putFloat("posz", i, (float) evioBanktrue.getDouble("avgZ", i)); + hipoPOS.putInt("tid", i, evioBanktrue.getInt("tid", i)); + hipoPOS.putFloat("phi", i, (float) 0.0); + //hipoPOS.setFloat("phi", i, (float) evioBank.getDouble("phiRad", i)); } -// hipoEvent.write(hipoADC,hipoPOS); hipoEvent.write(hipoADC); + hipoEvent.write(hipoPOS); } } From ec83bf8a111847b57e752a1df82471a24ee950e1 Mon Sep 17 00:00:00 2001 From: dcpayette Date: Wed, 3 Jul 2019 15:45:55 -0400 Subject: [PATCH 005/235] update to banks --- etc/bankdefs/hipo4/rtpc.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/bankdefs/hipo4/rtpc.json b/etc/bankdefs/hipo4/rtpc.json index 4482e85a31..26708e6694 100644 --- a/etc/bankdefs/hipo4/rtpc.json +++ b/etc/bankdefs/hipo4/rtpc.json @@ -6,7 +6,7 @@ "info": "reconstructed RTPC hits", "items": [ {"name":"TID", "type":"I", "info":"Track ID of the hit"}, - {"name":"cellID", "type":"I, "info":"cell id"}, + {"name":"cellID", "type":"I", "info":"cell id"}, {"name":"time", "type":"F", "info":"Time (ns)"}, {"name":"posX", "type":"F", "info":"x pos (cm)"}, {"name":"posY", "type":"F", "info":"y pos (cm)"}, From a4f9293a4c5068a8881f8e6a65c57c53d5da94da Mon Sep 17 00:00:00 2001 From: dcpayette Date: Tue, 9 Jul 2019 17:55:33 -0400 Subject: [PATCH 006/235] added rtpc to build file --- build-coatjava.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/build-coatjava.sh b/build-coatjava.sh index 6e41ac0d47..4db6b3e139 100755 --- a/build-coatjava.sh +++ b/build-coatjava.sh @@ -109,5 +109,6 @@ cp reconstruction/rich/target/clas12detector-rich-*-SNAPSHOT.jar coatjava/lib/se cp reconstruction/fvt/target/clas12detector-fmt-*-SNAPSHOT.jar coatjava/lib/services/ cp reconstruction/eb/target/clas12detector-eb-*-SNAPSHOT.jar coatjava/lib/services/ cp reconstruction/band/target/clas12detector-band-*-SNAPSHOT.jar coatjava/lib/services/ +cp reconstruction/rtpc/target/clas12detector-rtpc-*-SNAPSHOT.jar coatjava/lib/services/ echo "COATJAVA SUCCESSFULLY BUILT !" From 91c070d9d2658bc300b53022d6c8399ae2112ba1 Mon Sep 17 00:00:00 2001 From: dcpayette Date: Tue, 9 Jul 2019 18:48:17 -0400 Subject: [PATCH 007/235] cleanup outdated classes --- .gitignore | 3 + .../org/jlab/rec/rtpc/hit/TimeAverage.java | 389 ------- .../org/jlab/rec/rtpc/hit/TrackFinder2.java | 994 ------------------ .../org/jlab/rec/rtpc/hit/TrackHitReco.java | 528 ---------- .../org/jlab/rec/rtpc/hit/TrackHitReco2.java | 714 ------------- .../org/jlab/service/rtpc/RTPCEngine.java | 30 +- 6 files changed, 5 insertions(+), 2653 deletions(-) delete mode 100644 reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TimeAverage.java delete mode 100644 reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TrackFinder2.java delete mode 100644 reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TrackHitReco.java delete mode 100644 reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TrackHitReco2.java diff --git a/.gitignore b/.gitignore index b36994d9a6..1a1360a8fa 100644 --- a/.gitignore +++ b/.gitignore @@ -33,4 +33,7 @@ hs_err_pid* # no log files: *.log +*.evio +bin/evio2hipotest +export.sh \ No newline at end of file diff --git a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TimeAverage.java b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TimeAverage.java deleted file mode 100644 index 85dfb5d15c..0000000000 --- a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TimeAverage.java +++ /dev/null @@ -1,389 +0,0 @@ -package org.jlab.rec.rtpc.hit; - -import java.util.Collections; -import java.util.HashMap; -import java.util.Vector; -import java.util.concurrent.ConcurrentHashMap; - -import javax.swing.JFrame; - -import org.jlab.clas.physics.LorentzVector; -import org.jlab.clas.physics.Vector3; -import org.jlab.groot.data.GraphErrors; -import org.jlab.groot.graphics.EmbeddedCanvas; -import org.jlab.groot.math.F1D; - -public class TimeAverage { - - public void TA(HitParameters params, boolean draw) { - - HashMap ADCMap = params.get_R_adc(); - HashMap>> TIDMap = params.get_TIDMap(); - HashMap> trTIDMap = new HashMap>(); - HashMap> FinalTIDMap = new HashMap>(); - Vector PadList = new Vector(); - HashMap> hitlist = new HashMap>(); - int TrigWindSize = params.get_TrigWindSize(); - //int choosetid = 1; - int StepSize = 120; - double thresh = 0; - Vector3 padvec = new Vector3(); - LorentzVector test4vec = new LorentzVector(); - double sumnumer = 0; - double sumdenom = 0; - double maxvalue = 0; - int countadc = 0; - int newtidcounter = 1; - int tidsum = 0; - int min_pads = 3; - double phithresh = 0.6; - double zthresh = 24; - double timethresh = 1500; - - HashMap weightave = new HashMap(); - HashMap weightaveadc = new HashMap(); - - HashMap> gZvsT = new HashMap>(); - HashMap> gPhivsT = new HashMap>(); - - EmbeddedCanvas c = new EmbeddedCanvas(); - c.divide(5, 5); - EmbeddedCanvas c2 = new EmbeddedCanvas(); - c2.divide(5, 5); - int plotcounter = 0; - - JFrame jfr = new JFrame(); - jfr.setSize(1200,1200); - JFrame jfr2 = new JFrame(); - jfr2.setSize(1200,1200); - - - boolean drawellipse = false; - - - F1D ellipse1a = new F1D("ellipse1a","sqrt([b]*[b](1-((x-[h])*(x-[h])/([a]*[a]))))+[k]",2500,4508); - F1D ellipse1b = new F1D("ellipse1b","-sqrt([b]*[b](1-((x-[h])*(x-[h])/([a]*[a]))))+[k]",2500,4508); - F1D ellipse2a = new F1D("ellipse2a","sqrt([b]*[b](1-((x-[h])*(x-[h])/([a]*[a]))))+[k]",2800,4210); - F1D ellipse2b = new F1D("ellipse2b","-sqrt([b]*[b](1-((x-[h])*(x-[h])/([a]*[a]))))+[k]",2800,4210); - ellipse1a.setParameter(0, 50); - ellipse1a.setParameter(1, 3500); - ellipse1a.setParameter(2, 1000); - ellipse1a.setParameter(3, -75); - ellipse1b.setParameter(0, 50); - ellipse1b.setParameter(1, 3500); - ellipse1b.setParameter(2, 1000); - ellipse1b.setParameter(3, -75); - - ellipse2a.setParameter(0, 75); - ellipse2a.setParameter(1, 3500); - ellipse2a.setParameter(2, 1400); - ellipse2a.setParameter(3, -75); - ellipse2b.setParameter(0, 75); - ellipse2b.setParameter(1, 3500); - ellipse2b.setParameter(2, 1400); - ellipse2b.setParameter(3, -75); - - for(int choosetid : TIDMap.keySet()) - { - - for(int time : TIDMap.get(choosetid).keySet()) - { - //System.out.println(time); - for(int pad = 0; pad < TIDMap.get(choosetid).get(time).size(); pad++) - { - if(!PadList.contains(TIDMap.get(choosetid).get(time).get(pad))) - { - PadList.add(TIDMap.get(choosetid).get(time).get(pad)); - } - } - } - - for(int pad = 0; pad < PadList.size(); pad++) - { - for(int time : TIDMap.get(choosetid).keySet()) - { - if(TIDMap.get(choosetid).get(time).contains(PadList.get(pad))) - { - if(ADCMap.get(PadList.get(pad))[time]>maxvalue) - { - maxvalue = ADCMap.get(PadList.get(pad))[time]; - } - } - } - thresh = maxvalue/2; - countadc = 0; - for(int time = 0; time < TrigWindSize; time+=120) - { - if(ADCMap.get(PadList.get(pad))[time] > thresh) - { - sumnumer += ADCMap.get(PadList.get(pad))[time]*time; - sumdenom += ADCMap.get(PadList.get(pad))[time]; - countadc++; - //System.out.println(PadList.get(pad) + " " + time); - } - } - //System.out.println("weightave " + PadList.get(pad) + " " + sumnumer/sumdenom); - weightave.put(PadList.get(pad), sumnumer/sumdenom); - weightaveadc.put(PadList.get(pad), sumdenom); - sumnumer = 0; - sumdenom = 0; - maxvalue = 0; - padvec = PadCoords(PadList.get(pad)); - //gZvsT.addPoint(weightave.get(PadList.get(pad)), padvec.z(), 0, 0); - //gPhivsT.addPoint(weightave.get(PadList.get(pad)), Math.atan2(padvec.y(),padvec.x()),0,0); - } - int pad = 0; - double avetime = 0; - double adc = 0; - trTIDMap.put(choosetid,new Vector()); - for(int p = 0; p < PadList.size(); p++) - { - pad = PadList.get(p); - avetime = weightave.get(pad); - adc = weightaveadc.get(pad); - //LorentzVector v = new LorentzVector(avetime,Math.atan2(PadCoords(pad).y(),PadCoords(pad).x()),PadCoords(pad).z(),pad); - HitVector v = new HitVector(pad,PadCoords(pad).z(),Math.atan2(PadCoords(pad).y(),PadCoords(pad).x()),avetime,adc); - - trTIDMap.get(choosetid).add(v); - } - double smalltime = 0; - for(int i = 0; i < trTIDMap.get(choosetid).size(); i++) - { - smalltime = trTIDMap.get(choosetid).get(i).time(); - for(int j = 0; j < trTIDMap.get(choosetid).size();j++) - { - if(trTIDMap.get(choosetid).get(j).time() < smalltime && i!=j) - { - trTIDMap.get(choosetid).insertElementAt(trTIDMap.get(choosetid).get(i), j); - trTIDMap.get(choosetid).remove(i+1); - break; - } - } - } - int newtid = 150; - - - HitVector padcoords = new HitVector(); - HitVector checkpadcoords = new HitVector(); - - while(trTIDMap.get(choosetid).size()!=0) - { - hitlist.put(choosetid, new Vector()); - hitlist.get(choosetid).add(0); - padcoords = trTIDMap.get(choosetid).get(0); - for(int i = 1; i < trTIDMap.get(choosetid).size(); i++) - { - checkpadcoords = trTIDMap.get(choosetid).get(i); - if(Math.abs(checkpadcoords.time() - padcoords.time()) < timethresh && (Math.abs(checkpadcoords.phi()-padcoords.phi())()); - for(int i = 0; i < hitlist.get(choosetid).size(); i++) - { - trTIDMap.get(newtid).add(trTIDMap.get(choosetid).get(hitlist.get(choosetid).get(i))); - trTIDMap.get(choosetid).set(hitlist.get(choosetid).get(i),new HitVector(0,1e10,0)); - } - for(int i = 0; i < trTIDMap.get(choosetid).size(); i ++) - { - if(trTIDMap.get(choosetid).get(i).time() == 1e10) - { - trTIDMap.get(choosetid).remove(i); - i--; - } - } - hitlist.clear(); - newtid++; - } - trTIDMap.remove(choosetid); - HashMap> mergelist = new HashMap>(); - Vector mergelistvec = new Vector(); - int mergelistindex = 0; - HitVector testvec1 = new HitVector(); - HitVector testvec2 = new HitVector(); - for(int i : trTIDMap.keySet()) - { - mergelist.put(mergelistindex, new Vector()); - for(int f = trTIDMap.get(i).size() - 1; f >= (trTIDMap.get(i).size() - 5) && f > 0; f--) - { - testvec1 = trTIDMap.get(i).get(f); - for(int j : trTIDMap.keySet()) - { - if(i!=j) - { - for(int g = trTIDMap.get(j).size() - 1; g >= (trTIDMap.get(j).size() - 5) && g > 0; g--) - { - //System.out.println(f + " " + g); - testvec2 = trTIDMap.get(j).get(g); - if((Math.abs(testvec1.time() - testvec2.time()) < timethresh) && (Math.abs(testvec1.phi()-testvec2.phi())()); - for(int f = 0; f <= 5; f++) - { - if(f < trTIDMap.get(i).size()) { - testvec1 = trTIDMap.get(i).get(f); - for(int j : trTIDMap.keySet()) - { - if(i!=j) - { - for(int g = trTIDMap.get(j).size() - 1; g >= (trTIDMap.get(j).size() - 5) && g > 0; g--) - { - //System.out.println(f + " " + g); - testvec2 = trTIDMap.get(j).get(g); - if((Math.abs(testvec1.time() - testvec2.time()) < timethresh) && (Math.abs(testvec1.phi()-testvec2.phi())1) - { - TIDtokeep = mergelist.get(i).get(0); - for(int l = 1; l < mergelist.get(i).size(); l++) - { - TIDtomerge = mergelist.get(i).get(l); - trTIDMap.get(TIDtokeep).addAll(trTIDMap.get(TIDtomerge)); - trTIDMap.remove(TIDtomerge); - } - } - } - Vector toremove = new Vector(); - for(int i : trTIDMap.keySet()) - { - if(trTIDMap.get(i).size() < min_pads) - { - toremove.add(i); - } - } - for(int i = 0; i < toremove.size(); i++) - { - trTIDMap.remove(toremove.get(i)); - } - gZvsT.put(choosetid, new HashMap()); - c.cd(plotcounter); - gPhivsT.put(choosetid, new HashMap()); - c2.cd(plotcounter); - for(int i : trTIDMap.keySet()) - { - FinalTIDMap.put(newtidcounter,new Vector()); - gZvsT.get(choosetid).put(i, new GraphErrors()); - gZvsT.get(choosetid).get(i).setTitle("Z vs T"); - gPhivsT.get(choosetid).put(i, new GraphErrors()); - gPhivsT.get(choosetid).get(i).setTitle("Phi vs T"); - for(int j = 0; j < trTIDMap.get(i).size(); j++) - { - gZvsT.get(choosetid).get(i).addPoint(trTIDMap.get(i).get(j).time(), trTIDMap.get(i).get(j).z(), 0, 0); - gPhivsT.get(choosetid).get(i).addPoint(trTIDMap.get(i).get(j).time(), trTIDMap.get(i).get(j).phi(), 0, 0); - FinalTIDMap.get(newtidcounter).add(trTIDMap.get(i).get(j)); - } - gZvsT.get(choosetid).get(i).setMarkerSize(2); - gZvsT.get(choosetid).get(i).setMarkerColor(i-149); - gPhivsT.get(choosetid).get(i).setMarkerSize(2); - gPhivsT.get(choosetid).get(i).setMarkerColor(i-149); - c.draw(gZvsT.get(choosetid).get(i),"same"); - c2.draw(gPhivsT.get(choosetid).get(i),"same"); - newtidcounter++; - } - tidsum+= trTIDMap.size(); - PadList.clear(); - weightave.clear(); - trTIDMap.clear(); - hitlist.clear(); - mergelist.clear(); - plotcounter++; - } - //System.out.println(plotcounter); - //System.out.println("tidsum " + tidsum + "final map size " + FinalTIDMap.size()); - /* - for(int i : gZvsT.keySet()) - { - c.cd(plotcounter); - for(int j : gZvsT.get(i).keySet()) - { - c.draw(gZvsT.get(i).get(j),"same"); - } - plotcounter++; - }*/ - if(draw) { - jfr.add(c); - jfr.setTitle("Time Averaged ZvsT"); - jfr.setVisible(true); - jfr2.add(c2); - jfr2.setTitle("Time Averaged PhivsT"); - jfr2.setVisible(true); - } - params.set_FinalTimeMap(FinalTIDMap); - } - - private Vector3 PadCoords(int cellID) { - - double PAD_W = 2.79; // in mm - double PAD_S = 80.0; //in mm - double PAD_L = 4.0; // in mm - double RTPC_L= 384.0; // in mm - double phi_pad = 0; - //double Num_of_Rows = (2.0*(Math.PI)*PAD_S)/PAD_W; - double Num_of_Cols = RTPC_L/PAD_L; - double PI=Math.PI; - double z0 = -(RTPC_L/2.0); - double phi_per_pad = PAD_W/PAD_S; // in rad - double chan = (double)cellID; - double col = chan%Num_of_Cols; - double row=(chan-col)/Num_of_Cols; - double z_shift = row%4; - - phi_pad=(row*phi_per_pad)+(phi_per_pad/2.0); - - if(phi_pad>= 2.0*PI) - { - phi_pad -= 2.0*PI; - } - if(phi_pad<0) - { - phi_pad += 2.0*PI; - } - - double z_pad=z0+(col*PAD_L)+(PAD_L/2.0)+z_shift; - - Vector3 PadCoords = new Vector3(PAD_S*Math.cos(phi_pad),PAD_S*Math.sin(phi_pad),z_pad); - return PadCoords; - - } - - -} diff --git a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TrackFinder2.java b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TrackFinder2.java deleted file mode 100644 index fdfe402efb..0000000000 --- a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TrackFinder2.java +++ /dev/null @@ -1,994 +0,0 @@ -package org.jlab.rec.rtpc.hit; - -import java.awt.Component; -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.concurrent.ConcurrentHashMap; -import java.util.List; -import java.util.Vector; -import javax.swing.JFrame; -import org.jlab.groot.data.*; -import org.jlab.groot.fitter.*; -import org.jlab.groot.graphics.*; -import org.jlab.groot.math.F1D; -import org.jlab.groot.ui.TCanvas; -//import org.jlab.clas.physics.Vector3; - - - -public class TrackFinder2 { - - /*************************************** - * Author: David Payette - * - * The function FindTrack2 is divided into 3 main parts, the sorting algorithm, the merging algorithm, - * and plotting. The sorting algorithm builds a map call TIDMap. It starts empty and will be filled with - * track IDs (TIDs), each one returning a map of time slices (120 ns) that each contain a vector of pads which were sorted - * together in this time slice. So TIDMap.get(1).get(120).get(3) will give you the fourth pad at 120 ns that has TID 1. - * The sorting algorithm contains a series of nested loops as follows: The TIMELOOP loops through values of time starting - * at 0 and moving in steps of 120 ns up to the TrigWindSize (10000 ns). Then there is a PADLOOP which loops through all - * the pads which saw a signal in the simulation. The signal shape is created in PadHit for now since GEMC does not do signal - * simulation for our purposes yet. This signal is then integrated into 120 ns bins which is based on the Dream chip timing. - * For each pad in the loop, it checks for the ADC value at the current time, - * and if it passes an ADC threshold, then it moves on to be sorted. The TIDLOOP loops through all elements of a vector TIDVec, - * which initially only contains TID 1 and will add TIDs as necessary. If the TIDMap does not contain the current TID in the - * vector then it adds it to the map. Otherwise, the current pad in the loop is checked against all other pads assigned to - * the current TID by comparing the distance between the pads to a preset ellipse formula. This check is done for the current - * time slice, and a set number (timeadj) of previous time slices. If a pad is close enough to another pad with an assigned - * TID then it is also assigned this TID. A pad is allowed to be assigned multiple TIDs at this stage, which will flag the - * merging algorithm to remember to merge these TIDs later after the sort. If a pad makes it to the end of the TIDLOOP and still - * has not been sorted then it will be assigned a new TID as the new TID is added to the map. The merging algorithm looks - * for TIDs which were flagged to be merged during sort and combines them all into the lowest numbered TID and then the - * other TIDs are removed from the map. - * - * TIMELOOP: 0->10000 in 120 ns steps - * { - * PADLOOP: All pads which have an ADC value that passes threshold for current time - * { - * TIDLOOP: Loop through TIDs in TIDVec - * if(TID is in map){ Compare pad to other pads (PADINDEXLOOP) in current and previous times (PREVTIMELOOP) and see - * if it is near enough (using ellipse formula) } - * else{ If pad has not been assigned at least one TID, assign it a new one and add it to the map } - * - * if(pad has more than one TID){ group the TIDs into MapCombine, using the smallest one as the key } - * } - * } - * - * Loop over the keys of MapCombine, and take all the TIDs assigned to each key and merge them into the key TID and - * remove them from the TIDMap. - * - * Plot a bunch of stuff for testing. - * - * The ellipse formula looks like this: - * - * (dx^2 + dy^2)/phi_0^2 + (dz^2)/z_0^2 <= adjthresh^2 - * - * dx, dy, and dz are the distances between two pads, phi_0 and z_0 are set parameters that define the ellipse, - * and adjthresh is the maximum level of adjacency we allow. This determines how many rings of adjacent pads are - * close enough. - ****************************************/ - - public void FindTrack2(HitParameters params, boolean draw){ - /*************************************** - * - * INITIALIZE VARIABLES - * - ****************************************/ - //HashMap> TIDMap = new HashMap>(); - //HashMap PadThresh = new HashMap(); - //HashMap>> FixedTIDMap = new HashMap>>(); - //double PadPhistore = 0; - //double PadZstore = 0; - //boolean PadPhiChanged = false; - //Necessary pad variables - //double PAD_W = 2.79; //in mm - //double PAD_S = 80.0; //in mm - //double Num_of_Rows = (2.0*(Math.PI)*PAD_S)/PAD_W; - //int padindexmax = 0; Not being used currently - //double time1 = System.currentTimeMillis(); - /* Not being used currently - * int maxconcpads = 0; - * int concpads = 0; - * int maxconctime = 0; - */ - - - - HashMap ADCMap = params.get_R_adc(); //Key - Cell ID, Value - Array of signal height over time slices - - /** - * TIDMap contains a HashMap of Vectors - * The key is Track ID (TID), which returns a map - * The key of the returned map is Time, which returns a vector - * The elements of the vector are pads - * This stores all pads in each time slice, and all time slices for each TID - * Example :: Track ID 1, Time 120 contains pads: 3,4,5,7 so using the call - * TIDMap.get(1).get(120).get(3) will give you pad 5 - */ - HashMap>> TIDMap = new HashMap>>(); - - /** - * strkTIDMap uses the same structure as TIDMap but is used at the end to isolate - * TIDs which only contain single tracks. This map is all TIDs not sent to the disentangler - */ - HashMap>> strkTIDMap = new HashMap>>(); - - - Vector PadNum = params.get_PadNum(); //Contains pads used in PadHit - Vector TIDVec = new Vector<>(); //Contains all TIDs and is added to throughout, - TIDVec.add(1); //Starts with TID 1 - - - int Pad = 0; //initializing pad - double ADC = 0; //initializing ADC - int TrigWindSize = params.get_TrigWindSize(); //Trigger Window Size = 10000 - //int StepSize = params.get_StepSize(); - int StepSize = 120; //Time stepsize in ns - double adcthresh = 5e-4; //Arbitrary ADC threshold - - int min_pads = 0; //Minimum number of pads required to keep as a track - - //These vectors will contain x,y,z for each pad being checked - //Vector3 TempPadCoords = new Vector3(); - //Vector3 CheckPadCoords = new Vector3(); - //Vector3 CheckPadPrevCoords = new Vector3(); - - PadVector TempPadCoords;// = new PadVector(); - PadVector CheckPadCoords; - PadVector CheckPadPrevCoords; - - int TID = 0; //initialize TID - - //used for plotting - double plotphi = 0; - double plotz = 0; - - int timeadj = 2; //How many previous time slices to check in algorithm - int event = params.get_eventnum(); //event number only used for file number - - - //Initialize Ellipse Variables used for adjacency checks - double adjthresh = 12; //sqrt(right hand side of ellipse formula) - double EllipseDeltax = 0; //dx - double EllipseDeltay = 0; //dy - double EllipseDeltaz = 0; //dz - double EllipseTotal = 0; //left hand side of ellipse formula - double PhiDelta = 16; //phi_0 - double ZDelta = 36; //z_0 - - double phithresh = 0.15; - double zthresh = 10; - - //set variables for timing cut (currently time cut is not used, cuts on time happen later) - int tmin = 0; //min timing in ns - int trange = 20000; //added to min to calculate max in ns - int tmax = tmin+trange; - - //Maps and variables used for combining TIDs later in the merge algorithm - boolean PadSorted = false; - Vector PadTIDcollect = new Vector(); - Vector TIDcombine = new Vector(); - HashMap> MapCombine = new HashMap>(); - int mapkey = 0; - - //Map of graphs of ADC vs Time - HashMap gADCvsT = new HashMap(); - - //g.setTitleX("Phi"); - //g.setTitleY("Z"); - //g.setMarkerSize(5); - - try { - File f = new File("/Users/davidpayette/Documents/FileOutput/Output" + event + ".txt"); - f.delete(); - FileWriter write2 = new FileWriter("/Users/davidpayette/Documents/FileOutput/Output" + event + ".txt",true); - //File f2 = new File("/Users/davidpayette/Documents/FileOutput/Master.txt"); - FileWriter write3 = new FileWriter("/Users/davidpayette/Documents/FileOutput/Master.txt",true); - //Collections.sort(PadNum); - //H1F t2 = new H1F("t2","t2",TrigWindSize/StepSize,0,TrigWindSize); - - GraphErrors t1 = new GraphErrors(); - int counter = 0; - HashMap countermap = new HashMap(); - - /*************************************** - * - * SORTING ALGORITHM - * - ****************************************/ - /**loop over all times in 120 ns slices**/ - TIMELOOP: //these labels are not used for the most part, but help to label the loops - for(int t = 0; t < TrigWindSize; t += StepSize) - { - //System.out.println("Time is " + t); - //concpads = 0; - - /**loop over all pads for each time slice**/ - int padloopsize = PadNum.size(); - PADLOOP: - for(int p = 0; p < padloopsize; p++) - { - - PadSorted = false; - PadTIDcollect.clear(); - Pad = PadNum.get(p); - - //System.out.println(PadNum.size() + " size"); - //System.out.println(Pad + " " + t); - - ADC = ADCMap.get(Pad)[t]; - - /**only pads which have an ADC value above threshold will be assigned a TID**/ - if(ADC > adcthresh) - { - //write3.write(ADC + "\n"); - /**This is used for testing something else**/ - if(Pad == 11091) - { - t1.addPoint(t, ADCMap.get(Pad)[t], 0, 0); - //t2.fill(t); - } - if(!countermap.containsKey(Pad)) - { - countermap.put(Pad, 1); - } - else - { - counter = countermap.get(Pad); - counter++; - countermap.put(Pad,counter); - } - - //Plots ADC vs T for each Pad - if(!gADCvsT.containsKey(Pad)) - { - gADCvsT.put(Pad, new GraphErrors()); - gADCvsT.get(Pad).addPoint(t, ADCMap.get(Pad)[t], 0, 0); - } - else - { - gADCvsT.get(Pad).addPoint(t, ADCMap.get(Pad)[t], 0, 0); - } - /*******************************************/ - //System.out.println("Pad to be checked " + Pad + " checked at time " + t); - - //returns x,y,z of the current Pad - //Vector3 PadCoords = PadCoords(Pad); - PadVector PadCoords = params.get_padvector(Pad); - - //System.out.println("Pad " + Pad + " has row and column values " + PadPhi + " " + PadZ); - //g.addPoint(PadPhi, PadZ, 0, 0); - - /**loop through all TID's in a vector which will grow to include all future TID's**/ - int tidloopsize = TIDVec.size(); - TIDLOOP: - for(int i = 0; i < tidloopsize; i++) - { - TID = TIDVec.get(i); //returns current TID to sort into - //System.out.println("Current TID " + TID); - - /**if TID is already in the map**/ - if(TIDMap.containsKey(TID)) - { - //System.out.println("TID " + TID + " is already in the map"); - - /**loop through all pads in TIDMap and compare there row and column to current Pad**/ - PADINDEXLOOP: - for(int padindex = 0; padindex < 100; padindex++) //TODO 100 is unnecessary placeholder - { - //System.out.println("Pad index is " + padindex); - if(padindex < TIDMap.get(TID).get(t).size()) - { - //CheckPadCoords = PadCoords(TIDMap.get(TID).get(t).get(padindex)); //Get the x,y,z of the pad we are checking against - CheckPadCoords = params.get_padvector(TIDMap.get(TID).get(t).get(padindex)); - //System.out.println("At TID " + TID + " time " + t + " padindex " + padindex + " the check pad's location is " + checkpadphi + " " + checkpadz); - //System.out.println("Current time " + checkpadphi + " " + PadPhi + " " + checkpadz + " " + PadZ + " " + Math.abs(checkpadphi-PadPhi) + " " + Math.abs(checkpadz - PadZ)); - //System.out.println("Current time slice " + PadPhi + " " + PadZ + " " + " " + checkpadphi + " " + checkpadz); - //System.out.println("The comparison values for the pad to be sorted at current time are " + Math.abs(checkpadphi-PadPhi) + " " + Math.abs(checkpadz - PadZ)); - - /**Check current time slice for adjacency**/ - /**Calculates the ellipse parameters**/ - EllipseDeltax = Math.abs(PadCoords.x()-CheckPadCoords.x())*Math.abs(PadCoords.x()-CheckPadCoords.x()); - EllipseDeltay = Math.abs(PadCoords.y()-CheckPadCoords.y())*Math.abs(PadCoords.y()-CheckPadCoords.y()); - EllipseDeltaz = Math.abs(PadCoords.z()-CheckPadCoords.z())*Math.abs(PadCoords.z()-CheckPadCoords.z()); - EllipseTotal = ((EllipseDeltax+EllipseDeltay)/PhiDelta) + (EllipseDeltaz/ZDelta); - //System.out.println("Ellipse is " + EllipseTotal); - - /** - * If the ellipse equation falls within the accepted size assign the - * TID of the checked pad to the current pad in the loop - **/ - //if(EllipseTotal <= adjthresh) - if((Math.abs(CheckPadCoords.phi()-PadCoords.phi())0) - { - /**Loops through a variable number (timeadj) of previous time slices to see if it is adjacent to earlier pads**/ - PREVTIMELOOP: - for(int prevtime = t - StepSize; (prevtime >= (t - (timeadj*StepSize))) && (prevtime >= 0); prevtime -= StepSize) - { - if(padindex < TIDMap.get(TID).get(prevtime).size()) - { - //CheckPadPrevCoords = PadCoords(TIDMap.get(TID).get(prevtime).get(padindex)); //Get the x,y,z of the pad we are checking against - CheckPadPrevCoords = params.get_padvector(TIDMap.get(TID).get(prevtime).get(padindex)); - /**Calculates the ellipse parameters**/ - EllipseDeltax = Math.abs(PadCoords.x()-CheckPadPrevCoords.x())*Math.abs(PadCoords.x()-CheckPadPrevCoords.x()); - EllipseDeltay = Math.abs(PadCoords.y()-CheckPadPrevCoords.y())*Math.abs(PadCoords.y()-CheckPadPrevCoords.y()); - EllipseDeltaz = Math.abs(PadCoords.z()-CheckPadPrevCoords.z())*Math.abs(PadCoords.z()-CheckPadPrevCoords.z()); - EllipseTotal = ((EllipseDeltax+EllipseDeltay)/PhiDelta) + (EllipseDeltaz/ZDelta); - //System.out.println("Ellipse is " + EllipseTotal); - - //System.out.println("Previous time slice " + PadPhi + " " + PadZ + " " + " " + checkpadphiprev + " " + checkpadzprev); - //System.out.println("The comparison values for the pad to be sorted at previous time are " + Math.abs(checkpadphiprev-PadPhi) + " " + Math.abs(checkpadzprev - PadZ)); - /** - * If the ellipse equation falls within the accepted size assign the - * TID of the checked pad to the current pad in the loop - **/ - //if(EllipseTotal <= adjthresh) - if((Math.abs(CheckPadPrevCoords.phi()-PadCoords.phi())< phithresh || (Math.abs(CheckPadPrevCoords.phi()-PadCoords.phi()-2*Math.PI) < phithresh )) && Math.abs(CheckPadPrevCoords.z()-PadCoords.z())>()); - for(int time = 0; time < TrigWindSize; time += StepSize) - { - TIDMap.get(TID).put(time, new Vector<>()); //add TID to map - } - TIDMap.get(TID).get(t).add(Pad); - //PadTIDcollect.add(TID); - TIDVec.add(TID+1); //add TID to the list - } - break TIDLOOP; //makes sure the TID loop doesn't go forever since we are adding a new TID to the list - } - } // End TIDLOOP // - - /** Pad has more than one TID in this time slice **/ - if(PadTIDcollect.size()>1) - { - - //System.out.println("PadTIDcollect is " + PadTIDcollect.size()); - /*for(int i : MapCombine.keySet()) - { - if(MapCombine.get(i).size()>0) - { - for(int jZvsPhi = 0; jZvsPhi()); - } - //System.out.println("TID to merge " + mapkey); - - /**Loops through remaining TIDs to be merged and puts them into a map together**/ - for(int i = 1; i < PadTIDcollect.size(); i++) - { - /*if(!TIDcombine.contains(PadTIDcollect.get(i))) - { - MapCombine.get(mapkey).add(PadTIDcollect.get(i)); - //TIDcombine.add(PadTIDcollect.get(i)); - }*/ - if(!MapCombine.get(mapkey).contains(PadTIDcollect.get(i))) - { - MapCombine.get(mapkey).add(PadTIDcollect.get(i)); - } - //System.out.println("TID to merge " + PadTIDcollect.get(i)); - } - //TIDcombine.clear(); - } - } - //else {System.out.println("Pad " + Pad + " failed ADC threshold at time " + t);} - } // End PADLOOP // - - } // End TIMELOOP // - System.out.println("This event has " + TIDMap.size() + " tracks"); - EmbeddedCanvas chist = new EmbeddedCanvas(); - JFrame jhist = new JFrame(); - jhist.setSize(800, 600); - if(draw == true) - { - chist.draw(t1); - jhist.add(chist); - jhist.setVisible(true); - jhist.setTitle("histo"); - } - - - /*************************************** - * - * MERGE ALGORITHM - * - ****************************************/ - - //Merge Tracks - - int TIDtomerge = 0; //TID we are putting into the TIDtokeep - int TIDtokeep = 0; - //Vector TIDtoremove = new Vector(); - //for(int i : TIDMap.keySet()) {System.out.println("all TIDs before " + i );} - - /** - * For each TID that needs other TIDs to be merged into it - * we get each TID from the Map assigned to the TIDtokeep key and merge the TIDs together - * then remove the other TIDs (TIDtomerge) from the map - */ - for(int j : MapCombine.keySet()) - { - if(MapCombine.get(j).size() == 0) {break;} - TIDtokeep = j; - for(int i = 0; i < MapCombine.get(j).size(); i++) - { - TIDtomerge = MapCombine.get(j).get(i); - //TIDtoremove.add(TIDtomerge); - for(int time = 0 ; time < TrigWindSize; time+=StepSize) - { - if(TIDMap.containsKey(TIDtomerge) && TIDMap.containsKey(TIDtokeep)) - { - if(TIDMap.get(TIDtomerge).get(time).size()>0) - { - for(int padindex = 0; padindex < TIDMap.get(TIDtomerge).get(time).size(); padindex++) - { - TIDMap.get(TIDtokeep).get(time).add(TIDMap.get(TIDtomerge).get(time).get(padindex)); - } - } - } - } - TIDMap.remove(TIDtomerge); - } - //System.out.println(MapCombine.get(jZvsPhi).size()); - } - - //for(int i = 0; i < TIDtoremove.size(); i++) {TIDMap.remove(TIDtoremove.get(i));} - //for(int i : TIDMap.keySet()) {System.out.println("all TIDs after " + i );} - - /*************************************** - * - * PLOTS - * - ****************************************/ - //TESTING STUFF - int countermax = 0; - int padmax = 0; - int howmanyhits = 0; - for(int i : countermap.keySet()) - { - howmanyhits += countermap.get(i); - if(countermap.get(i)>countermax) - { - countermax = countermap.get(i); - padmax = i; - //System.out.println("countermax " + i + " " + countermax); - } - } - System.out.println("this many hits " + howmanyhits + " this many pads " + countermap.size()); - - - HashMap gZvsPhi = new HashMap(); - //HashMap graphmap2 = new HashMap(); - //EmbeddedCanvas tcan = new EmbeddedCanvas(); - //TCanvas tcan = new TCanvas("t", 800, 600); - for(int testTID : TIDMap.keySet()) - { - for(int time = 0; time < TrigWindSize; time+=StepSize) - { - for(int pad = 0; pad < TIDMap.get(testTID).get(time).size(); pad++) - { - //TempPadCoords = PadCoords(TIDMap.get(testTID).get(time).get(pad)); //gets x,y,z - TempPadCoords = params.get_padvector(TIDMap.get(testTID).get(time).get(pad)); - //plotphi = Math.atan2(TempPadCoords.y(),TempPadCoords.x()); //Phi - plotphi = TempPadCoords.phi(); - plotz = TempPadCoords.z(); //Z - //System.out.println(plotphi + " " + plotz); - - if(!gZvsPhi.containsKey(testTID)) - { - gZvsPhi.put(testTID, new GraphErrors()); - } - - gZvsPhi.get(testTID).addPoint(plotphi, plotz, 0, 0); //Plots Phi, Z for each track - - - //write2.write(testTID + "\t" + time + "\t" + plotphi + "\t" + plotz + "\n"); - } - - - /*if(TIDMap.get(testTID).get(a1).size()>0) - { - gZvsPhi.get(testTID).addPoint(0, 0, 0, 0); - gZvsPhi.get(testTID).addPoint(6.5, 20, 0, 0); - //tcan.draw(gZvsPhi.get(testTID)); - //tcan.save("/Users/davidpayette/Desktop/Plots/" + a1 + ".jpg"); - //tcan.repaint(); - graphmap2.put(a1, new TCanvas(" ",800,600)); - graphmap2.get(a1).draw(gZvsPhi.get(testTID)); - graphmap2.get(a1).save("/Users/davidpayette/Desktop/Plots/" + a1 + ".jpg"); - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - }*/ - - } - } - - //F1D fitfunc1 = new F1D("f","[0]*x+[1]",0,9000); - //F1D fitfunc1 = new F1D("p1"); - //fitfunc1.setParameter(0, 1); - //fitfunc1.setParameter(1,0); - - //Vector3 vZvsT = new Vector3(); - GraphErrors gZvsT = new GraphErrors(); - EmbeddedCanvas cZvsT = new EmbeddedCanvas(); - Vector PadTracker = new Vector(); - JFrame jZvsT = new JFrame(); - jZvsT.setSize(800,600); - - /*int choosetid = 0; - for(int t : TIDMap.get(choosetid).keySet()) - { - //System.out.println(t); - for(int p = 0; p cADCvsT = new HashMap(); - GraphErrors gHitsvsPad = new GraphErrors(); - EmbeddedCanvas cHitsvsPad = new EmbeddedCanvas(); - JFrame jHitsvsPad = new JFrame(); - int mod25 = (PadTracker.size() - (PadTracker.size() % 25))/25; - //System.out.println(mod25); - for(int k = 0; k <= mod25; k++) - { - cADCvsT.put(k, new EmbeddedCanvas()); - cADCvsT.get(k).divide(5, 5); - } - - //System.out.println("size of PadTracker " + PadTracker.size()); - int numplots = 0; - int whichplot = 0; - for(int h = 0; h < PadTracker.size(); h++) - { - gHitsvsPad.addPoint(PadTracker.get(h), countermap.get(PadTracker.get(h)), 0, 0); - cADCvsT.get(whichplot).cd(numplots); - gADCvsT.get(PadTracker.get(h)).setTitle(""+PadTracker.get(h)); - gADCvsT.get(PadTracker.get(h)).addPoint(0, 0, 0, 0); - gADCvsT.get(PadTracker.get(h)).addPoint(9000, 0, 0, 0); - gADCvsT.get(PadTracker.get(h)).setMarkerSize(2); - cADCvsT.get(whichplot).draw(gADCvsT.get(PadTracker.get(h))); - if(h % 25 == 0 && h > 0) - { - whichplot++; - numplots=0; - } - else - { - numplots++; - } - } - if(draw == true) - { - gHitsvsPad.setMarkerSize(2); - cHitsvsPad.draw(gHitsvsPad); - jHitsvsPad.add(cHitsvsPad); - jHitsvsPad.setTitle("jHitsvsPad"); - jHitsvsPad.setSize(800, 600); - jHitsvsPad.setVisible(true); - HashMap jADCvsT = new HashMap(); - for(int k : cADCvsT.keySet()) - { - jADCvsT.put(k, new JFrame()); - jADCvsT.get(k).setSize(1200,800); - jADCvsT.get(k).setTitle("jADCvsT" + " " + k); - jADCvsT.get(k).add(cADCvsT.get(k)); - jADCvsT.get(k).setVisible(true); - } - //DataFitter.fit(fitfunc1, gZvsT, "QER"); - //System.out.println(fitfunc1.getChiSquare()); - - gZvsT.setMarkerSize(1); - cZvsT.draw(gZvsT); - //cZvsT.draw(fitfunc1,"same"); - jZvsT.add(cZvsT); - jZvsT.setVisible(true); - } - int tlargest = 0; - //System.out.println("before " + TIDMap.size()); - //int loopsize = TIDMap.size(); - Vector toremove = new Vector(); - Vector PadList = new Vector(); - for(int testTID : TIDMap.keySet()) - { - - for(int t = 0; t < TrigWindSize; t += StepSize) - { - for(int pad = 0; pad < TIDMap.get(testTID).get(t).size(); pad++) - { - if(!PadList.contains(TIDMap.get(testTID).get(t).get(pad))) - { - PadList.add(TIDMap.get(testTID).get(t).get(pad)); - } - - if(t > tlargest) - { - tlargest = t; - } - if(t>4000) - { - //System.out.println(pad + " " + t); - } - } - } - //System.out.println(tlargest); - if(tlargest < tmin || tlargest > tmax) - { - toremove.add(testTID); - //TIDMap.remove(testTID); - //gZvsPhi.remove(testTID); - - } - //System.out.println("large T " + tlargest); - tlargest = 0; - if(PadList.size() <= min_pads) - { - if(!toremove.contains(testTID)) - { - toremove.add(testTID); - } - } - PadList.clear(); - } - HashMap> padmap = new HashMap>(); - int padlook = 0; - for(int i = 0; i < toremove.size(); i++) - { - TIDMap.remove(toremove.get(i)); - } - HashMap hZvsT = new HashMap(); - HashMap hPhivsT = new HashMap(); - //Vector3 padv = new Vector3(); - PadVector padv; - double padphi = 0; - double padz = 0; - for(int tid : TIDMap.keySet()) - { - padmap.put(tid, new Vector()); - hPhivsT.put(tid, new H2F("hPhivsT","hPhivsT",80,0,9600,90,-Math.PI,Math.PI)); - hZvsT.put(tid, new H2F("hZvsT","hZvsT",80,0,9600,50,-200,200)); - - for(int time : TIDMap.get(tid).keySet()) - { - for(int p = 0; p < TIDMap.get(tid).get(time).size(); p++) - { - /*padlook = TIDMap.get(tid).get(time).get(p); - if(!padmap.get(tid).contains(padlook)) - { - padmap.get(tid).add(padlook); - }*/ - //padv = PadCoords(TIDMap.get(tid).get(time).get(p)); - padv = params.get_padvector(TIDMap.get(tid).get(time).get(p)); - //padphi = Math.atan2(padv.y(),padv.x()); - padphi = padv.phi(); - padz = padv.z(); - //System.out.println(time + " " + padz); - hZvsT.get(tid).fill((double)time, padz); - hPhivsT.get(tid).fill((double)time, padphi); - } - } - } - int pcount = 0; - toremove.clear(); - double histmaxavez = 0; - double histmaxavephi = 0; - - //System.out.println("HERE " + hZvsT.size()); - EmbeddedCanvas chZvsT = new EmbeddedCanvas(); - EmbeddedCanvas chPhivsT = new EmbeddedCanvas(); - JFrame jhZvsT = new JFrame(); - JFrame jhPhivsT = new JFrame(); - chZvsT.divide(5,5); - chPhivsT.divide(5, 5); - jhZvsT.setSize(1200,1200); - jhPhivsT.setSize(1200,1200); - jhZvsT.setTitle("Z vs T 2d Hist"); - jhPhivsT.setTitle("Phi vs T 2d Hist"); - for(int i : hZvsT.keySet()) - { - histmaxavez+=hZvsT.get(i).getMax(); - histmaxavephi+=hPhivsT.get(i).getMax(); - } - histmaxavez/=hZvsT.size(); - histmaxavephi/=hPhivsT.size(); - for(int i : hZvsT.keySet()) - { - //System.out.println(hZvsT.get(i).getMax() + " " + hPhivsT.get(i).getMax() + " " + histmaxavez + " " + histmaxavephi); - //if(hZvsT.get(i).getMax() < 10 || hPhivsT.get(i).getMax() < 10) - if(hZvsT.get(i).getMax() < histmaxavez*0.75 && hPhivsT.get(i).getMax() < histmaxavephi*0.75) - { - if(!toremove.contains(i)) - { - toremove.add(i); - } - } - chZvsT.cd(pcount); - chPhivsT.cd(pcount); - chZvsT.draw(hZvsT.get(i)); - chPhivsT.draw(hPhivsT.get(i)); - pcount++; - } - jhZvsT.add(chZvsT); - jhPhivsT.add(chPhivsT); - - if(draw) { - jhZvsT.setVisible(true); - jhPhivsT.setVisible(true); - } - //for(int i : TIDMap.keySet()) {System.out.println(i + " before");} - for(int i = 0; i < toremove.size(); i++) - { - //System.out.println(TIDMap.get(toremove.get(i)).size()); - strkTIDMap.put(toremove.get(i), TIDMap.get(toremove.get(i))); - TIDMap.remove(toremove.get(i)); - } - /*for(int i : strkTIDMap.keySet()) - { - for(int j : strkTIDMap.get(i).keySet()) - { - for(int k = 0; k < strkTIDMap.get(i).get(j).size(); k ++) - { - System.out.println(x); - } - } - }*/ - //for(int i : TIDMap.keySet()) {System.out.println(i + " after");} - //for(int i = 0; i < toremove.size()) - /*for(int tid : TIDMap.keySet()) - { - for(int p = 0; p < padmap.get(tid).size(); p++) - { - padv = PadCoords(padmap.get(tid).get(p)); - padphi = Math.atan2(padv.y(),padv.x()); - padz = padv.z(); - for(int time : TIDMap.get(tid).keySet()) - { - if(TIDMap.get(tid).get(time).contains(padmap.get(tid).get(p))) - { - - } - } - } - }*/ - - //System.out.println(tlargest); - int color = 1; - int style = 1; - - //for(int i : TIDMap.keySet()) {System.out.println(i);} - //System.out.println("after " + TIDMap.size()); - //System.out.println(maxconcpads + " " + maxconctime + " " + TIDVec.size()); - if(draw) - { - - EmbeddedCanvas cZvsPhi = new EmbeddedCanvas(); - JFrame jZvsPhi = new JFrame(); - jZvsPhi.setSize(800,600); - for(int i : TIDMap.keySet()) - { - //System.out.println(i); - //if(i == 1) - //{ - gZvsPhi.get(i).setMarkerColor(color); - if(false)//if(i == 1) - { - gZvsPhi.get(i).setMarkerSize(6); - } - else - { - gZvsPhi.get(i).setMarkerSize(2); - } - //gZvsPhi.get(i).addPoint(0, 0, 0, 0); - //gZvsPhi.get(i).addPoint(180, 100, 0, 0); - - //gZvsPhi.get(i).setMarkerStyle(style); - - cZvsPhi.draw(gZvsPhi.get(i),"same"); - //cZvsPhi.save("/Users/davidpayette/Desktop/Plots/g" + i + ".png"); - color++; - style++; - - //} - //System.out.println("key " + i + " " + TIDMap.size()); - } - jZvsPhi.setTitle("Track Finder Output"); - jZvsPhi.add(cZvsPhi); - jZvsPhi.setVisible(true); - - } - write2.close(); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - for(int i : TIDMap.keySet()) - { - //System.out.println("TIDMap TIDs " + i); - } - for(int i : strkTIDMap.keySet()) - { - //System.out.println("strkTIDMap TIDs " + i); - } - params.set_TIDMap(TIDMap); - params.set_strkTIDMap(strkTIDMap); - //TIDMap.clear(); - //System.out.println(System.currentTimeMillis()-time1); - } - - /**Returns x, y, z as a vector, given pad number**/ - /* - private Vector3 PadCoords(int cellID) { - - double PAD_W = 2.79; // in mm - double PAD_S = 80.0; //in mm - double PAD_L = 4.0; // in mm - double RTPC_L= 384.0; // in mm - double phi_pad = 0; - //double Num_of_Rows = (2.0*(Math.PI)*PAD_S)/PAD_W; - double Num_of_Cols = RTPC_L/PAD_L; - double PI=Math.PI; - double z0 = -(RTPC_L/2.0); - double phi_per_pad = PAD_W/PAD_S; // in rad - double chan = (double)cellID; - double col = chan%Num_of_Cols; - double row=(chan-col)/Num_of_Cols; - double z_shift = row%4; - - phi_pad=(row*phi_per_pad)+(phi_per_pad/2.0); - - if(phi_pad>= 2.0*PI) - { - phi_pad -= 2.0*PI; - } - if(phi_pad<0) - { - phi_pad += 2.0*PI; - } - - double z_pad=z0+(col*PAD_L)+(PAD_L/2.0)+z_shift; - - Vector3 PadCoords = new (PAD_S*Math.cos(phi_pad),PAD_S*Math.sin(phi_pad),z_pad); - return PadCoords; - - } - - */ - - - //old functions, maybe used later - /*private double PadPhi(int cellID) { - - double PAD_W = 2.79; // in mm - double PAD_S = 80.0; //in mm - double PAD_L = 4.0; // in mm - double RTPC_L=400.0; // in mm - - double phi_pad = 0; - - double Num_of_Rows = (2.0*(Math.PI)*PAD_S)/PAD_W; - double Num_of_Cols = RTPC_L/PAD_L; - double TotChan = Num_of_Rows*Num_of_Cols; - - double PI=Math.PI; - - - - double phi_per_pad = PAD_W/PAD_S; // in rad - - double chan = (double)cellID; - double col = chan%Num_of_Cols; - double row=(chan-col)/Num_of_Cols; - - - //double z_shift = 0.; - - phi_pad=(row*phi_per_pad)+(phi_per_pad/2.0); - if(phi_pad>= 2.0*PI) { - phi_pad -= 2.0*PI; - } - if(phi_pad<0) - { - phi_pad += 2.0*PI; - } - - return phi_pad; - - } - private double PadZ(int cellID) - { - - double RTPC_L=400.0; // in mm - double PAD_L = 4.0; // in mm - double Num_of_Cols = RTPC_L/PAD_L; - double z0 = -(RTPC_L/2.0); // front of RTPC in mm at the center of the pad - double chan = (double)cellID; - double col = chan%Num_of_Cols; - double row=(chan-col)/Num_of_Cols; - double z_shift = row%4; - double z_pad = 0; - double testnum = (row-z_shift)/4; - - z_pad=z0+(col*PAD_L)+(PAD_L/2.0)+z_shift; - //if(z_shift == 0 && row > 0) {return col-1;} - //else{return col;} - return z_pad;//-testnum; - }*/ - -} diff --git a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TrackHitReco.java b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TrackHitReco.java deleted file mode 100644 index 0a3774d91b..0000000000 --- a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TrackHitReco.java +++ /dev/null @@ -1,528 +0,0 @@ -package org.jlab.rec.rtpc.hit; - -import java.util.concurrent.ConcurrentHashMap; -import java.util.HashMap; -import java.util.List; -import java.util.Vector; - -import javax.swing.JFrame; - -import org.jlab.groot.data.GraphErrors; -import org.jlab.groot.graphics.EmbeddedCanvas; - -public class TrackHitReco { - - public void Reco(List rawHits, HitParameters params) { - HashMap>> TIDMap = params.get_TIDMap(); - HashMap ADCMap = params.get_R_adc(); - HashMap graphmap = new HashMap(); - HashMap graphmap2 = new HashMap(); - Vector TimeVec = new Vector(); - Vector XVec = new Vector(); - Vector YVec = new Vector(); - Vector ZVec = new Vector(); - Vector Pads = new Vector(); - int p = 0; - EmbeddedCanvas c = new EmbeddedCanvas(); - EmbeddedCanvas c2 = new EmbeddedCanvas(); - EmbeddedCanvas c3 = new EmbeddedCanvas(); - JFrame j = new JFrame(); - j.setSize(800,600); - JFrame j2 = new JFrame(); - j2.setSize(800,600); - JFrame j3 = new JFrame(); - j3.setSize(800,600); - Vector PadList = new Vector(); - double maxvalue = 0; - double thresh = 0; - int TrigWindSize = params.get_TrigWindSize(); - double sumnumer = 0; - double sumdenom = 0; - HashMap weightave = new HashMap(); - //System.out.println(TIDMap.size()); - //for(Hit hit : rawHits) { - for(int TID : TIDMap.keySet()){ - PadList.clear(); - - for(int time : TIDMap.get(TID).keySet()) - { - for(int pad = 0; pad < TIDMap.get(TID).get(time).size(); pad++) - { - if(!PadList.contains(TIDMap.get(TID).get(time).get(pad))) - { - PadList.add(TIDMap.get(TID).get(time).get(pad)); - } - } - } - - for(int pad = 0; pad < PadList.size(); pad++) - { - for(int time : TIDMap.get(TID).keySet()) - { - if(TIDMap.get(TID).get(time).contains(PadList.get(pad))) - { - if(ADCMap.get(PadList.get(pad))[time]>maxvalue) - { - maxvalue = ADCMap.get(PadList.get(pad))[time]; - } - } - } - thresh = maxvalue/2; - for(int time = 0; time < TrigWindSize; time++) - { - if(ADCMap.get(PadList.get(pad))[time] > thresh) - { - sumnumer += ADCMap.get(PadList.get(pad))[time]*time; - sumdenom += ADCMap.get(PadList.get(pad))[time]; - //System.out.println(PadList.get(pad) + " " + time); - } - } - - //System.out.println("weightave " + PadList.get(pad) + " " + sumnumer/sumdenom); - weightave.put(PadList.get(pad), sumnumer/sumdenom); - sumnumer = 0; - sumdenom = 0; - maxvalue = 0; - //padvec = PadCoords(PadList.get(pad)); - //gZvsT.addPoint(weightave.get(PadList.get(pad)), padvec.z(), 0, 0); - //gPhivsT.addPoint(weightave.get(PadList.get(pad)), Math.atan2(padvec.y(),padvec.x()),0,0); - } - - graphmap.put(TID, new GraphErrors()); - graphmap2.put(TID, new GraphErrors()); - //System.out.println("hqwd" + TID); - for(int t : TIDMap.get(TID).keySet()){ - for(int padindex = 0; padindex < TIDMap.get(TID).get(t).size(); padindex++){ - - - int cellID = TIDMap.get(TID).get(t).get(padindex); - Pads.add(cellID); - double Time = (double)t; - //System.out.println(Time + " " + cellID); - - - //int NEve = 10; - - double PAD_W = 2.79; // in mm - double PAD_S = 80.0; //in mm - double PAD_L = 4.0; // in mm - double RTPC_L = 384.0; // in mm - - //double Num_of_Rows = (2.0*(Math.PI)*PAD_S)/PAD_W; - double Num_of_Cols = RTPC_L/PAD_L; - //double TotChan = Num_of_Rows*Num_of_Cols; - - double PI=Math.PI; - - double z0 = -(RTPC_L/2.0); // front of RTPC in mm at the center of the pad - - double phi_per_pad = PAD_W/PAD_S; // in rad - - - - // MagBoltz parameters - double a_t=1741.179712, b_t=-1.25E+02; // for f(x)=time(radius) - double a_phi=0.161689123, b_phi=0.023505021; // for f(x)=dphi(radius) - - double t_2GEM2 = 296.082; - double t_2GEM3 = 296.131; - double t_2PAD = 399.09; - double t_gap = t_2GEM2 + t_2GEM3 + t_2PAD; - - double phi_2GEM2 = 0.0492538; - double phi_2GEM3 = 0.0470817; - double phi_2PAD = 0.0612122; - double phi_gap = phi_2GEM2 + phi_2GEM3 + phi_2PAD; - - // find postition from Cell ID - //for (double s = 0.0; s < cellID.size(); s++) { - - double chan=0; - double t_s2pad = 0; - double dphi=0; - double dz=0; - double x_rec = 0; - double y_rec = 0; - - - double z_pad=0; - double z_rec=0; - double z_hit=0; // position of the hit on a single pad in z - double delta_z=0; - - double r_pos=0; - double r_rec=0; - double r_temp=0; - double delta_r=0; - - double phi_pad=0; - double phi_rec=0; - - - - // generated position of ionization in phi - - //phi_pos = Math.atan2(Y, X); - - // generated position of ionization in s - //r_pos=Math.sqrt(((X)*(X))+((Y)*(Y))); - - - // ------------------ find z and phi of pad from CellID ------------------ - chan = (double)cellID; - - double col = chan%Num_of_Cols; - double row=(chan-col)/Num_of_Cols; - double z_shift = row%4; - //double z_shift = 0.; - - phi_pad=(row*phi_per_pad)+(phi_per_pad/2.0); - if(phi_pad>= 2.0*PI) { - phi_pad -= 2.0*PI; - } - if(phi_pad<0) - { - phi_pad += 2.0*PI; - } - - z_pad=z0+(col*PAD_L)+(PAD_L/2.0)+z_shift; - // ----------------------------------------------------------------------- - - - // find reconstructed position of ionization from Time info - - t_s2pad = Time-t_gap; - - r_rec=((-(Math.sqrt(a_t*a_t+(4.*b_t*t_s2pad)))+a_t+(14.*b_t))/(2.*b_t))*10.0; //in mm - - - dphi=a_phi*(7.-r_rec/10.)+b_phi*(7.-r_rec/10.)*(7.-r_rec/10.); // in rad - - - dz=0; - - phi_rec=phi_pad-dphi-phi_gap; - if( phi_rec<0.0 ) - { - phi_rec+=2.0*PI; - } - if( phi_rec>2.0*PI ) - { - phi_rec-=2.0*PI; - } - - // x,y,z pos of reconstructed track - x_rec=r_rec*(Math.cos(phi_rec)); - y_rec=r_rec*(Math.sin(phi_rec)); - z_rec=z_pad-dz; - //if(r_rec > 30 && r_rec < 70) - //{ - graphmap.get(TID).addPoint(r_rec, z_rec, 0, 0); - graphmap2.get(TID).addPoint(x_rec, y_rec, 0, 0); - - //} - // x,y,z pos of pad hit - //x_pad=(PAD_S)*(Math.cos(phi_pad)); - //y_pad=(PAD_S)*(Math.sin(phi_pad)); - - // actual position on pad of hits - //phi_hit=phi_rad-(row*phi_per_pad); - //z_hit=Z-z0-(col*PAD_L)-z_shift; - - // find differences (delta = generated-reconstructed) - //delta_x=X-x_rec; - //delta_y=Y-y_rec; - //delta_z=Z-z_rec; - //delta_r=r_pos-r_rec; - //delta_phi = phi_pos-phi_rec; - - - - - /*hit.set_cellID(cellID); - hit.set_Time(t_s2pad); - hit.set_Edep(Edep); - hit.set_PosX(x_rec); - hit.set_PosY(y_rec); - hit.set_PosZ(z_rec); - TimeVec.add(t_s2pad); - XVec.add(x_rec); - YVec.add(y_rec); - ZVec.add(z_rec);*/ - - - } - } - } - GraphErrors grz = new GraphErrors(); - GraphErrors g1rz = new GraphErrors(); - GraphErrors gxy = new GraphErrors(); - GraphErrors g1xy = new GraphErrors(); - GraphErrors gerrorxvsphi = new GraphErrors(); - GraphErrors gerroryvsphi = new GraphErrors(); - int counter = 1; - for(Hit hit : rawHits) - { - if(true) { - int cellID = hit.get_cellID(); - double Time = hit.get_Time(); - double X = hit.get_PosXTrue(); - double Y = hit.get_PosYTrue(); - double Z = hit.get_PosZTrue(); - - //if(Pads.contains(cellID)) - //{ - //ystem.out.println(Time + " " + cellID); - - - //int NEve = 10; - - double PAD_W = 2.79; // in mm - double PAD_S = 80.0; //in mm - double PAD_L = 4.0; // in mm - double RTPC_L = 384.0; // in mm - - //double Num_of_Rows = (2.0*(Math.PI)*PAD_S)/PAD_W; - double Num_of_Cols = RTPC_L/PAD_L; - //double TotChan = Num_of_Rows*Num_of_Cols; - - double PI=Math.PI; - - double z0 = -(RTPC_L/2.0); // front of RTPC in mm at the center of the pad - - double phi_per_pad = PAD_W/PAD_S; // in rad - - - - // MagBoltz parameters - double a_t=1741.179712, b_t=-125; // for f(x)=time(radius) - double a_phi=0.161689123, b_phi=0.023505021; // for f(x)=dphi(radius) - - double t_2GEM2 = 296.082; - double t_2GEM3 = 296.131; - double t_2PAD = 399.09; - double t_gap = t_2GEM2 + t_2GEM3 + t_2PAD; - - double phi_2GEM2 = 0.0492538; - double phi_2GEM3 = 0.0470817; - double phi_2PAD = 0.0612122; - double phi_gap = phi_2GEM2 + phi_2GEM3 + phi_2PAD; - - // find position from Cell ID - //for (double s = 0.0; s < cellID.size(); s++) { - - double chan=0; - double t_s2pad = 0; - double dphi=0; - double dz=0; - double x_rec = 0; - double y_rec = 0; - - - double z_pad=0; - double z_rec=0; - double z_hit=0; // position of the hit on a single pad in z - double delta_z=0; - - double r_pos=0; - double r_rec=0; - double r_temp=0; - double delta_r=0; - - double phi_pad=0; - double phi_rec=0; - double phi_pos = 0; - - - // generated position of ionization in phi - - phi_pos = Math.atan2(Y, X); - - // generated position of ionization in s - r_pos=Math.sqrt(((X)*(X))+((Y)*(Y))); - - - // ------------------ find z and phi of pad from CellID ------------------ - chan = (double)cellID; - - double col = chan%Num_of_Cols; - double row=(chan-col)/Num_of_Cols; - double z_shift = row%4; - //double z_shift = 0.; - //System.out.println(row + " " + chan + " " + col + " " + phi_per_pad); - phi_pad=(row*phi_per_pad)+(phi_per_pad/2.0); - while(phi_pad >= 2*PI || phi_pad < 0) - { - if(phi_pad>= 2.0*PI) { - phi_pad -= 2.0*PI; - } - if(phi_pad<0) - { - phi_pad += 2.0*PI; - } - } - z_pad=z0+(col*PAD_L)+(PAD_L/2.0)+z_shift; - // ----------------------------------------------------------------------- - - - // find reconstructed position of ionization from Time info - - t_s2pad = Time-t_gap; - - r_rec=((-(Math.sqrt(a_t*a_t+(4*b_t*t_s2pad)))+a_t+(14*b_t))/(2*b_t))*10.0; //in mm - - - dphi=a_phi*(7-r_rec/10)+b_phi*(7-r_rec/10)*(7.-r_rec/10); // in rad - - - dz=0; - - phi_rec=phi_pad-dphi-phi_gap; - while(phi_rec < 0 || phi_rec >= 2*PI) - { - if( phi_rec<0.0 ) - { - phi_rec+=2.0*PI; - } - if( phi_rec>2.0*PI ) - { - phi_rec-=2.0*PI; - } - } - //System.out.println("reconstructed phi " + phi_rec + " actual phi " + Math.atan(Y/X)); - - // x,y,z pos of reconstructed track - x_rec=r_rec*(Math.cos(phi_rec)); - y_rec=r_rec*(Math.sin(phi_rec)); - z_rec=z_pad-dz; - //if(true) - //if(counter > 2500) - //if(z_rec > 160 && r_rec > 30 && r_rec < 55 && z_rec < 195) - if(true)//if(Math.abs(x_rec-X) < 3 && Math.abs(y_rec-Y) < 3 && Math.abs(z_rec-Z) < 3) - { - grz.addPoint(r_rec, z_rec, 0, 0); - gxy.addPoint(x_rec, y_rec, 0, 0); - //if(counter <= 53) - //{ - g1rz.addPoint(Math.sqrt(X*X+Y*Y), Z, 0, 0); - g1xy.addPoint(X, Y, 0, 0); - gerrorxvsphi.addPoint(Math.atan2(Y,X),Math.pow(Math.abs(x_rec-X),2)/X,0,0); - gerroryvsphi.addPoint(Math.atan2(Y,X),Math.pow(Math.abs(y_rec-Y),2)/Y,0,0); - //} - //System.out.println(counter); - } - else - { - grz.addPoint(0, 0, 0, 0); - g1rz.addPoint(0, 0, 0, 0); - gxy.addPoint(0, 0, 0, 0); - g1xy.addPoint(0, 0, 0, 0); - } - //} - // x,y,z pos of pad hit - //x_pad=(PAD_S)*(Math.cos(phi_pad)); - //y_pad=(PAD_S)*(Math.sin(phi_pad)); - - // actual position on pad of hits - //phi_hit=phi_rad-(row*phi_per_pad); - //z_hit=Z-z0-(col*PAD_L)-z_shift; - - // find differences (delta = generated-reconstructed) - //delta_x=X-x_rec; - //delta_y=Y-y_rec; - //delta_z=Z-z_rec; - //delta_r=r_pos-r_rec; - //delta_phi = phi_pos-phi_rec; - //System.out.println(X + " " + x_rec); - //System.out.println(r_pos + " " + r_rec); - - - - /*hit.set_cellID(cellID); - hit.set_Time(t_s2pad); - hit.set_Edep(Edep); - hit.set_PosX(x_rec); - hit.set_PosY(y_rec); - hit.set_PosZ(z_rec); - TimeVec.add(t_s2pad); - XVec.add(x_rec); - YVec.add(y_rec); - ZVec.add(z_rec);*/ - //} - counter++; - } - } - //System.out.println(counter); - GraphErrors g2 = new GraphErrors(); - double theta = 0; - double test_x = 0; - double test_y = 0; - double test_x2 = 0; - double test_y2 = 0; - while(theta <= 2*Math.PI) - { - test_x = 30 * Math.cos(theta); - test_y = 30 * Math.sin(theta); - test_x2 = 70 * Math.cos(theta); - test_y2 = 70 * Math.sin(theta); - g2.addPoint(test_x, test_y, 0, 0); - g2.addPoint(test_x2, test_y2, 0, 0); - theta+=0.01; - } - - for(int key : TIDMap.keySet()) - { - if(false) - //if(key == 1) - { - graphmap.get(key).setMarkerSize(6); - graphmap2.get(key).setMarkerSize(6); - } - else { - graphmap.get(key).setMarkerSize(2); - graphmap.get(key).setMarkerColor(4); - graphmap.get(key).setMarkerStyle(2); - - - graphmap2.get(key).setMarkerSize(2); - graphmap2.get(key).setMarkerColor(4); - graphmap2.get(key).setMarkerStyle(2); - } - c.draw(graphmap.get(key),"same"); - c2.draw(graphmap2.get(key),"same"); - - } - grz.setMarkerSize(3); - grz.setMarkerColor(1); - g1rz.setMarkerSize(1); - g1rz.setMarkerColor(5); - //grz.addPoint(30, -200, 0, 0); - //grz.addPoint(70, 200, 0, 0); - gxy.setMarkerSize(4); - gxy.setMarkerColor(2); - g1xy.setMarkerSize(0); - g1xy.setMarkerColor(5); - g2.setMarkerSize(0); - g2.setMarkerColor(3); - gerrorxvsphi.setMarkerSize(2); - gerroryvsphi.setMarkerSize(2); - c.draw(grz,"same"); - c.draw(g1rz,"same"); - c2.draw(gxy,"same"); - c2.draw(g1xy,"same"); - c2.draw(g2,"same"); - c3.divide(1, 2); - c3.cd(0); - c3.draw(gerrorxvsphi); - c3.cd(1); - c3.draw(gerroryvsphi); - j.setTitle("RZ"); - j2.setTitle("XY"); - j.add(c); - j.setVisible(true); - j2.add(c2); - j2.setVisible(true); - //j3.add(c3); - //j3.setVisible(true); - } -} diff --git a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TrackHitReco2.java b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TrackHitReco2.java deleted file mode 100644 index e65fa78d93..0000000000 --- a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TrackHitReco2.java +++ /dev/null @@ -1,714 +0,0 @@ -package org.jlab.rec.rtpc.hit; - -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.util.ArrayList; -import java.util.concurrent.ConcurrentHashMap; -import java.util.HashMap; -import java.util.List; -import java.util.Vector; - -import javax.swing.JFrame; - -import org.jlab.clas.physics.Vector3; -import org.jlab.groot.data.GraphErrors; -import org.jlab.groot.data.H1F; -import org.jlab.groot.graphics.EmbeddedCanvas; -import org.jlab.rec.rtpc.hit.RecoHitVector; - -public class TrackHitReco2 { - - public void Reco(List rawHits, HitParameters params, boolean draw) { - HashMap>> TIDMap = params.get_strkTIDMap(); - HashMap ADCMap = params.get_R_adc(); - HashMap graphmap = new HashMap(); - HashMap graphmap2 = new HashMap(); - HashMap> alltracks = params.get_alltracks(); - HashMap largetmap = params.get_largetmap(); - HashMap tdiffmap = new HashMap(); - HashMap> recohitvector = new HashMap>(); - Vector TimeVec = new Vector(); - Vector XVec = new Vector(); - Vector YVec = new Vector(); - Vector ZVec = new Vector(); - Vector Pads = new Vector(); - int p = 0; - EmbeddedCanvas c = new EmbeddedCanvas(); - EmbeddedCanvas c2 = new EmbeddedCanvas(); - EmbeddedCanvas c3 = new EmbeddedCanvas(); - EmbeddedCanvas c4 = new EmbeddedCanvas(); - JFrame j = new JFrame(); - j.setSize(800,600); - JFrame j2 = new JFrame(); - j2.setSize(800,600); - JFrame j3 = new JFrame(); - j3.setSize(800,600); - JFrame j4 = new JFrame(); - j4.setSize(800,600); - - double a_t1 = -2.48491E-4; - double a_t2 = 2.21413E-4; - double a_t3 = -3.11195E-3; - double a_t4 = -2.75206E-1; - double a_t5 = 1.74281E3; - - double b_t1 = 2.48873E-5; - double b_t2 = -1.19976E-4; - double b_t3 = -3.75962E-3; - double b_t4 = 5.33100E-2; - double b_t5 = -1.25647E2; - - double a_phi1 = -3.32718E-8; - double a_phi2 = 1.92110E-7; - double a_phi3 = 2.16919E-6; - double a_phi4 = -8.10207E-5; - double a_phi5 = 1.68481E-1; - - double b_phi1 = -3.23019E-9; - double b_phi2 = -6.92075E-8; - double b_phi3 = 1.24731E-5; - double b_phi4 = 2.57684E-5; - double b_phi5 = 2.10680E-2; - - H1F largetdist = new H1F("largetdist",100,0,10000); - - double timewindow = 2000; - double smalltcut = 300; - double largetcut = 8000; - int tracksizecut = 4; - double larget = 0; - double tdiff = 0; - double Time = 0; - int cellID = 0; - int outsidedriftcounter = 0; - int allhitscounter = 0; - /*Vector PadList = new Vector(); - double maxvalue = 0; - double thresh = 0; - int TrigWindSize = params.get_TrigWindSize(); - double sumnumer = 0; - double sumdenom = 0; - int count = 0;*/ - - //HashMap weightave = new HashMap(); - //System.out.println(TIDMap.size()); - //for(Hit hit : rawHits) { - //for(int TID : TIDMap.keySet()){ - //System.out.println(alltracks.size() + " " + alltracks.get(1).size()); - for(int TID : alltracks.keySet()) { - Pads.clear(); - /*PadList.clear(); - - double larget = 0; - for(int time : TIDMap.get(TID).keySet()) - { - for(int pad = 0; pad < TIDMap.get(TID).get(time).size(); pad++) - { - if(!PadList.contains(TIDMap.get(TID).get(time).get(pad))) - { - PadList.add(TIDMap.get(TID).get(time).get(pad)); - } - } - } - - for(int pad = 0; pad < PadList.size(); pad++) - { - for(int time : TIDMap.get(TID).keySet()) - { - if(TIDMap.get(TID).get(time).contains(PadList.get(pad))) - { - if(ADCMap.get(PadList.get(pad))[time]>maxvalue) - { - maxvalue = ADCMap.get(PadList.get(pad))[time]; - } - } - } - thresh = maxvalue/2; - for(int time = 0; time < TrigWindSize; time++) - { - if(ADCMap.get(PadList.get(pad))[time] > thresh) - { - sumnumer += ADCMap.get(PadList.get(pad))[time]*time; - sumdenom += ADCMap.get(PadList.get(pad))[time]; - //System.out.println(PadList.get(pad) + " " + time); - } - } - if(sumnumer/sumdenom >= larget) - { - larget = sumnumer/sumdenom; - } - //System.out.println("weightave " + PadList.get(pad) + " " + sumnumer/sumdenom); - weightave.put(PadList.get(pad), sumnumer/sumdenom); - sumnumer = 0; - sumdenom = 0; - maxvalue = 0; - //padvec = PadCoords(PadList.get(pad)); - //gZvsT.addPoint(weightave.get(PadList.get(pad)), padvec.z(), 0, 0); - //gPhivsT.addPoint(weightave.get(PadList.get(pad)), Math.atan2(padvec.y(),padvec.x()),0,0); - }*/ - //System.out.println("large t " + larget); - larget = largetmap.get(TID); - double smallt = 1000000; - for(int i = 0; i < alltracks.get(TID).size(); i ++) - { - if(alltracks.get(TID).get(i).time() < smallt) {smallt = alltracks.get(TID).get(i).time();} - } - //double smallt = alltracks.get(TID).get(alltracks.get(TID).size()-1).time(); - - - /*try { - File f = new File("/Users/davidpayette/Documents/FileOutput/smallt.txt"); - //f.delete(); - FileWriter out = new FileWriter("/Users/davidpayette/Documents/FileOutput/smallt.txt",true); - out.write(smallt + "\n"); - out.close(); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - }*/ - largetdist.fill(larget); - //System.out.println("large t is " + larget); - //if(TID != 2) {continue;} - //System.out.println(smallt + " small t"); - if(smallt < smalltcut || larget > largetcut || alltracks.get(TID).size() <= tracksizecut) {continue;} - //add smallt check as well for smallt too small - - graphmap.put(TID, new GraphErrors()); - graphmap2.put(TID, new GraphErrors()); - - tdiff = 6000 - larget; - //if(larget + tdiff > 7500) {continue;} - tdiffmap.put(TID, tdiff); - recohitvector.put(TID, new Vector()); - - //tdiff = 0; - //System.out.println("hqwd" + TID); - //for(int cellID : weightave.keySet()){ - //System.out.println("large t " + larget); - for(int k = 0; k < alltracks.get(TID).size(); k++) { - //for(int padindex = 0; padindex < TIDMap.get(TID).get(t).size(); padindex++){ - - allhitscounter++; - //int cellID = TIDMap.get(TID).get(t).get(padindex); - cellID = (int)alltracks.get(TID).get(k).pad(); - if(!Pads.contains(cellID)) { - Pads.add(cellID); - } - //double Time = weightave.get(cellID); - Time = alltracks.get(TID).get(k).time(); - //System.out.println("reco " + Time); - //System.out.println("tdiff " + tdiff); - Time+=tdiff; - - //System.out.println(Time + " " + cellID); - - - //int NEve = 10; - - double PAD_W = 2.79; // in mm - double PAD_S = 80.0; //in mm - double PAD_L = 4.0; // in mm - double RTPC_L = 384.0; // in mm - - //double Num_of_Rows = (2.0*(Math.PI)*PAD_S)/PAD_W; - double Num_of_Cols = RTPC_L/PAD_L; - //double TotChan = Num_of_Rows*Num_of_Cols; - - double PI=Math.PI; - - double z0 = -(RTPC_L/2.0); // front of RTPC in mm at the center of the pad - - double phi_per_pad = PAD_W/PAD_S; // in rad - - - - // MagBoltz parameters - //double a_t=1741.179712, b_t=-1.25E+02; // for f(x)=time(radius) - //double a_phi=0.161689123, b_phi=0.023505021; // for f(x)=dphi(radius) - - double t_2GEM2 = 296.082; - double t_2GEM3 = 296.131; - double t_2PAD = 399.09; - double t_gap = t_2GEM2 + t_2GEM3 + t_2PAD; - - double phi_2GEM2 = 0.0492538; - double phi_2GEM3 = 0.0470817; - double phi_2PAD = 0.0612122; - double phi_gap = phi_2GEM2 + phi_2GEM3 + phi_2PAD; - - // find postition from Cell ID - //for (double s = 0.0; s < cellID.size(); s++) { - - double chan=0; - double t_s2pad = 0; - double dphi=0; - double dz=0; - double x_rec = 0; - double y_rec = 0; - - - double z_pad=0; - double z_rec=0; - double z_hit=0; // position of the hit on a single pad in z - double delta_z=0; - - double r_pos=0; - double r_rec=0; - double r_temp=0; - double delta_r=0; - - double phi_pad=0; - double phi_rec=0; - - - - // generated position of ionization in phi - - //phi_pos = Math.atan2(Y, X); - - // generated position of ionization in s - //r_pos=Math.sqrt(((X)*(X))+((Y)*(Y))); - - - // ------------------ find z and phi of pad from CellID ------------------ - chan = (double)cellID; - - double col = chan%Num_of_Cols; - double row=(chan-col)/Num_of_Cols; - double z_shift = row%4; - //double z_shift = 0.; - - phi_pad=(row*phi_per_pad)+(phi_per_pad/2.0); - if(phi_pad>= 2.0*PI) { - phi_pad -= 2.0*PI; - } - if(phi_pad<0) - { - phi_pad += 2.0*PI; - } - - z_pad=z0+(col*PAD_L)+(PAD_L/2.0)+z_shift; - // ----------------------------------------------------------------------- - dz=0; - z_rec=z_pad-dz; - - // find reconstructed position of ionization from Time info - - t_s2pad = Time-t_gap; - //if(t_s2pad > 6000) {System.out.println("oooops");} - //System.out.println("time stuff " + t_s2pad + " " + Time); - - double a_t = get_rec_coef(a_t1,a_t2,a_t3,a_t4,a_t5,z_rec); - double b_t = get_rec_coef(b_t1,b_t2,b_t3,b_t4,b_t5,z_rec); - - r_rec=((-(Math.sqrt(a_t*a_t+(4.*b_t*t_s2pad)))+a_t+(14.*b_t))/(2.*b_t))*10.0; //in mm - - double a_phi = get_rec_coef(a_phi1,a_phi2,a_phi3,a_phi4,a_phi5,z_rec); - double b_phi = get_rec_coef(b_phi1,b_phi2,b_phi3,b_phi4,b_phi5,z_rec); - - dphi=a_phi*(7.-r_rec/10.)+b_phi*(7.-r_rec/10.)*(7.-r_rec/10.); // in rad - //System.out.println("r and phi " + r_rec + " " + dphi); - - - //System.out.println("phi stuff " + phi_pad + " " + dphi + " " + phi_gap); - phi_rec=phi_pad-dphi-phi_gap; - if( phi_rec<0.0 ) - { - phi_rec+=2.0*PI; - } - if( phi_rec>2.0*PI ) - { - phi_rec-=2.0*PI; - } - if(r_rec > 70 || r_rec < 30) - { - outsidedriftcounter++; - } - // x,y,z pos of reconstructed track - x_rec=r_rec*(Math.cos(phi_rec)); - y_rec=r_rec*(Math.sin(phi_rec)); - - - recohitvector.get(TID).add(new RecoHitVector(cellID,x_rec,y_rec,z_rec,tdiff,Time)); - //if(r_rec > 30 && r_rec < 70) - //{ - graphmap.get(TID).addPoint(r_rec, z_rec, 0, 0); - graphmap2.get(TID).addPoint(x_rec, y_rec, 0, 0); - - - - //System.out.println("TID time phi x y " + TID + " " + Time + " " + phi_rec + " " + x_rec + " " + y_rec); - //} - // x,y,z pos of pad hit - //x_pad=(PAD_S)*(Math.cos(phi_pad)); - //y_pad=(PAD_S)*(Math.sin(phi_pad)); - - // actual position on pad of hits - //phi_hit=phi_rad-(row*phi_per_pad); - //z_hit=Z-z0-(col*PAD_L)-z_shift; - - // find differences (delta = generated-reconstructed) - //delta_x=X-x_rec; - //delta_y=Y-y_rec; - //delta_z=Z-z_rec; - //delta_r=r_pos-r_rec; - //delta_phi = phi_pos-phi_rec; - - - - - /*hit.set_cellID(cellID); - hit.set_Time(t_s2pad); - hit.set_Edep(Edep); - hit.set_PosX(x_rec); - hit.set_PosY(y_rec); - hit.set_PosZ(z_rec); - TimeVec.add(t_s2pad); - XVec.add(x_rec); - YVec.add(y_rec); - ZVec.add(z_rec);*/ - - - - } - //System.out.println("num of pads " + Pads.size()); - } - GraphErrors grz = new GraphErrors(); - GraphErrors g1rz = new GraphErrors(); - GraphErrors gxy = new GraphErrors(); - GraphErrors g1xy = new GraphErrors(); - GraphErrors g2xy = new GraphErrors(); - GraphErrors gerrorxvsphi = new GraphErrors(); - GraphErrors gerroryvsphi = new GraphErrors(); - int counter = 1; - - for(Hit hit : rawHits) - { - if(true) { - cellID = hit.get_cellID(); - - Time = hit.get_Time(); - //double T_noshift = Time; - if(Time <= 0) {continue;} - Time -= hit.get_TShift(); - //System.out.println("Time " + hit.get_Time() + " " + hit.get_TShift()); - - double X = hit.get_PosXTrue(); - double Y = hit.get_PosYTrue(); - double Z = hit.get_PosZTrue(); - //double TimeNoShift = Time - hit.get_TShift(); - //if(Pads.contains(cellID)) - //{ - //ystem.out.println(Time + " " + cellID); - - - //int NEve = 10; - - double PAD_W = 2.79; // in mm - double PAD_S = 80.0; //in mm - double PAD_L = 4.0; // in mm - double RTPC_L = 384.0; // in mm - - //double Num_of_Rows = (2.0*(Math.PI)*PAD_S)/PAD_W; - double Num_of_Cols = RTPC_L/PAD_L; - //double TotChan = Num_of_Rows*Num_of_Cols; - - double PI=Math.PI; - - double z0 = -(RTPC_L/2.0); // front of RTPC in mm at the center of the pad - - double phi_per_pad = PAD_W/PAD_S; // in rad - - - - // MagBoltz parameters - //double a_t=1741.179712, b_t=-125; // for f(x)=time(radius) - //double a_phi=0.161689123, b_phi=0.023505021; // for f(x)=dphi(radius) - - double t_2GEM2 = 296.082; - double t_2GEM3 = 296.131; - double t_2PAD = 399.09; - double t_gap = t_2GEM2 + t_2GEM3 + t_2PAD; - - double phi_2GEM2 = 0.0492538; - double phi_2GEM3 = 0.0470817; - double phi_2PAD = 0.0612122; - double phi_gap = phi_2GEM2 + phi_2GEM3 + phi_2PAD; - - // find position from Cell ID - //for (double s = 0.0; s < cellID.size(); s++) { - - double chan=0; - double t_s2pad = 0; - double dphi=0; - double dz=0; - double x_rec = 0; - double y_rec = 0; - - - double z_pad=0; - double z_rec=0; - double z_hit=0; // position of the hit on a single pad in z - double delta_z=0; - - double r_pos=0; - double r_rec=0; - double r_temp=0; - double delta_r=0; - - double phi_pad=0; - double phi_rec=0; - double phi_pos = 0; - - double t_calc = 0; - - - - // generated position of ionization in phi - - phi_pos = Math.atan2(Y, X); - - // generated position of ionization in s - r_pos=Math.sqrt(((X)*(X))+((Y)*(Y))); - //System.out.println(r_pos + " " + X + " " + Y); - - - // ------------------ find z and phi of pad from CellID ------------------ - chan = (double)cellID; - - double col = chan%Num_of_Cols; - double row=(chan-col)/Num_of_Cols; - double z_shift = row%4; - //double z_shift = 0.; - //System.out.println(row + " " + chan + " " + col + " " + phi_per_pad); - phi_pad=(row*phi_per_pad)+(phi_per_pad/2.0); - while(phi_pad >= 2*PI || phi_pad < 0) - { - if(phi_pad>= 2.0*PI) { - phi_pad -= 2.0*PI; - } - if(phi_pad<0) - { - phi_pad += 2.0*PI; - } - } - z_pad=z0+(col*PAD_L)+(PAD_L/2.0)+z_shift; - // ----------------------------------------------------------------------- - dz=0; - z_rec=z_pad-dz; - - // find reconstructed position of ionization from Time info - - double a_t = get_rec_coef(a_t1,a_t2,a_t3,a_t4,a_t5,z_rec); - double b_t = get_rec_coef(b_t1,b_t2,b_t3,b_t4,b_t5,z_rec); - - - - double a_phi = get_rec_coef(a_phi1,a_phi2,a_phi3,a_phi4,a_phi5,z_rec); - double b_phi = get_rec_coef(b_phi1,b_phi2,b_phi3,b_phi4,b_phi5,z_rec); - - //System.out.println(a_t + " " + b_t + " " + a_phi + " " + b_phi + " " + z_rec); - - t_s2pad = Time-t_gap; - - r_rec = ((-(Math.sqrt(a_t*a_t+(4*b_t*t_s2pad)))+a_t+(14*b_t))/(2*b_t))*10.0; //in mm - t_calc = ((((2*b_t*r_pos*0.1)-(14*b_t)-a_t)*((2*b_t*r_pos*0.1)-14*b_t-a_t))-(a_t*a_t))*(1/(4*b_t)) + t_gap; - - - dphi=a_phi*(7-r_rec/10)+b_phi*(7-r_rec/10)*(7.-r_rec/10); // in rad - - - phi_rec=phi_pad-dphi-phi_gap; - while(phi_rec < 0 || phi_rec >= 2*PI) - { - if( phi_rec<0.0 ) - { - phi_rec+=2.0*PI; - } - if( phi_rec>2.0*PI ) - { - phi_rec-=2.0*PI; - } - } - //System.out.println("reconstructed phi " + phi_rec + " actual phi " + Math.atan(Y/X)); - - // x,y,z pos of reconstructed track - x_rec=r_rec*(Math.cos(phi_rec)); - y_rec=r_rec*(Math.sin(phi_rec)); - //System.out.println("rec " + x_rec + " " + y_rec + " " + phi_rec + " " + r_rec + " " + Time); - //if(true) - //if(counter > 2500) - //if(r_rec > 30 && r_rec < 70) - //if(Math.abs(x_rec-X) < 3 && Math.abs(y_rec-Y) < 3 && Math.abs(z_rec-Z) < 3) - //if(true) - //if(Math.abs(t_calc - Time) < timewindow) - if(hit.get_TShift() == 0) - { - //System.out.println(t_calc + " " + Time); - grz.addPoint(r_rec, z_rec, 0, 0); - gxy.addPoint(x_rec, y_rec, 0, 0); - //if(counter <= 53) - //{ - g1rz.addPoint(Math.sqrt(X*X+Y*Y), Z, 0, 0); - g1xy.addPoint(X, Y, 0, 0); - g2xy.addPoint(0, 0, 0, 0); - gerrorxvsphi.addPoint(Math.atan2(Y,X),Math.pow(Math.abs(x_rec-X),2)/X,0,0); - gerroryvsphi.addPoint(Math.atan2(Y,X),Math.pow(Math.abs(y_rec-Y),2)/Y,0,0); - //} - //System.out.println(counter); - } - else - { - //g2xy.addPoint(X, Y, 0, 0); - g2xy.addPoint(0, 0, 0, 0); - grz.addPoint(0, 0, 0, 0); - g1rz.addPoint(0, 0, 0, 0); - gxy.addPoint(0, 0, 0, 0); - g1xy.addPoint(0, 0, 0, 0); - } - //} - // x,y,z pos of pad hit - //x_pad=(PAD_S)*(Math.cos(phi_pad)); - //y_pad=(PAD_S)*(Math.sin(phi_pad)); - - // actual position on pad of hits - //phi_hit=phi_rad-(row*phi_per_pad); - //z_hit=Z-z0-(col*PAD_L)-z_shift; - - // find differences (delta = generated-reconstructed) - //delta_x=X-x_rec; - //delta_y=Y-y_rec; - //delta_z=Z-z_rec; - //delta_r=r_pos-r_rec; - //delta_phi = phi_pos-phi_rec; - //System.out.println(X + " " + x_rec); - //System.out.println(r_pos + " " + r_rec); - - - - /*hit.set_cellID(cellID); - hit.set_Time(t_s2pad); - hit.set_Edep(Edep); - hit.set_PosX(x_rec); - hit.set_PosY(y_rec); - hit.set_PosZ(z_rec); - TimeVec.add(t_s2pad); - XVec.add(x_rec); - YVec.add(y_rec); - ZVec.add(z_rec);*/ - //} - counter++; - } - } - //System.out.println(counter); - GraphErrors g2 = new GraphErrors(); - double theta = 0; - double test_x = 0; - double test_y = 0; - double test_x2 = 0; - double test_y2 = 0; - while(theta <= 2*Math.PI) - { - test_x = 30 * Math.cos(theta); - test_y = 30 * Math.sin(theta); - test_x2 = 70 * Math.cos(theta); - test_y2 = 70 * Math.sin(theta); - g2.addPoint(test_x, test_y, 0, 0); - g2.addPoint(test_x2, test_y2, 0, 0); - theta+=0.01; - } - int color = 2; - int shape = 1; - for(int key : graphmap.keySet()) - { - double szPos[][] = new double[recohitvector.get(key).size()][3]; - for(int i = 0; i < recohitvector.get(key).size(); i++) { - szPos[i][0] = recohitvector.get(key).get(i).x(); - szPos[i][1] = recohitvector.get(key).get(i).y(); - szPos[i][2] = recohitvector.get(key).get(i).z(); - } - //double R = 0; double A = 0; double B = 0; double Phi_deg = 0; double Theta_deg = 0; double Z0 = 0; int fit_track_to_beamline = 1; - //HelixFitJava hf = new HelixFitJava(); - //hf.HelixFit(recohitvector.get(key).size(), szPos, R, A, B, Phi_deg, Theta_deg, Z0, fit_track_to_beamline); - //System.out.println(key + " " + R); - if(false) - //if(key == 3) - { - graphmap.get(key).setMarkerSize(6); - graphmap2.get(key).setMarkerSize(6); - } - else { - graphmap.get(key).setMarkerSize(3); - graphmap.get(key).setMarkerColor(color); - graphmap.get(key).setMarkerStyle(shape); - - - graphmap2.get(key).setMarkerSize(3); - graphmap2.get(key).setMarkerColor(color); - graphmap2.get(key).setMarkerStyle(shape); - - } - //c.draw(graphmap.get(key),"same"); - //c2.draw(graphmap2.get(key),"same"); - color++; - if(color > 7) - { - color -= 6; - shape++; - } - } - grz.setMarkerSize(3); - grz.setMarkerColor(1); - g1rz.setMarkerSize(2); - g1rz.setMarkerColor(2); - //grz.addPoint(30, -200, 0, 0); - //grz.addPoint(70, 200, 0, 0); - gxy.setMarkerSize(2); - gxy.setMarkerColor(2); - g1xy.setMarkerSize(2); - g1xy.setMarkerColor(1); - g2xy.setMarkerSize(2); - g2xy.setMarkerColor(7); - g2.setMarkerSize(0); - g2.setMarkerColor(3); - gerrorxvsphi.setMarkerSize(2); - gerroryvsphi.setMarkerSize(2); - c.draw(grz,"same"); - c.draw(g1rz,"same"); - c2.draw(gxy,"same"); - c2.draw(g1xy,"same"); - c2.draw(g2,"same"); - c2.draw(g2xy,"same"); - c3.divide(1, 2); - c3.cd(0); - c3.draw(gerrorxvsphi); - c3.cd(1); - c3.draw(gerroryvsphi); - c4.draw(largetdist); - j.setTitle("RZ"); - j2.setTitle("XY"); - if(draw == true) { - j.add(c); - j.setVisible(true); - j2.add(c2); - j2.setVisible(true); - //j3.add(c3); - //j3.setVisible(true); - j4.add(c4); - //j4.setVisible(true); - } - - //System.out.println(outsidedriftcounter + "/" + allhitscounter); - params.set_alltracks(alltracks); - params.set_recohitvector(recohitvector); - } - - double get_rec_coef(double t1, double t2, double t3, double t4, double t5, double z2) { - double z = z2/1000; - return t1*z*z*z*z + t2*z*z*z + t3*z*z + t4*z + t5; - - } - - -} diff --git a/reconstruction/rtpc/src/main/java/org/jlab/service/rtpc/RTPCEngine.java b/reconstruction/rtpc/src/main/java/org/jlab/service/rtpc/RTPCEngine.java index f55a3df89e..92bf89fe19 100644 --- a/reconstruction/rtpc/src/main/java/org/jlab/service/rtpc/RTPCEngine.java +++ b/reconstruction/rtpc/src/main/java/org/jlab/service/rtpc/RTPCEngine.java @@ -15,7 +15,6 @@ import org.jlab.io.hipo.HipoDataSource; import org.jlab.io.hipo.HipoDataSync; import org.jlab.rec.rtpc.banks.HitReader; -import org.jlab.rec.rtpc.banks.RecoBankWriter; import org.jlab.rec.rtpc.banks.RecoBankWriter2; import org.jlab.rec.rtpc.hit.Hit; import org.jlab.rec.rtpc.hit.HitDistance; @@ -26,14 +25,10 @@ import org.jlab.rec.rtpc.hit.PadFit; import org.jlab.rec.rtpc.hit.PadHit; //import org.jlab.rec.rtpc.hit.PulseShapeAnalysis; -import org.jlab.rec.rtpc.hit.TimeAverage; import org.jlab.rec.rtpc.hit.TimeAverage2; //import org.jlab.rec.rtpc.hit.TrackDisentangler; //import org.jlab.rec.rtpc.hit.TrackFinder; -import org.jlab.rec.rtpc.hit.TrackFinder2; import org.jlab.rec.rtpc.hit.TrackFinder3; -import org.jlab.rec.rtpc.hit.TrackHitReco; -import org.jlab.rec.rtpc.hit.TrackHitReco2; import org.jlab.rec.rtpc.hit.TrackHitReco3; @@ -77,12 +72,8 @@ public boolean processDataEvent(DataEvent event) { PadFit pfit = new PadFit(); pfit.Fitting(params); -// PulseShapeAnalysis psa = new PulseShapeAnalysis(); -// psa.PSA(params); - - //TrackFinder TF = new TrackFinder(); - //TF.FindTrack(params); - if(swtch == 1) //outdated build + + if(swtch == 1) //not used normally { HitDistance HD = new HitDistance(); HD.FindDistance(params); @@ -96,23 +87,6 @@ else if(swtch == 2) { //current build only use this one DataBank recoBank = writer.fillRTPCHitsBank(event, params); event.appendBanks(recoBank); } - else //outdated build - { - TrackFinder2 TF = new TrackFinder2(); - TF.FindTrack2(params,false); - TimeAverage TA = new TimeAverage(); - TA.TA(params,false); - MapCombine MC = new MapCombine(); - MC.MC(params,false); - /*TrackHitReco TR = new TrackHitReco(); - TR.Reco(hits,params);*/ - TrackHitReco2 TR = new TrackHitReco2(); - TR.Reco(hits,params,false); - RecoBankWriter2 writer = new RecoBankWriter2(); - DataBank recoBank = writer.fillRTPCHitsBank(event, params); - event.appendBanks(recoBank); - //recoBank.show(); - } } else From 1057aef9fba8c7426422db0f2317125ec3732d7c Mon Sep 17 00:00:00 2001 From: dcpayette Date: Tue, 9 Jul 2019 19:02:34 -0400 Subject: [PATCH 008/235] weird directory issue --- reconstruction/README.md | 1 - .../main/java/org/jlab/rec/rtpc/Geometry.java | 20 - .../org/jlab/rec/rtpc/banks/HitReader.java | 104 -- .../jlab/rec/rtpc/banks/RecoBankWriter.java | 45 - .../jlab/rec/rtpc/banks/RecoBankWriter2.java | 91 -- .../java/org/jlab/rec/rtpc/banks/package.html | 14 - .../org/jlab/rec/rtpc/hit/HelixFitJava.java | 824 --------------- .../main/java/org/jlab/rec/rtpc/hit/Hit.java | 201 ---- .../org/jlab/rec/rtpc/hit/HitDistance.java | 128 --- .../org/jlab/rec/rtpc/hit/HitParameters.java | 105 -- .../jlab/rec/rtpc/hit/HitReconstruction.java | 204 ---- .../java/org/jlab/rec/rtpc/hit/HitVector.java | 87 -- .../org/jlab/rec/rtpc/hit/MapCombine.java | 281 ----- .../java/org/jlab/rec/rtpc/hit/PadAve.java | 99 -- .../java/org/jlab/rec/rtpc/hit/PadFit.java | 118 --- .../java/org/jlab/rec/rtpc/hit/PadHit.java | 185 ---- .../java/org/jlab/rec/rtpc/hit/PadVector.java | 80 -- .../org/jlab/rec/rtpc/hit/RecoHitVector.java | 94 -- .../org/jlab/rec/rtpc/hit/ReducedTrack.java | 61 -- .../jlab/rec/rtpc/hit/ReducedTrackMap.java | 59 -- .../org/jlab/rec/rtpc/hit/TimeAverage.java | 389 ------- .../org/jlab/rec/rtpc/hit/TimeAverage2.java | 159 --- .../java/org/jlab/rec/rtpc/hit/Track.java | 117 --- .../org/jlab/rec/rtpc/hit/TrackFinder2.java | 994 ------------------ .../org/jlab/rec/rtpc/hit/TrackFinder3.java | 219 ---- .../org/jlab/rec/rtpc/hit/TrackHitReco.java | 528 ---------- .../org/jlab/rec/rtpc/hit/TrackHitReco2.java | 714 ------------- .../org/jlab/rec/rtpc/hit/TrackHitReco3.java | 649 ------------ .../java/org/jlab/rec/rtpc/hit/TrackMap.java | 60 -- .../org/jlab/rec/rtpc/hit/TrackUtils.java | 44 - .../java/org/jlab/rec/rtpc/hit/package.html | 14 - .../main/java/org/jlab/rec/rtpc/package.html | 14 - .../org/jlab/service/rtpc/RTPCEngine.java | 179 ---- .../org/jlab/service/rtpc/package-info.java | 8 - 34 files changed, 6889 deletions(-) delete mode 100644 reconstruction/README.md delete mode 100644 reconstruction/src/main/java/org/jlab/rec/rtpc/Geometry.java delete mode 100644 reconstruction/src/main/java/org/jlab/rec/rtpc/banks/HitReader.java delete mode 100644 reconstruction/src/main/java/org/jlab/rec/rtpc/banks/RecoBankWriter.java delete mode 100644 reconstruction/src/main/java/org/jlab/rec/rtpc/banks/RecoBankWriter2.java delete mode 100644 reconstruction/src/main/java/org/jlab/rec/rtpc/banks/package.html delete mode 100644 reconstruction/src/main/java/org/jlab/rec/rtpc/hit/HelixFitJava.java delete mode 100644 reconstruction/src/main/java/org/jlab/rec/rtpc/hit/Hit.java delete mode 100644 reconstruction/src/main/java/org/jlab/rec/rtpc/hit/HitDistance.java delete mode 100644 reconstruction/src/main/java/org/jlab/rec/rtpc/hit/HitParameters.java delete mode 100644 reconstruction/src/main/java/org/jlab/rec/rtpc/hit/HitReconstruction.java delete mode 100644 reconstruction/src/main/java/org/jlab/rec/rtpc/hit/HitVector.java delete mode 100644 reconstruction/src/main/java/org/jlab/rec/rtpc/hit/MapCombine.java delete mode 100644 reconstruction/src/main/java/org/jlab/rec/rtpc/hit/PadAve.java delete mode 100644 reconstruction/src/main/java/org/jlab/rec/rtpc/hit/PadFit.java delete mode 100644 reconstruction/src/main/java/org/jlab/rec/rtpc/hit/PadHit.java delete mode 100644 reconstruction/src/main/java/org/jlab/rec/rtpc/hit/PadVector.java delete mode 100644 reconstruction/src/main/java/org/jlab/rec/rtpc/hit/RecoHitVector.java delete mode 100644 reconstruction/src/main/java/org/jlab/rec/rtpc/hit/ReducedTrack.java delete mode 100644 reconstruction/src/main/java/org/jlab/rec/rtpc/hit/ReducedTrackMap.java delete mode 100644 reconstruction/src/main/java/org/jlab/rec/rtpc/hit/TimeAverage.java delete mode 100644 reconstruction/src/main/java/org/jlab/rec/rtpc/hit/TimeAverage2.java delete mode 100644 reconstruction/src/main/java/org/jlab/rec/rtpc/hit/Track.java delete mode 100644 reconstruction/src/main/java/org/jlab/rec/rtpc/hit/TrackFinder2.java delete mode 100644 reconstruction/src/main/java/org/jlab/rec/rtpc/hit/TrackFinder3.java delete mode 100644 reconstruction/src/main/java/org/jlab/rec/rtpc/hit/TrackHitReco.java delete mode 100644 reconstruction/src/main/java/org/jlab/rec/rtpc/hit/TrackHitReco2.java delete mode 100644 reconstruction/src/main/java/org/jlab/rec/rtpc/hit/TrackHitReco3.java delete mode 100644 reconstruction/src/main/java/org/jlab/rec/rtpc/hit/TrackMap.java delete mode 100644 reconstruction/src/main/java/org/jlab/rec/rtpc/hit/TrackUtils.java delete mode 100644 reconstruction/src/main/java/org/jlab/rec/rtpc/hit/package.html delete mode 100644 reconstruction/src/main/java/org/jlab/rec/rtpc/package.html delete mode 100644 reconstruction/src/main/java/org/jlab/service/rtpc/RTPCEngine.java delete mode 100644 reconstruction/src/main/java/org/jlab/service/rtpc/package-info.java diff --git a/reconstruction/README.md b/reconstruction/README.md deleted file mode 100644 index af61df8ec2..0000000000 --- a/reconstruction/README.md +++ /dev/null @@ -1 +0,0 @@ -# RTPC-Tracking-Software diff --git a/reconstruction/src/main/java/org/jlab/rec/rtpc/Geometry.java b/reconstruction/src/main/java/org/jlab/rec/rtpc/Geometry.java deleted file mode 100644 index 9652c3b283..0000000000 --- a/reconstruction/src/main/java/org/jlab/rec/rtpc/Geometry.java +++ /dev/null @@ -1,20 +0,0 @@ -package org.jlab.rec.rtpc; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.PrintWriter; - -/*import org.jMath.Vector.threeVec; - -import trackfitter.surface.Line; -import trackfitter.track.Helix;*/ - -public class Geometry { - - public Geometry() { - - } - - - -} diff --git a/reconstruction/src/main/java/org/jlab/rec/rtpc/banks/HitReader.java b/reconstruction/src/main/java/org/jlab/rec/rtpc/banks/HitReader.java deleted file mode 100644 index 246ae66ed4..0000000000 --- a/reconstruction/src/main/java/org/jlab/rec/rtpc/banks/HitReader.java +++ /dev/null @@ -1,104 +0,0 @@ -package org.jlab.rec.rtpc.banks; - -import java.util.ArrayList; -import java.util.List; - -import org.jlab.io.base.DataBank; -import org.jlab.io.base.DataEvent; -import org.jlab.rec.rtpc.hit.Hit; -/** - * @author payette - * - */ -public class HitReader { - - private List _Hits; - - /** - * - * @return a list of RTPC hits - */ - public List get_RTPCHits() { - return _Hits; - } - - /** - * sets the list of RTPC hits - * @param RTPCHits list of RTPC hits - */ - public void set_RTPCHits(List RTPCHits) { - this._Hits = RTPCHits; - } - - - - - /** - * reads the hits using clas-io methods to get the EvioBank for the RTPC and fill the values to instanciate the RTPChit and MChit classes. - * This methods fills the RTPChit and MChit list of hits. If the data is not MC, the MChit list remains empty - * @param event DataEvent - */ - public void fetch_RTPCHits(DataEvent event) { - - - - List hits = new ArrayList(); - - DataBank bankDGTZ = null; - if(event.hasBank("RTPC::adc")==true) - bankDGTZ=event.getBank("RTPC::adc"); - DataBank bankTrue = null; - if(event.hasBank("RTPC::pos")==true) - bankTrue=event.getBank("RTPC::pos"); - if(bankDGTZ==null || bankTrue==null) - return ; - - int rows = bankDGTZ.rows(); - if(bankTrue.rows()!=rows) - return; - - int[] hitnb = new int[rows]; - int[] cellID = new int[rows]; - //int[] ADC = new int[rows]; - double[] Time = new double[rows]; - int[] step = new int[rows]; - double[] posX = new double[rows]; - double[] posY = new double[rows]; - double[] posZ = new double[rows]; - //double[] phiRad = new double[rows]; - double[] Edep = new double[rows]; - double[] TShift = new double[rows]; - - for(int i = 0; i 10000) - { - Time[i] = 0; - Edep[i] = 0; - posX[i] = 0; - posY[i] = 0; - posZ[i] = 0; - } - Hit hit = new Hit(1, cellID[i], 1, Time[i]); - hit.set_EdepTrue(Edep[i]); - hit.set_PosXTrue(posX[i]); - hit.set_PosYTrue(posY[i]); - hit.set_PosZTrue(posZ[i]); - hit.set_Time(Time[i]); - hit.set_TShift(TShift[i]); - - hits.add(hit); - } - - this.set_RTPCHits(hits); - - } -} diff --git a/reconstruction/src/main/java/org/jlab/rec/rtpc/banks/RecoBankWriter.java b/reconstruction/src/main/java/org/jlab/rec/rtpc/banks/RecoBankWriter.java deleted file mode 100644 index aa0b849626..0000000000 --- a/reconstruction/src/main/java/org/jlab/rec/rtpc/banks/RecoBankWriter.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.jlab.rec.rtpc.banks; - -import java.util.List; - -import org.jlab.io.base.DataBank; -import org.jlab.io.base.DataEvent; -import org.jlab.rec.rtpc.hit.Hit; - -public class RecoBankWriter { - - /** - * - * @param hitlist the list of hits that are of the type Hit. - * @return hits bank - * - */ - public DataBank fillRTPCHitsBank(DataEvent event, List hitlist) { - if(hitlist==null) - return null; - if(hitlist.size()==0) - return null; - - - DataBank bank = event.createBank("RTPC::rec", hitlist.size()); - - for(int i =0; i< hitlist.size(); i++) { - //System.out.println(hitlist.get(i).get_PosX()); - bank.setInt("id", i, hitlist.get(i).get_Id()); - bank.setInt("cellID",i, hitlist.get(i).get_cellID()); - bank.setFloat("posX",i, (float) hitlist.get(i).get_PosX()); - bank.setFloat("posY",i, (float) hitlist.get(i).get_PosY()); - bank.setFloat("posZ",i, (float) hitlist.get(i).get_PosZ()); - //bank.setDouble("Edep",i, hitlist.get(i).get_Edep()); - bank.setFloat("time", i, (float) hitlist.get(i).get_Time()); - - - } - - return bank; - - } - - - -} diff --git a/reconstruction/src/main/java/org/jlab/rec/rtpc/banks/RecoBankWriter2.java b/reconstruction/src/main/java/org/jlab/rec/rtpc/banks/RecoBankWriter2.java deleted file mode 100644 index 924a5e21e8..0000000000 --- a/reconstruction/src/main/java/org/jlab/rec/rtpc/banks/RecoBankWriter2.java +++ /dev/null @@ -1,91 +0,0 @@ -package org.jlab.rec.rtpc.banks; - -import java.util.concurrent.ConcurrentHashMap; -import java.util.Vector; - -import org.jlab.clas.physics.Vector3; - -//import java.util.List; - -import org.jlab.io.base.DataBank; -import org.jlab.io.base.DataEvent; -//import org.jlab.rec.rtpc.hit.Hit; -import org.jlab.rec.rtpc.hit.HitParameters; -import org.jlab.rec.rtpc.hit.HitVector; -import org.jlab.rec.rtpc.hit.RecoHitVector; -import java.util.HashMap; - -public class RecoBankWriter2 { - - /** - * - * @param hitlist the list of hits that are of the type Hit. - * @return hits bank - * - */ - public DataBank fillRTPCHitsBank(DataEvent event, HitParameters params) { - /*if(hitlist==null) - return null; - if(hitlist.size()==0) - return null;*/ - int listsize = 0; - int row = 0; - HashMap> recohitvector = params.get_recohitvector(); - - for(int TID:recohitvector.keySet()) { - for(int i = 0; i < recohitvector.get(TID).size(); i++) { - listsize++; - } - } - - DataBank bank = event.createBank("RTPC::rec", listsize); - - if (bank == null) { - System.err.println("COULD NOT CREATE A BANK!!!!!!"); - return null; - } - - for(int TID : recohitvector.keySet()) { - for(int i = 0; i < recohitvector.get(TID).size(); i++) { - int cellID = recohitvector.get(TID).get(i).pad(); - double x_rec = recohitvector.get(TID).get(i).x(); - double y_rec = recohitvector.get(TID).get(i).y(); - double z_rec = recohitvector.get(TID).get(i).z(); - double time = recohitvector.get(TID).get(i).time(); - double tdiff = recohitvector.get(TID).get(i).dt(); - - bank.setInt("TID", row, TID); - bank.setInt("cellID", row, cellID); - bank.setFloat("time", row, (float) time); - bank.setFloat("posX", row, (float) x_rec); - bank.setFloat("posY", row, (float) y_rec); - bank.setFloat("posZ", row, (float) z_rec); - bank.setFloat("tdiff", row, (float) tdiff); - - row++; - } - } - /*for(int i =0; i< listsize; i++) { - double x_rec = alltracks.get(k - double y_rec = params.get_YVec().get(i); - double z_rec = params.get_ZVec().get(i); - double time = params.get_time().get(i); - //System.out.println(params.get_time().size()); - bank.setInt("id", i, 1); - bank.setInt("cellID",i, params.get_PadNum().get(i)); - bank.setFloat("posX",i, (float) x_rec); - bank.setFloat("posY",i, (float) y_rec); - bank.setFloat("posZ",i, (float) z_rec); - //bank.setDouble("Edep",i, hitlist.get(i).get_Edep()); - bank.setFloat("time", i, (float) time); - - - }*/ - - return bank; - - } - - - -} \ No newline at end of file diff --git a/reconstruction/src/main/java/org/jlab/rec/rtpc/banks/package.html b/reconstruction/src/main/java/org/jlab/rec/rtpc/banks/package.html deleted file mode 100644 index 61a4c9b57d..0000000000 --- a/reconstruction/src/main/java/org/jlab/rec/rtpc/banks/package.html +++ /dev/null @@ -1,14 +0,0 @@ - - - - - -org.jlab.rec.rtpc.banks - - -
Author:
ziegler
- - \ No newline at end of file diff --git a/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/HelixFitJava.java b/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/HelixFitJava.java deleted file mode 100644 index 0590eeb085..0000000000 --- a/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/HelixFitJava.java +++ /dev/null @@ -1,824 +0,0 @@ -package org.jlab.rec.rtpc.hit; - -public class HelixFitJava { - - void rwsmav(double r[], double a[], double v[], int n) - { - // Author: Martin Poppe. r[n] = a[n,n]*v[n] - - int i, k, ind; - // Address in triangular matrix, row ii, column kk - for(i=1; i<=n; i++) - { - r[i-1] = 0; - for(k=1; k<=n; k++) - { - if (i >= k) { ind = (i*i-i)/2 + k; r[i-1] += a[ind-1]*v[k-1];} - else { ind = (k*k-k)/2 + i; r[i-1] += a[ind-1]*v[k-1];} - } - } - - } // End of void rwsmav(...) - - void rwsmin(double v[], double b[], int n, int m, int nrank) - { - // Author: V. Blobel - - // Obtain solution of linear equations V*X = B with symmetric matrix V - // and inverse (for m=1) or matrix inversion only (for m=0). - - // V = Symmetric n-by-n matrix in symmetric storage mode - // V(1) = V11, V(2) = V12, V(3) = V22, V(4) = V13, ... - // replaced by inverse matrix - // B = n-vector (for m=0 use a dummy argument) - // replaced by a solution vector - // m = see above - - // Method of solution is by elimination selecting the pivot point on the - // diagonal each stage. The rank of the matrix is returned in nrank. - - // For nrank != n, all remaining rows and columns of the resulting matrix - // V and the corresponding elements of B are set to zero. - - - double EPSS = (double)1.0E-6; - - int i, ii, ni, k=0, kk, j, jj, jl, jk, lk, l, ij; - double vkk, d, e; /* variable 'c' in original fortran file is not used */ - double[][] dr = new double[2][200]; - - // -------- Construct table ----------- - for(i=1; i<=n; i++) dr[0][i-1] = 1; - ni = n; - ii = 0; - for(i=1; i<=n; i++) { ii += i; dr[1][i-1] = Math.abs(v[ii-1]); } - - - // --------- Loop begins ---------- - nrank = n - ni; - - for (i=1; i<=ni; i++) - { - // --- Search for pivot and test for linearity and zero matrix - k = kk = jj = 0; vkk = 0; - for (j=1; j<=n; j++) - { - jj += j; - if (dr[0][j-1] == 0) break; - if (Math.abs(v[jj-1]) <= vkk) break; - if (Math.abs(v[jj-1]) < EPSS*dr[1][j-1]) break; - vkk = Math.abs(v[jj-1]); - k=j; kk=jj; - } - if (k == 0) {break;} - - // --- Preparation for elimination --- - nrank = nrank + 1; - dr[0][k-1] = 0; - d = 1/v[kk-1]; - v[kk-1] = -d; - if (m == 1) b[k-1] *= d; - jk = kk-k; - jl = 0; - - // --- Elimination --- - for (j=1; j<=n; j++) - { - if( j-k < 0 ) jk++; - else { - if ( j-k == 0) {jk = kk; jl += j; break;} - else jk = jk +j -1; - } - - - e = v[jk-1]; - v[jk-1] = d*e; - - if (m==1) b[j-1] -= b[k-1]*e; - lk = kk-k; - for (l=1; l<=j; l++) - { - jl++; - if(l-k < 0) lk++; - else { if (l==k) {lk=kk; break;} - else lk=lk + l - 1; - } - - v[jl-1] -= v[lk-1]*e; - } - } // End of loop over j - } // End of loop over i - - if(k != 0) { - // ----------- Change sign -------------- - ij=0; - for (i=1; i<=n; i++) { - for (j=1; j<=i; j++) - { - ij++; v[ij-1] = -v[ij-1]; - } - } - return; - - } - // --------- Clear rest of the matrix ------------- - - ij=0; - for (i=1; i<=n; i++) - { - if(m == 1 && dr[0][i-1] != 0) b[i-1]=0; - for (j=1; j<=i; j++) - { - ij++; - if (dr[0][i-1] + dr[0][j-1] != 0) v[ij-1]=0; - v[ij-1] = -v[ij-1]; - } - } - - return; - } // End of void rwsmin(double v[], double b[], int n, int m, int* nrank - - - - - //------------------------------------------------------------------------- - void rwfthc(int npt, double rf[], - double pf[], double wfi[], - double zf[], double wzf[], - int iopt, - - double vv0[], double ee0[], double ch2ph, double ch2z, - double del[], double delz[]) - - - // ----- Function for fast helix fit. ----- - - // A generalization of the TFTHEL routine to allow it to be called from a - // routine that contains any list of x and y values xf,yf for a set of npt - // points to be fitted. - - // ----- Input: ----- - - // npt: Number of 3-D points to be fit - // xf[]: Array of X-values of points to be fit - // yf[]: Array of Y-values of points to be fit - // rf[]: Array of R-values of points to be fit - // pf[]: Array of PHI-values of points to be fit - // wfi[]: Array of 1/(sig(rphi))**2 for each point - // zf[]: Array of Z-values of points to be fit - // wzf[]: Array of 1/(sig(z))**2 for each point - // iopt: 0 -> Distance**2 =x**2 +y**2 minimized; - // 1 -> Weighted with 1/SIMA(R*PHI)**2 - // 2 -> Error matrix calculated - // 3 -> 3-Dimensional iteration - - // ----- Output: ----- - - // vv0[5]: [0] = 1/r*charge, positive if clockwise; - // [1] = tan(lambda) { = dz/ds} tan(angle to (X,Y) PLANE); - // [2] = phi0 {0, 2*PI} angle to X-axis at r=d0; - // [3] = d0*sign [cm] minimal distance to Z-axis, - // +ve if axis encircled; - // [4] = z0 [cm] z position at r=d0; - // ee0[15]: Inverse of error matrix in triangular form; - // ch2ph: chi squared = Sum(phi deviations / errors)^2; - // ch2z: chi squared = Sum(z deviations / errors)^2; - // del: Unknown; - // delz: Unknown. - - // Note that the number of degrees of freedom = 2*npt-5 - - // Based on subroutine CIRCLE. - // Reference: "Computer Physics Communications", Volume 33, P. 329 - // Authors: N. Chernov, G. Ososkov and M. Poppe - - // Modified by Fred Weber, 8 Jun 1989. - // Translated into C by Michael Ispiryan, 2006 - - - { - int ITMAX = 15; - int IOWRIT = 6; - double EPS = (double)1.0e-16; - double ONEPI = (double)3.1415927; - double PI = (double)3.1415927; - double TWOPI = (double)6.2831854; - double PIBY2 = (double)1.57074635; - int MAX_HITS_ON_CHAIN = 200; - - double[] sp2 = new double[MAX_HITS_ON_CHAIN], vv1 = new double[5]; - double[] sxy = new double[MAX_HITS_ON_CHAIN], ss0 = new double[MAX_HITS_ON_CHAIN]; - double[] eee = new double[MAX_HITS_ON_CHAIN]; - double[] grad = new double[5], cov= new double[15], dv= new double[5]; - double[] deln = new double[MAX_HITS_ON_CHAIN], delzn = new double[MAX_HITS_ON_CHAIN]; - - double[] xf = new double[MAX_HITS_ON_CHAIN], yf= new double[MAX_HITS_ON_CHAIN], wf= new double[MAX_HITS_ON_CHAIN]; - - double alf, a0, a1, a2, a22, bet, cur, dd, den; - double det, dy, d2, f, fact, fg, f1, g, gam, gam0; - double g1, h, h2, p2, q2, rm, rn, xa, xb = 0, xd, xi; - double xm, xx, xy, x1, x2, den2, ya, yb, yd, yi, ym; - double yy, y1, y2, wn, sa2b2, dd0, phic; - - int i, n, iter, nrank= 0; - - double chi2_here, rr0, asym, sst, ph0, check; - double aa0, ome, gg0, hh0, ff0, sums, sumss, sumz, sumsz, sumw; - double denom, dzds_here, zz0, eta, dfd, dfo, dpd, dpo, ggg, dza; - double dzd, dzo, chi1; - - //nkb added these variables for the recalculation of dz/ds - double kangle, my_phi, xc, yc, xdca; - double ydca, xbar, ybar, xpt, ypt, alpha, beta; - if (npt <= 2) - { - System.out.println("BonusHelixFit::rwfthc(): Cannot fit less than 3 points; exiting..\n"); - return; - } - if (npt > MAX_HITS_ON_CHAIN) - { - System.out.println("BonusHelixFit::rwfthc(): Cannot fit more than " + MAX_HITS_ON_CHAIN + " points; exiting..\n" ); - return; - } - for(i=0; i= ITMAX) break; - dy = a1 + xa*(a22 + xa*(4.0*xa - 12.0)); - xb = xa - ya/dy; - if (Math.abs(ya) > Math.abs(yb)) xb = 0.5*(xb+xa); - if (Math.abs(xa-xb) < EPS) break; - xa = xb; yb = ya; iter++; - } - - gam = gam0*xb; - f1 = f - gam; - g1 = g - gam; - x1 = xd*g1 - yd*h; - y1 = yd*f1 - xd*h; - det = f1*g1 - h2; den2 = 1.0/(x1*x1 + y1*y1 + gam*det*det); - if (den2 <= 0.0) {ch2ph = 1.0E+30; ch2z = 1.0E+30; return;} - den = Math.sqrt(den2); cur = det*den + 0.0000000001; - alf = -(xm*det + x1)*den; - bet = -(ym*det + y1)*den; - rm = xm*xm + ym*ym; - - // ------- Calculation of standard circle parameters. NB: cur is - // ------- always positive. - asym = bet*xm - alf*ym; - sst = 1.0; - if (asym<0.0) sst = -1.0; - rr0 = sst*cur; - if((alf*alf + bet*bet) <= 0.0) {ch2ph = 1.0E+30; ch2z = 1.0E+30; return;} - sa2b2 = 1.0/(Math.sqrt(alf*alf + bet*bet)); - dd0 = (1.0 - 1.0/sa2b2)/cur; - phic = Math.asin(alf*sa2b2) + PIBY2; - if (bet > 0.0) phic = TWOPI - phic; - ph0 = phic + PIBY2; - - if (rr0 <= 0.0) ph0 -= ONEPI; - if (ph0 > TWOPI) ph0 -= TWOPI; - if (ph0 < 0.0) ph0 += TWOPI; - - vv0[0]=rr0; vv0[2]=ph0; vv0[3]=dd0; - //printf("rr0,ph0,dd0 = %f %f %f\n",1/rr0,ph0,dd0); - check = sst*rr0*dd0; - if (check == 1.0) { dd0 -= 0.007; vv0[3] = dd0; } - - // ------- Calculate phi distances to measured points - aa0=sst; ome=rr0; gg0=ome*dd0-aa0; hh0=1.0/gg0; - for(i=0; i 1.0) ff0 = 1.0; - - del[i] = ph0 + (ss0[i]-aa0)*PIBY2 + ss0[i]*Math.asin(ff0) - pf[i]; - if (del[i] > ONEPI) del[i] -= TWOPI; - if (del[i] < -ONEPI) del[i] += TWOPI; - } - - - // -------- Fit straight line in S-Z - for(i=0; i 0.9999) - { - //quiet = FALSE; - //fprintf(stderr, "+Track circles too much for this code(eee=%f); bad dzds\n",eee[i]); - //badarg = TRUE;//break; - //printf("eee[%d] = %f\n",i,eee[i]); - eee[i] = 0.9999; - } - if (eee[i] < -0.9999) - { - //quiet = FALSE; - //fprintf(stderr, "-Track circles too much for this code(eee=%f); bad dzds\n",eee[i]); - //badarg = TRUE;//break; - //printf("eee[%d] = %f\n",i,eee[i]); - eee[i] = -0.9999; - } - - sxy[i] = 2.0*Math.asin(eee[i])/ome; - //printf("original sxy[%d] = %f\n",i,sxy[i]); - } - - //if(badarg) - { - /* - for(i=0; i2.0*PI) my_phi-=2.0*PI; - xc = -Math.sin(my_phi)*((-vv0[3])+Math.abs(1.0/vv0[0])); - yc = Math.cos(my_phi)*((-vv0[3])+Math.abs(1.0/vv0[0])); - xdca = -Math.sin(my_phi)*(-vv0[3]); - ydca = Math.cos(my_phi)*(-vv0[3]); - xbar = xdca - xc; - ybar = ydca - yc; - //printf("xdca= %.1f ydca= %.1f xc= %.1f yc= %.1f xbar= %.1f ybar= %.1f\n", - // xdca, ydca, xc, yc, xbar, ybar); - for(i=0; i 1.0) - { - //quiet = FALSE; - //printf("eee[%d] = %f, rad = %f, mydd = %f\n",i,eee[i],1/rr0,Math.sqrt(mydd)); - //getchar(); - } - sxy[i] = (1/(sst*rr0))*acos(eee[i]); - //printf("law of Math.cos sxy[%d] = %f\n",i,sxy[i]); - */ - //ksxy = sxy[i]; - xpt = xf[i] - xc; - ypt = yf[i] - yc; - alpha = Math.atan2(ypt,xpt); - beta = Math.atan2(ybar,xbar); //if(alpha > 2*PI)alpha -= 2*PI; - //if(alpha < 0) alpha += 2*PI; - //if(beta > 2*PI) beta -= 2*PI; - //if(beta < 0) beta += 2*PI; - //printf("alpha = %.2f beta = %.2f\n",alpha*180./PI,beta*180./PI); - sxy[i] = beta - alpha; - if(sxy[i] > PI) sxy[i] = sxy[i] - 2*PI; - if(sxy[i] < -PI)sxy[i] = sxy[i] + 2*PI; - //if(sxy[i] < 0) sxy[i] += 2*PI; - kangle = sxy[i]; - sxy[i] = (1/rr0)*sxy[i]; - - //printf("[%d] xf= %.1f yf= %.1f xpt= %.1f ypt= %.1f\n", - //i, xf[i], yf[i], xpt, ypt); - //HFILL(9916, ksxy - sxy[i], 0.0, 1.0); - //printf("%f\n",ksxy-sxy[i]); - } - - } - - - sums = 0.0; - sumss = 0.0; - sumz = 0.0; - sumsz = 0.0; - sumw = 0.0; - for(i=0; i= 0.0) denom = 1.0E-6; - else denom = -1.0E-6; - } - - dzds_here = (sumw*sumsz - sums*sumz) / denom; - zz0 = (sumss*sumz - sums*sumsz) / denom; - vv0[1] = dzds_here; vv0[4] = zz0; - - // --------- Calculation of chi**2 - for(i=0; i 0.9999) ff0 = 0.9999; - if (ff0 < -0.9999) ff0 = -0.9999; - eta = ss0[i] / Math.sqrt(Math.abs(1.0+ff0)*(1.0-ff0)); - dfd = (1.0 + hh0*hh0*(1.0-ome*ome*rf[i]*rf[i])) / (2.0*rf[i]); - dfo = -aa0*(rf[i]*rf[i] - dd0*dd0)*hh0*hh0 / (2.0*rf[i]); - dpd = eta*dfd; dpo = eta*dfo; - // --- Derivatives of z component - ggg = eee[i] / Math.sqrt(Math.abs( (1.0+eee[i])*(1.0-eee[i]))); - dza = sxy[i]; - check = rf[i]*rf[i] - vv0[3]*vv0[3]; - if (check == 0.0) check = 2.0*0.007; - dzd = 2.0*(vv0[1]/vv0[0]) * Math.abs(ggg) * (0.5*aa0*vv0[0] / - (1.0 - aa0*vv0[3]*vv0[0]) - vv0[3]/check); - dzo = -vv0[1]*sxy[i]/vv0[0] + vv0[1]*ggg/(vv0[0]*vv0[0]) * - (2.0 + aa0*vv0[0]*vv0[3]/(1.0 - aa0*vv0[0]*vv0[3])); - - // ---- Error matrix - ee0[0] += sp2[i]*dpo*dpo + wzf[i]*dzo*dzo; - ee0[1] += wzf[i]*dza*dzo; - ee0[2] += wzf[i]*dza*dza; - ee0[3] += sp2[i]*dpo; - ee0[5] += sp2[i]; - ee0[6] += sp2[i]*dpo*dpd + wzf[i]*dzo*dzd; - ee0[8] += sp2[i]*dpd; - ee0[9] += sp2[i]*dpd*dpd + wzf[i]*dzd*dzd; - ee0[10] += wzf[i]*dzo; - ee0[11] += wzf[i]*dza; - ee0[13] += wzf[i]*dzd; - ee0[14] += wzf[i]; - - // --- Gradient vector - grad[0] += -del[i]*sp2[i]*dpo - delz[i]*wzf[i]*dzo; - grad[1] += - delz[i]*wzf[i]*dza; - grad[2] += -del[i]*sp2[i]; - grad[3] += -del[i]*sp2[i]*dpd - delz[i]*wzf[i]*dzd; - grad[4] += - delz[i]*wzf[i]; - } // End of for(i...) - - - if (iopt < 3) return; - - - // --------------- Newton's next guess - for(i=0; i<15; i++) cov[i] = ee0[i]; - - rwsmin(cov, vv1, 5, 0, nrank); - rwsmav(dv, cov, grad, 5); - - for(i=0; i<5; i++) vv1[i] = vv0[i] + dv[i]; - - //------- New differences in phi and z - gg0 = vv1[0]*vv1[3] - aa0; - for(i=0; i 1.0) ff0 = 1.0; - if (ff0 < -1.0) ff0 = -1.0; - - deln[i] = vv1[2] + (ss0[i]-aa0)*PIBY2 + ss0[i]*Math.asin(ff0) - pf[i]; - if (deln[i] > ONEPI) deln[i] -= TWOPI; - if (deln[i] < -ONEPI) deln[i] += TWOPI; - eee[i] = 0.5*vv1[0]*Math.sqrt(Math.abs( (rf[i]*rf[i] - vv1[3]*vv1[3]) / - (1.0 - aa0*vv1[0]*vv1[3]) )); - if (eee[i] > 0.9999) eee[i] = 0.9999; - if (eee[i] < -0.9999) eee[i] = -0.9999; - sxy[i] = 2.0*Math.asin(eee[i]) / vv1[0]; - delzn[i] = vv1[4] + vv1[1]*sxy[i] - zf[i]; - } - - // ---------- Calculation of chi**2 - chi1 = ch2ph = ch2z = 0.0; - for(i=0; i24.0) R=24.; - if(R<1.5) R=1.5; - double Para_dPhiVsR[] = {0.753136, -0.391614, 0.0836029, -0.00944999, - 0.000611348, -2.26783e-05, 4.47764e-07, -3.64278e-09}; - double dPhi = Para_dPhiVsR[0]; - for(int i=1;i<=7;i++) dPhi += Para_dPhiVsR[i]*Math.pow(R,i); - Phi = Phi - dPhi; - //apply 2nd correction if R<5.5 cm - if(R<5.5) { - double Para_dPhiVsR_2nd[] = {11.0937, -17.3801, 11.0492, -3.65267, - 0.663338, -0.0628701, 0.00243461}; - double dPhi_2nd = Para_dPhiVsR_2nd[0]; - for(int i=1;i<=6;i++) dPhi_2nd += Para_dPhiVsR_2nd[i]*Math.pow(R,i); - Phi = Phi - dPhi_2nd; - } - - return; - - /****************************************** - r_hel-rho_1st:r_hel, only good for 1.014.5) R=14.5; - if(R<14.50001) { - double Para_dRVsR[] = { 8.2822, -8.35421, 3.32568, -0.685895, 0.0797764, - -0.00527024, 0.000184178, -2.64062e-06}; - double dR = Para_dRVsR[0]; - for(int i=1;i<=7;i++) dR += Para_dRVsR[i]*Math.pow(R,i); - R = R - dR; - Rho = (Rho<0)? -R : R;*/ - //std::cout<<"\t\t dR="<arg0._cellID) { - return 1; - } else { - return 0; - } - } - - -} diff --git a/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/HitDistance.java b/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/HitDistance.java deleted file mode 100644 index 1dd2b5f470..0000000000 --- a/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/HitDistance.java +++ /dev/null @@ -1,128 +0,0 @@ -package org.jlab.rec.rtpc.hit; - -import java.util.HashMap; -import java.util.concurrent.ConcurrentHashMap; -import java.util.Vector; - -import javax.swing.JFrame; - -import org.jlab.clas.physics.Vector3; -import org.jlab.groot.data.H1F; -import org.jlab.groot.graphics.EmbeddedCanvas; - -public class HitDistance { - - public void FindDistance(HitParameters params) { - HashMap ADCMap = params.get_R_adc(); - Vector PadNum = params.get_PadNum(); - int Pad = 0; //initializing pad - int Pad2 = 0; - int TrigWindSize = params.get_TrigWindSize(); //Trigger Window Size = 10000 - //int StepSize = params.get_StepSize(); - int StepSize = 120; //Time stepsize - double thresh = 1e-5; //Arbitrary ADC threshold - double ADC = 0; - double ADC2 = 0; - Vector3 TempPadCoords = new Vector3(); - Vector3 CheckPadCoords = new Vector3(); - Vector3 CheckPadPrevCoords = new Vector3(); - EmbeddedCanvas c1 = new EmbeddedCanvas(); - EmbeddedCanvas c2 = new EmbeddedCanvas(); - EmbeddedCanvas c3 = new EmbeddedCanvas(); - H1F t1 = new H1F("t1","t1",100,0,50); - H1F t2 = new H1F("t2","t2",100,0,8); - H1F t3 = new H1F("t3","t3",100,0,10); - t1.setTitleX("xy in mm"); - t2.setTitleX("z in mm"); - t3.setTitleX("ellipse formula result"); - JFrame j1 = new JFrame(); - j1.setSize(800,600); - j1.setTitle("xy"); - JFrame j2 = new JFrame(); - j2.setSize(800,600); - j2.setTitle("z"); - JFrame j3 = new JFrame(); - j3.setSize(800,600); - j3.setTitle("ellipse"); - double EllipseDeltax = 0; - double EllipseDeltay = 0; - double EllipseDeltaz = 0; - double EllipseTotal = 0; - double PhiDelta = Math.pow(3, 2); - double ZDelta = Math.pow(6, 2); - for(int t = 0; t < TrigWindSize; t+=StepSize) - { - for(int p = 0; p < PadNum.size(); p ++) - { - Pad = PadNum.get(p); - ADC = ADCMap.get(Pad)[t]; - if(ADC > thresh) - { - Vector3 PadCoords = PadCoords(Pad); - for(int p2 = 0; p2 < PadNum.size(); p2++) - { - if(p2 != p) - { - Pad2 = PadNum.get(p2); - ADC2 = ADCMap.get(Pad2)[t]; - if(ADC2 > thresh) - { - CheckPadCoords = PadCoords(Pad2); - EllipseDeltax = Math.pow(Math.abs(PadCoords.x()-CheckPadCoords.x()),2); - EllipseDeltay = Math.pow(Math.abs(PadCoords.y()-CheckPadCoords.y()),2); - EllipseDeltaz = Math.pow(Math.abs(PadCoords.z()-CheckPadCoords.z()),2); - EllipseTotal = ((EllipseDeltax+EllipseDeltay)/PhiDelta) + (EllipseDeltaz/ZDelta); - t1.fill(Math.sqrt(EllipseDeltax+EllipseDeltay)); - t2.fill(Math.sqrt(EllipseDeltaz)); - t3.fill(EllipseTotal); - } - } - } - } - } - } - c1.draw(t1); - c2.draw(t2); - c3.draw(t3); - j1.add(c1); - j2.add(c2); - j3.add(c3); - j1.setVisible(true); - j2.setVisible(true); - j3.setVisible(true); - } - private Vector3 PadCoords(int cellID) { - - double PAD_W = 2.79; // in mm - double PAD_S = 80.0; //in mm - double PAD_L = 4.0; // in mm - double RTPC_L=384.0; // in mm - double phi_pad = 0; - //double Num_of_Rows = (2.0*(Math.PI)*PAD_S)/PAD_W; - double Num_of_Cols = RTPC_L/PAD_L; - double PI=Math.PI; - double z0 = -(RTPC_L/2.0); - double phi_per_pad = PAD_W/PAD_S; // in rad - double chan = (double)cellID; - double col = chan%Num_of_Cols; - double row=(chan-col)/Num_of_Cols; - double z_shift = row%4; - - phi_pad=(row*phi_per_pad)+(phi_per_pad/2.0); - - if(phi_pad>= 2.0*PI) - { - phi_pad -= 2.0*PI; - } - if(phi_pad<0) - { - phi_pad += 2.0*PI; - } - - double z_pad=z0+(col*PAD_L)+(PAD_L/2.0)+z_shift; - - Vector3 PadCoords = new Vector3(PAD_S*Math.cos(phi_pad),PAD_S*Math.sin(phi_pad),z_pad); - return PadCoords; - - } -} diff --git a/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/HitParameters.java b/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/HitParameters.java deleted file mode 100644 index dc2144ff9f..0000000000 --- a/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/HitParameters.java +++ /dev/null @@ -1,105 +0,0 @@ -package org.jlab.rec.rtpc.hit; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Vector; -import java.util.concurrent.ConcurrentHashMap; - -import org.jlab.clas.physics.LorentzVector; -import org.jlab.clas.physics.Vector3; - -public class HitParameters { - - private int _StepSize = 10; - private int _BinSize = 40; - private int _NBinKept = 3; - private int _TrigWindSize = 10000; - private int _eventnum = 0; - private HashMap _R_adc = new HashMap(); - private HashMap> _TimeMap = new HashMap>(); - private HashMap> _FinalTIDMap = new HashMap>(); - private Vector _PadN = new Vector(); // used to read only cell with signal, one entry for each hit - private Vector _PadNum = new Vector();// used to read only cell with signal, one entry for each cell - private Vector _Pad = new Vector(); - private Vector _ADC = new Vector(); - private Vector _Time_o = new Vector(); - private Vector _weightave = new Vector(); - private Vector _maxinte = new Vector(); - private Vector _time = new Vector(); - private Vector _XVec = new Vector(); - private Vector _YVec = new Vector(); - private Vector _ZVec = new Vector(); - private HashMap>> _TIDMap = new HashMap>>(); - private HashMap>> _strkTIDMap = new HashMap>>(); - private HashMap> _alltracks = new HashMap>(); - private HashMap _largetmap = new HashMap(); - private HashMap> _recohitvector = new HashMap>(); - private HashMap _padmap = new HashMap(); - private TrackMap _trackmap = new TrackMap(); - private ReducedTrackMap _rtrackmap = new ReducedTrackMap(); - - public int get_StepSize(){return _StepSize;} // step size of the signal before integration (arbitrary value) - public int get_BinSize(){return _BinSize;} // electronics integrates the signal over 40 ns - public int get_NBinKept(){return _NBinKept;} // only 1 bin over 3 is kept by the daq - public int get_TrigWindSize(){return _TrigWindSize;} // Trigger window should be 10 micro - public HashMap get_R_adc(){return _R_adc;} - public HashMap> get_TimeMap(){return _TimeMap;} - public Vector get_PadN(){return _PadN;} - public Vector get_PadNum(){return _PadNum;} - public Vector get_Pad(){return _Pad;} - public Vector get_ADC(){return _ADC;} - public Vector get_Time_o(){return _Time_o;} - public int get_eventnum(){return _eventnum;} - public Vector get_weightave() {return _weightave;} - public Vector get_maxinte() {return _maxinte;} - public Vector get_time() {return _time;} - public Vector get_XVec() {return _XVec;} - public Vector get_YVec() {return _YVec;} - public Vector get_ZVec() {return _ZVec;} - public HashMap>> get_TIDMap() {return _TIDMap;} - public HashMap>> get_strkTIDMap() {return _strkTIDMap;} - public HashMap> get_FinalTIDMap() {return _FinalTIDMap;} - public HashMap> get_alltracks() {return _alltracks;} - public HashMap get_largetmap() {return _largetmap;} - public HashMap> get_recohitvector() {return _recohitvector;} - public TrackMap get_trackmap() {return _trackmap;} - public ReducedTrackMap get_rtrackmap() {return _rtrackmap;} - public PadVector get_padvector(int pad) { - if(!_padmap.containsKey(pad)) { - _padmap.put(pad, new PadVector(pad)); - } - return _padmap.get(pad); - } - - - public void set_R_adc(HashMap _R_adc){this._R_adc = _R_adc;} - public void set_TimeMap(HashMap> _TimeMap){this._TimeMap = _TimeMap;} - public void set_PadN(Vector _PadN){this._PadN = _PadN;} - public void set_PadNum(Vector _PadNum){this._PadNum = _PadNum;} - public void set_Pad(Vector _Pad){this._Pad = _Pad;} - public void set_ADC(Vector _ADC){this._ADC = _ADC;} - public void set_Time_o(Vector _Time_o){this._Time_o = _Time_o;} - public void set_eventnum(int _eventnum){this._eventnum = _eventnum;} - public void set_weightave(Vector _weightave) {this._weightave = _weightave;} - public void set_maxinte(Vector _maxinte) {this._maxinte = _maxinte;} - public void set_time(Vector _time) {this._time = _time;} - public void set_XVec(Vector _XVec) {this._XVec = _XVec;} - public void set_YVec(Vector _YVec) {this._YVec = _YVec;} - public void set_ZVec(Vector _ZVec) {this._ZVec = _ZVec;} - public void set_TIDMap(HashMap>> _TIDMap) {this._TIDMap = _TIDMap;} - public void set_strkTIDMap(HashMap>> _strkTIDMap) {this._strkTIDMap = _strkTIDMap;} - public void set_FinalTimeMap(HashMap> _finalTIDMap){this._FinalTIDMap = _finalTIDMap;} - public void set_alltracks(HashMap> _alltracks) {this._alltracks = _alltracks;} - public void set_largetmap(HashMap _largetmap) {this._largetmap = _largetmap;} - public void set_recohitvector(HashMap> _recohitvector) {this._recohitvector = _recohitvector;} - public void set_trackmap(TrackMap _trackmap) {this._trackmap = _trackmap;} - public void set_rtrackmap(ReducedTrackMap _rtrackmap) {this._rtrackmap = _rtrackmap;} - - public HitParameters() {} - - private static HitParameters INSTANCE = new HitParameters(); - - public static HitParameters getInstance() { - return HitParameters.INSTANCE; -} -} \ No newline at end of file diff --git a/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/HitReconstruction.java b/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/HitReconstruction.java deleted file mode 100644 index c584416380..0000000000 --- a/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/HitReconstruction.java +++ /dev/null @@ -1,204 +0,0 @@ -package org.jlab.rec.rtpc.hit; - -import java.util.List; -import java.util.Vector; - -public class HitReconstruction { - - public HitReconstruction() { - // TODO Auto-generated constructor stub - } - - public void Reco(HitParameters params) { - Vector PadNum = params.get_PadNum(); - Vector weightave = params.get_weightave(); - Vector maxinte = params.get_maxinte(); - Vector TimeVec = new Vector(); - Vector XVec = new Vector(); - Vector YVec = new Vector(); - Vector ZVec = new Vector(); - int p = 0; - //for(Hit hit : rawHits) { - for(p = 0; p= 2.0*PI) { - phi_pad -= 2.0*PI; - } - if(phi_pad<0) - { - phi_pad += 2.0*PI; - } - - z_pad=z0+(col*PAD_L)+(PAD_L/2.0)+z_shift; - // ----------------------------------------------------------------------- - - - // find reconstructed position of ionization from Time info - - t_s2pad = Time-t_gap; - - r_rec=((-(Math.sqrt(a_t*a_t+(4.*b_t*t_s2pad)))+a_t+(14.*b_t))/(2.*b_t))*10.0; //in mm - - - dphi=a_phi*(7.-r_rec/10.)+b_phi*(7.-r_rec/10.)*(7.-r_rec/10.); // in rad - - - dz=0; - - phi_rec=phi_pad-dphi-phi_gap; - if( phi_rec<0.0 ) - { - phi_rec+=2.0*PI; - } - if( phi_rec>2.0*PI ) - { - phi_rec-=2.0*PI; - } - - // x,y,z pos of reconstructed track - x_rec=r_rec*(Math.cos(phi_rec)); - y_rec=r_rec*(Math.sin(phi_rec)); - z_rec=z_pad-dz; - - // x,y,z pos of pad hit - //x_pad=(PAD_S)*(Math.cos(phi_pad)); - //y_pad=(PAD_S)*(Math.sin(phi_pad)); - - // actual position on pad of hits - //phi_hit=phi_rad-(row*phi_per_pad); - //z_hit=Z-z0-(col*PAD_L)-z_shift; - - // find differences (delta = generated-reconstructed) - //delta_x=X-x_rec; - //delta_y=Y-y_rec; - //delta_z=Z-z_rec; - //delta_r=r_pos-r_rec; - //delta_phi = phi_pos-phi_rec; - - - - - /*hit.set_cellID(cellID); - hit.set_Time(t_s2pad); - hit.set_Edep(Edep); - hit.set_PosX(x_rec); - hit.set_PosY(y_rec); - hit.set_PosZ(z_rec);*/ - TimeVec.add(t_s2pad); - XVec.add(x_rec); - YVec.add(y_rec); - ZVec.add(z_rec); - - - - - } - params.set_time(TimeVec); - params.set_XVec(XVec); - params.set_YVec(YVec); - params.set_ZVec(ZVec); - //System.out.println(XVec.size() + " " + PadNum.size()); - //XVec.clear(); - //YVec.clear(); - //ZVec.clear(); - //TimeVec.clear(); - - } -} diff --git a/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/HitVector.java b/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/HitVector.java deleted file mode 100644 index 4d32d82e14..0000000000 --- a/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/HitVector.java +++ /dev/null @@ -1,87 +0,0 @@ -package org.jlab.rec.rtpc.hit; - -public class HitVector { - - private int pad; - private double z; - private double phi; - private double time; - private double adc; - - public HitVector() - { - pad = 0; - z = 0; - phi = 0; - time = 0; - adc = 0; - } - - public HitVector(int padnum, double hittime, double padadc) - { - pad = padnum; - z = 0; - phi = 0; - time = hittime; - adc = padadc; - } - - public HitVector(int padnum, double zpad, double phipad, double hittime, double padadc) - { - pad = padnum; - z = zpad; - phi = phipad; - time = hittime; - adc = padadc; - } - - public void setpad(int padnum) - { - pad = padnum; - } - - public void setz(double zpad) - { - z = zpad; - } - - public void setphi(double phipad) - { - phi = phipad; - } - - public void settime(double hittime) - { - time = hittime; - } - - public void setadc(double padadc) - { - adc = padadc; - } - - public int pad() - { - return pad; - } - - public double z() - { - return z; - } - - public double phi() - { - return phi; - } - - public double time() - { - return time; - } - - public double adc() - { - return adc; - } -} diff --git a/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/MapCombine.java b/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/MapCombine.java deleted file mode 100644 index 35688c4ac9..0000000000 --- a/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/MapCombine.java +++ /dev/null @@ -1,281 +0,0 @@ -package org.jlab.rec.rtpc.hit; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Vector; -import java.util.concurrent.ConcurrentHashMap; - -import javax.swing.JFrame; - -import org.jlab.clas.physics.LorentzVector; -import org.jlab.clas.physics.Vector3; -import org.jlab.groot.data.GraphErrors; -import org.jlab.groot.data.H2F; -import org.jlab.groot.graphics.EmbeddedCanvas; - -public class MapCombine { - - public void MC(HitParameters params, boolean draw) { - - HashMap> TAMap = params.get_FinalTIDMap(); - HashMap>> TFMap = params.get_strkTIDMap(); - HashMap ADCMap = params.get_R_adc(); - - Vector PadList = new Vector(); - double maxvalue = 0; - double thresh = 0; - int TrigWindSize = params.get_TrigWindSize(); - double sumnumer = 0; - double sumdenom = 0; - int count = 0; - int newtid = 0; - - HashMap weightave = new HashMap(); - HashMap weightaveadc = new HashMap(); - HashMap> trTFMap = new HashMap>(); - HashMap> alltracks = new HashMap>(); - HitVector vtmp = new HitVector(); - HitVector v3tmp = new HitVector(); - HitVector hitvec = new HitVector(); - Vector toListvec = new Vector(); - double larget = 0; - int countadcvalues = 0; - - /*GraphErrors g = new GraphErrors(); - EmbeddedCanvas c = new EmbeddedCanvas(); - JFrame jf = new JFrame(); - jf.setSize(800,600);*/ - //System.out.println(TIDMap.size()); - //for(Hit hit : rawHits) { - for(int TID : TFMap.keySet()){ - //System.out.println(" "); - larget = 0; - PadList.clear(); - weightave.clear(); - for(int time : TFMap.get(TID).keySet()) - { - for(int pad = 0; pad < TFMap.get(TID).get(time).size(); pad++) - { - //System.out.println(TID + " " + time + " " + TFMap.get(TID).get(time).get(pad)); - if(!PadList.contains(TFMap.get(TID).get(time).get(pad))) - { - PadList.add(TFMap.get(TID).get(time).get(pad)); - } - } - } - - for(int pad = 0; pad < PadList.size(); pad++) - { - for(int time : TFMap.get(TID).keySet()) - { - if(TFMap.get(TID).get(time).contains(PadList.get(pad))) - { - if(ADCMap.get(PadList.get(pad))[time]>maxvalue) - { - maxvalue = ADCMap.get(PadList.get(pad))[time]; - //System.out.println(maxvalue); - } - } - } - thresh = maxvalue/2; - for(int time = 0; time < TrigWindSize; time+=120) - { - if(ADCMap.get(PadList.get(pad))[time] > thresh) - { - sumnumer += ADCMap.get(PadList.get(pad))[time]*time; - sumdenom += ADCMap.get(PadList.get(pad))[time]; - countadcvalues++; - //System.out.println(PadList.get(pad) + " " + time); - } - } - if(sumnumer/sumdenom >= larget) - { - larget = sumnumer/sumdenom; - } - //System.out.println("weightave " + PadList.get(pad) + " " + sumnumer/sumdenom); - weightave.put(PadList.get(pad), sumnumer/sumdenom); - weightaveadc.put(PadList.get(pad), sumdenom); - sumnumer = 0; - sumdenom = 0; - maxvalue = 0; - countadcvalues = 0; - //padvec = PadCoords(PadList.get(pad)); - //gZvsT.addPoint(weightave.get(PadList.get(pad)), padvec.z(), 0, 0); - //gPhivsT.addPoint(weightave.get(PadList.get(pad)), Math.atan2(padvec.y(),padvec.x()),0,0); - } - - int pad = 0; - double avetime = 0; - double adc = 0; - trTFMap.put(TID,new Vector()); - for(int p = 0; p < PadList.size(); p++) - { - pad = PadList.get(p); - avetime = weightave.get(pad); - adc = weightaveadc.get(pad); - //LorentzVector v = new LorentzVector(avetime,Math.atan2(PadCoords(pad).y(),PadCoords(pad).x()),PadCoords(pad).z(),pad); - HitVector v = new HitVector(pad,PadCoords(pad).z(),Math.atan2(PadCoords(pad).y(),PadCoords(pad).x()),avetime,adc); - - trTFMap.get(TID).add(v); - } - - - //trTFMap.put(TID, new HashMap()); - //trTFMap.get(TID).putAll(weightave); - - //System.out.println(" "); - } - for(int choosetid : trTFMap.keySet()) { - double smalltime = 0; - for(int i = 0; i < trTFMap.get(choosetid).size(); i++) - { - smalltime = trTFMap.get(choosetid).get(i).time(); - for(int j = 0; j < trTFMap.get(choosetid).size();j++) - { - if(trTFMap.get(choosetid).get(j).time() < smalltime && i!=j) - { - trTFMap.get(choosetid).insertElementAt(trTFMap.get(choosetid).get(i), j); - trTFMap.get(choosetid).remove(i+1); - break; - } - } - } - } - - for(int i : TAMap.keySet()) - { - //toListvec.clear(); - alltracks.put(newtid, new Vector()); - for(int j = 0; j < TAMap.get(i).size(); j++) - { - vtmp = TAMap.get(i).get(j); - //v3tmp = new Vector3(vtmp.pad(),vtmp.time(),0); - //System.out.println(vtmp.e() + " " + vtmp.px()); - //System.out.println(v3tmp.x() + " " + v3tmp.y()); - //toListvec.add(v3tmp); - alltracks.get(newtid).add(vtmp); - } - //System.out.println(toListvec.size()); - //System.out.println(" "); - //alltracks.put(newtid, toListvec); - - newtid++; - - } - toListvec.clear(); - //System.out.println(" "); - for(int i : trTFMap.keySet()) - { - //System.out.println(" "); - //toListvec.clear(); - alltracks.put(newtid, new Vector()); - //for(int pad : trTFMap.get(i).keySet()) - for(int j = 0; j < trTFMap.get(i).size(); j++) - { - v3tmp = trTFMap.get(i).get(j); - //System.out.println(pad); - //v3tmp = new HitVector(pad,trTFMap.get(i).get(pad),0); - //System.out.println(v3tmp.x() + " " + v3tmp.y()); - //toListvec.add(v3tmp); - alltracks.get(newtid).add(v3tmp); - } - //System.out.println(" "); - //System.out.println(toListvec.size()); - //alltracks.put(newtid, toListvec); - newtid++; - } - HashMap largetmap = new HashMap(); - larget = 0; - HashMap histmap = new HashMap(); - HashMap canvasmap = new HashMap(); - HashMap framemap = new HashMap(); - //H2F adcvst = new H2F("adcvst",500,3000,12000,500,0,10); - //System.out.println(" "); - Vector marktid = new Vector(); - for(int i : alltracks.keySet()) - { - larget = 0; - /*if(alltracks.get(i).size() < 6) { - System.out.println("removed track with " + alltracks.get(i).size() + " hits"); - marktid.add(i); - continue; - }*/ - histmap.put(i, new GraphErrors()); - //System.out.println(i); - for(int j = 0; j < alltracks.get(i).size(); j++) - { - //if(j < 3) {g.addPoint(alltracks.get(i).get(j).y(), y, 0, 0); - //System.out.println(i + " " + alltracks.get(i).get(j).time() + " " + alltracks.get(i).get(j).adc()); - histmap.get(i).addPoint(alltracks.get(i).get(j).time(), alltracks.get(i).get(j).adc(),0,0); - if(alltracks.get(i).get(j).time() > larget) - { - larget = alltracks.get(i).get(j).time(); - - } - } - canvasmap.put(i, new EmbeddedCanvas()); - canvasmap.get(i).draw(histmap.get(i)); - framemap.put(i, new JFrame()); - framemap.get(i).setSize(800, 600); - framemap.get(i).add(canvasmap.get(i)); - if(draw) framemap.get(i).setVisible(true); - largetmap.put(i, larget); - //System.out.println(" "); - } - /*for(int i = 0; i < marktid.size(); i++) { - alltracks.remove(i); - }*/ - for(int z : canvasmap.keySet()) { - //canvasmap.get(z).save(z + ".png"); - } - EmbeddedCanvas c_adcvst = new EmbeddedCanvas(); - c_adcvst.draw(histmap.get(0)); - if(draw) { - JFrame j_adcvst = new JFrame(); - j_adcvst.setSize(800, 600); - j_adcvst.add(c_adcvst); - j_adcvst.setVisible(true); - } - - //System.out.println("There are " + alltracks.size() + " tracks sorted in this event!"); - params.set_alltracks(alltracks); - params.set_largetmap(largetmap); - } - - private Vector3 PadCoords(int cellID) { - - double PAD_W = 2.79; // in mm - double PAD_S = 80.0; //in mm - double PAD_L = 4.0; // in mm - double RTPC_L= 384.0; // in mm - double phi_pad = 0; - //double Num_of_Rows = (2.0*(Math.PI)*PAD_S)/PAD_W; - double Num_of_Cols = RTPC_L/PAD_L; - double PI=Math.PI; - double z0 = -(RTPC_L/2.0); - double phi_per_pad = PAD_W/PAD_S; // in rad - double chan = (double)cellID; - double col = chan%Num_of_Cols; - double row=(chan-col)/Num_of_Cols; - double z_shift = row%4; - - phi_pad=(row*phi_per_pad)+(phi_per_pad/2.0); - - if(phi_pad>= 2.0*PI) - { - phi_pad -= 2.0*PI; - } - if(phi_pad<0) - { - phi_pad += 2.0*PI; - } - - double z_pad=z0+(col*PAD_L)+(PAD_L/2.0)+z_shift; - - Vector3 PadCoords = new Vector3(PAD_S*Math.cos(phi_pad),PAD_S*Math.sin(phi_pad),z_pad); - return PadCoords; - - } - - -} diff --git a/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/PadAve.java b/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/PadAve.java deleted file mode 100644 index 79f5d80b13..0000000000 --- a/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/PadAve.java +++ /dev/null @@ -1,99 +0,0 @@ -package org.jlab.rec.rtpc.hit; - -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.util.concurrent.ConcurrentHashMap; -import java.util.HashMap; -import java.util.Vector; - -public class PadAve { - public void TimeAverage(HitParameters params){ - - int StepSize = params.get_StepSize(); // step size of the signal before integration (arbitrary value) - int BinSize = params.get_BinSize(); // electronics integrates the signal over 40 ns - int NBinKept = params.get_NBinKept(); // only 1 bin over 3 is kept by the daq - int TrigWindSize = params.get_TrigWindSize(); // Trigger window should be 10 micro - int NTrigSampl = TrigWindSize/BinSize; // number of time samples - double inte=0; - double inte_tot; // integral of the signal in BinSize - double max_inte=0; // maximum of the integral to help the fit - double max_t=0; - double sumnumer = 0; - double sumdenom = 0; - double weightave = 0; - double timesum = 0; - HashMap R_adc = params.get_R_adc(); - HashMap> TimeMap = params.get_TimeMap(); - Vector PadNum = params.get_PadNum(); - Vector PadN = params.get_PadN(); - Vector Pad = params.get_Pad(); - Vector ADC = params.get_ADC(); - Vector Time_o = params.get_Time_o(); - Vector weightavevec = new Vector(); - Vector maxinte = new Vector(); - boolean flag_event = false; - int eventnum = params.get_eventnum(); - //try{ - //FileWriter write2 = new FileWriter("/Users/davidpayette/Documents/FileOutput/Output.txt",true); - //write2.write("Event Number" + "\t" + "Pad Number" + "\t" + "Time Value for each bin" + "\t" + "ADC value for each bin" + "\r\n"); - - - inte=0; - for(int p=0;p0) inte+=0.5*(R_adc.get(PadNum.get(p))[t-StepSize]+R_adc.get(PadNum.get(p))[t])*StepSize; - inte_tot+=inte; - if(t%BinSize==0 && t>0){ // integration over BinSize - if(t%(BinSize*NBinKept)==0){ // one BinSize over NBinKept is read out, hence added to the histogram - if(max_inte R_adc = params.get_R_adc(); - HashMap Adcmap = new HashMap(); - Vector PadNum = params.get_PadNum(); - Vector PadN = params.get_PadN(); - Vector Pad = params.get_Pad(); - Vector ADC = params.get_ADC(); - Vector Time_o = params.get_Time_o(); - boolean flag_event = false; - int eventnum = params.get_eventnum(); - - /*JFrame j1 = new JFrame(); - GraphErrors g1 = new GraphErrors(); - g1.setMarkerSize(0); - g1.setTitleX("Time(ns)"); - g1.setTitleY("ADC"); - g1.setMarkerSize(3); - EmbeddedCanvas c1 = new EmbeddedCanvas(); - j1.setSize(800, 600); - */ - - - //F1D f1 = new F1D("f1", "[amp]*gaus(x,[mean],[sigma])",0,1); - - inte=0; - for(int p=0;p0) inte+=0.5*(R_adc.get(PadNum.get(p))[t-StepSize]+R_adc.get(PadNum.get(p))[t])*StepSize; - - inte_tot+=inte; - if(t%BinSize==0 && t>0){ // integration over BinSize - if(t%(BinSize*NBinKept)==0){ // one BinSize over NBinKept is read out, hence added to the histogram - - Adcmap.get(PadNum.get(p))[t] = inte; - - //g1.addPoint(t,inte,0,0); - if(max_inte rawHits, HitParameters params){ - - -//______________________________________________________________________________________________ -// __________________________________________ Variables _________________________________________ -//______________________________________________________________________________________________ - - int StepSize = params.get_StepSize(); // step size of the signal before integration (arbitrary value) - int BinSize = params.get_BinSize(); // electronics integrates the signal over 40 ns - int NBinKept = params.get_NBinKept(); // only 1 bin over 3 is kept by the daq - int TrigWindSize = params.get_TrigWindSize(); // Trigger window should be 10 micro - int NTrigSampl = TrigWindSize/BinSize; // number of time samples - - HashMap R_adc = params.get_R_adc();// Raw depositions for CellID, ADC - HashMap> TimeMap = params.get_TimeMap(); - - Vector PadN = params.get_PadN(); // used to read only cell with signal, one entry for each hit - //Vector PadNum = params.get_PadNum();// used to read only cell with signal, one entry for each cell - Vector PadNum = new Vector(); - Vector ADC = new Vector(); - - Vector Pad = params.get_Pad(); - //Vector ADC = params.get_ADC(); - Vector Time_o = params.get_Time_o(); - - - - -//______________________________________________________________________________________________ -// __________________________________________ Openings __________________________________________ -//______________________________________________________________________________________________ - - int CellID = 0; - double Time; - double totEdep; - int eventnum = params.get_eventnum(); - eventnum++; - double testsum = 0; - double testcount = 1; - -//______________________________________________________________________________________________ -// __________________________________________ Readings __________________________________________ -//______________________________________________________________________________________________ - -//--Creating the signal on pads with 1 ns steps. - - - // Initializations - R_adc.clear(); // Raw depositions for CellID, adc - PadN.clear(); - PadNum.clear(); - - //Pad->clear(); - //ADC->clear(); // not reliable for now as the fit fails often - //Time_o->clear(); - - //HashMap gmap = new HashMap(); - - for(Hit hit : rawHits){ - - CellID = hit.get_cellID(); - Time = hit.get_Time(); - totEdep = hit.get_EdepTrue(); - - /*try { - - File out = new File("/Users/dpaye001/Desktop/FileOutput/event" + eventnum + "/"); - if(!out.exists()) - {out.mkdirs();} - FileWriter write = new FileWriter("/Users/dpaye001/Desktop/FileOutput/event" + eventnum + "/" + "timetrue.xls",true); - write.write(Time + "\t" + CellID + "\r\n"); - write.close(); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - }*/ - - // searches in PadN if CellID already exists - - if(PadN.contains(CellID)){ // this pad has already seen signal - for(int t=0;t()); - TimeMap.get(CellID).add(Time); - for(int t=0;t= 2.0*PI) - { - phi_pad -= 2.0*PI; - } - if(phi_pad<0) - { - phi_pad += 2.0*PI; - } - - z_pad=z0+(col*PAD_L)+(PAD_L/2.0)+z_shift; - - set_x(PAD_S*Math.cos(phi_pad)); - set_y(PAD_S*Math.sin(phi_pad)); - set_z(z_pad); - set_phi(phi_pad); - } - - private void set_x(double x){ - _x = x; - } - - private void set_y(double y){ - _y = y; - } - - private void set_z(double z){ - _z = z; - } - - private void set_phi(double phi){ - _phi = phi; - } - - public double x(){ - return _x; - } - - public double y(){ - return _y; - } - - public double z(){ - return _z; - } - - public double phi(){ - return _phi; - } -} diff --git a/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/RecoHitVector.java b/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/RecoHitVector.java deleted file mode 100644 index 6837eee147..0000000000 --- a/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/RecoHitVector.java +++ /dev/null @@ -1,94 +0,0 @@ -package org.jlab.rec.rtpc.hit; - -public class RecoHitVector { - - private int pad; - private double x; - private double y; - private double z; - private double dt; - private double time; - - public RecoHitVector() - { - pad = 0; - x = 0; - y = 0; - z = 0; - dt = 0; - time = 0; - } - - public RecoHitVector(int padnum, double xrec, double yrec, double zrec, double tdiff, double t) - { - pad = padnum; - x = xrec; - y = yrec; - z = zrec; - dt = tdiff; - time = t; - } - - public void setpad(int padnum) - { - pad = padnum; - } - - public void setx(double xrec) - { - x = xrec; - } - - public void sety(double yrec) - { - y = yrec; - } - - public void setz(double zrec) - { - z = zrec; - } - - public void settime(double t) - { - time = t; - } - - public void setdt(double tdiff) - { - dt = tdiff; - } - - public int pad() - { - return pad; - } - - public double x() - { - return x; - } - - public double y() - { - return y; - } - - public double z() - { - return z; - } - - public double time() - { - return time; - } - - public double dt() - { - return dt; - } - - - -} diff --git a/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/ReducedTrack.java b/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/ReducedTrack.java deleted file mode 100644 index 08810c5875..0000000000 --- a/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/ReducedTrack.java +++ /dev/null @@ -1,61 +0,0 @@ -package org.jlab.rec.rtpc.hit; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; - -public class ReducedTrack { - - private List _hits = new ArrayList(); - private boolean _flagTrack = false; - - public ReducedTrack() { - //Default Constructor - } - - public void addHit(HitVector v) { - _hits.add(v); - } - - public void sortHits() { - Collections.sort(_hits, new Comparator() { - @Override - public int compare(HitVector v1, HitVector v2) { - return Double.compare(v2.time(),v1.time()); - } - }); - } - - public double getSmallT() { - return _hits.get(_hits.size()-1).time(); - } - - public double getLargeT() { - return _hits.get(0).time(); - } - - public Set getAllPads() { - Set pads = new HashSet(); - for(HitVector v : _hits) { - pads.add(v.pad()); - } - return pads; - } - - public List getAllHits() { - return _hits; - } - - public void flagTrack() { - _flagTrack = true; - } - - public boolean isTrackFlagged() { - return _flagTrack; - } - -} diff --git a/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/ReducedTrackMap.java b/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/ReducedTrackMap.java deleted file mode 100644 index 4ea6a3f7a1..0000000000 --- a/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/ReducedTrackMap.java +++ /dev/null @@ -1,59 +0,0 @@ -package org.jlab.rec.rtpc.hit; - -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.ConcurrentHashMap; -import java.util.HashMap; - -public class ReducedTrackMap { - - private HashMap _map; - private int _trackID = 0; - - public ReducedTrackMap() { - _map = new HashMap(); - } - - public void addTrack(ReducedTrack t) { - _trackID++; - _map.put(_trackID, t); - } - - public ReducedTrack getTrack(int trackID) { - if(!_map.containsKey(trackID)) { - addTrack(new ReducedTrack()); - } - return _map.get(trackID); - } - - public void updateTrack(int trackID, ReducedTrack t) { - _map.put(trackID, t); - } - - public void removeTrack(int trackID) { - _map.remove(trackID); - } - - public List getAllTrackIDs() { - List l = new ArrayList(); - for(int i : _map.keySet()) { - if(!l.contains(i)) { l.add(i);} - } - return l; - } - - public int getLastTrackID() { - return _trackID; - } - - public void mergeTracks(int trackIDparent, int trackID) { - ReducedTrack child = getTrack(trackID); - List l = child.getAllHits(); - ReducedTrack parent = getTrack(trackIDparent); - for(HitVector v : l) { - parent.addHit(v); - } - removeTrack(trackID); - } - -} diff --git a/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/TimeAverage.java b/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/TimeAverage.java deleted file mode 100644 index 85dfb5d15c..0000000000 --- a/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/TimeAverage.java +++ /dev/null @@ -1,389 +0,0 @@ -package org.jlab.rec.rtpc.hit; - -import java.util.Collections; -import java.util.HashMap; -import java.util.Vector; -import java.util.concurrent.ConcurrentHashMap; - -import javax.swing.JFrame; - -import org.jlab.clas.physics.LorentzVector; -import org.jlab.clas.physics.Vector3; -import org.jlab.groot.data.GraphErrors; -import org.jlab.groot.graphics.EmbeddedCanvas; -import org.jlab.groot.math.F1D; - -public class TimeAverage { - - public void TA(HitParameters params, boolean draw) { - - HashMap ADCMap = params.get_R_adc(); - HashMap>> TIDMap = params.get_TIDMap(); - HashMap> trTIDMap = new HashMap>(); - HashMap> FinalTIDMap = new HashMap>(); - Vector PadList = new Vector(); - HashMap> hitlist = new HashMap>(); - int TrigWindSize = params.get_TrigWindSize(); - //int choosetid = 1; - int StepSize = 120; - double thresh = 0; - Vector3 padvec = new Vector3(); - LorentzVector test4vec = new LorentzVector(); - double sumnumer = 0; - double sumdenom = 0; - double maxvalue = 0; - int countadc = 0; - int newtidcounter = 1; - int tidsum = 0; - int min_pads = 3; - double phithresh = 0.6; - double zthresh = 24; - double timethresh = 1500; - - HashMap weightave = new HashMap(); - HashMap weightaveadc = new HashMap(); - - HashMap> gZvsT = new HashMap>(); - HashMap> gPhivsT = new HashMap>(); - - EmbeddedCanvas c = new EmbeddedCanvas(); - c.divide(5, 5); - EmbeddedCanvas c2 = new EmbeddedCanvas(); - c2.divide(5, 5); - int plotcounter = 0; - - JFrame jfr = new JFrame(); - jfr.setSize(1200,1200); - JFrame jfr2 = new JFrame(); - jfr2.setSize(1200,1200); - - - boolean drawellipse = false; - - - F1D ellipse1a = new F1D("ellipse1a","sqrt([b]*[b](1-((x-[h])*(x-[h])/([a]*[a]))))+[k]",2500,4508); - F1D ellipse1b = new F1D("ellipse1b","-sqrt([b]*[b](1-((x-[h])*(x-[h])/([a]*[a]))))+[k]",2500,4508); - F1D ellipse2a = new F1D("ellipse2a","sqrt([b]*[b](1-((x-[h])*(x-[h])/([a]*[a]))))+[k]",2800,4210); - F1D ellipse2b = new F1D("ellipse2b","-sqrt([b]*[b](1-((x-[h])*(x-[h])/([a]*[a]))))+[k]",2800,4210); - ellipse1a.setParameter(0, 50); - ellipse1a.setParameter(1, 3500); - ellipse1a.setParameter(2, 1000); - ellipse1a.setParameter(3, -75); - ellipse1b.setParameter(0, 50); - ellipse1b.setParameter(1, 3500); - ellipse1b.setParameter(2, 1000); - ellipse1b.setParameter(3, -75); - - ellipse2a.setParameter(0, 75); - ellipse2a.setParameter(1, 3500); - ellipse2a.setParameter(2, 1400); - ellipse2a.setParameter(3, -75); - ellipse2b.setParameter(0, 75); - ellipse2b.setParameter(1, 3500); - ellipse2b.setParameter(2, 1400); - ellipse2b.setParameter(3, -75); - - for(int choosetid : TIDMap.keySet()) - { - - for(int time : TIDMap.get(choosetid).keySet()) - { - //System.out.println(time); - for(int pad = 0; pad < TIDMap.get(choosetid).get(time).size(); pad++) - { - if(!PadList.contains(TIDMap.get(choosetid).get(time).get(pad))) - { - PadList.add(TIDMap.get(choosetid).get(time).get(pad)); - } - } - } - - for(int pad = 0; pad < PadList.size(); pad++) - { - for(int time : TIDMap.get(choosetid).keySet()) - { - if(TIDMap.get(choosetid).get(time).contains(PadList.get(pad))) - { - if(ADCMap.get(PadList.get(pad))[time]>maxvalue) - { - maxvalue = ADCMap.get(PadList.get(pad))[time]; - } - } - } - thresh = maxvalue/2; - countadc = 0; - for(int time = 0; time < TrigWindSize; time+=120) - { - if(ADCMap.get(PadList.get(pad))[time] > thresh) - { - sumnumer += ADCMap.get(PadList.get(pad))[time]*time; - sumdenom += ADCMap.get(PadList.get(pad))[time]; - countadc++; - //System.out.println(PadList.get(pad) + " " + time); - } - } - //System.out.println("weightave " + PadList.get(pad) + " " + sumnumer/sumdenom); - weightave.put(PadList.get(pad), sumnumer/sumdenom); - weightaveadc.put(PadList.get(pad), sumdenom); - sumnumer = 0; - sumdenom = 0; - maxvalue = 0; - padvec = PadCoords(PadList.get(pad)); - //gZvsT.addPoint(weightave.get(PadList.get(pad)), padvec.z(), 0, 0); - //gPhivsT.addPoint(weightave.get(PadList.get(pad)), Math.atan2(padvec.y(),padvec.x()),0,0); - } - int pad = 0; - double avetime = 0; - double adc = 0; - trTIDMap.put(choosetid,new Vector()); - for(int p = 0; p < PadList.size(); p++) - { - pad = PadList.get(p); - avetime = weightave.get(pad); - adc = weightaveadc.get(pad); - //LorentzVector v = new LorentzVector(avetime,Math.atan2(PadCoords(pad).y(),PadCoords(pad).x()),PadCoords(pad).z(),pad); - HitVector v = new HitVector(pad,PadCoords(pad).z(),Math.atan2(PadCoords(pad).y(),PadCoords(pad).x()),avetime,adc); - - trTIDMap.get(choosetid).add(v); - } - double smalltime = 0; - for(int i = 0; i < trTIDMap.get(choosetid).size(); i++) - { - smalltime = trTIDMap.get(choosetid).get(i).time(); - for(int j = 0; j < trTIDMap.get(choosetid).size();j++) - { - if(trTIDMap.get(choosetid).get(j).time() < smalltime && i!=j) - { - trTIDMap.get(choosetid).insertElementAt(trTIDMap.get(choosetid).get(i), j); - trTIDMap.get(choosetid).remove(i+1); - break; - } - } - } - int newtid = 150; - - - HitVector padcoords = new HitVector(); - HitVector checkpadcoords = new HitVector(); - - while(trTIDMap.get(choosetid).size()!=0) - { - hitlist.put(choosetid, new Vector()); - hitlist.get(choosetid).add(0); - padcoords = trTIDMap.get(choosetid).get(0); - for(int i = 1; i < trTIDMap.get(choosetid).size(); i++) - { - checkpadcoords = trTIDMap.get(choosetid).get(i); - if(Math.abs(checkpadcoords.time() - padcoords.time()) < timethresh && (Math.abs(checkpadcoords.phi()-padcoords.phi())()); - for(int i = 0; i < hitlist.get(choosetid).size(); i++) - { - trTIDMap.get(newtid).add(trTIDMap.get(choosetid).get(hitlist.get(choosetid).get(i))); - trTIDMap.get(choosetid).set(hitlist.get(choosetid).get(i),new HitVector(0,1e10,0)); - } - for(int i = 0; i < trTIDMap.get(choosetid).size(); i ++) - { - if(trTIDMap.get(choosetid).get(i).time() == 1e10) - { - trTIDMap.get(choosetid).remove(i); - i--; - } - } - hitlist.clear(); - newtid++; - } - trTIDMap.remove(choosetid); - HashMap> mergelist = new HashMap>(); - Vector mergelistvec = new Vector(); - int mergelistindex = 0; - HitVector testvec1 = new HitVector(); - HitVector testvec2 = new HitVector(); - for(int i : trTIDMap.keySet()) - { - mergelist.put(mergelistindex, new Vector()); - for(int f = trTIDMap.get(i).size() - 1; f >= (trTIDMap.get(i).size() - 5) && f > 0; f--) - { - testvec1 = trTIDMap.get(i).get(f); - for(int j : trTIDMap.keySet()) - { - if(i!=j) - { - for(int g = trTIDMap.get(j).size() - 1; g >= (trTIDMap.get(j).size() - 5) && g > 0; g--) - { - //System.out.println(f + " " + g); - testvec2 = trTIDMap.get(j).get(g); - if((Math.abs(testvec1.time() - testvec2.time()) < timethresh) && (Math.abs(testvec1.phi()-testvec2.phi())()); - for(int f = 0; f <= 5; f++) - { - if(f < trTIDMap.get(i).size()) { - testvec1 = trTIDMap.get(i).get(f); - for(int j : trTIDMap.keySet()) - { - if(i!=j) - { - for(int g = trTIDMap.get(j).size() - 1; g >= (trTIDMap.get(j).size() - 5) && g > 0; g--) - { - //System.out.println(f + " " + g); - testvec2 = trTIDMap.get(j).get(g); - if((Math.abs(testvec1.time() - testvec2.time()) < timethresh) && (Math.abs(testvec1.phi()-testvec2.phi())1) - { - TIDtokeep = mergelist.get(i).get(0); - for(int l = 1; l < mergelist.get(i).size(); l++) - { - TIDtomerge = mergelist.get(i).get(l); - trTIDMap.get(TIDtokeep).addAll(trTIDMap.get(TIDtomerge)); - trTIDMap.remove(TIDtomerge); - } - } - } - Vector toremove = new Vector(); - for(int i : trTIDMap.keySet()) - { - if(trTIDMap.get(i).size() < min_pads) - { - toremove.add(i); - } - } - for(int i = 0; i < toremove.size(); i++) - { - trTIDMap.remove(toremove.get(i)); - } - gZvsT.put(choosetid, new HashMap()); - c.cd(plotcounter); - gPhivsT.put(choosetid, new HashMap()); - c2.cd(plotcounter); - for(int i : trTIDMap.keySet()) - { - FinalTIDMap.put(newtidcounter,new Vector()); - gZvsT.get(choosetid).put(i, new GraphErrors()); - gZvsT.get(choosetid).get(i).setTitle("Z vs T"); - gPhivsT.get(choosetid).put(i, new GraphErrors()); - gPhivsT.get(choosetid).get(i).setTitle("Phi vs T"); - for(int j = 0; j < trTIDMap.get(i).size(); j++) - { - gZvsT.get(choosetid).get(i).addPoint(trTIDMap.get(i).get(j).time(), trTIDMap.get(i).get(j).z(), 0, 0); - gPhivsT.get(choosetid).get(i).addPoint(trTIDMap.get(i).get(j).time(), trTIDMap.get(i).get(j).phi(), 0, 0); - FinalTIDMap.get(newtidcounter).add(trTIDMap.get(i).get(j)); - } - gZvsT.get(choosetid).get(i).setMarkerSize(2); - gZvsT.get(choosetid).get(i).setMarkerColor(i-149); - gPhivsT.get(choosetid).get(i).setMarkerSize(2); - gPhivsT.get(choosetid).get(i).setMarkerColor(i-149); - c.draw(gZvsT.get(choosetid).get(i),"same"); - c2.draw(gPhivsT.get(choosetid).get(i),"same"); - newtidcounter++; - } - tidsum+= trTIDMap.size(); - PadList.clear(); - weightave.clear(); - trTIDMap.clear(); - hitlist.clear(); - mergelist.clear(); - plotcounter++; - } - //System.out.println(plotcounter); - //System.out.println("tidsum " + tidsum + "final map size " + FinalTIDMap.size()); - /* - for(int i : gZvsT.keySet()) - { - c.cd(plotcounter); - for(int j : gZvsT.get(i).keySet()) - { - c.draw(gZvsT.get(i).get(j),"same"); - } - plotcounter++; - }*/ - if(draw) { - jfr.add(c); - jfr.setTitle("Time Averaged ZvsT"); - jfr.setVisible(true); - jfr2.add(c2); - jfr2.setTitle("Time Averaged PhivsT"); - jfr2.setVisible(true); - } - params.set_FinalTimeMap(FinalTIDMap); - } - - private Vector3 PadCoords(int cellID) { - - double PAD_W = 2.79; // in mm - double PAD_S = 80.0; //in mm - double PAD_L = 4.0; // in mm - double RTPC_L= 384.0; // in mm - double phi_pad = 0; - //double Num_of_Rows = (2.0*(Math.PI)*PAD_S)/PAD_W; - double Num_of_Cols = RTPC_L/PAD_L; - double PI=Math.PI; - double z0 = -(RTPC_L/2.0); - double phi_per_pad = PAD_W/PAD_S; // in rad - double chan = (double)cellID; - double col = chan%Num_of_Cols; - double row=(chan-col)/Num_of_Cols; - double z_shift = row%4; - - phi_pad=(row*phi_per_pad)+(phi_per_pad/2.0); - - if(phi_pad>= 2.0*PI) - { - phi_pad -= 2.0*PI; - } - if(phi_pad<0) - { - phi_pad += 2.0*PI; - } - - double z_pad=z0+(col*PAD_L)+(PAD_L/2.0)+z_shift; - - Vector3 PadCoords = new Vector3(PAD_S*Math.cos(phi_pad),PAD_S*Math.sin(phi_pad),z_pad); - return PadCoords; - - } - - -} diff --git a/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/TimeAverage2.java b/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/TimeAverage2.java deleted file mode 100644 index 90b806119f..0000000000 --- a/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/TimeAverage2.java +++ /dev/null @@ -1,159 +0,0 @@ -//Author: David Payette - -/* This code takes the tracks from the Track Finder, and reduces the signals in the track to single - * values in time by taking a weighted average of the signal using the ADC value as the weight - * The end result is the same tracks but with hits which now have non-discritized times (not in - * 120 ns slices) This is useful for the disentangler to split merged tracks - */ - -package org.jlab.rec.rtpc.hit; - -import java.util.HashMap; -import java.util.concurrent.ConcurrentHashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import javax.swing.JFrame; - -import org.jlab.groot.data.GraphErrors; -import org.jlab.groot.graphics.EmbeddedCanvas; - -public class TimeAverage2 { - - public TimeAverage2(HitParameters params, boolean draw) { - /* - *Initializations - */ - - ReducedTrackMap RTIDMap = new ReducedTrackMap(); - ReducedTrack rtrack; - TrackMap TIDMap = params.get_trackmap(); - HashMap ADCMap = params.get_R_adc(); - List tids = TIDMap.getAllTrackIDs(); - Track track; - double adc = 0; - double adcmax = 0; - double averagetime = 0; - double adcthresh = 0; - double sumnum = 0; - double sumden = 0; - - /* - * Main Algorithm - */ - - for(int tid : tids) { - track = TIDMap.getTrack(tid); - boolean trackflag = track.isTrackFlagged(); - rtrack = new ReducedTrack(); - if(trackflag) {rtrack.flagTrack();} - Set l = track.uniquePadList(); - Set timesbypad = new HashSet(); - for(int pad : l) { - adcmax = 0; - sumnum = 0; - sumden = 0; - timesbypad = track.PadTimeList(pad); - for(int time : timesbypad) { //Loop to calculate maximum adc value - adc = ADCMap.get(pad)[time]; - if(adc > adcmax) { - adcmax = adc; - } - } - adcthresh = adcmax/2; - for(int time : timesbypad) { //Loop to calculate weighted average time using ADC values which are above half of the maximum - adc = ADCMap.get(pad)[time]; - if(adc > adcthresh) { - sumnum += adc*time; - sumden += adc; - } - } - averagetime = sumnum/sumden; - PadVector p = params.get_padvector(pad); - HitVector v = new HitVector(pad,p.z(),p.phi(),averagetime,sumden); - rtrack.addHit(v); - } - RTIDMap.addTrack(rtrack); - } - - /* - * Output - */ - - params.set_rtrackmap(RTIDMap); - - /* - * Drawing for debugging - */ - - if(draw) { - - HashMap gmapzvsphi = new HashMap(); - EmbeddedCanvas cZvsPhi = new EmbeddedCanvas(); - JFrame jZvsPhi = new JFrame(); - jZvsPhi.setSize(800,800); - - HashMap gmapphivst = new HashMap(); - EmbeddedCanvas cPhivsT = new EmbeddedCanvas(); - JFrame jPhivsT = new JFrame(); - jPhivsT.setSize(800,800); - - HashMap gmapzvst = new HashMap(); - EmbeddedCanvas cZvsT = new EmbeddedCanvas(); - JFrame jZvsT = new JFrame(); - jZvsT.setSize(800,800); - int color = 1; - int style = 1; - for(int tid : RTIDMap.getAllTrackIDs()) { - ReducedTrack t = RTIDMap.getTrack(tid); - gmapzvsphi.put(tid, new GraphErrors()); - gmapphivst.put(tid, new GraphErrors()); - gmapzvst.put(tid, new GraphErrors()); - for(HitVector v : t.getAllHits()) { - double time = v.time(); - gmapzvsphi.get(tid).addPoint(v.phi(), v.z(), 0, 0); - gmapzvst.get(tid).addPoint(time, v.z(), 0, 0); - gmapphivst.get(tid).addPoint(time, v.phi(), 0, 0); - } - gmapzvsphi.get(tid).setMarkerColor(color); - gmapzvsphi.get(tid).setMarkerSize(3); - gmapzvsphi.get(tid).setMarkerStyle(style); - - gmapzvst.get(tid).setMarkerColor(color); - gmapzvst.get(tid).setMarkerSize(3); - gmapzvst.get(tid).setMarkerStyle(style); - - gmapphivst.get(tid).setMarkerColor(color); - gmapphivst.get(tid).setMarkerSize(3); - gmapphivst.get(tid).setMarkerStyle(style); - - cZvsPhi.draw(gmapzvsphi.get(tid),"same"); - cZvsT.draw(gmapzvst.get(tid),"same"); - cPhivsT.draw(gmapphivst.get(tid),"same"); - - color++; - if(color > 8) { - color = 1; - style++; - } - - } - - jZvsPhi.setTitle("Time Average Output"); - jZvsPhi.add(cZvsPhi); - jZvsPhi.setVisible(true); - - jZvsT.setTitle("Time Average Output"); - jZvsT.add(cZvsT); - //jZvsT.setVisible(true); - - jPhivsT.setTitle("Time Average Output"); - jPhivsT.add(cPhivsT); - //jPhivsT.setVisible(true); - - } - - } - -} diff --git a/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/Track.java b/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/Track.java deleted file mode 100644 index 2e0b62c631..0000000000 --- a/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/Track.java +++ /dev/null @@ -1,117 +0,0 @@ -package org.jlab.rec.rtpc.hit; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; -import java.util.HashMap; - -public class Track { - - private HashMap> _track = new HashMap>(84,1.0f); - private List _l = new ArrayList(); - //private int _padcount; - private boolean _flagTrack = false; - - public Track() { - //default constructor - } - public Track(int time, int padnum) { - if(!_track.containsKey(time)) { - addTimeSlice(time); - } - addPad(time,padnum); - } - - public void addTimeSlice(int time) { - _track.put(time, new ArrayList()); - } - - public void addTimeSlice(int time, List l) { - List templ = getTimeSlice(time); - for(int i : l) { - if(!templ.contains(i)) { - templ.add(i); - } - } - } - - public void addPad(int time, int padnum) { - _track.get(time).add(padnum); - } - - public List getTimeSlice(int time) { - if(!_track.containsKey(time)) { - addTimeSlice(time); - } - return _track.get(time); - } - - public List getAllTimeSlices(){ - List l = new ArrayList(); - for(int i : _track.keySet()) { - l.add(i); - } - return l; - } - - public boolean padExists(int time, int padnum) { - _l = getTimeSlice(time); - return _l.contains(padnum); - } - - public int padCountbyTime(int time) { - _l = getTimeSlice(time); - return _l.size(); - } - - public int padCountTotal() { - int _padcount = 0; - for(int time : _track.keySet()) { - _padcount += padCountbyTime(time); - } - return _padcount; - } - - public void flagTrack() { - _flagTrack = true; - } - - public boolean isTrackFlagged() { - return _flagTrack; - } - - public Set uniquePadList() { - List slice = new ArrayList(); - Set pads = new HashSet(); - for(int time : _track.keySet()) { - slice = getTimeSlice(time); - for(int pad : slice) { - - pads.add(pad); - - } - } - return pads; - } - - public Set PadTimeList(int pad) { - Set times = new HashSet(); - List allslices = getAllTimeSlices(); - List t = new ArrayList(); - for(int slice : allslices) { - t = getTimeSlice(slice); - if(t.contains(pad)) { - times.add(slice); - } - } - return times; - } - - public int uniquePadCountTotal() { - - return uniquePadList().size(); - - } - -} diff --git a/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/TrackFinder2.java b/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/TrackFinder2.java deleted file mode 100644 index fdfe402efb..0000000000 --- a/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/TrackFinder2.java +++ /dev/null @@ -1,994 +0,0 @@ -package org.jlab.rec.rtpc.hit; - -import java.awt.Component; -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.concurrent.ConcurrentHashMap; -import java.util.List; -import java.util.Vector; -import javax.swing.JFrame; -import org.jlab.groot.data.*; -import org.jlab.groot.fitter.*; -import org.jlab.groot.graphics.*; -import org.jlab.groot.math.F1D; -import org.jlab.groot.ui.TCanvas; -//import org.jlab.clas.physics.Vector3; - - - -public class TrackFinder2 { - - /*************************************** - * Author: David Payette - * - * The function FindTrack2 is divided into 3 main parts, the sorting algorithm, the merging algorithm, - * and plotting. The sorting algorithm builds a map call TIDMap. It starts empty and will be filled with - * track IDs (TIDs), each one returning a map of time slices (120 ns) that each contain a vector of pads which were sorted - * together in this time slice. So TIDMap.get(1).get(120).get(3) will give you the fourth pad at 120 ns that has TID 1. - * The sorting algorithm contains a series of nested loops as follows: The TIMELOOP loops through values of time starting - * at 0 and moving in steps of 120 ns up to the TrigWindSize (10000 ns). Then there is a PADLOOP which loops through all - * the pads which saw a signal in the simulation. The signal shape is created in PadHit for now since GEMC does not do signal - * simulation for our purposes yet. This signal is then integrated into 120 ns bins which is based on the Dream chip timing. - * For each pad in the loop, it checks for the ADC value at the current time, - * and if it passes an ADC threshold, then it moves on to be sorted. The TIDLOOP loops through all elements of a vector TIDVec, - * which initially only contains TID 1 and will add TIDs as necessary. If the TIDMap does not contain the current TID in the - * vector then it adds it to the map. Otherwise, the current pad in the loop is checked against all other pads assigned to - * the current TID by comparing the distance between the pads to a preset ellipse formula. This check is done for the current - * time slice, and a set number (timeadj) of previous time slices. If a pad is close enough to another pad with an assigned - * TID then it is also assigned this TID. A pad is allowed to be assigned multiple TIDs at this stage, which will flag the - * merging algorithm to remember to merge these TIDs later after the sort. If a pad makes it to the end of the TIDLOOP and still - * has not been sorted then it will be assigned a new TID as the new TID is added to the map. The merging algorithm looks - * for TIDs which were flagged to be merged during sort and combines them all into the lowest numbered TID and then the - * other TIDs are removed from the map. - * - * TIMELOOP: 0->10000 in 120 ns steps - * { - * PADLOOP: All pads which have an ADC value that passes threshold for current time - * { - * TIDLOOP: Loop through TIDs in TIDVec - * if(TID is in map){ Compare pad to other pads (PADINDEXLOOP) in current and previous times (PREVTIMELOOP) and see - * if it is near enough (using ellipse formula) } - * else{ If pad has not been assigned at least one TID, assign it a new one and add it to the map } - * - * if(pad has more than one TID){ group the TIDs into MapCombine, using the smallest one as the key } - * } - * } - * - * Loop over the keys of MapCombine, and take all the TIDs assigned to each key and merge them into the key TID and - * remove them from the TIDMap. - * - * Plot a bunch of stuff for testing. - * - * The ellipse formula looks like this: - * - * (dx^2 + dy^2)/phi_0^2 + (dz^2)/z_0^2 <= adjthresh^2 - * - * dx, dy, and dz are the distances between two pads, phi_0 and z_0 are set parameters that define the ellipse, - * and adjthresh is the maximum level of adjacency we allow. This determines how many rings of adjacent pads are - * close enough. - ****************************************/ - - public void FindTrack2(HitParameters params, boolean draw){ - /*************************************** - * - * INITIALIZE VARIABLES - * - ****************************************/ - //HashMap> TIDMap = new HashMap>(); - //HashMap PadThresh = new HashMap(); - //HashMap>> FixedTIDMap = new HashMap>>(); - //double PadPhistore = 0; - //double PadZstore = 0; - //boolean PadPhiChanged = false; - //Necessary pad variables - //double PAD_W = 2.79; //in mm - //double PAD_S = 80.0; //in mm - //double Num_of_Rows = (2.0*(Math.PI)*PAD_S)/PAD_W; - //int padindexmax = 0; Not being used currently - //double time1 = System.currentTimeMillis(); - /* Not being used currently - * int maxconcpads = 0; - * int concpads = 0; - * int maxconctime = 0; - */ - - - - HashMap ADCMap = params.get_R_adc(); //Key - Cell ID, Value - Array of signal height over time slices - - /** - * TIDMap contains a HashMap of Vectors - * The key is Track ID (TID), which returns a map - * The key of the returned map is Time, which returns a vector - * The elements of the vector are pads - * This stores all pads in each time slice, and all time slices for each TID - * Example :: Track ID 1, Time 120 contains pads: 3,4,5,7 so using the call - * TIDMap.get(1).get(120).get(3) will give you pad 5 - */ - HashMap>> TIDMap = new HashMap>>(); - - /** - * strkTIDMap uses the same structure as TIDMap but is used at the end to isolate - * TIDs which only contain single tracks. This map is all TIDs not sent to the disentangler - */ - HashMap>> strkTIDMap = new HashMap>>(); - - - Vector PadNum = params.get_PadNum(); //Contains pads used in PadHit - Vector TIDVec = new Vector<>(); //Contains all TIDs and is added to throughout, - TIDVec.add(1); //Starts with TID 1 - - - int Pad = 0; //initializing pad - double ADC = 0; //initializing ADC - int TrigWindSize = params.get_TrigWindSize(); //Trigger Window Size = 10000 - //int StepSize = params.get_StepSize(); - int StepSize = 120; //Time stepsize in ns - double adcthresh = 5e-4; //Arbitrary ADC threshold - - int min_pads = 0; //Minimum number of pads required to keep as a track - - //These vectors will contain x,y,z for each pad being checked - //Vector3 TempPadCoords = new Vector3(); - //Vector3 CheckPadCoords = new Vector3(); - //Vector3 CheckPadPrevCoords = new Vector3(); - - PadVector TempPadCoords;// = new PadVector(); - PadVector CheckPadCoords; - PadVector CheckPadPrevCoords; - - int TID = 0; //initialize TID - - //used for plotting - double plotphi = 0; - double plotz = 0; - - int timeadj = 2; //How many previous time slices to check in algorithm - int event = params.get_eventnum(); //event number only used for file number - - - //Initialize Ellipse Variables used for adjacency checks - double adjthresh = 12; //sqrt(right hand side of ellipse formula) - double EllipseDeltax = 0; //dx - double EllipseDeltay = 0; //dy - double EllipseDeltaz = 0; //dz - double EllipseTotal = 0; //left hand side of ellipse formula - double PhiDelta = 16; //phi_0 - double ZDelta = 36; //z_0 - - double phithresh = 0.15; - double zthresh = 10; - - //set variables for timing cut (currently time cut is not used, cuts on time happen later) - int tmin = 0; //min timing in ns - int trange = 20000; //added to min to calculate max in ns - int tmax = tmin+trange; - - //Maps and variables used for combining TIDs later in the merge algorithm - boolean PadSorted = false; - Vector PadTIDcollect = new Vector(); - Vector TIDcombine = new Vector(); - HashMap> MapCombine = new HashMap>(); - int mapkey = 0; - - //Map of graphs of ADC vs Time - HashMap gADCvsT = new HashMap(); - - //g.setTitleX("Phi"); - //g.setTitleY("Z"); - //g.setMarkerSize(5); - - try { - File f = new File("/Users/davidpayette/Documents/FileOutput/Output" + event + ".txt"); - f.delete(); - FileWriter write2 = new FileWriter("/Users/davidpayette/Documents/FileOutput/Output" + event + ".txt",true); - //File f2 = new File("/Users/davidpayette/Documents/FileOutput/Master.txt"); - FileWriter write3 = new FileWriter("/Users/davidpayette/Documents/FileOutput/Master.txt",true); - //Collections.sort(PadNum); - //H1F t2 = new H1F("t2","t2",TrigWindSize/StepSize,0,TrigWindSize); - - GraphErrors t1 = new GraphErrors(); - int counter = 0; - HashMap countermap = new HashMap(); - - /*************************************** - * - * SORTING ALGORITHM - * - ****************************************/ - /**loop over all times in 120 ns slices**/ - TIMELOOP: //these labels are not used for the most part, but help to label the loops - for(int t = 0; t < TrigWindSize; t += StepSize) - { - //System.out.println("Time is " + t); - //concpads = 0; - - /**loop over all pads for each time slice**/ - int padloopsize = PadNum.size(); - PADLOOP: - for(int p = 0; p < padloopsize; p++) - { - - PadSorted = false; - PadTIDcollect.clear(); - Pad = PadNum.get(p); - - //System.out.println(PadNum.size() + " size"); - //System.out.println(Pad + " " + t); - - ADC = ADCMap.get(Pad)[t]; - - /**only pads which have an ADC value above threshold will be assigned a TID**/ - if(ADC > adcthresh) - { - //write3.write(ADC + "\n"); - /**This is used for testing something else**/ - if(Pad == 11091) - { - t1.addPoint(t, ADCMap.get(Pad)[t], 0, 0); - //t2.fill(t); - } - if(!countermap.containsKey(Pad)) - { - countermap.put(Pad, 1); - } - else - { - counter = countermap.get(Pad); - counter++; - countermap.put(Pad,counter); - } - - //Plots ADC vs T for each Pad - if(!gADCvsT.containsKey(Pad)) - { - gADCvsT.put(Pad, new GraphErrors()); - gADCvsT.get(Pad).addPoint(t, ADCMap.get(Pad)[t], 0, 0); - } - else - { - gADCvsT.get(Pad).addPoint(t, ADCMap.get(Pad)[t], 0, 0); - } - /*******************************************/ - //System.out.println("Pad to be checked " + Pad + " checked at time " + t); - - //returns x,y,z of the current Pad - //Vector3 PadCoords = PadCoords(Pad); - PadVector PadCoords = params.get_padvector(Pad); - - //System.out.println("Pad " + Pad + " has row and column values " + PadPhi + " " + PadZ); - //g.addPoint(PadPhi, PadZ, 0, 0); - - /**loop through all TID's in a vector which will grow to include all future TID's**/ - int tidloopsize = TIDVec.size(); - TIDLOOP: - for(int i = 0; i < tidloopsize; i++) - { - TID = TIDVec.get(i); //returns current TID to sort into - //System.out.println("Current TID " + TID); - - /**if TID is already in the map**/ - if(TIDMap.containsKey(TID)) - { - //System.out.println("TID " + TID + " is already in the map"); - - /**loop through all pads in TIDMap and compare there row and column to current Pad**/ - PADINDEXLOOP: - for(int padindex = 0; padindex < 100; padindex++) //TODO 100 is unnecessary placeholder - { - //System.out.println("Pad index is " + padindex); - if(padindex < TIDMap.get(TID).get(t).size()) - { - //CheckPadCoords = PadCoords(TIDMap.get(TID).get(t).get(padindex)); //Get the x,y,z of the pad we are checking against - CheckPadCoords = params.get_padvector(TIDMap.get(TID).get(t).get(padindex)); - //System.out.println("At TID " + TID + " time " + t + " padindex " + padindex + " the check pad's location is " + checkpadphi + " " + checkpadz); - //System.out.println("Current time " + checkpadphi + " " + PadPhi + " " + checkpadz + " " + PadZ + " " + Math.abs(checkpadphi-PadPhi) + " " + Math.abs(checkpadz - PadZ)); - //System.out.println("Current time slice " + PadPhi + " " + PadZ + " " + " " + checkpadphi + " " + checkpadz); - //System.out.println("The comparison values for the pad to be sorted at current time are " + Math.abs(checkpadphi-PadPhi) + " " + Math.abs(checkpadz - PadZ)); - - /**Check current time slice for adjacency**/ - /**Calculates the ellipse parameters**/ - EllipseDeltax = Math.abs(PadCoords.x()-CheckPadCoords.x())*Math.abs(PadCoords.x()-CheckPadCoords.x()); - EllipseDeltay = Math.abs(PadCoords.y()-CheckPadCoords.y())*Math.abs(PadCoords.y()-CheckPadCoords.y()); - EllipseDeltaz = Math.abs(PadCoords.z()-CheckPadCoords.z())*Math.abs(PadCoords.z()-CheckPadCoords.z()); - EllipseTotal = ((EllipseDeltax+EllipseDeltay)/PhiDelta) + (EllipseDeltaz/ZDelta); - //System.out.println("Ellipse is " + EllipseTotal); - - /** - * If the ellipse equation falls within the accepted size assign the - * TID of the checked pad to the current pad in the loop - **/ - //if(EllipseTotal <= adjthresh) - if((Math.abs(CheckPadCoords.phi()-PadCoords.phi())0) - { - /**Loops through a variable number (timeadj) of previous time slices to see if it is adjacent to earlier pads**/ - PREVTIMELOOP: - for(int prevtime = t - StepSize; (prevtime >= (t - (timeadj*StepSize))) && (prevtime >= 0); prevtime -= StepSize) - { - if(padindex < TIDMap.get(TID).get(prevtime).size()) - { - //CheckPadPrevCoords = PadCoords(TIDMap.get(TID).get(prevtime).get(padindex)); //Get the x,y,z of the pad we are checking against - CheckPadPrevCoords = params.get_padvector(TIDMap.get(TID).get(prevtime).get(padindex)); - /**Calculates the ellipse parameters**/ - EllipseDeltax = Math.abs(PadCoords.x()-CheckPadPrevCoords.x())*Math.abs(PadCoords.x()-CheckPadPrevCoords.x()); - EllipseDeltay = Math.abs(PadCoords.y()-CheckPadPrevCoords.y())*Math.abs(PadCoords.y()-CheckPadPrevCoords.y()); - EllipseDeltaz = Math.abs(PadCoords.z()-CheckPadPrevCoords.z())*Math.abs(PadCoords.z()-CheckPadPrevCoords.z()); - EllipseTotal = ((EllipseDeltax+EllipseDeltay)/PhiDelta) + (EllipseDeltaz/ZDelta); - //System.out.println("Ellipse is " + EllipseTotal); - - //System.out.println("Previous time slice " + PadPhi + " " + PadZ + " " + " " + checkpadphiprev + " " + checkpadzprev); - //System.out.println("The comparison values for the pad to be sorted at previous time are " + Math.abs(checkpadphiprev-PadPhi) + " " + Math.abs(checkpadzprev - PadZ)); - /** - * If the ellipse equation falls within the accepted size assign the - * TID of the checked pad to the current pad in the loop - **/ - //if(EllipseTotal <= adjthresh) - if((Math.abs(CheckPadPrevCoords.phi()-PadCoords.phi())< phithresh || (Math.abs(CheckPadPrevCoords.phi()-PadCoords.phi()-2*Math.PI) < phithresh )) && Math.abs(CheckPadPrevCoords.z()-PadCoords.z())>()); - for(int time = 0; time < TrigWindSize; time += StepSize) - { - TIDMap.get(TID).put(time, new Vector<>()); //add TID to map - } - TIDMap.get(TID).get(t).add(Pad); - //PadTIDcollect.add(TID); - TIDVec.add(TID+1); //add TID to the list - } - break TIDLOOP; //makes sure the TID loop doesn't go forever since we are adding a new TID to the list - } - } // End TIDLOOP // - - /** Pad has more than one TID in this time slice **/ - if(PadTIDcollect.size()>1) - { - - //System.out.println("PadTIDcollect is " + PadTIDcollect.size()); - /*for(int i : MapCombine.keySet()) - { - if(MapCombine.get(i).size()>0) - { - for(int jZvsPhi = 0; jZvsPhi()); - } - //System.out.println("TID to merge " + mapkey); - - /**Loops through remaining TIDs to be merged and puts them into a map together**/ - for(int i = 1; i < PadTIDcollect.size(); i++) - { - /*if(!TIDcombine.contains(PadTIDcollect.get(i))) - { - MapCombine.get(mapkey).add(PadTIDcollect.get(i)); - //TIDcombine.add(PadTIDcollect.get(i)); - }*/ - if(!MapCombine.get(mapkey).contains(PadTIDcollect.get(i))) - { - MapCombine.get(mapkey).add(PadTIDcollect.get(i)); - } - //System.out.println("TID to merge " + PadTIDcollect.get(i)); - } - //TIDcombine.clear(); - } - } - //else {System.out.println("Pad " + Pad + " failed ADC threshold at time " + t);} - } // End PADLOOP // - - } // End TIMELOOP // - System.out.println("This event has " + TIDMap.size() + " tracks"); - EmbeddedCanvas chist = new EmbeddedCanvas(); - JFrame jhist = new JFrame(); - jhist.setSize(800, 600); - if(draw == true) - { - chist.draw(t1); - jhist.add(chist); - jhist.setVisible(true); - jhist.setTitle("histo"); - } - - - /*************************************** - * - * MERGE ALGORITHM - * - ****************************************/ - - //Merge Tracks - - int TIDtomerge = 0; //TID we are putting into the TIDtokeep - int TIDtokeep = 0; - //Vector TIDtoremove = new Vector(); - //for(int i : TIDMap.keySet()) {System.out.println("all TIDs before " + i );} - - /** - * For each TID that needs other TIDs to be merged into it - * we get each TID from the Map assigned to the TIDtokeep key and merge the TIDs together - * then remove the other TIDs (TIDtomerge) from the map - */ - for(int j : MapCombine.keySet()) - { - if(MapCombine.get(j).size() == 0) {break;} - TIDtokeep = j; - for(int i = 0; i < MapCombine.get(j).size(); i++) - { - TIDtomerge = MapCombine.get(j).get(i); - //TIDtoremove.add(TIDtomerge); - for(int time = 0 ; time < TrigWindSize; time+=StepSize) - { - if(TIDMap.containsKey(TIDtomerge) && TIDMap.containsKey(TIDtokeep)) - { - if(TIDMap.get(TIDtomerge).get(time).size()>0) - { - for(int padindex = 0; padindex < TIDMap.get(TIDtomerge).get(time).size(); padindex++) - { - TIDMap.get(TIDtokeep).get(time).add(TIDMap.get(TIDtomerge).get(time).get(padindex)); - } - } - } - } - TIDMap.remove(TIDtomerge); - } - //System.out.println(MapCombine.get(jZvsPhi).size()); - } - - //for(int i = 0; i < TIDtoremove.size(); i++) {TIDMap.remove(TIDtoremove.get(i));} - //for(int i : TIDMap.keySet()) {System.out.println("all TIDs after " + i );} - - /*************************************** - * - * PLOTS - * - ****************************************/ - //TESTING STUFF - int countermax = 0; - int padmax = 0; - int howmanyhits = 0; - for(int i : countermap.keySet()) - { - howmanyhits += countermap.get(i); - if(countermap.get(i)>countermax) - { - countermax = countermap.get(i); - padmax = i; - //System.out.println("countermax " + i + " " + countermax); - } - } - System.out.println("this many hits " + howmanyhits + " this many pads " + countermap.size()); - - - HashMap gZvsPhi = new HashMap(); - //HashMap graphmap2 = new HashMap(); - //EmbeddedCanvas tcan = new EmbeddedCanvas(); - //TCanvas tcan = new TCanvas("t", 800, 600); - for(int testTID : TIDMap.keySet()) - { - for(int time = 0; time < TrigWindSize; time+=StepSize) - { - for(int pad = 0; pad < TIDMap.get(testTID).get(time).size(); pad++) - { - //TempPadCoords = PadCoords(TIDMap.get(testTID).get(time).get(pad)); //gets x,y,z - TempPadCoords = params.get_padvector(TIDMap.get(testTID).get(time).get(pad)); - //plotphi = Math.atan2(TempPadCoords.y(),TempPadCoords.x()); //Phi - plotphi = TempPadCoords.phi(); - plotz = TempPadCoords.z(); //Z - //System.out.println(plotphi + " " + plotz); - - if(!gZvsPhi.containsKey(testTID)) - { - gZvsPhi.put(testTID, new GraphErrors()); - } - - gZvsPhi.get(testTID).addPoint(plotphi, plotz, 0, 0); //Plots Phi, Z for each track - - - //write2.write(testTID + "\t" + time + "\t" + plotphi + "\t" + plotz + "\n"); - } - - - /*if(TIDMap.get(testTID).get(a1).size()>0) - { - gZvsPhi.get(testTID).addPoint(0, 0, 0, 0); - gZvsPhi.get(testTID).addPoint(6.5, 20, 0, 0); - //tcan.draw(gZvsPhi.get(testTID)); - //tcan.save("/Users/davidpayette/Desktop/Plots/" + a1 + ".jpg"); - //tcan.repaint(); - graphmap2.put(a1, new TCanvas(" ",800,600)); - graphmap2.get(a1).draw(gZvsPhi.get(testTID)); - graphmap2.get(a1).save("/Users/davidpayette/Desktop/Plots/" + a1 + ".jpg"); - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - }*/ - - } - } - - //F1D fitfunc1 = new F1D("f","[0]*x+[1]",0,9000); - //F1D fitfunc1 = new F1D("p1"); - //fitfunc1.setParameter(0, 1); - //fitfunc1.setParameter(1,0); - - //Vector3 vZvsT = new Vector3(); - GraphErrors gZvsT = new GraphErrors(); - EmbeddedCanvas cZvsT = new EmbeddedCanvas(); - Vector PadTracker = new Vector(); - JFrame jZvsT = new JFrame(); - jZvsT.setSize(800,600); - - /*int choosetid = 0; - for(int t : TIDMap.get(choosetid).keySet()) - { - //System.out.println(t); - for(int p = 0; p cADCvsT = new HashMap(); - GraphErrors gHitsvsPad = new GraphErrors(); - EmbeddedCanvas cHitsvsPad = new EmbeddedCanvas(); - JFrame jHitsvsPad = new JFrame(); - int mod25 = (PadTracker.size() - (PadTracker.size() % 25))/25; - //System.out.println(mod25); - for(int k = 0; k <= mod25; k++) - { - cADCvsT.put(k, new EmbeddedCanvas()); - cADCvsT.get(k).divide(5, 5); - } - - //System.out.println("size of PadTracker " + PadTracker.size()); - int numplots = 0; - int whichplot = 0; - for(int h = 0; h < PadTracker.size(); h++) - { - gHitsvsPad.addPoint(PadTracker.get(h), countermap.get(PadTracker.get(h)), 0, 0); - cADCvsT.get(whichplot).cd(numplots); - gADCvsT.get(PadTracker.get(h)).setTitle(""+PadTracker.get(h)); - gADCvsT.get(PadTracker.get(h)).addPoint(0, 0, 0, 0); - gADCvsT.get(PadTracker.get(h)).addPoint(9000, 0, 0, 0); - gADCvsT.get(PadTracker.get(h)).setMarkerSize(2); - cADCvsT.get(whichplot).draw(gADCvsT.get(PadTracker.get(h))); - if(h % 25 == 0 && h > 0) - { - whichplot++; - numplots=0; - } - else - { - numplots++; - } - } - if(draw == true) - { - gHitsvsPad.setMarkerSize(2); - cHitsvsPad.draw(gHitsvsPad); - jHitsvsPad.add(cHitsvsPad); - jHitsvsPad.setTitle("jHitsvsPad"); - jHitsvsPad.setSize(800, 600); - jHitsvsPad.setVisible(true); - HashMap jADCvsT = new HashMap(); - for(int k : cADCvsT.keySet()) - { - jADCvsT.put(k, new JFrame()); - jADCvsT.get(k).setSize(1200,800); - jADCvsT.get(k).setTitle("jADCvsT" + " " + k); - jADCvsT.get(k).add(cADCvsT.get(k)); - jADCvsT.get(k).setVisible(true); - } - //DataFitter.fit(fitfunc1, gZvsT, "QER"); - //System.out.println(fitfunc1.getChiSquare()); - - gZvsT.setMarkerSize(1); - cZvsT.draw(gZvsT); - //cZvsT.draw(fitfunc1,"same"); - jZvsT.add(cZvsT); - jZvsT.setVisible(true); - } - int tlargest = 0; - //System.out.println("before " + TIDMap.size()); - //int loopsize = TIDMap.size(); - Vector toremove = new Vector(); - Vector PadList = new Vector(); - for(int testTID : TIDMap.keySet()) - { - - for(int t = 0; t < TrigWindSize; t += StepSize) - { - for(int pad = 0; pad < TIDMap.get(testTID).get(t).size(); pad++) - { - if(!PadList.contains(TIDMap.get(testTID).get(t).get(pad))) - { - PadList.add(TIDMap.get(testTID).get(t).get(pad)); - } - - if(t > tlargest) - { - tlargest = t; - } - if(t>4000) - { - //System.out.println(pad + " " + t); - } - } - } - //System.out.println(tlargest); - if(tlargest < tmin || tlargest > tmax) - { - toremove.add(testTID); - //TIDMap.remove(testTID); - //gZvsPhi.remove(testTID); - - } - //System.out.println("large T " + tlargest); - tlargest = 0; - if(PadList.size() <= min_pads) - { - if(!toremove.contains(testTID)) - { - toremove.add(testTID); - } - } - PadList.clear(); - } - HashMap> padmap = new HashMap>(); - int padlook = 0; - for(int i = 0; i < toremove.size(); i++) - { - TIDMap.remove(toremove.get(i)); - } - HashMap hZvsT = new HashMap(); - HashMap hPhivsT = new HashMap(); - //Vector3 padv = new Vector3(); - PadVector padv; - double padphi = 0; - double padz = 0; - for(int tid : TIDMap.keySet()) - { - padmap.put(tid, new Vector()); - hPhivsT.put(tid, new H2F("hPhivsT","hPhivsT",80,0,9600,90,-Math.PI,Math.PI)); - hZvsT.put(tid, new H2F("hZvsT","hZvsT",80,0,9600,50,-200,200)); - - for(int time : TIDMap.get(tid).keySet()) - { - for(int p = 0; p < TIDMap.get(tid).get(time).size(); p++) - { - /*padlook = TIDMap.get(tid).get(time).get(p); - if(!padmap.get(tid).contains(padlook)) - { - padmap.get(tid).add(padlook); - }*/ - //padv = PadCoords(TIDMap.get(tid).get(time).get(p)); - padv = params.get_padvector(TIDMap.get(tid).get(time).get(p)); - //padphi = Math.atan2(padv.y(),padv.x()); - padphi = padv.phi(); - padz = padv.z(); - //System.out.println(time + " " + padz); - hZvsT.get(tid).fill((double)time, padz); - hPhivsT.get(tid).fill((double)time, padphi); - } - } - } - int pcount = 0; - toremove.clear(); - double histmaxavez = 0; - double histmaxavephi = 0; - - //System.out.println("HERE " + hZvsT.size()); - EmbeddedCanvas chZvsT = new EmbeddedCanvas(); - EmbeddedCanvas chPhivsT = new EmbeddedCanvas(); - JFrame jhZvsT = new JFrame(); - JFrame jhPhivsT = new JFrame(); - chZvsT.divide(5,5); - chPhivsT.divide(5, 5); - jhZvsT.setSize(1200,1200); - jhPhivsT.setSize(1200,1200); - jhZvsT.setTitle("Z vs T 2d Hist"); - jhPhivsT.setTitle("Phi vs T 2d Hist"); - for(int i : hZvsT.keySet()) - { - histmaxavez+=hZvsT.get(i).getMax(); - histmaxavephi+=hPhivsT.get(i).getMax(); - } - histmaxavez/=hZvsT.size(); - histmaxavephi/=hPhivsT.size(); - for(int i : hZvsT.keySet()) - { - //System.out.println(hZvsT.get(i).getMax() + " " + hPhivsT.get(i).getMax() + " " + histmaxavez + " " + histmaxavephi); - //if(hZvsT.get(i).getMax() < 10 || hPhivsT.get(i).getMax() < 10) - if(hZvsT.get(i).getMax() < histmaxavez*0.75 && hPhivsT.get(i).getMax() < histmaxavephi*0.75) - { - if(!toremove.contains(i)) - { - toremove.add(i); - } - } - chZvsT.cd(pcount); - chPhivsT.cd(pcount); - chZvsT.draw(hZvsT.get(i)); - chPhivsT.draw(hPhivsT.get(i)); - pcount++; - } - jhZvsT.add(chZvsT); - jhPhivsT.add(chPhivsT); - - if(draw) { - jhZvsT.setVisible(true); - jhPhivsT.setVisible(true); - } - //for(int i : TIDMap.keySet()) {System.out.println(i + " before");} - for(int i = 0; i < toremove.size(); i++) - { - //System.out.println(TIDMap.get(toremove.get(i)).size()); - strkTIDMap.put(toremove.get(i), TIDMap.get(toremove.get(i))); - TIDMap.remove(toremove.get(i)); - } - /*for(int i : strkTIDMap.keySet()) - { - for(int j : strkTIDMap.get(i).keySet()) - { - for(int k = 0; k < strkTIDMap.get(i).get(j).size(); k ++) - { - System.out.println(x); - } - } - }*/ - //for(int i : TIDMap.keySet()) {System.out.println(i + " after");} - //for(int i = 0; i < toremove.size()) - /*for(int tid : TIDMap.keySet()) - { - for(int p = 0; p < padmap.get(tid).size(); p++) - { - padv = PadCoords(padmap.get(tid).get(p)); - padphi = Math.atan2(padv.y(),padv.x()); - padz = padv.z(); - for(int time : TIDMap.get(tid).keySet()) - { - if(TIDMap.get(tid).get(time).contains(padmap.get(tid).get(p))) - { - - } - } - } - }*/ - - //System.out.println(tlargest); - int color = 1; - int style = 1; - - //for(int i : TIDMap.keySet()) {System.out.println(i);} - //System.out.println("after " + TIDMap.size()); - //System.out.println(maxconcpads + " " + maxconctime + " " + TIDVec.size()); - if(draw) - { - - EmbeddedCanvas cZvsPhi = new EmbeddedCanvas(); - JFrame jZvsPhi = new JFrame(); - jZvsPhi.setSize(800,600); - for(int i : TIDMap.keySet()) - { - //System.out.println(i); - //if(i == 1) - //{ - gZvsPhi.get(i).setMarkerColor(color); - if(false)//if(i == 1) - { - gZvsPhi.get(i).setMarkerSize(6); - } - else - { - gZvsPhi.get(i).setMarkerSize(2); - } - //gZvsPhi.get(i).addPoint(0, 0, 0, 0); - //gZvsPhi.get(i).addPoint(180, 100, 0, 0); - - //gZvsPhi.get(i).setMarkerStyle(style); - - cZvsPhi.draw(gZvsPhi.get(i),"same"); - //cZvsPhi.save("/Users/davidpayette/Desktop/Plots/g" + i + ".png"); - color++; - style++; - - //} - //System.out.println("key " + i + " " + TIDMap.size()); - } - jZvsPhi.setTitle("Track Finder Output"); - jZvsPhi.add(cZvsPhi); - jZvsPhi.setVisible(true); - - } - write2.close(); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - for(int i : TIDMap.keySet()) - { - //System.out.println("TIDMap TIDs " + i); - } - for(int i : strkTIDMap.keySet()) - { - //System.out.println("strkTIDMap TIDs " + i); - } - params.set_TIDMap(TIDMap); - params.set_strkTIDMap(strkTIDMap); - //TIDMap.clear(); - //System.out.println(System.currentTimeMillis()-time1); - } - - /**Returns x, y, z as a vector, given pad number**/ - /* - private Vector3 PadCoords(int cellID) { - - double PAD_W = 2.79; // in mm - double PAD_S = 80.0; //in mm - double PAD_L = 4.0; // in mm - double RTPC_L= 384.0; // in mm - double phi_pad = 0; - //double Num_of_Rows = (2.0*(Math.PI)*PAD_S)/PAD_W; - double Num_of_Cols = RTPC_L/PAD_L; - double PI=Math.PI; - double z0 = -(RTPC_L/2.0); - double phi_per_pad = PAD_W/PAD_S; // in rad - double chan = (double)cellID; - double col = chan%Num_of_Cols; - double row=(chan-col)/Num_of_Cols; - double z_shift = row%4; - - phi_pad=(row*phi_per_pad)+(phi_per_pad/2.0); - - if(phi_pad>= 2.0*PI) - { - phi_pad -= 2.0*PI; - } - if(phi_pad<0) - { - phi_pad += 2.0*PI; - } - - double z_pad=z0+(col*PAD_L)+(PAD_L/2.0)+z_shift; - - Vector3 PadCoords = new (PAD_S*Math.cos(phi_pad),PAD_S*Math.sin(phi_pad),z_pad); - return PadCoords; - - } - - */ - - - //old functions, maybe used later - /*private double PadPhi(int cellID) { - - double PAD_W = 2.79; // in mm - double PAD_S = 80.0; //in mm - double PAD_L = 4.0; // in mm - double RTPC_L=400.0; // in mm - - double phi_pad = 0; - - double Num_of_Rows = (2.0*(Math.PI)*PAD_S)/PAD_W; - double Num_of_Cols = RTPC_L/PAD_L; - double TotChan = Num_of_Rows*Num_of_Cols; - - double PI=Math.PI; - - - - double phi_per_pad = PAD_W/PAD_S; // in rad - - double chan = (double)cellID; - double col = chan%Num_of_Cols; - double row=(chan-col)/Num_of_Cols; - - - //double z_shift = 0.; - - phi_pad=(row*phi_per_pad)+(phi_per_pad/2.0); - if(phi_pad>= 2.0*PI) { - phi_pad -= 2.0*PI; - } - if(phi_pad<0) - { - phi_pad += 2.0*PI; - } - - return phi_pad; - - } - private double PadZ(int cellID) - { - - double RTPC_L=400.0; // in mm - double PAD_L = 4.0; // in mm - double Num_of_Cols = RTPC_L/PAD_L; - double z0 = -(RTPC_L/2.0); // front of RTPC in mm at the center of the pad - double chan = (double)cellID; - double col = chan%Num_of_Cols; - double row=(chan-col)/Num_of_Cols; - double z_shift = row%4; - double z_pad = 0; - double testnum = (row-z_shift)/4; - - z_pad=z0+(col*PAD_L)+(PAD_L/2.0)+z_shift; - //if(z_shift == 0 && row > 0) {return col-1;} - //else{return col;} - return z_pad;//-testnum; - }*/ - -} diff --git a/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/TrackFinder3.java b/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/TrackFinder3.java deleted file mode 100644 index 3848bdf570..0000000000 --- a/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/TrackFinder3.java +++ /dev/null @@ -1,219 +0,0 @@ -//Author: David Payette - -/* This code sorts pad signals which have been integrated into 120 ns time slices into tracks - * based on their relative positions in space, and how close in time the signals occur - */ - -package org.jlab.rec.rtpc.hit; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.concurrent.ConcurrentHashMap; -import java.util.List; -import java.util.Vector; - -import javax.swing.JFrame; - -import org.jlab.groot.data.GraphErrors; -import org.jlab.groot.graphics.EmbeddedCanvas; - -public class TrackFinder3 { - - public TrackFinder3(HitParameters params, boolean draw) { - /* - *Initializations - */ - TrackUtils tutil = new TrackUtils(); - TrackMap TIDMap = new TrackMap(); - List TIDList; - Track track; - HashMap ADCMap = params.get_R_adc(); - Vector PadNum = params.get_PadNum(); - int TrigWindSize = params.get_TrigWindSize(); - int StepSize = 120; - double adcthresh = 5e-4; - int padloopsize = PadNum.size(); - boolean padSorted = false; - List padTIDlist = new ArrayList(); - List padlist; - int pad = 0; - double adc = 0; - int timeadjlimit = 4; - int parenttid = -1; - String method = "phiz"; - int minhitcount = 5; - - /* - * Main Algorithm - */ - TIMELOOP: //Loop over all times - for(int time = 0; time < TrigWindSize; time += StepSize) { //Steps of 120 up to TrigWindSize = 10000 - - PADLOOP: //Loop over all pads - for(int padindex = 0; padindex < padloopsize; padindex++) { - padSorted = false; //Flag to be set when the pad is assigned to a track - padTIDlist.clear(); //List of all TIDs assigned to the pad starts empty - pad = PadNum.get(padindex); - adc = ADCMap.get(pad)[time]; - - if(adc > adcthresh) { //pad adc threshold check - PadVector PadVec = params.get_padvector(pad); //initializes the x,y,z,phi for pad - TIDList = TIDMap.getAllTrackIDs(); //Retrieve list of all available TIDs - - TIDLOOP: //Loop over all Track IDs - for(int tid : TIDList) { - track = TIDMap.getTrack(tid); //Get track with current tid - - TIMECHECKLOOP: //Loop over current and former times - for(int timecheck = time; timecheck > 0 && timecheck >= time - timeadjlimit*StepSize; timecheck -= StepSize) { - padlist = track.getTimeSlice(timecheck); //Get pads assigned to current time slice - if(!padlist.contains(pad)) { //Ensures pad isn't already assigned here - PADCHECKLOOP: //Loop over pads - for(int checkpad : padlist) { - PadVector checkpadvec = params.get_padvector(checkpad); - if(tutil.comparePads(PadVec, checkpadvec, method)) { //compares the position of two pads - track.addPad(time, pad); //assign pad to track - //TIDMap.updateTrack(tid, track); - padSorted = true; //flag set - padTIDlist.add(tid); //track the TID assigned - break TIMECHECKLOOP; //no need to continue checking previous times - } //END PAD COMPARE - - } //END PADCHECKLOOP - - } else {//pad is somehow in this time slice already so lets go ahead and add it to the current time slice - track.addPad(time, pad); - //TIDMap.updateTrack(tid, track); - padSorted = true; - padTIDlist.add(tid); - break TIMECHECKLOOP; - } - - } //END TIMECHECKLOOP - - } //END TIDLOOP - - if(!padSorted) { //we need a new TID if we get here, the pad was never assigned an ID - TIDMap.addTrack(new Track(time,pad)); - } - - if(padTIDlist.size()>1) { //if a pad gets more than 1 ID let's merge the IDs - for(int tidtemp : padTIDlist) { - if(tidtemp == padTIDlist.get(0)) { - parenttid = padTIDlist.get(0); - } else { - TIDMap.mergeTracks(parenttid, tidtemp); - } - } - } - - } //END ADC THRESH CHECK - - } //END PADLOOP - - } //END TIMELOOP - - //END MAIN ALGORITHM - - /* - * Clean up and flag tracks - */ - - for(int tid : TIDMap.getAllTrackIDs()) { //We need to remove tracks with not enough pads to save time later - Track tempt = TIDMap.getTrack(tid); - if(tempt.uniquePadCountTotal() < minhitcount) { - TIDMap.removeTrack(tid); - } - } - - //System.out.println("This event has " + TIDMap.getAllTrackIDs().size() + " tracks"); - - //TODO Flag crossing tracks; for now flag all tracks - for(int tid : TIDMap.getAllTrackIDs()) { - Track t = TIDMap.getTrack(tid); - t.flagTrack(); - } - - /* - * Output - */ - - params.set_trackmap(TIDMap); - - /* - * Drawing for debugging - * To be removed - */ - - if(draw) { - - HashMap gmapzvsphi = new HashMap(); - EmbeddedCanvas cZvsPhi = new EmbeddedCanvas(); - JFrame jZvsPhi = new JFrame(); - jZvsPhi.setSize(800,600); - - HashMap gmapphivst = new HashMap(); - EmbeddedCanvas cPhivsT = new EmbeddedCanvas(); - JFrame jPhivsT = new JFrame(); - jPhivsT.setSize(800,600); - - HashMap gmapzvst = new HashMap(); - EmbeddedCanvas cZvsT = new EmbeddedCanvas(); - JFrame jZvsT = new JFrame(); - jZvsT.setSize(800,600); - int color = 1; - int style = 1; - for(int tid : TIDMap.getAllTrackIDs()) { - Track t = TIDMap.getTrack(tid); - gmapzvsphi.put(tid, new GraphErrors()); - gmapphivst.put(tid, new GraphErrors()); - gmapzvst.put(tid, new GraphErrors()); - for(int time : t.getAllTimeSlices()) { - for(int padref : t.getTimeSlice(time)) { - PadVector p = params.get_padvector(padref); - gmapzvsphi.get(tid).addPoint(p.phi(), p.z(), 0, 0); - gmapzvst.get(tid).addPoint(time, p.z(), 0, 0); - gmapphivst.get(tid).addPoint(time, p.phi(), 0, 0); - } - } - gmapzvsphi.get(tid).setMarkerColor(color); - gmapzvsphi.get(tid).setMarkerSize(3); - gmapzvsphi.get(tid).setMarkerStyle(style); - - gmapzvst.get(tid).setMarkerColor(color); - gmapzvst.get(tid).setMarkerSize(3); - gmapzvst.get(tid).setMarkerStyle(style); - - gmapphivst.get(tid).setMarkerColor(color); - gmapphivst.get(tid).setMarkerSize(3); - gmapphivst.get(tid).setMarkerStyle(style); - - cZvsPhi.draw(gmapzvsphi.get(tid),"same"); - cZvsT.draw(gmapzvst.get(tid),"same"); - cPhivsT.draw(gmapphivst.get(tid),"same"); - - color++; - if(color > 8) { - color = 1; - style++; - } - - } - - jZvsPhi.setTitle("Track Finder Output"); - jZvsPhi.add(cZvsPhi); - jZvsPhi.setVisible(true); - - jZvsT.setTitle("Track Finder Output"); - jZvsT.add(cZvsT); - jZvsT.setVisible(true); - - jPhivsT.setTitle("Track Finder Output"); - jPhivsT.add(cPhivsT); - jPhivsT.setVisible(true); - - } - - } - -} diff --git a/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/TrackHitReco.java b/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/TrackHitReco.java deleted file mode 100644 index 0a3774d91b..0000000000 --- a/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/TrackHitReco.java +++ /dev/null @@ -1,528 +0,0 @@ -package org.jlab.rec.rtpc.hit; - -import java.util.concurrent.ConcurrentHashMap; -import java.util.HashMap; -import java.util.List; -import java.util.Vector; - -import javax.swing.JFrame; - -import org.jlab.groot.data.GraphErrors; -import org.jlab.groot.graphics.EmbeddedCanvas; - -public class TrackHitReco { - - public void Reco(List rawHits, HitParameters params) { - HashMap>> TIDMap = params.get_TIDMap(); - HashMap ADCMap = params.get_R_adc(); - HashMap graphmap = new HashMap(); - HashMap graphmap2 = new HashMap(); - Vector TimeVec = new Vector(); - Vector XVec = new Vector(); - Vector YVec = new Vector(); - Vector ZVec = new Vector(); - Vector Pads = new Vector(); - int p = 0; - EmbeddedCanvas c = new EmbeddedCanvas(); - EmbeddedCanvas c2 = new EmbeddedCanvas(); - EmbeddedCanvas c3 = new EmbeddedCanvas(); - JFrame j = new JFrame(); - j.setSize(800,600); - JFrame j2 = new JFrame(); - j2.setSize(800,600); - JFrame j3 = new JFrame(); - j3.setSize(800,600); - Vector PadList = new Vector(); - double maxvalue = 0; - double thresh = 0; - int TrigWindSize = params.get_TrigWindSize(); - double sumnumer = 0; - double sumdenom = 0; - HashMap weightave = new HashMap(); - //System.out.println(TIDMap.size()); - //for(Hit hit : rawHits) { - for(int TID : TIDMap.keySet()){ - PadList.clear(); - - for(int time : TIDMap.get(TID).keySet()) - { - for(int pad = 0; pad < TIDMap.get(TID).get(time).size(); pad++) - { - if(!PadList.contains(TIDMap.get(TID).get(time).get(pad))) - { - PadList.add(TIDMap.get(TID).get(time).get(pad)); - } - } - } - - for(int pad = 0; pad < PadList.size(); pad++) - { - for(int time : TIDMap.get(TID).keySet()) - { - if(TIDMap.get(TID).get(time).contains(PadList.get(pad))) - { - if(ADCMap.get(PadList.get(pad))[time]>maxvalue) - { - maxvalue = ADCMap.get(PadList.get(pad))[time]; - } - } - } - thresh = maxvalue/2; - for(int time = 0; time < TrigWindSize; time++) - { - if(ADCMap.get(PadList.get(pad))[time] > thresh) - { - sumnumer += ADCMap.get(PadList.get(pad))[time]*time; - sumdenom += ADCMap.get(PadList.get(pad))[time]; - //System.out.println(PadList.get(pad) + " " + time); - } - } - - //System.out.println("weightave " + PadList.get(pad) + " " + sumnumer/sumdenom); - weightave.put(PadList.get(pad), sumnumer/sumdenom); - sumnumer = 0; - sumdenom = 0; - maxvalue = 0; - //padvec = PadCoords(PadList.get(pad)); - //gZvsT.addPoint(weightave.get(PadList.get(pad)), padvec.z(), 0, 0); - //gPhivsT.addPoint(weightave.get(PadList.get(pad)), Math.atan2(padvec.y(),padvec.x()),0,0); - } - - graphmap.put(TID, new GraphErrors()); - graphmap2.put(TID, new GraphErrors()); - //System.out.println("hqwd" + TID); - for(int t : TIDMap.get(TID).keySet()){ - for(int padindex = 0; padindex < TIDMap.get(TID).get(t).size(); padindex++){ - - - int cellID = TIDMap.get(TID).get(t).get(padindex); - Pads.add(cellID); - double Time = (double)t; - //System.out.println(Time + " " + cellID); - - - //int NEve = 10; - - double PAD_W = 2.79; // in mm - double PAD_S = 80.0; //in mm - double PAD_L = 4.0; // in mm - double RTPC_L = 384.0; // in mm - - //double Num_of_Rows = (2.0*(Math.PI)*PAD_S)/PAD_W; - double Num_of_Cols = RTPC_L/PAD_L; - //double TotChan = Num_of_Rows*Num_of_Cols; - - double PI=Math.PI; - - double z0 = -(RTPC_L/2.0); // front of RTPC in mm at the center of the pad - - double phi_per_pad = PAD_W/PAD_S; // in rad - - - - // MagBoltz parameters - double a_t=1741.179712, b_t=-1.25E+02; // for f(x)=time(radius) - double a_phi=0.161689123, b_phi=0.023505021; // for f(x)=dphi(radius) - - double t_2GEM2 = 296.082; - double t_2GEM3 = 296.131; - double t_2PAD = 399.09; - double t_gap = t_2GEM2 + t_2GEM3 + t_2PAD; - - double phi_2GEM2 = 0.0492538; - double phi_2GEM3 = 0.0470817; - double phi_2PAD = 0.0612122; - double phi_gap = phi_2GEM2 + phi_2GEM3 + phi_2PAD; - - // find postition from Cell ID - //for (double s = 0.0; s < cellID.size(); s++) { - - double chan=0; - double t_s2pad = 0; - double dphi=0; - double dz=0; - double x_rec = 0; - double y_rec = 0; - - - double z_pad=0; - double z_rec=0; - double z_hit=0; // position of the hit on a single pad in z - double delta_z=0; - - double r_pos=0; - double r_rec=0; - double r_temp=0; - double delta_r=0; - - double phi_pad=0; - double phi_rec=0; - - - - // generated position of ionization in phi - - //phi_pos = Math.atan2(Y, X); - - // generated position of ionization in s - //r_pos=Math.sqrt(((X)*(X))+((Y)*(Y))); - - - // ------------------ find z and phi of pad from CellID ------------------ - chan = (double)cellID; - - double col = chan%Num_of_Cols; - double row=(chan-col)/Num_of_Cols; - double z_shift = row%4; - //double z_shift = 0.; - - phi_pad=(row*phi_per_pad)+(phi_per_pad/2.0); - if(phi_pad>= 2.0*PI) { - phi_pad -= 2.0*PI; - } - if(phi_pad<0) - { - phi_pad += 2.0*PI; - } - - z_pad=z0+(col*PAD_L)+(PAD_L/2.0)+z_shift; - // ----------------------------------------------------------------------- - - - // find reconstructed position of ionization from Time info - - t_s2pad = Time-t_gap; - - r_rec=((-(Math.sqrt(a_t*a_t+(4.*b_t*t_s2pad)))+a_t+(14.*b_t))/(2.*b_t))*10.0; //in mm - - - dphi=a_phi*(7.-r_rec/10.)+b_phi*(7.-r_rec/10.)*(7.-r_rec/10.); // in rad - - - dz=0; - - phi_rec=phi_pad-dphi-phi_gap; - if( phi_rec<0.0 ) - { - phi_rec+=2.0*PI; - } - if( phi_rec>2.0*PI ) - { - phi_rec-=2.0*PI; - } - - // x,y,z pos of reconstructed track - x_rec=r_rec*(Math.cos(phi_rec)); - y_rec=r_rec*(Math.sin(phi_rec)); - z_rec=z_pad-dz; - //if(r_rec > 30 && r_rec < 70) - //{ - graphmap.get(TID).addPoint(r_rec, z_rec, 0, 0); - graphmap2.get(TID).addPoint(x_rec, y_rec, 0, 0); - - //} - // x,y,z pos of pad hit - //x_pad=(PAD_S)*(Math.cos(phi_pad)); - //y_pad=(PAD_S)*(Math.sin(phi_pad)); - - // actual position on pad of hits - //phi_hit=phi_rad-(row*phi_per_pad); - //z_hit=Z-z0-(col*PAD_L)-z_shift; - - // find differences (delta = generated-reconstructed) - //delta_x=X-x_rec; - //delta_y=Y-y_rec; - //delta_z=Z-z_rec; - //delta_r=r_pos-r_rec; - //delta_phi = phi_pos-phi_rec; - - - - - /*hit.set_cellID(cellID); - hit.set_Time(t_s2pad); - hit.set_Edep(Edep); - hit.set_PosX(x_rec); - hit.set_PosY(y_rec); - hit.set_PosZ(z_rec); - TimeVec.add(t_s2pad); - XVec.add(x_rec); - YVec.add(y_rec); - ZVec.add(z_rec);*/ - - - } - } - } - GraphErrors grz = new GraphErrors(); - GraphErrors g1rz = new GraphErrors(); - GraphErrors gxy = new GraphErrors(); - GraphErrors g1xy = new GraphErrors(); - GraphErrors gerrorxvsphi = new GraphErrors(); - GraphErrors gerroryvsphi = new GraphErrors(); - int counter = 1; - for(Hit hit : rawHits) - { - if(true) { - int cellID = hit.get_cellID(); - double Time = hit.get_Time(); - double X = hit.get_PosXTrue(); - double Y = hit.get_PosYTrue(); - double Z = hit.get_PosZTrue(); - - //if(Pads.contains(cellID)) - //{ - //ystem.out.println(Time + " " + cellID); - - - //int NEve = 10; - - double PAD_W = 2.79; // in mm - double PAD_S = 80.0; //in mm - double PAD_L = 4.0; // in mm - double RTPC_L = 384.0; // in mm - - //double Num_of_Rows = (2.0*(Math.PI)*PAD_S)/PAD_W; - double Num_of_Cols = RTPC_L/PAD_L; - //double TotChan = Num_of_Rows*Num_of_Cols; - - double PI=Math.PI; - - double z0 = -(RTPC_L/2.0); // front of RTPC in mm at the center of the pad - - double phi_per_pad = PAD_W/PAD_S; // in rad - - - - // MagBoltz parameters - double a_t=1741.179712, b_t=-125; // for f(x)=time(radius) - double a_phi=0.161689123, b_phi=0.023505021; // for f(x)=dphi(radius) - - double t_2GEM2 = 296.082; - double t_2GEM3 = 296.131; - double t_2PAD = 399.09; - double t_gap = t_2GEM2 + t_2GEM3 + t_2PAD; - - double phi_2GEM2 = 0.0492538; - double phi_2GEM3 = 0.0470817; - double phi_2PAD = 0.0612122; - double phi_gap = phi_2GEM2 + phi_2GEM3 + phi_2PAD; - - // find position from Cell ID - //for (double s = 0.0; s < cellID.size(); s++) { - - double chan=0; - double t_s2pad = 0; - double dphi=0; - double dz=0; - double x_rec = 0; - double y_rec = 0; - - - double z_pad=0; - double z_rec=0; - double z_hit=0; // position of the hit on a single pad in z - double delta_z=0; - - double r_pos=0; - double r_rec=0; - double r_temp=0; - double delta_r=0; - - double phi_pad=0; - double phi_rec=0; - double phi_pos = 0; - - - // generated position of ionization in phi - - phi_pos = Math.atan2(Y, X); - - // generated position of ionization in s - r_pos=Math.sqrt(((X)*(X))+((Y)*(Y))); - - - // ------------------ find z and phi of pad from CellID ------------------ - chan = (double)cellID; - - double col = chan%Num_of_Cols; - double row=(chan-col)/Num_of_Cols; - double z_shift = row%4; - //double z_shift = 0.; - //System.out.println(row + " " + chan + " " + col + " " + phi_per_pad); - phi_pad=(row*phi_per_pad)+(phi_per_pad/2.0); - while(phi_pad >= 2*PI || phi_pad < 0) - { - if(phi_pad>= 2.0*PI) { - phi_pad -= 2.0*PI; - } - if(phi_pad<0) - { - phi_pad += 2.0*PI; - } - } - z_pad=z0+(col*PAD_L)+(PAD_L/2.0)+z_shift; - // ----------------------------------------------------------------------- - - - // find reconstructed position of ionization from Time info - - t_s2pad = Time-t_gap; - - r_rec=((-(Math.sqrt(a_t*a_t+(4*b_t*t_s2pad)))+a_t+(14*b_t))/(2*b_t))*10.0; //in mm - - - dphi=a_phi*(7-r_rec/10)+b_phi*(7-r_rec/10)*(7.-r_rec/10); // in rad - - - dz=0; - - phi_rec=phi_pad-dphi-phi_gap; - while(phi_rec < 0 || phi_rec >= 2*PI) - { - if( phi_rec<0.0 ) - { - phi_rec+=2.0*PI; - } - if( phi_rec>2.0*PI ) - { - phi_rec-=2.0*PI; - } - } - //System.out.println("reconstructed phi " + phi_rec + " actual phi " + Math.atan(Y/X)); - - // x,y,z pos of reconstructed track - x_rec=r_rec*(Math.cos(phi_rec)); - y_rec=r_rec*(Math.sin(phi_rec)); - z_rec=z_pad-dz; - //if(true) - //if(counter > 2500) - //if(z_rec > 160 && r_rec > 30 && r_rec < 55 && z_rec < 195) - if(true)//if(Math.abs(x_rec-X) < 3 && Math.abs(y_rec-Y) < 3 && Math.abs(z_rec-Z) < 3) - { - grz.addPoint(r_rec, z_rec, 0, 0); - gxy.addPoint(x_rec, y_rec, 0, 0); - //if(counter <= 53) - //{ - g1rz.addPoint(Math.sqrt(X*X+Y*Y), Z, 0, 0); - g1xy.addPoint(X, Y, 0, 0); - gerrorxvsphi.addPoint(Math.atan2(Y,X),Math.pow(Math.abs(x_rec-X),2)/X,0,0); - gerroryvsphi.addPoint(Math.atan2(Y,X),Math.pow(Math.abs(y_rec-Y),2)/Y,0,0); - //} - //System.out.println(counter); - } - else - { - grz.addPoint(0, 0, 0, 0); - g1rz.addPoint(0, 0, 0, 0); - gxy.addPoint(0, 0, 0, 0); - g1xy.addPoint(0, 0, 0, 0); - } - //} - // x,y,z pos of pad hit - //x_pad=(PAD_S)*(Math.cos(phi_pad)); - //y_pad=(PAD_S)*(Math.sin(phi_pad)); - - // actual position on pad of hits - //phi_hit=phi_rad-(row*phi_per_pad); - //z_hit=Z-z0-(col*PAD_L)-z_shift; - - // find differences (delta = generated-reconstructed) - //delta_x=X-x_rec; - //delta_y=Y-y_rec; - //delta_z=Z-z_rec; - //delta_r=r_pos-r_rec; - //delta_phi = phi_pos-phi_rec; - //System.out.println(X + " " + x_rec); - //System.out.println(r_pos + " " + r_rec); - - - - /*hit.set_cellID(cellID); - hit.set_Time(t_s2pad); - hit.set_Edep(Edep); - hit.set_PosX(x_rec); - hit.set_PosY(y_rec); - hit.set_PosZ(z_rec); - TimeVec.add(t_s2pad); - XVec.add(x_rec); - YVec.add(y_rec); - ZVec.add(z_rec);*/ - //} - counter++; - } - } - //System.out.println(counter); - GraphErrors g2 = new GraphErrors(); - double theta = 0; - double test_x = 0; - double test_y = 0; - double test_x2 = 0; - double test_y2 = 0; - while(theta <= 2*Math.PI) - { - test_x = 30 * Math.cos(theta); - test_y = 30 * Math.sin(theta); - test_x2 = 70 * Math.cos(theta); - test_y2 = 70 * Math.sin(theta); - g2.addPoint(test_x, test_y, 0, 0); - g2.addPoint(test_x2, test_y2, 0, 0); - theta+=0.01; - } - - for(int key : TIDMap.keySet()) - { - if(false) - //if(key == 1) - { - graphmap.get(key).setMarkerSize(6); - graphmap2.get(key).setMarkerSize(6); - } - else { - graphmap.get(key).setMarkerSize(2); - graphmap.get(key).setMarkerColor(4); - graphmap.get(key).setMarkerStyle(2); - - - graphmap2.get(key).setMarkerSize(2); - graphmap2.get(key).setMarkerColor(4); - graphmap2.get(key).setMarkerStyle(2); - } - c.draw(graphmap.get(key),"same"); - c2.draw(graphmap2.get(key),"same"); - - } - grz.setMarkerSize(3); - grz.setMarkerColor(1); - g1rz.setMarkerSize(1); - g1rz.setMarkerColor(5); - //grz.addPoint(30, -200, 0, 0); - //grz.addPoint(70, 200, 0, 0); - gxy.setMarkerSize(4); - gxy.setMarkerColor(2); - g1xy.setMarkerSize(0); - g1xy.setMarkerColor(5); - g2.setMarkerSize(0); - g2.setMarkerColor(3); - gerrorxvsphi.setMarkerSize(2); - gerroryvsphi.setMarkerSize(2); - c.draw(grz,"same"); - c.draw(g1rz,"same"); - c2.draw(gxy,"same"); - c2.draw(g1xy,"same"); - c2.draw(g2,"same"); - c3.divide(1, 2); - c3.cd(0); - c3.draw(gerrorxvsphi); - c3.cd(1); - c3.draw(gerroryvsphi); - j.setTitle("RZ"); - j2.setTitle("XY"); - j.add(c); - j.setVisible(true); - j2.add(c2); - j2.setVisible(true); - //j3.add(c3); - //j3.setVisible(true); - } -} diff --git a/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/TrackHitReco2.java b/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/TrackHitReco2.java deleted file mode 100644 index e65fa78d93..0000000000 --- a/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/TrackHitReco2.java +++ /dev/null @@ -1,714 +0,0 @@ -package org.jlab.rec.rtpc.hit; - -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.util.ArrayList; -import java.util.concurrent.ConcurrentHashMap; -import java.util.HashMap; -import java.util.List; -import java.util.Vector; - -import javax.swing.JFrame; - -import org.jlab.clas.physics.Vector3; -import org.jlab.groot.data.GraphErrors; -import org.jlab.groot.data.H1F; -import org.jlab.groot.graphics.EmbeddedCanvas; -import org.jlab.rec.rtpc.hit.RecoHitVector; - -public class TrackHitReco2 { - - public void Reco(List rawHits, HitParameters params, boolean draw) { - HashMap>> TIDMap = params.get_strkTIDMap(); - HashMap ADCMap = params.get_R_adc(); - HashMap graphmap = new HashMap(); - HashMap graphmap2 = new HashMap(); - HashMap> alltracks = params.get_alltracks(); - HashMap largetmap = params.get_largetmap(); - HashMap tdiffmap = new HashMap(); - HashMap> recohitvector = new HashMap>(); - Vector TimeVec = new Vector(); - Vector XVec = new Vector(); - Vector YVec = new Vector(); - Vector ZVec = new Vector(); - Vector Pads = new Vector(); - int p = 0; - EmbeddedCanvas c = new EmbeddedCanvas(); - EmbeddedCanvas c2 = new EmbeddedCanvas(); - EmbeddedCanvas c3 = new EmbeddedCanvas(); - EmbeddedCanvas c4 = new EmbeddedCanvas(); - JFrame j = new JFrame(); - j.setSize(800,600); - JFrame j2 = new JFrame(); - j2.setSize(800,600); - JFrame j3 = new JFrame(); - j3.setSize(800,600); - JFrame j4 = new JFrame(); - j4.setSize(800,600); - - double a_t1 = -2.48491E-4; - double a_t2 = 2.21413E-4; - double a_t3 = -3.11195E-3; - double a_t4 = -2.75206E-1; - double a_t5 = 1.74281E3; - - double b_t1 = 2.48873E-5; - double b_t2 = -1.19976E-4; - double b_t3 = -3.75962E-3; - double b_t4 = 5.33100E-2; - double b_t5 = -1.25647E2; - - double a_phi1 = -3.32718E-8; - double a_phi2 = 1.92110E-7; - double a_phi3 = 2.16919E-6; - double a_phi4 = -8.10207E-5; - double a_phi5 = 1.68481E-1; - - double b_phi1 = -3.23019E-9; - double b_phi2 = -6.92075E-8; - double b_phi3 = 1.24731E-5; - double b_phi4 = 2.57684E-5; - double b_phi5 = 2.10680E-2; - - H1F largetdist = new H1F("largetdist",100,0,10000); - - double timewindow = 2000; - double smalltcut = 300; - double largetcut = 8000; - int tracksizecut = 4; - double larget = 0; - double tdiff = 0; - double Time = 0; - int cellID = 0; - int outsidedriftcounter = 0; - int allhitscounter = 0; - /*Vector PadList = new Vector(); - double maxvalue = 0; - double thresh = 0; - int TrigWindSize = params.get_TrigWindSize(); - double sumnumer = 0; - double sumdenom = 0; - int count = 0;*/ - - //HashMap weightave = new HashMap(); - //System.out.println(TIDMap.size()); - //for(Hit hit : rawHits) { - //for(int TID : TIDMap.keySet()){ - //System.out.println(alltracks.size() + " " + alltracks.get(1).size()); - for(int TID : alltracks.keySet()) { - Pads.clear(); - /*PadList.clear(); - - double larget = 0; - for(int time : TIDMap.get(TID).keySet()) - { - for(int pad = 0; pad < TIDMap.get(TID).get(time).size(); pad++) - { - if(!PadList.contains(TIDMap.get(TID).get(time).get(pad))) - { - PadList.add(TIDMap.get(TID).get(time).get(pad)); - } - } - } - - for(int pad = 0; pad < PadList.size(); pad++) - { - for(int time : TIDMap.get(TID).keySet()) - { - if(TIDMap.get(TID).get(time).contains(PadList.get(pad))) - { - if(ADCMap.get(PadList.get(pad))[time]>maxvalue) - { - maxvalue = ADCMap.get(PadList.get(pad))[time]; - } - } - } - thresh = maxvalue/2; - for(int time = 0; time < TrigWindSize; time++) - { - if(ADCMap.get(PadList.get(pad))[time] > thresh) - { - sumnumer += ADCMap.get(PadList.get(pad))[time]*time; - sumdenom += ADCMap.get(PadList.get(pad))[time]; - //System.out.println(PadList.get(pad) + " " + time); - } - } - if(sumnumer/sumdenom >= larget) - { - larget = sumnumer/sumdenom; - } - //System.out.println("weightave " + PadList.get(pad) + " " + sumnumer/sumdenom); - weightave.put(PadList.get(pad), sumnumer/sumdenom); - sumnumer = 0; - sumdenom = 0; - maxvalue = 0; - //padvec = PadCoords(PadList.get(pad)); - //gZvsT.addPoint(weightave.get(PadList.get(pad)), padvec.z(), 0, 0); - //gPhivsT.addPoint(weightave.get(PadList.get(pad)), Math.atan2(padvec.y(),padvec.x()),0,0); - }*/ - //System.out.println("large t " + larget); - larget = largetmap.get(TID); - double smallt = 1000000; - for(int i = 0; i < alltracks.get(TID).size(); i ++) - { - if(alltracks.get(TID).get(i).time() < smallt) {smallt = alltracks.get(TID).get(i).time();} - } - //double smallt = alltracks.get(TID).get(alltracks.get(TID).size()-1).time(); - - - /*try { - File f = new File("/Users/davidpayette/Documents/FileOutput/smallt.txt"); - //f.delete(); - FileWriter out = new FileWriter("/Users/davidpayette/Documents/FileOutput/smallt.txt",true); - out.write(smallt + "\n"); - out.close(); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - }*/ - largetdist.fill(larget); - //System.out.println("large t is " + larget); - //if(TID != 2) {continue;} - //System.out.println(smallt + " small t"); - if(smallt < smalltcut || larget > largetcut || alltracks.get(TID).size() <= tracksizecut) {continue;} - //add smallt check as well for smallt too small - - graphmap.put(TID, new GraphErrors()); - graphmap2.put(TID, new GraphErrors()); - - tdiff = 6000 - larget; - //if(larget + tdiff > 7500) {continue;} - tdiffmap.put(TID, tdiff); - recohitvector.put(TID, new Vector()); - - //tdiff = 0; - //System.out.println("hqwd" + TID); - //for(int cellID : weightave.keySet()){ - //System.out.println("large t " + larget); - for(int k = 0; k < alltracks.get(TID).size(); k++) { - //for(int padindex = 0; padindex < TIDMap.get(TID).get(t).size(); padindex++){ - - allhitscounter++; - //int cellID = TIDMap.get(TID).get(t).get(padindex); - cellID = (int)alltracks.get(TID).get(k).pad(); - if(!Pads.contains(cellID)) { - Pads.add(cellID); - } - //double Time = weightave.get(cellID); - Time = alltracks.get(TID).get(k).time(); - //System.out.println("reco " + Time); - //System.out.println("tdiff " + tdiff); - Time+=tdiff; - - //System.out.println(Time + " " + cellID); - - - //int NEve = 10; - - double PAD_W = 2.79; // in mm - double PAD_S = 80.0; //in mm - double PAD_L = 4.0; // in mm - double RTPC_L = 384.0; // in mm - - //double Num_of_Rows = (2.0*(Math.PI)*PAD_S)/PAD_W; - double Num_of_Cols = RTPC_L/PAD_L; - //double TotChan = Num_of_Rows*Num_of_Cols; - - double PI=Math.PI; - - double z0 = -(RTPC_L/2.0); // front of RTPC in mm at the center of the pad - - double phi_per_pad = PAD_W/PAD_S; // in rad - - - - // MagBoltz parameters - //double a_t=1741.179712, b_t=-1.25E+02; // for f(x)=time(radius) - //double a_phi=0.161689123, b_phi=0.023505021; // for f(x)=dphi(radius) - - double t_2GEM2 = 296.082; - double t_2GEM3 = 296.131; - double t_2PAD = 399.09; - double t_gap = t_2GEM2 + t_2GEM3 + t_2PAD; - - double phi_2GEM2 = 0.0492538; - double phi_2GEM3 = 0.0470817; - double phi_2PAD = 0.0612122; - double phi_gap = phi_2GEM2 + phi_2GEM3 + phi_2PAD; - - // find postition from Cell ID - //for (double s = 0.0; s < cellID.size(); s++) { - - double chan=0; - double t_s2pad = 0; - double dphi=0; - double dz=0; - double x_rec = 0; - double y_rec = 0; - - - double z_pad=0; - double z_rec=0; - double z_hit=0; // position of the hit on a single pad in z - double delta_z=0; - - double r_pos=0; - double r_rec=0; - double r_temp=0; - double delta_r=0; - - double phi_pad=0; - double phi_rec=0; - - - - // generated position of ionization in phi - - //phi_pos = Math.atan2(Y, X); - - // generated position of ionization in s - //r_pos=Math.sqrt(((X)*(X))+((Y)*(Y))); - - - // ------------------ find z and phi of pad from CellID ------------------ - chan = (double)cellID; - - double col = chan%Num_of_Cols; - double row=(chan-col)/Num_of_Cols; - double z_shift = row%4; - //double z_shift = 0.; - - phi_pad=(row*phi_per_pad)+(phi_per_pad/2.0); - if(phi_pad>= 2.0*PI) { - phi_pad -= 2.0*PI; - } - if(phi_pad<0) - { - phi_pad += 2.0*PI; - } - - z_pad=z0+(col*PAD_L)+(PAD_L/2.0)+z_shift; - // ----------------------------------------------------------------------- - dz=0; - z_rec=z_pad-dz; - - // find reconstructed position of ionization from Time info - - t_s2pad = Time-t_gap; - //if(t_s2pad > 6000) {System.out.println("oooops");} - //System.out.println("time stuff " + t_s2pad + " " + Time); - - double a_t = get_rec_coef(a_t1,a_t2,a_t3,a_t4,a_t5,z_rec); - double b_t = get_rec_coef(b_t1,b_t2,b_t3,b_t4,b_t5,z_rec); - - r_rec=((-(Math.sqrt(a_t*a_t+(4.*b_t*t_s2pad)))+a_t+(14.*b_t))/(2.*b_t))*10.0; //in mm - - double a_phi = get_rec_coef(a_phi1,a_phi2,a_phi3,a_phi4,a_phi5,z_rec); - double b_phi = get_rec_coef(b_phi1,b_phi2,b_phi3,b_phi4,b_phi5,z_rec); - - dphi=a_phi*(7.-r_rec/10.)+b_phi*(7.-r_rec/10.)*(7.-r_rec/10.); // in rad - //System.out.println("r and phi " + r_rec + " " + dphi); - - - //System.out.println("phi stuff " + phi_pad + " " + dphi + " " + phi_gap); - phi_rec=phi_pad-dphi-phi_gap; - if( phi_rec<0.0 ) - { - phi_rec+=2.0*PI; - } - if( phi_rec>2.0*PI ) - { - phi_rec-=2.0*PI; - } - if(r_rec > 70 || r_rec < 30) - { - outsidedriftcounter++; - } - // x,y,z pos of reconstructed track - x_rec=r_rec*(Math.cos(phi_rec)); - y_rec=r_rec*(Math.sin(phi_rec)); - - - recohitvector.get(TID).add(new RecoHitVector(cellID,x_rec,y_rec,z_rec,tdiff,Time)); - //if(r_rec > 30 && r_rec < 70) - //{ - graphmap.get(TID).addPoint(r_rec, z_rec, 0, 0); - graphmap2.get(TID).addPoint(x_rec, y_rec, 0, 0); - - - - //System.out.println("TID time phi x y " + TID + " " + Time + " " + phi_rec + " " + x_rec + " " + y_rec); - //} - // x,y,z pos of pad hit - //x_pad=(PAD_S)*(Math.cos(phi_pad)); - //y_pad=(PAD_S)*(Math.sin(phi_pad)); - - // actual position on pad of hits - //phi_hit=phi_rad-(row*phi_per_pad); - //z_hit=Z-z0-(col*PAD_L)-z_shift; - - // find differences (delta = generated-reconstructed) - //delta_x=X-x_rec; - //delta_y=Y-y_rec; - //delta_z=Z-z_rec; - //delta_r=r_pos-r_rec; - //delta_phi = phi_pos-phi_rec; - - - - - /*hit.set_cellID(cellID); - hit.set_Time(t_s2pad); - hit.set_Edep(Edep); - hit.set_PosX(x_rec); - hit.set_PosY(y_rec); - hit.set_PosZ(z_rec); - TimeVec.add(t_s2pad); - XVec.add(x_rec); - YVec.add(y_rec); - ZVec.add(z_rec);*/ - - - - } - //System.out.println("num of pads " + Pads.size()); - } - GraphErrors grz = new GraphErrors(); - GraphErrors g1rz = new GraphErrors(); - GraphErrors gxy = new GraphErrors(); - GraphErrors g1xy = new GraphErrors(); - GraphErrors g2xy = new GraphErrors(); - GraphErrors gerrorxvsphi = new GraphErrors(); - GraphErrors gerroryvsphi = new GraphErrors(); - int counter = 1; - - for(Hit hit : rawHits) - { - if(true) { - cellID = hit.get_cellID(); - - Time = hit.get_Time(); - //double T_noshift = Time; - if(Time <= 0) {continue;} - Time -= hit.get_TShift(); - //System.out.println("Time " + hit.get_Time() + " " + hit.get_TShift()); - - double X = hit.get_PosXTrue(); - double Y = hit.get_PosYTrue(); - double Z = hit.get_PosZTrue(); - //double TimeNoShift = Time - hit.get_TShift(); - //if(Pads.contains(cellID)) - //{ - //ystem.out.println(Time + " " + cellID); - - - //int NEve = 10; - - double PAD_W = 2.79; // in mm - double PAD_S = 80.0; //in mm - double PAD_L = 4.0; // in mm - double RTPC_L = 384.0; // in mm - - //double Num_of_Rows = (2.0*(Math.PI)*PAD_S)/PAD_W; - double Num_of_Cols = RTPC_L/PAD_L; - //double TotChan = Num_of_Rows*Num_of_Cols; - - double PI=Math.PI; - - double z0 = -(RTPC_L/2.0); // front of RTPC in mm at the center of the pad - - double phi_per_pad = PAD_W/PAD_S; // in rad - - - - // MagBoltz parameters - //double a_t=1741.179712, b_t=-125; // for f(x)=time(radius) - //double a_phi=0.161689123, b_phi=0.023505021; // for f(x)=dphi(radius) - - double t_2GEM2 = 296.082; - double t_2GEM3 = 296.131; - double t_2PAD = 399.09; - double t_gap = t_2GEM2 + t_2GEM3 + t_2PAD; - - double phi_2GEM2 = 0.0492538; - double phi_2GEM3 = 0.0470817; - double phi_2PAD = 0.0612122; - double phi_gap = phi_2GEM2 + phi_2GEM3 + phi_2PAD; - - // find position from Cell ID - //for (double s = 0.0; s < cellID.size(); s++) { - - double chan=0; - double t_s2pad = 0; - double dphi=0; - double dz=0; - double x_rec = 0; - double y_rec = 0; - - - double z_pad=0; - double z_rec=0; - double z_hit=0; // position of the hit on a single pad in z - double delta_z=0; - - double r_pos=0; - double r_rec=0; - double r_temp=0; - double delta_r=0; - - double phi_pad=0; - double phi_rec=0; - double phi_pos = 0; - - double t_calc = 0; - - - - // generated position of ionization in phi - - phi_pos = Math.atan2(Y, X); - - // generated position of ionization in s - r_pos=Math.sqrt(((X)*(X))+((Y)*(Y))); - //System.out.println(r_pos + " " + X + " " + Y); - - - // ------------------ find z and phi of pad from CellID ------------------ - chan = (double)cellID; - - double col = chan%Num_of_Cols; - double row=(chan-col)/Num_of_Cols; - double z_shift = row%4; - //double z_shift = 0.; - //System.out.println(row + " " + chan + " " + col + " " + phi_per_pad); - phi_pad=(row*phi_per_pad)+(phi_per_pad/2.0); - while(phi_pad >= 2*PI || phi_pad < 0) - { - if(phi_pad>= 2.0*PI) { - phi_pad -= 2.0*PI; - } - if(phi_pad<0) - { - phi_pad += 2.0*PI; - } - } - z_pad=z0+(col*PAD_L)+(PAD_L/2.0)+z_shift; - // ----------------------------------------------------------------------- - dz=0; - z_rec=z_pad-dz; - - // find reconstructed position of ionization from Time info - - double a_t = get_rec_coef(a_t1,a_t2,a_t3,a_t4,a_t5,z_rec); - double b_t = get_rec_coef(b_t1,b_t2,b_t3,b_t4,b_t5,z_rec); - - - - double a_phi = get_rec_coef(a_phi1,a_phi2,a_phi3,a_phi4,a_phi5,z_rec); - double b_phi = get_rec_coef(b_phi1,b_phi2,b_phi3,b_phi4,b_phi5,z_rec); - - //System.out.println(a_t + " " + b_t + " " + a_phi + " " + b_phi + " " + z_rec); - - t_s2pad = Time-t_gap; - - r_rec = ((-(Math.sqrt(a_t*a_t+(4*b_t*t_s2pad)))+a_t+(14*b_t))/(2*b_t))*10.0; //in mm - t_calc = ((((2*b_t*r_pos*0.1)-(14*b_t)-a_t)*((2*b_t*r_pos*0.1)-14*b_t-a_t))-(a_t*a_t))*(1/(4*b_t)) + t_gap; - - - dphi=a_phi*(7-r_rec/10)+b_phi*(7-r_rec/10)*(7.-r_rec/10); // in rad - - - phi_rec=phi_pad-dphi-phi_gap; - while(phi_rec < 0 || phi_rec >= 2*PI) - { - if( phi_rec<0.0 ) - { - phi_rec+=2.0*PI; - } - if( phi_rec>2.0*PI ) - { - phi_rec-=2.0*PI; - } - } - //System.out.println("reconstructed phi " + phi_rec + " actual phi " + Math.atan(Y/X)); - - // x,y,z pos of reconstructed track - x_rec=r_rec*(Math.cos(phi_rec)); - y_rec=r_rec*(Math.sin(phi_rec)); - //System.out.println("rec " + x_rec + " " + y_rec + " " + phi_rec + " " + r_rec + " " + Time); - //if(true) - //if(counter > 2500) - //if(r_rec > 30 && r_rec < 70) - //if(Math.abs(x_rec-X) < 3 && Math.abs(y_rec-Y) < 3 && Math.abs(z_rec-Z) < 3) - //if(true) - //if(Math.abs(t_calc - Time) < timewindow) - if(hit.get_TShift() == 0) - { - //System.out.println(t_calc + " " + Time); - grz.addPoint(r_rec, z_rec, 0, 0); - gxy.addPoint(x_rec, y_rec, 0, 0); - //if(counter <= 53) - //{ - g1rz.addPoint(Math.sqrt(X*X+Y*Y), Z, 0, 0); - g1xy.addPoint(X, Y, 0, 0); - g2xy.addPoint(0, 0, 0, 0); - gerrorxvsphi.addPoint(Math.atan2(Y,X),Math.pow(Math.abs(x_rec-X),2)/X,0,0); - gerroryvsphi.addPoint(Math.atan2(Y,X),Math.pow(Math.abs(y_rec-Y),2)/Y,0,0); - //} - //System.out.println(counter); - } - else - { - //g2xy.addPoint(X, Y, 0, 0); - g2xy.addPoint(0, 0, 0, 0); - grz.addPoint(0, 0, 0, 0); - g1rz.addPoint(0, 0, 0, 0); - gxy.addPoint(0, 0, 0, 0); - g1xy.addPoint(0, 0, 0, 0); - } - //} - // x,y,z pos of pad hit - //x_pad=(PAD_S)*(Math.cos(phi_pad)); - //y_pad=(PAD_S)*(Math.sin(phi_pad)); - - // actual position on pad of hits - //phi_hit=phi_rad-(row*phi_per_pad); - //z_hit=Z-z0-(col*PAD_L)-z_shift; - - // find differences (delta = generated-reconstructed) - //delta_x=X-x_rec; - //delta_y=Y-y_rec; - //delta_z=Z-z_rec; - //delta_r=r_pos-r_rec; - //delta_phi = phi_pos-phi_rec; - //System.out.println(X + " " + x_rec); - //System.out.println(r_pos + " " + r_rec); - - - - /*hit.set_cellID(cellID); - hit.set_Time(t_s2pad); - hit.set_Edep(Edep); - hit.set_PosX(x_rec); - hit.set_PosY(y_rec); - hit.set_PosZ(z_rec); - TimeVec.add(t_s2pad); - XVec.add(x_rec); - YVec.add(y_rec); - ZVec.add(z_rec);*/ - //} - counter++; - } - } - //System.out.println(counter); - GraphErrors g2 = new GraphErrors(); - double theta = 0; - double test_x = 0; - double test_y = 0; - double test_x2 = 0; - double test_y2 = 0; - while(theta <= 2*Math.PI) - { - test_x = 30 * Math.cos(theta); - test_y = 30 * Math.sin(theta); - test_x2 = 70 * Math.cos(theta); - test_y2 = 70 * Math.sin(theta); - g2.addPoint(test_x, test_y, 0, 0); - g2.addPoint(test_x2, test_y2, 0, 0); - theta+=0.01; - } - int color = 2; - int shape = 1; - for(int key : graphmap.keySet()) - { - double szPos[][] = new double[recohitvector.get(key).size()][3]; - for(int i = 0; i < recohitvector.get(key).size(); i++) { - szPos[i][0] = recohitvector.get(key).get(i).x(); - szPos[i][1] = recohitvector.get(key).get(i).y(); - szPos[i][2] = recohitvector.get(key).get(i).z(); - } - //double R = 0; double A = 0; double B = 0; double Phi_deg = 0; double Theta_deg = 0; double Z0 = 0; int fit_track_to_beamline = 1; - //HelixFitJava hf = new HelixFitJava(); - //hf.HelixFit(recohitvector.get(key).size(), szPos, R, A, B, Phi_deg, Theta_deg, Z0, fit_track_to_beamline); - //System.out.println(key + " " + R); - if(false) - //if(key == 3) - { - graphmap.get(key).setMarkerSize(6); - graphmap2.get(key).setMarkerSize(6); - } - else { - graphmap.get(key).setMarkerSize(3); - graphmap.get(key).setMarkerColor(color); - graphmap.get(key).setMarkerStyle(shape); - - - graphmap2.get(key).setMarkerSize(3); - graphmap2.get(key).setMarkerColor(color); - graphmap2.get(key).setMarkerStyle(shape); - - } - //c.draw(graphmap.get(key),"same"); - //c2.draw(graphmap2.get(key),"same"); - color++; - if(color > 7) - { - color -= 6; - shape++; - } - } - grz.setMarkerSize(3); - grz.setMarkerColor(1); - g1rz.setMarkerSize(2); - g1rz.setMarkerColor(2); - //grz.addPoint(30, -200, 0, 0); - //grz.addPoint(70, 200, 0, 0); - gxy.setMarkerSize(2); - gxy.setMarkerColor(2); - g1xy.setMarkerSize(2); - g1xy.setMarkerColor(1); - g2xy.setMarkerSize(2); - g2xy.setMarkerColor(7); - g2.setMarkerSize(0); - g2.setMarkerColor(3); - gerrorxvsphi.setMarkerSize(2); - gerroryvsphi.setMarkerSize(2); - c.draw(grz,"same"); - c.draw(g1rz,"same"); - c2.draw(gxy,"same"); - c2.draw(g1xy,"same"); - c2.draw(g2,"same"); - c2.draw(g2xy,"same"); - c3.divide(1, 2); - c3.cd(0); - c3.draw(gerrorxvsphi); - c3.cd(1); - c3.draw(gerroryvsphi); - c4.draw(largetdist); - j.setTitle("RZ"); - j2.setTitle("XY"); - if(draw == true) { - j.add(c); - j.setVisible(true); - j2.add(c2); - j2.setVisible(true); - //j3.add(c3); - //j3.setVisible(true); - j4.add(c4); - //j4.setVisible(true); - } - - //System.out.println(outsidedriftcounter + "/" + allhitscounter); - params.set_alltracks(alltracks); - params.set_recohitvector(recohitvector); - } - - double get_rec_coef(double t1, double t2, double t3, double t4, double t5, double z2) { - double z = z2/1000; - return t1*z*z*z*z + t2*z*z*z + t3*z*z + t4*z + t5; - - } - - -} diff --git a/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/TrackHitReco3.java b/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/TrackHitReco3.java deleted file mode 100644 index de93d85a77..0000000000 --- a/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/TrackHitReco3.java +++ /dev/null @@ -1,649 +0,0 @@ -//Author: David Payette and Nate Dzbenski - -/* This code takes the time-reduced tracks produced by the Time Average, as well as the original hits - * and uses a fit formula from garfield++ to calculate the hit's position in the drift region - * based on the time of the signal. We use the original hits to see how well the formula performs - * when we include factors such as time shifts and non-uniform magnetic fields - */ - -package org.jlab.rec.rtpc.hit; - -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Vector; -import java.util.concurrent.ConcurrentHashMap; - -import javax.swing.JFrame; - -import org.jlab.clas.physics.Vector3; -import org.jlab.groot.data.GraphErrors; -import org.jlab.groot.data.H1F; -import org.jlab.groot.graphics.EmbeddedCanvas; -import org.jlab.rec.rtpc.hit.RecoHitVector; - -public class TrackHitReco3 { - - public TrackHitReco3(List rawHits, HitParameters params, boolean draw) { - /* - HashMap graphmap = new HashMap(); - HashMap graphmap2 = new HashMap(); - */ - HashMap> alltracks = params.get_alltracks(); - HashMap largetmap = params.get_largetmap(); - HashMap tdiffmap = new HashMap(); - HashMap> recohitvector = new HashMap>(); - ReducedTrackMap RTIDMap = params.get_rtrackmap(); - Vector TimeVec = new Vector(); - Vector XVec = new Vector(); - Vector YVec = new Vector(); - Vector ZVec = new Vector(); - Vector Pads = new Vector(); - int p = 0; - - double a_t1 = -2.48491E-4; - double a_t2 = 2.21413E-4; - double a_t3 = -3.11195E-3; - double a_t4 = -2.75206E-1; - double a_t5 = 1.74281E3; - - double b_t1 = 2.48873E-5; - double b_t2 = -1.19976E-4; - double b_t3 = -3.75962E-3; - double b_t4 = 5.33100E-2; - double b_t5 = -1.25647E2; - - double a_phi1 = -3.32718E-8; - double a_phi2 = 1.92110E-7; - double a_phi3 = 2.16919E-6; - double a_phi4 = -8.10207E-5; - double a_phi5 = 1.68481E-1; - - double b_phi1 = -3.23019E-9; - double b_phi2 = -6.92075E-8; - double b_phi3 = 1.24731E-5; - double b_phi4 = 2.57684E-5; - double b_phi5 = 2.10680E-2; - if(draw){ - H1F largetdist = new H1F("largetdist",100,0,10000); - } - double timewindow = 2000; - double smalltcut = 300; - double largetcut = 8000; - int tracksizecut = 4; - double larget = 0; - double tdiff = 0; - double Time = 0; - int cellID = 0; - int outsidedriftcounter = 0; - int allhitscounter = 0; - - List tids = RTIDMap.getAllTrackIDs(); - for(int TID : tids) { - ReducedTrack t = RTIDMap.getTrack(TID); - Pads.clear(); - double smallt = t.getSmallT(); - larget = t.getLargeT(); - //largetdist.fill(larget); - if(draw){ - //graphmap.put(TID, new GraphErrors()); - //graphmap2.put(TID, new GraphErrors()); - } - tdiff = 6000 - larget; - tdiffmap.put(TID, tdiff); - recohitvector.put(TID, new Vector()); - - List allhits = t.getAllHits(); - for(HitVector hit : allhits) { - //for(int padindex = 0; padindex < TIDMap.get(TID).get(t).size(); padindex++){ - - allhitscounter++; - //int cellID = TIDMap.get(TID).get(t).get(padindex); - cellID = hit.pad(); - if(!Pads.contains(cellID)) { - Pads.add(cellID); - } - //double Time = weightave.get(cellID); - Time = hit.time(); - //System.out.println("reco " + Time); - //System.out.println("tdiff " + tdiff); - Time+=tdiff; - - //System.out.println(Time + " " + cellID); - - - //int NEve = 10; - - double PAD_W = 2.79; // in mm - double PAD_S = 80.0; //in mm - double PAD_L = 4.0; // in mm - double RTPC_L = 384.0; // in mm - - //double Num_of_Rows = (2.0*(Math.PI)*PAD_S)/PAD_W; - double Num_of_Cols = RTPC_L/PAD_L; - //double TotChan = Num_of_Rows*Num_of_Cols; - - double PI=Math.PI; - - double z0 = -(RTPC_L/2.0); // front of RTPC in mm at the center of the pad - - double phi_per_pad = PAD_W/PAD_S; // in rad - - - - // MagBoltz parameters - //double a_t=1741.179712, b_t=-1.25E+02; // for f(x)=time(radius) - //double a_phi=0.161689123, b_phi=0.023505021; // for f(x)=dphi(radius) - - double t_2GEM2 = 296.082; - double t_2GEM3 = 296.131; - double t_2PAD = 399.09; - double t_gap = t_2GEM2 + t_2GEM3 + t_2PAD; - - double phi_2GEM2 = 0.0492538; - double phi_2GEM3 = 0.0470817; - double phi_2PAD = 0.0612122; - double phi_gap = phi_2GEM2 + phi_2GEM3 + phi_2PAD; - - // find postition from Cell ID - //for (double s = 0.0; s < cellID.size(); s++) { - - double chan=0; - double t_s2pad = 0; - double dphi=0; - double dz=0; - double x_rec = 0; - double y_rec = 0; - - - double z_pad=0; - double z_rec=0; - double z_hit=0; // position of the hit on a single pad in z - double delta_z=0; - - double r_pos=0; - double r_rec=0; - double r_temp=0; - double delta_r=0; - - double phi_pad=0; - double phi_rec=0; - - - - // generated position of ionization in phi - - //phi_pos = Math.atan2(Y, X); - - // generated position of ionization in s - //r_pos=Math.sqrt(((X)*(X))+((Y)*(Y))); - - - // ------------------ find z and phi of pad from CellID ------------------ - chan = (double)cellID; - - double col = chan%Num_of_Cols; - double row=(chan-col)/Num_of_Cols; - double z_shift = row%4; - //double z_shift = 0.; - - phi_pad=(row*phi_per_pad)+(phi_per_pad/2.0); - if(phi_pad>= 2.0*PI) { - phi_pad -= 2.0*PI; - } - if(phi_pad<0) - { - phi_pad += 2.0*PI; - } - - z_pad=z0+(col*PAD_L)+(PAD_L/2.0)+z_shift; - // ----------------------------------------------------------------------- - dz=0; - z_rec=z_pad-dz; - - // find reconstructed position of ionization from Time info - - t_s2pad = Time-t_gap; - //if(t_s2pad > 6000) {System.out.println("oooops");} - //System.out.println("time stuff " + t_s2pad + " " + Time); - - double a_t = get_rec_coef(a_t1,a_t2,a_t3,a_t4,a_t5,z_rec); - double b_t = get_rec_coef(b_t1,b_t2,b_t3,b_t4,b_t5,z_rec); - - r_rec=((-(Math.sqrt(a_t*a_t+(4.*b_t*t_s2pad)))+a_t+(14.*b_t))/(2.*b_t))*10.0; //in mm - - double a_phi = get_rec_coef(a_phi1,a_phi2,a_phi3,a_phi4,a_phi5,z_rec); - double b_phi = get_rec_coef(b_phi1,b_phi2,b_phi3,b_phi4,b_phi5,z_rec); - - dphi=a_phi*(7.-r_rec/10.)+b_phi*(7.-r_rec/10.)*(7.-r_rec/10.); // in rad - //System.out.println("r and phi " + r_rec + " " + dphi); - - - //System.out.println("phi stuff " + phi_pad + " " + dphi + " " + phi_gap); - phi_rec=phi_pad-dphi-phi_gap; - if( phi_rec<0.0 ) - { - phi_rec+=2.0*PI; - } - if( phi_rec>2.0*PI ) - { - phi_rec-=2.0*PI; - } - if(r_rec > 70 || r_rec < 30) - { - outsidedriftcounter++; - } - // x,y,z pos of reconstructed track - x_rec=r_rec*(Math.cos(phi_rec)); - y_rec=r_rec*(Math.sin(phi_rec)); - - - recohitvector.get(TID).add(new RecoHitVector(cellID,x_rec,y_rec,z_rec,tdiff,Time)); - //if(r_rec > 30 && r_rec < 70) - //{ - if(draw){ - //graphmap.get(TID).addPoint(r_rec, z_rec, 0, 0); - //graphmap2.get(TID).addPoint(x_rec, y_rec, 0, 0); - } - - - - //System.out.println("TID time phi x y " + TID + " " + Time + " " + phi_rec + " " + x_rec + " " + y_rec); - //} - // x,y,z pos of pad hit - //x_pad=(PAD_S)*(Math.cos(phi_pad)); - //y_pad=(PAD_S)*(Math.sin(phi_pad)); - - // actual position on pad of hits - //phi_hit=phi_rad-(row*phi_per_pad); - //z_hit=Z-z0-(col*PAD_L)-z_shift; - - // find differences (delta = generated-reconstructed) - //delta_x=X-x_rec; - //delta_y=Y-y_rec; - //delta_z=Z-z_rec; - //delta_r=r_pos-r_rec; - //delta_phi = phi_pos-phi_rec; - - - - - /*hit.set_cellID(cellID); - hit.set_Time(t_s2pad); - hit.set_Edep(Edep); - hit.set_PosX(x_rec); - hit.set_PosY(y_rec); - hit.set_PosZ(z_rec); - TimeVec.add(t_s2pad); - XVec.add(x_rec); - YVec.add(y_rec); - ZVec.add(z_rec);*/ - - - - } - //System.out.println("num of pads " + Pads.size()); - } - /*GraphErrors grz = new GraphErrors(); - GraphErrors g1rz = new GraphErrors(); - GraphErrors gxy = new GraphErrors(); - GraphErrors g1xy = new GraphErrors(); - GraphErrors g2xy = new GraphErrors(); - GraphErrors gerrorxvsphi = new GraphErrors(); - GraphErrors gerroryvsphi = new GraphErrors();*/ - int counter = 1; - - for(Hit hit : rawHits) - { - if(true) { - cellID = hit.get_cellID(); - - Time = hit.get_Time(); - //double T_noshift = Time; - if(Time <= 0) {continue;} - Time -= hit.get_TShift(); - //System.out.println("Time " + hit.get_Time() + " " + hit.get_TShift()); - - double X = hit.get_PosXTrue(); - double Y = hit.get_PosYTrue(); - double Z = hit.get_PosZTrue(); - //double TimeNoShift = Time - hit.get_TShift(); - //if(Pads.contains(cellID)) - //{ - //ystem.out.println(Time + " " + cellID); - - - //int NEve = 10; - - double PAD_W = 2.79; // in mm - double PAD_S = 80.0; //in mm - double PAD_L = 4.0; // in mm - double RTPC_L = 384.0; // in mm - - //double Num_of_Rows = (2.0*(Math.PI)*PAD_S)/PAD_W; - double Num_of_Cols = RTPC_L/PAD_L; - //double TotChan = Num_of_Rows*Num_of_Cols; - - double PI=Math.PI; - - double z0 = -(RTPC_L/2.0); // front of RTPC in mm at the center of the pad - - double phi_per_pad = PAD_W/PAD_S; // in rad - - - - // MagBoltz parameters - //double a_t=1741.179712, b_t=-125; // for f(x)=time(radius) - //double a_phi=0.161689123, b_phi=0.023505021; // for f(x)=dphi(radius) - - double t_2GEM2 = 296.082; - double t_2GEM3 = 296.131; - double t_2PAD = 399.09; - double t_gap = t_2GEM2 + t_2GEM3 + t_2PAD; - - double phi_2GEM2 = 0.0492538; - double phi_2GEM3 = 0.0470817; - double phi_2PAD = 0.0612122; - double phi_gap = phi_2GEM2 + phi_2GEM3 + phi_2PAD; - - // find position from Cell ID - //for (double s = 0.0; s < cellID.size(); s++) { - - double chan=0; - double t_s2pad = 0; - double dphi=0; - double dz=0; - double x_rec = 0; - double y_rec = 0; - - - double z_pad=0; - double z_rec=0; - double z_hit=0; // position of the hit on a single pad in z - double delta_z=0; - - double r_pos=0; - double r_rec=0; - double r_temp=0; - double delta_r=0; - - double phi_pad=0; - double phi_rec=0; - double phi_pos = 0; - - double t_calc = 0; - - - - // generated position of ionization in phi - - phi_pos = Math.atan2(Y, X); - - // generated position of ionization in s - r_pos=Math.sqrt(((X)*(X))+((Y)*(Y))); - //System.out.println(r_pos + " " + X + " " + Y); - - - // ------------------ find z and phi of pad from CellID ------------------ - chan = (double)cellID; - - double col = chan%Num_of_Cols; - double row=(chan-col)/Num_of_Cols; - double z_shift = row%4; - //double z_shift = 0.; - //System.out.println(row + " " + chan + " " + col + " " + phi_per_pad); - phi_pad=(row*phi_per_pad)+(phi_per_pad/2.0); - while(phi_pad >= 2*PI || phi_pad < 0) - { - if(phi_pad>= 2.0*PI) { - phi_pad -= 2.0*PI; - } - if(phi_pad<0) - { - phi_pad += 2.0*PI; - } - } - z_pad=z0+(col*PAD_L)+(PAD_L/2.0)+z_shift; - // ----------------------------------------------------------------------- - dz=0; - z_rec=z_pad-dz; - - // find reconstructed position of ionization from Time info - - double a_t = get_rec_coef(a_t1,a_t2,a_t3,a_t4,a_t5,z_rec); - double b_t = get_rec_coef(b_t1,b_t2,b_t3,b_t4,b_t5,z_rec); - - - - double a_phi = get_rec_coef(a_phi1,a_phi2,a_phi3,a_phi4,a_phi5,z_rec); - double b_phi = get_rec_coef(b_phi1,b_phi2,b_phi3,b_phi4,b_phi5,z_rec); - - //System.out.println(a_t + " " + b_t + " " + a_phi + " " + b_phi + " " + z_rec); - - t_s2pad = Time-t_gap; - - r_rec = ((-(Math.sqrt(a_t*a_t+(4*b_t*t_s2pad)))+a_t+(14*b_t))/(2*b_t))*10.0; //in mm - t_calc = ((((2*b_t*r_pos*0.1)-(14*b_t)-a_t)*((2*b_t*r_pos*0.1)-14*b_t-a_t))-(a_t*a_t))*(1/(4*b_t)) + t_gap; - - - dphi=a_phi*(7-r_rec/10)+b_phi*(7-r_rec/10)*(7.-r_rec/10); // in rad - - - phi_rec=phi_pad-dphi-phi_gap; - while(phi_rec < 0 || phi_rec >= 2*PI) - { - if( phi_rec<0.0 ) - { - phi_rec+=2.0*PI; - } - if( phi_rec>2.0*PI ) - { - phi_rec-=2.0*PI; - } - } - //System.out.println("reconstructed phi " + phi_rec + " actual phi " + Math.atan(Y/X)); - - // x,y,z pos of reconstructed track - x_rec=r_rec*(Math.cos(phi_rec)); - y_rec=r_rec*(Math.sin(phi_rec)); - //System.out.println("rec " + x_rec + " " + y_rec + " " + phi_rec + " " + r_rec + " " + Time); - //if(true) - //if(counter > 2500) - //if(r_rec > 30 && r_rec < 70) - //if(Math.abs(x_rec-X) < 3 && Math.abs(y_rec-Y) < 3 && Math.abs(z_rec-Z) < 3) - //if(true) - //if(Math.abs(t_calc - Time) < timewindow) - /*if(draw){ - if(hit.get_TShift() == 0) - { - //System.out.println(t_calc + " " + Time); - grz.addPoint(r_rec, z_rec, 0, 0); - gxy.addPoint(x_rec, y_rec, 0, 0); - //if(counter <= 53) - //{ - g1rz.addPoint(Math.sqrt(X*X+Y*Y), Z, 0, 0); - g1xy.addPoint(X, Y, 0, 0); - g2xy.addPoint(0, 0, 0, 0); - gerrorxvsphi.addPoint(Math.atan2(Y,X),Math.pow(Math.abs(x_rec-X),2)/X,0,0); - gerroryvsphi.addPoint(Math.atan2(Y,X),Math.pow(Math.abs(y_rec-Y),2)/Y,0,0); - //} - //System.out.println(counter); - } - else - { - //g2xy.addPoint(X, Y, 0, 0); - g2xy.addPoint(0, 0, 0, 0); - grz.addPoint(0, 0, 0, 0); - g1rz.addPoint(0, 0, 0, 0); - gxy.addPoint(0, 0, 0, 0); - g1xy.addPoint(0, 0, 0, 0); - } - } - //} - // x,y,z pos of pad hit - //x_pad=(PAD_S)*(Math.cos(phi_pad)); - //y_pad=(PAD_S)*(Math.sin(phi_pad)); - - // actual position on pad of hits - //phi_hit=phi_rad-(row*phi_per_pad); - //z_hit=Z-z0-(col*PAD_L)-z_shift; - - // find differences (delta = generated-reconstructed) - //delta_x=X-x_rec; - //delta_y=Y-y_rec; - //delta_z=Z-z_rec; - //delta_r=r_pos-r_rec; - //delta_phi = phi_pos-phi_rec; - //System.out.println(X + " " + x_rec); - //System.out.println(r_pos + " " + r_rec); - - */ - - /*hit.set_cellID(cellID); - hit.set_Time(t_s2pad); - hit.set_Edep(Edep); - hit.set_PosX(x_rec); - hit.set_PosY(y_rec); - hit.set_PosZ(z_rec); - TimeVec.add(t_s2pad); - XVec.add(x_rec); - YVec.add(y_rec); - ZVec.add(z_rec);*/ - //} - counter++; - } - } - if(draw){ - /*EmbeddedCanvas c = new EmbeddedCanvas(); - EmbeddedCanvas c2 = new EmbeddedCanvas(); - EmbeddedCanvas c3 = new EmbeddedCanvas(); - EmbeddedCanvas c4 = new EmbeddedCanvas(); - //System.out.println(counter); - GraphErrors g2 = new GraphErrors(); - double theta = 0; - double test_x = 0; - double test_y = 0; - double test_x2 = 0; - double test_y2 = 0; - while(theta <= 2*Math.PI) - { - test_x = 30 * Math.cos(theta); - test_y = 30 * Math.sin(theta); - test_x2 = 70 * Math.cos(theta); - test_y2 = 70 * Math.sin(theta); - g2.addPoint(test_x, test_y, 0, 0); - g2.addPoint(test_x2, test_y2, 0, 0); - theta+=0.01; - } - int color = 2; - int shape = 1; - for(int key : graphmap.keySet()) - { - double szPos[][] = new double[recohitvector.get(key).size()][3]; - for(int i = 0; i < recohitvector.get(key).size(); i++) { - szPos[i][0] = recohitvector.get(key).get(i).x(); - szPos[i][1] = recohitvector.get(key).get(i).y(); - szPos[i][2] = recohitvector.get(key).get(i).z(); - } - //double R = 0; double A = 0; double B = 0; double Phi_deg = 0; double Theta_deg = 0; double Z0 = 0; int fit_track_to_beamline = 1; - //HelixFitJava hf = new HelixFitJava(); - //hf.HelixFit(recohitvector.get(key).size(), szPos, R, A, B, Phi_deg, Theta_deg, Z0, fit_track_to_beamline); - //System.out.println(key + " " + R); - if(false) - //if(key == 3) - { - graphmap.get(key).setMarkerSize(6); - graphmap2.get(key).setMarkerSize(6); - } - else { - graphmap.get(key).setMarkerSize(3); - graphmap.get(key).setMarkerColor(color); - graphmap.get(key).setMarkerStyle(shape); - - - graphmap2.get(key).setMarkerSize(3); - graphmap2.get(key).setMarkerColor(color); - graphmap2.get(key).setMarkerStyle(shape); - - } - c.draw(graphmap.get(key),"same"); - c2.draw(graphmap2.get(key),"same"); - color++; - if(color > 7) - { - color -= 6; - shape++; - } - } - grz.setMarkerSize(3); - grz.setMarkerColor(1); - g1rz.setMarkerSize(2); - g1rz.setMarkerColor(2); - //grz.addPoint(30, -200, 0, 0); - //grz.addPoint(70, 200, 0, 0); - gxy.setMarkerSize(2); - gxy.setMarkerColor(2); - g1xy.setMarkerSize(2); - g1xy.setMarkerColor(1); - g2xy.setMarkerSize(2); - g2xy.setMarkerColor(7); - g2.setMarkerSize(0); - g2.setMarkerColor(3); - gerrorxvsphi.setMarkerSize(2); - gerroryvsphi.setMarkerSize(2); - JFrame j = new JFrame(); - j.setSize(800,600); - JFrame j2 = new JFrame(); - j2.setSize(800,600); - JFrame j3 = new JFrame(); - j3.setSize(800,600); - JFrame j4 = new JFrame(); - j4.setSize(800,600); - c.draw(grz,"same"); - c.draw(g1rz,"same"); - c2.draw(gxy,"same"); - c2.draw(g1xy,"same"); - c2.draw(g2,"same"); - c2.draw(g2xy,"same"); - c3.divide(1, 2); - c3.cd(0); - c3.draw(gerrorxvsphi); - c3.cd(1); - c3.draw(gerroryvsphi); - //c4.draw(largetdist); - j.setTitle("RZ"); - j2.setTitle("XY"); - - - j.add(c); - j.setVisible(true); - j2.add(c2); - j2.setVisible(true); - //j3.add(c3); - //j3.setVisible(true); - j4.add(c4); - //j4.setVisible(true); - } - */ - } - //System.out.println(outsidedriftcounter + "/" + allhitscounter); - //params.set_alltracks(alltracks); - - params.set_recohitvector(recohitvector); - } - - double get_rec_coef(double t1, double t2, double t3, double t4, double t5, double z2) { - double z = z2/1000; - return t1*z*z*z*z + t2*z*z*z + t3*z*z + t4*z + t5; - - } - - -} - - - - diff --git a/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/TrackMap.java b/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/TrackMap.java deleted file mode 100644 index 8f51e288b0..0000000000 --- a/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/TrackMap.java +++ /dev/null @@ -1,60 +0,0 @@ -package org.jlab.rec.rtpc.hit; - -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.ConcurrentHashMap; -import java.util.HashMap; - -public class TrackMap { - - private HashMap _map; - private int _trackID = 0; - - public TrackMap() { - _map = new HashMap(); - } - - public void addTrack(Track t) { - _trackID++; - _map.put(_trackID, t); - } - - public Track getTrack(int trackID) { - if(!_map.containsKey(trackID)) { - addTrack(new Track()); - } - return _map.get(trackID); - } - - public void updateTrack(int trackID, Track t) { - _map.put(trackID, t); - } - - public void removeTrack(int trackID) { - _map.remove(trackID); - } - - public List getAllTrackIDs() { - List l = new ArrayList(); - for(int i : _map.keySet()) { - if(!l.contains(i)) { l.add(i);} - } - return l; - } - - public int getLastTrackID() { - return _trackID; - } - - public void mergeTracks(int trackIDparent, int trackID) { - Track child = getTrack(trackID); - List l = child.getAllTimeSlices(); - Track parent = getTrack(trackIDparent); - for(int time : l) { - parent.addTimeSlice(time,child.getTimeSlice(time)); - } - //updateTrack(trackIDparent, parent); - removeTrack(trackID); - } - -} diff --git a/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/TrackUtils.java b/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/TrackUtils.java deleted file mode 100644 index a8bf34306f..0000000000 --- a/reconstruction/src/main/java/org/jlab/rec/rtpc/hit/TrackUtils.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.jlab.rec.rtpc.hit; - -public class TrackUtils { - private double adjthresh = 16; - private double PhiDelta = 16; - private double ZDelta = 36; - private double phithresh = 0.16; - private double zthresh = 16; - - public TrackUtils() {} - - public boolean comparePads(PadVector p1, PadVector p2, String Method) { - if(Method == "ellipse") {return ellipseMethod(p1, p2);} - if(Method == "phiz") {return phizMethod(p1,p2);} - else return false; - } - - private boolean ellipseMethod(PadVector p1, PadVector p2) { - double p1x = p1.x(); - double p1y = p1.y(); - double p1z = p1.z(); - double p2x = p2.x(); - double p2y = p2.y(); - double p2z = p2.z(); - double EllipseDeltax = Math.abs(p1x-p2x)*Math.abs(p1x-p2x); - double EllipseDeltay = Math.abs(p1y-p2y)*Math.abs(p1y-p2y); - double EllipseDeltaz = Math.abs(p1z-p2z)*Math.abs(p1z-p2z); - double EllipseTotal = ((EllipseDeltax+EllipseDeltay)/PhiDelta) + (EllipseDeltaz/ZDelta); - if(EllipseTotal < adjthresh) return true; - return false; - } - - private boolean phizMethod(PadVector p1, PadVector p2) { - double p1phi = p1.phi(); - double p2phi = p2.phi(); - double p1z = p1.z(); - double p2z = p2.z(); - double phidiff = p2phi-p1phi; - double zdiff = Math.abs(p1z-p2z); - //System.out.println(p1phi + " " + p2phi + " " + (p1phi - p2phi)); - return ((Math.abs(phidiff) - - - - -org.jlab.rec.rtpc.hit - - -
Author:
ziegler
- - \ No newline at end of file diff --git a/reconstruction/src/main/java/org/jlab/rec/rtpc/package.html b/reconstruction/src/main/java/org/jlab/rec/rtpc/package.html deleted file mode 100644 index f0cd21cb47..0000000000 --- a/reconstruction/src/main/java/org/jlab/rec/rtpc/package.html +++ /dev/null @@ -1,14 +0,0 @@ - - - - - -org.jlab.rec.rtpc - - -
Author:
ziegler
- - \ No newline at end of file diff --git a/reconstruction/src/main/java/org/jlab/service/rtpc/RTPCEngine.java b/reconstruction/src/main/java/org/jlab/service/rtpc/RTPCEngine.java deleted file mode 100644 index f55a3df89e..0000000000 --- a/reconstruction/src/main/java/org/jlab/service/rtpc/RTPCEngine.java +++ /dev/null @@ -1,179 +0,0 @@ -package org.jlab.service.rtpc; - -import java.io.File; -import java.io.FileNotFoundException; - - -import java.util.ArrayList; -import java.util.List; - -import org.jlab.clas.reco.ReconstructionEngine; -//import org.jlab.coda.hipo.HipoException; -//import org.jlab.coda.jevio.EvioException; -import org.jlab.io.base.DataBank; -import org.jlab.io.base.DataEvent; -import org.jlab.io.hipo.HipoDataSource; -import org.jlab.io.hipo.HipoDataSync; -import org.jlab.rec.rtpc.banks.HitReader; -import org.jlab.rec.rtpc.banks.RecoBankWriter; -import org.jlab.rec.rtpc.banks.RecoBankWriter2; -import org.jlab.rec.rtpc.hit.Hit; -import org.jlab.rec.rtpc.hit.HitDistance; -import org.jlab.rec.rtpc.hit.HitParameters; -import org.jlab.rec.rtpc.hit.HitReconstruction; -import org.jlab.rec.rtpc.hit.MapCombine; -import org.jlab.rec.rtpc.hit.PadAve; -import org.jlab.rec.rtpc.hit.PadFit; -import org.jlab.rec.rtpc.hit.PadHit; -//import org.jlab.rec.rtpc.hit.PulseShapeAnalysis; -import org.jlab.rec.rtpc.hit.TimeAverage; -import org.jlab.rec.rtpc.hit.TimeAverage2; -//import org.jlab.rec.rtpc.hit.TrackDisentangler; -//import org.jlab.rec.rtpc.hit.TrackFinder; -import org.jlab.rec.rtpc.hit.TrackFinder2; -import org.jlab.rec.rtpc.hit.TrackFinder3; -import org.jlab.rec.rtpc.hit.TrackHitReco; -import org.jlab.rec.rtpc.hit.TrackHitReco2; -import org.jlab.rec.rtpc.hit.TrackHitReco3; - - - - -public class RTPCEngine extends ReconstructionEngine{ - - int test = 0; - int swtch = 2; - - - public RTPCEngine() { - super("RTPC","charlesg","3.0"); - } - - @Override - public boolean init() { - // TODO Auto-generated method stub - return true; - } - - @Override - public boolean processDataEvent(DataEvent event) { - HitParameters params = new HitParameters(); - HitReader hitRead = new HitReader(); - hitRead.fetch_RTPCHits(event); - - List hits = new ArrayList(); - //I) get the hits - hits = hitRead.get_RTPCHits(); - - //II) process the hits - //1) exit if hit list is empty - if(hits==null || hits.size()==0) { - return true; - } - if(event.hasBank("RTPC::pos")) - { - PadHit phit = new PadHit(); - phit.bonus_shaping(hits,params); - PadFit pfit = new PadFit(); - pfit.Fitting(params); - -// PulseShapeAnalysis psa = new PulseShapeAnalysis(); -// psa.PSA(params); - - //TrackFinder TF = new TrackFinder(); - //TF.FindTrack(params); - if(swtch == 1) //outdated build - { - HitDistance HD = new HitDistance(); - HD.FindDistance(params); - } - else if(swtch == 2) { //current build only use this one - TrackFinder3 TF = new TrackFinder3(params,false); - TimeAverage2 TA2 = new TimeAverage2(params,false); - //TrackDisentangler TD = new TrackDisentangler(params,true); - TrackHitReco3 TR3 = new TrackHitReco3(hits,params,false); - RecoBankWriter2 writer = new RecoBankWriter2(); - DataBank recoBank = writer.fillRTPCHitsBank(event, params); - event.appendBanks(recoBank); - } - else //outdated build - { - TrackFinder2 TF = new TrackFinder2(); - TF.FindTrack2(params,false); - TimeAverage TA = new TimeAverage(); - TA.TA(params,false); - MapCombine MC = new MapCombine(); - MC.MC(params,false); - /*TrackHitReco TR = new TrackHitReco(); - TR.Reco(hits,params);*/ - TrackHitReco2 TR = new TrackHitReco2(); - TR.Reco(hits,params,false); - RecoBankWriter2 writer = new RecoBankWriter2(); - DataBank recoBank = writer.fillRTPCHitsBank(event, params); - event.appendBanks(recoBank); - //recoBank.show(); - } - - } - else - { - return true; - } - - /* - for(Hit h : hits) { - System.out.println("Hit "+h.get_Id()+" CellID "+h.get_cellID()+" ADC "+h.get_ADC()+" true Edep "+h.get_EdepTrue()+" Edep "+h.get_Edep()+" Time "+h.get_Time()+" "+ - " true X "+h.get_PosXTrue()+" X "+h.get_PosX()+" true Y "+h.get_PosYTrue()+" Y "+h.get_PosY()+" true Z "+h.get_PosZTrue()+" Z "+h.get_PosZ()); - }*/ - - - - - return true; - } - - public static void main(String[] args){ - double starttime = System.nanoTime(); - //String inputFile = "/Users/davidpayette/Desktop/5c.2.3/clara/installation/plugins/clas12/2_72_516.hipo"; - //String inputFile = "/Users/davidpayette/Desktop/5c.2.3/clara/installation/plugins/clas12/1000_1_711.hipo"; - //String inputFile = "/Users/davidpayette/Desktop/5c.2.3/clara/installation/plugins/clas12/100_20_731.hipo"; - //String inputFile = "/Users/davidpayette/Desktop/5c.3.5/clara/installation/plugins/clas12/test.hipo"; - //String inputFile = "/Users/davidpayette/Desktop/5b.7.4/myClara/1212.hipo"; - //String inputFile = "/Users/davidpayette/Desktop/5b.7.4/myClara/plugins/clas12/Jantest.hipo"; - String inputFile = "/Users/davidpayette/Desktop/5b.7.4/myClara/plugins/clas12/newfeb.hipo"; - //String inputFile = "/Users/davidpayette/Desktop/Distribution/clas12-offline-software/1212again.hipo"; - //String inputFile = "/Users/davidpayette/Desktop/5c.2.3/clara/installation/plugins/clas12/100_20_802.hipo"; - //String inputFile = "/Users/davidpayette/Desktop/5c.2.3/clara/installation/plugins/clas12/10p.hipo"; - //String inputFile = args[0]; - String outputFile = "/Users/davidpayette/Desktop/5b.7.4/myClara/tout_working.hipo"; - - System.err.println(" \n[PROCESSING FILE] : " + inputFile); - - RTPCEngine en = new RTPCEngine(); - en.init(); - - - - HipoDataSource reader = new HipoDataSource(); - HipoDataSync writer = new HipoDataSync(); - reader.open(inputFile); - writer.open(outputFile); - System.out.println("starting " + starttime); - - File f1= new File("/Users/davidpayette/Documents/FileOutput/PulseShapeAll.txt"); - File f2= new File("/Users/davidpayette/Documents/FileOutput/PulseShapeMax.txt"); - File f3= new File("/Users/davidpayette/Documents/FileOutput/PulseShapeAllOverMax.txt"); - f1.delete(); - f2.delete(); - f3.delete(); - - while(reader.hasEvent()){ - - DataEvent event = reader.getNextEvent(); - en.processDataEvent(event); - writer.writeEvent(event); - } - writer.close(); - System.out.println("finished " + (System.nanoTime() - starttime)*Math.pow(10,-9)); - } -} diff --git a/reconstruction/src/main/java/org/jlab/service/rtpc/package-info.java b/reconstruction/src/main/java/org/jlab/service/rtpc/package-info.java deleted file mode 100644 index fb4baf2083..0000000000 --- a/reconstruction/src/main/java/org/jlab/service/rtpc/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** - * - */ -/** - * @author ziegler - * - */ -package org.jlab.service.rtpc; \ No newline at end of file From 1367d5799731d26668136e344f2aa2f25ebd2cb0 Mon Sep 17 00:00:00 2001 From: dcpayette Date: Tue, 9 Jul 2019 23:22:10 -0400 Subject: [PATCH 009/235] updated rtpc.json to fix bug --- etc/bankdefs/hipo4/rtpc.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/bankdefs/hipo4/rtpc.json b/etc/bankdefs/hipo4/rtpc.json index 26708e6694..b55919208a 100644 --- a/etc/bankdefs/hipo4/rtpc.json +++ b/etc/bankdefs/hipo4/rtpc.json @@ -4,7 +4,7 @@ "group": 1720, "item" : 1, "info": "reconstructed RTPC hits", - "items": [ + "entries": [ {"name":"TID", "type":"I", "info":"Track ID of the hit"}, {"name":"cellID", "type":"I", "info":"cell id"}, {"name":"time", "type":"F", "info":"Time (ns)"}, From f9a48fb37714c5e857e4eaafea6e2fd5655e9fc6 Mon Sep 17 00:00:00 2001 From: ziegler Date: Mon, 29 Jul 2019 13:52:10 -0400 Subject: [PATCH 010/235] Implementation of DC endplates bowing (sector-dependent) in DC geometry and use of geometry in reconstruction. --- .../jlab/detector/base/GeometryFactory.java | 1 + .../detector/geant4/v2/DCGeant4Factory.java | 146 +++++++++++++----- .../jlab/detector/geom/dc/DCGeantFactory.java | 2 +- .../java/org/jlab/rec/dc/hit/FittedHit.java | 13 +- .../rec/dc/timetodistance/T2DFunctions.java | 2 - .../java/org/jlab/service/dc/DCEngine.java | 15 +- .../jlab/service/dc/TrackDictionaryMaker.java | 2 +- .../service/dc/TrackDictionaryMakerRNG.java | 2 +- 8 files changed, 124 insertions(+), 59 deletions(-) diff --git a/common-tools/clas-detector/src/main/java/org/jlab/detector/base/GeometryFactory.java b/common-tools/clas-detector/src/main/java/org/jlab/detector/base/GeometryFactory.java index c8cf35c2de..ff0eededb6 100644 --- a/common-tools/clas-detector/src/main/java/org/jlab/detector/base/GeometryFactory.java +++ b/common-tools/clas-detector/src/main/java/org/jlab/detector/base/GeometryFactory.java @@ -46,6 +46,7 @@ public static ConstantProvider getConstants(DetectorType type, int run, String v provider.loadTable("/geometry/dc/layer"); provider.loadTable("/geometry/dc/alignment"); provider.loadTable("/geometry/dc/ministagger"); + provider.loadTable("/geometry/dc/endplatesbow"); } if(type==DetectorType.ECAL){ diff --git a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/DCGeant4Factory.java b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/DCGeant4Factory.java index 09db12ee8e..e299c542c8 100644 --- a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/DCGeant4Factory.java +++ b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/DCGeant4Factory.java @@ -47,6 +47,8 @@ final class DCdatabase { private final double align_dthetax[][] = new double[nSectors][nRegions]; private final double align_dthetay[][] = new double[nSectors][nRegions]; private final double align_dthetaz[][] = new double[nSectors][nRegions]; + + private final double endplatesbow[][][] = new double[nSectors][nRegions][2]; private int nsensewires; private int nguardwires; @@ -54,6 +56,8 @@ final class DCdatabase { private boolean ministaggerStatus = false; private double ministagger ; + private boolean endplatesStatus = false; + private final String dcdbpath = "/geometry/dc/"; private static DCdatabase instance = null; @@ -94,19 +98,27 @@ public void connect(ConstantProvider cp) { superwidth[isuper] = wpdist[isuper] * (nsenselayers[isuper] + nguardlayers[isuper] - 1) * cellthickness[isuper]; } - int alignrows = cp.length(dcdbpath+"alignment/dx"); - for(int irow = 0; irow< alignrows; irow++) { - int isec = cp.getInteger(dcdbpath + "alignment/sector",irow)-1; - int ireg = cp.getInteger(dcdbpath + "alignment/region",irow)-1; + int alignrows = cp.length(dcdbpath+"alignment/dx"); + for(int irow = 0; irow< alignrows; irow++) { + int isec = cp.getInteger(dcdbpath + "alignment/sector",irow)-1; + int ireg = cp.getInteger(dcdbpath + "alignment/region",irow)-1; - align_dx[isec][ireg]=cp.getDouble(dcdbpath + "alignment/dx",irow); - align_dy[isec][ireg]=cp.getDouble(dcdbpath + "alignment/dy",irow); - align_dz[isec][ireg]=cp.getDouble(dcdbpath + "alignment/dz",irow); + align_dx[isec][ireg]=cp.getDouble(dcdbpath + "alignment/dx",irow); + align_dy[isec][ireg]=cp.getDouble(dcdbpath + "alignment/dy",irow); + align_dz[isec][ireg]=cp.getDouble(dcdbpath + "alignment/dz",irow); - align_dthetax[isec][ireg]=cp.getDouble(dcdbpath + "alignment/dtheta_x",irow); - align_dthetay[isec][ireg]=cp.getDouble(dcdbpath + "alignment/dtheta_y",irow); - align_dthetaz[isec][ireg]=cp.getDouble(dcdbpath + "alignment/dtheta_z",irow); - } + align_dthetax[isec][ireg]=cp.getDouble(dcdbpath + "alignment/dtheta_x",irow); + align_dthetay[isec][ireg]=cp.getDouble(dcdbpath + "alignment/dtheta_y",irow); + align_dthetaz[isec][ireg]=cp.getDouble(dcdbpath + "alignment/dtheta_z",irow); + } + + int endplatesrows = cp.length(dcdbpath+"endplatesbow/coefficient"); + for(int irow = 0; irow< endplatesrows; irow++) { + int isec = cp.getInteger(dcdbpath + "endplatesbow/sector",irow)-1; + int ireg = cp.getInteger(dcdbpath + "endplatesbow/region",irow)-1; + int order = cp.getInteger(dcdbpath + "endplatesbow/order",irow); + endplatesbow[isec][ireg][order] = cp.getDouble(dcdbpath+"endplatesbow/coefficient", irow)*Length.cm; + } } public double dist2tgt(int ireg) { @@ -200,7 +212,19 @@ public void setMinistaggerStatus(boolean ministaggerStatus) { public boolean getMinistaggerStatus(){ return ministaggerStatus; } + + public double endplatesbow(int isec, int ireg, int order) { + return endplatesbow[isec][ireg][order]; + } + + public void setEndPlatesStatus(boolean endplatesStatus) { + this.endplatesStatus = endplatesStatus; + } + public boolean getEndPlatesStatus(){ + return endplatesStatus; + } + public double getAlignmentThetaX(int isec, int ireg) { return align_dthetax[isec][ireg]; } @@ -220,10 +244,11 @@ public Vector3d getAlignmentShift(int isec, int ireg) { final class Wire { + private final int sector; private final int ireg; private final int isuper; - private final int ilayer; - private final int iwire; + private final int layer; + private final int wire; private final DCdatabase dbref = DCdatabase.getInstance(); private final Vector3d midpoint; @@ -290,11 +315,50 @@ private void findEnds() { rightend = direction.times(wlenr).add(midpoint); } - public Wire(int isuper, int ilayer, int iwire) { - this.isuper = isuper; - this.ilayer = ilayer; - this.iwire = iwire; - this.ireg = isuper / 2; + /** + * Correct for endplates bowing in tilted coordinate system. + */ + public void correctEnds() { + double iwirn = (double) wire/112.0; + //deflection function + double defFunc = iwirn - 3 * iwirn*iwirn*iwirn +2 * iwirn*iwirn*iwirn*iwirn; + //max deflection for L and R sides of wire + double deflMaxL = dbref.endplatesbow(sector-1, ireg, 0); + double deflMaxR = dbref.endplatesbow(sector-1, ireg, 1); + //deflection of the L and R sides + double deflL = 0.5 * deflMaxL * defFunc; + double deflR = 0.5 * deflMaxR * defFunc; + + double xL = leftend.x + deflL; + double xR = rightend.x + deflR; + double yL = leftend.y; + double yR = rightend.y; + + // the uncorrected wirelength. We assume the wire length is not changing + double wlenl = leftend.sub(midpoint).magnitude(); + double wlenr = rightend.sub(midpoint).magnitude(); + //get the modified wire direction + double n = Math.sqrt((xR - xL)*(xR - xL)+(yR - yL)*(yR - yL)); + direction.set((xR - xL)/n, (yR - yL)/n, 0); + // midpoint corresponds to y = 0 + midpoint.set(xR -yR*((xR-xL)/(yR-yL)), 0, midpoint.z); + //get left and right ends assuming the wire length is not changing + leftend = direction.times(-wlenl).add(midpoint); + rightend = direction.times(wlenr).add(midpoint); + } + /** + * + * @param sector sector 1...6 + * @param super superlayer index 0...5 + * @param layer layer 1...6 + * @param wire wire 1...112 + */ + public Wire(int sector, int isuperl, int layer, int wire) { + this.sector = sector; + this.isuper = isuperl; + this.layer = layer; + this.wire = wire; + this.ireg = isuper / 2; // calculate first-wire distance from target double w2tgt = dbref.dist2tgt(ireg); @@ -315,13 +379,13 @@ public Wire(int isuper, int ilayer, int iwire) { double dw2 = dw / cster; // hh: wire distance in the wire plane - double hh = (iwire-1 + ((double)(ilayer % 2)) / 2.0) * dw2; - if(ireg==2 && isSensitiveWire(isuper, ilayer, iwire) && dbref.getMinistaggerStatus()) - hh += ((ilayer%2)*2-1)*dbref.ministagger(); + double hh = (wire-1 + ((double)(layer % 2)) / 2.0) * dw2; + if(ireg==2 && isSensitiveWire(isuper, layer, wire) && dbref.getMinistaggerStatus()) + hh += ((layer%2)*2-1)*dbref.ministagger(); // ll: layer distance double tt = dbref.cellthickness(isuper) * dbref.wpdist(isuper); - double ll = ilayer * tt; + double ll = layer * tt; // wire x=0 coordinates in the lab double ym = y0mid + ll * stilt + hh * ctilt; @@ -398,16 +462,21 @@ public final class DCGeant4Factory extends Geant4Factory { public static boolean MINISTAGGERON=true; public static boolean MINISTAGGEROFF=false; + + public static boolean ENDPLATESBOWON=true; + public static boolean ENDPLATESBOWOFF=false; /////////////////////////////////////////////////// public DCGeant4Factory(ConstantProvider provider) { - this(provider, MINISTAGGEROFF); + this(provider, MINISTAGGEROFF, ENDPLATESBOWOFF); } /////////////////////////////////////////////////// - public DCGeant4Factory(ConstantProvider provider, boolean ministaggerStatus) { + public DCGeant4Factory(ConstantProvider provider, boolean ministaggerStatus, + boolean endplatesStatus) { dbref.setMinistaggerStatus(ministaggerStatus); - + dbref.setEndPlatesStatus(endplatesStatus); + motherVolume = new G4World("fc"); dbref.connect(provider); @@ -448,11 +517,11 @@ public DCGeant4Factory(ConstantProvider provider, boolean ministaggerStatus) { for(int ilayer=0; ilayer Wl6) { private void resetGeom(String geomDBVar) { ConstantProvider provider = GeometryFactory.getConstants(DetectorType.DC, 11, Optional.ofNullable(geomDBVar).orElse("default")); - dcDetector = new DCGeant4Factory(provider, DCGeant4Factory.MINISTAGGERON); + dcDetector = new DCGeant4Factory(provider, DCGeant4Factory.MINISTAGGERON, DCGeant4Factory.ENDPLATESBOWON); for(int l=0; l<6; l++) { Constants.wpdist[l] = provider.getDouble("/geometry/dc/superlayer/wpdist", l); diff --git a/reconstruction/dc/src/main/java/org/jlab/service/dc/TrackDictionaryMakerRNG.java b/reconstruction/dc/src/main/java/org/jlab/service/dc/TrackDictionaryMakerRNG.java index 0aaeae68d3..86bbd680eb 100644 --- a/reconstruction/dc/src/main/java/org/jlab/service/dc/TrackDictionaryMakerRNG.java +++ b/reconstruction/dc/src/main/java/org/jlab/service/dc/TrackDictionaryMakerRNG.java @@ -669,7 +669,7 @@ public void setWl6(List Wl6) { private void resetGeom(String geomDBVar) { ConstantProvider provider = GeometryFactory.getConstants(DetectorType.DC, 11, Optional.ofNullable(geomDBVar).orElse("default")); - dcDetector = new DCGeant4Factory(provider, DCGeant4Factory.MINISTAGGERON); + dcDetector = new DCGeant4Factory(provider, DCGeant4Factory.MINISTAGGERON, DCGeant4Factory.ENDPLATESBOWON); for(int l=0; l<6; l++) { Constants.wpdist[l] = provider.getDouble("/geometry/dc/superlayer/wpdist", l); From a917f451ee66ca97ddfc3d00313a87f78d22a0d9 Mon Sep 17 00:00:00 2001 From: ziegler Date: Mon, 29 Jul 2019 16:11:54 -0400 Subject: [PATCH 011/235] add scale factor to deflection function so that its max is 1. --- .../java/org/jlab/detector/geant4/v2/DCGeant4Factory.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/DCGeant4Factory.java b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/DCGeant4Factory.java index e299c542c8..a716981629 100644 --- a/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/DCGeant4Factory.java +++ b/common-tools/clas-jcsg/src/main/java/org/jlab/detector/geant4/v2/DCGeant4Factory.java @@ -316,12 +316,12 @@ private void findEnds() { } /** - * Correct for endplates bowing in tilted coordinate system. + * Correct for endplates bowing in tilted coordinate system. (ziegler) */ public void correctEnds() { double iwirn = (double) wire/112.0; - //deflection function - double defFunc = iwirn - 3 * iwirn*iwirn*iwirn +2 * iwirn*iwirn*iwirn*iwirn; + //deflection function has to be 1 at extremum (3.8465409 scales it so it is 1 at first derivative) + double defFunc = 3.8465409*(iwirn - 3 * iwirn*iwirn*iwirn +2 * iwirn*iwirn*iwirn*iwirn); //max deflection for L and R sides of wire double deflMaxL = dbref.endplatesbow(sector-1, ireg, 0); double deflMaxR = dbref.endplatesbow(sector-1, ireg, 1); @@ -547,7 +547,7 @@ public DCGeant4Factory(ConstantProvider provider, boolean ministaggerStatus, .rotateZ(Math.toRadians(-isec * 60)) .rotateY(-dbref.thtilt(isuper/2)); - //implement end-plates bow in the tilted sector coordinate system + //implement end-plates bow in the tilted sector coordinate system (ziegler) wires[isec][isuper][ilayer][iwire].correctEnds(); //dc alignment implementation wires[isec][isuper][ilayer][iwire].translate(regionMids[isec][isuper/2].times(-1.0)); From 8fd5be0d1f9288ba236f5e84d3795e2efa3a67be Mon Sep 17 00:00:00 2001 From: baltzell Date: Mon, 29 Jul 2019 17:27:17 -0400 Subject: [PATCH 012/235] remove defunct jaw script --- bin/jaw | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100755 bin/jaw diff --git a/bin/jaw b/bin/jaw deleted file mode 100755 index 84955d6b99..0000000000 --- a/bin/jaw +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh -f - -source `dirname $0`/env.sh - -java -Dsun.java2d.pmoffscreen=false -Xms1024m -Xmx2048m -cp "$DATAMINING/lib/utils/*" org.jlab.jnp.math.cli.MathCli $* - -#********************************************************* -#--------------------------------------------------------- -# JHEP math CLI interface. -#--------------------------------------------------------- -#java -cp "target/jnp-math-1.0-SNAPSHOT-jar-with-dependencies.jar" org.jlab.jnp.math.cli.MathCli $* From 07038d96bf095601bd7bfbc0bd9fa6a3273f4bdf Mon Sep 17 00:00:00 2001 From: baltzell Date: Tue, 30 Jul 2019 08:32:06 -0400 Subject: [PATCH 013/235] rename to something more appropriate --- bin/{dclayereffs-anal => dclayereffs-ana} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename bin/{dclayereffs-anal => dclayereffs-ana} (100%) diff --git a/bin/dclayereffs-anal b/bin/dclayereffs-ana similarity index 100% rename from bin/dclayereffs-anal rename to bin/dclayereffs-ana From 24c9153cac75f2ad78cda500390c652580c2fa4d Mon Sep 17 00:00:00 2001 From: baltzell Date: Tue, 30 Jul 2019 09:09:20 -0400 Subject: [PATCH 014/235] move defunct scripts --- {bin => bin.old}/analyzer | 0 {bin => bin.old}/calibration | 0 {bin => bin.old}/clara-rec | 0 {bin => bin.old}/debug_ec.sh | 0 {bin => bin.old}/decoder-debugger | 0 {bin => bin.old}/eb-monitor | 0 {bin => bin.old}/ec-monitor | 0 {bin => bin.old}/gemc-evio | 0 {bin => bin.old}/grid | 0 {bin => bin.old}/pion | 0 {bin => bin.old}/rec-monitor | 0 {bin => bin.old}/update | 0 12 files changed, 0 insertions(+), 0 deletions(-) rename {bin => bin.old}/analyzer (100%) rename {bin => bin.old}/calibration (100%) rename {bin => bin.old}/clara-rec (100%) rename {bin => bin.old}/debug_ec.sh (100%) rename {bin => bin.old}/decoder-debugger (100%) rename {bin => bin.old}/eb-monitor (100%) rename {bin => bin.old}/ec-monitor (100%) rename {bin => bin.old}/gemc-evio (100%) rename {bin => bin.old}/grid (100%) rename {bin => bin.old}/pion (100%) rename {bin => bin.old}/rec-monitor (100%) rename {bin => bin.old}/update (100%) diff --git a/bin/analyzer b/bin.old/analyzer similarity index 100% rename from bin/analyzer rename to bin.old/analyzer diff --git a/bin/calibration b/bin.old/calibration similarity index 100% rename from bin/calibration rename to bin.old/calibration diff --git a/bin/clara-rec b/bin.old/clara-rec similarity index 100% rename from bin/clara-rec rename to bin.old/clara-rec diff --git a/bin/debug_ec.sh b/bin.old/debug_ec.sh similarity index 100% rename from bin/debug_ec.sh rename to bin.old/debug_ec.sh diff --git a/bin/decoder-debugger b/bin.old/decoder-debugger similarity index 100% rename from bin/decoder-debugger rename to bin.old/decoder-debugger diff --git a/bin/eb-monitor b/bin.old/eb-monitor similarity index 100% rename from bin/eb-monitor rename to bin.old/eb-monitor diff --git a/bin/ec-monitor b/bin.old/ec-monitor similarity index 100% rename from bin/ec-monitor rename to bin.old/ec-monitor diff --git a/bin/gemc-evio b/bin.old/gemc-evio similarity index 100% rename from bin/gemc-evio rename to bin.old/gemc-evio diff --git a/bin/grid b/bin.old/grid similarity index 100% rename from bin/grid rename to bin.old/grid diff --git a/bin/pion b/bin.old/pion similarity index 100% rename from bin/pion rename to bin.old/pion diff --git a/bin/rec-monitor b/bin.old/rec-monitor similarity index 100% rename from bin/rec-monitor rename to bin.old/rec-monitor diff --git a/bin/update b/bin.old/update similarity index 100% rename from bin/update rename to bin.old/update From 5034666675aa23f320c247a1cddc15059e2105e1 Mon Sep 17 00:00:00 2001 From: baltzell Date: Wed, 31 Jul 2019 09:35:14 -0400 Subject: [PATCH 015/235] bin scripts cleanup --- bin.old/analyzer | 16 +--------------- bin.old/calibration | 17 +---------------- bin.old/debug_ec.sh | 15 +-------------- bin.old/decoder-debugger | 16 +--------------- bin.old/eb-monitor | 15 +-------------- bin.old/ec-monitor | 15 +-------------- bin.old/gemc-evio | 15 +-------------- bin.old/grid | 15 +-------------- bin.old/pion | 16 +--------------- bin.old/rec-monitor | 15 +-------------- bin.old/update | 19 +++---------------- bin/bos2hipo | 16 +--------------- bin/browser | 15 +-------------- bin/convertor | 16 +--------------- bin/daq-monitor | 15 +-------------- bin/daqEventViewer | 15 +-------------- bin/dclayereffs-ana | 16 +--------------- bin/ddr | 18 +----------------- bin/decoder | 12 +----------- bin/decoder3 | 17 +---------------- bin/dict-maker | 15 +-------------- bin/dict-merge | 15 +-------------- bin/dict-validate | 15 +-------------- bin/env.sh | 7 ++++--- bin/evio-viewer | 16 +--------------- bin/evio2hipo | 16 +--------------- bin/eviocure | 16 +--------------- bin/eviodump | 15 +-------------- bin/hadd | 15 +-------------- bin/hipo-utils | 17 +---------------- bin/hipo-writer | 16 +--------------- bin/hipo3utils | 17 +---------------- bin/kpp-plots | 16 +--------------- bin/mon12 | 16 +--------------- bin/recon-util | 15 +-------------- bin/run-groovy | 12 ++++++------ bin/studio | 15 +-------------- bin/x-client | 14 +------------- bin/x-client-evio | 14 +------------- bin/x-server | 18 +----------------- 40 files changed, 50 insertions(+), 564 deletions(-) diff --git a/bin.old/analyzer b/bin.old/analyzer index 446f4ba71b..cd3152725e 100755 --- a/bin.old/analyzer +++ b/bin.old/analyzer @@ -2,18 +2,4 @@ source `dirname $0`/env.sh -#CLARA_HOME=`dirname $0` -#CLARA_SERVICES=`dirname $0` -#DATAMINING=`dirname $0` - -echo +------------------------------------------------------------------------- -echo "| Starting CLARA-PLATFORM with CLARA_SERVICES = " $CLARA_SERVICES -echo +------------------------------------------------------------------------- -echo "\n" - -echo "INSTALLATION DIRECTORY = " $CLARA_HOME -echo "LIBRARY DIRECTORY = " $DATAMINING/lib/clas/ - -#java -cp "$DATAMINING/lib/clas/core/*" org.jlab.coda.eventViewer.EventTreeFrame $* -#java -Xms1024m -cp "$DATAMINING/lib/clas/*:$DATAMINING/lib/plugins/*" org.jlab.io.hipo.HipoDataSync $* -java -Xms1024m -cp "$DATAMINING/lib/clas/*:$DATAMINING/lib/plugins/*" org.jlab.clas.physics.DataAnalysis $* +java -Xms1024m -cp "$CLAS12DIR/lib/clas/*:$CLAS12DIR/lib/plugins/*" org.jlab.clas.physics.DataAnalysis $* diff --git a/bin.old/calibration b/bin.old/calibration index 091339cd42..f30041ab7f 100755 --- a/bin.old/calibration +++ b/bin.old/calibration @@ -2,19 +2,4 @@ source `dirname $0`/env.sh -#CLARA_HOME=`dirname $0` -#CLARA_SERVICES=`dirname $0` -#DATAMINING=`dirname $0` - -echo +------------------------------------------------------------------------- -echo "| Starting CLARA-PLATFORM with CLARA_SERVICES = " $CLARA_SERVICES -echo +------------------------------------------------------------------------- -echo "\n" - -echo "INSTALLATION DIRECTORY = " $CLARA_HOME -echo "LIBRARY DIRECTORY = " $DATAMINING/lib/clas/ - -#java -cp "$DATAMINING/lib/clas/core/*" org.jlab.coda.eventViewer.EventTreeFrame $* -#java -XX:+UseSerialGC -Xms1024m -cp "$DATAMINING/lib/clas/*:$DATAMINING/lib/plugins/*" org.jlab.clasrec.rec.CLASReconstruction $* -#java -XX:+UseSerialGC -Xmx2048m -Xms2048m -cp "$DATAMINING/lib/clas/*:$DATAMINING/lib/plugins/*" org.jlab.detector.calib.tasks.CalibrationEngineTask $* -java -XX:+UseSerialGC -Xmx2048m -Xms2048m -cp "$DATAMINING/lib/clas/*:$DATAMINING/lib/plugins/*" org.jlab.calib.services.TOFCalibration $* +java -XX:+UseSerialGC -Xmx2048m -Xms2048m -cp "$CLAS12DIR/lib/clas/*:$CLAS12DIR/lib/plugins/*" org.jlab.calib.services.TOFCalibration $* diff --git a/bin.old/debug_ec.sh b/bin.old/debug_ec.sh index 85c00bd8eb..321a23d0fc 100755 --- a/bin.old/debug_ec.sh +++ b/bin.old/debug_ec.sh @@ -2,17 +2,4 @@ source `dirname $0`/env.sh -#CLARA_HOME=`dirname $0` -#CLARA_SERVICES=`dirname $0` -#DATAMINING=`dirname $0` - -echo +------------------------------------------------------------------------- -echo "| Starting CLARA-PLATFORM with CLARA_SERVICES = " $CLARA_SERVICES -echo +------------------------------------------------------------------------- -echo "\n" - -echo "INSTALLATION DIRECTORY = " $CLARA_HOME -echo "LIBRARY DIRECTORY = " $DATAMINING/lib/clas/ - -#java -cp "$DATAMINING/lib/clas/core/*" org.jlab.coda.eventViewer.EventTreeFrame $* -java -Xms1024m -cp "$DATAMINING/lib/clas/*:$DATAMINING/lib/plugins/*" org.jlab.display.ec.ECPion $* +java -Xms1024m -cp "$CLAS12DIR/lib/clas/*:$CLAS12DIR/lib/plugins/*" org.jlab.display.ec.ECPion $* diff --git a/bin.old/decoder-debugger b/bin.old/decoder-debugger index 2716be2193..0d613a4ec7 100755 --- a/bin.old/decoder-debugger +++ b/bin.old/decoder-debugger @@ -5,18 +5,4 @@ source `dirname $0`/env.sh MALLOC_ARENA_MAX=1; export MALLOC_ARENA_MAX -#CLARA_HOME=`dirname $0` -#CLARA_SERVICES=`dirname $0` -#DATAMINING=`dirname $0` - -echo +------------------------------------------------------------------------- -echo "| Starting CLARA-PLATFORM with CLARA_SERVICES = " $CLARA_SERVICES -echo +------------------------------------------------------------------------- -echo "\n" - -echo "INSTALLATION DIRECTORY = " $CLARA_HOME -echo "LIBRARY DIRECTORY = " $DATAMINING/lib/clas/ - -#java -cp "$DATAMINING/lib/clas/core/*" org.jlab.coda.eventViewer.EventTreeFrame $* -#java -Xms1024m -cp "$DATAMINING/lib/clas/*:$DATAMINING/lib/plugins/*" org.jlab.io.hipo.HipoDataSync $* -java -Xmx1536m -Xms1024m -cp "$DATAMINING/lib/clas/*:$DATAMINING/lib/plugins/*" org.jlab.detector.decode.DetectorDecoderDebug $* +java -Xmx1536m -Xms1024m -cp "$CLAS12DIR/lib/clas/*:$CLAS12DIR/lib/plugins/*" org.jlab.detector.decode.DetectorDecoderDebug $* diff --git a/bin.old/eb-monitor b/bin.old/eb-monitor index 9d8b6d29d0..5cea7b17a1 100755 --- a/bin.old/eb-monitor +++ b/bin.old/eb-monitor @@ -2,17 +2,4 @@ source `dirname $0`/env.sh -#CLARA_HOME=`dirname $0` -#CLARA_SERVICES=`dirname $0` -#DATAMINING=`dirname $0` - -echo +------------------------------------------------------------------------- -echo "| Starting CLARA-PLATFORM with CLARA_SERVICES = " $CLARA_SERVICES -echo +------------------------------------------------------------------------- -echo "\n" - -echo "INSTALLATION DIRECTORY = " $CLARA_HOME -echo "LIBRARY DIRECTORY = " $DATAMINING/lib/clas/ - -#java -cp "$DATAMINING/lib/clas/core/*" org.jlab.coda.eventViewer.EventTreeFrame $* -java -Xms1024m -cp "$DATAMINING/lib/clas/*:$DATAMINING/lib/services/*:$DATAMINING/lib/utils/*" org.jlab.service.eb.EBDebug $* +java -Xms1024m -cp "$CLAS12DIR/lib/clas/*:$CLAS12DIR/lib/services/*:$CLAS12DIR/lib/utils/*" org.jlab.service.eb.EBDebug $* diff --git a/bin.old/ec-monitor b/bin.old/ec-monitor index 2ac2584b1d..bd7fc15ba8 100755 --- a/bin.old/ec-monitor +++ b/bin.old/ec-monitor @@ -2,17 +2,4 @@ source `dirname $0`/env.sh -#CLARA_HOME=`dirname $0` -#CLARA_SERVICES=`dirname $0` -#DATAMINING=`dirname $0` - -echo +------------------------------------------------------------------------- -echo "| Starting CLARA-PLATFORM with CLARA_SERVICES = " $CLARA_SERVICES -echo +------------------------------------------------------------------------- -echo "\n" - -echo "INSTALLATION DIRECTORY = " $CLARA_HOME -echo "LIBRARY DIRECTORY = " $DATAMINING/lib/clas/ - -#java -cp "$DATAMINING/lib/clas/core/*" org.jlab.coda.eventViewer.EventTreeFrame $* -java -Xms1024m -cp "$DATAMINING/lib/clas/*:$DATAMINING/lib/services/*:$DATAMINING/lib/utils/*" org.jlab.display.ec.ECMonitor $* +java -Xms1024m -cp "$CLAS12DIR/lib/clas/*:$CLAS12DIR/lib/services/*:$CLAS12DIR/lib/utils/*" org.jlab.display.ec.ECMonitor $* diff --git a/bin.old/gemc-evio b/bin.old/gemc-evio index 82f5e8f76f..9aca3ab088 100755 --- a/bin.old/gemc-evio +++ b/bin.old/gemc-evio @@ -2,17 +2,4 @@ source `dirname $0`/env.sh -#CLARA_HOME=`dirname $0` -#CLARA_SERVICES=`dirname $0` -#DATAMINING=`dirname $0` - -echo +------------------------------------------------------------------------- -echo "| Starting CLARA-PLATFORM with CLARA_SERVICES = " $CLARA_SERVICES -echo +------------------------------------------------------------------------- -echo "\n" - -echo "INSTALLATION DIRECTORY = " $CLARA_HOME -echo "LIBRARY DIRECTORY = " $DATAMINING/lib/clas/ - -#java -cp "$DATAMINING/lib/clas/core/*" org.jlab.coda.eventViewer.EventTreeFrame $* -java -Xms1024m -cp "$DATAMINING/lib/clas/*:$DATAMINING/lib/plugins/*" org.jlab.clas.reco.io.ReconstructionIO $* +java -Xms1024m -cp "$CLAS12DIR/lib/clas/*:$CLAS12DIR/lib/plugins/*" org.jlab.clas.reco.io.ReconstructionIO $* diff --git a/bin.old/grid b/bin.old/grid index 68a7685fb2..1b5ffbb7c3 100755 --- a/bin.old/grid +++ b/bin.old/grid @@ -2,17 +2,4 @@ source `dirname $0`/env.sh -#CLARA_HOME=`dirname $0` -#CLARA_SERVICES=`dirname $0` -#DATAMINING=`dirname $0` - -echo +------------------------------------------------------------------------- -echo "| Starting CLARA-PLATFORM with CLARA_SERVICES = " $CLARA_SERVICES -echo +------------------------------------------------------------------------- -echo "\n" - -echo "INSTALLATION DIRECTORY = " $CLARA_HOME -echo "LIBRARY DIRECTORY = " $DATAMINING/lib/clas/ - -#java -cp "$DATAMINING/lib/clas/core/*" org.jlab.coda.eventViewer.EventTreeFrame $* -java -Xms1024m -cp "$DATAMINING/lib/clas/*:$DATAMINING/lib/plugins/*" org.jlab.groot.matrix.SparseGridIO $* +java -Xms1024m -cp "$CLAS12DIR/lib/clas/*:$CLAS12DIR/lib/plugins/*" org.jlab.groot.matrix.SparseGridIO $* diff --git a/bin.old/pion b/bin.old/pion index 7ee68900fa..d7dba70fbd 100755 --- a/bin.old/pion +++ b/bin.old/pion @@ -2,18 +2,4 @@ source `dirname $0`/env.sh -#CLARA_HOME=`dirname $0` -#CLARA_SERVICES=`dirname $0` -#DATAMINING=`dirname $0` - -echo +------------------------------------------------------------------------- -echo "| Starting CLARA-PLATFORM with CLARA_SERVICES = " $CLARA_SERVICES -echo +------------------------------------------------------------------------- -echo "\n" - -echo "INSTALLATION DIRECTORY = " $CLARA_HOME -echo "LIBRARY DIRECTORY = " $DATAMINING/lib/clas/ - -#java -cp "$DATAMINING/lib/clas/core/*" org.jlab.coda.eventViewer.EventTreeFrame $* -#java -Xms1024m -cp "$DATAMINING/lib/clas/*:$DATAMINING/lib/plugins/*" org.jlab.io.hipo.HipoDataSync $* -java -Xms1024m -cp "$DATAMINING/lib/clas/*:$DATAMINING/lib/services/*" org.jlab.display.ec.ECPionFinder $* +java -Xms1024m -cp "$CLAS12DIR/lib/clas/*:$CLAS12DIR/lib/services/*" org.jlab.display.ec.ECPionFinder $* diff --git a/bin.old/rec-monitor b/bin.old/rec-monitor index 1257139a79..2641c037aa 100755 --- a/bin.old/rec-monitor +++ b/bin.old/rec-monitor @@ -2,17 +2,4 @@ source `dirname $0`/env.sh -#CLARA_HOME=`dirname $0` -#CLARA_SERVICES=`dirname $0` -#DATAMINING=`dirname $0` - -echo +------------------------------------------------------------------------- -echo "| Starting CLARA-PLATFORM with CLARA_SERVICES = " $CLARA_SERVICES -echo +------------------------------------------------------------------------- -echo "\n" - -echo "INSTALLATION DIRECTORY = " $CLARA_HOME -echo "LIBRARY DIRECTORY = " $DATAMINING/lib/clas/ - -#java -cp "$DATAMINING/lib/clas/core/*" org.jlab.coda.eventViewer.EventTreeFrame $* -java -Xms1024m -cp "$DATAMINING/lib/clas/*:$DATAMINING/lib/plugins/*" org.jlab.monitor.eb.ReconstructionMonitor $* +java -Xms1024m -cp "$CLAS12DIR/lib/clas/*:$CLAS12DIR/lib/plugins/*" org.jlab.monitor.eb.ReconstructionMonitor $* diff --git a/bin.old/update b/bin.old/update index 7f9704a2c6..ac4a0d5f98 100755 --- a/bin.old/update +++ b/bin.old/update @@ -2,21 +2,8 @@ source `dirname $0`/env.sh -#CLARA_HOME=`dirname $0` -#CLARA_SERVICES=`dirname $0` -#DATAMINING=`dirname $0` -#echo +------------------------------------------------------------------------- -#echo "| Starting CLARA-PLATFORM with CLARA_SERVICES = " $CLARA_SERVICES -#echo +------------------------------------------------------------------------- -#echo "\n" -#echo "INSTALLATION DIRECTORY = " $CLARA_HOME -#echo "LIBRARY DIRECTORY = " $DATAMINING/lib/clas/ -#java -cp "$DATAMINING/lib/clas/core/*" org.jlab.coda.eventViewer.EventTreeFrame $* -#java -cp "$DATAMINING/lib/clas/*:$DATAMINING/lib/plugins/*" org.jlab.clas.tools.utils.StringTable -#java -cp "$DATAMINING/lib/clas/*:$DATAMINING/lib/utils/*:$DATAMINING/lib/plugins/*" org.jlab.clas.update.UpdateManager $* +java -cp "$CLAS12DIR/lib/clas/*:$CLAS12DIR/lib/utils/*:$CLAS12DIR/lib/plugins/*" org.jlab.clas.update.UpdateManager link http://clasweb.jlab.org/clas12maven/org/jlab/coat/coat-libs/3.0-SNAPSHOT/ coat-libs-3.0-SNAPSHOT.jar $CLAS12DIR/lib/clas -java -cp "$DATAMINING/lib/clas/*:$DATAMINING/lib/utils/*:$DATAMINING/lib/plugins/*" org.jlab.clas.update.UpdateManager link http://clasweb.jlab.org/clas12maven/org/jlab/coat/coat-libs/3.0-SNAPSHOT/ coat-libs-3.0-SNAPSHOT.jar $CLAS12DIR/lib/clas +java -cp "$CLAS12DIR/lib/clas/*:$CLAS12DIR/lib/utils/*:$CLAS12DIR/lib/plugins/*" org.jlab.clas.update.UpdateManager link https://userweb.jlab.org/~devita/kpp/ KPP-Plots-1.0.jar $CLAS12DIR/lib/utils -java -cp "$DATAMINING/lib/clas/*:$DATAMINING/lib/utils/*:$DATAMINING/lib/plugins/*" org.jlab.clas.update.UpdateManager link https://userweb.jlab.org/~devita/kpp/ KPP-Plots-1.0.jar $CLAS12DIR/lib/utils - -java -cp "$DATAMINING/lib/clas/*:$DATAMINING/lib/utils/*:$DATAMINING/lib/plugins/*" org.jlab.clas.update.UpdateManager link https://userweb.jlab.org/~devita/kpp/ KPP-Monitoring-1.0.jar $CLAS12DIR/lib/utils +java -cp "$CLAS12DIR/lib/clas/*:$CLAS12DIR/lib/utils/*:$CLAS12DIR/lib/plugins/*" org.jlab.clas.update.UpdateManager link https://userweb.jlab.org/~devita/kpp/ KPP-Monitoring-1.0.jar $CLAS12DIR/lib/utils diff --git a/bin/bos2hipo b/bin/bos2hipo index 5b2b9141f6..4730acd9d1 100755 --- a/bin/bos2hipo +++ b/bin/bos2hipo @@ -2,18 +2,4 @@ source `dirname $0`/env.sh -#CLARA_HOME=`dirname $0` -#CLARA_SERVICES=`dirname $0` -#DATAMINING=`dirname $0` - -echo +------------------------------------------------------------------------- -echo "| Starting CLARA-PLATFORM with CLARA_SERVICES = " $CLARA_SERVICES -echo +------------------------------------------------------------------------- -echo "\n" - -echo "INSTALLATION DIRECTORY = " $CLARA_HOME -echo "LIBRARY DIRECTORY = " $DATAMINING/lib/clas/ - -#java -cp "$DATAMINING/lib/clas/core/*" org.jlab.coda.eventViewer.EventTreeFrame $* -#java -Xms1024m -cp "$DATAMINING/lib/clas/*:$DATAMINING/lib/plugins/*" org.jlab.io.hipo.HipoDataSync $* -java -Xms1024m -cp "$DATAMINING/lib/clas/*:$DATAMINING/lib/plugins/*" org.jlab.io.utils.Bos2HipoEventBank $* +java -Xms1024m -cp "$CLAS12DIR/lib/clas/*:$CLAS12DIR/lib/plugins/*" org.jlab.io.utils.Bos2HipoEventBank $* diff --git a/bin/browser b/bin/browser index 1b2bce5c31..820bf4995d 100755 --- a/bin/browser +++ b/bin/browser @@ -2,17 +2,4 @@ source `dirname $0`/env.sh -#CLARA_HOME=`dirname $0` -#CLARA_SERVICES=`dirname $0` -#DATAMINING=`dirname $0` - -echo +------------------------------------------------------------------------- -echo "| Starting CLARA-PLATFORM with CLARA_SERVICES = " $CLARA_SERVICES -echo +------------------------------------------------------------------------- -echo "\n" - -echo "INSTALLATION DIRECTORY = " $CLARA_HOME -echo "LIBRARY DIRECTORY = " $DATAMINING/lib/clas/ - -#java -cp "$DATAMINING/lib/clas/core/*" org.jlab.coda.eventViewer.EventTreeFrame $* -java -Xms1024m -cp "$DATAMINING/lib/clas/*:$DATAMINING/lib/plugins/*" org.jlab.groot.ui.TBrowser $* +java -Xms1024m -cp "$CLAS12DIR/lib/clas/*:$CLAS12DIR/lib/plugins/*" org.jlab.groot.ui.TBrowser $* diff --git a/bin/convertor b/bin/convertor index 76a9afed03..650ae2470e 100755 --- a/bin/convertor +++ b/bin/convertor @@ -2,18 +2,4 @@ source `dirname $0`/env.sh -#CLARA_HOME=`dirname $0` -#CLARA_SERVICES=`dirname $0` -#DATAMINING=`dirname $0` - -echo +------------------------------------------------------------------------- -echo "| Starting CLARA-PLATFORM with CLARA_SERVICES = " $CLARA_SERVICES -echo +------------------------------------------------------------------------- -echo "\n" - -echo "INSTALLATION DIRECTORY = " $CLARA_HOME -echo "LIBRARY DIRECTORY = " $DATAMINING/lib/clas/ - -#java -cp "$DATAMINING/lib/clas/core/*" org.jlab.coda.eventViewer.EventTreeFrame $* -#java -Xms1024m -cp "$DATAMINING/lib/clas/*:$DATAMINING/lib/plugins/*" org.jlab.io.hipo.HipoDataSync $* -java -Xms1024m -cp "$DATAMINING/lib/clas/*:$DATAMINING/lib/plugins/*" org.jlab.clas.reco.io.HipoConvertor $* +java -Xms1024m -cp "$CLAS12DIR/lib/clas/*:$CLAS12DIR/lib/plugins/*" org.jlab.clas.reco.io.HipoConvertor $* diff --git a/bin/daq-monitor b/bin/daq-monitor index 55be7c9ae0..b765b23a4b 100755 --- a/bin/daq-monitor +++ b/bin/daq-monitor @@ -2,17 +2,4 @@ source `dirname $0`/env.sh -#CLARA_HOME=`dirname $0` -#CLARA_SERVICES=`dirname $0` -#DATAMINING=`dirname $0` - -echo +------------------------------------------------------------------------- -echo "| Starting CLARA-PLATFORM with CLARA_SERVICES = " $CLARA_SERVICES -echo +------------------------------------------------------------------------- -echo "\n" - -echo "INSTALLATION DIRECTORY = " $CLARA_HOME -echo "LIBRARY DIRECTORY = " $DATAMINING/lib/clas/ - -#java -cp "$DATAMINING/lib/clas/core/*" org.jlab.coda.eventViewer.EventTreeFrame $* -java -Xms1024m -cp "$DATAMINING/lib/clas/*:$DATAMINING/lib/services/*:$DATAMINING/lib/utils/*" org.jlab.detector.examples.DaqPulsePlotter $* +java -Xms1024m -cp "$CLAS12DIR/lib/clas/*:$CLAS12DIR/lib/services/*:$CLAS12DIR/lib/utils/*" org.jlab.detector.examples.DaqPulsePlotter $* diff --git a/bin/daqEventViewer b/bin/daqEventViewer index 6ad1aaa55d..b91ebbfbc4 100755 --- a/bin/daqEventViewer +++ b/bin/daqEventViewer @@ -2,17 +2,4 @@ source `dirname $0`/env.sh -#CLARA_HOME=`dirname $0` -#CLARA_SERVICES=`dirname $0` -#DATAMINING=`dirname $0` - -echo +------------------------------------------------------------------------- -echo "| Starting CLARA-PLATFORM with CLARA_SERVICES = " $CLARA_SERVICES -echo +------------------------------------------------------------------------- -echo "\n" - -echo "INSTALLATION DIRECTORY = " $CLARA_HOME -echo "LIBRARY DIRECTORY = " $DATAMINING/lib/clas/ - -#java -cp "$DATAMINING/lib/clas/core/*" org.jlab.coda.eventViewer.EventTreeFrame $* -java -Xms1024m -cp "$DATAMINING/lib/clas/*:$DATAMINING/lib/services/*:$DATAMINING/lib/utils/*" org.jlab.detector.examples.RawEventViewer $* +java -Xms1024m -cp "$CLAS12DIR/lib/clas/*:$CLAS12DIR/lib/services/*:$CLAS12DIR/lib/utils/*" org.jlab.detector.examples.RawEventViewer $* diff --git a/bin/dclayereffs-ana b/bin/dclayereffs-ana index 024abb172e..7db7d2ed02 100755 --- a/bin/dclayereffs-ana +++ b/bin/dclayereffs-ana @@ -2,18 +2,4 @@ source `dirname $0`/env.sh -#CLARA_HOME=`dirname $0` -#CLARA_SERVICES=`dirname $0` -#DATAMINING=`dirname $0` - -echo +------------------------------------------------------------------------- -echo "| Starting CLARA-PLATFORM with CLARA_SERVICES = " $CLARA_SERVICES -echo +------------------------------------------------------------------------- -echo "\n" - -echo "INSTALLATION DIRECTORY = " $CLARA_HOME -echo "LIBRARY DIRECTORY = " $DATAMINING/lib/clas/ - -#java -cp "$DATAMINING/lib/clas/core/*" org.jlab.coda.eventViewer.EventTreeFrame $* -#java -Xms1024m -cp "$DATAMINING/lib/clas/*:$DATAMINING/lib/plugins/*" org.jlab.io.hipo.HipoDataSync $* -java -Dsun.java2d.pmoffscreen=false -Xmx2048m -Xms1024m -cp "$DATAMINING/lib/clas/*:$DATAMINING/lib/utils/*:$DATAMINING/lib/services/*" org.jlab.service.dc.LayerEfficiencyAnalyzer $* +java -Dsun.java2d.pmoffscreen=false -Xmx2048m -Xms1024m -cp "$CLAS12DIR/lib/clas/*:$CLAS12DIR/lib/utils/*:$CLAS12DIR/lib/services/*" org.jlab.service.dc.LayerEfficiencyAnalyzer $* diff --git a/bin/ddr b/bin/ddr index 26f9faa8dd..759fe005d9 100755 --- a/bin/ddr +++ b/bin/ddr @@ -2,20 +2,4 @@ source `dirname $0`/env.sh -#CLARA_HOME=`dirname $0` -#CLARA_SERVICES=`dirname $0` -#DATAMINING=`dirname $0` - -echo +------------------------------------------------------------------------- -echo "| Starting CLARA-PLATFORM with CLARA_SERVICES = " $CLARA_SERVICES -echo +------------------------------------------------------------------------- -echo "\n" - -echo "INSTALLATION DIRECTORY = " $CLARA_HOME -echo "LIBRARY DIRECTORY = " $DATAMINING/lib/clas/ - -#java -cp "$DATAMINING/lib/clas/core/*" org.jlab.coda.eventViewer.EventTreeFrame $* -#java -Xms1024m -cp "$DATAMINING/lib/clas/*:$DATAMINING/lib/plugins/*" org.jlab.io.hipo.HipoDataSync $* -#java -XX:+UseNUMA -XX:+UseBiasedLocking -cp "$DATAMINING/lib/clas/*:$DATAMINING/lib/plugins/*" org.jlab.coda.xmsg.sys.xMsgProxy & -#java -cp "$DATAMINING/lib/clas/*:$DATAMINING/lib/plugins/*" org.jlab.coda.xmsg.sys.xMsgProxy -java -Xms1024m -cp "$DATAMINING/lib/clas/*:$DATAMINING/lib/plugins/*" org.jlab.clas.service.DataDistributionService -type et -host localhost -file /tmp/et_sys_$SESSION +java -Xms1024m -cp "$CLAS12DIR/lib/clas/*:$CLAS12DIR/lib/plugins/*" org.jlab.clas.service.DataDistributionService -type et -host localhost -file /tmp/et_sys_$SESSION diff --git a/bin/decoder b/bin/decoder index 7c7850098b..760071bdbe 100755 --- a/bin/decoder +++ b/bin/decoder @@ -5,18 +5,8 @@ source `dirname $0`/env.sh MALLOC_ARENA_MAX=1; export MALLOC_ARENA_MAX -#CLARA_HOME=`dirname $0` -#CLARA_SERVICES=`dirname $0` -#DATAMINING=`dirname $0` - echo +------------------------------------------------------------------------- echo "| DECODER GENERATION 4 (using HIPO-4 Library)" echo +------------------------------------------------------------------------- -echo "\n" - -echo "INSTALLATION DIRECTORY = " $CLARA_HOME -echo "LIBRARY DIRECTORY = " $DATAMINING/lib/clas/ -#java -cp "$DATAMINING/lib/clas/core/*" org.jlab.coda.eventViewer.EventTreeFrame $* -#java -Xms1024m -cp "$DATAMINING/lib/clas/*:$DATAMINING/lib/plugins/*" org.jlab.io.hipo.HipoDataSync $* -java -Xmx1536m -Xms1024m -cp "$DATAMINING/lib/clas/*:$DATAMINING/lib/plugins/*" org.jlab.detector.decode.CLASDecoder4 $* +java -Xmx1536m -Xms1024m -cp "$CLAS12DIR/lib/clas/*:$CLAS12DIR/lib/plugins/*" org.jlab.detector.decode.CLASDecoder4 $* diff --git a/bin/decoder3 b/bin/decoder3 index 0402b19e52..2f968b71c6 100755 --- a/bin/decoder3 +++ b/bin/decoder3 @@ -1,22 +1,7 @@ #!/bin/bash -# This doesn't work in dash (Travis's /bin/sh): source `dirname $0`/env.sh MALLOC_ARENA_MAX=1; export MALLOC_ARENA_MAX -#CLARA_HOME=`dirname $0` -#CLARA_SERVICES=`dirname $0` -#DATAMINING=`dirname $0` - -echo +------------------------------------------------------------------------- -echo "| Starting CLARA-PLATFORM with CLARA_SERVICES = " $CLARA_SERVICES -echo +------------------------------------------------------------------------- -echo "\n" - -echo "INSTALLATION DIRECTORY = " $CLARA_HOME -echo "LIBRARY DIRECTORY = " $DATAMINING/lib/clas/ - -#java -cp "$DATAMINING/lib/clas/core/*" org.jlab.coda.eventViewer.EventTreeFrame $* -#java -Xms1024m -cp "$DATAMINING/lib/clas/*:$DATAMINING/lib/plugins/*" org.jlab.io.hipo.HipoDataSync $* -java -Xmx1536m -Xms1024m -cp "$DATAMINING/lib/clas/*:$DATAMINING/lib/plugins/*" org.jlab.detector.decode.CLASDecoder $* +java -Xmx1536m -Xms1024m -cp "$CLAS12DIR/lib/clas/*:$CLAS12DIR/lib/plugins/*" org.jlab.detector.decode.CLASDecoder $* diff --git a/bin/dict-maker b/bin/dict-maker index 174feb9ebb..28af7f0001 100755 --- a/bin/dict-maker +++ b/bin/dict-maker @@ -3,18 +3,5 @@ source `dirname $0`/env.sh MALLOC_ARENA_MAX=1; export MALLOC_ARENA_MAX -#CLARA_HOME=`dirname $0` -#CLARA_SERVICES=`dirname $0` -#DATAMINING=`dirname $0` -echo +------------------------------------------------------------------------- -echo "| Starting CLARA-PLATFORM with CLARA_SERVICES = " $CLARA_SERVICES -echo +------------------------------------------------------------------------- -echo "\n" - -echo "INSTALLATION DIRECTORY = " $CLARA_HOME -echo "LIBRARY DIRECTORY = " $DATAMINING/lib/clas/ - -#java -cp "$DATAMINING/lib/clas/core/*" org.jlab.coda.eventViewer.EventTreeFrame $* -#java -Xms1024m -cp "$DATAMINING/lib/clas/*:$DATAMINING/lib/plugins/*" org.jlab.io.hipo.HipoDataSync $* -java -Xmx1536m -Xms1024m -cp "$DATAMINING/lib/clas/*:$DATAMINING/lib/services/*:$DATAMINING/lib/utils/*" org.jlab.service.dc.TrackDictionaryMakerRNG $* +java -Xmx1536m -Xms1024m -cp "$CLAS12DIR/lib/clas/*:$CLAS12DIR/lib/services/*:$CLAS12DIR/lib/utils/*" org.jlab.service.dc.TrackDictionaryMakerRNG $* diff --git a/bin/dict-merge b/bin/dict-merge index 2252ecf882..e58c4f22b4 100755 --- a/bin/dict-merge +++ b/bin/dict-merge @@ -3,18 +3,5 @@ source `dirname $0`/env.sh MALLOC_ARENA_MAX=1; export MALLOC_ARENA_MAX -#CLARA_HOME=`dirname $0` -#CLARA_SERVICES=`dirname $0` -#DATAMINING=`dirname $0` -echo +------------------------------------------------------------------------- -echo "| Starting CLARA-PLATFORM with CLARA_SERVICES = " $CLARA_SERVICES -echo +------------------------------------------------------------------------- -echo "\n" - -echo "INSTALLATION DIRECTORY = " $CLARA_HOME -echo "LIBRARY DIRECTORY = " $DATAMINING/lib/clas/ - -#java -cp "$DATAMINING/lib/clas/core/*" org.jlab.coda.eventViewer.EventTreeFrame $* -#java -Xms1024m -cp "$DATAMINING/lib/clas/*:$DATAMINING/lib/plugins/*" org.jlab.io.hipo.HipoDataSync $* -java -Xmx1536m -Xms1024m -cp "$DATAMINING/lib/clas/*:$DATAMINING/lib/services/*:$DATAMINING/lib/utils/*" org.jlab.service.dc.TrackDictionaryMerger $* +java -Xmx1536m -Xms1024m -cp "$CLAS12DIR/lib/clas/*:$CLAS12DIR/lib/services/*:$CLAS12DIR/lib/utils/*" org.jlab.service.dc.TrackDictionaryMerger $* diff --git a/bin/dict-validate b/bin/dict-validate index e227208bdb..5d70ba8581 100755 --- a/bin/dict-validate +++ b/bin/dict-validate @@ -3,18 +3,5 @@ source `dirname $0`/env.sh MALLOC_ARENA_MAX=1; export MALLOC_ARENA_MAX -#CLARA_HOME=`dirname $0` -#CLARA_SERVICES=`dirname $0` -#DATAMINING=`dirname $0` -echo +------------------------------------------------------------------------- -echo "| Starting CLARA-PLATFORM with CLARA_SERVICES = " $CLARA_SERVICES -echo +------------------------------------------------------------------------- -echo "\n" - -echo "INSTALLATION DIRECTORY = " $CLARA_HOME -echo "LIBRARY DIRECTORY = " $DATAMINING/lib/clas/ - -#java -cp "$DATAMINING/lib/clas/core/*" org.jlab.coda.eventViewer.EventTreeFrame $* -#java -Xms1024m -cp "$DATAMINING/lib/clas/*:$DATAMINING/lib/plugins/*" org.jlab.io.hipo.HipoDataSync $* -java -Xmx1536m -Xms1024m -cp "$DATAMINING/lib/clas/*:$DATAMINING/lib/services/*:$DATAMINING/lib/utils/*" org.jlab.service.dc.TrackDictionaryValidation $* +java -Xmx1536m -Xms1024m -cp "$CLAS12DIR/lib/clas/*:$CLAS12DIR/lib/services/*:$CLAS12DIR/lib/utils/*" org.jlab.service.dc.TrackDictionaryValidation $* diff --git a/bin/env.sh b/bin/env.sh index b0b6c9a2bb..200f78ccdb 100644 --- a/bin/env.sh +++ b/bin/env.sh @@ -1,10 +1,7 @@ #!/bin/bash SCRIPT_DIR=`dirname $0` -DISTRO_DIR=$SCRIPT_DIR/../ ; export DISTRO_DIR CLAS12DIR=$SCRIPT_DIR/../ ; export CLAS12DIR -CLARA_SERVICES=$DISTRO_DIR/lib/services; export CLARA_SERVICES -DATAMINING=$DISTRO_DIR ; export DATAMINING # Set default field maps (but do not override user's env): if [ -z "$COAT_MAGFIELD_TORUSMAP" ]; then @@ -17,3 +14,7 @@ if [ -z "$COAT_MAGFIELD_SOLENOIDMAP" ]; then export COAT_MAGFIELD_SOLENOIDMAP=Symm_solenoid_r601_phi1_z1201_13June2018.dat fi +echo +------------------------------------------------------------------------- +echo "| COATJAVA LIBRARY DIRECTORY = " $CLAS12DIR/lib/clas/ +echo +------------------------------------------------------------------------- + diff --git a/bin/evio-viewer b/bin/evio-viewer index 8d41a5d774..8d659aaf39 100755 --- a/bin/evio-viewer +++ b/bin/evio-viewer @@ -2,18 +2,4 @@ source `dirname $0`/env.sh -#CLARA_HOME=`dirname $0` -#CLARA_SERVICES=`dirname $0` -#DATAMINING=`dirname $0` - -echo +------------------------------------------------------------------------- -echo "| Starting CLARA-PLATFORM with CLARA_SERVICES = " $CLARA_SERVICES -echo +------------------------------------------------------------------------- -echo "\n" - -echo "INSTALLATION DIRECTORY = " $CLARA_HOME -echo "LIBRARY DIRECTORY = " $DATAMINING/lib/clas/ - -java -cp "$DATAMINING/lib/clas/*" org.jlab.coda.eventViewer.EventTreeFrame $* -#java -cp "$DATAMINING/lib/clas/*" org.jlab.coda.jevio.graphics.EventTreeFrame $* -#java -cp "$DATAMINING/lib/clas/*" org.jlab.coda.jevio.graphics.EventTreeFrame $* +java -cp "$CLAS12DIR/lib/clas/*" org.jlab.coda.eventViewer.EventTreeFrame $* diff --git a/bin/evio2hipo b/bin/evio2hipo index b64a8c82ac..ceda619f9b 100755 --- a/bin/evio2hipo +++ b/bin/evio2hipo @@ -4,18 +4,4 @@ source `dirname $0`/env.sh MALLOC_ARENA_MAX=1; export MALLOC_ARENA_MAX -#CLARA_HOME=`dirname $0` -#CLARA_SERVICES=`dirname $0` -#DATAMINING=`dirname $0` - -echo +------------------------------------------------------------------------- -echo "| Starting CLARA-PLATFORM with CLARA_SERVICES = " $CLARA_SERVICES -echo +------------------------------------------------------------------------- -echo "\n" - -echo "INSTALLATION DIRECTORY = " $CLARA_HOME -echo "LIBRARY DIRECTORY = " $DATAMINING/lib/clas/ - -#java -cp "$DATAMINING/lib/clas/core/*" org.jlab.coda.eventViewer.EventTreeFrame $* -#java -Xms1024m -cp "$DATAMINING/lib/clas/*:$DATAMINING/lib/plugins/*" org.jlab.io.hipo.HipoDataSync $* -java -Xmx1536m -Xms1024m -cp "$DATAMINING/lib/clas/*:$DATAMINING/lib/plugins/*" org.jlab.clas.reco.io.EvioHipoEvent4 $* +java -Xmx1536m -Xms1024m -cp "$CLAS12DIR/lib/clas/*:$CLAS12DIR/lib/plugins/*" org.jlab.clas.reco.io.EvioHipoEvent4 $* diff --git a/bin/eviocure b/bin/eviocure index 258a4bf05e..d2e0768d3f 100755 --- a/bin/eviocure +++ b/bin/eviocure @@ -4,18 +4,4 @@ source `dirname $0`/env.sh MALLOC_ARENA_MAX=1; export MALLOC_ARENA_MAX -#CLARA_HOME=`dirname $0` -#CLARA_SERVICES=`dirname $0` -#DATAMINING=`dirname $0` - -echo +------------------------------------------------------------------------- -echo "| Starting CLARA-PLATFORM with CLARA_SERVICES = " $CLARA_SERVICES -echo +------------------------------------------------------------------------- -echo "\n" - -echo "INSTALLATION DIRECTORY = " $CLARA_HOME -echo "LIBRARY DIRECTORY = " $DATAMINING/lib/clas/ - -#java -cp "$DATAMINING/lib/clas/core/*" org.jlab.coda.eventViewer.EventTreeFrame $* -#java -Xms1024m -cp "$DATAMINING/lib/clas/*:$DATAMINING/lib/plugins/*" org.jlab.io.hipo.HipoDataSync $* -java -Xmx1536m -Xms1024m -cp "$DATAMINING/lib/clas/*:$DATAMINING/lib/plugins/*" org.jlab.io.utils.EvioCure $* +java -Xmx1536m -Xms1024m -cp "$CLAS12DIR/lib/clas/*:$CLAS12DIR/lib/plugins/*" org.jlab.io.utils.EvioCure $* diff --git a/bin/eviodump b/bin/eviodump index be98a29fef..db4f7b0c4f 100755 --- a/bin/eviodump +++ b/bin/eviodump @@ -2,17 +2,4 @@ source `dirname $0`/env.sh -#CLARA_HOME=`dirname $0` -#CLARA_SERVICES=`dirname $0` -#DATAMINING=`dirname $0` - -echo +------------------------------------------------------------------------- -echo "| Starting CLARA-PLATFORM with CLARA_SERVICES = " $CLARA_SERVICES -echo +------------------------------------------------------------------------- -echo "\n" - -echo "INSTALLATION DIRECTORY = " $CLARA_HOME -echo "LIBRARY DIRECTORY = " $DATAMINING/lib/clas/ - -#java -cp "$DATAMINING/lib/clas/core/*" org.jlab.coda.eventViewer.EventTreeFrame $* -java -Xms1024m -cp "$DATAMINING/lib/clas/*:$DATAMINING/lib/plugins/*" org.jlab.io.utils.DataSourceDump $* +java -Xms1024m -cp "$CLAS12DIR/lib/clas/*:$CLAS12DIR/lib/plugins/*" org.jlab.io.utils.DataSourceDump $* diff --git a/bin/hadd b/bin/hadd index 2c045d5696..87673aade6 100755 --- a/bin/hadd +++ b/bin/hadd @@ -2,17 +2,4 @@ source `dirname $0`/env.sh -#CLARA_HOME=`dirname $0` -#CLARA_SERVICES=`dirname $0` -#DATAMINING=`dirname $0` - -echo +------------------------------------------------------------------------- -echo "| Starting CLARA-PLATFORM with CLARA_SERVICES = " $CLARA_SERVICES -echo +------------------------------------------------------------------------- -echo "\n" - -echo "INSTALLATION DIRECTORY = " $CLARA_HOME -echo "LIBRARY DIRECTORY = " $DATAMINING/lib/clas/ - -#java -cp "$DATAMINING/lib/clas/core/*" org.jlab.coda.eventViewer.EventTreeFrame $* -java -Xms1024m -cp "$DATAMINING/lib/clas/*:$DATAMINING/lib/plugins/*" org.jlab.groot.data.TDirectory $* +java -Xms1024m -cp "$CLAS12DIR/lib/clas/*:$CLAS12DIR/lib/plugins/*" org.jlab.groot.data.TDirectory $* diff --git a/bin/hipo-utils b/bin/hipo-utils index 2871f0ad81..4b48c1deac 100755 --- a/bin/hipo-utils +++ b/bin/hipo-utils @@ -4,19 +4,4 @@ source `dirname $0`/env.sh MALLOC_ARENA_MAX=1; export MALLOC_ARENA_MAX -#CLARA_HOME=`dirname $0` -#CLARA_SERVICES=`dirname $0` -#DATAMINING=`dirname $0` - -echo +------------------------------------------------------------------------- -echo "| Starting CLARA-PLATFORM with CLARA_SERVICES = " $CLARA_SERVICES -echo +------------------------------------------------------------------------- -echo "\n" - -echo "INSTALLATION DIRECTORY = " $CLARA_HOME -echo "LIBRARY DIRECTORY = " $DATAMINING/lib/clas/ - -#java -cp "$DATAMINING/lib/clas/core/*" org.jlab.coda.eventViewer.EventTreeFrame $* -#java -Xms1024m -cp "$DATAMINING/lib/clas/*:$DATAMINING/lib/plugins/*" org.jlab.io.hipo.HipoDataSync $* -#java -Xms1024m -cp "$DATAMINING/lib/clas/*:$DATAMINING/lib/plugins/*" org.jlab.clas.reco.io.HipoFileUtils $* -java -Xmx2048m -Xms1024m -cp "$DATAMINING/lib/clas/*:$DATAMINING/lib/plugins/*" org.jlab.jnp.hipo4.utils.HipoUtilities $* +java -Xmx2048m -Xms1024m -cp "$CLAS12DIR/lib/clas/*:$CLAS12DIR/lib/plugins/*" org.jlab.jnp.hipo4.utils.HipoUtilities $* diff --git a/bin/hipo-writer b/bin/hipo-writer index eae747fceb..6ac8133e92 100755 --- a/bin/hipo-writer +++ b/bin/hipo-writer @@ -2,18 +2,4 @@ source `dirname $0`/env.sh -#CLARA_HOME=`dirname $0` -#CLARA_SERVICES=`dirname $0` -#DATAMINING=`dirname $0` - -echo +------------------------------------------------------------------------- -echo "| Starting CLARA-PLATFORM with CLARA_SERVICES = " $CLARA_SERVICES -echo +------------------------------------------------------------------------- -echo "\n" - -echo "INSTALLATION DIRECTORY = " $CLARA_HOME -echo "LIBRARY DIRECTORY = " $DATAMINING/lib/clas/ - -#java -cp "$DATAMINING/lib/clas/core/*" org.jlab.coda.eventViewer.EventTreeFrame $* -#java -Xms1024m -cp "$DATAMINING/lib/clas/*:$DATAMINING/lib/plugins/*" org.jlab.io.hipo.HipoDataSync $* -java -Xms1024m -cp "$DATAMINING/lib/clas/*:$DATAMINING/lib/plugins/*" org.jlab.io.utils.Evio2HipoConverter $* +java -Xms1024m -cp "$CLAS12DIR/lib/clas/*:$CLAS12DIR/lib/plugins/*" org.jlab.io.utils.Evio2HipoConverter $* diff --git a/bin/hipo3utils b/bin/hipo3utils index 569279e187..5fe21358d5 100755 --- a/bin/hipo3utils +++ b/bin/hipo3utils @@ -4,19 +4,4 @@ source `dirname $0`/env.sh MALLOC_ARENA_MAX=1; export MALLOC_ARENA_MAX -#CLARA_HOME=`dirname $0` -#CLARA_SERVICES=`dirname $0` -#DATAMINING=`dirname $0` - -echo +------------------------------------------------------------------------- -echo "| Starting CLARA-PLATFORM with CLARA_SERVICES = " $CLARA_SERVICES -echo +------------------------------------------------------------------------- -echo "\n" - -echo "INSTALLATION DIRECTORY = " $CLARA_HOME -echo "LIBRARY DIRECTORY = " $DATAMINING/lib/clas/ - -#java -cp "$DATAMINING/lib/clas/core/*" org.jlab.coda.eventViewer.EventTreeFrame $* -#java -Xms1024m -cp "$DATAMINING/lib/clas/*:$DATAMINING/lib/plugins/*" org.jlab.io.hipo.HipoDataSync $* -#java -Xms1024m -cp "$DATAMINING/lib/clas/*:$DATAMINING/lib/plugins/*" org.jlab.clas.reco.io.HipoFileUtils $* -java -Xmx2048m -Xms1024m -cp "$DATAMINING/lib/clas/*:$DATAMINING/lib/plugins/*" org.jlab.jnp.hipo.utils.HipoUtilities $* +java -Xmx2048m -Xms1024m -cp "$CLAS12DIR/lib/clas/*:$CLAS12DIR/lib/plugins/*" org.jlab.jnp.hipo.utils.HipoUtilities $* diff --git a/bin/kpp-plots b/bin/kpp-plots index 6f4135adce..f33f426b58 100755 --- a/bin/kpp-plots +++ b/bin/kpp-plots @@ -2,18 +2,4 @@ source `dirname $0`/env.sh -#CLARA_HOME=`dirname $0` -#CLARA_SERVICES=`dirname $0` -#DATAMINING=`dirname $0` - -echo +------------------------------------------------------------------------- -echo "| Starting CLARA-PLATFORM with CLARA_SERVICES = " $CLARA_SERVICES -echo +------------------------------------------------------------------------- -echo "\n" - -echo "INSTALLATION DIRECTORY = " $CLARA_HOME -echo "LIBRARY DIRECTORY = " $DATAMINING/lib/clas/ - -#java -cp "$DATAMINING/lib/clas/core/*" org.jlab.coda.eventViewer.EventTreeFrame $* -#java -Xms1024m -cp "$DATAMINING/lib/clas/*:$DATAMINING/lib/plugins/*" org.jlab.io.hipo.HipoDataSync $* -java -Dsun.java2d.pmoffscreen=false -Xmx2048m -Xms1024m -cp "$DATAMINING/lib/clas/*:$DATAMINING/lib/utils/*:$DATAMINING/lib/services/*" org.clas.viewer.KPPViewer $* +java -Dsun.java2d.pmoffscreen=false -Xmx2048m -Xms1024m -cp "$CLAS12DIR/lib/clas/*:$CLAS12DIR/lib/utils/*:$CLAS12DIR/lib/services/*" org.clas.viewer.KPPViewer $* diff --git a/bin/mon12 b/bin/mon12 index 02e50f2583..fc693331c2 100755 --- a/bin/mon12 +++ b/bin/mon12 @@ -2,18 +2,4 @@ source `dirname $0`/env.sh -#CLARA_HOME=`dirname $0` -#CLARA_SERVICES=`dirname $0` -#DATAMINING=`dirname $0` - -echo +------------------------------------------------------------------------- -echo "| Starting CLARA-PLATFORM with CLARA_SERVICES = " $CLARA_SERVICES -echo +------------------------------------------------------------------------- -echo "\n" - -echo "INSTALLATION DIRECTORY = " $CLARA_HOME -echo "LIBRARY DIRECTORY = " $DATAMINING/lib/clas/ - -#java -cp "$DATAMINING/lib/clas/core/*" org.jlab.coda.eventViewer.EventTreeFrame $* -#java -Xms1024m -cp "$DATAMINING/lib/clas/*:$DATAMINING/lib/plugins/*" org.jlab.io.hipo.HipoDataSync $* -java -Dsun.java2d.pmoffscreen=false -Xmx2048m -Xms1024m -cp "$DATAMINING/lib/clas/*:$DATAMINING/lib/utils/*:$DATAMINING/lib/services/*" org.clas.viewer.EventViewer $* +java -Dsun.java2d.pmoffscreen=false -Xmx2048m -Xms1024m -cp "$CLAS12DIR/lib/clas/*:$CLAS12DIR/lib/utils/*:$CLAS12DIR/lib/services/*" org.clas.viewer.EventViewer $* diff --git a/bin/recon-util b/bin/recon-util index 0fe6c5e885..763324174c 100755 --- a/bin/recon-util +++ b/bin/recon-util @@ -3,18 +3,5 @@ source `dirname $0`/env.sh MALLOC_ARENA_MAX=1; export MALLOC_ARENA_MAX -#CLARA_HOME=`dirname $0` -#CLARA_SERVICES=`dirname $0` -#DATAMINING=`dirname $0` -echo +------------------------------------------------------------------------- -echo "| Starting CLARA-PLATFORM with CLARA_SERVICES = " $CLARA_SERVICES -echo +------------------------------------------------------------------------- -echo "\n" - -echo "INSTALLATION DIRECTORY = " $CLARA_HOME -echo "LIBRARY DIRECTORY = " $DATAMINING/lib/clas/ - -#java -cp "$DATAMINING/lib/clas/core/*" org.jlab.coda.eventViewer.EventTreeFrame $* -#java -Xms1024m -cp "$DATAMINING/lib/clas/*:$DATAMINING/lib/plugins/*" org.jlab.io.hipo.HipoDataSync $* -java -Xmx1536m -Xms1024m -cp "$DATAMINING/lib/clas/*:$DATAMINING/lib/services/*:$DATAMINING/lib/utils/*" org.jlab.clas.reco.EngineProcessor $* +java -Xmx1536m -Xms1024m -cp "$CLAS12DIR/lib/clas/*:$CLAS12DIR/lib/services/*:$CLAS12DIR/lib/utils/*" org.jlab.clas.reco.EngineProcessor $* diff --git a/bin/run-groovy b/bin/run-groovy index b36fe48fe1..6a93a9ea5e 100755 --- a/bin/run-groovy +++ b/bin/run-groovy @@ -3,17 +3,17 @@ source `dirname $0`/env.sh CLARA_HOME=`dirname $0`/.. -DATAMINING=`dirname $0`/.. +CLAS12DIR=`dirname $0`/.. CLAS12DIR=`dirname $0`/.. ; export CLAS12DIR CLARA_SERVICES=$CLAS12DIR/lib/services ; export CLARA_SERVICES -#JYTHONPATH=${DATAMINING}/lib/jython +#JYTHONPATH=${CLAS12DIR}/lib/jython #echo ${JYTHONPATH} #-------------------------------------------------------------- # Adding supporting COAT jar files -for i in `ls -a $DATAMINING/lib/clas/*.jar` +for i in `ls -a $CLAS12DIR/lib/clas/*.jar` do #echo "$i" if [ -z "${JYPATH}" ] ; then @@ -24,7 +24,7 @@ fi done #-------------------------------------------------------------- # Adding supporting plugins directory -for i in `ls -a $DATAMINING/lib/services/*.jar` +for i in `ls -a $CLAS12DIR/lib/services/*.jar` do if [ -z "${JYPATH}" ] ; then JYPATH="$i" @@ -38,7 +38,7 @@ done # Done loading plugins #-------------------------------------------------------------- # Adding supporting plugins directory -for i in `ls -a $DATAMINING/lib/utils/*.jar` +for i in `ls -a $CLAS12DIR/lib/utils/*.jar` do if [ -z "${JYPATH}" ] ; then JYPATH="$i" @@ -47,7 +47,7 @@ JYPATH=${JYPATH}:"$i" fi done #------------------------------------------------------------- -JYPATH=${JYPATH}:${DATAMINING}/lib/packages +JYPATH=${JYPATH}:${CLAS12DIR}/lib/packages echo " " echo " " echo "*****************************************" diff --git a/bin/studio b/bin/studio index 8afb445e32..39a00e472a 100755 --- a/bin/studio +++ b/bin/studio @@ -2,17 +2,4 @@ source `dirname $0`/env.sh -#CLARA_HOME=`dirname $0` -#CLARA_SERVICES=`dirname $0` -#DATAMINING=`dirname $0` - -echo +------------------------------------------------------------------------- -echo "| Starting CLARA-PLATFORM with CLARA_SERVICES = " $CLARA_SERVICES -echo +------------------------------------------------------------------------- -echo "\n" - -echo "INSTALLATION DIRECTORY = " $CLARA_HOME -echo "LIBRARY DIRECTORY = " $DATAMINING/lib/clas/ - -#java -cp "$DATAMINING/lib/clas/core/*" org.jlab.coda.eventViewer.EventTreeFrame $* -java -Xms1024m -Xmx2048m -cp "$DATAMINING/lib/clas/*:$DATAMINING/lib/plugins/*" org.jlab.clas.physics.EventTree $* +java -Xms1024m -Xmx2048m -cp "$CLAS12DIR/lib/clas/*:$CLAS12DIR/lib/plugins/*" org.jlab.clas.physics.EventTree $* diff --git a/bin/x-client b/bin/x-client index cab1bef627..e51c06ea1f 100755 --- a/bin/x-client +++ b/bin/x-client @@ -2,16 +2,4 @@ source `dirname $0`/env.sh -#CLARA_HOME=`dirname $0` -#CLARA_SERVICES=`dirname $0` -#DATAMINING=`dirname $0` - -echo +------------------------------------------------------------------------- -echo "| Starting CLARA-PLATFORM with CLARA_SERVICES = " $CLARA_SERVICES -echo +------------------------------------------------------------------------- -echo "\n" - -echo "INSTALLATION DIRECTORY = " $CLARA_HOME -echo "LIBRARY DIRECTORY = " $DATAMINING/lib/clas/ - -java -Xms1024m -cp "$DATAMINING/lib/clas/*:$DATAMINING/lib/plugins/*" org.jlab.io.hipo.HipoRingSource $* +java -Xms1024m -cp "$CLAS12DIR/lib/clas/*:$CLAS12DIR/lib/plugins/*" org.jlab.io.hipo.HipoRingSource $* diff --git a/bin/x-client-evio b/bin/x-client-evio index 9c2150a3fd..f873691079 100755 --- a/bin/x-client-evio +++ b/bin/x-client-evio @@ -2,16 +2,4 @@ source `dirname $0`/env.sh -#CLARA_HOME=`dirname $0` -#CLARA_SERVICES=`dirname $0` -#DATAMINING=`dirname $0` - -echo +------------------------------------------------------------------------- -echo "| Starting CLARA-PLATFORM with CLARA_SERVICES = " $CLARA_SERVICES -echo +------------------------------------------------------------------------- -echo "\n" - -echo "INSTALLATION DIRECTORY = " $CLARA_HOME -echo "LIBRARY DIRECTORY = " $DATAMINING/lib/clas/ - -java -Xms1024m -cp "$DATAMINING/lib/clas/*:$DATAMINING/lib/plugins/*" org.jlab.io.evio.EvioRingSource $* +java -Xms1024m -cp "$CLAS12DIR/lib/clas/*:$CLAS12DIR/lib/plugins/*" org.jlab.io.evio.EvioRingSource $* diff --git a/bin/x-server b/bin/x-server index f3e2c73090..5dc9385ea6 100755 --- a/bin/x-server +++ b/bin/x-server @@ -2,20 +2,4 @@ source `dirname $0`/env.sh -#CLARA_HOME=`dirname $0` -#CLARA_SERVICES=`dirname $0` -#DATAMINING=`dirname $0` - -echo +------------------------------------------------------------------------- -echo "| Starting CLARA-PLATFORM with CLARA_SERVICES = " $CLARA_SERVICES -echo +------------------------------------------------------------------------- -echo "\n" - -echo "INSTALLATION DIRECTORY = " $CLARA_HOME -echo "LIBRARY DIRECTORY = " $DATAMINING/lib/clas/ - -#java -cp "$DATAMINING/lib/clas/core/*" org.jlab.coda.eventViewer.EventTreeFrame $* -#java -Xms1024m -cp "$DATAMINING/lib/clas/*:$DATAMINING/lib/plugins/*" org.jlab.io.hipo.HipoDataSync $* -#java -XX:+UseNUMA -XX:+UseBiasedLocking -cp "$DATAMINING/lib/clas/*:$DATAMINING/lib/plugins/*" org.jlab.coda.xmsg.sys.xMsgProxy & -#java -cp "$DATAMINING/lib/clas/*:$DATAMINING/lib/plugins/*" org.jlab.coda.xmsg.sys.xMsgProxy -java -Xms1024m -cp "$DATAMINING/lib/clas/*:$DATAMINING/lib/plugins/*" org.jlab.clas.service.DataDistributionService $* +java -Xms1024m -cp "$CLAS12DIR/lib/clas/*:$CLAS12DIR/lib/plugins/*" org.jlab.clas.service.DataDistributionService $* From 160f1b94edecde378822ae29f622478f013b16da Mon Sep 17 00:00:00 2001 From: baltzell Date: Wed, 31 Jul 2019 20:18:25 -0400 Subject: [PATCH 016/235] add timestamp-based lookup of tag=1 RUN::scaler banks --- .../org/jlab/detector/decode/DaqScalers.java | 28 +-- .../detector/decode/DaqScalersSequence.java | 184 ++++++++++++++++++ 2 files changed, 201 insertions(+), 11 deletions(-) create mode 100644 common-tools/clas-detector/src/main/java/org/jlab/detector/decode/DaqScalersSequence.java diff --git a/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/DaqScalers.java b/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/DaqScalers.java index f85c45e95e..8102364c9d 100644 --- a/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/DaqScalers.java +++ b/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/DaqScalers.java @@ -41,16 +41,33 @@ public class DaqScalers { private float beamCharge=0; private float beamChargeGated=0; private float livetime=0; + private long timestamp = 0; public Dsc2RawReading dsc2=null; public StruckRawReading struck=null; + public void setTimestamp(long timestamp) { this.timestamp=timestamp; } private void setBeamCharge(float q) { this.beamCharge=q; } private void setBeamChargeGated(float q) { this.beamChargeGated=q; } private void setLivetime(float l) { this.livetime=l; } public float getBeamCharge() { return beamCharge; } public float getBeamChargeGated() { return beamChargeGated; } public float getLivetime() { return livetime; } + public long getTimestamp() { return timestamp; } public void show() { System.out.println("BCG=%.3f LT=%.3f"); } + /** + * @param runScalerBank HIPO RUN::scaler bank + */ + public static DaqScalers create(Bank runScalerBank) { + DaqScalers ds=new DaqScalers(); + for (int ii=0; ii { + + private final List scalers=new ArrayList<>(); + + @Override + public int compare(DaqScalers o1, DaqScalers o2) { + if (o1.getTimestamp() < o2.getTimestamp()) return -1; + if (o1.getTimestamp() > o2.getTimestamp()) return +1; + return 0; + } + + private int findIndex(long timestamp) { + if (this.scalers.isEmpty()) return -1; + if (timestamp < this.scalers.get(0).getTimestamp()) return -1; + if (timestamp > this.scalers.get(this.scalers.size()-1).getTimestamp()) return -1; + // make a fake state for timestamp search: + DaqScalers ds=new DaqScalers(); + ds.setTimestamp(timestamp); + final int index=Collections.binarySearch(this.scalers,ds,new DaqScalersSequence()); + final int n = index<0 ? -index-2 : index; + return n; + } + + protected boolean add(DaqScalers ds) { + if (this.scalers.isEmpty()) { + this.scalers.add(ds); + return true; + } + else { + final int index=Collections.binarySearch(this.scalers,ds,new DaqScalersSequence()); + if (index==this.scalers.size()) { + // its timestamp is later than the existing sequence: + this.scalers.add(ds); + return true; + } + else if (index<0) { + // it's a unique timestamp, insert it: + this.scalers.add(-index-1,ds); + return true; + } + else { + // it's a duplicate timestamp, ignore it: + return false; + } + } + } + + /** + * @param timestamp TI timestamp (i.e. RUN::config.timestamp) + * @return the most recent DaqScalers for the given timestamp + */ + public DaqScalers get(long timestamp) { + final int n=this.findIndex(timestamp); + if (n>=0) return this.scalers.get(n); + return null; + } + + /** + * This reads tag=1 events for RUN::scaler banks, and initializes and returns + * a {@link DaqScalersSequence} that can be used to access the most recent scaler + * readout for any given event. + * + * @param filenames list of names of HIPO files to read + * @return sequence + */ + public static DaqScalersSequence readSequence(List filenames) { + + DaqScalersSequence seq=new DaqScalersSequence(); + + for (String filename : filenames) { + + HipoReader reader = new HipoReader(); + reader.setTags(1); + reader.open(filename); + + SchemaFactory schema = reader.getSchemaFactory(); + + while (reader.hasNext()) { + + Event event=new Event(); + Bank scalerBank=new Bank(schema.getSchema("RUN::scaler")); + Bank configBank=new Bank(schema.getSchema("RUN::config")); + + reader.nextEvent(event); + event.read(scalerBank); + event.read(configBank); + + long timestamp=0; + + if (scalerBank.getRows()<1) continue; + if (configBank.getRows()>0) { + timestamp=configBank.getLong("timestamp",0); + } + + DaqScalers ds=DaqScalers.create(scalerBank); + ds.setTimestamp(timestamp); + seq.add(ds); + } + + reader.close(); + } + + return seq; + } + + public static void main(String[] args) { + + final String dir="/Users/baltzell/data/CLAS12/rg-a/decoded/6b.2.0/"; + final String file="clas_005038.evio.00000-00004.hipo"; + //final String dir="/Users/baltzell/data/CLAS12/rg-b/decoded/"; + //final String file="clas_006432.evio.00041-00042.hipo"; + + List filenames=new ArrayList<>(); + if (args.length>0) filenames.addAll(Arrays.asList(args)); + else filenames.add(dir+file); + + // 1!!!1 initialize a sequence from tag=1 events: + DaqScalersSequence seq = DaqScalersSequence.readSequence(filenames); + + long good=0; + long bad=0; + + for (String filename : filenames) { + + HipoReader reader = new HipoReader(); + reader.setTags(0); + reader.open(filename); + + SchemaFactory schema = reader.getSchemaFactory(); + + while (reader.hasNext()) { + + Bank rcfgBank=new Bank(schema.getSchema("RUN::config")); + + Event event=new Event(); + reader.nextEvent(event); + + event.read(rcfgBank); + + long timestamp = -1; + if (rcfgBank.getRows()>0) + timestamp = rcfgBank.getLong("timestamp",0); + + // 2!!!2 use the timestamp to get the most recent scaler data: + DaqScalers ds=seq.get(timestamp); + + if (ds==null) { + bad++; + } + else { + good++; + // do something useful with beam charge here: + } + } + + System.out.println("DaqScalersSequence: bad/good/badPercent: " + +bad+" "+good+" "+100*((float)bad)/(bad+good)+"%"); + + reader.close(); + + } + } +} From 21cf2d667043ac02ae698eeb6f0ec1e9d8850dba Mon Sep 17 00:00:00 2001 From: baltzell Date: Thu, 1 Aug 2019 11:22:20 -0400 Subject: [PATCH 017/235] fix scaler lookup for events after final readout --- .../java/org/jlab/detector/decode/DaqScalersSequence.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/DaqScalersSequence.java b/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/DaqScalersSequence.java index e7aeab124d..197a9222d6 100644 --- a/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/DaqScalersSequence.java +++ b/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/DaqScalersSequence.java @@ -33,7 +33,8 @@ public int compare(DaqScalers o1, DaqScalers o2) { private int findIndex(long timestamp) { if (this.scalers.isEmpty()) return -1; if (timestamp < this.scalers.get(0).getTimestamp()) return -1; - if (timestamp > this.scalers.get(this.scalers.size()-1).getTimestamp()) return -1; + // assume late timestamps are ok and go with last readout, so comment this out: + //if (timestamp > this.scalers.get(this.scalers.size()-1).getTimestamp()) return -1; // make a fake state for timestamp search: DaqScalers ds=new DaqScalers(); ds.setTimestamp(timestamp); @@ -171,6 +172,7 @@ public static void main(String[] args) { else { good++; // do something useful with beam charge here: + System.out.println(timestamp+" "+ds.getBeamCharge()+" "+ds.getBeamChargeGated()); } } From 929e0d3e1cb70a57cead7e8ce5095860df548c7c Mon Sep 17 00:00:00 2001 From: ziegler Date: Mon, 5 Aug 2019 11:53:30 -0400 Subject: [PATCH 018/235] Fix layer eff analyzer for emptly lists. --- .../service/dc/LayerEfficiencyAnalyzer.java | 393 +++++------------- 1 file changed, 107 insertions(+), 286 deletions(-) diff --git a/reconstruction/dc/src/main/java/org/jlab/service/dc/LayerEfficiencyAnalyzer.java b/reconstruction/dc/src/main/java/org/jlab/service/dc/LayerEfficiencyAnalyzer.java index eaa966c52a..d0533cbc3c 100644 --- a/reconstruction/dc/src/main/java/org/jlab/service/dc/LayerEfficiencyAnalyzer.java +++ b/reconstruction/dc/src/main/java/org/jlab/service/dc/LayerEfficiencyAnalyzer.java @@ -8,12 +8,12 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.concurrent.atomic.AtomicInteger; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JTabbedPane; import org.jlab.clas.swimtools.MagFieldsEngine; -import org.jlab.clas.swimtools.Swim; import org.jlab.io.hipo.HipoDataSource; import org.jlab.rec.dc.Constants; @@ -36,8 +36,10 @@ import org.jlab.rec.dc.hit.FittedHit; import org.jlab.rec.dc.segment.Segment; import org.jlab.rec.dc.segment.SegmentFinder; +import org.jlab.rec.dc.timetodistance.TableLoader; import org.jlab.rec.dc.timetodistance.TimeToDistanceEstimator; import org.jlab.rec.dc.trajectory.SegmentTrajectory; +import org.jlab.utils.groups.IndexedTable; public class LayerEfficiencyAnalyzer extends DCEngine implements IDataEventListener{ @@ -80,9 +82,17 @@ public LayerEfficiencyAnalyzer(){ private EmbeddedCanvas can12 = null; public double[] maxDoca = new double[6]; + + private AtomicInteger Run = new AtomicInteger(0); + + private int newRun = 0; @Override public boolean init() { + + Constants.Load(); + super.setOptions(); super.LoadTables(); + Constants.setT2D(1); maxDoca[0]=0.8;maxDoca[1]=0.9;maxDoca[2]=1.3;maxDoca[3]=1.4;maxDoca[4]=1.9;maxDoca[5]=2.0; //plots @@ -111,83 +121,24 @@ public boolean init() { can12 = new EmbeddedCanvas(); can12.divide(2, 3); // create histograms - for(int i =0; i<6; i++) { - - LayerEffs1.put(new Coordinate(i), - new H1F("Sector-1 layer efficiencies" + (i + 1), "superlayer" + (i + 1), 6, 0.5, 6.5)); - LayerEffs1.get(new Coordinate(i)).setTitleX("Layer" ); - LayerEffs1.get(new Coordinate(i)).setTitleY("Efficiency for superlayer "+(i+1) ); - - LayerEffs2.put(new Coordinate(i), - new H1F("Sector-2 layer efficiencies" + (i + 1), "superlayer" + (i + 1), 6, 0.5, 6.5)); - LayerEffs2.get(new Coordinate(i)).setTitleX("Layer" ); - LayerEffs2.get(new Coordinate(i)).setTitleY("Efficiency for superlayer "+(i+1) ); - - LayerEffs3.put(new Coordinate(i), - new H1F("Sector-3 layer efficiencies" + (i + 1), "superlayer" + (i + 1), 6, 0.5, 6.5)); - LayerEffs3.get(new Coordinate(i)).setTitleX("Layer" ); - LayerEffs3.get(new Coordinate(i)).setTitleY("Efficiency for superlayer "+(i+1) ); - - LayerEffs4.put(new Coordinate(i), - new H1F("Sector-4 layer efficiencies" + (i + 1), "superlayer" + (i + 1), 6, 0.5, 6.5)); - LayerEffs4.get(new Coordinate(i)).setTitleX("Layer" ); - LayerEffs4.get(new Coordinate(i)).setTitleY("Efficiency for superlayer "+(i+1) ); - - LayerEffs5.put(new Coordinate(i), - new H1F("Sector-5 layer efficiencies" + (i + 1), "superlayer" + (i + 1), 6, 0.5, 6.5)); - LayerEffs5.get(new Coordinate(i)).setTitleX("Layer" ); - LayerEffs5.get(new Coordinate(i)).setTitleY("Efficiency for superlayer "+(i+1) ); - - LayerEffs6.put(new Coordinate(i), - new H1F("Sector-6 layer efficiencies" + (i + 1), "superlayer" + (i + 1), 6, 0.5, 6.5)); - LayerEffs6.get(new Coordinate(i)).setTitleX("Layer" ); - LayerEffs6.get(new Coordinate(i)).setTitleY("Efficiency for superlayer "+(i+1) ); - - LayerEffsTrkD1.put(new Coordinate(i), - new H1F("Sector-1 layer inefficiencies vs trkDoca" + (i + 1), "superlayer" + (i + 1), 40, 0.0, 4.0)); - LayerEffsTrkD1.get(new Coordinate(i)).setTitleX("Track Doca (cm)" ); - LayerEffsTrkD1.get(new Coordinate(i)).setTitleY("Inefficiency for superlayer "+(i+1) ); - - LayerEffsTrkD2.put(new Coordinate(i), - new H1F("Sector-2 layer inefficiencies vs trkDoca" + (i + 1), "superlayer" + (i + 1), 40, 0.0, 4.0)); - LayerEffsTrkD2.get(new Coordinate(i)).setTitleX("Track Doca (cm)" ); - LayerEffsTrkD2.get(new Coordinate(i)).setTitleY("Inefficiency for superlayer "+(i+1) ); - - LayerEffsTrkD3.put(new Coordinate(i), - new H1F("Sector-3 layer inefficiencies vs trkDoca" + (i + 1), "superlayer" + (i + 1), 40, 0.0, 4.0)); - LayerEffsTrkD3.get(new Coordinate(i)).setTitleX("Track Doca (cm)" ); - LayerEffsTrkD3.get(new Coordinate(i)).setTitleY("Inefficiency for superlayer "+(i+1) ); - - LayerEffsTrkD4.put(new Coordinate(i), - new H1F("Sector-4 layer inefficiencies vs trkDoca" + (i + 1), "superlayer" + (i + 1), 40, 0.0, 4.0)); - LayerEffsTrkD4.get(new Coordinate(i)).setTitleX("Track Doca (cm)" ); - LayerEffsTrkD4.get(new Coordinate(i)).setTitleY("Inefficiency for superlayer "+(i+1) ); - - LayerEffsTrkD5.put(new Coordinate(i), - new H1F("Sector-5 layer inefficiencies vs trkDoca" + (i + 1), "superlayer" + (i + 1), 40, 0.0, 4.0)); - LayerEffsTrkD5.get(new Coordinate(i)).setTitleX("Track Doca (cm)" ); - LayerEffsTrkD5.get(new Coordinate(i)).setTitleY("Inefficiency for superlayer "+(i+1) ); - - LayerEffsTrkD6.put(new Coordinate(i), - new H1F("Sector-6 layer inefficiencies vs trkDoca" + (i + 1), "superlayer" + (i + 1), 40, 0.0, 4.0)); - LayerEffsTrkD6.get(new Coordinate(i)).setTitleX("Track Doca (cm)" ); - LayerEffsTrkD6.get(new Coordinate(i)).setTitleY("Inefficiency for superlayer "+(i+1) ); - - - this.setHistosAtt(LayerEffs1.get(new Coordinate(i)), 4); - this.setHistosAtt(LayerEffs2.get(new Coordinate(i)), 4); - this.setHistosAtt(LayerEffs3.get(new Coordinate(i)), 4); - this.setHistosAtt(LayerEffs4.get(new Coordinate(i)), 4); - this.setHistosAtt(LayerEffs5.get(new Coordinate(i)), 4); - this.setHistosAtt(LayerEffs6.get(new Coordinate(i)), 4); - this.setHistosAtt(LayerEffsTrkD1.get(new Coordinate(i)), 2); - this.setHistosAtt(LayerEffsTrkD2.get(new Coordinate(i)), 2); - this.setHistosAtt(LayerEffsTrkD3.get(new Coordinate(i)), 2); - this.setHistosAtt(LayerEffsTrkD4.get(new Coordinate(i)), 2); - this.setHistosAtt(LayerEffsTrkD5.get(new Coordinate(i)), 2); - this.setHistosAtt(LayerEffsTrkD6.get(new Coordinate(i)), 2); + for(int si =0; si<6; si++) { + LayerEffs.add(new HashMap()); + for(int i =0; i<6; i++) { + LayerEffs.get(si).put(new Coordinate(i), + new H1F("Sector-"+si+" layer efficiencies" + (i + 1), "superlayer" + (i + 1), 6, 0.5, 6.5)); + LayerEffs.get(si).get(new Coordinate(i)).setTitleX("Layer" ); + LayerEffs.get(si).get(new Coordinate(i)).setTitleY("Efficiency for superlayer "+(i+1) ); + + + LayerEffsTrkD.get(si).put(new Coordinate(i), + new H1F("Sector-"+si+" layer inefficiencies vs trkDoca" + (i + 1), "superlayer" + (i + 1), 40, 0.0, 4.0)); + LayerEffsTrkD.get(si).get(new Coordinate(i)).setTitleX("Track Doca (cm)" ); + LayerEffsTrkD.get(si).get(new Coordinate(i)).setTitleY("Inefficiency for superlayer "+(i+1) ); + + this.setHistosAtt(LayerEffs.get(si).get(new Coordinate(i)), 4); + this.setHistosAtt(LayerEffsTrkD.get(si).get(new Coordinate(i)), 2); + } } - tabbedPane.add("Sector-1 Layer Efficiencies", can1); tabbedPane.add("Sector-2 Layer Efficiencies", can2); tabbedPane.add("Sector-3 Layer Efficiencies", can3); @@ -195,7 +146,7 @@ public boolean init() { tabbedPane.add("Sector-5 Layer Efficiencies", can5); tabbedPane.add("Sector-6 Layer Efficiencies", can6); - tabbedPane.add("Sector-1 Infficiencies vs Track Doca", can7); + tabbedPane.add("Sector-1 Inefficiencies vs Track Doca", can7); tabbedPane.add("Sector-2 Inefficiencies vs Track Doca", can8); tabbedPane.add("Sector-3 Inefficiencies vs Track Doca", can9); tabbedPane.add("Sector-4 Inefficiencies vs Track Doca", can10); @@ -259,75 +210,70 @@ public boolean equals(Object obj) { } } - private Map LayerEffs1 = new HashMap(); - private Map LayerEffs2 = new HashMap(); - private Map LayerEffs3 = new HashMap(); - private Map LayerEffs4 = new HashMap(); - private Map LayerEffs5 = new HashMap(); - private Map LayerEffs6 = new HashMap(); - private Map LayerEffsTrkD1 = new HashMap(); - private Map LayerEffsTrkD2 = new HashMap(); - private Map LayerEffsTrkD3 = new HashMap(); - private Map LayerEffsTrkD4 = new HashMap(); - private Map LayerEffsTrkD5 = new HashMap(); - private Map LayerEffsTrkD6 = new HashMap(); - + private ArrayList> LayerEffs = new ArrayList>(); + private ArrayList> LayerEffsTrkD = new ArrayList>(); - @Override + //instantiate bank writer + RecoBankWriter rbc = new RecoBankWriter(); + HitReader hitRead = new HitReader(); + + @Override public boolean processDataEvent(DataEvent event) { - //setRunConditionsParameters( event) ; - if(event.hasBank("RUN::config")==false) { - System.err.println("RUN CONDITIONS NOT READ AT TIMEBASED LEVEL!"); + if (!event.hasBank("RUN::config")) { return true; } - //if(event.getBank("RECHB::Event").getFloat("startTime", 0)<0) - // return true; // require the start time to reconstruct the tracks in the event - - DataBank bank = event.getBank("RUN::config"); + + DataBank bank = event.getBank("RUN::config"); + long timeStamp = bank.getLong("timestamp", 0); + double triggerPhase = 0; + // Load the constants //------------------- int newRun = bank.getInt("run", 0); - if(newRun==0) - return true; - - double T_Start = 0; - if(Constants.isUSETSTART() == true) { - if(event.hasBank("RECHB::Event")==true) { - T_Start = event.getBank("RECHB::Event").getFloat("startTime", 0); - if(T_Start<0) { - return true; // quit if start time not found in data - } - } else { - return true; // no REC HB bank - } - } - // get Field - Swim dcSwim = new Swim(); + if (newRun == 0) + return true; + + if (Run.get() == 0 || (Run.get() != 0 && Run.get() != newRun)) { + if (timeStamp == -1) + return true; + // if (debug.get()) startTime = System.currentTimeMillis(); + IndexedTable tabJ = super.getConstantsManager().getConstants(newRun, Constants.TIMEJITTER); + double period = tabJ.getDoubleValue("period", 0, 0, 0); + int phase = tabJ.getIntValue("phase", 0, 0, 0); + int cycles = tabJ.getIntValue("cycles", 0, 0, 0); + + if (cycles > 0) triggerPhase = period * ((timeStamp + phase) % cycles); + + TableLoader.FillT0Tables(newRun, super.variationName); + TableLoader.Fill(super.getConstantsManager().getConstants(newRun, Constants.TIME2DIST)); + + Run.set(newRun); + if (event.hasBank("MC::Particle") && this.getEngineConfigString("wireDistort")==null) { + Constants.setWIREDIST(0); + } + } //System.out.println(" RUNNING TIME BASED...................................."); ClusterFitter cf = new ClusterFitter(); ClusterCleanerUtilities ct = new ClusterCleanerUtilities(); - List fhits = new ArrayList(); List clusters = new ArrayList(); List segments = new ArrayList(); - //instantiate bank writer - RecoBankWriter rbc = new RecoBankWriter(); - - HitReader hitRead = new HitReader(); + hitRead.read_HBHits(event, super.getConstantsManager().getConstants(newRun, "/calibration/dc/signal_generation/doca_resolution"), super.getConstantsManager().getConstants(newRun, "/calibration/dc/time_to_distance/time2dist"), Constants.getT0(), Constants.getT0Err(), dcDetector, tde); - hitRead.read_TBHits(event, - super.getConstantsManager().getConstants(newRun, "/calibration/dc/signal_generation/doca_resolution"), - super.getConstantsManager().getConstants(newRun, "/calibration/dc/time_to_distance/time2dist"), tde, Constants.getT0(), Constants.getT0Err()); + //hitRead.read_TBHits(event, + // super.getConstantsManager().getConstants(newRun, "/calibration/dc/signal_generation/doca_resolution"), + // super.getConstantsManager().getConstants(newRun, "/calibration/dc/time_to_distance/time2dist"), tde, Constants.getT0(), Constants.getT0Err()); List hits = new ArrayList(); //I) get the hits - if(hitRead.get_TBHits().isEmpty()) { + if(hitRead.get_HBHits()==null) + return true; + if(!hitRead.get_HBHits().isEmpty()) { hits = hitRead.get_HBHits(); - } else { - hits = hitRead.get_TBHits(); + return true; } //II) process the hits @@ -371,6 +317,7 @@ public boolean processDataEvent(DataEvent event) { index++; } } + event.appendBank(bankE); } return true; @@ -406,178 +353,58 @@ private void ProcessLayerEffs(DataEvent event) { } if(totLay[Bank.getByte("sector", i)-1][Bank.getByte("superlayer", i)-1][Bank.getByte("layer", i)-1]>0) { - if(Bank.getByte("sector", i)==1) { - float d = effLay[Bank.getByte("sector", i)-1][Bank.getByte("superlayer", i)-1][Bank.getByte("layer", i)-1]; - float n = totLay[Bank.getByte("sector", i)-1][Bank.getByte("superlayer", i)-1][Bank.getByte("layer", i)-1]; - float err = (float) (Math.sqrt(d*(d/n+1))/n); - LayerEffs1 - .get(new Coordinate(Bank.getByte("superlayer", i) - 1)) - .setBinContent(Bank.getByte("layer", i)-1,(float)100*d/ (float)n); - LayerEffs1 - .get(new Coordinate(Bank.getByte("superlayer", i) - 1)) - .setBinError(Bank.getByte("layer", i)-1,(float)100*err); - - if(Math.abs(Bank.getFloat("trkDoca", i))<4.0) { - float ddc = effLayA[Bank.getByte("sector", i)-1][Bank.getByte("superlayer", i)-1][(int)((Math.floor(Math.abs(Bank.getFloat("trkDoca", i))/trkDBinning)))]; - float ndc = totLayA[Bank.getByte("sector", i)-1][Bank.getByte("superlayer", i)-1][(int)((Math.floor(Math.abs(Bank.getFloat("trkDoca", i))/trkDBinning)))]; - float errdc = (float) (Math.sqrt(ddc*(ddc/ndc+1))/ndc); - LayerEffsTrkD1 - .get(new Coordinate(Bank.getByte("superlayer", i) - 1)) - .setBinContent((int)((Math.floor(Math.abs(Bank.getFloat("trkDoca", i))/trkDBinning))),(float)100*ddc/ (float)ndc); - LayerEffsTrkD1 - .get(new Coordinate(Bank.getByte("superlayer", i) - 1)) - .setBinError((int)((Math.floor(Math.abs(Bank.getFloat("trkDoca", i))/trkDBinning))),(float)100*errdc); - } - } - if(Bank.getByte("sector", i)==2) { - float d = effLay[Bank.getByte("sector", i)-1][Bank.getByte("superlayer", i)-1][Bank.getByte("layer", i)-1]; - float n = totLay[Bank.getByte("sector", i)-1][Bank.getByte("superlayer", i)-1][Bank.getByte("layer", i)-1]; - float err = (float) (Math.sqrt(d*(d/n+1))/n); - LayerEffs2 - .get(new Coordinate(Bank.getByte("superlayer", i) - 1)) + float d = effLay[Bank.getByte("sector", i)-1][Bank.getByte("superlayer", i)-1][Bank.getByte("layer", i)-1]; + float n = totLay[Bank.getByte("sector", i)-1][Bank.getByte("superlayer", i)-1][Bank.getByte("layer", i)-1]; + float err = (float) (Math.sqrt(d*(d/n+1))/n); + + LayerEffs.get(Bank.getByte("sector", i)-1).get(new Coordinate(Bank.getByte("superlayer", i) - 1)) .setBinContent(Bank.getByte("layer", i)-1,(float)100*d/ (float)n); - LayerEffs2 - .get(new Coordinate(Bank.getByte("superlayer", i) - 1)) + LayerEffs.get(Bank.getByte("sector", i)-1).get(new Coordinate(Bank.getByte("superlayer", i) - 1)) .setBinError(Bank.getByte("layer", i)-1,(float)100*err); - - if(Math.abs(Bank.getFloat("trkDoca", i))<4.0) { + if(Math.abs(Bank.getFloat("trkDoca", i))<4.0) { float ddc = effLayA[Bank.getByte("sector", i)-1][Bank.getByte("superlayer", i)-1][(int)((Math.floor(Math.abs(Bank.getFloat("trkDoca", i))/trkDBinning)))]; float ndc = totLayA[Bank.getByte("sector", i)-1][Bank.getByte("superlayer", i)-1][(int)((Math.floor(Math.abs(Bank.getFloat("trkDoca", i))/trkDBinning)))]; float errdc = (float) (Math.sqrt(ddc*(ddc/ndc+1))/ndc); - LayerEffsTrkD2 + LayerEffsTrkD.get(Bank.getByte("sector", i)-1) .get(new Coordinate(Bank.getByte("superlayer", i) - 1)) .setBinContent((int)((Math.floor(Math.abs(Bank.getFloat("trkDoca", i))/trkDBinning))),(float)100*ddc/ (float)ndc); - LayerEffsTrkD2 + LayerEffsTrkD.get(Bank.getByte("sector", i)-1) .get(new Coordinate(Bank.getByte("superlayer", i) - 1)) .setBinError((int)((Math.floor(Math.abs(Bank.getFloat("trkDoca", i))/trkDBinning))),(float)100*errdc); - } - } - if(Bank.getByte("sector", i)==3) { - float d = effLay[Bank.getByte("sector", i)-1][Bank.getByte("superlayer", i)-1][Bank.getByte("layer", i)-1]; - float n = totLay[Bank.getByte("sector", i)-1][Bank.getByte("superlayer", i)-1][Bank.getByte("layer", i)-1]; - float err = (float) (Math.sqrt(d*(d/n+1))/n); - LayerEffs3 - .get(new Coordinate(Bank.getByte("superlayer", i) - 1)) - .setBinContent(Bank.getByte("layer", i)-1,(float)100*d/ (float)n); - LayerEffs3 - .get(new Coordinate(Bank.getByte("superlayer", i) - 1)) - .setBinError(Bank.getByte("layer", i)-1,(float)100*err); - - if(Math.abs(Bank.getFloat("trkDoca", i))<4.0) { - float ddc = effLayA[Bank.getByte("sector", i)-1][Bank.getByte("superlayer", i)-1][(int)((Math.floor(Math.abs(Bank.getFloat("trkDoca", i))/trkDBinning)))]; - float ndc = totLayA[Bank.getByte("sector", i)-1][Bank.getByte("superlayer", i)-1][(int)((Math.floor(Math.abs(Bank.getFloat("trkDoca", i))/trkDBinning)))]; - float errdc = (float) (Math.sqrt(ddc*(ddc/ndc+1))/ndc); - LayerEffsTrkD3 - .get(new Coordinate(Bank.getByte("superlayer", i) - 1)) - .setBinContent((int)((Math.floor(Math.abs(Bank.getFloat("trkDoca", i))/trkDBinning))),(float)100*ddc/ (float)ndc); - LayerEffsTrkD3 - .get(new Coordinate(Bank.getByte("superlayer", i) - 1)) - .setBinError((int)((Math.floor(Math.abs(Bank.getFloat("trkDoca", i))/trkDBinning))),(float)100*errdc); - } - } - if(Bank.getByte("sector", i)==4) { - float d = effLay[Bank.getByte("sector", i)-1][Bank.getByte("superlayer", i)-1][Bank.getByte("layer", i)-1]; - float n = totLay[Bank.getByte("sector", i)-1][Bank.getByte("superlayer", i)-1][Bank.getByte("layer", i)-1]; - float err = (float) (Math.sqrt(d*(d/n+1))/n); - LayerEffs4 - .get(new Coordinate(Bank.getByte("superlayer", i) - 1)) - .setBinContent(Bank.getByte("layer", i)-1,(float)100*d/ (float)n); - LayerEffs4 - .get(new Coordinate(Bank.getByte("superlayer", i) - 1)) - .setBinError(Bank.getByte("layer", i)-1,(float)100*err); - - if(Math.abs(Bank.getFloat("trkDoca", i))<4.0) { - float ddc = effLayA[Bank.getByte("sector", i)-1][Bank.getByte("superlayer", i)-1][(int)((Math.floor(Math.abs(Bank.getFloat("trkDoca", i))/trkDBinning)))]; - float ndc = totLayA[Bank.getByte("sector", i)-1][Bank.getByte("superlayer", i)-1][(int)((Math.floor(Math.abs(Bank.getFloat("trkDoca", i))/trkDBinning)))]; - float errdc = (float) (Math.sqrt(ddc*(ddc/ndc+1))/ndc); - LayerEffsTrkD4 - .get(new Coordinate(Bank.getByte("superlayer", i) - 1)) - .setBinContent((int)((Math.floor(Math.abs(Bank.getFloat("trkDoca", i))/trkDBinning))),(float)100*ddc/ (float)ndc); - LayerEffsTrkD4 - .get(new Coordinate(Bank.getByte("superlayer", i) - 1)) - .setBinError((int)((Math.floor(Math.abs(Bank.getFloat("trkDoca", i))/trkDBinning))),(float)100*errdc); - } - } - if(Bank.getByte("sector", i)==5) { - float d = effLay[Bank.getByte("sector", i)-1][Bank.getByte("superlayer", i)-1][Bank.getByte("layer", i)-1]; - float n = totLay[Bank.getByte("sector", i)-1][Bank.getByte("superlayer", i)-1][Bank.getByte("layer", i)-1]; - float err = (float) (Math.sqrt(d*(d/n+1))/n); - LayerEffs5 - .get(new Coordinate(Bank.getByte("superlayer", i) - 1)) - .setBinContent(Bank.getByte("layer", i)-1,(float)100*d/ (float)n); - LayerEffs5 - .get(new Coordinate(Bank.getByte("superlayer", i) - 1)) - .setBinError(Bank.getByte("layer", i)-1,(float)100*err); - - if(Math.abs(Bank.getFloat("trkDoca", i))<4.0) { - float ddc = effLayA[Bank.getByte("sector", i)-1][Bank.getByte("superlayer", i)-1][(int)((Math.floor(Math.abs(Bank.getFloat("trkDoca", i))/trkDBinning)))]; - float ndc = totLayA[Bank.getByte("sector", i)-1][Bank.getByte("superlayer", i)-1][(int)((Math.floor(Math.abs(Bank.getFloat("trkDoca", i))/trkDBinning)))]; - float errdc = (float) (Math.sqrt(ddc*(ddc/ndc+1))/ndc); - LayerEffsTrkD5 - .get(new Coordinate(Bank.getByte("superlayer", i) - 1)) - .setBinContent((int)((Math.floor(Math.abs(Bank.getFloat("trkDoca", i))/trkDBinning))),(float)100*ddc/ (float)ndc); - LayerEffsTrkD5 - .get(new Coordinate(Bank.getByte("superlayer", i) - 1)) - .setBinError((int)((Math.floor(Math.abs(Bank.getFloat("trkDoca", i))/trkDBinning))),(float)100*errdc); - } - } - if(Bank.getByte("sector", i)==6) { - float d = effLay[Bank.getByte("sector", i)-1][Bank.getByte("superlayer", i)-1][Bank.getByte("layer", i)-1]; - float n = totLay[Bank.getByte("sector", i)-1][Bank.getByte("superlayer", i)-1][Bank.getByte("layer", i)-1]; - float err = (float) (Math.sqrt(d*(d/n+1))/n); - LayerEffs6 - .get(new Coordinate(Bank.getByte("superlayer", i) - 1)) - .setBinContent(Bank.getByte("layer", i)-1,(float)100*d/ (float)n); - LayerEffs6 - .get(new Coordinate(Bank.getByte("superlayer", i) - 1)) - .setBinError(Bank.getByte("layer", i)-1,(float)100*err); - - if(Math.abs(Bank.getFloat("trkDoca", i))<4.0) { - float ddc = effLayA[Bank.getByte("sector", i)-1][Bank.getByte("superlayer", i)-1][(int)((Math.floor(Math.abs(Bank.getFloat("trkDoca", i))/trkDBinning)))]; - float ndc = totLayA[Bank.getByte("sector", i)-1][Bank.getByte("superlayer", i)-1][(int)((Math.floor(Math.abs(Bank.getFloat("trkDoca", i))/trkDBinning)))]; - float errdc = (float) (Math.sqrt(ddc*(ddc/ndc+1))/ndc); - LayerEffsTrkD6 - .get(new Coordinate(Bank.getByte("superlayer", i) - 1)) - .setBinContent((int)((Math.floor(Math.abs(Bank.getFloat("trkDoca", i))/trkDBinning))),(float)100*ddc/ (float)ndc); - LayerEffsTrkD6 - .get(new Coordinate(Bank.getByte("superlayer", i) - 1)) - .setBinError((int)((Math.floor(Math.abs(Bank.getFloat("trkDoca", i))/trkDBinning))),(float)100*errdc); - } - } - } - } - - } + } + } + } + } private void drawPlots() { for (int i = 0; i < 6; i++) { can1.cd(i); - can1.draw(LayerEffs1.get(new Coordinate(i)), "E"); + can1.draw(LayerEffs.get(0).get(new Coordinate(i)), "E"); can2.cd(i); - can2.draw(LayerEffs2.get(new Coordinate(i)), "E"); + can2.draw(LayerEffs.get(1).get(new Coordinate(i)), "E"); can3.cd(i); - can3.draw(LayerEffs3.get(new Coordinate(i)), "E"); + can3.draw(LayerEffs.get(2).get(new Coordinate(i)), "E"); can4.cd(i); - can4.draw(LayerEffs4.get(new Coordinate(i)), "E"); + can4.draw(LayerEffs.get(3).get(new Coordinate(i)), "E"); can5.cd(i); - can5.draw(LayerEffs5.get(new Coordinate(i)), "E"); + can5.draw(LayerEffs.get(4).get(new Coordinate(i)), "E"); can6.cd(i); - can6.draw(LayerEffs6.get(new Coordinate(i)), "E"); + can6.draw(LayerEffs.get(5).get(new Coordinate(i)), "E"); can7.cd(i); - can7.draw(LayerEffsTrkD1.get(new Coordinate(i)), "E"); + can7.draw(LayerEffsTrkD.get(0).get(new Coordinate(i)), "E"); can8.cd(i); - can8.draw(LayerEffsTrkD2.get(new Coordinate(i)), "E"); + can8.draw(LayerEffsTrkD.get(1).get(new Coordinate(i)), "E"); can9.cd(i); - can9.draw(LayerEffsTrkD3.get(new Coordinate(i)), "E"); + can9.draw(LayerEffsTrkD.get(2).get(new Coordinate(i)), "E"); can10.cd(i); - can10.draw(LayerEffsTrkD4.get(new Coordinate(i)), "E"); + can10.draw(LayerEffsTrkD.get(3).get(new Coordinate(i)), "E"); can11.cd(i); - can11.draw(LayerEffsTrkD5.get(new Coordinate(i)), "E"); + can11.draw(LayerEffsTrkD.get(4).get(new Coordinate(i)), "E"); can12.cd(i); - can12.draw(LayerEffsTrkD6.get(new Coordinate(i)), "E"); + can12.draw(LayerEffsTrkD.get(5).get(new Coordinate(i)), "E"); can7.getPad(i).getAxisX().setRange(0, this.maxDoca[i]); can8.getPad(i).getAxisX().setRange(0, this.maxDoca[i]); @@ -614,18 +441,10 @@ public void saveHistosToFile(String fileName) { dir.cd(folder); for (int i = 0; i < 6; i++) { - dir.addDataSet(LayerEffs1.get(new Coordinate(i))); - dir.addDataSet(LayerEffs2.get(new Coordinate(i))); - dir.addDataSet(LayerEffs3.get(new Coordinate(i))); - dir.addDataSet(LayerEffs4.get(new Coordinate(i))); - dir.addDataSet(LayerEffs5.get(new Coordinate(i))); - dir.addDataSet(LayerEffs6.get(new Coordinate(i))); - dir.addDataSet(LayerEffsTrkD1.get(new Coordinate(i))); - dir.addDataSet(LayerEffsTrkD2.get(new Coordinate(i))); - dir.addDataSet(LayerEffsTrkD3.get(new Coordinate(i))); - dir.addDataSet(LayerEffsTrkD4.get(new Coordinate(i))); - dir.addDataSet(LayerEffsTrkD5.get(new Coordinate(i))); - dir.addDataSet(LayerEffsTrkD6.get(new Coordinate(i))); + for (int si = 0; si < 6; si++) { + dir.addDataSet(LayerEffs.get(si).get(new Coordinate(i))); + dir.addDataSet(LayerEffsTrkD.get(si).get(new Coordinate(i))); + } } System.out.println("Saving histograms to file " + fileName); dir.writeFile(fileName); @@ -661,13 +480,15 @@ public static void main(String[] args) { while (reader.hasEvent()) { counter++; DataEvent event = reader.getNextEvent(); - enf.processDataEvent(event); - en.processDataEvent(event); + //enf.processDataEvent(event); + //en.processDataEvent(event); tm.processDataEvent(event); tm.ProcessLayerEffs(event); //event.show(); - if(counter%1000==0) + if(counter%10==0) { + System.out.println(counter); tm.drawPlots(); + } } tm.drawPlots(); tm.saveHistosToFile("dclayereffs.hipo"); From 16023b7849aac91ed85fccaccdec44d2d3c8d949 Mon Sep 17 00:00:00 2001 From: baltzell Date: Wed, 7 Aug 2019 17:33:05 -0400 Subject: [PATCH 019/235] switch travis to openjdk11, add dependencies in pom.xmls that are now external in jdk11 (javafx and javax) --- .travis.yml | 5 +- common-tools/clas-geometry/pom.xml | 5 ++ common-tools/clas-io/pom.xml | 6 +++ common-tools/clas-jcsg/pom.xml | 10 ++++ common-tools/cnuphys/bCNU/pom.xml | 75 ++++++++++++++++++------------ 5 files changed, 69 insertions(+), 32 deletions(-) diff --git a/.travis.yml b/.travis.yml index c86c4a70da..2fabe0131c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,13 +5,12 @@ sudo: required language: java jdk: - - oraclejdk9 + - openjdk11 -# this affects which java version is used: addons: apt: packages: - - oracle-java9-installer + - openjfx before_install: - ls -lthra diff --git a/common-tools/clas-geometry/pom.xml b/common-tools/clas-geometry/pom.xml index 89c3559289..8eb040eae3 100644 --- a/common-tools/clas-geometry/pom.xml +++ b/common-tools/clas-geometry/pom.xml @@ -27,6 +27,11 @@ + + org.openjfx + javafx-controls + 11 + org.jlab.ccdb ccdb diff --git a/common-tools/clas-io/pom.xml b/common-tools/clas-io/pom.xml index cf35a7492f..2bf5fd4f61 100644 --- a/common-tools/clas-io/pom.xml +++ b/common-tools/clas-io/pom.xml @@ -28,6 +28,12 @@ + + javax.xml.bind + jaxb-api + 2.3.0 + + org.jlab.coda jevio diff --git a/common-tools/clas-jcsg/pom.xml b/common-tools/clas-jcsg/pom.xml index e5e473f0a9..503ee5f006 100644 --- a/common-tools/clas-jcsg/pom.xml +++ b/common-tools/clas-jcsg/pom.xml @@ -27,6 +27,16 @@ + + org.openjfx + javafx-controls + 11 + + + org.openjfx + javafx-fxml + 11 + org.jlab.clas clas-geometry diff --git a/common-tools/cnuphys/bCNU/pom.xml b/common-tools/cnuphys/bCNU/pom.xml index 372f7fa21c..541b201a00 100755 --- a/common-tools/cnuphys/bCNU/pom.xml +++ b/common-tools/cnuphys/bCNU/pom.xml @@ -16,48 +16,65 @@ + + org.openjfx + javafx-controls + 11 + - - cnuphys - numRec - 1.0 - + + org.openjfx + javafx-swing + 11 + + + + org.openjfx + javafx-controls + 11 + + + + cnuphys + numRec + 1.0 + - cnuphys - splot - 2.0-SNAPSHOT + cnuphys + splot + 2.0-SNAPSHOT - cnuphys - magfield - 2.0-SNAPSHOT + cnuphys + magfield + 2.0-SNAPSHOT - - cnuphys - swimmer - 2.0-SNAPSHOT + + cnuphys + swimmer + 2.0-SNAPSHOT - - org.jlab.coda - cMsg - 3.3 + + org.jlab.coda + cMsg + 3.3 - - org.jlab.coda - et - 14.0 - + + org.jlab.coda + et + 14.0 + - + - - 1.8 - 1.8 - + + 1.8 + 1.8 + From 587c7a8a6014e656c9d5a753851dbeb3216a0741 Mon Sep 17 00:00:00 2001 From: baltzell Date: Wed, 7 Aug 2019 19:53:30 -0400 Subject: [PATCH 020/235] upgrade to up-to-date spotbugs 3.1.12 --- common-tools/cnuphys/parent/pom.xml | 4 ++-- parent/pom.xml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/common-tools/cnuphys/parent/pom.xml b/common-tools/cnuphys/parent/pom.xml index ad21fca710..e546534f02 100755 --- a/common-tools/cnuphys/parent/pom.xml +++ b/common-tools/cnuphys/parent/pom.xml @@ -21,7 +21,7 @@ com.github.spotbugs spotbugs - 3.1.0 + 3.1.12 @@ -38,7 +38,7 @@ com.github.spotbugs spotbugs-maven-plugin - 3.1.0-RC6 + 3.1.12 spotbugs-exclude.xml diff --git a/parent/pom.xml b/parent/pom.xml index 1748420509..d645ef40b3 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -38,7 +38,7 @@ com.github.spotbugs spotbugs - 3.1.0 + 3.1.12 @@ -68,7 +68,7 @@ com.github.spotbugs spotbugs-maven-plugin - 3.1.0-RC6 + 3.1.12 spotbugs-exclude.xml From a75cb0cfe65c0d66e503f370552c2139b151f936 Mon Sep 17 00:00:00 2001 From: Veronique Ziegler Date: Thu, 8 Aug 2019 17:12:54 -0400 Subject: [PATCH 021/235] fix local angle calculation --- .../dc/src/main/java/org/jlab/rec/dc/hit/FittedHit.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reconstruction/dc/src/main/java/org/jlab/rec/dc/hit/FittedHit.java b/reconstruction/dc/src/main/java/org/jlab/rec/dc/hit/FittedHit.java index 80257430f5..035241bb0a 100644 --- a/reconstruction/dc/src/main/java/org/jlab/rec/dc/hit/FittedHit.java +++ b/reconstruction/dc/src/main/java/org/jlab/rec/dc/hit/FittedHit.java @@ -353,7 +353,7 @@ public void set_TimeToDistance(DataEvent event, double cosTrkAngle, double B, In //local angle correction double theta0 = Math.acos(1-0.02*B); - double alpha = Math.acos(cosTrkAngle); + double alpha = Math.atan2(cosTrkAngle, 1.0); // correct alpha with theta0, the angle corresponding to the isochrone lines twist due to the electric field if(event.hasBank("MC::Particle")==false) alpha-=Swimmer.getTorScale()*theta0; From f176cc09beb2390051d2632bd9a7b1bc1c9c04e5 Mon Sep 17 00:00:00 2001 From: ziegler Date: Mon, 12 Aug 2019 16:15:34 -0400 Subject: [PATCH 022/235] Fix bug in local angle calculation. --- .../jlab/rec/dc/cluster/ClusterFinder.java | 13 +++++------- .../jlab/rec/dc/cross/CrossListFinder.java | 8 ++++---- .../java/org/jlab/rec/dc/hit/FittedHit.java | 20 ++++++++++--------- .../jlab/rec/dc/segment/SegmentFinder.java | 4 ++-- 4 files changed, 22 insertions(+), 23 deletions(-) diff --git a/reconstruction/dc/src/main/java/org/jlab/rec/dc/cluster/ClusterFinder.java b/reconstruction/dc/src/main/java/org/jlab/rec/dc/cluster/ClusterFinder.java index 44ab676ceb..7f28fc576d 100644 --- a/reconstruction/dc/src/main/java/org/jlab/rec/dc/cluster/ClusterFinder.java +++ b/reconstruction/dc/src/main/java/org/jlab/rec/dc/cluster/ClusterFinder.java @@ -407,27 +407,24 @@ public List FindTimeBasedClusters(DataEvent event, cf.SetFitArray(clus, "TSC"); cf.Fit(clus, true); - double cosTrkAngle = 1. / Math.sqrt(1. + clus.get_clusterLineFitSlope() * clus.get_clusterLineFitSlope()); - // update the hits for (FittedHit fhit : clus) { - fhit.updateHitPositionWithTime(event, cosTrkAngle, fhit.getB(), tab, DcDetector, tde); + fhit.updateHitPositionWithTime(event, clus.get_clusterLineFitSlope(), fhit.getB(), tab, DcDetector, tde); } // iterate till convergence of trkAngle double Chi2Diff = 1; double prevChi2 = 999999999; - double cosTrkAngleFinal = 0; + double trkAngleFinal = 0; while (Chi2Diff > 0) { cf.SetFitArray(clus, "TSC"); cf.Fit(clus, true); Chi2Diff = prevChi2 - clus.get_Chisq(); if (Chi2Diff > 0) { - cosTrkAngle = 1. / Math.sqrt(1. + clus.get_clusterLineFitSlope() * clus.get_clusterLineFitSlope()); // update the hits for (FittedHit fhit : clus) { - fhit.updateHitPositionWithTime(event, cosTrkAngle, fhit.getB(), tab, DcDetector, tde); + fhit.updateHitPositionWithTime(event, clus.get_clusterLineFitSlope(), fhit.getB(), tab, DcDetector, tde); } - cosTrkAngleFinal = cosTrkAngle; + trkAngleFinal = clus.get_clusterLineFitSlope(); } prevChi2 = clus.get_Chisq(); } @@ -436,7 +433,7 @@ public List FindTimeBasedClusters(DataEvent event, cf.SetResidualDerivedParams(clus, false, false, DcDetector); //calcTimeResidual=false, resetLRAmbig=false for (FittedHit fhit : clus) { - fhit.updateHitPositionWithTime(event, cosTrkAngleFinal, fhit.getB(), tab, DcDetector, tde); + fhit.updateHitPositionWithTime(event, trkAngleFinal, fhit.getB(), tab, DcDetector, tde); } cf.SetFitArray(clus, "TSC"); cf.Fit(clus, true); diff --git a/reconstruction/dc/src/main/java/org/jlab/rec/dc/cross/CrossListFinder.java b/reconstruction/dc/src/main/java/org/jlab/rec/dc/cross/CrossListFinder.java index 049c24a800..aa4e9d62ec 100644 --- a/reconstruction/dc/src/main/java/org/jlab/rec/dc/cross/CrossListFinder.java +++ b/reconstruction/dc/src/main/java/org/jlab/rec/dc/cross/CrossListFinder.java @@ -197,18 +197,18 @@ private void RecalculateCrossDirErr(Cross c1, double slope, double slopeErr) { private void recalcParsSegment(DataEvent event, Segment _Segment1, IndexedTable tab, DCGeant4Factory DcDetector, TimeToDistanceEstimator tde) { //refit - double cosTrkAngle = 1. / Math.sqrt(1. + _Segment1.get_fittedCluster().get_clusterLineFitSlope() * _Segment1.get_fittedCluster().get_clusterLineFitSlope()); + double trkAngle = _Segment1.get_fittedCluster().get_clusterLineFitSlope(); // update the hits for (FittedHit fhit : _Segment1.get_fittedCluster()) { - fhit.updateHitPositionWithTime(event, cosTrkAngle, fhit.getB(), tab, DcDetector, tde); + fhit.updateHitPositionWithTime(event, trkAngle, fhit.getB(), tab, DcDetector, tde); } cf.SetFitArray(_Segment1.get_fittedCluster(), "TSC"); cf.Fit(_Segment1.get_fittedCluster(), true); - cosTrkAngle = 1. / Math.sqrt(1. + _Segment1.get_fittedCluster().get_clusterLineFitSlope() * _Segment1.get_fittedCluster().get_clusterLineFitSlope()); + trkAngle = _Segment1.get_fittedCluster().get_clusterLineFitSlope(); for (FittedHit fhit : _Segment1.get_fittedCluster()) { - fhit.updateHitPositionWithTime(event, cosTrkAngle, fhit.getB(), tab, DcDetector, tde); + fhit.updateHitPositionWithTime(event, trkAngle, fhit.getB(), tab, DcDetector, tde); } cf.SetFitArray(_Segment1.get_fittedCluster(), "TSC"); cf.Fit(_Segment1.get_fittedCluster(), true); diff --git a/reconstruction/dc/src/main/java/org/jlab/rec/dc/hit/FittedHit.java b/reconstruction/dc/src/main/java/org/jlab/rec/dc/hit/FittedHit.java index 035241bb0a..598451fb93 100644 --- a/reconstruction/dc/src/main/java/org/jlab/rec/dc/hit/FittedHit.java +++ b/reconstruction/dc/src/main/java/org/jlab/rec/dc/hit/FittedHit.java @@ -8,7 +8,6 @@ import org.jlab.rec.dc.timetodistance.TimeToDistanceEstimator; import org.jlab.geom.prim.Point3D; import org.jlab.io.base.DataEvent; -import org.jlab.rec.dc.timetodistance.TableLoader; import org.jlab.rec.dc.trajectory.StateVec; import org.jlab.utils.groups.IndexedTable; /** @@ -344,21 +343,23 @@ public void setAssociatedStateVec(StateVec _AssociatedStateVec) { /** * sets the calculated distance (in cm) from the time (in ns) */ - public void set_TimeToDistance(DataEvent event, double cosTrkAngle, double B, IndexedTable tab,TimeToDistanceEstimator tde) { + public void set_TimeToDistance(DataEvent event, double trkAngle, double B, IndexedTable tab,TimeToDistanceEstimator tde) { double distance = 0; int slIdx = this.get_Superlayer() - 1; int secIdx = this.get_Sector() - 1; if (_TrkgStatus != -1 && this.get_Time() > 0) { - + //local angle correction double theta0 = Math.acos(1-0.02*B); - double alpha = Math.atan2(cosTrkAngle, 1.0); + double alpha = Math.atan(trkAngle); + // correct alpha with theta0, the angle corresponding to the isochrone lines twist due to the electric field if(event.hasBank("MC::Particle")==false) alpha-=Swimmer.getTorScale()*theta0; - //reduce the corrected angle + this.setAlpha(Math.toDegrees(alpha)); + //reduce the corrected angle double ralpha = this.reducedAngle(alpha); double beta = this.get_Beta0to1(); double x = this.get_ClusFitDoca(); @@ -502,9 +503,9 @@ public void updateHitPosition(DCGeant4Factory DcDetector) { * A method to update the hit position information after the fit to the wire * positions employing hit-based tracking algorithms has been performed. */ - public void updateHitPositionWithTime(DataEvent event, double cosTrkAngle, double B, IndexedTable tab, DCGeant4Factory DcDetector, TimeToDistanceEstimator tde) { + public void updateHitPositionWithTime(DataEvent event, double trkAngle, double B, IndexedTable tab, DCGeant4Factory DcDetector, TimeToDistanceEstimator tde) { if (this.get_Time() > 0) { - this.set_TimeToDistance(event, cosTrkAngle, B, tab, tde); + this.set_TimeToDistance(event, trkAngle, B, tab, tde); } double z = DcDetector.getWireMidpoint(this.get_Sector() - 1, this.get_Superlayer() - 1, this.get_Layer() - 1, this.get_Wire() - 1).z; @@ -512,8 +513,9 @@ public void updateHitPositionWithTime(DataEvent event, double cosTrkAngle, doubl double x = this.calc_GeomCorr(DcDetector, 0); //this.set_X(x+this.get_LeftRightAmb()*this.get_TimeToDistance()); double MPCorr = 1; - if (cosTrkAngle > 0.8 & cosTrkAngle <= 1) { - MPCorr = cosTrkAngle; + double cosTkAng = 1./Math.sqrt(trkAngle*trkAngle + 1.); + if (cosTkAng > 0.8 & cosTkAng <= 1) { + MPCorr = cosTkAng; } this.set_X(x + this.get_LeftRightAmb() * (this.get_TimeToDistance() / MPCorr) / FastMath.cos(Math.toRadians(6.))); diff --git a/reconstruction/dc/src/main/java/org/jlab/rec/dc/segment/SegmentFinder.java b/reconstruction/dc/src/main/java/org/jlab/rec/dc/segment/SegmentFinder.java index 8c9f836bde..a93d59d2c3 100644 --- a/reconstruction/dc/src/main/java/org/jlab/rec/dc/segment/SegmentFinder.java +++ b/reconstruction/dc/src/main/java/org/jlab/rec/dc/segment/SegmentFinder.java @@ -84,8 +84,8 @@ public void get_LayerEfficiencies(Segment seg, DataEvent event, DCGeant4Factory int trjWire = trj.getWireOnTrajectory(seg.get_Sector(), seg.get_Superlayer(), l + 1, trkXMP, DcDetector); //double x = GeometryLoader.dcDetector.getSector(0).getSuperlayer(seg.get_Superlayer()-1).getLayer(l).getComponent(trjWire-1).getMidpoint().x(); double x = DcDetector.getWireMidpoint(seg.get_Sector() - 1, seg.get_Superlayer() - 1, l, trjWire - 1).x; - double cosTrkAngle = FastMath.cos(Math.toRadians(6.)) * Math.sqrt(1. + seg.get_fittedCluster().get_clusterLineFitSlope() * seg.get_fittedCluster().get_clusterLineFitSlope()); - double calc_doca = (x - trkX) * cosTrkAngle; + double cosTkAng = FastMath.cos(Math.toRadians(6.)) * Math.sqrt(1. + seg.get_fittedCluster().get_clusterLineFitSlope() * seg.get_fittedCluster().get_clusterLineFitSlope()); + double calc_doca = (x - trkX) * cosTkAng; trkDocas[l] = calc_doca; for (int j = 0; j < sector.length; j++) { From 3fa8ffb3a7af1425f119d272732146d0eb913a86 Mon Sep 17 00:00:00 2001 From: ziegler Date: Mon, 12 Aug 2019 18:40:04 -0400 Subject: [PATCH 023/235] Removed un-used method to read hits. Move geometry reading and wire properties to HitReader. --- .../java/org/jlab/rec/dc/banks/HitReader.java | 103 +----------------- 1 file changed, 2 insertions(+), 101 deletions(-) diff --git a/reconstruction/dc/src/main/java/org/jlab/rec/dc/banks/HitReader.java b/reconstruction/dc/src/main/java/org/jlab/rec/dc/banks/HitReader.java index 4f6ab2a55e..1a145a1c7e 100644 --- a/reconstruction/dc/src/main/java/org/jlab/rec/dc/banks/HitReader.java +++ b/reconstruction/dc/src/main/java/org/jlab/rec/dc/banks/HitReader.java @@ -332,6 +332,7 @@ public void read_HBHits(DataEvent event, IndexedTable constants0, IndexedTable c hit.set_LeftRightAmb(LR[i]); hit.set_TrkgStatus(0); hit.calc_CellSize(DcDetector); + hit.calc_GeomCorr(DcDetector, 0); hit.set_ClusFitDoca(trkDoca[i]); hit.set_TimeToDistance(event, 1.0, B[i], constants1, tde); @@ -354,107 +355,7 @@ public void read_HBHits(DataEvent event, IndexedTable constants0, IndexedTable c this.set_HBHits(hits); } - public void read_TBHits(DataEvent event, IndexedTable constants0, IndexedTable constants1, - TimeToDistanceEstimator tde, double[][][][] T0, double[][][][] T0ERR) { - /* - 0: this.getConstantsManager().getConstants(newRun, "/calibration/dc/signal_generation/doca_resolution"), - 1: this.getConstantsManager().getConstants(newRun, "/calibration/dc/time_to_distance/t2d") - */ - if (!event.hasBank("TimeBasedTrkg::TBHits") || !event.hasBank("RECHB::Event")) { - //System.err.println("there is no HB dc bank "); - _TBHits = new ArrayList<>(); - return; - } - - DataBank bank = event.getBank("TimeBasedTrkg::TBHits"); - int rows = bank.rows(); - - int[] id = new int[rows]; - int[] sector = new int[rows]; - int[] slayer = new int[rows]; - int[] layer = new int[rows]; - int[] wire = new int[rows]; - int[] tdc = new int[rows]; - int[] LR = new int[rows]; - double[] B = new double[rows]; - int[] clusterID = new int[rows]; - int[] trkID = new int[rows]; - double[] tProp = new double[rows]; - double[] tFlight = new double[rows]; - double startTime = (double) event.getBank("REC::Event").getFloat("startTime", 0); - - if (startTime < 0) - return; - - for (int i = 0; i < rows; i++) { - sector[i] = bank.getByte("sector", i); - slayer[i] = bank.getByte("superlayer", i); - layer[i] = bank.getByte("layer", i); - wire[i] = bank.getShort("wire", i); - tdc[i] = bank.getInt("TDC", i); - id[i] = bank.getShort("id", i); - LR[i] = bank.getByte("LR", i); - B[i] = bank.getFloat("B", i); - clusterID[i] = bank.getShort("clusterID", i); - trkID[i] = bank.getByte("trkID", i); - tProp[i] = bank.getFloat("TProp", i); - tFlight[i] = bank.getFloat("TFlight", i); - - if (event.hasBank("MC::Particle") || - event.getBank("RUN::config").getInt("run", 0) < 100) { - tProp[i] = 0; - tFlight[i] = 0; - } - } - int size = layer.length; - - List hits = new ArrayList<>(); - for (int i = 0; i < size; i++) { - //use only hits that have been fit to a track - if (trkID[i] == -1) { - continue; - } - // - FittedHit hit = new FittedHit(sector[i], slayer[i], layer[i], wire[i], tdc[i], id[i]); - hit.setB(B[i]); - //hit.setT0SubTime(time[i]- T_0+tProp[i]+tFlight[i]); - double T_0 = this.get_T0(sector[i], slayer[i], layer[i], wire[i], T0, T0ERR)[0]; - hit.setT0(T_0); - hit.set_Beta(this.readBeta(event, trkID[i])); - hit.setTStart(startTime); - hit.setTProp(tProp[i]); - //reset the time based on new beta - //double newtFlight = tFlight[i] / hit.get_Beta(); - //hit.setTFlight(newtFlight); - hit.setSignalTimeOfFlight(); - double newtFlight = hit.getTFlight(); - hit.set_Time((double) tdc[i] - tProp[i] - newtFlight - T_0 - startTime); - hit.set_LeftRightAmb(LR[i]); - hit.set_TrkgStatus(0); - - hit.set_DocaErr(hit.get_PosErr(event, B[i], constants0, constants1, tde)); - hit.set_AssociatedClusterID(clusterID[i]); - hit.set_AssociatedTBTrackID(trkID[i]); - - hit.set_TimeToDistance(event, 1.0, B[i], constants1, tde); - - hit.set_QualityFac(0); - if (hit.get_Doca() > hit.get_CellSize()) { - hit.set_OutOfTimeFlag(true); - hit.set_QualityFac(2); - } - if (hit.get_Time() < 0) - hit.set_QualityFac(1); - if(hit.get_Beta()>0.2 && hit.get_Beta()<=1.30) { - //if(hit.get_Beta()>1.0) - // hit.set_Beta(1.0); - hits.add(hit); - } - } - - this.set_TBHits(hits); - } - + private double readBeta(DataEvent event, int trkId) { double _beta = 1.0; From 6243472f7dba97f08402f993ddf6c8b5a173e0dc Mon Sep 17 00:00:00 2001 From: ziegler Date: Mon, 12 Aug 2019 18:41:26 -0400 Subject: [PATCH 024/235] Move geometry reading and wire properties to HitReader so that the wire end points and direction are not re-calculated everytime the hit is updated. --- .../dc/cluster/ClusterCleanerUtilities.java | 10 ++++ .../jlab/rec/dc/cluster/ClusterFinder.java | 5 ++ .../jlab/rec/dc/cluster/FittedCluster.java | 1 + .../java/org/jlab/rec/dc/hit/FittedHit.java | 57 ++++++++++--------- .../org/jlab/rec/dc/track/fit/MeasVecs.java | 53 ++++++++++------- .../jlab/rec/dc/trajectory/RoadFinder.java | 2 + .../java/org/jlab/service/dc/DCTBEngine.java | 10 +--- .../service/dc/LayerEfficiencyAnalyzer.java | 10 +--- 8 files changed, 82 insertions(+), 66 deletions(-) diff --git a/reconstruction/dc/src/main/java/org/jlab/rec/dc/cluster/ClusterCleanerUtilities.java b/reconstruction/dc/src/main/java/org/jlab/rec/dc/cluster/ClusterCleanerUtilities.java index 2abe822e4d..af590f966a 100644 --- a/reconstruction/dc/src/main/java/org/jlab/rec/dc/cluster/ClusterCleanerUtilities.java +++ b/reconstruction/dc/src/main/java/org/jlab/rec/dc/cluster/ClusterCleanerUtilities.java @@ -381,6 +381,11 @@ public FittedCluster LRAmbiguityResolver(DataEvent event, FittedCluster fClus, newhitPos.set_Id(hit.get_Id()); newhitPos.set_TrkgStatus(0); newhitPos.calc_CellSize(DcDetector); + newhitPos.set_XWire(hit.get_XWire()); + newhitPos.set_Z(hit.get_Z()); + newhitPos.set_WireLength(hit.get_WireLength()); + newhitPos.set_WireMaxSag(hit.get_WireMaxSag()); + newhitPos.set_WireLine(hit.get_WireLine()); newhitPos.set_LeftRightAmb(1); newhitPos.updateHitPositionWithTime(event, 1, hit.getB(), tab, DcDetector, tde); // assume the track angle is // to the layer, so that cosTrkAng =1 @@ -402,6 +407,11 @@ public FittedCluster LRAmbiguityResolver(DataEvent event, FittedCluster fClus, newhitNeg.set_Id(hit.get_Id()); newhitNeg.set_TrkgStatus(0); newhitNeg.calc_CellSize(DcDetector); + newhitNeg.set_XWire(hit.get_XWire()); + newhitNeg.set_Z(hit.get_Z()); + newhitNeg.set_WireLength(hit.get_WireLength()); + newhitNeg.set_WireMaxSag(hit.get_WireMaxSag()); + newhitNeg.set_WireLine(hit.get_WireLine()); newhitNeg.set_LeftRightAmb(-1); newhitNeg.updateHitPositionWithTime(event, 1, hit.getB(), tab, DcDetector, tde); // assume the track angle is // to the layer diff --git a/reconstruction/dc/src/main/java/org/jlab/rec/dc/cluster/ClusterFinder.java b/reconstruction/dc/src/main/java/org/jlab/rec/dc/cluster/ClusterFinder.java index 7f28fc576d..ba0ce33d15 100644 --- a/reconstruction/dc/src/main/java/org/jlab/rec/dc/cluster/ClusterFinder.java +++ b/reconstruction/dc/src/main/java/org/jlab/rec/dc/cluster/ClusterFinder.java @@ -385,6 +385,11 @@ public List FindTimeBasedClusters(DataEvent event, newhit.set_TrkgStatus(hit.get_TrkgStatus()); newhit.set_LeftRightAmb(-hit.get_LeftRightAmb()); newhit.calc_CellSize(DcDetector); + newhit.set_XWire(hit.get_XWire()); + newhit.set_Z(hit.get_Z()); + newhit.set_WireLength(hit.get_WireLength()); + newhit.set_WireMaxSag(hit.get_WireMaxSag()); + newhit.set_WireLine(hit.get_WireLine()); newhit.updateHitPositionWithTime(event, 1, hit.getB(), tab, DcDetector, tde); // assume the track angle is // to the layer newhit.set_AssociatedClusterID(hit.get_AssociatedClusterID()); newhit.set_AssociatedHBTrackID(hit.get_AssociatedHBTrackID()); diff --git a/reconstruction/dc/src/main/java/org/jlab/rec/dc/cluster/FittedCluster.java b/reconstruction/dc/src/main/java/org/jlab/rec/dc/cluster/FittedCluster.java index 6d43c5f2e2..e5c9d9fead 100644 --- a/reconstruction/dc/src/main/java/org/jlab/rec/dc/cluster/FittedCluster.java +++ b/reconstruction/dc/src/main/java/org/jlab/rec/dc/cluster/FittedCluster.java @@ -35,6 +35,7 @@ public FittedCluster(Cluster rawCluster) { fhit.set_DocaErr(rawCluster.get(i).get_DocaErr()); fhit.set_CellSize(rawCluster.get(i).get_CellSize()); fhit.set_Id(rawCluster.get(i).get_Id()); + this.add(fhit); } } diff --git a/reconstruction/dc/src/main/java/org/jlab/rec/dc/hit/FittedHit.java b/reconstruction/dc/src/main/java/org/jlab/rec/dc/hit/FittedHit.java index 598451fb93..d03a59eeed 100644 --- a/reconstruction/dc/src/main/java/org/jlab/rec/dc/hit/FittedHit.java +++ b/reconstruction/dc/src/main/java/org/jlab/rec/dc/hit/FittedHit.java @@ -4,6 +4,7 @@ import org.jlab.clas.clas.math.FastMath; import org.jlab.clas.swimtools.Swimmer; import org.jlab.detector.geant4.v2.DCGeant4Factory; +import org.jlab.geom.prim.Line3D; import org.jlab.rec.dc.Constants; import org.jlab.rec.dc.timetodistance.TimeToDistanceEstimator; import org.jlab.geom.prim.Point3D; @@ -458,11 +459,11 @@ public void set_X(double _X) { this._X = _X; } - public double get_XMP() { + public double get_XWire() { return _XMP; } - public void set_XMP(double _XMP) { + public void set_XWire(double _XMP) { this._XMP = _XMP; } @@ -490,13 +491,9 @@ public void set_Z(double _Z) { * local coord.sys. wire positions */ public void updateHitPosition(DCGeant4Factory DcDetector) { - - //double z = GeometryLoader.dcDetector.getSector(0).getSuperlayer(this.get_Superlayer()-1).getLayer(this.get_Layer()-1).getComponent(this.get_Wire()-1).getMidpoint().z(); - double z = DcDetector.getWireMidpoint(this.get_Sector() - 1, this.get_Superlayer() - 1, this.get_Layer() - 1, this.get_Wire() - 1).z; - double x= this.calc_GeomCorr(DcDetector, 0); - // - this.set_X(x); - this.set_Z(z); + if(this.get_Z()==0) + this.calc_GeomCorr(DcDetector, 0); + this.set_X(this.get_XWire()); } /** @@ -507,10 +504,9 @@ public void updateHitPositionWithTime(DataEvent event, double trkAngle, double B if (this.get_Time() > 0) { this.set_TimeToDistance(event, trkAngle, B, tab, tde); } - - double z = DcDetector.getWireMidpoint(this.get_Sector() - 1, this.get_Superlayer() - 1, this.get_Layer() - 1, this.get_Wire() - 1).z; - //double x = DcDetector.getWireMidpoint(this.get_Superlayer() - 1, this.get_Layer() - 1, this.get_Wire() - 1).x; - double x = this.calc_GeomCorr(DcDetector, 0); + if(this.get_Z()==0) + this.calc_GeomCorr(DcDetector, 0); + double x = this.get_XWire(); //this.set_X(x+this.get_LeftRightAmb()*this.get_TimeToDistance()); double MPCorr = 1; double cosTkAng = 1./Math.sqrt(trkAngle*trkAngle + 1.); @@ -519,14 +515,13 @@ public void updateHitPositionWithTime(DataEvent event, double trkAngle, double B } this.set_X(x + this.get_LeftRightAmb() * (this.get_TimeToDistance() / MPCorr) / FastMath.cos(Math.toRadians(6.))); - this.set_Z(z); - + } - public double XatY(DCGeant4Factory DcDetector, double y) { - double x = this.calc_GeomCorr(DcDetector, y); - return x + this.get_LeftRightAmb() * (this.get_TimeToDistance()) ; - } + //public double XatY(DCGeant4Factory DcDetector, double y) { + // double x = this.calc_GeomCorr(DcDetector, y); + // return x + this.get_LeftRightAmb() * (this.get_TimeToDistance()) ; + //} private double _WireLength; @@ -548,6 +543,16 @@ public void set_WireMaxSag(double _WireMaxSag) { this._WireMaxSag = _WireMaxSag; } + private Line3D _WireLine; + + public Line3D get_WireLine() { + return _WireLine; + } + + public void set_WireLine(Line3D _WireLine) { + this._WireLine = _WireLine; + } + private double _TrkResid=999; public double get_TrkResid() { @@ -558,14 +563,14 @@ public void set_TrkResid(double _TrkResid) { this._TrkResid = _TrkResid; } - private double calc_GeomCorr(DCGeant4Factory DcDetector, double y) { + public void calc_GeomCorr(DCGeant4Factory DcDetector, double y) { //corrects for wire sag only double xL = DcDetector.getWireLeftend(this.get_Sector()-1, this.get_Superlayer()-1, this.get_Layer()-1, this.get_Wire()-1).x; double xR = DcDetector.getWireRightend(this.get_Sector()-1, this.get_Superlayer()-1, this.get_Layer()-1, this.get_Wire()-1).x; double yL = DcDetector.getWireLeftend(this.get_Sector()-1, this.get_Superlayer()-1, this.get_Layer()-1, this.get_Wire()-1).y; double yR = DcDetector.getWireRightend(this.get_Sector()-1, this.get_Superlayer()-1, this.get_Layer()-1, this.get_Wire()-1).y; double x = DcDetector.getWireMidpoint(this.get_Sector()-1, this.get_Superlayer()-1, this.get_Layer()-1, this.get_Wire()-1).x; - + double z = DcDetector.getWireMidpoint(this.get_Sector()-1, this.get_Superlayer()-1, this.get_Layer()-1, this.get_Wire()-1).z; double wire = this.get_Wire(); double wireLen = Math.sqrt((xL-xR)*(xL-xR)+(yL-yR)*(yL-yR)); int sector = this.get_Sector(); @@ -619,13 +624,13 @@ private double calc_GeomCorr(DCGeant4Factory DcDetector, double y) { double delta_x = MaxSag*(1.-Math.abs(y)/(0.5*wireLen))*(1.-Math.abs(y)/(0.5*wireLen)); x+=delta_x; - + Line3D wireLine = new Line3D(new Point3D(xL, yL, 0), new Point3D(xR, yR, 0)); this.set_WireLength(wireLen); this.set_WireMaxSag(MaxSag); + this.set_WireLine(wireLine); - return x; - //System.out.println(this.printInfo()+ "x0 "+ DcDetector.getWireMidpoint(this.get_Superlayer()-1, this.get_Layer()-1, this.get_Wire()-1).x - //+" x "+x); + this.set_XWire(x); + this.set_Z(z); } /** @@ -669,7 +674,7 @@ public String printInfo() { //double xr = this._X*FastMath.cos(Math.toRadians(25.))+this._Z*FastMath.sin(Math.toRadians(25.)); //double zr = this._Z*FastMath.cos(Math.toRadians(25.))-this._X*FastMath.sin(Math.toRadians(25.)); String s = "DC Fitted Hit: ID " + this.get_Id() + " Sector " + this.get_Sector() + " Superlayer " + this.get_Superlayer() + " Layer " + this.get_Layer() + " Wire " + this.get_Wire() + " TDC " + this.get_TDC()+ " Time " + this.get_Time() - + " LR " + this.get_LeftRightAmb() + " doca " + this.get_TimeToDistance()+ " +/- " +this.get_DocaErr() + " updated pos " + this._X + " clus " + + " LR " + this.get_LeftRightAmb() + " doca " + (float)this.get_TimeToDistance()+ " +/- " +(float)this.get_DocaErr() + " updated pos " + (float)this._X + " clus " + this._AssociatedClusterID; return s; } diff --git a/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/fit/MeasVecs.java b/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/fit/MeasVecs.java index 702cf014e1..d981daab08 100644 --- a/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/fit/MeasVecs.java +++ b/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/fit/MeasVecs.java @@ -4,6 +4,8 @@ import java.util.Collections; import java.util.List; import org.jlab.detector.geant4.v2.DCGeant4Factory; +import org.jlab.geom.prim.Line3D; +import org.jlab.geom.prim.Vector3D; import org.jlab.rec.dc.hit.FittedHit; import org.jlab.rec.dc.track.Track; @@ -20,10 +22,10 @@ public class MeasVecs { * @return a double array corresponding to the 2 entries of the projector * matrix */ - public double[] H(double y, int s, double w, double l) { + public double[] H(double y, double s, double w, double l) { double[] hMatrix = new double[2]; hMatrix[0] = 1; - hMatrix[1] = -Math.tan((Math.toRadians(s * 6.))); + hMatrix[1] = -Math.tan((Math.toRadians(s))); // add geometric corrections //hMatrix[1]-= w*(4./l)*(1 - y/(l/2.)); return hMatrix; @@ -37,9 +39,9 @@ public double[] H(double y, int s, double w, double l) { * @param s the superlayer (0..1) * @return projected measurement */ - public double h(double[] stateV, int s, double w, double l) { + public double h(double[] stateV, double s, double w, double l) { - double val = stateV[0] - Math.tan((Math.toRadians(s * 6.))) * stateV[1]; + double val = stateV[0] - Math.tan((Math.toRadians(s))) * stateV[1]; // add geometric corrections val+= w; return val; @@ -72,7 +74,11 @@ public void setMeasVecs(Track trkcand, DCGeant4Factory DcDetector) { // continue; //} - HitOnTrack hot = new HitOnTrack(slayr, X, Z, trkcand.get(c).get(s).get(h).get_WireLength(), trkcand.get(c).get(s).get(h).get_WireMaxSag()); + HitOnTrack hot = new HitOnTrack(slayr, X, Z, + trkcand.get(c).get(s).get(h).get_WireLength(), + trkcand.get(c).get(s).get(h).get_WireMaxSag(), + trkcand.get(c).get(s).get(h).get_WireLine() + ); double err_sl1 = trkcand.get(c).get(s).get_fittedCluster().get_clusterLineFitSlopeErr(); double err_it1 = trkcand.get(c).get(s).get_fittedCluster().get_clusterLineFitInterceptErr(); @@ -114,6 +120,7 @@ public void setMeasVecs(Track trkcand, DCGeant4Factory DcDetector) { meas.tilt = hOTS.get(i)._tilt; meas.wireLen = hOTS.get(i)._wireLen; meas.wireMaxSag = hOTS.get(i)._wireMaxSag; + meas.wireLine = hOTS.get(i)._wireLine; this.measurements.add(i, meas); } } @@ -133,15 +140,11 @@ void setMeasVecsFromHB(Track trk, DCGeant4Factory DcDetector) { double Z = hitOnTrk.get_Z(); double X = sl1 * Z + it1; - //exclude hits that have poor segment - //if ((trkcand.get(c).get(s).get(h).get_X() - X) / (trkcand.get(c).get(s).get(h).get_CellSize() / FastMath.cos(Math.toRadians(6.))) > 1.5) { - //if(Math.abs(trk.get_ListOfHBSegments().get(s).get(h).get_Residual())>1) { - // continue; - //} - - HitOnTrack hot = new HitOnTrack(slayr, X, Z, hitOnTrk.get_WireLength(), hitOnTrk.get_WireMaxSag()); + HitOnTrack hot = new HitOnTrack(slayr, X, Z, + hitOnTrk.get_WireLength(), + hitOnTrk.get_WireMaxSag(), + hitOnTrk.get_WireLine()); double err_sl1 = trk.get_ListOfHBSegments().get(s).get_fittedCluster().get_clusterLineFitSlopeErr(); - double err_it1 = trk.get_ListOfHBSegments().get(s).get_fittedCluster().get_clusterLineFitInterceptErr(); double err_cov1 = trk.get_ListOfHBSegments().get(s).get_fittedCluster().get_clusterLineFitSlIntCov(); @@ -179,6 +182,7 @@ void setMeasVecsFromHB(Track trk, DCGeant4Factory DcDetector) { meas.tilt = hOTS.get(i)._tilt; meas.wireLen = hOTS.get(i)._wireLen; meas.wireMaxSag = hOTS.get(i)._wireMaxSag; + meas.wireLine = hOTS.get(i)._wireLine; this.measurements.add(i, meas); //System.out.println(" measurement "+i+" = "+meas.x+" at "+meas.z); } @@ -190,13 +194,15 @@ public class MeasVec { public double z; public double x; public double unc; - public int tilt; + public double tilt; public double error; public double wireLen; public double wireMaxSag; + public Line3D wireLine; boolean reject = false; int region; + MeasVec(int k) { this.k = k; } @@ -209,23 +215,26 @@ private class HitOnTrack implements Comparable { private double _X; private double _Z; private double _Unc; - private int _tilt; + private double _tilt; private double _wireLen; private double _wireMaxSag; + private Line3D _wireLine; private int region; - HitOnTrack(int superlayer, double X, double Z, double wirelen, double wiremaxsag) { + HitOnTrack(int superlayer, double X, double Z, double wirelen, double wiremaxsag, Line3D wireLine) { _X = X; _Z = Z; _wireLen = wirelen; _wireMaxSag = wiremaxsag; + _wireLine = wireLine; - int s = (int) (superlayer) % 2; - int tilt = 1; - if (s == 0) { - tilt = -1; - } - _tilt = tilt; + //int s = (int)(superlayer) % 2; + //int tilt = 1; + //if (s == 0) { + // tilt = -1; + //} + + _tilt = 90-Math.toDegrees(wireLine.direction().asUnit().angle(new Vector3D(1,0,0))); } @Override diff --git a/reconstruction/dc/src/main/java/org/jlab/rec/dc/trajectory/RoadFinder.java b/reconstruction/dc/src/main/java/org/jlab/rec/dc/trajectory/RoadFinder.java index de7d7bd440..84a5f1b5d4 100644 --- a/reconstruction/dc/src/main/java/org/jlab/rec/dc/trajectory/RoadFinder.java +++ b/reconstruction/dc/src/main/java/org/jlab/rec/dc/trajectory/RoadFinder.java @@ -134,6 +134,7 @@ public Segment findRoadMissingSegment(List segList, DCGeant4Factory DcD 0, -1); //estimate the error on the hit as the cellSize/sqrt(12) pseudoHit.calc_CellSize(DcDetector); + pseudoHit.calc_GeomCorr(DcDetector, 0); pseudoHit.set_DocaErr(pseudoHit.get_CellSize()/Math.sqrt(12.)); //update the hit position estimate and add to the pseudo-cluster pseudoHit.updateHitPosition(DcDetector); @@ -174,6 +175,7 @@ private Segment reFit(Segment pseudoSeg, ArrayList segList, DCGeant4Fac 0, -1); pseudoHit.set_DocaErr(pseudoHit.get_CellSize()/Math.sqrt(12.)/FastMath.cos(Math.toRadians(6.))); pseudoHit.updateHitPosition(DcDetector); + pseudoHit.calc_GeomCorr(DcDetector, 0); fpseudoCluster.add(pseudoHit); } cf.SetFitArray(fpseudoCluster, "TSC"); diff --git a/reconstruction/dc/src/main/java/org/jlab/service/dc/DCTBEngine.java b/reconstruction/dc/src/main/java/org/jlab/service/dc/DCTBEngine.java index 86471b5f55..64955c4990 100755 --- a/reconstruction/dc/src/main/java/org/jlab/service/dc/DCTBEngine.java +++ b/reconstruction/dc/src/main/java/org/jlab/service/dc/DCTBEngine.java @@ -101,17 +101,9 @@ public boolean processDataEvent(DataEvent event) { super.getConstantsManager().getConstants(newRun, "/calibration/dc/signal_generation/doca_resolution"), super.getConstantsManager().getConstants(newRun, "/calibration/dc/time_to_distance/time2dist"), Constants.getT0(), Constants.getT0Err(), dcDetector, tde); - hitRead.read_TBHits(event, - super.getConstantsManager().getConstants(newRun, "/calibration/dc/signal_generation/doca_resolution"), - super.getConstantsManager().getConstants(newRun, "/calibration/dc/time_to_distance/time2dist"), tde, Constants.getT0(), Constants.getT0Err()); List hits = new ArrayList(); //I) get the hits - if(hitRead.get_TBHits().isEmpty()) { - hits = hitRead.get_HBHits(); - - } else { - hits = hitRead.get_TBHits(); - } + hits = hitRead.get_HBHits(); //II) process the hits //1) exit if hit list is empty diff --git a/reconstruction/dc/src/main/java/org/jlab/service/dc/LayerEfficiencyAnalyzer.java b/reconstruction/dc/src/main/java/org/jlab/service/dc/LayerEfficiencyAnalyzer.java index eaa966c52a..93b5433d98 100644 --- a/reconstruction/dc/src/main/java/org/jlab/service/dc/LayerEfficiencyAnalyzer.java +++ b/reconstruction/dc/src/main/java/org/jlab/service/dc/LayerEfficiencyAnalyzer.java @@ -318,17 +318,9 @@ public boolean processDataEvent(DataEvent event) { super.getConstantsManager().getConstants(newRun, "/calibration/dc/signal_generation/doca_resolution"), super.getConstantsManager().getConstants(newRun, "/calibration/dc/time_to_distance/time2dist"), Constants.getT0(), Constants.getT0Err(), dcDetector, tde); - hitRead.read_TBHits(event, - super.getConstantsManager().getConstants(newRun, "/calibration/dc/signal_generation/doca_resolution"), - super.getConstantsManager().getConstants(newRun, "/calibration/dc/time_to_distance/time2dist"), tde, Constants.getT0(), Constants.getT0Err()); List hits = new ArrayList(); //I) get the hits - if(hitRead.get_TBHits().isEmpty()) { - hits = hitRead.get_HBHits(); - - } else { - hits = hitRead.get_TBHits(); - } + hits = hitRead.get_HBHits(); //II) process the hits //1) exit if hit list is empty From 228438dc55cab666825badf25bea19352388172c Mon Sep 17 00:00:00 2001 From: ziegler Date: Mon, 12 Aug 2019 18:45:02 -0400 Subject: [PATCH 025/235] use stereo angle in fit based on wire direction --- .../java/org/jlab/rec/dc/track/fit/MeasVecs.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/fit/MeasVecs.java b/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/fit/MeasVecs.java index d981daab08..4bf5a4dd5f 100644 --- a/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/fit/MeasVecs.java +++ b/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/fit/MeasVecs.java @@ -228,12 +228,12 @@ private class HitOnTrack implements Comparable { _wireMaxSag = wiremaxsag; _wireLine = wireLine; - //int s = (int)(superlayer) % 2; - //int tilt = 1; - //if (s == 0) { - // tilt = -1; - //} - + //int s = (int)(superlayer) % 2; + //int tilt = 1; + //if (s == 0) { + // tilt = -1; + //} + //use stereo angle in fit based on wire direction _tilt = 90-Math.toDegrees(wireLine.direction().asUnit().angle(new Vector3D(1,0,0))); } From 8238698c173f53e6e34f161d0ca5b9ec69be2ac6 Mon Sep 17 00:00:00 2001 From: ziegler Date: Tue, 13 Aug 2019 15:28:23 -0400 Subject: [PATCH 026/235] Oops...bug in set_ToPionHypothesis method. --- .../main/java/org/jlab/rec/dc/banks/HitReader.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/reconstruction/dc/src/main/java/org/jlab/rec/dc/banks/HitReader.java b/reconstruction/dc/src/main/java/org/jlab/rec/dc/banks/HitReader.java index e44568a374..eb08cb2506 100644 --- a/reconstruction/dc/src/main/java/org/jlab/rec/dc/banks/HitReader.java +++ b/reconstruction/dc/src/main/java/org/jlab/rec/dc/banks/HitReader.java @@ -320,7 +320,7 @@ public void read_HBHits(DataEvent event, IndexedTable constants0, IndexedTable c hit.setTProp(tProp[i]); //hit.setTFlight(tFlight[i]); hit.set_Beta(this.readBeta(event, trkID[i])); - this.set_BetaFlag(hit, hit.get_Beta());//reset beta for out of range assuming the pion hypothesis and setting a flag + this.set_BetaFlag(event, trkID[i], hit, hit.get_Beta());//reset beta for out of range assuming the pion hypothesis and setting a flag hit.setTFlight(tFlight[i]/hit.get_Beta0to1()); //resetting TFlight after beta has been obtained //hit.setSignalTimeOfFlight(); @@ -356,9 +356,9 @@ public void read_HBHits(DataEvent event, IndexedTable constants0, IndexedTable c this.set_HBHits(hits); } //betaFlag:0 = OK; -1 = negative; 1 = less than lower cut (0.15); 2 = greater than 1.15 (from HBEB beta vs p plots for data) - private void set_BetaFlag(FittedHit hit, double beta) { + private void set_BetaFlag(DataEvent event, int trkId, FittedHit hit, double beta) { if(beta<0.15) { - this.set_ToPionHypothesis(hit); + this.set_ToPionHypothesis(event, trkId, hit); if(beta<0) { hit.betaFlag = -1; } else { @@ -369,10 +369,12 @@ private void set_BetaFlag(FittedHit hit, double beta) { hit.betaFlag = 2; } } - private void set_ToPionHypothesis(FittedHit hit) { + private void set_ToPionHypothesis(DataEvent event, int trkId, FittedHit hit) { double piMass = 0.13957018; - double px, py, pz; + double px=0; + double py=0; + double pz=0; if (!event.hasBank("RECHB::Particle") || !event.hasBank("RECHB::Track")) return ; DataBank bank = event.getBank("RECHB::Track"); From f829dcdb3a2ed9121e0d4ea90985eb56310a1c15 Mon Sep 17 00:00:00 2001 From: dcpayette Date: Wed, 14 Aug 2019 13:39:29 -0400 Subject: [PATCH 027/235] cleaning phase 1 --- .../jlab/rec/rtpc/banks/RecoBankWriter2.java | 4 +- .../org/jlab/rec/rtpc/hit/HelixFitJava.java | 22 +- .../org/jlab/rec/rtpc/hit/HelixFitObject.java | 81 ++ .../org/jlab/rec/rtpc/hit/HelixFitTest.java | 692 ++++++++++++++++++ .../org/jlab/rec/rtpc/hit/HitDistance.java | 4 +- .../org/jlab/rec/rtpc/hit/HitParameters.java | 161 ++-- .../jlab/rec/rtpc/hit/HitReconstruction.java | 19 +- .../org/jlab/rec/rtpc/hit/MapCombine.java | 26 +- .../java/org/jlab/rec/rtpc/hit/PadAve.java | 19 +- .../java/org/jlab/rec/rtpc/hit/PadFit.java | 90 +-- .../java/org/jlab/rec/rtpc/hit/PadHit.java | 193 ++--- .../org/jlab/rec/rtpc/hit/TimeAverage2.java | 29 +- .../org/jlab/rec/rtpc/hit/TrackFinder3.java | 46 +- .../org/jlab/rec/rtpc/hit/TrackHitReco3.java | 30 +- .../org/jlab/service/rtpc/RTPCEngine.java | 222 +++--- 15 files changed, 1201 insertions(+), 437 deletions(-) create mode 100644 reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/HelixFitObject.java create mode 100644 reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/HelixFitTest.java diff --git a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/banks/RecoBankWriter2.java b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/banks/RecoBankWriter2.java index 924a5e21e8..49e143f24a 100644 --- a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/banks/RecoBankWriter2.java +++ b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/banks/RecoBankWriter2.java @@ -1,7 +1,6 @@ package org.jlab.rec.rtpc.banks; import java.util.concurrent.ConcurrentHashMap; -import java.util.Vector; import org.jlab.clas.physics.Vector3; @@ -13,6 +12,7 @@ import org.jlab.rec.rtpc.hit.HitParameters; import org.jlab.rec.rtpc.hit.HitVector; import org.jlab.rec.rtpc.hit.RecoHitVector; +import java.util.List; import java.util.HashMap; public class RecoBankWriter2 { @@ -30,7 +30,7 @@ public DataBank fillRTPCHitsBank(DataEvent event, HitParameters params) { return null;*/ int listsize = 0; int row = 0; - HashMap> recohitvector = params.get_recohitvector(); + HashMap> recohitvector = params.get_recohitvector(); for(int TID:recohitvector.keySet()) { for(int i = 0; i < recohitvector.get(TID).size(); i++) { diff --git a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/HelixFitJava.java b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/HelixFitJava.java index 0590eeb085..af4f181377 100644 --- a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/HelixFitJava.java +++ b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/HelixFitJava.java @@ -1,5 +1,6 @@ package org.jlab.rec.rtpc.hit; + public class HelixFitJava { void rwsmav(double r[], double a[], double v[], int n) @@ -708,7 +709,7 @@ void CorrHelixRPhi(double Rho, double Phi) // DCA: distance of closest approach to beamline // Chi2: ch2ph+ch2z/(npt-5) \------------------------------------------------------------------------*/ - void helix_fit(int PointNum,double szPos[][], double Rho, double A, double B, + HelixFitObject helix_fit(int PointNum,double szPos[][], double Rho, double A, double B, double Phi, double Theta, double X0, double Y0,double Z0, double DCA, double Chi2,int fit_track_to_beamline) { @@ -735,7 +736,7 @@ void helix_fit(int PointNum,double szPos[][], double Rho, double A, double B, if(PointNum>=kMaxHit) PointNum=kMaxHit-1; npt = PointNum; - if(npt<5) return; + if(npt<5) return new HelixFitObject(); for (jj=0; jj rawHits, HitParameters params){ + HashMap> recohitvector = params.get_recohitvector(); + + + double szpos[][] = new double[1000][3]; + int hit = 0; + for(int TID : recohitvector.keySet()){ + for(hit = 0; hit < recohitvector.get(TID).size(); hit++){ + szpos[hit][0] = recohitvector.get(TID).get(hit).x(); + szpos[hit][1] = recohitvector.get(TID).get(hit).y(); + szpos[hit][2] = recohitvector.get(TID).get(hit).z(); + } + HelixFitJava h = new HelixFitJava(); + HelixFitObject ho = h.HelixFit(hit,szpos,0,0,0,0,0,0,1); + double momfit = 0.3*50*ho.get_Rho()/10; + System.out.println(momfit); + } + + + + + + + + /* + int entry = -1; + int hitnum = 0; + int tid = -1; + int prevtid = 0; + int num_chains = 0; + int hh_num_hits = 0; + int[] num_hits_this_chain = new int[300]; + int[][] chain_hits = new int[300][300]; + double[] tempx = new double[30]; + double[] tempy = new double[30]; + double[] tempz = new double[30]; + double[] tempr = new double[30]; + double[] num_hits = new double[5000]; + double[] mom_all = new double[5000]; + double[] z_all = new double[5000]; + double[] theta_all = new double[5000]; + int itemp = 0; + int n_RTPC__rec_TID = 0; + double R; double A; double B; + double Phi_deg; double Theta_deg; double Z0; int fit_track_to_beamline=1; + //HashMap > hitHashMap; + boolean flag = true; + boolean finish_track_flag = false; + boolean trackidchange = false; + boolean split_curve = false; + boolean draw = false; + double momx; double momy; double momz; double mom; + TCanvas c1 = new TCanvas("c1", 800, 800); + H1F h1 = new H1F("h1", 100, 0,500); + + //TCanvas c2 = new TCanvas("c2", "Momentum Reconstructed Track (GeV)", 800, 800); + H1F h2 = new H1F("h2", "Momentum Reconstructed Track (MeV)", 75, 0, 500); + H1F h3 = new H1F("h3", "Momentum Reconstructed Track (MeV)", 100, 0, 500); + + H2F hGenRecvsGenTrue = new H2F("hGenRecvsGenTrue","hGenRecvsGenTrue",50,0.,500.,50,0.,500.); + hGenRecvsGenTrue.setTitleX("Momentum (lund)"); + hGenRecvsGenTrue.setTitleY("Momentum (reconstructed lund)"); + H2F hGenRecvsGenTrue2 = new H2F("hGenRecvsGenTrue2","hGenRecvsGenTrue2",50,0.,500.,50,0.,500.); + hGenRecvsGenTrue2.setTitleX("Momentum (lund)"); + hGenRecvsGenTrue2.setTitleY("Momentum (reconstructed lund)"); + H2F hRecvsGenTrue = new H2F("hRecvsGenTrue","hRecvsGenTrue",50,0.,500.,50,0.,500.); + hRecvsGenTrue.setTitleX("Momentum (lund)"); + hRecvsGenTrue.setTitleY("Momentum (rec)"); + H2F hRecvsGenRec = new H2F("hRecvsGenRec","hRecvsGenRec",50,0.,500.,50,0.,500.); + hRecvsGenRec.setTitleX("Momentum (reconstructed lund)"); + hRecvsGenRec.setTitleY("Momentum (rec)"); + H2F hHitsvsMom = new H2F("hHitsvsMom","hHitsvsMom",50,0,500,50,0,250); + hHitsvsMom.setTitleX("Momentum (lund)"); + hHitsvsMom.setTitleY("Number of Hits"); + + H1F h4 = new H1F("h4", "num gen hits in track", 50, 0, 100); + + H2F hMomvsTheta = new H2F("hMomvsTheta","hMomvsTheta",50,0,180,50,0,500); + H2F hZvsTheta = new H2F("hZvsTheta","hZvsTheta",50,0,180,50,-210,210); + hZvsTheta.setTitleX("Theta"); + hZvsTheta.setTitleY("Z vertex (lund)"); + H2F hMomvsThetaCut = new H2F("hMomvsThetaCut","hMomvsThetaCut",50,0,180,50,0,500); + H2F hZvsThetaCut = new H2F("hZvsThetaCut","hZvsThetaCut",50,0,180,50,-210,210); + hZvsThetaCut.setTitleX("Theta"); + hZvsThetaCut.setTitleY("Z vertex (lund)"); + H2F hMomvsThetaelse = new H2F("hMomvsThetaelse","hMomvsThetaelse",50,0,180,50,0,500); + H2F hZvsThetaelse = new H2F("hZvsThetaelse","hZvsThetaelse",50,0,180,50,-210,210); + hZvsThetaelse.setTitleX("Theta"); + hZvsThetaelse.setTitleY("Z vertex (lund)"); + + int cellID = 0; + double time = 0; + double z = 0; + double x = 0; + double y = 0; + double r = 0; + double phi = 0; + double q = 0; + boolean skipfirst = true; + boolean skipfirsttrack = true; + HashMap zvertex_rec = new HashMap(); + HashMap tshift_rec = new HashMap(); + HashMap momentum_rec = new HashMap(); + //HashMap momentum_gen; + //HashMap tshift_gen; + double zvertex_gen; + double tshift_gen; + TCanvas c6 = new TCanvas("c6", 800, 800); + //myfile << "Generated Momentum" << "\t" << "Reconstructed Momentum " << "\t" << "Time Shift" << endl; + int failed_genrec = 0; + for(Hit rawhit : rawHits){ + if(skipfirst){ skipfirst = false; continue;} + entry++; + //myfile << "Event " << entry << endl; + // if(entry > 1000) break; + //entry = -1; + hitnum = 0; + tid = -1; + prevtid = 0; + num_chains = 0; + hh_num_hits = 0; + itemp = 0; + flag = true; + finish_track_flag = false; + trackidchange = false; + split_curve = false; + draw = false; + skipfirsttrack = true; + //std::cout << "event # " << entry << std::endl; + double thetarad = 0; + double thetadeg = 0; + double vz = 0; + if(rawhit.get_TID() == 2) + + momx = MC__Lund_px.getValue(c); + momy = MC__Lund_py.getValue(c); + momz = MC__Lund_pz.getValue(c); + vz = MC__Lund_vz.getValue(c); + vz*=10; + mom = Math.Sqrt(momx*momx + momy*momy + momz*momz); + thetarad = Math.ACos(momz/mom); + thetadeg = thetarad*Math.RadToDeg(); + //std::cout << MC__Lund_vz.getValue(c) << " vz" << endl; + //std::cout << momx << " " << momy << " " << momz << " " << mom << endl; + } + } + h1.Fill(mom*1000); + //myfile << mom*1000 << "\t"; + /*int n_RTPC__pos_posx = RTPC__pos_posx.getLength(); + double genx[n_RTPC__pos_posx+1]; + double geny[n_RTPC__pos_posx+1]; + double genz[n_RTPC__pos_posx+1]; + for(int d = 0; d <= n_RTPC__pos_posx; d++){ + genx[d] = RTPC__pos_posx.getValue(d); + geny[d] = RTPC__pos_posy.getValue(d); + genz[d] = RTPC__pos_posz.getValue(d); + } + + TGraph *genxy = new TGraph(n_RTPC__pos_posx,genx,geny); + genxy.SetMarkerStyle(31); + genxy.SetMarkerColor(3); + */ + // n_RTPC__rec_TID = RTPC__rec_TID.getLength(); + /*int n_gen_TID = RTPC__pos_tid.getLength(); + int tid_temp = -1; + int num_tracks = 0; + /*for(int i = 0; i < n_RTPC__rec_TID; i++){ + if(RTPC__rec_TID.getValue(i) != tid_temp){ + tid_temp = RTPC__rec_TID.getValue(i); + num_tracks++; + } + } + std::cout << "This event has " << num_tracks << " tracks" << endl; + + for(int b = 0; b <= n_RTPC__rec_TID; b++){ + //if(!draw) break; + //std::cout << RTPC__rec_TID.getValue(b) << " " << RTPC__rec_time.getValue(b) << std::endl; + if(b < n_RTPC__rec_TID){ + prevtid = RTPC__rec_TID.getValue(b); + } + else{ + prevtid = -111; + } + + trackidchange = false; + if(tid != prevtid){ + finish_track_flag = false; + trackidchange = true; + if(num_hits_this_chain[tid] > 0 && b != 0){ + /*DEBUG + for(int i = 0; i < szpos.size(); i++){ + std::cout << szpos[i][0] << endl; + }*/ + /*HelixFit(num_hits_this_chain[tid]-1, szpos, R, A, B, Phi_deg, Theta_deg, Z0, fit_track_to_beamline); + std::cout << "tid : " << tid << std::endl; + std::cout << "A : " << A << std::endl; + std::cout << "B : " << B << std::endl; + std::cout << "R : " << R << std::endl; + std::cout << "p : " << 0.3*50*R/10 << std::endl; + std::cout << "Z : " << Z0 << std::endl; + std::cout << "Theta " << Theta_deg << std::endl; + std::cout << "Phi " << Phi_deg << std::endl; + zvertex_rec.insert(std::make_pair(tid,Z0)); + tshift_rec.insert(std::make_pair(tid,RTPC__rec_tdiff.getValue(b-1))); + momentum_rec.insert(std::make_pair(tid,0.3*50*R/10)); + if(!skipfirsttrack) myfile << "" << "\t"; + skipfirsttrack = false; + myfile << 0.3*50*R/10 << "\t" << RTPC__rec_tdiff.getValue(b-1) << endl; + + //if(tid == 1){ + if(true){ + //TCanvas *p = new TCanvas("p","p",800,600); + //TMultiGraph *mg = new TMultiGraph(); + //TEllipse *e = new TEllipse(A, B, R, R); + //p.drawFrame(-70,-70,70,70); + //e.draw(); + double xpos[300]; + double ypos[300]; + double zpos[300]; + double rpos[300]; + for(int i = 0; i < num_hits_this_chain[tid]-1; i++){ + xpos[i] = szpos[i][0]; + ypos[i] = szpos[i][1]; + zpos[i] = szpos[i][2]; + rpos[i] = Math.Sqrt(xpos[i]*xpos[i] + ypos[i]*ypos[i]); + } + //if(fit_track_to_beamline){ + xpos[num_hits_this_chain[tid]] = 0; + ypos[num_hits_this_chain[tid]] = 0; + zpos[num_hits_this_chain[tid]] = Z0; + rpos[num_hits_this_chain[tid]] = 0; + num_hits_this_chain[tid]++; + //} + double t0 = (Math.Pi()/2) + Phi_deg*Math.DegToRad(); + double tmin = t0; + double tmax = t0 - Math.TwoPi(); + int numpoints = 2000; + double step = (tmax - tmin)/(numpoints-1); + double xarrhelix[numpoints]; + double yarrhelix[numpoints]; + double zarrhelix[numpoints]; + double xarrinner[numpoints]; + double yarrinner[numpoints]; + double xarrouter[numpoints]; + double yarrouter[numpoints]; + + int i2 = 0; + double partxhelix[numpoints]; + double partyhelix[numpoints]; + double partzhelix[numpoints]; + double partrhelix[numpoints]; + //TNtuple *helixn = new TNtuple("helixn","helixn","x:y:z"); + for(int i = 0; i < numpoints;i++){ + if(i*step >= -Math.Pi()){ + xarrhelix[i] = A+xcirc(tmin+i*step,R,0); + yarrhelix[i] = B+ycirc(tmin+i*step,R,0); + zarrhelix[i] = Z0-zcirc(tmin+i*step-t0,R,Theta_deg); + //zarrhelix[i] = Z0; + //helixn.Fill(xarrhelix[i],yarrhelix[i],zarrhelix[i]); + if(Math.Abs(xarrhelix[i])<70 && Math.Abs(yarrhelix[i])<70){ + partxhelix[i2] = xarrhelix[i]; + partyhelix[i2] = yarrhelix[i]; + partzhelix[i2] = zarrhelix[i]; + partrhelix[i2] = Math.Sqrt(xarrhelix[i] * xarrhelix[i] + yarrhelix[i] * yarrhelix[i]); + i2++; + } + } + xarrinner[i] = xcirc(tmin + i*step,30,0); + yarrinner[i] = ycirc(tmin + i*step,30,0); + xarrouter[i] = xcirc(tmin + i*step,70,0); + yarrouter[i] = ycirc(tmin + i*step,70,0); + + } + //TGraph *circgr = new TGraph(numpoints,partxhelix,partyhelix); + //circgr.SetMarkerColor(2); + //circgr.GetXaxis().SetLimits(-70,70); + //circgr.GetYaxis().SetRangeUser(-70,70); + + //mg.Add(circgr); + + //TGraph *innergr = new TGraph(numpoints,xarrinner,yarrinner); + //mg.Add(innergr); + //TGraph *outergr = new TGraph(numpoints,xarrouter,yarrouter); + //mg.Add(outergr); + + //TGraph *gr = new TGraph(num_hits_this_chain[tid]-1,xpos,ypos); + //gr.GetXaxis().SetLimits(-70,70); + //gr.GetYaxis().SetRangeUser(-70,70); + //gr.SetMarkerStyle(31); + //mg.Add(gr); + if(split_curve){ + //TGraph *gr2 = new TGraph(itemp - 1, tempx, tempy); + //gr2.GetXaxis().SetLimits(-70,70); + //gr2.GetYaxis().SetRangeUser(-70,70); + //gr2.SetMarkerStyle(31); + //mg.Add(gr2); + } + //mg.Add(genxy); + //mg.GetXaxis().SetLimits(-70,70); + //mg.GetYaxis().SetRangeUser(-70,70); + //mg.SetTitle("y vs x;x;y"); + //mg.draw("ap"); + + //p.Update(); + //p.SaveAs("gxy.png"); + //TCanvas *trz = new TCanvas("","",800,600); + //TMultiGraph *mgrz = new TMultiGraph(); + //TGraph *grz = new TGraph(num_hits_this_chain[tid],rpos,zpos); + //grz.SetMarkerStyle(31); + //TGraph *hgrz = new TGraph(numpoints,partrhelix,partzhelix); + //hgrz.SetMarkerColor(2); + //mgrz.Add(grz); + //mgrz.Add(hgrz); + if(split_curve){ + //TGraph *grz2 = new TGraph(itemp - 1, tempr, tempz); + //mgrz.Add(grz2); + } + //mgrz.SetTitle("z vs r;r;z"); + //mgrz.draw("ap"); + //trz.SaveAs("grz.png"); + //TApplication *tapp = new TApplication("tapp",0,0); + //TApplication tapp("App", 0, 0); + //TCanvas *tc = new TCanvas("","",800,600); + //TView3D *view = (TView3D*) TView::CreateView(1); + //view.SetRange(5,5,5,25,25,25); + //TView *view = TView::CreateView(1); + //view.SetRange(-70,-70,100,70,70,200); + //TNtuple *n = new TNtuple("n","n","x:y:z"); + for(int i = 0; i <= num_hits_this_chain[tid] ; i++){ + //n.Fill(xpos[i],ypos[i],zpos[i]); + //std::cout << xpos[i] << " " << ypos[i] << " " << zpos[i] << " " << Math.ATan2(ypos[i],xpos[i])*Math.RadToDeg() << std::endl; + } + if(split_curve){ + for(int i = 0; i <= itemp - 1; i++){ + //n.Fill(tempx[i],tempy[i],tempz[i]); + } + } + + //n.SetMarkerStyle(3); + //n.draw("x:y:z"); + //helixn.draw("x:y:z","","same"); + //tc.cd(); + //tc.Modified(); + //tc.Update(); + //TApplication *tapp = new TApplication("tapp",&argc, argv); + //tapp.Run(); + //tc.SaveAs("3d.png"); + + //std::cout << "\nNext Event?" << std::endl; + //int key = std::cin.get(); + //if (key == EOF || key == 'n' || key == 'N') return 0; + //if (key != '\n') std::cin.ignore(numeric_limits::max(), '\n'); + //std::cout << "OK" << std::endl; + + flag = false; + } + } + //double szpos[300][3] = new double[300][3]; + if(b < n_RTPC__rec_TID){ + tid = RTPC__rec_TID.getValue(b); + //std::cout << tid << endl; + } + else + { + break; + } + // if(tid = -111){break;} + num_chains++; + num_hits_this_chain[tid] = 0; + }else if(finish_track_flag){ + tempx[itemp] = RTPC__rec_posX.getValue(b); + tempy[itemp] = RTPC__rec_posY.getValue(b); + tempz[itemp] = RTPC__rec_posZ.getValue(b); + tempr[itemp] = Math.Sqrt(tempx[itemp]*tempx[itemp] + tempy[itemp]*tempy[itemp]); + itemp++; + continue; + } + + cellID = RTPC__rec_cellID.getValue(b); + time = RTPC__rec_time.getValue(b); + z = RTPC__rec_posZ.getValue(b);//*10.0; + x = RTPC__rec_posX.getValue(b);//*10.0; + y = RTPC__rec_posY.getValue(b);//*10.0; + r = sqrt(x*x+y*y); + phi = atan2(y,x); + q = 1; + //std::cout << x << " " << y << " " << z << endl; + if(split_curve && b > 0 && !trackidchange && !finish_track_flag && Math.Abs(time - RTPC__rec_time.getValue(b-1))>500){ + finish_track_flag = true; + //std::cout << "finish track flag" << std::endl; + continue; + } + itemp = 0; + num_hits_this_chain[tid]++; + hh_num_hits++; + chain_hits[tid][num_hits_this_chain[tid]] = hh_num_hits; + /* double z = RTPC__rec_posZ.getValue(b);//*10.0; + double x = RTPC__rec_posX.getValue(b);//*10.0; + double y = RTPC__rec_posY.getValue(b);//*10.0; + double r = sqrt(x*x+y*y); + double phi = atan2(y,x); + double q = 1;*/ + /*szpos[num_hits_this_chain[tid]-1][0] = x; + szpos[num_hits_this_chain[tid]-1][1] = y; + szpos[num_hits_this_chain[tid]-1][2] = z; + + hh_hitlist[hh_num_hits] = new HitVector(cellID,time,1,z,r,phi,q); + //std::cout << hh_num_hits << std::endl; + } + //std::cout << hh_num_hits << std::endl; + */ + /*double szpos_gen[300][3]; + int num_gen_hits = 0; + for(int b = 0; b < n_gen_TID; b++){ + if(RTPC__pos_tid.getValue(b) == 2){ + szpos_gen[num_gen_hits][0] = RTPC__pos_posx.getValue(b); + szpos_gen[num_gen_hits][1] = RTPC__pos_posy.getValue(b); + szpos_gen[num_gen_hits][2] = RTPC__pos_posz.getValue(b); + + num_gen_hits++; + + } + } + + HelixFit(num_gen_hits, szpos_gen, R, A, B, Phi_deg, Theta_deg, Z0, fit_track_to_beamline); +//std::cout << "tid : " << tid << std::endl; + /*std::cout << "A gen: " << A << std::endl; + std::cout << "B gen: " << B << std::endl; + std::cout << "R gen: " << R << std::endl; + std::cout << "p gen: " << 0.3*50*R/10 << std::endl; + std::cout << "Z gen: " << Z0 << std::endl; + std::cout << "Theta gen " << Theta_deg << std::endl; + std::cout << "Phi gen " << Phi_deg << std::endl; + */ + /*double genrec = 0.3*50*R/10; + h3.Fill(genrec); + hHitsvsMom.Fill(mom*1000,num_gen_hits); + mom_all[entry] = mom*1000; + num_hits[entry] = num_gen_hits; + z_all[entry] = vz; + hMomvsTheta.Fill(thetadeg,mom*1000); + hZvsTheta.Fill(thetadeg,vz); + theta_all[entry] = Math.Tan(thetarad); + // std::cout << vz << " " << Math.Tan(thetarad) << endl; + if((((Math.Tan(thetarad) > 0) && ((200-vz)*Math.Tan(thetarad) > 50)) || ((Math.Tan(thetarad) < 0) && (-(vz+200)*Math.Tan(thetarad) > 50))) && num_gen_hits < 5) { + //if(num_gen_hits < 5 && vz < (1.25*thetadeg + 75) && vz > (1.25*thetadeg - 300)){ //if(-(vz+200)*Math.Cos(thetarad) > 0 && (200 - vz)*Math.Cos(thetarad) > 0){//if(num_gen_hits < 5){ + hMomvsThetaCut.Fill(thetadeg,mom*1000); + hZvsThetaCut.Fill(thetadeg,vz); + hGenRecvsGenTrue2.Fill(mom*1000,genrec); + }else{ + hMomvsThetaelse.Fill(thetadeg,mom*1000); + hZvsThetaelse.Fill(thetadeg,vz); + } + hGenRecvsGenTrue.Fill(mom*1000,genrec); + double xtempgen[num_gen_hits-1]; + double ytempgen[num_gen_hits-1]; + double tmax = 2*Math.Pi(); + int numpoints2 = 2000; + double step2 = (tmax)/(numpoints2-1); + double xarrinner2[numpoints2]; + double yarrinner2[numpoints2]; + double xarrouter2[numpoints2]; + double yarrouter2[numpoints2]; + for(int i = 0; i < numpoints2; i++) + { + xarrinner2[i] = xcirc(i*step2,30,0); + yarrinner2[i] = ycirc(i*step2,30,0); + xarrouter2[i] = xcirc(i*step2,70,0); + yarrouter2[i] = ycirc(i*step2,70,0); + + } + TGraph ginner = new TGraph(numpoints2,xarrinner2,yarrinner2); + TGraph gouter = new TGraph(numpoints2,xarrouter2,yarrouter2); + + if(true){ + //if(genrec<1){ + failed_genrec++; + for(int i = 0; i < num_gen_hits-1; i++){ + xtempgen[i] = szpos_gen[i][0]; + ytempgen[i] = szpos_gen[i][1]; + } + gtest[entry] = new TGraph(num_gen_hits-1, xtempgen, ytempgen); + // std::cout << "DEBUG fail" << num_gen_hits << std::endl; + }else{ + double stuffx[1]; + double stuffy[1]; + stuffx[0] = 0; + stuffy[0] = 0; + gtest[entry] = new TGraph(1,stuffx,stuffy); + std::cout << "DEBUG succeed" << num_gen_hits << std::endl; + } + c6.cd(); + gtest[entry].SetTitle(Form("%f",mom*1000)); + gtest[entry].GetXaxis().SetLimits(-75,75); + gtest[entry].GetYaxis().SetRangeUser(-75,75); + + gtest[entry].SetMarkerStyle(21); + gtest[entry].SetMarkerColor(kBlack); + gtest[entry].draw("AP"); + ginner.draw("same"); + gouter.draw("same"); + //c6.SaveAs(Form("images_out/%u-mom=%f-theta=%f-vz=%f.png",entry,mom*1000,thetadeg,vz)); + c6.cd(); + h4.Fill(num_gen_hits); + + //After looping through all tracks + + /*HashMap::iterator it1 = zvertex_rec.begin(); + HashMap::iterator it2 = tshift_rec.begin(); + double zvertex_rec_comp = 100000; + double tshift_rec_small = 100000; + int tid_test = 0; + int tid_test2 = 0; + boolean found_track = false; + while(it2!=tshift_rec.end()){ + cout << it2.second << endl; + if(Math.Abs(it2.second) < tshift_rec_small){ + tshift_rec_small = Math.Abs(it2.second); + tid_test = it2.first; + } + + if(Math.Abs(it2.second) < 1000 && genrec > 1){ + double zdiff = Math.Abs(zvertex_rec[it2.first] - Z0); + if(zdiff < 20 && zdiff < zvertex_rec_comp){ + zvertex_rec_comp = Math.Abs(zvertex_rec[it2.first]); + tid_test2 = it2.first; + found_track = true; + } + } + + it2++; + } + cout << tshift_rec_small << endl; + cout << " " << endl; + if(found_track){ + cout << " " << endl; + cout << momentum_rec[tid_test] << " " << mom << endl; + cout << " " << endl; + h2.Fill(momentum_rec[tid_test2]); + hRecvsGenTrue.Fill(mom*1000,momentum_rec[tid_test2]); + hRecvsGenRec.Fill(genrec,momentum_rec[tid_test2]); + } + zvertex_rec.clear(); + tshift_rec.clear(); + momentum_rec.clear();*/ + /*} + h2.draw(); + h1.draw("same"); + h3.draw("same"); + c1.SaveAs("c1.png"); + + TCanvas * c2 = new TCanvas("c2", "Momentum genrec vs gen(MeV)", 800, 800); + hGenRecvsGenTrue.draw("colz"); + c2.SaveAs("c2.png"); + TCanvas * cGenRecvsGenTrue2 = new TCanvas("cGenRecvsGenTrue2", "Momentum genrec vs gen(MeV)", 800, 800); + hGenRecvsGenTrue2.draw("colz"); + cGenRecvsGenTrue2.SaveAs("cGenRecvsGenTrue2.png"); + /* + TCanvas * c3 = new TCanvas("c3", "Momentum rec vs gen(MeV)", 800, 800); + hRecvsGenTrue.draw("colz"); + c3.SaveAs("c3.png"); + TCanvas * c4 = new TCanvas("c4", "Momentum rec vs genrec(MeV)", 800, 800); + hRecvsGenRec.draw("colz"); + c4.SaveAs("c4.png"); + */ + /*TCanvas *c5 = new TCanvas("c5","num gen hits per track", 800, 800); + h4.draw(); + + TCanvas *cZvsTan = new TCanvas("cZvsTan","Z vs Tan(theta)", 800, 800); + TGraph *gZvsTan = new TGraph(4999,theta_all,z_all); + gZvsTan.SetTitle("Z vs Tan(theta);Tan(theta);Z(mm)"); + gZvsTan.SetMarkerStyle(21); + // gZvsTan.GetXaxis().SetLimits(-75,75); + // gZvsTan.GetYaxis().SetRangeUser(-75,75); + gZvsTan.draw("AP"); + cZvsTan.SaveAs("cZvsTan.png"); + + TCanvas *cZvsTanrange = new TCanvas("cZvsTanrange","Z vs Tan(theta)", 800, 800); + TGraph *gZvsTanrange = new TGraph(4999,theta_all,z_all); + gZvsTanrange.SetTitle("Z vs Tan(theta);Tan(theta);Z(mm)"); + gZvsTanrange.SetMarkerStyle(1); + gZvsTanrange.GetXaxis().SetLimits(-100,100); + // gZvsTanrange.GetYaxis().SetRangeUser(-75,75); + gZvsTanrange.draw("AP"); + cZvsTanrange.SaveAs("cZvsTanrange.png"); + + TCanvas *cHitsvsMom = new TCanvas("cHitsvsMom","Num hits vs momentum", 800, 800); + hHitsvsMom.draw("colz"); + cHitsvsMom.SaveAs("cHitsvsMom.png"); + + TCanvas *cHitsvsMom2 = new TCanvas("cHitsvsMom2","Num hits vs momentum", 800, 800); + TGraph *gHitsvsMom = new TGraph(4999,mom_all,num_hits); + gHitsvsMom.SetTitle("Hits vs Mom;Momentum(lund);Number of Hits"); + gHitsvsMom.SetMarkerStyle(1); + gHitsvsMom.SetMarkerColor(kBlack); + gHitsvsMom.draw("AP"); + cHitsvsMom2.SaveAs("cHitsvsMom2.png"); + + TCanvas *cZvsTheta = new TCanvas("cZvsTheta","Z vertex(lund) vs Theta",800,800); + hZvsTheta.draw("colz"); + cZvsTheta.SaveAs("cZvsTheta.png"); + + TCanvas *cMomvsTheta = new TCanvas("cMomvsTheta","Mom vs Theta", 800, 800); + hMomvsTheta.setTitleX("Theta"); + hMomvsTheta.setTitleY("Momentum"); + hMomvsTheta.draw("colz"); + + + TCanvas *cZvsThetaCut = new TCanvas("cZvsThetaCut","Z vertex(lund) vs Theta",800,800); + hZvsThetaCut.draw("colz"); + + + TCanvas *cMomvsThetaCut = new TCanvas("cMomvsThetaCut","Mom vs Theta", 800, 800); + hMomvsThetaCut.setTitleX("Theta"); + hMomvsThetaCut.setTitleY("Momentum"); + hMomvsThetaCut.draw("colz"); + + + TCanvas *cZvsThetaelse = new TCanvas("cZvsThetaelse","Z vertex(lund) vs Theta",800,800); + hZvsThetaelse.draw("colz"); + + + TCanvas *cMomvsThetaelse = new TCanvas("cMomvsThetaelse","Mom vs Theta", 800, 800); + hMomvsThetaelse.setTitleX("Theta"); + hMomvsThetaelse.setTitleY("Momentum"); + hMomvsThetaelse.draw("colz"); + + + + + } + + double xcirc(double t, double r, double ph0){ + + return r*(Math.cos(ph0+t)); + } + double ycirc(double t, double r, double ph0){ + + return r*(Math.sin(ph0+t)); + } + double zcirc(double t, double r, double th){ + + return r*t/Math.tan(th*Math.PI/180); + } +*/ +} +} +class HitVector2{ + + int pad; + double t; + int status; + double z; + double r; + double phi; + double q; + + public HitVector2()//Default constructor + { + pad = status = -1; + t = z = r = phi = q = -1.0; + } + public HitVector2(int _pad, double _t, int _status, double _z, double _r, double _phi, double _q) + { + pad = _pad; + t = _t; + status = _status; + z = _z; + r = _r; + phi = _phi; + q = _q; + } +} \ No newline at end of file diff --git a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/HitDistance.java b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/HitDistance.java index 1dd2b5f470..282907e972 100644 --- a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/HitDistance.java +++ b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/HitDistance.java @@ -2,7 +2,7 @@ import java.util.HashMap; import java.util.concurrent.ConcurrentHashMap; -import java.util.Vector; +import java.util.List; import javax.swing.JFrame; @@ -14,7 +14,7 @@ public class HitDistance { public void FindDistance(HitParameters params) { HashMap ADCMap = params.get_R_adc(); - Vector PadNum = params.get_PadNum(); + List PadNum = params.get_PadNum(); int Pad = 0; //initializing pad int Pad2 = 0; int TrigWindSize = params.get_TrigWindSize(); //Trigger Window Size = 10000 diff --git a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/HitParameters.java b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/HitParameters.java index dc2144ff9f..b8f2b8c1d6 100644 --- a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/HitParameters.java +++ b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/HitParameters.java @@ -1,8 +1,8 @@ package org.jlab.rec.rtpc.hit; +import java.util.List; import java.util.ArrayList; import java.util.HashMap; -import java.util.Vector; import java.util.concurrent.ConcurrentHashMap; import org.jlab.clas.physics.LorentzVector; @@ -15,91 +15,86 @@ public class HitParameters { private int _NBinKept = 3; private int _TrigWindSize = 10000; private int _eventnum = 0; - private HashMap _R_adc = new HashMap(); - private HashMap> _TimeMap = new HashMap>(); - private HashMap> _FinalTIDMap = new HashMap>(); - private Vector _PadN = new Vector(); // used to read only cell with signal, one entry for each hit - private Vector _PadNum = new Vector();// used to read only cell with signal, one entry for each cell - private Vector _Pad = new Vector(); - private Vector _ADC = new Vector(); - private Vector _Time_o = new Vector(); - private Vector _weightave = new Vector(); - private Vector _maxinte = new Vector(); - private Vector _time = new Vector(); - private Vector _XVec = new Vector(); - private Vector _YVec = new Vector(); - private Vector _ZVec = new Vector(); - private HashMap>> _TIDMap = new HashMap>>(); - private HashMap>> _strkTIDMap = new HashMap>>(); - private HashMap> _alltracks = new HashMap>(); - private HashMap _largetmap = new HashMap(); - private HashMap> _recohitvector = new HashMap>(); - private HashMap _padmap = new HashMap(); + private HashMap _R_adc = new HashMap<>(); + private HashMap> _TimeMap = new HashMap<>(); + private HashMap> _FinalTIDMap = new HashMap<>(); + private List _PadN = new ArrayList<>(); // used to read only cell with signal, one entry for each hit + private List _PadNum = new ArrayList<>();// used to read only cell with signal, one entry for each cell + private List _Pad = new ArrayList<>(); + private List _ADC = new ArrayList<>(); + private List _Time_o = new ArrayList<>(); + private List _weightave = new ArrayList<>(); + private List _maxinte = new ArrayList<>(); + private List _time = new ArrayList<>(); + private List _XVec = new ArrayList<>(); + private List _YVec = new ArrayList<>(); + private List _ZVec = new ArrayList<>(); + private HashMap>> _TIDMap = new HashMap<>(); + private HashMap>> _strkTIDMap = new HashMap<>(); + private HashMap> _alltracks = new HashMap<>(); + private HashMap _largetmap = new HashMap<>(); + private HashMap> _recohitvector = new HashMap<>(); + private HashMap _padmap = new HashMap<>(); private TrackMap _trackmap = new TrackMap(); private ReducedTrackMap _rtrackmap = new ReducedTrackMap(); - public int get_StepSize(){return _StepSize;} // step size of the signal before integration (arbitrary value) - public int get_BinSize(){return _BinSize;} // electronics integrates the signal over 40 ns - public int get_NBinKept(){return _NBinKept;} // only 1 bin over 3 is kept by the daq - public int get_TrigWindSize(){return _TrigWindSize;} // Trigger window should be 10 micro - public HashMap get_R_adc(){return _R_adc;} - public HashMap> get_TimeMap(){return _TimeMap;} - public Vector get_PadN(){return _PadN;} - public Vector get_PadNum(){return _PadNum;} - public Vector get_Pad(){return _Pad;} - public Vector get_ADC(){return _ADC;} - public Vector get_Time_o(){return _Time_o;} - public int get_eventnum(){return _eventnum;} - public Vector get_weightave() {return _weightave;} - public Vector get_maxinte() {return _maxinte;} - public Vector get_time() {return _time;} - public Vector get_XVec() {return _XVec;} - public Vector get_YVec() {return _YVec;} - public Vector get_ZVec() {return _ZVec;} - public HashMap>> get_TIDMap() {return _TIDMap;} - public HashMap>> get_strkTIDMap() {return _strkTIDMap;} - public HashMap> get_FinalTIDMap() {return _FinalTIDMap;} - public HashMap> get_alltracks() {return _alltracks;} - public HashMap get_largetmap() {return _largetmap;} - public HashMap> get_recohitvector() {return _recohitvector;} - public TrackMap get_trackmap() {return _trackmap;} - public ReducedTrackMap get_rtrackmap() {return _rtrackmap;} - public PadVector get_padvector(int pad) { - if(!_padmap.containsKey(pad)) { - _padmap.put(pad, new PadVector(pad)); - } - return _padmap.get(pad); - } + public int get_StepSize(){return _StepSize;} // step size of the signal before integration (arbitrary value) + public int get_BinSize(){return _BinSize;} // electronics integrates the signal over 40 ns + public int get_NBinKept(){return _NBinKept;} // only 1 bin over 3 is kept by the daq + public int get_TrigWindSize(){return _TrigWindSize;} // Trigger window should be 10 micro + public HashMap get_R_adc(){return _R_adc;} + public HashMap> get_TimeMap(){return _TimeMap;} + public List get_PadN(){return _PadN;} + public List get_PadNum(){return _PadNum;} + public List get_Pad(){return _Pad;} + public List get_ADC(){return _ADC;} + public List get_Time_o(){return _Time_o;} + public int get_eventnum(){return _eventnum;} + public List get_weightave() {return _weightave;} + public List get_maxinte() {return _maxinte;} + public List get_time() {return _time;} + public List get_XVec() {return _XVec;} + public List get_YVec() {return _YVec;} + public List get_ZVec() {return _ZVec;} + public HashMap>> get_TIDMap() {return _TIDMap;} + public HashMap>> get_strkTIDMap() {return _strkTIDMap;} + public HashMap> get_FinalTIDMap() {return _FinalTIDMap;} + public HashMap> get_alltracks() {return _alltracks;} + public HashMap get_largetmap() {return _largetmap;} + public HashMap> get_recohitvector() {return _recohitvector;} + public TrackMap get_trackmap() {return _trackmap;} + public ReducedTrackMap get_rtrackmap() {return _rtrackmap;} + public PadVector get_padvector(int pad) { + if(!_padmap.containsKey(pad)) { + _padmap.put(pad, new PadVector(pad)); + } + return _padmap.get(pad); + } - public void set_R_adc(HashMap _R_adc){this._R_adc = _R_adc;} - public void set_TimeMap(HashMap> _TimeMap){this._TimeMap = _TimeMap;} - public void set_PadN(Vector _PadN){this._PadN = _PadN;} - public void set_PadNum(Vector _PadNum){this._PadNum = _PadNum;} - public void set_Pad(Vector _Pad){this._Pad = _Pad;} - public void set_ADC(Vector _ADC){this._ADC = _ADC;} - public void set_Time_o(Vector _Time_o){this._Time_o = _Time_o;} - public void set_eventnum(int _eventnum){this._eventnum = _eventnum;} - public void set_weightave(Vector _weightave) {this._weightave = _weightave;} - public void set_maxinte(Vector _maxinte) {this._maxinte = _maxinte;} - public void set_time(Vector _time) {this._time = _time;} - public void set_XVec(Vector _XVec) {this._XVec = _XVec;} - public void set_YVec(Vector _YVec) {this._YVec = _YVec;} - public void set_ZVec(Vector _ZVec) {this._ZVec = _ZVec;} - public void set_TIDMap(HashMap>> _TIDMap) {this._TIDMap = _TIDMap;} - public void set_strkTIDMap(HashMap>> _strkTIDMap) {this._strkTIDMap = _strkTIDMap;} - public void set_FinalTimeMap(HashMap> _finalTIDMap){this._FinalTIDMap = _finalTIDMap;} - public void set_alltracks(HashMap> _alltracks) {this._alltracks = _alltracks;} - public void set_largetmap(HashMap _largetmap) {this._largetmap = _largetmap;} - public void set_recohitvector(HashMap> _recohitvector) {this._recohitvector = _recohitvector;} - public void set_trackmap(TrackMap _trackmap) {this._trackmap = _trackmap;} - public void set_rtrackmap(ReducedTrackMap _rtrackmap) {this._rtrackmap = _rtrackmap;} - - public HitParameters() {} - - private static HitParameters INSTANCE = new HitParameters(); - - public static HitParameters getInstance() { - return HitParameters.INSTANCE; -} + public void set_R_adc(HashMap _R_adc){this._R_adc = _R_adc;} + public void set_TimeMap(HashMap> _TimeMap){this._TimeMap = _TimeMap;} + public void set_PadN(List _PadN){this._PadN = _PadN;} + public void set_PadNum(List _PadNum){this._PadNum = _PadNum;} + public void set_Pad(List _Pad){this._Pad = _Pad;} + public void set_ADC(List _ADC){this._ADC = _ADC;} + public void set_Time_o(List _Time_o){this._Time_o = _Time_o;} + public void set_eventnum(int _eventnum){this._eventnum = _eventnum;} + public void set_weightave(List _weightave) {this._weightave = _weightave;} + public void set_maxinte(List _maxinte) {this._maxinte = _maxinte;} + public void set_time(List _time) {this._time = _time;} + public void set_XVec(List _XVec) {this._XVec = _XVec;} + public void set_YVec(List _YVec) {this._YVec = _YVec;} + public void set_ZVec(List _ZVec) {this._ZVec = _ZVec;} + public void set_TIDMap(HashMap>> _TIDMap) {this._TIDMap = _TIDMap;} + public void set_strkTIDMap(HashMap>> _strkTIDMap) {this._strkTIDMap = _strkTIDMap;} + public void set_FinalTimeMap(HashMap> _finalTIDMap){this._FinalTIDMap = _finalTIDMap;} + public void set_alltracks(HashMap> _alltracks) {this._alltracks = _alltracks;} + public void set_largetmap(HashMap _largetmap) {this._largetmap = _largetmap;} + public void set_recohitvector(HashMap> _recohitvector) {this._recohitvector = _recohitvector;} + public void set_trackmap(TrackMap _trackmap) {this._trackmap = _trackmap;} + public void set_rtrackmap(ReducedTrackMap _rtrackmap) {this._rtrackmap = _rtrackmap;} + + public HitParameters() {} + } \ No newline at end of file diff --git a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/HitReconstruction.java b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/HitReconstruction.java index c584416380..76868c90c1 100644 --- a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/HitReconstruction.java +++ b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/HitReconstruction.java @@ -10,13 +10,10 @@ public HitReconstruction() { } public void Reco(HitParameters params) { - Vector PadNum = params.get_PadNum(); - Vector weightave = params.get_weightave(); - Vector maxinte = params.get_maxinte(); - Vector TimeVec = new Vector(); - Vector XVec = new Vector(); - Vector YVec = new Vector(); - Vector ZVec = new Vector(); + List PadNum = params.get_PadNum(); + List weightave = params.get_weightave(); + List maxinte = params.get_maxinte(); + int p = 0; //for(Hit hit : rawHits) { for(p = 0; p> TAMap = params.get_FinalTIDMap(); - HashMap>> TFMap = params.get_strkTIDMap(); + HashMap> TAMap = params.get_FinalTIDMap(); + HashMap>> TFMap = params.get_strkTIDMap(); HashMap ADCMap = params.get_R_adc(); - Vector PadList = new Vector(); + List PadList = new ArrayList(); double maxvalue = 0; double thresh = 0; int TrigWindSize = params.get_TrigWindSize(); @@ -32,12 +34,12 @@ public void MC(HitParameters params, boolean draw) { HashMap weightave = new HashMap(); HashMap weightaveadc = new HashMap(); - HashMap> trTFMap = new HashMap>(); - HashMap> alltracks = new HashMap>(); + HashMap> trTFMap = new HashMap>(); + HashMap> alltracks = new HashMap>(); HitVector vtmp = new HitVector(); HitVector v3tmp = new HitVector(); HitVector hitvec = new HitVector(); - Vector toListvec = new Vector(); + List toListvec = new ArrayList(); double larget = 0; int countadcvalues = 0; @@ -107,7 +109,7 @@ public void MC(HitParameters params, boolean draw) { int pad = 0; double avetime = 0; double adc = 0; - trTFMap.put(TID,new Vector()); + trTFMap.put(TID,new ArrayList()); for(int p = 0; p < PadList.size(); p++) { pad = PadList.get(p); @@ -134,7 +136,7 @@ public void MC(HitParameters params, boolean draw) { { if(trTFMap.get(choosetid).get(j).time() < smalltime && i!=j) { - trTFMap.get(choosetid).insertElementAt(trTFMap.get(choosetid).get(i), j); + trTFMap.get(choosetid).add(j, trTFMap.get(choosetid).get(i)); trTFMap.get(choosetid).remove(i+1); break; } @@ -145,7 +147,7 @@ public void MC(HitParameters params, boolean draw) { for(int i : TAMap.keySet()) { //toListvec.clear(); - alltracks.put(newtid, new Vector()); + alltracks.put(newtid, new ArrayList()); for(int j = 0; j < TAMap.get(i).size(); j++) { vtmp = TAMap.get(i).get(j); @@ -168,7 +170,7 @@ public void MC(HitParameters params, boolean draw) { { //System.out.println(" "); //toListvec.clear(); - alltracks.put(newtid, new Vector()); + alltracks.put(newtid, new ArrayList()); //for(int pad : trTFMap.get(i).keySet()) for(int j = 0; j < trTFMap.get(i).size(); j++) { @@ -191,7 +193,7 @@ public void MC(HitParameters params, boolean draw) { HashMap framemap = new HashMap(); //H2F adcvst = new H2F("adcvst",500,3000,12000,500,0,10); //System.out.println(" "); - Vector marktid = new Vector(); + List marktid = new ArrayList(); for(int i : alltracks.keySet()) { larget = 0; diff --git a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/PadAve.java b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/PadAve.java index 79f5d80b13..5e40a48ebe 100644 --- a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/PadAve.java +++ b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/PadAve.java @@ -5,7 +5,8 @@ import java.io.IOException; import java.util.concurrent.ConcurrentHashMap; import java.util.HashMap; -import java.util.Vector; +import java.util.List; +import java.util.ArrayList; public class PadAve { public void TimeAverage(HitParameters params){ @@ -24,14 +25,14 @@ public void TimeAverage(HitParameters params){ double weightave = 0; double timesum = 0; HashMap R_adc = params.get_R_adc(); - HashMap> TimeMap = params.get_TimeMap(); - Vector PadNum = params.get_PadNum(); - Vector PadN = params.get_PadN(); - Vector Pad = params.get_Pad(); - Vector ADC = params.get_ADC(); - Vector Time_o = params.get_Time_o(); - Vector weightavevec = new Vector(); - Vector maxinte = new Vector(); + HashMap> TimeMap = params.get_TimeMap(); + List PadNum = params.get_PadNum(); + List PadN = params.get_PadN(); + List Pad = params.get_Pad(); + List ADC = params.get_ADC(); + List Time_o = params.get_Time_o(); + List weightavevec = new ArrayList(); + List maxinte = new ArrayList(); boolean flag_event = false; int eventnum = params.get_eventnum(); //try{ diff --git a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/PadFit.java b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/PadFit.java index 9d28646775..d6a9a87095 100644 --- a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/PadFit.java +++ b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/PadFit.java @@ -20,27 +20,27 @@ public class PadFit { - public void Fitting(HitParameters params){ + public PadFit(HitParameters params){ - int StepSize = params.get_StepSize(); // step size of the signal before integration (arbitrary value) - int BinSize = params.get_BinSize(); // electronics integrates the signal over 40 ns - int NBinKept = params.get_NBinKept(); // only 1 bin over 3 is kept by the daq - int TrigWindSize = params.get_TrigWindSize(); // Trigger window should be 10 micro - int NTrigSampl = TrigWindSize/BinSize; // number of time samples - double inte=0; - double inte_tot; // integral of the signal in BinSize - double max_inte=0; // maximum of the integral to help the fit - double max_t=0; - HashMap R_adc = params.get_R_adc(); - HashMap Adcmap = new HashMap(); - Vector PadNum = params.get_PadNum(); - Vector PadN = params.get_PadN(); - Vector Pad = params.get_Pad(); - Vector ADC = params.get_ADC(); - Vector Time_o = params.get_Time_o(); - boolean flag_event = false; - int eventnum = params.get_eventnum(); + int StepSize = params.get_StepSize(); // step size of the signal before integration (arbitrary value) + int BinSize = params.get_BinSize(); // electronics integrates the signal over 40 ns + int NBinKept = params.get_NBinKept(); // only 1 bin over 3 is kept by the daq + int TrigWindSize = params.get_TrigWindSize(); // Trigger window should be 10 micro + int NTrigSampl = TrigWindSize/BinSize; // number of time samples + double inte=0; + double inte_tot; // integral of the signal in BinSize + double max_inte=0; // maximum of the integral to help the fit + double max_t=0; + HashMap R_adc = params.get_R_adc(); + HashMap Adcmap = new HashMap(); + List PadNum = params.get_PadNum(); + List PadN = params.get_PadN(); + List Pad = params.get_Pad(); + List ADC = params.get_ADC(); + List Time_o = params.get_Time_o(); + boolean flag_event = false; + int eventnum = params.get_eventnum(); /*JFrame j1 = new JFrame(); GraphErrors g1 = new GraphErrors(); @@ -55,29 +55,29 @@ public void Fitting(HitParameters params){ //F1D f1 = new F1D("f1", "[amp]*gaus(x,[mean],[sigma])",0,1); - inte=0; - for(int p=0;p0) inte+=0.5*(R_adc.get(PadNum.get(p))[t-StepSize]+R_adc.get(PadNum.get(p))[t])*StepSize; - - inte_tot+=inte; - if(t%BinSize==0 && t>0){ // integration over BinSize - if(t%(BinSize*NBinKept)==0){ // one BinSize over NBinKept is read out, hence added to the histogram - - Adcmap.get(PadNum.get(p))[t] = inte; - - //g1.addPoint(t,inte,0,0); - if(max_inte0) inte+=0.5*(R_adc.get(PadNum.get(p))[t-StepSize]+R_adc.get(PadNum.get(p))[t])*StepSize; + + inte_tot+=inte; + if(t%BinSize==0 && t>0){ // integration over BinSize + if(t%(BinSize*NBinKept)==0){ // one BinSize over NBinKept is read out, hence added to the histogram + + Adcmap.get(PadNum.get(p))[t] = inte; + + //g1.addPoint(t,inte,0,0); + if(max_inte R_adc;// = params.get_R_adc();// Raw depositions for CellID, ADC + private HashMap> TimeMap;// = params.get_TimeMap(); + + private List PadN;// = params.get_PadN(); // used to read only cell with signal, one entry for each hit + //Vector PadNum = params.get_PadNum();// used to read only cell with signal, one entry for each cell + private List PadNum = new ArrayList<>(); + private List ADC = new ArrayList<>(); + + private List Pad;// = params.get_Pad(); + //Vector ADC = params.get_ADC(); + private List Time_o;// = params.get_Time_o(); + - -public PadHit(){} - + private int CellID = 0; + private double Time; + private double totEdep; + private int eventnum;// = params.get_eventnum(); + + private double testsum = 0; + private double testcount = 1; -public void bonus_shaping(List rawHits, HitParameters params){ +public PadHit(List rawHits, HitParameters params){ -//______________________________________________________________________________________________ -// __________________________________________ Variables _________________________________________ -//______________________________________________________________________________________________ - - int StepSize = params.get_StepSize(); // step size of the signal before integration (arbitrary value) - int BinSize = params.get_BinSize(); // electronics integrates the signal over 40 ns - int NBinKept = params.get_NBinKept(); // only 1 bin over 3 is kept by the daq - int TrigWindSize = params.get_TrigWindSize(); // Trigger window should be 10 micro - int NTrigSampl = TrigWindSize/BinSize; // number of time samples - - HashMap R_adc = params.get_R_adc();// Raw depositions for CellID, ADC - HashMap> TimeMap = params.get_TimeMap(); - - Vector PadN = params.get_PadN(); // used to read only cell with signal, one entry for each hit - //Vector PadNum = params.get_PadNum();// used to read only cell with signal, one entry for each cell - Vector PadNum = new Vector(); - Vector ADC = new Vector(); - - Vector Pad = params.get_Pad(); - //Vector ADC = params.get_ADC(); - Vector Time_o = params.get_Time_o(); - + @@ -61,13 +66,22 @@ public void bonus_shaping(List rawHits, HitParameters params){ // __________________________________________ Openings __________________________________________ //______________________________________________________________________________________________ - int CellID = 0; - double Time; - double totEdep; - int eventnum = params.get_eventnum(); - eventnum++; - double testsum = 0; - double testcount = 1; + + StepSize = params.get_StepSize(); // step size of the signal before integration (arbitrary value) + BinSize = params.get_BinSize(); // electronics integrates the signal over 40 ns + NBinKept = params.get_NBinKept(); // only 1 bin over 3 is kept by the daq + TrigWindSize = params.get_TrigWindSize(); // Trigger window should be 10 micro + NTrigSampl = TrigWindSize/BinSize; // number of time samples + R_adc = params.get_R_adc();// Raw depositions for CellID, ADC + TimeMap = params.get_TimeMap(); + PadN = params.get_PadN(); // used to read only cell with signal, one entry for each hit + Pad = params.get_Pad(); + Time_o = params.get_Time_o(); + + + eventnum = params.get_eventnum(); + eventnum++; + //______________________________________________________________________________________________ // __________________________________________ Readings __________________________________________ @@ -87,87 +101,82 @@ public void bonus_shaping(List rawHits, HitParameters params){ //HashMap gmap = new HashMap(); - for(Hit hit : rawHits){ - - CellID = hit.get_cellID(); - Time = hit.get_Time(); - totEdep = hit.get_EdepTrue(); - - /*try { - - File out = new File("/Users/dpaye001/Desktop/FileOutput/event" + eventnum + "/"); - if(!out.exists()) - {out.mkdirs();} - FileWriter write = new FileWriter("/Users/dpaye001/Desktop/FileOutput/event" + eventnum + "/" + "timetrue.xls",true); - write.write(Time + "\t" + CellID + "\r\n"); - write.close(); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - }*/ + for(Hit hit : rawHits){ + + CellID = hit.get_cellID(); + Time = hit.get_Time(); + totEdep = hit.get_EdepTrue(); + + /*try { + + File out = new File("/Users/dpaye001/Desktop/FileOutput/event" + eventnum + "/"); + if(!out.exists()) + {out.mkdirs();} + FileWriter write = new FileWriter("/Users/dpaye001/Desktop/FileOutput/event" + eventnum + "/" + "timetrue.xls",true); + write.write(Time + "\t" + CellID + "\r\n"); + write.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + }*/ // searches in PadN if CellID already exists if(PadN.contains(CellID)){ // this pad has already seen signal - for(int t=0;t()); - TimeMap.get(CellID).add(Time); - for(int t=0;t()); + TimeMap.get(CellID).add(Time); + for(int t=0;t ADCMap;// = params.get_R_adc(); + private List tids;// = TIDMap.getAllTrackIDs(); + private Track track; + private double adc = 0; + private double adcmax = 0; + private double averagetime = 0; + private double adcthresh = 0; + private double sumnum = 0; + private double sumden = 0; + public TimeAverage2(HitParameters params, boolean draw) { /* *Initializations */ - - ReducedTrackMap RTIDMap = new ReducedTrackMap(); - ReducedTrack rtrack; - TrackMap TIDMap = params.get_trackmap(); - HashMap ADCMap = params.get_R_adc(); - List tids = TIDMap.getAllTrackIDs(); - Track track; - double adc = 0; - double adcmax = 0; - double averagetime = 0; - double adcthresh = 0; - double sumnum = 0; - double sumden = 0; + TIDMap = params.get_trackmap(); + ADCMap = params.get_R_adc(); + tids = TIDMap.getAllTrackIDs(); /* * Main Algorithm diff --git a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TrackFinder3.java b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TrackFinder3.java index 3848bdf570..750dd462ce 100644 --- a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TrackFinder3.java +++ b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TrackFinder3.java @@ -8,9 +8,7 @@ import java.util.ArrayList; import java.util.HashMap; -import java.util.concurrent.ConcurrentHashMap; import java.util.List; -import java.util.Vector; import javax.swing.JFrame; @@ -19,30 +17,36 @@ public class TrackFinder3 { + + private TrackUtils tutil = new TrackUtils(); + private TrackMap TIDMap = new TrackMap(); + private List TIDList; + private Track track; + private HashMap ADCMap;// = params.get_R_adc(); + private List PadNum;// = params.get_PadNum(); + private int TrigWindSize;// = params.get_TrigWindSize(); + private int StepSize = 120; + private double adcthresh = 5e-4; + private int padloopsize;// = PadNum.size(); + private boolean padSorted = false; + private List padTIDlist = new ArrayList(); + private List padlist; + private int pad = 0; + private double adc = 0; + private int timeadjlimit = 4; + private int parenttid = -1; + private String method = "phiz"; + private int minhitcount = 5; + public TrackFinder3(HitParameters params, boolean draw) { /* *Initializations */ - TrackUtils tutil = new TrackUtils(); - TrackMap TIDMap = new TrackMap(); - List TIDList; - Track track; - HashMap ADCMap = params.get_R_adc(); - Vector PadNum = params.get_PadNum(); - int TrigWindSize = params.get_TrigWindSize(); - int StepSize = 120; - double adcthresh = 5e-4; - int padloopsize = PadNum.size(); - boolean padSorted = false; - List padTIDlist = new ArrayList(); - List padlist; - int pad = 0; - double adc = 0; - int timeadjlimit = 4; - int parenttid = -1; - String method = "phiz"; - int minhitcount = 5; + ADCMap = params.get_R_adc(); + PadNum = params.get_PadNum(); + TrigWindSize = params.get_TrigWindSize(); + padloopsize = PadNum.size(); /* * Main Algorithm */ diff --git a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TrackHitReco3.java b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TrackHitReco3.java index de93d85a77..0b556335cb 100644 --- a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TrackHitReco3.java +++ b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TrackHitReco3.java @@ -14,8 +14,6 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import java.util.Vector; -import java.util.concurrent.ConcurrentHashMap; import javax.swing.JFrame; @@ -32,16 +30,16 @@ public TrackHitReco3(List rawHits, HitParameters params, boolean draw) { HashMap graphmap = new HashMap(); HashMap graphmap2 = new HashMap(); */ - HashMap> alltracks = params.get_alltracks(); + HashMap> alltracks = params.get_alltracks(); HashMap largetmap = params.get_largetmap(); - HashMap tdiffmap = new HashMap(); - HashMap> recohitvector = new HashMap>(); + HashMap tdiffmap = new HashMap<>(); + HashMap> recohitvector = new HashMap<>(); ReducedTrackMap RTIDMap = params.get_rtrackmap(); - Vector TimeVec = new Vector(); - Vector XVec = new Vector(); - Vector YVec = new Vector(); - Vector ZVec = new Vector(); - Vector Pads = new Vector(); + List TimeVec = new ArrayList<>(); + List XVec = new ArrayList<>(); + List YVec = new ArrayList<>(); + List ZVec = new ArrayList<>(); + List Pads = new ArrayList<>(); int p = 0; double a_t1 = -2.48491E-4; @@ -68,7 +66,7 @@ public TrackHitReco3(List rawHits, HitParameters params, boolean draw) { double b_phi4 = 2.57684E-5; double b_phi5 = 2.10680E-2; if(draw){ - H1F largetdist = new H1F("largetdist",100,0,10000); + H1F largetdist = new H1F("largetdist",100,0,10000); } double timewindow = 2000; double smalltcut = 300; @@ -94,7 +92,7 @@ public TrackHitReco3(List rawHits, HitParameters params, boolean draw) { } tdiff = 6000 - larget; tdiffmap.put(TID, tdiff); - recohitvector.put(TID, new Vector()); + recohitvector.put(TID, new ArrayList<>()); List allhits = t.getAllHits(); for(HitVector hit : allhits) { @@ -296,7 +294,7 @@ public TrackHitReco3(List rawHits, HitParameters params, boolean draw) { GraphErrors gerroryvsphi = new GraphErrors();*/ int counter = 1; - for(Hit hit : rawHits) + /*for(Hit hit : rawHits) { if(true) { cellID = hit.get_cellID(); @@ -513,9 +511,9 @@ public TrackHitReco3(List rawHits, HitParameters params, boolean draw) { YVec.add(y_rec); ZVec.add(z_rec);*/ //} - counter++; - } + /*counter++; } + }*/ if(draw){ /*EmbeddedCanvas c = new EmbeddedCanvas(); EmbeddedCanvas c2 = new EmbeddedCanvas(); @@ -635,7 +633,7 @@ public TrackHitReco3(List rawHits, HitParameters params, boolean draw) { params.set_recohitvector(recohitvector); } - double get_rec_coef(double t1, double t2, double t3, double t4, double t5, double z2) { + private double get_rec_coef(double t1, double t2, double t3, double t4, double t5, double z2) { double z = z2/1000; return t1*z*z*z*z + t2*z*z*z + t3*z*z + t4*z + t5; diff --git a/reconstruction/rtpc/src/main/java/org/jlab/service/rtpc/RTPCEngine.java b/reconstruction/rtpc/src/main/java/org/jlab/service/rtpc/RTPCEngine.java index 92bf89fe19..0d04cb5ab4 100644 --- a/reconstruction/rtpc/src/main/java/org/jlab/service/rtpc/RTPCEngine.java +++ b/reconstruction/rtpc/src/main/java/org/jlab/service/rtpc/RTPCEngine.java @@ -8,8 +8,6 @@ import java.util.List; import org.jlab.clas.reco.ReconstructionEngine; -//import org.jlab.coda.hipo.HipoException; -//import org.jlab.coda.jevio.EvioException; import org.jlab.io.base.DataBank; import org.jlab.io.base.DataEvent; import org.jlab.io.hipo.HipoDataSource; @@ -17,137 +15,117 @@ import org.jlab.rec.rtpc.banks.HitReader; import org.jlab.rec.rtpc.banks.RecoBankWriter2; import org.jlab.rec.rtpc.hit.Hit; -import org.jlab.rec.rtpc.hit.HitDistance; import org.jlab.rec.rtpc.hit.HitParameters; -import org.jlab.rec.rtpc.hit.HitReconstruction; -import org.jlab.rec.rtpc.hit.MapCombine; -import org.jlab.rec.rtpc.hit.PadAve; import org.jlab.rec.rtpc.hit.PadFit; import org.jlab.rec.rtpc.hit.PadHit; -//import org.jlab.rec.rtpc.hit.PulseShapeAnalysis; import org.jlab.rec.rtpc.hit.TimeAverage2; //import org.jlab.rec.rtpc.hit.TrackDisentangler; -//import org.jlab.rec.rtpc.hit.TrackFinder; import org.jlab.rec.rtpc.hit.TrackFinder3; import org.jlab.rec.rtpc.hit.TrackHitReco3; +import org.jlab.rec.rtpc.hit.HelixFitTest; public class RTPCEngine extends ReconstructionEngine{ - int test = 0; - int swtch = 2; - - - public RTPCEngine() { - super("RTPC","charlesg","3.0"); - } - - @Override - public boolean init() { - // TODO Auto-generated method stub - return true; - } - - @Override - public boolean processDataEvent(DataEvent event) { - HitParameters params = new HitParameters(); - HitReader hitRead = new HitReader(); - hitRead.fetch_RTPCHits(event); - - List hits = new ArrayList(); - //I) get the hits - hits = hitRead.get_RTPCHits(); - - //II) process the hits - //1) exit if hit list is empty - if(hits==null || hits.size()==0) { - return true; - } - if(event.hasBank("RTPC::pos")) - { - PadHit phit = new PadHit(); - phit.bonus_shaping(hits,params); - PadFit pfit = new PadFit(); - pfit.Fitting(params); - - - if(swtch == 1) //not used normally - { - HitDistance HD = new HitDistance(); - HD.FindDistance(params); - } - else if(swtch == 2) { //current build only use this one - TrackFinder3 TF = new TrackFinder3(params,false); - TimeAverage2 TA2 = new TimeAverage2(params,false); - //TrackDisentangler TD = new TrackDisentangler(params,true); - TrackHitReco3 TR3 = new TrackHitReco3(hits,params,false); - RecoBankWriter2 writer = new RecoBankWriter2(); - DataBank recoBank = writer.fillRTPCHitsBank(event, params); - event.appendBanks(recoBank); - } - - } - else - { - return true; - } - - /* - for(Hit h : hits) { - System.out.println("Hit "+h.get_Id()+" CellID "+h.get_cellID()+" ADC "+h.get_ADC()+" true Edep "+h.get_EdepTrue()+" Edep "+h.get_Edep()+" Time "+h.get_Time()+" "+ - " true X "+h.get_PosXTrue()+" X "+h.get_PosX()+" true Y "+h.get_PosYTrue()+" Y "+h.get_PosY()+" true Z "+h.get_PosZTrue()+" Z "+h.get_PosZ()); - }*/ - - - - - return true; - } - - public static void main(String[] args){ - double starttime = System.nanoTime(); - //String inputFile = "/Users/davidpayette/Desktop/5c.2.3/clara/installation/plugins/clas12/2_72_516.hipo"; - //String inputFile = "/Users/davidpayette/Desktop/5c.2.3/clara/installation/plugins/clas12/1000_1_711.hipo"; - //String inputFile = "/Users/davidpayette/Desktop/5c.2.3/clara/installation/plugins/clas12/100_20_731.hipo"; - //String inputFile = "/Users/davidpayette/Desktop/5c.3.5/clara/installation/plugins/clas12/test.hipo"; - //String inputFile = "/Users/davidpayette/Desktop/5b.7.4/myClara/1212.hipo"; - //String inputFile = "/Users/davidpayette/Desktop/5b.7.4/myClara/plugins/clas12/Jantest.hipo"; - String inputFile = "/Users/davidpayette/Desktop/5b.7.4/myClara/plugins/clas12/newfeb.hipo"; - //String inputFile = "/Users/davidpayette/Desktop/Distribution/clas12-offline-software/1212again.hipo"; - //String inputFile = "/Users/davidpayette/Desktop/5c.2.3/clara/installation/plugins/clas12/100_20_802.hipo"; - //String inputFile = "/Users/davidpayette/Desktop/5c.2.3/clara/installation/plugins/clas12/10p.hipo"; - //String inputFile = args[0]; - String outputFile = "/Users/davidpayette/Desktop/5b.7.4/myClara/tout_working.hipo"; - - System.err.println(" \n[PROCESSING FILE] : " + inputFile); - - RTPCEngine en = new RTPCEngine(); - en.init(); - - - - HipoDataSource reader = new HipoDataSource(); - HipoDataSync writer = new HipoDataSync(); - reader.open(inputFile); - writer.open(outputFile); - System.out.println("starting " + starttime); - - File f1= new File("/Users/davidpayette/Documents/FileOutput/PulseShapeAll.txt"); - File f2= new File("/Users/davidpayette/Documents/FileOutput/PulseShapeMax.txt"); - File f3= new File("/Users/davidpayette/Documents/FileOutput/PulseShapeAllOverMax.txt"); - f1.delete(); - f2.delete(); - f3.delete(); - - while(reader.hasEvent()){ - - DataEvent event = reader.getNextEvent(); - en.processDataEvent(event); - writer.writeEvent(event); - } - writer.close(); - System.out.println("finished " + (System.nanoTime() - starttime)*Math.pow(10,-9)); - } + + public RTPCEngine() { + super("RTPC","charlesg","3.0"); + } + + @Override + public boolean init() { + // TODO Auto-generated method stub + return true; + } + + @Override + public boolean processDataEvent(DataEvent event) { + HitParameters params = new HitParameters(); + HitReader hitRead = new HitReader(); + hitRead.fetch_RTPCHits(event); + + List hits = new ArrayList(); + //I) get the hits + hits = hitRead.get_RTPCHits(); + + //II) process the hits + //1) exit if hit list is empty + if(hits==null || hits.size()==0) { + return true; + } + + if(event.hasBank("RTPC::pos")){ + PadHit p = new PadHit(hits,params); + PadFit pfit = new PadFit(params); + TrackFinder3 TF = new TrackFinder3(params,false); + TimeAverage2 TA2 = new TimeAverage2(params,false); + //TrackDisentangler TD = new TrackDisentangler(params,true); + TrackHitReco3 TR3 = new TrackHitReco3(hits,params,false); + //HelixFitTest hft = new HelixFitTest(hits,params); + RecoBankWriter2 writer = new RecoBankWriter2(); + DataBank recoBank = writer.fillRTPCHitsBank(event, params); + event.appendBanks(recoBank); + } + else{ + return true; + } + + /* + for(Hit h : hits) { + System.out.println("Hit "+h.get_Id()+" CellID "+h.get_cellID()+" ADC "+h.get_ADC()+" true Edep "+h.get_EdepTrue()+" Edep "+h.get_Edep()+" Time "+h.get_Time()+" "+ + " true X "+h.get_PosXTrue()+" X "+h.get_PosX()+" true Y "+h.get_PosYTrue()+" Y "+h.get_PosY()+" true Z "+h.get_PosZTrue()+" Z "+h.get_PosZ()); + }*/ + + + + + return true; + } + + public static void main(String[] args){ + double starttime = System.nanoTime(); + //String inputFile = "/Users/davidpayette/Desktop/5c.2.3/clara/installation/plugins/clas12/2_72_516.hipo"; + //String inputFile = "/Users/davidpayette/Desktop/5c.2.3/clara/installation/plugins/clas12/1000_1_711.hipo"; + //String inputFile = "/Users/davidpayette/Desktop/5c.2.3/clara/installation/plugins/clas12/100_20_731.hipo"; + //String inputFile = "/Users/davidpayette/Desktop/5c.3.5/clara/installation/plugins/clas12/test.hipo"; + //String inputFile = "/Users/davidpayette/Desktop/5b.7.4/myClara/1212.hipo"; + //String inputFile = "/Users/davidpayette/Desktop/5b.7.4/myClara/plugins/clas12/Jantest.hipo"; + String inputFile = "/Users/davidpayette/Desktop/6b.2.0/myClara/plugins/clas12/5000_40_12Jul.hipo"; + //String inputFile = "/Users/davidpayette/Desktop/Distribution/clas12-offline-software/1212again.hipo"; + //String inputFile = "/Users/davidpayette/Desktop/5c.2.3/clara/installation/plugins/clas12/100_20_802.hipo"; + //String inputFile = "/Users/davidpayette/Desktop/5c.2.3/clara/installation/plugins/clas12/10p.hipo"; + //String inputFile = args[0]; + String outputFile = "/Users/davidpayette/Desktop/5b.7.4/myClara/tout_working.hipo"; + + System.err.println(" \n[PROCESSING FILE] : " + inputFile); + + RTPCEngine en = new RTPCEngine(); + en.init(); + + + + HipoDataSource reader = new HipoDataSource(); + HipoDataSync writer = new HipoDataSync(); + reader.open(inputFile); + writer.open(outputFile); + System.out.println("starting " + starttime); + + File f1= new File("/Users/davidpayette/Documents/FileOutput/PulseShapeAll.txt"); + File f2= new File("/Users/davidpayette/Documents/FileOutput/PulseShapeMax.txt"); + File f3= new File("/Users/davidpayette/Documents/FileOutput/PulseShapeAllOverMax.txt"); + f1.delete(); + f2.delete(); + f3.delete(); + + while(reader.hasEvent()){ + + DataEvent event = reader.getNextEvent(); + en.processDataEvent(event); + writer.writeEvent(event); + } + writer.close(); + System.out.println("finished " + (System.nanoTime() - starttime)*Math.pow(10,-9)); + } } From c546521df67ab05d87badffabf32f33dbc645c2d Mon Sep 17 00:00:00 2001 From: dcpayette Date: Wed, 14 Aug 2019 13:45:23 -0400 Subject: [PATCH 028/235] cleaning p2 --- .../main/java/org/jlab/rec/rtpc/hit/PadFit.java | 2 +- .../main/java/org/jlab/rec/rtpc/hit/Track.java | 17 ++++++++--------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/PadFit.java b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/PadFit.java index d6a9a87095..6af467b192 100644 --- a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/PadFit.java +++ b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/PadFit.java @@ -33,7 +33,7 @@ public PadFit(HitParameters params){ double max_inte=0; // maximum of the integral to help the fit double max_t=0; HashMap R_adc = params.get_R_adc(); - HashMap Adcmap = new HashMap(); + HashMap Adcmap = new HashMap<>(); List PadNum = params.get_PadNum(); List PadN = params.get_PadN(); List Pad = params.get_Pad(); diff --git a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/Track.java b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/Track.java index 2e0b62c631..37630cfcd6 100644 --- a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/Track.java +++ b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/Track.java @@ -3,13 +3,12 @@ import java.util.HashSet; import java.util.List; import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; import java.util.HashMap; public class Track { - private HashMap> _track = new HashMap>(84,1.0f); - private List _l = new ArrayList(); + private HashMap> _track = new HashMap<>(84,1.0f); + private List _l = new ArrayList<>(); //private int _padcount; private boolean _flagTrack = false; @@ -24,7 +23,7 @@ public Track(int time, int padnum) { } public void addTimeSlice(int time) { - _track.put(time, new ArrayList()); + _track.put(time, new ArrayList<>()); } public void addTimeSlice(int time, List l) { @@ -48,7 +47,7 @@ public List getTimeSlice(int time) { } public List getAllTimeSlices(){ - List l = new ArrayList(); + List l = new ArrayList<>(); for(int i : _track.keySet()) { l.add(i); } @@ -82,8 +81,8 @@ public boolean isTrackFlagged() { } public Set uniquePadList() { - List slice = new ArrayList(); - Set pads = new HashSet(); + List slice = new ArrayList<>(); + Set pads = new HashSet<>(); for(int time : _track.keySet()) { slice = getTimeSlice(time); for(int pad : slice) { @@ -96,9 +95,9 @@ public Set uniquePadList() { } public Set PadTimeList(int pad) { - Set times = new HashSet(); + Set times = new HashSet<>(); List allslices = getAllTimeSlices(); - List t = new ArrayList(); + List t = new ArrayList<>(); for(int slice : allslices) { t = getTimeSlice(slice); if(t.contains(pad)) { From e4366d0cb7c53fc9d62903036eedbeac5f143adc Mon Sep 17 00:00:00 2001 From: dcpayette Date: Sun, 18 Aug 2019 21:59:56 -0400 Subject: [PATCH 029/235] refactor and clean --- .../org/jlab/rec/rtpc/banks/HitReader.java | 18 +- .../jlab/rec/rtpc/banks/RecoBankWriter.java | 92 ++- .../jlab/rec/rtpc/banks/RecoBankWriter2.java | 91 --- .../org/jlab/rec/rtpc/hit/HelixFitTest.java | 12 +- .../org/jlab/rec/rtpc/hit/HitParameters.java | 174 +++-- .../java/org/jlab/rec/rtpc/hit/PadVector.java | 120 ++-- .../org/jlab/rec/rtpc/hit/TimeAverage.java | 83 +++ .../org/jlab/rec/rtpc/hit/TimeAverage2.java | 162 ----- .../org/jlab/rec/rtpc/hit/TrackFinder.java | 141 ++++ .../org/jlab/rec/rtpc/hit/TrackFinder3.java | 223 ------ .../org/jlab/rec/rtpc/hit/TrackHitReco.java | 137 ++++ .../org/jlab/rec/rtpc/hit/TrackHitReco3.java | 647 ------------------ .../org/jlab/service/rtpc/RTPCEngine.java | 40 +- 13 files changed, 588 insertions(+), 1352 deletions(-) delete mode 100644 reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/banks/RecoBankWriter2.java create mode 100644 reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TimeAverage.java delete mode 100644 reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TimeAverage2.java create mode 100644 reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TrackFinder.java delete mode 100644 reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TrackFinder3.java create mode 100644 reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TrackHitReco.java delete mode 100644 reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TrackHitReco3.java diff --git a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/banks/HitReader.java b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/banks/HitReader.java index 246ae66ed4..a8ac12f948 100644 --- a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/banks/HitReader.java +++ b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/banks/HitReader.java @@ -42,7 +42,7 @@ public void fetch_RTPCHits(DataEvent event) { - List hits = new ArrayList(); + List hits = new ArrayList<>(); DataBank bankDGTZ = null; if(event.hasBank("RTPC::adc")==true) @@ -59,26 +59,24 @@ public void fetch_RTPCHits(DataEvent event) { int[] hitnb = new int[rows]; int[] cellID = new int[rows]; - //int[] ADC = new int[rows]; double[] Time = new double[rows]; int[] step = new int[rows]; double[] posX = new double[rows]; double[] posY = new double[rows]; double[] posZ = new double[rows]; - //double[] phiRad = new double[rows]; double[] Edep = new double[rows]; double[] TShift = new double[rows]; for(int i = 0; i 10000) { Time[i] = 0; diff --git a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/banks/RecoBankWriter.java b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/banks/RecoBankWriter.java index aa0b849626..ab6103b05c 100644 --- a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/banks/RecoBankWriter.java +++ b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/banks/RecoBankWriter.java @@ -1,45 +1,63 @@ package org.jlab.rec.rtpc.banks; -import java.util.List; - import org.jlab.io.base.DataBank; import org.jlab.io.base.DataEvent; -import org.jlab.rec.rtpc.hit.Hit; +import org.jlab.rec.rtpc.hit.HitParameters; +import org.jlab.rec.rtpc.hit.RecoHitVector; +import java.util.List; +import java.util.HashMap; public class RecoBankWriter { - /** - * - * @param hitlist the list of hits that are of the type Hit. - * @return hits bank - * - */ - public DataBank fillRTPCHitsBank(DataEvent event, List hitlist) { - if(hitlist==null) - return null; - if(hitlist.size()==0) - return null; + /** + * + * @param hitlist the list of hits that are of the type Hit. + * @return hits bank + * + */ + public DataBank fillRTPCHitsBank(DataEvent event, HitParameters params) { + /*if(hitlist==null) + return null; + if(hitlist.size()==0) + return null;*/ + int listsize = 0; + int row = 0; + HashMap> recotrackmap = params.get_recotrackmap(); + + for(int TID : recotrackmap.keySet()) { + for(int i = 0; i < recotrackmap.get(TID).size(); i++) { + listsize++; + } + } + + DataBank bank = event.createBank("RTPC::rec", listsize); + + if (bank == null) { + System.err.println("COULD NOT CREATE A BANK!!!!!!"); + return null; + } - - DataBank bank = event.createBank("RTPC::rec", hitlist.size()); - - for(int i =0; i< hitlist.size(); i++) { - //System.out.println(hitlist.get(i).get_PosX()); - bank.setInt("id", i, hitlist.get(i).get_Id()); - bank.setInt("cellID",i, hitlist.get(i).get_cellID()); - bank.setFloat("posX",i, (float) hitlist.get(i).get_PosX()); - bank.setFloat("posY",i, (float) hitlist.get(i).get_PosY()); - bank.setFloat("posZ",i, (float) hitlist.get(i).get_PosZ()); - //bank.setDouble("Edep",i, hitlist.get(i).get_Edep()); - bank.setFloat("time", i, (float) hitlist.get(i).get_Time()); - - - } - - return bank; - - } - - - -} + for(int TID : recotrackmap.keySet()) { + for(int i = 0; i < recotrackmap.get(TID).size(); i++) { + int cellID = recotrackmap.get(TID).get(i).pad(); + double x_rec = recotrackmap.get(TID).get(i).x(); + double y_rec = recotrackmap.get(TID).get(i).y(); + double z_rec = recotrackmap.get(TID).get(i).z(); + double time = recotrackmap.get(TID).get(i).time(); + double tdiff = recotrackmap.get(TID).get(i).dt(); + + bank.setInt("TID", row, TID); + bank.setInt("cellID", row, cellID); + bank.setFloat("time", row, (float) time); + bank.setFloat("posX", row, (float) x_rec); + bank.setFloat("posY", row, (float) y_rec); + bank.setFloat("posZ", row, (float) z_rec); + bank.setFloat("tdiff", row, (float) tdiff); + + row++; + } + } + + return bank; + } +} \ No newline at end of file diff --git a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/banks/RecoBankWriter2.java b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/banks/RecoBankWriter2.java deleted file mode 100644 index 49e143f24a..0000000000 --- a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/banks/RecoBankWriter2.java +++ /dev/null @@ -1,91 +0,0 @@ -package org.jlab.rec.rtpc.banks; - -import java.util.concurrent.ConcurrentHashMap; - -import org.jlab.clas.physics.Vector3; - -//import java.util.List; - -import org.jlab.io.base.DataBank; -import org.jlab.io.base.DataEvent; -//import org.jlab.rec.rtpc.hit.Hit; -import org.jlab.rec.rtpc.hit.HitParameters; -import org.jlab.rec.rtpc.hit.HitVector; -import org.jlab.rec.rtpc.hit.RecoHitVector; -import java.util.List; -import java.util.HashMap; - -public class RecoBankWriter2 { - - /** - * - * @param hitlist the list of hits that are of the type Hit. - * @return hits bank - * - */ - public DataBank fillRTPCHitsBank(DataEvent event, HitParameters params) { - /*if(hitlist==null) - return null; - if(hitlist.size()==0) - return null;*/ - int listsize = 0; - int row = 0; - HashMap> recohitvector = params.get_recohitvector(); - - for(int TID:recohitvector.keySet()) { - for(int i = 0; i < recohitvector.get(TID).size(); i++) { - listsize++; - } - } - - DataBank bank = event.createBank("RTPC::rec", listsize); - - if (bank == null) { - System.err.println("COULD NOT CREATE A BANK!!!!!!"); - return null; - } - - for(int TID : recohitvector.keySet()) { - for(int i = 0; i < recohitvector.get(TID).size(); i++) { - int cellID = recohitvector.get(TID).get(i).pad(); - double x_rec = recohitvector.get(TID).get(i).x(); - double y_rec = recohitvector.get(TID).get(i).y(); - double z_rec = recohitvector.get(TID).get(i).z(); - double time = recohitvector.get(TID).get(i).time(); - double tdiff = recohitvector.get(TID).get(i).dt(); - - bank.setInt("TID", row, TID); - bank.setInt("cellID", row, cellID); - bank.setFloat("time", row, (float) time); - bank.setFloat("posX", row, (float) x_rec); - bank.setFloat("posY", row, (float) y_rec); - bank.setFloat("posZ", row, (float) z_rec); - bank.setFloat("tdiff", row, (float) tdiff); - - row++; - } - } - /*for(int i =0; i< listsize; i++) { - double x_rec = alltracks.get(k - double y_rec = params.get_YVec().get(i); - double z_rec = params.get_ZVec().get(i); - double time = params.get_time().get(i); - //System.out.println(params.get_time().size()); - bank.setInt("id", i, 1); - bank.setInt("cellID",i, params.get_PadNum().get(i)); - bank.setFloat("posX",i, (float) x_rec); - bank.setFloat("posY",i, (float) y_rec); - bank.setFloat("posZ",i, (float) z_rec); - //bank.setDouble("Edep",i, hitlist.get(i).get_Edep()); - bank.setFloat("time", i, (float) time); - - - }*/ - - return bank; - - } - - - -} \ No newline at end of file diff --git a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/HelixFitTest.java b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/HelixFitTest.java index a669ea439c..211005c7d5 100644 --- a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/HelixFitTest.java +++ b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/HelixFitTest.java @@ -18,16 +18,16 @@ */ public class HelixFitTest { public HelixFitTest(List rawHits, HitParameters params){ - HashMap> recohitvector = params.get_recohitvector(); + HashMap> recotrackmap = params.get_recotrackmap(); double szpos[][] = new double[1000][3]; int hit = 0; - for(int TID : recohitvector.keySet()){ - for(hit = 0; hit < recohitvector.get(TID).size(); hit++){ - szpos[hit][0] = recohitvector.get(TID).get(hit).x(); - szpos[hit][1] = recohitvector.get(TID).get(hit).y(); - szpos[hit][2] = recohitvector.get(TID).get(hit).z(); + for(int TID : recotrackmap.keySet()){ + for(hit = 0; hit < recotrackmap.get(TID).size(); hit++){ + szpos[hit][0] = recotrackmap.get(TID).get(hit).x(); + szpos[hit][1] = recotrackmap.get(TID).get(hit).y(); + szpos[hit][2] = recotrackmap.get(TID).get(hit).z(); } HelixFitJava h = new HelixFitJava(); HelixFitObject ho = h.HelixFit(hit,szpos,0,0,0,0,0,0,1); diff --git a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/HitParameters.java b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/HitParameters.java index b8f2b8c1d6..4fc5a91d7e 100644 --- a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/HitParameters.java +++ b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/HitParameters.java @@ -3,98 +3,94 @@ import java.util.List; import java.util.ArrayList; import java.util.HashMap; -import java.util.concurrent.ConcurrentHashMap; - -import org.jlab.clas.physics.LorentzVector; -import org.jlab.clas.physics.Vector3; public class HitParameters { - - private int _StepSize = 10; - private int _BinSize = 40; - private int _NBinKept = 3; - private int _TrigWindSize = 10000; - private int _eventnum = 0; - private HashMap _R_adc = new HashMap<>(); - private HashMap> _TimeMap = new HashMap<>(); - private HashMap> _FinalTIDMap = new HashMap<>(); - private List _PadN = new ArrayList<>(); // used to read only cell with signal, one entry for each hit - private List _PadNum = new ArrayList<>();// used to read only cell with signal, one entry for each cell - private List _Pad = new ArrayList<>(); - private List _ADC = new ArrayList<>(); - private List _Time_o = new ArrayList<>(); - private List _weightave = new ArrayList<>(); - private List _maxinte = new ArrayList<>(); - private List _time = new ArrayList<>(); - private List _XVec = new ArrayList<>(); - private List _YVec = new ArrayList<>(); - private List _ZVec = new ArrayList<>(); - private HashMap>> _TIDMap = new HashMap<>(); - private HashMap>> _strkTIDMap = new HashMap<>(); - private HashMap> _alltracks = new HashMap<>(); - private HashMap _largetmap = new HashMap<>(); - private HashMap> _recohitvector = new HashMap<>(); - private HashMap _padmap = new HashMap<>(); - private TrackMap _trackmap = new TrackMap(); - private ReducedTrackMap _rtrackmap = new ReducedTrackMap(); - - public int get_StepSize(){return _StepSize;} // step size of the signal before integration (arbitrary value) - public int get_BinSize(){return _BinSize;} // electronics integrates the signal over 40 ns - public int get_NBinKept(){return _NBinKept;} // only 1 bin over 3 is kept by the daq - public int get_TrigWindSize(){return _TrigWindSize;} // Trigger window should be 10 micro - public HashMap get_R_adc(){return _R_adc;} - public HashMap> get_TimeMap(){return _TimeMap;} - public List get_PadN(){return _PadN;} - public List get_PadNum(){return _PadNum;} - public List get_Pad(){return _Pad;} - public List get_ADC(){return _ADC;} - public List get_Time_o(){return _Time_o;} - public int get_eventnum(){return _eventnum;} - public List get_weightave() {return _weightave;} - public List get_maxinte() {return _maxinte;} - public List get_time() {return _time;} - public List get_XVec() {return _XVec;} - public List get_YVec() {return _YVec;} - public List get_ZVec() {return _ZVec;} - public HashMap>> get_TIDMap() {return _TIDMap;} - public HashMap>> get_strkTIDMap() {return _strkTIDMap;} - public HashMap> get_FinalTIDMap() {return _FinalTIDMap;} - public HashMap> get_alltracks() {return _alltracks;} - public HashMap get_largetmap() {return _largetmap;} - public HashMap> get_recohitvector() {return _recohitvector;} - public TrackMap get_trackmap() {return _trackmap;} - public ReducedTrackMap get_rtrackmap() {return _rtrackmap;} - public PadVector get_padvector(int pad) { - if(!_padmap.containsKey(pad)) { - _padmap.put(pad, new PadVector(pad)); - } - return _padmap.get(pad); + + final private int _StepSize = 10; + final private int _BinSize = 40; + final private int _NBinKept = 3; + final private int _TrigWindSize = 10000; + private int _eventnum = 0; + private HashMap _R_adc = new HashMap<>(); + private HashMap> _TimeMap = new HashMap<>(); + private HashMap> _FinalTIDMap = new HashMap<>(); + private List _PadN = new ArrayList<>(); // used to read only cell with signal, one entry for each hit + private List _PadNum = new ArrayList<>();// used to read only cell with signal, one entry for each cell + private List _Pad = new ArrayList<>(); + private List _ADC = new ArrayList<>(); + private List _Time_o = new ArrayList<>(); + private List _weightave = new ArrayList<>(); + private List _maxinte = new ArrayList<>(); + private List _time = new ArrayList<>(); + private List _XVec = new ArrayList<>(); + private List _YVec = new ArrayList<>(); + private List _ZVec = new ArrayList<>(); + private HashMap>> _TIDMap = new HashMap<>(); + private HashMap>> _strkTIDMap = new HashMap<>(); + private HashMap> _alltracks = new HashMap<>(); + private HashMap _largetmap = new HashMap<>(); + private HashMap> _recotrackmap = new HashMap<>(); + private HashMap _padmap = new HashMap<>(); + private TrackMap _trackmap = new TrackMap(); + private ReducedTrackMap _rtrackmap = new ReducedTrackMap(); + + public int get_StepSize(){return _StepSize;} // step size of the signal before integration (arbitrary value) + public int get_BinSize(){return _BinSize;} // electronics integrates the signal over 40 ns + public int get_NBinKept(){return _NBinKept;} // only 1 bin over 3 is kept by the daq + public int get_TrigWindSize(){return _TrigWindSize;} // Trigger window should be 10 micro + public HashMap get_R_adc(){return _R_adc;} + public HashMap> get_TimeMap(){return _TimeMap;} + public List get_PadN(){return _PadN;} + public List get_PadNum(){return _PadNum;} + public List get_Pad(){return _Pad;} + public List get_ADC(){return _ADC;} + public List get_Time_o(){return _Time_o;} + public int get_eventnum(){return _eventnum;} + public List get_weightave() {return _weightave;} + public List get_maxinte() {return _maxinte;} + public List get_time() {return _time;} + public List get_XVec() {return _XVec;} + public List get_YVec() {return _YVec;} + public List get_ZVec() {return _ZVec;} + public HashMap>> get_TIDMap() {return _TIDMap;} + public HashMap>> get_strkTIDMap() {return _strkTIDMap;} + public HashMap> get_FinalTIDMap() {return _FinalTIDMap;} + public HashMap> get_alltracks() {return _alltracks;} + public HashMap get_largetmap() {return _largetmap;} + public HashMap> get_recotrackmap() {return _recotrackmap;} + public TrackMap get_trackmap() {return _trackmap;} + public ReducedTrackMap get_rtrackmap() {return _rtrackmap;} + public PadVector get_padvector(int pad) { + if(!_padmap.containsKey(pad)) { + _padmap.put(pad, new PadVector(pad)); } - - - public void set_R_adc(HashMap _R_adc){this._R_adc = _R_adc;} - public void set_TimeMap(HashMap> _TimeMap){this._TimeMap = _TimeMap;} - public void set_PadN(List _PadN){this._PadN = _PadN;} - public void set_PadNum(List _PadNum){this._PadNum = _PadNum;} - public void set_Pad(List _Pad){this._Pad = _Pad;} - public void set_ADC(List _ADC){this._ADC = _ADC;} - public void set_Time_o(List _Time_o){this._Time_o = _Time_o;} - public void set_eventnum(int _eventnum){this._eventnum = _eventnum;} - public void set_weightave(List _weightave) {this._weightave = _weightave;} - public void set_maxinte(List _maxinte) {this._maxinte = _maxinte;} - public void set_time(List _time) {this._time = _time;} - public void set_XVec(List _XVec) {this._XVec = _XVec;} - public void set_YVec(List _YVec) {this._YVec = _YVec;} - public void set_ZVec(List _ZVec) {this._ZVec = _ZVec;} - public void set_TIDMap(HashMap>> _TIDMap) {this._TIDMap = _TIDMap;} - public void set_strkTIDMap(HashMap>> _strkTIDMap) {this._strkTIDMap = _strkTIDMap;} - public void set_FinalTimeMap(HashMap> _finalTIDMap){this._FinalTIDMap = _finalTIDMap;} - public void set_alltracks(HashMap> _alltracks) {this._alltracks = _alltracks;} - public void set_largetmap(HashMap _largetmap) {this._largetmap = _largetmap;} - public void set_recohitvector(HashMap> _recohitvector) {this._recohitvector = _recohitvector;} - public void set_trackmap(TrackMap _trackmap) {this._trackmap = _trackmap;} - public void set_rtrackmap(ReducedTrackMap _rtrackmap) {this._rtrackmap = _rtrackmap;} + return _padmap.get(pad); + } + + + public void set_R_adc(HashMap _R_adc){this._R_adc = _R_adc;} + public void set_TimeMap(HashMap> _TimeMap){this._TimeMap = _TimeMap;} + public void set_PadN(List _PadN){this._PadN = _PadN;} + public void set_PadNum(List _PadNum){this._PadNum = _PadNum;} + public void set_Pad(List _Pad){this._Pad = _Pad;} + public void set_ADC(List _ADC){this._ADC = _ADC;} + public void set_Time_o(List _Time_o){this._Time_o = _Time_o;} + public void set_eventnum(int _eventnum){this._eventnum = _eventnum;} + public void set_weightave(List _weightave) {this._weightave = _weightave;} + public void set_maxinte(List _maxinte) {this._maxinte = _maxinte;} + public void set_time(List _time) {this._time = _time;} + public void set_XVec(List _XVec) {this._XVec = _XVec;} + public void set_YVec(List _YVec) {this._YVec = _YVec;} + public void set_ZVec(List _ZVec) {this._ZVec = _ZVec;} + public void set_TIDMap(HashMap>> _TIDMap) {this._TIDMap = _TIDMap;} + public void set_strkTIDMap(HashMap>> _strkTIDMap) {this._strkTIDMap = _strkTIDMap;} + public void set_FinalTimeMap(HashMap> _finalTIDMap){this._FinalTIDMap = _finalTIDMap;} + public void set_alltracks(HashMap> _alltracks) {this._alltracks = _alltracks;} + public void set_largetmap(HashMap _largetmap) {this._largetmap = _largetmap;} + public void set_recotrackmap(HashMap> _recotrackmap) {this._recotrackmap = _recotrackmap;} + public void set_trackmap(TrackMap _trackmap) {this._trackmap = _trackmap;} + public void set_rtrackmap(ReducedTrackMap _rtrackmap) {this._rtrackmap = _rtrackmap;} - public HitParameters() {} + public HitParameters() {} } \ No newline at end of file diff --git a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/PadVector.java b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/PadVector.java index 7beab13872..1d0298f42d 100644 --- a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/PadVector.java +++ b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/PadVector.java @@ -2,79 +2,77 @@ public class PadVector { - private double _x; - private double _y; - private double _z; - private double _phi; - private double PAD_W = 2.79; // in mm - private double PAD_S = 80.0; //in mm - private double PAD_L = 4.0; // in mm - private double RTPC_L= 384.0; // in mm - private double phi_pad; - private double Num_of_Cols = RTPC_L/PAD_L; - private double PI=Math.PI; - private double z0 = -(RTPC_L/2.0); - private double phi_per_pad = PAD_W/PAD_S; // in rad - private double chan; - private double col; - private double row; - private double z_shift; - private double z_pad; + private double _x; + private double _y; + private double _z; + private double _phi; + private double PAD_W = 2.79; // in mm + private double PAD_S = 80.0; //in mm + private double PAD_L = 4.0; // in mm + private double RTPC_L= 384.0; // in mm + private double phi_pad; + private double Num_of_Cols = RTPC_L/PAD_L; + private double PI=Math.PI; + private double z0 = -(RTPC_L/2.0); + private double phi_per_pad = PAD_W/PAD_S; // in rad + private double chan; + private double col; + private double row; + private double z_shift; + private double z_pad; - public PadVector(int padnum){ - chan = (double)padnum; + public PadVector(int padnum){ + chan = (double)padnum; col = chan%Num_of_Cols; row=(chan-col)/Num_of_Cols; z_shift = row%4; - + phi_pad=(row*phi_per_pad)+(phi_per_pad/2.0); - - if(phi_pad>= 2.0*PI) - { - phi_pad -= 2.0*PI; + + if(phi_pad>= 2.0*PI) { + phi_pad -= 2.0*PI; } - if(phi_pad<0) - { - phi_pad += 2.0*PI; - } - + if(phi_pad<0){ + phi_pad += 2.0*PI; + } + z_pad=z0+(col*PAD_L)+(PAD_L/2.0)+z_shift; set_x(PAD_S*Math.cos(phi_pad)); set_y(PAD_S*Math.sin(phi_pad)); set_z(z_pad); set_phi(phi_pad); - } + } - private void set_x(double x){ - _x = x; - } - - private void set_y(double y){ - _y = y; - } - - private void set_z(double z){ - _z = z; - } - - private void set_phi(double phi){ - _phi = phi; - } + private void set_x(double x){ + _x = x; + } - public double x(){ - return _x; - } - - public double y(){ - return _y; - } - - public double z(){ - return _z; - } - - public double phi(){ - return _phi; - } + private void set_y(double y){ + _y = y; + } + + private void set_z(double z){ + _z = z; + } + + private void set_phi(double phi){ + _phi = phi; + } + + public double x(){ + return _x; + } + + public double y(){ + return _y; + } + + public double z(){ + return _z; + } + + public double phi(){ + return _phi; + } } diff --git a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TimeAverage.java b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TimeAverage.java new file mode 100644 index 0000000000..2f36f63824 --- /dev/null +++ b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TimeAverage.java @@ -0,0 +1,83 @@ +//Author: David Payette + +/* This code takes the tracks from the Track Finder, and reduces the signals in the track to single + * values in time by taking a weighted average of the signal using the ADC value as the weight + * The end result is the same tracks but with hits which now have non-discritized times (not in + * 120 ns slices) This is useful for the disentangler to split merged tracks + */ + +package org.jlab.rec.rtpc.hit; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +public class TimeAverage { + + private ReducedTrackMap RTIDMap = new ReducedTrackMap(); + private ReducedTrack rtrack; + private TrackMap TIDMap; + private HashMap ADCMap; + private List tids; + private Track track; + private double adc = 0; + private double adcmax = 0; + private double averagetime = 0; + private double adcthresh = 0; + private double sumnum = 0; + private double sumden = 0; + + public TimeAverage(HitParameters params) { + /* + *Initializations + */ + TIDMap = params.get_trackmap(); + ADCMap = params.get_R_adc(); + tids = TIDMap.getAllTrackIDs(); + + /* + * Main Algorithm + */ + + for(int tid : tids) { //Loop over all tracks + track = TIDMap.getTrack(tid); + boolean trackflag = track.isTrackFlagged(); + rtrack = new ReducedTrack(); + if(trackflag) {rtrack.flagTrack();} + Set l = track.uniquePadList(); + Set timesbypad = new HashSet<>(); + for(int pad : l) { + adcmax = 0; + sumnum = 0; + sumden = 0; + timesbypad = track.PadTimeList(pad); + for(int time : timesbypad) { //Loop to calculate maximum adc value + adc = ADCMap.get(pad)[time]; + if(adc > adcmax) { + adcmax = adc; + } + } + adcthresh = adcmax/2; + for(int time : timesbypad) { //Loop to calculate weighted average time using ADC values which are above half of the maximum + adc = ADCMap.get(pad)[time]; + if(adc > adcthresh) { + sumnum += adc*time; + sumden += adc; + } + } + averagetime = sumnum/sumden; + PadVector p = params.get_padvector(pad); + HitVector v = new HitVector(pad,p.z(),p.phi(),averagetime,sumden); + rtrack.addHit(v); + } + RTIDMap.addTrack(rtrack); + } + + /* + * Output + */ + + params.set_rtrackmap(RTIDMap); + } +} diff --git a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TimeAverage2.java b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TimeAverage2.java deleted file mode 100644 index ed469d54df..0000000000 --- a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TimeAverage2.java +++ /dev/null @@ -1,162 +0,0 @@ -//Author: David Payette - -/* This code takes the tracks from the Track Finder, and reduces the signals in the track to single - * values in time by taking a weighted average of the signal using the ADC value as the weight - * The end result is the same tracks but with hits which now have non-discritized times (not in - * 120 ns slices) This is useful for the disentangler to split merged tracks - */ - -package org.jlab.rec.rtpc.hit; - -import java.util.HashMap; -import java.util.concurrent.ConcurrentHashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import javax.swing.JFrame; - -import org.jlab.groot.data.GraphErrors; -import org.jlab.groot.graphics.EmbeddedCanvas; - -public class TimeAverage2 { - - private ReducedTrackMap RTIDMap = new ReducedTrackMap(); - private ReducedTrack rtrack; - private TrackMap TIDMap;// = params.get_trackmap(); - private HashMap ADCMap;// = params.get_R_adc(); - private List tids;// = TIDMap.getAllTrackIDs(); - private Track track; - private double adc = 0; - private double adcmax = 0; - private double averagetime = 0; - private double adcthresh = 0; - private double sumnum = 0; - private double sumden = 0; - - public TimeAverage2(HitParameters params, boolean draw) { - /* - *Initializations - */ - TIDMap = params.get_trackmap(); - ADCMap = params.get_R_adc(); - tids = TIDMap.getAllTrackIDs(); - - /* - * Main Algorithm - */ - - for(int tid : tids) { - track = TIDMap.getTrack(tid); - boolean trackflag = track.isTrackFlagged(); - rtrack = new ReducedTrack(); - if(trackflag) {rtrack.flagTrack();} - Set l = track.uniquePadList(); - Set timesbypad = new HashSet(); - for(int pad : l) { - adcmax = 0; - sumnum = 0; - sumden = 0; - timesbypad = track.PadTimeList(pad); - for(int time : timesbypad) { //Loop to calculate maximum adc value - adc = ADCMap.get(pad)[time]; - if(adc > adcmax) { - adcmax = adc; - } - } - adcthresh = adcmax/2; - for(int time : timesbypad) { //Loop to calculate weighted average time using ADC values which are above half of the maximum - adc = ADCMap.get(pad)[time]; - if(adc > adcthresh) { - sumnum += adc*time; - sumden += adc; - } - } - averagetime = sumnum/sumden; - PadVector p = params.get_padvector(pad); - HitVector v = new HitVector(pad,p.z(),p.phi(),averagetime,sumden); - rtrack.addHit(v); - } - RTIDMap.addTrack(rtrack); - } - - /* - * Output - */ - - params.set_rtrackmap(RTIDMap); - - /* - * Drawing for debugging - */ - - if(draw) { - - HashMap gmapzvsphi = new HashMap(); - EmbeddedCanvas cZvsPhi = new EmbeddedCanvas(); - JFrame jZvsPhi = new JFrame(); - jZvsPhi.setSize(800,800); - - HashMap gmapphivst = new HashMap(); - EmbeddedCanvas cPhivsT = new EmbeddedCanvas(); - JFrame jPhivsT = new JFrame(); - jPhivsT.setSize(800,800); - - HashMap gmapzvst = new HashMap(); - EmbeddedCanvas cZvsT = new EmbeddedCanvas(); - JFrame jZvsT = new JFrame(); - jZvsT.setSize(800,800); - int color = 1; - int style = 1; - for(int tid : RTIDMap.getAllTrackIDs()) { - ReducedTrack t = RTIDMap.getTrack(tid); - gmapzvsphi.put(tid, new GraphErrors()); - gmapphivst.put(tid, new GraphErrors()); - gmapzvst.put(tid, new GraphErrors()); - for(HitVector v : t.getAllHits()) { - double time = v.time(); - gmapzvsphi.get(tid).addPoint(v.phi(), v.z(), 0, 0); - gmapzvst.get(tid).addPoint(time, v.z(), 0, 0); - gmapphivst.get(tid).addPoint(time, v.phi(), 0, 0); - } - gmapzvsphi.get(tid).setMarkerColor(color); - gmapzvsphi.get(tid).setMarkerSize(3); - gmapzvsphi.get(tid).setMarkerStyle(style); - - gmapzvst.get(tid).setMarkerColor(color); - gmapzvst.get(tid).setMarkerSize(3); - gmapzvst.get(tid).setMarkerStyle(style); - - gmapphivst.get(tid).setMarkerColor(color); - gmapphivst.get(tid).setMarkerSize(3); - gmapphivst.get(tid).setMarkerStyle(style); - - cZvsPhi.draw(gmapzvsphi.get(tid),"same"); - cZvsT.draw(gmapzvst.get(tid),"same"); - cPhivsT.draw(gmapphivst.get(tid),"same"); - - color++; - if(color > 8) { - color = 1; - style++; - } - - } - - jZvsPhi.setTitle("Time Average Output"); - jZvsPhi.add(cZvsPhi); - jZvsPhi.setVisible(true); - - jZvsT.setTitle("Time Average Output"); - jZvsT.add(cZvsT); - //jZvsT.setVisible(true); - - jPhivsT.setTitle("Time Average Output"); - jPhivsT.add(cPhivsT); - //jPhivsT.setVisible(true); - - } - - } - -} diff --git a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TrackFinder.java b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TrackFinder.java new file mode 100644 index 0000000000..49bb25bee3 --- /dev/null +++ b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TrackFinder.java @@ -0,0 +1,141 @@ +//Author: David Payette + +/* This code sorts pad signals which have been integrated into 120 ns time slices into tracks + * based on their relative positions in space, and how close in time the signals occur + */ + +package org.jlab.rec.rtpc.hit; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +public class TrackFinder { + + private TrackUtils tutil = new TrackUtils(); + private TrackMap TIDMap = new TrackMap(); + private List TIDList; + private Track track; + private HashMap ADCMap; + private List PadNum; + private int TrigWindSize; + private int StepSize = 120;//Bin Size of Dream Electronics Output + private double adcthresh = 5e-4; + private int padloopsize;// = PadNum.size(); + private boolean padSorted = false; + private List padTIDlist = new ArrayList<>(); + private List padlist; + private int pad = 0; + private double adc = 0; + private int timeadjlimit = 4; + private int parenttid = -1; + private String method = "phiz"; + private int minhitcount = 5; + + public TrackFinder(HitParameters params) { + /* + *Initializations + */ + + ADCMap = params.get_R_adc(); + PadNum = params.get_PadNum(); + TrigWindSize = params.get_TrigWindSize(); + padloopsize = PadNum.size(); + /* + * Main Algorithm + */ + TIMELOOP: //Loop over all times + for(int time = 0; time < TrigWindSize; time += StepSize) { //Steps of 120 up to TrigWindSize = 10000 + + PADLOOP: //Loop over all pads + for(int padindex = 0; padindex < padloopsize; padindex++) { + padSorted = false; //Flag to be set when the pad is assigned to a track + padTIDlist.clear(); //List of all TIDs assigned to the pad starts empty + pad = PadNum.get(padindex); + adc = ADCMap.get(pad)[time]; + + if(adc > adcthresh) { //pad adc threshold check + PadVector PadVec = params.get_padvector(pad); //initializes the x,y,z,phi for pad + TIDList = TIDMap.getAllTrackIDs(); //Retrieve list of all available TIDs + + TIDLOOP: //Loop over all Track IDs + for(int tid : TIDList) { + track = TIDMap.getTrack(tid); //Get track with current tid + + TIMECHECKLOOP: //Loop over current and former times + for(int timecheck = time; timecheck > 0 && timecheck >= time - timeadjlimit*StepSize; timecheck -= StepSize) { + padlist = track.getTimeSlice(timecheck); //Get pads assigned to current time slice + if(!padlist.contains(pad)) { //Ensures pad isn't already assigned here + PADCHECKLOOP: //Loop over pads + for(int checkpad : padlist) { + PadVector checkpadvec = params.get_padvector(checkpad); + if(tutil.comparePads(PadVec, checkpadvec, method)) { //compares the position of two pads + track.addPad(time, pad); //assign pad to track + padSorted = true; //flag set + padTIDlist.add(tid); //track the TID assigned + break TIMECHECKLOOP; //no need to continue checking previous times + } //END PAD COMPARE + + } //END PADCHECKLOOP + + } else {//pad is somehow in this time slice already so lets go ahead and add it to the current time slice + track.addPad(time, pad); + padSorted = true; + padTIDlist.add(tid); + break TIMECHECKLOOP; + } + + } //END TIMECHECKLOOP + + } //END TIDLOOP + + if(!padSorted) { //we need a new TID if we get here, the pad was never assigned an ID + TIDMap.addTrack(new Track(time,pad)); + } + + if(padTIDlist.size()>1) { //if a pad gets more than 1 ID let's merge the IDs + for(int tidtemp : padTIDlist) { + if(tidtemp == padTIDlist.get(0)) { + parenttid = padTIDlist.get(0); + } else { + TIDMap.mergeTracks(parenttid, tidtemp); + } + } + } + + } //END ADC THRESH CHECK + + } //END PADLOOP + + } //END TIMELOOP + + //END MAIN ALGORITHM + + /* + * Clean up and flag tracks + */ + + for(int tid : TIDMap.getAllTrackIDs()) { //We need to remove tracks with not enough pads to save time later + Track tempt = TIDMap.getTrack(tid); + if(tempt.uniquePadCountTotal() < minhitcount) { + TIDMap.removeTrack(tid); + } + } + + //System.out.println("This event has " + TIDMap.getAllTrackIDs().size() + " tracks"); + + //TODO Flag crossing tracks; for now flag all tracks + for(int tid : TIDMap.getAllTrackIDs()) { + Track t = TIDMap.getTrack(tid); + t.flagTrack(); + } + + /* + * Output + */ + + params.set_trackmap(TIDMap); + + } + +} diff --git a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TrackFinder3.java b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TrackFinder3.java deleted file mode 100644 index 750dd462ce..0000000000 --- a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TrackFinder3.java +++ /dev/null @@ -1,223 +0,0 @@ -//Author: David Payette - -/* This code sorts pad signals which have been integrated into 120 ns time slices into tracks - * based on their relative positions in space, and how close in time the signals occur - */ - -package org.jlab.rec.rtpc.hit; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - -import javax.swing.JFrame; - -import org.jlab.groot.data.GraphErrors; -import org.jlab.groot.graphics.EmbeddedCanvas; - -public class TrackFinder3 { - - - private TrackUtils tutil = new TrackUtils(); - private TrackMap TIDMap = new TrackMap(); - private List TIDList; - private Track track; - private HashMap ADCMap;// = params.get_R_adc(); - private List PadNum;// = params.get_PadNum(); - private int TrigWindSize;// = params.get_TrigWindSize(); - private int StepSize = 120; - private double adcthresh = 5e-4; - private int padloopsize;// = PadNum.size(); - private boolean padSorted = false; - private List padTIDlist = new ArrayList(); - private List padlist; - private int pad = 0; - private double adc = 0; - private int timeadjlimit = 4; - private int parenttid = -1; - private String method = "phiz"; - private int minhitcount = 5; - - public TrackFinder3(HitParameters params, boolean draw) { - /* - *Initializations - */ - - ADCMap = params.get_R_adc(); - PadNum = params.get_PadNum(); - TrigWindSize = params.get_TrigWindSize(); - padloopsize = PadNum.size(); - /* - * Main Algorithm - */ - TIMELOOP: //Loop over all times - for(int time = 0; time < TrigWindSize; time += StepSize) { //Steps of 120 up to TrigWindSize = 10000 - - PADLOOP: //Loop over all pads - for(int padindex = 0; padindex < padloopsize; padindex++) { - padSorted = false; //Flag to be set when the pad is assigned to a track - padTIDlist.clear(); //List of all TIDs assigned to the pad starts empty - pad = PadNum.get(padindex); - adc = ADCMap.get(pad)[time]; - - if(adc > adcthresh) { //pad adc threshold check - PadVector PadVec = params.get_padvector(pad); //initializes the x,y,z,phi for pad - TIDList = TIDMap.getAllTrackIDs(); //Retrieve list of all available TIDs - - TIDLOOP: //Loop over all Track IDs - for(int tid : TIDList) { - track = TIDMap.getTrack(tid); //Get track with current tid - - TIMECHECKLOOP: //Loop over current and former times - for(int timecheck = time; timecheck > 0 && timecheck >= time - timeadjlimit*StepSize; timecheck -= StepSize) { - padlist = track.getTimeSlice(timecheck); //Get pads assigned to current time slice - if(!padlist.contains(pad)) { //Ensures pad isn't already assigned here - PADCHECKLOOP: //Loop over pads - for(int checkpad : padlist) { - PadVector checkpadvec = params.get_padvector(checkpad); - if(tutil.comparePads(PadVec, checkpadvec, method)) { //compares the position of two pads - track.addPad(time, pad); //assign pad to track - //TIDMap.updateTrack(tid, track); - padSorted = true; //flag set - padTIDlist.add(tid); //track the TID assigned - break TIMECHECKLOOP; //no need to continue checking previous times - } //END PAD COMPARE - - } //END PADCHECKLOOP - - } else {//pad is somehow in this time slice already so lets go ahead and add it to the current time slice - track.addPad(time, pad); - //TIDMap.updateTrack(tid, track); - padSorted = true; - padTIDlist.add(tid); - break TIMECHECKLOOP; - } - - } //END TIMECHECKLOOP - - } //END TIDLOOP - - if(!padSorted) { //we need a new TID if we get here, the pad was never assigned an ID - TIDMap.addTrack(new Track(time,pad)); - } - - if(padTIDlist.size()>1) { //if a pad gets more than 1 ID let's merge the IDs - for(int tidtemp : padTIDlist) { - if(tidtemp == padTIDlist.get(0)) { - parenttid = padTIDlist.get(0); - } else { - TIDMap.mergeTracks(parenttid, tidtemp); - } - } - } - - } //END ADC THRESH CHECK - - } //END PADLOOP - - } //END TIMELOOP - - //END MAIN ALGORITHM - - /* - * Clean up and flag tracks - */ - - for(int tid : TIDMap.getAllTrackIDs()) { //We need to remove tracks with not enough pads to save time later - Track tempt = TIDMap.getTrack(tid); - if(tempt.uniquePadCountTotal() < minhitcount) { - TIDMap.removeTrack(tid); - } - } - - //System.out.println("This event has " + TIDMap.getAllTrackIDs().size() + " tracks"); - - //TODO Flag crossing tracks; for now flag all tracks - for(int tid : TIDMap.getAllTrackIDs()) { - Track t = TIDMap.getTrack(tid); - t.flagTrack(); - } - - /* - * Output - */ - - params.set_trackmap(TIDMap); - - /* - * Drawing for debugging - * To be removed - */ - - if(draw) { - - HashMap gmapzvsphi = new HashMap(); - EmbeddedCanvas cZvsPhi = new EmbeddedCanvas(); - JFrame jZvsPhi = new JFrame(); - jZvsPhi.setSize(800,600); - - HashMap gmapphivst = new HashMap(); - EmbeddedCanvas cPhivsT = new EmbeddedCanvas(); - JFrame jPhivsT = new JFrame(); - jPhivsT.setSize(800,600); - - HashMap gmapzvst = new HashMap(); - EmbeddedCanvas cZvsT = new EmbeddedCanvas(); - JFrame jZvsT = new JFrame(); - jZvsT.setSize(800,600); - int color = 1; - int style = 1; - for(int tid : TIDMap.getAllTrackIDs()) { - Track t = TIDMap.getTrack(tid); - gmapzvsphi.put(tid, new GraphErrors()); - gmapphivst.put(tid, new GraphErrors()); - gmapzvst.put(tid, new GraphErrors()); - for(int time : t.getAllTimeSlices()) { - for(int padref : t.getTimeSlice(time)) { - PadVector p = params.get_padvector(padref); - gmapzvsphi.get(tid).addPoint(p.phi(), p.z(), 0, 0); - gmapzvst.get(tid).addPoint(time, p.z(), 0, 0); - gmapphivst.get(tid).addPoint(time, p.phi(), 0, 0); - } - } - gmapzvsphi.get(tid).setMarkerColor(color); - gmapzvsphi.get(tid).setMarkerSize(3); - gmapzvsphi.get(tid).setMarkerStyle(style); - - gmapzvst.get(tid).setMarkerColor(color); - gmapzvst.get(tid).setMarkerSize(3); - gmapzvst.get(tid).setMarkerStyle(style); - - gmapphivst.get(tid).setMarkerColor(color); - gmapphivst.get(tid).setMarkerSize(3); - gmapphivst.get(tid).setMarkerStyle(style); - - cZvsPhi.draw(gmapzvsphi.get(tid),"same"); - cZvsT.draw(gmapzvst.get(tid),"same"); - cPhivsT.draw(gmapphivst.get(tid),"same"); - - color++; - if(color > 8) { - color = 1; - style++; - } - - } - - jZvsPhi.setTitle("Track Finder Output"); - jZvsPhi.add(cZvsPhi); - jZvsPhi.setVisible(true); - - jZvsT.setTitle("Track Finder Output"); - jZvsT.add(cZvsT); - jZvsT.setVisible(true); - - jPhivsT.setTitle("Track Finder Output"); - jPhivsT.add(cPhivsT); - jPhivsT.setVisible(true); - - } - - } - -} diff --git a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TrackHitReco.java b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TrackHitReco.java new file mode 100644 index 0000000000..0010e7e88d --- /dev/null +++ b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TrackHitReco.java @@ -0,0 +1,137 @@ +//Author: David Payette and Nate Dzbenski + +/* This code takes the time-reduced tracks produced by the Time Average, as well as the original hits + * and uses a fit formula from garfield++ to calculate the hit's position in the drift region + * based on the time of the signal. We use the original hits to see how well the formula performs + * when we include factors such as time shifts and non-uniform magnetic fields + */ + +package org.jlab.rec.rtpc.hit; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +public class TrackHitReco { + + //MAGBOLTZ PARAMETERS DO NOT TOUCH + final private double a_t1 = -2.48491E-4; + final private double a_t2 = 2.21413E-4; + final private double a_t3 = -3.11195E-3; + final private double a_t4 = -2.75206E-1; + final private double a_t5 = 1.74281E3; + private double a_t; + + final private double b_t1 = 2.48873E-5; + final private double b_t2 = -1.19976E-4; + final private double b_t3 = -3.75962E-3; + final private double b_t4 = 5.33100E-2; + final private double b_t5 = -1.25647E2; + private double b_t; + + final private double a_phi1 = -3.32718E-8; + final private double a_phi2 = 1.92110E-7; + final private double a_phi3 = 2.16919E-6; + final private double a_phi4 = -8.10207E-5; + final private double a_phi5 = 1.68481E-1; + private double a_phi; + + final private double b_phi1 = -3.23019E-9; + final private double b_phi2 = -6.92075E-8; + final private double b_phi3 = 1.24731E-5; + final private double b_phi4 = 2.57684E-5; + final private double b_phi5 = 2.10680E-2; + private double b_phi; + + final private double t_2GEM2 = 296.082; + final private double t_2GEM3 = 296.131; + final private double t_2PAD = 399.09; + final private double t_gap = t_2GEM2 + t_2GEM3 + t_2PAD; + + final private double phi_2GEM2 = 0.0492538; + final private double phi_2GEM3 = 0.0470817; + final private double phi_2PAD = 0.0612122; + final private double phi_gap = phi_2GEM2 + phi_2GEM3 + phi_2PAD; + + + private double larget; + private double smallt; + private double tdiff; + private double Time; + private int cellID; + + private double drifttime; + private double r_rec; + private double dphi; + private double phi_rec; + private double x_rec; + private double y_rec; + + public TrackHitReco(HitParameters params) { + + HashMap tdiffmap = new HashMap<>(); + HashMap> recotrackmap = new HashMap<>(); + ReducedTrackMap RTIDMap = params.get_rtrackmap(); + List tids = RTIDMap.getAllTrackIDs(); + + for(int TID : tids) { + ReducedTrack track = RTIDMap.getTrack(TID); + smallt = track.getSmallT(); + larget = track.getLargeT(); + tdiff = 6000 - larget; + tdiffmap.put(TID, tdiff); + recotrackmap.put(TID, new ArrayList<>()); + List allhits = track.getAllHits(); + + for(HitVector hit : allhits) { + cellID = hit.pad(); + Time = hit.time(); + Time += tdiff; + + // find reconstructed position of ionization from Time info + drifttime = Time-t_gap; + r_rec = get_r_rec(hit.z(),drifttime); //in mm + dphi = get_dphi(hit.z(),r_rec); // in rad + + phi_rec=hit.phi()-dphi-phi_gap; + + if(phi_rec<0.0) { + phi_rec+=2.0*Math.PI; + } + if(phi_rec>2.0*Math.PI){ + phi_rec-=2.0*Math.PI; + } + + // x,y,z pos of reconstructed track + x_rec=r_rec*(Math.cos(phi_rec)); + y_rec=r_rec*(Math.sin(phi_rec)); + recotrackmap.get(TID).add(new RecoHitVector(cellID,x_rec,y_rec,hit.z(),tdiff,Time)); + } + } + + params.set_recotrackmap(recotrackmap); + } + + private double get_rec_coef(double t1, double t2, double t3, double t4, double t5, double z2) { + double z = z2/1000; + return t1*z*z*z*z + t2*z*z*z + t3*z*z + t4*z + t5; + } + + private double get_r_rec(double z,double t){ + a_t = get_rec_coef(a_t1,a_t2,a_t3,a_t4,a_t5,z); + b_t = get_rec_coef(b_t1,b_t2,b_t3,b_t4,b_t5,z); + return ((-(Math.sqrt(a_t*a_t+(4*b_t*t)))+a_t+(14*b_t))/(2*b_t))*10.0; + } + + private double get_dphi(double z, double r){ + a_phi = get_rec_coef(a_phi1,a_phi2,a_phi3,a_phi4,a_phi5,z); + b_phi = get_rec_coef(b_phi1,b_phi2,b_phi3,b_phi4,b_phi5,z); + return a_phi*(7-r/10)+b_phi*(7-r/10)*(7-r/10); // in rad + } + + +} + + + + diff --git a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TrackHitReco3.java b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TrackHitReco3.java deleted file mode 100644 index 0b556335cb..0000000000 --- a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TrackHitReco3.java +++ /dev/null @@ -1,647 +0,0 @@ -//Author: David Payette and Nate Dzbenski - -/* This code takes the time-reduced tracks produced by the Time Average, as well as the original hits - * and uses a fit formula from garfield++ to calculate the hit's position in the drift region - * based on the time of the signal. We use the original hits to see how well the formula performs - * when we include factors such as time shifts and non-uniform magnetic fields - */ - -package org.jlab.rec.rtpc.hit; - -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - -import javax.swing.JFrame; - -import org.jlab.clas.physics.Vector3; -import org.jlab.groot.data.GraphErrors; -import org.jlab.groot.data.H1F; -import org.jlab.groot.graphics.EmbeddedCanvas; -import org.jlab.rec.rtpc.hit.RecoHitVector; - -public class TrackHitReco3 { - - public TrackHitReco3(List rawHits, HitParameters params, boolean draw) { - /* - HashMap graphmap = new HashMap(); - HashMap graphmap2 = new HashMap(); - */ - HashMap> alltracks = params.get_alltracks(); - HashMap largetmap = params.get_largetmap(); - HashMap tdiffmap = new HashMap<>(); - HashMap> recohitvector = new HashMap<>(); - ReducedTrackMap RTIDMap = params.get_rtrackmap(); - List TimeVec = new ArrayList<>(); - List XVec = new ArrayList<>(); - List YVec = new ArrayList<>(); - List ZVec = new ArrayList<>(); - List Pads = new ArrayList<>(); - int p = 0; - - double a_t1 = -2.48491E-4; - double a_t2 = 2.21413E-4; - double a_t3 = -3.11195E-3; - double a_t4 = -2.75206E-1; - double a_t5 = 1.74281E3; - - double b_t1 = 2.48873E-5; - double b_t2 = -1.19976E-4; - double b_t3 = -3.75962E-3; - double b_t4 = 5.33100E-2; - double b_t5 = -1.25647E2; - - double a_phi1 = -3.32718E-8; - double a_phi2 = 1.92110E-7; - double a_phi3 = 2.16919E-6; - double a_phi4 = -8.10207E-5; - double a_phi5 = 1.68481E-1; - - double b_phi1 = -3.23019E-9; - double b_phi2 = -6.92075E-8; - double b_phi3 = 1.24731E-5; - double b_phi4 = 2.57684E-5; - double b_phi5 = 2.10680E-2; - if(draw){ - H1F largetdist = new H1F("largetdist",100,0,10000); - } - double timewindow = 2000; - double smalltcut = 300; - double largetcut = 8000; - int tracksizecut = 4; - double larget = 0; - double tdiff = 0; - double Time = 0; - int cellID = 0; - int outsidedriftcounter = 0; - int allhitscounter = 0; - - List tids = RTIDMap.getAllTrackIDs(); - for(int TID : tids) { - ReducedTrack t = RTIDMap.getTrack(TID); - Pads.clear(); - double smallt = t.getSmallT(); - larget = t.getLargeT(); - //largetdist.fill(larget); - if(draw){ - //graphmap.put(TID, new GraphErrors()); - //graphmap2.put(TID, new GraphErrors()); - } - tdiff = 6000 - larget; - tdiffmap.put(TID, tdiff); - recohitvector.put(TID, new ArrayList<>()); - - List allhits = t.getAllHits(); - for(HitVector hit : allhits) { - //for(int padindex = 0; padindex < TIDMap.get(TID).get(t).size(); padindex++){ - - allhitscounter++; - //int cellID = TIDMap.get(TID).get(t).get(padindex); - cellID = hit.pad(); - if(!Pads.contains(cellID)) { - Pads.add(cellID); - } - //double Time = weightave.get(cellID); - Time = hit.time(); - //System.out.println("reco " + Time); - //System.out.println("tdiff " + tdiff); - Time+=tdiff; - - //System.out.println(Time + " " + cellID); - - - //int NEve = 10; - - double PAD_W = 2.79; // in mm - double PAD_S = 80.0; //in mm - double PAD_L = 4.0; // in mm - double RTPC_L = 384.0; // in mm - - //double Num_of_Rows = (2.0*(Math.PI)*PAD_S)/PAD_W; - double Num_of_Cols = RTPC_L/PAD_L; - //double TotChan = Num_of_Rows*Num_of_Cols; - - double PI=Math.PI; - - double z0 = -(RTPC_L/2.0); // front of RTPC in mm at the center of the pad - - double phi_per_pad = PAD_W/PAD_S; // in rad - - - - // MagBoltz parameters - //double a_t=1741.179712, b_t=-1.25E+02; // for f(x)=time(radius) - //double a_phi=0.161689123, b_phi=0.023505021; // for f(x)=dphi(radius) - - double t_2GEM2 = 296.082; - double t_2GEM3 = 296.131; - double t_2PAD = 399.09; - double t_gap = t_2GEM2 + t_2GEM3 + t_2PAD; - - double phi_2GEM2 = 0.0492538; - double phi_2GEM3 = 0.0470817; - double phi_2PAD = 0.0612122; - double phi_gap = phi_2GEM2 + phi_2GEM3 + phi_2PAD; - - // find postition from Cell ID - //for (double s = 0.0; s < cellID.size(); s++) { - - double chan=0; - double t_s2pad = 0; - double dphi=0; - double dz=0; - double x_rec = 0; - double y_rec = 0; - - - double z_pad=0; - double z_rec=0; - double z_hit=0; // position of the hit on a single pad in z - double delta_z=0; - - double r_pos=0; - double r_rec=0; - double r_temp=0; - double delta_r=0; - - double phi_pad=0; - double phi_rec=0; - - - - // generated position of ionization in phi - - //phi_pos = Math.atan2(Y, X); - - // generated position of ionization in s - //r_pos=Math.sqrt(((X)*(X))+((Y)*(Y))); - - - // ------------------ find z and phi of pad from CellID ------------------ - chan = (double)cellID; - - double col = chan%Num_of_Cols; - double row=(chan-col)/Num_of_Cols; - double z_shift = row%4; - //double z_shift = 0.; - - phi_pad=(row*phi_per_pad)+(phi_per_pad/2.0); - if(phi_pad>= 2.0*PI) { - phi_pad -= 2.0*PI; - } - if(phi_pad<0) - { - phi_pad += 2.0*PI; - } - - z_pad=z0+(col*PAD_L)+(PAD_L/2.0)+z_shift; - // ----------------------------------------------------------------------- - dz=0; - z_rec=z_pad-dz; - - // find reconstructed position of ionization from Time info - - t_s2pad = Time-t_gap; - //if(t_s2pad > 6000) {System.out.println("oooops");} - //System.out.println("time stuff " + t_s2pad + " " + Time); - - double a_t = get_rec_coef(a_t1,a_t2,a_t3,a_t4,a_t5,z_rec); - double b_t = get_rec_coef(b_t1,b_t2,b_t3,b_t4,b_t5,z_rec); - - r_rec=((-(Math.sqrt(a_t*a_t+(4.*b_t*t_s2pad)))+a_t+(14.*b_t))/(2.*b_t))*10.0; //in mm - - double a_phi = get_rec_coef(a_phi1,a_phi2,a_phi3,a_phi4,a_phi5,z_rec); - double b_phi = get_rec_coef(b_phi1,b_phi2,b_phi3,b_phi4,b_phi5,z_rec); - - dphi=a_phi*(7.-r_rec/10.)+b_phi*(7.-r_rec/10.)*(7.-r_rec/10.); // in rad - //System.out.println("r and phi " + r_rec + " " + dphi); - - - //System.out.println("phi stuff " + phi_pad + " " + dphi + " " + phi_gap); - phi_rec=phi_pad-dphi-phi_gap; - if( phi_rec<0.0 ) - { - phi_rec+=2.0*PI; - } - if( phi_rec>2.0*PI ) - { - phi_rec-=2.0*PI; - } - if(r_rec > 70 || r_rec < 30) - { - outsidedriftcounter++; - } - // x,y,z pos of reconstructed track - x_rec=r_rec*(Math.cos(phi_rec)); - y_rec=r_rec*(Math.sin(phi_rec)); - - - recohitvector.get(TID).add(new RecoHitVector(cellID,x_rec,y_rec,z_rec,tdiff,Time)); - //if(r_rec > 30 && r_rec < 70) - //{ - if(draw){ - //graphmap.get(TID).addPoint(r_rec, z_rec, 0, 0); - //graphmap2.get(TID).addPoint(x_rec, y_rec, 0, 0); - } - - - - //System.out.println("TID time phi x y " + TID + " " + Time + " " + phi_rec + " " + x_rec + " " + y_rec); - //} - // x,y,z pos of pad hit - //x_pad=(PAD_S)*(Math.cos(phi_pad)); - //y_pad=(PAD_S)*(Math.sin(phi_pad)); - - // actual position on pad of hits - //phi_hit=phi_rad-(row*phi_per_pad); - //z_hit=Z-z0-(col*PAD_L)-z_shift; - - // find differences (delta = generated-reconstructed) - //delta_x=X-x_rec; - //delta_y=Y-y_rec; - //delta_z=Z-z_rec; - //delta_r=r_pos-r_rec; - //delta_phi = phi_pos-phi_rec; - - - - - /*hit.set_cellID(cellID); - hit.set_Time(t_s2pad); - hit.set_Edep(Edep); - hit.set_PosX(x_rec); - hit.set_PosY(y_rec); - hit.set_PosZ(z_rec); - TimeVec.add(t_s2pad); - XVec.add(x_rec); - YVec.add(y_rec); - ZVec.add(z_rec);*/ - - - - } - //System.out.println("num of pads " + Pads.size()); - } - /*GraphErrors grz = new GraphErrors(); - GraphErrors g1rz = new GraphErrors(); - GraphErrors gxy = new GraphErrors(); - GraphErrors g1xy = new GraphErrors(); - GraphErrors g2xy = new GraphErrors(); - GraphErrors gerrorxvsphi = new GraphErrors(); - GraphErrors gerroryvsphi = new GraphErrors();*/ - int counter = 1; - - /*for(Hit hit : rawHits) - { - if(true) { - cellID = hit.get_cellID(); - - Time = hit.get_Time(); - //double T_noshift = Time; - if(Time <= 0) {continue;} - Time -= hit.get_TShift(); - //System.out.println("Time " + hit.get_Time() + " " + hit.get_TShift()); - - double X = hit.get_PosXTrue(); - double Y = hit.get_PosYTrue(); - double Z = hit.get_PosZTrue(); - //double TimeNoShift = Time - hit.get_TShift(); - //if(Pads.contains(cellID)) - //{ - //ystem.out.println(Time + " " + cellID); - - - //int NEve = 10; - - double PAD_W = 2.79; // in mm - double PAD_S = 80.0; //in mm - double PAD_L = 4.0; // in mm - double RTPC_L = 384.0; // in mm - - //double Num_of_Rows = (2.0*(Math.PI)*PAD_S)/PAD_W; - double Num_of_Cols = RTPC_L/PAD_L; - //double TotChan = Num_of_Rows*Num_of_Cols; - - double PI=Math.PI; - - double z0 = -(RTPC_L/2.0); // front of RTPC in mm at the center of the pad - - double phi_per_pad = PAD_W/PAD_S; // in rad - - - - // MagBoltz parameters - //double a_t=1741.179712, b_t=-125; // for f(x)=time(radius) - //double a_phi=0.161689123, b_phi=0.023505021; // for f(x)=dphi(radius) - - double t_2GEM2 = 296.082; - double t_2GEM3 = 296.131; - double t_2PAD = 399.09; - double t_gap = t_2GEM2 + t_2GEM3 + t_2PAD; - - double phi_2GEM2 = 0.0492538; - double phi_2GEM3 = 0.0470817; - double phi_2PAD = 0.0612122; - double phi_gap = phi_2GEM2 + phi_2GEM3 + phi_2PAD; - - // find position from Cell ID - //for (double s = 0.0; s < cellID.size(); s++) { - - double chan=0; - double t_s2pad = 0; - double dphi=0; - double dz=0; - double x_rec = 0; - double y_rec = 0; - - - double z_pad=0; - double z_rec=0; - double z_hit=0; // position of the hit on a single pad in z - double delta_z=0; - - double r_pos=0; - double r_rec=0; - double r_temp=0; - double delta_r=0; - - double phi_pad=0; - double phi_rec=0; - double phi_pos = 0; - - double t_calc = 0; - - - - // generated position of ionization in phi - - phi_pos = Math.atan2(Y, X); - - // generated position of ionization in s - r_pos=Math.sqrt(((X)*(X))+((Y)*(Y))); - //System.out.println(r_pos + " " + X + " " + Y); - - - // ------------------ find z and phi of pad from CellID ------------------ - chan = (double)cellID; - - double col = chan%Num_of_Cols; - double row=(chan-col)/Num_of_Cols; - double z_shift = row%4; - //double z_shift = 0.; - //System.out.println(row + " " + chan + " " + col + " " + phi_per_pad); - phi_pad=(row*phi_per_pad)+(phi_per_pad/2.0); - while(phi_pad >= 2*PI || phi_pad < 0) - { - if(phi_pad>= 2.0*PI) { - phi_pad -= 2.0*PI; - } - if(phi_pad<0) - { - phi_pad += 2.0*PI; - } - } - z_pad=z0+(col*PAD_L)+(PAD_L/2.0)+z_shift; - // ----------------------------------------------------------------------- - dz=0; - z_rec=z_pad-dz; - - // find reconstructed position of ionization from Time info - - double a_t = get_rec_coef(a_t1,a_t2,a_t3,a_t4,a_t5,z_rec); - double b_t = get_rec_coef(b_t1,b_t2,b_t3,b_t4,b_t5,z_rec); - - - - double a_phi = get_rec_coef(a_phi1,a_phi2,a_phi3,a_phi4,a_phi5,z_rec); - double b_phi = get_rec_coef(b_phi1,b_phi2,b_phi3,b_phi4,b_phi5,z_rec); - - //System.out.println(a_t + " " + b_t + " " + a_phi + " " + b_phi + " " + z_rec); - - t_s2pad = Time-t_gap; - - r_rec = ((-(Math.sqrt(a_t*a_t+(4*b_t*t_s2pad)))+a_t+(14*b_t))/(2*b_t))*10.0; //in mm - t_calc = ((((2*b_t*r_pos*0.1)-(14*b_t)-a_t)*((2*b_t*r_pos*0.1)-14*b_t-a_t))-(a_t*a_t))*(1/(4*b_t)) + t_gap; - - - dphi=a_phi*(7-r_rec/10)+b_phi*(7-r_rec/10)*(7.-r_rec/10); // in rad - - - phi_rec=phi_pad-dphi-phi_gap; - while(phi_rec < 0 || phi_rec >= 2*PI) - { - if( phi_rec<0.0 ) - { - phi_rec+=2.0*PI; - } - if( phi_rec>2.0*PI ) - { - phi_rec-=2.0*PI; - } - } - //System.out.println("reconstructed phi " + phi_rec + " actual phi " + Math.atan(Y/X)); - - // x,y,z pos of reconstructed track - x_rec=r_rec*(Math.cos(phi_rec)); - y_rec=r_rec*(Math.sin(phi_rec)); - //System.out.println("rec " + x_rec + " " + y_rec + " " + phi_rec + " " + r_rec + " " + Time); - //if(true) - //if(counter > 2500) - //if(r_rec > 30 && r_rec < 70) - //if(Math.abs(x_rec-X) < 3 && Math.abs(y_rec-Y) < 3 && Math.abs(z_rec-Z) < 3) - //if(true) - //if(Math.abs(t_calc - Time) < timewindow) - /*if(draw){ - if(hit.get_TShift() == 0) - { - //System.out.println(t_calc + " " + Time); - grz.addPoint(r_rec, z_rec, 0, 0); - gxy.addPoint(x_rec, y_rec, 0, 0); - //if(counter <= 53) - //{ - g1rz.addPoint(Math.sqrt(X*X+Y*Y), Z, 0, 0); - g1xy.addPoint(X, Y, 0, 0); - g2xy.addPoint(0, 0, 0, 0); - gerrorxvsphi.addPoint(Math.atan2(Y,X),Math.pow(Math.abs(x_rec-X),2)/X,0,0); - gerroryvsphi.addPoint(Math.atan2(Y,X),Math.pow(Math.abs(y_rec-Y),2)/Y,0,0); - //} - //System.out.println(counter); - } - else - { - //g2xy.addPoint(X, Y, 0, 0); - g2xy.addPoint(0, 0, 0, 0); - grz.addPoint(0, 0, 0, 0); - g1rz.addPoint(0, 0, 0, 0); - gxy.addPoint(0, 0, 0, 0); - g1xy.addPoint(0, 0, 0, 0); - } - } - //} - // x,y,z pos of pad hit - //x_pad=(PAD_S)*(Math.cos(phi_pad)); - //y_pad=(PAD_S)*(Math.sin(phi_pad)); - - // actual position on pad of hits - //phi_hit=phi_rad-(row*phi_per_pad); - //z_hit=Z-z0-(col*PAD_L)-z_shift; - - // find differences (delta = generated-reconstructed) - //delta_x=X-x_rec; - //delta_y=Y-y_rec; - //delta_z=Z-z_rec; - //delta_r=r_pos-r_rec; - //delta_phi = phi_pos-phi_rec; - //System.out.println(X + " " + x_rec); - //System.out.println(r_pos + " " + r_rec); - - */ - - /*hit.set_cellID(cellID); - hit.set_Time(t_s2pad); - hit.set_Edep(Edep); - hit.set_PosX(x_rec); - hit.set_PosY(y_rec); - hit.set_PosZ(z_rec); - TimeVec.add(t_s2pad); - XVec.add(x_rec); - YVec.add(y_rec); - ZVec.add(z_rec);*/ - //} - /*counter++; - } - }*/ - if(draw){ - /*EmbeddedCanvas c = new EmbeddedCanvas(); - EmbeddedCanvas c2 = new EmbeddedCanvas(); - EmbeddedCanvas c3 = new EmbeddedCanvas(); - EmbeddedCanvas c4 = new EmbeddedCanvas(); - //System.out.println(counter); - GraphErrors g2 = new GraphErrors(); - double theta = 0; - double test_x = 0; - double test_y = 0; - double test_x2 = 0; - double test_y2 = 0; - while(theta <= 2*Math.PI) - { - test_x = 30 * Math.cos(theta); - test_y = 30 * Math.sin(theta); - test_x2 = 70 * Math.cos(theta); - test_y2 = 70 * Math.sin(theta); - g2.addPoint(test_x, test_y, 0, 0); - g2.addPoint(test_x2, test_y2, 0, 0); - theta+=0.01; - } - int color = 2; - int shape = 1; - for(int key : graphmap.keySet()) - { - double szPos[][] = new double[recohitvector.get(key).size()][3]; - for(int i = 0; i < recohitvector.get(key).size(); i++) { - szPos[i][0] = recohitvector.get(key).get(i).x(); - szPos[i][1] = recohitvector.get(key).get(i).y(); - szPos[i][2] = recohitvector.get(key).get(i).z(); - } - //double R = 0; double A = 0; double B = 0; double Phi_deg = 0; double Theta_deg = 0; double Z0 = 0; int fit_track_to_beamline = 1; - //HelixFitJava hf = new HelixFitJava(); - //hf.HelixFit(recohitvector.get(key).size(), szPos, R, A, B, Phi_deg, Theta_deg, Z0, fit_track_to_beamline); - //System.out.println(key + " " + R); - if(false) - //if(key == 3) - { - graphmap.get(key).setMarkerSize(6); - graphmap2.get(key).setMarkerSize(6); - } - else { - graphmap.get(key).setMarkerSize(3); - graphmap.get(key).setMarkerColor(color); - graphmap.get(key).setMarkerStyle(shape); - - - graphmap2.get(key).setMarkerSize(3); - graphmap2.get(key).setMarkerColor(color); - graphmap2.get(key).setMarkerStyle(shape); - - } - c.draw(graphmap.get(key),"same"); - c2.draw(graphmap2.get(key),"same"); - color++; - if(color > 7) - { - color -= 6; - shape++; - } - } - grz.setMarkerSize(3); - grz.setMarkerColor(1); - g1rz.setMarkerSize(2); - g1rz.setMarkerColor(2); - //grz.addPoint(30, -200, 0, 0); - //grz.addPoint(70, 200, 0, 0); - gxy.setMarkerSize(2); - gxy.setMarkerColor(2); - g1xy.setMarkerSize(2); - g1xy.setMarkerColor(1); - g2xy.setMarkerSize(2); - g2xy.setMarkerColor(7); - g2.setMarkerSize(0); - g2.setMarkerColor(3); - gerrorxvsphi.setMarkerSize(2); - gerroryvsphi.setMarkerSize(2); - JFrame j = new JFrame(); - j.setSize(800,600); - JFrame j2 = new JFrame(); - j2.setSize(800,600); - JFrame j3 = new JFrame(); - j3.setSize(800,600); - JFrame j4 = new JFrame(); - j4.setSize(800,600); - c.draw(grz,"same"); - c.draw(g1rz,"same"); - c2.draw(gxy,"same"); - c2.draw(g1xy,"same"); - c2.draw(g2,"same"); - c2.draw(g2xy,"same"); - c3.divide(1, 2); - c3.cd(0); - c3.draw(gerrorxvsphi); - c3.cd(1); - c3.draw(gerroryvsphi); - //c4.draw(largetdist); - j.setTitle("RZ"); - j2.setTitle("XY"); - - - j.add(c); - j.setVisible(true); - j2.add(c2); - j2.setVisible(true); - //j3.add(c3); - //j3.setVisible(true); - j4.add(c4); - //j4.setVisible(true); - } - */ - } - //System.out.println(outsidedriftcounter + "/" + allhitscounter); - //params.set_alltracks(alltracks); - - params.set_recohitvector(recohitvector); - } - - private double get_rec_coef(double t1, double t2, double t3, double t4, double t5, double z2) { - double z = z2/1000; - return t1*z*z*z*z + t2*z*z*z + t3*z*z + t4*z + t5; - - } - - -} - - - - diff --git a/reconstruction/rtpc/src/main/java/org/jlab/service/rtpc/RTPCEngine.java b/reconstruction/rtpc/src/main/java/org/jlab/service/rtpc/RTPCEngine.java index 0d04cb5ab4..4ba01bfaa1 100644 --- a/reconstruction/rtpc/src/main/java/org/jlab/service/rtpc/RTPCEngine.java +++ b/reconstruction/rtpc/src/main/java/org/jlab/service/rtpc/RTPCEngine.java @@ -13,16 +13,16 @@ import org.jlab.io.hipo.HipoDataSource; import org.jlab.io.hipo.HipoDataSync; import org.jlab.rec.rtpc.banks.HitReader; -import org.jlab.rec.rtpc.banks.RecoBankWriter2; +import org.jlab.rec.rtpc.banks.RecoBankWriter; import org.jlab.rec.rtpc.hit.Hit; import org.jlab.rec.rtpc.hit.HitParameters; import org.jlab.rec.rtpc.hit.PadFit; import org.jlab.rec.rtpc.hit.PadHit; -import org.jlab.rec.rtpc.hit.TimeAverage2; +import org.jlab.rec.rtpc.hit.TimeAverage; //import org.jlab.rec.rtpc.hit.TrackDisentangler; -import org.jlab.rec.rtpc.hit.TrackFinder3; -import org.jlab.rec.rtpc.hit.TrackHitReco3; -import org.jlab.rec.rtpc.hit.HelixFitTest; +import org.jlab.rec.rtpc.hit.TrackFinder; +import org.jlab.rec.rtpc.hit.TrackHitReco; +//import org.jlab.rec.rtpc.hit.HelixFitTest; @@ -31,7 +31,7 @@ public class RTPCEngine extends ReconstructionEngine{ public RTPCEngine() { - super("RTPC","charlesg","3.0"); + super("RTPC","davidp","3.0"); } @Override @@ -46,7 +46,7 @@ public boolean processDataEvent(DataEvent event) { HitReader hitRead = new HitReader(); hitRead.fetch_RTPCHits(event); - List hits = new ArrayList(); + List hits = new ArrayList<>(); //I) get the hits hits = hitRead.get_RTPCHits(); @@ -57,30 +57,18 @@ public boolean processDataEvent(DataEvent event) { } if(event.hasBank("RTPC::pos")){ - PadHit p = new PadHit(hits,params); - PadFit pfit = new PadFit(params); - TrackFinder3 TF = new TrackFinder3(params,false); - TimeAverage2 TA2 = new TimeAverage2(params,false); - //TrackDisentangler TD = new TrackDisentangler(params,true); - TrackHitReco3 TR3 = new TrackHitReco3(hits,params,false); - //HelixFitTest hft = new HelixFitTest(hits,params); - RecoBankWriter2 writer = new RecoBankWriter2(); - DataBank recoBank = writer.fillRTPCHitsBank(event, params); + PadHit PH = new PadHit(hits,params); + PadFit PF = new PadFit(params); + TrackFinder TF = new TrackFinder(params); + TimeAverage TA = new TimeAverage(params); + TrackHitReco TR = new TrackHitReco(params); + RecoBankWriter writer = new RecoBankWriter(); + DataBank recoBank = writer.fillRTPCHitsBank(event,params); event.appendBanks(recoBank); } else{ return true; } - - /* - for(Hit h : hits) { - System.out.println("Hit "+h.get_Id()+" CellID "+h.get_cellID()+" ADC "+h.get_ADC()+" true Edep "+h.get_EdepTrue()+" Edep "+h.get_Edep()+" Time "+h.get_Time()+" "+ - " true X "+h.get_PosXTrue()+" X "+h.get_PosX()+" true Y "+h.get_PosYTrue()+" Y "+h.get_PosY()+" true Z "+h.get_PosZTrue()+" Z "+h.get_PosZ()); - }*/ - - - - return true; } From a04bd335b154716a878ac7479537391553d66e24 Mon Sep 17 00:00:00 2001 From: dcpayette Date: Mon, 19 Aug 2019 14:05:28 -0400 Subject: [PATCH 030/235] Clean up signal sim --- .../java/org/jlab/rec/rtpc/hit/ADCMap.java | 84 ++++++++ .../org/jlab/rec/rtpc/hit/HitDistance.java | 15 +- .../org/jlab/rec/rtpc/hit/HitParameters.java | 16 +- .../jlab/rec/rtpc/hit/HitReconstruction.java | 8 +- .../org/jlab/rec/rtpc/hit/MapCombine.java | 11 +- .../java/org/jlab/rec/rtpc/hit/PadAve.java | 42 ++-- .../java/org/jlab/rec/rtpc/hit/PadFit.java | 43 ++-- .../java/org/jlab/rec/rtpc/hit/PadHit.java | 194 ------------------ .../jlab/rec/rtpc/hit/SignalSimulation.java | 59 ++++++ .../org/jlab/rec/rtpc/hit/TimeAverage.java | 8 +- .../org/jlab/rec/rtpc/hit/TrackFinder.java | 16 +- .../org/jlab/service/rtpc/RTPCEngine.java | 42 ++-- 12 files changed, 231 insertions(+), 307 deletions(-) create mode 100644 reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/ADCMap.java delete mode 100644 reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/PadHit.java create mode 100644 reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/SignalSimulation.java diff --git a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/ADCMap.java b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/ADCMap.java new file mode 100644 index 0000000000..1fd3cd66f8 --- /dev/null +++ b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/ADCMap.java @@ -0,0 +1,84 @@ +/* + * 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.rec.rtpc.hit; + +import java.util.HashMap; + +/** + * + * @author davidpayette + */ +public class ADCMap { + + private HashMap _ADCMap; + private HashMap _intADCMap; + + private int TrigWindSize = 10000; + private int SignalStepSize = 10; + + public ADCMap(){ + _ADCMap = new HashMap<>(); + _intADCMap = new HashMap<>(); + + } + + public void simulateSignal(int Pad, double time, double Edep){ + if(!_ADCMap.containsKey(Pad)){ + _ADCMap.put(Pad, new double[TrigWindSize]); + } + for(int tbin=0;tbin0) integral+=0.5*(_ADCMap.get(Pad)[tbin-SignalStepSize]+_ADCMap.get(Pad)[tbin])*SignalStepSize; + if(tbin%BinSize==0 && tbin>0){ // integration over BinSize + if(tbin%(BinSize*NBinKept)==0){ // one BinSize over NBinKept is read out + if(!_intADCMap.containsKey(Pad)){ + _intADCMap.put(Pad, new double[TrigWindSize]); + } + _intADCMap.get(Pad)[tbin] = integral; + } + integral=0; + } + } + } + + public double getSignal(int Pad, int Time){ + return _intADCMap.get(Pad)[Time]; + } + + public HashMap getADCMap(){ + return _intADCMap; + } + + private double EtoS(double tsignal, double t, double e_tot){ + + double sig; + //t = noise_elec(t); // change t to simulate the electronics noise, also modifies the amplitude + double p0 = 0.0; + double p2 = 178.158; + double p3 = 165.637; + double p4 = 165.165; + + if(t ADCMap = params.get_R_adc(); - List PadNum = params.get_PadNum(); + HashMap ADCMap = params.get_ADCMap(); + List PadList = params.get_PadList(); int Pad = 0; //initializing pad int Pad2 = 0; int TrigWindSize = params.get_TrigWindSize(); //Trigger Window Size = 10000 @@ -52,18 +52,18 @@ public void FindDistance(HitParameters params) { double ZDelta = Math.pow(6, 2); for(int t = 0; t < TrigWindSize; t+=StepSize) { - for(int p = 0; p < PadNum.size(); p ++) + for(int p = 0; p < PadList.size(); p ++) { - Pad = PadNum.get(p); + Pad = PadList.get(p); ADC = ADCMap.get(Pad)[t]; if(ADC > thresh) { Vector3 PadCoords = PadCoords(Pad); - for(int p2 = 0; p2 < PadNum.size(); p2++) + for(int p2 = 0; p2 < PadList.size(); p2++) { if(p2 != p) { - Pad2 = PadNum.get(p2); + Pad2 = PadList.get(p2); ADC2 = ADCMap.get(Pad2)[t]; if(ADC2 > thresh) { @@ -126,3 +126,4 @@ private Vector3 PadCoords(int cellID) { } } +*/ \ No newline at end of file diff --git a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/HitParameters.java b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/HitParameters.java index 4fc5a91d7e..b5b79274c4 100644 --- a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/HitParameters.java +++ b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/HitParameters.java @@ -6,16 +6,16 @@ public class HitParameters { - final private int _StepSize = 10; + final private int _SignalStepSize = 10; final private int _BinSize = 40; final private int _NBinKept = 3; final private int _TrigWindSize = 10000; private int _eventnum = 0; - private HashMap _R_adc = new HashMap<>(); + private ADCMap _ADCMap = new ADCMap(); private HashMap> _TimeMap = new HashMap<>(); private HashMap> _FinalTIDMap = new HashMap<>(); private List _PadN = new ArrayList<>(); // used to read only cell with signal, one entry for each hit - private List _PadNum = new ArrayList<>();// used to read only cell with signal, one entry for each cell + private List _PadList = new ArrayList<>();// used to read only cell with signal, one entry for each cell private List _Pad = new ArrayList<>(); private List _ADC = new ArrayList<>(); private List _Time_o = new ArrayList<>(); @@ -34,14 +34,14 @@ public class HitParameters { private TrackMap _trackmap = new TrackMap(); private ReducedTrackMap _rtrackmap = new ReducedTrackMap(); - public int get_StepSize(){return _StepSize;} // step size of the signal before integration (arbitrary value) + public int get_SignalStepSize(){return _SignalStepSize;} // step size of the signal before integration (arbitrary value) public int get_BinSize(){return _BinSize;} // electronics integrates the signal over 40 ns public int get_NBinKept(){return _NBinKept;} // only 1 bin over 3 is kept by the daq public int get_TrigWindSize(){return _TrigWindSize;} // Trigger window should be 10 micro - public HashMap get_R_adc(){return _R_adc;} + public ADCMap get_ADCMap(){return _ADCMap;} public HashMap> get_TimeMap(){return _TimeMap;} public List get_PadN(){return _PadN;} - public List get_PadNum(){return _PadNum;} + public List get_PadList(){return _PadList;} public List get_Pad(){return _Pad;} public List get_ADC(){return _ADC;} public List get_Time_o(){return _Time_o;} @@ -68,10 +68,10 @@ public PadVector get_padvector(int pad) { } - public void set_R_adc(HashMap _R_adc){this._R_adc = _R_adc;} + public void set_ADCMap(ADCMap _ADCMap){this._ADCMap = _ADCMap;} public void set_TimeMap(HashMap> _TimeMap){this._TimeMap = _TimeMap;} public void set_PadN(List _PadN){this._PadN = _PadN;} - public void set_PadNum(List _PadNum){this._PadNum = _PadNum;} + public void set_PadList(List _PadList){this._PadList = _PadList;} public void set_Pad(List _Pad){this._Pad = _Pad;} public void set_ADC(List _ADC){this._ADC = _ADC;} public void set_Time_o(List _Time_o){this._Time_o = _Time_o;} diff --git a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/HitReconstruction.java b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/HitReconstruction.java index 76868c90c1..c3cc569537 100644 --- a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/HitReconstruction.java +++ b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/HitReconstruction.java @@ -10,16 +10,16 @@ public HitReconstruction() { } public void Reco(HitParameters params) { - List PadNum = params.get_PadNum(); + List PadList = params.get_PadList(); List weightave = params.get_weightave(); List maxinte = params.get_maxinte(); int p = 0; //for(Hit hit : rawHits) { - for(p = 0; p> TAMap = params.get_FinalTIDMap(); HashMap>> TFMap = params.get_strkTIDMap(); - HashMap ADCMap = params.get_R_adc(); + HashMap ADCMap = params.get_ADCMap(); List PadList = new ArrayList(); double maxvalue = 0; @@ -49,7 +49,7 @@ public void MC(HitParameters params, boolean draw) { jf.setSize(800,600);*/ //System.out.println(TIDMap.size()); //for(Hit hit : rawHits) { - for(int TID : TFMap.keySet()){ +/* for(int TID : TFMap.keySet()){ //System.out.println(" "); larget = 0; PadList.clear(); @@ -202,7 +202,7 @@ public void MC(HitParameters params, boolean draw) { marktid.add(i); continue; }*/ - histmap.put(i, new GraphErrors()); +/* histmap.put(i, new GraphErrors()); //System.out.println(i); for(int j = 0; j < alltracks.get(i).size(); j++) { @@ -227,7 +227,7 @@ public void MC(HitParameters params, boolean draw) { /*for(int i = 0; i < marktid.size(); i++) { alltracks.remove(i); }*/ - for(int z : canvasmap.keySet()) { +/* for(int z : canvasmap.keySet()) { //canvasmap.get(z).save(z + ".png"); } EmbeddedCanvas c_adcvst = new EmbeddedCanvas(); @@ -281,3 +281,4 @@ private Vector3 PadCoords(int cellID) { } +*/ \ No newline at end of file diff --git a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/PadAve.java b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/PadAve.java index 5e40a48ebe..206e8b4654 100644 --- a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/PadAve.java +++ b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/PadAve.java @@ -1,5 +1,5 @@ package org.jlab.rec.rtpc.hit; - +/* import java.io.File; import java.io.FileWriter; import java.io.IOException; @@ -11,7 +11,7 @@ public class PadAve { public void TimeAverage(HitParameters params){ - int StepSize = params.get_StepSize(); // step size of the signal before integration (arbitrary value) + int SignalStepSize = params.get_SignalStepSize(); // step size of the signal before integration (arbitrary value) int BinSize = params.get_BinSize(); // electronics integrates the signal over 40 ns int NBinKept = params.get_NBinKept(); // only 1 bin over 3 is kept by the daq int TrigWindSize = params.get_TrigWindSize(); // Trigger window should be 10 micro @@ -24,9 +24,9 @@ public void TimeAverage(HitParameters params){ double sumdenom = 0; double weightave = 0; double timesum = 0; - HashMap R_adc = params.get_R_adc(); + HashMap ADCMap = params.get_ADCMap(); HashMap> TimeMap = params.get_TimeMap(); - List PadNum = params.get_PadNum(); + List PadList = params.get_PadList(); List PadN = params.get_PadN(); List Pad = params.get_Pad(); List ADC = params.get_ADC(); @@ -41,11 +41,11 @@ public void TimeAverage(HitParameters params){ inte=0; - for(int p=0;p0) inte+=0.5*(R_adc.get(PadNum.get(p))[t-StepSize]+R_adc.get(PadNum.get(p))[t])*StepSize; + for(int t=0;t0) inte+=0.5*(ADCMap.get(PadList.get(p))[t-SignalStepSize]+ADCMap.get(PadList.get(p))[t])*SignalStepSize; inte_tot+=inte; if(t%BinSize==0 && t>0){ // integration over BinSize if(t%(BinSize*NBinKept)==0){ // one BinSize over NBinKept is read out, hence added to the histogram @@ -53,8 +53,8 @@ public void TimeAverage(HitParameters params){ sumnumer+=inte*t; sumdenom+=inte; - //write2.write(eventnum + "\t" + PadNum.get(p) + "\t" + t + "\t" + inte + "\r\n"); - //System.out.println(eventnum + "\t" + PadNum.get(p) + "\t" + t + "\t" + inte + "\r\n"); + //write2.write(eventnum + "\t" + PadList.get(p) + "\t" + t + "\t" + inte + "\r\n"); + //System.out.println(eventnum + "\t" + PadList.get(p) + "\t" + t + "\t" + inte + "\r\n"); } inte=0; @@ -62,25 +62,16 @@ public void TimeAverage(HitParameters params){ } weightave = sumnumer/sumdenom; - for(int t=0; t R_adc = params.get_R_adc(); + ADCMap ADCMap = params.get_ADCMap(); HashMap Adcmap = new HashMap<>(); - List PadNum = params.get_PadNum(); + List PadList = params.get_PadList(); List PadN = params.get_PadN(); List Pad = params.get_Pad(); List ADC = params.get_ADC(); @@ -50,27 +42,27 @@ public PadFit(HitParameters params){ g1.setMarkerSize(3); EmbeddedCanvas c1 = new EmbeddedCanvas(); j1.setSize(800, 600); - */ + //F1D f1 = new F1D("f1", "[amp]*gaus(x,[mean],[sigma])",0,1); inte=0; - for(int p=0;p0) inte+=0.5*(R_adc.get(PadNum.get(p))[t-StepSize]+R_adc.get(PadNum.get(p))[t])*StepSize; + if(t>0) inte+=0.5*(ADCMap.get(PadList.get(p))[t-SignalStepSize]+ADCMap.get(PadList.get(p))[t])*SignalStepSize; inte_tot+=inte; if(t%BinSize==0 && t>0){ // integration over BinSize if(t%(BinSize*NBinKept)==0){ // one BinSize over NBinKept is read out, hence added to the histogram - Adcmap.get(PadNum.get(p))[t] = inte; + Adcmap.get(PadList.get(p))[t] = inte; //g1.addPoint(t,inte,0,0); if(max_inte R_adc;// = params.get_R_adc();// Raw depositions for CellID, ADC - private HashMap> TimeMap;// = params.get_TimeMap(); - - private List PadN;// = params.get_PadN(); // used to read only cell with signal, one entry for each hit - //Vector PadNum = params.get_PadNum();// used to read only cell with signal, one entry for each cell - private List PadNum = new ArrayList<>(); - private List ADC = new ArrayList<>(); - - private List Pad;// = params.get_Pad(); - //Vector ADC = params.get_ADC(); - private List Time_o;// = params.get_Time_o(); - - - private int CellID = 0; - private double Time; - private double totEdep; - private int eventnum;// = params.get_eventnum(); - - private double testsum = 0; - private double testcount = 1; - - - - - -public PadHit(List rawHits, HitParameters params){ - - - - - - -//______________________________________________________________________________________________ -// __________________________________________ Openings __________________________________________ -//______________________________________________________________________________________________ - - - StepSize = params.get_StepSize(); // step size of the signal before integration (arbitrary value) - BinSize = params.get_BinSize(); // electronics integrates the signal over 40 ns - NBinKept = params.get_NBinKept(); // only 1 bin over 3 is kept by the daq - TrigWindSize = params.get_TrigWindSize(); // Trigger window should be 10 micro - NTrigSampl = TrigWindSize/BinSize; // number of time samples - R_adc = params.get_R_adc();// Raw depositions for CellID, ADC - TimeMap = params.get_TimeMap(); - PadN = params.get_PadN(); // used to read only cell with signal, one entry for each hit - Pad = params.get_Pad(); - Time_o = params.get_Time_o(); - - - eventnum = params.get_eventnum(); - eventnum++; - - -//______________________________________________________________________________________________ -// __________________________________________ Readings __________________________________________ -//______________________________________________________________________________________________ - -//--Creating the signal on pads with 1 ns steps. - - - // Initializations - R_adc.clear(); // Raw depositions for CellID, adc - PadN.clear(); - PadNum.clear(); - - //Pad->clear(); - //ADC->clear(); // not reliable for now as the fit fails often - //Time_o->clear(); - - //HashMap gmap = new HashMap(); - - for(Hit hit : rawHits){ - - CellID = hit.get_cellID(); - Time = hit.get_Time(); - totEdep = hit.get_EdepTrue(); - - /*try { - - File out = new File("/Users/dpaye001/Desktop/FileOutput/event" + eventnum + "/"); - if(!out.exists()) - {out.mkdirs();} - FileWriter write = new FileWriter("/Users/dpaye001/Desktop/FileOutput/event" + eventnum + "/" + "timetrue.xls",true); - write.write(Time + "\t" + CellID + "\r\n"); - write.close(); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - }*/ - - // searches in PadN if CellID already exists - - if(PadN.contains(CellID)){ // this pad has already seen signal - for(int t=0;t()); - TimeMap.get(CellID).add(Time); - for(int t=0;t PadList = new ArrayList<>(); + private int CellID = 0; + private double Time; + private double Edep; + private ADCMap ADCMap = new ADCMap(); + + public SignalSimulation(List rawHits, HitParameters params){ + + SignalStepSize = params.get_SignalStepSize(); // step size of the signal before integration (arbitrary value) + BinSize = params.get_BinSize(); // electronics integrates the signal over 40 ns + NBinKept = params.get_NBinKept(); // only 1 bin over 3 is kept by the daq + TrigWindSize = params.get_TrigWindSize(); // Trigger window should be 10 micro + NTrigSampl = TrigWindSize/BinSize; // number of time samples + +//--Creating the signal on pads with 10 ns steps. + + for(Hit hit : rawHits){ + + CellID = hit.get_cellID(); + Time = hit.get_Time(); + Edep = hit.get_EdepTrue(); + ADCMap.simulateSignal(CellID,Time,Edep); + ADCMap.integrateSignal(CellID); + + if(!PadList.contains(CellID)) PadList.add(CellID); + + } + + params.set_PadList(PadList); + params.set_ADCMap(ADCMap); + + } + + + + + +} diff --git a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TimeAverage.java b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TimeAverage.java index 2f36f63824..fcd360215a 100644 --- a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TimeAverage.java +++ b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TimeAverage.java @@ -18,7 +18,7 @@ public class TimeAverage { private ReducedTrackMap RTIDMap = new ReducedTrackMap(); private ReducedTrack rtrack; private TrackMap TIDMap; - private HashMap ADCMap; + private ADCMap ADCMap; private List tids; private Track track; private double adc = 0; @@ -33,7 +33,7 @@ public TimeAverage(HitParameters params) { *Initializations */ TIDMap = params.get_trackmap(); - ADCMap = params.get_R_adc(); + ADCMap = params.get_ADCMap(); tids = TIDMap.getAllTrackIDs(); /* @@ -53,14 +53,14 @@ public TimeAverage(HitParameters params) { sumden = 0; timesbypad = track.PadTimeList(pad); for(int time : timesbypad) { //Loop to calculate maximum adc value - adc = ADCMap.get(pad)[time]; + adc = ADCMap.getSignal(pad,time); if(adc > adcmax) { adcmax = adc; } } adcthresh = adcmax/2; for(int time : timesbypad) { //Loop to calculate weighted average time using ADC values which are above half of the maximum - adc = ADCMap.get(pad)[time]; + adc = ADCMap.getSignal(pad,time); if(adc > adcthresh) { sumnum += adc*time; sumden += adc; diff --git a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TrackFinder.java b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TrackFinder.java index 49bb25bee3..b432de439c 100644 --- a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TrackFinder.java +++ b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TrackFinder.java @@ -16,12 +16,12 @@ public class TrackFinder { private TrackMap TIDMap = new TrackMap(); private List TIDList; private Track track; - private HashMap ADCMap; - private List PadNum; + private ADCMap ADCMap; + private List PadList; private int TrigWindSize; private int StepSize = 120;//Bin Size of Dream Electronics Output private double adcthresh = 5e-4; - private int padloopsize;// = PadNum.size(); + private int padloopsize;// = PadList.size(); private boolean padSorted = false; private List padTIDlist = new ArrayList<>(); private List padlist; @@ -37,10 +37,10 @@ public TrackFinder(HitParameters params) { *Initializations */ - ADCMap = params.get_R_adc(); - PadNum = params.get_PadNum(); + ADCMap = params.get_ADCMap(); + PadList = params.get_PadList(); TrigWindSize = params.get_TrigWindSize(); - padloopsize = PadNum.size(); + padloopsize = PadList.size(); /* * Main Algorithm */ @@ -51,8 +51,8 @@ public TrackFinder(HitParameters params) { for(int padindex = 0; padindex < padloopsize; padindex++) { padSorted = false; //Flag to be set when the pad is assigned to a track padTIDlist.clear(); //List of all TIDs assigned to the pad starts empty - pad = PadNum.get(padindex); - adc = ADCMap.get(pad)[time]; + pad = PadList.get(padindex); + adc = ADCMap.getSignal(pad,time); if(adc > adcthresh) { //pad adc threshold check PadVector PadVec = params.get_padvector(pad); //initializes the x,y,z,phi for pad diff --git a/reconstruction/rtpc/src/main/java/org/jlab/service/rtpc/RTPCEngine.java b/reconstruction/rtpc/src/main/java/org/jlab/service/rtpc/RTPCEngine.java index 4ba01bfaa1..ede87d07a1 100644 --- a/reconstruction/rtpc/src/main/java/org/jlab/service/rtpc/RTPCEngine.java +++ b/reconstruction/rtpc/src/main/java/org/jlab/service/rtpc/RTPCEngine.java @@ -16,8 +16,7 @@ import org.jlab.rec.rtpc.banks.RecoBankWriter; import org.jlab.rec.rtpc.hit.Hit; import org.jlab.rec.rtpc.hit.HitParameters; -import org.jlab.rec.rtpc.hit.PadFit; -import org.jlab.rec.rtpc.hit.PadHit; +import org.jlab.rec.rtpc.hit.SignalSimulation; import org.jlab.rec.rtpc.hit.TimeAverage; //import org.jlab.rec.rtpc.hit.TrackDisentangler; import org.jlab.rec.rtpc.hit.TrackFinder; @@ -57,11 +56,17 @@ public boolean processDataEvent(DataEvent event) { } if(event.hasBank("RTPC::pos")){ - PadHit PH = new PadHit(hits,params); - PadFit PF = new PadFit(params); + //to be removed, signals should be simulated in GEMC + SignalSimulation SS = new SignalSimulation(hits,params); + // + + //Sort Hits into Tracks at the Readout Pads TrackFinder TF = new TrackFinder(params); + //Calculate Average Time of Hit Signals TimeAverage TA = new TimeAverage(params); + //Reconstruct Hits in Drift Region TrackHitReco TR = new TrackHitReco(params); + RecoBankWriter writer = new RecoBankWriter(); DataBank recoBank = writer.fillRTPCHitsBank(event,params); event.appendBanks(recoBank); @@ -74,17 +79,8 @@ public boolean processDataEvent(DataEvent event) { public static void main(String[] args){ double starttime = System.nanoTime(); - //String inputFile = "/Users/davidpayette/Desktop/5c.2.3/clara/installation/plugins/clas12/2_72_516.hipo"; - //String inputFile = "/Users/davidpayette/Desktop/5c.2.3/clara/installation/plugins/clas12/1000_1_711.hipo"; - //String inputFile = "/Users/davidpayette/Desktop/5c.2.3/clara/installation/plugins/clas12/100_20_731.hipo"; - //String inputFile = "/Users/davidpayette/Desktop/5c.3.5/clara/installation/plugins/clas12/test.hipo"; - //String inputFile = "/Users/davidpayette/Desktop/5b.7.4/myClara/1212.hipo"; - //String inputFile = "/Users/davidpayette/Desktop/5b.7.4/myClara/plugins/clas12/Jantest.hipo"; + String inputFile = "/Users/davidpayette/Desktop/6b.2.0/myClara/plugins/clas12/5000_40_12Jul.hipo"; - //String inputFile = "/Users/davidpayette/Desktop/Distribution/clas12-offline-software/1212again.hipo"; - //String inputFile = "/Users/davidpayette/Desktop/5c.2.3/clara/installation/plugins/clas12/100_20_802.hipo"; - //String inputFile = "/Users/davidpayette/Desktop/5c.2.3/clara/installation/plugins/clas12/10p.hipo"; - //String inputFile = args[0]; String outputFile = "/Users/davidpayette/Desktop/5b.7.4/myClara/tout_working.hipo"; System.err.println(" \n[PROCESSING FILE] : " + inputFile); @@ -92,28 +88,20 @@ public static void main(String[] args){ RTPCEngine en = new RTPCEngine(); en.init(); - - HipoDataSource reader = new HipoDataSource(); HipoDataSync writer = new HipoDataSync(); reader.open(inputFile); writer.open(outputFile); System.out.println("starting " + starttime); - File f1= new File("/Users/davidpayette/Documents/FileOutput/PulseShapeAll.txt"); - File f2= new File("/Users/davidpayette/Documents/FileOutput/PulseShapeMax.txt"); - File f3= new File("/Users/davidpayette/Documents/FileOutput/PulseShapeAllOverMax.txt"); - f1.delete(); - f2.delete(); - f3.delete(); - while(reader.hasEvent()){ - - DataEvent event = reader.getNextEvent(); - en.processDataEvent(event); - writer.writeEvent(event); + DataEvent event = reader.getNextEvent(); + en.processDataEvent(event); + writer.writeEvent(event); } + writer.close(); + System.out.println("finished " + (System.nanoTime() - starttime)*Math.pow(10,-9)); } } From da33dac5aa1395b5a9ea572ab31851d985fee0e3 Mon Sep 17 00:00:00 2001 From: dcpayette Date: Mon, 19 Aug 2019 15:59:29 -0400 Subject: [PATCH 031/235] added helix fit support --- build-coatjava.sh | 2 +- etc/bankdefs/hipo4/rtpc.json | 17 +- .../jlab/rec/rtpc/banks/RecoBankWriter.java | 38 +- .../java/org/jlab/rec/rtpc/hit/ADCMap.java | 37 +- .../org/jlab/rec/rtpc/hit/FinalTrackInfo.java | 68 ++ .../org/jlab/rec/rtpc/hit/HelixFitJava.java | 3 + .../org/jlab/rec/rtpc/hit/HelixFitObject.java | 30 +- .../org/jlab/rec/rtpc/hit/HelixFitTest.java | 670 +----------------- .../org/jlab/rec/rtpc/hit/HitParameters.java | 5 + .../jlab/rec/rtpc/hit/SignalSimulation.java | 20 +- .../org/jlab/rec/rtpc/hit/TimeAverage.java | 4 +- .../org/jlab/rec/rtpc/hit/TrackFinder.java | 2 +- .../org/jlab/service/rtpc/RTPCEngine.java | 8 +- 13 files changed, 207 insertions(+), 697 deletions(-) create mode 100644 reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/FinalTrackInfo.java diff --git a/build-coatjava.sh b/build-coatjava.sh index 4db6b3e139..1c171c7a63 100755 --- a/build-coatjava.sh +++ b/build-coatjava.sh @@ -109,6 +109,6 @@ cp reconstruction/rich/target/clas12detector-rich-*-SNAPSHOT.jar coatjava/lib/se cp reconstruction/fvt/target/clas12detector-fmt-*-SNAPSHOT.jar coatjava/lib/services/ cp reconstruction/eb/target/clas12detector-eb-*-SNAPSHOT.jar coatjava/lib/services/ cp reconstruction/band/target/clas12detector-band-*-SNAPSHOT.jar coatjava/lib/services/ -cp reconstruction/rtpc/target/clas12detector-rtpc-*-SNAPSHOT.jar coatjava/lib/services/ +cp reconstruction/rtpc/target/rtpc-*-SNAPSHOT.jar coatjava/lib/services/ echo "COATJAVA SUCCESSFULLY BUILT !" diff --git a/etc/bankdefs/hipo4/rtpc.json b/etc/bankdefs/hipo4/rtpc.json index b55919208a..027f251039 100644 --- a/etc/bankdefs/hipo4/rtpc.json +++ b/etc/bankdefs/hipo4/rtpc.json @@ -13,5 +13,20 @@ {"name":"posZ", "type":"F", "info":"z pos (cm)"}, {"name":"tdiff", "type":"F", "info":"Time shift (ns)"} ] - } + }, + { + "name": "RTPC::trackinfo", + "group": 1720, + "item" : 2, + "info" : "reconstructed track info", + "entries": [ + {"name":"TID", "type":"I", "info":"Track ID of the hit"}, + {"name":"px", "type":"F", "info":"X component of the momentum"}, + {"name":"py", "type":"F", "info":"Y component of the momentum"}, + {"name":"pz", "type":"F", "info":"Z component of the momentum"}, + {"name":"vz", "type":"F", "info":"Z component of the reconstructed vertex"}, + {"name":"trackl", "type":"F", "info":"Length of the Track"}, + {"name":"dEdx", "type":"F", "info":"dEdx for the Track"} + ] + } ] diff --git a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/banks/RecoBankWriter.java b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/banks/RecoBankWriter.java index ab6103b05c..14ff1aa236 100644 --- a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/banks/RecoBankWriter.java +++ b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/banks/RecoBankWriter.java @@ -6,6 +6,7 @@ import org.jlab.rec.rtpc.hit.RecoHitVector; import java.util.List; import java.util.HashMap; +import org.jlab.rec.rtpc.hit.FinalTrackInfo; public class RecoBankWriter { @@ -31,7 +32,8 @@ public DataBank fillRTPCHitsBank(DataEvent event, HitParameters params) { } DataBank bank = event.createBank("RTPC::rec", listsize); - + + if (bank == null) { System.err.println("COULD NOT CREATE A BANK!!!!!!"); return null; @@ -60,4 +62,38 @@ public DataBank fillRTPCHitsBank(DataEvent event, HitParameters params) { return bank; } + + public DataBank fillRTPCTrackBank(DataEvent event, HitParameters params) { + /*if(hitlist==null) + return null; + if(hitlist.size()==0) + return null;*/ + HashMap finaltrackinfomap = params.get_finaltrackinfomap(); + int listsize = finaltrackinfomap.size(); + int row = 0; + + + DataBank bank = event.createBank("RTPC::trackinfo", listsize); + + + if (bank == null) { + System.err.println("COULD NOT CREATE A BANK!!!!!!"); + return null; + } + + for(int TID : finaltrackinfomap.keySet()) { + + bank.setInt("TID", row, TID); + bank.setFloat("px", row, (float) finaltrackinfomap.get(TID).get_px()); + bank.setFloat("py", row, (float) finaltrackinfomap.get(TID).get_py()); + bank.setFloat("pz", row, (float) finaltrackinfomap.get(TID).get_pz()); + bank.setFloat("vz", row, (float) finaltrackinfomap.get(TID).get_vz()); + bank.setFloat("trackl", row, (float) finaltrackinfomap.get(TID).get_tl()); + bank.setFloat("dEdx", row, (float) finaltrackinfomap.get(TID).get_dEdx()); + row++; + + } + + return bank; + } } \ No newline at end of file diff --git a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/ADCMap.java b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/ADCMap.java index 1fd3cd66f8..5f2b71a14c 100644 --- a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/ADCMap.java +++ b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/ADCMap.java @@ -16,8 +16,8 @@ public class ADCMap { private HashMap _ADCMap; private HashMap _intADCMap; - private int TrigWindSize = 10000; - private int SignalStepSize = 10; + final private int TrigWindSize = 10000; + final private int SignalStepSize = 10; public ADCMap(){ _ADCMap = new HashMap<>(); @@ -30,29 +30,31 @@ public void simulateSignal(int Pad, double time, double Edep){ _ADCMap.put(Pad, new double[TrigWindSize]); } for(int tbin=0;tbin0) integral+=0.5*(_ADCMap.get(Pad)[tbin-SignalStepSize]+_ADCMap.get(Pad)[tbin])*SignalStepSize; + if(tbin>0){ + integral+=0.5*(getSignal(pad,tbin-SignalStepSize)+getSignal(pad,tbin))*SignalStepSize; + } if(tbin%BinSize==0 && tbin>0){ // integration over BinSize if(tbin%(BinSize*NBinKept)==0){ // one BinSize over NBinKept is read out - if(!_intADCMap.containsKey(Pad)){ - _intADCMap.put(Pad, new double[TrigWindSize]); + if(!_intADCMap.containsKey(pad)){ + _intADCMap.put(pad, new double[TrigWindSize]); } - _intADCMap.get(Pad)[tbin] = integral; + _intADCMap.get(pad)[tbin] = integral; } integral=0; } } } - public double getSignal(int Pad, int Time){ + public double getADC(int Pad, int Time){ return _intADCMap.get(Pad)[Time]; } @@ -60,19 +62,26 @@ public HashMap getADCMap(){ return _intADCMap; } - private double EtoS(double tsignal, double t, double e_tot){ + private double getSignal(int pad, int time){ + return _ADCMap.get(pad)[time]; + } + + private double getSignalAtBin(double tsignal, double t, double edep){ - double sig; + double signal_height; //t = noise_elec(t); // change t to simulate the electronics noise, also modifies the amplitude double p0 = 0.0; double p2 = 178.158; double p3 = 165.637; double p4 = 165.165; - if(t rawHits, HitParameters params){ + public HelixFitTest(HitParameters params){ HashMap> recotrackmap = params.get_recotrackmap(); - - + HashMap finaltrackinfomap = new HashMap<>(); double szpos[][] = new double[1000][3]; int hit = 0; for(int TID : recotrackmap.keySet()){ @@ -31,662 +30,15 @@ public HelixFitTest(List rawHits, HitParameters params){ } HelixFitJava h = new HelixFitJava(); HelixFitObject ho = h.HelixFit(hit,szpos,0,0,0,0,0,0,1); - double momfit = 0.3*50*ho.get_Rho()/10; - System.out.println(momfit); + double momfit = ho.get_Mom(); + double px = ho.get_px(); + double py = ho.get_py(); + double pz = ho.get_pz(); + double vz = ho.get_Z0(); + double tl = ho.get_trackl(); + double dEdx = ho.get_dEdx(); + finaltrackinfomap.put(TID, new FinalTrackInfo(px,py,pz,vz,tl,dEdx)); } - - - - - - - - /* - int entry = -1; - int hitnum = 0; - int tid = -1; - int prevtid = 0; - int num_chains = 0; - int hh_num_hits = 0; - int[] num_hits_this_chain = new int[300]; - int[][] chain_hits = new int[300][300]; - double[] tempx = new double[30]; - double[] tempy = new double[30]; - double[] tempz = new double[30]; - double[] tempr = new double[30]; - double[] num_hits = new double[5000]; - double[] mom_all = new double[5000]; - double[] z_all = new double[5000]; - double[] theta_all = new double[5000]; - int itemp = 0; - int n_RTPC__rec_TID = 0; - double R; double A; double B; - double Phi_deg; double Theta_deg; double Z0; int fit_track_to_beamline=1; - //HashMap > hitHashMap; - boolean flag = true; - boolean finish_track_flag = false; - boolean trackidchange = false; - boolean split_curve = false; - boolean draw = false; - double momx; double momy; double momz; double mom; - TCanvas c1 = new TCanvas("c1", 800, 800); - H1F h1 = new H1F("h1", 100, 0,500); - - //TCanvas c2 = new TCanvas("c2", "Momentum Reconstructed Track (GeV)", 800, 800); - H1F h2 = new H1F("h2", "Momentum Reconstructed Track (MeV)", 75, 0, 500); - H1F h3 = new H1F("h3", "Momentum Reconstructed Track (MeV)", 100, 0, 500); - - H2F hGenRecvsGenTrue = new H2F("hGenRecvsGenTrue","hGenRecvsGenTrue",50,0.,500.,50,0.,500.); - hGenRecvsGenTrue.setTitleX("Momentum (lund)"); - hGenRecvsGenTrue.setTitleY("Momentum (reconstructed lund)"); - H2F hGenRecvsGenTrue2 = new H2F("hGenRecvsGenTrue2","hGenRecvsGenTrue2",50,0.,500.,50,0.,500.); - hGenRecvsGenTrue2.setTitleX("Momentum (lund)"); - hGenRecvsGenTrue2.setTitleY("Momentum (reconstructed lund)"); - H2F hRecvsGenTrue = new H2F("hRecvsGenTrue","hRecvsGenTrue",50,0.,500.,50,0.,500.); - hRecvsGenTrue.setTitleX("Momentum (lund)"); - hRecvsGenTrue.setTitleY("Momentum (rec)"); - H2F hRecvsGenRec = new H2F("hRecvsGenRec","hRecvsGenRec",50,0.,500.,50,0.,500.); - hRecvsGenRec.setTitleX("Momentum (reconstructed lund)"); - hRecvsGenRec.setTitleY("Momentum (rec)"); - H2F hHitsvsMom = new H2F("hHitsvsMom","hHitsvsMom",50,0,500,50,0,250); - hHitsvsMom.setTitleX("Momentum (lund)"); - hHitsvsMom.setTitleY("Number of Hits"); - - H1F h4 = new H1F("h4", "num gen hits in track", 50, 0, 100); - - H2F hMomvsTheta = new H2F("hMomvsTheta","hMomvsTheta",50,0,180,50,0,500); - H2F hZvsTheta = new H2F("hZvsTheta","hZvsTheta",50,0,180,50,-210,210); - hZvsTheta.setTitleX("Theta"); - hZvsTheta.setTitleY("Z vertex (lund)"); - H2F hMomvsThetaCut = new H2F("hMomvsThetaCut","hMomvsThetaCut",50,0,180,50,0,500); - H2F hZvsThetaCut = new H2F("hZvsThetaCut","hZvsThetaCut",50,0,180,50,-210,210); - hZvsThetaCut.setTitleX("Theta"); - hZvsThetaCut.setTitleY("Z vertex (lund)"); - H2F hMomvsThetaelse = new H2F("hMomvsThetaelse","hMomvsThetaelse",50,0,180,50,0,500); - H2F hZvsThetaelse = new H2F("hZvsThetaelse","hZvsThetaelse",50,0,180,50,-210,210); - hZvsThetaelse.setTitleX("Theta"); - hZvsThetaelse.setTitleY("Z vertex (lund)"); - - int cellID = 0; - double time = 0; - double z = 0; - double x = 0; - double y = 0; - double r = 0; - double phi = 0; - double q = 0; - boolean skipfirst = true; - boolean skipfirsttrack = true; - HashMap zvertex_rec = new HashMap(); - HashMap tshift_rec = new HashMap(); - HashMap momentum_rec = new HashMap(); - //HashMap momentum_gen; - //HashMap tshift_gen; - double zvertex_gen; - double tshift_gen; - TCanvas c6 = new TCanvas("c6", 800, 800); - //myfile << "Generated Momentum" << "\t" << "Reconstructed Momentum " << "\t" << "Time Shift" << endl; - int failed_genrec = 0; - for(Hit rawhit : rawHits){ - if(skipfirst){ skipfirst = false; continue;} - entry++; - //myfile << "Event " << entry << endl; - // if(entry > 1000) break; - //entry = -1; - hitnum = 0; - tid = -1; - prevtid = 0; - num_chains = 0; - hh_num_hits = 0; - itemp = 0; - flag = true; - finish_track_flag = false; - trackidchange = false; - split_curve = false; - draw = false; - skipfirsttrack = true; - //std::cout << "event # " << entry << std::endl; - double thetarad = 0; - double thetadeg = 0; - double vz = 0; - if(rawhit.get_TID() == 2) - - momx = MC__Lund_px.getValue(c); - momy = MC__Lund_py.getValue(c); - momz = MC__Lund_pz.getValue(c); - vz = MC__Lund_vz.getValue(c); - vz*=10; - mom = Math.Sqrt(momx*momx + momy*momy + momz*momz); - thetarad = Math.ACos(momz/mom); - thetadeg = thetarad*Math.RadToDeg(); - //std::cout << MC__Lund_vz.getValue(c) << " vz" << endl; - //std::cout << momx << " " << momy << " " << momz << " " << mom << endl; - } - } - h1.Fill(mom*1000); - //myfile << mom*1000 << "\t"; - /*int n_RTPC__pos_posx = RTPC__pos_posx.getLength(); - double genx[n_RTPC__pos_posx+1]; - double geny[n_RTPC__pos_posx+1]; - double genz[n_RTPC__pos_posx+1]; - for(int d = 0; d <= n_RTPC__pos_posx; d++){ - genx[d] = RTPC__pos_posx.getValue(d); - geny[d] = RTPC__pos_posy.getValue(d); - genz[d] = RTPC__pos_posz.getValue(d); - } - - TGraph *genxy = new TGraph(n_RTPC__pos_posx,genx,geny); - genxy.SetMarkerStyle(31); - genxy.SetMarkerColor(3); - */ - // n_RTPC__rec_TID = RTPC__rec_TID.getLength(); - /*int n_gen_TID = RTPC__pos_tid.getLength(); - int tid_temp = -1; - int num_tracks = 0; - /*for(int i = 0; i < n_RTPC__rec_TID; i++){ - if(RTPC__rec_TID.getValue(i) != tid_temp){ - tid_temp = RTPC__rec_TID.getValue(i); - num_tracks++; - } - } - std::cout << "This event has " << num_tracks << " tracks" << endl; - - for(int b = 0; b <= n_RTPC__rec_TID; b++){ - //if(!draw) break; - //std::cout << RTPC__rec_TID.getValue(b) << " " << RTPC__rec_time.getValue(b) << std::endl; - if(b < n_RTPC__rec_TID){ - prevtid = RTPC__rec_TID.getValue(b); - } - else{ - prevtid = -111; - } - - trackidchange = false; - if(tid != prevtid){ - finish_track_flag = false; - trackidchange = true; - if(num_hits_this_chain[tid] > 0 && b != 0){ - /*DEBUG - for(int i = 0; i < szpos.size(); i++){ - std::cout << szpos[i][0] << endl; - }*/ - /*HelixFit(num_hits_this_chain[tid]-1, szpos, R, A, B, Phi_deg, Theta_deg, Z0, fit_track_to_beamline); - std::cout << "tid : " << tid << std::endl; - std::cout << "A : " << A << std::endl; - std::cout << "B : " << B << std::endl; - std::cout << "R : " << R << std::endl; - std::cout << "p : " << 0.3*50*R/10 << std::endl; - std::cout << "Z : " << Z0 << std::endl; - std::cout << "Theta " << Theta_deg << std::endl; - std::cout << "Phi " << Phi_deg << std::endl; - zvertex_rec.insert(std::make_pair(tid,Z0)); - tshift_rec.insert(std::make_pair(tid,RTPC__rec_tdiff.getValue(b-1))); - momentum_rec.insert(std::make_pair(tid,0.3*50*R/10)); - if(!skipfirsttrack) myfile << "" << "\t"; - skipfirsttrack = false; - myfile << 0.3*50*R/10 << "\t" << RTPC__rec_tdiff.getValue(b-1) << endl; - - //if(tid == 1){ - if(true){ - //TCanvas *p = new TCanvas("p","p",800,600); - //TMultiGraph *mg = new TMultiGraph(); - //TEllipse *e = new TEllipse(A, B, R, R); - //p.drawFrame(-70,-70,70,70); - //e.draw(); - double xpos[300]; - double ypos[300]; - double zpos[300]; - double rpos[300]; - for(int i = 0; i < num_hits_this_chain[tid]-1; i++){ - xpos[i] = szpos[i][0]; - ypos[i] = szpos[i][1]; - zpos[i] = szpos[i][2]; - rpos[i] = Math.Sqrt(xpos[i]*xpos[i] + ypos[i]*ypos[i]); - } - //if(fit_track_to_beamline){ - xpos[num_hits_this_chain[tid]] = 0; - ypos[num_hits_this_chain[tid]] = 0; - zpos[num_hits_this_chain[tid]] = Z0; - rpos[num_hits_this_chain[tid]] = 0; - num_hits_this_chain[tid]++; - //} - double t0 = (Math.Pi()/2) + Phi_deg*Math.DegToRad(); - double tmin = t0; - double tmax = t0 - Math.TwoPi(); - int numpoints = 2000; - double step = (tmax - tmin)/(numpoints-1); - double xarrhelix[numpoints]; - double yarrhelix[numpoints]; - double zarrhelix[numpoints]; - double xarrinner[numpoints]; - double yarrinner[numpoints]; - double xarrouter[numpoints]; - double yarrouter[numpoints]; - - int i2 = 0; - double partxhelix[numpoints]; - double partyhelix[numpoints]; - double partzhelix[numpoints]; - double partrhelix[numpoints]; - //TNtuple *helixn = new TNtuple("helixn","helixn","x:y:z"); - for(int i = 0; i < numpoints;i++){ - if(i*step >= -Math.Pi()){ - xarrhelix[i] = A+xcirc(tmin+i*step,R,0); - yarrhelix[i] = B+ycirc(tmin+i*step,R,0); - zarrhelix[i] = Z0-zcirc(tmin+i*step-t0,R,Theta_deg); - //zarrhelix[i] = Z0; - //helixn.Fill(xarrhelix[i],yarrhelix[i],zarrhelix[i]); - if(Math.Abs(xarrhelix[i])<70 && Math.Abs(yarrhelix[i])<70){ - partxhelix[i2] = xarrhelix[i]; - partyhelix[i2] = yarrhelix[i]; - partzhelix[i2] = zarrhelix[i]; - partrhelix[i2] = Math.Sqrt(xarrhelix[i] * xarrhelix[i] + yarrhelix[i] * yarrhelix[i]); - i2++; - } - } - xarrinner[i] = xcirc(tmin + i*step,30,0); - yarrinner[i] = ycirc(tmin + i*step,30,0); - xarrouter[i] = xcirc(tmin + i*step,70,0); - yarrouter[i] = ycirc(tmin + i*step,70,0); - - } - //TGraph *circgr = new TGraph(numpoints,partxhelix,partyhelix); - //circgr.SetMarkerColor(2); - //circgr.GetXaxis().SetLimits(-70,70); - //circgr.GetYaxis().SetRangeUser(-70,70); - - //mg.Add(circgr); - - //TGraph *innergr = new TGraph(numpoints,xarrinner,yarrinner); - //mg.Add(innergr); - //TGraph *outergr = new TGraph(numpoints,xarrouter,yarrouter); - //mg.Add(outergr); - - //TGraph *gr = new TGraph(num_hits_this_chain[tid]-1,xpos,ypos); - //gr.GetXaxis().SetLimits(-70,70); - //gr.GetYaxis().SetRangeUser(-70,70); - //gr.SetMarkerStyle(31); - //mg.Add(gr); - if(split_curve){ - //TGraph *gr2 = new TGraph(itemp - 1, tempx, tempy); - //gr2.GetXaxis().SetLimits(-70,70); - //gr2.GetYaxis().SetRangeUser(-70,70); - //gr2.SetMarkerStyle(31); - //mg.Add(gr2); - } - //mg.Add(genxy); - //mg.GetXaxis().SetLimits(-70,70); - //mg.GetYaxis().SetRangeUser(-70,70); - //mg.SetTitle("y vs x;x;y"); - //mg.draw("ap"); - - //p.Update(); - //p.SaveAs("gxy.png"); - //TCanvas *trz = new TCanvas("","",800,600); - //TMultiGraph *mgrz = new TMultiGraph(); - //TGraph *grz = new TGraph(num_hits_this_chain[tid],rpos,zpos); - //grz.SetMarkerStyle(31); - //TGraph *hgrz = new TGraph(numpoints,partrhelix,partzhelix); - //hgrz.SetMarkerColor(2); - //mgrz.Add(grz); - //mgrz.Add(hgrz); - if(split_curve){ - //TGraph *grz2 = new TGraph(itemp - 1, tempr, tempz); - //mgrz.Add(grz2); - } - //mgrz.SetTitle("z vs r;r;z"); - //mgrz.draw("ap"); - //trz.SaveAs("grz.png"); - //TApplication *tapp = new TApplication("tapp",0,0); - //TApplication tapp("App", 0, 0); - //TCanvas *tc = new TCanvas("","",800,600); - //TView3D *view = (TView3D*) TView::CreateView(1); - //view.SetRange(5,5,5,25,25,25); - //TView *view = TView::CreateView(1); - //view.SetRange(-70,-70,100,70,70,200); - //TNtuple *n = new TNtuple("n","n","x:y:z"); - for(int i = 0; i <= num_hits_this_chain[tid] ; i++){ - //n.Fill(xpos[i],ypos[i],zpos[i]); - //std::cout << xpos[i] << " " << ypos[i] << " " << zpos[i] << " " << Math.ATan2(ypos[i],xpos[i])*Math.RadToDeg() << std::endl; - } - if(split_curve){ - for(int i = 0; i <= itemp - 1; i++){ - //n.Fill(tempx[i],tempy[i],tempz[i]); - } - } - - //n.SetMarkerStyle(3); - //n.draw("x:y:z"); - //helixn.draw("x:y:z","","same"); - //tc.cd(); - //tc.Modified(); - //tc.Update(); - //TApplication *tapp = new TApplication("tapp",&argc, argv); - //tapp.Run(); - //tc.SaveAs("3d.png"); - - //std::cout << "\nNext Event?" << std::endl; - //int key = std::cin.get(); - //if (key == EOF || key == 'n' || key == 'N') return 0; - //if (key != '\n') std::cin.ignore(numeric_limits::max(), '\n'); - //std::cout << "OK" << std::endl; - - flag = false; - } - } - //double szpos[300][3] = new double[300][3]; - if(b < n_RTPC__rec_TID){ - tid = RTPC__rec_TID.getValue(b); - //std::cout << tid << endl; - } - else - { - break; - } - // if(tid = -111){break;} - num_chains++; - num_hits_this_chain[tid] = 0; - }else if(finish_track_flag){ - tempx[itemp] = RTPC__rec_posX.getValue(b); - tempy[itemp] = RTPC__rec_posY.getValue(b); - tempz[itemp] = RTPC__rec_posZ.getValue(b); - tempr[itemp] = Math.Sqrt(tempx[itemp]*tempx[itemp] + tempy[itemp]*tempy[itemp]); - itemp++; - continue; - } - - cellID = RTPC__rec_cellID.getValue(b); - time = RTPC__rec_time.getValue(b); - z = RTPC__rec_posZ.getValue(b);//*10.0; - x = RTPC__rec_posX.getValue(b);//*10.0; - y = RTPC__rec_posY.getValue(b);//*10.0; - r = sqrt(x*x+y*y); - phi = atan2(y,x); - q = 1; - //std::cout << x << " " << y << " " << z << endl; - if(split_curve && b > 0 && !trackidchange && !finish_track_flag && Math.Abs(time - RTPC__rec_time.getValue(b-1))>500){ - finish_track_flag = true; - //std::cout << "finish track flag" << std::endl; - continue; - } - itemp = 0; - num_hits_this_chain[tid]++; - hh_num_hits++; - chain_hits[tid][num_hits_this_chain[tid]] = hh_num_hits; - /* double z = RTPC__rec_posZ.getValue(b);//*10.0; - double x = RTPC__rec_posX.getValue(b);//*10.0; - double y = RTPC__rec_posY.getValue(b);//*10.0; - double r = sqrt(x*x+y*y); - double phi = atan2(y,x); - double q = 1;*/ - /*szpos[num_hits_this_chain[tid]-1][0] = x; - szpos[num_hits_this_chain[tid]-1][1] = y; - szpos[num_hits_this_chain[tid]-1][2] = z; - - hh_hitlist[hh_num_hits] = new HitVector(cellID,time,1,z,r,phi,q); - //std::cout << hh_num_hits << std::endl; - } - //std::cout << hh_num_hits << std::endl; - */ - /*double szpos_gen[300][3]; - int num_gen_hits = 0; - for(int b = 0; b < n_gen_TID; b++){ - if(RTPC__pos_tid.getValue(b) == 2){ - szpos_gen[num_gen_hits][0] = RTPC__pos_posx.getValue(b); - szpos_gen[num_gen_hits][1] = RTPC__pos_posy.getValue(b); - szpos_gen[num_gen_hits][2] = RTPC__pos_posz.getValue(b); - - num_gen_hits++; - - } - } - - HelixFit(num_gen_hits, szpos_gen, R, A, B, Phi_deg, Theta_deg, Z0, fit_track_to_beamline); -//std::cout << "tid : " << tid << std::endl; - /*std::cout << "A gen: " << A << std::endl; - std::cout << "B gen: " << B << std::endl; - std::cout << "R gen: " << R << std::endl; - std::cout << "p gen: " << 0.3*50*R/10 << std::endl; - std::cout << "Z gen: " << Z0 << std::endl; - std::cout << "Theta gen " << Theta_deg << std::endl; - std::cout << "Phi gen " << Phi_deg << std::endl; - */ - /*double genrec = 0.3*50*R/10; - h3.Fill(genrec); - hHitsvsMom.Fill(mom*1000,num_gen_hits); - mom_all[entry] = mom*1000; - num_hits[entry] = num_gen_hits; - z_all[entry] = vz; - hMomvsTheta.Fill(thetadeg,mom*1000); - hZvsTheta.Fill(thetadeg,vz); - theta_all[entry] = Math.Tan(thetarad); - // std::cout << vz << " " << Math.Tan(thetarad) << endl; - if((((Math.Tan(thetarad) > 0) && ((200-vz)*Math.Tan(thetarad) > 50)) || ((Math.Tan(thetarad) < 0) && (-(vz+200)*Math.Tan(thetarad) > 50))) && num_gen_hits < 5) { - //if(num_gen_hits < 5 && vz < (1.25*thetadeg + 75) && vz > (1.25*thetadeg - 300)){ //if(-(vz+200)*Math.Cos(thetarad) > 0 && (200 - vz)*Math.Cos(thetarad) > 0){//if(num_gen_hits < 5){ - hMomvsThetaCut.Fill(thetadeg,mom*1000); - hZvsThetaCut.Fill(thetadeg,vz); - hGenRecvsGenTrue2.Fill(mom*1000,genrec); - }else{ - hMomvsThetaelse.Fill(thetadeg,mom*1000); - hZvsThetaelse.Fill(thetadeg,vz); - } - hGenRecvsGenTrue.Fill(mom*1000,genrec); - double xtempgen[num_gen_hits-1]; - double ytempgen[num_gen_hits-1]; - double tmax = 2*Math.Pi(); - int numpoints2 = 2000; - double step2 = (tmax)/(numpoints2-1); - double xarrinner2[numpoints2]; - double yarrinner2[numpoints2]; - double xarrouter2[numpoints2]; - double yarrouter2[numpoints2]; - for(int i = 0; i < numpoints2; i++) - { - xarrinner2[i] = xcirc(i*step2,30,0); - yarrinner2[i] = ycirc(i*step2,30,0); - xarrouter2[i] = xcirc(i*step2,70,0); - yarrouter2[i] = ycirc(i*step2,70,0); - - } - TGraph ginner = new TGraph(numpoints2,xarrinner2,yarrinner2); - TGraph gouter = new TGraph(numpoints2,xarrouter2,yarrouter2); - - if(true){ - //if(genrec<1){ - failed_genrec++; - for(int i = 0; i < num_gen_hits-1; i++){ - xtempgen[i] = szpos_gen[i][0]; - ytempgen[i] = szpos_gen[i][1]; - } - gtest[entry] = new TGraph(num_gen_hits-1, xtempgen, ytempgen); - // std::cout << "DEBUG fail" << num_gen_hits << std::endl; - }else{ - double stuffx[1]; - double stuffy[1]; - stuffx[0] = 0; - stuffy[0] = 0; - gtest[entry] = new TGraph(1,stuffx,stuffy); - std::cout << "DEBUG succeed" << num_gen_hits << std::endl; - } - c6.cd(); - gtest[entry].SetTitle(Form("%f",mom*1000)); - gtest[entry].GetXaxis().SetLimits(-75,75); - gtest[entry].GetYaxis().SetRangeUser(-75,75); - - gtest[entry].SetMarkerStyle(21); - gtest[entry].SetMarkerColor(kBlack); - gtest[entry].draw("AP"); - ginner.draw("same"); - gouter.draw("same"); - //c6.SaveAs(Form("images_out/%u-mom=%f-theta=%f-vz=%f.png",entry,mom*1000,thetadeg,vz)); - c6.cd(); - h4.Fill(num_gen_hits); - - //After looping through all tracks - - /*HashMap::iterator it1 = zvertex_rec.begin(); - HashMap::iterator it2 = tshift_rec.begin(); - double zvertex_rec_comp = 100000; - double tshift_rec_small = 100000; - int tid_test = 0; - int tid_test2 = 0; - boolean found_track = false; - while(it2!=tshift_rec.end()){ - cout << it2.second << endl; - if(Math.Abs(it2.second) < tshift_rec_small){ - tshift_rec_small = Math.Abs(it2.second); - tid_test = it2.first; - } - - if(Math.Abs(it2.second) < 1000 && genrec > 1){ - double zdiff = Math.Abs(zvertex_rec[it2.first] - Z0); - if(zdiff < 20 && zdiff < zvertex_rec_comp){ - zvertex_rec_comp = Math.Abs(zvertex_rec[it2.first]); - tid_test2 = it2.first; - found_track = true; - } - } - - it2++; - } - cout << tshift_rec_small << endl; - cout << " " << endl; - if(found_track){ - cout << " " << endl; - cout << momentum_rec[tid_test] << " " << mom << endl; - cout << " " << endl; - h2.Fill(momentum_rec[tid_test2]); - hRecvsGenTrue.Fill(mom*1000,momentum_rec[tid_test2]); - hRecvsGenRec.Fill(genrec,momentum_rec[tid_test2]); - } - zvertex_rec.clear(); - tshift_rec.clear(); - momentum_rec.clear();*/ - /*} - h2.draw(); - h1.draw("same"); - h3.draw("same"); - c1.SaveAs("c1.png"); - - TCanvas * c2 = new TCanvas("c2", "Momentum genrec vs gen(MeV)", 800, 800); - hGenRecvsGenTrue.draw("colz"); - c2.SaveAs("c2.png"); - TCanvas * cGenRecvsGenTrue2 = new TCanvas("cGenRecvsGenTrue2", "Momentum genrec vs gen(MeV)", 800, 800); - hGenRecvsGenTrue2.draw("colz"); - cGenRecvsGenTrue2.SaveAs("cGenRecvsGenTrue2.png"); - /* - TCanvas * c3 = new TCanvas("c3", "Momentum rec vs gen(MeV)", 800, 800); - hRecvsGenTrue.draw("colz"); - c3.SaveAs("c3.png"); - TCanvas * c4 = new TCanvas("c4", "Momentum rec vs genrec(MeV)", 800, 800); - hRecvsGenRec.draw("colz"); - c4.SaveAs("c4.png"); - */ - /*TCanvas *c5 = new TCanvas("c5","num gen hits per track", 800, 800); - h4.draw(); - - TCanvas *cZvsTan = new TCanvas("cZvsTan","Z vs Tan(theta)", 800, 800); - TGraph *gZvsTan = new TGraph(4999,theta_all,z_all); - gZvsTan.SetTitle("Z vs Tan(theta);Tan(theta);Z(mm)"); - gZvsTan.SetMarkerStyle(21); - // gZvsTan.GetXaxis().SetLimits(-75,75); - // gZvsTan.GetYaxis().SetRangeUser(-75,75); - gZvsTan.draw("AP"); - cZvsTan.SaveAs("cZvsTan.png"); - - TCanvas *cZvsTanrange = new TCanvas("cZvsTanrange","Z vs Tan(theta)", 800, 800); - TGraph *gZvsTanrange = new TGraph(4999,theta_all,z_all); - gZvsTanrange.SetTitle("Z vs Tan(theta);Tan(theta);Z(mm)"); - gZvsTanrange.SetMarkerStyle(1); - gZvsTanrange.GetXaxis().SetLimits(-100,100); - // gZvsTanrange.GetYaxis().SetRangeUser(-75,75); - gZvsTanrange.draw("AP"); - cZvsTanrange.SaveAs("cZvsTanrange.png"); - - TCanvas *cHitsvsMom = new TCanvas("cHitsvsMom","Num hits vs momentum", 800, 800); - hHitsvsMom.draw("colz"); - cHitsvsMom.SaveAs("cHitsvsMom.png"); - - TCanvas *cHitsvsMom2 = new TCanvas("cHitsvsMom2","Num hits vs momentum", 800, 800); - TGraph *gHitsvsMom = new TGraph(4999,mom_all,num_hits); - gHitsvsMom.SetTitle("Hits vs Mom;Momentum(lund);Number of Hits"); - gHitsvsMom.SetMarkerStyle(1); - gHitsvsMom.SetMarkerColor(kBlack); - gHitsvsMom.draw("AP"); - cHitsvsMom2.SaveAs("cHitsvsMom2.png"); - - TCanvas *cZvsTheta = new TCanvas("cZvsTheta","Z vertex(lund) vs Theta",800,800); - hZvsTheta.draw("colz"); - cZvsTheta.SaveAs("cZvsTheta.png"); - - TCanvas *cMomvsTheta = new TCanvas("cMomvsTheta","Mom vs Theta", 800, 800); - hMomvsTheta.setTitleX("Theta"); - hMomvsTheta.setTitleY("Momentum"); - hMomvsTheta.draw("colz"); - - - TCanvas *cZvsThetaCut = new TCanvas("cZvsThetaCut","Z vertex(lund) vs Theta",800,800); - hZvsThetaCut.draw("colz"); - - - TCanvas *cMomvsThetaCut = new TCanvas("cMomvsThetaCut","Mom vs Theta", 800, 800); - hMomvsThetaCut.setTitleX("Theta"); - hMomvsThetaCut.setTitleY("Momentum"); - hMomvsThetaCut.draw("colz"); - - - TCanvas *cZvsThetaelse = new TCanvas("cZvsThetaelse","Z vertex(lund) vs Theta",800,800); - hZvsThetaelse.draw("colz"); - - - TCanvas *cMomvsThetaelse = new TCanvas("cMomvsThetaelse","Mom vs Theta", 800, 800); - hMomvsThetaelse.setTitleX("Theta"); - hMomvsThetaelse.setTitleY("Momentum"); - hMomvsThetaelse.draw("colz"); - - - - - } - - double xcirc(double t, double r, double ph0){ - - return r*(Math.cos(ph0+t)); + params.set_finaltrackinfomap(finaltrackinfomap); } - double ycirc(double t, double r, double ph0){ - - return r*(Math.sin(ph0+t)); - } - double zcirc(double t, double r, double th){ - - return r*t/Math.tan(th*Math.PI/180); - } -*/ -} -} -class HitVector2{ - - int pad; - double t; - int status; - double z; - double r; - double phi; - double q; - - public HitVector2()//Default constructor - { - pad = status = -1; - t = z = r = phi = q = -1.0; - } - public HitVector2(int _pad, double _t, int _status, double _z, double _r, double _phi, double _q) - { - pad = _pad; - t = _t; - status = _status; - z = _z; - r = _r; - phi = _phi; - q = _q; - } } \ No newline at end of file diff --git a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/HitParameters.java b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/HitParameters.java index b5b79274c4..2ab8a1ada6 100644 --- a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/HitParameters.java +++ b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/HitParameters.java @@ -33,6 +33,7 @@ public class HitParameters { private HashMap _padmap = new HashMap<>(); private TrackMap _trackmap = new TrackMap(); private ReducedTrackMap _rtrackmap = new ReducedTrackMap(); + private HashMap _finaltrackinfomap; public int get_SignalStepSize(){return _SignalStepSize;} // step size of the signal before integration (arbitrary value) public int get_BinSize(){return _BinSize;} // electronics integrates the signal over 40 ns @@ -60,6 +61,7 @@ public class HitParameters { public HashMap> get_recotrackmap() {return _recotrackmap;} public TrackMap get_trackmap() {return _trackmap;} public ReducedTrackMap get_rtrackmap() {return _rtrackmap;} + public HashMap get_finaltrackinfomap() {return _finaltrackinfomap;} public PadVector get_padvector(int pad) { if(!_padmap.containsKey(pad)) { _padmap.put(pad, new PadVector(pad)); @@ -90,7 +92,10 @@ public PadVector get_padvector(int pad) { public void set_recotrackmap(HashMap> _recotrackmap) {this._recotrackmap = _recotrackmap;} public void set_trackmap(TrackMap _trackmap) {this._trackmap = _trackmap;} public void set_rtrackmap(ReducedTrackMap _rtrackmap) {this._rtrackmap = _rtrackmap;} + public void set_finaltrackinfomap(HashMap _finaltrackinfomap) {this._finaltrackinfomap = _finaltrackinfomap;} + public HitParameters() {} + } \ No newline at end of file diff --git a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/SignalSimulation.java b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/SignalSimulation.java index 7e68e0a47e..1541af5541 100644 --- a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/SignalSimulation.java +++ b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/SignalSimulation.java @@ -33,27 +33,19 @@ public SignalSimulation(List rawHits, HitParameters params){ TrigWindSize = params.get_TrigWindSize(); // Trigger window should be 10 micro NTrigSampl = TrigWindSize/BinSize; // number of time samples -//--Creating the signal on pads with 10 ns steps. - for(Hit hit : rawHits){ - CellID = hit.get_cellID(); - Time = hit.get_Time(); - Edep = hit.get_EdepTrue(); - ADCMap.simulateSignal(CellID,Time,Edep); - ADCMap.integrateSignal(CellID); + CellID = hit.get_cellID(); //Pad ID number of the hit + Time = hit.get_Time(); //Time of the hit + Edep = hit.get_EdepTrue(); //Simulated Energy of the hit + ADCMap.simulateSignal(CellID,Time,Edep); //Creates a signal based on the Time and the Energy + ADCMap.integrateSignal(CellID); //Integrates the signal into 120 ns bins based on DREAM elec specifications - if(!PadList.contains(CellID)) PadList.add(CellID); + if(!PadList.contains(CellID)) PadList.add(CellID); //Maintains a list of all unique Pad IDs } params.set_PadList(PadList); params.set_ADCMap(ADCMap); - } - - - - - } diff --git a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TimeAverage.java b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TimeAverage.java index fcd360215a..9aed40629a 100644 --- a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TimeAverage.java +++ b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TimeAverage.java @@ -53,14 +53,14 @@ public TimeAverage(HitParameters params) { sumden = 0; timesbypad = track.PadTimeList(pad); for(int time : timesbypad) { //Loop to calculate maximum adc value - adc = ADCMap.getSignal(pad,time); + adc = ADCMap.getADC(pad,time); if(adc > adcmax) { adcmax = adc; } } adcthresh = adcmax/2; for(int time : timesbypad) { //Loop to calculate weighted average time using ADC values which are above half of the maximum - adc = ADCMap.getSignal(pad,time); + adc = ADCMap.getADC(pad,time); if(adc > adcthresh) { sumnum += adc*time; sumden += adc; diff --git a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TrackFinder.java b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TrackFinder.java index b432de439c..8fc8771d31 100644 --- a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TrackFinder.java +++ b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/TrackFinder.java @@ -52,7 +52,7 @@ public TrackFinder(HitParameters params) { padSorted = false; //Flag to be set when the pad is assigned to a track padTIDlist.clear(); //List of all TIDs assigned to the pad starts empty pad = PadList.get(padindex); - adc = ADCMap.getSignal(pad,time); + adc = ADCMap.getADC(pad,time); if(adc > adcthresh) { //pad adc threshold check PadVector PadVec = params.get_padvector(pad); //initializes the x,y,z,phi for pad diff --git a/reconstruction/rtpc/src/main/java/org/jlab/service/rtpc/RTPCEngine.java b/reconstruction/rtpc/src/main/java/org/jlab/service/rtpc/RTPCEngine.java index ede87d07a1..062ac0f435 100644 --- a/reconstruction/rtpc/src/main/java/org/jlab/service/rtpc/RTPCEngine.java +++ b/reconstruction/rtpc/src/main/java/org/jlab/service/rtpc/RTPCEngine.java @@ -21,7 +21,7 @@ //import org.jlab.rec.rtpc.hit.TrackDisentangler; import org.jlab.rec.rtpc.hit.TrackFinder; import org.jlab.rec.rtpc.hit.TrackHitReco; -//import org.jlab.rec.rtpc.hit.HelixFitTest; +import org.jlab.rec.rtpc.hit.HelixFitTest; @@ -66,10 +66,14 @@ public boolean processDataEvent(DataEvent event) { TimeAverage TA = new TimeAverage(params); //Reconstruct Hits in Drift Region TrackHitReco TR = new TrackHitReco(params); + //Helix Fit Tracks to calculate Track Parameters + HelixFitTest HF = new HelixFitTest(params); RecoBankWriter writer = new RecoBankWriter(); DataBank recoBank = writer.fillRTPCHitsBank(event,params); - event.appendBanks(recoBank); + DataBank trackBank = writer.fillRTPCTrackBank(event,params); + event.appendBanks(recoBank); + event.appendBanks(trackBank); } else{ return true; From dec526a7437da6baa63ee494317e045729be5f9a Mon Sep 17 00:00:00 2001 From: baltzell Date: Thu, 22 Aug 2019 13:38:26 -0400 Subject: [PATCH 032/235] add more detectors to beta calculation --- .../src/main/java/org/jlab/rec/eb/EBUtil.java | 18 ++++ .../java/org/jlab/service/eb/EBAnalyzer.java | 101 ++++++++++-------- 2 files changed, 74 insertions(+), 45 deletions(-) diff --git a/reconstruction/eb/src/main/java/org/jlab/rec/eb/EBUtil.java b/reconstruction/eb/src/main/java/org/jlab/rec/eb/EBUtil.java index 7cb8db0b01..1ea7045c2a 100644 --- a/reconstruction/eb/src/main/java/org/jlab/rec/eb/EBUtil.java +++ b/reconstruction/eb/src/main/java/org/jlab/rec/eb/EBUtil.java @@ -2,6 +2,7 @@ import static java.lang.Math.abs; import static java.lang.Math.pow; +import java.util.List; import org.jlab.clas.detector.DetectorResponse; import org.jlab.clas.detector.DetectorParticle; import org.jlab.detector.base.DetectorType; @@ -78,6 +79,23 @@ else if (resp.getDescriptor().getType()==DetectorType.CTOF) { getDoubleValue("tres",sector,layer,component); } + /** + * Calculate beta for given detector type/layer, prioritized by layer: + */ + public static double getNeutralBeta(DetectorParticle p, DetectorType type, List layers,double startTime) { + double beta=-9999; + for (int layer : layers) { + DetectorResponse resp = p.getHit(type,layer); + if (resp!=null) { + beta = resp.getPosition().mag() / + (resp.getTime()-startTime) / + PhysicsConstants.speedOfLight(); + break; + } + } + return beta; + } + /** * Calculate beta for given detector type/layer, prioritized by layer: */ 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 9df997867a..a63b51e5b5 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 @@ -2,7 +2,11 @@ import static java.lang.Math.abs; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; +import java.util.Map; +import java.util.LinkedHashMap; +import java.util.Map.Entry; import org.jlab.clas.detector.DetectorEvent; import org.jlab.clas.detector.DetectorParticle; @@ -34,9 +38,25 @@ public class EBAnalyzer { static final int[] PID_NEGATIVE = new int[]{ 11, -211,-321,-2212}; static final int[] PID_NEUTRAL = new int[]{22,2112}; + Map > chargedBetaDetectors; + Map > neutralBetaDetectors; + public EBAnalyzer(EBCCDBConstants ccdb,EBRadioFrequency ebrf) { this.ccdb=ccdb; this.ebrf=ebrf; + chargedBetaDetectors=new LinkedHashMap<>(); + chargedBetaDetectors.put(DetectorType.FTOF,Arrays.asList(2,1,3)); + chargedBetaDetectors.put(DetectorType.CTOF,Arrays.asList(0)); + chargedBetaDetectors.put(DetectorType.ECAL,Arrays.asList(1,4,7)); + chargedBetaDetectors.put(DetectorType.HTCC,Arrays.asList(0)); + chargedBetaDetectors.put(DetectorType.CND,Arrays.asList(0)); + chargedBetaDetectors.put(DetectorType.FTCAL,Arrays.asList(0)); + neutralBetaDetectors=new LinkedHashMap<>(); + neutralBetaDetectors.put(DetectorType.ECAL,Arrays.asList(1,4,7)); + neutralBetaDetectors.put(DetectorType.CND,Arrays.asList(0)); + neutralBetaDetectors.put(DetectorType.FTCAL,Arrays.asList(0)); + neutralBetaDetectors.put(DetectorType.FTOF,Arrays.asList(2,1,3)); + neutralBetaDetectors.put(DetectorType.CTOF,Arrays.asList(0)); } @@ -282,6 +302,8 @@ public void assignBetas(DetectorEvent event,final boolean useStartTimeFromFT){ for (DetectorParticle p : event.getParticles()) { double beta = -99; + final double thisStartTime = p.getCharge()==0 ? startTime : p.getStartTime(); + if (p.isTriggerParticle()) { final double mass = PDGDatabase.getParticleById(p.getPid()).mass(); final double mom = p.vector().mag(); @@ -289,36 +311,30 @@ public void assignBetas(DetectorEvent event,final boolean useStartTimeFromFT){ } else { if (p.getCharge()==0) { - if (p.hasHit(DetectorType.ECAL)) { - // NOTE: prioritized by layer: PCAL, else Inner, else Outer - beta = EBUtil.getNeutralBeta(p,DetectorType.ECAL,new int[]{1,4,7},startTime); - } - else if (p.hasHit(DetectorType.CND)) { - beta = EBUtil.getNeutralBeta(p,DetectorType.CND,0,startTime); - } - else if (p.hasHit(DetectorType.FTCAL)) { - beta = EBUtil.getNeutralBeta(p,DetectorType.FTCAL,0,startTime); + for (Entry> bd : neutralBetaDetectors.entrySet()) { + if (p.hasHit(bd.getKey())) { + beta = EBUtil.getNeutralBeta(p,bd.getKey(),bd.getValue(),startTime); + break; + } } } else { - if (p.hasHit(DetectorType.FTOF, 2)==true){ - beta = p.getBeta(DetectorType.FTOF,2, p.getStartTime()); - } - else if(p.hasHit(DetectorType.FTOF, 1)==true){ - beta = p.getBeta(DetectorType.FTOF, 1,p.getStartTime()); - } - else if(p.hasHit(DetectorType.CTOF)==true){ - beta = p.getBeta(DetectorType.CTOF ,p.getStartTime()); - } - else if(p.hasHit(DetectorType.FTOF, 3)==true){ - beta = p.getBeta(DetectorType.FTOF, 3,p.getStartTime()); + boolean found=false; + for (Entry> bd : chargedBetaDetectors.entrySet()) { + for (Integer layer : bd.getValue()) { + if (p.hasHit(bd.getKey(),layer)) { + beta = p.getBeta(bd.getKey(),layer, p.getStartTime()); + found=true; + break; + } + } + if (found) break; } } } p.setBeta(beta); } } - public void assignPids(DetectorEvent event,final boolean useStartTimeFromFT) { PIDHypothesis pidHyp = new PIDHypothesis(); @@ -470,14 +486,17 @@ else if (p.hasHit(DetectorType.CND)) { for (int ii=0; ii> bd : chargedBetaDetectors.entrySet()) { + for (Integer layer : bd.getValue()) { + if (p.hasHit(bd.getKey(),layer)==true) { + dt = p.getVertexTime(bd.getKey(),layer,hypotheses[ii])-p.getStartTime(); + found=true; + break; + } + } + if (found) break; + } if ( abs(dt) < minTimeDiff ) { minTimeDiff=abs(dt); bestPid=hypotheses[ii]; @@ -487,7 +506,6 @@ else if (p.hasHit(DetectorType.FTOF,3)==true) return bestPid; } - /** * Get a basic pid quality factor. * @param p the particle for which to calculate a pid quality factor @@ -511,21 +529,14 @@ else if (abs(pid)==11) { else if (p.getCharge()!=0) { double sigma = -1; double delta_t = 99999; - if (p.hasHit(DetectorType.FTOF,2)==true) { - sigma = EBUtil.getDetTimingResolution(p.getHit(DetectorType.FTOF,2),ccdb); - delta_t = p.getVertexTime(DetectorType.FTOF, 2, pid)-p.getStartTime(); - } - else if (p.hasHit(DetectorType.FTOF,1)==true) { - sigma = EBUtil.getDetTimingResolution(p.getHit(DetectorType.FTOF,1),ccdb); - delta_t = p.getVertexTime(DetectorType.FTOF, 1, pid)-p.getStartTime(); - } - else if (p.hasHit(DetectorType.CTOF)==true) { - sigma = EBUtil.getDetTimingResolution(p.getHit(DetectorType.CTOF,0),ccdb); - delta_t = p.getVertexTime(DetectorType.CTOF, 0, pid)-p.getStartTime(); - } - else if (p.hasHit(DetectorType.FTOF,3)==true) { - sigma = EBUtil.getDetTimingResolution(p.getHit(DetectorType.FTOF,3),ccdb); - delta_t = p.getVertexTime(DetectorType.FTOF, 3, pid)-p.getStartTime(); + + for (Entry> bd : chargedBetaDetectors.entrySet()) { + for (Integer layer : bd.getValue()) { + if (p.hasHit(bd.getKey(),layer)==true) { + sigma = 1;//EBUtil.getDetTimingResolution(p.getHit(bd.getKey(),layer),ccdb); + delta_t = p.getVertexTime(bd.getKey(),layer, pid)-p.getStartTime(); + } + } } q = delta_t / sigma; } From 5e023d467d74eb6022b9e6c4fb9dc702f118176c Mon Sep 17 00:00:00 2001 From: baltzell Date: Thu, 22 Aug 2019 21:14:33 -0400 Subject: [PATCH 033/235] set timing resolution to zero for non-TOF --- .../eb/src/main/java/org/jlab/rec/eb/EBUtil.java | 2 +- .../src/main/java/org/jlab/service/eb/EBAnalyzer.java | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/reconstruction/eb/src/main/java/org/jlab/rec/eb/EBUtil.java b/reconstruction/eb/src/main/java/org/jlab/rec/eb/EBUtil.java index 1ea7045c2a..13fe86df54 100644 --- a/reconstruction/eb/src/main/java/org/jlab/rec/eb/EBUtil.java +++ b/reconstruction/eb/src/main/java/org/jlab/rec/eb/EBUtil.java @@ -73,7 +73,7 @@ else if (resp.getDescriptor().getType()==DetectorType.CTOF) { return 0.065; } else { - throw new RuntimeException("not ready for non-TOF"); + return 0;//throw new RuntimeException("not ready for non-TOF"); } return ccdb.getTable(tableName). getDoubleValue("tres",sector,layer,component); 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 a63b51e5b5..ab097e5979 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 @@ -44,6 +44,8 @@ public class EBAnalyzer { public EBAnalyzer(EBCCDBConstants ccdb,EBRadioFrequency ebrf) { this.ccdb=ccdb; this.ebrf=ebrf; + + // setup prioritization on timing detectors: chargedBetaDetectors=new LinkedHashMap<>(); chargedBetaDetectors.put(DetectorType.FTOF,Arrays.asList(2,1,3)); chargedBetaDetectors.put(DetectorType.CTOF,Arrays.asList(0)); @@ -530,13 +532,18 @@ else if (p.getCharge()!=0) { double sigma = -1; double delta_t = 99999; + boolean found=false; for (Entry> bd : chargedBetaDetectors.entrySet()) { for (Integer layer : bd.getValue()) { if (p.hasHit(bd.getKey(),layer)==true) { - sigma = 1;//EBUtil.getDetTimingResolution(p.getHit(bd.getKey(),layer),ccdb); - delta_t = p.getVertexTime(bd.getKey(),layer, pid)-p.getStartTime(); + sigma = EBUtil.getDetTimingResolution(p.getHit(bd.getKey(),layer),ccdb); + if (sigma>0) delta_t = p.getVertexTime(bd.getKey(),layer, pid)-p.getStartTime(); + found=true; + break; } + if (found) break; } + if (found) break; } q = delta_t / sigma; } From 03138174ef98a0e95e610e045dbd2bc20091ab76 Mon Sep 17 00:00:00 2001 From: ziegler Date: Mon, 26 Aug 2019 17:04:23 -0400 Subject: [PATCH 034/235] New Fitting algorithm using docas to the wires. --- .../main/java/org/jlab/rec/dc/Constants.java | 5 + .../java/org/jlab/rec/dc/banks/HitReader.java | 8 +- .../dc/cluster/ClusterCleanerUtilities.java | 2 + .../jlab/rec/dc/cluster/ClusterFinder.java | 1 + .../java/org/jlab/rec/dc/hit/FittedHit.java | 50 +- .../rec/dc/timetodistance/TableLoader.java | 36 +- .../TimeToDistanceEstimator.java | 24 +- .../rec/dc/track/TrackCandListFinder.java | 1 + .../jlab/rec/dc/track/fit/KFitterDoca.java | 340 ++++++++++++ .../org/jlab/rec/dc/track/fit/MeasVecs.java | 1 - .../jlab/rec/dc/track/fit/MeasVecsDoca.java | 261 +++++++++ .../jlab/rec/dc/track/fit/RungeKuttaDoca.java | 511 ++++++++++++++++++ .../jlab/rec/dc/track/fit/StateVecsDoca.java | 457 ++++++++++++++++ .../rec/dc/trajectory/TrajectorySurfaces.java | 20 +- .../java/org/jlab/service/dc/DCHBEngine.java | 2 + .../java/org/jlab/service/dc/DCTBEngine.java | 3 +- 16 files changed, 1681 insertions(+), 41 deletions(-) create mode 100644 reconstruction/dc/src/main/java/org/jlab/rec/dc/track/fit/KFitterDoca.java create mode 100644 reconstruction/dc/src/main/java/org/jlab/rec/dc/track/fit/MeasVecsDoca.java create mode 100644 reconstruction/dc/src/main/java/org/jlab/rec/dc/track/fit/RungeKuttaDoca.java create mode 100644 reconstruction/dc/src/main/java/org/jlab/rec/dc/track/fit/StateVecsDoca.java diff --git a/reconstruction/dc/src/main/java/org/jlab/rec/dc/Constants.java b/reconstruction/dc/src/main/java/org/jlab/rec/dc/Constants.java index 95ff57d7cd..a14d1e2fb8 100644 --- a/reconstruction/dc/src/main/java/org/jlab/rec/dc/Constants.java +++ b/reconstruction/dc/src/main/java/org/jlab/rec/dc/Constants.java @@ -85,6 +85,8 @@ public class Constants { public static final double SEGMENTPLANESANGLE = 1.5; // the angle between the normals to the segment fit planes is 12 degrees (6+6 for +/- stereo relative angles) + 1.5 degrees tolerance. This number (1.5) should be optimized public static final double ARGONRADLEN = 14; // radiation length in Argon is 14 cm + + public static final double AIRRADLEN = 30400; // radiation length in cm public static final double SWIMSTEPSIZE = 5.00*1.e-4; //n00 microns @@ -108,6 +110,8 @@ public class Constants { public static final int[] SNR_RIGHTSHIFTS = {0,1,2,2,4,4}; public static final int[] SNR_LEFTSHIFTS = {0,1,2,2,4,4}; + // Z Range for MS + public static double[] Z = new double[13]; // Arrays for combinatorial cluster compositions private static final int[][] CombArray1Layer = new int[][]{ @@ -167,6 +171,7 @@ public class Constants { public static double BETALOW = 0.15; //max number of hits allowed in the event to do tracking public static double MAXHITS = 2000; + ; public static boolean isUSETSTART() { return USETSTART; diff --git a/reconstruction/dc/src/main/java/org/jlab/rec/dc/banks/HitReader.java b/reconstruction/dc/src/main/java/org/jlab/rec/dc/banks/HitReader.java index eb08cb2506..64220ce484 100644 --- a/reconstruction/dc/src/main/java/org/jlab/rec/dc/banks/HitReader.java +++ b/reconstruction/dc/src/main/java/org/jlab/rec/dc/banks/HitReader.java @@ -335,7 +335,7 @@ public void read_HBHits(DataEvent event, IndexedTable constants0, IndexedTable c hit.calc_CellSize(DcDetector); hit.calc_GeomCorr(DcDetector, 0); hit.set_ClusFitDoca(trkDoca[i]); - hit.set_TimeToDistance(event, 1.0, B[i], constants1, tde); + hit.set_TimeToDistance(event, 0.0, B[i], constants1, tde); hit.set_QualityFac(0); if (hit.get_Doca() > hit.get_CellSize()) { @@ -349,8 +349,8 @@ public void read_HBHits(DataEvent event, IndexedTable constants0, IndexedTable c hit.set_AssociatedClusterID(clusterID[i]); hit.set_AssociatedHBTrackID(trkID[i]); - hits.add(hit); - + if(hit.betaFlag != -1) + hits.add(hit); } this.set_HBHits(hits); @@ -358,9 +358,9 @@ public void read_HBHits(DataEvent event, IndexedTable constants0, IndexedTable c //betaFlag:0 = OK; -1 = negative; 1 = less than lower cut (0.15); 2 = greater than 1.15 (from HBEB beta vs p plots for data) private void set_BetaFlag(DataEvent event, int trkId, FittedHit hit, double beta) { if(beta<0.15) { - this.set_ToPionHypothesis(event, trkId, hit); if(beta<0) { hit.betaFlag = -1; + this.set_ToPionHypothesis(event, trkId, hit); } else { hit.betaFlag = 1; } diff --git a/reconstruction/dc/src/main/java/org/jlab/rec/dc/cluster/ClusterCleanerUtilities.java b/reconstruction/dc/src/main/java/org/jlab/rec/dc/cluster/ClusterCleanerUtilities.java index af590f966a..b92eb436c1 100644 --- a/reconstruction/dc/src/main/java/org/jlab/rec/dc/cluster/ClusterCleanerUtilities.java +++ b/reconstruction/dc/src/main/java/org/jlab/rec/dc/cluster/ClusterCleanerUtilities.java @@ -376,6 +376,7 @@ public FittedCluster LRAmbiguityResolver(DataEvent event, FittedCluster fClus, newhitPos.set_DeltaTimeBeta(hit.get_DeltaTimeBeta()); newhitPos.setTStart(hit.getTStart()); newhitPos.setTProp(hit.getTProp()); + newhitPos.betaFlag= hit.betaFlag; newhitPos.setTFlight(hit.getTFlight()); newhitPos.set_Time(hit.get_Time()); newhitPos.set_Id(hit.get_Id()); @@ -402,6 +403,7 @@ public FittedCluster LRAmbiguityResolver(DataEvent event, FittedCluster fClus, newhitNeg.set_DeltaTimeBeta(hit.get_DeltaTimeBeta()); newhitNeg.setTStart(hit.getTStart()); newhitNeg.setTProp(hit.getTProp()); + newhitNeg.betaFlag= hit.betaFlag; newhitNeg.setTFlight(hit.getTFlight()); newhitNeg.set_Time(hit.get_Time()); newhitNeg.set_Id(hit.get_Id()); diff --git a/reconstruction/dc/src/main/java/org/jlab/rec/dc/cluster/ClusterFinder.java b/reconstruction/dc/src/main/java/org/jlab/rec/dc/cluster/ClusterFinder.java index f916b36c8a..ba91964910 100644 --- a/reconstruction/dc/src/main/java/org/jlab/rec/dc/cluster/ClusterFinder.java +++ b/reconstruction/dc/src/main/java/org/jlab/rec/dc/cluster/ClusterFinder.java @@ -380,6 +380,7 @@ public List FindTimeBasedClusters(DataEvent event, newhit.set_DeltaTimeBeta(hit.get_DeltaTimeBeta()); newhit.setTStart(hit.getTStart()); newhit.setTProp(hit.getTProp()); + newhit.betaFlag= hit.betaFlag; newhit.setTFlight(hit.getTFlight()); newhit.set_Time(hit.get_Time()); newhit.set_Id(hit.get_Id()); diff --git a/reconstruction/dc/src/main/java/org/jlab/rec/dc/hit/FittedHit.java b/reconstruction/dc/src/main/java/org/jlab/rec/dc/hit/FittedHit.java index e05fb1e0fa..23c0ba1dcb 100644 --- a/reconstruction/dc/src/main/java/org/jlab/rec/dc/hit/FittedHit.java +++ b/reconstruction/dc/src/main/java/org/jlab/rec/dc/hit/FittedHit.java @@ -8,6 +8,7 @@ import org.jlab.rec.dc.Constants; import org.jlab.rec.dc.timetodistance.TimeToDistanceEstimator; import org.jlab.geom.prim.Point3D; +import org.jlab.geom.prim.Vector3D; import org.jlab.io.base.DataEvent; import org.jlab.rec.dc.trajectory.StateVec; import org.jlab.utils.groups.IndexedTable; @@ -178,7 +179,7 @@ public double get_PosErr(DataEvent event, double B, IndexedTable constants0, Ind if (this._TrkgStatus != -1) { if (this.get_TimeToDistance() == 0) // if the time-to-dist is not set ... set it { - set_TimeToDistance(event, 1.0, B, constants1, tde); + set_TimeToDistance(event, 0.0, B, constants1, tde); } double x = this.get_Doca() / this.get_CellSize(); @@ -501,7 +502,8 @@ public void updateHitPosition(DCGeant4Factory DcDetector) { * A method to update the hit position information after the fit to the wire * positions employing hit-based tracking algorithms has been performed. */ - public void updateHitPositionWithTime(DataEvent event, double trkAngle, double B, IndexedTable tab, DCGeant4Factory DcDetector, TimeToDistanceEstimator tde) { + public void updateHitPositionWithTime(DataEvent event, double trkAngle, double B, + IndexedTable tab, DCGeant4Factory DcDetector, TimeToDistanceEstimator tde) { if (this.get_Time() > 0) { this.set_TimeToDistance(event, trkAngle, B, tab, tde); } @@ -515,10 +517,18 @@ public void updateHitPositionWithTime(DataEvent event, double trkAngle, double B MPCorr = cosTkAng; } - this.set_X(x + this.get_LeftRightAmb() * (this.get_TimeToDistance() / MPCorr) / FastMath.cos(Math.toRadians(6.))); + this.set_X(x + this.get_LeftRightAmb() * (this.get_TimeToDistance() / MPCorr) );/// FastMath.cos(Math.toRadians(6.))); } - + public double corrForMidPlaneProjection(double trkAngle, Line3D wireLine, FittedHit hit) { + double tilt = 90-Math.toDegrees(wireLine.direction().asUnit().angle(new Vector3D(1,0,0))); + double MPCorr = 1; + double cosTkAng = 1./Math.sqrt(trkAngle*trkAngle + 1.); + if (cosTkAng > 0.8 & cosTkAng <= 1) { + MPCorr = cosTkAng; + } + return MPCorr ; + } //public double XatY(DCGeant4Factory DcDetector, double y) { // double x = this.calc_GeomCorr(DcDetector, y); // return x + this.get_LeftRightAmb() * (this.get_TimeToDistance()) ; @@ -625,7 +635,8 @@ public void calc_GeomCorr(DCGeant4Factory DcDetector, double y) { double delta_x = MaxSag*(1.-Math.abs(y)/(0.5*wireLen))*(1.-Math.abs(y)/(0.5*wireLen)); x+=delta_x; - Line3D wireLine = new Line3D(new Point3D(xL, yL, 0), new Point3D(xR, yR, 0)); + Line3D wireLine = new Line3D(new Point3D(xL, yL, z), new Point3D(xR, yR, z)); + wireLine.setOrigin(x, y, z); this.set_WireLength(wireLen); this.set_WireMaxSag(MaxSag); this.set_WireLine(wireLine); @@ -961,5 +972,34 @@ public double get_Beta0to1() { beta=1.0; return beta; } + + //make a copy + public FittedHit clone() throws CloneNotSupportedException { + FittedHit hitClone = new FittedHit(this.get_Sector(), this.get_Superlayer(), this.get_Layer(), this.get_Wire(), + this.get_TDC(), this.get_Id()); + hitClone.set_Doca(this.get_Doca()); + hitClone.set_DocaErr(this.get_DocaErr()); + hitClone.setT0(this.getT0()); + hitClone.set_Beta(this.get_Beta()); + hitClone.setB(this.getB()); + hitClone.set_DeltaTimeBeta(this.get_DeltaTimeBeta()); + hitClone.setTStart(this.getTStart()); + hitClone.setTProp(this.getTProp()); + hitClone.setTFlight(this.getTFlight()); + hitClone.set_Time(this.get_Time()); + hitClone.set_Id(this.get_Id()); + hitClone.set_ClusFitDoca(this.get_ClusFitDoca()); + hitClone.set_LeftRightAmb(this.get_LeftRightAmb()); + hitClone.set_X(this.get_X()); + hitClone.set_Z(this.get_Z()); + hitClone.setAlpha(this.getAlpha()); + hitClone.set_CellSize(this.get_CellSize()); + hitClone.set_AssociatedClusterID(this.get_AssociatedClusterID()); + hitClone.set_AssociatedHBTrackID(this.get_AssociatedHBTrackID()); + hitClone.betaFlag = this.betaFlag; + + return hitClone; + } + } diff --git a/reconstruction/dc/src/main/java/org/jlab/rec/dc/timetodistance/TableLoader.java b/reconstruction/dc/src/main/java/org/jlab/rec/dc/timetodistance/TableLoader.java index 364e9f7570..2d939eb5c4 100644 --- a/reconstruction/dc/src/main/java/org/jlab/rec/dc/timetodistance/TableLoader.java +++ b/reconstruction/dc/src/main/java/org/jlab/rec/dc/timetodistance/TableLoader.java @@ -36,26 +36,25 @@ public TableLoader() { */ public static void test(){ TimeToDistanceEstimator tde = new TimeToDistanceEstimator(); - for(int s = 0; s<6; s++ ){ // loop over sectors - for(int r = 0; r<6; r++ ){ //loop over slys - for(int ibfield =0; ibfield1) - DISTFROMTIME[s][r][ibfield][icosalpha][tb]=DISTFROMTIME[s][r][ibfield][icosalpha][tb-1]; - if(DISTFROMTIME[s][r][ibfield][icosalpha][tb]==0) - System.out.println("Bbin "+ibfield+" cos "+icosalpha+" tb "+tb); - //double Xalpha = -(Math.toDegrees(Math.acos(Math.cos(Math.toRadians(30.)) + (icosalpha)*(1. - Math.cos(Math.toRadians(30.)))/5.)) - 30.); - //double Xtime=(2*tb+1); + + + double Xalpha = -(Math.toDegrees(Math.acos(Math.cos(Math.toRadians(30.)) + (icosalpha)*(1. - Math.cos(Math.toRadians(30.)))/5.)) - 30.); + double Xtime=(2*tb+1); //for (int k=0; k<10; k++){ - //double Bf = (ibfield+0.1*k)*0.5; - //int bbin = tde.getBIdx(Bf); - //double Xdoca=tde.interpolateOnGrid((double) Bf, Xalpha, Xtime, s, r); - // System.out.println("Bbin "+ibfield+" B "+ (float)Bf+" sl "+(r+1)+" time "+Xtime+" tb "+tb+" timeBin "+tde.getTimeIdx(Xtime, s, r, ibfield, icosalpha) - // +" icosalpha "+icosalpha+" Xalpha "+(float) Xalpha + " dis "+ (float)DISTFROMTIME[s][r][bbin][icosalpha][tde.getTimeIdx(Xtime, s, r, ibfield, icosalpha)] +" dis' "+ - // (float) Xdoca ); + double Bf = (ibfield)*0.5; + int bbin = tde.getBIdx(Bf); + double Xdoca=tde.interpolateOnGrid((double) Bf, Xalpha, Xtime, s, r); + System.out.println("Bbin "+ibfield+" B "+ (float)Bf+" sl "+(r+1)+" time "+Xtime+" tb "+tb+" timeBin "+tde.getTimeIdx(Xtime, s, r, ibfield, icosalpha) + +" icosalpha "+icosalpha+" Xalpha "+(float) Xalpha + " dis "+ (float)DISTFROMTIME[s][r][bbin][icosalpha][tde.getTimeIdx(Xtime, s, r, ibfield, icosalpha)] +" dis' "+ + (float) Xdoca ); //} } @@ -131,7 +130,7 @@ public static synchronized void Fill(IndexedTable tab) { //CCDBTables 1 = "/calibration/dc/time_to_distance/t2d"; //CCDBTables 2 = "/calibration/dc/time_corrections/T0_correction"; if (T2DLOADED) return; - System.out.println(" T2D TABLE FILLED....."); + double stepSize = 0.0010; DecimalFormat df = new DecimalFormat("#"); df.setRoundingMode(RoundingMode.CEILING); @@ -201,7 +200,8 @@ public static synchronized void Fill(IndexedTable tab) { } } TableLoader.fillMissingTableBins(); - + TableLoader.test(); + System.out.println(" T2D TABLE FILLED....."); T2DLOADED = true; } diff --git a/reconstruction/dc/src/main/java/org/jlab/rec/dc/timetodistance/TimeToDistanceEstimator.java b/reconstruction/dc/src/main/java/org/jlab/rec/dc/timetodistance/TimeToDistanceEstimator.java index b8dd441dba..d91a2cc860 100644 --- a/reconstruction/dc/src/main/java/org/jlab/rec/dc/timetodistance/TimeToDistanceEstimator.java +++ b/reconstruction/dc/src/main/java/org/jlab/rec/dc/timetodistance/TimeToDistanceEstimator.java @@ -72,7 +72,7 @@ public double interpolateOnGrid(double Bf, double alpha, double t, int SecIdx, double alpha1 = this.getAlphaFromAlphaIdx(binlowAlpha); double alpha2 = this.getAlphaFromAlphaIdx(binhighAlpha); - + // interpolate in B: double f_B_alpha1_t1 = interpolateLinear(B*B, B1*B1, B2*B2, TableLoader.DISTFROMTIME[SecIdx][SlyrIdx][binlowB][binlowAlpha][this.getTimeIdx(t, SecIdx, SlyrIdx, binlowB, binlowAlpha)], @@ -89,21 +89,23 @@ public double interpolateOnGrid(double Bf, double alpha, double t, int SecIdx, // interpolate in d for 2 values of alpha: double f_B_alpha1_t = interpolateLinear(t, this.getTimeIdx(t, SecIdx, SlyrIdx, binlowB, binlowAlpha)*2., this.getTimeNextIdx(t, SecIdx, SlyrIdx, binhighB, binlowAlpha)*2., f_B_alpha1_t1, f_B_alpha1_t2); double f_B_alpha2_t = interpolateLinear(t, this.getTimeIdx(t, SecIdx, SlyrIdx, binlowB, binhighAlpha)*2., this.getTimeNextIdx(t, SecIdx, SlyrIdx, binhighB, binhighAlpha)*2., f_B_alpha2_t1, f_B_alpha2_t2); -//if( TableLoader.DISTFROMTIME[SecIdx][SlyrIdx][binlowB][binlowAlpha][this.getTimeIdx(t, SecIdx, SlyrIdx, binlowB, binlowAlpha)]==0) -// System.out.println(SlyrIdx+" binlowB "+binlowB+" binlowAlpha "+binlowAlpha+" t "+this.getTimeIdx(t, SecIdx, SlyrIdx, binlowB, binlowAlpha)+" time "+t); -//if(TableLoader.DISTFROMTIME[SecIdx][SlyrIdx][binlowB][binhighAlpha][this.getTimeIdx(t, SecIdx, SlyrIdx, binlowB, binhighAlpha)]==0) -// System.out.println(SlyrIdx+" binlowB "+binlowB+" binhighAlpha "+binhighAlpha+" t "+this.getTimeIdx(t, SecIdx, SlyrIdx, binlowB, binhighAlpha)+" time "+t); -//if(TableLoader.DISTFROMTIME[SecIdx][SlyrIdx][binhighB][binlowAlpha][this.getTimeIdx(t, SecIdx, SlyrIdx, binhighB, binlowAlpha)]==0) -// System.out.println(SlyrIdx+" binhighB "+binhighB+" binlowAlpha "+binlowAlpha+" t "+this.getTimeIdx(t, SecIdx, SlyrIdx, binhighB, binlowAlpha)+" time "+t); -//if(TableLoader.DISTFROMTIME[SecIdx][SlyrIdx][binhighB][binhighAlpha][this.getTimeIdx(t, SecIdx, SlyrIdx, binhighB, binhighAlpha)]==0) -// System.out.println(SlyrIdx+" binhighB "+binhighB+" binhighAlpha "+binhighAlpha+" t "+this.getTimeIdx(t, SecIdx, SlyrIdx, binhighB, binhighAlpha)+" time "+t); - + //System.out.println( TableLoader.DISTFROMTIME[SecIdx][SlyrIdx][binlowB][binlowAlpha][this.getTimeIdx(t, SecIdx, SlyrIdx, binlowB, binlowAlpha)]); + //System.out.println(SlyrIdx+" binlowB "+binlowB+" binlowAlpha "+binlowAlpha+" t "+this.getTimeIdx(t, SecIdx, SlyrIdx, binlowB, binlowAlpha)+" time "+t); + //System.out.println(TableLoader.DISTFROMTIME[SecIdx][SlyrIdx][binlowB][binhighAlpha][this.getTimeIdx(t, SecIdx, SlyrIdx, binlowB, binhighAlpha)]); + //System.out.println(SlyrIdx+" binlowB "+binlowB+" binhighAlpha "+binhighAlpha+" t "+this.getTimeIdx(t, SecIdx, SlyrIdx, binlowB, binhighAlpha)+" time "+t); + //System.out.println(TableLoader.DISTFROMTIME[SecIdx][SlyrIdx][binhighB][binlowAlpha][this.getTimeIdx(t, SecIdx, SlyrIdx, binhighB, binlowAlpha)]); + //System.out.println(SlyrIdx+" binhighB "+binhighB+" binlowAlpha "+binlowAlpha+" t "+this.getTimeIdx(t, SecIdx, SlyrIdx, binhighB, binlowAlpha)+" time "+t); + //System.out.println(TableLoader.DISTFROMTIME[SecIdx][SlyrIdx][binhighB][binhighAlpha][this.getTimeIdx(t, SecIdx, SlyrIdx, binhighB, binhighAlpha)]); + //System.out.println(SlyrIdx+" binhighB "+binhighB+" binhighAlpha "+binhighAlpha+" t "+this.getTimeIdx(t, SecIdx, SlyrIdx, binhighB, binhighAlpha)+" time "+t); + //System.out.println(" f_B_alpha1_t1 "+f_B_alpha1_t1+" f_B_alpha2_t1 "+f_B_alpha2_t1 + // +" f_B_alpha1_t2 "+f_B_alpha1_t2+" f_B_alpha2_t2 "+f_B_alpha2_t2 + // +" f_B_alpha1_t "+f_B_alpha1_t+" f_B_alpha2_t "+f_B_alpha2_t); + // interpolate in alpha: (cos30-cosA) double f_B_alpha_t = interpolateLinear(Math.cos(Math.toRadians(30.))-Math.cos(Math.toRadians(alpha)), Math.cos(Math.toRadians(30.))-Math.cos(Math.toRadians(alpha1)), Math.cos(Math.toRadians(30.))-Math.cos(Math.toRadians(alpha2)), f_B_alpha1_t, f_B_alpha2_t); - return f_B_alpha_t; /* diff --git a/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/TrackCandListFinder.java b/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/TrackCandListFinder.java index 42fcbb9971..f381e05890 100755 --- a/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/TrackCandListFinder.java +++ b/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/TrackCandListFinder.java @@ -13,6 +13,7 @@ import org.jlab.rec.dc.hit.FittedHit; import org.jlab.rec.dc.segment.Segment; import org.jlab.rec.dc.track.fit.KFitter; +//import org.jlab.rec.dc.track.fit.KFitterDoca; import org.jlab.rec.dc.trajectory.StateVec; import org.jlab.rec.dc.trajectory.Trajectory; import org.jlab.rec.dc.trajectory.TrajectoryFinder; diff --git a/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/fit/KFitterDoca.java b/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/fit/KFitterDoca.java new file mode 100644 index 0000000000..a920462c26 --- /dev/null +++ b/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/fit/KFitterDoca.java @@ -0,0 +1,340 @@ +package org.jlab.rec.dc.track.fit; + +import Jama.Matrix; + +import java.util.ArrayList; +import java.util.List; + +import org.jlab.clas.swimtools.Swim; +import org.jlab.detector.geant4.v2.DCGeant4Factory; +import org.jlab.rec.dc.track.Track; +import org.jlab.rec.dc.track.fit.StateVecsDoca.CovMat; +import org.jlab.rec.dc.track.fit.StateVecsDoca.StateVec; + + +/** + * @author ziegler + */ +public class KFitterDoca { + + public boolean setFitFailed = false; + + private StateVecsDoca sv; + private MeasVecsDoca mv = new MeasVecsDoca(); + + public StateVec finalStateVec; + public CovMat finalCovMat; + public List kfStateVecsAlongTrajectory; + public int totNumIter = 30; + private double newChisq = Double.POSITIVE_INFINITY; + + public double chi2 = 0; + private double chi2kf = 0; + public int NDF = 0; + public int ConvStatus = 1; + + public KFitterDoca(Track trk, DCGeant4Factory DcDetector, + boolean TimeBasedUsingHBtrack, + Swim swimmer) { + sv = new StateVecsDoca(swimmer); + if (TimeBasedUsingHBtrack) { + this.initFromHB(trk, DcDetector); + } else { + this.init(trk, DcDetector); + } + } + + private void initFromHB(Track trk, DCGeant4Factory DcDetector) { + mv.setMeasVecsFromHB(trk, DcDetector); + int mSize = mv.measurements.size(); + sv.Z = new double[mSize]; + + for (int i = 0; i < mSize; i++) { + sv.Z[i] = mv.measurements.get(i).z; + } + sv.initFromHB(trk, sv.Z[0], this); + } + + public void init(Track trk, DCGeant4Factory DcDetector) { + mv.setMeasVecs(trk, DcDetector); + int mSize = mv.measurements.size(); + + sv.Z = new double[mSize]; + + for (int i = 0; i < mSize; i++) { + sv.Z[i] = mv.measurements.get(i).z; + } + sv.init(trk, sv.Z[0], this); + } + public int interNum = 0; + public void runFitter(int sector) { + this.chi2 = 0; + this.NDF = mv.ndf; + int svzLength = sv.Z.length; + +// IntStream.range(1,totNumIter ).parallel().forEach(i -> { + for (int i = 1; i <= totNumIter; i++) { + interNum = i; + this.chi2kf = 0; + if (i > 1) { + //get new state vec at 1st measurement after propagating back from the last filtered state + /*sv.transport(sector, + svzLength - 1, + 0, + sv.trackTraj.get(svzLength - 1), + sv.trackCov.get(svzLength- 1)); */ + for (int k = svzLength - 1; k >0; k--) { + //if(i==2 && this.totNumIter==30) + //System.out.println("sector " +sector+"stateVec "+sv.trackTraj.get(k).printInfo()); + if(k>=2) { + sv.transport(sector, k, k - 2, + sv.trackTraj.get(k), + sv.trackCov.get(k)); + this.filter(k - 2); + sv.transport(sector, k - 2, k - 1, + sv.trackTraj.get(k - 2), + sv.trackCov.get(k - 2)); + this.filter(k - 1); + } else { + sv.transport(sector, 1, 0, + sv.trackTraj.get(1), + sv.trackCov.get(1)); + this.filter(0); + } + } + } + for (int k = 0; k < svzLength - 1; k++) { + //if(i==2 && this.totNumIter==30) + //System.out.println("stateVec "+sv.trackTraj.get(k).printInfo()); + sv.transport(sector, k, k + 1, + sv.trackTraj.get(k), + sv.trackCov.get(k)); + this.filter(k + 1); + } + if (i > 1) { + if(this.setFitFailed==true) + i = totNumIter; + if (this.setFitFailed==false) { + if(this.finalStateVec!=null) { + if(Math.abs(sv.trackTraj.get(svzLength - 1).Q-this.finalStateVec.Q)<5.e-4 && + Math.abs(sv.trackTraj.get(svzLength - 1).x-this.finalStateVec.x)<1.e-4 && + Math.abs(sv.trackTraj.get(svzLength - 1).y-this.finalStateVec.y)<1.e-4 && + Math.abs(sv.trackTraj.get(svzLength - 1).tx-this.finalStateVec.tx)<1.e-6 && + Math.abs(sv.trackTraj.get(svzLength - 1).ty-this.finalStateVec.ty)<1.e-6) { + i = totNumIter; + } + } + this.finalStateVec = sv.trackTraj.get(svzLength - 1); + this.finalCovMat = sv.trackCov.get(svzLength - 1); + + } else { + this.ConvStatus = 1; + } + } + } +// }); + if(totNumIter==1) { + this.finalStateVec = sv.trackTraj.get(svzLength - 1); + this.finalCovMat = sv.trackCov.get(svzLength - 1); + } + this.calcFinalChisq(sector); + + } + + public Matrix filterCovMat(double[] H, Matrix C, double V) { + Matrix Ci; + + if (!this.isNonsingular(C)) { + return null; + } + try { + Ci = C.inverse(); + } catch (Exception e) { + return null; + } + double[][] HTGH = new double[][]{ + {H[0] * H[0] / V, H[0] * H[1] / V, 0, 0, 0}, + {H[0] * H[1] / V, H[1] * H[1] / V, 0, 0, 0}, + {0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0} + }; + Matrix Ca; + try { + Ca = Ci.plus(new Matrix(HTGH)); + } catch (Exception e) { + return null; + } + if (Ca != null && !this.isNonsingular(Ca)) { + return null; + } + if (Ca != null) { + Matrix CaInv = Ca.inverse(); + if (CaInv != null) { + return CaInv; + } else { + return null; + } + } else { + return null; + } + } + private void filter(int k) { + if (sv.trackTraj.get(k) != null && + sv.trackCov.get(k).covMat != null && + k < sv.Z.length + && mv.measurements.get(k).reject==false) { + + + double[] K = new double[5]; + double V = mv.measurements.get(k).unc[0]*4; + double[] H = mv.H(new double[]{sv.trackTraj.get(k).x, sv.trackTraj.get(k).y}, + mv.measurements.get(k).z, + mv.measurements.get(k).wireLine[0]); + Matrix CaInv = this.filterCovMat(H, sv.trackCov.get(k).covMat, V); + if (CaInv != null) { + sv.trackCov.get(k).covMat = CaInv; + } else { + return; + } + + for (int j = 0; j < 5; j++) { + // the gain matrix + K[j] = (H[0] * sv.trackCov.get(k).covMat.get(j, 0) + + H[1] * sv.trackCov.get(k).covMat.get(j, 1)) / V; + } + + double h = mv.h(new double[]{sv.trackTraj.get(k).x, sv.trackTraj.get(k).y}, + mv.measurements.get(k).z, + mv.measurements.get(k).wireLine[0]); + + double sign = Math.signum(mv.measurements.get(k).doca[0]); + //if(this.interNum>1) + // sign = Math.signum(h); + double c2 = ((sign*Math.abs(mv.measurements.get(k).doca[0]) - h) * (sign*Math.abs(mv.measurements.get(k).doca[0]) - h) / V); + //if(sign!=Math.signum(h) && this.interNum>1) System.out.println(sv.trackTraj.get(k).printInfo()+" h "+(float)h); + double x_filt = sv.trackTraj.get(k).x + K[0] * (sign*Math.abs(mv.measurements.get(k).doca[0]) - h); + double y_filt = sv.trackTraj.get(k).y + K[1] * (sign*Math.abs(mv.measurements.get(k).doca[0]) - h); + double tx_filt = sv.trackTraj.get(k).tx + K[2] * (sign*Math.abs(mv.measurements.get(k).doca[0]) - h); + double ty_filt = sv.trackTraj.get(k).ty + K[3] * (sign*Math.abs(mv.measurements.get(k).doca[0]) - h); + double Q_filt = sv.trackTraj.get(k).Q + K[4] * (sign*Math.abs(mv.measurements.get(k).doca[0]) - h); + + //USE THE DOUBLE HIT + if(mv.measurements.get(k).doca[1]!=-99) { + //now filter using the other Hit + V = mv.measurements.get(k).unc[1]*4; + H = mv.H(new double[]{x_filt, y_filt}, + mv.measurements.get(k).z, + mv.measurements.get(k).wireLine[1]); + CaInv = this.filterCovMat(H, sv.trackCov.get(k).covMat, V); + if (CaInv != null) { + sv.trackCov.get(k).covMat = CaInv; + } else { + return; + } + for (int j = 0; j < 5; j++) { + // the gain matrix + K[j] = (H[0] * sv.trackCov.get(k).covMat.get(j, 0) + + H[1] * sv.trackCov.get(k).covMat.get(j, 1)) / V; + } + h=mv.h(new double[]{x_filt, y_filt}, + mv.measurements.get(k).z, + mv.measurements.get(k).wireLine[1]); + + sign = Math.signum(mv.measurements.get(k).doca[1]); + //if(this.interNum>1) + // sign = Math.signum(h); + + x_filt += K[0] * (sign*Math.abs(mv.measurements.get(k).doca[1]) - h); + y_filt += K[1] * (sign*Math.abs(mv.measurements.get(k).doca[1]) - h); + tx_filt += K[2] * (sign*Math.abs(mv.measurements.get(k).doca[1]) - h); + ty_filt += K[3] * (sign*Math.abs(mv.measurements.get(k).doca[1]) - h); + Q_filt += K[4] * (sign*Math.abs(mv.measurements.get(k).doca[1]) - h); + + c2 += ((sign*Math.abs(mv.measurements.get(k).doca[1]) - h) * (sign*Math.abs(mv.measurements.get(k).doca[1]) - h) / V); + } + + chi2kf += c2; + sv.trackTraj.get(k).x = x_filt; + sv.trackTraj.get(k).y = y_filt; + sv.trackTraj.get(k).tx = tx_filt; + sv.trackTraj.get(k).ty = ty_filt; + sv.trackTraj.get(k).Q = Q_filt; + + } + } + + @SuppressWarnings("unused") + private void smooth(int sector, int k) { + this.chi2 = 0; + if (sv.trackTraj.get(k) != null && sv.trackCov.get(k).covMat != null) { + sv.transport(sector, k, 0, sv.trackTraj.get(k), sv.trackCov.get(k)); + for (int k1 = 0; k1 < k; k1++) { + sv.transport(sector, k1, k1 + 1, sv.trackTraj.get(k1), sv.trackCov.get(k1)); + this.filter(k1 + 1); + } + } + } + + private void calcFinalChisq(int sector) { + int k = sv.Z.length - 1; + this.chi2 = 0; + double path = 0; + double[] nRj = new double[3]; + + kfStateVecsAlongTrajectory = new ArrayList<>(); + if (sv.trackTraj.get(k) != null && sv.trackCov.get(k).covMat != null) { + sv.transport(sector, sv.Z.length - 1, 0, + sv.trackTraj.get(sv.Z.length - 1), + sv.trackCov.get(sv.Z.length - 1)); + org.jlab.rec.dc.trajectory.StateVec svc = + new org.jlab.rec.dc.trajectory.StateVec(sv.trackTraj.get(0).x, + sv.trackTraj.get(0).y, + sv.trackTraj.get(0).tx, + sv.trackTraj.get(0).ty); + svc.setZ(sv.trackTraj.get(0).z); + svc.setB(sv.trackTraj.get(0).B); + path += sv.trackTraj.get(0).deltaPath; + svc.setPathLength(path); + double h0 = mv.h(new double[]{sv.trackTraj.get(0).x, sv.trackTraj.get(0).y}, + mv.measurements.get(0).z, + mv.measurements.get(0).wireLine[0]); + svc.setProjector(mv.measurements.get(k).wireLine[0].origin().x()+h0/Math.cos(Math.toRadians(6.))); + kfStateVecsAlongTrajectory.add(svc); + double res = (mv.measurements.get(0).doca[0] - h0); + chi2 += (mv.measurements.get(0).doca[0] - h0) * (mv.measurements.get(0).doca[0] - h0) / mv.measurements.get(0).error; + nRj[mv.measurements.get(0).region-1]+=res*res/mv.measurements.get(0).error; + + for (int k1 = 0; k1 < k; k1++) { + sv.transport(sector, k1, k1 + 1, sv.trackTraj.get(k1), sv.trackCov.get(k1)); + + double V = mv.measurements.get(k1 + 1).error; + double h = mv.h(new double[]{sv.trackTraj.get(k1 + 1).x, sv.trackTraj.get(k1 + 1).y}, + mv.measurements.get(k1 + 1).z, + mv.measurements.get(k1 + 1).wireLine[0]); + svc = new org.jlab.rec.dc.trajectory.StateVec(sv.trackTraj.get(k1 + 1).x, + sv.trackTraj.get(k1 + 1).y, + sv.trackTraj.get(k1 + 1).tx, + sv.trackTraj.get(k1 + 1).ty); + svc.setZ(sv.trackTraj.get(k1 + 1).z); + svc.setB(sv.trackTraj.get(k1 + 1).B); + path += sv.trackTraj.get(k1 + 1).deltaPath; + svc.setPathLength(path); + svc.setProjector(mv.measurements.get(k1 + 1).wireLine[0].origin().x()+h/Math.cos(Math.toRadians(6.))); + kfStateVecsAlongTrajectory.add(svc); + res = (mv.measurements.get(k1 + 1).doca[0] - h); + chi2 += (mv.measurements.get(k1 + 1).doca[0] - h) * (mv.measurements.get(k1 + 1).doca[0] - h) / V; + + nRj[mv.measurements.get(k1 + 1).region-1]+=res*res/V; + + } + } + + } + + private boolean isNonsingular(Matrix mat) { + double matDet = mat.det(); + return Math.abs(matDet) >= 1.e-30; + } + +} diff --git a/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/fit/MeasVecs.java b/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/fit/MeasVecs.java index 4bf5a4dd5f..8358c1ec1c 100644 --- a/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/fit/MeasVecs.java +++ b/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/fit/MeasVecs.java @@ -139,7 +139,6 @@ void setMeasVecsFromHB(Track trk, DCGeant4Factory DcDetector) { double Z = hitOnTrk.get_Z(); double X = sl1 * Z + it1; - HitOnTrack hot = new HitOnTrack(slayr, X, Z, hitOnTrk.get_WireLength(), hitOnTrk.get_WireMaxSag(), diff --git a/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/fit/MeasVecsDoca.java b/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/fit/MeasVecsDoca.java new file mode 100644 index 0000000000..f558ceb68d --- /dev/null +++ b/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/fit/MeasVecsDoca.java @@ -0,0 +1,261 @@ +package org.jlab.rec.dc.track.fit; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import org.jlab.detector.geant4.v2.DCGeant4Factory; +import org.jlab.geom.prim.Line3D; +import org.jlab.geom.prim.Point3D; +import org.jlab.geom.prim.Vector3D; +import org.jlab.rec.dc.hit.FittedHit; +import org.jlab.rec.dc.track.Track; + +public class MeasVecsDoca { + + public List measurements = new ArrayList(); + + public int ndf=0; + + public double[] H(double[] stateV, double Z, Line3D wireLine) { + double[] hMatrix = new double[2]; + double[] stateVec = new double[2]; + double Err = 0.025; + double[][] Result = new double[2][2]; + for(int i = 0; i < 2; i++) { + stateVec[0] = stateV[0] + (double)Math.pow(-1, i) * Err; + stateVec[1] = stateV[1]; + Result[i][0] = h(stateVec, Z, wireLine); + } + for(int i = 0; i < 2; i++) { + stateVec[0] = stateV[0]; + stateVec[1] = stateV[1] + (double)Math.pow(-1, i) * Err; + Result[i][1] = h(stateVec, Z, wireLine); + } + hMatrix[0] = (Result[0][0]-Result[1][0])/(2.*Err); + hMatrix[1] = (Result[0][1]-Result[1][1])/(2.*Err); + + return hMatrix; + } + + public double h(double[] stateV, double Z, Line3D wireLine) { + + Line3D WL = new Line3D(); + WL.copy(wireLine); + WL.copy(WL.distance(new Point3D(stateV[0], stateV[1], Z))); + + //System.out.println(Math.signum(-WL.direction().x())+ + // wireLine.origin().toString()+WL.toString()+" "+stateV[0]+" ,"+stateV[1]); + return WL.length()*Math.signum(-WL.direction().x()); + } + + public void setMeasVecs(Track trkcand, DCGeant4Factory DcDetector) { + + List hOTS = new ArrayList(); // the list of hits on track + FittedHit hitOnTrk; + // loops over the regions (1 to 3) and the superlayers in a region (1 to 2) and obtains the hits on track + for (int c = 0; c < 3; c++) { + for (int s = 0; s < 2; s++) { + for (int h = 0; h < trkcand.get(c).get(s).size(); h++) { + if (trkcand.get(c).get(s).get(h).get_Id() == -1) { + continue; + } + trkcand.get(c).get(s).get(h).calc_CellSize(DcDetector); + hitOnTrk = trkcand.get(c).get(s).get(h); + int slayr = trkcand.get(c).get(s).get(h).get_Superlayer(); + + double sl1 = trkcand.get(c).get(s).get_fittedCluster().get_clusterLineFitSlope(); + double it1 = trkcand.get(c).get(s).get_fittedCluster().get_clusterLineFitIntercept(); + + double Z = hitOnTrk.get_Z(); + double X = sl1 * Z + it1; + + //exclude hits that have poor segment + //if ((trkcand.get(c).get(s).get(h).get_X() - X) / (trkcand.get(c).get(s).get(h).get_CellSize() / FastMath.cos(Math.toRadians(6.))) > 1.5) { + //if(Math.abs(trkcand.get(c).get(s).get(h).get_Residual())>1) { + // continue; + //} + + HitOnTrack hot = new HitOnTrack(slayr, X, Z, + trkcand.get(c).get(s).get(h).get_WireMaxSag(), + trkcand.get(c).get(s).get(h).get_WireLine() + ); + double err_sl1 = trkcand.get(c).get(s).get_fittedCluster().get_clusterLineFitSlopeErr(); + + double err_it1 = trkcand.get(c).get(s).get_fittedCluster().get_clusterLineFitInterceptErr(); + double err_cov1 = trkcand.get(c).get(s).get_fittedCluster().get_clusterLineFitSlIntCov(); + + hot._Unc[0] = Math.sqrt(err_sl1 * err_sl1 * Z * Z + err_it1 * err_it1); + hot._hitError = err_sl1 * err_sl1 * Z * Z + err_it1 * err_it1 + 2 * Z * err_cov1 + trkcand.get(c).get(s).get(h).get_DocaErr()*trkcand.get(c).get(s).get(h).get_DocaErr(); + //if(trkcand.get(c).get(s).get(h).get_Time()/CCDBConstants.getTMAXSUPERLAYER()[trkcand.get(c).get(s).get(h).get_Sector()-1][trkcand.get(c).get(s).get(h).get_Superlayer()-1]<1.1) + // hot._hitError = 100000; //exclude outoftimers from fit + hot.region = trkcand.get(c).get(s).get(h).get_Region(); + + hot._doca[0] = trkcand.get(c).get(s).get(h).get_ClusFitDoca(); + + double LR = Math.signum(trkcand.get(c).get(s).get(h).get_XWire()-trkcand.get(c).get(s).get(h).get_X()); + hot._doca[0]*=LR; + hot._Unc[0] = Math.sqrt(err_sl1 * err_sl1 * Z * Z + err_it1 * err_it1); + //hot._hitError = err_sl1 * err_sl1 * Z * Z + err_it1 * err_it1 + 2 * Z * err_cov1 + trk.get_ListOfHBSegments().get(s).get(h).get_DocaErr()*trk.get_ListOfHBSegments().get(s).get(h).get_DocaErr(); + hot._hitError = trkcand.get(c).get(s).get(h).get_DocaErr()*trkcand.get(c).get(s).get(h).get_DocaErr(); + //System.out.println(" Z "+Z+" ferr "+(float)(hot._Unc /(hot._hitError/4.))); + hot._Unc[0] = hot._hitError ; + hOTS.add(hot); + + } + } + } + Collections.sort(hOTS); // sort the collection in order of increasing Z value (i.e. going downstream from the target) + ndf = hOTS.size()-5; + // identify double hits and take the average position + for (int i = 0; i < hOTS.size(); i++) { + if (i > 0) { + if (Math.abs(hOTS.get(i - 1)._Z - hOTS.get(i)._Z)<0.01) { + hOTS.get(i - 1)._doca[1] = hOTS.get(i)._doca[0]; + hOTS.get(i - 1)._Unc[1] = hOTS.get(i)._Unc[0]; + hOTS.get(i - 1)._wireLine[1] = hOTS.get(i)._wireLine[0]; + hOTS.remove(i); + } + } + } + + + measurements = new ArrayList(hOTS.size()); + + for (int i = 0; i < hOTS.size(); i++) { + MeasVec meas = new MeasVec(i); + meas.x = hOTS.get(i)._X; + meas.z = hOTS.get(i)._Z; + meas.region = hOTS.get(i).region; + meas.error = hOTS.get(i)._hitError; + meas.unc = hOTS.get(i)._Unc; //uncertainty used in KF fit + meas.tilt = hOTS.get(i)._tilt; + meas.doca = hOTS.get(i)._doca; + meas.wireMaxSag = hOTS.get(i)._wireMaxSag; + meas.wireLine = hOTS.get(i)._wireLine; + this.measurements.add(i, meas); + } + } + + void setMeasVecsFromHB(Track trk, DCGeant4Factory DcDetector) { + List hOTS = new ArrayList(); // the list of hits on track + FittedHit hitOnTrk; + for(int s = 0; s < trk.get_ListOfHBSegments().size(); s++) { + for(int h = 0; h < trk.get_ListOfHBSegments().get(s).size(); h++) { + trk.get_ListOfHBSegments().get(s).get(h).calc_CellSize(DcDetector); + hitOnTrk = trk.get_ListOfHBSegments().get(s).get(h); + int slayr = trk.get_ListOfHBSegments().get(s).get(h).get_Superlayer(); + + double sl1 = trk.get_ListOfHBSegments().get(s).get_fittedCluster().get_clusterLineFitSlope(); + double it1 = trk.get_ListOfHBSegments().get(s).get_fittedCluster().get_clusterLineFitIntercept(); + + double Z = hitOnTrk.get_Z(); + double X = sl1 * Z + it1; + HitOnTrack hot = new HitOnTrack(slayr, X, Z, + hitOnTrk.get_WireMaxSag(), + hitOnTrk.get_WireLine()); + + hot._doca[0] = trk.get_ListOfHBSegments().get(s).get(h).get_Doca(); + + double LR = Math.signum(trk.get_ListOfHBSegments().get(s).get(h).get_XWire()-trk.get_ListOfHBSegments().get(s).get(h).get_X()); + hot._doca[0]*=LR; + hot._hitError = trk.get_ListOfHBSegments().get(s).get(h).get_DocaErr()*trk.get_ListOfHBSegments().get(s).get(h).get_DocaErr(); + //System.out.println(" Z "+Z+" ferr "+(float)(hot._Unc /(hot._hitError/4.))); + hot._Unc[0] = hot._hitError; + hot.region = trk.get_ListOfHBSegments().get(s).get(h).get_Region(); + hOTS.add(hot); + + } + } + Collections.sort(hOTS); // sort the collection in order of increasing Z value (i.e. going downstream from the target) + ndf = hOTS.size()-5; + // identify double hits and take the average position + for (int i = 0; i < hOTS.size(); i++) { + if (i > 0) { + if (Math.abs(hOTS.get(i - 1)._Z - hOTS.get(i)._Z)<0.01) { + hOTS.get(i - 1)._doca[1] = hOTS.get(i)._doca[0]; + hOTS.get(i - 1)._Unc[1] = hOTS.get(i)._Unc[0]; + hOTS.get(i - 1)._wireLine[1] = hOTS.get(i)._wireLine[0]; + hOTS.remove(i); + } + } + } + + measurements = new ArrayList(hOTS.size()); + + for (int i = 0; i < hOTS.size(); i++) { + MeasVec meas = new MeasVec(i); + meas.x = hOTS.get(i)._X; + meas.z = hOTS.get(i)._Z; + meas.region = hOTS.get(i).region; + meas.error = hOTS.get(i)._hitError; + meas.unc = hOTS.get(i)._Unc; //uncertainty used in KF fit + meas.tilt = hOTS.get(i)._tilt; + meas.doca = hOTS.get(i)._doca; + meas.wireMaxSag = hOTS.get(i)._wireMaxSag; + meas.wireLine[0] = hOTS.get(i)._wireLine[0]; + meas.wireLine[1] = hOTS.get(i)._wireLine[1]; + this.measurements.add(i, meas); + //System.out.println(" measurement "+i+" = "+meas.x+" at "+meas.z); + } + } + + public class MeasVec { + + final int k; + public double z; + public double x; + public double[] unc = new double[2]; + public double tilt; + public double error; + public double[] doca = new double[2]; + public double wireMaxSag; + public Line3D[] wireLine = new Line3D[2]; + boolean reject = false; + int region; + + + MeasVec(int k) { + this.k = k; + } + + } + + private class HitOnTrack implements Comparable { + + public double _hitError; + private double _X; + private double _Z; + private double[] _Unc = new double[2]; + private double _tilt; + private double[] _doca = new double[2]; + private double _wireMaxSag; + private Line3D[] _wireLine = new Line3D[2]; + private int region; + + HitOnTrack(int superlayer, double X, double Z, double wiremaxsag, Line3D wireLine) { + _X = X; + _Z = Z; + _wireMaxSag = wiremaxsag; + _wireLine[0] = wireLine; + _doca[0] = -99; + _doca[1] = -99; + _Unc[0] = 1; + _Unc[1] = 1; + + //use stereo angle in fit based on wire direction + _tilt = 90-Math.toDegrees(wireLine.direction().asUnit().angle(new Vector3D(1,0,0))); + } + + @Override + public int compareTo(HitOnTrack o) { + if (this._Z == o._Z) { + return 0; + } + if (this._Z > o._Z) { + return 1; + } else { + return -1; + } + } + } +} diff --git a/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/fit/RungeKuttaDoca.java b/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/fit/RungeKuttaDoca.java new file mode 100644 index 0000000000..71048b2eb8 --- /dev/null +++ b/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/fit/RungeKuttaDoca.java @@ -0,0 +1,511 @@ +/* + * 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.rec.dc.track.fit; + +import Jama.Matrix; +import java.util.ArrayList; +import org.jlab.clas.swimtools.Swim; +import org.jlab.rec.dc.Constants; + +/** + * + * @author ziegler + */ +public class RungeKuttaDoca { + + private final float[] _b = new float[3]; + final double v = 0.0029979245; + private final ArrayList k1; + private final ArrayList k2; + private final ArrayList k3; + private final ArrayList k4; + private final ArrayList jk1; + private final ArrayList jk2; + private final ArrayList jk3; + private final ArrayList jk4; + + public RungeKuttaDoca() { + this.k1 = new ArrayList(4); + this.k2 = new ArrayList(4); + this.k3 = new ArrayList(4); + this.k4 = new ArrayList(4); + this.jk1 = new ArrayList(12); + this.jk2 = new ArrayList(12); + this.jk3 = new ArrayList(12); + this.jk4 = new ArrayList(12); + + } + + public void SwimToZ(int sector, StateVecsDoca.StateVec fVec, Swim dcSwim, double z0, float[] bf){ + + double stepSize = 1.0; + dcSwim.Bfield(sector, fVec.x, fVec.y, fVec.z, bf); + + fVec.B = Math.sqrt(bf[0]*bf[0]+bf[1]*bf[1]+bf[2]*bf[2]); + double s = fVec.B; + double z = fVec.z; + final double Zi = fVec.z; + double BatMeas = 0; + + while(Math.signum(z0 - Zi) *z 0) { +// C[2][2] += cov_txtx; +// C[2][3] += cov_txty; +// C[3][2] += cov_txty; +// C[3][3] += cov_tyty; +// } +// + fVec.x = x; + fVec.y = y ; + fVec.z = z0+h; + fVec.tx = tx; + fVec.ty = ty; + fVec.Q = q; + fVec.B = Math.sqrt(_b[0]*_b[0]+_b[1]*_b[1]+_b[2]*_b[2]); + fVec.deltaPath = Math.sqrt((x0-x)*(x0-x)+(y0-y)*(y0-y)+h*h)+dPath; + fCov.covMat=new Matrix(C); + + + } + + + private double RK4(double k1, double k2, double k3, double k4, double h) { + return h/6*(k1 + 2*k2 +2*k3 + k4); + } + + private double Ax(double tx, double ty, double Bx, double By, double Bz) { + double C = Math.sqrt(1 + tx * tx + ty * ty); + return C * (ty * (tx * Bx + Bz) - (1 + tx * tx) * By); + } + private double Ay(double tx, double ty, double Bx, double By, double Bz) { + double C = Math.sqrt(1 + tx * tx + ty * ty); + return C * (-tx * (ty * By + Bz) + (1 + ty * ty) * Bx); + } + + private double delAx_deltx(double tx, double ty, double Bx, double By, double Bz) { + double C2 = 1 + tx * tx + ty * ty; + double C = Math.sqrt(1 + tx * tx + ty * ty); + double Ax = C * (ty * (tx * Bx + Bz) - (1 + tx * tx) * By); + double Ay = C * (-tx * (ty * By + Bz) + (1 + ty * ty) * Bx); + + return tx * Ax / C2 + C * (ty * Bx - 2 * tx * By); //delAx_deltx + } + private double delAx_delty(double tx, double ty, double Bx, double By, double Bz) { + double C2 = 1 + tx * tx + ty * ty; + double C = Math.sqrt(1 + tx * tx + ty * ty); + double Ax = C * (ty * (tx * Bx + Bz) - (1 + tx * tx) * By); + double Ay = C * (-tx * (ty * By + Bz) + (1 + ty * ty) * Bx); + + return ty * Ax / C2 + C * (tx * Bx + Bz); //delAx_delty + } + private double delAy_deltx(double tx, double ty, double Bx, double By, double Bz) { + double C2 = 1 + tx * tx + ty * ty; + double C = Math.sqrt(1 + tx * tx + ty * ty); + double Ax = C * (ty * (tx * Bx + Bz) - (1 + tx * tx) * By); + double Ay = C * (-tx * (ty * By + Bz) + (1 + ty * ty) * Bx); + + return tx * Ay / C2 + C * (-ty * By - Bz); //delAy_deltx + } + private double delAy_delty(double tx, double ty, double Bx, double By, double Bz) { + double C2 = 1 + tx * tx + ty * ty; + double C = Math.sqrt(1 + tx * tx + ty * ty); + double Ax = C * (ty * (tx * Bx + Bz) - (1 + tx * tx) * By); + double Ay = C * (-tx * (ty * By + Bz) + (1 + ty * ty) * Bx); + + return ty * Ay / C2 + C * (-tx * By + 2 * ty * Bx); //delAy_delty + } + + private void A(double tx, double ty, double Bx, double By, double Bz, double[] a) { + + double C = Math.sqrt(1 + tx * tx + ty * ty); + a[0] = C * (ty * (tx * Bx + Bz) - (1 + tx * tx) * By); + a[1] = C * (-tx * (ty * By + Bz) + (1 + ty * ty) * Bx); + } + + private void delA_delt(double tx, double ty, double Bx, double By, double Bz, double[] dela_delt) { + + double C2 = 1 + tx * tx + ty * ty; + double C = Math.sqrt(1 + tx * tx + ty * ty); + double Ax = C * (ty * (tx * Bx + Bz) - (1 + tx * tx) * By); + double Ay = C * (-tx * (ty * By + Bz) + (1 + ty * ty) * Bx); + + dela_delt[0] = tx * Ax / C2 + C * (ty * Bx - 2 * tx * By); //delAx_deltx + dela_delt[1] = ty * Ax / C2 + C * (tx * Bx + Bz); //delAx_delty + dela_delt[2] = tx * Ay / C2 + C * (-ty * By - Bz); //delAy_deltx + dela_delt[3] = ty * Ay / C2 + C * (-tx * By + 2 * ty * Bx); //delAy_delty + } + + private double deltx_deltx0_next(double q, double v, double tx1, double ty1, float b0, float b1, float b2, double deltx_deltx0_1, double delty_deltx0_1) { + return q*v*(delAx_deltx(tx1,ty1,b0,b1,b2)*(deltx_deltx0_1) + + delAx_delty(tx1,ty1,b0,b1,b2)*(delty_deltx0_1)); + } + + private double delty_deltx0_next(double q, double v, double tx1, double ty1, float b0, float b1, float b2, double deltx_deltx0_1, double delty_deltx0_1) { + return q*v*(delAy_deltx(tx1,ty1,b0,b1,b2)*(deltx_deltx0_1) + + delAy_delty(tx1,ty1,b0,b1,b2)*(delty_deltx0_1)); + } + + private double deltx_delty0_next(double q, double v, double tx1, double ty1, float b0, float b1, float b2, double deltx_delty0_1, double delty_delty0_1) { + return q*v*(delAx_delty(tx1,ty1,b0,b1,b2)*(deltx_delty0_1) + + delAx_delty(tx1,ty1,b0,b1,b2)*(delty_delty0_1)); + } + + private double delty_delty0_next(double q, double v, double tx1, double ty1, float b0, float b1, float b2, double deltx_delty0_1, double delty_delty0_1) { + return q*v*(delAy_delty(tx1,ty1,b0,b1,b2)*(deltx_delty0_1) + + delAy_delty(tx1,ty1,b0,b1,b2)*(delty_delty0_1)); + } + + private double deltx_delq0_next(double q, double v, double tx1, double ty1, float b0, float b1, float b2, double deltx_delq0_1, double delty_delq0_1) { + return v*Ax(tx1, ty1, b0, b1, b2) + + q*v*(delAx_deltx(tx1,ty1,b0,b1,b2)*(deltx_delq0_1) + + delAx_delty(tx1,ty1,b0,b1,b2)*(delty_delq0_1)); + } + + private double delty_delq0_next(double q, double v, double tx1, double ty1, float b0, float b1, float b2, double deltx_delq0_1, double delty_delq0_1) { + return v*Ay(tx1, ty1, b0, b1, b2) + + q*v*(delAy_deltx(tx1, ty1,b0,b1,b2)*(deltx_delq0_1) + + delAy_delty(tx1, ty1,b0,b1,b2)*(delty_delq0_1)); + } + + private void getRKn(int sector, ArrayList k1, ArrayList k2, double d, double x0, double y0, double z0, double tx0, double ty0, double q, float[] b) { + + double tx1 = k1.get(2); + double ty1 = k1.get(3); + + double x2 = tx0+d*tx1; + double y2 = ty0+d*ty1; + double tx2=q*v*Ax((tx0+d*tx1), (ty0+d*ty1), b[0], b[1], b[2]); + double ty2=q*v*Ay((tx0+d*tx1), (ty0+d*ty1), b[0], b[1], b[2]); + + k2.add(0, x2); + k2.add(1, y2); + k2.add(2, tx2); + k2.add(3, ty2); + } + + private void getjRKn(int sector, ArrayList k1, ArrayList jk1, ArrayList jk2, double d, double x0, double y0, double z0, double tx0, double ty0, double q, float[] _b, + double deltx_deltx0_0, double delty_deltx0_0, double deltx_delty0_0, double delty_delty0_0, double deltx_delq0_0, double delty_delq0_0) { + + double tx1 = k1.get(2); + double ty1 = k1.get(3); + + double delx_deltx0_1 = jk1.get(0); + double dely_deltx0_1 = jk1.get(1); + double delx_delty0_1 = jk1.get(2); + double dely_delty0_1 = jk1.get(3); + + double deltx_deltx0_1 = jk1.get(4); + double delty_deltx0_1 = jk1.get(5); + double deltx_delty0_1 = jk1.get(6); + double delty_delty0_1 = jk1.get(7); + + double delx_delq0_1 = jk1.get(8); + double dely_delq0_1 = jk1.get(9); + + double deltx_delq0_1 = jk1.get(10); + double delty_delq0_1 = jk1.get(11); + + double delx_deltx0_2 = deltx_deltx0_0+d*deltx_deltx0_1; + double dely_deltx0_2 = delty_deltx0_0+d*delty_deltx0_1; + double delx_delty0_2 = deltx_delty0_0+d*deltx_delty0_1; + double dely_delty0_2 = delty_delty0_0+d*delty_delty0_1; + + double deltx_deltx0_2 = this.deltx_deltx0_next(q,v,tx0+d*tx1,ty0+d*ty1,_b[0],_b[1],_b[2], + deltx_deltx0_0+d*deltx_deltx0_1,delty_deltx0_0+d*delty_deltx0_1); + double delty_deltx0_2 = this.delty_deltx0_next(q,v,tx0+d*tx1,ty0+d*ty1,_b[0],_b[1],_b[2], + deltx_deltx0_0+d*deltx_deltx0_1,delty_deltx0_0+d*delty_deltx0_1); + double deltx_delty0_2 = this.deltx_delty0_next(q,v,tx0+d*tx1,ty0+d*ty1,_b[0],_b[1],_b[2], + deltx_delty0_0+d*deltx_delty0_1,delty_delty0_0+d*delty_delty0_1); + double delty_delty0_2 = this.delty_delty0_next(q,v,tx0+d*tx1,ty0+d*ty1,_b[0],_b[1],_b[2], + deltx_delty0_0+d*deltx_delty0_1,delty_delty0_0+d*delty_delty0_1); + + double delx_delq0_2 = deltx_delq0_0+d*deltx_delq0_1; + double dely_delq0_2 = delty_delq0_0+d*delty_delq0_1; + + double deltx_delq0_2 = this.deltx_delq0_next(q,v,tx0+d*tx1,ty0+d*ty1,_b[0],_b[1],_b[2], + deltx_delq0_0+d*deltx_delq0_1,delty_delq0_0+d*delty_delq0_1); + double delty_delq0_2 = this.delty_delq0_next(q,v,tx0+d*tx1,ty0+d*ty1,_b[0],_b[1],_b[2], + deltx_delq0_0+d*deltx_delq0_1,delty_delq0_0+d*delty_delq0_1); + + jk2.add(0, delx_deltx0_2 ); + jk2.add(1, dely_deltx0_2 ); + jk2.add(2, delx_delty0_2 ); + jk2.add(3, dely_delty0_2 ); + + jk2.add(4, deltx_deltx0_2 ); + jk2.add(5, delty_deltx0_2 ); + jk2.add(6, deltx_delty0_2 ); + jk2.add(7, delty_delty0_2 ); + + jk2.add(8, delx_delq0_2 ); + jk2.add(9, dely_delq0_2 ); + + jk2.add(10, deltx_delq0_2 ); + jk2.add(11, delty_delq0_2 ); + } + + + +} diff --git a/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/fit/StateVecsDoca.java b/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/fit/StateVecsDoca.java new file mode 100644 index 0000000000..7813771029 --- /dev/null +++ b/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/fit/StateVecsDoca.java @@ -0,0 +1,457 @@ +package org.jlab.rec.dc.track.fit; + +import Jama.Matrix; +import java.util.HashMap; +import java.util.Map; +import org.jlab.clas.clas.math.FastMath; +import org.jlab.clas.swimtools.Swim; +import org.jlab.rec.dc.Constants; +import org.jlab.rec.dc.track.Track; +/** + * + * @author ziegler + */ +public class StateVecsDoca { + private double Bmax = 2.366498; // averaged + + final double speedLight = 0.002997924580; + public double[] Z; + // public List bfieldPoints = new ArrayList(); + public Map trackTraj = new HashMap(); + public Map trackCov = new HashMap(); + + + public StateVec StateVec; + public CovMat CovMat; + public Matrix F; + private final double[] A = new double[2]; + private final double[] dA = new double[4]; + private final float[] bf = new float[3]; + private final float[] lbf = new float[3]; + private Swim dcSwim; + private RungeKuttaDoca rk; + + /** + * State vector representing the track in the sector coordinate system at the measurement layer + */ + public StateVecsDoca(Swim swimmer) { + //Max Field Location: (phi, rho, z) = (29.50000, 44.00000, 436.00000) + // get the maximum value of the B field + dcSwim = swimmer; + rk = new RungeKuttaDoca(); + } + + /** + * + * @param i initial state vector index + * @param f final state vector index + * @param iVec state vector at the initial index + * @param covMat state covariance matrix at the initial index + */ + public void transport(int sector, int i, int f, StateVec iVec, CovMat covMat) { // s = signed step-size + if(iVec==null) + return; + double stepSize = 1.0; + StateVecsDoca.StateVec fVec = new StateVec(f); + CovMat fCov = new CovMat(f); + fVec.x = iVec.x; + fVec.y = iVec.y; + fVec.z = iVec.z; + fVec.tx = iVec.tx; + fVec.ty = iVec.ty; + fVec.Q = iVec.Q; + fVec.B = iVec.B; + fCov.covMat = covMat.covMat; + + double s = 0; + double z = Z[i]; + double BatMeas = iVec.B; + + while(Math.signum(Z[f] - Z[i]) *zMath.signum(Z[f] - Z[i]) *Z[f]) + s=Math.signum(Z[f] - Z[i]) *Math.abs(Z[f]-z); + + rk.RK4transport( sector, Q, x, y, z, tx, ty, s, dcSwim, + covMat, fVec, fCov, mass, dPath); + + + // Q process noise matrix estimate + double p = Math.abs(1. / iVec.Q); + + double X0 = this.getX0(iVec.z); + double t_ov_X0 = stepSize / X0;//path length in radiation length units = t/X0 [true path length/ X0] ; Ar radiation length = 14 cm + + double beta = p / Math.sqrt(p * p + mass * mass); // use particle momentum + if(beta>0) + beta =1; + + double sctRMS = ((0.0136)/(beta*p))*Math.sqrt(t_ov_X0)* + (1 + 0.038 * Math.log(t_ov_X0)); + + double cov_txtx = (1 + tx * tx) * (1 + tx * tx + ty * ty) * sctRMS * sctRMS; + double cov_tyty = (1 + ty * ty) * (1 + tx * tx + ty * ty) * sctRMS * sctRMS; + double cov_txty = tx * ty * (1 + tx * tx + ty * ty) * sctRMS * sctRMS; + + if (Math.signum(Z[f] - Z[i]) > 0) { + Matrix fMS = new Matrix(new double[][]{ + {0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0}, + {0, 0, cov_txtx, cov_txty, 0}, + {0, 0, cov_txty, cov_tyty, 0}, + {0, 0, 0, 0, 0} + }); + Matrix fCovMS = fCov.covMat.copy().plus(fMS); + fCov.covMat = fCovMS; + } + // end add process noise + + if( Math.abs(fVec.B - BatMeas)<0.0001) + stepSize*=2; + + BatMeas = fVec.B; + } + this.trackTraj.put(f, fVec); + this.trackCov.put(f, fCov); + } + private double getX0(double z) { + double X0 = Constants.AIRRADLEN; + double tolerance = 0.01; + for(int i = 1; i =Constants.Z[i]-tolerance && z<=Constants.Z[i+1]+tolerance) { + return Constants.AIRRADLEN; + } + } + + return X0; + } + /** + * + * @param i initial state vector index + * @param f final state vector index + * @param iVec state vector at the initial index + * @param covMat state covariance matrix at the initial index + */ + public void transportFixed(int sector, int i, int f, StateVec iVec, CovMat covMat) { // s = signed step-size + if(iVec==null) + return; + double stepSize = 0.5; + + StateVecsDoca.StateVec fVec = new StateVec(f); + StateVecsDoca.CovMat fCov = new CovMat(f); + fVec.x = iVec.x; + fVec.y = iVec.y; + fVec.z = iVec.z; + fVec.tx = iVec.tx; + fVec.ty = iVec.ty; + fVec.Q = iVec.Q; + fCov.covMat = covMat.covMat; + int nSteps = (int) (Math.abs((Z[i] - Z[f]) / stepSize) + 1); + + double s = (Z[f] - Z[i]) / (double) nSteps; + double z = Z[i]; + + for (int j = 0; j < nSteps; j++) { + // get the sign of the step + if (j == nSteps - 1) { + s = Math.signum(Z[f] - Z[i]) * Math.abs(z - Z[f]); + } + //System.out.println(" RK step num "+(j+1)+" = "+(float)s+" nSteps = "+nSteps); + double x = fVec.x; + double y = fVec.y; + z = fVec.z; + double tx = fVec.tx; + double ty = fVec.ty; + double Q = fVec.Q; + double dPath = fVec.deltaPath; + covMat.covMat = fCov.covMat; + + rk.RK4transport( sector, Q, x, y, z, tx, ty, s, dcSwim, + covMat, fVec, fCov, mass, dPath); + + } + + this.trackTraj.put(f, fVec); + this.trackCov.put(f, fCov); + } + + + private void A(double tx, double ty, double Bx, double By, double Bz, double[] a) { + + double C = Math.sqrt(1 + tx * tx + ty * ty); + a[0] = C * (ty * (tx * Bx + Bz) - (1 + tx * tx) * By); + a[1] = C * (-tx * (ty * By + Bz) + (1 + ty * ty) * Bx); + } + + private void delA_delt(double tx, double ty, double Bx, double By, double Bz, double[] dela_delt) { + + double C2 = 1 + tx * tx + ty * ty; + double C = Math.sqrt(1 + tx * tx + ty * ty); + double Ax = C * (ty * (tx * Bx + Bz) - (1 + tx * tx) * By); + double Ay = C * (-tx * (ty * By + Bz) + (1 + ty * ty) * Bx); + + dela_delt[0] = tx * Ax / C2 + C * (ty * Bx - 2 * tx * By); //delAx_deltx + dela_delt[1] = ty * Ax / C2 + C * (tx * Bx + Bz); //delAx_delty + dela_delt[2] = tx * Ay / C2 + C * (-ty * By - Bz); //delAy_deltx + dela_delt[3] = ty * Ay / C2 + C * (-tx * By + 2 * ty * Bx); //delAy_delty + } + + + private double mass = 0.13957018; + public void setMass(int hypo, double mass) { + + switch (hypo) { + case 0: + mass = 0.000510998; + break; + case 1: + mass = 0.13957018; + break; + case 2: + mass = 0.493677; + break; + case 3: + mass = 0.105658369; + break; + case 4: + mass = 0.938272029; + break; + } + } + + + /** + * + * @param trkcand the track candidate + * @param z0 the value in z to which the track is swam back to + * @param kf the final state measurement index + */ + public void init(Track trkcand, double z0, KFitterDoca kf) { + + if (trkcand.get_StateVecAtReg1MiddlePlane() != null) { + + StateVec initSV = new StateVec(0); + initSV.x = trkcand.get_StateVecAtReg1MiddlePlane().x(); + initSV.y = trkcand.get_StateVecAtReg1MiddlePlane().y(); + initSV.z = trkcand.get(0).get_Point().z(); + initSV.tx = trkcand.get_StateVecAtReg1MiddlePlane().tanThetaX(); + initSV.ty = trkcand.get_StateVecAtReg1MiddlePlane().tanThetaY(); + initSV.Q = trkcand.get_Q() / trkcand.get_P(); + + rk.SwimToZ(trkcand.get(0).get_Sector(), initSV, dcSwim, z0, bf); + + this.trackTraj.put(0, initSV); + } else { + kf.setFitFailed = true; + return; + } + //System.out.println((0)+"] init "+this.trackTraj.get(0).x+","+this.trackTraj.get(0).y+","+ + // this.trackTraj.get(0).z+","+this.trackTraj.get(0).tx+","+this.trackTraj.get(0).ty+" "+1/this.trackTraj.get(0).Q); + double err_sl1 = trkcand.get(0).get_Segment1().get_fittedCluster().get_clusterLineFitSlopeErr(); + double err_sl2 = trkcand.get(0).get_Segment2().get_fittedCluster().get_clusterLineFitSlopeErr(); + double err_it1 = trkcand.get(0).get_Segment1().get_fittedCluster().get_clusterLineFitInterceptErr(); + double err_it2 = trkcand.get(0).get_Segment2().get_fittedCluster().get_clusterLineFitInterceptErr(); + double wy_over_wx = (FastMath.cos(Math.toRadians(6.)) / FastMath.sin(Math.toRadians(6.))); + + double eux = 0.5 * Math.sqrt(err_sl1 * err_sl1 + err_sl2 * err_sl2); + double euy = 0.5 * wy_over_wx * Math.sqrt(err_sl1 * err_sl1 + err_sl2 * err_sl2); + double z = trkcand.get(0).get_Point().z(); + double ex = 0.5 * Math.sqrt(err_it1 * err_it1 + err_it2 * err_it2 + z * z * (err_sl1 * err_sl1 + err_sl2 * err_sl2)); + double ey = 0.5 * wy_over_wx * Math.sqrt(err_it1 * err_it1 + err_it2 * err_it2 + z * z * (err_sl1 * err_sl1 + err_sl2 * err_sl2)); + double epSq = 0.001 * trkcand.get_P() * trkcand.get_P(); + + Matrix initCMatrix = new Matrix(new double[][]{ + {ex * ex, 0, 0, 0, 0}, + {0, ey * ey, 0, 0, 0}, + {0, 0, eux * eux, 0, 0}, + {0, 0, 0, euy * euy, 0}, + {0, 0, 0, 0, epSq} + }); + + CovMat initCM = new CovMat(0); + initCM.covMat = initCMatrix; + this.trackCov.put(0, initCM); + } + private StateVec reset(StateVec SVplus, StateVec stateVec) { + SVplus = new StateVec(stateVec.k); + SVplus.x = stateVec.x; + SVplus.y = stateVec.y; + SVplus.tx = stateVec.tx; + SVplus.ty = stateVec.ty; + SVplus.z = stateVec.z; + SVplus.Q = stateVec.Q; + + return SVplus; + } + private void swimToSite(int sector, double z0, + StateVec SVplus, StateVec SVminus) { + + rk.SwimToZ(sector, SVplus, dcSwim, z0, bf); + rk.SwimToZ(sector, SVminus, dcSwim, z0, bf); + } + + double[] F(int sector, double z0, StateVec stateVec) { + double[] _F = new double[5]; + StateVec SVplus = null; + StateVec SVminus = null; + + SVplus = this.reset(SVplus, stateVec); + SVminus = this.reset(SVminus, stateVec); + + double delt_x = 0.05; + SVplus.x += delt_x/2.; + SVminus.x-= delt_x/2.; + + this.swimToSite(sector, z0, SVplus, SVminus); + + _F[0] = (SVplus.x - SVminus.x)/delt_x; + + SVplus = this.reset(SVplus, stateVec); + SVminus = this.reset(SVminus, stateVec); + + double delt_y = 0.05; + SVplus.y += delt_y/2.; + SVminus.y-= delt_y/2.; + + this.swimToSite(sector, z0, SVplus, SVminus); + + _F[1] = (SVplus.y - SVminus.y)/delt_y; + + SVplus = this.reset(SVplus, stateVec); + SVminus = this.reset(SVminus, stateVec); + + double delt_tx = 0.001; + SVplus.tx += delt_tx/2.; + SVminus.tx-= delt_tx/2.; + + this.swimToSite(sector, z0, SVplus, SVminus); + + _F[2] = (SVplus.tx - SVminus.tx)/delt_tx; + + SVplus = this.reset(SVplus, stateVec); + SVminus = this.reset(SVminus, stateVec); + + double delt_ty = 0.001; + SVplus.ty += delt_ty/2.; + SVminus.ty-= delt_ty/2.; + + this.swimToSite(sector, z0, SVplus, SVminus); + + _F[3] = (SVplus.ty - SVminus.ty)/delt_ty; + + SVplus = this.reset(SVplus, stateVec); + SVminus = this.reset(SVminus, stateVec); + + + _F[4] = 0.01/Math.abs(SVplus.Q); + + return _F; + + } + + void initFromHB(Track trkcand, double z0, KFitterDoca kf) { + if (trkcand != null && trkcand.getFinalStateVec()!=null + && trkcand.get_CovMat()!=null) { + if(trkcand.get(0).get(0).get(0).get_Beta()>0.99) { + this.setMass(0, mass); + } else { + this.setMass(1, mass); + } + StateVec initSV = new StateVec(0); + initSV.x = trkcand.getFinalStateVec().x(); + initSV.y = trkcand.getFinalStateVec().y(); + initSV.z = trkcand.getFinalStateVec().getZ(); + initSV.tx = trkcand.getFinalStateVec().tanThetaX(); + initSV.ty = trkcand.getFinalStateVec().tanThetaY(); + initSV.Q = ((double) trkcand.get_Q())/trkcand.get_P(); + + rk.SwimToZ(trkcand.get(0).get_Sector(), initSV, dcSwim, z0, bf); + this.trackTraj.put(0, initSV); + + CovMat initCM = new CovMat(0); + initCM.covMat = trkcand.get_CovMat(); + //test + StateVec rinitSV = new StateVec(0); + rinitSV.x = trkcand.getFinalStateVec().x(); + rinitSV.y = trkcand.getFinalStateVec().y(); + rinitSV.z = trkcand.getFinalStateVec().getZ(); + rinitSV.tx = trkcand.getFinalStateVec().tanThetaX(); + rinitSV.ty = trkcand.getFinalStateVec().tanThetaY(); + rinitSV.Q = ((double) trkcand.get_Q())/trkcand.get_P(); + double[][] FTF = new double[5][5]; + double[] F = this.F(trkcand.get(0).get_Sector(), z0, rinitSV); + for(int i = 0; i<5; i++) { + FTF[i][i]=F[i]*F[i]; + + } + + Matrix initCMatrix = new Matrix(FTF); + initCM.covMat = initCMatrix; + //end test + this.trackCov.put(0, initCM); //this.printMatrix(initCM.covMat); + } else { + kf.setFitFailed = true; + return; + } + + } + + public void printMatrix(Matrix C) { + for (int k = 0; k < 5; k++) { + for (int j = 0; j < 5; j++) { + System.out.println("C["+j+"]["+k+"] = "+C.get(j, k)); + } + } + } + + /** + * The state vector representing the track at a given measurement site + */ + public class StateVec { + + final int k; //index + public double z; //z (fixed measurement planes) + public double x; //track x in the tilted sector coordinate system at z + public double y; //track y in the tilted sector coordinate system at z + public double tx; //track px/pz in the tilted sector coordinate system at z + public double ty; //track py/pz in the tilted sector coordinate system at z + public double Q; //track q/p + double B; + double deltaPath; + + StateVec(int k) { + this.k = k; + } + + String printInfo() { + return this.k+"] = "+(float)this.x+", "+(float)this.y+", "+(float)this.z+", " + +(float)this.tx+", "+(float)this.ty+", "+(float)this.Q+" B = "+(float)this.B; + } + } + /** + * The track covariance matrix + */ + public class CovMat { + + final int k; + public Matrix covMat; + + CovMat(int k) { + this.k = k; + } + + } +} diff --git a/reconstruction/dc/src/main/java/org/jlab/rec/dc/trajectory/TrajectorySurfaces.java b/reconstruction/dc/src/main/java/org/jlab/rec/dc/trajectory/TrajectorySurfaces.java index b7f6733977..bd17f8c261 100644 --- a/reconstruction/dc/src/main/java/org/jlab/rec/dc/trajectory/TrajectorySurfaces.java +++ b/reconstruction/dc/src/main/java/org/jlab/rec/dc/trajectory/TrajectorySurfaces.java @@ -14,6 +14,7 @@ import org.jlab.detector.geant4.v2.FTOFGeant4Factory; import org.jlab.geom.base.Detector; import org.jlab.geom.prim.Vector3D; +import org.jlab.rec.dc.Constants; /** * A class to load the geometry constants used in the DC reconstruction. The * coordinate system used in the Tilted Sector coordinate system. @@ -39,7 +40,22 @@ public void LoadSurfaces(double targetPosition, double targetLength, DCGeant4Factory dcDetector, FTOFGeant4Factory ftofDetector, Detector ecalDetector) { - + // creating Boundaries for MS + Constants.Z[0]= targetPosition; + Constants.Z[1]= dcDetector.getWireMidpoint(0, 0, 0, 0).z; + Constants.Z[2]= dcDetector.getWireMidpoint(0, 0, 5, 0).z; + Constants.Z[3]= dcDetector.getWireMidpoint(0, 1, 0, 0).z; + Constants.Z[4]= dcDetector.getWireMidpoint(0, 1, 5, 0).z; + Constants.Z[5]= dcDetector.getWireMidpoint(0, 2, 0, 0).z; + Constants.Z[6]= dcDetector.getWireMidpoint(0, 2, 5, 0).z; + Constants.Z[7]= dcDetector.getWireMidpoint(0, 3, 0, 0).z; + Constants.Z[8]= dcDetector.getWireMidpoint(0, 3, 5, 0).z; + Constants.Z[9]= dcDetector.getWireMidpoint(0, 4, 0, 0).z; + Constants.Z[10]= dcDetector.getWireMidpoint(0, 4, 5, 0).z; + Constants.Z[11]= dcDetector.getWireMidpoint(0, 5, 0, 0).z; + Constants.Z[12]= dcDetector.getWireMidpoint(0, 5, 5, 0).z; + //DcDetector.getWireMidpoint(this.get_Sector()-1, this.get_Superlayer()-1, this.get_Layer()-1, this.get_Wire()-1).z; + double d = 0; Vector3D n; for(int is =0; is<6; is++) { @@ -119,4 +135,6 @@ public void LoadSurfaces(double targetPosition, double targetLength, // // return new Point3D(rx,ry,rzs); // } + + } diff --git a/reconstruction/dc/src/main/java/org/jlab/service/dc/DCHBEngine.java b/reconstruction/dc/src/main/java/org/jlab/service/dc/DCHBEngine.java index 0c038c8c42..5d87c96d54 100755 --- a/reconstruction/dc/src/main/java/org/jlab/service/dc/DCHBEngine.java +++ b/reconstruction/dc/src/main/java/org/jlab/service/dc/DCHBEngine.java @@ -7,6 +7,8 @@ import java.util.ArrayList; import java.util.List; import java.util.concurrent.atomic.AtomicInteger; +import java.util.logging.Level; +import java.util.logging.Logger; import org.jlab.clas.swimtools.MagFieldsEngine; import org.jlab.clas.swimtools.Swim; diff --git a/reconstruction/dc/src/main/java/org/jlab/service/dc/DCTBEngine.java b/reconstruction/dc/src/main/java/org/jlab/service/dc/DCTBEngine.java index 64955c4990..8ee45be275 100755 --- a/reconstruction/dc/src/main/java/org/jlab/service/dc/DCTBEngine.java +++ b/reconstruction/dc/src/main/java/org/jlab/service/dc/DCTBEngine.java @@ -25,6 +25,7 @@ import org.jlab.rec.dc.track.Track; import org.jlab.rec.dc.track.TrackCandListFinder; import org.jlab.rec.dc.track.fit.KFitter; +import org.jlab.rec.dc.track.fit.KFitterDoca; import org.jlab.rec.dc.trajectory.StateVec; import org.jlab.rec.dc.trajectory.Trajectory; import org.jlab.rec.dc.trajectory.TrajectoryFinder; @@ -219,7 +220,7 @@ public boolean processDataEvent(DataEvent event) { //if(TrackArray[i].get_FitChi2()>200) { // resetTrackParams(TrackArray[i], new DCSwimmer()); //} - KFitter kFit = new KFitter(TrackArray[i], dcDetector, true, dcSwim); + KFitterDoca kFit = new KFitterDoca(TrackArray[i], dcDetector, true, dcSwim); StateVec fn = new StateVec(); kFit.runFitter(TrackArray[i].get(0).get_Sector()); From 66b5f8edab5a53e68b7feacd58da09258af1c76b Mon Sep 17 00:00:00 2001 From: Andrey Kim Date: Tue, 27 Aug 2019 15:58:36 -0400 Subject: [PATCH 035/235] recon-util reads yaml file --- .../org/jlab/clas/reco/EngineProcessor.java | 148 +++++++++++++----- 1 file changed, 113 insertions(+), 35 deletions(-) diff --git a/common-tools/clas-reco/src/main/java/org/jlab/clas/reco/EngineProcessor.java b/common-tools/clas-reco/src/main/java/org/jlab/clas/reco/EngineProcessor.java index 83a6695fca..8fb9e44d14 100644 --- a/common-tools/clas-reco/src/main/java/org/jlab/clas/reco/EngineProcessor.java +++ b/common-tools/clas-reco/src/main/java/org/jlab/clas/reco/EngineProcessor.java @@ -5,6 +5,9 @@ */ package org.jlab.clas.reco; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.lang.ClassCastException; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -15,37 +18,47 @@ import org.jlab.io.hipo.HipoDataSync; import org.jlab.utils.benchmark.ProgressPrintout; import org.jlab.utils.options.OptionParser; +import org.jlab.clas.reco.ReconstructionEngine; +import org.jlab.clara.engine.EngineData; +import org.jlab.clara.engine.EngineDataType; +import org.yaml.snakeyaml.Yaml; +import org.yaml.snakeyaml.error.YAMLException; +import java.io.InputStream; +import java.io.FileInputStream; +import org.json.JSONObject; + /** * - * @author gavalian + * @author gavalian, kenjo */ public class EngineProcessor { - + private final Map processorEngines = new LinkedHashMap(); ReconstructionEngine engineDummy = null; - + public EngineProcessor(){ this.engineDummy = new DummyEngine(); } - + /** * add a reconstruction engine to the chain * @param name name of the engine in the chain * @param engine engine class */ public void addEngine(String name, ReconstructionEngine engine){ + engine.init(); this.processorEngines.put(name, engine); } - + public void initDefault(){ - + String[] names = new String[]{ "MAGFIELDS", "DCHB","FTOFHB","EC","HTCC","EBHB", "DCTB","FTOFTB","EBTB" }; - + String[] services = new String[]{ "org.jlab.clas.swimtools.MagFieldsEngine", "org.jlab.service.dc.DCHBEngine", @@ -57,7 +70,7 @@ public void initDefault(){ "org.jlab.service.ftof.FTOFTBEngine", "org.jlab.service.eb.EBTBEngine" }; - + for(int i = 0; i < names.length; i++){ this.addEngine(names[i], services[i]); } @@ -67,7 +80,7 @@ public void initDefault(){ }*/ } public void initAll(){ - + String[] names = new String[]{ "MAGFIELDS", "FTCAL", "FTHODO", "FTEB", @@ -76,7 +89,7 @@ public void initAll(){ "HTCC","LTCC","RICHEB","EBHB", "DCTB","FTOFTB","EBTB" }; - + String[] services = new String[]{ "org.jlab.clas.swimtools.MagFieldsEngine", "org.jlab.rec.ft.cal.FTCALEngine", @@ -98,7 +111,7 @@ public void initAll(){ "org.jlab.service.eb.EBTBEngine", "org.jlab.rec.rich.RICHEBEngine" }; - + for(int i = 0; i < names.length; i++){ this.addEngine(names[i], services[i]); } @@ -108,16 +121,16 @@ public void initAll(){ }*/ } public void initCaloDebug(){ - + String[] names = new String[]{ "EC","EB" }; - + String[] services = new String[]{ "org.jlab.service.ec.ECEngine", "org.jlab.service.eb.EBEngine", }; - + for(int i = 0; i < names.length; i++){ this.addEngine(names[i], services[i]); } @@ -127,7 +140,38 @@ public void initCaloDebug(){ }*/ } /** - * Adding engine to the map the order of the services matters, since they will + * Adding engine to the map the order of the services matters, since they will + * be executed in order added. + * @param name name for the service + * @param clazz class name including the package name + * @param jsonConfig string in json format with engine configuration + */ + public void addEngine(String name, String clazz, String jsonConf) { + Class c = null; + try { + c = Class.forName(clazz); + if( ReconstructionEngine.class.isAssignableFrom(c)==true){ + ReconstructionEngine engine = (ReconstructionEngine) c.newInstance(); + engine.init(); + if(jsonConf!="null") { + EngineData input = new EngineData(); + input.setData(EngineDataType.JSON.mimeType(), jsonConf); + engine.configure(input); + } + this.processorEngines.put(name, engine); + } else { + System.out.println(">>>> ERROR: class is not a reconstruction engine : " + clazz); + } + } catch (ClassNotFoundException ex) { + Logger.getLogger(EngineProcessor.class.getName()).log(Level.SEVERE, null, ex); + } catch (InstantiationException ex) { + Logger.getLogger(EngineProcessor.class.getName()).log(Level.SEVERE, null, ex); + } catch (IllegalAccessException ex) { + Logger.getLogger(EngineProcessor.class.getName()).log(Level.SEVERE, null, ex); + } + } + /** + * Adding engine to the map the order of the services matters, since they will * be executed in order added. * @param name name for the service * @param clazz class name including the package name @@ -138,6 +182,7 @@ public void addEngine(String name, String clazz) { c = Class.forName(clazz); if( ReconstructionEngine.class.isAssignableFrom(c)==true){ ReconstructionEngine engine = (ReconstructionEngine) c.newInstance(); + engine.init(); this.processorEngines.put(name, engine); } else { System.out.println(">>>> ERROR: class is not a reconstruction engine : " + clazz); @@ -148,7 +193,7 @@ public void addEngine(String name, String clazz) { Logger.getLogger(EngineProcessor.class.getName()).log(Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { Logger.getLogger(EngineProcessor.class.getName()).log(Level.SEVERE, null, ex); - } + } } /** * Add reconstruction engine to the chain @@ -160,6 +205,7 @@ public void addEngine( String clazz) { c = Class.forName(clazz); if( ReconstructionEngine.class.isAssignableFrom(c)==true){ ReconstructionEngine engine = (ReconstructionEngine) c.newInstance(); + engine.init(); this.processorEngines.put(engine.getName(), engine); } else { System.out.println(">>>> ERROR: class is not a reconstruction engine : " + clazz); @@ -170,7 +216,7 @@ public void addEngine( String clazz) { Logger.getLogger(EngineProcessor.class.getName()).log(Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { Logger.getLogger(EngineProcessor.class.getName()).log(Level.SEVERE, null, ex); - } + } } /** * Initialize all the engines in the chain. @@ -186,7 +232,7 @@ public void init(){ } /** * process a single event through the chain. - * @param event + * @param event */ public void processEvent(DataEvent event){ for(Map.Entry engine : this.processorEngines.entrySet()){ @@ -195,14 +241,14 @@ public void processEvent(DataEvent event){ //System.out.println("processing event"); engine.getValue().processDataEvent(event); } catch (Exception e){ - + System.out.println("[Exception] >>>>> engine : " + engine.getKey()); System.out.println(); e.printStackTrace(); } } } - + public void processFile(String file, String output){ this.processFile(file, output, -1); } @@ -215,15 +261,15 @@ public void processFile(String file, String output, int nevents){ if(file.endsWith(".hipo")==true){ HipoDataSource reader = new HipoDataSource(); reader.open(file); - + int eventCounter = 0; HipoDataSync writer = new HipoDataSync(); writer.setCompressionType(2); writer.open(output); - - ProgressPrintout progress = new ProgressPrintout(); + + ProgressPrintout progress = new ProgressPrintout(); while(reader.hasEvent()==true){ - DataEvent event = reader.getNextEvent(); + DataEvent event = reader.getNextEvent(); processEvent(event); writer.writeEvent(event); eventCounter++; @@ -245,34 +291,67 @@ public void show(){ System.out.println(String.format("%-24s | %s", entry.getKey(),entry.getValue().getClass().getName())); } } - + public static void main(String[] args){ - + OptionParser parser = new OptionParser("recon-util"); parser.addRequired("-o","output.hipo"); parser.addRequired("-i","input.hipo"); parser.setRequiresInputList(false); parser.addOption("-c","0","use default configuration [0 - no, 1 - yes/default, 2 - all services] "); parser.addOption("-n","-1","number of events to process"); + parser.addOption("-y","0","yaml file"); parser.setDescription("previously known as notsouseful-util"); - + parser.parse(args); - + if(parser.hasOption("-i")==true&&parser.hasOption("-o")==true){ - + List services = parser.getInputList(); - + String inputFile = parser.getOption("-i").stringValue(); String outputFile = parser.getOption("-o").stringValue(); - + /*for(int i =1; i < args.length; i++){ services.add(args[i]); }*/ - + EngineProcessor proc = new EngineProcessor(); int config = parser.getOption("-c").intValue(); int nevents = parser.getOption("-n").intValue(); - if(config>0){ + String yamlFileName = parser.getOption("-y").stringValue(); + if(yamlFileName!="0") { + try { + InputStream input = new FileInputStream(yamlFileName); + Yaml yaml = new Yaml(); + Map yamlConf = (Map) yaml.load(input); + JSONObject jsonObject=new JSONObject(yamlConf); + System.out.println(jsonObject.getJSONObject("configuration").getJSONObject("services")); + for(Object obj: jsonObject.getJSONArray("services")) { + if(obj instanceof JSONObject) { + JSONObject service = (JSONObject) obj; + String name = service.getString("name"); + String engineClass = service.getString("class"); + System.out.println(name); + System.out.println(engineClass); + JSONObject configs = jsonObject.getJSONObject("configuration").getJSONObject("services"); + if(configs.has(name)) { + proc.addEngine(name, engineClass, configs.getJSONObject(name).toString()); + } else { + proc.addEngine(name, engineClass); + } + } +// System.out.println(yamlConf.get("configuration").get("services")); +// String jsonConf = gson.toJson(yamlConf["configuration"]["services"][service["name"]]); + } + } catch (FileNotFoundException ex) { + Logger.getLogger(EngineProcessor.class.getName()).log(Level.SEVERE, null, ex); + } catch (IOException ex) { + Logger.getLogger(EngineProcessor.class.getName()).log(Level.SEVERE, null, ex); + } catch (ClassCastException | YAMLException ex) { + Logger.getLogger(EngineProcessor.class.getName()).log(Level.SEVERE, null, ex); + } + } else if (config>0){ if(config>2){ proc.initCaloDebug(); } else if(config==2){ @@ -286,8 +365,7 @@ public static void main(String[] args){ proc.addEngine(engine); } } - proc.init(); - proc.processFile(inputFile,outputFile,nevents); + proc.processFile(inputFile,outputFile,nevents); } } } From 53d72f7c046306cb2801d611b5b03162f3f5f6e3 Mon Sep 17 00:00:00 2001 From: dcpayette Date: Thu, 29 Aug 2019 10:03:10 -0400 Subject: [PATCH 036/235] correction to jar filename --- build-coatjava.sh | 2 +- reconstruction/rtpc/pom.xml | 2 +- .../src/main/java/org/jlab/rec/rtpc/hit/HelixFitJava.java | 3 --- .../src/main/java/org/jlab/rec/rtpc/hit/HelixFitTest.java | 4 ---- 4 files changed, 2 insertions(+), 9 deletions(-) diff --git a/build-coatjava.sh b/build-coatjava.sh index 1c171c7a63..4db6b3e139 100755 --- a/build-coatjava.sh +++ b/build-coatjava.sh @@ -109,6 +109,6 @@ cp reconstruction/rich/target/clas12detector-rich-*-SNAPSHOT.jar coatjava/lib/se cp reconstruction/fvt/target/clas12detector-fmt-*-SNAPSHOT.jar coatjava/lib/services/ cp reconstruction/eb/target/clas12detector-eb-*-SNAPSHOT.jar coatjava/lib/services/ cp reconstruction/band/target/clas12detector-band-*-SNAPSHOT.jar coatjava/lib/services/ -cp reconstruction/rtpc/target/rtpc-*-SNAPSHOT.jar coatjava/lib/services/ +cp reconstruction/rtpc/target/clas12detector-rtpc-*-SNAPSHOT.jar coatjava/lib/services/ echo "COATJAVA SUCCESSFULLY BUILT !" diff --git a/reconstruction/rtpc/pom.xml b/reconstruction/rtpc/pom.xml index 70a1b526c5..dbf046d4f7 100644 --- a/reconstruction/rtpc/pom.xml +++ b/reconstruction/rtpc/pom.xml @@ -5,7 +5,7 @@ 4.0.0 org.jlab.clas12.detector - rtpc + clas12detector-rtpc 1.0-SNAPSHOT jar diff --git a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/HelixFitJava.java b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/HelixFitJava.java index db56894cbf..af4f181377 100644 --- a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/HelixFitJava.java +++ b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/HelixFitJava.java @@ -822,9 +822,6 @@ HelixFitObject HelixFit(int PointNum, double szPos[][], double R, double A, doub h.set_Rho(R); h.set_Phi(Phi_deg); h.set_Theta(Theta_deg); - h.set_A(A); - h.set_B(B); - h.set_Z0(Z0); return h; } diff --git a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/HelixFitTest.java b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/HelixFitTest.java index 7a2d4bbae4..b8100227ed 100644 --- a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/HelixFitTest.java +++ b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/HelixFitTest.java @@ -7,10 +7,6 @@ import java.util.HashMap; import java.util.List; -import java.util.Vector; -import org.jlab.groot.data.*; -import org.jlab.groot.ui.*; -import org.jlab.groot.graphics.*; /** * From 99d0dfa393cf00010354b8380fe92fb7489ffe5f Mon Sep 17 00:00:00 2001 From: Raffaella De Vita Date: Wed, 4 Sep 2019 16:29:42 +0200 Subject: [PATCH 037/235] FTOF: fixed formula in matched cluster time computation --- .../java/org/jlab/rec/tof/cluster/ftof/ClusterMatcher.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/reconstruction/tof/src/main/java/org/jlab/rec/tof/cluster/ftof/ClusterMatcher.java b/reconstruction/tof/src/main/java/org/jlab/rec/tof/cluster/ftof/ClusterMatcher.java index 85e6a42fdf..876db81233 100644 --- a/reconstruction/tof/src/main/java/org/jlab/rec/tof/cluster/ftof/ClusterMatcher.java +++ b/reconstruction/tof/src/main/java/org/jlab/rec/tof/cluster/ftof/ClusterMatcher.java @@ -3,6 +3,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Collections; +import org.jlab.clas.pdg.PhysicsConstants; import org.jlab.geom.prim.Vector3D; import org.jlab.io.base.DataBank; @@ -301,7 +302,7 @@ private double[] get_CorrectedHitTime(Cluster clus1A, Cluster clus1B) { double term3 = 1. / delta_t1a + 1. / delta_t1b; for (int i = 0; i < 3; i++) { if (this._deltaPathLen[i] > 0) { - term2[i] = (clus1A.get_t() - this._deltaPathLen[i] / Beta) / delta_t1a; + term2[i] = (clus1A.get_t() - this._deltaPathLen[i] / Beta/ PhysicsConstants.speedOfLight()) / delta_t1a; tCorr[i] = (term1 + term2[i]) / term3; } } From bda1d0bb96a876f8d7aa33ef3bf6e05b526fe96b Mon Sep 17 00:00:00 2001 From: dcpayette Date: Tue, 10 Sep 2019 02:36:34 -0400 Subject: [PATCH 038/235] updates to fix zvertex in helix fit --- .../org/jlab/rec/rtpc/hit/FinalTrackInfo.java | 1 + .../org/jlab/rec/rtpc/hit/HelixFitJava.java | 29 ++++++++++++++----- .../org/jlab/rec/rtpc/hit/HelixFitTest.java | 2 +- .../org/jlab/service/rtpc/RTPCEngine.java | 1 + 4 files changed, 24 insertions(+), 9 deletions(-) diff --git a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/FinalTrackInfo.java b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/FinalTrackInfo.java index ab3c89995c..9edb5f9db6 100644 --- a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/FinalTrackInfo.java +++ b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/FinalTrackInfo.java @@ -24,6 +24,7 @@ public FinalTrackInfo(double px, double py, double pz, double vz, double tl, dou _px = px; _py = py; _pz = pz; + _vz = vz; _tl = tl; _dEdx = dEdx; } diff --git a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/HelixFitJava.java b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/HelixFitJava.java index af4f181377..58bfd234f6 100644 --- a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/HelixFitJava.java +++ b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/HelixFitJava.java @@ -709,10 +709,20 @@ void CorrHelixRPhi(double Rho, double Phi) // DCA: distance of closest approach to beamline // Chi2: ch2ph+ch2z/(npt-5) \------------------------------------------------------------------------*/ - HelixFitObject helix_fit(int PointNum,double szPos[][], double Rho, double A, double B, - double Phi, double Theta, double X0, double Y0,double Z0, - double DCA, double Chi2,int fit_track_to_beamline) + HelixFitObject helix_fit(int PointNum,double szPos[][],int fit_track_to_beamline)// double Rho, double A, double B, + //double Phi, double Theta, double X0, double Y0,double Z0, + //double DCA, double Chi2,int fit_track_to_beamline) { + double Rho; + double A; + double B; + double Phi; + double Theta; + double X0; + double Y0; + double Z0; + double DCA; + double Chi2; int kMaxHit = 200; //set it to 200 to match that one in rwfthc.cc double PI = Math.acos(0.0)*2.0; @@ -808,13 +818,16 @@ C TAN(LAMBDA) {=DZ/DS}TAN(ANGLE TO X,Y PLANE) } /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ - HelixFitObject HelixFit(int PointNum, double szPos[][], double R, double A, double B, - double Phi_deg, double Theta_deg, double Z0, int fit_track_to_beamline ) + HelixFitObject HelixFit(int PointNum, double szPos[][], int fit_track_to_beamline )// double R, double A, double B, + //double Phi_deg, double Theta_deg, double Z0, int fit_track_to_beamline ) { double PI=Math.acos(0.0)*2; - double Rho=0,Phi=0,Theta=0,X0=0,Y0=0,DCA=0,Chi2=0; - HelixFitObject h = helix_fit(PointNum, szPos, Rho, A, B, Phi, Theta, - X0, Y0, Z0, DCA, Chi2, fit_track_to_beamline); + //double Rho=0,Phi=0,Theta=0,X0=0,Y0=0,DCA=0,Chi2=0; + double R; + double Phi_deg; + double Theta_deg; + + HelixFitObject h = helix_fit(PointNum, szPos, fit_track_to_beamline); R=Math.abs(h.get_Rho()); Phi_deg=h.get_Phi()*180./PI; diff --git a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/HelixFitTest.java b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/HelixFitTest.java index b8100227ed..f2f0a4a80d 100644 --- a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/HelixFitTest.java +++ b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/HelixFitTest.java @@ -25,7 +25,7 @@ public HelixFitTest(HitParameters params){ szpos[hit][2] = recotrackmap.get(TID).get(hit).z(); } HelixFitJava h = new HelixFitJava(); - HelixFitObject ho = h.HelixFit(hit,szpos,0,0,0,0,0,0,1); + HelixFitObject ho = h.HelixFit(hit,szpos,1); double momfit = ho.get_Mom(); double px = ho.get_px(); double py = ho.get_py(); diff --git a/reconstruction/rtpc/src/main/java/org/jlab/service/rtpc/RTPCEngine.java b/reconstruction/rtpc/src/main/java/org/jlab/service/rtpc/RTPCEngine.java index 062ac0f435..abfb36ad89 100644 --- a/reconstruction/rtpc/src/main/java/org/jlab/service/rtpc/RTPCEngine.java +++ b/reconstruction/rtpc/src/main/java/org/jlab/service/rtpc/RTPCEngine.java @@ -102,6 +102,7 @@ public static void main(String[] args){ DataEvent event = reader.getNextEvent(); en.processDataEvent(event); writer.writeEvent(event); + } writer.close(); From 257f458d9a80e98f3c2ce4458efe7997ec4d7b0d Mon Sep 17 00:00:00 2001 From: dcpayette Date: Tue, 10 Sep 2019 02:42:35 -0400 Subject: [PATCH 039/235] removed outdated classes --- .../org/jlab/rec/rtpc/hit/MapCombine.java | 284 ------------------ .../java/org/jlab/rec/rtpc/hit/PadAve.java | 92 ------ .../java/org/jlab/rec/rtpc/hit/PadFit.java | 111 ------- 3 files changed, 487 deletions(-) delete mode 100644 reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/MapCombine.java delete mode 100644 reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/PadAve.java delete mode 100644 reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/PadFit.java diff --git a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/MapCombine.java b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/MapCombine.java deleted file mode 100644 index 070969a29f..0000000000 --- a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/MapCombine.java +++ /dev/null @@ -1,284 +0,0 @@ -package org.jlab.rec.rtpc.hit; -/* -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.ArrayList; - -import java.util.concurrent.ConcurrentHashMap; - -import javax.swing.JFrame; - -import org.jlab.clas.physics.LorentzVector; -import org.jlab.clas.physics.Vector3; -import org.jlab.groot.data.GraphErrors; -import org.jlab.groot.data.H2F; -import org.jlab.groot.graphics.EmbeddedCanvas; - -public class MapCombine { - - public void MC(HitParameters params, boolean draw) { - - HashMap> TAMap = params.get_FinalTIDMap(); - HashMap>> TFMap = params.get_strkTIDMap(); - HashMap ADCMap = params.get_ADCMap(); - - List PadList = new ArrayList(); - double maxvalue = 0; - double thresh = 0; - int TrigWindSize = params.get_TrigWindSize(); - double sumnumer = 0; - double sumdenom = 0; - int count = 0; - int newtid = 0; - - HashMap weightave = new HashMap(); - HashMap weightaveadc = new HashMap(); - HashMap> trTFMap = new HashMap>(); - HashMap> alltracks = new HashMap>(); - HitVector vtmp = new HitVector(); - HitVector v3tmp = new HitVector(); - HitVector hitvec = new HitVector(); - List toListvec = new ArrayList(); - double larget = 0; - int countadcvalues = 0; - - /*GraphErrors g = new GraphErrors(); - EmbeddedCanvas c = new EmbeddedCanvas(); - JFrame jf = new JFrame(); - jf.setSize(800,600);*/ - //System.out.println(TIDMap.size()); - //for(Hit hit : rawHits) { -/* for(int TID : TFMap.keySet()){ - //System.out.println(" "); - larget = 0; - PadList.clear(); - weightave.clear(); - for(int time : TFMap.get(TID).keySet()) - { - for(int pad = 0; pad < TFMap.get(TID).get(time).size(); pad++) - { - //System.out.println(TID + " " + time + " " + TFMap.get(TID).get(time).get(pad)); - if(!PadList.contains(TFMap.get(TID).get(time).get(pad))) - { - PadList.add(TFMap.get(TID).get(time).get(pad)); - } - } - } - - for(int pad = 0; pad < PadList.size(); pad++) - { - for(int time : TFMap.get(TID).keySet()) - { - if(TFMap.get(TID).get(time).contains(PadList.get(pad))) - { - if(ADCMap.get(PadList.get(pad))[time]>maxvalue) - { - maxvalue = ADCMap.get(PadList.get(pad))[time]; - //System.out.println(maxvalue); - } - } - } - thresh = maxvalue/2; - for(int time = 0; time < TrigWindSize; time+=120) - { - if(ADCMap.get(PadList.get(pad))[time] > thresh) - { - sumnumer += ADCMap.get(PadList.get(pad))[time]*time; - sumdenom += ADCMap.get(PadList.get(pad))[time]; - countadcvalues++; - //System.out.println(PadList.get(pad) + " " + time); - } - } - if(sumnumer/sumdenom >= larget) - { - larget = sumnumer/sumdenom; - } - //System.out.println("weightave " + PadList.get(pad) + " " + sumnumer/sumdenom); - weightave.put(PadList.get(pad), sumnumer/sumdenom); - weightaveadc.put(PadList.get(pad), sumdenom); - sumnumer = 0; - sumdenom = 0; - maxvalue = 0; - countadcvalues = 0; - //padvec = PadCoords(PadList.get(pad)); - //gZvsT.addPoint(weightave.get(PadList.get(pad)), padvec.z(), 0, 0); - //gPhivsT.addPoint(weightave.get(PadList.get(pad)), Math.atan2(padvec.y(),padvec.x()),0,0); - } - - int pad = 0; - double avetime = 0; - double adc = 0; - trTFMap.put(TID,new ArrayList()); - for(int p = 0; p < PadList.size(); p++) - { - pad = PadList.get(p); - avetime = weightave.get(pad); - adc = weightaveadc.get(pad); - //LorentzVector v = new LorentzVector(avetime,Math.atan2(PadCoords(pad).y(),PadCoords(pad).x()),PadCoords(pad).z(),pad); - HitVector v = new HitVector(pad,PadCoords(pad).z(),Math.atan2(PadCoords(pad).y(),PadCoords(pad).x()),avetime,adc); - - trTFMap.get(TID).add(v); - } - - - //trTFMap.put(TID, new HashMap()); - //trTFMap.get(TID).putAll(weightave); - - //System.out.println(" "); - } - for(int choosetid : trTFMap.keySet()) { - double smalltime = 0; - for(int i = 0; i < trTFMap.get(choosetid).size(); i++) - { - smalltime = trTFMap.get(choosetid).get(i).time(); - for(int j = 0; j < trTFMap.get(choosetid).size();j++) - { - if(trTFMap.get(choosetid).get(j).time() < smalltime && i!=j) - { - trTFMap.get(choosetid).add(j, trTFMap.get(choosetid).get(i)); - trTFMap.get(choosetid).remove(i+1); - break; - } - } - } - } - - for(int i : TAMap.keySet()) - { - //toListvec.clear(); - alltracks.put(newtid, new ArrayList()); - for(int j = 0; j < TAMap.get(i).size(); j++) - { - vtmp = TAMap.get(i).get(j); - //v3tmp = new Vector3(vtmp.pad(),vtmp.time(),0); - //System.out.println(vtmp.e() + " " + vtmp.px()); - //System.out.println(v3tmp.x() + " " + v3tmp.y()); - //toListvec.add(v3tmp); - alltracks.get(newtid).add(vtmp); - } - //System.out.println(toListvec.size()); - //System.out.println(" "); - //alltracks.put(newtid, toListvec); - - newtid++; - - } - toListvec.clear(); - //System.out.println(" "); - for(int i : trTFMap.keySet()) - { - //System.out.println(" "); - //toListvec.clear(); - alltracks.put(newtid, new ArrayList()); - //for(int pad : trTFMap.get(i).keySet()) - for(int j = 0; j < trTFMap.get(i).size(); j++) - { - v3tmp = trTFMap.get(i).get(j); - //System.out.println(pad); - //v3tmp = new HitVector(pad,trTFMap.get(i).get(pad),0); - //System.out.println(v3tmp.x() + " " + v3tmp.y()); - //toListvec.add(v3tmp); - alltracks.get(newtid).add(v3tmp); - } - //System.out.println(" "); - //System.out.println(toListvec.size()); - //alltracks.put(newtid, toListvec); - newtid++; - } - HashMap largetmap = new HashMap(); - larget = 0; - HashMap histmap = new HashMap(); - HashMap canvasmap = new HashMap(); - HashMap framemap = new HashMap(); - //H2F adcvst = new H2F("adcvst",500,3000,12000,500,0,10); - //System.out.println(" "); - List marktid = new ArrayList(); - for(int i : alltracks.keySet()) - { - larget = 0; - /*if(alltracks.get(i).size() < 6) { - System.out.println("removed track with " + alltracks.get(i).size() + " hits"); - marktid.add(i); - continue; - }*/ -/* histmap.put(i, new GraphErrors()); - //System.out.println(i); - for(int j = 0; j < alltracks.get(i).size(); j++) - { - //if(j < 3) {g.addPoint(alltracks.get(i).get(j).y(), y, 0, 0); - //System.out.println(i + " " + alltracks.get(i).get(j).time() + " " + alltracks.get(i).get(j).adc()); - histmap.get(i).addPoint(alltracks.get(i).get(j).time(), alltracks.get(i).get(j).adc(),0,0); - if(alltracks.get(i).get(j).time() > larget) - { - larget = alltracks.get(i).get(j).time(); - - } - } - canvasmap.put(i, new EmbeddedCanvas()); - canvasmap.get(i).draw(histmap.get(i)); - framemap.put(i, new JFrame()); - framemap.get(i).setSize(800, 600); - framemap.get(i).add(canvasmap.get(i)); - if(draw) framemap.get(i).setVisible(true); - largetmap.put(i, larget); - //System.out.println(" "); - } - /*for(int i = 0; i < marktid.size(); i++) { - alltracks.remove(i); - }*/ -/* for(int z : canvasmap.keySet()) { - //canvasmap.get(z).save(z + ".png"); - } - EmbeddedCanvas c_adcvst = new EmbeddedCanvas(); - c_adcvst.draw(histmap.get(0)); - if(draw) { - JFrame j_adcvst = new JFrame(); - j_adcvst.setSize(800, 600); - j_adcvst.add(c_adcvst); - j_adcvst.setVisible(true); - } - - //System.out.println("There are " + alltracks.size() + " tracks sorted in this event!"); - params.set_alltracks(alltracks); - params.set_largetmap(largetmap); - } - - private Vector3 PadCoords(int cellID) { - - double PAD_W = 2.79; // in mm - double PAD_S = 80.0; //in mm - double PAD_L = 4.0; // in mm - double RTPC_L= 384.0; // in mm - double phi_pad = 0; - //double Num_of_Rows = (2.0*(Math.PI)*PAD_S)/PAD_W; - double Num_of_Cols = RTPC_L/PAD_L; - double PI=Math.PI; - double z0 = -(RTPC_L/2.0); - double phi_per_pad = PAD_W/PAD_S; // in rad - double chan = (double)cellID; - double col = chan%Num_of_Cols; - double row=(chan-col)/Num_of_Cols; - double z_shift = row%4; - - phi_pad=(row*phi_per_pad)+(phi_per_pad/2.0); - - if(phi_pad>= 2.0*PI) - { - phi_pad -= 2.0*PI; - } - if(phi_pad<0) - { - phi_pad += 2.0*PI; - } - - double z_pad=z0+(col*PAD_L)+(PAD_L/2.0)+z_shift; - - Vector3 PadCoords = new Vector3(PAD_S*Math.cos(phi_pad),PAD_S*Math.sin(phi_pad),z_pad); - return PadCoords; - - } - - -} -*/ \ No newline at end of file diff --git a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/PadAve.java b/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/PadAve.java deleted file mode 100644 index 206e8b4654..0000000000 --- a/reconstruction/rtpc/src/main/java/org/jlab/rec/rtpc/hit/PadAve.java +++ /dev/null @@ -1,92 +0,0 @@ -package org.jlab.rec.rtpc.hit; -/* -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.util.concurrent.ConcurrentHashMap; -import java.util.HashMap; -import java.util.List; -import java.util.ArrayList; - -public class PadAve { - public void TimeAverage(HitParameters params){ - - int SignalStepSize = params.get_SignalStepSize(); // step size of the signal before integration (arbitrary value) - int BinSize = params.get_BinSize(); // electronics integrates the signal over 40 ns - int NBinKept = params.get_NBinKept(); // only 1 bin over 3 is kept by the daq - int TrigWindSize = params.get_TrigWindSize(); // Trigger window should be 10 micro - int NTrigSampl = TrigWindSize/BinSize; // number of time samples - double inte=0; - double inte_tot; // integral of the signal in BinSize - double max_inte=0; // maximum of the integral to help the fit - double max_t=0; - double sumnumer = 0; - double sumdenom = 0; - double weightave = 0; - double timesum = 0; - HashMap ADCMap = params.get_ADCMap(); - HashMap> TimeMap = params.get_TimeMap(); - List PadList = params.get_PadList(); - List PadN = params.get_PadN(); - List Pad = params.get_Pad(); - List ADC = params.get_ADC(); - List Time_o = params.get_Time_o(); - List weightavevec = new ArrayList(); - List maxinte = new ArrayList(); - boolean flag_event = false; - int eventnum = params.get_eventnum(); - //try{ - //FileWriter write2 = new FileWriter("/Users/davidpayette/Documents/FileOutput/Output.txt",true); - //write2.write("Event Number" + "\t" + "Pad Number" + "\t" + "Time Value for each bin" + "\t" + "ADC value for each bin" + "\r\n"); - - - inte=0; - for(int p=0;p0) inte+=0.5*(ADCMap.get(PadList.get(p))[t-SignalStepSize]+ADCMap.get(PadList.get(p))[t])*SignalStepSize; - inte_tot+=inte; - if(t%BinSize==0 && t>0){ // integration over BinSize - if(t%(BinSize*NBinKept)==0){ // one BinSize over NBinKept is read out, hence added to the histogram - if(max_inte Adcmap = new HashMap<>(); - List PadList = params.get_PadList(); - List PadN = params.get_PadN(); - List Pad = params.get_Pad(); - List ADC = params.get_ADC(); - List Time_o = params.get_Time_o(); - boolean flag_event = false; - int eventnum = params.get_eventnum(); - - /*JFrame j1 = new JFrame(); - GraphErrors g1 = new GraphErrors(); - g1.setMarkerSize(0); - g1.setTitleX("Time(ns)"); - g1.setTitleY("ADC"); - g1.setMarkerSize(3); - EmbeddedCanvas c1 = new EmbeddedCanvas(); - j1.setSize(800, 600); - - - - //F1D f1 = new F1D("f1", "[amp]*gaus(x,[mean],[sigma])",0,1); - - inte=0; - for(int p=0;p0) inte+=0.5*(ADCMap.get(PadList.get(p))[t-SignalStepSize]+ADCMap.get(PadList.get(p))[t])*SignalStepSize; - - inte_tot+=inte; - if(t%BinSize==0 && t>0){ // integration over BinSize - if(t%(BinSize*NBinKept)==0){ // one BinSize over NBinKept is read out, hence added to the histogram - - Adcmap.get(PadList.get(p))[t] = inte; - - //g1.addPoint(t,inte,0,0); - if(max_inte Date: Wed, 11 Sep 2019 09:39:27 -0400 Subject: [PATCH 040/235] prevent division by zero --- .../eb/src/main/java/org/jlab/service/eb/EBAnalyzer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 ab097e5979..d79f4cb1e8 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 @@ -545,7 +545,7 @@ else if (p.getCharge()!=0) { } if (found) break; } - q = delta_t / sigma; + if (sigma>0) q = delta_t / sigma; } // neutrals: From bf900cb1d807619ef7621f2a71216955ce0c2190 Mon Sep 17 00:00:00 2001 From: baltzell Date: Thu, 19 Sep 2019 11:37:01 -0400 Subject: [PATCH 041/235] Upgrade delayed helicity analysis - add delay walking with intermediate integrety checking - separate hardware and software status - do not inherit corrected hardware errors in analysis - multi-run manager, protecting against mixing runs - fix method naming scheme (not backward compatible) - get/search/predict/generated - no more null returns, HelicityBit.UDF instead - misc cleanup --- .../detector/helicity/HelicityAnalysis.java | 158 ------------------ .../helicity/HelicityAnalysisSimple.java | 142 +++++++++------- .../jlab/detector/helicity/HelicityBit.java | 1 + .../detector/helicity/HelicityGenerator.java | 24 ++- .../detector/helicity/HelicitySequence.java | 141 ++++++++++------ .../helicity/HelicitySequenceDelayed.java | 104 ++++++------ .../helicity/HelicitySequenceManager.java | 122 ++++++++++++++ .../jlab/detector/helicity/HelicityState.java | 67 +++++--- 8 files changed, 408 insertions(+), 351 deletions(-) delete mode 100644 common-tools/clas-detector/src/main/java/org/jlab/detector/helicity/HelicityAnalysis.java create mode 100644 common-tools/clas-detector/src/main/java/org/jlab/detector/helicity/HelicitySequenceManager.java diff --git a/common-tools/clas-detector/src/main/java/org/jlab/detector/helicity/HelicityAnalysis.java b/common-tools/clas-detector/src/main/java/org/jlab/detector/helicity/HelicityAnalysis.java deleted file mode 100644 index d43bfef54b..0000000000 --- a/common-tools/clas-detector/src/main/java/org/jlab/detector/helicity/HelicityAnalysis.java +++ /dev/null @@ -1,158 +0,0 @@ -package org.jlab.detector.helicity; - -import java.util.List; -import java.util.ArrayList; -import java.util.Arrays; - -import org.jlab.jnp.hipo4.io.HipoReader; -import org.jlab.jnp.hipo4.data.Event; -import org.jlab.jnp.hipo4.data.Bank; -import org.jlab.jnp.hipo4.data.SchemaFactory; - -/** - * An example of reading the helicity flips, analyzing the sequence, and getting - * the state for any event. - * - * @author baltzell - */ -public class HelicityAnalysis { - - /** - * This reads tag=1 events for HEL::flip banks, and initializes and returns - * a {@link HelicitySequenceDelayed} with delay set to zero. The delay can - * be changed later before a user tries to access the sequence. - * - * @param filenames list of names of HIPO file to read - * @return unanalyzed sequence - */ - public static HelicitySequenceDelayed readSequence(List filenames) { - - HelicitySequenceDelayed seq=new HelicitySequenceDelayed(8); - - for (String filename : filenames) { - - HipoReader reader = new HipoReader(); - reader.setTags(1); - reader.open(filename); - - SchemaFactory schema = reader.getSchemaFactory(); - - while (reader.hasNext()) { - - Event event=new Event(); - Bank flipBank=new Bank(schema.getSchema("HEL::flip")); - - reader.nextEvent(event); - event.read(flipBank); - - if (flipBank.getRows()<1) continue; - - seq.addState(HelicityState.createFromFlipBank(flipBank)); - } - - reader.close(); - } - - return seq; - } - - public static void main(String[] args) { - - final String dir="/Users/baltzell/data/CLAS12/rg-a/decoded/6b.2.0/"; - final String file="clas_005038.evio.00000-00004.hipo"; - //final String dir="/Users/baltzell/data/CLAS12/rg-b/decoded/"; - //final String file="clas_006432.evio.00041-00042.hipo"; - - List filenames=new ArrayList<>(); - if (args.length>0) filenames.addAll(Arrays.asList(args)); - else filenames.add(dir+file); - - // initialize a sequence from tag=1 events: - HelicitySequenceDelayed seq = HelicityAnalysis.readSequence(filenames); - seq.setVerbosity(1); - final boolean integrity = seq.analyze(); - if (!integrity) { - System.err.println("\n\n######### OOPS\n\n"); - // We may want to investigate further, or discard events. - } - - // print the sequence: - seq.show(); - - // set the appropriate delay for this data: - seq.setDelay(8); - - // now read the full events, e.g. during a normal physics analysis: - int nevents=0; - int nflips=0; - - for (String filename : filenames) { - - HipoReader reader = new HipoReader(); - reader.setTags(0); - reader.open(filename); - - SchemaFactory schema = reader.getSchemaFactory(); - - while (reader.hasNext()) { - - nevents++; - - Bank flipBank=new Bank(schema.getSchema("HEL::flip")); - Bank rcfgBank=new Bank(schema.getSchema("RUN::config")); - Bank onliBank=new Bank(schema.getSchema("HEL::online")); - - Event event=new Event(); - reader.nextEvent(event); - event.read(flipBank); - event.read(rcfgBank); - event.read(onliBank); - - // just to curtail printouts: - if (flipBank.getRows()>0) nflips++; - if (nflips<240) continue; - if (nevents%100!=0) continue; - - long timestamp = -1; - HelicityBit level3 = HelicityBit.UDF; - HelicityBit predicted = HelicityBit.UDF; - HelicityBit measured = HelicityBit.UDF; - HelicityBit lookedup = HelicityBit.UDF; - - // Get RUN::config.timestamp for this event: - if (rcfgBank.getRows()>0) - timestamp = rcfgBank.getLong("timestamp",0); - - // Get HEL::online.rawHelicity, the online, delay-corrected - // helicity for this event (if available): - if (onliBank.getRows()>0) - level3 = HelicityBit.create(onliBank.getByte("helicity",0)); - - // Get the offline, delay-corrected helicity for this event based - // on the measured sequence. If this timestamp is outside the - // measured range, the bit will be null. - if (seq.find(timestamp)!=null) - measured = seq.find(timestamp); - - // Same as previous, except use the pseudo-random generator's - // prediction which provides for bits later than the measured range. - // For example, the last N windows in a given file are measured in - // the next file (or not at all if it's the last file in a run), - // so will only be accessible with the generator. If you try to - // use a timestamp before the measured sequence, the generator will - // return null. - if (seq.findPrediction(timestamp)!=null) - predicted = seq.findPrediction(timestamp); - - if (seq.lookupPrediction(timestamp)!=null) - lookedup = seq.lookupPrediction(timestamp); - - System.out.println(String.format("%d %5d L3/Predict/Measured/Looked = %6s%6s%6s%6s", - timestamp,nflips,level3,predicted,measured,lookedup)); - } - - reader.close(); - - } - } -} diff --git a/common-tools/clas-detector/src/main/java/org/jlab/detector/helicity/HelicityAnalysisSimple.java b/common-tools/clas-detector/src/main/java/org/jlab/detector/helicity/HelicityAnalysisSimple.java index 1faeffa4cf..def72512a6 100644 --- a/common-tools/clas-detector/src/main/java/org/jlab/detector/helicity/HelicityAnalysisSimple.java +++ b/common-tools/clas-detector/src/main/java/org/jlab/detector/helicity/HelicityAnalysisSimple.java @@ -1,106 +1,124 @@ package org.jlab.detector.helicity; +import java.util.List; import java.util.ArrayList; import java.util.Arrays; -import java.util.List; -import org.jlab.jnp.hipo4.data.Bank; + +import org.jlab.jnp.hipo4.io.HipoReader; import org.jlab.jnp.hipo4.data.Event; +import org.jlab.jnp.hipo4.data.Bank; import org.jlab.jnp.hipo4.data.SchemaFactory; -import org.jlab.jnp.hipo4.io.HipoReader; /** + * An example of reading the helicity flips, analyzing the sequence, and getting + * the state for any event. * + * The 2 lines marked with "!!!" are the essential delayed-helicity correction + * and requires input from RUN::config.run and RUN::config.timestamp. + * * @author baltzell */ public class HelicityAnalysisSimple { - /** - * Example of accessing delay-corrected helicity. - * - * The 2 lines marked with "!!!" are specific to delay-corrected helicity. - * - * @param args a list of input HIPO4 filenames - */ public static void main(String[] args) { + + //final String dir="/Users/baltzell/data/CLAS12/rg-a/decoded/6b.2.0/"; + //final String file="clas_005038.evio.00000-00004.hipo"; + final String dir="/Users/baltzell/data/CLAS12/rg-b/decoded/"; + final String file="clas_006432.evio.00041-00042.hipo"; - final String dir="/Users/baltzell/data/CLAS12/rg-a/decoded/6b.2.0/"; - final String file="clas_005038.evio.00000-00004.hipo"; - //final String dir="/Users/baltzell/data/CLAS12/rg-b/decoded/"; - //final String file="clas_006432.evio.00041-00042.hipo"; List filenames=new ArrayList<>(); - - // override with user-inputs if available: if (args.length>0) filenames.addAll(Arrays.asList(args)); else filenames.add(dir+file); - // 1!!!1 initialize the helicity sequence: - HelicitySequenceDelayed seq = HelicityAnalysis.readSequence(filenames); - - seq.setVerbosity(2); + // !!! 111 + // initialize a sequence, with delay=8, from tag=1 events: + HelicitySequenceManager seq = new HelicitySequenceManager(8,filenames); - seq.analyze(); - - seq.show(); + // or initialize with a reader object: + //HelicitySequenceManager seq = new HelicitySequenceManager(8,HipoReader); + + // increase info printouts: + //seq.setVerbosity(2); + // print the sequence if any problems: + //if (!seq.analyze()) seq.show(); + // now read the full events, e.g. during a normal physics analysis: - - int nGoodEvents=0; - int nBadEvents=0; - int nMismatches=0; - int nMismatches2=0; + int nevents=0; + int nflips=0; + int nbad=0; - // loop over files: for (String filename : filenames) { - // open the file, initialize reader/tags/schema: HipoReader reader = new HipoReader(); reader.setTags(0); reader.open(filename); + SchemaFactory schema = reader.getSchemaFactory(); - - // loop over events: + while (reader.hasNext()) { - - // read the event: - Event event=new Event(); - reader.nextEvent(event); + + nevents++; - // get the event's timestamp: + Bank flipBank=new Bank(schema.getSchema("HEL::flip")); Bank rcfgBank=new Bank(schema.getSchema("RUN::config")); + Bank onliBank=new Bank(schema.getSchema("HEL::online")); + + Event event=new Event(); + reader.nextEvent(event); + event.read(flipBank); event.read(rcfgBank); - if (rcfgBank.getRows()<=0) continue; - final int evno = rcfgBank.getInt("event",0); + event.read(onliBank); + + // Get RUN::config.runno/timestamp for this event: + if (rcfgBank.getRows()<=0) continue; final long timestamp = rcfgBank.getLong("timestamp",0); - - // 2!!!2 use the timestamp to get the delay-corrected helicity: - HelicityBit predicted = seq.findPrediction(timestamp); + final int runno = rcfgBank.getInt("run",0); - HelicityBit lookup = seq.lookupPrediction(timestamp); - if (lookup!=HelicityBit.UDF && predicted!=lookup) { - nMismatches++; - } - HelicityBit measured = seq.find(timestamp); - if (measured!=HelicityBit.UDF && predicted!=measured) { - nMismatches2++; - } + // Get HEL::online.rawHelicity, the online, delay-corrected + // helicity for this event (if available): + //HelicityBit level3 = HelicityBit.UDF; + //if (onliBank.getRows()>0) + // level3 = HelicityBit.create(onliBank.getByte("helicity",0)); + + // !!! 222 + // Get the offline, delay-corrected helicity for this event + // based on the measured sequence. If the timestamp is outside + // the measured range, or the measured sequence is corrupted between + // the timestamp and the delayed timestamp, this will return null. + final HelicityBit measured = seq.search(runno,timestamp); + + // Same as previous, except assumes the pseudo-random generator's + // prediction, which allows to access states later than the measured + // range and cross intermediate sequence corruption. However, it + // requires a 4x longer consecutive valid sequence for initialization + // than the non-generator methods. + //final HelicityBit lookedup = seq.searchGenerated(runno,timestamp); - if ( (predicted==null || predicted==HelicityBit.UDF) && - timestamp>=seq.generator.getTimestamp()) { - nBadEvents++; - System.out.println(String.format("Bad Helicity: event=%d time=%d helicity=%s",evno,timestamp,predicted)); + // Same as previous, except relies on TI clock synced with helicity clock + // instead of counting states: + //final HelicityBit predicted = seq.predictGenerated(runno,timestamp); + + if (measured==HelicityBit.UDF) { + nbad++; } else { - // proceed with physics analysis: - nGoodEvents++; + // proceed with physics analysis } + + //if (flipBank.getRows()>0) nflips++; + //if (nflips>240 && nevents%100!=0) { + // System.out.println(String.format("%d %5d L3/Measured/LookedG/PredictG = %6s%6s%6s%6s", + // timestamp,nflips,level3,measured,lookedup,predicted)); + //} } + + System.out.println(String.format("HelicityAnalysisSimple: EVENTS BAD/TOTAL/FRACTION = %d/%d/%.2f%%", + nbad,nevents,100*((float)nbad)/nevents)); + reader.close(); + } - System.out.println(String.format("HelicityAnalysisSimple: BAD/GOOD/FRACTION=%d/%d/%.5f%%", - nBadEvents,nGoodEvents,100*((float)nBadEvents)/(nBadEvents+nGoodEvents))); - //System.out.println(String.format("HelicityAnalysisSimple: MISMATCHES/FRACTION=%d/%.5f%%", - // nMismatches,100*((float)nMismatches)/(nBadEvents+nGoodEvents))); - System.out.println(String.format("HelicityAnalysisSimple: MISMATCHES2/FRACTION=%d/%.5f%%", - nMismatches2,100*((float)nMismatches2)/(nBadEvents+nGoodEvents))); } } diff --git a/common-tools/clas-detector/src/main/java/org/jlab/detector/helicity/HelicityBit.java b/common-tools/clas-detector/src/main/java/org/jlab/detector/helicity/HelicityBit.java index c1604e5b23..2d9998b335 100644 --- a/common-tools/clas-detector/src/main/java/org/jlab/detector/helicity/HelicityBit.java +++ b/common-tools/clas-detector/src/main/java/org/jlab/detector/helicity/HelicityBit.java @@ -32,6 +32,7 @@ public static HelicityBit create(byte value) { public static HelicityBit getFlipped(HelicityBit bit) { if (bit==PLUS) return MINUS; if (bit==MINUS) return PLUS; + if (bit==DNE) return DNE; return UDF; } diff --git a/common-tools/clas-detector/src/main/java/org/jlab/detector/helicity/HelicityGenerator.java b/common-tools/clas-detector/src/main/java/org/jlab/detector/helicity/HelicityGenerator.java index 23b213bb22..1bc19ebab2 100644 --- a/common-tools/clas-detector/src/main/java/org/jlab/detector/helicity/HelicityGenerator.java +++ b/common-tools/clas-detector/src/main/java/org/jlab/detector/helicity/HelicityGenerator.java @@ -3,6 +3,7 @@ import java.util.List; import java.util.ArrayList; import java.util.Collections; +import java.util.Comparator; /** * Helicity Pseudo-Random Sequence. @@ -24,7 +25,7 @@ * * @author baltzell */ -public final class HelicityGenerator { +public final class HelicityGenerator implements Comparable, Comparator { public static final int REGISTER_SIZE=30; private final List states=new ArrayList<>(); @@ -48,6 +49,18 @@ private int getNextBit() { return nextBit; } + @Override + public int compareTo(HelicityGenerator other) { + if (this.getTimestamp() < other.getTimestamp()) return -1; + if (this.getTimestamp() > other.getTimestamp()) return +1; + return 0; + } + + @Override + public int compare(HelicityGenerator o1, HelicityGenerator o2) { + return o1.compareTo(o2); + } + /** * Get the timestamp of the first state in the generator sequence. * @return timestamp (4ns) @@ -85,7 +98,7 @@ public void reset() { /** * Test whether the generator is sufficiently initialized such that - * {@link getState(int)} method can be called, based on whether the + * {@link #get(int)} method can be called, based on whether the * number of added states is at least {@link REGISTER_SIZE}. * * @return whether the sequence is initialized @@ -146,7 +159,7 @@ public void addState(HelicityState state) { * @param n number of states after the first one. * @return the nth HelicityBit in the sequence. */ - public HelicityBit getState(final int n) { + public HelicityBit get(final int n) { if (!this.initialized()) throw new RuntimeException("Not initialized."); if (n < 0) @@ -309,9 +322,12 @@ else if (iStates.size() > 2 && } if (!this.initialized()) { - System.out.println("HelicityGenerator: Initialization Error."); + System.err.println("HelicityGenerator: Initialization Error."); this.reset(); } + else if (this.verbosity>0) { + System.out.println("HelicityGenerator: Initialized."); + } return this.initialized(); } diff --git a/common-tools/clas-detector/src/main/java/org/jlab/detector/helicity/HelicitySequence.java b/common-tools/clas-detector/src/main/java/org/jlab/detector/helicity/HelicitySequence.java index 056b78249a..7f83255cd3 100644 --- a/common-tools/clas-detector/src/main/java/org/jlab/detector/helicity/HelicitySequence.java +++ b/common-tools/clas-detector/src/main/java/org/jlab/detector/helicity/HelicitySequence.java @@ -3,22 +3,34 @@ import java.util.List; import java.util.ArrayList; import java.util.Collections; -import java.util.Comparator; +import java.util.HashMap; +import java.util.Map; + +import org.jlab.jnp.hipo4.data.Bank; +import org.jlab.jnp.hipo4.data.Event; +import org.jlab.jnp.hipo4.data.SchemaFactory; +import org.jlab.jnp.hipo4.io.HipoReader; /** * Stores a sequence of helicity states and provides timestamp- or state-count- - * based lookup of helicity state based on the measured sequence or pseudo-random + * based search of helicity state based on the measured sequence or pseudo-random * generator sequence, and provides some integrity checking of the sequence, * including comparing the measured and generator sequences. * + * ____________________________________________________________________ * Getter methods naming convention: - * "find" - lookup state based on timestamp - * "get" - lookup state based on state count - * "predict" - use pseudorandom generator (if necessary) + * + * Prefixes: + * "get" - based on state count + * "search" - based on finding timestamp in the measured sequence + * "predict" - based on generator seed time and expected periodicity * + * Suffixes: + * "Generated" - use the psuedo-random generator's sequence + * ____________________________________________________________________ + * * The generator methods are able to look past the measured range, while the - * non-generator methods cannot. Return values are null if the helicity cannot - * be determined. + * non-generator methods cannot. * * The inputs to initialize the sequence are {@link HelicityState} objects, one * per window at the helicity board clock frequency, which contain important @@ -32,7 +44,7 @@ * * @author baltzell */ -public class HelicitySequence implements Comparator { +public class HelicitySequence { // FIXME: these should go to CCDB: public static final double TIMESTAMP_CLOCK=250.0e6; // Hz @@ -40,6 +52,7 @@ public class HelicitySequence implements Comparator { protected boolean halfWavePlate=false; protected boolean analyzed=false; + protected final Map generators=new HashMap<>(); protected final HelicityGenerator generator=new HelicityGenerator(); protected final List states=new ArrayList<>(); protected int verbosity=0; @@ -55,19 +68,6 @@ public boolean getHalfWavePlate() { return this.halfWavePlate; } - /** - * Compare based on timestamp for sorting and List insertion. - * @param o1 - * @param o2 - * @return negative/positive of o1 is before/after o2, else zero. - */ - @Override - public int compare(HelicityState o1, HelicityState o2) { - if (o1.getTimestamp() < o2.getTimestamp()) return -1; - if (o1.getTimestamp() > o2.getTimestamp()) return +1; - return 0; - } - /** * Get the the number of states in the sequence. * @return the number of states @@ -89,6 +89,13 @@ public final boolean addState(HelicityState state) { if (this.verbosity>3) { System.out.println("HelicitySequence: adding state: "+state); } + + // terminate if trying to add more than one run number: + for (HelicityState hs : this.states) { + if (hs.getRun()!=state.getRun()) { + throw new RuntimeException("Run number mismatch: "+state.getRun()+"/"+state.getRun()); + } + } // mark that we'll need to redo the analysis: this.analyzed=false; @@ -102,7 +109,7 @@ public final boolean addState(HelicityState state) { return true; } else { - final int index=Collections.binarySearch(this.states,state,new HelicitySequence()); + final int index=Collections.binarySearch(this.states,state,new HelicityState()); if (index==this.states.size()) { // its timestamp is later than the existing sequence: this.states.add(state); @@ -140,14 +147,14 @@ public final static HelicityBit getBitInQuartet(HelicityBit firstBit, int bitInd * @param timestamp TI timestamp (i.e. RUN::config.timestamp) * @return index */ - protected final int findIndex(long timestamp) { + protected final int searchIndex(long timestamp) { if (!this.analyzed) this.analyze(); if (timestamp < this.getTimestamp(0)) return -1; if (timestamp > this.getTimestamp(this.size()-1)) return -1; // make a fake state for timestamp search: HelicityState state=new HelicityState(); state.setTimestamp(timestamp); - final int index=Collections.binarySearch(this.states,state,new HelicitySequence()); + final int index=Collections.binarySearch(this.states,state,new HelicityState()); final int n = index<0 ? -index-2 : index; return n; } @@ -184,8 +191,8 @@ protected HelicityState getState(int n) { * @param timestamp TI timestamp (i.e. RUN::config.timestamp) * @return the helicity state, null if timestamp is outside of measured range */ - protected HelicityState findState(long timestamp) { - final int index = this.findIndex(timestamp); + protected HelicityState searchState(long timestamp) { + final int index = this.searchIndex(timestamp); if (index < 0) return null; return this.getState(index); } @@ -193,11 +200,11 @@ protected HelicityState findState(long timestamp) { /** * Get the nth state in the measured sequence. * @param n the index of the state, where 0 corresponds to the first state - * @return the helicity state, null if outside the mesaured range + * @return the helicity state, HelicityBit.UDF if outside the mesaured range */ protected HelicityBit get(int n) { HelicityState state = this.getState(n); - if (state==null) return null; + if (state==null) return HelicityBit.UDF; else return state.getHelicity(); } @@ -206,9 +213,9 @@ protected HelicityBit get(int n) { * @param timestamp TI timestamp (i.e. RUN::config.timestamp) * @return the helicity state, null if timestamp is outside of measured range */ - public HelicityBit find(long timestamp) { - HelicityState state = this.findState(timestamp); - if (state==null) return null; + public HelicityBit search(long timestamp) { + HelicityState state = this.searchState(timestamp); + if (state==null) return HelicityBit.UDF; else return state.getHelicity(); } @@ -223,17 +230,17 @@ public HelicityBit find(long timestamp) { * @param n the index of the state * @return the helicity bit */ - protected HelicityBit getPrediction(int n) { + protected HelicityBit getGenerated(int n) { if (!this.analyzed) this.analyze(); - if (!this.generator.initialized()) return null; - if (n-this.generator.getOffset()<0) return null; + if (!this.generator.initialized()) return HelicityBit.UDF; + if (n-this.generator.getOffset()<0) return HelicityBit.UDF; // Generator only knows about first states in a pattern (e.g. quartets), // so get it and then calculate here within that pattern. // FIXME: here we assume the helicity board is in QUARTET configuration. final int nQuartet = (n-this.generator.getOffset())/4; final int nBitInQuartet = (n-this.generator.getOffset())%4; - HelicityBit firstBitInQuartet = this.generator.getState(nQuartet); + HelicityBit firstBitInQuartet = this.generator.get(nQuartet); HelicityBit bit = getBitInQuartet(firstBitInQuartet,nBitInQuartet); // the generator operates on the raw states, so flip it if the HWP is in: @@ -253,15 +260,15 @@ protected HelicityBit getPrediction(int n) { * @param timestamp TI timestamp (i.e. RUN::config.timestamp) * @return the helicity bit */ - public HelicityBit findPrediction(long timestamp) { + public HelicityBit predictGenerated(long timestamp) { final int n=this.predictIndex(timestamp); if (n<0) return HelicityBit.UDF; - return this.getPrediction(n); + return this.getGenerated(n); /* if (timestamp < this.getTimestamp(0)) return null; if (timestamp <= this.getTimestamp(this.size()-1)) { - // it's in the measured range, so lookup index based on timestamp: - return this.getPrediction(this.findIndex(timestamp)); + // it's in the measured range, so search index based on timestamp: + return this.getGenerated(this.findIndex(timestamp)); } else { // here we predict past the measured sequence, @@ -271,7 +278,7 @@ public HelicityBit findPrediction(long timestamp) { // or an average final int n = (int) ( (timestamp-this.getTimestamp(0)) / TIMESTAMP_CLOCK * HELICITY_CLOCK ); - return this.getPrediction(n); + return this.getGenerated(n); } */ } @@ -290,15 +297,15 @@ public boolean initialized() { } public void show() { - HelicityState prev=this.states.get(0); - for (int ii=0; ii0) { this.states.remove(0); } - int nRejects=0; while (true) { boolean rejection=false; @@ -348,12 +354,12 @@ private int rejectFalseFlips() { protected final boolean analyze() { if (verbosity>0) { - System.out.println("HelicitySequence: analyze() ...."); + System.out.println("HelicitySequence: Analyzing ...."); } final int nRejects=this.rejectFalseFlips(); - if (verbosity>1){ - System.out.println("HelicitySequence: rejected false flips: "+nRejects); + if (verbosity>0) { + System.out.println("HelicitySequence: Rejected false flips: "+nRejects); } if (this.states.size()>0) { @@ -367,9 +373,14 @@ protected final boolean analyze() { this.analyzed=true; - boolean integrity=this.integrityCheck(); + final boolean integrity=this.integrityCheck(); + + final boolean geninit=this.generator.initialize(this.states); + + if (geninit) { + this.generators.put(this.generator.getTimestamp(), this.generator); + } - boolean geninit=this.generator.initialize(this.states); return integrity && geninit; } @@ -397,6 +408,7 @@ public final boolean integrityCheck() { // check if neighboring syncs are the same (they shouldn't be): if (this.states.get(ii).getPairSync().value() == this.states.get(ii-1).getPairSync().value()) { syncErrors++; + this.states.get(ii).addSwStatusMask(HelicityState.Mask.SYNC); if (verbosity>1) System.err.println("ERROR: HelicitySequence SYNC: "+ii); } @@ -407,6 +419,7 @@ public final boolean integrityCheck() { this.states.get(ii-2).getPatternSync().value()+ this.states.get(ii-3).getPatternSync().value() != 2) { quartetErrors++; + this.states.get(ii).addSwStatusMask(HelicityState.Mask.PATTERN); if (verbosity>1) System.err.println("ERROR: HelicitySequence QUARTET: "+ii); } } @@ -415,13 +428,13 @@ public final boolean integrityCheck() { final double seconds = (this.getTimestamp(ii)-this.getTimestamp(ii-1))/TIMESTAMP_CLOCK; if (seconds < (1.0-0.5)/HELICITY_CLOCK) { smallGapErrors++; - this.states.get(ii).addStatusMask(HelicityState.Mask.SMALLGAP); + this.states.get(ii).addSwStatusMask(HelicityState.Mask.SMALLGAP); if (verbosity>1) System.err.println("ERROR: HelicitySequence TIMESTAMP: "+ii+" "+ this.getTimestamp(ii)+" "+this.getTimestamp(ii-1)+" "+seconds+"s"); } else if (seconds > (1.0+0.5)/HELICITY_CLOCK) { bigGapErrors++; - this.states.get(ii).addStatusMask(HelicityState.Mask.BIGGAP); + this.states.get(ii).addSwStatusMask(HelicityState.Mask.BIGGAP); if (verbosity>1) System.err.println("ERROR: HelicitySequence TIMESTAMP: "+ii+" "+ this.getTimestamp(ii)+" "+this.getTimestamp(ii-1)+" "+seconds+"s"); } @@ -431,7 +444,7 @@ else if (seconds > (1.0+0.5)/HELICITY_CLOCK) { int generatorErrors=0; if (this.generator.initialized()) { for (int ii=0; ii (1.0+0.5)/HELICITY_CLOCK) { return (hwpErrors+syncErrors+quartetErrors+bigGapErrors+smallGapErrors+generatorErrors) == 0; } + public void initialize(HipoReader reader) { + SchemaFactory schema = reader.getSchemaFactory(); + while (reader.hasNext()) { + Event event=new Event(); + Bank flipBank=new Bank(schema.getSchema("HEL::flip")); + reader.nextEvent(event); + event.read(flipBank); + if (flipBank.getRows()<1) continue; + this.addState(HelicityState.createFromFlipBank(flipBank)); + } + } + + public void initialize(List filenames) { + for (String filename : filenames) { + HipoReader reader = new HipoReader(); + reader.setTags(1); + reader.open(filename); + initialize(reader); + } + } } diff --git a/common-tools/clas-detector/src/main/java/org/jlab/detector/helicity/HelicitySequenceDelayed.java b/common-tools/clas-detector/src/main/java/org/jlab/detector/helicity/HelicitySequenceDelayed.java index c5868022d9..808f736645 100644 --- a/common-tools/clas-detector/src/main/java/org/jlab/detector/helicity/HelicitySequenceDelayed.java +++ b/common-tools/clas-detector/src/main/java/org/jlab/detector/helicity/HelicitySequenceDelayed.java @@ -10,108 +10,110 @@ */ public class HelicitySequenceDelayed extends HelicitySequence { - private int delay; + private final int delay; public HelicitySequenceDelayed(int delay) { this.delay=delay; } /** - * Set the number of windows delayed. - * - * @param delay - */ - public void setDelay(int delay) { - this.delay=delay; - } - - /** - * Get the delay-corrected nth state in the measured sequence. + * Get the delay-corrected nth state in the measured sequence, by walking + * forward delay states and returning HelicityBit.UDF if any errors + * along the way. * * @param n the index of the state, where 0 corresponds to the first state - * @return the helicity state, null if outside the mesaured range + * @return the helicity state */ @Override protected HelicityBit get(int n) { + if (n<0) return HelicityBit.UDF; + for (int i=n+1; i<=n+delay && i seqMap=new HashMap<>(); + + public HelicitySequenceManager(int delay) { + this.delay=delay; + } + + public HelicitySequenceManager(int delay,List filenames) { + this.delay=delay; + initialize(filenames); + } + + public HelicitySequenceManager(int delay,HipoReader reader) { + this.delay=delay; + initialize(reader); + } + + + public void setVerbosity(int verbosity) { + this.verbosity=verbosity; + for (HelicitySequence hs : seqMap.values()) { + hs.setVerbosity(verbosity); + } + } + + private boolean addState(int runno,HelicityState state) { + if (runno <= 0) return false; + if (!seqMap.containsKey(runno)) { + seqMap.put(runno, new HelicitySequenceDelayed(delay)); + seqMap.get(runno).setVerbosity(verbosity); + } + return seqMap.get(runno).addState(state); + } + + public HelicitySequence getSequence(int runno) { + if (seqMap.containsKey(runno)) return seqMap.get(runno); + return null; + } + + public HelicityBit search(int runno, long timestamp) { + if (seqMap.containsKey(runno)) return seqMap.get(runno).search(timestamp); + return HelicityBit.UDF; + } + + public HelicityBit predictGenerated(int runno, long timestamp) { + if (seqMap.containsKey(runno)) return seqMap.get(runno).predictGenerated(timestamp); + return HelicityBit.UDF; + } + + public HelicityBit searchGenerated(int runno, long timestamp) { + if (seqMap.containsKey(runno)) return seqMap.get(runno).searchGenerated(timestamp); + return HelicityBit.UDF; + } + + /** + * Initialize from a HipoReader object. + * @param reader + */ + public void initialize(HipoReader reader) { + SchemaFactory schema = reader.getSchemaFactory(); + while (reader.hasNext()) { + Event event=new Event(); + Bank flipBank=new Bank(schema.getSchema("HEL::flip")); + reader.nextEvent(event); + event.read(flipBank); + if (flipBank.getRows()<1) continue; + final int runno=flipBank.getInt("run",0); + this.addState(runno,HelicityState.createFromFlipBank(flipBank)); + } + } + + /** + * Initialize from a list of file names: + * @param filenames + */ + public void initialize(List filenames) { + for (String filename : filenames) { + HipoReader reader = new HipoReader(); + reader.setTags(1); + reader.open(filename); + initialize(reader); + reader.close(); + } + } + + public boolean analyze() { + boolean ret=true; + for (HelicitySequenceDelayed hsd : seqMap.values()) { + if (!hsd.analyze()) ret=false; + } + return ret; + } + + public void show() { + for (Entry x : seqMap.entrySet()) { + System.out.println("Run Number:::::::::::::::::: "+x.getKey()); + x.getValue().show(); + } + } + +} \ No newline at end of file diff --git a/common-tools/clas-detector/src/main/java/org/jlab/detector/helicity/HelicityState.java b/common-tools/clas-detector/src/main/java/org/jlab/detector/helicity/HelicityState.java index f471e0e4f3..bb43be0711 100644 --- a/common-tools/clas-detector/src/main/java/org/jlab/detector/helicity/HelicityState.java +++ b/common-tools/clas-detector/src/main/java/org/jlab/detector/helicity/HelicityState.java @@ -1,5 +1,6 @@ package org.jlab.detector.helicity; +import java.util.Comparator; import org.jlab.jnp.hipo4.data.SchemaFactory; import org.jlab.jnp.hipo4.data.Bank; @@ -12,7 +13,7 @@ * * @author baltzell */ -public class HelicityState implements Comparable { +public class HelicityState implements Comparable, Comparator { public static class Mask { public static final int HELICITY =0x1; @@ -21,7 +22,7 @@ public static class Mask { public static final int BIGGAP =0x8; public static final int SMALLGAP =0x10; } - + // FIXME: these should go in CCDB private static final short HALFADC=2000; private static final byte SECTOR=1; @@ -37,16 +38,45 @@ public static class Mask { private long timestamp = 0; private int event = 0; private int run = 0; - private byte status = -1; + private byte hwStatus = 0; + private byte swStatus = 0; public HelicityState(){} - public void addStatusMask(int mask) { - this.status |= mask; + /** + * Compare based on timestamp for sorting and List insertion. + * @param o1 + * @param o2 + * @return negative/positive if o1 is before/after o2, else zero. + */ + @Override + public int compare(HelicityState o1, HelicityState o2) { + return o1.compareTo(o2); + } + + /** + * Compare based on timestamp for sorting and List insertion. + * @param other + * @return negative/positive if this is before/after other, else zero. + */ + @Override + public int compareTo(HelicityState other) { + if (this.getTimestamp() < other.getTimestamp()) return -1; + if (this.getTimestamp() > other.getTimestamp()) return +1; + return 0; + } + + + public void addSwStatusMask(int mask) { + this.swStatus |= mask; } - public int getStatus() { - return this.status; + public int getSwStatus() { + return this.swStatus; + } + + public int getHwStatus() { + return this.hwStatus; } private HelicityBit getFadcState(short ped) { @@ -55,13 +85,6 @@ private HelicityBit getFadcState(short ped) { else return HelicityBit.MINUS; } - @Override - public int compareTo(HelicityState other) { - if (this.getTimestamp() < other.getTimestamp()) return -1; - if (this.getTimestamp() > other.getTimestamp()) return +1; - return 0; - } - /** * Create a state from a HEL::adc org.jlab.jnp.hipo4.data.Bank * @@ -87,10 +110,10 @@ public static HelicityState createFromFadcBank(Bank adcBank) { break; } } - state.status=0; - if (state.helicityRaw==HelicityBit.UDF) state.status |= Mask.HELICITY; - if (state.pairSync==HelicityBit.UDF) state.status |= Mask.SYNC; - if (state.patternSync==HelicityBit.UDF) state.status |= Mask.PATTERN; + state.hwStatus=0; + if (state.helicityRaw==HelicityBit.UDF) state.hwStatus |= Mask.HELICITY; + if (state.pairSync==HelicityBit.UDF) state.hwStatus |= Mask.SYNC; + if (state.patternSync==HelicityBit.UDF) state.hwStatus |= Mask.PATTERN; state.fixMissingReadouts(); return state; } @@ -106,7 +129,7 @@ public static HelicityState createFromFlipBank(Bank flipBank) { state.run = flipBank.getInt("run",0); state.event = flipBank.getInt("event",0); state.timestamp = flipBank.getLong("timestamp",0); - state.status = flipBank.getByte("status",0); + state.hwStatus = flipBank.getByte("status",0); state.helicity = HelicityBit.create(flipBank.getByte("helicity",0)); state.helicityRaw = HelicityBit.create(flipBank.getByte("helicityRaw",0)); state.pairSync = HelicityBit.create(flipBank.getByte("pair",0)); @@ -127,7 +150,7 @@ public static HelicityState createFromFlipBank(DataBank flipBank) { state.run = flipBank.getInt("run",0); state.event = flipBank.getInt("event",0); state.timestamp = flipBank.getLong("timestamp",0); - state.status = flipBank.getByte("status",0); + state.hwStatus = flipBank.getByte("status",0); state.helicity = HelicityBit.create(flipBank.getByte("helicity",0)); state.helicityRaw = HelicityBit.create(flipBank.getByte("helicityRaw",0)); state.pairSync = HelicityBit.create(flipBank.getByte("pair",0)); @@ -171,7 +194,7 @@ public String toString() { } public String getInfo(HelicityState other,int counter) { - return String.format("%s %6.2f %5d %7d", + return String.format("%s %8.2f %5d %7d", this.toString(), 1000*this.getSecondsDelta(other), this.getEventDelta(other), @@ -183,7 +206,7 @@ public Bank getFlipBank(SchemaFactory schemaFactory) { bank.putInt("run", 0, this.run); bank.putInt("event", 0, this.event); bank.putLong("timestamp", 0, this.timestamp); - bank.putByte("status", 0, this.status); + bank.putByte("status", 0, this.hwStatus); bank.putByte("helicity", 0, this.helicity.value()); bank.putByte("helicityRaw", 0, this.helicityRaw.value()); bank.putByte("pair", 0, this.pairSync.value()); From 9d614e3e4022be1a7c26ff5d2cdef9182c9df9e8 Mon Sep 17 00:00:00 2001 From: ziegler Date: Thu, 19 Sep 2019 14:56:16 -0400 Subject: [PATCH 042/235] New tracking using docas. Difference in docas used in residual calculation. Bug fix in MS matrix. --- .../java/org/jlab/rec/dc/hit/FittedHit.java | 8 +- .../rec/dc/track/TrackCandListFinder.java | 16 ++-- .../jlab/rec/dc/track/fit/KFitterDoca.java | 92 +++++++++++++------ .../jlab/rec/dc/track/fit/MeasVecsDoca.java | 5 +- .../org/jlab/rec/dc/track/fit/RungeKutta.java | 3 +- .../jlab/rec/dc/track/fit/RungeKuttaDoca.java | 12 +-- .../jlab/rec/dc/track/fit/StateVecsDoca.java | 9 +- .../org/jlab/rec/dc/trajectory/StateVec.java | 17 +++- .../java/org/jlab/service/dc/DCEngine.java | 2 +- 9 files changed, 105 insertions(+), 59 deletions(-) diff --git a/reconstruction/dc/src/main/java/org/jlab/rec/dc/hit/FittedHit.java b/reconstruction/dc/src/main/java/org/jlab/rec/dc/hit/FittedHit.java index 23c0ba1dcb..51d04e12e3 100644 --- a/reconstruction/dc/src/main/java/org/jlab/rec/dc/hit/FittedHit.java +++ b/reconstruction/dc/src/main/java/org/jlab/rec/dc/hit/FittedHit.java @@ -634,9 +634,11 @@ public void calc_GeomCorr(DCGeant4Factory DcDetector, double y) { double delta_x = MaxSag*(1.-Math.abs(y)/(0.5*wireLen))*(1.-Math.abs(y)/(0.5*wireLen)); - x+=delta_x; - Line3D wireLine = new Line3D(new Point3D(xL, yL, z), new Point3D(xR, yR, z)); - wireLine.setOrigin(x, y, z); + //x+=delta_x; + //Line3D wireLine = new Line3D(new Point3D(xL, yL, z), new Point3D(xR, yR, z)); + //wireLine.setOrigin(x, y, z); + Line3D wireLine = new Line3D(new Point3D(x, 0, z), new Point3D(xR, yR, z)); + this.set_WireLength(wireLen); this.set_WireMaxSag(MaxSag); this.set_WireLine(wireLine); diff --git a/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/TrackCandListFinder.java b/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/TrackCandListFinder.java index f381e05890..7f48a02a78 100755 --- a/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/TrackCandListFinder.java +++ b/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/TrackCandListFinder.java @@ -662,17 +662,15 @@ public void matchHits(List stateVecAtPlanesList, Track trk, for (Cross c : trk) { for (FittedHit h1 : c.get_Segment1()) { - if (Math.abs(st.getZ() - h1.get_Z()) < 0.1 && c.get_Segment1().get_Id()>-1) { + if (Math.abs(st.getZ() - h1.get_Z()) < 0.1 && c.get_Segment1().get_Id()>-1 && + (h1.get_XWire() - st.getProjector())<0.1) { - if((h1.get_X() - st.getProjector())>h1.get_CellSize()*2) - continue; - h1.set_Id(h1.get_Id()); h1.set_TDC(h1.get_TDC()); h1.set_AssociatedHBTrackID(trk.get_Id()); h1.set_AssociatedClusterID(h1.get_AssociatedClusterID()); h1.setAssociatedStateVec(st); - h1.set_TrkResid(h1.get_X() - st.getProjector()); + h1.set_TrkResid(h1.get_Doca() - st.getProjectorDoca()); h1.setB(st.getB()); h1.calc_SignalPropagAlongWire(st.x(), st.y(), DcDetector); h1.setSignalPropagTimeAlongWire(DcDetector); @@ -696,17 +694,15 @@ public void matchHits(List stateVecAtPlanesList, Track trk, } } for (FittedHit h1 : c.get_Segment2()) { - if (Math.abs(st.getZ() - h1.get_Z()) < 0.1 && c.get_Segment2().get_Id()>-1) { + if (Math.abs(st.getZ() - h1.get_Z()) < 0.1 && c.get_Segment2().get_Id()>-1 && + (h1.get_XWire() - st.getProjector())<0.1) { - if((h1.get_X() - st.getProjector())>h1.get_CellSize()*2) - continue; - h1.set_Id(h1.get_Id()); h1.set_TDC(h1.get_TDC()); h1.set_AssociatedHBTrackID(trk.get_Id()); h1.set_AssociatedClusterID(h1.get_AssociatedClusterID()); h1.setAssociatedStateVec(st); - h1.set_TrkResid(h1.get_X() - st.getProjector()); + h1.set_TrkResid(h1.get_Doca() - st.getProjectorDoca()); h1.setB(st.getB()); h1.calc_SignalPropagAlongWire(st.x(), st.y(), DcDetector); h1.setSignalPropagTimeAlongWire(DcDetector); diff --git a/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/fit/KFitterDoca.java b/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/fit/KFitterDoca.java index a920462c26..49d5672265 100644 --- a/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/fit/KFitterDoca.java +++ b/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/fit/KFitterDoca.java @@ -187,7 +187,7 @@ private void filter(int k) { double[] K = new double[5]; - double V = mv.measurements.get(k).unc[0]*4; + double V = mv.measurements.get(k).unc[0]; double[] H = mv.H(new double[]{sv.trackTraj.get(k).x, sv.trackTraj.get(k).y}, mv.measurements.get(k).z, mv.measurements.get(k).wireLine[0]); @@ -208,21 +208,31 @@ private void filter(int k) { mv.measurements.get(k).z, mv.measurements.get(k).wireLine[0]); - double sign = Math.signum(mv.measurements.get(k).doca[0]); + double signMeas = 1; + double sign = 1; + if(mv.measurements.get(k).doca[1]!=-99 || + !(Math.abs(mv.measurements.get(k).doca[0])<0.1 && mv.measurements.get(k).doca[1]==-99 ) ) { //use LR only for double hits && large enough docas + signMeas = Math.signum(mv.measurements.get(k).doca[0]); + sign = Math.signum(h); + } else { + signMeas = Math.signum(h); + sign = Math.signum(h); + } //if(this.interNum>1) - // sign = Math.signum(h); - double c2 = ((sign*Math.abs(mv.measurements.get(k).doca[0]) - h) * (sign*Math.abs(mv.measurements.get(k).doca[0]) - h) / V); - //if(sign!=Math.signum(h) && this.interNum>1) System.out.println(sv.trackTraj.get(k).printInfo()+" h "+(float)h); - double x_filt = sv.trackTraj.get(k).x + K[0] * (sign*Math.abs(mv.measurements.get(k).doca[0]) - h); - double y_filt = sv.trackTraj.get(k).y + K[1] * (sign*Math.abs(mv.measurements.get(k).doca[0]) - h); - double tx_filt = sv.trackTraj.get(k).tx + K[2] * (sign*Math.abs(mv.measurements.get(k).doca[0]) - h); - double ty_filt = sv.trackTraj.get(k).ty + K[3] * (sign*Math.abs(mv.measurements.get(k).doca[0]) - h); - double Q_filt = sv.trackTraj.get(k).Q + K[4] * (sign*Math.abs(mv.measurements.get(k).doca[0]) - h); + // signMeas = Math.signum(h); + double c2 = ((signMeas*Math.abs(mv.measurements.get(k).doca[0]) - sign*Math.abs(h)) + * (signMeas*Math.abs(mv.measurements.get(k).doca[0]) - sign*Math.abs(h)) / V); + //if(signMeas!=Math.signum(h) && this.interNum>1) System.out.println(sv.trackTraj.get(k).printInfo()+" h "+(float)h); + double x_filt = sv.trackTraj.get(k).x + K[0] * (signMeas*Math.abs(mv.measurements.get(k).doca[0]) - sign*Math.abs(h)); + double y_filt = sv.trackTraj.get(k).y + K[1] * (signMeas*Math.abs(mv.measurements.get(k).doca[0]) - sign*Math.abs(h)); + double tx_filt = sv.trackTraj.get(k).tx + K[2] * (signMeas*Math.abs(mv.measurements.get(k).doca[0]) - sign*Math.abs(h)); + double ty_filt = sv.trackTraj.get(k).ty + K[3] * (signMeas*Math.abs(mv.measurements.get(k).doca[0]) - sign*Math.abs(h)); + double Q_filt = sv.trackTraj.get(k).Q + K[4] * (signMeas*Math.abs(mv.measurements.get(k).doca[0]) - sign*Math.abs(h)); //USE THE DOUBLE HIT if(mv.measurements.get(k).doca[1]!=-99) { //now filter using the other Hit - V = mv.measurements.get(k).unc[1]*4; + V = mv.measurements.get(k).unc[1]; H = mv.H(new double[]{x_filt, y_filt}, mv.measurements.get(k).z, mv.measurements.get(k).wireLine[1]); @@ -241,17 +251,19 @@ private void filter(int k) { mv.measurements.get(k).z, mv.measurements.get(k).wireLine[1]); - sign = Math.signum(mv.measurements.get(k).doca[1]); + signMeas = Math.signum(mv.measurements.get(k).doca[1]); + sign = Math.signum(h); //if(this.interNum>1) - // sign = Math.signum(h); + // signMeas = Math.signum(h); - x_filt += K[0] * (sign*Math.abs(mv.measurements.get(k).doca[1]) - h); - y_filt += K[1] * (sign*Math.abs(mv.measurements.get(k).doca[1]) - h); - tx_filt += K[2] * (sign*Math.abs(mv.measurements.get(k).doca[1]) - h); - ty_filt += K[3] * (sign*Math.abs(mv.measurements.get(k).doca[1]) - h); - Q_filt += K[4] * (sign*Math.abs(mv.measurements.get(k).doca[1]) - h); + x_filt += K[0] * (signMeas*Math.abs(mv.measurements.get(k).doca[1]) - sign*Math.abs(h)); + y_filt += K[1] * (signMeas*Math.abs(mv.measurements.get(k).doca[1]) - sign*Math.abs(h)); + tx_filt += K[2] * (signMeas*Math.abs(mv.measurements.get(k).doca[1]) - sign*Math.abs(h)); + ty_filt += K[3] * (signMeas*Math.abs(mv.measurements.get(k).doca[1]) - sign*Math.abs(h)); + Q_filt += K[4] * (signMeas*Math.abs(mv.measurements.get(k).doca[1]) - sign*Math.abs(h)); - c2 += ((sign*Math.abs(mv.measurements.get(k).doca[1]) - h) * (sign*Math.abs(mv.measurements.get(k).doca[1]) - h) / V); + c2 += ((signMeas*Math.abs(mv.measurements.get(k).doca[1]) - sign*Math.abs(h)) + * (signMeas*Math.abs(mv.measurements.get(k).doca[1]) - sign*Math.abs(h)) / V); } chi2kf += c2; @@ -296,19 +308,33 @@ private void calcFinalChisq(int sector) { svc.setB(sv.trackTraj.get(0).B); path += sv.trackTraj.get(0).deltaPath; svc.setPathLength(path); + double V0 = mv.measurements.get(0).unc[0]; double h0 = mv.h(new double[]{sv.trackTraj.get(0).x, sv.trackTraj.get(0).y}, mv.measurements.get(0).z, mv.measurements.get(0).wireLine[0]); - svc.setProjector(mv.measurements.get(k).wireLine[0].origin().x()+h0/Math.cos(Math.toRadians(6.))); + svc.setProjector(mv.measurements.get(0).wireLine[0].origin().x()); + svc.setProjectorDoca(Math.abs(h0)); kfStateVecsAlongTrajectory.add(svc); double res = (mv.measurements.get(0).doca[0] - h0); - chi2 += (mv.measurements.get(0).doca[0] - h0) * (mv.measurements.get(0).doca[0] - h0) / mv.measurements.get(0).error; + chi2 += (mv.measurements.get(0).doca[0] - h0) * (mv.measurements.get(0).doca[0] - h0) / V0; nRj[mv.measurements.get(0).region-1]+=res*res/mv.measurements.get(0).error; - + //USE THE DOUBLE HIT + if(mv.measurements.get(0).doca[1]!=-99) { + V0 = mv.measurements.get(0).unc[1]; + h0 = mv.h(new double[]{sv.trackTraj.get(0).x, sv.trackTraj.get(0).y}, + mv.measurements.get(0).z, + mv.measurements.get(0).wireLine[1]); + res = (mv.measurements.get(0).doca[1] - h0); + chi2 += (mv.measurements.get(0).doca[1] - h0) * (mv.measurements.get(0).doca[1] - h0) / V0; + nRj[mv.measurements.get(0).region-1]+=res*res/mv.measurements.get(0).error; + svc.setProjector(mv.measurements.get(0).wireLine[1].origin().x()); + svc.setProjectorDoca(Math.abs(h0)); + kfStateVecsAlongTrajectory.add(svc); + } for (int k1 = 0; k1 < k; k1++) { sv.transport(sector, k1, k1 + 1, sv.trackTraj.get(k1), sv.trackCov.get(k1)); - double V = mv.measurements.get(k1 + 1).error; + double V = mv.measurements.get(k1 + 1).unc[0]; double h = mv.h(new double[]{sv.trackTraj.get(k1 + 1).x, sv.trackTraj.get(k1 + 1).y}, mv.measurements.get(k1 + 1).z, mv.measurements.get(k1 + 1).wireLine[0]); @@ -320,13 +346,25 @@ private void calcFinalChisq(int sector) { svc.setB(sv.trackTraj.get(k1 + 1).B); path += sv.trackTraj.get(k1 + 1).deltaPath; svc.setPathLength(path); - svc.setProjector(mv.measurements.get(k1 + 1).wireLine[0].origin().x()+h/Math.cos(Math.toRadians(6.))); + svc.setProjector(mv.measurements.get(k1 + 1).wireLine[0].origin().x()); + svc.setProjectorDoca(Math.abs(h)); kfStateVecsAlongTrajectory.add(svc); - res = (mv.measurements.get(k1 + 1).doca[0] - h); + res = (mv.measurements.get(k1 + 1).doca[0] - h); chi2 += (mv.measurements.get(k1 + 1).doca[0] - h) * (mv.measurements.get(k1 + 1).doca[0] - h) / V; - nRj[mv.measurements.get(k1 + 1).region-1]+=res*res/V; - + //USE THE DOUBLE HIT + if(mv.measurements.get(k1 + 1).doca[1]!=-99) { + V = mv.measurements.get(k1 + 1).unc[1]; + h = mv.h(new double[]{sv.trackTraj.get(k1 + 1).x, sv.trackTraj.get(k1 + 1).y}, + mv.measurements.get(k1 + 1).z, + mv.measurements.get(k1 + 1).wireLine[1]); + res = (mv.measurements.get(k1 + 1).doca[1] - h); + chi2 += (mv.measurements.get(k1 + 1).doca[1] - h) * (mv.measurements.get(k1 + 1).doca[1] - h) / V; + nRj[mv.measurements.get(k1 + 1).region-1]+=res*res/V; + svc.setProjector(mv.measurements.get(k1 + 1).wireLine[1].origin().x()); + svc.setProjectorDoca(Math.abs(h)); + kfStateVecsAlongTrajectory.add(svc); + } } } diff --git a/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/fit/MeasVecsDoca.java b/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/fit/MeasVecsDoca.java index f558ceb68d..812316e3b9 100644 --- a/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/fit/MeasVecsDoca.java +++ b/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/fit/MeasVecsDoca.java @@ -160,7 +160,7 @@ void setMeasVecsFromHB(Track trk, DCGeant4Factory DcDetector) { hot._doca[0]*=LR; hot._hitError = trk.get_ListOfHBSegments().get(s).get(h).get_DocaErr()*trk.get_ListOfHBSegments().get(s).get(h).get_DocaErr(); //System.out.println(" Z "+Z+" ferr "+(float)(hot._Unc /(hot._hitError/4.))); - hot._Unc[0] = hot._hitError; + hot._Unc[0] = hot._hitError*4; hot.region = trk.get_ListOfHBSegments().get(s).get(h).get_Region(); hOTS.add(hot); @@ -188,7 +188,8 @@ void setMeasVecsFromHB(Track trk, DCGeant4Factory DcDetector) { meas.z = hOTS.get(i)._Z; meas.region = hOTS.get(i).region; meas.error = hOTS.get(i)._hitError; - meas.unc = hOTS.get(i)._Unc; //uncertainty used in KF fit + meas.unc[0] = hOTS.get(i)._Unc[0]; //uncertainty used in KF fit + meas.unc[1] = hOTS.get(i)._Unc[1]; //uncertainty used in KF fit meas.tilt = hOTS.get(i)._tilt; meas.doca = hOTS.get(i)._doca; meas.wireMaxSag = hOTS.get(i)._wireMaxSag; diff --git a/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/fit/RungeKutta.java b/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/fit/RungeKutta.java index 088b97bc07..2a79a4c08a 100644 --- a/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/fit/RungeKutta.java +++ b/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/fit/RungeKutta.java @@ -7,6 +7,7 @@ import Jama.Matrix; import java.util.ArrayList; +import org.jlab.clas.pdg.PhysicsConstants; import org.jlab.clas.swimtools.Swim; import org.jlab.rec.dc.Constants; @@ -307,7 +308,7 @@ void RK4transport(int sector, double q, double x0, double y0, double z0, double double cosEntranceAngle = Math.abs((x * px + y * py + z * pz) / (Math.sqrt(x * x + y * y + z * z) * p)); double pathLength = t_ov_X0 / cosEntranceAngle; - double sctRMS = (0.0136 / (beta * p)) * Math.sqrt(pathLength) * (1 + 0.038 * Math.log(pathLength)); // Highland-Lynch-Dahl formula + double sctRMS = (0.0136 / (beta*PhysicsConstants.speedOfLight() * p)) * Math.sqrt(pathLength) * (1 + 0.038 * Math.log(pathLength)); // Highland-Lynch-Dahl formula double cov_txtx = (1 + tx * tx) * (1 + tx * tx + ty * ty) * sctRMS * sctRMS; double cov_tyty = (1 + ty * ty) * (1 + tx * tx + ty * ty) * sctRMS * sctRMS; diff --git a/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/fit/RungeKuttaDoca.java b/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/fit/RungeKuttaDoca.java index 71048b2eb8..d1655c3eba 100644 --- a/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/fit/RungeKuttaDoca.java +++ b/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/fit/RungeKuttaDoca.java @@ -8,8 +8,6 @@ import Jama.Matrix; import java.util.ArrayList; import org.jlab.clas.swimtools.Swim; -import org.jlab.rec.dc.Constants; - /** * * @author ziegler @@ -221,9 +219,9 @@ void RK4transport(int sector, double q, double x0, double y0, double z0, double double delx_delq0_3 = deltx_delq0_0+0.5*h*deltx_delq0_2; double dely_delq0_3 = delty_delq0_0+0.5*h*delty_delq0_2; - double deltx_delq0_3 = this.deltx_delq0_next(q,v,tx0+0.5*h*tx2,ty0+0.5*ty2,_b[0],_b[1],_b[2], + double deltx_delq0_3 = this.deltx_delq0_next(q,v,tx0+0.5*h*tx2,ty0+0.5*h*ty2,_b[0],_b[1],_b[2], deltx_delq0_0+0.5*h*deltx_delq0_2,delty_delq0_0+0.5*h*delty_delq0_2); - double delty_delq0_3 = this.delty_delq0_next(q,v,tx0+0.5*h*tx2,ty0+0.5*ty2,_b[0],_b[1],_b[2], + double delty_delq0_3 = this.delty_delq0_next(q,v,tx0+0.5*h*tx2,ty0+0.5*h*ty2,_b[0],_b[1],_b[2], deltx_delq0_0+0.5*h*deltx_delq0_2,delty_delq0_0+0.5*h*delty_delq0_2); swimmer.Bfield(sector, x0+h*x3, y0+h*y3, z0+h, _b); @@ -297,10 +295,10 @@ void RK4transport(int sector, double q, double x0, double y0, double z0, double // // Q process noise matrix estimate // double p = Math.abs(1. / q); // -// double X0 = this.getX0(z0+h/2); +// double X0 = fVec.getX0(z0+h/2); // double t_ov_X0 = Math.sqrt((x0-x)*(x0-x)+(y0-y)*(y0-y)+h*h) / X0;//path length in radiation length units = t/X0 [true path length/ X0] ; Ar radiation length = 14 cm // -// double beta = p / Math.sqrt(p * p + mass * mass); // use particle momentum +// double beta = p / Math.sqrt(p * p + mass * mass); //use particle momentum // beta = 1; // // double sctRMS = ((0.0136)/(beta*p))*Math.sqrt(t_ov_X0*Math.sqrt(1 + tx0 * tx0 + ty0 * ty0))* @@ -316,7 +314,7 @@ void RK4transport(int sector, double q, double x0, double y0, double z0, double // C[3][2] += cov_txty; // C[3][3] += cov_tyty; // } -// + fVec.x = x; fVec.y = y ; fVec.z = z0+h; diff --git a/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/fit/StateVecsDoca.java b/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/fit/StateVecsDoca.java index 7813771029..7ec32958da 100644 --- a/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/fit/StateVecsDoca.java +++ b/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/fit/StateVecsDoca.java @@ -4,6 +4,7 @@ import java.util.HashMap; import java.util.Map; import org.jlab.clas.clas.math.FastMath; +import org.jlab.clas.pdg.PhysicsConstants; import org.jlab.clas.swimtools.Swim; import org.jlab.rec.dc.Constants; import org.jlab.rec.dc.track.Track; @@ -90,14 +91,14 @@ public void transport(int sector, int i, int f, StateVec iVec, CovMat covMat) { // Q process noise matrix estimate double p = Math.abs(1. / iVec.Q); - double X0 = this.getX0(iVec.z); + double X0 = this.getX0(z); double t_ov_X0 = stepSize / X0;//path length in radiation length units = t/X0 [true path length/ X0] ; Ar radiation length = 14 cm double beta = p / Math.sqrt(p * p + mass * mass); // use particle momentum if(beta>0) beta =1; - double sctRMS = ((0.0136)/(beta*p))*Math.sqrt(t_ov_X0)* + double sctRMS = ((0.0136)/(beta*PhysicsConstants.speedOfLight()*p))*Math.sqrt(t_ov_X0)* (1 + 0.038 * Math.log(t_ov_X0)); double cov_txtx = (1 + tx * tx) * (1 + tx * tx + ty * ty) * sctRMS * sctRMS; @@ -125,14 +126,14 @@ public void transport(int sector, int i, int f, StateVec iVec, CovMat covMat) { this.trackTraj.put(f, fVec); this.trackCov.put(f, fCov); } - private double getX0(double z) { + public double getX0(double z) { double X0 = Constants.AIRRADLEN; double tolerance = 0.01; for(int i = 1; i =Constants.Z[i]-tolerance && z<=Constants.Z[i+1]+tolerance) { - return Constants.AIRRADLEN; + return Constants.ARGONRADLEN; } } diff --git a/reconstruction/dc/src/main/java/org/jlab/rec/dc/trajectory/StateVec.java b/reconstruction/dc/src/main/java/org/jlab/rec/dc/trajectory/StateVec.java index fa833cb24a..1bc2f7fa1c 100644 --- a/reconstruction/dc/src/main/java/org/jlab/rec/dc/trajectory/StateVec.java +++ b/reconstruction/dc/src/main/java/org/jlab/rec/dc/trajectory/StateVec.java @@ -83,17 +83,26 @@ public double getB() { public void setB(double b) { this.b = b; } - // KF projector - private double h; + // KF projector --> get Wire midPoint match + private double hw; public double getProjector() { - return h; + return hw; } public void setProjector(double h) { + this.hw = h; + } + // KF projector --> get fit doca + private double h; + + public double getProjectorDoca() { + return h; + } + + public void setProjectorDoca(double h) { this.h = h; } - /** * Sets the stateVec * diff --git a/reconstruction/dc/src/main/java/org/jlab/service/dc/DCEngine.java b/reconstruction/dc/src/main/java/org/jlab/service/dc/DCEngine.java index 4d6eabc5a0..150c7dc702 100755 --- a/reconstruction/dc/src/main/java/org/jlab/service/dc/DCEngine.java +++ b/reconstruction/dc/src/main/java/org/jlab/service/dc/DCEngine.java @@ -62,7 +62,7 @@ public void setOptions() { } } else { - wireDistortionsFlag = System.getenv("COAT_DC_WIREDISTORTION"); + wireDistortionsFlag = System.getenv("COAT_DC_WIREDISTORTION"); if (wireDistortionsFlag!=null) { System.out.println("["+this.getName()+"] run with wire distortions in tracking config chosen based on env = "+wireDistortionsFlag); if(Boolean.valueOf(wireDistortionsFlag)==true) { From 1b7483b1bac30822388b921ec1503341adb00e8a Mon Sep 17 00:00:00 2001 From: baltzell Date: Fri, 20 Sep 2019 17:55:35 -0400 Subject: [PATCH 043/235] bump version --- common-tools/clas-analysis/pom.xml | 14 +++++++------- common-tools/clas-detector/pom.xml | 10 +++++----- common-tools/clas-eventmerger/pom.xml | 10 +++++----- common-tools/clas-geometry/pom.xml | 4 ++-- common-tools/clas-io/pom.xml | 6 +++--- common-tools/clas-jcsg/pom.xml | 8 ++++---- common-tools/clas-math/pom.xml | 4 ++-- common-tools/clas-physics/pom.xml | 4 ++-- common-tools/clas-reco/pom.xml | 14 +++++++------- common-tools/clas-utils/pom.xml | 4 ++-- common-tools/cnuphys/ced/pom.xml | 8 ++++---- common-tools/cnuphys/magfield/pom.xml | 2 +- common-tools/cnuphys/swimmer/pom.xml | 2 +- common-tools/coat-lib/deployDistribution.sh | 2 +- common-tools/coat-lib/pom.xml | 20 ++++++++++---------- common-tools/parent/pom.xml | 2 +- common-tools/pom.xml | 4 ++-- common-tools/swim-tools/pom.xml | 6 +++--- parent/pom.xml | 2 +- pom.xml | 4 ++-- reconstruction/band/pom.xml | 2 +- reconstruction/cnd/pom.xml | 2 +- reconstruction/cvt/pom.xml | 10 +++++----- reconstruction/dc/pom.xml | 12 ++++++------ reconstruction/eb/pom.xml | 10 +++++----- reconstruction/ec/pom.xml | 14 +++++++------- reconstruction/ft/pom.xml | 8 ++++---- reconstruction/fvt/pom.xml | 6 +++--- reconstruction/htcc/pom.xml | 8 ++++---- reconstruction/ltcc/pom.xml | 6 +++--- reconstruction/pom.xml | 4 ++-- reconstruction/rich/pom.xml | 8 ++++---- reconstruction/tof/pom.xml | 4 ++-- version-bump.sh | 18 ++++++++++++++++++ 34 files changed, 130 insertions(+), 112 deletions(-) create mode 100755 version-bump.sh diff --git a/common-tools/clas-analysis/pom.xml b/common-tools/clas-analysis/pom.xml index 6724843558..7406a2b2fa 100644 --- a/common-tools/clas-analysis/pom.xml +++ b/common-tools/clas-analysis/pom.xml @@ -3,14 +3,14 @@ 4.0.0 org.jlab.clas clas-analysis - 6.3.1-SNAPSHOT + 6b.3.2-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 6.3.1-SNAPSHOT + 6b.3.2-SNAPSHOT @@ -30,31 +30,31 @@ org.jlab.clas clas-utils - 6.3.1-SNAPSHOT + 6b.3.2-SNAPSHOT org.jlab.clas clas-physics - 6.3.1-SNAPSHOT + 6b.3.2-SNAPSHOT org.jlab.clas clas-io - 6.3.1-SNAPSHOT + 6b.3.2-SNAPSHOT org.jlab.clas clas-geometry - 6.3.1-SNAPSHOT + 6b.3.2-SNAPSHOT org.jlab.clas clas-detector - 6.3.1-SNAPSHOT + 6b.3.2-SNAPSHOT diff --git a/common-tools/clas-detector/pom.xml b/common-tools/clas-detector/pom.xml index 6cbfa77191..d9a083f8c6 100644 --- a/common-tools/clas-detector/pom.xml +++ b/common-tools/clas-detector/pom.xml @@ -3,14 +3,14 @@ 4.0.0 org.jlab.clas clas-detector - 6.3.1-SNAPSHOT + 6b.3.2-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 6.3.1-SNAPSHOT + 6b.3.2-SNAPSHOT @@ -30,7 +30,7 @@ org.jlab.clas clas-utils - 6.3.1-SNAPSHOT + 6b.3.2-SNAPSHOT @@ -42,13 +42,13 @@ org.jlab.clas clas-io - 6.3.1-SNAPSHOT + 6b.3.2-SNAPSHOT org.jlab.clas clas-geometry - 6.3.1-SNAPSHOT + 6b.3.2-SNAPSHOT diff --git a/common-tools/clas-eventmerger/pom.xml b/common-tools/clas-eventmerger/pom.xml index 63f4695d53..28a4ed33f7 100644 --- a/common-tools/clas-eventmerger/pom.xml +++ b/common-tools/clas-eventmerger/pom.xml @@ -2,14 +2,14 @@ 4.0.0 clas-eventmerger - 6.3.1-SNAPSHOT + 6b.3.2-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 6.3.1-SNAPSHOT + 6b.3.2-SNAPSHOT @@ -29,19 +29,19 @@ org.jlab.clas clas-utils - 6.3.1-SNAPSHOT + 6b.3.2-SNAPSHOT org.jlab.clas clas-io - 6.3.1-SNAPSHOT + 6b.3.2-SNAPSHOT org.jlab.clas clas-geometry - 6.3.1-SNAPSHOT + 6b.3.2-SNAPSHOT diff --git a/common-tools/clas-geometry/pom.xml b/common-tools/clas-geometry/pom.xml index 8eb040eae3..57a8830f26 100644 --- a/common-tools/clas-geometry/pom.xml +++ b/common-tools/clas-geometry/pom.xml @@ -3,14 +3,14 @@ 4.0.0 org.jlab.clas clas-geometry - 6.3.1-SNAPSHOT + 6b.3.2-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 6.3.1-SNAPSHOT + 6b.3.2-SNAPSHOT diff --git a/common-tools/clas-io/pom.xml b/common-tools/clas-io/pom.xml index 2bf5fd4f61..75bd599bfd 100644 --- a/common-tools/clas-io/pom.xml +++ b/common-tools/clas-io/pom.xml @@ -3,14 +3,14 @@ 4.0.0 org.jlab.clas clas-io - 6.3.1-SNAPSHOT + 6b.3.2-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 6.3.1-SNAPSHOT + 6b.3.2-SNAPSHOT @@ -75,7 +75,7 @@ org.jlab.clas clas-utils - 6.3.1-SNAPSHOT + 6b.3.2-SNAPSHOT diff --git a/common-tools/clas-jcsg/pom.xml b/common-tools/clas-jcsg/pom.xml index 503ee5f006..e26c8a463b 100644 --- a/common-tools/clas-jcsg/pom.xml +++ b/common-tools/clas-jcsg/pom.xml @@ -3,14 +3,14 @@ 4.0.0 org.jlab.clas clas-jcsg - 6.3.1-SNAPSHOT + 6b.3.2-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 6.3.1-SNAPSHOT + 6b.3.2-SNAPSHOT @@ -40,12 +40,12 @@ org.jlab.clas clas-geometry - 6.3.1-SNAPSHOT + 6b.3.2-SNAPSHOT org.jlab.clas clas-detector - 6.3.1-SNAPSHOT + 6b.3.2-SNAPSHOT java3d diff --git a/common-tools/clas-math/pom.xml b/common-tools/clas-math/pom.xml index 54bc39e42f..297ac2cab1 100644 --- a/common-tools/clas-math/pom.xml +++ b/common-tools/clas-math/pom.xml @@ -3,14 +3,14 @@ 4.0.0 org.jlab.clas clas-math - 6.3.1-SNAPSHOT + 6b.3.2-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 6.3.1-SNAPSHOT + 6b.3.2-SNAPSHOT diff --git a/common-tools/clas-physics/pom.xml b/common-tools/clas-physics/pom.xml index dcfd100835..c22e0bbbea 100644 --- a/common-tools/clas-physics/pom.xml +++ b/common-tools/clas-physics/pom.xml @@ -4,7 +4,7 @@ org.jlab.clas clas-physics - 6.3.1-SNAPSHOT + 6b.3.2-SNAPSHOT jar @@ -23,7 +23,7 @@ org.jlab.clas clas12rec ../../parent/pom.xml - 6.3.1-SNAPSHOT + 6b.3.2-SNAPSHOT diff --git a/common-tools/clas-reco/pom.xml b/common-tools/clas-reco/pom.xml index fc70e1e375..d9b51c6f6e 100644 --- a/common-tools/clas-reco/pom.xml +++ b/common-tools/clas-reco/pom.xml @@ -3,14 +3,14 @@ 4.0.0 org.jlab.clas clas-reco - 6.3.1-SNAPSHOT + 6b.3.2-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 6.3.1-SNAPSHOT + 6b.3.2-SNAPSHOT @@ -67,7 +67,7 @@ org.jlab.clas clas-math - 6.3.1-SNAPSHOT + 6b.3.2-SNAPSHOT selected cluster : "); + //for(FittedHit h : BestCluster) + // System.out.println(h.printInfo()); + return BestCluster; + } + } diff --git a/reconstruction/dc/src/main/java/org/jlab/rec/dc/cluster/ClusterFinder.java b/reconstruction/dc/src/main/java/org/jlab/rec/dc/cluster/ClusterFinder.java index ba91964910..8002ea8a5d 100644 --- a/reconstruction/dc/src/main/java/org/jlab/rec/dc/cluster/ClusterFinder.java +++ b/reconstruction/dc/src/main/java/org/jlab/rec/dc/cluster/ClusterFinder.java @@ -206,7 +206,7 @@ public List FindHitBasedClusters(List allhits, ClusterCleane continue; selectedClusList.add(fClus); } - + //System.out.println(" Clusters Step 2"); // for(FittedCluster c : selectedClusList) // for(FittedHit h : c) @@ -219,33 +219,48 @@ public List FindHitBasedClusters(List allhits, ClusterCleane cf.SetFitArray(clus, "LC"); cf.Fit(clus, true); - - if (clus.get_fitProb() > Constants.HITBASEDTRKGMINFITHI2PROB || clus.size() < Constants.HITBASEDTRKGNONSPLITTABLECLSSIZE) { + if(clus.get_fitProb() Constants.HITBASEDTRKGMINFITHI2PROB ){ + // || + // (clus.size() < Constants.HITBASEDTRKGNONSPLITTABLECLSSIZE && clus.get_fitProb()!=0) ){ fittedClusList.add(clus); //if the chi2 prob is good enough, then just add the cluster, or if the cluster is not split-able because it has too few hits - } else { + } else { + List splitClus = ct.ClusterSplitter(clus, selectedClusList.size(), cf); fittedClusList.addAll(splitClus); } } - + + ArrayList rmHits = new ArrayList(); for (FittedCluster clus : fittedClusList) { - if (clus != null && clus.size() > 3 ) { - + if (clus != null && clus.size() > 3 && clus.get_fitProb()>Constants.HITBASEDTRKGMINFITHI2PROB) { + // update the hits for (FittedHit fhit : clus) { fhit.set_TrkgStatus(0); fhit.updateHitPosition(DcDetector); - fhit.set_AssociatedClusterID(clus.get_Id()); + //fhit.set_AssociatedClusterID(clus.get_Id()); } + cf.SetFitArray(clus, "TSC"); cf.Fit(clus, true); cf.SetResidualDerivedParams(clus, false, false, DcDetector); //calcTimeResidual=false, resetLRAmbig=false, local= false - + + clus = ct.ClusterCleaner(clus, cf, DcDetector); + // update the hits + for (FittedHit fhit : clus) { + fhit.set_AssociatedClusterID(clus.get_Id()); + } cf.SetFitArray(clus, "TSC"); cf.Fit(clus, false); cf.SetSegmentLineParameters(clus.get(0).get_Z(), clus); - - if (clus != null) { + + if (clus != null ) { refittedClusList.add(clus); } From a16d6660c564d6c176774a2754d2241c50eea16a Mon Sep 17 00:00:00 2001 From: gavalian Date: Wed, 25 Sep 2019 17:18:15 -0400 Subject: [PATCH 057/235] added BonusDecoder class for bonus detector. CodaEventDecoder now decodes bank 57641 for bonus --- .../jlab/detector/decode/BonusDecoder.java | 83 +++++++++++++++++ .../detector/decode/CodaEventDecoder.java | 92 +++++++++++++++++++ .../detector/decode/DetectorDataDgtz.java | 13 ++- 3 files changed, 186 insertions(+), 2 deletions(-) create mode 100644 common-tools/clas-detector/src/main/java/org/jlab/detector/decode/BonusDecoder.java diff --git a/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/BonusDecoder.java b/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/BonusDecoder.java new file mode 100644 index 0000000000..e8ed93cd47 --- /dev/null +++ b/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/BonusDecoder.java @@ -0,0 +1,83 @@ +/* + * 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.decode; + +import java.util.ArrayList; +import java.util.List; +import org.jlab.coda.jevio.EvioNode; +import org.jlab.io.evio.EvioDataEvent; +import org.jlab.io.evio.EvioTreeBranch; +import org.jlab.io.evio.EvioSource; +/** + * + * @author gavalian + */ +public class BonusDecoder { + private CodaEventDecoder codaDecoder = null; + private EvioSource reader = new EvioSource(); + + public BonusDecoder(){ + codaDecoder = new CodaEventDecoder(); + } + + public void open(String filename){ + reader.open(filename); + } + + public boolean hasEvent(){ + return reader.hasEvent(); + } + + public List nextEvent(int crate){ + + EvioDataEvent event = (EvioDataEvent) reader.getNextEvent(); + List branches = codaDecoder.getEventBranches(event); + //System.out.println("Next Event-----"); + for(int i = 0; i < branches.size(); i++){ + EvioTreeBranch branch = branches.get(i); + //System.out.println("node found : tag = " + branch.getTag() + " num = " + branch.getNum()); + if(branch.getTag()==crate){ + for(EvioNode node : branch.getNodes()){ + /*System.out.println("\t ["+branch.getTag()+"] : node : tag = " + + node.getTag() + " , num = " + node.getNum() + ", type = " + + node.getDataTypeObj());*/ + if(node.getTag()==57641){ + //System.out.println("analyzing data----"); + List data = codaDecoder.getDataEntries_57641(crate, node, event); + return data; + //System.out.println("data size = " + data.size()); + /*for(int d = 0; d < data.size(); d++){ + System.out.println(data.get(d).toString()); + //data.get(i). + }*/ + } + } + } + } + return new ArrayList(); + //EvioTreeBranch cbranch = codaDecoder.getEventBranch(branches, crate); + //if(cbranch == null ) return ; +/* + for (EvioNode node : cbranch.getNodes()) { + if(node.getTag()==57641){ + // This is bit-packed PULSE mode for BONUS + System.err.println("found tag = " + node.getTag() + " " + node.getNum()); + //getDataEntries_57640(crate, node, event); + } + }*/ + } + + public static void main(String[] args){ + String filename = "/Users/gavalian/Work/DataSpace/clas12/bonus/bonustest_000002.evio.00000"; + BonusDecoder decoder = new BonusDecoder(); + decoder.open(filename); + int counter = 0; + while(decoder.hasEvent()==true&&counter<100){ + counter++; + decoder.nextEvent(63); + } + } +} diff --git a/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/CodaEventDecoder.java b/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/CodaEventDecoder.java index 2622173406..0d988d6fdf 100644 --- a/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/CodaEventDecoder.java +++ b/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/CodaEventDecoder.java @@ -894,6 +894,98 @@ public List getDataEntries_57640(Integer crate, EvioNode node } return entries; } + + /** + * Decoding MicroMegas Packed Data + * @param crate + * @param node + * @param event + * @return + */ + public List getDataEntries_57641(Integer crate, EvioNode node, EvioDataEvent event){ + // Micromegas packed data + // ---------------------- + + ArrayList entries = new ArrayList(); + if(node.getTag()==57641){ + try { + ByteBuffer compBuffer = node.getByteData(true); + CompositeData compData = new CompositeData(compBuffer.array(),event.getByteOrder()); + + List cdatatypes = compData.getTypes(); + List cdataitems = compData.getItems(); + + //System.out.println("composite data size = " + cdatatypes.size()); + int jdata = 0; // item counter + for( int i = 0 ; i < cdatatypes.size(); ) { // loop over data types + Byte SLOT = (Byte)cdataitems.get( jdata++ ); i++; + + Integer EV_ID = (Integer)cdataitems.get( jdata++ ); i++; + + Long TIMESTAMP = (Long)cdataitems.get( jdata++ ); i++; + + Short nChannels = (Short)cdataitems.get( jdata++ ); i++; + + for( int ch=0; ch0){ + str.append("PULSE : "); + for(int i = 0; i < nsamples; i++){ + str.append(String.format("%5d ", adcPulse.get(0)[i])); + } + } else { + str.append(String.format("ADC (%d) (L=%6d) : %5d %5d %5d time = %5d %9.4f max = %5d", + getOrder(), nsamples, getIntegral(),getADC(), getPedestal(), getTimeCourse(), getTime(), getHeight())); + } return str.toString(); } From 32787ff759dc5148563de34bce4fe25c93959342 Mon Sep 17 00:00:00 2001 From: ziegler Date: Thu, 26 Sep 2019 14:59:50 -0400 Subject: [PATCH 058/235] Fix layer efficiency code. --- .../org/jlab/service/dc/LayerEfficiencyAnalyzer.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/reconstruction/dc/src/main/java/org/jlab/service/dc/LayerEfficiencyAnalyzer.java b/reconstruction/dc/src/main/java/org/jlab/service/dc/LayerEfficiencyAnalyzer.java index d0533cbc3c..5700ce07c8 100644 --- a/reconstruction/dc/src/main/java/org/jlab/service/dc/LayerEfficiencyAnalyzer.java +++ b/reconstruction/dc/src/main/java/org/jlab/service/dc/LayerEfficiencyAnalyzer.java @@ -123,6 +123,7 @@ public boolean init() { // create histograms for(int si =0; si<6; si++) { LayerEffs.add(new HashMap()); + LayerEffsTrkD.add(new HashMap()); for(int i =0; i<6; i++) { LayerEffs.get(si).put(new Coordinate(i), new H1F("Sector-"+si+" layer efficiencies" + (i + 1), "superlayer" + (i + 1), 6, 0.5, 6.5)); @@ -230,7 +231,7 @@ public boolean processDataEvent(DataEvent event) { // Load the constants //------------------- int newRun = bank.getInt("run", 0); - if (newRun == 0) + if (newRun == 0) return true; if (Run.get() == 0 || (Run.get() != 0 && Run.get() != newRun)) { @@ -458,11 +459,10 @@ public static void main(String[] args) { screensize = Toolkit.getDefaultToolkit().getScreenSize(); frame.setSize((int) (screensize.getHeight() * .75 * 1.618), (int) (screensize.getHeight() * .75)); - LayerEfficiencyAnalyzer tm = new LayerEfficiencyAnalyzer(); + MagFieldsEngine enf = new MagFieldsEngine(); enf.init(); - DCHBEngine en = new DCHBEngine(); - en.init(); + LayerEfficiencyAnalyzer tm = new LayerEfficiencyAnalyzer(); tm.init(); frame.add(tm.mainPanel); @@ -480,12 +480,10 @@ public static void main(String[] args) { while (reader.hasEvent()) { counter++; DataEvent event = reader.getNextEvent(); - //enf.processDataEvent(event); - //en.processDataEvent(event); tm.processDataEvent(event); tm.ProcessLayerEffs(event); //event.show(); - if(counter%10==0) { + if(counter%1000==0) { System.out.println(counter); tm.drawPlots(); } From c5e8a7661c40e70eda62b36ed08caafb7d94cb74 Mon Sep 17 00:00:00 2001 From: Raffaella De Vita Date: Fri, 27 Sep 2019 12:04:26 +0200 Subject: [PATCH 059/235] bumped version to 6c.3.3 --- common-tools/clas-analysis/pom.xml | 14 +++++++------- common-tools/clas-detector/pom.xml | 10 +++++----- common-tools/clas-eventmerger/pom.xml | 10 +++++----- common-tools/clas-geometry/pom.xml | 4 ++-- common-tools/clas-io/pom.xml | 6 +++--- common-tools/clas-jcsg/pom.xml | 8 ++++---- common-tools/clas-math/pom.xml | 4 ++-- common-tools/clas-physics/pom.xml | 4 ++-- common-tools/clas-reco/pom.xml | 14 +++++++------- common-tools/clas-utils/pom.xml | 4 ++-- common-tools/cnuphys/ced/pom.xml | 8 ++++---- common-tools/cnuphys/magfield/pom.xml | 2 +- common-tools/cnuphys/swimmer/pom.xml | 2 +- common-tools/coat-lib/pom.xml | 20 ++++++++++---------- common-tools/parent/pom.xml | 2 +- common-tools/pom.xml | 4 ++-- common-tools/swim-tools/pom.xml | 6 +++--- parent/pom.xml | 2 +- pom.xml | 4 ++-- reconstruction/band/pom.xml | 2 +- reconstruction/cnd/pom.xml | 2 +- reconstruction/cvt/pom.xml | 10 +++++----- reconstruction/dc/pom.xml | 12 ++++++------ reconstruction/eb/pom.xml | 10 +++++----- reconstruction/ec/pom.xml | 14 +++++++------- reconstruction/ft/pom.xml | 8 ++++---- reconstruction/fvt/pom.xml | 6 +++--- reconstruction/htcc/pom.xml | 8 ++++---- reconstruction/ltcc/pom.xml | 6 +++--- reconstruction/pom.xml | 4 ++-- reconstruction/rich/pom.xml | 8 ++++---- reconstruction/rtpc/pom.xml | 6 +++--- reconstruction/tof/pom.xml | 4 ++-- 33 files changed, 114 insertions(+), 114 deletions(-) diff --git a/common-tools/clas-analysis/pom.xml b/common-tools/clas-analysis/pom.xml index 7406a2b2fa..8b02c04d8c 100644 --- a/common-tools/clas-analysis/pom.xml +++ b/common-tools/clas-analysis/pom.xml @@ -3,14 +3,14 @@ 4.0.0 org.jlab.clas clas-analysis - 6b.3.2-SNAPSHOT + 6c.3.3-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 6b.3.2-SNAPSHOT + 6c.3.3-SNAPSHOT @@ -30,31 +30,31 @@ org.jlab.clas clas-utils - 6b.3.2-SNAPSHOT + 6c.3.3-SNAPSHOT org.jlab.clas clas-physics - 6b.3.2-SNAPSHOT + 6c.3.3-SNAPSHOT org.jlab.clas clas-io - 6b.3.2-SNAPSHOT + 6c.3.3-SNAPSHOT org.jlab.clas clas-geometry - 6b.3.2-SNAPSHOT + 6c.3.3-SNAPSHOT org.jlab.clas clas-detector - 6b.3.2-SNAPSHOT + 6c.3.3-SNAPSHOT diff --git a/common-tools/clas-detector/pom.xml b/common-tools/clas-detector/pom.xml index d9a083f8c6..4b958e47b3 100644 --- a/common-tools/clas-detector/pom.xml +++ b/common-tools/clas-detector/pom.xml @@ -3,14 +3,14 @@ 4.0.0 org.jlab.clas clas-detector - 6b.3.2-SNAPSHOT + 6c.3.3-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 6b.3.2-SNAPSHOT + 6c.3.3-SNAPSHOT @@ -30,7 +30,7 @@ org.jlab.clas clas-utils - 6b.3.2-SNAPSHOT + 6c.3.3-SNAPSHOT @@ -42,13 +42,13 @@ org.jlab.clas clas-io - 6b.3.2-SNAPSHOT + 6c.3.3-SNAPSHOT org.jlab.clas clas-geometry - 6b.3.2-SNAPSHOT + 6c.3.3-SNAPSHOT diff --git a/common-tools/clas-eventmerger/pom.xml b/common-tools/clas-eventmerger/pom.xml index 28a4ed33f7..9d32a359c0 100644 --- a/common-tools/clas-eventmerger/pom.xml +++ b/common-tools/clas-eventmerger/pom.xml @@ -2,14 +2,14 @@ 4.0.0 clas-eventmerger - 6b.3.2-SNAPSHOT + 6c.3.3-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 6b.3.2-SNAPSHOT + 6c.3.3-SNAPSHOT @@ -29,19 +29,19 @@ org.jlab.clas clas-utils - 6b.3.2-SNAPSHOT + 6c.3.3-SNAPSHOT org.jlab.clas clas-io - 6b.3.2-SNAPSHOT + 6c.3.3-SNAPSHOT org.jlab.clas clas-geometry - 6b.3.2-SNAPSHOT + 6c.3.3-SNAPSHOT diff --git a/common-tools/clas-geometry/pom.xml b/common-tools/clas-geometry/pom.xml index 57a8830f26..36a1393fcc 100644 --- a/common-tools/clas-geometry/pom.xml +++ b/common-tools/clas-geometry/pom.xml @@ -3,14 +3,14 @@ 4.0.0 org.jlab.clas clas-geometry - 6b.3.2-SNAPSHOT + 6c.3.3-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 6b.3.2-SNAPSHOT + 6c.3.3-SNAPSHOT diff --git a/common-tools/clas-io/pom.xml b/common-tools/clas-io/pom.xml index 75bd599bfd..ba9f6aa3ff 100644 --- a/common-tools/clas-io/pom.xml +++ b/common-tools/clas-io/pom.xml @@ -3,14 +3,14 @@ 4.0.0 org.jlab.clas clas-io - 6b.3.2-SNAPSHOT + 6c.3.3-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 6b.3.2-SNAPSHOT + 6c.3.3-SNAPSHOT @@ -75,7 +75,7 @@ org.jlab.clas clas-utils - 6b.3.2-SNAPSHOT + 6c.3.3-SNAPSHOT diff --git a/common-tools/clas-jcsg/pom.xml b/common-tools/clas-jcsg/pom.xml index e26c8a463b..a970332ef2 100644 --- a/common-tools/clas-jcsg/pom.xml +++ b/common-tools/clas-jcsg/pom.xml @@ -3,14 +3,14 @@ 4.0.0 org.jlab.clas clas-jcsg - 6b.3.2-SNAPSHOT + 6c.3.3-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 6b.3.2-SNAPSHOT + 6c.3.3-SNAPSHOT @@ -40,12 +40,12 @@ org.jlab.clas clas-geometry - 6b.3.2-SNAPSHOT + 6c.3.3-SNAPSHOT org.jlab.clas clas-detector - 6b.3.2-SNAPSHOT + 6c.3.3-SNAPSHOT java3d diff --git a/common-tools/clas-math/pom.xml b/common-tools/clas-math/pom.xml index 297ac2cab1..2303f35f83 100644 --- a/common-tools/clas-math/pom.xml +++ b/common-tools/clas-math/pom.xml @@ -3,14 +3,14 @@ 4.0.0 org.jlab.clas clas-math - 6b.3.2-SNAPSHOT + 6c.3.3-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 6b.3.2-SNAPSHOT + 6c.3.3-SNAPSHOT diff --git a/common-tools/clas-physics/pom.xml b/common-tools/clas-physics/pom.xml index c22e0bbbea..ea746df579 100644 --- a/common-tools/clas-physics/pom.xml +++ b/common-tools/clas-physics/pom.xml @@ -4,7 +4,7 @@ org.jlab.clas clas-physics - 6b.3.2-SNAPSHOT + 6c.3.3-SNAPSHOT jar @@ -23,7 +23,7 @@ org.jlab.clas clas12rec ../../parent/pom.xml - 6b.3.2-SNAPSHOT + 6c.3.3-SNAPSHOT diff --git a/common-tools/clas-reco/pom.xml b/common-tools/clas-reco/pom.xml index d9b51c6f6e..e88dfdb145 100644 --- a/common-tools/clas-reco/pom.xml +++ b/common-tools/clas-reco/pom.xml @@ -3,14 +3,14 @@ 4.0.0 org.jlab.clas clas-reco - 6b.3.2-SNAPSHOT + 6c.3.3-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 6b.3.2-SNAPSHOT + 6c.3.3-SNAPSHOT @@ -67,7 +67,7 @@ org.jlab.clas clas-math - 6b.3.2-SNAPSHOT + 6c.3.3-SNAPSHOT loading bankdefs from directory : " + dirname); + System.out.println("[EvioDataDictionary]---> loading bankdefs from directory : " + dirname); File dict_dir = new File(dirname); if (dict_dir.exists() == false) { @@ -96,7 +96,7 @@ public final void initWithDir(String dirname) { } ArrayList xmlFileList = FileUtils.filesInFolder(dict_dir, "xml", ignorePrefixes); - System.err.println("[EvioDataDictionary]------> number of XML files located : " + xmlFileList.size()); + System.out.println("[EvioDataDictionary]------> number of XML files located : " + xmlFileList.size()); Integer counter = 0; for (String file : xmlFileList) { ArrayList descList = DictionaryLoader.getDescriptorsFromFile(file); @@ -111,7 +111,7 @@ public final void initWithDir(String dirname) { counter++; } } - System.err.println("[EvioDataDictionary]--> total number of descriptors found : " + counter.toString()); + System.out.println("[EvioDataDictionary]--> total number of descriptors found : " + counter.toString()); } public void show() { @@ -167,7 +167,7 @@ public String getNameByTagNum(int tag, int num) { public DataBank createBank(String name, int rows) { if (descriptors.containsKey(name) == false) { - System.out.println("[EvioDataDictionary]:: ERROR ---> no descriptor with name = " + name + " is found"); + System.err.println("[EvioDataDictionary]:: ERROR ---> no descriptor with name = " + name + " is found"); } EvioDataDescriptor desc = descriptors.get(name); EvioDataBank bank = new EvioDataBank(desc); diff --git a/common-tools/clas-io/src/main/java/org/jlab/io/evio/EvioSource.java b/common-tools/clas-io/src/main/java/org/jlab/io/evio/EvioSource.java index 274454f61f..cf24b7b319 100644 --- a/common-tools/clas-io/src/main/java/org/jlab/io/evio/EvioSource.java +++ b/common-tools/clas-io/src/main/java/org/jlab/io/evio/EvioSource.java @@ -53,7 +53,7 @@ public EvioSource() { EvioFactory.loadDictionary(dictionaryPath); dictionary = EvioFactory.getDictionary(); - System.err.println("[EvioSource] ---> Factory loaded descriptor count : " + dictionary.getDescriptorList().length); + System.out.println("[EvioSource] ---> Factory loaded descriptor count : " + dictionary.getDescriptorList().length); // dictionary.show(); } @@ -85,7 +85,7 @@ public EvioSource(String filename) { EvioFactory.loadDictionary(dictionaryPath); dictionary = EvioFactory.getDictionary(); - System.err.println("[EvioSource] ---> Factory loaded descriptor count : " + dictionary.getDescriptorList().length); + System.out.println("[EvioSource] ---> Factory loaded descriptor count : " + dictionary.getDescriptorList().length); dictionary.show(); this.open(filename); } From 22d63e05f974c613fb19786245a0ee86e8cb259a Mon Sep 17 00:00:00 2001 From: ziegler Date: Mon, 14 Oct 2019 16:08:03 -0400 Subject: [PATCH 066/235] DC time corrections updated: tBeta correction implemented as a function of time instead of trkdoca. There is a setting in YAML to use the new tBeta correction. If not set it will default to using the trkdoca dependent tBeta correction. --- .../main/java/org/jlab/rec/dc/Constants.java | 14 +++++++++++++ .../java/org/jlab/rec/dc/hit/FittedHit.java | 20 ++++++++++++++----- .../java/org/jlab/service/dc/DCEngine.java | 16 +++++++++++++++ .../java/org/jlab/service/dc/DCHBEngine.java | 2 -- 4 files changed, 45 insertions(+), 7 deletions(-) diff --git a/reconstruction/dc/src/main/java/org/jlab/rec/dc/Constants.java b/reconstruction/dc/src/main/java/org/jlab/rec/dc/Constants.java index e7a034da6e..02785a157d 100644 --- a/reconstruction/dc/src/main/java/org/jlab/rec/dc/Constants.java +++ b/reconstruction/dc/src/main/java/org/jlab/rec/dc/Constants.java @@ -165,6 +165,8 @@ public class Constants { public static int[][] STBLOC; private static boolean USETSTART = true; + private static boolean USETIMETBETA = false; + public static double SEEDCUT = 5000; public static double MINPATH = 200; public static double BETAHIGH = 1.5; @@ -173,6 +175,8 @@ public class Constants { public static double MAXHITS = 2000; ; public static double TRANSVTXCUT = 20; + + public static double AVEDRIFTVEL = 0.0027; //velocity in cm / ns. [CLAS-Note 96-008] public static boolean isUSETSTART() { return USETSTART; @@ -182,6 +186,15 @@ public static void setUSETSTART(boolean USETSTART) { Constants.USETSTART = USETSTART; } + public static boolean useUSETIMETBETA() { + return USETIMETBETA; + } + + public static void setUSETIMETBETA(boolean USETIMETBETA) { + Constants.USETIMETBETA = USETIMETBETA; + } + + private static double WIREDIST = 0.0; /** @@ -301,5 +314,6 @@ public static double getT2D() { return Constants.T2D; } + } diff --git a/reconstruction/dc/src/main/java/org/jlab/rec/dc/hit/FittedHit.java b/reconstruction/dc/src/main/java/org/jlab/rec/dc/hit/FittedHit.java index 51d04e12e3..d6633b8e53 100644 --- a/reconstruction/dc/src/main/java/org/jlab/rec/dc/hit/FittedHit.java +++ b/reconstruction/dc/src/main/java/org/jlab/rec/dc/hit/FittedHit.java @@ -370,7 +370,11 @@ public void set_TimeToDistance(DataEvent event, double trkAngle, double B, Index double deltatime_beta = 0; if (x != -1) { - deltatime_beta = calcDeltaTimeBeta(x, tab, beta); + if(Constants.useUSETIMETBETA()==true) { + deltatime_beta = calcDeltaTimeBetaTFCN(this.get_Time(), tab, beta); + } else { + deltatime_beta = calcDeltaTimeBeta(x, tab, beta); + } } if(event.hasBank("MC::Particle")==false) { distance = tde.interpolateOnGrid(B, Math.toDegrees(ralpha), this.getCorrectedTime(this.get_Time(), deltatime_beta), secIdx, slIdx) ; @@ -393,6 +397,7 @@ public double getCorrectedTime(double t, double dbt) { correctedTime=0.01; // fixes edge effects ... to be improved return correctedTime; } + public double calcDeltaTimeBeta(double x, IndexedTable tab, double beta){ return (Math.sqrt(x * x + (tab.getDoubleValue("distbeta", this.get_Sector(), this.get_Superlayer(),0) * beta * beta) * @@ -400,10 +405,15 @@ public double calcDeltaTimeBeta(double x, IndexedTable tab, double beta){ this.get_Superlayer(),0) * beta * beta)) - x) / Constants.V0AVERAGED; } - //public double calcDeltaTimeBeta(double x, int superlayer, double beta) { - // double distbeta = TableLoader.distbetaValues[superlayer-1]; - // return (Math.sqrt(x * x + (distbeta * beta * beta) * (distbeta* beta * beta)) - x) / Constants.V0AVERAGED; - //} + public double calcDeltaTimeBetaTFCN(double t,IndexedTable tab, double beta){ + double db = tab.getDoubleValue("distbeta", this.get_Sector(), + this.get_Superlayer(),0); + double delt = db/Constants.AVEDRIFTVEL; + //see [CLAS-Note 96-008] + double tBeta = (0.5 *delt*delt*delt*t)/(delt*delt*delt*t*t*t); + return tBeta*beta*beta; + } + /** * diff --git a/reconstruction/dc/src/main/java/org/jlab/service/dc/DCEngine.java b/reconstruction/dc/src/main/java/org/jlab/service/dc/DCEngine.java index 150c7dc702..20742c831b 100755 --- a/reconstruction/dc/src/main/java/org/jlab/service/dc/DCEngine.java +++ b/reconstruction/dc/src/main/java/org/jlab/service/dc/DCEngine.java @@ -77,7 +77,23 @@ public void setOptions() { if (wireDistortionsFlag==null) { System.out.println("["+this.getName()+"] run with default setting for wire distortions in tracking (MC-off/Data-on)"); } + //Use time in tBeta function (true: use time; false: use track doca) + String useTIMETBETA = this.getEngineConfigString("dcTimeTBeta"); + if (useTIMETBETA!=null) { + System.out.println("["+this.getName()+"] run with start time in tracking config chosen based on yaml = "+useTIMETBETA); + Constants.setUSETIMETBETA(Boolean.valueOf(useTIMETBETA)); + } + else { + useTIMETBETA = System.getenv("COAT_DC_USETIMETBETA"); + if (useTIMETBETA!=null) { + System.out.println("["+this.getName()+"] run with start time in tracking config chosen based on env = "+useTIMETBETA); + Constants.setUSETIMETBETA(Boolean.valueOf(useTIMETBETA)); + } + } + if (useTIMETBETA==null) { + System.out.println("["+this.getName()+"] run with start time in tracking config chosen based on default = "+Constants.useUSETIMETBETA()); + } //T2D Function String T2Dfcn = this.getEngineConfigString("dcT2DFunc"); diff --git a/reconstruction/dc/src/main/java/org/jlab/service/dc/DCHBEngine.java b/reconstruction/dc/src/main/java/org/jlab/service/dc/DCHBEngine.java index 5d87c96d54..0c038c8c42 100755 --- a/reconstruction/dc/src/main/java/org/jlab/service/dc/DCHBEngine.java +++ b/reconstruction/dc/src/main/java/org/jlab/service/dc/DCHBEngine.java @@ -7,8 +7,6 @@ import java.util.ArrayList; import java.util.List; import java.util.concurrent.atomic.AtomicInteger; -import java.util.logging.Level; -import java.util.logging.Logger; import org.jlab.clas.swimtools.MagFieldsEngine; import org.jlab.clas.swimtools.Swim; From 25b0df25d29d186c0f61532d92a58beb163cc349 Mon Sep 17 00:00:00 2001 From: ziegler Date: Tue, 15 Oct 2019 13:30:39 -0400 Subject: [PATCH 067/235] New Matrix library used in DC tracking. --- .../java/org/jlab/rec/dc/track/Track.java | 3 +- .../jlab/rec/dc/track/fit/KFitterDoca.java | 80 +++++++++---------- .../jlab/rec/dc/track/fit/RungeKuttaDoca.java | 9 ++- .../jlab/rec/dc/track/fit/StateVecsDoca.java | 62 +++++++------- .../java/org/jlab/service/dc/DCTBEngine.java | 6 +- 5 files changed, 86 insertions(+), 74 deletions(-) diff --git a/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/Track.java b/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/Track.java index 9365de0c0c..ef1b3d67c7 100755 --- a/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/Track.java +++ b/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/Track.java @@ -1,6 +1,7 @@ package org.jlab.rec.dc.track; -import Jama.Matrix; +//import Jama.Matrix; +import org.jlab.jnp.matrix.*; import java.util.ArrayList; import java.util.List; import org.jlab.geom.prim.Point3D; diff --git a/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/fit/KFitterDoca.java b/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/fit/KFitterDoca.java index e9ca5db744..457271b4cb 100644 --- a/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/fit/KFitterDoca.java +++ b/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/fit/KFitterDoca.java @@ -1,6 +1,6 @@ package org.jlab.rec.dc.track.fit; -import Jama.Matrix; +//import Jama.Matrix; import java.util.ArrayList; import java.util.List; @@ -10,7 +10,7 @@ import org.jlab.rec.dc.track.Track; import org.jlab.rec.dc.track.fit.StateVecsDoca.CovMat; import org.jlab.rec.dc.track.fit.StateVecsDoca.StateVec; - +import org.jlab.jnp.matrix.*; /** * @author ziegler @@ -33,6 +33,12 @@ public class KFitterDoca { public int NDF = 0; public int ConvStatus = 1; + Matrix first_inverse = new Matrix(); + Matrix addition = new Matrix(); + Matrix result = new Matrix(); + Matrix result_inv = new Matrix(); + Matrix adj = new Matrix(); + public KFitterDoca(Track trk, DCGeant4Factory DcDetector, boolean TimeBasedUsingHBtrack, Swim swimmer, int c) { @@ -109,7 +115,9 @@ public void runFitter(int sector) { sv.transport(sector, k, k + 1, sv.trackTraj.get(k), sv.trackCov.get(k)); - this.filter(k + 1); + //if(i==1 && k==0) + // Matrix5x5.show(sv.trackCov.get(k).covMat); + this.filter(k + 1); } if (i > 1) { if(this.setFitFailed==true) @@ -141,43 +149,35 @@ public void runFitter(int sector) { } - public Matrix filterCovMat(double[] H, Matrix C, double V) { - Matrix Ci; - - if (!this.isNonsingular(C)) { - return null; - } - try { - Ci = C.inverse(); - } catch (Exception e) { - return null; - } - double[][] HTGH = new double[][]{ - {H[0] * H[0] / V, H[0] * H[1] / V, 0, 0, 0}, - {H[0] * H[1] / V, H[1] * H[1] / V, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }; - Matrix Ca; - try { - Ca = Ci.plus(new Matrix(HTGH)); - } catch (Exception e) { - return null; - } - if (Ca != null && !this.isNonsingular(Ca)) { + public Matrix filterCovMat(double[] H, Matrix Ci, double V) { + + double det = Matrix5x5.inverse(Ci, first_inverse, adj); + if(Math.abs(det)<1.e-30) return null; - } - if (Ca != null) { - Matrix CaInv = Ca.inverse(); - if (CaInv != null) { - return CaInv; - } else { - return null; - } - } else { + + addition.set( + H[0] * H[0] / V, H[0] * H[1] / V, 0, 0, 0, + H[0] * H[1] / V, H[1] * H[1] / V, 0, 0, 0, + 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0); + //System.out.println("Ci "); + //Matrix5x5.show(Ci); + //System.out.println("Cinv "); + //Matrix5x5.show(first_inverse); + //System.out.println("addition "); + //Matrix5x5.show(addition); + + Matrix5x5.add(first_inverse, addition, result); + double det2 = Matrix5x5.inverse(result, result_inv, adj); + //System.out.println("addition result"); + //Matrix5x5.show(result); + //System.out.println("inv result"); + //Matrix5x5.show(result_inv); + if(Math.abs(det2)<1.e-30) return null; - } + + return result_inv; } private void filter(int k) { if (sv.trackTraj.get(k) != null && @@ -371,9 +371,9 @@ private void calcFinalChisq(int sector) { } - private boolean isNonsingular(Matrix mat) { + /*private boolean isNonsingular(Matrix mat) { double matDet = mat.det(); return Math.abs(matDet) >= 1.e-30; - } + }*/ } diff --git a/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/fit/RungeKuttaDoca.java b/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/fit/RungeKuttaDoca.java index 6afa3b4b7f..96ab61e7bf 100644 --- a/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/fit/RungeKuttaDoca.java +++ b/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/fit/RungeKuttaDoca.java @@ -5,7 +5,8 @@ */ package org.jlab.rec.dc.track.fit; -import Jama.Matrix; +//import Jama.Matrix; +import org.jlab.jnp.matrix.*; import java.util.ArrayList; import org.jlab.clas.swimtools.Swim; /** @@ -323,9 +324,9 @@ void RK4transport(int sector, double q, double x0, double y0, double z0, double fVec.Q = q; fVec.B = Math.sqrt(_b[0]*_b[0]+_b[1]*_b[1]+_b[2]*_b[2]); fVec.deltaPath = Math.sqrt((x0-x)*(x0-x)+(y0-y)*(y0-y)+h*h)+dPath; - fCov.covMat=new Matrix(C); - - + fCov.covMat.set(C); + //System.out.println("Transported matrix"); + //Matrix5x5.show(fCov.covMat); } diff --git a/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/fit/StateVecsDoca.java b/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/fit/StateVecsDoca.java index aef31a4f17..e60eac39a1 100644 --- a/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/fit/StateVecsDoca.java +++ b/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/fit/StateVecsDoca.java @@ -1,6 +1,7 @@ package org.jlab.rec.dc.track.fit; -import Jama.Matrix; +//import Jama.Matrix; +import org.jlab.jnp.matrix.*; import java.util.HashMap; import java.util.Map; import org.jlab.clas.clas.math.FastMath; @@ -25,7 +26,9 @@ public class StateVecsDoca { public StateVec StateVec; public CovMat CovMat; - public Matrix F; + public Matrix F = new Matrix(); + private Matrix fMS = new Matrix(); + private Matrix copyMatrix = new Matrix(); private final double[] A = new double[2]; private final double[] dA = new double[4]; private final float[] bf = new float[3]; @@ -63,8 +66,8 @@ public void transport(int sector, int i, int f, StateVec iVec, CovMat covMat) { fVec.ty = iVec.ty; fVec.Q = iVec.Q; fVec.B = iVec.B; - fCov.covMat = covMat.covMat; - + //fCov.covMat = covMat.covMat; + Matrix5x5.copy(covMat.covMat, fCov.covMat); double s = 0; double z = Z[i]; double BatMeas = iVec.B; @@ -78,8 +81,8 @@ public void transport(int sector, int i, int f, StateVec iVec, CovMat covMat) { double ty = fVec.ty; double Q = fVec.Q; double dPath = fVec.deltaPath; - covMat.covMat = fCov.covMat; - + //covMat.covMat = fCov.covMat; + Matrix5x5.copy(fCov.covMat, covMat.covMat); s= Math.signum(Z[f] - Z[i]) * stepSize; // System.out.println(" from "+(float)Z[i]+" to "+(float)Z[f]+" at "+(float)z+" By is "+bf[1]+" B is "+Math.sqrt(bf[0]*bf[0]+bf[1]*bf[1]+bf[2]*bf[2])/Bmax+" stepSize is "+s); if(Math.signum(Z[f] - Z[i]) *(z+s)>Math.signum(Z[f] - Z[i]) *Z[f]) @@ -110,16 +113,19 @@ public void transport(int sector, int i, int f, StateVec iVec, CovMat covMat) { double cov_tyty = (1 + ty * ty) * (1 + tx * tx + ty * ty) * sctRMS * sctRMS; double cov_txty = tx * ty * (1 + tx * tx + ty * ty) * sctRMS * sctRMS; + //if (Math.signum(Z[f] - Z[i]) > 0) { - Matrix fMS = new Matrix(new double[][]{ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, cov_txtx, cov_txty, 0}, - {0, 0, cov_txty, cov_tyty, 0}, - {0, 0, 0, 0, 0} - }); - Matrix fCovMS = fCov.covMat.copy().plus(fMS); - fCov.covMat = fCovMS; + fMS.set( + 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, + 0, 0, cov_txtx, cov_txty, 0, + 0, 0, cov_txty, cov_tyty, 0, + 0, 0, 0, 0, 0 + ); + + Matrix5x5.copy(fCov.covMat, copyMatrix); + Matrix5x5.add(copyMatrix, fMS, fCov.covMat); + //} // end add process noise @@ -281,14 +287,14 @@ public void init(Track trkcand, double z0, KFitterDoca kf, int c) { double ey = 0.5 * wy_over_wx * Math.sqrt(err_it1 * err_it1 + err_it2 * err_it2 + z * z * (err_sl1 * err_sl1 + err_sl2 * err_sl2)); double epSq = 0.001 * trkcand.get_P() * trkcand.get_P(); - Matrix initCMatrix = new Matrix(new double[][]{ - {ex * ex, 0, 0, 0, 0}, - {0, ey * ey, 0, 0, 0}, - {0, 0, eux * eux, 0, 0}, - {0, 0, 0, euy * euy, 0}, - {0, 0, 0, 0, epSq} - }); - + Matrix initCMatrix = new Matrix(); + initCMatrix.set(ex * ex, 0, 0, 0, 0, + 0, ey * ey, 0, 0, 0, + 0, 0, eux * eux, 0, 0, + 0, 0, 0, euy * euy, 0, + 0, 0, 0, 0, epSq + ); + CovMat initCM = new CovMat(0); initCM.covMat = initCMatrix; this.trackCov.put(0, initCM); @@ -395,14 +401,16 @@ void initFromHB(Track trkcand, double z0, KFitterDoca kf) { rinitSV.tx = trkcand.getFinalStateVec().tanThetaX(); rinitSV.ty = trkcand.getFinalStateVec().tanThetaY(); rinitSV.Q = ((double) trkcand.get_Q())/trkcand.get_P(); - double[][] FTF = new double[5][5]; + double[] FTF = new double[25]; double[] F = this.F(trkcand.get(0).get_Sector(), z0, rinitSV); for(int i = 0; i<5; i++) { - FTF[i][i]=F[i]*F[i]; + FTF[i*5+i]=F[i]*F[i]; } - Matrix initCMatrix = new Matrix(FTF); + //Matrix initCMatrix = new Matrix(FTF); + Matrix initCMatrix = new Matrix(); + initCMatrix.set(FTF); initCM.covMat = initCMatrix; //end test this.trackCov.put(0, initCM); //this.printMatrix(initCM.covMat); @@ -451,7 +459,7 @@ String printInfo() { public class CovMat { final int k; - public Matrix covMat; + public Matrix covMat = new Matrix(); CovMat(int k) { this.k = k; diff --git a/reconstruction/dc/src/main/java/org/jlab/service/dc/DCTBEngine.java b/reconstruction/dc/src/main/java/org/jlab/service/dc/DCTBEngine.java index f32d5706b6..bf4397742e 100755 --- a/reconstruction/dc/src/main/java/org/jlab/service/dc/DCTBEngine.java +++ b/reconstruction/dc/src/main/java/org/jlab/service/dc/DCTBEngine.java @@ -1,6 +1,7 @@ package org.jlab.service.dc; -import Jama.Matrix; +//import Jama.Matrix; +import org.jlab.jnp.matrix.*; import java.util.ArrayList; import java.util.List; import java.util.concurrent.atomic.AtomicInteger; @@ -181,7 +182,8 @@ public boolean processDataEvent(DataEvent event) { trkbank.getFloat("tx", i), trkbank.getFloat("ty", i)); HBFinalSV.setZ(trkbank.getFloat("z", i)); HBtrk.setFinalStateVec(HBFinalSV); - Matrix initCMatrix = new Matrix(new double[][]{ + Matrix initCMatrix = new Matrix(); + initCMatrix.set(new double[][]{ {trkcovbank.getFloat("C11", i), trkcovbank.getFloat("C12", i), trkcovbank.getFloat("C13", i), trkcovbank.getFloat("C14", i), trkcovbank.getFloat("C15", i)}, {trkcovbank.getFloat("C21", i), trkcovbank.getFloat("C22", i), trkcovbank.getFloat("C23", i), trkcovbank.getFloat("C24", i), trkcovbank.getFloat("C25", i)}, {trkcovbank.getFloat("C31", i), trkcovbank.getFloat("C32", i), trkcovbank.getFloat("C33", i), trkcovbank.getFloat("C34", i), trkcovbank.getFloat("C35", i)}, From cffc2f1325be74ec2c5761b59c9aa09910928287 Mon Sep 17 00:00:00 2001 From: ziegler Date: Tue, 15 Oct 2019 13:35:01 -0400 Subject: [PATCH 068/235] Added ability to remove a region used in tracking to study the effect on resolution and efficiency. --- .../main/java/org/jlab/rec/cvt/Constants.java | 10 +++++ .../org/jlab/rec/cvt/banks/HitReader.java | 8 ++-- .../rec/cvt/services/CVTReconstruction.java | 41 ++++++++----------- 3 files changed, 32 insertions(+), 27 deletions(-) diff --git a/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/Constants.java b/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/Constants.java index 8a369d0209..f64fc11287 100644 --- a/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/Constants.java +++ b/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/Constants.java @@ -34,6 +34,8 @@ public class Constants { private static double _RbErr = 1./Math.sqrt(12.); private static double _Zoffset = 0; + + private static int _rmReg = 0; public static double getXb() { return _Xb; @@ -67,6 +69,14 @@ public static void setZoffset(double _Zoffset) { Constants._Zoffset = _Zoffset; } + public static int getRmReg() { + return _rmReg; + } + + public static void setRmReg(int _reg) { + Constants._rmReg = _reg; + } + //public static final boolean DEBUGMODE =false; // for landau inverse calculation public static final double f[] = { diff --git a/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/banks/HitReader.java b/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/banks/HitReader.java index f091903c85..19d4a54e42 100644 --- a/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/banks/HitReader.java +++ b/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/banks/HitReader.java @@ -114,7 +114,8 @@ public void fetch_BMTHits(DataEvent event, ADCConvertor adcConv, org.jlab.rec.cv // hit.set_Status(-1); hit.set_Id(i+1); // add this hit - hits.add(hit); + if(hit.get_Layer()+3!=org.jlab.rec.cvt.Constants.getRmReg()) + hits.add(hit); } // fills the list of BMT hits @@ -157,10 +158,11 @@ public void fetch_SVTHits(DataEvent event, ADCConvertor adcConv, int omitLayer, if (bankDGTZ.getInt("ADC", i) < 0) { continue; // ignore hits TDC hits with ADC==-1 } - + id[i] = i + 1; sector[i] = bankDGTZ.getByte("sector", i); layer[i] = bankDGTZ.getByte("layer", i); + strip[i] = bankDGTZ.getShort("component", i); ADC[i] = bankDGTZ.getInt("ADC", i); @@ -230,7 +232,7 @@ public void fetch_SVTHits(DataEvent event, ADCConvertor adcConv, int omitLayer, hit.set_Id(id[i]); // add this hit - if(SvtStrip.get_Edep()>0) + if(SvtStrip.get_Edep()>0 && hit.get_Region()!=org.jlab.rec.cvt.Constants.getRmReg()) hits.add(hit); } } diff --git a/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/services/CVTReconstruction.java b/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/services/CVTReconstruction.java index 294e1151aa..b69605b11b 100644 --- a/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/services/CVTReconstruction.java +++ b/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/services/CVTReconstruction.java @@ -10,7 +10,6 @@ import org.jlab.detector.base.GeometryFactory; import org.jlab.detector.calib.utils.DatabaseConstantProvider; import org.jlab.detector.geant4.v2.CTOFGeant4Factory; -import org.jlab.detector.geant4.v2.FTOFGeant4Factory; import org.jlab.detector.geant4.v2.SVT.SVTConstants; import org.jlab.detector.geant4.v2.SVT.SVTStripFactory; import org.jlab.geom.base.ConstantProvider; @@ -25,10 +24,6 @@ import org.jlab.rec.cvt.bmt.CCDBConstantsLoader; import org.jlab.rec.cvt.track.StraightTrack; import org.jlab.rec.cvt.track.Track; -import org.jlab.rec.cvt.track.Track; -import org.jlab.utils.groups.IndexedTable; -//import org.jlab.service.eb.EBHBEngine; -//import org.jlab.service.eb.EBTBEngine; /** * Service to return reconstructed BST track candidates- the output is in Evio @@ -86,16 +81,7 @@ public void setRunConditionsParameters(DataEvent event, String Fields, int iRun, System.out.println(" CHECK CONFIGS..............................." + FieldsConfig + " = ? " + newConfig); Constants.Load(isCosmics, isSVTonly, (double) bank.getFloat("solenoid", 0)); - // Load the Fields - //System.out.println("************************************************************SETTING FIELD SCALE *****************************************************"); - //TrkSwimmer.setMagneticFieldScale(bank.getFloat("solenoid", 0)); // something changed in the configuration - //double shift =0; - //if(bank.getInt("run", 0)>1840) - // shift = -1.9; - //MagneticFields.getInstance().setSolenoidShift(shift); -// this.setFieldsConfig(newConfig); -//CCDBConstantsLoader.Load(new DatabaseConstantProvider(bank.getInt("run", 0), "default")); } this.setFieldsConfig(newConfig); @@ -184,16 +170,23 @@ public boolean loadConstants( int run ) { } public boolean init() { - //System.out.println(" ........................................ trying to connect to db "); -//// CCDBConstantsLoader.Load(new DatabaseConstantProvider( "sqlite:///clas12.sqlite", "default")); - //CCDBConstantsLoader.Load(new DatabaseConstantProvider(10, "default")); - - //DatabaseConstantProvider cp = new DatabaseConstantProvider(11, "default"); -//// DatabaseConstantProvider cp = new DatabaseConstantProvider( "sqlite:///clas12.sqlite", "default"); - //cp = SVTConstants.connect( cp ); - //SVTConstants.loadAlignmentShifts( cp ); - //cp.disconnect(); - //this.setSVTDB(cp); + // Load config + String rmReg = this.getEngineConfigString("removeRegion"); + + if (rmReg!=null) { + System.out.println("["+this.getName()+"] run with region "+rmReg+"removed config chosen based on yaml"); + Constants.setRmReg(Integer.valueOf(rmReg)); + } + else { + rmReg = System.getenv("COAT_CVT_REMOVEREGION"); + if (rmReg!=null) { + System.out.println("["+this.getName()+"] run with region "+rmReg+"removed config chosen based on env"); + Constants.setRmReg(Integer.valueOf(rmReg)); + } + } + if (rmReg==null) { + System.out.println("["+this.getName()+"] run with all region (default) "); + } // Load other geometries String variationName = Optional.ofNullable(this.getEngineConfigString("variation")).orElse("default"); From eb82eaafb6af6bfaafe07f34657e4c5d1b309f20 Mon Sep 17 00:00:00 2001 From: ziegler Date: Tue, 15 Oct 2019 16:56:02 -0400 Subject: [PATCH 069/235] Fix service configuration output String for new tBeta function. Fix bug in tBeta function. --- .../dc/src/main/java/org/jlab/rec/dc/hit/FittedHit.java | 2 +- .../dc/src/main/java/org/jlab/service/dc/DCEngine.java | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/reconstruction/dc/src/main/java/org/jlab/rec/dc/hit/FittedHit.java b/reconstruction/dc/src/main/java/org/jlab/rec/dc/hit/FittedHit.java index d6633b8e53..7f16fa0568 100644 --- a/reconstruction/dc/src/main/java/org/jlab/rec/dc/hit/FittedHit.java +++ b/reconstruction/dc/src/main/java/org/jlab/rec/dc/hit/FittedHit.java @@ -410,7 +410,7 @@ public double calcDeltaTimeBetaTFCN(double t,IndexedTable tab, double beta){ this.get_Superlayer(),0); double delt = db/Constants.AVEDRIFTVEL; //see [CLAS-Note 96-008] - double tBeta = (0.5 *delt*delt*delt*t)/(delt*delt*delt*t*t*t); + double tBeta = (0.5 *delt*delt*delt*t)/(delt*delt*delt+t*t*t); return tBeta*beta*beta; } diff --git a/reconstruction/dc/src/main/java/org/jlab/service/dc/DCEngine.java b/reconstruction/dc/src/main/java/org/jlab/service/dc/DCEngine.java index 20742c831b..677af550ef 100755 --- a/reconstruction/dc/src/main/java/org/jlab/service/dc/DCEngine.java +++ b/reconstruction/dc/src/main/java/org/jlab/service/dc/DCEngine.java @@ -81,18 +81,18 @@ public void setOptions() { String useTIMETBETA = this.getEngineConfigString("dcTimeTBeta"); if (useTIMETBETA!=null) { - System.out.println("["+this.getName()+"] run with start time in tracking config chosen based on yaml = "+useTIMETBETA); + System.out.println("["+this.getName()+"] run with new tBeta chosen based on yaml = "+useTIMETBETA); Constants.setUSETIMETBETA(Boolean.valueOf(useTIMETBETA)); } else { useTIMETBETA = System.getenv("COAT_DC_USETIMETBETA"); if (useTIMETBETA!=null) { - System.out.println("["+this.getName()+"] run with start time in tracking config chosen based on env = "+useTIMETBETA); + System.out.println("["+this.getName()+"] run with with new tBeta config chosen based on env = "+useTIMETBETA); Constants.setUSETIMETBETA(Boolean.valueOf(useTIMETBETA)); } } if (useTIMETBETA==null) { - System.out.println("["+this.getName()+"] run with start time in tracking config chosen based on default = "+Constants.useUSETIMETBETA()); + System.out.println("["+this.getName()+"] run with with new tBeta config chosen based on default = "+Constants.useUSETIMETBETA()); } //T2D Function String T2Dfcn = this.getEngineConfigString("dcT2DFunc"); From fcb2b1ce794f3b718aae19d79ad41a1200f92373 Mon Sep 17 00:00:00 2001 From: baltzell Date: Thu, 17 Oct 2019 20:18:07 -0400 Subject: [PATCH 070/235] bin/bin.old cleanup --- bin.old/analyzer | 5 ----- {bin => bin.old}/convertor | 0 {bin => bin.old}/ddr | 0 bin.old/debug_ec.sh | 5 ----- {bin => bin.old}/decoder3 | 0 bin.old/eb-monitor | 5 ----- bin.old/ec-monitor | 5 ----- bin.old/gemc-evio | 5 ----- {bin => bin.old}/hipo-writer | 0 {bin => bin.old}/hipo3utils | 0 bin.old/pion | 5 ----- {bin => bin.old}/studio | 0 {bin => bin.old}/x-client | 0 {bin => bin.old}/x-client-evio | 0 {bin => bin.old}/x-server | 0 bin/daq-monitor | 5 ----- bin/{browser => hipo-browser} | 0 17 files changed, 35 deletions(-) delete mode 100755 bin.old/analyzer rename {bin => bin.old}/convertor (100%) rename {bin => bin.old}/ddr (100%) delete mode 100755 bin.old/debug_ec.sh rename {bin => bin.old}/decoder3 (100%) delete mode 100755 bin.old/eb-monitor delete mode 100755 bin.old/ec-monitor delete mode 100755 bin.old/gemc-evio rename {bin => bin.old}/hipo-writer (100%) rename {bin => bin.old}/hipo3utils (100%) delete mode 100755 bin.old/pion rename {bin => bin.old}/studio (100%) rename {bin => bin.old}/x-client (100%) rename {bin => bin.old}/x-client-evio (100%) rename {bin => bin.old}/x-server (100%) delete mode 100755 bin/daq-monitor rename bin/{browser => hipo-browser} (100%) diff --git a/bin.old/analyzer b/bin.old/analyzer deleted file mode 100755 index cd3152725e..0000000000 --- a/bin.old/analyzer +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -f - -source `dirname $0`/env.sh - -java -Xms1024m -cp "$CLAS12DIR/lib/clas/*:$CLAS12DIR/lib/plugins/*" org.jlab.clas.physics.DataAnalysis $* diff --git a/bin/convertor b/bin.old/convertor similarity index 100% rename from bin/convertor rename to bin.old/convertor diff --git a/bin/ddr b/bin.old/ddr similarity index 100% rename from bin/ddr rename to bin.old/ddr diff --git a/bin.old/debug_ec.sh b/bin.old/debug_ec.sh deleted file mode 100755 index 321a23d0fc..0000000000 --- a/bin.old/debug_ec.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -f - -source `dirname $0`/env.sh - -java -Xms1024m -cp "$CLAS12DIR/lib/clas/*:$CLAS12DIR/lib/plugins/*" org.jlab.display.ec.ECPion $* diff --git a/bin/decoder3 b/bin.old/decoder3 similarity index 100% rename from bin/decoder3 rename to bin.old/decoder3 diff --git a/bin.old/eb-monitor b/bin.old/eb-monitor deleted file mode 100755 index 5cea7b17a1..0000000000 --- a/bin.old/eb-monitor +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -f - -source `dirname $0`/env.sh - -java -Xms1024m -cp "$CLAS12DIR/lib/clas/*:$CLAS12DIR/lib/services/*:$CLAS12DIR/lib/utils/*" org.jlab.service.eb.EBDebug $* diff --git a/bin.old/ec-monitor b/bin.old/ec-monitor deleted file mode 100755 index bd7fc15ba8..0000000000 --- a/bin.old/ec-monitor +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -f - -source `dirname $0`/env.sh - -java -Xms1024m -cp "$CLAS12DIR/lib/clas/*:$CLAS12DIR/lib/services/*:$CLAS12DIR/lib/utils/*" org.jlab.display.ec.ECMonitor $* diff --git a/bin.old/gemc-evio b/bin.old/gemc-evio deleted file mode 100755 index 9aca3ab088..0000000000 --- a/bin.old/gemc-evio +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -f - -source `dirname $0`/env.sh - -java -Xms1024m -cp "$CLAS12DIR/lib/clas/*:$CLAS12DIR/lib/plugins/*" org.jlab.clas.reco.io.ReconstructionIO $* diff --git a/bin/hipo-writer b/bin.old/hipo-writer similarity index 100% rename from bin/hipo-writer rename to bin.old/hipo-writer diff --git a/bin/hipo3utils b/bin.old/hipo3utils similarity index 100% rename from bin/hipo3utils rename to bin.old/hipo3utils diff --git a/bin.old/pion b/bin.old/pion deleted file mode 100755 index d7dba70fbd..0000000000 --- a/bin.old/pion +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -f - -source `dirname $0`/env.sh - -java -Xms1024m -cp "$CLAS12DIR/lib/clas/*:$CLAS12DIR/lib/services/*" org.jlab.display.ec.ECPionFinder $* diff --git a/bin/studio b/bin.old/studio similarity index 100% rename from bin/studio rename to bin.old/studio diff --git a/bin/x-client b/bin.old/x-client similarity index 100% rename from bin/x-client rename to bin.old/x-client diff --git a/bin/x-client-evio b/bin.old/x-client-evio similarity index 100% rename from bin/x-client-evio rename to bin.old/x-client-evio diff --git a/bin/x-server b/bin.old/x-server similarity index 100% rename from bin/x-server rename to bin.old/x-server diff --git a/bin/daq-monitor b/bin/daq-monitor deleted file mode 100755 index b765b23a4b..0000000000 --- a/bin/daq-monitor +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -f - -source `dirname $0`/env.sh - -java -Xms1024m -cp "$CLAS12DIR/lib/clas/*:$CLAS12DIR/lib/services/*:$CLAS12DIR/lib/utils/*" org.jlab.detector.examples.DaqPulsePlotter $* diff --git a/bin/browser b/bin/hipo-browser similarity index 100% rename from bin/browser rename to bin/hipo-browser From 9560fdcd86a77465201688dc9381a8b7b11d963f Mon Sep 17 00:00:00 2001 From: baltzell Date: Wed, 23 Oct 2019 18:09:57 -0400 Subject: [PATCH 071/235] overload helicity getters with Event arg, privatize HipoReader-based constructor (need rewind/getTags) --- .../helicity/HelicitySequenceManager.java | 46 +++++++++++++------ 1 file changed, 31 insertions(+), 15 deletions(-) diff --git a/common-tools/clas-detector/src/main/java/org/jlab/detector/helicity/HelicitySequenceManager.java b/common-tools/clas-detector/src/main/java/org/jlab/detector/helicity/HelicitySequenceManager.java index ce9dbaae82..a5d615e204 100644 --- a/common-tools/clas-detector/src/main/java/org/jlab/detector/helicity/HelicitySequenceManager.java +++ b/common-tools/clas-detector/src/main/java/org/jlab/detector/helicity/HelicitySequenceManager.java @@ -18,25 +18,22 @@ */ public final class HelicitySequenceManager { + SchemaFactory schema=null; private final int delay; private int verbosity=1; private volatile Map seqMap=new HashMap<>(); - - public HelicitySequenceManager(int delay) { - this.delay=delay; - } - + Bank rcfgBank=null; + public HelicitySequenceManager(int delay,List filenames) { this.delay=delay; initialize(filenames); } - public HelicitySequenceManager(int delay,HipoReader reader) { + private HelicitySequenceManager(int delay,HipoReader reader) { this.delay=delay; initialize(reader); } - public void setVerbosity(int verbosity) { this.verbosity=verbosity; for (HelicitySequence hs : seqMap.values()) { @@ -62,26 +59,46 @@ public HelicityBit search(int runno, long timestamp) { if (seqMap.containsKey(runno)) return seqMap.get(runno).search(timestamp); return HelicityBit.UDF; } - public HelicityBit predictGenerated(int runno, long timestamp) { if (seqMap.containsKey(runno)) return seqMap.get(runno).predictGenerated(timestamp); return HelicityBit.UDF; } - public HelicityBit searchGenerated(int runno, long timestamp) { if (seqMap.containsKey(runno)) return seqMap.get(runno).searchGenerated(timestamp); return HelicityBit.UDF; } + + public HelicityBit search(Event event) { + event.read(this.rcfgBank); + if (rcfgBank.getRows()<1) return HelicityBit.UDF; + return this.search(rcfgBank.getInt("run",0),rcfgBank.getLong("timestamp",0)); + } + public HelicityBit predictGenerated(Event event) { + event.read(this.rcfgBank); + if (rcfgBank.getRows()<1) return HelicityBit.UDF; + return this.predictGenerated(rcfgBank.getInt("run",0),rcfgBank.getLong("timestamp",0)); + } + public HelicityBit searchGenerated(Event event) { + event.read(this.rcfgBank); + if (rcfgBank.getRows()<1) return HelicityBit.UDF; + return this.searchGenerated(rcfgBank.getInt("run",0),rcfgBank.getLong("timestamp",0)); + } /** * Initialize from a HipoReader object. + * This requires an unread HipoReader, since HipoReader doesn't provide a + * rewind option, nor a way to read the set tags. * @param reader */ - public void initialize(HipoReader reader) { - SchemaFactory schema = reader.getSchemaFactory(); + private void initialize(HipoReader reader) { + if (this.schema==null) { + this.schema=reader.getSchemaFactory(); + this.rcfgBank=new Bank(this.schema.getSchema("RUN::config")); + } + reader.setTags(1); while (reader.hasNext()) { Event event=new Event(); - Bank flipBank=new Bank(schema.getSchema("HEL::flip")); + Bank flipBank=new Bank(this.schema.getSchema("HEL::flip")); reader.nextEvent(event); event.read(flipBank); if (flipBank.getRows()<1) continue; @@ -94,10 +111,9 @@ public void initialize(HipoReader reader) { * Initialize from a list of file names: * @param filenames */ - public void initialize(List filenames) { + private void initialize(List filenames) { for (String filename : filenames) { HipoReader reader = new HipoReader(); - reader.setTags(1); reader.open(filename); initialize(reader); reader.close(); @@ -119,4 +135,4 @@ public void show() { } } -} \ No newline at end of file +} From 39b4b0e12f6d53cb7a3a22753795de478516c7b8 Mon Sep 17 00:00:00 2001 From: baltzell Date: Wed, 23 Oct 2019 18:10:17 -0400 Subject: [PATCH 072/235] add dst-maker script (a hipo-utils wrapper) --- bin/dst-maker | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100755 bin/dst-maker diff --git a/bin/dst-maker b/bin/dst-maker new file mode 100755 index 0000000000..a542ddce28 --- /dev/null +++ b/bin/dst-maker @@ -0,0 +1,32 @@ +#!/bin/sh + +usage="\nUsage: dst-maker -o outputfile inputfile [inputfile [...]]\n" + +if [ "$#" -lt 3 ]; then + echo -e $usage + exit +elif [ "$1" != "-o" ]; then + echo -e $usage + exit +elif [ -e $2 ]; then + echo -e $usage + echo File already exists: $2 + exit +else + for x in ${@:3} + do + if ! [ -e $x ]; then + echo -e $usage + echo File does not exist: $x + exit + fi + done +fi + +hipo-utils \ + -filter \ + -b 'RUN::*,RAW::epics,RAW::scaler,HEL::flip,HEL::online,REC::*' \ + -merge \ + -o $2 \ + ${@:3} + From f060779cf55834536900551677e7fe8f039042ca Mon Sep 17 00:00:00 2001 From: baltzell Date: Wed, 23 Oct 2019 18:10:34 -0400 Subject: [PATCH 073/235] reduce memory limit on recon-util (10% faster!?) --- bin/recon-util | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/recon-util b/bin/recon-util index 763324174c..4137ff6fdd 100755 --- a/bin/recon-util +++ b/bin/recon-util @@ -4,4 +4,4 @@ source `dirname $0`/env.sh MALLOC_ARENA_MAX=1; export MALLOC_ARENA_MAX -java -Xmx1536m -Xms1024m -cp "$CLAS12DIR/lib/clas/*:$CLAS12DIR/lib/services/*:$CLAS12DIR/lib/utils/*" org.jlab.clas.reco.EngineProcessor $* +java -Xmx1024m -Xms768m -cp "$CLAS12DIR/lib/clas/*:$CLAS12DIR/lib/services/*:$CLAS12DIR/lib/utils/*" org.jlab.clas.reco.EngineProcessor $* From 2200775f073beb9544219f31f5c1aeb54364454b Mon Sep 17 00:00:00 2001 From: baltzell Date: Wed, 23 Oct 2019 18:59:03 -0400 Subject: [PATCH 074/235] add RECFT and MC banks to dst-maker --- bin/dst-maker | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/dst-maker b/bin/dst-maker index a542ddce28..81aca6fac8 100755 --- a/bin/dst-maker +++ b/bin/dst-maker @@ -25,7 +25,7 @@ fi hipo-utils \ -filter \ - -b 'RUN::*,RAW::epics,RAW::scaler,HEL::flip,HEL::online,REC::*' \ + -b 'RUN::*,RAW::epics,RAW::scaler,HEL::flip,HEL::online,REC::*,RECFT::*,MC::*' \ -merge \ -o $2 \ ${@:3} From 803eb5892c415366544183f46c0909b388b396e0 Mon Sep 17 00:00:00 2001 From: baltzell Date: Sat, 26 Oct 2019 17:03:50 -0400 Subject: [PATCH 075/235] Revert "reduce memory limit on recon-util (10% faster!?)" This reverts commit f060779cf55834536900551677e7fe8f039042ca. --- bin/recon-util | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/recon-util b/bin/recon-util index 4137ff6fdd..763324174c 100755 --- a/bin/recon-util +++ b/bin/recon-util @@ -4,4 +4,4 @@ source `dirname $0`/env.sh MALLOC_ARENA_MAX=1; export MALLOC_ARENA_MAX -java -Xmx1024m -Xms768m -cp "$CLAS12DIR/lib/clas/*:$CLAS12DIR/lib/services/*:$CLAS12DIR/lib/utils/*" org.jlab.clas.reco.EngineProcessor $* +java -Xmx1536m -Xms1024m -cp "$CLAS12DIR/lib/clas/*:$CLAS12DIR/lib/services/*:$CLAS12DIR/lib/utils/*" org.jlab.clas.reco.EngineProcessor $* From 6adc68a9ff361cb1f26edd465a8d26a0ee6aff35 Mon Sep 17 00:00:00 2001 From: baltzell Date: Sat, 26 Oct 2019 17:21:48 -0400 Subject: [PATCH 076/235] hardcode a timestamp tolerance in decoder, for cosmic issues --- .../main/java/org/jlab/detector/decode/CodaEventDecoder.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/CodaEventDecoder.java b/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/CodaEventDecoder.java index 0d988d6fdf..1db85b940c 100644 --- a/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/CodaEventDecoder.java +++ b/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/CodaEventDecoder.java @@ -47,6 +47,8 @@ public class CodaEventDecoder { private List triggerWords = new ArrayList<>(); JsonObject epicsData = new JsonObject(); + private final long timeStampTolerance = 2L; + public CodaEventDecoder(){ } @@ -124,7 +126,7 @@ public void setTimeStamp(EvioDataEvent event) { if(tiEntries.size()>0) { long ts = tiEntries.get(0).getTimeStamp(); for(int i=1; ithis.timeStampTolerance) { tiSync=false; if(this.timeStampErrors<100) { System.out.println("WARNING: mismatch in TI time stamps: crate " From 92681e2ce35f49e1a27961c028b932e601c090a1 Mon Sep 17 00:00:00 2001 From: baltzell Date: Sat, 26 Oct 2019 18:11:37 -0400 Subject: [PATCH 077/235] infinite tolerance, print the other crate --- .../java/org/jlab/detector/decode/CodaEventDecoder.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/CodaEventDecoder.java b/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/CodaEventDecoder.java index 1db85b940c..fd9dff8e67 100644 --- a/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/CodaEventDecoder.java +++ b/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/CodaEventDecoder.java @@ -47,7 +47,7 @@ public class CodaEventDecoder { private List triggerWords = new ArrayList<>(); JsonObject epicsData = new JsonObject(); - private final long timeStampTolerance = 2L; + private final long timeStampTolerance = 0L; public CodaEventDecoder(){ @@ -127,11 +127,12 @@ public void setTimeStamp(EvioDataEvent event) { long ts = tiEntries.get(0).getTimeStamp(); for(int i=1; ithis.timeStampTolerance) { - tiSync=false; + //tiSync=false; if(this.timeStampErrors<100) { System.out.println("WARNING: mismatch in TI time stamps: crate " + tiEntries.get(i).getDescriptor().getCrate() + " reports " - + tiEntries.get(i).getTimeStamp() + " instead of " + ts); + + tiEntries.get(i).getTimeStamp() + " instead of the " + ts + + " from crate " + tiEntries.get(0).getDescriptor().getCrate()); this.timeStampErrors++; } } From d44be6763dfcba0b3b0106ae30c7d449981a5de2 Mon Sep 17 00:00:00 2001 From: Gagik Gavalian Date: Wed, 30 Oct 2019 11:35:00 -0400 Subject: [PATCH 078/235] added timing to the bonus decoded ADC --- .../detector/decode/CodaEventDecoder.java | 177 +++++++++--------- 1 file changed, 89 insertions(+), 88 deletions(-) diff --git a/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/CodaEventDecoder.java b/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/CodaEventDecoder.java index 0d988d6fdf..aa8a8675d9 100644 --- a/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/CodaEventDecoder.java +++ b/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/CodaEventDecoder.java @@ -44,7 +44,7 @@ public class CodaEventDecoder { private int timeStampErrors = 0; private long triggerBits = 0; private byte helicityLevel3 = HelicityBit.UDF.value(); - private List triggerWords = new ArrayList<>(); + private List triggerWords = new ArrayList<>(); JsonObject epicsData = new JsonObject(); public CodaEventDecoder(){ @@ -86,7 +86,7 @@ public JsonObject getEpicsData(){ public List getTriggerWords(){ return this.triggerWords; } - + private void printByteBuffer(ByteBuffer buffer, int max, int columns){ int n = max; if(buffer.capacity() getADCEntries(EvioDataEvent event){ List entries = new ArrayList(); List branches = this.getEventBranches(event); @@ -163,38 +163,38 @@ public List getADCEntries(EvioDataEvent event){ } return entries; } - + public List getADCEntries(EvioDataEvent event, int crate){ List entries = new ArrayList(); - + List branches = this.getEventBranches(event); EvioTreeBranch cbranch = this.getEventBranch(branches, crate); - + if(cbranch == null ) return null; - + for(EvioNode node : cbranch.getNodes()){ if(node.getTag()==57638){ //System.out.println(" NODE = " + node.getTag() + " , " + node.getNum() + - // " , " + node.getTypeObj().name()); + // " , " + node.getTypeObj().name()); return this.getDataEntries_57638(crate, node, event); } } - + return entries; } - + public List getADCEntries(EvioDataEvent event, int crate, int tagid){ - + List adc = new ArrayList(); List branches = this.getEventBranches(event); - + EvioTreeBranch cbranch = this.getEventBranch(branches, crate); if(cbranch == null ) return null; - + for(EvioNode node : cbranch.getNodes()){ -// +// //if(node.getTag()==57638){ if(node.getTag()==tagid){ // This is regular integrated pulse mode, used for FTOF @@ -202,11 +202,11 @@ public List getADCEntries(EvioDataEvent event, int crate, int tagid){ return this.getADCEntries_Tag(crate, node, event,tagid); //return this.getDataEntriesMode_7(crate,node, event); } - + } return adc; } - + /** * returns list of decoded data in the event for given crate. * @param event @@ -226,7 +226,7 @@ public List getDataEntries(EvioDataEvent event, int crate){ // This is regular integrated pulse mode, used for FTOF // FTCAL and EC/PCAL //return this.getDataEntries_57602(crate, node, event); - + this.readHeaderBank(crate, node, event); //return this.getDataEntriesMode_7(crate,node, event); } @@ -245,7 +245,7 @@ public List getDataEntries(EvioDataEvent event, int crate){ // This is regular integrated pulse mode, used for FTOF // FTCAL and EC/PCAL //return this.getDataEntries_57602(crate, node, event); - + return this.getDataEntries_57617(crate, node, event); //return this.getDataEntriesMode_7(crate,node, event); } @@ -253,33 +253,33 @@ else if(node.getTag()==57602){ // This is regular integrated pulse mode, used for FTOF // FTCAL and EC/PCAL //return this.getDataEntries_57602(crate, node, event); - + return this.getDataEntries_57602(crate, node, event); //return this.getDataEntriesMode_7(crate,node, event); } else if(node.getTag()==57601){ // This is regular integrated pulse mode, used for FTOF // FTCAL and EC/PCAL - + return this.getDataEntries_57601(crate, node, event); //return this.getDataEntriesMode_7(crate,node, event); } else if(node.getTag()==57627){ // This is regular integrated pulse mode, used for MM - + return this.getDataEntries_57627(crate, node, event); //return this.getDataEntriesMode_7(crate,node, event); } else if(node.getTag()==57640){ // This is bit-packed pulse mode, used for MM - + return this.getDataEntries_57640(crate, node, event); //return this.getDataEntriesMode_7(crate,node, event); } else if(node.getTag()==57622){ // This is regular integrated pulse mode, used for FTOF // FTCAL and EC/PCAL - + return this.getDataEntries_57622(crate, node, event); //return this.getDataEntriesMode_7(crate,node, event); } @@ -431,7 +431,7 @@ public ArrayList getDataEntries_57617(Integer crate, EvioNode int halfID = DataUtils.getInteger(halfWord, 3, 3); int adc = adcbyte; Integer channelKey = ((half<<8) | (channel & 0xff)); - + // System.err.println( "Half/chip = " + half + " CHIP = " + chipID + " HALF = " + halfID + " CHANNEL = " + channel + " KEY = " + channelKey ); // TDC data entry @@ -441,7 +441,7 @@ public ArrayList getDataEntries_57617(Integer crate, EvioNode chipID = DataUtils.getInteger(halfWord, 0, 1) + 1; channel = 0; channelKey = 0; - tdc = (short) ((adcbyte<<8) | (tdcbyte & 0xff)); + tdc = (short) ((adcbyte<<8) | (tdcbyte & 0xff)); // System.err.println( "Half/chip = " + half + " CHIP = " + chipID + " HALF = " + halfID + " TDC = " + tdcbyte + " ADC = " + adc + " Time = " + tdc ); adc = -1; } @@ -476,7 +476,7 @@ public ArrayList getDataEntries_57617(Integer crate, EvioNode } return rawdata; } - + public List getADCEntries_Tag(Integer crate, EvioNode node, EvioDataEvent event, int tagid){ List entries = new ArrayList(); if(node.getTag()==tagid){ @@ -570,7 +570,7 @@ public void decodeComposite(ByteBuffer buffer, int offset, List ctypes citems.add(counter); ctypes.add(DataType.NVALUE); position++; - + for(int i = 0; i < counter; i++){ Short channel = (short) (0x00FF&(buffer.get(position))); position++; @@ -592,7 +592,7 @@ public void decodeComposite(ByteBuffer buffer, int offset, List ctypes System.out.println("Exception : Length = " + length + " position = " + position); } } - + public List getDataEntries_57638(Integer crate, EvioNode node, EvioDataEvent event){ List entries = new ArrayList(); if(node.getTag()==57638){ @@ -600,7 +600,7 @@ public List getDataEntries_57638(Integer crate, EvioNode node, EvioDa ByteBuffer compBuffer = node.getByteData(true); //System.out.println(" COMPOSITE TYPE = " + node.getTypeObj().name() + " " + node.getDataTypeObj().name()); //System.out.println(" COMPOSITE BUFFER = " + compBuffer.array().length); - + /*for(int i = 0; i < compBuffer.array().length; i++){ short value = (short) (0x00FF&(compBuffer.array()[i])); System.out.println(String.format("%4d %4d ",i,value)); @@ -609,7 +609,7 @@ public List getDataEntries_57638(Integer crate, EvioNode node, EvioDa List cdatatypes = new ArrayList(); List cdataitems = new ArrayList(); this.decodeComposite(compBuffer, 24, cdatatypes, cdataitems); - + /*try { CompositeData compData = new CompositeData(compBuffer.array(),event.getByteOrder()); List ccdatatypes = compData.getTypes(); @@ -622,15 +622,15 @@ public List getDataEntries_57638(Integer crate, EvioNode node, EvioDa } catch (EvioException ex) { Logger.getLogger(CodaEventDecoder.class.getName()).log(Level.SEVERE, null, ex); }*/ - - - + + + /* CompositeData compData = new CompositeData(compBuffer.array(),event.getByteOrder()); List cdatatypes = compData.getTypes(); List cdataitems = compData.getItems(); - + */ /*if(cdatatypes.get(3) != DataType.NVALUE){ System.err.println("[EvioRawDataSource] ** error ** corrupted " @@ -643,7 +643,7 @@ public List getDataEntries_57638(Integer crate, EvioNode node, EvioDa while(position branches = this.getEventBranches(event); @@ -1244,7 +1245,7 @@ public List getDataEntries_Scalers(EvioDataEvent event){ SCALERData scaler = new SCALERData(); scaler.setHelicity((byte) helicity); scaler.setQuartet((byte) quartet); - scaler.setValue(value); + scaler.setValue(value); entry.addSCALER(scaler); scalerEntries.add(entry); } @@ -1256,12 +1257,12 @@ else if(node.getTag()==57621 && loop>=5) { if(id<3 && slot<4) { DetectorDataDgtz entry = new DetectorDataDgtz(crate,num,loop-5); SCALERData scaler = new SCALERData(); - scaler.setValue(DataUtils.getLongFromInt(dataEntry)); + scaler.setValue(DataUtils.getLongFromInt(dataEntry)); entry.addSCALER(scaler); scalerEntries.add(entry); // long long_data = 0; // long value = (long) ((long_data|dataEntry)&0x00000000FFFFFFFFL); -// System.out.println(loop + " " + crate + " " + slot + " " + id + " " + dataEntry + " " + value + " " + DataUtils.getLongFromInt(dataEntry) + " " + String.format("0x%08X", dataEntry) + " " + String.format("0x%16X", value)); +// System.out.println(loop + " " + crate + " " + slot + " " + id + " " + dataEntry + " " + value + " " + DataUtils.getLongFromInt(dataEntry) + " " + String.format("0x%08X", dataEntry) + " " + String.format("0x%16X", value)); } } } @@ -1272,8 +1273,8 @@ else if(node.getTag()==57621 && loop>=5) { } public List getDataEntries_VTP(EvioDataEvent event){ - - List vtpEntries = new ArrayList(); + + List vtpEntries = new ArrayList(); // this.triggerBank = null; //System.out.println(" READING TRIGGER BANK"); List branches = this.getEventBranches(event); @@ -1347,13 +1348,13 @@ public List getDataEntries_TI(EvioDataEvent event){ for(EvioNode node : cbranch.getNodes()){ if(node.getTag()==57610){ long[] longData = ByteDataTransformer.toLongArray(node.getStructureBuffer(true)); - int[] intData = ByteDataTransformer.toIntArray(node.getStructureBuffer(true)); + int[] intData = ByteDataTransformer.toIntArray(node.getStructureBuffer(true)); long tStamp = longData[2]&0x0000ffffffffffffL; // Below is endian swap if needed //long ntStamp = (((long)(intData[5]&0x0000ffffL))<<32) | (intData[4]&0xffffffffL); //System.out.println(longData[2]+" "+tStamp+" "+crate+" "+node.getDataLength()); - + DetectorDataDgtz entry = new DetectorDataDgtz(crate,0,0); entry.setTimeStamp(tStamp); if(node.getDataLength()==4) tiEntries.add(entry); @@ -1396,7 +1397,7 @@ public static void main(String[] args){ detectorDecoder.translate(dataSet); detectorDecoder.fitPulses(dataSet); if(decoder.getDataEntries_VTP(event).size()!=0) { -// for(DetectorDataDgtz entry : decoder.getDataEntries_VTP(event)) +// for(DetectorDataDgtz entry : decoder.getDataEntries_VTP(event)) // System.out.println(entry.toString()); } // System.out.println("---> printout EVENT # " + icounter); From ec293f47b03dee75ca3f2dcb32c086bb3bc2f5a6 Mon Sep 17 00:00:00 2001 From: baltzell Date: Sun, 3 Nov 2019 18:02:04 -0500 Subject: [PATCH 079/235] Revert "reduce memory limits on evio2hipo/decoder" This reverts commit addd90c1a5271c25d26dee0053f0170bae3b7468. --- bin/decoder | 2 +- bin/evio2hipo | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/decoder b/bin/decoder index d2ca03adf1..760071bdbe 100755 --- a/bin/decoder +++ b/bin/decoder @@ -9,4 +9,4 @@ echo +------------------------------------------------------------------------- echo "| DECODER GENERATION 4 (using HIPO-4 Library)" echo +------------------------------------------------------------------------- -java -Xmx512m -Xms256m -cp "$CLAS12DIR/lib/clas/*:$CLAS12DIR/lib/plugins/*" org.jlab.detector.decode.CLASDecoder4 $* +java -Xmx1536m -Xms1024m -cp "$CLAS12DIR/lib/clas/*:$CLAS12DIR/lib/plugins/*" org.jlab.detector.decode.CLASDecoder4 $* diff --git a/bin/evio2hipo b/bin/evio2hipo index 201e29e50a..ceda619f9b 100755 --- a/bin/evio2hipo +++ b/bin/evio2hipo @@ -4,4 +4,4 @@ source `dirname $0`/env.sh MALLOC_ARENA_MAX=1; export MALLOC_ARENA_MAX -java -Xmx512m -Xms256m -cp "$CLAS12DIR/lib/clas/*:$CLAS12DIR/lib/plugins/*" org.jlab.clas.reco.io.EvioHipoEvent4 $* +java -Xmx1536m -Xms1024m -cp "$CLAS12DIR/lib/clas/*:$CLAS12DIR/lib/plugins/*" org.jlab.clas.reco.io.EvioHipoEvent4 $* From dfe947ceef8dfc3515980f0bdd10bc6de2165410 Mon Sep 17 00:00:00 2001 From: baltzell Date: Sun, 3 Nov 2019 18:32:39 -0500 Subject: [PATCH 080/235] fix mistake on decoder memory limit (pending meamory leak fix) --- bin/decoder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/decoder b/bin/decoder index d2ca03adf1..760071bdbe 100755 --- a/bin/decoder +++ b/bin/decoder @@ -9,4 +9,4 @@ echo +------------------------------------------------------------------------- echo "| DECODER GENERATION 4 (using HIPO-4 Library)" echo +------------------------------------------------------------------------- -java -Xmx512m -Xms256m -cp "$CLAS12DIR/lib/clas/*:$CLAS12DIR/lib/plugins/*" org.jlab.detector.decode.CLASDecoder4 $* +java -Xmx1536m -Xms1024m -cp "$CLAS12DIR/lib/clas/*:$CLAS12DIR/lib/plugins/*" org.jlab.detector.decode.CLASDecoder4 $* From bb0de1f56b12c1a8d8e78e80913173c7ec0b4173 Mon Sep 17 00:00:00 2001 From: ziegler Date: Thu, 7 Nov 2019 10:05:40 -0500 Subject: [PATCH 081/235] Modified tBeta correction (off by default). --- .../main/java/org/jlab/rec/dc/hit/FittedHit.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/reconstruction/dc/src/main/java/org/jlab/rec/dc/hit/FittedHit.java b/reconstruction/dc/src/main/java/org/jlab/rec/dc/hit/FittedHit.java index 7f16fa0568..12938f4ea6 100644 --- a/reconstruction/dc/src/main/java/org/jlab/rec/dc/hit/FittedHit.java +++ b/reconstruction/dc/src/main/java/org/jlab/rec/dc/hit/FittedHit.java @@ -368,18 +368,24 @@ public void set_TimeToDistance(DataEvent event, double trkAngle, double B, Index double x = this.get_ClusFitDoca(); double deltatime_beta = 0; + double deltatime_beta2 = 0; if (x != -1) { if(Constants.useUSETIMETBETA()==true) { deltatime_beta = calcDeltaTimeBetaTFCN(this.get_Time(), tab, beta); + deltatime_beta2 = calcDeltaTimeBeta(this.get_Time(), tab, beta); } else { deltatime_beta = calcDeltaTimeBeta(x, tab, beta); } } if(event.hasBank("MC::Particle")==false) { - distance = tde.interpolateOnGrid(B, Math.toDegrees(ralpha), this.getCorrectedTime(this.get_Time(), deltatime_beta), secIdx, slIdx) ; + distance = tde.interpolateOnGrid(B, Math.toDegrees(ralpha), + this.getCorrectedTime(this.get_Time(), deltatime_beta+deltatime_beta2), + secIdx, slIdx) ; } else { - distance = tde.interpolateOnGrid(B, Math.toDegrees(ralpha), this.getCorrectedTime(this.get_Time(), 0), secIdx, slIdx) ; + distance = tde.interpolateOnGrid(B, Math.toDegrees(ralpha), + this.getCorrectedTime(this.get_Time(), 0), + secIdx, slIdx) ; } //deltatime_beta = calcDeltaTimeBeta(distance, tab, beta); //deltatime_beta = calcDeltaTimeBeta(distance, this.get_Superlayer(), beta); @@ -406,9 +412,9 @@ public double calcDeltaTimeBeta(double x, IndexedTable tab, double beta){ } public double calcDeltaTimeBetaTFCN(double t,IndexedTable tab, double beta){ - double db = tab.getDoubleValue("distbeta", this.get_Sector(), + double delt = tab.getDoubleValue("c3", this.get_Sector(), this.get_Superlayer(),0); - double delt = db/Constants.AVEDRIFTVEL; + //see [CLAS-Note 96-008] double tBeta = (0.5 *delt*delt*delt*t)/(delt*delt*delt+t*t*t); return tBeta*beta*beta; From 6bc2285d00b3e14b62109cb80b746a338ca0b9db Mon Sep 17 00:00:00 2001 From: ziegler Date: Thu, 7 Nov 2019 10:06:42 -0500 Subject: [PATCH 082/235] Modified print output to validate the table. Added check for getting the center of the table bin (commented out). --- .../rec/dc/timetodistance/TableLoader.java | 36 ++++++++++--------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/reconstruction/dc/src/main/java/org/jlab/rec/dc/timetodistance/TableLoader.java b/reconstruction/dc/src/main/java/org/jlab/rec/dc/timetodistance/TableLoader.java index 2d939eb5c4..790b60a06e 100644 --- a/reconstruction/dc/src/main/java/org/jlab/rec/dc/timetodistance/TableLoader.java +++ b/reconstruction/dc/src/main/java/org/jlab/rec/dc/timetodistance/TableLoader.java @@ -43,19 +43,17 @@ public static void test(){ System.out.println(" NEW TIME BIN "); for(int icosalpha =0; icosalphaDISTFROMTIME[s][r][ibfield][icosalpha][tbin] + // && Math.abs((double)(2.*tbin+1)-timebfield)<=Math.abs((double)(2.*tbin+1)-prevTime)) { + // DISTFROMTIME[s][r][ibfield][icosalpha][tbin]=x; + //} // bincount++; DISTFROMTIME[s][r][ibfield][icosalpha][tbin]+=stepSize; } - + /* if(timebfield>timebfield_max) { DISTFROMTIME[s][r][ibfield][icosalpha][tbin]=x-stepSize*0.5; if(DISTFROMTIME[s][r][ibfield][icosalpha][tbin]>dmax) @@ -200,7 +204,7 @@ public static synchronized void Fill(IndexedTable tab) { } } TableLoader.fillMissingTableBins(); - TableLoader.test(); + //TableLoader.test(); System.out.println(" T2D TABLE FILLED....."); T2DLOADED = true; } From bce0eafde4433436c8f65b8f7359d07d788b5a60 Mon Sep 17 00:00:00 2001 From: ziegler Date: Thu, 7 Nov 2019 10:07:14 -0500 Subject: [PATCH 083/235] Added method to check the endplate with bowing on. --- .../rec/dc/trajectory/TrajectorySurfaces.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/reconstruction/dc/src/main/java/org/jlab/rec/dc/trajectory/TrajectorySurfaces.java b/reconstruction/dc/src/main/java/org/jlab/rec/dc/trajectory/TrajectorySurfaces.java index bd17f8c261..bd613ff523 100644 --- a/reconstruction/dc/src/main/java/org/jlab/rec/dc/trajectory/TrajectorySurfaces.java +++ b/reconstruction/dc/src/main/java/org/jlab/rec/dc/trajectory/TrajectorySurfaces.java @@ -5,6 +5,8 @@ */ package org.jlab.rec.dc.trajectory; +import java.io.File; +import java.io.FileNotFoundException; import java.util.ArrayList; import java.util.List; import org.jlab.detector.base.DetectorLayer; @@ -15,6 +17,8 @@ import org.jlab.geom.base.Detector; import org.jlab.geom.prim.Vector3D; import org.jlab.rec.dc.Constants; + +import java.io.PrintWriter; /** * A class to load the geometry constants used in the DC reconstruction. The * coordinate system used in the Tilted Sector coordinate system. @@ -135,6 +139,28 @@ public void LoadSurfaces(double targetPosition, double targetLength, // // return new Point3D(rx,ry,rzs); // } + + public void checkDCGeometry(DCGeant4Factory dcDetector) throws FileNotFoundException { + int is = 0; + PrintWriter pw = new PrintWriter(new File("/Users/ziegler/WireEndPoints.txt")); + + pw.printf("superlayer"+" "+"layer"+" "+"wire"+" "+"xL"+" "+"yL"+" "+ + "xR"+" "+"yR"+" "+"z" + ); + for(int isup =0; isup<6; isup++) { + for(int il =5; il<6; il++) { + for(int ic =0; ic<112; ic++) { // include only layer 6 + double z = dcDetector.getWireMidpoint(is, isup, il, ic).z; + double xL = dcDetector.getWireLeftend(is, isup, il, ic).x; + double xR = dcDetector.getWireRightend(is, isup, il, ic).x; + double yL = dcDetector.getWireLeftend(is, isup, il, ic).y; + double yR = dcDetector.getWireRightend(is, isup, il, ic).y; + pw.printf("%d\t %d\t %d\t %.1f\t %.1f\t %.1f\t %.1f\t %.1f\t\n", (isup+1),(il+1),(ic+1),xL,yL,xR,yR,z + ); + } + } + } + } } From f91d05d05558af58e1745393e20f7be6db3c58eb Mon Sep 17 00:00:00 2001 From: ziegler Date: Thu, 7 Nov 2019 10:07:55 -0500 Subject: [PATCH 084/235] Code cleanup. --- .../main/java/org/jlab/rec/dc/timetodistance/T2DFunctions.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/reconstruction/dc/src/main/java/org/jlab/rec/dc/timetodistance/T2DFunctions.java b/reconstruction/dc/src/main/java/org/jlab/rec/dc/timetodistance/T2DFunctions.java index add2df66be..012ebaeccf 100644 --- a/reconstruction/dc/src/main/java/org/jlab/rec/dc/timetodistance/T2DFunctions.java +++ b/reconstruction/dc/src/main/java/org/jlab/rec/dc/timetodistance/T2DFunctions.java @@ -332,7 +332,8 @@ public static synchronized double polyFcnMac(double x, double alpha, double bfie c = c /(4.-(1.-6.*R*R)/(1.-2.*R)); double b = delv/(rcapital*rcapital) - 4.*c/(3.*rcapital); double d = 1/v_0; - double a = (tmax - b*dmaxalpha*dmaxalpha*dmaxalpha - c*dmaxalpha*dmaxalpha - d*dmaxalpha)/(dmaxalpha*dmaxalpha*dmaxalpha*dmaxalpha) ; + double a = (tmax - b*dmaxalpha*dmaxalpha*dmaxalpha - + c*dmaxalpha*dmaxalpha - d*dmaxalpha)/(dmaxalpha*dmaxalpha*dmaxalpha*dmaxalpha) ; time = a*x*x*x*x + b*x*x*x + c*x*x + d*x ; //B correction From 6143486df5651772d1851be3049b413de56ba5ed Mon Sep 17 00:00:00 2001 From: ziegler Date: Thu, 7 Nov 2019 10:08:33 -0500 Subject: [PATCH 085/235] Added validation geometry validation debug print (off by default). --- .../dc/src/main/java/org/jlab/service/dc/DCEngine.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/reconstruction/dc/src/main/java/org/jlab/service/dc/DCEngine.java b/reconstruction/dc/src/main/java/org/jlab/service/dc/DCEngine.java index 677af550ef..c080bb8cd4 100755 --- a/reconstruction/dc/src/main/java/org/jlab/service/dc/DCEngine.java +++ b/reconstruction/dc/src/main/java/org/jlab/service/dc/DCEngine.java @@ -1,7 +1,10 @@ package org.jlab.service.dc; +import java.io.FileNotFoundException; import java.util.Arrays; import java.util.Optional; +import java.util.logging.Level; +import java.util.logging.Logger; import org.jlab.clas.reco.ReconstructionEngine; import org.jlab.detector.base.DetectorType; import org.jlab.detector.base.GeometryFactory; @@ -172,6 +175,13 @@ public void LoadTables() { // create the surfaces tSurf = new TrajectorySurfaces(); + // for debugging the end plates bowing: + //==================================== + //try { + // tSurf.checkDCGeometry(dcDetector); + //} catch (FileNotFoundException ex) { + // Logger.getLogger(DCEngine.class.getName()).log(Level.SEVERE, null, ex); + //} tSurf.LoadSurfaces(targetPosition, targetLength,dcDetector, ftofDetector, ecalDetector); // Get the constants for the correct variation From dec64b5f752dd3794642fb5040ca17d789c7f902 Mon Sep 17 00:00:00 2001 From: ziegler Date: Thu, 7 Nov 2019 10:13:21 -0500 Subject: [PATCH 086/235] Added cut in cylindrical stopper for loopers. --- .../java/org/jlab/clas/swimtools/Swim.java | 92 +++++++------------ 1 file changed, 34 insertions(+), 58 deletions(-) diff --git a/common-tools/swim-tools/src/main/java/org/jlab/clas/swimtools/Swim.java b/common-tools/swim-tools/src/main/java/org/jlab/clas/swimtools/Swim.java index 91898d354c..6fd972ebdd 100644 --- a/common-tools/swim-tools/src/main/java/org/jlab/clas/swimtools/Swim.java +++ b/common-tools/swim-tools/src/main/java/org/jlab/clas/swimtools/Swim.java @@ -335,31 +335,50 @@ private void checkR(double _x0, double _y0, double _z0) { /** * Cylindrical stopper */ - private class CylindricalcalBoundarySwimStopper implements IStopper { + private class CylindricalBoundarySwimStopper implements IStopper { private double _finalPathLength = Double.NaN; private double _Rad; - + //boolean cutOff = false; + // check that the track can get to R. Stops at the track radius + //float[] b = new float[3]; + //double x0 = _x0*100; + //double y0 = _y0*100; + //double z0 = _z0*100; + + double max = -1.0; /** * A swim stopper that will stop if the boundary of a plane is crossed * * @param maxR * the max radial coordinate in meters. */ - private CylindricalcalBoundarySwimStopper(double Rad) { - // DC reconstruction units are cm. Swim units are m. Hence scale by - // 100 - _Rad = Rad; + private CylindricalBoundarySwimStopper(double Rad) { + // DC reconstruction units are cm. Swim units are m. Hence scale by + // 100 + _Rad = Rad; + // check if the track will reach the surface of the cylinder. + //BfieldLab(x0, y0, z0, b); + //double trkR = _pTot*Math.sin(Math.toRadians(_theta))/Math.abs(b[2]*LIGHTVEL); + //double trkXc = x0 + trkR * Math.sin(Math.toRadians(_phi)); + //if(trkR<(Rad+trkXc) && Math.sqrt(x0*x0+y0*y0)<_Rad) { // check only for swimming inside out. + // cutOff=true; + //} } @Override public boolean stopIntegration(double t, double[] y) { - double r = Math.sqrt(y[0] * y[0] + y[1] * y[1]) * 100.; - - return (r > _Rad); - + double r = Math.sqrt(y[0] * y[0] + y[1] * y[1]) * 100.; + if(r>max ) + max = r; + //if(cutOff) { + return (r < max || r > _Rad); // stop intergration at closest distance to the cylinder + //} + //else { + // return (r > _Rad); + //} } /** @@ -383,24 +402,25 @@ public void setFinalT(double finalPathLength) { _finalPathLength = finalPathLength; } } + //private final double LIGHTVEL = 0.000299792458 ; + /** * * @param Rad * @return state x,y,z,px,py,pz, pathlength, iBdl at the surface */ public double[] SwimToCylinder(double Rad) { - + double[] value = new double[8]; - // using adaptive stepsize if(this.SwimUnPhys) return null; - CylindricalcalBoundarySwimStopper stopper = new CylindricalcalBoundarySwimStopper(Rad); + CylindricalBoundarySwimStopper stopper = new CylindricalBoundarySwimStopper(Rad); SwimTrajectory st = PC.CF.swim(_charge, _x0, _y0, _z0, _pTot, _theta, _phi, stopper, _maxPathLength, stepSize, 0.0005); if(st==null) - return null; + return null; st.computeBDL(PC.CP); // st.computeBDL(compositeField); @@ -632,50 +652,6 @@ public double[] SwimToPlaneBoundary(double d_cm, Vector3D n, int dir) { } catch (RungeKuttaException e) { e.printStackTrace(); } - -// PlaneBoundarySwimStopper stopper = new PlaneBoundarySwimStopper(d, n, dir); - - // this is a uniform stepsize swimmer (dph) -// st = PC.CF.swim(_charge, _x0, _y0, _z0, _pTot, _theta, _phi, stopper, _maxPathLength, stepSize, 0.0005); -// st.computeBDL(PC.CP); -// // st.computeBDL(compositeField); -// -// double[] lastY = st.lastElement(); -// -// value[0] = lastY[0] * 100; // convert back to cm -// value[1] = lastY[1] * 100; // convert back to cm -// value[2] = lastY[2] * 100; // convert back to cm -// value[3] = lastY[3] * _pTot; // normalized values -// value[4] = lastY[4] * _pTot; -// value[5] = lastY[5] * _pTot; -// value[6] = lastY[6] * 100; -// value[7] = lastY[7] * 10; // Conversion from kG.m to T.cm -// -// double tv1 = Math.abs(tvalue[0]); -// double v1 = Math.abs(value[0]); -// -// double fract = (Math.abs(tv1 - v1) / Math.max(tv1, v1)); -// if (fract > 0.9) { -// System.out.println("\nBig Diff fract = " + fract + " direction = " + dir + " DIST = " + d); -// -// double vtxR = Math.sqrt(_x0 * _x0 + _y0 * _y0 + _z0 * _z0); -// System.out.println("VTX: (" + _x0 + ", " + _y0 + ", " + _z0 + ") VtxR: " + vtxR + " P: " + _pTot -// + " theta: " + _theta + " phi: " + _phi); -// -// printV("tV", tvalue); -// printV(" V", value); -// // System.out.println("tV: (" + tvalue[0]/100 + ", " + tvalue[1]/100 -// // + ", " + tvalue[2]/100 + ")"); -// // System.out.println(" V: (" + value[0]/100 + ", " + value[1]/100 + -// // ", " + value[2]/100 + ")"); -// } -// -// // System.out.println(); -// // for (int i = 0; i < 8; i++) { -// // System.out.print(String.format("%-8.5f ", value[i])); -// // } -// // System.out.println(); - return value; } From ac53a6d6c76226fc193c0c7fe2430f2e3052540f Mon Sep 17 00:00:00 2001 From: Raffaella De Vita Date: Thu, 7 Nov 2019 15:29:16 -0500 Subject: [PATCH 087/235] bumped version to 6c.3.5 --- common-tools/clas-analysis/pom.xml | 14 +++++++------- common-tools/clas-detector/pom.xml | 10 +++++----- common-tools/clas-eventmerger/pom.xml | 10 +++++----- common-tools/clas-geometry/pom.xml | 4 ++-- common-tools/clas-io/pom.xml | 6 +++--- common-tools/clas-jcsg/pom.xml | 8 ++++---- common-tools/clas-math/pom.xml | 4 ++-- common-tools/clas-physics/pom.xml | 4 ++-- common-tools/clas-reco/pom.xml | 14 +++++++------- common-tools/clas-utils/pom.xml | 4 ++-- common-tools/cnuphys/ced/pom.xml | 8 ++++---- common-tools/cnuphys/magfield/pom.xml | 2 +- common-tools/cnuphys/swimmer/pom.xml | 2 +- common-tools/coat-lib/deployDistribution.sh | 2 +- common-tools/coat-lib/pom.xml | 20 ++++++++++---------- common-tools/parent/pom.xml | 2 +- common-tools/pom.xml | 4 ++-- common-tools/swim-tools/pom.xml | 6 +++--- parent/pom.xml | 2 +- pom.xml | 4 ++-- reconstruction/band/pom.xml | 2 +- reconstruction/cnd/pom.xml | 2 +- reconstruction/cvt/pom.xml | 10 +++++----- reconstruction/dc/pom.xml | 12 ++++++------ reconstruction/eb/pom.xml | 10 +++++----- reconstruction/ec/pom.xml | 14 +++++++------- reconstruction/ft/pom.xml | 8 ++++---- reconstruction/fvt/pom.xml | 6 +++--- reconstruction/htcc/pom.xml | 8 ++++---- reconstruction/ltcc/pom.xml | 6 +++--- reconstruction/pom.xml | 4 ++-- reconstruction/rich/pom.xml | 8 ++++---- reconstruction/rtpc/pom.xml | 6 +++--- reconstruction/tof/pom.xml | 4 ++-- 34 files changed, 115 insertions(+), 115 deletions(-) diff --git a/common-tools/clas-analysis/pom.xml b/common-tools/clas-analysis/pom.xml index 56cf7151fc..7ebbf0d457 100644 --- a/common-tools/clas-analysis/pom.xml +++ b/common-tools/clas-analysis/pom.xml @@ -3,14 +3,14 @@ 4.0.0 org.jlab.clas clas-analysis - 6c.3.4-SNAPSHOT + 6c.3.5-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 6c.3.4-SNAPSHOT + 6c.3.5-SNAPSHOT @@ -30,31 +30,31 @@ org.jlab.clas clas-utils - 6c.3.4-SNAPSHOT + 6c.3.5-SNAPSHOT org.jlab.clas clas-physics - 6c.3.4-SNAPSHOT + 6c.3.5-SNAPSHOT org.jlab.clas clas-io - 6c.3.4-SNAPSHOT + 6c.3.5-SNAPSHOT org.jlab.clas clas-geometry - 6c.3.4-SNAPSHOT + 6c.3.5-SNAPSHOT org.jlab.clas clas-detector - 6c.3.4-SNAPSHOT + 6c.3.5-SNAPSHOT diff --git a/common-tools/clas-detector/pom.xml b/common-tools/clas-detector/pom.xml index e81aebdb9f..e0942cca4b 100644 --- a/common-tools/clas-detector/pom.xml +++ b/common-tools/clas-detector/pom.xml @@ -3,14 +3,14 @@ 4.0.0 org.jlab.clas clas-detector - 6c.3.4-SNAPSHOT + 6c.3.5-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 6c.3.4-SNAPSHOT + 6c.3.5-SNAPSHOT @@ -30,7 +30,7 @@ org.jlab.clas clas-utils - 6c.3.4-SNAPSHOT + 6c.3.5-SNAPSHOT @@ -42,13 +42,13 @@ org.jlab.clas clas-io - 6c.3.4-SNAPSHOT + 6c.3.5-SNAPSHOT org.jlab.clas clas-geometry - 6c.3.4-SNAPSHOT + 6c.3.5-SNAPSHOT diff --git a/common-tools/clas-eventmerger/pom.xml b/common-tools/clas-eventmerger/pom.xml index a2649a49d0..bb7fd89fec 100644 --- a/common-tools/clas-eventmerger/pom.xml +++ b/common-tools/clas-eventmerger/pom.xml @@ -2,14 +2,14 @@ 4.0.0 clas-eventmerger - 6c.3.4-SNAPSHOT + 6c.3.5-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 6c.3.4-SNAPSHOT + 6c.3.5-SNAPSHOT @@ -29,19 +29,19 @@ org.jlab.clas clas-utils - 6c.3.4-SNAPSHOT + 6c.3.5-SNAPSHOT org.jlab.clas clas-io - 6c.3.4-SNAPSHOT + 6c.3.5-SNAPSHOT org.jlab.clas clas-geometry - 6c.3.4-SNAPSHOT + 6c.3.5-SNAPSHOT diff --git a/common-tools/clas-geometry/pom.xml b/common-tools/clas-geometry/pom.xml index 473c6c07b8..1429005284 100644 --- a/common-tools/clas-geometry/pom.xml +++ b/common-tools/clas-geometry/pom.xml @@ -3,14 +3,14 @@ 4.0.0 org.jlab.clas clas-geometry - 6c.3.4-SNAPSHOT + 6c.3.5-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 6c.3.4-SNAPSHOT + 6c.3.5-SNAPSHOT diff --git a/common-tools/clas-io/pom.xml b/common-tools/clas-io/pom.xml index 8d26abe9bf..0ae651ddbb 100644 --- a/common-tools/clas-io/pom.xml +++ b/common-tools/clas-io/pom.xml @@ -3,14 +3,14 @@ 4.0.0 org.jlab.clas clas-io - 6c.3.4-SNAPSHOT + 6c.3.5-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 6c.3.4-SNAPSHOT + 6c.3.5-SNAPSHOT @@ -75,7 +75,7 @@ org.jlab.clas clas-utils - 6c.3.4-SNAPSHOT + 6c.3.5-SNAPSHOT diff --git a/common-tools/clas-jcsg/pom.xml b/common-tools/clas-jcsg/pom.xml index 37abd42c17..5c20f6d845 100644 --- a/common-tools/clas-jcsg/pom.xml +++ b/common-tools/clas-jcsg/pom.xml @@ -3,14 +3,14 @@ 4.0.0 org.jlab.clas clas-jcsg - 6c.3.4-SNAPSHOT + 6c.3.5-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 6c.3.4-SNAPSHOT + 6c.3.5-SNAPSHOT @@ -40,12 +40,12 @@ org.jlab.clas clas-geometry - 6c.3.4-SNAPSHOT + 6c.3.5-SNAPSHOT org.jlab.clas clas-detector - 6c.3.4-SNAPSHOT + 6c.3.5-SNAPSHOT java3d diff --git a/common-tools/clas-math/pom.xml b/common-tools/clas-math/pom.xml index 3bf18e713f..6ad55c4bcb 100644 --- a/common-tools/clas-math/pom.xml +++ b/common-tools/clas-math/pom.xml @@ -3,14 +3,14 @@ 4.0.0 org.jlab.clas clas-math - 6c.3.4-SNAPSHOT + 6c.3.5-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 6c.3.4-SNAPSHOT + 6c.3.5-SNAPSHOT diff --git a/common-tools/clas-physics/pom.xml b/common-tools/clas-physics/pom.xml index 6962625b01..751e86d6b5 100644 --- a/common-tools/clas-physics/pom.xml +++ b/common-tools/clas-physics/pom.xml @@ -4,7 +4,7 @@ org.jlab.clas clas-physics - 6c.3.4-SNAPSHOT + 6c.3.5-SNAPSHOT jar @@ -23,7 +23,7 @@ org.jlab.clas clas12rec ../../parent/pom.xml - 6c.3.4-SNAPSHOT + 6c.3.5-SNAPSHOT diff --git a/common-tools/clas-reco/pom.xml b/common-tools/clas-reco/pom.xml index b56c406b32..3856044881 100644 --- a/common-tools/clas-reco/pom.xml +++ b/common-tools/clas-reco/pom.xml @@ -3,14 +3,14 @@ 4.0.0 org.jlab.clas clas-reco - 6c.3.4-SNAPSHOT + 6c.3.5-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 6c.3.4-SNAPSHOT + 6c.3.5-SNAPSHOT @@ -67,7 +67,7 @@ org.jlab.clas clas-math - 6c.3.4-SNAPSHOT + 6c.3.5-SNAPSHOT loading table for run = " + run); DatabaseConstantsDescriptor desc = defaultDescriptor.getCopy(run); DatabaseConstantProvider provider = new DatabaseConstantProvider(run, @@ -118,6 +138,10 @@ private synchronized void loadConstantsForRun(int run){ rcdbpro.disconnect(); } + public void reset(){ + this.runConstants.clear(); + } + @Override public String toString(){ StringBuilder str = new StringBuilder(); @@ -229,9 +253,12 @@ public static void main(String[] args){ manager.init(Arrays.asList(new String[]{ "/daq/fadc/ec", "/daq/fadc/ftof","/daq/fadc/htcc"})); - - IndexedTable table1 = manager.getConstants(10, "/daq/fadc/htcc"); - IndexedTable table2 = manager.getConstants(10, "/daq/fadc/ec"); - IndexedTable table3 = manager.getConstants(12, "/daq/fadc/htcc"); + for(int i = 0; i < 5 ; i++){ + IndexedTable table1 = manager.getConstants(10, "/daq/fadc/htcc"); + IndexedTable table2 = manager.getConstants(10, "/daq/fadc/ec"); + IndexedTable table3 = manager.getConstants(12, "/daq/fadc/htcc"); + manager.reset(); + System.out.println("\n\n STATUS = " + manager.getRequestStatus()); + } } } diff --git a/common-tools/clas-reco/src/main/java/org/jlab/clas/reco/ReconstructionEngine.java b/common-tools/clas-reco/src/main/java/org/jlab/clas/reco/ReconstructionEngine.java index c51091b03d..deff562a2f 100644 --- a/common-tools/clas-reco/src/main/java/org/jlab/clas/reco/ReconstructionEngine.java +++ b/common-tools/clas-reco/src/main/java/org/jlab/clas/reco/ReconstructionEngine.java @@ -228,6 +228,14 @@ public EngineData execute(EngineData input) { String mt = input.getMimeType(); //System.out.println(" DATA TYPE = [" + mt + "]"); HipoDataEvent dataEventHipo = null; + + if(constantsManager.getRequestStatus()<0){ + String msg = String.format("HALT : DATABASE CONNECTION ERROR"); + output.setStatus(EngineStatus.ERROR); + output.setDescription(msg); + return output; + } + if(mt.compareTo("binary/data-hipo")==0){ try { //ByteBuffer bb = (ByteBuffer) input.getData(); From a681d1858cd54883c2e5492aaca4544fa4e34000 Mon Sep 17 00:00:00 2001 From: gavalian Date: Mon, 9 Dec 2019 13:48:41 -0500 Subject: [PATCH 132/235] Changed the severity to 12 when database connection error accures --- .../main/java/org/jlab/clas/reco/ReconstructionEngine.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/common-tools/clas-reco/src/main/java/org/jlab/clas/reco/ReconstructionEngine.java b/common-tools/clas-reco/src/main/java/org/jlab/clas/reco/ReconstructionEngine.java index deff562a2f..47b0e2a4c5 100644 --- a/common-tools/clas-reco/src/main/java/org/jlab/clas/reco/ReconstructionEngine.java +++ b/common-tools/clas-reco/src/main/java/org/jlab/clas/reco/ReconstructionEngine.java @@ -230,8 +230,9 @@ public EngineData execute(EngineData input) { HipoDataEvent dataEventHipo = null; if(constantsManager.getRequestStatus()<0){ - String msg = String.format("HALT : DATABASE CONNECTION ERROR"); - output.setStatus(EngineStatus.ERROR); + String msg = String.format("HALT : DATABASE CONNECTION ERROR"); + //output.setStatus(EngineStatus.ERROR); + output.setStatus(EngineStatus.ERROR, 12); output.setDescription(msg); return output; } From 2dc0eb2303d8693efa2b5bab2dc21c7e0fa32b33 Mon Sep 17 00:00:00 2001 From: gavalian Date: Mon, 9 Dec 2019 14:34:38 -0500 Subject: [PATCH 133/235] changed the exit code to severe=13 --- .../src/main/java/org/jlab/clas/reco/ReconstructionEngine.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common-tools/clas-reco/src/main/java/org/jlab/clas/reco/ReconstructionEngine.java b/common-tools/clas-reco/src/main/java/org/jlab/clas/reco/ReconstructionEngine.java index 47b0e2a4c5..308da09e35 100644 --- a/common-tools/clas-reco/src/main/java/org/jlab/clas/reco/ReconstructionEngine.java +++ b/common-tools/clas-reco/src/main/java/org/jlab/clas/reco/ReconstructionEngine.java @@ -232,7 +232,7 @@ public EngineData execute(EngineData input) { if(constantsManager.getRequestStatus()<0){ String msg = String.format("HALT : DATABASE CONNECTION ERROR"); //output.setStatus(EngineStatus.ERROR); - output.setStatus(EngineStatus.ERROR, 12); + output.setStatus(EngineStatus.ERROR, 13); output.setDescription(msg); return output; } From fc201989bf4599caba2d9866016a5d1e856439b5 Mon Sep 17 00:00:00 2001 From: gavalian Date: Tue, 10 Dec 2019 09:11:08 -0500 Subject: [PATCH 134/235] Fixed the issue with constant manager in Reconstruction Engine --- .../java/org/jlab/clas/reco/ReconstructionEngine.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/common-tools/clas-reco/src/main/java/org/jlab/clas/reco/ReconstructionEngine.java b/common-tools/clas-reco/src/main/java/org/jlab/clas/reco/ReconstructionEngine.java index 308da09e35..09dbe3ae65 100644 --- a/common-tools/clas-reco/src/main/java/org/jlab/clas/reco/ReconstructionEngine.java +++ b/common-tools/clas-reco/src/main/java/org/jlab/clas/reco/ReconstructionEngine.java @@ -218,6 +218,13 @@ public void setTimeStamp(String timestamp){ } } + protected boolean constantManagerStatus(){ + for(Map.Entry entry : this.constManagerMap.entrySet()){ + if(entry.getValue().getRequestStatus()<0) return false; + } + return true; + } + @Override public EngineData execute(EngineData input) { @@ -229,10 +236,10 @@ public EngineData execute(EngineData input) { //System.out.println(" DATA TYPE = [" + mt + "]"); HipoDataEvent dataEventHipo = null; - if(constantsManager.getRequestStatus()<0){ + if(constantManagerStatus()==false){ String msg = String.format("HALT : DATABASE CONNECTION ERROR"); //output.setStatus(EngineStatus.ERROR); - output.setStatus(EngineStatus.ERROR, 13); + output.setStatus(EngineStatus.ERROR, 13); output.setDescription(msg); return output; } From 55f5dc392efef1dd42263307fdd9f01e46136d4e Mon Sep 17 00:00:00 2001 From: ziegler Date: Tue, 10 Dec 2019 17:27:35 -0500 Subject: [PATCH 135/235] BMT projector feature fix. --- .../jlab/rec/cvt/services/CVTRecHandler.java | 8 ++-- .../org/jlab/rec/cvt/track/fit/StateVecs.java | 14 ++++-- .../org/jlab/rec/cvt/trajectory/Helix.java | 6 ++- .../rec/cvt/trajectory/TrajectoryFinder.java | 43 ++++++++++++------- 4 files changed, 45 insertions(+), 26 deletions(-) diff --git a/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/services/CVTRecHandler.java b/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/services/CVTRecHandler.java index fdfa416181..e32855da63 100644 --- a/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/services/CVTRecHandler.java +++ b/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/services/CVTRecHandler.java @@ -326,15 +326,15 @@ public List beamTracking(Swim swimmer){ KFitter kf; List trkcands = new ArrayList(); - + //System.out.println(" LOOKING FOR SEED......................"); //List seeds = trseed.findSeed(SVTclusters, SVTGeom, crosses.get(1), BMTGeom); List seeds = trseed.findSeed(crosses.get(0), crosses.get(1), SVTGeom, BMTGeom, swimmer); for (Seed seed : seeds) { - + //System.out.println(" OUTPUT SEED......................"); kf = new KFitter(seed, SVTGeom, swimmer ); kf.runFitter(SVTGeom, BMTGeom, swimmer); - //System.out.println(" OUTPUT SEED......................"); + //System.out.println(" OUTPUT FITTED SEED......................"); trkcands.add(kf.OutputTrack(seed, SVTGeom, swimmer)); if (kf.setFitFailed == false) { trkcands.get(trkcands.size() - 1).set_TrackingStatus(2); @@ -354,7 +354,7 @@ public List beamTracking(Swim swimmer){ trks = trkFinder.getTracks(trkcands, SVTGeom, BMTGeom, CTOFGeom, CNDGeom, swimmer); for( int i=0;i getTrkInMiddleOfBar(int id, double[] inters, CTOFGeant4Fa } return stateVecs; } + + } From 40e6d07b32ba8f85a9516fd92746b200565b05da Mon Sep 17 00:00:00 2001 From: ziegler Date: Wed, 11 Dec 2019 09:25:25 -0500 Subject: [PATCH 136/235] Swim stopper to use in trajectory for central. Pathlength fix for cnd. --- .../java/org/jlab/clas/swimtools/Swim.java | 94 +++++++------------ .../org/jlab/rec/cnd/hit/CvtGetHTrack.java | 4 +- 2 files changed, 38 insertions(+), 60 deletions(-) diff --git a/common-tools/swim-tools/src/main/java/org/jlab/clas/swimtools/Swim.java b/common-tools/swim-tools/src/main/java/org/jlab/clas/swimtools/Swim.java index 91898d354c..114dc0eef1 100644 --- a/common-tools/swim-tools/src/main/java/org/jlab/clas/swimtools/Swim.java +++ b/common-tools/swim-tools/src/main/java/org/jlab/clas/swimtools/Swim.java @@ -335,31 +335,50 @@ private void checkR(double _x0, double _y0, double _z0) { /** * Cylindrical stopper */ - private class CylindricalcalBoundarySwimStopper implements IStopper { + private class CylindricalBoundarySwimStopper implements IStopper { private double _finalPathLength = Double.NaN; private double _Rad; - + //boolean cutOff = false; + // check that the track can get to R. Stops at the track radius + //float[] b = new float[3]; + //double x0 = _x0*100; + //double y0 = _y0*100; + //double z0 = _z0*100; + + double max = -1.0; /** * A swim stopper that will stop if the boundary of a plane is crossed * * @param maxR * the max radial coordinate in meters. */ - private CylindricalcalBoundarySwimStopper(double Rad) { - // DC reconstruction units are cm. Swim units are m. Hence scale by - // 100 - _Rad = Rad; + private CylindricalBoundarySwimStopper(double Rad) { + // DC reconstruction units are cm. Swim units are m. Hence scale by + // 100 + _Rad = Rad; + // check if the track will reach the surface of the cylinder. + //BfieldLab(x0, y0, z0, b); + //double trkR = _pTot*Math.sin(Math.toRadians(_theta))/Math.abs(b[2]*LIGHTVEL); + //double trkXc = x0 + trkR * Math.sin(Math.toRadians(_phi)); + //if(trkR<(Rad+trkXc) && Math.sqrt(x0*x0+y0*y0)<_Rad) { // check only for swimming inside out. + // cutOff=true; + //} } @Override public boolean stopIntegration(double t, double[] y) { - double r = Math.sqrt(y[0] * y[0] + y[1] * y[1]) * 100.; - - return (r > _Rad); - + double r = Math.sqrt(y[0] * y[0] + y[1] * y[1]) * 100.; + if(r>max ) + max = r; + //if(cutOff) { + return (r < max || r > _Rad); // stop intergration at closest distance to the cylinder + //} + //else { + // return (r > _Rad); + //} } /** @@ -383,24 +402,25 @@ public void setFinalT(double finalPathLength) { _finalPathLength = finalPathLength; } } + //private final double LIGHTVEL = 0.000299792458 ; + /** * * @param Rad * @return state x,y,z,px,py,pz, pathlength, iBdl at the surface */ public double[] SwimToCylinder(double Rad) { - + double[] value = new double[8]; - // using adaptive stepsize if(this.SwimUnPhys) return null; - CylindricalcalBoundarySwimStopper stopper = new CylindricalcalBoundarySwimStopper(Rad); + CylindricalBoundarySwimStopper stopper = new CylindricalBoundarySwimStopper(Rad); SwimTrajectory st = PC.CF.swim(_charge, _x0, _y0, _z0, _pTot, _theta, _phi, stopper, _maxPathLength, stepSize, 0.0005); if(st==null) - return null; + return null; st.computeBDL(PC.CP); // st.computeBDL(compositeField); @@ -632,50 +652,6 @@ public double[] SwimToPlaneBoundary(double d_cm, Vector3D n, int dir) { } catch (RungeKuttaException e) { e.printStackTrace(); } - -// PlaneBoundarySwimStopper stopper = new PlaneBoundarySwimStopper(d, n, dir); - - // this is a uniform stepsize swimmer (dph) -// st = PC.CF.swim(_charge, _x0, _y0, _z0, _pTot, _theta, _phi, stopper, _maxPathLength, stepSize, 0.0005); -// st.computeBDL(PC.CP); -// // st.computeBDL(compositeField); -// -// double[] lastY = st.lastElement(); -// -// value[0] = lastY[0] * 100; // convert back to cm -// value[1] = lastY[1] * 100; // convert back to cm -// value[2] = lastY[2] * 100; // convert back to cm -// value[3] = lastY[3] * _pTot; // normalized values -// value[4] = lastY[4] * _pTot; -// value[5] = lastY[5] * _pTot; -// value[6] = lastY[6] * 100; -// value[7] = lastY[7] * 10; // Conversion from kG.m to T.cm -// -// double tv1 = Math.abs(tvalue[0]); -// double v1 = Math.abs(value[0]); -// -// double fract = (Math.abs(tv1 - v1) / Math.max(tv1, v1)); -// if (fract > 0.9) { -// System.out.println("\nBig Diff fract = " + fract + " direction = " + dir + " DIST = " + d); -// -// double vtxR = Math.sqrt(_x0 * _x0 + _y0 * _y0 + _z0 * _z0); -// System.out.println("VTX: (" + _x0 + ", " + _y0 + ", " + _z0 + ") VtxR: " + vtxR + " P: " + _pTot -// + " theta: " + _theta + " phi: " + _phi); -// -// printV("tV", tvalue); -// printV(" V", value); -// // System.out.println("tV: (" + tvalue[0]/100 + ", " + tvalue[1]/100 -// // + ", " + tvalue[2]/100 + ")"); -// // System.out.println(" V: (" + value[0]/100 + ", " + value[1]/100 + -// // ", " + value[2]/100 + ")"); -// } -// -// // System.out.println(); -// // for (int i = 0; i < 8; i++) { -// // System.out.print(String.format("%-8.5f ", value[i])); -// // } -// // System.out.println(); - return value; } @@ -805,4 +781,4 @@ public void BfieldLab(double x_cm, double y_cm, double z_cm, float[] result) { } -} +} \ No newline at end of file diff --git a/reconstruction/cnd/src/main/java/org/jlab/rec/cnd/hit/CvtGetHTrack.java b/reconstruction/cnd/src/main/java/org/jlab/rec/cnd/hit/CvtGetHTrack.java index e4589c876e..1ac890f0d9 100755 --- a/reconstruction/cnd/src/main/java/org/jlab/rec/cnd/hit/CvtGetHTrack.java +++ b/reconstruction/cnd/src/main/java/org/jlab/rec/cnd/hit/CvtGetHTrack.java @@ -112,7 +112,9 @@ public void getCvtHTrack(DataEvent event, CalibrationConstantsLoader ccdb) { trk._TrkInters.get(lay - 1).add(trk.get_Helix().getPointAtRadius(escaperadius)); double r = Math.sqrt(Xm.x() * Xm.x() + Xm.y() * Xm.y()); double par = 1. - ((r * r - dca * dca) * rho * rho) / (2. * (1. + dca * Math.abs(rho))); - double pathLength = Math.abs(Math.acos(par) / rho); + double pathLengthXY = Math.abs(Math.acos(par) / rho); + + double pathLength = Math.sqrt((Xm.z() - z0 )*(Xm.z() - z0 )+pathLengthXY*pathLengthXY); trk._TrkLengths.add(pathLength); } helices.add(trk); From 19ccbca723e7866c5dc8e5751aa549e13a1a7b13 Mon Sep 17 00:00:00 2001 From: baltzell Date: Thu, 12 Dec 2019 13:38:42 -0500 Subject: [PATCH 137/235] use OptionParser for postprocessing --- bin/{.postprocess => postprocess} | 0 .../analysis/postprocess/Tag1ToEvent.java | 52 +++++++++++++------ 2 files changed, 37 insertions(+), 15 deletions(-) rename bin/{.postprocess => postprocess} (100%) diff --git a/bin/.postprocess b/bin/postprocess similarity index 100% rename from bin/.postprocess rename to bin/postprocess diff --git a/common-tools/clas-analysis/src/main/java/org/jlab/analysis/postprocess/Tag1ToEvent.java b/common-tools/clas-analysis/src/main/java/org/jlab/analysis/postprocess/Tag1ToEvent.java index 55964c33de..5f5bf6026b 100644 --- a/common-tools/clas-analysis/src/main/java/org/jlab/analysis/postprocess/Tag1ToEvent.java +++ b/common-tools/clas-analysis/src/main/java/org/jlab/analysis/postprocess/Tag1ToEvent.java @@ -17,6 +17,8 @@ import org.jlab.detector.helicity.HelicityBit; import org.jlab.detector.helicity.HelicitySequenceManager; +import org.jlab.utils.options.OptionParser; + /** * Calls routines to do analysis and per-event lookup of delayed helicity * and beam charge from tag-1 events, and outputs a file with modified @@ -27,8 +29,6 @@ * FIXME: DaqScalersSequence doesn't manage run numbers. Until then, we * cannot mix run numbers here. * - * FIXME: Use standard command-line interpreter, with decent usage help. - * * @author wphelps * @author baltzell */ @@ -37,16 +37,34 @@ public class Tag1ToEvent { public static void main(String[] args) { - // first argument is output filename: - String fileout = args[0]; - - // all other arguments are input filenames: - List filenames = new ArrayList<>(); - for (int i = 1; i < args.length; i++) - filenames.add(args[i]); + OptionParser parser = new OptionParser("postprocess"); + parser.addOption("-q","0","do beam charge and livetime (0/1=false/true)"); + parser.addOption("-d","0","do delayed helicity (0/1=false/true)"); + parser.addRequired("-o","output.hipo"); + parser.parse(args); + + // input files: + List inputList = parser.getInputList(); + if(inputList.isEmpty()==true){ + parser.printUsage(); + System.err.println("\n >>>> error : no input file is specified....\n"); + System.exit(1); + } + + // output file: + String fileout = parser.getOption("-o").stringValue(); + + // helicity / beamcharge options: + final boolean doHelicity = parser.getOption("-d").intValue() != 0; + final boolean doBeamCharge = parser.getOption("-q").intValue() != 0; + if (!doHelicity && !doBeamCharge) { + parser.printUsage(); + System.err.println("\n >>>>> error : at least one of -q/-d must be specified\n"); + System.exit(1); + } - HelicitySequenceManager helSeq = new HelicitySequenceManager(8,filenames); - DaqScalersSequence chargeSeq = DaqScalersSequence.readSequence(filenames); + HelicitySequenceManager helSeq = new HelicitySequenceManager(8,inputList); + DaqScalersSequence chargeSeq = DaqScalersSequence.readSequence(inputList); HipoWriterSorted writer = new HipoWriterSorted(); writer.getSchemaFactory().initFromDirectory(ClasUtilsFile.getResourceDir("COATJAVA", "etc/bankdefs/hipo4")); @@ -66,7 +84,7 @@ public static void main(String[] args) { long badHelicity = 0; long goodHelicity = 0; - for (String filename : filenames) { + for (String filename : inputList) { HipoReader reader = new HipoReader(); reader.open(filename); @@ -88,14 +106,18 @@ public static void main(String[] args) { // write heliicty to REC::Event: if (Math.abs(hb.value())==1) goodHelicity++; else badHelicity++; - recEventBank.putByte("helicity",0,hb.value()); + if (doHelicity) { + recEventBank.putByte("helicity",0,hb.value()); + } // write beam charge to REC::Event: if (ds==null) badCharge++; else { goodCharge++; - recEventBank.putFloat("beamCharge",0,ds.getBeamCharge()); - recEventBank.putDouble("liveTime",0,ds.getLivetime()); + if (doBeamCharge) { + recEventBank.putFloat("beamCharge",0,ds.getBeamCharge()); + recEventBank.putDouble("liveTime",0,ds.getLivetime()); + } } // update the output file: From 490a645fa20eeb801353a6558607c75e9bc08d23 Mon Sep 17 00:00:00 2001 From: ziegler Date: Wed, 11 Dec 2019 09:25:25 -0500 Subject: [PATCH 138/235] Swim stopper to use in trajectory for central. Pathlength fix for cnd. --- .../src/main/java/org/jlab/clas/swimtools/Swim.java | 2 +- .../cnd/src/main/java/org/jlab/rec/cnd/hit/CvtGetHTrack.java | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/common-tools/swim-tools/src/main/java/org/jlab/clas/swimtools/Swim.java b/common-tools/swim-tools/src/main/java/org/jlab/clas/swimtools/Swim.java index 6fd972ebdd..114dc0eef1 100644 --- a/common-tools/swim-tools/src/main/java/org/jlab/clas/swimtools/Swim.java +++ b/common-tools/swim-tools/src/main/java/org/jlab/clas/swimtools/Swim.java @@ -781,4 +781,4 @@ public void BfieldLab(double x_cm, double y_cm, double z_cm, float[] result) { } -} +} \ No newline at end of file diff --git a/reconstruction/cnd/src/main/java/org/jlab/rec/cnd/hit/CvtGetHTrack.java b/reconstruction/cnd/src/main/java/org/jlab/rec/cnd/hit/CvtGetHTrack.java index e4589c876e..1ac890f0d9 100755 --- a/reconstruction/cnd/src/main/java/org/jlab/rec/cnd/hit/CvtGetHTrack.java +++ b/reconstruction/cnd/src/main/java/org/jlab/rec/cnd/hit/CvtGetHTrack.java @@ -112,7 +112,9 @@ public void getCvtHTrack(DataEvent event, CalibrationConstantsLoader ccdb) { trk._TrkInters.get(lay - 1).add(trk.get_Helix().getPointAtRadius(escaperadius)); double r = Math.sqrt(Xm.x() * Xm.x() + Xm.y() * Xm.y()); double par = 1. - ((r * r - dca * dca) * rho * rho) / (2. * (1. + dca * Math.abs(rho))); - double pathLength = Math.abs(Math.acos(par) / rho); + double pathLengthXY = Math.abs(Math.acos(par) / rho); + + double pathLength = Math.sqrt((Xm.z() - z0 )*(Xm.z() - z0 )+pathLengthXY*pathLengthXY); trk._TrkLengths.add(pathLength); } helices.add(trk); From 3fc641570c42b36a025b64b4b899749780c0cb3d Mon Sep 17 00:00:00 2001 From: Raffaella De Vita Date: Fri, 13 Dec 2019 09:09:25 -0500 Subject: [PATCH 139/235] bumped version to 6b.4.0 --- common-tools/clas-analysis/pom.xml | 14 +++++++------- common-tools/clas-detector/pom.xml | 10 +++++----- common-tools/clas-eventmerger/pom.xml | 10 +++++----- common-tools/clas-geometry/pom.xml | 4 ++-- common-tools/clas-io/pom.xml | 6 +++--- common-tools/clas-jcsg/pom.xml | 8 ++++---- common-tools/clas-math/pom.xml | 4 ++-- common-tools/clas-physics/pom.xml | 4 ++-- common-tools/clas-reco/pom.xml | 14 +++++++------- common-tools/clas-utils/pom.xml | 4 ++-- common-tools/cnuphys/ced/pom.xml | 8 ++++---- common-tools/cnuphys/magfield/pom.xml | 2 +- common-tools/cnuphys/swimmer/pom.xml | 2 +- common-tools/coat-lib/deployDistribution.sh | 2 +- common-tools/coat-lib/pom.xml | 20 ++++++++++---------- common-tools/parent/pom.xml | 2 +- common-tools/pom.xml | 4 ++-- common-tools/swim-tools/pom.xml | 6 +++--- parent/pom.xml | 2 +- pom.xml | 4 ++-- reconstruction/band/pom.xml | 2 +- reconstruction/cnd/pom.xml | 2 +- reconstruction/cvt/pom.xml | 10 +++++----- reconstruction/dc/pom.xml | 12 ++++++------ reconstruction/eb/pom.xml | 10 +++++----- reconstruction/ec/pom.xml | 14 +++++++------- reconstruction/ft/pom.xml | 8 ++++---- reconstruction/fvt/pom.xml | 6 +++--- reconstruction/htcc/pom.xml | 8 ++++---- reconstruction/ltcc/pom.xml | 6 +++--- reconstruction/pom.xml | 4 ++-- reconstruction/rich/pom.xml | 8 ++++---- reconstruction/rtpc/pom.xml | 6 +++--- reconstruction/tof/pom.xml | 4 ++-- 34 files changed, 115 insertions(+), 115 deletions(-) diff --git a/common-tools/clas-analysis/pom.xml b/common-tools/clas-analysis/pom.xml index 8d1a772b13..7d631af434 100644 --- a/common-tools/clas-analysis/pom.xml +++ b/common-tools/clas-analysis/pom.xml @@ -3,14 +3,14 @@ 4.0.0 org.jlab.clas clas-analysis - 6b.4.0-SNAPSHOT + 6b.4.1-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 6b.4.0-SNAPSHOT + 6b.4.1-SNAPSHOT @@ -30,31 +30,31 @@ org.jlab.clas clas-utils - 6b.4.0-SNAPSHOT + 6b.4.1-SNAPSHOT org.jlab.clas clas-physics - 6b.4.0-SNAPSHOT + 6b.4.1-SNAPSHOT org.jlab.clas clas-io - 6b.4.0-SNAPSHOT + 6b.4.1-SNAPSHOT org.jlab.clas clas-geometry - 6b.4.0-SNAPSHOT + 6b.4.1-SNAPSHOT org.jlab.clas clas-detector - 6b.4.0-SNAPSHOT + 6b.4.1-SNAPSHOT diff --git a/common-tools/clas-detector/pom.xml b/common-tools/clas-detector/pom.xml index 78fcd75d34..a233c69232 100644 --- a/common-tools/clas-detector/pom.xml +++ b/common-tools/clas-detector/pom.xml @@ -3,14 +3,14 @@ 4.0.0 org.jlab.clas clas-detector - 6b.4.0-SNAPSHOT + 6b.4.1-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 6b.4.0-SNAPSHOT + 6b.4.1-SNAPSHOT @@ -30,7 +30,7 @@ org.jlab.clas clas-utils - 6b.4.0-SNAPSHOT + 6b.4.1-SNAPSHOT @@ -42,13 +42,13 @@ org.jlab.clas clas-io - 6b.4.0-SNAPSHOT + 6b.4.1-SNAPSHOT org.jlab.clas clas-geometry - 6b.4.0-SNAPSHOT + 6b.4.1-SNAPSHOT diff --git a/common-tools/clas-eventmerger/pom.xml b/common-tools/clas-eventmerger/pom.xml index a67b5aa45a..2ebf106cc6 100644 --- a/common-tools/clas-eventmerger/pom.xml +++ b/common-tools/clas-eventmerger/pom.xml @@ -2,14 +2,14 @@ 4.0.0 clas-eventmerger - 6b.4.0-SNAPSHOT + 6b.4.1-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 6b.4.0-SNAPSHOT + 6b.4.1-SNAPSHOT @@ -29,19 +29,19 @@ org.jlab.clas clas-utils - 6b.4.0-SNAPSHOT + 6b.4.1-SNAPSHOT org.jlab.clas clas-io - 6b.4.0-SNAPSHOT + 6b.4.1-SNAPSHOT org.jlab.clas clas-geometry - 6b.4.0-SNAPSHOT + 6b.4.1-SNAPSHOT diff --git a/common-tools/clas-geometry/pom.xml b/common-tools/clas-geometry/pom.xml index 25831b4dce..f34da5d5a7 100644 --- a/common-tools/clas-geometry/pom.xml +++ b/common-tools/clas-geometry/pom.xml @@ -3,14 +3,14 @@ 4.0.0 org.jlab.clas clas-geometry - 6b.4.0-SNAPSHOT + 6b.4.1-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 6b.4.0-SNAPSHOT + 6b.4.1-SNAPSHOT diff --git a/common-tools/clas-io/pom.xml b/common-tools/clas-io/pom.xml index 0a7fbacbab..51706cdc72 100644 --- a/common-tools/clas-io/pom.xml +++ b/common-tools/clas-io/pom.xml @@ -3,14 +3,14 @@ 4.0.0 org.jlab.clas clas-io - 6b.4.0-SNAPSHOT + 6b.4.1-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 6b.4.0-SNAPSHOT + 6b.4.1-SNAPSHOT @@ -75,7 +75,7 @@ org.jlab.clas clas-utils - 6b.4.0-SNAPSHOT + 6b.4.1-SNAPSHOT diff --git a/common-tools/clas-jcsg/pom.xml b/common-tools/clas-jcsg/pom.xml index 3078d0de51..b00cc5c9a8 100644 --- a/common-tools/clas-jcsg/pom.xml +++ b/common-tools/clas-jcsg/pom.xml @@ -3,14 +3,14 @@ 4.0.0 org.jlab.clas clas-jcsg - 6b.4.0-SNAPSHOT + 6b.4.1-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 6b.4.0-SNAPSHOT + 6b.4.1-SNAPSHOT @@ -40,12 +40,12 @@ org.jlab.clas clas-geometry - 6b.4.0-SNAPSHOT + 6b.4.1-SNAPSHOT org.jlab.clas clas-detector - 6b.4.0-SNAPSHOT + 6b.4.1-SNAPSHOT java3d diff --git a/common-tools/clas-math/pom.xml b/common-tools/clas-math/pom.xml index 1f3abae4d7..e4c79706bd 100644 --- a/common-tools/clas-math/pom.xml +++ b/common-tools/clas-math/pom.xml @@ -3,14 +3,14 @@ 4.0.0 org.jlab.clas clas-math - 6b.4.0-SNAPSHOT + 6b.4.1-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 6b.4.0-SNAPSHOT + 6b.4.1-SNAPSHOT diff --git a/common-tools/clas-physics/pom.xml b/common-tools/clas-physics/pom.xml index c3d7c9ea80..b0c2b42f1c 100644 --- a/common-tools/clas-physics/pom.xml +++ b/common-tools/clas-physics/pom.xml @@ -4,7 +4,7 @@ org.jlab.clas clas-physics - 6b.4.0-SNAPSHOT + 6b.4.1-SNAPSHOT jar @@ -23,7 +23,7 @@ org.jlab.clas clas12rec ../../parent/pom.xml - 6b.4.0-SNAPSHOT + 6b.4.1-SNAPSHOT diff --git a/common-tools/clas-reco/pom.xml b/common-tools/clas-reco/pom.xml index cd5dfe5d77..03282f72cb 100644 --- a/common-tools/clas-reco/pom.xml +++ b/common-tools/clas-reco/pom.xml @@ -3,14 +3,14 @@ 4.0.0 org.jlab.clas clas-reco - 6b.4.0-SNAPSHOT + 6b.4.1-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 6b.4.0-SNAPSHOT + 6b.4.1-SNAPSHOT @@ -67,7 +67,7 @@ org.jlab.clas clas-math - 6b.4.0-SNAPSHOT + 6b.4.1-SNAPSHOT etac %8.4f for background %g %g \n", etac*MRAD, prob, Math.log(prob)); }else{ //System.out.format("ATT: wrong prob for background %g \n",prob-1); } @@ -302,8 +450,8 @@ public void get_pid(RICHParticle hadron, int recotype) { lh_el += Math.log(prob); ch_el += Math.log(prob)*etac; n_el++; - reco.set_elprob(Math.log(prob)); - if(debugMode>=2)System.out.format("prob %d etac %8.4f for electron %g %g \n",npho, etac*MRAD, prob, Math.log(prob)); + reco.set_ElProb(Math.log(prob)); + if(debugMode>=2)System.out.format("- --> etac %8.4f for electron %g %g \n", etac*MRAD, prob, Math.log(prob)); }else{ //System.out.format("ATT: wrong prob for electron %g \n",prob-1); } @@ -314,8 +462,8 @@ public void get_pid(RICHParticle hadron, int recotype) { lh_pi += Math.log(prob); ch_pi += Math.log(prob)*etac; n_pi++; - reco.set_piprob(Math.log(prob)); - if(debugMode>=1)System.out.format("prob %d etac %8.4f for pion %g %g \n",npho, etac*MRAD, prob, Math.log(prob)); + reco.set_PiProb(Math.log(prob)); + if(debugMode>=1)System.out.format(" --> etac %8.4f for pion %g %g \n", etac*MRAD, prob, Math.log(prob)); }else{ //System.out.format("ATT: wrong prob for pion %g \n",prob-1); } @@ -326,8 +474,8 @@ public void get_pid(RICHParticle hadron, int recotype) { lh_k += Math.log(prob); ch_k += Math.log(prob)*etac; n_k++; - reco.set_kprob(Math.log(prob)); - if(debugMode>=1)System.out.format("prob %d etac %8.4f for kaon %g %g \n",npho, etac*MRAD, prob, Math.log(prob)); + reco.set_KProb(Math.log(prob)); + if(debugMode>=1)System.out.format(" --> etac %8.4f for kaon %g %g \n", etac*MRAD, prob, Math.log(prob)); }else{ //System.out.format("ATT: wrong prob for kaon %g \n",prob-1); } @@ -337,16 +485,15 @@ public void get_pid(RICHParticle hadron, int recotype) { if(prob-1>=RICHConstants.RICH_BKG_PROBABILITY){ lh_pr += Math.log(prob); ch_pr += Math.log(prob)*etac; - reco.set_prprob(Math.log(prob)); + reco.set_PrProb(Math.log(prob)); n_pr++; - if(debugMode>=1)System.out.format("prob %d etac %8.4f for proton %g %g \n",npho, etac*MRAD, prob, Math.log(prob)); + if(debugMode>=1)System.out.format(" --> etac %8.4f for proton %g %g \n", etac*MRAD, prob, Math.log(prob)); }else{ //System.out.format("ATT: wrong prob for proton %g \n",prob-1); } if(debugMode>=2) pho.shortshow(); } - npho++; } if(lh_el>0)ch_el=ch_el/lh_el; @@ -364,22 +511,18 @@ public void get_pid(RICHParticle hadron, int recotype) { ch_el, ch_pi, ch_k, ch_pr, ch_had); double newRQ = 0.0; - if(recotype==0) { - newRQ = hadron.analytic.assign_PID(lh_el, lh_pi, lh_k, lh_pr, lh_bg); - hadron.set_RICHpid(hadron.analytic.get_bestH()); - if(debugMode>=1)System.out.format("NEW ALY eve %8d mom %6.2f xy %7.2f %7.2f %7.2f %7.2f %8.2f %8.4f Npho %5d %8.4f %3d %g %3d %g --> %8.5f %7.2f %7.2f %3d %3d | %5d %8.4f \n",eventID, hadron.get_momentum(), - hadron.lab_origin.x(), hadron.lab_origin.y(), hadron.meas_hit.x, hadron.meas_hit.y, hadron.get_changle(0)*MRAD, hadron.refi_emission, - n_el, lh_el, hadron.analytic.get_bestH(), hadron.analytic.get_bestprob(), hadron.analytic.get_secH(), hadron.analytic.get_secprob(), - newRQ, ch_had*MRAD, ch_el*MRAD, hadron.get_CLASpid(), hadron.get_RICHpid(), match_nchi2, match_chi2); - } - if(recotype==1) { - newRQ = hadron.traced.assign_PID(lh_el, lh_pi, lh_k, lh_pr, lh_bg); - hadron.set_RICHpid(hadron.traced.get_bestH()); - if(debugMode>=1)System.out.format("NEW TRA eve %8d mom %6.2f xy %7.2f %7.2f %7.2f %7.2f %8.2f %8.4f Npho %5d %8.4f %3d %g %3d %g --> %8.5f %7.2f %7.2f %3d %3d | %5d %8.4f \n",eventID, hadron.get_momentum(), - hadron.lab_origin.x(), hadron.lab_origin.y(), hadron.meas_hit.x, hadron.meas_hit.y, hadron.get_changle(0)*MRAD, hadron.refi_emission, - n_el, lh_el, hadron.traced.get_bestH(), hadron.traced.get_bestprob(), hadron.traced.get_secH(), hadron.traced.get_secprob(), - newRQ, ch_had*MRAD, ch_el*MRAD, hadron.get_CLASpid(), hadron.get_RICHpid(), match_nchi2, match_chi2); - } + RICHSolution hreco = new RICHSolution(); + String hstri = null; + if(recotype==0) {hreco = hadron.analytic; hstri="ALI";} + if(recotype==1) {hreco = hadron.traced; hstri="TRA";} + + newRQ = hreco.assign_PID(lh_el, lh_pi, lh_k, lh_pr, lh_bg); + hadron.set_RICHpid(hreco.get_BestH()); + if(debugMode>=1)System.out.format("%s eve %8d mom %6.2f xy %7.2f %7.2f %7.2f %7.2f %8.2f %8.4f Npho %5d %8.4f %3d %g %3d %g --> %8.5f %7.2f %7.2f %3d %3d\n", + hstri,eventID, hadron.get_momentum(), + hadron.lab_origin.x(), hadron.lab_origin.y(), hadron.meas_hit.x, hadron.meas_hit.y, hadron.get_changle(0,0)*MRAD, hadron.refi_emission, + n_el, lh_el, hadron.analytic.get_BestH(), hadron.analytic.get_Bestprob(), hadron.analytic.get_secH(), hadron.analytic.get_secprob(), + newRQ, ch_el*MRAD, ch_had*MRAD, hadron.get_CLASpid(), hadron.get_RICHpid()); } @@ -411,6 +554,53 @@ public void showEvent(){ } } + // ---------------- + public void select_Photons(RICHConstants recopar, int recotype){ + // ---------------- + int debugMode = 0; + int jj=0; + for( RICHParticle pho: photons){ + if(pho.get_type()==0){ + + RICHHit hit = get_Hit( pho.get_hit_index() ); + RICHParticle had = get_Hadron( pho.get_ParentIndex() ); + + RICHSolution reco = new RICHSolution(); + String stype = null; + if(recotype==0) { + if (had.get_Status()!=1)continue; + reco = pho.analytic; stype="analytic"; + } + if(recotype==1) {reco = pho.traced; stype="traced";} + + double htime = hit.get_time(); + double dtime = pho.get_start_time() + reco.get_time() - htime; + + int irefle = reco.get_RefleType(); + if(irefle<0 || irefle>2) continue; + + double CHMI = had.minChAngle(irefle); + double CHMA = had.maxChAngle(irefle); + double DTMA = recopar.RICH_TIME_RMS*3; + + double etaC = reco.get_EtaC(); + + // select acceptable Cherenkov solution + if((etaC>CHMI && etaC=1){ + System.out.format("Test pho %4d %4d %s %7.2f (%7.2f-%7.2f) %7.2f (%7.2f) --> %4d %d\n", + jj,pho.get_id(), stype, etaC*MRAD, CHMI*MRAD, CHMA*MRAD, dtime, DTMA, reco.get_OK(),reco.get_FirstRefle()); + } + jj++; + + } + + } + + } // ---------------- public void analyze_Photons(){ @@ -466,8 +656,8 @@ public void associate_Throws(RICHTool tool){ // ---------------- int debugMode = 0; - match_nchi2 = 0 ; - match_chi2 = 0.0 ; + int match_nchi2 = 0 ; + double match_chi2 = 0.0 ; RICHConstants recopar = tool.get_Constants(); @@ -576,6 +766,7 @@ public void throw_Photons(RICHParticle hadron, int Npho, double theta, int type, // store in the event if(rays.get(rays.size()-1).is_detected()){ + if(debugMode>=1)System.out.format(" --> detected \n"); photons.add(photon); fac=1; if (photon.traced.get_rayrefle()>2)fac=2.; diff --git a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHEventBuilder.java b/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHEventBuilder.java index adc762a952..611bb3468c 100644 --- a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHEventBuilder.java +++ b/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHEventBuilder.java @@ -265,6 +265,7 @@ public boolean read_ForwardTracks(DataEvent event) { * disregard central detector tracks */ if(idet!=6)continue; + if(tr.getSector()!=4)continue; for (int j=0; j=1) System.out.format(" --> %7.2f %7.2f %7.2f | %7.2f %7.2f %7.2f -> %7.2f %7.2f %7.2f \n", - jx,jy,jz,jcx,jcy,jcz,vdir.x,vdir.y,vdir.z); + if(debugMode>=1) System.out.format(" --> %7.2f %7.2f %7.2f | %7.2f %7.2f %7.2f -> %7.2f %7.2f %7.2f | path %7.2f \n", + jx,jy,jz,jcx,jcy,jcz,vdir.x,vdir.y,vdir.z,rbank.getFloat("path", j)); }else{ if(debugMode>=1) System.out.format("\n"); } @@ -380,8 +381,13 @@ public void process_Hit_Matching(){ int index = p.getDetectorHit(richevent.get_ResClus(), DetectorType.RICH, 1, rich_match_cut); if(index>=0){ // while storing the match, calculates the matched position as middle point between track and hit and path (track last cross plus distance to hit) - p.addResponse(richevent.get_ResClu(index), true); - richevent.get_ResClu(index).setAssociation(n); + + DetectorResponse res = richevent.get_ResClu(index); + double dist = tool.toVector3d(res.getPosition()).distance( tool.toVector3d(p.getLastCross().origin()) ); + //res.setPath(p.getPathLength()+dist); + + p.addResponse(res, true); + res.setAssociation(p.getTrackStatus()); if(debugMode>=1) System.out.println(" --> match found "+index+" for particle "+n); } @@ -462,41 +468,53 @@ public boolean find_Hadrons() { double CLASbeta = p.getTheoryBeta(CLASpid); if(debugMode>=1) { - System.out.format(" --> track %4d %4d ori %s P %8.2f the %8.2f time @IP %8.2f \n",p.getTrackIndex(),CLASpid, - tool.toString(p.getLastCross().origin()),p.vector().mag(),theta*RAD,richevent.get_EventTime()); + System.out.format(" --> track %4d %4d ori %s P %8.2f the %8.2f time @IP %8.2f path %7.2f\n",p.getTrackIndex(),CLASpid, + tool.toString(p.getLastCross().origin()),p.vector().mag(),theta*RAD,richevent.get_EventTime(),p.getPathLength()); } DetectorResponse r = null; - int nresp = 0; + DetectorResponse exr = null; + int nr = 0; + int nexr = 0; + double RICHtime = 0.0; + double Match_chi2 = 0.0; + int RICHiclu = -1; for(DetectorResponse rtest : p.getDetectorResponses()){ if(rtest.getDescriptor().getType()==DetectorType.RICH){ r = rtest; - nresp++; + RICHtime = richevent.get_EventTime() + r.getPath()/CLASbeta/(PhysicsConstants.speedOfLight()); + RICHiclu = r.getHitIndex(); + double CLAStime = richevent.get_EventTime() + r.getPath()/CLASbeta/(PhysicsConstants.speedOfLight()); + + if(debugMode>=1)System.out.format(" --> cluster %4d hit %s path %7.2f --> clas %8.2f vs rich %8.2f time\n \n",RICHiclu, + tool.toString(r.getPosition()), r.getPath(), CLAStime, RICHtime); + + nr++; } } - if(tool.get_Constants().DO_MIRROR_HADS==1 && nresp==0){ - if(debugMode>=1)System.out.format("EXTRAPOLATED \n"); - r = extrapolate_RICHResponse(p); - if(r!=null) nresp++; + + if( (nr==1) || (nr==0 && tool.get_Constants().DO_MIRROR_HADS==1) ){ + if(debugMode>=1)System.out.format("EXTRAPOLATED with nresp %d \n",nr); + exr = extrapolate_RICHResponse(p, r); + if(exr!=null) nexr++; } // ATT: define the response tratment in special cases - if(nresp==0){if(debugMode>=1)System.out.format("No RICH intersection for particle %8.2f \n",theta*RAD); continue;} - if(nresp>1){if(debugMode>=1)System.out.format("Too many RICH responses for particle \n"); continue;} + if(nexr==0){if(debugMode>=1)System.out.format("No RICH intersection for particle with nresp %d and theta %8.2f \n",nr,theta*RAD); continue;} + if(nr==1)Match_chi2 = 2*exr.getMatchedDistance()/tool.get_Constants().RICH_HITMATCH_RMS; - // ATT: time taken at the RICH matching point - double CLAStime = richevent.get_EventTime() + r.getPath()/CLASbeta/(PhysicsConstants.speedOfLight()); + // ATT: time taken at the RICH extrapolated point + double CLAStime = richevent.get_EventTime() + exr.getPath()/CLASbeta/(PhysicsConstants.speedOfLight()); //double CLAStime = richevent.get_EventTime() + p.getPathLength()/CLASbeta/(PhysicsConstants.speedOfLight()); - if(debugMode>=1) { - System.out.format(" --> response %4d hit %s path %7.2f --> clas %8.2f vs rich %8.2f time\n \n",r.getHitIndex(), - tool.toString(r.getPosition()), r.getPath(), CLAStime, r.getTime()); - } + if(debugMode>=1)System.out.format(" --> intersec %4d hit %s path %7.2f --> time clas %7.2f vs rich %8.2f chi2 %7.2f \n \n",RICHiclu, + tool.toString(exr.getPosition()), exr.getPath(), CLAStime, RICHtime, Match_chi2); - RICHParticle richhadron = new RICHParticle(hindex, p.getTrackStatus(), r.getHitIndex(), p.vector().mag(), CLASpid, tool); + RICHParticle richhadron = new RICHParticle(hindex, p.getTrackStatus(), RICHiclu, p.vector().mag(), CLASpid, tool); richhadron.traced.set_time((float) CLAStime); - richhadron.set_meas_time(r.getTime()); - if(!richhadron.set_points(p.getLastCross().origin(), p.getLastCross().end(), r.getPosition(), r.getStatus(), tool) ){ + richhadron.traced.set_machi2(Match_chi2); + richhadron.set_meas_time(exr.getTime()); + if(!richhadron.set_points(p.getLastCross().origin(), p.getLastCross().end(), exr.getPosition(), exr.getStatus(), tool) ){ if(debugMode>=1)System.out.println(" ERROR: no MAPMT interesection found for hadron \n"); continue; } @@ -518,7 +536,7 @@ public boolean find_Hadrons() { if(debugMode>=1){ System.out.format(" ------------------- \n"); System.out.format(" Hadron %4d id %4d from part %4d and clu %4d CLAS eve %7d pid %5d \n ", hindex, richhadron.get_id(), - p.getTrackStatus(), r.getHitIndex(), richevent.get_EventID(), CLASpid); + p.getTrackStatus(), RICHiclu, richevent.get_EventID(), CLASpid); System.out.format(" ------------------- \n"); richhadron.show(); @@ -590,9 +608,15 @@ public boolean analyze_Cherenkovs() { if(tool.get_Constants().DO_ANALYTIC==1){ richevent.analyze_Photons(); + richevent.select_Photons(tool.get_Constants(), 0); for(RICHParticle richhadron : richevent.get_Hadrons()){ - richevent.get_pid(richhadron,0); + if (richhadron.get_Status()==1){ + richevent.get_ChMean(richhadron,0); + richevent.get_pid(richhadron,0); + }else{ + if(debugMode>=1)System.out.format(" Hadron pointing to mirror, skip analytic analysis \n"); + } } } @@ -612,23 +636,23 @@ public boolean reco_Cherenkovs() { int trials = tool.get_Constants().THROW_PHOTON_NUMBER; if(tool.get_Constants().THROW_ELECTRONS==1){ - double chel = richhadron.get_changle(0); + double chel = richhadron.get_changle(0,0); if(chel>0)richevent.throw_Photons(richhadron, trials, chel, 5, tool); } if(tool.get_Constants().THROW_PIONS==1){ - double chpi = richhadron.get_changle(1); + double chpi = richhadron.get_changle(1,0); if(chpi>0)richevent.throw_Photons(richhadron, trials, chpi, 1, tool); } if(tool.get_Constants().THROW_KAONS==1){ - double chk = richhadron.get_changle(2); + double chk = richhadron.get_changle(2,0); if(chk>0)richevent.throw_Photons(richhadron, trials, chk, 2, tool); } if(tool.get_Constants().THROW_PROTONS==1){ - double chpr = richhadron.get_changle(3); + double chpr = richhadron.get_changle(3,0); if(chpr>0)richevent.throw_Photons(richhadron, trials, chpr, 3, tool); } @@ -640,8 +664,10 @@ public boolean reco_Cherenkovs() { richevent.associate_Throws(tool); richevent.trace_Photons(tool); + richevent.select_Photons(tool.get_Constants(), 1); for(RICHParticle richhadron : richevent.get_Hadrons()){ + richevent.get_ChMean(richhadron,1); richevent.get_pid(richhadron,1); } @@ -652,32 +678,53 @@ public boolean reco_Cherenkovs() { // ---------------- - public DetectorResponse extrapolate_RICHResponse(DetectorParticle p){ + public DetectorResponse extrapolate_RICHResponse(DetectorParticle p, DetectorResponse r){ // ---------------- int debugMode = 0; + int imir=0; - DetectorResponse r = new DetectorResponse(4, 18, 1); + DetectorResponse exr = new DetectorResponse(4, 18, 1); - Vector3d extra = tool.find_intersection_UpperHalf_RICH( p.getLastCross()); + Point3D extra = tool.toPoint3D( tool.find_intersection_MAPMT( p.getLastCross()) ); if(extra==null){ - extra = tool.find_intersection_MAPMT( p.getLastCross()); + imir=1; + extra = tool.toPoint3D( tool.find_intersection_UpperHalf_RICH( p.getLastCross()) ); } if(extra==null) return null; - double dist = extra.distance( tool.toVector3d(p.getLastCross().origin()) ); + double extrapath = extra.distance( p.getLastCross().origin() ); + + Point3D rpos = new Point3D(0.0, 0.0, 0.0); + Point3D rmatch = new Point3D(0.0, 0.0, 0.0); + if(r!=null){ + + rpos = r.getPosition().toPoint3D(); + Line3D lmatch = new Line3D(rpos, extra); + rmatch = lmatch.midpoint(); + exr.setPosition( rpos.x(), rpos.y(), rpos.z() ); + exr.setMatchPosition( rmatch.x(), rmatch.y(), rmatch.z()); + exr.setStatus(1); + + }else{ + + exr.setPosition( extra.x(), extra.y(), extra.z() ); + exr.setMatchPosition( extra.x(), extra.y(), extra.z()); + exr.setStatus(0); - r.setPosition(extra.x, extra.y, extra.z); - r.setPath(p.getPathLength()+dist); - r.setStatus(0); + } + exr.setPath(p.getPathLength()+extrapath); int CLASpid = p.getPid(); if(CLASpid==0)CLASpid = 211; double CLASbeta = p.getTheoryBeta(CLASpid); - r.setTime( richevent.get_EventTime() + r.getPath()/CLASbeta/(PhysicsConstants.speedOfLight()) ); + exr.setTime( richevent.get_EventTime() + exr.getPath()/CLASbeta/(PhysicsConstants.speedOfLight()) ); + + if(debugMode>0)System.out.format("extrapolate_RICHResponse: %d %d ex %s r %s mach %s L %7.2f (%7.2f + %7.2f) T %7.2f \n",exr.getStatus(),imir,extra.toStringBrief(2), + rpos.toStringBrief(2),rmatch.toStringBrief(2),exr.getPath(),p.getPathLength(),extrapath,exr.getTime()); - return r; + return exr; } // ---------------- diff --git a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHLayer.java b/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHLayer.java index 9bd228a3f5..5d9a9c7f0d 100644 --- a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHLayer.java +++ b/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHLayer.java @@ -9,6 +9,7 @@ import org.jlab.geom.prim.Point3D; import org.jlab.geom.prim.Line3D; import org.jlab.geom.prim.Vector3D; +import org.jlab.geom.prim.Plane3D; import eu.mihosoft.vrl.v3d.Vertex; import eu.mihosoft.vrl.v3d.Vector3d; @@ -228,6 +229,43 @@ public Sphere3D get_TrackingSphere(int ico) { public Vector3D get_LayerCSGBary(){ return get_CompoCSGBary(-1); } //------------------------------ + //------------------------------ + public Plane3D get_TrajPlane(){ + //------------------------------ + + int debugMode = 0; + + double toIP = -1.; + if(get_Name().equals("mapmts")) toIP=1.; + + Point3D pos = toPoint3D( get_SurfBary(-1, vinside.multiply(toIP)) ); + Vector3D ver = get_LayerNormal(vinside.multiply(toIP) ); + Plane3D plane = new Plane3D(pos, ver); + + if(debugMode>=1) { + System.out.format("get_TrajPlane %d %s to IP %7.2f %s\n",id,name,toIP,vinside.multiply(toIP).toStringBrief(2)); + System.out.format("get_TrajPlane %s %s \n",pos.toStringBrief(2), ver.toStringBrief(2)); + plane.show(); + } + return plane; + + } + + //------------------------------ + public Vector3D get_CompoBary(int icompo){ + //------------------------------ + + int debugMode = 0; + + Vector3D bary = get_SurfBary(icompo, vinside); + Vector3D sbary = get_SurfBary(icompo, vinside.multiply(-1.)); + + if(debugMode>0)System.out.format("%s %s \n",bary.toStringBrief(2), sbary.toStringBrief(2)); + return (bary.add(sbary)).multiply(0.5); + + } + + //------------------------------ public Vector3D get_CompoCSGBary(int icompo){ //------------------------------ @@ -388,6 +426,47 @@ public Vector3D get_SurfBary(int icompo, Vector3D vers){ return null; } + + //------------------------------ + public int get_Quadrant(int Nqua, int icompo, Point3D point){ + //------------------------------ + + /* + * Look for the quadrant of aerogel tile + */ + int debugMode = 0; + + int Nqua2 = (int) Math.pow(Nqua,2); + + if(debugMode>=1)System.out.format(" Get %d quadrant for compo %d point %s\n", Nqua2,icompo,point.toStringBrief(2)); + + Shape3D surf = get_TrackingSurf(icompo); + Vector3D vers = new Vector3D(vinside.multiply(-1.)); + Point3D bary = toPoint3D(get_SurfBary(icompo, vers)); + + Point3D vtx = null; + for(Point3D v: select_Vertexes(surf, vers)){ + if( (v.y()-bary.y()>0) && (v.x()-bary.x()>0) ) vtx = v; + if(debugMode>=1)System.out.format(" --> tets %s \n",v.toStringBrief(2)); + } + + int iqua = -1; + if(vtx!=null){ + if(debugMode>=1)System.out.format(" vtx choice %s \n", vtx.toStringBrief(2)); + double dx = (vtx.x()-point.x())/20*Nqua; + double dy = (vtx.y()-point.y())/20*Nqua; + int idx = (int) dx; + int idy = (int) dy; + iqua = idy*Nqua+idx; + if(debugMode>=1)System.out.format("Calc idx %7.2f %d idy %7.2f %d --> %d \n", dx,idx, dy,idy, iqua); + } + + return iqua; + + } + + + //------------------------------ public boolean into_Layer(Line3D ray, int icompo, int ifa) { //------------------------------ @@ -452,7 +531,7 @@ public RICHIntersection find_Intersection(Line3D ray, int ico, int exit, int pos //ATT:aggiungere min path int debugMode = 0; - if(ico<-1 || ico>=this.size()) return null; + if(ico<-2 || ico>=this.size()) return null; boolean global = true; int ilay = this.get_id(); @@ -825,6 +904,10 @@ public ArrayList merge_CompoList() { public Point3D toPoint3D(Vertex ver) {return new Point3D(ver.pos.x, ver.pos.y, ver.pos.z); } //------------------------------ + //------------------------------ + public Point3D toPoint3D(Vector3D ver) {return new Point3D(ver.x(), ver.y(), ver.z()); } + //------------------------------ + //------------------------------ public Vector3d toVector3d(Vertex ver) {return new Vector3d(ver.pos.x, ver.pos.y, ver.pos.z); } //------------------------------ diff --git a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHParticle.java b/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHParticle.java index 813080bb16..88d3902077 100644 --- a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHParticle.java +++ b/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHParticle.java @@ -33,20 +33,25 @@ public class RICHParticle { private int parent_index = -999; private int hit_index = -999; private int type = 0; + private int recofound = -1; private int status = -1; private int CLASpid = -999; private int RICHpid = -999; private double momentum = 0; - private double[] ChAngle = new double[4]; + private double[][] ChAngle = new double[4][3]; + private double[] sChAngle = new double[3]; public Vector3d meas_hit = null; private double meas_time = 0.0; public Point3D lab_origin = null; public Vector3d lab_emission = null; - public int ilay_emission = 0; - public int ico_emission = 0; + public int ilay_emission = -1; + public int ico_emission = -1; + public int qua_emission = -1; public float refi_emission = 0; + public double chele_emission[] = {0.0, 0.0, 0.0}; + public double schele_emission[] = {0.0, 0.0, 0.0}; public double lab_phi = 0.0; public double lab_theta = 0.0; @@ -96,8 +101,6 @@ public RICHParticle(int id, int parent_index, int hit_index, double mom, int CLA recopar = tool.get_Constants(); - //if(CLASpid!=22)set_changle(); - } @@ -134,15 +137,35 @@ private void set_changle() { // define only one Cherenkov angle depending on the pid hypothesis int debugMode = 0; - for(int k=0 ; k<4; k++) ChAngle[k] = 0.0; - ChAngle[0] = expectedChAngle(11); // expected angle for electron - ChAngle[1] = expectedChAngle(211); // pion - ChAngle[2] = expectedChAngle(321); // kaon - ChAngle[3] = expectedChAngle(2212); // proton + for(int j=0; j<3; j++) { + for(int k=0 ; k<4; k++) ChAngle[k][j] = 0.0; + sChAngle[j] = 0.0; + } + + for (int iref=0; iref<3; iref++){ + if(recopar.CHANGLES_FROM_ELECTRON==1){ + ChAngle[0][iref] = calibrated_ChAngle(11, iref); // expected angle for electron + ChAngle[1][iref] = calibrated_ChAngle(211, iref); // pion + ChAngle[2][iref] = calibrated_ChAngle(321, iref); // kaon + ChAngle[3][iref] = calibrated_ChAngle(2212, iref); // proton + + sChAngle[iref] = calibrated_sChAngle(iref); // expected angle for electron + + }else{ + + ChAngle[0][iref] = nominal_ChAngle(11); // expected angle for electron + ChAngle[1][iref] = nominal_ChAngle(211); // pion + ChAngle[2][iref] = nominal_ChAngle(321); // kaon + ChAngle[3][iref] = nominal_ChAngle(2212); // proton + + sChAngle[iref] = nominal_sChAngle(); // expected angle for electron + } + } if(debugMode>=1) { - System.out.format(" Create RICH particle mom %8.2f Ch %8.2f %8.2f %8.2f %8.2f \n",momentum,ChAngle[0]*MRAD,ChAngle[1]*MRAD,ChAngle[2]*MRAD,ChAngle[3]*MRAD); - System.out.format(" --> Ch angle limits %8.2f %8.2f \n",minChAngle()*MRAD,maxChAngle()*MRAD); + System.out.format(" Create RICH particle mom %8.2f \n",momentum); + for(int ir=0; ir<3; ir++) System.out.format(" --> Dir pr %7.2f k %7.2f pi %7.2f e %7.2f --> limi %7.2f %7.2f res %7.2f\n", + ChAngle[3][ir]*MRAD,ChAngle[2][ir]*MRAD,ChAngle[1][ir]*MRAD,ChAngle[0][ir]*MRAD,minChAngle(0)*MRAD,maxChAngle(0)*MRAD,sChAngle[0]*MRAD); } } @@ -163,6 +186,10 @@ private void set_changle() { public int get_type() {return type;} // ------------- + // ------------- + public int get_recofound() {return recofound;} + // ------------- + // ------------- public int get_Status() {return status;} // ------------- @@ -184,9 +211,12 @@ private void set_changle() { // ------------- // ------------- - public double get_changle(int i) { return ChAngle[i]; } + public double get_changle(int ipar, int irefle) { return ChAngle[ipar][irefle]; } // ------------- + // ------------- + public double get_schangle(int irefle) { return sChAngle[irefle]; } + // ------------ // ------------- public double get_beta(int pid) { @@ -207,26 +237,33 @@ public double get_beta(int pid) { } // ---------------- - public double maxChAngle() { + public double maxChAngle(int irefle) { // ---------------- - for(int k=0 ; k<4; k++) if(ChAngle[k]>0)return ChAngle[k] + 3*recopar.RICH_DIRECT_RMS; + for(int k=0 ; k<4; k++) if(ChAngle[k][irefle]>0)return ChAngle[k][irefle] + 3*sChAngle[irefle]; return 0.0; } // ---------------- - public double minChAngle() { + public double minChAngle(int irefle) { // ---------------- // calculate the minimum Cherenlov angle compatible with the momentum - for(int k=3 ; k>=0; k--) if(ChAngle[k]>0)return Math.max(recopar.RICH_MIN_CHANGLE, ChAngle[k] - 3*recopar.RICH_DIRECT_RMS); + for(int k=3 ; k>=0; k--) if(ChAngle[k][irefle]>0) return Math.max(recopar.RICH_MIN_CHANGLE, ChAngle[k][irefle] - 3*sChAngle[irefle]); return 0.0; } // ---------------- - public double expectedChAngle(int pid){ + public double nominal_sChAngle(){ + // ---------------- + + return recopar.RICH_DIRECT_RMS; + } + + // ---------------- + public double nominal_ChAngle(int pid){ // ---------------- int debugMode = 0; @@ -238,6 +275,29 @@ public double expectedChAngle(int pid){ return 0.0; } + // ---------------- + public double calibrated_sChAngle(int irefle){ + // ---------------- + + return schele_emission[irefle]; + } + + // ---------------- + public double calibrated_ChAngle(int pid, int irefle){ + // ---------------- + + int debugMode = 0; + double arg = 0.0; + double beta = get_beta(pid); + double cose = chele_emission[irefle]; + + if(beta>0) arg = 1.0/beta*cose; + if(debugMode>=1) System.out.format(" Expected Ch Angle %8.4f beta %8.4f n %7.3f arg %8.4f\n",get_mass(pid),beta,refi_emission, Math.acos(arg)*MRAD); + if(arg>0.0 && arg<1.0) return Math.acos(arg); + return 0.0; + } + + // ---------------- public void set_id(int id) { this.id=id;} // ---------------- @@ -254,6 +314,10 @@ public double expectedChAngle(int pid){ public void set_type(int type) { this.type=type; } // ---------------- + // ---------------- + public void set_recofound(int recof) { this.recofound=recof; } + // ---------------- + // ---------------- public void set_Status(int sta) { this.status = sta; } // ---------------- @@ -419,18 +483,23 @@ public boolean find_aerogel_points(RICHTool tool){ aero_entrance = tool.toVector3d(entrance.get_pos()); aero_exit = tool.toVector3d(exit.get_pos()); aero_normal = tool.toVector3d(exit.get_normal()); + /* * Take point at 3/4 of path inside aerrogel */ Vector3d amiddle = aero_exit.midpoint(aero_entrance); aero_middle = aero_exit.midpoint(amiddle); lab_emission = aero_middle; - // take the downstream aerogel tile as the one with largest number of phtoons and average emisison point + // take the downstream aerogel tile as the one with largest number of phtoons and average emission point ilay_emission = exit.get_layer(); ico_emission = exit.get_component(); if(debugMode>=1)System.out.format(" AERO lay %3d ico %3d \n",ilay_emission,ico_emission); refi_emission = tool.get_Component(ilay_emission,ico_emission).get_index(); + qua_emission = tool.get_Layer(ilay_emission).get_Quadrant(3, ico_emission, entrance.get_pos()); + for(int iref=0; iref<3; iref++)chele_emission[iref] = tool.get_ChElectron(ilay_emission, ico_emission, qua_emission, iref); + for(int iref=0; iref<3; iref++)schele_emission[iref] = tool.get_sChElectron(ilay_emission, ico_emission, qua_emission, iref); + set_changle(); RotAxis = aero_normal.cross(Vector3d.Z_ONE).normalized(); @@ -623,7 +692,7 @@ public void find_EtaC_raytrace_steps(RICHParticle hadron, RICHTool tool) { double EtaCmin = 0.0; if(Math.abs(Cos_EtaC)<1.)EtaCmin = Math.acos(Cos_EtaC); int ntrials = 0; - while (dist > recopar.RICH_DIRECT_RMS*100/2. && ntrials<10){ + while (dist > nominal_sChAngle()*100/2. && ntrials<20){ if(debugMode>=1){ System.out.format(" Attempt %d with the %7.1f (%7.2f) phi %7.2f EtaC %7.2f\n",ntrials, the_min*MRAD, the_min*RAD, phi_min*RAD, EtaCmin*MRAD); @@ -634,16 +703,19 @@ public void find_EtaC_raytrace_steps(RICHParticle hadron, RICHTool tool) { int nthe = 0; for (nthe=1; nthe<=4; nthe++){ - double theta_dthe = the_min + recopar.RICH_DIRECT_RMS/nthe; + double theta_dthe = the_min + nominal_sChAngle()/nthe; Vector3d vpho_dthe = new Vector3d( Math.sin(theta_dthe)*Math.cos(phi_min), Math.sin(theta_dthe)*Math.sin(phi_min), Math.cos(theta_dthe)); - ArrayList rays_dthe = tool.RayTrace(lab_emission, ilay_emission, ico_emission, vpho_dthe); + double naero = 1/(hadron.get_beta(get_CLASpid())*(Math.sin(Theta_P)* Math.sin(theta_dthe)*Math.cos(phi_min-Phi_P)+Math.cos(Theta_P)*Math.cos(theta_dthe))); + + ArrayList rays_dthe = tool.RayTrace(lab_emission, ilay_emission, ico_emission, vpho_dthe, naero); + //ArrayList rays_dthe = tool.RayTrace(lab_emission, ilay_emission, ico_emission, vpho_dthe); if(rays_dthe!=null){ int nrefle_dthe = get_rayrefle(rays_dthe); if(debugMode>=1) System.out.format(" test %2d the %7.1f nrfl %2d vs %2d ",nthe, theta_dthe*MRAD, nrefle_dthe, nrefle_min); if(nrefle_dthe==nrefle_min){ Vector3d pmt_dthe = tool.toVector3d(rays_dthe.get(rays_dthe.size()-1).end()); Vector3d vers_dthe = pmt_dthe.minus(pmt_min); - dthe = (vec_dist.x*vers_dthe.x + vec_dist.y*vers_dthe.y) / (vers_dthe.x*vers_dthe.x + vers_dthe.y*vers_dthe.y) * recopar.RICH_DIRECT_RMS; + dthe = (vec_dist.x*vers_dthe.x + vec_dist.y*vers_dthe.y) / (vers_dthe.x*vers_dthe.x + vers_dthe.y*vers_dthe.y) * nominal_sChAngle(); if(debugMode>=1) System.out.format(" --> dthe pos %7.2f %7.2f %7.2f delta %7.1f (%8.2f %8.2f) \n", pmt_dthe.x, pmt_dthe.y, pmt_dthe.z, dthe*MRAD, vers_dthe.x, vers_dthe.y); break; @@ -654,16 +726,19 @@ public void find_EtaC_raytrace_steps(RICHParticle hadron, RICHTool tool) { } for (int nphi=1; nphi<=4; nphi++){ - double phi_dphi = phi_min + recopar.RICH_DIRECT_RMS/nphi; + double phi_dphi = phi_min + nominal_sChAngle()/nphi; Vector3d vpho_dphi = new Vector3d( Math.sin(the_min)*Math.cos(phi_dphi), Math.sin(the_min)*Math.sin(phi_dphi), Math.cos(the_min)); - ArrayList rays_dphi = tool.RayTrace(lab_emission, ilay_emission, ico_emission, vpho_dphi); + double naero = 1/(hadron.get_beta(get_CLASpid())*(Math.sin(Theta_P)* Math.sin(the_min)*Math.cos(phi_dphi-Phi_P)+Math.cos(Theta_P)*Math.cos(the_min))); + + ArrayList rays_dphi = tool.RayTrace(lab_emission, ilay_emission, ico_emission, vpho_dphi, naero); + //ArrayList rays_dphi = tool.RayTrace(lab_emission, ilay_emission, ico_emission, vpho_dphi); if(rays_dphi!=null){ int nrefle_dphi = get_rayrefle(rays_dphi); if(debugMode>=1) System.out.format(" test %2d phi %7.2f nrfl %2d vs %2d ",nphi, phi_dphi*RAD, nrefle_dphi, nrefle_min); if(nrefle_dphi==nrefle_min){ Vector3d pmt_dphi = tool.toVector3d(rays_dphi.get(rays_dphi.size()-1).end()); Vector3d vers_dphi = (pmt_dphi.minus(pmt_min)); - dphi = (vec_dist.x*vers_dphi.x + vec_dist.y*vers_dphi.y) / (vers_dphi.x*vers_dphi.x + vers_dphi.y*vers_dphi.y) * recopar.RICH_DIRECT_RMS; + dphi = (vec_dist.x*vers_dphi.x + vec_dist.y*vers_dphi.y) / (vers_dphi.x*vers_dphi.x + vers_dphi.y*vers_dphi.y) * nominal_sChAngle(); if(debugMode>=1) System.out.format(" --> dphi pos %7.2f %7.2f %7.2f delta %7.2f (%8.2f %8.2f) \n", pmt_dphi.x, pmt_dphi.y, pmt_dphi.z, dphi*RAD, vers_dphi.x, vers_dphi.y); break; @@ -681,7 +756,10 @@ public void find_EtaC_raytrace_steps(RICHParticle hadron, RICHTool tool) { if(debugMode>=1) System.out.format(" do step nn %3d the %7.1f phi %7.2f (from %7.1f %7.2f) \n",nn,the_new*MRAD,phi_new*RAD,the_min*MRAD,phi_min*RAD); Vector3d vpho_min = new Vector3d( Math.sin(the_new)*Math.cos(phi_new), Math.sin(the_new)*Math.sin(phi_new), Math.cos(the_new)); - rays_min = tool.RayTrace(lab_emission, ilay_emission, ico_emission, vpho_min); + double naero = 1/(hadron.get_beta(get_CLASpid())*(Math.sin(Theta_P)* Math.sin(the_new)*Math.cos(phi_new-Phi_P)+Math.cos(Theta_P)*Math.cos(the_new))); + + rays_min = tool.RayTrace(lab_emission, ilay_emission, ico_emission, vpho_min, naero); + //rays_min = tool.RayTrace(lab_emission, ilay_emission, ico_emission, vpho_min); if(rays_min!=null){ int nrefle_new = get_rayrefle(rays_min); if(debugMode>=1) System.out.format(" test %2d the %7.1f phi %7.2f nrfl %2d vs %2d ",nn, the_new*MRAD, phi_new*RAD, nrefle_new, nrefle_min); @@ -716,7 +794,7 @@ public void find_EtaC_raytrace_steps(RICHParticle hadron, RICHTool tool) { ntrials++; } - if(dist < recopar.RICH_DIRECT_RMS*100.){ + if(dist < nominal_sChAngle()*100.){ if(debugMode>=1){ System.out.format(" --> Matched value found using %d calls: result is %8.2f %8.2f matched hit %7.2f %7.2f %7.2f dist %7.3f \n", @@ -872,14 +950,18 @@ public double pid_probability(RICHParticle hadron, int pid, int recotype) { // angle probability double mean = 0.0; - if(Math.abs(pid)==11)mean=hadron.get_changle(0); - if(Math.abs(pid)==211)mean=hadron.get_changle(1); - if(Math.abs(pid)==321)mean=hadron.get_changle(2); - if(Math.abs(pid)==2212)mean=hadron.get_changle(3); + int irefle = reco.get_RefleType(); + if(irefle>=0 && irefle<=2){ + if(Math.abs(pid)==11)mean=hadron.get_changle(0, irefle); + if(Math.abs(pid)==211)mean=hadron.get_changle(1, irefle); + if(Math.abs(pid)==321)mean=hadron.get_changle(2, irefle); + if(Math.abs(pid)==2212)mean=hadron.get_changle(3, irefle); + } + + double sigma = hadron.get_schangle(irefle); double func = 0.0; double dfunc = 1e-3; - double sigma = recopar.RICH_DIRECT_RMS; if(mean>0){ func = Math.exp((-0.5)*Math.pow((reco.get_EtaC() - mean)/sigma, 2) )/ (sigma*Math.sqrt(2* Math.PI)); @@ -933,8 +1015,13 @@ public void show() { Vector3d ori_impact = meas_hit.minus(reference); System.out.format(" PART info pid %d mass %8.5f mom %g \n", CLASpid, get_mass(CLASpid), momentum); - System.out.format(" ChAngle (mrad) %8.2f %8.2f %8.2f %8.2f limits %8.2f %8.2f \n", ChAngle[3]*MRAD, ChAngle[2]*MRAD, ChAngle[1]*MRAD, ChAngle[0]*MRAD, - minChAngle()*MRAD, maxChAngle()*MRAD); + + System.out.format(" ChAngle dir (mrad) %8.2f %8.2f %8.2f %8.2f limits %8.2f %8.2f \n", ChAngle[3][0]*MRAD, ChAngle[2][0]*MRAD, ChAngle[1][0]*MRAD, ChAngle[0][0]*MRAD, + minChAngle(0)*MRAD, maxChAngle(0)*MRAD); + System.out.format(" ChAngle lat (mrad) %8.2f %8.2f %8.2f %8.2f limits %8.2f %8.2f \n", ChAngle[3][1]*MRAD, ChAngle[2][1]*MRAD, ChAngle[1][1]*MRAD, ChAngle[0][1]*MRAD, + minChAngle(1)*MRAD, maxChAngle(1)*MRAD); + System.out.format(" ChAngle spe (mrad) %8.2f %8.2f %8.2f %8.2f limits %8.2f %8.2f \n", ChAngle[3][2]*MRAD, ChAngle[2][2]*MRAD, ChAngle[1][2]*MRAD, ChAngle[0][2]*MRAD, + minChAngle(2)*MRAD, maxChAngle(2)*MRAD); System.out.println(" "); System.out.format(" TRACK origin %8.1f %8.1f %8.1f \n", lab_origin.x(), lab_origin.y(), lab_origin.z()); System.out.format(" direction %8.3f %8.3f %8.3f theta %8.2f phi %8.2f \n", lab_direction.x, lab_direction.y, lab_direction.z, lab_theta*RAD, lab_phi*RAD); diff --git a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHSolution.java b/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHSolution.java index ae91ccff37..0c8c0c2e07 100644 --- a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHSolution.java +++ b/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHSolution.java @@ -28,6 +28,7 @@ public RICHSolution(int type) { } private int type; // Solution type + private int OK = -1; // Solution type private float EtaC=0; // Cherenkov angle private float aeron=0; // Aerogel refrative index @@ -37,6 +38,7 @@ public RICHSolution(int type) { private int nrefle=0; // Number of photon reflections private int nrefra=0; // Number of photon refractions private float time=0; // Transit time within the RICH (solution dependent) + private double machi2 = 0.0; // chi2 of the hit-trajectory matching private Vector3d hit = new Vector3d(0,0,0);; // Impact point of photon on the PMT private ArrayList raytracks = new ArrayList(); // Detailed path of the photon @@ -47,6 +49,16 @@ public RICHSolution(int type) { private double prprob = 0.0; // Cherenkov probability for proton private double bgprob = 0.0; // Cherenkov probability for background + private int ndir = 0; // Number of direct photons + private double chdir = 0.0; // Mean Cherenkov angle for direct photons + private double sdir = 0.0; // RMS Cherenkov angle for direct photons + private int nlat = 0; // Number of photons reflected by lateral mirrors + private double chlat = 0.0; // Mean Cherenkov angle for photons reflected by lateral mirrors + private double slat = 0.0; // RMS Cherenkov angle for photons reflected by lateral mirrors + private int nspe = 0; // Number of photons reflected by ssperical mirrors + private double chspe = 0.0; // Mean Cherenkov angle for photons reflected by ssperical mirrors + private double sspe = 0.0; // RMS Cherenkov angle for photons reflected by ssperical mirrors + private double bestprob = 0.0; // best Cherenkov probability for hadron ID private double secprob = 0.0; // second best Cherenkov probability for hadron ID private int bestH = 0; // best Cherenkov probability for hadron ID @@ -57,6 +69,10 @@ public RICHSolution(int type) { public int get_type() { return type; } // ---------------- + // ---------------- + public int get_OK() { return OK; } + // ---------------- + // ---------------- public float get_EtaC() { return EtaC; } // ---------------- @@ -81,6 +97,10 @@ public RICHSolution(int type) { public float get_time() { return time; } // ---------------- + // ---------------- + public double get_machi2() { return machi2; } + // ---------------- + // ---------------- public float get_raypath() { // ---------------- @@ -108,11 +128,29 @@ public float get_raytime() { } // ---------------- - public int get_firstrefle() { + public int get_FirstRefle() { // ---------------- if(raytracks.size()>2) return raytracks.get(2).get_type(); - return -1; + return 0; + + } + + // ---------------- + public int get_RefleType() { + // ---------------- + + int ifirst = get_FirstRefle(); + int ilay = (int) (ifirst-10000)/100; + if(ifirst<10000){ + return 0; + }else{ + if(ilay==11){ + return 2; + }else{ + return 1; + } + } } @@ -171,27 +209,63 @@ public int get_rayrefra() { // ---------------- // ---------------- - public double get_elprob() { return elprob; } + public double get_ElProb() { return elprob; } + // ---------------- + + // ---------------- + public double get_PiProb() { return piprob; } + // ---------------- + + // ---------------- + public double get_KProb() { return kprob; } + // ---------------- + + // ---------------- + public double get_PrProb() { return prprob; } + // ---------------- + + // ---------------- + public double get_BgProb() { return bgprob; } + // ---------------- + + // ---------------- + public int get_Ndir() { return ndir; } + // ---------------- + + // ---------------- + public double get_Chdir() { return chdir; } + // ---------------- + + // ---------------- + public double get_RMSdir() { return sdir; } + // ---------------- + + // ---------------- + public int get_Nlat() { return nlat; } + // ---------------- + + // ---------------- + public double get_Chlat() { return chlat; } // ---------------- // ---------------- - public double get_piprob() { return piprob; } + public double get_RMSlat() { return slat; } // ---------------- // ---------------- - public double get_kprob() { return kprob; } + public int get_Nspe() { return nspe; } // ---------------- // ---------------- - public double get_prprob() { return prprob; } + public double get_Chspe() { return chspe; } // ---------------- // ---------------- - public double get_bgprob() { return bgprob; } + public double get_RMSspe() { return sspe; } // ---------------- // ---------------- - public int get_bestH() { return bestH; } + public int get_BestH() { return bestH; } // ---------------- // ---------------- @@ -199,7 +273,7 @@ public int get_rayrefra() { // ---------------- // ---------------- - public double get_bestprob() { return bestprob; } + public double get_Bestprob() { return bestprob; } // ---------------- // ---------------- @@ -214,11 +288,11 @@ public int get_rayrefra() { public double assign_PID(double lh_el, double lh_pi, double lh_k, double lh_pr, double lh_bg) { // ---------------- - this.set_elprob(lh_el); - this.set_piprob(lh_pi); - this.set_kprob(lh_k); - this.set_prprob(lh_pr); - this.set_bgprob(lh_bg); + this.set_ElProb(lh_el); + this.set_PiProb(lh_pi); + this.set_KProb(lh_k); + this.set_PrProb(lh_pr); + this.set_BgProb(lh_bg); double likeh[] = {this.piprob, this.kprob, this.prprob}; Arrays.sort(likeh); @@ -241,6 +315,10 @@ public double assign_PID(double lh_el, double lh_pi, double lh_k, double lh_pr, public void set_type(int type) { this.type = type; } // ---------------- + // ---------------- + public void set_OK(int ok) { this.OK = ok; } + // ---------------- + // ---------------- public void set_EtaC(float EtaC) { this.EtaC = EtaC; } // ---------------- @@ -265,6 +343,10 @@ public double assign_PID(double lh_el, double lh_pi, double lh_k, double lh_pr, public void set_time(float time) { this.time = time; } // ---------------- + // ---------------- + public void set_machi2(double machi2) { this.machi2 = machi2; } + // ---------------- + // ---------------- public void set_nrefle(int nrefle) { this.nrefle = nrefle; } // ---------------- @@ -302,23 +384,59 @@ public void set_raytracks(ArrayList rays){ // ---------------- // ---------------- - public void set_elprob(double elprob) { this.elprob = elprob; } + public void set_ElProb(double elprob) { this.elprob = elprob; } + // ---------------- + + // ---------------- + public void set_PiProb(double piprob) { this.piprob = piprob; } + // ---------------- + + // ---------------- + public void set_KProb(double kprob) { this.kprob = kprob; } + // ---------------- + + // ---------------- + public void set_PrProb(double prprob) { this.prprob = prprob; } + // ---------------- + + // ---------------- + public void set_BgProb(double bgprob) { this.bgprob = bgprob; } + // ---------------- + + // ---------------- + public void set_Ndir(int ndir) { this.ndir= ndir; } + // ---------------- + + // ---------------- + public void set_Chdir(double chdir) { this.chdir= chdir; } + // ---------------- + + // ---------------- + public void set_RMSdir(double sdir) { this.sdir= sdir; } + // ---------------- + + // ---------------- + public void set_Nlat(int nlat) { this.nlat= nlat; } + // ---------------- + + // ---------------- + public void set_Chlat(double chlat) { this.chlat= chlat; } // ---------------- // ---------------- - public void set_piprob(double piprob) { this.piprob = piprob; } + public void set_RMSlat(double slat) { this.slat= slat; } // ---------------- // ---------------- - public void set_kprob(double kprob) { this.kprob = kprob; } + public void set_Nspe(int nspe) { this.nspe= nspe; } // ---------------- // ---------------- - public void set_prprob(double prprob) { this.prprob = prprob; } + public void set_Chspe(double chspe) { this.chspe= chspe; } // ---------------- // ---------------- - public void set_bgprob(double bgprob) { this.bgprob = bgprob; } + public void set_RMSspe(double sspe) { this.sspe= sspe; } // ---------------- // ---------------- @@ -360,7 +478,7 @@ public void showSolution() { // ---------------- System.out.format("SOL type %3d EtaC %8.3f n %6.4f the %7.3f phi %7.3f hit %6.1f %6.1 %6.1f path %6.1f time %6.2f nrfl %2d nfr %2d pel %7.5f pi %7.5g k %7.5g pr %7.5g bg %7.5g \n", get_type(), get_EtaC(), get_aeron(), get_theta(), get_phi(), get_hit().x, get_hit().y, get_hit().z, get_path(), get_time(), get_nrefle(), get_nrefra(), - get_elprob(), get_piprob(), get_kprob(), get_prprob(), get_bgprob()); + get_ElProb(), get_PiProb(), get_KProb(), get_PrProb(), get_BgProb()); } } diff --git a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHTool.java b/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHTool.java index 8ba793ae48..e00d5cbe2f 100644 --- a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHTool.java +++ b/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHTool.java @@ -204,6 +204,12 @@ public void RICHTool(){ private double pmt_timewalk[][] = new double[NPMT][4]; private double aero_refi[][] = new double[4][31]; private double aero_plan[][] = new double[4][31]; + private double aero_chele_dir[][][] = new double[4][31][225]; + private double aero_chele_lat[][][] = new double[4][31][225]; + private double aero_chele_spe[][][] = new double[4][31][225]; + private double aero_schele_dir[][][] = new double[4][31][225]; + private double aero_schele_lat[][][] = new double[4][31][225]; + private double aero_schele_spe[][][] = new double[4][31][225]; private Vector3D rich_survey_angle = new Vector3D(); private Vector3D rich_survey_shift = new Vector3D(); @@ -233,11 +239,21 @@ public void RICHTool(){ private RICHConstants reco_constants = new RICHConstants(); //------------------------------ - public void init_GeoConstants(IndexedTable aeroConstants, IndexedTable misaConstants, IndexedTable paraConstants){ + public void init_GeoConstants(int iflag, IndexedTable aeroConstants, IndexedTable misaConstants, IndexedTable paraConstants){ //------------------------------ + System.out.format(" &&& init_GeoConstants \n"); + // generate the tracking layers (0 = only Aerogel and MaPMT for trajectory, 1 = all) // start processing time init_ProcessTime(); + + // reset alignment constants + for (int ila=0; ila0){ + // global pixel coordinat indexes + init_GlobalPixelGeo(); - // RICH survey - init_Survey(); + // RICH survey + init_Survey(); + } // RICH geometry organized on layers of Shape3D area and RICH components - init_RICHLayers(); + init_RICHLayers(iflag); } @@ -361,7 +378,7 @@ public void init_TimeConstantsCCDB(IndexedTable timewalkConstants, IndexedTable * TIME_WALKs */ - // ATT: time_walk bank definition is wrong + // TODO: time_walk bank definition is wrong for(int ipmt=0; ipmt=1 && reco_constants.RICH_DEBUG>0){ + //if(debugMode>=1 && reco_constants.RICH_DEBUG>0){ //MC + if(debugMode>=1){ System.out.format(" \n"); System.out.format("CCDB RICH PARA DO_MISALIGNMENT %8d \n", reco_constants.DO_MISALIGNMENT); @@ -462,24 +480,18 @@ public void init_GeoConstantsCCDB(IndexedTable paraConstants, IndexedTable aeroC * This comes on top of the RICH survey and global transformation */ - for (int ila=0; ila=1 && reco_constants.RICH_DEBUG>0){ if(layer_misa_shift[ila][ico].mag()>0 || layer_misa_angle[ila][ico].mag()>0){ @@ -619,7 +631,11 @@ public void init_ConstantsTxT(int flag){ float ss = Float.parseFloat(array[5]); float sa = Float.parseFloat(array[6]); + + int inp = Integer.parseInt(array[7]); + float hr = Float.parseFloat(array[8]); + reco_constants.DO_MISALIGNMENT = idc; reco_constants.FORCE_DC_MATCH = imatch; reco_constants.MISA_RICH_REF = iref; @@ -629,6 +645,9 @@ public void init_ConstantsTxT(int flag){ reco_constants.MISA_SHIFT_SCALE = (double) ss ; reco_constants.MISA_ANGLE_SCALE = (double) sa; + reco_constants.THROW_PHOTON_NUMBER = inp; + reco_constants.RICH_DIRECT_RMS = (double) hr / 1000.; + if(debugMode>=1){ System.out.format("TEXT PARA DO_MISALIGNMENT %7d \n", reco_constants.DO_MISALIGNMENT); @@ -640,6 +659,10 @@ public void init_ConstantsTxT(int flag){ System.out.format("TEXT PARA MISA_SHIFT_SCALE %7.3f \n", reco_constants.MISA_SHIFT_SCALE); System.out.format("TEXT PARA MISA_ANGLE_SCALE %7.3f \n", reco_constants.MISA_ANGLE_SCALE); + System.out.format("TEXT PARA THROW_PHOTON_NUMBER %7d \n", reco_constants.THROW_PHOTON_NUMBER); + + System.out.format("TEXT PARA RICH_DIRECT_RMS %7.3f (mrad) \n", reco_constants.RICH_DIRECT_RMS*1000); + } } @@ -659,12 +682,12 @@ public void init_ConstantsTxT(int flag){ * SINGLE COMPONENT MISALIGNMENT * This comes on top of the RICH survey and global transformation */ - for (int ila=0; ila=0)System.out.format("MISA conversion %4d %3d --> %4d %3d \n",lla,cco,ila,ico); // the rotation is assumed to be in the component local ref system - layer_misa_shift[ila][ico] = new Vector3D( dx*sscale, dy*sscale, dz*sscale); - layer_misa_angle[ila][ico] = new Vector3D(thx*ascale, thy*ascale, thz*ascale); + layer_misa_shift[ila][ico].add( new Vector3D( dx*sscale, dy*sscale, dz*sscale)); + layer_misa_angle[ila][ico].add( new Vector3D(thx*ascale, thy*ascale, thz*ascale)); if(debugMode>=0){ if(layer_misa_shift[ila][ico].mag()>0 || layer_misa_angle[ila][ico].mag()>0){ System.out.format("TXT MISA layer %4d ico %3d (%4d %3d) shift %s angle %s \n", ila,ico,lla,cco, - layer_misa_shift[ila][ico].toStringBrief(2), layer_misa_angle[ila][ico].toStringBrief(2)); + layer_misa_shift[ila][ico].toStringBrief(3), layer_misa_angle[ila][ico].toStringBrief(3)); } } @@ -756,6 +779,64 @@ public void init_ConstantsTxT(int flag){ if(debugMode>=1)System.out.format("initConstants: DONE \n"); } + + if(flag==4){ + + /* + * AEROGEL CALIBRATED OPTICS + */ + + String chele_filename = new String("CALIB_DATA/aerogel_chele.txt"); + + try { + + BufferedReader bf = new BufferedReader(new FileReader(chele_filename)); + String currentLine = null; + + while ( (currentLine = bf.readLine()) != null) { + + String[] array = currentLine.split(" "); + int idlay = Integer.parseInt(array[1]); + int iaer = Integer.parseInt(array[2]); + int iqua = Integer.parseInt(array[3]); + + if(debugMode>=1)System.out.format("Read chele for AERO lay %3d compo %3d quadrant %3d", idlay, iaer, iqua); + + int ndir = Integer.parseInt(array[4]); + float chdir = Float.parseFloat(array[5]); + float sdir = Float.parseFloat(array[6]); + + int nlat = Integer.parseInt(array[7]); + float chlat = Float.parseFloat(array[8]); + float slat = Float.parseFloat(array[9]); + + int nspe = Integer.parseInt(array[10]); + float chspe = Float.parseFloat(array[11]); + float sspe = Float.parseFloat(array[12]); + + aero_chele_dir[idlay-201][iaer-1][iqua] = chdir; + aero_chele_lat[idlay-201][iaer-1][iqua] = chlat; + aero_chele_spe[idlay-201][iaer-1][iqua] = chspe; + + aero_schele_dir[idlay-201][iaer-1][iqua] = sdir; + aero_schele_lat[idlay-201][iaer-1][iqua] = slat; + aero_schele_spe[idlay-201][iaer-1][iqua] = sspe; + + //aero_refi[idlay-201][iaer-1] = (float) RICHConstants.RICH_AEROGEL_INDEX; + if(debugMode>=1)System.out.format(" n = %8.5f pla = %8.2f \n", aero_refi[idlay-201][iaer-1], aero_plan[idlay-201][iaer-1]); + + } + + } catch (Exception e) { + + System.err.format("Exception occurred trying to read '%s' \n", chele_filename); + e.printStackTrace(); + } + + if(debugMode>=1)System.out.format("initConstants: DONE \n"); + + } + } @@ -938,7 +1019,7 @@ public void init_Survey(){ } //------------------------------ - public void init_RICHLayers(){ + public void init_RICHLayers(int iflag){ //------------------------------ // Take RICHFactory Layers of Geant4 volumes (for GEMC) and convert in coatjava Layers // of RICH components accounting for optical descriptiors plus basic tracking @@ -980,6 +1061,9 @@ public void init_RICHLayers(){ } RICHLayer layer = new RICHLayer(ilay, slayer, vlayer); + //if(iflag==0 && (ilay>3 && ilay<12)) continue; + if(iflag==1 || (ilay<4 || ilay==12)) { + for (int ico=0; ico=1)System.out.format("add layer %d \n",ilay); opticlayers.add(layer); + } /* - * Generate the basic planes for tracking + * Generate and misalign the basic planes for tracking */ - generate_TrackingPlanes(); + rich_frame = survey_frame.clone(); - /* - * Misalign the basic planes for tracking - */ - if(reco_constants.DO_MISALIGNMENT==1)misalign_TrackingPlanes(); + for (int ilay=0; ilay3 && ilay<12)) continue; + if(debugMode>=1)System.out.format("generate surfaces for layer %d \n",ilay); + + generate_TrackingPlane(ilay); + + if(reco_constants.DO_MISALIGNMENT==1)misalign_TrackingPlane(ilay); + + store_TrackingPlane(ilay); + + } - /* - * Store the composite planes for tracking - */ - store_TrackingPlanes(); - - /* - * Generate Pixel map on the misaligned MAPMT plane - */ + if(iflag>0){ + /* + * Generate Pixel map on the misaligned MAPMT plane + */ + RICHLayer layer = get_Layer("mapmts"); + List compo_list = layer.get_CompoList(); + Shape3D compo_misa = layer.get_TrackingSurf(); + generate_Pixel_Map(layer.get_id(), 0, compo_misa, compo_list); + + if(debugMode>=1)show_Shape3D(compo_misa, null, "CC"); + if(debugMode>=1)show_RICH("Real RICH Geometry", "RR"); + } + + } + + // ---------------- + public void testTraj() { + // ---------------- + + Plane3D pl_mapmt = get_MaPMTforTraj(); + pl_mapmt.show(); + + Point3D pa[] = new Point3D[3]; + for (int ia=0; ia<3; ia++){ + Plane3D pl_aero = get_AeroforTraj(ia); + pl_aero.show(); + pa[ia]=pl_aero.point(); + System.out.format("Ref point %s \n",pa[ia].toStringBrief(2)); + + } + + Point3D IP = new Point3D(0.,0.,0.); + for (int ia=0; ia<3; ia++){ + Line3D lin = new Line3D(IP, pa[ia]); + int iplane = select_AeroforTraj(lin, lin, lin); + System.out.format("For LIN %d select plane %d \n",ia,iplane); + + } + + } + + + //------------------------------ + public Plane3D get_MaPMTforTraj() { + //------------------------------ + RICHLayer layer = get_Layer("mapmts"); - List compo_list = layer.get_CompoList(); - Shape3D compo_misa = layer.get_TrackingSurf(); - generate_Pixel_Map(layer.get_id(), 0, compo_misa, compo_list); + return layer.get_TrajPlane(); + + } + + + //------------------------------ + public Plane3D get_AeroforTraj(int iflag) { + //------------------------------ - if(debugMode>=1)show_Shape3D(compo_misa, null, "CC"); - if(debugMode>=1)show_RICH("Real RICH Geometry", "RR"); + RICHLayer layer = get_Layer("aerogel_2cm_B1"); + if(iflag==1) layer = get_Layer("aerogel_2cm_B2"); + if(iflag==2) layer = get_Layer("aerogel_3cm_L1"); + + return layer.get_TrajPlane(); + + } + + + //------------------------------ + public int select_AeroforTraj(Line3D first, Line3D second, Line3D third) { + //------------------------------ + + RICHIntersection entra = get_Layer("aerogel_2cm_B2").find_Entrance(second, -2); + if(entra!=null) return 1; + + if(entra==null) entra = get_Layer("aerogel_3cm_L1").find_Entrance(third, -2); + if(entra!=null) return 2; + + // return a solution plane in any case + return 0; } @@ -1326,8 +1483,8 @@ public void build_CompoSurfs(RICHLayer layer, Vector3D orient) { compo.set_TrackingSurf(plane); if(debugMode>=1 && plane.size()>0){ - String head = String.format("COMP %3d %3d ",layer.get_id(),ico); System.out.format("Compo %3d %3d Normal %s \n",layer.get_id(),ico,toString(get_Shape3D_Normal(plane))); + String head = String.format("COMP %3d %3d ",layer.get_id(),ico); show_Shape3D(plane, null, head); } } @@ -1444,7 +1601,7 @@ public void misalign_Layer(RICHLayer layer){ Vector3D lshift = layer_misa_shift[ilay+1][0]; Vector3D langle = layer_misa_angle[ilay+1][0]; if(langle.mag()>0 || lshift.mag()>0){ - if(debugMode>=1){System.out.format(" --> asLayer %s %s \n", toString(lshift), toString(langle)); } + if(debugMode>=1){System.out.format(" --> asLayer %d %s %s \n", ilay, toString(lshift), toString(langle)); } if(debugMode>=1)System.out.format(" --> global \n"); misalign_Element( layer.get_GlobalSurf(), lframe, langle, lshift); @@ -1480,63 +1637,57 @@ public void misalign_Layer(RICHLayer layer){ //------------------------------ - public void generate_TrackingPlanes(){ + public void generate_TrackingPlane(int ilay){ //------------------------------ int debugMode = 0; - rich_frame = survey_frame.clone(); - - for (int ilay=0; ilay=1){ - System.out.format("------------------------\n"); - System.out.format("Generate tracking for Layer %d %s view %s \n", ilay, layer.get_Name(), orient.toStringBrief(3)); - System.out.format("------------------------\n"); - } + RICHLayer layer = get_Layer(ilay); + Vector3D orient = layer.get_Vinside(); - /* - * Nominal plane just for reference - */ - layer.set_NominalPlane( generate_Nominal_Plane(ilay, 0) ); + if(debugMode>=1){ + System.out.format("------------------------\n"); + System.out.format("Generate tracking for Layer %d %s view %s \n", ilay, layer.get_Name(), orient.toStringBrief(3)); + System.out.format("------------------------\n"); + } + /* + * Nominal plane just for reference + */ + layer.set_NominalPlane( generate_Nominal_Plane(ilay, 0) ); - /* - * For each component, group faces with normal and position vs barycenter along orient - */ - build_CompoSurfs(layer, orient); - - /* - * Generate a global plane for fast tracking without gaps - * In case of aerogel add the second global face - */ - build_GlobalPlanes(layer, orient); + /* + * For each component, group faces with normal and position vs barycenter along orient + */ + build_CompoSurfs(layer, orient); + + /* + * Generate a global plane for fast tracking without gaps + * In case of aerogel add the second global face + */ + build_GlobalPlanes(layer, orient); - /* - * Select the pivot for the RICH rotations - */ - if(layer.is_mapmt()) { - if(reco_constants.MISA_PMT_PIVOT==1) rich_frame.set_bref(layer.get_SurfBary()); - if(debugMode>=1)System.out.format("RICH PIVOT %s \n",rich_frame.bref().toStringBrief(2)); - } + /* + * Select the pivot for the RICH rotations + */ + if(layer.is_mapmt()) { + if(reco_constants.MISA_PMT_PIVOT==1) rich_frame.set_bref(layer.get_SurfBary()); + if(debugMode>=1)System.out.format("RICH PIVOT %s \n",rich_frame.bref().toStringBrief(2)); + } - /* - * define the spherical surfaces when needed - */ - build_CompoSpheres(layer); - } + /* + * define the spherical surfaces when needed + */ + build_CompoSpheres(layer); } //------------------------------ - public void misalign_TrackingPlanes(){ + public void misalign_TrackingPlane(int ilay){ //------------------------------ int debugMode = 0; @@ -1544,38 +1695,19 @@ public void misalign_TrackingPlanes(){ /* * Apply misalignment around given PIVOT */ - for (int ilay=0; ilay=1){ - System.out.format("------------------------\n"); - System.out.format("Misalign tracking for Layer %d %s\n", ilay, get_Layer(ilay).get_Name()); - System.out.format("------------------------\n"); - } - - RICHLayer layer = get_Layer(ilay); - - /* - * Misalign surfs as required - */ - misalign_Layer(layer); - - /* - * Store misalignmed tracking surfaces for fast tracking - */ - //layer.set_TrackingSurf( layer.merge_CompoSurfs()); - //layer.set_CompoList( layer.merge_CompoList()); + if(debugMode>=1){ + System.out.format("------------------------\n"); + System.out.format("Misalign tracking for Layer %d %s\n", ilay, get_Layer(ilay).get_Name()); + System.out.format("------------------------\n"); + } - /* - * Generate Pixel map on the misaligned MAPMT plane - */ - /*if(layer.is_mapmt()) { - List compo_list = layer.get_CompoList(); - Shape3D compo_misa = layer.get_TrackingSurf(); - if(debugMode>=1)show_Shape3D(compo_misa, null, "CC"); - generate_Pixel_Map(ilay, 0, compo_misa, compo_list); - }*/ + RICHLayer layer = get_Layer(ilay); - } + /* + * Misalign surfs as required + */ + misalign_Layer(layer); /* * Check misalignment effect on survey plane @@ -1594,7 +1726,7 @@ public void misalign_TrackingPlanes(){ //------------------------------ - public void store_TrackingPlanes(){ + public void store_TrackingPlane(int ilay){ //------------------------------ int debugMode = 0; @@ -1602,23 +1734,20 @@ public void store_TrackingPlanes(){ /* * Store the composite tracking planes */ - for (int ilay=0; ilay=1){ - System.out.format("------------------------\n"); - System.out.format("Store tracking for Layer %d %s\n", ilay, get_Layer(ilay).get_Name()); - System.out.format("------------------------\n"); - } - - RICHLayer layer = get_Layer(ilay); + if(debugMode>=1){ + System.out.format("------------------------\n"); + System.out.format("Store tracking for Layer %d %s\n", ilay, get_Layer(ilay).get_Name()); + System.out.format("------------------------\n"); + } - /* - * Store misalignmed tracking surfaces for fast tracking - */ - layer.set_TrackingSurf( layer.merge_CompoSurfs()); - layer.set_CompoList( layer.merge_CompoList()); + RICHLayer layer = get_Layer(ilay); - } + /* + * Store misalignmed tracking surfaces for fast tracking + */ + layer.set_TrackingSurf( layer.merge_CompoSurfs()); + layer.set_CompoList( layer.merge_CompoList()); } @@ -1879,6 +2008,92 @@ public double get_aerorefi(int ila, int ico){ } + //------------------------------ + public double get_sChElectron(int ila, int ico, int iqua, int irefle) { + //------------------------------ + + if(get_Constants().CHANGLES_FROM_ELECTRON==1){ + if(irefle==0){ + if(aero_schele_dir[ila][ico][iqua]>0){ + return aero_schele_dir[ila][ico][iqua]; + }else{ + if(aero_schele_lat[ila][ico][iqua]>0){ + return aero_schele_lat[ila][ico][iqua]; + }else{ + return aero_schele_spe[ila][ico][iqua]; + } + } + } + if(irefle==1){ + if(aero_schele_lat[ila][ico][iqua]>0){ + return aero_schele_lat[ila][ico][iqua]; + }else{ + if(aero_schele_dir[ila][ico][iqua]>0){ + return aero_schele_dir[ila][ico][iqua]; + }else{ + return aero_schele_spe[ila][ico][iqua]; + } + } + } + if(irefle==2){ + if(aero_schele_spe[ila][ico][iqua]>0){ + return aero_schele_spe[ila][ico][iqua]; + }else{ + if(aero_schele_dir[ila][ico][iqua]>0){ + return aero_schele_dir[ila][ico][iqua]; + }else{ + return aero_schele_lat[ila][ico][iqua]; + } + } + } + } + return 0.0; + } + + //------------------------------ + public double get_ChElectron(int ila, int ico, int iqua, int irefle) { + //------------------------------ + + if(get_Constants().CHANGLES_FROM_ELECTRON==1){ + if(irefle==0){ + if(aero_chele_dir[ila][ico][iqua]>0){ + return aero_chele_dir[ila][ico][iqua]; + }else{ + if(aero_chele_lat[ila][ico][iqua]>0){ + return aero_chele_lat[ila][ico][iqua]; + }else{ + return aero_chele_spe[ila][ico][iqua]; + } + } + } + if(irefle==1){ + if(aero_chele_lat[ila][ico][iqua]>0){ + return aero_chele_lat[ila][ico][iqua]; + }else{ + if(aero_chele_dir[ila][ico][iqua]>0){ + return aero_chele_dir[ila][ico][iqua]; + }else{ + return aero_chele_spe[ila][ico][iqua]; + } + } + } + if(irefle==2){ + if(aero_chele_spe[ila][ico][iqua]>0){ + return aero_chele_spe[ila][ico][iqua]; + }else{ + if(aero_chele_dir[ila][ico][iqua]>0){ + return aero_chele_dir[ila][ico][iqua]; + }else{ + return aero_chele_lat[ila][ico][iqua]; + } + } + } + } + return 0.0; + + } + + //------------------------------ public double getPMTtimeoff(int ipmt, int ich){ //------------------------------ @@ -2093,6 +2308,7 @@ public Point3D toPoint3D(Vector3D vin) { //------------------------------ public Point3D toPoint3D(Vector3d vin) { //------------------------------ + if(vin==null) return null; Point3D pout = new Point3D(vin.x, vin.y, vin.z); return pout; } @@ -2172,8 +2388,12 @@ public void show_RICH(String name, String head){ RICHLayer layer = get_Layer(ilay); if(layer.is_aerogel() || layer.is_mapmt()){ show_Shape3D(layer.get_GlobalSurf(), null, ini); - if(layer.is_aerogel())show_Shape3D(layer.get_TrackingSurf(), null, "AA"); + if(layer.is_aerogel()){ + show_Shape3D(layer.get_TrackingSurf(), null, "AA"); + for(int ico=0; ico RayTrace(Vector3d emission, int orilay, int orico, Vector3d vlab) { + // ---------------- + + int debugMode = 0; + + RICHLayer layer = get_Layer(orilay); + if(debugMode>=1)System.out.format("Raytrace gets refractive index from CCDB database %8.5f \n",layer.get(orico).get_index()); + return RayTrace(emission, orilay, orico, vlab, layer.get(orico).get_index()); + + } + + // ---------------- + public ArrayList RayTrace(Vector3d emission, int orilay, int orico, Vector3d vlab, double naero) { // ---------------- // return the hit position on the PMT plane of a photon emitted at emission with direction vlab @@ -2793,7 +3024,14 @@ public ArrayList RayTrace(Vector3d emission, int orilay, int orico, Vec Point3D new_pos = first_intersection.get_pos(); RICHRay oriray = new RICHRay(emi, new_pos); - oriray.set_refind(layer.get(orico).get_index()); + + /* rewrite the refractive index to be consistent with photon theta + only valid for initial aerogel + the rest of components take ref index from CCDB database + */ + //oriray.set_refind(layer.get(orico).get_index()); + first_intersection.set_nin((float) naero); + oriray.set_refind(naero); raytracks.add(oriray); RICHRay rayin = new RICHRay(new_pos, oriray.direction().multiply(200)); diff --git a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHio.java b/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHio.java index a376a3b2a0..3ee098ce3a 100644 --- a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHio.java +++ b/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHio.java @@ -8,11 +8,14 @@ import org.jlab.io.base.DataEvent; import org.jlab.clas.detector.DetectorResponse; + public class RICHio { /* * RICH i/o */ + private static double RAD = 180./Math.PI; + private static double MRAD = 1000; // constructor // ---------------- @@ -97,6 +100,8 @@ public void write_CherenkovBanks(DataEvent event, RICHEvent richevent, RICHConst if(richevent.get_nPho()>0)write_RingCherBank(event, richevent, recopar); + if(richevent.get_nHad()>0)write_HadCherBank(event, richevent, recopar); + } @@ -214,6 +219,7 @@ public void write_HadronBank(DataEvent event, RICHEvent richevent) { bankHads.setFloat("traced_hitz", i, (float) had.meas_hit.z); bankHads.setFloat("traced_time", i, (float) had.traced.get_time()); bankHads.setFloat("traced_path", i, (float) had.traced.get_path()); + //bankHads.setFloat("traced_mchi2", i, (float) had.traced.get_machi2()); bankHads.setShort("traced_ilay", i, (short) had.ilay_emission); bankHads.setShort("traced_ico", i, (short) had.ico_emission); @@ -221,12 +227,12 @@ public void write_HadronBank(DataEvent event, RICHEvent richevent) { bankHads.setFloat("traced_emiy", i, (float) had.lab_emission.y); bankHads.setFloat("traced_emiz", i, (float) had.lab_emission.z); - bankHads.setFloat("EtaC_ele", i, (float) had.get_changle(0)); - bankHads.setFloat("EtaC_pi", i, (float) had.get_changle(1)); - bankHads.setFloat("EtaC_k", i, (float) had.get_changle(2)); - bankHads.setFloat("EtaC_pr", i, (float) had.get_changle(3)); - bankHads.setFloat("EtaC_min", i, (float) had.minChAngle()); - bankHads.setFloat("EtaC_max", i, (float) had.maxChAngle()); + bankHads.setFloat("EtaC_ele", i, (float) had.get_changle(0,0)); + bankHads.setFloat("EtaC_pi", i, (float) had.get_changle(1,0)); + bankHads.setFloat("EtaC_k", i, (float) had.get_changle(2,0)); + bankHads.setFloat("EtaC_pr", i, (float) had.get_changle(3,0)); + bankHads.setFloat("EtaC_min", i, (float) had.minChAngle(0)); + bankHads.setFloat("EtaC_max", i, (float) had.maxChAngle(0)); } event.appendBanks(bankHads); @@ -234,6 +240,59 @@ public void write_HadronBank(DataEvent event, RICHEvent richevent) { } + // ---------------- + public void write_HadCherBank(DataEvent event, RICHEvent richevent, RICHConstants recopar) { + // ---------------- + + int debugMode = 0; + + int NHAD = richevent.get_nHad(); + if(debugMode>=1)System.out.format("Creating Bank for %5d Hadrons \n", NHAD); + + if(NHAD>0) { + if(debugMode>=1)System.out.println(" --> Creating the HadCher Bank "); + DataBank bankHads = event.createBank("RICH::hadCher", NHAD); + if(bankHads==null){ + System.out.println("ERROR CREATING BANK : RICH::hadCher"); + return; + } + + for(int i = 0; i < NHAD; i++){ + + RICHParticle had = richevent.get_Hadron(i); + double dT_max = recopar.RICH_TIME_RMS*3; + + if(debugMode>0)System.out.format(" RICHio %7.2f %7.2f %5d %7.2f %9.4f %9.4f \n",had.minChAngle(0)*MRAD,had.maxChAngle(0)*MRAD, + had.traced.get_BestH(),had.traced.get_RQP(),had.traced.get_ElProb(),had.traced.get_PiProb()); + + bankHads.setShort("id", i ,(short) had.get_id()); + bankHads.setShort("hindex", i, (short) had.get_hit_index()); + bankHads.setShort("pindex", i, (short) had.get_ParentIndex()); + + bankHads.setShort("emilay", i, (short) had.ilay_emission); + bankHads.setShort("emico", i, (short) had.ico_emission); + bankHads.setShort("emqua", i, (short) had.qua_emission); + bankHads.setFloat("mchi2", i, (float) had.traced.get_machi2()); + + bankHads.setFloat("ch_min", i, (float) had.minChAngle(0)); + bankHads.setFloat("ch_max", i, (float) had.maxChAngle(0)); + bankHads.setFloat("dt_max", i, (float) dT_max); + bankHads.setFloat("ch_dir", i, (float) had.traced.get_Chdir()); + bankHads.setFloat("ch_lat", i, (float) had.traced.get_Chlat()); + bankHads.setFloat("ch_spe", i, (float) had.traced.get_Chspe()); + + bankHads.setShort("best_PID", i, (short) had.traced.get_BestH()); + bankHads.setFloat("RQ_prob", i, (float) had.traced.get_RQP()); + bankHads.setFloat("el_prob", i, (float) had.traced.get_ElProb()); + bankHads.setFloat("pi_prob", i, (float) had.traced.get_PiProb()); + bankHads.setFloat("k_prob", i, (float) had.traced.get_KProb()); + bankHads.setFloat("pr_prob", i, (float) had.traced.get_PrProb()); + } + event.appendBanks(bankHads); + } + + } + // ---------------- public void write_RingCherBank(DataEvent event, RICHEvent richevent, RICHConstants recopar) { // ---------------- @@ -251,6 +310,8 @@ public void write_RingCherBank(DataEvent event, RICHEvent richevent, RICHConstan return; } + int SELE = 2; + for(int i = 0; i < NPHO; i++){ RICHParticle pho = richevent.get_Photon(i); @@ -264,16 +325,12 @@ public void write_RingCherBank(DataEvent event, RICHEvent richevent, RICHConstan double htime = hit.get_time(); double a_time = pho.get_start_time() + pho.analytic.get_time(); double t_time = pho.get_start_time() + pho.traced.get_time(); - double chmi = had.minChAngle(); - double chma = had.maxChAngle(); - double dtma = recopar.RICH_TIME_RMS*3; double a_etaC = pho.analytic.get_EtaC(); double t_etaC = pho.traced.get_EtaC(); // skip no real Cherenkov solution - if((a_etaCchma) && (t_etaCchma)) continue; - if(Math.abs(a_time-htime)>dtma && Math.abs(t_time-htime)>dtma) continue; + if(pho.analytic.get_OK()!=SELE && pho.traced.get_OK()!=SELE) continue; bankRing.setShort("id", i, (short) pho.get_id()); bankRing.setShort("hindex", i, (short) pho.get_hit_index()); @@ -317,6 +374,7 @@ public void write_PhotonBank(DataEvent event, RICHEvent richevent) { for(int i = 0; i < NPHO; i++){ RICHParticle pho = richevent.get_Photon(i); + if(debugMode>=1)System.out.format(" --> %3d %3d %3d \n",pho.get_id(),pho.get_type(),pho.get_ParentIndex()); bankPhos.setShort("id",i, (short) pho.get_id()); bankPhos.setShort("type",i, (short) pho.get_type()); @@ -333,11 +391,11 @@ public void write_PhotonBank(DataEvent event, RICHEvent richevent) { bankPhos.setFloat("analytic_EtaC",i,(float) pho.analytic.get_EtaC()); bankPhos.setFloat("analytic_aeron",i,(float) pho.analytic.get_aeron()); - bankPhos.setFloat("analytic_elpr",i,(float) pho.analytic.get_elprob()); - bankPhos.setFloat("analytic_pipr",i,(float) pho.analytic.get_piprob()); - bankPhos.setFloat("analytic_kpr",i,(float) pho.analytic.get_kprob()); - bankPhos.setFloat("analytic_prpr",i,(float) pho.analytic.get_prprob()); - bankPhos.setFloat("analytic_bgpr",i,(float) pho.analytic.get_bgprob()); + bankPhos.setFloat("analytic_elpr",i,(float) pho.analytic.get_ElProb()); + bankPhos.setFloat("analytic_pipr",i,(float) pho.analytic.get_PiProb()); + bankPhos.setFloat("analytic_kpr",i,(float) pho.analytic.get_KProb()); + bankPhos.setFloat("analytic_prpr",i,(float) pho.analytic.get_PrProb()); + bankPhos.setFloat("analytic_bgpr",i,(float) pho.analytic.get_BgProb()); bankPhos.setFloat("traced_the",i,(float) pho.traced.get_theta()); bankPhos.setFloat("traced_phi",i,(float) pho.traced.get_phi()); @@ -348,15 +406,15 @@ public void write_PhotonBank(DataEvent event, RICHEvent richevent) { bankPhos.setFloat("traced_time",i,(float) pho.traced.get_time()); bankPhos.setShort("traced_nrfl",i,(short) pho.traced.get_nrefle()); bankPhos.setShort("traced_nrfr",i,(short) pho.traced.get_nrefra()); - bankPhos.setShort("traced_1rfl",i,(short) pho.traced.get_firstrefle()); + bankPhos.setShort("traced_1rfl",i,(short) pho.traced.get_FirstRefle()); bankPhos.setFloat("traced_EtaC",i,(float) pho.traced.get_EtaC()); bankPhos.setFloat("traced_aeron",i,(float) pho.traced.get_aeron()); - bankPhos.setFloat("traced_elpr",i,(float) pho.traced.get_elprob()); - bankPhos.setFloat("traced_pipr",i,(float) pho.traced.get_piprob()); - bankPhos.setFloat("traced_kpr",i,(float) pho.traced.get_kprob()); - bankPhos.setFloat("traced_prpr",i,(float) pho.traced.get_prprob()); - bankPhos.setFloat("traced_bgpr",i,(float) pho.traced.get_bgprob()); + bankPhos.setFloat("traced_elpr",i,(float) pho.traced.get_ElProb()); + bankPhos.setFloat("traced_pipr",i,(float) pho.traced.get_PiProb()); + bankPhos.setFloat("traced_kpr",i,(float) pho.traced.get_KProb()); + bankPhos.setFloat("traced_prpr",i,(float) pho.traced.get_PrProb()); + bankPhos.setFloat("traced_bgpr",i,(float) pho.traced.get_BgProb()); } event.appendBanks(bankPhos); From f149405a0a977688a81c94a12792ac170af91c93 Mon Sep 17 00:00:00 2001 From: mcontalb Date: Tue, 18 Feb 2020 16:37:50 +0100 Subject: [PATCH 204/235] rich.json consistent with previous commit --- etc/bankdefs/hipo4/rich.json | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/etc/bankdefs/hipo4/rich.json b/etc/bankdefs/hipo4/rich.json index ead4a9d9f5..dd458f7902 100644 --- a/etc/bankdefs/hipo4/rich.json +++ b/etc/bankdefs/hipo4/rich.json @@ -163,5 +163,35 @@ {"name":"ttime", "type":"F", "info":"photon arrival time for traced solution" }, {"name":"tEtaC", "type":"F", "info":"Cherenkov angle as traced solution" } ] + }, + { + "name": "RICH::hadCher", + "group": 21800, + "item" : 35, + "info": "Reconstructed Cherenov information per track", + "entries": [ + {"name":"id", "type":"S", "info":"id"}, + {"name":"hindex", "type":"S", "info":"related row in the RICH::clusters bank (if any)"}, + {"name":"pindex", "type":"S", "info":"related row in the REC::Particle bank"}, + + {"name":"emilay", "type":"S", "info":"aerogel layer of photon emission"}, + {"name":"emico", "type":"S", "info":"aerogel component of photon emission"}, + {"name":"emqua", "type":"S", "info":"aerogel quadrant of photon emission"}, + {"name":"mchi2", "type":"F", "info":"track-cluster matching chi2 (if any)"}, + + {"name":"ch_min", "type":"F", "info":"minimum EtaC selection"}, + {"name":"ch_max", "type":"F", "info":"maximum EtaC selection"}, + {"name":"dt_max", "type":"F", "info":"maximum delta-time selection"}, + {"name":"ch_dir", "type":"F", "info":"average Cherenkov angle for direct photons"}, + {"name":"ch_lat", "type":"F", "info":"average Cherenkov angle for photons reflected by flat mirrors"}, + {"name":"ch_spe", "type":"F", "info":"average Cherenkov angle for photons reflected by spherical mirrors"}, + + {"name":"best_PID", "type":"S", "info":"most probable PID choice"}, + {"name":"RQ_prob", "type":"F", "info":"goodness of choice parameter (1=anambiguos, 0=random)"}, + {"name":"el_prob", "type":"F", "info":"probability to be an electron"}, + {"name":"pi_prob", "type":"F", "info":"probability to be an pion"}, + {"name":"k_prob", "type":"F", "info":"probability to be an kaon"}, + {"name":"pr_prob", "type":"F", "info":"probability to be an proton"} + ] } - ] +] From a6cc464b8d96cac729df73d7093f690ad9aa256a Mon Sep 17 00:00:00 2001 From: baltzell Date: Tue, 18 Feb 2020 17:08:43 -0500 Subject: [PATCH 205/235] set layer in REC::ForwardTagger --- .../src/main/java/org/jlab/clas/detector/DetectorData.java | 3 ++- .../src/main/java/org/jlab/clas/detector/TaggerResponse.java | 1 + 2 files changed, 3 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 afc9731236..1668b21b49 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 @@ -335,7 +335,8 @@ public static DataBank getForwardTaggerBank(List responses, Da bank.setFloat("dy", row, (float) t.getPositionWidth().y()); bank.setFloat("radius", row, (float) t.getRadius()); bank.setShort("size", row, (short) t.getSize()); - bank.setFloat("chi2", row, (float) 0.0); + bank.setFloat("chi2", row, (float) 0.0); + bank.setByte("layer", row, (byte) t.getDescriptor().getLayer()); row = row + 1; } return bank; 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 eedf015c6c..08aef64cef 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 @@ -82,6 +82,7 @@ public static List readHipoEvent(DataEvent event, ft.setPositionWidth(dx, dy, 0); ft.getDescriptor().setType(type); + ft.getDescriptor().setSectorLayerComponent(0,1,0); responseList.add((DetectorResponse)ft); } From a7978fcd793eac25d6c6378696cccd18f3b61d0a Mon Sep 17 00:00:00 2001 From: baltzell Date: Tue, 18 Feb 2020 17:36:23 -0500 Subject: [PATCH 206/235] switch FT eb tests to use RECFT::Particle --- .../advanced-tests/src/eb/EBTwoTrackTest.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/validation/advanced-tests/src/eb/EBTwoTrackTest.java b/validation/advanced-tests/src/eb/EBTwoTrackTest.java index 8f557de043..063f97a21a 100644 --- a/validation/advanced-tests/src/eb/EBTwoTrackTest.java +++ b/validation/advanced-tests/src/eb/EBTwoTrackTest.java @@ -385,7 +385,7 @@ public void checkAllRefs(DataEvent ev) { public void checkParticleStatus(DataEvent event) { if (recPartBank==null) return; for (int ipart=0; ipart0.90,true); + if (ftPDG==11) assertEquals(eEff>0.78,true); else if (ftPDG==22) assertEquals(gEff>0.88,true); - assertEquals(hEff>0.50,true); + assertEquals(hEff>0.62,true); } // This is for Forward Tagger; @@ -499,7 +499,7 @@ private void processEventFT(DataEvent event) { nEvents++; - if (recBank==null || recPartBank==null || recFtBank==null) return; + if (recBank==null || recPartBank==null || recFtBank==null || recFtPartBank==null) return; if (debug) { System.out.println("\n\n#############################################################\n"); @@ -510,9 +510,9 @@ private void processEventFT(DataEvent event) { final float startTime=recBank.getFloat("startTime",0); - for (int ii=0; ii0 || fdCharge==0); ii++) { - final int pid = recPartBank.getInt("pid",ii); + for (int ii=0; ii0 || fdCharge==0); ii++) { + final int pid = recFtPartBank.getInt("pid",ii); if (pid==hadronPDG) { final double px=recPartBank.getFloat("px",ii); final double py=recPartBank.getFloat("py",ii); @@ -603,7 +603,7 @@ else if (!isCentral && trkBank.getInt("sector",ii)==hadronSector) { for (int ii = 0; ii < recPartBank.rows(); ii++) { - final short status = recPartBank.getShort("status", ii); + final short status = (short)Math.abs(recPartBank.getShort("status", ii)); final byte charge = recPartBank.getByte("charge", ii); final int pid = recPartBank.getInt("pid", ii); final boolean isFT = status/1000 == 1; From 570a4b36e95491fbd83c48a9152502dfdf682496 Mon Sep 17 00:00:00 2001 From: ziegler Date: Wed, 19 Feb 2020 14:13:33 -0500 Subject: [PATCH 207/235] CVT status word. --- etc/bankdefs/hipo4/cvt.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/etc/bankdefs/hipo4/cvt.json b/etc/bankdefs/hipo4/cvt.json index b7d736b774..f48dfcbcd6 100644 --- a/etc/bankdefs/hipo4/cvt.json +++ b/etc/bankdefs/hipo4/cvt.json @@ -43,7 +43,8 @@ {"name":"Cross8_ID", "type":"S", "info":"ID of cross in the track"}, {"name":"Cross9_ID", "type":"S", "info":"ID of cross in the track"}, {"name":"xb", "type":"F", "info":"x offset "}, - {"name":"yb", "type":"F", "info":"y offset "} + {"name":"yb", "type":"F", "info":"y offset "}, + {"name":"status", "type":"S", "info":"track status : 1abc (a = nb SVT crosses, b = nb BMT Z clusters, c = nb BMT C clusters, used in fit)"} ] }, { From 3c01e974d60ed278a21075a5624efcc1e255c4b6 Mon Sep 17 00:00:00 2001 From: ziegler Date: Wed, 19 Feb 2020 14:13:52 -0500 Subject: [PATCH 208/235] CVT status word. --- .../org/jlab/rec/cvt/banks/RecoBankWriter.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/banks/RecoBankWriter.java b/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/banks/RecoBankWriter.java index f0571660ac..c819f1de0d 100644 --- a/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/banks/RecoBankWriter.java +++ b/reconstruction/cvt/src/main/java/org/jlab/rec/cvt/banks/RecoBankWriter.java @@ -371,6 +371,10 @@ public DataBank fillTracksBank(DataEvent event, List trkcands, double zSh bank.setFloat("c_uz", i, (float) trkcands.get(i).get_TrackDirAtCTOFRadius().z()); bank.setFloat("pathlength", i, (float) (trkcands.get(i).get_pathLength() / 10.)); // conversion to cm + //for status word: + int a = 0; + int b = 0; + int c = 0; // fills the list of cross ids for crosses belonging to that reconstructed track for (int j = 0; j < trkcands.get(i).size(); j++) { if(j<9) { @@ -379,13 +383,22 @@ public DataBank fillTracksBank(DataEvent event, List trkcands, double zSh hitStrg += "_ID"; //System.out.println(" j "+j+" matched id "+trkcands.get(i).get(j).get_Id()); bank.setShort(hitStrg, i, (short) trkcands.get(i).get(j).get_Id()); } + // counter to get status word + if(trkcands.get(i).get(j).get_Detector().equalsIgnoreCase("SVT")) + a++; + if(trkcands.get(i).get(j).get_Detector().equalsIgnoreCase("BMT") + && trkcands.get(i).get(j).get_DetectorType().equalsIgnoreCase("Z")) + b++; + if(trkcands.get(i).get(j).get_Detector().equalsIgnoreCase("BMT") + && trkcands.get(i).get(j).get_DetectorType().equalsIgnoreCase("C")) + c++; } + bank.setShort("status", i, (short) ((short) 1000+a*100+b*10+c)); bank.setFloat("circlefit_chi2_per_ndf", i, (float) trkcands.get(i).get_circleFitChi2PerNDF()); bank.setFloat("linefit_chi2_per_ndf", i, (float) trkcands.get(i).get_lineFitChi2PerNDF()); bank.setFloat("chi2", i, (float) trkcands.get(i).getChi2()); bank.setShort("ndf", i, (short) trkcands.get(i).getNDF()); - } //bank.show(); return bank; From e8e6d8ab7352d34732e70481aee8d6c68ef06a42 Mon Sep 17 00:00:00 2001 From: ziegler Date: Wed, 19 Feb 2020 17:08:35 -0500 Subject: [PATCH 209/235] Allow non zero T0 in MC. --- .../dc/src/main/java/org/jlab/rec/dc/banks/HitReader.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/reconstruction/dc/src/main/java/org/jlab/rec/dc/banks/HitReader.java b/reconstruction/dc/src/main/java/org/jlab/rec/dc/banks/HitReader.java index 9d99bac201..36e041bfc7 100644 --- a/reconstruction/dc/src/main/java/org/jlab/rec/dc/banks/HitReader.java +++ b/reconstruction/dc/src/main/java/org/jlab/rec/dc/banks/HitReader.java @@ -316,11 +316,11 @@ public void read_HBHits(DataEvent event, IndexedTable constants0, IndexedTable c if (!event.hasBank("MC::Particle") && event.getBank("RUN::config").getInt("run", 0) > 100) { - T_0 = this.get_T0(sector[i], slayer[i], layer[i], wire[i], T0, T0ERR)[0]; + //T_0 = this.get_T0(sector[i], slayer[i], layer[i], wire[i], T0, T0ERR)[0]; if (event.hasBank("RECHB::Event")) T_Start = event.getBank("RECHB::Event").getFloat("startTime", 0); } - + T_0 = this.get_T0(sector[i], slayer[i], layer[i], wire[i], T0, T0ERR)[0]; FittedHit hit = new FittedHit(sector[i], slayer[i], layer[i], wire[i], tdc[i], id[i]); hit.set_Id(id[i]); hit.setB(B[i]); From 3d6c04402c93a4ea75ee02967814a36574f9651e Mon Sep 17 00:00:00 2001 From: mcontalb Date: Thu, 20 Feb 2020 01:50:12 +0100 Subject: [PATCH 210/235] new ccdb banks: add pixels/electro, extend parameters --- .../java/org/jlab/rec/rich/RICHConstants.java | 7 +- .../java/org/jlab/rec/rich/RICHEBEngine.java | 12 +- .../java/org/jlab/rec/rich/RICHEvent.java | 12 +- .../org/jlab/rec/rich/RICHEventBuilder.java | 2 + .../main/java/org/jlab/rec/rich/RICHHit.java | 4 +- .../java/org/jlab/rec/rich/RICHParticle.java | 111 +++++++++---- .../main/java/org/jlab/rec/rich/RICHTool.java | 157 ++++++++++++++++-- .../main/java/org/jlab/rec/rich/RICHio.java | 12 +- 8 files changed, 252 insertions(+), 65 deletions(-) diff --git a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHConstants.java b/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHConstants.java index e4aa061857..56ed6c1a06 100644 --- a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHConstants.java +++ b/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHConstants.java @@ -37,7 +37,7 @@ public class RICHConstants { public static final double RICH_MIN_CHANGLE = 10.e-3; // rad public static final double RICH_MATCH_POLYDIST = 1.e-3; // Matching dist between poly and point - public static final double RICH_BKG_PROBABILITY = 1.e-3; // Background probability for likelihood + public static final double RICH_BKG_PROBABILITY = 1.e-5; // Background probability for likelihood public static final double READ_FROM_FILES = 0.; // read values from txt files @@ -64,6 +64,9 @@ public class RICHConstants { public int DO_MIRROR_HADS = 1; // if 1 reconstruct hadrons pointing to mirror public int DO_CURVED_AERO = 1; // if 1 use spherical surface of aerogel + public int USE_ELECTRON_ANGLES = 0; // Get Cherenkov angle and rms from electrons control sample + public int USE_PIXEL_PROPERTIES = 0; // Use pixel status and efficiency in the likelihood + public double GOODHIT_FRAC = 80.; // Maximum duration (in % of local max) to flag xtalk public double RICH_DCMATCH_CUT = 15.; // RICH cluster matching cut with tracks public double RICH_HITMATCH_RMS = 0.6; // RICH - particle matching chi2 reference (cm) @@ -77,8 +80,6 @@ public class RICHConstants { public double MISA_SHIFT_SCALE = 1.0; // Scale factor for misalignment shifts public double MISA_ANGLE_SCALE = 1.0; // Scale factor for misalignment angles - public int CHANGLES_FROM_ELECTRON = 0; // Get Cherenkov angle and rms from electrons control sample - // ----------------- // Run Type // ----------------- diff --git a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHEBEngine.java b/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHEBEngine.java index 539b9ca2fa..8055cfebf0 100644 --- a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHEBEngine.java +++ b/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHEBEngine.java @@ -118,7 +118,9 @@ public boolean init_CCDB(int iflag) { "/calibration/rich/time_walk", "/calibration/rich/time_offset", "/calibration/rich/misalignments", - "/calibration/rich/parameter" + "/calibration/rich/parameterss", + "/calibration/rich/pixels", + "/calibration/rich/electro" }; requireConstants(Arrays.asList(richTables)); @@ -133,10 +135,10 @@ public boolean init_CCDB(int iflag) { // Get the constant tables for reconstruction parameters, geometry and optical characterization int run = 11; - IndexedTable test = getConstantsManager().getConstants(run, "/calibration/rich/parameter"); + //IndexedTable test = getConstantsManager().getConstants(run, "/calibration/rich/parameter"); tool.init_GeoConstants(iflag, - getConstantsManager().getConstants(run, "/calibration/rich/parameter"), + getConstantsManager().getConstants(run, "/calibration/rich/parameterss"), getConstantsManager().getConstants(run, "/calibration/rich/aerogel"), getConstantsManager().getConstants(run, "/calibration/rich/misalignments") ); @@ -208,7 +210,9 @@ public void init_Event(DataEvent event, RICHEvent richevent, RICHTool tool) { // Get the run-dependent tables for time calibration tool.init_TimeConstants( getConstantsManager().getConstants(run, "/calibration/rich/time_walk"), - getConstantsManager().getConstants(run, "/calibration/rich/time_offset") ); + getConstantsManager().getConstants(run, "/calibration/rich/time_offset"), + getConstantsManager().getConstants(run, "/calibration/rich/electro"), + getConstantsManager().getConstants(run, "/calibration/rich/pixels") ); } diff --git a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHEvent.java b/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHEvent.java index 9645d8ee42..d1b046f31d 100644 --- a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHEvent.java +++ b/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHEvent.java @@ -429,11 +429,13 @@ public void get_pid(RICHParticle hadron, int recotype) { if(recotype==1) reco = pho.traced; double etac = reco.get_EtaC(); if(reco.get_OK()!=SELE) continue; + + RICHHit hit = hits.get( pho.get_hit_index() ); if(debugMode>=1)System.out.format("calc prob for photon %d \n",pho.get_id()); // prob for backgound - prob = pho.pid_probability(hadron, 0, recotype); + prob = pho.pid_probability(hadron, hit, 0, recotype); if(prob-1>=RICHConstants.RICH_BKG_PROBABILITY){ lh_bg += Math.log(prob); ch_bg += Math.log(prob)*etac; @@ -445,7 +447,7 @@ public void get_pid(RICHParticle hadron, int recotype) { } // prob for electron - prob = pho.pid_probability(hadron, 11, recotype); + prob = pho.pid_probability(hadron, hit, 11, recotype); if(prob-1>=RICHConstants.RICH_BKG_PROBABILITY){ lh_el += Math.log(prob); ch_el += Math.log(prob)*etac; @@ -457,7 +459,7 @@ public void get_pid(RICHParticle hadron, int recotype) { } // prob for pion - prob=pho.pid_probability(hadron, 211, recotype); + prob=pho.pid_probability(hadron, hit, 211, recotype); if(prob-1>=RICHConstants.RICH_BKG_PROBABILITY){ lh_pi += Math.log(prob); ch_pi += Math.log(prob)*etac; @@ -469,7 +471,7 @@ public void get_pid(RICHParticle hadron, int recotype) { } // prob for kaon - prob=pho.pid_probability(hadron, 321, recotype); + prob=pho.pid_probability(hadron, hit, 321, recotype); if(prob-1>=RICHConstants.RICH_BKG_PROBABILITY){ lh_k += Math.log(prob); ch_k += Math.log(prob)*etac; @@ -481,7 +483,7 @@ public void get_pid(RICHParticle hadron, int recotype) { } // prob for proton - prob=pho.pid_probability(hadron, 2212, recotype); + prob=pho.pid_probability(hadron, hit, 2212, recotype); if(prob-1>=RICHConstants.RICH_BKG_PROBABILITY){ lh_pr += Math.log(prob); ch_pr += Math.log(prob)*etac; diff --git a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHEventBuilder.java b/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHEventBuilder.java index 611bb3468c..bde92eca71 100644 --- a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHEventBuilder.java +++ b/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHEventBuilder.java @@ -587,6 +587,8 @@ public boolean find_Photons(List RichHits){ photon.set_points(richhadron, tool.toVector3d(RichHits.get(k).getPosition())); photon.set_meas_time(RichHits.get(k).getTime()); photon.set_start_time(richhadron.get_start_time()); + RICHHit hit = richevent.get_Hit( RichHits.get(k).getHitIndex() ); + photon.set_PixelProp(hit, tool); richevent.add_Photon(photon); diff --git a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHHit.java b/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHHit.java index 8b3f622d2a..be4d71cdd3 100644 --- a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHHit.java +++ b/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHHit.java @@ -20,11 +20,13 @@ public class RICHHit implements Comparable{ private int idy; // anode local idy (within PMT) private int glx; // anode global idx (onto RICH plane) private int gly; // anode global idy (onto RICH plane) + private float x; // anode global x (within CLAS) private float y; // anode global y (within CLAS) private float z; // anode global z (within CLAS) private float time; // Hit time private float rawtime; // Hit rawtime + private int duration; // Hit duration private int cluster; // parent cluster ID private int xtalk; // xtalk type @@ -44,7 +46,7 @@ public RICHHit(int hid, RICHTool tool, int phase, RICHEdge lead, RICHEdge trail) this.id = hid; this.sector = lead.get_sector(); this.tile = lead.get_tile(); - this.pmt = tool.Tile2PMT(tile, lead.get_channel()); // run from1 to 64 + this.pmt = tool.Tile2PMT(tile, lead.get_channel()); // run from1 to 391 this.channel = (lead.get_channel()-1)%64; this.anode = tool.Maroc2Anode(channel); // run from 1 to 64 this.idx = tool.Anode2idx(anode); diff --git a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHParticle.java b/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHParticle.java index 88d3902077..0260ced87a 100644 --- a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHParticle.java +++ b/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHParticle.java @@ -55,6 +55,12 @@ public class RICHParticle { public double lab_phi = 0.0; public double lab_theta = 0.0; + private double pixel_gain = 0.0; + private double pixel_eff = 0.0; + private int pixel_flag = 0; + private double pixel_mtime = 0; + private double pixel_stime = 0; + // rotated frame into RICH local coordinates (used for the analytic solution) public double RotAngle = 0.0; public Vector3d RotAxis = null; @@ -143,7 +149,7 @@ private void set_changle() { } for (int iref=0; iref<3; iref++){ - if(recopar.CHANGLES_FROM_ELECTRON==1){ + if(recopar.USE_ELECTRON_ANGLES==1){ ChAngle[0][iref] = calibrated_ChAngle(11, iref); // expected angle for electron ChAngle[1][iref] = calibrated_ChAngle(211, iref); // pion ChAngle[2][iref] = calibrated_ChAngle(321, iref); // kaon @@ -289,10 +295,11 @@ public double calibrated_ChAngle(int pid, int irefle){ int debugMode = 0; double arg = 0.0; double beta = get_beta(pid); - double cose = chele_emission[irefle]; + double cose = Math.cos(chele_emission[irefle]); if(beta>0) arg = 1.0/beta*cose; - if(debugMode>=1) System.out.format(" Expected Ch Angle %8.4f beta %8.4f n %7.3f arg %8.4f\n",get_mass(pid),beta,refi_emission, Math.acos(arg)*MRAD); + if(debugMode>=1) System.out.format(" Expected Ch Angle %7.2f %8.4f beta %8.4f n %7.3f arg %8.4f\n",chele_emission[irefle]*1000, + get_mass(pid),beta,refi_emission, Math.acos(arg)*MRAD); if(arg>0.0 && arg<1.0) return Math.acos(arg); return 0.0; } @@ -363,6 +370,34 @@ public void set_RICHpid(int hpid){ if(this.CLASpid<0)RICHpid*=-1; } + // ---------------- + public void set_PixelProp(RICHHit hit, RICHTool tool){ + // ---------------- + + int debugMode = 0; + + int ipmt = hit.get_pmt()-1; + int ich = hit.get_anode()-1; + + if (tool.get_Constants().USE_PIXEL_PROPERTIES==1){ + pixel_gain = tool.get_PixelGain(ipmt, ich); + pixel_eff = tool.get_PixelEff(ipmt, ich); + pixel_flag = tool.get_PixelFlag(ipmt, ich); + pixel_mtime = tool.get_PixelMtime(ipmt, ich); + pixel_stime = tool.get_PixelStime(ipmt, ich); + }else{ + pixel_gain = 1.0; + pixel_eff = 1.0; + pixel_flag = 1; + pixel_mtime = 0.0; + pixel_stime = recopar.RICH_TIME_RMS; + } + + if(debugMode>=1) System.out.format("Photon pixel %4d %4d %4d --> %2d %7.2f %7.2f %7.2f %7.2f \n",hit.get_id(), ipmt, ich, pixel_flag, pixel_gain, + pixel_eff, pixel_mtime, pixel_stime); + + } + // ---------------- public void set_points(RICHParticle hadron, Vector3d impa){ // ---------------- @@ -933,7 +968,7 @@ public double time_probability(double testtime, int recotype) { // ---------------- - public double pid_probability(RICHParticle hadron, int pid, int recotype) { + public double pid_probability(RICHParticle hadron, RICHHit hit, int pid, int recotype) { // ---------------- /* * calculate probability for a given pid hypothesis @@ -948,41 +983,55 @@ public double pid_probability(RICHParticle hadron, int pid, int recotype) { if(recotype==0) reco = analytic; if(recotype==1) reco = traced; - // angle probability - double mean = 0.0; - int irefle = reco.get_RefleType(); - if(irefle>=0 && irefle<=2){ - if(Math.abs(pid)==11)mean=hadron.get_changle(0, irefle); - if(Math.abs(pid)==211)mean=hadron.get_changle(1, irefle); - if(Math.abs(pid)==321)mean=hadron.get_changle(2, irefle); - if(Math.abs(pid)==2212)mean=hadron.get_changle(3, irefle); - } - - double sigma = hadron.get_schangle(irefle); - double func = 0.0; double dfunc = 1e-3; - if(mean>0){ - func = Math.exp((-0.5)*Math.pow((reco.get_EtaC() - mean)/sigma, 2) )/ (sigma*Math.sqrt(2* Math.PI)); - } - - // timing probability - double meant = start_time + reco.get_time(); - double sigmat = recopar.RICH_TIME_RMS; - double funt = 0.0; double dfunt = 1; - if(meant>0){ - funt = Math.exp((-0.5)*Math.pow((meas_time - meant)/sigmat, 2) )/ (sigmat*Math.sqrt(2* Math.PI)); + + double mean = 0.0; + double sigma = 0.0; + double recot = 0.0; + double meant = 0.0; + double sigmat = 0.0; + + if(pixel_flag==1){ + + // angle probability + + int irefle = reco.get_RefleType(); + if(irefle>=0 && irefle<=2){ + if(Math.abs(pid)==11)mean=hadron.get_changle(0, irefle); + if(Math.abs(pid)==211)mean=hadron.get_changle(1, irefle); + if(Math.abs(pid)==321)mean=hadron.get_changle(2, irefle); + if(Math.abs(pid)==2212)mean=hadron.get_changle(3, irefle); + + sigma = hadron.get_schangle(irefle); + } + + if(mean>0 && sigma>0){ + func = Math.exp((-0.5)*Math.pow((reco.get_EtaC() - mean)/sigma, 2) )/ (sigma*Math.sqrt(2* Math.PI)); + } + + // timing probability + recot = start_time + reco.get_time(); + meant = pixel_mtime; + sigmat = pixel_stime; + + + if(recot>0 && sigmat>0){ + funt = Math.exp((-0.5)*Math.pow((meas_time - recot - meant)/sigmat, 2) )/ (sigmat*Math.sqrt(2* Math.PI)); + } + } - - double prob = 1 + func*dfunc*funt*dfunt + recopar.RICH_BKG_PROBABILITY; - if(debugMode>=1)if(prob-1>recopar.RICH_BKG_PROBABILITY)System.out.format( - "PID prob %4d mean %8.3f etaC %8.3f meant %8.3f time %8.3f --> %g %g %g \n",pid, - mean*MRAD,reco.get_EtaC()*MRAD,meant,meas_time,func*dfunc,funt*dfunt,Math.log(prob)); + double prob = 1 + pixel_eff*func*dfunc*funt*dfunt + recopar.RICH_BKG_PROBABILITY; + + //if(debugMode>=1)if(prob-1>recopar.RICH_BKG_PROBABILITY)System.out.format( + if(debugMode>=1)System.out.format( + "PID prob %4d mean %7.2f etaC %7.2f sigma %7.2f meant %7.2f (%7.2f + %7.2f) time %7.2f sigmat %7.2f eff %7.2f --> %g %g %8.4f e-3\n",pid, + mean*MRAD,reco.get_EtaC()*MRAD,sigma*MRAD,recot+meant,recot,meant,meas_time,sigmat,pixel_eff,func*dfunc,funt*dfunt,Math.log(prob)*1e3); return prob; } diff --git a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHTool.java b/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHTool.java index e00d5cbe2f..842d135877 100644 --- a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHTool.java +++ b/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHTool.java @@ -202,6 +202,13 @@ public void RICHTool(){ private double pmt_timeoff[][] = new double[NPMT][NPIX]; private double pmt_timewalk[][] = new double[NPMT][4]; + private double pixel_gain[][] = new double[NPMT][NPIX]; + private double pixel_eff[][] = new double[NPMT][NPIX]; + private int pixel_flag[][] = new int [NPMT][NPIX]; // 0 = dead, 1 = ok, 2= hot + private int pixel_ntime[][] = new int [NPMT][NPIX]; // 0 = dead, 1 = ok, 2= hot + private double pixel_mtime[][] = new double [NPMT][NPIX]; // 0 = dead, 1 = ok, 2= hot + private double pixel_stime[][] = new double [NPMT][NPIX]; // 0 = dead, 1 = ok, 2= hot + private double aero_refi[][] = new double[4][31]; private double aero_plan[][] = new double[4][31]; private double aero_chele_dir[][][] = new double[4][31][225]; @@ -242,7 +249,6 @@ public void RICHTool(){ public void init_GeoConstants(int iflag, IndexedTable aeroConstants, IndexedTable misaConstants, IndexedTable paraConstants){ //------------------------------ - System.out.format(" &&& init_GeoConstants \n"); // generate the tracking layers (0 = only Aerogel and MaPMT for trajectory, 1 = all) // start processing time init_ProcessTime(); @@ -277,14 +283,14 @@ public void init_GeoConstants(int iflag, IndexedTable aeroConstants, IndexedTabl } //------------------------------ - public void init_TimeConstants(IndexedTable timewalkConstants, IndexedTable timeoffConstants){ + public void init_TimeConstants(IndexedTable timewalkConstants, IndexedTable timeoffConstants, IndexedTable cheleConstants, IndexedTable pixelConstants){ //------------------------------ // load constants if(RICHConstants.READ_FROM_FILES==1){ init_ConstantsTxT(2); }else{ - init_TimeConstantsCCDB(timewalkConstants, timeoffConstants); + init_TimeConstantsCCDB(timewalkConstants, timeoffConstants, cheleConstants, pixelConstants); } } @@ -353,7 +359,7 @@ public int get_Globalidy(int pmt, int anode) { //------------------------------ - public void init_TimeConstantsCCDB(IndexedTable timewalkConstants, IndexedTable timeoffConstants){ + public void init_TimeConstantsCCDB(IndexedTable timewalkConstants, IndexedTable timeoffConstants, IndexedTable cheleConstants, IndexedTable pixelConstants){ //------------------------------ int debugMode = 1; @@ -367,7 +373,7 @@ public void init_TimeConstantsCCDB(IndexedTable timewalkConstants, IndexedTable pmt_timeoff[ipmt][ich] = (float) timeoffConstants.getDoubleValue("offset", 4, ipmt+1, ich+1); } if(debugMode>=1 && reco_constants.RICH_DEBUG>0){ - if(ipmt<10 || ipmt>380)System.out.format("CCDB RICH TOFF ipmt %4d %8.2f (ch1) %8.2f (ch2) %8.2f (ch63) %8.2f (ch64) \n", ipmt+1, + if(ipmt<10 || ipmt>380)System.out.format("CCDB RICH TOFF ipmt %4d %8.3f (ch1) %8.3f (ch2) %8.3f (ch63) %8.3f (ch64) \n", ipmt+1, pmt_timeoff[ipmt][0], pmt_timeoff[ipmt][1], pmt_timeoff[ipmt][62], pmt_timeoff[ipmt][63]); if(ipmt==10)System.out.format("CCDB RICH TOFF ....... \n"); if(ipmt==390)System.out.format(" \n"); @@ -385,13 +391,87 @@ public void init_TimeConstantsCCDB(IndexedTable timewalkConstants, IndexedTable pmt_timewalk[ipmt][2] = (float) Math.abs(timewalkConstants.getDoubleValue("m2", 4, ipmt+1, 0))*(-1.0); pmt_timewalk[ipmt][3] = (float) timewalkConstants.getDoubleValue("T0", 4, ipmt+1, 0); if(debugMode>=1 && reco_constants.RICH_DEBUG>0){ - if(ipmt<10 || ipmt>380)System.out.format("CCDB RICH TWALK ipmt %4d D0 = %8.2f T0 = %8.2f m1 = %8.3f m2 = %8.3f\n", ipmt+1, + if(ipmt<10 || ipmt>380)System.out.format("CCDB RICH TWALK ipmt %4d D0 = %8.3f T0 = %8.3f m1 = %8.4f m2 = %8.4f\n", ipmt+1, pmt_timewalk[ipmt][0], pmt_timewalk[ipmt][1] , pmt_timewalk[ipmt][2], pmt_timewalk[ipmt][3]); if(ipmt==10)System.out.format("CCDB RICH TWALK ....... \n"); if(ipmt==390)System.out.format(" \n"); } } + /* + * AEROGEL CALIBRATED OPTCIS (USING ELECTRON CONTROL SAMPLE) + */ + + int ndo[] = {16,22,31,31}; + double mrad = reco_constants.MRAD; + for (int ila=0; ila<4; ila++){ + for (int ico=0; ico=1 && reco_constants.RICH_DEBUG>0){ + if( (itil<2 || itil>ndo[ila]-3) && (iqua==0 || iqua==224)) { + System.out.format("CCDB RICH CHELE ila %4d itile %3d iq %4d dir = %7.2f %7.2f lat = %7.2f %7.2f spe = %7.2f %7.2f \n", 201+ila, itil+1, iqua+1, + aero_chele_dir[ila][itil][iqua]*mrad, aero_schele_dir[ila][itil][iqua]*mrad, + aero_chele_lat[ila][itil][iqua]*mrad, aero_schele_lat[ila][itil][iqua]*mrad, + aero_chele_spe[ila][itil][iqua]*mrad, aero_schele_spe[ila][itil][iqua]*mrad); + } + if(ila==3 && ico==ndo[ila]*225-1)System.out.format(" \n"); + } + } + } + + /* + * PIXELS + */ + + for(int ipmt=0; ipmt=1 && reco_constants.RICH_DEBUG>0){ + if(ipmt<2 || ipmt>388)System.out.format("CCDB PIXEL GAIN ipmt %4d %8.2f (ch1) %8.2f (ch2) %8.2f (ch63) %8.2f (ch64) \n", ipmt+1, + pixel_gain[ipmt][0], pixel_gain[ipmt][1], pixel_gain[ipmt][62], pixel_gain[ipmt][63]); + if(ipmt==10)System.out.format("CCDB PIXEL GAIN ....... \n"); + + if(ipmt<2 || ipmt>388)System.out.format("CCDB PIXEL EFF ipmt %4d %8.2f (ch1) %8.2f (ch2) %8.2f (ch63) %8.2f (ch64) \n", ipmt+1, + pixel_eff[ipmt][0], pixel_eff[ipmt][1], pixel_eff[ipmt][62], pixel_eff[ipmt][63]); + if(ipmt==10)System.out.format("CCDB PIXEL EFF ....... \n"); + + if(ipmt<2 || ipmt>388)System.out.format("CCDB PIXEL STATUS ipmt %4d %8d (ch1) %8d (ch2) %8d (ch63) %8d (ch64) \n", ipmt+1, + pixel_flag[ipmt][0], pixel_flag[ipmt][1], pixel_flag[ipmt][62], pixel_flag[ipmt][63]); + if(ipmt==10)System.out.format("CCDB PIXEL STATUS ....... \n"); + + if(ipmt<2 || ipmt>388)System.out.format("CCDB PIXEL NTIME ipmt %4d %8d (ch1) %8d (ch2) %8d (ch63) %8d (ch64) \n", ipmt+1, + pixel_ntime[ipmt][0], pixel_ntime[ipmt][1], pixel_ntime[ipmt][62], pixel_ntime[ipmt][63]); + if(ipmt==10)System.out.format("CCDB PIXEL NTIME ....... \n"); + + if(ipmt<2 || ipmt>388)System.out.format("CCDB PIXEL MTIME ipmt %4d %8.2f (ch1) %8.2f (ch2) %8.2f (ch63) %8.2f (ch64) \n", ipmt+1, + pixel_mtime[ipmt][0], pixel_mtime[ipmt][1], pixel_mtime[ipmt][62], pixel_mtime[ipmt][63]); + if(ipmt==10)System.out.format("CCDB PIXEL MTIME ....... \n"); + + if(ipmt<2 || ipmt>388)System.out.format("CCDB PIXEL STIME ipmt %4d %8.2f (ch1) %8.2f (ch2) %8.2f (ch63) %8.2f (ch64) \n", ipmt+1, + pixel_stime[ipmt][0], pixel_stime[ipmt][1], pixel_stime[ipmt][62], pixel_stime[ipmt][63]); + if(ipmt==10)System.out.format("CCDB PIXEL STIME ....... \n"); + + if(ipmt==390)System.out.format(" \n"); + } + } + } @@ -419,10 +499,13 @@ public void init_GeoConstantsCCDB(IndexedTable paraConstants, IndexedTable aeroC reco_constants.THROW_PHOTON_NUMBER = paraConstants.getIntValue("flag11", 4, 0, 0); reco_constants.TRACE_PHOTONS = paraConstants.getIntValue("flag12", 4, 0, 0); - reco_constants.REDO_RICH_RECO = paraConstants.getIntValue("falg13", 4, 0, 0); + reco_constants.REDO_RICH_RECO = paraConstants.getIntValue("flag13", 4, 0, 0); reco_constants.DO_MIRROR_HADS = paraConstants.getIntValue("flag14", 4, 0, 0); reco_constants.DO_CURVED_AERO = paraConstants.getIntValue("flag15", 4, 0, 0); + reco_constants.USE_ELECTRON_ANGLES = paraConstants.getIntValue("flag16", 4, 0, 0); + reco_constants.USE_PIXEL_PROPERTIES = paraConstants.getIntValue("flag17", 4, 0, 0); + reco_constants.GOODHIT_FRAC = paraConstants.getDoubleValue("par1", 4, 0, 0); reco_constants.RICH_DCMATCH_CUT = paraConstants.getDoubleValue("par2", 4, 0, 0); reco_constants.RICH_HITMATCH_RMS = paraConstants.getDoubleValue("par3", 4, 0, 0); @@ -437,6 +520,8 @@ public void init_GeoConstantsCCDB(IndexedTable paraConstants, IndexedTable aeroC //TODO: check //reco_constants.RICH_DEBUG = 1.0; + //reco_constants.USE_ELECTRON_ANGLES = 1; + //reco_constants.USE_PIXEL_PROPERTIES = 1; //if(debugMode>=1 && reco_constants.RICH_DEBUG>0){ //MC if(debugMode>=1){ @@ -459,6 +544,9 @@ public void init_GeoConstantsCCDB(IndexedTable paraConstants, IndexedTable aeroC System.out.format("CCDB RICH PARA DO_MIRROR_HADS %8d \n", reco_constants.DO_MIRROR_HADS); System.out.format("CCDB RICH PARA DO_CURVED_AERO %8d \n", reco_constants.DO_CURVED_AERO); + System.out.format("CCDB RICH PARA USE_ELECTRON_ANGLES %8d \n", reco_constants.USE_ELECTRON_ANGLES); + System.out.format("CCDB RICH PARA USE_PIXEL_PROPERTIES %8d \n \n", reco_constants.USE_PIXEL_PROPERTIES); + System.out.format("CCDB RICH PARA GOODHIT_FRAC %8.4f \n", reco_constants.GOODHIT_FRAC); System.out.format("CCDB RICH PARA RICH_DCMATCH_CUT %8.4f \n", reco_constants.RICH_DCMATCH_CUT); System.out.format("CCDB RICH PARA RICH_HITMATCH_RMS %8.4f \n", reco_constants.RICH_HITMATCH_RMS); @@ -495,12 +583,12 @@ public void init_GeoConstantsCCDB(IndexedTable paraConstants, IndexedTable aeroC int lla = ccdb_ila[im]; int cco = ccdb_ico[im]; - double dx = (double) misaConstants.getIntValue("dx", 4, lla, cco); - double dy = (double) misaConstants.getIntValue("dy", 4, lla, cco); - double dz = (double) misaConstants.getIntValue("dz", 4, lla, cco); - double thx = (double) misaConstants.getIntValue("dthx", 4, lla, cco); - double thy = (double) misaConstants.getIntValue("dthy", 4, lla, cco); - double thz = (double) misaConstants.getIntValue("dthz", 4, lla, cco); + double dx = (double) misaConstants.getDoubleValue("dx", 4, lla, cco); + double dy = (double) misaConstants.getDoubleValue("dy", 4, lla, cco); + double dz = (double) misaConstants.getDoubleValue("dz", 4, lla, cco); + double thx = (double) misaConstants.getDoubleValue("dthx", 4, lla, cco); + double thy = (double) misaConstants.getDoubleValue("dthy", 4, lla, cco); + double thz = (double) misaConstants.getDoubleValue("dthz", 4, lla, cco); // the rotation is assumed to be in the component local ref system int ila = tool_ila[im]; @@ -509,6 +597,8 @@ public void init_GeoConstantsCCDB(IndexedTable paraConstants, IndexedTable aeroC layer_misa_angle[ila][ico].add( new Vector3D(thx*ascale, thy*ascale, thz*ascale)); if(debugMode>=1 && reco_constants.RICH_DEBUG>0){ + //System.out.format("QUA QUA %4d %4d %d %d %7.2f %7.2f %7.2f %7.2f %7.2f \n",ila,ico,lla,cco,dx,dy,dz, + // layer_misa_shift[ila][ico].mag(),layer_misa_angle[ila][ico].mag()*reco_constants.MRAD); if(layer_misa_shift[ila][ico].mag()>0 || layer_misa_angle[ila][ico].mag()>0){ System.out.format("CCDB RICH MISA ila %4d ico %3d (%4d %3d) shift %s angle %s \n", lla,cco, ila,ico, layer_misa_shift[ila][ico].toStringBrief(3), layer_misa_angle[ila][ico].toStringBrief(3)); @@ -520,7 +610,7 @@ public void init_GeoConstantsCCDB(IndexedTable paraConstants, IndexedTable aeroC /* - * AEROGEL OPTCIS + * AEROGEL NOMINAL OPTCIS */ int nco[] = {16,22,31,31}; @@ -528,7 +618,19 @@ public void init_GeoConstantsCCDB(IndexedTable paraConstants, IndexedTable aeroC for (int ico=0; ico=1 && reco_constants.RICH_DEBUG>0)System.out.format("CCDB RICH AERO ila %4d ico %3d n = %8.5f pla = %8.2f\n", 201+ila, ico+1, aero_refi[ila][ico], aero_plan[ila][ico]); + if(debugMode>=2 && reco_constants.RICH_DEBUG>0)System.out.format("CCDB RICH AERO ila %4d ico %3d n = %8.5f pla = %8.2f\n", 201+ila, ico+1, aero_refi[ila][ico], aero_plan[ila][ico]); + } + } + + if(debugMode>=2){ + int ndo[] = {16,22,32,32}; + for (int ila=0; ila<4; ila++){ + for (int ico=0; ico0){ return aero_schele_dir[ila][ico][iqua]; @@ -2050,11 +2152,32 @@ public double get_sChElectron(int ila, int ico, int iqua, int irefle) { return 0.0; } + + //------------------------------ + public double get_PixelGain(int ipmt, int ich) { return pixel_gain[ipmt][ich]; } + //------------------------------ + + //------------------------------ + public double get_PixelEff(int ipmt, int ich) { return pixel_eff[ipmt][ich]; } + //------------------------------ + + //------------------------------ + public int get_PixelFlag(int ipmt, int ich) { return pixel_flag[ipmt][ich]; } + //------------------------------ + + //------------------------------ + public double get_PixelMtime(int ipmt, int ich) { return pixel_mtime[ipmt][ich]; } + //------------------------------ + + //------------------------------ + public double get_PixelStime(int ipmt, int ich) { return pixel_stime[ipmt][ich]; } + //------------------------------ + //------------------------------ public double get_ChElectron(int ila, int ico, int iqua, int irefle) { //------------------------------ - if(get_Constants().CHANGLES_FROM_ELECTRON==1){ + if(get_Constants().USE_ELECTRON_ANGLES==1){ if(irefle==0){ if(aero_chele_dir[ila][ico][iqua]>0){ return aero_chele_dir[ila][ico][iqua]; diff --git a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHio.java b/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHio.java index 3ee098ce3a..4e7359d5cd 100644 --- a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHio.java +++ b/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHio.java @@ -43,10 +43,6 @@ public void clear_Banks(DataEvent event) { event.removeBank("RICH::response"); if(debugMode==1)System.out.format("Remove RICH::response from event \n"); } - if(event.hasBank("RICH::ringCher")){ - event.removeBank("RICH::ringCher"); - if(debugMode==1)System.out.format("Remove RICH::ringCher from event \n"); - } if(event.hasBank("RICH::hadrons")){ event.removeBank("RICH::hadrons"); if(debugMode==1)System.out.format("Remove RICH::hadrons from event \n"); @@ -55,6 +51,14 @@ public void clear_Banks(DataEvent event) { event.removeBank("RICH::photons"); if(debugMode==1)System.out.format("Remove RICH::photons from event \n"); } + if(event.hasBank("RICH::ringCher")){ + event.removeBank("RICH::ringCher"); + if(debugMode==1)System.out.format("Remove RICH::ringCher from event \n"); + } + if(event.hasBank("RICH::hadCher")){ + event.removeBank("RICH::hadCher"); + if(debugMode==1)System.out.format("Remove RICH::hadCher from event \n"); + } } From 28a26915990ae94d13bfa08c1cc17ab2d3ee67dd Mon Sep 17 00:00:00 2001 From: mcontalb Date: Thu, 20 Feb 2020 20:24:16 +0100 Subject: [PATCH 211/235] fix quadrant definition --- .../java/org/jlab/geom/prim/Vector3D.java | 8 +- .../java/org/jlab/rec/rich/RICHLayer.java | 139 +++++++++++++++--- .../java/org/jlab/rec/rich/RICHParticle.java | 14 +- .../main/java/org/jlab/rec/rich/RICHio.java | 2 +- 4 files changed, 132 insertions(+), 31 deletions(-) diff --git a/common-tools/clas-geometry/src/main/java/org/jlab/geom/prim/Vector3D.java b/common-tools/clas-geometry/src/main/java/org/jlab/geom/prim/Vector3D.java index fe0a5a9416..e6c838e183 100644 --- a/common-tools/clas-geometry/src/main/java/org/jlab/geom/prim/Vector3D.java +++ b/common-tools/clas-geometry/src/main/java/org/jlab/geom/prim/Vector3D.java @@ -436,10 +436,10 @@ public void rotate(Vector3D vector, double angle) { vector.add(A); vector.add(B); vector.setMag(m); - System.out.println(Math.toDegrees(angle)); - System.out.println(A); - System.out.println(B); - System.out.println(vector); + //System.out.println(Math.toDegrees(angle)); + //System.out.println(A); + //System.out.println(B); + //System.out.println(vector); } /** diff --git a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHLayer.java b/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHLayer.java index 5d9a9c7f0d..5041e21dc9 100644 --- a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHLayer.java +++ b/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHLayer.java @@ -21,6 +21,9 @@ public class RICHLayer extends ArrayList { * A layer in the RICH consists of an array of components */ + private static double MRAD = 1000.; + private static double RAD = 180./Math.PI; + private int id; // layer id private String name; // layer name @@ -427,6 +430,120 @@ public Vector3D get_SurfBary(int icompo, Vector3D vers){ } + //------------------------------ + public int get_TileQuadrant(int Nqua, int icompo, Point3D point, ArrayList verts) { + //------------------------------ + + int debugMode = 0; + + Shape3D surf = get_TrackingSurf(icompo); + Vector3D vers = new Vector3D(vinside.multiply(-1.)); + Point3D surfb = toPoint3D(get_SurfBary(icompo, vers)); + + if(debugMode==1)System.out.format(" \n"); + for(int i=0; i %s \n",i,j,v0.toStringBrief(2)); + if(debugMode==1)System.out.format(" stpx %3d %3d --> %s \n",i,j,stpx.toStringBrief(2)); + if(debugMode==1)System.out.format(" vb %3d %3d --> %s \n",i,j,vb.toStringBrief(2)); + if(debugMode==1)System.out.format(" vcross %3d %3d --> %s \n",i,j,vcross.toStringBrief(2)); + if(debugMode==1)System.out.format(" vspy %3d %3d --> %s \n",i,j,stpy.toStringBrief(2)); + if(debugMode==1)System.out.format(" vbary %3d %3d --> %s \n",i,j,vbary.toStringBrief(2)); + + found=1; + + } + } + } + + Vector3D step = new Vector3D(0.,0.,0.); + Vector3D vtx = new Vector3D(0.,0.,0.); + step.add(stpx); + step.add(stpy); + step.scale(-1.); + double phi = step.phi()*RAD; + if(debugMode==1)System.out.format(" step --> %s %7.2f\n",step.toStringBrief(2),phi); + + if(phi>0 && phi<=90) { + vtx = v0.toVector3D(); + } + if(phi>-180 && phi<=-90) { + vtx = (vbary.sub(step)).clone(); + stpx.scale(-1); + stpy.scale(-1); + } + if(phi>90 && phi<=180) { + vcross.rotate(step,90/RAD); + vtx = (vbary.add(step)).clone(); + stpx.scale(-1); + } + if(phi>-90 && phi<=0) { + vcross.rotate(step,-90/RAD); + vtx = (vbary.add(step)).clone(); + stpy.scale(-1); + } + + Vector3D diff = vtx.toPoint3D().vectorTo(point); + Vector3D prox = diff.projection(stpx); + Vector3D proy = diff.projection(stpy); + double dx = prox.mag(); + double dy = proy.mag(); + double ddx = dx/20*Nqua; + double ddy = dy/20*Nqua; + + double th = diff.theta(); + double ph = prox.theta(); + + int idx = (int) ddx; + int idy = (int) ddy; + + if(debugMode==1)System.out.format(" angles %7.2f %7.2f \n",th,ph); + if(debugMode==1)System.out.format(" diff --> %s\n",diff.toStringBrief(2)); + if(debugMode==1)System.out.format(" prox --> %s\n",prox.toStringBrief(2)); + if(debugMode==1)System.out.format(" proy --> %s\n",proy.toStringBrief(2)); + if(debugMode==1)System.out.format(" vtx --> %s\n",vtx.toStringBrief(2)); + if(debugMode==1)System.out.format(" point --> %s --> %7.2f %7.2f %7.2f %7.2f %4d %4d\n",point.toStringBrief(2), dx,dy,ddx,ddy,idx,idy); + + return idy*Nqua+idx; + } + //------------------------------ public int get_Quadrant(int Nqua, int icompo, Point3D point){ //------------------------------ @@ -438,28 +555,14 @@ public int get_Quadrant(int Nqua, int icompo, Point3D point){ int Nqua2 = (int) Math.pow(Nqua,2); - if(debugMode>=1)System.out.format(" Get %d quadrant for compo %d point %s\n", Nqua2,icompo,point.toStringBrief(2)); + if(debugMode>=1)System.out.format(" Get %d quadrant for compo %d ilay %d point %s\n", Nqua2,icompo,id, point.toStringBrief(2)); Shape3D surf = get_TrackingSurf(icompo); Vector3D vers = new Vector3D(vinside.multiply(-1.)); - Point3D bary = toPoint3D(get_SurfBary(icompo, vers)); + int iqua = get_TileQuadrant(Nqua, icompo, point, select_Vertexes(surf, vers)); - Point3D vtx = null; - for(Point3D v: select_Vertexes(surf, vers)){ - if( (v.y()-bary.y()>0) && (v.x()-bary.x()>0) ) vtx = v; - if(debugMode>=1)System.out.format(" --> tets %s \n",v.toStringBrief(2)); - } - - int iqua = -1; - if(vtx!=null){ - if(debugMode>=1)System.out.format(" vtx choice %s \n", vtx.toStringBrief(2)); - double dx = (vtx.x()-point.x())/20*Nqua; - double dy = (vtx.y()-point.y())/20*Nqua; - int idx = (int) dx; - int idy = (int) dy; - iqua = idy*Nqua+idx; - if(debugMode>=1)System.out.format("Calc idx %7.2f %d idy %7.2f %d --> %d \n", dx,idx, dy,idy, iqua); - } + if(iqua<0)iqua=0; + if(iqua>Nqua2)iqua=Nqua2; return iqua; diff --git a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHParticle.java b/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHParticle.java index 0260ced87a..e09e8f348e 100644 --- a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHParticle.java +++ b/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHParticle.java @@ -48,7 +48,7 @@ public class RICHParticle { public Vector3d lab_emission = null; public int ilay_emission = -1; public int ico_emission = -1; - public int qua_emission = -1; + public int iqua_emission = -1; public float refi_emission = 0; public double chele_emission[] = {0.0, 0.0, 0.0}; public double schele_emission[] = {0.0, 0.0, 0.0}; @@ -528,21 +528,19 @@ public boolean find_aerogel_points(RICHTool tool){ // take the downstream aerogel tile as the one with largest number of phtoons and average emission point ilay_emission = exit.get_layer(); ico_emission = exit.get_component(); - if(debugMode>=1)System.out.format(" AERO lay %3d ico %3d \n",ilay_emission,ico_emission); refi_emission = tool.get_Component(ilay_emission,ico_emission).get_index(); - qua_emission = tool.get_Layer(ilay_emission).get_Quadrant(3, ico_emission, entrance.get_pos()); - for(int iref=0; iref<3; iref++)chele_emission[iref] = tool.get_ChElectron(ilay_emission, ico_emission, qua_emission, iref); - for(int iref=0; iref<3; iref++)schele_emission[iref] = tool.get_sChElectron(ilay_emission, ico_emission, qua_emission, iref); + iqua_emission = tool.get_Layer(ilay_emission).get_Quadrant(5, ico_emission, entrance.get_pos()); + if(debugMode>=1)System.out.format(" AERO lay %3d ico %3d qua %3d \n",ilay_emission,ico_emission,iqua_emission); + + for(int iref=0; iref<3; iref++)chele_emission[iref] = tool.get_ChElectron(ilay_emission, ico_emission, iqua_emission, iref); + for(int iref=0; iref<3; iref++)schele_emission[iref] = tool.get_sChElectron(ilay_emission, ico_emission, iqua_emission, iref); set_changle(); RotAxis = aero_normal.cross(Vector3d.Z_ONE).normalized(); RotAngle = aero_normal.angle(Vector3d.Z_ONE); - if(debugMode>=1){ - System.out.format(" Qua %d %f \n",CLASpid,meas_hit.x); - } if(start_time==0.0)start_time = traced.get_time() - meas_hit.distance(aero_middle)/get_beta(CLASpid)/(PhysicsConstants.speedOfLight()); if(debugMode>=3){ diff --git a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHio.java b/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHio.java index 4e7359d5cd..63a324e942 100644 --- a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHio.java +++ b/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHio.java @@ -275,7 +275,7 @@ public void write_HadCherBank(DataEvent event, RICHEvent richevent, RICHConstant bankHads.setShort("emilay", i, (short) had.ilay_emission); bankHads.setShort("emico", i, (short) had.ico_emission); - bankHads.setShort("emqua", i, (short) had.qua_emission); + bankHads.setShort("emqua", i, (short) had.iqua_emission); bankHads.setFloat("mchi2", i, (float) had.traced.get_machi2()); bankHads.setFloat("ch_min", i, (float) had.minChAngle(0)); From 09a0af339408f815cdcde4405cae6998d374286f Mon Sep 17 00:00:00 2001 From: Raffaella De Vita Date: Thu, 20 Feb 2020 15:45:44 -0500 Subject: [PATCH 212/235] DC trajectories: dropped FMT planes temporarily and add track selection based on vertex --- .../src/main/java/org/jlab/rec/dc/Constants.java | 6 ++++-- .../main/java/org/jlab/rec/dc/track/Track.java | 7 +++++++ .../org/jlab/rec/dc/trajectory/Trajectory.java | 5 ++++- .../rec/dc/trajectory/TrajectorySurfaces.java | 15 +++++++-------- .../main/java/org/jlab/service/dc/DCTBEngine.java | 4 ++-- 5 files changed, 24 insertions(+), 13 deletions(-) diff --git a/reconstruction/dc/src/main/java/org/jlab/rec/dc/Constants.java b/reconstruction/dc/src/main/java/org/jlab/rec/dc/Constants.java index 06ac940d89..f87d4d80f4 100644 --- a/reconstruction/dc/src/main/java/org/jlab/rec/dc/Constants.java +++ b/reconstruction/dc/src/main/java/org/jlab/rec/dc/Constants.java @@ -316,6 +316,8 @@ public static double getT2D() { return Constants.T2D; } - - + // geometry constants not yet read from CCDB of from geometry services + public static double htccRadius=175; + public static double ltccPlane=653.09; + } diff --git a/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/Track.java b/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/Track.java index ef1b3d67c7..7bae226c0e 100755 --- a/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/Track.java +++ b/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/Track.java @@ -6,6 +6,7 @@ import java.util.List; import org.jlab.geom.prim.Point3D; import org.jlab.geom.prim.Vector3D; +import org.jlab.rec.dc.Constants; import org.jlab.rec.dc.hit.FittedHit; import org.jlab.rec.dc.segment.Segment; import org.jlab.rec.dc.trajectory.StateVec; @@ -381,6 +382,12 @@ public List getHitsOnTrack() { return _hitsOnTrack; } + + public boolean isGood() { + boolean isGood=true; + if(this._trakOrig.distance(0, 0, 0)>Constants.htccRadius) isGood=false; + return isGood; + } /** * Basic track info */ diff --git a/reconstruction/dc/src/main/java/org/jlab/rec/dc/trajectory/Trajectory.java b/reconstruction/dc/src/main/java/org/jlab/rec/dc/trajectory/Trajectory.java index c5716b0089..d641c1a2b7 100644 --- a/reconstruction/dc/src/main/java/org/jlab/rec/dc/trajectory/Trajectory.java +++ b/reconstruction/dc/src/main/java/org/jlab/rec/dc/trajectory/Trajectory.java @@ -6,6 +6,7 @@ import org.jlab.detector.base.DetectorLayer; import org.jlab.detector.base.DetectorType; import org.jlab.geom.prim.Vector3D; +import org.jlab.rec.dc.Constants; import org.jlab.rec.dc.cross.Cross; @@ -264,12 +265,14 @@ public void calcTrajectory(int id, Swim dcSwim, double x, double y, double z, d int dir = 1; //HTCC: swim to sphere and save end point - double[] trkParsCheren = dcSwim.SwimToSphere(175.); +// System.out.println("New track " + x + " " + y + " " + z); + double[] trkParsCheren = dcSwim.SwimToSphere(Constants.htccRadius); if(trkParsCheren==null) return; this.FillTrajectory(id, trajectory, trkParsCheren, trkParsCheren[6], trkParsCheren[7], DetectorType.HTCC, 1); pathLen = trkParsCheren[6]; iBdl = trkParsCheren[7]; // System.out.println( "HTCC" + " " + trkParsCheren[0] + " " + trkParsCheren[1] + " " + trkParsCheren[2] + " " + trkParsCheren[6] + " " + trkParsCheren[7]); + int is = _Sector-1; // loop over surfaces: Target, FMT, DC, LTCC, FTOF, ECAL diff --git a/reconstruction/dc/src/main/java/org/jlab/rec/dc/trajectory/TrajectorySurfaces.java b/reconstruction/dc/src/main/java/org/jlab/rec/dc/trajectory/TrajectorySurfaces.java index 88c63e26ef..6505fa47a1 100644 --- a/reconstruction/dc/src/main/java/org/jlab/rec/dc/trajectory/TrajectorySurfaces.java +++ b/reconstruction/dc/src/main/java/org/jlab/rec/dc/trajectory/TrajectorySurfaces.java @@ -63,7 +63,6 @@ public void LoadSurfaces(double targetPosition, double targetLength, double d = 0; Vector3D n; for(int is =0; is<6; is++) { - int index =0; System.out.println(" CREATING SURFACES FOR SECTOR "+(is+1)); this._DetectorPlanes.add(new ArrayList()); @@ -72,12 +71,12 @@ public void LoadSurfaces(double targetPosition, double targetLength, this._DetectorPlanes.get(is).add(new Surface(DetectorType.TARGET, DetectorLayer.TARGET_DOWNSTREAM, targetPosition+targetLength/2, 0., 0., 1.)); this._DetectorPlanes.get(is).add(new Surface(DetectorType.TARGET, DetectorLayer.TARGET_CENTER, targetPosition, 0., 0., 1.)); - //add FMT - for(int i=0;i<6;i++) { - d = FVT_Z1stlayer+i*FVT_Interlayer; - this._DetectorPlanes.get(is).add(new Surface(DetectorType.FMT, i+1, d, 0., 0., 1.)); - } - index=7; // end of MM + HTCC(7) +// //add FMT +// for(int i=0;i<6;i++) { +// d = FVT_Z1stlayer+i*FVT_Interlayer; +// this._DetectorPlanes.get(is).add(new Surface(DetectorType.FMT, i+1, d, 0., 0., 1.)); +// } + // Add DC //n = this.RotateFromTSCtoLabC(0,0,1, is+1).toVector3D(); // don't rotate to the lab @@ -106,7 +105,7 @@ public void LoadSurfaces(double targetPosition, double targetLength, d = P.dot(n); this._DetectorPlanes.get(is).add(new Surface(DetectorType.FTOF, DetectorLayer.FTOF1A, -d, -n.x(), -n.y(), -n.z())); //LTCC - this._DetectorPlanes.get(is).add(new Surface(DetectorType.LTCC,1, 653.09, -n.x(), -n.y(), -n.z())); + this._DetectorPlanes.get(is).add(new Surface(DetectorType.LTCC,1, Constants.ltccPlane, -n.x(), -n.y(), -n.z())); //PCAL int superLayer = (int) ((DetectorLayer.PCAL_V-1)/3); int localLayer = DetectorLayer.PCAL_Z+1; diff --git a/reconstruction/dc/src/main/java/org/jlab/service/dc/DCTBEngine.java b/reconstruction/dc/src/main/java/org/jlab/service/dc/DCTBEngine.java index e3e58eb512..3a48ef3dbb 100755 --- a/reconstruction/dc/src/main/java/org/jlab/service/dc/DCTBEngine.java +++ b/reconstruction/dc/src/main/java/org/jlab/service/dc/DCTBEngine.java @@ -247,8 +247,7 @@ public boolean processDataEvent(DataEvent event) { Point3D VTCS = crosses.get(0).getCoordsInSector( TrackArray[i].get_Vtx0().x(), TrackArray[i].get_Vtx0().y(), TrackArray[i].get_Vtx0().z()); TrackArray[i].set_CovMat(kFit.propagateToVtx(crosses.get(0).get_Sector(), VTCS.z())); - - trkcands.add(TrackArray[i]); + if(TrackArray[i].isGood()) trkcands.add(TrackArray[i]); } } @@ -259,6 +258,7 @@ public boolean processDataEvent(DataEvent event) { // track found int trkId = 1; + System.out.println("Creating Trajectories for new event with " + trkcands.size() + " tracks"); if(trkcands.size()>0) { //trkcandFinder.removeOverlappingTracks(trkcands); // remove overlaps From 835c272d6dc24c2f8084d07bcdab84f24e491d65 Mon Sep 17 00:00:00 2001 From: Raffaella De Vita Date: Thu, 20 Feb 2020 15:49:40 -0500 Subject: [PATCH 213/235] removed printout --- .../dc/src/main/java/org/jlab/service/dc/DCTBEngine.java | 1 - 1 file changed, 1 deletion(-) diff --git a/reconstruction/dc/src/main/java/org/jlab/service/dc/DCTBEngine.java b/reconstruction/dc/src/main/java/org/jlab/service/dc/DCTBEngine.java index 3a48ef3dbb..dd299d8d00 100755 --- a/reconstruction/dc/src/main/java/org/jlab/service/dc/DCTBEngine.java +++ b/reconstruction/dc/src/main/java/org/jlab/service/dc/DCTBEngine.java @@ -258,7 +258,6 @@ public boolean processDataEvent(DataEvent event) { // track found int trkId = 1; - System.out.println("Creating Trajectories for new event with " + trkcands.size() + " tracks"); if(trkcands.size()>0) { //trkcandFinder.removeOverlappingTracks(trkcands); // remove overlaps From c4cda1054d24a0c1a965619608d204b8a6949919 Mon Sep 17 00:00:00 2001 From: baltzell Date: Fri, 21 Feb 2020 14:15:34 -0500 Subject: [PATCH 214/235] propagate new CVT track status to REC::Track --- .../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 1668b21b49..51020f8904 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 @@ -574,6 +574,7 @@ public static List readCentralDetectorTracks(DataEvent event, St track.setPath(bank.getFloat("pathlength", row)); track.setNDF(bank.getInt("ndf",row)); track.setchi2(bank.getFloat("chi2",row)); + track.setStatus(bank.getShort("status",row)); //track.addCTOFPoint(x,y,z); Vector3D hc_vec = DetectorData.readVector(bank, row, "c_x", "c_y", "c_z"); From 34d1d7dc0455b1d278a42b34f6886c5641969103 Mon Sep 17 00:00:00 2001 From: Raffaella De Vita Date: Fri, 21 Feb 2020 21:08:42 -0500 Subject: [PATCH 215/235] fix to flag for un-swimmable tracks --- .../src/main/java/org/jlab/clas/swimtools/Swim.java | 3 ++- .../src/main/java/org/jlab/rec/dc/trajectory/Trajectory.java | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/common-tools/swim-tools/src/main/java/org/jlab/clas/swimtools/Swim.java b/common-tools/swim-tools/src/main/java/org/jlab/clas/swimtools/Swim.java index c9f0ac9d4e..db7149ca84 100644 --- a/common-tools/swim-tools/src/main/java/org/jlab/clas/swimtools/Swim.java +++ b/common-tools/swim-tools/src/main/java/org/jlab/clas/swimtools/Swim.java @@ -328,6 +328,7 @@ public double[] SwimToPlaneLab(double z_cm) { } private void checkR(double _x0, double _y0, double _z0) { + this.SwimUnPhys=false; if(Math.sqrt(_x0*_x0 + _y0*_y0)>this._rMax || Math.sqrt(_x0*_x0 + _y0*_y0 + _z0*_z0)>this._maxPathLength) this.SwimUnPhys=true; @@ -500,7 +501,7 @@ public double[] SwimToSphere(double Rad) { if(this.SwimUnPhys==true) return null; SphericalBoundarySwimStopper stopper = new SphericalBoundarySwimStopper(Rad); - + SwimTrajectory st = PC.CF.swim(_charge, _x0, _y0, _z0, _pTot, _theta, _phi, stopper, _maxPathLength, stepSize, 0.0005); if(st==null) diff --git a/reconstruction/dc/src/main/java/org/jlab/rec/dc/trajectory/Trajectory.java b/reconstruction/dc/src/main/java/org/jlab/rec/dc/trajectory/Trajectory.java index d641c1a2b7..cf8f0bb6b1 100644 --- a/reconstruction/dc/src/main/java/org/jlab/rec/dc/trajectory/Trajectory.java +++ b/reconstruction/dc/src/main/java/org/jlab/rec/dc/trajectory/Trajectory.java @@ -324,7 +324,7 @@ else if(surface.getDetectorType()==DetectorType.FMT) { dcSwim.SetSwimParameters(trkParsCheren[0], trkParsCheren[1], trkParsCheren[2], trkParsCheren[3], trkParsCheren[4], trkParsCheren[5], q); dir=1; } - + // Swim in the lab for all detectors that are not DC trkPars = dcSwim.SwimToPlaneBoundary(surface.get_d(), new Vector3D(surface.get_nx(),surface.get_ny(),surface.get_nz()),dir); @@ -338,7 +338,7 @@ else if(surface.getDetectorType()==DetectorType.FMT) { //System.out.println(" Failed swim"); return; } - + // System.out.println(surface.getDetectorType().getName() + " " + surface.getDetectorLayer() + " " + trkPars[0] + " " + trkPars[1] + " " + trkPars[2] + " " + trkPars[6] + " " + trkPars[7]); // if surface correspond to target, invert unit vector before is saved and calculate manually the pathlength From 85f722b6a8e48530353f97df0bb1e8487a816f6a Mon Sep 17 00:00:00 2001 From: Raffaella De Vita Date: Mon, 24 Feb 2020 22:05:21 -0500 Subject: [PATCH 216/235] FT: fix to time matching between hodoscope and calorimeter --- .../ft/src/main/java/org/jlab/rec/ft/FTEventBuilder.java | 3 ++- .../ft/src/main/java/org/jlab/rec/ft/FTParticle.java | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEventBuilder.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEventBuilder.java index e6ef7fecd6..cd048b7393 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEventBuilder.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTEventBuilder.java @@ -2,6 +2,7 @@ import java.util.ArrayList; import java.util.List; +import org.jlab.clas.pdg.PhysicsConstants; import org.jlab.detector.calib.utils.ConstantsManager; import org.jlab.io.base.DataBank; import org.jlab.io.base.DataEvent; @@ -140,7 +141,7 @@ public List initFTparticles(List responses) { track.setEnergy(responses.get(i).getEnergy()); track.setPosition(responses.get(i).getPosition()); track.setDirection(); - track.setTime(responses.get(i).getTime() - responses.get(i).getPosition().mag() / 29.97); + track.setTime(responses.get(i).getTime() - responses.get(i).getPosition().mag() / PhysicsConstants.speedOfLight()); track.setCalorimeterIndex(responses.get(i).getId()); track.setHodoscopeIndex(-1); track.setTrackerIndex(-1); diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTParticle.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTParticle.java index be26d101cc..2c7b5faf79 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTParticle.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTParticle.java @@ -1,6 +1,7 @@ package org.jlab.rec.ft; import java.util.List; +import org.jlab.clas.pdg.PhysicsConstants; import org.jlab.geom.prim.Line3D; import org.jlab.geom.prim.Vector3D; import org.jlab.utils.groups.IndexedTable; @@ -11,7 +12,7 @@ public class FTParticle { private int _ID; // track ID private int _Charge; // 0/1 for photon/electron - private double _Time; // time of impact on the FT + private double _Time; // time of the particle at the vertex private double _Energy; // total energy of the cluster including correction private Vector3D _Position = new Vector3D(); // position private Vector3D _Direction = new Vector3D(); // direction @@ -154,7 +155,7 @@ public int getDetectorHit(List hitList, String detectorType, double if(response.getAssociation()<0 && response.getType() == detectorType){ Line3D dist = cross.distance(response.getPosition().toPoint3D()); double hitdistance = dist.length(); - double timedistance = Math.abs(this.getTime()-response.getTime()); + double timedistance = Math.abs(this.getTime()-(response.getTime()-response.getPosition().mag()/PhysicsConstants.speedOfLight())); // System.out.println(" LOOP = " + loop + " distance = " + hitdistance); if(timedistance Date: Mon, 24 Feb 2020 23:21:56 -0500 Subject: [PATCH 217/235] FT: reduced time matching window --- .../ft/src/main/java/org/jlab/rec/ft/FTConstants.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTConstants.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTConstants.java index 498abf252a..bdf38ce32d 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTConstants.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTConstants.java @@ -12,7 +12,7 @@ public class FTConstants { public static final double CAL_HODO_DISTANCE_MATCHING = 3.0; // matching distance in cm - public static final double CAL_HODO_TIME_MATCHING = 8; // matching time in ns + public static final double CAL_HODO_TIME_MATCHING = 4; // matching time in ns public static final double CAL_TRK_DISTANCE_MATCHING = 1.5; // matching distance in cm public static final double CAL_TRK_TIME_MATCHING = 30; // matching time in ns TOBECORRECTED From 9ec1245af346e3323cf83753a4beedc9c31f63c1 Mon Sep 17 00:00:00 2001 From: Raffaella De Vita Date: Tue, 25 Feb 2020 14:20:46 -0500 Subject: [PATCH 218/235] FT: add constraint on hodoscope cluster size --- .../ft/src/main/java/org/jlab/rec/ft/FTConstants.java | 4 +++- .../ft/src/main/java/org/jlab/rec/ft/FTParticle.java | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTConstants.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTConstants.java index bdf38ce32d..fc51b84123 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTConstants.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTConstants.java @@ -10,9 +10,11 @@ * @author devita */ public class FTConstants { + + public static final int HODO_MIN_CLUSTER_SIZE = 2; // minimum size of hodo clusters for match to calorimeter public static final double CAL_HODO_DISTANCE_MATCHING = 3.0; // matching distance in cm - public static final double CAL_HODO_TIME_MATCHING = 4; // matching time in ns + public static final double CAL_HODO_TIME_MATCHING = 8; // matching time in ns public static final double CAL_TRK_DISTANCE_MATCHING = 1.5; // matching distance in cm public static final double CAL_TRK_TIME_MATCHING = 30; // matching time in ns TOBECORRECTED diff --git a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTParticle.java b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTParticle.java index 2c7b5faf79..cda4624fa1 100644 --- a/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTParticle.java +++ b/reconstruction/ft/src/main/java/org/jlab/rec/ft/FTParticle.java @@ -154,7 +154,7 @@ public int getDetectorHit(List hitList, String detectorType, double FTResponse response = hitList.get(loop); if(response.getAssociation()<0 && response.getType() == detectorType){ Line3D dist = cross.distance(response.getPosition().toPoint3D()); - double hitdistance = dist.length(); + double hitdistance = dist.length(); double timedistance = Math.abs(this.getTime()-(response.getTime()-response.getPosition().mag()/PhysicsConstants.speedOfLight())); // System.out.println(" LOOP = " + loop + " distance = " + hitdistance); if(timedistance hitList, String detectorType, double } } } + if(bestIndex>-1) { + if(hitList.get(bestIndex).getSize() Date: Tue, 25 Feb 2020 17:45:14 -0500 Subject: [PATCH 219/235] EB FT test thresholds updated for new cluster selection --- validation/advanced-tests/src/eb/EBTwoTrackTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/validation/advanced-tests/src/eb/EBTwoTrackTest.java b/validation/advanced-tests/src/eb/EBTwoTrackTest.java index 063f97a21a..0d13051307 100644 --- a/validation/advanced-tests/src/eb/EBTwoTrackTest.java +++ b/validation/advanced-tests/src/eb/EBTwoTrackTest.java @@ -487,7 +487,7 @@ private void checkResultsFT() { System.out.println(String.format("FT gEff = %.3f",gEff)); System.out.println(String.format("FD hEff = %.3f",hEff)); System.out.println("#############################################################"); - if (ftPDG==11) assertEquals(eEff>0.78,true); + if (ftPDG==11) assertEquals(eEff>0.77,true); else if (ftPDG==22) assertEquals(gEff>0.88,true); assertEquals(hEff>0.62,true); } From 7dbe7ad70c26142159153fe776812c509ae9f891 Mon Sep 17 00:00:00 2001 From: Pierre Chatagnon <33055626+PChatagnon@users.noreply.github.com> Date: Wed, 26 Feb 2020 15:03:32 +0100 Subject: [PATCH 220/235] Update layer gap --- .../src/main/java/org/jlab/rec/cnd/constants/Parameters.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reconstruction/cnd/src/main/java/org/jlab/rec/cnd/constants/Parameters.java b/reconstruction/cnd/src/main/java/org/jlab/rec/cnd/constants/Parameters.java index cb27614da2..b0280913be 100755 --- a/reconstruction/cnd/src/main/java/org/jlab/rec/cnd/constants/Parameters.java +++ b/reconstruction/cnd/src/main/java/org/jlab/rec/cnd/constants/Parameters.java @@ -18,7 +18,7 @@ public class Parameters { public static final double R0 = 28.92; // radius of inner-most surface of CND paddle (cm) public static final double Thickness = 3.08; // thickness of each paddle (cm) - public static final double LayerGap = 0.01; // radial gap between surfaces of paddles in neighbouring layers (cm) + public static final double LayerGap = 1.0; // radial gap between surfaces of paddles in neighbouring layers (cm) public static final double BlockSlice = 360./SectNum; // azimuthal angle subtended by each sector public static final double[] PLength = new double[LayNum] ; // Paddle length in each layer (cm) From 8fcc77a2d00d80b856171b56d029cd405cb55533 Mon Sep 17 00:00:00 2001 From: Pierre Chatagnon <33055626+PChatagnon@users.noreply.github.com> Date: Wed, 26 Feb 2020 15:20:42 +0100 Subject: [PATCH 221/235] Update Parameters.java Corrected units and value --- .../main/java/org/jlab/rec/cnd/constants/Parameters.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/reconstruction/cnd/src/main/java/org/jlab/rec/cnd/constants/Parameters.java b/reconstruction/cnd/src/main/java/org/jlab/rec/cnd/constants/Parameters.java index b0280913be..7b2d5aefee 100755 --- a/reconstruction/cnd/src/main/java/org/jlab/rec/cnd/constants/Parameters.java +++ b/reconstruction/cnd/src/main/java/org/jlab/rec/cnd/constants/Parameters.java @@ -16,9 +16,9 @@ public class Parameters { public static final int LayNum = 3; // Number of layer public static final int CompNum = 2; // Number of components (paddles) in each layer, sector - public static final double R0 = 28.92; // radius of inner-most surface of CND paddle (cm) - public static final double Thickness = 3.08; // thickness of each paddle (cm) - public static final double LayerGap = 1.0; // radial gap between surfaces of paddles in neighbouring layers (cm) + public static final double R0 = 28.92; // not used // radius of inner-most surface of CND paddle (cm) + public static final double Thickness = 3.08; // not used // thickness of each paddle (cm) + public static final double LayerGap = 1.0; // IN MM // radial gap between surfaces of paddles in neighbouring layers (cm) public static final double BlockSlice = 360./SectNum; // azimuthal angle subtended by each sector public static final double[] PLength = new double[LayNum] ; // Paddle length in each layer (cm) From 6823a5547ac96752583a8b6372186f63f3b79f89 Mon Sep 17 00:00:00 2001 From: Raffaella De Vita Date: Wed, 26 Feb 2020 23:02:23 -0500 Subject: [PATCH 222/235] version bump, updated kpp-plots and mon12, new rich bank added to schemas --- build-coatjava.sh | 2 +- common-tools/clas-analysis/pom.xml | 14 +++++++------- common-tools/clas-detector/pom.xml | 10 +++++----- common-tools/clas-eventmerger/pom.xml | 10 +++++----- common-tools/clas-geometry/pom.xml | 4 ++-- common-tools/clas-io/pom.xml | 6 +++--- common-tools/clas-jcsg/pom.xml | 8 ++++---- common-tools/clas-math/pom.xml | 4 ++-- common-tools/clas-physics/pom.xml | 4 ++-- common-tools/clas-reco/pom.xml | 14 +++++++------- common-tools/clas-utils/pom.xml | 4 ++-- common-tools/cnuphys/ced/pom.xml | 8 ++++---- common-tools/cnuphys/magfield/pom.xml | 2 +- common-tools/cnuphys/swimmer/pom.xml | 2 +- common-tools/coat-lib/deployDistribution.sh | 2 +- common-tools/coat-lib/pom.xml | 20 ++++++++++---------- common-tools/parent/pom.xml | 2 +- common-tools/pom.xml | 4 ++-- common-tools/swim-tools/pom.xml | 6 +++--- etc/bankdefs/util/bankSplit.py | 4 ++-- external-dependencies/KPP-Plots-3.1.jar | Bin 146222 -> 0 bytes external-dependencies/KPP-Plots-3.2.jar | Bin 0 -> 157842 bytes external-dependencies/clas12mon-3.1.jar | Bin 177216 -> 189702 bytes parent/pom.xml | 2 +- pom.xml | 4 ++-- reconstruction/band/pom.xml | 2 +- reconstruction/cnd/pom.xml | 2 +- reconstruction/cvt/pom.xml | 10 +++++----- reconstruction/dc/pom.xml | 12 ++++++------ reconstruction/eb/pom.xml | 10 +++++----- reconstruction/ec/pom.xml | 14 +++++++------- reconstruction/ft/pom.xml | 8 ++++---- reconstruction/fvt/pom.xml | 6 +++--- reconstruction/htcc/pom.xml | 8 ++++---- reconstruction/ltcc/pom.xml | 6 +++--- reconstruction/pom.xml | 4 ++-- reconstruction/rich/pom.xml | 8 ++++---- reconstruction/rtpc/pom.xml | 6 +++--- reconstruction/tof/pom.xml | 4 ++-- 39 files changed, 118 insertions(+), 118 deletions(-) delete mode 100644 external-dependencies/KPP-Plots-3.1.jar create mode 100644 external-dependencies/KPP-Plots-3.2.jar diff --git a/build-coatjava.sh b/build-coatjava.sh index c38f5d205f..bf11ae5644 100755 --- a/build-coatjava.sh +++ b/build-coatjava.sh @@ -66,7 +66,7 @@ cp external-dependencies/vecmath-1.3.1-2.jar coatjava/lib/clas/ mkdir -p coatjava/lib/utils cp external-dependencies/jclara-4.3-SNAPSHOT.jar coatjava/lib/utils cp external-dependencies/clas12mon-3.1.jar coatjava/lib/utils -cp external-dependencies/KPP-Plots-3.1.jar coatjava/lib/utils +cp external-dependencies/KPP-Plots-3.2.jar coatjava/lib/utils #cp external-dependencies/jaw-1.0.jar coatjava/lib/utils mkdir -p coatjava/lib/services diff --git a/common-tools/clas-analysis/pom.xml b/common-tools/clas-analysis/pom.xml index 0b057359fb..3ac9ebfea6 100644 --- a/common-tools/clas-analysis/pom.xml +++ b/common-tools/clas-analysis/pom.xml @@ -3,14 +3,14 @@ 4.0.0 org.jlab.clas clas-analysis - 6b.5.1-SNAPSHOT + 6b.5.2-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 6b.5.1-SNAPSHOT + 6b.5.2-SNAPSHOT @@ -30,31 +30,31 @@ org.jlab.clas clas-utils - 6b.5.1-SNAPSHOT + 6b.5.2-SNAPSHOT org.jlab.clas clas-physics - 6b.5.1-SNAPSHOT + 6b.5.2-SNAPSHOT org.jlab.clas clas-io - 6b.5.1-SNAPSHOT + 6b.5.2-SNAPSHOT org.jlab.clas clas-geometry - 6b.5.1-SNAPSHOT + 6b.5.2-SNAPSHOT org.jlab.clas clas-detector - 6b.5.1-SNAPSHOT + 6b.5.2-SNAPSHOT diff --git a/common-tools/clas-detector/pom.xml b/common-tools/clas-detector/pom.xml index c6bc6fec66..81a9215770 100644 --- a/common-tools/clas-detector/pom.xml +++ b/common-tools/clas-detector/pom.xml @@ -3,14 +3,14 @@ 4.0.0 org.jlab.clas clas-detector - 6b.5.1-SNAPSHOT + 6b.5.2-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 6b.5.1-SNAPSHOT + 6b.5.2-SNAPSHOT @@ -30,7 +30,7 @@ org.jlab.clas clas-utils - 6b.5.1-SNAPSHOT + 6b.5.2-SNAPSHOT @@ -42,13 +42,13 @@ org.jlab.clas clas-io - 6b.5.1-SNAPSHOT + 6b.5.2-SNAPSHOT org.jlab.clas clas-geometry - 6b.5.1-SNAPSHOT + 6b.5.2-SNAPSHOT diff --git a/common-tools/clas-eventmerger/pom.xml b/common-tools/clas-eventmerger/pom.xml index d04a08b1dc..63f0abb208 100644 --- a/common-tools/clas-eventmerger/pom.xml +++ b/common-tools/clas-eventmerger/pom.xml @@ -2,14 +2,14 @@ 4.0.0 clas-eventmerger - 6b.5.1-SNAPSHOT + 6b.5.2-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 6b.5.1-SNAPSHOT + 6b.5.2-SNAPSHOT @@ -29,19 +29,19 @@ org.jlab.clas clas-utils - 6b.5.1-SNAPSHOT + 6b.5.2-SNAPSHOT org.jlab.clas clas-io - 6b.5.1-SNAPSHOT + 6b.5.2-SNAPSHOT org.jlab.clas clas-geometry - 6b.5.1-SNAPSHOT + 6b.5.2-SNAPSHOT diff --git a/common-tools/clas-geometry/pom.xml b/common-tools/clas-geometry/pom.xml index 7afb1eb8fc..6ea856cccc 100644 --- a/common-tools/clas-geometry/pom.xml +++ b/common-tools/clas-geometry/pom.xml @@ -3,14 +3,14 @@ 4.0.0 org.jlab.clas clas-geometry - 6b.5.1-SNAPSHOT + 6b.5.2-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 6b.5.1-SNAPSHOT + 6b.5.2-SNAPSHOT diff --git a/common-tools/clas-io/pom.xml b/common-tools/clas-io/pom.xml index a68621c5a7..91d66e7d71 100644 --- a/common-tools/clas-io/pom.xml +++ b/common-tools/clas-io/pom.xml @@ -3,14 +3,14 @@ 4.0.0 org.jlab.clas clas-io - 6b.5.1-SNAPSHOT + 6b.5.2-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 6b.5.1-SNAPSHOT + 6b.5.2-SNAPSHOT @@ -75,7 +75,7 @@ org.jlab.clas clas-utils - 6b.5.1-SNAPSHOT + 6b.5.2-SNAPSHOT diff --git a/common-tools/clas-jcsg/pom.xml b/common-tools/clas-jcsg/pom.xml index 983aff52ca..68bb3020c5 100644 --- a/common-tools/clas-jcsg/pom.xml +++ b/common-tools/clas-jcsg/pom.xml @@ -3,14 +3,14 @@ 4.0.0 org.jlab.clas clas-jcsg - 6b.5.1-SNAPSHOT + 6b.5.2-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 6b.5.1-SNAPSHOT + 6b.5.2-SNAPSHOT @@ -40,12 +40,12 @@ org.jlab.clas clas-geometry - 6b.5.1-SNAPSHOT + 6b.5.2-SNAPSHOT org.jlab.clas clas-detector - 6b.5.1-SNAPSHOT + 6b.5.2-SNAPSHOT java3d diff --git a/common-tools/clas-math/pom.xml b/common-tools/clas-math/pom.xml index c2b02119b3..c5aaf1454e 100644 --- a/common-tools/clas-math/pom.xml +++ b/common-tools/clas-math/pom.xml @@ -3,14 +3,14 @@ 4.0.0 org.jlab.clas clas-math - 6b.5.1-SNAPSHOT + 6b.5.2-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 6b.5.1-SNAPSHOT + 6b.5.2-SNAPSHOT diff --git a/common-tools/clas-physics/pom.xml b/common-tools/clas-physics/pom.xml index 6417657bf7..89c7963dea 100644 --- a/common-tools/clas-physics/pom.xml +++ b/common-tools/clas-physics/pom.xml @@ -4,7 +4,7 @@ org.jlab.clas clas-physics - 6b.5.1-SNAPSHOT + 6b.5.2-SNAPSHOT jar @@ -23,7 +23,7 @@ org.jlab.clas clas12rec ../../parent/pom.xml - 6b.5.1-SNAPSHOT + 6b.5.2-SNAPSHOT diff --git a/common-tools/clas-reco/pom.xml b/common-tools/clas-reco/pom.xml index d54ddc464c..bf7074c658 100644 --- a/common-tools/clas-reco/pom.xml +++ b/common-tools/clas-reco/pom.xml @@ -3,14 +3,14 @@ 4.0.0 org.jlab.clas clas-reco - 6b.5.1-SNAPSHOT + 6b.5.2-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 6b.5.1-SNAPSHOT + 6b.5.2-SNAPSHOT @@ -67,7 +67,7 @@ org.jlab.clas clas-math - 6b.5.1-SNAPSHOT + 6b.5.2-SNAPSHOT %s \n",i,j,v0.toStringBrief(2)); - if(debugMode==1)System.out.format(" stpx %3d %3d --> %s \n",i,j,stpx.toStringBrief(2)); - if(debugMode==1)System.out.format(" vb %3d %3d --> %s \n",i,j,vb.toStringBrief(2)); - if(debugMode==1)System.out.format(" vcross %3d %3d --> %s \n",i,j,vcross.toStringBrief(2)); - if(debugMode==1)System.out.format(" vspy %3d %3d --> %s \n",i,j,stpy.toStringBrief(2)); - if(debugMode==1)System.out.format(" vbary %3d %3d --> %s \n",i,j,vbary.toStringBrief(2)); + if(debugMode==1){ + System.out.format(" v0 %3d %3d --> %s \n",i,j,v0.toStringBrief(2)); + System.out.format(" stpx %3d %3d --> %s \n",i,j,stpx.toStringBrief(2)); + System.out.format(" vb %3d %3d --> %s \n",i,j,vb.toStringBrief(2)); + System.out.format(" vcross %3d %3d --> %s \n",i,j,vcross.toStringBrief(2)); + System.out.format(" vspy %3d %3d --> %s \n",i,j,stpy.toStringBrief(2)); + System.out.format(" vbary %3d %3d --> %s \n",i,j,vbary.toStringBrief(2)); + } found=1; @@ -523,6 +530,17 @@ public int get_TileQuadrant(int Nqua, int icompo, Point3D point, ArrayList %s\n",diff.toStringBrief(2)); - if(debugMode==1)System.out.format(" prox --> %s\n",prox.toStringBrief(2)); - if(debugMode==1)System.out.format(" proy --> %s\n",proy.toStringBrief(2)); - if(debugMode==1)System.out.format(" vtx --> %s\n",vtx.toStringBrief(2)); - if(debugMode==1)System.out.format(" point --> %s --> %7.2f %7.2f %7.2f %7.2f %4d %4d\n",point.toStringBrief(2), dx,dy,ddx,ddy,idx,idy); + if(debugMode==1){ + System.out.format(" angles %7.2f %7.2f \n",th,ph); + System.out.format(" diff --> %s\n",diff.toStringBrief(2)); + System.out.format(" prox --> %s\n",prox.toStringBrief(2)); + System.out.format(" proy --> %s\n",proy.toStringBrief(2)); + System.out.format(" vtx --> %s\n",vtx.toStringBrief(2)); + System.out.format(" point --> %s --> %7.2f %7.2f %7.2f %7.2f %4d %4d\n",point.toStringBrief(2), dx,dy,ddx,ddy,idx,idy); + if(idx>=Nqua || idy>=Nqua)System.out.format(" ECCOLO x %7.2f %4d y %7.2f %4d \n",ddx,idx,ddy,idy); + } + + // to stay within limits + if(idx<0)idx=0; + if(idx>Nqua-1)idx=Nqua-1; + if(idy<0)idy=0; + if(idy>Nqua-1)idy=Nqua-1; return idy*Nqua+idx; } @@ -553,17 +580,15 @@ public int get_Quadrant(int Nqua, int icompo, Point3D point){ */ int debugMode = 0; + if(Nqua<0 || Nqua>15)Nqua=1; int Nqua2 = (int) Math.pow(Nqua,2); - if(debugMode>=1)System.out.format(" Get %d quadrant for compo %d ilay %d point %s\n", Nqua2,icompo,id, point.toStringBrief(2)); + if(debugMode>=1)System.out.format(" Get %d %d quadrant for compo %d ilay %d point %s\n", Nqua, Nqua2,icompo,id, point.toStringBrief(2)); Shape3D surf = get_TrackingSurf(icompo); - Vector3D vers = new Vector3D(vinside.multiply(-1.)); + Vector3D vers = new Vector3D(vinside); int iqua = get_TileQuadrant(Nqua, icompo, point, select_Vertexes(surf, vers)); - if(iqua<0)iqua=0; - if(iqua>Nqua2)iqua=Nqua2; - return iqua; } diff --git a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHParticle.java b/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHParticle.java index e09e8f348e..e59f1d5ab4 100644 --- a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHParticle.java +++ b/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHParticle.java @@ -48,6 +48,7 @@ public class RICHParticle { public Vector3d lab_emission = null; public int ilay_emission = -1; public int ico_emission = -1; + public int ico_entrance = -1; public int iqua_emission = -1; public float refi_emission = 0; public double chele_emission[] = {0.0, 0.0, 0.0}; @@ -170,8 +171,8 @@ private void set_changle() { if(debugMode>=1) { System.out.format(" Create RICH particle mom %8.2f \n",momentum); - for(int ir=0; ir<3; ir++) System.out.format(" --> Dir pr %7.2f k %7.2f pi %7.2f e %7.2f --> limi %7.2f %7.2f res %7.2f\n", - ChAngle[3][ir]*MRAD,ChAngle[2][ir]*MRAD,ChAngle[1][ir]*MRAD,ChAngle[0][ir]*MRAD,minChAngle(0)*MRAD,maxChAngle(0)*MRAD,sChAngle[0]*MRAD); + for(int ir=0; ir<3; ir++) System.out.format(" --> Refle %3d pr %7.2f k %7.2f pi %7.2f e %7.2f --> limi %7.2f %7.2f res %7.2f\n",ir, + ChAngle[3][ir]*MRAD,ChAngle[2][ir]*MRAD,ChAngle[1][ir]*MRAD,ChAngle[0][ir]*MRAD,minChAngle(ir)*MRAD,maxChAngle(ir)*MRAD,sChAngle[ir]*MRAD); } } @@ -297,6 +298,7 @@ public double calibrated_ChAngle(int pid, int irefle){ double beta = get_beta(pid); double cose = Math.cos(chele_emission[irefle]); + // ATT: beta=1 assumed for electron if(beta>0) arg = 1.0/beta*cose; if(debugMode>=1) System.out.format(" Expected Ch Angle %7.2f %8.4f beta %8.4f n %7.3f arg %8.4f\n",chele_emission[irefle]*1000, get_mass(pid),beta,refi_emission, Math.acos(arg)*MRAD); @@ -528,10 +530,18 @@ public boolean find_aerogel_points(RICHTool tool){ // take the downstream aerogel tile as the one with largest number of phtoons and average emission point ilay_emission = exit.get_layer(); ico_emission = exit.get_component(); + ico_entrance = entrance.get_component(); refi_emission = tool.get_Component(ilay_emission,ico_emission).get_index(); - iqua_emission = tool.get_Layer(ilay_emission).get_Quadrant(5, ico_emission, entrance.get_pos()); - if(debugMode>=1)System.out.format(" AERO lay %3d ico %3d qua %3d \n",ilay_emission,ico_emission,iqua_emission); + int Nqua = tool.get_Constants().QUADRANT_NUMBER; + iqua_emission = tool.get_Layer(ilay_emission).get_Quadrant(Nqua, ico_emission, exit.get_pos()); + + if(debugMode>=1){ + System.out.format(" AERO lay %3d ico %3d qua %3d \n",ilay_emission,ico_emission,iqua_emission); + if(entrance.get_layer()!=ilay_emission || entrance.get_component()!=ico_emission) + System.out.format(" AERO CROSS ilay %4d %4d ico %4d %4d \n",entrance.get_layer(),ilay_emission,entrance.get_component(),ico_emission); + } + for(int iref=0; iref<3; iref++)chele_emission[iref] = tool.get_ChElectron(ilay_emission, ico_emission, iqua_emission, iref); for(int iref=0; iref<3; iref++)schele_emission[iref] = tool.get_sChElectron(ilay_emission, ico_emission, iqua_emission, iref); diff --git a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHTool.java b/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHTool.java index 842d135877..17c4d864e5 100644 --- a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHTool.java +++ b/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHTool.java @@ -409,13 +409,13 @@ public void init_TimeConstantsCCDB(IndexedTable timewalkConstants, IndexedTable int itil = (int) ico/225; int iqua = (int) ico - itil*225; - aero_chele_dir[ila][itil][iqua] = (float) cheleConstants.getDoubleValue("ch_dir", 4,201+ila,ico+2) / 1000.; - aero_chele_lat[ila][itil][iqua] = (float) cheleConstants.getDoubleValue("ch_lat", 4,201+ila,ico+2) / 1000.; - aero_chele_spe[ila][itil][iqua] = (float) cheleConstants.getDoubleValue("ch_spe", 4,201+ila,ico+2) / 1000.; + aero_chele_dir[ila][itil][iqua] = (float) cheleConstants.getDoubleValue("ch_dir", 4,201+ila,ico+1); + aero_chele_lat[ila][itil][iqua] = (float) cheleConstants.getDoubleValue("ch_lat", 4,201+ila,ico+1); + aero_chele_spe[ila][itil][iqua] = (float) cheleConstants.getDoubleValue("ch_spe", 4,201+ila,ico+1); - aero_schele_dir[ila][itil][iqua] = (float) cheleConstants.getDoubleValue("s_dir", 4,201+ila,ico+2) / 1000.; - aero_schele_lat[ila][itil][iqua] = (float) cheleConstants.getDoubleValue("s_lat", 4,201+ila,ico+2) / 1000.; - aero_schele_spe[ila][itil][iqua] = (float) cheleConstants.getDoubleValue("s_spe", 4,201+ila,ico+2) / 1000.; + aero_schele_dir[ila][itil][iqua] = (float) cheleConstants.getDoubleValue("s_dir", 4,201+ila,ico+1); + aero_schele_lat[ila][itil][iqua] = (float) cheleConstants.getDoubleValue("s_lat", 4,201+ila,ico+1); + aero_schele_spe[ila][itil][iqua] = (float) cheleConstants.getDoubleValue("s_spe", 4,201+ila,ico+1); if(debugMode>=1 && reco_constants.RICH_DEBUG>0){ if( (itil<2 || itil>ndo[ila]-3) && (iqua==0 || iqua==224)) { @@ -505,6 +505,8 @@ public void init_GeoConstantsCCDB(IndexedTable paraConstants, IndexedTable aeroC reco_constants.USE_ELECTRON_ANGLES = paraConstants.getIntValue("flag16", 4, 0, 0); reco_constants.USE_PIXEL_PROPERTIES = paraConstants.getIntValue("flag17", 4, 0, 0); + reco_constants.SAVE_THROWS = paraConstants.getIntValue("flag18", 4, 0, 0); + reco_constants.QUADRANT_NUMBER = paraConstants.getIntValue("flag19", 4, 0, 0); reco_constants.GOODHIT_FRAC = paraConstants.getDoubleValue("par1", 4, 0, 0); reco_constants.RICH_DCMATCH_CUT = paraConstants.getDoubleValue("par2", 4, 0, 0); @@ -520,44 +522,47 @@ public void init_GeoConstantsCCDB(IndexedTable paraConstants, IndexedTable aeroC //TODO: check //reco_constants.RICH_DEBUG = 1.0; + //reco_constants.QUADRANT_NUMBER = 5; //reco_constants.USE_ELECTRON_ANGLES = 1; //reco_constants.USE_PIXEL_PROPERTIES = 1; //if(debugMode>=1 && reco_constants.RICH_DEBUG>0){ //MC if(debugMode>=1){ System.out.format(" \n"); - System.out.format("CCDB RICH PARA DO_MISALIGNMENT %8d \n", reco_constants.DO_MISALIGNMENT); - System.out.format("CCDB RICH PARA FORCE_DC_MATCH %8d \n", reco_constants.FORCE_DC_MATCH); - System.out.format("CCDB RICH PARA MISA_RICH_REF %8d \n", reco_constants.MISA_RICH_REF); - System.out.format("CCDB RICH PARA MISA_PMT_PIVOT %8d \n", reco_constants.MISA_PMT_PIVOT); - System.out.format("CCDB RICH PARA APPLY_SURVEY %8d \n", reco_constants.APPLY_SURVEY); - - System.out.format("CCDB RICH PARA DO_ANALYTIC %8d \n", reco_constants.DO_ANALYTIC); - System.out.format("CCDB RICH PARA THROW_ELECTRONS %8d \n", reco_constants.THROW_ELECTRONS); - System.out.format("CCDB RICH PARA THROW_PIONS %8d \n", reco_constants.THROW_PIONS); - System.out.format("CCDB RICH PARA THROW_KAONS %8d \n", reco_constants.THROW_KAONS); - System.out.format("CCDB RICH PARA THROW_PROTONS %8d \n", reco_constants.THROW_PROTONS); - System.out.format("CCDB RICH PARA THROW_PHOTON_NUMBER %8d \n", reco_constants.THROW_PHOTON_NUMBER); - System.out.format("CCDB RICH PARA TRACE_PHOTONS %8d \n", reco_constants.TRACE_PHOTONS); - - System.out.format("CCDB RICH PARA REDO_RICH_RECO %8d \n", reco_constants.REDO_RICH_RECO); - System.out.format("CCDB RICH PARA DO_MIRROR_HADS %8d \n", reco_constants.DO_MIRROR_HADS); - System.out.format("CCDB RICH PARA DO_CURVED_AERO %8d \n", reco_constants.DO_CURVED_AERO); - - System.out.format("CCDB RICH PARA USE_ELECTRON_ANGLES %8d \n", reco_constants.USE_ELECTRON_ANGLES); - System.out.format("CCDB RICH PARA USE_PIXEL_PROPERTIES %8d \n \n", reco_constants.USE_PIXEL_PROPERTIES); - - System.out.format("CCDB RICH PARA GOODHIT_FRAC %8.4f \n", reco_constants.GOODHIT_FRAC); - System.out.format("CCDB RICH PARA RICH_DCMATCH_CUT %8.4f \n", reco_constants.RICH_DCMATCH_CUT); - System.out.format("CCDB RICH PARA RICH_HITMATCH_RMS %8.4f \n", reco_constants.RICH_HITMATCH_RMS); - System.out.format("CCDB RICH PARA RICH_DIRECT_RMS %8.4f \n", reco_constants.RICH_DIRECT_RMS); - System.out.format("CCDB RICH PARA SHOW_PROGRESS_INTERVAL %8.4f \n", reco_constants.SHOW_PROGRESS_INTERVAL); - System.out.format("CCDB RICH PARA THROW_ASSOCIATION_CUT %8.4f \n", reco_constants.THROW_ASSOCIATION_CUT); - - System.out.format("CCDB RICH PARA RICH_DEBUG %8.4f \n", reco_constants.RICH_DEBUG); - System.out.format("CCDB RICH PARA RICH_TIME_RMS %8.4f \n", reco_constants.RICH_TIME_RMS); - System.out.format("CCDB RICH PARA MISA_SHIFT_SCALE %8.4f \n", reco_constants.MISA_SHIFT_SCALE); - System.out.format("CCDB RICH PARA MISA_ANGLE_SCALE %8.4f \n", reco_constants.MISA_ANGLE_SCALE); + System.out.format("CCDB RICH PARA DO_MISALIGNMENT %9d \n", reco_constants.DO_MISALIGNMENT); + System.out.format("CCDB RICH PARA FORCE_DC_MATCH %9d \n", reco_constants.FORCE_DC_MATCH); + System.out.format("CCDB RICH PARA MISA_RICH_REF %9d \n", reco_constants.MISA_RICH_REF); + System.out.format("CCDB RICH PARA MISA_PMT_PIVOT %9d \n", reco_constants.MISA_PMT_PIVOT); + System.out.format("CCDB RICH PARA APPLY_SURVEY %9d \n", reco_constants.APPLY_SURVEY); + + System.out.format("CCDB RICH PARA DO_ANALYTIC %9d \n", reco_constants.DO_ANALYTIC); + System.out.format("CCDB RICH PARA THROW_ELECTRONS %9d \n", reco_constants.THROW_ELECTRONS); + System.out.format("CCDB RICH PARA THROW_PIONS %9d \n", reco_constants.THROW_PIONS); + System.out.format("CCDB RICH PARA THROW_KAONS %9d \n", reco_constants.THROW_KAONS); + System.out.format("CCDB RICH PARA THROW_PROTONS %9d \n", reco_constants.THROW_PROTONS); + System.out.format("CCDB RICH PARA THROW_PHOTON_NUMBER %9d \n", reco_constants.THROW_PHOTON_NUMBER); + System.out.format("CCDB RICH PARA TRACE_PHOTONS %9d \n", reco_constants.TRACE_PHOTONS); + + System.out.format("CCDB RICH PARA REDO_RICH_RECO %9d \n", reco_constants.REDO_RICH_RECO); + System.out.format("CCDB RICH PARA DO_MIRROR_HADS %9d \n", reco_constants.DO_MIRROR_HADS); + System.out.format("CCDB RICH PARA DO_CURVED_AERO %9d \n", reco_constants.DO_CURVED_AERO); + + System.out.format("CCDB RICH PARA USE_ELECTRON_ANGLES %9d \n", reco_constants.USE_ELECTRON_ANGLES); + System.out.format("CCDB RICH PARA USE_PIXEL_PROPERTIES %9d \n", reco_constants.USE_PIXEL_PROPERTIES); + System.out.format("CCDB RICH PARA SAVE_THROWS %9d \n", reco_constants.SAVE_THROWS); + System.out.format("CCDB RICH PARA QUADRANT_NUMBER %9d \n \n", reco_constants.QUADRANT_NUMBER); + + System.out.format("CCDB RICH PARA GOODHIT_FRAC %9.4f \n", reco_constants.GOODHIT_FRAC); + System.out.format("CCDB RICH PARA RICH_DCMATCH_CUT %9.4f \n", reco_constants.RICH_DCMATCH_CUT); + System.out.format("CCDB RICH PARA RICH_HITMATCH_RMS %9.4f \n", reco_constants.RICH_HITMATCH_RMS); + System.out.format("CCDB RICH PARA RICH_DIRECT_RMS %9.4f \n", reco_constants.RICH_DIRECT_RMS); + System.out.format("CCDB RICH PARA SHOW_PROGRESS_INTERVAL %9.4f \n", reco_constants.SHOW_PROGRESS_INTERVAL); + System.out.format("CCDB RICH PARA THROW_ASSOCIATION_CUT %9.4f \n", reco_constants.THROW_ASSOCIATION_CUT); + + System.out.format("CCDB RICH PARA RICH_DEBUG %9.4f \n", reco_constants.RICH_DEBUG); + System.out.format("CCDB RICH PARA RICH_TIME_RMS %9.4f \n", reco_constants.RICH_TIME_RMS); + System.out.format("CCDB RICH PARA MISA_SHIFT_SCALE %9.4f \n", reco_constants.MISA_SHIFT_SCALE); + System.out.format("CCDB RICH PARA MISA_ANGLE_SCALE %9.4f \n", reco_constants.MISA_ANGLE_SCALE); System.out.format(" \n"); } diff --git a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHio.java b/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHio.java index 63a324e942..07380ec5da 100644 --- a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHio.java +++ b/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHio.java @@ -100,7 +100,7 @@ public void write_CherenkovBanks(DataEvent event, RICHEvent richevent, RICHConst if(richevent.get_nHad()>0)write_HadronBank(event, richevent); - if(richevent.get_nPho()>0)write_PhotonBank(event, richevent); + if(richevent.get_nPho()>0)write_PhotonBank(event, richevent, recopar); if(richevent.get_nPho()>0)write_RingCherBank(event, richevent, recopar); @@ -252,9 +252,9 @@ public void write_HadCherBank(DataEvent event, RICHEvent richevent, RICHConstant int NHAD = richevent.get_nHad(); if(debugMode>=1)System.out.format("Creating Bank for %5d Hadrons \n", NHAD); - + if(NHAD>0) { - if(debugMode>=1)System.out.println(" --> Creating the HadCher Bank "); + if(debugMode>=1)System.out.println(" --> Creating the RICH::hadCher Bank "); DataBank bankHads = event.createBank("RICH::hadCher", NHAD); if(bankHads==null){ System.out.println("ERROR CREATING BANK : RICH::hadCher"); @@ -269,12 +269,22 @@ public void write_HadCherBank(DataEvent event, RICHEvent richevent, RICHConstant if(debugMode>0)System.out.format(" RICHio %7.2f %7.2f %5d %7.2f %9.4f %9.4f \n",had.minChAngle(0)*MRAD,had.maxChAngle(0)*MRAD, had.traced.get_BestH(),had.traced.get_RQP(),had.traced.get_ElProb(),had.traced.get_PiProb()); - bankHads.setShort("id", i ,(short) had.get_id()); - bankHads.setShort("hindex", i, (short) had.get_hit_index()); - bankHads.setShort("pindex", i, (short) had.get_ParentIndex()); - - bankHads.setShort("emilay", i, (short) had.ilay_emission); - bankHads.setShort("emico", i, (short) had.ico_emission); + if(had.get_id()>255)continue; + if(had.get_hit_index()>255)continue; + if(had.get_ParentIndex()>255)continue; + if(had.ilay_emission>255)continue; + if(had.ico_emission>255)continue; + if(had.ico_entrance>255)continue; + if(had.iqua_emission>255)continue; + if(had.traced.get_BestH()>255)continue; + + bankHads.setByte("id", i ,(byte) had.get_id()); + bankHads.setByte("hindex", i, (byte) had.get_hit_index()); + bankHads.setByte("pindex", i, (byte) had.get_ParentIndex()); + + bankHads.setByte("emilay", i, (byte) had.ilay_emission); + bankHads.setByte("emico", i, (byte) had.ico_emission); + bankHads.setByte("enico", i, (byte) had.ico_entrance); bankHads.setShort("emqua", i, (short) had.iqua_emission); bankHads.setFloat("mchi2", i, (float) had.traced.get_machi2()); @@ -285,7 +295,7 @@ public void write_HadCherBank(DataEvent event, RICHEvent richevent, RICHConstant bankHads.setFloat("ch_lat", i, (float) had.traced.get_Chlat()); bankHads.setFloat("ch_spe", i, (float) had.traced.get_Chspe()); - bankHads.setShort("best_PID", i, (short) had.traced.get_BestH()); + bankHads.setByte("best_PID", i, (byte) had.traced.get_BestH()); bankHads.setFloat("RQ_prob", i, (float) had.traced.get_RQP()); bankHads.setFloat("el_prob", i, (float) had.traced.get_ElProb()); bankHads.setFloat("pi_prob", i, (float) had.traced.get_PiProb()); @@ -303,23 +313,37 @@ public void write_RingCherBank(DataEvent event, RICHEvent richevent, RICHConstan int debugMode = 0; + int SELE = 2; + int NPHO = richevent.get_nPho(); if(debugMode>=1)System.out.format("Creating Bank for %5d Ring Cherenkovs \n", NPHO); if(NPHO!=0) { - if(debugMode>=1)System.out.println(" --> Creating the RICH::ringCher Bank "); - DataBank bankRing = event.createBank("RICH::ringCher", NPHO); + + int Nring = 0; + + for(int i = 0; i < NPHO; i++){ + RICHParticle pho = richevent.get_Photon(i); + if(pho.get_type()!=0) continue; + if(pho.analytic.get_OK()==SELE || pho.traced.get_OK()==SELE) Nring++; + } + + if(debugMode>=1)System.out.format(" --> Creating the RICH::ringCher Bank for Npho %5d Nring %5d \n",NPHO,Nring); + DataBank bankRing = event.createBank("RICH::ringCher", Nring); if(bankRing==null){ System.out.println("ERROR CREATING BANK : RICH::ringCher"); return; } - int SELE = 2; + int ientry = 0; for(int i = 0; i < NPHO; i++){ RICHParticle pho = richevent.get_Photon(i); + // consistency + if(ientry>Nring) continue; + // only reconstructed photons if(pho.get_type()!=0) continue; @@ -333,24 +357,40 @@ public void write_RingCherBank(DataEvent event, RICHEvent richevent, RICHConstan double a_etaC = pho.analytic.get_EtaC(); double t_etaC = pho.traced.get_EtaC(); + if(debugMode>=1)System.out.format(" pho %3d %3d flag %3d %3d ",i,ientry,pho.analytic.get_OK(),pho.traced.get_OK()); // skip no real Cherenkov solution - if(pho.analytic.get_OK()!=SELE && pho.traced.get_OK()!=SELE) continue; + if(pho.analytic.get_OK()==SELE || pho.traced.get_OK()==SELE){ - bankRing.setShort("id", i, (short) pho.get_id()); - bankRing.setShort("hindex", i, (short) pho.get_hit_index()); - bankRing.setShort("pindex", i, (short) had.get_ParentIndex()); + if(had.get_ParentIndex()>255)continue; + if(hit.get_anode()>255)continue; + if(pho.traced.get_nrefle()>255)continue; - bankRing.setFloat("time", i, (float) htime); - bankRing.setShort("pmt", i, (short) hit.get_pmt()); - bankRing.setShort("anode", i, (short) hit.get_anode()); + if(debugMode>=1)System.out.format(" --> store \n"); - bankRing.setFloat("apath", i, (float) pho.analytic.get_path()); - bankRing.setFloat("atime", i, (float) a_time ); - bankRing.setFloat("aEtaC", i, (float) a_etaC ); + bankRing.setShort("id", ientry, (short) pho.get_id()); + bankRing.setShort("hindex", ientry, (short) pho.get_hit_index()); + bankRing.setByte("pindex", ientry, (byte) had.get_ParentIndex()); - bankRing.setFloat("tpath", i, (float) pho.traced.get_path()); - bankRing.setFloat("ttime", i, (float) t_time ); - bankRing.setFloat("tEtaC", i, (float) t_etaC ); + bankRing.setShort("pmt", ientry, (short) hit.get_pmt()); + bankRing.setByte("anode", ientry, (byte) hit.get_anode()); + bankRing.setFloat("time", ientry, (float) htime); + + bankRing.setFloat("apath", ientry, (float) pho.analytic.get_path()); + bankRing.setFloat("atime", ientry, (float) a_time ); + bankRing.setFloat("aEtaC", ientry, (float) a_etaC ); + + bankRing.setFloat("tpath", ientry, (float) pho.traced.get_path()); + bankRing.setFloat("ttime", ientry, (float) t_time ); + bankRing.setFloat("tEtaC", ientry, (float) t_etaC ); + + bankRing.setByte("nrfl", ientry, (byte) pho.traced.get_nrefle()); + bankRing.setShort("1rfl", ientry, (short) pho.traced.get_FirstRefle()); + + ientry++; + + }else{ + if(debugMode>=1)System.out.format(" \n"); + } } event.appendBanks(bankRing); @@ -359,7 +399,7 @@ public void write_RingCherBank(DataEvent event, RICHEvent richevent, RICHConstan // ---------------- - public void write_PhotonBank(DataEvent event, RICHEvent richevent) { + public void write_PhotonBank(DataEvent event, RICHEvent richevent, RICHConstants recopar) { // ---------------- int debugMode = 0; @@ -368,57 +408,80 @@ public void write_PhotonBank(DataEvent event, RICHEvent richevent) { if(debugMode>=1)System.out.format("Creating Bank for %5d Photons \n", NPHO); if(NPHO!=0) { - if(debugMode>=1)System.out.println(" --> Creating the Photons Bank "); - DataBank bankPhos = event.createBank("RICH::photons", NPHO); + + int Nrow = 0; + + for(int i = 0; i < NPHO; i++){ + RICHParticle pho = richevent.get_Photon(i); + if(pho.get_type()==0 || recopar.SAVE_THROWS==1)Nrow++; + } + + if(debugMode>=1)System.out.format(" --> Creating the Photons Bank for Npho %4d Nrow %4d \n",NPHO,Nrow); + DataBank bankPhos = event.createBank("RICH::photons", Nrow); if(bankPhos==null){ System.out.println("ERROR CREATING BANK : RICH::photons"); return; } + int ientry = 0; + for(int i = 0; i < NPHO; i++){ RICHParticle pho = richevent.get_Photon(i); - if(debugMode>=1)System.out.format(" --> %3d %3d %3d \n",pho.get_id(),pho.get_type(),pho.get_ParentIndex()); - - bankPhos.setShort("id",i, (short) pho.get_id()); - bankPhos.setShort("type",i, (short) pho.get_type()); - bankPhos.setShort("hit_index",i,(short) pho.get_hit_index()); - bankPhos.setShort("hadron_index",i,(short) pho.get_ParentIndex()); - bankPhos.setFloat("start_time",i,(float) pho.get_start_time()); - - bankPhos.setFloat("analytic_the",i,(float) pho.analytic.get_theta()); - bankPhos.setFloat("analytic_phi",i,(float) pho.analytic.get_phi()); - bankPhos.setFloat("analytic_path",i,(float) pho.analytic.get_path()); - bankPhos.setFloat("analytic_time",i,(float) pho.analytic.get_time()); - //bankPhos.setShort("analytic_nrfl",i,(short) pho.analytic.get_nrefle()); - //bankPhos.setShort("analytic_nrfr",i,(short) pho.analytic.get_nrefra()); - - bankPhos.setFloat("analytic_EtaC",i,(float) pho.analytic.get_EtaC()); - bankPhos.setFloat("analytic_aeron",i,(float) pho.analytic.get_aeron()); - bankPhos.setFloat("analytic_elpr",i,(float) pho.analytic.get_ElProb()); - bankPhos.setFloat("analytic_pipr",i,(float) pho.analytic.get_PiProb()); - bankPhos.setFloat("analytic_kpr",i,(float) pho.analytic.get_KProb()); - bankPhos.setFloat("analytic_prpr",i,(float) pho.analytic.get_PrProb()); - bankPhos.setFloat("analytic_bgpr",i,(float) pho.analytic.get_BgProb()); - - bankPhos.setFloat("traced_the",i,(float) pho.traced.get_theta()); - bankPhos.setFloat("traced_phi",i,(float) pho.traced.get_phi()); - bankPhos.setFloat("traced_hitx",i,(float) pho.traced.get_hit().x); - bankPhos.setFloat("traced_hity",i,(float) pho.traced.get_hit().y); - bankPhos.setFloat("traced_hitz",i,(float) pho.traced.get_hit().z); - bankPhos.setFloat("traced_path",i,(float) pho.traced.get_path()); - bankPhos.setFloat("traced_time",i,(float) pho.traced.get_time()); - bankPhos.setShort("traced_nrfl",i,(short) pho.traced.get_nrefle()); - bankPhos.setShort("traced_nrfr",i,(short) pho.traced.get_nrefra()); - bankPhos.setShort("traced_1rfl",i,(short) pho.traced.get_FirstRefle()); - - bankPhos.setFloat("traced_EtaC",i,(float) pho.traced.get_EtaC()); - bankPhos.setFloat("traced_aeron",i,(float) pho.traced.get_aeron()); - bankPhos.setFloat("traced_elpr",i,(float) pho.traced.get_ElProb()); - bankPhos.setFloat("traced_pipr",i,(float) pho.traced.get_PiProb()); - bankPhos.setFloat("traced_kpr",i,(float) pho.traced.get_KProb()); - bankPhos.setFloat("traced_prpr",i,(float) pho.traced.get_PrProb()); - bankPhos.setFloat("traced_bgpr",i,(float) pho.traced.get_BgProb()); + if(debugMode>=1)System.out.format(" pho %3d %3d type %3d %3d ",i,ientry,pho.get_type(),pho.get_ParentIndex()); + + // consistency + if(ientry>Nrow) continue; + + if(pho.get_type()==0 || recopar.SAVE_THROWS==1){ + + if(debugMode>=1)System.out.format(" --> store \n"); + + bankPhos.setShort("id", ientry, (short) pho.get_id()); + bankPhos.setShort("type", ientry, (short) pho.get_type()); + bankPhos.setShort("hit_index", ientry,(short) pho.get_hit_index()); + bankPhos.setShort("hadron_index", ientry,(short) pho.get_ParentIndex()); + bankPhos.setFloat("start_time", ientry,(float) pho.get_start_time()); + + bankPhos.setFloat("analytic_the", ientry,(float) pho.analytic.get_theta()); + bankPhos.setFloat("analytic_phi", ientry,(float) pho.analytic.get_phi()); + bankPhos.setFloat("analytic_path", ientry,(float) pho.analytic.get_path()); + bankPhos.setFloat("analytic_time", ientry,(float) pho.analytic.get_time()); + //bankPhos.setShort("analytic_nrfl",ientry,(short) pho.analytic.get_nrefle()); + //bankPhos.setShort("analytic_nrfr",ientry,(short) pho.analytic.get_nrefra()); + + bankPhos.setFloat("analytic_EtaC", ientry,(float) pho.analytic.get_EtaC()); + bankPhos.setFloat("analytic_aeron", ientry,(float) pho.analytic.get_aeron()); + bankPhos.setFloat("analytic_elpr", ientry,(float) pho.analytic.get_ElProb()); + bankPhos.setFloat("analytic_pipr", ientry,(float) pho.analytic.get_PiProb()); + bankPhos.setFloat("analytic_kpr", ientry,(float) pho.analytic.get_KProb()); + bankPhos.setFloat("analytic_prpr", ientry,(float) pho.analytic.get_PrProb()); + bankPhos.setFloat("analytic_bgpr", ientry,(float) pho.analytic.get_BgProb()); + + bankPhos.setFloat("traced_the", ientry,(float) pho.traced.get_theta()); + bankPhos.setFloat("traced_phi", ientry,(float) pho.traced.get_phi()); + bankPhos.setFloat("traced_hitx", ientry,(float) pho.traced.get_hit().x); + bankPhos.setFloat("traced_hity", ientry,(float) pho.traced.get_hit().y); + bankPhos.setFloat("traced_hitz", ientry,(float) pho.traced.get_hit().z); + bankPhos.setFloat("traced_path", ientry,(float) pho.traced.get_path()); + bankPhos.setFloat("traced_time", ientry,(float) pho.traced.get_time()); + bankPhos.setShort("traced_nrfl", ientry,(short) pho.traced.get_nrefle()); + bankPhos.setShort("traced_nrfr", ientry,(short) pho.traced.get_nrefra()); + bankPhos.setShort("traced_1rfl", ientry,(short) pho.traced.get_FirstRefle()); + + bankPhos.setFloat("traced_EtaC", ientry,(float) pho.traced.get_EtaC()); + bankPhos.setFloat("traced_aeron", ientry,(float) pho.traced.get_aeron()); + bankPhos.setFloat("traced_elpr", ientry,(float) pho.traced.get_ElProb()); + bankPhos.setFloat("traced_pipr", ientry,(float) pho.traced.get_PiProb()); + bankPhos.setFloat("traced_kpr", ientry,(float) pho.traced.get_KProb()); + bankPhos.setFloat("traced_prpr", ientry,(float) pho.traced.get_PrProb()); + bankPhos.setFloat("traced_bgpr", ientry,(float) pho.traced.get_BgProb()); + + ientry++; + + }else{ + if(debugMode>=1)System.out.format(" \n"); + } } event.appendBanks(bankPhos); From e1a37597be922bed9cb9505f0822e8b6d6b389ea Mon Sep 17 00:00:00 2001 From: Raffaella De Vita Date: Wed, 4 Mar 2020 15:41:54 -0500 Subject: [PATCH 231/235] removed printout and updated bank list for schema directories --- etc/bankdefs/util/bankSplit.py | 4 ++-- .../rich/src/main/java/org/jlab/rec/rich/RICHTool.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/etc/bankdefs/util/bankSplit.py b/etc/bankdefs/util/bankSplit.py index aa9fe261c0..61d12be393 100644 --- a/etc/bankdefs/util/bankSplit.py +++ b/etc/bankdefs/util/bankSplit.py @@ -50,8 +50,8 @@ def createdirandlinks(dirname, banklist): # create dst, calibration and monitoring directories dst = ["RUN::config","RAW::epics","RAW::scaler","REC::Event","REC::Particle","REC::Calorimeter","REC::Cherenkov","REC::CovMat","REC::ForwardTagger","REC::Scintillator","REC::Track","REC::Traj","RECFT::Event","RECFT::Particle","RICH::tdc","RICH::ringCher","RICH::hadCher","RUN::scaler","HEL::flip","HEL::online","MC::Event","MC::Header","MC::Lund","MC::Particle","MC::True"] -calibration = ["BAND::adc","BAND::tdc","BAND::hits","CND::adc","CND::hits","CND::tdc","CTOF::adc","CTOF::hits","CTOF::tdc","CVTRec::Tracks","ECAL::adc","ECAL::calib","ECAL::clusters","ECAL::peaks","ECAL::tdc","FT::particles","FTCAL::adc","FTCAL::clusters","FTCAL::hits","FTHODO::adc","FTHODO::clusters","FTHODO::hits","FTOF::adc","FTOF::hits","FTOF::tdc","HEL::flip","HEL::online","HTCC::adc","HTCC::rec","LTCC::adc","LTCC::clusters","MC::Event","MC::Header","MC::Lund","MC::Particle","MC::True","RAW::epics","RAW::scaler","REC::Calorimeter","REC::Cherenkov","REC::CovMat","REC::Event","REC::ForwardTagger","REC::Particle","REC::Scintillator","REC::Track","REC::Traj","RECFT::Event","RECFT::Particle","RF::adc","RF::tdc","RICH::tdc","RICH::hits","RICH::hadCher","RICH::hadrons","RICH::photons","RUN::config","RUN::rf","RUN::scaler","RUN::trigger","TimeBasedTrkg::TBCrosses","TimeBasedTrkg::TBHits","TimeBasedTrkg::TBSegments","TimeBasedTrkg::TBSegmentTrajectory","TimeBasedTrkg::TBTracks","TimeBasedTrkg::Trajectory"] -monitoring = ["BAND::adc","BAND::tdc","BAND::hits","BMT::adc","BMTRec::Clusters","BMTRec::Crosses","BMTRec::Hits","BMTRec::LayerEffs","BST::adc","BSTRec::Clusters","BSTRec::Crosses","BSTRec::Hits","BSTRec::LayerEffs","CND::adc","CND::clusters","CND::hits","CND::tdc","CTOF::adc","CTOF::hits","CTOF::tdc","CVTRec::Tracks","CVTRec::Trajectory","ECAL::adc","ECAL::calib","ECAL::clusters","ECAL::hits","ECAL::peaks","ECAL::tdc","FT::particles","FTCAL::adc","FTCAL::clusters","FTCAL::hits","FTHODO::adc","FTHODO::clusters","FTHODO::hits","FTOF::adc","FTOF::hits","FTOF::tdc","HEL::adc","HEL::flip","HEL::online","HitBasedTrkg::HBTracks","HTCC::adc","HTCC::rec","LTCC::adc","LTCC::clusters","MC::Event","MC::Header","MC::Lund","MC::Particle","MC::True","RAW::epics","RAW::scaler","RAW::vtp","REC::Calorimeter","REC::Cherenkov","REC::CovMat","REC::Event","REC::ForwardTagger","REC::Particle","REC::Scintillator","REC::Track","REC::Traj","RECFT::Event","RECFT::Particle","RECHB::Calorimeter","RECHB::Cherenkov","RECHB::Event","RECHB::ForwardTagger","RECHB::Particle","RECHB::Scintillator","RECHB::Track","RF::adc","RF::tdc","RICH::tdc","RICH::hits","RICH::hadrons","RICH::photons","RUN::config","RUN::rf","RUN::scaler","RUN::trigger","TimeBasedTrkg::TBCrosses","TimeBasedTrkg::TBHits","TimeBasedTrkg::TBSegments","TimeBasedTrkg::TBSegmentTrajectory","TimeBasedTrkg::TBTracks","TimeBasedTrkg::Trajectory"] +calibration = ["BAND::adc","BAND::tdc","BAND::hits","CND::adc","CND::hits","CND::tdc","CTOF::adc","CTOF::hits","CTOF::tdc","CVTRec::Tracks","ECAL::adc","ECAL::calib","ECAL::clusters","ECAL::peaks","ECAL::tdc","FT::particles","FTCAL::adc","FTCAL::clusters","FTCAL::hits","FTHODO::adc","FTHODO::clusters","FTHODO::hits","FTOF::adc","FTOF::hits","FTOF::tdc","HEL::flip","HEL::online","HTCC::adc","HTCC::rec","LTCC::adc","LTCC::clusters","MC::Event","MC::Header","MC::Lund","MC::Particle","MC::True","RAW::epics","RAW::scaler","REC::Calorimeter","REC::Cherenkov","REC::CovMat","REC::Event","REC::ForwardTagger","REC::Particle","REC::Scintillator","REC::Track","REC::Traj","RECFT::Event","RECFT::Particle","RF::adc","RF::tdc","RICH::tdc","RICH::hits","RICH::hadCher","RICH::hadrons","RICH::photons","RICH::ringCher","RUN::config","RUN::rf","RUN::scaler","RUN::trigger","TimeBasedTrkg::TBCrosses","TimeBasedTrkg::TBHits","TimeBasedTrkg::TBSegments","TimeBasedTrkg::TBSegmentTrajectory","TimeBasedTrkg::TBTracks","TimeBasedTrkg::Trajectory"] +monitoring = ["BAND::adc","BAND::tdc","BAND::hits","BMT::adc","BMTRec::Clusters","BMTRec::Crosses","BMTRec::Hits","BMTRec::LayerEffs","BST::adc","BSTRec::Clusters","BSTRec::Crosses","BSTRec::Hits","BSTRec::LayerEffs","CND::adc","CND::clusters","CND::hits","CND::tdc","CTOF::adc","CTOF::hits","CTOF::tdc","CVTRec::Tracks","CVTRec::Trajectory","ECAL::adc","ECAL::calib","ECAL::clusters","ECAL::hits","ECAL::peaks","ECAL::tdc","FT::particles","FTCAL::adc","FTCAL::clusters","FTCAL::hits","FTHODO::adc","FTHODO::clusters","FTHODO::hits","FTOF::adc","FTOF::hits","FTOF::tdc","HEL::adc","HEL::flip","HEL::online","HitBasedTrkg::HBTracks","HTCC::adc","HTCC::rec","LTCC::adc","LTCC::clusters","MC::Event","MC::Header","MC::Lund","MC::Particle","MC::True","RAW::epics","RAW::scaler","RAW::vtp","REC::Calorimeter","REC::Cherenkov","REC::CovMat","REC::Event","REC::ForwardTagger","REC::Particle","REC::Scintillator","REC::Track","REC::Traj","RECFT::Event","RECFT::Particle","RECHB::Calorimeter","RECHB::Cherenkov","RECHB::Event","RECHB::ForwardTagger","RECHB::Particle","RECHB::Scintillator","RECHB::Track","RF::adc","RF::tdc","RICH::tdc","RICH::hits","RICH::hadCher","RICH::hadrons","RICH::photons","RICH::ringCher","RUN::config","RUN::rf","RUN::scaler","RUN::trigger","TimeBasedTrkg::TBCrosses","TimeBasedTrkg::TBHits","TimeBasedTrkg::TBSegments","TimeBasedTrkg::TBSegmentTrajectory","TimeBasedTrkg::TBTracks","TimeBasedTrkg::Trajectory"] ebrerun=list(dst) ebrerun.extend(["FTOF::hits","TimeBasedTrkg::TBTracks","TimeBasedTrkg::Trajectory","TimeBasedTrkg::TBCovMat","HitBasedTrkg::HBTracks","FTOF::hbhits","ECAL::clusters","CTOF::hits","CND::clusters","HTCC::rec","LTCC::clusters","ECAL::moments","CVTRec::Tracks","CVTRec::Trajectory","FT::particles","FTCAL::clusters","FTHODO::clusters","RUN:rf"]) createdirandlinks("dst/", dst) diff --git a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHTool.java b/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHTool.java index 17c4d864e5..f440c0c5df 100644 --- a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHTool.java +++ b/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHTool.java @@ -525,8 +525,8 @@ public void init_GeoConstantsCCDB(IndexedTable paraConstants, IndexedTable aeroC //reco_constants.QUADRANT_NUMBER = 5; //reco_constants.USE_ELECTRON_ANGLES = 1; //reco_constants.USE_PIXEL_PROPERTIES = 1; - //if(debugMode>=1 && reco_constants.RICH_DEBUG>0){ //MC - if(debugMode>=1){ + if(debugMode>=1 && reco_constants.RICH_DEBUG>0){ //MC + //if(debugMode>=1){ System.out.format(" \n"); System.out.format("CCDB RICH PARA DO_MISALIGNMENT %9d \n", reco_constants.DO_MISALIGNMENT); From b69d0a5d9a1edecaa6e0e708907184ef044cd443 Mon Sep 17 00:00:00 2001 From: baltzell Date: Wed, 4 Mar 2020 19:49:23 -0500 Subject: [PATCH 232/235] drop some layers from REC::Traj --- .../main/java/org/jlab/clas/detector/DetectorData.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 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 33b0c005ba..e6ec1529d1 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 @@ -383,11 +383,13 @@ public static DataBank getTracksBank(List particles, DataEvent public static DataBank getTrajectoriesBank(List particles, DataEvent event, String bank_name) { + // these are going to be dropped from REC::Traj: + // FIXME: should be HashSet instead of ArrayList Map > ignore=new HashMap<>(); - //ignore.put(DetectorType.TARGET.getDetectorId(),Arrays.asList(1,2)); - //ignore.put(DetectorType.CVT.getDetectorId(),Arrays.asList(1,2,3,4,5,6,7,8,9,10,11,12)); - //ignore.put(DetectorType.DC.getDetectorId(),Arrays.asList(6,12,18,24,30,36)); - + ignore.put(DetectorType.TARGET.getDetectorId(),Arrays.asList(1,2)); + ignore.put(DetectorType.CVT.getDetectorId(),Arrays.asList(2,4,6,8,9,10,11)); + ignore.put(DetectorType.DC.getDetectorId(),Arrays.asList(12,24,30)); + DataBank bank=null; if (bank_name!=null) { From 2d42138f5c449a24c8d0cb0d30d4f4813f386a76 Mon Sep 17 00:00:00 2001 From: ziegler Date: Thu, 5 Mar 2020 10:38:47 -0500 Subject: [PATCH 233/235] Remove bad tracks whose fit diverges resulting in NaN parameters. --- .../java/org/jlab/rec/dc/banks/RecoBankWriter.java | 9 ++++----- .../java/org/jlab/rec/dc/track/fit/KFitterDoca.java | 10 +++++++++- .../java/org/jlab/rec/dc/track/fit/StateVecsDoca.java | 2 +- .../src/main/java/org/jlab/service/dc/DCTBEngine.java | 2 +- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/reconstruction/dc/src/main/java/org/jlab/rec/dc/banks/RecoBankWriter.java b/reconstruction/dc/src/main/java/org/jlab/rec/dc/banks/RecoBankWriter.java index 57e1fff983..9c52062249 100755 --- a/reconstruction/dc/src/main/java/org/jlab/rec/dc/banks/RecoBankWriter.java +++ b/reconstruction/dc/src/main/java/org/jlab/rec/dc/banks/RecoBankWriter.java @@ -707,17 +707,16 @@ private DataBank fillTBCrossesBank(DataEvent event, List crosslist) { * @return segments bank */ private DataBank fillTBTracksBank(DataEvent event, List candlist) { - if(event.hasBank("TimeBasedTrkg::TBTracks")) { // for second pass tracking - HipoDataEvent de = (HipoDataEvent) event; + // if(event.hasBank("TimeBasedTrkg::TBTracks")) { // for second pass tracking + // HipoDataEvent de = (HipoDataEvent) event; //HipoEvent dde = de.getHipoEvent(); // HipoGroup group = dde.getGroup("TimeBasedTrkg::TBTracks"); ////event.show(); //group.show(); //dde.removeGroup("TimeBasedTrkg::TBTracks"); - } + // } DataBank bank = event.createBank("TimeBasedTrkg::TBTracks", candlist.size()); - - for (int i = 0; i < candlist.size(); i++) { + for (int i = 0; i < candlist.size(); i++) { bank.setShort("id", i, (short) candlist.get(i).get_Id()); bank.setShort("status", i, (short) (100+candlist.get(i).get_Status()*10+candlist.get(i).get_MissingSuperlayer())); bank.setByte("sector", i, (byte) candlist.get(i).get_Sector()); diff --git a/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/fit/KFitterDoca.java b/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/fit/KFitterDoca.java index 530c9582c6..3f04b2790c 100644 --- a/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/fit/KFitterDoca.java +++ b/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/fit/KFitterDoca.java @@ -160,7 +160,7 @@ public void runFitter(int sector) { this.finalStateVec = sv.trackTraj.get(svzLength - 1); this.finalCovMat = sv.trackCov.get(svzLength - 1); - + } else { this.ConvStatus = 1; } @@ -172,6 +172,8 @@ public void runFitter(int sector) { this.finalCovMat = sv.trackCov.get(svzLength - 1); } this.calcFinalChisq(sector); + if(Double.isNaN(chi2)) + this.setFitFailed = true; if(TBT==true) { if(chi2>initChi2) { // fit failed this.finalStateVec = this.initialStateVec; @@ -215,6 +217,12 @@ public Matrix filterCovMat(double[] H, Matrix Ci, double V) { } private double KFScale = 4; private void filter(int k) { + if(Double.isNaN(sv.trackTraj.get(k).x) || Double.isNaN(sv.trackTraj.get(k).y) + || Double.isNaN(sv.trackTraj.get(k).tx) ||Double.isNaN(sv.trackTraj.get(k).ty ) + || Double.isNaN(sv.trackTraj.get(k).Q)) { + this.setFitFailed = true; + return; + } if (sv.trackTraj.get(k) != null && sv.trackCov.get(k).covMat != null && k < sv.Z.length diff --git a/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/fit/StateVecsDoca.java b/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/fit/StateVecsDoca.java index 4b723bf3ea..34b2f6206f 100644 --- a/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/fit/StateVecsDoca.java +++ b/reconstruction/dc/src/main/java/org/jlab/rec/dc/track/fit/StateVecsDoca.java @@ -541,7 +541,7 @@ public class StateVec { String printInfo() { return this.k+"] = "+(float)this.x+", "+(float)this.y+", "+(float)this.z+", " - +(float)this.tx+", "+(float)this.ty+", "+(float)this.Q+" B = "+(float)this.B; + +(float)this.tx+", "+(float)this.ty+", "+(float)1./this.Q+" B = "+(float)this.B; } } /** diff --git a/reconstruction/dc/src/main/java/org/jlab/service/dc/DCTBEngine.java b/reconstruction/dc/src/main/java/org/jlab/service/dc/DCTBEngine.java index dd299d8d00..18259bd614 100755 --- a/reconstruction/dc/src/main/java/org/jlab/service/dc/DCTBEngine.java +++ b/reconstruction/dc/src/main/java/org/jlab/service/dc/DCTBEngine.java @@ -222,7 +222,7 @@ public boolean processDataEvent(DataEvent event) { // resetTrackParams(TrackArray[i], new DCSwimmer()); //} KFitterDoca kFit = new KFitterDoca(TrackArray[i], dcDetector, true, dcSwim, 0); - + StateVec fn = new StateVec(); kFit.runFitter(TrackArray[i].get(0).get_Sector()); From aba45614690b9cdca6690bd2a6003d7bcd3f3117 Mon Sep 17 00:00:00 2001 From: mcontalb Date: Thu, 5 Mar 2020 23:56:35 +0100 Subject: [PATCH 234/235] fix ray-trace matching resolution --- .../rich/src/main/java/org/jlab/rec/rich/RICHParticle.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHParticle.java b/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHParticle.java index e59f1d5ab4..465c54ed3a 100644 --- a/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHParticle.java +++ b/reconstruction/rich/src/main/java/org/jlab/rec/rich/RICHParticle.java @@ -735,7 +735,7 @@ public void find_EtaC_raytrace_steps(RICHParticle hadron, RICHTool tool) { double EtaCmin = 0.0; if(Math.abs(Cos_EtaC)<1.)EtaCmin = Math.acos(Cos_EtaC); int ntrials = 0; - while (dist > nominal_sChAngle()*100/2. && ntrials<20){ + while (dist > nominal_sChAngle()*100/10. && ntrials<20){ if(debugMode>=1){ System.out.format(" Attempt %d with the %7.1f (%7.2f) phi %7.2f EtaC %7.2f\n",ntrials, the_min*MRAD, the_min*RAD, phi_min*RAD, EtaCmin*MRAD); From e92da431f9d62fe04f86ff19483580cf7d646b76 Mon Sep 17 00:00:00 2001 From: Raffaella De Vita Date: Fri, 6 Mar 2020 10:21:47 -0500 Subject: [PATCH 235/235] version bumped to 6.5.3 --- common-tools/clas-analysis/pom.xml | 14 +++++++------- common-tools/clas-detector/pom.xml | 10 +++++----- common-tools/clas-eventmerger/pom.xml | 10 +++++----- common-tools/clas-geometry/pom.xml | 4 ++-- common-tools/clas-io/pom.xml | 6 +++--- common-tools/clas-jcsg/pom.xml | 8 ++++---- common-tools/clas-math/pom.xml | 4 ++-- common-tools/clas-physics/pom.xml | 4 ++-- common-tools/clas-reco/pom.xml | 14 +++++++------- common-tools/clas-utils/pom.xml | 4 ++-- common-tools/cnuphys/ced/pom.xml | 8 ++++---- common-tools/cnuphys/magfield/pom.xml | 2 +- common-tools/cnuphys/swimmer/pom.xml | 2 +- common-tools/coat-lib/deployDistribution.sh | 2 +- common-tools/coat-lib/pom.xml | 20 ++++++++++---------- common-tools/parent/pom.xml | 2 +- common-tools/pom.xml | 4 ++-- common-tools/swim-tools/pom.xml | 6 +++--- parent/pom.xml | 2 +- pom.xml | 4 ++-- reconstruction/band/pom.xml | 2 +- reconstruction/cnd/pom.xml | 2 +- reconstruction/cvt/pom.xml | 10 +++++----- reconstruction/dc/pom.xml | 12 ++++++------ reconstruction/eb/pom.xml | 10 +++++----- reconstruction/ec/pom.xml | 14 +++++++------- reconstruction/ft/pom.xml | 8 ++++---- reconstruction/fvt/pom.xml | 6 +++--- reconstruction/htcc/pom.xml | 8 ++++---- reconstruction/ltcc/pom.xml | 6 +++--- reconstruction/pom.xml | 4 ++-- reconstruction/rich/pom.xml | 8 ++++---- reconstruction/rtpc/pom.xml | 6 +++--- reconstruction/tof/pom.xml | 4 ++-- 34 files changed, 115 insertions(+), 115 deletions(-) diff --git a/common-tools/clas-analysis/pom.xml b/common-tools/clas-analysis/pom.xml index 3ac9ebfea6..96b5060d95 100644 --- a/common-tools/clas-analysis/pom.xml +++ b/common-tools/clas-analysis/pom.xml @@ -3,14 +3,14 @@ 4.0.0 org.jlab.clas clas-analysis - 6b.5.2-SNAPSHOT + 6.5.3-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 6b.5.2-SNAPSHOT + 6.5.3-SNAPSHOT @@ -30,31 +30,31 @@ org.jlab.clas clas-utils - 6b.5.2-SNAPSHOT + 6.5.3-SNAPSHOT org.jlab.clas clas-physics - 6b.5.2-SNAPSHOT + 6.5.3-SNAPSHOT org.jlab.clas clas-io - 6b.5.2-SNAPSHOT + 6.5.3-SNAPSHOT org.jlab.clas clas-geometry - 6b.5.2-SNAPSHOT + 6.5.3-SNAPSHOT org.jlab.clas clas-detector - 6b.5.2-SNAPSHOT + 6.5.3-SNAPSHOT diff --git a/common-tools/clas-detector/pom.xml b/common-tools/clas-detector/pom.xml index 81a9215770..bbf38fb4ea 100644 --- a/common-tools/clas-detector/pom.xml +++ b/common-tools/clas-detector/pom.xml @@ -3,14 +3,14 @@ 4.0.0 org.jlab.clas clas-detector - 6b.5.2-SNAPSHOT + 6.5.3-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 6b.5.2-SNAPSHOT + 6.5.3-SNAPSHOT @@ -30,7 +30,7 @@ org.jlab.clas clas-utils - 6b.5.2-SNAPSHOT + 6.5.3-SNAPSHOT @@ -42,13 +42,13 @@ org.jlab.clas clas-io - 6b.5.2-SNAPSHOT + 6.5.3-SNAPSHOT org.jlab.clas clas-geometry - 6b.5.2-SNAPSHOT + 6.5.3-SNAPSHOT diff --git a/common-tools/clas-eventmerger/pom.xml b/common-tools/clas-eventmerger/pom.xml index 63f0abb208..f48732911b 100644 --- a/common-tools/clas-eventmerger/pom.xml +++ b/common-tools/clas-eventmerger/pom.xml @@ -2,14 +2,14 @@ 4.0.0 clas-eventmerger - 6b.5.2-SNAPSHOT + 6.5.3-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 6b.5.2-SNAPSHOT + 6.5.3-SNAPSHOT @@ -29,19 +29,19 @@ org.jlab.clas clas-utils - 6b.5.2-SNAPSHOT + 6.5.3-SNAPSHOT org.jlab.clas clas-io - 6b.5.2-SNAPSHOT + 6.5.3-SNAPSHOT org.jlab.clas clas-geometry - 6b.5.2-SNAPSHOT + 6.5.3-SNAPSHOT diff --git a/common-tools/clas-geometry/pom.xml b/common-tools/clas-geometry/pom.xml index 6ea856cccc..908157764b 100644 --- a/common-tools/clas-geometry/pom.xml +++ b/common-tools/clas-geometry/pom.xml @@ -3,14 +3,14 @@ 4.0.0 org.jlab.clas clas-geometry - 6b.5.2-SNAPSHOT + 6.5.3-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 6b.5.2-SNAPSHOT + 6.5.3-SNAPSHOT diff --git a/common-tools/clas-io/pom.xml b/common-tools/clas-io/pom.xml index 91d66e7d71..2195813842 100644 --- a/common-tools/clas-io/pom.xml +++ b/common-tools/clas-io/pom.xml @@ -3,14 +3,14 @@ 4.0.0 org.jlab.clas clas-io - 6b.5.2-SNAPSHOT + 6.5.3-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 6b.5.2-SNAPSHOT + 6.5.3-SNAPSHOT @@ -75,7 +75,7 @@ org.jlab.clas clas-utils - 6b.5.2-SNAPSHOT + 6.5.3-SNAPSHOT diff --git a/common-tools/clas-jcsg/pom.xml b/common-tools/clas-jcsg/pom.xml index 68bb3020c5..cdcf3927af 100644 --- a/common-tools/clas-jcsg/pom.xml +++ b/common-tools/clas-jcsg/pom.xml @@ -3,14 +3,14 @@ 4.0.0 org.jlab.clas clas-jcsg - 6b.5.2-SNAPSHOT + 6.5.3-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 6b.5.2-SNAPSHOT + 6.5.3-SNAPSHOT @@ -40,12 +40,12 @@ org.jlab.clas clas-geometry - 6b.5.2-SNAPSHOT + 6.5.3-SNAPSHOT org.jlab.clas clas-detector - 6b.5.2-SNAPSHOT + 6.5.3-SNAPSHOT java3d diff --git a/common-tools/clas-math/pom.xml b/common-tools/clas-math/pom.xml index c5aaf1454e..85931a22f2 100644 --- a/common-tools/clas-math/pom.xml +++ b/common-tools/clas-math/pom.xml @@ -3,14 +3,14 @@ 4.0.0 org.jlab.clas clas-math - 6b.5.2-SNAPSHOT + 6.5.3-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 6b.5.2-SNAPSHOT + 6.5.3-SNAPSHOT diff --git a/common-tools/clas-physics/pom.xml b/common-tools/clas-physics/pom.xml index 89c7963dea..cae0f269b8 100644 --- a/common-tools/clas-physics/pom.xml +++ b/common-tools/clas-physics/pom.xml @@ -4,7 +4,7 @@ org.jlab.clas clas-physics - 6b.5.2-SNAPSHOT + 6.5.3-SNAPSHOT jar @@ -23,7 +23,7 @@ org.jlab.clas clas12rec ../../parent/pom.xml - 6b.5.2-SNAPSHOT + 6.5.3-SNAPSHOT diff --git a/common-tools/clas-reco/pom.xml b/common-tools/clas-reco/pom.xml index bf7074c658..54a85fc890 100644 --- a/common-tools/clas-reco/pom.xml +++ b/common-tools/clas-reco/pom.xml @@ -3,14 +3,14 @@ 4.0.0 org.jlab.clas clas-reco - 6b.5.2-SNAPSHOT + 6.5.3-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 6b.5.2-SNAPSHOT + 6.5.3-SNAPSHOT @@ -67,7 +67,7 @@ org.jlab.clas clas-math - 6b.5.2-SNAPSHOT + 6.5.3-SNAPSHOT