Belle II Software development
HistogramMapping.h
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8#pragma once
9
10#include <framework/pcore/EvtMessage.h>
11#include <TH1.h>
12
13#include <string>
14#include <memory>
15#include <map>
16
17namespace Belle2 {
31 public:
37 HistogramMapping(const HistogramMapping& rhs) = delete;
41 HistogramMapping() = default;
43 explicit HistogramMapping(std::unique_ptr<Belle2::EvtMessage> msg);
44
46 void operator+=(const HistogramMapping& rhs);
47
49 void write() const;
51 void clear();
53 void printMe() const;
55 std::unique_ptr<Belle2::EvtMessage> toMessage() const;
57 bool empty() const;
58
59 private:
61 std::map<std::string, std::unique_ptr<TH1>> m_histograms;
62 };
64}
Utility to store received histograms (hierarchical tree structures) from clients (as an event message...
HistogramMapping()=default
Default constructor needed during summation.
void write() const
Write out all stored histograms in the currently selected ROOT gDirectory.
HistogramMapping(const HistogramMapping &rhs)=delete
As this is a heavy object, make sure to not copy.
bool empty() const
Check if there are no stored histograms.
std::map< std::string, std::unique_ptr< TH1 > > m_histograms
Internal storage of the histograms in the form name -> unique TH1 pointer.
void printMe() const
Debug function to print out the content as into messages.
HistogramMapping(HistogramMapping &&rhs)=default
Moving is allowed.
HistogramMapping & operator=(HistogramMapping &&rhs)=default
Moving is allowed.
void clear()
Clear all histograms in the internal map also deleting the pointers.
std::unique_ptr< Belle2::EvtMessage > toMessage() const
Construct an EvtMessage by serializing the content of the internal histogram storage....
void operator+=(const HistogramMapping &rhs)
Add another histogramm tree instance by merging all histograms with the same name.
HistogramMapping & operator=(const HistogramMapping &rhs)=delete
As this is a heavy object, make sure to not copy.
Abstract base class for different kinds of events.