BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
HistogramDef.cc
1/*
2Beam Delivery Simulation (BDSIM) Copyright (C) Royal Holloway,
3University of London 2001 - 2024.
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#include "HistogramDef.hh"
20
21#include <iostream>
22#include <regex>
23#include <string>
24
25ClassImp(HistogramDef)
26
28 treeName(""),
29 histName(""),
30 nDimensions(0),
31 variable(""),
32 selection(""),
33 perEntry(false)
34{;}
35
36HistogramDef::HistogramDef(const std::string& treeNameIn,
37 const std::string& histNameIn,
38 int nDimensionsIn,
39 const std::string& variableIn,
40 const std::string& selectionIn,
41 bool perEntryIn):
42 treeName(treeNameIn),
43 histName(histNameIn),
44 nDimensions(nDimensionsIn),
45 variable(variableIn),
46 selection(selectionIn),
47 perEntry(perEntryIn)
48{;}
49
50std::ostream& operator<< (std::ostream& out, const HistogramDef& s)
51{
52 std::string hs = s.GetHistogramString();
53 std::string bs = s.GetBinningString();
54 out << hs << " " << s.treeName << " " << s.histName << " " << bs << " " << s.variable << " " << s.selection << "\n";
55 return out;
56}
57
58void HistogramDef::ReplaceStringInVariable(const std::string& match,
59 const std::string& replacement)
60{
61 variable = std::regex_replace(variable, std::regex(match), replacement);
62}
Common specification for a histogram.
HistogramDef()
Public constructor only for compatibility with ROOT - not intended for use.
virtual std::string GetHistogramString() const =0
Get the first string that defines the histogram in rebdsim for feedback.
void ReplaceStringInVariable(const std::string &match, const std::string &replacement)
Little utility function.
virtual std::string GetBinningString() const =0
Provide the binning string in the original input format for feedback.