18#include "HepMC3/FourVector.h"
19#include "HepMC3/GenEvent.h"
20#include "HepMC3/GenParticle.h"
23#include "marley/hepmc3_utils.hh"
24#include "marley/Error.hh"
25#include "marley/Generator.hh"
26#include "marley/ProjectileDirectionRotator.hh"
29 const std::array<double, 3>& dir ) : EventProcessor(),
32 constexpr ThreeVector null_three_vector = { 0., 0., 0. };
34 " passed to constructor of marley::ProjectileDirectionRotator" );
45 const auto projectile = marley_hepmc3::get_projectile( ev );
47 double pmom = mom4.
p3mod();
48 if ( pmom <= 0. )
return;
50 ThreeVector pdir = { mom4.
px() / pmom, mom4.
py() / pmom, mom4.
pz() / pmom };
55 ThreeVector random_dir = sample_isotropic_direction( gen );
56 this->set_projectile_direction( random_dir );
84marley::ProjectileDirectionRotator::ThreeVector
85 marley::ProjectileDirectionRotator::sample_isotropic_direction(
95 double sin_theta = marley_utils::real_sqrt( 1. - std::pow(cos_theta, 2) );
96 double ux = sin_theta * std::cos( phi );
97 double uy = sin_theta * std::sin( phi );
98 double uz = cos_theta;
100 ThreeVector direction = { ux, uy, uz };
104void marley::ProjectileDirectionRotator::set_randomize_directions(
107 randomize_projectile_direction_ = do_sampling;
double px() const
x-component of momentum
double py() const
y-component of momentum
double p3mod() const
Magnitude of p3 = (px, py, pz) vector.
double pz() const
z-component of momentum
Stores event-related information.
const std::vector< ConstGenParticlePtr > & particles() const
Get list of particles (const)
Base class for all exceptions thrown by MARLEY functions.
The MARLEY Event generator.
double uniform_random_double(double min, double max, bool inclusive)
Sample a random number uniformly on either [min, max) or [min, max].
ThreeVector last_pdir_
Stores the direction 3-vector for the last projectile that triggered a recalculation of the rotation ...
virtual void process_event(HepMC3::GenEvent &ev, marley::Generator &gen) override
Rotates all 3-momenta in the input event so that the projectile 3-momentum lies along dir_vec_ in the...
bool randomize_projectile_direction_
Flag that indicates whether the (rotated) projectile direction should be sampled isotropically for ea...
ThreeVector dir_vec_
3-vector that points in the desired direction of the projectile
ProjectileDirectionRotator(const ThreeVector &dir={0., 0., 1.})
marley::RotationMatrix rot_matrix_
RotationMatrix used to rotate the coordinate system of the input GenEvent.
void rotate_event(HepMC3::GenEvent &ev)
Helper function that does the coordinate system rotation.
Simple rotation matrix implementation used to reorient Particle objects based on the incident neutrin...