IAP GITLAB

Commit 30606dc7 authored by Ralf Ulrich's avatar Ralf Ulrich Committed by Maximilian Sackel

formating and copyrights, clang-format is (now) part of container

parent 5a724d29
......@@ -55,7 +55,7 @@ check-copyrights:
##########################################################
check-clang-format:
image: corsika/devel:u-18.04
image: corsika/devel:clang-8
stage: quality
tags:
- corsika
......@@ -83,7 +83,7 @@ check-clang-format:
before_script:
- cd Data && for F in `find . -name "*.bz2" | grep -v ".git"`; do [ ! -f ${F%%.bz2} ] && bunzip2 -vk $F; done
- cd ${CI_PROJECT_DIR}
script:
script:
- mkdir -p build
- cd build
- cmake .. -DCMAKE_BUILD_TYPE=Debug -DWITH_PYTHIA=ON
......@@ -91,7 +91,7 @@ check-clang-format:
- if: $CI_MERGE_REQUEST_ID
- if: $CI_COMMIT_TAG
- if: $CI_COMMIT_BRANCH
cache:
cache:
paths:
- ${CI_PROJECT_DIR}/build/
- ${CI_PROJECT_DIR}/Data/
......@@ -135,7 +135,7 @@ config-clang-8:
- if: $CI_COMMIT_BRANCH
when: manual
allow_failure: true
cache:
cache:
paths:
- ${CI_PROJECT_DIR}/build/
- ${CI_PROJECT_DIR}/Data/
......@@ -152,7 +152,7 @@ build-u-18_04:
key: "${CI_COMMIT_REF_SLUG}-gcc"
# build for clang
build-clang-8:
build-clang-8:
extends: .build
image: corsika/devel:clang-8
dependencies:
......@@ -175,7 +175,7 @@ build-clang-8:
script:
- cd build
- set -o pipefail
- ctest -j4 -VV | gzip -v -9 > test.log.gz
- ctest -j4 -VV | gzip -v -9 > test.log.gz
rules:
- if: $CI_MERGE_REQUEST_ID
when: manual
......@@ -192,7 +192,7 @@ build-clang-8:
- ${CI_PROJECT_DIR}/build/test_outputs/junit*.xml
paths:
- ${CI_PROJECT_DIR}/build/test.log.gz
cache:
cache:
paths:
- ${CI_PROJECT_DIR}/build/
- ${CI_PROJECT_DIR}/Data/
......@@ -233,7 +233,7 @@ test-clang-8:
- cd build
- cmake --build . -- -j4
- set -o pipefail
- ctest -j4 -VV | gzip -v -9 > test.log.gz
- ctest -j4 -VV | gzip -v -9 > test.log.gz
rules:
- if: '$CI_MERGE_REQUEST_ID && $CI_MERGE_REQUEST_TITLE =~ /^Draft:/'
allow_failure: false
......@@ -249,7 +249,7 @@ test-clang-8:
- ${CI_PROJECT_DIR}/build/test_outputs/junit*.xml
paths:
- ${CI_PROJECT_DIR}/build/test.log.gz
cache:
cache:
paths:
- ${CI_PROJECT_DIR}/build/
- ${CI_PROJECT_DIR}/Data/
......@@ -266,7 +266,7 @@ build_test-u-18_04:
key: "${CI_COMMIT_REF_SLUG}-gcc"
# build_test for clang
build_test-clang-8:
build_test-clang-8:
extends: .build_test
image: corsika/devel:clang-8
dependencies:
......@@ -302,7 +302,7 @@ build_test-clang-8:
expire_in: 3 days
paths:
- ${CI_PROJECT_DIR}/build/examples.log.gz
cache:
cache:
paths:
- ${CI_PROJECT_DIR}/build/
- ${CI_PROJECT_DIR}/Data/
......@@ -310,7 +310,7 @@ build_test-clang-8:
policy: pull
# example for gcc
example-u-18_04:
example-u-18_04:
extends: .example
image: corsika/devel:u-18.04
dependencies:
......@@ -362,7 +362,7 @@ example-clang-8:
paths:
- ${CI_PROJECT_DIR}/build/examples.log.gz
- ${CI_PROJECT_DIR}/build/test.log.gz
cache:
cache:
paths:
- ${CI_PROJECT_DIR}/build/
- ${CI_PROJECT_DIR}/Data/
......@@ -370,7 +370,7 @@ example-clang-8:
policy: pull
# build_test_example for gcc
build_test_example-u-18_04:
build_test_example-u-18_04:
extends: .build_test_example
image: corsika/devel:u-18.04
dependencies:
......@@ -412,7 +412,7 @@ build_test_example-clang-8:
- if: $CI_COMMIT_BRANCH
when: manual
allow_failure: true
cache:
cache:
paths:
- ${CI_PROJECT_DIR}/build/
- ${CI_PROJECT_DIR}/Data/
......@@ -420,7 +420,7 @@ build_test_example-clang-8:
policy: pull
# install for gcc
install-u-18_04:
install-u-18_04:
extends: .install
image: corsika/devel:u-18.04
dependencies:
......@@ -454,7 +454,7 @@ install-clang-8:
- cmake .. -DCMAKE_BUILD_TYPE=Release
- cmake --build . -- -j4
- set -o pipefail
- ctest -j4 -VV | gzip -v -9 > test.log.gz
- ctest -j4 -VV | gzip -v -9 > test.log.gz
- make -j4 run_examples | gzip -v -9 > examples.log.gz
rules:
- if: '$CI_MERGE_REQUEST_LABELS =~ /Ready for code review/' # run on merge requests, if label 'Ready for code review' is set
......@@ -467,7 +467,7 @@ install-clang-8:
- if: $CI_COMMIT_TAG
when: manual
allow_failure: true
cache:
cache:
paths:
- ${CI_PROJECT_DIR}/build/
- ${CI_PROJECT_DIR}/Data/
......@@ -493,7 +493,7 @@ release-full-u-18_04:
key: "${CI_COMMIT_REF_SLUG}-gcc"
# release for clang
release-full-clang-8:
release-full-clang-8:
extends: .release
image: corsika/devel:clang-8
dependencies:
......@@ -518,7 +518,7 @@ coverage:
- cd build
- cmake .. -DCMAKE_BUILD_TYPE=Coverage
- cmake --build . -- -j4
- ctest -j4 -VV | gzip -v -9 > test.log.gz
- ctest -j4 -VV | gzip -v -9 > test.log.gz
- cmake --build . --target coverage
- tar czf coverage-report.tar.gz coverage-report
coverage: '/^.*functions\.+:\s(.*\%)\s/'
......@@ -537,7 +537,7 @@ coverage:
paths:
- ${CI_PROJECT_DIR}/build/test.log.gz
- ${CI_PROJECT_DIR}/build/coverage-report.tar.gz
cache:
cache:
paths:
- ${CI_PROJECT_DIR}/build/
- ${CI_PROJECT_DIR}/Data/
......@@ -577,7 +577,7 @@ documentation:
expire_in: 3 weeks
paths:
- ${CI_PROJECT_DIR}/public
cache:
cache:
paths:
- ${CI_PROJECT_DIR}/build/
- ${CI_PROJECT_DIR}/Data/
......@@ -610,7 +610,7 @@ sanity:
- if: $CI_COMMIT_TAG
when: manual
allow_failure: true
cache:
cache:
paths:
- ${CI_PROJECT_DIR}/build/
- ${CI_PROJECT_DIR}/Data/
......
......@@ -162,5 +162,5 @@ int main() {
<< "relative difference (%): " << (Efinal / E0 - 1) * 100 << endl;
cout << "total dEdX energy (GeV): " << eLoss.GetTotal() / 1_GeV << endl
<< "relative difference (%): " << eLoss.GetTotal() / E0 * 100 << endl;
cut.Reset();
cut.Reset();
}
......@@ -159,15 +159,16 @@ int main(int argc, char** argv) {
cut.ShowResults();
em_continuous.ShowResults();
observationLevel.ShowResults();
cout << "Cascade energy cut: " << EAS.GetEnergyCut()/1_GeV << " GeV" << endl;
const HEPEnergyType Efinal =
cut.GetCutEnergy() + cut.GetInvEnergy() + cut.GetEmEnergy() + em_continuous.GetEnergyLost() + observationLevel.GetEnergyGround() + EAS.GetEnergyCut();
cout << "Cascade energy cut: " << EAS.GetEnergyCut() / 1_GeV << " GeV" << endl;
const HEPEnergyType Efinal = cut.GetCutEnergy() + cut.GetInvEnergy() +
cut.GetEmEnergy() + em_continuous.GetEnergyLost() +
observationLevel.GetEnergyGround() + EAS.GetEnergyCut();
cout << "total cut energy (GeV): " << Efinal / 1_GeV << endl
<< "relative difference (%): " << (Efinal / E0 - 1) * 100 << endl;
observationLevel.Reset();
cut.Reset();
em_continuous.Reset();
auto const hists = proposalCounted.GetHistogram();
hists.saveLab("inthist_lab.txt");
hists.saveCMS("inthist_cms.txt");
......
......@@ -22,12 +22,12 @@
#include <corsika/process/observation_plane/ObservationPlane.h>
#include <corsika/process/on_shell_check/OnShellCheck.h>
#include <corsika/process/particle_cut/ParticleCut.h>
#include <corsika/process/proposal/ContinuousProcess.h>
#include <corsika/process/proposal/Interaction.h>
#include <corsika/process/pythia/Decay.h>
#include <corsika/process/sibyll/Decay.h>
#include <corsika/process/sibyll/Interaction.h>
#include <corsika/process/sibyll/NuclearInteraction.h>
#include <corsika/process/proposal/ContinuousProcess.h>
#include <corsika/process/proposal/Interaction.h>
#include <corsika/process/switch_process/SwitchProcess.h>
#include <corsika/process/tracking_line/TrackingLine.h>
#include <corsika/process/urqmd/UrQMD.h>
......@@ -207,8 +207,8 @@ int main(int argc, char** argv) {
55_GeV);
auto decaySequence = decayPythia << decaySibyll;
auto sequence = switchProcess << reset_particle_mass << decaySequence << proposalCounted << em_continuous
<< cut << longprof << observationLevel;
auto sequence = switchProcess << reset_particle_mass << decaySequence << proposalCounted
<< em_continuous << cut << longprof << observationLevel;
// define air shower object, run simulation
tracking_line::TrackingLine tracking;
......@@ -220,13 +220,13 @@ int main(int argc, char** argv) {
EAS.Run();
cut.ShowResults();
em_continuous.ShowResults();
observationLevel.ShowResults();
cout << "Cascade energy cut: " << EAS.GetEnergyCut()/1_GeV << " GeV" << endl;
const HEPEnergyType Efinal =
cut.GetCutEnergy() + cut.GetInvEnergy() + cut.GetEmEnergy() + em_continuous.GetEnergyLost() + observationLevel.GetEnergyGround() + EAS.GetEnergyCut();
cout << "Cascade energy cut: " << EAS.GetEnergyCut() / 1_GeV << " GeV" << endl;
const HEPEnergyType Efinal = cut.GetCutEnergy() + cut.GetInvEnergy() +
cut.GetEmEnergy() + em_continuous.GetEnergyLost() +
observationLevel.GetEnergyGround() + EAS.GetEnergyCut();
cout << "total cut energy (GeV): " << Efinal / 1_GeV << endl
<< "relative difference (%): " << (Efinal / E0 - 1) * 100 << endl;
observationLevel.Reset();
......@@ -234,7 +234,7 @@ int main(int argc, char** argv) {
em_continuous.Reset();
auto const hists = sibyllCounted.GetHistogram() + sibyllNucCounted.GetHistogram() +
urqmdCounted.GetHistogram() + proposalCounted.GetHistogram();
urqmdCounted.GetHistogram() + proposalCounted.GetHistogram();
hists.saveLab("inthist_lab.txt");
hists.saveCMS("inthist_cms.txt");
......
......@@ -18,8 +18,6 @@
#include <stdexcept>
#include <vector>
namespace corsika::environment {
class NuclearComposition {
std::vector<float> const fNumberFractions; //!< relative fractions of number density
......@@ -29,7 +27,7 @@ namespace corsika::environment {
double const fAvgMassNumber;
std::size_t hash_;
template <class AConstIterator, class BConstIterator>
class WeightProviderIterator {
AConstIterator fAIter;
......@@ -134,21 +132,17 @@ namespace corsika::environment {
// Note: when this class ever modifies its internal data, the hash
// must be updated, too!
size_t hash() const { return hash_; }
private:
void updateHash() {
std::vector<std::size_t> hashes;
for (float ifrac : GetFractions())
hashes.push_back(std::hash<float>{}(ifrac));
for (float ifrac : GetFractions()) hashes.push_back(std::hash<float>{}(ifrac));
for (corsika::particles::Code icode : GetComponents())
hashes.push_back(std::hash<int>{}(static_cast<int>(icode)));
hashes.push_back(std::hash<int>{}(static_cast<int>(icode)));
std::size_t h = std::hash<double>{}(GetAverageMassNumber());
for (std::size_t ih : hashes)
h = h ^ (ih<<1);
for (std::size_t ih : hashes) h = h ^ (ih << 1);
hash_ = h;
}
};
} // namespace corsika::environment
......@@ -87,8 +87,8 @@ namespace corsika::cascade {
, fStack(stack)
, energy_cut_(0 * corsika::units::si::electronvolt) {}
corsika::units::si::HEPEnergyType GetEnergyCut() const { return energy_cut_; }
corsika::units::si::HEPEnergyType GetEnergyCut() const { return energy_cut_; }
/**
* set the nodes for all particles on the stack according to their numerical
* position
......@@ -213,11 +213,11 @@ namespace corsika::cascade {
// apply all continuous processes on particle + track
process::EProcessReturn status = fProcessSequence.DoContinuous(vParticle, step);
if (status == process::EProcessReturn::eParticleAbsorbed) {
std::cout << "Cascade: delete absorbed particle " << vParticle.GetPID() << " "
<< vParticle.GetEnergy() / 1_GeV << "GeV" << std::endl;
energy_cut_ += vParticle.GetEnergy();
energy_cut_ += vParticle.GetEnergy();
vParticle.Delete();
return;
}
......@@ -334,10 +334,10 @@ namespace corsika::cascade {
TProcessList& fProcessSequence;
TStack& fStack;
corsika::random::RNG& fRNG =
corsika::random::RNGManager::GetInstance().GetRandomStream("cascade");
corsika::random::RNGManager::GetInstance().GetRandomStream("cascade");
corsika::units::si::HEPEnergyType energy_cut_;
}; // namespace corsika::cascade
} // namespace corsika::cascade
......@@ -145,11 +145,9 @@ public:
};
class Decay1 : public DecayProcess<Decay1> {
int fV = 0;
public:
Decay1(const int v)
: fV(v) {
Decay1(const int v) {
cout << "Decay1()" << endl;
globalCount++;
}
......
......@@ -31,7 +31,7 @@ using SetupTrack = corsika::setup::Trajectory;
using namespace corsika::process::energy_loss;
EnergyLoss::EnergyLoss(environment::ShowerAxis const& shower_axis,
corsika::units::si::HEPEnergyType emCut)
corsika::units::si::HEPEnergyType emCut)
: shower_axis_(shower_axis)
, emCut_(emCut)
, profile_(int(shower_axis.maximumX() / dX_) + 1) {}
......@@ -178,7 +178,7 @@ process::EProcessReturn EnergyLoss::DoContinuous(SetupParticle& p, SetupTrack co
<< " E=" << E / 1_GeV << "GeV, Ekin=" << Ekin / 1_GeV << ", Enew=" << Enew / 1_GeV
<< "GeV" << endl;
auto status = process::EProcessReturn::eOk;
if (E<emCut_) {
if (E < emCut_) {
Enew = emCut_;
status = process::EProcessReturn::eParticleAbsorbed;
}
......@@ -195,7 +195,7 @@ LengthType EnergyLoss::MaxStepLength(SetupParticle const& vParticle,
}
auto constexpr dX = 1_g / square(1_cm);
auto const dEdX = - TotalEnergyLoss(vParticle, dX) / dX; // dE > 0
auto const dEdX = -TotalEnergyLoss(vParticle, dX) / dX; // dE > 0
//~ auto const Ekin = vParticle.GetEnergy() - vParticle.GetMass();
// in any case: never go below 0.99*emCut_ This needs to be
......@@ -207,8 +207,8 @@ LengthType EnergyLoss::MaxStepLength(SetupParticle const& vParticle,
// afterwards.
//
const auto energy = vParticle.GetEnergy();
auto energy_lim = std::max(0.9*energy, 0.99*emCut_);
auto energy_lim = std::max(0.9 * energy, 0.99 * emCut_);
auto const maxGrammage = (energy - energy_lim) / dEdX;
return vParticle.GetNode()->GetModelProperties().ArclengthFromGrammage(vTrack,
......
......@@ -27,9 +27,10 @@ namespace corsika::process::energy_loss {
units::si::square(1e-2 * units::si::meter));
void MomentumUpdate(setup::Stack::ParticleType&, units::si::HEPEnergyType Enew);
public:
EnergyLoss(environment::ShowerAxis const& showerAxis, corsika::units::si::HEPEnergyType emCut);
EnergyLoss(environment::ShowerAxis const& showerAxis,
corsika::units::si::HEPEnergyType emCut);
process::EProcessReturn DoContinuous(setup::Stack::ParticleType&,
setup::Trajectory const&);
......@@ -52,7 +53,7 @@ namespace corsika::process::energy_loss {
return 10_g / square(1_cm);
}); // profile binning
private:
private:
environment::ShowerAxis const& shower_axis_;
corsika::units::si::HEPEnergyType emCut_;
std::vector<units::si::HEPEnergyType> profile_; // longitudinal profile
......
......@@ -67,10 +67,10 @@ LengthType ObservationPlane::MaxStepLength(setup::Stack::ParticleType const&,
void ObservationPlane::ShowResults() const {
std::cout << " ******************************" << std::endl
<< " ObservationPlane: " << std::endl;
<< " ObservationPlane: " << std::endl;
std::cout << " energy in ground (GeV) : " << energy_ground_ / 1_GeV << std::endl
<< " no. of particles in ground : " << count_ground_ << std::endl
<< " ******************************" << std::endl;
<< " no. of particles in ground : " << count_ground_ << std::endl
<< " ******************************" << std::endl;
}
void ObservationPlane::Reset() {
......
......@@ -39,7 +39,7 @@ namespace corsika::process::observation_plane {
void ShowResults() const;
void Reset();
corsika::units::si::HEPEnergyType GetEnergyGround() const { return energy_ground_; }
private:
geometry::Plane const plane_;
std::ofstream outputStream_;
......
......@@ -123,9 +123,11 @@ namespace corsika::process {
C8LOG_INFO(fmt::format(
" ******************************\n"
" ParticleCut: \n"
" energy in em. component (GeV): {}\n"
if (bCutEm)
" energy in em. component (GeV): {}\n"
" no. of em. particles injected: {}\n"
" energy in inv. component (GeV): {}\n"
if (bCutInv)
" energy in inv. component (GeV): {}\n"
" no. of inv. particles injected: {}\n"
" energy below particle cut (GeV): {}\n"
" ******************************",
......
......@@ -36,7 +36,8 @@ namespace corsika::process::proposal {
// saved in the calc map by a key build out of a hash of composed of the component and
// particle code.
auto disp = PROPOSAL::make_displacement(c, true);
auto scatter = PROPOSAL::make_scattering("highland", particle[code], media.at(comp.hash()));
auto scatter =
PROPOSAL::make_scattering("highland", particle[code], media.at(comp.hash()));
calc[std::make_pair(comp.hash(), code)] =
std::make_tuple(std::move(disp), std::move(scatter));
}
......@@ -80,8 +81,7 @@ namespace corsika::process::proposal {
// scattering
auto vec = corsika::geometry::QuantityVector(
final_dir.GetX() * E_f, final_dir.GetY() * E_f, final_dir.GetZ() * E_f);
vP.SetMomentum(
corsika::stack::MomentumVector(vP_dir.GetCoordinateSystem(), vec));
vP.SetMomentum(corsika::stack::MomentumVector(vP_dir.GetCoordinateSystem(), vec));
}
template <>
......
......@@ -36,15 +36,15 @@ namespace corsika::process::proposal {
// interpolate the crosssection for given media and energy cut. These may
// take some minutes if you have to build the tables and cannot read the
// from disk
auto c = p_cross->second(media.at(&comp), emCut_);
auto c = p_cross->second(media.at(comp.hash()), emCut_);
// Look which interactions take place and build the corresponding
// interaction and secondarie builder. The interaction integral will
// interpolated too and saved in the calc map by a key build out of a hash
// of composed of the component and particle code.
auto inter_types = PROPOSAL::CrossSectionVector::GetInteractionTypes(c);
calc[std::make_pair(&comp, code)] = std::make_tuple(
PROPOSAL::make_secondaries(inter_types, particle[code], media.at(&comp)),
calc[std::make_pair(comp.hash(), code)] = std::make_tuple(
PROPOSAL::make_secondaries(inter_types, particle[code], media.at(comp.hash())),
PROPOSAL::make_interaction(c, true));
}
......@@ -67,7 +67,8 @@ namespace corsika::process::proposal {
// Read how much random numbers are required to calculate the secondaries.
// Calculate the secondaries and deploy them on the corsika stack.
auto rnd = vector<double>(get<eSECONDARIES>(c->second)->RequiredRandomNumbers(type));
auto rnd =
vector<double>(get<eSECONDARIES>(c->second)->RequiredRandomNumbers(type));
for (auto& it : rnd) it = distr(fRNG);
auto point = PROPOSAL::Vector3D(vP.GetPosition().GetX() / 1_cm,
vP.GetPosition().GetY() / 1_cm,
......@@ -78,8 +79,8 @@ namespace corsika::process::proposal {
d.GetZ().magnitude());
auto loss = make_tuple(static_cast<int>(type), point, direction,
v * vP.GetEnergy() / 1_MeV, 0.);
auto sec = get<eSECONDARIES>(c->second)->CalculateSecondaries(vP.GetEnergy() / 1_MeV,
loss, *comp_ptr, rnd);
auto sec = get<eSECONDARIES>(c->second)->CalculateSecondaries(
vP.GetEnergy() / 1_MeV, loss, *comp_ptr, rnd);
for (auto& s : sec) {
auto E = get<PROPOSAL::Loss::ENERGY>(s) * 1_MeV;
auto vec = corsika::geometry::QuantityVector(
......
......@@ -64,7 +64,7 @@ namespace corsika::process::proposal {
"table directory. ");
}
}
size_t ProposalProcessBase::hash::operator()(const calc_key_t& p) const noexcept {
return p.first ^ std::hash<particles::Code>{}(p.second);
}
......
/*
* (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.
*/
#pragma once
#include <PROPOSAL/PROPOSAL.h>
......
......@@ -49,7 +49,10 @@ else:
filelist = [x for x in filelist
if "ThirdParty" not in x and (x.endswith(".h") or x.endswith(".cc"))]
cmd = "clang-format -style=file"
cmd = "clang-format"
if "CLANG_FORMAT" in os.environ:
cmd = os.environ["CLANG_FORMAT"]
cmd += " -style=file"
if args.apply:
for filename in filelist:
subp.check_call(cmd.split() + ["-i", filename])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment