30 int main(
int argc,
char **argv)
35 const char*
const count_t =
"count";
36 const char*
const value_t =
"value";
40 double background = 5;
64 JParser<> zap(
"Program to test JRootfit algorithm.");
72 zap[
'O'] =
make_field(option) = count_t, value_t;
79 catch(
const exception& error) {
80 FATAL(error.what() << endl);
84 gRandom->SetSeed(seed);
88 const size_t nx = 20 * ls;
89 const double xmin = -5.0 * ls;
90 const double xmax = +5.0 * ls;
92 const size_t ny = 20 * ls;
93 const double ymin = -5.0 * ls;
94 const double ymax = +5.0 * ls;
98 if (inputFile ==
"") {
100 h2 =
new TH2D(
"h2", NULL, nx,
xmin,
xmax, ny, ymin, ymax);
116 TFile*
in = TFile::Open(inputFile.c_str(),
"exist");
118 in->GetObject(
"h2", h2);
124 const double x0 = h2->GetMean(1);
125 const double y0 = h2->GetMean(2);
126 const double xs = h2->GetStdDev(1) * 0.33;
127 const double ys = h2->GetStdDev(2) * 0.33;
128 const double signal = h2->GetMaximum();
129 const double background = h2->GetMinimum() + 0.10;
133 auto f2 = (JGauss2X<1>(x0, xs) *
134 JGauss2Y<2>(y0, ys) *
135 JP0<1>(signal)) +
Exp(JP0<2>(log(background)));
139 typedef decltype(f2) function_type;
143 for (
size_t i = 0;
i != getNumberOfParameters<function_type>(); ++
i) {
144 cout << setw(2) <<
i <<
' '
149 const chrono::steady_clock::time_point t0 = chrono::steady_clock::now();
151 const auto result = (option == count_t ?
152 (writeFits ? Fit<m_count>(h2, f2, {},
X,
Y) : Fit<m_count>(*h2, f2, {},
X,
Y)) :
153 (writeFits ? Fit<m_value>(h2, f2, {},
X,
Y) : Fit<m_value>(*h2, f2, {},
X,
Y)));
155 const chrono::steady_clock::time_point t1 = chrono::steady_clock::now();
157 cout <<
"chi2/NDF " <<
FIXED(7,3) <<
result.getChi2() <<
"/" <<
result.getNDF() << endl;
158 cout <<
"Number of iterations " <<
result.numberOfIterations << endl;
159 cout <<
"Elapsed time [us] " << setw(8) << chrono::duration_cast<chrono::microseconds>(t1 - t0).
count() << endl;
161 for (
size_t i = 0;
i !=
result.getNumberOfParameters(); ++
i) {
162 cout << setw(2) <<
i <<
' '
Utility class to parse command line options.
int main(int argc, char *argv[])
int getParameter(const std::string &text)
Get parameter number from text string.
#define gmake_property(A)
macros to convert (template) parameter to JPropertiesElement object
Utility class to parse parameter values.
then usage $script< input file >[option] nPossible options count
*fatal Wrong number of arguments esac JCookie sh typeset Z DETECTOR typeset Z SOURCE_RUN typeset Z TARGET_RUN set_variable PARAMETERS_FILE $WORKDIR parameters
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
JExp< JF1_t > Exp(const JF1_t &f1)
Exponent of function.
then fatal Wrong number of arguments fi set_variable STRING $argv[1] set_variable DETECTORXY_TXT $WORKDIR $DETECTORXY_TXT tail read X Y CHI2 RMS printf optimum n $X $Y $CHI2 $RMS awk v Y
Auxiliary data structure for floating point format specification.
Utility class to parse parameter values.
void FillRandom(TH1 *h1, const T &f1)
Fill 1D histogram according Poisson statistics with expectation values from given 1D function...
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
then usage $script< input file >[option[primary[working directory]]] nWhere option can be N
then fatal The output file must have the wildcard in the e g root fi eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Utility class to parse command line options.
no fit printf nominal n $STRING awk v X
Functional algebra in 2D.