Hammer  1.0.0
Helicity Amplitude Module for Matrix Element Reweighting
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ParticleUtils.hh
Go to the documentation of this file.
1 ///
2 /// @file ParticleUtils.hh
3 /// @brief PDG codes to UID functions
4 ///
5 
6 //**** This file is a part of the HAMMER library
7 //**** Copyright (C) 2016 - 2020 The HAMMER Collaboration
8 //**** HAMMER is licensed under version 3 of the GPL; see COPYING for details
9 //**** Please note the MCnet academic guidelines; see GUIDELINES for details
10 
11 // -*- C++ -*-
12 #ifndef HAMMER_TOOLS_ParticleUtils
13 #define HAMMER_TOOLS_ParticleUtils
14 
15 #include <vector>
16 #include <functional>
17 
18 #include "Hammer/IndexTypes.hh"
19 #include "Hammer/Tools/Pdg.fhh"
20 
21 namespace Hammer {
22 
23  class Particle;
24 
25  /// @brief sorting function for PDG ids for computing hashes.
26  /// the codes are ordered if \f$ |a|<|b| \f$ or if \f$ |a|=|b| \f$ and if \f$ a<b \f$
27  /// @param[in] a the first PDG code
28  /// @param[in] b the second PDG code
29  bool pdgSorter(PdgId a, PdgId b);
30 
31  /// @brief compute a unique ID for a given process based on the PDG codes of the parent particle and
32  /// the ordered list of the daughters (and grandaughters if present)
33  /// @param[in] parent the PDG code of the parent particle
34  /// @param[in] allDaughters the ordered list of PDG codes of the daughters particles
35  /// @return the unique id
36  HashId processID(PdgId parent, const std::vector<PdgId>& allDaughters);
37 
38  HashId combineProcessIDs(const std::set<HashId>& allIds);
39 
40  /// @brief combine list of codes of daughters and grandaughters (for processes which parameterise
41  /// two subsequent decays in a single amplitude) in a single list for computing hashes
42  /// the convention is that daughters are ordered within themselves, grandDaughters are ordered
43  /// within themselves, and then the two groups are concatenated with daughters first
44  /// @param[in] daughters
45  /// @param[in] subDaughters
46  /// @return the combined list
47  std::vector<PdgId> combineDaughters(const std::vector<PdgId>& daughters,
48  const std::vector<PdgId>& subDaughters = {});
49 
50  /// @brief return the PDG codes of the conjugate particles (itself if self-conjugate)
51  /// for all the PDG codes in alist
52  /// @param[in] list the PDG codes
53  std::vector<PdgId> flipSigns(const std::vector<PdgId>& list);
54 
55  /// @brief return the PDG code of the conjugate particle (itself if self-conjugate)
56  /// @param[in] id the PDG code
57  PdgId flipSign(const PdgId& id);
58 
59  /// @brief checks whether two particles are ordered according to the PDG code ordering used in computing hashes
60  /// (see `pdgSorter` for more info on the ordering)
61  /// @param[in] pdgGetter the PDG code extractor function
62  /// @param[in] a the first particle
63  /// @param[in] b the second particle
64  bool particlesByPdg(const std::function<PdgId(const Particle&)>& pdgGetter, const Particle& a, const Particle& b);
65 
66 
67 } // namespace Hammer
68 
69 #endif
Hammer data types declarations.
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...
bool particlesByPdg(const std::function< PdgId(const Particle &)> &pdgGetter, const Particle &a, const Particle &b)
checks whether two particles are ordered according to the PDG code ordering used in computing hashes ...
bool pdgSorter(PdgId a, PdgId b)
sorting function for PDG ids for computing hashes.
std::vector< PdgId > flipSigns(const std::vector< PdgId > &list)
return the PDG codes of the conjugate particles (itself if self-conjugate) for all the PDG codes in a...
Pdg forward declarations.
HashId combineProcessIDs(const std::set< HashId > &allIds)
PdgId flipSign(const PdgId &id)
return the PDG code of the conjugate particle (itself if self-conjugate)
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...
size_t HashId
Definition: IndexTypes.hh:31
int PdgId
Definition: Pdg.fhh:17