36 std::shared_ptr<WrapperCalculationCleanFlags> calculation_is_clean,
SharedOffset offset)
37 :
LikelihoodWrapper(std::move(likelihood), std::move(calculation_is_clean), std::move(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;
101 std::copy(offsets_message_begin, offsets_message_end,
shared_offset_.offsets().begin());
144 if (
get_manager()->process_manager().is_master()) {
145 bool valChanged =
false;
146 bool constChanged =
false;
147 std::vector<update_state_t> to_update;
148 for (std::size_t ix = 0u; ix < static_cast<std::size_t>(
vars_.size()); ++ix) {
150 constChanged = (
vars_[ix].isConstant() !=
save_vars_[ix].isConstant());
152 if (valChanged || constChanged) {
163 double val = rar_val->
getVal();
165 bool isC =
vars_[ix].isConstant();
171 if (!to_update.empty() || update_offsets) {
173 zmq::message_t message(to_update.begin(), to_update.end());
176 if (update_offsets) {
179 std::move(message), std::move(offsets_message));
196 if (
get_manager()->process_manager().is_master()) {
209 for (std::size_t ix = 0; ix < N_tasks; ++ix) {
225 for (
auto item_it =
results_.cbegin() + 1; item_it !=
results_.cend(); ++item_it) {
261 results_.emplace_back(task_result->value, task_result->carry);
262 if (task_result->has_errors) {
267 return job_completed;
274 assert(
get_manager()->process_manager().is_worker());
276 double section_first = 0;
277 double section_last = 1;
280 std::size_t N_events =
likelihood_->numDataEntries();
281 if (event_task > 0) {
283 section_first =
static_cast<double>(first) / N_events;
286 std::size_t last = N_events * (event_task + 1) /
getNEventTasks();
287 section_last =
static_cast<double>(last) / N_events;
309 std::size_t components_first = 0;
310 std::size_t components_last =
likelihood_->getNComponents();
323 for (std::size_t comp_ix = components_first; comp_ix < components_last; ++comp_ix) {
324 auto component_result =
likelihood_->evaluatePartition({section_first, section_last}, comp_ix, comp_ix + 1);
348 printf(
"WARNING: when calling MinuitFcnGrad::setOffsetting after the run has already been started the "
349 "MinuitFcnGrad::likelihood_in_gradient object (a LikelihoodSerial) on the workers can no longer be "
350 "updated! This function (LikelihoodJob::enableOffsetting) can in principle be used outside of "
351 "MinuitFcnGrad, but be aware of this limitation. To do a minimization with a different offsetting "
352 "setting, please delete all RooFit::MultiProcess based objects so that the forked processes are killed "
353 "and then set up a new RooMinimizer.\n");
358#define PROCESS_VAL(p) \
359 case (p): s = #p; break;
367 default: s = std::to_string(
static_cast<int>(value));
The Kahan summation is a compensated summation algorithm, which significantly reduces numerical error...
bool isConstant() const
Check if the "Constant" attribute is set.
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.
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_
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_
LikelihoodWrapper(std::shared_ptr< RooAbsL > likelihood, std::shared_ptr< WrapperCalculationCleanFlags > calculation_is_clean, SharedOffset offset)
std::shared_ptr< WrapperCalculationCleanFlags > calculation_is_clean_
LikelihoodType likelihood_type_
Variable that can be changed from the outside.
void setVal(double value) override
Set value of variable to 'value'.
Namespace for new RooFit test statistic calculation.
std::ostream & operator<<(std::ostream &out, const LikelihoodJob::update_state_mode 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.