Hammer  1.0.0
Helicity Amplitude Module for Matrix Element Reweighting
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Hammer.cc
Go to the documentation of this file.
1 ///
2 /// @file Hammer.cc
3 /// @brief Main Hammer class
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 #include <iostream>
13 #include <algorithm>
14 #include <boost/algorithm/string.hpp>
15 
16 #include "Hammer/Hammer.hh"
18 #include "Hammer/Histos.hh"
20 #include "Hammer/Event.hh"
21 
22 #include "Hammer/AmplitudeBase.hh"
23 #include "Hammer/FormFactorBase.hh"
24 #include "Hammer/Math/Histogram.hh"
25 #include "Hammer/ProvidersRepo.hh"
26 #include "Hammer/ExternalData.hh"
27 #include "Hammer/ProcRates.hh"
28 #include "Hammer/ProcManager.hh"
33 
36 
37 #include "Hammer/Math/Utils.hh"
38 #include "Hammer/Math/Units.hh"
40 #include "Hammer/Tools/Logging.hh"
41 #include "Hammer/Tools/Utils.hh"
42 #include "Hammer/Tools/Pdg.hh"
43 
44 
45 using namespace std;
46 
47 namespace Hammer {
48 
49  Hammer::Hammer() : _containers{new DictionaryManager{}},
50  _settings{new SettingsHandler{}},
51  _histograms{new Histos{_containers.get()}},
52  _builder{new flatbuffers::FlatBufferBuilder{16*1024*1024}},
53  _event{new Event{_histograms.get(), _containers.get()}} {
55  this->setSettingsHandler(*_settings);
56  _histograms->setSettingsHandler(*_settings);
57  _event->setSettingsHandler(*_settings);
58  _containers->setSettingsHandler(*_settings);
59  // ProcManager{};
60  _histograms->init();
61  }
62 
63  Hammer::~Hammer() noexcept {
64  _builder->Clear();
65  _event->clear();
66  }
67 
68  void Hammer::initEvent(double weight) {
69  _event->clear();
70  if(_histograms->isValidHistogram("Total Sum of Weights", 1)){
71  _event->setHistogramBin("Total Sum of Weights", IndexList{0});
72  }
73  if(!isZero(weight - 1.0)) {
74  _event->setEventBaseWeight(weight);
75  }
76  }
77 
78  size_t Hammer::addProcess(Process& p) {
79  return _event->addProcess(p);
80  }
81 
82  void Hammer::removeProcess(size_t id) {
83  _event->removeProcess(id);
84  }
85 
86  void Hammer::setEventHistogramBin(const string& name, const IndexList& bins) {
87  _event->setHistogramBin(name, bins);
88  }
89 
90  void Hammer::fillEventHistogram(const string& name, const vector<double>& values) {
91  if(_histograms->canFill(name, values)){
92  setEventHistogramBin(name, _histograms->getBinIndices(name, values));
93  }
94  }
95 
96  void Hammer::setEventBaseWeight(double weight) {
97  if(!isZero(weight - 1.0)) {
98  _event->setEventBaseWeight(weight);
99  }
100  }
101 
102  bool Hammer::loadEventWeights(IOBuffer& buffer, bool merge) {
103  if(buffer.kind == RecordType::EVENT) {
104  const Serial::FBEvent* buf = flatbuffers::GetRoot<Serial::FBEvent>(buffer.start);
105  if (buf != nullptr) {
106  return _event->read(buf, merge);
107  }
108  }
109  MSG_ERROR("Invalid event record on read!");
110  return false;
111  }
112 
113  IOBuffer Hammer::saveEventWeights() const {
114  _builder->Clear();
115  _event->write(&(*_builder));
116  IOBuffer result;
117  result.kind = RecordType::EVENT;
118  result.start = _builder->GetBufferPointer();
119  result.length = _builder->GetSize();
120  return result;
121  }
122 
123  bool Hammer::loadRunHeader(IOBuffer& buffer, bool merge) {
124  if(buffer.kind == RecordType::HEADER) {
125  const Serial::FBHeader* buf = flatbuffers::GetRoot<Serial::FBHeader>(buffer.start);
126  if (buf != nullptr) {
127  bool result = _settings->read(buf, merge);
128  result &= _containers->read(buf, merge);
129  return result;
130  }
131  }
132  MSG_ERROR("Invalid header record on read!");
133  return false;
134  }
135 
136  IOBuffer Hammer::saveRunHeader() const {
137  _builder->Clear();
138  _containers->write(&(*_builder));
139  IOBuffer result;
140  result.kind = RecordType::HEADER;
141  result.start = _builder->GetBufferPointer();
142  result.length = _builder->GetSize();
143  return result;
144  }
145 
146  string Hammer::loadHistogramDefinition(IOBuffer& buffer, bool merge) {
147  if(buffer.kind == RecordType::HISTOGRAM_DEFINITION) {
148  const Serial::FBHistoDefinition* buf = flatbuffers::GetRoot<Serial::FBHistoDefinition>(buffer.start);
149  if (buf != nullptr) {
150  return _histograms->readDefinition(buf, merge);
151  }
152  }
153  MSG_ERROR("Invalid histogram record on read!");
154  return "";
155  }
156 
157  HistoInfo Hammer::loadHistogram(IOBuffer& buffer, bool merge) {
158  if(buffer.kind == RecordType::HISTOGRAM) {
159  const Serial::FBHistogram* buf = flatbuffers::GetRoot<Serial::FBHistogram>(buffer.start);
160  if (buf != nullptr) {
161  return _histograms->readHistogram(buf, merge);
162  }
163  }
164  MSG_ERROR("Invalid histogram record on read!");
165  return HistoInfo{"", "", EventUIDGroup{}};
166  }
167 
168  IOBuffers Hammer::saveHistogram(const string& name) const {
169  unique_ptr<Serial::DetachedBuffers> resultVec{new Serial::DetachedBuffers{}};
170  _histograms->checkExists(name);
171  _builder->Clear();
172  if(_histograms->writeDefinition(&(*_builder), name)) {
173  resultVec->add(_builder->Release(), RecordType::HISTOGRAM_DEFINITION);
174  for (auto& schemeName : _containers->schemeDefs().getFFSchemeNames()) {
175  for (auto& eventIDs : _histograms->getEventIDRepsForHisto(name, schemeName)) {
176  _builder->Clear();
177  _histograms->writeHistogram(&(*_builder), name, schemeName, eventIDs);
178  resultVec->add(_builder->Release(), RecordType::HISTOGRAM);
179  }
180  }
181  }
182  return IOBuffers{move(resultVec)};
183  }
184 
185  IOBuffers Hammer::saveHistogram(const string& name, const string& scheme) const {
186  unique_ptr<Serial::DetachedBuffers> resultVec{new Serial::DetachedBuffers{}};
187  _histograms->checkExists(name);
188  _builder->Clear();
189  if(_histograms->writeDefinition(&(*_builder), name)) {
190  resultVec->add(_builder->Release(), RecordType::HISTOGRAM_DEFINITION);
191  for(auto& eventIDs: _histograms->getEventIDRepsForHisto(name, scheme)) {
192  _builder->Clear();
193  _histograms->writeHistogram(&(*_builder), name, scheme, eventIDs);
194  resultVec->add(_builder->Release(), RecordType::HISTOGRAM);
195  }
196  if(resultVec->size() == 1) {
197  MSG_ERROR("No scheme '" + scheme + "' present for histogram '" + name + "'. Only definition will be saved.");
198  }
199  }
200  return IOBuffers{move(resultVec)};
201  }
202 
203  IOBuffers Hammer::saveHistogram(const string& name, const EventUIDGroup& eventIDs) const {
204  unique_ptr<Serial::DetachedBuffers> resultVec{new Serial::DetachedBuffers{}};
205  _histograms->checkExists(name);
206  _builder->Clear();
207  if (_histograms->writeDefinition(&(*_builder), name)) {
208  resultVec->add(_builder->Release(), RecordType::HISTOGRAM_DEFINITION);
209  for (auto& schemeName : _containers->schemeDefs().getFFSchemeNames()) {
210  _builder->Clear();
211  _histograms->writeHistogram(&(*_builder), name, schemeName, *eventIDs.begin());
212  resultVec->add(_builder->Release(), RecordType::HISTOGRAM);
213  }
214  if(resultVec->size() == 1) {
215  string groupId = "[ ";
216  for(auto& elem: eventIDs) {
217  groupId += "[ ";
218  for(auto& elem2: elem) {
219  groupId += to_string(elem2) + " ";
220  }
221  groupId += "] ";
222  }
223  groupId += "] ";
224  MSG_ERROR("No event ID " + groupId + "present for histogram '" + name + "'. Only definition will be saved.");
225  }
226  }
227  return IOBuffers{move(resultVec)};
228  }
229 
230  IOBuffers Hammer::saveHistogram(const string& name, const string& scheme, const EventUIDGroup& eventIDs) const {
231  unique_ptr<Serial::DetachedBuffers> resultVec{new Serial::DetachedBuffers{}};
232  _histograms->checkExists(name);
233  _builder->Clear();
234  if (_histograms->writeDefinition(&(*_builder), name)) {
235  resultVec->add(_builder->Release(), RecordType::HISTOGRAM_DEFINITION);
236  _builder->Clear();
237  _histograms->writeHistogram(&(*_builder), name, scheme, *eventIDs.begin());
238  resultVec->add(_builder->Release(), RecordType::HISTOGRAM);
239  if (resultVec->size() == 1) {
240  string groupId = "[ ";
241  for (auto& elem : eventIDs) {
242  groupId += "[ ";
243  for (auto& elem2 : elem) {
244  groupId += to_string(elem2) + " ";
245  }
246  groupId += "] ";
247  }
248  groupId += "] ";
249  MSG_ERROR("No event ID " + groupId + "/ scheme '" + scheme + "' combination present for histogram '" + name +
250  "'. Only definition will be saved.");
251  }
252  }
253  return IOBuffers{move(resultVec)};
254  }
255 
256  IOBuffers Hammer::saveHistogram(const HistoInfo& info) const {
257  if(info.scheme.size() > 0 && info.eventGroupId.size() > 0) {
258  return saveHistogram(info.name, info.scheme, info.eventGroupId);
259  }
260  else if(info.scheme.size() > 0) {
261  return saveHistogram(info.name, info.scheme);
262  }
263  else if(info.eventGroupId.size() > 0) {
264  return saveHistogram(info.name, info.eventGroupId);
265  }
266  else {
267  return saveHistogram(info.name);
268  }
269  }
270 
271  bool Hammer::loadRates(IOBuffer& buffer, bool merge) {
272  if(buffer.kind == RecordType::RATE) {
273  const Serial::FBRates* buf = flatbuffers::GetRoot<Serial::FBRates>(buffer.start);
274  if (buf != nullptr) {
275  return _containers->rates().read(buf, merge);
276  }
277  }
278  MSG_ERROR("Invalid rate record on read!");
279  return false;
280  }
281 
282  IOBuffer Hammer::saveRates() const {
283  _builder->Clear();
284  _containers->rates().write(&(*_builder));
285  IOBuffer result;
286  result.kind = RecordType::RATE;
287  result.start = _builder->GetBufferPointer();
288  result.length = _builder->GetSize();
289  return result;
290  }
291 
292  void Hammer::processEvent() {
293  if(isOn("CalcProcesses")) {
294  _event->calc();
295  }
296  if(_histograms->size() > 0 && isOn("CalcHistograms")) {
297  _event->fillHistograms();
298  }
299  }
300 
301  void Hammer::readCards(const string& fileDecays, const string& fileOptions) {
302  _containers->readDecays(fileDecays);
303  _settings->readSettings(fileOptions);
304  }
305 
306  void Hammer::saveOptionCard(const string& fileOptions, bool useDefault) const {
307  _settings->saveSettings(fileOptions, useDefault);
308  }
309 
310  void Hammer::saveHeaderCard(const string& fileDecays) const {
311  _containers->saveDecays(fileDecays);
312  }
313 
314  void Hammer::saveReferences(const std::string& fileRefs) const {
315  _settings->saveReferences(fileRefs);
316  }
317 
318  void Hammer::setOptions(const string& options) {
319  _settings->parseSettings(options);
320  }
321 
322  void Hammer::setHeader(const string& options) {
323  _containers->parseDecays(options);
324  }
325 
326  void Hammer::initRun() {
327 // addHistogram("Total Sum of Weights", IndexList{1}, false);
328  _containers->init();
329  _event->init();
330  _histograms->init();
331  }
332 
333  void Hammer::addTotalSumOfWeights(const bool compress, const bool witherrors){
334  addHistogram("Total Sum of Weights", IndexList{1}, false);
335  if(compress) {collapseProcessesInHistogram("Total Sum of Weights");}
336  keepErrorsInHistogram("Total Sum of Weights", witherrors);
337  }
338 
339  void Hammer::addHistogram(const string& name, const IndexList& binSizes, bool hasUnderOverFlow,
340  const vector<pair<double, double>>& ranges) {
341  _histograms->addHistogramDefinition(name, binSizes, hasUnderOverFlow, ranges);
342  }
343 
344  void Hammer::addHistogram(const string& name, const vector<vector<double>>& binEdges,
345  bool hasUnderOverFlow) {
346  _histograms->addHistogramDefinition(name, binEdges, hasUnderOverFlow);
347  }
348 
349  void Hammer::keepErrorsInHistogram(const string& name, bool value) {
350  _histograms->setHistogramKeepErrors(name, value);
351  }
352 
353  void Hammer::collapseProcessesInHistogram(const string& name) {
354  _histograms->setHistogramCompression(name);
355  }
356 
357  void Hammer::specializeWCInWeights(const string& process, const vector<complex<double>>& values){
358  _containers->externalData().specializeWCInWeights(process, values);
359  }
360 
361  void Hammer::specializeWCInWeights(const string& process, const map<string, complex<double>>& settings){
362  _containers->externalData().specializeWCInWeights(process, settings);
363  }
364 
365  void Hammer::resetSpecializeWCInWeights(const string& process){
366  _containers->externalData().resetSpecializeWCInWeights(process);
367  }
368 
369  void Hammer::specializeWCInHistogram(const string& name, const string& process,
370  const vector<complex<double>>& values) {
371  auto data = _containers->externalData().getTempWilsonCoefficients(process, values);
372  _histograms->addHistogramFixedData(name, data);
373  }
374 
375  void Hammer::specializeWCInHistogram(const string& name, const string& process,
376  const map<string, complex<double>>& settings) {
377  auto data = _containers->externalData().getTempWilsonCoefficients(process, settings);
378  _histograms->addHistogramFixedData(name, data);
379  }
380 
381  void Hammer::specializeFFInHistogram(const string& name, const string& process, const string& group,
382  const vector<double>& values) {
383  auto data = _containers->externalData().getTempFFEigenVectors({process, group}, values);
384  _histograms->addHistogramFixedData(name, data);
385  }
386 
387  void Hammer::specializeFFInHistogram(const string& name, const string& process, const string& group,
388  const map<string, double>& settings) {
389  auto data = _containers->externalData().getTempFFEigenVectors({process, group}, settings);
390  _histograms->addHistogramFixedData(name, data);
391  }
392 
393  void Hammer::resetSpecializationInHistogram(const string& name) {
394  _histograms->resetHistogramFixedData(name);
395  }
396 
397  void Hammer::createProjectedHistogram(const string& oldName, const string& newName,
398  const set<uint16_t>& collapsedIndexPositions) {
399  _histograms->createProjectedHistogram(oldName, newName, collapsedIndexPositions);
400  }
401 
402 
403  void Hammer::removeHistogram(const string& name) {
404  _histograms->removeHistogram(name);
405  }
406 
407  void Hammer::addFFScheme(const string& schemeName, const map<string, string>& schemes) {
408  _containers->schemeDefs().addFFScheme(schemeName, schemes);
409  }
410 
411  void Hammer::setFFInputScheme(const map<string, string>& schemes) {
412  _containers->schemeDefs().setFFInputScheme(schemes);
413  }
414 
415  void Hammer::removeFFScheme(const string& schemeName) {
416  _containers->schemeDefs().removeFFScheme(schemeName);
417  }
418 
419  vector<string> Hammer::getFFSchemeNames() const {
420  return _containers->schemeDefs().getFFSchemeNames();
421  }
422 
423  void Hammer::includeDecay(const vector<string>& names) {
424  _containers->processDefs().addIncludedDecay(names);
425  }
426 
427  void Hammer::includeDecay(const string& name) {
428  _containers->processDefs().addIncludedDecay({name});
429  }
430 
431  void Hammer::forbidDecay(const vector<string>& names) {
432  _containers->processDefs().addForbiddenDecay(names);
433  }
434 
435  void Hammer::forbidDecay(const string& name) {
436  _containers->processDefs().addForbiddenDecay({name});
437  }
438 
439  void Hammer::addPurePSVertices(const set<string>& vertices, WTerm what) {
440  _containers->purePSDefs().addPurePhaseSpaceVertices(vertices, what);
441  }
442 
443  void Hammer::clearPurePSVertices(WTerm what) {
444  _containers->purePSDefs().clearPurePhaseSpaceVertices(what);
445  }
446 
447  void Hammer::setUnits(string name) {
448  _settings->changeSetting<string>("Hammer", "Units", name);
449  Units& units = Units::instance();
450  _mcunits = units.getUnitsRescalingToMC(name, "GeV");
451  }
452 
453  void Hammer::defineSettings() {
454  setPath("Hammer");
455  addSetting<bool>("CalcHistograms", true);
456  addSetting<bool>("CalcProcesses", true);
457  addSetting<string>("Units", "GeV");
458  }
459 
460  Log& Hammer::getLog() const {
461  return Log::getLog("Hammer.Hammer");
462  }
463 
464  void Hammer::setWilsonCoefficients(const string& process, const vector<complex<double>>& values, WTerm what) {
465  _containers->externalData().setWilsonCoefficients(process, values, what);
466  }
467 
468  void Hammer::setWilsonCoefficients(const string& process, const map<string, complex<double>>& values, WTerm what) {
469  _containers->externalData().setWilsonCoefficients(process, values, what);
470  }
471 
472  void Hammer::setWilsonCoefficientsLocal(const string& process, const vector<complex<double>>& values) {
473  _containers->externalData().setWilsonCoefficientsLocal(process, values);
474  }
475 
476  void Hammer::setWilsonCoefficientsLocal(const string& process, const map<string, complex<double>>& values) {
477  _containers->externalData().setWilsonCoefficientsLocal(process, values);
478  }
479 
480  void Hammer::resetWilsonCoefficients(const string& process, WTerm what) {
481  _containers->externalData().resetWilsonCoefficients(process, what);
482  }
483 
484  void Hammer::setFFEigenvectors(const string& process, const string& group, const vector<double>& values) {
485  FFPrefixGroup tmp{process, group};
486  if(_containers->providers().checkFFPrefixAndGroup(tmp)) {
487  _containers->externalData().setFFEigenVectors(tmp, values);
488  }
489  }
490 
491  void Hammer::setFFEigenvectors(const string& process, const string& group, const map<string, double>& settings) {
492  FFPrefixGroup tmp{process, group};
493  if(_containers->providers().checkFFPrefixAndGroup(tmp)) {
494  _containers->externalData().setFFEigenVectors(tmp, settings);
495  }
496  }
497 
498  void Hammer::setFFEigenvectorsLocal(const string& process, const string& group, const vector<double>& values) {
499  FFPrefixGroup tmp{process, group};
500  if (_containers->providers().checkFFPrefixAndGroup(tmp)) {
501  _containers->externalData().setFFEigenVectorsLocal(tmp, values);
502  }
503  }
504 
505  void Hammer::setFFEigenvectorsLocal(const string& process, const string& group, const map<string, double>& settings) {
506  FFPrefixGroup tmp{process, group};
507  if (_containers->providers().checkFFPrefixAndGroup(tmp)) {
508  _containers->externalData().setFFEigenVectorsLocal(tmp, settings);
509  }
510  }
511 
512  void Hammer::resetFFEigenvectors(const string& process, const string& group) {
513  FFPrefixGroup tmp{process, group};
514  if (_containers->providers().checkFFPrefixAndGroup(tmp)) {
515  _containers->externalData().resetFFEigenVectors(tmp);
516  }
517  }
518 
519  double Hammer::getWeight(const string& scheme, const vector<size_t>& processes) const {
520  auto tempProcesses = processes;
521  if(tempProcesses.size() == 0) {
522  copy(_event->getEventId().begin(), _event->getEventId().end(), back_inserter(tempProcesses));
523  }
524  double result = _event->getEventBaseWeight();
525  for(auto elem: tempProcesses) {
526  try{
527  result *= _event->getWeight(scheme, elem);
528  }
529  catch(RangeError& err) {
530  MSG_ERROR("Weight not found: " << err.what() << ". Skipping");
531  continue;
532  }
533  }
534  return result;
535  }
536 
537  double Hammer::getWeight(const string& scheme, const vector<vector<string>>& processes) const {
538  const auto procIdSet = _containers->processDefs().decayStringsToProcessIds(processes);
539  const vector<HashId> processesId(procIdSet.begin(), procIdSet.end());
540  return getWeight(scheme, processesId);
541  }
542 
543  map<size_t, double> Hammer::getWeights(const string& scheme) const {
544  return _event->getWeights(scheme);
545  }
546 
547  double Hammer::getRate(const HashId& vertexid, const string& scheme) const {
548  return _containers->rates().getVertexRate(vertexid, scheme)*_mcunits;
549  }
550 
551  double Hammer::getRate(const PdgId& parent, const vector<PdgId>& daughters, const string& scheme) const {
552  auto tmp = combineDaughters(daughters, {});
553  HashId vertexid = processID(parent, tmp);
554  //Integral
555  return _containers->rates().getVertexRate(vertexid, scheme)*_mcunits;
556  }
557 
558  double Hammer::getRate(const string& vertex, const string& scheme) const {
559  PID& pdg = PID::instance();
560  auto vertexid = pdg.expandToValidVertexUIDs(vertex);
561  if (vertexid.size() == 1){
562  return _containers->rates().getVertexRate(vertexid[0], scheme)*_mcunits;
563  } else {
564  MSG_ERROR("Vertex string does not correspond to a (charge) unique process. ");
565  return 0.;
566  }
567  }
568 
569  double Hammer::getDenominatorRate(const HashId& vertexid) const {
570  return getRate(vertexid, "Denominator");
571  }
572 
573  double Hammer::getDenominatorRate(const PdgId& parent, const vector<PdgId>& daughters) const {
574  return getRate(parent, daughters, "Denominator");
575  }
576 
577  double Hammer::getDenominatorRate(const string& vertex) const {
578  return getRate(vertex, "Denominator");
579  }
580 
581 
582  IOHistogram Hammer::getHistogram(const string& name, const string& scheme) const {
583  return _histograms->getHistogram(name, scheme);
584  }
585 
586  EventIdGroupDict<IOHistogram> Hammer::getHistograms(const string& name, const string& scheme) const {
587  return _histograms->getHistograms(name, scheme);
588  }
589 
590  EventUIDGroup Hammer::getHistogramEventIds(const string& name, const string& scheme) const {
591  return _histograms->getHistogramEventIds(name, scheme);
592  }
593 
594  vector<vector<double>> Hammer::getHistogramBinEdges(const string& name) const {
595  return _histograms->getHistogramEdges(name);
596  }
597 
598  IndexList Hammer::getHistogramShape(const string& name) const {
599  return _histograms->getHistogramShape(name);
600  }
601 
602  bool Hammer::histogramHasUnderOverFlows(const string& name) const {
603  return _histograms->getUnderOverFlows(name);
604  }
605 
606 #ifdef HAVE_ROOT
607 
608  unique_ptr<TH1D> Hammer::getHistogram1D(const string& name, const string& scheme) const {
609  return _histograms->getHistogram1D(name, scheme);
610  }
611 
612  unique_ptr<TH2D> Hammer::getHistogram2D(const string& name, const string& scheme) const {
613  return _histograms->getHistogram2D(name, scheme);
614  }
615 
616  unique_ptr<TH3D> Hammer::getHistogram3D(const string& name, const string& scheme) const {
617  return _histograms->getHistogram3D(name, scheme);
618  }
619 
620  EventIdGroupDict<unique_ptr<TH1D>> Hammer::getHistograms1D(const string& name, const string& scheme) const {
621  return _histograms->getHistograms1D(name, scheme);
622  }
623 
624  EventIdGroupDict<unique_ptr<TH2D>> Hammer::getHistograms2D(const string& name, const string& scheme) const {
625  return _histograms->getHistograms2D(name, scheme);
626  }
627 
628  EventIdGroupDict<unique_ptr<TH3D>> Hammer::getHistograms3D(const string& name, const string& scheme) const {
629  return _histograms->getHistograms3D(name, scheme);
630  }
631 
632  void Hammer::setHistogram1D(const string& name, const string& scheme, TH1D& histogram) const {
633  _histograms->setHistogram1D(name, scheme, histogram);
634  }
635 
636  void Hammer::setHistogram2D(const string& name, const string& scheme, TH2D& histogram) const {
637  _histograms->setHistogram2D(name, scheme, histogram);
638  }
639 
640  void Hammer::setHistogram3D(const string& name, const string& scheme, TH3D& histogram) const {
641  _histograms->setHistogram3D(name, scheme, histogram);
642  }
643 
644  void Hammer::setHistograms1D(const string& name, const string& scheme,
645  EventIdGroupDict<unique_ptr<TH1D>>& histograms) const {
646  _histograms->setHistograms1D(name, scheme, histograms);
647  }
648 
649  void Hammer::setHistograms2D(const string& name, const string& scheme,
650  EventIdGroupDict<unique_ptr<TH2D>>& histograms) const {
651  _histograms->setHistograms2D(name, scheme, histograms);
652  }
653 
654  void Hammer::setHistograms3D(const string& name, const string& scheme,
655  EventIdGroupDict<unique_ptr<TH3D>>& histograms) const {
656  _histograms->setHistograms3D(name, scheme, histograms);
657  }
658 
659 #endif
660 
661 } // namespace Hammer
PDG codes to UID functions.
Hammer event class.
Hammer base form factor class.
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
Definition: Pdg.cc:833
void collapseProcessesInHistogram(const std::string &name)
Definition: Hammer.cc:353
void setPath(const std::string &path)
provide the basic path for the settings defined by this class, as in &quot;&lt;path&gt;:&lt;setting&gt;&quot; ...
Container class for values of WC and FF vectors.
Decay process class.
Definition: Process.hh:34
void addHistogram(const std::string &name, const std::vector< uint16_t > &binSizes, bool hasUnderOverFlow=true, const std::vector< std::pair< double, double >> &ranges={})
Adds a tensor histogram.
std::vector< BinContents > IOHistogram
Definition: IOTypes.hh:132
RecordType kind
Definition: IOTypes.hh:33
std::string scheme
Definition: IOTypes.hh:136
Container class for storing included/forbidden process info.
std::set< EventUID > EventUIDGroup
Definition: IndexTypes.hh:56
static void resetWarningCounters()
reset the warning counters for all loggers
Definition: Logging.cc:132
Hammer class for dealing with units.
Definition: Units.hh:38
double _mcunits
Definition: Hammer.hh:519
Interface class for amplitudes, rates, FFs dictionary container.
Message logging routines.
Hammer base amplitude class.
Hammer settings manager class.
double getWeight(const std::string &scheme, const std::vector< size_t > &processes={}) const
Definition: Hammer.cc:519
Hammer histogram manager.
static Log & getLog(const std::string &name)
Get a logger with the given name.
Definition: Logging.cc:139
std::unique_ptr< SettingsHandler > _settings
Definition: Hammer.hh:515
Unit conversion factors.
Hammer histogram class.
std::vector< IndexType > IndexList
Logging class.
Definition: Logging.hh:33
void setEventHistogramBin(const std::string &name, const std::vector< uint16_t > &bins)
Definition: Hammer.cc:86
static Units & instance()
Definition: Units.cc:30
std::unique_ptr< Event > _event
Definition: Hammer.hh:518
UMap< EventUIDGroup, T > EventIdGroupDict
Definition: IndexTypes.hh:58
Hammer class for dealing with particle data.
Definition: Pdg.hh:32
Container class for pure phase space vertices definitions.
bool isZero(const std::complex< double > val)
Definition: Math/Utils.hh:25
Container class for all process related data structures.
ROOT includes.
static PID & instance()
Definition: Pdg.cc:283
std::unique_ptr< DictionaryManager > _containers
Definition: Hammer.hh:514
void keepErrorsInHistogram(const std::string &name, bool value=true)
Definition: Hammer.cc:349
Hammer particle data class.
Container class for Scheme Definitions.
Hammer settings manager class.
std::unique_ptr< Histos > _histograms
Definition: Hammer.hh:516
#define MSG_ERROR(x)
Definition: Logging.hh:367
uint8_t * start
Definition: IOTypes.hh:35
std::unique_ptr< flatbuffers::FlatBufferBuilder > _builder
Definition: Hammer.hh:517
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...
std::set< std::set< size_t > > eventGroupId
Definition: IOTypes.hh:137
std::string name
Definition: IOTypes.hh:135
size_t HashId
Definition: IndexTypes.hh:31
bool isOn(const std::string &name) const
method to check a boolean setting defined by this class
Main class.
Definition: Hammer.hh:45
Container class for process rate tensors.
Main Hammer class.
uint32_t length
Definition: IOTypes.hh:34
Hammer available modules header.
int PdgId
Definition: Pdg.fhh:17
Out-of-range error class.
Definition: Exceptions.hh:49
Serialization related typedefs and includes.
double getRate(const HashId &id, const std::string &scheme) const
Definition: Hammer.cc:547
Global container class for amplitudes, rates, FFs, data.
IOBuffers saveHistogram(const std::string &name) const
Definition: Hammer.cc:168