27{
30
33
35 string inputFile;
36 string formula;
38 size_t numberOfEvents;
39 string title;
41 bool logx;
45
46 try {
47
48 JParser<> zap(
"Program to create TH1D and fill according given formula.");
49
61
63 }
64 catch(const exception &error) {
66 }
67
68
69 if ((formula != "" && inputFile != "") ||
70 (formula == "" && inputFile == "")) {
71 FATAL(
"Specify input file or formula." <<
endl);
72 }
73
75
77
78 const string::size_type pos = title.rfind('/');
79
80 if (pos != string::npos) {
81
82 const string dir = title.substr(0, pos);
83
84 out.mkdir(dir.c_str());
85 out.cd (dir.c_str());
86
87 title = title.substr(pos + 1);
88 }
89
91 X.getNumberOfBins(), X.getLowerLimit(), X.getUpperLimit());
92
93 if (formula != "") {
94
95 TF1 f1("f1", formula.c_str(),
96 logx ?
pow(10.0, X.getLowerLimit()) : X.getLowerLimit(),
97 logx ?
pow(10.0, X.getUpperLimit()) : X.getUpperLimit());
98
100 f1.FixParameter(getParameter(*i),
getValue(*i));
101 }
102
103 if (numberOfEvents > 0) {
104
105 h0.Sumw2();
106
107 for (size_t i = 0; i != numberOfEvents; ++i) {
108
109 const double x = f1.GetRandom(
gRandom);
110
111 h0.Fill(logx ?
log10(x) :
x);
112 }
113
114 } else {
115
116 for (
Int_t ix = 1;
ix <= h0.GetXaxis()->GetNbins(); ++
ix) {
117 h0.SetBinContent(
ix, f1.Eval(h0.GetXaxis()->GetBinCenter(
ix)));
118 }
119 }
120
121 } else if (inputFile != "") {
122
124 h0.Sumw2();
125 }
126
127 ifstream in(inputFile.c_str());
128
129 for (
double x; in >>
x; ) {
130 h0.Fill(x);
131 }
132
133 in.close();
134 }
135
136 out.Write();
137 out.Close();
138}
#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)...