33namespace TestStatistics {
36 std::shared_ptr<WrapperCalculationCleanFlags> calculation_is_clean,
SharedOffset offset)
38 n_event_tasks_(MultiProcess::Config::
LikelihoodJob::defaultNEventTasks),
39 n_component_tasks_(MultiProcess::Config::
LikelihoodJob::defaultNComponentTasks),
40 likelihood_serial_(likelihood_, calculation_is_clean_, shared_offset_)
58 std::unique_ptr<RooArgSet> vars{
likelihood_->getParameters()};
83 auto message_end = message_begin + message.size() /
sizeof(
update_state_t);
84 std::vector<update_state_t> to_update(message_begin, message_end);
85 for (
auto const &item : to_update) {
87 rvar->
setVal(
static_cast<double>(item.value));
89 rvar->
setConstant(
static_cast<bool>(item.is_constant));
100 auto offsets_message_end = offsets_message_begin + N_offsets;
142 if (
get_manager()->process_manager().is_master()) {
143 bool valChanged =
false;
144 bool constChanged =
false;
145 std::vector<update_state_t> to_update;
146 for (std::size_t ix = 0u; ix < static_cast<std::size_t>(
vars_.
size()); ++ix) {
148 constChanged = (
vars_[ix].isConstant() !=
save_vars_[ix].isConstant());
150 if (valChanged || constChanged) {
161 double val = rar_val->
getVal();
163 bool isC =
vars_[ix].isConstant();
169 if (!to_update.empty() || update_offsets) {
171 zmq::message_t message(to_update.begin(), to_update.end());
174 if (update_offsets) {
177 std::move(message), std::move(offsets_message));
194 if (
get_manager()->process_manager().is_master()) {
207 for (std::size_t ix = 0; ix < N_tasks; ++ix) {
223 for (
auto item_it =
results_.cbegin() + 1; item_it !=
results_.cend(); ++item_it) {
259 results_.emplace_back(task_result->value, task_result->carry);
260 if (task_result->has_errors) {
265 return job_completed;
272 assert(
get_manager()->process_manager().is_worker());
274 double section_first = 0;
275 double section_last = 1;
278 std::size_t N_events =
likelihood_->numDataEntries();
279 if (event_task > 0) {
281 section_first =
static_cast<double>(first) / N_events;
284 std::size_t last = N_events * (event_task + 1) /
getNEventTasks();
285 section_last =
static_cast<double>(last) / N_events;
307 std::size_t components_first = 0;
308 std::size_t components_last =
likelihood_->getNComponents();
321 for (std::size_t comp_ix = components_first; comp_ix < components_last; ++comp_ix) {
322 auto component_result =
likelihood_->evaluatePartition({section_first, section_last}, comp_ix, comp_ix + 1);
346 printf(
"WARNING: when calling MinuitFcnGrad::setOffsetting after the run has already been started the "
347 "MinuitFcnGrad::likelihood_in_gradient object (a LikelihoodSerial) on the workers can no longer be "
348 "updated! This function (LikelihoodJob::enableOffsetting) can in principle be used outside of "
349 "MinuitFcnGrad, but be aware of this limitation. To do a minimization with a different offsetting "
350 "setting, please delete all RooFit::MultiProcess based objects so that the forked processes are killed "
351 "and then set up a new RooMinimizer.\n");
356#define PROCESS_VAL(p) \
357 case (p): s = #p; break;
365 default: s = std::to_string(
static_cast<int>(
value));
TBuffer & operator<<(TBuffer &buf, const Tmpl *obj)
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h offset
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Option_t Option_t TPoint TPoint const char mode
The Kahan summation is a compensated summation algorithm, which significantly reduces numerical error...
bool isConstant() const
Check if the "Constant" attribute is set.
virtual void removeAll()
Remove all arguments from our set, deleting them if we own them.
virtual bool add(const RooAbsArg &var, bool silent=false)
Add the specified argument to list.
Storage_t::size_type size() const
virtual RooAbsArg * addClone(const RooAbsArg &var, bool silent=false)
Add a clone of the specified argument to list.
void setConstant(bool value=true)
Abstract base class for objects that represent a real value and implements functionality common to al...
double getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
static Int_t numEvalErrors()
Return the number of logged evaluation errors since the last clearing.
void logEvalError(const char *message, const char *serverValueString=nullptr) const
Log evaluation error message.
static void clearEvalErrorLog()
Clear the stack of evaluation error messages.
RooArgList is a container object that can hold multiple RooAbsArg objects.
RooAbsArg * at(Int_t idx) const
Return object at given index, or nullptr if index is out of range.
Messenger & messenger() const
ProcessManager & process_manager() const
static bool is_instantiated()
JobManager * get_manager()
Get JobManager instance; create and activate if necessary.
void gather_worker_results()
Wait for all tasks to be retrieved for the current Job.
value_t receive_from_master_on_worker(bool *more=nullptr)
void send_from_worker_to_master(T &&item)
specialization that sends the final message
void publish_from_master_to_workers(T &&item)
specialization that sends the final message
std::size_t N_workers() const
virtual void add(JobTask job_task)=0
Enqueue a task.
void enableOffsetting(bool flag) override
std::size_t getNEventTasks()
bool receive_task_result_on_master(const zmq::message_t &message) override
void evaluate_task(std::size_t task) override
std::size_t getNComponentTasks()
void updateWorkersParameters()
std::size_t n_event_tasks_
std::vector< ROOT::Math::KahanSum< double > > results_
void updateWorkersOffsetting()
void send_back_task_result_from_worker(std::size_t task) override
void update_state() override
Virtual function to update any necessary state on workers.
void evaluate() override
Triggers (possibly asynchronous) evaluation of the likelihood.
SharedOffset::OffsetVec offsets_previous_
ROOT::Math::KahanSum< double > result_
std::size_t n_component_tasks_
LikelihoodJob(std::shared_ptr< RooAbsL > _likelihood, std::shared_ptr< WrapperCalculationCleanFlags > calculation_is_clean, SharedOffset offset)
LikelihoodSerial likelihood_serial_
std::size_t n_tasks_at_workers_
void evaluate() override
Triggers (possibly asynchronous) evaluation of the likelihood.
Virtual base class for implementation of likelihood calculation strategies.
virtual bool isOffsetting() const
std::shared_ptr< RooAbsL > likelihood_
SharedOffset shared_offset_
virtual std::string GetName() const
virtual void enableOffsetting(bool flag)
OffsettingMode offsetting_mode_
LikelihoodType likelihood_type_
Variable that can be changed from the outside.
void setVal(double value) override
Set value of variable to 'value'.
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
static constexpr std::size_t automaticNEventTasks
static constexpr std::size_t automaticNComponentTasks
Little struct that can pack a float into the unused bits of the mantissa of a NaN double.
float getPayload() const
Retrieve packed float.
double getNaNWithPayload() const
Retrieve a NaN with the current float payload packed into the mantissa.
void accumulate(double val)
Accumulate a packed float from another NaN into this.