IAP GITLAB

Skip to content
Snippets Groups Projects
testCascade.cc 3.07 KiB
Newer Older

/**
 * (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.
 */

#include <corsika/environment/Environment.h>

#include <corsika/cascade/Cascade.h>
#include <corsika/process/ProcessSequence.h>
#include <corsika/process/stack_inspector/StackInspector.h>
ralfulrich's avatar
ralfulrich committed
#include <corsika/process/tracking_line/TrackingLine.h>
#include <corsika/stack/super_stupid/SuperStupidStack.h>

#include <corsika/geometry/Point.h>
#include <corsika/geometry/Vector.h>

#include <corsika/setup/SetupStack.h>
#include <corsika/setup/SetupTrajectory.h>
using corsika::setup::Trajectory;

#define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one
                          // cpp file
#include <catch2/catch.hpp>

using namespace corsika::process;
using namespace corsika::units;
using namespace corsika::geometry;

#include <iostream>
using namespace std;
using namespace corsika::units::si;
static int fCount = 0;

class ProcessSplit : public corsika::process::BaseProcess<ProcessSplit> {
public:
  ProcessSplit() {}

  template <typename Particle>
  void MinStepLength(Particle&, setup::Trajectory&) const {}
  template <typename Particle, typename Stack>
  EProcessReturn DoContinuous(Particle&, setup::Trajectory&, Stack&) const {
ralfulrich's avatar
ralfulrich committed
    return EProcessReturn::eOk;
  }

  template <typename Particle, typename Stack>
  void DoDiscrete(Particle& p, Stack& s) const {
    EnergyType E = p.GetEnergy();
      p.Delete();
      fCount++;
    } else {
      p.SetEnergy(E / 2);
      auto pnew = s.NewParticle();
      // s.Copy(p, pnew);
      pnew.SetEnergy(E / 2);
      pnew.SetPosition(p.GetPosition());
      pnew.SetMomentum(p.GetMomentum());
ralfulrich's avatar
ralfulrich committed
    }
  }

  void Init() { fCount = 0; }

  int GetCount() const { return fCount; }

private:
};

TEST_CASE("Cascade", "[Cascade]") {
  corsika::environment::Environment env; // dummy environment
  tracking_line::TrackingLine<setup::Stack> tracking(env);
  stack_inspector::StackInspector<setup::Stack> p0(true);
  ProcessSplit p1;
  const auto sequence = p0 + p1;
ralfulrich's avatar
ralfulrich committed

  corsika::cascade::Cascade EAS(tracking, sequence, stack);
  CoordinateSystem& rootCS = RootCoordinateSystem::GetInstance().GetRootCS();

  stack.Clear();
  auto particle = stack.NewParticle();
  EnergyType E0 = 100_GeV;
  particle.SetEnergy(E0);
  particle.SetPosition(Point(rootCS, {0_m, 0_m, 10_km}));
  particle.SetMomentum(corsika::stack::super_stupid::MomentumVector(
      rootCS, {0 * newton * second, 0 * newton * second, -1 * newton * second}));
  SECTION("sectionTwo") {
    for (int i = 0; i < 0; ++i) {
      stack.Clear();
      auto particle = stack.NewParticle();
      EnergyType E0 = 100_GeV * pow(10, i);
      particle.SetEnergy(E0);
      EAS.Init();
      EAS.Run();
ralfulrich's avatar
ralfulrich committed

      // cout << "Result: E0=" << E0 / 1_GeV << "GeV, count=" << p1.GetCount() << endl;