Fix https://sft.its.cern.ch/jira/browse/ROOT-5413
use forward declaration instead of include
Added ${PYTHIA6_DIR} from command line as a location for Pythia6
Fix documentation about use of Minos in RooAbsPdf::fitTo,   see #ROOT-5423
follow usual unix return code convention: 0 return from main means all tests good, return value > 0 counts number of failed tests (helpful as part of a git bisect script)

Signed-off-by: Wouter Verkerke <verkerke@nikhef.nl>
deprecate RooComplex class, adapt rest of RooFit code base to use std::complex instead, clean up RooMath interface while I'm at it

The old RooFit functions all had "error function" somewhere in their
name, which was incorrect. They all calculated w(z)=exp(-z^2)*erfc(-i*z).
The new functions all have different names. If you used to call one of
the old functions in your code, the new functions you want to call are
either faddeeva_fast (which correspond to the fast interpolated version
in the old RooFit code), or faddeeva. The new code also implements the
(complementary) error function erf(z) (erfc(z)) for complex arguments z.

Since RooComplex is never persisted anywhere in RooFit, the class can be
dropped in a future release. New code should use std::complex and the
faddeeva, faddeeva_fast, erf, erf_fast, erfc and erfc_fast routines in
RooMath directly. The old routines in RooMath and the RooComplex
constructor print deprecation warnings.

The deprecation warnings for RooComplex and old style RooMath calls are
designed for maximum annoyance (every use of a deprecated function
prints a warning to stdout, so users change their code), but there is an
upper bound to cause minimum offence (after 4096 warning messages, the
printout of warning messages stops, so log files will not fill up disks,
and jobs can still be run).

Signed-off-by: Wouter Verkerke <verkerke@nikhef.nl>
Use continued fraction approximation in Faddeeva function for large |z|, as it's slightly faster, and just as accurate in that regime

Signed-off-by: Wouter Verkerke <verkerke@nikhef.nl>
patch from Thomas Bird <thomas.bird@cern.ch> and Rob Lambert <Rob.Lambert.cern.ch>: allows to project a region and produce an asymmetry plot of it

Signed-off-by: Wouter Verkerke <verkerke@nikhef.nl>
patch from Thomas Bird <thomas.bird@cern.ch>, Rob Lambert <Rob.Lambert@cern.ch>, with some slight robustness improvements and better error checking by Manuel Schiller <manuel.schiller@nikhef.nl>: implement analytical integrals for Chebychev polynomials

Signed-off-by: Wouter Verkerke <verkerke@nikhef.nl>
patch by Thomas Bird <thomas.bird@cern.ch> and Rob Lambert <Rob.Lambert@cern.ch>: have "master process" delegate all compute jobs to children in multi-CPU mode (advantage is that the master process can in theory keep children busy without blocking on some long-running computation itself)

Signed-off-by: Wouter Verkerke <verkerke@nikhef.nl>
some code cleanups, mostly to guard against future typos (if (0 == i) vs if (i = 0)) and to have the nice version of for loops (variable declared only inside for loop, ++i vs i++)

Signed-off-by: Wouter Verkerke <verkerke@nikhef.nl>
patch modified from solution provided by Sascha Stahl <sascha.stahl@cern.ch>, fixes JIRA ROOT-5229: fix RooFit's treatment of weighted datasets in conjunction with simultaneous PDFs

Signed-off-by: Wouter Verkerke <verkerke@nikhef.nl>
new class BidirMMapPipe, a bidirectional communications channel between a parent process and its child, which buffers communications intenally, and tries to minimise the time spent in the OS (except when you want to block there)

This class offers an interface very similar to the familiar read/write
syscalls, has a flush operation to flush internal buffers to the other
end, and a poll method which allows a parent process with several open
pipes to block until an event occurs on any of those pipes (events would
be pipe becomes readable, writable, is closed by the other end),
allowing for fairly efficient I/O multiplexing on those pipes.

In addition to that, it overloads the familiar operator<< and operator>>
methods to allow binary I/O over the channel for the basic data types
(char, short, int, long, long long and their unsigned counterparts,
double and float), C-style zero-terminated strings and std::string, and
raw pointers (which are sent as addresses).

Signed-off-by: Wouter Verkerke <verkerke@nikhef.nl>
Have EvalError contain strings, not fixed sized arrays (which are a waste of space)

This patch is in preparation for the RooRealMPFE rewrite using
BidirMMapPipe. It will simplify issues with fixed size buffers in the
IPC there considerably. This has no impact on the persisted format of
classes since EvalErrors are not persisted as far as I can tell.

Signed-off-by: Wouter Verkerke <verkerke@nikhef.nl>
rewrite RooRealMPFE to use BidirMMapPipe, take care to make the communications protocol as efficient as possible (as few trips through the pipe as can be achieved)

To this end, the only commands in the parent which flush the buffers to
the other end are the "calculate" command which causes the child to
start the calculation, and the "retrieve result" command which causes
the child to send the result of the calculation. All other commands are
queued in the parent until the "calculate" command is sent, and the
child gets them when all buffers are flushed after the "calculate"
command has been sent as one huge string of requests. In the child, the
only reply which flushes the internal buffers is the reply to "retrieve
result" which sends the result and any evaluation errors that may have
occurred in the child in one go.

The advantage of this mode of operation is that both ends may block in
the OS while trying to read from the pipe until there is a significant
amount of work to be done, resulting in less latency because the OS only
has the schedule the end that becomes runnable once instead of
scheduling it every time the other end sends a tiny request like a
parameter change notification, for example. This makes it explicit that
these "little" requests are nothing more than options to the one
CPU-intensive request which we really want the child process to perform:
the evaluation of the PDF over a certain subset of events.

[FIXME:] One more thought on persistency: This class should be rewritten
somewhat, because persistency is tricky: you cannot persist the child
processes along with the class in the ROOT file and recreate them on the
machine which reads the RooRealMPFE class. That means any reference to
child processes, pids, file descriptors and other communication
structures are meaningless once the class is read back on the target
machine. I can see two ways out: Either we forbid persisting this class
altogether, or we need some special hooks which always write the
persisted version of the class in the Initialize state (irrespective of
the actual state) which will force creation of the child processes on
the target machine when needed. Since the old class had the exact same
issue, I didn't fix this just yet...

Signed-off-by: Wouter Verkerke <verkerke@nikhef.nl>
make RooRealMPFE and the whole process of forking children a lot less chatty

Signed-off-by: Wouter Verkerke <verkerke@nikhef.nl>
Propagate Kahan summation carries over process boundaries when using more than one core.

Signed-off-by: Wouter Verkerke <verkerke@nikhef.nl>
Fix bug in which extended term in PDF might not get calculated.

Signed-off-by: Wouter Verkerke <verkerke@nikhef.nl>
if the correction formula for SumW2 corrected covariances is correct, the result must be positive definite and symmetric, so use tools which ensure that (and refuse to work when the pos. def. requirement is violated)

The reasoning here is: If the covariance obtained by the fit where the
weights enter linearly is positive definite and called V, and the Hesse
matrix evaluated with the weights entering squared is called C, then C
and VCV have exactly the same number of negative eigenvalues, since V
cannot flip the sign of the eigenvalues of C - V positive definite. The
idea of a proof is to consider the bilinear form <v, w>_M = v^T M w. If
M is pos. def., then <v,v>_M > 0 for all vectors v != 0, and the
bilinear form induces a norm. To see that each negative eigenvalue of C
induces a negative eigenvalue in VCV, you consider the corresponsing
eigenvectors of C, use that V is invertible, and arrive at non-zero
vectors v- for which <v-, v-> < 0.

The code that is used to obtain C from the corresponding covariance
matrix is tuned for symmetric pos. def. matrices, and has been used for
ages in practically all track fits done in LHCb. Therefore, it's robust,
well tested, and quite fast.

Signed-off-by: Wouter Verkerke <verkerke@nikhef.nl>
when using SumW2, make RooNLLVar keep two offsets, one for NLLs evaluated with the weights, one for NLLs evaluated with the weights squared

Signed-off-by: Wouter Verkerke <verkerke@nikhef.nl>