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
39 G4int fID;
40 G4int fType;
41 G4double fEkin;
42 G4double fX;
43 G4double fY;
44 G4double fZ;
45 G4double fTheta;
46 G4double fPhi;
47 G4double fPx;
48 G4double fPy;
49 G4double fPz;
50};
51
52
53class G4Event;
61class RMGGeneratorMUSUNCosmicMuons : public RMGVGenerator {
62
63 public:
64
65 RMGGeneratorMUSUNCosmicMuons();
66 ~RMGGeneratorMUSUNCosmicMuons() = default;
67
68 RMGGeneratorMUSUNCosmicMuons(RMGGeneratorMUSUNCosmicMuons const&) = delete;
69 RMGGeneratorMUSUNCosmicMuons& operator=(RMGGeneratorMUSUNCosmicMuons const&) = delete;
70 RMGGeneratorMUSUNCosmicMuons(RMGGeneratorMUSUNCosmicMuons&&) = delete;
71 RMGGeneratorMUSUNCosmicMuons& operator=(RMGGeneratorMUSUNCosmicMuons&&) = delete;
72
74 void GeneratePrimaries(G4Event*) override;
76 void SetParticlePosition(G4ThreeVector) override{};
77
79 void BeginOfRunAction(const G4Run*) override;
81 void EndOfRunAction(const G4Run*) override;
82
83 private:
84
85 void DefineCommands();
86 void SetMUSUNFile(G4String pathToFile);
87
92 bool PrepareCopy(std::string pathToFile);
93
94 std::unique_ptr<G4ParticleGun> fGun = nullptr;
95 std::unique_ptr<G4GenericMessenger> fMessenger = nullptr;
96 G4String fPathToFile = "";
97 std::filesystem::path fPathToTmpFolder;
98 std::filesystem::path fPathToTmpFile;
99
100 static RMGAnalysisReader* fAnalysisReader;
101 static bool fHasCartesianMomentum;
102
103 static RMGGeneratorMUSUNCosmicMuons_Data* fInputData;
104};
105
106#endif
107
108// 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:125
void GeneratePrimaries(G4Event *) override
Read the next muon entry from the temporary file and shoot it.
Definition RMGGeneratorMUSUNCosmicMuons.cc:165
void EndOfRunAction(const G4Run *) override
Close the input file and clean up the temporary directory.
Definition RMGGeneratorMUSUNCosmicMuons.cc:157
void SetParticlePosition(G4ThreeVector) override
No-op: vertex sampling is fixed by the input MUSUN file.
Definition RMGGeneratorMUSUNCosmicMuons.hh:76
Row schema for the MUSUN input ntuple consumed by RMGGeneratorMUSUNCosmicMuons.
Definition RMGGeneratorMUSUNCosmicMuons.hh:38