diff --git a/.github/lsan.supp b/.github/lsan.supp index abaee04a3d..4f9bf66a2b 100644 --- a/.github/lsan.supp +++ b/.github/lsan.supp @@ -5,3 +5,4 @@ leak:edm4hep::*::createBuffers leak:libActsCore.so leak:libCling.so leak:libCore.so +leak:libJANA.so diff --git a/.github/workflows/linux-eic-shell.yml b/.github/workflows/linux-eic-shell.yml index b61f2dcd26..5d4c15c62b 100644 --- a/.github/workflows/linux-eic-shell.yml +++ b/.github/workflows/linux-eic-shell.yml @@ -210,7 +210,7 @@ jobs: path: clang_tidy_fixes.yml if-no-files-found: ignore - name: Suggest clang-tidy fixes as PR comments - uses: platisd/clang-tidy-pr-comments@v1.5.0 + uses: platisd/clang-tidy-pr-comments@v1.5.1 if: ${{ github.event_name == 'pull_request' }} with: github_token: ${{ secrets.GITHUB_TOKEN }} @@ -764,20 +764,19 @@ jobs: if_no_artifact_found: warn - name: Compare to previous artifacts uses: eic/run-cvmfs-osg-eic-shell@main - if: steps.download_previous_artifact.outputs.found_artifact == 'true' with: platform-release: "${{ env.platform }}:${{ env.release }}" setup: "/opt/detector/epic-${{ env.detector-version }}/bin/thisepic.sh" run: | - export PYTHONPATH=$HOME/.local/lib/python3.10/site-packages:$PYTHONPATH mkdir capybara-reports mkdir new ln -sf ../rec_${{ matrix.particle }}_1GeV_20GeV_${{ matrix.detector_config }}.edm4eic.root new/ - capybara bara ref/rec_${{ matrix.particle }}_1GeV_20GeV_${{ matrix.detector_config }}.edm4eic.root new/rec_${{ matrix.particle }}_1GeV_20GeV_${{ matrix.detector_config }}.edm4eic.root + # using nullglob to ensure ref/* does not fail + shopt -s nullglob + capybara bara ref/*rec_${{ matrix.particle }}_1GeV_20GeV_${{ matrix.detector_config }}.edm4eic.root new/rec_${{ matrix.particle }}_1GeV_20GeV_${{ matrix.detector_config }}.edm4eic.root mv capybara-reports rec_${{ matrix.particle }}_1GeV_20GeV_${{ matrix.detector_config }} touch .rec_${{ matrix.particle }}_1GeV_20GeV_${{ matrix.detector_config }} - uses: actions/upload-artifact@v4 - if: steps.download_previous_artifact.outputs.found_artifact == 'true' with: name: rec_${{ matrix.particle }}_1GeV_20GeV_${{ matrix.detector_config }}.capy path: | @@ -965,21 +964,19 @@ jobs: if_no_artifact_found: warn - name: Compare to previous artifacts uses: eic/run-cvmfs-osg-eic-shell@main - if: steps.download_previous_artifact.outputs.found_artifact == 'true' with: platform-release: "${{ env.platform }}:${{ env.release }}" setup: "/opt/detector/epic-${{ env.detector-version }}/bin/thisepic.sh" run: | - pip install 'pygithub>=2' 'bokeh>=3' - export PYTHONPATH=$HOME/.local/lib/python3.10/site-packages:$PYTHONPATH mkdir capybara-reports mkdir new ln -sf ../rec_dis_${{matrix.beam}}_minQ2=${{matrix.minq2}}_${{ matrix.detector_config }}.edm4eic.root new/ - capybara bara ref/rec_dis_${{matrix.beam}}_minQ2=${{matrix.minq2}}_${{ matrix.detector_config }}.edm4eic.root new/rec_dis_${{matrix.beam}}_minQ2=${{matrix.minq2}}_${{ matrix.detector_config }}.edm4eic.root + # using nullglob to ensure ref/* does not fail + shopt -s nullglob + capybara bara ref/*rec_dis_${{matrix.beam}}_minQ2=${{matrix.minq2}}_${{ matrix.detector_config }}.edm4eic.root new/rec_dis_${{matrix.beam}}_minQ2=${{matrix.minq2}}_${{ matrix.detector_config }}.edm4eic.root mv capybara-reports rec_dis_${{matrix.beam}}_minQ2=${{matrix.minq2}}_${{ matrix.detector_config }} touch .rec_dis_${{matrix.beam}}_minQ2=${{matrix.minq2}}_${{ matrix.detector_config }} - uses: actions/upload-artifact@v4 - if: steps.download_previous_artifact.outputs.found_artifact == 'true' with: name: rec_dis_${{matrix.beam}}_minQ2=${{matrix.minq2}}_${{ matrix.detector_config }}.capy path: | diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index cf215b1c65..033cb95c37 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,7 +2,7 @@ ci: skip: [clang-format] repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.6.0 + rev: v5.0.0 hooks: - id: end-of-file-fixer - id: trailing-whitespace diff --git a/CMakeLists.txt b/CMakeLists.txt index 0d67602baf..bbfa5d22b8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -150,13 +150,10 @@ set(CMAKE_INSTALL_RPATH set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) # Check and print what JANA2 is used -find_package(JANA 2.0.8 REQUIRED) +find_package(JANA REQUIRED) message(STATUS "${CMAKE_PROJECT_NAME}: JANA2 CMake : ${JANA_DIR}") message(STATUS "${CMAKE_PROJECT_NAME}: JANA2 includes: ${JANA_INCLUDE_DIR}") message(STATUS "${CMAKE_PROJECT_NAME}: JANA2 library : ${JANA_LIBRARY}") -add_compile_definitions(HAVE_PODIO) -# TODO: NWB: Do this correctly in JANA via target_compile_definitions for v2.1.1 -# TODO: NWB: Maybe we want these to be prefixed, e.g. JANA2_HAVE_PODIO # Algorithms find_package(algorithms 1.0.0 REQUIRED Core) diff --git a/docs/howto/use_docker.md b/docs/howto/use_docker.md index 628f654afa..21adc1b216 100644 --- a/docs/howto/use_docker.md +++ b/docs/howto/use_docker.md @@ -8,7 +8,7 @@ The containers are released both for docker and singularity. Singularity images - [Docker Hub](https://hub.docker.com/u/eicweb) - CVMFS path (available at BNL and JLab): ``` - singularity run /cvmfs/singularity.opensciencegrid.org/eicweb/jug_xl:nightly + singularity run /cvmfs/singularity.opensciencegrid.org/eicweb/eic_xl:nightly ``` ### Images structure: @@ -19,7 +19,7 @@ The containers are released both for docker and singularity. Singularity images - **debian_base** - is a container generic base container based on amd64/debian:testing - **jug_dev** - have all major HENP packages such as ROOT, Geant4 and DD4HEP but without detector and reconstruction. The image is used for testing purposes and automation. -- **jug_xl** - intended to be used to run simulation and work on detectors for users. jug_dev + full simulation packages +- **eic_xl** - intended to be used to run simulation and work on detectors for users. jug_dev + full simulation packages @@ -39,7 +39,7 @@ So testing is the precursor to the next release version. **TL;DR;** -Now it is recommended to use: ```eicweb/jug_xl:nightly``` +Now it is recommended to use: ```eicweb/eic_xl:nightly``` ## Run in docker @@ -50,13 +50,13 @@ Containers are available at eicweb namespace at To download or update the container: ```bash -docker pull eicweb/jug_xl:nightly +docker pull eicweb/eic_xl:nightly ``` Running docker (minimal and probably useless): ```bash -docker run -it --rm eicweb/jug_xl:nightly +docker run -it --rm eicweb/eic_xl:nightly ``` @@ -113,7 +113,7 @@ You can bind any directory on your system to docker image by using **-v** flag: Convenient place inside docker image is `/mnt/` directory. Full example: ```bash -docker run -it -v /home/user/eic/data:/mnt/data --rm eicweb/jug_xl:nightly +docker run -it -v /home/user/eic/data:/mnt/data --rm eicweb/eic_xl:nightly ls /mnt/data ``` @@ -133,7 +133,7 @@ ls /mnt/data With debugging enabled and all ports open: ``` -docker run -it --rm --cap-add=SYS_PTRACE --security-opt seccomp=unconfined eicweb/jug_xl:nightly +docker run -it --rm --cap-add=SYS_PTRACE --security-opt seccomp=unconfined eicweb/eic_xl:nightly ``` @@ -146,7 +146,7 @@ The setup depends on particular tool: - [Visual Studio Code docker remote debugging](https://code.visualstudio.com/docs/remote/remote-overview) - [CLion docker toolchain](https://www.jetbrains.com/help/clion/clion-toolchains-in-docker.html) -> Use `\usr\local\bin\cmake` as cmake path, when configuring IDEs with jug_xl image +> Use `\usr\local\bin\cmake` as cmake path, when configuring IDEs with eic_xl image ![vscode-docker](vscode_docker.png ':size=800') @@ -166,7 +166,7 @@ You can use X11 natively (as natively as possible) with this docker image in you To use graphics, make sure you are in an X11 session and run the following command: ```bash -docker run -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix --rm -it --user $(id -u) eicweb/jug_xl:nightly +docker run -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix --rm -it --user $(id -u) eicweb/eic_xl:nightly ``` There might be issues with user id on systems like JLab farms. @@ -179,7 +179,7 @@ Make sure VcXsrv is whitelisted in the Windows firewall when prompted. Start VcXsrv with 'allow from any origin' flag ```bash -docker run --rm -it -e LIBGL_ALWAIS_INDIRECT=1 -e DISPLAY=10.0.75.1:0 eicweb/jug_xl:nightly +docker run --rm -it -e LIBGL_ALWAIS_INDIRECT=1 -e DISPLAY=10.0.75.1:0 eicweb/eic_xl:nightly ``` > 10.0.75.1 address corresponds to the network configuration in docker settings @@ -208,7 +208,7 @@ This will start XQuartz and whitelist your local IP address. Finally, you can start up docker with the following command: ``` -docker run --rm -it -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=$ip:0 eicweb/jug_xl:nightly +docker run --rm -it -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=$ip:0 eicweb/eic_xl:nightly ``` @@ -221,7 +221,7 @@ action needed. For the most optimal experience, you can install your software to ``/usr/local`` is a symlink to ``/opt/view``). ``` -FROM eicweb/jug_xl:nightly +FROM eicweb/eic_xl:nightly RUN apt-get update \ && export DEBIAN_FRONTEND=noninteractive \ && apt-get -y install git gdb diff --git a/docs/howto/use_singularity.md b/docs/howto/use_singularity.md index ff78fb39c8..4337041742 100644 --- a/docs/howto/use_singularity.md +++ b/docs/howto/use_singularity.md @@ -88,10 +88,10 @@ For farms like at BNL or JLab the images are automatically replicated to CVMS: ```bash -/cvmfs/singularity.opensciencegrid.org/eicweb/jug_xl* +/cvmfs/singularity.opensciencegrid.org/eicweb/eic_xl* # example to run -singularity run /cvmfs/singularity.opensciencegrid.org/eicweb/jug_xl:nightly +singularity run /cvmfs/singularity.opensciencegrid.org/eicweb/eic_xl:nightly ``` ### eic-shell explained @@ -106,7 +106,7 @@ singularity like: # $PREFIX here is where you installed everything (by default where install.sh executed) export EIC_SHELL_PREFIX=... export SINGULARITY_BINDPATH=/home -singularity exec $PREFIX/local/lib/jug_xl-nightly.sif eic-shell $@ +singularity exec $PREFIX/local/lib/eic_xl-nightly.sif eic-shell $@ ``` The **eic-shell** inside the container loads the proper environment and diff --git a/docs/tutorial/02-work-environment.md b/docs/tutorial/02-work-environment.md index 72bd516218..0ee305b63e 100644 --- a/docs/tutorial/02-work-environment.md +++ b/docs/tutorial/02-work-environment.md @@ -24,7 +24,7 @@ curl --location https://get.epic-eic.org | bash # or, if /cvmfs is available: # n.b. on JLab ifarm you may need to do 'module load singularity/3.9.5' first -singularity exec /cvmfs/singularity.opensciencegrid.org/eicweb/jug_xl:nightly eic-shell +singularity exec /cvmfs/singularity.opensciencegrid.org/eicweb/eic_xl:nightly eic-shell ``` Once inside the eic-shell, you should source the geometry setup script since this is not done by default. diff --git a/src/algorithms/calorimetry/ImagingClusterReco.h b/src/algorithms/calorimetry/ImagingClusterReco.h index df9bce263b..28baf24447 100644 --- a/src/algorithms/calorimetry/ImagingClusterReco.h +++ b/src/algorithms/calorimetry/ImagingClusterReco.h @@ -1,5 +1,5 @@ // SPDX-License-Identifier: LGPL-3.0-or-later -// Copyright (C) 2022 Sylvester Joosten, Chao Peng, Wouter Deconinck, David Lawrence +// Copyright (C) 2022 - 2024, Sylvester Joosten, Chao Peng, Wouter Deconinck, David Lawrence, Derek Anderson /* * Reconstruct the cluster/layer info for imaging calorimeter @@ -22,7 +22,11 @@ // Event Model related classes #include +#if EDM4EIC_VERSION_MAJOR >= 7 +#include +#else #include +#endif #include #include #include @@ -37,7 +41,11 @@ namespace eicrecon { using ImagingClusterRecoAlgorithm = algorithms::Algorithm< algorithms::Input< edm4eic::ProtoClusterCollection, +#if EDM4EIC_VERSION_MAJOR >= 7 + edm4eic::MCRecoCalorimeterHitAssociationCollection +#else edm4hep::SimCalorimeterHitCollection +#endif >, algorithms::Output< edm4eic::ClusterCollection, @@ -60,7 +68,11 @@ namespace eicrecon { public: ImagingClusterReco(std::string_view name) : ImagingClusterRecoAlgorithm{name, +#if EDM4EIC_VERSION_MAJOR >= 7 + {"inputProtoClusterCollection", "mcRawHitAssocations"}, +#else {"inputProtoClusterCollection", "mcHits"}, +#endif {"outputClusterCollection", "outputClusterAssociations", "outputLayerCollection"}, "Reconstruct the cluster/layer info for imaging calorimeter."} {} @@ -70,7 +82,11 @@ namespace eicrecon { void process(const Input& input, const Output& output) const final { +#if EDM4EIC_VERSION_MAJOR >= 7 + const auto [proto, mchitassociations] = input; +#else const auto [proto, mchits] = input; +#endif auto [clusters, associations, layers] = output; for (const auto& pcl: *proto) { @@ -95,45 +111,22 @@ namespace eicrecon { } clusters->push_back(cl); - // If mcHits are available, associate cluster with MCParticle - if (mchits->size() > 0) { - - // 1. find pclhit with the largest energy deposition - auto pclhits = pcl.getHits(); - auto pclhit = std::max_element( - pclhits.begin(), - pclhits.end(), - [](const auto &pclhit1, const auto &pclhit2) { - return pclhit1.getEnergy() < pclhit2.getEnergy(); - } - ); - - // 2. find mchit with same CellID - const edm4hep::SimCalorimeterHit* mchit = nullptr; - for (auto h : *mchits) { - if (h.getCellID() == pclhit->getCellID()) { - mchit = &h; - break; - } - } - if( !mchit ){ - // break if no matching hit found for this CellID - warning("Proto-cluster has highest energy in CellID {}, but no mc hit with that CellID was found.", pclhit->getCellID()); - break; - } - - // 3. find mchit's MCParticle - const auto &mcp = mchit->getContributions(0).getParticle(); - - // set association - auto clusterassoc = associations->create(); - clusterassoc.setRecID(cl.getObjectID().index); - clusterassoc.setSimID(mcp.getObjectID().index); - clusterassoc.setWeight(1.0); - clusterassoc.setRec(cl); - clusterassoc.setSim(mcp); + // If sim hits are available, associate cluster with MCParticle +#if EDM4EIC_VERSION_MAJOR >= 7 + if (mchitassociations->size() == 0) { + debug("Provided MCRecoCalorimeterHitAssociation collection is empty. No truth associations will be performed."); + continue; + } else { + associate_mc_particles(cl, mchitassociations, associations); } - +#else + if (mchits->size() == 0) { + debug("Provided SimCalorimeterHitCollection is empty. No truth association will be performed."); + continue; + } else { + associate_mc_particles(cl, mchits, associations); + } +#endif } // debug output @@ -303,6 +296,139 @@ namespace eicrecon { // theta and phi return {std::acos(dir(2)), std::atan2(dir(1), dir(0))}; } + + void associate_mc_particles( + const edm4eic::Cluster& cl, +#if EDM4EIC_VERSION_MAJOR >= 7 + const edm4eic::MCRecoCalorimeterHitAssociationCollection* mchitassociations, +#else + const edm4hep::SimCalorimeterHitCollection* mchits, +#endif + edm4eic::MCRecoClusterParticleAssociationCollection* assocs + ) const { + // -------------------------------------------------------------------------- + // Association Logic + // -------------------------------------------------------------------------- + /* 1. identify all sim hits associated with a given protocluster, and sum + * the energy of the sim hits. + * 2. for each sim hit + * - identify parents of each contributing particles; and + * - if parent is a primary particle, add to list of contributors + * and sum the energy contributed by the parent. + * 3. create an association for each contributing primary with a weight + * of contributed energy over total sim hit energy. + */ + + // lambda to compare MCParticles + auto compare = [](const edm4hep::MCParticle& lhs, const edm4hep::MCParticle& rhs) { + if (lhs.getObjectID().collectionID == rhs.getObjectID().collectionID) { + return (lhs.getObjectID().index < rhs.getObjectID().index); + } else { + return (lhs.getObjectID().collectionID < rhs.getObjectID().collectionID); + } + }; + + // bookkeeping maps for associated primaries + std::map mapMCParToContrib(compare); + + // -------------------------------------------------------------------------- + // 1. get associated sim hits and sum energy + // -------------------------------------------------------------------------- + double eSimHitSum = 0.; + for (auto clhit : cl.getHits()) { + // vector to hold associated sim hits + std::vector vecAssocSimHits; + +#if EDM4EIC_VERSION_MAJOR >= 7 + for (const auto& hitAssoc : *mchitassociations) { + // if found corresponding raw hit, add sim hit to vector + // and increment energy sum + if (clhit.getRawHit() == hitAssoc.getRawHit()) { + vecAssocSimHits.push_back(hitAssoc.getSimHit()); + eSimHitSum += vecAssocSimHits.back().getEnergy(); + } + + } +#else + for (const auto& mchit : *mchits) { + if (mchit.getCellID() == clhit.getCellID()) { + vecAssocSimHits.push_back(mchit); + eSimHitSum += vecAssocSimHits.back().getEnergy(); + break; + } + } + + // if no matching cell ID found, continue + // otherwise increment sum + if (vecAssocSimHits.empty()) { + debug("No matching SimHit for hit {}", clhit.getCellID()); + continue; + } +#endif + debug("{} associated sim hits found for reco hit (cell ID = {})", vecAssocSimHits.size(), clhit.getCellID()); + + // ------------------------------------------------------------------------ + // 2. loop through associated sim hits + // ------------------------------------------------------------------------ + for (const auto& simHit : vecAssocSimHits) { + for (const auto& contrib : simHit.getContributions()) { + // -------------------------------------------------------------------- + // grab primary responsible for contribution & increment relevant sum + // -------------------------------------------------------------------- + edm4hep::MCParticle primary = get_primary(contrib); + mapMCParToContrib[primary] += contrib.getEnergy(); + + trace("Identified primary: id = {}, pid = {}, total energy = {}, contributed = {}", + primary.getObjectID().index, + primary.getPDG(), + primary.getEnergy(), + mapMCParToContrib[primary] + ); + } + } + } + debug("Found {} primaries contributing a total of {} GeV", mapMCParToContrib.size(), eSimHitSum); + + // -------------------------------------------------------------------------- + // 3. create association for each contributing primary + // -------------------------------------------------------------------------- + for (auto [part, contribution] : mapMCParToContrib) { + // calculate weight + const double weight = contribution / eSimHitSum; + + // set association + auto assoc = assocs->create(); + assoc.setRecID(cl.getObjectID().index); // if not using collection, this is always set to -1 + assoc.setSimID(part.getObjectID().index); + assoc.setWeight(weight); + assoc.setRec(cl); + assoc.setSim(part); + debug("Associated cluster #{} to MC Particle #{} (pid = {}, status = {}, energy = {}) with weight ({})", + cl.getObjectID().index, + part.getObjectID().index, + part.getPDG(), + part.getGeneratorStatus(), + part.getEnergy(), + weight + ); + } + } + + edm4hep::MCParticle get_primary(const edm4hep::CaloHitContribution& contrib) const { + // get contributing particle + const auto contributor = contrib.getParticle(); + + // walk back through parents to find primary + // - TODO finalize primary selection. This + // can be improved!! + edm4hep::MCParticle primary = contributor; + while (primary.parents_size() > 0) { + if (primary.getGeneratorStatus() != 0) break; + primary = primary.getParents(0); + } + return primary; + } + }; } // namespace eicrecon diff --git a/src/algorithms/fardetectors/MatrixTransferStatic.cc b/src/algorithms/fardetectors/MatrixTransferStatic.cc index 48331e6c67..01b933806a 100644 --- a/src/algorithms/fardetectors/MatrixTransferStatic.cc +++ b/src/algorithms/fardetectors/MatrixTransferStatic.cc @@ -81,10 +81,10 @@ void eicrecon::MatrixTransferStatic::process( aY[1][0] = 0.0204108951; //c aY[1][1] = -0.139318692; //d - local_x_offset = -0.339334; - local_y_offset = -0.000299454; - local_x_slope_offset = -0.219603248; - local_y_slope_offset = -0.000176128; + local_x_offset = -1209.29;//-0.339334; these are the local coordinate values + local_y_offset = 0.00132511;//-0.000299454; + local_x_slope_offset = -45.4772;//-0.219603248; + local_y_slope_offset = 0.000745498;//-0.000176128; } else if(abs(100.0 - nomMomentum)/100.0 < nomMomentumError){ @@ -99,10 +99,10 @@ void eicrecon::MatrixTransferStatic::process( aY[1][0] = 0.0226283320; //c aY[1][1] = -0.082666019; //d - local_x_offset = -0.329072; - local_y_offset = -0.00028343; - local_x_slope_offset = -0.218525084; - local_y_slope_offset = -0.00015321; + local_x_offset = -1209.27;//-0.329072; + local_y_offset = 0.00355218;//-0.00028343; + local_x_slope_offset = -45.4737;//-0.218525084; + local_y_slope_offset = 0.00204394;//-0.00015321; } else if(abs(41.0 - nomMomentum)/41.0 < nomMomentumError){ @@ -117,10 +117,10 @@ void eicrecon::MatrixTransferStatic::process( aY[1][0] = 0.0179664765; //c aY[1][1] = 0.004160679; //d - local_x_offset = -0.283273; - local_y_offset = -0.00552451; - local_x_slope_offset = -0.21174031; - local_y_slope_offset = -0.003212011; + local_x_offset = -1209.22;//-0.283273; + local_y_offset = 0.00868737;//-0.00552451; + local_x_slope_offset = -45.4641;//-0.21174031; + local_y_slope_offset = 0.00498786;//-0.003212011; } else if(abs(135.0 - nomMomentum)/135.0 < nomMomentumError){ //135 GeV deuterons @@ -202,16 +202,16 @@ void eicrecon::MatrixTransferStatic::process( if(!goodHit2 && gpos.z() > m_cfg.hit2minZ && gpos.z() < m_cfg.hit2maxZ){ - goodHit[1].x = pos0.x(); - goodHit[1].y = pos0.y(); - goodHit[1].z = gpos.z(); + goodHit[1].x = gpos.x(); //pos0.x() - pos0 is local coordinates, gpos is global + goodHit[1].y = gpos.y(); //pos0.y() - temporarily changing to global to solve the local coordinate issue + goodHit[1].z = gpos.z(); // - which is unique to the Roman pots situation goodHit2 = true; } if(!goodHit1 && gpos.z() > m_cfg.hit1minZ && gpos.z() < m_cfg.hit1maxZ){ - goodHit[0].x = pos0.x(); - goodHit[0].y = pos0.y(); + goodHit[0].x = gpos.x(); //pos0.x() + goodHit[0].y = gpos.y(); //pos0.y() goodHit[0].z = gpos.z(); goodHit1 = true; @@ -252,6 +252,8 @@ void eicrecon::MatrixTransferStatic::process( } } + Yip[1] = Yrp[0]/aY[0][1]; + // convert polar angles to radians double rsx = Xip[1] * dd4hep::mrad; double rsy = Yip[1] * dd4hep::mrad; diff --git a/src/algorithms/tracking/ActsToTracks.cc b/src/algorithms/tracking/ActsToTracks.cc index 79480d1884..aa8c069449 100644 --- a/src/algorithms/tracking/ActsToTracks.cc +++ b/src/algorithms/tracking/ActsToTracks.cc @@ -120,7 +120,9 @@ void ActsToTracks::process(const Input& input, const Output& output) const { for (size_t j = 0; const auto& [b, y] : edm4eic_indexed_units) { // FIXME why not pars.getCovariance()(i,j) = covariance(a,b) / x / y; cov(i,j) = covariance(a,b) / x / y; + ++j; } + ++i; } pars.setCovariance(cov); diff --git a/src/algorithms/tracking/CKFTracking.cc b/src/algorithms/tracking/CKFTracking.cc index 93d33feff7..371574de5a 100644 --- a/src/algorithms/tracking/CKFTracking.cc +++ b/src/algorithms/tracking/CKFTracking.cc @@ -109,8 +109,8 @@ namespace eicrecon { std::vector, std::vector > - CKFTracking::process(const edm4eic::Measurement2DCollection& meas2Ds, - const edm4eic::TrackParametersCollection &init_trk_params) { + CKFTracking::process(const edm4eic::TrackParametersCollection& init_trk_params, + const edm4eic::Measurement2DCollection& meas2Ds) { // create sourcelink and measurement containers diff --git a/src/algorithms/tracking/CKFTracking.h b/src/algorithms/tracking/CKFTracking.h index 6373488b79..896944c542 100644 --- a/src/algorithms/tracking/CKFTracking.h +++ b/src/algorithms/tracking/CKFTracking.h @@ -74,8 +74,8 @@ namespace eicrecon { std::vector, std::vector > - process(const edm4eic::Measurement2DCollection& meas2Ds, - const edm4eic::TrackParametersCollection &init_trk_params); + process(const edm4eic::TrackParametersCollection& init_trk_params, + const edm4eic::Measurement2DCollection& meas2Ds); private: std::shared_ptr m_log; diff --git a/src/detectors/B0ECAL/B0ECAL.cc b/src/detectors/B0ECAL/B0ECAL.cc index 9d912a8221..2b653f841f 100644 --- a/src/detectors/B0ECAL/B0ECAL.cc +++ b/src/detectors/B0ECAL/B0ECAL.cc @@ -33,11 +33,12 @@ extern "C" { {"B0ECalRawHits"}, #endif { - .eRes = {0.0 * sqrt(dd4hep::GeV), 0.02, 0.0 * dd4hep::GeV}, + // The stochastic term is set using light yield in PbOW4 of N_photons = 145.75 / GeV / mm, for 6x6 mm2 sensors with PDE=0.18 (a=1/sqrt(145.75*36*0.18)) + .eRes = {0.0326 * sqrt(dd4hep::GeV), 0.00, 0.0 * dd4hep::GeV}, .tRes = 0.0 * dd4hep::ns, .threshold= 5.0 * dd4hep::MeV, .capADC = 16384, - .dyRangeADC = 20 * dd4hep::GeV, + .dyRangeADC = 170 * dd4hep::GeV, .pedMeanADC = 100, .pedSigmaADC = 1, .resolutionTDC = 1e-11, @@ -50,12 +51,12 @@ extern "C" { "B0ECalRecHits", {"B0ECalRawHits"}, {"B0ECalRecHits"}, { .capADC = 16384, - .dyRangeADC = 20. * dd4hep::GeV, + .dyRangeADC = 170. * dd4hep::GeV, .pedMeanADC = 100, .pedSigmaADC = 1, .resolutionTDC = 1e-11, .thresholdFactor = 0.0, - .thresholdValue = 0.0, + .thresholdValue = 1.0, // using threshold of 10 photons = 10 MeV = 1 ADC .sampFrac = "0.998", .readout = "B0ECalHits", .sectorField = "sector", diff --git a/src/detectors/BEMC/BEMC.cc b/src/detectors/BEMC/BEMC.cc index 36b2d9953f..266512c6ca 100644 --- a/src/detectors/BEMC/BEMC.cc +++ b/src/detectors/BEMC/BEMC.cc @@ -68,7 +68,7 @@ extern "C" { .resolutionTDC = EcalBarrelScFi_resolutionTDC, .thresholdFactor = 0.0, // use only thresholdValue .thresholdValue = 5.0, // 16384 ADC counts/1500 MeV * 0.5 MeV (desired threshold) = 5.46 - .sampFrac = "0.10200085", + .sampFrac = "0.09320426", .readout = "EcalBarrelScFiHits", .layerField = "layer", .sectorField = "sector", @@ -175,7 +175,11 @@ extern "C" { app->Add(new JOmniFactoryGeneratorT( "EcalBarrelImagingClusters", {"EcalBarrelImagingProtoClusters", +#if EDM4EIC_VERSION_MAJOR >= 7 + "EcalBarrelImagingRawHitAssociations"}, +#else "EcalBarrelImagingHits"}, +#endif {"EcalBarrelImagingClusters", "EcalBarrelImagingClusterAssociations", "EcalBarrelImagingLayers" diff --git a/src/detectors/EEMC/EEMC.cc b/src/detectors/EEMC/EEMC.cc index 9604b03090..8908c7ac72 100644 --- a/src/detectors/EEMC/EEMC.cc +++ b/src/detectors/EEMC/EEMC.cc @@ -40,7 +40,7 @@ extern "C" { {"EcalEndcapNRawHits"}, #endif { - .eRes = {0.0 * sqrt(dd4hep::GeV), 0.02, 0.0 * dd4hep::GeV}, + .eRes = {0.0 * sqrt(dd4hep::GeV), 0.0, 0.0 * dd4hep::GeV}, .tRes = 0.0 * dd4hep::ns, .threshold = 0.0 * dd4hep::MeV, // Use ADC cut instead .capADC = EcalEndcapN_capADC, diff --git a/src/detectors/FEMC/FEMC.cc b/src/detectors/FEMC/FEMC.cc index 09c1a3ba2b..998e425285 100644 --- a/src/detectors/FEMC/FEMC.cc +++ b/src/detectors/FEMC/FEMC.cc @@ -1,7 +1,5 @@ -// Copyright 2022, David Lawrence -// Subject to the terms in the LICENSE file found in the top-level directory. -// -// +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (C) 2021 - 2024, Chao Peng, Sylvester Joosten, Whitney Armstrong, David Lawrence, Friederike Bock, Wouter Deconinck, Kolja Kauder, Sebouh Paul #include #include @@ -77,12 +75,12 @@ extern "C" { "EcalEndcapPIslandProtoClusters", {"EcalEndcapPRecHits"}, {"EcalEndcapPIslandProtoClusters"}, { .sectorDist = 5.0 * dd4hep::cm, - .localDistXY = {10.0 * dd4hep::cm, 10.0 * dd4hep::cm}, - .splitCluster = true, + .dimScaledLocalDistXY = {1.5,1.5}, + .splitCluster = false, .minClusterHitEdep = 0.0 * dd4hep::MeV, - .minClusterCenterEdep = 10.0 * dd4hep::MeV, - .transverseEnergyProfileMetric = "globalDistEtaPhi", - .transverseEnergyProfileScale = 0.04, + .minClusterCenterEdep = 60.0 * dd4hep::MeV, + .transverseEnergyProfileMetric = "dimScaledLocalDistXY", + .transverseEnergyProfileScale = 1., }, app // TODO: Remove me once fixed )); @@ -213,12 +211,11 @@ extern "C" { "EcalEndcapPInsertIslandProtoClusters", {"EcalEndcapPInsertRecHits"}, {"EcalEndcapPInsertIslandProtoClusters"}, { .sectorDist = 5.0 * dd4hep::cm, - .localDistXY = {10.0 * dd4hep::cm, 10.0 * dd4hep::cm}, .dimScaledLocalDistXY = {1.5,1.5}, .splitCluster = false, .minClusterHitEdep = 0.0 * dd4hep::MeV, - .minClusterCenterEdep = 10.0 * dd4hep::MeV, - .transverseEnergyProfileMetric = "globalDistEtaPhi", + .minClusterCenterEdep = 60.0 * dd4hep::MeV, + .transverseEnergyProfileMetric = "dimScaledLocalDistXY", .transverseEnergyProfileScale = 1., }, app // TODO: Remove me once fixed diff --git a/src/detectors/MPGD/MPGD.cc b/src/detectors/MPGD/MPGD.cc index d4fd16a7e6..ea29ae3c64 100644 --- a/src/detectors/MPGD/MPGD.cc +++ b/src/detectors/MPGD/MPGD.cc @@ -29,7 +29,7 @@ void InitPlugin(JApplication *app) { "MPGDBarrelRawHitAssociations" }, { - .threshold = 0.25 * dd4hep::keV, + .threshold = 100 * dd4hep::eV, .timeResolution = 10, }, app @@ -57,7 +57,7 @@ void InitPlugin(JApplication *app) { "OuterMPGDBarrelRawHitAssociations" }, { - .threshold = 0.25 * dd4hep::keV, + .threshold = 100 * dd4hep::eV, .timeResolution = 10, }, app @@ -85,7 +85,7 @@ void InitPlugin(JApplication *app) { "BackwardMPGDEndcapRawHitAssociations" }, { - .threshold = 0.25 * dd4hep::keV, + .threshold = 100 * dd4hep::eV, .timeResolution = 10, }, app @@ -113,7 +113,7 @@ void InitPlugin(JApplication *app) { "ForwardMPGDEndcapRawHitAssociations" }, { - .threshold = 0.25 * dd4hep::keV, + .threshold = 100 * dd4hep::eV, .timeResolution = 10, }, app diff --git a/src/detectors/ZDC/ZDC.cc b/src/detectors/ZDC/ZDC.cc index e1a16e1b51..8a6d7954cc 100644 --- a/src/detectors/ZDC/ZDC.cc +++ b/src/detectors/ZDC/ZDC.cc @@ -134,10 +134,10 @@ extern "C" { #endif { .tRes = 0.0 * dd4hep::ns, - .capADC = 32768, - .dyRangeADC = 800 * dd4hep::MeV, + .capADC = 65536, + .dyRangeADC = 1000. * dd4hep::MeV, .pedMeanADC = 400, - .pedSigmaADC = 10, + .pedSigmaADC = 2, .resolutionTDC = 10 * dd4hep::picosecond, .corrMeanScale = "1.0", .readout = "HcalFarForwardZDCHits", @@ -148,12 +148,12 @@ extern "C" { app->Add(new JOmniFactoryGeneratorT( "HcalFarForwardZDCRecHits", {"HcalFarForwardZDCRawHits"}, {"HcalFarForwardZDCRecHits"}, { - .capADC = 32678, - .dyRangeADC = 800. * dd4hep::MeV, + .capADC = 65536, + .dyRangeADC = 1000. * dd4hep::MeV, .pedMeanADC = 400, - .pedSigmaADC = 10, + .pedSigmaADC = 2, .resolutionTDC = 10 * dd4hep::picosecond, - .thresholdFactor = 4.0, + .thresholdFactor = 3.0, .thresholdValue = 0.0, .sampFrac = "1.0", .readout = "HcalFarForwardZDCHits", diff --git a/src/extensions/jana/JOmniFactory.h b/src/extensions/jana/JOmniFactory.h index ca018494da..873070d21b 100644 --- a/src/extensions/jana/JOmniFactory.h +++ b/src/extensions/jana/JOmniFactory.h @@ -473,7 +473,6 @@ class JOmniFactory : public JMultifactory { std::vector default_input_collection_names, std::vector default_output_collection_names ) { - // TODO: NWB: JMultiFactory::GetTag,SetTag are not currently usable m_prefix = (this->GetPluginName().empty()) ? tag : this->GetPluginName() + ":" + tag; // Obtain collection name overrides if provided. diff --git a/src/extensions/jana/JOmniFactoryGeneratorT.h b/src/extensions/jana/JOmniFactoryGeneratorT.h index 14ed7080b9..ff0ad25fe7 100644 --- a/src/extensions/jana/JOmniFactoryGeneratorT.h +++ b/src/extensions/jana/JOmniFactoryGeneratorT.h @@ -98,9 +98,6 @@ class JOmniFactoryGeneratorT : public JFactoryGenerator { factory->SetApplication(m_app); factory->SetPluginName(this->GetPluginName()); factory->SetFactoryName(JTypeInfo::demangle()); - // factory->SetTag(wiring.m_tag); - // We do NOT want to do this because JMF will use the tag to suffix the collection names - // TODO: NWB: Change this in JANA factory->config() = wiring.m_default_cfg; // Set up all of the wiring prereqs so that Init() can do its thing diff --git a/src/factories/calorimetry/ImagingClusterReco_factory.h b/src/factories/calorimetry/ImagingClusterReco_factory.h index 9c55c195b8..2246f40743 100644 --- a/src/factories/calorimetry/ImagingClusterReco_factory.h +++ b/src/factories/calorimetry/ImagingClusterReco_factory.h @@ -18,7 +18,11 @@ class ImagingClusterReco_factory : std::unique_ptr m_algo; PodioInput m_protos_input {this}; +#if EDM4EIC_VERSION_MAJOR >= 7 + PodioInput m_mchitassocs_input {this}; +#else PodioInput m_mchits_input {this}; +#endif PodioOutput m_clusters_output {this}; PodioOutput m_assocs_output {this}; @@ -40,7 +44,11 @@ class ImagingClusterReco_factory : } void Process(int64_t run_number, uint64_t event_number) { +#if EDM4EIC_VERSION_MAJOR >= 7 + m_algo->process({m_protos_input(), m_mchitassocs_input()}, +#else m_algo->process({m_protos_input(), m_mchits_input()}, +#endif {m_clusters_output().get(), m_assocs_output().get(), m_layers_output().get()}); } }; diff --git a/src/global/tracking/CKFTracking_factory.h b/src/global/tracking/CKFTracking_factory.h index 91f2e7c2fd..ba17ca3ca6 100644 --- a/src/global/tracking/CKFTracking_factory.h +++ b/src/global/tracking/CKFTracking_factory.h @@ -54,8 +54,8 @@ class CKFTracking_factory : m_acts_trajectories_output(), m_acts_tracks_output() ) = m_algo->process( - *m_measurements_input(), - *m_parameters_input() + *m_parameters_input(), + *m_measurements_input() ); } }; diff --git a/src/tests/omnifactory_test/JOmniFactoryTests.cc b/src/tests/omnifactory_test/JOmniFactoryTests.cc index 40680174d1..b9ca6b6b4e 100644 --- a/src/tests/omnifactory_test/JOmniFactoryTests.cc +++ b/src/tests/omnifactory_test/JOmniFactoryTests.cc @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -55,7 +56,6 @@ struct BasicTestAlg : public JOmniFactory { m_process_call_count++; logger()->info("Calling BasicTestAlg::Process with bucket_count={}, threshold={}", config().bucket_count, config().threshold); // Provide empty collections (as opposed to nulls) so that PODIO doesn't crash - // TODO: NWB: I though multifactories already took care of this under the hood somewhere output_hits_left() = std::make_unique(); output_hits_right() = std::make_unique(); output_vechits().push_back(new edm4hep::SimCalorimeterHit()); @@ -64,7 +64,7 @@ struct BasicTestAlg : public JOmniFactory { template MultifactoryT* RetrieveMultifactory(JFactorySet* facset, std::string output_collection_name) { - auto fac = facset->GetFactory(output_collection_name); + auto fac = facset->GetFactory(JTypeInfo::demangle(), output_collection_name); REQUIRE(fac != nullptr); auto helper = dynamic_cast*>(fac); REQUIRE(helper != nullptr); @@ -180,10 +180,11 @@ TEST_CASE("JParameterManager correctly understands which values are defaulted an REQUIRE(b->config().threshold == 12.0); std::cout << "Showing the full table of config parameters" << std::endl; - app.GetJParameterManager()->PrintParameters(true, false, true); + app.GetJParameterManager()->PrintParameters(2, 1); // verbosity, strictness std::cout << "Showing only overridden config parameters" << std::endl; - app.GetJParameterManager()->PrintParameters(false, false, true); + app.GetJParameterManager()->PrintParameters(1, 1); // verbosity, strictness + } TEST_CASE("Wiring itself is correctly defaulted") { @@ -220,11 +221,11 @@ TEST_CASE("Wiring itself is correctly defaulted") { b->logger()->info("Showing the full table of config parameters"); - app.GetJParameterManager()->PrintParameters(true, false, true); + app.GetJParameterManager()->PrintParameters(2,1); // verbosity, strictness b->logger()->info("Showing only overridden config parameters"); // Should be empty because everything is defaulted - app.GetJParameterManager()->PrintParameters(false, false, true); + app.GetJParameterManager()->PrintParameters(1,1); // verbosity, strictness } struct VariadicTestAlg : public JOmniFactory {