diff --git a/.containers/coatjava.Dockerfile b/.containers/coatjava.Dockerfile index dbe73116a0..513e16c0a1 100644 --- a/.containers/coatjava.Dockerfile +++ b/.containers/coatjava.Dockerfile @@ -22,4 +22,5 @@ ARG REF_NAME=development # build coatjava RUN java --version && cd /opt && \ git clone https://code.jlab.org/hallb/alert/coatjava.git && cd coatjava && \ - git fetch origin && git checkout ${REF_NAME} && ./build-coatjava.sh --quiet + git fetch origin && git checkout ${REF_NAME} && ./build-coatjava.sh --quiet && \ + ./install-clara /opt/clara diff --git a/.containers/coatjava.def b/.containers/coatjava.def new file mode 100644 index 0000000000..8dc1962ac8 --- /dev/null +++ b/.containers/coatjava.def @@ -0,0 +1,14 @@ +Bootstrap: docker +From: codecr.jlab.org/hallb/alert/coatjava/coatjava:{{ REF_NAME }} + + +%environment + export CLAS12DIR=/opt/coatjava/coatjava + +%help + This is a clas12 coatjava container used to run coatjava on HPC systems + and do rapid development. + +%labels + Author Whitney Armstrong warmstrong@anl.gov + REF_NAME {{ REF_NAME }} diff --git a/.github/workflows/maven.yml b/.github/workflows/ci.yml similarity index 80% rename from .github/workflows/maven.yml rename to .github/workflows/ci.yml index 5ec80c4110..916e9157b3 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/ci.yml @@ -23,7 +23,9 @@ defaults: env: java_version: 17 java_distribution: zulu + javadoc_version: 24 # newer than `java_version` for better javadoc groovy_version: 4.x + CCDB_CONNECTION: 'sqlite:////cvmfs/oasis.opensciencegrid.org/jlab/hallb/clas12/sw/noarch/data/ccdb/ccdb_latest.sqlite' jobs: @@ -40,11 +42,17 @@ jobs: runs-on: ${{ matrix.runner }} steps: - uses: actions/checkout@v4 - - name: Set up JDK - uses: actions/setup-java@v4 + - uses: actions/setup-java@v4 with: java-version: ${{ env.java_version }} distribution: ${{ env.java_distribution }} + - uses: cvmfs-contrib/github-action-cvmfs@v5 + with: + cvmfs_repositories: 'oasis.opensciencegrid.org' + - name: cvmfs + run: ls /cvmfs/oasis.opensciencegrid.org/jlab/hallb/clas12/sw/noarch/data/ccdb/ccdb_latest.sqlite + - name: echo CCDB_CONNECTION + run: echo $CCDB_CONNECTION - name: build run: ./build-coatjava.sh --spotbugs --unittests --quiet -T4 - name: tar # tarball to preserve permissions @@ -103,8 +111,13 @@ jobs: - uses: actions/download-artifact@v4 with: name: build_${{ matrix.runner }} + - uses: cvmfs-contrib/github-action-cvmfs@v5 + with: + cvmfs_repositories: 'oasis.opensciencegrid.org' - name: untar build run: tar xzvf coatjava.tar.gz + - name: echo CCDB_CONNECTION + run: echo $CCDB_CONNECTION - name: run test run: | cd validation/advanced-tests @@ -160,55 +173,46 @@ jobs: - name: pass run: exit 0 - # generate documentation + # documentation ############################################################################# generate_documentation: runs-on: ubuntu-latest + needs: [ build ] steps: + ### mkdocs - uses: actions/checkout@v4 - - name: Set up JDK - uses: actions/setup-java@v4 - with: - java-version: ${{ env.java_version }} - distribution: ${{ env.java_distribution }} - - name: build - run: ./build-coatjava.sh - - name: generate documentation - run: ./build-javadocs.sh - - uses: actions/upload-artifact@v4 - with: - name: javadoc - path: docs/javadoc/ - retention-days: 1 - - # deploy web pages - ############################################################################# - - collect_webpages: - if: ${{ github.ref == 'refs/heads/development' }} - needs: [ build, generate_documentation ] - runs-on: ubuntu-latest - steps: - - name: download jacoco report + - name: install mkdocs dependencies + run: python -m pip install -r docs/mkdocs/requirements.txt + - name: generate mkdocs + run: docs/mkdocs/generate.sh pages + ### jacoco + - name: download jacoco report artifact uses: actions/download-artifact@v4 with: name: jacoco_report path: pages/jacoco - - name: download javadoc documentation - uses: actions/download-artifact@v4 + ### javadoc + - name: set up JDK + uses: actions/setup-java@v4 with: - name: javadoc - path: pages/javadoc - - run: tree pages + java-version: ${{ env.javadoc_version }} + distribution: ${{ env.java_distribution }} + - name: build coatjava + run: ./build-coatjava.sh + - name: generate javadoc documentation + run: | + ./build-javadocs.sh + mv docs/javadoc pages/ + ### upload artifacts - uses: actions/upload-pages-artifact@v3 with: - retention-days: 1 + retention-days: 7 path: pages/ deploy_web_pages: if: ${{ github.ref == 'refs/heads/development' }} - needs: collect_webpages + needs: [ generate_documentation ] permissions: pages: write id-token: write diff --git a/.gitignore b/.gitignore index 77c0fd6ff3..900361e56b 100644 --- a/.gitignore +++ b/.gitignore @@ -32,6 +32,12 @@ hs_err_pid* *.iml .idea +# eclipse JDT language server +.classpath +.factorypath +.project +.settings + # no log files: *.log *.evio diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index da31aa64a8..51bd6a7da6 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -9,6 +9,7 @@ workflow: variables: KUBERNETES_MEMORY_LIMIT: "8Gi" + REF_NAME: ${CI_COMMIT_REF_NAME} default: image: ubuntu:noble @@ -69,3 +70,34 @@ shared_for_alert_tests: project: hallb/alert/atof/shared_for_alert strategy: depend +coatjava:singularity: + image: eicweb.phy.anl.gov:4567/containers/image_recipes/ubuntu_dind:latest + needs: ["coatjava_build"] + tags: + - silicon + allow_failure: true + script: + - apptainer build --build-arg REF_NAME=${REF_NAME} coatjava.sif .containers/coatjava.def + - ls -lrth + artifacts: + paths: + - coatjava.sif + +create-pages: + image: codecr.jlab.org/hallb/alert/coatjava/coatjava:development + script: + - export MAVEN_OPTS=" -Dfile.encoding=UTF-8" + - echo "${CI_COMMIT_REF_NAME}" + - ls -lrth + - mvn --version + - java --version + - ls -lrth + - pwd + - ls -lrth docs/javadoc + - ./build-javadocs.sh + - ls -lrth + - ls -lrth docs/ + - ls -lrth docs/javadoc + - mv docs/javadoc public + pages: true # specifies that this is a Pages job and publishes the default public directory + diff --git a/README.md b/README.md index 932aa457cd..606d8c9bfd 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ [![Validation Status](https://github.com/JeffersonLab/coatjava/actions/workflows/validation.yml/badge.svg)](https://github.com/JeffersonLab/coatjava/actions/workflows/validation.yml) [![Coverage](https://badgen.net/static/JaCoCo/coverage/purple)](https://jeffersonlab.github.io/coatjava/jacoco) +- [**Documentation Homepage**](https://jeffersonlab.github.io/coatjava) - [API Documentation (Javadoc)](https://jeffersonlab.github.io/coatjava/javadoc) ---- @@ -58,3 +59,6 @@ http://stackoverflow.com/questions/600079/how-do-i-clone-a-subdirectory-only-of- --> + +[Coatjava Apptainer](https://code.jlab.org/hallb/alert/coatjava/-/jobs/artifacts/development/raw/coatjava.sif?job=coatjava%3Asingularity) + diff --git a/bin/hipo-multi-merge b/bin/hipo-multi-merge index 5dcbacea8e..ebed509cec 100755 --- a/bin/hipo-multi-merge +++ b/bin/hipo-multi-merge @@ -8,6 +8,8 @@ def print_log(name, val) puts name.rjust(30) + " = #{val}" end +SlurmMemReq = 2048 + 200 # `-Xmx` argument from `hipo-utils`, plus extra padding + # user options @args = OpenStruct.new @args.inputs = nil @@ -76,7 +78,7 @@ if @args.use_batch 'job-name' => "hipo_multi_merge___#{@args.prefix}", 'account' => 'clas12', 'partition' => 'production', - 'mem-per-cpu' => 500, + 'mem-per-cpu' => SlurmMemReq, 'time' => '1:00:00', 'ntasks' => 1, 'cpus-per-task' => 1, diff --git a/bin/recon-util b/bin/recon-util index a11a11e8c3..e933e14b46 100755 --- a/bin/recon-util +++ b/bin/recon-util @@ -2,9 +2,12 @@ . `dirname $0`/../libexec/env.sh +split_cli $@ + export MALLOC_ARENA_MAX=1 -java -Xmx1536m -Xms1024m -XX:+UseSerialGC \ +java -Xmx1536m -Xms1024m -XX:+UseSerialGC ${jvm_options[@]} \ -cp "$CLAS12DIR/lib/clas/*:$CLAS12DIR/lib/services/*:$CLAS12DIR/lib/utils/*" \ org.jlab.clas.reco.EngineProcessor \ - $* + ${class_options[@]} + diff --git a/build-javadocs.sh b/build-javadocs.sh index bfdfe87abd..4932f9ee9d 100755 --- a/build-javadocs.sh +++ b/build-javadocs.sh @@ -5,8 +5,10 @@ set -e +export MAVEN_OPTS=" -Dfile.encoding=UTF-8" + ##### generate documentation -mvn javadoc:javadoc -Ddoclint=none +mvn javadoc:javadoc -Ddoclint=none ##### collect documentation diff --git a/common-tools/clara-io/pom.xml b/common-tools/clara-io/pom.xml index 829ad4a1bd..185959920a 100644 --- a/common-tools/clara-io/pom.xml +++ b/common-tools/clara-io/pom.xml @@ -3,14 +3,14 @@ 4.0.0 org.jlab.clas clara-io - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT @@ -61,7 +61,7 @@ org.apache.commons commons-text - 1.13.0 + 1.13.1 diff --git a/common-tools/clas-analysis/pom.xml b/common-tools/clas-analysis/pom.xml index fd3f5efb02..a6b5d9d850 100644 --- a/common-tools/clas-analysis/pom.xml +++ b/common-tools/clas-analysis/pom.xml @@ -3,63 +3,63 @@ 4.0.0 org.jlab.clas clas-analysis - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT org.jlab.clas clas-utils - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT org.jlab.clas clas-physics - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT org.jlab.clas clas-io - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT org.jlab.clas clas-geometry - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT org.jlab.clas clas-jcsg - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT org.jlab.clas swim-tools - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT org.jlab.clas clas-detector - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT org.jlab.clas clas-reco - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT diff --git a/common-tools/clas-detector/pom.xml b/common-tools/clas-detector/pom.xml index 635bc38466..26933b2080 100644 --- a/common-tools/clas-detector/pom.xml +++ b/common-tools/clas-detector/pom.xml @@ -3,21 +3,21 @@ 4.0.0 org.jlab.clas clas-detector - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT org.jlab.clas clas-utils - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT @@ -29,13 +29,13 @@ org.jlab.clas clas-io - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT org.jlab.clas clas-geometry - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT diff --git a/common-tools/clas-detector/src/main/java/org/jlab/detector/banks/RawBank.java b/common-tools/clas-detector/src/main/java/org/jlab/detector/banks/RawBank.java index fffc360b58..19482d6005 100644 --- a/common-tools/clas-detector/src/main/java/org/jlab/detector/banks/RawBank.java +++ b/common-tools/clas-detector/src/main/java/org/jlab/detector/banks/RawBank.java @@ -74,9 +74,9 @@ public static enum OrderType { BGADDED_NOISE1 ( 70), // background hits retained by level-1 denoising BGADDED_NOISE2 ( 80), // background hits retained by level-2 denoising BGADDED_NOISE3 ( 90), // background hits retained by level-3 denoising - USER1 (100), - USER2 (110), - USER3 (120); + DECREMOVED (100), // hits removed during decoding + USER1 (110), + USER2 (120); private final int rawOrderId; private OrderType(int id){ rawOrderId = id; } public int getTypeId() { return rawOrderId; } diff --git a/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/CLASDecoder4.java b/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/CLASDecoder4.java index 763042a2d4..aa366ed859 100644 --- a/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/CLASDecoder4.java +++ b/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/CLASDecoder4.java @@ -139,6 +139,7 @@ public void initEvent(DataEvent event){ detectorDecoder.translate(dataList); detectorDecoder.fitPulses(dataList); + detectorDecoder.filterTDCs(dataList); if(this.decoderDebugMode>0){ System.out.println("\n>>>>>>>>> TRANSLATED data"); for(DetectorDataDgtz data : dataList){ @@ -248,7 +249,7 @@ public List getEntriesSCALER(DetectorType type, } public void extractPulses(Event event) { - ahdcExtractor.update(64, null, event, schemaFactory, "AHDC::wf", "AHDC::adc"); + ahdcExtractor.update(30, null, event, schemaFactory, "AHDC::wf", "AHDC::adc"); } public Bank getDataBankWF(String name, DetectorType type) { @@ -260,6 +261,7 @@ public Bank getDataBankWF(String name, DetectorType type) { b.putShort("component", i, (short) a.get(i).getDescriptor().getComponent()); b.putByte("order", i, (byte) a.get(i).getDescriptor().getOrder()); b.putLong("timestamp", i, a.get(i).getADCData(0).getTimeStamp()); + b.putInt("time", i, (int)a.get(i).getADCData(0).getTime()); DetectorDataDgtz.ADCData xxx = a.get(i).getADCData(0); for (int j=0; j getDataEntries(EvioDataEvent event){ // zero out the trigger bits, but let the others properties inherit // from the previous event, in the case where there's no HEAD bank: this.setTriggerBits(0); - List rawEntries = new ArrayList(); + List rawEntries = new ArrayList<>(); List branches = this.getEventBranches(event); this.setTimeStamp(event); for(EvioTreeBranch branch : branches){ @@ -85,7 +85,6 @@ public List getDataEntries(EvioDataEvent event){ rawEntries.addAll(scalerEntries); this.getDataEntries_EPICS(event); - this.getDataEntries_HelicityDecoder(event); return rawEntries; } @@ -280,10 +279,13 @@ else if(node.getTag()==57640){ return this.getDataEntries_57640(crate, node, event); } else if(node.getTag()==57622){ - // This is regular integrated pulse mode, used for FTOF - // FTCAL and EC/PCAL + // This is regular DCRB bank with TDCs only return this.getDataEntries_57622(crate, node, event); } + else if(node.getTag()==57648){ + // This is DCRB bank with TDCs and widths + return this.getDataEntries_57648(crate, node, event); + } else if(node.getTag()==57636){ // RICH TDC data return this.getDataEntries_57636(crate, node, event); @@ -642,7 +644,6 @@ public List getDataEntries_57601(Integer crate, EvioNode node System.out.println("Exception in CRATE = " + crate + " RUN = " + this.runNumber + " EVENT = " + this.eventNumber + " LENGTH = " + compBuffer.array().length); this.printByteBuffer(compBuffer, 120, 20); -// Logger.getLogger(CodaEventDecoder.class.getName()).log(Level.SEVERE, null, ex); } } return entries; @@ -745,7 +746,7 @@ public List getDataEntries_57640(Integer crate, EvioNode node int nSamples = nBytes*8/12; short[] samples = new short[ nSamples ]; - int s = 0; + int s; for( int b=0;b getDataEntries_57641(Integer crate, EvioNode node for( int ch=0; ch getDataEntries_57641(Integer crate, EvioNode node int nSamples = nBytes*8/12; short[] samples = new short[ nSamples ]; - int s = 0; + int s; for( int b=0;b getDataEntries_57622(Integer crate, EvioNode node } } } catch (EvioException ex) { - //Logger.getLogger(EvioRawDataSource.class.getName()).log(Level.SEVERE, null, ex); + Logger.getLogger(CodaEventDecoder.class.getName()).log(Level.SEVERE, null, ex); } catch (IndexOutOfBoundsException ex){ - //System.out.println("[ERROR] ----> ERROR DECODING COMPOSITE DATA FOR ONE EVENT"); + Logger.getLogger(CodaEventDecoder.class.getName()).log(Level.SEVERE, null, ex); + } + + } + return entries; + } + + /** + * Bank TAG=57648 used for DC (Drift Chambers) TDC and ToT values. + * @param crate + * @param node + * @param event + * @return + */ + public List getDataEntries_57648(Integer crate, EvioNode node, EvioDataEvent event){ + List entries = new ArrayList<>(); + if(node.getTag()==57648){ + try { + ByteBuffer compBuffer = node.getByteData(true); + CompositeData compData = new CompositeData(compBuffer.array(),event.getByteOrder()); + //List cdatatypes = compData.getTypes(); + List cdataitems = compData.getItems(); + + int totalSize = cdataitems.size(); + int position = 0; + while( (position + 4) < totalSize){ + Byte slot = (Byte) cdataitems.get(position); + //Integer trig = (Integer) cdataitems.get(position+1); + Long time = (Long) cdataitems.get(position+2); + Integer nchannels = (Integer) cdataitems.get(position+3); + int counter = 0; + position = position + 4; + while(counter getDataEntries_57657(Integer crate, EvioNode node int position = 0; while(position -> "bank" DetectorDataDgtz -> "tdc" TDCData + // there is a redundancy in timestamp: the same value is stored in TDCData and the DetectorDataDgz + // + bank.setTimeStamp(time_stamp); + bank.setTrigger(trig_num);; + TDCData tdc_data = new TDCData(tdc, tot); + tdc_data.setTimeStamp(time_stamp).setOrder(counter); + bank.addTDC(tdc_data); entries.add(bank); - position += 3; + position += 3; // channel,tdc,tot counter++; //System.err.println("event: " + bank.toString()); } @@ -1130,14 +1189,12 @@ public HelicityDecoderData getDataEntries_HelicityDecoder(EvioDataEvent event){ for(EvioNode node : branch.getNodes()){ if(node.getTag()==57651) { - long[] longData = ByteDataTransformer.toLongArray(node.getStructureBuffer(true)); int[] intData = ByteDataTransformer.toIntArray(node.getStructureBuffer(true)); // When there are multiple HelicityDecoder banks in an event, there is a BLKHDR work in the data, // and when there is one HelicityDecoder bank in an event, it is not there. So we need to // detect where the trigger time word is. int i_data_offset = 2; - int i_data_length = intData.length; while(i_data_offset=intData.length){ - System.err.println("ERROR: HelicityDecoder data is corrupted. Trigger time word not found."); + System.err.println("ERROR: HelicityDecoder EVIO data is corrupted. Trigger time word not found."); return null; } long timeStamp = (intData[i_data_offset]&0x00ffffff) + (((long)(intData[i_data_offset+1]&0x00ffffffL))<<24); i_data_offset+=2; // Next word should be "DECODER DATA", with 0x18 in the top 5 bits. - if(((int) (( ((long)intData[i_data_offset]) & 0x00000000ffffffffL ) >> 27)) != 0x18){ - System.err.println("ERROR: HelicityDecoder data is corrupted. DECODER BANK not found."); + try { + if(((int) (( ((long)intData[i_data_offset]) & 0x00000000ffffffffL ) >> 27)) != 0x18){ + System.err.println("ERROR: HelicityDecoder EVIO data is corrupted."); + return null; + } + } + catch (ArrayIndexOutOfBoundsException e) { + System.err.println("ERROR: HelicityDecoder EVIO data looks like v2 firmware(?), ignoring it."); return null; } - int num_data_words = intData[i_data_offset]&0x07ffffff; - if(num_data_words < 14){ - System.err.println("ERROR: HelicityDecoder data is corrupted. Not enough data words."); + try { + int num_data_words = intData[i_data_offset]&0x07ffffff; + if(num_data_words < 14){ + System.err.println("ERROR: HelicityDecoder EVIO data is corrupted. Not enough data words."); + return null; + } + } + catch (ArrayIndexOutOfBoundsException e) { + System.err.println("ERROR: HelicityDecoder EVIO data looks like v2 firmware(?), ignoring it."); return null; } i_data_offset ++; // Point to the first word in the data block. diff --git a/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/DetectorDataDgtz.java b/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/DetectorDataDgtz.java index 375c322b3d..ebc0a1957f 100644 --- a/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/DetectorDataDgtz.java +++ b/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/DetectorDataDgtz.java @@ -2,6 +2,7 @@ import java.util.ArrayList; import java.util.List; +import org.jlab.detector.banks.RawBank.OrderType; import org.jlab.detector.base.DetectorDescriptor; import org.jlab.detector.base.DetectorType; import org.jlab.detector.helicity.HelicityBit; @@ -14,12 +15,14 @@ */ public class DetectorDataDgtz implements Comparable { - private final List adcStore = new ArrayList<>(); - private final List tdcStore = new ArrayList<>(); - private final List vtpStore = new ArrayList<>(); - private final List scalerStore = new ArrayList<>(); - private Long timeStamp = 0L; + private final List adcStore = new ArrayList<>(); + private final List tdcStore = new ArrayList<>(); + private final List vtpStore = new ArrayList<>(); + private final List scalerStore = new ArrayList<>(); + private Long timeStamp = 0L; + private int trigger = 0; // Trigger number ( usually only 1 trigger due to rol2(?) ); + private final DetectorDescriptor descriptor = new DetectorDescriptor(); public DetectorDataDgtz(){ @@ -66,6 +69,9 @@ public long getTimeStamp(){ public DetectorDescriptor getDescriptor(){ return this.descriptor; } + + public int getTrigger() { return trigger;} + public DetectorDataDgtz setTrigger(int trig) { trigger = trig;return this;} @Override public String toString(){ @@ -333,6 +339,8 @@ public static class TDCData implements Comparable{ private int tdcOrder = 0; // Used for sorting private int tdcTime = 0; private int tdcToT = 0; // Time over threshold + private Long timeStamp = 0L; + private OrderType tdcType = OrderType.NOMINAL; public TDCData() {} public TDCData(int time) { this.tdcTime = time;} @@ -340,9 +348,13 @@ public TDCData() {} public int getTime() { return this.tdcTime;} public int getToT() { return this.tdcToT;} public int getOrder() { return tdcOrder;} + public long getTimeStamp(){ return this.timeStamp; } + public OrderType getType() { return tdcType;} public TDCData setOrder(int order) { tdcOrder = order;return this;} public TDCData setTime(short time) { tdcTime = time;return this;} public TDCData setToT(short ToT) { tdcToT = ToT;return this;} + public TDCData setTimeStamp(long time){ timeStamp = time;return this; } + public TDCData setType(OrderType type) { tdcType = type; return this;} @Override public String toString(){ diff --git a/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/DetectorEventDecoder.java b/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/DetectorEventDecoder.java index 09a4ad7bf5..da36a07577 100644 --- a/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/DetectorEventDecoder.java +++ b/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/DetectorEventDecoder.java @@ -1,7 +1,12 @@ package org.jlab.detector.decode; +import java.util.ArrayList; import java.util.Arrays; +import java.util.Comparator; +import java.util.HashMap; import java.util.List; +import java.util.Map; +import org.jlab.detector.banks.RawBank.OrderType; import org.jlab.detector.base.DetectorType; import org.jlab.detector.calib.utils.ConstantsManager; import org.jlab.detector.decode.DetectorDataDgtz.ADCData; @@ -21,6 +26,7 @@ public class DetectorEventDecoder { List keysTrans = null; List tablesFitter = null; List keysFitter = null; + List keysFilter = null; private int runNumber = 10; @@ -109,6 +115,9 @@ public final void initDecoder(){ }); fitterManager.init(keysFitter, tablesFitter); + // Data filter list + keysFilter = Arrays.asList(new String[]{"DC"}); + scalerManager.init(Arrays.asList(new String[]{"/runcontrol/fcup","/runcontrol/slm","/runcontrol/hwp", "/runcontrol/helicity","/daq/config/scalers/dsc1"})); } @@ -159,7 +168,7 @@ public void fitPulses(List detectorData){ //custom MM fitter if( ( (table.equals("BMT"))&&(data.getDescriptor().getType().getName().equals("BMT")) ) || ( (table.equals("FMT"))&&(data.getDescriptor().getType().getName().equals("FMT")) ) - || ( (table.equals("AHDC"))&&(data.getDescriptor().getType().getName().equals("AHDC")) ) + //|| ( (table.equals("AHDC"))&&(data.getDescriptor().getType().getName().equals("AHDC")) ) || ( (table.equals("FTTRK"))&&(data.getDescriptor().getType().getName().equals("FTTRK")) ) ){ IndexedTable daq = fitterManager.getConstants(runNumber, table); short adcOffset = (short) daq.getDoubleValue("adc_offset", 0, 0, 0); @@ -211,4 +220,42 @@ public void fitPulses(List detectorData){ } } } + + + public void filterTDCs(List detectorData){ + int maxMultiplicity = 1; + for(String table : keysFilter){ + Map> filteredData = new HashMap<>(); + for(DetectorDataDgtz data : detectorData){ + if(data.getDescriptor().getType()==DetectorType.getType(table)) { + int key = data.getDescriptor().getHashCode(); + if(!filteredData.containsKey(key)) + filteredData.put(key, new ArrayList<>()); + filteredData.get(key).add(data); + } + } + for(int key : filteredData.keySet()) { + filteredData.get(key).sort(new TDCComparator()); + if(filteredData.get(key).size()>maxMultiplicity) + for(int i=maxMultiplicity; i { + + // override the compare() method + public int compare(DetectorDataDgtz s1, DetectorDataDgtz s2) + { + if(s1.getTDCSize()>0 && s2.getTDCSize()>0) + return s1.getTDCData(0).getTime()0) + return 1; + else if(s2.getTDCSize()>0) + return -1; + else + return 0; + } + } } diff --git a/common-tools/clas-detector/src/main/java/org/jlab/detector/pulse/HipoExtractor.java b/common-tools/clas-detector/src/main/java/org/jlab/detector/pulse/HipoExtractor.java index c833e875a3..6ab098d145 100644 --- a/common-tools/clas-detector/src/main/java/org/jlab/detector/pulse/HipoExtractor.java +++ b/common-tools/clas-detector/src/main/java/org/jlab/detector/pulse/HipoExtractor.java @@ -129,8 +129,10 @@ protected List getPulses(int n, IndexedTable it, DataBank wfBank) { for (int i=0; i p = it==null ? extract(null, i, samples) : - extract(it.getNamedEntry(getIndices(wfBank,i)), i, samples); + long timestamp = wfBank.getLong("timestamp",i); + int time = wfBank.getInt("time",i); + List p = it==null ? extract(null, i, timestamp, time, samples) : + extract(it.getNamedEntry(getIndices(wfBank,i)), i, timestamp, time, samples); if (p!=null && !p.isEmpty()) { if (pulses == null) pulses = new ArrayList<>(); pulses.addAll(p); @@ -147,8 +149,10 @@ protected List getPulses(int n, IndexedTable it, Bank wfBank) { samples[j] = wfBank.getShort(String.format("s%d",j+1), i); // FIXME: Can speed this up (but looks like not for DataBank?): //samples[j] = wfBank.getShort(String.format(5+j,j+1), i); - List p = it==null ? extract(null, i, samples) : - extract(it.getNamedEntry(getIndices(wfBank,i)), i, samples); + int time = wfBank.getInt("time",i); + long timestamp = wfBank.getLong("timestamp",i); + List p = it==null ? extract(null, i, timestamp, time, samples) : + extract(it.getNamedEntry(getIndices(wfBank,i)), i, timestamp, time, samples); if (p!=null && !p.isEmpty()) { if (pulses == null) pulses = new ArrayList<>(); pulses.addAll(p); diff --git a/common-tools/clas-detector/src/main/java/org/jlab/detector/pulse/IExtractor.java b/common-tools/clas-detector/src/main/java/org/jlab/detector/pulse/IExtractor.java index bfa765d84e..fac170f6b8 100644 --- a/common-tools/clas-detector/src/main/java/org/jlab/detector/pulse/IExtractor.java +++ b/common-tools/clas-detector/src/main/java/org/jlab/detector/pulse/IExtractor.java @@ -5,6 +5,6 @@ public interface IExtractor { - public List extract(NamedEntry pars, int id, short... samples); + public List extract(NamedEntry pars, int id, long par1, long par2, short... samples); } diff --git a/common-tools/clas-detector/src/main/java/org/jlab/detector/pulse/Mode3.java b/common-tools/clas-detector/src/main/java/org/jlab/detector/pulse/Mode3.java index bf4049f60a..23e1289606 100644 --- a/common-tools/clas-detector/src/main/java/org/jlab/detector/pulse/Mode3.java +++ b/common-tools/clas-detector/src/main/java/org/jlab/detector/pulse/Mode3.java @@ -20,11 +20,13 @@ public class Mode3 extends HipoExtractor { /** * @param pars CCDB row * @param id link to row in source bank + * @param par1 + * @param par2 * @param samples ADC samples * @return extracted pulses */ @Override - public List extract(NamedEntry pars, int id, short... samples) { + public List extract(NamedEntry pars, int id, long par1, long par2, short... samples) { List pulses = null; diff --git a/common-tools/clas-detector/src/main/java/org/jlab/detector/pulse/Mode7.java b/common-tools/clas-detector/src/main/java/org/jlab/detector/pulse/Mode7.java index b7f58f2c70..883b150aa2 100644 --- a/common-tools/clas-detector/src/main/java/org/jlab/detector/pulse/Mode7.java +++ b/common-tools/clas-detector/src/main/java/org/jlab/detector/pulse/Mode7.java @@ -29,8 +29,8 @@ private static float calculateTime(int t0, float ped, short... samples) { } @Override - public List extract(NamedEntry pars, int id, short... samples) { - List pulses = super.extract(pars, id, samples); + public List extract(NamedEntry pars, int id, long par1, long par2, short... samples) { + List pulses = super.extract(pars, id, par1, par2, samples); for (Pulse p : pulses) p.time = calculateTime((int)p.time, p.pedestal, samples); return pulses; diff --git a/common-tools/clas-detector/src/main/java/org/jlab/detector/pulse/ModeAHDC.java b/common-tools/clas-detector/src/main/java/org/jlab/detector/pulse/ModeAHDC.java index 26038aa226..80395d2b58 100644 --- a/common-tools/clas-detector/src/main/java/org/jlab/detector/pulse/ModeAHDC.java +++ b/common-tools/clas-detector/src/main/java/org/jlab/detector/pulse/ModeAHDC.java @@ -5,18 +5,14 @@ import org.jlab.io.base.DataBank; import org.jlab.io.base.DataEvent; import org.jlab.jnp.hipo4.data.Bank; -import org.jlab.jnp.hipo4.data.Event; -import org.jlab.jnp.hipo4.data.SchemaFactory; import org.jlab.utils.groups.IndexedTable; - -import net.jcip.annotations.GuardedBy; import org.jlab.utils.groups.NamedEntry; /** * A new extraction method dedicated to the AHDC signal waveform * - * Some blocks of code are inspired by MVTFitter.java + * Some blocks of code are inspired by MVTFitter.java and Bonus12 (`createBonusBank()`) * * @author ftouchte */ @@ -29,15 +25,15 @@ public class ModeAHDC extends HipoExtractor { * * @param pars CCDB row * @param id link to row in source bank + * @param timestamp ... + * @param time time (exprimed in bin) of the first channel of the AHDC pulse (after or not zero suppress; if ZS=0, time == 0) * @param samples ADC samples */ @Override - public List extract(NamedEntry pars, int id, short... samples){ + public List extract(NamedEntry pars, int id, long timestamp, long time, short... samples){ // Settings parameters (they can be initialised by a CCDB) - float samplingTime = 44; - int sparseSample = 0; - short adcOffset = 0; - long timeStamp = 0; + float samplingTime = 50.0f; + short adcOffset = 0; ///< pedestal of the pulse float fineTimeStampResolution = 0; float amplitudeFractionCFA = 0.5f; @@ -46,11 +42,9 @@ public List extract(NamedEntry pars, int id, short... samples){ // Calculation intermediaries int binMax = 0; //Bin of the max ADC over the pulse - int binOffset = 0; //Offset due to sparse sample float adcMax = 0; //Max value of ADC over the pulse (fitted) float timeMax =0; //Time of the max ADC over the pulse (fitted) float integral = 0; //Sum of ADCs over the pulse (not fitted) - long timestamp = 0; short[] samplesCorr; //Waveform after offset (pedestal) correction int binNumber = 0; //Number of bins in one waveform @@ -62,7 +56,7 @@ public List extract(NamedEntry pars, int id, short... samples){ /// ///////////////////////// // Begin waveform correction /// //////////////////////// - //waveformCorrection(samples,adcOffset,samplingTime,sparseSample, binMax, adcMax, integral, samplesCorr[], binOffset, timeMax); + //waveformCorrection(samples,adcOffset,samplingTime, binMax, adcMax, integral, samplesCorr[], time, timeMax); /** * This method subtracts the pedestal (noise) from samples and stores it in : samplesCorr * It also computes a first value for : adcMax, binMax, timeMax and integral @@ -70,9 +64,8 @@ public List extract(NamedEntry pars, int id, short... samples){ * @param samples ADC samples * @param adcOffset pedestal or noise level * @param samplingTime time between two adc bins - * @param sparseSample used to define binOffset */ - //private void waveformCorrection(short[] samples, short adcOffset, float samplingTime, int sparseSample, int binMax, int adcMax, int integral, short samplesCorr[], int binOffset, int timeMax){ + //private void waveformCorrection(short[] samples, short adcOffset, float samplingTime, int binMax, int adcMax, int integral, short samplesCorr[], int time, int timeMax){ binNumber = samples.length; binMax = 0; if (binNumber >= 5) { @@ -106,8 +99,7 @@ public List extract(NamedEntry pars, int id, short... samples){ } binMax = (binMax + binMax2)/2; } - binOffset = sparseSample*binMax; - timeMax = (binMax + binOffset)*samplingTime; + timeMax = (binMax + time)*samplingTime; //} /// ///////////////////////// @@ -155,7 +147,7 @@ public List extract(NamedEntry pars, int id, short... samples){ if (binRise + 1 <= binNumber-1) slopeRise = samplesCorr[binRise+1] - samplesCorr[binRise]; float fittedBinRise = (slopeRise == 0) ? binRise : binRise + (threshold - samplesCorr[binRise])/slopeRise; - leadingEdgeTime = (fittedBinRise + binOffset)*samplingTime; // binOffset is determined in wavefromCorrection() // must be the same for all time ? // or must be defined using fittedBinRise*sparseSample + leadingEdgeTime = (fittedBinRise + time)*samplingTime; // trailingEdgeTime int binFall = binMax; @@ -172,7 +164,7 @@ public List extract(NamedEntry pars, int id, short... samples){ if (binFall - 1 >= 0) slopeFall = samplesCorr[binFall] - samplesCorr[binFall-1]; float fittedBinFall = (slopeFall == 0) ? binFall : binFall-1 + (threshold - samplesCorr[binFall-1])/slopeFall; - trailingEdgeTime = (fittedBinFall + binOffset)*samplingTime; + trailingEdgeTime = (fittedBinFall + time)*samplingTime; // timeOverThreshold timeOverThreshold = trailingEdgeTime - leadingEdgeTime; @@ -217,29 +209,10 @@ public List extract(NamedEntry pars, int id, short... samples){ if (binZero + 1 <= binNumber) slopeCFD = signal[binZero+1] - signal[binZero]; float fittedBinZero = (slopeCFD == 0) ? binZero : binZero + (0 - signal[binZero])/slopeCFD; - constantFractionTime = (fittedBinZero + binOffset)*samplingTime; + constantFractionTime = (fittedBinZero + time)*samplingTime; //} - /// ///////////////////////// - // Begin fineTimeStampCorrection - /// //////////////////////// - //fineTimeStampCorrection(timeStamp,fineTimeStampResolution); - /** - * From MVTFitter.java - * Make fine timestamp correction (using dream (=electronic chip) clock) - * @param timeStamp timing informations (used to make fine corrections) - * @param fineTimeStampResolution precision of dream clock (usually 8) - */ - //private void fineTimeStampCorrection (long timeStamp, float fineTimeStampResolution) { - //this.timestamp = timeStamp; - String binaryTimeStamp = Long.toBinaryString(timeStamp); //get 64 bit timestamp in binary format - if (binaryTimeStamp.length()>=3){ - byte fineTimeStamp = Byte.parseByte(binaryTimeStamp.substring(binaryTimeStamp.length()-3,binaryTimeStamp.length()),2); //fineTimeStamp : keep and convert last 3 bits of binary timestamp - timeMax += (float) ((fineTimeStamp+0.5) * fineTimeStampResolution); //fineTimeStampCorrection - // Question : I wonder if I have to do the same thing of all time quantities that the extract() methods compute. - } - //} // output Pulse pulse = new Pulse(); pulse.id = id; @@ -252,19 +225,11 @@ public List extract(NamedEntry pars, int id, short... samples){ pulse.timeOverThreshold = timeOverThreshold; pulse.constantFractionTime = constantFractionTime; //pulse.binMax = binMax; - //pulse.binOffset = binOffset; pulse.pedestal = adcOffset; List output = new ArrayList<>(); output.add(pulse); return output; } - /** - * Fit the max of the pulse using parabolic fit, this method updates the timeMax and adcMax values - * @param samplingTime time between 2 ADC bins - */ - private void fitParabolic(float samplingTime) { - - } @Override public void update(int n, IndexedTable it, DataEvent event, String wfBankName, String adcBankName) { diff --git a/common-tools/clas-geometry/pom.xml b/common-tools/clas-geometry/pom.xml index 6dc61e0065..38db5ad277 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 - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT diff --git a/common-tools/clas-geometry/src/main/java/org/jlab/geom/detector/alert/AHDC/AlertDCFactory.java b/common-tools/clas-geometry/src/main/java/org/jlab/geom/detector/alert/AHDC/AlertDCFactory.java index 0a9bd13026..7b9bd1ad90 100644 --- a/common-tools/clas-geometry/src/main/java/org/jlab/geom/detector/alert/AHDC/AlertDCFactory.java +++ b/common-tools/clas-geometry/src/main/java/org/jlab/geom/detector/alert/AHDC/AlertDCFactory.java @@ -86,8 +86,8 @@ public AlertDCLayer createLayer(ConstantProvider cp, int sectorId, int superlaye double R_layer = 32.0d; double DR_layer = 4.0d; - double zoff1 = 0.0d; - double zoff2 = 300.0d; + double zoff1 = -150.0d; + double zoff2 = 150.0d; Point3D p1 = new Point3D(R_layer, 0, zoff1); Vector3D n1 = new Vector3D(0, 0, 1); @@ -125,21 +125,26 @@ public AlertDCLayer createLayer(ConstantProvider cp, int sectorId, int superlaye double alphaW_layer = Math.toRadians(round / (numWires)); // shift the wire end point +-20deg in XY plan - double thster = Math.toRadians(20.0d); + double thster = Math.toRadians(-20.0d); double zl = 300.0d; // Create AHDC sense wires for (int wireId = 0; wireId < numWires; wireId++) { - // The point given by (wx, wy, wz) is the midpoint of the current wire. - double wx = -R_layer * Math.sin(alphaW_layer * wireId); - double wy = -R_layer * Math.cos(alphaW_layer * wireId); + // start at phi=0 + // in each layer the first wire is the first at phi>=0, i.e. + // 0.5 0 0.5 0 0.5 0.5 0 0.5 for layer 1 to 8 + double wirePhiIndex = wireId + 0.5*(numWires%2) + 0.5*layerId*(1-2*(numWires%2)); + + // The point given by (wx, wy, wz) is the origin of the current wire. + double wx = R_layer * Math.cos(alphaW_layer * wirePhiIndex); + double wy = R_layer * Math.sin(alphaW_layer * wirePhiIndex); // Find the interesection of the current wire with the end-plate // planes by construciting a long line that passes through the midpoint - double wx_end = -R_layer * Math.sin(alphaW_layer * wireId + thster * (Math.pow(-1, superlayerId))); - double wy_end = -R_layer * Math.cos(alphaW_layer * wireId + thster * (Math.pow(-1, superlayerId))); - Line3D line = new Line3D(wx, wy, 0, wx_end, wy_end, zl); + double wx_end = R_layer * Math.cos(alphaW_layer * wirePhiIndex + thster * (Math.pow(-1, superlayerId))); + double wy_end = R_layer * Math.sin(alphaW_layer * wirePhiIndex + thster * (Math.pow(-1, superlayerId))); + Line3D line = new Line3D(wx, wy, -zl/2, wx_end, wy_end, zl/2); Point3D lPoint = new Point3D(); Point3D rPoint = new Point3D(); @@ -150,63 +155,63 @@ public AlertDCLayer createLayer(ConstantProvider cp, int sectorId, int superlaye // Do not change the code above. It is for signal wires positioning // Construct the cell around the signal wires created above top - double px_0 = -(R_layer + 2) * Math.sin(alphaW_layer * wireId); - double py_0 = -(R_layer + 2) * Math.cos(alphaW_layer * wireId); - double px_1 = -(R_layer + 2) * Math.sin(alphaW_layer * wireId + alphaW_layer / 2); - double py_1 = -(R_layer + 2) * Math.cos(alphaW_layer * wireId + alphaW_layer / 2); - double px_2 = -(R_layer - 2) * Math.sin(alphaW_layer * wireId + alphaW_layer / 2); - double py_2 = -(R_layer - 2) * Math.cos(alphaW_layer * wireId + alphaW_layer / 2); - double px_3 = -(R_layer - 2) * Math.sin(alphaW_layer * wireId); - double py_3 = -(R_layer - 2) * Math.cos(alphaW_layer * wireId); - double px_4 = -(R_layer - 2) * Math.sin(alphaW_layer * wireId - alphaW_layer / 2); - double py_4 = -(R_layer - 2) * Math.cos(alphaW_layer * wireId - alphaW_layer / 2); - double px_5 = -(R_layer + 2) * Math.sin(alphaW_layer * wireId - alphaW_layer / 2); - double py_5 = -(R_layer + 2) * Math.cos(alphaW_layer * wireId - alphaW_layer / 2); + double px_0 = (R_layer + 2) * Math.cos(alphaW_layer * wirePhiIndex); + double py_0 = (R_layer + 2) * Math.sin(alphaW_layer * wirePhiIndex); + double px_1 = (R_layer + 2) * Math.cos(alphaW_layer * wirePhiIndex + alphaW_layer / 2); + double py_1 = (R_layer + 2) * Math.sin(alphaW_layer * wirePhiIndex + alphaW_layer / 2); + double px_2 = (R_layer - 2) * Math.cos(alphaW_layer * wirePhiIndex + alphaW_layer / 2); + double py_2 = (R_layer - 2) * Math.sin(alphaW_layer * wirePhiIndex + alphaW_layer / 2); + double px_3 = (R_layer - 2) * Math.cos(alphaW_layer * wirePhiIndex); + double py_3 = (R_layer - 2) * Math.sin(alphaW_layer * wirePhiIndex); + double px_4 = (R_layer - 2) * Math.cos(alphaW_layer * wirePhiIndex - alphaW_layer / 2); + double py_4 = (R_layer - 2) * Math.sin(alphaW_layer * wirePhiIndex - alphaW_layer / 2); + double px_5 = (R_layer + 2) * Math.cos(alphaW_layer * wirePhiIndex - alphaW_layer / 2); + double py_5 = (R_layer + 2) * Math.sin(alphaW_layer * wirePhiIndex - alphaW_layer / 2); // bottom (do not forget to add the +20 deg. twist respect to the "straight" version) - double px_6 = -(R_layer + 2) * Math.sin(alphaW_layer * wireId + thster * (Math.pow(-1, superlayerId))); - double py_6 = -(R_layer + 2) * Math.cos(alphaW_layer * wireId + thster * (Math.pow(-1, superlayerId))); - double px_7 = -(R_layer + 2) * Math.sin(alphaW_layer * wireId + alphaW_layer / 2 + thster * (Math.pow(-1, superlayerId))); - double py_7 = -(R_layer + 2) * Math.cos(alphaW_layer * wireId + alphaW_layer / 2 + thster * (Math.pow(-1, superlayerId))); - double px_8 = -(R_layer - 2) * Math.sin(alphaW_layer * wireId + alphaW_layer / 2 + thster * (Math.pow(-1, superlayerId))); - double py_8 = -(R_layer - 2) * Math.cos(alphaW_layer * wireId + alphaW_layer / 2 + thster * (Math.pow(-1, superlayerId))); - double px_9 = -(R_layer - 2) * Math.sin(alphaW_layer * wireId + thster * (Math.pow(-1, superlayerId))); - double py_9 = -(R_layer - 2) * Math.cos(alphaW_layer * wireId + thster * (Math.pow(-1, superlayerId))); - double px_10 = -(R_layer - 2) * Math.sin(alphaW_layer * wireId - alphaW_layer / 2 + thster * (Math.pow(-1, superlayerId))); - double py_10 = -(R_layer - 2) * Math.cos(alphaW_layer * wireId - alphaW_layer / 2 + thster * (Math.pow(-1, superlayerId))); - double px_11 = -(R_layer + 2) * Math.sin(alphaW_layer * wireId - alphaW_layer / 2 + thster * (Math.pow(-1, superlayerId))); - double py_11 = -(R_layer + 2) * Math.cos(alphaW_layer * wireId - alphaW_layer / 2 + thster * (Math.pow(-1, superlayerId))); + double px_6 = (R_layer + 2) * Math.cos(alphaW_layer * wirePhiIndex + thster * (Math.pow(-1, superlayerId))); + double py_6 = (R_layer + 2) * Math.sin(alphaW_layer * wirePhiIndex + thster * (Math.pow(-1, superlayerId))); + double px_7 = (R_layer + 2) * Math.cos(alphaW_layer * wirePhiIndex + alphaW_layer / 2 + thster * (Math.pow(-1, superlayerId))); + double py_7 = (R_layer + 2) * Math.sin(alphaW_layer * wirePhiIndex + alphaW_layer / 2 + thster * (Math.pow(-1, superlayerId))); + double px_8 = (R_layer - 2) * Math.cos(alphaW_layer * wirePhiIndex + alphaW_layer / 2 + thster * (Math.pow(-1, superlayerId))); + double py_8 = (R_layer - 2) * Math.sin(alphaW_layer * wirePhiIndex + alphaW_layer / 2 + thster * (Math.pow(-1, superlayerId))); + double px_9 = (R_layer - 2) * Math.cos(alphaW_layer * wirePhiIndex + thster * (Math.pow(-1, superlayerId))); + double py_9 = (R_layer - 2) * Math.sin(alphaW_layer * wirePhiIndex + thster * (Math.pow(-1, superlayerId))); + double px_10 = (R_layer - 2) * Math.cos(alphaW_layer * wirePhiIndex - alphaW_layer / 2 + thster * (Math.pow(-1, superlayerId))); + double py_10 = (R_layer - 2) * Math.sin(alphaW_layer * wirePhiIndex - alphaW_layer / 2 + thster * (Math.pow(-1, superlayerId))); + double px_11 = (R_layer + 2) * Math.cos(alphaW_layer * wirePhiIndex - alphaW_layer / 2 + thster * (Math.pow(-1, superlayerId))); + double py_11 = (R_layer + 2) * Math.sin(alphaW_layer * wirePhiIndex - alphaW_layer / 2 + thster * (Math.pow(-1, superlayerId))); // Group into points with (x,y,z) coordinates List firstF = new ArrayList<>(); List secondF = new ArrayList<>(); // first Face - Point3D p_0 = new Point3D(px_0, py_0, 0.0d); - Point3D p_1 = new Point3D(px_1, py_1, 0.0d); - Point3D p_2 = new Point3D(px_2, py_2, 0.0d); - Point3D p_3 = new Point3D(px_3, py_3, 0.0d); - Point3D p_4 = new Point3D(px_4, py_4, 0.0d); - Point3D p_5 = new Point3D(px_5, py_5, 0.0d); + Point3D p_0 = new Point3D(px_0, py_0, -zl/2); + Point3D p_1 = new Point3D(px_1, py_1, -zl/2); + Point3D p_2 = new Point3D(px_2, py_2, -zl/2); + Point3D p_3 = new Point3D(px_3, py_3, -zl/2); + Point3D p_4 = new Point3D(px_4, py_4, -zl/2); + Point3D p_5 = new Point3D(px_5, py_5, -zl/2); // second Face - Point3D p_6 = new Point3D(px_6, py_6, zl); - Point3D p_7 = new Point3D(px_7, py_7, zl); - Point3D p_8 = new Point3D(px_8, py_8, zl); - Point3D p_9 = new Point3D(px_9, py_9, zl); - Point3D p_10 = new Point3D(px_10, py_10, zl); - Point3D p_11 = new Point3D(px_11, py_11, zl); + Point3D p_6 = new Point3D(px_6, py_6, zl/2); + Point3D p_7 = new Point3D(px_7, py_7, zl/2); + Point3D p_8 = new Point3D(px_8, py_8, zl/2); + Point3D p_9 = new Point3D(px_9, py_9, zl/2); + Point3D p_10 = new Point3D(px_10, py_10, zl/2); + Point3D p_11 = new Point3D(px_11, py_11, zl/2); // defining a cell around a wireLine, must be counter-clockwise! firstF.add(p_0); - firstF.add(p_1); - firstF.add(p_2); - firstF.add(p_3); - firstF.add(p_4); firstF.add(p_5); + firstF.add(p_4); + firstF.add(p_3); + firstF.add(p_2); + firstF.add(p_1); secondF.add(p_6); - secondF.add(p_7); - secondF.add(p_8); - secondF.add(p_9); - secondF.add(p_10); secondF.add(p_11); + secondF.add(p_10); + secondF.add(p_9); + secondF.add(p_8); + secondF.add(p_7); // Create the cell and signal wire inside // PrismaticComponent(int componentId, List firstFace, List secondFace) diff --git a/common-tools/clas-geometry/src/main/java/org/jlab/geom/detector/alert/ATOF/AlertTOFFactory.java b/common-tools/clas-geometry/src/main/java/org/jlab/geom/detector/alert/ATOF/AlertTOFFactory.java index e96d4f991b..7bdc686481 100644 --- a/common-tools/clas-geometry/src/main/java/org/jlab/geom/detector/alert/ATOF/AlertTOFFactory.java +++ b/common-tools/clas-geometry/src/main/java/org/jlab/geom/detector/alert/ATOF/AlertTOFFactory.java @@ -95,8 +95,9 @@ public AlertTOFLayer createLayer(ConstantProvider cp, int sectorId, int superlay double pad_b1 = 8.17369; // mm double pad_b2 = 10.27; // mm - double pad_z = 279.7; // mm - if (superlayerId == 1) pad_z = 27.7; // mm + double atof_length = 279.7; // mm + double pad_z = atof_length; // For the bar + if (superlayerId == 1) pad_z = 27.7; // mm, for the wedges 10*27.7 + 9*0.3 // trapezoide dimensions for a smaller paddle (internal) double small_pad_b1 = 7.85924; // mm @@ -134,8 +135,8 @@ public AlertTOFLayer createLayer(ConstantProvider cp, int sectorId, int superlay for (int padId = 0; padId < current_ncomponents; padId++) { //Component index increases with increasing z - double len_b = padId * pad_z + padId * gap_pad_z; // back paddle plan - double len_f = len_b + pad_z; // front paddle plan + double len_b = padId * pad_z + padId * gap_pad_z;// back paddle plan + double len_f = len_b + pad_z;// front paddle plan Point3D p0 = new Point3D(-dR / 2, -widthBl / 2, len_f); Point3D p1 = new Point3D(dR / 2, -widthTl / 2, len_f); @@ -161,8 +162,8 @@ public AlertTOFLayer createLayer(ConstantProvider cp, int sectorId, int superlay xoffset = (Rl + dR / 2) * Math.cos(Math.toRadians(current_angle_deg)); yoffset = (Rl + dR / 2) * Math.sin(Math.toRadians(current_angle_deg)); - - Paddle.translateXYZ(xoffset, yoffset, 0); + + Paddle.translateXYZ(xoffset, yoffset, - atof_length/2); //centering at z=0 // Add the paddles to the list layer.addComponent(Paddle); diff --git a/common-tools/clas-io/pom.xml b/common-tools/clas-io/pom.xml index 3b1e1e0e21..7e228cb9d2 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 - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT @@ -90,13 +90,13 @@ org.jlab.clas clas-utils - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT org.jlab.clas clas-logging - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT compile diff --git a/common-tools/clas-io/src/main/java/org/jlab/io/ui/ConnectionDialog.java b/common-tools/clas-io/src/main/java/org/jlab/io/ui/ConnectionDialog.java index 4c9333409e..d1c3c08677 100644 --- a/common-tools/clas-io/src/main/java/org/jlab/io/ui/ConnectionDialog.java +++ b/common-tools/clas-io/src/main/java/org/jlab/io/ui/ConnectionDialog.java @@ -42,8 +42,8 @@ public class ConnectionDialog extends BasicDialog { private static String[] hostNames = new String[]{"clondaq2","clondaq3","clondaq4","clondaq5","clondaq6","clondaq7"}; private static String[] hostIP = new String[]{"129.57.167.109","129.57.167.226","129.57.167.227","129.57.167.41","129.57.167.60","129.57.167.20"}; - private static String defaultHost = "clondaq6"; - private static String defaultIP = "129.57.167.60"; + private static String defaultHost = "clondaq7"; + private static String defaultIP = "129.57.167.20"; Map connectionHosts = new LinkedHashMap(); diff --git a/common-tools/clas-io/src/main/java/org/jlab/io/ui/ConnectionDialogHipo.java b/common-tools/clas-io/src/main/java/org/jlab/io/ui/ConnectionDialogHipo.java index 49b9756414..353cf8dd95 100644 --- a/common-tools/clas-io/src/main/java/org/jlab/io/ui/ConnectionDialogHipo.java +++ b/common-tools/clas-io/src/main/java/org/jlab/io/ui/ConnectionDialogHipo.java @@ -1,28 +1,17 @@ -/* - * 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.io.ui; import java.awt.Component; -import java.awt.FlowLayout; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; import java.util.LinkedHashMap; -import java.util.List; import java.util.Map; import javax.swing.BorderFactory; import javax.swing.Box; import javax.swing.BoxLayout; import javax.swing.ButtonGroup; import javax.swing.JComboBox; -import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JRadioButton; import javax.swing.JTextField; import javax.swing.border.Border; -import org.jlab.utils.FileUtils; /** * @@ -41,8 +30,8 @@ public class ConnectionDialogHipo extends BasicDialog { private JRadioButton _directConnect; private JRadioButton _connectToDAQ; - private static String[] hostNames = new String[]{"clondaq2","clondaq3","clondaq4","clondaq5","clondaq6"}; - private static String[] hostIP = new String[]{"129.57.167.109","129.57.167.226","129.57.167.227","129.57.167.41","129.57.167.60"}; + private static String[] hostNames = new String[]{"clondaq2","clondaq3","clondaq4","clondaq5","clondaq6","clondaq7"}; + private static String[] hostIP = new String[]{"129.57.167.109","129.57.167.226","129.57.167.227","129.57.167.41","129.57.167.60","129.57.167.20"}; Map connectionHosts = new LinkedHashMap(); @@ -66,7 +55,6 @@ public ConnectionDialogHipo() { this.connectionHosts.put(hostNames[i],hostIP[i]); } } - @Override protected Component createCenterComponent() { @@ -89,17 +77,9 @@ protected Component createCenterComponent() { panel.add(Box.createVerticalStrut(6)); panel.add(_connectToDAQ); - - - - - Border emptyBorder = BorderFactory .createEtchedBorder();//4, 4, 4, 4); - //CommonBorder cborder = new CommonBorder("Connect to ET"); - - //panel.setBorder(BorderFactory.createCompoundBorder(emptyBorder)); panel.setBorder(BorderFactory.createTitledBorder(emptyBorder, "Connect to Host")); return panel; } @@ -142,7 +122,6 @@ public int getConnectionType() { else if (_connectToDAQ.isSelected()) { return CONNECTDAQ; } - return -1; } diff --git a/common-tools/clas-jcsg/pom.xml b/common-tools/clas-jcsg/pom.xml index 7a059f995c..6e4f21a527 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 - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT @@ -27,12 +27,12 @@ org.jlab.clas clas-geometry - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT org.jlab.clas clas-detector - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT java3d @@ -42,7 +42,7 @@ org.slf4j slf4j-simple - 2.0.16 + 2.0.17 diff --git a/common-tools/clas-logging/pom.xml b/common-tools/clas-logging/pom.xml index 0066ae526e..e5e26b7457 100644 --- a/common-tools/clas-logging/pom.xml +++ b/common-tools/clas-logging/pom.xml @@ -3,14 +3,14 @@ 4.0.0 org.jlab.clas clas-logging - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT diff --git a/common-tools/clas-math/pom.xml b/common-tools/clas-math/pom.xml index f4630287b2..2f4470e1fa 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 - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT diff --git a/common-tools/clas-physics/pom.xml b/common-tools/clas-physics/pom.xml index a40eb684fb..01d33087b4 100644 --- a/common-tools/clas-physics/pom.xml +++ b/common-tools/clas-physics/pom.xml @@ -4,14 +4,14 @@ org.jlab.clas clas-physics - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT diff --git a/common-tools/clas-reco/pom.xml b/common-tools/clas-reco/pom.xml index 49da337693..a192b87817 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 - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT @@ -42,37 +42,37 @@ org.jlab.clas clas-math - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT org.jlab.clas clas-io - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT org.jlab.clas clas-logging - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT org.jlab.clas clas-physics - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT org.jlab.clas clas-utils - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT org.jlab.clas clas-detector - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT 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 ff1fc6ab2a..157d4e0214 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 @@ -164,6 +164,9 @@ public void initAll(){ "org.jlab.service.eb.EBTBEngine", "org.jlab.rec.rich.RICHEBEngine", "org.jlab.service.rtpc.RTPCEngine", + "org.jlab.service.ahdc.AHDCEngine", + "org.jlab.service.atof.ATOFEngine", + "org.jlab.service.alert.ALERTEngine", "org.jlab.service.mc.TruthMatch" }; diff --git a/common-tools/clas-tracking/pom.xml b/common-tools/clas-tracking/pom.xml index 54afb47497..9015e373c1 100644 --- a/common-tools/clas-tracking/pom.xml +++ b/common-tools/clas-tracking/pom.xml @@ -3,14 +3,14 @@ 4.0.0 org.jlab.clas clas-tracking - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT @@ -22,7 +22,7 @@ org.jlab.clas swim-tools - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT jar diff --git a/common-tools/clas-utils/pom.xml b/common-tools/clas-utils/pom.xml index 8a5af26906..f444fbf279 100644 --- a/common-tools/clas-utils/pom.xml +++ b/common-tools/clas-utils/pom.xml @@ -3,26 +3,26 @@ 4.0.0 org.jlab.clas clas-utils - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT org.jlab.clas clas-logging - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT org.apache.commons commons-text - 1.13.0 + 1.13.1 org.apache.commons diff --git a/common-tools/cnuphys/apache/.classpath b/common-tools/cnuphys/apache/.classpath deleted file mode 100644 index 6ae56430f7..0000000000 --- a/common-tools/cnuphys/apache/.classpath +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/common-tools/cnuphys/apache/.project b/common-tools/cnuphys/apache/.project deleted file mode 100644 index c79ffc7af2..0000000000 --- a/common-tools/cnuphys/apache/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - apache - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/common-tools/cnuphys/cnuphys/pom.xml b/common-tools/cnuphys/cnuphys/pom.xml index d7a26242e5..cea751f02c 100644 --- a/common-tools/cnuphys/cnuphys/pom.xml +++ b/common-tools/cnuphys/cnuphys/pom.xml @@ -18,7 +18,7 @@ local-build - https://clasweb.jlab.org/clas12maven + https://clasweb.jlab.org/.clas12maven diff --git a/common-tools/cnuphys/magfield/.settings/org.eclipse.jdt.core.prefs b/common-tools/cnuphys/magfield/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 6d08f8e4e5..0000000000 --- a/common-tools/cnuphys/magfield/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,12 +0,0 @@ -#Thu Oct 18 15:20:29 EDT 2012 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.6 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.6 diff --git a/common-tools/cnuphys/magfield/pom.xml b/common-tools/cnuphys/magfield/pom.xml index 7457f062fe..1775d908f7 100644 --- a/common-tools/cnuphys/magfield/pom.xml +++ b/common-tools/cnuphys/magfield/pom.xml @@ -23,7 +23,7 @@ org.jlab.clas clas-math - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT diff --git a/common-tools/cnuphys/magfield/src/main/java/.classpath b/common-tools/cnuphys/magfield/src/main/java/.classpath deleted file mode 100644 index 737dc4026a..0000000000 --- a/common-tools/cnuphys/magfield/src/main/java/.classpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/common-tools/cnuphys/magfield/src/main/java/.project b/common-tools/cnuphys/magfield/src/main/java/.project deleted file mode 100644 index 65d79e0096..0000000000 --- a/common-tools/cnuphys/magfield/src/main/java/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - magfield - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/common-tools/cnuphys/magfield/src/main/java/cnuphys/bin/.classpath b/common-tools/cnuphys/magfield/src/main/java/cnuphys/bin/.classpath deleted file mode 100644 index 737dc4026a..0000000000 --- a/common-tools/cnuphys/magfield/src/main/java/cnuphys/bin/.classpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/common-tools/cnuphys/magfield/src/main/java/cnuphys/bin/.project b/common-tools/cnuphys/magfield/src/main/java/cnuphys/bin/.project deleted file mode 100644 index 65d79e0096..0000000000 --- a/common-tools/cnuphys/magfield/src/main/java/cnuphys/bin/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - magfield - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/common-tools/cnuphys/numRec/.classpath b/common-tools/cnuphys/numRec/.classpath deleted file mode 100644 index 4ce1143c36..0000000000 --- a/common-tools/cnuphys/numRec/.classpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/common-tools/cnuphys/numRec/.project b/common-tools/cnuphys/numRec/.project deleted file mode 100644 index e9bd6eb16c..0000000000 --- a/common-tools/cnuphys/numRec/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - numericalRec - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/common-tools/cnuphys/numRec/bin/.classpath b/common-tools/cnuphys/numRec/bin/.classpath deleted file mode 100644 index 233be1d2c4..0000000000 --- a/common-tools/cnuphys/numRec/bin/.classpath +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/common-tools/cnuphys/numRec/bin/.project b/common-tools/cnuphys/numRec/bin/.project deleted file mode 100644 index 848f89238f..0000000000 --- a/common-tools/cnuphys/numRec/bin/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - numRecip - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/common-tools/cnuphys/numRec/src/.classpath b/common-tools/cnuphys/numRec/src/.classpath deleted file mode 100644 index 233be1d2c4..0000000000 --- a/common-tools/cnuphys/numRec/src/.classpath +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/common-tools/cnuphys/numRec/src/.project b/common-tools/cnuphys/numRec/src/.project deleted file mode 100644 index 848f89238f..0000000000 --- a/common-tools/cnuphys/numRec/src/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - numRecip - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/common-tools/cnuphys/parent/pom.xml b/common-tools/cnuphys/parent/pom.xml index 7fe07ee342..e682b3b29e 100644 --- a/common-tools/cnuphys/parent/pom.xml +++ b/common-tools/cnuphys/parent/pom.xml @@ -8,7 +8,7 @@ clas12maven - https://clasweb.jlab.org/clas12maven + https://clasweb.jlab.org/.clas12maven @@ -38,7 +38,7 @@ com.github.spotbugs spotbugs-maven-plugin - 4.8.6.6 + 4.9.3.0 spotbugs-exclude.xml @@ -46,7 +46,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.13.0 + 3.14.0 UTF-8 17 diff --git a/common-tools/cnuphys/snr/src/main/java/.classpath b/common-tools/cnuphys/snr/src/main/java/.classpath deleted file mode 100644 index c1248cd1ab..0000000000 --- a/common-tools/cnuphys/snr/src/main/java/.classpath +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/common-tools/cnuphys/snr/src/main/java/.project b/common-tools/cnuphys/snr/src/main/java/.project deleted file mode 100644 index 95191682a3..0000000000 --- a/common-tools/cnuphys/snr/src/main/java/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - snr - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/common-tools/cnuphys/snr/src/main/java/cnuphys/bin/.classpath b/common-tools/cnuphys/snr/src/main/java/cnuphys/bin/.classpath deleted file mode 100644 index c1248cd1ab..0000000000 --- a/common-tools/cnuphys/snr/src/main/java/cnuphys/bin/.classpath +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/common-tools/cnuphys/snr/src/main/java/cnuphys/bin/.project b/common-tools/cnuphys/snr/src/main/java/cnuphys/bin/.project deleted file mode 100644 index 95191682a3..0000000000 --- a/common-tools/cnuphys/snr/src/main/java/cnuphys/bin/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - snr - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/common-tools/cnuphys/splot/.classpath b/common-tools/cnuphys/splot/.classpath deleted file mode 100644 index 748dc76710..0000000000 --- a/common-tools/cnuphys/splot/.classpath +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/common-tools/cnuphys/splot/.project b/common-tools/cnuphys/splot/.project deleted file mode 100644 index 1d5b581255..0000000000 --- a/common-tools/cnuphys/splot/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - splot - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/common-tools/cnuphys/splot/src/main/java/.classpath b/common-tools/cnuphys/splot/src/main/java/.classpath deleted file mode 100644 index 8320dcd5ac..0000000000 --- a/common-tools/cnuphys/splot/src/main/java/.classpath +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/common-tools/cnuphys/splot/src/main/java/.project b/common-tools/cnuphys/splot/src/main/java/.project deleted file mode 100644 index 1d5b581255..0000000000 --- a/common-tools/cnuphys/splot/src/main/java/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - splot - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/common-tools/cnuphys/swimmer/.settings/org.eclipse.jdt.core.prefs b/common-tools/cnuphys/swimmer/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 7341ab1683..0000000000 --- a/common-tools/cnuphys/swimmer/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,11 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.7 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.7 diff --git a/common-tools/cnuphys/swimmer/pom.xml b/common-tools/cnuphys/swimmer/pom.xml index 1ce598917b..833df583c3 100644 --- a/common-tools/cnuphys/swimmer/pom.xml +++ b/common-tools/cnuphys/swimmer/pom.xml @@ -35,7 +35,7 @@ org.jlab.clas clas-math - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT diff --git a/common-tools/cnuphys/swimmer/src/main/java/.classpath b/common-tools/cnuphys/swimmer/src/main/java/.classpath deleted file mode 100644 index 74825a682b..0000000000 --- a/common-tools/cnuphys/swimmer/src/main/java/.classpath +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - diff --git a/common-tools/cnuphys/swimmer/src/main/java/.project b/common-tools/cnuphys/swimmer/src/main/java/.project deleted file mode 100644 index 049cf6453d..0000000000 --- a/common-tools/cnuphys/swimmer/src/main/java/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - swimmer - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/common-tools/cnuphys/swimmer/src/main/java/cnuphys/bin/.classpath b/common-tools/cnuphys/swimmer/src/main/java/cnuphys/bin/.classpath deleted file mode 100644 index 74825a682b..0000000000 --- a/common-tools/cnuphys/swimmer/src/main/java/cnuphys/bin/.classpath +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - diff --git a/common-tools/cnuphys/swimmer/src/main/java/cnuphys/bin/.project b/common-tools/cnuphys/swimmer/src/main/java/cnuphys/bin/.project deleted file mode 100644 index 049cf6453d..0000000000 --- a/common-tools/cnuphys/swimmer/src/main/java/cnuphys/bin/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - swimmer - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/common-tools/coat-lib/deployDistribution.sh b/common-tools/coat-lib/deployDistribution.sh index 82f60669c1..ad46bd278c 100755 --- a/common-tools/coat-lib/deployDistribution.sh +++ b/common-tools/coat-lib/deployDistribution.sh @@ -8,7 +8,7 @@ cd `dirname $0` # Script is exporting existing Jar files to repository #------------------------------------------------------------------------------------------------- -VERSION=11.1.2 +VERSION=12.0.6t mvn org.apache.maven.plugins:maven-install-plugin:2.5.2:install-file \ -Dfile=target/coat-libs-${VERSION}-SNAPSHOT.jar \ diff --git a/common-tools/coat-lib/pom.xml b/common-tools/coat-lib/pom.xml index 19adba8240..d7a2270cf6 100644 --- a/common-tools/coat-lib/pom.xml +++ b/common-tools/coat-lib/pom.xml @@ -3,21 +3,21 @@ 4.0.0 org.jlab.clas coat-libs - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT pom local-build - https://clasweb.jlab.org/clas12maven + https://clasweb.jlab.org/.clas12maven jnp-build - https://clasweb.jlab.org/jhep/maven + https://clasweb.jlab.org/.jhep/maven freehep-repo-public - https://clasweb.jlab.org/clas12maven/ + https://clasweb.jlab.org/.clas12maven/ @@ -94,67 +94,67 @@ org.jlab.clas clas-io - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT org.jlab.clas clara-io - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT org.jlab.clas clas-reco - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT org.jlab.clas clas-utils - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT org.jlab.clas clas-jcsg - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT org.jlab.clas clas-detector - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT org.jlab.clas clas-analysis - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT org.jlab.clas clas-geometry - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT org.jlab.clas clas-physics - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT org.jlab.clas swim-tools - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT org.jlab.clas clas-tracking - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT diff --git a/common-tools/parent/pom.xml b/common-tools/parent/pom.xml index 2b2f55a848..5981c34caa 100644 --- a/common-tools/parent/pom.xml +++ b/common-tools/parent/pom.xml @@ -3,18 +3,18 @@ org.jlab.clas common-tools - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT pom clas12maven - https://clasweb.jlab.org/clas12maven + https://clasweb.jlab.org/.clas12maven jnp-maven - https://clasweb.jlab.org/jhep/maven + https://clasweb.jlab.org/.jhep/maven diff --git a/common-tools/pom.xml b/common-tools/pom.xml index 818a5f5b0d..af174eeb56 100644 --- a/common-tools/pom.xml +++ b/common-tools/pom.xml @@ -2,14 +2,14 @@ 4.0.0 org.jlab.clas common-tools - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT pom org.jlab.clas clas12rec ../parent/pom.xml - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT diff --git a/common-tools/swim-tools/pom.xml b/common-tools/swim-tools/pom.xml index ea39341ec5..e7a922364d 100644 --- a/common-tools/swim-tools/pom.xml +++ b/common-tools/swim-tools/pom.xml @@ -3,21 +3,21 @@ 4.0.0 org.jlab.clas swim-tools - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT org.jlab.clas clas-reco - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT diff --git a/docs/mkdocs/docs/index.md b/docs/mkdocs/docs/index.md new file mode 100644 index 0000000000..bcc06f3adb --- /dev/null +++ b/docs/mkdocs/docs/index.md @@ -0,0 +1,14 @@ +# COATJAVA + +## Documentation + +| | | +| --- | --- | +| [**API Documentation**](javadoc/index.html) | Documentation for classes and methods | +| [**HIPO Bank**](banks.md) | Bank descriptions | +| [**Source code**](https://github.com/JeffersonLab/coatjava) | The source code `git` repository | + +--- + +## Reports +- [Coverage Report](jacoco/index.html) diff --git a/docs/mkdocs/generate.sh b/docs/mkdocs/generate.sh new file mode 100755 index 0000000000..77110954eb --- /dev/null +++ b/docs/mkdocs/generate.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash + +set -euo pipefail + +# generate the documentation +if [ $# -ne 1 ]; then + echo "USAGE: $0 [output_dir]" >&2 + exit 2 +fi + +# make output dir +output_dir=$(realpath $1) +mkdir -p $output_dir + +# make build directory +build_dir=${output_dir}__build +mkdir -p $build_dir +rm -r $build_dir +mkdir -p $build_dir + +# source directories +src_dir=$(dirname $0) +top_dir=$src_dir/../.. + +# generate build files +cp $src_dir/mkdocs.yaml $build_dir/ +cp -r $src_dir/docs $build_dir/ +$src_dir/src/banks.rb $top_dir/etc/bankdefs/hipo4 > $build_dir/docs/banks.md +tree $build_dir + +# build +mkdocs build --config-file $build_dir/mkdocs.yaml --site-dir $output_dir +tree $output_dir diff --git a/docs/mkdocs/mkdocs.yaml b/docs/mkdocs/mkdocs.yaml new file mode 100644 index 0000000000..17b2f0e054 --- /dev/null +++ b/docs/mkdocs/mkdocs.yaml @@ -0,0 +1,10 @@ +site_name: COATJAVA Documentation +nav: + - Home: index.md + - HIPO Bank Definitions: banks.md +use_directory_urls: false +extra: + homepage: index.html +theme: + name: mkdocs + user_color_mode_toggle: auto diff --git a/docs/mkdocs/requirements.txt b/docs/mkdocs/requirements.txt new file mode 100644 index 0000000000..a5678a34b0 --- /dev/null +++ b/docs/mkdocs/requirements.txt @@ -0,0 +1 @@ +mkdocs>=1.6.1 diff --git a/etc/bankdefs/util/dumpBankIDs.rb b/docs/mkdocs/src/banks.rb similarity index 92% rename from etc/bankdefs/util/dumpBankIDs.rb rename to docs/mkdocs/src/banks.rb index 1f6ac8dc5f..4dafbf674b 100755 --- a/etc/bankdefs/util/dumpBankIDs.rb +++ b/docs/mkdocs/src/banks.rb @@ -51,13 +51,7 @@ # dump a table puts """# Bank Group and Item IDs -This file was generated by -```bash -#{$0} #{ARGV.join ' '} -``` - -> [!IMPORTANT] -> Please re-run this script if you modify any of the bank definitions. +> **NOTE:** Iguana banks, which are defined in the Iguana repository, use group number 30000. """ diff --git a/etc/bankdefs/hipo4/README.md b/etc/bankdefs/hipo4/README.md deleted file mode 100644 index 8b0eac1a24..0000000000 --- a/etc/bankdefs/hipo4/README.md +++ /dev/null @@ -1,401 +0,0 @@ -# Bank Group and Item IDs - -This file was generated by -```bash -etc/bankdefs/util/dumpBankIDs.rb etc/bankdefs/hipo4 -``` - -> [!IMPORTANT] -> Please re-run this script if you modify any of the bank definitions. - - -## Group 40 - -| Item ID | Name | Description | -| --- | --- | --- | -| 0 | `MC::Header` | Head bank for the generated event | -| 1 | `MC::Event` | Lund header bank for the generated event | -| 2 | `MC::Particle` | Generated Particle information | -| 3 | `MC::Lund` | Generated Particle information from Lund | -| 4 | `MC::True` | True detector information from GEANT4 | -| 5 | `MC::User` | User-defined information | -| 6 | `MC::GenMatch` | `MC::Particle` -> `REC::Particle` matching | -| 7 | `MC::RecMatch` | `Rec::Particle` -> `MC::Particle` matching | - -## Group 300 - -| Item ID | Name | Description | -| --- | --- | --- | -| 10 | `RECHB::Event` | Event Header Bank | -| 11 | `RECHB::Particle` | Reconstructed Particle Information | -| 12 | `RECHB::Calorimeter` | Calorimeter Responses for Particles bank | -| 13 | `RECHB::Cherenkov` | Cherenkov Responses for Particles bank | -| 14 | `RECHB::ForwardTagger` | Forward Tagger information for Particles bank | -| 15 | `RECHB::Scintillator` | Scintillator Responses for Particles bank | -| 16 | `RECHB::Track` | Track information for Particles bank | -| 17 | `RECHB::TrackCross` | Track Cross information for Particles bank (deprecated by `RECHB::Traj`) | -| 18 | `RECHB::Traj` | Trajectory information for Particles bank | -| 23 | `RECHB::ScintExtras` | Scintillator Cluster Parameters | -| 24 | `RECHB::CaloExtras` | Calorimeter Cluster Parameters | -| 30 | `REC::Event` | Event Header Bank | -| 31 | `REC::Particle` | Reconstructed Particle Information | -| 32 | `REC::Calorimeter` | Calorimeter Responses for Particles bank | -| 33 | `REC::Cherenkov` | Cherenkov Responses for Particles bank | -| 34 | `REC::ForwardTagger` | Forward Tagger information for Particles bank | -| 35 | `REC::Scintillator` | Scintillator Responses for Particles bank | -| 36 | `REC::Track` | Track information for Particles bank | -| 37 | `REC::TrackCross` | Track Cross information for Particles bank (deprecated by `REC::Traj`) | -| 38 | `REC::CovMat` | reconstructed track covariance matrix | -| 39 | `REC::VertDoca` | Track Cross information for Particles bank | -| 40 | `REC::Traj` | Trajectory information for Particles bank | -| 41 | `RECFT::Event` | Event Header Bank, shadowing `REC::Event` with FT-based start time | -| 42 | `RECFT::Particle` | Reconstructed Particle Information, shadowing `REC::Particle` with FT-based start time | -| 43 | `REC::ScintExtras` | Scintillator Cluster Parameters | -| 44 | `REC::UTrack` | Track information for Particles bank | -| 45 | `RECHB::UTrack` | Track information for Particles bank | -| 46 | `REC::CaloExtras` | Calorimeter Cluster Parameters | - -## Group 400 - -| Item ID | Name | Description | -| --- | --- | --- | -| 10 | `RECHBAI::Event` | Event Header Bank | -| 11 | `RECHBAI::Particle` | Reconstructed Particle Information | -| 12 | `RECHBAI::Calorimeter` | Calorimeter Responses for Particles bank | -| 13 | `RECHBAI::Cherenkov` | Cherenkov Responses for Particles bank | -| 14 | `RECHBAI::ForwardTagger` | Forward Tagger information for Particles bank | -| 15 | `RECHBAI::Scintillator` | Scintillator Responses for Particles bank | -| 16 | `RECHBAI::Track` | Track information for Particles bank | -| 17 | `RECHBAI::TrackCross` | Track Cross information for Particles bank (deprecated by `RECHBAI::Traj`) | -| 18 | `RECHBAI::Traj` | Trajectory information for Particles bank | -| 23 | `RECHBAI::ScintExtras` | Scintillator Cluster Parameters | -| 24 | `RECHBAI::CaloExtras` | Calorimeter Cluster Parameters | -| 30 | `RECAI::Event` | Event Header Bank | -| 31 | `RECAI::Particle` | Reconstructed Particle Information | -| 32 | `RECAI::Calorimeter` | Calorimeter Responses for Particles bank | -| 33 | `RECAI::Cherenkov` | Cherenkov Responses for Particles bank | -| 34 | `RECAI::ForwardTagger` | Forward Tagger information for Particles bank | -| 35 | `RECAI::Scintillator` | Scintillator Responses for Particles bank | -| 36 | `RECAI::Track` | Track information for Particles bank | -| 37 | `RECAI::TrackCross` | Track Cross information for Particles bank (deprecated by `RECAI::Traj`) | -| 38 | `RECAI::CovMat` | reconstructed track covariance matrix | -| 39 | `RECAI::VertDoca` | Track Cross information for Particles bank | -| 40 | `RECAI::Traj` | Trajectory information for Particles bank | -| 41 | `RECAIFT::Event` | Event Header Bank, shadowing `RECAI::Event` with FT-based start time | -| 42 | `RECAIFT::Particle` | Reconstructed Particle Information, shadowing `RECAI::Particle` with FT-based start time | -| 43 | `RECAI::ScintExtras` | Scintillator Cluster Parameters | -| 44 | `RECAI::UTrack` | Track information for Particles bank | -| 45 | `RECHBAI::UTrack` | Track information for Particles bank | -| 46 | `RECAI::CaloExtras` | Calorimeter Cluster Parameters | - -## Group 4200 - -| Item ID | Name | Description | -| --- | --- | --- | -| 1 | `nn::tracks` | track parameters from neural network | -| 2 | `nn::dchits` | index if the track hits in DC tdc bank. | -| 3 | `ai::tracks` | tracks identified with AI | -| 4 | `aidn::tracks` | tracks identified with denoised AI | - -## Group 10000 - -| Item ID | Name | Description | -| --- | --- | --- | -| 11 | `RUN::config` | Run Configuration | -| 12 | `RUN::rf` | RF information | -| 13 | `RUN::trigger` | RUN trigger information | -| 14 | `RUN::scaler` | Run-integrated, analyzed scalers. | -| 15 | `RUN::filter` | Random trigger filter information | -| 16 | `HEL::scaler` | Helicity-gated, analyzed scalers. | -| 17 | `COAT::config` | COATJAVA configuration, e.g. version numbers, CLARA YAML settings | - -## Group 20000 - -| Item ID | Name | Description | -| --- | --- | --- | -| 11 | `RAW::adc` | ADC bank for untranslated signals | -| 12 | `RAW::tdc` | TDC bank for untranslated signals | -| 13 | `RAW::scaler` | Scaler bank | -| 14 | `RAW::vtp` | VTP bank | -| 15 | `RAW::epics` | EPICS bank | - -## Group 20100 - -| Item ID | Name | Description | -| --- | --- | --- | -| 11 | `BMT::adc` | ADC bank for the Barrel MicroMegas Tracker | -| 21 | `BMTRec::Hits` | first pass reconstructed BMT hits on track | -| 22 | `BMTRec::Clusters` | first pass reconstructed BMT clusters | -| 25 | `BMTRec::Crosses` | first pass reconstructed BMT crosses | -| 26 | `BMTRec::LayerEffs` | layer efficiencies | -| 31 | `BMT::Hits` | reconstructed BMT hits on track | -| 32 | `BMT::Clusters` | reconstructed BMT clusters | -| 35 | `BMT::Crosses` | reconstructed BMT crosses | - -## Group 20200 - -| Item ID | Name | Description | -| --- | --- | --- | -| 11 | `BST::adc` | ADC bank for the Barrel Silicon Tracker | -| 21 | `BSTRec::Hits` | first pass reconstructed BST hits on track | -| 22 | `BSTRec::Clusters` | first pass reconstructed BST clusters | -| 25 | `BSTRec::Crosses` | first reconstructed BST crosses | -| 29 | `BSTRec::LayerEffs` | layer efficiencies | -| 31 | `BST::Hits` | reconstructed BST hits on track | -| 32 | `BST::Clusters` | reconstructed BST clusters | -| 35 | `BST::Crosses` | reconstructed BST crosses | - -## Group 20300 - -| Item ID | Name | Description | -| --- | --- | --- | -| 11 | `CND::adc` | ADC bank for the Central Neutron Detector | -| 12 | `CND::tdc` | TDC bank for the Central Neutron Detector | -| 21 | `CND::hits` | reconstructed hit info from CND | -| 22 | `CND::clusters` | reconstructed cluster info from CND and CTOF | - -## Group 20400 - -| Item ID | Name | Description | -| --- | --- | --- | -| 11 | `CTOF::adc` | ADC bank for the Central Time of Flight | -| 12 | `CTOF::tdc` | TDC bank for the Central Time of Flight | -| 20 | `CTOF::rawhits` | reconstructed hit info from U/D CTOF PMTs | -| 21 | `CTOF::hits` | reconstructed hit info from CTOF | -| 22 | `CTOF::clusters` | reconstructed clusters from CTOF | - -## Group 20500 - -| Item ID | Name | Description | -| --- | --- | --- | -| 25 | `CVTRec::Seeds` | first pass reconstructed CVT track seeds | -| 26 | `CVTRec::Tracks` | reconstructed CVT tracks | -| 27 | `CVTRec::UTracks` | reconstructed CVT tracks | -| 28 | `CVTRec::TrackCovMat` | reconstructed CVT tracks covariance matrix in track representation | -| 29 | `CVTRec::CosmicSeeds` | reconstructed CVT cosmic seed | -| 30 | `CVTRec::Cosmics` | reconstructed SVT cosmic tracks | -| 31 | `CVTRec::Trajectory` | Trajectory bank | -| 32 | `CVTRec::KFTrajectory` | Trajectory bank output from KF | -| 35 | `CVT::Seeds` | reconstructed CVT track seeds | -| 36 | `CVT::Tracks` | reconstructed CVT tracks | -| 37 | `CVT::UTracks` | reconstructed CVT tracks | -| 41 | `CVT::Trajectory` | Trajectory bank | -| 42 | `CVT::KFTrajectory` | Trajectory bank output from KF | -| 43 | `CVT::SeedClusters` | Ids of clusters on track for 12 layers of CVT | -| 44 | `CVTRec::SeedClusters` | Ids of clusters on track for 12 layers of CVT | - -## Group 20600 - -| Item ID | Name | Description | -| --- | --- | --- | -| 12 | `DC::tdc` | TDC bank for the Drift Chambers | -| 13 | `DC::jitter` | DCRB timestamps bank | -| 14 | `DC::doca` | Drift Chamber DOCA bank | -| 21 | `HitBasedTrkg::HBHits` | reconstructed hits using DC wire positions | -| 22 | `HitBasedTrkg::HBClusters` | reconstructed clusters using DC wire positions | -| 23 | `HitBasedTrkg::HBSegments` | reconstructed segments using DC wire positions | -| 24 | `HitBasedTrkg::HBSegmentTrajectory` | reconstructed segment trajectory from hit-based tracking | -| 25 | `HitBasedTrkg::HBCrosses` | reconstructed segments using DC wire positions | -| 26 | `HitBasedTrkg::HBTracks` | reconstructed tracks using DC wire positions | -| 27 | `HitBasedTrkg::HBHitTrkId` | pointers between track and hit banks | -| 28 | `HitBasedTrkg::Hits` | reconstructed hits using DC wire positions | -| 29 | `HitBasedTrkg::Clusters` | reconstructed clusters using DC wire positions | -| 30 | `HitBasedTrkg::Trajectory` | Trajectory bank | -| 31 | `TimeBasedTrkg::TBHits` | reconstructed hits using DC timing information | -| 32 | `TimeBasedTrkg::TBClusters` | reconstructed clusters using DC timing information | -| 33 | `TimeBasedTrkg::TBSegments` | reconstructed segments using DC timing information | -| 34 | `TimeBasedTrkg::TBSegmentTrajectory` | reconstructed segment trajectory from hit-based tracking | -| 35 | `TimeBasedTrkg::TBCrosses` | reconstructed segments using DC timing information | -| 36 | `TimeBasedTrkg::TBTracks` | reconstructed tracks using DC timing information | -| 37 | `TimeBasedTrkg::TBCovMat` | reconstructed track covariance matrix | -| 48 | `HitBasedTrkg::DNHits` | reconstructed hits using DC wire positions | -| 49 | `HitBasedTrkg::DNClusters` | reconstructed clusters using DC wire positions | -| 53 | `TimeBasedTrkg::Trajectory` | Trajectory bank | -| 61 | `HitBasedTrkg::AIHits` | reconstructed hits using DC wire positions | -| 62 | `HitBasedTrkg::AIClusters` | reconstructed clusters using DC wire positions | -| 63 | `HitBasedTrkg::AISegments` | reconstructed segments using DC wire positions | -| 65 | `HitBasedTrkg::AICrosses` | reconstructed segments using DC wire positions | -| 66 | `HitBasedTrkg::AITracks` | reconstructed tracks using DC wire positions | -| 67 | `HitBasedTrkg::AIHitTrkId` | pointers between track and hit banks | -| 68 | `HitBasedTrkg::AITrajectory` | Trajectory bank | -| 71 | `TimeBasedTrkg::AIHits` | reconstructed hits using DC timing information | -| 72 | `TimeBasedTrkg::AIClusters` | reconstructed clusters using DC timing information | -| 73 | `TimeBasedTrkg::AISegments` | reconstructed segments using DC timing information | -| 75 | `TimeBasedTrkg::AICrosses` | reconstructed segments using DC timing information | -| 76 | `TimeBasedTrkg::AITracks` | reconstructed tracks using DC timing information | -| 77 | `TimeBasedTrkg::AICovMat` | reconstructed track covariance matrix | -| 93 | `TimeBasedTrkg::AITrajectory` | Trajectory bank | - -## Group 20700 - -| Item ID | Name | Description | -| --- | --- | --- | -| 11 | `ECAL::adc` | ADC bank for the Electromagnetic Calorimeter | -| 12 | `ECAL::tdc` | TDC bank for the Electromagnetic Calorimeter | -| 21 | `ECAL::hits` | ECAL hits | -| 22 | `ECAL::peaks` | reconstructed peaks from ECAL | -| 23 | `ECAL::clusters` | reconstructed clusters in ECAL | -| 24 | `ECAL::calib` | Raw and recon peak energy and recon peak time from ECAL | -| 25 | `ECAL::moments` | ECCAL bank for clusters containing distances an moments | -| 26 | `ECAL::scaler` | Occupancy bank for the Electromagnetic Calorimeter | -| 27 | `ECAL::trigger` | Occupancy bank for trigger bits | - -## Group 20800 - -| Item ID | Name | Description | -| --- | --- | --- | -| 11 | `FMT::adc` | ADC bank for the Forward MicroMegas Tracker | -| 21 | `FMT::Hits` | reconstructed FMT hits | -| 22 | `FMT::Clusters` | reconstructed FMT clusters | -| 25 | `FMT::Crosses` | reconstructed FMT crosses | -| 36 | `FMT::Tracks` | reconstructed tracks using FMT information | -| 37 | `FMT::Trajectory` | FMT tracks trajectory bank | - -## Group 20900 - -| Item ID | Name | Description | -| --- | --- | --- | -| 24 | `FT::particles` | Reconstructed Particles in FT | - -## Group 21000 - -| Item ID | Name | Description | -| --- | --- | --- | -| 11 | `FTCAL::adc` | ADC bank for the Forward Tagger Calorimeter | -| 21 | `FTCAL::hits` | Reconstructed Hits in FT calorimeter | -| 22 | `FTCAL::clusters` | Reconstructed Clusters in FT calorimeter | - -## Group 21100 - -| Item ID | Name | Description | -| --- | --- | --- | -| 11 | `FTHODO::adc` | ADC bank for the Forward Tagger Hodoscope | -| 21 | `FTHODO::hits` | Reconstructed Hits in FT hodoscope | -| 22 | `FTHODO::clusters` | Reconstructed clusters in FT hodoscope | - -## Group 21200 - -| Item ID | Name | Description | -| --- | --- | --- | -| 11 | `FTOF::adc` | ADC bank for the Forward Time of Flight | -| 12 | `FTOF::tdc` | TDC bank for the Forward Time of Flight | -| 20 | `FTOF::rawhits` | reconstructed hit info from L/R FTOF PMTs | -| 21 | `FTOF::hbhits` | reconstructed hit info from FTOF | -| 22 | `FTOF::hbclusters` | reconstructed clusters from FTOF | -| 31 | `FTOF::hits` | reconstructed hit info from FTOF | -| 32 | `FTOF::clusters` | reconstructed clusters from FTOF | -| 33 | `FTOF::matchedclusters` | matched clusters from FTOF | - -## Group 21300 - -| Item ID | Name | Description | -| --- | --- | --- | -| 11 | `FTTRK::adc` | ADC bank for the Forward Tagger Tracker | -| 21 | `FTTRK::hits` | Reconstructed Hits in FT tracker | -| 22 | `FTTRK::clusters` | Reconstructed clusters in FT tracker | -| 23 | `FTTRK::crosses` | Reconstructed crosses in FT tracker | - -## Group 21500 - -| Item ID | Name | Description | -| --- | --- | --- | -| 11 | `HTCC::adc` | ADC bank for the High Threshold Cerenkov Counter | -| 12 | `HTCC::tdc` | TDC bank for the High Threshold Cerenkov Counter | -| 22 | `HTCC::rec` | reconstructed clusters in HTCC | - -## Group 21600 - -| Item ID | Name | Description | -| --- | --- | --- | -| 11 | `LTCC::adc` | ADC bank for the Low Threshold Cerenkov Counter | -| 12 | `LTCC::tdc` | TDC bank for the Low Threshold Cerenkov Counter | -| 22 | `LTCC::clusters` | reconstructed clusters from the LTCC | - -## Group 21700 - -| Item ID | Name | Description | -| --- | --- | --- | -| 11 | `RF::adc` | ADC bank for the RF signals | -| 12 | `RF::tdc` | TDC bank for the RF signals | - -## Group 21800 - -| Item ID | Name | Description | -| --- | --- | --- | -| 12 | `RICH::tdc` | TDC bank for the Ring Imaging Cerenkov Counter | -| 36 | `RICH::Ring` | Reconstructed Cherenov information for single photon | -| 37 | `RICH::Particle` | Reconstructed Cherenov information per track | -| 38 | `RICH::Hadron` | Reconstructed Hadrons in RICH | -| 39 | `RICH::Photon` | Reconstructed Photons in RICH | -| 40 | `RICH::Hit` | Reconstructed Hits in RICH | -| 41 | `RICH::Signal` | Reconstructed Signals in RICH | -| 42 | `RICH::Cluster` | Reconstructed Clusters in RICH | -| 43 | `RICH::Response` | RICH Responses for Particles bank | - -## Group 21900 - -| Item ID | Name | Description | -| --- | --- | --- | -| 11 | `RTPC::adc` | ADC bank for the Radial TPC | -| 14 | `RTPC::pos` | Digitized bank for the Radial TPC | -| 21 | `RTPC::hits` | reconstructed RTPC hits | -| 22 | `RTPC::tracks` | reconstructed track info | -| 23 | `RTPC::KFtracks` | Kalman Fitter track info | - -## Group 22000 - -| Item ID | Name | Description | -| --- | --- | --- | -| 11 | `HEL::adc` | ADC bank for the Helicity signals. Compoment 1/2/3 is helicity/sync/quartet. | -| 12 | `HEL::flip` | Helicity flips from ADC bank. State values are -1/0/+1, where 0 is invalid. | -| 13 | `HEL::online` | Helicity with online delay-correction in Level3 trigger | -| 14 | `HEL::decoder` | Helicity decoder board data | - -## Group 22100 - -| Item ID | Name | Description | -| --- | --- | --- | -| 11 | `BAND::adc` | ADC bank for the Backward Angle Neutron Detector | -| 12 | `BAND::tdc` | TDC bank for the Backward Angle Neutron Detector | -| 21 | `BAND::hits` | reconstructed coincidence hits from BAND | -| 22 | `BAND::rawhits` | single PMT hits from BAND | -| 23 | `BAND::laser` | laser hits from BAND | - -## Group 22200 - -| Item ID | Name | Description | -| --- | --- | --- | -| 11 | `RASTER::adc` | ADC bank for the Raster signals | -| 21 | `RASTER::position` | Reconstructed raster position | - -## Group 22300 - -| Item ID | Name | Description | -| --- | --- | --- | -| 11 | `URWELL::adc` | ADC bank for the URWELL | -| 21 | `URWELL::hits` | URWELL hits | -| 22 | `URWELL::clusters` | reconstructed clusters from URWELL | -| 23 | `URWELL::crosses` | reconstructed crosses from URWELL | - -## Group 22400 - -| Item ID | Name | Description | -| --- | --- | --- | -| 12 | `AHDC::tdc` | TDC bank for the ALERT Wire Chamber | - -## Group 22500 - -| Item ID | Name | Description | -| --- | --- | --- | -| 11 | `ATOF::adc` | ADC bank for the ALERT time-of-flight detector | - -## Group 23000 - -| Item ID | Name | Description | -| --- | --- | --- | -| 21 | `AHDC::Track` | Reco Tracks | -| 22 | `AHDC::MC` | MC Tracks | -| 23 | `AHDC::Hits` | Raw Hits | -| 24 | `AHDC::PreClusters` | Pre Clusters info | -| 25 | `AHDC::Clusters` | Clusters info | -| 26 | `AHDC::KFTrack` | Reco Kalman Filter Tracks | diff --git a/etc/bankdefs/hipo4/alert.json b/etc/bankdefs/hipo4/alert.json index 611babce13..dd57254c5c 100644 --- a/etc/bankdefs/hipo4/alert.json +++ b/etc/bankdefs/hipo4/alert.json @@ -1,6 +1,6 @@ [ { - "name": "ALERT::Projections", + "name": "ALERT::projections", "group": 23000, "item": 31, "info": "Track Projections to ATOF", @@ -10,7 +10,7 @@ "type": "S", "info": "projection id" },{ - "name": "trackID", + "name": "trackid", "type": "S", "info": "id of the track that was projected" }, { @@ -26,11 +26,11 @@ "type": "F", "info": "z position at atof bar (middle surface) in mm" },{ - "name": "L_at_bar", + "name": "l_at_bar", "type": "F", "info": "path length at atof bar (inner surface) in mm" },{ - "name": "L_in_bar", + "name": "l_in_bar", "type": "F", "info": "path length inside atof bar in mm" },{ @@ -46,11 +46,11 @@ "type": "F", "info": "z position at atof wedge (middle surface) in mm" },{ - "name": "L_at_wedge", + "name": "l_at_wedge", "type": "F", "info": "path length at atof wedge (inner surface) in mm" },{ - "name": "L_in_wedge", + "name": "l_in_wedge", "type": "F", "info": "path length inside atof wedge in mm" } @@ -114,11 +114,11 @@ "type": "S", "info": "hit id" }, { - "name": "N_bar", + "name": "n_bar", "type": "I", "info": "number of hits from the bars" }, { - "name": "N_wedge", + "name": "n_wedge", "type": "I", "info": "number of hits from the wedges" },{ @@ -156,13 +156,13 @@ } ] },{ - "name": "AHDC::Hits", + "name": "AHDC::hits", "group": 23000, "item": 23, "info": "Raw Hits", "entries": [ { - "name": "ID", + "name": "id", "type": "S", "info": "hit id" }, { @@ -178,54 +178,74 @@ "type": "I", "info": "wire number" }, { - "name": "Doca", + "name": "doca", "type": "D", - "info": "distance od closest approch (mm)" + "info": "distance od closest approch (mm) is actually the distance from time2distance calibration" + }, { + "name": "residual", + "type": "D", + "info": "residual (mm) is distance from time2distance calibration minus the distance of closest approach computed at the Kalman Filter stage" + }, { + "name": "residual_prefit", + "type": "D", + "info": "residual pre-fit (mm)" + }, { + "name": "time", + "type": "D", + "info": "time (ns) is leadingEdgeTime from AHDC::adc minus t0 from calibration" + }, { + "name": "trackid", + "type": "I", + "info": "track id, is -1 if not associated to a Track" } ] }, { - "name": "AHDC::PreClusters", + "name": "AHDC::preclusters", "group": 23000, "item": 24, "info": "Pre Clusters info", "entries": [ { - "name": "X", + "name": "x", "type": "F", - "info": "X info (mm)" + "info": "x info (mm)" }, { - "name": "Y", + "name": "y", "type": "F", - "info": "Y info (mm)" + "info": "y info (mm)" } ] }, { - "name": "AHDC::Clusters", + "name": "AHDC::clusters", "group": 23000, "item": 25, "info": "Clusters info", "entries": [ { - "name": "X", + "name": "x", "type": "F", - "info": "X info (mm)" + "info": "x info (mm)" }, { - "name": "Y", + "name": "y", "type": "F", - "info": "Y info (mm)" + "info": "y info (mm)" }, { - "name": "Z", + "name": "z", "type": "F", - "info": "Z info (mm)" + "info": "z info (mm)" } ] }, { - "name": "AHDC::Track", + "name": "AHDC::track", "group": 23000, "item": 21, "info": "Reco Tracks", "entries": [ { + "name": "trackid", + "type": "I", + "info": "track id" + }, { "name": "x", "type": "F", "info": "x position in mm" @@ -249,15 +269,47 @@ "name": "pz", "type": "F", "info": "pz in MeV" + }, { + "name": "n_hits", + "type": "I", + "info": "number of hits" + }, { + "name": "sum_adc", + "type": "I", + "info": "Sum of adc (adc)" + }, { + "name": "path", + "type": "F", + "info": "Length of the track (mm)" + }, { + "name": "dEdx", + "type": "F", + "info": "Deposited energy per path (adc/mm)" + }, { + "name": "p_drift", + "type": "F", + "info": "Momentum in the drift region (MeV)" + }, { + "name": "chi2", + "type": "F", + "info": "Sum of squared residuals (mm^2)" + }, { + "name": "sum_residuals", + "type": "F", + "info": "Sum of residuals (mm)" } ] }, { - "name": "AHDC::KFTrack", + "name": "AHDC::kftrack", "group": 23000, "item": 26, "info": "Reco Kalman Filter Tracks", "entries": [ { + "name": "trackid", + "type": "I", + "info": "track id" + }, { "name": "x", "type": "F", "info": "x position in mm" @@ -281,10 +333,38 @@ "name": "pz", "type": "F", "info": "pz in MeV" + }, { + "name": "n_hits", + "type": "I", + "info": "number of hits" + }, { + "name": "sum_adc", + "type": "I", + "info": "Sum of adc (adc)" + }, { + "name": "path", + "type": "F", + "info": "Length of the track (mm)" + }, { + "name": "dEdx", + "type": "F", + "info": "Deposited energy per path (adc/mm)" + }, { + "name": "p_drift", + "type": "F", + "info": "Momentum in the drift region (MeV)" + }, { + "name": "chi2", + "type": "F", + "info": "Sum of squared residuals (mm^2)" + }, { + "name": "sum_residuals", + "type": "F", + "info": "Sum of residuals (mm)" } ] }, { - "name": "AHDC::MC", + "name": "AHDC::mc", "group": 23000, "item": 22, "info": "MC Tracks", @@ -317,22 +397,22 @@ ] }, { - "name": "AHDC_AI::Prediction", + "name": "AHDC::ai:prediction", "group": 23000, "item": 30, "info": "Prediction given by AI", "entries": [ - {"name": "X1", "type": "F", "info": "X1 position of the 1th superprecluster (mm)"}, - {"name": "Y1", "type": "F", "info": "Y1 position of the 1th superprecluster (mm)"}, - {"name": "X2", "type": "F", "info": "X2 position of the 2nd superprecluster (mm)"}, - {"name": "Y2", "type": "F", "info": "Y2 position of the 2nd superprecluster (mm)"}, - {"name": "X3", "type": "F", "info": "X3 position of the 3rd superprecluster (mm)"}, - {"name": "Y3", "type": "F", "info": "Y3 position of the 3rd superprecluster (mm)"}, - {"name": "X4", "type": "F", "info": "X4 position of the 4th superprecluster (mm)"}, - {"name": "Y4", "type": "F", "info": "Y4 position of the 4th superprecluster (mm)"}, - {"name": "X5", "type": "F", "info": "X5 position of the 5th superprecluster (mm)"}, - {"name": "Y5", "type": "F", "info": "Y5 position of the 5th superprecluster (mm)"}, - {"name": "Pred", "type": "F", "info": "Prediction of the model: 0 mean bad track; 1 mean good track"} + {"name": "x1", "type": "F", "info": "X1 position of the 1th superprecluster (mm)"}, + {"name": "y1", "type": "F", "info": "Y1 position of the 1th superprecluster (mm)"}, + {"name": "x2", "type": "F", "info": "X2 position of the 2nd superprecluster (mm)"}, + {"name": "y2", "type": "F", "info": "Y2 position of the 2nd superprecluster (mm)"}, + {"name": "x3", "type": "F", "info": "X3 position of the 3rd superprecluster (mm)"}, + {"name": "y3", "type": "F", "info": "Y3 position of the 3rd superprecluster (mm)"}, + {"name": "x4", "type": "F", "info": "X4 position of the 4th superprecluster (mm)"}, + {"name": "y4", "type": "F", "info": "Y4 position of the 4th superprecluster (mm)"}, + {"name": "x5", "type": "F", "info": "X5 position of the 5th superprecluster (mm)"}, + {"name": "y5", "type": "F", "info": "Y5 position of the 5th superprecluster (mm)"}, + {"name": "pred", "type": "F", "info": "Prediction of the model: 0 mean bad track; 1 mean good track"} ] } ] diff --git a/etc/bankdefs/hipo4/data.json b/etc/bankdefs/hipo4/data.json index 5ccc2696e4..826813894d 100644 --- a/etc/bankdefs/hipo4/data.json +++ b/etc/bankdefs/hipo4/data.json @@ -40,40 +40,7 @@ { "name":"s28" , "type":"S", "info":""}, { "name":"s29" , "type":"S", "info":""}, { "name":"s30" , "type":"S", "info":""}, - { "name":"s31" , "type":"S", "info":""}, - { "name":"s32" , "type":"S", "info":""}, - { "name":"s33" , "type":"S", "info":""}, - { "name":"s34" , "type":"S", "info":""}, - { "name":"s35" , "type":"S", "info":""}, - { "name":"s36" , "type":"S", "info":""}, - { "name":"s37" , "type":"S", "info":""}, - { "name":"s38" , "type":"S", "info":""}, - { "name":"s39" , "type":"S", "info":""}, - { "name":"s40" , "type":"S", "info":""}, - { "name":"s41" , "type":"S", "info":""}, - { "name":"s42" , "type":"S", "info":""}, - { "name":"s43" , "type":"S", "info":""}, - { "name":"s44" , "type":"S", "info":""}, - { "name":"s45" , "type":"S", "info":""}, - { "name":"s46" , "type":"S", "info":""}, - { "name":"s47" , "type":"S", "info":""}, - { "name":"s48" , "type":"S", "info":""}, - { "name":"s49" , "type":"S", "info":""}, - { "name":"s50" , "type":"S", "info":""}, - { "name":"s51" , "type":"S", "info":""}, - { "name":"s52" , "type":"S", "info":""}, - { "name":"s53" , "type":"S", "info":""}, - { "name":"s54" , "type":"S", "info":""}, - { "name":"s55" , "type":"S", "info":""}, - { "name":"s56" , "type":"S", "info":""}, - { "name":"s57" , "type":"S", "info":""}, - { "name":"s58" , "type":"S", "info":""}, - { "name":"s59" , "type":"S", "info":""}, - { "name":"s60" , "type":"S", "info":""}, - { "name":"s61" , "type":"S", "info":""}, - { "name":"s62" , "type":"S", "info":""}, - { "name":"s63" , "type":"S", "info":""}, - { "name":"s64" , "type":"S", "info":""} + { "name":"time" , "type":"I", "info":"for fine time correction"} ] }, { @@ -107,7 +74,9 @@ { "name":"component" , "type":"S", "info":"signal (1-2)"}, { "name":"order" , "type":"B", "info":"order: 2 - TDCL , 3 - TDCR"}, { "name":"TDC" , "type":"I", "info":"TDC value"}, - { "name":"ToT" , "type":"I", "info":"Time Over Threshold"} + { "name":"ToT" , "type":"I", "info":"Time Over Threshold"}, + { "name":"timestamp" , "type":"L", "info":"timestamp"}, + { "name":"trigger" , "type":"I", "info":"trigger number"} ] }, { @@ -209,7 +178,8 @@ { "name":"layer" , "type":"B", "info":"layer (1..36)"}, { "name":"component" , "type":"S", "info":"wire number (1..112)"}, { "name":"order" , "type":"B", "info":"order: 2 - TDCL , 3 - TDCR"}, - { "name":"TDC" , "type":"I", "info":"TDC value"} + { "name":"TDC" , "type":"I", "info":"TDC value"}, + { "name":"ToT" , "type":"S", "info":"Time Over Threshold"} ] }, { diff --git a/etc/bankdefs/hipo4/dc.json b/etc/bankdefs/hipo4/dc.json index 616528e41b..53852e00b3 100644 --- a/etc/bankdefs/hipo4/dc.json +++ b/etc/bankdefs/hipo4/dc.json @@ -6,7 +6,7 @@ "info": "reconstructed hits using DC wire positions", "entries": [ {"name":"id", "type":"S", "info":"id of the hit"}, - {"name": "indexTDC", "type":"S", "info":"inex in the bank DC::TDC"}, + {"name":"indexTDC", "type":"S", "info":"index in the bank DC::TDC"}, {"name":"status", "type":"S", "info":"id of the hit"}, {"name":"sector", "type":"B", "info":"DC sector"}, {"name":"superlayer", "type":"B", "info":"DC superlayer (1...6)"}, @@ -62,6 +62,7 @@ "info": "reconstructed hits using DC wire positions", "entries": [ {"name":"id", "type":"S", "info":"id of the hit"}, + {"name":"indexTDC", "type":"S", "info":"index in the bank DC::TDC"}, {"name":"status", "type":"S", "info":"id of the hit"}, {"name":"sector", "type":"B", "info":"DC sector"}, {"name":"superlayer", "type":"B", "info":"DC superlayer (1...6)"}, diff --git a/etc/bankdefs/hipo4/dcnn.json b/etc/bankdefs/hipo4/dcnn.json index 7a2aa7be58..74276a745d 100644 --- a/etc/bankdefs/hipo4/dcnn.json +++ b/etc/bankdefs/hipo4/dcnn.json @@ -6,6 +6,7 @@ "info": "reconstructed hits using DC wire positions", "entries": [ {"name":"id", "type":"S", "info":"id of the hit"}, + {"name":"indexTDC", "type":"S", "info":"index in the bank DC::TDC"}, {"name":"status", "type":"S", "info":"id of the hit"}, {"name":"sector", "type":"B", "info":"DC sector"}, {"name":"superlayer", "type":"B", "info":"DC superlayer (1...6)"}, diff --git a/etc/bankdefs/util/bankSplit.py b/etc/bankdefs/util/bankSplit.py index 7d93505028..95bed900f1 100755 --- a/etc/bankdefs/util/bankSplit.py +++ b/etc/bankdefs/util/bankSplit.py @@ -65,7 +65,7 @@ def create(dirname, banklist): raster = ["RASTER::position"] rich = ["RICH::tdc","RICH::Ring","RICH::Particle"] rtpc = ["RTPC::hits","RTPC::tracks","RTPC::KFtracks"] -alert = ["AHDC::Track", "AHDC::MC", "AHDC::Hits", "AHDC::PreClusters", "AHDC::Clusters", "AHDC::KFTrack", "AHDC_AI::Prediction"] +alert = ["AHDC::track", "AHDC::mc", "AHDC::hits", "AHDC::preclusters", "AHDC::clusters", "AHDC::kftrack", "AHDC::ai:prediction"] dets = band + raster + rich + rtpc + alert # additions for the calibration schema: @@ -107,6 +107,15 @@ def create(dirname, banklist): level3 = list(dst) level3.extend(["DC::tdc", "ECAL::adc", "ECAL::clusters", "FTOF::tdc", "FTOF::adc", "HitBasedTrkg::HBClusters", "HitBasedTrkg::HBTracks", "HTCC::adc", "RF::adc", "RF::tdc", "RUN::rf", "TimeBasedTrkg::TBClusters", "TimeBasedTrkg::TBTracks"]) +import glob +rgl = glob.glob('./singles/full/ALERT*.json') +rgl.extend(glob.glob('./singles/full/AHDC*.json')) +rgl.extend(glob.glob('./singles/full/ATOF*.json')) +rgl = [os.path.basename(x)[:-5] for x in rgl] +calib.extend(rgl) +mon.extend(rgl) +dst.extend(rgl) + create("dst/", set(dst)) create("dsthb/", set(dsthb)) create("calib/", set(calib)) diff --git a/etc/data/test/ahdc.hipo b/etc/data/test/ahdc.hipo new file mode 100644 index 0000000000..25ce56c19b Binary files /dev/null and b/etc/data/test/ahdc.hipo differ diff --git a/etc/data/test/atof.hipo b/etc/data/test/atof.hipo new file mode 100644 index 0000000000..8f55b52ae4 Binary files /dev/null and b/etc/data/test/atof.hipo differ diff --git a/etc/ejml/ejmlclas12.network b/etc/ejml/ejmlclas12.network index d15f5a1cf2..c63596b28c 100644 Binary files a/etc/ejml/ejmlclas12.network and b/etc/ejml/ejmlclas12.network differ diff --git a/libexec/env.sh b/libexec/env.sh index c1825694b1..e11b653c23 100644 --- a/libexec/env.sh +++ b/libexec/env.sh @@ -1,7 +1,6 @@ #!/bin/bash -CLAS12DIR=$(cd $(dirname ${BASH_SOURCE[0]:-$0})/.. && pwd -P) -export CLAS12DIR +export CLAS12DIR=$(cd $(dirname ${BASH_SOURCE[0]:-$0})/.. && pwd -P) # Set default field maps (but do not override user's env): if [ -z "${COAT_MAGFIELD_TORUSMAP-}" ]; then @@ -37,3 +36,16 @@ if [ $# -ge 1 ]; then fi fi + +function split_cli { + jvm_options=() + class_options=() + while [[ $# -gt 0 ]] + do + case $1 in + --) shift && jvm_options=("${@}") && break ;; + *) class_options+=($1) && shift ;; + esac + done +} + diff --git a/parent/pom.xml b/parent/pom.xml index 7ec68aacdb..a8c84578fe 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -3,18 +3,18 @@ org.jlab.clas clas12rec - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT pom clas12maven - https://clasweb.jlab.org/clas12maven + https://clasweb.jlab.org/.clas12maven jnp-maven - https://clasweb.jlab.org/jhep/maven + https://clasweb.jlab.org/.jhep/maven @@ -56,7 +56,7 @@ org.jacoco jacoco-maven-plugin - 0.8.12 + 0.8.13 @@ -115,7 +115,7 @@ com.github.spotbugs spotbugs-maven-plugin - 4.8.6.6 + 4.9.3.0 spotbugs-exclude.xml @@ -134,7 +134,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.13.0 + 3.14.0 17 UTF-8 @@ -177,7 +177,7 @@ org.jacoco jacoco-maven-plugin - 0.8.12 + 0.8.13 diff --git a/pom.xml b/pom.xml index dfa7482c60..b34f89a69b 100644 --- a/pom.xml +++ b/pom.xml @@ -1,15 +1,21 @@ + + UTF-8 + UTF-8 + + 4.0.0 org.jlab.clas clas12 - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT pom + org.jlab.clas clas12rec parent/pom.xml - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT diff --git a/reconstruction/alert/pom.xml b/reconstruction/alert/pom.xml index a6e4c5cf61..1f6ebc0267 100644 --- a/reconstruction/alert/pom.xml +++ b/reconstruction/alert/pom.xml @@ -13,31 +13,37 @@ org.jlab.clas clas12rec ../../parent/pom.xml - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT org.jlab.clas clas-reco - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT org.jlab.clas clas-io - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT + compile + + + org.jlab.clas + clas-analysis + 12.0.6t-SNAPSHOT compile org.jlab.clas clas-tracking - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT compile org.jlab.clas clas-geometry - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT compile diff --git a/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/AI/Model.java b/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/AI/Model.java index a558763d78..83813a8561 100644 --- a/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/AI/Model.java +++ b/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/AI/Model.java @@ -16,6 +16,11 @@ import java.io.IOException; import java.nio.file.Paths; +/** Model of What. + * + * + * \todo fix class name + */ public class Model { private ZooModel model; @@ -34,6 +39,9 @@ public NDList processInput(TranslatorContext translatorContext, float[] floats) return new NDList(samples); } }; + System.setProperty("ai.djl.pytorch.num_interop_threads", "1"); + System.setProperty("ai.djl.pytorch.num_threads", "1"); + System.setProperty("ai.djl.pytorch.graph_optimizer", "false"); String path = CLASResources.getResourcePath("etc/nnet/ALERT/model_AHDC/"); Criteria my_model = Criteria.builder().setTypes(float[].class, Float.class) diff --git a/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/AI/PreclusterSuperlayer.java b/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/AI/PreclusterSuperlayer.java index ecab32728c..f1773e73e9 100644 --- a/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/AI/PreclusterSuperlayer.java +++ b/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/AI/PreclusterSuperlayer.java @@ -39,6 +39,10 @@ public double getY() { return y; } + public int getSuperlayer() { + return this.preclusters.get(0).get_Super_layer(); + } + public String toString() { return "PreCluster{" + "X: " + this.x + " Y: " + this.y + " phi: " + Math.atan2(this.y, this.x) + "}\n"; diff --git a/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/AI/TrackConstruction.java b/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/AI/TrackConstruction.java index dce5414001..d88ee4a661 100644 --- a/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/AI/TrackConstruction.java +++ b/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/AI/TrackConstruction.java @@ -1,5 +1,6 @@ package org.jlab.rec.ahdc.AI; +import org.apache.commons.lang3.mutable.MutableBoolean; import org.jlab.rec.ahdc.Hit.Hit; import java.io.File; @@ -7,9 +8,31 @@ import java.io.IOException; import java.util.*; +/** + * The TrackConstruction class is responsible for constructing all possible track + * candidates from a set of superpreclusters. + */ public class TrackConstruction { + private int max_number_of_track_candidates = 10000; + private double max_angle = Math.toRadians(60); + + /** + * Default constructor. + */ public TrackConstruction() {} + /** + * Computes the modulo operation, which returns the remainder of the division + * of one number by another. This method handles floating-point edge cases + * to ensure accurate results within the expected range. + * + * @param x The dividend. + * @param y The divisor. If y is 0, the method returns x. + * @return The result of x modulo y. The result is in the range: + * - [0..y) if y > 0 + * - (y..0] if y < 0 + * Special cases are handled to avoid floating-point inaccuracies. + */ private double mod(double x, double y) { if (0. == y) return x; @@ -33,74 +56,135 @@ private double mod(double x, double y) { return m; } + + /** + * Wraps an angle to the range [0, 2Ï€). + * + * @param angle The angle to wrap. + * @return The angle wrapped to the range [0, 2Ï€). + */ private double warp_zero_two_pi(double angle) { return mod(angle, 2. * Math.PI); } + /** + * Checks if an angle is within a specified range. + * + * @param angle The angle to check. + * @param lower The lower bound of the range. + * @param upper The upper bound of the range. + * @return {@code true} if the angle is within the range, {@code false} otherwise. + */ private boolean angle_in_range(double angle, double lower, double upper) { return warp_zero_two_pi(angle - lower) <= warp_zero_two_pi(upper - lower); } + /** + * Computes the Cartesian product of two lists of integers, ensuring the number of track candidates + * does not exceed the maximum allowed limit. + * + * @param v1 The first list of integer combinations. + * @param v2 The second list of integers to combine with the first list. + * @param too_much_track_candidates A mutable boolean that is set to {@code true} if the number of track candidates exceeds the maximum limit. + * @param number_of_track_candidates The current count of track candidates. + * @return A list of all possible combinations of integers from {@code v1} and {@code v2}. + */ + private ArrayList> cartesian_product(ArrayList> v1, ArrayList v2, MutableBoolean too_much_track_candidates, int number_of_track_candidates) { + ArrayList> result = new ArrayList<>(); + for (ArrayList i : v1) { + if (too_much_track_candidates.booleanValue()) break; + for (int j : v2) { + if (too_much_track_candidates.booleanValue()) break; + ArrayList n = new ArrayList<>(i); + n.add(j); + result.add(n); + + if (number_of_track_candidates + result.size() >= max_number_of_track_candidates) { + too_much_track_candidates.setValue(true); + break; + } + } + - public ArrayList> get_all_possible_track(ArrayList preclusterSuperlayers) { - - // Get seeds to start the track finding algorithm - ArrayList seeds = new ArrayList<>(); - for (PreclusterSuperlayer precluster : preclusterSuperlayers) { - if (precluster.getPreclusters().get(0).get_hits_list().get(0).getSuperLayerId() == 1) seeds.add(precluster); } - seeds.sort(new Comparator() { - @Override - public int compare(PreclusterSuperlayer a1, PreclusterSuperlayer a2) { - return Double.compare(Math.atan2(a1.getY(), a1.getX()), Math.atan2(a2.getY(), a2.getX())); + return result; + } + + public boolean get_all_possible_track(ArrayList preclusterSuperlayers, ArrayList> all_track_candidates) { + + /* + Identify all superpreclusters located in the first superlayer. + These superpreclusters serve as seeds for constructing track candidates. + A track candidate always starts from a seed. + */ + ArrayList seed_index = new ArrayList<>(); + for (int i = 0; i < preclusterSuperlayers.size(); i++) { + if (!preclusterSuperlayers.get(i).getPreclusters().isEmpty() && + preclusterSuperlayers.get(i).getSuperlayer() == 1) { + seed_index.add(i); } - }); - // System.out.println("seeds: " + seeds); + } - // Get all possible tracks ---------------------------------------------------------------- - double max_angle = Math.toRadians(60); - ArrayList> all_combinations = new ArrayList<>(); - for (PreclusterSuperlayer seed : seeds) { - double phi_seed = warp_zero_two_pi(Math.atan2(seed.getY(), seed.getX())); + boolean sucess = true; + int number_of_track_candidates = 0; - ArrayList track = new ArrayList<>(); - for (PreclusterSuperlayer p : preclusterSuperlayers) { - double phi_p = warp_zero_two_pi(Math.atan2(p.getY(), p.getX())); - if (angle_in_range(phi_p, phi_seed - max_angle, phi_seed + max_angle)) track.add(p); - } - // System.out.println("track: " + track.size()); - - ArrayList> combinations = new ArrayList<>(List.of(new ArrayList<>(List.of(seed)))); - // System.out.println("combinations: " + combinations); - - for (int i = 1; i < 5; ++i) { - ArrayList> new_combinations = new ArrayList<>(); - for (ArrayList combination : combinations) { - - for (PreclusterSuperlayer precluster : track) { - if (precluster.getPreclusters().get(0).get_hits_list().get(0).getSuperLayerId() == seed.getPreclusters().get(0).get_hits_list().get(0).getSuperLayerId() + i) { - // System.out.printf("Good Precluster x: %.2f, y: %.2f, r: %.2f%n", precluster.getX(), precluster.getY(), Math.hypot(precluster.getX(), precluster.getY())); - // System.out.println("combination: " + combination); - - ArrayList new_combination = new ArrayList<>(combination); - new_combination.add(precluster); - // System.out.println("new_combination: " + new_combination); - new_combinations.add(new_combination); - } - } - for (ArrayList c : new_combinations) { - // System.out.println("c.size: " + c.size() + ", c: " + c); - } + // Loop over all seeds to construct track candidates + for (int s : seed_index) { + // Check if the number of track candidates exceeds the maximum limit if so, stop the loop + if (!sucess) break; + // Find all superpreclusters that have a phi angle within phi angle of the seed +/- 60 degrees + // The goal is to reduce the number of superpreclusters to loop over + double phi_seed = warp_zero_two_pi(Math.atan2(preclusterSuperlayers.get(s).getY(), preclusterSuperlayers.get(s).getX())); // phi angle of the seed + ArrayList all_superpreclusters = new ArrayList<>(); // all superpreclusters that are within phi angle of the seed + for (int i = 0; i < preclusterSuperlayers.size(); ++i) { + double phi_p = warp_zero_two_pi(Math.atan2(preclusterSuperlayers.get(i).getY(), preclusterSuperlayers.get(i).getX())); + if (angle_in_range(phi_p, phi_seed - max_angle, phi_seed + max_angle)) { + all_superpreclusters.add(i); } - combinations = new_combinations; - if (combinations.size() > 10000) break; } - for (ArrayList combination : combinations) { - if (combination.size() == 5) { - all_combinations.add(combination); + + + // Sort the superpreclusters by superlayer to have a simpler loops after + ArrayList superpreclusters_s1 = new ArrayList<>(List.of(s)); + ArrayList superpreclusters_s3 = new ArrayList<>(); + ArrayList superpreclusters_s4 = new ArrayList<>(); + ArrayList superpreclusters_s2 = new ArrayList<>(); + ArrayList superpreclusters_s5 = new ArrayList<>(); + + for (int i = 0; i < all_superpreclusters.size(); i++) { + if (preclusterSuperlayers.get(all_superpreclusters.get(i)).getPreclusters().get(0).get_Super_layer() == 2) + superpreclusters_s2.add(all_superpreclusters.get(i)); + else if (preclusterSuperlayers.get(all_superpreclusters.get(i)).getPreclusters().get(0).get_Super_layer() == 3) + superpreclusters_s3.add(all_superpreclusters.get(i)); + else if (preclusterSuperlayers.get(all_superpreclusters.get(i)).getPreclusters().get(0).get_Super_layer() == 4) + superpreclusters_s4.add(all_superpreclusters.get(i)); + else if (preclusterSuperlayers.get(all_superpreclusters.get(i)).getPreclusters().get(0).get_Super_layer() == 5) + superpreclusters_s5.add(all_superpreclusters.get(i)); + } + + MutableBoolean too_much_track_candidates = new MutableBoolean(); // Need to be a mutable boolean to be able to change it in the cartesian_product method + too_much_track_candidates.setFalse(); + + // Find all possible combinations of superpreclusters on different superlayers + ArrayList> combinations_s1_s2 = cartesian_product(new ArrayList<>(List.of(superpreclusters_s1)), superpreclusters_s2, too_much_track_candidates, number_of_track_candidates); + ArrayList> combinations_s1_s2_s3 = cartesian_product(combinations_s1_s2, superpreclusters_s3, too_much_track_candidates, number_of_track_candidates); + ArrayList> combinations_s1_s2_s3_s4 = cartesian_product(combinations_s1_s2_s3, superpreclusters_s4, too_much_track_candidates, number_of_track_candidates); + ArrayList> combinations_s1_s2_s3_s4_s5 = cartesian_product(combinations_s1_s2_s3_s4, superpreclusters_s5, too_much_track_candidates, number_of_track_candidates); + + // Keep track of the number of track candidates + number_of_track_candidates += combinations_s1_s2_s3_s4_s5.size(); + if (too_much_track_candidates.booleanValue()) sucess = false; // If the number of track candidates exceeds the maximum limit, set success to false + + // Add all track candidates to the list of all track candidates + // And switch back from index to superprecluster + for (ArrayList combination : combinations_s1_s2_s3_s4_s5) { + ArrayList track_candidate = new ArrayList<>(); + for (int index : combination) { + track_candidate.add(preclusterSuperlayers.get(index)); } + all_track_candidates.add(track_candidate); } } - return all_combinations; + return sucess; } } diff --git a/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/Banks/RecoBankWriter.java b/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/Banks/RecoBankWriter.java index 72b9b5f2fe..38a701cd3b 100644 --- a/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/Banks/RecoBankWriter.java +++ b/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/Banks/RecoBankWriter.java @@ -15,15 +15,19 @@ public class RecoBankWriter { public DataBank fillAHDCHitsBank(DataEvent event, ArrayList hitList) { if (hitList == null || hitList.size() == 0) return null; - DataBank bank = event.createBank("AHDC::Hits", hitList.size()); + DataBank bank = event.createBank("AHDC::hits", hitList.size()); for (int i = 0; i < hitList.size(); i++) { - bank.setShort("ID", i, (short) hitList.get(i).getId()); + bank.setShort("id", i, (short) hitList.get(i).getId()); bank.setByte("layer", i, (byte) hitList.get(i).getLayerId()); bank.setByte("superlayer", i, (byte) hitList.get(i).getSuperLayerId()); bank.setInt("wire", i, hitList.get(i).getWireId()); - bank.setDouble("Doca", i, hitList.get(i).getDoca()); + bank.setDouble("doca", i, hitList.get(i).getDoca()); + bank.setDouble("residual", i, hitList.get(i).getResidual()); + bank.setDouble("residual_prefit", i, hitList.get(i).getResidualPrefit()); + bank.setDouble("time", i, hitList.get(i).getTime()); + bank.setInt("trackid", i, hitList.get(i).getTrackId()); } return bank; @@ -32,11 +36,11 @@ public DataBank fillAHDCHitsBank(DataEvent event, ArrayList hitList) { public DataBank fillPreClustersBank(DataEvent event, ArrayList preClusters) { if (preClusters == null || preClusters.size() == 0) return null; - DataBank bank = event.createBank("AHDC::PreClusters", preClusters.size()); + DataBank bank = event.createBank("AHDC::preclusters", preClusters.size()); for (int i = 0; i < preClusters.size(); i++) { - bank.setFloat("X", i, (float) preClusters.get(i).get_X()); - bank.setFloat("Y", i, (float) preClusters.get(i).get_Y()); + bank.setFloat("x", i, (float) preClusters.get(i).get_X()); + bank.setFloat("y", i, (float) preClusters.get(i).get_Y()); } return bank; @@ -45,12 +49,12 @@ public DataBank fillPreClustersBank(DataEvent event, ArrayList preCl public DataBank fillClustersBank(DataEvent event, ArrayList clusters) { if (clusters == null || clusters.size() == 0) return null; - DataBank bank = event.createBank("AHDC::Clusters", clusters.size()); + DataBank bank = event.createBank("AHDC::clusters", clusters.size()); for (int i = 0; i < clusters.size(); i++) { - bank.setFloat("X", i, (float) clusters.get(i).get_X()); - bank.setFloat("Y", i, (float) clusters.get(i).get_Y()); - bank.setFloat("Z", i, (float) clusters.get(i).get_Z()); + bank.setFloat("x", i, (float) clusters.get(i).get_X()); + bank.setFloat("y", i, (float) clusters.get(i).get_Y()); + bank.setFloat("z", i, (float) clusters.get(i).get_Z()); } return bank; @@ -68,7 +72,7 @@ public DataBank fillAHDCMCTrackBank(DataEvent event) { double pz_mc = particle.getFloat("pz", 0) * 1000; int row = 0; - DataBank bank = event.createBank("AHDC::MC", row + 1); + DataBank bank = event.createBank("AHDC::mc", row + 1); bank.setFloat("x", row, (float) x_mc); bank.setFloat("y", row, (float) y_mc); bank.setFloat("z", row, (float) z_mc); @@ -81,7 +85,7 @@ public DataBank fillAHDCMCTrackBank(DataEvent event) { public DataBank fillAHDCTrackBank(DataEvent event, ArrayList tracks) { - DataBank bank = event.createBank("AHDC::Track", tracks.size()); + DataBank bank = event.createBank("AHDC::track", tracks.size()); int row = 0; @@ -94,12 +98,20 @@ public DataBank fillAHDCTrackBank(DataEvent event, ArrayList tracks) { double py = track.get_py(); double pz = track.get_pz(); + bank.setInt("trackid", row, (int) track.get_trackId()); bank.setFloat("x", row, (float) x); bank.setFloat("y", row, (float) y); bank.setFloat("z", row, (float) z); bank.setFloat("px", row, (float) px); bank.setFloat("py", row, (float) py); bank.setFloat("pz", row, (float) pz); + bank.setInt("n_hits", row, (int) track.get_n_hits()); + bank.setInt("sum_adc", row, (int) track.get_sum_adc()); + bank.setFloat("path", row, (float) track.get_path()); + bank.setFloat("dEdx", row, (float) track.get_dEdx()); + bank.setFloat("p_drift", row, (float) track.get_p_drift()); + bank.setFloat("chi2", row, (float) track.get_chi2()); + bank.setFloat("sum_residuals", row, (float) track.get_sum_residuals()); row++; } @@ -109,7 +121,7 @@ public DataBank fillAHDCTrackBank(DataEvent event, ArrayList tracks) { public DataBank fillAHDCKFTrackBank(DataEvent event, ArrayList tracks) { - DataBank bank = event.createBank("AHDC::KFTrack", tracks.size()); + DataBank bank = event.createBank("AHDC::kftrack", tracks.size()); int row = 0; @@ -122,12 +134,20 @@ public DataBank fillAHDCKFTrackBank(DataEvent event, ArrayList tracks) { double py = track.getPy0_kf(); double pz = track.getPz0_kf(); + bank.setInt("trackid", row, (int) track.get_trackId()); bank.setFloat("x", row, (float) x); bank.setFloat("y", row, (float) y); bank.setFloat("z", row, (float) z); bank.setFloat("px", row, (float) px); bank.setFloat("py", row, (float) py); bank.setFloat("pz", row, (float) pz); + bank.setInt("n_hits", row, (int) track.get_n_hits()); + bank.setInt("sum_adc", row, (int) track.get_sum_adc()); + bank.setFloat("path", row, (float) track.get_path_kf()); + bank.setFloat("dEdx", row, (float) track.get_dEdx_kf()); + bank.setFloat("p_drift", row, (float) track.get_p_drift_kf()); + bank.setFloat("chi2", row, (float) track.get_chi2()); + bank.setFloat("sum_residuals", row, (float) track.get_sum_residuals()); row++; } @@ -137,23 +157,23 @@ public DataBank fillAHDCKFTrackBank(DataEvent event, ArrayList tracks) { public DataBank fillAIPrediction(DataEvent event, ArrayList predictions) { - DataBank bank = event.createBank("AHDC_AI::Prediction", predictions.size()); + DataBank bank = event.createBank("AHDC::ai:prediction", predictions.size()); int row = 0; for (TrackPrediction track : predictions) { - bank.setFloat("X1", row, (float) track.getSuperpreclusters().get(0).getX()); - bank.setFloat("Y1", row, (float) track.getSuperpreclusters().get(0).getY()); - bank.setFloat("X2", row, (float) track.getSuperpreclusters().get(1).getX()); - bank.setFloat("Y2", row, (float) track.getSuperpreclusters().get(1).getY()); - bank.setFloat("X3", row, (float) track.getSuperpreclusters().get(2).getX()); - bank.setFloat("Y3", row, (float) track.getSuperpreclusters().get(2).getY()); - bank.setFloat("X4", row, (float) track.getSuperpreclusters().get(3).getX()); - bank.setFloat("Y4", row, (float) track.getSuperpreclusters().get(3).getY()); - bank.setFloat("X5", row, (float) track.getSuperpreclusters().get(4).getX()); - bank.setFloat("Y5", row, (float) track.getSuperpreclusters().get(4).getY()); - - bank.setFloat("Pred", row, track.getPrediction()); + bank.setFloat("x1", row, (float) track.getSuperpreclusters().get(0).getX()); + bank.setFloat("y1", row, (float) track.getSuperpreclusters().get(0).getY()); + bank.setFloat("x2", row, (float) track.getSuperpreclusters().get(1).getX()); + bank.setFloat("y2", row, (float) track.getSuperpreclusters().get(1).getY()); + bank.setFloat("x3", row, (float) track.getSuperpreclusters().get(2).getX()); + bank.setFloat("y3", row, (float) track.getSuperpreclusters().get(2).getY()); + bank.setFloat("x4", row, (float) track.getSuperpreclusters().get(3).getX()); + bank.setFloat("y4", row, (float) track.getSuperpreclusters().get(3).getY()); + bank.setFloat("x5", row, (float) track.getSuperpreclusters().get(4).getX()); + bank.setFloat("y5", row, (float) track.getSuperpreclusters().get(4).getY()); + + bank.setFloat("pred", row, track.getPrediction()); row++; } diff --git a/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/Cluster/ClusterFinder.java b/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/Cluster/ClusterFinder.java index 7a1421815a..87a4446b1c 100644 --- a/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/Cluster/ClusterFinder.java +++ b/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/Cluster/ClusterFinder.java @@ -5,6 +5,11 @@ import java.util.ArrayList; import java.util.List; +/** ClusterFinder + * + * \todo description of what it does and how it works + * + */ public class ClusterFinder { private final ArrayList _AHDCClusters = new ArrayList<>(); @@ -55,6 +60,7 @@ private void find_associate_cluster(PreCluster precluster, List AHDC } public void findCluster(List AHDC_precluster_list) { + /// \todo parameters should be exposed int window = 30; int minimal_distance = 10; diff --git a/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/Distance/Distance.java b/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/Distance/Distance.java index 51b9a1bbe9..0d9d10ce87 100644 --- a/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/Distance/Distance.java +++ b/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/Distance/Distance.java @@ -7,6 +7,11 @@ import java.util.Arrays; import java.util.List; +/** Distance. + * + * \todo What is this class and what does it do? + * + */ public class Distance { private ArrayList _AHDCTracks; diff --git a/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/HelixFit/HelixFitJava.java b/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/HelixFit/HelixFitJava.java index 55a50a4c78..1b29535d51 100644 --- a/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/HelixFit/HelixFitJava.java +++ b/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/HelixFit/HelixFitJava.java @@ -1,8 +1,19 @@ package org.jlab.rec.ahdc.HelixFit; +import java.util.logging.Level; +import java.util.logging.Logger; +/** Helix Fit. + * + * This appears to be some code translation. + */ public class HelixFitJava { + static final Logger LOGGER = Logger.getLogger(HelixFitJava.class.getName()); + + /** \todo What does this method do + * \what does its name even mean? + */ void rwsmav(double r[], double a[], double v[], int n) { // Author: Martin Poppe. r[n] = a[n,n]*v[n] @@ -233,12 +244,12 @@ void rwfthc(int npt, double rf[], double ydca, xbar, ybar, xpt, ypt, alpha, beta; if (npt <= 2) { - System.out.println("BonusHelixFit::rwfthc(): Cannot fit less than 3 points; exiting..\n"); + LOGGER.finest("BonusHelixFit::rwfthc(): Cannot fit less than 3 points; exiting."); return; } if (npt > MAX_HITS_ON_CHAIN) { - System.out.println("BonusHelixFit::rwfthc(): Cannot fit more than " + MAX_HITS_ON_CHAIN + " points; exiting..\n" ); + LOGGER.log(Level.FINEST, "BonusHelixFit::rwfthc(): Cannot fit more than {0} points; exiting.", MAX_HITS_ON_CHAIN); return; } for(i=0; i { @@ -9,66 +12,44 @@ public class Hit implements Comparable { private final int layerId; private final int wireId; private final double doca; + private final double adc; + private final double time; + private Line3D wireLine; private double phi; private double radius; private int nbOfWires; private boolean use = false; private double x; private double y; + private double residual_prefit; + private double residual; + private int trackId; - public Hit(int _Id, int _Super_layer, int _Layer, int _Wire, double _Doca) { + //updated constructor with ADC + public Hit(int _Id, int _Super_layer, int _Layer, int _Wire, double _Doca, double _ADC, double _Time) { this.id = _Id; this.superLayerId = _Super_layer; this.layerId = _Layer; this.wireId = _Wire; this.doca = _Doca; - wirePosition(); - } - - private void wirePosition() { - final double DR_layer = 4.0; - final double round = 360.0; - - double numWires = 32.0; - double R_layer = 47.0; - - switch (this.superLayerId) { - case 1: - numWires = 47.0; - R_layer = 32.0; - break; - case 2: - numWires = 56.0; - R_layer = 38.0; - break; - case 3: - numWires = 72.0; - R_layer = 48.0; - break; - case 4: - numWires = 87.0; - R_layer = 58.0; - break; - case 5: - numWires = 99.0; - R_layer = 68.0; - break; - } + this.adc = _ADC; + this.time = _Time; + this.residual_prefit = 0.0; + this.residual = 0.0; + this.trackId = -1; // not defined yet + } - R_layer = R_layer + DR_layer * (this.layerId-1); - double alphaW_layer = Math.toRadians(round / (numWires)); - //should it be at z = 0? in which case, we need to account for the positive or negative stereo angle... - double wx = -R_layer * Math.sin(alphaW_layer * (this.wireId-1) + 0.5*thster * (Math.pow(-1, this.superLayerId-1))); - double wy = -R_layer * Math.cos(alphaW_layer * (this.wireId-1) + 0.5*thster * (Math.pow(-1, this.superLayerId-1))); - + public void setWirePosition(AlertDCDetector factory) { + //System.out.println(" superlayer " + this.superLayerId + " layer " + this.layerId + " wire " + this.wireId + " R_layer " + R_layer + " wx " + wx + " wy " + wy); - - this.nbOfWires = (int) numWires; - this.phi = Math.atan2(wy, wx); - this.radius = R_layer; - this.x = wx; - this.y = wy; + wireLine = factory.getSector(1).getSuperlayer(superLayerId).getLayer(layerId).getComponent(wireId).getLine(); + Point3D end = wireLine.end(); + this.nbOfWires = factory.getSector(1).getSuperlayer(superLayerId).getLayer(layerId).getNumComponents(); + this.phi = end.vectorFrom(0, 0, 0).phi(); + this.radius = end.distance(0, 0, end.z()); + this.x = end.x(); + this.y = end.y(); } @Override @@ -88,7 +69,7 @@ public int compareTo(Hit arg0) { public int getId() { return id; } - + public int getSuperLayerId() { return superLayerId; } @@ -105,7 +86,11 @@ public double getDoca() { return doca; } - public double getRadius() { + public Line3D getLine() { + return wireLine; + } + + public double getRadius() { return radius; } @@ -130,4 +115,35 @@ public double getY() { } public double getPhi() {return phi;} + + public double getADC() {return adc;} + + public double getResidual() { + return residual; + } + + public double getResidualPrefit() { + return residual_prefit; + } + + public void setResidual(double resid) { + this.residual = resid; + } + + public void setResidualPrefit(double resid) { + this.residual_prefit = resid; + } + + public double getTime() { + return time; + } + + public int getTrackId() { + return trackId; + } + + public void setTrackId(int _trackId) { + this.trackId = _trackId; + } + } diff --git a/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/Hit/HitReader.java b/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/Hit/HitReader.java index cef052afef..32df59f4af 100644 --- a/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/Hit/HitReader.java +++ b/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/Hit/HitReader.java @@ -5,18 +5,22 @@ import org.jlab.io.base.DataBank; import org.jlab.io.base.DataEvent; import org.jlab.detector.banks.RawDataBank; +import org.jlab.geom.detector.alert.AHDC.AlertDCDetector; +import org.jlab.rec.constants.CalibrationConstantsLoader; public class HitReader { private ArrayList _AHDCHits; private ArrayList _TrueAHDCHits; + private boolean sim = false; - public HitReader(DataEvent event, boolean simulation) { - fetch_AHDCHits(event); + public HitReader(DataEvent event, AlertDCDetector detector, boolean simulation) { + sim = simulation; + fetch_AHDCHits(event, detector); if (simulation) fetch_TrueAHDCHits(event); } - public void fetch_AHDCHits(DataEvent event) { + public final void fetch_AHDCHits(DataEvent event, AlertDCDetector detector) { ArrayList hits = new ArrayList<>(); if (event.hasBank("AHDC::adc")) { @@ -31,16 +35,54 @@ public void fetch_AHDCHits(DataEvent event) { int number = bankDGTZ.getByte("layer", i); int layer = number % 10; int superlayer = (int) (number % 100) / 10; + int sector = bankDGTZ.getInt("sector", i); int wire = bankDGTZ.getShort("component", i); - double doca = bankDGTZ.getShort("ped", i) / 1000.0; - - hits.add(new Hit(id, superlayer, layer, wire, doca)); + double adc = bankDGTZ.getInt("ADC", i); + double leadingEdgeTime = bankDGTZ.getFloat("leadingEdgeTime", i); + double timeOverThreshold = bankDGTZ.getFloat("timeOverThreshold", i); + double adcOffset = bankDGTZ.getShort("ped", i); + // Retrieve raw hit cuts from CCDB + int key_value = sector*10000 + number*100 + wire; + double[] rawHitCuts = CalibrationConstantsLoader.AHDC_RAW_HIT_CUTS.get( key_value ); + double t_min = rawHitCuts[0]; + double t_max = rawHitCuts[1]; + double tot_min = rawHitCuts[2]; + double tot_max = rawHitCuts[3]; + double adc_min = rawHitCuts[4]; + double adc_max = rawHitCuts[5]; + double ped_min = rawHitCuts[6]; + double ped_max = rawHitCuts[7]; + //System.out.println("t_min : " + t_min + " t_max : " + t_max + " tot_min : " + tot_min + " tot_max : " + tot_max + " adc_min : " + adc_min + " adc_max : " + adc_max + " ped_min : " + ped_min + " ped_max : " + ped_max); + // Apply these cuts + if (((adc >= adc_min) && (adc <= adc_max) && (leadingEdgeTime >= t_min) && (leadingEdgeTime <= t_max) && (timeOverThreshold >= tot_min) && (timeOverThreshold <= tot_max) && (adcOffset >= ped_min) && (adcOffset <= ped_max)) || sim) { + // Retrieve others CCDB + double[] timeOffsets = CalibrationConstantsLoader.AHDC_TIME_OFFSETS.get( key_value ); + double[] time2distance = CalibrationConstantsLoader.AHDC_TIME_TO_DISTANCE.get( 10101 ); // the time to distance table has only one row ! (10101 is its only key) + double t0 = timeOffsets[0]; + double p0 = time2distance[0]; + double p1 = time2distance[1]; + double p2 = time2distance[2]; + double p3 = time2distance[3]; + double p4 = time2distance[4]; + double p5 = time2distance[5]; + + double time = leadingEdgeTime - t0; + // we may prevent time to be too small or too big + // CONDITION TO BE ADDED + // we should also use a flag to prevent to read the ccdb if reconstructed event if from simulation + // TO BE DONE + //double doca = bankDGTZ.getShort("ped", i) / 1000.0; + double doca = p0 + p1*Math.pow(time,1.0) + p2*Math.pow(time,2.0) + p3*Math.pow(time,3.0) + p4*Math.pow(time,4.0) + p5*Math.pow(time, 5.0); + Hit h = new Hit(id, superlayer, layer, wire, doca, adc, time); + h.setWirePosition(detector); + hits.add(h); + } } } this.set_AHDCHits(hits); } - public void fetch_TrueAHDCHits(DataEvent event) { + public final void fetch_TrueAHDCHits(DataEvent event) { ArrayList truehits = new ArrayList<>(); DataBank bankSIMU = event.getBank("MC::True"); @@ -75,4 +117,4 @@ public void set_TrueAHDCHits(ArrayList _TrueAHDCHits) { this._TrueAHDCHits = _TrueAHDCHits; } -} \ No newline at end of file +} diff --git a/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/KalmanFilter/Hit.java b/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/KalmanFilter/Hit.java index fa4d1dc477..0aeabb8af0 100644 --- a/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/KalmanFilter/Hit.java +++ b/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/KalmanFilter/Hit.java @@ -11,135 +11,75 @@ public class Hit implements Comparable { - private final double thster = Math.toRadians(20.0); - private final double zl = 300.0;//OK private final int superLayer; private final int layer; private final int wire; private final double r; private final double phi; private final double doca; - private final double adc; + private double adc; private final double numWires; private final Line3D line3D; - - // Comparison with: common-tools/clas-geometry/src/main/java/org/jlab/geom/detector/alert/AHDC/AlertDCFactory.java - // here, SuperLayer, Layer, Wire, start from 1 - // in AlertDCFactory, same variables start from 1 - public Hit(int superLayer, int layer, int wire, int numWire, double r, double doca) { + private final Line3D line3D_plus; + private final Line3D line3D_minus; + private int hitidx; + private int hitsign; + + // Comparison with: common-tools/clas-geometry/src/main/java/org/jlab/geom/detector/alert/AHDC/AlertDCFactory.java + // here, SuperLayer, Layer, Wire, start from 1 + // in AlertDCFactory, same variables start from 1 + public Hit(int superLayer, int layer, int wire, int numWire, Line3D line, double doca) { this.superLayer = superLayer; this.layer = layer; this.wire = wire; - this.r = r; + this.r = line.end().distance(0, 0, line.end().z()); this.doca = doca; this.numWires = numWire; this.adc = 0;//placeholder + this.hitidx = -1; + this.hitsign = 0; - final double DR_layer = 4.0;//OK - final double round = 360.0;//OK - final double thster = Math.toRadians(20.0);//OK - - double numWires = 32.0; - double R_layer = 47.0; - - double zoff1 = -zl/2;//OK - double zoff2 = +zl/2;//OK - Point3D p1 = new Point3D(R_layer, 0, zoff1); - Vector3D n1 = new Vector3D(0, 0, 1); - //n1.rotateY(-thopen); - //n1.rotateZ(thtilt); - Plane3D lPlane = new Plane3D(p1, n1);//OK - - Point3D p2 = new Point3D(R_layer, 0, zoff2); - Vector3D n2 = new Vector3D(0, 0, 1); - //n2.rotateY(thopen); - //n2.rotateZ(thtilt); - Plane3D rPlane = new Plane3D(p2, n2);//OK - - switch (this.superLayer) {//OK - case 1: - numWires = 47.0; - R_layer = 32.0; - break; - case 2: - numWires = 56.0; - R_layer = 38.0; - break; - case 3: - numWires = 72.0; - R_layer = 48.0; - break; - case 4: - numWires = 87.0; - R_layer = 58.0; - break; - case 5: - numWires = 99.0; - R_layer = 68.0; - break; - } - - - R_layer = R_layer + DR_layer * (this.layer-1);//OK - double alphaW_layer = Math.toRadians(round / (numWires));//OK - double wx = -R_layer * Math.sin(alphaW_layer * (this.wire-1));//OK - double wy = -R_layer * Math.cos(alphaW_layer * (this.wire-1));//OK - - double wx_end = -R_layer * Math.sin(alphaW_layer * (this.wire-1) + thster * (Math.pow(-1, this.superLayer-1)));//OK - double wy_end = -R_layer * Math.cos(alphaW_layer * (this.wire-1) + thster * (Math.pow(-1, this.superLayer-1)));//OK - - this.phi = Math.atan2( (wy+wy_end)*0.5, (wx+wx_end)*0.5 ); + this.phi = line.midpoint().vectorFrom(0,0,0).phi(); //System.out.println(" superlayer " + this.superLayer + " layer " + this.layer + " wire " + this.wire + " wx " + wx + " wy " + wy + " wx_end " + wx_end + " wy_end " + wy_end + " phi " + this.phi); - Line3D line = new Line3D(wx, wy, -zl/2, wx_end, wy_end, zl/2); - Point3D lPoint = new Point3D(); - Point3D rPoint = new Point3D(); - lPlane.intersection(line, lPoint); - rPlane.intersection(line, rPoint); - //lPoint.setZ(-zl/2); - //rPoint.setZ(zl/2); - //lPoint.show(); - //rPoint.show(); - // All wire go from left to right - Line3D wireLine = new Line3D(lPoint, rPoint); - //wireLine.show(); - this.line3D = wireLine; - } - - //hit measurement vector in cylindrical coordinates: r, phi, z - public RealVector get_Vector() { - // final double costhster = Math.cos(thster); - // final double sinthster = Math.cos(thster); - RealVector wire_meas = new ArrayRealVector(new double[]{this.r(), this.phi(), 0}); - // Array2DRowRealMatrix stereo_rotation = new Array2DRowRealMatrix(new double[][]{{1, 0.0, 0.0}, {0, costhster, -sinthster}, {0, sinthster, costhster}});//rotation of wire: needed? - return wire_meas;//.multiply(stereo_rotation); + this.line3D = line; + + //calculate the "virtual" left and right wires accounting for the DOCA + double deltaphi = Math.asin(this.doca/r); + this.line3D_plus = new Line3D(); + this.line3D_plus.copy(line); + this.line3D_plus.rotateZ(deltaphi); + + this.line3D_minus = new Line3D(); + this.line3D_minus.copy(line); + this.line3D_minus.rotateZ(deltaphi); + } - //hit measurement vector in 1 dimension: minimize distance - doca - public RealVector get_Vector_simple() { + //hit measurement vector in 1 dimension: minimize distance - doca + public RealVector get_Vector() { return new ArrayRealVector(new double[]{this.doca}); } - //hit measurement vector in 1 dimension: minimize distance - doca - adds hit "sign" - public RealVector get_Vector_sign(int sign) { - // Attempt: multiply doca by sign - return new ArrayRealVector(new double[]{sign*this.doca}); + //hit measurement vector in 1 dimension with sign: if sign = 0, return doca, otherwise return 0 + public RealVector get_Vector(int sign, boolean goodsign) { + if(sign == 0 || goodsign){ + return new ArrayRealVector(new double[]{this.doca}); + }else{ + return new ArrayRealVector(new double[]{0.0}); + } } - public RealMatrix get_MeasurementNoise() { - final double costhster = Math.cos(thster); - final double sinthster = Math.cos(thster); - //dR = 0.1m dphi = pi dz = L/2 - Array2DRowRealMatrix wire_noise = new Array2DRowRealMatrix(new double[][]{{0.1, 0.0, 0.0}, {0.0, Math.atan(0.1/this.r), 0.0}, {0.0, 0.0, 150.0/costhster}});//uncertainty matrix in wire coordinates - Array2DRowRealMatrix stereo_rotation = new Array2DRowRealMatrix(new double[][]{{1, 0.0, 0.0}, {0, costhster, -sinthster}, {0, sinthster, costhster}});//rotation of wire - wire_noise.multiply(stereo_rotation); - - return wire_noise.multiply(wire_noise); - // + public RealMatrix get_MeasurementNoise() { + return new Array2DRowRealMatrix(new double[][]{{0.0225}}); } - - public RealMatrix get_MeasurementNoise_simple() { - return new Array2DRowRealMatrix(new double[][]{{0.01}}); + + public RealMatrix get_MeasurementNoise(boolean goodsign) { + if(goodsign){ + return new Array2DRowRealMatrix(new double[][]{{0.0225}}); + }else{ + return new Array2DRowRealMatrix(new double[][]{{2*this.doca*this.doca}}); + } } public double doca() { @@ -151,20 +91,22 @@ public double doca() { public double phi() {return phi;}//at z = 0; public double phi(double z) { - // double x_0 = r*sin(phi); - // double y_0 = r*cos(phi); - double x_z = r*Math.sin( phi + thster * z/(zl*0.5) * (Math.pow(-1, this.superLayer-1)) ); - double y_z = r*Math.cos( phi + thster * z/(zl*0.5) * (Math.pow(-1, this.superLayer-1)) ); - return Math.atan2(x_z, y_z); + return this.line3D.lerpPoint((z-line3D.origin().z())/line3D.length()).vectorFrom(0,0,0).phi(); } public Line3D line() {return line3D;} public double distance(Point3D point3D) { - //System.out.println("Calculating distance: "); - //this.line3D.show(); - //point3D.show(); - //System.out.println(" d = " + this.line3D.distance(point3D).length()); + return this.line3D.distance(point3D).length(); + } + + public double distance(Point3D point3D, int sign, boolean goodsign) { + //if(sign!=0) + //System.out.println(" r " + this.r + " phi " + this.phi + " doca " + this.doca + " sign " + sign + " distance " + this.line3D.distance(point3D).length() + " (sign 0) " + this.line3D_plus.distance(point3D).length() + " (sign+) " + this.line3D_minus.distance(point3D).length() + " (sign-) "); + if(!goodsign){ + if(sign>0)return this.line3D_plus.distance(point3D).length(); + if(sign<0)return this.line3D_minus.distance(point3D).length(); + } return this.line3D.distance(point3D).length(); } @@ -183,10 +125,6 @@ public RealVector get_Vector_beam() { return null; } - public double getThster() { - return thster; - } - public int getSuperLayer() { return superLayer; } @@ -211,6 +149,10 @@ public double getADC() { return adc; } + public void setADC(double _adc) { + this.adc = _adc; + } + public Line3D getLine3D() { return line3D; } @@ -218,5 +160,22 @@ public Line3D getLine3D() { public double getNumWires() { return numWires; } + + public int getHitIdx() { + return hitidx; + } + + public void setHitIdx(int idx) { + this.hitidx = idx; + } + + public int getSign() { + return hitsign; + } + + public void setSign(int sign) { + this.hitsign = sign; + } + } diff --git a/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/KalmanFilter/Hit_beam.java b/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/KalmanFilter/Hit_beam.java index e1160642e4..a578f7da99 100644 --- a/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/KalmanFilter/Hit_beam.java +++ b/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/KalmanFilter/Hit_beam.java @@ -2,6 +2,7 @@ import org.apache.commons.math3.linear.ArrayRealVector; import org.apache.commons.math3.linear.RealVector; +import org.jlab.geom.prim.Line3D; public class Hit_beam extends Hit { @@ -9,7 +10,7 @@ public class Hit_beam extends Hit { double r,phi; public Hit_beam(int superLayer, int layer, int wire, int numWire, double doca, double x, double y , double z) { - super(0, 0, 0, 0, Math.hypot(x,y), 0); + super(0, 0, 0, 0, new Line3D(x,y,0,x,y,1), 0); this.x = x; this.y = y; this.z = z; diff --git a/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/KalmanFilter/KFitter.java b/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/KalmanFilter/KFitter.java index 3feddf5b27..1a184bf5dc 100644 --- a/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/KalmanFilter/KFitter.java +++ b/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/KalmanFilter/KFitter.java @@ -17,7 +17,7 @@ public class KFitter { // masses/energies in MeV private final double electron_mass_c2 = PhysicsConstants.massElectron() * 1000; private final double proton_mass_c2 = PhysicsConstants.massProton() * 1000; - + private boolean isvertexdefined = false; public KFitter(final RealVector initialStateEstimate, final RealMatrix initialErrorCovariance, final Stepper stepper, final Propagator propagator) { this.stateEstimation = initialStateEstimate; @@ -73,39 +73,39 @@ public void predict(Indicator indicator) throws Exception { } public void correct(Indicator indicator) { - //System.out.println(" state before: (" + stateEstimation.getEntry(0) + ", " + stateEstimation.getEntry(1) + ", " + stateEstimation.getEntry(2) + ", " + stateEstimation.getEntry(3) + ", " + stateEstimation.getEntry(4) + ", " + stateEstimation.getEntry(5) + ");" ); - //System.out.println(" state radius before: " + Math.sqrt( Math.pow(stateEstimation.getEntry(0), 2) + Math.pow(stateEstimation.getEntry(1), 2) ) ); RealVector z, z_plus, z_minus; RealMatrix measurementNoise; RealMatrix measurementMatrix; RealVector h; if (indicator.R == 0.0 && !indicator.direction) { + double z_beam_res_sq = 1.e10;//in mm + if(isvertexdefined)z_beam_res_sq = 4.0;//assuming 2. mm resolution measurementNoise = new Array2DRowRealMatrix( new double[][]{ - // {9.00, 0.0000, 0.0000}, - // {0.00, 1e10, 0.0000}, - // {0.00, 0.0000, 1e10} {0.09, 0.0000, 0.0000}, - {0.00, 1.e10, 0.0000}, - {0.00, 0.0000, 1.e10} + {0.00, 1e10, 0.0000}, + {0.00, 0.0000, z_beam_res_sq} });//3x3 measurementMatrix = H_beam(stateEstimation);//6x3 h = h_beam(stateEstimation);//3x1 z = indicator.hit.get_Vector_beam();//0! } else { - measurementNoise = indicator.hit.get_MeasurementNoise_simple();//1x1 - measurementMatrix = H_simple(stateEstimation, indicator);//6x1 - h = h_simple(stateEstimation, indicator);//.multiply(wire_sign_mat(indicator));//1x1 - z = indicator.hit.get_Vector_simple();//1x1 - - // measurementNoise = indicator.hit.get_MeasurementNoise();//3x3 - // measurementMatrix = H(stateEstimation, indicator);//6x3 - // h = h(stateEstimation, indicator);//3x1 - // z = indicator.hit.get_Vector();//3x1 - - //System.out.println(" h: r " + h.getEntry(0) + " phi " + h.getEntry(1) + " h z " + h.getEntry(2) + " z: r " + z.getEntry(0) + " phi " + z.getEntry(1) + " z " + z.getEntry(2) ); - + //System.out.println(" hit r " + indicator.hit.r() + " hit phi " + indicator.hit.phi() + " phi wire (-zl/2) " + indicator.hit.phi(-150.0) + " phi wire (0) " + indicator.hit.phi(0.0) + " phi wire (+zl/2) " + indicator.hit.phi(150.) + " state x " + stateEstimation.getEntry(0) + " state y " + stateEstimation.getEntry(1) + " state z " + stateEstimation.getEntry(2) ); + boolean goodsign = true; + if(indicator.hit.getSign()!=0){ + double dphi = Math.atan2(stateEstimation.getEntry(1), stateEstimation.getEntry(0))-indicator.hit.phi(stateEstimation.getEntry(2)); + if(dphi*indicator.hit.getSign()<0)goodsign = false; + //System.out.println(" hit r " + indicator.hit.r() + " phi wire (z) " + indicator.hit.phi(stateEstimation.getEntry(2)) + " phi state " + Math.atan2(stateEstimation.getEntry(1), stateEstimation.getEntry(0)) + " sign " + indicator.hit.getSign() + " good? " + goodsign ); + } + //measurementNoise = indicator.hit.get_MeasurementNoise();//1x1 + measurementNoise = indicator.hit.get_MeasurementNoise(goodsign);//1x1 + measurementMatrix = H(stateEstimation, indicator);//6x1 + //measurementMatrix = H(stateEstimation, indicator, goodsign);//6x1 + h = h(stateEstimation, indicator);//1x1 + //h = h(stateEstimation, indicator, goodsign);//1x1 + z = indicator.hit.get_Vector();//1x1 + //z = indicator.hit.get_Vector(indicator.hit.getSign(), goodsign);//1x1 } RealMatrix measurementMatrixT = measurementMatrix.transpose(); @@ -128,7 +128,6 @@ public void correct(Indicator indicator) { RealMatrix tmpMatrix = identity.subtract(kalmanGain.multiply(measurementMatrix)); errorCovariance = tmpMatrix.multiply(errorCovariance.multiply(tmpMatrix.transpose())).add(kalmanGain.multiply(measurementNoise.multiply(kalmanGain.transpose()))); - //System.out.println(" state after: (" + stateEstimation.getEntry(0) + ", " + stateEstimation.getEntry(1) + ", " + stateEstimation.getEntry(2) + ", " + stateEstimation.getEntry(3) + ", " + stateEstimation.getEntry(4) + ", " + stateEstimation.getEntry(5) + ");" ); // Give back to the stepper the new stateEstimation stepper.y = stateEstimation.toArray(); } @@ -138,20 +137,21 @@ public double residual(Indicator indicator) { return indicator.hit.doca()-d; } - public double wire_sign(Indicator indicator) {//let's decide: positive when (phi state - phi wire) > 0 + //function for left-right disambiguation + public int wire_sign(Indicator indicator) {//let's decide: positive when (phi state - phi wire) > 0 double phi_state = Math.atan2(stateEstimation.getEntry(1), stateEstimation.getEntry(0)); double phi_wire = indicator.hit.phi(stateEstimation.getEntry(2)); - //System.out.println(" phi state " + phi_state + " phi wire " + phi_wire);// + " phi state alt? " + Math.atan2(stateEstimation.getEntry(1), stateEstimation.getEntry(0))); - return (phi_state-phi_wire)/Math.abs(phi_state-phi_wire) ; + if( (phi_state-phi_wire)/Math.abs(phi_state-phi_wire)>0 ){ + return +1; + }else{ + return -1; + } } - // public RealMatrix wire_sign_mat(Indicator indicator) {//let's decide: positive when (phi state - phi wire) > 0 - // double phi_state = Math.atan2(stateEstimation.getEntry(1), stateEstimation.getEntry(0)); - // double phi_wire = indicator.hit.phi(stateEstimation.getEntry(2)); - // System.out.println(" phi state " + phi_state + " phi wire " + phi_wire);// + " phi state alt? " + Math.atan2(stateEstimation.getEntry(1), stateEstimation.getEntry(0))); - // return MatrixUtils.createRealMatrix(new double[][]{{(phi_state-phi_wire)/Math.abs(phi_state-phi_wire)}}); - // } - + public void ResetErrorCovariance(final RealMatrix initialErrorCovariance){ + this.errorCovariance = initialErrorCovariance; + } + private RealMatrix F(Indicator indicator, Stepper stepper1) throws Exception { double[] dfdx = subfunctionF(indicator, stepper1, 0); @@ -166,7 +166,7 @@ private RealMatrix F(Indicator indicator, Stepper stepper1) throws Exception { } double[] subfunctionF(Indicator indicator, Stepper stepper1, int i) throws Exception { - double h = 1e-8; + double h = 1e-8;// in mm Stepper stepper_plus = new Stepper(stepper1.y); Stepper stepper_minus = new Stepper(stepper1.y); @@ -189,57 +189,20 @@ private RealMatrix F(Indicator indicator, Stepper stepper1) throws Exception { return new double[]{dxdi, dydi, dzdi, dpxdi, dpydi, dpzdi}; } - //measurement matrix in cylindrical coordinates: r, phi, z + //measurement matrix in 1 dimension: minimize distance - doca private RealVector h(RealVector x, Indicator indicator) { - //As per my understanding: d -> r wire; phi -> phi wire, z unconstrained - double xx = x.getEntry(0); - double yy = x.getEntry(1); - return MatrixUtils.createRealVector(new double[]{Math.hypot(xx, yy), Math.atan2(yy, xx), x.getEntry(2)}); - } - - //measurement matrix in 1 dimension: minimize distance - doca - private RealVector h_simple(RealVector x, Indicator indicator) { double d = indicator.hit.distance(new Point3D(x.getEntry(0), x.getEntry(1), x.getEntry(2))); - return MatrixUtils.createRealVector(new double[]{d});//would need to have this 3x3 + //double d = indicator.hit.distance(new Point3D(x.getEntry(0), x.getEntry(1), x.getEntry(2)), indicator.hit.getSign()); + return MatrixUtils.createRealVector(new double[]{d}); } - //measurement noise matrix in cylindrical coordinates: r, phi, z - private RealMatrix H(RealVector x, Indicator indicator) { - // dphi/dx - double xx = x.getEntry(0); - double yy = x.getEntry(1); - - double drdx = (xx) / (Math.hypot(xx, yy)); - double drdy = (yy) / (Math.hypot(xx, yy)); - double drdz = 0.0; - double drdpx = 0.0; - double drdpy = 0.0; - double drdpz = 0.0; - - double dphidx = -(yy) / (xx * xx + yy * yy); - double dphidy = (xx) / (xx * xx + yy * yy); - double dphidz = 0.0; - double dphidpx = 0.0; - double dphidpy = 0.0; - double dphidpz = 0.0; - - double dzdx = 0.0; - double dzdy = 0.0; - double dzdz = 1.0; - double dzdpx = 0.0; - double dzdpy = 0.0; - double dzdpz = 0.0; - - return MatrixUtils.createRealMatrix( - new double[][]{ - {drdx, drdy, drdz, drdpx, drdpy, drdpz}, - {dphidx, dphidy, dphidz, dphidpx, dphidpy, dphidpz}, - {dzdx, dzdy, dzdz, dzdpx, dzdpy, dzdpz} - }); + private RealVector h(RealVector x, Indicator indicator, boolean goodsign) { + double d = indicator.hit.distance(new Point3D(x.getEntry(0), x.getEntry(1), x.getEntry(2)), indicator.hit.getSign(), goodsign); + return MatrixUtils.createRealVector(new double[]{d}); } - //measurement matrix in 1 dimension: minimize distance - doca - private RealMatrix H_simple(RealVector x, Indicator indicator) { + //measurement matrix in 1 dimension: minimize distance - doca + private RealMatrix H(RealVector x, Indicator indicator) { double ddocadx = subfunctionH(x, indicator, 0); double ddocady = subfunctionH(x, indicator, 1); @@ -254,15 +217,44 @@ private RealMatrix H_simple(RealVector x, Indicator indicator) { } double subfunctionH(RealVector x, Indicator indicator, int i) { - double h = 1e-8; + double h = 1e-8;// in mm RealVector x_plus = x.copy(); RealVector x_minus = x.copy(); x_plus.setEntry(i, x_plus.getEntry(i) + h); x_minus.setEntry(i, x_minus.getEntry(i) - h); - double doca_plus = h_simple(x_plus, indicator).getEntry(0); - double doca_minus = h_simple(x_minus, indicator).getEntry(0); + double doca_plus = h(x_plus, indicator).getEntry(0); + double doca_minus = h(x_minus, indicator).getEntry(0); + + return (doca_plus - doca_minus) / (2 * h); + } + + //measurement matrix in 1 dimension: minimize distance - doca + private RealMatrix H(RealVector x, Indicator indicator, boolean goodsign) { + + double ddocadx = subfunctionH(x, indicator, 0, goodsign); + double ddocady = subfunctionH(x, indicator, 1, goodsign); + double ddocadz = subfunctionH(x, indicator, 2, goodsign); + double ddocadpx = subfunctionH(x, indicator, 3, goodsign); + double ddocadpy = subfunctionH(x, indicator, 4, goodsign); + double ddocadpz = subfunctionH(x, indicator, 5, goodsign); + + // As per my understanding: ddocadx,y,z -> = dr/dx,y,z, etc + return MatrixUtils.createRealMatrix(new double[][]{ + {ddocadx, ddocady, ddocadz, ddocadpx, ddocadpy, ddocadpz}}); + } + + double subfunctionH(RealVector x, Indicator indicator, int i, boolean goodsign) { + double h = 1e-8;// in mm + RealVector x_plus = x.copy(); + RealVector x_minus = x.copy(); + + x_plus.setEntry(i, x_plus.getEntry(i) + h); + x_minus.setEntry(i, x_minus.getEntry(i) - h); + + double doca_plus = h(x_plus, indicator, goodsign).getEntry(0); + double doca_minus = h(x_minus, indicator, goodsign).getEntry(0); return (doca_plus - doca_minus) / (2 * h); } @@ -332,4 +324,6 @@ public double getMomentum() { return Math.sqrt(stateEstimation.getEntry(3) * stateEstimation.getEntry(3) + stateEstimation.getEntry(4) * stateEstimation.getEntry(4) + stateEstimation.getEntry(5) * stateEstimation.getEntry(5)); } + public void setVertexDefined(boolean isvtxdef) {isvertexdefined = isvtxdef;} + } diff --git a/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/KalmanFilter/KalmanFilter.java b/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/KalmanFilter/KalmanFilter.java index 2cd0bc5593..3ff2ad9f40 100644 --- a/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/KalmanFilter/KalmanFilter.java +++ b/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/KalmanFilter/KalmanFilter.java @@ -31,46 +31,42 @@ public class KalmanFilter { - public KalmanFilter(ArrayList tracks, DataEvent event) {propagation(tracks, event);} + public KalmanFilter(ArrayList tracks, DataEvent event, boolean IsMC) {propagation(tracks, event, IsMC);} - private void propagation(ArrayList tracks, DataEvent event) { + private final int Niter = 10; + private final boolean IsVtxDefined = false; - try { - //If simulation read MC::Particle Bank ------------------------------------------------ - DataBank bankParticle = event.getBank("MC::Particle"); - double vxmc = bankParticle.getFloat("vx", 0)*10;//mm - double vymc = bankParticle.getFloat("vy", 0)*10;//mm - double vzmc = bankParticle.getFloat("vz", 0)*10;//mm - double pxmc = bankParticle.getFloat("px", 0)*1000;//MeV - double pymc = bankParticle.getFloat("py", 0)*1000;//MeV - double pzmc = bankParticle.getFloat("pz", 0)*1000;//MeV - double p_mc = java.lang.Math.sqrt(pxmc*pxmc+pymc*pymc+pzmc*pzmc); - //System.out.println("MC track: vz: " + vzmc*10 + " px: " + pxmc*1000 + " py: " + pymc*1000 + " pz: " + pzmc*1000 + "; p = " + p_mc*1000);//convert p to MeV, v to mm - - ArrayList sim_hits = new ArrayList<>(); - sim_hits.add(new Point3D(0, 0, vzmc)); + private void propagation(ArrayList tracks, DataEvent event, boolean IsMC) { - DataBank bankMC = event.getBank("MC::True"); - for (int i = 0; i < bankMC.rows(); i++) { - if (bankMC.getInt("pid", i) == 2212) { - float x = bankMC.getFloat("avgX", i); - float y = bankMC.getFloat("avgY", i); - float z = bankMC.getFloat("avgZ", i); - // System.out.println("r_sim = " + Math.hypot(x, y)); - sim_hits.add(new Point3D(x, y, z)); + try { + double vz_constraint = 0; + if(IsMC) {//If simulation read MC::Particle Bank ------------------------------------------------ + DataBank bankParticle = event.getBank("MC::Particle"); + double vxmc = bankParticle.getFloat("vx", 0)*10;//mm + double vymc = bankParticle.getFloat("vy", 0)*10;//mm + double vzmc = bankParticle.getFloat("vz", 0)*10;//mm + double pxmc = bankParticle.getFloat("px", 0)*1000;//MeV + double pymc = bankParticle.getFloat("py", 0)*1000;//MeV + double pzmc = bankParticle.getFloat("pz", 0)*1000;//MeV + double p_mc = java.lang.Math.sqrt(pxmc*pxmc+pymc*pymc+pzmc*pzmc); + //System.out.println("MC track: vz: " + vzmc*10 + " px: " + pxmc*1000 + " py: " + pymc*1000 + " pz: " + pzmc*1000 + "; p = " + p_mc*1000);//convert p to MeV, v to mm + + ArrayList sim_hits = new ArrayList<>(); + sim_hits.add(new Point3D(0, 0, vzmc)); + + DataBank bankMC = event.getBank("MC::True"); + for (int i = 0; i < bankMC.rows(); i++) { + if (bankMC.getInt("pid", i) == 2212) { + float x = bankMC.getFloat("avgX", i); + float y = bankMC.getFloat("avgY", i); + float z = bankMC.getFloat("avgZ", i); + // System.out.println("r_sim = " + Math.hypot(x, y)); + sim_hits.add(new Point3D(x, y, z)); + } } + vz_constraint = vzmc; } - - /* - Writer hitsWriter = new FileWriter("hits.dat"); - for (Point3D p : sim_hits) { - hitsWriter.write("" + p.x() + ", " + p.y() + ", " + p.z() + '\n'); - } - hitsWriter.close(); - */ - - // Initialization --------------------------------------------------------------------- final double magfield = +50; final PDGParticle proton = PDGDatabase.getParticleById(2212); @@ -80,148 +76,144 @@ private void propagation(ArrayList tracks, DataEvent event) { // Initialization material map HashMap materialHashMap = materialGeneration(); - - // Initialization State Vector - final double x0 = 0.0; - final double y0 = 0.0; - final double z0 = tracks.get(0).get_Z0(); - //final - double px0 = tracks.get(0).get_px(); - //final - double py0 = tracks.get(0).get_py(); - final double pz0 = tracks.get(0).get_pz(); - final double p_init = java.lang.Math.sqrt(px0*px0+py0*py0+pz0*pz0); - double[] y = new double[]{x0, y0, z0, px0, py0, pz0}; - //System.out.println("y = " + x0 + ", " + y0 + ", " + z0 + ", " + px0 + ", " + py0 + ", " + pz0 + "; p = " + p_init); - // EPAF: *the line below is for TEST ONLY!!!* - //double[] y = new double[]{vxmc, vymc, vzmc, pxmc, pymc, pzmc}; - //System.out.println("y = " + vxmc + ", " + vymc + ", " + vzmc + ", " + pxmc + ", " + pymc + ", " + pzmc + "; p = " + java.lang.Math.sqrt(pxmc*pxmc+pymc*pymc+pzmc*pzmc)); - - // Initialization hit - //System.out.println("tracks = " + tracks); - ArrayList AHDC_hits = tracks.get(0).getHits(); - ArrayList KF_hits = new ArrayList<>(); - for (org.jlab.rec.ahdc.Hit.Hit AHDC_hit : AHDC_hits) { - //System.out.println("Superlayer = " + AHDC_hit.getSuperLayerId() + ", Layer " + AHDC_hit.getLayerId() + ", Wire " + AHDC_hit.getWireId() + ", Nwires " + AHDC_hit.getNbOfWires() + ", Radius " + AHDC_hit.getRadius() + ", DOCA " + AHDC_hit.getDoca()); - Hit hit = new Hit(AHDC_hit.getSuperLayerId(), AHDC_hit.getLayerId(), AHDC_hit.getWireId(), AHDC_hit.getNbOfWires(), AHDC_hit.getRadius(), AHDC_hit.getDoca()); - + int trackId = 0; + for (Track track : tracks) { + trackId++; + track.set_trackId(trackId); + // Initialization State Vector + final double x0 = 0.0; + final double y0 = 0.0; + final double z0 = track.get_Z0(); + //final + double px0 = track.get_px(); + //final + double py0 = track.get_py(); + final double pz0 = track.get_pz(); + //final double p_init = java.lang.Math.sqrt(px0*px0+py0*py0+pz0*pz0); + double[] y = new double[]{x0, y0, z0, px0, py0, pz0}; + // Initialization hit + ArrayList AHDC_hits = track.getHits(); + ArrayList KF_hits = new ArrayList<>(); + //System.out.println(" px " + y[3] + " py " + y[4] +" pz " + y[5] +" vz " + y[2] + " number of hits: " + AHDC_hits.size() + " MC hits? " + sim_hits.size()); + track.set_n_hits(AHDC_hits.size()); + for (org.jlab.rec.ahdc.Hit.Hit AHDC_hit : AHDC_hits) { + Hit hit = new Hit(AHDC_hit.getSuperLayerId(), AHDC_hit.getLayerId(), AHDC_hit.getWireId(), AHDC_hit.getNbOfWires(), AHDC_hit.getLine(), AHDC_hit.getDoca()); + hit.setADC(AHDC_hit.getADC()); + hit.setHitIdx(AHDC_hit.getId()); + hit.setSign(0); + // set track id + AHDC_hit.setTrackId(trackId); + + //System.out.println( " r = " + hit.r() + " hit.phi " + hit.phi() +" hit.doca = " + hit.getDoca() ); // Do delete hit with same radius - // boolean aleardyHaveR = false; - // for (Hit o: KF_hits){ - // if (o.r() == hit.r()){ - // aleardyHaveR = true; - // } + boolean phi_rollover = false; + boolean aleardyHaveR = false; + for (Hit o: KF_hits){ + if (o.r() == hit.r()){ + aleardyHaveR = true; + // //sign+ means (phi track - phi wire) > 0 + // if(o.phi()>hit.phi()){ + // if(Math.abs(o.phi()-hit.phi())< 2*Math.toRadians(360./o.getNumWires()) ){ + // o.setSign(-1); + // hit.setSign(+1); + // }else{ + // phi_rollover = true; + // hit.setSign(-1); + // o.setSign(+1); + // } + // }else{ + // if(Math.abs(o.phi()-hit.phi())< 2*Math.toRadians(360./o.getNumWires()) ){ + // hit.setSign(-1); + // o.setSign(+1); + // }else{ + // phi_rollover = true; + // o.setSign(-1); + // hit.setSign(+1); + // } + // } + // //System.out.println( " r = " + o.r() + " o.phi = " + o.phi() + " o.doca = " + o.getDoca()*o.getSign() + " hit.phi " + hit.phi() +" hit.doca = " + hit.getDoca()*hit.getSign() + " angle between wires: " + Math.toRadians(360./hit.getNumWires()) + " >= ? angle covered by docas: " + Math.atan( (o.getDoca()+hit.getDoca())/o.r() ) ); + } + } + if(!aleardyHaveR)KF_hits.add(hit); + // if (phi_rollover){ + // KF_hits.add(KF_hits.size()-1, hit); + // }else{ + // KF_hits.add(hit); // } - // if (!aleardyHaveR) - KF_hits.add(hit); - } - - - /* - Writer hitsWiresWriter = new FileWriter("hits_wires.dat"); - for (Hit h : KF_hits) { - hitsWiresWriter.write("" + h.getSuperLayer() + ", " + h.getLayer() + ", " + h.getWire() + ", " + h.getDoca() + ", " + h.getNumWires() + ", " + h.getR() + '\n'); - } - hitsWiresWriter.close(); - */ - - //System.out.println("KF_hits = " + KF_hits); - - final ArrayList forwardIndicators = forwardIndicators(KF_hits, materialHashMap); - final ArrayList backwardIndicators = backwardIndicators(KF_hits, materialHashMap); - - // Start propagation - Stepper stepper = new Stepper(y); - RungeKutta4 RK4 = new RungeKutta4(proton, numberOfVariables, B); - Propagator propagator = new Propagator(RK4); - - // ---------------------------------------------------------------------------------------- - - // Initialization of the Kalman Fitter - RealVector initialStateEstimate = new ArrayRealVector(stepper.y); - //first 3 lines in cm^2; last 3 lines in MeV^2 - RealMatrix initialErrorCovariance = MatrixUtils.createRealMatrix(new double[][]{{1.00, 0.0, 0.0, 0.0, 0.0, 0.0}, {0.0, 1.00, 0.0, 0.0, 0.0, 0.0}, {0.0, 0.0, 25.0, 0.0, 0.0, 0.0}, {0.0, 0.0, 0.0, 1.00, 0.0, 0.0}, {0.0, 0.0, 0.0, 0.0, 1.00, 0.0}, {0.0, 0.0, 0.0, 0.0, 0.0, 25.0}}); - - KFitter kFitter = new KFitter(initialStateEstimate, initialErrorCovariance, stepper, propagator); - - /* - Stepper stepper_fisrt = new Stepper(y); - Writer writer_first = new FileWriter("track_first.dat"); - for (Indicator indicator : forwardIndicators) { - stepper_fisrt.initialize(indicator); - propagator.propagateAndWrite(stepper_fisrt, indicator, writer_first); - } - writer_first.close(); - - + } - System.out.println("--------- BackWard propagation !! ---------"); - - Writer writer_back = new FileWriter("track_back.dat"); - for (Indicator indicator : backwardIndicators) { - stepper.initialize(indicator); - propagator.propagateAndWrite(stepper, indicator, writer_back); - } - writer_back.close(); - */ - - //Print out hit residuals *before* fit: - // for (Indicator indicator : forwardIndicators) { - // kFitter.predict(indicator); - // if (indicator.haveAHit()) { - // System.out.println(" Pre-fit: indicator R " + indicator.R + "; y = " + kFitter.getStateEstimationVector() + " p = " + kFitter.getMomentum() + " residual: " + kFitter.residual(indicator) + " sign " + kFitter.wire_sign(indicator) ); - // } - // } + double zbeam = 0; + if(IsVtxDefined)zbeam = vz_constraint;//test + final ArrayList forwardIndicators = forwardIndicators(KF_hits, materialHashMap); + final ArrayList backwardIndicators = backwardIndicators(KF_hits, materialHashMap, zbeam); - for (int k = 0; k < 10; k++) { - - //System.out.println("--------- ForWard propagation !! ---------"); - + // Start propagation + Stepper stepper = new Stepper(y); + RungeKutta4 RK4 = new RungeKutta4(proton, numberOfVariables, B); + Propagator propagator = new Propagator(RK4); + + // ---------------------------------------------------------------------------------------- + + // Initialization of the Kalman Fitter + RealVector initialStateEstimate = new ArrayRealVector(stepper.y); + //first 3 lines in cm^2; last 3 lines in MeV^2 + RealMatrix initialErrorCovariance = MatrixUtils.createRealMatrix(new double[][]{{1.00, 0.0, 0.0, 0.0, 0.0, 0.0}, {0.0, 1.00, 0.0, 0.0, 0.0, 0.0}, {0.0, 0.0, 25.0, 0.0, 0.0, 0.0}, {0.0, 0.0, 0.0, 1.00, 0.0, 0.0}, {0.0, 0.0, 0.0, 0.0, 1.00, 0.0}, {0.0, 0.0, 0.0, 0.0, 0.0, 25.0}}); + KFitter kFitter = new KFitter(initialStateEstimate, initialErrorCovariance, stepper, propagator); + kFitter.setVertexDefined(IsVtxDefined); + + for (int k = 0; k < Niter; k++) { + //System.out.println("--------- ForWard propagation !! ---------"); + //Reset error covariance: + //kFitter.ResetErrorCovariance(initialErrorCovariance); for (Indicator indicator : forwardIndicators) { - kFitter.predict(indicator); - //System.out.println("indicator R " + indicator.R + " h " + indicator.h + "; y = " + kFitter.getStateEstimationVector() + " p = " + kFitter.getMomentum()); - if (indicator.haveAHit()) { - //System.out.println("Superlayer = " + indicator.hit.getSuperLayer() + ", Layer " + indicator.hit.getLayer() + ", Wire " + indicator.hit.getWire() + ", Nwires " + indicator.hit.getNumWires() + ", Radius " + indicator.hit.getR() + ", DOCA " + indicator.hit.getDoca()); - kFitter.correct(indicator); - //System.out.println("y = " + kFitter.getStateEstimationVector() + " p = " + kFitter.getMomentum()); + kFitter.predict(indicator); + if (indicator.haveAHit()) { + if( k==0 && indicator.hit.getHitIdx()>0){ + for (org.jlab.rec.ahdc.Hit.Hit AHDC_hit : AHDC_hits){ + if(AHDC_hit.getId()==indicator.hit.getHitIdx())AHDC_hit.setResidualPrefit(kFitter.residual(indicator)); + } } + kFitter.correct(indicator); + } } //System.out.println("--------- BackWard propagation !! ---------"); - for (Indicator indicator : backwardIndicators) { - kFitter.predict(indicator); - //System.out.println("indicator R " + indicator.R + " h " + indicator.h + "; y = " + kFitter.getStateEstimationVector() + " p = " + kFitter.getMomentum()); - if (indicator.haveAHit()) { - //System.out.println("Superlayer = " + indicator.hit.getSuperLayer() + ", Layer " + indicator.hit.getLayer() + ", Wire " + indicator.hit.getWire() + ", Nwires " + indicator.hit.getNumWires() + ", Radius " + indicator.hit.getR() + ", DOCA " + indicator.hit.getDoca()); - kFitter.correct(indicator); - //System.out.println("y = " + kFitter.getStateEstimationVector() + " p = " + kFitter.getMomentum()); + kFitter.predict(indicator); + if (indicator.haveAHit()) { + kFitter.correct(indicator); + } + } + } + + RealVector x_out = kFitter.getStateEstimationVector(); + track.setPositionAndMomentumForKF(x_out); + + //Residual calcuation post fit: + for (Indicator indicator : forwardIndicators) { + kFitter.predict(indicator); + if (indicator.haveAHit()) { + if( indicator.hit.getHitIdx()>0){ + for (org.jlab.rec.ahdc.Hit.Hit AHDC_hit : AHDC_hits){ + if(AHDC_hit.getId()==indicator.hit.getHitIdx())AHDC_hit.setResidual(kFitter.residual(indicator)); } + } } - } - - // //Print out residuals *after* fit: - // for (Indicator indicator : forwardIndicators) { - // kFitter.predict(indicator); - // if (indicator.haveAHit()) { - // System.out.println(" Post-fit: indicator R " + indicator.R + "; y = " + kFitter.getStateEstimationVector() + " p = " + kFitter.getMomentum() + " residual: " + kFitter.residual(indicator) + " sign " + kFitter.wire_sign(indicator) ); - // } - // } - - /* - Writer writer_last = new FileWriter("track_last.dat"); - for (Indicator indicator : forwardIndicators) { - stepper.initialize(indicator); - propagator.propagateAndWrite(stepper, indicator, writer_last); - } - writer_last.close(); - */ - - - RealVector x_out = kFitter.getStateEstimationVector(); - tracks.get(0).setPositionAndMomentumForKF(x_out); - - //System.out.println("y_final = " + x_out + " p_final = " + kFitter.getMomentum()); + } + // At this stage, all relevants AHDC hits are filled + // Compute sum_adc, sum_residuals and chi2 + int sum_adc = 0; + double sum_residuals = 0; + double chi2 = 0; + for (org.jlab.rec.ahdc.Hit.Hit AHDC_hit : AHDC_hits) { + sum_adc += AHDC_hit.getADC(); + sum_residuals += AHDC_hit.getResidual(); + chi2 += Math.pow(AHDC_hit.getResidual(),2.0); + } + track.set_sum_adc(sum_adc); + track.set_sum_residuals(sum_residuals); + track.set_chi2(chi2); + }//end of loop on track candidates } catch (Exception e) { // e.printStackTrace(); } @@ -301,4 +293,17 @@ ArrayList backwardIndicators(ArrayList hitArrayList, HashMap backwardIndicators(ArrayList hitArrayList, HashMap materialHashMap, double vz) { + ArrayList backwardIndicators = new ArrayList<>(); + //R, h, defined in mm! + for (int i = hitArrayList.size() - 2; i >= 0; i--) { + backwardIndicators.add(new Indicator(hitArrayList.get(i).r(), 0.1, hitArrayList.get(i), false, materialHashMap.get("BONuS12Gas"))); + } + backwardIndicators.add(new Indicator(3.060, 1, null, false, materialHashMap.get("BONuS12Gas"))); + backwardIndicators.add(new Indicator(3.0, 0.001, null, false, materialHashMap.get("Kapton"))); + Hit hit = new Hit_beam(0, 0, 0, 0, 0, 0, 0, vz); + backwardIndicators.add(new Indicator(0.0, 0.2, hit, false, materialHashMap.get("deuteriumGas"))); + return backwardIndicators; + } } diff --git a/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/Mode.java b/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/Mode.java new file mode 100644 index 0000000000..1278ddae4c --- /dev/null +++ b/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/Mode.java @@ -0,0 +1,5 @@ +package org.jlab.rec.ahdc; + +public enum Mode { + AI_Track_Finding, CV_Track_Finding; +} diff --git a/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/PreCluster/PreCluster.java b/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/PreCluster/PreCluster.java index 77140769c8..0045641849 100644 --- a/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/PreCluster/PreCluster.java +++ b/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/PreCluster/PreCluster.java @@ -4,6 +4,11 @@ import java.util.ArrayList; +/** PreCluster. + * + * \todo What is a pre cluster? + * + */ public class PreCluster implements Comparable { private int _Id; diff --git a/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/Track/Track.java b/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/Track/Track.java index 8a968ba512..ea1548a083 100644 --- a/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/Track/Track.java +++ b/reconstruction/alert/src/main/java/org/jlab/rec/ahdc/Track/Track.java @@ -15,21 +15,32 @@ public class Track { private List _Clusters = new ArrayList<>(); private boolean _Used = false; private final ArrayList hits = new ArrayList<>(); - ; - + + private int trackId = -1; ///< id of the track + private int n_hits = 0; ///< number of hits + private int sum_adc = 0; ///< sum of adc (adc) + private double sum_residuals = 0; ///< sum of residuals (mm) + private double chi2 = 0; ///< sum of residuals^2 (mm^2) + // AHDC::track private double x0 = 0; private double y0 = 0; private double z0 = 0; private double px0 = 0; private double py0 = 0; private double pz0 = 0; - + private double dEdx = 0; ///< deposited energy per path length (adc/mm) + private double p_drift = 0; ///< momentum in the drift region (MeV) + private double path = 0; ///< length of the track (mm) + // AHDC::kftrack private double x0_kf = 0; private double y0_kf = 0; private double z0_kf = 0; private double px0_kf = 0; private double py0_kf = 0; private double pz0_kf = 0; + private double dEdx_kf = 0; ///< deposited energy per path length (adc/mm) + private double p_drift_kf = 0; ///< momentum in the drift region (MeV) + private double path_kf = 0; ///< length of the track (mm) public Track(List clusters) { this._Clusters = clusters; @@ -64,6 +75,15 @@ public void setPositionAndMomentum(HelixFitObject helixFitObject) { this.pz0 = helixFitObject.get_pz(); } + public void setPositionAndMomentumVec(double[] x) { + this.x0 = x[0]; + this.y0 = x[1]; + this.z0 = x[2]; + this.px0 = x[3]; + this.py0 = x[4]; + this.pz0 = x[5]; + } + public void setPositionAndMomentumForKF(RealVector x) { this.x0_kf = x.getEntry(0); this.y0_kf = x.getEntry(1); @@ -153,4 +173,32 @@ public double getPy0_kf() { public double getPz0_kf() { return pz0_kf; } + + // Same for Track and KFTrack + public void set_trackId(int _trackId) { trackId = _trackId;} + public void set_n_hits(int _n_hits) { n_hits = _n_hits;} + public void set_sum_adc(int _sum_adc) { sum_adc = _sum_adc;} + public void set_chi2(double _chi2) { chi2 = _chi2;} + public void set_sum_residuals(double _sum_residuals) { sum_residuals = _sum_residuals;} + public int get_trackId() {return trackId;} + public int get_n_hits() {return n_hits;} + public int get_sum_adc() {return sum_adc;} + public double get_chi2() {return chi2;} + public double get_sum_residuals() {return sum_residuals;} + // AHDC::track + public void set_dEdx(double _dEdx) { dEdx = _dEdx;} + public void set_p_drift(double _p_drift) { p_drift = _p_drift;} + public void set_path(double _path) { path = _path;} + public double get_dEdx() {return dEdx;} + public double get_p_drift() {return p_drift;} + public double get_path() {return path;} + + // AHDC::kftrack + public void set_dEdx_kf(double _dEdx_kf) { dEdx_kf = _dEdx_kf;} + public void set_p_drift_kf(double _p_drift_kf) { p_drift_kf = _p_drift_kf;} + public void set_path_kf(double _path_kf) { path_kf = _path_kf;} + public double get_dEdx_kf() {return dEdx_kf;} + public double get_p_drift_kf() {return p_drift_kf;} + public double get_path_kf() {return path_kf;} + } diff --git a/reconstruction/alert/src/main/java/org/jlab/rec/alert/banks/RecoBankWriter.java b/reconstruction/alert/src/main/java/org/jlab/rec/alert/banks/RecoBankWriter.java new file mode 100644 index 0000000000..787654a7fa --- /dev/null +++ b/reconstruction/alert/src/main/java/org/jlab/rec/alert/banks/RecoBankWriter.java @@ -0,0 +1,81 @@ +package org.jlab.rec.alert.banks; + +import java.util.ArrayList; +import org.jlab.io.base.DataBank; +import org.jlab.io.base.DataEvent; +import org.jlab.rec.alert.projections.TrackProjection; + +/** + * The ALERT {@code RecoBankWriter} writes the banks needed for the ALERT + * reconstruction: track projections. + * + * @author Noemie Pilleux + * @author Whit Armstrong + */ +public class RecoBankWriter { + + /** + * Writes the bank of track projections. + * + * @param event the {@link DataEvent} in which to add the bank + * @param projections the {@link ArrayList} of {@link TrackProjection} + * containing the track projection info to be added to the bank + * + * @return {@link DataBank} the bank with all the projected tracks in the + * event. + * + */ + public static DataBank fillProjectionsBank(DataEvent event, ArrayList projections) { + + DataBank bank = event.createBank("ALERT::projections", projections.size()); + + if (bank == null) { + System.err.println("COULD NOT CREATE A ALERT::projections BANK!!!!!!"); + return null; + } + for (int i = 0; i < projections.size(); i++) { + TrackProjection projection = projections.get(i); + bank.setShort("id", i, (short) (i + 1)); + bank.setShort("trackid", i, (short) projection.getTrackID()); + bank.setFloat("x_at_bar", i, (float) projection.getBarIntersect().x()); + bank.setFloat("y_at_bar", i, (float) projection.getBarIntersect().y()); + bank.setFloat("z_at_bar", i, (float) projection.getBarIntersect().z()); + bank.setFloat("l_at_bar", i, (float) projection.getBarPathLength()); + bank.setFloat("l_in_bar", i, (float) projection.getBarInPathLength()); + bank.setFloat("x_at_wedge", i, (float) projection.getWedgeIntersect().x()); + bank.setFloat("y_at_wedge", i, (float) projection.getWedgeIntersect().y()); + bank.setFloat("z_at_wedge", i, (float) projection.getWedgeIntersect().z()); + bank.setFloat("l_at_wedge", i, (float) projection.getWedgePathLength()); + bank.setFloat("l_in_wedge", i, (float) projection.getWedgeInPathLength()); + } + return bank; + } + + /** + * Appends the alert match banks to an event. + * + * @param event the {@link DataEvent} in which to append the banks + * @param projections the {@link ArrayList} of {@link TrackProjection} containing the + * track projections info to be added + * + * @return 0 if it worked, 1 if it failed + * + */ + public int appendMatchBanks(DataEvent event, ArrayList projections) { + + DataBank projbank = this.fillProjectionsBank(event, projections); + if (projbank != null) { + event.appendBank(projbank); + } else { + return 1; + } + return 0; + } + + /** + * @param args the command line arguments + */ + public static void main(String[] args) { + } + +} diff --git a/reconstruction/alert/src/main/java/org/jlab/rec/alert/projections/TrackProjector.java b/reconstruction/alert/src/main/java/org/jlab/rec/alert/projections/TrackProjector.java index 4807be813f..ca4a487a91 100644 --- a/reconstruction/alert/src/main/java/org/jlab/rec/alert/projections/TrackProjector.java +++ b/reconstruction/alert/src/main/java/org/jlab/rec/alert/projections/TrackProjector.java @@ -90,50 +90,52 @@ public void setB(Double B) { public void projectTracks(DataEvent event) {//, CalibrationConstantsLoader ccdb) { projections.clear(); - String track_bank_name = "AHDC::Track"; - if (event == null) { // check if there is an event - //System.out.print(" no event \n"); - } else if (event.hasBank(track_bank_name) == false) { - // check if there are ahdc tracks in the event - //System.out.print("no tracks \n"); - } else { - DataBank bank = event.getBank(track_bank_name); - int nt = bank.rows(); // number of tracks - TrackProjection projection = new TrackProjection(); - for (int i = 0; i < nt; i++) { - double x = bank.getFloat("x", i); - double y = bank.getFloat("y", i); - double z = bank.getFloat("z", i); - double px = bank.getFloat("px", i); - double py = bank.getFloat("py", i); - double pz = bank.getFloat("pz", i); - int id = nt + 1;//To be replaced by track id if it is added to the out bank - - int q = -1; //need the charge sign from tracking - - Units units = Units.MM; //can be MM or CM. - - double xb = 0; - double yb = 0; - - //momenta must be in GeV for the helix class - Helix helix = new Helix(x, y, z, px / 1000., py / 1000., pz / 1000., q, b, xb, yb, units); - - //Intersection points with the middle of the bar or wedge - projection.setBarIntersect(helix.getHelixPointAtR(Parameters.BAR_MIDDLE_RADIUS)); - projection.setWedgeIntersect(helix.getHelixPointAtR(Parameters.WEDGE_MIDDLE_RADIUS)); - - double rVertex = Math.sqrt(x * x + y * y); - - //Path length to the middle of the bar or wedge - projection.setBarPathLength((float) helix.getPathLength(rVertex, Parameters.BAR_MIDDLE_RADIUS)); - projection.setWedgePathLength((float) helix.getPathLength(rVertex, Parameters.WEDGE_MIDDLE_RADIUS)); - //Path length from the inner radius to the middle radius - projection.setBarInPathLength((float) helix.getPathLength(Parameters.BAR_INNER_RADIUS, Parameters.BAR_MIDDLE_RADIUS)); - projection.setWedgeInPathLength((float) helix.getPathLength(Parameters.WEDGE_INNER_RADIUS, Parameters.WEDGE_MIDDLE_RADIUS)); - projection.setTrackID(id); - projections.add(projection); - } + String track_bank_name = "AHDC::track"; + + // check if there is an event + if (event == null) return; + //System.out.print(" no event \n"); + + // check if there are ahdc tracks in the event + if (event.hasBank(track_bank_name) == false) return; + //System.out.print("no tracks \n"); + + DataBank bank = event.getBank(track_bank_name); + int nt = bank.rows(); // number of tracks + TrackProjection projection = new TrackProjection(); + for (int i = 0; i < nt; i++) { + double x = bank.getFloat("x", i); + double y = bank.getFloat("y", i); + double z = bank.getFloat("z", i); + double px = bank.getFloat("px", i); + double py = bank.getFloat("py", i); + double pz = bank.getFloat("pz", i); + int id = nt + 1;//To be replaced by track id if it is added to the out bank + + int q = -1; //need the charge sign from tracking + + Units units = Units.MM; //can be MM or CM. + + double xb = 0; + double yb = 0; + + //momenta must be in GeV for the helix class + Helix helix = new Helix(x, y, z, px / 1000., py / 1000., pz / 1000., q, b, xb, yb, units); + + //Intersection points with the middle of the bar or wedge + projection.setBarIntersect(helix.getHelixPointAtR(Parameters.BAR_MIDDLE_RADIUS)); + projection.setWedgeIntersect(helix.getHelixPointAtR(Parameters.WEDGE_MIDDLE_RADIUS)); + + double rVertex = Math.sqrt(x * x + y * y); + + //Path length to the middle of the bar or wedge + projection.setBarPathLength((float) helix.getPathLength(rVertex, Parameters.BAR_MIDDLE_RADIUS)); + projection.setWedgePathLength((float) helix.getPathLength(rVertex, Parameters.WEDGE_MIDDLE_RADIUS)); + //Path length from the inner radius to the middle radius + projection.setBarInPathLength((float) helix.getPathLength(Parameters.BAR_INNER_RADIUS, Parameters.BAR_MIDDLE_RADIUS)); + projection.setWedgeInPathLength((float) helix.getPathLength(Parameters.WEDGE_INNER_RADIUS, Parameters.WEDGE_MIDDLE_RADIUS)); + projection.setTrackID(id); + projections.add(projection); } } @@ -148,56 +150,56 @@ public void projectMCTracks(DataEvent event) {//, CalibrationConstantsLoader ccd projections.clear(); String track_bank_name = "MC::Particle"; - if (event == null) { // check if there is an event - //System.out.print(" no event \n"); - } else if (event.hasBank(track_bank_name) == false) { - // check if there are ahdc tracks in the event - //System.out.print("no tracks \n"); - } else { - DataBank bank = event.getBank(track_bank_name); - int nt = bank.rows(); // number of tracks - TrackProjection projection = new TrackProjection(); - - for (int i = 0; i < nt; i++) { - - double x = bank.getFloat("vx", i); - double y = bank.getFloat("vy", i); - double z = bank.getFloat("vz", i); - double px = bank.getFloat("px", i); - double py = bank.getFloat("py", i); - double pz = bank.getFloat("pz", i); - int id = bank.getShort("id", i); - //Put everything in MM - x = x * 10; - y = y * 10; - z = z * 10; - - Units units = Units.MM; - - int q = -1; //need the charge sign from tracking - - double xb = 0; - double yb = 0; - - //momenta must be in GeV for the helix class - Helix helix = new Helix(x, y, z, px, py, pz, q, b, xb, yb, units); - - //Intersection points with the middle of the bar or wedge - projection.setBarIntersect(helix.getHelixPointAtR(Parameters.BAR_MIDDLE_RADIUS)); - projection.setWedgeIntersect(helix.getHelixPointAtR(Parameters.WEDGE_MIDDLE_RADIUS)); - - double rVertex = Math.sqrt(x * x + y * y); - - //Path length to the middle of the bar or wedge - projection.setBarPathLength((float) helix.getPathLength(rVertex, Parameters.BAR_MIDDLE_RADIUS)); - projection.setWedgePathLength((float) helix.getPathLength(rVertex, Parameters.WEDGE_MIDDLE_RADIUS)); - //Path length from the inner radius to the middle radius - projection.setBarInPathLength((float) helix.getPathLength(Parameters.BAR_INNER_RADIUS, Parameters.BAR_MIDDLE_RADIUS)); - projection.setWedgeInPathLength((float) helix.getPathLength(Parameters.WEDGE_INNER_RADIUS, Parameters.WEDGE_MIDDLE_RADIUS)); - - projection.setTrackID(id); - projections.add(projection); - } + if (event == null) return; + //System.out.print(" no event \n"); + + // check if there are ahdc tracks in the event + if (event.hasBank(track_bank_name) == false) return; + //System.out.print("no tracks \n"); + + DataBank bank = event.getBank(track_bank_name); + int nt = bank.rows(); // number of tracks + TrackProjection projection = new TrackProjection(); + + for (int i = 0; i < nt; i++) { + + double x = bank.getFloat("vx", i); + double y = bank.getFloat("vy", i); + double z = bank.getFloat("vz", i); + double px = bank.getFloat("px", i); + double py = bank.getFloat("py", i); + double pz = bank.getFloat("pz", i); + int id = bank.getShort("id", i); + //Put everything in MM + x = x * 10; + y = y * 10; + z = z * 10; + + Units units = Units.MM; + + int q = -1; //need the charge sign from tracking + + double xb = 0; + double yb = 0; + + //momenta must be in GeV for the helix class + Helix helix = new Helix(x, y, z, px, py, pz, q, b, xb, yb, units); + + //Intersection points with the middle of the bar or wedge + projection.setBarIntersect(helix.getHelixPointAtR(Parameters.BAR_MIDDLE_RADIUS)); + projection.setWedgeIntersect(helix.getHelixPointAtR(Parameters.WEDGE_MIDDLE_RADIUS)); + + double rVertex = Math.sqrt(x * x + y * y); + + //Path length to the middle of the bar or wedge + projection.setBarPathLength((float) helix.getPathLength(rVertex, Parameters.BAR_MIDDLE_RADIUS)); + projection.setWedgePathLength((float) helix.getPathLength(rVertex, Parameters.WEDGE_MIDDLE_RADIUS)); + //Path length from the inner radius to the middle radius + projection.setBarInPathLength((float) helix.getPathLength(Parameters.BAR_INNER_RADIUS, Parameters.BAR_MIDDLE_RADIUS)); + projection.setWedgeInPathLength((float) helix.getPathLength(Parameters.WEDGE_INNER_RADIUS, Parameters.WEDGE_MIDDLE_RADIUS)); + + projection.setTrackID(id); + projections.add(projection); } } diff --git a/reconstruction/alert/src/main/java/org/jlab/rec/atof/banks/RecoBankWriter.java b/reconstruction/alert/src/main/java/org/jlab/rec/atof/banks/RecoBankWriter.java index b903b71f57..6209275942 100644 --- a/reconstruction/alert/src/main/java/org/jlab/rec/atof/banks/RecoBankWriter.java +++ b/reconstruction/alert/src/main/java/org/jlab/rec/atof/banks/RecoBankWriter.java @@ -78,8 +78,8 @@ public static DataBank fillATOFClusterBank(DataEvent event, ArrayList projections) { - DataBank bank = event.createBank("ALERT::Projections", projections.size()); + DataBank bank = event.createBank("ALERT::projections", projections.size()); if (bank == null) { - System.err.println("COULD NOT CREATE A ALERT::Projections BANK!!!!!!"); + System.err.println("COULD NOT CREATE A ALERT::projections BANK!!!!!!"); return null; } for (int i = 0; i < projections.size(); i++) { TrackProjection projection = projections.get(i); bank.setShort("id", i, (short) (i + 1)); - bank.setShort("trackID", i, (short) projection.getTrackID()); + bank.setShort("trackid", i, (short) projection.getTrackID()); bank.setFloat("x_at_bar", i, (float) projection.getBarIntersect().x()); bank.setFloat("y_at_bar", i, (float) projection.getBarIntersect().y()); bank.setFloat("z_at_bar", i, (float) projection.getBarIntersect().z()); - bank.setFloat("L_at_bar", i, (float) projection.getBarPathLength()); - bank.setFloat("L_in_bar", i, (float) projection.getBarInPathLength()); + bank.setFloat("l_at_bar", i, (float) projection.getBarPathLength()); + bank.setFloat("l_in_bar", i, (float) projection.getBarInPathLength()); bank.setFloat("x_at_wedge", i, (float) projection.getWedgeIntersect().x()); bank.setFloat("y_at_wedge", i, (float) projection.getWedgeIntersect().y()); bank.setFloat("z_at_wedge", i, (float) projection.getWedgeIntersect().z()); - bank.setFloat("L_at_wedge", i, (float) projection.getWedgePathLength()); - bank.setFloat("L_in_wedge", i, (float) projection.getWedgeInPathLength()); + bank.setFloat("l_at_wedge", i, (float) projection.getWedgePathLength()); + bank.setFloat("l_in_wedge", i, (float) projection.getWedgeInPathLength()); } return bank; } diff --git a/reconstruction/alert/src/main/java/org/jlab/rec/atof/cluster/ATOFCluster.java b/reconstruction/alert/src/main/java/org/jlab/rec/atof/cluster/ATOFCluster.java index e04ccee1e3..bf16716823 100644 --- a/reconstruction/alert/src/main/java/org/jlab/rec/atof/cluster/ATOFCluster.java +++ b/reconstruction/alert/src/main/java/org/jlab/rec/atof/cluster/ATOFCluster.java @@ -193,7 +193,7 @@ public int matchTrack(DataEvent event) { //This cluster point in space Point3D cluster = new Point3D(this.x, this.y, this.z); //Bank to be read - String track_bank_name = "ALERT::Projections"; + String track_bank_name = "ALERT::projections"; //Checking if there is an event if (event == null) { return 1; @@ -228,9 +228,9 @@ public int matchTrack(DataEvent event) { xt = track_bank.getFloat("x_at_wedge", i); yt = track_bank.getFloat("y_at_wedge", i); zt = track_bank.getFloat("z_at_wedge", i); - path = track_bank.getFloat("L_at_wedge", i); + path = track_bank.getFloat("l_at_wedge", i); //A wedge hit traveled through the whole bar and then through a portion of the wedge - inpath = track_bank.getFloat("L_in_wedge", i) + track_bank.getFloat("L_at_wedge", i) - track_bank.getFloat("L_at_bar", i); + inpath = track_bank.getFloat("l_in_wedge", i) + track_bank.getFloat("l_at_wedge", i) - track_bank.getFloat("l_at_bar", i); } case "bar" -> { sigma_phi = Parameters.SIGMA_PHI_TRACK_MATCHING_BAR; @@ -238,8 +238,8 @@ public int matchTrack(DataEvent event) { xt = track_bank.getFloat("x_at_bar", i); yt = track_bank.getFloat("y_at_bar", i); zt = track_bank.getFloat("z_at_bar", i); - path = track_bank.getFloat("L_at_bar", i); - inpath = track_bank.getFloat("L_in_bar", i); + path = track_bank.getFloat("l_at_bar", i); + inpath = track_bank.getFloat("l_in_bar", i); } case "bar up", "bar down" -> { System.out.print("Impossible to match track and hit; hit type is a single up or down bar hit. \n"); diff --git a/reconstruction/alert/src/main/java/org/jlab/rec/atof/hit/ATOFHit.java b/reconstruction/alert/src/main/java/org/jlab/rec/atof/hit/ATOFHit.java index f1ce4751d9..8277987701 100644 --- a/reconstruction/alert/src/main/java/org/jlab/rec/atof/hit/ATOFHit.java +++ b/reconstruction/alert/src/main/java/org/jlab/rec/atof/hit/ATOFHit.java @@ -3,6 +3,8 @@ import org.jlab.geom.base.*; import org.jlab.geom.prim.Point3D; import org.jlab.rec.atof.constants.Parameters; +import java.util.logging.Level; +import java.util.logging.Logger; /** * @@ -15,6 +17,8 @@ */ public class ATOFHit { + static final Logger LOGGER = Logger.getLogger(ATOFHit.class.getName()); + private int sector, layer, component, order; private int tdc, tot; private double time, energy, x, y, z; @@ -182,7 +186,7 @@ public final String makeType() { public final int convertTdcToTime() { double tdc2time, veff, distance_to_sipm; if (null == this.type) { - System.out.print("Null hit type, cannot convert tdc to time."); + LOGGER.finest("Null hit type, cannot convert tdc to time."); return 1; } else { switch (this.type) { @@ -205,11 +209,11 @@ public final int convertTdcToTime() { distance_to_sipm = 0; } case "bar" -> { - System.out.print("Bar hit type, cannot convert tdc to time."); + LOGGER.finest("Bar hit type, cannot convert tdc to time."); return 1; } default -> { - System.out.print("Undefined hit type, cannot convert tdc to time."); + LOGGER.finest("Undefined hit type, cannot convert tdc to time."); return 1; } } @@ -230,7 +234,7 @@ public final int convertTdcToTime() { public final int convertTotToEnergy() { double tot2energy; if (null == this.type) { - System.out.print("Null hit type, cannot convert tot to energy."); + LOGGER.finest("Null hit type, cannot convert tot to energy."); return 1; } else { switch (this.type) { @@ -254,11 +258,11 @@ public final int convertTotToEnergy() { this.energy = tot2energy * this.tot; } case "bar" -> { - System.out.print("Bar hit type, cannot convert tot to energy."); + LOGGER.finest("Bar hit type, cannot convert tot to energy."); return 1; } default -> { - System.out.print("Undefined hit type, cannot convert tot to energy."); + LOGGER.finest("Undefined hit type, cannot convert tot to energy."); return 1; } } @@ -294,12 +298,11 @@ public final int convertSLCToXYZ(Detector atof) { Component comp = atof.getSector(this.sector).getSuperlayer(sl).getLayer(this.layer).getComponent(this.component); Point3D midpoint = comp.getMidpoint(); //Midpoints defined in the system were z=0 is the upstream end of the atof - //Translation to the system were z=0 is the center of the atof //Units are mm this.x = midpoint.x(); this.y = midpoint.y(); - this.z = midpoint.z() - Parameters.LENGTH_ATOF / 2.; - return 0; + this.z = midpoint.z(); + return 0; } /** diff --git a/reconstruction/alert/src/main/java/org/jlab/rec/constants/CalibrationConstantsLoader.java b/reconstruction/alert/src/main/java/org/jlab/rec/constants/CalibrationConstantsLoader.java new file mode 100644 index 0000000000..ac77b84308 --- /dev/null +++ b/reconstruction/alert/src/main/java/org/jlab/rec/constants/CalibrationConstantsLoader.java @@ -0,0 +1,214 @@ +package org.jlab.rec.constants; + +import org.jlab.detector.calib.utils.ConstantsManager; +import org.jlab.detector.calib.utils.DatabaseConstantProvider; +import org.jlab.utils.groups.IndexedTable; + +import java.util.HashMap; +import java.util.Map; + +/** + * This class loads constants from CCDB + * + * inspired by the one of the BAND subsystem + * + * @author ftouchte + */ + +public class CalibrationConstantsLoader { + + public CalibrationConstantsLoader() { + // TODO Auto-generated constructor stub + } + public static boolean CSTLOADED = false; + + // Maps for constants from database + // AHDC + public static Map AHDC_TIME_OFFSETS = new HashMap<>(); ///< AHDC Parameters for timing offsets + public static Map AHDC_TIME_TO_DISTANCE = new HashMap<>(); ///< AHDC Parameters for time to distance + public static Map AHDC_RAW_HIT_CUTS = new HashMap<>(); ///< AHDC Parameters for raw hit cuts + + // ATOF + public static Map ATOF_EFFECTIVE_VELOCITY = new HashMap<>(); ///< ATOF Parameters for effective velocity + public static Map ATOF_TIME_WALK = new HashMap<>(); ///< ATOF Parameters for time walk + public static Map ATOF_ATTENUATION_LENGTH = new HashMap<>(); ///< ATOF Parameters for attenuation lenght + public static Map ATOF_TIME_OFFSETS = new HashMap<>(); ///< ATOF Parameters for timing offsets + + public static synchronized void Load(int runno, ConstantsManager manager) { + + //System.out.println("*Loading calibration constants*"); + + IndexedTable ahdc_timeOffsets = manager.getConstants(runno, "/calibration/alert/ahdc/time_offsets"); + IndexedTable ahdc_time2distance = manager.getConstants(runno, "/calibration/alert/ahdc/time_to_distance"); + IndexedTable ahdc_rawHitCuts = manager.getConstants(runno, "/calibration/alert/ahdc/raw_hit_cuts"); + IndexedTable atof_effectiveVelocity = manager.getConstants(runno, "/calibration/alert/atof/effective_velocity"); + IndexedTable atof_timeWalk = manager.getConstants(runno, "/calibration/alert/atof/time_walk"); + IndexedTable atof_attenuationLength = manager.getConstants(runno, "/calibration/alert/atof/attenuation"); + IndexedTable atof_timeOffsets = manager.getConstants(runno, "/calibration/alert/atof/time_offsets"); + + + //////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // AHDC time offsets + for( int i = 0; i < ahdc_timeOffsets.getRowCount(); i++){ + int sector = Integer.parseInt((String)ahdc_timeOffsets.getValueAt(i, 0)); + int layer = Integer.parseInt((String)ahdc_timeOffsets.getValueAt(i, 1)); + int component = Integer.parseInt((String)ahdc_timeOffsets.getValueAt(i, 2)); + double t0 = ahdc_timeOffsets.getDoubleValue("t0", sector, layer, component); + double dt0 = ahdc_timeOffsets.getDoubleValue("dt0", sector, layer, component); + double extra1 = ahdc_timeOffsets.getDoubleValue("extra1", sector, layer, component); + double extra2 = ahdc_timeOffsets.getDoubleValue("extra2", sector, layer, component); + double chi2ndf = ahdc_timeOffsets.getDoubleValue("chi2ndf", sector, layer, component); + // Put in map + int key = sector*10000 + layer*100 + component; + double params[] = {t0, dt0, extra1, extra2, chi2ndf}; + AHDC_TIME_OFFSETS.put(Integer.valueOf(key), params); + //System.out.println("t0 : " + t0 + " dt0 : " + dt0 + " extra1 : " + extra1 + " extra2 : " + extra2 + " chi2ndf : " + chi2ndf); + } + + //////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // AHDC time to distance + // Caution, this table has only one row + // the corresponding identifers are (sector, layer, component) == (1,1,1) + // but it applies for all AHDC wires ! + for( int i = 0; i < ahdc_time2distance.getRowCount(); i++){ + int sector = Integer.parseInt((String)ahdc_time2distance.getValueAt(i, 0)); + int layer = Integer.parseInt((String)ahdc_time2distance.getValueAt(i, 1)); + int component = Integer.parseInt((String)ahdc_time2distance.getValueAt(i, 2)); + double p0 = ahdc_time2distance.getDoubleValue("p0", sector, layer, component); + double p1 = ahdc_time2distance.getDoubleValue("p1", sector, layer, component); + double p2 = ahdc_time2distance.getDoubleValue("p2", sector, layer, component); + double p3 = ahdc_time2distance.getDoubleValue("p3", sector, layer, component); + double p4 = ahdc_time2distance.getDoubleValue("p4", sector, layer, component); + double p5 = ahdc_time2distance.getDoubleValue("p5", sector, layer, component); + double dp0 = ahdc_time2distance.getDoubleValue("dp0", sector, layer, component); + double dp1 = ahdc_time2distance.getDoubleValue("dp1", sector, layer, component); + double dp2 = ahdc_time2distance.getDoubleValue("dp2", sector, layer, component); + double dp3 = ahdc_time2distance.getDoubleValue("dp3", sector, layer, component); + double dp4 = ahdc_time2distance.getDoubleValue("dp4", sector, layer, component); + double dp5 = ahdc_time2distance.getDoubleValue("dp5", sector, layer, component); + double chi2ndf = ahdc_time2distance.getDoubleValue("chi2ndf", sector, layer, component); + // Put in map + int key = sector*10000 + layer*100 + component; + double params[] = {p0, p1, p2, p3, p4, p5, dp0, dp1, dp2, dp3, dp4, dp5, chi2ndf}; + AHDC_TIME_TO_DISTANCE.put(Integer.valueOf(key), params); + //System.out.println("p0 : " + p0 + " p1 : " + p1 + " p2 : " + p2 + " p3 : " + p3 + " p4 : " + p4 + " p5 : " + p5); + } + + //////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // AHDC raw hit cuts + for( int i = 0; i < ahdc_rawHitCuts.getRowCount(); i++){ + int sector = Integer.parseInt((String)ahdc_rawHitCuts.getValueAt(i, 0)); + int layer = Integer.parseInt((String)ahdc_rawHitCuts.getValueAt(i, 1)); + int component = Integer.parseInt((String)ahdc_rawHitCuts.getValueAt(i, 2)); + double t_min = ahdc_rawHitCuts.getDoubleValue("t_min", sector, layer, component); + double t_max = ahdc_rawHitCuts.getDoubleValue("t_max", sector, layer, component); + double tot_min = ahdc_rawHitCuts.getDoubleValue("tot_min", sector, layer, component); + double tot_max = ahdc_rawHitCuts.getDoubleValue("tot_max", sector, layer, component); + double adc_min = ahdc_rawHitCuts.getDoubleValue("adc_min", sector, layer, component); + double adc_max = ahdc_rawHitCuts.getDoubleValue("adc_max", sector, layer, component); + double ped_min = ahdc_rawHitCuts.getDoubleValue("ped_min", sector, layer, component); + double ped_max = ahdc_rawHitCuts.getDoubleValue("ped_max", sector, layer, component); + // Put in map + int key = sector*10000 + layer*100 + component; + double params[] = {t_min, t_max, tot_min, tot_max, adc_min, adc_max, ped_min, ped_max}; + AHDC_RAW_HIT_CUTS.put(Integer.valueOf(key), params); + //System.out.println("t_min : " + t_min + " t_max : " + t_max + " tot_min : " + tot_min + " tot_max : " + tot_max + " adc_min : " + adc_min + " adc_max : " + adc_max + " ped_min : " + ped_min + " ped_max : " + ped_max); + } + + //////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // ATOF effective velocity + for( int i = 0; i < atof_effectiveVelocity.getRowCount(); i++){ + int sector = Integer.parseInt((String)atof_effectiveVelocity.getValueAt(i, 0)); + int layer = Integer.parseInt((String)atof_effectiveVelocity.getValueAt(i, 1)); + int component = Integer.parseInt((String)atof_effectiveVelocity.getValueAt(i, 2)); + double veff = atof_effectiveVelocity.getDoubleValue("veff", sector, layer, component); + double dveff = atof_effectiveVelocity.getDoubleValue("dveff", sector, layer, component); + double extra1 = atof_effectiveVelocity.getDoubleValue("extra1", sector, layer, component); + double extra2 = atof_effectiveVelocity.getDoubleValue("extra2", sector, layer, component); + // Put in map + int key = sector*10000 + layer*1000 + component*10; + double params[] = {veff, dveff, extra1, extra2}; + ATOF_EFFECTIVE_VELOCITY.put(Integer.valueOf(key), params); + //System.out.println("veff : " + veff + " dveff : " + dveff + " extra1 : " + extra1 + " extra2 : " + extra2); + } + + //////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // ATOF time walk + for( int i = 0; i < atof_timeWalk.getRowCount(); i++){ + int sector = Integer.parseInt((String)atof_timeWalk.getValueAt(i, 0)); + int layer = Integer.parseInt((String)atof_timeWalk.getValueAt(i, 1)); + int component = Integer.parseInt((String)atof_timeWalk.getValueAt(i, 2)); + int order = Integer.parseInt((String)atof_timeWalk.getValueAt(i, 3)); + double tw0 = atof_timeWalk.getDoubleValue("tw0", sector, layer, component); + double tw1 = atof_timeWalk.getDoubleValue("tw1", sector, layer, component); + double tw2 = atof_timeWalk.getDoubleValue("tw2", sector, layer, component); + double tw3 = atof_timeWalk.getDoubleValue("tw3", sector, layer, component); + double dtw0 = atof_timeWalk.getDoubleValue("dtw0", sector, layer, component); + double dtw1 = atof_timeWalk.getDoubleValue("dtw1", sector, layer, component); + double dtw2 = atof_timeWalk.getDoubleValue("dtw2", sector, layer, component); + double dtw3 = atof_timeWalk.getDoubleValue("dtw3", sector, layer, component); + double chi2ndf = atof_timeWalk.getDoubleValue("chi2ndf", sector, layer, component); + // Put in map + int key = sector*10000 + layer*1000 + component*10 + order; + double params[] = {tw0, tw1, tw2, tw3, dtw0, dtw1, dtw2, dtw3, chi2ndf}; + ATOF_TIME_WALK.put(Integer.valueOf(key), params); + //System.out.println("tw0 : " + tw0 + " tw1 : " + tw1 + " tw2 : " + tw2 + " tw3 : " + tw3 + " ..."); + } + + //////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // ATOF attenuation length + for( int i = 0; i < atof_attenuationLength.getRowCount(); i++){ + int sector = Integer.parseInt((String)atof_attenuationLength.getValueAt(i, 0)); + int layer = Integer.parseInt((String)atof_attenuationLength.getValueAt(i, 1)); + int component = Integer.parseInt((String)atof_attenuationLength.getValueAt(i, 2)); + double attlen = atof_attenuationLength.getDoubleValue("attlen", sector, layer, component); + double dattlen = atof_attenuationLength.getDoubleValue("dattlen", sector, layer, component); + double extra1 = atof_attenuationLength.getDoubleValue("extra1", sector, layer, component); + double extra2 = atof_attenuationLength.getDoubleValue("extra2", sector, layer, component); + // Put in map + int key = sector*10000 + layer*1000 + component*10; + double params[] = {attlen, dattlen, extra1, extra2}; + ATOF_ATTENUATION_LENGTH.put(Integer.valueOf(key), params); + //System.out.println("attlen : " + attlen + " dattlen : " + dattlen + " extra1 : " +extra1 + " extra2 : " + extra2 + " ..."); + } + + //////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // ATOF time offsets + for( int i = 0; i < atof_timeOffsets.getRowCount(); i++){ + int sector = Integer.parseInt((String)atof_timeOffsets.getValueAt(i, 0)); + int layer = Integer.parseInt((String)atof_timeOffsets.getValueAt(i, 1)); + int component = Integer.parseInt((String)atof_timeOffsets.getValueAt(i, 2)); + int order = Integer.parseInt((String)atof_timeOffsets.getValueAt(i, 3)); // we have to use it here ! + double t0 = atof_timeOffsets.getDoubleValue("t0", sector, layer, component); + double upstream_downstream = atof_timeOffsets.getDoubleValue("upstream_downstream", sector, layer, component); + double wedge_bar = atof_timeOffsets.getDoubleValue("wedge_bar", sector, layer, component); + double extra1 = atof_timeOffsets.getDoubleValue("extra1", sector, layer, component); + double extra2 = atof_timeOffsets.getDoubleValue("extra2", sector, layer, component); + // Put in map + int key = sector*10000 + layer*1000 + component*10 + order; + double params[] = {t0, upstream_downstream, wedge_bar, extra1, extra2}; + ATOF_TIME_OFFSETS.put(Integer.valueOf(key), params); + //System.out.println("t0 : " + t0 + " up_down : " + upstream_downstream + " wedge_bar : " + wedge_bar + " ..."); + } + + + CSTLOADED = true; + + } + + + private static DatabaseConstantProvider DB; + + public static final DatabaseConstantProvider getDB() { + return DB; + } + + + public static final void setDB(DatabaseConstantProvider dB) { + DB = dB; + } + + public static void main (String arg[]) { + // CalibrationConstantsLoader.Load(10,"default"); + } +} diff --git a/reconstruction/alert/src/main/java/org/jlab/rec/service/AHDCEngine.java b/reconstruction/alert/src/main/java/org/jlab/rec/service/AHDCEngine.java deleted file mode 100644 index 5dab3df8f9..0000000000 --- a/reconstruction/alert/src/main/java/org/jlab/rec/service/AHDCEngine.java +++ /dev/null @@ -1,241 +0,0 @@ -package org.jlab.service.ahdc; - -import org.jlab.clas.reco.ReconstructionEngine; -import org.jlab.clas.tracking.kalmanfilter.Material; -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.ahdc.AI.*; -import org.jlab.rec.ahdc.Banks.RecoBankWriter; -import org.jlab.rec.ahdc.Cluster.Cluster; -import org.jlab.rec.ahdc.Cluster.ClusterFinder; -import org.jlab.rec.ahdc.Distance.Distance; -import org.jlab.rec.ahdc.HelixFit.HelixFitJava; -import org.jlab.rec.ahdc.Hit.Hit; -import org.jlab.rec.ahdc.Hit.HitReader; -import org.jlab.rec.ahdc.Hit.TrueHit; -import org.jlab.rec.ahdc.HoughTransform.HoughTransform; -import org.jlab.rec.ahdc.KalmanFilter.KalmanFilter; -import org.jlab.rec.ahdc.KalmanFilter.MaterialMap; -import org.jlab.rec.ahdc.PreCluster.PreCluster; -import org.jlab.rec.ahdc.PreCluster.PreClusterFinder; -import org.jlab.rec.ahdc.Track.Track; - -import java.io.File; -import java.util.*; - -public class AHDCEngine extends ReconstructionEngine { - - private boolean simulation; - private boolean use_AI_for_trackfinding; - private String findingMethod; - private HashMap materialMap; - private Model model; - - public AHDCEngine() { - super("ALERT", "ouillon", "1.0.1"); - } - - @Override - public boolean init() { - simulation = false; - findingMethod = "distance"; - use_AI_for_trackfinding = true; - - if (materialMap == null) { - materialMap = MaterialMap.generateMaterials(); - } - - model = new Model(); - - return true; - } - - - @Override - public boolean processDataEvent(DataEvent event) { - - int runNo = 10; - int eventNo = 777; - double magfield = 50.0; - double magfieldfactor = 1; - - if (event.hasBank("RUN::config")) { - DataBank bank = event.getBank("RUN::config"); - runNo = bank.getInt("run", 0); - eventNo = bank.getInt("event", 0); - magfieldfactor = bank.getFloat("solenoid", 0); - if (runNo <= 0) { - System.err.println("RTPCEngine: got run <= 0 in RUN::config, skipping event."); - return false; - } - } - - magfield = 50 * magfieldfactor; - - if (event.hasBank("AHDC::adc")) { - // I) Read raw hit - HitReader hitRead = new HitReader(event, simulation); - - ArrayList AHDC_Hits = hitRead.get_AHDCHits(); - ArrayList TrueAHDC_Hits = hitRead.get_TrueAHDCHits(); - //System.out.println("AHDC_Hits size " + AHDC_Hits.size()); - - // II) Create PreCluster - ArrayList AHDC_PreClusters = new ArrayList<>(); - PreClusterFinder preclusterfinder = new PreClusterFinder(); - preclusterfinder.findPreCluster(AHDC_Hits); - AHDC_PreClusters = preclusterfinder.get_AHDCPreClusters(); - //System.out.println("AHDC_PreClusters size " + AHDC_PreClusters.size()); - - - - // III) Create Cluster - ClusterFinder clusterfinder = new ClusterFinder(); - clusterfinder.findCluster(AHDC_PreClusters); - ArrayList AHDC_Clusters = clusterfinder.get_AHDCClusters(); - //System.out.println("AHDC_Clusters size " + AHDC_Clusters.size()); - - // IV) Track Finder - ArrayList AHDC_Tracks = new ArrayList<>(); - ArrayList predictions = new ArrayList<>(); - - if (use_AI_for_trackfinding == false) { - if (findingMethod.equals("distance")) { - // IV) a) Distance method - //System.out.println("using distance"); - Distance distance = new Distance(); - distance.find_track(AHDC_Clusters); - AHDC_Tracks = distance.get_AHDCTracks(); - } else if (findingMethod.equals("hough")) { - // IV) b) Hough Transform method - //System.out.println("using hough"); - HoughTransform houghtransform = new HoughTransform(); - houghtransform.find_tracks(AHDC_Clusters); - AHDC_Tracks = houghtransform.get_AHDCTracks(); - } - } - else { - // AI --------------------------------------------------------------------------------- - AHDC_Hits.sort(new Comparator() { - @Override - public int compare(Hit a1, Hit a2) { - return Double.compare(a1.getRadius(), a2.getRadius()); - } - }); - PreClustering preClustering = new PreClustering(); - ArrayList preClustersAI = preClustering.find_preclusters_for_AI(AHDC_Hits); - ArrayList preclusterSuperlayers = preClustering.merge_preclusters(preClustersAI); - TrackConstruction trackConstruction = new TrackConstruction(); - ArrayList> tracks = trackConstruction.get_all_possible_track(preclusterSuperlayers); - - - try { - AIPrediction aiPrediction = new AIPrediction(); - predictions = aiPrediction.prediction(tracks, model.getModel()); - } catch (Exception e) { - throw new RuntimeException(e); - } - - for (TrackPrediction t : predictions) { - if (t.getPrediction() > 0.5) - AHDC_Tracks.add(new Track(t.getClusters())); - } - } - // ------------------------------------------------------------------------------------ - - - //Temporary track method ONLY for MC with no background; - //AHDC_Tracks.add(new Track(AHDC_Hits)); - - // V) Global fit - for (Track track : AHDC_Tracks) { - int nbOfPoints = track.get_Clusters().size(); - - double[][] szPos = new double[nbOfPoints][3]; - - int j = 0; - for (Cluster cluster : track.get_Clusters()) { - szPos[j][0] = cluster.get_X(); - szPos[j][1] = cluster.get_Y(); - szPos[j][2] = cluster.get_Z(); - j++; - } - - HelixFitJava h = new HelixFitJava(); - track.setPositionAndMomentum(h.HelixFit(nbOfPoints, szPos, 1)); - } - - // VI) Kalman Filter - // System.out.println("AHDC_Tracks = " + AHDC_Tracks); - KalmanFilter kalmanFitter = new KalmanFilter(AHDC_Tracks, event); - - // VII) Write bank - RecoBankWriter writer = new RecoBankWriter(); - - DataBank recoHitsBank = writer.fillAHDCHitsBank(event, AHDC_Hits); - DataBank recoPreClusterBank = writer.fillPreClustersBank(event, AHDC_PreClusters); - DataBank recoClusterBank = writer.fillClustersBank(event, AHDC_Clusters); - DataBank recoTracksBank = writer.fillAHDCTrackBank(event, AHDC_Tracks); - DataBank recoKFTracksBank = writer.fillAHDCKFTrackBank(event, AHDC_Tracks); - DataBank AIPredictionBanks = writer.fillAIPrediction(event, predictions); - - event.appendBank(recoHitsBank); - event.appendBank(recoPreClusterBank); - event.appendBank(recoClusterBank); - event.appendBank(recoTracksBank); - event.appendBank(recoKFTracksBank); - event.appendBank(AIPredictionBanks); - - if (simulation) { - DataBank recoMCBank = writer.fillAHDCMCTrackBank(event); - event.appendBank(recoMCBank); - } - - } - return true; - } - - public static void main(String[] args) { - - double starttime = System.nanoTime(); - - int nEvent = 0; - int maxEvent = 1000; - int myEvent = 3; - String inputFile = "alert_out_update.hipo"; - String outputFile = "output.hipo"; - - if (new File(outputFile).delete()) System.out.println("output.hipo is delete."); - - System.err.println(" \n[PROCESSING FILE] : " + inputFile); - - AHDCEngine en = new AHDCEngine(); - - HipoDataSource reader = new HipoDataSource(); - HipoDataSync writer = new HipoDataSync(); - - en.init(); - - reader.open(inputFile); - writer.open(outputFile); - - while (reader.hasEvent() && nEvent < maxEvent) { - nEvent++; - // if (nEvent % 100 == 0) System.out.println("nEvent = " + nEvent); - DataEvent event = reader.getNextEvent(); - - // if (nEvent != myEvent) continue; - // System.out.println("*********** NEXT EVENT ************"); - // event.show(); - - en.processDataEvent(event); - writer.writeEvent(event); - - } - writer.close(); - - System.out.println("finished " + (System.nanoTime() - starttime) * Math.pow(10, -9)); - } -} diff --git a/reconstruction/alert/src/main/java/org/jlab/service/ahdc/AHDCEngine.java b/reconstruction/alert/src/main/java/org/jlab/service/ahdc/AHDCEngine.java new file mode 100644 index 0000000000..e0c8d340b8 --- /dev/null +++ b/reconstruction/alert/src/main/java/org/jlab/service/ahdc/AHDCEngine.java @@ -0,0 +1,330 @@ +package org.jlab.service.ahdc; + +import org.jlab.clas.reco.ReconstructionEngine; +import org.jlab.clas.tracking.kalmanfilter.Material; +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.ahdc.AI.*; +import org.jlab.rec.ahdc.Banks.RecoBankWriter; +import org.jlab.rec.ahdc.Cluster.Cluster; +import org.jlab.rec.ahdc.Cluster.ClusterFinder; +import org.jlab.rec.ahdc.Distance.Distance; +import org.jlab.rec.ahdc.HelixFit.HelixFitJava; +import org.jlab.rec.ahdc.Hit.Hit; +import org.jlab.rec.ahdc.Hit.HitReader; +import org.jlab.rec.ahdc.Hit.TrueHit; +import org.jlab.rec.ahdc.HoughTransform.HoughTransform; +import org.jlab.rec.ahdc.KalmanFilter.KalmanFilter; +import org.jlab.rec.ahdc.KalmanFilter.MaterialMap; +import org.jlab.rec.ahdc.PreCluster.PreCluster; +import org.jlab.rec.ahdc.PreCluster.PreClusterFinder; +import org.jlab.rec.ahdc.Track.Track; +import org.jlab.rec.ahdc.Mode; +import java.io.File; +import java.util.*; +import org.jlab.detector.calib.utils.DatabaseConstantProvider; +import org.jlab.geom.detector.alert.AHDC.AlertDCDetector; +import org.jlab.geom.detector.alert.AHDC.AlertDCFactory; +import org.jlab.rec.constants.CalibrationConstantsLoader; +import org.jlab.detector.pulse.ModeAHDC; + +/** AHDCEngine reconstruction service. + * + * AHDC Reconstruction using only AHDC information. + * + * Reconstruction utilizing other detectors (i.e. ATOF) are + * implemented in ALERTEngine. + * + */ +public class AHDCEngine extends ReconstructionEngine { + + private boolean simulation; + + /** + * String name for track seedsfinding method. + * Options are: + * - "distance" + * - "hough" + * + * \todo remove bool use_AI_for_trackfinding and use option string above. + */ + private String findingMethod; + + /// Material Map used by Kalman filter + private HashMap materialMap; + + /// \todo better name... Model of what? + private Model model; + + /// \todo better name... mode for what? + private Mode mode = Mode.CV_Track_Finding; + + private AlertDCDetector factory = null; + private ModeAHDC ahdcExtractor = new ModeAHDC(); + + public AHDCEngine() { + super("ALERT", "ouillon", "1.0.1"); + } + + @Override + public boolean init() { + + factory = (new AlertDCFactory()).createDetectorCLAS(new DatabaseConstantProvider()); + + simulation = false; + findingMethod = "distance"; + + if (materialMap == null) { + materialMap = MaterialMap.generateMaterials(); + } + + if(this.getEngineConfigString("Mode")!=null) { + if (Objects.equals(this.getEngineConfigString("Mode"), Mode.AI_Track_Finding.name())) + mode = Mode.AI_Track_Finding; + + if (Objects.equals(this.getEngineConfigString("Mode"), Mode.CV_Track_Finding.name())) + mode = Mode.CV_Track_Finding; + } + + if (mode == Mode.AI_Track_Finding) { + model = new Model(); + } + + // Requires calibration constants + String[] alertTables = new String[] { + "/calibration/alert/ahdc/time_offsets", + "/calibration/alert/ahdc/time_to_distance", + "/calibration/alert/ahdc/raw_hit_cuts", + "/calibration/alert/atof/effective_velocity", + "/calibration/alert/atof/time_walk", + "/calibration/alert/atof/attenuation", + "/calibration/alert/atof/time_offsets" + }; + requireConstants(Arrays.asList(alertTables)); + + this.getConstantsManager().setVariation("default"); + + this.registerOutputBank("AHDC::hits","AHDC::preclusters","AHDC::clusters","AHDC::track","AHDC::kftrack","AHDC::mc","AHDC::ai:prediction"); + + return true; + } + + int Run = -1; + + @Override + public boolean processDataEvent(DataEvent event) { + + int runNo = 10; // needed here? + int eventNo = 777; // same + + double magfield = 50.0; // what is this? + double magfieldfactor = 1; // why is this here? + + if(event.hasBank("MC::Particle")){ + simulation = true; + } + + // TODO: this code should perhaps be in the if statement MC::Particle + ahdcExtractor.update(30, null, event, "AHDC::wf", "AHDC::adc"); + + if (event.hasBank("RUN::config")) { + DataBank bank = event.getBank("RUN::config"); + runNo = bank.getInt("run", 0); + eventNo = bank.getInt("event", 0); + magfieldfactor = bank.getFloat("solenoid", 0); + if (runNo <= 0) { + System.err.println("AHDCEngine: got run <= 0 in RUN::config, skipping event."); + return false; + } + int newRun = Run; + newRun = runNo; + // Load the constants + //------------------- + if(Run!=newRun) { + CalibrationConstantsLoader.Load(newRun, this.getConstantsManager()); + Run = newRun; + } + } + + /// What is this? + magfield = 50 * magfieldfactor; + + if (event.hasBank("AHDC::adc")) { + // I) Read raw hit + HitReader hitRead = new HitReader(event, factory, simulation); + + ArrayList AHDC_Hits = hitRead.get_AHDCHits(); + if(simulation){ + ArrayList TrueAHDC_Hits = hitRead.get_TrueAHDCHits(); + } + //System.out.println("AHDC_Hits size " + AHDC_Hits.size()); + + // II) Create PreCluster + ArrayList AHDC_PreClusters = new ArrayList<>(); + PreClusterFinder preclusterfinder = new PreClusterFinder(); + preclusterfinder.findPreCluster(AHDC_Hits); + AHDC_PreClusters = preclusterfinder.get_AHDCPreClusters(); + //System.out.println("AHDC_PreClusters size " + AHDC_PreClusters.size()); + + // III) Create Cluster + ClusterFinder clusterfinder = new ClusterFinder(); + clusterfinder.findCluster(AHDC_PreClusters); + ArrayList AHDC_Clusters = clusterfinder.get_AHDCClusters(); + //System.out.println("AHDC_Clusters size " + AHDC_Clusters.size()); + + // IV) Track Finder + ArrayList AHDC_Tracks = new ArrayList<>(); + ArrayList predictions = new ArrayList<>(); + + // If there is too much hits, we rely on to the conventional track finding + if (AHDC_Hits.size() > 300) mode = Mode.CV_Track_Finding; + + if (mode == Mode.CV_Track_Finding) { + if (findingMethod.equals("distance")) { + // IV) a) Distance method + //System.out.println("using distance"); + Distance distance = new Distance(); + distance.find_track(AHDC_Clusters); + AHDC_Tracks = distance.get_AHDCTracks(); + } else if (findingMethod.equals("hough")) { + // IV) b) Hough Transform method + //System.out.println("using hough"); + HoughTransform houghtransform = new HoughTransform(); + houghtransform.find_tracks(AHDC_Clusters); + AHDC_Tracks = houghtransform.get_AHDCTracks(); + } + } + if (mode == Mode.AI_Track_Finding) { + // AI --------------------------------------------------------------------------------- + AHDC_Hits.sort(new Comparator() { + @Override + public int compare(Hit a1, Hit a2) { + return Double.compare(a1.getRadius(), a2.getRadius()); + } + }); + PreClustering preClustering = new PreClustering(); + ArrayList preClustersAI = preClustering.find_preclusters_for_AI(AHDC_Hits); + ArrayList preclusterSuperlayers = preClustering.merge_preclusters(preClustersAI); + TrackConstruction trackConstruction = new TrackConstruction(); + ArrayList> tracks = new ArrayList<>(); + boolean sucess = trackConstruction.get_all_possible_track(preclusterSuperlayers, tracks); + + if (!sucess) { + System.err.println("Too much tracks candidates, exit"); + return false; + } + + try { + AIPrediction aiPrediction = new AIPrediction(); + predictions = aiPrediction.prediction(tracks, model.getModel()); + } catch (Exception e) { + throw new RuntimeException(e); + } + + for (TrackPrediction t : predictions) { + if (t.getPrediction() > 0.2) + AHDC_Tracks.add(new Track(t.getClusters())); + } + } + // ------------------------------------------------------------------------------------ + + + //Temporary track method ONLY for MC with no background; + //AHDC_Tracks.add(new Track(AHDC_Hits)); + + // V) Global fit + for (Track track : AHDC_Tracks) { + int nbOfPoints = track.get_Clusters().size(); + + double[][] szPos = new double[nbOfPoints][3]; + + int j = 0; + for (Cluster cluster : track.get_Clusters()) { + szPos[j][0] = cluster.get_X(); + szPos[j][1] = cluster.get_Y(); + szPos[j][2] = cluster.get_Z(); + j++; + } + + HelixFitJava h = new HelixFitJava(); + track.setPositionAndMomentum(h.HelixFit(nbOfPoints, szPos, 1)); + // double p = 150.0;//MeV/c + // double phi = Math.atan2(szPos[0][1], szPos[0][0]); + // double x_0[] = {0.0, 0.0, 0.0, p*Math.sin(phi), + // p*Math.cos(phi), 0.0}; track.setPositionAndMomentumVec(x_0); + } + + // VI) Kalman Filter + // System.out.println("AHDC_Tracks = " + AHDC_Tracks); + KalmanFilter kalmanFitter = new KalmanFilter(AHDC_Tracks, event, simulation); + // VII) Write bank + RecoBankWriter writer = new RecoBankWriter(); + + DataBank recoHitsBank = writer.fillAHDCHitsBank(event, AHDC_Hits); + DataBank recoPreClusterBank = writer.fillPreClustersBank(event, AHDC_PreClusters); + DataBank recoClusterBank = writer.fillClustersBank(event, AHDC_Clusters); + DataBank recoTracksBank = writer.fillAHDCTrackBank(event, AHDC_Tracks); + DataBank recoKFTracksBank = writer.fillAHDCKFTrackBank(event, AHDC_Tracks); + DataBank AIPredictionBanks = writer.fillAIPrediction(event, predictions); + + event.appendBank(recoHitsBank); + event.appendBank(recoPreClusterBank); + event.appendBank(recoClusterBank); + event.appendBank(recoTracksBank); + event.appendBank(recoKFTracksBank); + event.appendBank(AIPredictionBanks); + + if (simulation) { + DataBank recoMCBank = writer.fillAHDCMCTrackBank(event); + event.appendBank(recoMCBank); + } + + + } + return true; + } + + public static void main(String[] args) { + + double starttime = System.nanoTime(); + + int nEvent = 0; + int maxEvent = 10; + int myEvent = 3; + String inputFile = "merged_10.hipo"; + String outputFile = "output.hipo"; + + if (new File(outputFile).delete()) System.out.println("output.hipo is delete."); + + System.err.println(" \n[PROCESSING FILE] : " + inputFile); + + AHDCEngine en = new AHDCEngine(); + + HipoDataSource reader = new HipoDataSource(); + HipoDataSync writer = new HipoDataSync(); + + en.init(); + + reader.open(inputFile); + writer.open(outputFile); + + while (reader.hasEvent() && nEvent < maxEvent) { + nEvent++; + // if (nEvent % 100 == 0) System.out.println("nEvent = " + nEvent); + DataEvent event = reader.getNextEvent(); + + // if (nEvent != myEvent) continue; + // System.out.println("*********** NEXT EVENT ************"); + // event.show(); + + en.processDataEvent(event); + writer.writeEvent(event); + + } + writer.close(); + + System.out.println("finished " + (System.nanoTime() - starttime) * Math.pow(10, -9)); + } +} diff --git a/reconstruction/alert/src/main/java/org/jlab/service/alert/ALERTEngine.java b/reconstruction/alert/src/main/java/org/jlab/service/alert/ALERTEngine.java new file mode 100644 index 0000000000..b6e6851ec8 --- /dev/null +++ b/reconstruction/alert/src/main/java/org/jlab/service/alert/ALERTEngine.java @@ -0,0 +1,177 @@ +package org.jlab.service.alert; + +import java.util.ArrayList; +import java.util.concurrent.atomic.AtomicInteger; +import java.io.File; +import java.util.*; + +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.clas.reco.ReconstructionEngine; +import org.jlab.clas.tracking.kalmanfilter.Material; +import org.jlab.clas.swimtools.Swim; + +import org.jlab.rec.alert.banks.RecoBankWriter; +import org.jlab.rec.alert.projections.TrackProjector; + + +/** + *

ALERTEngine reconstruction service.

+ * + * @author Whit Armstrong + * @author Noemie Pilleux + * @since 2025-04-03 + */ +public class ALERTEngine extends ReconstructionEngine { + + /** + * ALERT Engine output bank writer. + * + * @see RecoBankWriter + * + *

Output banks

+ *
    + *
  • Track Projection @see TrackProjector
  • + *
+ * + */ + private RecoBankWriter rbc; + + /** + * Current run number being processed. + * TODO: why atomic here and nowhere else? + */ + private final AtomicInteger run = new AtomicInteger(0); + + private double b; //Magnetic field + + public void setB(double B) { + this.b = B; + } + public double getB() { + return b; + } + + /** + * ALERTEngine service c'tor. + */ + public ALERTEngine() { + super("ALERT", "whit,ouillon,pilleux", "0.1"); + } + + /** + * ALERTEngine initialization. + * Creates the RecoBankWriter and checks for various yaml flags. + * TODO: document flags + */ + @Override + public boolean init() { + + rbc = new RecoBankWriter(); + + + if(this.getEngineConfigString("Mode")!=null) { + //if (Objects.equals(this.getEngineConfigString("Mode"), Mode.AI_Track_Finding.name())) + // mode = Mode.AI_Track_Finding; + } + return true; + } + + /** + * Process Event. + * Main method called to process event data. + * + *
    + *
  • Check for AHDC and ATOF banks
  • + *
  • Project track to ATOF
  • + *
+ */ + @Override + public boolean processDataEvent(DataEvent event) { + + if (!event.hasBank("AHDC::adc")) + return false; + if (!event.hasBank("ATOF::tdc")) + return false; + + if (!event.hasBank("RUN::config")) { + return true; + } + + DataBank bank = event.getBank("RUN::config"); + + int newRun = bank.getInt("run", 0); + if (newRun == 0) { + return true; + } + + if (run.get() == 0 || (run.get() != 0 && run.get() != newRun)) { + run.set(newRun); + } + + //Do we need to read the event vx,vy,vz? + //If not, this part can be moved in the initialization of the engine. + double eventVx=0,eventVy=0,eventVz=0; //They should be in CM + //Track Projector Initialisation with b field + Swim swim = new Swim(); + float magField[] = new float[3]; + swim.BfieldLab(eventVx, eventVy, eventVz, magField); + this.b = Math.sqrt(Math.pow(magField[0],2) + Math.pow(magField[1],2) + Math.pow(magField[2],2)); + + TrackProjector projector = new TrackProjector(); + projector.setB(this.b); + projector.projectTracks(event); + rbc.appendMatchBanks(event, projector.getProjections()); + + return true; + } + + /** + * ALERTEngine main. + * TODO: needs good test. + */ + public static void main(String[] args) { + + double starttime = System.nanoTime(); + + int nEvent = 0; + int maxEvent = 1000; + int myEvent = 3; + String inputFile = "alert_out_update.hipo"; + String outputFile = "output.hipo"; + + if (new File(outputFile).delete()) System.out.println("output.hipo is delete."); + + System.err.println(" \n[PROCESSING FILE] : " + inputFile); + + ALERTEngine en = new ALERTEngine(); + + HipoDataSource reader = new HipoDataSource(); + HipoDataSync writer = new HipoDataSync(); + + en.init(); + + reader.open(inputFile); + writer.open(outputFile); + + while (reader.hasEvent() && nEvent < maxEvent) { + nEvent++; + // if (nEvent % 100 == 0) System.out.println("nEvent = " + nEvent); + DataEvent event = reader.getNextEvent(); + + // if (nEvent != myEvent) continue; + // System.out.println("*********** NEXT EVENT ************"); + // event.show(); + + en.processDataEvent(event); + writer.writeEvent(event); + + } + writer.close(); + + System.out.println("finished " + (System.nanoTime() - starttime) * Math.pow(10, -9)); + } +} diff --git a/reconstruction/alert/src/main/java/org/jlab/rec/service/ATOFEngine.java b/reconstruction/alert/src/main/java/org/jlab/service/atof/ATOFEngine.java similarity index 77% rename from reconstruction/alert/src/main/java/org/jlab/rec/service/ATOFEngine.java rename to reconstruction/alert/src/main/java/org/jlab/service/atof/ATOFEngine.java index 19f27e5aa8..c409355a04 100644 --- a/reconstruction/alert/src/main/java/org/jlab/rec/service/ATOFEngine.java +++ b/reconstruction/alert/src/main/java/org/jlab/service/atof/ATOFEngine.java @@ -18,7 +18,7 @@ import org.jlab.rec.atof.hit.ATOFHit; import org.jlab.rec.atof.hit.BarHit; import org.jlab.rec.atof.hit.HitFinder; -import org.jlab.rec.alert.projections.TrackProjector; +//import org.jlab.rec.alert.projections.TrackProjector; /** * Service to return reconstructed ATOF hits and clusters @@ -69,18 +69,22 @@ public boolean processDataEvent(DataEvent event) { run.set(newRun); } - //Do we need to read the event vx,vy,vz? - //If not, this part can be moved in the initialization of the engine. - double eventVx=0,eventVy=0,eventVz=0; //They should be in CM - //Track Projector Initialisation with b field - Swim swim = new Swim(); - float magField[] = new float[3]; - swim.BfieldLab(eventVx, eventVy, eventVz, magField); - this.b = Math.sqrt(Math.pow(magField[0],2) + Math.pow(magField[1],2) + Math.pow(magField[2],2)); - TrackProjector projector = new TrackProjector(); - projector.setB(this.b); - projector.projectTracks(event); - rbc.appendMatchBanks(event, projector.getProjections()); + ////Do we need to read the event vx,vy,vz? + ////If not, this part can be moved in the initialization of the engine. + //double eventVx=0,eventVy=0,eventVz=0; //They should be in CM + ////Track Projector Initialisation with b field + //Swim swim = new Swim(); + //float magField[] = new float[3]; + //swim.BfieldLab(eventVx, eventVy, eventVz, magField); + //this.b = Math.sqrt(Math.pow(magField[0],2) + Math.pow(magField[1],2) + Math.pow(magField[2],2)); + + ///// \todo move this to ALERTEngine + //TrackProjector projector = new TrackProjector(); + //projector.setB(this.b); + //projector.projectTracks(event); + //rbc.appendMatchBanks(event, projector.getProjections()); + + // Why do we have to "find" hits? //Hit finder init HitFinder hitfinder = new HitFinder(); hitfinder.findHits(event, ATOF); diff --git a/reconstruction/alert/src/test/java/org/jlab/service/alert/AHDCTest.java b/reconstruction/alert/src/test/java/org/jlab/service/alert/AHDCTest.java new file mode 100644 index 0000000000..3fa950672f --- /dev/null +++ b/reconstruction/alert/src/test/java/org/jlab/service/alert/AHDCTest.java @@ -0,0 +1,49 @@ +package org.jlab.service.alert; + +import org.junit.Test; +import static org.junit.Assert.assertEquals; + +import org.jlab.io.base.DataEvent; +import org.jlab.detector.base.DetectorType; +import org.jlab.jnp.hipo4.data.SchemaFactory; +import org.jlab.logging.DefaultLogger; +import org.jlab.utils.system.ClasUtilsFile; +import org.jlab.analysis.physics.TestEvent; +import org.jlab.service.ahdc.AHDCEngine; + +/** + * + * @author baltzell + * @author ftouchte + */ +public class AHDCTest { + + @Test + public void run() { + System.setProperty("CLAS12DIR", "../../"); + DefaultLogger.debug(); + String dir = ClasUtilsFile.getResourceDir("CLAS12DIR", "etc/bankdefs/hipo4"); + SchemaFactory schemaFactory = new SchemaFactory(); + schemaFactory.initFromDirectory(dir); + + DataEvent event = TestEvent.get(DetectorType.AHDC); + + AHDCEngine engine = new AHDCEngine(); + engine.init(); + engine.processDataEvent(event); + + event.show(); + event.getBank("AHDC::hits").show(); + event.getBank("AHDC::clusters").show(); + + assertEquals(event.hasBank("FAKE::Bank"), false); + assertEquals(event.hasBank("AHDC::wf"), true); + assertEquals(event.getBank("AHDC::hits").rows(), 25); + } + + public static void main(String[] args) { + AHDCTest t = new AHDCTest(); + t.run(); + } + +} diff --git a/reconstruction/alert/src/test/java/org/jlab/service/alert/ATOFTest.java b/reconstruction/alert/src/test/java/org/jlab/service/alert/ATOFTest.java new file mode 100644 index 0000000000..55b621bb19 --- /dev/null +++ b/reconstruction/alert/src/test/java/org/jlab/service/alert/ATOFTest.java @@ -0,0 +1,46 @@ +package org.jlab.service.alert; + +import org.junit.Test; +import static org.junit.Assert.assertEquals; + +import org.jlab.io.base.DataEvent; +import org.jlab.detector.base.DetectorType; +import org.jlab.jnp.hipo4.data.SchemaFactory; +import org.jlab.logging.DefaultLogger; +import org.jlab.utils.system.ClasUtilsFile; +import org.jlab.analysis.physics.TestEvent; +import org.jlab.service.atof.ATOFEngine; + +/** + * @N-Plx + */ +public class ATOFTest { + + @Test + public void run() { + System.setProperty("CLAS12DIR", "../../"); + DefaultLogger.debug(); + String dir = ClasUtilsFile.getResourceDir("CLAS12DIR", "etc/bankdefs/hipo4"); + SchemaFactory schemaFactory = new SchemaFactory(); + schemaFactory.initFromDirectory(dir); + + DataEvent event = TestEvent.get(DetectorType.ATOF); + + ATOFEngine engine = new ATOFEngine(); + engine.init(); + engine.processDataEvent(event); + + event.show(); + event.getBank("ATOF::hits").show(); + event.getBank("ATOF::clusters").show(); + + assertEquals(event.hasBank("FAKE::Bank"), false); + assertEquals(event.hasBank("ATOF::tdc"), true); + assertEquals(event.getBank("ATOF::hits").rows(), 8); + } + + public static void main(String[] args) { + ATOFTest t = new ATOFTest(); + t.run(); + } +} diff --git a/reconstruction/band/pom.xml b/reconstruction/band/pom.xml index 6d8fe0fb4f..01da9e29d3 100644 --- a/reconstruction/band/pom.xml +++ b/reconstruction/band/pom.xml @@ -13,14 +13,14 @@ org.jlab.clas clas12rec ../../parent/pom.xml - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT org.jlab.clas clas-reco - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT diff --git a/reconstruction/bg/pom.xml b/reconstruction/bg/pom.xml index 195842c21e..4a4962f80c 100644 --- a/reconstruction/bg/pom.xml +++ b/reconstruction/bg/pom.xml @@ -13,7 +13,7 @@ org.jlab.clas clas12rec ../../parent/pom.xml - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT @@ -21,19 +21,19 @@ org.jlab.clas clas-io - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT org.jlab.clas clas-reco - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT org.jlab.clas clas-analysis - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT diff --git a/reconstruction/cnd/pom.xml b/reconstruction/cnd/pom.xml index 0e5c074050..9bacf780e8 100644 --- a/reconstruction/cnd/pom.xml +++ b/reconstruction/cnd/pom.xml @@ -13,7 +13,7 @@ org.jlab.clas clas12rec ../../parent/pom.xml - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT diff --git a/reconstruction/cvt/pom.xml b/reconstruction/cvt/pom.xml index 9c8d67d3d5..dfc710a64e 100644 --- a/reconstruction/cvt/pom.xml +++ b/reconstruction/cvt/pom.xml @@ -13,7 +13,7 @@ org.jlab.clas clas12rec ../../parent/pom.xml - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT @@ -21,7 +21,7 @@ org.jlab.clas clas-jcsg - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT @@ -47,7 +47,7 @@ org.jlab.clas clas-tracking - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT diff --git a/reconstruction/dc/pom.xml b/reconstruction/dc/pom.xml index 9f352b167e..6d3abd820d 100644 --- a/reconstruction/dc/pom.xml +++ b/reconstruction/dc/pom.xml @@ -14,7 +14,7 @@ org.jlab.clas clas12rec ../../parent/pom.xml - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT @@ -28,25 +28,25 @@ org.jlab.clas clas-tracking - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT org.jlab.clas clas-jcsg - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT org.jlab.clas clas-reco - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT org.jlab.clas clas-analysis - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT @@ -75,13 +75,13 @@ org.jlab.clas swim-tools - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT org.jlab.clas clas-math - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT 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 faa907a8cf..02162955c5 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 @@ -205,65 +205,24 @@ private int getJitter(int sector, int layer, int wire, int order) { } return jitter; } - - public void fetch_DCHits(DataEvent event, Clas12NoiseAnalysis noiseAnalysis, - NoiseReductionParameters parameters, - Clas12NoiseResult results) { - this.initialize(event); - this.fetch_DCHits(noiseAnalysis, parameters, results); - } - + /** * reads the hits using clas-io methods to get the EvioBank for the DC and * fill the values to instantiate the DChit and MChit classes.This methods * fills the DChit list of hits. - * - * @param noiseAnalysis - * @param parameters - * @param results */ - private void fetch_DCHits(Clas12NoiseAnalysis noiseAnalysis, - NoiseReductionParameters parameters, - Clas12NoiseResult results) { - - _DCHits = new ArrayList<>(); - - IndexedList noise = new IndexedList<>(4); + public void fetch_DCHits(DataEvent event) { + this.initialize(event); - RawDataBank bankDGTZ = new RawDataBank(bankNames.getTdcBank(), OrderGroups.NODENOISE); - bankDGTZ.read(event); - - // event selection, including cut on max number of hits - if( run <= 0 || - tiTimeStamp < 0 || - bankDGTZ.rows()==0 || bankDGTZ.rows()>Constants.MAXHITS ) { - return; - } - else { - int rows = bankDGTZ.rows(); - int[] sector = new int[rows]; - int[] layer = new int[rows]; - int[] superlayer = new int[rows]; - int[] wire = new int[rows]; - for (int i = 0; i < rows; i++) { - sector[i] = bankDGTZ.getByte("sector", i); - layer[i] = (bankDGTZ.getByte("layer", i)-1)%6 + 1; - superlayer[i] = (bankDGTZ.getByte("layer", i)-1)/6 + 1; - wire[i] = bankDGTZ.getShort("component", i); - } - results.clear(); - noiseAnalysis.clear(); - noiseAnalysis.findNoise(sector, superlayer, layer, wire, results); - for(int i=0; i(); this.getDCRBJitters(Constants.getInstance().isSWAPDCRBBITS()); RawDataBank bankFiltered = new RawDataBank(bankNames.getTdcBank(), rawBankOrders); bankFiltered.read(event); + + if(run <= 0 || tiTimeStamp < 0 || bankFiltered.rows() > Constants.MAXHITS) return; + this.set_NumTDCBankRows(bankFiltered.rows()); for (int i = 0; i < bankFiltered.rows(); i++) { int sector = bankFiltered.getByte("sector", i); @@ -279,12 +238,7 @@ private void fetch_DCHits(Clas12NoiseAnalysis noiseAnalysis, if (wirestat != null) { if (wirestat.getIntValue("status", sector, layer+(superlayer-1)*6, wire) != 0) passHit = false; - } - - if(noise.hasItem(sector, superlayer, layer, wire)) { - if(noise.getItem(sector, superlayer, layer, wire)) - passHit = false; - } + } if (passHit && wire != -1 && !(superlayer == 0)) { 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 b2b37c20f1..6ab72f997e 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 @@ -188,34 +188,20 @@ public List ClusterSplitter(FittedCluster clus, int nextClsStartI } } } - //no gaps - List contigArrayOfHits = new ArrayList<>(); //contiguous cluster - - boolean passCluster = true; - for (int l = 1; l <= Constants.NLAYR; l++) { - for (int i = 0; i < newClus.size(); i++) { - if (newClus.get(i).get_Layer() == l) { - contigArrayOfHits.add(newClus.get(i)); - } - } - } - for (int i = 0; i < contigArrayOfHits.size() - 1; i++) { //if there is a gap do not include in list - if (contigArrayOfHits.get(i + 1).get_Layer() - contigArrayOfHits.get(i).get_Layer() > 1) { - passCluster = false; + + //Limits for cluster candiates + boolean passCluster = false; + int nLayers = count_nlayers_in_cluster(newClus); + if((!isExceptionalCluster(newClus) && nLayers >= Constants.DC_MIN_NLAYERS) + || (isExceptionalCluster(newClus) && nLayers >= Constants.DC_MIN_NLAYERS - 1)) { + //require consistency with line + cf.SetFitArray(newClus, "LC"); + cf.Fit(newClus, true); + if ((nLayers == 6 && newClus.get_fitProb() > 0.9) || (nLayers == 5 && newClus.get_fitProb() > 0.85) + || (nLayers == 4 && newClus.get_fitProb() > 0.75) || (nLayers == 3 && newClus.get_fitProb() > 0.65)) { + passCluster = true; } } - //require 4 layers to make a cluster - if ((!isExceptionalCluster(contigArrayOfHits) && count_nlayers_in_cluster(contigArrayOfHits) < Constants.DC_MIN_NLAYERS) - || (isExceptionalCluster(contigArrayOfHits) && count_nlayers_in_cluster(contigArrayOfHits) < Constants.DC_MIN_NLAYERS - 1)) { - passCluster = false; - } - - //require consistency with line - cf.SetFitArray(newClus, "LC"); - cf.Fit(newClus, true); - if (newClus.get_fitProb() < 0.9) { - passCluster = false; - } if (!(splitclusters.contains(newClus)) && passCluster) { splitclusters.add(newClus); @@ -314,7 +300,7 @@ public int count_nlayers_hit(Hit[] hits_inlayer) { * @param hitsInClus the hits in a cluster * @return the number of layers in a cluster */ - int count_nlayers_in_cluster(List hitsInClus) { + int count_nlayers_in_cluster(List hitsInClus) { // count hits in each layer int nlayr = 6; int[] nlayers = new int[nlayr]; 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 d9b8eb2ab8..a2d1b735fe 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 @@ -236,7 +236,8 @@ public List FindHitBasedClusters(List allhits, ClusterCleane int idSharedHits = numTDCBankRows + 10000; for (FittedCluster clus : fittedClusList) { if (clus != null && ((!ct.isExceptionalFittedCluster(clus) && clus.size() >= Constants.DC_MIN_NLAYERS) || - (ct.isExceptionalFittedCluster(clus) && clus.size() >= Constants.DC_MIN_NLAYERS-1)) && clus.get_fitProb()>Constants.HITBASEDTRKGMINFITHI2PROB) { + (ct.isExceptionalFittedCluster(clus) && clus.size() >= Constants.DC_MIN_NLAYERS-1)) + && ((ct.count_nlayers_in_cluster(clus) < Constants.DC_MIN_NLAYERS && clus.get_fitProb() > 0.4) || (ct.count_nlayers_in_cluster(clus) >= Constants.DC_MIN_NLAYERS && clus.get_fitProb()>Constants.HITBASEDTRKGMINFITHI2PROB))) { // update the hits for (FittedHit fhit : clus) { 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 5105388bc9..d9c8d75825 100644 --- 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 @@ -66,6 +66,8 @@ public void setFinalStateVec(StateVec finalStateVec) { private Segment _singleSuperlayer ; private int _fitConvergenceStatus; private StateVec finalStateVec ; + + private boolean isAITrack = false; public Track() { } @@ -98,6 +100,14 @@ public Segment getSingleSuperlayer() { public void setSingleSuperlayer(Segment _singleSuperlayer) { this._singleSuperlayer = _singleSuperlayer; } + + public void setIsAITrack(boolean isAITrack){ + this.isAITrack = isAITrack; + } + + public boolean getIsAITrack(){ + return isAITrack; + } public int getBitStatus() { int status = 0; @@ -119,6 +129,9 @@ public int getBitStatus() { for(int isl = 0; isl <6; isl++) { status |= segmentStatus[isl] << isl*2; } + + status |= (this.isAITrack ? 1 : 0) << 12; // The 13th bit tells if track is from AI-assisted trcking; 1: yes; 0: no + return status; } diff --git a/reconstruction/dc/src/main/java/org/jlab/service/dc/DCHBClustering.java b/reconstruction/dc/src/main/java/org/jlab/service/dc/DCHBClustering.java index 978ae61e2f..f6d0e5f7ab 100644 --- a/reconstruction/dc/src/main/java/org/jlab/service/dc/DCHBClustering.java +++ b/reconstruction/dc/src/main/java/org/jlab/service/dc/DCHBClustering.java @@ -1,9 +1,5 @@ package org.jlab.service.dc; -import cnuphys.snr.NoiseReductionParameters; -import cnuphys.snr.clas12.Clas12NoiseAnalysis; -import cnuphys.snr.clas12.Clas12NoiseResult; - import java.util.List; import org.jlab.clas.swimtools.Swim; import org.jlab.io.base.DataEvent; @@ -45,27 +41,16 @@ public boolean processDataEvent(DataEvent event) { // get Field Swim dcSwim = new Swim(); /* 2 */ - // init SNR - Clas12NoiseResult results = new Clas12NoiseResult(); + ClusterFitter cf = new ClusterFitter(); /* 3 */ - Clas12NoiseAnalysis noiseAnalysis = new Clas12NoiseAnalysis(); + ClusterCleanerUtilities ct = new ClusterCleanerUtilities(); /* 4 */ - NoiseReductionParameters parameters = - new NoiseReductionParameters( - 2, - Constants.SNR_LEFTSHIFTS, - Constants.SNR_RIGHTSHIFTS); + RecoBankWriter rbc = new RecoBankWriter(this.getBanks()); /* 5 */ - ClusterFitter cf = new ClusterFitter(); + HitReader hitRead = new HitReader(this.getBanks(), this.getRawBankOrders(), super.getConstantsManager(), Constants.getInstance().dcDetector); /* 6 */ - ClusterCleanerUtilities ct = new ClusterCleanerUtilities(); + hitRead.fetch_DCHits(event); /* 7 */ - RecoBankWriter rbc = new RecoBankWriter(this.getBanks()); - /* 8 */ - HitReader hitRead = new HitReader(this.getBanks(), this.getRawBankOrders(), super.getConstantsManager(), Constants.getInstance().dcDetector); - /* 9 */ - hitRead.fetch_DCHits(event, noiseAnalysis, parameters, results); - /* 10 */ //I) get the hits List hits = hitRead.get_DCHits(Constants.getInstance().SECTORSELECT); //II) process the hits @@ -73,7 +58,7 @@ public boolean processDataEvent(DataEvent event) { if (hits.isEmpty()) { return true; } - /* 11 */ + /* 8 */ //2) find the clusters from these hits ClusterFinder clusFinder = new ClusterFinder(); List clusters = clusFinder.FindHitBasedClusters(hits, @@ -84,7 +69,7 @@ public boolean processDataEvent(DataEvent event) { return true; } else { List fhits = rbc.createRawHitList(hits); - /* 13 */ + /* 9 */ rbc.updateListsWithClusterInfo(fhits, clusters); event.appendBanks(rbc.fillHitsBank(event, fhits), rbc.fillHBClustersBank(event, clusters) 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 eae796665e..c25bc4f479 100644 --- a/reconstruction/dc/src/main/java/org/jlab/service/dc/DCHBEngine.java +++ b/reconstruction/dc/src/main/java/org/jlab/service/dc/DCHBEngine.java @@ -1,9 +1,5 @@ package org.jlab.service.dc; -import cnuphys.snr.NoiseReductionParameters; -import cnuphys.snr.clas12.Clas12NoiseAnalysis; -import cnuphys.snr.clas12.Clas12NoiseResult; - import java.util.ArrayList; import java.util.List; @@ -69,28 +65,17 @@ public boolean processDataEvent(DataEvent event) { // get Field Swim dcSwim = new Swim(); /* 2 */ - // init SNR - Clas12NoiseResult results = new Clas12NoiseResult(); - /* 3 */ - Clas12NoiseAnalysis noiseAnalysis = new Clas12NoiseAnalysis(); - /* 4 */ - NoiseReductionParameters parameters = - new NoiseReductionParameters( - 2, - Constants.SNR_LEFTSHIFTS, - Constants.SNR_RIGHTSHIFTS); - /* 5 */ ClusterFitter cf = new ClusterFitter(); - /* 6 */ + /* 3 */ ClusterCleanerUtilities ct = new ClusterCleanerUtilities(); - /* 7 */ + /* 4 */ RecoBankWriter rbc = new RecoBankWriter(this.getBanks()); - /* 8 */ + /* 5 */ HitReader hitRead = new HitReader(this.getBanks(), this.getRawBankOrders(), super.getConstantsManager(), Constants.getInstance().dcDetector); - /* 9 */ - hitRead.fetch_DCHits(event, noiseAnalysis, parameters, results); + /* 6 */ + hitRead.fetch_DCHits(event); - /* 10 */ + /* 7 */ //I) get the hits List hits = hitRead.get_DCHits(); //II) process the hits @@ -98,7 +83,7 @@ public boolean processDataEvent(DataEvent event) { if (hits.isEmpty()) { return true; } - /* 11 */ + /* 8 */ //2) find the clusters from these hits ClusterFinder clusFinder = new ClusterFinder(); List clusters = clusFinder.FindHitBasedClusters(hits, @@ -108,17 +93,17 @@ public boolean processDataEvent(DataEvent event) { if (clusters.isEmpty()) { return true; } - /* 12 */ + /* 9 */ List fhits = rbc.createRawHitList(hits); - /* 13 : assign cluster IDs to hits: if hit is associated to two clusters, the second survives*/ + /* 10 : assign cluster IDs to hits: if hit is associated to two clusters, the second survives*/ rbc.updateListsWithClusterInfo(fhits, clusters); - /* 14 */ + /* 11 */ //3) find the segments from the fitted clusters SegmentFinder segFinder = new SegmentFinder(); List segments = segFinder.get_Segments(clusters, event, Constants.getInstance().dcDetector, false); - /* 15 */ + /* 12 */ // need 6 segments to make a trajectory if (segments.isEmpty()) { rbc.fillAllHBBanks(event, @@ -142,7 +127,7 @@ public boolean processDataEvent(DataEvent event) { } } segments.removeAll(rmSegs); - /* 16 */ + /* 13 */ CrossMaker crossMake = new CrossMaker(); List crosses = crossMake.find_Crosses(segments, Constants.getInstance().dcDetector); if (crosses.isEmpty()) { @@ -154,7 +139,7 @@ public boolean processDataEvent(DataEvent event) { null); return true; } - /* 17 */ + /* 14 */ CrossListFinder crossLister = new CrossListFinder(); CrossList crosslist = crossLister.candCrossLists(event, crosses, @@ -163,14 +148,14 @@ public boolean processDataEvent(DataEvent event) { Constants.getInstance().dcDetector, null, dcSwim, false); - /* 18 */ + /* 15 */ //6) find the list of track candidates TrackCandListFinder trkcandFinder = new TrackCandListFinder(Constants.HITBASE); List trkcands = trkcandFinder.getTrackCands(crosslist, Constants.getInstance().dcDetector, Swimmer.getTorScale(), dcSwim, false); - /* 19 */ + /* 16 */ // track found int trkId = 1; diff --git a/reconstruction/dc/src/main/java/org/jlab/service/dc/DCHBPostClusterAI.java b/reconstruction/dc/src/main/java/org/jlab/service/dc/DCHBPostClusterAI.java index 0b63a3310b..c60e14f4e0 100644 --- a/reconstruction/dc/src/main/java/org/jlab/service/dc/DCHBPostClusterAI.java +++ b/reconstruction/dc/src/main/java/org/jlab/service/dc/DCHBPostClusterAI.java @@ -3,6 +3,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; +import java.util.Map; import java.util.logging.Level; import org.jlab.clas.swimtools.Swim; import org.jlab.clas.swimtools.Swimmer; @@ -20,10 +21,16 @@ import org.jlab.rec.dc.segment.Segment; import org.jlab.rec.dc.track.Track; import org.jlab.rec.dc.track.TrackCandListFinder; +import org.jlab.rec.dc.cluster.ClusterFinder; +import org.jlab.rec.dc.cluster.ClusterFitter; +import org.jlab.rec.dc.segment.SegmentFinder; +import org.jlab.rec.dc.cross.CrossMaker; +import org.jlab.rec.dc.trajectory.Road; +import org.jlab.rec.dc.trajectory.RoadFinder; /** * - * @author ziegler + * @author ziegler, tongtong */ public class DCHBPostClusterAI extends DCEngine { @@ -52,22 +59,19 @@ public boolean processDataEvent(DataEvent event) { return true; } + ////// AI-assisted tracking /* IO */ HitReader reader = new HitReader(this.getBanks(), Constants.getInstance().dcDetector); reader.initialize(event); RecoBankWriter writer = new RecoBankWriter(this.getBanks()); // get Field Swim dcSwim = new Swim(); - /* 2 */ - - /* 5 */ LOGGER.log(Level.FINE, "HB AI process event"); - /* 7 */ - /* 8 */ + //AI List trkcands = null; List crosses = null; - List clusters = null; + List clusters = new ArrayList<>(); List segments = null; List fhits = null; @@ -77,7 +81,7 @@ public boolean processDataEvent(DataEvent event) { List hits = reader.get_DCHits(); fhits = new ArrayList<>(); //II) process the hits - //1) exit if hit list is empty + // Exit if hit list is empty if (hits.isEmpty()) { return true; } @@ -99,7 +103,6 @@ public boolean processDataEvent(DataEvent event) { LOGGER.log(Level.FINE, "Pass Cross"+c.printInfo()); } if (crosses.isEmpty()) { - clusters = new ArrayList<>(); for(Segment seg : segments) { clusters.add(seg.get_fittedCluster()); } @@ -122,45 +125,197 @@ public boolean processDataEvent(DataEvent event) { dcSwim, true); // track found - clusters = new ArrayList<>(); int trkId = 1; if (trkcands.size() > 0) { // remove overlaps trkcandFinder.removeOverlappingTracks(trkcands); for (Track trk : trkcands) { + trk.setIsAITrack(true); + + for (Cross c : trk) { + clusters.add(c.get_Segment1().get_fittedCluster()); + clusters.add(c.get_Segment2().get_fittedCluster()); + } + // reset the id trk.set_Id(trkId); trkcandFinder.matchHits(trk.getStateVecs(), trk, Constants.getInstance().dcDetector, dcSwim); - for (Cross c : trk) { - c.set_CrossDirIntersSegWires(); - clusters.add(c.get_Segment1().get_fittedCluster()); - clusters.add(c.get_Segment2().get_fittedCluster()); - trkcandFinder.setHitDoubletsInfo(c.get_Segment1()); - trkcandFinder.setHitDoubletsInfo(c.get_Segment2()); - for (FittedHit h1 : c.get_Segment1()) { - h1.set_AssociatedHBTrackID(trkId); - //if(h1.get_AssociatedHBTrackID()>0) - fhits.add(h1); + trkId++; + } + } + + ////// Find tracks by rest of clusters using conventional tracking + List clustersConv = null; + List segmentsConv = null; + List crossesConv = null; + List trkcandsConv = null; + + //1) read hits from the banks + Map> hitsConv = reader.read_Hits(event); + + //2) find clusters from these hits + ClusterFinder clusFinder = new ClusterFinder(); + ClusterFitter cf = new ClusterFitter(); + clustersConv = clusFinder.RecomposeClusters(hitsConv, Constants.getInstance().dcDetector, cf); + + //3) remove clusters which are on tracks + List removedClustersConv = new ArrayList(); + for(FittedCluster cls : clustersConv){ + boolean flag = false; + for(Track trk : trkcands){ + if(flag) break; + for(Cross crs : trk){ + if(cls.get_Id() == crs.get_Segment1().get_Id() || cls.get_Id() == crs.get_Segment2().get_Id()) { + removedClustersConv.add(cls); + flag = true; + break; + } + } + } + } + clustersConv.removeAll(removedClustersConv); + clusters.addAll(clustersConv); + + //4) find segments from clusters + SegmentFinder segFinder = new SegmentFinder(); + segmentsConv = segFinder.get_Segments(clustersConv, + event, + Constants.getInstance().dcDetector, false); + List rmSegsConv = new ArrayList<>(); + // clean up hit-based segments + double trkDocOverCellSize; + for (Segment se : segmentsConv) { + trkDocOverCellSize = 0; + for (FittedHit fh : se.get_fittedCluster()) { + trkDocOverCellSize += fh.get_ClusFitDoca() / fh.get_CellSize(); + } + if (trkDocOverCellSize / se.size() > 1.1) { + rmSegsConv.add(se); + } + } + segmentsConv.removeAll(rmSegsConv); + segments.addAll(segmentsConv); + + //5) find crosses from segments + CrossMaker crossMake = new CrossMaker(); + crossesConv = crossMake.find_Crosses(segmentsConv, Constants.getInstance().dcDetector); + crosses.addAll(crossesConv); + + //6) find cross lists from crosses + CrossList crosslistConv = crossLister.candCrossLists(event, crossesConv, + false, + null, + Constants.getInstance().dcDetector, + null, + dcSwim, false); + + //7) find track candidates with 5 or 6 clusters + // track candidates with 6 clusters + trkcandsConv = trkcandFinder.getTrackCands(crosslistConv, + Constants.getInstance().dcDetector, + Swimmer.getTorScale(), + dcSwim, false); + + // track candidates with 5 clusters + RoadFinder rf = new RoadFinder(); + List allRoadsConv = rf.findRoads(segmentsConv, Constants.getInstance().dcDetector); + List Segs2RoadConv = new ArrayList<>(); + List psegmentsConv = new ArrayList<>(); + for (Road r : allRoadsConv) { + Segs2RoadConv.clear(); + int missingSL = -1; + for (int ri = 0; ri < 3; ri++) { + if (r.get(ri).associatedCrossId == -1) { + if (r.get(ri).get_Superlayer() % 2 == 1) { + missingSL = r.get(ri).get_Superlayer() + 1; + } else { + missingSL = r.get(ri).get_Superlayer() - 1; } - for (FittedHit h2 : c.get_Segment2()) { - h2.set_AssociatedHBTrackID(trkId); - //if(h2.get_AssociatedHBTrackID()>0) - fhits.add(h2); + } + } + if(missingSL==-1) + continue; + for (int ri = 0; ri < 3; ri++) { + for (Segment s : segmentsConv) { + if (s.get_Sector() == r.get(ri).get_Sector() && + s.get_Region() == r.get(ri).get_Region() && + s.associatedCrossId == r.get(ri).associatedCrossId && + r.get(ri).associatedCrossId != -1) { + if (s.get_Superlayer() % 2 == missingSL % 2) + Segs2RoadConv.add(s); } } - trk.calcTrajectory(trk.getId(), dcSwim, trk.get_Vtx0(), trk.get_pAtOrig(), trk.get_Q()); - trkId++; + } + if (Segs2RoadConv.size() == 2) { + Segment pSegmentConv = rf.findRoadMissingSegment(Segs2RoadConv, + Constants.getInstance().dcDetector, + r.a); + if (pSegmentConv != null) + psegmentsConv.add(pSegmentConv); } } + + segmentsConv.addAll(psegmentsConv); + List pcrossesConv = crossMake.find_Crosses(segmentsConv, Constants.getInstance().dcDetector); + CrossList pcrosslistConv = crossLister.candCrossLists(event, pcrossesConv, + false, + null, + Constants.getInstance().dcDetector, + null, + dcSwim, true); + List mistrkcandsConv = trkcandFinder.getTrackCands(pcrosslistConv, + Constants.getInstance().dcDetector, + Swimmer.getTorScale(), + dcSwim, false); - // no candidate found, stop here and save the hits, + //8) Select overlapping tracks from all track candidates with 5 or 6 clusters, and update hits in tracks + trkcandsConv.addAll(mistrkcandsConv); + if (!trkcandsConv.isEmpty()) { + // remove overlaps + trkcandFinder.removeOverlappingTracks(trkcandsConv); + for (Track trk : trkcandsConv) { + // reset the id + trk.set_Id(trkId); + trkcandFinder.matchHits(trk.getStateVecs(), + trk, + Constants.getInstance().dcDetector, + dcSwim); + trkId++; + } + } + + //////gather all the hits for pointer bank creation + trkcands.addAll(trkcandsConv); + trkId=1; + for (Track trk : trkcands) { + trk.calcTrajectory(trk.getId(), dcSwim, trk.get_Vtx0(), trk.get_pAtOrig(), trk.get_Q()); + for (Cross c : trk) { + c.set_CrossDirIntersSegWires(); + trkcandFinder.setHitDoubletsInfo(c.get_Segment1()); + trkcandFinder.setHitDoubletsInfo(c.get_Segment2()); + for (FittedHit h1 : c.get_Segment1()) { + h1.set_AssociatedHBTrackID(trkId); + //if(h1.get_AssociatedHBTrackID()>0) + fhits.add(h1); + } + for (FittedHit h2 : c.get_Segment2()) { + h2.set_AssociatedHBTrackID(trkId); + //if(h2.get_AssociatedHBTrackID()>0) + fhits.add(h2); + } + } + trkId++; + } + + // no candidate found, stop here and save the hits, // the clusters, the segments, the crosses if (trkcands.isEmpty()) { event.appendBanks( writer.fillHBHitsBank(event, fhits), + writer.fillHBClustersBank(event, clusters), writer.fillHBSegmentsBank(event, segments), writer.fillHBCrossesBank(event, crosses)); } 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 2bd9d1e9f9..ee5952aa32 100644 --- a/reconstruction/dc/src/main/java/org/jlab/service/dc/DCTBEngine.java +++ b/reconstruction/dc/src/main/java/org/jlab/service/dc/DCTBEngine.java @@ -189,6 +189,11 @@ public boolean processDataEvent(DataEvent event) { trkbank.getFloat("tx", i), trkbank.getFloat("ty", i)); HBFinalSV.setZ(trkbank.getFloat("z", i)); HBtrk.setFinalStateVec(HBFinalSV); + + int status = trkbank.getShort("status", i); + int isAITrack = (status >> 12) & 1; + HBtrk.setIsAITrack((isAITrack == 1)); + TrackArray[HBtrk.get_Id()-1] = HBtrk; // TrackArray[HBtrk.get_Id()-1].set_Status(0); } diff --git a/reconstruction/eb/pom.xml b/reconstruction/eb/pom.xml index 08a26dcc77..fa1d4bbd07 100644 --- a/reconstruction/eb/pom.xml +++ b/reconstruction/eb/pom.xml @@ -13,7 +13,7 @@ org.jlab.clas clas12rec ../../parent/pom.xml - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT @@ -21,25 +21,25 @@ org.jlab.clas clas-utils - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT org.jlab.clas clas-io - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT org.jlab.clas clas-reco - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT org.jlab.clas clas-analysis - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT diff --git a/reconstruction/ec/pom.xml b/reconstruction/ec/pom.xml index b70658b6aa..947416d323 100644 --- a/reconstruction/ec/pom.xml +++ b/reconstruction/ec/pom.xml @@ -13,7 +13,7 @@ org.jlab.clas clas12rec ../../parent/pom.xml - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT @@ -21,13 +21,13 @@ org.jlab.clas clas-detector - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT org.jlab.clas clas-analysis - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT diff --git a/reconstruction/fmt/pom.xml b/reconstruction/fmt/pom.xml index 8aa1df07eb..a39d197662 100644 --- a/reconstruction/fmt/pom.xml +++ b/reconstruction/fmt/pom.xml @@ -15,21 +15,21 @@ org.jlab.clas clas12rec ../../parent/pom.xml - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT org.jlab.clas clas-jcsg - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT jar org.jlab.clas swim-tools - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT diff --git a/reconstruction/ft/pom.xml b/reconstruction/ft/pom.xml index 9a18c45343..f5dadf1b6c 100644 --- a/reconstruction/ft/pom.xml +++ b/reconstruction/ft/pom.xml @@ -13,7 +13,7 @@ org.jlab.clas clas12rec ../../parent/pom.xml - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT @@ -21,7 +21,7 @@ org.jlab.clas clas-reco - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT diff --git a/reconstruction/htcc/pom.xml b/reconstruction/htcc/pom.xml index 3412c49c2b..a05b7d2d66 100644 --- a/reconstruction/htcc/pom.xml +++ b/reconstruction/htcc/pom.xml @@ -13,7 +13,7 @@ org.jlab.clas clas12rec ../../parent/pom.xml - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT @@ -21,7 +21,7 @@ org.jlab.clas clas-reco - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT diff --git a/reconstruction/htcc/src/main/java/.classpath b/reconstruction/htcc/src/main/java/.classpath deleted file mode 100644 index 3da7f1474e..0000000000 --- a/reconstruction/htcc/src/main/java/.classpath +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/reconstruction/htcc/src/main/java/.project b/reconstruction/htcc/src/main/java/.project deleted file mode 100644 index b4155c2226..0000000000 --- a/reconstruction/htcc/src/main/java/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - HTCCReco - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/reconstruction/ltcc/pom.xml b/reconstruction/ltcc/pom.xml index 6454000c7e..a629cf13a0 100644 --- a/reconstruction/ltcc/pom.xml +++ b/reconstruction/ltcc/pom.xml @@ -13,14 +13,14 @@ org.jlab.clas clas12rec ../../parent/pom.xml - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT org.jlab.clas clas-reco - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT diff --git a/reconstruction/mc/pom.xml b/reconstruction/mc/pom.xml index f590eceb3b..448a1e0c63 100644 --- a/reconstruction/mc/pom.xml +++ b/reconstruction/mc/pom.xml @@ -13,7 +13,7 @@ org.jlab.clas clas12rec ../../parent/pom.xml - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT @@ -21,7 +21,7 @@ org.jlab.clas clas-reco - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT diff --git a/reconstruction/mltn/pom.xml b/reconstruction/mltn/pom.xml index 95bf0ab6d0..c8c42ad60f 100644 --- a/reconstruction/mltn/pom.xml +++ b/reconstruction/mltn/pom.xml @@ -14,7 +14,7 @@ org.jlab.clas clas12rec ../../parent/pom.xml - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT @@ -34,13 +34,13 @@ org.jlab.clas clas-io - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT org.jlab.clas clas-reco - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT diff --git a/reconstruction/pom.xml b/reconstruction/pom.xml index 76ed7aa839..453c33b27b 100644 --- a/reconstruction/pom.xml +++ b/reconstruction/pom.xml @@ -3,14 +3,14 @@ org.jlab.clas reconstruction - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT pom org.jlab.clas clas12rec ../parent/pom.xml - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT diff --git a/reconstruction/postproc/pom.xml b/reconstruction/postproc/pom.xml index 6c561dfefb..95dc95887d 100644 --- a/reconstruction/postproc/pom.xml +++ b/reconstruction/postproc/pom.xml @@ -13,7 +13,7 @@ org.jlab.clas clas12rec ../../parent/pom.xml - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT @@ -21,19 +21,19 @@ org.jlab.clas clas-io - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT org.jlab.clas clas-reco - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT org.jlab.clas clas-analysis - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT diff --git a/reconstruction/raster/pom.xml b/reconstruction/raster/pom.xml index 2c248ac363..b8a0bc018e 100644 --- a/reconstruction/raster/pom.xml +++ b/reconstruction/raster/pom.xml @@ -13,7 +13,7 @@ org.jlab.clas clas12rec ../../parent/pom.xml - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT @@ -21,7 +21,7 @@ org.jlab.clas clas-reco - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT diff --git a/reconstruction/rich/pom.xml b/reconstruction/rich/pom.xml index 58a9573c34..3f96607402 100644 --- a/reconstruction/rich/pom.xml +++ b/reconstruction/rich/pom.xml @@ -13,7 +13,7 @@ org.jlab.clas clas12rec ../../parent/pom.xml - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT @@ -21,13 +21,13 @@ org.jlab.clas clas-reco - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT org.jlab.clas clas-jcsg - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT diff --git a/reconstruction/rtpc/pom.xml b/reconstruction/rtpc/pom.xml index 66340c0618..e805b1381b 100644 --- a/reconstruction/rtpc/pom.xml +++ b/reconstruction/rtpc/pom.xml @@ -13,7 +13,7 @@ org.jlab.clas clas12rec ../../parent/pom.xml - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT @@ -21,12 +21,12 @@ org.jlab.clas clas-reco - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT org.jlab.clas clas-tracking - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT compile diff --git a/reconstruction/swaps/pom.xml b/reconstruction/swaps/pom.xml index e09381c4dc..fe8a73ed4a 100644 --- a/reconstruction/swaps/pom.xml +++ b/reconstruction/swaps/pom.xml @@ -13,7 +13,7 @@ org.jlab.clas clas12rec ../../parent/pom.xml - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT @@ -21,19 +21,19 @@ org.jlab.clas clas-detector - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT org.jlab.clas clas-io - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT org.jlab.clas clas-reco - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT diff --git a/reconstruction/tof/pom.xml b/reconstruction/tof/pom.xml index ce99a611c0..96c967791a 100644 --- a/reconstruction/tof/pom.xml +++ b/reconstruction/tof/pom.xml @@ -13,7 +13,7 @@ org.jlab.clas clas12rec ../../parent/pom.xml - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT @@ -21,7 +21,7 @@ org.jlab.clas clas-jcsg - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT diff --git a/reconstruction/urwell/pom.xml b/reconstruction/urwell/pom.xml index ccb5251a2c..96c5920e89 100644 --- a/reconstruction/urwell/pom.xml +++ b/reconstruction/urwell/pom.xml @@ -13,7 +13,7 @@ org.jlab.clas clas12rec ../../parent/pom.xml - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT @@ -21,13 +21,13 @@ org.jlab.clas clas-detector - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT org.jlab.clas clas-analysis - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT diff --git a/reconstruction/vtx/pom.xml b/reconstruction/vtx/pom.xml index 98c454538c..6d822fa6d9 100644 --- a/reconstruction/vtx/pom.xml +++ b/reconstruction/vtx/pom.xml @@ -13,7 +13,7 @@ org.jlab.clas clas12rec ../../parent/pom.xml - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT @@ -33,13 +33,13 @@ org.jlab.clas swim-tools - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT jar org.jlab.clas clas-tracking - 11.1.2-SNAPSHOT + 12.0.6t-SNAPSHOT jar diff --git a/validation/advanced-tests/src/eb/scripts/gemc.sh b/validation/advanced-tests/src/eb/scripts/gemc.sh index a721a35b1a..d4d9e36785 100755 --- a/validation/advanced-tests/src/eb/scripts/gemc.sh +++ b/validation/advanced-tests/src/eb/scripts/gemc.sh @@ -3,9 +3,10 @@ usage() { echo "Usage: $0 [-g GEMC] [-n NEV] [-p PARTS] [-c GCARD] [-m]" 1>&2; exit $1; } run=11 -gemc=5.10 +gemc=dev nevents=100 particles=() +seed=1234567 while getopts "g:n:c:p:mdh" o do @@ -53,7 +54,7 @@ function run_gemc () { [ -e "$_output" ] && echo Output file already exists: $_output && exit 3 [ -z ${dryrun+x} ] && set -x $dryrun gemc \ - $_gcard -RUNNO=$_run -USE_GUI=0 -N=$_nevents \ + $_gcard -RANDOM=$seed -RUNNO=$_run -USE_GUI=0 -N=$_nevents \ -SAVE_ALL_MOTHERS=1 -SKIPREJECTEDHITS=1 -INTEGRATEDRAW="*" -NGENP=50 \ -INPUT_GEN_FILE="LUND, $_input" \ -OUTPUT="hipo, $_output" & diff --git a/validation/advanced-tests/src/eb/scripts/gen.py b/validation/advanced-tests/src/eb/scripts/gen.py new file mode 100755 index 0000000000..6d1cbdb6a6 --- /dev/null +++ b/validation/advanced-tests/src/eb/scripts/gen.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python +import random,math,sys + +mp = 0.93827 +me = 0.00051 +fmt = ' '.join(6*['%d']+8*['%.4f']) + +def cartesian(p,t,h,m): + x = p * math.cos(h) * math.sin(t) + y = p * math.sin(h) * math.sin(t) + z = p * math.cos(t) + e = math.sqrt(p*p + m*m) + return [x,y,z,e] + +for i in range(int(sys.argv[1])): + p = 0.1+0.1*random.random() + e = math.sqrt(p*p+mp*mp) + t = math.radians(70+40*random.random()) + h = 2*math.pi*random.random() + z = -5+10*random.random() + header = [2,1,1,0,0,0,0,0,0,0] + electron = [1,0,1,11,0,0] + cartesian(9.0,math.radians(12),0,me) + [me,0,0,z] + hadron = [2,0,1,2212,0,0] + cartesian(p,t,h,mp) + [mp,0,0,z] + print(' '.join([str(x) for x in header])) + print(fmt%tuple(electron)) + print(fmt%tuple(hadron)) diff --git a/validation/advanced-tests/src/eb/scripts/list.txt b/validation/advanced-tests/src/eb/scripts/list.txt index 548db442e2..03a77c22b2 100644 --- a/validation/advanced-tests/src/eb/scripts/list.txt +++ b/validation/advanced-tests/src/eb/scripts/list.txt @@ -12,3 +12,4 @@ electrondeuteronC -pid 45 -cd electronFTpion -pid -211 -ft electronFTproton -pid -2212 -ft electronFTkaon -pid -321 -ft +electronprotonA -pid -2212 -al