MARLEY (Model of Argon Reaction Low Energy Yields) v2.0.0
A Monte Carlo event generator for tens-of-MeV neutrino interactions
Loading...
Searching...
No Matches
CachedOpticalModel.hh
1
4//
5// This file is part of MARLEY (Model of Argon Reaction Low Energy Yields)
6//
7// MARLEY is free software: you can redistribute it and/or modify it under the
8// terms of version 3 of the GNU General Public License as published by the
9// Free Software Foundation.
10//
11// For the full text of the license please see COPYING or
12// visit http://opensource.org/licenses/GPL-3.0
13//
14// Please respect the MCnet academic usage guidelines. See GUIDELINES
15// or visit https://www.montecarlonet.org/GUIDELINES for details.
16
17#pragma once
18
19#include <complex>
20#include <iostream>
21#include <map>
22#include <memory>
23
24#include "marley/OpticalModel.hh"
25
26namespace marley {
27
28 // Forward-declare the InterpolatingFunction class (used in the cache)
30
34
35 public:
36
39 CachedOpticalModel( int Z, int A ) : OpticalModel( Z, A ) {}
40
41 virtual ~CachedOpticalModel() = default;
42
43 virtual double transmission_coefficient( double total_KE_CM,
44 int fragment_pdg, int two_j, int l, int two_s,
45 int target_charge = 0 ) override;
46
47 struct TCKey {
48
49 TCKey() {}
50 TCKey( int fragment_pdg, int two_j, int l, int two_s,
51 int target_charge ) : frag_pdg_( fragment_pdg ), two_j_( two_j ),
52 l_( l ), two_s_( two_s ), target_charge_( target_charge ) {}
53
54 // Defines an ordering allowing this struct to be used as the key
55 // for a std::map
56 bool operator<( const TCKey& other ) const {
57 if ( frag_pdg_ != other.frag_pdg_ ) {
58 return frag_pdg_ < other.frag_pdg_;
59 }
60 else if ( two_j_ != other.two_j_ ) {
61 return two_j_ < other.two_j_;
62 }
63 else if ( l_ != other.l_ ) {
64 return l_ < other.l_;
65 }
66 else if ( two_s_ != other.two_s_ ) {
67 return two_s_ < other.two_s_;
68 }
69 else if ( target_charge_ != other.target_charge_ ) {
70 return target_charge_ < other.target_charge_;
71 }
72 return false;
73 }
74
75 int frag_pdg_ = 0;
76 int two_j_ = 0;
77 int l_ = 0;
78 int two_s_ = 0;
79 int target_charge_ = 0;
80 };
81
82 inline static void set_use_cache( bool use_it ) {
83 USE_CACHE = use_it;
84 }
85
86 protected:
87
89 virtual double compute_transmission_coefficient( double total_KE_CM,
90 int fragment_pdg, int two_j, int l, int two_s,
91 int target_charge = 0 ) = 0;
92
95 std::map< TCKey, std::shared_ptr< InterpolatingFunction > >
97
99 static constexpr double MIN_TOTAL_KE_CM = 1e-10; // MeV
101 static constexpr double MAX_TOTAL_KE_CM = 100.; // MeV
102
105 static bool USE_CACHE;
106 };
107
108}
Nuclear optical model that caches transmission coefficient calculations for efficiency.
static bool USE_CACHE
Boolean switch that allows global enabling/disabling of the cache, which is used by default.
static constexpr double MIN_TOTAL_KE_CM
Minimum kinetic energy to use when interacting with the cache.
static constexpr double MAX_TOTAL_KE_CM
Maximum kinetic energy to use when interacting with the cache.
std::map< TCKey, std::shared_ptr< InterpolatingFunction > > tc_cache_
Saved InterpolatingFunction objects corresponding to previously-encountered transmission coefficient ...
virtual double compute_transmission_coefficient(double total_KE_CM, int fragment_pdg, int two_j, int l, int two_s, int target_charge=0)=0
Do the actual calculation of the transmission coefficient.
virtual double transmission_coefficient(double total_KE_CM, int fragment_pdg, int two_j, int l, int two_s, int target_charge=0) override
Calculate the transmission coefficient for a nuclear fragment.
Abstract base class for an approximate representation of a 1D continuous function.
OpticalModel(int Z, int A)
int A() const
Get the mass number.
int Z() const
Get the atomic number.