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;
63 JParser<> zap(
"Program to test JRootfit algorithm.");
70 zap[
'O'] =
make_field(option) = count_t, value_t;
77 catch(
const exception& error) {
78 FATAL(error.what() << endl);
82 gRandom->SetSeed(seed);
90 if (inputFile ==
"") {
92 h1 =
new TH1D(
"h1", NULL, nx,
xmin,
xmax);
105 TFile*
in = TFile::Open(inputFile.c_str(),
"exist");
107 in->GetObject(
"h1", h1);
113 const double center = h1->GetMean();
114 const double sigma = h1->GetStdDev() * 0.66;
115 const double signal = h1->GetMaximum();
116 const double background = h1->GetMinimum() + 0.10;
121 auto f1 = JP0<1>(signal) * JGauss<1>(center,
sigma) +
Exp(JP0<2>(log(background)));
123 typedef decltype(
f1) function_type;
127 for (
size_t i = 0;
i != getNumberOfParameters<function_type>(); ++
i) {
128 cout << setw(2) <<
i <<
' '
133 const chrono::steady_clock::time_point t0 = chrono::steady_clock::now();
135 const auto result = (option == count_t ?
136 (writeFits ? Fit<m_count>(h1,
f1, {},
X) : Fit<m_count>(*h1, f1, {},
X)) :
137 (writeFits ? Fit<m_value>(h1,
f1, {},
X) : Fit<m_value>(*h1, f1, {},
X)));
139 const chrono::steady_clock::time_point t1 = chrono::steady_clock::now();
141 cout <<
"chi2/NDF " <<
FIXED(7,3) <<
result.getChi2() <<
"/" <<
result.getNDF() << endl;
142 cout <<
"Number of iterations " <<
result.numberOfIterations << endl;
143 cout <<
"Elapsed time [us] " << setw(8) << chrono::duration_cast<chrono::microseconds>(t1 - t0).
count() << endl;
145 for (
size_t i = 0;
i !=
result.getNumberOfParameters(); ++
i) {
146 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.
Auxiliary data structure for floating point format specification.
Utility class to parse parameter values.
const JPolynome f1(1.0, 2.0, 3.0)
Function.
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