remage
Simulation framework for HPGe-based experiments
 
Loading...
Searching...
No Matches
RMGGeomBench.hh
1// Copyright (C) 2025 Moritz Neuberger <https://orcid.org/0009-0001-8471-9076>
2//
3// This program is free software: you can redistribute it and/or modify it under
4// the terms of the GNU Lesser General Public License as published by the Free
5// Software Foundation, either version 3 of the License, or (at your option) any
6// later version.
7//
8// This program is distributed in the hope that it will be useful, but WITHOUT
9// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
10// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
11// details.
12//
13// You should have received a copy of the GNU Lesser General Public License
14// along with this program. If not, see <https://www.gnu.org/licenses/>.
15
16#ifndef _RMG_GEOMBENCH_HH_
17#define _RMG_GEOMBENCH_HH_
18
19#include <chrono>
20#include <memory>
21#include <string>
22#include <vector>
23
24#include "CLHEP/Units/SystemOfUnits.h"
25#include "G4AnalysisManager.hh"
26#include "G4GenericMessenger.hh"
27#include "G4LogicalVolume.hh"
28#include "G4ParticleGun.hh"
29#include "G4VPhysicalVolume.hh"
30
31#include "RMGGeomBenchOutputScheme.hh"
32#include "RMGVGenerator.hh"
33
34namespace u = CLHEP;
35
43class RMGGeomBench : public RMGVGenerator {
44
45 public:
46
47 RMGGeomBench();
48 ~RMGGeomBench();
49
50 RMGGeomBench(RMGGeomBench const&) = delete;
51 RMGGeomBench& operator=(RMGGeomBench const&) = delete;
52 RMGGeomBench(RMGGeomBench&&) = delete;
53 RMGGeomBench& operator=(RMGGeomBench&&) = delete;
54
56 void GeneratePrimaries(G4Event* event) override;
58 void SetParticlePosition(G4ThreeVector) override{};
60 void RecordBatchTime(int pixel_idx, double batch_time);
62 void SaveAllPixels();
63
65 void BeginOfRunAction(const G4Run* r) override;
67 void EndOfRunAction(const G4Run* r) override;
68
69 private:
70
71 // Helper to find the benchmark output scheme if it's active
72 RMGGeomBenchOutputScheme* GetBenchmarkOutputScheme();
73
74 std::unique_ptr<G4ParticleGun> fGun = nullptr;
75
76 std::unique_ptr<G4GenericMessenger> fMessenger = nullptr;
77 void DefineCommands();
78
79 int totalnevents;
80 int totalnpixels;
81 int neventsperpixel;
82
83 // Configurable sampling parameters (user-specified increments)
84 G4ThreeVector user_increment;
85 G4ThreeVector sampling_width;
86
87 // Calculated number of pixels based on increments and widths
88 int npixels_x;
89 int npixels_y;
90 int npixels_z;
91 size_t ID;
92
93 double starttime;
94 double currenttime;
95 double bunchstarttime;
96
97 // For tracking batches and calculating median
98 std::vector<std::vector<double>> pixel_batch_times; // One vector of batch times per pixel
99 int events_per_bunch;
100 int total_batch_rounds;
101 int current_batch_event;
102 int current_pixel_index;
103 int current_batch_round;
104
105 G4ThreeVector origin;
106 G4ThreeVector limit;
107 G4ThreeVector increment;
108};
109
110#endif
Output scheme for geometry navigation benchmark data.
Definition RMGGeomBenchOutputScheme.hh:38
void GeneratePrimaries(G4Event *event) override
Shoot a geantino from the pixel currently being benchmarked.
Definition RMGGeomBench.cc:407
void RecordBatchTime(int pixel_idx, double batch_time)
Append a batch timing to the running median for the given pixel.
Definition RMGGeomBench.cc:298
void SaveAllPixels()
Flush per-pixel median timings to the benchmark output scheme.
Definition RMGGeomBench.cc:314
void EndOfRunAction(const G4Run *r) override
Save aggregated timings to the output scheme.
Definition RMGGeomBench.cc:284
void BeginOfRunAction(const G4Run *r) override
Compute the sampling grid from the user-specified increments and widths.
Definition RMGGeomBench.cc:106
void SetParticlePosition(G4ThreeVector) override
No-op: vertex sampling is driven by the benchmark grid.
Definition RMGGeomBench.hh:58