ROOT  6.06/08
Reference Guide
RooRealMPFE.cxx
Go to the documentation of this file.
1 /*****************************************************************************
2  * Project: RooFit *
3  * Package: RooFitCore *
4  * @(#)root/roofitcore:$Id$
5  * Authors: *
6  * WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu *
7  * DK, David Kirkby, UC Irvine, dkirkby@uci.edu *
8  * *
9  * Copyright (c) 2000-2005, Regents of the University of California *
10  * and Stanford University. All rights reserved. *
11  * *
12  * Redistribution and use in source and binary forms, *
13  * with or without modification, are permitted according to the terms *
14  * listed in LICENSE (http://roofit.sourceforge.net/license.txt) *
15  *****************************************************************************/
16 
17 //////////////////////////////////////////////////////////////////////////////
18 //
19 // BEGIN_HTML
20 // RooRealMPFE is the multi-processor front-end for parallel calculation
21 // of RooAbsReal objects. Each RooRealMPFE forks a process that calculates
22 // the value of the proxies RooAbsReal object. The (re)calculation of
23 // the proxied object is started asynchronously with the calculate() option.
24 // A subsequent call to getVal() will return the calculated value when available
25 // If the calculation is still in progress when getVal() is called it blocks
26 // the calling process until the calculation is done. The forked calculation process
27 // is terminated when the front-end object is deleted
28 // Simple use demonstration
29 //
30 // <pre>
31 // RooAbsReal* slowFunc ;
32 //
33 // Double_t val = slowFunc->getVal() // Evaluate slowFunc in current process
34 //
35 // RooRealMPFE mpfe("mpfe","frontend to slowFunc",*slowFunc) ;
36 // mpfe.calculate() ; // Start calculation of slow-func in remote process
37 // // .. do other stuff here ..
38 // Double_t val = mpfe.getVal() // Wait for remote calculation to finish and retrieve value
39 // </pre>
40 //
41 // END_HTML
42 //
43 
44 #include "Riostream.h"
45 #include "RooFit.h"
46 
47 #ifndef _WIN32
48 #include "BidirMMapPipe.h"
49 #endif
50 
51 #include <cstdlib>
52 #include <sstream>
53 #include "RooRealMPFE.h"
54 #include "RooArgSet.h"
55 #include "RooAbsCategory.h"
56 #include "RooRealVar.h"
57 #include "RooCategory.h"
58 #include "RooMPSentinel.h"
59 #include "RooMsgService.h"
60 #include "RooNLLVar.h"
61 #include "RooTrace.h"
62 
63 #include "TSystem.h"
64 
66 
67 using namespace std;
68 using namespace RooFit;
69 
71  ;
72 
73 
74 ////////////////////////////////////////////////////////////////////////////////
75 /// Construct front-end object for object 'arg' whose evaluation will be calculated
76 /// asynchronously in a separate process. If calcInline is true the value of 'arg'
77 /// is calculate synchronously in the current process.
78 
79 RooRealMPFE::RooRealMPFE(const char *name, const char *title, RooAbsReal& arg, Bool_t calcInline) :
80  RooAbsReal(name,title),
81  _state(Initialize),
82  _arg("arg","arg",this,arg),
83  _vars("vars","vars",this),
84  _calcInProgress(kFALSE),
85  _verboseClient(kFALSE),
86  _verboseServer(kFALSE),
87  _inlineMode(calcInline),
88  _remoteEvalErrorLoggingState(RooAbsReal::PrintErrors),
89  _pipe(0),
90  _updateMaster(0),
91  _retrieveDispatched(kFALSE), _evalCarry(0.)
92 {
93 #ifdef _WIN32
95 #endif
96  initVars() ;
97  _sentinel.add(*this) ;
98 
99 }
100 
101 
102 
103 ////////////////////////////////////////////////////////////////////////////////
104 /// Copy constructor. Initializes in clean state so that upon eval
105 /// this instance will create its own server processes
106 
107 RooRealMPFE::RooRealMPFE(const RooRealMPFE& other, const char* name) :
108  RooAbsReal(other, name),
110  _arg("arg",this,other._arg),
111  _vars("vars",this,other._vars),
115  _inlineMode(other._inlineMode),
116  _forceCalc(other._forceCalc),
118  _pipe(0),
119  _updateMaster(0),
121 {
122  initVars() ;
123  _sentinel.add(*this) ;
124 }
125 
126 
127 
128 ////////////////////////////////////////////////////////////////////////////////
129 /// Destructor
130 
132 {
133  if (_state==Client) standby();
134  _sentinel.remove(*this);
135 }
136 
137 
138 
139 ////////////////////////////////////////////////////////////////////////////////
140 /// Initialize list of variables of front-end argument 'arg'
141 
143 {
144  // Empty current lists
145  _vars.removeAll() ;
146  _saveVars.removeAll() ;
147 
148  // Retrieve non-constant parameters
149  RooArgSet* vars = _arg.arg().getParameters(RooArgSet()) ;
150  //RooArgSet* ncVars = (RooArgSet*) vars->selectByAttrib("Constant",kFALSE) ;
151  RooArgList varList(*vars) ;
152 
153  // Save in lists
154  _vars.add(varList) ;
155  _saveVars.addClone(varList) ;
156  _valueChanged.resize(_vars.getSize()) ;
157  _constChanged.resize(_vars.getSize()) ;
158 
159  // Force next calculation
160  _forceCalc = kTRUE ;
161 
162  delete vars ;
163  //delete ncVars ;
164 }
165 
167 {
168  if (_inlineMode) {
169  RooAbsTestStatistic* tmp = dynamic_cast<RooAbsTestStatistic*>(_arg.absArg());
170  if (tmp) return tmp->getCarry();
171  else return 0.;
172  } else {
173  return _evalCarry;
174  }
175 }
176 
177 ////////////////////////////////////////////////////////////////////////////////
178 /// Initialize the remote process and message passing
179 /// pipes between current process and remote process
180 
182 {
183  // Trivial case: Inline mode
184  if (_inlineMode) {
185  _state = Inline ;
186  return ;
187  }
188 
189 #ifndef _WIN32
190  // Clear eval error log prior to forking
191  // to avoid confusions...
193  // Fork server process and setup IPC
194  _pipe = new BidirMMapPipe();
195 
196  if (_pipe->isChild()) {
197  // Start server loop
199  _state = Server ;
200  serverLoop();
201 
202  // Kill server at end of service
203  if (_verboseServer) ccoutD(Minimization) << "RooRealMPFE::initialize(" <<
204  GetName() << ") server process terminating" << endl ;
205 
206  delete _arg.absArg();
207  delete _pipe;
208  _exit(0) ;
209  } else {
210  // Client process - fork successul
211  if (_verboseClient) ccoutD(Minimization) << "RooRealMPFE::initialize(" <<
212  GetName() << ") successfully forked server process " <<
213  _pipe->pidOtherEnd() << endl ;
214  _state = Client ;
216  }
217 #endif // _WIN32
218 }
219 
220 
221 
222 ////////////////////////////////////////////////////////////////////////////////
223 /// Server loop of remote processes. This function will return
224 /// only when an incoming TERMINATE message is received.
225 
227 {
228 #ifndef _WIN32
229  int msg ;
230 
231  Int_t idx, index, numErrors ;
232  Double_t value ;
233  Bool_t isConst ;
234 
236 
237  while(*_pipe && !_pipe->eof()) {
238  *_pipe >> msg;
239  if (Terminate == msg) {
240  if (_verboseServer) cout << "RooRealMPFE::serverLoop(" << GetName()
241  << ") IPC fromClient> Terminate" << endl;
242  // send terminate acknowledged to client
243  *_pipe << msg << BidirMMapPipe::flush;
244  break;
245  }
246 
247  switch (msg) {
248  case SendReal:
249  {
250  *_pipe >> idx >> value >> isConst;
251  if (_verboseServer) cout << "RooRealMPFE::serverLoop(" << GetName()
252  << ") IPC fromClient> SendReal [" << idx << "]=" << value << endl ;
253  RooRealVar* rvar = (RooRealVar*)_vars.at(idx) ;
254  rvar->setVal(value) ;
255  if (rvar->isConstant() != isConst) {
256  rvar->setConstant(isConst) ;
257  }
258  }
259  break ;
260 
261  case SendCat:
262  {
263  *_pipe >> idx >> index;
264  if (_verboseServer) cout << "RooRealMPFE::serverLoop(" << GetName()
265  << ") IPC fromClient> SendCat [" << idx << "]=" << index << endl ;
266  ((RooCategory*)_vars.at(idx))->setIndex(index) ;
267  }
268  break ;
269 
270  case Calculate:
271  if (_verboseServer) cout << "RooRealMPFE::serverLoop(" << GetName()
272  << ") IPC fromClient> Calculate" << endl ;
273  _value = _arg ;
274  break ;
275 
276  case CalculateNoOffset:
277  if (_verboseServer) cout << "RooRealMPFE::serverLoop(" << GetName()
278  << ") IPC fromClient> Calculate" << endl ;
279 
281  _value = _arg ;
283  break ;
284 
285  case Retrieve:
286  {
287  if (_verboseServer) cout << "RooRealMPFE::serverLoop(" << GetName()
288  << ") IPC fromClient> Retrieve" << endl ;
289  msg = ReturnValue;
290  numErrors = numEvalErrors();
291  *_pipe << msg << _value << getCarry() << numErrors;
292 
293  if (_verboseServer) cout << "RooRealMPFE::serverLoop(" << GetName()
294  << ") IPC toClient> ReturnValue " << _value << " NumError " << numErrors << endl ;
295 
296  if (numErrors) {
297  // Loop over errors
298  std::string objidstr;
299  {
300  ostringstream oss2;
301  // Format string with object identity as this cannot be evaluated on the other side
302  oss2 << "PID" << gSystem->GetPid() << "/";
304  objidstr = oss2.str();
305  }
306  std::map<const RooAbsArg*,pair<string,list<EvalError> > >::const_iterator iter = evalErrorIter();
307  const RooAbsArg* ptr = 0;
308  for (int i = 0; i < numEvalErrorItems(); ++i) {
309  list<EvalError>::const_iterator iter2 = iter->second.second.begin();
310  for (; iter->second.second.end() != iter2; ++iter2) {
311  ptr = iter->first;
312  *_pipe << ptr << iter2->_msg << iter2->_srvval << objidstr;
313  if (_verboseServer) cout << "RooRealMPFE::serverLoop(" << GetName()
314  << ") IPC toClient> sending error log Arg " << iter->first << " Msg " << iter2->_msg << endl ;
315  }
316  }
317  // let other end know that we're done with the list of errors
318  ptr = 0;
319  *_pipe << ptr;
320  // Clear error list on local side
322  }
324  }
325  break;
326 
327  case ConstOpt:
328  {
329  Bool_t doTrack ;
330  int code;
331  *_pipe >> code >> doTrack;
332  if (_verboseServer) cout << "RooRealMPFE::serverLoop(" << GetName()
333  << ") IPC fromClient> ConstOpt " << code << " doTrack = " << (doTrack?"T":"F") << endl ;
334  ((RooAbsReal&)_arg.arg()).constOptimizeTestStatistic(static_cast<RooAbsArg::ConstOpCode>(code),doTrack) ;
335  break ;
336  }
337 
338  case Verbose:
339  {
340  Bool_t flag ;
341  *_pipe >> flag;
342  if (_verboseServer) cout << "RooRealMPFE::serverLoop(" << GetName()
343  << ") IPC fromClient> Verbose " << (flag?1:0) << endl ;
344  _verboseServer = flag ;
345  }
346  break ;
347 
348 
349  case ApplyNLLW2:
350  {
351  Bool_t flag ;
352  *_pipe >> flag;
353  if (_verboseServer) cout << "RooRealMPFE::serverLoop(" << GetName()
354  << ") IPC fromClient> ApplyNLLW2 " << (flag?1:0) << endl ;
355 
356  // Do application of weight-squared here
357  doApplyNLLW2(flag) ;
358  }
359  break ;
360 
361  case EnableOffset:
362  {
363  Bool_t flag ;
364  *_pipe >> flag;
365  if (_verboseServer) cout << "RooRealMPFE::serverLoop(" << GetName()
366  << ") IPC fromClient> EnableOffset " << (flag?1:0) << endl ;
367 
368  // Enable likelihoof offsetting here
369  ((RooAbsReal&)_arg.arg()).enableOffsetting(flag) ;
370  }
371  break ;
372 
373  case LogEvalError:
374  {
375  int iflag2;
376  *_pipe >> iflag2;
377  RooAbsReal::ErrorLoggingMode flag2 = static_cast<RooAbsReal::ErrorLoggingMode>(iflag2);
379  if (_verboseServer) cout << "RooRealMPFE::serverLoop(" << GetName()
380  << ") IPC fromClient> LogEvalError flag = " << flag2 << endl ;
381  }
382  break ;
383 
384 
385  default:
386  if (_verboseServer) cout << "RooRealMPFE::serverLoop(" << GetName()
387  << ") IPC fromClient> Unknown message (code = " << msg << ")" << endl ;
388  break ;
389  }
390  }
391 
392 #endif // _WIN32
393 }
394 
395 
396 
397 ////////////////////////////////////////////////////////////////////////////////
398 /// Client-side function that instructs server process to start
399 /// asynchronuous (re)calculation of function value. This function
400 /// returns immediately. The calculated value can be retrieved
401 /// using getVal()
402 
404 {
405 
406  // Start asynchronous calculation of arg value
407  if (_state==Initialize) {
408  // cout << "RooRealMPFE::calculate(" << GetName() << ") initializing" << endl ;
409  const_cast<RooRealMPFE*>(this)->initialize() ;
410  }
411 
412  // Inline mode -- Calculate value now
413  if (_state==Inline) {
414  // cout << "RooRealMPFE::calculate(" << GetName() << ") performing Inline calculation NOW" << endl ;
415  _value = _arg ;
416  clearValueDirty() ;
417  }
418 
419 #ifndef _WIN32
420  // Compare current value of variables with saved values and send changes to server
421  if (_state==Client) {
422  // cout << "RooRealMPFE::calculate(" << GetName() << ") state is Client trigger remote calculation" << endl ;
423  Int_t i(0) ;
424  RooFIter viter = _vars.fwdIterator() ;
425  RooFIter siter = _saveVars.fwdIterator() ;
426 
427  //for (i=0 ; i<_vars.getSize() ; i++) {
428  RooAbsArg *var, *saveVar ;
429  while((var = viter.next())) {
430  saveVar = siter.next() ;
431 
432  //Bool_t valChanged = !(*var==*saveVar) ;
433  Bool_t valChanged,constChanged ;
434  if (!_updateMaster) {
435  valChanged = !var->isIdentical(*saveVar,kTRUE) ;
436  constChanged = (var->isConstant() != saveVar->isConstant()) ;
437  _valueChanged[i] = valChanged ;
438  _constChanged[i] = constChanged ;
439  } else {
440  valChanged = _updateMaster->_valueChanged[i] ;
441  constChanged = _updateMaster->_constChanged[i] ;
442  }
443 
444  if ( valChanged || constChanged || _forceCalc) {
445  //cout << "RooRealMPFE::calculate(" << GetName() << " variable " << var->GetName() << " changed " << endl ;
446  if (_verboseClient) cout << "RooRealMPFE::calculate(" << GetName()
447  << ") variable " << _vars.at(i)->GetName() << " changed" << endl ;
448  if (constChanged) {
449  ((RooRealVar*)saveVar)->setConstant(var->isConstant()) ;
450  }
451  saveVar->copyCache(var) ;
452 
453  // send message to server
454  if (dynamic_cast<RooAbsReal*>(var)) {
455  int msg = SendReal ;
456  Double_t val = ((RooAbsReal*)var)->getVal() ;
457  Bool_t isC = var->isConstant() ;
458  *_pipe << msg << i << val << isC;
459 
460  if (_verboseServer) cout << "RooRealMPFE::calculate(" << GetName()
461  << ") IPC toServer> SendReal [" << i << "]=" << val << (isC?" (Constant)":"") << endl ;
462  } else if (dynamic_cast<RooAbsCategory*>(var)) {
463  int msg = SendCat ;
464  UInt_t idx = ((RooAbsCategory*)var)->getIndex() ;
465  *_pipe << msg << i << idx;
466  if (_verboseServer) cout << "RooRealMPFE::calculate(" << GetName()
467  << ") IPC toServer> SendCat [" << i << "]=" << idx << endl ;
468  }
469  }
470  i++ ;
471  }
472 
473  int msg = hideOffset() ? Calculate : CalculateNoOffset;
474  *_pipe << msg;
475  if (_verboseServer) cout << "RooRealMPFE::calculate(" << GetName()
476  << ") IPC toServer> Calculate " << endl ;
477 
478  // Clear dirty state and mark that calculation request was dispatched
479  clearValueDirty() ;
481  _forceCalc = kFALSE ;
482 
483  msg = Retrieve ;
484  *_pipe << msg << BidirMMapPipe::flush;
485  if (_verboseServer) cout << "RooRealMPFE::evaluate(" << GetName()
486  << ") IPC toServer> Retrieve " << endl ;
488 
489  } else if (_state!=Inline) {
490  cout << "RooRealMPFE::calculate(" << GetName()
491  << ") ERROR not in Client or Inline mode" << endl ;
492  }
493 
494 
495 #endif // _WIN32
496 }
497 
498 
499 
500 
501 ////////////////////////////////////////////////////////////////////////////////
502 /// If value needs recalculation and calculation has not beed started
503 /// with a call to calculate() start it now. This function blocks
504 /// until remote process has finished calculation and returns
505 /// remote value
506 
507 Double_t RooRealMPFE::getValV(const RooArgSet* /*nset*/) const
508 {
509 
510  if (isValueDirty()) {
511  // Cache is dirty, no calculation has been started yet
512  //cout << "RooRealMPFE::getValF(" << GetName() << ") cache is dirty, caling calculate and evaluate" << endl ;
513  calculate() ;
514  _value = evaluate() ;
515  } else if (_calcInProgress) {
516  //cout << "RooRealMPFE::getValF(" << GetName() << ") calculation in progress, calling evaluate" << endl ;
517  // Cache is clean and calculation is in progress
518  _value = evaluate() ;
519  } else {
520  //cout << "RooRealMPFE::getValF(" << GetName() << ") cache is clean, doing nothing" << endl ;
521  // Cache is clean and calculated value is in cache
522  }
523 
524 // cout << "RooRealMPFE::getValV(" << GetName() << ") value = " << Form("%5.10f",_value) << endl ;
525  return _value ;
526 }
527 
528 
529 
530 ////////////////////////////////////////////////////////////////////////////////
531 /// Send message to server process to retrieve output value
532 /// If error were logged use logEvalError() on remote side
533 /// transfer those errors to the local eval error queue.
534 
536 {
537  // Retrieve value of arg
538  Double_t return_value = 0;
539  if (_state==Inline) {
540  return_value = _arg ;
541  } else if (_state==Client) {
542 #ifndef _WIN32
543  bool needflush = false;
544  int msg;
545  Double_t value;
546 
547  // If current error loggin state is not the same as remote state
548  // update the remote state
550  msg = LogEvalError ;
552  *_pipe << msg << flag;
553  needflush = true;
555  }
556 
557  if (!_retrieveDispatched) {
558  msg = Retrieve ;
559  *_pipe << msg;
560  needflush = true;
561  if (_verboseServer) cout << "RooRealMPFE::evaluate(" << GetName()
562  << ") IPC toServer> Retrieve " << endl ;
563  }
564  if (needflush) *_pipe << BidirMMapPipe::flush;
566 
567 
568  Int_t numError;
569 
570  *_pipe >> msg >> value >> _evalCarry >> numError;
571 
572  if (msg!=ReturnValue) {
573  cout << "RooRealMPFE::evaluate(" << GetName()
574  << ") ERROR: unexpected message from server process: " << msg << endl ;
575  return 0 ;
576  }
577  if (_verboseServer) cout << "RooRealMPFE::evaluate(" << GetName()
578  << ") IPC fromServer> ReturnValue " << value << endl ;
579 
580  if (_verboseServer) cout << "RooRealMPFE::evaluate(" << GetName()
581  << ") IPC fromServer> NumErrors " << numError << endl ;
582  if (numError) {
583  // Retrieve remote errors and feed into local error queue
584  char *msgbuf1 = 0, *msgbuf2 = 0, *msgbuf3 = 0;
585  RooAbsArg *ptr = 0;
586  while (true) {
587  *_pipe >> ptr;
588  if (!ptr) break;
589  *_pipe >> msgbuf1 >> msgbuf2 >> msgbuf3;
590  if (_verboseServer) cout << "RooRealMPFE::evaluate(" << GetName()
591  << ") IPC fromServer> retrieving error log Arg " << ptr << " Msg " << msgbuf1 << endl ;
592 
593  logEvalError(reinterpret_cast<RooAbsReal*>(ptr),msgbuf3,msgbuf1,msgbuf2) ;
594  }
595  std::free(msgbuf1);
596  std::free(msgbuf2);
597  std::free(msgbuf3);
598  }
599 
600  // Mark end of calculation in progress
602  return_value = value ;
603 #endif // _WIN32
604  }
605 
606  return return_value;
607 }
608 
609 
610 
611 ////////////////////////////////////////////////////////////////////////////////
612 /// Terminate remote server process and return front-end class
613 /// to standby mode. Calls to calculate() or evaluate() after
614 /// this call will automatically recreated the server process.
615 
617 {
618 #ifndef _WIN32
619  if (_state==Client) {
620  if (_pipe->good()) {
621  // Terminate server process ;
622  if (_verboseServer) cout << "RooRealMPFE::standby(" << GetName()
623  << ") IPC toServer> Terminate " << endl;
624  int msg = Terminate;
625  *_pipe << msg << BidirMMapPipe::flush;
626  // read handshake
627  msg = 0;
628  *_pipe >> msg;
629  if (Terminate != msg || 0 != _pipe->close()) {
630  std::cerr << "In " << __func__ << "(" << __FILE__ ", " << __LINE__ <<
631  "): Server shutdown failed." << std::endl;
632  }
633  } else {
634  if (_verboseServer) {
635  std::cerr << "In " << __func__ << "(" << __FILE__ ", " <<
636  __LINE__ << "): Pipe has already shut down, not sending "
637  "Terminate to server." << std::endl;
638  }
639  }
640  // Close pipes
641  delete _pipe;
642  _pipe = 0;
643 
644  // Revert to initialize state
645  _state = Initialize;
646  }
647 #endif // _WIN32
648 }
649 
650 
651 
652 ////////////////////////////////////////////////////////////////////////////////
653 /// Intercept call to optimize constant term in test statistics
654 /// and forward it to object on server side.
655 
657 {
658 #ifndef _WIN32
659  if (_state==Client) {
660 
661  int msg = ConstOpt ;
662  int op = opcode;
663  *_pipe << msg << op << doAlsoTracking;
664  if (_verboseServer) cout << "RooRealMPFE::constOptimize(" << GetName()
665  << ") IPC toServer> ConstOpt " << opcode << endl ;
666 
667  initVars() ;
668  }
669 #endif // _WIN32
670 
671  if (_state==Inline) {
672  ((RooAbsReal&)_arg.arg()).constOptimizeTestStatistic(opcode,doAlsoTracking) ;
673  }
674 }
675 
676 
677 
678 ////////////////////////////////////////////////////////////////////////////////
679 /// Control verbose messaging related to inter process communication
680 /// on both client and server side
681 
682 void RooRealMPFE::setVerbose(Bool_t clientFlag, Bool_t serverFlag)
683 {
684 #ifndef _WIN32
685  if (_state==Client) {
686  int msg = Verbose ;
687  *_pipe << msg << serverFlag;
688  if (_verboseServer) cout << "RooRealMPFE::setVerbose(" << GetName()
689  << ") IPC toServer> Verbose " << (serverFlag?1:0) << endl ;
690  }
691 #endif // _WIN32
692  _verboseClient = clientFlag ; _verboseServer = serverFlag ;
693 }
694 
695 
696 ////////////////////////////////////////////////////////////////////////////////
697 /// Control verbose messaging related to inter process communication
698 /// on both client and server side
699 
701 {
702 #ifndef _WIN32
703  if (_state==Client) {
704  int msg = ApplyNLLW2 ;
705  *_pipe << msg << flag;
706  if (_verboseServer) cout << "RooRealMPFE::applyNLLWeightSquared(" << GetName()
707  << ") IPC toServer> ApplyNLLW2 " << (flag?1:0) << endl ;
708  }
709 #endif // _WIN32
710  doApplyNLLW2(flag) ;
711 }
712 
713 
714 ////////////////////////////////////////////////////////////////////////////////
715 
717 {
718  RooNLLVar* nll = dynamic_cast<RooNLLVar*>(_arg.absArg()) ;
719  if (nll) {
720  nll->applyWeightSquared(flag) ;
721  }
722 }
723 
724 
725 ////////////////////////////////////////////////////////////////////////////////
726 /// Control verbose messaging related to inter process communication
727 /// on both client and server side
728 
730 {
731 #ifndef _WIN32
732  if (_state==Client) {
733  int msg = EnableOffset ;
734  *_pipe << msg << flag;
735  if (_verboseServer) cout << "RooRealMPFE::enableOffsetting(" << GetName()
736  << ") IPC toServer> EnableOffset " << (flag?1:0) << endl ;
737  }
738 #endif // _WIN32
739  ((RooAbsReal&)_arg.arg()).enableOffsetting(flag) ;
740 }
741 
742 
743 
void clearValueDirty() const
Definition: RooAbsArg.h:447
void calculate() const
Client-side function that instructs server process to start asynchronuous (re)calculation of function...
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:51
virtual int GetPid()
Get process id.
Definition: TSystem.cxx:711
virtual void printStream(std::ostream &os, Int_t contents, StyleOption style, TString indent="") const
Print description of object on ostream, printing contents set by contents integer, which is interpreted as an OR of &#39;enum ContentsOptions&#39; values and in the style given by &#39;enum StyleOption&#39;.
void initVars()
Initialize list of variables of front-end argument &#39;arg&#39;.
static EvalErrorIter evalErrorIter()
Definition: RooAbsReal.cxx:279
virtual RooAbsArg * addClone(const RooAbsArg &var, Bool_t silent=kFALSE)
Add a clone of the specified argument to list.
header file for BidirMMapPipe, a class which forks off a child process and serves as communications c...
Double_t _evalCarry
Definition: RooRealMPFE.h:86
State _state
Definition: RooRealMPFE.h:59
Bool_t _verboseServer
Definition: RooRealMPFE.h:75
static void callgrind_zero()
Utility function to trigger zeroing of callgrind counters.
Definition: RooTrace.cxx:297
static void clearEvalErrorLog()
Clear the stack of evaluation error messages.
static Int_t numEvalErrorItems()
Definition: RooAbsReal.cxx:271
void initialize()
Initialize the remote process and message passing pipes between current process and remote process...
RooRealMPFE * _updateMaster
Flags if variable needs update on server-side.
Definition: RooRealMPFE.h:84
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kFALSE
Definition: Rtypes.h:92
void applyNLLWeightSquared(Bool_t flag)
Control verbose messaging related to inter process communication on both client and server side...
STL namespace.
static void setHideOffset(Bool_t flag)
Definition: RooAbsReal.cxx:118
RooRealProxy _arg
Definition: RooRealMPFE.h:70
Bool_t _verboseClient
Definition: RooRealMPFE.h:74
void applyWeightSquared(Bool_t flag)
Definition: RooNLLVar.cxx:215
Bool_t _calcInProgress
Definition: RooRealMPFE.h:73
Bool_t _retrieveDispatched
Update master.
Definition: RooRealMPFE.h:85
static void setEvalErrorLoggingMode(ErrorLoggingMode m)
Set evaluation error logging mode.
Vc_ALWAYS_INLINE void free(T *p)
Frees memory that was allocated with Vc::malloc.
Definition: memory.h:94
std::vector< Bool_t > _constChanged
Flags if variable needs update on server-side.
Definition: RooRealMPFE.h:83
void flush()
flush buffers with unwritten data
virtual void removeAll()
Remove all arguments from our set, deleting them if we own them.
virtual ~RooRealMPFE()
Destructor.
friend class RooArgSet
Definition: RooAbsArg.h:469
void serverLoop()
Server loop of remote processes.
virtual Bool_t isIdentical(const RooAbsArg &other, Bool_t assumeSameType=kFALSE)=0
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Reimplementation of standard RooArgList::add()
RooListProxy _vars
Definition: RooRealMPFE.h:71
virtual Double_t getCarry() const
virtual void setVal(Double_t value)
Set value of variable to &#39;value&#39;.
Definition: RooRealVar.cxx:202
virtual Double_t getCarry() const
Int_t getSize() const
void setVerbose(Bool_t clientFlag=kTRUE, Bool_t serverFlag=kTRUE)
Control verbose messaging related to inter process communication on both client and server side...
RooRealMPFE(const char *name, const char *title, RooAbsReal &arg, Bool_t calcInline=kFALSE)
Construct front-end object for object &#39;arg&#39; whose evaluation will be calculated asynchronously in a s...
Definition: RooRealMPFE.cxx:79
void Initialize(Bool_t useTMVAStyle=kTRUE)
Definition: tmvaglob.cxx:176
R__EXTERN TSystem * gSystem
Definition: TSystem.h:549
static Int_t numEvalErrors()
Return the number of logged evaluation errors since the last clearing.
RooAbsArg * at(Int_t idx) const
Definition: RooArgList.h:84
void setConstant(Bool_t value=kTRUE)
void logEvalError(const char *message, const char *serverValueString=0) const
Log evaluation error message.
virtual void copyCache(const RooAbsArg *source, Bool_t valueOnly=kFALSE, Bool_t setValDirty=kTRUE)=0
RooArgList _saveVars
Definition: RooRealMPFE.h:72
unsigned int UInt_t
Definition: RtypesCore.h:42
void standby()
Terminate remote server process and return front-end class to standby mode.
RooAbsArg * absArg() const
Definition: RooArgProxy.h:37
BidirMMapPipe creates a bidirectional channel between the current process and a child it forks...
static Bool_t hideOffset()
Definition: RooAbsReal.cxx:119
std::vector< Bool_t > _valueChanged
connection to child
Definition: RooRealMPFE.h:82
RooAbsArg * next()
void enableOffsetting(Bool_t flag)
Control verbose messaging related to inter process communication on both client and server side...
void remove(RooRealMPFE &mpfe)
Remove given multi-processor front-end object from the sentinel.
#define ClassImp(name)
Definition: Rtypes.h:279
double Double_t
Definition: RtypesCore.h:55
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition: RooAbsReal.h:53
RooFIter fwdIterator() const
RooArgSet * getParameters(const RooAbsData *data, Bool_t stripDisconnected=kTRUE) const
Create a list of leaf nodes in the arg tree starting with ourself as top node that don&#39;t match any of...
Definition: RooAbsArg.cxx:559
void add(RooRealMPFE &mpfe)
Register given multi-processor front-end object with the sentinel.
static ErrorLoggingMode evalErrorLoggingMode()
Return current evaluation error logging mode.
RooAbsReal::ErrorLoggingMode _remoteEvalErrorLoggingState
Definition: RooRealMPFE.h:78
#define name(a, b)
Definition: linkTestLib0.cpp:5
Bool_t isValueDirty() const
Definition: RooAbsArg.h:336
Double_t _value
Definition: RooAbsReal.h:389
virtual Double_t evaluate() const
Send message to server process to retrieve output value If error were logged use logEvalError() on re...
virtual void removeAll()
Reimplementation of standard RooArgList::removeAll()
Bool_t _forceCalc
Definition: RooRealMPFE.h:77
virtual void constOptimizeTestStatistic(ConstOpCode opcode, Bool_t doAlsoTracking=kTRUE)
Intercept call to optimize constant term in test statistics and forward it to object on server side...
void doApplyNLLW2(Bool_t flag)
RooAbsArg is the common abstract base class for objects that represent a value (of arbitrary type) an...
Definition: RooAbsArg.h:66
const RooAbsReal & arg() const
Definition: RooRealProxy.h:43
const Bool_t kTRUE
Definition: Rtypes.h:91
#define ccoutD(a)
Definition: RooMsgService.h:38
float value
Definition: math.cpp:443
return
Definition: HLFactory.cxx:514
Bool_t isConstant() const
Definition: RooAbsArg.h:266
RooFit::BidirMMapPipe * _pipe
Definition: RooRealMPFE.h:80
Bool_t _inlineMode
Definition: RooRealMPFE.h:76
virtual Double_t getValV(const RooArgSet *nset=0) const
If value needs recalculation and calculation has not beed started with a call to calculate() start it...
static RooMPSentinel _sentinel
Definition: RooRealMPFE.h:88