diff --git a/.gitmodules b/.gitmodules index cb79c58058e9360e53f096be77cbf0ee2aca2282..f79f2dd4cf234c1d437eb19b69900bd3d40798d3 100644 --- a/.gitmodules +++ b/.gitmodules @@ -6,3 +6,6 @@ path = ThirdParty/spdlog url = https://github.com/gabime/spdlog.git shallow = true +[submodule "Processes/Proposal/PROPOSAL"] + path = Processes/Proposal/PROPOSAL + url = https://github.com/tudo-astroparticlephysics/PROPOSAL.git diff --git a/Documentation/Examples/CMakeLists.txt b/Documentation/Examples/CMakeLists.txt index 1c4a2e76c84b9d32a567fd07792987841416b784..50c937f1415e3c4115c6299970664a795a42092c 100644 --- a/Documentation/Examples/CMakeLists.txt +++ b/Documentation/Examples/CMakeLists.txt @@ -14,26 +14,51 @@ target_link_libraries (stack_example SuperStupidStack CORSIKAunits) # address sanitizer is making this example too slow, so we only do "undefined" CORSIKA_ADD_EXAMPLE (boundary_example) target_link_libraries (boundary_example - SuperStupidStack - CORSIKAunits - CORSIKAlogging - CORSIKArandom - ProcessSibyll - ProcessPythia8 - ProcessProposal - CORSIKAcascade - ProcessTrackWriter - ProcessParticleCut - ProcessTrackingLine - CORSIKAprocesses - CORSIKAparticles - CORSIKAgeometry - CORSIKAenvironment - CORSIKAprocesssequence - ) + SuperStupidStack + CORSIKAunits + CORSIKAlogging + CORSIKArandom + ProcessSibyll + CORSIKAcascade + ProcessTrackWriter + ProcessParticleCut + ProcessTrackingLine + ProcessPythia8 + ProcessProposal + CORSIKAprocesses + CORSIKAparticles + CORSIKAgeometry + CORSIKAenvironment + CORSIKAprocesssequence + ) CORSIKA_ADD_EXAMPLE (cascade_example) target_link_libraries (cascade_example + SuperStupidStack + CORSIKAunits + CORSIKAlogging + CORSIKArandom + ProcessSibyll + ProcessProposal + CORSIKAcascade + ProcessEnergyLoss + ProcessTrackWriter + ProcessStackInspector + ProcessTrackingLine + ProcessParticleCut + ProcessHadronicElasticModel + ProcessStackInspector + CORSIKAprocesses + CORSIKAcascade + CORSIKAparticles + CORSIKAgeometry + CORSIKAenvironment + CORSIKAprocesssequence + ) + +if (Pythia8_FOUND) + CORSIKA_ADD_EXAMPLE (cascade_proton_example) + target_link_libraries (cascade_proton_example SuperStupidStack CORSIKAunits CORSIKAlogging @@ -48,7 +73,6 @@ target_link_libraries (cascade_example ProcessTrackWriter ProcessStackInspector ProcessTrackingLine - ProcessProposal ProcessParticleCut ProcessOnShellCheck ProcessHadronicElasticModel @@ -61,91 +85,25 @@ target_link_libraries (cascade_example CORSIKAprocesssequence ) -if (Pythia8_FOUND) - CORSIKA_ADD_EXAMPLE (cascade_proton_example) - target_link_libraries (cascade_proton_example - SuperStupidStack - CORSIKAunits - CORSIKAlogging - CORSIKArandom - ProcessSibyll - ProcessPythia - CORSIKAcascade - ProcessEnergyLoss - ProcessTrackWriter - ProcessStackInspector - ProcessTrackingLine - ProcessParticleCut - ProcessHadronicElasticModel - ProcessStackInspector - CORSIKAprocesses - CORSIKAcascade - CORSIKAparticles - CORSIKAgeometry - CORSIKAenvironment - CORSIKAprocesssequence - ) - - CORSIKA_ADD_EXAMPLE (vertical_EAS RUN_OPTIONS 4 2 10000.) - target_link_libraries (vertical_EAS - SuperStupidStack - CORSIKAunits - CORSIKAlogging - CORSIKArandom - ProcessSibyll - ProcessPythia - ProcessUrQMD - ProcessSwitch - CORSIKAcascade - ProcessEnergyLoss - ProcessObservationPlane - ProcessInteractionCounter - ProcessTrackWriter - ProcessTrackingLine - ProcessParticleCut - ProcessStackInspector - ProcessLongitudinalProfile - CORSIKAprocesses - CORSIKAcascade - CORSIKAparticles - CORSIKAgeometry - CORSIKAenvironment - CORSIKAprocesssequence - ) -endif() - -CORSIKA_ADD_EXAMPLE (stopping_power stopping_power) -target_link_libraries (stopping_power - SuperStupidStack - CORSIKAunits - ProcessEnergyLoss - CORSIKAparticles - CORSIKAgeometry - CORSIKAenvironment - ) - -CORSIKA_ADD_EXAMPLE (staticsequence_example) -target_link_libraries (staticsequence_example - CORSIKAprocesssequence - CORSIKAunits - CORSIKAgeometry - CORSIKAlogging) - -CORSIKA_ADD_EXAMPLE (proposal_example RUN_OPTIONS 100.) -target_link_libraries (proposal_example + CORSIKA_ADD_EXAMPLE (vertical_EAS RUN_OPTIONS 4 2 10000.) + target_link_libraries (vertical_EAS SuperStupidStack CORSIKAunits CORSIKAlogging CORSIKArandom CORSIKAcascade + ProcessProposal + ProcessPythia8 ProcessObservationPlane ProcessInteractionCounter ProcessTrackWriter - ProcessProposal + ProcessEnergyLoss ProcessTrackingLine ProcessParticleCut + ProcessOnShellCheck ProcessStackInspector ProcessLongitudinalProfile + ProcessCONEXSourceCut CORSIKAprocesses CORSIKAcascade CORSIKAparticles @@ -153,3 +111,52 @@ target_link_libraries (proposal_example CORSIKAenvironment CORSIKAprocesssequence ) +endif() + +CORSIKA_ADD_EXAMPLE (stopping_power stopping_power) +target_link_libraries (stopping_power + SuperStupidStack + CORSIKAunits + ProcessEnergyLoss + CORSIKAparticles + CORSIKAgeometry + CORSIKAenvironment + ) + +CORSIKA_ADD_EXAMPLE (staticsequence_example) +target_link_libraries (staticsequence_example + CORSIKAprocesssequence + CORSIKAunits + CORSIKAgeometry + CORSIKAlogging) + + +CORSIKA_ADD_EXAMPLE (proposal_example RUN_OPTIONS 100.) +target_link_libraries (proposal_example + SuperStupidStack + CORSIKAunits + CORSIKAlogging + CORSIKArandom + ProcessSibyll + ProcessPythia8 + ProcessUrQMD + ProcessSwitch + CORSIKAcascade + ProcessCONEXSourceCut + ProcessEnergyLoss + ProcessObservationPlane + ProcessInteractionCounter + ProcessTrackWriter + ProcessProposal + ProcessTrackingLine + ProcessParticleCut + ProcessOnShellCheck + ProcessStackInspector + ProcessLongitudinalProfile + CORSIKAprocesses + CORSIKAcascade + CORSIKAparticles + CORSIKAgeometry + CORSIKAenvironment + CORSIKAprocesssequence + ) diff --git a/Documentation/Examples/boundary_example.cc b/Documentation/Examples/boundary_example.cc index caaa087a4fb1e32b52daf54276c23626b419d4f0..26a8239bda592c1b9d45ed2536677cdf31f00e34 100644 --- a/Documentation/Examples/boundary_example.cc +++ b/Documentation/Examples/boundary_example.cc @@ -118,7 +118,7 @@ int main() { process::sibyll::Interaction sibyll; process::sibyll::Decay decay; - process::particle_cut::ParticleCut cut(20_GeV); + process::particle_cut::ParticleCut cut(20_GeV, true, true); process::track_writer::TrackWriter trackWriter("tracks.dat"); MyBoundaryCrossingProcess<true> boundaryCrossing("crossings.dat"); diff --git a/Documentation/Examples/cascade_example.cc b/Documentation/Examples/cascade_example.cc index 7aa0561c0e2849fa32e25fa1cf1a9d5f00f564b5..b77dcea923b9c5c40137420c893c72b47561a579 100644 --- a/Documentation/Examples/cascade_example.cc +++ b/Documentation/Examples/cascade_example.cc @@ -23,7 +23,7 @@ #include <corsika/geometry/Sphere.h> -#include <corsika/process/proposal/Interaction.h> +//#include <corsika/process/proposal/Interaction.h> #include <corsika/process/sibyll/Decay.h> #include <corsika/process/sibyll/Interaction.h> @@ -137,19 +137,19 @@ int main() { random::RNGManager::GetInstance().RegisterRandomStream("sibyll"); random::RNGManager::GetInstance().RegisterRandomStream("pythia"); - random::RNGManager::GetInstance().RegisterRandomStream("proposal"); + //random::RNGManager::GetInstance().RegisterRandomStream("proposal"); process::sibyll::Interaction sibyll; process::sibyll::NuclearInteraction sibyllNuc(sibyll, env); process::sibyll::Decay decay; // cascade with only HE model ==> HE cut - process::particle_cut::ParticleCut cut(80_GeV); - process::proposal::Interaction proposal(env, cut); + process::particle_cut::ParticleCut cut(80_GeV, true, true); + //process::proposal::Interaction proposal(env, cut); process::track_writer::TrackWriter trackWriter("tracks.dat"); process::energy_loss::EnergyLoss eLoss{showerAxis}; // assemble all processes into an ordered process list - auto sequence = stackInspect << sibyll << sibyllNuc << proposal << decay + auto sequence = stackInspect << sibyll << sibyllNuc /* << proposal*/ << decay /* << eLoss */ << cut << trackWriter; diff --git a/Documentation/Examples/cascade_proton_example.cc b/Documentation/Examples/cascade_proton_example.cc index 996d67eb9fd3383801f150c2eb6d50c87f2da36d..12f758a0d02653905a62df5d0d229b395cf74c59 100644 --- a/Documentation/Examples/cascade_proton_example.cc +++ b/Documentation/Examples/cascade_proton_example.cc @@ -123,7 +123,7 @@ int main() { // process::sibyll::NuclearInteraction sibyllNuc(env, sibyll); // process::sibyll::Decay decay; process::pythia::Decay decay; - process::particle_cut::ParticleCut cut(20_GeV); + process::particle_cut::ParticleCut cut(20_GeV, true, true); // random::RNGManager::GetInstance().RegisterRandomStream("HadronicElasticModel"); // process::HadronicElasticModel::HadronicElasticInteraction diff --git a/Documentation/Examples/proposal_example.cc b/Documentation/Examples/proposal_example.cc index de16fc65db2f361cea0ccb74aa28d8cbe089bf3d..d0699c45e69f9d0cf934c60bddab4780db388e0d 100644 --- a/Documentation/Examples/proposal_example.cc +++ b/Documentation/Examples/proposal_example.cc @@ -1,7 +1,5 @@ /* - * (c) Copyright 2018 CORSIKA Project, corsika-project@lists.kit.edu - * - * See file AUTHORS for a list of contributors. + * (c) Copyright 2020 CORSIKA Project, corsika-project@lists.kit.edu * * This software is distributed under the terms of the GNU General Public * Licence version 3 (GPL Version 3). See file LICENSE for a full version of @@ -107,8 +105,8 @@ int main(int argc, char** argv) { cout << "input momentum: " << plab.GetComponents() / 1_GeV << ", norm = " << plab.norm() << endl; - auto const observationHeight = 1.4_km + builder.earthRadius; - auto const injectionHeight = 112.75_km + builder.earthRadius; + auto const observationHeight = 1.4_km + builder.getEarthRadius(); + auto const injectionHeight = 112.75_km + builder.getEarthRadius(); auto const t = -observationHeight * cos(thetaRad) + sqrt(-si::detail::static_pow<2>(sin(thetaRad) * observationHeight) + si::detail::static_pow<2>(injectionHeight)); @@ -136,15 +134,12 @@ int main(int argc, char** argv) { PROPOSAL::InterpolationDef::path_to_tables = "~/.local/share/PROPOSAL/tables/"; PROPOSAL::InterpolationDef::path_to_tables_readonly = "~/.local/share/PROPOSAL/tables/"; - process::particle_cut::ParticleCut cut(10_GeV); + process::particle_cut::ParticleCut cut(10_GeV, false, true); process::proposal::Interaction proposal(env, cut); process::proposal::ContinuousProcess em_continuous(env, cut); process::interaction_counter::InteractionCounter proposalCounted(proposal); process::track_writer::TrackWriter trackWriter("tracks.dat"); - // energy cut; n.b. ParticleCut needs to be modified not to discard EM particles! - /* process::particle_cut::ParticleCut cut{60_GeV}; */ - // long. profile; columns for gamma, e+, e- still need to be added process::longitudinal_profile::LongitudinalProfile longprof{showerAxis}; @@ -161,7 +156,6 @@ int main(int argc, char** argv) { // define air shower object, run simulation tracking_line::TrackingLine tracking; cascade::Cascade EAS(env, tracking, sequence, stack); - EAS.Init(); // to fix the point of first interaction, uncomment the following two lines: // EAS.SetNodes(); diff --git a/Documentation/Examples/vertical_EAS.cc b/Documentation/Examples/vertical_EAS.cc index 17a80986d0485df5043a1216926ca1da9f542f2f..60d4f3fc9d4d699baa6af054a3f8b8c849addac0 100644 --- a/Documentation/Examples/vertical_EAS.cc +++ b/Documentation/Examples/vertical_EAS.cc @@ -181,7 +181,7 @@ int main(int argc, char** argv) { decaySibyll.PrintDecayConfig(); - process::particle_cut::ParticleCut cut{60_GeV}; + process::particle_cut::ParticleCut cut{60_GeV, true, true}; process::on_shell_check::OnShellCheck reset_particle_mass(1.e-3, 1.e-1, false); diff --git a/Processes/CMakeLists.txt b/Processes/CMakeLists.txt index c405641bbcbbae6bc614cb8f6f377465c41a700f..509bf305e20364d1151c9ad101504eec5245191a 100644 --- a/Processes/CMakeLists.txt +++ b/Processes/CMakeLists.txt @@ -13,7 +13,6 @@ if (CONEX_FOUND) endif (CONEX_FOUND) add_subdirectory (HadronicElasticModel) add_subdirectory (UrQMD) -add_subdirectory (SwitchProcess) add_subdirectory (Proposal) # continuous physics @@ -34,15 +33,15 @@ add_subdirectory (SwitchProcess) ########################################## # add_custom_target(CORSIKAprocesses) add_library (CORSIKAprocesses INTERFACE) -add_dependencies(CORSIKAprocesses ProcessNullModel) -add_dependencies(CORSIKAprocesses ProcessSibyll) -add_dependencies(CORSIKAprocesses ProcessProposal) +add_dependencies (CORSIKAprocesses ProcessNullModel) +add_dependencies (CORSIKAprocesses ProcessSibyll) +add_dependencies (CORSIKAprocesses ProcessProposal) if (Pythia8_FOUND) - add_dependencies(CORSIKAprocesses ProcessPythia) + add_dependencies (CORSIKAprocesses ProcessPythia8) endif (Pythia8_FOUND) -add_dependencies(CORSIKAprocesses ProcessStackInspector) -add_dependencies(CORSIKAprocesses ProcessTrackingLine) -add_dependencies(CORSIKAprocesses ProcessEnergyLoss) -add_dependencies(CORSIKAprocesses ProcessUrQMD) -add_dependencies(CORSIKAprocesses ProcessParticleCut) -add_dependencies(CORSIKAprocesses ProcessOnShellCheck) +add_dependencies (CORSIKAprocesses ProcessStackInspector) +add_dependencies (CORSIKAprocesses ProcessTrackingLine) +add_dependencies (CORSIKAprocesses ProcessEnergyLoss) +add_dependencies (CORSIKAprocesses ProcessUrQMD) +add_dependencies (CORSIKAprocesses ProcessParticleCut) +add_dependencies (CORSIKAprocesses ProcessOnShellCheck) diff --git a/Processes/ParticleCut/ParticleCut.cc b/Processes/ParticleCut/ParticleCut.cc index 1a154b2825cd80c4d9d6d4adf3ab280f0dba76e7..659a94c6f1452742667a7c72f5f97f7dfe69dec6 100644 --- a/Processes/ParticleCut/ParticleCut.cc +++ b/Processes/ParticleCut/ParticleCut.cc @@ -34,7 +34,6 @@ namespace corsika::process { } bool ParticleCut::ParticleIsEmParticle(Code vCode) const { - // FOR NOW: switch switch (vCode) { case Code::Gamma: case Code::Electron: @@ -66,13 +65,12 @@ namespace corsika::process { C8LOG_DEBUG(fmt::format("ParticleCut: checking {}, E= {} GeV, EcutTot={} GeV", pid, energy / 1_GeV, (fEmEnergy + fInvEnergy + fEnergy) / 1_GeV)); - /* if (ParticleIsEmParticle(pid)) { */ - /* C8LOG_DEBUG("removing em. particle..."); */ - /* fEmEnergy += energy; */ - /* fEmCount += 1; */ - /* return true; */ - /* } else */ - if (ParticleIsInvisible(pid)) { + if (bCutEm &&ParticleIsEmParticle(pid)) { + C8LOG_DEBUG("removing em. particle..."); + fEmEnergy += energy; + fEmCount += 1; + return true; + } else if (bCutInv && ParticleIsInvisible(pid)) { C8LOG_DEBUG("removing inv. particle..."); fInvEnergy += energy; fInvCount += 1; @@ -110,14 +108,14 @@ namespace corsika::process { return process::EProcessReturn::eOk; } - ParticleCut::ParticleCut(const units::si::HEPEnergyType vCut) - : fECut(vCut) { + ParticleCut::ParticleCut(const units::si::HEPEnergyType eCut, bool em, bool inv) + : eCut_(eCut), cutEm_(em), cutInv_(inv) { - fEmEnergy = 0._GeV; - fEmCount = 0; - fInvEnergy = 0._GeV; - fInvCount = 0; - fEnergy = 0._GeV; + fEmEnergy = 0_GeV; + uiEmCount = 0; + finvEnergy = 0_GeV; + uiInvCount = 0; + fEnergy = 0_GeV; } void ParticleCut::ShowResults() { @@ -130,7 +128,7 @@ namespace corsika::process { " no. of inv. particles injected: {}\n" " energy below particle cut (GeV): {}\n" " ******************************", - fEmEnergy / 1_GeV, fEmCount, fInvEnergy / 1_GeV, fInvCount, fEnergy / 1_GeV)); + fEmEnergy / 1_GeV, uiEmCount, fInvEnergy / 1_GeV, uiInvCount, fEnergy / 1_GeV)); } } // namespace particle_cut } // namespace corsika::process diff --git a/Processes/ParticleCut/ParticleCut.h b/Processes/ParticleCut/ParticleCut.h index af73dbb4704ff9e1e4fb07824d356f2bfedfa9bb..a7f3898b175ef9ba97f4b894eef80bfa40640627 100644 --- a/Processes/ParticleCut/ParticleCut.h +++ b/Processes/ParticleCut/ParticleCut.h @@ -19,20 +19,18 @@ namespace corsika::process { class ParticleCut : public process::SecondariesProcess<ParticleCut>, public corsika::process::ContinuousProcess<ParticleCut> { - using Particle = corsika::setup::Stack::ParticleType; - using Track = corsika::setup::Trajectory; - - units::si::HEPEnergyType const fECut; + units::si::HEPEnergyType const fECut_; + bool bCutEm; + bool bCutInv; units::si::HEPEnergyType fEnergy = 0 * units::si::electronvolt; units::si::HEPEnergyType fEmEnergy = 0 * units::si::electronvolt; - unsigned int fEmCount = 0; + unsigned int uiEmCount = 0; units::si::HEPEnergyType fInvEnergy = 0 * units::si::electronvolt; - unsigned int fInvCount = 0; + unsigned int uiInvCount = 0; public: - ParticleCut(const units::si::HEPEnergyType eCut) - : fECut(eCut) {} + ParticleCut(const units::si::HEPEnergyType eCut, bool em, bool inv); EProcessReturn DoSecondaries(corsika::setup::StackView&); @@ -45,13 +43,6 @@ namespace corsika::process { void ShowResults(); - units::si::HEPEnergyType GetECut() const { return fECut; } - units::si::HEPEnergyType GetInvEnergy() const { return fInvEnergy; } - units::si::HEPEnergyType GetCutEnergy() const { return fEnergy; } - units::si::HEPEnergyType GetEmEnergy() const { return fEmEnergy; } - unsigned int GetNumberEmParticles() const { return fEmCount; } - unsigned int GetNumberInvParticles() const { return fInvCount; } - protected: template <typename TParticle> bool checkCutParticle(const TParticle& p); @@ -60,7 +51,15 @@ namespace corsika::process { bool ParticleIsBelowEnergyCut(TParticle const&) const; bool ParticleIsEmParticle(particles::Code) const; - bool ParticleIsInvisible(particles::Code) const; + + void ShowResults(); + + units::si::HEPEnergyType GetECut() const { return fECut; } + units::si::HEPEnergyType GetInvEnergy() const { return fInvEnergy; } + units::si::HEPEnergyType GetCutEnergy() const { return fEnergy; } + units::si::HEPEnergyType GetEmEnergy() const { return fEmEnergy; } + unsigned int GetNumberEmParticles() const { return uiEmCount; } + unsigned int GetNumberInvParticles() const { return fInvCount; } }; } // namespace particle_cut } // namespace corsika::process diff --git a/Processes/ParticleCut/testParticleCut.cc b/Processes/ParticleCut/testParticleCut.cc index b3d375f206ae1cd3c61cfdcdd53c5408f7a0cb68..7b3ce99eae1a166bc50efca8b40113872f8b3713 100644 --- a/Processes/ParticleCut/testParticleCut.cc +++ b/Processes/ParticleCut/testParticleCut.cc @@ -43,9 +43,9 @@ TEST_CASE("ParticleCut", "[processes]") { particles::Code::Electron, particles::Code::MuPlus, particles::Code::NuE, particles::Code::Neutron}; - SECTION("cut on particle type") { + SECTION("cut on particle type: inv") { - ParticleCut cut(20_GeV); + ParticleCut cut(20_GeV, false, true); // add primary particle to stack auto particle = stack.AddParticle( @@ -70,11 +70,41 @@ TEST_CASE("ParticleCut", "[processes]") { cut.DoSecondaries(view); - REQUIRE(view.GetSize() == 8); + CHECK(view.GetSize() == 9); } + SECTION("cut on particle type: em") { + + ParticleCut cut(20_GeV, true, false); + + // add primary particle to stack + auto particle = stack.AddParticle( + std::tuple<particles::Code, units::si::HEPEnergyType, + corsika::stack::MomentumVector, geometry::Point, units::si::TimeType>{ + particles::Code::Proton, Eabove, + corsika::stack::MomentumVector(rootCS, {0_GeV, 0_GeV, 0_GeV}), + geometry::Point(rootCS, 0_m, 0_m, 0_m), 0_ns}); + // view on secondary particles + corsika::stack::SecondaryView view(particle); + // ref. to primary particle through the secondary view. + // only this way the secondary view is populated + auto projectile = view.GetProjectile(); + // add secondaries, all with energies above the threshold + // only cut is by species + for (auto proType : particleList) + projectile.AddSecondary(std::tuple<particles::Code, units::si::HEPEnergyType, + corsika::stack::MomentumVector, geometry::Point, + units::si::TimeType>{ + proType, Eabove, corsika::stack::MomentumVector(rootCS, {0_GeV, 0_GeV, 0_GeV}), + geometry::Point(rootCS, 0_m, 0_m, 0_m), 0_ns}); + + cut.DoSecondaries(view); + + CHECK(view.GetSize() == 9); + } + SECTION("cut low energy") { - ParticleCut cut(20_GeV); + ParticleCut cut(20_GeV, true, true); // add primary particle to stack auto particle = stack.AddParticle( @@ -99,6 +129,6 @@ TEST_CASE("ParticleCut", "[processes]") { cut.DoSecondaries(view); - REQUIRE(view.GetSize() == 0); + CHECK(view.GetSize() == 0); } } diff --git a/Processes/Proposal/CMakeLists.txt b/Processes/Proposal/CMakeLists.txt index 8d2a19788215b616ca2d6dd28199212ce8fc2918..c3bc28b8379eccd948b489ee7c035225c0eb416a 100644 --- a/Processes/Proposal/CMakeLists.txt +++ b/Processes/Proposal/CMakeLists.txt @@ -1,5 +1,4 @@ -# find_package(PROPOSAL REQUIRED ${LIB_INCLUDE}) - +add_subdirectory (PROPOSAL) FILE (GLOB MODEL_SOURCES *.cc) FILE (GLOB MODEL_HEADERS *.h) @@ -8,9 +7,10 @@ SET (MODEL_NAMESPACE corsika/process/proposal) ADD_LIBRARY (ProcessProposal STATIC ${MODEL_SOURCES}) CORSIKA_COPY_HEADERS_TO_NAMESPACE (ProcessProposal ${MODEL_NAMESPACE} ${MODEL_HEADERS}) -SET_TARGET_PROPERTIES ( ProcessProposal PROPERTIES VERSION ${PROJECT_VERSION} - SOVERSION 1 - # PUBLIC_HEADER "${MODEL_HEADERS}" +SET_TARGET_PROPERTIES ( + ProcessProposal + PROPERTIES VERSION ${PROJECT_VERSION} + SOVERSION 1 ) TARGET_LINK_LIBRARIES ( @@ -21,7 +21,7 @@ TARGET_LINK_LIBRARIES ( CORSIKAthirdparty CORSIKAgeometry CORSIKAenvironment - ${PROPOSAL_LIBRARY} + PROPOSAL::PROPOSAL ) TARGET_INCLUDE_DIRECTORIES ( @@ -31,16 +31,8 @@ TARGET_INCLUDE_DIRECTORIES ( $<INSTALL_INTERFACE:include/include> ) -TARGET_INCLUDE_DIRECTORIES ( - ProcessProposal - SYSTEM - PUBLIC ${PROPOSAL_INCLUDE_DIR} - INTERFACE ${PROPOSAL_INCLUDE_DIR} - ) - INSTALL ( TARGETS ProcessProposal LIBRARY DESTINATION lib ARCHIVE DESTINATION lib -# PUBLIC_HEADER DESTINATION include/${MODEL_NAMESPACE} ) diff --git a/Processes/Proposal/CMakeLists_PROPOSAL.txt b/Processes/Proposal/CMakeLists_PROPOSAL.txt new file mode 100644 index 0000000000000000000000000000000000000000..e947d10e96670342f6f64375219ff5a615c84045 --- /dev/null +++ b/Processes/Proposal/CMakeLists_PROPOSAL.txt @@ -0,0 +1,179 @@ + +cmake_minimum_required(VERSION 3.8) + +project(PROPOSAL VERSION 6.1.2 LANGUAGES CXX) + +IF(APPLE) + # In newer version of cmake this will be the default + SET(CMAKE_MACOSX_RPATH 1) +ENDIF(APPLE) + +# sets standard installtion paths +include(GNUInstallDirs) + +if(CMAKE_PROJECT_NAME STREQUAL corsika) + message(STATUS "Including PROPOSAL as part of CORSIKA8") + set (IN_CORSIKA8 ON) +else(CMAKE_PROJECT_NAME STREQUAL corsika) + set (IN_CORSIKA8 OFF) +### full RPATH +### copied from https://cmake.org/Wiki/CMake_RPATH_handling +### set the RPATH so that for using PROPOSAL in python +### the DYLD_LIBRARY_PATH must not be set in the bashrc +### But for using PROPOSAL as c-Library, this path still +### has to be set + +# use, i.e. don't skip the full RPATH for the build tree +SET(CMAKE_SKIP_BUILD_RPATH FALSE) + +# when building, don't use the install RPATH already +# (but later on when installing) +OPTION(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) +list(APPEND CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib;${CMAKE_INSTALL_PREFIX}/lib64") +message(STATUS "${CMAKE_INSTALL_RPATH}") + +# add the automatically determined parts of the RPATH +# which point to directories outside the build tree to the install RPATH +OPTION(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) +### end full RPATH + +# Some additional options +OPTION(ADD_PYTHON "Choose to compile the python wrapper library" ON) +endif(CMAKE_PROJECT_NAME STREQUAL corsika) + +################################################################# +#################### PROPOSAL ######################## +################################################################# +file(GLOB_RECURSE SRC_FILES ${PROJECT_SOURCE_DIR}/src/PROPOSAL/*) +if (IN_CORSIKA8) +add_library(PROPOSAL STATIC ${SRC_FILES}) +else (IN_CORSIKA8) +add_library(PROPOSAL SHARED ${SRC_FILES}) +endif (IN_CORSIKA8) + +add_library(PROPOSAL::PROPOSAL ALIAS PROPOSAL) +target_compile_features(PROPOSAL PUBLIC cxx_std_11) +set_target_properties(PROPOSAL PROPERTIES CXX_EXTENSIONS OFF) +target_include_directories( + PROPOSAL PUBLIC + $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> + $<INSTALL_INTERFACE:include> +) +target_compile_options(PROPOSAL PRIVATE -Wall -Wextra -Wnarrowing -Wpedantic -fdiagnostics-show-option -Wno-format-security) +install( + TARGETS PROPOSAL + EXPORT PROPOSALTargets + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} +) + +# input version from the project call, so the library knows its own version +configure_file( + "${PROJECT_SOURCE_DIR}/include/PROPOSAL/version.h.in" + "${PROJECT_BINARY_DIR}/include/PROPOSAL/version.h" +) +install( + FILES ${PROJECT_BINARY_DIR}/include/PROPOSAL/version.h + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/include/PROPOSAL +) +target_include_directories( + PROPOSAL PUBLIC + $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include> + $<INSTALL_INTERFACE:include> +) + +# install header files +file(GLOB_RECURSE INC_FILES ${PROJECT_SOURCE_DIR}/include/*) +foreach(INC_FILE ${INC_FILES}) + file(RELATIVE_PATH REL_FILE ${PROJECT_SOURCE_DIR}/include ${INC_FILE}) + get_filename_component(DIR ${REL_FILE} DIRECTORY) + install(FILES include/${REL_FILE} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${DIR}) +endforeach() + + +if(NOT IS_SYMLINK ${CMAKE_BINARY_DIR}/resources) + execute_process(COMMAND ln -sv ${CMAKE_SOURCE_DIR}/resources ${CMAKE_BINARY_DIR}/resources OUTPUT_VARIABLE link_msg OUTPUT_STRIP_TRAILING_WHITESPACE) + message(STATUS "Symlink to resources created:") + message(STATUS " ${link_msg}") +endif() + + +################################################################# +################# spdlog ####################### +################################################################# + +if (NOT IN_CORSIKA8) +set(CMAKE_POSITION_INDEPENDENT_CODE ON) +add_subdirectory("vendor/spdlog") +endif (NOT IN_CORSIKA8) +target_link_libraries(PROPOSAL PRIVATE spdlog::spdlog) + + +################################################################# +################# Tests ######################## +################################################################# + +if (NOT IN_CORSIKA8) +if(CMAKE_PROJECT_NAME STREQUAL PROPOSAL) + include(CTest) +endif() +if(CMAKE_PROJECT_NAME STREQUAL PROPOSAL AND BUILD_TESTING) + add_subdirectory(tests) +else() + MESSAGE(STATUS "No tests will be build.") +endif() +endif (NOT IN_CORSIKA8) + +################################################################# +################# Documentation ######################## +################################################################# +if (NOT IN_CORSIKA8) +add_subdirectory(doc) +endif (NOT IN_CORSIKA8) + + +################################################################# +################# python ######################### +################################################################# +if (NOT IN_CORSIKA8) +IF(ADD_PYTHON) + message(STATUS "Building the python wrapper library.") + find_package(PythonLibs REQUIRED) + add_subdirectory("vendor/pybind11") + file(GLOB_RECURSE PYTHON_SRC_FILES ${PROJECT_SOURCE_DIR}/interface/python/*) + + pybind11_add_module(pyproposal SHARED ${PYTHON_SRC_FILES}) + set_target_properties(pyproposal PROPERTIES OUTPUT_NAME proposal) + target_include_directories(pyproposal PRIVATE ${PYTHON_INCLUDE_DIRS}) + target_include_directories(pyproposal PRIVATE ${PROJECT_SOURCE_DIR}/interface/python) + target_link_libraries(pyproposal PRIVATE PROPOSAL) + target_compile_options(pyproposal PRIVATE -fvisibility=hidden) + install(TARGETS pyproposal EXPORT PROPOSALTargets DESTINATION ${CMAKE_INSTALL_LIBDIR}) +ELSE(ADD_PYTHON) + MESSAGE(STATUS "No python wrapper library will be build.") +ENDIF(ADD_PYTHON) +endif (NOT IN_CORSIKA8) + + + +################################################################# +################# INSTALLATION ################### +################################################################# +if (NOT IN_CORSIKA8) +install( + EXPORT PROPOSALTargets + FILE PROPOSALConfig.cmake + NAMESPACE PROPOSAL:: + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/PROPOSAL +) + +include(CMakePackageConfigHelpers) +write_basic_package_version_file( + "PROPOSALConfigVersion.cmake" + VERSION ${PACKAGE_VERSION} + COMPATIBILITY SameMajorVersion +) +install( + FILES "${CMAKE_CURRENT_BINARY_DIR}/PROPOSALConfigVersion.cmake" + DESTINATION lib/cmake/PROPOSAL +) +endif (NOT IN_CORSIKA8) diff --git a/Processes/Proposal/ContinuousProcess.cc b/Processes/Proposal/ContinuousProcess.cc index d95202e5de358f102314dde343550f7fe5348f2d..537a2498510128ce245f3372a1b56d58cff689fe 100644 --- a/Processes/Proposal/ContinuousProcess.cc +++ b/Processes/Proposal/ContinuousProcess.cc @@ -1,3 +1,11 @@ +/* + * (c) Copyright 2020 CORSIKA Project, corsika-project@lists.kit.edu + * + * This software is distributed under the terms of the GNU General Public + * Licence version 3 (GPL Version 3). See file LICENSE for a full version of + * the license. + */ + #include <PROPOSAL/PROPOSAL.h> #include <corsika/environment/IMediumModel.h> #include <corsika/environment/NuclearComposition.h> diff --git a/Processes/Proposal/ContinuousProcess.h b/Processes/Proposal/ContinuousProcess.h index 7e234ac632e3a01dd29164e14a6b5d34125f2e06..c5f6fb701390ca52018cf1d308f30dbb06269ffc 100644 --- a/Processes/Proposal/ContinuousProcess.h +++ b/Processes/Proposal/ContinuousProcess.h @@ -1,15 +1,12 @@ /* * (c) Copyright 2018 CORSIKA Project, corsika-project@lists.kit.edu * - * See file AUTHORS for a list of contributors. - * * This software is distributed under the terms of the GNU General Public * Licence version 3 (GPL Version 3). See file LICENSE for a full version of * the license. */ -#ifndef _corsika_process_proposal_interaction_h_ -#define _corsika_process_proposal_interaction_h_ +#pragma once #include <PROPOSAL/PROPOSAL.h> #include <corsika/environment/Environment.h> @@ -19,7 +16,6 @@ #include <corsika/random/RNGManager.h> #include <corsika/random/UniformRealDistribution.h> #include <unordered_map> -#include "PROPOSAL/PROPOSAL.h" using std::unordered_map; @@ -102,8 +98,6 @@ namespace corsika::process::proposal { template <typename TEnvironment> ContinuousProcess(TEnvironment const&, CORSIKA_ParticleCut&); - void Init(){}; - template <typename Particle> corsika::units::si::HEPEnergyType TotalEnergyLoss( Particle const&, corsika::units::si::GrammageType const&); @@ -120,4 +114,3 @@ namespace corsika::process::proposal { }; } // namespace corsika::process::proposal -#endif diff --git a/Processes/Proposal/Interaction.cc b/Processes/Proposal/Interaction.cc index fb567b39813e53dc204ed42a695bc7e8df536b86..b1f25c96e6e389efb2a98bd0ae2a4f6c6761d812 100644 --- a/Processes/Proposal/Interaction.cc +++ b/Processes/Proposal/Interaction.cc @@ -1,3 +1,11 @@ +/* + * (c) Copyright 2020 CORSIKA Project, corsika-project@lists.kit.edu + * + * This software is distributed under the terms of the GNU General Public + * Licence version 3 (GPL Version 3). See file LICENSE for a full version of + * the license. + */ + #include <corsika/environment/IMediumModel.h> #include <corsika/environment/NuclearComposition.h> diff --git a/Processes/Proposal/Interaction.h b/Processes/Proposal/Interaction.h index f3c3b2cf0b61b5a63524332f1f1a12f2b89a9827..6e1b2d57941c204a1a5a1b210c0e62f54a7295c8 100644 --- a/Processes/Proposal/Interaction.h +++ b/Processes/Proposal/Interaction.h @@ -1,15 +1,14 @@ /* - * (c) Copyright 2018 CORSIKA Project, corsika-project@lists.kit.edu - * - * See file AUTHORS for a list of contributors. + * (c) Copyright 2020 CORSIKA Project, corsika-project@lists.kit.edu * * This software is distributed under the terms of the GNU General Public * Licence version 3 (GPL Version 3). See file LICENSE for a full version of * the license. */ -#ifndef _corsika_process_proposal_interaction_h_ -#define _corsika_process_proposalythia_interaction_h_ +#pragma once + +#include <PROPOSAL/PROPOSAL.h> #include <corsika/environment/Environment.h> #include <corsika/particles/ParticleProperties.h> @@ -18,7 +17,6 @@ #include <corsika/random/RNGManager.h> #include <corsika/random/UniformRealDistribution.h> #include <array> -#include "PROPOSAL/PROPOSAL.h" using namespace corsika::environment; using namespace corsika::units::si; @@ -100,8 +98,6 @@ namespace corsika::process::proposal { template <typename TEnvironment> Interaction(TEnvironment const& env, CORSIKA_ParticleCut& cut); - void Init(){}; - template <typename Particle> corsika::process::EProcessReturn DoInteraction(Particle&); @@ -109,4 +105,3 @@ namespace corsika::process::proposal { corsika::units::si::GrammageType GetInteractionLength(TParticle const& p); }; } // namespace corsika::process::proposal -#endif diff --git a/Processes/Proposal/PROPOSAL b/Processes/Proposal/PROPOSAL new file mode 160000 index 0000000000000000000000000000000000000000..db516bd34ea00e8f8711b364a49d87e913ccdaaa --- /dev/null +++ b/Processes/Proposal/PROPOSAL @@ -0,0 +1 @@ +Subproject commit db516bd34ea00e8f8711b364a49d87e913ccdaaa diff --git a/ThirdParty/CMakeLists.txt b/ThirdParty/CMakeLists.txt index b5b2ded0a154b2d591ca7fc3f4152dfa86482382..27c166eb9b76fed84519a37dbf735db0f4c1646f 100644 --- a/ThirdParty/CMakeLists.txt +++ b/ThirdParty/CMakeLists.txt @@ -18,7 +18,7 @@ mark_as_advanced (ThirdPartyChoiceValues) ############################################################################## # Build spdlog -add_subdirectory(spdlog) +add_subdirectory (spdlog) ############################################################################## # check for boost: either use C8 or system-level installation diff --git a/do-copyright.py b/do-copyright.py index a94ee4ddddd5a5e597b18a8afcee7c9e8c919316..4c2b29cc7a2c79418a5a8517018806e6c0aa1a9e 100755 --- a/do-copyright.py +++ b/do-copyright.py @@ -21,7 +21,7 @@ Debug settings are 0: nothing, 1: checking, 2: filesystem """ Debug = 0 -excludeDirs = ["ThirdParty", "git", "build", "install"] +excludeDirs = ["ThirdParty", "git", "build", "install", "PROPOSAL"] excludeFiles = ['PhysicalConstants.h','CorsikaFenvOSX.cc', 'sgn.h'] extensions = [".cc", ".h", ".test"]