From 867baa64eac9a2ebfa0897b75a4fac5649a97954 Mon Sep 17 00:00:00 2001 From: Luis Antonio Obis Aparicio <luis.antonio.obis@gmail.com> Date: Fri, 10 Feb 2023 16:57:00 +0100 Subject: [PATCH 1/6] add pre-commit config files --- .clang-format | 2 +- .cmake-format.yaml | 6 ++++++ .pre-commit-config.yaml | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 .cmake-format.yaml create mode 100644 .pre-commit-config.yaml diff --git a/.clang-format b/.clang-format index 686e2d92..f01f570b 100644 --- a/.clang-format +++ b/.clang-format @@ -7,4 +7,4 @@ DerivePointerAlignment: false PointerAlignment: Left IndentWidth: 4 -ColumnLimit : 110 +ColumnLimit: 110 diff --git a/.cmake-format.yaml b/.cmake-format.yaml new file mode 100644 index 00000000..5b703c9d --- /dev/null +++ b/.cmake-format.yaml @@ -0,0 +1,6 @@ +# https://cmake-format.readthedocs.io/en/latest/configuration.html + +format: + tab_size: 4 + separate_ctrl_name_with_space: true + separate_fn_name_with_space: false diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..87c5b7f6 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,35 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: check-added-large-files + - id: check-case-conflict + - id: check-merge-conflict + - id: check-symlinks + - id: check-yaml + - id: check-xml + - id: requirements-txt-fixer + - id: end-of-file-fixer + exclude: external/.*$ + - id: mixed-line-ending + exclude: external/.*$ + - id: trailing-whitespace + exclude: external/.*$ + + - repo: https://github.com/pre-commit/mirrors-clang-format + rev: v15.0.6 + hooks: + - id: clang-format + exclude: external/.*$ + + - repo: https://github.com/cheshirekow/cmake-format-precommit + rev: v0.6.13 + hooks: + - id: cmake-format + additional_dependencies: [ pyyaml ] + # - id: cmake-lint + + - repo: https://github.com/psf/black + rev: 22.12.0 + hooks: + - id: black From 33e41afd09cdd4921c27d7a6fcc081df791437d8 Mon Sep 17 00:00:00 2001 From: Luis Antonio Obis Aparicio <luis.antonio.obis@gmail.com> Date: Fri, 10 Feb 2023 17:05:38 +0100 Subject: [PATCH 2/6] manually fixed files before pre-commit --- examples/old/axionSpectrum.xml | 4 +- examples/old/axionlib.xml | 8 +-- scripts/xlsToBin.py | 91 ++++++++++++++++++++-------------- 3 files changed, 61 insertions(+), 42 deletions(-) diff --git a/examples/old/axionSpectrum.xml b/examples/old/axionSpectrum.xml index 3a07e68b..d566c5bc 100644 --- a/examples/old/axionSpectrum.xml +++ b/examples/old/axionSpectrum.xml @@ -11,8 +11,8 @@ <TRestAxionSpectrum name="tabulatedSpectrum" verboseLevel="debug"> <parameter name="mode" value="table" /> <parameter name="spectrumTableFileName" value="Primakoff_Gianotti_202008.dat" /> - <parameter name="g1ref" value=1.0e-10 /> + <parameter name="g1ref" value="1.0e-10" /> <!-- Important to set this to zero to end up selecting the correct table mode --> - <parameter name="g2ref" value=0 /> + <parameter name="g2ref" value="0" /> </TRestAxionSpectrum> </TRestAxionSpectra> diff --git a/examples/old/axionlib.xml b/examples/old/axionlib.xml index 20c91b8e..a42e3bb7 100644 --- a/examples/old/axionlib.xml +++ b/examples/old/axionlib.xml @@ -1,7 +1,7 @@ <!-- Created by Sebastian Hoof (8/2020) --> <!-- Example file with multiple 'TRestAxionSolarModel' tags --> -</TRestAxionSolarModels> - <TRestAxionSolarModel name="SolarAxionLibTest" verboseLevel="debug"> - <parameter name="solarAxionModel" value="external/solarAxionFlux/data/solar_models/SolarModel_B16-AGSS09.dat" /> - </TRestAxionSolarModel> +<TRestAxionSolarModels> + <TRestAxionSolarModel name="SolarAxionLibTest" verboseLevel="debug"> + <parameter name="solarAxionModel" value="external/solarAxionFlux/data/solar_models/SolarModel_B16-AGSS09.dat"/> + </TRestAxionSolarModel> </TRestAxionSolarModels> diff --git a/scripts/xlsToBin.py b/scripts/xlsToBin.py index 8d57a87d..a8e8dd23 100755 --- a/scripts/xlsToBin.py +++ b/scripts/xlsToBin.py @@ -1,6 +1,6 @@ #!/usr/bin/python -# This basic script serves to create a plain binary file from the XLS files provided by Bykovsky +# This basic script serves to create a plain binary file from the XLS files provided by Bykovsky # for the Baby-IAXO magnet. We will only upload the resulting bin file, if the original XLS file # would be required at some point, do not hesitate to contact me at javier.galan@unizar.es. # @@ -12,27 +12,27 @@ import struct from pandas import DataFrame, read_csv import matplotlib.pyplot as plt -import pandas as pd +import pandas as pd -# Field map is provided only for the top magnetic bore. We will recenter the field map. +# Field map is provided only for the top magnetic bore. We will recenter the field map. # Since this is a condition for TRestAxionMagneticField. xCenter = 0 yCenter = 0 zCenter = 0.7975 -print "Starting to read" +print("Starting to read") # loading the data into a matrix (xyzBdata) -file = r'../../../data/magneticField/Bykovskiy_201906.xls' +file = r"../../../data/magneticField/Bykovskiy_201906.xls" df = pd.read_excel(file) -print df[1:5] +print(df[1:5]) -print "Translating to matrix" +print("Translating to matrix") xyzBdata = df.as_matrix(columns=df.columns[0:]) -print xyzBdata[0][0:6] +print(xyzBdata[0][0:6]) -print len(xyzBdata) +print(len(xyzBdata)) # Printing out some info about data xMax = -100000 @@ -52,7 +52,20 @@ f = open("output.txt", "wt") for x in xyzBdata: - f.write( str(x[0]) + "\t" + str(x[1]) + "\t" + str(x[2]) + "\t" + str(x[3]) + "\t" + str(x[4]) + "\t" + str(x[5]) + "\n" ) + f.write( + str(x[0]) + + "\t" + + str(x[1]) + + "\t" + + str(x[2]) + + "\t" + + str(x[3]) + + "\t" + + str(x[4]) + + "\t" + + str(x[5]) + + "\n" + ) if xMax < x[0]: xMax = x[0] if yMax < x[1]: @@ -83,51 +96,57 @@ f.close() -print "X max : " + str(xMax) -print "Y max : " + str(yMax) -print "Z max : " + str(zMax) + "\n" +print("X max : " + str(xMax)) +print("Y max : " + str(yMax)) +print("Z max : " + str(zMax) + "\n") -print "X min : " + str(xMin) -print "Y min : " + str(yMin) -print "Z min : " + str(zMin) + "\n" +print("X min : " + str(xMin)) +print("Y min : " + str(yMin)) +print("Z min : " + str(zMin) + "\n") -print "BX max : " + str(xBMax) -print "BY max : " + str(yBMax) -print "BZ max : " + str(zBMax) + "\n" +print("BX max : " + str(xBMax)) +print("BY max : " + str(yBMax)) +print("BZ max : " + str(zBMax) + "\n") -print "BX min : " + str(xBMin) -print "BY min : " + str(yBMin) -print "BZ min : " + str(zBMin) + "\n" +print("BX min : " + str(xBMin)) +print("BY min : " + str(yBMin)) +print("BZ min : " + str(zBMin) + "\n") # Creating the binary file -fbin = open('output.bin', 'wb') +fbin = open("output.bin", "wb") count = 0 for x in xyzBdata: # We recenter the volume and redefine axis (x becomes z, y becomes x and z becomes y) # XLS file distances are expressed in m. We translate to mm. - y = [1000*(x[1]-yCenter),1000*(x[2]-zCenter),1000*(x[0]-xCenter),x[4],x[5],x[3]] + y = [ + 1000 * (x[1] - yCenter), + 1000 * (x[2] - zCenter), + 1000 * (x[0] - xCenter), + x[4], + x[5], + x[3], + ] # Baby-IAXO is symmetric respect to z (direction along axis) and x (direction parallel to the ground). # I.e. x and y in the previous axis definition. # The y-axis symmetry (in the new axis definition) affects the second bore that is not described in this map. # We apply the corresponding symmetries to define the full map of one magnetic bore in the output binary file. - count = count + 1 - fbin.write(struct.pack('<%df' % len(y), *y)) - if( count < 6 ): - print len(y) - print x[0:6] - print y[0:6] + fbin.write(struct.pack("<%df" % len(y), *y)) + if count < 6: + print(len(y)) + print(x[0:6]) + print(y[0:6]) # The original file was only missing the z-axis, when we change the sign of z-axis we must change the sign of Bz. if y[2] > 0: y[2] = -y[2] y[5] = -y[5] count = count + 1 - fbin.write(struct.pack('<%df' % len(y), *y)) - if( count < 6 ): - print len(y) - print x[0:6] - print y[0:6] + fbin.write(struct.pack("<%df" % len(y), *y)) + if count < 6: + print(len(y)) + print(x[0:6]) + print(y[0:6]) fbin.close() -print "Lines writen : " + str(count) +print("Lines writen : " + str(count)) From decbac624ee1700131344e02fd97cbfddcecd881 Mon Sep 17 00:00:00 2001 From: Luis Antonio Obis Aparicio <luis.antonio.obis@gmail.com> Date: Fri, 10 Feb 2023 17:09:16 +0100 Subject: [PATCH 3/6] run pre-commit on all files --- .github/workflows/validation.yml | 2 +- CMakeLists.txt | 86 ++-- README.md | 2 +- cmake/CompileDir.cmake | 449 +++++++++--------- cmake/FindGarfield.cmake | 62 +-- cmake/FindROOT.cmake | 375 ++++++++------- cmake/MacroRootDict.cmake | 240 +++++----- examples/old/axionGenerator.rml | 2 +- images/Logo_REST_full_doxygen.svg | 2 +- inc/TRestAxionDetectorResponseProcess.h | 1 - inc/TRestAxionDeviationProcess.h | 1 - inc/TRestAxionEvent.h | 3 +- inc/TRestAxionFieldPropagationProcess.h | 5 +- inc/TRestAxionGeneratorProcess.h | 6 +- inc/TRestAxionLikelihood.h | 3 +- inc/TRestAxionMCPLOptics.h | 1 + inc/TRestAxionMagneticField.h | 4 +- inc/TRestAxionOptics.h | 1 + inc/TRestAxionOpticsMirror.h | 4 +- inc/TRestAxionSolarFlux.h | 4 +- inc/TRestAxionTrueWolterOptics.h | 1 + inc/TRestAxionWolterOptics.h | 1 + macros/REST_Axion_XMMAngleEffCSV.C | 47 +- pipeline/README.md | 1 - pipeline/clang-format/clang-format.sh | 1 - pipeline/clang-format/clangformattest.sh | 1 - pipeline/likelihood/babyIAXO.rml | 61 ++- .../metadata/magneticField/boundary/README.md | 8 +- .../metadata/magneticField/magneticField.py | 90 ++-- .../GetMagneticField_test_output.txt | 1 - .../magneticField/trilinear/README.md | 21 +- pipeline/metadata/optics/basic.py | 159 ++++--- pipeline/metadata/optics/mcpl.py | 10 +- pipeline/metadata/optics/mirrors.py | 102 ++-- pipeline/metadata/solarFlux/compare.py | 95 ++-- pipeline/metadata/solarFlux/solarPlot.py | 138 +++--- pipeline/metadata/solarFlux/solarTests.py | 55 ++- pipeline/metadata/transmission/windowPlot.py | 157 +++--- .../axion-field/validateStreamer.py | 12 +- pipeline/validateLibrary.py | 224 ++++----- pipeline/validateMacros.py | 2 +- scripts/fluxToTables.py | 68 +-- src/TRestAxionEvent.cxx | 1 + src/TRestAxionField.cxx | 2 + src/TRestAxionFieldPropagationProcess.cxx | 1 + src/TRestAxionOpticsMirror.cxx | 1 + src/TRestAxionTrueWolterOptics.cxx | 2 + src/TRestAxionWolterOptics.cxx | 2 + 48 files changed, 1332 insertions(+), 1185 deletions(-) diff --git a/.github/workflows/validation.yml b/.github/workflows/validation.yml index 0e02e217..08e30e38 100644 --- a/.github/workflows/validation.yml +++ b/.github/workflows/validation.yml @@ -21,7 +21,7 @@ defaults: jobs: framework-validation: uses: rest-for-physics/framework/.github/workflows/validation.yml@master - + libCheck: name: Validate library runs-on: ubuntu-latest diff --git a/CMakeLists.txt b/CMakeLists.txt index 8aaefa06..fb71e894 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,66 +1,72 @@ -#---------------------------------------------------------------------------- +# ---------------------------------------------------------------------------- # Setup the project cmake_minimum_required(VERSION 3.5 FATAL_ERROR) include(ExternalProject) set(CMAKE_MACOSX_RPATH 1) -set( LibraryVersion "1.1" ) +set(LibraryVersion "1.1") add_definitions(-DLIBRARY_VERSION="${LibraryVersion}") -find_path( MPFR_FOUND mpfr.h ) -if( MPFR_FOUND MATCHES "MPFR_FOUND-NOTFOUND" ) - if( EXISTS ${MPFR_PATH}/include/mpfr.h ) - set( MPFR_FOUND FOUND ) - endif() -endif() +find_path(MPFR_FOUND mpfr.h) +if (MPFR_FOUND MATCHES "MPFR_FOUND-NOTFOUND") + if (EXISTS ${MPFR_PATH}/include/mpfr.h) + set(MPFR_FOUND FOUND) + endif () +endif () -if( MPFR_FOUND MATCHES "MPFR_FOUND-NOTFOUND" ) - message( FATAL_ERROR "MPFR library was not found. Adding the location to the installation path may solve this problem.\n Use -DMPFR_PATH=/path/to/mpfr/" ) -else() - set( external_include_dirs ${external_include_dirs} ${MPFR_PATH}/include ) - link_directories( ${MPFR_PATH}/lib ) -endif() +if (MPFR_FOUND MATCHES "MPFR_FOUND-NOTFOUND") + message( + FATAL_ERROR + "MPFR library was not found. Adding the location to the installation path may solve this problem.\n Use -DMPFR_PATH=/path/to/mpfr/" + ) +else () + set(external_include_dirs ${external_include_dirs} ${MPFR_PATH}/include) + link_directories(${MPFR_PATH}/lib) +endif () -#------------------------------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------------------------------- # Add the SolarAxionFlux library submodule as an external project. if (${REST_SOLAXFLUX} MATCHES "ON") - ## Integration of REST_SolaxFlux comes now as an option. - ## It causes problems when active development happens at that library - ## It should be fixed a versioning system. Probably through choosing the - ## right submodule commit that works with RestAxionLib. - ## - ## For the moment I will just encapsulate SolaxFlux library to be - ## able to compile and use a dummy/standard solar axion flux generation. + # Integration of REST_SolaxFlux comes now as an option. It causes problems + # when active development happens at that library It should be fixed a + # versioning system. Probably through choosing the right submodule commit + # that works with RestAxionLib. + # + # For the moment I will just encapsulate SolaxFlux library to be able to + # compile and use a dummy/standard solar axion flux generation. add_definitions(-DUSE_SolaxFlux) set(SOLAXFLUX_DIR "${CMAKE_CURRENT_SOURCE_DIR}/external/solarAxionFlux") - message( STATUS "SOLAXFLUX_DIR: ${SOLAXFLUX_DIR}" ) + message(STATUS "SOLAXFLUX_DIR: ${SOLAXFLUX_DIR}") - ExternalProject_Add(solaxflux - SOURCE_DIR ${SOLAXFLUX_DIR} - GIT_SUBMODULES "" - GIT_CONFIG advice.detachedHead=False - CMAKE_CACHE_ARGS "-DPYTHON_SUPPORT:STRING=OFF;-DCMAKE_CXX_COMPILER:STRING=${CMAKE_CXX_COMPILER}") + ExternalProject_Add( + solaxflux + SOURCE_DIR ${SOLAXFLUX_DIR} + GIT_SUBMODULES "" + GIT_CONFIG advice.detachedHead=False + CMAKE_CACHE_ARGS + "-DPYTHON_SUPPORT:STRING=OFF;-DCMAKE_CXX_COMPILER:STRING=${CMAKE_CXX_COMPILER}" + ) - link_directories( ${SOLAXFLUX_DIR}/lib ) - set( external_include_dirs ${external_include_dirs} ${SOLAXFLUX_DIR}/include ) - set( external_libs ${external_libs} -laxionflux) + link_directories(${SOLAXFLUX_DIR}/lib) + set(external_include_dirs ${external_include_dirs} ${SOLAXFLUX_DIR}/include) + set(external_libs ${external_libs} -laxionflux) endif (${REST_SOLAXFLUX} MATCHES "ON") -set( external_libs ${external_libs} -lmpfr ) +set(external_libs ${external_libs} -lmpfr) -COMPILELIB("") +compilelib("") -INSTALL(DIRECTORY ./data/ +install( + DIRECTORY ./data/ DESTINATION ./data/axion/ - COMPONENT install - ) + COMPONENT install) -INSTALL(DIRECTORY ./examples/ +install( + DIRECTORY ./examples/ DESTINATION ./examples/axion/ - COMPONENT install - ) + COMPONENT install) file(GLOB_RECURSE MAC "${CMAKE_CURRENT_SOURCE_DIR}/macros/*") -INSTALL(FILES ${MAC} DESTINATION ./macros/axion) +install(FILES ${MAC} DESTINATION ./macros/axion) diff --git a/README.md b/README.md index f211a7cd..2a7a8dfa 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ python3 pull-submodules.py --onlylibs As any REST library, this library requires a running installion of REST-for-Physics Framework. But on top of that, some calculations require higher precision arithmetics and we need to use a external library named `mpfr`. We use a c++ wrapper that is available at the [following site](http://www.holoborodko.com/pavel/mpfr/#intro). This wrapper (mpreal.h) is already available/uploaded to this repository. -All you need to be able to compile `axionlib` is to install the [mpfr](https://www.mpfr.org) and [mpir](http://mpir.org) libraries. Download the source, compile, and install. +All you need to be able to compile `axionlib` is to install the [mpfr](https://www.mpfr.org) and [mpir](http://mpir.org) libraries. Download the source, compile, and install. Usually as simple as running `./configure`, `make` and `make install` at the downloaded source directory. #### mpfr installation: diff --git a/cmake/CompileDir.cmake b/cmake/CompileDir.cmake index bcc1a639..f9413bdd 100644 --- a/cmake/CompileDir.cmake +++ b/cmake/CompileDir.cmake @@ -1,234 +1,247 @@ - - # ============================================================================ # Macro for compileing the whole directories into a single library # -# The working directory of this macro should have regular form like: -# DIR -# ├── CMakeLists.txt -# ├── SUB-DIR-1 -# │ ├── inc -# │ │ └── CLASS_A.h -# │ └── src -# │ └── CLASS_A.cxx -# └── SUB-DIR-2 -# ├── inc -# │ ├── CLASS_B.h -# │ └── CLASS_C.h -# └── src -# ├── CLASS_B.cxx -# └── CLASS_C.cxx -# Or: -# DIR -# ├── CMakeLists.txt -# ├── inc -# │ ├── CLASS_A.h -# │ └── CLASS_B.h -# └── src -# ├── CLASS_A.cxx -# └── CLASS_B.cxx +# The working directory of this macro should have regular form like: DIR ├── +# CMakeLists.txt ├── SUB-DIR-1 │ ├── inc │ │ └── CLASS_A.h │ └── src +# │ └── CLASS_A.cxx └── SUB-DIR-2 ├── inc │ ├── CLASS_B.h │ └── +# CLASS_C.h └── src ├── CLASS_B.cxx └── CLASS_C.cxx Or: DIR ├── CMakeLists.txt +# ├── inc │ ├── CLASS_A.h │ └── CLASS_B.h └── src ├── CLASS_A.cxx └── +# CLASS_B.cxx # -# This macro will first set include directories of cmake to ${CMAKE_CURRENT_SOURCE_DIR}, -# ${CMAKE_CURRENT_SOURCE_DIR}/inc, sub-directories, and sub-directories/inc. +# This macro will first set include directories of cmake to +# ${CMAKE_CURRENT_SOURCE_DIR}, ${CMAKE_CURRENT_SOURCE_DIR}/inc, sub-directories, +# and sub-directories/inc. # # Then it will find out all the cxx files and call CINT. # -# Finally it will call cmake to add a library, using the found cxx files, CINT-wrappered -# cxx files, and other defined c++ scripts. +# Finally it will call cmake to add a library, using the found cxx files, +# CINT-wrappered cxx files, and other defined c++ scripts. # -## Arguments: -# libname - the generated library name +# Arguments: libname - the generated library name # -## Optional global variables(PARENT_SCOPE): -# rest_include_dirs - the previous inc directories of REST. After this macro, -# additional inc dirs from the current directory will be -# attatched at the end of this variable. +# Optional global variables(PARENT_SCOPE): rest_include_dirs - the previous +# inc directories of REST. After this macro, additional inc dirs from the +# current directory will be attatched at the end of this variable. # -# external_include_dirs - the external inc dirs, for example from ROOT. +# external_include_dirs - the external inc dirs, for example from ROOT. # -## Optional local variables: -# contents - this variable defines needed sub-directories of current directory +# Optional local variables: contents - this variable defines needed +# sub-directories of current directory # -# addon_src - if some of the scripts do not follow regular directory form, -# set them in this argument to compile them. CINT will not be -# called for them. +# addon_src - if some of the scripts do not follow regular directory +# form, set them in this argument to compile them. CINT will not be called for +# them. # -# addon_CINT - if some of the scripts do not follow regular directory form, -# set them in this argument to compile them with CINT +# addon_CINT - if some of the scripts do not follow regular directory +# form, set them in this argument to compile them with CINT # -# addon_inc - if some of the header directories do not follow regular directory -# form, set them in this argument to include them. +# addon_inc - if some of the header directories do not follow +# regular directory form, set them in this argument to include them. # # ---------------------------------------------------------------------------- -MACRO( COMPILEDIR_SE libname ) - - message(STATUS "making build files for ${CMAKE_CURRENT_SOURCE_DIR}") - - set(contentfiles) - - if(DEFINED contents) - message("specified sub-dirs: ${contents}") - foreach(content ${contents}) - set(rest_include_dirs ${rest_include_dirs} ${addon_inc} ${CMAKE_CURRENT_SOURCE_DIR}/${content} ${CMAKE_CURRENT_SOURCE_DIR}/${content}/inc) - endforeach(content) - set(rest_include_dirs ${rest_include_dirs} PARENT_SCOPE) - - foreach(content ${contents}) - file(GLOB_RECURSE files ${content}/*.cxx) - foreach (file ${files}) - - string(REGEX MATCH "[^/\\]*cxx" temp ${file}) - string(REPLACE ".cxx" "" class ${temp}) - - set(ROOT_DICT_INCLUDE_DIRS ${rest_include_dirs} ${external_include_dirs}) - file(GLOB_RECURSE header ${class}.h) - set(ROOT_DICT_INPUT_HEADERS ${header} ${ROOT_DICT_OUTPUT_DIR}/${class}_LinkDef.h) - GEN_ROOT_DICT_LINKDEF_HEADER( ${class} ${header}) - GEN_ROOT_DICT_SOURCES(CINT_${class}.cxx ${ROOT_DICT_OUTPUT_DIR}/${class}_LinkDef.h) - - set(contentfiles ${contentfiles} ${file} ${ROOT_DICT_OUTPUT_SOURCES}) - - endforeach (file) - - endforeach(content) - else() - message("using inc/src folders in root directory") - set(rest_include_dirs ${rest_include_dirs} ${addon_inc} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/inc) - set(rest_include_dirs ${rest_include_dirs} PARENT_SCOPE) - - file(GLOB_RECURSE files src/*.cxx) - foreach (file ${files}) - - string(REGEX MATCH "[^/\\]*cxx" temp ${file}) - string(REPLACE ".cxx" "" class ${temp}) - - set(ROOT_DICT_INCLUDE_DIRS ${rest_include_dirs} ${external_include_dirs}) - file(GLOB_RECURSE header ${class}.h) - set(ROOT_DICT_INPUT_HEADERS ${header} ${ROOT_DICT_OUTPUT_DIR}/${class}_LinkDef.h) - GEN_ROOT_DICT_LINKDEF_HEADER( ${class} ${header}) - GEN_ROOT_DICT_SOURCES(CINT_${class}.cxx ${ROOT_DICT_OUTPUT_DIR}/${class}_LinkDef.h) - - set(contentfiles ${contentfiles} ${file} ${ROOT_DICT_OUTPUT_SOURCES}) - - endforeach (file) - - - - endif() - - - foreach(src ${addon_CINT}) - string(REGEX MATCH "[^/\\]+$" filename ${src}) - set(ROOT_DICT_INCLUDE_DIRS ${rest_include_dirs} ${external_include_dirs}) - set(ROOT_DICT_INPUT_HEADERS ${src}) - GEN_ROOT_DICT_SOURCES(CINT_${filename}.cxx) - set(contentfiles ${contentfiles} ${src} ${ROOT_DICT_OUTPUT_SOURCES}) - endforeach(src) - - - include_directories(${rest_include_dirs}) - add_library(${libname} SHARED ${contentfiles} ${addon_src}) - - - if(CMAKE_SYSTEM_NAME MATCHES "Windows") - set_target_properties(${libname} PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE) - target_link_libraries(${libname} ${rest_libraries} ${external_libs}) - install(TARGETS ${libname} - RUNTIME DESTINATION bin - LIBRARY DESTINATION bin - ARCHIVE DESTINATION lib) - else() - target_link_libraries(${libname} ${rest_libraries} ${external_libs}) - install(TARGETS ${libname} - RUNTIME DESTINATION bin - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib/static) - endif() - set(rest_libraries ${rest_libraries} ${libname}) - set(rest_libraries ${rest_libraries} PARENT_SCOPE) -ENDMACRO() - -MACRO( COMPILEDIR libname ) - - message(STATUS "making build files for ${CMAKE_CURRENT_SOURCE_DIR}") - - set(contentfiles) - - if(DEFINED contents) - message("specified sub-dirs: ${contents}") - foreach(content ${contents}) - set(rest_include_dirs ${rest_include_dirs} ${addon_inc} ${CMAKE_CURRENT_SOURCE_DIR}/${content} ${CMAKE_CURRENT_SOURCE_DIR}/${content}/inc) - endforeach(content) - set(rest_include_dirs ${rest_include_dirs} PARENT_SCOPE) - - foreach(content ${contents}) - file(GLOB_RECURSE files ${content}/*.cxx) - foreach (file ${files}) - - string(REGEX MATCH "[^/\\]*cxx" temp ${file}) - string(REPLACE ".cxx" "" class ${temp}) - - set(ROOT_DICT_INCLUDE_DIRS ${rest_include_dirs} ${external_include_dirs}) - file(GLOB_RECURSE header ${class}.h) - set(ROOT_DICT_INPUT_HEADERS ${header}) - GEN_ROOT_DICT_SOURCES(CINT_${class}.cxx) - - set(contentfiles ${contentfiles} ${file} ${ROOT_DICT_OUTPUT_SOURCES}) - - endforeach (file) - - endforeach(content) - else() - message("using inc/src folders in root directory") - set(rest_include_dirs ${rest_include_dirs} ${addon_inc} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/inc) - set(rest_include_dirs ${rest_include_dirs} PARENT_SCOPE) - - file(GLOB_RECURSE files src/*.cxx) - foreach (file ${files}) - - string(REGEX MATCH "[^/\\]*cxx" temp ${file}) - string(REPLACE ".cxx" "" class ${temp}) - - set(ROOT_DICT_INCLUDE_DIRS ${rest_include_dirs} ${external_include_dirs}) - file(GLOB_RECURSE header ${class}.h) - set(ROOT_DICT_INPUT_HEADERS ${header}) - GEN_ROOT_DICT_SOURCES(CINT_${class}.cxx) - - set(contentfiles ${contentfiles} ${file} ${ROOT_DICT_OUTPUT_SOURCES}) - - endforeach (file) - - - - endif() - - - foreach(src ${addon_CINT}) - string(REGEX MATCH "[^/\\]+$" filename ${src}) - set(ROOT_DICT_INCLUDE_DIRS ${rest_include_dirs} ${external_include_dirs}) - set(ROOT_DICT_INPUT_HEADERS ${src}) - GEN_ROOT_DICT_SOURCES(CINT_${filename}.cxx) - set(contentfiles ${contentfiles} ${src} ${ROOT_DICT_OUTPUT_SOURCES}) - endforeach(src) - - include_directories(${rest_include_dirs}) - add_library(${libname} SHARED ${contentfiles} ${addon_src}) - - if(CMAKE_SYSTEM_NAME MATCHES "Windows") - set_target_properties(${libname} PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE) - target_link_libraries(${libname} ${rest_libraries} ${external_libs}) - install(TARGETS ${libname} - RUNTIME DESTINATION bin - LIBRARY DESTINATION bin - ARCHIVE DESTINATION lib) - else() - target_link_libraries(${libname} ${rest_libraries} ${external_libs}) - install(TARGETS ${libname} - RUNTIME DESTINATION bin - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib/static) - endif() - set(rest_libraries ${rest_libraries} ${libname}) - set(rest_libraries ${rest_libraries} PARENT_SCOPE) -ENDMACRO() - +macro (COMPILEDIR_SE libname) + + message(STATUS "making build files for ${CMAKE_CURRENT_SOURCE_DIR}") + + set(contentfiles) + + if (DEFINED contents) + message("specified sub-dirs: ${contents}") + foreach (content ${contents}) + set(rest_include_dirs + ${rest_include_dirs} ${addon_inc} + ${CMAKE_CURRENT_SOURCE_DIR}/${content} + ${CMAKE_CURRENT_SOURCE_DIR}/${content}/inc) + endforeach (content) + set(rest_include_dirs + ${rest_include_dirs} + PARENT_SCOPE) + + foreach (content ${contents}) + file(GLOB_RECURSE files ${content}/*.cxx) + foreach (file ${files}) + + string(REGEX MATCH "[^/\\]*cxx" temp ${file}) + string(REPLACE ".cxx" "" class ${temp}) + + set(ROOT_DICT_INCLUDE_DIRS ${rest_include_dirs} + ${external_include_dirs}) + file(GLOB_RECURSE header ${class}.h) + set(ROOT_DICT_INPUT_HEADERS + ${header} ${ROOT_DICT_OUTPUT_DIR}/${class}_LinkDef.h) + gen_root_dict_linkdef_header(${class} ${header}) + gen_root_dict_sources( + CINT_${class}.cxx + ${ROOT_DICT_OUTPUT_DIR}/${class}_LinkDef.h) + + set(contentfiles ${contentfiles} ${file} + ${ROOT_DICT_OUTPUT_SOURCES}) + + endforeach (file) + + endforeach (content) + else () + message("using inc/src folders in root directory") + set(rest_include_dirs + ${rest_include_dirs} ${addon_inc} ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/inc) + set(rest_include_dirs + ${rest_include_dirs} + PARENT_SCOPE) + + file(GLOB_RECURSE files src/*.cxx) + foreach (file ${files}) + + string(REGEX MATCH "[^/\\]*cxx" temp ${file}) + string(REPLACE ".cxx" "" class ${temp}) + + set(ROOT_DICT_INCLUDE_DIRS ${rest_include_dirs} + ${external_include_dirs}) + file(GLOB_RECURSE header ${class}.h) + set(ROOT_DICT_INPUT_HEADERS + ${header} ${ROOT_DICT_OUTPUT_DIR}/${class}_LinkDef.h) + gen_root_dict_linkdef_header(${class} ${header}) + gen_root_dict_sources(CINT_${class}.cxx + ${ROOT_DICT_OUTPUT_DIR}/${class}_LinkDef.h) + + set(contentfiles ${contentfiles} ${file} + ${ROOT_DICT_OUTPUT_SOURCES}) + + endforeach (file) + + endif () + + foreach (src ${addon_CINT}) + string(REGEX MATCH "[^/\\]+$" filename ${src}) + set(ROOT_DICT_INCLUDE_DIRS ${rest_include_dirs} + ${external_include_dirs}) + set(ROOT_DICT_INPUT_HEADERS ${src}) + gen_root_dict_sources(CINT_${filename}.cxx) + set(contentfiles ${contentfiles} ${src} ${ROOT_DICT_OUTPUT_SOURCES}) + endforeach (src) + + include_directories(${rest_include_dirs}) + add_library(${libname} SHARED ${contentfiles} ${addon_src}) + + if (CMAKE_SYSTEM_NAME MATCHES "Windows") + set_target_properties(${libname} PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS + TRUE) + target_link_libraries(${libname} ${rest_libraries} ${external_libs}) + install( + TARGETS ${libname} + RUNTIME DESTINATION bin + LIBRARY DESTINATION bin + ARCHIVE DESTINATION lib) + else () + target_link_libraries(${libname} ${rest_libraries} ${external_libs}) + install( + TARGETS ${libname} + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib/static) + endif () + set(rest_libraries ${rest_libraries} ${libname}) + set(rest_libraries + ${rest_libraries} + PARENT_SCOPE) +endmacro () + +macro (COMPILEDIR libname) + + message(STATUS "making build files for ${CMAKE_CURRENT_SOURCE_DIR}") + + set(contentfiles) + + if (DEFINED contents) + message("specified sub-dirs: ${contents}") + foreach (content ${contents}) + set(rest_include_dirs + ${rest_include_dirs} ${addon_inc} + ${CMAKE_CURRENT_SOURCE_DIR}/${content} + ${CMAKE_CURRENT_SOURCE_DIR}/${content}/inc) + endforeach (content) + set(rest_include_dirs + ${rest_include_dirs} + PARENT_SCOPE) + + foreach (content ${contents}) + file(GLOB_RECURSE files ${content}/*.cxx) + foreach (file ${files}) + + string(REGEX MATCH "[^/\\]*cxx" temp ${file}) + string(REPLACE ".cxx" "" class ${temp}) + + set(ROOT_DICT_INCLUDE_DIRS ${rest_include_dirs} + ${external_include_dirs}) + file(GLOB_RECURSE header ${class}.h) + set(ROOT_DICT_INPUT_HEADERS ${header}) + gen_root_dict_sources(CINT_${class}.cxx) + + set(contentfiles ${contentfiles} ${file} + ${ROOT_DICT_OUTPUT_SOURCES}) + + endforeach (file) + + endforeach (content) + else () + message("using inc/src folders in root directory") + set(rest_include_dirs + ${rest_include_dirs} ${addon_inc} ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/inc) + set(rest_include_dirs + ${rest_include_dirs} + PARENT_SCOPE) + + file(GLOB_RECURSE files src/*.cxx) + foreach (file ${files}) + + string(REGEX MATCH "[^/\\]*cxx" temp ${file}) + string(REPLACE ".cxx" "" class ${temp}) + + set(ROOT_DICT_INCLUDE_DIRS ${rest_include_dirs} + ${external_include_dirs}) + file(GLOB_RECURSE header ${class}.h) + set(ROOT_DICT_INPUT_HEADERS ${header}) + gen_root_dict_sources(CINT_${class}.cxx) + + set(contentfiles ${contentfiles} ${file} + ${ROOT_DICT_OUTPUT_SOURCES}) + + endforeach (file) + + endif () + + foreach (src ${addon_CINT}) + string(REGEX MATCH "[^/\\]+$" filename ${src}) + set(ROOT_DICT_INCLUDE_DIRS ${rest_include_dirs} + ${external_include_dirs}) + set(ROOT_DICT_INPUT_HEADERS ${src}) + gen_root_dict_sources(CINT_${filename}.cxx) + set(contentfiles ${contentfiles} ${src} ${ROOT_DICT_OUTPUT_SOURCES}) + endforeach (src) + + include_directories(${rest_include_dirs}) + add_library(${libname} SHARED ${contentfiles} ${addon_src}) + + if (CMAKE_SYSTEM_NAME MATCHES "Windows") + set_target_properties(${libname} PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS + TRUE) + target_link_libraries(${libname} ${rest_libraries} ${external_libs}) + install( + TARGETS ${libname} + RUNTIME DESTINATION bin + LIBRARY DESTINATION bin + ARCHIVE DESTINATION lib) + else () + target_link_libraries(${libname} ${rest_libraries} ${external_libs}) + install( + TARGETS ${libname} + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib/static) + endif () + set(rest_libraries ${rest_libraries} ${libname}) + set(rest_libraries + ${rest_libraries} + PARENT_SCOPE) +endmacro () diff --git a/cmake/FindGarfield.cmake b/cmake/FindGarfield.cmake index cdbf9c43..480cda3f 100644 --- a/cmake/FindGarfield.cmake +++ b/cmake/FindGarfield.cmake @@ -1,59 +1,59 @@ +# * Try to find Garfield++ instalation This module sets up Garfield information +# It defines: Garfield_FOUND If Garfiled++ is found +# Garfield_INCLUDE_DIRS PATH to the include directories Garfield_LIBRARIES +# the libraries needed to use Garfield++ -# - Try to find Garfield++ instalation -# This module sets up Garfield information -# It defines: -# Garfield_FOUND If Garfiled++ is found -# Garfield_INCLUDE_DIRS PATH to the include directories -# Garfield_LIBRARIES the libraries needed to use Garfield++ +# message(STATUS "Looking for Garfield ...") -#message(STATUS "Looking for Garfield ...") - -# Alternative paths which can be defined by user -#set(Garfield_DIR "" CACHE PATH "Directory where Garfield is installed") -#set(Garfield_INC_DIR "" CACHE PATH "Alternative directory for Garfield includes") -#set(Garfield_LIB_DIR "" CACHE PATH "Alternative directory for Garfield libraries") +# Alternative paths which can be defined by user set(Garfield_DIR "" CACHE PATH +# "Directory where Garfield is installed") set(Garfield_INC_DIR "" CACHE PATH +# "Alternative directory for Garfield includes") set(Garfield_LIB_DIR "" CACHE +# PATH "Alternative directory for Garfield libraries") set(Garfield_DIR $ENV{GARFIELD_HOME}) find_path(Garfield_INCLUDE_DIRS Sensor.hh - HINTS ${Garfield_DIR}/include/ ${Garfield_DIR}/include/Garfield ${Garfield_INC_DIR} - ${Garfield_DIR}/Include) + HINTS ${Garfield_DIR}/include/ ${Garfield_DIR}/include/Garfield + ${Garfield_INC_DIR} ${Garfield_DIR}/Include) -#message(STATUS Garfield_INCLUDE_DIRS ${Garfield_INCLUDE_DIRS}) +# message(STATUS Garfield_INCLUDE_DIRS ${Garfield_INCLUDE_DIRS}) -find_library(Garfield_LIBRARIES NAMES libGarfield.so Garfield - HINTS ${Garfield_DIR}/lib ${Garfield_LIB_DIR} - $ENV{GARFIELD_HOME}/lib) -#message(STATUS Garfield_LIBRARIES ${Garfield_LIBRARIES}) +find_library( + Garfield_LIBRARIES + NAMES libGarfield.so Garfield + HINTS ${Garfield_DIR}/lib ${Garfield_LIB_DIR} $ENV{GARFIELD_HOME}/lib) +# message(STATUS Garfield_LIBRARIES ${Garfield_LIBRARIES}) -#if (${Garfield_LIBRARY_DIR}) -# set (Garfield_LIBRARIES -L${Garfield_LIBRARY_DIR} -lGarfield) -#endif() +# if (${Garfield_LIBRARY_DIR}) set (Garfield_LIBRARIES -L${Garfield_LIBRARY_DIR} +# -lGarfield) endif() if (Garfield_INCLUDE_DIRS AND Garfield_LIBRARIES) - set (Garfield_FOUND TRUE) -endif() + set(Garfield_FOUND TRUE) +endif () -if (NOT DEFINED ENV{GARFIELD_HOME} ) - message("\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\nError : GARFIELD HOME is not defined! +if (NOT DEFINED ENV{GARFIELD_HOME}) + message( + "\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\nError : GARFIELD HOME is not defined! \nCheck Garfield is installed and GARFIELD_HOME is pointing to install directory \nHINT : GARFIELD_HOME/lib/libGarfield.so should exist. \nIf you do not need Garfield++ interface in your REST installation, then, \nplease, run cmake disabling REST_GARFIELD variable \n\ni.e. : cmake -DREST_GARFIELD=OFF ../ - \n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n" ) -endif() + \n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n") +endif () if (Garfield_FOUND) if (NOT Garfield_FIND_QUIETLY) message(STATUS "Found Garfield includes in ${Garfield_INCLUDE_DIRS}") message(STATUS "Found Garfield libraries ${Garfield_LIBRARIES}") endif (NOT Garfield_FIND_QUIETLY) -else(Garfield_FOUND) +else (Garfield_FOUND) if (Garfield_FIND_REQUIRED) - message(FATAL_ERROR "Garfield required, but not found!\ntry to run \"./scripts/installation/v2.2/installGarfield.sh\" to install it. + message( + FATAL_ERROR + "Garfield required, but not found!\ntry to run \"./scripts/installation/v2.2/installGarfield.sh\" to install it. ") endif (Garfield_FIND_REQUIRED) -endif(Garfield_FOUND) +endif (Garfield_FOUND) # Make variables changeble to the advanced user mark_as_advanced(Garfield_INCLUDE_DIRS) diff --git a/cmake/FindROOT.cmake b/cmake/FindROOT.cmake index e9d911f5..c4e2cbcf 100644 --- a/cmake/FindROOT.cmake +++ b/cmake/FindROOT.cmake @@ -1,197 +1,196 @@ -# - Finds ROOT instalation -# This module sets up ROOT information -# It defines: -# ROOT_FOUND If the ROOT is found -# ROOT_INCLUDE_DIR PATH to the include directory (deprecated) -# ROOT_INCLUDE_DIRS PATH to the include directory -# ROOT_LIBRARIES Most common libraries -# ROOT_LIBRARY_DIR PATH to the library directory -# ROOT_BIN_DIR PATH to the excutables directory -# ROOT_PYTHONVER Compatible python version string - -# First search for ROOTConfig.cmake on the path defined via user setting +# * Finds ROOT instalation This module sets up ROOT information It defines: +# ROOT_FOUND If the ROOT is found ROOT_INCLUDE_DIR PATH to the +# include directory (deprecated) ROOT_INCLUDE_DIRS PATH to the include +# directory ROOT_LIBRARIES Most common libraries ROOT_LIBRARY_DIR PATH +# to the library directory ROOT_BIN_DIR PATH to the excutables +# directory ROOT_PYTHONVER Compatible python version string + +# First search for ROOTConfig.cmake on the path defined via user setting # ROOT_DIR -if(EXISTS ${ROOT_DIR}/ROOTConfig.cmake) - include(${ROOT_DIR}/ROOTConfig.cmake) - message(STATUS "Found ROOT CMake configuration in ${ROOT_DIR}") - set(ROOT_INCLUDE_DIR ${ROOT_INCLUDE_DIRS}) - set(ROOT_FOUND TRUE) - return() -endif() - -find_program(ROOT_CONFIG_EXECUTABLE root-config - PATHS ${ROOTSYS}/bin $ENV{ROOTSYS}/bin) - -if(NOT ROOT_CONFIG_EXECUTABLE) - set(ROOT_FOUND FALSE) -else() - set(ROOT_FOUND TRUE) - - execute_process( - COMMAND ${ROOT_CONFIG_EXECUTABLE} --prefix - OUTPUT_VARIABLE ROOTSYS - OUTPUT_STRIP_TRAILING_WHITESPACE) - - execute_process( - COMMAND ${ROOT_CONFIG_EXECUTABLE} --version - OUTPUT_VARIABLE ROOT_VERSION - OUTPUT_STRIP_TRAILING_WHITESPACE) - - execute_process( - COMMAND ${ROOT_CONFIG_EXECUTABLE} --incdir - OUTPUT_VARIABLE ROOT_INCLUDE_DIRS - OUTPUT_STRIP_TRAILING_WHITESPACE) - - execute_process( - COMMAND ${ROOT_CONFIG_EXECUTABLE} --libs - OUTPUT_VARIABLE ROOT_LIBRARIES - OUTPUT_STRIP_TRAILING_WHITESPACE) - - execute_process( - COMMAND ${ROOT_CONFIG_EXECUTABLE} --python-version - OUTPUT_VARIABLE ROOT_PYTHONVER - OUTPUT_STRIP_TRAILING_WHITESPACE) - - execute_process( - COMMAND ${ROOT_CONFIG_EXECUTABLE} --bindir - OUTPUT_VARIABLE ROOT_BIN_DIR - OUTPUT_STRIP_TRAILING_WHITESPACE) - - - #set(ROOT_LIBRARIES ${ROOT_LIBRARIES} -lThread -lMinuit -lHtml -lVMC -lEG -lGeom -lTreePlayer -lXMLIO -lProof) - #set(ROOT_LIBRARIES ${ROOT_LIBRARIES} -lProofPlayer -lMLP -lSpectrum -lEve -lRGL -lGed -lXMLParser -lPhysics) - set(ROOT_LIBRARY_DIR ${ROOTSYS}/lib) - set(ROOT_INCLUDE_DIR ${ROOT_INCLUDE_DIRS}) - - # Make variables changeble to the advanced user - mark_as_advanced(ROOT_CONFIG_EXECUTABLE) - - if(NOT ROOT_FIND_QUIETLY) - message(STATUS "Found ROOT ${ROOT_VERSION} in ${ROOTSYS}") - endif() -endif() +if (EXISTS ${ROOT_DIR}/ROOTConfig.cmake) + include(${ROOT_DIR}/ROOTConfig.cmake) + message(STATUS "Found ROOT CMake configuration in ${ROOT_DIR}") + set(ROOT_INCLUDE_DIR ${ROOT_INCLUDE_DIRS}) + set(ROOT_FOUND TRUE) + return() +endif () + +find_program(ROOT_CONFIG_EXECUTABLE root-config PATHS ${ROOTSYS}/bin + $ENV{ROOTSYS}/bin) + +if (NOT ROOT_CONFIG_EXECUTABLE) + set(ROOT_FOUND FALSE) +else () + set(ROOT_FOUND TRUE) + + execute_process( + COMMAND ${ROOT_CONFIG_EXECUTABLE} --prefix + OUTPUT_VARIABLE ROOTSYS + OUTPUT_STRIP_TRAILING_WHITESPACE) + + execute_process( + COMMAND ${ROOT_CONFIG_EXECUTABLE} --version + OUTPUT_VARIABLE ROOT_VERSION + OUTPUT_STRIP_TRAILING_WHITESPACE) + + execute_process( + COMMAND ${ROOT_CONFIG_EXECUTABLE} --incdir + OUTPUT_VARIABLE ROOT_INCLUDE_DIRS + OUTPUT_STRIP_TRAILING_WHITESPACE) + + execute_process( + COMMAND ${ROOT_CONFIG_EXECUTABLE} --libs + OUTPUT_VARIABLE ROOT_LIBRARIES + OUTPUT_STRIP_TRAILING_WHITESPACE) + + execute_process( + COMMAND ${ROOT_CONFIG_EXECUTABLE} --python-version + OUTPUT_VARIABLE ROOT_PYTHONVER + OUTPUT_STRIP_TRAILING_WHITESPACE) + + execute_process( + COMMAND ${ROOT_CONFIG_EXECUTABLE} --bindir + OUTPUT_VARIABLE ROOT_BIN_DIR + OUTPUT_STRIP_TRAILING_WHITESPACE) + + # set(ROOT_LIBRARIES ${ROOT_LIBRARIES} -lThread -lMinuit -lHtml -lVMC -lEG + # -lGeom -lTreePlayer -lXMLIO -lProof) set(ROOT_LIBRARIES ${ROOT_LIBRARIES} + # -lProofPlayer -lMLP -lSpectrum -lEve -lRGL -lGed -lXMLParser -lPhysics) + set(ROOT_LIBRARY_DIR ${ROOTSYS}/lib) + set(ROOT_INCLUDE_DIR ${ROOT_INCLUDE_DIRS}) + + # Make variables changeble to the advanced user + mark_as_advanced(ROOT_CONFIG_EXECUTABLE) + + if (NOT ROOT_FIND_QUIETLY) + message(STATUS "Found ROOT ${ROOT_VERSION} in ${ROOTSYS}") + endif () +endif () if (NOT ROOT_FOUND) - if (ROOT_FIND_REQUIRED) - message(FATAL_ERROR "ROOT required, but not found") - endif (ROOT_FIND_REQUIRED) -endif() + if (ROOT_FIND_REQUIRED) + message(FATAL_ERROR "ROOT required, but not found") + endif (ROOT_FIND_REQUIRED) +endif () -#include(CMakeMacroParseArguments) +# include(CMakeMacroParseArguments) find_program(ROOTCINT_EXECUTABLE rootcint PATHS $ENV{ROOTSYS}/bin) find_program(GENREFLEX_EXECUTABLE genreflex PATHS $ENV{ROOTSYS}/bin) find_package(GCCXML) -#---------------------------------------------------------------------------- -# function ROOT_GENERATE_DICTIONARY( dictionary -# header1 header2 ... -# LINKDEF linkdef1 ... -# OPTIONS opt1...) -function(ROOT_GENERATE_DICTIONARY dictionary) - CMAKE_PARSE_ARGUMENTS(ARG "" "" "LINKDEF;OPTIONS" "" ${ARGN}) - #---Get the list of header files------------------------- - set(headerfiles) - foreach(fp ${ARG_UNPARSED_ARGUMENTS}) - file(GLOB files ${fp}) - if(files) - foreach(f ${files}) - if(NOT f MATCHES LinkDef) - set(headerfiles ${headerfiles} ${f}) - endif() - endforeach() - else() - set(headerfiles ${headerfiles} ${fp}) - endif() - endforeach() - #---Get the list of include directories------------------ - # Filter out UNIX system directory to workaround bug in - # rootcint (info from Andrea Dotti, and info from post: - # http://root.cern.ch/phpBB3/viewtopic.php?f=3&t=15086 - get_directory_property(incdirs INCLUDE_DIRECTORIES) - set(includedirs) - foreach( d ${incdirs}) - if(NOT ${d} STREQUAL "/usr/include") - set(includedirs ${includedirs} -I${d}) - endif() - endforeach() - #---Get LinkDef.h file------------------------------------ - set(linkdefs) - foreach( f ${ARG_LINKDEF}) - if( IS_ABSOLUTE ${f}) - set(linkdefs ${linkdefs} ${f}) - else() - if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/inc/${f}) - set(linkdefs ${linkdefs} ${CMAKE_CURRENT_SOURCE_DIR}/inc/${f}) - else() - set(linkdefs ${linkdefs} ${CMAKE_CURRENT_SOURCE_DIR}/${f}) - endif() - endif() - endforeach() - #---call rootcint------------------------------------------ - add_custom_command(OUTPUT ${dictionary}.cxx ${dictionary}.h - COMMAND ${ROOTCINT_EXECUTABLE} -cint -f ${dictionary}.cxx - -c ${ARG_OPTIONS} ${includedirs} ${headerfiles} ${linkdefs} - DEPENDS ${headerfiles} ${linkdefs}) -endfunction() - -#---------------------------------------------------------------------------- -# function REFLEX_GENERATE_DICTIONARY(dictionary -# header1 header2 ... -# SELECTION selectionfile ... -# OPTIONS opt1...) -function(REFLEX_GENERATE_DICTIONARY dictionary) - CMAKE_PARSE_ARGUMENTS(ARG "" "" "SELECTION;OPTIONS" "" ${ARGN}) - #---Get the list of header files------------------------- - set(headerfiles) - foreach(fp ${ARG_UNPARSED_ARGUMENTS}) - file(GLOB files ${fp}) - if(files) - foreach(f ${files}) - set(headerfiles ${headerfiles} ${f}) - endforeach() - else() - set(headerfiles ${headerfiles} ${fp}) - endif() - endforeach() - #---Get Selection file------------------------------------ - if(IS_ABSOLUTE ${ARG_SELECTION}) - set(selectionfile ${ARG_SELECTION}) - else() - set(selectionfile ${CMAKE_CURRENT_SOURCE_DIR}/${ARG_SELECTION}) - endif() - #---Get the list of include directories------------------ - get_directory_property(incdirs INCLUDE_DIRECTORIES) - set(includedirs) - foreach( d ${incdirs}) - set(includedirs ${includedirs} -I${d}) - endforeach() - #---Get preprocessor definitions-------------------------- - get_directory_property(defs COMPILE_DEFINITIONS) - foreach( d ${defs}) - set(definitions ${definitions} -D${d}) - endforeach() - #---Names and others--------------------------------------- - set(gensrcdict ${dictionary}.cpp) - if(MSVC) - set(gccxmlopts "--gccxmlopt=\"--gccxml-compiler cl\"") - elseif(APPLE) - set(gccxmlopts "--gccxmlopt=--gccxml-compiler g++ ") - else() - set(gccxmlopts) - endif() - #set(rootmapname ${dictionary}Dict.rootmap) - #set(rootmapopts --rootmap=${rootmapname} --rootmap-lib=${libprefix}${dictionary}Dict) - #---Check GCCXML and get path----------------------------- - if(GCCXML) - get_filename_component(gccxmlpath ${GCCXML} PATH) - else() - message(WARNING "GCCXML not found. Install and setup your environment to find 'gccxml' executable") - endif() - #---Actual command---------------------------------------- - add_custom_command(OUTPUT ${gensrcdict} ${rootmapname} - COMMAND ${GENREFLEX_EXECUTABLE} ${headerfiles} -o ${gensrcdict} ${gccxmlopts} ${rootmapopts} --select=${selectionfile} - --gccxmlpath=${gccxmlpath} ${ARG_OPTIONS} ${includedirs} ${definitions} - DEPENDS ${headerfiles} ${selectionfile}) -endfunction() - +# ---------------------------------------------------------------------------- +# function ROOT_GENERATE_DICTIONARY( dictionary header1 header2 ... LINKDEF +# linkdef1 ... OPTIONS opt1...) +function (ROOT_GENERATE_DICTIONARY dictionary) + cmake_parse_arguments(ARG "" "" "LINKDEF;OPTIONS" "" ${ARGN}) + # ---Get the list of header files------------------------- + set(headerfiles) + foreach (fp ${ARG_UNPARSED_ARGUMENTS}) + file(GLOB files ${fp}) + if (files) + foreach (f ${files}) + if (NOT f MATCHES LinkDef) + set(headerfiles ${headerfiles} ${f}) + endif () + endforeach () + else () + set(headerfiles ${headerfiles} ${fp}) + endif () + endforeach () + # ---Get the list of include directories------------------ + # Filter out UNIX system directory to workaround bug in rootcint (info from + # Andrea Dotti, and info from post: + # http://root.cern.ch/phpBB3/viewtopic.php?f=3&t=15086 + get_directory_property(incdirs INCLUDE_DIRECTORIES) + set(includedirs) + foreach (d ${incdirs}) + if (NOT ${d} STREQUAL "/usr/include") + set(includedirs ${includedirs} -I${d}) + endif () + endforeach () + # ---Get LinkDef.h file------------------------------------ + set(linkdefs) + foreach (f ${ARG_LINKDEF}) + if (IS_ABSOLUTE ${f}) + set(linkdefs ${linkdefs} ${f}) + else () + if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/inc/${f}) + set(linkdefs ${linkdefs} ${CMAKE_CURRENT_SOURCE_DIR}/inc/${f}) + else () + set(linkdefs ${linkdefs} ${CMAKE_CURRENT_SOURCE_DIR}/${f}) + endif () + endif () + endforeach () + # ---call rootcint------------------------------------------ + add_custom_command( + OUTPUT ${dictionary}.cxx ${dictionary}.h + COMMAND ${ROOTCINT_EXECUTABLE} -cint -f ${dictionary}.cxx -c + ${ARG_OPTIONS} ${includedirs} ${headerfiles} ${linkdefs} + DEPENDS ${headerfiles} ${linkdefs}) +endfunction () + +# ---------------------------------------------------------------------------- +# function REFLEX_GENERATE_DICTIONARY(dictionary header1 header2 ... SELECTION +# selectionfile ... OPTIONS opt1...) +function (REFLEX_GENERATE_DICTIONARY dictionary) + cmake_parse_arguments(ARG "" "" "SELECTION;OPTIONS" "" ${ARGN}) + # ---Get the list of header files------------------------- + set(headerfiles) + foreach (fp ${ARG_UNPARSED_ARGUMENTS}) + file(GLOB files ${fp}) + if (files) + foreach (f ${files}) + set(headerfiles ${headerfiles} ${f}) + endforeach () + else () + set(headerfiles ${headerfiles} ${fp}) + endif () + endforeach () + # ---Get Selection file------------------------------------ + if (IS_ABSOLUTE ${ARG_SELECTION}) + set(selectionfile ${ARG_SELECTION}) + else () + set(selectionfile ${CMAKE_CURRENT_SOURCE_DIR}/${ARG_SELECTION}) + endif () + # ---Get the list of include directories------------------ + get_directory_property(incdirs INCLUDE_DIRECTORIES) + set(includedirs) + foreach (d ${incdirs}) + set(includedirs ${includedirs} -I${d}) + endforeach () + # ---Get preprocessor definitions-------------------------- + get_directory_property(defs COMPILE_DEFINITIONS) + foreach (d ${defs}) + set(definitions ${definitions} -D${d}) + endforeach () + # ---Names and others--------------------------------------- + set(gensrcdict ${dictionary}.cpp) + if (MSVC) + set(gccxmlopts "--gccxmlopt=\"--gccxml-compiler cl\"") + elseif (APPLE) + set(gccxmlopts "--gccxmlopt=--gccxml-compiler g++ ") + else () + set(gccxmlopts) + endif () + # set(rootmapname ${dictionary}Dict.rootmap) set(rootmapopts + # --rootmap=${rootmapname} --rootmap-lib=${libprefix}${dictionary}Dict) + # ---Check GCCXML and get path----------------------------- + if (GCCXML) + get_filename_component(gccxmlpath ${GCCXML} PATH) + else () + message( + WARNING + "GCCXML not found. Install and setup your environment to find 'gccxml' executable" + ) + endif () + # ---Actual command---------------------------------------- + add_custom_command( + OUTPUT ${gensrcdict} ${rootmapname} + COMMAND + ${GENREFLEX_EXECUTABLE} ${headerfiles} -o ${gensrcdict} + ${gccxmlopts} ${rootmapopts} --select=${selectionfile} + --gccxmlpath=${gccxmlpath} ${ARG_OPTIONS} ${includedirs} + ${definitions} + DEPENDS ${headerfiles} ${selectionfile}) +endfunction () diff --git a/cmake/MacroRootDict.cmake b/cmake/MacroRootDict.cmake index d2aa6ab6..244b4fe2 100644 --- a/cmake/MacroRootDict.cmake +++ b/cmake/MacroRootDict.cmake @@ -1,158 +1,170 @@ -IF(APPLE) - SET( LD_LIBRARY_PATH_VAR DYLD_LIBRARY_PATH ) -ELSE() - SET( LD_LIBRARY_PATH_VAR LD_LIBRARY_PATH ) -ENDIF() -SET( LD_LIBRARY_PATH_CONTENTS $ENV{${LD_LIBRARY_PATH_VAR}} ) -#MESSAGE( STATUS "LD_LIBRARY_PATH_CONTENTS: ${LD_LIBRARY_PATH_CONTENTS}" ) - -SET( ROOT_CINT_WRAPPER ${LD_LIBRARY_PATH_VAR}=${ROOT_LIBRARY_DIR}:${LD_LIBRARY_PATH_CONTENTS} ${ROOTCINT_EXECUTABLE} ) - -IF( NOT DEFINED ROOT_DICT_OUTPUT_DIR ) - SET( ROOT_DICT_OUTPUT_DIR "${PROJECT_BINARY_DIR}/rootdict" ) -ENDIF() +if (APPLE) + set(LD_LIBRARY_PATH_VAR DYLD_LIBRARY_PATH) +else () + set(LD_LIBRARY_PATH_VAR LD_LIBRARY_PATH) +endif () +set(LD_LIBRARY_PATH_CONTENTS $ENV{${LD_LIBRARY_PATH_VAR}}) +# MESSAGE( STATUS "LD_LIBRARY_PATH_CONTENTS: ${LD_LIBRARY_PATH_CONTENTS}" ) + +set(ROOT_CINT_WRAPPER + ${LD_LIBRARY_PATH_VAR}=${ROOT_LIBRARY_DIR}:${LD_LIBRARY_PATH_CONTENTS} + ${ROOTCINT_EXECUTABLE}) + +if (NOT DEFINED ROOT_DICT_OUTPUT_DIR) + set(ROOT_DICT_OUTPUT_DIR "${PROJECT_BINARY_DIR}/rootdict") +endif () # clean generated header files with 'make clean' -SET_DIRECTORY_PROPERTIES( PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${ROOT_DICT_OUTPUT_DIR}" ) - -IF( NOT ROOT_FIND_QUIETLY ) - MESSAGE( STATUS "Check for ROOT_DICT_OUTPUT_DIR: ${PROJECT_BINARY_DIR}/rootdict" ) - MESSAGE( STATUS "Check for ROOT_DICT_CINT_DEFINITIONS: ${ROOT_DICT_CINT_DEFINITIONS}" ) -ENDIF() - +set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES + "${ROOT_DICT_OUTPUT_DIR}") + +if (NOT ROOT_FIND_QUIETLY) + message( + STATUS "Check for ROOT_DICT_OUTPUT_DIR: ${PROJECT_BINARY_DIR}/rootdict") + message( + STATUS + "Check for ROOT_DICT_CINT_DEFINITIONS: ${ROOT_DICT_CINT_DEFINITIONS}" + ) +endif () # ============================================================================ -# helper macro to prepare input headers for GEN_ROOT_DICT_SOURCES -# sorts LinkDef.h to be the last header (required by rootcint) +# helper macro to prepare input headers for GEN_ROOT_DICT_SOURCES sorts +# LinkDef.h to be the last header (required by rootcint) # -# arguments: -# input_dir - directory to search for headers matching *.hh +# arguments: input_dir - directory to search for headers matching *.hh # -# returns: -# ROOT_DICT_INPUT_HEADERS - all header files found in input_dir with -# ${input_dir}_LinkDef.h as the last header (if found) +# returns: ROOT_DICT_INPUT_HEADERS - all header files found in input_dir with +# ${input_dir}_LinkDef.h as the last header (if found) # # ---------------------------------------------------------------------------- -MACRO( PREPARE_ROOT_DICT_HEADERS _input_dir ) - - FILE( GLOB ROOT_DICT_INPUT_HEADERS "${_input_dir}/*.h" ) - FILE( GLOB _linkdef_hdr "${_input_dir}/LinkDef.h" ) +macro (PREPARE_ROOT_DICT_HEADERS _input_dir) - #LIST( FIND ROOT_DICT_INPUT_HEADERS ${_linkdef_hdr} _aux ) - #IF( ${_aux} EQUAL 0 OR ${_aux} GREATER 0 ) - # LIST( REMOVE_ITEM ROOT_DICT_INPUT_HEADERS "${_linkdef_hdr}" ) - # LIST( APPEND ROOT_DICT_INPUT_HEADERS "${_linkdef_hdr}" ) - #ENDIF() + file(GLOB ROOT_DICT_INPUT_HEADERS "${_input_dir}/*.h") + file(GLOB _linkdef_hdr "${_input_dir}/LinkDef.h") - IF( _linkdef_hdr ) - LIST( REMOVE_ITEM ROOT_DICT_INPUT_HEADERS "${_linkdef_hdr}" ) - LIST( APPEND ROOT_DICT_INPUT_HEADERS "${_linkdef_hdr}") - ENDIF() + # LIST( FIND ROOT_DICT_INPUT_HEADERS ${_linkdef_hdr} _aux ) IF( ${_aux} + # EQUAL 0 OR ${_aux} GREATER 0 ) LIST( REMOVE_ITEM ROOT_DICT_INPUT_HEADERS + # "${_linkdef_hdr}" ) LIST( APPEND ROOT_DICT_INPUT_HEADERS "${_linkdef_hdr}" + # ) ENDIF() - #MESSAGE( STATUS "ROOT_DICT_INPUT_HEADERS: ${ROOT_DICT_INPUT_HEADERS}" ) - -ENDMACRO( PREPARE_ROOT_DICT_HEADERS ) + if (_linkdef_hdr) + list(REMOVE_ITEM ROOT_DICT_INPUT_HEADERS "${_linkdef_hdr}") + list(APPEND ROOT_DICT_INPUT_HEADERS "${_linkdef_hdr}") + endif () + # MESSAGE( STATUS "ROOT_DICT_INPUT_HEADERS: ${ROOT_DICT_INPUT_HEADERS}" ) +endmacro (PREPARE_ROOT_DICT_HEADERS) # ============================================================================ # helper macro to generate Linkdef.h files for rootcint # -# arguments: -# namespace - prefix used for creating header <namespace>_Linkdef.h -# ARGN - list of sources to be used for generating Linkdef.h +# arguments: namespace - prefix used for creating header <namespace>_Linkdef.h +# ARGN - list of sources to be used for generating Linkdef.h # -# returns: -# ROOT_DICT_INPUT_HEADERS - all header files + <namespace>_LinkDef.h in the -# correct order to be used by macro GEN_ROOT_DICT_SOURCES +# returns: ROOT_DICT_INPUT_HEADERS - all header files + <namespace>_LinkDef.h in +# the correct order to be used by macro GEN_ROOT_DICT_SOURCES # # ---------------------------------------------------------------------------- -MACRO( GEN_ROOT_DICT_LINKDEF_HEADER _namespace ) - - SET( _input_headers ${ARGN} ) - SET( _linkdef_header "${ROOT_DICT_OUTPUT_DIR}/${_namespace}_Linkdef.h" ) - - FOREACH( _header ${_input_headers} ) - SET( ${_namespace}_file_contents "${${_namespace}_file_contents}\\#ifdef __CINT__\\\\n" ) - SET( ${_namespace}_file_contents "${${_namespace}_file_contents}\\#pragma link off all globals\\;\\\\n" ) - SET( ${_namespace}_file_contents "${${_namespace}_file_contents}\\#pragma link off all classes\\;\\\\n" ) - SET( ${_namespace}_file_contents "${${_namespace}_file_contents}\\#pragma link off all functions\\;\\\\n" ) - SET( ${_namespace}_file_contents "${${_namespace}_file_contents}\\#pragma link C++ nestedclasses\\;\\\\n" ) - SET( ${_namespace}_file_contents "${${_namespace}_file_contents}\\#pragma link C++ nestedclasses\\;\\\\n" ) - SET( ${_namespace}_file_contents "${${_namespace}_file_contents}\\#pragma link C++ class ${_namespace}\\+\\;\\\\n" ) - SET( ${_namespace}_file_contents "${${_namespace}_file_contents}\\#endif\\\\n" ) - ENDFOREACH() - - ADD_CUSTOM_COMMAND( +macro (GEN_ROOT_DICT_LINKDEF_HEADER _namespace) + + set(_input_headers ${ARGN}) + set(_linkdef_header "${ROOT_DICT_OUTPUT_DIR}/${_namespace}_Linkdef.h") + + foreach (_header ${_input_headers}) + set(${_namespace}_file_contents + "${${_namespace}_file_contents}\\#ifdef __CINT__\\\\n") + set(${_namespace}_file_contents + "${${_namespace}_file_contents}\\#pragma link off all globals\\;\\\\n" + ) + set(${_namespace}_file_contents + "${${_namespace}_file_contents}\\#pragma link off all classes\\;\\\\n" + ) + set(${_namespace}_file_contents + "${${_namespace}_file_contents}\\#pragma link off all functions\\;\\\\n" + ) + set(${_namespace}_file_contents + "${${_namespace}_file_contents}\\#pragma link C++ nestedclasses\\;\\\\n" + ) + set(${_namespace}_file_contents + "${${_namespace}_file_contents}\\#pragma link C++ nestedclasses\\;\\\\n" + ) + set(${_namespace}_file_contents + "${${_namespace}_file_contents}\\#pragma link C++ class ${_namespace}\\+\\;\\\\n" + ) + set(${_namespace}_file_contents + "${${_namespace}_file_contents}\\#endif\\\\n") + endforeach () + + add_custom_command( OUTPUT ${_linkdef_header} COMMAND mkdir -p ${ROOT_DICT_OUTPUT_DIR} COMMAND printf "${${_namespace}_file_contents}" > ${_linkdef_header} DEPENDS ${_input_headers} - COMMENT "generating: ${_linkdef_header}" - ) - - SET( ROOT_DICT_INPUT_HEADERS ${_input_headers} ${_linkdef_header} ) + COMMENT "generating: ${_linkdef_header}") -ENDMACRO() + set(ROOT_DICT_INPUT_HEADERS ${_input_headers} ${_linkdef_header}) +endmacro () # ============================================================================ # macro for generating root dict sources with rootcint # -# arguments: -# dict_src_filename - filename of the dictionary source (to be generated) +# arguments: dict_src_filename - filename of the dictionary source (to be +# generated) # -# requires following variables: -# ROOT_DICT_INPUT_HEADERS - list of headers needed to generate dict source -# * if $LinkDef.h is in the list it must be at the end !! -# ROOT_DICT_INCLUDE_DIRS - list of include dirs to pass to rootcint -I.. -# ROOT_DICT_CINT_DEFINITIONS - extra definitions to pass to rootcint -# ROOT_DICT_OUTPUT_DIR - where dictionary source should be generated +# requires following variables: ROOT_DICT_INPUT_HEADERS - list of headers needed +# to generate dict source * if $LinkDef.h is in the list it must be at the end +# !! ROOT_DICT_INCLUDE_DIRS - list of include dirs to pass to rootcint -I.. +# ROOT_DICT_CINT_DEFINITIONS - extra definitions to pass to rootcint +# ROOT_DICT_OUTPUT_DIR - where dictionary source should be generated # -# returns: -# ROOT_DICT_OUTPUT_SOURCES - list containing generated source and other -# previously generated sources - +# returns: ROOT_DICT_OUTPUT_SOURCES - list containing generated source and other +# previously generated sources + # ---------------------------------------------------------------------------- -MACRO( GEN_ROOT_DICT_SOURCE _dict_src_filename ) +macro (GEN_ROOT_DICT_SOURCE _dict_src_filename) - SET( _input_depend ${ARGN} ) + set(_input_depend ${ARGN}) # TODO check for ROOT_CINT_EXECUTABLE # need to prefix all include dirs with -I - set( _dict_includes ) - FOREACH( _inc ${ROOT_DICT_INCLUDE_DIRS} ) - SET( _dict_includes "${_dict_includes}\t-I${_inc}") #fg: the \t fixes a wired string expansion - #SET( _dict_includes ${_dict_includes} -I${_inc} ) - ENDFOREACH() - - # We modify the list of headers to be given to ROOTCINT command. - # We must remove/clean the full path from the main header - list ( GET ROOT_DICT_INPUT_HEADERS 0 MAIN_HEADER) - get_filename_component( MAIN_HEADER_CLEAN ${MAIN_HEADER} NAME) - list ( GET ROOT_DICT_INPUT_HEADERS 1 LINKDEF_HEADER ) - set( ROOT_DICT_INPUT_HEADERS_CLEAN ${MAIN_HEADER_CLEAN} ${LINKDEF_HEADER} ) - - - STRING( REPLACE "/" "_" _dict_src_filename_nosc ${_dict_src_filename} ) - SET( _dict_src_file ${ROOT_DICT_OUTPUT_DIR}/${_dict_src_filename_nosc} ) - STRING( REGEX REPLACE "^(.*)\\.(.*)$" "\\1.h" _dict_hdr_file "${_dict_src_file}" ) - ADD_CUSTOM_COMMAND( - OUTPUT ${_dict_src_file} + set(_dict_includes) + foreach (_inc ${ROOT_DICT_INCLUDE_DIRS}) + set(_dict_includes "${_dict_includes}\t-I${_inc}") # fg: the \t fixes a + # wired string + # expansion + # SET( _dict_includes ${_dict_includes} -I${_inc} ) + endforeach () + + # We modify the list of headers to be given to ROOTCINT command. We must + # remove/clean the full path from the main header + list(GET ROOT_DICT_INPUT_HEADERS 0 MAIN_HEADER) + get_filename_component(MAIN_HEADER_CLEAN ${MAIN_HEADER} NAME) + list(GET ROOT_DICT_INPUT_HEADERS 1 LINKDEF_HEADER) + set(ROOT_DICT_INPUT_HEADERS_CLEAN ${MAIN_HEADER_CLEAN} ${LINKDEF_HEADER}) + + string(REPLACE "/" "_" _dict_src_filename_nosc ${_dict_src_filename}) + set(_dict_src_file ${ROOT_DICT_OUTPUT_DIR}/${_dict_src_filename_nosc}) + string(REGEX REPLACE "^(.*)\\.(.*)$" "\\1.h" _dict_hdr_file + "${_dict_src_file}") + add_custom_command( + OUTPUT ${_dict_src_file} COMMAND mkdir -p ${ROOT_DICT_OUTPUT_DIR} - COMMAND ${ROOT_CINT_WRAPPER} -f "${_dict_src_file}" ${_dict_includes} ${ROOT_DICT_INPUT_HEADERS_CLEAN} + COMMAND ${ROOT_CINT_WRAPPER} -f "${_dict_src_file}" ${_dict_includes} + ${ROOT_DICT_INPUT_HEADERS_CLEAN} WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" DEPENDS ${ROOT_DICT_INPUT_HEADERS} ${_input_depend} - COMMENT "generating: ${_dict_src_file} with ${ROOT_DICT_INPUT_HEADERS}" - ) - LIST( APPEND ROOT_DICT_OUTPUT_SOURCES ${_dict_src_file} ) + COMMENT "generating: ${_dict_src_file} with ${ROOT_DICT_INPUT_HEADERS}") + list(APPEND ROOT_DICT_OUTPUT_SOURCES ${_dict_src_file}) -ENDMACRO() +endmacro () # for backwards compatibility -MACRO( GEN_ROOT_DICT_SOURCES _dict_src_filename ) - #MESSAGE( "USING DEPRECATED GEN_ROOT_DICT_SOURCES. PLEASE USE GEN_ROOT_DICT_SOURCE instead." ) - SET( ROOT_DICT_OUTPUT_SOURCES ) - GEN_ROOT_DICT_SOURCE( ${_dict_src_filename} ) -ENDMACRO() +macro (GEN_ROOT_DICT_SOURCES _dict_src_filename) + # MESSAGE( "USING DEPRECATED GEN_ROOT_DICT_SOURCES. PLEASE USE + # GEN_ROOT_DICT_SOURCE instead." ) + set(ROOT_DICT_OUTPUT_SOURCES) + gen_root_dict_source(${_dict_src_filename}) +endmacro () # ============================================================================ diff --git a/examples/old/axionGenerator.rml b/examples/old/axionGenerator.rml index d8088f69..5357a3df 100644 --- a/examples/old/axionGenerator.rml +++ b/examples/old/axionGenerator.rml @@ -74,7 +74,7 @@ <!-- <TRestAxionSolarModel name="sunPrimakoff" file="metadata.rml" verboseLevel="info" /> - <addTask command="sunPrimakoff->PrintMetadata()" value="ON"/> + <addTask command="sunPrimakoff->PrintMetadata()" value="ON"/> --> <addTask command="EventProcess->RunProcess()" value="ON"/> </TRestManager> diff --git a/images/Logo_REST_full_doxygen.svg b/images/Logo_REST_full_doxygen.svg index 8546af69..c0f2194f 100644 --- a/images/Logo_REST_full_doxygen.svg +++ b/images/Logo_REST_full_doxygen.svg @@ -173,4 +173,4 @@ <use xlink:href="#glyph3-2" x="67.01427" y="37.933977"></use> </g> </g> -</svg> \ No newline at end of file +</svg> diff --git a/inc/TRestAxionDetectorResponseProcess.h b/inc/TRestAxionDetectorResponseProcess.h index 76b63de8..7fcb48f5 100644 --- a/inc/TRestAxionDetectorResponseProcess.h +++ b/inc/TRestAxionDetectorResponseProcess.h @@ -24,7 +24,6 @@ #define RestCore_TRestAxionDetectorResponseProcess #include "TH2D.h" - #include "TRestAxionEvent.h" #include "TRestEventProcess.h" diff --git a/inc/TRestAxionDeviationProcess.h b/inc/TRestAxionDeviationProcess.h index b66355bb..91f0728a 100644 --- a/inc/TRestAxionDeviationProcess.h +++ b/inc/TRestAxionDeviationProcess.h @@ -24,7 +24,6 @@ #define RestCore_TRestAxionDeviationProcess #include "TRandom3.h" - #include "TRestAxionEvent.h" #include "TRestAxionEventProcess.h" diff --git a/inc/TRestAxionEvent.h b/inc/TRestAxionEvent.h index 88f386f1..566a7883 100644 --- a/inc/TRestAxionEvent.h +++ b/inc/TRestAxionEvent.h @@ -27,10 +27,9 @@ #include "TMath.h" #include "TObject.h" -#include "TVector3.h" - #include "TRestEvent.h" #include "TRestSystemOfUnits.h" +#include "TVector3.h" /// An event data class to define the parameters related to an axion particle class TRestAxionEvent : public TRestEvent { diff --git a/inc/TRestAxionFieldPropagationProcess.h b/inc/TRestAxionFieldPropagationProcess.h index 287645db..c12e3ac8 100644 --- a/inc/TRestAxionFieldPropagationProcess.h +++ b/inc/TRestAxionFieldPropagationProcess.h @@ -23,14 +23,13 @@ #ifndef RestCore_TRestAxionFieldPropagationProcess #define RestCore_TRestAxionFieldPropagationProcess -#include "TVector3.h" -#include "TVectorD.h" - #include "TRestAxionEvent.h" #include "TRestAxionEventProcess.h" #include "TRestAxionField.h" #include "TRestAxionMagneticField.h" #include "TRestPhysics.h" +#include "TVector3.h" +#include "TVectorD.h" //! A process to introduce the magnetic field profile integration along the track class TRestAxionFieldPropagationProcess : public TRestAxionEventProcess { diff --git a/inc/TRestAxionGeneratorProcess.h b/inc/TRestAxionGeneratorProcess.h index dedd9c06..b29391df 100644 --- a/inc/TRestAxionGeneratorProcess.h +++ b/inc/TRestAxionGeneratorProcess.h @@ -23,12 +23,10 @@ #ifndef RestCore_TRestAxionGeneratorProcess #define RestCore_TRestAxionGeneratorProcess +#include "TRandom3.h" #include "TRestAxionEvent.h" -#include "TRestEventProcess.h" - #include "TRestAxionSolarFlux.h" - -#include "TRandom3.h" +#include "TRestEventProcess.h" //! A process to initialize the axion event (mainly through TRestAxionSolarFlux) class TRestAxionGeneratorProcess : public TRestEventProcess { diff --git a/inc/TRestAxionLikelihood.h b/inc/TRestAxionLikelihood.h index 5a0c70d6..055bb819 100644 --- a/inc/TRestAxionLikelihood.h +++ b/inc/TRestAxionLikelihood.h @@ -25,13 +25,12 @@ #include <TRestMetadata.h> +#include "TRandom3.h" #include "TRestAxionBufferGas.h" #include "TRestAxionField.h" #include "TRestAxionSolarModel.h" #include "TRestAxionSpectrum.h" -#include "TRandom3.h" - //! A metadata class deninning a particular implementation of the likelihood to obtain the experimental //! sensitivity class TRestAxionLikelihood : public TRestMetadata { diff --git a/inc/TRestAxionMCPLOptics.h b/inc/TRestAxionMCPLOptics.h index 96120320..dea39e61 100644 --- a/inc/TRestAxionMCPLOptics.h +++ b/inc/TRestAxionMCPLOptics.h @@ -24,6 +24,7 @@ #define _TRestAxionMCPLOptics #include <TRestAxionOptics.h> + #include <iostream> /// A class to load optics response using MCPL files diff --git a/inc/TRestAxionMagneticField.h b/inc/TRestAxionMagneticField.h index 1a1a723d..dfaf80e3 100644 --- a/inc/TRestAxionMagneticField.h +++ b/inc/TRestAxionMagneticField.h @@ -24,15 +24,15 @@ #define _TRestAxionMagneticField #include <TRestMetadata.h> + #include <iostream> #include "TCanvas.h" #include "TH2D.h" +#include "TRestMesh.h" #include "TVector3.h" #include "TVectorD.h" -#include "TRestMesh.h" - /// A structure to define the properties and store the field data of a single magnetic volume inside /// TRestAxionMagneticField struct MagneticFieldVolume { diff --git a/inc/TRestAxionOptics.h b/inc/TRestAxionOptics.h index 6289e7d8..4f049ebf 100644 --- a/inc/TRestAxionOptics.h +++ b/inc/TRestAxionOptics.h @@ -26,6 +26,7 @@ #include <TRestAxionOpticsMirror.h> #include <TRestCombinedMask.h> #include <TRestMetadata.h> + #include <iostream> #include "TRandom3.h" diff --git a/inc/TRestAxionOpticsMirror.h b/inc/TRestAxionOpticsMirror.h index ff8a871e..3ee5936a 100644 --- a/inc/TRestAxionOpticsMirror.h +++ b/inc/TRestAxionOpticsMirror.h @@ -23,10 +23,10 @@ #ifndef _TRestAxionOpticsMirror #define _TRestAxionOpticsMirror +#include <TCanvas.h> #include <TRestMetadata.h> -#include <iostream> -#include <TCanvas.h> +#include <iostream> /// A metadata class accessing the Henke database to load reflectivity data class TRestAxionOpticsMirror : public TRestMetadata { diff --git a/inc/TRestAxionSolarFlux.h b/inc/TRestAxionSolarFlux.h index a33d0ef1..064fcab7 100644 --- a/inc/TRestAxionSolarFlux.h +++ b/inc/TRestAxionSolarFlux.h @@ -27,10 +27,8 @@ #include <TH1F.h> #include <TH2F.h> #include <TRandom3.h> - -#include <TRestMetadata.h> - #include <TRestAxionSolarModel.h> +#include <TRestMetadata.h> //! A metadata class to load tabulated solar axion fluxes class TRestAxionSolarFlux : public TRestMetadata { diff --git a/inc/TRestAxionTrueWolterOptics.h b/inc/TRestAxionTrueWolterOptics.h index 505d6465..b8ba4ba0 100644 --- a/inc/TRestAxionTrueWolterOptics.h +++ b/inc/TRestAxionTrueWolterOptics.h @@ -26,6 +26,7 @@ #include <TRestRingsMask.h> #include <TRestSpiderMask.h> #include <TRestTools.h> + #include <iostream> /// A class that calculates the reflection path of X-rays through a Wolter 1 telescope diff --git a/inc/TRestAxionWolterOptics.h b/inc/TRestAxionWolterOptics.h index 83be3ccb..eb1e837a 100644 --- a/inc/TRestAxionWolterOptics.h +++ b/inc/TRestAxionWolterOptics.h @@ -26,6 +26,7 @@ #include <TRestRingsMask.h> #include <TRestSpiderMask.h> #include <TRestTools.h> + #include <iostream> /// A class that calculates the reflection path of X-rays through a Wolter 1 telescope diff --git a/macros/REST_Axion_XMMAngleEffCSV.C b/macros/REST_Axion_XMMAngleEffCSV.C index dbe22da2..81576f20 100644 --- a/macros/REST_Axion_XMMAngleEffCSV.C +++ b/macros/REST_Axion_XMMAngleEffCSV.C @@ -8,22 +8,26 @@ #define RestTask_Axion_XMMAngleEffCSV //******************************************************************************************************* -//*** Description: It creates an efficiency curve from different runs under different angles. +//*** Description: It creates an efficiency curve from different runs under different angles. //*** It's also possible to compare data from a csv file with this curve. -//*** +//*** //*** //*** -------------- //*** Usage: restManager XMMAngleEffCSV "./trueWolter/OpticsBench_Yaw_*_Dev_*_BabyIAXO_Run*.root" [csvFile] //*** //*** Where the optional arguments are: //*** -//*** - The path and pattern name of the files that should be read in. The * is in the places where there is a difference in the file names. +//*** - The path and pattern name of the files that should be read in. The * is in the places where there is a +// difference in the file names. //*** -//*** - The path and name of the csv file with data to compare to the data from the prvious files. If not given it will be left out. +//*** - The path and name of the csv file with data to compare to the data from the prvious files. If not +// given it will be left out. //******************************************************************************************************* -Int_t REST_Axion_XMMAngleEffCSV(TString pathAndPattern = "./trueWolter/OpticsBench_Yaw_*_Dev_*_BabyIAXO_Run*.root", const string& csvFile = "") { +Int_t REST_Axion_XMMAngleEffCSV( + TString pathAndPattern = "./trueWolter/OpticsBench_Yaw_*_Dev_*_BabyIAXO_Run*.root", + const string& csvFile = "") { vector<string> files = TRestTools::GetFilesMatchingPattern((string)pathAndPattern); - + if (files.size() == 0) { RESTError << "Files not found!" << RESTendl; return -1; @@ -43,7 +47,9 @@ Int_t REST_Axion_XMMAngleEffCSV(TString pathAndPattern = "./trueWolter/OpticsBen Int_t obsID = run->GetAnalysisTree()->GetObservableID("optics_efficiency"); if (obsID == -1) { - RESTError << "No observable \"" << "optics_efficiency" << "\" in file " << files[n] << RESTendl; + RESTError << "No observable \"" + << "optics_efficiency" + << "\" in file " << files[n] << RESTendl; continue; } Double_t eff = 0; @@ -52,9 +58,9 @@ Int_t REST_Axion_XMMAngleEffCSV(TString pathAndPattern = "./trueWolter/OpticsBen Double_t dev = std::stod(run->GetMetadataMember("deviation::fDevAngle")) * 180. / 3.1415; for (int i = 0; i < run->GetEntries(); i++) { - run->GetAnalysisTree()->GetBranch((TString)"optics_efficiency")->GetEntry(i); + run->GetAnalysisTree()->GetBranch((TString) "optics_efficiency")->GetEntry(i); Double_t value = run->GetAnalysisTree()->GetDblObservableValue(obsID); - //std::cout << value << " for i " << i << std::endl; + // std::cout << value << " for i " << i << std::endl; counts++; eff += value; } @@ -63,20 +69,19 @@ Int_t REST_Axion_XMMAngleEffCSV(TString pathAndPattern = "./trueWolter/OpticsBen efficiencies[n] = eff; angles[n] = angle; totalCounts[n] = counts; - if (angle == 0 && dev == 0) eff0 = eff; // and dev 0 + if (angle == 0 && dev == 0) eff0 = eff; // and dev 0 } Double_t angleMax = *max_element(angles.begin(), angles.end()); - delete run; std::vector<float> effError; for (int n = 0; n < files.size(); n++) { std::cout << "eff: " << efficiencies[n] << " total " << totalCounts[n] << std::endl; effError.push_back(TMath::Sqrt(efficiencies[n] + efficiencies[n] / eff0) / eff0); - std::cout << "eff: " << efficiencies[n] << " error " << (TMath::Sqrt(efficiencies[n] + efficiencies[n] / eff0) / eff0) << std::endl; - efficiencies[n] = efficiencies[n] / eff0; + std::cout << "eff: " << efficiencies[n] << " error " + << (TMath::Sqrt(efficiencies[n] + efficiencies[n] / eff0) / eff0) << std::endl; + efficiencies[n] = efficiencies[n] / eff0; } - TCanvas c("", "", 1200, 800); @@ -89,20 +94,20 @@ Int_t REST_Axion_XMMAngleEffCSV(TString pathAndPattern = "./trueWolter/OpticsBen effGraph.SetMarkerColor(kRed); effGraph.SetMarkerStyle(21); effGraph.Draw("AP"); - + effGraph.GetYaxis()->SetLimits(0.0, angleMax); effGraph.GetHistogram()->SetMaximum(1); effGraph.GetHistogram()->SetMinimum(0); TGraph expGraph; /// Add the csv file if given - if (csvFile != ""){ - std::vector<std::vector <Double_t>> expData; - TRestTools::ReadCSVFile(csvFile, expData, 1); // angles at expData[n][0], effArea at expData[n][1] - + if (csvFile != "") { + std::vector<std::vector<Double_t>> expData; + TRestTools::ReadCSVFile(csvFile, expData, 1); // angles at expData[n][0], effArea at expData[n][1] + std::vector<float> anglesExp; std::vector<float> efficienciesExp; Double_t effExp0 = 0; - + for (unsigned int n = 0; n < expData.size(); n++) { if (expData[n][0] < 0.01 && expData[n][0] > 0) effExp0 = expData[n][1]; } @@ -113,7 +118,7 @@ Int_t REST_Axion_XMMAngleEffCSV(TString pathAndPattern = "./trueWolter/OpticsBen expGraph.AddPoint(expData[n][0], expData[n][1] / effExp0); } std::cout << anglesExp[2000] << " " << efficienciesExp[2000] << std::endl; - + expGraph.SetName("expGraph"); expGraph.SetMarkerColor(kBlue); expGraph.SetMarkerStyle(2); diff --git a/pipeline/README.md b/pipeline/README.md index 3f8384df..9fd88710 100644 --- a/pipeline/README.md +++ b/pipeline/README.md @@ -3,4 +3,3 @@ - **clang-format**: It contains scripts used to assure that code fulfills clang-format code format definitions. - **magnegicField**: Tests to validate magnetic field loading class TRestAxionMagneticField. - diff --git a/pipeline/clang-format/clang-format.sh b/pipeline/clang-format/clang-format.sh index 09ad2680..f06fdef5 100755 --- a/pipeline/clang-format/clang-format.sh +++ b/pipeline/clang-format/clang-format.sh @@ -106,4 +106,3 @@ if [ "-" = "$1" ] ; then }"' '"${file}"' done fi - diff --git a/pipeline/clang-format/clangformattest.sh b/pipeline/clang-format/clangformattest.sh index a7fd6a18..dfd25b4c 100755 --- a/pipeline/clang-format/clangformattest.sh +++ b/pipeline/clang-format/clangformattest.sh @@ -53,4 +53,3 @@ fi git reset HEAD --hard exit 1 - diff --git a/pipeline/likelihood/babyIAXO.rml b/pipeline/likelihood/babyIAXO.rml index ad66dadd..ff634b94 100644 --- a/pipeline/likelihood/babyIAXO.rml +++ b/pipeline/likelihood/babyIAXO.rml @@ -1,36 +1,29 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no" ?> - +<?xml version="1.0" encoding="UTF-8" standalone="no"?> <axion> - - <TRestAxionBufferGas name="helium" verboseLevel="warning" > - <gas name="H" density="1g/cm3"/> - </TRestAxionBufferGas> - - <TRestAxionLikelihood name="babyIAXO" > - <parameter name="Bmag" value="1.73T"/> - <parameter name="Rmag" value="35cm"/> - <parameter name="Lmag" value="10m"/> - <parameter name="efficiency" value="0.35*0.7"/> - <parameter name="bckLevel" value="1.e-7"/> - <parameter name="expTimeVacuum" value="1.5*365*12"/> - <!--<parameter name="expTimePerStep" value="1.5*365.*12./50."/>--> - <parameter name="expTimePerStep" value="-1"/> - <parameter name="pressureSteps" value="150"/> - - <!-- Spot in cm2 --> - <parameter name="spotArea" value="0.3"/> - <!-- Helium density in g/cm3 --> - <parameter name="lastStepDensity" value="0.1789e-3"/> - - <parameter name="energyRange" value="(1,8)"/> - - </TRestAxionLikelihood> - - <TRestAxionFieldPropagationProcess name="babyMagnet" value="ON" verboseLevel="info" > - <parameter name="mode" value="plan" /> <!-- plan or distance --> - <parameter name="distance" value="30000 mm" /> - <parameter name="finalNPlan" value="(0,0,1)mm" /> - <parameter name="finalPositionPlan" value="(0,0,10000)mm" /> - </TRestAxionFieldPropagationProcess> + <TRestAxionBufferGas name="helium" verboseLevel="warning"> + <gas name="H" density="1g/cm3"/> + </TRestAxionBufferGas> + <TRestAxionLikelihood name="babyIAXO"> + <parameter name="Bmag" value="1.73T"/> + <parameter name="Rmag" value="35cm"/> + <parameter name="Lmag" value="10m"/> + <parameter name="efficiency" value="0.35*0.7"/> + <parameter name="bckLevel" value="1.e-7"/> + <parameter name="expTimeVacuum" value="1.5*365*12"/> + <!--<parameter name="expTimePerStep" value="1.5*365.*12./50."/>--> + <parameter name="expTimePerStep" value="-1"/> + <parameter name="pressureSteps" value="150"/> + <!-- Spot in cm2 --> + <parameter name="spotArea" value="0.3"/> + <!-- Helium density in g/cm3 --> + <parameter name="lastStepDensity" value="0.1789e-3"/> + <parameter name="energyRange" value="(1,8)"/> + </TRestAxionLikelihood> + <TRestAxionFieldPropagationProcess name="babyMagnet" value="ON" verboseLevel="info"> + <parameter name="mode" value="plan"/> + <!-- plan or distance --> + <parameter name="distance" value="30000 mm"/> + <parameter name="finalNPlan" value="(0,0,1)mm"/> + <parameter name="finalPositionPlan" value="(0,0,10000)mm"/> + </TRestAxionFieldPropagationProcess> </axion> - diff --git a/pipeline/metadata/magneticField/boundary/README.md b/pipeline/metadata/magneticField/boundary/README.md index 89626993..478793ed 100755 --- a/pipeline/metadata/magneticField/boundary/README.md +++ b/pipeline/metadata/magneticField/boundary/README.md @@ -1,7 +1,7 @@ ### Description -The scripts in this directory are used to test the implementation of the `TRestAxionMagneticField::GetVolumeBoundaries` and `TRestAxionMagneticField::GetFieldBoundaries` methods. These methods are used to find the coordinates of the points where the trajectory of the particle intersects the boundary planes of magnetic field regions through which the particle passes. In general, the magnetic field volume can consist of several regions where each region is defined in a separate `<addMagnetVolume...>` line in the configuration file. Also, in some (or all) regions the magnetic field can be zero in the outer parts of the region, i.e., near the borders. In this case, it is possible that the particle, right after entering the region, passes through the part where `B=0` before traversing the section where `B>0`. Also, just before exiting the region, the particle can again pass through the region where `B=0`. Therefore, two methods are used to find the boundary points of the particle trajectory in each region. The `TRestAxionMagneticField::GetVolumeBoundaries` method searches for the points where the trajectory intersects the boundary planes of the region. If two such points (entry point and exit point) are found, their coordinates are returned. The `TRestAxionMagneticField::GetFieldBoundaries` method checks if the particle, right after entering the region, first passes through the section of the region where `B=0` and determines the coordinates of the first point where `B>0` on the particle trajectory after entering the region. In a similar manner, the method checks if just before exiting the region the particle passes through the section where `B=0` and determines the last point on the trajectory where `B>0` before exiting the region. Thus these two points are actually the boundary points of one segment of the particle trajectory along which `B>0`. +The scripts in this directory are used to test the implementation of the `TRestAxionMagneticField::GetVolumeBoundaries` and `TRestAxionMagneticField::GetFieldBoundaries` methods. These methods are used to find the coordinates of the points where the trajectory of the particle intersects the boundary planes of magnetic field regions through which the particle passes. In general, the magnetic field volume can consist of several regions where each region is defined in a separate `<addMagnetVolume...>` line in the configuration file. Also, in some (or all) regions the magnetic field can be zero in the outer parts of the region, i.e., near the borders. In this case, it is possible that the particle, right after entering the region, passes through the part where `B=0` before traversing the section where `B>0`. Also, just before exiting the region, the particle can again pass through the region where `B=0`. Therefore, two methods are used to find the boundary points of the particle trajectory in each region. The `TRestAxionMagneticField::GetVolumeBoundaries` method searches for the points where the trajectory intersects the boundary planes of the region. If two such points (entry point and exit point) are found, their coordinates are returned. The `TRestAxionMagneticField::GetFieldBoundaries` method checks if the particle, right after entering the region, first passes through the section of the region where `B=0` and determines the coordinates of the first point where `B>0` on the particle trajectory after entering the region. In a similar manner, the method checks if just before exiting the region the particle passes through the section where `B=0` and determines the last point on the trajectory where `B>0` before exiting the region. Thus these two points are actually the boundary points of one segment of the particle trajectory along which `B>0`. To perform the test just execute the command `restRoot -b -q Boundaries_test_interactive.C`. @@ -42,14 +42,14 @@ However, since the magnetic field is given on a discrete set of grid points sepa ``` as can be seen in the `Bx_vs_x_y.jpg` and `By_vs_x_y_SURF3.jpg` plots. -The reason is that the `TRestAxionMagneticField::GetMagneticField` method (which returns `Bx`, `By` and `Bz` values at the point specified as the input parameter) uses trilinear interpolation to determine the magnetic field values at the given point. Therefore, for the points with `x` coordinate, e.g., +The reason is that the `TRestAxionMagneticField::GetMagneticField` method (which returns `Bx`, `By` and `Bz` values at the point specified as the input parameter) uses trilinear interpolation to determine the magnetic field values at the given point. Therefore, for the points with `x` coordinate, e.g., -50 <= x <= -40, the value of `Bx` will linearly increase from `Bx` = 0 (which is the value at `x` = -50 grid point) to `Bx` = 4 at `x` = -40 grid point. ### Description of files in this directory -1) **create_magnetic_field.C** - a restRoot script that produces the magnetic field map described above and stores it in the file `B_Field_boundary_test.dat`. +1) **create_magnetic_field.C** - a restRoot script that produces the magnetic field map described above and stores it in the file `B_Field_boundary_test.dat`. -2) **B_Field_boundary_test.dat**: this file contains the magnetic field map produced by the `create_magnetic_field.C` script. +2) **B_Field_boundary_test.dat**: this file contains the magnetic field map produced by the `create_magnetic_field.C` script. Each row in the file contains data for one grid point. First three columns contain `x`, `y` and `z` coordinate of the grid point, respectively, while other three columns are `Bx`, `By` and `Bz` values for the corresponding grid point. diff --git a/pipeline/metadata/magneticField/magneticField.py b/pipeline/metadata/magneticField/magneticField.py index 199d4436..b29298fe 100755 --- a/pipeline/metadata/magneticField/magneticField.py +++ b/pipeline/metadata/magneticField/magneticField.py @@ -14,72 +14,74 @@ babyField = ROOT.TRestAxionMagneticField("fields.rml", "babyIAXO") if babyField.GetError(): - print ( babyField.GetErrorMessage() ) - print ( "\nMagnetic field initialization failed! Exit code : 101" ) + print(babyField.GetErrorMessage()) + print("\nMagnetic field initialization failed! Exit code : 101") exit(101) -p1 = ROOT.TVector3(0,0,0) -p2 = ROOT.TVector3(0,0,-2500) -p3 = ROOT.TVector3(0,0,2500) -p4 = ROOT.TVector3(0,0,4500) +p1 = ROOT.TVector3(0, 0, 0) +p2 = ROOT.TVector3(0, 0, -2500) +p3 = ROOT.TVector3(0, 0, 2500) +p4 = ROOT.TVector3(0, 0, 4500) -d1 = ROOT.TVector3(0,0,1) -d2 = ROOT.TVector3(1,1,1) -d3 = ROOT.TVector3(0.5,0.5,1) -d4 = ROOT.TVector3(1,1,0.5) +d1 = ROOT.TVector3(0, 0, 1) +d2 = ROOT.TVector3(1, 1, 1) +d3 = ROOT.TVector3(0.5, 0.5, 1) +d4 = ROOT.TVector3(1, 1, 0.5) -b1 = int( 1000 * babyField.GetTransversalComponent( p1, d1)) -b2 = int( 1000 * babyField.GetTransversalComponent( p2, d1)) -b3 = int( 1000 * babyField.GetTransversalComponent( p3, d1)) -b4 = int( 1000 * babyField.GetTransversalComponent( p4, d1)) +b1 = int(1000 * babyField.GetTransversalComponent(p1, d1)) +b2 = int(1000 * babyField.GetTransversalComponent(p2, d1)) +b3 = int(1000 * babyField.GetTransversalComponent(p3, d1)) +b4 = int(1000 * babyField.GetTransversalComponent(p4, d1)) -startFrom = ROOT.TVector3(-300,300,-2500) -goTo = ROOT.TVector3(300,-300,2500) -b5 = int( 1000. * babyField.GetTransversalFieldAverage( startFrom, goTo, 20, 500) ) +startFrom = ROOT.TVector3(-300, 300, -2500) +goTo = ROOT.TVector3(300, -300, 2500) +b5 = int(1000.0 * babyField.GetTransversalFieldAverage(startFrom, goTo, 20, 500)) -print ( "\nEvaluating transversal field average Bykovskiy_201906.dat centered at (0,0,0)" ) -if( b5 != 1548 ): - print ("\nEvaluation of field failed! Exit code : 302") +print("\nEvaluating transversal field average Bykovskiy_201906.dat centered at (0,0,0)") +if b5 != 1548: + print("\nEvaluation of field failed! Exit code : 302") exit(302) -print ( "[\033[92m OK \x1b[0m]" ) +print("[\033[92m OK \x1b[0m]") -print ( "\nEvaluating field volume Bykovskiy_201906.dat centered at (0,0,0)" ) -if( b1 != 2007 or b2 != 1998 or b3 != 1998 or b4 != 1119 ): - print ("\nEvaluation of field failed! Exit code : 102") +print("\nEvaluating field volume Bykovskiy_201906.dat centered at (0,0,0)") +if b1 != 2007 or b2 != 1998 or b3 != 1998 or b4 != 1119: + print("\nEvaluation of field failed! Exit code : 102") exit(102) -print ( "[\033[92m OK \x1b[0m]" ) +print("[\033[92m OK \x1b[0m]") castField = ROOT.TRestAxionMagneticField("fields.rml", "CAST") if castField.GetError(): - print ( castField.GetErrorMessage() ) - print ( "\nMagnetic field initialization failed! Exit code : 201" ) + print(castField.GetErrorMessage()) + print("\nMagnetic field initialization failed! Exit code : 201") exit(201) -b1 = int( 1000 * castField.GetTransversalComponent( p1, d1)) -b2 = int( 1000 * castField.GetTransversalComponent( p2, d2)) -b3 = int( 1000 * castField.GetTransversalComponent( p3, d3)) -b4 = int( 1000 * castField.GetTransversalComponent( p4, d4)) +b1 = int(1000 * castField.GetTransversalComponent(p1, d1)) +b2 = int(1000 * castField.GetTransversalComponent(p2, d2)) +b3 = int(1000 * castField.GetTransversalComponent(p3, d3)) +b4 = int(1000 * castField.GetTransversalComponent(p4, d4)) -print ("\nEvaluating CAST magnet constant field defintion centered at (0,0,0)" ) -if( b1 != 8900 or b2 != 7266 or b3 != 8124 or b4 != 6633 ): - print ("\nEvaluation of field failed! Exit code : 202") +print("\nEvaluating CAST magnet constant field defintion centered at (0,0,0)") +if b1 != 8900 or b2 != 7266 or b3 != 8124 or b4 != 6633: + print("\nEvaluation of field failed! Exit code : 202") exit(202) -print ("[\033[92m OK \x1b[0m]") +print("[\033[92m OK \x1b[0m]") -boundaries = castField.GetFieldBoundaries( ROOT.TVector3(12,34,0), ROOT.TVector3(0,-1,0) ) +boundaries = castField.GetFieldBoundaries( + ROOT.TVector3(12, 34, 0), ROOT.TVector3(0, -1, 0) +) -yMax = int( 1000 * boundaries[0].Y() ) -yMin = int( 1000 * boundaries[1].Y() ) +yMax = int(1000 * boundaries[0].Y()) +yMin = int(1000 * boundaries[1].Y()) -print ("\nEvaluating CAST cylindrical volume boundaries") -if( yMax != 17839 or yMin != -17839 ): - print ("\nEvaluation of field failed! Exit code : 203") +print("\nEvaluating CAST cylindrical volume boundaries") +if yMax != 17839 or yMin != -17839: + print("\nEvaluation of field failed! Exit code : 203") exit(203) -print ("[\033[92m OK \x1b[0m]") +print("[\033[92m OK \x1b[0m]") -print ("") -print ("All tests passed!") +print("") +print("All tests passed!") exit(0) diff --git a/pipeline/metadata/magneticField/trilinear/GetMagneticField_test_output.txt b/pipeline/metadata/magneticField/trilinear/GetMagneticField_test_output.txt index dde422a0..f021eeb6 100644 --- a/pipeline/metadata/magneticField/trilinear/GetMagneticField_test_output.txt +++ b/pipeline/metadata/magneticField/trilinear/GetMagneticField_test_output.txt @@ -121,4 +121,3 @@ Difference = (11327.2, -15138.5, 5481.4) x = 449.9 y = 1150.1 z = 13001.0 Bx = 0.0 By = 0.0 Bz = 0.0 True values: TBx = 7551.3 TBy = -16053.3 TBz = 5001.0 Difference = (7551.3, -16053.3, 5001.0) - diff --git a/pipeline/metadata/magneticField/trilinear/README.md b/pipeline/metadata/magneticField/trilinear/README.md index 150b5883..dac15bdb 100644 --- a/pipeline/metadata/magneticField/trilinear/README.md +++ b/pipeline/metadata/magneticField/trilinear/README.md @@ -19,19 +19,18 @@ By = 8x +5y -3z Bz = -4x -4y +z ``` -2) **Magnetic_field.dat**: this file contains the magnetic field map produced by the `create_magnetic_field.cxx` script. +2) **Magnetic_field.dat**: this file contains the magnetic field map produced by the `create_magnetic_field.cxx` script. Each row in the file contains data for one grid point. First three columns contain `x`, `y` and `z` coordinate of the grid point, respectively, while other three columns are `Bx`, `By` and `Bz` values for the corresponding grid point. -3) **GetMagneticField_test.cxx**: is a restRoot script which tests the `TRestAxionMagneticField::GetMagneticField` method. -The test is performed by comparing the values of the magnetic field components obtained by the `GetMagneticField` method -with the expected values, i.e., values calculated by the equations for `Bx`, `By` and `Bz` given above. -This comparison is performed on a set of 31 points. -The `TVector3` "offset" variable represents the offset of the magnetic field volume with the respect to the laboratory frame. -The output of the script is shown on screen and written in the output file `GetMagneticField_test_output.txt`. +3) **GetMagneticField_test.cxx**: is a restRoot script which tests the `TRestAxionMagneticField::GetMagneticField` method. +The test is performed by comparing the values of the magnetic field components obtained by the `GetMagneticField` method +with the expected values, i.e., values calculated by the equations for `Bx`, `By` and `Bz` given above. +This comparison is performed on a set of 31 points. +The `TVector3` "offset" variable represents the offset of the magnetic field volume with the respect to the laboratory frame. +The output of the script is shown on screen and written in the output file `GetMagneticField_test_output.txt`. -4) **my_metadata.rml** is a config file used to load the magnetic field map by the `GetMagneticField_test.cxx` script. -The parameters in this file are described at the beginning of the `TRestAxionMagneticField.cxx` file in `RestAxionLib/src` directory. -Note that the `position` parameter represents the offset of the magnetic field volume with the respect to the laboratory frame +4) **my_metadata.rml** is a config file used to load the magnetic field map by the `GetMagneticField_test.cxx` script. +The parameters in this file are described at the beginning of the `TRestAxionMagneticField.cxx` file in `RestAxionLib/src` directory. +Note that the `position` parameter represents the offset of the magnetic field volume with the respect to the laboratory frame and it should be equal to the value of the `offset` variable in the `GetMagneticField_test.cxx` script. - diff --git a/pipeline/metadata/optics/basic.py b/pipeline/metadata/optics/basic.py index ff17bc7d..b6098d37 100755 --- a/pipeline/metadata/optics/basic.py +++ b/pipeline/metadata/optics/basic.py @@ -7,23 +7,38 @@ outfname = "opticsBasic.png" from ROOT import ( - TChain, TFile, TTree, TCanvas, TPad, TRandom3, - TH1D, TH2D, TH3D, - TProfile, TProfile2D, TProfile3D, - TGraph, TGraph2D, - TF1, TF2, TF3, TFormula, - TLorentzVector, TVector3) + TChain, + TFile, + TTree, + TCanvas, + TPad, + TRandom3, + TH1D, + TH2D, + TH3D, + TProfile, + TProfile2D, + TProfile3D, + TGraph, + TGraph2D, + TF1, + TF2, + TF3, + TFormula, + TLorentzVector, + TVector3, +) ROOT.gSystem.Load("libRestFramework.so") ROOT.gSystem.Load("libRestAxion.so") ### Creating a canvas and pad for drawing -c1 = TCanvas( 'c1', 'My canvas', 800,700 ) -c1.GetFrame().SetBorderSize( 6 ) -c1.GetFrame().SetBorderMode( -1 ) +c1 = TCanvas("c1", "My canvas", 800, 700) +c1.GetFrame().SetBorderSize(6) +c1.GetFrame().SetBorderMode(-1) -pad1 = TPad("pad1","This is pad1",0.01,0.02,0.99,0.97); -pad1.Divide(2,2) +pad1 = TPad("pad1", "This is pad1", 0.01, 0.02, 0.99, 0.97) +pad1.Divide(2, 2) pad1.Draw() totalSamples = 10000 @@ -33,16 +48,16 @@ spiderOptics = ROOT.TRestAxionOptics("optics.rml", "basic_spider") rings = basicOptics.GetNumberOfRings() -print( "Number of rings (no-spider): " + str(rings) ) +print("Number of rings (no-spider): " + str(rings)) maxRingRadius = basicOptics.GetMaxRingRadius() -print( "Max ring radius (no-spider): " + str(maxRingRadius) ) +print("Max ring radius (no-spider): " + str(maxRingRadius)) rings_sp = spiderOptics.GetNumberOfRings() -print( "Number of rings (spider): " + str(rings_sp) ) +print("Number of rings (spider): " + str(rings_sp)) maxRingRadius_sp = spiderOptics.GetMaxRingRadius() -print( "Max ring radius (spider): " + str(maxRingRadius_sp) ) +print("Max ring radius (spider): " + str(maxRingRadius_sp)) # OP: Optics plane GP: Generator plane OPS: Optics plane spider graphsOP = [] @@ -50,15 +65,15 @@ gr = ROOT.TGraph() gr.SetMarkerStyle(20) gr.SetMarkerSize(0.5) - gr.SetMarkerColor(38+n) + gr.SetMarkerColor(38 + n) gr.SetTitle("Optics plane (no-Spider)") gr.GetXaxis().SetTitle("X [mm]") - gr.GetXaxis().SetTitleSize(0.05); - gr.GetXaxis().SetLabelSize(0.05); + gr.GetXaxis().SetTitleSize(0.05) + gr.GetXaxis().SetLabelSize(0.05) gr.GetYaxis().SetTitle("Y [mm]") gr.GetYaxis().SetTitleOffset(1) - gr.GetYaxis().SetTitleSize(0.05); - gr.GetYaxis().SetLabelSize(0.05); + gr.GetYaxis().SetTitleSize(0.05) + gr.GetYaxis().SetLabelSize(0.05) graphsOP.append(gr) graphsGP = [] @@ -66,15 +81,15 @@ gr = ROOT.TGraph() gr.SetMarkerStyle(20) gr.SetMarkerSize(0.5) - gr.SetMarkerColor(38+n) + gr.SetMarkerColor(38 + n) gr.SetTitle("Generator plane (no-Spider)") gr.GetXaxis().SetTitle("X [mm]") - gr.GetXaxis().SetTitleSize(0.05); - gr.GetXaxis().SetLabelSize(0.05); + gr.GetXaxis().SetTitleSize(0.05) + gr.GetXaxis().SetLabelSize(0.05) gr.GetYaxis().SetTitle("Y [mm]") gr.GetYaxis().SetTitleOffset(1) - gr.GetYaxis().SetTitleSize(0.05); - gr.GetYaxis().SetLabelSize(0.05); + gr.GetYaxis().SetTitleSize(0.05) + gr.GetYaxis().SetLabelSize(0.05) graphsGP.append(gr) graphsOPS = [] @@ -82,15 +97,15 @@ gr = ROOT.TGraph() gr.SetMarkerStyle(20) gr.SetMarkerSize(0.5) - gr.SetMarkerColor(38+n) + gr.SetMarkerColor(38 + n) gr.SetTitle("Optics plane (Spider)") gr.GetXaxis().SetTitle("X [mm]") - gr.GetXaxis().SetTitleSize(0.05); - gr.GetXaxis().SetLabelSize(0.05); + gr.GetXaxis().SetTitleSize(0.05) + gr.GetXaxis().SetLabelSize(0.05) gr.GetYaxis().SetTitle("Y [mm]") gr.GetYaxis().SetTitleOffset(1) - gr.GetYaxis().SetTitleSize(0.05); - gr.GetYaxis().SetLabelSize(0.05); + gr.GetYaxis().SetTitleSize(0.05) + gr.GetYaxis().SetLabelSize(0.05) graphsOPS.append(gr) graphsGPS = [] @@ -98,82 +113,84 @@ gr = ROOT.TGraph() gr.SetMarkerStyle(20) gr.SetMarkerSize(0.5) - gr.SetMarkerColor(38+n) + gr.SetMarkerColor(38 + n) gr.SetTitle("Generator plane (Spider)") gr.GetXaxis().SetTitle("X [mm]") - gr.GetXaxis().SetTitleSize(0.05); - gr.GetXaxis().SetLabelSize(0.05); + gr.GetXaxis().SetTitleSize(0.05) + gr.GetXaxis().SetLabelSize(0.05) gr.GetYaxis().SetTitle("Y [mm]") gr.GetYaxis().SetTitleOffset(1) - gr.GetYaxis().SetTitleSize(0.05); - gr.GetYaxis().SetLabelSize(0.05); + gr.GetYaxis().SetTitleSize(0.05) + gr.GetYaxis().SetLabelSize(0.05) graphsGPS.append(gr) rnd = TRandom3(0) for n in range(totalSamples): - x = (10+maxRingRadius) * (rnd.Rndm() - 0.5) * 2 - y = (10+maxRingRadius) * (rnd.Rndm() - 0.5) * 2 + x = (10 + maxRingRadius) * (rnd.Rndm() - 0.5) * 2 + y = (10 + maxRingRadius) * (rnd.Rndm() - 0.5) * 2 - pos = TVector3(x,y,0) - direction = TVector3((rnd.Rndm() - 0.5)*0.01, (rnd.Rndm() - 0.5)*0.01, 1 ) + pos = TVector3(x, y, 0) + direction = TVector3((rnd.Rndm() - 0.5) * 0.01, (rnd.Rndm() - 0.5) * 0.01, 1) - posEntrance = basicOptics.GetPositionAtEntrance( pos, direction ) + posEntrance = basicOptics.GetPositionAtEntrance(pos, direction) - ring = basicOptics.GetEntranceRing( pos, direction ) - if( ring >= 0 ): - graphsGP[ring].SetPoint(graphsGP[ring].GetN(), x, y ) - graphsOP[ring].SetPoint(graphsOP[ring].GetN(), posEntrance.X(), posEntrance.Y() ) + ring = basicOptics.GetEntranceRing(pos, direction) + if ring >= 0: + graphsGP[ring].SetPoint(graphsGP[ring].GetN(), x, y) + graphsOP[ring].SetPoint(graphsOP[ring].GetN(), posEntrance.X(), posEntrance.Y()) pad1.cd(2) -graphsOP[0].GetXaxis().SetLimits(-maxRingRadius-20,maxRingRadius+20); -graphsOP[0].GetHistogram().SetMaximum(maxRingRadius+20); -graphsOP[0].GetHistogram().SetMinimum(-maxRingRadius-20); +graphsOP[0].GetXaxis().SetLimits(-maxRingRadius - 20, maxRingRadius + 20) +graphsOP[0].GetHistogram().SetMaximum(maxRingRadius + 20) +graphsOP[0].GetHistogram().SetMinimum(-maxRingRadius - 20) graphsOP[0].Draw("AP") -for n in range(1,rings): +for n in range(1, rings): graphsOP[n].Draw("P") pad1.cd(1) -graphsGP[0].GetXaxis().SetLimits(-maxRingRadius-20,maxRingRadius+20); -graphsGP[0].GetHistogram().SetMaximum(maxRingRadius+20); -graphsGP[0].GetHistogram().SetMinimum(-maxRingRadius-20); +graphsGP[0].GetXaxis().SetLimits(-maxRingRadius - 20, maxRingRadius + 20) +graphsGP[0].GetHistogram().SetMaximum(maxRingRadius + 20) +graphsGP[0].GetHistogram().SetMinimum(-maxRingRadius - 20) graphsGP[0].Draw("AP") -for n in range(1,rings): +for n in range(1, rings): graphsGP[n].Draw("P") for n in range(totalSamples): - x = (10+maxRingRadius) * (rnd.Rndm() - 0.5) * 2 - y = (10+maxRingRadius) * (rnd.Rndm() - 0.5) * 2 + x = (10 + maxRingRadius) * (rnd.Rndm() - 0.5) * 2 + y = (10 + maxRingRadius) * (rnd.Rndm() - 0.5) * 2 - pos = TVector3(x,y,0) - direction = TVector3((rnd.Rndm() - 0.5)*0.01, (rnd.Rndm() - 0.5)*0.01, 1 ) + pos = TVector3(x, y, 0) + direction = TVector3((rnd.Rndm() - 0.5) * 0.01, (rnd.Rndm() - 0.5) * 0.01, 1) - posEntrance = spiderOptics.GetPositionAtEntrance( pos, direction ) + posEntrance = spiderOptics.GetPositionAtEntrance(pos, direction) - ring = spiderOptics.GetEntranceRing( pos, direction ) - if( ring >= 0 ): - graphsGPS[ring].SetPoint(graphsGPS[ring].GetN(), x, y ) - graphsOPS[ring].SetPoint(graphsOPS[ring].GetN(), posEntrance.X(), posEntrance.Y() ) + ring = spiderOptics.GetEntranceRing(pos, direction) + if ring >= 0: + graphsGPS[ring].SetPoint(graphsGPS[ring].GetN(), x, y) + graphsOPS[ring].SetPoint( + graphsOPS[ring].GetN(), posEntrance.X(), posEntrance.Y() + ) pad1.cd(4) -graphsOPS[0].GetXaxis().SetLimits(-maxRingRadius_sp-20,maxRingRadius_sp+20); -graphsOPS[0].GetHistogram().SetMaximum(maxRingRadius_sp+20); -graphsOPS[0].GetHistogram().SetMinimum(-maxRingRadius_sp-20); +graphsOPS[0].GetXaxis().SetLimits(-maxRingRadius_sp - 20, maxRingRadius_sp + 20) +graphsOPS[0].GetHistogram().SetMaximum(maxRingRadius_sp + 20) +graphsOPS[0].GetHistogram().SetMinimum(-maxRingRadius_sp - 20) graphsOPS[0].Draw("AP") -for n in range(1,rings): +for n in range(1, rings): graphsOPS[n].Draw("P") pad1.cd(3) -graphsGPS[0].GetXaxis().SetLimits(-maxRingRadius_sp-20,maxRingRadius_sp+20); -graphsGPS[0].GetHistogram().SetMaximum(maxRingRadius_sp+20); -graphsGPS[0].GetHistogram().SetMinimum(-maxRingRadius_sp-20); +graphsGPS[0].GetXaxis().SetLimits(-maxRingRadius_sp - 20, maxRingRadius_sp + 20) +graphsGPS[0].GetHistogram().SetMaximum(maxRingRadius_sp + 20) +graphsGPS[0].GetHistogram().SetMinimum(-maxRingRadius_sp - 20) graphsGPS[0].Draw("AP") -for n in range(1,rings): +for n in range(1, rings): graphsGPS[n].Draw("P") c1.Print(outfname) -print ("All tests passed! [\033[92m OK \x1b[0m]") +print("All tests passed! [\033[92m OK \x1b[0m]") -print ("") +print("") exit(0) diff --git a/pipeline/metadata/optics/mcpl.py b/pipeline/metadata/optics/mcpl.py index 36a96409..a3ee6ed9 100755 --- a/pipeline/metadata/optics/mcpl.py +++ b/pipeline/metadata/optics/mcpl.py @@ -10,14 +10,14 @@ ## MCPL class is not implemented. We just check that it is properly prototyped -#rings = mcplOptics_1.GetNumberOfRings() -#print( "Number of rings: " + str(rings) ) -#if( rings != 5 ): +# rings = mcplOptics_1.GetNumberOfRings() +# print( "Number of rings: " + str(rings) ) +# if( rings != 5 ): # print( "\nError! Number of rings is not 5!" ) # exit(1) -#print (" [\033[92m OK \x1b[0m]") +# print (" [\033[92m OK \x1b[0m]") # -print ("All tests passed!") +print("All tests passed!") exit(0) diff --git a/pipeline/metadata/optics/mirrors.py b/pipeline/metadata/optics/mirrors.py index 11c7bac4..1273eb6e 100755 --- a/pipeline/metadata/optics/mirrors.py +++ b/pipeline/metadata/optics/mirrors.py @@ -5,83 +5,83 @@ ROOT.gSystem.Load("libRestFramework.so") ROOT.gSystem.Load("libRestAxion.so") -print( "Loading default dummy mirror" ) +print("Loading default dummy mirror") mirror = ROOT.TRestAxionOpticsMirror("mirrors.rml", "default") mirror.PrintMetadata() -ref1 = mirror.GetReflectivity( 0.25, 1 ) -ref2 = mirror.GetReflectivity( 0.5, 3 ) -ref3 = mirror.GetReflectivity( 0.75, 5 ) -ref4 = mirror.GetReflectivity( 1., 7 ) +ref1 = mirror.GetReflectivity(0.25, 1) +ref2 = mirror.GetReflectivity(0.5, 3) +ref3 = mirror.GetReflectivity(0.75, 5) +ref4 = mirror.GetReflectivity(1.0, 7) -ref1int = int(10000. * ref1 ) -ref2int = int(10000. * ref2 ) -ref3int = int(10000. * ref3 ) -ref4int = int(10000. * ref4 ) +ref1int = int(10000.0 * ref1) +ref2int = int(10000.0 * ref2) +ref3int = int(10000.0 * ref3) +ref4int = int(10000.0 * ref4) -print( "Reflectivity: " + str(ref1int), end ="" ) -if( ref1int != 9721 ): - print( "\nError! Reflectivity should be 0.9721!" ) +print("Reflectivity: " + str(ref1int), end="") +if ref1int != 9721: + print("\nError! Reflectivity should be 0.9721!") exit(1) -print (" [\033[92m OK \x1b[0m]") +print(" [\033[92m OK \x1b[0m]") -print( "Reflectivity: " + str(ref2int), end ="" ) -if( ref2int != 9563 ): - print( "\nError! Reflectivity should be 0.9563!" ) +print("Reflectivity: " + str(ref2int), end="") +if ref2int != 9563: + print("\nError! Reflectivity should be 0.9563!") exit(1) -print (" [\033[92m OK \x1b[0m]") +print(" [\033[92m OK \x1b[0m]") -print( "Reflectivity: " + str(ref3int), end ="" ) -if( ref3int != 34 ): - print( "\nError! Reflectivity should be 0.0037!" ) +print("Reflectivity: " + str(ref3int), end="") +if ref3int != 34: + print("\nError! Reflectivity should be 0.0037!") exit(1) -print (" [\033[92m OK \x1b[0m]") +print(" [\033[92m OK \x1b[0m]") -print( "Reflectivity: " + str(ref4int), end ="" ) -if( ref4int != 2 ): - print( "\nError! Reflectivity should be 0.0005!" ) +print("Reflectivity: " + str(ref4int), end="") +if ref4int != 2: + print("\nError! Reflectivity should be 0.0005!") exit(1) -print (" [\033[92m OK \x1b[0m]") +print(" [\033[92m OK \x1b[0m]") -print( "Loading XMM mirror" ) +print("Loading XMM mirror") mirror = ROOT.TRestAxionOpticsMirror("mirrors.rml", "XMM") mirror.PrintMetadata() -ref1 = mirror.GetReflectivity( 0.25, 1 ) -ref2 = mirror.GetReflectivity( 0.5, 3 ) -ref3 = mirror.GetReflectivity( 0.75, 5 ) -ref4 = mirror.GetReflectivity( 1., 7 ) +ref1 = mirror.GetReflectivity(0.25, 1) +ref2 = mirror.GetReflectivity(0.5, 3) +ref3 = mirror.GetReflectivity(0.75, 5) +ref4 = mirror.GetReflectivity(1.0, 7) -ref1int = int(10000. * ref1 ) -ref2int = int(10000. * ref2 ) -ref3int = int(10000. * ref3 ) -ref4int = int(10000. * ref4 ) +ref1int = int(10000.0 * ref1) +ref2int = int(10000.0 * ref2) +ref3int = int(10000.0 * ref3) +ref4int = int(10000.0 * ref4) -print( "Reflectivity: " + str(ref1int), end ="" ) -if( ref1int != 9428 ): - print( "\nError! Reflectivity should be 0.9429!" ) +print("Reflectivity: " + str(ref1int), end="") +if ref1int != 9428: + print("\nError! Reflectivity should be 0.9429!") exit(1) -print (" [\033[92m OK \x1b[0m]") +print(" [\033[92m OK \x1b[0m]") -print( "Reflectivity: " + str(ref2int), end ="" ) -if( ref2int != 7099 ): - print( "\nError! Reflectivity should be 0.7090!" ) +print("Reflectivity: " + str(ref2int), end="") +if ref2int != 7099: + print("\nError! Reflectivity should be 0.7090!") exit(1) -print (" [\033[92m OK \x1b[0m]") +print(" [\033[92m OK \x1b[0m]") -print( "Reflectivity: " + str(ref3int), end ="" ) -if( ref3int != 5357 ): - print( "\nError! Reflectivity should be 0.5357!" ) +print("Reflectivity: " + str(ref3int), end="") +if ref3int != 5357: + print("\nError! Reflectivity should be 0.5357!") exit(1) -print (" [\033[92m OK \x1b[0m]") +print(" [\033[92m OK \x1b[0m]") -print( "Reflectivity: " + str(ref4int), end ="" ) -if( ref4int != 145 ): - print( "\nError! Reflectivity should be 0.0145!" ) +print("Reflectivity: " + str(ref4int), end="") +if ref4int != 145: + print("\nError! Reflectivity should be 0.0145!") exit(1) -print (" [\033[92m OK \x1b[0m]") +print(" [\033[92m OK \x1b[0m]") -print ("All tests passed!") +print("All tests passed!") exit(0) diff --git a/pipeline/metadata/solarFlux/compare.py b/pipeline/metadata/solarFlux/compare.py index 6b1d45b8..aac091f3 100755 --- a/pipeline/metadata/solarFlux/compare.py +++ b/pipeline/metadata/solarFlux/compare.py @@ -7,97 +7,112 @@ import math import ROOT from ROOT import ( - TChain, TFile, TTree, TCanvas, TPad, TRandom3, - TH1D, TH2D, TH3D, - TProfile, TProfile2D, TProfile3D, - TGraph, TGraph2D, - TF1, TF2, TF3, TFormula, - TLorentzVector, TVector3) + TChain, + TFile, + TTree, + TCanvas, + TPad, + TRandom3, + TH1D, + TH2D, + TH3D, + TProfile, + TProfile2D, + TProfile3D, + TGraph, + TGraph2D, + TF1, + TF2, + TF3, + TFormula, + TLorentzVector, + TVector3, +) ROOT.gSystem.Load("libRestFramework.so") ROOT.gSystem.Load("libRestAxion.so") -c1 = TCanvas( 'c1', 'My canvas', 1200,600 ) -c1.GetFrame().SetBorderSize( 6 ) -c1.GetFrame().SetBorderMode( -1 ) +c1 = TCanvas("c1", "My canvas", 1200, 600) +c1.GetFrame().SetBorderSize(6) +c1.GetFrame().SetBorderMode(-1) -pad1 = TPad("pad1","This is pad1",0.01,0.02,0.99,0.97); -pad1.Divide(2,1) +pad1 = TPad("pad1", "This is pad1", 0.01, 0.02, 0.99, 0.97) +pad1.Divide(2, 1) pad1.Draw() primakoffLH = ROOT.TRestAxionSolarFlux("fluxes.rml", "LennertHoofPrimakoff") primakoffG = ROOT.TRestAxionSolarFlux("fluxes.rml", "Gianotti") if primakoffLH.GetError(): - print ( primakoffLH.GetErrorMessage() ) - print ( "\nSolar flux initialization failed! Exit code : 101" ) + print(primakoffLH.GetErrorMessage()) + print("\nSolar flux initialization failed! Exit code : 101") exit(101) -LH_spt = TH2D("LennertHoof_2D", "Energy versus solar radius", 200, 0, 20, 100, 0, 1 ) +LH_spt = TH2D("LennertHoof_2D", "Energy versus solar radius", 200, 0, 20, 100, 0, 1) for x in range(totalSamples): x = primakoffLH.GetRandomEnergyAndRadius() - LH_spt.Fill( x[0], x[1] ) + LH_spt.Fill(x[0], x[1]) -G_spt = TH2D("Gianotti_2D", "Energy versus solar radius", 200, 0, 20, 100, 0, 1 ) +G_spt = TH2D("Gianotti_2D", "Energy versus solar radius", 200, 0, 20, 100, 0, 1) for x in range(totalSamples): x = primakoffG.GetRandomEnergyAndRadius() - G_spt.Fill( x[0], x[1] ) + G_spt.Fill(x[0], x[1]) pad1.cd(1) enSpt_G = G_spt.ProjectionX() -enSpt_G.Scale( primakoffG.GetTotalFlux()/100. ) # 100eV binsize +enSpt_G.Scale(primakoffG.GetTotalFlux() / 100.0) # 100eV binsize enSpt_G.SetTitle("Energy spectrum") -enSpt_G.GetYaxis().SetTitleSize(0.05); +enSpt_G.GetYaxis().SetTitleSize(0.05) enSpt_G.SetStats(0) enSpt_G.GetXaxis().SetTitle("Energy [keV]") -enSpt_G.GetXaxis().SetTitleSize(0.05); -enSpt_G.GetXaxis().SetLabelSize(0.05); +enSpt_G.GetXaxis().SetTitleSize(0.05) +enSpt_G.GetXaxis().SetLabelSize(0.05) enSpt_G.GetYaxis().SetTitle("Flux [cm-2 s-1 keV-1]") -enSpt_G.GetYaxis().SetTitleSize(0.05); -enSpt_G.GetYaxis().SetLabelSize(0.05); +enSpt_G.GetYaxis().SetTitleSize(0.05) +enSpt_G.GetYaxis().SetLabelSize(0.05) enSpt_G.SetFillStyle(4050) -enSpt_G.SetFillColorAlpha(ROOT.kBlue, 0.1); -enSpt_G.SetLineColor(ROOT.kBlue+2) +enSpt_G.SetFillColorAlpha(ROOT.kBlue, 0.1) +enSpt_G.SetLineColor(ROOT.kBlue + 2) enSpt_G.Draw("hist") enSpt_LH = LH_spt.ProjectionX() -enSpt_LH.Scale( primakoffLH.GetTotalFlux()/100. ) # 100eV binsize +enSpt_LH.Scale(primakoffLH.GetTotalFlux() / 100.0) # 100eV binsize enSpt_LH.SetFillStyle(4050) -enSpt_LH.SetFillColorAlpha(ROOT.kOrange, 0.1); -enSpt_LH.SetLineColor(ROOT.kOrange+3) +enSpt_LH.SetFillColorAlpha(ROOT.kOrange, 0.1) +enSpt_LH.SetLineColor(ROOT.kOrange + 3) enSpt_LH.Draw("hist SAME") -legend = ROOT.TLegend(0.45,0.85,0.88,0.76); -legend.AddEntry(enSpt_G,"Primakoff Gianotti","f"); -legend.AddEntry(enSpt_LH,"Primakoff Lennert&Hoof","f"); +legend = ROOT.TLegend(0.45, 0.85, 0.88, 0.76) +legend.AddEntry(enSpt_G, "Primakoff Gianotti", "f") +legend.AddEntry(enSpt_LH, "Primakoff Lennert&Hoof", "f") legend.SetTextSize(0.03) legend.Draw() pad1.cd(2) rSpt_G = G_spt.ProjectionY() rSpt_G.SetTitle("Radial distribution") -rSpt_G.GetXaxis().SetTitleSize(0.05); +rSpt_G.GetXaxis().SetTitleSize(0.05) rSpt_G.GetXaxis().SetTitle("Solar radius") -rSpt_G.GetYaxis().SetTitleSize(0.05); -rSpt_G.GetYaxis().SetLabelSize(0.05); +rSpt_G.GetYaxis().SetTitleSize(0.05) +rSpt_G.GetYaxis().SetLabelSize(0.05) rSpt_G.SetFillStyle(4050) -rSpt_G.SetFillColorAlpha(ROOT.kBlue, 0.1); -rSpt_G.SetLineColor(ROOT.kBlue+2) +rSpt_G.SetFillColorAlpha(ROOT.kBlue, 0.1) +rSpt_G.SetLineColor(ROOT.kBlue + 2) rSpt_G.SetStats(0) rSpt_G.Draw() rSpt_LH = LH_spt.ProjectionY() rSpt_LH.SetFillStyle(4050) -rSpt_LH.SetFillColorAlpha(ROOT.kOrange, 0.1); -rSpt_LH.SetLineColor(ROOT.kOrange+3) +rSpt_LH.SetFillColorAlpha(ROOT.kOrange, 0.1) +rSpt_LH.SetLineColor(ROOT.kOrange + 3) rSpt_LH.Draw("SAME") legend.Draw() c1.Print(outfname) -print ("File: " + str(outfname) + " was generated [\033[92m OK \x1b[0m]") +print("File: " + str(outfname) + " was generated [\033[92m OK \x1b[0m]") -print ("") +print("") exit(0) diff --git a/pipeline/metadata/solarFlux/solarPlot.py b/pipeline/metadata/solarFlux/solarPlot.py index 78e16b87..ed74615a 100755 --- a/pipeline/metadata/solarFlux/solarPlot.py +++ b/pipeline/metadata/solarFlux/solarPlot.py @@ -3,20 +3,47 @@ import math import ROOT from ROOT import ( - TChain, TFile, TTree, TCanvas, TPad, TRandom3, - TH1D, TH2D, TH3D, - TProfile, TProfile2D, TProfile3D, - TGraph, TGraph2D, - TF1, TF2, TF3, TFormula, - TLorentzVector, TVector3) + TChain, + TFile, + TTree, + TCanvas, + TPad, + TRandom3, + TH1D, + TH2D, + TH3D, + TProfile, + TProfile2D, + TProfile3D, + TGraph, + TGraph2D, + TF1, + TF2, + TF3, + TFormula, + TLorentzVector, + TVector3, +) import argparse parser = argparse.ArgumentParser() -parser.add_argument('--rml', dest='rmlfile', type=str, help='The input RML file .rml') -parser.add_argument('--out', dest='outfname', type=str, help='The output filename in png,pdf,C or any other ROOT accepted format') -parser.add_argument('--fluxname', dest='fluxname', type=str, help='The name of the flux definition to be chosen from the RML') -parser.add_argument('--N', dest='samples', type=int, help='The number of generated particles') +parser.add_argument("--rml", dest="rmlfile", type=str, help="The input RML file .rml") +parser.add_argument( + "--out", + dest="outfname", + type=str, + help="The output filename in png,pdf,C or any other ROOT accepted format", +) +parser.add_argument( + "--fluxname", + dest="fluxname", + type=str, + help="The name of the flux definition to be chosen from the RML", +) +parser.add_argument( + "--N", dest="samples", type=int, help="The number of generated particles" +) args = parser.parse_args() rmlfile = "fluxes.rml" @@ -37,18 +64,23 @@ samples = args.samples validation = False -if rmlfile == "fluxes.rml" and fluxname == "combined" and outfname == "flux.png" and samples == 20000: +if ( + rmlfile == "fluxes.rml" + and fluxname == "combined" + and outfname == "flux.png" + and samples == 20000 +): validation = True ROOT.gSystem.Load("libRestFramework.so") ROOT.gSystem.Load("libRestAxion.so") -c1 = TCanvas( 'c1', 'My canvas', 800,700 ) -c1.GetFrame().SetBorderSize( 6 ) -c1.GetFrame().SetBorderMode( -1 ) +c1 = TCanvas("c1", "My canvas", 800, 700) +c1.GetFrame().SetBorderSize(6) +c1.GetFrame().SetBorderMode(-1) -pad1 = TPad("pad1","This is pad1",0.01,0.02,0.99,0.97); -pad1.Divide(2,2) +pad1 = TPad("pad1", "This is pad1", 0.01, 0.02, 0.99, 0.97) +pad1.Divide(2, 2) pad1.Draw() combinedFlux = ROOT.TRestAxionSolarFlux(rmlfile, fluxname) @@ -56,92 +88,92 @@ combinedFlux.PrintMetadata() if combinedFlux.GetError(): - print ( combinedFlux.GetErrorMessage() ) - print ( "\nSolar flux initialization failed! Exit code : 101" ) + print(combinedFlux.GetErrorMessage()) + print("\nSolar flux initialization failed! Exit code : 101") exit(101) -comb_spt = TH2D("comb_spt", "Energy versus solar radius", 20000, 0, 20, 100, 0, 1 ) +comb_spt = TH2D("comb_spt", "Energy versus solar radius", 20000, 0, 20, 100, 0, 1) for x in range(samples): x = combinedFlux.GetRandomEnergyAndRadius() - comb_spt.Fill( x[0], x[1] ) + comb_spt.Fill(x[0], x[1]) rnd = TRandom3(0) -solarDisk = TH2D("solar_disk", "SolarDisk", 120, -1.2, 1.2, 120, -1.2, 1.2 ) +solarDisk = TH2D("solar_disk", "SolarDisk", 120, -1.2, 1.2, 120, -1.2, 1.2) for x in range(samples): angle = rnd.Rndm() * 2 * math.pi x = combinedFlux.GetRandomEnergyAndRadius() - solarDisk.Fill( x[1]*math.cos(angle), x[1]*math.sin(angle) ) + solarDisk.Fill(x[1] * math.cos(angle), x[1] * math.sin(angle)) pad1.cd(1) -pad1.cd(1).SetRightMargin(0.09); -pad1.cd(1).SetLeftMargin(0.15); -pad1.cd(1).SetBottomMargin(0.15); +pad1.cd(1).SetRightMargin(0.09) +pad1.cd(1).SetLeftMargin(0.15) +pad1.cd(1).SetBottomMargin(0.15) comb_spt.SetStats(0) comb_spt.GetXaxis().SetTitle("Energy [keV]") -comb_spt.GetXaxis().SetTitleSize(0.05); -comb_spt.GetXaxis().SetLabelSize(0.05); +comb_spt.GetXaxis().SetTitleSize(0.05) +comb_spt.GetXaxis().SetLabelSize(0.05) comb_spt.GetYaxis().SetTitle("Solar radius") -comb_spt.GetYaxis().SetTitleSize(0.05); -comb_spt.GetYaxis().SetLabelSize(0.05); +comb_spt.GetYaxis().SetTitleSize(0.05) +comb_spt.GetYaxis().SetLabelSize(0.05) comb_spt.Draw("colz") pad1.cd(2) pad1.cd(2).SetLogy() -pad1.cd(2).SetRightMargin(0.09); -pad1.cd(2).SetLeftMargin(0.15); -pad1.cd(2).SetBottomMargin(0.15); +pad1.cd(2).SetRightMargin(0.09) +pad1.cd(2).SetLeftMargin(0.15) +pad1.cd(2).SetBottomMargin(0.15) enSpt = comb_spt.ProjectionX() enSpt.SetTitle("Energy spectrum") -enSpt.GetYaxis().SetTitleSize(0.05); +enSpt.GetYaxis().SetTitleSize(0.05) enSpt.SetStats(0) enSpt.SetFillStyle(4050) -enSpt.SetFillColor(ROOT.kBlue-9) +enSpt.SetFillColor(ROOT.kBlue - 9) enSpt.SetLineColor(ROOT.kBlack) enSpt.Draw() pad1.cd(3) -pad1.cd(3).SetRightMargin(0.09); -pad1.cd(3).SetLeftMargin(0.15); -pad1.cd(3).SetBottomMargin(0.15); +pad1.cd(3).SetRightMargin(0.09) +pad1.cd(3).SetLeftMargin(0.15) +pad1.cd(3).SetBottomMargin(0.15) rSpt = comb_spt.ProjectionY() rSpt.SetTitle("Radial distribution") -rSpt.GetYaxis().SetTitleSize(0.05); +rSpt.GetYaxis().SetTitleSize(0.05) rSpt.SetStats(0) rSpt.SetFillStyle(4050) -rSpt.SetFillColor(ROOT.kBlue-9) +rSpt.SetFillColor(ROOT.kBlue - 9) rSpt.SetLineColor(ROOT.kBlack) rSpt.Draw() pad1.cd(4) -pad1.cd(4).SetRightMargin(0.09); -pad1.cd(4).SetLeftMargin(0.15); -pad1.cd(4).SetBottomMargin(0.15); +pad1.cd(4).SetRightMargin(0.09) +pad1.cd(4).SetLeftMargin(0.15) +pad1.cd(4).SetBottomMargin(0.15) solarDisk.SetStats(0) solarDisk.GetXaxis().SetTitle("X") -solarDisk.GetXaxis().SetTitleSize(0.05); -solarDisk.GetXaxis().SetLabelSize(0.05); +solarDisk.GetXaxis().SetTitleSize(0.05) +solarDisk.GetXaxis().SetLabelSize(0.05) solarDisk.GetYaxis().SetTitle("Y") solarDisk.GetYaxis().SetTitleOffset(1) -solarDisk.GetYaxis().SetTitleSize(0.05); -solarDisk.GetYaxis().SetLabelSize(0.05); +solarDisk.GetYaxis().SetTitleSize(0.05) +solarDisk.GetYaxis().SetLabelSize(0.05) solarDisk.Draw("colz") c1.Print(outfname) -print( "Generated file : " + outfname ) +print("Generated file : " + outfname) -print ( "\nMaximum energy bin is " + str(enSpt.GetMaximumBin() ) ) +print("\nMaximum energy bin is " + str(enSpt.GetMaximumBin())) if validation: - if ( enSpt.GetMaximumBin() != 8001 ): - print ( "\nMaximum Bin is not the expected one! Exit code : 1" ) + if enSpt.GetMaximumBin() != 8001: + print("\nMaximum Bin is not the expected one! Exit code : 1") exit(1) -print ( "\nMaximum radius bin is " + str(rSpt.GetMaximumBin() ) ) +print("\nMaximum radius bin is " + str(rSpt.GetMaximumBin())) if validation: - if ( rSpt.GetMaximumBin() != 25 ): - print ( "\nMaximum Bin is not the expected one! Exit code : 2" ) + if rSpt.GetMaximumBin() != 25: + print("\nMaximum Bin is not the expected one! Exit code : 2") exit(2) exit(0) diff --git a/pipeline/metadata/solarFlux/solarTests.py b/pipeline/metadata/solarFlux/solarTests.py index 80926871..80fa7efd 100755 --- a/pipeline/metadata/solarFlux/solarTests.py +++ b/pipeline/metadata/solarFlux/solarTests.py @@ -3,12 +3,27 @@ import math import ROOT from ROOT import ( - TChain, TFile, TTree, TCanvas, TPad, TRandom3, - TH1D, TH2D, TH3D, - TProfile, TProfile2D, TProfile3D, - TGraph, TGraph2D, - TF1, TF2, TF3, TFormula, - TLorentzVector, TVector3) + TChain, + TFile, + TTree, + TCanvas, + TPad, + TRandom3, + TH1D, + TH2D, + TH3D, + TProfile, + TProfile2D, + TProfile3D, + TGraph, + TGraph2D, + TF1, + TF2, + TF3, + TFormula, + TLorentzVector, + TVector3, +) ROOT.gSystem.Load("libRestFramework.so") @@ -19,35 +34,35 @@ monoFlux.PrintMetadata() if monoFlux.GetError(): - print ( monoFlux.GetErrorMessage() ) - print ( "\nSolar flux initialization failed! Exit code : 101" ) + print(monoFlux.GetErrorMessage()) + print("\nSolar flux initialization failed! Exit code : 101") exit(101) x = monoFlux.GetRandomEnergyAndRadius() -print( x[0] ) -print( x[1] ) -if ( int( x[0]*100 ) != 800 or int( x[1]*100 ) != 83 ): - print ( "\nMonochromatic flux values seem to be wrong! Exit code : 201" ) +print(x[0]) +print(x[1]) +if int(x[0] * 100) != 800 or int(x[1] * 100) != 83: + print("\nMonochromatic flux values seem to be wrong! Exit code : 201") exit(201) - -print ("[\033[92m OK \x1b[0m]") + +print("[\033[92m OK \x1b[0m]") continuumFlux = ROOT.TRestAxionSolarFlux("fluxes.rml", "Gianotti") continuumFlux.LoadTables() continuumFlux.PrintMetadata() if continuumFlux.GetError(): - print ( continuumFlux.GetErrorMessage() ) - print ( "\nSolar flux initialization failed! Exit code : 101" ) + print(continuumFlux.GetErrorMessage()) + print("\nSolar flux initialization failed! Exit code : 101") exit(101) x = monoFlux.GetRandomEnergyAndRadius() -if ( int( x[0]*100 ) != 400 or int( x[1]*100 ) != 24 ): - print ( "\nContinuum flux values seem to be wrong! Exit code : 202" ) +if int(x[0] * 100) != 400 or int(x[1] * 100) != 24: + print("\nContinuum flux values seem to be wrong! Exit code : 202") exit(202) -print ("All tests passed! [\033[92m OK \x1b[0m]") +print("All tests passed! [\033[92m OK \x1b[0m]") -print ("") +print("") exit(0) diff --git a/pipeline/metadata/transmission/windowPlot.py b/pipeline/metadata/transmission/windowPlot.py index df3b0274..1aaeff0a 100644 --- a/pipeline/metadata/transmission/windowPlot.py +++ b/pipeline/metadata/transmission/windowPlot.py @@ -6,47 +6,68 @@ patternType = "strongBack" from ROOT import ( - TChain, TFile, TTree, TCanvas, TPad, TRandom3, - TH1D, TH2D, TH3D, - TProfile, TProfile2D, TProfile3D, - TGraph, TGraph2D, - TF1, TF2, TF3, TFormula, - TLorentzVector, TVector3) + TChain, + TFile, + TTree, + TCanvas, + TPad, + TRandom3, + TH1D, + TH2D, + TH3D, + TProfile, + TProfile2D, + TProfile3D, + TGraph, + TGraph2D, + TF1, + TF2, + TF3, + TFormula, + TLorentzVector, + TVector3, +) ROOT.gSystem.Load("libRestFramework.so") ROOT.gSystem.Load("libRestAxion.so") ### Creating a canvas and pad for drawing -c1 = TCanvas( 'c1', 'My canvas', 1200, 400 ) -c1.GetFrame().SetBorderSize( 6 ) -c1.GetFrame().SetBorderMode( -1 ) +c1 = TCanvas("c1", "My canvas", 1200, 400) +c1.GetFrame().SetBorderSize(6) +c1.GetFrame().SetBorderMode(-1) -pad1 = TPad( "pad1", "This is pad1", 0.01, 0.02, 0.99, 0.97 ); -pad1.Divide( 3, 1 ) +pad1 = TPad("pad1", "This is pad1", 0.01, 0.02, 0.99, 0.97) +pad1.Divide(3, 1) pad1.Draw() totalSamples = 100000 -print ("Loading cathode" ) +print("Loading cathode") cathode = ROOT.TRestAxionXrayWindow("windows.rml", "cathode") -print ("Loading strongBack" ) +print("Loading strongBack") strongBack = ROOT.TRestAxionXrayWindow("windows.rml", patternType) -print ("Loading silicon foil" ) +print("Loading silicon foil") siFoil = ROOT.TRestAxionXrayWindow("windows.rml", "siliconFoil") radius = strongBack.GetWindowRadius() -print ( "\nGetting window radius" ) +print("\nGetting window radius") if radius != 8: - print ("\nThe window radius is not as expected! Exit code : 102") + print("\nThe window radius is not as expected! Exit code : 102") exit(102) -print ( "[\033[92m OK \x1b[0m]" ) +print("[\033[92m OK \x1b[0m]") # L: Low energy (0-5)keV M: Medium energy H: High energy -histL = ROOT.TH2D("Low", "Low energy", 80, -radius-2, radius+2, 80, -radius-2, radius+2 ) -histM = ROOT.TH2D("Medium", "Medium energy", 80, -radius-2, radius+2, 80, -radius-2, radius+2 ) -histH = ROOT.TH2D("High", "High energy", 80, -radius-2, radius+2, 80, -radius-2, radius+2 ) - -#for n in range(rings): +histL = ROOT.TH2D( + "Low", "Low energy", 80, -radius - 2, radius + 2, 80, -radius - 2, radius + 2 +) +histM = ROOT.TH2D( + "Medium", "Medium energy", 80, -radius - 2, radius + 2, 80, -radius - 2, radius + 2 +) +histH = ROOT.TH2D( + "High", "High energy", 80, -radius - 2, radius + 2, 80, -radius - 2, radius + 2 +) + +# for n in range(rings): # gr = ROOT.TGraph() # gr.SetMarkerStyle(20) # gr.SetMarkerSize(0.5) @@ -64,26 +85,26 @@ rnd = TRandom3(0) for n in range(totalSamples): - x = (radius+2) * (rnd.Rndm() - 0.5) * 2 - y = (radius+2) * (rnd.Rndm() - 0.5) * 2 - en = 0.01 + 14.9 * rnd.Rndm() - - cth = cathode.GetTransmission( en, x, y) - stb = strongBack.GetTransmission( en, x, y) - sil = siFoil.GetTransmission( en, x, y) - - if( stb == 0 ): - continue - #print ("x: " + str(x) + " y: " + str(y) + " en: " + str(en) ) - #print ("cathode: " + str(cth) + " sBack: " + str(stb) + " siFoil: " + str(sil) ) - tr = cth * stb * sil - - if( en < 5 ): - histL.Fill( x, y, tr ) - elif( en < 10): - histM.Fill( x, y, tr ) - else: - histH.Fill( x, y, tr ) + x = (radius + 2) * (rnd.Rndm() - 0.5) * 2 + y = (radius + 2) * (rnd.Rndm() - 0.5) * 2 + en = 0.01 + 14.9 * rnd.Rndm() + + cth = cathode.GetTransmission(en, x, y) + stb = strongBack.GetTransmission(en, x, y) + sil = siFoil.GetTransmission(en, x, y) + + if stb == 0: + continue + # print ("x: " + str(x) + " y: " + str(y) + " en: " + str(en) ) + # print ("cathode: " + str(cth) + " sBack: " + str(stb) + " siFoil: " + str(sil) ) + tr = cth * stb * sil + + if en < 5: + histL.Fill(x, y, tr) + elif en < 10: + histM.Fill(x, y, tr) + else: + histH.Fill(x, y, tr) ## This is to work out a graph with the MC obtained efficiencies (TODO) grCathode = ROOT.TGraph() @@ -92,12 +113,12 @@ grCathode.SetMarkerColor(38) grCathode.SetTitle("Aluminum cathode 20nm") grCathode.GetXaxis().SetTitle("Energy [keV]") -grCathode.GetXaxis().SetTitleSize(0.05); -grCathode.GetXaxis().SetLabelSize(0.05); +grCathode.GetXaxis().SetTitleSize(0.05) +grCathode.GetXaxis().SetLabelSize(0.05) grCathode.GetYaxis().SetTitle(" ") grCathode.GetYaxis().SetTitleOffset(1) -grCathode.GetYaxis().SetTitleSize(0.05); -grCathode.GetYaxis().SetLabelSize(0.05); +grCathode.GetYaxis().SetTitleSize(0.05) +grCathode.GetYaxis().SetLabelSize(0.05) grSBack = ROOT.TGraph() grSBack.SetMarkerStyle(20) @@ -105,12 +126,12 @@ grSBack.SetMarkerColor(39) grSBack.SetTitle("Silicon strong-back 200um") grSBack.GetXaxis().SetTitle("Energy [keV]") -grSBack.GetXaxis().SetTitleSize(0.05); -grSBack.GetXaxis().SetLabelSize(0.05); +grSBack.GetXaxis().SetTitleSize(0.05) +grSBack.GetXaxis().SetLabelSize(0.05) grSBack.GetYaxis().SetTitle(" ") grSBack.GetYaxis().SetTitleOffset(1) -grSBack.GetYaxis().SetTitleSize(0.05); -grSBack.GetYaxis().SetLabelSize(0.05); +grSBack.GetYaxis().SetTitleSize(0.05) +grSBack.GetYaxis().SetLabelSize(0.05) grSiFoil = ROOT.TGraph() grSiFoil.SetMarkerStyle(20) @@ -118,12 +139,12 @@ grSiFoil.SetMarkerColor(40) grSiFoil.SetTitle("Silicon foil 500nm") grSiFoil.GetXaxis().SetTitle("Energy [keV]") -grSiFoil.GetXaxis().SetTitleSize(0.05); -grSiFoil.GetXaxis().SetLabelSize(0.05); +grSiFoil.GetXaxis().SetTitleSize(0.05) +grSiFoil.GetXaxis().SetLabelSize(0.05) grSiFoil.GetYaxis().SetTitle(" ") grSiFoil.GetYaxis().SetTitleOffset(1) -grSiFoil.GetYaxis().SetTitleSize(0.05); -grSiFoil.GetYaxis().SetLabelSize(0.05); +grSiFoil.GetYaxis().SetTitleSize(0.05) +grSiFoil.GetYaxis().SetLabelSize(0.05) pad1.cd(1) histL.SetStats(0) @@ -139,27 +160,27 @@ c1.Print(outfname) -print ( "Low: " + str( histL.Integral() ) ) -print ( "Mid: " + str( histM.Integral() ) ) -print ( "High: " + str( histH.Integral() ) ) -if( histL.Integral() < 10000 ): - print( "Effective counts at low energy below 10000!!") - print ( "Low: " + str( histL.Integral() ) ) +print("Low: " + str(histL.Integral())) +print("Mid: " + str(histM.Integral())) +print("High: " + str(histH.Integral())) +if histL.Integral() < 10000: + print("Effective counts at low energy below 10000!!") + print("Low: " + str(histL.Integral())) exit(103) -if( histM.Integral() < 12000 ): - print( "Effective counts at low energy below 12000!!") - print ( "Mid: " + str( histM.Integral() ) ) +if histM.Integral() < 12000: + print("Effective counts at low energy below 12000!!") + print("Mid: " + str(histM.Integral())) exit(104) -if( histH.Integral() < 14000 ): - print( "Effective counts at low energy below 14000!!") - print ( "High: " + str( histH.Integral() ) ) +if histH.Integral() < 14000: + print("Effective counts at low energy below 14000!!") + print("High: " + str(histH.Integral())) exit(105) -print ("All tests passed! [\033[92m OK \x1b[0m]") +print("All tests passed! [\033[92m OK \x1b[0m]") -print ("") +print("") exit(0) diff --git a/pipeline/ray-tracing/axion-field/validateStreamer.py b/pipeline/ray-tracing/axion-field/validateStreamer.py index 599720c6..b6cab8ee 100644 --- a/pipeline/ray-tracing/axion-field/validateStreamer.py +++ b/pipeline/ray-tracing/axion-field/validateStreamer.py @@ -1,16 +1,18 @@ import os, sys -os.system("restRoot -b -q StreamerOutput.C'(\"AxionPhotonProbability.root\")' | grep Process | grep TRestAxion | grep version | wc -l > output.log 2>&1") +os.system( + "restRoot -b -q StreamerOutput.C'(\"AxionPhotonProbability.root\")' | grep Process | grep TRestAxion | grep version | wc -l > output.log 2>&1" +) -with open('output.log') as f: +with open("output.log") as f: lines = f.readlines() for line in lines: - if( line.find("6") == 0): - print ("The number of processes inside the event data chain is 6. Succeed!") + if line.find("6") == 0: + print("The number of processes inside the event data chain is 6. Succeed!") sys.exit(0) else: - print ("The number of processes inside the event data chain is NOT 6! Fail!") + print("The number of processes inside the event data chain is NOT 6! Fail!") sys.exit(1) sys.exit(0) diff --git a/pipeline/validateLibrary.py b/pipeline/validateLibrary.py index 4c6b398a..7d51399a 100755 --- a/pipeline/validateLibrary.py +++ b/pipeline/validateLibrary.py @@ -5,7 +5,7 @@ # J. Galan - Javier.Galan.Lacarra@cern.ch # 23 - Dec - 2019 -#from __future__ import print_function +# from __future__ import print_function import os import sys import re @@ -14,41 +14,42 @@ def validateClass(className): - print ("") - print ("++++ Validating class : " + className) - with open(className, 'r') as file: + print("") + print("++++ Validating class : " + className) + with open(className, "r") as file: data = file.read() - data = data[data.find("::Initialize()"):] + data = data[data.find("::Initialize()") :] data = getMethodDefinition(data) data = removeCppComment(data) - #print (data) - #print data.find("SETLIBRARYVERSION(LIBRARY_VERSION);") + # print (data) + # print data.find("SETLIBRARYVERSION(LIBRARY_VERSION);") if data.find("SETLIBRARYVERSION(LIBRARY_VERSION);") >= 0: - print ("OK") + print("OK") return else: - print( "Problem found at class : " + className ) - print( "SetLibraryVersion was NOT found at Initialization!" ) + print("Problem found at class : " + className) + print("SetLibraryVersion was NOT found at Initialization!") sys.exit(1) return + def getObservablePositions(data): obsposes = {} pos = 0 - str = "SETOBSERVABLEVALUE(\"" - while(pos < len(data)): - pos1 = data.find(str,pos) - if(pos1 == -1): - break + str = 'SETOBSERVABLEVALUE("' + while pos < len(data): + pos1 = data.find(str, pos) + if pos1 == -1: + break pos1 += len(str) - pos2 = data.find("\"",pos1) - if(pos2 == -1): - break + pos2 = data.find('"', pos1) + if pos2 == -1: + break name = data[pos1:pos2] - if(not obsposes.has_key(name)): + if not obsposes.has_key(name): obsposes[name] = pos1 pos = pos2 + 1 @@ -60,115 +61,120 @@ def getMethodDefinition(text): counter = 1 start = initPos + 1 - while(counter > 0): - pos1 = text.find("{",start) - pos2 = text.find("}",start) + while counter > 0: + pos1 = text.find("{", start) + pos2 = text.find("}", start) endPosition = pos2 + 1 - if(pos1 != -1 and pos2 != -1): - if(pos1 < pos2): + if pos1 != -1 and pos2 != -1: + if pos1 < pos2: counter = counter + 1 start = pos1 + 1 - if(pos2 < pos1): + if pos2 < pos1: counter = counter - 1 start = pos2 + 1 elif pos1 != -1: - print ("Big error!!") + print("Big error!!") else: - counter = counter - 1 - start = pos2 + 1 + counter = counter - 1 + start = pos2 + 1 return text[initPos:endPosition].upper() -def removeCppComment(strInput) : - state = 0; - strOutput = '' - strRemoved = '' - - for c in strInput : - if state == 0 and c == '/' : # ex. [/] - state = 1 - elif state == 1 and c == '*' : # ex. [/*] - state = 2 - elif state == 1 and c == '/' : # ex. [#] - state = 4 - elif state == 1 : # ex. [<secure/_stdio.h> or 5/3] - state = 0 - - elif state == 3 and c == '*': # ex. [/*he**] - state = 3 - elif state == 2 and c == '*': # ex. [/*he*] - state = 3 - elif state == 2: # ex. [/*heh] - state = 2 - - elif state == 3 and c == '/': # ex. [/*heh*/] - state = 0 - elif state == 3: # ex. [/*heh*e] - state = 2 - - elif state == 4 and c == '\\': # ex. [//hehe\] - state = 9 - elif state == 9 and c == '\\': # ex. [//hehe\\\\\] - state = 9 - elif state == 9: # ex. [//hehe\<enter> or //hehe\a] - state = 4 - elif state == 4 and c == '\n': # ex. [//hehe<enter>] - state = 0 - - elif state == 0 and c == '\'': # ex. ['] - state = 5 - elif state == 5 and c == '\\': # ex. ['\] - state = 6 - elif state == 6: # ex. ['\n or '\' or '\t etc.] - state = 5 - elif state == 5 and c == '\'': # ex. ['\n' or '\'' or '\t' ect.] - state = 0 - - elif state == 0 and c == '\"': # ex. ["] - state = 7 - elif state == 7 and c == '\\': # ex. ["\] - state = 8 - elif state == 8: # ex. ["\n or "\" or "\t ect.] - state = 7 - elif state == 7 and c == '\"': # ex. ["\n" or "\"" or "\t" ect.] - state = 0 - - if (state == 0 and c != '/') or state == 5 or\ - state == 6 or state == 7 or state == 8 : - strOutput += c - else: - # removed chareters - strRemoved += c - - return strOutput +def removeCppComment(strInput): + state = 0 + strOutput = "" + strRemoved = "" + + for c in strInput: + if state == 0 and c == "/": # ex. [/] + state = 1 + elif state == 1 and c == "*": # ex. [/*] + state = 2 + elif state == 1 and c == "/": # ex. [#] + state = 4 + elif state == 1: # ex. [<secure/_stdio.h> or 5/3] + state = 0 + + elif state == 3 and c == "*": # ex. [/*he**] + state = 3 + elif state == 2 and c == "*": # ex. [/*he*] + state = 3 + elif state == 2: # ex. [/*heh] + state = 2 + + elif state == 3 and c == "/": # ex. [/*heh*/] + state = 0 + elif state == 3: # ex. [/*heh*e] + state = 2 + + elif state == 4 and c == "\\": # ex. [//hehe\] + state = 9 + elif state == 9 and c == "\\": # ex. [//hehe\\\\\] + state = 9 + elif state == 9: # ex. [//hehe\<enter> or //hehe\a] + state = 4 + elif state == 4 and c == "\n": # ex. [//hehe<enter>] + state = 0 + + elif state == 0 and c == "'": # ex. ['] + state = 5 + elif state == 5 and c == "\\": # ex. ['\] + state = 6 + elif state == 6: # ex. ['\n or '\' or '\t etc.] + state = 5 + elif state == 5 and c == "'": # ex. ['\n' or '\'' or '\t' ect.] + state = 0 + + elif state == 0 and c == '"': # ex. ["] + state = 7 + elif state == 7 and c == "\\": # ex. ["\] + state = 8 + elif state == 8: # ex. ["\n or "\" or "\t ect.] + state = 7 + elif state == 7 and c == '"': # ex. ["\n" or "\"" or "\t" ect.] + state = 0 + + if ( + (state == 0 and c != "/") + or state == 5 + or state == 6 + or state == 7 + or state == 8 + ): + strOutput += c + else: + # removed chareters + strRemoved += c + + return strOutput files = [] # r=root, d=directories, f = files for r, d, f in os.walk(sys.argv[1]): - for file in f: - validate = 0 - if '.cxx' in file: -# print ( file ) - with open(os.path.join(r, file)) as fin: - if '::InitFromConfigFile' in fin.read(): - validate = 1 - with open(os.path.join(r, file)) as fin: - if '::LoadDefaultConfig' in fin.read(): - validate = 1 - with open(os.path.join(r, file)) as fin: - if '::Initialize' in fin.read(): - validate = validate + 1 - if validate == 2: - files.append(os.path.join(r, file)) - validateClass(os.path.join(r, file)) - -#for f in files: + for file in f: + validate = 0 + if ".cxx" in file: + # print ( file ) + with open(os.path.join(r, file)) as fin: + if "::InitFromConfigFile" in fin.read(): + validate = 1 + with open(os.path.join(r, file)) as fin: + if "::LoadDefaultConfig" in fin.read(): + validate = 1 + with open(os.path.join(r, file)) as fin: + if "::Initialize" in fin.read(): + validate = validate + 1 + if validate == 2: + files.append(os.path.join(r, file)) + validateClass(os.path.join(r, file)) + +# for f in files: # print(f) -#validateProcess(sys.argv[1]); +# validateProcess(sys.argv[1]); sys.exit(0) diff --git a/pipeline/validateMacros.py b/pipeline/validateMacros.py index 005d339b..98b7a2ca 100755 --- a/pipeline/validateMacros.py +++ b/pipeline/validateMacros.py @@ -2,7 +2,7 @@ os.system("restRoot -b -q -m 1 > error.log 2>&1") -with open('error.log') as f: +with open("error.log") as f: lines = f.readlines() for line in lines: diff --git a/scripts/fluxToTables.py b/scripts/fluxToTables.py index ae63d4c7..3fa90f07 100755 --- a/scripts/fluxToTables.py +++ b/scripts/fluxToTables.py @@ -12,15 +12,25 @@ from array import array from ROOT import TH1D, TH2D -import pandas as pd +import pandas as pd import argparse parser = argparse.ArgumentParser() -parser.add_argument('--file', dest='fname', type=str, help='Input filename .flux') -parser.add_argument('--out', dest='outfname', type=str, help='Output filename .dat') -parser.add_argument('--binsize', dest='binsize', type=float, help='The energy bin size used at the .flux file [in eV].') -parser.add_argument('--skiprows', dest='skiprows', type=int, help='The number of header rows to be skipped') +parser.add_argument("--file", dest="fname", type=str, help="Input filename .flux") +parser.add_argument("--out", dest="outfname", type=str, help="Output filename .dat") +parser.add_argument( + "--binsize", + dest="binsize", + type=float, + help="The energy bin size used at the .flux file [in eV].", +) +parser.add_argument( + "--skiprows", + dest="skiprows", + type=int, + help="The number of header rows to be skipped", +) args = parser.parse_args() # This is the default for SolarAxionFlux library @@ -37,52 +47,52 @@ parser.print_usage() sys.exit(1) -print (args.fname) -print (args.fname.find(".")) +print(args.fname) +print(args.fname.find(".")) outfname = os.path.basename(args.fname) -outfname = outfname[0:outfname.find(".")] + ".Nxxf" +outfname = outfname[0 : outfname.find(".")] + ".Nxxf" if args.outfname != None: outfname = args.outfname + "Nxxf" -print (outfname) +print(outfname) -extension = outfname[outfname.find(".")+1:] -print (extension) +extension = outfname[outfname.find(".") + 1 :] +print(extension) data = pd.read_csv(args.fname, sep=" ", skiprows=skiprows, header=None) -print (data) +print(data) -fluxTable = TH2D( "flux", "Flux table", 100, 0., 1., 200, 0., 20. ) +fluxTable = TH2D("flux", "Flux table", 100, 0.0, 1.0, 200, 0.0, 20.0) -#fluxData = data.as_matrix(columns=data.columns[0:]) +# fluxData = data.as_matrix(columns=data.columns[0:]) for n in range(len(data)): r = 0.005 + data[0][n] en = data[1][n] - 0.005 - flux = data[2][n] * binsize/100. + flux = data[2][n] * binsize / 100.0 - fluxTable.Fill( r, en, flux ) + fluxTable.Fill(r, en, flux) - #print( "R: " + str(r) + " En: " + str(en) + " Flux: " + str(flux) + "\n" ) + # print( "R: " + str(r) + " En: " + str(en) + " Flux: " + str(flux) + "\n" ) -print (outfname) +print(outfname) if extension == "Nxxf": - print("Writting binary" ) - output_file = open(outfname, 'wb') - for n in range(0,fluxTable.GetNbinsX()): - float_array = array('f', []) - for m in range(0,fluxTable.GetNbinsY()): - float_array.append(float(fluxTable.GetBinContent( n+1, m+1 ))) + print("Writting binary") + output_file = open(outfname, "wb") + for n in range(0, fluxTable.GetNbinsX()): + float_array = array("f", []) + for m in range(0, fluxTable.GetNbinsY()): + float_array.append(float(fluxTable.GetBinContent(n + 1, m + 1))) float_array.tofile(output_file) output_file.close() else: - outf = open( outfname, "w") - print( str(fluxTable.GetNbinsX()) + " " + str(fluxTable.GetNbinsY()) ) - for n in range(0,fluxTable.GetNbinsX()): - for m in range(0,fluxTable.GetNbinsY()): - outf.write( str(fluxTable.GetBinContent( n+1, m+1 )) ) + outf = open(outfname, "w") + print(str(fluxTable.GetNbinsX()) + " " + str(fluxTable.GetNbinsY())) + for n in range(0, fluxTable.GetNbinsX()): + for m in range(0, fluxTable.GetNbinsY()): + outf.write(str(fluxTable.GetBinContent(n + 1, m + 1))) if m == fluxTable.GetNbinsY() - 1: outf.write("\n") else: diff --git a/src/TRestAxionEvent.cxx b/src/TRestAxionEvent.cxx index ec262244..c5e2c2c0 100644 --- a/src/TRestAxionEvent.cxx +++ b/src/TRestAxionEvent.cxx @@ -41,6 +41,7 @@ /// <hr> /// #include "TRestAxionEvent.h" + #include "TRestTools.h" using namespace std; diff --git a/src/TRestAxionField.cxx b/src/TRestAxionField.cxx index 1514b285..a5cb8b94 100644 --- a/src/TRestAxionField.cxx +++ b/src/TRestAxionField.cxx @@ -44,7 +44,9 @@ /// <hr> /// #include "TRestAxionField.h" + #include <TVectorD.h> + #include "TH1F.h" #ifdef USE_MPFR diff --git a/src/TRestAxionFieldPropagationProcess.cxx b/src/TRestAxionFieldPropagationProcess.cxx index 3d89d4b1..e086a50b 100644 --- a/src/TRestAxionFieldPropagationProcess.cxx +++ b/src/TRestAxionFieldPropagationProcess.cxx @@ -113,6 +113,7 @@ /// <hr> /// #include "TRestAxionFieldPropagationProcess.h" + #include <TVectorD.h> #include <numeric> diff --git a/src/TRestAxionOpticsMirror.cxx b/src/TRestAxionOpticsMirror.cxx index 43f007c0..de0c8e23 100644 --- a/src/TRestAxionOpticsMirror.cxx +++ b/src/TRestAxionOpticsMirror.cxx @@ -127,6 +127,7 @@ /// #include "TRestAxionOpticsMirror.h" + #include <TAxis.h> #include <TGraph.h> #include <TH1F.h> diff --git a/src/TRestAxionTrueWolterOptics.cxx b/src/TRestAxionTrueWolterOptics.cxx index 21f6ea08..592c5ba0 100644 --- a/src/TRestAxionTrueWolterOptics.cxx +++ b/src/TRestAxionTrueWolterOptics.cxx @@ -117,7 +117,9 @@ using namespace std; #include <TAxis.h> #include <TGraph.h> #include <TH1F.h> + #include <cmath> + #include "TRestPhysics.h" using namespace REST_Physics; ClassImp(TRestAxionTrueWolterOptics); diff --git a/src/TRestAxionWolterOptics.cxx b/src/TRestAxionWolterOptics.cxx index e810d061..faac2445 100644 --- a/src/TRestAxionWolterOptics.cxx +++ b/src/TRestAxionWolterOptics.cxx @@ -117,7 +117,9 @@ using namespace std; #include <TAxis.h> #include <TGraph.h> #include <TH1F.h> + #include <cmath> + #include "TRestPhysics.h" using namespace REST_Physics; ClassImp(TRestAxionWolterOptics); From 4d0324546bc85909abdc1f7ea973cef0bbf9f405 Mon Sep 17 00:00:00 2001 From: Luis Antonio Obis Aparicio <luis.antonio.obis@gmail.com> Date: Fri, 10 Feb 2023 17:12:27 +0100 Subject: [PATCH 4/6] add pre-commit files check to workflow --- .github/workflows/validation.yml | 242 ++++++++++++++++--------------- 1 file changed, 123 insertions(+), 119 deletions(-) diff --git a/.github/workflows/validation.yml b/.github/workflows/validation.yml index 08e30e38..d8ebf4df 100644 --- a/.github/workflows/validation.yml +++ b/.github/workflows/validation.yml @@ -29,7 +29,7 @@ jobs: image: ghcr.io/lobis/root-geant4-garfield:rest-for-physics steps: - uses: actions/checkout@v3 - - run: python3 pipeline/validateLibrary.py . + - run: python3 pipeline/validateLibrary.py . build-axionlib: name: Build only axionlib @@ -43,6 +43,10 @@ jobs: with: cmake-flags: "-DCMAKE_INSTALL_PREFIX=${{ env.REST_PATH }} -DCMAKE_BUILD_TYPE=${{ env.CMAKE_BUILD_TYPE }} -DREST_WELCOME=ON -DRESTLIB_AXION=ON -DREST_MPFR=ON" branch: ${{ env.BRANCH_NAME }} + - name: Verify pre-commit config files match + run: | + cd $GITHUB_WORKSPACE + python ${{ env.REST_PATH }}/scripts/validatePreCommitConfig.py - name: Cache framework installation id: axionlib-install-cache uses: actions/cache@v3 @@ -79,25 +83,25 @@ jobs: image: ghcr.io/lobis/root-geant4-garfield:rest-for-physics needs: [ build-axionlib ] steps: - - uses: actions/checkout@v3 - - name: Restore cache - uses: actions/cache@v3 - id: axionlib-install-cache - with: - key: ${{ env.BRANCH_NAME }}-${{ github.sha }} - path: ${{ env.REST_PATH }} - - name: Basic physics tests - run: | - source ${{ env.REST_PATH }}/thisREST.sh - cd pipeline/physics/ - wget https://sultan.unizar.es/axionlib-data/bufferGas/He.abs - wget https://sultan.unizar.es/axionlib-data/bufferGas/He.nff - wget https://sultan.unizar.es/axionlib-data/bufferGas/Ne.abs - wget https://sultan.unizar.es/axionlib-data/bufferGas/Ne.nff - wget https://sultan.unizar.es/axionlib-data/bufferGas/bufferGases.rml - wget https://sultan.unizar.es/axionlib-data/magneticField/fields.rml - wget https://sultan.unizar.es/axionlib-data/magneticField/Bykovskiy_201906.dat - restRoot -b -q AxionPhysicsValidation.C + - uses: actions/checkout@v3 + - name: Restore cache + uses: actions/cache@v3 + id: axionlib-install-cache + with: + key: ${{ env.BRANCH_NAME }}-${{ github.sha }} + path: ${{ env.REST_PATH }} + - name: Basic physics tests + run: | + source ${{ env.REST_PATH }}/thisREST.sh + cd pipeline/physics/ + wget https://sultan.unizar.es/axionlib-data/bufferGas/He.abs + wget https://sultan.unizar.es/axionlib-data/bufferGas/He.nff + wget https://sultan.unizar.es/axionlib-data/bufferGas/Ne.abs + wget https://sultan.unizar.es/axionlib-data/bufferGas/Ne.nff + wget https://sultan.unizar.es/axionlib-data/bufferGas/bufferGases.rml + wget https://sultan.unizar.es/axionlib-data/magneticField/fields.rml + wget https://sultan.unizar.es/axionlib-data/magneticField/Bykovskiy_201906.dat + restRoot -b -q AxionPhysicsValidation.C Metadata: name: Check metadata @@ -106,63 +110,63 @@ jobs: image: ghcr.io/lobis/root-geant4-garfield:rest-for-physics needs: [ build-axionlib ] steps: - - uses: actions/checkout@v3 - - name: Restore cache - uses: actions/cache@v3 - id: axionlib-install-cache - with: - key: ${{ env.BRANCH_NAME }}-${{ github.sha }} - path: ${{ env.REST_PATH }} - - name: Magnetic field - run: | - source ${{ env.REST_PATH }}/thisREST.sh - cd pipeline/metadata/magneticField/ - wget https://rest-for-physics.github.io/axionlib-data/magneticField/fields.rml - wget https://rest-for-physics.github.io/axionlib-data/magneticField/Bykovskiy_201906.dat - python magneticField.py - cd trilinear - wget https://rest-for-physics.github.io/axionlib-data/magneticField/fields.rml - restRoot -b -q GetMagneticField_test.C - cd ../boundary/ - restRoot -b -q Boundaries_test.C - - name: Optics Mirrors - run: | - source ${{ env.REST_PATH }}/thisREST.sh - cd pipeline/metadata/optics/ - wget https://rest-for-physics.github.io/axionlib-data/optics/optics.rml - wget https://rest-for-physics.github.io/axionlib-data/opticsMirror/mirrors.rml - wget https://rest-for-physics.github.io/axionlib-data/opticsMirror/Reflectivity_Single_C_30_SiO2_0.N901f - wget https://rest-for-physics.github.io/axionlib-data/opticsMirror/Transmission_Single_C_30_SiO2_0.N901f - wget https://rest-for-physics.github.io/axionlib-data/opticsMirror/Reflectivity_Single_Au_250_Ni_0.4.N901f - wget https://rest-for-physics.github.io/axionlib-data/opticsMirror/Transmission_Single_Au_250_Ni_0.4.N901f - python mirrors.py - - name: MCPL Optics - run: | - source ${{ env.REST_PATH }}/thisREST.sh - cd pipeline/metadata/optics/ - wget https://rest-for-physics.github.io/axionlib-data/optics/optics.rml - python mcpl.py - - name: X-ray transmission - run: | - source ${{ env.REST_PATH }}/thisREST.sh - cd pipeline/metadata/transmission/ - wget https://rest-for-physics.github.io/axionlib-data/transmission/windows.rml - wget https://rest-for-physics.github.io/axionlib-data/transmission/Al.sol - wget https://rest-for-physics.github.io/axionlib-data/transmission/Si.sol - wget https://rest-for-physics.github.io/axionlib-data/transmission/Si3N4.sol - export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${{ env.REST_PATH }}/mpfr-4.0.2/install/lib - python windowPlot.py - - name: Solar flux - run: | - source ${{ env.REST_PATH }}/thisREST.sh - cd pipeline/metadata/solarFlux/ - wget https://rest-for-physics.github.io/axionlib-data/solarFlux/fluxes.rml - wget https://rest-for-physics.github.io/axionlib-data/solarFlux/Dummy_Galan_202202.spt - wget https://rest-for-physics.github.io/axionlib-data/solarFlux/Primakoff_Gianotti_201904.dat - wget https://rest-for-physics.github.io/axionlib-data/solarFlux/Primakoff_LennertHoof_202203.dat - python solarTests.py - python solarPlot.py - python compare.py + - uses: actions/checkout@v3 + - name: Restore cache + uses: actions/cache@v3 + id: axionlib-install-cache + with: + key: ${{ env.BRANCH_NAME }}-${{ github.sha }} + path: ${{ env.REST_PATH }} + - name: Magnetic field + run: | + source ${{ env.REST_PATH }}/thisREST.sh + cd pipeline/metadata/magneticField/ + wget https://rest-for-physics.github.io/axionlib-data/magneticField/fields.rml + wget https://rest-for-physics.github.io/axionlib-data/magneticField/Bykovskiy_201906.dat + python magneticField.py + cd trilinear + wget https://rest-for-physics.github.io/axionlib-data/magneticField/fields.rml + restRoot -b -q GetMagneticField_test.C + cd ../boundary/ + restRoot -b -q Boundaries_test.C + - name: Optics Mirrors + run: | + source ${{ env.REST_PATH }}/thisREST.sh + cd pipeline/metadata/optics/ + wget https://rest-for-physics.github.io/axionlib-data/optics/optics.rml + wget https://rest-for-physics.github.io/axionlib-data/opticsMirror/mirrors.rml + wget https://rest-for-physics.github.io/axionlib-data/opticsMirror/Reflectivity_Single_C_30_SiO2_0.N901f + wget https://rest-for-physics.github.io/axionlib-data/opticsMirror/Transmission_Single_C_30_SiO2_0.N901f + wget https://rest-for-physics.github.io/axionlib-data/opticsMirror/Reflectivity_Single_Au_250_Ni_0.4.N901f + wget https://rest-for-physics.github.io/axionlib-data/opticsMirror/Transmission_Single_Au_250_Ni_0.4.N901f + python mirrors.py + - name: MCPL Optics + run: | + source ${{ env.REST_PATH }}/thisREST.sh + cd pipeline/metadata/optics/ + wget https://rest-for-physics.github.io/axionlib-data/optics/optics.rml + python mcpl.py + - name: X-ray transmission + run: | + source ${{ env.REST_PATH }}/thisREST.sh + cd pipeline/metadata/transmission/ + wget https://rest-for-physics.github.io/axionlib-data/transmission/windows.rml + wget https://rest-for-physics.github.io/axionlib-data/transmission/Al.sol + wget https://rest-for-physics.github.io/axionlib-data/transmission/Si.sol + wget https://rest-for-physics.github.io/axionlib-data/transmission/Si3N4.sol + export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${{ env.REST_PATH }}/mpfr-4.0.2/install/lib + python windowPlot.py + - name: Solar flux + run: | + source ${{ env.REST_PATH }}/thisREST.sh + cd pipeline/metadata/solarFlux/ + wget https://rest-for-physics.github.io/axionlib-data/solarFlux/fluxes.rml + wget https://rest-for-physics.github.io/axionlib-data/solarFlux/Dummy_Galan_202202.spt + wget https://rest-for-physics.github.io/axionlib-data/solarFlux/Primakoff_Gianotti_201904.dat + wget https://rest-for-physics.github.io/axionlib-data/solarFlux/Primakoff_LennertHoof_202203.dat + python solarTests.py + python solarPlot.py + python compare.py Ray-tracing: name: Check ray-tracing processing chain @@ -171,45 +175,45 @@ jobs: image: ghcr.io/lobis/root-geant4-garfield:rest-for-physics needs: [ build-axionlib ] steps: - - uses: actions/checkout@v3 - - name: Restore cache - uses: actions/cache@v3 - id: axionlib-install-cache - with: - key: ${{ env.BRANCH_NAME }}-${{ github.sha }} - path: ${{ env.REST_PATH }} - - name: XMM optics bench ray-tracing - run: | - source ${{ env.REST_PATH }}/thisREST.sh - export REST_NEVENTS=1000 - export REST_RUN=100 - cd pipeline/ray-tracing/optics/ - wget https://rest-for-physics.github.io/axionlib-data/optics/xmm.rml - wget https://rest-for-physics.github.io/axionlib-data/optics/XMM.Wolter - wget https://rest-for-physics.github.io/axionlib-data/opticsMirror/Reflectivity_Single_Au_250_Ni_0.4.N901f - wget https://rest-for-physics.github.io/axionlib-data/opticsMirror/Transmission_Single_Au_250_Ni_0.4.N901f - restManager --c opticsBench.rml - restRoot -b -q ValidateXMM.C'("OpticsBench_Yaw_0.05_Dev_0.005_BabyIAXO_Run00100.root")' - - name: Window transmission - run: | - source ${{ env.REST_PATH }}/thisREST.sh - cd pipeline/ray-tracing/transmission/ - wget https://rest-for-physics.github.io/axionlib-data/transmission/Si.sol - restManager --c emptyWindow.rml - restRoot ValidateTransmission.C'("EmptyVacuumWindow.root", 0.07, 0.09)' - restManager --c shiftedWindow.rml - restRoot ValidateTransmission.C'("ShiftedVacuumWindow", 0.3, 0.5)' - restManager --c siWindow.rml - restRoot -b -q ValidateTransmission.C'("SiWindow.root", 0.9, 1)' - - name: Axion-field integration - run: | - source ${{ env.REST_PATH }}/thisREST.sh - cd pipeline/ray-tracing/axion-field/ - wget https://rest-for-physics.github.io/axionlib-data/magneticField/fields.rml - wget https://rest-for-physics.github.io/axionlib-data/magneticField/Bykovskiy_201906.dat - wget https://sultan.unizar.es/axionlib-data/bufferGas/He.abs - wget https://sultan.unizar.es/axionlib-data/bufferGas/He.nff - wget https://rest-for-physics.github.io/axionlib-data/bufferGas/bufferGases.rml - restManager --c photonConversion.rml - restRoot -b -q Validate.C'(5.86614e-19, 1.61288)' - python3 validateStreamer.py + - uses: actions/checkout@v3 + - name: Restore cache + uses: actions/cache@v3 + id: axionlib-install-cache + with: + key: ${{ env.BRANCH_NAME }}-${{ github.sha }} + path: ${{ env.REST_PATH }} + - name: XMM optics bench ray-tracing + run: | + source ${{ env.REST_PATH }}/thisREST.sh + export REST_NEVENTS=1000 + export REST_RUN=100 + cd pipeline/ray-tracing/optics/ + wget https://rest-for-physics.github.io/axionlib-data/optics/xmm.rml + wget https://rest-for-physics.github.io/axionlib-data/optics/XMM.Wolter + wget https://rest-for-physics.github.io/axionlib-data/opticsMirror/Reflectivity_Single_Au_250_Ni_0.4.N901f + wget https://rest-for-physics.github.io/axionlib-data/opticsMirror/Transmission_Single_Au_250_Ni_0.4.N901f + restManager --c opticsBench.rml + restRoot -b -q ValidateXMM.C'("OpticsBench_Yaw_0.05_Dev_0.005_BabyIAXO_Run00100.root")' + - name: Window transmission + run: | + source ${{ env.REST_PATH }}/thisREST.sh + cd pipeline/ray-tracing/transmission/ + wget https://rest-for-physics.github.io/axionlib-data/transmission/Si.sol + restManager --c emptyWindow.rml + restRoot ValidateTransmission.C'("EmptyVacuumWindow.root", 0.07, 0.09)' + restManager --c shiftedWindow.rml + restRoot ValidateTransmission.C'("ShiftedVacuumWindow", 0.3, 0.5)' + restManager --c siWindow.rml + restRoot -b -q ValidateTransmission.C'("SiWindow.root", 0.9, 1)' + - name: Axion-field integration + run: | + source ${{ env.REST_PATH }}/thisREST.sh + cd pipeline/ray-tracing/axion-field/ + wget https://rest-for-physics.github.io/axionlib-data/magneticField/fields.rml + wget https://rest-for-physics.github.io/axionlib-data/magneticField/Bykovskiy_201906.dat + wget https://sultan.unizar.es/axionlib-data/bufferGas/He.abs + wget https://sultan.unizar.es/axionlib-data/bufferGas/He.nff + wget https://rest-for-physics.github.io/axionlib-data/bufferGas/bufferGases.rml + restManager --c photonConversion.rml + restRoot -b -q Validate.C'(5.86614e-19, 1.61288)' + python3 validateStreamer.py From 5ee05fab09560bdca0c86c9de30cbe77aa8175a1 Mon Sep 17 00:00:00 2001 From: Luis Antonio Obis Aparicio <luis.antonio.obis@gmail.com> Date: Fri, 10 Feb 2023 17:33:34 +0100 Subject: [PATCH 5/6] run the validation script using curl --- .github/workflows/validation.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/validation.yml b/.github/workflows/validation.yml index d8ebf4df..e0acbb7c 100644 --- a/.github/workflows/validation.yml +++ b/.github/workflows/validation.yml @@ -44,9 +44,7 @@ jobs: cmake-flags: "-DCMAKE_INSTALL_PREFIX=${{ env.REST_PATH }} -DCMAKE_BUILD_TYPE=${{ env.CMAKE_BUILD_TYPE }} -DREST_WELCOME=ON -DRESTLIB_AXION=ON -DREST_MPFR=ON" branch: ${{ env.BRANCH_NAME }} - name: Verify pre-commit config files match - run: | - cd $GITHUB_WORKSPACE - python ${{ env.REST_PATH }}/scripts/validatePreCommitConfig.py + run: curl https://raw.githubusercontent.com/rest-for-physics/framework/master/scripts/validatePreCommitConfig.py | sudo python - - name: Cache framework installation id: axionlib-install-cache uses: actions/cache@v3 From c222ab82d63641a0c1fdd623eb79551fb9a038f1 Mon Sep 17 00:00:00 2001 From: Luis Antonio Obis Aparicio <luis.antonio.obis@gmail.com> Date: Fri, 10 Feb 2023 17:36:18 +0100 Subject: [PATCH 6/6] make sure the directory is correct --- .github/workflows/validation.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/validation.yml b/.github/workflows/validation.yml index e0acbb7c..41acd991 100644 --- a/.github/workflows/validation.yml +++ b/.github/workflows/validation.yml @@ -44,7 +44,9 @@ jobs: cmake-flags: "-DCMAKE_INSTALL_PREFIX=${{ env.REST_PATH }} -DCMAKE_BUILD_TYPE=${{ env.CMAKE_BUILD_TYPE }} -DREST_WELCOME=ON -DRESTLIB_AXION=ON -DREST_MPFR=ON" branch: ${{ env.BRANCH_NAME }} - name: Verify pre-commit config files match - run: curl https://raw.githubusercontent.com/rest-for-physics/framework/master/scripts/validatePreCommitConfig.py | sudo python - + run: | + cd $GITHUB_WORKSPACE + curl https://raw.githubusercontent.com/rest-for-physics/framework/master/scripts/validatePreCommitConfig.py | python - name: Cache framework installation id: axionlib-install-cache uses: actions/cache@v3