diff --git a/Processes/CONEX/CONEX.h b/Processes/CONEX/CONEX.h index bbc914f6e09639f054d191dcd5c1ca5ac25c9172..5e63e675d5b8d85c10bd4c5a134c1064ccc1e8a1 100644 --- a/Processes/CONEX/CONEX.h +++ b/Processes/CONEX/CONEX.h @@ -10,7 +10,7 @@ #pragma once -#include <ConexDynamicInterface.h> +//#include <ConexDynamicInterface.h> namespace corsika::process::CONEX { diff --git a/Processes/CONEX/testConex.cc b/Processes/CONEX/testConex.cc index 1f0bb20591062d0f25a6dd43c61971ee17c6022d..070b460dbf6bd991602abfe953a75dd591543a69 100644 --- a/Processes/CONEX/testConex.cc +++ b/Processes/CONEX/testConex.cc @@ -27,8 +27,8 @@ TEST_CASE("CONEX", "[processes]") { using std::endl; std::string parameterPathName = ""; - auto cxModel = eSibyll23; - ConexDynamicInterface cx(cxModel); + //auto cxModel = eSibyll23; + //ConexDynamicInterface cx(cxModel); int randomSeeds[3]; randomSeeds[0] = 1234; @@ -38,7 +38,7 @@ TEST_CASE("CONEX", "[processes]") { int nShower = 1; // large to avoid final stats. int maxDetail = 0; int particleListMode = 0; - cx.Init(nShower, randomSeeds, maxDetail, particleListMode, parameterPathName); + //cx.Init(nShower, randomSeeds, maxDetail, particleListMode, parameterPathName); double energyInGeV = 100.; double zenith = 60; @@ -46,6 +46,6 @@ TEST_CASE("CONEX", "[processes]") { double impactParameter = 0; int particleType = 100; - cx.RunConex(randomSeeds, energyInGeV, zenith, azimuth, impactParameter, particleType); + //cx.RunConex(randomSeeds, energyInGeV, zenith, azimuth, impactParameter, particleType); } } diff --git a/Processes/CONEXSourceCut/CMakeLists.txt b/Processes/CONEXSourceCut/CMakeLists.txt index 01cf2af5ba0c67fdbd949e19e9eedda7eaa3ff7d..aa6861b14fcb6e09d8a97d7d33ba48054a849a28 100644 --- a/Processes/CONEXSourceCut/CMakeLists.txt +++ b/Processes/CONEXSourceCut/CMakeLists.txt @@ -6,6 +6,7 @@ set ( set ( MODEL_HEADERS CONEXSourceCut.h + CONEX_f.h ) set ( @@ -31,6 +32,8 @@ target_link_libraries ( CORSIKAprocesssequence CORSIKAsetup C8::ext::conex + ProcessSibyll + ProcessUrQMD ) target_include_directories ( diff --git a/Processes/CONEXSourceCut/CONEXSourceCut.cc b/Processes/CONEXSourceCut/CONEXSourceCut.cc index bde3df5b191290db59bcae0fa9635025bd2313e7..1f84fbf257dd969f5452601aad06c13e12d7eee1 100644 --- a/Processes/CONEXSourceCut/CONEXSourceCut.cc +++ b/Processes/CONEXSourceCut/CONEXSourceCut.cc @@ -76,8 +76,10 @@ corsika::process::EProcessReturn CONEXSourceCut::DoSecondaries( << std::endl; p.Delete(); - conex_.Shower(egs_pid, E, x, y, altitude, slantDistance, lateralX, lateralY, slantX, - time, u, v, w, iri, weight, latchin); + //conex_.Shower(egs_pid, E, x, y, altitude, slantDistance, lateralX, lateralY, slantX, + // time, u, v, w, iri, weight, latchin); + conex::show_(egs_pid, E, x, y, altitude, slantDistance, lateralX, lateralY, slantX, + time, u, v, w, iri, weight, latchin); } return corsika::process::EProcessReturn::eOk; @@ -90,12 +92,15 @@ void CONEXSourceCut::SolveCE() { int iCEmode = 1; int id = 0; // RU: max, fix this int nshtot_ = 0; // RU: max, fix this - conex_.HadronCascade(id, nshtot_, zero, iCEmode); - conex_.SolveMomentEquations(zero); + //conex_.HadronCascade(id, nshtot_, zero, iCEmode); + //conex_.SolveMomentEquations(zero); + conex::hadroncascade_(id, nshtot_, zero, iCEmode); + conex::solvemomentequations_(zero); // RU: this here is from cxroot, - int nX = conex_.GetNumberOfDepthBins(); // make sure this works! + //int nX = conex_.GetNumberOfDepthBins(); // make sure this works! + int nX = conex::get_number_of_depth_bins_(); // make sure this works! int icut = 1; int icutg = 2; @@ -119,12 +124,18 @@ void CONEXSourceCut::SolveCE() { float EGround[3], fitpars[13], currlgE, Xmx, Nmx, XmxdEdX, dEdXmx; - conex_.GetShowerData(icut, iSec, nX, X[0], N[0], fitpars[0], H[0], D[0]); - conex_.GetdEdXProfile(icut, nX, dEdX[0], EGround[0]); - conex_.GetMuonProfile(icutm, nX, Mu[0], dMu[0]); - conex_.GetGammaProfile(icutg, nX, Gamma[0]); - conex_.GetElectronProfile(icute, nX, Electrons[0]); - conex_.GetHadronProfile(icuth, nX, Hadrons[0]); + // conex_.GetShowerData(icut, iSec, nX, X[0], N[0], fitpars[0], H[0], D[0]); + // conex_.GetdEdXProfile(icut, nX, dEdX[0], EGround[0]); + // conex_.GetMuonProfile(icutm, nX, Mu[0], dMu[0]); + // conex_.GetGammaProfile(icutg, nX, Gamma[0]); + // conex_.GetElectronProfile(icute, nX, Electrons[0]); + // conex_.GetHadronProfile(icuth, nX, Hadrons[0]); + conex::get_shower_data_(icut, iSec, nX, X[0], N[0], fitpars[0], H[0], D[0]); + conex::get_shower_edep_(icut, nX, dEdX[0], EGround[0]); + conex::get_shower_muon_(icutm, nX, Mu[0], dMu[0]); + conex::get_shower_gamma_(icutg, nX, Gamma[0]); + conex::get_shower_electron_(icute, nX, Electrons[0]); + conex::get_shower_hadron_(icuth, nX, Hadrons[0]); } // RU: move all the non-C8 code from the following c++ function into a new file. Here we @@ -135,8 +146,8 @@ CONEXSourceCut::CONEXSourceCut(geometry::Point center, environment::ShowerAxis s // units::si::GrammageType Xcut, units::si::HEPEnergyType primaryEnergy, particles::PDGCode primaryID) - : conex_{ConexDynamicInterface(eSibyll23)} - , center_{center} + : //conex_{ConexDynamicInterface(eSibyll23)} + center_{center} , showerAxis_{showerAxis} , groundDist_{groundDist} , conexObservationCS_{std::invoke([&]() { @@ -158,14 +169,23 @@ CONEXSourceCut::CONEXSourceCut(geometry::Point center, environment::ShowerAxis s })} , y_sf_{showerAxis_.GetDirection().cross(x_sf_)} { - std::string parameterPathName = ""; - int randomSeeds[3] = {1234, 0, 0}; // will be overwritten later?? - + int heModel = eSibyll23; + int nShower = 1; // large to avoid final stats. int maxDetail = 0; int particleListMode = 0; - conex_.Init(nShower, randomSeeds, maxDetail, particleListMode, parameterPathName); + //conex_.Init(nShower, randomSeeds, maxDetail, particleListMode, parameterPathName); + + std::string configPath = CONEX_CONFIG_PATH; + conex::initconex_(nShower, randomSeeds, + heModel, + maxDetail, +#ifdef CONEX_EXTENSIONS + particleListMode, +#endif + configPath.c_str(), + configPath.size()); double eprima = primaryEnergy / 1_GeV; @@ -189,5 +209,6 @@ CONEXSourceCut::CONEXSourceCut(geometry::Point center, environment::ShowerAxis s std::array<int, 3> ioseed{static_cast<int>(rng()), static_cast<int>(rng()), static_cast<int>(rng())}; - conex_.ConexRun(ipart, eprima, theta, phi, dimpact, ioseed.data()); + //conex_.ConexRun(ipart, eprima, theta, phi, dimpact, ioseed.data()); + conex::conexrun_(ipart, eprima, theta, phi, dimpact, ioseed.data()); } diff --git a/Processes/CONEXSourceCut/CONEXSourceCut.h b/Processes/CONEXSourceCut/CONEXSourceCut.h index 0fb5a3236c47e57da5cb846643ef3d5a85e0c685..1686897a507e2b50396e46fa9df07e45072f97ad 100644 --- a/Processes/CONEXSourceCut/CONEXSourceCut.h +++ b/Processes/CONEXSourceCut/CONEXSourceCut.h @@ -11,8 +11,8 @@ #ifndef _corsika_process_particle_cut_CONEXSourceCut_h_ #define _corsika_process_particle_cut_CONEXSourceCut_h_ -#define __CORSIKA8__ // must define this conex-internal flag -#include <ConexDynamicInterface.h> +//#define __CORSIKA8__ // must define this conex-internal flag +//#include <ConexDynamicInterface.h> #include <corsika/environment/ShowerAxis.h> #include <corsika/geometry/Point.h> @@ -22,29 +22,11 @@ #include <corsika/setup/SetupStack.h> #include <corsika/units/PhysicalUnits.h> -namespace conex { - /* - extern "C" { - // ipart,energy,theta,phi,dimpact,ioseed - void conexrun_(int& ipart, double& energy, double& theta, double& phi, double& - dimpact, int ioseed[3]); void conexcascade_(); void hadroncascade_(int&, int&, int&, - int&); void solvemomentequations_(int&); void show_(int& iqi, double& ei, double& xmi, - double& ymi, double& zmi, double& dmi, double& xi, double& yi, double& zi, double& - tmi, double& ui, double& vi, double& wi, int& iri, double& wti, int& latchi); - - int get_number_of_depth_bins_(); +#include <corsika/process/conex_source_cut/CONEX_f.h> - void get_shower_data_(const int&, const int&, const int&, float&, float&, - float&, float&, float&); - void get_shower_edep_(const int&, const int&, float&, float&); - void get_shower_muon_(const int&, const int&, float&, float&); - void get_shower_gamma_(const int&, const int&, float&); - void get_shower_electron_(const int&, const int&, float&); - void get_shower_hadron_(const int&, const int&, float&); - } - */ +namespace conex { corsika::units::si::LengthType constexpr earthRadius{6371315 * - corsika::units::si::meter}; + corsika::units::si::meter}; } // namespace conex namespace corsika::process { @@ -63,7 +45,7 @@ namespace corsika::process { void SolveCE(); private: - ConexDynamicInterface conex_; + //ConexDynamicInterface conex_; //! CONEX e.m. particle codes static std::array<std::pair<particles::Code, int>, 3> constexpr egs_em_codes_{ diff --git a/Processes/CONEXSourceCut/CONEX_f.h b/Processes/CONEXSourceCut/CONEX_f.h index bbb09cb3dd7adde629c7c2f8a764c62172dd9543..a00bc7e35dac6351060f7f6db2dd3f509b093105 100644 --- a/Processes/CONEXSourceCut/CONEX_f.h +++ b/Processes/CONEXSourceCut/CONEX_f.h @@ -15,134 +15,37 @@ //---------------------------------------------- // wrapper -extern "C" { -struct cxcut_ { - double eecut; - double epcut; - double ehcut; - double emcut; -}; - -struct cxsubcut_ { - double feecut_; - double fehcut_; - double femcut_; -}; - -struct cxbas4_ { - double eprima_; - double thetas_; - double costhet_; - double phisho_; - int muse; - int musz; - double c2bas; - double sinthet; - double sinphi; - double XminSlant; - double HGrd; - double distMaxi; -}; - -struct cxoptl_ { - // struct cxoptl_ { - // std::array<double, 16> dptl; - //}; - - struct dptl_ { - double px, py, pz, E, m; // 5-momentum - double x, y; - double h; - double t; - double id; - double weight; - double generation; - double Xslant; - double lateralX, lateralY; - double slantDistance; - }; -}; - -struct cxbas6_ { - double altitude; - double RadGrd; - double DistALt; - double dphmaxi0; - double dphlim0; - double dphmin0; - bool goOutGrd; -}; - -struct cxetc_ { - int mode; - int iwrt; - int i1DMC; - int iphonu; -}; - -struct cxthin_ { - double thin; - double ethin; - double wtmax; - double rthmax; - int iothin; -}; - -int constexpr mxExpro = 1; -int constexpr mxPxpro = 10; -int constexpr maximE = 281; -// CONEX ifdef -#ifdef __SAVEMEMO__ -int constexpr maximZ = 201; -#else -int constexpr maximZ = 3701; +#include <conexConfig.h> +#include <conexHEModels.h> + +namespace conex { + + extern "C" { + // ipart,energy,theta,phi,dimpact,ioseed + void initconex_(int&, int*, int&, int&, +#ifdef CONEX_EXTENSIONS + int&, #endif - -struct cxoutput3_ { - std::array<std::array<double, 4>, mxPxpro + 2> XmaxShow; - std::array<std::array<double, 5>, mxPxpro + 2> XmaxMean; - std::array<std::array<double, maximZ>, mxPxpro> XmaxProf; - int iXmax; -}; - -struct cxoutput1_ { - std::array<std::array<std::array<double, maximZ>, mxExpro>, mxPxpro + 2> XProf, XmeanP, - XmeanP2; - std::array<double, mxExpro> EMCutP, HaCutP; - double XminP; - double XmaxP; - int nminX; - int nmaxX; - int mZEMHa; - int ifout; - int ivers; - bool lheader; -}; - -/* - common/cxoutput3/XmaxShow(4,-1:mxPxpro),XmaxMean(5,-1:mxPxpro) - &,XmaxProf(maximz,-1:mxPxpro),iXmax - common/cxoutput1/XProf(maximz,mxExpro,-1:mxPxpro) - &,XmeanP(maximz,mxExpro,-1:mxPxpro) - &,XmeanP2(maximz,mxExpro,-1:mxPxpro) - &,EMCutP(mxExpro),HaCutP(mxExpro),XminP,XmaxP - &,nminX,nmaxX,mZEMHa,ifout,ivers,lheader -*/ - -int InitialParticle_(int&); -void HadronCascade_(int&, int&, int&, int&); -void SolveMomentEquations_(int&); -void show_(int& iqi, double& ei, double& xmi, double& ymi, double& zmi, double& dmi, - double& xi, double& yi, double& zi, double& tmi, double& ui, double& vi, - double& wi, int& iri, double& wti, int& latchi); - -int get_number_of_depth_bins_(); - -void get_shower_data_(const int&, const int&, const int&, float&, float&, float&, float&, - float&); -void get_shower_edep_(const int&, const int&, float&, float&); -void get_shower_muon_(const int&, const int&, float&, float&); -void get_shower_gamma_(const int&, const int&, float&); -void get_shower_electron_(const int&, const int&, float&); -void get_shower_hadron_(const int&, const int&, float&); + const char*, int); + void conexrun_(int& ipart, double& energy, double& theta, double& phi, double& + dimpact, int ioseed[3]); + void conexcascade_(); + void hadroncascade_(int&, int&, int&, + int&); + void solvemomentequations_(int&); + void show_(int& iqi, double& ei, double& xmi, + double& ymi, double& zmi, double& dmi, double& xi, double& yi, double& zi, double& + tmi, double& ui, double& vi, double& wi, int& iri, double& wti, int& latchi); + + int get_number_of_depth_bins_(); + + void get_shower_data_(const int&, const int&, const int&, float&, float&, + float&, float&, float&); + void get_shower_edep_(const int&, const int&, float&, float&); + void get_shower_muon_(const int&, const int&, float&, float&); + void get_shower_gamma_(const int&, const int&, float&); + void get_shower_electron_(const int&, const int&, float&); + void get_shower_hadron_(const int&, const int&, float&); + } + } diff --git a/ThirdParty/CMakeLists.txt b/ThirdParty/CMakeLists.txt index f0c73e78c39a002335865f1ef05ef562d1a1cdb5..979d960e677e9790c0156f9b5320a092514b5faa 100644 --- a/ThirdParty/CMakeLists.txt +++ b/ThirdParty/CMakeLists.txt @@ -269,7 +269,8 @@ else () ) set (CONEX_FOUND 1 PARENT_SCOPE) ExternalProject_Get_Property (cxroot INSTALL_DIR) - set (CONEX_PREFIX ${INSTALL_DIR}) + get_filename_component(INSTALL_DIR_ABS ${INSTALL_DIR} ABSOLUTE) + set (CONEX_PREFIX ${INSTALL_DIR_ABS}) set (CONEX_INCLUDE_DIR ${CONEX_PREFIX}/src) set (CONEX_INCLUDE_DIR ${CONEX_PREFIX}/src PARENT_SCOPE) add_dependencies (C8::ext::conex cxroot) @@ -279,8 +280,9 @@ else () set_target_properties ( C8::ext::conex PROPERTIES - IMPORTED_LOCATION ${CONEX_PREFIX}/lib/${CMAKE_SYSTEM_NAME}/libCONEXdynamic.a - IMPORTED_LINK_INTERFACE_LIBRARIES dl + IMPORTED_LOCATION ${CONEX_PREFIX}/lib/${CMAKE_SYSTEM_NAME}/libCONEXsibyll.so + IMPORTED_NO_SONAME 1 + SKIP_BUILD_RPATH FALSE INTERFACE_INCLUDE_DIRECTORIES $<BUILD_INTERFACE:${CONEX_INCLUDE_DIR}> )