27{
30
33
35 string inputFile;
36 string formula;
38 size_t numberOfEvents;
39 string title;
43 bool logx;
49
50 try {
51
52 JParser<> zap(
"Program to create TH3D and fill according given formula.");
53
69
71 }
72 catch(const exception &error) {
74 }
75
76
77 if ((formula != "" && inputFile != "") ||
78 (formula == "" && inputFile == "")) {
79 FATAL(
"Specify input file or formula." <<
endl);
80 }
81
83
85
86 const string::size_type pos = title.rfind('/');
87
88 if (pos != string::npos) {
89
90 const string dir = title.substr(0, pos);
91
92 out.mkdir(dir.c_str());
93 out.cd (dir.c_str());
94
95 title = title.substr(pos + 1);
96 }
97
99 X.getNumberOfBins(), X.getLowerLimit(), X.getUpperLimit(),
100 Y.getNumberOfBins(), Y.getLowerLimit(), Y.getUpperLimit(),
101 Z.getNumberOfBins(), Z.getLowerLimit(), Z.getUpperLimit());
102
103 if (formula != "") {
104
105 TF3
f3(
"f3", formula.c_str(),
106 logx ?
pow(10.0, X.getLowerLimit()) : X.getLowerLimit(),
107 logx ?
pow(10.0, X.getUpperLimit()) : X.getUpperLimit(),
108 logy ?
pow(10.0, Y.getLowerLimit()) : Y.getLowerLimit(),
109 logy ?
pow(10.0, Y.getUpperLimit()) : Y.getUpperLimit(),
110 logz ?
pow(10.0, Z.getLowerLimit()) : Z.getLowerLimit(),
111 logz ?
pow(10.0, Z.getUpperLimit()) : Z.getUpperLimit());
112
114 f3.FixParameter(getParameter(*i),
getValue(*i));
115 }
116
117 if (numberOfEvents > 0) {
118
119 h0.Sumw2();
120
122
123 for (size_t i = 0; i != numberOfEvents; ++i) {
124
126
127 h0.Fill(logx ?
log10(x) :
x,
130 }
131
132 } else {
133
137
138 h0.SetBinContent(
ix,
iy,
iz,
f3.Eval(h0.GetXaxis()->GetBinCenter(
ix),
139 h0.GetYaxis()->GetBinCenter(
iy),
140 h0.GetZaxis()->GetBinCenter(
iz)));
141 }
142 }
143 }
144 }
145 } else if (inputFile != "") {
146
148 h0.Sumw2();
149 }
150
151 ifstream in(inputFile.c_str());
152
153 for (
double x, y, z; in >>
x >>
y >> z; ) {
154 h0.Fill(x, y, z);
155 }
156
157 in.close();
158 }
159
160 out.Write();
161 out.Close();
162}
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
double f3(const double x, const double y, const double z)
3D function.
Wrapper class around string.
Template definition of a multi-dimensional oscillation probability interpolation table.
Utility class to parse command line options.
double getValue(const JScale_t scale)
Get numerical value corresponding to scale.
T pow(const T &x, const double y)
Power .
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Empty structure for specification of parser element that is initialised (i.e. does not require input)...