Hammer  1.0.0
Helicity Amplitude Module for Matrix Element Reweighting
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HistogramSet.hh
Go to the documentation of this file.
1 ///
2 /// @file HistogramSet.hh
3 /// @brief Container class for histograms belonging to different event types
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_HISTOGRAMSET_HH
13 #define HAMMER_HISTOGRAMSET_HH
14 
15 #include <map>
16 #include <vector>
17 #include <memory>
18 
22 #include "Hammer/Tools/Utils.hh"
23 #include "Hammer/Tools/IOTypes.hh"
24 #include "Hammer/IndexTypes.hh"
25 
26 #include "Hammer/Math/Tensor.hh"
27 
28 namespace Hammer {
29 
30  class Histogram;
31  class HistogramDefinition;
32 
33  class HistogramSet {
34 
35  public:
36 
37  HistogramSet(bool compressed = false);
38  HistogramSet(const HistogramSet& other, const std::string& newName, const HistogramDefinition& newDef, const std::set<uint16_t>& collapsedIndexPositions);
39 
40  Histogram* getHistogram(const EventUID& id);
41  Histogram* getHistogram(size_t id);
42  size_t addEventId(const EventUID& id, const LabelsList& labels);
43  Histogram* addHistogram(size_t id, std::unique_ptr<Histogram> hist);
44 
45  EventUIDGroup read(const Serial::FBHistogram* msgreader, const HistogramDefinition& def, bool merge);
46  std::unique_ptr<Serial::FBHistogramBuilder> write(flatbuffers::FlatBufferBuilder* msgwriter, const EventUID& id) const;
47 
48  EventIdGroupDict<IOHistogram> specializeEventHistograms(const std::vector<Tensor>& externalData) const;
49  IOHistogram specializeSumHistogram(const std::vector<Tensor>& externalData) const;
50 
52  std::vector<LabelsList> getHistogramLabels() const;
53  std::vector<EventUID> getEventUIDRepresentatives() const;
54 
55  void clear();
56 
57  private:
59  std::map<size_t, EventUIDGroup> _compressionReverseDict;
60 
61  std::map<size_t, LabelsList> _labelsDict;
63 
64  std::vector<std::unique_ptr<Histogram>> _data;
65 
67  };
68 
69 }
70 
71 #endif
std::set< ProcessUID > EventUID
Definition: IndexTypes.hh:53
Forward declaration of serialization related typedefs and includes.
std::unordered_map< K, V, boost::hash< K >> UMap
Definition: Tools/Utils.hh:104
Multidimensional histogram class with Tensor as cell bins.
Definition: Histogram.hh:39
Hammer data types declarations.
size_t addEventId(const EventUID &id, const LabelsList &labels)
Definition: HistogramSet.cc:60
std::vector< BinContents > IOHistogram
Definition: IOTypes.hh:132
EventUIDGroup read(const Serial::FBHistogram *msgreader, const HistogramDefinition &def, bool merge)
std::set< EventUID > EventUIDGroup
Definition: IndexTypes.hh:56
Hammer configuration definitions.
Histogram * getHistogram(const EventUID &id)
Definition: HistogramSet.cc:41
std::vector< std::unique_ptr< Histogram > > _data
Definition: HistogramSet.hh:64
std::vector< LabelsList > getHistogramLabels() const
EventIdGroupDict< IOHistogram > specializeEventHistograms(const std::vector< Tensor > &externalData) const
std::unique_ptr< Serial::FBHistogramBuilder > write(flatbuffers::FlatBufferBuilder *msgwriter, const EventUID &id) const
UMap< LabelsList, size_t > _labelsReverseDict
Definition: HistogramSet.hh:62
EventUIDGroup getEventIdsInHistogram() const
EventIdDict< size_t > _compressionDict
Definition: HistogramSet.hh:58
std::map< size_t, LabelsList > _labelsDict
Definition: HistogramSet.hh:61
UMap< EventUIDGroup, T > EventIdGroupDict
Definition: IndexTypes.hh:58
HistogramSet(bool compressed=false)
Definition: HistogramSet.cc:26
IOHistogram specializeSumHistogram(const std::vector< Tensor > &externalData) const
UMap< EventUID, T > EventIdDict
Definition: IndexTypes.hh:55
std::map< size_t, EventUIDGroup > _compressionReverseDict
Definition: HistogramSet.hh:59
std::vector< IndexLabel > LabelsList
std::vector< EventUID > getEventUIDRepresentatives() const
Declarations for Hammer IO structs.
ROOT forward declarations.
Hammer tensor class.
Histogram * addHistogram(size_t id, std::unique_ptr< Histogram > hist)
Definition: HistogramSet.cc:86