BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
SlicedFormFactorList Class Reference

Class that contains and owns a list of form factors and the index of their containing layer. More...

Public Member Functions

 SlicedFormFactorList ()=default
 
 SlicedFormFactorList (SlicedFormFactorList &&other)=default
 
 ~SlicedFormFactorList ()=default
 
SlicedFormFactorListoperator= (SlicedFormFactorList &&other)=default
 
std::pair< const IFormFactor *, size_t > operator[] (size_t index) const
 
std::map< size_t, std::vector< HomogeneousRegion > > regionMap () const
 
size_t size () const
 

Static Public Member Functions

static SlicedFormFactorList createSlicedFormFactors (const IParticle &particle, const std::vector< Slice > &slices, double z_ref)
 

Private Member Functions

void addParticle (IParticle &particle, const std::vector< Slice > &slices, double z_ref)
 

Private Attributes

std::vector< std::pair< std::unique_ptr< IFormFactor >, size_t > > m_ff_list
 
std::map< size_t, std::vector< HomogeneousRegion > > m_region_map
 

Detailed Description

Class that contains and owns a list of form factors and the index of their containing layer.

This class also handles the slicing of form factors if they cross layer interfaces.

Definition at line 36 of file SlicedFormFactorList.h.

Constructor & Destructor Documentation

◆ SlicedFormFactorList() [1/2]

SlicedFormFactorList::SlicedFormFactorList ( )
default

◆ SlicedFormFactorList() [2/2]

SlicedFormFactorList::SlicedFormFactorList ( SlicedFormFactorList &&  other)
default

◆ ~SlicedFormFactorList()

SlicedFormFactorList::~SlicedFormFactorList ( )
default

Member Function Documentation

◆ addParticle()

void SlicedFormFactorList::addParticle ( IParticle particle,
const std::vector< Slice > &  slices,
double  z_ref 
)
private

Definition at line 44 of file SlicedFormFactorList.cpp.

46 {
47  auto slice_indices = SliceIndexSpan(particle, slices, z_ref);
48  bool single_layer = (slice_indices.first == slice_indices.second);
49  for (size_t i = slice_indices.first; i < slice_indices.second + 1; ++i) {
50  double z_top_i = SliceTopZ(i, slices);
51  kvector_t translation(0.0, 0.0, z_ref - z_top_i);
52  particle.translate(translation);
53  // if particle is contained in this layer, set limits to infinite:
54  ZLimits limits = single_layer ? ZLimits() : SlicesZLimits(slices, i);
55  auto sliced_particle = particle.createSlicedParticle(limits);
56  m_ff_list.emplace_back(std::move(sliced_particle.m_slicedff), i);
57  double thickness = slices[i].thickness();
58  if (thickness > 0.0)
59  ScaleRegions(sliced_particle.m_regions, 1 / thickness);
60  m_region_map[i].insert(m_region_map[i].end(), sliced_particle.m_regions.begin(),
61  sliced_particle.m_regions.end());
62  z_ref = z_top_i; // particle now has coordinates relative to z_top_i
63  }
64 }
virtual SlicedParticle createSlicedParticle(ZLimits limits) const
Creates a sliced form factor for this particle.
Definition: IParticle.cpp:28
void translate(kvector_t translation) final
Translates the particle.
Definition: IParticle.cpp:34
std::vector< std::pair< std::unique_ptr< IFormFactor >, size_t > > m_ff_list
std::map< size_t, std::vector< HomogeneousRegion > > m_region_map
Class that contains upper and lower limits of the z-coordinate for the slicing of form factors.
Definition: ZLimits.h:45

References IParticle::createSlicedParticle(), m_ff_list, m_region_map, and IParticle::translate().

Referenced by createSlicedFormFactors().

Here is the call graph for this function:

◆ createSlicedFormFactors()

SlicedFormFactorList SlicedFormFactorList::createSlicedFormFactors ( const IParticle particle,
const std::vector< Slice > &  slices,
double  z_ref 
)
static

Definition at line 32 of file SlicedFormFactorList.cpp.

35 {
36  SlicedFormFactorList result;
37  auto particles = particle.decompose();
38  for (auto* particle : particles) {
39  result.addParticle(*particle, slices, z_ref);
40  }
41  return result;
42 }
virtual SafePointerVector< IParticle > decompose() const
Decompose in constituent IParticle objects.
Definition: IParticle.cpp:87
Class that contains and owns a list of form factors and the index of their containing layer.
void addParticle(IParticle &particle, const std::vector< Slice > &slices, double z_ref)

References addParticle(), and IParticle::decompose().

Referenced by ProcessedLayout::processParticle().

Here is the call graph for this function:

◆ operator=()

SlicedFormFactorList& SlicedFormFactorList::operator= ( SlicedFormFactorList &&  other)
default

◆ operator[]()

std::pair< const IFormFactor *, size_t > SlicedFormFactorList::operator[] ( size_t  index) const

Definition at line 71 of file SlicedFormFactorList.cpp.

72 {
73  if (index >= size())
74  throw std::out_of_range("SlicedFormFactorList::operator[] error: "
75  "index out of range");
76  return {m_ff_list[index].first.get(), m_ff_list[index].second};
77 }

References m_ff_list, and size().

Here is the call graph for this function:

◆ regionMap()

std::map< size_t, std::vector< HomogeneousRegion > > SlicedFormFactorList::regionMap ( ) const

Definition at line 79 of file SlicedFormFactorList.cpp.

80 {
81  return m_region_map;
82 }

References m_region_map.

◆ size()

size_t SlicedFormFactorList::size ( ) const

Definition at line 66 of file SlicedFormFactorList.cpp.

67 {
68  return m_ff_list.size();
69 }

References m_ff_list.

Referenced by operator[]().

Member Data Documentation

◆ m_ff_list

std::vector<std::pair<std::unique_ptr<IFormFactor>, size_t> > SlicedFormFactorList::m_ff_list
private

Definition at line 55 of file SlicedFormFactorList.h.

Referenced by addParticle(), operator[](), and size().

◆ m_region_map

std::map<size_t, std::vector<HomogeneousRegion> > SlicedFormFactorList::m_region_map
private

Definition at line 56 of file SlicedFormFactorList.h.

Referenced by addParticle(), and regionMap().


The documentation for this class was generated from the following files: