Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RooRealMPFE.cxx
Go to the documentation of this file.
1/// \cond ROOFIT_INTERNAL
2
3/*****************************************************************************
4 * Project: RooFit *
5 * Package: RooFitCore *
6 * @(#)root/roofitcore:$Id$
7 * Authors: *
8 * WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu *
9 * DK, David Kirkby, UC Irvine, dkirkby@uci.edu *
10 * *
11 * Copyright (c) 2000-2005, Regents of the University of California *
12 * and Stanford University. All rights reserved. *
13 * *
14 * Redistribution and use in source and binary forms, *
15 * with or without modification, are permitted according to the terms *
16 * listed in LICENSE (http://roofit.sourceforge.net/license.txt) *
17 *****************************************************************************/
18
19/**
20\file RooRealMPFE.cxx
21\class RooRealMPFE
22\ingroup Roofitcore
23
24Multi-processor front-end for parallel calculation
25of RooAbsReal objects. Each RooRealMPFE forks a process that calculates
26the value of the proxies RooAbsReal object. The (re)calculation of
27the proxied object is started asynchronously with the calculate() option.
28A subsequent call to getVal() will return the calculated value when available
29If the calculation is still in progress when getVal() is called it blocks
30the calling process until the calculation is done. The forked calculation process
31is terminated when the front-end object is deleted
32Simple use demonstration
33
34~~~{.cpp}
35RooAbsReal* slowFunc ;
36
37double val = slowFunc->getVal() // Evaluate slowFunc in current process
38
39RooRealMPFE mpfe("mpfe","frontend to slowFunc",*slowFunc) ;
40mpfe.calculate() ; // Start calculation of slow-func in remote process
41 // .. do other stuff here ..
42double val = mpfe.getVal() // Wait for remote calculation to finish and retrieve value
43~~~
44
45For general multiprocessing in ROOT, please refer to the TProcessExecutor class.
46
47**/
48
49#include "Riostream.h"
50
51#ifndef _WIN32
52#include "BidirMMapPipe.h"
53#endif
54
55#include <cstdlib>
56#include <memory>
57#include <sstream>
58#include "RooRealMPFE.h"
59#include "RooArgSet.h"
60#include "RooAbsCategory.h"
61#include "RooRealVar.h"
62#include "RooCategory.h"
63#include "RooMsgService.h"
64#include "RooNLLVar.h"
65#include "RooTrace.h"
66
67#include "Rtypes.h"
68#include "TSystem.h"
69
70
71class RooRealMPFE ;
72
73// RooMPSentinel is a singleton class that keeps track of all
74// parallel execution processes for goodness-of-fit calculations.
75// The primary task of RooMPSentinel is to terminate all server processes
76// when the main ROOT process is exiting.
77struct RooMPSentinel {
78
79 static RooMPSentinel& instance();
80
82
83 void add(RooRealMPFE& mpfe) ;
84 void remove(RooRealMPFE& mpfe) ;
85
87};
88
89RooMPSentinel& RooMPSentinel::instance() {
90 static RooMPSentinel inst;
91 return inst;
92}
93
94
95using std::string, std::ostringstream, std::list;
96using namespace RooFit;
97
98
99////////////////////////////////////////////////////////////////////////////////
100/// Construct front-end object for object 'arg' whose evaluation will be calculated
101/// asynchronously in a separate process. If calcInline is true the value of 'arg'
102/// is calculate synchronously in the current process.
103
104RooRealMPFE::RooRealMPFE(const char *name, const char *title, RooAbsReal& arg, bool calcInline) :
105 RooAbsReal(name,title),
106 _state(Initialize),
107 _arg("arg","arg",this,arg),
108 _vars("vars","vars",this),
114 _pipe(nullptr),
115 _updateMaster(nullptr),
117{
118#ifdef _WIN32
119 _inlineMode = true;
120#endif
121 initVars() ;
122 RooMPSentinel::instance().add(*this) ;
123
124}
125
126
127
128////////////////////////////////////////////////////////////////////////////////
129/// Copy constructor. Initializes in clean state so that upon eval
130/// this instance will create its own server processes
131
132RooRealMPFE::RooRealMPFE(const RooRealMPFE& other, const char* name) :
134 _state(Initialize),
135 _arg("arg",this,other._arg),
136 _vars("vars",this,other._vars),
143 _pipe(nullptr),
144 _updateMaster(nullptr),
146{
147 initVars() ;
148 RooMPSentinel::instance().add(*this) ;
149}
150
151
152
153////////////////////////////////////////////////////////////////////////////////
154/// Destructor
155
156RooRealMPFE::~RooRealMPFE()
157{
158 if (_state==Client) standby();
159 RooMPSentinel::instance().remove(*this);
160}
161
162
163
164////////////////////////////////////////////////////////////////////////////////
165/// Initialize list of variables of front-end argument 'arg'
166
167void RooRealMPFE::initVars()
168{
169 // Empty current lists
170 _vars.removeAll() ;
171 _saveVars.removeAll() ;
172
173 // Retrieve non-constant parameters
174 std::unique_ptr<RooArgSet> vars{_arg->getParameters(RooArgSet())};
175 // RooArgSet *ncVars = vars->selectByAttrib("Constant", false);
176 RooArgList varList(*vars) ;
177
178 // Save in lists
179 _vars.add(varList) ;
180 _saveVars.addClone(varList) ;
181 _valueChanged.resize(_vars.size()) ;
182 _constChanged.resize(_vars.size()) ;
183
184 // Force next calculation
185 _forceCalc = true ;
186}
187
188double RooRealMPFE::getCarry() const
189{
190 if (_inlineMode) {
191 RooAbsTestStatistic* tmp = dynamic_cast<RooAbsTestStatistic*>(_arg.absArg());
192 if (tmp) return tmp->getCarry();
193 else return 0.;
194 } else {
195 return _evalCarry;
196 }
197}
198
199////////////////////////////////////////////////////////////////////////////////
200/// Initialize the remote process and message passing
201/// pipes between current process and remote process
202
203void RooRealMPFE::initialize()
204{
205 // Trivial case: Inline mode
206 if (_inlineMode) {
207 _state = Inline ;
208 return ;
209 }
210
211#ifndef _WIN32
212 // Clear eval error log prior to forking
213 // to avoid confusions...
214 clearEvalErrorLog() ;
215 // Fork server process and setup IPC
216 _pipe = new BidirMMapPipe();
217
218 if (_pipe->isChild()) {
219 // Start server loop
221 _state = Server ;
222 serverLoop();
223
224 // Kill server at end of service
225 if (_verboseServer) ccoutD(Minimization) << "RooRealMPFE::initialize(" <<
226 GetName() << ") server process terminating" << std::endl ;
227
228 delete _arg.absArg();
229 delete _pipe;
230 _exit(0) ;
231 } else {
232 // Client process - fork successful
233 if (_verboseClient) {
234 ccoutD(Minimization) << "RooRealMPFE::initialize(" << GetName() << ") successfully forked server process "
235 << _pipe->pidOtherEnd() << std::endl;
236 }
237 _state = Client ;
239 }
240#endif // _WIN32
241}
242
243
244
245////////////////////////////////////////////////////////////////////////////////
246/// Server loop of remote processes. This function will return
247/// only when an incoming TERMINATE message is received.
248
249void RooRealMPFE::serverLoop()
250{
251#ifndef _WIN32
252 int msg ;
253
254 Int_t idx;
255 Int_t index;
257 double value ;
258 bool isConst ;
259
260 clearEvalErrorLog() ;
261
262 while(*_pipe && !_pipe->eof()) {
263 *_pipe >> msg;
264 if (Terminate == msg) {
265 if (_verboseServer) std::cout << "RooRealMPFE::serverLoop(" << GetName()
266 << ") IPC fromClient> Terminate" << std::endl;
267 // send terminate acknowledged to client
268 *_pipe << msg << BidirMMapPipe::flush;
269 break;
270 }
271
272 switch (msg) {
273 case SendReal:
274 {
275 *_pipe >> idx >> value >> isConst;
276 if (_verboseServer) std::cout << "RooRealMPFE::serverLoop(" << GetName()
277 << ") IPC fromClient> SendReal [" << idx << "]=" << value << std::endl ;
278 RooRealVar* rvar = static_cast<RooRealVar*>(_vars.at(idx)) ;
279 rvar->setVal(value) ;
280 if (rvar->isConstant() != isConst) {
281 rvar->setConstant(isConst) ;
282 }
283 }
284 break ;
285
286 case SendCat:
287 {
288 *_pipe >> idx >> index;
289 if (_verboseServer) std::cout << "RooRealMPFE::serverLoop(" << GetName()
290 << ") IPC fromClient> SendCat [" << idx << "]=" << index << std::endl ;
291 (static_cast<RooCategory*>(_vars.at(idx)))->setIndex(index) ;
292 }
293 break ;
294
295 case Calculate:
296 if (_verboseServer) std::cout << "RooRealMPFE::serverLoop(" << GetName()
297 << ") IPC fromClient> Calculate" << std::endl ;
298 _value = _arg ;
299 break ;
300
302 if (_verboseServer) std::cout << "RooRealMPFE::serverLoop(" << GetName()
303 << ") IPC fromClient> Calculate" << std::endl ;
304
306 _value = _arg ;
308 break ;
309
310 case Retrieve:
311 {
312 if (_verboseServer) std::cout << "RooRealMPFE::serverLoop(" << GetName()
313 << ") IPC fromClient> Retrieve" << std::endl ;
315 numErrors = numEvalErrors();
316 *_pipe << msg << _value << getCarry() << numErrors;
317
318 if (_verboseServer) std::cout << "RooRealMPFE::serverLoop(" << GetName()
319 << ") IPC toClient> ReturnValue " << _value << " NumError " << numErrors << std::endl ;
320
321 if (numErrors) {
322 // Loop over errors
323 std::string objidstr;
324 {
325 ostringstream oss2;
326 // Format string with object identity as this cannot be evaluated on the other side
327 oss2 << "PID" << gSystem->GetPid() << "/";
328 printStream(oss2,kName|kClassName|kArgs,kInline);
329 objidstr = oss2.str();
330 }
331 std::map<const RooAbsArg*,std::pair<string,list<EvalError> > >::const_iterator iter = evalErrorIter();
332 const RooAbsArg* ptr = nullptr;
333 for (int i = 0; i < numEvalErrorItems(); ++i) {
334 list<EvalError>::const_iterator iter2 = iter->second.second.begin();
335 for (; iter->second.second.end() != iter2; ++iter2) {
336 ptr = iter->first;
337 *_pipe << ptr << iter2->_msg << iter2->_srvval << objidstr;
338 if (_verboseServer) std::cout << "RooRealMPFE::serverLoop(" << GetName()
339 << ") IPC toClient> sending error log Arg " << iter->first << " Msg " << iter2->_msg << std::endl ;
340 }
341 }
342 // let other end know that we're done with the list of errors
343 ptr = nullptr;
344 *_pipe << ptr;
345 // Clear error list on local side
346 clearEvalErrorLog();
347 }
348 *_pipe << BidirMMapPipe::flush;
349 }
350 break;
351
352 case ConstOpt:
353 {
354 bool doTrack ;
355 int code;
356 *_pipe >> code >> doTrack;
357 if (_verboseServer) std::cout << "RooRealMPFE::serverLoop(" << GetName()
358 << ") IPC fromClient> ConstOpt " << code << " doTrack = " << (doTrack?"T":"F") << std::endl ;
359 ((RooAbsReal&)_arg.arg()).constOptimizeTestStatistic(static_cast<RooAbsArg::ConstOpCode>(code),doTrack) ;
360 break ;
361 }
362
363 case Verbose:
364 {
365 bool flag ;
366 *_pipe >> flag;
367 if (_verboseServer) std::cout << "RooRealMPFE::serverLoop(" << GetName()
368 << ") IPC fromClient> Verbose " << (flag?1:0) << std::endl ;
370 }
371 break ;
372
373
374 case ApplyNLLW2:
375 {
376 bool flag ;
377 *_pipe >> flag;
378 if (_verboseServer) std::cout << "RooRealMPFE::serverLoop(" << GetName()
379 << ") IPC fromClient> ApplyNLLW2 " << (flag?1:0) << std::endl ;
380
381 // Do application of weight-squared here
383 }
384 break ;
385
386 case EnableOffset:
387 {
388 bool flag ;
389 *_pipe >> flag;
390 if (_verboseServer) std::cout << "RooRealMPFE::serverLoop(" << GetName()
391 << ") IPC fromClient> EnableOffset " << (flag?1:0) << std::endl ;
392
393 // Enable likelihoof offsetting here
394 ((RooAbsReal&)_arg.arg()).enableOffsetting(flag) ;
395 }
396 break ;
397
398 case LogEvalError:
399 {
400 int iflag2;
401 *_pipe >> iflag2;
404 if (_verboseServer) std::cout << "RooRealMPFE::serverLoop(" << GetName()
405 << ") IPC fromClient> LogEvalError flag = " << flag2 << std::endl ;
406 }
407 break ;
408
409
410 default:
411 if (_verboseServer) std::cout << "RooRealMPFE::serverLoop(" << GetName()
412 << ") IPC fromClient> Unknown message (code = " << msg << ")" << std::endl ;
413 break ;
414 }
415 }
416
417#endif // _WIN32
418}
419
420
421
422////////////////////////////////////////////////////////////////////////////////
423/// Client-side function that instructs server process to start
424/// asynchronous (re)calculation of function value. This function
425/// returns immediately. The calculated value can be retrieved
426/// using getVal()
427
428void RooRealMPFE::calculate() const
429{
430
431 // Start asynchronous calculation of arg value
432 if (_state==Initialize) {
433 // std::cout << "RooRealMPFE::calculate(" << GetName() << ") initializing" << std::endl ;
434 const_cast<RooRealMPFE*>(this)->initialize() ;
435 }
436
437 // Inline mode -- Calculate value now
438 if (_state==Inline) {
439 // std::cout << "RooRealMPFE::calculate(" << GetName() << ") performing Inline calculation NOW" << std::endl ;
440 _value = _arg ;
441 clearValueDirty() ;
442 }
443
444#ifndef _WIN32
445 // Compare current value of variables with saved values and send changes to server
446 if (_state==Client) {
447 // std::cout << "RooRealMPFE::calculate(" << GetName() << ") state is Client trigger remote calculation" << std::endl ;
448 Int_t i(0) ;
449
450 //for (i=0 ; i<_vars.size() ; i++) {
451 RooAbsArg *var;
453 for (std::size_t j=0 ; j<_vars.size() ; j++) {
454 var = _vars.at(j);
455 saveVar = _saveVars.at(j);
456
457 //bool valChanged = !(*var==*saveVar) ;
458 bool valChanged;
459 bool constChanged;
460 if (!_updateMaster) {
461 valChanged = !var->isIdentical(*saveVar,true) ;
462 constChanged = (var->isConstant() != saveVar->isConstant()) ;
465 } else {
466 valChanged = _updateMaster->_valueChanged[i] ;
467 constChanged = _updateMaster->_constChanged[i] ;
468 }
469
471 //cout << "RooRealMPFE::calculate(" << GetName() << " variable " << var->GetName() << " changed " << std::endl ;
472 if (_verboseClient) std::cout << "RooRealMPFE::calculate(" << GetName()
473 << ") variable " << _vars.at(i)->GetName() << " changed" << std::endl ;
474 if (constChanged) {
475 (static_cast<RooRealVar*>(saveVar))->setConstant(var->isConstant()) ;
476 }
477 saveVar->copyCache(var) ;
478
479 // send message to server
480 if (dynamic_cast<RooAbsReal*>(var)) {
481 int msg = SendReal ;
482 double val = (static_cast<RooAbsReal*>(var))->getVal() ;
483 bool isC = var->isConstant() ;
484 *_pipe << msg << i << val << isC;
485
486 if (_verboseServer) std::cout << "RooRealMPFE::calculate(" << GetName()
487 << ") IPC toServer> SendReal [" << i << "]=" << val << (isC?" (Constant)":"") << std::endl ;
488 } else if (dynamic_cast<RooAbsCategory*>(var)) {
489 int msg = SendCat ;
490 UInt_t idx = (static_cast<RooAbsCategory*>(var))->getCurrentIndex() ;
491 *_pipe << msg << i << idx;
492 if (_verboseServer) std::cout << "RooRealMPFE::calculate(" << GetName()
493 << ") IPC toServer> SendCat [" << i << "]=" << idx << std::endl ;
494 }
495 }
496 i++ ;
497 }
498
499 int msg = hideOffset() ? Calculate : CalculateNoOffset;
500 *_pipe << msg;
501 if (_verboseServer) std::cout << "RooRealMPFE::calculate(" << GetName()
502 << ") IPC toServer> Calculate " << std::endl ;
503
504 // Clear dirty state and mark that calculation request was dispatched
505 clearValueDirty() ;
507 _forceCalc = false ;
508
509 msg = Retrieve ;
510 *_pipe << msg << BidirMMapPipe::flush;
511 if (_verboseServer) std::cout << "RooRealMPFE::evaluate(" << GetName()
512 << ") IPC toServer> Retrieve " << std::endl ;
514
515 } else if (_state!=Inline) {
516 std::cout << "RooRealMPFE::calculate(" << GetName()
517 << ") ERROR not in Client or Inline mode" << std::endl ;
518 }
519
520
521#endif // _WIN32
522}
523
524
525
526
527////////////////////////////////////////////////////////////////////////////////
528/// If value needs recalculation and calculation has not been started
529/// with a call to calculate() start it now. This function blocks
530/// until remote process has finished calculation and returns
531/// remote value
532
533double RooRealMPFE::getValV(const RooArgSet* /*nset*/) const
534{
535
536 if (isValueDirty()) {
537 // Cache is dirty, no calculation has been started yet
538 //cout << "RooRealMPFE::getValF(" << GetName() << ") cache is dirty, calling calculate and evaluate" << std::endl ;
539 calculate() ;
540 _value = evaluate() ;
541 } else if (_calcInProgress) {
542 //cout << "RooRealMPFE::getValF(" << GetName() << ") calculation in progress, calling evaluate" << std::endl ;
543 // Cache is clean and calculation is in progress
544 _value = evaluate() ;
545 } else {
546 //cout << "RooRealMPFE::getValF(" << GetName() << ") cache is clean, doing nothing" << std::endl ;
547 // Cache is clean and calculated value is in cache
548 }
549
550// std::cout << "RooRealMPFE::getValV(" << GetName() << ") value = " << Form("%5.10f",_value) << std::endl ;
551 return _value ;
552}
553
554
555
556////////////////////////////////////////////////////////////////////////////////
557/// Send message to server process to retrieve output value
558/// If error were logged use logEvalError() on remote side
559/// transfer those errors to the local eval error queue.
560
561double RooRealMPFE::evaluate() const
562{
563 // Retrieve value of arg
564 double return_value = 0;
565 if (_state==Inline) {
566 return_value = _arg ;
567 } else if (_state==Client) {
568#ifndef _WIN32
569 bool needflush = false;
570 int msg;
571 double value;
572
573 // If current error logging state is not the same as remote state
574 // update the remote state
575 if (evalErrorLoggingMode() != _remoteEvalErrorLoggingState) {
576 msg = LogEvalError ;
577 RooAbsReal::ErrorLoggingMode flag = evalErrorLoggingMode() ;
578 *_pipe << msg << flag;
579 needflush = true;
580 _remoteEvalErrorLoggingState = evalErrorLoggingMode() ;
581 }
582
583 if (!_retrieveDispatched) {
584 msg = Retrieve ;
585 *_pipe << msg;
586 needflush = true;
587 if (_verboseServer) std::cout << "RooRealMPFE::evaluate(" << GetName()
588 << ") IPC toServer> Retrieve " << std::endl ;
589 }
590 if (needflush) *_pipe << BidirMMapPipe::flush;
592
593
595
596 *_pipe >> msg >> value >> _evalCarry >> numError;
597
598 if (msg!=ReturnValue) {
599 std::cout << "RooRealMPFE::evaluate(" << GetName()
600 << ") ERROR: unexpected message from server process: " << msg << std::endl ;
601 return 0 ;
602 }
603 if (_verboseServer) std::cout << "RooRealMPFE::evaluate(" << GetName()
604 << ") IPC fromServer> ReturnValue " << value << std::endl ;
605
606 if (_verboseServer) std::cout << "RooRealMPFE::evaluate(" << GetName()
607 << ") IPC fromServer> NumErrors " << numError << std::endl ;
608 if (numError) {
609 // Retrieve remote errors and feed into local error queue
610 char *msgbuf1 = nullptr;
611 char *msgbuf2 = nullptr;
612 char *msgbuf3 = nullptr;
613 RooAbsArg *ptr = nullptr;
614 while (true) {
615 *_pipe >> ptr;
616 if (!ptr) break;
617 *_pipe >> msgbuf1 >> msgbuf2 >> msgbuf3;
618 if (_verboseServer) std::cout << "RooRealMPFE::evaluate(" << GetName()
619 << ") IPC fromServer> retrieving error log Arg " << ptr << " Msg " << msgbuf1 << std::endl ;
620
621 logEvalError(reinterpret_cast<RooAbsReal*>(ptr),msgbuf3,msgbuf1,msgbuf2) ;
622 }
623 std::free(msgbuf1);
624 std::free(msgbuf2);
625 std::free(msgbuf3);
626 }
627
628 // Mark end of calculation in progress
631#endif // _WIN32
632 }
633
634 return return_value;
635}
636
637
638
639////////////////////////////////////////////////////////////////////////////////
640/// Terminate remote server process and return front-end class
641/// to standby mode. Calls to calculate() or evaluate() after
642/// this call will automatically recreated the server process.
643
644void RooRealMPFE::standby()
645{
646#ifndef _WIN32
647 if (_state==Client) {
648 if (_pipe->good()) {
649 // Terminate server process ;
650 if (_verboseServer) std::cout << "RooRealMPFE::standby(" << GetName()
651 << ") IPC toServer> Terminate " << std::endl;
652 int msg = Terminate;
653 *_pipe << msg << BidirMMapPipe::flush;
654 // read handshake
655 msg = 0;
656 *_pipe >> msg;
657 if (Terminate != msg || 0 != _pipe->close()) {
658 std::cerr << "In " << __func__ << "(" << __FILE__ ", " << __LINE__ <<
659 "): Server shutdown failed." << std::endl;
660 }
661 } else {
662 if (_verboseServer) {
663 std::cerr << "In " << __func__ << "(" << __FILE__ ", " <<
664 __LINE__ << "): Pipe has already shut down, not sending "
665 "Terminate to server." << std::endl;
666 }
667 }
668 // Close pipes
669 delete _pipe;
670 _pipe = nullptr;
671
672 // Revert to initialize state
673 _state = Initialize;
674 }
675#endif // _WIN32
676}
677
678
679
680////////////////////////////////////////////////////////////////////////////////
681/// Intercept call to optimize constant term in test statistics
682/// and forward it to object on server side.
683
684void RooRealMPFE::constOptimizeTestStatistic(ConstOpCode opcode, bool doAlsoTracking)
685{
686#ifndef _WIN32
687 if (_state==Client) {
688
689 int msg = ConstOpt ;
690 int op = opcode;
691 *_pipe << msg << op << doAlsoTracking;
692 if (_verboseServer) std::cout << "RooRealMPFE::constOptimize(" << GetName()
693 << ") IPC toServer> ConstOpt " << opcode << std::endl ;
694
695 initVars() ;
696 }
697#endif // _WIN32
698
699 if (_state==Inline) {
700 ((RooAbsReal&)_arg.arg()).constOptimizeTestStatistic(opcode,doAlsoTracking) ;
701 }
702}
703
704
705
706////////////////////////////////////////////////////////////////////////////////
707/// Control verbose messaging related to inter process communication
708/// on both client and server side
709
710void RooRealMPFE::setVerbose(bool clientFlag, bool serverFlag)
711{
712#ifndef _WIN32
713 if (_state==Client) {
714 int msg = Verbose ;
715 *_pipe << msg << serverFlag;
716 if (_verboseServer) std::cout << "RooRealMPFE::setVerbose(" << GetName()
717 << ") IPC toServer> Verbose " << (serverFlag?1:0) << std::endl ;
718 }
719#endif // _WIN32
721}
722
723
724////////////////////////////////////////////////////////////////////////////////
725/// Control verbose messaging related to inter process communication
726/// on both client and server side
727
728void RooRealMPFE::applyNLLWeightSquared(bool flag)
729{
730#ifndef _WIN32
731 if (_state==Client) {
732 int msg = ApplyNLLW2 ;
733 *_pipe << msg << flag;
734 if (_verboseServer) std::cout << "RooRealMPFE::applyNLLWeightSquared(" << GetName()
735 << ") IPC toServer> ApplyNLLW2 " << (flag?1:0) << std::endl ;
736 }
737#endif // _WIN32
739}
740
741
742////////////////////////////////////////////////////////////////////////////////
743
744void RooRealMPFE::doApplyNLLW2(bool flag)
745{
746 RooNLLVar* nll = dynamic_cast<RooNLLVar*>(_arg.absArg()) ;
747 if (nll) {
748 nll->applyWeightSquared(flag) ;
749 }
750}
751
752
753////////////////////////////////////////////////////////////////////////////////
754/// Control verbose messaging related to inter process communication
755/// on both client and server side
756
757void RooRealMPFE::enableOffsetting(bool flag)
758{
759#ifndef _WIN32
760 if (_state==Client) {
761 int msg = EnableOffset ;
762 *_pipe << msg << flag;
763 if (_verboseServer) std::cout << "RooRealMPFE::enableOffsetting(" << GetName()
764 << ") IPC toServer> EnableOffset " << (flag?1:0) << std::endl ;
765 }
766#endif // _WIN32
767 ((RooAbsReal&)_arg.arg()).enableOffsetting(flag) ;
768}
769
770
771
772////////////////////////////////////////////////////////////////////////////////
773/// Destructor. Terminate all parallel processes still registered with
774/// the sentinel
775
776RooMPSentinel::~RooMPSentinel()
777{
778 for(auto * mpfe : static_range_cast<RooRealMPFE*>(_mpfeSet)) {
779 mpfe->standby() ;
780 }
781}
782
783
784
785////////////////////////////////////////////////////////////////////////////////
786/// Register given multi-processor front-end object with the sentinel
787
788void RooMPSentinel::add(RooRealMPFE& mpfe)
789{
790 _mpfeSet.add(mpfe,true) ;
791}
792
793
794
795////////////////////////////////////////////////////////////////////////////////
796/// Remove given multi-processor front-end object from the sentinel
797
798void RooMPSentinel::remove(RooRealMPFE& mpfe)
799{
800 _mpfeSet.remove(mpfe,true) ;
801}
802
803/// \endcond
ROOT::RRangeCast< T, false, Range_t > static_range_cast(Range_t &&coll)
static Roo_reg_AGKInteg1D instance
#define ccoutD(a)
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:59
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int)
Definition RtypesCore.h:60
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
char name[80]
Definition TGX11.cxx:148
@ kName
R__EXTERN TSystem * gSystem
Definition TSystem.h:582
Common abstract base class for objects that represent a value and a "shape" in RooFit.
Definition RooAbsArg.h:76
bool isConstant() const
Check if the "Constant" attribute is set.
Definition RooAbsArg.h:283
virtual bool isIdentical(const RooAbsArg &other, bool assumeSameType=false) const =0
A space to attach TBranches.
void setConstant(bool value=true)
Abstract base class for objects that represent a real value and implements functionality common to al...
Definition RooAbsReal.h:63
static void setHideOffset(bool flag)
static void setEvalErrorLoggingMode(ErrorLoggingMode m)
Set evaluation error logging mode.
RooArgList is a container object that can hold multiple RooAbsArg objects.
Definition RooArgList.h:22
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:24
Object to represent discrete states.
Definition RooCategory.h:28
Variable that can be changed from the outside.
Definition RooRealVar.h:37
void setVal(double value) override
Set value of variable to 'value'.
static void callgrind_zero()
Utility function to trigger zeroing of callgrind counters.
Definition RooTrace.cxx:352
virtual int GetPid()
Get process id.
Definition TSystem.cxx:720
RooCmdArg Verbose(bool flag=true)
double nll(double pdf, double weight, int binnedL, int doBinOffset)
Definition MathFuncs.h:452
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
Definition CodegenImpl.h:72
void evaluate(typename Architecture_t::Tensor_t &A, EActivationFunction f)
Apply the given activation function to each value in the given tensor A.
Definition Functions.h:98
void initialize(typename Architecture_t::Matrix_t &A, EInitialization m)
Definition Functions.h:282
void Initialize(Bool_t useTMVAStyle=kTRUE)
Definition tmvaglob.cxx:176