diff --git a/.clang-format b/.clang-format new file mode 100644 index 000000000..63027b878 --- /dev/null +++ b/.clang-format @@ -0,0 +1 @@ +BasedOnStyle: LLVM diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 000000000..426494769 --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,14 @@ +HeaderFilterRegex: '' +Checks: ' + bugprone-*, + concurrency-*, + cppcoreguidelines-*, + modernize-*, + portability-*, + readability-*, + -modernize-use-trailing-return-type, + -modernize-avoid-c-arrays, + -modernize-use-nodiscard, + -readability-magic-numbers +' +FormatStyle: file diff --git a/.github/workflows/build-lcg-and-test.yml b/.github/workflows/build-lcg-and-test.yml new file mode 100644 index 000000000..9c6755f20 --- /dev/null +++ b/.github/workflows/build-lcg-and-test.yml @@ -0,0 +1,96 @@ +name: Build LCG and Test + +on: [push, pull_request] + +env: + LCG: "LCG_101" + sys: "x86_64-ubuntu2004-gcc9-opt" + +jobs: + build: + runs-on: ubuntu-20.04 + strategy: + fail-fast: false + steps: + - uses: actions/checkout@v2 + - uses: cvmfs-contrib/github-action-cvmfs@v2 + with: + cvmfs_repositories: 'sft.cern.ch,geant4.cern.ch' + - uses: aidasoft/run-lcg-view@v1 + with: + release-platform: ${{ env.LCG }}/${{ env.sys }} + run: | + cmake -Bbuild -S. -DCMAKE_INSTALL_PREFIX=install/ + cmake --build build + cmake --build build --target install + - run: | + tar -cvf install.tar install/ + - uses: actions/upload-artifact@v2 + with: + name: ${{ env.LCG }}-${{ env.sys }} + path: install.tar + retention-days: 1 + + test_geometries: + runs-on: ubuntu-20.04 + needs: build + strategy: + fail-fast: false + matrix: + suite: ["load", "validate", "overlap"] + steps: + - uses: actions/checkout@v2 + - uses: cvmfs-contrib/github-action-cvmfs@v2 + with: + cvmfs_repositories: 'sft.cern.ch,geant4.cern.ch' + - uses: actions/download-artifact@v2 + with: + name: ${{ env.LCG }}-${{ env.sys }} + - run: | + tar -xvf install.tar + - uses: aidasoft/run-lcg-view@v1 + with: + release-platform: ${{ env.LCG }}/${{ env.sys }} + run: | + mkdir -p logfiles rootfiles + source install/bin/remoll.sh + scripts/tests/test_geometries.sh ${{ matrix.suite }} + ls -al logfiles rootfiles + - uses: actions/upload-artifact@v2 + with: + name: test_geometries_${{ matrix.suite }}_logfiles + path: | + logfiles/ + retention-days: 3 + + test_macros: + runs-on: ubuntu-20.04 + needs: build + strategy: + fail-fast: false + matrix: + suite: ["unit", "commit", "release"] + steps: + - uses: actions/checkout@v2 + - uses: cvmfs-contrib/github-action-cvmfs@v2 + with: + cvmfs_repositories: 'sft.cern.ch,geant4.cern.ch' + - uses: actions/download-artifact@v2 + with: + name: ${{ env.LCG }}-${{ env.sys }} + - run: | + tar -xvf install.tar + - uses: aidasoft/run-lcg-view@v1 + with: + release-platform: ${{ env.LCG }}/${{ env.sys }} + run: | + mkdir -p logfiles rootfiles + source install/bin/remoll.sh + scripts/tests/test_macros.sh ${{ matrix.suite }} + ls -al logfiles rootfiles + - uses: actions/upload-artifact@v2 + with: + name: test_macros_${{ matrix.suite }}_logfiles + path: | + logfiles/ + retention-days: 3 diff --git a/.github/workflows/build-lcg-cvmfs.yml b/.github/workflows/build-lcg-cvmfs.yml new file mode 100644 index 000000000..0679cdc8f --- /dev/null +++ b/.github/workflows/build-lcg-cvmfs.yml @@ -0,0 +1,41 @@ +name: Build LCG on CVMFS + +on: [push, pull_request] + +jobs: + linux: + runs-on: ubuntu-20.04 + strategy: + fail-fast: false + matrix: + LCG: ["LCG_101/x86_64-ubuntu2004-gcc9-opt", + "LCG_99/x86_64-ubuntu2004-gcc9-opt"] + steps: + - uses: actions/checkout@v2 + - uses: cvmfs-contrib/github-action-cvmfs@v2 + with: + cvmfs_repositories: 'sft.cern.ch,geant4.cern.ch' + - uses: aidasoft/run-lcg-view@v1 + with: + release-platform: ${{ matrix.LCG }} + run: | + cmake -Bbuild -S. + cmake --build build + + macos: + runs-on: macos-10.15 + strategy: + matrix: + LCG: ["LCG_101/x86_64-mac1015-clang120-opt", + "LCG_99/x86_64-mac1015-clang120-opt"] + steps: + - uses: actions/checkout@v2 + - uses: cvmfs-contrib/github-action-cvmfs@v2 + with: + cvmfs_repositories: 'sft.cern.ch,geant4.cern.ch' + - uses: aidasoft/run-lcg-view@v1 + with: + release-platform: ${{ matrix.LCG }} + run: | + cmake -Bbuild -S. + cmake --build build diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml new file mode 100644 index 000000000..f2a7206d5 --- /dev/null +++ b/.github/workflows/docker-image.yml @@ -0,0 +1,56 @@ +name: Build Docker Images + +on: + push: + branches: + - '**' + tags: + - 'v*' + pull_request: + +jobs: + push_to_registry: + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Docker meta + id: docker_meta + uses: crazy-max/ghaction-docker-meta@v1 + with: + images: ${{ github.repository }} + tag-semver: | + {{version}} + {{major}}.{{minor}} + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 +# - name: Cache Docker layers +# uses: actions/cache@v2 +# with: +# path: /tmp/.buildx-cache +# key: ${{ runner.os }}-buildx-${{ github.sha }} +# restore-keys: | +# ${{ runner.os }}-buildx- + - name: Login to DockerHub + id: docker_login + if: github.event_name != 'pull_request' + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + continue-on-error: true + - name: Build and push + id: docker_build + uses: docker/build-push-action@v2 + with: + context: . + file: Dockerfile + push: ${{ steps.docker_login.outcome == 'success' && github.event_name != 'pull_request' }} + tags: ${{ steps.docker_meta.outputs.tags }} + labels: ${{ steps.docker_meta.outputs.labels }} +# cache-from: type=local,src=/tmp/.buildx-cache +# cache-to: type=local,dest=/tmp/.buildx-cache + - name: Image digest + run: echo ${{ steps.docker_build.outputs.digest }} diff --git a/.gitignore b/.gitignore index c2e860a32..158dc458a 100755 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,8 @@ G4Worker?_run*evt*.rndm run*evt*.rndm currentEvent.rndm currentRun.rndm +*.state +*.rndm # output from createHTML _remoll_*.html diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 000000000..2efd22eb8 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,9 @@ +[submodule "geometry/generators/remoll-coil-generator"] + path = geometry/generators/remoll-coil-generator + url = https://github.com/jeffersonlab/remoll-coil-generator.git +[submodule "geometry/generators/remoll-detector-generator"] + path = geometry/generators/remoll-detector-generator + url = https://github.com/JeffersonLab/remoll-detector-generator.git +[submodule "geometry/generators/remoll-showermax-generator"] + path = geometry/generators/remoll-showermax-generator + url = https://github.com/jeffersonlab/remoll-showermax-generator.git diff --git a/.travis.yml b/.travis.yml index 8a3665ed8..3fa7487c5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -41,12 +41,23 @@ jobs: echo "=== scripts/tests/test_macros.sh ${suite} ===" ; mkdir -p ${PWD}/logfiles ${PWD}/rootfiles ; time docker run --rm -v ${PWD}/rootfiles:/jlab/remoll/rootfiles -v ${PWD}/logfiles:/jlab/remoll/logfiles -t jeffersonlab/remoll:$TRAVIS_BRANCH sh -c " - scripts/tests/test_macros.sh ${suite} && - scripts/tests/targz_macros.sh ${suite} && - scripts/tests/watermark.sh ${suite} - " ; + scripts/tests/test_macros.sh ${suite} + " ; done ; ls -al ${PWD}/logfiles ${PWD}/rootfiles + - script: + - if [ "$TRAVIS_BRANCH" == "master" ]; then + for suite in release ; do + echo "=== scripts/tests/test_macros.sh ${suite} ===" ; + mkdir -p ${PWD}/logfiles ${PWD}/rootfiles ; + time docker run --rm -v ${PWD}/rootfiles:/jlab/remoll/rootfiles -v ${PWD}/logfiles:/jlab/remoll/logfiles -t jeffersonlab/remoll:$TRAVIS_BRANCH sh -c " + scripts/tests/test_macros.sh ${suite} && + scripts/tests/targz_macros.sh ${suite} && + scripts/tests/watermark.sh ${suite} + " ; + done ; + ls -al ${PWD}/logfiles ${PWD}/rootfiles ; + fi notifications: slack: diff --git a/CMakeLists.txt b/CMakeLists.txt index 43a13e494..d7b86ee75 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,9 +1,24 @@ #---------------------------------------------------------------------------- # Setup the project # -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.8) project(remoll VERSION 0.1 LANGUAGES CXX C) +# Export compile commands as json for run-clang-tidy +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + +# Also use clang-tidy integration in CMake +option(ENABLE_CLANG_TIDY "Enable clang-tidy integration in cmake" OFF) +if(ENABLE_CLANG_TIDY) + find_program(CLANG_TIDY_EXE NAMES "clang-tidy") + if (CLANG_TIDY_EXE) + message(STATUS "clang-tidy found: ${CLANG_TIDY_EXE}") + set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_EXE}" CACHE STRING "" FORCE) + else() + set(CMAKE_CXX_CLANG_TIDY "" CACHE STRING "" FORCE) + endif() +endif() + # Disallow in-source builds if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR}) message(FATAL_ERROR "remoll requires an out-of-source build.") @@ -20,11 +35,6 @@ include(CMakeEnv) # Use GNU install dirs include(GNUInstallDirs) -# Request C++11 standard -set(CMAKE_CXX_STANDARD 11) -set(CMAKE_CXX_STANDARD_REQUIRED True) -set(CMAKE_CXX_EXTENSIONS False) - # MAC specific variable if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") set(CMAKE_MACOSX_RPATH ON) @@ -38,6 +48,9 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") endif() endif() +# For remollSearchPath.hh +# FIXME +# link_libraries(stdc++fs) #---------------------------------------------------------------------------- # Locate sources and headers for this project @@ -86,7 +99,7 @@ list(APPEND sources ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Dict.cxx) #---------------------------------------------------------------------------- # Boost # -find_package(Boost QUIET COMPONENTS iostreams) +find_package(Boost QUIET OPTIONAL_COMPONENTS iostreams filesystem) if(Boost_FOUND) message(STATUS "Boost found --> building with boost enabled.") include_directories(${Boost_INCLUDE_DIRS}) @@ -94,10 +107,52 @@ if(Boost_FOUND) ADD_DEFINITIONS(-D__USE_BOOST) if(Boost_IOSTREAMS_FOUND) message(STATUS "Boost::iostreams found --> building with boost::iostreams enabled.") - ADD_DEFINITIONS(-D__USE_BOOST_IOSTREAMS) + #ADD_DEFINITIONS(-D__USE_BOOST_IOSTREAMS) + endif() + if(Boost_FILESYSTEM_FOUND) + message(STATUS "Boost::filesystem found --> building with boost::filesystem enabled.") + ADD_DEFINITIONS(-D__USE_BOOST_FILESYSTEM) endif() +else() + message(STATUS "Boost not found.") endif() +#---------------------------------------------------------------------------- +# Find CADMesh libraries +set(cadmesh_LIBRARIES "") +find_package(cadmesh QUIET) +if(cadmesh_FOUND) + # Pretty sure at some point cadmesh will update to use lowercase + include_directories(${CADMESH_INCLUDE_DIRS}) + include_directories(${cadmesh_INCLUDE_DIRS}) + link_directories(${cadmesh_LIBRARY_DIR}) + ADD_DEFINITIONS(-D__USE_CADMESH) + + find_path(TETGEN_INCLUDE_DIRS tetgen.h + PATHS + $ENV{TETGEN_PATH} + $ENV{TETGEN_PATH}/tetgen + /usr/local/include + /usr/include) + find_library(TETGEN_LIBRARIES NAMES tetgen tet + PATHS + $ENV{TETGEN_PATH} + $ENV{TETGEN_PATH}/tetgen + /usr/local/lib + /usr/lib) + if(TETGEN_INCLUDE_DIRS) + if(TETGEN_LIBRARIES) + include_directories(${TETGEN_INCLUDE_DIRS}) + ADD_DEFINITIONS(-D__USE_CADMESH_TETGEN) + endif() + endif() + + find_package(assimp QUIET) + if(assimp_FOUND) + include_directories(${ASSIMP_INCLUDE_DIRS}) + ADD_DEFINITIONS(-D__USE_CADMESH_ASSIMP) + endif() +endif() #---------------------------------------------------------------------------- # Find Geant4 package, activating all available UI and Vis drivers by default @@ -196,6 +251,7 @@ target_link_libraries(lib${PROJECT_NAME} ${Boost_LIBRARIES} ${HEPMC_LIBRARIES} ${PYTHIA6_LIBRARIES} + ${cadmesh_LIBRARIES} ) install(TARGETS lib${PROJECT_NAME} @@ -305,74 +361,76 @@ set(REMOLL_LOCATION /group/halla/www/hallaweb/html/12GeV/Moller/downloads/remoll set(REMOLL_DOWNLOADS http://hallaweb.jlab.org/12GeV/Moller/downloads/remoll/) set(REMOLL_MAP_DIR ${PROJECT_SOURCE_DIR}/map_directory) if(EXISTS ${REMOLL_LOCATION}) - message(STATUS "Copying files directly from directory...") + message(STATUS "Fieldmaps will be copied from directory...") set(REMOLL_DOWNLOADS file://${REMOLL_LOCATION}) else() message(STATUS "Fieldmaps will be downloaded from web...") endif() -file(DOWNLOAD - ${REMOLL_DOWNLOADS}/hybridJLAB.txt - ${REMOLL_MAP_DIR}/hybridJLAB.txt - EXPECTED_MD5 c2da18fd7ab80cc4abe7eafc487963dc - ) -file(DOWNLOAD - ${REMOLL_DOWNLOADS}/upstreamJLAB_1.25.txt - ${REMOLL_MAP_DIR}/upstreamJLAB_1.25.txt - EXPECTED_MD5 af06ed35516c17640e89ba3aa0f5b200 - ) -file(DOWNLOAD - ${REMOLL_DOWNLOADS}/hybridJLAB_v2.txt - ${REMOLL_MAP_DIR}/hybridJLAB_v2.txt - EXPECTED_MD5 4a0d1abc9b80cf5f2c3dd495a1133e26 - ) -file(DOWNLOAD - ${REMOLL_DOWNLOADS}/segmentedJLAB_v2.txt - ${REMOLL_MAP_DIR}/segmentedJLAB_v2.txt - EXPECTED_MD5 2a21b540f6496e3f554302f369646bbb - ) -file(DOWNLOAD - ${REMOLL_DOWNLOADS}/upstreamJLAB_v2.txt - ${REMOLL_MAP_DIR}/upstreamJLAB_v2.txt - EXPECTED_MD5 bed73f2ea44135c52222bc8e767e1954 - ) -install(FILES - ${REMOLL_MAP_DIR}/hybridJLAB.txt - ${REMOLL_MAP_DIR}/upstreamJLAB_1.25.txt - ${REMOLL_MAP_DIR}/hybridJLAB_v2.txt - ${REMOLL_MAP_DIR}/segmentedJLAB_v2.txt - ${REMOLL_MAP_DIR}/upstreamJLAB_v2.txt - DESTINATION ${CMAKE_INSTALL_DATADIR}/remoll) +if(Boost_IOSTREAMS_FOUND) + message(STATUS "Gzipped fieldmaps will be made available...") +endif() +# for i in *.txt ; do echo `md5sum $i|awk '{print$1}'`:`md5sum $i.gz|awk '{print$1}'`:$i ; done +set(REMOLL_MAPS +b8b30b803bae42f69135323ff40fe7db:99bf3fae83677c6c2f3e09a871682b2e:V2U.1a.50cm.parallel.txt +d5f568675ca29e295c1013617a2dc092:b3e031ce9d97fa5331ec39e8903817e6:V2DSg.9.75cm.parallel.txt +) +set(REMOLL_MAPS_EXTRA +1c79bc83e4da5e9d5e44338e28ce6ebe:c7591d167ca56e871e8e5eeecab2872c:V2DSg.9.75cm.txt +f768447f761b9bf01af7c57e249d1d8a:94ec0017b21fc56d9d8084d68e479fd5:V2U.1a.50cm.txt +b1b8f2845dc5cd420c6ff49ae7760a60:6002f6f5f092346cb2bdedac046d1905:V1U.2a.txt +70e2bbed1831816957e953bba48f01d5:2fd1cd2785db92f9c880b675890460b5:V2U.1a.txt +e55ffd8aba96cbf24962155d3c7f75e4:0172016c988867b0928258d79cd1c865:V2U.1b.txt +eb802b9d8569669b5aa674fc56c52a24:df7f4dd87c894c5eef878b248ef14c3e:V1DSg.3.txt +c71758450b063ab83e95a7ba8c590885:a5ba5c81c0c6590d43fac1cbd3f2d7a0:V2DSg.1a.txt +c2ac33287df1bf20bfedcb4d4a96c8d5:3a31416eb7659248f7a2ba582d43a6fe:V2DSg.1b.txt +ca69d4a4397ae3a944f603b91dfbe586:36e2aa90d39e4ad9be4f747a522baa69:V1DHy.3.txt +259459226a5cacc1d62ba295534645e2:95c6193ea30c03316068e3d67d3ec32b:V2DHy.1.txt +b4bfef8f362e0df66f166b4e76a6847e:57a7719eb877572751f4c4b481d6a788:blockyHybrid_rm_3.0.txt +7df29e47413c8dd69fd179298f11b717:9120bc05099a144916467b6ea17e39f8:blockyUpstream_rm_1.1_noscale.txt +3e2338e1ba74b03da37545e98931f5f3:75dfcd912e74f42543892fed8271fa7c:blockyUpstream_rm_1.1.txt +c2da18fd7ab80cc4abe7eafc487963dc:112a466bf5dc2ef4dd24b935767a0540:hybridJLAB.txt +4a0d1abc9b80cf5f2c3dd495a1133e26:a8f5875a4ef0c27c63f31cf7395b13f0:hybridJLAB_v2.txt +0f6e9a3a8392d01c63f1609afc4e4c09:996a6581de9d3c331398bb85ef955a15:hybridSymmetric_sensR_0.0.txt +78fad2ffa5b5ae129df11bdf0ce25333:f21fb19507197baba3658885315c9a6e:hybridSymmetric_sensR_0.1.txt +2a21b540f6496e3f554302f369646bbb:fb95664f9bdba1c22ad28eb21bd1c9fb:segmentedJLAB_v2.txt +af06ed35516c17640e89ba3aa0f5b200:b8009dc61a17eea1d884f0c746f6922c:upstreamJLAB_1.25.txt +bed73f2ea44135c52222bc8e767e1954:f50ce73289174ada019977f2dec87cb6:upstreamJLAB_v2.txt +4ca3d968cadd85a89b86148411eda678:ce0a41b96a5937978aa9f30155fab610:upstreamSymmetric_sensR_0.0.txt +849d9dc5abab0842fc13fef7f4918648:4a8c457385f179a036fffca4ae8e2cb0:upstreamSymmetric_sensR_0.1.txt +) if(ADDITIONAL_FIELDS) - message(STATUS "Ensuring additional fields are available") - file(DOWNLOAD - ${REMOLL_DOWNLOADS}/blockyUpstream_rm_1.1.txt - ${REMOLL_MAP_DIR}/blockyUpstream_rm_1.1.txt - EXPECTED_MD5 3e2338e1ba74b03da37545e98931f5f3 - ) - file(DOWNLOAD - ${REMOLL_DOWNLOADS}/blockyHybrid_rm_3.0.txt - ${REMOLL_MAP_DIR}/blockyHybrid_rm_3.0.txt - EXPECTED_MD5 b4bfef8f362e0df66f166b4e76a6847e - ) - file(DOWNLOAD - ${REMOLL_DOWNLOADS}/upstreamSymmetric_sensR_0.1.txt - ${REMOLL_MAP_DIR}/upstreamSymmetric_sensR_0.1.txt - EXPECTED_MD5 849d9dc5abab0842fc13fef7f4918648 - ) - file(DOWNLOAD - ${REMOLL_DOWNLOADS}/hybridSymmetric_sensR_0.1.txt - ${REMOLL_MAP_DIR}/hybridSymmetric_sensR_0.1.txt - EXPECTED_MD5 78fad2ffa5b5ae129df11bdf0ce25333 - ) - install(FILES - ${REMOLL_MAP_DIR}/blockyHybrid_rm_3.0.txt - ${REMOLL_MAP_DIR}/blockyUpstream_rm_1.1.txt - ${REMOLL_MAP_DIR}/upstreamSymmetric_sensR_0.1.txt - ${REMOLL_MAP_DIR}/hybridSymmetric_sensR_0.1.txt - DESTINATION ${CMAKE_INSTALL_DATADIR}/remoll) + message(STATUS "Ensuring additional fields are available.") else() message(STATUS "Download additional fields with '-DADDITIONAL_FIELDS=ON'.") + set(REMOLL_MAPS_EXTRA "") endif() +foreach(MAP IN LISTS REMOLL_MAPS REMOLL_MAPS_EXTRA) + set(REGEX "^(.*):(.*):(.*)$") + # Hash 1: txt file, Hash 2: txt.gz file + string(REGEX REPLACE ${REGEX} "\\1" HASH1 ${MAP}) + string(REGEX REPLACE ${REGEX} "\\2" HASH2 ${MAP}) + string(REGEX REPLACE ${REGEX} "\\3" FILE ${MAP}) + if(Boost_IOSTREAMS_FOUND) + file(DOWNLOAD + ${REMOLL_DOWNLOADS}/${FILE}.gz + ${REMOLL_MAP_DIR}/${FILE}.gz + EXPECTED_MD5 ${HASH2} + ) + install(FILES + ${REMOLL_MAP_DIR}/${FILE}.gz + DESTINATION ${CMAKE_INSTALL_DATADIR}/remoll/map_directory) + endif() + #else() + file(DOWNLOAD + ${REMOLL_DOWNLOADS}/${FILE} + ${REMOLL_MAP_DIR}/${FILE} + EXPECTED_MD5 ${HASH1} + ) + install(FILES + ${REMOLL_MAP_DIR}/${FILE} + DESTINATION ${CMAKE_INSTALL_DATADIR}/remoll/map_directory) + #endif() +endforeach() #---------------------------------------------------------------------------- @@ -383,6 +441,13 @@ install(FILES ${PROJECT_SOURCE_DIR}/cmake/scripts/RemollUseFile.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/remoll) +#---------------------------------------------------------------------------- +# remollSearchPath + +add_definitions( + -DCMAKE_INSTALL_PREFIX=\"${CMAKE_INSTALL_PREFIX}\" + -DCMAKE_INSTALL_FULL_DATADIR=\"${CMAKE_INSTALL_FULL_DATADIR}\" +) #---------------------------------------------------------------------------- # uninstall diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md new file mode 100644 index 000000000..92555a18f --- /dev/null +++ b/CONTRIBUTORS.md @@ -0,0 +1,24 @@ +# Contributors + +This project would not have been possible without the hard work +of many contributors (in alphabetical order): + +- Kurtis Bartlett (kdbartlett) +- Raktiha Beminiwattha (rakithab) +- Devika Bhatta Pathak (devika123) +- Chanda Bindu (chandabindu) +- Cameron Clarke (cameronc137) +- Wouter Deconinck (wdconinc) +- Daniel De Layo (danieldelayo) +- Audrey Farrell (acfarrell) +- Catherine Feldman (catherinef37) +- Ciprian Gal (cipriangal) +- Valerie Gray (vmgray) +- Nicholas Hirlinger Saylor (hirlingersaylor) +- Dominic Lunde (dclunde) +- Juliette Mammei (jmammei) +- Scott Mundy (scmundy) +- Sakib Rahman (rahmans1) +- Seamus Riordan (seamusriordan) +- Rupesh Silwal (silwalr) +- Erik Stevenson (eriknstevenson) diff --git a/Dockerfile b/Dockerfile index addc6e4f1..fe948675a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,21 +18,16 @@ # cd `readlink -f .` # -FROM jeffersonlab/jlabce:2.3-mt +FROM jeffersonlab/remoll-builder:main -# Install libgcj and pdftk -RUN wget -q https://copr.fedorainfracloud.org/coprs/robert/gcj/repo/epel-7/robert-gcj-epel-7.repo -P /etc/yum.repos.d && \ - wget -q https://copr.fedorainfracloud.org/coprs/robert/pdftk/repo/epel-7/robert-pdftk-epel-7.repo -P /etc/yum.repos.d && \ - yum install -q -y pdftk ghostscript +# XrootD +RUN yum --enablerepo=extras -y install epel-release +RUN yum -y install python3-pip \ + xrootd-client -# Add Tini entry point -ENV TINI_VERSION v0.19.0 -ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini -RUN chmod +x /tini - -# Set JLab CE version -ENV JLAB_VERSION=2.3 -ENV JLAB_ROOT=/jlab +# Stashcp +RUN pip3 install setuptools && \ + pip3 install stashcp # Set remoll location ENV REMOLL=/jlab/remoll @@ -48,14 +43,6 @@ RUN source /etc/profile && \ make install && \ make clean -# Environment through /etc/profile -RUN ln -sf $REMOLL/bin/remoll.csh /etc/profile.d/remoll.csh -RUN ln -sf $REMOLL/bin/remoll.sh /etc/profile.d/remoll.sh - -# Override JLab CE environment for container use -COPY docker/jlab.sh /jlab/${JLAB_VERSION}/ce/jlab.sh - # Entry point loads the environment -ENTRYPOINT ["/tini", "--", "bash", "-c", "source /etc/profile && \"$@\"", "-s"] - +ENTRYPOINT ["/bin/bash", "-c", "source /etc/profile && source $REMOLL/bin/remoll.sh && \"$@\"", "--"] CMD ["remoll"] diff --git a/README.md b/README.md index 03cb474ef..996ead8fd 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Simulations for the MOLLER Experiment at Jefferson Lab -[![Build Status](http://travis-ci.org/JeffersonLab/remoll.svg?branch=develop)](https://travis-ci.org/JeffersonLab/remoll) +[![Build Status](https://github.com/JeffersonLab/remoll/actions/workflows/docker-image.yml/badge.svg?branch=develop)](https://github.com/JeffersonLab/remoll/actions/workflows/docker-image.yml) ## Community diff --git a/README.replay.md b/README.replay.md new file mode 100644 index 000000000..a800906a7 --- /dev/null +++ b/README.replay.md @@ -0,0 +1,52 @@ +## Replaying simulated events + +These instructions explain how to replay exactly some previously simulated events. + +### Run the original large-N simulations + +Not every simulation output file can automatically be used to replay certain events. + +You must enable storing the random seed status for each event. This is done by default on recent versions of remoll, but on older versions you will need to run with the following flag enabled: +``` +/run/storeRndmStatToEvent 1 +``` + +### Select events of interest + +Now, we select a small-ish number of events in the ROOT tree. You will need to use `reroot` for this. + +Example: + +Suppose you have identified that all events in the following histogram are of interest for replaying: +``` +T->Draw("hit.r","hit.det==8001 && hit.pid!=22 && hit.trid>2 && hit.r<1100*mm") +``` +You can now tell ROOT to write out the random engine state files for those events: +``` +T->Draw("hit.r*seed.Save()","hit.det==8001 && hit.pid!=22 && hit.trid>2 && hit.r<1100*mm") +``` +The `seed.Save()` function always just returns 1, and writes the random engine state files. + +You should end up with a bunch of files with names like `run0evt118.state`. + +### Convert random state file format + +Next, we convert the state files into a different file format and set them up to go to individual runs. This will allow you to click through them one by one. +``` +scripts/convert-mixmaxrng-states-to-runs.sh run0evt*.state +``` +You should end up with a bunch of files with names like `run0evt0.rndm`, `run1evt0.rndm`, etc. They will all be event number 0 in consecutive runs. + +Note that the wildcard will sort alphabetically, not by event number, so it will sort `run0evt225.state` before `run0evt31.state`. That is the order that the `run0evt0.rndm`, `run1evt0.rndm` files will be in. + +### Replay the events in remoll + +Finally, start remoll interactively and execute exactly the same setup as in the first step: same geometry, physics list, etc. + +Before starting an actual event simulation, tell it to load the `run0evt0.rndm`, `run1evt0.rndm` files with +``` +/random/resetEngineFromEachEvent 1 +``` +Now you can rerun each event again with `/run/beamOn 1`, or the play button on the graphical interface. Whenever it is starting a new run (of 1 event, in this case) and a new event, it will first check for the `run0evt0.rndm`, `run1evt0.rndm` files. + +Note: If you click play beyond the end of any stored events, it will just generate regular random events (and it will not warn you about this). diff --git a/analysis/CMakeLists.txt b/analysis/CMakeLists.txt index d594d8e6d..c344ee330 100644 --- a/analysis/CMakeLists.txt +++ b/analysis/CMakeLists.txt @@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 2.6 FATAL_ERROR) project(analysis) add_subdirectory(pe) +add_subdirectory(bkgd_pe) add_subdirectory(hallRad) add_subdirectory(pruneTreeEnvelope) add_subdirectory(rad_dose) diff --git a/analysis/bkgd_pe/CMakeLists.txt b/analysis/bkgd_pe/CMakeLists.txt new file mode 100755 index 000000000..dfb4ad5fe --- /dev/null +++ b/analysis/bkgd_pe/CMakeLists.txt @@ -0,0 +1,74 @@ +#---------------------------------------------------------------------------- +# Setup the project +# +cmake_minimum_required(VERSION 2.6 FATAL_ERROR) +project(bkgd_pe) + +# Default install path is the source directory +if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + message(STATUS " Install-prefix was at default -> forcing it to the source-dir" ) + message(STATUS " Use -DCMAKE_INSTALL_PREFIX=/usr/local to set to something else" ) + set (CMAKE_INSTALL_PREFIX "${CMAKE_SOURCE_DIR}" + CACHE PATH "default install path" FORCE ) +endif() + +# Use GNU install dirs +include(GNUInstallDirs) + +list(APPEND CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}") + +find_package(Remoll REQUIRED HINTS "${PROJECT_SOURCE_DIR}/../..") +include(${REMOLL_USE_FILE}) +list(APPEND CMAKE_INSTALL_RPATH "${REMOLL_LIBRARY_DIR}") + +list(APPEND CMAKE_INSTALL_RPATH "${REMOLL_LIBRARY_DIR}/../..") + +find_package(ROOT REQUIRED) +include(${ROOT_USE_FILE}) +list(APPEND CMAKE_INSTALL_RPATH "${ROOT_LIBRARY_DIR}") + + +#---------------------------------------------------------------------------- +# generate dictionaries +# +ROOT_GENERATE_DICTIONARY( + bkgd_peDict # path to dictionary to generate + "include/bkgd_petypes.hh" # list of classes to process + LINKDEF "include/bkgd_peLinkDef.h" # ROOT linkDef file + OPTIONS -p +) + +#---------------------------------------------------------------------------- +# +include_directories(${PROJECT_SOURCE_DIR}/include ${REMOLL_INCLUDE_DIR}) + +#---------------------------------------------------------------------------- +# Locate sources and headers for this project +# NB: headers are included so they will show up in IDEs +# +file(GLOB sources ${PROJECT_SOURCE_DIR}/src/bkgd_pe*.cc) +file(GLOB headers ${PROJECT_SOURCE_DIR}/include/bkgd_pe*.hh) + +#---------------------------------------------------------------------------- +# Add the executable, and link it to the Geant4 libraries +# +#---------------------------------------------------------------------------- +# Generate dictionaries as well (so we can write objects to ROOT files +# +add_library(bkgd_pe-lib SHARED ${sources} ${headers} bkgd_peDict.cxx) +set_target_properties(bkgd_pe-lib PROPERTIES OUTPUT_NAME bkgd_pe) +target_link_libraries(bkgd_pe-lib ${ROOT_LIBRARIES} ${REMOLL_LIBRARIES}) + +add_executable(bkgd_pe-bin bkgd_pe.cc) +set_target_properties(bkgd_pe-bin PROPERTIES OUTPUT_NAME bkgd_pe) +target_link_libraries(bkgd_pe-bin ${REMOLL_LIBRARIES} bkgd_pe-lib) + +#---------------------------------------------------------------------------- +# +add_custom_target(bkgd_pe DEPENDS bkgd_pe-bin) + +#---------------------------------------------------------------------------- +# Install the executable to 'bin' directory under CMAKE_INSTALL_PREFIX +# +install(TARGETS bkgd_pe-bin DESTINATION ${CMAKE_INSTALL_BINDIR}) +install(TARGETS bkgd_pe-lib DESTINATION ${CMAKE_INSTALL_LIBDIR}) diff --git a/analysis/bkgd_pe/bkgd_pe.cc b/analysis/bkgd_pe/bkgd_pe.cc new file mode 100644 index 000000000..c50fead67 --- /dev/null +++ b/analysis/bkgd_pe/bkgd_pe.cc @@ -0,0 +1,972 @@ +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "TTree.h" +#include "TFile.h" +#include "remolltypes.hh" +#include "bkgd_petypes.hh" +#include "bkgd_pe.hh" + +#define pi 3.141592653589793238462643383279502884L + +class bkgd { + public: + int do_pe(int, char**); + void set_plot_style(); + int get_lookuptable(); + void bkgd_pe_ana(); + void bkgd_pePlots(int, char **); + private: + std::string fileString = "tracking.root"; + std::string detName = "R5o"; + std::string anaStr = "backgrounds"; + double current = 65.0; + double degeneracy = 50.0; + double user_angle = 0.0; + double user_x_pos = 0.0; + double user_reflectivity = 0.7; + double user_cerenkov = 1.0; + double user_scintillation = 1.0; + double user_z_pos = 0.0; + double N_entries = 0; + //std::string varString = "reflectorAngle"; + //std::string unitString = "deg"; + bool reana = true; + int detid=540210; + + TH2D* lookupTable; + TH2D* lookupTableReference; + TH2D* lookupTableLog; + TH2D* lookupTableFlat; +}; + +int bkgd::get_lookuptable() +{ + TFile* old_file; + TTree* oldtree; + /*double oldx_pos = 0.0; + double oldangle = 0.0; + double oldavg = 0.0; + double oldavg_err = 0.0; + double oldrms = 0.0; + double oldrms_err = 0.0; + double oldres = 0.0; + double oldN_en = 0.0; + double oldreflectivity = 0.0; + double oldcerenkov = 0.0; + double oldscintillation = 0.0; + double oldz_pos = 0.0;*/ + // FIXME + if (!gSystem->AccessPathName(Form("scans_%s.root",detName.c_str()))) { + // Old file exists, read it and add new entries + old_file = TFile::Open(Form("scans_%s.root",detName.c_str())); + old_file->GetObject("scans", oldtree); + if (!oldtree) { + std::cout << "ERROR: Dead scans tree" ; + return 0; + } + int nent = oldtree->GetEntries(); + } + else { + Printf("Error, no scans_%s.root file available, please place the look-up-table data there",detName.c_str()); + return 0; + } + // Draw a TGraph, GOFF mode, obtain the output vectors and loop over them, filling in a low/up bin edge array with the means of neighboring bin centers, if it's an edge then calculate distance from opposite side and add that off to the side. + // Include in cut avg_pes != 0 (i.e. not some glitch) + // Make a new TH2 hist with Nentries from tgraph and bin low/highs in angle and x_pos from above exercise + + TH1* tmpHist; + //TGraph* tmpGraph; + // + const Int_t refnPoints = oldtree->Draw("angle:10*abs(x_pos):avg_pes","avg_pes!=0","goff"); + //const Int_t nPoints = oldtree->Draw("angle:10*(x_pos)-960.0-215.0:avg_pes","angle>-23 && angle<23 && avg_pes!=0 && scintillation==1 && cerenkov==1 && reflectivity==0.7","goff"); + Double_t* ref_local_angle_points = oldtree->GetV1(); + Double_t* ref_local_x_pos_points = oldtree->GetV2(); + Double_t ref_x_pos = ref_local_x_pos_points[(int) refnPoints/2]; // Just take the first entry and hope it is good enough :/ + Double_t ref_angle = ref_local_angle_points[(int) refnPoints/2]; + std::cout<< "Using reference X = " << ref_x_pos << ", and reference angle = " << ref_angle << " to determine lookup table binning info" << std::endl; + + const Int_t nAngles = oldtree->Draw("angle",Form("10*abs(x_pos)==%f",ref_x_pos),"goff"); + //const Int_t nAngles = oldtree->Draw("angle","angle>-23 && angle<23 && x_pos==1.0 && avg_pes!=0 && scintillation==1 && cerenkov==1 && reflectivity==0.7","goff"); + Double_t* angle_points1 = oldtree->GetV1(); + Double_t* angle_points = new Double_t[nAngles+1]; + Int_t* angle_indices = new Int_t[nAngles]; + TMath::Sort(nAngles,angle_points1,angle_indices,kFALSE); + for (Int_t j = 0 ; j < nAngles; j++) { + angle_points[j] = angle_points1[angle_indices[j]]; + std::cout<< "Bin angle point = " << angle_points[j] << std::endl; + } + + const Int_t nXpos = oldtree->Draw("10*abs(x_pos)",Form("angle==%f",ref_angle),"goff"); + //const Int_t nXpos = oldtree->Draw("10*(x_pos)-960.0-215.0","angle==0.0 && avg_pes!=0 && scintillation==1 && cerenkov==1 && reflectivity==0.7","goff"); + Double_t* x_pos_points1 = oldtree->GetV1(); + Double_t* x_pos_points = new Double_t[nXpos+1]; + Int_t* x_pos_indices = new Int_t[nXpos]; + TMath::Sort(nXpos,x_pos_points1,x_pos_indices,kFALSE); + for (Int_t j = 0 ; j < nXpos; j++) { + x_pos_points[j] = x_pos_points1[x_pos_indices[j]]; + std::cout<< "Bin x point = " << x_pos_points[j] << std::endl; + } + x_pos_points[nXpos] = x_pos_points[nXpos-1] + ( x_pos_points[nXpos-1] - x_pos_points[nXpos-2] ); + angle_points[nAngles] = angle_points[nAngles-1] + ( angle_points[nAngles-1] - angle_points[nAngles-2] ); + std::cout<< "Last bin x point = " << x_pos_points[nXpos] << std::endl; + std::cout<< "Last bin angle point = " << angle_points[nAngles] << std::endl; + + lookupTable = new TH2D("lookupTable","lookupTable",nAngles,angle_points,nXpos,x_pos_points); + lookupTableReference = new TH2D("lookupTableReference","lookupTableReference",nAngles,angle_points,nXpos,x_pos_points); + lookupTableLog = new TH2D("lookupTableLog","lookupTableLog",nAngles,angle_points,nXpos,x_pos_points); + lookupTableFlat = new TH2D("lookupTableFlat","lookupTableFlat",nAngles,angle_points,nXpos,x_pos_points); + + const Int_t nPoints = oldtree->Draw("angle:10*abs(x_pos):avg_pes","avg_pes!=0","goff"); + Double_t* local_angle_points = oldtree->GetV1(); + Double_t* local_x_pos_points = oldtree->GetV2(); + Double_t* avg_pes_points = oldtree->GetV3(); + + for (Int_t i = 0 ; i < nPoints ; i++ ) { + std::cout<< "Filling lookup table with point: 10*abs(x_pos) = " << local_x_pos_points[i] << ", x bin " << lookupTable->GetYaxis()->FindBin(local_x_pos_points[i]) << ", angle = " << local_angle_points[i] << ", angle bin " << lookupTable->GetXaxis()->FindBin(local_angle_points[i]) << ", pe value = " << avg_pes_points[i] << std::endl; + lookupTable->Fill(local_angle_points[i],local_x_pos_points[i],avg_pes_points[i]); + lookupTableReference->Fill(local_angle_points[i],local_x_pos_points[i],avg_pes_points[i]); + lookupTableLog->Fill(local_angle_points[i],local_x_pos_points[i],TMath::Log(avg_pes_points[i])); + // Unweighted, so the weighted one can have its bins re-normalized if any are filled with more than one point (I know, it is cheating the definition of a histogram, but lookup tables are hard in ROOT). + lookupTableFlat->Fill(local_angle_points[i],local_x_pos_points[i],1); + } + Double_t localBinContent = 0.0; + Double_t localFlatBinContent = 0.0; + + for (Int_t i = 0 ; i < nPoints ; i++ ) { + //std::cout << "Angle bin = " << lookupTableReference->GetXaxis()->FindBin(local_angle_points[i]) << " x_pos bin = " << lookupTableReference->GetYaxis()->FindBin(local_x_pos_points[i]) << " of x = " << local_x_pos_points[i] << std::endl; + localBinContent = (Double_t)lookupTableReference->GetBinContent(lookupTableReference->GetXaxis()->FindBin(local_angle_points[i]),lookupTableReference->GetYaxis()->FindBin(local_x_pos_points[i])); + localFlatBinContent = (Double_t)lookupTableFlat->GetBinContent(lookupTableFlat->GetXaxis()->FindBin(local_angle_points[i]),lookupTableFlat->GetYaxis()->FindBin(local_x_pos_points[i])); + if (localFlatBinContent > 1) { + std::cout<< "Checking double-filling: was " << localBinContent << ", with " << localFlatBinContent << " points at 10*(x_pos) = " << local_x_pos_points[i] << ", angle = " << local_angle_points[i] << ", pe value = " << avg_pes_points[i] << std::endl; + // Normalize each bin the be the true average of whatever was thrown into it. + //lookupTable->SetBinContent(lookupTable->GetBin(lookupTable->GetXaxis()->FindBin(local_angle_points[i]),lookupTable->GetYaxis()->FindBin(local_x_pos_points[i])),avg_pes_points[i]); + lookupTable->SetBinContent(lookupTable->GetBin(lookupTable->GetXaxis()->FindBin(local_angle_points[i]),lookupTable->GetYaxis()->FindBin(local_x_pos_points[i])),localBinContent/localFlatBinContent); + //lookupTable->SetBinContent(local_angle_points[i],local_x_pos_points[i],localBinContent/localFlatBinContent); + std::cout << "now = " << (Double_t)lookupTable->GetBinContent(lookupTable->GetXaxis()->FindBin(local_angle_points[i]),lookupTable->GetYaxis()->FindBin(local_x_pos_points[i])) << std::endl ; + } + } + TCanvas * c1 = new TCanvas(); + c1->cd(); + lookupTableLog->SetName(Form("Look Up Table - Log(Avg PEs)")); + lookupTableLog->SetTitle(Form("Look Up Table - Log(Avg PEs)")); + lookupTableLog->SetXTitle(Form("Angle (degrees)")); + lookupTableLog->SetYTitle(Form("Radial hit position (mm)")); + lookupTableLog->Draw("COLZ"); + c1->SaveAs(Form("lookupTable_%s.pdf(",detName.c_str())); + TCanvas * c2 = new TCanvas(); + c2->cd(); + lookupTable->SetName(Form("Look Up Table - Avg PEs")); + lookupTable->SetTitle(Form("Look Up Table - Avg PEs")); + lookupTable->SetXTitle(Form("Angle (degrees)")); + lookupTable->SetYTitle(Form("Radial hit position (mm)")); + lookupTable->Draw("COLZ"); + c2->SaveAs(Form("lookupTable_%s.pdf)",detName.c_str())); + delete c1; + delete c2; + return 1; +} + +void bkgd::set_plot_style() +{ + const Int_t NRGBs = 5; + const Int_t NCont = 255; + // See class TColor documentation and SetPalette() command + Double_t stops[NRGBs] = { 0.00, 0.34, 0.61, 0.84, 1.00 }; + Double_t red[NRGBs] = { 0.00, 0.00, 0.87, 1.00, 0.51 }; + Double_t green[NRGBs] = { 0.00, 0.81, 1.00, 0.20, 0.00 }; + Double_t blue[NRGBs] = { 0.51, 1.00, 0.12, 0.00, 0.00 }; + TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont); + gStyle->SetNumberContours(NCont); +} + + +void bkgd::bkgd_pe_ana() +{ + TTree::SetMaxTreeSize(Long64_t(1024)*1024*1024*200); //200 GB tree + Double_t asymmetry = 0.0; + Double_t rate = 0.0; + remollEvent_t *fEvent = 0; + /*double A, Am; + double xs; + double Q2, W2; + double thcom; + double beamp;*/ + std::vector < remollGenericDetectorHit_t > *fHit = 0; + std::vector < remollEventParticle_t > *fPart = 0; + int dotPos = fileString.rfind("."); + std::ostringstream os; + os << anaStr << "_" << fileString.substr(0, dotPos) << "_PEs_"<<"det_"<Get("T"); + TFile *newFile = new TFile(fileName.c_str(),"RECREATE", "", 1); + + TTree* newTree = new TTree("T", "Tree of detector hits"); + oldTree->SetBranchAddress("ev", &fEvent); + oldTree->SetBranchAddress("rate", &rate); + oldTree->SetBranchAddress("hit", &fHit); + oldTree->SetBranchAddress("part", &fPart); + std::vector < simPEs_t > *simPEs = new std::vector < simPEs_t > ; + std::vector < simPEs_t > *simRPEs = new std::vector < simPEs_t > ; + std::vector < simPEs_t > *simAPEs = new std::vector < simPEs_t > ; + std::vector < catPEs_t > *catPEs = new std::vector < catPEs_t > ; + std::vector < Q_t > *Q = new std::vector < Q_t > ; + std::vector < Ref_t > *Ref = new std::vector < Ref_t > ; + std::vector < RefX_t > *RefX = new std::vector < RefX_t > ; + std::vector < Refair_t > *Refair = new std::vector < Refair_t > ; + std::vector < LG_t > *LG = new std::vector < LG_t > ; + std::vector < LGair_t > *LGair = new std::vector < LGair_t > ; + std::vector < PMTcat_t > *PMTcat = new std::vector < PMTcat_t > ; + std::vector < PMTbulk_t > *PMTbulk = new std::vector < PMTbulk_t > ; + std::vector < elseX_t > *elseX = new std::vector < elseX_t > ; + std::vector eTRID; + std::vector DETID; + std::vector PID; + std::vector MTRID; + std::vector peTRID; + double peNumber; + double peRateWeighting; + double peAsymmetryWeighting; + + int Qcounted = 0; + int Refaircounted = 0; + int LGaircounted = 0; + int PMTbulkcounted = 0; + int detSourcedPEs = 0; + double peN_entries = 0; + + //TODO reading data into envelopes downstream could be sped up + //by storing the data by Z instead of by hit + + newTree->Branch("nentries", &peN_entries); + newTree->Branch("simpes", &simPEs); + newTree->Branch("simRpes", &simRPEs); + newTree->Branch("simApes", &simAPEs); + newTree->Branch("catpes", &catPEs); + newTree->Branch("q", &Q); + newTree->Branch("ref", &Ref); + newTree->Branch("refx", &RefX); + newTree->Branch("refair", &Refair); + newTree->Branch("lg", &LG); + newTree->Branch("lgair", &LGair); + newTree->Branch("pmtcat", &PMTcat); + newTree->Branch("pmtbulk", &PMTbulk); + newTree->Branch("else", &elseX); + + Double_t lookup = 0.0; + Int_t lookupAngle = 0; + Int_t lookupXpos = 0; + + for (size_t j = 0; j < oldTree->GetEntries(); j++) + { + if (j%10000 == 0) + { + std::cerr << "\r" << j << "/" << oldTree->GetEntries() << " - " << (j*1.0)/oldTree->GetEntries() * 100 << "%"; + } + + oldTree->GetEntry(j); + remollEvent_t event = *fEvent; + //std::cout << "Hits: " << fHit->size() << std::endl; + //std::cout << "Parts: " << fPart->size() << std::endl; + //std::vector x, y, z, px, py, pz, p, e, m, vx, vy, vz; + std::vector cathitx, cathity, cathitz; + // Log which electron track IDs (and other info) hit which detectors, and which PE IDs hit the cathode and where + // Attribute all npe counts and cathode hit positions to all DETID branches that are hit during that event (in lieu of getting photon birth vertex properly down) + // int npe = 0; // do this as peTRID->Size(); + + for (size_t i = 0; i < fHit->size(); i++) + { + remollGenericDetectorHit_t hit = fHit->at(i); + //Count each optical photon hit in an entry, iff the primary electron hits a detector, also sum accidentals + // Make a root tree out of the amounts (and locations) of photon hits on the various detectors + // Each branch is a different detector that the electron can hit (quartz, wall, air, cathode, PMT, etc.) + // Store the electron hit location and energy, etc. for that hit + // Store the total number of photons that hit the cathode after that electron hit, and their cathode hit info + + // FIXME remove this condition to get results for ALL SIGNAL of any form, not just parent electron hits + if (anaStr == "backgrounds" && (hit.det==detid+4 || hit.det == detid+5) && hit.pid == 11 && hit.mtrid == 0){ // Then this is our primary signal of interest + // if you do mtrid == 1 then you get the delta rays! About a 1% contribution + eTRID.push_back(hit.trid); + DETID.push_back(hit.det); + // FIXME Assumes the detector is alligned along the x axis and so are all particles!! Fails for backscattered particles + lookupAngle = lookupTable->GetXaxis()->FindBin((180.0/TMath::Pi())*asin(((hit.px*abs(hit.x) + hit.py*abs(hit.y))/hit.r)/hit.p)); // Maintain sign convention on angles here... was just hit.px/hit.p before... + lookupXpos = lookupTable->GetYaxis()->FindBin(hit.r); + lookup = lookupTable->GetBinContent(lookupAngle,lookupXpos); + peNumber += lookup; + peRateWeighting += rate*lookup/(current*degeneracy); + peAsymmetryWeighting += event.A*rate*lookup/(current*degeneracy); + if ( lookup == 0.0 ) { + std::cout << "0 PEs" << std::endl; + } + std::cout << anaStr << " PE Hit, rate = " << rate/(current*degeneracy) << ", Asymmetry = " << event.A << ", lookup pe value = " << lookup << ", bin number " << lookupTable->GetBin(lookupAngle,lookupXpos) << ", " << lookupAngle << ", " << lookupXpos << ", angle = " << (180.0/TMath::Pi())*asin(((hit.px*abs(hit.x) + hit.py*abs(hit.y))/hit.r)/hit.p) << ", abs(x_pos) = " << hit.r << ", which yields: " << peRateWeighting << std::endl; + } + if (anaStr == "signals" && (hit.det==detid+1) && hit.pid == 11 && hit.mtrid == 0){ // Then this is our primary signal of interest + // if you do mtrid == 1 then you get the delta rays! About a 1% contribution + eTRID.push_back(hit.trid); + DETID.push_back(hit.det); + lookup = 15.0; + if (detName == "R5o") lookup = 25.0; + peNumber += lookup; + peRateWeighting += rate*lookup/(current*degeneracy); + peAsymmetryWeighting += event.A*rate*lookup/(current*degeneracy); + } + if (hit.det == detid+1) { + // If any particle hits the quartz detector then tell the particle ID and mother ID (so we can keep track of deltas) + PID.push_back(hit.pid); + MTRID.push_back(hit.mtrid); + } + if (hit.pid == 0 && hit.det == detid){ + // This is an optical photon and we want to count ++ if it hits the PMT cathode + peTRID.push_back(hit.trid); + cathitx.push_back(hit.x); + cathity.push_back(hit.y); + cathitz.push_back(hit.z); + } + } + + for (size_t i = 0; i < fHit->size();i++) + { + remollGenericDetectorHit_t hit = fHit->at(i); + for (size_t k = 0; k < eTRID.size(); k++) + { + if (hit.trid == eTRID.at(k)) { // Then this electron hit a detector we should know about and store all of the info and cathode hits too + //std::cout << "electron TRID " << hit.trid << std::endl; + // Make the electron hit info go into the appropriate detector branch + // quartz + if (hit.det == detid+1 && Qcounted==0) { + Q->push_back(QTrim(hit,peTRID.size(),cathitx,cathity,cathitz)); + Qcounted++; + } + // reflector air + if (hit.det == detid+2 && Refaircounted==0) { + Refair->push_back(RefairTrim(hit,peTRID.size(),cathitx,cathity,cathitz)); + Refaircounted++; + } + // reflector skin + if (hit.det == detid+3) { + Ref->push_back(RefTrim(hit,peTRID.size(),cathitx,cathity,cathitz)); + } + // reflector volume + if (hit.det == detid+4) { + RefX->push_back(RefXTrim(hit,peTRID.size(),cathitx,cathity,cathitz)); + } + // light guide air + if (hit.det == detid+6 && LGaircounted==0) { + LGair->push_back(LGairTrim(hit,peTRID.size(),cathitx,cathity,cathitz)); + LGaircounted++; + } + // light guide skin + if (hit.det == detid+5) { + LG->push_back(LGTrim(hit,peTRID.size(),cathitx,cathity,cathitz)); + } + // PMT bulk + if (hit.det == detid+7 && PMTbulkcounted==0) { + PMTbulk->push_back(PMTbulkTrim(hit,peTRID.size(),cathitx,cathity,cathitz)); + PMTbulkcounted++; + } + // PMT cathode + if (hit.det == detid) { + PMTcat->push_back(PMTcatTrim(hit,peTRID.size(),cathitx,cathity,cathitz)); + } + //break; //how is this useful?? I want to muliple count + } + } + } + simPEs->push_back(simPEsTrim(DETID,PID,MTRID,peNumber,cathitx,cathity,cathitz)); + simRPEs->push_back(simPEsTrim(DETID,PID,MTRID,peRateWeighting,cathitx,cathity,cathitz)); + simAPEs->push_back(simPEsTrim(DETID,PID,MTRID,peAsymmetryWeighting,cathitx,cathity,cathitz)); + catPEs->push_back(catPEsTrim(DETID,PID,MTRID,(int)peTRID.size(),cathitx,cathity,cathitz)); + detSourcedPEs=(int)peTRID.size(); + elseX->push_back(elseXTrim(((int)peTRID.size()-detSourcedPEs),cathitx,cathity,cathitz)); + peN_entries = oldTree->GetEntries(); + // FIXME old logic requires hits on the cathode... new flat_parallel detecor just wants any hit + // if (catPEs->size() > 0){} + if (simPEs->size() > 0){ + newTree->Fill(); + } + peNumber=0.0; + peRateWeighting=0.0; + peAsymmetryWeighting=0.0; + Qcounted=0; + Refaircounted=0; + LGaircounted=0; + PMTbulkcounted=0; + detSourcedPEs=0; + eTRID.clear(); + catPEs->clear(); + simPEs->clear(); + simRPEs->clear(); + simAPEs->clear(); + elseX->clear(); + Q->clear(); + Refair->clear(); + Ref->clear(); + RefX->clear(); + LGair->clear(); + LG->clear(); + PMTbulk->clear(); + PMTcat->clear(); + cathitx.clear(); + cathity.clear(); + cathitz.clear(); + DETID.clear(); + PID.clear(); + MTRID.clear(); + peTRID.clear(); + } + newFile = newTree->GetCurrentFile(); + newTree->Write("", TObject::kOverwrite); + newTree->Print(); + old->Close(); + newFile->Close(); +} + +//void pePlots(int argcC, char **argvC, std::string fileString="tracking.root", int detid=540210, std::string variable="reflectorAngle", double varVal=11.5, std::string unit="deg") +void bkgd::bkgd_pePlots(int argcC, char **argvC) +{ + //TApplication theApp("App",&argcC,argvC); + + int dotpos = fileString.rfind(".root"); + std::ostringstream os; + std::ostringstream os2; + os << anaStr << "_" << fileString.substr(0, dotpos) << "_PEs_"<<"det_"<Add(ttemp); + TFile *plotsFile = new TFile(fileNamePlots.c_str(),"RECREATE", "", 1); + TTree* plotsTree = new TTree("T", "Tree of plots"); + plotsFile->cd(); // Is this necessary? + //int nentries = (Int_t)newTree->GetEntries(); + // + Tmol->SetBranchAddress("nentries", &N_entries); + if (Tmol) { + Tmol->GetEntry(0); + } + std::fstream file_out_rms; + std::fstream file_out_integral; + std::ofstream file_out_mean; + std::ofstream file_out_res; + file_out_integral.open("int.csv",std::ofstream::out | std::ofstream::app); + file_out_rms.open("rms.csv",std::ofstream::out | std::ofstream::app); + file_out_mean.open("mean.csv",std::ofstream::out | std::ofstream::app); + file_out_res.open("res.csv",std::ofstream::out | std::ofstream::app); + + //gROOT->SetStyle("Plain"); + //gStyle->SetOptStat(0); + gStyle->SetOptStat("eMR"); + gStyle->SetNumberContours(255); + + set_plot_style(); + + const int n_plots = 15; + //TH1 *Histo[n_plots]; + double integral[n_plots]; + double RMS[n_plots]; + double RMSerror[n_plots]; + double Mean[n_plots]; + double Meanerror[n_plots]; + TCanvas * c1[n_plots]; + + std::string names[n_plots]={ + "Simulated Total Cathode Spectrum per event", + "Simulated Rate-weighted Total Cathode Spectrum per event", + "Simulated Asym-weighted Total Cathode Spectrum per event", + "Total Cathode Spectrum per event", + "Cathode Spectrum from primary signal quartz electrons only", + "Cathode Spectrum from quartz deltas", + "Cathode Spectrum from all non-primary quartz signals", + "e- hit radial hit spectrum on the reflector", // Consider adding photon xyz tracking too - would have to go beside the cathode xyz tracking feature + "e- hit radial hit spectrum on the quartz-reflector holder", + "Cathode Spectrum from the reflector air", + "e- hit radial spectrum on the light guide walls", + "Cathode Spectrum from the light guide air", + "e- hit radial spectrum in the PMT bulk", + "e- hit spectrum in the cathode", + "Cathode Spectrum from elsewhere"}; + std::string draws[n_plots]={ + "simpes.npes", + "simRpes.npes", + "simApes.npes", + "catpes.npes", + "catpes.npes", + "catpes.npes", + "catpes.npes", + "ref.r", + "refx.r", + "refair.npes", + "lg.r", + "lgair.npes", + "pmtbulk.r", + "pmtcat.r", + "else.npes"}; + std::string cuts[n_plots]={ + "simRpes.npes*(1==1)", + "", + "", + "", + Form("catpes.detids==%d && catpes.pids==11 && catpes.mtrids==0",detid), + Form("catpes.detids==%d && abs(catpes.pids)==11 && catpes.mtrids!=0",detid), + Form("catpes.detids==%d && catpes.mtrids!=0",detid), + "ref.npes*(ref.npes!=0)", + "refx.npes*(refx.npes!=0)", + "", + "lg.npes*(lg.npes!=0)", + "", + "", + "", + ""}; + std::string drawOpts[n_plots]={ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + ""}; + std::string xTitle[n_plots]={ + "Simulated PEs", + "Simulated Rate-weighted PEs", + "Simulated Asym-weighted PEs", + "PEs", + "PEs", + "PEs", + "PEs", + "PMT spectrum vs. Radial Hit Position (mm)", + "PMT spectrum vs. Radial Hit Position (mm)", + "PEs", + "PMT spectrum vs. Radial Hit Position (mm)", + "PEs", + "Radial Hit Position (mm)", + "Radial Hit Position (mm)", + "PEs"}; + std::string yTitle[n_plots]={ + "Spectrum", + "Spectrum", + "Spectrum", + "Spectrum", + "Spectrum", + "Spectrum", + "Spectrum", + "Counts Spectrum", + "Counts Spectrum", + "Spectrum", + "Counts Spectrum", + "Spectrum", + "Counts", + "Counts", + "Spectrum"}; + /* + int nbins[n_plots]={ + 100, + 10000, + 10000, + 100, + 100, + 100, + 100, + 100, + 100, + 100, + 100, + 100, + 100, + 100, + 100}; + double lowbin[n_plots]={ + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 900.0, + 900.0, + 0.0, + 950.0, + 0.0, + 1050.0, + 1050.0, + 0.0}; + double highbin[n_plots]={ + 10.0, + 1.0e9. + 1.0e9, + 100.0, + 100.0, + 100.0, + 100.0, + 1200.0, + 1200.0, + 100.0, + 1200.0, + 100.0, + 1400.0, + 1250.0, + 100.0}; + */ + + + //for (int p=0;pcd(); + if (p < 3) c1[p]->SetLogy(); + //Histo[p]=new TH1F(Form("Histo[%d]",p),Form("%s; %s; %s",names[p].c_str(),xTitle[p].c_str(),yTitle[p].c_str()),nbins[p],lowbin[p],highbin[p]); + //Tmol->Draw(Form("%s>>Histo[%d]",draws[p].c_str(),p),Form("%s",cuts[p].c_str())); + Tmol->Draw(Form("%s",draws[p].c_str(),p),Form("%s",cuts[p].c_str()),Form("%s",drawOpts[p].c_str())); + TH1* htmp = (TH1*)gROOT->FindObject("htemp"); + + htmp->SetName(Form("Histo[%d]",p)); + htmp->SetTitle(Form("%s",names[p].c_str())); + htmp->SetXTitle(Form("%s",xTitle[p].c_str())); + htmp->SetYTitle(Form("%s",yTitle[p].c_str())); + + htmp->SetStats(1221); + integral[p] = 1.0*htmp->Integral(); + RMS[p] = 1.0*htmp->GetRMS(); + RMSerror[p] = 1.0*htmp->GetRMSError(); + Mean[p] = 1.0*htmp->GetMean(); + Meanerror[p] = 1.0*htmp->GetMeanError(); + + //Plot_Name,x_axis_units,x_number,y_number,y_uncertainty + // user_reflectivity = 0.9, double user_cerenkov = 1.0, double user_scintillation = 1.0, double user_z_pos = -11.0 + if (p==0){ //then we simulated PEs on the photocathode + //file_out_rms<AccessPathName("scans.root")) { + // Old file exists, read it and add new entries + old_file = TFile::Open("scans.root"); + old_file->GetObject("scans", oldtree); + new_file.cd(); + if (!oldtree) { + std::cout << "ERROR: Dead scans tree" ; + return; + } + newtree = oldtree->CloneTree(0); + int nent = oldtree->GetEntries(); + + // TLeaf* angleL = oldtree->GetLeaf("angle"); + // TLeaf* x_posL = oldtree->GetLeaf("x_pos"); + + // Clear out prior instance if exists + bool prior = true; + if (oldtree->GetBranch("reflectivity")) { + oldtree->SetBranchAddress("reflectivity",&oldreflectivity); + newtree->SetBranchAddress("reflectivity",&reflectivity); + } + else { + newtree->Branch("reflectivity",&reflectivity); + prior = false; + } + if (oldtree->GetBranch("cerenkov")) { + oldtree->SetBranchAddress("cerenkov",&oldcerenkov); + newtree->SetBranchAddress("cerenkov",&cerenkov); + } + else { + newtree->Branch("cerenkov",&cerenkov); + prior = false; + } + if (oldtree->GetBranch("scintillation")) { + oldtree->SetBranchAddress("scintillation",&oldscintillation); + newtree->SetBranchAddress("scintillation",&scintillation); + } + else { + newtree->Branch("scintillation",&scintillation); + prior = false; + } + if (oldtree->GetBranch("z_pos")) { + oldtree->SetBranchAddress("z_pos",&oldz_pos); + newtree->SetBranchAddress("z_pos",&z_pos); + } + else { + newtree->Branch("z_pos",&z_pos); + prior = false; + } + oldtree->SetBranchAddress("angle",&oldangle); + oldtree->SetBranchAddress("x_pos",&oldx_pos); + oldtree->SetBranchAddress("avg_pes",&oldavg); + oldtree->SetBranchAddress("avg_pes_err",&oldavg_err); + oldtree->SetBranchAddress("rms_pes",&oldrms); + oldtree->SetBranchAddress("rms_pes_err",&oldrms_err); + oldtree->SetBranchAddress("res",&oldres); + oldtree->SetBranchAddress("nentries",&oldN_en); + newtree->SetBranchAddress("angle",&angle); + newtree->SetBranchAddress("x_pos",&x_pos); + newtree->SetBranchAddress("avg_pes",&avg); + newtree->SetBranchAddress("avg_pes_err",&avg_err); + newtree->SetBranchAddress("rms_pes",&rms); + newtree->SetBranchAddress("rms_pes_err",&rms_err); + newtree->SetBranchAddress("res",&res); + newtree->SetBranchAddress("nentries",&N_en); + for (int j = 0 ; j < nent ; j++ ) { + // x_posL->GetBranch()->GetEntry(j); + // angleL->GetBranch()->GetEntry(j); + oldtree->GetEntry(j); + + if (ref_x_pos == oldx_pos && ref_angle == oldangle && (!prior || (ref_reflectivity == oldreflectivity && ref_cerenkov == oldcerenkov && ref_scintillation == oldscintillation && ref_z_pos == oldz_pos))) { + //if (ref_x_pos == x_posL->GetValue() && ref_angle == angleL->GetValue()) + std::cout << "TEST 1" << std::endl; + continue; + } + x_pos = oldx_pos; + angle = oldangle; + avg = oldavg; + avg_err = oldavg_err; + rms = oldrms; + rms_err = oldrms_err; + res = oldres; + N_en = oldN_en; + reflectivity = oldreflectivity; + cerenkov = oldcerenkov; + scintillation = oldscintillation; + z_pos = oldz_pos; + if (!oldtree->GetBranch("reflectivity")) { + reflectivity = 0.9; + } + if (!oldtree->GetBranch("cerenkov")) { + cerenkov = 1.0; + } + if (!oldtree->GetBranch("scintillation")) { + scintillation = 1.0; + } + if (!oldtree->GetBranch("z_pos")) { + z_pos = -11.0; + } + newtree->Fill(); + } + + // Append current run to end + old_file->Close(); + gSystem->Exec("rm scans.root"); + delete old_file; + } + else { + // Old file doesn't exist, make a new one + new_file.cd(); + newtree = new TTree("scans","scans"); + + // Write new tree + newtree->Branch("angle",&angle); + newtree->Branch("x_pos",&x_pos); + newtree->Branch("avg_pes",&avg); + newtree->Branch("avg_pes_err",&avg_err); + newtree->Branch("rms_pes",&rms); + newtree->Branch("rms_pes_err",&rms_err); + newtree->Branch("res",&res); + newtree->Branch("nentries",&N_en); + newtree->Branch("reflectivity",&reflectivity); + newtree->Branch("cerenkov",&cerenkov); + newtree->Branch("scintillation",&scintillation); + newtree->Branch("z_pos",&z_pos); + } + + newtree->SetBranchAddress("angle",&angle); + newtree->SetBranchAddress("x_pos",&x_pos); + newtree->SetBranchAddress("avg_pes",&avg); + newtree->SetBranchAddress("avg_pes_err",&avg_err); + newtree->SetBranchAddress("rms_pes",&rms); + newtree->SetBranchAddress("rms_pes_err",&rms_err); + newtree->SetBranchAddress("res",&res); + newtree->SetBranchAddress("nentries",&N_en); + newtree->SetBranchAddress("reflectivity",&reflectivity); + newtree->SetBranchAddress("cerenkov",&cerenkov); + newtree->SetBranchAddress("scintillation",&scintillation); + newtree->SetBranchAddress("z_pos",&z_pos); + + angle = user_angle; + x_pos = user_x_pos; + file_out_integral << names[p] << ", " << anaStr << ", " << fileString << ", " << detName << ", " << detid << ", Integral, "<Exec("mv localTmp.root scans.root"); + + } + plotsFile->cd(); + c1[p]->Write(); + c1[p]->SaveAs(Form("%s_%s_%d_%d.png",fileString.substr(0,fileString.find(".root")).c_str(),anaStr.c_str(),detid,p)); + } + + file_out_integral.close(); + file_out_rms.close(); + file_out_mean.close(); + file_out_res.close(); + + plotsFile = plotsTree->GetCurrentFile(); + plotsTree->Write("", TObject::kOverwrite); + plotsTree->Print(); + plotsFile->Close(); + //theApp.Run(); +} + +int bkgd::do_pe(int argc, char **argv) +{ + if (argc <= 1 || argc > 10) + { + std::cerr << "Usage: ./bkgd_pe char*:filename int:detNumber char*:detName char*:analysis (backgrounds or signals) double:reflectivity double:cerenkov double:scintillation double:beamCurrent double:degeneracy (Number of duplicate sample jobs)" << std::endl; + //std::cerr << "Usage: ./pe char*:filename int:detid char*:manipulateVariable float:variableValue bool:reanalyze(y or n)" << std::endl; + exit(0); + } + if (argc >= 2) + { + std::string fileName(argv[1]); + fileString = fileName; + } + if (argc >= 3) + { + detid = atoi(argv[2]); + } + if (argc >= 4) + { + std::string det_Name(argv[3]); + detName = det_Name; + } + if (argc >= 5) + { + std::string ana(argv[4]); + anaStr = ana; + } + if (argc >= 6) + { + user_reflectivity = atof(argv[5]); + } + if (argc >=7) + { + user_cerenkov = atof(argv[6]); + } + if (argc >=8) + { + user_scintillation = atof(argv[7]); + } + if (argc >=9) + { + current = atof(argv[8]); + } + if (argc >=10) + { + degeneracy = atof(argv[9]); + } + + int success = get_lookuptable(); + if (!success){ + return 0; + } + if (reana == true) { + std::cout << "Running with file=" << fileString << ", analysis=" << anaStr << ", detid=" << detid << std::endl; + bkgd_pe_ana(); + } + if (argc >=1){ + std::cout << "Plotting previously analyzed file=" << fileString << " + " << anaStr << " + PEs_det_" << detid << ".root" << std::endl; + bkgd_pePlots(argc, argv); + } + return 1; +} + +int main(int argc, char **argv) +{ + bkgd ana; + return ana.do_pe(argc, argv); +} diff --git a/analysis/bkgd_pe/include/bkgd_pe.hh b/analysis/bkgd_pe/include/bkgd_pe.hh new file mode 100644 index 000000000..334da0ea8 --- /dev/null +++ b/analysis/bkgd_pe/include/bkgd_pe.hh @@ -0,0 +1,230 @@ +#include "remolltypes.hh" +#include "bkgd_petypes.hh" + +simPEs_t simPEsTrim(std::vector sourcedetids, std::vector quartzpids, std::vector quartzmtrids, double nPEs, std::vector cathitx, std::vector cathity, std::vector cathitz) +{ + simPEs_t newHit; + newHit.npes=nPEs; + newHit.detids=sourcedetids; + newHit.pids=quartzpids; + newHit.mtrids=quartzmtrids; + newHit.cathitx=cathitx; + newHit.cathity=cathity; + newHit.cathitz=cathitz; + return newHit; +} + +catPEs_t catPEsTrim(std::vector sourcedetids, std::vector quartzpids, std::vector quartzmtrids, size_t peLen, std::vector cathitx, std::vector cathity, std::vector cathitz) +{ + catPEs_t newHit; + newHit.npes=peLen; + newHit.detids=sourcedetids; + newHit.pids=quartzpids; + newHit.mtrids=quartzmtrids; + newHit.cathitx=cathitx; + newHit.cathity=cathity; + newHit.cathitz=cathitz; + return newHit; +} + +Q_t QTrim(remollGenericDetectorHit_t hit, size_t peLen, std::vector cathitx, std::vector cathity, std::vector cathitz) +{ + Q_t newHit; + newHit.det = hit.det; + newHit.x=hit.x; + newHit.y=hit.y; + newHit.z=hit.z; + newHit.r=hit.r; + newHit.px=hit.px; + newHit.py=hit.py; + newHit.pz=hit.pz; + newHit.p=hit.p; + newHit.e=hit.e; + newHit.m=hit.m; + newHit.vx=hit.vx; + newHit.vy=hit.vy; + newHit.vz=hit.vz; + newHit.npes=peLen; + newHit.cathitx=cathitx; + newHit.cathity=cathity; + newHit.cathitz=cathitz; + return newHit; +} + +Ref_t RefTrim(remollGenericDetectorHit_t hit, size_t peLen, std::vector cathitx, std::vector cathity, std::vector cathitz) +{ + Ref_t newHit; + newHit.det = hit.det; + newHit.x=hit.x; + newHit.y=hit.y; + newHit.z=hit.z; + newHit.r=hit.r; + newHit.px=hit.px; + newHit.py=hit.py; + newHit.pz=hit.pz; + newHit.p=hit.p; + newHit.e=hit.e; + newHit.m=hit.m; + newHit.vx=hit.vx; + newHit.vy=hit.vy; + newHit.vz=hit.vz; + newHit.npes=peLen; + newHit.cathitx=cathitx; + newHit.cathity=cathity; + newHit.cathitz=cathitz; + return newHit; +} + +RefX_t RefXTrim(remollGenericDetectorHit_t hit, size_t peLen, std::vector cathitx, std::vector cathity, std::vector cathitz) +{ + RefX_t newHit; + newHit.det = hit.det; + newHit.x=hit.x; + newHit.y=hit.y; + newHit.z=hit.z; + newHit.r=hit.r; + newHit.px=hit.px; + newHit.py=hit.py; + newHit.pz=hit.pz; + newHit.p=hit.p; + newHit.e=hit.e; + newHit.m=hit.m; + newHit.vx=hit.vx; + newHit.vy=hit.vy; + newHit.vz=hit.vz; + newHit.npes=peLen; + newHit.cathitx=cathitx; + newHit.cathity=cathity; + newHit.cathitz=cathitz; + return newHit; +} + +Refair_t RefairTrim(remollGenericDetectorHit_t hit, size_t peLen, std::vector cathitx, std::vector cathity, std::vector cathitz) +{ + Refair_t newHit; + newHit.det = hit.det; + newHit.x=hit.x; + newHit.y=hit.y; + newHit.z=hit.z; + newHit.r=hit.r; + newHit.px=hit.px; + newHit.py=hit.py; + newHit.pz=hit.pz; + newHit.p=hit.p; + newHit.e=hit.e; + newHit.m=hit.m; + newHit.vx=hit.vx; + newHit.vy=hit.vy; + newHit.vz=hit.vz; + newHit.npes=peLen; + newHit.cathitx=cathitx; + newHit.cathity=cathity; + newHit.cathitz=cathitz; + return newHit; +} + +LG_t LGTrim(remollGenericDetectorHit_t hit, size_t peLen, std::vector cathitx, std::vector cathity, std::vector cathitz) +{ + LG_t newHit; + newHit.det = hit.det; + newHit.x=hit.x; + newHit.y=hit.y; + newHit.z=hit.z; + newHit.r=hit.r; + newHit.px=hit.px; + newHit.py=hit.py; + newHit.pz=hit.pz; + newHit.p=hit.p; + newHit.e=hit.e; + newHit.m=hit.m; + newHit.vx=hit.vx; + newHit.vy=hit.vy; + newHit.vz=hit.vz; + newHit.npes=peLen; + newHit.cathitx=cathitx; + newHit.cathity=cathity; + newHit.cathitz=cathitz; + return newHit; +} + +LGair_t LGairTrim(remollGenericDetectorHit_t hit, size_t peLen, std::vector cathitx, std::vector cathity, std::vector cathitz) +{ + LGair_t newHit; + newHit.det = hit.det; + newHit.x=hit.x; + newHit.y=hit.y; + newHit.z=hit.z; + newHit.r=hit.r; + newHit.px=hit.px; + newHit.py=hit.py; + newHit.pz=hit.pz; + newHit.p=hit.p; + newHit.e=hit.e; + newHit.m=hit.m; + newHit.vx=hit.vx; + newHit.vy=hit.vy; + newHit.vz=hit.vz; + newHit.npes=peLen; + newHit.cathitx=cathitx; + newHit.cathity=cathity; + newHit.cathitz=cathitz; + return newHit; +} + +PMTcat_t PMTcatTrim(remollGenericDetectorHit_t hit, size_t peLen, std::vector cathitx, std::vector cathity, std::vector cathitz) +{ + PMTcat_t newHit; + newHit.det = hit.det; + newHit.x=hit.x; + newHit.y=hit.y; + newHit.z=hit.z; + newHit.r=hit.r; + newHit.px=hit.px; + newHit.py=hit.py; + newHit.pz=hit.pz; + newHit.p=hit.p; + newHit.e=hit.e; + newHit.m=hit.m; + newHit.vx=hit.vx; + newHit.vy=hit.vy; + newHit.vz=hit.vz; + newHit.npes=peLen; + newHit.cathitx=cathitx; + newHit.cathity=cathity; + newHit.cathitz=cathitz; + return newHit; +} + +PMTbulk_t PMTbulkTrim(remollGenericDetectorHit_t hit, size_t peLen, std::vector cathitx, std::vector cathity, std::vector cathitz) +{ + PMTbulk_t newHit; + newHit.det = hit.det; + newHit.x=hit.x; + newHit.y=hit.y; + newHit.z=hit.z; + newHit.r=hit.r; + newHit.px=hit.px; + newHit.py=hit.py; + newHit.pz=hit.pz; + newHit.p=hit.p; + newHit.e=hit.e; + newHit.m=hit.m; + newHit.vx=hit.vx; + newHit.vy=hit.vy; + newHit.vz=hit.vz; + newHit.npes=peLen; + newHit.cathitx=cathitx; + newHit.cathity=cathity; + newHit.cathitz=cathitz; + return newHit; +} + +elseX_t elseXTrim(int peLen, std::vector cathitx, std::vector cathity, std::vector cathitz) +{ + elseX_t newHit; + newHit.npes=peLen; + newHit.cathitx=cathitx; + newHit.cathity=cathity; + newHit.cathitz=cathitz; + return newHit; +} diff --git a/analysis/bkgd_pe/include/bkgd_peLinkDef.h b/analysis/bkgd_pe/include/bkgd_peLinkDef.h new file mode 100644 index 000000000..16cdf0c0e --- /dev/null +++ b/analysis/bkgd_pe/include/bkgd_peLinkDef.h @@ -0,0 +1,31 @@ +#if defined(__CINT__) || defined(__CLING__) + +#pragma link off all globals; +#pragma link off all classes; +#pragma link off all functions; + +#pragma link C++ struct simPEs_t+; +#pragma link C++ struct catPEs_t+; +#pragma link C++ struct Q_t+; +#pragma link C++ struct Ref_t+; +#pragma link C++ struct RefX_t+; +#pragma link C++ struct Refair_t+; +#pragma link C++ struct LG_t+; +#pragma link C++ struct LGair_t+; +#pragma link C++ struct PMTcat_t+; +#pragma link C++ struct PMTbulk_t+; +#pragma link C++ struct elseX_t+; + +#pragma link C++ struct vector+; +#pragma link C++ struct vector+; +#pragma link C++ struct vector+; +#pragma link C++ struct vector+; +#pragma link C++ struct vector+; +#pragma link C++ struct vector+; +#pragma link C++ struct vector+; +#pragma link C++ struct vector+; +#pragma link C++ struct vector+; +#pragma link C++ struct vector+; +#pragma link C++ struct vector+; + +#endif diff --git a/analysis/bkgd_pe/include/bkgd_petypes.hh b/analysis/bkgd_pe/include/bkgd_petypes.hh new file mode 100644 index 000000000..e40de28de --- /dev/null +++ b/analysis/bkgd_pe/include/bkgd_petypes.hh @@ -0,0 +1,148 @@ +#ifndef __BKGD_PE_TYPES_HH +#define __BKGD_PE_TYPES_HH + +/* + bkgd_petypes.hh + + Generic data types which are classes. Used for passing IO + data around and useful enumerations in PE calculations +*/ + +//#if !defined(__CINT__) && !defined(__CLING__) +//#include +//#endif + +#define __RUNSTR_LEN 255 +#define __MAXFILE_LEN 1048576 // MB file size limit + +#include "TTimeStamp.h" + +// Event structure + +struct catPEs_t { // The full spectrum regardless of source + int npes; // PE counts per event + std::vector detids; // store the source det IDs too + std::vector mtrids; // store the source mtrids too + std::vector pids; // store the source pids too + std::vector cathitx, cathity, cathitz; //Cathode PE hit information +}; + +struct simPEs_t { // lookup table simulated Quartz Hits + double npes; + std::vector detids; // store the source det IDs too + std::vector mtrids; // store the source mtrids too + std::vector pids; // store the source pids too + std::vector cathitx, cathity, cathitz; //Cathode PE hit information +}; + +struct Q_t { // Quartz Hits + int npes; + int det; + double r; + double x; + double y; + double z; + double px, py, pz; + double p, e, m; + double vx, vy, vz; + std::vector cathitx, cathity, cathitz; //Cathode PE hit information +}; + +struct Ref_t { // Reflector Primary Hits + int npes; + int det; + double r; + double x; + double y; + double z; + double px, py, pz; + double p, e, m; + double vx, vy, vz; + std::vector cathitx, cathity, cathitz; //Cathode PE hit information +}; + +struct RefX_t { // Reflector Accidental Side Hits + int npes; + int det; + double r; + double x; + double y; + double z; + double px, py, pz; + double p, e, m; + double vx, vy, vz; + std::vector cathitx, cathity, cathitz; //Cathode PE hit information +}; + +struct Refair_t { // Reflector Air Volume Hits + int npes; + int det; + double r; + double x; + double y; + double z; + double px, py, pz; + double p, e, m; + double vx, vy, vz; + std::vector cathitx, cathity, cathitz; //Cathode PE hit information +}; + +struct LG_t { // Light Guide Hits + int npes; + int det; + double r; + double x; + double y; + double z; + double px, py, pz; + double p, e, m; + double vx, vy, vz; + std::vector cathitx, cathity, cathitz; //Cathode PE hit information +}; + +struct LGair_t { // Light Guide Air Volume Hits + int npes; + int det; + double r; + double x; + double y; + double z; + double px, py, pz; + double p, e, m; + double vx, vy, vz; + std::vector cathitx, cathity, cathitz; //Cathode PE hit information +}; + +struct PMTcat_t { // PMT Cathode Hits + int npes; + int det; + double r; + double x; + double y; + double z; + double px, py, pz; + double p, e, m; + double vx, vy, vz; + std::vector cathitx, cathity, cathitz; //Cathode PE hit information +}; + +struct PMTbulk_t { // PMT Bulk Volume Hits + int npes; + int det; + double r; + double x; + double y; + double z; + double px, py, pz; + double p, e, m; + double vx, vy, vz; + std::vector cathitx, cathity, cathitz; //Cathode PE hit information +}; + +struct elseX_t { // PMT Bulk Volume Hits + int npes; + std::vector cathitx, cathity, cathitz; //Cathode PE hit information +}; + + +#endif // __BKGD_PE_TYPES_HH diff --git a/analysis/copytree/README.md b/analysis/copytree/README.md new file mode 100644 index 000000000..db1956b3d --- /dev/null +++ b/analysis/copytree/README.md @@ -0,0 +1,19 @@ +Two examples of pruning remoll output trees are provided. + + + +copytree_allbr.C - copies the entire structure for selected events +copytree_selectbr.C - copies specific branches and prunes them farther based on additional cuts for selected events + + + + +Usage: + + + +./reroot -q -b copytree_selectbr.C'("input.root", "output.root")' + + + +In the specific example shown here, the output can be fed to remoll external generator for ferrous bellows studies. diff --git a/analysis/copytree/copytree_allbr.C b/analysis/copytree/copytree_allbr.C new file mode 100755 index 000000000..59194235a --- /dev/null +++ b/analysis/copytree/copytree_allbr.C @@ -0,0 +1,54 @@ +using namespace ROOT; + +Int_t isValid(std::vector *); + +int copytree_allbr(TString source, TString out){ + +TChain T("T"); +T.Add(Form("%s", source.Data())); // Adding source file +Int_t nEvents= T.GetEntries(); // Number of primary events +std::cout << "Analyzing "<< nEvents << "events" << std::endl; + +TFile f(Form("%s", out.Data()), "RECREATE"); +auto *tree = T.CloneTree(0); + +remollEvent_t *fEvent=0; +std::vector *fHit=0; + +T.SetBranchAddress("ev", &fEvent); +T.SetBranchAddress("hit", &fHit); + + +for (size_t j=0;j< nEvents;j++){ + T.GetEntry(j); + + if(isValid(fHit)){ // identify events for which track id 1 hits bellows + tree->Fill(); + } +} + +tree->Print(); +tree->Write(); + + +return 0; +} + + + +Int_t isValid(std::vector *fHit){ + +Int_t found=0; +// return true if there is atleast one hit on one of the bellows with track id 1 for an individual event +for (size_t i=0;isize();i++){ + remollGenericDetectorHit_t hit=fHit->at(i); + if ((hit.det>=70 && hit.det <=76) && hit.trid==1){ + found=1; + break; + } +} + +return found; + +} + diff --git a/analysis/copytree/copytree_selectbr.C b/analysis/copytree/copytree_selectbr.C new file mode 100755 index 000000000..8311b9724 --- /dev/null +++ b/analysis/copytree/copytree_selectbr.C @@ -0,0 +1,83 @@ +using namespace ROOT; + +Int_t isValid(std::vector *); + +int copytree_selectbr(TString source, TString out){ + +TChain T("T"); +T.Add(Form("%s", source.Data())); +Int_t nEvents= T.GetEntries(); +std::cout << "Analyzing "<< nEvents << "events" << std::endl; + +// Only need event and hit branch for remollExternalGenerator +remollEvent_t *oevent=0; +std::vector *ohit=0; +TFile f(Form("%s", out.Data()), "RECREATE"); +auto *tree = new TTree("T", "outputtree"); +auto *br_event = tree->Branch("ev", &oevent); +auto *br_hit = tree->Branch("hit", &ohit); + +remollEvent_t *fEvent=0; +std::vector *fHit=0; +T.SetBranchAddress("ev", &fEvent); +T.SetBranchAddress("hit", &fHit); + +std::map unique; + +for (size_t j=0;j< nEvents;j++){ + T.GetEntry(j); + + // identify events for which track id 1 hits one of the bellows + if(isValid(fHit)){ + oevent = fEvent; + unique[5547]=0; + unique[28]=0; + unique[70]=0; + unique[71]=0; + unique[72]=0; + unique[73]=0; + unique[74]=0; + unique[75]=0; + unique[76]=0; + + for(size_t i=0;isize();i++){ + remollGenericDetectorHit_t hit=fHit->at(i); + + // only record the hits with track id 1. Record the first hit on each detector as the hit for each primary track is already time ordered. + if(hit.trid!=1 || unique[hit.det]!=0 ) continue; + unique[hit.det]++; + ohit->push_back(hit); + + } + + tree->Fill(); + ohit->clear(); // must clear output hit collection vector before loading the next event + + } +} + +tree->Print(); +tree->Write(); + + +return 0; +} + + + +Int_t isValid(std::vector *fHit){ + +Int_t found=0; +// return true if there is atleast one hit on one of the bellows with track id 1 for an individual event +for (size_t i=0;isize();i++){ + remollGenericDetectorHit_t hit=fHit->at(i); + if ((hit.det>=70 && hit.det <=76) && hit.trid==1){ + found=1; + break; + } +} + +return found; + +} + diff --git a/analysis/cut1plot2.C b/analysis/cut1plot2.C new file mode 100644 index 000000000..1f5eae4dd --- /dev/null +++ b/analysis/cut1plot2.C @@ -0,0 +1,351 @@ +// Run commands in this order: +// +// //Start reroot +// >/path/to/build/reroot +// +// //Load in the script, and run it +// >.L cut1plot2.C +// > cut1plot2(, +// <1 for beam generator, 0 else>) + +#include "histogramUtilities.h" +#include "anaConst.h" + +TFile *fout; +string fileNm; +int beamGen(1); +long nTotEv(0); +int nFiles(0); +long currentEvNr(0); + +TH2F* dBL_xy[nSpecies][nDmg]; +TH2F* dBL_xyFold[nSpecies][nDmg]; +TH2F* dBL_rzFold[nSpecies][nDmg]; +TH1F* dBL_r[nSpecies][nDmg]; +TH1F* dBL_energy[nSpecies]; +TH1F* dBL_energyLin[nSpecies]; +TH1F* dCoil_energy[nSpecies]; +TH1F* dCoil_energyLin[nSpecies]; +TH2F* dCoil_rz[nSpecies][nDmg]; + +TH2F *dBL_thE[nSpecies][nDmg]; +TH2F *dBL_zE[nSpecies][nDmg]; +TH2F *dBL_thZ[nSpecies][nDmg]; + +TH2F *dBL_phE[nSpecies][nDmg]; +TH2F *dBL_phZ[nSpecies][nDmg]; +TH2F *dBL_phZc2[nSpecies][nDmg]; + +TH1F *dBL_vZ[nSpecies][nDmg]; +TH2F *dBL_vZE[nSpecies][nDmg]; +TH2F *dBL_vRZ[nSpecies][nDmg]; + +void initHisto(int); +void writeOutput(); +long processOne(string); +void process(); + +void cut1plot2(const string& finName = "./remollout.root", int beamGenerator=1, int overWriteFile=1){ + fileNm = finName; + beamGen = beamGenerator; + + initHisto(overWriteFile); + process(); + writeOutput(); +} + +void process(){ + + if(fileNm==""){ + cout<<"\t did not find input file. Quitting!"<>data){ + cout<<" processing: "<IsOpen() || fin->IsZombie()){ + cout<<"Problem: can't find file: "<Close(); + delete fin; + return 0; + } + TTree *t=(TTree*)fin->Get("T"); + if (t == 0) return 0; + Double_t rate=0; + remollEvent_t *ev=0; + remollBeamTarget_t *bm=0; + std::vector *part=0; + std::vector *hit=0; + //std::vector *sum; + t->SetBranchAddress("rate", &rate); + t->SetBranchAddress("bm", &bm); + t->SetBranchAddress("ev", &ev); + t->SetBranchAddress("part", &part); + t->SetBranchAddress("hit", &hit); + //t->SetBranchAddress("sum", &sum); + + long nEntries = t->GetEntries(); + cout<<"\tTotal events: "< procID; + int sector(-1); + + std::vector trackNr; + std::vector zzAtCoil; + //for (Long64_t event = 0; event < 5; t->GetEntry(event++)) { + for (Long64_t event = 0; event < nEntries; t->GetEntry(event++)) { + currentEvNr++; + if( float(event+1)/nEntries*100 > currentProc){ + cout<<"at tree entry\t"<size();j++){ + + if(hit->at(j).det <4001 || hit->at(j).det>4014) continue; + //if(hit->at(j).det != 4001 && hit->at(j).det != 4008) continue; + + if(std::isnan(rate) || std::isinf(rate)) continue; + if(rate==0) {rate=1;} + + int sp = spM[int(hit->at(j).pid)]-1; + if(sp==-1) continue; + + double kinE = hit->at(j).k; + double rr=hit->at(j).r; + double rdDmg[3]={rate,rate*kinE,0}; + double zz = hit->at(j).z; + + //if( rr > 90 ) continue; + if( rr > 90 || zz<1500 || zz>2500) continue; + dCoil_energy[sp]->Fill(kinE); + dCoil_energyLin[sp]->Fill(kinE); + for(int kk=0;kk<3;kk++){ + dCoil_rz[sp][kk]->Fill(zz,rr,rdDmg[kk]); + } + + if( find(trackNr.begin(),trackNr.end(),hit->at(j).trid) == trackNr.end() ){ + trackNr.push_back(hit->at(j).trid); + zzAtCoil.push_back(zz); + } + } + + for(int j=0;jsize();j++){ + if(hit->at(j).det != 26) continue; + + std::vector::iterator it = find(trackNr.begin(),trackNr.end(),hit->at(j).trid); + if( it == trackNr.end() ) continue; + int index = std::distance(trackNr.begin(),it); + + if(std::isnan(rate) || std::isinf(rate)) continue; + if(rate==0) {rate=1;} + + int sp = spM[int(hit->at(j).pid)]-1; + if(sp==-1) continue; + + double kinE = hit->at(j).k; + double rr=hit->at(j).r; + + double rdDmg[3]={rate,rate*kinE,0}; + double xx = hit->at(j).x; + double yy = hit->at(j).y; + double th = atan2(sqrt(hit->at(j).px*hit->at(j).px + hit->at(j).py*hit->at(j).py),hit->at(j).pz); + double ph = atan2(hit->at(j).py,hit->at(j).px); + + if(hit->at(j).pz<0) continue; + + if(kinE<30) continue; + dBL_energy[sp]->Fill(kinE); + dBL_energyLin[sp]->Fill(kinE); + for(int kk=0;kk<3;kk++){ + double phi = atan2(yy,xx); + double secPhi = fmod(phi,2*pi/7); + double xr = rr*cos(secPhi); + double yr = rr*sin(secPhi); + dBL_xyFold[sp][kk]->Fill(xr,yr,rdDmg[kk]); + + dBL_xy[sp][kk]->Fill(xx,yy,rdDmg[kk]); + dBL_r[sp][kk]->Fill(rr,rdDmg[kk]); + dBL_thE[sp][kk]->Fill(th,kinE/1000,rdDmg[kk]); + dBL_phE[sp][kk]->Fill(ph,kinE/1000,rdDmg[kk]); + dBL_thZ[sp][kk]->Fill(zzAtCoil[index],th,rdDmg[kk]); + dBL_phZ[sp][kk]->Fill(zzAtCoil[index],ph,rdDmg[kk]); + dBL_phZc2[sp][kk]->Fill(hit->at(j).vz,ph,rdDmg[kk]); + dBL_zE[sp][kk]->Fill(zzAtCoil[index],kinE/1000,rdDmg[kk]); + dBL_rzFold[sp][kk]->Fill(zzAtCoil[index],rr,rdDmg[kk]); + dBL_vZ[sp][kk]->Fill(hit->at(j).vz,rdDmg[kk]); + dBL_vRZ[sp][kk]->Fill(hit->at(j).vz,sqrt(hit->at(j).vx*hit->at(j).vx+hit->at(j).vy*hit->at(j).vy),rdDmg[kk]); + dBL_vZE[sp][kk]->Fill(hit->at(j).vz,kinE,rdDmg[kk]); + } + + } + + } + + fin->Close(); + delete fin; + return nEntries; +} + + +void initHisto(int fileType){ + string foutNm = Form("%s_Elarger30_c1p2V7.root",fileNm.substr(0,fileNm.find_last_of(".")).c_str()); + + const string fTp[2]={"UPDATE","RECREATE"}; + cout<<"Will "<cd(); + for(int i=0;iScale(scaleFactor); + dBL_energy[i]->Write(); + dBL_energyLin[i]->Scale(scaleFactor); + dBL_energyLin[i]->Write(); + dCoil_energy[i]->Scale(scaleFactor); + dCoil_energy[i]->Write(); + dCoil_energyLin[i]->Scale(scaleFactor); + dCoil_energyLin[i]->Write(); + + for(int j=0;jScale(scaleFactor); + dBL_xy[i][j]->Write(); + dBL_xyFold[i][j]->Scale(scaleFactor); + dBL_xyFold[i][j]->Write(); + dBL_r[i][j]->Scale(scaleFactor); + dBL_r[i][j]->Write(); + dCoil_rz[i][j]->Scale(scaleFactor); + dCoil_rz[i][j]->Write(); + dBL_rzFold[i][j]->Scale(scaleFactor); + dBL_rzFold[i][j]->Write(); + dBL_thE[i][j]->Scale(scaleFactor); + dBL_thE[i][j]->Write(); + dBL_thZ[i][j]->Scale(scaleFactor); + dBL_thZ[i][j]->Write(); + dBL_phE[i][j]->Scale(scaleFactor); + dBL_phE[i][j]->Write(); + dBL_phZ[i][j]->Scale(scaleFactor); + dBL_phZ[i][j]->Write(); + dBL_phZc2[i][j]->Scale(scaleFactor); + dBL_phZc2[i][j]->Write(); + dBL_zE[i][j]->Scale(scaleFactor); + dBL_zE[i][j]->Write(); + dBL_vZ[i][j]->Scale(scaleFactor); + dBL_vZ[i][j]->Write(); + dBL_vZE[i][j]->Scale(scaleFactor); + dBL_vZE[i][j]->Write(); + dBL_vRZ[i][j]->Scale(scaleFactor); + dBL_vRZ[i][j]->Write(); + + } + } + fout->Close(); +} diff --git a/analysis/firstHit.C b/analysis/firstHit.C new file mode 100644 index 000000000..1420de488 --- /dev/null +++ b/analysis/firstHit.C @@ -0,0 +1,230 @@ +// Run commands in this order: +// +// //Start reroot +// >/path/to/build/reroot +// +// //Load in the script, and run it +// >.L cut1plot2.C +// > cut1plot2(, +// <1 for beam generator, 0 else>) + +#include "histogramUtilities.h" +#include "anaConst.h" + +TFile *fout; +string fileNm; +int beamGen(1); +long nTotEv(0); +int nFiles(0); +long currentEvNr(0); + +//these are all for the hotspot +TH2F* dCoil_xy[nSpecies][nDmg]; +TH2F* dCoil_rz[nSpecies][nDmg]; + +TH2F* dCoil_EinEdep[nSpecies]; +TH1F* dCoil_Ein[nSpecies]; +TH1F* dCoil_EinLin[nSpecies]; + +void initHisto(int); +void writeOutput(); +long processOne(string); +void process(); + +void firstHit(const string& finName = "./remollout.root", int beamGenerator=1, int overWriteFile=1){ + fileNm = finName; + beamGen = beamGenerator; + + initHisto(overWriteFile); + process(); + writeOutput(); +} + +void process(){ + + if(fileNm==""){ + cout<<"\t did not find input file. Quitting!"<>data){ + cout<<" processing: "<IsOpen() || fin->IsZombie()){ + cout<<"Problem: can't find file: "<Close(); + delete fin; + return 0; + } + TTree *t=(TTree*)fin->Get("T"); + if (t == 0) return 0; + Double_t rate=0; + remollEvent_t *ev=0; + remollBeamTarget_t *bm=0; + std::vector *part=0; + std::vector *hit=0; + //std::vector *sum; + t->SetBranchAddress("rate", &rate); + t->SetBranchAddress("bm", &bm); + t->SetBranchAddress("ev", &ev); + t->SetBranchAddress("part", &part); + t->SetBranchAddress("hit", &hit); + //t->SetBranchAddress("sum", &sum); + + long nEntries = t->GetEntries(); + cout<<"\tTotal events: "< procID; + int sector(-1); + + std::vector firstHit; + std::vector species; + std::vector powerDep,kinE,xH,yH,zH; + //for (Long64_t event = 0; event < 5; t->GetEntry(event++)) { + for (Long64_t event = 0; event < nEntries; t->GetEntry(event++)) { + currentEvNr++; + if( float(event+1)/nEntries*100 > currentProc){ + cout<<"at tree entry\t"<size();j++){ + + //if(hit->at(j).det <4001 || hit->at(j).det>4014) continue; + if(hit->at(j).det != 4001 && hit->at(j).det != 4008) continue; + + if(std::isnan(rate) || std::isinf(rate)) continue; + if(rate==0) {rate=1;} + + int sp = spM[int(hit->at(j).pid)]-1; + if(sp==-1) continue; + + int trid = hit->at(j).trid; + int mtrid = hit->at(j).mtrid; + int foundUS(-1); + for(int k=0;ksize() && foundUS==-1;k++) + if(trid == hit->at(k).trid && hit->at(k).det==26) + foundUS = trid; + else if(mtrid == hit->at(k).trid && hit->at(k).det==26) + foundUS = mtrid; + + if(foundUS==-1) continue; + trid = foundUS; + + std::vector::iterator it = find(firstHit.begin(),firstHit.end(),trid); + if( it == firstHit.end() ){ + firstHit.push_back(trid); + kinE.push_back(hit->at(j).k); + species.push_back(sp); + powerDep.push_back(0); + xh.push_back(hit->at(j).x); + yh.push_back(hit->at(j).x); + zh.push_back(hit->at(j).z); + + dCoil_Ein[sp]->Fill(hit->at(j).k); + dCoil_EinLin[sp]->Fill(hit->at(j).k); + }else{ + int index = std::distance(firstHit.begin(),it); + powerDep[index]+=hit->at(j).edep; + } + } + + + for(int j=0;jFill(kinE[j],powerDep[j]); + dCoil_xy[sp][0]->Fill(xH[j],yH[j]); + dCoil_xy[sp][1]->Fill(xH[j],yH[j],powerDep[j]); + dCoil_rz[sp][0]->Fill(zH[j],sqrt(xH[j]*xH[j]+yH[j]*yH[j])); + dCoil_rz[sp][1]->Fill(zH[j],sqrt(xH[j]*xH[j]+yH[j]*yH[j]),powerDet[j]); + } + + } + + fin->Close(); + delete fin; + return nEntries; +} + + +void initHisto(int fileType){ + string foutNm = Form("%s_coilW_firstHitV0.root",fileNm.substr(0,fileNm.find_last_of(".")).c_str()); + + const string fTp[2]={"UPDATE","RECREATE"}; + cout<<"Will "<cd(); + for(int i=0;iScale(scaleFactor); + dCoil_EinEdep[i]->Write(); + dCoil_Ein[i]->Scale(scaleFactor); + dCoil_Ein[i]->Write(); + dCoil_EinLin[i]->Scale(scaleFactor); + dCoil_EinLin[i]->Write(); + + for(int j=0;jScale(scaleFactor); + dCoil_xy[i][j]->Write(); + dCoil_rz[i][j]->Scale(scaleFactor); + dCoil_rz[i][j]->Write(); + } + } + fout->Close(); +} diff --git a/analysis/pe/include/pe.hh b/analysis/pe/include/pe.hh index 51a2076f9..07ea9ee35 100644 --- a/analysis/pe/include/pe.hh +++ b/analysis/pe/include/pe.hh @@ -1,10 +1,14 @@ #include "remolltypes.hh" #include "petypes.hh" -catPEs_t catPEsTrim(std::vector sourcedetids, std::vector quartzpids, std::vector quartzmtrids, size_t peLen, std::vector cathitx, std::vector cathity, std::vector cathitz) +catPEs_t catPEsTrim(int sourcedetid, std::vector sourcedetids, std::vector quartzpids, std::vector quartzmtrids, size_t peLen, double all_bounces, double ref_bounces, double lg_bounces, std::vector cathitx, std::vector cathity, std::vector cathitz) { catPEs_t newHit; newHit.npes=peLen; + newHit.all_bounces=all_bounces; + newHit.ref_bounces=ref_bounces; + newHit.lg_bounces=lg_bounces; + newHit.det=sourcedetid; newHit.detids=sourcedetids; newHit.pids=quartzpids; newHit.mtrids=quartzmtrids; @@ -14,10 +18,10 @@ catPEs_t catPEsTrim(std::vector sourcedetids, std::vector quartzpids, return newHit; } -Q_t QTrim(remollGenericDetectorHit_t hit, size_t peLen, std::vector cathitx, std::vector cathity, std::vector cathitz) +hitPEs_t hitPEsTrim(remollGenericDetectorHit_t hit, size_t peLen, std::vector cathitx, std::vector cathity, std::vector cathitz) { - Q_t newHit; - newHit.det = hit.det; + hitPEs_t newHit; + newHit.det=hit.det; newHit.x=hit.x; newHit.y=hit.y; newHit.z=hit.z; @@ -38,180 +42,3 @@ Q_t QTrim(remollGenericDetectorHit_t hit, size_t peLen, std::vector cath return newHit; } -Ref_t RefTrim(remollGenericDetectorHit_t hit, size_t peLen, std::vector cathitx, std::vector cathity, std::vector cathitz) -{ - Ref_t newHit; - newHit.det = hit.det; - newHit.x=hit.x; - newHit.y=hit.y; - newHit.z=hit.z; - newHit.r=hit.r; - newHit.px=hit.px; - newHit.py=hit.py; - newHit.pz=hit.pz; - newHit.p=hit.p; - newHit.e=hit.e; - newHit.m=hit.m; - newHit.vx=hit.vx; - newHit.vy=hit.vy; - newHit.vz=hit.vz; - newHit.npes=peLen; - newHit.cathitx=cathitx; - newHit.cathity=cathity; - newHit.cathitz=cathitz; - return newHit; -} - -RefX_t RefXTrim(remollGenericDetectorHit_t hit, size_t peLen, std::vector cathitx, std::vector cathity, std::vector cathitz) -{ - RefX_t newHit; - newHit.det = hit.det; - newHit.x=hit.x; - newHit.y=hit.y; - newHit.z=hit.z; - newHit.r=hit.r; - newHit.px=hit.px; - newHit.py=hit.py; - newHit.pz=hit.pz; - newHit.p=hit.p; - newHit.e=hit.e; - newHit.m=hit.m; - newHit.vx=hit.vx; - newHit.vy=hit.vy; - newHit.vz=hit.vz; - newHit.npes=peLen; - newHit.cathitx=cathitx; - newHit.cathity=cathity; - newHit.cathitz=cathitz; - return newHit; -} - -Refair_t RefairTrim(remollGenericDetectorHit_t hit, size_t peLen, std::vector cathitx, std::vector cathity, std::vector cathitz) -{ - Refair_t newHit; - newHit.det = hit.det; - newHit.x=hit.x; - newHit.y=hit.y; - newHit.z=hit.z; - newHit.r=hit.r; - newHit.px=hit.px; - newHit.py=hit.py; - newHit.pz=hit.pz; - newHit.p=hit.p; - newHit.e=hit.e; - newHit.m=hit.m; - newHit.vx=hit.vx; - newHit.vy=hit.vy; - newHit.vz=hit.vz; - newHit.npes=peLen; - newHit.cathitx=cathitx; - newHit.cathity=cathity; - newHit.cathitz=cathitz; - return newHit; -} - -LG_t LGTrim(remollGenericDetectorHit_t hit, size_t peLen, std::vector cathitx, std::vector cathity, std::vector cathitz) -{ - LG_t newHit; - newHit.det = hit.det; - newHit.x=hit.x; - newHit.y=hit.y; - newHit.z=hit.z; - newHit.r=hit.r; - newHit.px=hit.px; - newHit.py=hit.py; - newHit.pz=hit.pz; - newHit.p=hit.p; - newHit.e=hit.e; - newHit.m=hit.m; - newHit.vx=hit.vx; - newHit.vy=hit.vy; - newHit.vz=hit.vz; - newHit.npes=peLen; - newHit.cathitx=cathitx; - newHit.cathity=cathity; - newHit.cathitz=cathitz; - return newHit; -} - -LGair_t LGairTrim(remollGenericDetectorHit_t hit, size_t peLen, std::vector cathitx, std::vector cathity, std::vector cathitz) -{ - LGair_t newHit; - newHit.det = hit.det; - newHit.x=hit.x; - newHit.y=hit.y; - newHit.z=hit.z; - newHit.r=hit.r; - newHit.px=hit.px; - newHit.py=hit.py; - newHit.pz=hit.pz; - newHit.p=hit.p; - newHit.e=hit.e; - newHit.m=hit.m; - newHit.vx=hit.vx; - newHit.vy=hit.vy; - newHit.vz=hit.vz; - newHit.npes=peLen; - newHit.cathitx=cathitx; - newHit.cathity=cathity; - newHit.cathitz=cathitz; - return newHit; -} - -PMTcat_t PMTcatTrim(remollGenericDetectorHit_t hit, size_t peLen, std::vector cathitx, std::vector cathity, std::vector cathitz) -{ - PMTcat_t newHit; - newHit.det = hit.det; - newHit.x=hit.x; - newHit.y=hit.y; - newHit.z=hit.z; - newHit.r=hit.r; - newHit.px=hit.px; - newHit.py=hit.py; - newHit.pz=hit.pz; - newHit.p=hit.p; - newHit.e=hit.e; - newHit.m=hit.m; - newHit.vx=hit.vx; - newHit.vy=hit.vy; - newHit.vz=hit.vz; - newHit.npes=peLen; - newHit.cathitx=cathitx; - newHit.cathity=cathity; - newHit.cathitz=cathitz; - return newHit; -} - -PMTbulk_t PMTbulkTrim(remollGenericDetectorHit_t hit, size_t peLen, std::vector cathitx, std::vector cathity, std::vector cathitz) -{ - PMTbulk_t newHit; - newHit.det = hit.det; - newHit.x=hit.x; - newHit.y=hit.y; - newHit.z=hit.z; - newHit.r=hit.r; - newHit.px=hit.px; - newHit.py=hit.py; - newHit.pz=hit.pz; - newHit.p=hit.p; - newHit.e=hit.e; - newHit.m=hit.m; - newHit.vx=hit.vx; - newHit.vy=hit.vy; - newHit.vz=hit.vz; - newHit.npes=peLen; - newHit.cathitx=cathitx; - newHit.cathity=cathity; - newHit.cathitz=cathitz; - return newHit; -} - -elseX_t elseXTrim(int peLen, std::vector cathitx, std::vector cathity, std::vector cathitz) -{ - elseX_t newHit; - newHit.npes=peLen; - newHit.cathitx=cathitx; - newHit.cathity=cathity; - newHit.cathitz=cathitz; - return newHit; -} diff --git a/analysis/pe/include/peLinkDef.h b/analysis/pe/include/peLinkDef.h index 78279ed0f..3834ad5e2 100644 --- a/analysis/pe/include/peLinkDef.h +++ b/analysis/pe/include/peLinkDef.h @@ -5,25 +5,9 @@ #pragma link off all functions; #pragma link C++ struct catPEs_t+; -#pragma link C++ struct Q_t+; -#pragma link C++ struct Ref_t+; -#pragma link C++ struct RefX_t+; -#pragma link C++ struct Refair_t+; -#pragma link C++ struct LG_t+; -#pragma link C++ struct LGair_t+; -#pragma link C++ struct PMTcat_t+; -#pragma link C++ struct PMTbulk_t+; -#pragma link C++ struct elseX_t+; +#pragma link C++ struct hitPEs_t+; #pragma link C++ struct vector+; -#pragma link C++ struct vector+; -#pragma link C++ struct vector+; -#pragma link C++ struct vector+; -#pragma link C++ struct vector+; -#pragma link C++ struct vector+; -#pragma link C++ struct vector+; -#pragma link C++ struct vector+; -#pragma link C++ struct vector+; -#pragma link C++ struct vector+; +#pragma link C++ struct vector+; #endif diff --git a/analysis/pe/include/petypes.hh b/analysis/pe/include/petypes.hh index a49105cf8..68126aaa6 100644 --- a/analysis/pe/include/petypes.hh +++ b/analysis/pe/include/petypes.hh @@ -21,13 +21,15 @@ struct catPEs_t { // The full spectrum regardless of source int npes; // PE counts per event + double all_bounces, ref_bounces, lg_bounces; + int det; // store the source det ID too std::vector detids; // store the source det IDs too std::vector mtrids; // store the source mtrids too std::vector pids; // store the source pids too std::vector cathitx, cathity, cathitz; //Cathode PE hit information }; -struct Q_t { // Quartz Hits +struct hitPEs_t { // Quartz Hits int npes; int det; double r; @@ -40,101 +42,6 @@ struct Q_t { // Quartz Hits std::vector cathitx, cathity, cathitz; //Cathode PE hit information }; -struct Ref_t { // Reflector Primary Hits - int npes; - int det; - double r; - double x; - double y; - double z; - double px, py, pz; - double p, e, m; - double vx, vy, vz; - std::vector cathitx, cathity, cathitz; //Cathode PE hit information -}; - -struct RefX_t { // Reflector Accidental Side Hits - int npes; - int det; - double r; - double x; - double y; - double z; - double px, py, pz; - double p, e, m; - double vx, vy, vz; - std::vector cathitx, cathity, cathitz; //Cathode PE hit information -}; - -struct Refair_t { // Reflector Air Volume Hits - int npes; - int det; - double r; - double x; - double y; - double z; - double px, py, pz; - double p, e, m; - double vx, vy, vz; - std::vector cathitx, cathity, cathitz; //Cathode PE hit information -}; - -struct LG_t { // Light Guide Hits - int npes; - int det; - double r; - double x; - double y; - double z; - double px, py, pz; - double p, e, m; - double vx, vy, vz; - std::vector cathitx, cathity, cathitz; //Cathode PE hit information -}; - -struct LGair_t { // Light Guide Air Volume Hits - int npes; - int det; - double r; - double x; - double y; - double z; - double px, py, pz; - double p, e, m; - double vx, vy, vz; - std::vector cathitx, cathity, cathitz; //Cathode PE hit information -}; - -struct PMTcat_t { // PMT Cathode Hits - int npes; - int det; - double r; - double x; - double y; - double z; - double px, py, pz; - double p, e, m; - double vx, vy, vz; - std::vector cathitx, cathity, cathitz; //Cathode PE hit information -}; - -struct PMTbulk_t { // PMT Bulk Volume Hits - int npes; - int det; - double r; - double x; - double y; - double z; - double px, py, pz; - double p, e, m; - double vx, vy, vz; - std::vector cathitx, cathity, cathitz; //Cathode PE hit information -}; - -struct elseX_t { // PMT Bulk Volume Hits - int npes; - std::vector cathitx, cathity, cathitz; //Cathode PE hit information -}; #endif // __PE_TYPES_HH diff --git a/analysis/pe/pe.cc b/analysis/pe/pe.cc index 34ceefe17..9ebf4836d 100644 --- a/analysis/pe/pe.cc +++ b/analysis/pe/pe.cc @@ -64,30 +64,52 @@ void pe(std::string file="tracking.root", int detid=50001) oldTree->SetBranchAddress("hit", &fHit); oldTree->SetBranchAddress("part", &fPart); std::vector < catPEs_t > *catPEs = new std::vector < catPEs_t > ; - std::vector < Q_t > *Q = new std::vector < Q_t > ; - std::vector < Ref_t > *Ref = new std::vector < Ref_t > ; - std::vector < RefX_t > *RefX = new std::vector < RefX_t > ; - std::vector < Refair_t > *Refair = new std::vector < Refair_t > ; - std::vector < LG_t > *LG = new std::vector < LG_t > ; - std::vector < LGair_t > *LGair = new std::vector < LGair_t > ; - std::vector < PMTcat_t > *PMTcat = new std::vector < PMTcat_t > ; - std::vector < PMTbulk_t > *PMTbulk = new std::vector < PMTbulk_t > ; - std::vector < elseX_t > *elseX = new std::vector < elseX_t > ; - std::vector eTRID; + std::vector < catPEs_t > *refPEs = new std::vector < catPEs_t > ; + std::vector < catPEs_t > *lgPEs = new std::vector < catPEs_t > ; + std::vector < catPEs_t > *straightPEs = new std::vector < catPEs_t > ; + std::vector < catPEs_t > *bouncePEs = new std::vector < catPEs_t > ; + std::vector < hitPEs_t > *Q = new std::vector < hitPEs_t > ; + std::vector < hitPEs_t > *Ref = new std::vector < hitPEs_t > ; + std::vector < hitPEs_t > *RefX = new std::vector < hitPEs_t > ; + std::vector < hitPEs_t > *Refair = new std::vector < hitPEs_t > ; + std::vector < hitPEs_t > *LG = new std::vector < hitPEs_t > ; + std::vector < hitPEs_t > *LGair = new std::vector < hitPEs_t > ; + std::vector < hitPEs_t > *PMTcat = new std::vector < hitPEs_t > ; + std::vector < hitPEs_t > *PMTbulk = new std::vector < hitPEs_t > ; + std::vector < catPEs_t > *elseX = new std::vector < catPEs_t > ; + std::vector eTRID; + std::vector refTRID; + std::vector lgTRID; std::vector DETID; std::vector PID; std::vector MTRID; std::vector peTRID; + int refSourceDetID = 0; + int sourceDetID = 0; + double refHit = 0; + double lgHit = 0; + double straightHit = 0; int Qcounted = 0; int Refaircounted = 0; int LGaircounted = 0; int PMTbulkcounted = 0; int detSourcedPEs = 0; + int refSourced = 0; + int lgSourced = 0; + double all_bounces = 0; + double ref_bounces = 0; + double lg_bounces = 0; + double N_entries = 0; //TODO reading data into envelopes downstream could be sped up //by storing the data by Z instead of by hit + newTree->Branch("nentries", &N_entries); newTree->Branch("catpes", &catPEs); + newTree->Branch("refpes", &refPEs); + newTree->Branch("lgpes", &lgPEs); + newTree->Branch("straightpes", &straightPEs); + newTree->Branch("bouncepes", &bouncePEs); newTree->Branch("q", &Q); newTree->Branch("ref", &Ref); newTree->Branch("refx", &RefX); @@ -104,6 +126,9 @@ void pe(std::string file="tracking.root", int detid=50001) std::cerr << "\r" << j << "/" << oldTree->GetEntries() << " - " << (j*1.0)/oldTree->GetEntries() * 100 << "%"; } + refHit = 0; + lgHit = 0; + straightHit = 0; oldTree->GetEntry(j); //std::cout << "Hits: " << fHit->size() << std::endl; //std::cout << "Parts: " << fPart->size() << std::endl; @@ -124,17 +149,32 @@ void pe(std::string file="tracking.root", int detid=50001) if (hit.pid == 11 && hit.mtrid == 0){ // Then this is our primary signal of interest // if you do mtrid == 1 then you get the delta rays! About a 1% contribution + if (hit.det == detid+1) { + // If the hit is quartz, indicate that quartz is the source of all PEs + refSourceDetID = hit.det; + sourceDetID = hit.det; + } + if (refSourceDetID != detid+1) { + // If the no hit has been quartz yet then update it to be whatever the current hit is, this will be overwritten by the above condition if quartz is a secondary hit somehow + refSourceDetID = hit.det; + sourceDetID = hit.det; + } + //sourceDetID = hit.det; // If placed here it would wipe out the parent particle's initial hit if it hits quartz and then onto something else... non-ideal eTRID.push_back(hit.trid); DETID.push_back(hit.det); - if (i<30 && hit.det == 50001){ - } } - if (hit.det == detid) { + if (hit.det == detid+1) { // If any particle hits the quartz detector then tell the particle ID and mother ID (so we can keep track of deltas) PID.push_back(hit.pid); MTRID.push_back(hit.mtrid); } - if (hit.pid == 0 && hit.det == detid+700){ + if (hit.pid == 0 && ( hit.det == detid+5 || hit.det == detid+3 ) ){ // 5 = LG, 3 = other side of reflector... + lgTRID.push_back(hit.trid); + } + if (hit.pid == 0 && hit.det == detid+4){ + refTRID.push_back(hit.trid); + } + if (hit.pid == 0 && hit.det == detid){ // This is an optical photon and we want to count ++ if it hits the PMT cathode peTRID.push_back(hit.trid); cathitx.push_back(hit.x); @@ -143,67 +183,141 @@ void pe(std::string file="tracking.root", int detid=50001) } } + //std::cout << "Event number " << j << std::endl; for (size_t i = 0; i < fHit->size();i++) { remollGenericDetectorHit_t hit = fHit->at(i); + for (size_t k = 0; k < peTRID.size(); k++) + { + //std::cout<< "Checking cathode hit track ID = " << peTRID.at(k) << " Against hit track ID = " << hit.trid << std::endl; + if (hit.pid==0 && hit.trid == peTRID.at(k)) { + if (hit.det == detid+3 || hit.det == detid+5) + { // FIXME Explicitly count bounces + //std::cout<< "Lightguide or other side of reflector hit - Match found" << std::endl; + lg_bounces = lg_bounces +1.0; + all_bounces = all_bounces+1.0; + } + if (hit.det == detid+4) + { + ref_bounces = ref_bounces+1.0; + all_bounces = all_bounces+1.0; + } + //std::cout<< "Cathode hit - Match found" << std::endl; + for (size_t l = 0; l < lgTRID.size(); l++) + { // FIXME Implicitly count bounces + //std::cout<< "Checking lg hit track ID = " << lgTRID.at(l) << " Against hit track ID = " << hit.trid << std::endl; + if (hit.trid == lgTRID.at(l) && hit.trid == peTRID.at(k) && hit.det == detid) { + //std::cout<< "Lightguide or other side of reflector hit track matches PE track and hit == cathode - Match found, PE from light guide verified" << std::endl; + lgHit = lgHit+1.0; + lgSourced = 1; + } + } + for (size_t l = 0; l < refTRID.size(); l++) + { + //std::cout<< "Checking ref hit track ID = " << refTRID.at(l) << " Against hit track ID = " << hit.trid << std::endl; + if (hit.trid == refTRID.at(l) && hit.trid == peTRID.at(k) && hit.det == detid) { + //std::cout<< "Reflector hit track matches PE track and hit == cathode - Match found, PE from reflector verified" << std::endl; + refHit = refHit+1.0; + refSourced = 1; + } + } + if (!refSourced && !lgSourced && hit.det == detid) { + straightHit = straightHit+1.0; + } + } + refSourced = 0; + lgSourced = 0; + } for (size_t k = 0; k < eTRID.size(); k++) { if (hit.trid == eTRID.at(k)) { // Then this electron hit a detector we should know about and store all of the info and cathode hits too //std::cout << "electron TRID " << hit.trid << std::endl; // Make the electron hit info go into the appropriate detector branch // quartz - if (hit.det == detid && Qcounted==0) { - Q->push_back(QTrim(hit,peTRID.size(),cathitx,cathity,cathitz)); + if (hit.det == detid+1 && Qcounted==0) { + Q->push_back(hitPEsTrim(hit,peTRID.size(),cathitx,cathity,cathitz)); Qcounted++; } // reflector air - if (hit.det == detid+100 && Refaircounted==0) { - Refair->push_back(RefairTrim(hit,peTRID.size(),cathitx,cathity,cathitz)); + if (hit.det == detid+2 && Refaircounted==0) { + Refair->push_back(hitPEsTrim(hit,peTRID.size(),cathitx,cathity,cathitz)); Refaircounted++; } // reflector skin - if (hit.det == detid+200) { - Ref->push_back(RefTrim(hit,peTRID.size(),cathitx,cathity,cathitz)); + if (hit.det == detid+3) { + Ref->push_back(hitPEsTrim(hit,peTRID.size(),cathitx,cathity,cathitz)); } // reflector volume - if (hit.det == detid+300) { - RefX->push_back(RefXTrim(hit,peTRID.size(),cathitx,cathity,cathitz)); + if (hit.det == detid+4) { + RefX->push_back(hitPEsTrim(hit,peTRID.size(),cathitx,cathity,cathitz)); } // light guide air - if (hit.det == detid+400 && LGaircounted==0) { - LGair->push_back(LGairTrim(hit,peTRID.size(),cathitx,cathity,cathitz)); + if (hit.det == detid+6 && LGaircounted==0) { + LGair->push_back(hitPEsTrim(hit,peTRID.size(),cathitx,cathity,cathitz)); LGaircounted++; } // light guide skin - if (hit.det == detid+500) { - LG->push_back(LGTrim(hit,peTRID.size(),cathitx,cathity,cathitz)); + if (hit.det == detid+5) { + LG->push_back(hitPEsTrim(hit,peTRID.size(),cathitx,cathity,cathitz)); } // PMT bulk - if (hit.det == detid+600 && PMTbulkcounted==0) { - PMTbulk->push_back(PMTbulkTrim(hit,peTRID.size(),cathitx,cathity,cathitz)); + if (hit.det == detid+7 && PMTbulkcounted==0) { + PMTbulk->push_back(hitPEsTrim(hit,peTRID.size(),cathitx,cathity,cathitz)); PMTbulkcounted++; } // PMT cathode - if (hit.det == detid+700) { - PMTcat->push_back(PMTcatTrim(hit,peTRID.size(),cathitx,cathity,cathitz)); + if (hit.det == detid) { + PMTcat->push_back(hitPEsTrim(hit,peTRID.size(),cathitx,cathity,cathitz)); } //break; //how is this useful?? I want to muliple count } - } + } + } + if (refHit>=1.0) { + refPEs->push_back(catPEsTrim(refSourceDetID,DETID,PID,MTRID,(int)refHit,0,0,0,cathitx,cathity,cathitz)); + } + if (lgHit>=1.0) { + lgPEs->push_back(catPEsTrim(refSourceDetID,DETID,PID,MTRID,(int)lgHit,0,0,0,cathitx,cathity,cathitz)); } - catPEs->push_back(catPEsTrim(DETID,PID,MTRID,(int)peTRID.size(),cathitx,cathity,cathitz)); + if (straightHit>=1.0) { + straightPEs->push_back(catPEsTrim(refSourceDetID,DETID,PID,MTRID,(int)straightHit,0,0,0,cathitx,cathity,cathitz)); + } + refHit=0; + lgHit=0; + straightHit=0; detSourcedPEs=(int)peTRID.size(); - elseX->push_back(elseXTrim(((int)peTRID.size()-detSourcedPEs),cathitx,cathity,cathitz)); - if (catPEs->size() > 0){ + catPEs->push_back(catPEsTrim(sourceDetID,DETID,PID,MTRID,detSourcedPEs,0,0,0,cathitx,cathity,cathitz)); + // FIXME: Bounces here are avg per event... but could store a vector or push back one number of bounces per PE and then the histogram would have entries == number of PEs + bouncePEs->push_back(catPEsTrim(sourceDetID,DETID,PID,MTRID,detSourcedPEs,all_bounces/detSourcedPEs,ref_bounces/detSourcedPEs,lg_bounces/detSourcedPEs,cathitx,cathity,cathitz)); + if (sourceDetID == detid+1) { + // If it is a quartz sourced hit then proceed empty, else add number of PEs + elseX->push_back(catPEsTrim(sourceDetID,DETID,PID,MTRID,0,0,0,0,cathitx,cathity,cathitz)); + } + else { + elseX->push_back(catPEsTrim(sourceDetID,DETID,PID,MTRID,detSourcedPEs,0,0,0,cathitx,cathity,cathitz)); + } + N_entries = (double)oldTree->GetEntries(); + //if (catPEs->size() > 0){ newTree->Fill(); - } + //} Qcounted=0; Refaircounted=0; LGaircounted=0; PMTbulkcounted=0; detSourcedPEs=0; + refSourceDetID=0; + sourceDetID=0; + all_bounces=0; + ref_bounces=0; + lg_bounces=0; eTRID.clear(); + lgTRID.clear(); + refTRID.clear(); + refPEs->clear(); + lgPEs->clear(); + straightPEs->clear(); catPEs->clear(); + bouncePEs->clear(); elseX->clear(); Q->clear(); Refair->clear(); @@ -223,16 +337,18 @@ void pe(std::string file="tracking.root", int detid=50001) } newFile = newTree->GetCurrentFile(); newTree->Write("", TObject::kOverwrite); - newTree->Print(); + //newTree->Print(); old->Close(); newFile->Close(); } -void pePlots(int argcC, char **argvC, std::string fileP="tracking.root", int detid=50001, std::string variable="reflectorAngle", double varVal=11.5, std::string unit="deg") +//void pePlots(int argcC, char **argvC, std::string fileP="tracking.root", int detid=50001, std::string variable="reflectorAngle", double varVal=11.5, std::string unit="deg") +//void pePlots(int argcC, char **argvC, std::string fileP="tracking.root", int detid=50001, double user_angle = 0.0, double user_x_pos = 0.0, double user_reflectivity = 0.9, double user_cerenkov = 1.0, double user_scintillation = 1.0, double user_z_pos = -11.0) +void pePlots(std::string fileP, int detid, std::vector &argNames, std::vector &argValues) { - TApplication theApp("App",&argcC,argvC); + //TApplication theApp("App",&argcC,argvC); - int dotpos = fileP.rfind("."); + int dotpos = fileP.rfind(".root"); std::ostringstream os; std::ostringstream os2; os << fileP.substr(0, dotpos) << "_PEs_"<<"det_"<cd(); // Is this necessary? //int nentries = (Int_t)newTree->GetEntries(); + // + double N_entries = 0; + Tmol->SetBranchAddress("nentries", &N_entries); + if (Tmol) { + Tmol->GetEntry(0); + } + std::fstream file_out_ref_rms; + std::ofstream file_out_ref_mean; + std::ofstream file_out_ref_res; + file_out_ref_rms.open("ref_rms.csv",std::ofstream::out | std::ofstream::app); + file_out_ref_mean.open("ref_mean.csv",std::ofstream::out | std::ofstream::app); + file_out_ref_res.open("ref_res.csv",std::ofstream::out | std::ofstream::app); std::fstream file_out_rms; std::ofstream file_out_mean; std::ofstream file_out_res; @@ -261,17 +389,25 @@ void pePlots(int argcC, char **argvC, std::string fileP="tracking.root", int det set_plot_style(); - const int n_plots = 12; + const int n_plots = 18; TH1F *Histo[n_plots]; double RMS[n_plots]; double RMSerror[n_plots]; double Mean[n_plots]; double Meanerror[n_plots]; + double Nentries[n_plots]; TCanvas * c1[n_plots]; + std::string names[n_plots]={"Total Cathode Spectrum per event", + "Quartz sourced, Reflector bounced Cathode PEs", + "Quartz sourced, Lightguide bounced Cathode PEs", + "Quartz sourced, No bounce straight shot Cathode PEs", "Cathode Spectrum from primary signal quartz electrons only", "Cathode Spectrum from quartz deltas", "Cathode Spectrum from all non-primary quartz signals", + "Number of bounces for a Cathode PE off of ref plus LG", + "Number of bounces for a Cathode PE off of ref", + "Number of bounces for a Cathode PE off of LG", "e- hit radial hit spectrum on the reflector", // Consider adding photon xyz tracking too - would have to go beside the cathode xyz tracking feature "e- hit radial hit spectrum on the quartz-reflector holder", "Cathode Spectrum from the reflector air", @@ -281,9 +417,15 @@ void pePlots(int argcC, char **argvC, std::string fileP="tracking.root", int det "e- hit spectrum in the cathode", "Cathode Spectrum from elsewhere"}; std::string draws[n_plots]={"catpes.npes", + "refpes.npes", + "lgpes.npes", + "straightpes.npes", "catpes.npes", "catpes.npes", "catpes.npes", + "bouncepes.all_bounces", + "bouncepes.ref_bounces", + "bouncepes.lg_bounces", "ref.r", "refx.r", "refair.npes", @@ -293,9 +435,18 @@ void pePlots(int argcC, char **argvC, std::string fileP="tracking.root", int det "pmtcat.r", "else.npes"}; std::string cuts[n_plots]={"", - Form("catpes.detids==%d && catpes.pids==11 && catpes.mtrids==0",detid), - Form("catpes.detids==%d && abs(catpes.pids)==11 && catpes.mtrids!=0",detid), - Form("catpes.detids==%d && catpes.mtrids!=0",detid), + Form("refpes.det==%d",detid+1), + Form("lgpes.det==%d",detid+1), + Form("straightpes.det==%d",detid+1), + //Form("catpes.detids==%d && catpes.pids==11 && catpes.mtrids==0",detid+1), + Form("catpes.det==%d && catpes.pids==11 && catpes.mtrids==0",detid+1), + //Form("catpes.detids==%d && abs(catpes.pids)==11 && catpes.mtrids!=0",detid+1), + Form("catpes.det==%d && abs(catpes.pids)==11 && catpes.mtrids!=0",detid+1), + //`Form("catpes.detids==%d && catpes.mtrids!=0",detid+1), + Form("catpes.det==%d && catpes.mtrids!=0",detid+1), + "", + "", + "", "ref.npes*(ref.npes!=0)", "refx.npes*(refx.npes!=0)", "", @@ -304,10 +455,35 @@ void pePlots(int argcC, char **argvC, std::string fileP="tracking.root", int det "", "", ""}; + std::string drawOpts[n_plots]={ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + ""}; std::string xTitle[n_plots]={"PEs", "PEs", "PEs", "PEs", + "PEs", + "PEs", + "PEs", + "Bounces", + "Bounces", + "Bounces", "PMT spectrum vs. Radial Hit Position (mm)", "PMT spectrum vs. Radial Hit Position (mm)", "PEs", @@ -320,6 +496,12 @@ void pePlots(int argcC, char **argvC, std::string fileP="tracking.root", int det "Spectrum", "Spectrum", "Spectrum", + "Spectrum", + "Spectrum", + "Spectrum", + "Bounce Counter", + "Bounce Counter", + "Bounce Counter", "Counts Spectrum", "Counts Spectrum", "Spectrum", @@ -328,6 +510,7 @@ void pePlots(int argcC, char **argvC, std::string fileP="tracking.root", int det "Counts", "Counts", "Spectrum"}; + /* int nbins[n_plots]={100, 100, 100, @@ -339,12 +522,14 @@ void pePlots(int argcC, char **argvC, std::string fileP="tracking.root", int det 100, 100, 100, + 100, 100}; double lowbin[n_plots]={ 0.0, 0.0, 0.0, 0.0, + 0.0, 900.0, 900.0, 0.0, @@ -355,6 +540,7 @@ void pePlots(int argcC, char **argvC, std::string fileP="tracking.root", int det 0.0}; double highbin[n_plots]={ 100.0, + 10.0, 100.0, 100.0, 100.0, @@ -366,37 +552,382 @@ void pePlots(int argcC, char **argvC, std::string fileP="tracking.root", int det 1400.0, 1250.0, 100.0}; + */ + + + int nGoodEntries = 0; + + std::vector ref_argValues(argValues); + std::vector new_argValues(argValues); + std::vector old_argValues(argValues); + //std::cout<<"TEST " << argValues.at(2); + std::fill(new_argValues.begin(),new_argValues.end(),0.0); + std::fill(old_argValues.begin(),old_argValues.end(),0.0); + /*double ref_x_pos = user_x_pos; + double ref_angle = user_angle; + double ref_reflectivity = user_reflectivity; + double ref_cerenkov = user_cerenkov; + double ref_scintillation = user_scintillation; + double ref_z_pos = user_z_pos; + double oldx_pos = 0.0; + double oldangle = 0.0; + double oldreflectivity = 0.0; + double oldcerenkov = 0.0; + double oldscintillation = 0.0; + double oldz_pos = 0.0;*/ + + // Avg will include all PEs: regardless of where the electron that sourced it came from or what surfaces it bounced off of + double oldavg = 0.0; + double oldavg_err = 0.0; + double oldrms = 0.0; + double oldrms_err = 0.0; + double oldres = 0.0; + double oldN_en = 0.0; + // Quartz-electron hitting sourced PEs: which bounce off of LG, Ref, nothing, or agnostic + double oldavg_Qsourced_refHit = 0.0; + double oldavg_Qsourced_lgHit = 0.0; + double oldavg_Qsourced_straightHit = 0.0; + double oldavg_Qsourced_primaries = 0.0; + // Per-event averaged number of bounces off of surfaces before hitting PMT cathode + // FIXME Could fill per-PE instead of avg per event if wanted + double oldavg_allbounce = 0.0; + double oldavg_refbounce = 0.0; + double oldavg_lgbounce = 0.0; - for (int p=0;pAccessPathName("scans.root")) { + // Old file exists, read it and add new entries + old_file = TFile::Open("scans.root"); + old_file->GetObject("scans", oldtree); + new_file.cd(); + if (!oldtree) { + std::cout << "ERROR: Dead scans tree" ; + return; + } + newtree = oldtree->CloneTree(0); + int nent = oldtree->GetEntries(); + + // TLeaf* angleL = oldtree->GetLeaf("angle"); + // TLeaf* x_posL = oldtree->GetLeaf("new_x_pos"); + + // Clear out prior instance if exists - will replace again later, putting it at the end of the list + //bool prior = false; + int match = 0; + for ( int k = 0 ; k < argNames.size() ; k++ ) { + oldtree->SetBranchAddress(argNames.at(k).c_str(),&old_argValues.at(k)); + newtree->SetBranchAddress(argNames.at(k).c_str(),&argValues.at(k)); + } + /*oldtree->SetBranchAddress("angle",&oldangle); + oldtree->SetBranchAddress("new_x_pos",&oldx_pos); + oldtree->SetBranchAddress("reflectivity",&oldreflectivity); + oldtree->SetBranchAddress("cerenkov",&oldcerenkov); + oldtree->SetBranchAddress("scintillation",&oldscintillation); + oldtree->SetBranchAddress("z_pos",&oldz_pos);*/ + oldtree->SetBranchAddress("avg_pes",&oldavg); + oldtree->SetBranchAddress("avg_pes_err",&oldavg_err); + oldtree->SetBranchAddress("rms_pes",&oldrms); + oldtree->SetBranchAddress("rms_pes_err",&oldrms_err); + oldtree->SetBranchAddress("res",&oldres); + oldtree->SetBranchAddress("nentries",&oldN_en); + + oldtree->SetBranchAddress("avg_Qsourced_refHit_pes", &oldavg_Qsourced_refHit); + oldtree->SetBranchAddress("avg_Qsourced_lgHit_pes", &oldavg_Qsourced_lgHit); + oldtree->SetBranchAddress("avg_Qsourced_straightHit_pes", &oldavg_Qsourced_straightHit); + oldtree->SetBranchAddress("avg_Qsourced_primaries_pes", &oldavg_Qsourced_primaries); + + oldtree->SetBranchAddress("avg_all_bounces", &oldavg_allbounce); + oldtree->SetBranchAddress("avg_ref_bounces", &oldavg_refbounce); + oldtree->SetBranchAddress("avg_lg_bounces", &oldavg_lgbounce); + /*newtree->SetBranchAddress("angle",&angle); + newtree->SetBranchAddress("new_x_pos",&new_x_pos); + newtree->SetBranchAddress("reflectivity",&reflectivity); + newtree->SetBranchAddress("cerenkov",&cerenkov); + newtree->SetBranchAddress("scintillation",&scintillation); + newtree->SetBranchAddress("z_pos",&z_pos);*/ + newtree->SetBranchAddress("avg_pes",&avg); + newtree->SetBranchAddress("avg_pes_err",&avg_err); + newtree->SetBranchAddress("rms_pes",&rms); + newtree->SetBranchAddress("rms_pes_err",&rms_err); + newtree->SetBranchAddress("res",&res); + newtree->SetBranchAddress("nentries",&N_en); + + newtree->SetBranchAddress("avg_Qsourced_refHit_pes", &avg_Qsourced_refHit); + newtree->SetBranchAddress("avg_Qsourced_lgHit_pes", &avg_Qsourced_lgHit); + newtree->SetBranchAddress("avg_Qsourced_straightHit_pes", &avg_Qsourced_straightHit); + newtree->SetBranchAddress("avg_Qsourced_primaries_pes", &avg_Qsourced_primaries); + + newtree->SetBranchAddress("avg_all_bounces", &avg_allbounce); + newtree->SetBranchAddress("avg_ref_bounces", &avg_refbounce); + newtree->SetBranchAddress("avg_lg_bounces", &avg_lgbounce); + + for (int j = 0 ; j < nent ; j++ ) { + // x_posL->GetBranch()->GetEntry(j); + // angleL->GetBranch()->GetEntry(j); + oldtree->GetEntry(j); + + for ( int k = 0 ; k < argNames.size() ; k++ ) { + if ( old_argValues.at(k) == ref_argValues.at(k) ) { + match++; + } + new_argValues.at(k) = ref_argValues.at(k); + } + if (match == argNames.size()) continue; + /*if (ref_x_pos == oldx_pos && ref_angle == oldangle && ref_reflectivity == oldreflectivity && ref_cerenkov == oldcerenkov && ref_scintillation == oldscintillation && ref_z_pos == oldz_pos) { + prior = true; + //if (ref_x_pos == x_posL->GetValue() && ref_angle == angleL->GetValue()) + std::cout << "TEST 1" << std::endl; + if (prior) { + continue; + } + }*/ + avg = oldavg; + avg_err = oldavg_err; + rms = oldrms; + rms_err = oldrms_err; + res = oldres; + N_en = oldN_en; + + avg_Qsourced_refHit = oldavg_Qsourced_refHit; + avg_Qsourced_lgHit = oldavg_Qsourced_lgHit; + avg_Qsourced_straightHit = oldavg_Qsourced_straightHit; + avg_Qsourced_primaries = oldavg_Qsourced_primaries; + + avg_allbounce = oldavg_allbounce; + avg_refbounce = oldavg_refbounce; + avg_lgbounce = oldavg_lgbounce; + + /*new_x_pos = oldx_pos; + angle = oldangle; + reflectivity = oldreflectivity; + cerenkov = oldcerenkov; + scintillation = oldscintillation; + z_pos = oldz_pos;*/ + newtree->Fill(); + } + + // Append current run to end + old_file->Close(); + gSystem->Exec("rm scans.root"); + delete old_file; + } + else { + // Old file doesn't exist, make a new one + new_file.cd(); + newtree = new TTree("scans","scans"); + + // Write new tree + for ( int k = 0 ; k < argNames.size() ; k++ ) { + newtree->Branch(argNames.at(k).c_str(),&new_argValues.at(k)); + } + /*newtree->Branch("angle",&angle); + newtree->Branch("x_pos",&new_x_pos); + newtree->Branch("reflectivity",&reflectivity); + newtree->Branch("cerenkov",&cerenkov); + newtree->Branch("scintillation",&scintillation); + newtree->Branch("z_pos",&z_pos);*/ + newtree->Branch("avg_pes",&avg); + newtree->Branch("avg_pes_err",&avg_err); + newtree->Branch("rms_pes",&rms); + newtree->Branch("rms_pes_err",&rms_err); + newtree->Branch("res",&res); + newtree->Branch("nentries",&N_en); + + newtree->Branch("avg_Qsourced_refHit_pes", &avg_Qsourced_refHit); + newtree->Branch("avg_Qsourced_lgHit_pes", &avg_Qsourced_lgHit); + newtree->Branch("avg_Qsourced_straightHit_pes", &avg_Qsourced_straightHit); + newtree->Branch("avg_Qsourced_primaries_pes", &avg_Qsourced_primaries); + + newtree->Branch("avg_all_bounces", &avg_allbounce); + newtree->Branch("avg_ref_bounces", &avg_refbounce); + newtree->Branch("avg_lg_bounces", &avg_lgbounce); + } + + for ( int k = 0 ; k < argNames.size() ; k++ ) { + newtree->SetBranchAddress(argNames.at(k).c_str(),&new_argValues.at(k)); + new_argValues.at(k) = argValues.at(k); + std::cout << argNames.at(k) << " = " << argValues.at(k) << ", "; + } + std::cout<SetBranchAddress("angle",&angle); + newtree->SetBranchAddress("x_pos",&new_x_pos); + newtree->SetBranchAddress("reflectivity",&reflectivity); + newtree->SetBranchAddress("cerenkov",&cerenkov); + newtree->SetBranchAddress("scintillation",&scintillation); + newtree->SetBranchAddress("z_pos",&z_pos);*/ + newtree->SetBranchAddress("avg_pes",&avg); + newtree->SetBranchAddress("avg_pes_err",&avg_err); + newtree->SetBranchAddress("rms_pes",&rms); + newtree->SetBranchAddress("rms_pes_err",&rms_err); + newtree->SetBranchAddress("res",&res); + newtree->SetBranchAddress("nentries",&N_en); + + newtree->SetBranchAddress("avg_Qsourced_refHit_pes", &avg_Qsourced_refHit); + newtree->SetBranchAddress("avg_Qsourced_lgHit_pes", &avg_Qsourced_lgHit); + newtree->SetBranchAddress("avg_Qsourced_straightHit_pes", &avg_Qsourced_straightHit); + newtree->SetBranchAddress("avg_Qsourced_primaries_pes", &avg_Qsourced_primaries); + + newtree->SetBranchAddress("avg_all_bounces", &avg_allbounce); + newtree->SetBranchAddress("avg_ref_bounces", &avg_refbounce); + newtree->SetBranchAddress("avg_lg_bounces", &avg_lgbounce); + + // DONE scans.root setup + // Clean up defaults, don't just copy prior good entry if appending new data to existing scans.root + + avg = 0.0; + avg_err = 0.0; + rms = 0.0; + rms_err = 0.0; + res = 0.0; + N_en = 0.0; + avg_Qsourced_refHit = 0.0; + avg_Qsourced_lgHit = 0.0; + avg_Qsourced_straightHit = 0.0; + avg_Qsourced_primaries = 0.0; + avg_allbounce = 0.0; + avg_refbounce = 0.0; + avg_lgbounce = 0.0; + + for (int p=0;pcd(); - c1[p]->SetLogy(); - Histo[p]=new TH1F(Form("Histo[%d]",p),Form("%s; %s; %s",names[p].c_str(),xTitle[p].c_str(),yTitle[p].c_str()),nbins[p],lowbin[p],highbin[p]); + //Histo[p]=new TH1F(Form("Histo[%d]",p),Form("%s; %s; %s",names[p].c_str(),xTitle[p].c_str(),yTitle[p].c_str()),nbins[p],lowbin[p],highbin[p]); //Histo[p]=new TH1F(); //Histo[p]->SetName(Form("Histo[%d]",p)); - Tmol->Draw(Form("%s>>Histo[%d]",draws[p].c_str(),p),Form("%s",cuts[p].c_str())); - - //Histo[p]->SetTitle(Form("%s",names[p].c_str())); - //Histo[p]->SetXTitle(Form("PEs/radius hit position; Spectrum")); - //Histo[p]->SetYTitle(Form("Spectrum")); - - Histo[p]->SetStats(1111); - RMS[p] = 1.0*Histo[p]->GetRMS(); - RMSerror[p] = 1.0*Histo[p]->GetRMSError(); - Mean[p] = 1.0*Histo[p]->GetMean(); - Meanerror[p] = 1.0*Histo[p]->GetMeanError(); - - //Plot_Name,x_axis_units,x_number,y_number,y_uncertainty - if (p==1){ //then a primary electron hit the quartz and we want to see the spectrum - file_out_rms<Draw(Form("%s>>Histo[%d]",draws[p].c_str(),p),Form("%s",cuts[p].c_str())); + nGoodEntries = Tmol->Draw(Form("%s",draws[p].c_str(),p),Form("%s",cuts[p].c_str()),Form("%s",drawOpts[p].c_str())); + if (nGoodEntries>0) { + TH1* htmp = (TH1*)gROOT->FindObject("htemp"); + + htmp->SetName(Form("Histo[%d]",p)); + htmp->SetTitle(Form("%s",names[p].c_str())); + htmp->SetXTitle(Form("%s",xTitle[p].c_str())); + htmp->SetYTitle(Form("%s",yTitle[p].c_str())); - c1[p]->Write(); - c1[p]->SaveAs(/*plotsFolder+*/Form("%s_%03.2f_%02d.png",variable.c_str(),varVal,p)); + htmp->SetStats(1221); + + //Histo[p]->SetTitle(Form("%s",names[p].c_str())); + //Histo[p]->SetXTitle(Form("PEs/radius hit position; Spectrum")); + //Histo[p]->SetYTitle(Form("Spectrum")); + + //Histo[p]->SetStats(1111); + //RMS[p] = 1.0*Histo[p]->GetRMS(); + //RMSerror[p] = 1.0*Histo[p]->GetRMSError(); + //Mean[p] = 1.0*Histo[p]->GetMean(); + //Meanerror[p] = 1.0*Histo[p]->GetMeanError(); + htmp->SetStats(1111); + RMS[p] = 1.0*htmp->GetRMS(); + RMSerror[p] = 1.0*htmp->GetRMSError(); + Mean[p] = 1.0*htmp->GetMean(); + Meanerror[p] = 1.0*htmp->GetMeanError(); + Nentries[p] = 1.0*htmp->GetEntries(); + if (Mean[p]>0){ + c1[p]->SetLogy(); + } + + //Plot_Name,x_axis_units,x_number,y_number,y_uncertainty + // user_reflectivity = 0.9, double user_cerenkov = 1.0, double user_scintillation = 1.0, double user_z_pos = -11.0 + if (p==0){ //then a primary electron hit the quartz and we want to see the spectrum + //file_out_rms<cd(); + c1[p]->Write(); + c1[p]->SaveAs(Form("%s_%d.png",fileP.substr(0,fileP.find(".root")).c_str(),p)); + + //std::cout << "TEST 2 X = " << x_pos << ", angle = " << angle <Fill(); + newtree->Write("scans",TObject::kOverwrite); + new_file.Close(); + + gSystem->Exec("mv localTmp.root scans.root"); + + file_out_ref_rms.close(); + file_out_ref_mean.close(); + file_out_ref_res.close(); file_out_rms.close(); file_out_mean.close(); file_out_res.close(); @@ -405,20 +936,28 @@ void pePlots(int argcC, char **argvC, std::string fileP="tracking.root", int det plotsTree->Write("", TObject::kOverwrite); plotsTree->Print(); plotsFile->Close(); - theApp.Run(); + //theApp.Run(); } int main(int argc, char **argv) { std::string fileString = "tracking.root"; - std::string varString = "reflectorAngle"; - std::string unitString = "deg"; + /*double user_angle = 0.0; + double user_x_pos = 0.0; + double user_reflectivity = 0.9; + double user_cerenkov = 1.0; + double user_scintillation = 1.0; + double user_z_pos = -11.0;*/ + //std::string varString = "reflectorAngle"; + //std::string unitString = "deg"; bool reana = true; - int detid=50001; - double manipVar=11.5; - if (argc <= 1 || argc > 7) + int detid=540210; + //double manipVar=11.5; + if (argc <= 1) { - std::cerr << "Usage: ./pe char*:filename int:detid char*:manipulateVariable float:variableValue bool:reanalyze(y or n)" << std::endl; + std::cerr << "Usage: ./pe char*:filename int:detNumber [list of: VariableName=Value (char*=double)]" << std::endl; + //std::cerr << "Usage: ./pe char*:filename int:detNumber double:angle double:x_pos double:reflectivity double:cerenkov double:scintillation double:z_pos" << std::endl; + //std::cerr << "Usage: ./pe char*:filename int:detid char*:manipulateVariable float:variableValue bool:reanalyze(y or n)" << std::endl; exit(0); } if (argc >= 2) @@ -430,33 +969,56 @@ int main(int argc, char **argv) { detid = atoi(argv[2]); } - if (argc >=4) + + int argN = 4; + std::string argi = ""; + std::vector argNames; + std::vector argValues; + while (argN <= argc) { + argi = argv[argN-1]; + if (argi.find("=") != argi.size()) { + argNames.push_back(argi.substr(0,argi.find("="))); + argValues.push_back(atof(argi.substr(argi.find("=")+1, argi.size() - argi.find("=") ).c_str())); + } + else { + continue; + } + argN++; + } + /* + if (argc >= 4) { - std::string varName(argv[3]); - varString = varName; + user_angle = atof(argv[3]); } - if (argc >=5) + if (argc >= 5) { - manipVar = atof(argv[4]); + user_x_pos = atof(argv[4]); } - if (argc >=6) + if (argc >= 6) { - std::string unitName(argv[5]); - unitString = unitName; + user_reflectivity = atof(argv[5]); } if (argc >=7) { - if (argv[6][0]=='n'){ - reana=false; - } + user_cerenkov = atof(argv[6]); + } + if (argc >=8) + { + user_scintillation = atof(argv[7]); + } + if (argc >=9) + { + user_z_pos = atof(argv[8]); } + */ if (reana == true) { std::cout << "Running with file=" << fileString << ", detid=" << detid << std::endl; pe(fileString, detid); } - if (argc >=5){ + if (argc >=3){ std::cout << "Plotting previously analyzed file=" << fileString << " + PEs_det_" << detid << ".root" << std::endl; - pePlots(argc, argv, fileString, detid, varString, manipVar, unitString); + //pePlots(argc, argv, fileString, detid, argNames, argValues, user_angle, user_x_pos, user_reflectivity, user_cerenkov, user_scintillation, user_z_pos); + pePlots(fileString, detid, argNames, argValues); } } diff --git a/analysis/pe_studies/README.md b/analysis/pe_studies/README.md new file mode 100644 index 000000000..99839d429 --- /dev/null +++ b/analysis/pe_studies/README.md @@ -0,0 +1,86 @@ +# Known glitches on UMass Mocha cluster: +* /share/library will refuse to show up unless you qlogin to compute-0-0 and ls it directly +* Similarly, you need to log in to compute-0-0 and execute remoll at least once by hand to get all the libraries in place + +Once remoll is built add these two lines into bin/remoll.sh to get it to work properly: + +`export PATH="/share/library":${PATH}` + +`export LD_LIBRARY_PATH="/share/library/":${LD_LIBRARY_PATH}` + +- - - + +# Available Detector Optimization Analyses + +## 'scripts' Folder +The 'scripts' folder contains any bash scripts that greatly simplify the job of scanning parameters of various rings and optimizing detectors after any change in upstream electron transport, and serve as a template for further studies that can be done. + +Each script within the scripts folder is intended to be executed from the pe_studies folder -> `./scripts/full-scan.sh [args]`, and each of them has been set up so that all of the relative paths and needed executables are automatically referenced correctly or moved into the correct places (and if not, then a useful message is printed explaining what went wrong and how to fix it by hand). + +All of the scripts assume that you are using the UMass Mocha compute cluster's SGE qsub system. This system has some issues (listed above), which have had semi-reasonable work-arounds developed that do work (but require additional effort to get right). + +'scripts' contents: +### produce.sh +Usage `./scripts/produce.sh numberRepeat (no path, just name)macroName.mac nameStub cadp.csv` + +This script generates the flux at the downstream "flat" idealized detector array (where each individual sub-segment of each detector has been flattened and projected onto the x-y axis, and all detectors are separate, but with the same numbering system as the full detector system), which allows later sampling from that accepted flux (see full-scan.sh) + +The arguments are as follows: +* numberRepeat: "50" is a good default and is the number of separate simulation jobs to execute. Ideally we want around 5 million events for the main generators to get reasonable statistics, but this takes days if done in just one job. Splitting that into 50 jobs of 100k events each (the default contained in the macros/runexample_...parallel.mac macros) is ideal. +* macroName.mac: "runexample_moller_parallel.mac" (or epelastic or epinelastic) are the pre-written macros which should work. Note that these macros depend on the "flat" parallel world gdml file, which is also generated by this script and copied into the correct place. These sample macros are adequate, though please note which magnetic fields are used, as well as the GDML geometry, raster selection, and kryptonite settings. These choices were somewhat arbitrary when the macros were committed. +* nameStub: "moller" (or epelastic or epinelastic) are what you should probably use here. This field is just to avoid having to parse whatever macro's name is given and is used as the remollout_NAME.root output. +* cadp.csv: "cadp.csv" is the usual name of the csv file that will be used in the perl scripts in the remoll-detector-generator scripts. The file is assumed to live inside that repository, and that repository is assumed to be parallel to the current install of remoll (three levels up). + +In order for the flux that is produced to be useful, edit mollerParallel.gdml to only have the detectors you want. The flat parameterized detector from the detector perl scripts should be used to interface with the full-scan.sh. + +Once you have generated the outputs, please make sure that none of the individual jobs have segfaulted or failed in any way. If they have then just go and manually re-run that failed job. + +Once all of the jobs are done the easiest thing to do is execute `hadd -f moller.root out_moller_*/remollout_parallel_moller.root`, which merges them all into one. Because of the way that remoll samples and assigns relative weights, it is important for you to know the uA beam current that was assumed while simulating and the number of individual jobs that were `hadd` together. The rates in any one remoll job are self normalized so that that one job stands alone. `hadd` multiple jobs together will then multiply the rates higher by the multiplicity of separate jobs. Similarly if you want the rate in Hz/uA you need to later divide by the number of uA (which is 65 uA in the sameple macros given). + +### scan.sh +Usage: `./scripts/scan.sh fixed-non-scanned "variable-to-scan" min-of-scan (-30) max-of-scan (30) step-size (0.5) Reflectivity Cerenkov Scintillation z_position Pass Detector` + +This script assumes that a "Geometry name" suffix'ed set of GDML files has been placed in the geometry_sandbox folder of remoll, and that the user wants to scan shooting at different positions or angles onto the light guide. The angles, x position, and z position of the beam generator are passed in as arguments. Practically speaking this script needs to just be called from within the `scripts/full-scan.sh` script, which knows to produce the GDML files itself and read the cadp.csv file to know what x and z points to shoot the beam from. The analysis requires 2 passes, to simulate and then analyze the sim outputs. And the outputs come in the scans.root output file that contains several metrics, including average number of pes and it's RMS, as well as number of bounces against the reflector, lightguide, and both, as well as the input command line parameters. + +The arguments are as follows: +* fixed-non-scanned: "0.0" is the default number here, which decides the fixed value of the fixed "variable-to-scan" determined in the next argument. +* variable-to-scan: Typing "angle" or "x" here refers to whether the scan is over "angle" or "x", with the other variable held fixed, at the value given in the previous argument. Angle is in degrees, and x is in cm. +* min-of-scan: "-30" is the default number here, which is the minimum value of the scanned variable (in degrees, or cm, if angle or x is scanned, respectively). +* max-of-scan: "30" is similarly the max. +* step-size: "0.5" is the default step size, and determines the steps between min and max (can be any double). +* Reflectivity: "0.9" is the default reflectivity. This variable edits the material properties in the gdml files before beginning the simulation. +* Cerenkov: "1.0" is a boolean (it's bash... 1.0 means it is turned on, and 0.0 means it is turned off. Really anything other than 0.0 will turn it on) to edit the macro file and turn cerenkov on or off. The Macro is assumed to be macros/preserve_scans.mac (and can be editted by the user if wanted.) +* Scintillation: "1.0" is a boolean (it's bash... 1.0 means it is turned on, and 0.0 means it is turned off. Really anything other than 0.0 will turn it on) to edit the macro file and turn scintillation on or off. The Macro is assumed to be macros/preserve_scans.mac (and can be editted by the user if wanted.) +* z position of the beam origin: "0" is the default starting point, defining the origin of the beam (plus raster) that is used to spray the detector. This number will be edited within the script to adjust for the angle of the light guide and reflector so that the beam starts as close to the detector as possible. This number should be determined empirically using the macros/detector_vis.mac macro (probably needs to be in the higher remoll macros folder to get picked up correctly). The full-scan.sh and ref-scan.sh scripts have their own ways of determining what this number should be (also was determined partially empirically). +* Geometry name: "Mainz" or "R5o" or "R1", etc. are names that are used to determing the GDML files used (as well as the detector number based on ring name, though det number is the final paramter that can be passed in by hand). +* Pass: "1" or "2". "1" means it is the first pass, when the simulation jobs are submitted. "2" means the `pe` analysis pass, where the outputs are analyzed (and if pass 1 segfaulted it will resubmit the job. This is convenient for relatively small numbers of jobs, but when it gets to the thousands something better like the sub-ref-scan.sh approach is preferable). +* detector: "540210" is the detector number, which can be determined automatically if the "Geometry name" input was a ring number ("R1", "R2" ... "R5o", "R6"), but must be passed by hand for unique GDML geometry names. +### full-scan.sh +This is a script that wraps around scan.sh to produce a lookup table's worth of angle and light guide length (x) hits. The results can be `hadd` together to be fed as input into the `scripts/do_all_rates.sh` calculation that generates the `scripts/produce.sh` convoluted signal and background results. + +### do_all_rates.sh +This script assumes several files are already in place and will complain if they are not in the right places or with the right names. Do `scripts/produce.sh` and `scripts/full-scan.sh` first to properly prepare for getting the lightguide backgrounds lookup table folded into the MOLLER flux for final numbers. Please note that the "signal" size has been assumed at 12 PEs vs 25 PEs for rings 1,2,3,4, and 6, vs 5, respectively. The "background" signal is entirely determined by the lookup table coming from the `scripts/full-scan.sh` analysis. +### ref-scan.sh +This is a script that will allow you to scan the reflector length and reflector angle parameters to determine the ideal size and angle of the reflector segment for ideal light collection. Parameters for cerenkov and scintillation can be turned on and off to help understand what is happening. With some care, the relflectivity of the reflector section and the light guide section could be separated from eachother and this can be used to determine the impact of blackening in the light guide section (you would need to edit the material property names or values by hand in the GDML files copied into this analysis in order for that test to be feasible, though it has been done before. See the logic surrounding the Reflectivity parameter in these scripts for guidance on how to achieve this) +This script is run similarly to scan.sh. For instructions on general parameters to enter, input ./scripts/ref-scan.sh +### sub-ref-scan.sh +This script executes similarly to `scripts/ref-scan.sh`, but it loops over sub-segments of the reflector, allowing fine tuning of a fresnel-type mirror, for optimal light collection. This is just one easiest way that the light guides and reflectors can be studied in addition to the default flat segments we have started with. +### getMax.C +This script assumes you have produced a sub-ref-scan.sh analysis (which by the way takes a really long time, like 4 days worth of simulation time at 30 jobs at a time). Once that analysis is done you should hadd all of its scans.root files into one single file and feed that file into the getMax.C scripst as the first argument. The second argument should be a double == to the value of the mean PE counts when there is NO reflector section at all (i.e. it is the amount of PEs from photons that never hit the reflector section in the first place, which are duplicate counted for each independent simulation of sub-segments). + +Setting up a no-reflector simulation should be as simple as taking one of the many job outputs from sub-ref-scan.sh and changing the geometry to comment out the reflector_540210 (or whatever detector number) component (not reflectorSkin though, that is the other-walls of the reflector section). + +## Look up table prediction of signal to background ratios in MOLLER detectors === +* First, produce a flux at the detector array to sample from + * Run scripts/produce.sh for moller, epelastic, and epinelastic - 5 million events (50x 100k jobs) is a good high statistics goal + * Note that mocha.physics.umass.edu often segfaults jobs, and so you may need to redo some of them by hand + * Then hadd moller.root out\_moller\_\*/remollout\_\*.root + * Again for epelastic and epinelastic + * Move these sample files to the folder of choice for doing subsequent analysis +* Run scripts/full-scan.sh to create a look up table of light guide PE yields for the geometry +* Then run bkgd_pe on the flux sample root files you have to generate outputs + + +## Final notes +Always check for segfault failed runs before proceeding. +Delete core-dump failed rootfiles and when confident with results also delete the root files systematically to save disk space. diff --git a/analysis/pe_studies/active-SD-mollerParallel.gdml b/analysis/pe_studies/active-SD-mollerParallel.gdml new file mode 100644 index 000000000..4cad12b4f --- /dev/null +++ b/analysis/pe_studies/active-SD-mollerParallel.gdml @@ -0,0 +1,225 @@ + + + + +]> + + + + + &positions; + + + + + + + + &world; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/analysis/pe_studies/macros/detector_vis.mac b/analysis/pe_studies/macros/detector_vis.mac new file mode 100644 index 000000000..711c393b6 --- /dev/null +++ b/analysis/pe_studies/macros/detector_vis.mac @@ -0,0 +1,62 @@ +# Use this open statement to create an OpenGL view: +/vis/open OGL 600x600-0+0 + +#/remoll/physlist/parallel/disable +#/remoll/physlist/optical/enable +/remoll/physlist/parallel/enable +/remoll/physlist/optical/disable + +# This is the current working geometry +/remoll/setgeofile geometry/mollerMother_merged.gdml + +#/remoll/likekryptonite true + +#Below the this energy, the tracks are killed +#/remoll/minEnergyCut 0 MeV + +#/remoll/setphysicslist QGSP_BERT_EMV + +/run/initialize + +/remoll/SD/enable_all + +#/remoll/beamene 11.0 GeV +/remoll/beamene 855 MeV +/remoll/beamcurr 50 microampere +#/remoll/optical true +#/remoll/addfield CLEO_rm.dat +/control/execute ../../vis/vis.mac +#/gun/position 0.0 0.0 -0.1 m +#/gun/momentum 0.5 1.0 2.0 GeV + +# Raster is on by default with 5x5mm +/remoll/rasx 5 mm +/remoll/rasy 5 mm + +## Beam generator +/remoll/evgen/set beam +#/remoll/evgen/beam/origin -987.5,0.0,-150.0 mm +/remoll/evgen/beam/origin -987.5 -1.0 21850.0 mm +/remoll/evgen/beam/rasterRefZ 21850 mm +#/remoll/evgen/beam/x -987.5 mm +/remoll/evgen/beam/direction -0.0523 0.0 0.9986 +/remoll/evgen/beam/rasx 105.0 mm +/remoll/evgen/beam/rasy 78.0 mm +/remoll/evgen/beam/partName e- +#/remoll/evgen/beam/x -987.5 mm +#/remoll/evgen/beam/z -150.0 mm +#/remoll/evgen/beam/px -0.0523 +#/remoll/evgen/beam/pz 0.9986 +/remoll/filename remollout_r5o_beam_default.root + + +## External Generator +#/remoll/evgen/set external +#/remoll/evgen/external/file remoll_moller_envelope_noCol4_noCoils_500k_LGtest_det28.root +#/remoll/evgen/external/detid 28 +#/remoll/evgen/external/startEvent 0 +#/remoll/evgen/external/zOffset -28550.0 +#/remoll/filename remollout_r5o_external_default.root + + +#/run/beamOn 100 diff --git a/analysis/pe_studies/macros/preserve_recreate-brad.mac b/analysis/pe_studies/macros/preserve_recreate-brad.mac new file mode 100644 index 000000000..87ba63d4b --- /dev/null +++ b/analysis/pe_studies/macros/preserve_recreate-brad.mac @@ -0,0 +1,68 @@ +# Recreating the Mainz beam test + +# These must be called before initialize +/remoll/setgeofile geometry_sandbox/mollerMother_Mainz.gdml +/remoll/physlist/parallel/disable +/remoll/physlist/optical/enable + +/process/optical/processActivation Cerenkov false +/process/optical/processActivation Scintillation false + +/process/optical/setTrackSecondariesFirst Cerenkov true +/process/optical/setTrackSecondariesFirst Scintillation true + +# This must be explicitly called +/run/initialize + +/process/optical/cerenkov/setTrackSecondariesFirst true +/process/optical/cerenkov/setMaxPhotons 2000 +/process/optical/scintillation/setTrackSecondariesFirst true +/process/optical/scintillation/setYieldFactor 1.0 +/process/optical/scintillation/setExcitationRatio 0.0 + +/remoll/SD/enable_all + +/remoll/printgeometry true + +#/remoll/scalefield map_directory/blockyHybrid_rm_3.0.txt 1.0 +#/remoll/magcurrent map_directory/blockyHybrid_rm_3.0.txt 1000.0 A + +# Raster and initial angle stuff +/remoll/oldras true +#/remoll/rasx 0 mm +#/remoll/rasy 10 mm + +#Set Beam Generator settings +/remoll/evgen/set beam +#/run/beamOn 0 + + +#---------------------------------------- + +# Kill tracks on interactions with W, Cu, and Pb +#/control/execute macros/kryptonite.mac + +/process/list + +# Electrons incident on quartz------------ + +#/process/optical/cerenkov/setMaxPhotons 0 +# (Quartz center, - 1/2 of quartz length, - full distance to PMT )/2 +# (-987.5-75 -1350 )/2 = 1206.25 +/remoll/evgen/beam/rasterRefZ 0.0 mm +/remoll/evgen/beam/origin 0.0 0.0 0.0 mm +/remoll/evgen/beam/th -11.5 deg +#/remoll/evgen/beam/x -1206.25 mm +#/remoll/evgen/beam/z 45.0 mm +#-11.5 degrees /remoll/evgen/beam/th -0.1047 +#/remoll/evgen/beam/direction -0.19937 0.0 0.97992 +#/remoll/evgen/beam/th -11.5 deg +/remoll/evgen/beam/rasx 0.0 mm +/remoll/evgen/beam/rasy 10.0 mm +/remoll/beamene 850 MeV + +/remoll/evgen/beam/partName e- + +/remoll/filename remollout_Mainz_0.0_degrees_0.0_x.root + +/run/beamOn 100000 diff --git a/analysis/pe_studies/macros/preserve_ref_scans.mac b/analysis/pe_studies/macros/preserve_ref_scans.mac new file mode 100644 index 000000000..d7ebadf7d --- /dev/null +++ b/analysis/pe_studies/macros/preserve_ref_scans.mac @@ -0,0 +1,67 @@ +# Recreating the Mainz beam test + +# These must be called before initialize +/remoll/setgeofile geometry_sandbox/mollerMother_Mainz.gdml +/remoll/physlist/parallel/disable +/remoll/physlist/optical/enable + +/process/optical/processActivation Cerenkov false +/process/optical/processActivation Scintillation false + +/process/optical/setTrackSecondariesFirst Cerenkov true +/process/optical/setTrackSecondariesFirst Scintillation true + +# This must be explicitly called +/run/initialize + +/process/optical/cerenkov/setTrackSecondariesFirst true +/process/optical/cerenkov/setMaxPhotons 2000 +/process/optical/scintillation/setTrackSecondariesFirst true +/process/optical/scintillation/setYieldFactor 1.0 +/process/optical/scintillation/setExcitationRatio 0.0 + +/remoll/SD/enable_all + +/remoll/printgeometry true + +#/remoll/scalefield map_directory/blockyHybrid_rm_3.0.txt 1.0 +#/remoll/magcurrent map_directory/blockyHybrid_rm_3.0.txt 1000.0 A + +# Raster and initial angle stuff +/remoll/oldras true +#/remoll/rasx 0 mm +#/remoll/rasy 10 mm + +#Set Beam Generator settings +/remoll/evgen/set beam +#/run/beamOn 0 + + +#---------------------------------------- + +# Kill tracks on interactions with W, Cu, and Pb +#/control/execute macros/kryptonite.mac + +/process/list + +# Electrons incident on quartz------------ + +#/process/optical/cerenkov/setMaxPhotons 0 +# (Quartz center, - 1/2 of quartz length, - full distance to PMT )/2 +# (-987.5-75 -1350 )/2 = 1206.25 +/remoll/evgen/beam/rasterRefZ 0.0 mm +/remoll/evgen/beam/origin 0.0 0.0 0.0 mm +/remoll/evgen/beam/th -11.5 deg +#/remoll/evgen/beam/x -1206.25 mm +#/remoll/evgen/beam/z 45.0 mm +#-11.5 degrees /remoll/evgen/beam/th -0.1047 +#/remoll/evgen/beam/direction -0.19937 0.0 0.97992 +/remoll/evgen/beam/rasx 25.0 mm +/remoll/evgen/beam/rasy 25.0 mm +/remoll/beamene 8000 MeV + +/remoll/evgen/beam/partName e- + +/remoll/filename remollout_Mainz_0.0_degrees_0.0_x.root + +/run/beamOn 5000 diff --git a/analysis/pe_studies/macros/preserve_scans.mac b/analysis/pe_studies/macros/preserve_scans.mac new file mode 100644 index 000000000..5b73ac5ee --- /dev/null +++ b/analysis/pe_studies/macros/preserve_scans.mac @@ -0,0 +1,67 @@ +# Recreating the Mainz beam test + +# These must be called before initialize +/remoll/setgeofile geometry_sandbox/mollerMother_Mainz.gdml +/remoll/physlist/parallel/disable +/remoll/physlist/optical/enable + +/process/optical/processActivation Cerenkov false +/process/optical/processActivation Scintillation false + +/process/optical/setTrackSecondariesFirst Cerenkov true +/process/optical/setTrackSecondariesFirst Scintillation true + +# This must be explicitly called +/run/initialize + +/process/optical/cerenkov/setTrackSecondariesFirst true +/process/optical/cerenkov/setMaxPhotons 2000 +/process/optical/scintillation/setTrackSecondariesFirst true +/process/optical/scintillation/setYieldFactor 1.0 +/process/optical/scintillation/setExcitationRatio 0.0 + +/remoll/SD/enable_all + +/remoll/printgeometry true + +#/remoll/scalefield map_directory/blockyHybrid_rm_3.0.txt 1.0 +#/remoll/magcurrent map_directory/blockyHybrid_rm_3.0.txt 1000.0 A + +# Raster and initial angle stuff +/remoll/oldras true +#/remoll/rasx 0 mm +#/remoll/rasy 10 mm + +#Set Beam Generator settings +/remoll/evgen/set beam +#/run/beamOn 0 + + +#---------------------------------------- + +# Kill tracks on interactions with W, Cu, and Pb +#/control/execute macros/kryptonite.mac + +/process/list + +# Electrons incident on quartz------------ + +#/process/optical/cerenkov/setMaxPhotons 0 +# (Quartz center, - 1/2 of quartz length, - full distance to PMT )/2 +# (-987.5-75 -1350 )/2 = 1206.25 +/remoll/evgen/beam/rasterRefZ 0.0 mm +/remoll/evgen/beam/origin 0.0 0.0 0.0 mm +/remoll/evgen/beam/th -11.5 deg +#/remoll/evgen/beam/x -1206.25 mm +#/remoll/evgen/beam/z 45.0 mm +#-11.5 degrees /remoll/evgen/beam/th -0.1047 +#/remoll/evgen/beam/direction -0.19937 0.0 0.97992 +/remoll/evgen/beam/rasx 2.5 mm +/remoll/evgen/beam/rasy 10.0 mm +/remoll/beamene 8000 MeV + +/remoll/evgen/beam/partName e- + +/remoll/filename remollout_Mainz_0.0_degrees_0.0_x.root + +/run/beamOn 10000 diff --git a/analysis/pe_studies/macros/runexample_epelastic_parallel.mac b/analysis/pe_studies/macros/runexample_epelastic_parallel.mac new file mode 100644 index 000000000..1eb095bc2 --- /dev/null +++ b/analysis/pe_studies/macros/runexample_epelastic_parallel.mac @@ -0,0 +1,181 @@ +# Example file + +# store tracks +#/tracking/storeTrajectory 1 + +# This must be called before initialize +/remoll/geometry/setfile geometry/mollerMother_merged.gdml +# Parallel world geometry is optional - detector 28 (the primary detector array's idealize vacuum detector) is included in this parallel world now. +/remoll/parallel/setfile geometry/mollerParallel.gdml + +#/remoll/physlist/register QGSP_BERT_HP +/remoll/physlist/parallel/enable +# if optical physics is turned on it will only work if parallel physics is not turned on. +#/remoll/physlist/optical/enable + +# This must be explicitly called +/run/initialize + +/remoll/SD/disable_all +/remoll/SD/enable 104011 +/remoll/SD/enable 104017 +/remoll/SD/enable 104015 +/remoll/SD/enable 104014 +/remoll/SD/enable 140111 +/remoll/SD/enable 140117 +/remoll/SD/enable 140115 +/remoll/SD/enable 140114 +/remoll/SD/enable 140211 +/remoll/SD/enable 140217 +/remoll/SD/enable 140215 +/remoll/SD/enable 140214 +/remoll/SD/enable 204011 +/remoll/SD/enable 204017 +/remoll/SD/enable 204015 +/remoll/SD/enable 204014 +/remoll/SD/enable 240111 +/remoll/SD/enable 240117 +/remoll/SD/enable 240115 +/remoll/SD/enable 240114 +/remoll/SD/enable 240211 +/remoll/SD/enable 240217 +/remoll/SD/enable 240215 +/remoll/SD/enable 240214 +/remoll/SD/enable 304011 +/remoll/SD/enable 304017 +/remoll/SD/enable 304015 +/remoll/SD/enable 304014 +/remoll/SD/enable 340111 +/remoll/SD/enable 340117 +/remoll/SD/enable 340115 +/remoll/SD/enable 340114 +/remoll/SD/enable 340211 +/remoll/SD/enable 340217 +/remoll/SD/enable 340215 +/remoll/SD/enable 340214 +/remoll/SD/enable 404011 +/remoll/SD/enable 404017 +/remoll/SD/enable 404015 +/remoll/SD/enable 404014 +/remoll/SD/enable 440111 +/remoll/SD/enable 440117 +/remoll/SD/enable 440115 +/remoll/SD/enable 440114 +/remoll/SD/enable 440211 +/remoll/SD/enable 440217 +/remoll/SD/enable 440215 +/remoll/SD/enable 440214 +/remoll/SD/enable 504001 +/remoll/SD/enable 504007 +/remoll/SD/enable 504005 +/remoll/SD/enable 504004 +/remoll/SD/enable 504011 +/remoll/SD/enable 504017 +/remoll/SD/enable 504015 +/remoll/SD/enable 504014 +/remoll/SD/enable 504021 +/remoll/SD/enable 504027 +/remoll/SD/enable 504025 +/remoll/SD/enable 504024 +/remoll/SD/enable 540101 +/remoll/SD/enable 540107 +/remoll/SD/enable 540105 +/remoll/SD/enable 540104 +/remoll/SD/enable 540111 +/remoll/SD/enable 540117 +/remoll/SD/enable 540115 +/remoll/SD/enable 540114 +/remoll/SD/enable 540121 +/remoll/SD/enable 540127 +/remoll/SD/enable 540125 +/remoll/SD/enable 540124 +/remoll/SD/enable 540201 +/remoll/SD/enable 540207 +/remoll/SD/enable 540205 +/remoll/SD/enable 540204 +/remoll/SD/enable 540211 +/remoll/SD/enable 540217 +/remoll/SD/enable 540215 +/remoll/SD/enable 540214 +/remoll/SD/enable 540221 +/remoll/SD/enable 540227 +/remoll/SD/enable 540225 +/remoll/SD/enable 540224 +/remoll/SD/enable 604011 +/remoll/SD/enable 604017 +/remoll/SD/enable 604015 +/remoll/SD/enable 604014 +/remoll/SD/enable 640111 +/remoll/SD/enable 640117 +/remoll/SD/enable 640115 +/remoll/SD/enable 640114 +/remoll/SD/enable 640211 +/remoll/SD/enable 640217 +/remoll/SD/enable 640215 +/remoll/SD/enable 640214 + +/control/execute macros/load_magnetic_fieldmaps.mac + +# Raster and initial angle stuff +/remoll/oldras true +/remoll/rasx 5 mm +/remoll/rasy 5 mm +#/remoll/beam_x0 0 mm +#/remoll/beam_y0 0 mm +# initial angle +#/remoll/beam_th0 0 mrad +#/remoll/beam_ph0 0 mrad +# gaussian spread widths +#/remoll/beam_dth 0 mrad +#/remoll/beam_dph 0 mrad + +#/remoll/evgen/set beam +# To hit Ring 5 open in septant 4 +#/remoll/evgen/beam/x -1300 mm +#/remoll/evgen/beam/rasx -30 mm +#/remoll/evgen/beam/origin -987.5 0 -50 mm +#/remoll/evgen/beam/direction (-0.0523,0,0.9986) +# Mainz test energy +#/remoll/beamene 855 MeV + +/remoll/evgen/set elastic +#/remoll/evgen/thcommin 30.0 deg +#/remoll/evgen/thcommax 150.0 deg +#/remoll/evgen/set elastic +#/remoll/evgen/thmin 0.1 deg +#/remoll/evgen/thmax 2.0 deg +#/remoll/evgen/emin 80.0 MeV +#/remoll/evgen/set inelastic +#/remoll/evgen/set pion +#/remoll/piontype pi+ +#/remoll/evgen/set pion_LUND +#/remoll/evgen/set inelasticAl +#/remoll/evgen/set quasielasticAl +#/remoll/evgen/set elasticAl +#/remoll/evgen/set external +#/remoll/externalfile remollout.root +#/remoll/externaldetid 4051 + +#/remoll/evgen/beamPolarization +L +#/remoll/field/equationtype 2 +#/remoll/field/steppertype 2 +#/remoll/field/print + +/remoll/beamene 11 GeV + +/remoll/beamcurr 65 microampere + +# Make interactions with W, Cu, and Pb +# realistic rather than pure absorbers +/control/execute macros/kryptonite.mac + +/process/list + +# Specify random number seed +#/remoll/seed 123456 + +/remoll/filename remollout_parallel_epelastic.root + +#/tracking/verbose 2 +/remoll/printtargetinfo +/run/beamOn 100000 diff --git a/analysis/pe_studies/macros/runexample_epinelastic_parallel.mac b/analysis/pe_studies/macros/runexample_epinelastic_parallel.mac new file mode 100644 index 000000000..478e3b870 --- /dev/null +++ b/analysis/pe_studies/macros/runexample_epinelastic_parallel.mac @@ -0,0 +1,181 @@ +# Example file + +# store tracks +#/tracking/storeTrajectory 1 + +# This must be called before initialize +/remoll/geometry/setfile geometry/mollerMother_merged.gdml +# Parallel world geometry is optional - detector 28 (the primary detector array's idealize vacuum detector) is included in this parallel world now. +/remoll/parallel/setfile geometry/mollerParallel.gdml + +#/remoll/physlist/register QGSP_BERT_HP +/remoll/physlist/parallel/enable +# if optical physics is turned on it will only work if parallel physics is not turned on. +#/remoll/physlist/optical/enable + +# This must be explicitly called +/run/initialize + +/remoll/SD/disable_all +/remoll/SD/enable 104011 +/remoll/SD/enable 104017 +/remoll/SD/enable 104015 +/remoll/SD/enable 104014 +/remoll/SD/enable 140111 +/remoll/SD/enable 140117 +/remoll/SD/enable 140115 +/remoll/SD/enable 140114 +/remoll/SD/enable 140211 +/remoll/SD/enable 140217 +/remoll/SD/enable 140215 +/remoll/SD/enable 140214 +/remoll/SD/enable 204011 +/remoll/SD/enable 204017 +/remoll/SD/enable 204015 +/remoll/SD/enable 204014 +/remoll/SD/enable 240111 +/remoll/SD/enable 240117 +/remoll/SD/enable 240115 +/remoll/SD/enable 240114 +/remoll/SD/enable 240211 +/remoll/SD/enable 240217 +/remoll/SD/enable 240215 +/remoll/SD/enable 240214 +/remoll/SD/enable 304011 +/remoll/SD/enable 304017 +/remoll/SD/enable 304015 +/remoll/SD/enable 304014 +/remoll/SD/enable 340111 +/remoll/SD/enable 340117 +/remoll/SD/enable 340115 +/remoll/SD/enable 340114 +/remoll/SD/enable 340211 +/remoll/SD/enable 340217 +/remoll/SD/enable 340215 +/remoll/SD/enable 340214 +/remoll/SD/enable 404011 +/remoll/SD/enable 404017 +/remoll/SD/enable 404015 +/remoll/SD/enable 404014 +/remoll/SD/enable 440111 +/remoll/SD/enable 440117 +/remoll/SD/enable 440115 +/remoll/SD/enable 440114 +/remoll/SD/enable 440211 +/remoll/SD/enable 440217 +/remoll/SD/enable 440215 +/remoll/SD/enable 440214 +/remoll/SD/enable 504001 +/remoll/SD/enable 504007 +/remoll/SD/enable 504005 +/remoll/SD/enable 504004 +/remoll/SD/enable 504011 +/remoll/SD/enable 504017 +/remoll/SD/enable 504015 +/remoll/SD/enable 504014 +/remoll/SD/enable 504021 +/remoll/SD/enable 504027 +/remoll/SD/enable 504025 +/remoll/SD/enable 504024 +/remoll/SD/enable 540101 +/remoll/SD/enable 540107 +/remoll/SD/enable 540105 +/remoll/SD/enable 540104 +/remoll/SD/enable 540111 +/remoll/SD/enable 540117 +/remoll/SD/enable 540115 +/remoll/SD/enable 540114 +/remoll/SD/enable 540121 +/remoll/SD/enable 540127 +/remoll/SD/enable 540125 +/remoll/SD/enable 540124 +/remoll/SD/enable 540201 +/remoll/SD/enable 540207 +/remoll/SD/enable 540205 +/remoll/SD/enable 540204 +/remoll/SD/enable 540211 +/remoll/SD/enable 540217 +/remoll/SD/enable 540215 +/remoll/SD/enable 540214 +/remoll/SD/enable 540221 +/remoll/SD/enable 540227 +/remoll/SD/enable 540225 +/remoll/SD/enable 540224 +/remoll/SD/enable 604011 +/remoll/SD/enable 604017 +/remoll/SD/enable 604015 +/remoll/SD/enable 604014 +/remoll/SD/enable 640111 +/remoll/SD/enable 640117 +/remoll/SD/enable 640115 +/remoll/SD/enable 640114 +/remoll/SD/enable 640211 +/remoll/SD/enable 640217 +/remoll/SD/enable 640215 +/remoll/SD/enable 640214 + +/control/execute macros/load_magnetic_fieldmaps.mac + +# Raster and initial angle stuff +/remoll/oldras true +/remoll/rasx 5 mm +/remoll/rasy 5 mm +#/remoll/beam_x0 0 mm +#/remoll/beam_y0 0 mm +# initial angle +#/remoll/beam_th0 0 mrad +#/remoll/beam_ph0 0 mrad +# gaussian spread widths +#/remoll/beam_dth 0 mrad +#/remoll/beam_dph 0 mrad + +#/remoll/evgen/set beam +# To hit Ring 5 open in septant 4 +#/remoll/evgen/beam/x -1300 mm +#/remoll/evgen/beam/rasx -30 mm +#/remoll/evgen/beam/origin -987.5 0 -50 mm +#/remoll/evgen/beam/direction (-0.0523,0,0.9986) +# Mainz test energy +#/remoll/beamene 855 MeV + +/remoll/evgen/set inelastic +#/remoll/evgen/thcommin 30.0 deg +#/remoll/evgen/thcommax 150.0 deg +#/remoll/evgen/set elastic +#/remoll/evgen/thmin 0.1 deg +#/remoll/evgen/thmax 2.0 deg +#/remoll/evgen/emin 80.0 MeV +#/remoll/evgen/set inelastic +#/remoll/evgen/set pion +#/remoll/piontype pi+ +#/remoll/evgen/set pion_LUND +#/remoll/evgen/set inelasticAl +#/remoll/evgen/set quasielasticAl +#/remoll/evgen/set elasticAl +#/remoll/evgen/set external +#/remoll/externalfile remollout.root +#/remoll/externaldetid 4051 + +#/remoll/evgen/beamPolarization +L +#/remoll/field/equationtype 2 +#/remoll/field/steppertype 2 +#/remoll/field/print + +/remoll/beamene 11 GeV + +/remoll/beamcurr 65 microampere + +# Make interactions with W, Cu, and Pb +# realistic rather than pure absorbers +/control/execute macros/kryptonite.mac + +/process/list + +# Specify random number seed +#/remoll/seed 123456 + +/remoll/filename remollout_parallel_epinelastic.root + +#/tracking/verbose 2 +/remoll/printtargetinfo +/run/beamOn 100000 diff --git a/analysis/pe_studies/macros/runexample_moller_parallel.mac b/analysis/pe_studies/macros/runexample_moller_parallel.mac new file mode 100644 index 000000000..3f223e144 --- /dev/null +++ b/analysis/pe_studies/macros/runexample_moller_parallel.mac @@ -0,0 +1,181 @@ +# Example file + +# store tracks +#/tracking/storeTrajectory 1 + +# This must be called before initialize +/remoll/geometry/setfile geometry/mollerMother_merged.gdml +# Parallel world geometry is optional - detector 28 (the primary detector array's idealize vacuum detector) is included in this parallel world now. +/remoll/parallel/setfile geometry/mollerParallel.gdml + +#/remoll/physlist/register QGSP_BERT_HP +/remoll/physlist/parallel/enable +# if optical physics is turned on it will only work if parallel physics is not turned on. +#/remoll/physlist/optical/enable + +# This must be explicitly called +/run/initialize + +/remoll/SD/disable_all +/remoll/SD/enable 104011 +/remoll/SD/enable 104017 +/remoll/SD/enable 104015 +/remoll/SD/enable 104014 +/remoll/SD/enable 140111 +/remoll/SD/enable 140117 +/remoll/SD/enable 140115 +/remoll/SD/enable 140114 +/remoll/SD/enable 140211 +/remoll/SD/enable 140217 +/remoll/SD/enable 140215 +/remoll/SD/enable 140214 +/remoll/SD/enable 204011 +/remoll/SD/enable 204017 +/remoll/SD/enable 204015 +/remoll/SD/enable 204014 +/remoll/SD/enable 240111 +/remoll/SD/enable 240117 +/remoll/SD/enable 240115 +/remoll/SD/enable 240114 +/remoll/SD/enable 240211 +/remoll/SD/enable 240217 +/remoll/SD/enable 240215 +/remoll/SD/enable 240214 +/remoll/SD/enable 304011 +/remoll/SD/enable 304017 +/remoll/SD/enable 304015 +/remoll/SD/enable 304014 +/remoll/SD/enable 340111 +/remoll/SD/enable 340117 +/remoll/SD/enable 340115 +/remoll/SD/enable 340114 +/remoll/SD/enable 340211 +/remoll/SD/enable 340217 +/remoll/SD/enable 340215 +/remoll/SD/enable 340214 +/remoll/SD/enable 404011 +/remoll/SD/enable 404017 +/remoll/SD/enable 404015 +/remoll/SD/enable 404014 +/remoll/SD/enable 440111 +/remoll/SD/enable 440117 +/remoll/SD/enable 440115 +/remoll/SD/enable 440114 +/remoll/SD/enable 440211 +/remoll/SD/enable 440217 +/remoll/SD/enable 440215 +/remoll/SD/enable 440214 +/remoll/SD/enable 504001 +/remoll/SD/enable 504007 +/remoll/SD/enable 504005 +/remoll/SD/enable 504004 +/remoll/SD/enable 504011 +/remoll/SD/enable 504017 +/remoll/SD/enable 504015 +/remoll/SD/enable 504014 +/remoll/SD/enable 504021 +/remoll/SD/enable 504027 +/remoll/SD/enable 504025 +/remoll/SD/enable 504024 +/remoll/SD/enable 540101 +/remoll/SD/enable 540107 +/remoll/SD/enable 540105 +/remoll/SD/enable 540104 +/remoll/SD/enable 540111 +/remoll/SD/enable 540117 +/remoll/SD/enable 540115 +/remoll/SD/enable 540114 +/remoll/SD/enable 540121 +/remoll/SD/enable 540127 +/remoll/SD/enable 540125 +/remoll/SD/enable 540124 +/remoll/SD/enable 540201 +/remoll/SD/enable 540207 +/remoll/SD/enable 540205 +/remoll/SD/enable 540204 +/remoll/SD/enable 540211 +/remoll/SD/enable 540217 +/remoll/SD/enable 540215 +/remoll/SD/enable 540214 +/remoll/SD/enable 540221 +/remoll/SD/enable 540227 +/remoll/SD/enable 540225 +/remoll/SD/enable 540224 +/remoll/SD/enable 604011 +/remoll/SD/enable 604017 +/remoll/SD/enable 604015 +/remoll/SD/enable 604014 +/remoll/SD/enable 640111 +/remoll/SD/enable 640117 +/remoll/SD/enable 640115 +/remoll/SD/enable 640114 +/remoll/SD/enable 640211 +/remoll/SD/enable 640217 +/remoll/SD/enable 640215 +/remoll/SD/enable 640214 + +/control/execute macros/load_magnetic_fieldmaps.mac + +# Raster and initial angle stuff +/remoll/oldras true +/remoll/rasx 5 mm +/remoll/rasy 5 mm +#/remoll/beam_x0 0 mm +#/remoll/beam_y0 0 mm +# initial angle +#/remoll/beam_th0 0 mrad +#/remoll/beam_ph0 0 mrad +# gaussian spread widths +#/remoll/beam_dth 0 mrad +#/remoll/beam_dph 0 mrad + +#/remoll/evgen/set beam +# To hit Ring 5 open in septant 4 +#/remoll/evgen/beam/x -1300 mm +#/remoll/evgen/beam/rasx -30 mm +#/remoll/evgen/beam/origin -987.5 0 -50 mm +#/remoll/evgen/beam/direction (-0.0523,0,0.9986) +# Mainz test energy +#/remoll/beamene 855 MeV + +/remoll/evgen/set moller +#/remoll/evgen/thcommin 30.0 deg +#/remoll/evgen/thcommax 150.0 deg +#/remoll/evgen/set elastic +#/remoll/evgen/thmin 0.1 deg +#/remoll/evgen/thmax 2.0 deg +#/remoll/evgen/emin 80.0 MeV +#/remoll/evgen/set inelastic +#/remoll/evgen/set pion +#/remoll/piontype pi+ +#/remoll/evgen/set pion_LUND +#/remoll/evgen/set inelasticAl +#/remoll/evgen/set quasielasticAl +#/remoll/evgen/set elasticAl +#/remoll/evgen/set external +#/remoll/externalfile remollout.root +#/remoll/externaldetid 4051 + +#/remoll/evgen/beamPolarization +L +#/remoll/field/equationtype 2 +#/remoll/field/steppertype 2 +#/remoll/field/print + +/remoll/beamene 11 GeV + +/remoll/beamcurr 65 microampere + +# Make interactions with W, Cu, and Pb +# realistic rather than pure absorbers +/control/execute macros/kryptonite.mac + +/process/list + +# Specify random number seed +#/remoll/seed 123456 + +/remoll/filename remollout_parallel_moller.root + +#/tracking/verbose 2 +/remoll/printtargetinfo +/run/beamOn 100000 diff --git a/analysis/pe_studies/macros/runexample_test-det28_parallel.mac b/analysis/pe_studies/macros/runexample_test-det28_parallel.mac new file mode 100644 index 000000000..b667f625b --- /dev/null +++ b/analysis/pe_studies/macros/runexample_test-det28_parallel.mac @@ -0,0 +1,35 @@ +# This must be called before initialize +/remoll/geometry/setfile geometry/mollerMother_merged.gdml +# Parallel world geometry is optional - detector 28 (the primary detector array's idealize vacuum detector) is included in this parallel world now. +/remoll/parallel/setfile geometry/mollerParallelOrig.gdml + +/remoll/physlist/parallel/enable + +# This must be explicitly called +/run/initialize + +/remoll/SD/disable_all +/remoll/SD/enable 28 +#/remoll/SD/enable 540211 +#/remoll/SD/enable 540217 +#/remoll/SD/enable 540215 +#/remoll/SD/enable 540214 + +/control/execute macros/load_magnetic_fieldmaps.mac + +# Raster and initial angle stuff +#/remoll/oldras false +/remoll/oldras true +/remoll/rasx 5 mm +/remoll/rasy 5 mm + +/remoll/evgen/set moller +/remoll/beamene 11 GeV +/remoll/beamcurr 65 microampere +/control/execute macros/kryptonite.mac +/process/list + +/remoll/filename remollout_testParallel.root + +/remoll/printtargetinfo +/run/beamOn 10000 diff --git a/analysis/pe_studies/scripts/do_all_rates.sh b/analysis/pe_studies/scripts/do_all_rates.sh new file mode 100755 index 000000000..803a1f67a --- /dev/null +++ b/analysis/pe_studies/scripts/do_all_rates.sh @@ -0,0 +1,95 @@ +#!/bin/bash + +if [[ ! -d results ]] ; then + mkdir results +fi +if [[ ! -f results/bkgd_pe ]] ; then + cp -p ../build/bkgd_pe/bkgd_pe results/bkgd_pe +fi +if [[ ! -d results/pdfs ]] ; then + mkdir results/pdfs +fi +if [[ ! -f results/scans_R5o.root ]] ; then + echo "Error: No results/scans_R5o.root exists, trying to do the hadd now. But please verify files are in the \"results\" folder and try again + " + hadd -f scans_R5o.root scans/R5o/out_R5o*/scans.root + mv scans_R5o.root results/scans_R5o.root + exit +fi + +if [ "$#" -lt 3 ] ; then + echo " ERROR, requires at least three inputs, of the names of the ROOT files for sampling rates out of (give the name of the file, not the relative path, sorry) + " + echo " This script will loop over all 6 rings of the MOLLER detector and generate bkgd_pe outputs for moller, epelastic, and epinelastic generators. + " + echo " Warning: This script assumes that there are outputs from \"scripts/produce.sh\" living in the \"results\" folder, as well as results of \"scripts/full-scan.sh\" for each ring R1, R2, R3, R4, R5o (assumes open = trans = closed), and R6, all named as \"scans_R\#.root\" + " + echo " usage: ./do_all_rates.sh mollerRootFileName epelasticRootFileName epinelasticRootFileName [rootFile hadd multiplicity=50.0] [beamCurrent=65.0] [reflectivity=0.7] [cerenkov=1] [scintillation=1]" + exit +else + moller=$1 +fi +if [ "$#" -ge 2 ] ; then + epelastic=$2 +fi +if [ "$#" -ge 3 ] ; then + epinelastic=$3 +fi +if [ "$#" -ge 4 ] ; then + repeatCount=$4 +fi +if [ "$#" -ge 5 ] ; then + beamCurrent=$5 +fi +if [ "$#" -ge 6 ] ; then + reflectivity=$6 +fi +if [ "$#" -ge 7 ] ; then + cer=$7 +fi +if [ "$#" -ge 8 ] ; then + scint=$8 +fi + +cd results + +detectorNumberArray=("104010" "204010" "304010" "404010" "504000" "504010" "504020" "604010" "140110" "240110" "340110" "440110" "540100" "540110" "540120" "640110" "140210" "240210" "340210" "440210" "540200" "540210" "540220" "640210") +detectorNameArray=("R1" "R2" "R3" "R4" "R5o" "R5o" "R5o" "R6" "R1" "R2" "R3" "R4" "R5o" "R5o" "R5o" "R6" "R1" "R2" "R3" "R4" "R5o" "R5o" "R5o" "R6") +analysesArray=("$moller" "$epelastic" "$epinelastic") +# Treat open, trans, and closed as identical geometry for now... seems to be true anyway + +if [[ ! -f $moller ]] ; then + echo "Error: This script is working out of $pwd folder, and $moller does not exist in this \"results\" folder, please place it there and try again. Note that the script input should be the root file name, not the path to it (sorry). + " +fi +if [[ ! -f $epelastic ]] ; then + echo "Error: This script is working out of $pwd folder, and $epelastic does not exist in this \"results\" folder, please place it there and try again. Note that the script input should be the root file name, not the path to it (sorry). + " +fi +if [[ ! -f $epinelastic ]] ; then + echo "Error: This script is working out of $pwd folder, and $epinelastic does not exist in this \"results\" folder, please place it there and try again. Note that the script input should be the root file name, not the path to it (sorry). + " +fi + +for ana in ${analysesArray[@]}; do + for i in ${!detectorNumberArray[@]}; do + if [[ -f scans_${detectorNameArray[${i}]}.root ]] ; then + ./bkgd_pe $ana ${detectorNumberArray[${i}]} ${detectorNameArray[${i}]} signals $reflectivity $cer $scint $beamCurrent $repeatCount + convert ${ana%".root"}_signals_${detectorNumberArray[${i}]}*.png ${ana%".root"}_signals_${detectorNumberArray[${i}]}.pdf + rm *.png + else + echo "No scans_${detectorNameArray[${i}]}.root, skipping to try the next ring" + fi + done + for i in ${!detectorNumberArray[@]}; do + if [[ -f scans_${detectorNameArray[${i}]}.root ]] ; then + ./bkgd_pe $ana ${detectorNumberArray[${i}]} ${detectorNameArray[${i}]} backgrounds $reflectivity $cer $scint $beamCurrent $repeatCount + convert ${ana%".root"}_backgrounds_${detectorNumberArray[${i}]}*.png ${ana%".root"}_backgrounds_${detectorNumberArray[${i}]}.pdf + rm *.png + else + echo "No scans_${detectorNameArray[${i}]}.root, skipping to try the next ring" + fi + done +done +cd - +mv results/*.pdf results/pdfs/ diff --git a/analysis/pe_studies/scripts/full-scan.sh b/analysis/pe_studies/scripts/full-scan.sh new file mode 100755 index 000000000..4d5e6d176 --- /dev/null +++ b/analysis/pe_studies/scripts/full-scan.sh @@ -0,0 +1,133 @@ +#!/bin/bash + +geom="R5o" +if [ "$#" -lt 1 ] ; then + echo " ERROR, requires at least one input + " + echo " This script will generate a geometry from the csv file you feed with the geometry name you give (smart look up which ring to use, read the script for a list) - it then executes scan.sh once for each step in the length along the light guide you chose. + " + echo " This is intended to be used to produce look up tables for background/signal comparisons for MOLLER detectors that have already been optimized. + " + echo " usage: ./full-scan.sh \"geometry = R5o\" [analysis pass = 1] [reflectivity = 0.7] [x step size (cm) = 1.0] [angle step size (degrees) = 0.1] [csv file = \"cadp.csv\"]" + exit +else + geom=$1 +fi + +analysis=1 # Submit jobs = 1, analyze jobs = 2 +reflectivity=0.8 +xPosStep=1.0 # 1 cm steps +angleStep=0.1 # 60 steps per x pos +csv="cadp.csv" +if [ "$#" -gt 1 ] ; then + analysis=$2 +fi +if [ "$#" -gt 2 ] ; then + reflectivity=$3 +fi +if [ "$#" -gt 3 ] ; then + xPosStep=$4 +fi +if [ "$#" -gt 4 ] ; then + angleStep=$5 +fi +if [ "$#" -gt 5 ] ; then + csv=$6 +fi +xPosMin=1040.0 # Reflector begin +xPosMax=1350.0 # PMT begin +angleMin=-6.0 # 3 degrees high +angleMax=0.0 # 3 degrees low +z_pos=0.0 +z_p=0.0 +lgAngle=6.0 + +user_ring="5.0" +det=540210 + +script_ring="5" +if [[ $geom == "R1" ]] ; then + user_ring="1" + script_ring="1" + det=140210 +elif [[ $geom == "R2" ]] ; then + user_ring="2" + script_ring="2" + det=240210 +elif [[ $geom == "R3" ]] ; then + user_ring="3" + script_ring="3" + det=340210 +elif [[ $geom == "R4" ]] ; then + user_ring="4" + script_ring="4" + det=440210 +elif [[ $geom == "R5o" ]] ; then + user_ring="5.0" + script_ring="5" + det=540210 +elif [[ $geom == "R5t" ]] ; then + user_ring="5.1" + script_ring="5trans" + det=540110 +elif [[ $geom == "R5c" ]] ; then + user_ring="5.2" + script_ring="5closed" + det=504010 +elif [[ $geom == "R6" ]] ; then + user_ring="6" + script_ring="6" + det=640210 +fi + +outString="" +OLDIFS=$IFS +IFS="," +while read ring qR qL overlap qThick num2 num3 refL ref_angle lg_angle pmtR tilt pmtRad wallThickness extraPMT1 extraPMT2 z1 z2 +do + if [[ $ring != $user_ring ]] ; then + outString="$outString +$ring,$qR,$qL,$overlap,$qThick,$num2,$num3,$refL,$ref_angle,$lg_angle,$pmtR,$tilt,$pmtRad,$wallThickness,$extraPMT1,$extraPMT2,$z1,$z2" + continue + fi + xPosMax=$(printf "%.2f" "$(bc -l <<< ${pmtR}-10.0)") + xPosMin=$(printf "%.2f" "$(bc -l <<< ${qR}+0.5*${qL}+5.0)") + lgAngle=$lg_angle + z_p=$(printf "%.2f" "$(bc -l <<< ${z1}-0.5*$qThick-$refL*s\(\(${ref_angle}-${lg_angle}\)*3.14159/180.0\))") + echo "$ring $xPosMin $xPosMax z = $z_p starting z = $z1 and second = $z2" + outString="$outString +$ring,$qR,$qL,$overlap,$qThick,$num2,$num3,$refL,$ref_angle,$lg_angle,$pmtR,$tilt,$pmtRad,$wallThickness,$extraPMT1,$extraPMT2,$z1,$z2" +done < $csv +IFS=$OLDIFS + +if [[ ! -f ../../geometry_sandbox/mollerMother_${geom}.gdml ]] ; then + if [[ "$analysis" == "1" ]] ; then + cd ../../../remoll-detector-generator/ + echo "$outString" > cadp_${geom}.csv + perl cadGeneratorV1.pl -F cadp_${geom}.csv + perl gdmlGeneratorV1_materials.pl -M detectorMotherP.csv -D parameter.csv -P qe.txt -U UVS_45total.txt -R MylarRef.txt -L ${script_ring} -T _${geom} + cd - + mv ../../../remoll-detector-generator/*_${geom}.* ../../geometry_sandbox/ + mv ../../../remoll-detector-generator/cadp_${geom}.csv ../../geometry_sandbox/ + fi +fi + +# Rescale numbers to cm from mm +numSteps=$(printf "%.0f" "$(bc -l <<< 0.1*\(${xPosMax}-${xPosMin}\)/$xPosStep)") +echo "$numSteps steps" +for currentStep in `seq 0 $numSteps`; +do + x_pos=$(printf "%.1f" "$(bc -l <<< -0.1*$xPosMin-1.0*$currentStep*$xPosStep)") + z_pos=$(printf "%.1f" "$(bc -l <<< 0.1*$z_p-\(-1.0*$x_pos-0.1*$xPosMin\)*s\(${lgAngle}*3.14159/180.0\))") + + echo "$x_pos $z_pos" + ./scripts/scan.sh $x_pos angle $angleMin $angleMax $angleStep $reflectivity 1 1 $z_pos $geom ${analysis} $det & +done + +if [[ ! -d results ]] ; then + mkdir results +fi +if [[ ! -f results/bkgd_pe ]] ; then + cp ../build/bkgd_pe/bkgd_pe results/bkgd_pe +fi + diff --git a/analysis/pe_studies/scripts/generate-baseline-geometries.sh b/analysis/pe_studies/scripts/generate-baseline-geometries.sh new file mode 100755 index 000000000..0d36e40bc --- /dev/null +++ b/analysis/pe_studies/scripts/generate-baseline-geometries.sh @@ -0,0 +1,72 @@ +#!/bin/bash + +# Takes 5 arguments +# +# Fixed value of non-scanned variable - default = 0.0 +# Variable to scan ("angle" or "x") - default = "angle" +# Min of scanned variable - default = -30 +# Max of scanned variable - default = 30 +# Step size - default = 0.5 + +if [ "$#" -lt 1 ] ; then + echo " ERROR, requires at least one input + " + echo " This script generates geometry from cadp.csv - feed it as an argument either \"all\" or the ring name you want to specifically create (\"R5o\", etc.) + " + exit +fi + + +geom=$1 +user_ring="5.0" +script_ring="5" +if [[ $geom == "R1" ]] ; then + user_ring="1" + script_ring="1" +elif [[ $geom == "R2" ]] ; then + user_ring="2" + script_ring="2" +elif [[ $geom == "R3" ]] ; then + user_ring="3" + script_ring="3" +elif [[ $geom == "R4" ]] ; then + user_ring="4" + script_ring="4" +elif [[ $geom == "R5o" ]] ; then + user_ring="5.0" + script_ring="5" +elif [[ $geom == "R5t" ]] ; then + user_ring="5.1" + script_ring="5trans" +elif [[ $geom == "R5c" ]] ; then + user_ring="5.2" + script_ring="5closed" +elif [[ $geom == "R6" ]] ; then + user_ring="6" + script_ring="6" +fi + +cd ../../../remoll-detector-generator/ +outString="" +OLDIFS=$IFS +IFS="," +while read ring qR qL overlap qThick num2 num3 refL ref_angle lg_angle pmtR tilt pmtRad wallThickness extraPMT1 extraPMT2 z1 z2 +do + if [[ $ring != $user_ring ]] ; then + outString="$outString + $ring,$qR,$qL,$overlap,$qThick,$num2,$num3,$refL,$ref_angle,$lg_angle,$pmtR,$tilt,$pmtRad,$wallThickness,$extraPMT1,$extraPMT2,$z1,$z2" + continue + fi + outString="$outString + $ring,$qR,$qL,$overlap,$qThick,$num2,$num3,$refL,$ref_angle,$lg_angle,$pmtR,$tilt,$pmtRad,$wallThickness,$extraPMT1,$extraPMT2,$z1,$z2" +done < cadp.csv +IFS=$OLDIFS + +echo "$outString" > cadp_${geom}.csv +perl cadGeneratorV1.pl -F cadp_${geom}.csv +perl gdmlGeneratorV1_materials.pl -M detectorMotherP.csv -D parameter.csv -P qe.txt -U UVS_45total.txt -R MylarRef.txt -L ${script_ring} -T _${geom} + +cd - +cp -p ../../../remoll-detector-generator/materialsOptical.xml ../../geometry_sandbox +mv ../../../remoll-detector-generator/cadp_${geom}.csv ../../geometry_sandbox +mv ../../../remoll-detector-generator/*${geom}.* ../../geometry_sandbox diff --git a/analysis/pe_studies/scripts/getMax.C b/analysis/pe_studies/scripts/getMax.C new file mode 100644 index 000000000..71d20db9e --- /dev/null +++ b/analysis/pe_studies/scripts/getMax.C @@ -0,0 +1,84 @@ +void getMax(TString fName = "scans.root",Double_t baseline = 0.0) { + TFile* fFile = TFile::Open(fName); + if (!fFile) { + std::cout<< "ERROR: No file named " << fName << std::endl; + return; + } + TChain* scans = (TChain*) fFile->Get("scans"); + TCanvas * c1 = new TCanvas(); + + Double_t old_integral = baseline; + Double_t new_integral = baseline; + + //(5 tiles of x width, 10 tiles of y length, and fill with the Theta chosen above) + TH2F * improvementHistOld = new TH2F ("ImprovementOld","Original Yield", 5, 0, 5, 10, 0 , 10); + TH2F * improvementHist = new TH2F ("Improvement","Improvement", 5, 0, 5, 10, 0 , 10); + TH2F * oldHist_Theta = new TH2F ("OldThetas","Original Thetas", 5, 0, 5, 10, 0 , 10); + TH2F * oldHist_Phi = new TH2F ("OldPhis","Original Phis", 5, 0, 5, 10, 0 , 10); + TH2F * newHist_Theta = new TH2F ("OptimalThetas","Optimal Thetas", 5, 0, 5, 10, 0 , 10); + TH2F * newHist_Phi = new TH2F ("OptimalPhis","Optimal Phis", 5, 0, 5, 10, 0 , 10); + + c1->cd(1); + for (Int_t i = 0 ; i < 5; i++ ) { + for (Int_t j = 0 ; j < 10; j++ ) { + std::cout<< "Step " << i << " " << j << std::endl; + scans->Draw("theta:phi",Form("avg_pes*(width_step==%d && length_step==%d)",i,j),"COLZ"); + + //c1->SaveAs("test.pdf"); + TH2* hTemp = (TH2*) gROOT->FindObject("htemp"); + Int_t max_bin = hTemp->GetMaximumBin(); + Double_t max_value = hTemp->GetBinContent(max_bin); + new_integral += max_value - baseline; + Int_t xBin, yBin, zBin; + hTemp->GetBinXYZ(max_bin,xBin,yBin,zBin); + std::cout<< "Max bin = " << max_bin << ", and value = " << hTemp->GetBinContent(max_bin) << std::endl; + std::cout<< "Phi max = " << hTemp->GetXaxis()->GetBinCenter(xBin) << std::endl; + std::cout<< "Theta max = " << hTemp->GetYaxis()->GetBinCenter(yBin) << std::endl; + newHist_Theta->Fill(i,j,hTemp->GetYaxis()->GetBinCenter(yBin)); + newHist_Phi->Fill(i,j,hTemp->GetXaxis()->GetBinCenter(xBin)); + + scans->Draw("theta:phi",Form("avg_pes*(phi==0 && theta==0 && width_step==%d && length_step==%d)",i,j),"COLZ"); + + //c1->SaveAs("test.pdf"); + hTemp = (TH2*) gROOT->FindObject("htemp"); + if (!hTemp) {continue;} + Int_t old_max_bin = hTemp->GetMaximumBin(); + Double_t old_max_value = hTemp->GetBinContent(old_max_bin); + old_integral += old_max_value - baseline; + Int_t old_xBin, old_yBin, old_zBin; + hTemp->GetBinXYZ(old_max_bin,old_xBin,old_yBin,old_zBin); + std::cout<< "Old Max bin = " << old_max_bin << ", and value = " << hTemp->GetBinContent(old_max_bin) << std::endl; + std::cout<< "Old Phi max = " << hTemp->GetXaxis()->GetBinCenter(old_xBin) << std::endl; + std::cout<< "Old Theta max = " << hTemp->GetYaxis()->GetBinCenter(old_yBin) << std::endl; + + std::cout<< "Improvement factor = " << max_value/old_max_value << std::endl; + improvementHistOld->Fill(i,j,old_max_value); + improvementHist->Fill(i,j,max_value/old_max_value); + oldHist_Theta->Fill(i,j,hTemp->GetYaxis()->GetBinCenter(old_yBin)); + oldHist_Phi->Fill(i,j,hTemp->GetXaxis()->GetBinCenter(old_xBin)); + max_value = 0.0; + old_max_value = 0.0; + } + } + std::cout<< "\n"; + std::cout<< "\n"; + std::cout<< "Old integral = " << 2*old_integral << ", and new integral = " << 2*new_integral << std::endl; + std::cout<< "Improvement factor = " << new_integral/old_integral << std::endl; + + TCanvas * c2 = new TCanvas(); + c2->Divide(2,2); + c2->cd(1); + improvementHistOld->Draw("COLZ"); + c2->cd(2); + improvementHist->Draw("COLZ"); + c2->cd(3); + newHist_Theta->Draw("COLZ"); + c2->cd(4); + newHist_Phi->Draw("COLZ"); + int dotPos = ((std::string)fName).rfind(".root"); + std::ostringstream os; + os << ((std::string)fName).substr(0, dotPos) << ".pdf"; + std::string fileName = os.str(); + c2->SaveAs(fileName.c_str()); +} + diff --git a/analysis/pe_studies/scripts/produce.sh b/analysis/pe_studies/scripts/produce.sh new file mode 100755 index 000000000..b83d4b911 --- /dev/null +++ b/analysis/pe_studies/scripts/produce.sh @@ -0,0 +1,94 @@ +#!/bin/bash + +# Takes 5 arguments +# +# Fixed value of non-scanned variable - default = 0.0 +# Variable to scan ("angle" or "x") - default = "angle" +# Min of scanned variable - default = -30 +# Max of scanned variable - default = 30 +# Step size - default = 0.5 + +if [ "$#" -lt 1 ] ; then + echo " ERROR, requires at least one input + " + echo " This script generates a geometry from cadp.csv (passed as an argument), then pulls the flat-parallel world version of that geometry into the standard position inside remoll/geometry_sandbox, and then generates a flux of particles incident on that geometry for use in later downstream flux simulations + " + echo " usage: ./produce.sh numberRepeat (no path, just name)macroName.mac nameStub cadp.csv" + exit +fi + +num=0 +macro="detector_runexample.mac" +if [ "$#" -ge 1 ] ; then + num=$1 +fi +if [ "$#" -ge 2 ] ; then + macro="$2" +fi +if [ "$#" -ge 3 ] ; then + stub="$3" +else + stub="produce" +fi +if [ "$#" -ge 4 ] ; then + csv="$4" +else + csv="cadp.csv" +fi + +cd ../../../remoll-detector-generator/ +outString="" +OLDIFS=$IFS +IFS="," +while read ring qR qL overlap qThick num2 num3 refL ref_angle lg_angle pmtR tilt pmtRad wallThickness extraPMT1 extraPMT2 z1 z2 +do + if [[ $outString == "" ]]; then + echo "test 1 " + outString="$ring,$qR,$qL,$overlap,$qThick,$num2,$num3,$refL,$ref_angle,$lg_angle,$pmtR,$tilt,$pmtRad,$wallThickness,$extraPMT1,$extraPMT2,$z1,$z2" + else + echo "test 2 " + outString="$outString +$ring,$qR,$qL,$overlap,$qThick,$num2,$num3,$refL,$ref_angle,$lg_angle,$pmtR,$tilt,$pmtRad,$wallThickness,$extraPMT1,$extraPMT2,$z1,$z2" + fi +done < $csv +IFS=$OLDIFS + +echo "$outString" > cadp_${stub}.csv +perl cadGeneratorV1.pl -F cadp_${stub}.csv +perl gdmlGeneratorV1_materials_reflector.pl -M detectorMotherP.csv -D parameter.csv -P qe.txt -U UVS_45total.txt -R MylarRef.txt -T _${stub} +cd - +mv -f ../../../remoll-detector-generator/cadp_${stub}.csv . +cp -f ../../../remoll-detector-generator/flat_*${stub}.* ../../geometry/flat_segmented_detector_produce.gdml +# Local saved geometry file with the "flat" geometry turned on +cp -f active-SD-mollerParallel.gdml ../../geometry/mollerParallel.gdml + +for currentStep in `seq 1 $num`; +do + tmpFolder="produce/out_${stub}_${currentStep}" + if [ ! -d produce ] ; then + mkdir produce + fi + if [ ! -d $tmpFolder ] ; then + mkdir $tmpFolder + fi + cd $tmpFolder + cp -p ../../../../build/remoll . + cp -p ../../../../bin/remoll.sh . + + cp -p ../../macros/${macro} . + ln -s ../../../../geometry geometry + ln -s ../../../../macros macros + ln -s ../../../../map_directory map_directory + echo "#!/bin/bash +# +#$ -cwd +#$ -j y +#$ -S /bin/bash +source remoll.sh +./remoll ${macro} + " > runscript_${currentStep}.sh + chmod 755 runscript_${currentStep}.sh + qsub runscript_${currentStep}.sh + cd - +done + diff --git a/analysis/pe_studies/scripts/ref-scan.sh b/analysis/pe_studies/scripts/ref-scan.sh new file mode 100755 index 000000000..6158794a1 --- /dev/null +++ b/analysis/pe_studies/scripts/ref-scan.sh @@ -0,0 +1,254 @@ +#!/bin/bash + +# Takes 5 arguments +# +# Fixed value of non-scanned variable - default = 80.0 +# Variable to scan ("angle" or "x") - default = "angle" +# Min of scanned variable - default = -30 +# Max of scanned variable - default = 30 +# Step size - default = 0.5 + +if [ "$#" -lt 1 ] ; then + echo " ERROR, requires at least one input + " + echo " This script generates geometry from cadp.csv (with options for which ring) and makes a series of analyses at various reflector lengths and angles + " + echo " usage: ./ref-scan.sh fixed-non-scanned \"variable-to-scan\" min-of-scan (0) max-of-scan (30) step-size (1.0) + Takes 10 arguments + + Fixed value of non-scanned variable - default = 80.0 + Variable to scan (\"angle\" or \"x\") - default = \"angle\" + Min of scanned variable - default = 0 + Max of scanned variable - default = 30 + Step size - default = 1.0 + Reflectivity of light guide - default = 0.7 + Cerenkov - default = 1.0 + Scintillation - default = 1.0 + geometry file name - default = \"R5o\" + pass - default = 1 + det number (optional, automatic) - default = 540210" + exit +fi + +fixed="$1" +scanned="angle" +q_r=0.0 +scanMin=0.0 +scanMax=30.0 +scanStep=1.0 +reflectivity=0.7 +cerenkov=1 +scintillation=1 +geom="R5o" +det=540210 +pass="1" +if [ "$#" -gt 1 ] ; then + scanned="$2" +fi +if [ "$#" -gt 2 ] ; then + scanMin=$3 +fi +if [ "$#" -gt 3 ] ; then + scanMax=$4 +fi +if [ "$#" -gt 4 ] ; then + scanStep=$5 +fi +if [ "$#" -gt 5 ] ; then + reflectivity=$6 +fi +if [ "$#" -gt 6 ] ; then + cerenkov=$(printf "%.0f" "$7") +fi +if [ "$#" -gt 7 ] ; then + scintillation=$(printf "%.0f" "$8") +fi +if [ "$#" -gt 8 ] ; then + geom="${9}" +fi +if [ "$#" -gt 9 ] ; then + pass="${10}" +fi +user_ring="5.0" +script_ring="5" +if [[ $geom == "R1" ]] ; then + user_ring="1" + script_ring="1" + det=140210 +elif [[ $geom == "R2" ]] ; then + user_ring="2" + script_ring="2" + det=240210 +elif [[ $geom == "R3" ]] ; then + user_ring="3" + script_ring="3" + det=340210 +elif [[ $geom == "R4" ]] ; then + user_ring="4" + script_ring="4" + det=440210 +elif [[ $geom == "R5o" ]] ; then + user_ring="5.0" + script_ring="5" + det=540210 +elif [[ $geom == "R5t" ]] ; then + user_ring="5.1" + script_ring="5trans" + det=540110 +elif [[ $geom == "R5c" ]] ; then + user_ring="5.2" + script_ring="5closed" + det=504010 +elif [[ $geom == "R6" ]] ; then + user_ring="6" + script_ring="6" + det=640210 +fi +secondpass="$pass" +if [ "$#" -gt 10 ] ; then + det="${11}" +fi + + + +tiltAngle=3.5 +refAngle=18.0 +refLength=80.0 +z_p=0.0 +numSteps=$(printf "%.0f" "$(bc -l <<< \(${scanMax}-\(${scanMin}\)\)/$scanStep)") +fixed=$(printf "%.1f" "$(bc -l <<< 1.0*$fixed)") +z_point=0.0 + +defaultName="refScanOut.root" +outputName="refScanOut.root" +name="refScan_0.0_degrees_0.0_L" + +cer="true" +scint="true" +if [[ $cerenkov > 0.0 ]] ; then + cer="true" +else + cer="false" +fi +if [[ $scintillation > 0.0 ]] ; then + scint="true" +else + scint="false" +fi + + +for currentStep in `seq 0 $numSteps`; +do + point=$(printf "%.1f" "$(bc -l <<< \($scanMin+\(1.0*$currentStep*$scanStep\)\))") + if [[ "$scanned" == "angle" ]] ; then + refLength=$fixed + refAngle=$point + fi + if [[ "$scanned" == "x" ]] ; then + refLength=$point + refAngle=$fixed + fi + + + name="${refAngle}_degrees_${refLength}_L_${reflectivity}_ref_${cerenkov}_cer_${scintillation}_scint" + + cd ../../../remoll-detector-generator/ + outString="" + OLDIFS=$IFS + IFS="," + while read ring qR qL overlap qThick num2 num3 refL ref_angle lg_angle pmtR tilt pmtRad wallThickness extraPMT1 extraPMT2 z1 z2 + do + if [[ $ring != $user_ring ]] ; then + outString="$outString +$ring,$qR,$qL,$overlap,$qThick,$num2,$num3,$refL,$ref_angle,$lg_angle,$pmtR,$tilt,$pmtRad,$wallThickness,$extraPMT1,$extraPMT2,$z1,$z2" + continue + fi + #xPosMax=$(printf "%.2f" "$(bc -l <<< ${pmtR}-10.0)") + #xPosMin=$(printf "%.2f" "$(bc -l <<< ${qR}+0.5*${qL}+5.0)") + z_p=$(printf "%.2f" "$(bc -l <<< ${z1}-0.55*$qThick)") + #echo "$ring $xPosMin $xPosMax z = $z_p starting z = $z1 and second = $z2" + ref_angle=$refAngle + refL=$refLength + tiltAngle=$tilt + q_r=$qR + outString="$outString +$ring,$qR,$qL,$overlap,$qThick,$num2,$num3,$refL,$ref_angle,$lg_angle,$pmtR,$tilt,$pmtRad,$wallThickness,$extraPMT1,$extraPMT2,$z1,$z2" + done < cadp.csv + IFS=$OLDIFS + + z_point=$z_p + + if [[ "$pass" == "1" ]] ; then + echo "$outString" > cadp_${geom}_${name}.csv + perl cadGeneratorV1.pl -F cadp_${geom}_${name}.csv + perl gdmlGeneratorV1_materials.pl -M detectorMotherP.csv -D parameter.csv -P qe.txt -U UVS_45total.txt -R MylarRef.txt -L ${script_ring} -T _${geom} + fi + cd - + + if [[ "$pass" == "1" ]] ; then + cp macros/preserve_ref_scans.mac macros/scans_${geom}_${name}.mac + sed -i 's;'"/remoll/evgen/beam/th -11.5 deg"';'"/remoll/evgen/beam/th -${tiltAngle} deg"';g' macros/scans_${geom}_${name}.mac + sed -i 's;'"/remoll/evgen/beam/origin 0.0 0.0 0.0 mm"';'"/remoll/evgen/beam/origin -${q_r} 0.0 ${z_point} mm"';g' macros/scans_${geom}_${name}.mac + + sed -i 's;'"/remoll/setgeofile geometry_sandbox/mollerMother_Mainz.gdml"';'"/remoll/setgeofile mollerMother_${geom}.gdml"';g' macros/scans_${geom}_${name}.mac + + sed -i 's;'"/remoll/evgen/beam/rasterRefZ 0.0 mm"';'"/remoll/evgen/beam/rasterRefZ ${z_point} mm"';g' macros/scans_${geom}_${name}.mac + + sed -i 's;'"/process/optical/processActivation Cerenkov false"';'"/process/optical/processActivation Cerenkov ${cer}"';g' macros/scans_${geom}_${name}.mac + sed -i 's;'"/process/optical/processActivation Scintillation false"';'"/process/optical/processActivation Scintillation ${scint}"';g' macros/scans_${geom}_${name}.mac + sed -i 's;'"Mainz_0.0_degrees_0.0_x.root"';'"${geom}_${name}.root"';g' macros/scans_${geom}_${name}.mac + fi + + tmpFolder="ref-scans/$geom/out_${geom}_${name}" + if [ ! -d ref-scans ] ; then + mkdir ref-scans + fi + if [ ! -d ref-scans/${geom} ] ; then + mkdir ref-scans/${geom} + fi + if [ ! -d $tmpFolder ] ; then + mkdir $tmpFolder + fi + cd $tmpFolder + if [[ "$pass" == "2" ]] ; then + if [[ ! -f remollout_${geom}_${name}.pdf ]] ; then + cp ../../../../../analysis/bin/pe . + if [[ ! -f remollout_${geom}_${name}.root ]] ; then + echo "Error, no remollout_${geom}_${name}.root file, retrying analysis" + secondpass="1" + else + echo "./pe remollout_${geom}_${name}.root ${det} angle\=${refAngle} reflength\=${refLength} reflectivity\=${reflectivity} cerenkov\=${cerenkov} scintillation\=${scintillation} z_pos\=${z_point}" + ./pe remollout_${geom}_${name}.root ${det} angle\=${refAngle} reflength\=${refLength} reflectivity\=${reflectivity} cerenkov\=${cerenkov} scintillation\=${scintillation} z_pos\=${z_point} + convert remollout_${geom}_${name}*.png remollout_${geom}_${name}.pdf + rm remollout_${geom}_${name}*.png + #rm remollout_${geom}_${name}.root + rm remollout_${geom}_${name}_PEs_det_${det}.root + rm remollout_${geom}_${name}_PEs_det_${det}_plots.root + fi + fi + fi + if [[ "$pass" == "1" ]] ; then + cp -p ../../../../../build/remoll . + cp -p ../../../../../bin/remoll.sh . + cp -p ../../../../../../remoll-detector-generator/materialsOptical.xml . + mv ../../../../../../remoll-detector-generator/cadp_${geom}_${name}.csv . + mv ../../../../../../remoll-detector-generator/*${geom}.* . + sed -i 's;'" \n runscript_${geom}_${name}.sh + chmod 755 runscript_${geom}_${name}.sh + fi + if [[ "$pass" == "1" || "$secondpass" == "1" ]] ; then + qsub runscript_${geom}_${name}.sh + fi + cd - + secondpass="$pass" +done diff --git a/analysis/pe_studies/scripts/scan.sh b/analysis/pe_studies/scripts/scan.sh new file mode 100755 index 000000000..fee5b4f13 --- /dev/null +++ b/analysis/pe_studies/scripts/scan.sh @@ -0,0 +1,209 @@ +#!/bin/bash + +# Takes 5 arguments +# +# Fixed value of non-scanned variable - default = 0.0 +# Variable to scan ("angle" or "x") - default = "angle" +# Min of scanned variable - default = -30 +# Max of scanned variable - default = 30 +# Step size - default = 0.5 + +if [ "$#" -lt 1 ] ; then + echo " ERROR, requires at least one input + " + echo " This script assumes a geometry exists in remoll/geometry_sandbox and then computes the PEs for a given detector due to a beam of electrons hitting the detector + " + echo " Assumes you have already created the geometry (in ../../../remoll-detector-generator/) with the correct parameters and name you want before proceding + " + echo " usage: ./scan.sh fixed-non-scanned \"variable-to-scan\" min-of-scan (-30) max-of-scan (30) step-size (0.5) + Takes 12 arguments + + Fixed value of non-scanned variable - default = 0.0 + Variable to scan (\"angle\" or \"x\") - default = \"angle\" + Min of scanned variable - default = -30 + Max of scanned variable - default = 30 + Step size - default = 0.5 + Reflectivity of light guide - default = 0.9 + Cerenkov - default = 1.0 + Scintillation - default = 1.0 + z Position of beam origin - default = -11.0 + geometry file name - default = \"Mainz\" + pass - default = 1 + det number - default = 540210" + exit +fi +fixed="$1" +scanned="angle" +scanMin=-30.0 +scanMax=30.0 +scanStep=0.5 +reflectivity=0.9 +cerenkov=1 +scintillation=1 +#z_pos=-52.0 +z_pos=0.0 +geom="Mainz" +det=540210 +pass="1" +if [ "$#" -gt 1 ] ; then + scanned="$2" +fi +if [ "$#" -gt 2 ] ; then + scanMin=$3 +fi +if [ "$#" -gt 3 ] ; then + scanMax=$4 +fi +if [ "$#" -gt 4 ] ; then + scanStep=$5 +fi +if [ "$#" -gt 5 ] ; then + reflectivity=$6 +fi +if [ "$#" -gt 6 ] ; then + cerenkov=$(printf "%.0f" "$7") +fi +if [ "$#" -gt 7 ] ; then + scintillation=$(printf "%.0f" "$8") +fi +if [ "$#" -gt 8 ] ; then + z_pos=$9 +fi +if [ "$#" -gt 9 ] ; then + geom="${10}" +fi +if [[ $geom == "R1" ]] ; then + det=140210 +elif [[ $geom == "R2" ]] ; then + det=240210 +elif [[ $geom == "R3" ]] ; then + det=340210 +elif [[ $geom == "R4" ]] ; then + det=440210 +elif [[ $geom == "R5o" ]] ; then + det=540210 +elif [[ $geom == "R5t" ]] ; then + det=540110 +elif [[ $geom == "R5c" ]] ; then + det=504010 +elif [[ $geom == "R6" ]] ; then + det=640210 +fi +if [ "$#" -gt 10 ] ; then + pass="${11}" +fi +secondpass="$pass" +if [ "$#" -gt 11 ] ; then + det="${12}" +fi + +angle=0.0 +x_pos=0.0 + +numSteps=$(printf "%.0f" "$(bc -l <<< \(${scanMax}-\(${scanMin}\)\)/$scanStep)") +fixed=$(printf "%.1f" "$(bc -l <<< 1.0*$fixed)") +z_point=0.0 + +defaultName="qsimout.root" +outputName="qsimout.root" +name="0.0_degrees_0.0_x" + +cer="true" +scint="true" +if [[ $cerenkov > 0.0 ]] ; then + cer="true" +else + cer="false" +fi +if [[ $scintillation > 0.0 ]] ; then + scint="true" +else + scint="false" +fi + +for currentStep in `seq 0 $numSteps`; +do + point=$(printf "%.1f" "$(bc -l <<< \($scanMin+\(1.0*$currentStep*$scanStep\)\))") + if [[ "$scanned" == "angle" ]] ; then + x_pos=$fixed + angle=$point + fi + if [[ "$scanned" == "x" ]] ; then + x_pos=$point + angle=$fixed + fi + name="${angle}_degrees_${x_pos}_x_${z_pos}_z_${reflectivity}_ref_${cerenkov}_cer_${scintillation}_scint" + if [[ "$pass" == "1" ]] ; then + cp macros/preserve_scans.mac macros/scans_${geom}_${name}.mac + # FIXME This angle is hardcoded to the qsim-matching case!! + # 0.1994 = sin(11.5 degrees), $fixed is the distance from 0.0, + is farther towards PMT, further back away from +z axis + # 0.104528 = sin(6 degrees) + z_point=$z_pos + # FIXME doing z_pos as external input only now, for full detector array setting + #z_point=$(printf "%.1f" "$(bc -l <<< ${z_pos}+\($x_pos*0.1045\))") + # FIXME z_point and x offset relationships assume the detector is immediately downstream of the origin, and ideally centered at the middle of the lightguide + #z_point=$(printf "%.1f" "$(bc -l <<< -11.0-\($fixed*0.1994\))") + sed -i 's;'"/remoll/evgen/beam/th -11.5 deg"';'"/remoll/evgen/beam/th ${angle} deg"';g' macros/scans_${geom}_${name}.mac + sed -i 's;'"/remoll/evgen/beam/origin 0.0 0.0 0.0 mm"';'"/remoll/evgen/beam/origin ${x_pos} 0.0 ${z_point} cm"';g' macros/scans_${geom}_${name}.mac + + sed -i 's;'"/remoll/setgeofile geometry_sandbox/mollerMother_Mainz.gdml"';'"/remoll/setgeofile mollerMother_${geom}.gdml"';g' macros/scans_${geom}_${name}.mac + + sed -i 's;'"/remoll/evgen/beam/rasterRefZ 0.0 mm"';'"/remoll/evgen/beam/rasterRefZ ${z_point} cm"';g' macros/scans_${geom}_${name}.mac + + sed -i 's;'"/process/optical/processActivation Cerenkov false"';'"/process/optical/processActivation Cerenkov ${cer}"';g' macros/scans_${geom}_${name}.mac + sed -i 's;'"/process/optical/processActivation Scintillation false"';'"/process/optical/processActivation Scintillation ${scint}"';g' macros/scans_${geom}_${name}.mac + sed -i 's;'"Mainz_0.0_degrees_0.0_x.root"';'"${geom}_${name}.root"';g' macros/scans_${geom}_${name}.mac + fi + tmpFolder="scans/$geom/out_${geom}_${name}" + if [ ! -d scans ] ; then + mkdir scans + fi + if [ ! -d scans/${geom} ] ; then + mkdir scans/${geom} + fi + if [ ! -d $tmpFolder ] ; then + mkdir $tmpFolder + fi + cd $tmpFolder + if [[ "$pass" == "2" ]] ; then + if [[ ! -f remollout_${geom}_${name}.pdf ]] ; then + cp ../../../../../analysis/bin/pe . + if [[ ! -f remollout_${geom}_${name}.root ]] ; then + echo "Error, no remollout_${geom}_${name}.root file, retrying analysis" + secondpass="1" + else + echo "./pe remollout_${geom}_${name}.root ${det} angle\=${angle} x_pos\=${x_pos} reflectivity\=${reflectivity} cerenkov\=${cerenkov} scintillation\=${scintillation} z_pos\=${z_point}" + ./pe remollout_${geom}_${name}.root ${det} angle\=${angle} x_pos\=${x_pos} reflectivity\=${reflectivity} cerenkov\=${cerenkov} scintillation\=${scintillation} z_pos\=${z_point} + convert remollout_${geom}_${name}*.png remollout_${geom}_${name}.pdf + rm remollout_${geom}_${name}*.png + rm remollout_${geom}_${name}.root + rm remollout_${geom}_${name}_PEs_det_${det}.root + rm remollout_${geom}_${name}_PEs_det_${det}_plots.root + fi + fi + fi + if [[ "$pass" == "1" ]] ; then + cp -p ../../../../../build/remoll . + cp -p ../../../../../bin/remoll.sh . + cp -p ../../../../../geometry_sandbox/materialsOptical.xml . + cp -p ../../../../../geometry_sandbox/*${geom}.* . + cp -p ../../../../../geometry_sandbox/matrices_${geom}.xml matrices_${geom}.xml + sed -i 's;'" \n runscript_${geom}_${name}.sh + chmod 755 runscript_${geom}_${name}.sh + fi + if [[ "$pass" == "1" || "$secondpass" == "1" ]] ; then + qsub runscript_${geom}_${name}.sh + fi + cd - + secondpass="$pass" +done diff --git a/analysis/pe_studies/scripts/sub-ref-scan.sh b/analysis/pe_studies/scripts/sub-ref-scan.sh new file mode 100755 index 000000000..a4ce1b712 --- /dev/null +++ b/analysis/pe_studies/scripts/sub-ref-scan.sh @@ -0,0 +1,283 @@ +#!/bin/bash + +if [ "$#" -lt 1 ] ; then + echo " ERROR, requires at least one input + " + echo " This script generates geometry from cadp.csv (with options for which ring) and makes a series of analyses at various reflector lengths and angles. + " + echo " This one will also scan across sub-segments of the reflector, and therefore takes much longer and is a more consuming analysis to undertake. The specific technique is to make the reflector only a small segment of it's full self, with the orientation of that subsegment scanned. The non-reflector bounced flux will be counted in each analysis, so it is a good idea to measure the non-reflector signal explicitly and subtract it from each of this analysis for sanity. The segmentation scale is hardcoded in here, but can be changed if you like. Also note that the detector is symmetric about the YZ plane, so only half the segments in the Y direction (width) must be simulated. + " + echo " usage: ./sub-ref-scan.sh reflectivity=0.7 Cerenkov=1.0 Scintillation=1.0 geometry=R5o analysis-pass=1 det-number=540210 + Takes 6 arguments + + Reflectivity of light guide - default = 0.7 + Cerenkov - default = 1.0 + Scintillation - default = 1.0 + geometry file name - default = \"R5o\" + pass - default = 1 + det number (optional, automatic) - default = 540210" + exit +fi + +tiltAngle=3.5 +refAngle=18.0 +thetaSubRef=0.0 +phiSubRef=0.0 +refLength=80.0 +z_p=0.0 +z_point=0.0 +q_r=0.0 +reflectivity=0.7 +cerenkov=1 +scintillation=1 +geom="R5o" +det=540210 +pass="1" +if [ "$#" -gt 0 ] ; then + reflectivity=$1 +fi +if [ "$#" -gt 1 ] ; then + cerenkov=$(printf "%.0f" "$2") +fi +if [ "$#" -gt 2 ] ; then + scintillation=$(printf "%.0f" "$3") +fi +if [ "$#" -gt 3 ] ; then + geom="${4}" +fi +if [ "$#" -gt 4 ] ; then + pass="${5}" +fi +user_ring="5.0" +script_ring="5" +if [[ $geom == "R1" ]] ; then + user_ring="1" + script_ring="1" + det=140210 +elif [[ $geom == "R2" ]] ; then + user_ring="2" + script_ring="2" + det=240210 +elif [[ $geom == "R3" ]] ; then + user_ring="3" + script_ring="3" + det=340210 +elif [[ $geom == "R4" ]] ; then + user_ring="4" + script_ring="4" + det=440210 +elif [[ $geom == "R5o" ]] ; then + user_ring="5.0" + script_ring="5" + det=540210 +elif [[ $geom == "R5t" ]] ; then + user_ring="5.1" + script_ring="5trans" + det=540110 +elif [[ $geom == "R5c" ]] ; then + user_ring="5.2" + script_ring="5closed" + det=504010 +elif [[ $geom == "R6" ]] ; then + user_ring="6" + script_ring="6" + det=640210 +fi +secondpass="$pass" +missing=0 +started=0 +if [ "$#" -gt 5 ] ; then + det="${6}" +fi + + +defaultName="refScanOut.root" +outputName="refScanOut.root" +name="refScan_0.0_degrees_0.0_L" + +cer="true" +scint="true" +if [[ $cerenkov > 0.0 ]] ; then + cer="true" +else + cer="false" +fi +if [[ $scintillation > 0.0 ]] ; then + scint="true" +else + scint="false" +fi + +# On the first pass just do the loop once (started == 0) +# Then, if $pass == 2 the $missing number could be > 0, in which case loop again +while (( $missing!=0 )) || (( $started==0 )) ; +do + missing=0 + started=1 + +#for wStep in `seq 0 4`; +# seq 0 to 9 is redundant, as there is a symmetry about the midplane where width = 4.5 +for wStep in `seq 0 4`; +do + for lStep in `seq 0 9`; + do + for thetaStepSeq in `seq 0 10`; + do + thetaSubRef=$(printf "%.1f" "$(bc -l <<< \(-9.0+\(1.0*$thetaStepSeq*3.0\)\))") + for phiStepSeq in `seq 0 12`; + do + phiSubRef=$(printf "%.1f" "$(bc -l <<< \(-30.0+\(1.0*$phiStepSeq*5.0\)\))") + + +cd ../../../remoll-detector-generator/ +outString="" +OLDIFS=$IFS +IFS="," +while read ring qR qL overlap qThick num2 num3 refL ref_angle lg_angle pmtR tilt pmtRad wallThickness extraPMT1 extraPMT2 z1 z2 +do + if [[ $ring != $user_ring ]] ; then + outString="$outString +$ring,$qR,$qL,$overlap,$qThick,$num2,$num3,$refL,$ref_angle,$lg_angle,$pmtR,$tilt,$pmtRad,$wallThickness,$extraPMT1,$extraPMT2,$z1,$z2" + continue + fi + refAngle=$ref_angle + refLength=$refL + tiltAngle=$tilt + #xPosMax=$(printf "%.2f" "$(bc -l <<< ${pmtR}-10.0)") + #xPosMin=$(printf "%.2f" "$(bc -l <<< ${qR}+0.5*${qL}+5.0)") + z_p=$(printf "%.2f" "$(bc -l <<< ${z1}-0.55*$qThick)") + #echo "$ring $xPosMin $xPosMax z = $z_p starting z = $z1 and second = $z2" + q_r=$qR + outString="$outString +$ring,$qR,$qL,$overlap,$qThick,$num2,$num3,$refL,$ref_angle,$lg_angle,$pmtR,$tilt,$pmtRad,$wallThickness,$extraPMT1,$extraPMT2,$z1,$z2" +done < cadp.csv +IFS=$OLDIFS + +z_point=$z_p +name="${refAngle}_degrees_${refLength}_L_${reflectivity}_ref_${cerenkov}_cer_${scintillation}_scint" + +if [[ "$pass" == "1" ]] ; then + echo "$outString" > cadp_${geom}_${name}.csv + perl cadGeneratorV1.pl -F cadp_${geom}_${name}.csv + perl gdmlGeneratorV1_materials.pl -M detectorMotherP.csv -D parameter.csv -P qe.txt -U UVS_45total.txt -R MylarRef.txt -L ${script_ring} -T _${geom} -i $lStep -j $wStep -t $thetaSubRef -p $phiSubRef +fi +cd - + +if [[ "$pass" == "1" ]] ; then + cp macros/preserve_ref_scans.mac macros/scans_${geom}_${name}.mac + sed -i 's;'"/remoll/evgen/beam/th -11.5 deg"';'"/remoll/evgen/beam/th -${tiltAngle} deg"';g' macros/scans_${geom}_${name}.mac + sed -i 's;'"/remoll/evgen/beam/origin 0.0 0.0 0.0 mm"';'"/remoll/evgen/beam/origin -${q_r} 0.0 ${z_point} mm"';g' macros/scans_${geom}_${name}.mac + + sed -i 's;'"/remoll/setgeofile geometry_sandbox/mollerMother_Mainz.gdml"';'"/remoll/setgeofile mollerMother_${geom}.gdml"';g' macros/scans_${geom}_${name}.mac + + sed -i 's;'"/remoll/evgen/beam/rasterRefZ 0.0 mm"';'"/remoll/evgen/beam/rasterRefZ ${z_point} mm"';g' macros/scans_${geom}_${name}.mac + + sed -i 's;'"/process/optical/processActivation Cerenkov false"';'"/process/optical/processActivation Cerenkov ${cer}"';g' macros/scans_${geom}_${name}.mac + sed -i 's;'"/process/optical/processActivation Scintillation false"';'"/process/optical/processActivation Scintillation ${scint}"';g' macros/scans_${geom}_${name}.mac + sed -i 's;'"Mainz_0.0_degrees_0.0_x.root"';'"${geom}_${name}.root"';g' macros/scans_${geom}_${name}.mac +fi + +tmpFolder="sub-scans/${geom}/out_${geom}_${wStep}_widthStep_${lStep}_lengthStep_${thetaSubRef}_theta_${phiSubRef}_phi_${name}" +if [ ! -d sub-scans ] ; then + mkdir sub-scans +fi +if [ ! -d sub-scans/${geom} ] ; then + mkdir sub-scans/${geom} +fi +if [ ! -d $tmpFolder ] ; then + mkdir $tmpFolder +fi +cd $tmpFolder +if [[ "$pass" == "2" ]] ; then + if [[ ! -f remollout_${geom}_${name}.pdf ]] ; then + cp ../../../../../analysis/bin/pe . + if [[ ! -f finished.txt ]] ; then + #if [[ ! -f remollout_${geom}_${name}.root ]] ; then + echo "Not finished with ${geom} ${name}: ${wStep} widthStep, ${lStep} lengthStep, ${thetaSubRef} theta, ${phiSubRef} phi, will retry analysis" + let missing=$missing+1 + #echo "$missing" + # Do missing check instead + #secondpass="1" + else + echo "./pe remollout_${geom}_${name}.root ${det} angle\=${refAngle} reflength\=${refLength} reflectivity\=${reflectivity} cerenkov\=${cerenkov} scintillation\=${scintillation} z_pos\=${z_point} length_step\=$lStep width_step\=$wStep theta\=$thetaSubRef phi\=$phiSubRef" + ./pe remollout_${geom}_${name}.root ${det} angle\=${refAngle} reflength\=${refLength} reflectivity\=${reflectivity} cerenkov\=${cerenkov} scintillation\=${scintillation} z_pos\=${z_point} length_step\=$lStep width_step\=$wStep theta\=$thetaSubRef phi\=$phiSubRef + convert remollout_${geom}_${name}*.png remollout_${geom}_${name}.pdf + rm remollout_${geom}_${name}*.png + rm remollout_${geom}_${name}.root + rm remollout_${geom}_${name}_PEs_det_${det}.root + rm remollout_${geom}_${name}_PEs_det_${det}_plots.root + fi + fi +fi +if [[ "$pass" == "1" ]] ; then + cp -p ../../../../../build/remoll . + cp -p ../../../../../bin/remoll.sh . + cp -p ../../../../../../remoll-detector-generator/materialsOptical.xml . + mv ../../../../../../remoll-detector-generator/cadp_${geom}_${name}.csv . + mv ../../../../../../remoll-detector-generator/*${geom}.* . + sed -i 's;'" \n runscript_${geom}_${name}.sh + chmod 755 runscript_${geom}_${name}.sh +fi +#if [[ "$pass" == "1" || "$secondpass" == "1" ]] ; then +if [[ "$pass" == "1" ]] ; then + qsub runscript_${geom}_${name}.sh +fi +cd - +secondpass="$pass" + done + done + done +done +if [[ "$pass" == "1" ]] ; then + echo "Pass 1 finished, feel free to rerun immediately with pass 2 (will loop until all jobs finish)" + missing=0 +fi +if (( $missing!=0 )) ; then + echo "Pass 2 finished, waiting on $missing incomplete jobs for another pass + " + echo "Sleeping for 10 minutes" + sleep 60 + echo "Sleeping for 9 minutes" + sleep 60 + echo "Sleeping for 8 minutes" + sleep 60 + echo "Sleeping for 7 minutes" + sleep 60 + echo "Sleeping for 6 minutes" + sleep 60 + echo "Sleeping for 5 minutes" + sleep 60 + echo "Sleeping for 4 minutes" + sleep 60 + echo "Sleeping for 3 minutes" + sleep 60 + echo "Sleeping for 2 minutes" + sleep 60 + echo "Sleeping for 1 minutes" + sleep 57 + echo "Retrying analysis" + sleep 3 +fi +done diff --git a/analysis/tests/test_power.C b/analysis/tests/test_power.C index 5f7650e3e..039366fcc 100644 --- a/analysis/tests/test_power.C +++ b/analysis/tests/test_power.C @@ -6,6 +6,7 @@ part of this is taken from Rakitha's code coll_scan.cc */ #include #include +#include #include "remolltypes.hh" diff --git a/cmake/modules/FindROOT.cmake b/cmake/modules/FindROOT.cmake index b5eab412c..faabdbdcd 100644 --- a/cmake/modules/FindROOT.cmake +++ b/cmake/modules/FindROOT.cmake @@ -86,6 +86,7 @@ if(NOT ROOT_CONFIG_EXEC) ) # Remove include directories from compiler flags; they are handled separately string(REGEX REPLACE "-I[^ ]*" "" _cxx_flags "${_cxx_flags}") + string(REGEX REPLACE "-O[^ ]*" "" _cxx_flags "${_cxx_flags}") set(ROOT_CXX_FLAGS "${_cxx_flags}" CACHE STRING "ROOT C++ compiler flags" FORCE) mark_as_advanced(ROOT_CXX_FLAGS) unset(_cxx_flags) diff --git a/geometry/beampipe/downstream/beampipeDSMother.gdml b/geometry/beampipe/downstream/beampipeDSMother.gdml index 40c9b39ec..26df36495 100644 --- a/geometry/beampipe/downstream/beampipeDSMother.gdml +++ b/geometry/beampipe/downstream/beampipeDSMother.gdml @@ -1,28 +1,38 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="http://service-spi.web.cern.ch/service-spi/app/releases/GDML/schema/gdml.xsd"> - - - - - - + + + + + + + + + + + + + + - - + + - - + + @@ -47,69 +57,427 @@ - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - + + + + + - - - - - + + + + + - - - - - + + + + + - - - - - + + + + + - - - + + + + + - - - + + + + + - - - + + + + + - - - + + + + - - - + + + - + - + - - - + + + diff --git a/geometry/beampipe/premoller/beampipeRaster.gdml b/geometry/beampipe/premoller/beampipeRaster.gdml index 1d9e9d3f6..22ff3eb54 100644 --- a/geometry/beampipe/premoller/beampipeRaster.gdml +++ b/geometry/beampipe/premoller/beampipeRaster.gdml @@ -6,6 +6,9 @@ + + + - - - - - ]> - - - - - - - &matrices; - - &materials; - &solids_mainz; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/geometry/donut/donutConcreteLead.gdml b/geometry/donut/donutConcreteLead.gdml new file mode 100644 index 000000000..2857a093c --- /dev/null +++ b/geometry/donut/donutConcreteLead.gdml @@ -0,0 +1,949 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + +
+
+ + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + +
+
+ + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/geometry/dumpDaughter.gdml b/geometry/dumpDaughter.gdml deleted file mode 100644 index 9638ef2d8..000000000 --- a/geometry/dumpDaughter.gdml +++ /dev/null @@ -1,805 +0,0 @@ - - - - -]> - - - - - &matrices; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - &materials; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/geometry/electronics/subSBSbunker.gdml b/geometry/electronics/subSBSbunker.gdml index 429eafaef..266a59068 100644 --- a/geometry/electronics/subSBSbunker.gdml +++ b/geometry/electronics/subSBSbunker.gdml @@ -5,7 +5,7 @@ ]> - + @@ -127,7 +127,7 @@ - + diff --git a/geometry/generators/remoll-coil-generator b/geometry/generators/remoll-coil-generator new file mode 160000 index 000000000..3212c9e1f --- /dev/null +++ b/geometry/generators/remoll-coil-generator @@ -0,0 +1 @@ +Subproject commit 3212c9e1fa40103171e7e419f2d1765f10e29b30 diff --git a/geometry/generators/remoll-detector-generator b/geometry/generators/remoll-detector-generator new file mode 160000 index 000000000..425314488 --- /dev/null +++ b/geometry/generators/remoll-detector-generator @@ -0,0 +1 @@ +Subproject commit 425314488c7d1d6f887ab765158633ece055ab96 diff --git a/geometry/generators/remoll-showermax-generator b/geometry/generators/remoll-showermax-generator new file mode 160000 index 000000000..5c0331884 --- /dev/null +++ b/geometry/generators/remoll-showermax-generator @@ -0,0 +1 @@ +Subproject commit 5c0331884032f92712a35d8e5bef93672ff1ca73 diff --git a/geometry/hall/hallDaughter_acceptanceDefinition.gdml b/geometry/hall/hallDaughter_acceptanceDefinition.gdml index afd2f931e..43f322ec3 100644 --- a/geometry/hall/hallDaughter_acceptanceDefinition.gdml +++ b/geometry/hall/hallDaughter_acceptanceDefinition.gdml @@ -11,8 +11,8 @@ &matrices; - - + + diff --git a/geometry/hall/hallDaughter_dump.gdml b/geometry/hall/hallDaughter_dump.gdml index f02f4c8d8..1f9e57b29 100644 --- a/geometry/hall/hallDaughter_dump.gdml +++ b/geometry/hall/hallDaughter_dump.gdml @@ -12,9 +12,9 @@ &matrices; - - - + + + @@ -31,7 +31,7 @@ - + @@ -216,16 +216,24 @@ - + - + + + + + + + + - + - @@ -421,7 +429,7 @@ z="dumpWaterTank_length"/> - + @@ -441,7 +449,7 @@ - + @@ -592,7 +600,6 @@ - @@ -602,7 +609,7 @@ - + @@ -715,8 +722,7 @@ - - + diff --git a/geometry/hall/hallDaughter_merged.gdml b/geometry/hall/hallDaughter_merged.gdml index 52d3576e8..da7fe89f1 100644 --- a/geometry/hall/hallDaughter_merged.gdml +++ b/geometry/hall/hallDaughter_merged.gdml @@ -11,8 +11,8 @@ &matrices; - - + + @@ -214,6 +214,7 @@ + diff --git a/geometry/hall/subDumpDiffuser.gdml b/geometry/hall/subDumpDiffuser.gdml index f211a0522..455e52386 100644 --- a/geometry/hall/subDumpDiffuser.gdml +++ b/geometry/hall/subDumpDiffuser.gdml @@ -2,7 +2,7 @@ + xsi:noNamespaceSchemaLocation="http://service-spi.web.cern.ch/service-spi/app/releases/GDML/schema/gdml.xsd"> @@ -145,7 +145,6 @@ - @@ -156,6 +155,8 @@ + + diff --git a/geometry/huts/lefthut.gdml b/geometry/huts/lefthut.gdml index c75aaa057..f94f8ff6a 100644 --- a/geometry/huts/lefthut.gdml +++ b/geometry/huts/lefthut.gdml @@ -12,6 +12,9 @@ + + + @@ -37,7 +40,7 @@ - + @@ -65,6 +68,7 @@ + @@ -76,6 +80,7 @@ + @@ -88,34 +93,35 @@ - + - + - + - + - + - + + diff --git a/geometry/huts/righthut.gdml b/geometry/huts/righthut.gdml index eec8c80af..bff199e32 100644 --- a/geometry/huts/righthut.gdml +++ b/geometry/huts/righthut.gdml @@ -37,7 +37,7 @@ - + @@ -66,6 +66,7 @@ + @@ -76,6 +77,7 @@ + @@ -85,35 +87,36 @@ + - + - + - + - + - + - + diff --git a/geometry/hybrid/hybridDaughter_merged.gdml b/geometry/hybrid/hybridDaughter_merged.gdml index 2a4b4a321..56a7e21e2 100644 --- a/geometry/hybrid/hybridDaughter_merged.gdml +++ b/geometry/hybrid/hybridDaughter_merged.gdml @@ -25,19 +25,15 @@ - - - - - - - - - - + + + + + + - + - - - + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -128,114 +118,174 @@ - - - - - - - - - - - - - - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - + + + - - - - + + + + + + + + + + + + + + + - - - - + + + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - + + + + @@ -249,14 +299,19 @@ - - + - - - - - + + + + + + + + + + + @@ -394,7 +449,7 @@ - + @@ -409,13 +464,375 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -426,13 +843,33 @@ - + + + + + + + + + + + + + + + + + + - + - - + + + + + @@ -480,13 +917,13 @@ - + - + - - - + + + @@ -560,14 +997,14 @@ - - + + - - + + @@ -608,32 +1045,41 @@ - - + + - + - - - + + + + + + + - + + + + + + - - + + @@ -654,12 +1100,12 @@ - + - + @@ -672,6 +1118,7 @@ + diff --git a/geometry/hybrid/hybridToroid.gdml b/geometry/hybrid/hybridToroid.gdml index 7986b0cb3..5603d1e82 100644 --- a/geometry/hybrid/hybridToroid.gdml +++ b/geometry/hybrid/hybridToroid.gdml @@ -14,489 +14,2490 @@ + + + + + + + + + + + + - - - + + + + + + + + + +
+
+ + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + - - - + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - + - - + + + + + + - - + + + + + + + - - - - - - + + + + + + + + + + - - - - - - + - - - - + + + + + + + + + - - - - - - + - - - - - - + + + + + + + - - - - - - + + + + + + + + + + - - - - - - + - - - - - - + + + + + + + + + - - - - - - + - - - - - - + + + + + + + - - - - - - + + + + + + + + + + - - - - - - + - - - - - - + + + + + + + + + - - - - - - + - - - - - - + + + + + + + - - - - - - + + + + + + + + + + - - - - - - + - - - - - - + + + + + + + - - - - - - + + + + + + + + + + - - - - - - + - - - - - - + + + + + + + - - - - - - + + + + + + + + + + - - - - - - + - - - - - - + + + + + + + - - - - - - - - - -
-
- + + + + + + + + + + - - - - - - - - + - + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + - + + + + + + + - + - + - + + + + + + - - - - - - - - - + + + + + + + + + + - - - + + + + + + - + - + - + + + + + + - - - - - - - - - + + + + + + + + + + - - - + + + + + + - + - + - + + + + + + - - - - - - - - - + + + + + + + + + + - - - - - - + + + + + + - + - + - - + + + + + - - - - - - - - - - - - + + + + + + - + - + - - + + + + + - - - - - - - - - - - - + + + + + + - + - + - - + + + + + - - - - - - - - - - - - + + + + + + - + - + - + + + + - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + + + + + + + - - - - + + + + - - - - + + + + - + - - - - + + + + + + + + + + + + + + + + + + + + + + - + - - - - + + + + + + + + + + + + + + + + + + + + + + - + - - - - + + + + + + + + + + + + + + + + + + + + + + - + - - - - + + + + + + + + + + + + + + + + + + + + + + - + - - - - + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/geometry/materials.xml b/geometry/materials.xml index 4eb286c4d..0215c0fbe 100644 --- a/geometry/materials.xml +++ b/geometry/materials.xml @@ -9,7 +9,7 @@ - + @@ -21,7 +21,7 @@ - + @@ -33,7 +33,7 @@ - + @@ -48,13 +48,13 @@ - + - + @@ -68,17 +68,13 @@ - + - - - - - + @@ -91,7 +87,7 @@ - + @@ -106,7 +102,7 @@ - + @@ -130,7 +126,7 @@ - + @@ -151,7 +147,7 @@ - + @@ -159,7 +155,7 @@ - + @@ -178,7 +174,7 @@ - + @@ -186,7 +182,7 @@ - + @@ -196,7 +192,7 @@ - + @@ -213,7 +209,7 @@ - + @@ -226,7 +222,7 @@ - + @@ -272,8 +268,8 @@ --> - - + + - - - + + + - - - - - - - - - - - - + + + + + + + + + + + + - - - - - - - - - - - + + + + + + + + + + + - - - - - - - - - - + + + + + + + + + + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + @@ -426,8 +422,8 @@ - - + + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - - + + - + + - + - - + + + - + - - - + + + + + + + + + + + + + + + + - + - - + + diff --git a/geometry/mollerMother_acceptanceDefinition.gdml b/geometry/mollerMother_acceptanceDefinition.gdml deleted file mode 100644 index e85bf7b27..000000000 --- a/geometry/mollerMother_acceptanceDefinition.gdml +++ /dev/null @@ -1,55 +0,0 @@ - - - - -]> - - - - - &positions; - - - - - - - &world; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/geometry/mollerMother_acceptanceDefinition_includeCol4.gdml b/geometry/mollerMother_acceptanceDefinition_includeCol4.gdml deleted file mode 100644 index 55553dbb5..000000000 --- a/geometry/mollerMother_acceptanceDefinition_includeCol4.gdml +++ /dev/null @@ -1,54 +0,0 @@ - - - - -]> - - - - - &positions; - - - - - - - &world; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/geometry/mollerMother_black.gdml b/geometry/mollerMother_black.gdml deleted file mode 100644 index 602f94472..000000000 --- a/geometry/mollerMother_black.gdml +++ /dev/null @@ -1,82 +0,0 @@ - - - - -]> - - - - - - - - - - -&matrices; - -&materials; - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/geometry/mollerMother_dump.gdml b/geometry/mollerMother_dump.gdml deleted file mode 100644 index 69a0c1034..000000000 --- a/geometry/mollerMother_dump.gdml +++ /dev/null @@ -1,77 +0,0 @@ - - - - -]> - - - - - &positions; - - - - - - - &world; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/geometry/mollerMother_merged.gdml b/geometry/mollerMother_merged.gdml deleted file mode 100644 index 097e33505..000000000 --- a/geometry/mollerMother_merged.gdml +++ /dev/null @@ -1,112 +0,0 @@ - - - - -]> - - - - - &positions; - - - - - - - &world; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/geometry/mollerMother_parametrized.gdml b/geometry/mollerMother_parametrized.gdml index 4598fb0ab..45d896f9a 100644 --- a/geometry/mollerMother_parametrized.gdml +++ b/geometry/mollerMother_parametrized.gdml @@ -21,35 +21,59 @@ - + + + + - + - - + + + + + + + + + - + - - + + - + - - + + + + + + + + + + + + + + + + @@ -59,17 +83,30 @@ - + - - + + + - + - - - + + + + + + + + + + + + + + + diff --git a/geometry/mollerParallel.gdml b/geometry/mollerParallel.gdml index e11ca3555..14ea053fe 100644 --- a/geometry/mollerParallel.gdml +++ b/geometry/mollerParallel.gdml @@ -31,21 +31,27 @@ startphi="0" deltaphi="360" aunit="deg" rmax="1200" rmin="0" z="1" lunit="mm"/> - - + + + + + @@ -91,13 +97,35 @@ - + + + + + + + + + + + + + + + + + + + + + + - + + @@ -126,6 +154,20 @@ + + + + + + + + + + + + + + @@ -160,6 +202,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + @@ -176,12 +243,8 @@ - - - - - + @@ -201,6 +264,15 @@ + + + + + + + + + diff --git a/geometry/pion/Calorimeter/pionDetectorCalorimeter.gdml b/geometry/pion/Calorimeter/pionDetectorCalorimeter.gdml index 5d234fc8e..738273958 100644 --- a/geometry/pion/Calorimeter/pionDetectorCalorimeter.gdml +++ b/geometry/pion/Calorimeter/pionDetectorCalorimeter.gdml @@ -64,7 +64,7 @@ - + @@ -92,7 +92,7 @@ - + diff --git a/geometry/pion/GEM/pionDetectorGEM.gdml b/geometry/pion/GEM/pionDetectorGEM.gdml index ff92e3a34..8eb9ecf07 100644 --- a/geometry/pion/GEM/pionDetectorGEM.gdml +++ b/geometry/pion/GEM/pionDetectorGEM.gdml @@ -4,8 +4,8 @@ - - + + @@ -36,7 +36,7 @@ - + diff --git a/geometry/pion/GEM/pionDetectorGEMOpenSector.gdml b/geometry/pion/GEM/pionDetectorGEMOpenSector.gdml index 39f0bdaa8..6b87bda03 100644 --- a/geometry/pion/GEM/pionDetectorGEMOpenSector.gdml +++ b/geometry/pion/GEM/pionDetectorGEMOpenSector.gdml @@ -3,14 +3,15 @@ - - + + + - + - + @@ -18,10 +19,10 @@ + rmin="pionDetectorGEMInnerRadius" + rmax="pionDetectorGEMOuterRadius" + z="pionDetectorGEMLength" + startphi="-0.5*PHI/2.0" deltaphi="0.5*PHI" aunit="deg"/> - + @@ -43,16 +44,22 @@ - + - + + + + + + + diff --git a/geometry/pion/Lucite/pionDetectorLucite.gdml b/geometry/pion/Lucite/pionDetectorLucite.gdml index cc6aebf53..3d05fd74d 100644 --- a/geometry/pion/Lucite/pionDetectorLucite.gdml +++ b/geometry/pion/Lucite/pionDetectorLucite.gdml @@ -8,13 +8,13 @@ - + - + @@ -30,17 +30,17 @@ - - + + - + - + @@ -49,8 +49,8 @@ - - + + @@ -58,13 +58,18 @@ - + + + + + + - + @@ -104,10 +109,6 @@ value="pionDetectorLuciteReflectorThickness/cos(pionDetectorLuciteReflectorTheta)"/> - - &matrices; @@ -119,26 +120,34 @@ - + - - - + + @@ -394,8 +413,8 @@ z="(-pionDetectorLuciteLightGuideHeight+pionDetectorLuciteLightGuideEntryDetectorThickness)/2.0"/> @@ -411,10 +430,10 @@ theta="pionDetectorLuciteLightGuideTheta" phi="90.0*deg" x1="SCALE_UP*(pionDetectorLuciteReflectorWidth+2.0*pionDetectorLuciteLightGuideThickness)" x2="SCALE_UP*(pionDetectorLuciteReflectorWidth+2.0*pionDetectorLuciteLightGuideThickness)" - x3="SCALE_UP*(pionDetectorLucitePMTDiameter+2.0*pionDetectorLuciteLightGuideThickness)" - x4="SCALE_UP*(pionDetectorLucitePMTDiameter+2.0*pionDetectorLuciteLightGuideThickness)" + x3="SCALE_UP*(numberOfPMTsInX*pionDetectorLucitePMTDiameter+2.0*pionDetectorLuciteLightGuideThickness)" + x4="SCALE_UP*(numberOfPMTsInX*pionDetectorLucitePMTDiameter+2.0*pionDetectorLuciteLightGuideThickness)" y1="SCALE_UP*(pionDetectorLuciteReflectorDepth+2.0*pionDetectorLuciteLightGuideThickness)" - y2="SCALE_UP*(pionDetectorLucitePMTDiameter+2.0*pionDetectorLuciteLightGuideThickness)" + y2="SCALE_UP*(numberOfPMTsInZ*pionDetectorLucitePMTDiameter+2.0*pionDetectorLuciteLightGuideThickness)" z="SCALE_UP*(pionDetectorLuciteLightGuideHeight+pionDetectorLucitePMTThickness)"/> @@ -440,7 +459,7 @@ - + + + + @@ -632,10 +654,11 @@ + - + - + @@ -644,30 +667,47 @@ - + + + + + + + + - + - + - + - + + + + + + + + + + + + + + - - - - + z="(-pionDetectorLucitePMTHousingHeight+pionDetectorLucitePMTThickness)/2.0"/> @@ -708,18 +748,27 @@ +pionDetectorLuciteLightGuideHeight/2.0"/> - - - - - + + + + + + + + + + diff --git a/geometry/pion/Lucite/pionDetectorLuciteSector.gdml b/geometry/pion/Lucite/pionDetectorLuciteSector.gdml index fbec1758f..ff14ba86f 100644 --- a/geometry/pion/Lucite/pionDetectorLuciteSector.gdml +++ b/geometry/pion/Lucite/pionDetectorLuciteSector.gdml @@ -3,6 +3,7 @@ + @@ -11,7 +12,7 @@ the radius along with the angle of the detector to increase the length in the longitudinal direction. --> - + - + - + - + + + + + + + + + + + + + + + @@ -58,45 +81,129 @@ + + + + + + + + + + + + + + + + + + + + - + + x="pionDetectorLuciteInnerEdgeRadialPosition" + z="-0.25*2.54*cm"/> + + + + + + + + + + + - + - + + + + + + + diff --git a/geometry/pion/Lucite/pionDetectorLucite_world.gdml b/geometry/pion/Lucite/pionDetectorLucite_world.gdml index 7611cb814..afbffb2b5 100644 --- a/geometry/pion/Lucite/pionDetectorLucite_world.gdml +++ b/geometry/pion/Lucite/pionDetectorLucite_world.gdml @@ -4,6 +4,7 @@ + @@ -24,6 +25,12 @@ + + diff --git a/geometry/pion/TS/pionDetectorTS.gdml b/geometry/pion/TS/pionDetectorTS.gdml index 80546669c..a4d64ea89 100644 --- a/geometry/pion/TS/pionDetectorTS.gdml +++ b/geometry/pion/TS/pionDetectorTS.gdml @@ -5,7 +5,7 @@ - + @@ -30,7 +30,7 @@ - + diff --git a/geometry/pion/TS/pionDetectorTSOpenSector.gdml b/geometry/pion/TS/pionDetectorTSOpenSector.gdml index 0fe2ee409..95d72920a 100644 --- a/geometry/pion/TS/pionDetectorTSOpenSector.gdml +++ b/geometry/pion/TS/pionDetectorTSOpenSector.gdml @@ -3,14 +3,15 @@ - - + + + - + - + @@ -18,10 +19,10 @@ + rmin="pionDetectorTSInnerRadius" + rmax="pionDetectorTSOuterRadius" + z="pionDetectorTSLength" + startphi="-0.5*PHI/2.0" deltaphi="0.5*PHI" aunit="deg"/> - + @@ -43,16 +44,22 @@ - + - + + + + + + + diff --git a/geometry/pion/pionDetectorSystem.gdml b/geometry/pion/pionDetectorSystem.gdml index bc29b8bb7..c48667ec9 100644 --- a/geometry/pion/pionDetectorSystem.gdml +++ b/geometry/pion/pionDetectorSystem.gdml @@ -4,132 +4,66 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + - - + + + + - - - - - - - - - - - - + - - - - - - - - + - + + + --> diff --git a/geometry/mollerMother_5open.gdml b/geometry/pion/pionDetectorSystem_world.gdml similarity index 57% rename from geometry/mollerMother_5open.gdml rename to geometry/pion/pionDetectorSystem_world.gdml index 40be70be2..96f0f20be 100644 --- a/geometry/mollerMother_5open.gdml +++ b/geometry/pion/pionDetectorSystem_world.gdml @@ -1,40 +1,35 @@ - - -]> - - - &positions; + + - &world; + - + - - - + + - + + - + - + diff --git a/geometry/pion/pionDetectorVirtualDet.gdml b/geometry/pion/pionDetectorVirtualDet.gdml index 2d7716a46..ac4bbcdaa 100644 --- a/geometry/pion/pionDetectorVirtualDet.gdml +++ b/geometry/pion/pionDetectorVirtualDet.gdml @@ -17,7 +17,7 @@ + rmin="820*mm" rmax="2000*mm" startphi="0" z="pionDetectorVirtualDetThickness"/> diff --git a/geometry/positions.xml b/geometry/positions.xml index 976b3fc8e..e67218f71 100644 --- a/geometry/positions.xml +++ b/geometry/positions.xml @@ -18,13 +18,11 @@ - - - - - - + + + + @@ -38,24 +36,37 @@ - - + + + - - + + + + + + + - + - + + + + - - + + + + + + + diff --git a/geometry/showermax/showerMaxGen.gdml b/geometry/showermax/showerMaxGen.gdml index 1a6a12eec..98d79f944 100644 --- a/geometry/showermax/showerMaxGen.gdml +++ b/geometry/showermax/showerMaxGen.gdml @@ -7,27 +7,43 @@ + + + + + + + + + + + + + + + + - - + + - - + + - - + + @@ -35,39 +51,39 @@ - - - - -

- - - + + + + +
+
+ + + + + + + + + + + + + + + + + + - - + + - + - - - - - - - - - - - - - - - - @@ -92,12 +108,21 @@ + + + + + + + + + @@ -108,6 +133,8 @@ + + @@ -118,6 +145,8 @@ + + @@ -128,49 +157,67 @@ + + + + - + + + + + - + - + - + - + + + + + + + + + + + - + - + - + @@ -180,24 +227,25 @@ - + - + - + - + + @@ -222,12 +270,21 @@ + + + + + + + + + @@ -238,6 +295,8 @@ + + @@ -248,6 +307,8 @@ + + @@ -258,49 +319,67 @@ + + + + - + + + + + - + - + - + - + + + + + + + + + + + - + - + - + @@ -310,24 +389,25 @@ - + - + - + - + + @@ -352,12 +432,21 @@ + + + + + + + + + @@ -368,6 +457,8 @@ + + @@ -378,6 +469,8 @@ + + @@ -388,49 +481,67 @@ + + + + - + + + + + - + - + - + - + + + + + + + + + + + - + - + - + @@ -440,24 +551,25 @@ - + - + - + - + + @@ -482,12 +594,21 @@ + + + + + + + + + @@ -498,6 +619,8 @@ + + @@ -508,6 +631,8 @@ + + @@ -518,49 +643,67 @@ + + + + - + + + + + - + - + - + - + + + + + + + + + + + - + - + - + @@ -570,24 +713,25 @@ - + - + - + - + + @@ -612,12 +756,21 @@ + + + + + + + + + @@ -628,6 +781,8 @@ + + @@ -638,6 +793,8 @@ + + @@ -648,49 +805,67 @@ + + + + - + + + + + - + - + - + - + + + + + + + + + + + - + - + - + @@ -700,24 +875,25 @@ - + - + - + - + + @@ -742,12 +918,21 @@ + + + + + + + + + @@ -758,6 +943,8 @@ + + @@ -768,6 +955,8 @@ + + @@ -778,49 +967,67 @@ + + + + - + + + + + - + - + - + - + + + + + + + + + + + - + - + - + @@ -830,24 +1037,25 @@ - + - + - + - + + @@ -872,12 +1080,21 @@ + + + + + + + + + @@ -888,6 +1105,8 @@ + + @@ -898,6 +1117,8 @@ + + @@ -908,49 +1129,67 @@ + + + + - + + + + + - + - + - + - + + + + + + + + + + + - + - + - + @@ -960,24 +1199,25 @@ - + - + - + - + + @@ -1002,12 +1242,21 @@ + + + + + + + + + @@ -1018,6 +1267,8 @@ + + @@ -1028,6 +1279,8 @@ + + @@ -1038,49 +1291,67 @@ + + + + - + + + + + - + - + - + - + + + + + + + + + + + - + - + - + @@ -1090,24 +1361,25 @@ - + - + - + - + + @@ -1132,12 +1404,21 @@ + + + + + + + + + @@ -1148,6 +1429,8 @@ + + @@ -1158,6 +1441,8 @@ + + @@ -1168,49 +1453,67 @@ + + + + - + + + + + - + - + - + - + + + + + + + + + + + - + - + - + @@ -1220,24 +1523,25 @@ - + - + - + - + + @@ -1262,12 +1566,21 @@ + + + + + + + + + @@ -1278,6 +1591,8 @@ + + @@ -1288,6 +1603,8 @@ + + @@ -1298,49 +1615,67 @@ + + + + - + + + + + - + - + - + - + + + + + + + + + + + - + - + - + @@ -1350,24 +1685,25 @@ - + - + - + - + + @@ -1392,12 +1728,21 @@ + + + + + + + + + @@ -1408,6 +1753,8 @@ + + @@ -1418,6 +1765,8 @@ + + @@ -1428,49 +1777,67 @@ + + + + - + + + + + - + - + - + - + + + + + + + + + + + - + - + - + @@ -1480,24 +1847,25 @@ - + - + - + - + + @@ -1522,12 +1890,21 @@ + + + + + + + + + @@ -1538,6 +1915,8 @@ + + @@ -1548,6 +1927,8 @@ + + @@ -1558,49 +1939,67 @@ + + + + - + + + + + - + - + - + - + + + + + + + + + + + - + - + - + @@ -1610,24 +2009,25 @@ - + - + - + - + + @@ -1652,12 +2052,21 @@ + + + + + + + + + @@ -1668,6 +2077,8 @@ + + @@ -1678,6 +2089,8 @@ + + @@ -1688,49 +2101,67 @@ + + + + - + + + + + - + - + - + - + + + + + + + + + + + - + - + - + @@ -1740,24 +2171,25 @@ - + - + - + - + + @@ -1782,12 +2214,21 @@ + + + + + + + + + @@ -1798,6 +2239,8 @@ + + @@ -1808,6 +2251,8 @@ + + @@ -1818,49 +2263,67 @@ + + + + - + + + + + - + - + - + - + + + + + + + + + + + - + - + - + @@ -1870,24 +2333,25 @@ - + - + - + - + + @@ -1912,12 +2376,21 @@ + + + + + + + + + @@ -1928,6 +2401,8 @@ + + @@ -1938,6 +2413,8 @@ + + @@ -1948,49 +2425,67 @@ + + + + - + + + + + - + - + - + - + + + + + + + + + + + - + - + - + @@ -2000,24 +2495,25 @@ - + - + - + - + + @@ -2042,12 +2538,21 @@ + + + + + + + + + @@ -2058,6 +2563,8 @@ + + @@ -2068,6 +2575,8 @@ + + @@ -2078,49 +2587,67 @@ + + + + - + + + + + - + - + - + - + + + + + + + + + + + - + - + - + @@ -2130,24 +2657,25 @@ - + - + - + - + + @@ -2172,12 +2700,21 @@ + + + + + + + + + @@ -2188,6 +2725,8 @@ + + @@ -2198,6 +2737,8 @@ + + @@ -2208,49 +2749,67 @@ + + + + - + + + + + - + - + - + - + + + + + + + + + + + - + - + - + @@ -2260,24 +2819,25 @@ - + - + - + - + + @@ -2302,12 +2862,21 @@ + + + + + + + + + @@ -2318,6 +2887,8 @@ + + @@ -2328,6 +2899,8 @@ + + @@ -2338,49 +2911,67 @@ + + + + - + + + + + - + - + - + - + + + + + + + + + + + - + - + - + @@ -2390,24 +2981,25 @@ - + - + - + - + + @@ -2432,12 +3024,21 @@ + + + + + + + + + @@ -2448,6 +3049,8 @@ + + @@ -2458,6 +3061,8 @@ + + @@ -2468,49 +3073,67 @@ + + + + - + + + + + - + - + - + - + + + + + + + + + + + - + - + - + @@ -2520,24 +3143,25 @@ - + - + - + - + + @@ -2562,12 +3186,21 @@ + + + + + + + + + @@ -2578,6 +3211,8 @@ + + @@ -2588,6 +3223,8 @@ + + @@ -2598,49 +3235,67 @@ + + + + - + + + + + - + - + - + - + + + + + + + + + + + - + - + - + @@ -2650,24 +3305,25 @@ - + - + - + - + + @@ -2692,12 +3348,21 @@ + + + + + + + + + @@ -2708,6 +3373,8 @@ + + @@ -2718,6 +3385,8 @@ + + @@ -2728,49 +3397,67 @@ + + + + - + + + + + - + - + - + - + + + + + + + + + + + - + - + - + @@ -2780,24 +3467,25 @@ - + - + - + - + + @@ -2822,12 +3510,21 @@ + + + + + + + + + @@ -2838,6 +3535,8 @@ + + @@ -2848,6 +3547,8 @@ + + @@ -2858,49 +3559,67 @@ + + + + - + + + + + - + - + - + - + + + + + + + + + + + - + - + - + @@ -2910,24 +3629,25 @@ - + - + - + - + + @@ -2952,12 +3672,21 @@ + + + + + + + + + @@ -2968,6 +3697,8 @@ + + @@ -2978,6 +3709,8 @@ + + @@ -2988,49 +3721,67 @@ + + + + - + + + + + - + - + - + - + + + + + + + + + + + - + - + - + @@ -3040,24 +3791,25 @@ - + - + - + - + + @@ -3082,12 +3834,21 @@ + + + + + + + + + @@ -3098,6 +3859,8 @@ + + @@ -3108,6 +3871,8 @@ + + @@ -3118,49 +3883,67 @@ + + + + - + + + + + - + - + - + - + + + + + + + + + + + - + - + - + @@ -3170,24 +3953,25 @@ - + - + - + - + + @@ -3212,12 +3996,21 @@ + + + + + + + + + @@ -3228,6 +4021,8 @@ + + @@ -3238,6 +4033,8 @@ + + @@ -3248,49 +4045,67 @@ + + + + - + + + + + - + - + - + - + + + + + + + + + + + - + - + - + @@ -3300,24 +4115,25 @@ - + - + - + - + + @@ -3342,12 +4158,21 @@ + + + + + + + + + @@ -3358,6 +4183,8 @@ + + @@ -3368,6 +4195,8 @@ + + @@ -3378,49 +4207,67 @@ + + + + - + + + + + - + - + - + - + + + + + + + + + + + - + - + - + @@ -3430,24 +4277,25 @@ - + - + - + - + + @@ -3472,12 +4320,21 @@ + + + + + + + + + @@ -3488,6 +4345,8 @@ + + @@ -3498,6 +4357,8 @@ + + @@ -3508,49 +4369,67 @@ + + + + - + + + + + - + - + - + - + + + + + + + + + + + - + - + - + @@ -3560,24 +4439,25 @@ - + - + - + - + + @@ -3602,12 +4482,21 @@ + + + + + + + + + @@ -3618,6 +4507,8 @@ + + @@ -3628,6 +4519,8 @@ + + @@ -3638,49 +4531,67 @@ + + + + - + + + + + - + - + - + - + + + + + + + + + + + - + - + - + @@ -3690,172 +4601,173 @@ - + - + - + - + + - - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + - \ No newline at end of file + diff --git a/geometry/solids/world.xml b/geometry/solids/world.xml index 2d8452a57..28cdde052 100644 --- a/geometry/solids/world.xml +++ b/geometry/solids/world.xml @@ -1,8 +1,8 @@ - + - + diff --git a/geometry/solids_mainz.xml b/geometry/solids_mainz.xml deleted file mode 100644 index b1dcac3f3..000000000 --- a/geometry/solids_mainz.xml +++ /dev/null @@ -1,130 +0,0 @@ - - - - - - - - - - - - - - - - -
-
- - - - - - - - - - - - - -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - - - - - - - - - - - - - - - - - - - -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/geometry/target/subTargetRegion.gdml b/geometry/target/subTargetRegion.gdml index 23b9adcb4..16455991e 100644 --- a/geometry/target/subTargetRegion.gdml +++ b/geometry/target/subTargetRegion.gdml @@ -54,7 +54,7 @@ - + @@ -129,7 +129,7 @@ - + - - + + @@ -150,7 +150,7 @@ - + @@ -169,7 +169,7 @@ - + - + - - - - - - - - - - - - - - - - - - - - - @@ -305,6 +284,7 @@ + @@ -313,6 +293,7 @@ + @@ -321,6 +302,7 @@ + @@ -331,6 +313,7 @@ + @@ -342,6 +325,7 @@ + @@ -352,6 +336,7 @@ + @@ -362,6 +347,7 @@ + @@ -372,6 +358,7 @@ + @@ -383,6 +370,7 @@ + @@ -393,6 +381,7 @@ + @@ -412,26 +401,14 @@ - - - - - - - - - - - - - - + + @@ -520,7 +497,7 @@ - + diff --git a/geometry/target/target12C.gdml b/geometry/target/target12C.gdml deleted file mode 100644 index 836e95d86..000000000 --- a/geometry/target/target12C.gdml +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - - - - - -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/geometry/target/targetLadder.gdml b/geometry/target/targetLadder.gdml new file mode 100644 index 000000000..10ce6c4bc --- /dev/null +++ b/geometry/target/targetLadder.gdml @@ -0,0 +1,267 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/geometry/tracking/daughterGEM1.gdml b/geometry/tracking/daughterGEM1.gdml deleted file mode 100644 index 16db945c2..000000000 --- a/geometry/tracking/daughterGEM1.gdml +++ /dev/null @@ -1,73 +0,0 @@ - - - - - - - - - -

- - - - - -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/geometry/tracking/daughterGEM2.gdml b/geometry/tracking/daughterGEM2.gdml deleted file mode 100644 index 19a89cf1f..000000000 --- a/geometry/tracking/daughterGEM2.gdml +++ /dev/null @@ -1,73 +0,0 @@ - - - - - - - - - -

- - - - - -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/geometry/tracking/daughterGEM3.gdml b/geometry/tracking/daughterGEM3.gdml deleted file mode 100644 index 775b33557..000000000 --- a/geometry/tracking/daughterGEM3.gdml +++ /dev/null @@ -1,73 +0,0 @@ - - - - - - - - - -

- - - - - -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/geometry/tracking/daughterGEM4.gdml b/geometry/tracking/daughterGEM4.gdml deleted file mode 100644 index 1be47f505..000000000 --- a/geometry/tracking/daughterGEM4.gdml +++ /dev/null @@ -1,74 +0,0 @@ - - - - - - - - - -

- - - - - -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/geometry/tracking/trackingDaughter.gdml b/geometry/tracking/trackingDaughter.gdml index 1add7af8b..caa108bb9 100644 --- a/geometry/tracking/trackingDaughter.gdml +++ b/geometry/tracking/trackingDaughter.gdml @@ -4,14 +4,8 @@ xsi:noNamespaceSchemaLocation="http://service-spi.web.cern.ch/service-spi/app/releases/GDML/schema/gdml.xsd"> - - - - - - - - + + @@ -29,10 +23,8 @@ - - - - + + @@ -59,13 +51,16 @@ - + + + + + rmin="650" rmax="1900" z="100" lunit="mm"/> @@ -110,7 +105,7 @@ - + @@ -135,76 +130,36 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + - + - + - + - + - + - - - - - - - - - - + diff --git a/geometry/upstream/inner_upstream_nose_shield_beampipe.gdml b/geometry/upstream/inner_upstream_nose_shield_beampipe.gdml new file mode 100755 index 000000000..01fa28c3c --- /dev/null +++ b/geometry/upstream/inner_upstream_nose_shield_beampipe.gdml @@ -0,0 +1,105 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/geometry/upstream/sieve.gdml b/geometry/upstream/sieve.gdml new file mode 100644 index 000000000..80775f63a --- /dev/null +++ b/geometry/upstream/sieve.gdml @@ -0,0 +1,181 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/geometry/upstream/upstreamBeampipe.gdml b/geometry/upstream/upstreamBeampipe.gdml index 55f1ec493..b8e7a5668 100644 --- a/geometry/upstream/upstreamBeampipe.gdml +++ b/geometry/upstream/upstreamBeampipe.gdml @@ -5,13 +5,6 @@ - - - - - - - @@ -20,24 +13,40 @@ - - - + + + + + + + + + + + + + + + + + - - + + - + diff --git a/geometry/upstream/upstreamDaughter_merged.gdml b/geometry/upstream/upstreamDaughter_merged.gdml index b48cd968c..00c7066c4 100644 --- a/geometry/upstream/upstreamDaughter_merged.gdml +++ b/geometry/upstream/upstreamDaughter_merged.gdml @@ -3,35 +3,29 @@ + ]> + &positions; &matrices; - - - + - - - - - - - - + + @@ -44,6 +38,7 @@ + @@ -57,9 +52,55 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -73,11 +114,19 @@ - + + + + + + + + + &materials; @@ -228,7 +277,6 @@ --> - @@ -240,13 +288,13 @@ - - - - - + + + + + - + - - - - - - + + + + @@ -336,91 +374,142 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - - - - - - - - - - + + + - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - - + + + + - - - - - + + + + + + + + + + + + + + + - - - - - + + + + + @@ -454,6 +543,7 @@ + @@ -461,7 +551,7 @@ - + @@ -502,26 +592,322 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - - + + - - + + - - - + + - - + + + + + + + + + + + + @@ -588,6 +983,18 @@ + + + + + + + + + + + + diff --git a/geometry/upstream/upstreamToroid.gdml b/geometry/upstream/upstreamToroid.gdml index 07b5f2b51..0947432bb 100644 --- a/geometry/upstream/upstreamToroid.gdml +++ b/geometry/upstream/upstreamToroid.gdml @@ -14,199 +14,391 @@ + + + + + + + + + + + + - - - - - - - - - - + + + + + + +

+
+ + + + + + + + + + + + + + + + + - - - - - + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + - - - - - + + + + + + - + + + - + + + + + + + + + + - + + + + + + - - - - - - - - - + + + + + + + + + + + - + + + + + + + + + + - + + + + + + - - - - - - - - - + + + + + + + + + + + + + + + + + + + - + + - + + + + + + - - - - - - - - - + + + + + + + + + + + - + + + + + + + + + + - + + + + + + - - - - - - - - - + + + + + + + + + + + - + + + + + + + + + + - + + + + + + - - - - - - - - - + + + + + + + + + + + + + + + + + + + - + + - + + + + + + - - - - - - - - - + + + + + + + + + + + + + + + + + + + - + + - + + + + + + - - - - - - - - - + + + + + + + + + + + - + + - - - - - - - + - - - + + + + - - - + + + + - - - + + + + - - - + + + + - - - + + + + - - - + + + + + + + + + + + + - - + + + + diff --git a/geometry/upstream/upstream_nose_shield_beampipe.gdml b/geometry/upstream/upstream_nose_shield_beampipe.gdml new file mode 100755 index 000000000..f5533a61b --- /dev/null +++ b/geometry/upstream/upstream_nose_shield_beampipe.gdml @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/geometry_Mainz/detector_Mainz.gdml b/geometry_Mainz/detector_Mainz.gdml deleted file mode 100644 index 62429a652..000000000 --- a/geometry_Mainz/detector_Mainz.gdml +++ /dev/null @@ -1,202 +0,0 @@ - - - - - - ]> - - - - - - - &matrices_Mainz; - - &materials; - &solids_Mainz; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/geometry_Mainz/materialsOptical.xml b/geometry_Mainz/materialsOptical.xml deleted file mode 100644 index 07e35e64d..000000000 --- a/geometry_Mainz/materialsOptical.xml +++ /dev/null @@ -1,73 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/geometry_Mainz/solids_Mainz.xml b/geometry_Mainz/solids_Mainz.xml deleted file mode 100644 index f16a1aee0..000000000 --- a/geometry_Mainz/solids_Mainz.xml +++ /dev/null @@ -1,133 +0,0 @@ - - - - - - - - - - - - - - - - -
-
- - - - - - - - - - - - - -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - - - - - - - - - - - - - - - - - - - -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/geometry/detector_5open.gdml b/geometry_sandbox/detector_Mainz.gdml similarity index 53% rename from geometry/detector_5open.gdml rename to geometry_sandbox/detector_Mainz.gdml index c6a2f9735..42a1c415b 100644 --- a/geometry/detector_5open.gdml +++ b/geometry_sandbox/detector_Mainz.gdml @@ -1,20 +1,20 @@ - - + + + ]> - + -&matrices; +&matrices_Mainz; &materials; -&solids_5open; +&solids_Mainz; @@ -24,28 +24,29 @@ - + - + - + + - + - + @@ -53,34 +54,34 @@ - + - + - + - + - + - + - + @@ -93,12 +94,14 @@ - + + @@ -106,7 +109,7 @@ - + @@ -119,92 +122,105 @@ + - - - - - + + + + + - + - + - + - + - - + - + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - + + + + + + + + + + + + + + + - - + + diff --git a/geometry_Mainz/detector_Mainz_v2.gdml b/geometry_sandbox/detector_Mainz_v2.gdml similarity index 100% rename from geometry_Mainz/detector_Mainz_v2.gdml rename to geometry_sandbox/detector_Mainz_v2.gdml diff --git a/geometry_Mainz/materials.xml b/geometry_sandbox/materials.xml similarity index 100% rename from geometry_Mainz/materials.xml rename to geometry_sandbox/materials.xml diff --git a/geometry_sandbox/materialsOptical.xml b/geometry_sandbox/materialsOptical.xml new file mode 100644 index 000000000..e1ab08090 --- /dev/null +++ b/geometry_sandbox/materialsOptical.xml @@ -0,0 +1,119 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/geometry_sandbox/materialsOptical_Mainz.xml b/geometry_sandbox/materialsOptical_Mainz.xml new file mode 100644 index 000000000..0d1926048 --- /dev/null +++ b/geometry_sandbox/materialsOptical_Mainz.xml @@ -0,0 +1,125 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/geometry_Mainz/matrices_Mainz.xml b/geometry_sandbox/matrices_Mainz.xml similarity index 99% rename from geometry_Mainz/matrices_Mainz.xml rename to geometry_sandbox/matrices_Mainz.xml index b022fa308..b96bd9eec 100644 --- a/geometry_Mainz/matrices_Mainz.xml +++ b/geometry_sandbox/matrices_Mainz.xml @@ -3887,7 +3887,9 @@ 7.75292132725114*eV 0.626332 7.75340582427197*eV 0.622443 7.75389038185113*eV 0.618527"/> - + - \ No newline at end of file + + + + + + + + + diff --git a/geometry_Mainz/matrices_Mainz_v2.xml b/geometry_sandbox/matrices_Mainz_v2.xml similarity index 99% rename from geometry_Mainz/matrices_Mainz_v2.xml rename to geometry_sandbox/matrices_Mainz_v2.xml index b022fa308..c52e22d6c 100644 --- a/geometry_Mainz/matrices_Mainz_v2.xml +++ b/geometry_sandbox/matrices_Mainz_v2.xml @@ -6079,4 +6079,4 @@ 7.75292132725114*eV 0.39013 7.75340582427197*eV 0.29228 7.75389038185113*eV 0.288638"/> - \ No newline at end of file + diff --git a/geometry_Mainz/mollerMother.gdml b/geometry_sandbox/mollerMother.gdml similarity index 92% rename from geometry_Mainz/mollerMother.gdml rename to geometry_sandbox/mollerMother.gdml index 1be976c75..c02a5d333 100644 --- a/geometry_Mainz/mollerMother.gdml +++ b/geometry_sandbox/mollerMother.gdml @@ -29,14 +29,14 @@ - + - + diff --git a/geometry_sandbox/mollerMother_Mainz.gdml b/geometry_sandbox/mollerMother_Mainz.gdml new file mode 100644 index 000000000..6f13a1226 --- /dev/null +++ b/geometry_sandbox/mollerMother_Mainz.gdml @@ -0,0 +1,43 @@ + + + + + + + + + + + + + +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/geometry/solids_5open.xml b/geometry_sandbox/solids_Mainz.xml similarity index 66% rename from geometry/solids_5open.xml rename to geometry_sandbox/solids_Mainz.xml index 902be8aaf..305ff003b 100644 --- a/geometry/solids_5open.xml +++ b/geometry_sandbox/solids_Mainz.xml @@ -1,12 +1,19 @@ - - - - - - - + + + + + + + + + + + + + + @@ -23,65 +30,65 @@ - - - + + + - + - - + + - - - + + +

- + - - + + - - + + - - + + - - + + - - - + + + - + - - + + @@ -93,7 +100,7 @@ - +
@@ -114,7 +121,7 @@ - + @@ -149,7 +156,7 @@ startphi="0" deltaphi="2*PI" aunit="rad" lunit= "mm" /> - + @@ -158,7 +165,9 @@ startphi="0" deltaphi="2*PI" aunit="rad" lunit= "mm" /> - + + + diff --git a/geometry_Mainz/solids_Mainz_v2.xml b/geometry_sandbox/solids_Mainz_v2.xml similarity index 100% rename from geometry_Mainz/solids_Mainz_v2.xml rename to geometry_sandbox/solids_Mainz_v2.xml diff --git a/geometry_Mainz/targetDaughter.gdml b/geometry_sandbox/targetDaughter.gdml similarity index 100% rename from geometry_Mainz/targetDaughter.gdml rename to geometry_sandbox/targetDaughter.gdml diff --git a/include/remollBeamTarget.hh b/include/remollBeamTarget.hh index 5857ae1de..fe7be08b9 100644 --- a/include/remollBeamTarget.hh +++ b/include/remollBeamTarget.hh @@ -4,8 +4,10 @@ #include "remolltypes.hh" #include "remollglobs.hh" #include "remollVertex.hh" +#include "remollMultScatt.hh" #include "G4ThreeVector.hh" +#include "G4GenericMessenger.hh" #include /*! @@ -25,35 +27,53 @@ */ -class G4GenericMessenger; class G4VPhysicalVolume; class G4Material; -class remollMultScatt; class remollBeamTarget { private: // Static geometry objects - static G4String fActiveTargetVolume; - static std::vector fTargetVolumes; - static G4VPhysicalVolume* fTargetMother; + static G4String fActiveTargetMotherName; + static G4String fActiveTargetVolumeName; + static size_t fActiveTargetMother; + static size_t fActiveTargetVolume; + static std::vector> fTargetMothers; + static std::vector>> fTargetVolumes; // Effective lengths are weighted by density (i.e. in 1/cm^2) static G4double fTotalTargetEffectiveLength; static G4double fActiveTargetEffectiveLength; // Positions are in physical distances (i.e. in cm) static G4double fMotherTargetAbsolutePosition; - static G4double fActiveTargetRelativePosition; + // Flag to require recomputation of effective lengths + static bool fUpdateNeeded; + public: static void UpdateInfo(); public: // Static geometry functions - static void ResetTargetVolumes(){ fTargetVolumes.clear(); fTargetMother = 0; UpdateInfo(); } - static void SetMotherVolume( G4VPhysicalVolume *v ){ fTargetMother = v; UpdateInfo(); } - static void AddTargetVolume( G4VPhysicalVolume *v ){ fTargetVolumes.push_back(v); UpdateInfo(); } - static std::vector GetTargetVolumes(){ return fTargetVolumes; } + static void ResetTargetVolumes() { + fTargetVolumes.clear(); + fTargetMothers.clear(); + fUpdateNeeded = true; + } + static void AddMotherVolume(G4VPhysicalVolume *v, const G4String& tag) { + fTargetMothers.push_back(std::make_pair(v,tag)); + fTargetVolumes.resize(fTargetMothers.size()); + fActiveTargetMother = fTargetMothers.size() - 1; + fUpdateNeeded = true; + } + static void AddTargetVolume(G4VPhysicalVolume *v, const G4String& tag) { + fTargetVolumes[fActiveTargetMother].push_back(std::make_pair(v,tag)); + fUpdateNeeded = true; + } + static std::vector> GetTargetVolumes() { + return fTargetVolumes[fActiveTargetMother]; + } + void SetActiveTargetMother(G4String name); void SetActiveTargetVolume(G4String name); void PrintTargetInfo(); @@ -62,22 +82,32 @@ class remollBeamTarget { remollBeamTarget(); virtual ~remollBeamTarget(); - G4double GetEffLumin(); + G4double GetEffLumin(SamplingType_t) const; - - remollVertex SampleVertex(SampType_t); + remollVertex SampleVertex(SamplingType_t); G4double fBeamEnergy; G4double fBeamCurrent; G4double fBeamPolarization; - remollMultScatt *fMS; + private: + remollMultScatt fMS; + public: + const remollMultScatt& GetMultScatt() const { return fMS; } + private: bool fAlreadyWarned; bool fAlreadyWarned_LH2; private: - G4GenericMessenger* fMessenger; + G4GenericMessenger fMessenger{ + this, + "/remoll/", + "Remoll properties"}; + G4GenericMessenger fTargetMessenger{ + this, + "/remoll/target/", + "Remoll target properties"}; G4Material *fDefaultMat; diff --git a/include/remollDetectorConstruction.hh b/include/remollDetectorConstruction.hh index 66acccf30..d3a040758 100644 --- a/include/remollDetectorConstruction.hh +++ b/include/remollDetectorConstruction.hh @@ -4,16 +4,18 @@ #include "G4GDMLParser.hh" #include "G4GDMLAuxStructType.hh" #include "G4VUserDetectorConstruction.hh" +#include "G4GenericMessenger.hh" #include "G4Types.hh" #include #include +#include "remollSearchPath.hh" + class G4Tubs; class G4LogicalVolume; class G4VPhysicalVolume; class G4VSensitiveDetector; -class G4GenericMessenger; class G4UserLimits; class remollGlobalField; @@ -48,7 +50,7 @@ class remollDetectorConstruction : public G4VUserDetectorConstruction private: - G4GDMLParser *fGDMLParser; + G4GDMLParser fGDMLParser; G4bool fGDMLValidate; G4bool fGDMLOverlapCheck; @@ -57,6 +59,7 @@ class remollDetectorConstruction : public G4VUserDetectorConstruction G4String fGDMLFile; void SetGDMLFile(G4String gdmlfile) { + gdmlfile = remollSearchPath::resolve(gdmlfile); size_t i = gdmlfile.rfind('/'); if (i != std::string::npos) { fGDMLPath = gdmlfile.substr(0,i); @@ -64,8 +67,14 @@ class remollDetectorConstruction : public G4VUserDetectorConstruction fGDMLFile = gdmlfile.substr(i + 1); } - G4GenericMessenger* fMessenger; - G4GenericMessenger* fGeometryMessenger; + G4GenericMessenger fMessenger{ + this, + "/remoll/", + "Remoll properties"}; + G4GenericMessenger fGeometryMessenger{ + this, + "/remoll/geometry/", + "Remoll geometry properties"}; void ReloadGeometry(const G4String gdmlfile); @@ -84,8 +93,10 @@ class remollDetectorConstruction : public G4VUserDetectorConstruction private: - G4GenericMessenger* fUserLimitsMessenger; - + G4GenericMessenger fUserLimitsMessenger{ + this, + "/remoll/geometry/userlimits/", + "Remoll geometry properties"}; public: @@ -98,7 +109,10 @@ class remollDetectorConstruction : public G4VUserDetectorConstruction private: - G4GenericMessenger* fKryptoniteMessenger; + G4GenericMessenger fKryptoniteMessenger{ + this, + "/remoll/kryptonite/", + "Remoll kryptonite properties"}; static G4UserLimits* fKryptoniteUserLimits; G4bool fKryptoniteEnable; G4int fKryptoniteVerbose; @@ -109,6 +123,11 @@ class remollDetectorConstruction : public G4VUserDetectorConstruction void InitKryptoniteMaterials(); + private: + + std::vector fMeshPVs; + + void AddMesh(const G4String& filename); public: diff --git a/include/remollGen12CElastic.hh b/include/remollGen12CElastic.hh deleted file mode 100644 index d37d94d78..000000000 --- a/include/remollGen12CElastic.hh +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef __REMOLLGEN12CELASTIC_HH -#define __REMOLLGEN12CELASTIC_HH -/*! - * e12C elastic event generator - * - * Rupesh Silwal - * Aug 9, 2013 - * - * Based heavily on remollGenpElastic.hh -*/ - -#include "remollVEventGen.hh" - -class remollBeamTarget; - -class remollGen12CElastic : public remollVEventGen { - public: - remollGen12CElastic(); - ~remollGen12CElastic(); - - private: - void SamplePhysics(remollVertex *, remollEvent *); - - G4double RadProfile(G4double,G4double); - G4double EnergNumInt(G4double,G4double,G4double); - - remollBeamTarget *fBeamTarg; -}; - -#endif// __REMOLLGEN12CELASTIC_HH diff --git a/include/remollGenBeam.hh b/include/remollGenBeam.hh index cfea33922..3b3de8628 100644 --- a/include/remollGenBeam.hh +++ b/include/remollGenBeam.hh @@ -48,6 +48,7 @@ class remollGenBeam : public remollVEventGen { void SetDirectionZ(double dz); void SetDirectionPh(double ph); void SetDirectionTh(double th); + void SetDirectionIsotropic(); void SetCorrelationX(double cx); void SetCorrelationY(double cy); @@ -65,6 +66,10 @@ class remollGenBeam : public remollVEventGen { G4ThreeVector fOriginSpread; EOriginModel fOriginModelX, fOriginModelY, fOriginModelZ; G4ThreeVector fDirection; + G4double fOriginShift; + G4bool fIsotropic; + G4double fIsotropicThetaMin; + G4double fIsotropicThetaMax; G4ThreeVector fCorrelation; G4ThreeVector fPolarization; diff --git a/include/remollGenC12.hh b/include/remollGenC12.hh new file mode 100644 index 000000000..b721c5fa0 --- /dev/null +++ b/include/remollGenC12.hh @@ -0,0 +1,37 @@ +#ifndef __REMOLLGENC12_HH +#define __REMOLLGENC12_HH + +#include "remollVEventGen.hh" + +#include + +class remollGenC12 : public remollVEventGen { +public: + remollGenC12(G4int physicsType); + virtual ~remollGenC12(); + +private: + G4int type; + + static std::map fNamesMap; + static std::map CreateNamesMap(); + + void SamplePhysics(remollVertex *, remollEvent *); + + ///Christy Bosted fit + void GenInelastic(G4double beamE,G4double theta, + G4double &Q2,G4double &W2,G4double &effectiveXsection, + G4double &fWeight,G4double &eOut,G4double &asym); + + ///Christy Bosted fit + void GenQuasiElastic(G4double beamE,G4double theta, + G4double &Q2,G4double &W2,G4double &effectiveXsection, + G4double &fWeight,G4double &eOut,G4double &asym); + + void GenElastic(G4double beamE, G4double theta, + G4double &Q2,G4double &W2,G4double &effectiveXsection, + G4double &fWeight,G4double &eOut,G4double &asym); + +}; + +#endif//__REMOLLGENC12_HH diff --git a/include/remollGenExternal.hh b/include/remollGenExternal.hh index 6fa1e2c79..08fd37a64 100644 --- a/include/remollGenExternal.hh +++ b/include/remollGenExternal.hh @@ -52,14 +52,16 @@ class remollGenExternal : public remollVEventGen { private: void SamplePhysics(remollVertex *, remollEvent *); + // External event file and tree, entry number - TFile* fFile; - TTree* fTree; - Int_t fEntry, fEntries; + static TFile* fFile; + static TTree* fTree; + static Int_t fEntry, fEntries; // Event and hit structures - remollEvent_t* fEvent; - std::vector* fHit; + static remollEvent_t* fEvent; + static std::vector* fHit; + G4double fzOffset; // Detector ID to consider diff --git a/include/remollGenMoller.hh b/include/remollGenMoller.hh index 525feb06c..d7ebf90ca 100644 --- a/include/remollGenMoller.hh +++ b/include/remollGenMoller.hh @@ -11,8 +11,6 @@ #include "remollVEventGen.hh" -class remollBeamTarget; - class remollGenMoller : public remollVEventGen { public: remollGenMoller(); @@ -20,9 +18,6 @@ class remollGenMoller : public remollVEventGen { private: void SamplePhysics(remollVertex *, remollEvent *); - - remollBeamTarget *fBeamTarg; - }; #endif//__REMOLLGENMOLLER_HH diff --git a/include/remollGenTF1.hh b/include/remollGenTF1.hh deleted file mode 100644 index 3a4fbaa34..000000000 --- a/include/remollGenTF1.hh +++ /dev/null @@ -1,82 +0,0 @@ -#ifndef __REMOLLGENTF1_HH -#define __REMOLLGENTF1_HH -/*! - * Event generator matching MOLLER output at detector plane - * - * Cameron Clarke - * April 25, 2018 - * -*/ - -#include "G4Event.hh" - -#include "remollVEventGen.hh" -#include "Randomize.hh" -#include "G4AutoLock.hh" - -#include -// For the TH1Fs -#include -#include -#include -#include -#include -#include - -#include - -class TFile; -class TTree; -struct remollEvent_t; -struct remollGenericDetectorHit_t; - - -class remollGenTF1 : public remollVEventGen { - public: - remollGenTF1(); - virtual ~remollGenTF1(); - void GeneratePrimaries(G4Event* anEvent); - double RadSpectrum(); - void PrintEventGen(); - - private: - void SamplePhysics(remollVertex *, remollEvent *); - - void SetRing(G4int num); - void SetRadOffset(G4bool offset); - void SetGenFunctionFile(G4String filename); - void SetSector(int secnum); - void SetScatteringType(G4String input); - - void distAnalysis(); - void getHist(G4String fname); - void fitHist(G4String type); - static double elasticFit(double *x, double *par); - static double inelasticFit(double *x, double *par); - static double lorentzFit(double *x, double *par); - - double fZpos; - - - TFile* fFile; - TF1* fFunc; - TF1* fMollerFunc; - TF1* fElasticFunc; - TF1* fInelasticFunc; - G4String fType; - G4int fRing; - G4int fSector; - TH1F* fMollerHist; - TH1F* fElasticHist; - TH1F* fInelasticHist; - G4double r_t; - public: - G4double fXmin, fXmax, fYmin, fYmax; - G4double fZ; - G4double fDeltaPh_min, fDeltaPh_max; - G4double fR_min, fR_max; - G4bool fBoffsetR; - -}; - -#endif//__REMOLLGENTF1_HH diff --git a/include/remollGenericDetectorHit.hh b/include/remollGenericDetectorHit.hh index 7186997f1..01c728f2f 100644 --- a/include/remollGenericDetectorHit.hh +++ b/include/remollGenericDetectorHit.hh @@ -48,7 +48,7 @@ class remollGenericDetectorHit : public G4VHit { G4double fThRec; // Total momentum, energy, mass, kinetic energy - G4double fP, fE, fM, fK; + G4double fP, fE, fM, fK, fBeta; // Origin G4ThreeVector f3V; // Geant4 track ID, particle type, and mother ID @@ -92,6 +92,7 @@ class remollGenericDetectorHit : public G4VHit { hit.e = fE; hit.m = fM; hit.k = fK; + hit.beta = fBeta; hit.edep = fEdep; return hit; }; diff --git a/include/remollGenpElastic.hh b/include/remollGenpElastic.hh index 7e14279f4..ac6476856 100644 --- a/include/remollGenpElastic.hh +++ b/include/remollGenpElastic.hh @@ -11,8 +11,6 @@ #include "remollVEventGen.hh" -class remollBeamTarget; - class remollGenpElastic : public remollVEventGen { public: remollGenpElastic(); diff --git a/include/remollGlobalField.hh b/include/remollGlobalField.hh index 0c0e31111..bac883e2e 100644 --- a/include/remollGlobalField.hh +++ b/include/remollGlobalField.hh @@ -7,11 +7,11 @@ */ #include "G4MagneticField.hh" +#include "G4GenericMessenger.hh" #include "G4ThreeVector.hh" #include -class G4GenericMessenger; class G4EquationOfMotion; class G4MagIntegratorStepper; class G4ChordFinder; @@ -27,6 +27,7 @@ class remollGlobalField : public G4MagneticField { void AddNewField(G4String& name); + void SetInterpolationType(const G4String& name, const G4String& type); void SetZOffset(const G4String& name, G4double offset); void SetFieldScale(const G4String& name, G4double scale); void SetMagnetCurrent(const G4String& name, G4double current); @@ -103,8 +104,16 @@ class remollGlobalField : public G4MagneticField { remollMagneticField* GetFieldByName(const G4String& name) const; - G4GenericMessenger* fMessenger; - G4GenericMessenger* fGlobalFieldMessenger; + G4GenericMessenger fMessenger{ + this, + "/remoll/", + "Remoll properties" + }; + G4GenericMessenger fGlobalFieldMessenger{ + this, + "/remoll/field/", + "Remoll global field properties" + }; G4int fVerboseLevel; diff --git a/include/remollIO.hh b/include/remollIO.hh index 50be0ed26..8480781be 100644 --- a/include/remollIO.hh +++ b/include/remollIO.hh @@ -12,6 +12,7 @@ #include "remollSystemOfUnits.hh" #include "G4String.hh" +#include "G4GenericMessenger.hh" #include #include @@ -20,8 +21,6 @@ class TFile; class TTree; -class G4GenericMessenger; - class remollGenericDetectorHit; class remollGenericDetectorSum; class remollEvent; @@ -62,10 +61,10 @@ class remollSeed_t: public TObject { // Save function for use in ROOT tree int Save() const { std::stringstream name; - name << "run" << fRunNo << "evt" << fEvtNo << ".rndm"; + name << "run" << fRunNo << "evt" << fEvtNo << ".state"; std::ofstream file(name.str()); file << fSeed; - return fSeed.Length(); + return 1; }; ClassDef(remollSeed_t,1); }; @@ -75,13 +74,13 @@ class remollIO { // Singleton pointer static remollIO* gInstance; // Private constructor - remollIO(); + remollIO(const G4String& outputfile); public: // Public destructor virtual ~remollIO(); // Static instance getter - static remollIO* GetInstance(); + static remollIO* GetInstance(const G4String& outputfile = "remollout.root"); void SetFilename(const G4String& name) { fFilename = name; } G4String GetFilename() const { return fFilename; } @@ -116,7 +115,7 @@ class remollIO { TFile *fFile; TTree *fTree; - G4GenericMessenger* fMessenger; + G4GenericMessenger fMessenger{this,"/remoll/","Remoll properties"}; G4String fFilename; diff --git a/include/remollMagneticField.hh b/include/remollMagneticField.hh index b4977ab4d..31a0af0f8 100644 --- a/include/remollMagneticField.hh +++ b/include/remollMagneticField.hh @@ -14,7 +14,7 @@ */ class remollMagneticField : public G4MagneticField { - /*! + /*! * Moller spectrometer magnetic field class * * Use trilinear interpolation in cylindrical coordinates @@ -36,26 +36,28 @@ class remollMagneticField : public G4MagneticField { * */ + private: + + enum EInterpolationType {kLinear, kCubic}; + public: - remollMagneticField( G4String ); - virtual ~remollMagneticField(); - void GetFieldValue(const G4double Point[4], G4double *Bfield) const; + remollMagneticField(const G4String&); + virtual ~remollMagneticField() { }; - void InitializeGrid(); - void ReadFieldMap(); + void AddFieldValue(const G4double point[4], G4double *field) const; + void GetFieldValue(const G4double point[4], G4double *field) const; - void SetFieldScale(G4double s); - void SetMagnetCurrent(G4double s); + void SetFieldScale(G4double scale) { fFieldScale = scale; } + void SetRefCurrent(G4double current) { fRefCurrent = current; } + void SetCurrent(G4double current) { SetFieldScale(current/fRefCurrent); } - void SetZoffset(G4double z){ fZoffset= z; } + void SetZoffset(G4double z) { fZoffset = z; } - G4String GetName(); + const G4String& GetName() const { return fName; } enum Coord_t { kR, kPhi, kZ }; - G4bool IsInit(){ return fInit; } - G4bool IsInBoundingBox(const G4double* p) const { if (p[2] - fZoffset < fMin[kZ] || p[2] - fZoffset > fMax[kZ]) return false; if (p[0] < -fMax[kR] || p[0] > fMax[kR]) return false; @@ -64,10 +66,11 @@ class remollMagneticField : public G4MagneticField { } private: + G4String fName; G4String fFilename; - G4int fN[__NDIM]; - G4double fMin[__NDIM], fMax[__NDIM]; + size_t fN[__NDIM]; + G4double fUnit[__NDIM], fMin[__NDIM], fMax[__NDIM], fStep[__NDIM]; G4double fFileMin[__NDIM], fFileMax[__NDIM]; G4int fNxtant; // Number of *tants (septants, or whatever) @@ -80,9 +83,68 @@ class remollMagneticField : public G4MagneticField { G4double fZMapOffset, fPhiMapOffset; G4double fFieldScale; // Scale overall field by this amount - G4double fMagCurrent0; // Scale overall field by this amount + G4double fRefCurrent; // Reference current for magnetic field + + private: - G4bool fInit; + EInterpolationType fInterpolationType; + + public: + + void SetInterpolationType(EInterpolationType type) { + fInterpolationType = type; + } + void SetInterpolationType(const G4String& type) { + if (type == "linear") SetInterpolationType(kLinear); + if (type == "cubic") SetInterpolationType(kCubic); + } + EInterpolationType GetInterpolationType() const { + return fInterpolationType; + } + + private: + + static const char kLinearMap[8][3]; + static const char kCubicMap[64][3]; + + double _linearInterpolate(const double p[2 << 0], double x) const { + return p[0] + x * (p[1] - p[0]); + } + double _bilinearInterpolate(const double p[2 << 1], const double x[2]) const { + double c[2]; + c[0] = _linearInterpolate(&(p[0]), x[0]); + c[1] = _linearInterpolate(&(p[2]), x[0]); + return _linearInterpolate(c, x[1]); + } + double _trilinearInterpolate(const double p[2 << 2], const double x[3]) const { + double c[2]; + c[0] = _bilinearInterpolate(&(p[0]), &(x[0])); + c[1] = _bilinearInterpolate(&(p[4]), &(x[0])); + return _linearInterpolate(c, x[2]); + } + + double _cubicInterpolate(const double p[4 << 0], double x) const { + return p[1] + + 0.5 * x * (p[2] - p[0] + + x * (2. * p[0] - 5. * p[1] + 4. * p[2] - p[3] + + x * (3. * (p[1] - p[2]) + p[3] - p[0]))); + } + double _bicubicInterpolate(const double p[4 << 1], const double x[2]) const { + double c[4]; + c[0] = _cubicInterpolate(&(p[0]), x[1]); + c[1] = _cubicInterpolate(&(p[4]), x[1]); + c[2] = _cubicInterpolate(&(p[8]), x[1]); + c[3] = _cubicInterpolate(&(p[12]), x[1]); + return _cubicInterpolate(c, x[0]); + } + double _tricubicInterpolate(const double p[4 << 2], const double x[3]) const { + double c[4]; + c[0] = _bicubicInterpolate(&(p[0]), &(x[1])); + c[1] = _bicubicInterpolate(&(p[16]), &(x[1])); + c[2] = _bicubicInterpolate(&(p[32]), &(x[1])); + c[3] = _bicubicInterpolate(&(p[48]), &(x[1])); + return _cubicInterpolate(c, x[0]); + } }; diff --git a/include/remollMultScatt.hh b/include/remollMultScatt.hh index ddb5b4bd4..c242f5f14 100644 --- a/include/remollMultScatt.hh +++ b/include/remollMultScatt.hh @@ -59,48 +59,46 @@ ------------------------------------------------- */ -#define MAT_MAX 50 +#include +#include class remollMultScatt { public: remollMultScatt(); - remollMultScatt( double p, double t, double A, double Z ); - remollMultScatt( double p, int nmat, double t[], double A[], double Z[] ); + remollMultScatt(double p, const std::tuple& m); + remollMultScatt(double p, const std::vector>& m); - void Init( double p, double t, double A, double Z ); - void Init( double p, int nmat, double t[], double A[], double Z[] ); + void Init(double p, const std::tuple& m); + void Init(double p, const std::vector>& m); virtual ~remollMultScatt() {;} double J0(double x); double CalcMSDistPlane( double theta); - double CalcMSDistPlane( double theta, double p, int, double t[], double A[], double Z[] ); - double CalcMSDistPlane( double theta, double p, double t, double A, double Z ); + double CalcMSDistPlane( double theta, double p, const std::vector>& m); + double CalcMSDistPlane( double theta, double p, const std::tuple& m); - double CalcMSDist( double theta); - double CalcMSDist( double theta, double p, int, double t[], double A[], double Z[] ); - double CalcMSDist( double theta, double p, double t, double A, double Z ); + double CalcMSDist(double theta); + double CalcMSDist(double theta, double p, const std::vector>& m); + double CalcMSDist(double theta, double p, const std::tuple& m); double GenerateMS(); - double GenerateMS( double p, double t, double A, double Z ); - double GenerateMS( double p, int nmat, double t[], double A[], double Z[] ); + double GenerateMS(double p, const std::tuple& m); + double GenerateMS(double p, const std::vector>& m); double GenerateMSPlane(); - double GenerateMSPlane( double p, double t, double A, double Z ); - double GenerateMSPlane( double p, int nmat, double t[], double A[], double Z[] ); + double GenerateMSPlane(double p, const std::tuple& m); + double GenerateMSPlane(double p, const std::vector>& m); - double GetPDGTh(){ return fthpdg; } + double GetPDGTh() const { return fthpdg; } private: bool fInit, fReturnZero; double fErf2sig; - int fNmat; double fp; - double ft[MAT_MAX]; - double fA[MAT_MAX]; - double fZ[MAT_MAX]; + std::vector> fm; double fth; double fthpdg; diff --git a/include/remollParallelConstruction.hh b/include/remollParallelConstruction.hh index 696183795..287482a8c 100644 --- a/include/remollParallelConstruction.hh +++ b/include/remollParallelConstruction.hh @@ -2,11 +2,13 @@ #define __REMOLLPARALLELCONSTRUCTION_HH 1 #include +#include +#include + +#include "remollSearchPath.hh" class G4LogicalVolume; class G4VPhysicalVolume; -class G4GDMLParser; -class G4GenericMessenger; // /// A parallel world construction class @@ -30,6 +32,7 @@ class remollParallelConstruction : public G4VUserParallelWorld G4String fGDMLFile; void SetGDMLFile(G4String gdmlfile) { + gdmlfile = remollSearchPath::resolve(gdmlfile); size_t i = gdmlfile.rfind('/'); if (i != std::string::npos) { fGDMLPath = gdmlfile.substr(0,i); @@ -37,14 +40,17 @@ class remollParallelConstruction : public G4VUserParallelWorld fGDMLFile = gdmlfile.substr(i + 1); } - G4GDMLParser *fGDMLParser; + G4GDMLParser fGDMLParser; G4bool fGDMLValidate; G4bool fGDMLOverlapCheck; G4int fVerboseLevel; - G4GenericMessenger* fParallelMessenger; + G4GenericMessenger fParallelMessenger{ + this, + "/remoll/parallel/", + "Remoll parallel geometry properties"}; G4VPhysicalVolume* fWorldVolume; G4String fWorldName; diff --git a/include/remollPhysicsList.hh b/include/remollPhysicsList.hh index c39363811..8180b2aaa 100644 --- a/include/remollPhysicsList.hh +++ b/include/remollPhysicsList.hh @@ -2,8 +2,8 @@ #define remollPhysicsList_h 1 #include "G4VModularPhysicsList.hh" +#include "G4GenericMessenger.hh" -class G4GenericMessenger; class G4VPhysicsConstructor; class remollPhysicsList: public G4VModularPhysicsList @@ -55,11 +55,22 @@ class remollPhysicsList: public G4VModularPhysicsList protected: // Generic messenger as protected to be used in derived classes - G4GenericMessenger* fPhysListMessenger; - G4GenericMessenger* fOpticalMessenger; - G4GenericMessenger* fParallelMessenger; - G4GenericMessenger* fStepLimiterMessenger; - G4GenericMessenger* fBaseMessenger; + G4GenericMessenger fPhysListMessenger{ + this, + "/remoll/physlist/", + "Remoll physics list properties"}; + G4GenericMessenger fOpticalMessenger{ + this, + "/remoll/physlist/optical/", + "Remoll optical physics properties"}; + G4GenericMessenger fParallelMessenger{ + this, + "/remoll/physlist/parallel/", + "Remoll parallel physics properties"}; + G4GenericMessenger fStepLimiterMessenger{ + this, + "/remoll/physlist/steplimiter/", + "Remoll step limiter properties"}; }; #endif diff --git a/include/remollPrimaryGeneratorAction.hh b/include/remollPrimaryGeneratorAction.hh index 8b61e7224..cc8b121f0 100644 --- a/include/remollPrimaryGeneratorAction.hh +++ b/include/remollPrimaryGeneratorAction.hh @@ -1,16 +1,18 @@ #ifndef remollPrimaryGeneratorAction_h #define remollPrimaryGeneratorAction_h 1 +#include "remollBeamTarget.hh" + #include "G4VUserPrimaryGeneratorAction.hh" #include "G4VPrimaryGenerator.hh" +#include "G4GenericMessenger.hh" #include "G4String.hh" #include +#include -class G4GenericMessenger; class G4ParticleGun; class G4Event; -class remollBeamTarget; class remollVEventGen; class remollEvent; @@ -28,23 +30,22 @@ class remollPrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction void SetGenerator(G4String&); private: - std::map fEvGenMap; - remollVEventGen *fEventGen; + std::map> fEvGenMap; + std::shared_ptr fEventGen; G4String fEventGenName; - std::map fPriGenMap; - G4VPrimaryGenerator *fPriGen; + std::map> fPriGenMap; + std::shared_ptr fPriGen; G4String fPriGenName; G4ParticleGun* fParticleGun; - remollBeamTarget *fBeamTarg; + remollBeamTarget fBeamTarg; remollEvent *fEvent; - G4GenericMessenger* fMessenger; - G4GenericMessenger* fEvGenMessenger; + G4GenericMessenger fEvGenMessenger{this,"/remoll/evgen/","Remoll event generator properties"}; G4double fEffCrossSection; }; diff --git a/include/remollRunAction.hh b/include/remollRunAction.hh index c1b1dd1a3..4e3b70de4 100644 --- a/include/remollRunAction.hh +++ b/include/remollRunAction.hh @@ -2,17 +2,17 @@ #define remollRunAction_h 1 #include "globals.hh" +#include "G4GenericMessenger.hh" #include "G4UserRunAction.hh" +#include "G4Timer.hh" -class G4GenericMessenger; -class G4Timer; class G4Run; class remollRunAction : public G4UserRunAction { public: remollRunAction(); - virtual ~remollRunAction(); + virtual ~remollRunAction() = default; public: G4Run* GenerateRun(); @@ -23,11 +23,15 @@ class remollRunAction : public G4UserRunAction void UpdateSeed(const G4long seed); private: - G4GenericMessenger* fMessenger; - G4Timer* fTimer; + G4GenericMessenger fMessenger{ + this, + "/remoll/", + "Remoll properties"}; + + G4Timer fTimer; private: - G4int fInterval; + G4int fInterval{10}; public: void SetUpdateInterval(G4int interval) { fInterval = interval; }; }; diff --git a/include/remollRunData.hh b/include/remollRunData.hh index 3c87f01a0..03a10b777 100644 --- a/include/remollRunData.hh +++ b/include/remollRunData.hh @@ -15,52 +15,67 @@ * stream */ -class TGeoManager; - class remollRunData : public TObject { using TObject::Print; public: - remollRunData(); - virtual ~remollRunData(); + remollRunData() { }; + virtual ~remollRunData() { }; - unsigned long long int GetNthrown(){ return fNthrown; } - void SetNthrown(unsigned long long int n){ fNthrown = n; } + void Init(); - void Init(); + void Print(); - void SetGenName(const char *n){ strcpy(fGenName, n); } - const char *GetGenName(){ return fGenName; } + private: + std::vector fMagData; + public: + void AddMagData(filedata_t d) { fMagData.push_back(d); } - void SetBeamE(double E){ fBeamE = E; } - void SetSeed(unsigned long int seed){ fSeed = seed; } + private: + remollTextFile fMacro; + public: + void SetMacroFile(const char *fn) { fMacro = remollTextFile(fn); } - void AddMagData(filedata_t d){fMagData.push_back(d);} - void SetMacroFile(const char *fn){ fMacro = remollTextFile(fn); } + private: + std::vector fGDMLFiles; + public: void AddGDMLFile(const char *fn); + remollTextFile GetGDMLFile(int i) const { return fGDMLFiles[i]; } void ClearGDMLFiles(){ fGDMLFiles.clear(); } - void RecreateGDML(const char *adir = NULL, bool clobber = false); - remollTextFile GetGDMLFile(int i){ return fGDMLFiles[i]; } - - void Print(); + private: + long int fNthrown; + public: + void SetNthrown(unsigned long long int n) { fNthrown = n; } + unsigned long long int GetNthrown() const { return fNthrown; } - TTimeStamp fRunTime; + private: + long int fSeed; + public: + void SetSeed(unsigned long int seed) { fSeed = seed; } + unsigned long long int GetSeed() const { return fSeed; } - long int fNthrown; - long int fSeed; - double fBeamE; - char fGenName[__RUNSTR_LEN]; + private: + std::string fGitInfo; + public: + std::string GetGitInfo() const { return fGitInfo; } - char fHostName[__RUNSTR_LEN]; - char fRunPath[__RUNSTR_LEN]; + private: + TTimeStamp fRunTime; + public: + TTimeStamp GetRunTime() const { return fRunTime; } - remollTextFile fMacro; - std::vector fGDMLFiles; + private: + std::string fRunPath; + public: + std::string GetRunPath() const { return fRunPath; } - std::vector fMagData; + private: + std::string fHostName; + public: + std::string GetHostName() const { return fHostName; } - ClassDef(remollRunData, 1); + ClassDef(remollRunData, 2); }; #endif//__REMOLLRUNDATA_HH diff --git a/include/remollSearchPath.hh b/include/remollSearchPath.hh new file mode 100644 index 000000000..f28c9b88f --- /dev/null +++ b/include/remollSearchPath.hh @@ -0,0 +1,60 @@ +#ifndef __REMOLLSEARCHPATH_HH +#define __REMOLLSEARCHPATH_HH + +/*! + -------------------------------------------------------------------------------------------- + remollSearchPath + + Header-only file to search for files inside + the remoll directory. + -------------------------------------------------------------------------------------------- +Usage: + remollSearchPath mySearchPath; + mySearchPath.add("macros"); //< Adds the macros directory to the list of directories the next line will search for gui.mac in + mySearchPath("gui.mac"); //< Returns the canonical path of gui.mac as a std::string + + The add() function by default adds CMAKE_INSTALL_PREFIX, CMAKE_INSTALL_FULL_DATADIR + and the current working directory to the list of directories the operator() will search in. + -------------------------------------------------------------------------------------------- +*/ + +#if defined(__cpp_lib_filesystem) +#include +namespace fs = std::filesystem; +#elif defined(__cpp_lib_experimental_filesystem) +#include +namespace fs = std::experimental::filesystem; +#elif defined(__USE_BOOST_FILESYSTEM) +#include +namespace fs = boost::filesystem; +#else +#define NO_FS_SUPPORT +#endif + +#include +#include + +#ifdef __APPLE__ +#include +#endif + +class remollSearchPath +{ +private: + static remollSearchPath* fInstance; + #ifndef NO_FS_SUPPORT + std::vector fSearchPath; + #endif + remollSearchPath(); + +public: + static remollSearchPath* getInstance(); + virtual ~remollSearchPath(); + void add(const std::string& path); + std::string operator() (const std::string& filename); + static std::string resolve(const std::string& filename) { + return remollSearchPath::getInstance()->operator()(filename); + } +}; + +#endif //__REMOLLSEARCHPATH_HH diff --git a/include/remollTrackingAction.hh b/include/remollTrackingAction.hh index 375d84ad4..e868cad05 100644 --- a/include/remollTrackingAction.hh +++ b/include/remollTrackingAction.hh @@ -3,23 +3,25 @@ // geant4 includes #include "G4Types.hh" +#include "G4GenericMessenger.hh" #include "G4UserTrackingAction.hh" -// forward declares -class G4GenericMessenger; - class remollTrackingAction : public G4UserTrackingAction { public: remollTrackingAction(); - virtual ~remollTrackingAction(); + virtual ~remollTrackingAction() = default; void PreUserTrackingAction(const G4Track* aTrack); void PostUserTrackingAction(const G4Track* aTrack); private: - G4GenericMessenger* fMessenger; - G4int fTrackingFlag; + G4GenericMessenger fMessenger{ + this, + "/remoll/tracking/", + "Remoll tracking properties"}; + + G4int fTrackingFlag{3}; }; #endif diff --git a/include/remollVEventGen.hh b/include/remollVEventGen.hh index d4eca30bc..03cf1f19e 100644 --- a/include/remollVEventGen.hh +++ b/include/remollVEventGen.hh @@ -7,6 +7,7 @@ #include "G4String.hh" #include "G4ThreeVector.hh" +#include "G4GenericMessenger.hh" /*! Generic base class for event generators @@ -23,7 +24,6 @@ */ class G4ParticleGun; -class G4GenericMessenger; class remollEvent; class remollBeamTarget; @@ -44,7 +44,9 @@ class remollVEventGen { fBeamTarg = bt; } - void SetSampType( SampType_t st ) { fSampType = st; } + void SetSamplingType(SamplingType_t type) { fSamplingType = type; } + SamplingType_t GetSamplingType() const { return fSamplingType; } + void SetDoMultScatt( G4bool multscatt ){ fApplyMultScatt = multscatt; } void SetEmin(double emin) { fE_min = emin; } @@ -90,14 +92,17 @@ public: protected: - SampType_t fSampType; + SamplingType_t fSamplingType; G4bool fApplyMultScatt; private: // Generic messenger as protected to be used in derived classes - G4GenericMessenger* fEvGenMessenger; + G4GenericMessenger fEvGenMessenger{ + this, + "/remoll/evgen/", + "Remoll event generator properties"}; protected: - G4GenericMessenger* fThisGenMessenger; + G4GenericMessenger fThisGenMessenger; }; diff --git a/include/remolltypes.hh b/include/remolltypes.hh index c7bb40f0e..f511e63b1 100644 --- a/include/remolltypes.hh +++ b/include/remolltypes.hh @@ -17,7 +17,11 @@ #include "TTimeStamp.h" -enum SampType_t { kNoTargetVolume, kActiveTargetVolume, kAllTargetVolumes }; +enum SamplingType_t { + kNoTargetVolume, + kActiveTargetVolume, + kAllTargetVolumes +}; struct filedata_t { char filename[__RUNSTR_LEN]; @@ -73,7 +77,7 @@ struct remollGenericDetectorHit_t { double px, py, pz; double pxl, pyl, pzl; double sx, sy, sz; - double p, e, m, k; + double p, e, m, k, beta; double vx, vy, vz; double edep; }; diff --git a/jobs/jlabSubmit1.py b/jobs/jlabSubmit1.py new file mode 100644 index 000000000..5f53cdefd --- /dev/null +++ b/jobs/jlabSubmit1.py @@ -0,0 +1,245 @@ +#!/usr/bin/python +from subprocess import call +import sys, os, time, tarfile + +def main(): + +#FIXME Update these + email = "vdoomra@jlab.org" + + config = "test_run" + + identifier = raw_input("Please enter the identifier: ") + + sourceDir = "/work/halla/moller12gev/vdoomra" + #outDir = "/lustre/expphy/volatile/halla/parity/chandan/sim_out/"+identifier + outDir = "/lustre/expphy/volatile/halla/moller12gev/vdoomra"+config + if not os.path.exists(outDir): + os.makedirs(outDir) + nrEv = 500 #900000 + nrStart= 1 + nrStopActual = 4 #60 + nrStop = nrStopActual+1 #60 + + print('Running ' + str(nrEv*(nrStop - nrStart)) + ' events...') + + #jobName=config + '_' + identifier + '_' + val + "mm" + '_%03dkEv'%(nrEv/1000) + jobName=config + '_' + identifier + '_%02dkEv'%(nrEv/1000) + + ###tar exec+geometry + make_tarfile(sourceDir,config,identifier) + + for jobNr in range(nrStart,nrStop): # repeat for jobNr jobs + print("Starting job setup for jobID: " + str(jobNr)) + + jobFullName = jobName + '_%03d'%jobNr + outDirFull=outDir+"/"+jobFullName + createMacFiles(config, outDirFull, sourceDir, nrEv, jobNr, identifier) + + ###copy tarfile + call(["cp",sourceDir+"/rad_analysis/default.tar.gz", + outDir+"/"+jobFullName+"/default.tar.gz"]) + + createXMLfile(sourceDir,outDir,jobName,nrStart,nrStop,email,identifier) + + print "All done for config ",config,"_",identifier," for #s between ",nrStart, " and ", nrStopActual + + +def createMacFiles(config,outDirFull,sourceDir,nrEv,jobNr,identifier): + + if not os.path.exists(outDirFull+"/log"): + os.makedirs(outDirFull+"/log") + + f=open(outDirFull+"/"+"runexample_"+identifier+".mac",'w') + f.write("/remoll/setgeofile geometry/mollerMother_merged.gdml\n") + f.write("/remoll/physlist/register QGSP_BERT_HP\n") + f.write("/remoll/physlist/parallel/enable\n") + f.write("/remoll/parallel/setfile geometry/mollerParallel.gdml\n") + f.write("/run/numberOfThreads 10\n") + f.write("/run/initialize\n") + f.write("/remoll/addfield map_directory/hybridJLAB.txt\n") + f.write("/remoll/addfield map_directory/upstreamJLAB_1.25.txt\n") + #f.write("/remoll/evgen/set moller\n") + f.write("/remoll/evgen/set beam\n") + #f.write("/remoll/evgen/set elastic\n") + #f.write("/remoll/oldras false\n") + f.write("/remoll/evgen/beam/origin 0 0 -7.5 m\n") + f.write("/remoll/evgen/beam/rasx 5 mm\n") + f.write("/remoll/evgen/beam/rasy 5 mm\n") + f.write("/remoll/evgen/beam/corrx 0.065\n") + f.write("/remoll/evgen/beam/corry 0.065\n") + #f.write("/remoll/beam_corrph 0.02134\n") + #f.write("/remoll/beam_corrth 0.02134\n") + f.write("/remoll/evgen/beam/rasrefz -4.5 m\n") + f.write("/remoll/beamene 11 GeV\n") + f.write("/remoll/beamcurr 70 microampere\n") + f.write("/remoll/SD/disable_all\n") + f.write("/remoll/SD/enable 28\n") + f.write("/remoll/SD/detect lowenergyneutral 28\n") + f.write("/remoll/SD/detect secondaries 28\n") + f.write("/remoll/SD/detect boundaryhits 28\n") + + f.write("/remoll/SD/enable 55\n") + f.write("/remoll/SD/detect lowenergyneutral 55\n") + f.write("/remoll/SD/detect secondaries 55\n") + f.write("/remoll/SD/detect boundaryhits 55\n") + + f.write("/remoll/SD/enable 56\n") + f.write("/remoll/SD/detect lowenergyneutral 56\n") + f.write("/remoll/SD/detect secondaries 56\n") + f.write("/remoll/SD/detect boundaryhits 56\n") + + f.write("/remoll/SD/enable 57\n") + f.write("/remoll/SD/detect lowenergyneutral 57\n") + f.write("/remoll/SD/detect secondaries 57\n") + f.write("/remoll/SD/detect boundaryhits 57\n") + + f.write("/remoll/SD/enable 58\n") + f.write("/remoll/SD/detect lowenergyneutral 58\n") + f.write("/remoll/SD/detect secondaries 58\n") + f.write("/remoll/SD/detect boundaryhits 58\n") + + #f.write("/remoll/SD/enable 3340\n") + #f.write("/remoll/SD/detect lowenergyneutral 3340\n") + #f.write("/remoll/SD/detect secondaries 3340\n") + #f.write("/remoll/SD/detect boundaryhits 3340\n") + # f.write("/remoll/SD/enable 95\n") + # f.write("/remoll/SD/detect lowenergyneutral 95\n") + # f.write("/remoll/SD/detect secondaries 95\n") + # f.write("/remoll/SD/detect boundaryhits 95\n") + # f.write("/remoll/SD/enable 55\n") + # f.write("/remoll/SD/detect lowenergyneutral 55\n") + # f.write("/remoll/SD/detect secondaries 55\n") + # f.write("/remoll/SD/enable 56\n") + # f.write("/remoll/SD/detect lowenergyneutral 56\n") + # f.write("/remoll/SD/detect secondaries 56\n") + # f.write("/remoll/SD/enable 3333\n") + # f.write("/remoll/SD/detect lowenergyneutral 3333\n") + # f.write("/remoll/SD/detect secondaries 3333\n") + # f.write("/remoll/SD/detect boundaryhits 3333\n") + # f.write("/remoll/SD/enable 3334\n") + # f.write("/remoll/SD/detect lowenergyneutral 3334\n") + # f.write("/remoll/SD/detect secondaries 3334\n") + # f.write("/remoll/SD/detect boundaryhits 3334\n") + # f.write("/remoll/SD/enable 3335\n") + # f.write("/remoll/SD/detect lowenergyneutral 3335\n") + # f.write("/remoll/SD/detect secondaries 3335\n") + # f.write("/remoll/SD/detect boundaryhits 3335\n") + # f.write("/remoll/SD/enable 3336\n") + # f.write("/remoll/SD/detect lowenergyneutral 3336\n") + # f.write("/remoll/SD/detect secondaries 3336\n") + # f.write("/remoll/SD/detect boundaryhits 3336\n") + # f.write("/remoll/SD/enable 3337\n") + # f.write("/remoll/SD/detect lowenergyneutral 3337\n") + # f.write("/remoll/SD/detect secondaries 3337\n") + # f.write("/remoll/SD/detect boundaryhits 3337\n") + # f.write("/remoll/SD/enable 3338\n") + # f.write("/remoll/SD/detect lowenergyneutral 3338\n") + # f.write("/remoll/SD/detect secondaries 3338\n") + # f.write("/remoll/SD/detect boundaryhits 3338\n") + # f.write("/remoll/SD/enable 3339\n") + # f.write("/remoll/SD/detect lowenergyneutral 3339\n") + # f.write("/remoll/SD/detect secondaries 3339\n") + # f.write("/remoll/SD/detect boundaryhits 3339\n") + #f.write("/remoll/SD/enable 96\n") + #f.write("/remoll/SD/detect lowenergyneutral 96\n") + #f.write("/remoll/SD/detect secondaries 96\n") + #f.write("/remoll/SD/enable 97\n") + #f.write("/remoll/SD/detect lowenergyneutral 97\n") + #f.write("/remoll/SD/detect secondaries 97\n") + #f.write("/remoll/kryptonite/volume logicUSTracker\n") + #f.write("/remoll/kryptonite/volume logicDSTracker\n") + #f.write("/remoll/kryptonite/volume logicWasher_12\n") + f.write("/remoll/kryptonite/enable\n") + f.write("/process/list\n") + f.write("/remoll/filename remollout.root\n") + f.write("/run/beamOn "+str(nrEv)+"\n") + f.close() + return 0 + +def createXMLfile(sourceDir,outDir,jobName,nrStart,nrStop,email,identifier): + + if not os.path.exists(sourceDir+"/rad_analysis/jobs"): + os.makedirs(sourceDir+"/rad_analysis/jobs") + + f=open(sourceDir+"/rad_analysis/jobs/"+jobName+".xml","w") + f.write("\n") + f.write(" \n") + f.write(" \n") + + f.write(" \n") +# f.write(" \n") +# f.write(" \n") + + f.write(" \n") + f.write(" \n") + f.write(" \n") + + f.write(" \n") + + for number in range(nrStart,nrStop): # repeat for nr jobs + idName= outDir+"/"+jobName+'_%03d'%(number) + rootfile= outDir+"/remollout_"+identifier+'%d'%(number) + f.write(" \n") + f.write(" \n") + f.write(" \n") + + # f.write(" \n") + f.write(" \n") + f.write(" \n") + f.write(" \n") + f.write(" \n\n") + + f.write("\n") + f.close() + return 0 + +def make_tarfile(sourceDir,config,ident): + print "making geometry tarball" + if os.path.isfile(sourceDir+"/rad_analysis/default.tar.gz"): + os.remove(sourceDir+"/rad_analysis/default.tar.gz") + tar = tarfile.open(sourceDir+"/rad_analysis/default.tar.gz","w:gz") + tar.add(sourceDir+"/remoll/build/remoll",arcname="remoll") + tar.add(sourceDir+"/remoll/build/libremoll_rdict.pcm",arcname="libremoll_rdict.pcm") + tar.add(sourceDir+"/remoll/build/libremoll.so",arcname="libremoll.so") + #tar.add(sourceDir+"/rad_analysis/pruneTree",arcname="pruneTree") + #tar.add(sourceDir+"/macros/runexample_"+ident+".mac",arcname="runexample_"+ident+".mac") + #runexample overwrite could crash + tar.add(sourceDir+"/remoll/map_directory",arcname="map_directory") + #tar.add(sourceDir+"/remoll/geometry",arcname="geometry") + #tar.add(sourceDir+"/remoll/geometry/schema",arcname="geometry/schema") + tar.add(sourceDir+"/remoll/geometry/materials.xml",arcname="geometry/materials.xml") + tar.add(sourceDir+"/remoll/geometry/matrices.xml",arcname="geometry/matrices.xml") + tar.add(sourceDir+"/remoll/geometry/positions.xml",arcname="geometry/positions.xml") + tar.add(sourceDir+"/remoll/geometry/solids/world.xml",arcname="geometry/solids/world.xml") + tar.add(sourceDir+"/remoll/geometry/mollerParallel.gdml" ,arcname="geometry/mollerParallel.gdml") + tar.add(sourceDir+"/remoll/geometry/mollerMother_merged.gdml" ,arcname="geometry/mollerMother_merged.gdml") + tar.add(sourceDir+"/remoll/geometry/target/subTargetRegion.gdml" ,arcname="geometry/target/subTargetRegion.gdml") + tar.add(sourceDir+"/remoll/geometry/hall/hallDaughter_merged.gdml" ,arcname="geometry/hall/hallDaughter_merged.gdml") + tar.add(sourceDir+"/remoll/geometry/hall/hallDaughter_dump.gdml" ,arcname="geometry/hall/hallDaughter_dump.gdml") + tar.add(sourceDir+"/remoll/geometry/hall/subDumpDiffuser.gdml" ,arcname="geometry/hall/subDumpDiffuser.gdml") + tar.add(sourceDir+"/remoll/geometry/upstream/upstreamDaughter_merged.gdml" ,arcname="geometry/upstream/upstreamDaughter_merged.gdml") + tar.add(sourceDir+"/remoll/geometry/upstream/upstreamToroid.gdml" ,arcname="geometry/upstream/upstreamToroid.gdml") + tar.add(sourceDir+"/remoll/geometry/upstream/upstreamBeampipe.gdml" ,arcname="geometry/upstream/upstreamBeampipe.gdml") + tar.add(sourceDir+"/remoll/geometry/hybrid/hybridToroid.gdml" ,arcname="geometry/hybrid/hybridToroid.gdml") + tar.add(sourceDir+"/remoll/geometry/hybrid/hybridDaughter_merged.gdml" ,arcname="geometry/hybrid/hybridDaughter_merged.gdml") + tar.add(sourceDir+"/remoll/geometry/huts/lefthut.gdml" ,arcname="geometry/huts/lefthut.gdml") + tar.add(sourceDir+"/remoll/geometry/huts/righthut.gdml" ,arcname="geometry/huts/righthut.gdml") + tar.add(sourceDir+"/remoll/geometry/showermax/showerMaxGen.gdml" ,arcname="geometry/showermax/showerMaxGen.gdml") + tar.add(sourceDir+"/remoll/geometry/pion/pionDetectorSystem.gdml" ,arcname="geometry/pion/pionDetectorSystem.gdml") + tar.add(sourceDir+"/remoll/geometry/beampipe/downstream/beampipeDSMother.gdml" ,arcname="geometry/beampipe/downstream/beampipeDSMother.gdml") + + tar.close() + +if __name__ == '__main__': + main() + diff --git a/macros/compare_with_cad.mac b/macros/compare_with_cad.mac new file mode 100644 index 000000000..d2104766a --- /dev/null +++ b/macros/compare_with_cad.mac @@ -0,0 +1,50 @@ +/remoll/geometry/setfile geometry/mollerMother.gdml +/remoll/parallel/setfile geometry/mollerParallel.gdml + +/run/initialize + +/control/execute macros/load_meshes.mac + +/control/execute vis/SQt.mac + +/control/execute vis/section_xz.mac +/vis/viewer/zoomTo 40 +/vis/viewer/set/targetPoint 0 0 -10 m +/vis/ogl/export section_xz_-10.svg +/vis/viewer/set/targetPoint 0 0 -5 m +/vis/ogl/export section_xz_-05.svg +/vis/viewer/set/targetPoint 0 0 0 m +/vis/ogl/export section_xz_00.svg +/vis/viewer/set/targetPoint 0 0 5 m +/vis/ogl/export section_xz_05.svg +/vis/viewer/set/targetPoint 0 0 10 m +/vis/ogl/export section_xz_10.svg +/vis/viewer/set/targetPoint 0 0 15 m +/vis/ogl/export section_xz_15.svg +/vis/viewer/set/targetPoint 0 0 20 m +/vis/ogl/export section_xz_20.svg +/vis/viewer/set/targetPoint 0 0 25 m +/vis/ogl/export section_xz_25.svg +/vis/viewer/set/targetPoint 0 0 30 m +/vis/ogl/export section_xz_30.svg + +/control/execute vis/section_yz.mac +/vis/viewer/zoomTo 40 +/vis/viewer/set/targetPoint 0 0 -10 m +/vis/ogl/export section_yz_-10.svg +/vis/viewer/set/targetPoint 0 0 -5 m +/vis/ogl/export section_yz_-05.svg +/vis/viewer/set/targetPoint 0 0 0 m +/vis/ogl/export section_yz_00.svg +/vis/viewer/set/targetPoint 0 0 5 m +/vis/ogl/export section_yz_05.svg +/vis/viewer/set/targetPoint 0 0 10 m +/vis/ogl/export section_yz_10.svg +/vis/viewer/set/targetPoint 0 0 15 m +/vis/ogl/export section_yz_15.svg +/vis/viewer/set/targetPoint 0 0 20 m +/vis/ogl/export section_yz_20.svg +/vis/viewer/set/targetPoint 0 0 25 m +/vis/ogl/export section_yz_25.svg +/vis/viewer/set/targetPoint 0 0 30 m +/vis/ogl/export section_yz_30.svg diff --git a/macros/envelope_data.mac b/macros/envelope_data.mac index b1c5a725e..557be7035 100644 --- a/macros/envelope_data.mac +++ b/macros/envelope_data.mac @@ -4,7 +4,7 @@ /tracking/storeTrajectory 1 # This must be called before initialize -/remoll/setgeofile geometry/mollerMother_merged.gdml +/remoll/setgeofile geometry/mollerMother.gdml # This must be explicitly called /run/initialize diff --git a/macros/gui.mac b/macros/gui.mac index f88854805..a2ce51468 100644 --- a/macros/gui.mac +++ b/macros/gui.mac @@ -22,15 +22,12 @@ # # Geometry menu : /gui/addMenu geom "1. Geometry" -/gui/addButton geom geometry/mollerMother.gdml "/remoll/geometry/setfile geometry/mollerMother.gdml" -/gui/addButton geom geometry/mollerMother_dump.gdml "/remoll/geometry/setfile geometry/mollerMother_dump.gdml" -/gui/addButton geom geometry/mollerMother_empty.gdml "/remoll/geometry/setfile geometry/mollerMother_empty.gdml" -/gui/addButton geom geometry/mollerMother_merged.gdml "/remoll/geometry/setfile geometry/mollerMother_merged.gdml" -/gui/addButton geom geometry/mollerMother_trackingOnly.gdml "/remoll/geometry/setfile geometry/mollerMother_trackingOnly.gdml" -/gui/addButton geom geometry/mollerMother_showerMaxOnly.gdml "/remoll/geometry/setfile geometry/mollerMother_showerMaxOnly.gdml" -/gui/addButton geom geometry/pionDetectorLucite.gdml "/remoll/geometry/setfile geometry/pion/Lucite/pionDetectorLucite_world.gdml" -/gui/addButton geom geometry/showerMaxDetector.gdml "/remoll/geometry/setfile geometry/showerMaxDetector.gdml" -/gui/addButton geom geometry/mollerParallel.gdml "/remoll/parallel/setfile geometry/mollerParallel.gdml" +/gui/addButton geom "MOLLER Parallel" "/remoll/parallel/setfile geometry/mollerParallel.gdml" +/gui/addButton geom "MOLLER Experiment" "/remoll/geometry/setfile geometry/mollerMother.gdml" +/gui/addButton geom "MOLLER Experiment (w. dets)" "/remoll/geometry/setfile geometry/mollerMother_parametrized.gdml" +/gui/addButton geom "Only pion system" "/remoll/geometry/setfile geometry/pion/Lucite/pionDetectorLucite_world.gdml" +/gui/addButton geom "Only showermax" "/remoll/geometry/setfile geometry/showerMaxDetector.gdml" +/gui/addButton geom "No parallel" "/remoll/parallel/setfile " # # Initialize menu : /gui/addMenu phys "2. Physics" @@ -54,35 +51,48 @@ # # Viewer menu : /gui/addMenu view "4. Viewer" -#/gui/addButton view "My viewer" "/control/execute vis/myVis.mac" -#/gui/addButton view "OIX viewer" "/control/execute vis/OIX.mac" -#/gui/addButton view "X viewer" "/control/execute vis/X.mac" /gui/addButton view "Qt viewer (immediate)" "/control/execute vis/IQt.mac" -/gui/addButton view "Qt viewer (stored)" "/control/execute vis/SQt.mac" -/gui/addButton view "Draw real world" "/vis/drawVolume world" -/gui/addButton view "Draw all worlds" "/vis/drawVolume worlds" -/gui/addButton view "Set style solid" "/vis/viewer/set/style s" -/gui/addButton view "Set style wire" "/vis/viewer/set/style w" +/gui/addButton view "Qt viewer (stored)" "/control/execute vis/SQt.mac" +/gui/addButton view "Display limit 1M" "/vis/ogl/set/displayListLimit 1000000" +/gui/addButton view "Load vis settings" "/control/execute vis/vis.mac" +/gui/addButton view "Load cutaway settings" "/control/execute vis/cutaway.mac" +/gui/addButton view "Clear cutaway planes" "/vis/viewer/clearCutawayPlanes" +/gui/addButton view "YZ section view" "/control/execute vis/section_yz.mac" +/gui/addButton view "XZ section view" "/control/execute vis/section_xz.mac" +/gui/addButton view "Draw real world" "/vis/drawVolume world" +/gui/addButton view "Draw all worlds" "/vis/drawVolume worlds" +/gui/addButton view "Set style surface" "/vis/viewer/set/style surface" +/gui/addButton view "Set style wireframe" "/vis/viewer/set/style wireframe" /gui/addButton view "Hide tracks behind objects" "/vis/viewer/set/hiddenMarker true" /gui/addButton view "Show tracks behind objects" "/vis/viewer/set/hiddenMarker false" -/gui/addButton view "Front view" "/vis/viewer/set/viewpointThetaPhi 180 0 deg" -/gui/addButton view "Back view" "/vis/viewer/set/viewpointThetaPhi 0 0 deg" -/gui/addButton view "Side 1 view" "/vis/viewer/set/viewpointThetaPhi 90 180 deg" -/gui/addButton view "Side 2 view" "/vis/viewer/set/viewpointThetaPhi -90 180 deg" -/gui/addButton view "Top view" "/vis/viewer/set/viewpointThetaPhi 90 90 deg" -/gui/addButton view "Cutaway" "/control/execute vis/cutaway.mac" -/gui/addButton view "Mag fields" "/vis/scene/add/magneticField 50" -/gui/addButton view "Update view" "/vis/viewer/update" -/gui/addButton view "Update scene" "/vis/scene/notifyHandlers" -/gui/addButton view "Reset scene" "/control/execute vis/vis.mac" +/gui/addButton view "Hide individual steps" "/vis/modeling/trajectories/MollerStyle/default/setDrawStepPts false" +/gui/addButton view "Show individual steps" "/vis/modeling/trajectories/MollerStyle/default/setDrawStepPts true" +/gui/addButton view "Front view (+Z)" "/vis/viewer/set/viewpointThetaPhi 180 0 deg" +/gui/addButton view "Back view (-Z)" "/vis/viewer/set/viewpointThetaPhi 0 0 deg" +/gui/addButton view "Side 1 view (+X)" "/vis/viewer/set/viewpointThetaPhi 90 180 deg" +/gui/addButton view "Side 2 view (-X)" "/vis/viewer/set/viewpointThetaPhi -90 180 deg" +/gui/addButton view "Top view (-Y)" "/vis/viewer/set/viewpointThetaPhi 90 90 deg" +/gui/addButton view "Mag fields" "/vis/scene/add/magneticField 50" +/gui/addButton view "Refresh viewer (retraverse graphical data)" "/vis/viewer/refresh" +/gui/addButton view "Update viewer (interaction or end-of-file)" "/vis/viewer/update" +/gui/addButton view "Flush viewer (= refresh + update)" "/vis/viewer/flush" +/gui/addButton view "Update scene" "/vis/scene/notifyHandlers" +# +# Filter menu : +/gui/addMenu filter "5. Filters" +/gui/addButton filter "HideAllGammas ON" "/vis/filtering/trajectories/HideAllGammas/active 1" +/gui/addButton filter "HideAllGammas OFF" "/vis/filtering/trajectories/HideAllGammas/active 0" +/gui/addButton filter "ShowOnlyCharged ON" "/vis/filtering/trajectories/ShowOnlyCharged/active 1" +/gui/addButton filter "ShowOnlyCharged OFF" "/vis/filtering/trajectories/ShowOnlyCharged/active 0" +/gui/addButton filter "ShowOnlyPionDetectorHits ON" "/vis/filtering/trajectories/ShowOnlyPionDetectorHits/active 1" +/gui/addButton filter "ShowOnlyPionDetectorHits OFF" "/vis/filtering/trajectories/ShowOnlyPionDetectorHits/active 0" # # Run menu : -/gui/addMenu field "5. Fields" -/gui/addButton field "blockyHybrid_rm_3.0" "/remoll/addfield map_directory/blockyHybrid_rm_3.0.txt" -/gui/addButton field "blockyUpstream_rm_1.1" "/remoll/addfield map_directory/blockyUpstream_rm_1.1.txt" +/gui/addMenu field "6. Fields" +/gui/addButton field "Load fieldmaps" "/control/execute macros/load_magnetic_fieldmaps.mac" # # Generator menu : -/gui/addMenu gen "6. Generator" +/gui/addMenu gen "7. Generator" /gui/addButton gen "Moller" "/remoll/evgen/set moller" /gui/addButton gen "Beam" "/remoll/evgen/set beam" /gui/addButton gen "Beam/pi-" "/remoll/evgen/beam/partName pi-" @@ -93,7 +103,8 @@ # # Run menu : -/gui/addMenu run "7. Run" +/gui/addMenu run "8. Run" +/gui/addButton run "Load from files" "/random/resetEngineFromEachEvent 1" /gui/addButton run "beamOn 1" "/run/beamOn 1" /gui/addButton run "beamOn 2" "/run/beamOn 2" /gui/addButton run "beamOn 5" "/run/beamOn 5" diff --git a/macros/hepmc/ee_ee_hepmc.mac b/macros/hepmc/ee_ee_hepmc.mac index d761c4670..71a0e99f0 100644 --- a/macros/hepmc/ee_ee_hepmc.mac +++ b/macros/hepmc/ee_ee_hepmc.mac @@ -1,4 +1,4 @@ -/remoll/geometry/setfile geometry/mollerMother_merged.gdml +/remoll/geometry/setfile geometry/mollerMother.gdml /remoll/parallel/setfile geometry/mollerParallel.gdml /remoll/physlist/parallel/enable diff --git a/macros/hepmc/ee_ee_moller.mac b/macros/hepmc/ee_ee_moller.mac index e9e065674..cbcabdd2a 100644 --- a/macros/hepmc/ee_ee_moller.mac +++ b/macros/hepmc/ee_ee_moller.mac @@ -1,4 +1,4 @@ -/remoll/geometry/setfile geometry/mollerMother_merged.gdml +/remoll/geometry/setfile geometry/mollerMother.gdml /remoll/parallel/setfile geometry/mollerParallel.gdml /remoll/physlist/parallel/enable diff --git a/macros/hepmc/ep_ep_elastic.mac b/macros/hepmc/ep_ep_elastic.mac index 6297fa8b3..624692857 100644 --- a/macros/hepmc/ep_ep_elastic.mac +++ b/macros/hepmc/ep_ep_elastic.mac @@ -1,4 +1,4 @@ -/remoll/geometry/setfile geometry/mollerMother_merged.gdml +/remoll/geometry/setfile geometry/mollerMother.gdml /remoll/parallel/setfile geometry/mollerParallel.gdml /remoll/physlist/parallel/enable diff --git a/macros/hepmc/ep_ep_hepmc.mac b/macros/hepmc/ep_ep_hepmc.mac index 913fc56ca..44197bcb4 100644 --- a/macros/hepmc/ep_ep_hepmc.mac +++ b/macros/hepmc/ep_ep_hepmc.mac @@ -1,4 +1,4 @@ -/remoll/geometry/setfile geometry/mollerMother_merged.gdml +/remoll/geometry/setfile geometry/mollerMother.gdml /remoll/parallel/setfile geometry/mollerParallel.gdml /remoll/physlist/parallel/enable diff --git a/macros/initializeTF1Generator.mac b/macros/initializeTF1Generator.mac deleted file mode 100644 index 4ab005b3b..000000000 --- a/macros/initializeTF1Generator.mac +++ /dev/null @@ -1,62 +0,0 @@ -# File for creating the output files needed to use the TF1 generator for the first time. -# Once this macro is run the remollGenFunctions.root file can be reused for faster runtime. -# Run more events of the three generators for more accurate TF1 generator output. - -# store tracks -#/tracking/storeTrajectory 1 - -# This must be called before initialize -/remoll/setgeofile geometry/mollerMother_noShlds.gdml - -# This must be explicitly called -/run/initialize - -/remoll/addfield map_directory/blockyHybrid_rm_3.0.txt -/remoll/addfield map_directory/blockyUpstream_rm_1.1.txt - -#create moller output file -#/remoll/evgen/set moller -#/run/beamOn 0 -#/remoll/filename remollout_moller.root -#/run/beamOn 10000 - -#create elastic output file -#/remoll/evgen/set elastic -#/run/beamOn 0 -#/remoll/filename remollout_elastic.root -#/run/beamOn 100000 - -#create inelastic output file -/remoll/evgen/set inelastic -/run/beamOn 0 -/remoll/filename remollout_inelastic.root -/run/beamOn 100000 - - -#/remoll/scalefield map_directory/blockyHybrid_rm_3.0.txt 1.0 -#/remoll/magcurrent map_directory/blockyHybrid_rm_3.0.txt 1000.0 A - -# Raster and initial angle stuff -/remoll/oldras true -/remoll/rasx 5 mm -/remoll/rasy 5 mm - -/remoll/evgen/set TF1 -/run/beamOn 0 -/remoll/evgen/TF1/sector 0 -/remoll/evgen/TF1/scattType inelastic -/remoll/evgen/TF1/setFileFunction genDefault - -/remoll/beamene 11 GeV - -/remoll/beamcurr 85 microampere - -# Make interactions with W, Cu, and Pb -# realistic rather than pure absorbers -/control/execute macros/kryptonite.mac - -/process/list - -/remoll/filename remollout.root - -/run/beamOn 10000 diff --git a/macros/issues/issue179.mac b/macros/issues/issue179.mac index c3a316230..5c10ab729 100644 --- a/macros/issues/issue179.mac +++ b/macros/issues/issue179.mac @@ -1,4 +1,4 @@ -/remoll/setgeofile geometry/mollerMother_merged.gdml +/remoll/setgeofile geometry/mollerMother.gdml /run/initialize /remoll/addfield map_directory/blockyHybrid_rm_3.0.txt /remoll/addfield map_directory/blockyUpstream_rm_1.1.txt diff --git a/macros/issues/issue186_set1.mac b/macros/issues/issue186_set1.mac index 1fa6f0db6..0350941c1 100644 --- a/macros/issues/issue186_set1.mac +++ b/macros/issues/issue186_set1.mac @@ -1,4 +1,4 @@ -/remoll/setgeofile geometry/mollerMother_merged.gdml +/remoll/setgeofile geometry/mollerMother.gdml /run/initialize /remoll/addfield map_directory/blockyHybrid_rm_3.0.txt /remoll/addfield map_directory/blockyUpstream_rm_1.1.txt diff --git a/macros/issues/issue186_set2.mac b/macros/issues/issue186_set2.mac index 9d2b64f6d..00ecbf22a 100644 --- a/macros/issues/issue186_set2.mac +++ b/macros/issues/issue186_set2.mac @@ -1,4 +1,4 @@ -/remoll/setgeofile geometry/mollerMother_merged.gdml +/remoll/setgeofile geometry/mollerMother.gdml /run/initialize /remoll/addfield map_directory/blockyHybrid_rm_3.0.txt /remoll/addfield map_directory/blockyUpstream_rm_1.1.txt diff --git a/macros/issues/issue186_set3.mac b/macros/issues/issue186_set3.mac index 218991f96..d5f9bd118 100644 --- a/macros/issues/issue186_set3.mac +++ b/macros/issues/issue186_set3.mac @@ -1,4 +1,4 @@ -/remoll/setgeofile geometry/mollerMother_merged.gdml +/remoll/setgeofile geometry/mollerMother.gdml /run/initialize /remoll/addfield map_directory/blockyHybrid_rm_3.0.txt /remoll/addfield map_directory/blockyUpstream_rm_1.1.txt diff --git a/macros/issues/issue186_set4.mac b/macros/issues/issue186_set4.mac index 34d237524..6262d9965 100644 --- a/macros/issues/issue186_set4.mac +++ b/macros/issues/issue186_set4.mac @@ -1,4 +1,4 @@ -/remoll/setgeofile geometry/mollerMother_merged.gdml +/remoll/setgeofile geometry/mollerMother.gdml /run/initialize /remoll/addfield map_directory/blockyHybrid_rm_3.0.txt /remoll/addfield map_directory/blockyUpstream_rm_1.1.txt diff --git a/macros/issues/issue186_set5.mac b/macros/issues/issue186_set5.mac index 9cadfa933..be7c6aba1 100644 --- a/macros/issues/issue186_set5.mac +++ b/macros/issues/issue186_set5.mac @@ -1,4 +1,4 @@ -/remoll/setgeofile geometry/mollerMother_merged.gdml +/remoll/setgeofile geometry/mollerMother.gdml /run/initialize /remoll/addfield map_directory/blockyHybrid_rm_3.0.txt /remoll/addfield map_directory/blockyUpstream_rm_1.1.txt diff --git a/macros/load_magnetic_fieldmaps.mac b/macros/load_magnetic_fieldmaps.mac index f39b6cb4e..73fb40fb1 100644 --- a/macros/load_magnetic_fieldmaps.mac +++ b/macros/load_magnetic_fieldmaps.mac @@ -2,7 +2,7 @@ # # Instead of including magnetic field maps directly in your macros, # consider loading this macro with -# /control/execute macros/load_magnetic_field.mac +# /control/execute macros/load_magnetic_fieldmaps.mac -/remoll/addfield map_directory/segmentedJLAB_v2.txt -/remoll/addfield map_directory/upstreamJLAB_v2.txt +/remoll/addfield map_directory/V2U.1a.50cm.parallel.txt +/remoll/addfield map_directory/V2DSg.9.75cm.parallel.txt diff --git a/macros/load_mesh.mac b/macros/load_mesh.mac new file mode 100644 index 000000000..60a30e900 --- /dev/null +++ b/macros/load_mesh.mac @@ -0,0 +1,6 @@ +/control/echo {mesh} +/control/alias url https://hallaweb.jlab.org/12GeV/Moller/downloads/remoll/cad +/control/alias dir geometry/meshes +/control/shell mkdir -p {dir} +/control/shell wget -N -c -P {dir} {url}/{mesh} +/remoll/geometry/addmesh {dir}/{mesh} diff --git a/macros/load_meshes.mac b/macros/load_meshes.mac new file mode 100644 index 000000000..ec7e50f89 --- /dev/null +++ b/macros/load_meshes.mac @@ -0,0 +1,16 @@ +# This loads the small meshes +/control/foreach macros/load_mesh.mac mesh "JL0094043_small.stl JL0095703_small.stl JL0096597_small.stl JL0096636_small.stl JL0094866_small.stl JL0096772_small.stl JL0091832_small.stl JL0096533_small.stl JL0094773_small.stl JL0096752_small.stl JL0097012_small.stl JL0109771_small.stl" + +# Below are larger meshes (slow, needs memory) + +# JL0096676_small.stl: dump tunnel utilities +/control/foreach macros/load_mesh.mac mesh "JL0096676_small.stl" + +# JL0094629_small.stl: hybrid toroid +/control/foreach macros/load_mesh.mac mesh "JL0094629_small.stl" + +# Below are envelopes (slow, needs memory) + +# JL0100741_small.stl: envelopes +#/control/foreach macros/load_mesh.mac mesh "JL0100741_small.stl" + diff --git a/macros/pion/pionDetectorLucite.mac b/macros/pion/pionDetectorLucite.mac index eafc7c73d..fb2ca1aa6 100644 --- a/macros/pion/pionDetectorLucite.mac +++ b/macros/pion/pionDetectorLucite.mac @@ -2,6 +2,7 @@ # This must be called before initialize /remoll/geometry/setfile geometry/pion/Lucite/pionDetectorLucite_world.gdml +/remoll/parallel/setfile # Enable optical physics /remoll/physlist/parallel/disable diff --git a/macros/pion/pion_rates_at_lucite_plane.mac b/macros/pion/pion_rates_at_lucite_plane.mac index 586525039..42a0a5a0e 100644 --- a/macros/pion/pion_rates_at_lucite_plane.mac +++ b/macros/pion/pion_rates_at_lucite_plane.mac @@ -10,8 +10,7 @@ /run/initialize # Magnetic fields -/remoll/addfield map_directory/blockyHybrid_rm_3.0.txt -/remoll/addfield map_directory/blockyUpstream_rm_1.1.txt +/control/execute macros/load_magnetic_fieldmaps.mac # Make interactions with W, Cu, and Pb # realistic rather than pure absorbers @@ -42,7 +41,7 @@ /remoll/filename pion_rates_at_lucite_plane_evgen_pion_1k.root # Number of events -/run/beamOn 1000 +/run/beamOn 10000 ### 2. moller electrons @@ -62,44 +61,43 @@ /remoll/filename pion_rates_at_lucite_plane_evgen_moller_1k.root # Number of events -/run/beamOn 1000 +/run/beamOn 10000 ### 3. ep elastic electrons -/remoll/evgen/set elastic +#/remoll/evgen/set elastic +#/remoll/evgen/emin 0.0 MeV +#/remoll/evgen/emax 11.0 GeV -/remoll/evgen/emin 0.0 MeV -/remoll/evgen/emax 11.0 GeV - -/remoll/evgen/thmin 0.5 deg -/remoll/evgen/thmax 3.0 deg +#/remoll/evgen/thmin 0.5 deg +#/remoll/evgen/thmax 3.0 deg # Specify random number seed -/remoll/seed 1234 +#/remoll/seed 1234 # Filename -/remoll/filename pion_rates_at_lucite_plane_evgen_ep_elastic_1k.root +#/remoll/filename pion_rates_at_lucite_plane_evgen_ep_elastic_1k.root # Number of events -/run/beamOn 1000 +#/run/beamOn 1000 ### 4. ep inelastic electrons -/remoll/evgen/set inelastic +#/remoll/evgen/set inelastic -/remoll/evgen/emin 0.0 MeV -/remoll/evgen/emax 11.0 GeV +#/remoll/evgen/emin 0.0 MeV +#/remoll/evgen/emax 11.0 GeV -/remoll/evgen/thmin 0.5 deg -/remoll/evgen/thmax 3.0 deg +#/remoll/evgen/thmin 0.5 deg +#/remoll/evgen/thmax 3.0 deg # Specify random number seed -/remoll/seed 1234 +#/remoll/seed 1234 # Filename -/remoll/filename pion_rates_at_lucite_plane_evgen_ep_inelastic_1k.root +#/remoll/filename pion_rates_at_lucite_plane_evgen_ep_inelastic_1k.root # Number of events -/run/beamOn 1000 +#/run/beamOn 1000 diff --git a/macros/pionDetectorLucite.in b/macros/pionDetectorLucite.in index 831e122e3..9c03d7358 100644 --- a/macros/pionDetectorLucite.in +++ b/macros/pionDetectorLucite.in @@ -1,5 +1,6 @@ # This must be called before initialize /remoll/geometry/setfile geometry/pionDetectorLucite_world.gdml +/remoll/parallel/setfile # Enable optical physics /remoll/physlist/optical/enable diff --git a/macros/runBeam.mac b/macros/runBeam.mac index b069108c1..39fc0138d 100644 --- a/macros/runBeam.mac +++ b/macros/runBeam.mac @@ -1,4 +1,4 @@ -/remoll/setgeofile geometry/mollerMother_merged.gdml +/remoll/setgeofile geometry/mollerMother.gdml /remoll/physlist/register QGSP_BERT_HP /remoll/physlist/parallel/enable /remoll/parallel/setfile geometry/mollerParallel.gdml diff --git a/macros/runEE.mac b/macros/runEE.mac index 03836866f..d125b20c1 100644 --- a/macros/runEE.mac +++ b/macros/runEE.mac @@ -1,4 +1,4 @@ -/remoll/setgeofile geometry/mollerMother_merged.gdml +/remoll/setgeofile geometry/mollerMother.gdml /remoll/physlist/register QGSP_BERT_HP /remoll/physlist/parallel/enable /remoll/parallel/setfile geometry/mollerParallel.gdml diff --git a/macros/runEPpion.mac b/macros/runEPpion.mac index 50efba104..955bcb939 100644 --- a/macros/runEPpion.mac +++ b/macros/runEPpion.mac @@ -1,4 +1,4 @@ -/remoll/setgeofile geometry/mollerMother_merged.gdml +/remoll/setgeofile geometry/mollerMother.gdml /remoll/physlist/register QGSP_BERT_HP /remoll/physlist/parallel/enable /remoll/parallel/setfile geometry/mollerParallel.gdml diff --git a/macros/runTF1.mac b/macros/runTF1.mac deleted file mode 100644 index 65b70ccee..000000000 --- a/macros/runTF1.mac +++ /dev/null @@ -1,44 +0,0 @@ -# Example file - -# store tracks -#/tracking/storeTrajectory 1 - -# This must be called before initialize -/remoll/setgeofile geometry/mollerMother_noShlds.gdml - -# This must be explicitly called -/run/initialize - -/remoll/printgeometry true - -/remoll/addfield map_directory/blockyHybrid_rm_3.0.txt -/remoll/addfield map_directory/blockyUpstream_rm_1.1.txt - -#/remoll/scalefield map_directory/blockyHybrid_rm_3.0.txt 1.0 -#/remoll/magcurrent map_directory/blockyHybrid_rm_3.0.txt 1000.0 A - -# Raster and initial angle stuff -/remoll/oldras true -/remoll/rasx 5 mm -/remoll/rasy 5 mm - -/remoll/evgen/set TF1 -/run/beamOn 0 -/remoll/evgen/TF1/sector 0 -/remoll/evgen/TF1/scattType elastic - -/remoll/evgen/TF1/setFileFunction remollGenFunctions.root:sum - -/remoll/beamene 11 GeV - -/remoll/beamcurr 85 microampere - -# Make interactions with W, Cu, and Pb -# realistic rather than pure absorbers -/control/execute macros/kryptonite.mac - -/process/list - -/remoll/filename sum_updated.root - -/run/beamOn 100000 diff --git a/macros/runexample.mac b/macros/runexample.mac index 718f90053..87a740522 100644 --- a/macros/runexample.mac +++ b/macros/runexample.mac @@ -4,7 +4,7 @@ #/tracking/storeTrajectory 1 # This must be called before initialize -/remoll/geometry/setfile geometry/mollerMother_merged.gdml +/remoll/geometry/setfile geometry/mollerMother.gdml # Parallel world geometry is optional - detector 28 (the primary detector array's idealize vacuum detector) is included in this parallel world now. /remoll/parallel/setfile geometry/mollerParallel.gdml @@ -81,5 +81,5 @@ /remoll/filename remollout.root #/tracking/verbose 2 -/remoll/printtargetinfo +/remoll/target/print /run/beamOn 100 diff --git a/macros/runexample_AlDummy1US.mac b/macros/runexample_AlDummy1US.mac new file mode 100644 index 000000000..dc7740adc --- /dev/null +++ b/macros/runexample_AlDummy1US.mac @@ -0,0 +1,34 @@ +# Example file + +# This must be called before initialize +/remoll/geometry/setfile geometry/mollerMother.gdml +/remoll/parallel/setfile geometry/mollerParallel.gdml + +# This must be explicitly called +/run/initialize + +# Set target ladder position +/control/execute macros/target/AlDummy1US.mac +#/control/execute macros/target/AlDummy1DS.mac +#/control/execute macros/target/AlDummy2US.mac +#/control/execute macros/target/AlDummy2DS.mac + +# Load magnetic fields +/control/execute macros/load_magnetic_fieldmaps.mac + +# Raster and initial angle stuff +/remoll/oldras true +/remoll/rasx 5 mm +/remoll/rasy 5 mm + +#/remoll/evgen/set elasticAl +/remoll/evgen/set inelasticAl +#/remoll/evgen/set quasielasticAl +#/remoll/evgen/set moller + +/remoll/beamcurr 85 microampere + +/remoll/seed 123456 + +/remoll/target/print +/run/beamOn 100 diff --git a/macros/runexample_C12.mac b/macros/runexample_C12.mac deleted file mode 100644 index 766f42ebd..000000000 --- a/macros/runexample_C12.mac +++ /dev/null @@ -1,45 +0,0 @@ -# Example file - -# This must be called before initialize -/remoll/setgeofile geometry_sculpt/mollerMother.gdml - -# This must be explicitly called -/run/initialize - -/control/execute macros/load_magnetic_fieldmaps.mac - -# Raster and initial angle stuff -/remoll/rasx 0 mm -/remoll/rasy 0 mm -#/remoll/beam_x0 0 mm -#/remoll/beam_y0 0 mm -# initial angle -#/remoll/beam_th0 0 mrad -#/remoll/beam_ph0 0 mrad -# gaussian spread widths -#/remoll/beam_dth 0 mrad -#/remoll/beam_dph 0 mrad - -/remoll/gen carbon -/remoll/thmin 0.1 deg -/remoll/thmax 2.0 deg - -/remoll/beamcurr 85 microampere - -#Enable optical photons and processes -#/remoll/optical true - -# Make interactions with W, Cu, and Pb -# realistic rather than pure absorbers -#/remoll/krypt true - -# Specify random number seed -/remoll/seed 123456 - -#/tracking/storeTrajectory 1 -#/tracking/verbose 2 -#/run/verbose 2 - -/remoll/filename Rootfiles/remoll_C12_noras_4GEMRes75um_det28z.root -/run/beamOn 1000000 - diff --git a/macros/runexample_Optics1.mac b/macros/runexample_Optics1.mac new file mode 100644 index 000000000..e6e754255 --- /dev/null +++ b/macros/runexample_Optics1.mac @@ -0,0 +1,30 @@ +# Example file + +# This must be called before initialize +/remoll/geometry/setfile geometry/mollerMother.gdml +/remoll/parallel/setfile geometry/mollerParallel.gdml + +# This must be explicitly called +/run/initialize + +# Set target ladder position +/control/execute macros/target/Optics1.mac + +# Load magnetic fields +/control/execute macros/load_magnetic_fieldmaps.mac + +# Raster and initial angle stuff +/remoll/rasx 0 mm +/remoll/rasy 0 mm + +/remoll/evgen/set elasticC12 +#/remoll/evgen/set quasielasticC12 +#/remoll/evgen/set inelasticC12 + +/remoll/beamcurr 85 microampere + +/remoll/seed 123456 + +/remoll/target/print +/run/beamOn 100 + diff --git a/macros/runexample_envelope.mac b/macros/runexample_envelope.mac index b4a781db1..34fcc52a0 100644 --- a/macros/runexample_envelope.mac +++ b/macros/runexample_envelope.mac @@ -1,6 +1,6 @@ # Macrofile # This must be called before initialize -/remoll/setgeofile geometry/mollerMother_merged.gdml +/remoll/setgeofile geometry/mollerMother.gdml # This must be explicitly called /run/initialize /remoll/tracking/set 0 diff --git a/macros/vis.mac b/macros/runexample_vis.mac similarity index 95% rename from macros/vis.mac rename to macros/runexample_vis.mac index e8fa8db29..65cb4dec0 100644 --- a/macros/vis.mac +++ b/macros/runexample_vis.mac @@ -4,7 +4,7 @@ /remoll/physlist/optical/enable # This is the current working geometry -/remoll/setgeofile geometry/mollerMother_merged.gdml +/remoll/setgeofile geometry/mollerMother.gdml #/remoll/likekryptonite true @@ -51,6 +51,3 @@ #/remoll/evgen/external/startEvent 0 #/remoll/evgen/external/zOffset -28550.0 #/remoll/filename remollout_r5o_external_default.root - - -#/run/beamOn 100 diff --git a/macros/showermax/sm_close14_elastic_1001.mac b/macros/showermax/sm_close14_elastic_1001.mac new file mode 100644 index 000000000..226c425b3 --- /dev/null +++ b/macros/showermax/sm_close14_elastic_1001.mac @@ -0,0 +1,54 @@ +/remoll/setgeofile geometry/mollerMother.gdml +/remoll/physlist/register QGSP_BERT_HP +/remoll/physlist/parallel/enable +/remoll/parallel/setfile geometry/mollerParallel.gdml + +/run/initialize +/control/execute macros/load_magnetic_fieldmaps.mac + +/remoll/evgen/set elastic + +/remoll/oldras false +/remoll/beam_corrph 0.02134 +/remoll/beam_corrth 0.02134 + +/remoll/beamene 11 GeV +/remoll/beamcurr 65 microampere + +/remoll/SD/disable_all +/remoll/SD/enable 28 +/remoll/SD/detect lowenergyneutral 28 +/remoll/SD/detect secondaries 28 +/remoll/SD/detect boundaryhits 28 + +/remoll/SD/enable 70 +/remoll/SD/detect lowenergyneutral 70 +/remoll/SD/detect secondaries 70 +/remoll/SD/detect boundaryhits 70 + +/remoll/SD/enable 7141 +/remoll/SD/detect lowenergyneutral 7141 +/remoll/SD/detect secondaries 7141 +/remoll/SD/detect boundaryhits 7141 + +/remoll/SD/enable 7142 +/remoll/SD/detect lowenergyneutral 7142 +/remoll/SD/detect secondaries 7142 +/remoll/SD/detect boundaryhits 7142 + +/remoll/SD/enable 7144 +/remoll/SD/detect lowenergyneutral 7144 +/remoll/SD/detect secondaries 7144 +/remoll/SD/detect boundaryhits 7144 + +/remoll/SD/enable 7146 +/remoll/SD/detect lowenergyneutral 7146 +/remoll/SD/detect secondaries 7146 +/remoll/SD/detect boundaryhits 7146 + +/remoll/SD/enable 7148 +/remoll/SD/detect lowenergyneutral 7148 +/remoll/SD/detect secondaries 7148 +/remoll/SD/detect boundaryhits 7148 + +/run/beamOn 50000 diff --git a/macros/showermax/sm_close14_inelastic_1001.mac b/macros/showermax/sm_close14_inelastic_1001.mac new file mode 100644 index 000000000..8aaffaa2c --- /dev/null +++ b/macros/showermax/sm_close14_inelastic_1001.mac @@ -0,0 +1,54 @@ +/remoll/setgeofile geometry/mollerMother.gdml +/remoll/physlist/register QGSP_BERT_HP +/remoll/physlist/parallel/enable +/remoll/parallel/setfile geometry/mollerParallel.gdml + +/run/initialize +/control/execute macros/load_magnetic_fieldmaps.mac + +/remoll/evgen/set inelastic + +/remoll/oldras false +/remoll/beam_corrph 0.02134 +/remoll/beam_corrth 0.02134 + +/remoll/beamene 11 GeV +/remoll/beamcurr 65 microampere + +/remoll/SD/disable_all +/remoll/SD/enable 28 +/remoll/SD/detect lowenergyneutral 28 +/remoll/SD/detect secondaries 28 +/remoll/SD/detect boundaryhits 28 + +/remoll/SD/enable 70 +/remoll/SD/detect lowenergyneutral 70 +/remoll/SD/detect secondaries 70 +/remoll/SD/detect boundaryhits 70 + +/remoll/SD/enable 7141 +/remoll/SD/detect lowenergyneutral 7141 +/remoll/SD/detect secondaries 7141 +/remoll/SD/detect boundaryhits 7141 + +/remoll/SD/enable 7142 +/remoll/SD/detect lowenergyneutral 7142 +/remoll/SD/detect secondaries 7142 +/remoll/SD/detect boundaryhits 7142 + +/remoll/SD/enable 7144 +/remoll/SD/detect lowenergyneutral 7144 +/remoll/SD/detect secondaries 7144 +/remoll/SD/detect boundaryhits 7144 + +/remoll/SD/enable 7146 +/remoll/SD/detect lowenergyneutral 7146 +/remoll/SD/detect secondaries 7146 +/remoll/SD/detect boundaryhits 7146 + +/remoll/SD/enable 7148 +/remoll/SD/detect lowenergyneutral 7148 +/remoll/SD/detect secondaries 7148 +/remoll/SD/detect boundaryhits 7148 + +/run/beamOn 50000 diff --git a/macros/showermax/sm_close14_moller_1001.mac b/macros/showermax/sm_close14_moller_1001.mac new file mode 100644 index 000000000..165deb2f7 --- /dev/null +++ b/macros/showermax/sm_close14_moller_1001.mac @@ -0,0 +1,54 @@ +/remoll/setgeofile geometry/mollerMother.gdml +/remoll/physlist/register QGSP_BERT_HP +/remoll/physlist/parallel/enable +/remoll/parallel/setfile geometry/mollerParallel.gdml + +/run/initialize +/control/execute macros/load_magnetic_fieldmaps.mac + +/remoll/evgen/set moller + +/remoll/oldras false +/remoll/beam_corrph 0.02134 +/remoll/beam_corrth 0.02134 + +/remoll/beamene 11 GeV +/remoll/beamcurr 65 microampere + +/remoll/SD/disable_all +/remoll/SD/enable 28 +/remoll/SD/detect lowenergyneutral 28 +/remoll/SD/detect secondaries 28 +/remoll/SD/detect boundaryhits 28 + +/remoll/SD/enable 70 +/remoll/SD/detect lowenergyneutral 70 +/remoll/SD/detect secondaries 70 +/remoll/SD/detect boundaryhits 70 + +/remoll/SD/enable 7141 +/remoll/SD/detect lowenergyneutral 7141 +/remoll/SD/detect secondaries 7141 +/remoll/SD/detect boundaryhits 7141 + +/remoll/SD/enable 7142 +/remoll/SD/detect lowenergyneutral 7142 +/remoll/SD/detect secondaries 7142 +/remoll/SD/detect boundaryhits 7142 + +/remoll/SD/enable 7144 +/remoll/SD/detect lowenergyneutral 7144 +/remoll/SD/detect secondaries 7144 +/remoll/SD/detect boundaryhits 7144 + +/remoll/SD/enable 7146 +/remoll/SD/detect lowenergyneutral 7146 +/remoll/SD/detect secondaries 7146 +/remoll/SD/detect boundaryhits 7146 + +/remoll/SD/enable 7148 +/remoll/SD/detect lowenergyneutral 7148 +/remoll/SD/detect secondaries 7148 +/remoll/SD/detect boundaryhits 7148 + +/run/beamOn 50000 diff --git a/macros/showermax/sm_open00_elastic_1001.mac b/macros/showermax/sm_open00_elastic_1001.mac new file mode 100644 index 000000000..1eb7560ad --- /dev/null +++ b/macros/showermax/sm_open00_elastic_1001.mac @@ -0,0 +1,54 @@ +/remoll/setgeofile geometry/mollerMother.gdml +/remoll/physlist/register QGSP_BERT_HP +/remoll/physlist/parallel/enable +/remoll/parallel/setfile geometry/mollerParallel.gdml + +/run/initialize +/control/execute macros/load_magnetic_fieldmaps.mac + +/remoll/evgen/set elastic + +/remoll/oldras false +/remoll/beam_corrph 0.02134 +/remoll/beam_corrth 0.02134 + +/remoll/beamene 11 GeV +/remoll/beamcurr 65 microampere + +/remoll/SD/disable_all +/remoll/SD/enable 28 +/remoll/SD/detect lowenergyneutral 28 +/remoll/SD/detect secondaries 28 +/remoll/SD/detect boundaryhits 28 + +/remoll/SD/enable 70 +/remoll/SD/detect lowenergyneutral 70 +/remoll/SD/detect secondaries 70 +/remoll/SD/detect boundaryhits 70 + +/remoll/SD/enable 7001 +/remoll/SD/detect lowenergyneutral 7001 +/remoll/SD/detect secondaries 7001 +/remoll/SD/detect boundaryhits 7001 + +/remoll/SD/enable 7002 +/remoll/SD/detect lowenergyneutral 7002 +/remoll/SD/detect secondaries 7002 +/remoll/SD/detect boundaryhits 7002 + +/remoll/SD/enable 7004 +/remoll/SD/detect lowenergyneutral 7004 +/remoll/SD/detect secondaries 7004 +/remoll/SD/detect boundaryhits 7004 + +/remoll/SD/enable 7006 +/remoll/SD/detect lowenergyneutral 7006 +/remoll/SD/detect secondaries 7006 +/remoll/SD/detect boundaryhits 7006 + +/remoll/SD/enable 7008 +/remoll/SD/detect lowenergyneutral 7008 +/remoll/SD/detect secondaries 7008 +/remoll/SD/detect boundaryhits 7008 + +/run/beamOn 50000 diff --git a/macros/showermax/sm_open00_inelastic_1001.mac b/macros/showermax/sm_open00_inelastic_1001.mac new file mode 100644 index 000000000..006710f29 --- /dev/null +++ b/macros/showermax/sm_open00_inelastic_1001.mac @@ -0,0 +1,54 @@ +/remoll/setgeofile geometry/mollerMother.gdml +/remoll/physlist/register QGSP_BERT_HP +/remoll/physlist/parallel/enable +/remoll/parallel/setfile geometry/mollerParallel.gdml + +/run/initialize +/control/execute macros/load_magnetic_fieldmaps.mac + +/remoll/evgen/set inelastic + +/remoll/oldras false +/remoll/beam_corrph 0.02134 +/remoll/beam_corrth 0.02134 + +/remoll/beamene 11 GeV +/remoll/beamcurr 65 microampere + +/remoll/SD/disable_all +/remoll/SD/enable 28 +/remoll/SD/detect lowenergyneutral 28 +/remoll/SD/detect secondaries 28 +/remoll/SD/detect boundaryhits 28 + +/remoll/SD/enable 70 +/remoll/SD/detect lowenergyneutral 70 +/remoll/SD/detect secondaries 70 +/remoll/SD/detect boundaryhits 70 + +/remoll/SD/enable 7001 +/remoll/SD/detect lowenergyneutral 7001 +/remoll/SD/detect secondaries 7001 +/remoll/SD/detect boundaryhits 7001 + +/remoll/SD/enable 7002 +/remoll/SD/detect lowenergyneutral 7002 +/remoll/SD/detect secondaries 7002 +/remoll/SD/detect boundaryhits 7002 + +/remoll/SD/enable 7004 +/remoll/SD/detect lowenergyneutral 7004 +/remoll/SD/detect secondaries 7004 +/remoll/SD/detect boundaryhits 7004 + +/remoll/SD/enable 7006 +/remoll/SD/detect lowenergyneutral 7006 +/remoll/SD/detect secondaries 7006 +/remoll/SD/detect boundaryhits 7006 + +/remoll/SD/enable 7008 +/remoll/SD/detect lowenergyneutral 7008 +/remoll/SD/detect secondaries 7008 +/remoll/SD/detect boundaryhits 7008 + +/run/beamOn 50000 diff --git a/macros/showermax/sm_open00_moller_1001.mac b/macros/showermax/sm_open00_moller_1001.mac new file mode 100644 index 000000000..e43edea0a --- /dev/null +++ b/macros/showermax/sm_open00_moller_1001.mac @@ -0,0 +1,54 @@ +/remoll/setgeofile geometry/mollerMother.gdml +/remoll/physlist/register QGSP_BERT_HP +/remoll/physlist/parallel/enable +/remoll/parallel/setfile geometry/mollerParallel.gdml + +/run/initialize +/control/execute macros/load_magnetic_fieldmaps.mac + +/remoll/evgen/set moller + +/remoll/oldras false +/remoll/beam_corrph 0.02134 +/remoll/beam_corrth 0.02134 + +/remoll/beamene 11 GeV +/remoll/beamcurr 65 microampere + +/remoll/SD/disable_all +/remoll/SD/enable 28 +/remoll/SD/detect lowenergyneutral 28 +/remoll/SD/detect secondaries 28 +/remoll/SD/detect boundaryhits 28 + +/remoll/SD/enable 70 +/remoll/SD/detect lowenergyneutral 70 +/remoll/SD/detect secondaries 70 +/remoll/SD/detect boundaryhits 70 + +/remoll/SD/enable 7001 +/remoll/SD/detect lowenergyneutral 7001 +/remoll/SD/detect secondaries 7001 +/remoll/SD/detect boundaryhits 7001 + +/remoll/SD/enable 7002 +/remoll/SD/detect lowenergyneutral 7002 +/remoll/SD/detect secondaries 7002 +/remoll/SD/detect boundaryhits 7002 + +/remoll/SD/enable 7004 +/remoll/SD/detect lowenergyneutral 7004 +/remoll/SD/detect secondaries 7004 +/remoll/SD/detect boundaryhits 7004 + +/remoll/SD/enable 7006 +/remoll/SD/detect lowenergyneutral 7006 +/remoll/SD/detect secondaries 7006 +/remoll/SD/detect boundaryhits 7006 + +/remoll/SD/enable 7008 +/remoll/SD/detect lowenergyneutral 7008 +/remoll/SD/detect secondaries 7008 +/remoll/SD/detect boundaryhits 7008 + +/run/beamOn 10000 diff --git a/macros/showermax/sm_trans21_elastic_1001.mac b/macros/showermax/sm_trans21_elastic_1001.mac new file mode 100644 index 000000000..5b5ec9b04 --- /dev/null +++ b/macros/showermax/sm_trans21_elastic_1001.mac @@ -0,0 +1,54 @@ +/remoll/setgeofile geometry/mollerMother.gdml +/remoll/physlist/register QGSP_BERT_HP +/remoll/physlist/parallel/enable +/remoll/parallel/setfile geometry/mollerParallel.gdml + +/run/initialize +/control/execute macros/load_magnetic_fieldmaps.mac + +/remoll/evgen/set elastic + +/remoll/oldras false +/remoll/beam_corrph 0.02134 +/remoll/beam_corrth 0.02134 + +/remoll/beamene 11 GeV +/remoll/beamcurr 65 microampere + +/remoll/SD/disable_all +/remoll/SD/enable 28 +/remoll/SD/detect lowenergyneutral 28 +/remoll/SD/detect secondaries 28 +/remoll/SD/detect boundaryhits 28 + +/remoll/SD/enable 70 +/remoll/SD/detect lowenergyneutral 70 +/remoll/SD/detect secondaries 70 +/remoll/SD/detect boundaryhits 70 + +/remoll/SD/enable 7211 +/remoll/SD/detect lowenergyneutral 7211 +/remoll/SD/detect secondaries 7211 +/remoll/SD/detect boundaryhits 7211 + +/remoll/SD/enable 7212 +/remoll/SD/detect lowenergyneutral 7212 +/remoll/SD/detect secondaries 7212 +/remoll/SD/detect boundaryhits 7212 + +/remoll/SD/enable 7214 +/remoll/SD/detect lowenergyneutral 7214 +/remoll/SD/detect secondaries 7214 +/remoll/SD/detect boundaryhits 7214 + +/remoll/SD/enable 7216 +/remoll/SD/detect lowenergyneutral 7216 +/remoll/SD/detect secondaries 7216 +/remoll/SD/detect boundaryhits 7216 + +/remoll/SD/enable 7218 +/remoll/SD/detect lowenergyneutral 7218 +/remoll/SD/detect secondaries 7218 +/remoll/SD/detect boundaryhits 7218 + +/run/beamOn 50000 diff --git a/macros/showermax/sm_trans21_inelastic_1001.mac b/macros/showermax/sm_trans21_inelastic_1001.mac new file mode 100644 index 000000000..8f188e715 --- /dev/null +++ b/macros/showermax/sm_trans21_inelastic_1001.mac @@ -0,0 +1,54 @@ +/remoll/setgeofile geometry/mollerMother.gdml +/remoll/physlist/register QGSP_BERT_HP +/remoll/physlist/parallel/enable +/remoll/parallel/setfile geometry/mollerParallel.gdml + +/run/initialize +/control/execute macros/load_magnetic_fieldmaps.mac + +/remoll/evgen/set inelastic + +/remoll/oldras false +/remoll/beam_corrph 0.02134 +/remoll/beam_corrth 0.02134 + +/remoll/beamene 11 GeV +/remoll/beamcurr 65 microampere + +/remoll/SD/disable_all +/remoll/SD/enable 28 +/remoll/SD/detect lowenergyneutral 28 +/remoll/SD/detect secondaries 28 +/remoll/SD/detect boundaryhits 28 + +/remoll/SD/enable 70 +/remoll/SD/detect lowenergyneutral 70 +/remoll/SD/detect secondaries 70 +/remoll/SD/detect boundaryhits 70 + +/remoll/SD/enable 7211 +/remoll/SD/detect lowenergyneutral 7211 +/remoll/SD/detect secondaries 7211 +/remoll/SD/detect boundaryhits 7211 + +/remoll/SD/enable 7212 +/remoll/SD/detect lowenergyneutral 7212 +/remoll/SD/detect secondaries 7212 +/remoll/SD/detect boundaryhits 7212 + +/remoll/SD/enable 7214 +/remoll/SD/detect lowenergyneutral 7214 +/remoll/SD/detect secondaries 7214 +/remoll/SD/detect boundaryhits 7214 + +/remoll/SD/enable 7216 +/remoll/SD/detect lowenergyneutral 7216 +/remoll/SD/detect secondaries 7216 +/remoll/SD/detect boundaryhits 7216 + +/remoll/SD/enable 7218 +/remoll/SD/detect lowenergyneutral 7218 +/remoll/SD/detect secondaries 7218 +/remoll/SD/detect boundaryhits 7218 + +/run/beamOn 50000 diff --git a/macros/showermax/sm_trans21_moller_1001.mac b/macros/showermax/sm_trans21_moller_1001.mac new file mode 100644 index 000000000..677b4a21c --- /dev/null +++ b/macros/showermax/sm_trans21_moller_1001.mac @@ -0,0 +1,54 @@ +/remoll/setgeofile geometry/mollerMother.gdml +/remoll/physlist/register QGSP_BERT_HP +/remoll/physlist/parallel/enable +/remoll/parallel/setfile geometry/mollerParallel.gdml + +/run/initialize +/control/execute macros/load_magnetic_fieldmaps.mac + +/remoll/evgen/set moller + +/remoll/oldras false +/remoll/beam_corrph 0.02134 +/remoll/beam_corrth 0.02134 + +/remoll/beamene 11 GeV +/remoll/beamcurr 65 microampere + +/remoll/SD/disable_all +/remoll/SD/enable 28 +/remoll/SD/detect lowenergyneutral 28 +/remoll/SD/detect secondaries 28 +/remoll/SD/detect boundaryhits 28 + +/remoll/SD/enable 70 +/remoll/SD/detect lowenergyneutral 70 +/remoll/SD/detect secondaries 70 +/remoll/SD/detect boundaryhits 70 + +/remoll/SD/enable 7211 +/remoll/SD/detect lowenergyneutral 7211 +/remoll/SD/detect secondaries 7211 +/remoll/SD/detect boundaryhits 7211 + +/remoll/SD/enable 7212 +/remoll/SD/detect lowenergyneutral 7212 +/remoll/SD/detect secondaries 7212 +/remoll/SD/detect boundaryhits 7212 + +/remoll/SD/enable 7214 +/remoll/SD/detect lowenergyneutral 7214 +/remoll/SD/detect secondaries 7214 +/remoll/SD/detect boundaryhits 7214 + +/remoll/SD/enable 7216 +/remoll/SD/detect lowenergyneutral 7216 +/remoll/SD/detect secondaries 7216 +/remoll/SD/detect boundaryhits 7216 + +/remoll/SD/enable 7218 +/remoll/SD/detect lowenergyneutral 7218 +/remoll/SD/detect secondaries 7218 +/remoll/SD/detect boundaryhits 7218 + +/run/beamOn 50000 diff --git a/macros/sieve/sieve_in.mac b/macros/sieve/sieve_in.mac new file mode 100644 index 000000000..6d15003f1 --- /dev/null +++ b/macros/sieve/sieve_in.mac @@ -0,0 +1,2 @@ +# Move the sieve 200 mm to beam axis +/remoll/geometry/relative_position USsieve (-200,0,0) diff --git a/macros/sieve/sieve_out.mac b/macros/sieve/sieve_out.mac new file mode 100644 index 000000000..88cddd749 --- /dev/null +++ b/macros/sieve/sieve_out.mac @@ -0,0 +1,2 @@ +# Move the sieve 200 mm off axis +/remoll/geometry/relative_position USsieve (200,0,0) diff --git a/macros/target/AlDummy1DS.mac b/macros/target/AlDummy1DS.mac new file mode 100644 index 000000000..b887226ea --- /dev/null +++ b/macros/target/AlDummy1DS.mac @@ -0,0 +1,3 @@ +/remoll/geometry/absolute_position targetLadder (0,350,0) +/remoll/target/mother AlDummy1DS +/remoll/target/volume DSAl diff --git a/macros/target/AlDummy1US.mac b/macros/target/AlDummy1US.mac new file mode 100644 index 000000000..a473767ff --- /dev/null +++ b/macros/target/AlDummy1US.mac @@ -0,0 +1,3 @@ +/remoll/geometry/absolute_position targetLadder (0,280,0) +/remoll/target/mother AlDummy1US +/remoll/target/volume USAl diff --git a/macros/target/AlDummy2DS.mac b/macros/target/AlDummy2DS.mac new file mode 100644 index 000000000..41419cc01 --- /dev/null +++ b/macros/target/AlDummy2DS.mac @@ -0,0 +1,3 @@ +/remoll/geometry/absolute_position targetLadder (0,490,0) +/remoll/target/mother AlDummy2DS +/remoll/target/volume DSAl diff --git a/macros/target/AlDummy2US.mac b/macros/target/AlDummy2US.mac new file mode 100644 index 000000000..1f0fa73e1 --- /dev/null +++ b/macros/target/AlDummy2US.mac @@ -0,0 +1,3 @@ +/remoll/geometry/absolute_position targetLadder (0,420,0) +/remoll/target/mother AlDummy2US +/remoll/target/volume USAl diff --git a/macros/target/AlDummyHoleDS.mac b/macros/target/AlDummyHoleDS.mac new file mode 100644 index 000000000..639298318 --- /dev/null +++ b/macros/target/AlDummyHoleDS.mac @@ -0,0 +1,3 @@ +/remoll/geometry/absolute_position targetLadder (0,210,0) +/remoll/target/mother AlHoleDS +/remoll/target/volume DSAl diff --git a/macros/target/AlDummyHoleUS.mac b/macros/target/AlDummyHoleUS.mac new file mode 100644 index 000000000..bf302211a --- /dev/null +++ b/macros/target/AlDummyHoleUS.mac @@ -0,0 +1,3 @@ +/remoll/geometry/absolute_position targetLadder (0,140,0) +/remoll/target/mother AlHoleUS +/remoll/target/volume USAl diff --git a/macros/target/AlHoleUS.mac b/macros/target/AlHoleUS.mac new file mode 100644 index 000000000..bf302211a --- /dev/null +++ b/macros/target/AlHoleUS.mac @@ -0,0 +1,3 @@ +/remoll/geometry/absolute_position targetLadder (0,140,0) +/remoll/target/mother AlHoleUS +/remoll/target/volume USAl diff --git a/macros/target/LH2.mac b/macros/target/LH2.mac new file mode 100644 index 000000000..d7507df8c --- /dev/null +++ b/macros/target/LH2.mac @@ -0,0 +1,3 @@ +/remoll/geometry/absolute_position targetLadder (0,0,0) +/remoll/target/mother LH2 +/remoll/target/volume LH2 diff --git a/macros/target/Optics1.mac b/macros/target/Optics1.mac new file mode 100644 index 000000000..b68c4c31f --- /dev/null +++ b/macros/target/Optics1.mac @@ -0,0 +1,3 @@ +/remoll/geometry/absolute_position targetLadder (0,560,0) +/remoll/target/mother Optics1 +/remoll/target/volume DSC diff --git a/macros/target/Optics2.mac b/macros/target/Optics2.mac new file mode 100644 index 000000000..2f0b72c07 --- /dev/null +++ b/macros/target/Optics2.mac @@ -0,0 +1,3 @@ +/remoll/geometry/absolute_position targetLadder (0,630,0) +/remoll/target/mother Optics2 +/remoll/target/volume USC diff --git a/macros/tests/commit/test_beam.mac b/macros/tests/commit/test_beam.mac index 7e894b30e..b3e957d22 100644 --- a/macros/tests/commit/test_beam.mac +++ b/macros/tests/commit/test_beam.mac @@ -1,7 +1,6 @@ # This must be called before initialize /remoll/geometry/setfile geometry/mollerMother.gdml /remoll/parallel/setfile geometry/mollerParallel.gdml -/remoll/physlist/parallel/enable # This must be explicitly called /run/initialize @@ -17,37 +16,17 @@ # Beam energy /remoll/beamene 11 GeV - +# Beam generator /remoll/evgen/set beam -#/remoll/evgen/set moller -#/remoll/evgen/thcommin 30.0 deg -#/remoll/evgen/thcommax 150.0 deg -#/remoll/evgen/set elastic -#/remoll/evgen/emin 80.0 MeV -#/remoll/evgen/set inelastic -#/remoll/evgen/set pion -#/remoll/piontype pi- -#/remoll/evgen/set pion_LUND -#/remoll/evgen/set inelasticAl -#/remoll/evgen/set quasielasticAl -#/remoll/evgen/set elasticAl - -# Generation limits -# theta -/remoll/evgen/thmin 0.5 deg -/remoll/evgen/thmax 3.0 deg # Beam current for rate /remoll/beamcurr 85 microampere -# Make interactions with W, Cu, and Pb -# realistic rather than pure absorbers -/control/execute macros/kryptonite.mac - +# Seed /remoll/seed 123456 # Output /remoll/filename test_beam.root # Shoot -/run/beamOn 1000 +/run/beamOn 100 diff --git a/macros/tests/commit/test_elastic.mac b/macros/tests/commit/test_elastic.mac index ac6664455..956b17e8f 100644 --- a/macros/tests/commit/test_elastic.mac +++ b/macros/tests/commit/test_elastic.mac @@ -1,7 +1,6 @@ # This must be called before initialize /remoll/geometry/setfile geometry/mollerMother.gdml /remoll/parallel/setfile geometry/mollerParallel.gdml -/remoll/physlist/parallel/enable # This must be explicitly called /run/initialize @@ -40,14 +39,11 @@ # Beam current for rate /remoll/beamcurr 85 microampere -# Make interactions with W, Cu, and Pb -# realistic rather than pure absorbers -/control/execute macros/kryptonite.mac - +# Seed /remoll/seed 123456 # Output /remoll/filename test_elastic.root # Shoot -/run/beamOn 1000 +/run/beamOn 100 diff --git a/macros/tests/commit/test_elasticAl.mac b/macros/tests/commit/test_elasticAl.mac index 67f90ecf6..a74f20e2f 100644 --- a/macros/tests/commit/test_elasticAl.mac +++ b/macros/tests/commit/test_elasticAl.mac @@ -1,7 +1,6 @@ # This must be called before initialize /remoll/geometry/setfile geometry/mollerMother.gdml /remoll/parallel/setfile geometry/mollerParallel.gdml -/remoll/physlist/parallel/enable # This must be explicitly called /run/initialize @@ -29,14 +28,11 @@ # Beam current for rate /remoll/beamcurr 85 microampere -# Make interactions with W, Cu, and Pb -# realistic rather than pure absorbers -/control/execute macros/kryptonite.mac - +# Seed /remoll/seed 123456 # Output /remoll/filename test_elasticAl.root # Shoot -/run/beamOn 10000 +/run/beamOn 100 diff --git a/macros/tests/commit/test_elasticAl_DS.mac b/macros/tests/commit/test_elasticAl_DS.mac index 50580287a..44e833d76 100644 --- a/macros/tests/commit/test_elasticAl_DS.mac +++ b/macros/tests/commit/test_elasticAl_DS.mac @@ -1,7 +1,6 @@ # This must be called before initialize /remoll/geometry/setfile geometry/mollerMother.gdml /remoll/parallel/setfile geometry/mollerParallel.gdml -/remoll/physlist/parallel/enable # This must be explicitly called /run/initialize @@ -31,14 +30,11 @@ # Beam current for rate /remoll/beamcurr 85 microampere -# Make interactions with W, Cu, and Pb -# realistic rather than pure absorbers -/control/execute macros/kryptonite.mac - +# Seed /remoll/seed 123456 # Output /remoll/filename test_elasticAl_DS.root # Shoot -/run/beamOn 10000 +/run/beamOn 100 diff --git a/macros/tests/commit/test_elasticAl_US.mac b/macros/tests/commit/test_elasticAl_US.mac index 6b2d29e4b..0d53244a7 100644 --- a/macros/tests/commit/test_elasticAl_US.mac +++ b/macros/tests/commit/test_elasticAl_US.mac @@ -1,7 +1,6 @@ # This must be called before initialize /remoll/geometry/setfile geometry/mollerMother.gdml /remoll/parallel/setfile geometry/mollerParallel.gdml -/remoll/physlist/parallel/enable # This must be explicitly called /run/initialize @@ -31,14 +30,11 @@ # Beam current for rate /remoll/beamcurr 85 microampere -# Make interactions with W, Cu, and Pb -# realistic rather than pure absorbers -/control/execute macros/kryptonite.mac - +# Seed /remoll/seed 123456 # Output /remoll/filename test_elasticAl_US.root # Shoot -/run/beamOn 10000 +/run/beamOn 100 diff --git a/macros/tests/commit/test_inelastic.mac b/macros/tests/commit/test_inelastic.mac index 7efd556b3..3e22473f7 100644 --- a/macros/tests/commit/test_inelastic.mac +++ b/macros/tests/commit/test_inelastic.mac @@ -1,7 +1,6 @@ # This must be called before initialize /remoll/geometry/setfile geometry/mollerMother.gdml /remoll/parallel/setfile geometry/mollerParallel.gdml -/remoll/physlist/parallel/enable # This must be explicitly called /run/initialize @@ -40,14 +39,11 @@ # Beam current for rate /remoll/beamcurr 85 microampere -# Make interactions with W, Cu, and Pb -# realistic rather than pure absorbers -/control/execute macros/kryptonite.mac - +# Seed /remoll/seed 123456 # Output /remoll/filename test_inelastic.root # Shoot -/run/beamOn 1000 +/run/beamOn 100 diff --git a/macros/tests/commit/test_inelasticAl.mac b/macros/tests/commit/test_inelasticAl.mac index eb4ab9057..4317717f3 100644 --- a/macros/tests/commit/test_inelasticAl.mac +++ b/macros/tests/commit/test_inelasticAl.mac @@ -1,7 +1,6 @@ # This must be called before initialize /remoll/geometry/setfile geometry/mollerMother.gdml /remoll/parallel/setfile geometry/mollerParallel.gdml -/remoll/physlist/parallel/enable # This must be explicitly called /run/initialize @@ -40,14 +39,11 @@ # Beam current for rate /remoll/beamcurr 85 microampere -# Make interactions with W, Cu, and Pb -# realistic rather than pure absorbers -/control/execute macros/kryptonite.mac - +# Seed /remoll/seed 123456 # Output /remoll/filename test_inelasticAl.root # Shoot -/run/beamOn 1000 +/run/beamOn 100 diff --git a/macros/tests/commit/test_moller.mac b/macros/tests/commit/test_moller.mac index b31198495..9343c5831 100644 --- a/macros/tests/commit/test_moller.mac +++ b/macros/tests/commit/test_moller.mac @@ -1,7 +1,6 @@ # This must be called before initialize /remoll/geometry/setfile geometry/mollerMother.gdml /remoll/parallel/setfile geometry/mollerParallel.gdml -/remoll/physlist/parallel/enable # This must be explicitly called /run/initialize @@ -40,14 +39,11 @@ # Beam current for rate /remoll/beamcurr 85 microampere -# Make interactions with W, Cu, and Pb -# realistic rather than pure absorbers -/control/execute macros/kryptonite.mac - +# Seed /remoll/seed 123456 # Output /remoll/filename test_moller.root # Shoot -/run/beamOn 1000 +/run/beamOn 100 diff --git a/macros/tests/commit/test_pion.mac b/macros/tests/commit/test_pion.mac index 021248939..4f97ab2c9 100644 --- a/macros/tests/commit/test_pion.mac +++ b/macros/tests/commit/test_pion.mac @@ -1,7 +1,6 @@ # This must be called before initialize /remoll/geometry/setfile geometry/mollerMother.gdml /remoll/parallel/setfile geometry/mollerParallel.gdml -/remoll/physlist/parallel/enable # This must be explicitly called /run/numberOfThreads 1 @@ -41,14 +40,11 @@ # Beam current for rate /remoll/beamcurr 85 microampere -# Make interactions with W, Cu, and Pb -# realistic rather than pure absorbers -/control/execute macros/kryptonite.mac - +# Seed /remoll/seed 123456 # Output /remoll/filename test_pion.root # Shoot -/run/beamOn 1000 +/run/beamOn 100 diff --git a/macros/tests/commit/test_power.mac b/macros/tests/commit/test_power.mac index 581ab89f6..d664abf98 100644 --- a/macros/tests/commit/test_power.mac +++ b/macros/tests/commit/test_power.mac @@ -1,7 +1,6 @@ # This must be called before initialize /remoll/geometry/setfile geometry/mollerMother.gdml /remoll/parallel/setfile geometry/mollerParallel.gdml -/remoll/physlist/parallel/enable # This must be explicitly called /run/initialize @@ -18,4 +17,4 @@ /remoll/filename test_power.root # Shoot -/run/beamOn 10000 +/run/beamOn 100 diff --git a/macros/tests/commit/test_raster.mac b/macros/tests/commit/test_raster.mac index 05d81c0d5..8c73dc499 100644 --- a/macros/tests/commit/test_raster.mac +++ b/macros/tests/commit/test_raster.mac @@ -1,7 +1,6 @@ # This must be called before initialize /remoll/geometry/setfile geometry/mollerMother.gdml /remoll/parallel/setfile geometry/mollerParallel.gdml -/remoll/physlist/parallel/enable # This must be explicitly called /run/initialize @@ -52,14 +51,11 @@ # Beam current for rate /remoll/beamcurr 85 microampere -# Make interactions with W, Cu, and Pb -# realistic rather than pure absorbers -/control/execute macros/kryptonite.mac - +# Seed /remoll/seed 123456 # Output /remoll/filename test_raster.root # Shoot -/run/beamOn 1000 +/run/beamOn 100 diff --git a/macros/tests/release/test_moller.mac b/macros/tests/release/test_moller.mac index 3a40ed168..83887d0e2 100644 --- a/macros/tests/release/test_moller.mac +++ b/macros/tests/release/test_moller.mac @@ -1,7 +1,6 @@ # This must be called before initialize /remoll/geometry/setfile geometry/mollerMother.gdml /remoll/parallel/setfile geometry/mollerParallel.gdml -/remoll/physlist/parallel/enable # This must be explicitly called /run/initialize @@ -40,10 +39,7 @@ # Beam current for rate /remoll/beamcurr 85 microampere -# Make interactions with W, Cu, and Pb -# realistic rather than pure absorbers -/control/execute macros/kryptonite.mac - +# Seed /remoll/seed 123456 # Output diff --git a/macros/tests/unit/test_fields_cubic.mac b/macros/tests/unit/test_fields_cubic.mac new file mode 100644 index 000000000..bdd38ef99 --- /dev/null +++ b/macros/tests/unit/test_fields_cubic.mac @@ -0,0 +1,54 @@ +/run/numberOfThreads 1 +/run/initialize + +/control/execute macros/load_magnetic_fieldmaps.mac + +/remoll/field/interpolation map_directory/V2DSg.9.75cm.txt linear +#0.35 -180 8.5 0.00357702902439 0.000508489642332 0.00792856854346 +/remoll/field/value 0.3500 0.0 8.50 +/remoll/field/value 0.3502 0.0 8.51 +/remoll/field/value 0.3504 0.0 8.52 +/remoll/field/value 0.3506 0.0 8.53 +/remoll/field/value 0.3508 0.0 8.54 +/remoll/field/value 0.3510 0.0 8.55 +/remoll/field/value 0.3512 0.0 8.56 +/remoll/field/value 0.3514 0.0 8.57 +/remoll/field/value 0.3516 0.0 8.58 +/remoll/field/value 0.3518 0.0 8.59 +/remoll/field/value 0.3520 0.0 8.60 +#0.352 -180 8.6 8.3868756498e-05 0.0241781282489 0.00052352054301 +/remoll/field/value 0.3522 0.0 8.61 +/remoll/field/value 0.3524 0.0 8.62 +/remoll/field/value 0.3526 0.0 8.63 +/remoll/field/value 0.3528 0.0 8.64 +/remoll/field/value 0.3530 0.0 8.65 +/remoll/field/value 0.3532 0.0 8.66 +/remoll/field/value 0.3534 0.0 8.67 +/remoll/field/value 0.3536 0.0 8.68 +/remoll/field/value 0.3538 0.0 8.69 +/remoll/field/value 0.3540 0.0 8.70 + +/remoll/field/interpolation map_directory/V2DSg.9.75cm.txt cubic +#0.35 -180 8.5 0.00357702902439 0.000508489642332 0.00792856854346 +/remoll/field/value 0.3500 0.0 8.50 +/remoll/field/value 0.3502 0.0 8.51 +/remoll/field/value 0.3504 0.0 8.52 +/remoll/field/value 0.3506 0.0 8.53 +/remoll/field/value 0.3508 0.0 8.54 +/remoll/field/value 0.3510 0.0 8.55 +/remoll/field/value 0.3512 0.0 8.56 +/remoll/field/value 0.3514 0.0 8.57 +/remoll/field/value 0.3516 0.0 8.58 +/remoll/field/value 0.3518 0.0 8.59 +/remoll/field/value 0.3520 0.0 8.60 +#0.352 -180 8.6 8.3868756498e-05 0.0241781282489 0.00052352054301 +/remoll/field/value 0.3522 0.0 8.61 +/remoll/field/value 0.3524 0.0 8.62 +/remoll/field/value 0.3526 0.0 8.63 +/remoll/field/value 0.3528 0.0 8.64 +/remoll/field/value 0.3530 0.0 8.65 +/remoll/field/value 0.3532 0.0 8.66 +/remoll/field/value 0.3534 0.0 8.67 +/remoll/field/value 0.3536 0.0 8.68 +/remoll/field/value 0.3538 0.0 8.69 +/remoll/field/value 0.3540 0.0 8.70 diff --git a/macros/tests/unit/test_gen_beam_raster.mac b/macros/tests/unit/test_gen_beam_raster.mac index 8f1e420b3..3a90db14c 100644 --- a/macros/tests/unit/test_gen_beam_raster.mac +++ b/macros/tests/unit/test_gen_beam_raster.mac @@ -1,7 +1,7 @@ /run/initialize /remoll/evgen/set beam /remoll/filename remollout_default_raster.root -/run/beamOn 1000 +/run/beamOn 100 /remoll/evgen/beam/origin 0 0 -5 m /remoll/evgen/beam/direction 0 0 1 @@ -12,4 +12,4 @@ /remoll/evgen/beam/corrx 0.5 /remoll/evgen/beam/corry 0.1 /remoll/filename remollout_strange_raster.root -/run/beamOn 1000 +/run/beamOn 100 diff --git a/macros/tests/unit/test_physlist_4.mac b/macros/tests/unit/test_physlist_4.mac deleted file mode 100644 index 607c4cd44..000000000 --- a/macros/tests/unit/test_physlist_4.mac +++ /dev/null @@ -1,6 +0,0 @@ -# Register already loaded physics list -/remoll/physlist/register QGSP_BERT_HP - -# Initialize and run -/run/initialize -/run/beamOn 1 diff --git a/macros/tests/unit/test_physlist_5.mac b/macros/tests/unit/test_physlist_5.mac deleted file mode 100644 index 0d69f5a15..000000000 --- a/macros/tests/unit/test_physlist_5.mac +++ /dev/null @@ -1,12 +0,0 @@ -# List physics lists -/remoll/physlist/list - -# Register different physics list -/remoll/physlist/register QGSP_BERT - -# Re-register default physics list -/remoll/physlist/register QGSP_BERT_HP - -# Initialize and run -/run/initialize -/run/beamOn 1 diff --git a/macros/tests/unit/test_polarization.mac b/macros/tests/unit/test_polarization.mac index 7f4c9ced6..3865db61e 100644 --- a/macros/tests/unit/test_polarization.mac +++ b/macros/tests/unit/test_polarization.mac @@ -4,7 +4,7 @@ /control/execute macros/load_magnetic_fieldmaps.mac -/remoll/gen moller +/remoll/evgen/set moller /remoll/field/equationtype 2 /run/beamOn 100 diff --git a/macros/tests/unit/test_rng_engine.C b/macros/tests/unit/test_rng_engine.C new file mode 100644 index 000000000..330427ec1 --- /dev/null +++ b/macros/tests/unit/test_rng_engine.C @@ -0,0 +1,4 @@ +{ + TFile f("remollout.root"); + T->Scan("seed.Save()"); +} diff --git a/macros/tests/unit/test_rng_engine.mac b/macros/tests/unit/test_rng_engine.mac new file mode 100644 index 000000000..32bb85a4f --- /dev/null +++ b/macros/tests/unit/test_rng_engine.mac @@ -0,0 +1,57 @@ +# Disable storing random state to events to fail this test +#/run/storeRndmStatToEvent 0 + +# Ensure rndm1 directory exists +/control/shell mkdir -p rndm1 +/random/setDirectoryName rndm1 +# Store random state to files +/random/setSavingFlag 1 +/random/saveEachEventFlag 1 + +# Run 10 events +/run/initialize +/run/beamOn 10 + +# Write all random states for run 1 +/control/shell reroot -l -q macros/tests/unit/test_rng_engine.C + +# Ensure rndm1 directory exists +/control/shell mkdir -p rndm2 +/random/setDirectoryName rndm2 + +# Convert random state for event 5 +# Note: resetEngineFromEachEvent reads from current directory +/control/shell scripts/convert-mixmaxrng-state.sh run0evt9.state > run1evt0.rndm +/control/shell scripts/convert-mixmaxrng-state.sh run0evt8.state > run1evt1.rndm +/control/shell scripts/convert-mixmaxrng-state.sh run0evt7.state > run1evt2.rndm +/control/shell scripts/convert-mixmaxrng-state.sh run0evt6.state > run1evt3.rndm +/control/shell scripts/convert-mixmaxrng-state.sh run0evt5.state > run1evt4.rndm +/control/shell scripts/convert-mixmaxrng-state.sh run0evt4.state > run1evt5.rndm +/control/shell scripts/convert-mixmaxrng-state.sh run0evt3.state > run1evt6.rndm +/control/shell scripts/convert-mixmaxrng-state.sh run0evt2.state > run1evt7.rndm +/control/shell scripts/convert-mixmaxrng-state.sh run0evt1.state > run1evt8.rndm +/control/shell scripts/convert-mixmaxrng-state.sh run0evt0.state > run1evt9.rndm + +# Reset engine for each event +/random/resetEngineFromEachEvent 1 + +# Run 10 events +/run/beamOn 10 + +# Write all random states for run 1 +/control/shell reroot -l -q macros/tests/unit/test_rng_engine.C + +# Compare random states on all events +/control/shell diff --ignore-matching-lines ^MixMaxRng-begin run0evt0.state run1evt9.state +/control/shell diff --ignore-matching-lines ^MixMaxRng-begin run0evt1.state run1evt8.state +/control/shell diff --ignore-matching-lines ^MixMaxRng-begin run0evt2.state run1evt7.state +/control/shell diff --ignore-matching-lines ^MixMaxRng-begin run0evt3.state run1evt6.state +/control/shell diff --ignore-matching-lines ^MixMaxRng-begin run0evt4.state run1evt5.state +/control/shell diff --ignore-matching-lines ^MixMaxRng-begin run0evt5.state run1evt4.state +/control/shell diff --ignore-matching-lines ^MixMaxRng-begin run0evt6.state run1evt3.state +/control/shell diff --ignore-matching-lines ^MixMaxRng-begin run0evt7.state run1evt2.state +/control/shell diff --ignore-matching-lines ^MixMaxRng-begin run0evt8.state run1evt1.state +/control/shell diff --ignore-matching-lines ^MixMaxRng-begin run0evt9.state run1evt0.state + +# Clean up +# rm -rf *.rndm *.state rndm1 rndm2 diff --git a/macros/tests/unit/test_sieve.mac b/macros/tests/unit/test_sieve.mac new file mode 100644 index 000000000..850c48f1a --- /dev/null +++ b/macros/tests/unit/test_sieve.mac @@ -0,0 +1,24 @@ +/remoll/geometry/setfile geometry/mollerMother_merged.gdml +/remoll/parallel/setfile geometry/mollerParallel.gdml + +/run/initialize + +/remoll/geometry/printoverlaps + +/control/execute macros/load_magnetic_fieldmaps.mac + +/remoll/kryptonite/volume sieve_sector_logic + +/remoll/SD/enable_range 1000 1010 + +/remoll/evgen/set moller + +/control/execute macros/sieve/sieve_in.mac +/remoll/filename test_sieve_in.root +/remoll/seed 123456 +/run/beamOn 10 + +/control/execute macros/sieve/sieve_out.mac +/remoll/filename test_sieve_out.root +/remoll/seed 123456 +/run/beamOn 10 diff --git a/macros/tests/unit/test_target.mac b/macros/tests/unit/test_target.mac index f8b1746fe..46949b1f3 100644 --- a/macros/tests/unit/test_target.mac +++ b/macros/tests/unit/test_target.mac @@ -1,5 +1,5 @@ /run/initialize /remoll/targname USAlTarg -/remoll/printtargetinfo +/remoll/target/print /run/beamOn 1 diff --git a/remoll.cc b/remoll.cc index 79d19f8e1..b4def9fe3 100644 --- a/remoll.cc +++ b/remoll.cc @@ -19,6 +19,8 @@ typedef G4RunManager RunManager; #include "G4Version.hh" #include "G4UImanager.hh" +#include "remollIO.hh" + #include "remollRun.hh" #include "remollRunData.hh" @@ -27,6 +29,8 @@ typedef G4RunManager RunManager; #include "remollDetectorConstruction.hh" #include "remollParallelConstruction.hh" +#include "remollSearchPath.hh" + #include "G4VisExecutive.hh" #include "G4UIExecutive.hh" @@ -42,7 +46,7 @@ typedef G4RunManager RunManager; namespace { void PrintUsage() { G4cerr << "Usage: " << G4endl; - G4cerr << " remoll [-g geometry] [-m macro] [-u UIsession] [-r seed] "; + G4cerr << " remoll [-f] [-g geometry] [-m macro] [-u UIsession] [-r seed] [-o outputfile] "; #ifdef G4MULTITHREADED G4cerr << "[-t nThreads] "; #endif @@ -61,6 +65,14 @@ int main(int argc, char** argv) { gROOT->Reset(); #endif + // Warn if LIBGL_ALWAYS_INDIRECT is set + if (std::getenv("LIBGL_ALWAYS_INDIRECT") != nullptr) { + G4cerr << "remoll: Environment variable LIBGL_ALWAYS_INDIRECT is set." << G4endl; + G4cerr << "remoll: This may interfere with visualization. Unset wih:" << G4endl; + G4cerr << "remoll: tcsh> unsetenv LIBGL_ALWAYS_INDIRECT" << G4endl; + G4cerr << "remoll: bash> unset LIBGL_ALWAYS_INDIRECT" << G4endl; + } + // Initialize the random seed G4long seed = time(0) + (int) getpid(); // Open /dev/urandom @@ -78,6 +90,8 @@ int main(int argc, char** argv) { G4String session; G4String geometry_gdmlfile; G4String parallel_gdmlfile; + G4String outputfile; + __attribute__((unused)) G4bool force = false; #ifdef G4MULTITHREADED G4int threads = 0; #endif @@ -88,6 +102,8 @@ int main(int argc, char** argv) { else if (G4String(argv[i]) == "-p") parallel_gdmlfile = argv[++i]; else if (G4String(argv[i]) == "-u") session = argv[++i]; else if (G4String(argv[i]) == "-r") seed = atol(argv[++i]); + else if (G4String(argv[i]) == "-o") outputfile = argv[++i]; + else if (G4String(argv[i]) == "-f") force = true; #ifdef G4MULTITHREADED else if (G4String(argv[i]) == "-t") threads = atoi(argv[++i]); #endif @@ -98,6 +114,27 @@ int main(int argc, char** argv) { } } + //------------------------------- + // Check dependency versions + //------------------------------- + #if G4VERSION_NUMBER < 1060 + if (! force) { + G4cerr << "WARNING: You are running with an older geant4 version." << G4endl; + G4cerr << "WARNING: The encouraged version of geant4 is 10.6.2." << G4endl; + G4cerr << "WARNING: Pass the option '-f' to ignore this warning." << G4endl; + exit(-1); + } + #endif + + #if ROOT_VERSION_CODE < ROOT_VERSION(6,14,4) + if (! force) { + G4cerr << "WARNING: You are running with an older ROOT version." << G4endl; + G4cerr << "WARNING: The encouraged version of ROOT is 6.14.4." << G4endl; + G4cerr << "WARNING: Pass the option '-f' to ignore this warning." << G4endl; + exit(-1); + } + #endif + //------------------------------- // Initialization of Run manager @@ -108,8 +145,15 @@ int main(int argc, char** argv) { #endif // Set the default random seed + G4cout << G4endl << "remoll: Random seed: " << seed << G4endl; G4Random::setTheSeed(seed); + // Create remoll IO object with output file name + if (outputfile.size() > 0) + remollIO::GetInstance(outputfile); + else + remollIO::GetInstance(); + // Detector geometry G4String material_name = "material"; remollDetectorConstruction* detector = new remollDetectorConstruction(material_name, geometry_gdmlfile); @@ -147,18 +191,27 @@ int main(int argc, char** argv) { G4cout << "remoll: see also https://github.com/JeffersonLab/remoll/issues/130" << G4endl; #endif + // Define UI session for interactive mode - if (macro.size()) + G4String searchpath = "."; + searchpath += ":" + std::string(CMAKE_INSTALL_FULL_DATADIR) + "/remoll"; + searchpath += ":" + std::string(CMAKE_INSTALL_FULL_DATADIR) + "/remoll/macros"; + if (macro.size() != 0u) { // Run in batch mode // Copy contents of macro into buffer to be written out into ROOT file - remollRun::GetRunData()->SetMacroFile(macro); - UImanager->ExecuteMacroFile(macro); + UImanager->SetMacroSearchPath(searchpath); + UImanager->ParseMacroSearchPath(); + remollRun::GetRunData()->SetMacroFile((remollSearchPath::resolve(macro)).c_str()); + UImanager->ExecuteMacroFile((remollSearchPath::resolve(macro)).c_str()); } else { // Define UI session for interactive mode G4UIExecutive* ui = new G4UIExecutive(argc,argv,session); - if (ui->IsGUI()) - UImanager->ApplyCommand("/control/execute macros/gui.mac"); + if (ui->IsGUI()) { + UImanager->SetMacroSearchPath(searchpath); + UImanager->ParseMacroSearchPath(); + UImanager->ExecuteMacroFile((remollSearchPath::resolve("macros/gui.mac")).c_str()); + } ui->SessionStart(); delete ui; } diff --git a/scripts/PunchThroughStudies/BlockerPunchThru.C b/scripts/PunchThroughStudies/BlockerPunchThru.C new file mode 100644 index 000000000..af3262d0b --- /dev/null +++ b/scripts/PunchThroughStudies/BlockerPunchThru.C @@ -0,0 +1,216 @@ +// Simple example macro for reroot analysis of remoll simulations for MOLLER +// +// Need to use reroot (CERN's root compiled with special remoll libraries, +// or root when you have linked to ibremoll.so, i.e. by a command like +// setenv LD_PRELOAD build/libremoll.so +// needs to have a subdirectory "images/Blocker" defined for the images to go to +// +// Run using (for example): +// build/reroot +// .L scripts/BlockerPunchThru090.C +// BlockerPunchThru090() +// +// Can put multiple root files in the script, and they will be chained together. +// +// This script will take root files of a certain Blocker thickness. It will first loop +// through the events and flag any in which a primary particle hits a Blocker hole. +// Then it will exclude these flagged events and plot electrons and positrons that hit +// upstream and downstream of the surface of the Blocker. Those particles that hit +// downstream of the surface are flagged as "punch through particles". +// Punch-through particles are plotted on the rings of the main detector. An +// xy plot and radial plot are included. Finally, all charged particles that reach the +// main detector rings are plotted (xy and r). + +#include +void BlockerPunchThru() +{ + //Allow Tree to use the root files that you call + TChain* T = new TChain("T"); + + //Add files from the directory "rootfilesPT/", "090" is the Blocker thickness in mm. Replace these root files with whatever root files you would like to analyze. + T->Add("rootfilesPT/blocker/WBlockerC12_ep_100k_090mm0.root"); + T->Add("rootfilesPT/blocker/WBlockerC12_ep_100k_090mm1.root"); + T->Add("rootfilesPT/blocker/WBlockerC12_ep_100k_090mm2.root"); + T->Add("rootfilesPT/blocker/WBlockerC12_ep_100k_090mm3.root"); + T->Add("rootfilesPT/blocker/WBlockerC12_ep_100k_090mm4.root"); + T->Add("rootfilesPT/blocker/WBlockerC12_ep_100k_090mm5.root"); + T->Add("rootfilesPT/blocker/WBlockerC12_ep_100k_090mm6.root"); + T->Add("rootfilesPT/blocker/WBlockerC12_ep_100k_090mm7.root"); + T->Add("rootfilesPT/blocker/WBlockerC12_ep_100k_090mm8.root"); + T->Add("rootfilesPT/blocker/WBlockerC12_ep_100k_090mm9.root"); + + //Define variables that we will loop over later + Double_t rate = 0; + std::vector* parts = 0; + std::vector* hits = 0; + + //Define some branches of the Tree (which is "T") + T->SetBranchAddress("rate", &rate); + T->SetBranchAddress("hit", &hits); + T->SetBranchAddress("part", &parts); + + gROOT -> SetBatch(kTRUE); + +//---------------------------------------------------------------------------- + + //Define Histograms that we will fill later + + //---Blocker Surfaces--- + + //2D histogram for e+ and e- hitting the upstream Blocker surface + TH2F *us_Blocker_virt = new TH2F("us_Blocker_virt","Upstream Blocker (090mm) Virtual Detector Charged Particle Hits", 100, -150, 150, 100, -150, 150); + us_Blocker_virt -> GetXaxis() -> SetTitle("x Position of Hits [mm]"); + us_Blocker_virt -> GetYaxis() -> SetTitle("y Position of Hits [mm]"); + + //2D histogram for e+ and e- hitting the downstream Blocker surface, i.e., the particles that punch through the Blocker + TH2F *ds_Blocker_virt = new TH2F("ds_Blocker_virt","Downstream Blocker (090mm) Virtual Detector Charged Particle Hits", 100, -150, 150, 100, -150, 150); + ds_Blocker_virt -> GetXaxis() -> SetTitle("x Position of Hits [mm]"); + ds_Blocker_virt -> GetYaxis() -> SetTitle("y Position of Hits [mm]"); + + //---Main Detector PT--- + + //1D histogram for e+ and e- that punch through the Blocker and make it to the main detector on the rings + TH1F *radial_main = new TH1F("radial_main","Energies of Charged Particles that Exited the Downstream Blocker (090mm) Surface and Hit the Main Detector", 50, 0, 1500); + radial_main -> GetXaxis() -> SetTitle("Energies of Hits [MeV]"); + + //2D histogram for particles that punch through the Blocker and make it to the main detector on the rings (xy plot) + TH2F *punch_thru_xy_main = new TH2F("punch_thru_xy_main","Charged Particles that Exited the Downstream Blocker (090mm) Surface and Hit the Main Detector", 100, -1200, 1200, 100, -1200, 1200); + punch_thru_xy_main -> GetXaxis() -> SetTitle("x Position of Hits [mm]"); + punch_thru_xy_main -> GetYaxis() -> SetTitle("y Position of Hits [mm]"); + + //---All Charged Particles--- + + //1D histogram for e+ and e- that make it to the main detector on the rings + TH1F *radial_main_all = new TH1F("radial_main_all","Energies of All Charged Particles that Hit the Main Detector for a 090mm Blocker", 50, 0, 1500); + radial_main_all -> GetXaxis() -> SetTitle("Energies of Hits [MeV]"); + + //2D histogram for particles that make it to the main detector on the rings (xy plot) + TH2F *xy_main_all = new TH2F("xy_main_all","All Charged Particles that Hit the Main Detector for a 090mm Blocker", 100, -1200, 1200, 100, -1200, 1200); + xy_main_all -> GetXaxis() -> SetTitle("x Position of Hits [mm]"); + xy_main_all -> GetYaxis() -> SetTitle("y Position of Hits [mm]"); + + //---Booleans--- + + //Define logical flag for punch-through + bool punch_thru = false; + +//---------------------------------------------------------------------------- + + //Loop over all events + for (size_t iev = 0; iev < T->GetEntries(); iev++) + { + T->GetEntry(iev); + + punch_thru = false; + + //Process over hits + for (size_t ihit = 0; ihit < hits->size(); ihit++) + { + remollGenericDetectorHit_t hit = hits->at(ihit); + + if ((hit.pid==11 || hit.pid==-11)&& hit.r >=35.306 && hit.r<97.9932) + { + + if (hit.det == 1004 && hit.pz >= 0) + { + us_Blocker_virt -> Fill(hit.x, hit.y, rate); + }//end upstream if + + if (hit.det == 1005 && hit.pz >= 0) + { + ds_Blocker_virt -> Fill(hit.x, hit.y, rate); + //Flag particles as "punch through particles" + punch_thru = true; + }//end downstream if + + }//end pid and hole if + + }//end process over hits + + //process over hits again to look at the main detector + for (size_t ihit = 0; ihit < hits->size(); ihit++) + { + remollGenericDetectorHit_t hit = hits->at(ihit); + + //Only look at "punch through particles" that hit the main detector on rings 1-7 and make sure they are e- or e+ with positive z momentum. + if (punch_thru && hit.det==28 && hit.r>=650 && hit.r<=1200 && (hit.pid==11 || hit.pid==-11) && hit.pz>=0) + { + punch_thru_xy_main -> Fill(hit.x, hit.y, rate); + radial_main -> Fill(hit.e, rate); + }//end main det if + + //Only look at charged particles that hit the main detector on rings 1-7. + if (hit.det==28 && hit.r>=650 && hit.r<=1200 && hit.pz>=0 && (hit.pid==11 || hit.pid==-11)) + { + xy_main_all -> Fill(hit.x, hit.y, rate); + radial_main_all -> Fill(hit.e, rate); + }//end main det if + + }//end process over hits + }//end process over events + +//-------------------------------------------------------------------------------- +//Draw and save the histograms + + //---Blocker Surfaces--- + + //Create a canvas on which to draw the histograms + TCanvas *virt = new TCanvas("virt","Charged Particles Hitting the Virtual Detectors Upstream and Downstream of the Blocker", 1000, 1000, 1000, 1000); + + //Divide the canvas into 1 column, 2 rows + virt -> Divide(1,2); + + //Look at the first entry on the canvas and draw the upstream detector + virt -> cd(1); + us_Blocker_virt -> Draw("colz"); + + //Look at the second entry on the canvas and draw the downstream detector + virt -> cd(2); + ds_Blocker_virt -> Draw("colz"); + + //Save the canvas as an image in the director "remoll/images/Blocker/" + virt -> SaveAs("images/Blocker/Punch_Thru_US_DS_WBlocker_090.png"); + + + //---Main Detector PT--- + + //Create a canvas on which to draw the histograms + TCanvas *main = new TCanvas("main","Electrons and Positrons Hitting the Main Detector", 1000, 1000, 1000, 1000); + + //Divide the canvas into 1 column, 2 rows + main -> Divide(1,2); + + //Look at the first entry on the canvas and draw the xy main detector + main -> cd(1); + punch_thru_xy_main -> Draw("colz"); + + //Look at the second entry on the canvas and draw the r main detector + main -> cd(2); + radial_main -> Draw("B"); + + //Save the canvas as an image in the director "remoll/images/Blocker/" + main -> SaveAs("images/Blocker/Punch_Thru_Main_WBlocker_090.png"); + + + //---Main Detector--- + + //Create a canvas on which to draw the histograms + TCanvas *main_all_charged = new TCanvas("main_all_charged","Particles Hitting the Main Detector", 1000, 1000, 1000, 1000); + + //Divide the canvas into 1 column, 2 rows + main_all_charged -> Divide(1,2); + + //Look at the first entry on the canvas and draw the xy main detector + main_all_charged -> cd(1); + xy_main_all -> Draw("colz"); + + //Look at the second entry on the canvas and draw the r main detector + main_all_charged -> cd(2); + radial_main_all -> Draw("B"); + + //Save the canvas as an image in the director "remoll/images/Blocker/" + main_all_charged -> SaveAs("images/Blocker/Main_All_WBlocker_090.png"); + + +}//end BlockerPunchThru() + diff --git a/scripts/PunchThroughStudies/PunchThruC12ep.C b/scripts/PunchThroughStudies/PunchThruC12ep.C new file mode 100644 index 000000000..d26725e8e --- /dev/null +++ b/scripts/PunchThroughStudies/PunchThruC12ep.C @@ -0,0 +1,352 @@ +// Simple example macro for reroot analysis of remoll simulations for MOLLER +// +// Need to use reroot (CERN's root compiled with special remoll libraries, +// or root when you have linked to ibremoll.so, i.e. by a command like +// setenv LD_PRELOAD build/libremoll.so +// needs to have a subdirectory "images/NewPT" defined for the images to go to +// +// Run using (for example): +// build/reroot +// .L scripts/PunchThru90C12ep.C +// PunchThru90C12ep() +// +// Can put multiple root files in the script, and they will be chained together. You must +// specify which root files that this should run over. + +// This script was written with the intention of looking at ep scattering on the C12 +// thin target, but the script should work for any event generator and any target. +// +// This script will take root files of a certain sieve thickness, 90mm. It will first loop +// through the events and flag any in which a primary particle hits a sieve hole. +// Then it will exclude these flagged events and plot electrons and positrons that hit +// upstream and downstream of the surface of the sieve. Those particles that hit +// downstream of the surface are flagged as "punch through particles". +// Punch-through particles are plotted on the rings of the main detector. An +// xy plot and radial plot are included. Finally, all charged particles that reach the +// main detector rings are plotted (xy and r). +// +// Addition: I now also plot electrons and positrons that hit the main detector after +// passing through the sieve holes. This is so that I can look at the amount of noise our +// signal is likely to see. + +#include +void PunchThruC12ep() +{ + //Allow Tree to use the root files that you call + TChain* T = new TChain("T"); + + //Add files from the directory "rootfilesPT/", "90" is the sieve thickness in mm. Replace these root files with whatever root files you would like to analyze. + T->Add("rootfilesPT/WSieveC12_ep_100k_90mm0.root"); + T->Add("rootfilesPT/WSieveC12_ep_100k_90mm1.root"); + T->Add("rootfilesPT/WSieveC12_ep_100k_90mm2.root"); + T->Add("rootfilesPT/WSieveC12_ep_100k_90mm3.root"); + T->Add("rootfilesPT/WSieveC12_ep_100k_90mm4.root"); + T->Add("rootfilesPT/WSieveC12_ep_100k_90mm5.root"); + T->Add("rootfilesPT/WSieveC12_ep_100k_90mm6.root"); + T->Add("rootfilesPT/WSieveC12_ep_100k_90mm7.root"); + T->Add("rootfilesPT/WSieveC12_ep_100k_90mm8.root"); + T->Add("rootfilesPT/WSieveC12_ep_100k_90mm9.root"); + + //Define variables that we will loop over later + Double_t rate = 0; + std::vector* parts = 0; + std::vector* hits = 0; + + //Define some branches of the Tree (which is "T") + T->SetBranchAddress("rate", &rate); + T->SetBranchAddress("hit", &hits); + T->SetBranchAddress("part", &parts); + + gROOT -> SetBatch(kTRUE); + +//---------------------------------------------------------------------------- + +//Define Histograms that we will fill later + + //---Sieve surface histograms--- + + //2D histogram for e+ and e- hitting the upstream sieve surface + TH2F *us_sieve_virt = new TH2F("us_sieve_virt","Upstream Sieve (90mm) Virtual Detector Charged Particle Hits for ep Scattering with Thin Carbon Target", 7000, -150, 150, 7000, -150, 150); + us_sieve_virt -> GetXaxis() -> SetTitle("x Position of Hits [mm]"); + us_sieve_virt -> GetYaxis() -> SetTitle("y Position of Hits [mm]"); + + //2D histogram for e+ and e- hitting the downstream sieve surface, i.e., the particles that punch through the sieve + TH2F *ds_sieve_virt = new TH2F("ds_sieve_virt","Downstream Sieve (90mm) Virtual Detector Charged Particle Hits for ep Scattering with Thin Carbon Target", 7000, -150, 150, 7000, -150, 150); + ds_sieve_virt -> GetXaxis() -> SetTitle("x Position of Hits [mm]"); + ds_sieve_virt -> GetYaxis() -> SetTitle("y Position of Hits [mm]"); + + //---Main detector histograms--- + + //2D histogram for e+ and e- that punch through the sieve and make it to the main detector on the rings (xy plot) + TH2F *punch_thru_main = new TH2F("punch_thru_main","Charged Particles that Exited the Downstream Sieve (90mm) Surface and Hit the Main Detector for ep Scattering with Thin Carbon Target", 1000, -1200, 1200, 1000, -1200, 1200); + punch_thru_main -> GetXaxis() -> SetTitle("x Position of Hits [mm]"); + punch_thru_main -> GetYaxis() -> SetTitle("y Position of Hits [mm]"); + + //1D histogram for e+ and e- that punch through the sieve and make it to the main detector on the rings (r plot) + TH1F *radial_main = new TH1F("radial_main","Charged Particles that Exit the Downstream Sieve (90mm) Surface and Hit the Main Detector", 1000, 650, 1200); + radial_main -> GetXaxis() -> SetTitle("r Position of Hits [mm]"); + + //2D histogram for electrons and positrons that make it to the main detector on the rings after passing through the sieve holes (xy plot) + TH2F *main_holes = new TH2F("main_holes","Charged Particles that Pass Through the Sieve Holes (90mm) and Hit the Main Detector for ep Scattering with Thin Carbon Target", 1000, -1200, 1200, 1000, -1200, 1200); + main_holes -> GetXaxis() -> SetTitle("x Position of Hits [mm]"); + main_holes -> GetYaxis() -> SetTitle("y Position of Hits [mm]"); + + //1D histogram for electrons and positrons that make it to the main detector on the rings after passing through the sieve holes (r plot) + TH1F *radial_main_holes = new TH1F("radial_main_holes","Charged Particles that Pass Through the Sieve Holes (90mm) and Hit the Main Detector", 1000, 650, 1200); + radial_main_holes -> GetXaxis() -> SetTitle("r Position of Hits [mm]"); + + //2D histogram for all electrons and positrons that make it to the main detector on the rings (xy plot) + TH2F *main_all = new TH2F("main_all","All Charged Particles that Hit the Main Detector for ep Scattering with Thin Carbon Target and a 90mm Sieve", 1000, -1200, 1200, 1000, -1200, 1200); + main_all -> GetXaxis() -> SetTitle("x Position of Hits [mm]"); + main_all -> GetYaxis() -> SetTitle("y Position of Hits [mm]"); + + //1D histogram for all electrons and positrons that make it to the main detector on the rings (r plot) + TH1F *radial_main_all = new TH1F("radial_main_all","All Charged Particles that Hit the Main Detector for ep Scattering with Thin Carbon Target and a 90mm Sieve", 1000, 650, 1200); + radial_main_all -> GetXaxis() -> SetTitle("r Position of Hits [mm]"); + +//---------------------------------------------------------------------------- + + //Define logical flag for each hole + bool no_hole_1 = false; + bool no_hole_2 = false; + bool no_hole_3 = false; + + bool hole_1 = false; + bool hole_2 = false; + bool hole_3 = false; + + //Define logical flag for punch-through. When this is true, it means that we are looking at perticles that exit the downstream surface of the sieve. + bool punch_thru = false; + +//---------------------------------------------------------------------------- + + //Loop over all events + for (size_t iev = 0; iev < T->GetEntries(); iev++) + { + T->GetEntry(iev); + + //Define initial values for booleans + no_hole_1 = true; + no_hole_2 = true; + no_hole_3 = true; + punch_thru = false; + + //Process hits, i.e., loop over all the hits in this event + for (size_t ihit = 0; ihit < hits->size(); ihit++) + { + remollGenericDetectorHit_t hit = hits->at(ihit); + + //no_hole_# is false if the primary electron goes through the hole + if (hit.det == 1001 && (hit.trid == 1)) + { + no_hole_1 = false; + } + + if (hit.det == 1002 && (hit.trid == 1)) + { + no_hole_2 = false; + } + + if (hit.det == 1003 && (hit.trid == 1)) + { + no_hole_3 = false; + } + }//end process over hits + + //Process over hits again + for (size_t ihit = 0; ihit < hits->size(); ihit++) + { + remollGenericDetectorHit_t hit = hits->at(ihit); + + //Look at only charged particles for events in which a primary electron did NOT go through a sieve hole. The radial restriction is to focus on only the sieve surface. + if ((hit.pid==11 || hit.pid==-11) && no_hole_1 && no_hole_2 && no_hole_3 && hit.r >=35.306 && hit.r<97.9932) + { + + //Look at only the virtual detector placed exactly upstream of the sieve and ensure that we are only looking at particles with positive z momentum. + if (hit.det == 1004 && hit.pz >= 0) + { + //Fill the histogram that plots only particles that hit the upstream sieve surface + us_sieve_virt -> Fill(hit.x, hit.y, rate); + }//end upstream if + + if (hit.det == 1005 && hit.pz >= 0) + { + //Fill the histogram that plots only particles that exit the downstream sieve surface + ds_sieve_virt -> Fill(hit.x, hit.y, rate); + //Flag particles as "punch through particles" + punch_thru = true; + }//end downstream if + + }//end pid and hole if + + }//end process over hits + + //process over hits again to look at the main detector + for (size_t ihit = 0; ihit < hits->size(); ihit++) + { + remollGenericDetectorHit_t hit = hits->at(ihit); + + //Only look at "punch through particles" that hit the main detector on rings 1-7 and make sure they are e- or e+ with positive z momentum. + if (punch_thru && hit.det==28 && hit.r>=650 && hit.r<=1200 && (hit.pid==11 || hit.pid==-11) && hit.pz>=0) + { + //Fill histogram for charged particles that exit the downstream surface of the sieve and reach the main detector. + punch_thru_main -> Fill(hit.x, hit.y, rate); + //This is the same plot as above but is radial instead of xy. + radial_main -> Fill(hit.r, rate); + }//end main det if + + }//end process over hits + + }//end process over events + +//---------------------------------------------------------------------------- + + //Loop over all events to flag the holes differently. + for (size_t iev = 0; iev < T->GetEntries(); iev++) + { + T->GetEntry(iev); + + hole_1 = false; + hole_2 = false; + hole_3 = false; + + //Process over hits to look at the main detector + for (size_t ihit = 0; ihit < hits->size(); ihit++) + { + remollGenericDetectorHit_t hit = hits->at(ihit); + + //Look at all charged particles that hit the main detector on rings 1-7 and make sure they are e- or e+ with positive z momentum. + if (hit.det==28 && hit.r>=650 && hit.r<=1200 && (hit.pid==11 || hit.pid==-11) && hit.pz>=0) + { + //Fill a histogram with ALL charged particles that hit the main detector. + main_all -> Fill(hit.x, hit.y, rate); + //This is the same plot as above but is radial instead of xy. + radial_main_all -> Fill(hit.r, rate); + }//end hole and radius if + + }//end process over hits + + //Process hits, i.e., loop over all the hits in this event + for (size_t ihit = 0; ihit < hits->size(); ihit++) + { + remollGenericDetectorHit_t hit = hits->at(ihit); + + //hole_# is true if the primary electron goes through the hole + if (hit.det == 1001 && (hit.trid == 1)) + { + hole_1 = true; + } + + if (hit.det == 1002 && (hit.trid == 1)) + { + hole_2 = true; + } + + if (hit.det == 1003 && (hit.trid == 1)) + { + hole_3 = true; + } + + }//end process over hits + + //process over hits to look at the main detector + for (size_t ihit = 0; ihit < hits->size(); ihit++) + { + remollGenericDetectorHit_t hit = hits->at(ihit); + + //Only look at sieve hole particles that hit the main detector on rings 1-7 and make sure they are e- or e+ with positive z momentum. + if ((hole_1 || hole_2 || hole_3) && hit.det==28 && hit.r>=650 && hit.r<=1200 && (hit.pid==11 || hit.pid==-11) && hit.pz>=0) + { + //Fill the histogram that plots the charged particles that go through the sieve holes. + main_holes -> Fill(hit.x, hit.y, rate); + //This is the same plot as above but is radial instead of xy. + radial_main_holes -> Fill(hit.r, rate); + }//end hole and radius if + + }//end process over hits + + }//end process over events + + +//-------------------------------------------------------------------------------- +//Draw and save the histograms + + //---Sieve Surfaces--- + + //Create a canvas on which to draw the histograms + TCanvas *virt = new TCanvas("virt","Charged Particles Hitting the Virtual Detectors Upstream and Downstream of the Sieve", 1000, 1000, 1000, 1000); + + //Divide the canvas into 1 column, 2 rows + virt -> Divide(1,2); + + //Look at the first entry on the canvas and draw the upstream detector + virt -> cd(1); + us_sieve_virt -> Draw(); + + //Look at the second entry on the canvas and draw the downstream detector + virt -> cd(2); + ds_sieve_virt -> Draw(); + + //Save the canvas as an image in the director "remoll/images/PT/" + virt -> SaveAs("images/NewPT/Punch_Thru_US_DS_WSieve_90.png"); + + //---Main Detector Punch Through--- + + //Create a canvas on which to draw the histograms + TCanvas *main = new TCanvas("main","Electrons and Positrons Hitting the Main Detector", 1000, 1000, 1000, 1000); + + //Divide the canvas into 1 column, 2 rows + main -> Divide(1,2); + + //Look at the first entry on the canvas and draw the xy main detector + main -> cd(1); + punch_thru_main -> Draw(); + + //Look at the second entry on the canvas and draw the r main detector + main -> cd(2); + radial_main -> Draw(); + + //Save the canvas as an image in the director "remoll/images/PT/" + main -> SaveAs("images/NewPT/Punch_Thru_Main_WSieve_90.png"); + + + //---Main Detector All--- + + //Create a canvas on which to draw the histograms + TCanvas *main_for_all = new TCanvas("main_for_all","Particles Hitting the Main Detector", 1000, 1000, 1000, 1000); + + //Divide the canvas into 1 column, 2 rows + main_for_all -> Divide(1,2); + + //Look at the first entry on the canvas and draw the xy main detector + main_for_all -> cd(1); + main_all -> Draw(); + + //Look at the second entry on the canvas and draw the r main detector + main_for_all -> cd(2); + radial_main_all -> Draw(); + + //Save the canvas as an image in the director "remoll/images/PT/" + main_for_all -> SaveAs("images/NewPT/Punch_Thru_Main_All_WSieve_90.png"); + + //---Main Detector Holes--- + + //Create a canvas on which to draw the histograms + TCanvas *main_for_holes = new TCanvas("main_for_holes","Particles Hitting the Main Detector", 1000, 1000, 1000, 1000); + + //Divide the canvas into 1 column, 2 rows + main_for_holes -> Divide(1,2); + + //Look at the first entry on the canvas and draw the xy main detector + main_for_holes -> cd(1); + main_holes -> Draw(); + + //Look at the second entry on the canvas and draw the r main detector + main_for_holes -> cd(2); + radial_main_holes -> Draw(); + + //Save the canvas as an image in the director "remoll/images/PT/" + main_for_holes -> SaveAs("images/NewPT/Punch_Thru_Main_Holes_WSieve_90.png"); + +}//end PunchThru90C12ep() + diff --git a/scripts/convert-mixmaxrng-state.sh b/scripts/convert-mixmaxrng-state.sh new file mode 100755 index 000000000..905f027ab --- /dev/null +++ b/scripts/convert-mixmaxrng-state.sh @@ -0,0 +1,77 @@ +#!/bin/bash + +if [ $# -lt 1 ] ; then + echo "Convert the MixMaxRNG engine state stream format into rndm file format." + echo "Usage (to stdout): `basename $0` [infile]" + exit +fi + +# Convert file format like +# +#MixMaxRng-begin 30331785 +#58933861902009719 +#1785835428502820402 +#1423853375428307990 +#177508786414027104 +#605196243949405736 +#861701010447754611 +#2250242789326832084 +#1084033761752659819 +#1855444124088891051 +#242731982633356449 +#808181319309293506 +#1276833616859972515 +#632930668351273437 +#1854356059141373284 +#1573087033096440666 +#1508189008866546922 +#2274580468617938516 +#1 +#1826895464979352203 +#MixMaxRng-end +# +# written by +# +#std::ostream & MixMaxRng::put ( std::ostream& os ) const +#{ +# char beginMarker[] = "MixMaxRng-begin"; +# char endMarker[] = "MixMaxRng-end"; +# +# int pr = os.precision(24); +# os << beginMarker << " "; +# os << theSeed << "\n"; +# for (int i=0; i run${run}evt0.rndm + let run=run+1 + shift +done diff --git a/scripts/scan.sh b/scripts/scan.sh new file mode 100755 index 000000000..6bf117d31 --- /dev/null +++ b/scripts/scan.sh @@ -0,0 +1,154 @@ +#!/bin/bash + +# Takes 5 arguments +# +# Fixed value of non-scanned variable - default = 0.0 +# Variable to scan ("angle" or "x") - default = "angle" +# Min of scanned variable - default = -30 +# Max of scanned variable - default = 30 +# Step size - default = 0.5 + +if [ "$#" -lt 1 ] ; then + echo " ERROR, requires at least one input + " + echo " usage: ./scan.sh fixed-non-scanned \"variable-to-scan\" min-of-scan (-30) max-of-scan (30) step-size (0.5) + Takes 9 arguments + + Fixed value of non-scanned variable - default = 0.0 + Variable to scan (\"angle\" or \"x\") - default = \"angle\" + Min of scanned variable - default = -30 + Max of scanned variable - default = 30 + Step size - default = 0.5 + Reflectivity of light guide - default = 0.9 + Cerenkov - default = 1.0 + Scintillation - default = 1.0 + z Position of beam origin - default = -11.0 + geometry file name - default = \"Mainz\"" + exit +fi +fixed="$1" +scanned="angle" +scanMin=-30.0 +scanMax=30.0 +scanStep=0.5 +reflectivity=0.9 +cerenkov=1 +scintillation=1 +#z_pos=-52.0 +z_pos=0.0 +geom="Mainz" +if [ "$#" -gt 1 ] ; then + scanned="$2" +fi +if [ "$#" -gt 2 ] ; then + scanMin=$3 +fi +if [ "$#" -gt 3 ] ; then + scanMax=$4 +fi +if [ "$#" -gt 4 ] ; then + scanStep=$5 +fi +if [ "$#" -gt 5 ] ; then + reflectivity=$6 +fi +if [ "$#" -gt 6 ] ; then + cerenkov=$(printf "%.0f" "$7") +fi +if [ "$#" -gt 7 ] ; then + scintillation=$(printf "%.0f" "$8") +fi +if [ "$#" -gt 8 ] ; then + z_pos=$9 +fi +if [ "$#" -gt 9 ] ; then + geom="${10}" +fi + +angle=0.0 +x_pos=0.0 + +numSteps=$(printf "%.0f" "$(bc -l <<< \(${scanMax}-\(${scanMin}\)\)/$scanStep)") +fixed=$(printf "%.1f" "$(bc -l <<< 1.0*$fixed)") +z_point=0.0 + +defaultName="qsimout.root" +outputName="qsimout.root" +name="0.0_degrees_0.0_x" + +cer="true" +scint="true" +if [[ $cerenkov > 0.0 ]] ; then + cer="true" +else + cer="false" +fi +if [[ $scintillation > 0.0 ]] ; then + scint="true" +else + scint="false" +fi + +#tmpFolder="${scanned}_${fixed}" +#if [ ! -d $tmpFolder ] ; then +# mkdir $tmpFolder +#fi + +for currentStep in `seq 0 $numSteps`; +do + point=$(printf "%.1f" "$(bc -l <<< \($scanMin+\(1.0*$currentStep*$scanStep\)\))") + if [[ "$scanned" == "angle" ]] ; then + x_pos=$fixed + angle=$point + fi + if [[ "$scanned" == "x" ]] ; then + x_pos=$point + angle=$fixed + fi + name="${angle}_degrees_${x_pos}_x_${z_pos}_z_${reflectivity}_ref_${cerenkov}_cer_${scintillation}_scint" + cp preserve_recreate-brad.mac recreate-brad_${geom}_${name}.mac + # FIXME This angle is hardcoded to the qsim-matching case!! + # 0.1994 = sin(11.5 degrees), $fixed is the distance from 0.0, + is farther towards PMT, further back away from +z axis + # 0.104528 = sin(6 degrees) + z_point=$(printf "%.1f" "$(bc -l <<< ${z_pos}+\($x_pos*0.1045\))") + # FIXME z_point and x offset relationships assume the detector is immediately downstream of the origin, and ideally centered at the middle of the lightguide + #z_point=$(printf "%.1f" "$(bc -l <<< -11.0-\($fixed*0.1994\))") + sed -i 's;'"/remoll/evgen/beam/th -11.5 deg"';'"/remoll/evgen/beam/th ${angle} deg"';g' recreate-brad_${geom}_${name}.mac + sed -i 's;'"/remoll/evgen/beam/origin 0.0 0.0 0.0 mm"';'"/remoll/evgen/beam/origin ${x_pos} 0.0 ${z_point} cm"';g' recreate-brad_${geom}_${name}.mac + + sed -i 's;'"/remoll/setgeofile geometry_Mainz/mollerMother_Mainz.gdml"';'"/remoll/setgeofile mollerMother_${geom}.gdml"';g' recreate-brad_${geom}_${name}.mac + + sed -i 's;'"/remoll/evgen/beam/rasterRefZ 0.0 mm"';'"/remoll/evgen/beam/rasterRefZ ${z_point} cm"';g' recreate-brad_${geom}_${name}.mac + + sed -i 's;'"/process/optical/processActivation Cerenkov false"';'"/process/optical/processActivation Cerenkov ${cer}"';g' recreate-brad_${geom}_${name}.mac + sed -i 's;'"/process/optical/processActivation Scintillation false"';'"/process/optical/processActivation Scintillation ${scint}"';g' recreate-brad_${geom}_${name}.mac + sed -i 's;'"Mainz_0.0_degrees_0.0_x.root"';'"${geom}_${name}.root"';g' recreate-brad_${geom}_${name}.mac + tmpFolder="out_${geom}_${name}" + if [ ! -d $tmpFolder ] ; then + mkdir $tmpFolder + fi + cd $tmpFolder + cp -p ../../build/remoll . + cp -p ../../geometry_Mainz/materialsOptical.xml . + cp -p ../../geometry_Mainz/*${geom}.* . + cp ../../geometry_Mainz/preserve_matrices_${geom}.xml matrices_${geom}.xml + sed -i 's;'"2.00214948263953\*eV 0.9"';'"2.00214948263953\*eV ${reflectivity}"';g' matrices_${geom}.xml + sed -i 's;'"7.75389038185112\*eV 0.9"';'"7.75389038185112\*eV ${reflectivity}"';g' matrices_${geom}.xml + cp ../pe . + mv ../recreate-brad_${geom}_${name}.mac . + #source /share/apps/root-5.34.36-build/bin/thisroot.sh + ./remoll recreate-brad_${geom}_${name}.mac + #cd ../ + #./build/remoll macros/recreate-brad_${geom}_${name}.mac + #cd - + #source /share/apps/root-6.14.06-build/bin/thisroot.sh + #cd $tmpFolder + ./pe remollout_${geom}_${name}.root 540210 ${angle} ${x_pos} ${reflectivity} ${cerenkov} ${scintillation} ${z_point} + #../pe ../../remollout_${geom}_${name}.root 540210 ${reflectivity} ${cerenkov} ${scintillation} ${z_point} + #source /share/apps/root-5.34.36-build/bin/thisroot.sh + convert remollout_${geom}_${name}*.png remollout_${geom}_${name}.pdf + rm remollout_${geom}_${name}*.png + rm remollout_${geom}_${name}.root + rm remollout_${geom}_${name}_PEs_det_540210.root + cd - +done diff --git a/scripts/tests/test_macros.sh b/scripts/tests/test_macros.sh index 970f52a3f..44cf1df56 100755 --- a/scripts/tests/test_macros.sh +++ b/scripts/tests/test_macros.sh @@ -61,6 +61,11 @@ if [ "$suite" == "valgrind" ] ; then echo fi +# Accumulate timing information +mkdir -p ${logfiles} +rm -rf ${logfiles}/time.log +export TIME="%E real,\t%U user,\t%S sys,\t%C" +time="time -a -o ${logfiles}/time.log" # Run test suite macros as requested for macro in ${macros}/${macroglob} ; do @@ -72,7 +77,7 @@ for macro in ${macros}/${macroglob} ; do # Run remoll macro mkdir -p ${logfiles} - time $prefix remoll ${macro} 2>&1 | tee ${logfiles}/${name}.log + $time $prefix remoll ${macro} 2>&1 | tee ${logfiles}/${name}.log # Unit tests do not have output if [ "$suite" == "unit" ] ; then @@ -95,7 +100,8 @@ for macro in ${macros}/${macroglob} ; do echo "Starting analysis..." | tee ${logfiles}/analysis/${name}.log for rootmacro in ${analysis1}/${analysisglob} ${analysis2}/${analysisglob} ; do echo "Running analysis macro `basename ${rootmacro} .C`..." - time reroot -q -b -l "${rootmacro}+(\"${rootfiles}\",\"${name}\")" 2>&1 | tee -a ${logfiles}/analysis/${name}.log + $time reroot -q -b -l "${rootmacro}+(\"${rootfiles}\",\"${name}\")" 2>&1 | tee -a ${logfiles}/analysis/${name}.log done done +cat ${logfiles}/time.log diff --git a/src/HepMCG4AsciiInterface.cc b/src/HepMCG4AsciiInterface.cc index c918297b9..a6a5f73af 100644 --- a/src/HepMCG4AsciiInterface.cc +++ b/src/HepMCG4AsciiInterface.cc @@ -63,7 +63,7 @@ void HepMCG4AsciiInterface::Initialize() HepMC::GenEvent* HepMCG4AsciiInterface::GenerateHepMCEvent() { HepMC::GenEvent* evt= asciiInput-> read_next_event(); - if(!evt) return 0; // no more event + if(evt == nullptr) return 0; // no more event if(verbose>0) evt-> print(); diff --git a/src/HepMCG4Interface.cc b/src/HepMCG4Interface.cc index 580ca5733..a3e7bb61f 100644 --- a/src/HepMCG4Interface.cc +++ b/src/HepMCG4Interface.cc @@ -49,7 +49,7 @@ HepMCG4Interface::HepMCG4Interface() //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... HepMCG4Interface::~HepMCG4Interface() { - if (hepmcEvent) delete hepmcEvent; + delete hepmcEvent; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... @@ -81,7 +81,7 @@ void HepMCG4Interface::HepMC2G4(const HepMC::GenEvent* hepmcevt, pitr = (*vitr)->particles_begin(HepMC::children); pitr != (*vitr)->particles_end(HepMC::children); ++pitr) { - if (!(*pitr)->end_vertex() && (*pitr)->status() == 1) { + if (((*pitr)->end_vertex() == nullptr) && (*pitr)->status() == 1) { qvtx = true; break; } @@ -127,11 +127,11 @@ HepMC::GenEvent* HepMCG4Interface::GenerateHepMCEvent() void HepMCG4Interface::GeneratePrimaryVertex(G4Event* anEvent) { // delete previous event object - if (hepmcEvent) delete hepmcEvent; + delete hepmcEvent; // generate next event hepmcEvent = GenerateHepMCEvent(); - if (! hepmcEvent) { + if (hepmcEvent == nullptr) { G4cout << "HepMCInterface: no generated particles. run terminated..." << G4endl; G4RunManager::GetRunManager()->AbortRun(); diff --git a/src/remollBeamTarget.cc b/src/remollBeamTarget.cc index 584855941..30d9d1111 100644 --- a/src/remollBeamTarget.cc +++ b/src/remollBeamTarget.cc @@ -1,3 +1,4 @@ +#include "G4Box.hh" #include "G4Tubs.hh" #include "G4VPhysicalVolume.hh" #include "G4LogicalVolume.hh" @@ -10,8 +11,6 @@ #include "G4RunManager.hh" #endif -#include "G4GenericMessenger.hh" - #include "G4GeometryManager.hh" #include "G4SystemOfUnits.hh" #include "G4PhysicalConstants.hh" @@ -19,25 +18,25 @@ #include "Randomize.hh" #include "remollBeamTarget.hh" -#include "remollMultScatt.hh" #include -#define __MAX_MAT 100 - #include "G4Threading.hh" #include "G4AutoLock.hh" namespace { G4Mutex remollBeamTargetMutex = G4MUTEX_INITIALIZER; } // Initialize static geometry objects -G4String remollBeamTarget::fActiveTargetVolume = "h2Targ"; -G4VPhysicalVolume* remollBeamTarget::fTargetMother = 0; -std::vector remollBeamTarget::fTargetVolumes; +G4String remollBeamTarget::fActiveTargetMotherName = "LH2"; +G4String remollBeamTarget::fActiveTargetVolumeName = "LH2"; +size_t remollBeamTarget::fActiveTargetMother = 0; +size_t remollBeamTarget::fActiveTargetVolume = 0; +std::vector> remollBeamTarget::fTargetMothers; +std::vector>> remollBeamTarget::fTargetVolumes; G4double remollBeamTarget::fActiveTargetEffectiveLength = -1e9; G4double remollBeamTarget::fMotherTargetAbsolutePosition = -1e9; -G4double remollBeamTarget::fActiveTargetRelativePosition = -1e9; G4double remollBeamTarget::fTotalTargetEffectiveLength = 0.0; +G4bool remollBeamTarget::fUpdateNeeded = true; remollBeamTarget::remollBeamTarget() : fBeamEnergy(gDefaultBeamE),fBeamCurrent(gDefaultBeamCur),fBeamPolarization(gDefaultBeamPol), @@ -45,9 +44,6 @@ remollBeamTarget::remollBeamTarget() fX0(0.0),fY0(0.0),fTh0(0.0),fPh0(0.0), fdTh(0.0),fdPh(0.0),fCorrTh(0.0),fCorrPh(0.0) { - // Create new multiple scattering - fMS = new remollMultScatt(); - // Infrared energy cutoff fEnergyCut = 1e-6 * MeV; @@ -55,61 +51,71 @@ remollBeamTarget::remollBeamTarget() fDefaultMat = new G4Material("Default_proton", 1.0, 1.0, 1e-19*g/mole); // Create generic messenger - fMessenger = new G4GenericMessenger(this,"/remoll/","Remoll properties"); - fMessenger->DeclareMethod("targname",&remollBeamTarget::SetActiveTargetVolume,"Target name").SetStates(G4State_Idle); - fMessenger->DeclareMethod("printtargetinfo",&remollBeamTarget::PrintTargetInfo).SetStates(G4State_Idle); - - fMessenger->DeclarePropertyWithUnit("beamcurr","microampere",fBeamCurrent,"Beam current"); - fMessenger->DeclarePropertyWithUnit("beamene","GeV",fBeamEnergy,"Beam energy"); - - fMessenger->DeclareProperty("oldras",fOldRaster,"Old (no ang corln) or new (ang corl) raster"); - fMessenger->DeclarePropertyWithUnit("rasx","cm",fRasterX,"Square raster width x (horizontal)"); - fMessenger->DeclarePropertyWithUnit("rasy","cm",fRasterY,"Square raster width y (vertical)"); - - fMessenger->DeclarePropertyWithUnit("beam_x0","cm",fX0,"beam initial position in x (horizontal)"); - fMessenger->DeclarePropertyWithUnit("beam_y0","cm",fY0,"beam initial position in y (vertical)"); - fMessenger->DeclarePropertyWithUnit("beam_ph0","deg",fPh0,"beam initial direction in x (horizontal)"); - fMessenger->DeclarePropertyWithUnit("beam_th0","deg",fTh0,"beam initial direction in y (vertical)"); - fMessenger->DeclarePropertyWithUnit("beam_corrph","deg",fCorrPh,"beam correlated angle (horizontal)"); - fMessenger->DeclarePropertyWithUnit("beam_corrth","deg",fCorrTh,"beam correlated angle (vertical)"); - fMessenger->DeclarePropertyWithUnit("beam_dph","deg",fdPh,"beam gaussian spread in x (horizontal)"); - fMessenger->DeclarePropertyWithUnit("beam_dth","deg",fdTh,"beam gaussian spread in y (vertical)"); + fMessenger.DeclarePropertyWithUnit("beamcurr","microampere",fBeamCurrent,"Beam current"); + fMessenger.DeclarePropertyWithUnit("beamene","GeV",fBeamEnergy,"Beam energy"); + + fMessenger.DeclareProperty("oldras",fOldRaster,"Old (no ang corln) or new (ang corl) raster"); + fMessenger.DeclarePropertyWithUnit("rasx","cm",fRasterX,"Square raster width x (horizontal)"); + fMessenger.DeclarePropertyWithUnit("rasy","cm",fRasterY,"Square raster width y (vertical)"); + + fMessenger.DeclarePropertyWithUnit("beam_x0","cm",fX0,"beam initial position in x (horizontal)"); + fMessenger.DeclarePropertyWithUnit("beam_y0","cm",fY0,"beam initial position in y (vertical)"); + fMessenger.DeclarePropertyWithUnit("beam_ph0","deg",fPh0,"beam initial direction in x (horizontal)"); + fMessenger.DeclarePropertyWithUnit("beam_th0","deg",fTh0,"beam initial direction in y (vertical)"); + fMessenger.DeclarePropertyWithUnit("beam_corrph","deg",fCorrPh,"beam correlated angle (horizontal)"); + fMessenger.DeclarePropertyWithUnit("beam_corrth","deg",fCorrTh,"beam correlated angle (vertical)"); + fMessenger.DeclarePropertyWithUnit("beam_dph","deg",fdPh,"beam gaussian spread in x (horizontal)"); + fMessenger.DeclarePropertyWithUnit("beam_dth","deg",fdTh,"beam gaussian spread in y (vertical)"); + + fTargetMessenger.DeclareMethod("mother",&remollBeamTarget::SetActiveTargetMother,"Set target mother name").SetStates(G4State_Idle); + fTargetMessenger.DeclareMethod("volume",&remollBeamTarget::SetActiveTargetVolume,"Set target volume name").SetStates(G4State_Idle); + fTargetMessenger.DeclareMethod("print",&remollBeamTarget::PrintTargetInfo).SetStates(G4State_Idle); } remollBeamTarget::~remollBeamTarget() { - delete fMessenger; - delete fMS; } -G4double remollBeamTarget::GetEffLumin(){ - return fEffectiveMaterialLength*fBeamCurrent/(e_SI*coulomb); +G4double remollBeamTarget::GetEffLumin(SamplingType_t sampling_type) const +{ + if (sampling_type == kNoTargetVolume) + return fBeamCurrent / (e_SI*coulomb); // no length, just frequency + else + return fBeamCurrent / (e_SI*coulomb) * fEffectiveMaterialLength; } void remollBeamTarget::PrintTargetInfo() { - for (std::vector::iterator - it = fTargetVolumes.begin(); it != fTargetVolumes.end(); it++) { + if (fUpdateNeeded) UpdateInfo(); - // Try to cast the target volume into its tubs solid - G4LogicalVolume* volume = (*it)->GetLogicalVolume(); - G4Material* material = volume->GetMaterial(); - G4VSolid* solid = volume->GetSolid(); + for (auto mother = fTargetMothers.begin(); + mother != fTargetMothers.end(); + mother++) { + + auto i_mother = mother - fTargetMothers.begin(); + + G4cout << "Target mother " << (*mother).second << ":" << G4endl; - G4cout << "Target volume " << (*it)->GetName() << ":" << G4endl; - G4cout << " volume: " << volume->GetName() << G4endl; - G4cout << " material: " << material->GetName() << G4endl; - G4cout << " solid: " << solid->GetName() << G4endl; + for (auto daughter = fTargetVolumes[i_mother].begin(); + daughter != fTargetVolumes[i_mother].end(); + daughter++) { + + G4LogicalVolume* volume = (*daughter).first->GetLogicalVolume(); + G4Material* material = volume->GetMaterial(); + + G4cout << " Target volume " << (*daughter).second << ":"; + G4cout << " material: " << material->GetName() << G4endl; - if( (*it)->GetLogicalVolume()->GetName() == fActiveTargetVolume ){ - G4cout << " active volume: " << fActiveTargetVolume << G4endl; } } + G4cout << "Current active target: " << G4endl; + G4cout << "Target mother = " << fActiveTargetMotherName << G4endl; + G4cout << "Target volume = " << fActiveTargetVolumeName << G4endl; + G4cout << "Final target parameters: " << G4endl; - G4cout << " active target effective length: " << fActiveTargetEffectiveLength << G4endl; - G4cout << " active target relative position: " << fActiveTargetRelativePosition << G4endl; - G4cout << " total active length: " << fTotalTargetEffectiveLength << G4endl; + G4cout << " total target effective length: " << fTotalTargetEffectiveLength/(gram/cm2) << " gram/cm2" << G4endl; + G4cout << " active target effective length: " << fActiveTargetEffectiveLength/(gram/cm2) << " gram/cm2" << G4endl; } void remollBeamTarget::UpdateInfo() @@ -118,86 +124,117 @@ void remollBeamTarget::UpdateInfo() fActiveTargetEffectiveLength = -1e9; fMotherTargetAbsolutePosition = -1e9; - fActiveTargetRelativePosition = -1e9; fTotalTargetEffectiveLength = 0.0; // Can't calculate anything without mother, let's hope we find one later on - if (!fTargetMother) { + if (fTargetMothers.size() == 0) { return; } - fMotherTargetAbsolutePosition = fTargetMother->GetTranslation().z(); - for (std::vector::iterator - it = fTargetVolumes.begin(); it != fTargetVolumes.end(); it++) { + // Find mother volume + for (auto mother = fTargetMothers.begin(); + mother != fTargetMothers.end(); + mother++) { + + if ((*mother).second == fActiveTargetMotherName) { + fActiveTargetMother = mother - fTargetMothers.begin(); + } + } + + // Find target volume + for (auto daughter = fTargetVolumes[fActiveTargetMother].begin(); + daughter != fTargetVolumes[fActiveTargetMother].end(); + daughter++) { + + if ((*daughter).second == fActiveTargetVolumeName) { + fActiveTargetVolume = daughter - fTargetVolumes[fActiveTargetMother].begin(); + } + + } + + // Get absolute position + fMotherTargetAbsolutePosition = fTargetMothers[fActiveTargetMother].first->GetTranslation().z() - 4500; + + for (auto it = fTargetVolumes[fActiveTargetMother].begin(); + it != fTargetVolumes[fActiveTargetMother].end(); + it++) { // Try to cast the target volume into its tubs solid - G4LogicalVolume* volume = (*it)->GetLogicalVolume(); + G4VPhysicalVolume* physvol = (*it).first; + G4LogicalVolume* volume = physvol->GetLogicalVolume(); G4Material* material = volume->GetMaterial(); G4VSolid* solid = volume->GetSolid(); + G4Tubs* tubs = dynamic_cast(solid); + G4Box* box = dynamic_cast(solid); // Assume everything is non-nested tubes - if( !tubs ){ + if ((tubs == nullptr) && (box == nullptr)) { G4cerr << "ERROR: " << __PRETTY_FUNCTION__ << " line " << __LINE__ << - ": Target volume not made of G4Tubs" << G4endl; + ": Target volume " << volume->GetName() << " not made of G4Tubs or G4Box" << G4endl; exit(1); } - if( (*it)->GetLogicalVolume()->GetName() == fActiveTargetVolume ){ - - if( fActiveTargetEffectiveLength >= 0.0 ){ - G4cerr << "ERROR: " << __PRETTY_FUNCTION__ << " line " << __LINE__ << - ": Multiply defined target volumes" << G4endl; - exit(1); - } + G4double z_half_length = 0; + if (tubs != nullptr) z_half_length = tubs->GetZHalfLength(); + if (box != nullptr) z_half_length = box->GetZHalfLength(); - fActiveTargetEffectiveLength = tubs->GetZHalfLength()*2.0 - * material->GetDensity(); + fTotalTargetEffectiveLength += 2.0 * z_half_length * material->GetDensity(); - fActiveTargetRelativePosition = (*it)->GetTranslation().z(); + if (it == fTargetVolumes[fActiveTargetMother].begin() + fActiveTargetVolume) { - fTotalTargetEffectiveLength += tubs->GetZHalfLength()*2.0 - * material->GetDensity(); + fActiveTargetEffectiveLength = 2.0 * z_half_length * material->GetDensity(); } } + + fUpdateNeeded = false; } -void remollBeamTarget::SetActiveTargetVolume(G4String name) +void remollBeamTarget::SetActiveTargetMother(G4String name) { G4AutoLock lock(&remollBeamTargetMutex); - fActiveTargetVolume = name; + fActiveTargetMotherName = name; + fUpdateNeeded = true; +} - lock.unlock(); - UpdateInfo(); +void remollBeamTarget::SetActiveTargetVolume(G4String name) +{ + G4AutoLock lock(&remollBeamTargetMutex); + fActiveTargetVolumeName = name; + fUpdateNeeded = true; } //////////////////////////////////////////////////////////////////////////////////////////// // Sampling functions -remollVertex remollBeamTarget::SampleVertex(SampType_t samp) +remollVertex remollBeamTarget::SampleVertex(SamplingType_t sampling_type) { // Create vertex remollVertex vertex; // No sampling required - if (samp == kNoTargetVolume) { + static bool sampling_type_has_been_warned = false; + if (sampling_type == kNoTargetVolume) { + if (! sampling_type_has_been_warned) { + G4cerr << "ERROR: " << __PRETTY_FUNCTION__ << " line " << __LINE__ << ": " << + "kNoTargetVolume!" << G4endl; + sampling_type_has_been_warned = true; + } return vertex; } // Check if target mother volume exists - if (fTargetMother == 0) { + if (fTargetMothers.size() == 0) { G4cerr << "ERROR: " << __PRETTY_FUNCTION__ << " line " << __LINE__ << ": " << "No target mother volume defined!" << G4endl; - exit(1); } // Check if target volume exists - if (fTargetVolumes.size() == 0) { + if (fTargetVolumes[fActiveTargetMother].size() == 0) { G4cerr << "ERROR: " << __PRETTY_FUNCTION__ << " line " << __LINE__ << ": " << "No target volume defined!" << G4endl; - exit(1); } // Sample raster x and y positions on target @@ -208,9 +245,12 @@ remollVertex remollBeamTarget::SampleVertex(SampType_t samp) // Sample where along target weighted by density (which roughly corresponds to A // or the number of electrons, which is probably good enough for this + // Update if needed + if (fUpdateNeeded) UpdateInfo(); + // Figure out how far along the target we got G4double total_effective_length = 0; - switch( samp ){ + switch (sampling_type) { case kActiveTargetVolume: total_effective_length = fActiveTargetEffectiveLength; break; @@ -235,33 +275,46 @@ remollVertex remollBeamTarget::SampleVertex(SampType_t samp) // Start with no multiple scattering materials loaded: // this may seem like something that can be made static, // but it's probably not worth it since only called once per event. - int nmsmat = 0; - double msthick[__MAX_MAT]; - double msA[__MAX_MAT]; - double msZ[__MAX_MAT]; + std::vector> ms; // Figure out the material we are in and the radiation length we traversed - for (std::vector::iterator - it = fTargetVolumes.begin(); it != fTargetVolumes.end() && !found_active_volume; it++ ){ + for (auto it = fTargetVolumes[fActiveTargetMother].begin(); + it != fTargetVolumes[fActiveTargetMother].end() && !found_active_volume; + it++) { + + // Target volume + G4VPhysicalVolume* physvol = (*it).first; // Relative position of this target volume in mother volume - G4double volume_relative_position = (*it)->GetTranslation().z(); + G4double volume_relative_position = physvol->GetTranslation().z(); // Try to cast the target volume into its tubs solid - G4LogicalVolume* volume = (*it)->GetLogicalVolume(); + G4LogicalVolume* volume = physvol->GetLogicalVolume(); G4Material* material = volume->GetMaterial(); G4VSolid* solid = volume->GetSolid(); + G4Tubs* tubs = dynamic_cast(solid); + G4Box* box = dynamic_cast(solid); + + if ((tubs == nullptr) && (box == nullptr)) { + G4cerr << "ERROR: " << __PRETTY_FUNCTION__ << " line " << __LINE__ << + ": Target volume " << volume->GetName() << " not made of G4Tubs or G4Box" << G4endl; + continue; // exit(1); + } + + G4double z_half_length = 0; + if (box != nullptr) z_half_length = box->GetZHalfLength(); + if (tubs != nullptr) z_half_length = tubs->GetZHalfLength(); // Effective length of this target volume - G4double effective_length = tubs->GetZHalfLength()*2.0 * material->GetDensity(); + G4double effective_length = z_half_length*2.0 * material->GetDensity(); // Find position in this volume (if we are in it) G4double effective_position_in_volume; G4double actual_position_in_volume; - switch( samp ){ + switch (sampling_type) { case kActiveTargetVolume: - if ((*it)->GetLogicalVolume()->GetName() == fActiveTargetVolume ){ + if (it == fTargetVolumes[fActiveTargetMother].begin() + fActiveTargetVolume) { // This is the active volume, and we only sample here found_active_volume = true; actual_position_in_volume = effective_position/material->GetDensity(); @@ -274,7 +327,7 @@ remollVertex remollBeamTarget::SampleVertex(SampType_t samp) break; case kAllTargetVolumes: - if( effective_position - cumulative_effective_length < effective_length ){ + if (effective_position - cumulative_effective_length < effective_length) { // This is the volume where our sample landed found_active_volume = true; effective_position_in_volume = (effective_position - cumulative_effective_length); @@ -292,7 +345,7 @@ remollVertex remollBeamTarget::SampleVertex(SampType_t samp) break; } - if( material->GetBaseMaterial() ){ + if( material->GetBaseMaterial() != nullptr ){ G4cerr << __FILE__ << " " << __PRETTY_FUNCTION__ << ": The material you're using isn't" << " defined in a way we can use for multiple scattering calculations" << G4endl; G4cerr << "Aborting" << G4endl; @@ -309,7 +362,7 @@ remollVertex remollBeamTarget::SampleVertex(SampType_t samp) fRadiationLength = cumulative_radiation_length; fVer = G4ThreeVector( rasx, rasy, fMotherTargetAbsolutePosition - + volume_relative_position - tubs->GetZHalfLength() + + volume_relative_position - z_half_length + actual_position_in_volume ); G4double masssum = 0.0; @@ -322,10 +375,10 @@ remollVertex remollBeamTarget::SampleVertex(SampType_t samp) // but it does - SPR 2/5/13. assert( atomvec ); masssum += (*elvec)[i]->GetA()*atomvec[i]; - msthick[nmsmat] = material->GetDensity()*actual_position_in_volume*fracvec[i]; - msA[nmsmat] = (*elvec)[i]->GetA()*mole/g; - msZ[nmsmat] = (*elvec)[i]->GetZ(); - nmsmat++; + double t = material->GetDensity()*actual_position_in_volume*fracvec[i]; + double A = (*elvec)[i]->GetA()*mole/g; + double Z = (*elvec)[i]->GetZ(); + ms.push_back(std::make_tuple(t,A,Z)); } // Effective material length for luminosity calculation @@ -335,10 +388,10 @@ remollVertex remollBeamTarget::SampleVertex(SampType_t samp) const G4ElementVector *elvec = material->GetElementVector(); const G4double *fracvec = material->GetFractionVector(); for( unsigned int i = 0; i < elvec->size(); i++ ){ - msthick[nmsmat] = effective_length*fracvec[i]; - msA[nmsmat] = (*elvec)[i]->GetA()*mole/g; - msZ[nmsmat] = (*elvec)[i]->GetZ(); - nmsmat++; + double t = effective_length*fracvec[i]; + double A = (*elvec)[i]->GetA()*mole/g; + double Z = (*elvec)[i]->GetZ(); + ms.push_back(std::make_tuple(t,A,Z)); } } } @@ -359,10 +412,10 @@ remollVertex remollBeamTarget::SampleVertex(SampType_t samp) // Sample multiple scattering angles G4double msth = 0, msph = 0; - if( nmsmat > 0 ){ - fMS->Init( fBeamEnergy, nmsmat, msthick, msA, msZ ); - msth = fMS->GenerateMSPlane(); - msph = fMS->GenerateMSPlane(); + if (ms.size() > 0) { + fMS.Init(fBeamEnergy, ms); + msth = fMS.GenerateMSPlane(); + msph = fMS.GenerateMSPlane(); } assert( !std::isnan(msth) && !std::isnan(msph) ); assert( !std::isinf(msth) && !std::isinf(msph) ); diff --git a/src/remollDetectorConstruction.cc b/src/remollDetectorConstruction.cc index 37b88dc54..3c32dbdea 100644 --- a/src/remollDetectorConstruction.cc +++ b/src/remollDetectorConstruction.cc @@ -5,7 +5,6 @@ #include "remollGlobalField.hh" #include "remollIO.hh" -#include "G4GenericMessenger.hh" #include "G4GeometryManager.hh" #include "G4GeometryTolerance.hh" #include "G4FieldManager.hh" @@ -16,6 +15,7 @@ #include "G4PhysicalVolumeStore.hh" #include "G4LogicalVolumeStore.hh" #include "G4LogicalVolume.hh" +#include "G4PVPlacement.hh" #include "globals.hh" #include "G4RunManager.hh" @@ -29,6 +29,11 @@ // GDML export #include "G4GDMLParser.hh" +//CADMesh +#ifdef __USE_CADMESH +#include +#endif + // visual #include "G4VisAttributes.hh" #include "G4Colour.hh" @@ -36,6 +41,10 @@ #include #include +#ifdef __APPLE__ +#include +#endif + #include "G4Threading.hh" #include "G4AutoLock.hh" namespace { G4Mutex remollDetectorConstructionMutex = G4MUTEX_INITIALIZER; } @@ -46,178 +55,174 @@ G4UserLimits* remollDetectorConstruction::fKryptoniteUserLimits = new G4UserLimi remollDetectorConstruction::remollDetectorConstruction(const G4String& name, const G4String& gdmlfile) : fVerboseLevel(0), - fGDMLParser(0), fGDMLValidate(false), - fGDMLOverlapCheck(false), - fGDMLPath("geometry"), - fGDMLFile("mollerMother.gdml"), - fMessenger(0), - fGeometryMessenger(0), - fUserLimitsMessenger(0), - fKryptoniteMessenger(0), + fGDMLOverlapCheck(true), + fGDMLPath(""), + fGDMLFile(""), fKryptoniteEnable(true), fKryptoniteVerbose(0), fWorldVolume(0), fWorldName(name) { + // Define some engineering units + new G4UnitDefinition("inch","in","Length",25.4*CLHEP::millimeter); + + SetGDMLFile("geometry/mollerMother.gdml"); // If gdmlfile is non-empty - if (gdmlfile.length() > 0) SetGDMLFile(gdmlfile); + if (gdmlfile.length() > 0) { + SetGDMLFile(gdmlfile); + } - // Create GDML parser - fGDMLParser = new G4GDMLParser(); + // New units + new G4UnitDefinition("inch","in","Length",25.4*CLHEP::millimeter); // Create generic messenger - fMessenger = new G4GenericMessenger(this,"/remoll/","Remoll properties"); - fMessenger->DeclareMethod( + fMessenger.DeclareMethod( "setgeofile", &remollDetectorConstruction::SetGDMLFile, "Set geometry GDML file") .SetStates(G4State_PreInit); - fMessenger->DeclareMethod( + fMessenger.DeclareMethod( "printgeometry", &remollDetectorConstruction::PrintGeometry, "Print the geometry tree") .SetStates(G4State_Idle) .SetDefaultValue("false"); - fMessenger->DeclareMethod( + fMessenger.DeclareMethod( "printelements", &remollDetectorConstruction::PrintElements, "Print the elements") .SetStates(G4State_Idle); - fMessenger->DeclareMethod( + fMessenger.DeclareMethod( "printmaterials", &remollDetectorConstruction::PrintMaterials, "Print the materials") .SetStates(G4State_Idle); // Create geometry messenger - fGeometryMessenger = new G4GenericMessenger(this, - "/remoll/geometry/", - "Remoll geometry properties"); - fGeometryMessenger->DeclareMethod( + fGeometryMessenger.DeclareMethod( "setfile", &remollDetectorConstruction::SetGDMLFile, "Set geometry GDML file") .SetStates(G4State_PreInit); - fGeometryMessenger->DeclareProperty( + fGeometryMessenger.DeclareProperty( "verbose", fVerboseLevel, "Set geometry verbose level") .SetStates(G4State_PreInit,G4State_Idle); - fGeometryMessenger->DeclareProperty( + fGeometryMessenger.DeclareProperty( "validate", fGDMLValidate, "Set GMDL validate flag") .SetStates(G4State_PreInit) .SetDefaultValue("true"); - fGeometryMessenger->DeclareProperty( + fGeometryMessenger.DeclareProperty( "overlapcheck", fGDMLOverlapCheck, "Set GMDL overlap check flag") .SetStates(G4State_PreInit) .SetDefaultValue("true"); - fGeometryMessenger->DeclareMethod( + fGeometryMessenger.DeclareMethod( "load", &remollDetectorConstruction::ReloadGeometry, "Reload the geometry") .SetStates(G4State_PreInit,G4State_Idle); - fGeometryMessenger->DeclareMethod( + fGeometryMessenger.DeclareMethod( "printelements", &remollDetectorConstruction::PrintElements, "Print the elements") .SetStates(G4State_Idle); - fGeometryMessenger->DeclareMethod( + fGeometryMessenger.DeclareMethod( "printmaterials", &remollDetectorConstruction::PrintMaterials, "Print the materials") .SetStates(G4State_Idle); - fGeometryMessenger->DeclareMethod( + fGeometryMessenger.DeclareMethod( "printgeometry", &remollDetectorConstruction::PrintGeometry, "Print the geometry tree") .SetStates(G4State_Idle) .SetDefaultValue("false"); - fGeometryMessenger->DeclareMethod( + fGeometryMessenger.DeclareMethod( "printoverlaps", &remollDetectorConstruction::PrintOverlaps, "Print the geometry overlap") .SetStates(G4State_Idle); - fGeometryMessenger->DeclareMethod( + fGeometryMessenger.DeclareMethod( "absolute_position", &remollDetectorConstruction::AbsolutePosition, "Set the position of volume in parent frame [mm]") .SetStates(G4State_PreInit,G4State_Idle); - fGeometryMessenger->DeclareMethod( + fGeometryMessenger.DeclareMethod( "relative_position", &remollDetectorConstruction::RelativePosition, "Position a volume relative to current position [mm]") .SetStates(G4State_PreInit,G4State_Idle); - fGeometryMessenger->DeclareMethod( + fGeometryMessenger.DeclareMethod( "absolute_rotation", &remollDetectorConstruction::AbsoluteRotation, "Set the rotation of volume in parent frame [deg]") .SetStates(G4State_PreInit,G4State_Idle); - fGeometryMessenger->DeclareMethod( + fGeometryMessenger.DeclareMethod( "relative_rotation", &remollDetectorConstruction::RelativeRotation, "Rotate a volume relative to current orientation [deg]") .SetStates(G4State_PreInit,G4State_Idle); + fGeometryMessenger.DeclareMethod( + "addmesh", + &remollDetectorConstruction::AddMesh, + "Add mesh file (ascii stl, ascii ply, ascii obj)") + .SetStates(G4State_Idle); // Create user limits messenger - fUserLimitsMessenger = new G4GenericMessenger(this, - "/remoll/geometry/userlimits/", - "Remoll geometry properties"); - fUserLimitsMessenger->DeclareMethod( + fUserLimitsMessenger.DeclareMethod( "usermaxallowedstep", &remollDetectorConstruction::SetUserMaxAllowedStep, "Set user limit MaxAllowedStep for logical volume") .SetStates(G4State_Idle); - fUserLimitsMessenger->DeclareMethod( + fUserLimitsMessenger.DeclareMethod( "usermaxtracklength", &remollDetectorConstruction::SetUserMaxTrackLength, "Set user limit MaxTrackLength for logical volume") .SetStates(G4State_Idle); - fUserLimitsMessenger->DeclareMethod( + fUserLimitsMessenger.DeclareMethod( "usermaxtime", &remollDetectorConstruction::SetUserMaxTime, "Set user limit MaxTime for logical volume") .SetStates(G4State_Idle); - fUserLimitsMessenger->DeclareMethod( + fUserLimitsMessenger.DeclareMethod( "userminekine", &remollDetectorConstruction::SetUserMinEkine, "Set user limit MinEkine for logical volume") .SetStates(G4State_Idle); - fUserLimitsMessenger->DeclareMethod( + fUserLimitsMessenger.DeclareMethod( "userminrange", &remollDetectorConstruction::SetUserMinRange, "Set user limit MinRange for logical volume") .SetStates(G4State_Idle); // Create kryptonite messenger - fKryptoniteMessenger = new G4GenericMessenger(this, - "/remoll/kryptonite/", - "Remoll kryptonite properties"); - fKryptoniteMessenger->DeclareMethod( + fKryptoniteMessenger.DeclareMethod( "verbose", &remollDetectorConstruction::SetKryptoniteVerbose, "Set verbose level"); - fKryptoniteMessenger->DeclareMethod( + fKryptoniteMessenger.DeclareMethod( "enable", &remollDetectorConstruction::EnableKryptonite, "Treat materials as kryptonite"); - fKryptoniteMessenger->DeclareMethod( + fKryptoniteMessenger.DeclareMethod( "disable", &remollDetectorConstruction::DisableKryptonite, "Treat materials as regular"); - fKryptoniteMessenger->DeclareMethod( + fKryptoniteMessenger.DeclareMethod( "add", &remollDetectorConstruction::AddKryptoniteCandidate, "Add specified material to list of kryptonite candidates"); - fKryptoniteMessenger->DeclareMethod( + fKryptoniteMessenger.DeclareMethod( "list", &remollDetectorConstruction::ListKryptoniteCandidates, "List kryptonite candidate materials"); - fKryptoniteMessenger->DeclareMethod( + fKryptoniteMessenger.DeclareMethod( "volume", &remollDetectorConstruction::EnableKryptoniteVolume, "Treat volume as kryptonite"); @@ -250,7 +255,7 @@ void remollDetectorConstruction::EnableKryptoniteVolume(G4String name) // Find volume G4LogicalVolume* logical_volume = G4LogicalVolumeStore::GetInstance()->GetVolume(name); - if (! logical_volume) { + if (logical_volume == nullptr) { G4cerr << __FILE__ << " line " << __LINE__ << ": Warning volume " << name << " unknown" << G4endl; return; } @@ -354,11 +359,36 @@ void remollDetectorConstruction::SetUserMinRange(G4String name, G4String value_u remollDetectorConstruction::~remollDetectorConstruction() { - delete fGDMLParser; - delete fMessenger; - delete fGeometryMessenger; - delete fKryptoniteMessenger; - delete fUserLimitsMessenger; + for (auto pv: fMeshPVs) { + auto lv = pv->GetLogicalVolume(); + auto solid = lv->GetSolid(); + delete solid; + delete lv; + delete pv; + } +} + +void remollDetectorConstruction::AddMesh(const G4String& filename) +{ + #ifdef __USE_CADMESH + // Read mesh + auto mesh = CADMesh::TessellatedMesh::FromSTL(filename); + + // Extract solids + G4Material* material = G4NistManager::Instance()->FindOrBuildMaterial("G4_Galactic"); + for (auto solid: mesh->GetSolids()) { + auto lv = new G4LogicalVolume(solid, material, filename); + lv->SetVisAttributes(G4Colour(0.0,1.0,0.0,1.0)); + auto pv = new G4PVPlacement(G4Transform3D(), filename, lv, fWorldVolume, false, 0, false); + fMeshPVs.push_back(pv); + } + + // Reoptimize geometry + G4RunManager* run_manager = G4RunManager::GetRunManager(); + run_manager->GeometryHasBeenModified(); + #else + G4cerr << __FILE__ << " line " << __LINE__ << ": Warning - meshes not supported." << G4endl; + #endif } void remollDetectorConstruction::AbsolutePosition(G4String name, G4ThreeVector position) @@ -368,7 +398,7 @@ void remollDetectorConstruction::AbsolutePosition(G4String name, G4ThreeVector p // Find volume G4VPhysicalVolume* physical_volume = G4PhysicalVolumeStore::GetInstance()->GetVolume(name); - if (! physical_volume) { + if (physical_volume == nullptr) { G4cerr << __FILE__ << " line " << __LINE__ << ": Warning volume " << name << " unknown" << G4endl; return; } @@ -394,7 +424,7 @@ void remollDetectorConstruction::RelativePosition(G4String name, G4ThreeVector p // Find volume G4VPhysicalVolume* physical_volume = G4PhysicalVolumeStore::GetInstance()->GetVolume(name); - if (! physical_volume) { + if (physical_volume == nullptr) { G4cerr << __FILE__ << " line " << __LINE__ << ": Warning volume " << name << " unknown" << G4endl; return; } @@ -420,7 +450,7 @@ void remollDetectorConstruction::AbsoluteRotation(G4String name, G4ThreeVector r // Find volume G4VPhysicalVolume* physical_volume = G4PhysicalVolumeStore::GetInstance()->GetVolume(name); - if (! physical_volume) { + if (physical_volume == nullptr) { G4cerr << __FILE__ << " line " << __LINE__ << ": Warning volume " << name << " unknown" << G4endl; return; } @@ -459,7 +489,7 @@ void remollDetectorConstruction::RelativeRotation(G4String name, G4ThreeVector r // Find volume G4VPhysicalVolume* physical_volume = G4PhysicalVolumeStore::GetInstance()->GetVolume(name); - if (! physical_volume) { + if (physical_volume == nullptr) { G4cerr << __FILE__ << " line " << __LINE__ << ": Warning volume " << name << " unknown" << G4endl; return; } @@ -512,38 +542,39 @@ void remollDetectorConstruction::PrintGDMLWarning() const G4VPhysicalVolume* remollDetectorConstruction::ParseGDMLFile() { // Clear parser - fGDMLParser->Clear(); - - // Print GDML warning - PrintGDMLWarning(); + fGDMLParser.Clear(); // Print parsing options G4cout << "Reading " << fGDMLFile << G4endl; G4cout << "- schema validation " << (fGDMLValidate? "on": "off") << G4endl; G4cout << "- overlap check " << (fGDMLOverlapCheck? "on": "off") << G4endl; + // Print GDML warning when validation + if (fGDMLValidate) PrintGDMLWarning(); + // Get remollIO instance before chdir since remollIO creates root file remollIO* io = remollIO::GetInstance(); // Change directory char cwd[MAXPATHLEN]; - if (!getcwd(cwd,MAXPATHLEN)) { + if (getcwd(cwd,MAXPATHLEN) == nullptr) { G4cerr << __FILE__ << " line " << __LINE__ << ": ERROR no current working directory" << G4endl; exit(-1); } - if (chdir(fGDMLPath)) { + if (chdir(fGDMLPath) != 0) { G4cerr << __FILE__ << " line " << __LINE__ << ": ERROR cannot change directory" << G4endl; exit(-1); } // Parse GDML file - fGDMLParser->SetOverlapCheck(fGDMLOverlapCheck); - // hide output if not validating or checking ovelaps + fGDMLParser.SetOverlapCheck(fGDMLOverlapCheck); + // hide output if not validating or checking overlaps + // https://bugzilla-geant4.kek.jp/show_bug.cgi?id=2358 if (! fGDMLOverlapCheck && ! fGDMLValidate) G4cout.setstate(std::ios_base::failbit); - fGDMLParser->Read(fGDMLFile,fGDMLValidate); + fGDMLParser.Read(fGDMLFile,fGDMLValidate); G4cout.clear(); - G4VPhysicalVolume* worldvolume = fGDMLParser->GetWorldVolume(); + G4VPhysicalVolume* worldvolume = fGDMLParser.GetWorldVolume(); // Print tolerances if (fVerboseLevel > 0) { @@ -566,7 +597,7 @@ G4VPhysicalVolume* remollDetectorConstruction::ParseGDMLFile() io->GrabGDMLFiles(fGDMLFile); // Change directory back - if (chdir(cwd)) { + if (chdir(cwd) != 0) { G4cerr << __FILE__ << " line " << __LINE__ << ": ERROR cannot change directory" << G4endl; exit(-1); } @@ -577,7 +608,7 @@ G4VPhysicalVolume* remollDetectorConstruction::ParseGDMLFile() void remollDetectorConstruction::PrintAuxiliaryInfo() const { - const G4GDMLAuxMapType* auxmap = fGDMLParser->GetAuxMap(); + const G4GDMLAuxMapType* auxmap = fGDMLParser.GetAuxMap(); G4cout << "Found " << auxmap->size() << " volume(s) with auxiliary information." << G4endl << G4endl; @@ -595,7 +626,7 @@ void remollDetectorConstruction::ParseAuxiliaryTargetInfo() // how to improve this, you are welcome to :-) // Loop over volumes with auxiliary information - const G4GDMLAuxMapType* auxmap = fGDMLParser->GetAuxMap(); + const G4GDMLAuxMapType* auxmap = fGDMLParser.GetAuxMap(); for(G4GDMLAuxMapType::const_iterator iter = auxmap->begin(); iter != auxmap->end(); iter++) { @@ -609,10 +640,13 @@ void remollDetectorConstruction::ParseAuxiliaryTargetInfo() // Treat auxiliary type "TargetSystem" only if ((*vit).type != "TargetSystem") continue; + // Target system name + G4String mother_tag = (*vit).value; + // Found target mother logical volume G4LogicalVolume* mother_logical_volume = logical_volume; if (fVerboseLevel > 0) - G4cout << "Found target mother logical volume " + G4cout << "Found target system mother logical volume " << mother_logical_volume->GetName() << "." << G4endl; // Now find target mother physical volume @@ -624,15 +658,14 @@ void remollDetectorConstruction::ParseAuxiliaryTargetInfo() // Mutex lock before writing static structures in remollBeamTarget G4AutoLock lock(&remollDetectorConstructionMutex); - remollBeamTarget::ResetTargetVolumes(); - remollBeamTarget::SetMotherVolume(mother_physical_volume); + remollBeamTarget::AddMotherVolume(mother_physical_volume, mother_tag); if (fVerboseLevel > 0) G4cout << "Found target mother physical volume " << mother_physical_volume->GetName() << "." << G4endl; } else { G4cout << "Target mother logical volume does not occur " - << "*exactly once* as a physical volume." << G4endl; + << "*exactly once as a physical volume." << G4endl; exit(-1); } @@ -666,10 +699,13 @@ void remollDetectorConstruction::ParseAuxiliaryTargetInfo() // If the logical volume is tagged as "TargetSamplingVolume" if ((*vit2).type != "TargetSamplingVolume") continue; + // Target system name + G4String target_tag = (*vit2).value; + // Add target volume G4cout << "Adding target sampling volume " << target_logical_volume->GetName() << "." << G4endl; - remollBeamTarget::AddTargetVolume(target_physical_volume); + remollBeamTarget::AddTargetVolume(target_physical_volume, target_tag); } // loop over auxiliary tags in volume to find "TargetSamplingVolume" @@ -680,11 +716,13 @@ void remollDetectorConstruction::ParseAuxiliaryTargetInfo() } // loop over auxiliary tags in volume to find "TargetSystem" } // loop over volumes with auxiliary tags to find "TargetSystem" + + remollBeamTarget::UpdateInfo(); } void remollDetectorConstruction::ParseAuxiliaryUserLimits() { - const G4GDMLAuxMapType* auxmap = fGDMLParser->GetAuxMap(); + const G4GDMLAuxMapType* auxmap = fGDMLParser.GetAuxMap(); for(G4GDMLAuxMapType::const_iterator iter = auxmap->begin(); iter != auxmap->end(); iter++) { @@ -718,7 +756,7 @@ void remollDetectorConstruction::ParseAuxiliaryUserLimits() void remollDetectorConstruction::ParseAuxiliaryVisibilityInfo() { // Loop over volumes with auxiliary information - const G4GDMLAuxMapType* auxmap = fGDMLParser->GetAuxMap(); + const G4GDMLAuxMapType* auxmap = fGDMLParser.GetAuxMap(); for(G4GDMLAuxMapType::const_iterator iter = auxmap->begin(); iter != auxmap->end(); iter++) { @@ -740,7 +778,7 @@ void remollDetectorConstruction::ParseAuxiliaryVisibilityInfo() if ((*vit).type == "Visibility") { G4Colour colour(1.0,1.0,1.0); const G4VisAttributes* visAttribute_old = ((*iter).first)->GetVisAttributes(); - if (visAttribute_old) + if (visAttribute_old != nullptr) colour = visAttribute_old->GetColour(); G4VisAttributes visAttribute_new(colour); if ((*vit).value == "true") @@ -777,7 +815,7 @@ void remollDetectorConstruction::ParseAuxiliaryVisibilityInfo() G4Colour colour(1.0,1.0,1.0); const G4VisAttributes* visAttribute_old = ((*iter).first)->GetVisAttributes(); - if (visAttribute_old) + if (visAttribute_old != nullptr) colour = visAttribute_old->GetColour(); G4Colour colour_new( @@ -798,14 +836,6 @@ void remollDetectorConstruction::ParseAuxiliaryVisibilityInfo() G4VisAttributes* motherVisAtt = new G4VisAttributes(G4Colour(1.0,1.0,1.0)); motherVisAtt->SetForceWireframe(true); fWorldVolume->GetLogicalVolume()->SetVisAttributes(motherVisAtt); - - // Set all immediate daughters of the world volume to wireframe - G4VisAttributes* daughterVisAtt = new G4VisAttributes(G4Colour(1.0,1.0,1.0)); - daughterVisAtt->SetForceWireframe(true); - auto n = fWorldVolume->GetLogicalVolume()->GetNoDaughters(); - for (decltype(n) i = 0; i < n; i++) { - fWorldVolume->GetLogicalVolume()->GetDaughter(i)->GetLogicalVolume()->SetVisAttributes(daughterVisAtt); - } } void remollDetectorConstruction::ParseAuxiliarySensDetInfo() @@ -814,10 +844,10 @@ void remollDetectorConstruction::ParseAuxiliarySensDetInfo() G4cout << "Beginning sensitive detector assignment" << G4endl; // Duplication map - std::map detnomap; + std::map> detnomap; // Loop over all volumes with auxiliary tags - const G4GDMLAuxMapType* auxmap = fGDMLParser->GetAuxMap(); + const G4GDMLAuxMapType* auxmap = fGDMLParser.GetAuxMap(); for (G4GDMLAuxMapType::const_iterator iter = auxmap->begin(); iter != auxmap->end(); iter++) { G4LogicalVolume* myvol = (*iter).first; @@ -832,6 +862,8 @@ void remollDetectorConstruction::ParseAuxiliarySensDetInfo() auto it_sensdet = NextAuxWithType(list.begin(), list.end(), "SensDet"); if (it_sensdet != list.end()) { + G4String sens_det = it_sensdet->value; + // Find first aux list entry with type DetNo auto it_detno = NextAuxWithType(list.begin(), list.end(), "DetNo"); if (it_detno != list.end()) { @@ -845,10 +877,12 @@ void remollDetectorConstruction::ParseAuxiliarySensDetInfo() det_name_ss << "remoll/det_" << det_no; std::string det_name = det_name_ss.str(); - // Check for duplication - if (detnomap.count(det_no) != 0) { - G4cerr << "remoll: DetNo " << det_no << " for " << myvol->GetName() << G4endl; - G4cerr << "remoll: already used by " << detnomap[det_no]->GetName() << G4endl; + // Check for duplication when not a shared detector number + if (detnomap.count(det_no) != 0 && detnomap[det_no].first != sens_det) { + std::string sens_det2 = detnomap[det_no].first; + G4LogicalVolume* myvol2 = detnomap[det_no].second; + G4cerr << "remoll: Detector number " << det_no << " (" << sens_det << ") " << myvol->GetName() << G4endl; + G4cerr << "remoll: already used by " << det_no << " (" << sens_det2 << ") " << myvol2->GetName() << G4endl; } // Try to find sensitive detector @@ -870,11 +904,11 @@ void remollDetectorConstruction::ParseAuxiliarySensDetInfo() // Register detector with SD manager SDman->AddNewDetector(remollsd); - detnomap[det_no] = myvol; + detnomap[det_no] = std::make_pair(sens_det, myvol); // Register detector with remollIO remollIO* io = remollIO::GetInstance(); - io->RegisterDetector(myvol->GetName(), it_sensdet->value, det_no); + io->RegisterDetector(myvol->GetName(), sens_det, det_no); } @@ -892,11 +926,11 @@ void remollDetectorConstruction::ParseAuxiliarySensDetInfo() it_dettype = NextAuxWithType(++it_dettype, list.end(), "DetType")) { // Set detector type - if (remollsd) remollsd->SetDetectorType(it_dettype->value); + if (remollsd != nullptr) remollsd->SetDetectorType(it_dettype->value); // Print detector type if (fVerboseLevel > 0) - if (remollsd) remollsd->PrintDetectorType(); + if (remollsd != nullptr) remollsd->PrintDetectorType(); } @@ -930,7 +964,7 @@ G4VPhysicalVolume* remollDetectorConstruction::Construct() void remollDetectorConstruction::LoadMagneticField() { // Remove existing field and load new field - if (fGlobalField) delete fGlobalField; + delete fGlobalField; fGlobalField = new remollGlobalField(); } @@ -951,7 +985,7 @@ void remollDetectorConstruction::SetUserLimits( { // Find volume G4LogicalVolume* logical_volume = G4LogicalVolumeStore::GetInstance()->GetVolume(name); - if (! logical_volume) { + if (logical_volume == nullptr) { G4cerr << __FILE__ << " line " << __LINE__ << ": Warning volume " << name << " unknown" << G4endl; return; } @@ -974,7 +1008,7 @@ void remollDetectorConstruction::SetUserLimits( { // Get user limits G4UserLimits* userlimits = logical_volume->GetUserLimits(); - if (! userlimits) { + if (userlimits == nullptr) { userlimits = new G4UserLimits(); logical_volume->SetUserLimits(userlimits); } @@ -1102,7 +1136,7 @@ void remollDetectorConstruction::PrintGeometryTree( } // Print sensitive detector G4VSensitiveDetector* sd = aVolume->GetLogicalVolume()->GetSensitiveDetector(); - if (print && sd) + if (print && (sd != nullptr)) { remollGenericDetector* remollsd = dynamic_cast(sd); G4cout << " [" << remollsd->GetDetNo() << "]"; diff --git a/src/remollEvent.cc b/src/remollEvent.cc index 1c666ab86..97c51e51f 100644 --- a/src/remollEvent.cc +++ b/src/remollEvent.cc @@ -48,7 +48,7 @@ std::vector remollEvent::GetEventParticleIO() const { std::vector parts; for (size_t idx = 0; idx < fPartType.size(); idx++) { remollEventParticle_t part; - part.pid = (fPartType[idx]? fPartType[idx]->GetPDGEncoding(): 0); + part.pid = (fPartType[idx] != nullptr? fPartType[idx]->GetPDGEncoding(): 0); part.sx = fPartSpin[idx].x(); part.sy = fPartSpin[idx].y(); part.sz = fPartSpin[idx].z(); @@ -181,7 +181,7 @@ G4bool remollEvent::EventIsSane(){ } for(unsigned int i = 0; i < fPartPos.size(); i++ ){ - if( !fPartType[i] ){ return false; } + if( fPartType[i] == nullptr ){ return false; } if( std::isnan(fPartPos[i].x()) || std::isinf(fPartPos[i].x()) ) return false; if( std::isnan(fPartPos[i].y()) || std::isinf(fPartPos[i].y()) ) return false; @@ -209,7 +209,7 @@ void remollEvent::Print(){ unsigned int i; for( i = 0; i < fPartPos.size(); i++ ){ - if( !fPartType[i] ){ + if( fPartType[i] == nullptr ){ G4cout << "\tParticle type for " << i << " not defined" << G4endl; } else { G4cout << "\t" << fPartType[i]->GetParticleName() << ":" << G4endl; diff --git a/src/remollEventAction.cc b/src/remollEventAction.cc index 4c373ec9f..56677b704 100644 --- a/src/remollEventAction.cc +++ b/src/remollEventAction.cc @@ -54,7 +54,7 @@ void remollEventAction::EndOfEventAction(const G4Event* aEvent) auto n = HCE->GetCapacity(); for (decltype(n) hcidx = 0; hcidx < n; hcidx++) { G4VHitsCollection* thiscol = HCE->GetHC(hcidx); - if (thiscol){ // This is NULL if nothing is stored + if (thiscol != nullptr){ // This is NULL if nothing is stored // Dynamic cast to test types, process however see fit and feed to IO diff --git a/src/remollGen12CElastic.cc b/src/remollGen12CElastic.cc deleted file mode 100644 index fdea03f8b..000000000 --- a/src/remollGen12CElastic.cc +++ /dev/null @@ -1,367 +0,0 @@ -#include "remollGen12CElastic.hh" - -#include "CLHEP/Random/RandFlat.h" - -#include "remollEvent.hh" -#include "remollVertex.hh" -#include "remollBeamTarget.hh" -#include "remollMultScatt.hh" - -#include "G4Material.hh" -#include "G4VPhysicalVolume.hh" -#include "G4LogicalVolume.hh" -#include "Randomize.hh" - -#include "G4SystemOfUnits.hh" -#include "G4PhysicalConstants.hh" - -#include "remolltypes.hh" - -#include - -#define Euler 0.5772157 -#define NINTERVAL 3 -//#define mAl (27*931.5*MeV) -#define C12_A 12 - -remollGen12CElastic::remollGen12CElastic() -: remollVEventGen("carbon") -{ - fTh_min = 0.1*deg; - fTh_max = 2.0*deg; - - fE_min = 80.0*MeV; // Absolute minimum of electron energy - // to generate - fApplyMultScatt = false; -} - -remollGen12CElastic::~remollGen12CElastic(){ -} - -// Generate eAl elastic event -void remollGen12CElastic::SamplePhysics(remollVertex *vert, remollEvent *evt) -{ - // Crazy weighting for brem because ep cross section blows up at low Q2 - - // Get initial beam energy instead of using other sampling - double beamE = fBeamTarg->fBeamEnergy; - // double Ekin = beamE - electron_mass_c2; - - // std::vector targVols = fBeamTarg->GetTargVols(); - - // bool bypass_target = false; - - // std::vector::iterator it = targVols.begin(); - // if( targVols.size() > 0 ){ - // while( (*it)->GetLogicalVolume()->GetMaterial()->GetName() != "C12" - // && it != targVols.end() ){ it++; } - - // if( (*it)->GetLogicalVolume()->GetMaterial()->GetName() != "C12" ){ - // G4cerr << __FILE__ << " line " << __LINE__ << ": WARNING could not find target" << G4endl; - // bypass_target = true; - // } - // } else { - // bypass_target = true; - // } - - // double bremcut = fBeamTarg->fEcut; - - // // Approximation for Q2, just needs to be order of magnitude - // double effQ2 = 2.0*beamE*beamE*(1.0-cos(0.5*deg)); - - // // About ~1.5% - // double int_bt = 0.75*(alpha/pi)*( log( effQ2/(electron_mass_c2*electron_mass_c2) ) - 1.0 ); - - // double bt; - // if( !bypass_target ){ - // bt = (4.0/3.0)*(fBeamTarg->fTravLen/(*it)->GetLogicalVolume()->GetMaterial()->GetRadlen() - // + int_bt); - // } else { - // bt = 0.0; - // } - - // double prob, prob_sample, sample, eloss, value; - // value = 1.0; - // prob = 1.- pow(bremcut/Ekin,bt) - bt/(bt+1.)*(1.- pow(bremcut/Ekin,bt+1.)) - // + 0.75*bt/(2.+bt)*(1.- pow(bremcut/Ekin,bt+2.)); - // prob = prob/(1.- bt*Euler + bt*bt/2.*(Euler*Euler+pi*pi/6.)); /* Gamma function */ - // prob_sample = G4UniformRand(); /* Random sampling */ - - // double Evlo[NINTERVAL] = { - // bremcut, - // (beamE-bremcut)*2.0*GeV/(11.0*GeV-bremcut), - // (beamE-bremcut)*9.0*GeV/(11.0*GeV-bremcut), - // }; - - // double Evhi[NINTERVAL] = { - // (beamE-bremcut)*2.0*GeV/(11.0*GeV-bremcut), - // (beamE-bremcut)*9.0*GeV/(11.0*GeV-bremcut), - // (beamE-bremcut)*(beamE-fE_min)/(11.0*GeV-bremcut), - // }; - - // double Eprob[NINTERVAL] = { 0.40, 0.20, 0.40 }; - - // double Enorm[NINTERVAL]; - // // Interval normalization - // for( int idx = 0; idx < NINTERVAL; idx++ ){ - // Enorm[idx] = ((Evhi[idx]-Evlo[idx])/(Evhi[NINTERVAL-1]-Evlo[0])) - // /Eprob[idx]; - // } - - // int Evidx; - // double evsum = 0.0; - // double vweight = 0.0; - // eloss = 0.0; - - // // Averages over the intervals - // double vavg[NINTERVAL] = { - // log(Evhi[0]/Evlo[0])/(Evhi[0]-Evlo[0]), - // log((beamE-Evlo[1])/(beamE-Evhi[1]))/(Evhi[1]-Evlo[1]), - // (1.0/(beamE-Evhi[2])-1.0/(beamE-Evlo[2]))/(Evhi[2]-Evlo[2]) - // }; - - // if (prob_sample <= prob) {//Bremsstrahlung has taken place! - // // We break this into 4 seperate energy loss intervals - // // with total integrals roughly the size of - // // what the ep product looks like with 11 GeV beam - // // cut - 2000 MeV, 1/x, 40% - // // 2000 - 9000 MeV, 1/(E-x), 20% - // // 9000 - 10990 MeV, 1/(E-x)^2, 40% - - // sample = G4UniformRand(); - - // // Identify our region - // // based on the probability distribution - // Evidx = 0; - // evsum = Eprob[Evidx]; - // while( evsum < sample ){ - // Evidx++; - // evsum += Eprob[Evidx]; - // } - - // sample = G4UniformRand(); - - // if( Evidx == 0 ){ - // eloss = Evlo[Evidx]*pow(Evhi[Evidx]/Evlo[Evidx],sample); - // vweight = eloss; - // } - - // if( Evidx == 1 ){ - // eloss = beamE - (beamE-Evhi[Evidx])* - // pow((beamE-Evlo[Evidx])/(beamE-Evhi[Evidx]),sample); - // vweight = (beamE-eloss); - // } - - // if( Evidx == 2 ){ - // eloss = beamE - pow( (1.0/(beamE-Evhi[Evidx]) - 1.0/(beamE-Evlo[Evidx]))*sample - // + 1.0/(beamE-Evlo[Evidx]), -1.0 ); - // vweight = (beamE-eloss)*(beamE-eloss); - // } - - // if( !(eloss > 0.0 ) ){ - // printf("idx = %d\n", Evidx ); - // } - - // assert( eloss > 0.0 ); - - // assert( !std::isnan(eloss) && !std::isinf(eloss) ); - - // vweight *= vavg[Evidx]; - // // mult by beamE-bremcut for proper normalization - // value = RadProfile( eloss, bt)* - // ((Evhi[NINTERVAL-1]-Evlo[0])/EnergNumInt(bt, Evlo[0], Evhi[NINTERVAL-1])) // average of RadProfile - // *vweight // sampling weighting (flat or ) / average value for normalization - // *Enorm[Evidx]; // Weight given the region - - // beamE -= eloss; - // } - - if( beamE < electron_mass_c2 ){ - evt->SetEffCrossSection(0.0); - evt->SetAsymmetry(0.0); - return; - } - - // Set event information to our new sampling - evt->fBeamE = beamE; - evt->fBeamMomentum = evt->fBeamMomentum.unit()*sqrt(beamE*beamE - electron_mass_c2*electron_mass_c2); - - //////////////////////////////////////////////////////////////////////////////////////////// - - - // sample with 1.0/(1-cos)^2 - - double cthmin = cos(fTh_min); - double cthmax = cos(fTh_max); - - double icth_b = 1.0/(1.0-cthmax); - double icth_a = 1.0/(1.0-cthmin); - - double sampv = 1.0/CLHEP::RandFlat::shoot(icth_b, icth_a); - - assert( -1.0 < sampv && sampv < 1.0 ); - - double th = acos(1.0-sampv); - - // Value to reweight cross section by to account for non-uniform - // sampling - double samp_fact = sampv*sampv*(icth_a-icth_b)/(cthmin-cthmax); - - double ph = CLHEP::RandFlat::shoot(0.0, 2.0*pi); - - double ef = C12_A*proton_mass_c2*beamE/(C12_A*proton_mass_c2 + beamE*(1.0-cos(th))); - - double q2 = 2.0*beamE*ef*(1.0-cos(th)); - // double tau = q2/(4.0*C12_A*proton_mass_c2*C12_A*proton_mass_c2); - - // double gd = pow( 1.0 + q2/(0.71*GeV*GeV), -2.0 ); - // double gep = gd; - // double gmp = 2.79*gd; - - // double gen = 1.91*gd*tau/(1.0+5.6*tau); // galster - // double gmn = -1.91*gd; - - double sigma_mott = hbarc*hbarc*pow(alpha*cos(th/2.0), 2.0)/pow(2.0*beamE*sin(th/2.0)*sin(th/2.0), 2.0); - // double ffpart1 = (gep*gep + tau*gmp*gmp)/(1.0+tau); - // double ffpart2 = 2.0*tau*gmp*gmp*tan(th/2.0)*tan(th/2.0); - - // double sigma = sigma_mott*(ef/beamE)*(ffpart1 + ffpart2); - double sigma = sigma_mott*(ef/beamE); - - double V = (fPh_max - fPh_min) * (cthmin - cthmax) * samp_fact; - - // Suppress too low angles from being generated - // If we're in the multiple-scattering regime - // the cross sections are senseless. We'll define this - // as anything less than three sigma of the characteristic - // width - - if( th < 3.0*fBeamTarg->fMS->GetPDGTh() ){ - sigma = 0.0; - } - - // Multiply by Z because we have Z protons - // value for uneven weighting - - double thisZ; - - thisZ = vert->GetMaterial()->GetZ(); - - // evt->SetEffCrossSection(sigma*V*thisZ*value); - evt->SetEffCrossSection(sigma*V*thisZ); - - if( vert->GetMaterial()->GetNumberOfElements() != 1 ){ - G4cerr << __FILE__ << " line " << __LINE__ << - ": Error! Some lazy programmer didn't account for complex materials in the moller process!" << G4endl; - exit(1); - } - - // G4double APV_base = -GF*q2/(4.0*sqrt(2.0)*pi*alpha); - - // G4double eps = pow(1.0 + 2.0*(1.0+tau)*tan(th/2.0)*tan(th/2.0), -1.0); - - // G4double apvffnum = eps*gep*gen + tau*gmp*gmn; - // G4double apvffden = eps*gep*gep + tau*gmp*gmp; - - // G4double APV = APV_base*(QWp - apvffnum/apvffden); - - // evt->SetAsymmetry(APV); - evt->SetAsymmetry(0); - - evt->SetQ2( q2 ); - evt->SetW2( C12_A*proton_mass_c2*C12_A*proton_mass_c2 ); - - // // REradiate//////////////////////////////////////////////////////////////////////////// - // // We're going to use the new kinematics for this guy - - // int_bt = (alpha/pi)*( log( q2/(electron_mass_c2*electron_mass_c2) ) - 1.0 ); - // Ekin = ef - electron_mass_c2;; - // double env, ref; - - // prob = 1.- pow(bremcut/Ekin, int_bt) - int_bt/(int_bt+1.)*(1.- pow(bremcut/Ekin,int_bt+1.)) - // + 0.75*int_bt/(2.+int_bt)*(1.- pow(bremcut/Ekin,int_bt+2.)); - // prob = prob/(1.- int_bt*Euler + int_bt*int_bt/2.*(Euler*Euler+pi*pi/6.)); /* Gamma function */ - // prob_sample = G4UniformRand(); /* Random sampling */ - - // if (prob_sample <= prob) {//Bremsstrahlung has taken place! - // do { - // sample = G4UniformRand(); - // eloss = fBeamTarg->fEcut*pow(Ekin/fBeamTarg->fEcut,sample); - // env = 1./eloss; - // value = 1./eloss*(1.-eloss/Ekin+0.75*pow(eloss/Ekin,2))*pow(eloss/Ekin,bt); - - // sample = G4UniformRand(); - // ref = value/env; - // } while (sample > ref); - - // ef = Ekin-eloss+electron_mass_c2; - // assert( ef > electron_mass_c2 ); - // } - - /////////////////////////////////////////////////////////////////////////////////////// - - evt->ProduceNewParticle( G4ThreeVector(0.0, 0.0, 0.0), - G4ThreeVector(ef*cos(ph)*sin(th), ef*sin(ph)*sin(th), ef*cos(th) ), - "e-" ); - - return; - -} - -G4double remollGen12CElastic::RadProfile(G4double eloss, G4double btt){ - double Ekin = fBeamTarg->fBeamEnergy - electron_mass_c2; - double retval = 1./eloss*(1.-eloss/Ekin+0.75*pow(eloss/Ekin,2))*pow(eloss/Ekin,btt); - - if( std::isnan(retval) || std::isinf(retval) ){ - G4cerr << __FILE__ << " line " << __LINE__ << ": ERROR" << G4endl; - G4cerr << "Ekin " << Ekin/GeV << " GeV btt = " << btt << " retval = " << retval << G4endl; - fprintf(stderr, "eloss = %e GeV\n", eloss/GeV); - } - - assert( !std::isnan(retval) && !std::isinf(retval) ); - - return retval; -} - -G4double remollGen12CElastic::EnergNumInt(G4double btt, G4double a0, G4double b0){ - const int nbin = 1000; - double sum = 0.0; - double bremcut = fBeamTarg->fEnergyCut; - - int j; - double boolc[5] = {7.0, 32.0, 12.0, 32.0, 7.0}; - - double a, b, thissum; - - for(int i =0;iDeclarePropertyWithUnit("origin","mm",fOriginMean,"origin position mean: x y z unit"); - fThisGenMessenger->DeclareMethodWithUnit("x","mm",&remollGenBeam::SetOriginXMean,"origin x position mean"); - fThisGenMessenger->DeclareMethodWithUnit("y","mm",&remollGenBeam::SetOriginYMean,"origin y position mean"); - fThisGenMessenger->DeclareMethodWithUnit("z","mm",&remollGenBeam::SetOriginZMean,"origin z position mean"); - - fThisGenMessenger->DeclarePropertyWithUnit("originspread","mm",fOriginSpread,"origin position spread: x y z unit"); - fThisGenMessenger->DeclareMethodWithUnit("xspread","mm",&remollGenBeam::SetOriginXSpread,"origin x position spread"); - fThisGenMessenger->DeclareMethodWithUnit("yspread","mm",&remollGenBeam::SetOriginYSpread,"origin y position spread"); - fThisGenMessenger->DeclareMethodWithUnit("zspread","mm",&remollGenBeam::SetOriginZSpread,"origin z position spread"); - fThisGenMessenger->DeclareMethod("xmodel",&remollGenBeam::SetOriginXModel,"origin x position model: flat, gauss"); - fThisGenMessenger->DeclareMethod("ymodel",&remollGenBeam::SetOriginYModel,"origin y position model: flat, gauss"); - fThisGenMessenger->DeclareMethod("zmodel",&remollGenBeam::SetOriginZModel,"origin z position model: flat, gauss"); - - fThisGenMessenger->DeclareProperty("direction",fDirection,"direction vector (will be normalized): x y z"); - fThisGenMessenger->DeclareMethod("px",&remollGenBeam::SetDirectionX,"direction x (vector will be normalized before use)"); - fThisGenMessenger->DeclareMethod("py",&remollGenBeam::SetDirectionY,"direction y (vector will be normalized before use)"); - fThisGenMessenger->DeclareMethod("pz",&remollGenBeam::SetDirectionZ,"direction z (vector will be normalized before use)"); - fThisGenMessenger->DeclareMethodWithUnit("th","deg",&remollGenBeam::SetDirectionTh,"direction vector theta angle"); - fThisGenMessenger->DeclareMethodWithUnit("ph","deg",&remollGenBeam::SetDirectionPh,"direction vector phi angle"); - - fThisGenMessenger->DeclareProperty("polarization",fPolarization,"polarization vector (will be normalized): x y z"); - fThisGenMessenger->DeclareMethod("sx",&remollGenBeam::SetPolarizationX,"x component of polarization"); - fThisGenMessenger->DeclareMethod("sy",&remollGenBeam::SetPolarizationY,"y component of polarization"); - fThisGenMessenger->DeclareMethod("sz",&remollGenBeam::SetPolarizationZ,"z component of polarization"); - - fThisGenMessenger->DeclareMethodWithUnit("rasrefz","mm",&remollGenBeam::SetRasterRefZ,"reference z position where raster is defined"); - fThisGenMessenger->DeclareMethodWithUnit("rasx","mm",&remollGenBeam::SetRasterX,"raster x spread perpendicular to the beam at z = 0"); - fThisGenMessenger->DeclareMethodWithUnit("rasy","mm",&remollGenBeam::SetRasterY,"raster y spread perpendicular to the beam at z = 0"); - fThisGenMessenger->DeclareMethod("corrx",&remollGenBeam::SetCorrelationX,"sensitivity of direction to position in x (in mrad/mm)"); - fThisGenMessenger->DeclareMethod("corry",&remollGenBeam::SetCorrelationY,"sensitivity of direction to position in y (in mrad/mm)"); - - fThisGenMessenger->DeclareMethod("partName",&remollGenBeam::SetPartName,"name of particle to shoot"); + fThisGenMessenger.DeclarePropertyWithUnit("rasterRefZ","mm",fRasterRefZ,"Raster Origin Z: z unit"); + fThisGenMessenger.DeclarePropertyWithUnit("origin","mm",fOriginMean,"origin position mean: x y z unit"); + fThisGenMessenger.DeclareMethodWithUnit("x","mm",&remollGenBeam::SetOriginXMean,"origin x position mean"); + fThisGenMessenger.DeclareMethodWithUnit("y","mm",&remollGenBeam::SetOriginYMean,"origin y position mean"); + fThisGenMessenger.DeclareMethodWithUnit("z","mm",&remollGenBeam::SetOriginZMean,"origin z position mean"); + + fThisGenMessenger.DeclarePropertyWithUnit("originspread","mm",fOriginSpread,"origin position spread: x y z unit"); + fThisGenMessenger.DeclareMethodWithUnit("xspread","mm",&remollGenBeam::SetOriginXSpread,"origin x position spread"); + fThisGenMessenger.DeclareMethodWithUnit("yspread","mm",&remollGenBeam::SetOriginYSpread,"origin y position spread"); + fThisGenMessenger.DeclareMethodWithUnit("zspread","mm",&remollGenBeam::SetOriginZSpread,"origin z position spread"); + fThisGenMessenger.DeclareMethod("xmodel",&remollGenBeam::SetOriginXModel,"origin x position model: flat, gauss"); + fThisGenMessenger.DeclareMethod("ymodel",&remollGenBeam::SetOriginYModel,"origin y position model: flat, gauss"); + fThisGenMessenger.DeclareMethod("zmodel",&remollGenBeam::SetOriginZModel,"origin z position model: flat, gauss"); + + fThisGenMessenger.DeclareProperty("direction",fDirection,"direction vector (will be normalized): x y z"); + fThisGenMessenger.DeclareMethod("px",&remollGenBeam::SetDirectionX,"direction x (vector will be normalized before use)"); + fThisGenMessenger.DeclareMethod("py",&remollGenBeam::SetDirectionY,"direction y (vector will be normalized before use)"); + fThisGenMessenger.DeclareMethod("pz",&remollGenBeam::SetDirectionZ,"direction z (vector will be normalized before use)"); + fThisGenMessenger.DeclareMethodWithUnit("th","deg",&remollGenBeam::SetDirectionTh,"direction vector theta angle"); + fThisGenMessenger.DeclareMethodWithUnit("ph","deg",&remollGenBeam::SetDirectionPh,"direction vector phi angle"); + fThisGenMessenger.DeclareProperty("isotropic",fIsotropic,"direction is isotropic"); + fThisGenMessenger.DeclarePropertyWithUnit("isotropic_theta_min","deg",fIsotropicThetaMin,"minimum theta in isotropic direction"); + fThisGenMessenger.DeclarePropertyWithUnit("isotropic_theta_max","deg",fIsotropicThetaMax,"maximum theta in isotropic direction"); + + fThisGenMessenger.DeclarePropertyWithUnit("originshift","mm",fOriginShift,"origin shift along direction vector: s unit"); + + fThisGenMessenger.DeclareProperty("polarization",fPolarization,"polarization vector (will be normalized): x y z"); + fThisGenMessenger.DeclareMethod("sx",&remollGenBeam::SetPolarizationX,"x component of polarization"); + fThisGenMessenger.DeclareMethod("sy",&remollGenBeam::SetPolarizationY,"y component of polarization"); + fThisGenMessenger.DeclareMethod("sz",&remollGenBeam::SetPolarizationZ,"z component of polarization"); + + fThisGenMessenger.DeclareMethodWithUnit("rasrefz","mm",&remollGenBeam::SetRasterRefZ,"reference z position where raster is defined"); + fThisGenMessenger.DeclareMethodWithUnit("rasx","mm",&remollGenBeam::SetRasterX,"raster x spread perpendicular to the beam at z = 0"); + fThisGenMessenger.DeclareMethodWithUnit("rasy","mm",&remollGenBeam::SetRasterY,"raster y spread perpendicular to the beam at z = 0"); + fThisGenMessenger.DeclareMethod("corrx",&remollGenBeam::SetCorrelationX,"sensitivity of direction to position in x (in mrad/mm)"); + fThisGenMessenger.DeclareMethod("corry",&remollGenBeam::SetCorrelationY,"sensitivity of direction to position in y (in mrad/mm)"); + + fThisGenMessenger.DeclareMethod("partName",&remollGenBeam::SetPartName,"name of particle to shoot"); } remollGenBeam::~remollGenBeam() { } @@ -108,7 +117,15 @@ void remollGenBeam::SetPolarizationX(double sx){ fPolarization.setX(sx); } void remollGenBeam::SetPolarizationY(double sy){ fPolarization.setY(sy); } void remollGenBeam::SetPolarizationZ(double sz){ fPolarization.setZ(sz); } -void remollGenBeam::SetPartName(G4String& name){ fParticleName = name; } +void remollGenBeam::SetPartName(G4String& name){ + G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable(); + G4ParticleDefinition* particle = particleTable->FindParticle(name); + if (particle != nullptr) fParticleName = name; + else { + G4cerr << "remollGenBeam: particle " << name << " not recognized." << G4endl; + exit(-1); + } +} G4double remollGenBeam::GetSpread(G4double spread, EOriginModel model) { @@ -135,8 +152,8 @@ void remollGenBeam::SamplePhysics(remollVertex * /*vert*/, remollEvent *evt) G4ParticleDefinition* particle = particleTable->FindParticle(fParticleName); // Get initial beam energy instead of using other sampling - double E = fBeamTarg->fBeamEnergy; double m = particle->GetPDGMass(); + double E = fBeamTarg->fBeamEnergy + m; double p = sqrt(E*E - m*m); // Start from mean position @@ -145,6 +162,14 @@ void remollGenBeam::SamplePhysics(remollVertex * /*vert*/, remollEvent *evt) // Start from mean direction G4ThreeVector direction(fDirection.unit()); + // Add direction range + if (fIsotropic) { + double th = acos(G4RandFlat::shoot(cos(fIsotropicThetaMax), cos(fIsotropicThetaMin))); + double ph = G4RandFlat::shoot(0.0, 2.0*pi); + direction.setTheta(th); + direction.setPhi(ph); + } + // Add a spread based on chosen model G4ThreeVector spread = GetSpread(fOriginSpread, fOriginModelX, fOriginModelY, fOriginModelZ); @@ -165,6 +190,9 @@ void remollGenBeam::SamplePhysics(remollVertex * /*vert*/, remollEvent *evt) origin += raster; origin += spread; + // Add shift to origin + origin += fOriginShift * direction; + // Override target sampling evt->fBeamE = E; evt->fBeamMomentum = p * direction; @@ -177,7 +205,7 @@ void remollGenBeam::SamplePhysics(remollVertex * /*vert*/, remollEvent *evt) fParticleName, evt->fBeamPolarization); - evt->SetEffCrossSection(0.0); + evt->SetEffCrossSection(1.0); evt->SetAsymmetry(0.0); evt->SetQ2(0.0); diff --git a/src/remollGenC12.cc b/src/remollGenC12.cc new file mode 100644 index 000000000..7fb9add47 --- /dev/null +++ b/src/remollGenC12.cc @@ -0,0 +1,260 @@ +#include "remollGenC12.hh" + +#include "Randomize.hh" + +#include +#include + +#include "remollEvent.hh" +#include "remollVertex.hh" +#include "remolltypes.hh" + +#include "G4Material.hh" +#include "G4SystemOfUnits.hh" +#include "G4PhysicalConstants.hh" + +extern G4int F1F2IN09(G4int Z, G4int IA, G4double qsq, + G4double wsq, G4double &F1, G4double &F2); + +extern G4int F1F2QE09(G4int Z, G4int IA, G4double qsq, + G4double wsq, G4double &F1, G4double &F2); + +std::map remollGenC12::fNamesMap = remollGenC12::CreateNamesMap(); + +std::map remollGenC12::CreateNamesMap() { + std::map names; + names[0] = "elasticC12"; + names[1] = "quasielasticC12"; + names[2] = "inelasticC12"; + return names; +} + +remollGenC12::remollGenC12(G4int physicsType) +: remollVEventGen(fNamesMap[physicsType]) { + type = physicsType; + + fTh_min = 0.1*deg; + fTh_max = 5.0*deg; + fApplyMultScatt = true; +} + +remollGenC12::~remollGenC12() { +} + +void remollGenC12::SamplePhysics(remollVertex *vert, remollEvent *evt) { + + G4double beamE = vert->GetBeamEnergy(); // in MeV (it can be modified by beam loss) + G4double th = acos(G4RandFlat::shoot(cos(fTh_max), cos(fTh_min))); // radians + + ///////////////////////////////////////// + // sample with 1.0/(1-cos)^2 + //////////////////////////////////////// +/* + double cthmin = cos(fTh_min); + double cthmax = cos(fTh_max); + + double icth_b = 1.0/(1.0-cthmax); + double icth_a = 1.0/(1.0-cthmin); + + double sampv = 1.0/G4RandFlat::shoot(icth_b, icth_a); + + assert( -1.0 < sampv && sampv < 1.0 ); + + double th = acos(1.0-sampv); + // Value to reweight cross section by to account for non-uniform + // sampling + double samp_fact = sampv*sampv*(icth_a-icth_b)/(cthmin-cthmax); + + G4double phaseSpaceFactor = 2.0*pi*(cos(fTh_min) - cos(fTh_max))*samp_fact; +*/ + + G4double phaseSpaceFactor = (fPh_max - fPh_min) * (cos(fTh_min) - cos(fTh_max)); + G4double ph = G4RandFlat::shoot(fPh_min, fPh_max); + G4double eOut=0; + G4double fWeight=0; + G4double Q2=0; + G4double effectiveXsection=0; + G4double W2=0; + G4double asym=0; + + switch (type) { + case 0: + GenElastic(beamE,th,Q2,W2,effectiveXsection,fWeight,eOut,asym); + break; + case 1: + GenQuasiElastic(beamE,th,Q2,W2,effectiveXsection,fWeight,eOut,asym); + phaseSpaceFactor=phaseSpaceFactor*(beamE/GeV - electron_mass_c2/GeV); + break; + case 2: + GenInelastic(beamE,th,Q2,W2,effectiveXsection,fWeight,eOut,asym); + phaseSpaceFactor=phaseSpaceFactor*(beamE/GeV - electron_mass_c2/GeV); + break; + default: + G4cerr<<"Unknown C12 event type"<GetMaterial()->GetNumberOfElements() != 1 ) { + G4cerr << __FILE__ << " line " << __LINE__ << + " : Error! Some lazy programmer didn't account for complex materials in the moller process!" << G4endl; + exit(1); + } + + evt->SetThCoM(th); + evt->SetEffCrossSection(phaseSpaceFactor*effectiveXsection*microbarn); + evt->SetQ2( Q2 ); //MeV^2 + evt->SetAsymmetry(asym); + evt->SetW2( W2 ); + evt->ProduceNewParticle( G4ThreeVector(0.0, 0.0, 0.0), + G4ThreeVector(eOut*sin(th)*cos(ph), eOut*sin(th)*sin(ph), eOut*cos(th) ), + "e-" ); + + return; +} + +void remollGenC12::GenInelastic(G4double beamE,G4double theta, + G4double &Q2,G4double &W2,G4double &effectiveXsection, + G4double &fWeight,G4double &eOut, G4double &asym) { + + G4double F1 = 0.0; + G4double F2 = 0.0; + G4double W1 = 0.0; + G4double xsect = 0.0; + + G4double CTH,STH,T2THE,Nu; + + do{ + eOut = electron_mass_c2 + G4UniformRand()*(beamE - electron_mass_c2);// Generate flat energy distribution of outgoing electron + CTH = cos(theta/2.0); + STH = sin(theta/2.0); + T2THE = STH*STH/CTH/CTH; + Nu = beamE - eOut; + Q2 = 4.0*beamE*eOut*STH*STH; + W2 = pow(proton_mass_c2,2) + 2.0*proton_mass_c2*Nu - Q2; + }while(W2/GeV/GeV<0 || W2/GeV/GeV>10 || Q2/GeV/GeV<0.0 || Q2/GeV/GeV>10); //this is because F1F2IN09 won't work for W>3 and Q2>10 + + // Mott scattering + G4double MOTT = pow((hbarc/GeV/m*fine_structure_const/(2.*beamE/GeV)*CTH/STH/STH),2)/microbarn; // units: ubarn + + G4int A=12; + G4int Z=6; + G4int bad=F1F2IN09(Z, A, Q2/GeV/GeV, W2/GeV/GeV, F1, F2); + if(bad != 0){ + G4cerr << "ERROR: " << __FILE__ << " line " << __LINE__ << G4endl; + G4cerr << " result was (-1 = Q2,W2 out of range in resmodd | -2 = A<3 | 1 inf/nan F1/F2) : " << bad <* remollGenExternal::fHit = 0; +Int_t remollGenExternal::fEntry = 0; +Int_t remollGenExternal::fEntries = 0; + remollGenExternal::remollGenExternal() : remollVEventGen("external"), - fFile(0), fTree(0), - fEntry(0), fEntries(0), - fEvent(0), fHit(0), fzOffset(0), fDetectorID(28), fLoopID(1) { - fSampType = kNoTargetVolume; + fSamplingType = kNoTargetVolume; + // Add to generic messenger - fThisGenMessenger->DeclareMethod("file",&remollGenExternal::SetGenExternalFile,"External generator event filename"); - fThisGenMessenger->DeclareMethod("zOffset",&remollGenExternal::SetGenExternalZOffset,"External generator zOffset"); - fThisGenMessenger->DeclareMethod("detid",&remollGenExternal::SetGenExternalDetID,"External generator detector ID"); - fThisGenMessenger->DeclareMethod("startEvent",&remollGenExternal::SetGenExternalEntry,"External generator starting event: -1 starts random, n starts at n (default n=0)"); + fThisGenMessenger.DeclareMethod("file",&remollGenExternal::SetGenExternalFile,"External generator event filename"); + fThisGenMessenger.DeclareMethod("zOffset",&remollGenExternal::SetGenExternalZOffset,"External generator zOffset"); + fThisGenMessenger.DeclareMethod("detid",&remollGenExternal::SetGenExternalDetID,"External generator detector ID"); + fThisGenMessenger.DeclareMethod("startEvent",&remollGenExternal::SetGenExternalEntry,"External generator starting event: -1 starts random, n starts at n (default n=0)"); } remollGenExternal::~remollGenExternal() { G4AutoLock inFileLock(&inFileMutex); + // Close file which deletes tree - if (fFile) { + if (fFile != nullptr) { fFile->Close(); fTree = 0; } @@ -47,52 +53,53 @@ remollGenExternal::~remollGenExternal() void remollGenExternal::SetGenExternalFile(G4String& filename) { G4AutoLock inFileLock(&inFileMutex); + G4cout << "Setting the external file to " << filename << " from " << fFile << G4endl; // Close previous file - if (fFile) { + if (fFile != nullptr) { fFile->Close(); fFile = 0; } // Try to open filename fFile = new TFile(filename); - if (! fFile) { + if (fFile == nullptr) { G4cerr << "Could not open external event file " << filename << G4endl; return; } // Try to find tree in file fFile->GetObject("T",fTree); - if (! fTree) { + if (fTree == nullptr) { G4cerr << "Could not find tree T in event file (SetGenExternalFile)" << filename << G4endl; return; } - inFileLock.unlock(); - // Get number of entries + // Nunber of entries fEntries = fTree->GetEntries(); // Initialize tree - if (fTree->GetBranch("hit")) { + if (fTree->GetBranch("hit") != nullptr) { fTree->SetBranchAddress("hit", &fHit); } else { G4cerr << "Could not find branch hit in event file " << filename << G4endl; return; } -/* event tree removed by Cameron 11/15/2018 -* if (fTree->GetBranch("ev")) { -* fTree->SetBranchAddress("ev", &fEvent); -* } else { -* G4cerr << "Could not find branch ev in event file " << filename << G4endl; -* return; -* } -*/ + + if (fTree->GetBranch("ev") != nullptr) { + fTree->SetBranchAddress("ev", &fEvent); + } else { + G4cerr << "Could not find branch ev in event file " << filename << G4endl; + return; + } } void remollGenExternal::SamplePhysics(remollVertex* /* vert */, remollEvent* evt) { + G4AutoLock inFileLock(&inFileMutex); + // Check whether three exists - if (! fTree) { + if (fTree == nullptr) { G4cerr << "Could not find tree T in event file (SamplePhysics)" << G4endl; return; } @@ -105,18 +112,13 @@ void remollGenExternal::SamplePhysics(remollVertex* /* vert */, remollEvent* evt if (fEntry >= fEntries) fEntry = 0; fTree->GetEntry(fEntry++); - -/* event tree removed by Cameron 11/15/2018 -* // Weighting completely handled by event file -* evt->SetEffCrossSection(fEvent->xs*microbarn); -* evt->SetQ2(fEvent->Q2); -* evt->SetW2(fEvent->W2); -* evt->SetAsymmetry(fEvent->A*ppb); -*/ - evt->SetEffCrossSection(619.5*microbarn); - evt->SetQ2(0.0); - evt->SetW2(4e15); - evt->SetAsymmetry(-42.0*ppb); + + // Weighting completely handled by event file + evt->SetEffCrossSection(fEvent->xs*microbarn); + evt->SetQ2(fEvent->Q2); + evt->SetW2(fEvent->W2); + evt->SetAsymmetry(fEvent->A*ppb); + // Loop over all hits in this event for (size_t i = 0; i < fHit->size(); i++) { // Create local copy of this hit @@ -131,10 +133,11 @@ void remollGenExternal::SamplePhysics(remollVertex* /* vert */, remollEvent* evt G4String particlename = particle->GetParticleName(); // Throw new particle - evt->ProduceNewParticle( - G4ThreeVector(hit.x, hit.y, hit.z + fzOffset), - G4ThreeVector(hit.px, hit.py, hit.pz), - particlename); + G4ThreeVector r(hit.x,hit.y,hit.z); + G4ThreeVector p(hit.px,hit.py,hit.pz); + r += fzOffset*p.unit(); + evt->ProduceNewParticle(r,p,particlename); + number_of_particles++; } diff --git a/src/remollGenHyperon.cc b/src/remollGenHyperon.cc index 45141faf5..97d82de5c 100644 --- a/src/remollGenHyperon.cc +++ b/src/remollGenHyperon.cc @@ -2,7 +2,6 @@ // Geant4 includes #include "G4Material.hh" -#include "G4GenericMessenger.hh" // remoll includes #include "remollBeamTarget.hh" @@ -29,25 +28,25 @@ remollGenHyperon::remollGenHyperon() fRUnit(cm),fPUnit(GeV),fWUnit(barn) { // Add to generic messenger - fThisGenMessenger->DeclareProperty("debug",fDebugLevel,"Debug level"); - fThisGenMessenger->DeclareProperty("file",fFile,"Input filename"); - fThisGenMessenger->DeclareProperty("skip",fSkip,"Number of lines to skip"); - fThisGenMessenger->DeclareProperty("particle",fParticle,"Particle name"); - fThisGenMessenger->DeclarePropertyWithUnit("runit","cm",fRUnit,"Units of position"); - fThisGenMessenger->DeclarePropertyWithUnit("punit","GeV",fPUnit,"Units of momentum"); - fThisGenMessenger->DeclarePropertyWithUnit("wunit","barn",fWUnit,"Units of weight"); + fThisGenMessenger.DeclareProperty("debug",fDebugLevel,"Debug level"); + fThisGenMessenger.DeclareProperty("file",fFile,"Input filename"); + fThisGenMessenger.DeclareProperty("skip",fSkip,"Number of lines to skip"); + fThisGenMessenger.DeclareProperty("particle",fParticle,"Particle name"); + fThisGenMessenger.DeclarePropertyWithUnit("runit","cm",fRUnit,"Units of position"); + fThisGenMessenger.DeclarePropertyWithUnit("punit","GeV",fPUnit,"Units of momentum"); + fThisGenMessenger.DeclarePropertyWithUnit("wunit","barn",fWUnit,"Units of weight"); } remollGenHyperon::~remollGenHyperon() { G4AutoLock lock(&remollGenHyperonMutex); - if (fFileReader) { delete fFileReader; fFileReader = 0; } + if (fFileReader != nullptr) { delete fFileReader; fFileReader = 0; } } remollFileReader* remollGenHyperon::GetFileReader() const { G4AutoLock lock(&remollGenHyperonMutex); - if (! fFileReader) { + if (fFileReader == nullptr) { fFileReader = new remollFileReader(fFile,fSkip,fDebugLevel); } return fFileReader; @@ -58,7 +57,7 @@ void remollGenHyperon::SamplePhysics(remollVertex* /*vert*/, remollEvent* evt) remollFileEvent event; // Limit scope of mutex to read from buffered file - if (GetFileReader()) { + if (GetFileReader() != nullptr) { G4AutoLock lock(&remollGenHyperonMutex); event = fFileReader->GetAnEvent(); // don't use GetFileReader, race condition } diff --git a/src/remollGenLUND.cc b/src/remollGenLUND.cc index bc229e6e3..1e5807066 100644 --- a/src/remollGenLUND.cc +++ b/src/remollGenLUND.cc @@ -2,7 +2,6 @@ // Geant4 includes #include "G4Material.hh" -#include "G4GenericMessenger.hh" // remoll includes #include "remollBeamTarget.hh" @@ -36,7 +35,7 @@ remollGenLUND::remollGenLUND() LUNDfile_linecount = 0; // Add to generic messenger - fThisGenMessenger->DeclareMethod("LUND_filename",&remollGenLUND::SetLUNDFile,"LUND Input filename"); + fThisGenMessenger.DeclareMethod("LUND_filename",&remollGenLUND::SetLUNDFile,"LUND Input filename"); } remollGenLUND::~remollGenLUND() diff --git a/src/remollGenPion.cc b/src/remollGenPion.cc index b4f02bb0a..a78a6e921 100644 --- a/src/remollGenPion.cc +++ b/src/remollGenPion.cc @@ -1,7 +1,6 @@ #include "remollBeamTarget.hh" #include "remollGenPion.hh" -#include "G4GenericMessenger.hh" #include "G4String.hh" #include "Randomize.hh" @@ -34,8 +33,8 @@ remollGenPion::remollGenPion() fE_max = -1.0*GeV; // negative to automatically pick beam energy // Add to generic messenger - fThisGenMessenger->DeclareMethod("piontype",&remollGenPion::SetPionTypeByString_Deprecated,"Generate pion type"); - fThisGenMessenger->DeclareMethod("settype",&remollGenPion::SetPionTypeByString,"Generate pion type"); + fThisGenMessenger.DeclareMethod("piontype",&remollGenPion::SetPionTypeByString_Deprecated,"Generate pion type"); + fThisGenMessenger.DeclareMethod("settype",&remollGenPion::SetPionTypeByString,"Generate pion type"); } remollGenPion::~remollGenPion() { } diff --git a/src/remollGenTF1.cc b/src/remollGenTF1.cc deleted file mode 100644 index f4449d6cb..000000000 --- a/src/remollGenTF1.cc +++ /dev/null @@ -1,468 +0,0 @@ -/* remollGenTF1.cc - * - * Updated June 2018 - * - * Reads functions of radius from external root file and generates particles according to those functions. - * Default functions are inside remollGenFunctions.root, and include moller, elastic, and inelastic scattering - * for the whole array as well as for sectors 1, 2, and 3. - * - */ -#include "remollGenTF1.hh" - -#include "remollEvent.hh" -#include "remollVertex.hh" -#include "remollBeamTarget.hh" - -#include "G4GenericMessenger.hh" -#include "G4Material.hh" -#include "G4VPhysicalVolume.hh" -#include "G4LogicalVolume.hh" -#include "G4PhysicalConstants.hh" - -#include "remolltypes.hh" - - -#include "CLHEP/Random/RandFlat.h" -#include "CLHEP/Random/RandGauss.h" -#include -#include -#include -#include -// For the TF1s -#include "TROOT.h" -#include "TFile.h" -#include "TTree.h" -#include "TH1F.h" -#include "TF1.h" -#include "TMath.h" - - -G4Mutex inFileMutex2 = G4MUTEX_INITIALIZER; //files are being read so mutex is needed - -remollGenTF1::remollGenTF1() -: remollVEventGen("TF1"), - fFile(0), - fFunc(0),fMollerFunc(0), - fElasticFunc(0), - fInelasticFunc(0), - fType(), - fRing(1), fSector(0) -{ - fApplyMultScatt = true; - r_t = G4RandFlat::shoot(600,1200); - fZpos = (28.5*m - 0.52*m); - fThisGenMessenger->DeclarePropertyWithUnit("rmax","mm",fR_max,"Maximum generation radial hit position (mm) for Remoll generator"); - fThisGenMessenger->DeclarePropertyWithUnit("rmin","mm",fR_min,"Minimum generation radial hit position (mm) for Remoll generator"); - fThisGenMessenger->DeclarePropertyWithUnit("deltaphmax","deg",fDeltaPh_max,"Upward Phi spread limit"); - fThisGenMessenger->DeclarePropertyWithUnit("deltaphmin","deg",fDeltaPh_min,"Downward Phi spread limit"); - fThisGenMessenger->DeclareProperty("BoffsetR",fBoffsetR,"Boolean for offsetting detector to the side (and flat radial distribution if R_max =/= 0)"); - fThisGenMessenger->DeclareProperty("sector",fSector,"Integer sector number for Remoll generator"); - fThisGenMessenger->DeclareProperty("ring",fRing,"Integer ring number for Remoll generator"); - fThisGenMessenger->DeclareMethod("setFileFunction",&remollGenTF1::SetGenFunctionFile,"ROOT filename:function name"); - fThisGenMessenger->DeclareMethod("scattType",&remollGenTF1::SetScatteringType,"Scattering type: moller, elastic, inelastic, or all"); - fThisGenMessenger->DeclareMethod("sector",&remollGenTF1::SetSector,"Sector number: 1,2,or 3, or 0 for all"); - fThisGenMessenger->DeclareMethod("radOffset",&remollGenTF1::SetRadOffset,"Radial offset to center detectors: boolean"); - fThisGenMessenger->DeclareMethod("ring",&remollGenTF1::SetRing,"Detector ring number (1-6)"); - SetScatteringType("all"); - SetSector(0); - SetRadOffset(false); - SetGenFunctionFile("remollGenFunctions.root:elastic_0"); -} - -remollGenTF1::~remollGenTF1() { - if (fFile){ - fFile->Close(); - } - fFunc = 0; - fMollerFunc = 0; - fElasticFunc = 0; - fInelasticFunc = 0; -} - -void remollGenTF1::PrintEventGen() -{ - remollVEventGen::PrintEventGen(); - G4cout << "r hits (Remoll generator) =[" << fR_min/mm << "," << fR_max/mm << "] mm" << G4endl; - G4cout << "phi spread (remoll generator) = [" << fDeltaPh_min/deg << "," << fDeltaPh_max/deg << "] deg" << G4endl; -} - -void remollGenTF1::SetRing(G4int num){ fRing = num; } - -void remollGenTF1::SetRadOffset(G4bool offset){ fBoffsetR = offset; } - -void remollGenTF1::SetScatteringType(G4String input){ fType = input; } - -void remollGenTF1::SetSector(const G4int secnum){ fSector = secnum; } - -void remollGenTF1::SetGenFunctionFile(G4String input) { - if(input == "genDefault"){ //input for generating input files using moller, elastic, and inelastic generators and then performing fits to use as TF1 input - G4cerr << "Reading generated default output files." << G4endl; - distAnalysis(); - return; - } - - if (!input.contains(":")){ - G4cerr << "Improper formatting for user input. Please ensure your macro commands include '/remoll/evgen/TF1/setFileFunction :'" << G4endl; - return; - } - - std::stringstream ss; - ss << input; - - G4String filename; - G4String funcname; - - std::getline(ss, filename, ':'); - std::getline(ss, funcname, ':'); - - G4cout << "File name read as " << filename << G4endl; - G4cout << "Function name read as " << funcname << G4endl; - - G4AutoLock inFileLock(&inFileMutex2); - - G4cout << "Setting the external file to " << filename << G4endl; - - if (fFile) { - fFile->Close(); - fFunc = 0; - } - - fFile = new TFile(filename); - if (! fFile){ - G4cerr << "Could not open function file " << filename << G4endl; - return; - } - - fFile->GetObject(funcname,fFunc); - if (! fFunc){ - G4cerr << "could not find function in file " << filename << G4endl; - return; - } - inFileLock.unlock(); -} - -void remollGenTF1::SamplePhysics(remollVertex * /*vert*/, remollEvent *evt) -{ - if (!fFunc){ - G4cerr << "No Function set before SamplePhysics was called" << G4endl; - return; - } - double xPos, yPos, zPos, zOffset; - fE_min = 2.0*GeV; - fE_max = 11.0*GeV; - - fTh_min = -0*deg;//FIXME Needs justification, what about the angle about the z axis that this points as well, is that phi, or is phi the start position about z? - fTh_max = 2.5*deg; - - fR_min = 0.0*mm; - fR_max = 0.0*mm; - - fPh_min = 0.0*deg; - fPh_max = 360.0*deg; - - fDeltaPh_min = -2.0*deg; - fDeltaPh_max = 2.0*deg; - -// fRing = 5; -// fSector = 0; //FIXME what are the sector options? What do they refer to? -// fBoffsetR = false; - -// zPos = fZ; - - // Get initial Remoll energy instead of using other sampling - double E = G4RandFlat::shoot( fE_min, fE_max ); - double mass = electron_mass_c2; - double p = sqrt(E*E - mass*mass); - - double pX, pY, pZ; - double randTheta, randDeltaPhi, randPhi; - - randTheta = G4RandFlat::shoot( fTh_min, fTh_max ); - randPhi = G4RandFlat::shoot(fPh_min,fPh_max); - randDeltaPhi = G4RandFlat::shoot(fDeltaPh_min,fDeltaPh_max); // FIXME define min/max angle spread in phi direction - pX = cos(randPhi)*sin(randTheta)*p + sin(randPhi)*sin(randDeltaPhi)*p; - pY = sin(randPhi)*sin(randTheta)*p - cos(randPhi)*sin(randDeltaPhi)*p; - pZ = cos(randDeltaPhi)*cos(randTheta)*p; -//get radial distribution from remoll, radius is along x-axis - double radialOffset[6][3] = {{710,710,710}, - {755,755,755}, - {817.5,817.5,817.5}, - {892.5,892.5,892.5}, - {1017.5,987.5,1030}, - {1150,1150,1150}}; - double rad = RadSpectrum(); - zOffset = -1*500; //FIXME arbitrary z offset for Moller distribution propagation - affects air showering noise - zPos = (28500 + zOffset); //FIXME arbitrary z offset for Moller distribution propagation - affects air showering noise - double xHitPos = (rad*cos(randPhi)- 1*((fBoffsetR)? radialOffset[fRing][fSector] : 0.0)); // Putting the offset here means that the detector and distribution will still make circles, just where the edge of the circle now passes the origin - double yHitPos = rad*sin(randPhi); - xPos = xHitPos - (-1*zOffset)*sin(randTheta)*cos(randPhi) - (-1*zOffset)*sin(randPhi)*sin(randDeltaPhi); - yPos = yHitPos - (-1*zOffset)*sin(randTheta)*sin(randPhi) + (-1*zOffset)*cos(randPhi)*sin(randDeltaPhi); - - - assert( E > 0.0 ); - assert( E > mass ); - - evt->ProduceNewParticle( G4ThreeVector(xPos, yPos, zPos), - G4ThreeVector(pX, pY, pZ ), - "e-" ); - evt->fBeamE = E; - evt->fBeamMomentum = evt->fBeamMomentum.unit()*p; - // Override Beam Target creating a spread in z vertex, by overwriting the remollVEventGen.cc functionality - // where it asks the remollBeamTarget to treat the vertex as beam target spread. Adds (+=) the vector fVertexPos - // to the particle position vector defined when particle is defined, happening in PolishEvent() method - evt->fVertexPos.setZ( 0.0 ); - - evt->SetEffCrossSection(0.0); - evt->SetAsymmetry(0.0); - evt->SetQ2(0.0); - evt->SetW2(0.0); - -} - -double remollGenTF1::RadSpectrum(){ - //generate radius from TF1, radius in millimeters! - if (fR_max>0.0 && fBoffsetR==true) { - double flatRad = G4RandFlat::shoot(fR_min,fR_max); - return flatRad; - } - - //Randomly generate the distribution using the Metropolis algorithm - double r, a, u; - //r_t is the previous hit, r is the proposed new hit, a is their relative - //probabilities, and u is the deciding probability. - r = G4RandGauss::shoot(r_t,100); //generate proposed r with gaussian around previous - - if (fType == "all" && !fFile){ - a = (fMollerFunc->Eval(r) + fElasticFunc->Eval(r) + fInelasticFunc->Eval(r)) / (fMollerFunc->Eval(r_t) + fElasticFunc->Eval(r_t) + fInelasticFunc->Eval(r_t)); - }else{ - a = fFunc->Eval(r) / fFunc->Eval(r_t); - } - u = G4RandFlat::shoot(0.0,1.0); - if (u <= a) - r_t = r; - return r_t; -} - -void remollGenTF1::distAnalysis(){ - //takes input of remoll output files using moller, elastic, and inelastic generators - //Pulls hit radius data from the root files and puts it into histograms, and then fits - //those histograms with parameterized functions that are output into remollGenFunctions.root - if (fType == "moller" || fType == "all"){ - G4String fname("remollout_moller.root"); - getHist(fname); - fitHist("moller"); - if(fType == "moller") - fFunc = fMollerFunc; - }if (fType == "elastic" || fType == "all"){ - getHist("remollout_elastic.root"); - fitHist("elastic"); - if (fType == "elastic") - fFunc = fElasticFunc; - }if (fType == "inelastic" || fType == "all"){ - getHist("remollout_inelastic.root"); - fitHist("inelastic"); - if (fType == "inelastic") - fFunc = fInelasticFunc; - } -} - - -void remollGenTF1::getHist(G4String fname){ - G4AutoLock inFileLock(&inFileMutex2); - - G4cout << "Opening file " << fname << G4endl; - TFile *file = new TFile(fname); - if (!file){ - G4cerr << "File not found." << G4endl; - exit(1); - } - TTree *T = (TTree*)(file->Get("T")); - if (!T){ - G4cerr << "TTree T not found" << G4endl; - exit(1); - } - TH1F* rad = new TH1F("rad","hit.r",120,600,1200); - - rad->GetXaxis()->SetTitle("Radius (mm)"); - rad->GetYaxis()->SetTitle("Rate (GeV/5 mm)"); - - int entries = T->GetEntries(); - double rate; - std::vector* Hit = new std::vector; - - if (T->GetBranch("hit")){ - T->SetBranchAddress("hit", &Hit); - }else{ - G4cerr << "Could not find branch hit in input file" << G4endl; - } - if (T->GetBranch("rate")){ - T->SetBranchAddress("rate",&rate); - }else{ - G4cerr << "Could not find branch rate in input file" << G4endl; - } - std::cerr << "Total entries to read: " << entries << std::endl; - for(int i = 0; i < entries; i++){ - T->GetEntry(i); - for (size_t j = 0; j < Hit->size(); j++){ - remollGenericDetectorHit_t hit = Hit->at(j);//create local copy of hit - if (hit.det == 28 && hit.r > 600 && hit.r < 1200 && (hit.pid == 11 || hit.pid == -11)){ - if (fSector == 0){ - rad->Fill(hit.r,rate); - continue; - } - - //determine sector number (conditions provided by Seamus) - double secphi; - double eigth = 360.0/56.0; - if (atan2(hit.y,hit.x)>0){ - secphi = fmod(atan2(hit.y,hit.x),2.0*3.14159/7.0)*180/3.14159; - } - else{ - secphi = fmod(atan2(hit.y,hit.x)+2.0*3.14159,2.0*3.14159/7.0)*180/3.14159; - } - - if((secphi < eigth || secphi > 7*eigth) && fSector == 1) - rad->Fill(hit.r,rate); - if (((eigth < secphi && secphi < 3.0*eigth) || (5.0*eigth < secphi && secphi < 7.0*eigth)) && fSector == 2) - rad->Fill(hit.r,rate); - if ((3.0*eigth < secphi && secphi < 5.0*eigth) && fSector == 3) - rad->Fill(hit.r,rate); - } - } - } - rad->Scale(1e7/entries); - rad->SetDirectory(0); - file->Close(); - inFileLock.unlock(); - if (fname == "remollout_moller.root"){ - fMollerHist = rad; - }else if (fname == "remollout_elastic.root"){ - fElasticHist = rad; - }else if ( fname == "remollout_inelastic.root"){ - fInelasticHist = rad; - } - return; - -} - -void remollGenTF1::fitHist(G4String type){ - TF1* fit; - - //fit histograms of all sectors - if (type == "moller"){ - TH1F* rad = fMollerHist; - G4cerr << "Fitting moller sector " << fSector << G4endl; - fit = new TF1("mol","gaus",600,1200); - rad->GetXaxis()->SetRange(rad->FindBin(900),rad->FindBin(1100)); - double max = rad->GetMaximum(); - double mean = rad->GetBinCenter(rad->GetMaximumBin()); - double FWHM = rad->GetBinCenter(rad->FindLastBinAbove(max/2.0)) - rad->GetBinCenter(rad->FindFirstBinAbove(max/2.0)); - fit->SetParameters(max,FWHM/2,mean); - rad->Fit("mol","NM"); - fMollerFunc = fit; - return; - } - - else if (type == "elastic"){ - TH1F* rad = fElasticHist; - G4cerr << "Fitting elastic sector " << fSector << G4endl; - - fit = new TF1("el", remollGenTF1::elasticFit, 600,1200,6); - - rad->GetXaxis()->SetRange(rad->FindBin(700),rad->FindBin(800)); - - double max = rad->GetMaximum(); - double mean = rad->GetBinCenter(rad->GetMaximumBin()); - double FWHM = rad->GetBinCenter(rad->FindLastBinAbove(max/2.0)) - rad->GetBinCenter(rad->FindFirstBinAbove(max/2.0)); - fit->SetParameter(0,max); - fit->SetParameter(2,mean); - fit->SetParameter(1,FWHM/2); - - //Adjust range to only quadratic range - rad->GetXaxis()->SetRange(rad->FindBin(800),rad->FindBin(1100)); - - //fit->SetParameter(3,8e6); - double b = rad->GetBinCenter(rad->GetMinimumBin()); - double c = rad->GetMinimum(); - double a = rad->GetBinContent(rad->FindBin(b+110))/12100; - - fit->SetParameter(3, a); - fit->SetParameter(4, c); - fit->SetParameter(5, b); - - - rad->GetXaxis()->SetRange(rad->FindBin(600),rad->FindBin(1200)); - rad->Fit(fit,"QMN"); - fit->SetParameters(fit->GetParameters()); - rad->Fit(fit,"MN"); - fElasticFunc = fit; - return; - } - - else if (type == "inelastic"){ - G4cerr << "Fitting inelastic sector "<< fSector << G4endl; - TH1F* rad = fInelasticHist; - fit = new TF1("in",remollGenTF1::inelasticFit,600,1200,5); - - - rad->GetXaxis()->SetRange(0,rad->FindBin(800)); - double max = rad->GetMaximum(); - double mean = rad->GetBinCenter(rad->GetMaximumBin()); - double HWHM = abs(mean - rad->GetBinCenter(rad->FindFirstBinAbove(max/2.0))); - double stddev = 2*HWHM / (2*sqrt(2*log(2))); - fit->SetParameter(0,max); - fit->SetParameter(1,mean); - fit->SetParameter(2,stddev); - - //a*x^-b - rad->GetXaxis()->SetRange(rad->FindBin(mean),rad->FindBin(1200)); - double x1 = 950.0; - double x2 = 1100.0; - double y1 = rad->GetBinContent(rad->FindBin(x1)); - double y2 = rad->GetBinContent(rad->FindBin(x2)); - double b = log(y1/y2) / log(x2/x1); - double a = y1 / pow(x1,-1*b); - fit->SetParameter(3,a); - fit->SetParameter(4,b); - - rad->GetXaxis()->SetRange(0,120); - - rad->Fit(fit,"NMWP"); - fInelasticFunc = fit; - return; - } - return; -} -double remollGenTF1::lorentzFit(double *x, double *par){ - return (0.5*par[0]*par[1]/TMath::Pi())/TMath::Max(1.0e-10,(x[0]-par[2])*(x[0]-par[2]) + 0.25*par[1]*par[1]); -} - -double remollGenTF1::elasticFit(double *x, double *par){ - if (x[0] > 1200 || x[0] < 600) - return 0.0; - double q = 0.0; - double l = lorentzFit(x,par); - - q = (TMath::Abs(par[3])*(x[0]-par[5])*(x[0]-par[5])-par[4]); - if (l < q && x[0] > par[2]){ - return q; - }else{ - return l; - } - return 0.0; -} - -double remollGenTF1::inelasticFit(double *x, double *par){ - double arg = (fabs(par[2])>1e-6)? (x[0] - (par[1]))/par[2] : 0.0; - double g = par[0]*exp(-0.5*arg*arg)/(par[2]*sqrt(2.0*TMath::Pi())); - double e = 0; - if (x[0] > (par[1])) - e = par[3]/TMath::Power(x[0],par[4]);/* + par[5];*/ - if (g > e){ - return g; - } - else{ - return e; - } - return 0.0; -} diff --git a/src/remollGenericDetector.cc b/src/remollGenericDetector.cc index df2ae6c66..0ff4060c5 100644 --- a/src/remollGenericDetector.cc +++ b/src/remollGenericDetector.cc @@ -3,6 +3,7 @@ #include "G4OpticalPhoton.hh" #include "G4SDManager.hh" #include "G4GenericMessenger.hh" +#include "G4PhysicalConstants.hh" #include "remollGenericDetectorHit.hh" #include "remollGenericDetectorSum.hh" @@ -60,7 +61,7 @@ void remollGenericDetector::BuildStaticMessenger() G4AutoLock lock(&remollGenericDetectorMutex); // If already built, just return - if (fStaticMessenger) return; + if (fStaticMessenger != nullptr) return; fStaticMessenger = new G4GenericMessenger(this,"/remoll/SD/","Remoll SD properties"); fStaticMessenger->DeclareMethod( @@ -160,7 +161,7 @@ G4bool remollGenericDetector::ProcessHits(G4Step* step, G4TouchableHistory*) G4double edep = step->GetTotalEnergyDeposit(); // Create a detector sum for this detector, if necessary - if (! fSumMap.count(copyID)) { + if (fSumMap.count(copyID) == 0u) { remollGenericDetectorSum* sum = new remollGenericDetectorSum(fDetNo, copyID); fSumMap[copyID] = sum; fSumColl->insert(sum); @@ -170,7 +171,7 @@ G4bool remollGenericDetector::ProcessHits(G4Step* step, G4TouchableHistory*) sum->AddEDep(pid, pos, edep); // Create a running sum for this detector, if necessary - if (! fRunningSumMap.count(copyID)) { + if (fRunningSumMap.count(copyID) == 0u) { remollGenericDetectorSum* sum = new remollGenericDetectorSum(fDetNo, copyID); fRunningSumMap[copyID] = sum; } @@ -222,7 +223,7 @@ G4bool remollGenericDetector::ProcessHits(G4Step* step, G4TouchableHistory*) G4VUserTrackInformation* usertrackinfo = track->GetUserInformation(); remollUserTrackInformation* remollusertrackinfo = dynamic_cast(usertrackinfo); - if (remollusertrackinfo) { + if (remollusertrackinfo != nullptr) { // if stored postpoint status is fGeomBoundary if (remollusertrackinfo->GetStepStatus() == fGeomBoundary) firststepinvolume = true; @@ -303,6 +304,7 @@ G4bool remollGenericDetector::ProcessHits(G4Step* step, G4TouchableHistory*) hit->fE = track->GetTotalEnergy(); hit->fM = particle->GetPDGMass(); hit->fK = track->GetKineticEnergy(); + hit->fBeta = track->GetVelocity() / c_light; hit->fTrID = track->GetTrackID(); hit->fmTrID = track->GetParentID(); diff --git a/src/remollGenericDetectorHit.cc b/src/remollGenericDetectorHit.cc index 6df8584d2..c7b2b5cfd 100644 --- a/src/remollGenericDetectorHit.cc +++ b/src/remollGenericDetectorHit.cc @@ -20,6 +20,7 @@ remollGenericDetectorHit::remollGenericDetectorHit(G4int det, G4int copy) fE = -1.0; fM = -1.0; fK = -1.0; + fBeta = -1.0; f3XRec = G4ThreeVector(-1e9, -1e9, -1e9); f3dPRec = G4ThreeVector(-1e9, -1e9, -1e9); @@ -56,6 +57,7 @@ remollGenericDetectorHit::remollGenericDetectorHit(const remollGenericDetectorHi fE = right.fE; fM = right.fM; fK = right.fK; + fBeta = right.fBeta; f3XRec = right.f3XRec; f3dPRec = right.f3dPRec; diff --git a/src/remollGenpElastic.cc b/src/remollGenpElastic.cc index 918aaa49f..e713cc715 100644 --- a/src/remollGenpElastic.cc +++ b/src/remollGenpElastic.cc @@ -9,7 +9,6 @@ #include "remollEvent.hh" #include "remollVertex.hh" #include "remollBeamTarget.hh" -#include "remollMultScatt.hh" #include "remolltypes.hh" #include @@ -39,16 +38,16 @@ void remollGenpElastic::SamplePhysics(remollVertex *vert, remollEvent *evt){ double beamE = fBeamTarg->fBeamEnergy; double Ekin = beamE - electron_mass_c2; - std::vector targVols = fBeamTarg->GetTargetVolumes(); + auto targVols = fBeamTarg->GetTargetVolumes(); bool bypass_target = false; - std::vector::iterator it = targVols.begin(); + auto it = targVols.begin(); if( targVols.size() > 0 ){ - while( (*it)->GetLogicalVolume()->GetMaterial()->GetName() != "G4_lH2" + while( (*it).first->GetLogicalVolume()->GetMaterial()->GetName() != "G4_lH2" && it != targVols.end() ){ it++; } - if( (*it)->GetLogicalVolume()->GetMaterial()->GetName() != "G4_lH2" ){ + if( (*it).first->GetLogicalVolume()->GetMaterial()->GetName() != "G4_lH2" ){ G4cerr << __FILE__ << " line " << __LINE__ << ": WARNING could not find target" << G4endl; bypass_target = true; } @@ -66,7 +65,7 @@ void remollGenpElastic::SamplePhysics(remollVertex *vert, remollEvent *evt){ double bt; if( !bypass_target ){ - bt = (4.0/3.0)*(fBeamTarg->fTravelledLength/(*it)->GetLogicalVolume()->GetMaterial()->GetRadlen() + bt = (4.0/3.0)*(fBeamTarg->fTravelledLength/(*it).first->GetLogicalVolume()->GetMaterial()->GetRadlen() + int_bt); } else { bt = 0.0; @@ -229,7 +228,7 @@ void remollGenpElastic::SamplePhysics(remollVertex *vert, remollEvent *evt){ // as anything less than three sigma of the characteristic // width - if( th < 3.0*fBeamTarg->fMS->GetPDGTh() ){ + if( th < 3.0*fBeamTarg->GetMultScatt().GetPDGTh() ){ sigma = 0.0; } diff --git a/src/remollGlobalField.cc b/src/remollGlobalField.cc index 1487217f7..f6eeda60b 100644 --- a/src/remollGlobalField.cc +++ b/src/remollGlobalField.cc @@ -3,7 +3,6 @@ #include "G4TransportationManager.hh" #include "G4FieldManager.hh" #include "G4UImanager.hh" -#include "G4GenericMessenger.hh" #include "G4PropagatorInField.hh" @@ -65,35 +64,31 @@ remollGlobalField::remollGlobalField() fFieldManager->SetDetectorField(this); // Create generic messenger - fMessenger = new G4GenericMessenger(this,"/remoll/","Remoll properties"); - fMessenger->DeclareMethod("addfield",&remollGlobalField::AddNewField,"Add magnetic field"); + fMessenger.DeclareMethod("addfield",&remollGlobalField::AddNewField,"Add magnetic field"); // Create global field messenger - fGlobalFieldMessenger = new G4GenericMessenger(this,"/remoll/field/","Remoll global field properties"); - fGlobalFieldMessenger->DeclareMethod("equationtype",&remollGlobalField::SetEquationType,"Set equation type: \n 0: B-field, no spin (default); \n 2: B-field, with spin"); - fGlobalFieldMessenger->DeclareMethod("steppertype",&remollGlobalField::SetStepperType,"Set stepper type: \n 0: ExplicitEuler; \n 1: ImplicitEuler; \n 2: SimpleRunge; \n 3: SimpleHeum; \n 4: ClassicalRK4 (default); \n 5: CashKarpRKF45"); - fGlobalFieldMessenger->DeclareMethod("print",&remollGlobalField::PrintAccuracyParameters,"Print the accuracy parameters"); - fGlobalFieldMessenger->DeclareProperty("epsmin",fEpsMin,"Set the minimum epsilon of the field propagator"); - fGlobalFieldMessenger->DeclareProperty("epsmax",fEpsMax,"Set the maximum epsilon of the field propagator"); - fGlobalFieldMessenger->DeclareProperty("minstep",fMinStep,"Set the minimum step of the chord finder"); - fGlobalFieldMessenger->DeclareProperty("deltachord",fDeltaChord,"Set delta chord for the chord finder"); - fGlobalFieldMessenger->DeclareProperty("deltaonestep",fDeltaOneStep,"Set delta one step for the field manager"); - fGlobalFieldMessenger->DeclareProperty("deltaintersection",fMinStep,"Set delta intersection for the field manager"); - fGlobalFieldMessenger->DeclareMethod("zoffset",&remollGlobalField::SetZOffset,"Set magnetic field z offset"); - fGlobalFieldMessenger->DeclareMethod("scale",&remollGlobalField::SetFieldScale,"Scale magnetic field by factor"); - fGlobalFieldMessenger->DeclareMethod("current",&remollGlobalField::SetMagnetCurrent,"Scale magnetic field by current"); - fGlobalFieldMessenger->DeclareMethod("value",&remollGlobalField::PrintFieldValue,"Print the field value at a given point (in m)"); - fGlobalFieldMessenger->DeclareProperty("verbose",fVerboseLevel,"Set the verbose level"); + fGlobalFieldMessenger.DeclareMethod("equationtype",&remollGlobalField::SetEquationType,"Set equation type: \n 0: B-field, no spin (default); \n 2: B-field, with spin"); + fGlobalFieldMessenger.DeclareMethod("steppertype",&remollGlobalField::SetStepperType,"Set stepper type: \n 0: ExplicitEuler; \n 1: ImplicitEuler; \n 2: SimpleRunge; \n 3: SimpleHeum; \n 4: ClassicalRK4 (default); \n 5: CashKarpRKF45"); + fGlobalFieldMessenger.DeclareMethod("print",&remollGlobalField::PrintAccuracyParameters,"Print the accuracy parameters"); + fGlobalFieldMessenger.DeclareProperty("epsmin",fEpsMin,"Set the minimum epsilon of the field propagator"); + fGlobalFieldMessenger.DeclareProperty("epsmax",fEpsMax,"Set the maximum epsilon of the field propagator"); + fGlobalFieldMessenger.DeclareProperty("minstep",fMinStep,"Set the minimum step of the chord finder"); + fGlobalFieldMessenger.DeclareProperty("deltachord",fDeltaChord,"Set delta chord for the chord finder"); + fGlobalFieldMessenger.DeclareProperty("deltaonestep",fDeltaOneStep,"Set delta one step for the field manager"); + fGlobalFieldMessenger.DeclareProperty("deltaintersection",fMinStep,"Set delta intersection for the field manager"); + fGlobalFieldMessenger.DeclareMethod("interpolation",&remollGlobalField::SetInterpolationType,"Set magnetic field interpolation type"); + fGlobalFieldMessenger.DeclareMethod("zoffset",&remollGlobalField::SetZOffset,"Set magnetic field z offset"); + fGlobalFieldMessenger.DeclareMethod("scale",&remollGlobalField::SetFieldScale,"Scale magnetic field by factor"); + fGlobalFieldMessenger.DeclareMethod("current",&remollGlobalField::SetMagnetCurrent,"Scale magnetic field by current"); + fGlobalFieldMessenger.DeclareMethod("value",&remollGlobalField::PrintFieldValue,"Print the field value at a given point (in m)"); + fGlobalFieldMessenger.DeclareProperty("verbose",fVerboseLevel,"Set the verbose level"); } remollGlobalField::~remollGlobalField() { - delete fMessenger; - delete fGlobalFieldMessenger; - - if (fEquation) delete fEquation; - if (fStepper) delete fStepper; - if (fChordFinder) delete fChordFinder; + delete fEquation; + delete fStepper; + delete fChordFinder; } void remollGlobalField::SetAccuracyParameters() @@ -122,7 +117,7 @@ void remollGlobalField::PrintAccuracyParameters() void remollGlobalField::SetEquation() { - if (fEquation) delete fEquation; + delete fEquation; switch (fEquationType) { @@ -144,7 +139,7 @@ void remollGlobalField::SetEquation() void remollGlobalField::SetStepper() { - if (fStepper) delete fStepper; + delete fStepper; switch (fStepperType) { @@ -180,7 +175,7 @@ void remollGlobalField::SetStepper() void remollGlobalField::SetChordFinder() { - if (fChordFinder) delete fChordFinder; + delete fChordFinder; fChordFinder = new G4ChordFinder(this,fMinStep,fStepper); fChordFinder->GetIntegrationDriver()->SetVerboseLevel(0); @@ -194,46 +189,39 @@ void remollGlobalField::AddNewField(G4String& name) // If this field has already been loaded if (GetFieldByName(name) != 0) return; - + // Load new field remollMagneticField *thisfield = new remollMagneticField(name); - if (thisfield->IsInit()) { - fFields.push_back(thisfield); - - if (fVerboseLevel > 0) - G4cout << __FUNCTION__ << ": field " << name << " was added." << G4endl; + fFields.push_back(thisfield); - // Add file data to output data stream + if (fVerboseLevel > 0) + G4cout << __FUNCTION__ << ": field " << name << " was added." << G4endl; - remollRunData *rd = remollRun::GetRunData(); + // Add file data to output data stream + remollRunData *rd = remollRun::GetRunData(); - // FIXME disabled TMD5 functionality as long as CentOS 7.2 is common - // due to kernel bug when running singularity containers + // FIXME disabled TMD5 functionality as long as CentOS 7.2 is common + // due to kernel bug when running singularity containers - //TMD5 *md5 = TMD5::FileChecksum(name.data()); + //TMD5 *md5 = TMD5::FileChecksum(name.data()); - filedata_t fdata; + filedata_t fdata; - strcpy(fdata.filename, name.data()); - strcpy(fdata.hashsum, "no hash" ); // md5->AsString() ); + strcpy(fdata.filename, name.data()); + strcpy(fdata.hashsum, "no hash" ); // md5->AsString() ); - //G4cout << "MD5 checksum " << md5->AsString() << G4endl; + //G4cout << "MD5 checksum " << md5->AsString() << G4endl; - //delete md5; + //delete md5; - struct stat fs; - stat(name.data(), &fs); - fdata.timestamp = TTimeStamp( fs.st_mtime ); + struct stat fs; + stat(name.data(), &fs); + fdata.timestamp = TTimeStamp( fs.st_mtime ); - if (fVerboseLevel > 0) - G4cout << __FUNCTION__ << ": field timestamp = " << fdata.timestamp << G4endl; + if (fVerboseLevel > 0) + G4cout << __FUNCTION__ << ": field timestamp = " << fdata.timestamp << G4endl; - rd->AddMagData(fdata); - - } else { - G4cerr << "WARNING " << __FILE__ << " line " << __LINE__ - << ": field " << name << " was not initialized." << G4endl; - } + rd->AddMagData(fdata); } remollMagneticField* remollGlobalField::GetFieldByName(const G4String& name) const @@ -252,34 +240,25 @@ void remollGlobalField::PrintFieldValue(const G4ThreeVector& r) GetFieldValue(p, B); G4cout << "At r" << r << " [m]: B = "; for (int i = 0; i < __GLOBAL_NDIM; i++) { - G4cout << B[i] << " "; + G4cout << B[i]/tesla << " "; } G4cout << "T" << G4endl; } -void remollGlobalField::GetFieldValue(const G4double p[], G4double *resB) const +void remollGlobalField::GetFieldValue(const G4double p[], G4double *field) const { - G4double Bsum [__GLOBAL_NDIM] = {0}; - - std::vector::const_iterator it = fFields.begin(); - for (it = fFields.begin(); it != fFields.end(); it++) { - G4double thisB[__GLOBAL_NDIM] = {0}; - (*it)->GetFieldValue(p, thisB); - - for (int i = 0; i < __GLOBAL_NDIM; i++) { - Bsum[i] += thisB[i]; - } - } - - for (int i = 0; i < __GLOBAL_NDIM; i++) { - resB[i] = Bsum[i]; - } + // Field is not initialized to zero by geant4 + field[0] = 0.0; + field[1] = 0.0; + field[2] = 0.0; + for (auto it = fFields.begin(); it != fFields.end(); it++) + (*it)->AddFieldValue(p, field); } void remollGlobalField::SetZOffset(const G4String& name, G4double offset) { remollMagneticField *field = GetFieldByName(name); - if (field) { + if (field != nullptr) { G4AutoLock lock(&remollGlobalFieldMutex); field->SetZoffset(offset); } else { @@ -288,10 +267,22 @@ void remollGlobalField::SetZOffset(const G4String& name, G4double offset) } } +void remollGlobalField::SetInterpolationType(const G4String& name, const G4String& type) +{ + remollMagneticField *field = GetFieldByName(name); + if (field != nullptr) { + G4AutoLock lock(&remollGlobalFieldMutex); + field->SetInterpolationType(type); + } else { + G4cerr << "WARNING " << __FILE__ << " line " << __LINE__ + << ": field " << name << " interpolation type failed" << G4endl; + } +} + void remollGlobalField::SetFieldScale(const G4String& name, G4double scale) { remollMagneticField *field = GetFieldByName(name); - if (field) { + if (field != nullptr) { G4AutoLock lock(&remollGlobalFieldMutex); field->SetFieldScale(scale); } else { @@ -303,9 +294,9 @@ void remollGlobalField::SetFieldScale(const G4String& name, G4double scale) void remollGlobalField::SetMagnetCurrent(const G4String& name, G4double current) { remollMagneticField *field = GetFieldByName(name); - if (field) { + if (field != nullptr) { G4AutoLock lock(&remollGlobalFieldMutex); - field->SetMagnetCurrent(current); + field->SetRefCurrent(current); } else { G4cerr << "WARNING " << __FILE__ << " line " << __LINE__ << ": field " << name << " scaling failed" << G4endl; diff --git a/src/remollHEPEvtInterface.cc b/src/remollHEPEvtInterface.cc index ee273aa48..8c815d4ba 100644 --- a/src/remollHEPEvtInterface.cc +++ b/src/remollHEPEvtInterface.cc @@ -52,20 +52,20 @@ remollHEPEvtInterface::remollHEPEvtInterface() remollHEPEvtInterface::~remollHEPEvtInterface() { G4AutoLock lock(&remollHEPEvtInterfaceMutex); - if(fHEPEvtInterface) { delete fHEPEvtInterface; fHEPEvtInterface = 0; } + if(fHEPEvtInterface != nullptr) { delete fHEPEvtInterface; fHEPEvtInterface = 0; } delete fMessenger; } void remollHEPEvtInterface::Initialize() { G4AutoLock lock(&remollHEPEvtInterfaceMutex); - if (fHEPEvtInterface) { delete fHEPEvtInterface; fHEPEvtInterface = 0; } + if (fHEPEvtInterface != nullptr) { delete fHEPEvtInterface; fHEPEvtInterface = 0; } fHEPEvtInterface = new G4HEPEvtInterface(fFilename,fVerbose); } void remollHEPEvtInterface::GeneratePrimaryVertex(G4Event* anEvent) { G4AutoLock lock(&remollHEPEvtInterfaceMutex); - if (!fHEPEvtInterface) { Initialize(); } + if (fHEPEvtInterface == nullptr) { Initialize(); } fHEPEvtInterface->GeneratePrimaryVertex(anEvent); } diff --git a/src/remollIO.cc b/src/remollIO.cc index e5908be3a..91f0db622 100644 --- a/src/remollIO.cc +++ b/src/remollIO.cc @@ -5,7 +5,6 @@ #include #include "G4ParticleDefinition.hh" -#include "G4GenericMessenger.hh" #include "remollGenericDetectorHit.hh" #include "remollGenericDetectorSum.hh" @@ -19,6 +18,10 @@ #include #include +#ifdef __APPLE__ +#include +#endif + #include #include #include @@ -31,47 +34,43 @@ ClassImp(remollSeed_t) // Singleton remollIO* remollIO::gInstance = 0; -remollIO* remollIO::GetInstance() { +remollIO* remollIO::GetInstance(const G4String& outputfile) { if (gInstance == 0) { - gInstance = new remollIO(); + gInstance = new remollIO(outputfile); } return gInstance; } -remollIO::remollIO() -: fFile(0),fTree(0),fFilename("remollout.root"),fRate(0) +remollIO::remollIO(const G4String& outputfile) +: fFile(0),fTree(0),fFilename(outputfile),fRate(0) { - // Create generic messenger - fMessenger = new G4GenericMessenger(this,"/remoll/","Remoll properties"); - fMessenger->DeclareProperty("filename",fFilename,"Output filename"); + fMessenger.DeclareProperty("filename",fFilename,"Output filename"); } remollIO::~remollIO() { // Delete tree - if (fTree) { + if (fTree != nullptr) { delete fTree; fTree = NULL; } // Delete file - if (fFile) { + if (fFile != nullptr) { delete fFile; fFile = NULL; } - - delete fMessenger; } void remollIO::InitializeTree() { - if (fFile) { + if (fFile != nullptr) { fFile->Close(); delete fFile; fFile = NULL; fTree = NULL; } - if (fTree) { + if (fTree != nullptr) { delete fTree; fTree = NULL; } @@ -106,7 +105,7 @@ void remollIO::InitializeTree() void remollIO::FillTree() { - if( !fTree ){ + if( fTree == nullptr ){ G4cerr << "Error " << __PRETTY_FUNCTION__ << ": " << __FILE__ << " line " << __LINE__ << " - Trying to fill non-existent tree" << G4endl; @@ -133,7 +132,7 @@ void remollIO::Flush() void remollIO::WriteTree() { - if (!fFile) + if (fFile == nullptr) return; if (!fFile->IsOpen()) { @@ -167,7 +166,7 @@ void remollIO::WriteTree() void remollIO::SetEventData(const remollEvent *ev) { - if (! ev) return; + if (ev == nullptr) return; fRate = ev->fRate*s; @@ -178,7 +177,7 @@ void remollIO::SetEventData(const remollEvent *ev) // Beam data const remollBeamTarget* bt = ev->GetBeamTarget(); - if (bt) + if (bt != nullptr) fBm = bt->GetBeamTargetIO(); } @@ -268,15 +267,15 @@ void remollIO::SearchGDMLforFiles(G4String fn) str_docURI.erase(str_docURI.find_last_of('/') + 1); // remove cwd at begin char cwd[MAXPATHLEN]; - if (getcwd(cwd,MAXPATHLEN) && str_docURI.find(cwd) == 0) { + if ((getcwd(cwd,MAXPATHLEN) != nullptr) && str_docURI.find(cwd) == 0) { str_docURI.erase(0, strlen(cwd) + 1); } // Get doctype and entities xercesc::DOMDocumentType* xmlDocType = xmlDoc->getDoctype(); - if (xmlDocType) { + if (xmlDocType != nullptr) { xercesc::DOMNamedNodeMap* xmlNamedNodeMap = xmlDocType->getEntities(); - if (xmlNamedNodeMap) { + if (xmlNamedNodeMap != nullptr) { for (XMLSize_t xx = 0; xx < xmlNamedNodeMap->getLength(); ++xx) { xercesc::DOMNode* currentNode = xmlNamedNodeMap->item(xx); if (currentNode->getNodeType() == xercesc::DOMNode::ENTITY_NODE) { // is entity @@ -310,7 +309,7 @@ void remollIO::TraverseChildren( xercesc::DOMElement *thisel ) for( XMLSize_t xx = 0; xx < nodeCount; ++xx ){ xercesc::DOMNode* currentNode = children->item(xx); - if( currentNode->getNodeType() ){ // true is not NULL + if( currentNode->getNodeType() != 0u ){ // true is not NULL if (currentNode->getNodeType() == xercesc::DOMNode::ELEMENT_NODE) { // is element xercesc::DOMElement* currentElement diff --git a/src/remollMagneticField.cc b/src/remollMagneticField.cc index a6ff71160..c38c2c957 100644 --- a/src/remollMagneticField.cc +++ b/src/remollMagneticField.cc @@ -8,6 +8,8 @@ #include "G4SystemOfUnits.hh" #include "G4PhysicalConstants.hh" +#include "remollSearchPath.hh" + #include #include @@ -25,127 +27,148 @@ #include #endif -remollMagneticField::remollMagneticField( G4String filename ){ - - fFilename = filename; - - // Initialize grid variables - for( int cidx = kR; cidx < kZ; cidx++ ){ - fN[cidx] = -1; - fMin[cidx] = -1e9; - fMax[cidx] = -2e9; - } - - fPhi0 = -1e9; - - // Default offset for field maps in reference frame with - // the hall pivot at z = 0. - fZoffset = -5000.0; - - fInit = false; - fMagCurrent0 = -1e9; - - fFieldScale = 1.0; - - ReadFieldMap(); -} - -remollMagneticField::~remollMagneticField(){ -} - -G4String remollMagneticField::GetName(){ - if( !fInit ){ - G4cerr << "WARNING " << __FILE__ << " line " << __LINE__ - << ": access uninitialized field." << G4endl; - return G4String(""); - } - - return fFilename; -} - -void remollMagneticField::SetFieldScale(G4double s){ - fFieldScale = s; - G4cout << fFilename << " scale set to " << s << G4endl; - return; -} - -void remollMagneticField::SetMagnetCurrent(G4double s){ - if( fMagCurrent0 > 0.0 ){ - SetFieldScale(s/fMagCurrent0); - } else { - G4cerr << "Warning: " << __FILE__ << " line " << __LINE__ - << ": Field current not specified in map " << fFilename << " - Ignoring and proceeding " << G4endl; - } - return; -} - - -void remollMagneticField::InitializeGrid() { - /*! - * Dynamically size 3D vectors to what we need to store the file - * These should already be set from values read in from the fieldmap - */ - - if( fN[kR] <= 0 || fN[kPhi] <= 0 || fN[kZ] <= 0 ){ - G4cerr << "Error " << __FILE__ << " line " << __LINE__ - << ": grid size invalid. Aborting" << G4endl; - exit(1); - } - - G4cout << "Initializing field map grid for " << fFilename << G4endl; - G4int cidx, ridx, pidx, zidx; - - for( cidx = kR; cidx <= kZ; cidx++ ){ - // Set up storage space for table - fBFieldData[cidx].clear(); - fBFieldData[cidx].resize(fN[kR]); - - for( ridx = 0; ridx < fN[kR]; ridx++) { - fBFieldData[cidx][ridx].resize(fN[kPhi]); - - for( pidx=0; pidx> fN[cidx] >> fMin[cidx] >> fMax[cidx]) { - G4cout << "N,min,max[" << cidx << "] = " << fN[cidx] << "," - << fMin[cidx] << "," << fMax[cidx] << G4endl; + fMin[cidx] *= fUnit[cidx]; + fMax[cidx] *= fUnit[cidx]; + fStep[cidx] = (fMax[cidx] - fMin[cidx]) / (fN[cidx] - 1); + G4cout << "N,min,max,step[" << cidx << "] = " << fN[cidx] << "," + << fMin[cidx] << "," << fMax[cidx] << "," << fStep[cidx] << G4endl; } else { - G4cerr << "Error " << __FILE__ << " line " << __LINE__ + G4cerr << "Error " << __FILE__ << " line " << __LINE__ << ": File " << fFilename << " contains unreadable header. Aborting" << G4endl; exit(1); } } + // Read in grid offsets getline(inputfile,inputline); if (std::istringstream(inputline) >> fPhiMapOffset >> fZMapOffset) { G4cout << "PhiMapOffset,ZMapOffset = " << fPhiMapOffset << "," @@ -191,37 +219,36 @@ void remollMagneticField::ReadFieldMap(){ exit(1); } - fPhiMapOffset *= deg; - fZMapOffset *= m; + fPhiMapOffset *= fUnit[kPhi]; + fZMapOffset *= fUnit[kZ]; + // Read in extants getline(inputfile,inputline); if (std::istringstream(inputline) >> fNxtant) { G4cout << "Nxtant = " << fNxtant << G4endl; } else { - G4cerr << "Error " << __FILE__ << " line " << __LINE__ + G4cerr << "Error " << __FILE__ << " line " << __LINE__ << ": File " << fFilename << " contains unreadable header. Aborting" << G4endl; exit(1); } - G4cout << __PRETTY_FUNCTION__ << ": N xtants = " << fNxtant << G4endl; fxtantSize = 2.0*pi/fNxtant; ////////////////////////////////////////////////////////////////////// getline(inputfile,inputline); - if (std::istringstream(inputline) >> fMagCurrent0) { - G4cout << "MagCurrent0 = " << fMagCurrent0 << G4endl; + if (std::istringstream(inputline) >> fRefCurrent) { + G4cout << "RefCurrent = " << fRefCurrent << G4endl; } else { G4cerr << "Error " << __FILE__ << " line " << __LINE__ << ": File " << fFilename << " contains unreadable header. Aborting" << G4endl; exit(1); } - G4cout << __PRETTY_FUNCTION__ << ": field current = " << fMagCurrent0 << " A" << G4endl; // Sanity check on header data if( !( fMin[kR] >= 0.0 && fMin[kR] < fMax[kR] && - -180.0 <= fMin[kPhi] && fMin[kPhi] <= 180.0 && - -180.0 <= fMax[kPhi] && fMax[kPhi] <= 180.0 && + -180.0*deg <= fMin[kPhi] && fMin[kPhi] <= 180.0*deg && + -180.0*deg <= fMax[kPhi] && fMax[kPhi] <= 180.0*deg && fMin[kPhi] < fMax[kPhi] && fMin[kZ] < fMax[kZ] && fN[kR] > 0 && fN[kPhi] > 0 && fN[kZ] > 0 && @@ -230,32 +257,22 @@ void remollMagneticField::ReadFieldMap(){ ){ G4cerr << "Error " << __FILE__ << " line " << __LINE__ << ": File " << fFilename << " contains invalid header data. Aborting" << G4endl; - G4cerr<<"fMin[kR] >= 0.0: "<= 0.0)<<" "<= 0.0: "<= 0.0)<<" "< 0: "< 0 )<<" "< 0: "< 0 )<<" "< 0: "< 0 )<<" "< 0: "< 0 )<<" "<>(fN[kPhi], + std::vector(fN[kZ], 0.0))); + } - for( zidx = 0; zidx < fN[kZ]; zidx++ ){ - for( pidx = 0; pidx < fN[kPhi]; pidx++ ){ - for( ridx = 0; ridx < fN[kR]; ridx++ ){ + // Read in values + G4int nlines = 0; + for (size_t zidx = 0; zidx < fN[kZ]; zidx++) { + for (size_t pidx = 0; pidx < fN[kPhi]; pidx++) { + for (size_t ridx = 0; ridx < fN[kR]; ridx++) { getline(inputfile,inputline); // Read in field values and assign units - if (std::istringstream(inputline) >> raw_R_m >> raw_Phi_deg >> raw_Z_m >> br >> bp >> bz) { + G4double r, phi, z, bx, by, bz; + if (std::istringstream(inputline) >> r >> phi >> z >> bx >> by >> bz) { nlines++; } else { G4cerr << "Error " << __FILE__ << " line " << __LINE__ @@ -325,82 +351,53 @@ void remollMagneticField::ReadFieldMap(){ exit(1); } - //////////////////////////////////////////////////////////////////// - // This checks that we're reading in properly framed data - // This can probably be condensed - if( ridx == 0 ){ - if( fabs(raw_R_m*m - fMin[kR]) > eps ){ - G4cerr << "Error " << __FILE__ << " line " << __LINE__ - << ": File " << fFilename << " contains bad data framing in R. Aborting" << G4endl; - G4cerr << "Index ("<< ridx << ", " << pidx << ", " << zidx << ") Expected " << fMin[kR]/m << " read " << raw_R_m << G4endl; - exit(1); - } - } - if( pidx == 0 ){ - if( fabs(raw_Phi_deg*deg - fFileMin[kPhi]) > eps ){ - G4cerr << "Error " << __FILE__ << " line " << __LINE__ - << ": File " << fFilename << " contains bad data framing in Phi. Aborting" << G4endl; - G4cerr << "Index ("<< ridx << ", " << pidx << ", " << zidx << ") Expected " << fFileMin[kPhi]/degree << " read " << raw_Phi_deg << G4endl; - exit(1); - } - } - if( zidx == 0 ){ - if( fabs(raw_Z_m*m - fFileMin[kZ]) > eps ){ - G4cerr << "Error " << __FILE__ << " line " << __LINE__ - << ": File " << fFilename << " contains bad data framing in Z. Aborting" << G4endl; - G4cerr << "Index ("<< ridx << ", " << pidx << ", " << zidx << ") Expected " << fFileMin[kZ]/m << " read " << raw_Z_m << G4endl; - exit(1); - } - } - if( ridx == fN[kR]-1 ){ - if( fabs(raw_R_m*m - fMax[kR]) > eps ){ - G4cerr << "Error " << __FILE__ << " line " << __LINE__ - << ": File " << fFilename << " contains bad data framing in R. Aborting" << G4endl; - G4cerr << "Index ("<< ridx << ", " << pidx << ", " << zidx << ") Expected " << fMax[kR]/m << " read " << raw_R_m << G4endl; - exit(1); - } + // Check that we're reading in properly framed data + if( fabs(r*fUnit[kR] - (fMin[kR] + ridx * fStep[kR]) ) > eps ){ + G4cerr << "Error " << __FILE__ << " line " << __LINE__ + << ": File " << fFilename << " contains bad data framing in R. Aborting" << G4endl; + G4cerr << "Index ("<< ridx << ", " << pidx << ", " << zidx << ") Expected " << (fMin[kR] + ridx * fStep[kR])/m << " read " << r << G4endl; + exit(1); } - if( pidx == fN[kPhi]-1 ){ - if( fabs(raw_Phi_deg*deg - fFileMax[kPhi]) > eps ){ - G4cerr << "Error " << __FILE__ << " line " << __LINE__ - << ": File " << fFilename << " contains bad data framing in Phi. Aborting" << G4endl; - G4cerr << "Index ("<< ridx << ", " << pidx << ", " << zidx << ") Expected " << fFileMax[kPhi]/m << " read " << raw_Phi_deg << G4endl; - exit(1); - } + + if( fabs(phi*fUnit[kPhi] - (fFileMin[kPhi] + pidx * fStep[kPhi]) ) > eps ){ + G4cerr << "Error " << __FILE__ << " line " << __LINE__ + << ": File " << fFilename << " contains bad data framing in Phi. Aborting" << G4endl; + G4cerr << "Index ("<< ridx << ", " << pidx << ", " << zidx << ") Expected " << fFileMin[kPhi]/degree << " read " << phi << G4endl; + exit(1); } - if( zidx == fN[kZ]-1 ){ - if( fabs(raw_Z_m*m - fFileMax[kZ]) > eps ){ - G4cerr << "Error " << __FILE__ << " line " << __LINE__ - << ": File " << fFilename << " contains bad data framing in Z. Aborting" << G4endl; - G4cerr << "Index ("<< ridx << ", " << pidx << ", " << zidx << ") Expected " << fFileMax[kZ]/m << " read " << raw_Z_m << G4endl; - exit(1); - } + if( fabs(z*fUnit[kZ] - (fFileMin[kZ] + zidx * fStep[kZ]) ) > eps ){ + G4cerr << "Error " << __FILE__ << " line " << __LINE__ + << ": File " << fFilename << " contains bad data framing in Z. Aborting" << G4endl; + G4cerr << "Index ("<< ridx << ", " << pidx << ", " << zidx << ") Expected " << fFileMin[kZ]/m << " read " << z << G4endl; + exit(1); } - //////////////////////////////////////////////////////////////////// - - /* convert to proper units */ - //G4double val_R = raw_R_m*m; - //G4double val_Z = raw_Z_m*m; - //G4double val_Phi = raw_Phi_deg*degree; // Set the grid values to the values which have been read-in - fBFieldData[kR][ridx][pidx][zidx] = br*tesla; - fBFieldData[kPhi][ridx][pidx][zidx] = bp*tesla; - fBFieldData[kZ][ridx][pidx][zidx] = bz*tesla; + fBFieldData[0][ridx][pidx][zidx] = bx*tesla; + fBFieldData[1][ridx][pidx][zidx] = by*tesla; + fBFieldData[2][ridx][pidx][zidx] = bz*tesla; } } } - fInit = true; G4cout << "... done reading " << nlines << " lines." << G4endl<< G4endl; +} +void remollMagneticField::GetFieldValue(const G4double point[4], G4double *field ) const +{ + // set to zero + field[0] = 0.0; + field[1] = 0.0; + field[2] = 0.0; + // add values + AddFieldValue(point, field); } -void remollMagneticField::GetFieldValue(const G4double Point[4], G4double *Bfield ) const +void remollMagneticField::AddFieldValue(const G4double point[4], G4double *field ) const { // Check the bounding box - if (! IsInBoundingBox(Point)) return; + if (! IsInBoundingBox(point)) return; // First we have to translate into polar or cylindric coordinates // since the field maps are given in cylindric coordinates and the @@ -410,37 +407,33 @@ void remollMagneticField::GetFieldValue(const G4double Point[4], G4double *Bfiel // back to the field manager // 1. First calculate r and z - G4double r = sqrt(Point[0]*Point[0] + Point[1]*Point[1]); - G4double z = Point[2] - fZoffset; + G4double r = sqrt(point[0]*point[0] + point[1]*point[1]); + G4double z = point[2] - fZoffset; // Check that the point is a valid number if( std::isnan(r) || std::isinf(r) || std::isnan(z) || std::isinf(z) ){ G4cerr << __FILE__ << " line " << __LINE__ << ": ERROR bad conversion to cylindrical coordinates" << G4endl; - G4cerr << "Point ( " << Point[0]/m << ", " << Point[1]/m << ", " << Point[2]/m << " ) m" << G4endl; + G4cerr << "Point ( " << point[0]/m << ", " << point[1]/m << ", " << point[2]/m << " ) m" << G4endl; exit(1); } // Check that the point is within the defined region - if( r > fMax[kR] || r < fMin[kR] || - z > fMax[kZ] || z < fMin[kZ] ){ + if( r >= fMax[kR] || r < fMin[kR] || + z >= fMax[kZ] || z < fMin[kZ] ){ return; } - // Ensure we're going to get our grid indices correct - assert( fMin[kR] <= r && r <= fMax[kR] ); - assert( fMin[kZ] <= z && z <= fMax[kZ] ); - // 2. Next calculate phi (slower) - G4double phi = atan2(Point[1],Point[0]); + G4double phi = atan2(point[1],point[0]); // Check that the point is a valid number if( std::isnan(phi) || std::isinf(phi) ){ G4cerr << __FILE__ << " line " << __LINE__ << ": ERROR bad conversion to cylindrical coordinates" << G4endl; - G4cerr << "Point ( " << Point[0]/m << ", " << Point[1]/m << ", " << Point[2]/m << " ) m" << G4endl; + G4cerr << "Point ( " << point[0]/m << ", " << point[1]/m << ", " << point[2]/m << " ) m" << G4endl; exit(1); } @@ -470,15 +463,16 @@ void remollMagneticField::GetFieldValue(const G4double Point[4], G4double *Bfiel // Check that the point is within the defined region // before interpolation. If it is outside, the field is zero - if( lphi > fFileMax[kPhi] || lphi < fFileMin[kPhi] ){ + if( lphi >= fFileMax[kPhi] || lphi < fFileMin[kPhi] ){ return; } // Ensure we're going to get our grid indices correct - assert( fFileMin[kPhi] <= lphi && lphi <= fFileMax[kPhi] ); + assert( fFileMin[kPhi] <= lphi && lphi < fFileMax[kPhi] ); - // 3. Get interoplation variables + // 3. Get interpolation variables + // the N-1 here is fencepost problem G4double x[__NDIM] = {0}; G4double didx[__NDIM] = {0}; @@ -487,42 +481,77 @@ void remollMagneticField::GetFieldValue(const G4double Point[4], G4double *Bfiel x[kZ] = modf( ( z - fMin[kZ] )*(fN[kZ]-1)/( fMax[kZ] - fMin[kZ] ), &(didx[kZ]) ); // Cast these to integers for indexing and check - G4int idx[__NDIM] = {0}; - for(int cidx = 0; cidx < __NDIM; cidx++ ){ idx[cidx] = (G4int) didx[cidx]; } - + size_t idx[__NDIM] = {0}; + for (size_t cidx = 0; cidx < __NDIM; cidx++) { + idx[cidx] = size_t(didx[cidx]); + } assert( 0 <= idx[kR] && idx[kR] < fN[kR] ); assert( 0 <= idx[kPhi] && idx[kPhi] < fN[kPhi] ); assert( 0 <= idx[kZ] && idx[kZ] < fN[kZ] ); + // Flag edge cases and treat at best as linear + EInterpolationType type = fInterpolationType; + if (idx[kR] == 0 || idx[kR] == fN[kR] - 2 + || idx[kZ] == 0 || idx[kZ] == fN[kZ] - 2) { + type = kLinear; + } + G4int phi_wrap = INT_MAX; + if (fNxtant == 1 && fxtantSize > 1.9*pi) { + phi_wrap = fN[kPhi] - 1; + } else if (idx[kPhi] == 0 || idx[kPhi] == fN[kPhi] - 2) { + } + + // number of cell vertices + size_t n = 64; + const char (*map)[3] = kCubicMap; + switch (type) { + case kLinear: + map = kLinearMap; + n = 8; + break; + case kCubic: + map = kCubicMap; + n = 64; + break; + } + + // values of cell vertices + thread_local G4double values[__NDIM][64]; + for (size_t i = 0; i < n; i++) { + for (size_t cidx = 0; cidx < __NDIM; cidx++) { + values[cidx][i] = + fBFieldData[cidx] + [idx[kR] + map[i][kR]] + [(idx[kPhi] + map[i][kPhi] + fN[kPhi] - 1) % phi_wrap] // wrap around + [idx[kZ] + map[i][kZ]]; + } + } + // Interpolate - G4double Bint[__NDIM] = {0}; + G4ThreeVector Bcart(0.0,0.0,0.0); for(int cidx = 0; cidx < __NDIM; cidx++ ){ - - G4double c00, c10, c01, c11; - c00 = fBFieldData[cidx][idx[kR]][idx[kPhi]][idx[kZ]]*(1.0-x[kR]) - + fBFieldData[cidx][idx[kR]+1][idx[kPhi]][idx[kZ]]*x[kR]; - c10 = fBFieldData[cidx][idx[kR]][idx[kPhi]+1][idx[kZ]]*(1.0-x[kR]) - + fBFieldData[cidx][idx[kR]+1][idx[kPhi]+1][idx[kZ]]*x[kR]; - c01 = fBFieldData[cidx][idx[kR]][idx[kPhi]][idx[kZ]+1]*(1.0-x[kR]) - + fBFieldData[cidx][idx[kR]+1][idx[kPhi]][idx[kZ]+1]*x[kR]; - c11 = fBFieldData[cidx][idx[kR]][idx[kPhi]+1][idx[kZ]+1]*(1.0-x[kR]) - + fBFieldData[cidx][idx[kR]+1][idx[kPhi]+1][idx[kZ]+1]*x[kR]; - - G4double c0, c1; - c0 = c00*(1.0-x[kPhi]) + c10*x[kPhi]; - c1 = c01*(1.0-x[kPhi]) + c11*x[kPhi]; - - Bint[cidx] = c0*(1.0-x[kZ])+c1*x[kZ]; + switch (type) { + case kLinear: { + Bcart[cidx] = _trilinearInterpolate(values[cidx], x); + break; + } + case kCubic: { + Bcart[cidx] = _tricubicInterpolate(values[cidx], x); + break; + } + } } - G4ThreeVector Bcart = G4ThreeVector(Bint[kR], Bint[kPhi], Bint[kZ]); - Bcart.rotateZ(lphi + fPhiMapOffset); // this changes coordinates from Br, Bphi to Bx, By - // Now we are cartesian, which is what we need to feed Geant4 (yay) + // rotate by local phi, offset, and xtant + Bcart.rotateZ(lphi + fPhiMapOffset + xtant*fxtantSize); + + // scale field + Bcart *= fFieldScale; - Bcart.rotateZ(xtant*fxtantSize); // rotate into our xtant - Bfield[0] = Bcart.x()*fFieldScale; - Bfield[1] = Bcart.y()*fFieldScale; - Bfield[2] = Bcart.z()*fFieldScale; + // add to original field + field[0] += Bcart.x(); + field[1] += Bcart.y(); + field[2] += Bcart.z(); } diff --git a/src/remollMultScatt.cc b/src/remollMultScatt.cc index 5d1020939..5cd22ee97 100644 --- a/src/remollMultScatt.cc +++ b/src/remollMultScatt.cc @@ -13,87 +13,68 @@ remollMultScatt::remollMultScatt() { InitInternal(); - - return; } -remollMultScatt::remollMultScatt( double p, int nmat, double t[], double A[], double Z[] ){ +remollMultScatt::remollMultScatt(double p, const std::vector>& m) +: remollMultScatt() { /* p - electron momentum - nmat - number of materials - t - Thickness - A - Mass number - Z - Atomic number + (t, - Thickness + A, - Mass number + Z) - Atomic number */ - InitInternal(); - remollMultScatt(); - Init( p, nmat, t, A, Z ); - return; + Init(p, m); } -remollMultScatt::remollMultScatt( double p, double t, double A, double Z ){ +remollMultScatt::remollMultScatt(double p, const std::tuple& m) { /* p - electron momentum - nmat - number of materials - t - Thickness - A - Mass number - Z - Atomic number + (t, - Thickness + A, - Mass number + Z) - Atomic number */ InitInternal(); - Init( p, t, A, Z ); - - return; + Init(p, m); } void remollMultScatt::InitInternal(){ fInit = false; fErf2sig = erf(2.0/sqrt(2.0)); - fNmat = 0; } -void remollMultScatt::Init( double p, int nmat, double t[], double A[], double Z[] ){ - /* +void remollMultScatt::Init(double p, const std::vector>& m) { + /* Load materials and calculate necessary variables to generate distributions p - electron momentum - nmat - number of materials - t - Thickness - A - Mass number - Z - Atomic number + (t, - Thickness + A, - Mass number + Z) - Atomic number */ - int i; - - if( nmat >= MAT_MAX ){ - fprintf(stderr, "%s %s line %d: Too many materials. Limited by MAT_MAX (%d)\n", - __FILE__, __FUNCTION__, __LINE__, MAT_MAX ); - return; - } - - fNmat = nmat; - fReturnZero = false; fInit = false; fp = p; - for( i = 0; i < nmat; i++ ){ - assert( !std::isnan(t[i]) && !std::isinf(t[i]) && - !std::isnan(A[i]) && !std::isinf(A[i]) && - !std::isnan(Z[i]) && !std::isinf(Z[i]) ); + fm.resize(m.size()); + for (size_t i = 0; i < m.size(); i++) { + assert( !std::isnan(std::get<0>(m[i])) && !std::isinf(std::get<0>(m[i])) && + !std::isnan(std::get<1>(m[i])) && !std::isinf(std::get<1>(m[i])) && + !std::isnan(std::get<2>(m[i])) && !std::isinf(std::get<2>(m[i])) ); - ft[i] = t[i]; - fA[i] = A[i]; - fZ[i] = Z[i]; + fm[i] = m[i]; } double radsum = 0.0; - double X0; - for( i = 0; i < nmat; i++ ){ - X0 = (716.4*g/cm2)*A[i]/(Z[i]*(Z[i]+1.0)*log(287.0/sqrt(Z[i]))); - radsum += t[i]/X0; + for (size_t i = 0; i < m.size(); i++) { + double t = std::get<0>(m[i]); + double A = std::get<1>(m[i]); + double Z = std::get<2>(m[i]); + double X0 = (716.4*g/cm2)*A/(Z*(Z+1.0)*log(287.0/sqrt(Z))); + radsum += t/X0; } // First work out characteristic gaussian spread. @@ -107,14 +88,15 @@ void remollMultScatt::Init( double p, int nmat, double t[], double A[], double Z fthpdg = thpdg; // First calculate b - - double expb_num, expb_den; double bsum = 0.0; - for( i = 0; i < fNmat; i++ ){ - expb_num = (6680.0*cm2/g)*ft[i]*(fZ[i]+1.0)*pow(fZ[i],1.0/3.0); - expb_den = fA[i]*(1.0+3.34*pow(fZ[i]/137.0,2.0)); + for (size_t i = 0; i < fm.size(); i++) { + double t = std::get<0>(fm[i]); + double A = std::get<1>(fm[i]); + double Z = std::get<2>(fm[i]); + expb_num = (6680.0*cm2/g)*t*(Z+1.0)*pow(Z,1.0/3.0); + expb_den = A*(1.0+3.34*pow(Z/137.0,2.0)); bsum += expb_num/expb_den; } @@ -124,18 +106,9 @@ void remollMultScatt::Init( double p, int nmat, double t[], double A[], double Z /* Added bsum < 0 check to this if statement otherwise if target material is set to vacuum for beam on target case b would be nan and exit the simulation - Rakitha Fri Aug 21 12:19:37 EDT 2015 */ - if( fNmat == 0 || bsum < 0 || log(bsum) < 1.0){ + if (fm.size() == 0 || bsum < 0 || log(bsum) < 1.0) { fInit = true; fReturnZero = true; - - /* - fprintf(stderr, "%s line %d: WARNING sum of b is %f\n", __FILE__, __LINE__, bsum ); - for( i = 0; i < fNmat; i++ ){ - fprintf(stderr, "\tThickness mat %d: %f g/cm2\n", i, ft[i] ); - } - fprintf(stderr, "Too little material - disabling MS for this configuration\n"); - */ - return; } @@ -158,13 +131,14 @@ void remollMultScatt::Init( double p, int nmat, double t[], double A[], double Z // Change of variables - double chi2, chi2_num, chi2_den; - - chi2 = 0.0; + double chi2 = 0.0; - for( i = 0; i < fNmat; i++ ){ - chi2_num = 4.0*3.14159*e_squared*e_squared*ft[i]*fZ[i]*(fZ[i]+1.0); - chi2_den = fp*fp*(A[i]*g/mole); + for (size_t i = 0; i < fm.size(); i++) { + double t = std::get<0>(fm[i]); + double A = std::get<1>(fm[i]); + double Z = std::get<2>(fm[i]); + double chi2_num = 4.0*3.14159*e_squared*e_squared*t*Z*(Z+1.0); + double chi2_den = fp*fp*(A*g/mole); chi2 += chi2_num/chi2_den; } @@ -202,27 +176,21 @@ void remollMultScatt::Init( double p, int nmat, double t[], double A[], double Z return; } -void remollMultScatt::Init( double p, double t, double A, double Z ){ +void remollMultScatt::Init(double p, const std::tuple& m) { /* p - electron momentum, [GeV] - nmat - number of materials - t - Thickness [g/cm2] - A - Mass number - Z - Atomic number + (t, - Thickness [g/cm2] + A, - Mass number + Z) - Atomic number */ - - double tt[] = {t}; - double tA[] = {A}; - double tZ[] = {Z}; - - Init( p, 1, tt, tA, tZ ); - return; + std::vector> tm(1, m); + Init(p, tm); } double remollMultScatt::J0(double x) { // Returns J0 for any real x // Stolen from ROOT in TMath.cxx - + double ax,z; double xx,y,result,result1,result2; const double p1 = 57568490574.0, p2 = -13362590354.0, p3 = 651619640.7; @@ -277,7 +245,7 @@ double remollMultScatt::solvelogeq(double b){ int n = 0; double f, df; - + // Fix at 100 iterations while( n < MAX_ITER && fabs(thisB-lastB)>err ){ assert(thisB > 0.0); @@ -382,20 +350,19 @@ double remollMultScatt::intsimpson_fn( double th, int n ){ return sum/fact; } -double remollMultScatt::CalcMSDistPlane( double theta, double p, double t, double A, double Z ){ - Init( p, t, A, Z ); +double remollMultScatt::CalcMSDistPlane( double theta, double p, const std::tuple& m) { + Init(p, m); return CalcMSDistPlane(theta); } -double remollMultScatt::CalcMSDistPlane( double theta, double p, int nmat, double t[], double A[], double Z[] ){ - Init( p, nmat, t, A, Z ); +double remollMultScatt::CalcMSDistPlane( double theta, double p, const std::vector>& m) { + Init(p, m); return CalcMSDistPlane(theta); } -double remollMultScatt::CalcMSDistPlane( double theta){ +double remollMultScatt::CalcMSDistPlane( double theta) { /* p - electron momentum - nmat - number of materials t - Thickness A - Mass number Z - Atomic number @@ -430,13 +397,13 @@ double remollMultScatt::CalcMSDistPlane( double theta){ return retval; } -double remollMultScatt::CalcMSDist( double theta, double p, double t, double A, double Z ){ - Init( p, t, A, Z ); +double remollMultScatt::CalcMSDist( double theta, double p, const std::tuple& m) { + Init(p, m); return CalcMSDist(theta); } -double remollMultScatt::CalcMSDist( double theta, double p, int nmat, double t[], double A[], double Z[] ){ - Init( p, nmat, t, A, Z ); +double remollMultScatt::CalcMSDist( double theta, double p, const std::vector>& m) { + Init(p, m); assert( !std::isnan(theta)); return CalcMSDist(theta); } @@ -512,27 +479,25 @@ double remollMultScatt::GenerateMSPlane(){ return -1e9; } -double remollMultScatt::GenerateMSPlane( double p, int nmat, double t[], double A[], double Z[] ){ +double remollMultScatt::GenerateMSPlane(double p, const std::vector>& m) { /* p - electron momentum, [GeV] - nmat - number of materials t - Thickness [g/cm2] A - Mass number Z - Atomic number */ - Init(p, nmat, t, A, Z); + Init(p, m); return GenerateMSPlane(); } -double remollMultScatt::GenerateMSPlane( double p, double t, double A, double Z ){ +double remollMultScatt::GenerateMSPlane(double p, const std::tuple& m) { /* p - electron momentum - nmat - number of materials t - Thickness A - Mass number Z - Atomic number */ - Init(p, t, A, Z); + Init(p, m); return GenerateMSPlane(); } @@ -553,26 +518,24 @@ double remollMultScatt::GenerateMS(){ return thisth; } -double remollMultScatt::GenerateMS( double p, int nmat, double t[], double A[], double Z[] ){ +double remollMultScatt::GenerateMS(double p, const std::vector>& m) { /* p - electron momentum - nmat - number of materials - t - Thickness + t - Thickness A - Mass number Z - Atomic number */ - Init(p, nmat, t, A, Z); + Init(p, m); return GenerateMS(); } -double remollMultScatt::GenerateMS( double p, double t, double A, double Z ){ +double remollMultScatt::GenerateMS(double p, const std::tuple& m) { /* p - electron momentum - nmat - number of materials t - Thickness A - Mass number Z - Atomic number */ - Init(p, t, A, Z); + Init(p, m); return GenerateMS(); } diff --git a/src/remollParallelConstruction.cc b/src/remollParallelConstruction.cc index 0a60f776c..9f38759cb 100644 --- a/src/remollParallelConstruction.cc +++ b/src/remollParallelConstruction.cc @@ -2,56 +2,59 @@ #include -#include #include #include #include -#include #include #include +#include "G4UnitsTable.hh" #include "remollGenericDetector.hh" #include "remollIO.hh" +#ifdef __APPLE__ +#include +#endif + //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... remollParallelConstruction::remollParallelConstruction(const G4String& name, const G4String& gdmlfile) : G4VUserParallelWorld(name), - fGDMLPath("geometry"),fGDMLFile(""), - fGDMLParser(0), + fGDMLPath(""),fGDMLFile(""), fGDMLValidate(false), - fGDMLOverlapCheck(false), + fGDMLOverlapCheck(true), fVerboseLevel(0), - fParallelMessenger(0), fWorldVolume(0), fWorldName(name) { + SetGDMLFile("geometry/mollerParallel.gdml"); // If gdmlfile is non-empty - if (gdmlfile.length() > 0) fGDMLFile = gdmlfile; + if (gdmlfile.length() > 0) { + SetGDMLFile(gdmlfile); + } - // Create GDML parser - fGDMLParser = new G4GDMLParser(); + // New units + new G4UnitDefinition("inch","in","Length",25.4*CLHEP::millimeter); // Create parallel geometry messenger - fParallelMessenger = new G4GenericMessenger(this, - "/remoll/parallel/", - "Remoll parallel geometry properties"); - fParallelMessenger->DeclareMethod( + fParallelMessenger.DeclareMethod( "setfile", &remollParallelConstruction::SetGDMLFile, "Set parallel geometry GDML file") - .SetStates(G4State_PreInit); - fParallelMessenger->DeclareProperty( + .SetStates(G4State_PreInit) + .SetDefaultValue("") + .command->GetParameter(0)->SetOmittable(true); + fParallelMessenger.DeclareProperty( "verbose", fVerboseLevel, "Set geometry verbose level") .SetStates(G4State_PreInit); - fParallelMessenger->DeclareProperty( + fParallelMessenger.DeclareProperty( "validate", fGDMLValidate, "Set GMDL validate flag") .SetStates(G4State_PreInit) .SetDefaultValue("true"); - fParallelMessenger->DeclareProperty( + fParallelMessenger.DeclareProperty( "overlapcheck", fGDMLOverlapCheck, "Set GMDL overlap check flag") @@ -62,8 +65,6 @@ remollParallelConstruction::remollParallelConstruction(const G4String& name, con //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... remollParallelConstruction::~remollParallelConstruction() { - delete fGDMLParser; - delete fParallelMessenger; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... @@ -118,9 +119,7 @@ void remollParallelConstruction::ConstructSD() G4VPhysicalVolume* remollParallelConstruction::ParseGDMLFile() { // Clear parser - //fGDMLParser->Clear(); // FIXME doesn't clear auxmap, instead just recreate - if (fGDMLParser) delete fGDMLParser; - fGDMLParser = new G4GDMLParser(); + //fGDMLParser.Clear(); // FIXME doesn't clear auxmap, instead just recreate // Print GDML warning PrintGDMLWarning(); @@ -132,23 +131,24 @@ G4VPhysicalVolume* remollParallelConstruction::ParseGDMLFile() // Change directory char cwd[MAXPATHLEN]; - if (!getcwd(cwd,MAXPATHLEN)) { + if (getcwd(cwd,MAXPATHLEN) == nullptr) { G4cerr << __FILE__ << " line " << __LINE__ << ": ERROR no current working directory" << G4endl; exit(-1); } - if (chdir(fGDMLPath)) { + if (chdir(fGDMLPath) != 0) { G4cerr << __FILE__ << " line " << __LINE__ << ": ERROR cannot change directory" << G4endl; exit(-1); } // Parse GDML file - fGDMLParser->SetOverlapCheck(fGDMLOverlapCheck); - // hide output if not validating or checking ovelaps + fGDMLParser.SetOverlapCheck(fGDMLOverlapCheck); + // hide output if not validating or checking overlaps + // https://bugzilla-geant4.kek.jp/show_bug.cgi?id=2358 if (! fGDMLOverlapCheck && ! fGDMLValidate) G4cout.setstate(std::ios_base::failbit); - fGDMLParser->Read(fGDMLFile,fGDMLValidate); + fGDMLParser.Read(fGDMLFile,fGDMLValidate); G4cout.clear(); - G4VPhysicalVolume* parallelvolume = fGDMLParser->GetWorldVolume(); + G4VPhysicalVolume* parallelvolume = fGDMLParser.GetWorldVolume(); G4LogicalVolume* parallellogical = parallelvolume->GetLogicalVolume(); // Add GDML files to IO @@ -156,7 +156,7 @@ G4VPhysicalVolume* remollParallelConstruction::ParseGDMLFile() io->GrabGDMLFiles(fGDMLFile); // Change directory back - if (chdir(cwd)) { + if (chdir(cwd) != 0) { G4cerr << __FILE__ << " line " << __LINE__ << ": ERROR cannot change directory" << G4endl; exit(-1); } @@ -176,7 +176,7 @@ G4VPhysicalVolume* remollParallelConstruction::ParseGDMLFile() //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void remollParallelConstruction::PrintAuxiliaryInfo() const { - const G4GDMLAuxMapType* auxmap = fGDMLParser->GetAuxMap(); + const G4GDMLAuxMapType* auxmap = fGDMLParser.GetAuxMap(); G4cout << "Found " << auxmap->size() << " volume(s) with auxiliary information." << G4endl << G4endl; @@ -186,7 +186,7 @@ void remollParallelConstruction::PrintAuxiliaryInfo() const void remollParallelConstruction::ParseAuxiliaryVisibilityInfo() { // Loop over volumes with auxiliary information - const G4GDMLAuxMapType* auxmap = fGDMLParser->GetAuxMap(); + const G4GDMLAuxMapType* auxmap = fGDMLParser.GetAuxMap(); for(G4GDMLAuxMapType::const_iterator iter = auxmap->begin(); iter != auxmap->end(); iter++) { @@ -208,7 +208,7 @@ void remollParallelConstruction::ParseAuxiliaryVisibilityInfo() if ((*vit).type == "Visibility") { G4Colour colour(1.0,1.0,1.0); const G4VisAttributes* visAttribute_old = ((*iter).first)->GetVisAttributes(); - if (visAttribute_old) + if (visAttribute_old != nullptr) colour = visAttribute_old->GetColour(); G4VisAttributes visAttribute_new(colour); if ((*vit).value == "true") @@ -245,7 +245,7 @@ void remollParallelConstruction::ParseAuxiliaryVisibilityInfo() G4Colour colour(1.0,1.0,1.0); const G4VisAttributes* visAttribute_old = ((*iter).first)->GetVisAttributes(); - if (visAttribute_old) + if (visAttribute_old != nullptr) colour = visAttribute_old->GetColour(); G4Colour colour_new( @@ -287,7 +287,7 @@ void remollParallelConstruction::ParseAuxiliarySensDetInfo() if (fVerboseLevel > 0) G4cout << "Beginning sensitive detector assignment" << G4endl; - const G4GDMLAuxMapType* auxmap = fGDMLParser->GetAuxMap(); + const G4GDMLAuxMapType* auxmap = fGDMLParser.GetAuxMap(); for (G4GDMLAuxMapType::const_iterator iter = auxmap->begin(); iter != auxmap->end(); iter++) { G4LogicalVolume* myvol = (*iter).first; if (fVerboseLevel > 0) diff --git a/src/remollPhysicsList.cc b/src/remollPhysicsList.cc index 58145c1e5..bf1dedbff 100644 --- a/src/remollPhysicsList.cc +++ b/src/remollPhysicsList.cc @@ -3,7 +3,6 @@ #include "G4PhysListFactory.hh" #include "G4ParallelWorldPhysics.hh" #include "G4OpticalPhysics.hh" -#include "G4GenericMessenger.hh" #include "G4RunManager.hh" #include "G4NuclearLevelData.hh" #include "G4HadronicProcessStore.hh" @@ -21,11 +20,7 @@ remollPhysicsList::remollPhysicsList() fReferencePhysList(0), fParallelPhysics(0), fOpticalPhysics(0), - fStepLimiterPhysics(0), - fPhysListMessenger(0), - fOpticalMessenger(0), - fParallelMessenger(0), - fBaseMessenger(0) + fStepLimiterPhysics(0) { // Let users know to ignore the warning by Particle HP package G4cout << "remoll: Since the high precision neutron simulation in the some physics lists " << G4endl; @@ -43,67 +38,53 @@ remollPhysicsList::remollPhysicsList() EnableStepLimiterPhysics(); EnableParallelPhysics(); DisableOpticalPhysics(); - G4cout << "remoll: step limiter physics is " << (fStepLimiterPhysics? "enabled":"disabled") << G4endl; - G4cout << "remoll: parallel physics is " << (fParallelPhysics? "enabled":"disabled") << G4endl; - G4cout << "remoll: optical physics is " << (fOpticalPhysics? "enabled":"disabled") << G4endl; - - // Create physlist messenger - fPhysListMessenger = new G4GenericMessenger(this, - "/remoll/physlist/", - "Remoll physics list properties"); - fParallelMessenger = new G4GenericMessenger(this, - "/remoll/physlist/parallel/", - "Remoll parallel physics properties"); - fOpticalMessenger = new G4GenericMessenger(this, - "/remoll/physlist/optical/", - "Remoll optical physics properties"); - fStepLimiterMessenger = new G4GenericMessenger(this, - "/remoll/physlist/steplimiter/", - "Remoll step limiter properties"); + G4cout << "remoll: step limiter physics is " << (fStepLimiterPhysics != nullptr? "enabled":"disabled") << G4endl; + G4cout << "remoll: parallel physics is " << (fParallelPhysics != nullptr? "enabled":"disabled") << G4endl; + G4cout << "remoll: optical physics is " << (fOpticalPhysics != nullptr? "enabled":"disabled") << G4endl; // Create commands - fPhysListMessenger->DeclareMethod( + fPhysListMessenger.DeclareMethod( "verbose", &remollPhysicsList::SetVerboseLevel, "Set physics list verbose level") .SetStates(G4State_PreInit); - fPhysListMessenger->DeclareMethod( + fPhysListMessenger.DeclareMethod( "register", &remollPhysicsList::RegisterReferencePhysList, "Register reference physics list") .SetStates(G4State_PreInit); - fPhysListMessenger->DeclareMethod( + fPhysListMessenger.DeclareMethod( "list", &remollPhysicsList::ListReferencePhysLists, "List reference physics lists"); - fParallelMessenger->DeclareMethod( + fParallelMessenger.DeclareMethod( "enable", &remollPhysicsList::EnableParallelPhysics, "Enable parallel physics") .SetStates(G4State_PreInit); - fParallelMessenger->DeclareMethod( + fParallelMessenger.DeclareMethod( "disable", &remollPhysicsList::DisableParallelPhysics, "Disable parallel physics") .SetStates(G4State_PreInit); - fOpticalMessenger->DeclareMethod( + fOpticalMessenger.DeclareMethod( "enable", &remollPhysicsList::EnableOpticalPhysics, "Enable optical physics") .SetStates(G4State_PreInit); - fOpticalMessenger->DeclareMethod( + fOpticalMessenger.DeclareMethod( "disable", &remollPhysicsList::DisableOpticalPhysics, "Disable optical physics") .SetStates(G4State_PreInit); - fStepLimiterMessenger->DeclareMethod( + fStepLimiterMessenger.DeclareMethod( "enable", &remollPhysicsList::EnableStepLimiterPhysics, "Enable step limiter"); - fStepLimiterMessenger->DeclareMethod( + fStepLimiterMessenger.DeclareMethod( "disable", &remollPhysicsList::DisableStepLimiterPhysics, "Disable step limiter"); @@ -117,12 +98,6 @@ remollPhysicsList::~remollPhysicsList() // delete fReferencePhysicsListToDelete.at(i); //} //fReferencePhysicsListToDelete.clear(); - - if (fPhysListMessenger) delete fPhysListMessenger; - if (fStepLimiterMessenger) delete fStepLimiterMessenger; - if (fParallelMessenger) delete fParallelMessenger; - if (fOpticalMessenger) delete fOpticalMessenger; - if (fBaseMessenger) delete fBaseMessenger; } void remollPhysicsList::SetVerboseLevel(G4int level) @@ -151,7 +126,7 @@ void remollPhysicsList::SetParallelPhysics(G4bool flag) void remollPhysicsList::EnableParallelPhysics() { - if (fParallelPhysics) { + if (fParallelPhysics != nullptr) { G4cout << "Parallel physics already active" << G4endl; return; } @@ -170,7 +145,7 @@ void remollPhysicsList::EnableParallelPhysics() void remollPhysicsList::DisableParallelPhysics() { - if (!fParallelPhysics) { + if (fParallelPhysics == nullptr) { G4cout << "Parallel physics not active" << G4endl; return; } @@ -195,7 +170,7 @@ void remollPhysicsList::SetOpticalPhysics(G4bool flag) void remollPhysicsList::EnableOpticalPhysics() { - if (fOpticalPhysics) { + if (fOpticalPhysics != nullptr) { G4cout << "Optical physics already active" << G4endl; return; } @@ -213,7 +188,7 @@ void remollPhysicsList::EnableOpticalPhysics() void remollPhysicsList::DisableOpticalPhysics() { - if (!fOpticalPhysics) { + if (fOpticalPhysics == nullptr) { G4cout << "Optical physics not active" << G4endl; return; } @@ -238,7 +213,7 @@ void remollPhysicsList::SetStepLimiterPhysics(G4bool flag) void remollPhysicsList::EnableStepLimiterPhysics() { - if (fStepLimiterPhysics) { + if (fStepLimiterPhysics != nullptr) { G4cout << "Step limiter already active" << G4endl; return; } @@ -260,7 +235,7 @@ void remollPhysicsList::EnableStepLimiterPhysics() void remollPhysicsList::DisableStepLimiterPhysics() { - if (!fStepLimiterPhysics) { + if (fStepLimiterPhysics == nullptr) { G4cout << "Step limiter physics not active" << G4endl; return; } @@ -345,7 +320,7 @@ void remollPhysicsList::RegisterReferencePhysList(G4String name) } // Remove previous reference physics list - if (fReferencePhysList) RemoveReferencePhysList(); + if (fReferencePhysList != nullptr) RemoveReferencePhysList(); // Get reference physics list fReferencePhysList = factory.GetReferencePhysList(name); diff --git a/src/remollPrimaryGeneratorAction.cc b/src/remollPrimaryGeneratorAction.cc index 38a898579..c850a73a7 100644 --- a/src/remollPrimaryGeneratorAction.cc +++ b/src/remollPrimaryGeneratorAction.cc @@ -4,7 +4,6 @@ #include "G4ParticleGun.hh" #include "G4ParticleTable.hh" #include "G4ParticleDefinition.hh" -#include "G4GenericMessenger.hh" #include "remollHEPEvtInterface.hh" #ifdef G4LIB_USE_HEPMC @@ -27,16 +26,17 @@ #include "remollGenpInelastic.hh" #include "remollGenPion.hh" #include "remollGenBeam.hh" -#include "remollGenTF1.hh" -#include "remollGen12CElastic.hh" +#include "remollGenC12.hh" #include "remollGenFlat.hh" #include "remollGenExternal.hh" #include "remollGenAl.hh" #include "remollGenLUND.hh" #include "remollGenHyperon.hh" +#include + remollPrimaryGeneratorAction::remollPrimaryGeneratorAction() -: fEventGen(0),fPriGen(0),fParticleGun(0),fBeamTarg(0),fEvent(0),fMessenger(0),fEffCrossSection(0) +: fEventGen(0),fPriGen(0),fParticleGun(0),fEvent(0),fEffCrossSection(0) { static bool has_been_warned = false; if (! has_been_warned) { @@ -47,52 +47,43 @@ remollPrimaryGeneratorAction::remollPrimaryGeneratorAction() } // Populate map with all possible event generators - fEvGenMap["moller"] = new remollGenMoller(); - fEvGenMap["elastic"] = new remollGenpElastic(); - fEvGenMap["inelastic"] = new remollGenpInelastic(); - fEvGenMap["pion"] = new remollGenPion(); - fEvGenMap["beam"] = new remollGenBeam(); - fEvGenMap["flat"] = new remollGenFlat(); - fEvGenMap["TF1"] = new remollGenTF1(); - fEvGenMap["elasticAl"] = new remollGenAl(0); - fEvGenMap["quasielasticAl"] = new remollGenAl(1); - fEvGenMap["inelasticAl"] = new remollGenAl(2); - fEvGenMap["external"] = new remollGenExternal(); - fEvGenMap["pion_LUND"] = new remollGenLUND(); - fEvGenMap["carbon"] = new remollGen12CElastic(); - fEvGenMap["hyperon"] = new remollGenHyperon(); + fEvGenMap["moller"] = std::make_shared(); + fEvGenMap["elastic"] = std::make_shared(); + fEvGenMap["inelastic"] = std::make_shared(); + fEvGenMap["pion"] = std::make_shared(); + fEvGenMap["beam"] = std::make_shared(); + fEvGenMap["flat"] = std::make_shared(); + fEvGenMap["elasticAl"] = std::make_shared(0); + fEvGenMap["quasielasticAl"] = std::make_shared(1); + fEvGenMap["inelasticAl"] = std::make_shared(2); + fEvGenMap["external"] = std::make_shared(); + fEvGenMap["pion_LUND"] = std::make_shared(); + fEvGenMap["elasticC12"] = std::make_shared(0); + fEvGenMap["quasielasticC12"] = std::make_shared(1); + fEvGenMap["inelasticC12"] = std::make_shared(2); + fEvGenMap["hyperon"] = std::make_shared(); // Populate map with all possible primary generators - fPriGenMap["particlegun"] = new G4ParticleGun(); - fPriGenMap["HEPEvt"] = new remollHEPEvtInterface(); + fPriGenMap["particlegun"] = std::make_shared(); + fPriGenMap["HEPEvt"] = std::make_shared(); #ifdef G4LIB_USE_HEPMC - fPriGenMap["hepmcAscii"] = new HepMCG4AsciiInterface(); + fPriGenMap["hepmcAscii"] = std::make_shared(); #ifdef G4LIB_USE_PYTHIA - fPriGenMap["hepmcPythia"] = new HepMCG4PythiaInterface() + fPriGenMap["hepmcPythia"] = std::make_shared(); #endif #endif - // Create beam target - fBeamTarg = new remollBeamTarget(); - // Default generator G4String default_generator = "moller"; SetGenerator(default_generator); // Create event generator messenger - fEvGenMessenger = new G4GenericMessenger(this,"/remoll/evgen/","Remoll event generator properties"); - fEvGenMessenger->DeclareMethod("set",&remollPrimaryGeneratorAction::SetGenerator,"Select physics generator"); - fEvGenMessenger->DeclarePropertyWithUnit("sigma","picobarn",fEffCrossSection,"Set effective cross section"); + fEvGenMessenger.DeclareMethod("set",&remollPrimaryGeneratorAction::SetGenerator,"Select physics generator"); + fEvGenMessenger.DeclarePropertyWithUnit("sigma","picobarn",fEffCrossSection,"Set effective cross section"); } remollPrimaryGeneratorAction::~remollPrimaryGeneratorAction() { - fEvGenMap.clear(); - fPriGenMap.clear(); - if (fEvGenMessenger) delete fEvGenMessenger; - if (fMessenger) delete fMessenger; - if (fBeamTarg) delete fBeamTarg; - if (fEventGen) delete fEventGen; } void remollPrimaryGeneratorAction::SetGenerator(G4String& genname) @@ -102,7 +93,7 @@ void remollPrimaryGeneratorAction::SetGenerator(G4String& genname) fPriGen = 0; // Find event generator - std::map::iterator evgen = fEvGenMap.find(genname); + auto evgen = fEvGenMap.find(genname); if (evgen != fEvGenMap.end()) { G4cout << "Setting generator to " << genname << G4endl; fPriGen = 0; @@ -113,7 +104,7 @@ void remollPrimaryGeneratorAction::SetGenerator(G4String& genname) } // Find primary generator - std::map::iterator prigen = fPriGenMap.find(genname); + auto prigen = fPriGenMap.find(genname); if (prigen != fPriGenMap.end()) { G4cout << "Setting generator to " << genname << G4endl; fPriGen = prigen->second; @@ -131,10 +122,8 @@ void remollPrimaryGeneratorAction::SetGenerator(G4String& genname) // Set the beam target if (fEventGen) { - fEventGen->SetBeamTarget(fBeamTarg); + fEventGen->SetBeamTarget(&fBeamTarg); } - - remollRun::GetRunData()->SetGenName(genname.data()); } void remollPrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent) @@ -145,7 +134,7 @@ void remollPrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent) } // Delete old primary event - if (fEvent) { + if (fEvent != nullptr) { delete fEvent; fEvent = 0; } @@ -174,24 +163,24 @@ void remollPrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent) fEvent = fEventGen->GenerateEvent(); for (unsigned int pidx = 0; pidx < fEvent->fPartType.size(); pidx++) { - double p = fEvent->fPartMom[pidx].mag(); + double p = fEvent->fPartRealMom[pidx].mag(); double m = fEvent->fPartType[pidx]->GetPDGMass(); double kinE = sqrt(p*p + m*m) - m; fParticleGun->SetParticleDefinition(fEvent->fPartType[pidx]); fParticleGun->SetParticleEnergy(kinE); fParticleGun->SetParticlePosition(fEvent->fPartPos[pidx]); - fParticleGun->SetParticleMomentumDirection(fEvent->fPartMom[pidx].unit()); + fParticleGun->SetParticleMomentumDirection(fEvent->fPartRealMom[pidx].unit()); G4ThreeVector pol(0,0,0); if (pidx == 0) { if (cross.mag() !=0) { if (cross.mag() == 1) //transverse polarization - pol = G4ThreeVector( (fEvent->fPartMom[0].unit()).cross(cross)); + pol = G4ThreeVector( (fEvent->fPartRealMom[0].unit()).cross(cross)); else if (fBeamPol.contains("+") ) //positive helicity - pol = fEvent->fPartMom[0].unit(); + pol = fEvent->fPartRealMom[0].unit(); else //negative helicity - pol = - fEvent->fPartMom[0].unit(); + pol = - fEvent->fPartRealMom[0].unit(); } } fParticleGun->SetParticlePolarization(pol); @@ -206,11 +195,12 @@ void remollPrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent) G4double nthrown = remollRun::GetRunData()->GetNthrown(); // Calculate rate + SamplingType_t sampling_type = fEventGen->GetSamplingType(); if (fEvent->fRate == 0) { // If the rate is set to 0 then calculate it using the cross section - fEvent->fRate = fEvent->fEffXs * fBeamTarg->GetEffLumin() / nthrown; + fEvent->fRate = fEvent->fEffXs * fBeamTarg.GetEffLumin(sampling_type) / nthrown; } else { // For LUND - calculate rate and cross section - fEvent->fEffXs = fEvent->fRate * nthrown / fBeamTarg->GetEffLumin(); + fEvent->fEffXs = fEvent->fRate * nthrown / fBeamTarg.GetEffLumin(sampling_type); fEvent->fRate = fEvent->fRate / nthrown; } diff --git a/src/remollRun.cc b/src/remollRun.cc index 29f52b96a..744e621e5 100644 --- a/src/remollRun.cc +++ b/src/remollRun.cc @@ -6,7 +6,7 @@ remollRunData* remollRun::fRunData = 0; remollRunData* remollRun::GetRunData() { - if (!fRunData) { + if (fRunData == nullptr) { fRunData = new remollRunData(); fRunData->Init(); } diff --git a/src/remollRunAction.cc b/src/remollRunAction.cc index aefd24006..29d22012a 100644 --- a/src/remollRunAction.cc +++ b/src/remollRunAction.cc @@ -1,6 +1,5 @@ #include "remollRunAction.hh" -#include "G4GenericMessenger.hh" #include "G4RunManager.hh" #include "G4Timer.hh" @@ -14,31 +13,22 @@ namespace { G4Mutex remollRunActionMutex = G4MUTEX_INITIALIZER; } remollRunAction::remollRunAction() -: fInterval(10) { - // Create messenger to set the seed with single long int - fMessenger = new G4GenericMessenger(this,"/remoll/","Remoll properties"); - fMessenger->DeclareMethod( + fMessenger.DeclareMethod( "seed", &remollRunAction::UpdateSeed, "Set random engine seed") .SetParameterName("seed", false) .SetStates(G4State_PreInit,G4State_Idle); - fMessenger->DeclareMethod( + fMessenger.DeclareMethod( "interval", &remollRunAction::SetUpdateInterval, "Print this many progress points (i.e. 100 -> every 1%)") .SetParameterName("interval", false) .SetStates(G4State_PreInit,G4State_Idle); - // Create timer - fTimer = new G4Timer(); -} - -remollRunAction::~remollRunAction() -{ - delete fMessenger; - delete fTimer; + // Store random status before primary particle generation + G4RunManager::GetRunManager()->StoreRandomNumberStatusToG4Event(1); } void remollRunAction::UpdateSeed(const G4long seed) @@ -68,7 +58,7 @@ void remollRunAction::BeginOfRunAction(const G4Run* run) { G4cout << "### Run " << aRun->GetRunID() << " start." << G4endl; - fTimer->Start(); + fTimer.Start(); G4AutoLock lock(&remollRunActionMutex); remollIO* io = remollIO::GetInstance(); @@ -86,10 +76,10 @@ void remollRunAction::EndOfRunAction(const G4Run* run) if (IsMaster()) { - fTimer->Stop(); + fTimer.Stop(); G4cout << "### Run " << aRun->GetRunID() << " ended " - << "(" << fTimer->GetUserElapsed() << "s)." << G4endl; + << "(" << fTimer.GetUserElapsed() << "s)." << G4endl; G4AutoLock lock(&remollRunActionMutex); remollIO* io = remollIO::GetInstance(); diff --git a/src/remollRunData.cc b/src/remollRunData.cc index 02feca767..3c0ab1eba 100644 --- a/src/remollRunData.cc +++ b/src/remollRunData.cc @@ -12,30 +12,29 @@ // External objects extern const char* const gGitInfo; -remollRunData::remollRunData() +void remollRunData::Init() { + fNthrown = 0; fSeed = 0; - fNthrown = -1; - fBeamE = -1e9; - fGenName[0] = '\0'; - fHostName[0] = '\0'; -} -remollRunData::~remollRunData(){ -} + fGitInfo = gGitInfo; -void remollRunData::Init() -{ - fNthrown = 0; - fBeamE = 0; - strcpy(fGenName, "default"); - if(gethostname(fHostName,__RUNSTR_LEN) == -1){ - fprintf(stderr, "%s line %d: ERROR could not get hostname\n", __PRETTY_FUNCTION__ , __LINE__ ); - fprintf(stderr, "%s\n",strerror(errno)); + const unsigned int length = 128; + + char hostname[length]; + if (gethostname(hostname, length) == -1) { + G4cerr << "Error: " << __PRETTY_FUNCTION__ << " line " << __LINE__ << ": " + << "could not get hostname" << G4endl; + } else { + fHostName = hostname; } - if(getcwd(fRunPath,__RUNSTR_LEN) == NULL){ - fprintf(stderr, "%s line %d: ERROR could not get current working directory\n", __PRETTY_FUNCTION__ , __LINE__ ); - fprintf(stderr, "%s\n",strerror(errno)); + + char runpath[length]; + if (getcwd(runpath, length) == NULL) { + G4cerr << "Error: " << __PRETTY_FUNCTION__ << " line " << __LINE__ << ": " + << "could not get current working directory" << G4endl; + } else { + fRunPath = runpath; } } @@ -43,13 +42,11 @@ void remollRunData::Print() { G4cout << "git repository info" << G4endl; G4cout << "-------------------------------------------------" << G4endl; - G4cout << gGitInfo << G4endl; + G4cout << fGitInfo << G4endl; G4cout << "-------------------------------------------------" << G4endl; G4cout << "Run at " << fRunTime.AsString("ls") << " on " << fHostName << G4endl; - G4cout << "Run Path " << fRunPath << G4endl;; + G4cout << "Run path " << fRunPath << G4endl; G4cout << "N generated = " << fNthrown << G4endl; - G4cout << "Beam Energy = " << fBeamE << "GeV" << G4endl; - G4cout << "Generator = " << fGenName << G4endl; G4cout << "Field maps:" << G4endl; for (unsigned int i = 0; i < fMagData.size(); i++ ){ diff --git a/src/remollSearchPath.cc b/src/remollSearchPath.cc new file mode 100644 index 000000000..fdb6b670a --- /dev/null +++ b/src/remollSearchPath.cc @@ -0,0 +1,61 @@ +#include "remollSearchPath.hh" + +#include + +remollSearchPath* remollSearchPath::fInstance = nullptr; + +remollSearchPath::remollSearchPath() { + // add CMAKE_INSTALL_FULL_DATADIR, CMAKE_INSTALL_PREFIX and CWD to search path + #ifndef NO_FS_SUPPORT + #ifdef _GNU_SOURCE + fSearchPath.push_back(fs::path(get_current_dir_name())); + #else + char* dir = (char*) malloc(PATH_MAX * sizeof(char)); + if (getcwd(dir, PATH_MAX) != nullptr) { + fSearchPath.push_back(fs::path(dir)); + free(dir); + } + #endif + fSearchPath.push_back(fs::path(CMAKE_INSTALL_PREFIX)); + fSearchPath.push_back(fs::path(CMAKE_INSTALL_FULL_DATADIR)); + #endif +} + +remollSearchPath *remollSearchPath::getInstance() { + if (fInstance == nullptr) { + fInstance = new remollSearchPath(); + } + return fInstance; +} + +remollSearchPath::~remollSearchPath() {} + +void remollSearchPath::add(const std::string& path) { +#ifndef NO_FS_SUPPORT + // Check if path is an absolute path + if (fs::exists(fs::path(path))) { + fSearchPath.push_back(fs::path(path)); + } +#endif +} + +std::string remollSearchPath::operator() (const std::string& filename) { + // If the file you are looking for exists inside any of the + // directories inside fSearchPath, return the filename prefixed with + // the directory for which the full path exists +#ifndef NO_FS_SUPPORT + for (auto path: fSearchPath) { + fs::path test(path.string() + "/" + filename); + if(fs::exists(test)) { + return test.string(); + } + else if(fs::exists(path / "remoll" / filename)) { + return (path / "remoll" / filename).string(); + } + } +#endif + + // File not found in any of the search directories, + // return the filename + return std::string(filename); +} diff --git a/src/remollSteppingAction.cc b/src/remollSteppingAction.cc index accffe3b0..10107e5c0 100644 --- a/src/remollSteppingAction.cc +++ b/src/remollSteppingAction.cc @@ -4,7 +4,6 @@ #include "G4Track.hh" #include "G4Material.hh" #include "G4MaterialTable.hh" -#include "G4GenericMessenger.hh" remollSteppingAction::remollSteppingAction() { diff --git a/src/remollTextFile.cc b/src/remollTextFile.cc index 4aa4a9c2e..61a62417d 100644 --- a/src/remollTextFile.cc +++ b/src/remollTextFile.cc @@ -42,12 +42,12 @@ remollTextFile::remollTextFile(const remollTextFile& r) const remollTextFile& remollTextFile::operator=(const remollTextFile& r){ TObject::operator=(r); - if (fFilename) { delete[] fFilename; } + delete[] fFilename; fFilenameSize = r.fFilenameSize; fFilename = new char[r.fFilenameSize]; strncpy(fFilename, r.fFilename, fFilenameSize); - if (fBuffer) { delete[] fBuffer; } + delete[] fBuffer; fBufferSize = r.fBufferSize; fBuffer = new char[r.fBufferSize]; memcpy(fBuffer, r.fBuffer, fBufferSize); @@ -56,8 +56,8 @@ const remollTextFile& remollTextFile::operator=(const remollTextFile& r){ } remollTextFile::~remollTextFile(){ - if (fFilename) { delete[] fFilename; } - if (fBuffer) { delete[] fBuffer; } + delete[] fFilename; + delete[] fBuffer; } void remollTextFile::copyFileIn(const char *fn){ @@ -115,14 +115,14 @@ void remollTextFile::RecreateInDir(const char *adir, bool clobber ){ if( ret == -1 && errno != EEXIST ){ fprintf(stderr, "%s - %s\n", thisdir, strerror(errno) ); delete thisdir; - delete catpath; + delete[] catpath; return; } Recreate(catpath, clobber); delete thisdir; - delete catpath; + delete[] catpath; } void remollTextFile::Recreate(const char *fn, bool clobber ){ diff --git a/src/remollTrackReconstruct.cc b/src/remollTrackReconstruct.cc index 9a6965802..f7c042678 100644 --- a/src/remollTrackReconstruct.cc +++ b/src/remollTrackReconstruct.cc @@ -241,7 +241,7 @@ G4ThreeVector remollTrackReconstruct::EvaluateTrack(std::vector rPosX // invert matXZ G4double detXZ = matXZ[0][0]*matXZ[1][1] - matXZ[0][1]*matXZ[1][0]; - if(!detXZ){ + if(detXZ == 0.0){ // G4cerr << "** Can't invert the matrix because determinant is ZERO **" << G4endl; return G4ThreeVector(-1000/m,-1000/m,0); // in m } diff --git a/src/remollTrackingAction.cc b/src/remollTrackingAction.cc index aa2393fc8..172aaf806 100644 --- a/src/remollTrackingAction.cc +++ b/src/remollTrackingAction.cc @@ -7,13 +7,10 @@ #include "G4Version.hh" #include "G4TrackingManager.hh" #include "G4OpticalPhoton.hh" -#include "G4GenericMessenger.hh" remollTrackingAction::remollTrackingAction() -: fMessenger(0),fTrackingFlag(3) { - fMessenger = new G4GenericMessenger(this,"/remoll/tracking/","Remoll tracking properties"); - fMessenger->DeclareProperty("set",fTrackingFlag) + fMessenger.DeclareProperty("set",fTrackingFlag) .SetGuidance("Select tracking flag") .SetGuidance(" 0 : Track primary electrons only") .SetGuidance(" 1 : Track primary electrons and optical photons only") @@ -24,15 +21,10 @@ remollTrackingAction::remollTrackingAction() .SetStates(G4State_PreInit,G4State_Idle); } -remollTrackingAction::~remollTrackingAction() -{ - delete fMessenger; -} - void remollTrackingAction::PreUserTrackingAction(const G4Track* aTrack) { G4VUserTrackInformation* usertrackinfo = aTrack->GetUserInformation(); - if (! usertrackinfo) { + if (usertrackinfo == nullptr) { #if G4VERSION_NUMBER >= 1030 aTrack->SetUserInformation(new remollUserTrackInformation()); #else @@ -77,10 +69,10 @@ void remollTrackingAction::PreUserTrackingAction(const G4Track* aTrack) void remollTrackingAction::PostUserTrackingAction(const G4Track* aTrack) { G4VUserTrackInformation* usertrackinfo = aTrack->GetUserInformation(); - if (usertrackinfo) { + if (usertrackinfo != nullptr) { remollUserTrackInformation* remollusertrackinfo = dynamic_cast(usertrackinfo); - if (remollusertrackinfo) { + if (remollusertrackinfo != nullptr) { G4StepStatus stepstatus = aTrack->GetStep()->GetPostStepPoint()->GetStepStatus(); remollusertrackinfo->SetStepStatus(stepstatus); } diff --git a/src/remollVEventGen.cc b/src/remollVEventGen.cc index 753862e1d..91db6bcfd 100644 --- a/src/remollVEventGen.cc +++ b/src/remollVEventGen.cc @@ -4,7 +4,6 @@ #include "G4ParticleGun.hh" #include "G4RotationMatrix.hh" -#include "G4GenericMessenger.hh" #include "remollBeamTarget.hh" #include "remollVertex.hh" @@ -25,38 +24,33 @@ remollVEventGen::remollVEventGen(const G4String name) : fName(name), fBeamPol("0"), fNumberOfParticles(1),fParticleGun(0), - fBeamTarg(0) + fBeamTarg(0), + fThisGenMessenger(this,"/remoll/evgen/" + name + "/","Remoll " + name + " generator properties") { // Set initial number of particles and create particle gun SetNumberOfParticles(fNumberOfParticles); // Create event generator messenger - fEvGenMessenger = new G4GenericMessenger(this,"/remoll/evgen/","Remoll event generator properties"); - fEvGenMessenger->DeclarePropertyWithUnit("emax","GeV",fE_max,"Maximum generation energy"); - fEvGenMessenger->DeclarePropertyWithUnit("emin","GeV",fE_min,"Minimum generation energy"); - fEvGenMessenger->DeclarePropertyWithUnit("thmax","deg",fTh_max,"Maximum generation theta angle"); - fEvGenMessenger->DeclarePropertyWithUnit("thmin","deg",fTh_min,"Minimum generation theta angle"); - fEvGenMessenger->DeclarePropertyWithUnit("phmax","deg",fPh_max,"Maximum generation phi angle"); - fEvGenMessenger->DeclarePropertyWithUnit("phmin","deg",fPh_min,"Minimum generation phi angle"); - fEvGenMessenger->DeclarePropertyWithUnit("thcommax","deg",fThCoM_max,"Maximum CoM generation theta angle"); - fEvGenMessenger->DeclarePropertyWithUnit("thcommin","deg",fThCoM_min,"Minimum CoM generation theta angle"); - fEvGenMessenger->DeclareProperty("beamPolarization",fBeamPol,"Polarization direction: +L, +H, +V, -L, -H, -V, 0"); - fEvGenMessenger->DeclareMethod( + fEvGenMessenger.DeclarePropertyWithUnit("emax","GeV",fE_max,"Maximum generation energy"); + fEvGenMessenger.DeclarePropertyWithUnit("emin","GeV",fE_min,"Minimum generation energy"); + fEvGenMessenger.DeclarePropertyWithUnit("thmax","deg",fTh_max,"Maximum generation theta angle"); + fEvGenMessenger.DeclarePropertyWithUnit("thmin","deg",fTh_min,"Minimum generation theta angle"); + fEvGenMessenger.DeclarePropertyWithUnit("phmax","deg",fPh_max,"Maximum generation phi angle"); + fEvGenMessenger.DeclarePropertyWithUnit("phmin","deg",fPh_min,"Minimum generation phi angle"); + fEvGenMessenger.DeclarePropertyWithUnit("thcommax","deg",fThCoM_max,"Maximum CoM generation theta angle"); + fEvGenMessenger.DeclarePropertyWithUnit("thcommin","deg",fThCoM_min,"Minimum CoM generation theta angle"); + fEvGenMessenger.DeclareProperty("beamPolarization",fBeamPol,"Polarization direction: +L, +H, +V, -L, -H, -V, 0"); + fEvGenMessenger.DeclareMethod( "printlimits", &remollVEventGen::PrintEventGen, "Print the event generator limits"); - // Create specific event generator messenger - fThisGenMessenger = new G4GenericMessenger(this,"/remoll/evgen/" + name + "/","Remoll " + name + " generator properties"); - - fSampType = kActiveTargetVolume; + fSamplingType = kActiveTargetVolume; fApplyMultScatt = false; } remollVEventGen::~remollVEventGen() { - delete fThisGenMessenger; - delete fEvGenMessenger; } void remollVEventGen::PrintEventGen() @@ -74,7 +68,7 @@ void remollVEventGen::SetNumberOfParticles(G4int n) fNumberOfParticles = n; // Delete old particle gun - if (fParticleGun) { + if (fParticleGun != nullptr) { delete fParticleGun; fParticleGun = 0; } @@ -85,7 +79,7 @@ void remollVEventGen::SetNumberOfParticles(G4int n) remollEvent* remollVEventGen::GenerateEvent() { // Set up beam/target vertex - remollVertex vert = fBeamTarg->SampleVertex(fSampType); + remollVertex vert = fBeamTarg->SampleVertex(fSamplingType); ///////////////////////////////////////////////////////////////////// // Create and initialize values for event @@ -125,7 +119,7 @@ void remollVEventGen::PolishEvent(remollEvent *ev) { exit(1); } - G4ThreeVector rotax = (fBeamTarg->fDir.cross(G4ThreeVector(0.0, 0.0, 1.0))).unit(); + G4ThreeVector rotax = (-1)*(fBeamTarg->fDir.cross(G4ThreeVector(0.0, 0.0, 1.0))).unit(); G4RotationMatrix msrot; msrot.rotate(fBeamTarg->fDir.theta(), rotax); diff --git a/vis/detector_vis.mac b/vis/detector_vis.mac new file mode 100644 index 000000000..786697244 --- /dev/null +++ b/vis/detector_vis.mac @@ -0,0 +1,89 @@ +# +# Create a new empty scene +# +/vis/scene/create + +# +# Draw both real and parallel worlds +# +/vis/drawVolume worlds + +# +# Declare that the world volume should be added to the scene +# +/vis/scene/add/volume +# +# +# Attach scene to scenehandler +# +/vis/sceneHandler/attach + +# Add axis (has to be after /vis/scene/create ) +# +/vis/scene/add/axes 0 0 0 100 cm + + +# +# Draw a picture that has just the detector (no trajectories or hits). +# +/vis/viewer/flush + +# +# Declare that trajectories and hits should be added to the scene +# +/vis/scene/add/trajectories +/vis/scene/add/hits + +# +# Set camera +# +/vis/viewer/reset +# Specify view angle: +#updated setting +/vis/viewer/set/viewpointThetaPhi 90. 0. +#old value +#/vis/viewer/set/viewpointThetaPhi 35 15 deg +#/vis/viewer/zoom 2.0 + +# +# Set surface +# +/vis/viewer/set/style surface + +#updated setting from PREX vis.mac +/vis/viewer/set/viewpointThetaPhi 90 180 deg +#/vis/viewer/panTo 100 3000 cm +/vis/viewer/zoom 5.0 +/vis/viewer/set/lightsThetaPhi 40 50 +#New cutaway plane setting +#/vis/viewer/set/cutawayMode intersection +#/vis/viewer/addCutawayPlane 0.0 0.0 0.0 m 1.0 0.0 0.0 +/vis/viewer/addCutawayPlane 0.0 0.0 0.0 m 0.0 -1.0 0.0 +#/vis/viewer/addCutawayPlane 0.25 0.0 0.0 m -1.0 0.0 0.0 +#old value +#/vis/viewer/set/lightsMove with-camera +# + +# +# Create style +# +/vis/modeling/trajectories/create/drawByParticleID MollerStyle +/vis/modeling/trajectories/MollerStyle/set e- red +/vis/modeling/trajectories/MollerStyle/set e+ blue +/vis/modeling/trajectories/MollerStyle/set gamma green +/vis/modeling/trajectories/MollerStyle/set neutron white +/vis/modeling/trajectories/MollerStyle/set opticalphoton yellow +/vis/modeling/trajectories/MollerStyle/set proton magenta +# +/vis/modeling/trajectories/select MollerStyle + +# +# Event action +# +/vis/scene/endOfEventAction accumulate + +# +# Run action +# +/vis/scene/endOfRunAction refresh + diff --git a/vis/section_xz.mac b/vis/section_xz.mac new file mode 100644 index 000000000..63f958654 --- /dev/null +++ b/vis/section_xz.mac @@ -0,0 +1,7 @@ +/vis/viewer/clearCutawayPlanes +/vis/viewer/set/cutawayMode intersection +/vis/viewer/addCutawayPlane 0.0 0.0 -1.0 mm 0.0 +1.0 0.0 +/vis/viewer/addCutawayPlane 0.0 0.0 +1.0 mm 0.0 -1.0 0.0 +/vis/viewer/set/style wireframe +/vis/viewer/set/upVector 1.0 0.0 0.0 +/vis/viewer/set/viewpointThetaPhi 90 90 deg diff --git a/vis/section_yz.mac b/vis/section_yz.mac new file mode 100644 index 000000000..94645cd5f --- /dev/null +++ b/vis/section_yz.mac @@ -0,0 +1,7 @@ +/vis/viewer/clearCutawayPlanes +/vis/viewer/set/cutawayMode intersection +/vis/viewer/addCutawayPlane -1.0 0.0 0.0 mm +1.0 0.0 0.0 +/vis/viewer/addCutawayPlane +1.0 0.0 0.0 mm -1.0 0.0 0.0 +/vis/viewer/set/style wireframe +/vis/viewer/set/upVector 0.0 1.0 0.0 +/vis/viewer/set/viewpointThetaPhi 90 180 deg diff --git a/vis/vis.mac b/vis/vis.mac index 4f11b397d..2ee8e7537 100644 --- a/vis/vis.mac +++ b/vis/vis.mac @@ -31,7 +31,7 @@ # # Declare that trajectories and hits should be added to the scene # -/vis/scene/add/trajectories +/vis/scene/add/trajectories rich /vis/scene/add/hits # @@ -75,6 +75,23 @@ # /vis/modeling/trajectories/select MollerStyle +# +# Create filters +# +/vis/filtering/trajectories/create/particleFilter HideAllGammas +/vis/filtering/trajectories/HideAllGammas/add gamma +/vis/filtering/trajectories/HideAllGammas/invert true +/vis/filtering/trajectories/HideAllGammas/active 0 + +/vis/filtering/trajectories/create/chargeFilter ShowOnlyCharged +/vis/filtering/trajectories/ShowOnlyCharged/add 0 +/vis/filtering/trajectories/ShowOnlyCharged/invert true +/vis/filtering/trajectories/ShowOnlyCharged/active 0 + +/vis/filtering/trajectories/create/encounteredVolumeFilter ShowOnlyPionDetectorHits +/vis/filtering/trajectories/ShowOnlyPionDetectorHits/add pionDetectorLuciteAllPlanesWedgeGlue_physical +/vis/filtering/trajectories/ShowOnlyPionDetectorHits/active 0 + # # Event action #