29namespace TestStatistics {
32 std::shared_ptr<RooAbsL> likelihood,
33 std::shared_ptr<WrapperCalculationCleanFlags> calculation_is_clean)
35 n_event_tasks_(MultiProcess::Config::
LikelihoodJob::defaultNEventTasks),
36 n_component_tasks_(MultiProcess::Config::
LikelihoodJob::defaultNComponentTasks)
49 throw std::logic_error(
"in LikelihoodJob constructor: likelihood is not of a valid subclass!");
73 std::unique_ptr<RooArgSet> vars{
likelihood_->getParameters()};
93 auto message_end = message_begin + message.size() /
sizeof(
update_state_t);
94 std::vector<update_state_t> to_update(message_begin, message_end);
95 for (
auto const &item : to_update) {
97 rvar->
setVal(
static_cast<double>(item.value));
99 rvar->
setConstant(
static_cast<bool>(item.is_constant));
140 if (
get_manager()->process_manager().is_master()) {
141 bool valChanged =
false;
142 bool constChanged =
false;
143 std::vector<update_state_t> to_update;
144 for (std::size_t ix = 0u; ix < static_cast<std::size_t>(
vars_.
getSize()); ++ix) {
146 constChanged = (
vars_[ix].isConstant() !=
save_vars_[ix].isConstant());
148 if (valChanged || constChanged) {
159 double val = rar_val->
getVal();
161 bool isC =
vars_[ix].isConstant();
166 if (!to_update.empty()) {
168 zmq::message_t message(to_update.begin(), to_update.end());
183 if (
get_manager()->process_manager().is_master()) {
189 for (std::size_t ix = 0; ix < N_tasks; ++ix) {
220 results_.emplace_back(task_result->value, task_result->carry);
223 return job_completed;
230 assert(
get_manager()->process_manager().is_worker());
232 double section_first = 0;
233 double section_last = 1;
236 std::size_t N_events =
likelihood_->numDataEntries();
237 if (event_task > 0) {
239 section_first =
static_cast<double>(
first) / N_events;
242 std::size_t last = N_events * (event_task + 1) /
getNEventTasks();
243 section_last =
static_cast<double>(last) / N_events;
254 std::size_t components_first = 0;
255 std::size_t components_last =
likelihood_->getNComponents();
265 result_ =
likelihood_->evaluatePartition({section_first, section_last}, components_first, components_last);
270 throw std::logic_error(
271 "in LikelihoodJob::evaluate_task: likelihood types other than binned and unbinned not yet implemented!");
281 printf(
"WARNING: when calling MinuitFcnGrad::setOffsetting after the run has already been started the MinuitFcnGrad::likelihood_in_gradient object (a LikelihoodSerial) on the workers can no longer be updated! This function (LikelihoodJob::enableOffsetting) can in principle be used outside of MinuitFcnGrad, but be aware of this limitation. To do a minimization with a different offsetting setting, please delete all RooFit::MultiProcess based objects so that the forked processes are killed and then set up a new RooMinimizer.\n");
286#define PROCESS_VAL(p) \
287 case (p): s = #p; break;
295 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 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.
Int_t getSize() const
Return the number of elements in the collection.
virtual bool add(const RooAbsArg &var, bool silent=false)
Add the specified argument to list.
virtual RooAbsArg * addClone(const RooAbsArg &var, bool silent=false)
Add a clone of the specified argument to list.
void setConstant(bool value=true)
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
double getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
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()
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.
LikelihoodJob(std::shared_ptr< RooAbsL > _likelihood, std::shared_ptr< WrapperCalculationCleanFlags > calculation_is_clean)
ROOT::Math::KahanSum< double > result_
std::size_t n_component_tasks_
LikelihoodJob * clone() const override
LikelihoodType likelihood_type_
std::size_t n_tasks_at_workers_
Virtual base class for implementation of likelihood calculation strategies.
virtual bool isOffsetting() const
std::shared_ptr< RooAbsL > likelihood_
ROOT::Math::KahanSum< double > applyOffsetting(ROOT::Math::KahanSum< double > current_value)
virtual void enableOffsetting(bool flag)
Likelihood class that sums over multiple -log components.
RooRealVar represents a 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