Skip to content

Commit 387fc66

Browse files
committed
Fix function range change, also spellcheck and format fix
1 parent c5368d8 commit 387fc66

File tree

6 files changed

+16
-13
lines changed

6 files changed

+16
-13
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ In the data file each line corresponds to a single histogram. The line is identi
4949

5050
## Functions
5151
Each function is an independent entity, and can be a combinations of various generic functions. Any form of function accepted by `TFormula` is allowed, e.g.: `cos(x)+sin(x)`, `gaus(0)+exp(3)`, `[0]*x+[2]`, etc.
52-
For all the functions belonging to a single histogram, a sum of functions is created and the sum is fit. For example, to fit a gausian signal and a polynomial background, one could define two functions: `gaus(0) pol3(3)`. From the fitting point of view it does not matter whether you define two partial functions `gaus(0) pol3(3)` or one larger `gaus(0)+pol3(3)`, however HelloFitty offers ways to access each partial function separately, which would not be possible with one grand function.
52+
For all the functions belonging to a single histogram, a sum of functions is created and the sum is fit. For example, to fit a gaussian signal and a polynomial background, one could define two functions: `gaus(0) pol3(3)`. From the fitting point of view it does not matter whether you define two partial functions `gaus(0) pol3(3)` or one larger `gaus(0)+pol3(3)`, however HelloFitty offers ways to access each partial function separately, which would not be possible with one grand function.
5353

5454
## Parameters
5555
After the `|` separator which marks end of function definitions, the parameters definitions start. There should be as many parameters defined as expected by the functions, and more or less parameters will result in throw of `hf::invalid_format`.

inc/details.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,8 @@ struct fitter_impl
186186
std::unordered_map<int, draw_opts> partial_functions_styles;
187187

188188
template <class T>
189-
auto generic_fit(entry* hfp, entry_impl* hfp_m_d, const char* name, T* dataobj, const char* pars,
190-
const char* gpars) -> bool
189+
auto generic_fit(entry* hfp, entry_impl* hfp_m_d, const char* name, T* dataobj, const char* pars, const char* gpars)
190+
-> bool
191191
{
192192
hfp_m_d->prepare();
193193

include/hellofitty.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ class HELLOFITTY_EXPORT fitter final
309309

310310
/// For histograms which have no record in the entries collection, you can set a generic
311311
/// function and aparameters to be fit. It will not be used for disabled histograms.
312-
/// Pass an emtpy object to clear the generic entry.
312+
/// Pass an empty object to clear the generic entry.
313313
/// @param generic a generic histogram function object
314314
auto set_generic_entry(entry generic) -> void;
315315
/// Check if the generic entry is set.
@@ -325,8 +325,8 @@ class HELLOFITTY_EXPORT fitter final
325325
/// @param aux_file the output file for parameters
326326
/// @param mode source selection mode
327327
/// @return the file was properly imported
328-
auto init_from_file(std::string input_file, std::string aux_file,
329-
priority_mode mode = priority_mode::newer) -> bool;
328+
auto init_from_file(std::string input_file, std::string aux_file, priority_mode mode = priority_mode::newer)
329+
-> bool;
330330
/// Force file exporting. If the output file was not set, the function does nothing.
331331
/// @return true if the file was written
332332
auto export_to_file(bool update_reference = false) -> bool;
@@ -341,7 +341,7 @@ class HELLOFITTY_EXPORT fitter final
341341
/// @param hist histogram to be fitted
342342
/// @param pars histogram fitting pars
343343
/// @param gpars histogram fit drawing pars
344-
/// @return pair of bool (true if fit successfull) and used entry
344+
/// @return pair of bool (true if fit successful) and used entry
345345
auto fit(TH1* hist, const char* pars = "BQ", const char* gpars = "") -> std::pair<bool, entry*>;
346346
/// Fit the histogram using provided entry. The fit entry is not automatically stored in the collection and must
347347
/// be add using @see hf::fitter::insert_parameter.
@@ -357,9 +357,9 @@ class HELLOFITTY_EXPORT fitter final
357357
/// @param graph graph to be fitted
358358
/// @param pars graph fitting pars
359359
/// @param gpars graph fit drawing pars
360-
/// @return pair of bool (true if fit successfull) and used entry
361-
auto fit(const char* name, TGraph* graph, const char* pars = "BQ",
362-
const char* gpars = "") -> std::pair<bool, entry*>;
360+
/// @return pair of bool (true if fit successful) and used entry
361+
auto fit(const char* name, TGraph* graph, const char* pars = "BQ", const char* gpars = "")
362+
-> std::pair<bool, entry*>;
363363
/// Fit the graph using provided entry. The fit entry is not automatically stored in the collection and must
364364
/// be add using @see hf::fitter::insert_parameter.
365365
/// @param hfp graph entry to be used

source/entry.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,10 @@ auto entry::set_fit_range(Double_t range_lower, Double_t range_upper) -> void
151151
{
152152
m_d->range_min = range_lower;
153153
m_d->range_max = range_upper;
154+
155+
m_d->complete_function_object.SetRange(range_lower, range_upper);
156+
for (auto& f : m_d->funcs)
157+
f.function_obj.SetRange(range_lower, range_upper);
154158
}
155159

156160
auto entry::get_fit_range_min() const -> Double_t { return m_d->range_min; }

source/fitter.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#include "details.hpp"
2525
#include "parser.hpp"
2626

27-
#include <TF1.h>
2827
#include <TGraph.h>
2928
#include <TH1.h>
3029
#include <TList.h>

source/hellofitty.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ auto parse_line_entry(const std::string& line, format_version version) -> std::p
5858
}
5959
}
6060

61-
auto HELLOFITTY_EXPORT format_line_entry(const std::string& name, const hf::entry* entry,
62-
format_version version) -> std::string
61+
auto HELLOFITTY_EXPORT format_line_entry(const std::string& name, const hf::entry* entry, format_version version)
62+
-> std::string
6363
{
6464
switch (version)
6565
{

0 commit comments

Comments
 (0)