16 #include <boost/functional/hash.hpp>
27 ParticleData::ParticleData() {
28 _signatureIndex = 0ul;
31 ParticleData::~ParticleData() {
33 _signatureIndex = 0ul;
37 return _signatures[_signatureIndex].id;
40 HashId ParticleData::hadronicId()
const {
41 return _signatures[_signatureIndex].hadronicId;
44 const vector<double>& ParticleData::masses()
const {
45 return _signatures[_signatureIndex].masses;
48 bool ParticleData::checkValidSignature(
PdgId parent,
const vector<PdgId>& daughters,
49 const vector<PdgId>& granddaughters) {
50 vector<PdgId> flippedDaughters;
51 vector<PdgId> flippedGrandDaughters;
52 flippedDaughters.reserve(daughters.size());
53 flippedGrandDaughters.reserve(granddaughters.size());
54 transform(daughters.begin(),daughters.end(),back_inserter(flippedDaughters), [parent](
PdgId id) ->
PdgId {
return (parent > 0) ?
id :
flipSign(
id); });
55 transform(granddaughters.begin(),granddaughters.end(),back_inserter(flippedGrandDaughters), [parent](
PdgId id) ->
PdgId {
return (parent > 0) ?
id :
flipSign(
id); });
56 auto result1 = daughters;
57 result1.reserve(daughters.size() + granddaughters.size());
58 result1.insert(result1.end(), granddaughters.begin(), granddaughters.end());
60 transform(result2.begin(),result2.end(), result2.begin(),[parent](
PdgId id) ->
PdgId {
return (parent > 0) ?
id :
flipSign(
id);});
61 return equal(result1.begin(),result1.end(),result2.begin());
64 void ParticleData::addProcessSignature(
PdgId parent,
const vector<PdgId>& daughters,
65 const vector<PdgId>& granddaughters) {
66 ASSERT_MSG(checkValidSignature(parent, daughters, granddaughters),
67 "Particle order does not respect Hammer Convention in addProcessSignature. Shame on you!");
71 newsig.
calcIds(daughters.size());
76 _signatures.push_back(newsig);
79 void ParticleData::Signature::calcIds(
size_t numDaughters) {
81 vector<PdgId> hadDaughters;
82 copy_n(daughters.begin(), numDaughters, back_inserter(hadDaughters));
83 hadDaughters.erase(remove_if(hadDaughters.begin(), hadDaughters.end(), [](
PdgId idx){
return (abs(idx) < 100); }),
85 hadronicId =
processID(parent, hadDaughters);
88 void ParticleData::Signature::addMass(
PdgId idx) {
89 PID& pdg = PID::instance();
90 masses.push_back(pdg.
getMass(idx));
93 void ParticleData::Signature::addMasses(
const vector<PdgId>& ids) {
94 PID& pdg = PID::instance();
96 masses.push_back(pdg.
getMass(elem));
100 bool ParticleData::setSignatureIndex(
size_t idx) {
101 if(idx > _signatures.size()) {
102 _signatureIndex = 0ul;
106 _signatureIndex = idx;
111 size_t ParticleData::numSignatures()
const {
112 return _signatures.size();
std::vector< PdgId > daughters
particle IDs of the (ordered) daughter (and granddaughter) particles.
#define ASSERT_MSG(x, msg)
PDG codes to UID functions.
PdgId parent
particle ID of the parent particle
std::vector< PdgId > combineDaughters(const std::vector< PdgId > &daughters, const std::vector< PdgId > &subDaughters)
combine list of codes of daughters and grandaughters (for processes which parameterise two subsequent...
Hammer decay PDG code management.
Decay signature information.
std::vector< double > masses
list of particle mass values parent + daughters (in the same order as the particle ID vector) ...
void addMasses(const std::vector< PdgId > &ids)
appends the masses of a list of particles to the mass list
void calcIds(size_t numDaughters)
computes the unique IDs from the PDG codes
void addMass(PdgId id)
appends the mass of a particle to the mass list
PdgId flipSign(const PdgId &id)
return the PDG code of the conjugate particle (itself if self-conjugate)
Hammer class for dealing with particle data.
Hammer particle data class.
HashId processID(PdgId parent, const std::vector< PdgId > &allDaughters)
compute a unique ID for a given process based on the PDG codes of the parent particle and the ordered...
double getMass(PdgId id) const
particle mass from a PDG code