Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-27 09:14:58

0001 // lAger: General Purpose l/A-event Generator
0002 // Copyright (C) 2016-2021 Sylvester Joosten <sjoosten@anl.gov>
0003 // 
0004 // This file is part of lAger.
0005 // 
0006 // lAger is free software: you can redistribute it and/or modify
0007 // it under the terms of the GNU General Public License as published by
0008 // the Free Shoftware Foundation, either version 3 of the License, or
0009 // (at your option) any later version.
0010 // 
0011 // lAger is distributed in the hope that it will be useful,
0012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
0013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0014 // GNU General Public License for more details.
0015 // 
0016 // You should have received a copy of the GNU General Public License
0017 // along with lAger.  If not, see <https://www.gnu.org/licenses/>.
0018 // 
0019 
0020 #ifndef LAGER_GEN_BEAM_VERTEX_GEN_LOADED
0021 #define LAGER_GEN_BEAM_VERTEX_GEN_LOADED
0022 
0023 #include <lager/core/generator.hh>
0024 #include <lager/core/interval.hh>
0025 #include <lager/core/particle.hh>
0026 #include <lager/gen/initial/data.hh>
0027 #include <lager/gen/initial/generator.hh>
0028 
0029 namespace lager {
0030 namespace initial {
0031 
0032 // =============================================================================
0033 // vertex at a specific position (default: 0,0,0)
0034 // =============================================================================
0035 class origin_vertex : public vertex_generator {
0036 public:
0037   origin_vertex(const configuration& cf, const string_path& path,
0038                 std::shared_ptr<TRandom> r)
0039       : vertex_generator{std::move(r)}
0040       , vertex_{0, 0, cf.get<double>(path / "vz", 0), 0} {
0041     LOG_INFO("initial::origin_vertex", "Vertex generator initialized");
0042   }
0043 
0044   virtual particle::XYZTVector generate() { return vertex_; }
0045   virtual double max_cross_section() const { return 1.; }
0046   virtual double phase_space() const { return 1.; }
0047 
0048 protected:
0049   const particle::XYZTVector vertex_;
0050 };
0051 
0052 class linear_vertex : public vertex_generator {
0053 public:
0054   linear_vertex(const configuration& cf, const string_path& path,
0055                 std::shared_ptr<TRandom> r)
0056       : vertex_generator{std::move(r)}
0057       , range_{cf.get_range<double>(path / "range")} {
0058     LOG_INFO("initial::linear_vertex", "Vertex generator initialized");
0059     LOG_INFO("initial::linear_vertex",
0060              "Vertex range [cm]: [" + std::to_string(range_.min) + ", " +
0061                  std::to_string(range_.max) + "]");
0062   }
0063 
0064   virtual particle::XYZTVector generate() {
0065     const double vz = rng()->Uniform(range_.min, range_.max);
0066     LOG_JUNK2("linear_vertex", "Vertex position [cm]: " + std::to_string(vz));
0067     return {0., 0., vz, 0};
0068   }
0069   virtual double max_cross_section() const { return 1.; }
0070   virtual double phase_space() const { return 1.; }
0071 
0072 protected:
0073   const interval<double> range_;
0074 };
0075 
0076 } // namespace initial
0077 } // namespace lager
0078 
0079 #endif