LDMX Software
BertiniExactlyNProductsModel.cxx
1#include "SimCore/PhotoNuclearModels/BertiniExactlyNProductsModel.h"
2
3#include <numeric>
4
5namespace simcore {
6
7bool BertiniExactlyNProductsProcess::acceptEvent() const {
8 int secondaries{theParticleChange.GetNumberOfSecondaries()};
9 int n_hard{0};
10 std::vector<int> matching_count(pdg_ids_.size(), 0);
11
12 for (int i{0}; i < secondaries; ++i) {
13 const auto secondary{theParticleChange.GetSecondary(i)->GetParticle()};
14 const auto pdg_code{secondary->GetDefinition()->GetPDGEncoding()};
15 const auto energy{secondary->GetKineticEnergy()};
16
17 if (energy > threshold_) {
18 ++n_hard;
19 for (size_t j{0}; j < matching_count.size(); ++j) {
20 if (pdg_code == pdg_ids_[j]) ++matching_count[j];
21 }
22 }
23 }
24
25 int total_matched =
26 std::accumulate(matching_count.begin(), matching_count.end(), 0);
27
28 bool all_matched =
29 std::find(std::begin(matching_count), std::end(matching_count), 0) ==
30 std::end(matching_count);
31
32 if (total_matched == n_products_ && n_hard == total_matched &&
33 (!check_allmatch_ || all_matched)) {
34 return true;
35 }
36
37 return false;
38}
39
41 G4ProcessManager* process_manager) {
42 auto photo_nuclear_process{
43 new G4HadronInelasticProcess("photonNuclear", G4Gamma::Definition())};
44
45 auto model{new BertiniExactlyNProductsProcess{
46 threshold_, zmin_, emin_, pdg_ids_, check_allmatch_, n_products_}};
47 model->SetMaxEnergy(15 * CLHEP::GeV);
48 addPNCrossSectionData(photo_nuclear_process);
49 photo_nuclear_process->RegisterMe(model);
50 process_manager->AddDiscreteProcess(photo_nuclear_process);
51}
52} // namespace simcore
53
54DECLARE_PHOTONUCLEAR_MODEL(simcore::BertiniExactlyNProductsModel)
void constructGammaProcess(G4ProcessManager *processManager)
The primary part of the model interface, responsible for adding the desired G4HadronicInteraction to ...
virtual void addPNCrossSectionData(G4HadronInelasticProcess *process) const
Default implementation for adding XS data for the process.
Dynamically loadable photonuclear models either from SimCore or external libraries implementing this ...