File indexing completed on 2025-12-16 10:29:44
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef HISTFACTORY_HISTREF_H
0012 #define HISTFACTORY_HISTREF_H
0013
0014 #include <memory>
0015 #include <TH1.h>
0016
0017 namespace RooStats{
0018 namespace HistFactory {
0019
0020
0021
0022
0023
0024 class HistRef {
0025
0026 public:
0027
0028
0029
0030 HistRef(TH1 * h = nullptr) : fHist(h) {}
0031
0032 HistRef( const HistRef& other )
0033 {
0034 if (other.fHist) fHist.reset(CopyObject(other.fHist.get()));
0035 }
0036
0037 HistRef(HistRef&& other) :
0038 fHist(std::move(other.fHist)) {}
0039
0040 ~HistRef() {}
0041
0042
0043 HistRef & operator= (const HistRef & other) {
0044 if (this == &other) return *this;
0045
0046 fHist.reset(CopyObject(other.fHist.get()));
0047 return *this;
0048 }
0049
0050 HistRef& operator=(HistRef&& other) {
0051 fHist = std::move(other.fHist);
0052 return *this;
0053 }
0054
0055 TH1 * GetObject() const { return fHist.get(); }
0056
0057
0058 void SetObject(TH1 *h) {
0059 fHist.reset(h);
0060 }
0061
0062
0063 void operator= (TH1 * h) { SetObject(h); }
0064
0065
0066 TH1* ReleaseObject() {
0067 return fHist.release();
0068 }
0069
0070
0071
0072 private:
0073 static TH1 * CopyObject(const TH1 * h);
0074 std::unique_ptr<TH1> fHist;
0075 };
0076
0077 }
0078 }
0079
0080 #endif