Added underflow bin (energy) to indices that are
drawn from
This commit is contained in:
@@ -18,6 +18,7 @@ std::mt19937* RandomNumbers::engine() {
|
||||
}
|
||||
|
||||
// does NOT shuffle the indices!
|
||||
// num bins for the energy binning should include the underflow bin!
|
||||
RandomIndex::RandomIndex(blitz::TinyVector<int, 5> num_bins) :
|
||||
num_bins_(num_bins){
|
||||
|
||||
@@ -44,6 +45,8 @@ bool RandomIndex::visited_all() {
|
||||
|
||||
// return the next index in the shuffled index vector. Returns the last
|
||||
// index if all bins have been visited. Reshuffling resets this.
|
||||
// Note that the underflow bin for the energy is included, i.e. min index for E
|
||||
// is -1 not 0
|
||||
blitz::TinyVector<int, 5> RandomIndex::index() {
|
||||
size_t tmp_one_dimensional_idx = one_dimensional_indices_[current_index_in_vector_];
|
||||
|
||||
@@ -63,6 +66,8 @@ blitz::TinyVector<int, 5> RandomIndex::index() {
|
||||
tmp_one_dimensional_idx -= tmp * current_prod;
|
||||
}
|
||||
|
||||
return_index(4) -= 1;
|
||||
|
||||
if(!visited_all())
|
||||
current_index_in_vector_++;
|
||||
|
||||
|
||||
@@ -65,7 +65,8 @@ TrackedSpecie::TrackedSpecie(
|
||||
num_bins(0) = tmp(0); num_bins(1) = tmp(1); num_bins(2) = tmp(2);
|
||||
|
||||
num_bins(3) = density_field->pitchAngleBinning()->numBins();
|
||||
num_bins(4) = density_field->energyBinning()->numBins();
|
||||
// include underflow bin in the energy direction only
|
||||
num_bins(4) = density_field->energyBinning()->numBins() + 1;
|
||||
|
||||
random_index_ = std::make_shared<RandomIndex> (RandomIndex(num_bins));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user