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 15 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 17 of file BertiniExactlyNProductsModel.h.

20 : BertiniEventTopologyProcess{},
21 threshold_{threshold},
22 zmin_{zmin},
23 emin_{emin},
24 pdg_ids_{pdg_ids},
25 check_allmatch_{check_allmatch},
26 n_products_{n_products} {}

Member Function Documentation

◆ acceptEvent()

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

Implements simcore::BertiniEventTopologyProcess.

Definition at line 7 of file BertiniExactlyNProductsModel.cxx.

7 {
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}

◆ acceptProjectile()

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

Implements simcore::BertiniEventTopologyProcess.

Definition at line 30 of file BertiniExactlyNProductsModel.h.

30 {
31 return projectile.GetKineticEnergy() >= emin_;
32 }

◆ acceptTarget()

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

Implements simcore::BertiniEventTopologyProcess.

Definition at line 34 of file BertiniExactlyNProductsModel.h.

34 {
35 return targetNucleus.GetZ_asInt() >= zmin_;
36 }

Member Data Documentation

◆ check_allmatch_

bool simcore::BertiniExactlyNProductsProcess::check_allmatch_
private

Definition at line 45 of file BertiniExactlyNProductsModel.h.

◆ emin_

double simcore::BertiniExactlyNProductsProcess::emin_
private

Definition at line 43 of file BertiniExactlyNProductsModel.h.

◆ n_products_

int simcore::BertiniExactlyNProductsProcess::n_products_
private

Definition at line 46 of file BertiniExactlyNProductsModel.h.

◆ pdg_ids_

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

Definition at line 44 of file BertiniExactlyNProductsModel.h.

◆ threshold_

double simcore::BertiniExactlyNProductsProcess::threshold_
private

Definition at line 41 of file BertiniExactlyNProductsModel.h.

◆ zmin_

int simcore::BertiniExactlyNProductsProcess::zmin_
private

Definition at line 42 of file BertiniExactlyNProductsModel.h.


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