remage
Simulation framework for HPGe-based experiments
Loading...
Searching...
No Matches
RMGGeneratorMUSUNCosmicMuons.hh
1// Copyright (C) 2024 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
17#ifndef _RMG_GENERATOR_MUSUN_COSMIC_MUONS_HH_
18#define _RMG_GENERATOR_MUSUN_COSMIC_MUONS_HH_
19
20#include <filesystem>
21
22#include "CLHEP/Units/SystemOfUnits.h"
23#include "G4GenericMessenger.hh"
24#include "G4ParticleGun.hh"
25
26#include "RMGAnalysisReader.hh"
27#include "RMGVGenerator.hh"
28#include "RMGVVertexGenerator.hh"
29
30namespace u = CLHEP;
31
40 G4int fID;
41 G4int fType;
42 G4double fEkin;
43 G4double fX;
44 G4double fY;
45 G4double fZ;
46 G4double fTheta;
47 G4double fPhi;
48 G4double fPx;
49 G4double fPy;
50 G4double fPz;
51};
52
53
54class G4Event;
62class RMGGeneratorMUSUNCosmicMuons : public RMGVGenerator {
63
64 public:
65
66 RMGGeneratorMUSUNCosmicMuons();
67 ~RMGGeneratorMUSUNCosmicMuons() = default;
68
69 RMGGeneratorMUSUNCosmicMuons(RMGGeneratorMUSUNCosmicMuons const&) = delete;
70 RMGGeneratorMUSUNCosmicMuons& operator=(RMGGeneratorMUSUNCosmicMuons const&) = delete;
71 RMGGeneratorMUSUNCosmicMuons(RMGGeneratorMUSUNCosmicMuons&&) = delete;
72 RMGGeneratorMUSUNCosmicMuons& operator=(RMGGeneratorMUSUNCosmicMuons&&) = delete;
73
75 void GeneratePrimaries(G4Event*) override;
77 void SetParticlePosition(G4ThreeVector) override{};
78
80 void BeginOfRunAction(const G4Run*) override;
82 void EndOfRunAction(const G4Run*) override;
83
84 private:
85
86 void DefineCommands();
87 void SetMUSUNFile(G4String pathToFile);
88
93 bool PrepareCopy(std::string pathToFile);
94
95 std::unique_ptr<G4ParticleGun> fGun = nullptr;
96 std::unique_ptr<G4GenericMessenger> fMessenger = nullptr;
97 G4String fPathToFile = "";
98 std::filesystem::path fPathToTmpFolder;
99 std::filesystem::path fPathToTmpFile;
100
101 static RMGAnalysisReader* fAnalysisReader;
102 static bool fHasCartesianMomentum;
103
104 static RMGGeneratorMUSUNCosmicMuons_Data* fInputData;
105};
106
107#endif
108
109// vim: tabstop=2 shiftwidth=2 expandtab
wrapper around G4VAnalysisReader instances with special handling for LH5 files.
Definition RMGAnalysisReader.hh:41
void BeginOfRunAction(const G4Run *) override
Convert the MUSUN ASCII input to Geant4 CSV and open it for reading.
Definition RMGGeneratorMUSUNCosmicMuons.cc:129
void GeneratePrimaries(G4Event *) override
Read the next muon entry from the temporary file and shoot it.
Definition RMGGeneratorMUSUNCosmicMuons.cc:188
void EndOfRunAction(const G4Run *) override
Close the input file and clean up the temporary directory.
Definition RMGGeneratorMUSUNCosmicMuons.cc:161
void SetParticlePosition(G4ThreeVector) override
No-op: vertex sampling is fixed by the input MUSUN file.
Definition RMGGeneratorMUSUNCosmicMuons.hh:77
Row schema for the MUSUN input ntuple consumed by RMGGeneratorMUSUNCosmicMuons.
Definition RMGGeneratorMUSUNCosmicMuons.hh:39