IAP GITLAB

Skip to content
Snippets Groups Projects
Commit 3e666822 authored by ralfulrich's avatar ralfulrich
Browse files

converted EProcessReturn to bitwise enum, as it was desinged for

parent 76cf8e50
No related branches found
No related tags found
No related merge requests found
......@@ -141,18 +141,18 @@ public:
cout << "removing em. particle..." << endl;
fEmEnergy += p.GetEnergy();
fEmCount += 1;
p.Delete();
// p.Delete();
ret = EProcessReturn::eParticleAbsorbed;
} else if (isInvisible(pid)) {
cout << "removing inv. particle..." << endl;
fInvEnergy += p.GetEnergy();
fInvCount += 1;
p.Delete();
// p.Delete();
ret = EProcessReturn::eParticleAbsorbed;
} else if (isBelowEnergyCut(p)) {
cout << "removing low en. particle..." << endl;
fEnergy += p.GetEnergy();
p.Delete();
// p.Delete();
ret = EProcessReturn::eParticleAbsorbed;
}
return ret;
......
......@@ -119,7 +119,10 @@ namespace corsika::cascade {
fProcessSequence.DoContinuous(particle, step, fStack);
if (status == corsika::process::EProcessReturn::eParticleAbsorbed) {
// fStack.Delete(particle); // TODO: check if this is really needed
std::cout << "Cascade: delete absorbed particle " << particle.GetPID() << " "
<< particle.GetEnergy() / 1_GeV << "GeV" << std::endl;
particle.Delete();
return;
} else {
std::cout << "sth. happening before geometric limit ?"
......
......@@ -80,7 +80,7 @@ public:
}
template <typename Particle, typename T, typename Stack>
void DoContinuous(Particle& p, T&, Stack& s) const {
EProcessReturn DoContinuous(Particle& p, T&, Stack& s) const {
EnergyType E = p.GetEnergy();
if (E < 85_MeV) {
p.Delete();
......@@ -95,6 +95,7 @@ public:
pnew.SetPosition(p.GetPosition());
pnew.SetMomentum(p.GetMomentum());
}
return EProcessReturn::eOk;
}
void Init() { fCount = 0; }
......
......@@ -20,13 +20,25 @@ namespace corsika::process {
that can be accumulated easily with "|="
*/
enum class EProcessReturn {
eOk = 1,
eParticleAbsorbed = 2,
eInteracted = 3,
eDecayed = 4,
enum class EProcessReturn : int {
eOk = (1 << 0),
eParticleAbsorbed = (1 << 2),
eInteracted = (1 << 3),
eDecayed = (1 << 4),
};
inline EProcessReturn operator|(EProcessReturn a, EProcessReturn b) {
return static_cast<EProcessReturn>(static_cast<int>(a) | static_cast<int>(b));
}
inline EProcessReturn& operator|=(EProcessReturn& a, EProcessReturn b) {
return a = a | b;
}
inline bool operator==(EProcessReturn a, EProcessReturn b) {
return (static_cast<int>(a) & static_cast<int>(b)) != 0;
}
} // namespace corsika::process
#endif
......@@ -60,11 +60,11 @@ namespace corsika::process {
EProcessReturn ret = EProcessReturn::eOk;
if constexpr (std::is_base_of<ContinuousProcess<T1>, T1>::value ||
is_process_sequence<T1>::value) {
A.DoContinuous(p, t, s);
ret |= A.DoContinuous(p, t, s);
}
if constexpr (std::is_base_of<ContinuousProcess<T2>, T2>::value ||
is_process_sequence<T2>::value) {
B.DoContinuous(p, t, s);
ret |= B.DoContinuous(p, t, s);
}
return ret;
}
......
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