27{
30
33
35 string inputFile;
36 string formula;
38 size_t numberOfEvents;
39 string title;
42 bool logx;
47
48 try {
49
50 JParser<> zap(
"Program to create TH2D and fill according given formula.");
51
65
67 }
68 catch(const exception &error) {
70 }
71
72
73 if ((formula != "" && inputFile != "") ||
74 (formula == "" && inputFile == "")) {
75 FATAL(
"Specify input file or formula." <<
endl);
76 }
77
79
81
82 const string::size_type pos = title.rfind('/');
83
84 if (pos != string::npos) {
85
86 const string dir = title.substr(0, pos);
87
88 out.mkdir(dir.c_str());
89 out.cd (dir.c_str());
90
91 title = title.substr(pos + 1);
92 }
93
95 X.getNumberOfBins(), X.getLowerLimit(), X.getUpperLimit(),
96 Y.getNumberOfBins(), Y.getLowerLimit(), Y.getUpperLimit());
97
98 if (formula != "") {
99
100 TF2 f2("f2", formula.c_str(),
101 logx ?
pow(10.0, X.getLowerLimit()) : X.getLowerLimit(),
102 logx ?
pow(10.0, X.getUpperLimit()) : X.getUpperLimit(),
103 logy ?
pow(10.0, Y.getLowerLimit()) : Y.getLowerLimit(),
104 logy ?
pow(10.0, Y.getUpperLimit()) : Y.getUpperLimit());
105
107 f2.FixParameter(getParameter(*i),
getValue(*i));
108 }
109
110 if (numberOfEvents > 0) {
111
112 h0.Sumw2();
113
115
116 for (size_t i = 0; i != numberOfEvents; ++i) {
117
119
120 h0.Fill(logx ?
log10(x) :
x,
122 }
123
124 } else {
125
128 h0.SetBinContent(
ix,
iy, f2.Eval(h0.GetXaxis()->GetBinCenter(
ix),
129 h0.GetYaxis()->GetBinCenter(
iy)));
130 }
131 }
132 }
133 } else if (inputFile != "") {
134
136 h0.Sumw2();
137 }
138
139 ifstream in(inputFile.c_str());
140
141 for (
double x, y; in >>
x >>
y; ) {
142 h0.Fill(x, y);
143 }
144
145 in.close();
146 }
147
148 out.Write();
149 out.Close();
150}
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
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)...