Added underflow bin (energy) to indices that are

drawn from
This commit is contained in:
2025-05-23 16:58:42 +02:00
parent 786cb6d877
commit 59f4041238
2 changed files with 7 additions and 1 deletions
+5
View File
@@ -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_++;
+2 -1
View File
@@ -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));
}