14 #include <boost/algorithm/string.hpp>
16 #include "yaml-cpp/yaml.h"
31 Log& PurePhaseSpaceDefs::getLog()
const {
32 return Log::getLog(
"Hammer.PurePhaseSpaceDefs");
35 void PurePhaseSpaceDefs::write(flatbuffers::FlatBufferBuilder* msgwriter,
38 auto numlabels = msgwriter->CreateVectorOfStrings(_purePhaseSpaceVerticesNames.numerator);
40 ids.reserve(_purePhaseSpaceVertices.numerator.size());
41 copy(_purePhaseSpaceVertices.numerator.begin(), _purePhaseSpaceVertices.numerator.end(), back_inserter(ids));
42 auto numids = msgwriter->CreateVector(ids);
43 Serial::FBPurePSBuilder numBuilder{*msgwriter};
44 numBuilder.add_labels(numlabels);
45 numBuilder.add_ids(numids);
46 purePSs->push_back(numBuilder.Finish());
47 auto denlabels = msgwriter->CreateVectorOfStrings(_purePhaseSpaceVerticesNames.denominator);
49 ids.reserve(_purePhaseSpaceVertices.denominator.size());
50 copy(_purePhaseSpaceVertices.denominator.begin(), _purePhaseSpaceVertices.denominator.end(), back_inserter(ids));
51 auto denids = msgwriter->CreateVector(ids);
52 Serial::FBPurePSBuilder denBuilder{*msgwriter};
53 denBuilder.add_labels(denlabels);
54 denBuilder.add_ids(denids);
55 purePSs->push_back(denBuilder.Finish());
59 if(msgreader !=
nullptr) {
60 auto pureps = msgreader->pureps();
61 ASSERT(pureps->size() != 0);
62 auto labels = pureps->Get(0)->labels();
63 auto ids = pureps->Get(0)->ids();
64 _purePhaseSpaceVerticesNames.numerator.clear();
65 _purePhaseSpaceVertices.numerator.clear();
67 _purePhaseSpaceVerticesNames.numerator.reserve(labels->size());
68 for (
unsigned int i = 0; i < labels->size(); ++i) {
69 _purePhaseSpaceVerticesNames.numerator.push_back(labels->Get(i)->c_str());
71 for (
unsigned int i = 0; i < ids->size(); ++i) {
72 _purePhaseSpaceVertices.numerator.insert(ids->Get(i));
75 labels = pureps->Get(1)->labels();
76 ids = pureps->Get(1)->ids();
77 _purePhaseSpaceVerticesNames.denominator.clear();
78 _purePhaseSpaceVertices.denominator.clear();
80 _purePhaseSpaceVerticesNames.denominator.reserve(labels->size());
81 for (
unsigned int i = 0; i < labels->size(); ++i) {
82 _purePhaseSpaceVerticesNames.denominator.push_back(labels->Get(i)->c_str());
84 for (
unsigned int i = 0; i < ids->size(); ++i) {
85 _purePhaseSpaceVertices.denominator.insert(ids->Get(i));
93 void PurePhaseSpaceDefs::clearPurePhaseSpaceVertices(
WTerm what) {
95 case WTerm::NUMERATOR:
96 _purePhaseSpaceVerticesNames.numerator.clear();
98 case WTerm::DENOMINATOR:
99 _purePhaseSpaceVerticesNames.denominator.clear();
102 _purePhaseSpaceVerticesNames.numerator.clear();
103 _purePhaseSpaceVerticesNames.denominator.clear();
108 void PurePhaseSpaceDefs::addPurePhaseSpaceVertices(
const set<string>& vertices,
WTerm what) {
110 case WTerm::NUMERATOR:
111 _purePhaseSpaceVerticesNames.numerator.insert(_purePhaseSpaceVerticesNames.numerator.end(),
112 vertices.begin(), vertices.end());
114 case WTerm::DENOMINATOR:
115 _purePhaseSpaceVerticesNames.denominator.insert(_purePhaseSpaceVerticesNames.denominator.end(),
116 vertices.begin(), vertices.end());
119 _purePhaseSpaceVerticesNames.numerator.insert(_purePhaseSpaceVerticesNames.numerator.end(),
120 vertices.begin(), vertices.end());
121 _purePhaseSpaceVerticesNames.denominator.insert(_purePhaseSpaceVerticesNames.denominator.end(),
122 vertices.begin(), vertices.end());
127 void PurePhaseSpaceDefs::addPurePhaseSpaceVertex(
const string& decay,
WTerm what) {
129 case WTerm::NUMERATOR:
130 _purePhaseSpaceVerticesNames.numerator.push_back(decay);
132 case WTerm::DENOMINATOR:
133 _purePhaseSpaceVerticesNames.denominator.push_back(decay);
136 _purePhaseSpaceVerticesNames.numerator.push_back(decay);
137 _purePhaseSpaceVerticesNames.denominator.push_back(decay);
144 PID& pdg = PID::instance();
145 for (
auto elem : _purePhaseSpaceVerticesNames.numerator) {
147 result.numerator.insert(temp.begin(),temp.end());
149 for (
auto elem : _purePhaseSpaceVerticesNames.denominator) {
151 result.denominator.insert(temp.begin(),temp.end());
159 auto itNum = _purePhaseSpaceVertices.numerator.find(
id);
160 auto itDen = _purePhaseSpaceVertices.denominator.find(
id);
161 bool foundnum = itNum != _purePhaseSpaceVertices.numerator.end();
162 bool foundden = itDen != _purePhaseSpaceVertices.denominator.end();
166 void PurePhaseSpaceDefs::init() {
167 _purePhaseSpaceVertices = purePhaseSpaceVertices();
171 out << YAML::convert<PurePhaseSpaceDefs>::encode(s);
179 Node convert<::Hammer::PurePhaseSpaceDefs>::encode(const ::Hammer::PurePhaseSpaceDefs& value) {
181 if (value._purePhaseSpaceVerticesNames.numerator.size() > 0) {
183 for (
auto& elem : value._purePhaseSpaceVerticesNames.numerator) {
184 tmpNode.push_back(elem);
186 node[
"Numerator"] = tmpNode;
188 if (value._purePhaseSpaceVerticesNames.denominator.size() > 0) {
190 for (
auto& elem : value._purePhaseSpaceVerticesNames.denominator) {
191 tmpNode.push_back(elem);
193 node[
"Denominator"] = tmpNode;
200 for (
auto entry2 : node) {
201 string what = entry2.first.as<
string>();
202 if (what ==
"Numerator") {
204 YAML::Node processes = entry2.second;
205 if(processes.IsSequence()) {
206 for (
auto process : processes) {
212 }
else if (what ==
"Denominator") {
214 YAML::Node processes = entry2.second;
215 if(processes.IsSequence()) {
216 for (
auto process : processes) {
PDG codes to UID functions.
Hammer settings manager class.
TensorData read(const Serial::FBTensor *msgreader)
YAML::Emitter & operator<<(YAML::Emitter &out, const ProcessDefinitions &s)
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...
std::vector< HashId > expandToValidVertexUIDs(const std::string &name, const bool &hadOnly=false) const
NumDenPair< std::vector< std::string > > _purePhaseSpaceVerticesNames
Hammer exception definitions.
Hammer class for dealing with particle data.
Container class for pure phase space vertices definitions.
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...
Serialization related typedefs and includes.