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