LDMX Software
simcore::BertiniExactlyNProductsProcess Class Reference

Public Member Functions

 BertiniExactlyNProductsProcess (double threshold, int zmin, double emin, std::vector< int > pdg_ids, bool check_allmatch, int n_products)
 
bool acceptProjectile (const G4HadProjectile &projectile) const override
 
bool acceptTarget (const G4Nucleus &targetNucleus) const override
 
bool acceptEvent () const override
 
- Public Member Functions inherited from simcore::BertiniEventTopologyProcess
 BertiniEventTopologyProcess (bool count_light_ions=true)
 
G4HadFinalState * ApplyYourself (const G4HadProjectile &projectile, G4Nucleus &targetNucleus) override
 
void cleanupSecondaries ()
 
constexpr bool isLightIon (const int pdgCode) const
 Check if the PDG code corresponds to a light ion nucleus.
 
constexpr bool skipCountingParticle (const int pdgcode) const
 Whether or not to include a particular particle type in any counting.
 
virtual void incrementEventWeight (int N)
 

Private Attributes

double threshold_
 
int zmin_
 
double emin_
 
std::vector< int > pdg_ids_
 
bool check_allmatch_
 
int n_products_
 

Detailed Description

Definition at line 12 of file BertiniExactlyNProductsModel.h.

Constructor & Destructor Documentation

◆ BertiniExactlyNProductsProcess()

simcore::BertiniExactlyNProductsProcess::BertiniExactlyNProductsProcess ( double threshold,
int zmin,
double emin,
std::vector< int > pdg_ids,
bool check_allmatch,
int n_products )
inline

Definition at line 14 of file BertiniExactlyNProductsModel.h.

17 : BertiniEventTopologyProcess{},
18 threshold_{threshold},
19 zmin_{zmin},
20 emin_{emin},
21 pdg_ids_{pdg_ids},
22 check_allmatch_{check_allmatch},
23 n_products_{n_products} {}

Member Function Documentation

◆ acceptEvent()

bool simcore::BertiniExactlyNProductsProcess::acceptEvent ( ) const
overridevirtual

Implements simcore::BertiniEventTopologyProcess.

Definition at line 9 of file BertiniExactlyNProductsModel.cxx.

9 {
10 int secondaries{theParticleChange.GetNumberOfSecondaries()};
11 int n_hard{0};
12 std::vector<int> matching_count(pdg_ids_.size(), 0);
13
14 for (int i{0}; i < secondaries; ++i) {
15 const auto secondary{theParticleChange.GetSecondary(i)->GetParticle()};
16 const auto pdg_code{secondary->GetDefinition()->GetPDGEncoding()};
17 const auto energy{secondary->GetKineticEnergy()};
18
19 if (energy > threshold_) {
20 ++n_hard;
21 for (size_t j{0}; j < matching_count.size(); ++j) {
22 if (pdg_code == pdg_ids_[j]) ++matching_count[j];
23 }
24 }
25 }
26
27 int total_matched =
28 std::accumulate(matching_count.begin(), matching_count.end(), 0);
29
30 bool all_matched =
31 std::find(std::begin(matching_count), std::end(matching_count), 0) ==
32 std::end(matching_count);
33
34 if (total_matched == n_products_ && n_hard == total_matched &&
35 (!check_allmatch_ || all_matched)) {
36 return true;
37 }
38
39 return false;
40}

◆ acceptProjectile()

bool simcore::BertiniExactlyNProductsProcess::acceptProjectile ( const G4HadProjectile & projectile) const
inlineoverridevirtual

Implements simcore::BertiniEventTopologyProcess.

Definition at line 27 of file BertiniExactlyNProductsModel.h.

27 {
28 return projectile.GetKineticEnergy() >= emin_;
29 }

◆ acceptTarget()

bool simcore::BertiniExactlyNProductsProcess::acceptTarget ( const G4Nucleus & targetNucleus) const
inlineoverridevirtual

Implements simcore::BertiniEventTopologyProcess.

Definition at line 31 of file BertiniExactlyNProductsModel.h.

31 {
32 return targetNucleus.GetZ_asInt() >= zmin_;
33 }

Member Data Documentation

◆ check_allmatch_

bool simcore::BertiniExactlyNProductsProcess::check_allmatch_
private

Definition at line 42 of file BertiniExactlyNProductsModel.h.

◆ emin_

double simcore::BertiniExactlyNProductsProcess::emin_
private

Definition at line 40 of file BertiniExactlyNProductsModel.h.

◆ n_products_

int simcore::BertiniExactlyNProductsProcess::n_products_
private

Definition at line 43 of file BertiniExactlyNProductsModel.h.

◆ pdg_ids_

std::vector<int> simcore::BertiniExactlyNProductsProcess::pdg_ids_
private

Definition at line 41 of file BertiniExactlyNProductsModel.h.

◆ threshold_

double simcore::BertiniExactlyNProductsProcess::threshold_
private

Definition at line 38 of file BertiniExactlyNProductsModel.h.

◆ zmin_

int simcore::BertiniExactlyNProductsProcess::zmin_
private

Definition at line 39 of file BertiniExactlyNProductsModel.h.


The documentation for this class was generated from the following files: