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