Hammer  1.0.0
Helicity Amplitude Module for Matrix Element Reweighting
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HistogramDefinition.hh
Go to the documentation of this file.
1 ///
2 /// @file HistogramDefinition.hh
3 /// @brief Histogram definition 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 #ifndef HAMMER_MATH_HISTOGRAMDEFINITION_HH
13 #define HAMMER_MATH_HISTOGRAMDEFINITION_HH
14 
15 #include <vector>
16 #include <utility>
17 
19 #include "Hammer/Tools/Utils.hh"
20 #include "Hammer/IndexTypes.hh"
21 
22 #include "Hammer/Math/Tensor.hh"
23 
26 
27 namespace Hammer {
28 
29  namespace MD = MultiDimensional;
30 
31  class Log;
32 
34 
35  public:
36 
37  HistogramDefinition(bool hasUnderOverFlow, const IndexList& numBins, const MD::BinEdgeList& binEdges,
38  bool shouldCompress, bool keepErrors);
39  HistogramDefinition(bool hasUnderOverFlow, const IndexList& numBins, const MD::BinRangeList& ranges,
40  bool shouldCompress, bool keepErrors);
41  HistogramDefinition(bool hasUnderOverFlow, const MD::BinEdgeList& binEdges, bool shouldCompress, bool keepErrors);
42 
43  HistogramDefinition(const Serial::FBHistoDefinition* msgreader);
44  public:
45 
46 
48  void resetFixedData();
49  const Tensor& getFixedData(EventUID id, const std::string& schemeName, LabelsList tensorLabels) const;
50 
52  bool shouldCompress() const;
53  void setCompression(bool value);
54  bool shouldKeepErrors() const;
55  void setKeepErrors(bool value);
56 
57  void write(flatbuffers::FlatBufferBuilder* msgwriter, const std::string& name) const;
58 
59  bool checkDefinition(const Serial::FBHistoDefinition* msgreader) const;
60  private:
61  /// @brief logging facility
62  /// @return stream to be used for logging
63  Log& getLog() const;
64 
65  void read(const Serial::FBHistoDefinition* msgreader);
66 
67  private:
71 
72  using FixedKey = std::pair<EventUID, SchemeName>;
74 
75  std::map<IndexLabel, MultiDimensional::SharedTensorData> _fixedDataPool;
76 
77  };
78 
79 
80 } // namespace Hammer
81 
82 #endif
std::set< ProcessUID > EventUID
Definition: IndexTypes.hh:53
Log & getLog() const
logging facility
Forward declaration of serialization related typedefs and includes.
std::unordered_map< K, V, boost::hash< K >> UMap
Definition: Tools/Utils.hh:104
const MD::BinnedIndexing< MD::SequentialIndexing > & getIndexing() const
Hammer data types declarations.
MD::BinnedIndexing< MD::SequentialIndexing > _indexing
void write(flatbuffers::FlatBufferBuilder *msgwriter, const std::string &name) const
std::vector< std::vector< double >> BinEdgeList
UMap< FixedKey, Tensor > _fixedData
Non-sparse tensor indexer.
void read(const Serial::FBHistoDefinition *msgreader)
std::shared_ptr< IContainer > SharedTensorData
HistogramDefinition(bool hasUnderOverFlow, const IndexList &numBins, const MD::BinEdgeList &binEdges, bool shouldCompress, bool keepErrors)
std::pair< EventUID, SchemeName > FixedKey
std::vector< IndexType > IndexList
Logging class.
Definition: Logging.hh:33
const Tensor & getFixedData(EventUID id, const std::string &schemeName, LabelsList tensorLabels) const
Multidimensional tensor class with complex numbers as elements.
Definition: Tensor.hh:33
std::map< IndexLabel, MultiDimensional::SharedTensorData > _fixedDataPool
std::vector< IndexLabel > LabelsList
Binned tensor (histogram) indexer.
bool checkDefinition(const Serial::FBHistoDefinition *msgreader) const
std::vector< BinRange > BinRangeList
Hammer tensor class.
void addFixedData(MultiDimensional::SharedTensorData data)