BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
TH1Set.hh
1/*
2Beam Delivery Simulation (BDSIM) Copyright (C) Royal Holloway,
3University of London 2001 - 2023.
4
5This file is part of BDSIM.
6
7BDSIM is free software: you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published
9by the Free Software Foundation version 3 of the License.
10
11BDSIM is distributed in the hope that it will be useful, but
12WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with BDSIM. If not, see <http://www.gnu.org/licenses/>.
18*/
19#ifndef TH1SET_H
20#define TH1SET_H
21
22#include "HistSparse1D.hh"
23
24#include "TH1.h"
25#include "TH1D.h"
26
27#include <map>
28
29class TList;
30class TPad;
31
38class TH1Set: public TH1D
39{
40public:
42 TH1Set();
43 TH1Set(const char* name, const char* title);
44 ~TH1Set() override;
45
46 const HistSparse& GetHistSparse1D() const {return data;}
47
48 Int_t Fill(const char*, Double_t) override {return 0;}
49 Int_t Fill(Double_t x) override {return this->Fill(x,1.0);}
50 Int_t Fill(Double_t x, Double_t w) override;
51 void DoFillN(Int_t ntimes, const Double_t* x, const Double_t* w, Int_t stride=1) override;
52
53 Int_t AddNewBin(long long int x);
54
55 // Have to implement these to prevent a warning in older GCC.
56 Bool_t Add(TF1*, Double_t, Option_t*) override {return false;}
57 Bool_t Add(const TH1*, const TH1*, Double_t, Double_t) override {return false;}
58 // The one we implement.
59 Bool_t Add(const TH1*, Double_t) override;
60
61 Double_t GetBinContentByAbscissa(long long int x) const;
62 Double_t GetBinErrorByAbscissa(long long int x) const;
63 void SetBinContentByAbscissa(long long int x, Double_t newValue);
64 void SetBinErrorByAbscissa(long long int x, Double_t newError);
65
66 HistSparse data;
67 std::map<long long int, Int_t> abscissaToBinIndex;
68
69 /*
70virtual Bool_t Add(TF1 *h1, Double_t c1=1, Option_t *option="");
71TObject* Clone(const char* newname = "") const;
72
73virtual Int_t FindBin(Double_t x, Double_t y = 0, Double_t z = 0);
74virtual Double_t GetBinContent(Int_t bin) const;
75virtual Double_t GetBinError(Int_t bin) const;
76//Double_t GetMaximum() const;
77virtual Double_t GetMaximum(Double_t maxval) const;
78// Double_t GetMinimum() const;
79virtual Double_t GetMinimum(Double_t minval) const;
80
81virtual Double_t Integral(Option_t* option = "") const;
82virtual Long64_t Merge(TCollection *);
83
84virtual void SavePrimitive(std::ostream& out, Option_t* option = "");
85virtual void Reset(Option_t *option);
86virtual void Scale(Double_t c1 = 1, Option_t* option = "");
87virtual void SetBinContent(Int_t bin, Double_t content);
88virtual void SetBinError(Int_t bin, Double_t error);
89virtual void GetStats(Double_t *stats) const;
90*/
91 ClassDefOverride(TH1Set,1)
92};
93
94#endif
Sparse 1D histogram based on a map.
Definition: HistSparse1D.hh:45
TH1D but with a category axis.
Definition: TH1Set.hh:39