R3BROOT
R3B analysis software
Loading...
Searching...
No Matches
CosmicMuonDistributions.h
Go to the documentation of this file.
1#pragma once
2#include <Math/GenVector/Cartesian3D.h>
3#include <R3BNeulandCommon.h>
4#include <TRandom.h>
5#include <stdexcept>
6
7namespace R3B::Neuland
8{
10 {
11 public:
12 void set_mean_sigma(double mean, double sigma)
13 {
14 mean_ = mean;
15 sigma_ = sigma;
16 }
17
18 auto operator()(TRandom* rd_engine_) const -> double
19 {
20 auto energy = rd_engine_->Gaus(mean_, sigma_);
21 return energy;
22 };
23
24 private:
25 double mean_ = 0.;
26 double sigma_ = 0.;
27 };
28
30 {
31 public:
32 auto operator()(TRandom* rd_engine_) const -> double
33 {
34 const auto n_steps = 10000;
35 const auto step_size = 0.1;
36
37 auto target_distribution = [](double val) -> double { return std::pow(std::cos(val), 2.); };
38
39 double current_angle = 0.;
40 double new_angle = 0.;
41
42 for (int i = 0; i < n_steps; ++i)
43 {
44 new_angle = rd_engine_->Gaus(current_angle, step_size);
45
46 if (new_angle < -M_PI_2 || new_angle > M_PI_2)
47 {
48 continue;
49 }
50
51 double acceptance_ratio = target_distribution(new_angle) / target_distribution(current_angle);
52
53 if (rd_engine_->Uniform(0.0, 1.0) < acceptance_ratio)
54 {
55 current_angle = new_angle;
56 }
57 }
58
59 return current_angle;
60 }
61 };
62
64 {
65 public:
66 double xmin{};
67 double xmax{};
68 double ymin{};
69 double ymax{};
70 double zmin{};
71 double zmax{};
72 };
73
75 {
76 public:
77 void set_box_size(DetectorBoxSize detector_box_size)
78 {
79 detector_box_size_.xmin = detector_box_size.xmin;
80 detector_box_size_.xmax = detector_box_size.xmax;
81 detector_box_size_.ymin = detector_box_size.ymin;
82 detector_box_size_.ymax = detector_box_size.ymax;
83 detector_box_size_.zmin = detector_box_size.zmin;
84 detector_box_size_.zmax = detector_box_size.zmax;
85 }
86
87 auto operator()(TRandom* rd_engine_) const -> ROOT::Math::Cartesian3D<double>
88 {
89 auto box_positions = ROOT::Math::Cartesian3D<double>{};
90 if (rd_engine_ != nullptr)
91 {
92 box_positions.SetX(rd_engine_->Uniform(detector_box_size_.xmin, detector_box_size_.xmax));
93 box_positions.SetY(rd_engine_->Uniform(detector_box_size_.ymin, detector_box_size_.ymax));
94 box_positions.SetZ(rd_engine_->Uniform(detector_box_size_.zmin, detector_box_size_.zmax));
95 return box_positions;
96 }
97 throw std::runtime_error("rnd engine is nullptr!");
98 }
99
100 private:
101 DetectorBoxSize detector_box_size_{};
102 };
103} // namespace R3B::Neuland
auto operator()(TRandom *rd_engine_) const -> double
auto operator()(TRandom *rd_engine_) const -> double
void set_mean_sigma(double mean, double sigma)
void set_box_size(DetectorBoxSize detector_box_size)
auto operator()(TRandom *rd_engine_) const -> ROOT::Math::Cartesian3D< double >
Simulation of NeuLAND Bar/Paddle.