IAP GITLAB

Skip to content
Snippets Groups Projects
Commit 59564cc0 authored by ralfulrich's avatar ralfulrich
Browse files

complete interface change

parent a173a4bb
No related branches found
No related tags found
No related merge requests found
Showing
with 151 additions and 109 deletions
...@@ -256,8 +256,6 @@ int main() { ...@@ -256,8 +256,6 @@ int main() {
double theta = 0.; double theta = 0.;
double phi = 0.; double phi = 0.;
{ {
auto particle = stack.NewParticle();
particle.SetPID(Code::Proton);
HEPMomentumType P0 = sqrt(E0 * E0 - Proton::GetMass() * Proton::GetMass()); HEPMomentumType P0 = sqrt(E0 * E0 - Proton::GetMass() * Proton::GetMass());
auto momentumComponents = [](double theta, double phi, HEPMomentumType ptot) { auto momentumComponents = [](double theta, double phi, HEPMomentumType ptot) {
return std::make_tuple(ptot * sin(theta) * cos(phi), ptot * sin(theta) * sin(phi), return std::make_tuple(ptot * sin(theta) * cos(phi), ptot * sin(theta) * sin(phi),
...@@ -268,11 +266,8 @@ int main() { ...@@ -268,11 +266,8 @@ int main() {
auto plab = stack::super_stupid::MomentumVector(rootCS, {px, py, pz}); auto plab = stack::super_stupid::MomentumVector(rootCS, {px, py, pz});
cout << "input angles: theta=" << theta << " phi=" << phi << endl; cout << "input angles: theta=" << theta << " phi=" << phi << endl;
cout << "input momentum: " << plab.GetComponents() / 1_GeV << endl; cout << "input momentum: " << plab.GetComponents() / 1_GeV << endl;
particle.SetEnergy(E0); Point pos(rootCS, 0_m, 0_m, 0_m);
particle.SetMomentum(plab); stack.AddParticle(Code::Proton, E0, plab, pos, 0_ns);
particle.SetTime(0_ns);
Point p(rootCS, 0_m, 0_m, 0_m);
particle.SetPosition(p);
} }
// define air shower object, run simulation // define air shower object, run simulation
......
...@@ -11,6 +11,10 @@ ...@@ -11,6 +11,10 @@
#include <corsika/particles/ParticleProperties.h> #include <corsika/particles/ParticleProperties.h>
#include <corsika/stack/super_stupid/SuperStupidStack.h> #include <corsika/stack/super_stupid/SuperStupidStack.h>
#include <corsika/geometry/Point.h>
#include <corsika/geometry/RootCoordinateSystem.h>
#include <cassert> #include <cassert>
#include <iomanip> #include <iomanip>
#include <iostream> #include <iostream>
...@@ -20,10 +24,12 @@ using namespace corsika::stack; ...@@ -20,10 +24,12 @@ using namespace corsika::stack;
using namespace std; using namespace std;
void fill(corsika::stack::super_stupid::SuperStupidStack& s) { void fill(corsika::stack::super_stupid::SuperStupidStack& s) {
const geometry::CoordinateSystem& rootCS =
geometry::RootCoordinateSystem::GetInstance().GetRootCoordinateSystem();
for (int i = 0; i < 11; ++i) { for (int i = 0; i < 11; ++i) {
auto p = s.NewParticle(); s.AddParticle(corsika::particles::Code::Electron, 1.5_GeV * i,
p.SetPID(corsika::particles::Code::Electron); stack::super_stupid::MomentumVector(rootCS, {0_GeV, 0_GeV, 1_GeV}),
p.SetEnergy(1.5_GeV * i); geometry::Point(rootCS, 0_m, 0_m, 0_m), 0_ns);
} }
} }
......
...@@ -84,7 +84,7 @@ public: ...@@ -84,7 +84,7 @@ public:
} }
template <typename Particle, typename T, typename Stack> template <typename Particle, typename T, typename Stack>
EProcessReturn DoContinuous(Particle& p, T&, Stack& s) { EProcessReturn DoContinuous(Particle& p, T&, Stack&) {
fCalls++; fCalls++;
HEPEnergyType E = p.GetEnergy(); HEPEnergyType E = p.GetEnergy();
if (E < fEcrit) { if (E < fEcrit) {
...@@ -92,13 +92,7 @@ public: ...@@ -92,13 +92,7 @@ public:
fCount++; fCount++;
} else { } else {
p.SetEnergy(E / 2); p.SetEnergy(E / 2);
auto pnew = s.NewParticle(); p.AddSecondary(p.GetPID(), E / 2, p.GetMomentum(), p.GetPosition(), p.GetTime());
// s.Copy(p, pnew); fix that .... todo
pnew.SetPID(p.GetPID());
pnew.SetTime(p.GetTime());
pnew.SetEnergy(E / 2);
pnew.SetPosition(p.GetPosition());
pnew.SetMomentum(p.GetMomentum());
} }
return EProcessReturn::eOk; return EProcessReturn::eOk;
} }
...@@ -133,14 +127,11 @@ TEST_CASE("Cascade", "[Cascade]") { ...@@ -133,14 +127,11 @@ TEST_CASE("Cascade", "[Cascade]") {
RootCoordinateSystem::GetInstance().GetRootCoordinateSystem(); RootCoordinateSystem::GetInstance().GetRootCoordinateSystem();
stack.Clear(); stack.Clear();
auto particle = stack.NewParticle();
HEPEnergyType E0 = 100_GeV; HEPEnergyType E0 = 100_GeV;
particle.SetPID(particles::Code::Electron); stack.AddParticle(
particle.SetEnergy(E0); particles::Code::Electron, E0,
particle.SetPosition(Point(rootCS, {0_m, 0_m, 10_km})); corsika::stack::super_stupid::MomentumVector(rootCS, {0_GeV, 0_GeV, -1_GeV}),
particle.SetMomentum( Point(rootCS, {0_m, 0_m, 10_km}), 0_ns);
corsika::stack::super_stupid::MomentumVector(rootCS, {0_GeV, 0_GeV, -1_GeV}));
particle.SetTime(0_ns);
EAS.Init(); EAS.Init();
EAS.Run(); EAS.Run();
......
...@@ -46,6 +46,11 @@ namespace corsika::stack { ...@@ -46,6 +46,11 @@ namespace corsika::stack {
/// will be invalidated by this operation /// will be invalidated by this operation
void Delete() { GetIterator().GetStack().Delete(GetIterator()); } void Delete() { GetIterator().GetStack().Delete(GetIterator()); }
template <typename... Args>
StackIterator AddSecondary(const Args... v) {
return GetStack().AddSecondary(GetIterator(), v...);
}
// protected: // todo should be proteced, but don't now how to 'friend Stack' // protected: // todo should be proteced, but don't now how to 'friend Stack'
/// Function to provide CRTP access to inheriting class (type) /// Function to provide CRTP access to inheriting class (type)
StackIterator& GetIterator() { return static_cast<StackIterator&>(*this); } StackIterator& GetIterator() { return static_cast<StackIterator&>(*this); }
......
...@@ -71,12 +71,14 @@ namespace corsika::stack { ...@@ -71,12 +71,14 @@ namespace corsika::stack {
/// increase stack size, create new particle at end of stack /// increase stack size, create new particle at end of stack
template <typename... Args> template <typename... Args>
StackIterator AddParticle(Args... v) { StackIterator AddParticle(const Args... v) {
IncrementSize(); IncrementSize();
return StackIterator(*this, GetSize() - 1, v...); return StackIterator(*this, GetSize() - 1, v...);
// auto p = StackIterator(*this, GetSize() - 1); }
// p.SetParticleData(v...); template <typename... Args>
// return p; StackIterator AddSecondary(StackIterator& parent, const Args... v) {
IncrementSize();
return StackIterator(*this, GetSize() - 1, parent, v...);
} }
void Copy(StackIterator& a, StackIterator& b) { Copy(a.GetIndex(), b.GetIndex()); } void Copy(StackIterator& a, StackIterator& b) { Copy(a.GetIndex(), b.GetIndex()); }
/// delete this particle /// delete this particle
......
...@@ -95,6 +95,14 @@ namespace corsika::stack { ...@@ -95,6 +95,14 @@ namespace corsika::stack {
(**this).SetParticleData(args...); (**this).SetParticleData(args...);
} }
template <typename... Args>
StackIteratorInterface(StackType& data, const int index,
StackIteratorInterface& parent, const Args... args)
: fIndex(index)
, fData(&data) {
(**this).SetParticleData(*parent, args...);
}
public: public:
StackIteratorInterface& operator++() { StackIteratorInterface& operator++() {
++fIndex; ++fIndex;
...@@ -116,7 +124,7 @@ namespace corsika::stack { ...@@ -116,7 +124,7 @@ namespace corsika::stack {
} }
protected: protected:
int GetIndex() const { return fIndex; } inline int GetIndex() const { return fIndex; }
StackType& GetStack() { return *fData; } StackType& GetStack() { return *fData; }
const StackType& GetStack() const { return *fData; } const StackType& GetStack() const { return *fData; }
StackData& /*typename std::decay<StackData>::type&*/ GetStackData() { StackData& /*typename std::decay<StackData>::type&*/ GetStackData() {
......
...@@ -61,10 +61,14 @@ class TestParticleInterface : public ParticleBase<StackIteratorInterface> { ...@@ -61,10 +61,14 @@ class TestParticleInterface : public ParticleBase<StackIteratorInterface> {
using ParticleBase<StackIteratorInterface>::GetStack; using ParticleBase<StackIteratorInterface>::GetStack;
using ParticleBase<StackIteratorInterface>::GetStackData; using ParticleBase<StackIteratorInterface>::GetStackData;
using ParticleBase<StackIteratorInterface>::GetIndex; using ParticleBase<StackIteratorInterface>::GetIndex;
using ParticleBase<StackIteratorInterface>::GetIterator;
public: public:
// one version // one version
void AddSecondary(const double v) { GetStack().AddParticle(v); } StackIteratorInterface& AddSecondary(const double v) {
GetStack().AddParticle(v);
return GetIterator();
}
// another version // another version
void AddSecondary(const double v, const double p) { GetStack().AddParticle(v + p); } void AddSecondary(const double v, const double p) { GetStack().AddParticle(v + p); }
...@@ -82,7 +86,7 @@ TEST_CASE("Stack", "[Stack]") { ...@@ -82,7 +86,7 @@ TEST_CASE("Stack", "[Stack]") {
// helper function for sum over stack data // helper function for sum over stack data
auto sum = [](const StackTest& stack) { auto sum = [](const StackTest& stack) {
double v = 0; double v = 0;
for (const auto&& p : stack) v += p.GetData(); for (const auto& p : stack) v += p.GetData();
return v; return v;
}; };
......
...@@ -21,6 +21,8 @@ ...@@ -21,6 +21,8 @@
#include <corsika/units/PhysicalUnits.h> #include <corsika/units/PhysicalUnits.h>
#include <corsika/stack/super_stupid/SuperStupidStack.h>
#include <corsika/setup/SetupStack.h> #include <corsika/setup/SetupStack.h>
#include <corsika/setup/SetupTrajectory.h> #include <corsika/setup/SetupTrajectory.h>
...@@ -30,16 +32,19 @@ using namespace corsika; ...@@ -30,16 +32,19 @@ using namespace corsika;
TEST_CASE("NullModel", "[processes]") { TEST_CASE("NullModel", "[processes]") {
auto const& cs = auto const& dummyCS =
geometry::RootCoordinateSystem::GetInstance().GetRootCoordinateSystem(); geometry::RootCoordinateSystem::GetInstance().GetRootCoordinateSystem();
geometry::Point const origin(cs, {0_m, 0_m, 0_m}); geometry::Point const origin(dummyCS, {0_m, 0_m, 0_m});
geometry::Vector<corsika::units::si::SpeedType::dimension_type> v( geometry::Vector<corsika::units::si::SpeedType::dimension_type> v(
cs, 0_m / second, 0_m / second, 1_m / second); dummyCS, 0_m / second, 0_m / second, 1_m / second);
geometry::Line line(origin, v); geometry::Line line(origin, v);
geometry::Trajectory<geometry::Line> track(line, 10_s); geometry::Trajectory<geometry::Line> track(line, 10_s);
setup::Stack stack; setup::Stack stack;
auto particle = stack.NewParticle(); auto particle = stack.AddParticle(
particles::Code::Electron, 1.5_GeV,
stack::super_stupid::MomentumVector(dummyCS, {1_GeV, 1_GeV, 1_GeV}),
geometry::Point(dummyCS, {1 * meter, 1 * meter, 1 * meter}), 100_s);
SECTION("interface") { SECTION("interface") {
......
...@@ -163,24 +163,22 @@ namespace corsika::process { ...@@ -163,24 +163,22 @@ namespace corsika::process {
} }
template <typename Particle, typename Stack> template <typename Particle, typename Stack>
void DoDecay(Particle& p, Stack& s) { void DoDecay(Particle& p, Stack&) {
using corsika::geometry::Point; using corsika::geometry::Point;
using namespace corsika::units::si; using namespace corsika::units::si;
fCount++; fCount++;
SibStack ss; SibStack ss;
ss.Clear(); ss.Clear();
// copy particle to sibyll stack
auto pin = ss.NewParticle();
const corsika::particles::Code pCode = p.GetPID(); const corsika::particles::Code pCode = p.GetPID();
pin.SetPID(process::sibyll::ConvertToSibyllRaw(pCode)); // copy particle to sibyll stack
pin.SetEnergy(p.GetEnergy()); ss.AddParticle(process::sibyll::ConvertToSibyllRaw(pCode), p.GetEnergy(),
pin.SetMomentum(p.GetMomentum()); p.GetMomentum(),
// setting particle mass with Corsika values, may be inconsistent with sibyll // setting particle mass with Corsika values, may be inconsistent
// internal values // with sibyll internal values
// TODO: #warning setting particle mass with Corsika values, may be inconsistent // TODO: #warning setting particle mass with Corsika values, may be
// with sibyll internal values // inconsistent with sibyll internal values
pin.SetMass(corsika::particles::GetMass(pCode)); corsika::particles::GetMass(pCode));
// remember position // remember position
Point const decayPoint = p.GetPosition(); Point const decayPoint = p.GetPosition();
TimeType const t0 = p.GetTime(); TimeType const t0 = p.GetTime();
...@@ -203,12 +201,8 @@ namespace corsika::process { ...@@ -203,12 +201,8 @@ namespace corsika::process {
// FOR NOW: skip particles that have decayed in Sibyll, move to iterator? // FOR NOW: skip particles that have decayed in Sibyll, move to iterator?
if (psib.HasDecayed()) continue; if (psib.HasDecayed()) continue;
// add to corsika stack // add to corsika stack
auto pnew = s.NewParticle(); p.AddSecondary(process::sibyll::ConvertFromSibyll(psib.GetPID()),
pnew.SetEnergy(psib.GetEnergy()); psib.GetEnergy(), psib.GetMomentum(), decayPoint, t0);
pnew.SetPID(process::sibyll::ConvertFromSibyll(psib.GetPID()));
pnew.SetMomentum(psib.GetMomentum());
pnew.SetPosition(decayPoint);
pnew.SetTime(t0);
} }
// empty sibyll stack // empty sibyll stack
ss.Clear(); ss.Clear();
......
...@@ -172,7 +172,7 @@ namespace corsika::process::sibyll { ...@@ -172,7 +172,7 @@ namespace corsika::process::sibyll {
*/ */
template <typename Particle, typename Stack> template <typename Particle, typename Stack>
corsika::process::EProcessReturn DoInteraction(Particle& p, Stack& s) { corsika::process::EProcessReturn DoInteraction(Particle& p, Stack&) {
using namespace corsika::units; using namespace corsika::units;
using namespace corsika::utl; using namespace corsika::utl;
...@@ -328,12 +328,9 @@ namespace corsika::process::sibyll { ...@@ -328,12 +328,9 @@ namespace corsika::process::sibyll {
auto const Plab = boost.fromCoM(FourVector(eCoM, pCoM)); auto const Plab = boost.fromCoM(FourVector(eCoM, pCoM));
// add to corsika stack // add to corsika stack
auto pnew = s.NewParticle(); auto pnew = p.AddSecondary(process::sibyll::ConvertFromSibyll(psib.GetPID()),
pnew.SetPID(process::sibyll::ConvertFromSibyll(psib.GetPID())); Plab.GetTimeLikeComponent(),
pnew.SetEnergy(Plab.GetTimeLikeComponent()); Plab.GetSpaceLikeComponents(), pOrig, tOrig);
pnew.SetMomentum(Plab.GetSpaceLikeComponents());
pnew.SetPosition(pOrig);
pnew.SetTime(tOrig);
Plab_final += pnew.GetMomentum(); Plab_final += pnew.GetMomentum();
Elab_final += pnew.GetEnergy(); Elab_final += pnew.GetEnergy();
......
...@@ -29,9 +29,7 @@ namespace corsika::process::sibyll { ...@@ -29,9 +29,7 @@ namespace corsika::process::sibyll {
void Init(); void Init();
void Clear() { s_plist_.np = 0; } void Clear() { s_plist_.np = 0; }
int GetSize() const { return s_plist_.np; } int GetSize() const { return s_plist_.np; }
int GetCapacity() const { return 8000; } int GetCapacity() const { return 8000; }
void SetId(const int i, const int v) { s_plist_.llist[i] = v; } void SetId(const int i, const int v) { s_plist_.llist[i] = v; }
...@@ -43,7 +41,6 @@ namespace corsika::process::sibyll { ...@@ -43,7 +41,6 @@ namespace corsika::process::sibyll {
using namespace corsika::units::si; using namespace corsika::units::si;
s_plist_.p[4][i] = v / 1_GeV; s_plist_.p[4][i] = v / 1_GeV;
} }
void SetMomentum(const int i, const MomentumVector& v) { void SetMomentum(const int i, const MomentumVector& v) {
using namespace corsika::units::si; using namespace corsika::units::si;
auto tmp = v.GetComponents(); auto tmp = v.GetComponents();
...@@ -51,7 +48,6 @@ namespace corsika::process::sibyll { ...@@ -51,7 +48,6 @@ namespace corsika::process::sibyll {
} }
int GetId(const int i) const { return s_plist_.llist[i]; } int GetId(const int i) const { return s_plist_.llist[i]; }
corsika::units::si::HEPEnergyType GetEnergy(const int i) const { corsika::units::si::HEPEnergyType GetEnergy(const int i) const {
using namespace corsika::units::si; using namespace corsika::units::si;
return s_plist_.p[3][i] * 1_GeV; return s_plist_.p[3][i] * 1_GeV;
...@@ -60,7 +56,6 @@ namespace corsika::process::sibyll { ...@@ -60,7 +56,6 @@ namespace corsika::process::sibyll {
using namespace corsika::units::si; using namespace corsika::units::si;
return s_plist_.p[4][i] * 1_GeV; return s_plist_.p[4][i] * 1_GeV;
} }
MomentumVector GetMomentum(const int i) const { MomentumVector GetMomentum(const int i) const {
using corsika::geometry::CoordinateSystem; using corsika::geometry::CoordinateSystem;
using corsika::geometry::QuantityVector; using corsika::geometry::QuantityVector;
...@@ -93,6 +88,27 @@ namespace corsika::process::sibyll { ...@@ -93,6 +88,27 @@ namespace corsika::process::sibyll {
using corsika::stack::ParticleBase<StackIteratorInterface>::GetIndex; using corsika::stack::ParticleBase<StackIteratorInterface>::GetIndex;
public: public:
void SetParticleData(const int vID, // corsika::process::sibyll::SibyllCode vID,
const corsika::units::si::HEPEnergyType vE,
const MomentumVector& vP,
const corsika::units::si::HEPMassType vM) {
SetPID(vID);
SetEnergy(vE);
SetMomentum(vP);
SetMass(vM);
}
void SetParticleData(ParticleInterface<StackIteratorInterface>& /*parent*/,
const int vID, // corsika::process::sibyll::SibyllCode vID,
const corsika::units::si::HEPEnergyType vE,
const MomentumVector& vP,
const corsika::units::si::HEPMassType vM) {
SetPID(vID);
SetEnergy(vE);
SetMomentum(vP);
SetMass(vM);
}
void SetEnergy(const corsika::units::si::HEPEnergyType v) { void SetEnergy(const corsika::units::si::HEPEnergyType v) {
GetStackData().SetEnergy(GetIndex(), v); GetStackData().SetEnergy(GetIndex(), v);
} }
......
...@@ -116,7 +116,12 @@ TEST_CASE("SibyllInterface", "[processes]") { ...@@ -116,7 +116,12 @@ TEST_CASE("SibyllInterface", "[processes]") {
SECTION("InteractionInterface") { SECTION("InteractionInterface") {
setup::Stack stack; setup::Stack stack;
auto particle = stack.NewParticle(); const HEPEnergyType E0 = 10_GeV;
HEPMomentumType P0 =
sqrt(E0 * E0 - particles::Proton::GetMass() * particles::Proton::GetMass());
auto plab = stack::super_stupid::MomentumVector(cs, {0_GeV, 0_GeV, -P0});
geometry::Point pos(cs, 0_m, 0_m, 0_m);
auto particle = stack.AddParticle(particles::Code::Proton, E0, plab, pos, 0_ns);
Interaction model(env); Interaction model(env);
...@@ -130,19 +135,12 @@ TEST_CASE("SibyllInterface", "[processes]") { ...@@ -130,19 +135,12 @@ TEST_CASE("SibyllInterface", "[processes]") {
SECTION("DecayInterface") { SECTION("DecayInterface") {
setup::Stack stack; setup::Stack stack;
auto particle = stack.NewParticle(); const HEPEnergyType E0 = 10_GeV;
{ HEPMomentumType P0 =
const HEPEnergyType E0 = 10_GeV; sqrt(E0 * E0 - particles::Proton::GetMass() * particles::Proton::GetMass());
particle.SetPID(particles::Code::Proton); auto plab = stack::super_stupid::MomentumVector(cs, {0_GeV, 0_GeV, -P0});
HEPMomentumType P0 = geometry::Point pos(cs, 0_m, 0_m, 0_m);
sqrt(E0 * E0 - particles::Proton::GetMass() * particles::Proton::GetMass()); auto particle = stack.AddParticle(particles::Code::Proton, E0, plab, pos, 0_ns);
auto plab = stack::super_stupid::MomentumVector(cs, {0_GeV, 0_GeV, -P0});
particle.SetEnergy(E0);
particle.SetMomentum(plab);
particle.SetTime(0_ns);
geometry::Point p(cs, 0_m, 0_m, 0_m);
particle.SetPosition(p);
}
Decay model; Decay model;
......
...@@ -30,16 +30,19 @@ using namespace corsika; ...@@ -30,16 +30,19 @@ using namespace corsika;
TEST_CASE("StackInspector", "[processes]") { TEST_CASE("StackInspector", "[processes]") {
auto const& cs = auto const& rootCS =
geometry::RootCoordinateSystem::GetInstance().GetRootCoordinateSystem(); geometry::RootCoordinateSystem::GetInstance().GetRootCoordinateSystem();
geometry::Point const origin(cs, {0_m, 0_m, 0_m}); geometry::Point const origin(rootCS, {0_m, 0_m, 0_m});
geometry::Vector<corsika::units::si::SpeedType::dimension_type> v( geometry::Vector<corsika::units::si::SpeedType::dimension_type> v(
cs, 0_m / second, 0_m / second, 1_m / second); rootCS, 0_m / second, 0_m / second, 1_m / second);
geometry::Line line(origin, v); geometry::Line line(origin, v);
geometry::Trajectory<geometry::Line> track(line, 10_s); geometry::Trajectory<geometry::Line> track(line, 10_s);
setup::Stack stack; setup::Stack stack;
auto particle = stack.NewParticle(); auto particle = stack.AddParticle(
particles::Code::Electron, 10_GeV,
corsika::stack::super_stupid::MomentumVector(rootCS, {0_GeV, 0_GeV, -1_GeV}),
geometry::Point(rootCS, {0_m, 0_m, 10_km}), 0_ns);
SECTION("interface") { SECTION("interface") {
......
...@@ -43,23 +43,53 @@ namespace corsika::stack { ...@@ -43,23 +43,53 @@ namespace corsika::stack {
using corsika::stack::ParticleBase<StackIteratorInterface>::GetIndex; using corsika::stack::ParticleBase<StackIteratorInterface>::GetIndex;
public: public:
/// the factory function, this is how to create a new particle:
/*void AddSecondary(const corsika::particles::Code vDataPID,
const corsika::units::si::HEPEnergyType vDataE,
const MomentumVector& vMomentum,
const corsika::geometry::Point& vPosition,
const corsika::units::si::TimeType vTime) {
GetStack().AddParticle(vDataPID, vDataE, vMomentum, vPosition, vTime);
}*/
//
void SetParticleData(const corsika::particles::Code vDataPID,
const corsika::units::si::HEPEnergyType vDataE,
const MomentumVector& vMomentum,
const corsika::geometry::Point& vPosition,
const corsika::units::si::TimeType vTime) {
SetPID(vDataPID);
SetEnergy(vDataE);
SetMomentum(vMomentum);
SetPosition(vPosition);
SetTime(vTime);
}
void SetParticleData(ParticleInterface<StackIteratorInterface>& /*parent*/,
const corsika::particles::Code vDataPID,
const corsika::units::si::HEPEnergyType vDataE,
const MomentumVector& vMomentum,
const corsika::geometry::Point& vPosition,
const corsika::units::si::TimeType vTime) {
SetPID(vDataPID);
SetEnergy(vDataE);
SetMomentum(vMomentum);
SetPosition(vPosition);
SetTime(vTime);
}
/// individual setters /// individual setters
void SetPID(const corsika::particles::Code id) { void SetPID(const corsika::particles::Code id) {
GetStackData().SetPID(GetIndex(), id); GetStackData().SetPID(GetIndex(), id);
} }
void SetEnergy(const corsika::units::si::HEPEnergyType& e) { void SetEnergy(const corsika::units::si::HEPEnergyType& e) {
GetStackData().SetEnergy(GetIndex(), e); GetStackData().SetEnergy(GetIndex(), e);
} }
void SetMomentum(const MomentumVector& v) { void SetMomentum(const MomentumVector& v) {
GetStackData().SetMomentum(GetIndex(), v); GetStackData().SetMomentum(GetIndex(), v);
} }
void SetPosition(const corsika::geometry::Point& v) { void SetPosition(const corsika::geometry::Point& v) {
GetStackData().SetPosition(GetIndex(), v); GetStackData().SetPosition(GetIndex(), v);
} }
void SetTime(const corsika::units::si::TimeType& v) { void SetTime(const corsika::units::si::TimeType& v) {
GetStackData().SetTime(GetIndex(), v); GetStackData().SetTime(GetIndex(), v);
} }
...@@ -68,23 +98,18 @@ namespace corsika::stack { ...@@ -68,23 +98,18 @@ namespace corsika::stack {
corsika::particles::Code GetPID() const { corsika::particles::Code GetPID() const {
return GetStackData().GetPID(GetIndex()); return GetStackData().GetPID(GetIndex());
} }
corsika::units::si::HEPEnergyType GetEnergy() const { corsika::units::si::HEPEnergyType GetEnergy() const {
return GetStackData().GetEnergy(GetIndex()); return GetStackData().GetEnergy(GetIndex());
} }
MomentumVector GetMomentum() const { MomentumVector GetMomentum() const {
return GetStackData().GetMomentum(GetIndex()); return GetStackData().GetMomentum(GetIndex());
} }
corsika::geometry::Point GetPosition() const { corsika::geometry::Point GetPosition() const {
return GetStackData().GetPosition(GetIndex()); return GetStackData().GetPosition(GetIndex());
} }
corsika::units::si::TimeType GetTime() const { corsika::units::si::TimeType GetTime() const {
return GetStackData().GetTime(GetIndex()); return GetStackData().GetTime(GetIndex());
} }
corsika::geometry::Vector<corsika::units::si::dimensionless_d> GetDirection() corsika::geometry::Vector<corsika::units::si::dimensionless_d> GetDirection()
const { const {
return GetMomentum() / GetEnergy(); return GetMomentum() / GetEnergy();
...@@ -110,30 +135,22 @@ namespace corsika::stack { ...@@ -110,30 +135,22 @@ namespace corsika::stack {
} }
int GetSize() const { return fDataPID.size(); } int GetSize() const { return fDataPID.size(); }
int GetCapacity() const { return fDataPID.size(); } int GetCapacity() const { return fDataPID.size(); }
void SetPID(const int i, const corsika::particles::Code id) { fDataPID[i] = id; } void SetPID(const int i, const corsika::particles::Code id) { fDataPID[i] = id; }
void SetEnergy(const int i, const corsika::units::si::HEPEnergyType e) { void SetEnergy(const int i, const corsika::units::si::HEPEnergyType e) {
fDataE[i] = e; fDataE[i] = e;
} }
void SetMomentum(const int i, const MomentumVector& v) { fMomentum[i] = v; } void SetMomentum(const int i, const MomentumVector& v) { fMomentum[i] = v; }
void SetPosition(const int i, const corsika::geometry::Point& v) { void SetPosition(const int i, const corsika::geometry::Point& v) {
fPosition[i] = v; fPosition[i] = v;
} }
void SetTime(const int i, const corsika::units::si::TimeType& v) { fTime[i] = v; } void SetTime(const int i, const corsika::units::si::TimeType& v) { fTime[i] = v; }
corsika::particles::Code GetPID(const int i) const { return fDataPID[i]; } corsika::particles::Code GetPID(const int i) const { return fDataPID[i]; }
corsika::units::si::HEPEnergyType GetEnergy(const int i) const { return fDataE[i]; } corsika::units::si::HEPEnergyType GetEnergy(const int i) const { return fDataE[i]; }
MomentumVector GetMomentum(const int i) const { return fMomentum[i]; } MomentumVector GetMomentum(const int i) const { return fMomentum[i]; }
corsika::geometry::Point GetPosition(const int i) const { return fPosition[i]; } corsika::geometry::Point GetPosition(const int i) const { return fPosition[i]; }
corsika::units::si::TimeType GetTime(const int i) const { return fTime[i]; } corsika::units::si::TimeType GetTime(const int i) const { return fTime[i]; }
/** /**
......
...@@ -28,17 +28,15 @@ using namespace std; ...@@ -28,17 +28,15 @@ using namespace std;
TEST_CASE("SuperStupidStack", "[stack]") { TEST_CASE("SuperStupidStack", "[stack]") {
geometry::CoordinateSystem& dummyCS =
geometry::RootCoordinateSystem::GetInstance().GetRootCoordinateSystem();
SECTION("read+write") { SECTION("read+write") {
SuperStupidStack s; SuperStupidStack s;
auto p = s.NewParticle(); s.AddParticle(particles::Code::Electron, 1.5_GeV,
p.SetPID(particles::Code::Electron); MomentumVector(dummyCS, {1_GeV, 1_GeV, 1_GeV}),
p.SetEnergy(1.5_GeV); Point(dummyCS, {1 * meter, 1 * meter, 1 * meter}), 100_s);
geometry::CoordinateSystem& dummyCS =
geometry::RootCoordinateSystem::GetInstance().GetRootCoordinateSystem();
p.SetMomentum(MomentumVector(dummyCS, {1_GeV, 1_GeV, 1_GeV}));
p.SetPosition(Point(dummyCS, {1 * meter, 1 * meter, 1 * meter}));
p.SetTime(100_s);
// read // read
REQUIRE(s.GetSize() == 1); REQUIRE(s.GetSize() == 1);
...@@ -54,7 +52,10 @@ TEST_CASE("SuperStupidStack", "[stack]") { ...@@ -54,7 +52,10 @@ TEST_CASE("SuperStupidStack", "[stack]") {
SECTION("write+delete") { SECTION("write+delete") {
SuperStupidStack s; SuperStupidStack s;
for (int i = 0; i < 99; ++i) s.NewParticle(); for (int i = 0; i < 99; ++i)
s.AddParticle(particles::Code::Electron, 1.5_GeV,
MomentumVector(dummyCS, {1_GeV, 1_GeV, 1_GeV}),
Point(dummyCS, {1 * meter, 1 * meter, 1 * meter}), 100_s);
REQUIRE(s.GetSize() == 99); REQUIRE(s.GetSize() == 99);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment