|
||||
File indexing completed on 2025-01-18 09:13:04
0001 // This file is part of the ACTS project. 0002 // 0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project 0004 // 0005 // This Source Code Form is subject to the terms of the Mozilla Public 0006 // License, v. 2.0. If a copy of the MPL was not distributed with this 0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/. 0008 0009 #pragma once 0010 0011 #include "Acts/Definitions/Algebra.hpp" 0012 0013 #include <array> 0014 0015 namespace ActsFatras { 0016 0017 /// Generate ranom numbers within the regular, centric Rectangle. 0018 struct RectangleRandom { 0019 double xmax; 0020 double ymax; 0021 0022 /// Constructor from half lengths. 0023 /// 0024 /// @param xmax_ the half length in x 0025 /// @param ymax_ the half length in y 0026 RectangleRandom(double xmax_, double ymax_) : xmax(xmax_), ymax(ymax_) {} 0027 0028 /// Given two random numbers @param r0 and @param r1 0029 /// generate a x/y position inside the Rectangle @return 0030 /// 0031 /// @note r0, r1 need to be within [0,1] 0032 Acts::Vector2 operator()(double r0, double r1) const { 0033 return {(2 * r0 - 1) * xmax, (2 * r1 - 1) * ymax}; 0034 } 0035 }; 0036 0037 /// Create Random variables inside a regular Trapezoid. 0038 struct TrapezoidRandom { 0039 double xminy; 0040 double xmaxy; 0041 double ymin; 0042 double ymax; 0043 0044 /// Constructor for TrapezoidBounds : PlaneBounds 0045 /// 0046 /// @param xminy_ the x value at minimum y value 0047 /// @param xmaxy_ the x value at maximum y value 0048 /// @param ymax_ the half length in y 0049 TrapezoidRandom(double xminy_, double xmaxy_, double ymax_) 0050 : xminy(xminy_), xmaxy(xmaxy_), ymin(-ymax_), ymax(ymax_) {} 0051 0052 /// Constructor for DiscTrapezoidBounds : DiscBounds 0053 /// 0054 /// @param xminy_ the x value at minimum y value 0055 /// @param xmaxy_ the x value at maximum y value 0056 /// @param ymin_ the minimum y value (conicides with rmin) 0057 /// @param ymax_ the maximum y value 0058 TrapezoidRandom(double xminy_, double xmaxy_, double ymin_, double ymax_) 0059 : xminy(xminy_), xmaxy(xmaxy_), ymin(ymin_), ymax(ymax_) {} 0060 0061 /// Given two random numbers @param r0 and @param r1 0062 /// generate a x/y position inside the Trapezoid @return 0063 /// 0064 /// @note r0, r1 need to be within [0,1] 0065 Acts::Vector2 operator()(double r0, double r1) const { 0066 double y = ymin + (ymax - ymin) * r1; 0067 double xmax = xminy + (xmaxy - xminy) / (ymax - ymin) * (y - ymin); 0068 double x = (2 * r0 - 1) * xmax; 0069 return {x, y}; 0070 } 0071 }; 0072 0073 /// Generate ranom numbers within disc ring 0074 struct DiscRandom { 0075 double rmin; 0076 double rmax; 0077 double phimin; 0078 double phimax; 0079 0080 /// Constructor for RadiablBounds : DiscBounds 0081 /// 0082 /// @param rmin_ the minimum r of the disc 0083 /// @param rmax_ the maximum r of the disc 0084 /// @param phimin_ the minimum phi value of the disc 0085 /// @param phimax_ the maximum phi value of the disc 0086 DiscRandom(double rmin_, double rmax_, double phimin_, double phimax_) 0087 : rmin(rmin_), rmax(rmax_), phimin(phimin_), phimax(phimax_) {} 0088 0089 /// Given two random numbers @param r0 and @param r1 0090 /// generate a x/y position inside the Disc @return 0091 /// 0092 /// @note r0, r1 need to be within [0,1] 0093 Acts::Vector2 operator()(double r0, double r1) const { 0094 double r = rmin + (rmax - rmin) * r0; 0095 double phi = phimin + (phimax - phimin) * r1; 0096 return {r * std::cos(phi), r * std::sin(phi)}; 0097 } 0098 }; 0099 0100 /// Generate random numbers within an Annulus object 0101 struct AnnulusRandom { 0102 double rmin; 0103 double rmax; 0104 double phimins; // strip system 0105 double phimaxs; // strip system 0106 double originxs; // strip system origin x 0107 double originys; // strip system origin y 0108 0109 /// Constructor for RadiablBounds : DiscBounds 0110 /// 0111 /// @param rmin_ the minimum r of the disc 0112 /// @param rmax_ the maximum r of the disc 0113 /// @param phimins_ the minimum phi - strip system 0114 /// @param phimaxs_ the maximum phi - strip system 0115 /// @param originxs_ the origin x - strip system 0116 /// @param originys_ the origin y - strip system 0117 AnnulusRandom(double rmin_, double rmax_, double phimins_, double phimaxs_, 0118 double originxs_, double originys_) 0119 : rmin(rmin_), 0120 rmax(rmax_), 0121 phimins(phimins_), 0122 phimaxs(phimaxs_), 0123 originxs(originxs_), 0124 originys(originys_) {} 0125 0126 /// Given two random numbers @param r0 and @param r1 0127 /// generate a x/y position inside Annulus shape and @return 0128 /// 0129 /// @note r0, r1 need to be within [0,1] 0130 Acts::Vector2 operator()(double r0, double r1) const { 0131 double r = rmin + (rmax - rmin) * r0; 0132 double phi = phimins + (phimaxs - phimins) * r1; 0133 return {r * std::cos(phi), r * std::sin(phi)}; 0134 } 0135 }; 0136 0137 } // namespace ActsFatras
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |