MARLEY (Model of Argon Reaction Low Energy Yields)  v1.2.0
A Monte Carlo event generator for tens-of-MeV neutrino interactions
TargetAtom.hh
1 //
5 // This file is part of MARLEY (Model of Argon Reaction Low Energy Yields)
6 //
7 // MARLEY is free software: you can redistribute it and/or modify it under the
8 // terms of version 3 of the GNU General Public License as published by the
9 // Free Software Foundation.
10 //
11 // For the full text of the license please see COPYING or
12 // visit http://opensource.org/licenses/GPL-3.0
13 //
14 // Please respect the MCnet academic usage guidelines. See GUIDELINES
15 // or visit https://www.montecarlonet.org/GUIDELINES for details.
16 
17 #pragma once
18 
19 // Standard library includes
20 #include <ostream>
21 #include <string>
22 
23 namespace marley {
24 
26  class TargetAtom {
27 
28  public:
29 
32  explicit TargetAtom( int pdg );
33 
38  explicit TargetAtom( int Z, int A );
39 
47  inline explicit operator int() const { return pdg_; }
48 
51  inline bool operator==(const marley::TargetAtom& ta) const
52  {
53  return pdg_ == ta.pdg_;
54  }
55 
56  inline bool operator!=(const marley::TargetAtom& ta) const
57  {
58  return pdg_ != ta.pdg_;
59  }
60 
63  inline bool operator<(const marley::TargetAtom& ta) const
64  {
65  return pdg_ < ta.pdg_;
66  }
67 
70  std::string to_string() const;
71 
73  int Z() const;
74 
76  int A() const;
77 
79  inline int pdg() const { return pdg_; }
80 
81  protected:
82 
88  void check_pdg_validity() const;
89 
91  int pdg_;
92  };
93 
94 }
95 
96 inline std::ostream& operator<<(std::ostream& out, const marley::TargetAtom& ta)
97 {
98  out << ta.to_string();
99  return out;
100 }
An atomic target for a lepton scattering reaction.
Definition: TargetAtom.hh:26
int A() const
Returns the mass number of the target atom.
Definition: TargetAtom.cc:36
int pdg() const
Returns the nuclear PDG code of the target atom.
Definition: TargetAtom.hh:79
int pdg_
PDG code for the nucleus of the target atom.
Definition: TargetAtom.hh:91
bool operator<(const marley::TargetAtom &ta) const
Define the less-than operator so that TargetAtom objects can be used as the keys of a std::map.
Definition: TargetAtom.hh:63
std::string to_string() const
Converts the PDG code to a string representation (e.g., "40Ar")
Definition: TargetAtom.cc:40
void check_pdg_validity() const
Helper function for the constructors. Checks the atom's PDG code for validity.
Definition: TargetAtom.cc:46
bool operator==(const marley::TargetAtom &ta) const
Two TargetAtom objects are considered equal if their nuclear PDG codes match.
Definition: TargetAtom.hh:51
TargetAtom(int pdg)
Create a TargetAtom object from an integer PDG code.
Definition: TargetAtom.cc:23
int Z() const
Returns the proton number of the target atom.
Definition: TargetAtom.cc:32