- Moved to array operations for main loops. - Changed to setting pointers to operator only once before loop. - Changed Population Containers - Added Recombination - Added Inelastic Scattering Kinematics - Reworked Elastic Scattering Cross Section - Reworked Elastic Scattering Kinematics - Reworked organisation of different particle species and corresponding operators
87 lines
2.4 KiB
C++
87 lines
2.4 KiB
C++
//
|
|
// average_container.h
|
|
// mc_electron
|
|
//
|
|
// Created by Christian Reiling on 10.05.19.
|
|
// Copyright © 2019 Christian Reiling. All rights reserved.
|
|
//
|
|
|
|
#ifndef average_container_h
|
|
#define average_container_h
|
|
|
|
|
|
#include "edge_container.h"
|
|
|
|
|
|
template <class T_Map>
|
|
class Average_Container : public Base_Container<T_Map> {
|
|
public:
|
|
Average_Container() : Base_Container<T_Map>() {}
|
|
Average_Container(std::string load_path) : Base_Container<T_Map>(load_path) {}
|
|
Average_Container(const Edge_Container<T_Map> &edgeContainer) {calcMap(edgeContainer);};
|
|
|
|
public:
|
|
void calcMap(const Edge_Container<T_Map> &edgeContainer);
|
|
private:
|
|
void rec_calcMap(const double &subMap, std::deque<double> Points);
|
|
template <typename T> void rec_calcMap(const T &subMapm, std::deque<double> Points);
|
|
|
|
public:
|
|
double get_value(std::deque<double> point);
|
|
};
|
|
|
|
|
|
template <class T_Map>
|
|
void Average_Container<T_Map>::calcMap(const Edge_Container<T_Map> &edgeContainer) {
|
|
T_Map edgeMap = edgeContainer.getMap();
|
|
if (edgeMap.empty()) {
|
|
std::stringstream ss;
|
|
ss<<"Average_Container::calcMap: Input Edge_Container empty.\n";
|
|
throw MyException(ss.str());
|
|
}
|
|
Base_Container<T_Map>::Map.clear();
|
|
std::deque<double> Points;
|
|
rec_calcMap(edgeMap, Points);
|
|
}
|
|
|
|
template <class T_Map>
|
|
void Average_Container<T_Map>::rec_calcMap(const double &subMap, std::deque<double> Points) {
|
|
Points.push_back(subMap);
|
|
Base_Container<T_Map>::addPoint(Points);
|
|
}
|
|
|
|
template <class T_Map>
|
|
template <typename T>
|
|
void Average_Container<T_Map>::rec_calcMap(const T &subMap, std::deque<double> Points) {
|
|
double curVal, nextVal, avgVal;
|
|
typename T::const_iterator curItr, nextItr;
|
|
for (nextItr = ++(subMap.cbegin()); nextItr!= subMap.cend(); nextItr++) {
|
|
curItr = nextItr;
|
|
--curItr;
|
|
curVal = curItr->first;
|
|
nextVal = nextItr->first;
|
|
avgVal = curVal + (nextVal-curVal)/2;
|
|
Points.push_back(avgVal);
|
|
rec_calcMap(curItr->second, Points);
|
|
Points.pop_back();
|
|
}
|
|
// insert last point as overflow value
|
|
curItr = (--subMap.cend());
|
|
Points.push_back(curItr->first);
|
|
rec_calcMap(curItr->second, Points);
|
|
}
|
|
|
|
|
|
template <class T_Map>
|
|
double Average_Container<T_Map>::get_value(std::deque <double> Point) {
|
|
Base_Container<T_Map>::checkEmpty();
|
|
if (Base_Container<T_Map>::Dim != Point.size()) {
|
|
std::stringstream ss;
|
|
ss<<"EdgeBase_Container::interpolate: deque point dimension missmatch.\n";
|
|
throw MyException(ss.str());
|
|
}
|
|
return (Base_Container<T_Map>::get_value(Point, Lower_bound_Over));
|
|
}
|
|
|
|
#endif /* average_container_h */
|