Page MenuHomeHEPForge

No OneTemporary

diff --git a/ChangeLog b/ChangeLog
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,1544 +1,1550 @@
2015-12-21 Andy Buckley <andy.buckley@cern.ch>
+ * Add a rebinning unit test, pytest-rebin.
+
+ * Add optional range arguments to rebinBy methods, allowing block
+ rebinnings to be applied only within a range of (original) bin
+ indices.
+
* Add missing root.py submodule file. Oops!
2015-12-20 Andy Buckley <andy.buckley@cern.ch>
* Convert linspace to use multiplication rather than repeated
addition to construct edge values, reducing precision errors.
Thanks to Holger Schulz for the suggestion.
2015-12-15 Andy Buckley <andy.buckley@cern.ch>
* Add xEdges() methods to Axis1D and the Histo1D and Profile1D
that use it. The returned edge lists are finite only, i.e. they do
not contain the +-inf values on the ends of the internal
BinSearcher edges.
2015-12-13 Andy Buckley <andy.buckley@cern.ch>
* Version 1.5.7!
* Extend batch-adding in ReaderYODA to include Scatter types.
* Add a match_aos function to Python, for filtering AO lists/dicts
on path patterns and anti-patterns.
2015-12-12 Andy Buckley <andy.buckley@cern.ch>
* Add a flag to yoda2root to change whether the conversion is to
'proper' types or to (more robustly) TGraphAsymmErrors objects.
* Fix accidental use of S2D_MODE flag where S1D_MODE should have
been used, in yodamerge. Thanks again to Radek Podskubka.
* Allow new rebinTo() merging to restrict to a subset of the bin
range, merging the outside bins into the overflow distributions.
2015-12-11 Andy Buckley <andy.buckley@cern.ch>
* Add a rebinTo() method on Axis1D, allowing rebinning to a new
given set of bin edges. Add an explicitly named rebinBy(), and
overloaded rebin() aliases for both, and pass through to Histo1D
and Profile1D APIs. Plus other internal tweaks to binning
functionality... anticipating/fuelling the fundamental rewrite.
2015-12-10 Andy Buckley <andy.buckley@cern.ch>
* Improve ReaderYODA to use temporary bin containers, to minimise
calling sort when adding bins to histos. A quick test suggests
this has sped up big file reading by a factor of 30 or so!!!
* Add missing addBins() operators (only in C++ so far) to Histo
and Profile classes.
* Fix Counter::numEntries to return an unsigned long rather than double.
Thanks to Radek Podskubka for the bug discovery and detective work.
* Improve sortedvector to insert new elements into the sorted
position, rather than resorting the whole vector. This should be a
bit more efficient, but I think the asymptotic complexity is the
same. Might help a bit with reading big data files.
2015-12-04 Andy Buckley <andy.buckley@cern.ch>
* Add yoda.HAS_ROOT_SUPPORT flag, for API user convenience.
2015-11-22 Andy Buckley <andy.buckley@cern.ch>
* Version 1.5.6!
* Make AO path setting and retrieval prepend a leading slash if it
is missing (unless the path is completely empty).
2015-11-21 Andy Buckley <andy.buckley@cern.ch>
* Add root2yoda conversion script.
* Deprecating yoda.to_root() in favour of yoda.root module, which
contains to_root and to_yoda functions, as well as a ROOT file
walking function.
2015-11-17 Andy Buckley <andy.buckley@cern.ch>
* Map ROOT-to-YODA (as scatter) functions to Python. Phew.
* Map new to-ROOT functions, including TGraph ones, to Python.
2015-11-16 Andy Buckley <andy.buckley@cern.ch>
* ROOTCnv.h: Add toScatter3D ROOT->YODA, and toNew* YODA->ROOT
conversion routines.
* ROOTCnv.h: Fix bug in toTH2D(const Histo2D& h) as used with
ROOT6. Thanks to Tim Martin.
2015-11-05 Andy Buckley <andy.buckley@cern.ch>
* Fix double-dealloc in new Point class hierarchy Python mapping.
2015-10-23 Andy Buckley <andy.buckley@cern.ch>
* Make the version() function inline, and the numerical constants static.
* Change the default plotting backend to MPL rather than the much slower PGF.
2015-10-09 Andy Buckley <andy.buckley@cern.ch>
* Reinstate __getitem__ special methods for Scatters in Python.
* Provide dim() methods/attributes for the Point and Bin base classes.
* Rename set*Err to set*Errs for the asymmetric variants. Plural
aliases are also provided for the symm case.
2015-10-08 Andy Buckley <andy.buckley@cern.ch>
* Pass std::pairs by reference in Point*D error setting functions.
* Add Point base class with generic accessors to Point*D
properties via an integer axis ID argument.
2015-10-07 Andy Buckley <andy.buckley@cern.ch>
* Version 1.5.5 release.
* Counter.pyx: Typo fix in sumW mapping.
* yodamerge: Re-add checking for non-emptiness before merging, in
case the empty ones are missing a ScaledBy attribute. Won't
normally apply to Profiles, since they don't usually get
normalised, but we might as well include them in the vetoing since
empty histos don't contribute to the merging. Added a command-line
option to disable this heuristic since in very strange situations
a null sumW does not mean no fills.
2015-10-06 Andy Buckley <andy.buckley@cern.ch>
* Version 1.5.4 release.
* ReaderYODA: Typo fixes in Counter filling of sumW and Scatter3D reader state flag.
* yodamerge: add merging heuristics for Scatter1D and Scatter3D (needs unification)
2015-10-05 Andy Buckley <andy.buckley@cern.ch>
* yodamerge: add a fix for empty-in-all-runs histo merging; thanks
to Daniel Rauch.
2015-10-04 Andy Buckley <andy.buckley@cern.ch>
* Adding dim() function and corresponding Python attribute to AnalysisObject.
* Map Counter arithmetic operations into Python.
* Map Counter mkScatter() into Python (as bound method).
* Add a YODA::version() function, mapped into Python and used to
set the yoda.__version__ variable.
2015-10-01 Andy Buckley <andy.buckley@cern.ch>
* Expose the yoda.plot() Python function in a way that doesn't
automatically induce a dependence on matplotlib.
2015-09-30 Andy Buckley <andy.buckley@cern.ch>
* Fix yodals to work with Counters.
2015-09-23 Andy Buckley <andy.buckley@cern.ch>
* Version 1.5.3 release.
* Update Boost version requirement to 1.48, due to use of
type_traits/has_dereference, and add a check for that feature's
header.
2015-09-19 Andy Buckley <andy.buckley@cern.ch>
* Further improvements to handling leading _multiple_ # marks on
YODA format BEGIN lines.
2015-09-11 Andy Buckley <andy.buckley@cern.ch>
* Version 1.5.2 release.
* Tolerate leading # symbols without separating whitespace on
BEGIN lines in YODA format parsing.
* Further improvements to handling LowStatsErrors in YODA format writing.
* Fix shadowed variables that made ReaderYODA unhappy.
2015-09-03 Andy Buckley <andy.buckley@cern.ch>
* Version 1.5.1 release.
* Fix bugs in Python wrapper for Point3D.
2015-08-28 Peter Richardson <Peter.Richardson@durham.ac.uk>
* Catch LowStatsError when writing multiple histograms so only the
histogram with the problem is not written
2015-08-28 Andy Buckley <andy.buckley@cern.ch>
* Version 1.5.0 release.
2015-08-24 Andy Buckley <andy.buckley@cern.ch>
* Improve protection of efficiency calculation against the weird
world of general weighted events.
2015-08-17 Andy Buckley <andy.buckley@cern.ch>
* Add some protection against calling matplotlib's legend() method
if there are no valid labels to display, to suppress an MPL
warning message when using yoda.plot().
2015-08-12 Andy Buckley <andy.buckley@cern.ch>
* Fix cut & paste typo, and add LowStatsError catching in Profile division.
2015-08-11 Andy Buckley <andy.buckley@cern.ch>
* Replace old Spirit-based ReaderYODA with the new hand-rolled one.
* Adding filling of Histo1D, Profile1D, Histo2D and Profile2D in
new ReaderYODA. More hacking of Axis and Histo/Profile
interfaces... needs clean-up, and infinite binning implementation.
2015-08-07 Andy Buckley <andy.buckley@cern.ch>
* Convert the ReaderFLAT parser to also use a simple hand-written parser rather than Spirit.
2015-08-04 Andy Buckley <andy.buckley@cern.ch>
* Add methods for Counter, Axis and Histo1D internal state
access/setting, mainly for new persistency. NEEDS PRE-RELEASE TESTING!!!
2015-07-30 Andy Buckley <andy.buckley@cern.ch>
* Remove # markers from YODA format BEGIN/END output. The parser
will continue to accept them.
2015-07-29 Andy Buckley <andy.buckley@cern.ch>
* Add SFINAE trait magic to restrict write(RANGE) functions to
accepting iterables. Also generalising to allow either
container-of-objects or container-of-pointers args by providing a
writeBody(AO*) function to complement writeBody(AO&). Based on a
patch from Lukas Heinrich.
* Add configuration of output streams to throw exceptions on
bad/fail state (based on patch from Lukas Heinrich).
2015-07-01 Andy Buckley <andy.buckley@cern.ch>
* 1.4.0 release.
2015-06-30 Andy Buckley <andy.buckley@cern.ch>
* More tweaks to yodamerge: adding control of S2D merging
strategy, and now performing weighted normalized histo merges
without reference to an absolute normalization.
* Change yodamerge norm-detection heuristic to just look for a
ScaledBy attribute rather than fuzzily compare norms.
2015-06-26 Andy Buckley <andy.buckley@cern.ch>
* Removing add, subtract, and divide functions and operators on
Scatter types, and re-implementing Histo and Profile divide
functions explicitly rather than via mkScatter. Also removed from
the Python interface. The combine() methods remain.
2015-06-24 Andy Buckley <andy.buckley@cern.ch>
* Adding workaround versions of binAt to all the Python histo
types (for some reason the direct mapping that works for bin(i)
produces a compile error for binAt(x) :-/
2015-06-23 Andy Buckley <andy.buckley@cern.ch>
* Renaming, tidying, completing, etc. the Python-mapped methods on Bin1D and Bin2D.
* Rename Python Histo2D mean, variance, etc. pair-returning
methods to xyMean, xyVariance, etc., to distinguish from Profile2D
mean, variance, etc.
* Add Python mappings of all the methods below.
* Add full set of {x,y}{Mean,Variance,StdDev,StdErr,RMS} to 1D and
2D binned distributions.
* Add optional includeoverflows=True argument to all binned AO
numEntries and effNumEntries.
* Fix type of numEntries to always be unsigned long.
2015-06-18 Andy Buckley <andy.buckley@cern.ch>
* Fix typos in Point3D Python mapping (accidentally trying to get
the ptr via _Point2D rather than _Point3D).
2015-06-13 Andy Buckley <andy.buckley@cern.ch>
* Adding an AnalysisObject::name() method, to return the last part
of the path. Mapped into a Python property.
* Adding an optional usestddev argument to mkScatter for profile
types, so the error bars can represent distribution width rather
than uncertainty on the mean. Mapped to Python.
2015-06-08 Andy Buckley <andy.buckley@cern.ch>
* Adding unpatterns arguments to Python read functions, and
auto-conversion from single strings and re.compile()d strs.
2015-06-04 Andy Buckley <andy.buckley@cern.ch>
* Add binAt(x,y) and binIndexAt(iglobal) Python methods for 2D
histos. Still want a way to get and pass a pair of bin indices, I
think.
* Adding includeoverflows optional args for Histo1D (eff)numEntries.
* Adding Rename Histo1D integral() methods as integral(),
integralRange(), and integralTo(), and mapping to Python.
2015-06-02 Andy Buckley <andy.buckley@cern.ch>
* Adding missing binAt and binIndexAt methods to Histo1D and
Profile1D, plus other minor Python mapping tweaks.
* Add a regex pattern match optional argument to the IO.read()
Python functions, for pre-emptive filtering.
2015-03-27 Andy Buckley <andy.buckley@cern.ch>
* Fix a harmless possibility to raise an FPE exception in the
BinSearcher. Thanks to Leif Lonnblad for the discovery, debug and
patch!
2015-03-19 Andy Buckley <andy.buckley@cern.ch>
* Bump version for 1.3.1 release.
2015-03-06 Andy Buckley <andy.buckley@cern.ch>
* Adding usefocus optional argument to some mkScatter functions, plus the Python bindings.
* Cleaning up some Python mappings of 2D histogram bin classes.
* Removing mappings of bin-level fill and scale operations in Python.
* Fix formatting and error handling in Python Bin and Dbn __repr__ methods.
* Add a -i/--in-place option pair on yodascale.
2015-02-05 Andy Buckley <andy.buckley@cern.ch>
* Convert script matching options to use re search rather than match.
* Adding matching options and verbose option to yodals.
2015-01-27 Andy Buckley <andy.buckley@cern.ch>
* Improvements and additions to ROOTCnv.h routines, particularly
to TProfile creation: thanks to Roman Lysak for advice.
2015-01-16 Andy Buckley <andy.buckley@cern.ch>
* Add convenience YODA/YODA.h header.
2015-01-15 Andy Buckley <andy.buckley@cern.ch>
* yodascale now uses PointMatcher and can normalize or multiply to
abs values or ref histos/bin ranges.
2015-01-05 Andy Buckley <andy.buckley@cern.ch>
* Adding yoda.matcher Python sub-package with PointMatcher
functionality. To be used in Professor 2.0 and in yodascale.
* Adding 'scat2' type to yodahist.
* Add match/unmatch args to all conversion scripts, via a new Python yoda.script_helpers function.
* Script updates, improved docstrings, and improved tab completion.
2014-12-10 Andy Buckley <andy.buckley@cern.ch>
* Add a yoda.plotting sub-module, based on matplotlib.
2014-12-03 Andy Buckley <andy.buckley@cern.ch>
* Small build improvements: cleaning test1.root from the yoda2root
test, and adding a make target & flag file for mktemplates in
pyext/yoda to make sure that it only gets run once.
2014-11-25 Andy Buckley <andy.buckley@cern.ch>
* Handle overflow filling in binned types without invoking an exception.
* Change inRange to have non-fuzzy comparison behaviour.
2014-11-11 Andy Buckley <andy.buckley@cern.ch>
* Improving/adding __div__ functions in Python for all binned types.
* Add std:: prefix to isinf() calls in BinSearcher.h.
2014-09-30 Andy Buckley <andy.buckley@cern.ch>
* 1.3.0 release!
* Use numEntries() rather than effNumEntries() when checking
consistency of inputs to efficiency() calculations -- the
effNumEntries of a set can be smaller than that of a strict
subset, surprisingly!
2014-09-17 Andy Buckley <andy.buckley@cern.ch>
* Small improvements to yodahist and yodaplot behaviours/UIs.
* Adding setX/Y/Z(val, err) methods to Point3D.
* Add an efficiency method for 2D histos.
* Hide fill and fillBin methods from Python mappings of bin types.
2014-09-01 Andy Buckley <andy.buckley@cern.ch>
* YODA 1.2.1 release!
2014-08-29 Andy Buckley <andy.buckley@cern.ch>
* Hide non-const access to bin objects from histogram users:
avoids potential for inconsistency between total dbns and in-range
bins.
* Bug in BinSearcher fixed by Peter Richardson: constructor
arguments were passed in the wrong order when constructing a
LinEstimator in cases where log binning wouldn't be allowed.
2014-08-26 Andy Buckley <andy.buckley@cern.ch>
* Add protection against / characters in histo names in yoda2root
(thanks to Will Bell for the report and suggested patch).
2014-08-17 Andy Buckley <andy.buckley@cern.ch>
* Add +=, -=, *-, /=, ++ and -- operators to Counter, along with
an (implicit) constructor from a double -- all for user
convenience so Counter can be used in lieu of a simple number.
2014-08-15 Andy Buckley <andy.buckley@cern.ch>
* YODA 1.2.0 release!
* Permit +-inf values to be filled into histograms; NaN fills will
still explicitly throw an exception.
* Add unit tests for Counter, Scatter1D, and Scatter2D, including
persistency.
* Adding YODA and FLAT format I/O for Scatter1D and Counter (as
far as currently possible -- FLAT Counter can't be read due to a
#item ambiguity, just like the one between the YODA format Point3D
and ProfileBin1D). To be continued...
2014-08-14 Andy Buckley <andy.buckley@cern.ch>
* Python mappings for Dbn0D and Counter, and other improvements.
* Adding val() and err() methods to Counter, and errW() and
relErrW() to all DbnXD types.
* Adding Scatter1D and Point1D types, with conversion from Counter
supported. Both Counter and Scatter1D still need to be supported
by YODA persistency.
2014-08-11 Andy Buckley <andy.buckley@cern.ch>
* Add ROOT version checking to configure. Thanks to Michael Grosse
for the report/request.
2014-08-05 Andy Buckley <andy.buckley@cern.ch>
* Remove all methods not specific about the axis to which they
refer, e.g. Histo1D::mean -> xMean. Also remove all related
aliases (a nightmare to maintain) and low/highEdge and midpoint
functions: use the proper xMin/Max/Mid from now on. This is a
significant compatibility breaking API change (and the decision
was not taken lightly) so will require a 2nd digit version change.
* Lots of adding xMin/Max etc. functions to C++ and Python bin/histo classes.
* Compiler pickiness fixes in BinSearcher.
* Improvement to linspace, avoiding fuzzyEquals and again making
sure that the end value is exact.
2014-07-23 Andy Buckley <andy.buckley@cern.ch>
* Fix to logspace: make sure that start and end values are exact,
not the result of exp(log(x)).
* Clean-up, minor improvements, and adding a test for BinSearcher and friends.
2014-07-19 Andy Buckley <andy.buckley@cern.ch>
* Various consistency improvements and minor bugfixes to Python
mapping utils and Dbn and Bin objects.
* Fix Axis2D::reset, which was resetting the total dbn and
outflows, but not the bins!!! Thanks to Ewen Gillies for the
report.
2014-07-18 Andy Buckley <andy.buckley@cern.ch>
* Add scaleX,Y,Z and scaleXYZ to Point and Scatter classes, and
deprecate less explicit/consistent Scatter2D/3D.scale method.
2014-07-17 Andy Buckley <andy.buckley@cern.ch>
* yodascale now writes out rescaled histograms and profiles rather than scatters.
* A few more improvements on Point2D/3D, adding x,y,zMin/Max function mappings.
* Add first version of a yodascale script, based on code from Simone Amoroso.
2014-07-16 Andy Buckley <andy.buckley@cern.ch>
* More Scatter and 2D histo interface improvement.
* Remove 'return *this' from Scatter2D/3D add and combine methods.
* Add unit test checks for 1D and 2D mkScatter functions.
* Improve Scatter2D/3D C++ and Python interfaces.
* Add Scatter3D Python mapping.
2014-07-15 Andy Buckley <andy.buckley@cern.ch>
* Add auto-parsing of yes/no/on/off/true/false as bools in the
Python ao.annotation() function.
* Add parsing of yodaplot styles from command line args and
analysis object annotations.
2014-07-12 Andy Buckley <andy.buckley@cern.ch>
* Fix infinite recursions in Python wrappers for Point2D and
Point3D, and make the Python Point3D interface more standard.
* Add yodaplot script for basic plotting, using pgfplots as a backend.
2014-07-10 Andy Buckley <andy.buckley@cern.ch>
* Add mkScatter(Scatter2D) and mkScatter(Scatter3D) functions and
Python mappings: this allows all AOs to be used as args to
mkScatter(...) without needing to check if they already are
scatters.
2014-07-02 Andy Buckley <andy.buckley@cern.ch>
* Set y value and/or error to 0 in mkScatter(Histo1D) if an
exception is thrown when calculating the appropriate values. Need
an optional param to control this error handling behaviour between
set-zero and skip-bin?
2014-07-01 Andy Buckley <andy.buckley@cern.ch>
* Add exception translation to the mkScatter functions.
* Add -m/-M match/unmatch options to yodacnv -- useful for
filtering histogram file contents in a YODA->YODA conversion.
2014-06-24 Andy Buckley <andy.buckley@cern.ch>
* Don't complain about merge assumptions if there is only one
object with that path name to be 'merged'
2014-06-17 Andy Buckley <andy.buckley@cern.ch>
* Adding explicit int cast in Python wrapping of numEntries functions.
2014-06-13 Andy Buckley <andy.buckley@cern.ch>
* Adding yodals script to list data file contents.
2014-06-11 David Grellscheid <David.Grellscheid@durham.ac.uk>
* pyext/yoda/Makefile.am: 'make distcheck' and out-of-source
builds should work now.
2014-06-10 Andy Buckley <andy.buckley@cern.ch>
* Fix use of the install command for bash completion installation on Macs.
2014-06-06 Andy Buckley <andy.buckley@cern.ch>
* YODA 1.1.0 release. Middle version number change to reflect API changes w.r.t 1.0.6.
* Adding unit tests against ref data for yodamerge in make check.
2014-06-04 Andy Buckley <andy.buckley@cern.ch>
* Fix silly typos in yodamerge which somehow made it past "make check" testing :-(
2014-06-02 Andy Buckley <andy.buckley@cern.ch>
* YODA 1.0.7 release. DO NOT USE: prefer 1.1.0, above.
2014-05-30 Andy Buckley <andy.buckley@cern.ch>
* Removing 'foreach' macro definition and using raw BOOST_FOREACH instead until C++11 is allowed.
* Adding pytest-p1d and pytest-p2d tests, and FLAT writing/reading in pytests.
* Tweaking WriterFLAT and adding ReaderFLAT functionality for 2D histos and profiles.
2014-05-30 Holger Schulz <hschulz@physik.hu-berlin.de>
* Some basic (FLAT) write-out capability for 2D histos
2014-05-29 Andy Buckley <andy.buckley@cern.ch>
* Improvements to the yodahist script, including support for 2D
histograms and input files.
* Adding bin edges constructors for all 1D and 2D histos in Python.
2014-05-22 Andy Buckley <andy.buckley@cern.ch>
* Improvements to Profile2D and Point2D interfaces in Python.
* Add a single-file at a time yodacnv multi-format converter
script (thanks to Andrii Verbytskyi for the suggestion).
2014-05-19 Andy Buckley <andy.buckley@cern.ch>
* Typo fixes in Profile2D YODA-format parsing: 2D histo tests now pass!
* Adding Python tests for Histo2D and Profile2D.
* Adding a YODA/Predicates.h header and using it in Axis2D bin edge construction.
* Enabling Profile2D writing in various Writers, and a bit of IO code tidying.
2014-05-17 Andy Buckley <andy.buckley@cern.ch>
* Disable writing out of Histo2D and Profile2D outflows for now,
while they are redesigned, and get 2D I/O working for the in-range
part.
2014-05-14 Andy Buckley <andy.buckley@cern.ch>
* Mapping the divide and efficiency functions into the Python
interface as class methods, including the __div__ special
function.
2014-05-13 Andy Buckley <andy.buckley@cern.ch>
* Add the AnalysisObject::type() method back in Python (even
though type(ao) is more Pythonic, this may be useful)
2014-05-06 Andy Buckley <andy.buckley@cern.ch>
* Add Profile2D YODA format writing, note need for Scatter format
change, add sumXY storage to both 2D histo types.
2014-05-03 Andy Buckley <andy.buckley@cern.ch>
* Adding YODA reader functionality for Histo2D and Profile2D, but
without outflows support yet.
2014-04-25 Andy Buckley <andy.buckley@cern.ch>
* Adding simple command line yodahist script for quick 1D
histogramming from plain text files, with weight support. More
development to come!
* Mapping linspace, logspace and a few stat functions into Python.
2014-04-24 Andy Buckley <andy.buckley@cern.ch>
* Fixes, script installation, and detailed numerical comparisons
in yodadiff.
2014-04-17 Andy Buckley <andy.buckley@cern.ch>
* Change AnalysisObject::annotations to return the list of
annotation keys rather than the map, since the previous behaviour
mapped very badly into Python.
2014-04-16 Andy Buckley <andy.buckley@cern.ch>
* Add special case handling for 2-arg use of x2y scripts where the
second arg is -, for stdin. This will be treated as writing out to
stdout, not converting two files one of which is stdin.
2014-04-15 Andy Buckley <andy.buckley@cern.ch>
* Adding a more portable version of getline to be used in the YODA
file parsing to avoid falling over on DOS-produced input files.
2014-04-14 Andy Buckley <andy.buckley@cern.ch>
* Adding the namespace protection workaround for Boost described
at http://www.boost.org/doc/libs/1_55_0/doc/html/foreach.html
2014-04-13 Andy Buckley <andy.buckley@cern.ch>
* Adding an assumed-equal-run-size, ratio-like merging heuristic
for Scatter2Ds to yodamerge, and renaming the --normalize-all flag
to --assume-normalized.
* Adding and installing a pkg-config data file for YODA.
* Rationalising (and fixing?) the yodamerge logic re. user &
normalization scalings, and making way for a Scatter2D merging
heuristic.
2014-03-10 Andy Buckley <andy.buckley@cern.ch>
* YODA 1.0.6 release.
2014-03-06 Andy Buckley <andy.buckley@cern.ch>
* Improvements to AnalysisObject annotation handling in Python.
* Adding rescaling arguments to yodamerge (and scale function to Python Scatter2D).
* Better documentation and consistency of Histo and Profile Python
wrappers, and removing some inappropriate attributes.
* Adding clone() and newclone() functions to all analysis object classes.
2014-02-28 Andy Buckley <andy.buckley@cern.ch>
* Cython mapping improvements, esp. adding numPoints/numBins
functions and better Scatter2D __repr__.
* Adding mapping of the mkScatter functions into Python (as
methods on Histo1D and Profile1D rather than the original free
functions, at least for now: some Python type-identifying
boilerplate is needed to make a single mkScatter function work in
Python)
2014-02-27 Leif Lönnblad <Leif.Lonnblad@thep.lu.se>
* Minor modifications to BinSearcher to avoid NaN's. The NaN's
were treated correctly before, but better to avoid them all
together.
2014-02-27 Andy Buckley <andy.buckley@cern.ch>
* Adding the generated pyext/yoda/rootcompat.cpp to the tarball
and sorting out the ROOT/Cython interface conditionals a bit more
sanely. Thanks to Oldrich Kepka for the bug report.
* Protecting yodamerge against input histograms with zero
integrals (thanks to Christian Bierlich for the bug report).
2014-02-14 Frank Siegert <frank.siegert@cern.ch>
* Fix race condition with mktemplates.
2014-02-12 David Grellscheid <david.grellscheid@dur.ac.uk>
* Fix bug in mktemplates code (thanks to Christian Johnson for the bug report).
2014-02-09 Andy Buckley <andy.buckley@cern.ch>
* Adding explicit include/generated dir creation to Python
extension build (thanks to Christian Johnson for the bug report).
2014-02-06 Andy Buckley <andy.buckley@cern.ch>
* 1.0.5 release!
2014-02-05 Andy Buckley <andy.buckley@cern.ch>
* Adding patches to ReaderFLAT and ReaderYODA use of Boost Spirit
which reduce the Boost version requirement from 1.47 ->
1.41. Thanks to Andrii Verbytskyi for the patch.
* Protect against invalid prefix value if the --prefix configure option is unused.
2014-02-04 Andy Buckley <andy.buckley@cern.ch>
* Adding copy assignment operators where missing, based on an
implementation in AnalysisObject which only copies rvalue paths
and titles if they are non-null.
2014-02-03 Andy Buckley <andy.buckley@cern.ch>
* Improving (i.e. increasing) bin edge overlap tolerance: 1e-10 relative was too tight.
2014-01-31 Andy Buckley <andy.buckley@cern.ch>
* Adding x/yMid etc. methods on Bin1D and 2D, and more related Python API improvements.
2014-01-28 Andy Buckley <andy.buckley@cern.ch>
* Adding missing fillBin methods to 1D and 2D Histo/Profile Python classes.
* Fixed yodamerge default output file name treatment.
* Avoid computing an unrecoverable error in Histo1D.__repr__
* Clean-ups and API improvements in Python IO functions.
* Adding more sumW,W2 and (eff)NumEntries attrs to Python objects.
2013-12-17 Andy Buckley <andy.buckley@cern.ch>
* Improved argument handling for x2y scripts.
2013-11-16 Andy Buckley <andy.buckley@cern.ch>
* Fix to build the Cython rootcompt extension .cpp on request.
2013-11-14 Andy Buckley <andy.buckley@cern.ch>
* Adding flags for the C++11 or C++0x standard if supported, cf. Rivet.
2013-10-24 Andy Buckley <andy.buckley@cern.ch>
* YODA 1.0.4 release.
* Supporting zsh completion via bash completion compatibility.
2013-10-21 Andy Buckley <andy.buckley@cern.ch>
* Removing unused internal iterator typedefs from Writer functions.
2013-10-18 Andy Buckley <andy.buckley@cern.ch>
* Adding a yodaenv.sh sourceable script to help with environment setup.
* Remove Scatters from being handled by yodamerge by blocking the
__add__ method fallback.
2013-10-09 Andy Buckley <andy.buckley@cern.ch>
* Improvements to yoda-config and command-line completion, for the
Rivet 2.0.0 release.
2013-10-09 Andy Buckley <andy.buckley@cern.ch>
* Version 1.0.3 release.
2013-10-04 Andy Buckley <andy.buckley@cern.ch>
* Cython mapping improvements.
* Adding some improved heuristics and a --normalize-all option to
yodamerge. Frank S is now happy again ;-)
2013-10-01 Andy Buckley <andy.buckley@cern.ch>
* Adding operator +, -, +=, -= Python mappings wherever possible
for Histo1/2D, Profile1/2D, and Scatter2D.
2013-09-26 Andy Buckley <andy.buckley@cern.ch>
* Cython is no longer needed by tarball users.
2013-09-25 Andy Buckley <andy.buckley@cern.ch>
* Unset path of returned histogram if those of the args to add()
and subtract() are difference.
2013-09-24 Andy Buckley <andy.buckley@cern.ch>
* Python mapping improvements.
2013-09-23 Andy Buckley <andy.buckley@cern.ch>
* Add the -avoid-version flag to libtool.
* Adding more add and subtract special methods in Python.
2013-09-22 Andy Buckley <andy.buckley@cern.ch>
* mkScatter schanged to use histo midpoints rather than focuses by
default for the point x value.
2013-08-14 Andy Buckley <andy.buckley@cern.ch>
* Version 1.0.2.
* Some exception message improvements and improving the protection
of cosmetic mean calculations in WriterYODA.
2013-07-12 Andy Buckley <andy.buckley@cern.ch>
* Adding ROOT detection in configure and otherwise updating Dave's
rootcompat module so that it'll compile. There might be an
inconvenient ROOT version dependency in the signature of one of
the PyROOT API functions that is used as a shim :-(
2013-06-17 Andy Buckley <andy.buckley@cern.ch>
* Adding yoda.m4 from James Robinson.
2013-06-06 Hendrik Hoeth <hendrik.hoeth@cern.ch>
* Improve "==" operator in Axis1D and Axis2D
2013-06-06 Andy Buckley <andy.buckley@cern.ch>
* Adding fillBin() methods to all 1D and 2D histos, and noting
that Bin types need a back-link to their axis to maintain
consistency.
* Release of version 1.0.1
2013-06-05 Andy Buckley <andy.buckley@cern.ch>
* Change the divide(Scatter, Scatter) behaviours to use the
midpoint of the num/denom bins rather than mean of foci for the
output point position (and hence errors, too).
* Adding a toIntegralEfficiencyHisto function.
* Adding another Histo1D::integral() function, this time from 0 ->
i, maybe including the underflow.
2013-06-04 Andy Buckley <andy.buckley@cern.ch>
* Updating the Cython version requirement to 0.18
2013-06-03 Andy Buckley <andy.buckley@cern.ch>
* Adding relErr functions to 1D and 2D histo and profile bins, and
being careful about div by zero.
* Improvements in error treatment in division (better handling of zeros).
* Renaming merge-histos to yodamerge and installing it (and
improving the usage string a bit).
2013-05-31 Andy Buckley <andy.buckley@cern.ch>
* Adding the Counter type, and ability to output it from the YODA writer.
* Adding numEntries and effNumEntries methods to 1D and 2D Histo
and Profile classes.
* Adding Dbn0D and using it to implement Dbn1D.
2013-05-30 Andy Buckley <andy.buckley@cern.ch>
* Fixing several nasty errors in argument ordering for
Point{1,2,3}D construction in Scatter addPoint functions.
* Adding abs(...) to the returned Dbn1D::variance(), to avoid
problems when negative weights produce negative variance. No, we
don't like this either: is there a more correct way?
* Fixing the efficiency(Histo1D, Histo1D) implementation,
cf. http://root.cern.ch/phpBB3/viewtopic.php?t=3753
* Adding mkScatter(Profile2D)
2013-05-29 Hendrik Hoeth <hendrik.hoeth@cern.ch>
* Adding a reader for FLAT files and a flat2yoda converter
2013-05-27 Andy Buckley <andy.buckley@cern.ch>
* Adding a yoda-completion file for bash.
2013-05-17 Andy Buckley <andy.buckley@cern.ch>
* Mapping HistoBin1D.relErr in Python.
* Adding a non-const points() accessor to Scatter2D.
2013-05-13 Andy Buckley <andy.buckley@cern.ch>
* Adding combined value+error setX/Y functions on Point2D.
* Adding HistoBin1D::relErr()
2013-04-23 Andy Buckley <andy.buckley@cern.ch>
* Adding Python output handling for single AOs and to be able to
use a "-" filename to mean stdout.
2013-04-12 Andy Buckley <andy.buckley@cern.ch>
* Releasing version 1.0.0 -- it seems stable enough.
2013-04-10 Andy Buckley <andy.buckley@cern.ch>
* Being more careful about adding -Wno-* flags to the C++ compiler
used to built the Cython extension lib.
2013-03-22 Andy Buckley <andy.buckley@cern.ch>
* Removing the use of svn:external to pull in Boost macros and
using a minimal local set instead.
* Using the nice Boost-finding macros from
https://github.com/tsuna/boost.m4 and tidying up configure.ac
2013-03-15 Andy Buckley <andy.buckley@cern.ch>
* Re-organising the C++ side of the auto-format I/O functions,
into a new IO header and separated from the Reader.h and
Writer.h. I'm tempted to say that users shouldn't really NEED to
ever directly touch the Reader and Writer objects...
* Adding auto-format read and write functions. I will probably
change the API. Python mappings have been provided, but the string
workarounds were too much of a pain with Cython 0.16 so I have
updated the Cython version requirement to 0.17 where it is
automatic and hence much cleaner.
2013-03-08 Andy Buckley <andy.buckley@cern.ch>
* Making the x2y converter scripts write a copy into the *current*
directory if only the input is specified.
2013-03-05 Andy Buckley <andy.buckley@cern.ch>
* Removing Plot entirely from YODA: it was an anomaly only added
to make plot file generation easy, but this is now done better via
StringIO (in new compare-histos/rivet-cmphistos).
* Removing the Plot from Cython... and soon from YODA itself:
we'll do this stuff manually and less hackily.
* Make Cython automatically add a copy of the original call
signature to each function's docstring.
2013-03-04 Andy Buckley <andy.buckley@cern.ch>
* Adding Plot mapping to Cython and improving the AO annotations handling in Python.
* Adding PLOT section writing to WriterFLAT (and WriterYODA,
although that might be a bad idea...)
* Adding aida2yoda and aida2flat converter scripts.
2013-02-02 David Mallows <dave.mallows@gmail.com>
* Adding support for Python >= 2.4 (was Python >= 2.6)
* Fixing miscellaneous warnings on GCC 4.1
2013-01-30 Andy Buckley <andy.buckley@cern.ch>
* Adding a points() method to the Python Scatter2D wrapper.
* Adding a virtual destructor to Bin.
2012-12-30 Andy Buckley <andy.buckley@cern.ch>
* Adding support for Boost.Range arguments and file format autodetection in Writer.
2012-11-24 Andy Buckley <andy.buckley@cern.ch>
* Bump version to 0.6beta0
* Adding more ROOT converters. Who knows how to make TProfiles
from scratch, but Histo1D and Scatter2D are covered, which should
be enough to get started with, at least.
2012-11-16 Andy Buckley <andy.buckley@cern.ch>
* Adding yoda-config
2012-11-16 Hendrik Hoeth <hendrik.hoeth@cern.ch>
* Adding WriterFLAT and yoda2flat
2012-11-16 Andy Buckley <andy.buckley@cern.ch>
* Adding YODA/ROOTCnv.h. for data object converter functions. Two
(untested) functions added for TH1 -> YODA.
* Adding toIntegralHisto(Histo1D&) function.
2012-11-15 Dave Mallows <dave.mallows@gmail.com>
* Commited numerous changes to Axis2D. Axis2D now uses BinSearcher as
with Axis1D.
2012-11-15 Andy Buckley <andy.buckley@cern.ch>
* Improving division and efficiency treatments, and allowing
arbitrary f(x), f(y), and flip transformations on Scatter2D.
2012-11-14 Andy Buckley <andy.buckley@cern.ch>
* Converting linspace, logspace, and their usage to place the nbins argument first.
2012-08-07 Andy Buckley <andy.buckley@cern.ch>
* Removing unused (beyond 2nd order) sumWXYZ counter from Dbn3D.
2012-08-07 Dave Mallows <dave.mallows@gmail.com>
* Converted Axis1D to use new Utils/BinSearcher.
2012-08-02 Dave Mallows <dave.mallows@gmail.com>
* Heavily refactored Cython bindings
* HistoBin1D, ProfileBin1D etc. now inherit from Bin1D[DBN]
* Temporarily removed Histo2D, Profile2D and Scatter3D mappings.
2012-07-23 Andy Buckley <andy.buckley@cern.ch>
* Installing scripts from bin dir, and making the yoda2aida interface nicer.
* Adding Cython mappings for Dbn3D and Profile2D, and other fixes/improvements.
2012-07-22 Andy Buckley <andy.buckley@cern.ch>
* Adding Cython mappings for Scatter3D and ProfileBin2D.
* Fixing more crap code legacy from old 2D plot implementation, this time in Scatter3D.
2012-07-19 Andy Buckley <andy.buckley@cern.ch>
* Adding stdErr for Histo2D + Python mapping, and more Cython improvements.
* Adding path/title-only AO constructors and making nice Python constructor for Histo2D.
* Cython mapping improvements & additions for Point3D + Scatter3D.
* Removing mixed symm/asymm constructors on Point*D & Scatter*D classes.
2012-07-12 Andy Buckley <andy.buckley@cern.ch>
* Reintroducing Profile2D and Scatter3D.
* Adding axis locking to Axis2D.
* Supporting Histo2D in WriterYODA.
2012-07-02 Andy Buckley <andy.buckley@cern.ch>
* More incremental progress toward a working 2D bin hash mechanism.
2012-05-03 Andy Buckley <andy.buckley@cern.ch>
* Adding nice constructor behaviours to the Histo1D and Profile2D
Python interfaces, and adding the mkScatter operation for
Profile1D.
* Adding more default constructors for analysis objects, to allow
member variable and STL container use without pointers.
2012-05-02 Andy Buckley <andy.buckley@cern.ch>
* A much simplified and more robust rewrite of the Axis1D class,
just using STL map in place of the hand-written bin edge caching.
* Improvements (I hope) to the binary search in Axis1D, and
providing an experimental default constructor for Histo1D.
2011-12-08 Hendrik Hoeth <hendrik.hoeth@cern.ch>
* ReaderYODA can now parse Histo1D and Profile1D flat files
2011-12-08 Andy Buckley <andy.buckley@cern.ch>
* Adding a Utils::ndarray object and using it to implement a
general Scatter<N> system, with generalised Point<N> and Error<N>
to boot.
2011-12-07 Hendrik Hoeth <hendrik.hoeth@cern.ch>
* Lots of cleanup
2011-12-07 Andy Buckley <andy.buckley@cern.ch>
* Mapping the Dbn1D and Dbn2D classes into Python.
* Adding an outflows() accessor to Histo2D.
* Writing out total dbn lines for Histo1D and Profile1D in the
YODA format, and now writing out the 'cross-terms' for Profile1D,
too.
* Properly adding Dbn1D accessors for Histo1D.
* Updating the Cython mappings to provide the totalDbn() methods
and add a placeholder mapping for Dbn2D. Completed mappings are
needed for Dbn{1,2,3}D and the Profile types.
* Adding totalDbn() accessors to data types.
2011-12-06 Andy Buckley <andy.buckley@cern.ch>
* Making Histo1D/2D::scaleW() write a ScaledBy annotation.
* Adding annotation-fetching methods with a default return value
argument to AnalysisObject.
* Adding normalize() methods to Histo1D/2D.
* Adding weighted RMS calculating methods to Dbn1D, Dbn2D and
Bin1D/2D.
2011-09-03 Dave Mallows <dave.mallows@gmail.com>
* Fixed ReaderAIDA: x-value and low y-error interchanged when filling
Scatter2D.
* Changed to Cython for Python bindings: Swig bindings were in need of
serious amounts of work. Cython should provide a means to provide more
Pythonic bindings to YODA. A minimal subset of ReaderAIDA, Scatter2D
and Point2D have been wrapped.
* Modified configure.ac, Makefile.am and pyext/Makefile.am to reflect
change to Cython. Added cython.m4 from python-efl (Part of the
enlightenment project; LGPL)
2011-08-31 Dave Mallows <dave.mallows@gmail.com>
* Fixed python tests by installing python extension to pyext/build
2011-08-23 Andy Buckley <andy@insectnation.org>
* Adding rebinning interface to Histo1D and Profile1D, and adding
a test (and a new test feature for output message formatting)
* Adding first implementation of 1D bin merging to Axis1D.
2011-08-22 Andy Buckley <andy@insectnation.org>
* Adding copy constructors and assignment operators to Histo1D,
Profile1D, and Scatter2D, and their respective bins/points.
* Remove use of sign(weight) in filling sum(w2) -- I think this
was an historical attempt based on a scaling axiom which turned
out to be inappropriate.
* Reworking the Bin1D inheritance and composition design so that
all bin types store a single distribution object -- a Dbn1D for
histo bins and a Dbn2D for profile bins.
2011-08-18 Andy Buckley <andy@insectnation.org>
* Removing the Profile1D -> ProfileBin1D friendship. This is very
heartening -- the fewer friend declarations we need, the more
indication that the class structure is not pathological! (Or that
we've just made everything public... but we haven't)
2011-08-15 Andy Buckley <andy@insectnation.org>
* Inlining all functions in HistoBin1D, ProfileBin1D, and
HistoBin2D.
* Converting Dbn2D to be composed of two Dbn1Ds and a
cross-term. Also tidying the interfaces of the 2D classes and the
scaleX/Y methods throughout, and adding Doxygen comments.
2011-08-12 Andy Buckley <andy@insectnation.org>
* Adding proper Doxygen structures and full descriptive comments
to Dbn2D.
* Adding the persistency state-setting constructors for Profile1D
and Dbn2D.
* Inlining lots of methods on Dbn1D. Same should be done for
Dbn2D, but first it needs to be reimplemented in terms of two
Dbn1Ds + the cross-term.
2011-08-11 Andy Buckley <andy@insectnation.org>
* Various typo fixes and comments relating to persistency
constructors, Histo2D slicing, etc.
* Changing the HistoBin1D state-setting constructors (aargh, these
should *not* have already existed) to take Dbn1D as an argument
rather than a long list of doubles.
2011-08-01 Andy Buckley <andy@insectnation.org>
* Adding tests to check that implicit construction of Weights
objects from literal doubles and ints works.
2011-07-28 Andy Buckley <andy@insectnation.org>
* Bumping version number to 0.4.0beta0 -- there have been
substantial changes recently and YODA is now in a state where it
should be interesting for outsiders to start playing with it.
* Templating the Axis1D on the distribution type to be used for
total and under/overflow statistics: Profile1D now has Dbn2D
objects handling its total and overflow statistics.
2011-07-26 Andy Buckley <andy@insectnation.org>
* Added a Histo1D::integral(index1, index2) method. Not sure how
or if to extend this to Profile1D.
* Implementing incomplete Scatter2D operator+ and operator-
functions.
2011-07-25 Andy Buckley <andy@insectnation.org>
* Adding a Weights class, designed to seamlessly replace
double-type weights and weighted moments with a named and
vectorised form.
2011-07-19 Andy Buckley <andy@insectnation.org>
* Add Profile1D and Scatter2D division operators.
* Add xMin/xMax synonyms to the Axis1D, cf. the bins.
2011-07-18 Andy Buckley <andy@insectnation.org>
* Add a first stab at a Histo1D/Histo1D division operator.
2011-07-10 Andy Buckley <andy@insectnation.org>
* Add construction of Histo1Ds from Profile1D and Histo1D, and
construction of Profile1Ds from those and Scatter2D.
2011-07-07 Andy Buckley <andy@insectnation.org>
* Add construction of a Histo1D from Scatter2D.
2011-06-15 Andy Buckley <andy@insectnation.org>
* Making the AIDA reader work, including reading of annotations
and a few tweaks to the simple type persistency system. Test histo
1b updated.
2011-06-12 Andy Buckley <andy@insectnation.org>
* Removing Histo1D::area
* Filling and using under/overflow and total db on Histo1D, and
adding boolean arg to integral, sumW, etc.
* Fixing for C++ change in behaviour of std::make_pair
* Adding addAnnotation, and mapping annotations to Python.
2011-02-22 Andy Buckley <andy@insectnation.org>
* Use distutils rather than setuptools for the Python interface
build.
* Renaming Bin, HistoBin and ProfileBin to be Bin1D, HistoBin1D,
ProfileBin1D. Bin is now a top-level abstract class with minimal
functionality to be shared between 1D and 2D bins.
2011-01-12 Andy Buckley <andy@insectnation.org>
* Type annotations in mkScatter
* Added many vector constructors and addPoint functions to
Scatter2D.
2011-01-11 Andy Buckley <andy@insectnation.org>
* Add lexical_cast support to annotation get and set functions.
* Write out annotations in AIDA format, and copy annotations in
mkScatter -- using a new AnalysisObject::setAnnotations method.
* Convert DPS output to use interim Scatter construction
* Make (unused) yoda.plot subpackage.
* Write out annotations in YODA format.
* Make Scatter2D representations of Histo1D and Profile1D.
* Write out Scatter2D objects in AIDA and YODA formats.
* Make Scatter2D and Point2D work. Add a few extra
methods... evolution and tweaking required.
2011-01-10 Andy Buckley <andy@insectnation.org>
* Add Boost checks and header includes. Not used yet.
* Hide Utils:: content from Doxygen and nvector -> Utils::nvector.
* Removing unused YAML stuff: we aren't going that way for
persistency anymore.
* Renaming Axis -> Axis1D
* Removing dead-end templated Scatter stuff.
* Move (generated) config files into the Config subdir.
* Move sortedvector and indexedset into the Utils dir.
* Move the "utils" directory and namespace to "Utils"
* Put the Doxyfile under configure control by moving it to
Doxyfile.in and using the @PACKAGE_VERSION@ token.
* Make Doxygen find the .icc file and hide functions with name _*
and in the YAML namespace.
* Removing the Binning argument and enum in favour of explicit bin
edge vectors, possibly produced explicitly via the MathUtils
linspace and logspace functions, or the new Axis::mkBinEdgesLin/Log
alias functions.
* Fixed Axis, Histo1D and Profile1D constructors, by adding a path
argument, passing the path and title args to the AnalysisObject
base constructor properly.
* Removed several old and unused files such as Tree.h
2011-01-09 Andy Buckley <andy@insectnation.org>
* Updating copyright comments to be valid into 2011.
* Persistency fixes, and changing the interface to use the annotated path.
* Using annotations for path and title.
* Adding tests of collection and iterator range AO writing.
* Adding static write functions on Writer*.h implementations to
avoid needing to make an explicit Writer object via the create()
functions.
* Rename Exception.h -> Exceptions.h
* Added AnnotationError.
* Re-enable persistency of collections with begin/end iterators.
2011-01-08 Andy Buckley <andy@insectnation.org>
* Enabling quiet compilation.
* More annotation functionality.
2011-01-07 Andy Buckley <andy@insectnation.org>
* Sorting out autoheaders to be more useful.
* Rewriting AIDA writer to use DPS representation (no reloading)
for Histo1D and Profile1D objects.
* Adding persistency system hooks, since RTTI just sucks too much.
* Renaming test files to have more meaningful names.
2010-12-10 Andy Buckley <andy@insectnation.org>
* Some tweaks to Axis, Bin, etc. to use the sortedvector. Seems to
be working! (I must be checking it wrongly...)
* Adding another candidate object for the axis bin container: a
sorted extension to STL std::vector with an insert method. This
will do as a development placeholder: a proper sorted & indexed
container may be substituted later.
* Fix test code: titles are no longer given as histogram
constructor arguments.
2010-11-21 Andy Buckley <andy@insectnation.org>
* Adding indexed set for holding bins on axes. Still not sure it's
what we want, as (I just realised) STL sets are iterator-immutable
because they are self-keyed and changes to elements would also
change their sorting.
2010-09-19 Andy Buckley <andy@insectnation.org>
* Restarting ChangeLog contributions! Many changes in the huge
time since last update... activity on YODA has renewed and we have
a better picture of the distinctive features we require. New idea:
named weight vector filling, allowing "parallel" histograms for
various event weight variations. I/O remains an awkward issue,
especially since the classes are now much richer than they used to
be, and don't know about paths. Output can be easily put on top:
not an issue... and we can probably do something with
pickling. But reading in from C++?
2008-09-16 Andy Buckley <andy@insectnation.org>
* Moved duplicate Histo1D/Profile1D code on to Axis, making Axis a
templated class at the same time.
2008-09-12 Andy Buckley <andy@insectnation.org>
* Started work on a little plotting tool, initially for Herwig++
parton pT cut testing, but incrementally enhancing it to be a
command-line quick plotter seems like a good idea.
* Added some more test programs... working towards a proper test
suite.
* Added "no path & title" constructors - you don't always want to
write out the histo, since sometimes it's just a good way to
gather statistics.
* Fixed YODA mapping to allow use of vectors of bins as Python
lists.
* Added Profile1D functionality.
* Fixed Dbn1D to use sign(weight) as part of the "w**2" measure,
so that negative weights behave themselves.
2008-05-23 Andy Buckley <andy@insectnation.org>
* Added Dbn1D class to centralise the calculation of statistics
from unbounded, unbinned, weighted distributions.
2008-05-15 Andy Buckley <andy@insectnation.org>
* Added Profile1D class.
* Fixed NaN errors from zero weights.
2008-04-14 Andy Buckley <andy@insectnation.org>
* Python SWIG interface now compiles and can be used: the subtlety
that was breaking it was that SWIG has to be prodded in pretty
non-obvious ways to make std::vectors of classes without
default (no-arg) constructors. See
http://osdir.com/ml/programming.swig/2004-04/msg00011.html for
about the only reference to this to be found anywhere!
* Basic AIDA writer now available - it doesn't yet output all the
necessary information though, especially not for merging parallel
runs.
diff --git a/include/YODA/Axis1D.h b/include/YODA/Axis1D.h
--- a/include/YODA/Axis1D.h
+++ b/include/YODA/Axis1D.h
@@ -1,599 +1,604 @@
#ifndef YODA_Axis1D_h
#define YODA_Axis1D_h
#include "YODA/AnalysisObject.h"
#include "YODA/Exceptions.h"
#include "YODA/Bin.h"
#include "YODA/Utils/MathUtils.h"
#include "YODA/Utils/BinSearcher.h"
#include <limits>
#include <string>
namespace YODA {
/// @brief 1D bin container
///
/// This class handles most of the low-level operations on an axis of bins
/// arranged in a 1D line (including gaps).
template <typename BIN1D, typename DBN>
class Axis1D {
public:
/// Typedefs
//@{
/// Bin type
typedef BIN1D Bin;
/// A vector containing 1D bins. Not used for searching.
typedef typename std::vector<Bin> Bins;
//@}
/// @name Constructors
//@{
/// Empty constructor
Axis1D()
: _locked(false)
{ }
/// Constructor accepting a list of bin edges
Axis1D(const std::vector<double>& binedges)
: _locked(false)
{
addBins(binedges);
}
/// @brief Constructor accepting a vector of bins.
///
/// Note that not only dimensions of these bins will be set,
/// all the contents of the bins will be copied across, including
/// the statistics
Axis1D(const std::vector<BIN1D>& bins)
: _locked(false)
{
addBins(bins);
}
/// Constructor with the number of bins and the axis limits
/// @todo Rewrite interface to use a pair for the low/high
Axis1D(size_t nbins, double lower, double upper)
: _locked(false)
{
addBins(linspace(nbins, lower, upper));
}
/// @brief Constructor accepting a vector of bins.
///
/// Note that not only dimensions of these bins will be set,
/// all the contents of the bins will be copied across, including
/// the statistics
Axis1D(const Bins& bins, const DBN& dbn_tot, const DBN& dbn_uflow, const DBN& dbn_oflow)
: _dbn(dbn_tot), _underflow(dbn_uflow), _overflow(dbn_oflow), _locked(false)
{
addBins(bins);
}
/// @name Statistics accessor functions
//@{
/// Get the number of bins on the axis
size_t numBins() const {
return bins().size();
}
/// Return a vector of bins (const)
const Bins& bins() const {
return _bins;
}
/// Return a vector of bins (non-const)
Bins& bins() {
return _bins;
}
/// Return the lowest-value bin edge on the axis
double xMin() const {
if (numBins() == 0) throw RangeError("This axis contains no bins and so has no defined range");
return bins().front().xMin();
}
/// Return the highest-value bin edge on the axis
double xMax() const {
if (numBins() == 0) throw RangeError("This axis contains no bins and so has no defined range");
return bins().back().xMax();
}
/// Return all the Nbin+1 bin edges on the axis
///
/// @note This only returns the finite edges, i.e. -inf and +inf are removed
/// @todo Make the +-inf stripping controllable by a default-valued bool arg
std::vector<double> xEdges() const {
std::vector<double> rtn(_binsearcher.edges().begin()+1, _binsearcher.edges().end()-1);
return rtn;
}
/// Return a bin at a given index (non-const)
BIN1D& bin(size_t index) {
if (index >= numBins()) throw RangeError("YODA::Histo1D: index out of range!");
return _bins[index];
}
/// Return a bin at a given index (const)
const BIN1D& bin(size_t index) const {
if (index >= numBins()) throw RangeError("YODA::Histo1D: index out of range!");
return _bins[index];
}
/// Returns an index of a bin at a given coord, -1 if no bin matches
ssize_t binIndexAt(double coord) const {
// Yes, this is robust even with an empty axis: there's always at least one outflow
return _indexes[_binsearcher.index(coord)];
}
/// Return a bin at a given coordinate (non-const)
BIN1D& binAt(double x) {
const ssize_t index = binIndexAt(x);
if (index == -1) throw RangeError("There is no bin at the specified x");
return bin(index);
}
/// Return a bin at a given coordinate (const)
const BIN1D& binAt(double x) const {
const ssize_t index = binIndexAt(x);
if (index == -1) throw RangeError("There is no bin at the specified x");
return bin(index);
}
/// Return the total distribution (const)
const DBN& totalDbn() const {
return _dbn;
}
/// Return the total distribution (non-const)
DBN& totalDbn() {
return _dbn;
}
/// Set the total distribution: CAREFUL!
void setTotalDbn(const DBN& dbn) {
_dbn = dbn;
}
/// Return underflow (const)
const DBN& underflow() const {
return _underflow;
}
/// Return underflow (non-const)
DBN& underflow() {
return _underflow;
}
/// Set the underflow distribution: CAREFUL!
void setUnderflow(const DBN& dbn) {
_underflow = dbn;
}
/// Return overflow (const)
const DBN& overflow() const {
return _overflow;
}
/// Return overflow (non-const)
DBN& overflow() {
return _overflow;
}
/// Set the overflow distribution: CAREFUL!
void setOverflow(const DBN& dbn) {
_overflow = dbn;
}
//@}
/// @name Modifiers and helpers
//@{
/// Reset all the bin statistics on the axis
void reset() {
_dbn.reset();
_underflow.reset();
_overflow.reset();
BOOST_FOREACH(Bin& bin, _bins) bin.reset();
_locked = false;
}
/// Set the axis lock state
void _setLock(bool locked) {
_locked = locked;
}
/// Get lists of Nbins+1 edges, and Nbins+2 indices (-1 for gaps) from the current binning
/// @todo Push this into an abstract Binning object in v2?
/// @todo Should be a const ref arg?
std::pair< std::vector<double>, std::vector<long> > _mk_edges_indexes(Bins& bins) const {
std::vector<double> edges; edges.reserve(bins.size()+1); // Nbins+1 edges
std::vector<long> indexes; edges.reserve(bins.size()+2); // Nbins + 2*outflows
// Sort the bins
std::sort(bins.begin(), bins.end());
// Keep a note of the last high edge
double last_high = -std::numeric_limits<double>::infinity();
// Check for overlaps
for (size_t i = 0; i < bins.size(); ++i) {
Bin& currentBin = bins[i];
const double new_low = currentBin.xMin();
const double reldiff = (new_low - last_high) / currentBin.xWidth();
if (reldiff < -1e-3) { //< @note If there is a "large" negative gap (i.e. overlap), throw an exception
std::stringstream ss;
ss << "Bin edges overlap: " << last_high << " -> " << new_low;
throw RangeError(ss.str());
} else if (reldiff > 1e-3) { //< @note If there is a "large" positive gap, create a bin gap
indexes.push_back(-1); // First index will be for underflow
edges.push_back(new_low); // Will include first edge
}
// Bins check that they are not zero or negative width. It's okay for
// them to throw an exception here, as we haven't changed anything yet.
indexes.push_back(i);
edges.push_back(currentBin.xMax());
last_high = currentBin.xMax();
}
indexes.push_back(-1); // Overflow
return std::make_pair(edges, indexes);
}
/// Merge together the bin range with indices from @a from to @a to, inclusive.
/// Merge a series of bins, between the bins identified by indices @a from and @a to
void mergeBins(size_t from, size_t to) {
// Correctness checking
if (from >= numBins())
throw RangeError("Initial merge index is out of range");
if (to >= numBins())
throw RangeError("Final merge index is out of range");
if (from > to)
throw RangeError("Final bin must be greater than or equal to initial bin");
if (_gapInRange(from, to))
throw RangeError("Bin ranges containing gaps cannot be merged");
if (from == to)
return; // nothing to be done
Bin& b = bin(from);
for (size_t i = from + 1; i <= to; ++i)
b.merge(_bins[i]);
eraseBins(from+1, to);
}
- /// @brief Merge every group of @a n bins, starting from the LHS
+ /// @brief Merge every group of @a n bins, from start to end inclusive
///
/// If the number of bins is not a multiple of @a n, the last @a m < @a n
/// bins on the RHS will also be merged, as the closest possible approach to
/// factor @n rebinning everywhere.
- void rebinBy(unsigned int n) {
- for (size_t m = 0; m < numBins(); ++m) {
- const size_t end = (m + n - 1 < numBins()) ? m + n -1 : numBins() - 1;
- if (end > m) mergeBins(m, end);
+ void rebinBy(unsigned int n, size_t begin=0, size_t end=UINT_MAX) {
+ if (n < 1) throw UserError("Rebinning requested in groups of 0!");
+ for (size_t m = begin; m < end; ++m) {
+ if (m > numBins()) break;
+ const size_t myend = (m+n-1 < numBins()) ? m+n-1 : numBins()-1;
+ if (myend > m) {
+ mergeBins(m, myend);
+ end -= myend-m; //< reduce upper index by the number of removed bins
+ }
}
}
/// @brief Overloaded alias for rebinBy
- void rebin(unsigned int n) { rebinBy(n); }
+ void rebin(unsigned int n, size_t begin=0, size_t end=UINT_MAX) { rebinBy(n, begin, end); }
/// @brief Rebin to the given list of bin edges
void rebinTo(const std::vector<double>& newedges) {
if (newedges.size() < 2)
throw UserError("Requested rebinning to an edge list which defines no bins");
const Utils::BinSearcher newbs(newedges);
const std::vector<double> eshared = newbs.shared_edges(_binsearcher);
if (eshared.size() != newbs.size())
throw BinningError("Requested rebinning to incompatible edges");
// std::cout << "Before merging" << std::endl;
// BOOST_FOREACH (double x, _binsearcher.edges()) std::cout << x << std::endl;
// If the new min finite edge isn't the same, merge it into the underflow
// NB. Edge search match the *next* bin, so step back one unit... and note these are BinSearcher indices, i.e. i+1
if (!fuzzyEquals(xMin(), newedges.front())) {
const size_t kmatch = _binsearcher.index(newedges.front()) - 1;
mergeBins(0, kmatch-1);
_underflow += bin(0).dbn();
eraseBin(0);
}
// std::cout << "Merged start bins" << std::endl;
// BOOST_FOREACH (double x, _binsearcher.edges()) std::cout << x << std::endl;
// Now the same for the overflow
if (!fuzzyEquals(xMax(), newedges.back())) {
const size_t kmatch = _binsearcher.index(newedges.back()) - 1;
// std::cout << newedges.back() << " -> " << kmatch << " .. " << _bins.size()-1 << " / " << numBins() << std::endl;
mergeBins(kmatch, _bins.size()-1);
_overflow += bin(_bins.size()-1).dbn();
eraseBin(_bins.size()-1);
}
// std::cout << "Merged end bins" << std::endl;
// BOOST_FOREACH (double x, _binsearcher.edges()) std::cout << x << std::endl;
// Now merge the in-range bins
size_t jcurr = 0;
for (size_t i = 1; i < newedges.size(); ++i) { //< we already know that i=0 matches (until we support merging into overflows)
const size_t kmatch = _binsearcher.index(newedges.at(i)) - 1; //< Will match the *next* bin, so step back one unit... and note these are BinSearcher indices
assert(kmatch >= jcurr+1);
mergeBins(jcurr, kmatch-1);
jcurr += 1; //< The next bin to be merged, in the new numbering
}
// std::cout << "After merging" << std::endl;
// BOOST_FOREACH (double x, _binsearcher.edges()) std::cout << x << std::endl;
}
/// @brief Overloaded alias for rebinTo
void rebin(const std::vector<double>& newedges) { rebinTo(newedges); }
/// Add a bin, passed explicitly
void addBin(const Bin& b) {
/// @todo Efficiency?
Bins newBins(_bins);
newBins.push_back(b);
_updateAxis(newBins);
}
/// Add a bin, providing its low and high edge
void addBin(double low, double high) {
addBin(Bin(low, high));
}
/// Add a contiguous set of bins to an axis, via their list of edges
void addBins(const std::vector<double>& binedges) {
Bins newBins(_bins);
if (binedges.size() == 0) return;
double low = binedges.front();
for (size_t i = 1; i < binedges.size(); ++i) {
const double high = binedges[i];
newBins.push_back(Bin(low, high));
low = high;
}
_updateAxis(newBins);
}
/// Add a list of bins as pairs of lowEdge, highEdge
void addBins(const std::vector<std::pair<double, double> >& binpairs) {
// Make a copy of the current binning
Bins newBins(_bins);
// Iterate over given bins
for (size_t i = 0; i < binpairs.size(); ++i) {
std::pair<double, double> b = binpairs[i];
newBins.push_back(Bin(b.first, b.second));
}
_updateAxis(newBins);
}
/// Add a list of Bin objects
void addBins(const Bins& bins) {
Bins newBins(_bins);
BOOST_FOREACH(const Bin& b, bins) newBins.push_back(b);
_updateAxis(newBins);
}
/// Remove a bin
void eraseBin(const size_t i) {
// Might as well erase from the internal bins, as we can guarantee
// consistency.
if (i >= numBins())
throw RangeError("Bin index is out of range");
const bool wasLocked = _locked;
_locked = false;
_bins.erase(_bins.begin() + i);
_updateAxis(_bins);
_locked = wasLocked;
}
/// Remove a bin range
void eraseBins(const size_t from, const size_t to) {
if (from >= numBins())
throw RangeError("Initial index out of range");
if (to >= numBins())
throw RangeError("Final index out of range");
if (from > to)
throw RangeError("Final index is less than initial index");
const bool wasLocked = _locked;
_locked = false;
_bins.erase(_bins.begin() + from, _bins.begin() + to + 1);
_updateAxis(_bins);
_locked = wasLocked;
}
/// Scale the size of an axis by a factor
// @todo What if somebody passes in negative scalefactor? (test idea)
void scaleX(double scalefactor) {
_dbn.scaleX(scalefactor);
_underflow.scaleX(scalefactor);
_overflow.scaleX(scalefactor);
for (size_t i = 0; i < _bins.size(); ++i)
_bins[i].scaleX(scalefactor);
_updateAxis(_bins);
}
/// Scale the amount of fills by a factor
void scaleW(double scalefactor) {
_dbn.scaleW(scalefactor);
_underflow.scaleW(scalefactor);
_overflow.scaleW(scalefactor);
for (size_t i = 0; i < _bins.size(); ++i) _bins[i].scaleW(scalefactor);
}
//@}
/// @name Comparisons to other Axis objects
//@{
bool sameBinning(const Axis1D& other) const {
if (numBins() != other.numBins()) return false;
if (_indexes != other._indexes) return false;
return _binsearcher.same_edges(other._binsearcher);
}
bool subsetBinning(const Axis1D& other) const {
const int ndiff = numBins() - other.numBins();
if (ndiff == 0) return sameBinning(other);
/// @todo Do we require the finite axis begin/end to be the same?
return !_binsearcher.shared_edges(other._binsearcher).empty();
}
//@}
/// @name Operators
//@{
/// Check if two of the Axis have the same binning, within numeric tolerance
bool operator == (const Axis1D& other) const {
return sameBinning(other);
}
/// Check if the binning of two of the Axis is different
bool operator != (const Axis1D& other) const {
return ! operator == (other);
}
/// Add two axes together
Axis1D<BIN1D,DBN>& operator += (const Axis1D<BIN1D,DBN>& toAdd) {
if (*this != toAdd) throw LogicError("YODA::Histo1D: Cannot add axes with different binnings.");
for (size_t i = 0; i < _bins.size(); ++i) {
_bins[i] += toAdd.bins().at(i);
}
_dbn += toAdd._dbn;
_underflow += toAdd._underflow;
_overflow += toAdd._overflow;
return *this;
}
/// Subtract two axes
Axis1D<BIN1D,DBN>& operator -= (const Axis1D<BIN1D,DBN>& toSubtract) {
if (*this != toSubtract) throw LogicError("YODA::Histo1D: Cannot add axes with different binnings.");
for (size_t i = 0; i < _bins.size(); ++i) {
_bins[i] -= toSubtract.bins().at(i);
}
_dbn -= toSubtract._dbn;
_underflow -= toSubtract._underflow;
_overflow -= toSubtract._overflow;
return *this;
}
//@}
private:
/// Sort the given bins vector, and regenerate the bin searcher
//
/// The bin searcher is purely for searching, and is generated from
/// the bins list only.
void _updateAxis(Bins& bins) {
// Ensure that axis is not locked
if (_locked) {
throw LockError("Attempting to update a locked axis");
}
// Get the new cuts and indexes (throws if overlaps), and set them on the searcher
const std::pair< std::vector<double>, std::vector<long> > es_is = _mk_edges_indexes(bins);
_binsearcher = Utils::BinSearcher(es_is.first);
_indexes = es_is.second;
_bins = bins;
}
/// Check if there are any gaps in the axis' binning between bin indices @a
/// from and @a to, inclusive.
bool _gapInRange(size_t ifrom, size_t ito) const {
if (ifrom == ito) return false;
assert(ito < numBins() && ifrom < ito);
/// @todo Why do we need to re-find the bin indices?
const size_t from_ix = _binsearcher.index(bin(ifrom).xMid());
const size_t to_ix = _binsearcher.index(bin(ito).xMid());
// std::cout << ifrom << " vs. " << from_ix << std::endl;
// std::cout << ito << " vs. " << to_ix << std::endl;
for (size_t i = from_ix; i <= to_ix; i++)
// for (size_t i = ifrom; i <= ito; i++)
if (_indexes[i] == -1) return true;
return false;
}
private:
/// @name Data structures
//@{
/// Bins vector
Bins _bins;
/// Total distribution
DBN _dbn;
/// Under- and overflows
DBN _underflow;
DBN _overflow;
// Binsearcher, for searching bins
Utils::BinSearcher _binsearcher;
// Mapping from binsearcher indices to bin indices (allowing gaps)
std::vector<long> _indexes;
/// Whether modifying bin edges is permitted
bool _locked;
//@}
};
/// Add the statistics on two axes.
template <typename BIN1D, typename DBN>
inline Axis1D<BIN1D,DBN> operator + (const Axis1D<BIN1D,DBN>& first, const Axis1D<BIN1D,DBN>& second) {
Axis1D<BIN1D,DBN> tmp = first;
tmp += second;
return tmp;
}
/// Subtract the statistics on two axis.
template <typename BIN1D, typename DBN>
inline Axis1D<BIN1D,DBN> operator - (const Axis1D<BIN1D,DBN>& first, const Axis1D<BIN1D,DBN>& second) {
Axis1D<BIN1D,DBN> tmp = first;
tmp -= second;
return tmp;
}
}
#endif
diff --git a/include/YODA/Histo1D.h b/include/YODA/Histo1D.h
--- a/include/YODA/Histo1D.h
+++ b/include/YODA/Histo1D.h
@@ -1,515 +1,515 @@
// -*- C++ -*-
//
// This file is part of YODA -- Yet more Objects for Data Analysis
// Copyright (C) 2008-2015 The YODA collaboration (see AUTHORS for details)
//
#ifndef YODA_Histo1D_h
#define YODA_Histo1D_h
#include "YODA/AnalysisObject.h"
#include "YODA/HistoBin1D.h"
#include "YODA/Dbn1D.h"
#include "YODA/Scatter2D.h"
#include "YODA/Axis1D.h"
#include "YODA/Exceptions.h"
#include <vector>
#include <string>
#include <map>
namespace YODA {
/// Convenience typedef
typedef Axis1D<HistoBin1D, Dbn1D> Histo1DAxis;
/// A one-dimensional histogram.
class Histo1D : public AnalysisObject {
public:
/// Convenience typedefs
typedef Histo1DAxis Axis;
typedef Axis::Bins Bins;
typedef HistoBin1D Bin;
/// @name Constructors
//@{
/// Default constructor
Histo1D(const std::string& path="", const std::string& title="")
: AnalysisObject("Histo1D", path, title),
_axis()
{ }
/// Constructor giving range and number of bins.
Histo1D(size_t nbins, double lower, double upper,
const std::string& path="", const std::string& title="")
: AnalysisObject("Histo1D", path, title),
_axis(nbins, lower, upper)
{ }
/// @brief Constructor giving explicit bin edges.
///
/// For n bins, binedges.size() == n+1, the last one being the upper bound
/// of the last bin
Histo1D(const std::vector<double>& binedges,
const std::string& path="", const std::string& title="")
: AnalysisObject("Histo1D", path, title),
_axis(binedges)
{ }
/// Constructor accepting an explicit collection of bins.
Histo1D(const std::vector<Bin>& bins,
const std::string& path="", const std::string& title="")
: AnalysisObject("Histo1D", path, title),
_axis(bins)
{ }
/// Copy constructor with optional new path
/// @todo Also allow title setting from the constructor?
Histo1D(const Histo1D& h, const std::string& path="");
/// Constructor from a Scatter2D's binning, with optional new path
/// @todo Also allow title setting from the constructor?
Histo1D(const Scatter2D& s, const std::string& path="");
/// Constructor from a Profile1D's binning, with optional new path
/// @todo Also allow title setting from the constructor?
Histo1D(const Profile1D& p, const std::string& path="");
/// @brief State-setting constructor
///
/// Intended principally for internal persistency use.
Histo1D(const std::vector<HistoBin1D>& bins,
const Dbn1D& dbn_tot, const Dbn1D& dbn_uflow, const Dbn1D& dbn_oflow,
const std::string& path="", const std::string& title="")
: AnalysisObject("Histo1D", path, title),
_axis(bins, dbn_tot, dbn_uflow, dbn_oflow)
{ }
/// Assignment operator
Histo1D& operator = (const Histo1D& h1) {
AnalysisObject::operator = (h1); //< AO treatment of paths etc.
_axis = h1._axis;
return *this;
}
/// Make a copy on the stack
Histo1D clone() const {
return Histo1D(*this);
}
/// Make a copy on the heap, via 'new'
Histo1D* newclone() const {
return new Histo1D(*this);
}
//@}
/// Fill dimension of this data object
size_t dim() const { return 1; }
/// @name Modifiers
//@{
/// @brief Reset the histogram.
///
/// Keep the binning but set all bin contents and related quantities to zero
virtual void reset() {
_axis.reset();
}
/// Fill histo by value and weight
void fill(double x, double weight=1.0);
/// Fill histo bin i with the given weight
void fillBin(size_t i, double weight=1.0);
/// Rescale as if all fill weights had been different by factor @a scalefactor.
void scaleW(double scalefactor) {
setAnnotation("ScaledBy", annotation<double>("ScaledBy", 1.0) * scalefactor);
_axis.scaleW(scalefactor);
}
/// Normalize the (visible) histo area to the @a normto value.
///
/// If @a includeoverflows is true, the original normalisation is computed with
/// the overflow bins included, so that the resulting visible normalisation can
/// be less than @a normto. This is probably what you want.
void normalize(double normto=1.0, bool includeoverflows=true) {
const double oldintegral = integral(includeoverflows);
if (oldintegral == 0) throw WeightError("Attempted to normalize a histogram with null area");
/// @todo Check that this is the desired behaviour
scaleW(normto / oldintegral);
}
/// Merge together the bin range with indices from @a from to @a to, inclusive
void mergeBins(size_t from, size_t to) {
_axis.mergeBins(from, to);
}
/// Merge every group of n bins, starting from the LHS
- void rebinBy(unsigned int n) {
- _axis.rebinBy(n);
+ void rebinBy(unsigned int n, size_t begin=0, size_t end=UINT_MAX) {
+ _axis.rebinBy(n, begin, end);
}
/// Overloaded alias for rebinBy
- void rebin(unsigned int n) {
- rebinBy(n);
+ void rebin(unsigned int n, size_t begin=0, size_t end=UINT_MAX) {
+ rebinBy(n, begin, end);
}
/// Rebin to the given list of bin edges
void rebinTo(const std::vector<double>& newedges) {
_axis.rebinTo(newedges);
}
/// Overloaded alias for rebinTo
void rebin(const std::vector<double>& newedges) {
rebinTo(newedges);
}
//@}
public:
/// @name Bin accessors
//@{
/// Number of bins on this axis (not counting under/overflow)
size_t numBins() const { return bins().size(); }
/// Low edge of this histo's axis
double xMin() const { return _axis.xMin(); }
/// High edge of this histo's axis
double xMax() const { return _axis.xMax(); }
/// All bin edges on this histo's axis
///
/// @note This only returns the finite edges, i.e. -inf and +inf are removed
/// @todo Make the +-inf stripping controllable by a default-valued bool arg
const std::vector<double> xEdges() const { return _axis.xEdges(); }
/// Access the bin vector
std::vector<YODA::HistoBin1D>& bins() { return _axis.bins(); }
/// Access the bin vector (const version)
const std::vector<YODA::HistoBin1D>& bins() const { return _axis.bins(); }
/// Access a bin by index (non-const version)
HistoBin1D& bin(size_t index) { return _axis.bins()[index]; }
/// Access a bin by index (const version)
const HistoBin1D& bin(size_t index) const { return _axis.bins()[index]; }
/// Access a bin index by coordinate
/// @todo Convert to ssize_t?
int binIndexAt(double x) {
return _axis.binIndexAt(x);
}
/// Access a bin by coordinate (const version)
const HistoBin1D& binAt(double x) const { return _axis.binAt(x); }
/// Access summary distribution, including gaps and overflows (non-const version)
Dbn1D& totalDbn() { return _axis.totalDbn(); }
/// Access summary distribution, including gaps and overflows (const version)
const Dbn1D& totalDbn() const { return _axis.totalDbn(); }
/// Set summary distribution, mainly for persistency: CAREFUL!
void setTotalDbn(const Dbn1D& dbn) { _axis.setTotalDbn(dbn); }
/// Access underflow (non-const version)
Dbn1D& underflow() { return _axis.underflow(); }
/// Access underflow (const version)
const Dbn1D& underflow() const { return _axis.underflow(); }
/// Set underflow distribution, mainly for persistency: CAREFUL!
void setUnderflow(const Dbn1D& dbn) { _axis.setUnderflow(dbn); }
/// Access overflow (non-const version)
Dbn1D& overflow() { return _axis.overflow(); }
/// Access overflow (const version)
const Dbn1D& overflow() const { return _axis.overflow(); }
/// Set overflow distribution, mainly for persistency: CAREFUL!
void setOverflow(const Dbn1D& dbn) { _axis.setOverflow(dbn); }
/// Add a new bin specifying its lower and upper bound
void addBin(double from, double to) { _axis.addBin(from, to); }
/// Add new bins by specifying a vector of edges
void addBins(std::vector<double> edges) { _axis.addBins(edges); }
// /// Add new bins specifying a beginning and end of each of them
// void addBins(std::vector<std::pair<double,double> > edges) {
// _axis.addBins(edges);
// }
/// Add a new bin, perhaps already populated: CAREFUL!
void addBin(const HistoBin1D& b) { _axis.addBin(b); }
/// @brief Bins addition operator
///
/// Add multiple bins without resetting
void addBins(const Bins& bins) {
_axis.addBins(bins);
}
/// Remove a bin
void eraseBin(size_t index) { _axis.eraseBin(index); }
//@}
/// @name Whole histo data
//@{
/// Get the total area (sumW) of the histogram
double integral(bool includeoverflows=true) const { return sumW(includeoverflows); }
/// @brief Get the integrated area of the histogram between bins @a binindex1 and @a binindex2.
///
/// @note The area of bin @a binindex2 _is_ included in the returned
/// value. To include the underflow and overflow areas, you should add them
/// explicitly with the underflow() and overflow() methods.
///
/// @todo Allow int bin index args for type compatibility with binIndexAt()?
double integralRange(size_t binindex1, size_t binindex2) const {
assert(binindex2 >= binindex1);
if (binindex1 >= numBins()) throw RangeError("binindex1 is out of range");
if (binindex2 >= numBins()) throw RangeError("binindex2 is out of range");
double rtn = 0;
for (size_t i = binindex1; i < binindex2; ++i) {
rtn += bin(i).sumW();
}
return rtn;
}
/// @brief Get the integrated area of the histogram up to bin @a binindex.
///
/// @note The area of bin @a binindex _is_ included in the returned
/// value. To not include the underflow, set includeunderflow=false.
///
/// @todo Allow int bin index args for type compatibility with binIndexAt()?
double integralTo(size_t binindex, bool includeunderflow=true) const {
double rtn = includeunderflow ? underflow().sumW() : 0;
rtn += integralRange(0, binindex);
return rtn;
}
/// Get the number of fills
unsigned long numEntries(bool includeoverflows=true) const;
/// Get the effective number of fills
double effNumEntries(bool includeoverflows=true) const;
/// Get sum of weights in histo
double sumW(bool includeoverflows=true) const;
/// Get sum of squared weights in histo
double sumW2(bool includeoverflows=true) const;
/// Get the mean in x
double xMean(bool includeoverflows=true) const;
/// Get the variance in x
double xVariance(bool includeoverflows=true) const;
/// Get the standard deviation in x
double xStdDev(bool includeoverflows=true) const {
if (includeoverflows) return _axis.totalDbn().xStdDev();
return std::sqrt(xVariance(includeoverflows));
}
/// Get the standard error in x
double xStdErr(bool includeoverflows=true) const;
/// Get the RMS in x
double xRMS(bool includeoverflows=true) const;
//@}
/// @name Adding and subtracting histograms
//@{
/// @brief Add another histogram to this one
///
/// @note Adding histograms will unset any ScaledBy attribute from prevous calls to scaleW or normalize.
Histo1D& operator += (const Histo1D& toAdd) {
if (hasAnnotation("ScaledBy")) rmAnnotation("ScaledBy");
_axis += toAdd._axis;
return *this;
// if (!hasAnnotation("ScaledBy") && !toAdd.hasAnnotation("ScaledBy")) {
// _axis += toAdd._axis;
// } else {
// // Undo scaling of both histograms
// double scaledBy = annotation<double>("ScaledBy", 1.0);
// _axis.scaleW(1.0/scaledBy);
// double toAddScaledBy = toAdd.annotation<double>("ScaledBy", 1.0);
// Axis1D<HistoBin1D, Dbn1D> toAddAxis = toAdd._axis;
// toAddAxis.scaleW(1.0/toAddScaledBy);
// _axis += toAddAxis;
// // Re-apply combined scaling
// double newScaledBy = scaledBy*toAddScaledBy/(scaledBy+toAddScaledBy);
// _axis.scaleW(newScaledBy);
// setAnnotation("ScaledBy", newScaledBy);
// }
/// @todo What about if one histo sets ScaledBy, and the other doesn't?!? Aaaargh
// return *this;
}
/// @brief Subtract another histogram from this one
///
/// @note Subtracting histograms will unset any ScaledBy attribute from prevous calls to scaleW or normalize.
Histo1D& operator -= (const Histo1D& toSubtract) {
if (hasAnnotation("ScaledBy")) rmAnnotation("ScaledBy");
_axis -= toSubtract._axis;
return *this;
}
//@}
protected:
/// Access a bin by coordinate (non-const version)
HistoBin1D& binAt(double x) { return _axis.binAt(x); }
private:
/// @name Bin data
//@{
/// Definition of bin edges and contents
Axis1D<HistoBin1D, Dbn1D> _axis;
//@}
};
/// @name Combining histos: global operators
//@{
/// Add two histograms
inline Histo1D add(const Histo1D& first, const Histo1D& second) {
Histo1D tmp = first;
if (first.path() != second.path()) tmp.setPath("");
tmp += second;
return tmp;
}
/// Add two histograms
inline Histo1D operator + (const Histo1D& first, const Histo1D& second) {
return add(first, second);
}
/// Subtract two histograms
inline Histo1D subtract(const Histo1D& first, const Histo1D& second) {
Histo1D tmp = first;
if (first.path() != second.path()) tmp.setPath("");
tmp -= second;
return tmp;
}
/// Subtract two histograms
inline Histo1D operator - (const Histo1D& first, const Histo1D& second) {
return subtract(first, second);
}
/// @todo Add multiply(H1, H1) -> Scatter2D?
/// Divide two histograms, with an uncorrelated error treatment
///
/// @todo Wouldn't it be nice to be able to supply a correlation matrix or function as optional arg?
///
/// @note The two histos must have _exactly_ the same binning.
Scatter2D divide(const Histo1D& numer, const Histo1D& denom);
/// Divide two histograms, with an uncorrelated error treatment
///
/// @note The two histos must have _exactly_ the same binning.
inline Scatter2D operator / (const Histo1D& numer, const Histo1D& denom) {
return divide(numer, denom);
}
/// @todo Add functions/operators on pointers
/// @brief Calculate a histogrammed efficiency ratio of two histograms
///
/// @note The two histos must have _exactly_ the same binning.
///
/// @note An efficiency is not the same thing as a standard division of two
/// histograms: the errors are treated as correlated via binomial statistics.
Scatter2D efficiency(const Histo1D& accepted, const Histo1D& total);
/// @brief Calculate the asymmetry (a-b)/(a+b) of two histograms
///
/// @note The two histos must have _exactly_ the same binning.
inline Scatter2D asymm(const Histo1D& a, const Histo1D& b) {
return (a-b) / (a+b);
}
/// @brief Convert a Histo1D to a Scatter2D representing the integral of the histogram
///
/// @note The integral histo errors are calculated as sqrt(binvalue), as if they
/// are uncorrelated. This is not in general true for integral histograms, so if you
/// need accurate errors you should explicitly monitor bin-to-bin correlations.
///
/// The includeunderflow param chooses whether the underflow bin is included
/// in the integral numbers as an offset.
Scatter2D toIntegralHisto(const Histo1D& h, bool includeunderflow=true);
/// @brief Convert a Histo1D to a Scatter2D where each bin is a fraction of the total
///
/// @note This sounds weird: let's explain a bit more! Sometimes we want to
/// take a histo h, make an integral histogram H from it, and then divide H by
/// the total integral of h, such that every bin in H represents the
/// cumulative efficiency of that bin as a fraction of the total. I.e. an
/// integral histo, scaled by 1/total_integral and with binomial errors.
///
/// The includeunderflow param behaves as for toIntegral, and applies to both
/// the initial integration and the integral used for the scaling. The
/// includeoverflow param applies only to obtaining the scaling factor.
Scatter2D toIntegralEfficiencyHisto(const Histo1D& h, bool includeunderflow=true, bool includeoverflow=true);
//@}
}
#endif
diff --git a/include/YODA/Profile1D.h b/include/YODA/Profile1D.h
--- a/include/YODA/Profile1D.h
+++ b/include/YODA/Profile1D.h
@@ -1,402 +1,402 @@
// -*- C++ -*-
//
// This file is part of YODA -- Yet more Objects for Data Analysis
// Copyright (C) 2008-2015 The YODA collaboration (see AUTHORS for details)
//
#ifndef YODA_Profile1D_h
#define YODA_Profile1D_h
#include "YODA/AnalysisObject.h"
#include "YODA/ProfileBin1D.h"
#include "YODA/Scatter2D.h"
#include "YODA/Dbn2D.h"
#include "YODA/Axis1D.h"
#include "YODA/Exceptions.h"
#include <vector>
#include <string>
#include <map>
namespace YODA {
// Forward declarations
class Histo1D;
class Scatter2D;
/// Convenience typedef
typedef Axis1D<ProfileBin1D, Dbn2D> Profile1DAxis;
/// A one-dimensional profile histogram.
class Profile1D : public AnalysisObject {
public:
/// Convenience typedefs
typedef Profile1DAxis Axis;
typedef Axis::Bins Bins;
typedef ProfileBin1D Bin;
/// @name Constructors
//@{
/// Default constructor
Profile1D(const std::string& path="", const std::string& title="")
: AnalysisObject("Profile1D", path, title),
_axis()
{ }
/// Constructor giving range and number of bins
Profile1D(size_t nxbins, double xlower, double xupper,
const std::string& path="", const std::string& title="")
: AnalysisObject("Profile1D", path, title),
_axis(nxbins, xlower, xupper)
{ }
/// Constructor giving explicit bin edges
///
/// For n bins, binedges.size() == n+1, the last one being the upper bound
/// of the last bin
Profile1D(const std::vector<double>& xbinedges,
const std::string& path="", const std::string& title="")
: AnalysisObject("Profile1D", path, title),
_axis(xbinedges)
{ }
/// Copy constructor with optional new path
/// @todo Also allow title setting from the constructor?
Profile1D(const Profile1D& p, const std::string& path="");
/// Constructor from a Scatter2D's binning, with optional new path
/// @todo Also allow title setting from the constructor?
Profile1D(const Scatter2D& s, const std::string& path="");
/// Constructor from a Histo1D's binning, with optional new path
/// @todo Also allow title setting from the constructor?
Profile1D(const Histo1D& h, const std::string& path="");
/// @brief State-setting constructor.
///
/// Intended principally for internal persistency use.
Profile1D(const std::vector<ProfileBin1D>& bins,
const Dbn2D& dbn_tot, const Dbn2D& dbn_uflow, const Dbn2D& dbn_oflow,
const std::string& path="", const std::string& title="")
: AnalysisObject("Profile1D", path, title),
_axis(bins, dbn_tot, dbn_uflow, dbn_oflow)
{ }
/// Assignment operator
Profile1D& operator = (const Profile1D& p1) {
AnalysisObject::operator = (p1); //< AO treatment of paths etc.
_axis = p1._axis;
return *this;
}
/// Make a copy on the stack
Profile1D clone() const {
return Profile1D(*this);
}
/// Make a copy on the heap, via 'new'
Profile1D* newclone() const {
return new Profile1D(*this);
}
//@}
/// Fill dimension of this data object
size_t dim() const { return 1; }
/// @name Modifiers
//@{
/// Fill histo by value and weight
void fill(double x, double y, double weight=1.0);
/// Fill histo x bin i with the given y value and weight
void fillBin(size_t i, double y, double weight=1.0);
/// @brief Reset the histogram
///
/// Keep the binning but set all bin contents and related quantities to zero
void reset() {
_axis.reset();
}
/// Rescale as if all fill weights had been different by factor @a scalefactor.
void scaleW(double scalefactor) {
_axis.scaleW(scalefactor);
}
/// Rescale as if all y values had been different by factor @a scalefactor.
void scaleY(double scalefactor) {
_axis.totalDbn().scaleY(scalefactor);
_axis.overflow().scaleY(scalefactor);
_axis.underflow().scaleY(scalefactor);
for (size_t i = 0; i < bins().size(); ++i)
bin(i).scaleY(scalefactor);
}
/// Merge together the bin range with indices from @a from to @a to, inclusive
void mergeBins(size_t from, size_t to) {
_axis.mergeBins(from, to);
}
/// Merge every group of n bins, starting from the LHS
- void rebinBy(unsigned int n) {
- _axis.rebinBy(n);
+ void rebinBy(unsigned int n, size_t begin=0, size_t end=UINT_MAX) {
+ _axis.rebinBy(n, begin, end);
}
/// Overloaded alias for rebinBy
- void rebin(unsigned int n) {
- rebinBy(n);
+ void rebin(unsigned int n, size_t begin=0, size_t end=UINT_MAX) {
+ rebinBy(n, begin, end);
}
/// Rebin to the given list of bin edges
void rebinTo(const std::vector<double>& newedges) {
_axis.rebinTo(newedges);
}
/// Overloaded alias for rebinTo
void rebin(const std::vector<double>& newedges) {
rebinTo(newedges);
}
/// Bin addition operator
void addBin(double xlow, double xhigh) {
_axis.addBin(xlow, xhigh);
}
/// Bin addition operator
void addBins(const std::vector<double> binedges) {
_axis.addBins(binedges);
}
// /// Bin addition operator
// void addBins(const std::vector<std::pair<double,double> > edges) {
// _axis.addBins(edges);
// }
/// Add a new bin, perhaps already populated: CAREFUL!
void addBin(const ProfileBin1D& b) { _axis.addBin(b); }
/// @brief Bins addition operator
///
/// Add multiple bins without resetting
void addBins(const Bins& bins) {
_axis.addBins(bins);
}
//@}
/// @name Bin accessors
//@{
/// Number of bins on this axis (not counting under/overflow)
size_t numBins() const { return bins().size(); }
/// Low edge of this histo's axis
double xMin() const { return _axis.xMin(); }
/// High edge of this histo's axis
double xMax() const { return _axis.xMax(); }
/// All bin edges on this histo's axis
///
/// @note This only returns the finite edges, i.e. -inf and +inf are removed
/// @todo Make the +-inf stripping controllable by a default-valued bool arg
const std::vector<double> xEdges() const { return _axis.xEdges(); }
/// Access the bin vector
std::vector<YODA::ProfileBin1D>& bins() { return _axis.bins(); }
/// Access the bin vector
const std::vector<YODA::ProfileBin1D>& bins() const { return _axis.bins(); }
/// Access a bin by index (non-const version)
ProfileBin1D& bin(size_t index) { return _axis.bins()[index]; }
/// Access a bin by index (const version)
const ProfileBin1D& bin(size_t index) const { return _axis.bins()[index]; }
/// Access a bin index by x-coordinate.
int binIndexAt(double x) { return _axis.binIndexAt(x); }
/// Access a bin by x-coordinate (const version)
const ProfileBin1D& binAt(double x) const { return _axis.binAt(x); }
/// Access summary distribution, including gaps and overflows (non-const version)
Dbn2D& totalDbn() { return _axis.totalDbn(); }
/// Access summary distribution, including gaps and overflows (const version)
const Dbn2D& totalDbn() const { return _axis.totalDbn(); }
/// Set summary distribution, mainly for persistency: CAREFUL!
void setTotalDbn(const Dbn2D& dbn) { _axis.setTotalDbn(dbn); }
/// Access underflow (non-const version)
Dbn2D& underflow() { return _axis.underflow(); }
/// Access underflow (const version)
const Dbn2D& underflow() const { return _axis.underflow(); }
/// Set underflow distribution, mainly for persistency: CAREFUL!
void setUnderflow(const Dbn2D& dbn) { _axis.setUnderflow(dbn); }
/// Access overflow (non-const version)
Dbn2D& overflow() { return _axis.overflow(); }
/// Access overflow (const version)
const Dbn2D& overflow() const { return _axis.overflow(); }
/// Set overflow distribution, mainly for persistency: CAREFUL!
void setOverflow(const Dbn2D& dbn) { _axis.setOverflow(dbn); }
//@}
/// @name Whole histo data
//@{
/// @todo Add integrals? Or are they too ambiguous to make a core function?
/// Get the number of fills
unsigned long numEntries(bool includeoverflows=true) const;
/// Get the effective number of fills
double effNumEntries(bool includeoverflows=true) const;
/// Get sum of weights in histo.
double sumW(bool includeoverflows=true) const;
/// Get sum of squared weights in histo.
double sumW2(bool includeoverflows=true) const;
/// Get the mean x
double xMean(bool includeoverflows=true) const;
/// Get the variance in x
double xVariance(bool includeoverflows=true) const;
/// Get the standard deviation in x
double xStdDev(bool includeoverflows=true) const {
return std::sqrt(xVariance(includeoverflows));
}
/// Get the standard error on <x>
double xStdErr(bool includeoverflows=true) const;
/// Get the RMS in x
double xRMS(bool includeoverflows=true) const;
//@}
/// @name Adding and subtracting histograms
//@{
/// Add another profile to this one
Profile1D& operator += (const Profile1D& toAdd) {
if (hasAnnotation("ScaledBy")) rmAnnotation("ScaledBy");
_axis += toAdd._axis;
return *this;
}
/// Subtract another profile from this one
Profile1D& operator -= (const Profile1D& toSubtract) {
if (hasAnnotation("ScaledBy")) rmAnnotation("ScaledBy");
_axis -= toSubtract._axis;
return *this;
}
inline bool operator == (const Profile1D& other){
return _axis == other._axis;
}
inline bool operator != (const Profile1D& other){
return ! operator == (other);
}
//@}
protected:
/// Access a bin by x-coordinate (non-const version)
ProfileBin1D& binAt(double x) { return _axis.binAt(x); }
private:
/// @name Bin data
//@{
/// The bins contained in this profile histogram
Axis1D<ProfileBin1D, Dbn2D> _axis;
//@}
};
/// @name Combining profile histos: global operators
//@{
/// Add two profile histograms
inline Profile1D add(const Profile1D& first, const Profile1D& second) {
Profile1D tmp = first;
if (first.path() != second.path()) tmp.setPath("");
tmp += second;
return tmp;
}
/// Add two profile histograms
inline Profile1D operator + (const Profile1D& first, const Profile1D& second) {
return add(first, second);
}
/// Subtract two profile histograms
inline Profile1D subtract(const Profile1D& first, const Profile1D& second) {
Profile1D tmp = first;
if (first.path() != second.path()) tmp.setPath("");
tmp -= second;
return tmp;
}
/// Subtract two profile histograms
inline Profile1D operator - (const Profile1D& first, const Profile1D& second) {
return subtract(first, second);
}
/// Divide two profile histograms
Scatter2D divide(const Profile1D& numer, const Profile1D& denom);
/// Divide two profile histograms
inline Scatter2D operator / (const Profile1D& numer, const Profile1D& denom) {
return divide(numer, denom);
}
//@}
}
#endif
diff --git a/pyext/yoda/declarations.pxd b/pyext/yoda/declarations.pxd
--- a/pyext/yoda/declarations.pxd
+++ b/pyext/yoda/declarations.pxd
@@ -1,1372 +1,1372 @@
from libcpp.map cimport map
from libcpp.pair cimport pair
from libcpp.vector cimport vector
from libcpp cimport bool
from libcpp.string cimport string
from cython.operator cimport dereference as deref
cdef extern from "YODA/Config/YodaConfig.h" namespace "YODA":
string version()
# Import the error handling C++ routine
cdef extern from "errors.hh":
# Have a look in errors.cpp for implementation specifics
void yodaerr "translate_yoda_error" ()
ctypedef map[string, string] Annotations
ctypedef double (*dbl_dbl_fptr) (double)
# Math utils {{{
cdef extern from "YODA/Utils/MathUtils.h" namespace "YODA":
# bool isZero(double a, double tolerance)
# bool fuzzyEquals(double a, double b, double tolerance)
# bool fuzzyGtrEquals(double a, double b, double tolerance)
# bool fuzzyLessEquals(double a, double b, double tolerance)
vector[double] linspace(size_t nbins, double start, double end)
vector[double] logspace(size_t nbins, double start, double end)
int index_between(double&, vector[double]& binedges)
double mean(vector[int]& sample)
double covariance(vector[int]& sample1, vector[int]& sample2)
double correlation(vector[int]& sample1, vector[int]& sample2)
# }}}
# Dbn0D {{{
cdef extern from "YODA/Dbn0D.h" namespace "YODA":
cdef cppclass Dbn0D:
Dbn0D ()
Dbn0D (Dbn0D)
void fill(double weight)
void reset()
void scaleW(double)
# Raw distribution running sums
unsigned long numEntries() except +yodaerr
double effNumEntries() except +yodaerr
double sumW() except +yodaerr
double sumW2() except +yodaerr
double errW() except +yodaerr
double relErrW() except +yodaerr
Dbn0D operator+ (Dbn0D) except +yodaerr
Dbn0D operator- (Dbn0D) except +yodaerr
# TODO: += and -= operators
#}}} Dbn0D
# Dbn1D {{{
cdef extern from "YODA/Dbn1D.h" namespace "YODA":
cdef cppclass Dbn1D:
Dbn1D ()
Dbn1D (Dbn1D)
void fill(double val, double weight)
void reset()
void scaleW(double)
void scaleX(double)
double errW() except +yodaerr
double relErrW() except +yodaerr
double xMean() except +yodaerr
double xVariance() except +yodaerr
double xStdDev() except +yodaerr
double xStdErr() except +yodaerr
double xRMS() except +yodaerr
# Raw distribution running sums
unsigned long numEntries() except +yodaerr
double effNumEntries() except +yodaerr
double sumW() except +yodaerr
double sumW2() except +yodaerr
double sumWX() except +yodaerr
double sumWX2() except +yodaerr
Dbn1D operator+ (Dbn1D) except +yodaerr
Dbn1D operator- (Dbn1D) except +yodaerr
# TODO: += and -= operators
#}}} Dbn1D
# Dbn2D {{{
cdef extern from "YODA/Dbn2D.h" namespace "YODA":
cdef cppclass Dbn2D:
Dbn2D ()
Dbn2D (Dbn2D)
void fill(double x, double y, double weight) except +yodaerr
void reset() except +yodaerr
void scaleW(double) except +yodaerr
void scaleX(double) except +yodaerr
void scaleY(double) except +yodaerr
void scaleXY(double, double) except +yodaerr
double errW() except +yodaerr
double relErrW() except +yodaerr
double xMean() except +yodaerr
double xVariance() except +yodaerr
double xStdDev() except +yodaerr
double xStdErr() except +yodaerr
double xRMS() except +yodaerr
double yMean() except +yodaerr
double yVariance() except +yodaerr
double yStdDev() except +yodaerr
double yStdErr() except +yodaerr
double yRMS() except +yodaerr
# Raw distribution running sums
unsigned long numEntries() except +yodaerr
double effNumEntries() except +yodaerr
double sumW() except +yodaerr
double sumW2() except +yodaerr
double sumWX() except +yodaerr
double sumWX2() except +yodaerr
double sumWY() except +yodaerr
double sumWY2() except +yodaerr
double sumWXY() except +yodaerr
# Operators
void flipXY() except +yodaerr
Dbn1D transformX() except +yodaerr
Dbn1D transformY() except +yodaerr
Dbn2D operator + (Dbn2D) except +yodaerr
Dbn2D operator - (Dbn2D) except +yodaerr
# TODO: += and -= operators
#}}} Dbn2D
# Dbn3D {{{
cdef extern from "YODA/Dbn3D.h" namespace "YODA":
cdef cppclass Dbn3D:
Dbn3D ()
Dbn3D (Dbn3D)
void fill(double x, double y, double z, double weight)
void reset()
void scaleW(double)
void scaleX(double)
void scaleY(double)
void scaleZ(double)
# void scaleXY(double, double)
# void scaleYZ(double, double)
# void scaleXZ(double, double)
void scaleXYZ(double, double, double)
double errW() except +yodaerr
double relErrW() except +yodaerr
double xMean()
double xVariance()
double xStdDev()
double xStdErr()
double xRMS()
double yMean()
double yVariance()
double yStdDev()
double yStdErr()
double yRMS()
double zMean()
double zVariance()
double zStdDev()
double zStdErr()
double zRMS()
# Raw distribution running sums
unsigned long numEntries()
double effNumEntries()
double sumW()
double sumW2()
double sumWX()
double sumWX2()
double sumWY()
double sumWY2()
double sumWZ()
double sumWZ2()
double sumWXY()
double sumWXZ()
double sumWYZ()
double sumWXYZ()
# Operators
void flipXY()
void flipXZ()
void flipYZ()
Dbn1D transformX()
Dbn1D transformY()
Dbn1D transformZ()
Dbn3D operator + (Dbn3D)
Dbn3D operator - (Dbn3D)
# TODO: += and -= operators
#}}} Dbn3D
# Point {{{
cdef extern from "YODA/Point.h" namespace "YODA":
cdef cppclass Point:
int dim() except +yodaerr
double val(size_t i) except +yodaerr
void setVal(size_t i, double val) except +yodaerr
pair[double,double] errs(size_t i) except +yodaerr
double errMinus(size_t i) except +yodaerr
void setErrMinus(size_t i, double eminus) except +yodaerr
double errPlus(size_t i) except +yodaerr
void setErrPlus(size_t i, double eplus) except +yodaerr
double errAvg(size_t i) except +yodaerr
void setErr(size_t i, double e) except +yodaerr
# void setErrs(size_t i, double e) except +yodaerr
# void setErrs(size_t i, double eminus, double eplus) except +yodaerr
void setErrs(size_t i, pair[double,double]& e) except +yodaerr
# void set(size_t i, double val, double e) except +yodaerr
# void set(size_t i, double val, double eminus, double eplus) except +yodaerr
void set(size_t i, double val, pair[double,double]& e) except +yodaerr
#}}} Point
# Point1D {{{
cdef extern from "YODA/Point1D.h" namespace "YODA":
cdef cppclass Point1D(Point):
Point1D () except +yodaerr
Point1D (Point1D p) except +yodaerr
Point1D (double x, double exminus, double explus) except +yodaerr
double x() except +yodaerr
void setX(double x) except +yodaerr
pair[double,double] xErrs() except +yodaerr
void setXErrs(pair[double, double]&) except +yodaerr
double xErrAvg() except +yodaerr
double xMin() except +yodaerr
double xMax() except +yodaerr
void scaleX(double) except +yodaerr
bool operator == (Point1D) except +yodaerr
bool operator != (Point1D b) except +yodaerr
bool operator < (Point1D b) except +yodaerr
bool operator <= (Point1D b) except +yodaerr
bool operator > (Point1D b) except +yodaerr
bool operator >= (Point1D b) except +yodaerr
# }}} Point1D
# Point2D {{{
cdef extern from "YODA/Point2D.h" namespace "YODA":
cdef cppclass Point2D(Point):
Point2D () except +yodaerr
Point2D (Point2D p) except +yodaerr
Point2D (double x, double y,
double exminus, double explus,
double eyminus, double eyplus) except +yodaerr
double x() except +yodaerr
double y() except +yodaerr
void setX(double x) except +yodaerr
void setY(double y) except +yodaerr
pair[double,double] xy() except +yodaerr
void setXY(pair[double,double]&) except +yodaerr
pair[double,double] xErrs() except +yodaerr
pair[double,double] yErrs() except +yodaerr
void setXErrs(pair[double, double]&) except +yodaerr
void setYErrs(pair[double, double]&) except +yodaerr
double xErrAvg() except +yodaerr
double yErrAvg() except +yodaerr
double xMin() except +yodaerr
double xMax() except +yodaerr
double yMin() except +yodaerr
double yMax() except +yodaerr
void scaleX(double) except +yodaerr
void scaleY(double) except +yodaerr
void scaleXY(double, double) except +yodaerr
#void scale(double, double) except +yodaerr
bool operator == (Point2D) except +yodaerr
bool operator != (Point2D b) except +yodaerr
bool operator < (Point2D b) except +yodaerr
bool operator <= (Point2D b) except +yodaerr
bool operator > (Point2D b) except +yodaerr
bool operator >= (Point2D b) except +yodaerr
# }}} Point2D
# Point3D {{{
cdef extern from "YODA/Point3D.h" namespace "YODA":
cdef cppclass Point3D(Point):
Point3D () except +yodaerr
Point3D (Point3D& p) except +yodaerr
Point3D (double x, double y, double z,
double exminus, double explus,
double eyminus, double eyplus,
double ezminus, double ezplus) except +yodaerr
double x() except +yodaerr
double y() except +yodaerr
double z() except +yodaerr
void setX(double x) except +yodaerr
void setY(double y) except +yodaerr
void setZ(double z) except +yodaerr
pair[double,double] xErrs() except +yodaerr
pair[double,double] yErrs() except +yodaerr
pair[double,double] zErrs() except +yodaerr
void setXErrs(pair[double, double]&) except +yodaerr
void setYErrs(pair[double, double]&) except +yodaerr
void setZErrs(pair[double, double]&) except +yodaerr
double xErrAvg()
double yErrAvg()
double zErrAvg()
double xMin() except +yodaerr
double xMax() except +yodaerr
double yMin() except +yodaerr
double yMax() except +yodaerr
double zMin() except +yodaerr
double zMax() except +yodaerr
void scaleX(double) except +yodaerr
void scaleY(double) except +yodaerr
void scaleZ(double) except +yodaerr
void scaleXYZ(double, double, double) except +yodaerr
#void scale(double, double, double) except +yodaerr
bool operator == (Point3D b)
bool operator != (Point3D b)
bool operator < (Point3D b)
bool operator <= (Point3D b)
bool operator > (Point3D b)
bool operator >= (Point3D b)
#}}} Point3D
# Bin {{{
cdef extern from "YODA/Bin.h" namespace "YODA":
cdef cppclass Bin:
int dim() except +yodaerr
unsigned long numEntries() except +yodaerr
double effNumEntries() except +yodaerr
double sumW() except +yodaerr
double sumW2() except +yodaerr
# }}} Bin
#Bin1D {{{
cdef extern from "YODA/Bin1D.h" namespace "YODA":
cdef cppclass Bin1D[DBN](Bin):
Bin1D(pair[double, double] edges) except +yodaerr
Bin1D(pair[double, double] edges, DBN dbn) except +yodaerr
Bin1D(Bin1D) except +yodaerr
# THIS IS A CYTHON LIMITATION... DO NOT CALL THIS
Bin1D() # (DO NOT CALL THIS DO NOT CALL THIS) ###
#################################################
#We're fine as long as we don't try to instantiate these from Python
# void scaleW(double scale) except +yodaerr
# void scaleX(double scale) except +yodaerr
void reset() except +yodaerr
pair[double, double] edges() except +yodaerr
double xMin() except +yodaerr
double xMax() except +yodaerr
double xMid() except +yodaerr
double xWidth() except +yodaerr
double xFocus() except +yodaerr
# x statistics
double xMean() except +yodaerr
double xVariance() except +yodaerr
double xStdDev() except +yodaerr
double xStdErr() except +yodaerr
double xRMS() except +yodaerr
# raw statistics
double sumWX() except +yodaerr
double sumWX2() except +yodaerr
void merge (Bin1D&) except +yodaerr
Bin1D operator + (Bin1D&) except +yodaerr
Bin1D operator - (Bin1D&) except +yodaerr
ctypedef Bin1D[Dbn1D] Bin1D_Dbn1D
ctypedef Bin1D[Dbn2D] Bin1D_Dbn2D
ctypedef Bin1D[Dbn3D] Bin1D_Dbn3D
#}}} Bin1D
# Bin2D {{{
cdef extern from "YODA/Bin2D.h" namespace "YODA":
cdef cppclass Bin2D[DBN](Bin):
Bin2D(pair[double, double] xedges, pair[double, double] yedges) except+
Bin2D(Bin2D bin) except +yodaerr
# CYTHON HACK DO NOT CALL THIS IT DOES NOT EXIST
Bin2D() # (DO NOT CALL DO NOT CALL)
################################################
# void scaleW(double scale) except +yodaerr
# void scaleXY(double, double) except +yodaerr
void reset() except +yodaerr
pair[double, double] xEdges() except +yodaerr
pair[double, double] yEdges() except +yodaerr
double xMin() except +yodaerr
double yMin() except +yodaerr
double xMax() except +yodaerr
double yMax() except +yodaerr
double xMid() except +yodaerr
double yMid() except +yodaerr
double xWidth() except +yodaerr
double yWidth() except +yodaerr
double xFocus() except +yodaerr
double yFocus() except +yodaerr
pair[double, double] xyFocus() except +yodaerr
pair[double, double] xyMid() except +yodaerr
# x statistics
double xMean() except +yodaerr
double xVariance() except +yodaerr
double xStdDev() except +yodaerr
double xStdErr() except +yodaerr
double xRMS() except +yodaerr
double yMean() except +yodaerr
double yVariance() except +yodaerr
double yStdDev() except +yodaerr
double yStdErr() except +yodaerr
double yRMS() except +yodaerr
# Raw statistics
double sumWX() except +yodaerr
double sumWY() except +yodaerr
double sumWXY() except +yodaerr
double sumWX2() except +yodaerr
double sumWY2() except +yodaerr
#void merge(Bin2D) except +yodaerr
Bin2D operator + (Bin2D) except +yodaerr
Bin2D operator - (Bin2D) except +yodaerr
int adjacentTo(Bin2D) except +yodaerr
ctypedef Bin2D[Dbn2D] Bin2D_Dbn2D
ctypedef Bin2D[Dbn3D] Bin2D_Dbn3D
# }}} Bin2D
# HistoBin1D {{{
cdef extern from "YODA/HistoBin1D.h" namespace "YODA":
cdef cppclass HistoBin1D(Bin1D_Dbn1D):
HistoBin1D(double lowedge, double highedge) except +yodaerr
HistoBin1D(HistoBin1D) except +yodaerr
# void fill(double x, double weight) except +yodaerr
# void fillBin(double weight) except +yodaerr
double area() except +yodaerr
double height() except +yodaerr
double areaErr() except +yodaerr
double heightErr() except +yodaerr
double relErr() except +yodaerr
HistoBin1D operator+(HistoBin1D) except +yodaerr
HistoBin1D operator-(HistoBin1D) except +yodaerr
#}}} HistoBin1D
cdef extern from "merge.hh":
void HistoBin1D_iadd_HistoBin1D "cython_iadd" (HistoBin1D*, HistoBin1D*)
void HistoBin1D_isub_HistoBin1D "cython_isub" (HistoBin1D*, HistoBin1D*)
# void HistoBin1D_imul_dbl "cython_imul_dbl" (HistoBin1D*, double)
# void HistoBin1D_idiv_dbl "cython_idiv_dbl" (HistoBin1D*, double)
HistoBin1D* HistoBin1D_add_HistoBin1D "cython_add" (HistoBin1D*, HistoBin1D*)
HistoBin1D* HistoBin1D_sub_HistoBin1D "cython_sub" (HistoBin1D*, HistoBin1D*)
HistoBin1D* HistoBin1D_div_HistoBin1D "cython_div" (HistoBin1D*, HistoBin1D*)
# HistoBin2D {{{
cdef extern from "YODA/HistoBin2D.h" namespace "YODA":
cdef cppclass HistoBin2D(Bin2D_Dbn2D):
HistoBin2D(double xmin, double xmax, double ymin, double ymax) except +yodaerr
HistoBin2D(HistoBin2D) except +yodaerr
# void fill(double x, double y, double weight) except +yodaerr
# void fillBin(double weight) except +yodaerr
void reset()
# Accessors
double volume() except +yodaerr
double volumeErr() except +yodaerr
double height() except +yodaerr
double heightErr() except +yodaerr
double relErr() except +yodaerr
HistoBin2D operator+(HistoBin2D) except +yodaerr
HistoBin2D operator-(HistoBin2D) except +yodaerr
#Bin2D_Dbn2D merge(HistoBin2D b)
#}}} HistoBin2D
# ProfileBin1D {{{
cdef extern from "YODA/ProfileBin1D.h" namespace "YODA":
cdef cppclass ProfileBin1D(Bin1D_Dbn2D):
ProfileBin1D(ProfileBin1D) except +yodaerr
ProfileBin1D(double, double) except +yodaerr
#void fill(double x, double y, double weight) except +yodaerr
#void fillBin(double y, double weight) except +yodaerr
void reset() except +yodaerr
double mean() except +yodaerr
double stdDev() except +yodaerr
double variance() except +yodaerr
double stdErr() except +yodaerr
double rms() except +yodaerr
double sumWY() except +yodaerr
double sumWY2() except +yodaerr
ProfileBin1D operator + (ProfileBin1D) except +yodaerr
ProfileBin1D operator - (ProfileBin1D) except +yodaerr
# void scaleY(double) except +yodaerr
# }}} ProfileBin1D
cdef extern from "merge.hh":
void ProfileBin1D_iadd_ProfileBin1D "cython_iadd" (ProfileBin1D*, ProfileBin1D*)
void ProfileBin1D_isub_ProfileBin1D "cython_isub" (ProfileBin1D*, ProfileBin1D*)
# void ProfileBin1D_imul_dbl "cython_imul_dbl" (ProfileBin1D*, double)
# void ProfileBin1D_idiv_dbl "cython_idiv_dbl" (ProfileBin1D*, double)
ProfileBin1D* ProfileBin1D_add_ProfileBin1D "cython_add" (ProfileBin1D*, ProfileBin1D*)
ProfileBin1D* ProfileBin1D_sub_ProfileBin1D "cython_sub" (ProfileBin1D*, ProfileBin1D*)
ProfileBin1D* ProfileBin1D_div_ProfileBin1D "cython_div" (ProfileBin1D*, ProfileBin1D*)
# ProfileBin2D {{{
cdef extern from "YODA/ProfileBin2D.h" namespace "YODA":
cdef cppclass ProfileBin2D(Bin2D_Dbn3D):
ProfileBin2D (ProfileBin2D h) except +yodaerr
ProfileBin2D (double, double, double, double) except +yodaerr
# void fill(double x, double y, double z, double weight) except +yodaerr
# void fillBin(double z, double weight) except +yodaerr
double mean() except +yodaerr
double stdDev() except +yodaerr
double variance() except +yodaerr
double stdErr() except +yodaerr
double rms() except +yodaerr
double sumWZ() except +yodaerr
double sumWZ2() except +yodaerr
ProfileBin2D operator + (ProfileBin2D) except +yodaerr
ProfileBin2D operator - (ProfileBin2D) except +yodaerr
# void scaleZ(double) except +yodaerr
# }}} ProfileBin2D
# AnalysisObject {{{
cdef extern from "YODA/AnalysisObject.h" namespace "YODA":
cdef cppclass AnalysisObject:
# Constructors
AnalysisObject(string type, string path, string title) except +yodaerr
AnalysisObject(string type, string path, AnalysisObject ao, string title) except +yodaerr
AnalysisObject()
#AnalysisObject* newclone() except +yodaerr
## String used in automatic type determination
string type() except +yodaerr
## Data object fill- or plot-space dimension
int dim() except +yodaerr
## Annotations
vector[string] annotations() except +yodaerr
bool hasAnnotation(string key) except +yodaerr
string annotation(string key) except +yodaerr
string annotation(string key, string default) except +yodaerr
void setAnnotation(string, string) except +yodaerr
void rmAnnotation(string name) except +yodaerr
void clearAnnotations() except +yodaerr
## Standard annotations
string title() except +yodaerr
void setTitle(string title) except +yodaerr
string path() except +yodaerr
void setPath(string title) except +yodaerr
string name() except +yodaerr
# }}} AnalysisObject
cdef extern from "YODA/Utils/sortedvector.h" namespace "YODA::Utils":
cdef cppclass sortedvector[T](vector):
sortedvector(vector[T]) except +yodaerr
void insert(T) except +yodaerr
# TODO: forward declarations for bin-copying constructors
# Counter {{{
cdef extern from "YODA/Counter.h" namespace "YODA":
cdef cppclass Counter(AnalysisObject):
Counter() except +yodaerr
Counter(string path, string title) except +yodaerr
#Counter(Dbn0D dbn, string path, string title) except +yodaerr
Counter(Counter c, string path)
Counter clone() except +yodaerr
Counter* newclone() except +yodaerr
void reset() except +yodaerr
void fill(double weight) except +yodaerr
unsigned long numEntries() except +yodaerr
double effNumEntries() except +yodaerr
double sumW() except +yodaerr
double sumW2() except +yodaerr
double val() except +yodaerr
double err() except +yodaerr
double relErr() except +yodaerr
void scaleW(double) except +yodaerr
# operator += (Counter)
# operator -= (Counter)
Scatter1D Counter_div_Counter "divide" (const Counter&, const Counter&) except +yodaerr
Scatter1D Counter_eff_Counter "efficiency" (const Counter&, const Counter&) except +yodaerr
cdef extern from "merge.hh":
void Counter_iadd_Counter "cython_iadd" (Counter*, Counter*)
void Counter_isub_Counter "cython_isub" (Counter*, Counter*)
# void Counter_imul_dbl "cython_imul_dbl" (Counter*, double)
# void Counter_idiv_dbl "cython_idiv_dbl" (Counter*, double)
Counter* Counter_add_Counter "cython_add" (Counter*, Counter*)
Counter* Counter_sub_Counter "cython_sub" (Counter*, Counter*)
#Counter* Counter_div_Counter "cython_div" (Counter*, Counter*)
cdef extern from "YODA/Scatter1D.h" namespace "YODA":
Scatter1D mkScatter_Counter "YODA::mkScatter" (const Counter&) except +yodaerr
#}}} Counter
# Scatter1D {{{
cdef extern from "YODA/Scatter1D.h" namespace "YODA":
cdef cppclass Scatter1D(AnalysisObject):
Scatter1D() except +yodaerr
Scatter1D(string path, string title) except +yodaerr
Scatter1D(sortedvector[Point1D],
string path,
string title) except +yodaerr
Scatter1D(vector[double], vector[double],
vector[pair[double, double]],
vector[pair[double, double]]) except +yodaerr
Scatter1D(Scatter1D p, string path)
Scatter1D clone() except +yodaerr
Scatter1D* newclone() except +yodaerr
void reset() except +yodaerr
size_t numPoints() except +yodaerr
# TODO: have to ignore exception handling on ref-returning methods until Cython bug is fixed
vector[Point1D]& points() #except +yodaerr
Point1D& point(size_t index) #except +yodaerr
void addPoint(const Point1D&) #except +yodaerr
void addPoint(double) #except +yodaerr
void addPoint(double, const pair[double, double]&) #except +yodaerr
void addPoints(const sortedvector[Point1D]&) #except +yodaerr
#void combineWith(const Scatter1D&) #except +yodaerr
#void combineWith(const vector[Scatter1D]&) #except +yodaerr
void scaleX(double) except +yodaerr
void Scatter1D_transformX "YODA::transformX" (Scatter1D&, dbl_dbl_fptr)
#}}} Scatter1D
# cdef extern from "merge.hh":
# Scatter2D* Scatter2D_add_Scatter2D "cython_add" (Scatter2D*, Scatter2D*)
# Scatter2D* Scatter2D_sub_Scatter2D "cython_sub" (Scatter2D*, Scatter2D*)
cdef extern from "YODA/Scatter1D.h" namespace "YODA":
Scatter1D mkScatter_Scatter1D "YODA::mkScatter" (const Scatter1D&) except +yodaerr
# Scatter2D {{{
cdef extern from "YODA/Scatter2D.h" namespace "YODA":
cdef cppclass Scatter2D(AnalysisObject):
Scatter2D() except +yodaerr
Scatter2D(string path, string title) except +yodaerr
Scatter2D(sortedvector[Point2D],
string path,
string title) except +yodaerr
Scatter2D(vector[double], vector[double],
vector[pair[double, double]],
vector[pair[double, double]]) except +yodaerr
Scatter2D(Scatter2D p, string path)
Scatter2D clone() except +yodaerr
Scatter2D* newclone() except +yodaerr
void reset() except +yodaerr
size_t numPoints() except +yodaerr
# TODO: have to ignore exception handling on ref-returning methods until Cython bug is fixed
vector[Point2D]& points() #except +yodaerr
Point2D& point(size_t index) #except +yodaerr
void addPoint(const Point2D&) #except +yodaerr
void addPoint(double, double) #except +yodaerr
void addPoint(double, double,
const pair[double, double]&, const pair[double, double]&) #except +yodaerr
void addPoints(const sortedvector[Point2D]&) #except +yodaerr
void combineWith(const Scatter2D&) #except +yodaerr
void combineWith(const vector[Scatter2D]&) #except +yodaerr
void scaleX(double) except +yodaerr
void scaleY(double) except +yodaerr
void scaleXY(double, double) except +yodaerr
#void scale(double, double) except +yodaerr
void Scatter2D_transformX "YODA::transformX" (Scatter2D&, dbl_dbl_fptr)
void Scatter2D_transformY "YODA::transformY" (Scatter2D&, dbl_dbl_fptr)
#}}} Scatter2D
# cdef extern from "merge.hh":
# Scatter2D* Scatter2D_add_Scatter2D "cython_add" (Scatter2D*, Scatter2D*)
# Scatter2D* Scatter2D_sub_Scatter2D "cython_sub" (Scatter2D*, Scatter2D*)
cdef extern from "YODA/Scatter2D.h" namespace "YODA":
Scatter2D mkScatter_Scatter2D "YODA::mkScatter" (const Scatter2D&) except +yodaerr
# Scatter3D {{{
cdef extern from "YODA/Scatter3D.h" namespace "YODA":
cdef cppclass Scatter3D(AnalysisObject):
Scatter3D() except +yodaerr
Scatter3D(string path, string title) except +yodaerr
Scatter3D(sortedvector[Point3D],
string path,
string title) except +yodaerr
Scatter3D(vector[double], vector[double],
vector[pair[double, double]],
vector[pair[double, double]],
vector[pair[double, double]]) except +yodaerr
Scatter3D(Scatter3D p, string path)
Scatter3D clone() except +yodaerr
Scatter3D* newclone() except +yodaerr
void reset() except +yodaerr
size_t numPoints() except +yodaerr
# TODO: have to ignore exception handling on ref-returning methods until Cython bug is fixed
sortedvector[Point3D]& points() #except +yodaerr
Point3D& point(size_t index) #except +yodaerr
void addPoint(const Point3D&) #except +yodaerr
void addPoint(double, double, double) #except +yodaerr
void addPoint(double, double, double,
const pair[double, double]&, const pair[double, double]&, const pair[double, double]&) #except +yodaerr
void addPoints(const sortedvector[Point3D]&) #except +yodaerr
void combineWith(const Scatter3D&) #except +yodaerr
void combineWith(const vector[Scatter3D]&) #except +yodaerr
void scaleX(double) except +yodaerr
void scaleY(double) except +yodaerr
void scaleZ(double) except +yodaerr
void scaleXYZ(double, double, double) except +yodaerr
#void scale(double, double, double) except +yodaerr
void Scatter3D_transformX "YODA::transformX" (Scatter3D&, dbl_dbl_fptr)
void Scatter3D_transformY "YODA::transformY" (Scatter3D&, dbl_dbl_fptr)
void Scatter3D_transformZ "YODA::transformZ" (Scatter3D&, dbl_dbl_fptr)
#}}} Scatter3D
# cdef extern from "merge.hh":
# Scatter3D* Scatter3D_add_Scatter3D "cython_add" (Scatter3D*, Scatter3D*)
# Scatter3D* Scatter3D_sub_Scatter3D "cython_sub" (Scatter3D*, Scatter3D*)
cdef extern from "YODA/Scatter3D.h" namespace "YODA":
Scatter3D mkScatter_Scatter3D "YODA::mkScatter" (const Scatter3D&) except +yodaerr
# Histo1D#{{{
cdef extern from "YODA/Histo1D.h" namespace "YODA":
cdef cppclass Histo1D(AnalysisObject):
Histo1D() except +yodaerr
Histo1D(string path, string title) except +yodaerr
Histo1D(size_t nbins,
double lower,
double upper,
string path,
string title) except +yodaerr
Histo1D(vector[double] binedges,
string path,
string title) except +yodaerr
Histo1D(vector[Bin] bins, string path, string title) except +yodaerr
Histo1D(Histo1D h, string path) except +yodaerr
#Histo1D(Profile1D p, string path)
#Histo1D(Scatter2D p, string path)
Histo1D clone() except +yodaerr
Histo1D* newclone() except +yodaerr
void reset() except +yodaerr
void fill(double x, double weight) except +yodaerr
void fillBin(size_t i, double weight) except +yodaerr
void scaleW(double s) except +yodaerr
void normalize(double normto, bool includeoverflows) except +yodaerr
void mergeBins(size_t, size_t) except +yodaerr
- void rebinBy(unsigned int n) except +yodaerr
+ void rebinBy(unsigned int n, size_t begin, size_t end) except +yodaerr
void rebinTo(vector[double] edges) except +yodaerr
void addBin(double, double) except +yodaerr
void addBins(vector[double] edges) except +yodaerr
void eraseBin(size_t index) except +yodaerr
double xMin() except +yodaerr
double xMax() except +yodaerr
vector[double] xEdges() except +yodaerr
size_t numBins() except +yodaerr
vector[HistoBin1D]& bins()
int binIndexAt(double x) except +yodaerr
const HistoBin1D& bin(size_t ix)
const HistoBin1D& binAt(double x) except +yodaerr
# TODO: Some Cython mapping problem?
Dbn1D& totalDbn()
Dbn1D& underflow()
Dbn1D& overflow()
# Whole histo data
double integral(bool)
double integralTo(int, bool)
double integralRange(int, int)
unsigned long numEntries(bool)
double effNumEntries(bool)
double sumW(bool)
double sumW2(bool)
double xMean(bool)
double xVariance(bool)
double xStdDev(bool)
double xStdErr(bool)
double xRMS(bool)
# operator == (Histo1D)
# operator != (Histo1D)
operator + (Histo1D)
operator - (Histo1D)
operator / (Histo1D)
Scatter2D Histo1D_toIntegral "toIntegralHisto" (const Histo1D& h, bool includeunderflow) except +yodaerr
Scatter2D Histo1D_toIntegralEff "toIntegralEfficiencyHisto" (const Histo1D& h, bool includeunderflow, bool includeoverflow) except +yodaerr
Scatter2D Histo1D_div_Histo1D "divide" (const Histo1D&, const Histo1D&) except +yodaerr
Scatter2D Histo1D_eff_Histo1D "efficiency" (const Histo1D&, const Histo1D&) except +yodaerr
cdef extern from "merge.hh":
void Histo1D_iadd_Histo1D "cython_iadd" (Histo1D*, Histo1D*)
void Histo1D_isub_Histo1D "cython_isub" (Histo1D*, Histo1D*)
# void Histo1D_imul_dbl "cython_imul_dbl" (Histo1D*, double)
# void Histo1D_idiv_dbl "cython_idiv_dbl" (Histo1D*, double)
Histo1D* Histo1D_add_Histo1D "cython_add" (Histo1D*, Histo1D*)
Histo1D* Histo1D_sub_Histo1D "cython_sub" (Histo1D*, Histo1D*)
Histo1D* Histo1D_div_Histo1D "cython_div" (Histo1D*, Histo1D*)
cdef extern from "YODA/Scatter2D.h" namespace "YODA":
Scatter2D mkScatter_Histo1D "YODA::mkScatter" (const Histo1D&, bool) except +yodaerr
#}}} Histo1D
# Histo2D {{{
cdef extern from "YODA/Histo2D.h" namespace "YODA":
cdef cppclass Histo2D(AnalysisObject):
Histo2D() except +yodaerr
Histo2D(string path, string title) except +yodaerr
Histo2D(size_t nBinsX, double lowerX, double upperX,
size_t nBinsY, double lowerY, double upperY,
string path, string title) except +yodaerr
Histo2D(vector[double] xedges, vector[double] yedges,
string path, string title) except +yodaerr
Histo2D(Histo2D, string path)
#Histo2D(Profile1D p, string path)
#Histo2D(Scatter2D p, string path)
Histo2D clone() except +yodaerr
Histo2D* newclone() except +yodaerr
# TODO: add missing functions and enable refs + exceptions when Cython allows
void reset() except +yodaerr
void fill(double x, double y, double weight) except +yodaerr
void fillBin(size_t i, double weight) except +yodaerr
void normalize(double normto, bool includeoverflows) except +yodaerr
void scaleW(double scalefactor) except +yodaerr
void scaleXY(double, double)
# void mergeBins(size_t, size_t) except +yodaerr
# void rebin(unsigned int n) except +yodaerr
size_t numBins() except +yodaerr
size_t numBinsX() except +yodaerr
size_t numBinsY() except +yodaerr
vector[HistoBin2D]& bins() #except +yodaerr
int binIndexAt(double x, double y) except +yodaerr
const HistoBin2D& bin(size_t ix) #except +yodaerr
const HistoBin2D& binAt(double x, double y) #except +yodaerr
void addBin(const pair[double, double]&, const pair[double, double]&)
void addBins(const vector[HistoBin2D]&)
void addBin(double, double) except +yodaerr
void addBins(const vector[double]& edges) except +yodaerr
# void eraseBin(size_t index) except +yodaerr
double xMin() except +yodaerr
double xMax() except +yodaerr
double yMin() except +yodaerr
double yMax() except +yodaerr
# Dbn2D& outflow(int, int) #except +yodaerr
# Whole histo data
Dbn2D& totalDbn() #except +yodaerr
double integral(bool)
unsigned long numEntries(bool)
double effNumEntries(bool)
double sumW(bool)
double sumW2(bool)
double xMean(bool)
double yMean(bool)
double xVariance(bool)
double yVariance(bool)
double xStdDev(bool)
double yStdDev(bool)
double xStdErr(bool)
double yStdErr(bool)
double xRMS(bool)
double yRMS(bool)
# operator == (Histo2D)
# operator != (Histo2D)
operator + (Histo2D)
operator - (Histo2D)
operator / (Histo2D)
Scatter3D Histo2D_div_Histo2D "divide" (const Histo2D&, const Histo2D&) except +yodaerr
Scatter3D Histo2D_eff_Histo2D "efficiency" (const Histo2D&, const Histo2D&) except +yodaerr
cdef extern from "merge.hh":
void Histo2D_iadd_Histo2D "cython_iadd" (Histo2D*, Histo2D*)
void Histo2D_isub_Histo2D "cython_isub" (Histo2D*, Histo2D*)
# void Histo2D_imul_dbl "cython_imul_dbl" (Histo2D*, double)
# void Histo2D_idiv_dbl "cython_idiv_dbl" (Histo2D*, double)
Histo2D* Histo2D_add_Histo2D "cython_add" (Histo2D*, Histo2D*)
Histo2D* Histo2D_sub_Histo2D "cython_sub" (Histo2D*, Histo2D*)
Histo2D* Histo2D_div_Histo2D "cython_div" (Histo2D*, Histo2D*)
cdef extern from "YODA/Scatter3D.h" namespace "YODA":
Scatter3D mkScatter_Histo2D "YODA::mkScatter" (const Histo2D&, bool) except +yodaerr
# Histo2D }}}
# Profile1D {{{
cdef extern from "YODA/Profile1D.h" namespace "YODA":
cdef cppclass Profile1D(AnalysisObject):
Profile1D() except +yodaerr
Profile1D(string path, string title) except +yodaerr
Profile1D(size_t nxbins,
double xlower,
double xupper,
string path,
string title) except +yodaerr
Profile1D(vector[double] xbinedges,
string path,
string title) except +yodaerr
Profile1D(Profile1D p, string path) except +yodaerr
Profile1D(Scatter2D s, string path) except +yodaerr
#Profile1D(Histo1D p, string path)
Profile1D clone() except +yodaerr
Profile1D* newclone() except +yodaerr
void reset() except +yodaerr
void fill(double x, double y, double weight) except +yodaerr
void fillBin(size_t i, double y, double weight) except +yodaerr
void scaleW(double s) except +yodaerr
void scaleY(double s) except +yodaerr
void mergeBins(size_t, size_t) except +yodaerr
- void rebinBy(unsigned int n) except +yodaerr
+ void rebinBy(unsigned int n, size_t begin, size_t end) except +yodaerr
void rebinTo(vector[double] edges) except +yodaerr
void addBin(double, double) except +yodaerr
void addBins(vector[double] edges) except +yodaerr
# TODO: void eraseBin(size_t index) except +yodaerr
double xMin() except +yodaerr
double xMax() except +yodaerr
vector[double] xEdges() except +yodaerr
size_t numBins() except +yodaerr
vector[ProfileBin1D] bins() #except +yodaerr
int binIndexAt(double x) except +yodaerr
const ProfileBin1D& bin(size_t ix) #except +yodaerr
const ProfileBin1D& binAt(double x) #except +yodaerr
# The trick here is to treat these not as references.
# I suppose when you think about it, it makes sense
Dbn2D& totalDbn()
Dbn2D& underflow()
Dbn2D& overflow()
unsigned long numEntries(bool)
double effNumEntries(bool)
double sumW(bool)
double sumW2(bool)
double xMean(bool)
double xVariance(bool)
double xStdDev(bool)
double xStdErr(bool)
double xRMS(bool)
operator + (Profile1D)
operator - (Profile1D)
operator / (Profile1D)
Scatter2D Profile1D_div_Profile1D "divide" (const Profile1D&, const Profile1D&) except +yodaerr
cdef extern from "merge.hh":
void Profile1D_iadd_Profile1D "cython_iadd" (Profile1D*, Profile1D*)
void Profile1D_isub_Profile1D "cython_isub" (Profile1D*, Profile1D*)
# void Profile1D_imul_dbl "cython_imul_dbl" (Profile1D*, double)
# void Profile1D_idiv_dbl "cython_idiv_dbl" (Profile1D*, double)
Profile1D* Profile1D_add_Profile1D "cython_add" (Profile1D*, Profile1D*)
Profile1D* Profile1D_sub_Profile1D "cython_sub" (Profile1D*, Profile1D*)
Profile1D* Profile1D_div_Profile1D "cython_div" (Profile1D*, Profile1D*)
cdef extern from "YODA/Scatter2D.h" namespace "YODA":
Scatter2D mkScatter_Profile1D "YODA::mkScatter" (const Profile1D&, bool, bool) except +yodaerr
#}}} Profile1D
# Profile2D {{{
cdef extern from "YODA/Profile2D.h" namespace "YODA":
cdef cppclass Profile2D(AnalysisObject):
Profile2D() except +yodaerr
Profile2D(string path, string title) except +yodaerr
Profile2D(size_t nbinsX, double lowerX, double upperX,
size_t nbinsY, double lowerY, double upperY,
string path, string title) except +yodaerr
Profile2D(vector[double] xedges, vector[double] yedges,
string path, string title) except +yodaerr
Profile2D(Profile2D p, string path) except +yodaerr
#Profile2D(Scatter3D s, string path) except +yodaerr
#Profile2D(Histo2D p, string path)
Profile2D clone() except +yodaerr
Profile2D* newclone() except +yodaerr
# TODO: add missing functions and enable refs + exceptions when Cython allows
void reset() except +yodaerr
void fill(double x, double y, double z, double weight) except +yodaerr
void fillBin(size_t i, double z, double weight) except +yodaerr
void scaleW(double s) except +yodaerr
void scaleXY(double, double)
# void mergeBins(size_t, size_t) except +yodaerr
# void rebin(unsigned int n) except +yodaerr
size_t numBins() except +yodaerr
size_t numBinsX() except +yodaerr
size_t numBinsY() except +yodaerr
vector[ProfileBin2D]& bins() #except +yodaerr
int binIndexAt(double x, double y) except +yodaerr
const ProfileBin2D& bin(size_t ix) #except +yodaerr
const ProfileBin2D& binAt(double x, y) #except +yodaerr
void addBin(const pair[double, double]&, const pair[double, double]&) except +yodaerr
void addBins(const vector[double]&, const vector[double]&) except +yodaerr
# void eraseBin(size_t index) except +yodaerr
double xMin() except +yodaerr
double xMax() except +yodaerr
double yMin() except +yodaerr
double yMax() except +yodaerr
# Dbn3D& outflow(int, int) #except +yodaerr
# Whole histo data
Dbn3D& totalDbn() #except +yodaerr
unsigned long numEntries(bool)
double effNumEntries(bool)
double sumW(bool)
double sumW2(bool)
double xMean(bool)
double yMean(bool)
double xVariance(bool)
double yVariance(bool)
double xStdDev(bool)
double yStdDev(bool)
double xStdErr(bool)
double yStdErr(bool)
double xRMS(bool)
double yRMS(bool)
operator + (Profile2D)
operator - (Profile2D)
operator / (Profile2D)
Scatter3D Profile2D_div_Profile2D "divide" (const Profile2D&, const Profile2D&) except +yodaerr
cdef extern from "merge.hh":
void Profile2D_iadd_Profile2D "cython_iadd" (Profile2D*, Profile2D*)
void Profile2D_isub_Profile2D "cython_isub" (Profile2D*, Profile2D*)
# void Profile2D_imul_dbl "cython_imul_dbl" (Profile2D*, double)
# void Profile2D_idiv_dbl "cython_idiv_dbl" (Profile2D*, double)
Profile2D* Profile2D_add_Profile2D "cython_add" (Profile2D*, Profile2D*)
Profile2D* Profile2D_sub_Profile2D "cython_sub" (Profile2D*, Profile2D*)
Profile2D* Profile2D_div_Profile2D "cython_div" (Profile2D*, Profile2D*)
cdef extern from "YODA/Scatter3D.h" namespace "YODA":
Scatter3D mkScatter_Profile2D "YODA::mkScatter" (const Profile2D&, bool, bool) except +yodaerr
#}}} Profile2D
# Streams {{{
cdef extern from "<sstream>" namespace "std":
cdef cppclass ostringstream:
ostringstream()
string& str()
cdef extern from "<sstream>" namespace "std":
cdef cppclass istringstream:
istringstream()
string& str(string&)
cdef extern from "YODA/Reader.h" namespace "YODA":
cdef cppclass Reader:
void read(istringstream&, vector[AnalysisObject*]&) except +yodaerr
cdef extern from "YODA/ReaderYODA.h" namespace "YODA":
Reader& ReaderYODA_create "YODA::ReaderYODA::create" ()
cdef extern from "YODA/ReaderFLAT.h" namespace "YODA":
Reader& ReaderFLAT_create "YODA::ReaderFLAT::create" ()
cdef extern from "YODA/ReaderAIDA.h" namespace "YODA":
Reader& ReaderAIDA_create "YODA::ReaderAIDA::create" ()
cdef extern from "YODA/Reader.h" namespace "YODA":
Reader& Reader_create "YODA::mkReader" (string& filename)
cdef extern from "YODA/Writer.h" namespace "YODA":
cdef cppclass Writer:
void write(ostringstream&, vector[AnalysisObject*]&)
cdef extern from "YODA/WriterYODA.h" namespace "YODA":
Writer& WriterYODA_create "YODA::WriterYODA::create" ()
cdef extern from "YODA/WriterFLAT.h" namespace "YODA":
Writer& WriterFLAT_create "YODA::WriterFLAT::create" ()
cdef extern from "YODA/WriterAIDA.h" namespace "YODA":
Writer& WriterAIDA_create "YODA::WriterAIDA::create" ()
cdef extern from "YODA/Reader.h" namespace "YODA":
Writer& Writer_create "YODA::mkWriter" (string& filename)
# Streams }}}
# Axis1D {{{
cdef extern from "YODA/Axis1D.h" namespace "YODA":
cdef cppclass Axis1D[BIN1D, DBN]:
Axis1D() except +yodaerr
Axis1D(vector[double] binedges) except +yodaerr
Axis1D(size_t, double, double) except +yodaerr
Axis1D(vector[BIN1D] bins) except +yodaerr
void addBin(double, double) except +yodaerr
size_t numBins() except +yodaerr
vector[BIN1D]& bins()
double xMin() except +yodaerr
double xMax() except +yodaerr
vector[double] xEdges() except +yodaerr
long getBinIndex(double)
void reset()
DBN& totalDbn()
DBN& underflow()
DBN& overflow()
void eraseBin(size_t index) except +yodaerr
void mergeBins(size_t, size_t) except +yodaerr
# Axis1D }}}
# Axis2D {{{
cdef extern from "YODA/Axis2D.h" namespace "YODA":
cdef cppclass Axis2D[BIN2D, DBN]:
Axis2D() except +yodaerr
Axis2D(vector[double], vector[double]) except +yodaerr
Axis2D(size_t, pair[double, double], size_t, pair[double, double]) except +yodaerr
Axis2D(vector[BIN2D] bins) except +yodaerr
void addBin(pair[double, double], pair[double, double]) except +yodaerr
size_t numBins() except +yodaerr
vector[BIN2D]& bins()
double xMin() except +yodaerr
double xMax() except +yodaerr
double yMin() except +yodaerr
double yMax() except +yodaerr
long getBinIndex(double, double)
void reset()
DBN& totalDbn()
# TODO: reinstate DBN& outflow(int, int)
void eraseBin(size_t index) except +yodaerr
void mergeBins(size_t, size_t) except +yodaerr
# Axis2D }}}
diff --git a/pyext/yoda/include/Histo1D.pyx b/pyext/yoda/include/Histo1D.pyx
--- a/pyext/yoda/include/Histo1D.pyx
+++ b/pyext/yoda/include/Histo1D.pyx
@@ -1,396 +1,398 @@
cdef class Histo1D(AnalysisObject):
"""
1D histogram, with distinction between bin areas and heights.
Complete histogram binning is supported, including uniform/regular binning,
variable-width binning, unbinned gaps in the covered range, and
under/overflows. Rebinning by integer factors, or by explicit merging of
contiguous bins is also supported.
Rescaling of weights and/or the x axis is permitted in-place: the result is
still a valid Histo1D. Binning-compatible 1D histograms may be divided,
resulting in a Scatter2D since further fills would not be meaningful.
Several sets of arguments are tried by the constructor in the
following order.
Histo1D(path="", title="").
Construct a histogram with optional path and title but no bins.
Histo1D(nbins, low, high, path="", title="")
Construct a histogram with optional path and title, and nbins bins
uniformly distributed between low and high.
Histo1D(B, path="", title="").
Construct a histogram with optional path and title, from an
iterator of bins, B.
"""
cdef inline c.Histo1D* h1ptr(self) except NULL:
return <c.Histo1D*> self.ptr()
def __init__(self, *args, **kwargs):
util.try_loop([self.__init2, self.__init5, self.__init3], *args, **kwargs)
def __init2(self, char *path="", char *title=""):
cutil.set_owned_ptr(self, new c.Histo1D(string(path), string(title)))
# TODO: Is Cython clever enough that we can make 3a and 3b versions and let it do the type inference?
def __init3(self, bins_or_edges, char *path="", char *title=""):
# TODO: Do this type-checking better
cdef vector[double] edges
try:
## If float conversions work for all elements, it's a list of edges:
edges = list(float(x) for x in bins_or_edges)
cutil.set_owned_ptr(self, new c.Histo1D(edges, string(path), string(title)))
except:
## Assume it's a list of HistoBin1D
bins = bins_or_edges
self.__init2(path, title)
self.addBins(bins)
def __init5(self, nbins, low, high, char *path="", char *title=""):
cutil.set_owned_ptr(self, new c.Histo1D(nbins, low, high, string(path), string(title)))
def __len__(self):
"Number of bins"
return self.numBins
def __getitem__(self, i):
"Direct access to bins"
cdef size_t ii = cutil.pythonic_index(i, self.h1ptr().numBins())
return cutil.new_borrowed_cls(HistoBin1D, & self.h1ptr().bin(ii), self)
def __repr__(self):
xmean = None
if self.sumW() != 0:
xmean = "%0.2e" % self.xMean()
return "<%s '%s' %d bins, sumw=%0.2g, xmean=%s>" % \
(self.__class__.__name__, self.path,
len(self.bins), self.sumW(), xmean)
def reset(self):
"""None -> None.
Reset the histogram but leave the bin structure."""
self.h1ptr().reset()
def clone(self):
"""None -> Histo1D.
Clone this Histo1D."""
return cutil.new_owned_cls(Histo1D, self.h1ptr().newclone())
def fill(self, x, weight=1.0):
"""(x,[w]) -> None.
Fill with given x value and optional weight."""
self.h1ptr().fill(x, weight)
def fillBin(self, size_t ix, weight=1.0):
"""(ix,[w]) -> None.
Fill bin ix and optional weight."""
self.h1ptr().fillBin(ix, weight)
@property
def totalDbn(self):
"""None -> Dbn1D
The Dbn1D representing the total distribution."""
return cutil.new_borrowed_cls(Dbn1D, &self.h1ptr().totalDbn(), self)
@property
def underflow(self):
"""None -> Dbn1D
The Dbn1D representing the underflow distribution."""
return cutil.new_borrowed_cls(Dbn1D, &self.h1ptr().underflow(), self)
@property
def overflow(self):
"""None -> Dbn1D
The Dbn1D representing the overflow distribution."""
return cutil.new_borrowed_cls(Dbn1D, &self.h1ptr().overflow(), self)
def integral(self, includeoverflows=True):
"""([bool]) -> float
Histogram integral, optionally excluding the overflows."""
return self.h1ptr().integral(includeoverflows)
def integralRange(self, int ia, int ib):
"""(int, int) -> float
Integral between bins ia..ib inclusive"""
return self.h1ptr().integralRange(ia, ib)
def integralTo(self, int ia, includeunderflow=True):
"""(int, [bool]) -> float
Integral up to bin ia inclusive, optionally excluding the underflow"""
return self.h1ptr().integralRange(ia, includeunderflow)
def numEntries(self, includeoverflows=True):
"""([bool]) -> int
Number of times this histogram was filled, optionally excluding the overflows."""
return self.h1ptr().numEntries(includeoverflows)
def effNumEntries(self, includeoverflows=True):
"""([bool]) -> float
Effective number of times this histogram was filled, computed from weights, and optionally excluding the overflows."""
return self.h1ptr().effNumEntries(includeoverflows)
def sumW(self, includeoverflows=True):
"""([bool]) -> float
Sum of weights filled into this histogram, optionally excluding the overflows."""
return self.h1ptr().sumW(includeoverflows)
def sumW2(self, includeoverflows=True):
"""([bool]) -> float
Sum of weights filled into this histogram, optionally excluding the overflows."""
return self.h1ptr().sumW2(includeoverflows)
def xMean(self, includeoverflows=True):
"""([bool]) -> float
Mean x of the histogram, optionally excluding the overflows."""
return self.h1ptr().xMean(includeoverflows)
def xVariance(self, includeoverflows=True):
"""([bool]) -> float
Variance in x of the histogram, optionally excluding the overflows."""
return self.h1ptr().xVariance(includeoverflows)
def xStdDev(self, includeoverflows=True):
"""([bool]) -> float
Standard deviation in x of the histogram, optionally excluding the overflows."""
return self.h1ptr().xStdDev(includeoverflows)
def xStdErr(self, includeoverflows=True):
"""([bool]) -> float
Standard error on the mean x of the histogram, optionally excluding the overflows."""
return self.h1ptr().xStdErr(includeoverflows)
def xRMS(self, includeoverflows=True):
"""([bool]) -> float
RMS in x of the histogram, optionally excluding the overflows."""
return self.h1ptr().xRMS(includeoverflows)
def scaleW(self, w):
""" (float) -> None.
Rescale the weights in this histogram by the factor w."""
self.h1ptr().scaleW(w)
def normalize(self, normto=1.0, includeoverflows=True):
""" (float, bool) -> None.
Normalize the histogram."""
self.h1ptr().normalize(normto, includeoverflows)
@property
def xMin(self):
"""Low x edge of the histo."""
return self.h1ptr().xMin()
@property
def xMax(self):
"""High x edge of the histo."""
return self.h1ptr().xMax()
@property
def xEdges(self):
"""All x edges of the histo."""
return self.h1ptr().xEdges()
@property
def numBins(self):
"""() -> int
Number of bins (not including overflows)."""
return self.h1ptr().numBins()
@property
def bins(self):
"""Access the ordered bins list."""
return list(self)
def bin(self, i):
"""Get the i'th bin (equivalent to bins[i]"""
# cdef size_t ii = cutil.pythonic_index(i, self.h1ptr().numBins())
return cutil.new_borrowed_cls(HistoBin1D, & self.h1ptr().bin(i), self)
def binIndexAt(self, x):
"""Get the bin index containing position x"""
return self.h1ptr().binIndexAt(x)
def binAt(self, x):
"""Get the bin containing position x"""
# TODO: what's the problem with this direct mapping? Produces compile error re. no default constructor...
#return cutil.new_borrowed_cls(HistoBin1D, & self.h1ptr().binAt(x), self)
# TODO: need out-of-range check to return None?
return self.bin(self.binIndexAt(x))
def addBin(self, low, high):
"""(low, high) -> None.
Add a bin."""
self.h1ptr().addBin(low, high)
def addBins(self, edges_or_bins):
"""Add several bins."""
# TODO: simplify / make consistent
arg = list(edges_or_bins)
util.try_loop([self.__addBins_edges,
self.__addBins_tuples,
self.__addBins_points,
self.__addBins_bins], arg)
def __addBins_edges(self, edges):
cdef vector[double] cedges
for edge in edges:
cedges.push_back(edge)
if len(edges):
self.h1ptr().addBins(cedges)
def __addBins_bins(self, bins):
self.__addBins_tuples(imap(attrgetter('edges'), bins))
def __addBins_points(self, points):
self.__addBins_tuples(imap(attrgetter('xRange'), points))
def __addBins_tuples(self, tuples):
cdef double a, b
for a, b in tuples:
self.h1ptr().addBin(a, b)
def mergeBins(self, ia, ib):
"""mergeBins(ia, ib) -> None.
Merge bins from indices ia through ib."""
self.h1ptr().mergeBins(ia, ib)
- def rebinBy(self, n):
+ def rebinBy(self, n, begin=0, end=None):
"""(n) -> None.
- Merge every group of n bins together."""
- self.h1ptr().rebinBy(int(n))
+ Merge every group of n bins together (between begin and end, if specified)."""
+ if end is None:
+ end = self.numBins
+ self.h1ptr().rebinBy(int(n), begin, end)
def rebinTo(self, edges):
"""([edges]) -> None.
Merge bins to produce the given new edges... which must be a subset of the current ones."""
self.h1ptr().rebinTo(edges)
- def rebin(self, arg):
+ def rebin(self, arg, **kwargs):
"""(n) -> None or ([edges]) -> None
Merge bins, like rebinBy if an int argument is given; like rebinTo if an iterable is given."""
if hasattr(arg, "__iter__"):
- self.rebinTo(arg)
+ self.rebinTo(arg, **kwargs)
else:
- self.rebinBy(arg)
+ self.rebinBy(arg, **kwargs)
def mkScatter(self, usefocus=False):
"""None -> Scatter2D.
Convert this Histo1D to a Scatter2D, with y representing bin heights
(not sumW) and height errors."""
cdef c.Scatter2D s2 = c.mkScatter_Histo1D(deref(self.h1ptr()), usefocus)
return cutil.new_owned_cls(Scatter2D, s2.newclone())
def toIntegral(self, efficiency=False, includeunderflow=True, includeoverflow=True):
"""None -> Scatter2D.
Convert this Histo1D to a Scatter2D representing an integral (i.e. cumulative)
histogram constructed from this differential one.
The efficiency argument is used to construct an 'efficiency integral' histogram
and the includeXXXflow bools determine whether under and overflows are included
in computing the (efficiency) integral.
"""
cdef c.Scatter2D s
if not efficiency:
s = c.Histo1D_toIntegral(deref(self.h1ptr()), includeunderflow)
else:
s = c.Histo1D_toIntegralEff(deref(self.h1ptr()), includeunderflow, includeoverflow)
return cutil.new_owned_cls(Scatter2D, s.newclone())
def divideBy(self, Histo1D h, efficiency=False):
"""Histo1D -> Scatter2D
Divide this histogram by h, returning a Scatter2D. The optional 'efficiency'
argument, if set True, will use a binomial efficiency treatment of the errors.
"""
# if type(h) is not Histo1D:
# raise ValueError("Histograms must be of the same type to be divided")
cdef c.Scatter2D s
if not efficiency:
s = c.Histo1D_div_Histo1D(deref(self.h1ptr()), deref(h.h1ptr()))
else:
s = c.Histo1D_eff_Histo1D(deref(self.h1ptr()), deref(h.h1ptr()))
return cutil.new_owned_cls(Scatter2D, s.newclone())
## In-place special methods
def __iadd__(Histo1D self, Histo1D other):
c.Histo1D_iadd_Histo1D(self.h1ptr(), other.h1ptr())
return self
def __isub__(Histo1D self, Histo1D other):
c.Histo1D_isub_Histo1D(self.h1ptr(), other.h1ptr())
return self
# def __imul__(Histo1D self, double x):
# c.Histo1D_imul_dbl(self.h1ptr(), x)
# return self
# def __idiv__(Histo1D self, double x):
# c.Histo1D_idiv_dbl(self.h1ptr(), x)
# return self
## Unbound special methods
# # TODO: only to bootstrap sum(), but doesn't work properly? Seems to treat *self* as the int...
# def __radd__(Histo1D self, zero):
# #assert zero == 0
# print "FOO"
# return self.clone()
def __add__(Histo1D self, Histo1D other):
# print "BAR"
h = Histo1D()
cutil.set_owned_ptr(h, c.Histo1D_add_Histo1D(self.h1ptr(), other.h1ptr()))
return h
# TODO: Cython doesn't support type overloading for special functions?
# def __add__(Histo1D self, int x):
# """
# Special operator support to allow use of sum(histos) which starts from 0.
# """
# assert(x == 0)
# return self
# TODO: Cython doesn't support type overloading for special functions?
# def __radd__(Histo1D self, int x):
# """
# Special operator support to allow use of sum(histos) which starts from 0.
# """
# assert(x == 0)
# return self
def __sub__(Histo1D self, Histo1D other):
h = Histo1D()
cutil.set_owned_ptr(h, c.Histo1D_sub_Histo1D(self.h1ptr(), other.h1ptr()))
return h
# def __mul__(Histo1D self, double x):
# h = c.Histo1D_mul_dbl(self.h1ptr(), x)
# return h
# def __rmul__(Histo1D self, double x):
# h = c.Histo1D_mul_dbl(self.h1ptr(), x)
# return h
def __div__(Histo1D self, Histo1D other):
return self.divideBy(other)
diff --git a/pyext/yoda/include/Profile1D.pyx b/pyext/yoda/include/Profile1D.pyx
--- a/pyext/yoda/include/Profile1D.pyx
+++ b/pyext/yoda/include/Profile1D.pyx
@@ -1,284 +1,285 @@
-
cdef class Profile1D(AnalysisObject):
"""
1D profile histogram, used to measure mean values of a y variable, binned in x.
Complete histogram binning is supported, including uniform/regular binning,
variable-width binning, unbinned gaps in the covered range, and
under/overflows. Rebinning by integer factors, or by explicit merging of
contiguous bins is also supported.
Rescaling of weights and/or the x axis is permitted in-place: the result is
still a valid Histo1D. Binning-compatible 1D histograms may be divided,
resulting in a Scatter2D since further fills would not be meaningful.
Several sets of arguments are tried by the constructor in the following
order.
Profile1D(path="", title="").
Construct a histogram with optional path and title but no bins.
Profile1D(nbins, low, high, path="", title="")
Construct a histogram with optional path and title, and nbins bins
uniformly distributed between low and high.
Profile1D(B, path="", title="").
Construct a histogram with optional path and title, from an
iterator of bins, B.
"""
cdef inline c.Profile1D* p1ptr(self) except NULL:
return <c.Profile1D*> self.ptr()
def __init__(self, *args, **kwargs):
util.try_loop([self.__init2, self.__init3, self.__init5], *args, **kwargs)
def __init2(self, char *path="", char *title=""):
cutil.set_owned_ptr(
self, new c.Profile1D(string(path), string(title)))
# TODO: Is Cython clever enough that we can make 3a and 3b versions and let it do the type inference?
def __init3(self, bins_or_edges, char *path="", char *title=""):
# TODO: Do this type-checking better
cdef vector[double] edges
try:
## If float conversions work for all elements, it's a list of edges:
edges = list(float(x) for x in bins_or_edges)
cutil.set_owned_ptr(self, new c.Profile1D(edges, string(path), string(title)))
except:
## Assume it's a list of HistoBin1D
bins = bins_or_edges
self.__init2(path, title)
self.addBins(bins)
def __init5(self, size_t nbins, double lower, double upper, char *path="", char *title=""):
cutil.set_owned_ptr(
self, new c.Profile1D(nbins, lower, upper, string(path), string(title)))
def __len__(self):
"Number of bins"
return self.p1ptr().bins().size()
def __getitem__(self, i):
"Direct access to bins"
cdef size_t ii = cutil.pythonic_index(i, self.p1ptr().bins().size())
return cutil.new_borrowed_cls(ProfileBin1D, & self.p1ptr().bin(ii), self)
def __repr__(self):
return "<%s '%s' %d bins, sumw=%0.2g>" % \
(self.__class__.__name__, self.path,
len(self.bins), self.sumW())
def reset(self):
"""None -> None.
Reset the histogram but leave the bin structure."""
self.p1ptr().reset()
def clone(self):
"""None -> Profile1D.
Clone this Profile1D."""
return cutil.new_owned_cls(Profile1D, self.p1ptr().newclone())
def fill(self, x, y, weight=1.0):
"""(x,y,[w]) -> None.
Fill with given x & y values and optional weight."""
self.p1ptr().fill(x, y, weight)
def fillBin(self, size_t ix, double y, weight=1.0):
"""(ix,y,[w]) -> None.
Fill bin ix with y value and optional weight."""
self.p1ptr().fillBin(ix, y, weight)
@property
def totalDbn(self):
"""() -> Dbn2D
The Dbn2D representing the total distribution."""
return cutil.new_borrowed_cls(
Dbn2D, &self.p1ptr().totalDbn(), self)
@property
def underflow(self):
"""() -> Dbn2D
The Dbn2D representing the underflow distribution."""
return cutil.new_borrowed_cls(
Dbn2D, &self.p1ptr().underflow(), self)
@property
def overflow(self):
"""() -> Dbn2D
The Dbn2D representing the overflow distribution."""
return cutil.new_borrowed_cls(
Dbn2D, &self.p1ptr().overflow(), self)
def numEntries(self, includeoverflows=True):
"""([bool]) -> int
Number of times this histogram was filled, optionally excluding the overflows."""
return self.p1ptr().numEntries(includeoverflows)
def effNumEntries(self, includeoverflows=True):
"""([bool]) -> float
Effective number of times this histogram was filled, computed from weights and optionally excluding the overflows."""
return self.p1ptr().effNumEntries(includeoverflows)
def sumW(self, includeoverflows=True):
"""([bool]) -> float
Sum of weights filled into this histogram."""
return self.p1ptr().sumW(includeoverflows)
def sumW2(self, includeoverflows=True):
"""([bool]) -> float
Sum of weights filled into this histogram."""
return self.p1ptr().sumW2(includeoverflows)
def xMean(self, includeoverflows=True):
"""([bool]) -> float
Mean x of the histogram, optionally excluding the overflows."""
return self.p1ptr().xMean(includeoverflows)
def xVariance(self, includeoverflows=True):
"""([bool]) -> float
Variance in x of the histogram, optionally excluding the overflows."""
return self.p1ptr().xVariance(includeoverflows)
def xStdDev(self, includeoverflows=True):
"""([bool]) -> float
Standard deviation in x of the histogram, optionally excluding the overflows."""
return self.p1ptr().xStdDev(includeoverflows)
def xStdErr(self, includeoverflows=True):
"""([bool]) -> float
Standard error on the mean x of the histogram, optionally excluding the overflows."""
return self.p1ptr().xStdErr(includeoverflows)
def xRMS(self, includeoverflows=True):
"""([bool]) -> float
RMS in x of the histogram, optionally excluding the overflows."""
return self.p1ptr().xRMS(includeoverflows)
def scaleW(self, double w):
"""(float) -> None.
Rescale the weights in this histogram by the factor w."""
self.p1ptr().scaleW(w)
def scaleY(self, double f):
"""(float) -> None.
Scale the y-direction (profiled value) in this histogram by the factor f."""
self.p1ptr().scaleY(f)
@property
def xMin(self):
"""Low x edge of the histo."""
return self.p1ptr().xMin()
@property
def xMax(self):
"""High x edge of the histo."""
return self.p1ptr().xMax()
@property
def xEdges(self):
"""All x edges of the histo."""
return self.p1ptr().xEdges()
@property
def numBins(self):
"""() -> int
Number of bins (not including overflows)."""
return self.p1ptr().numBins()
@property
def bins(self):
"""Access the ordered bins list."""
return list(self)
def binIndexAt(self, x):
"""Get the bin index containing position x"""
return self.p1ptr().binIndexAt(x)
def binAt(self, x):
"""Get the bin containing position x"""
# TODO: what's the problem with this direct mapping? Produces compile error re. no default constructor...
# return cutil.new_borrowed_cls(ProfileBin1D, & self.p1ptr().binAt(x), self)
# TODO: need out-of-range check to return None?
return self.bin(self.binIndexAt(x))
def addBin(self, low, high):
"""Add a bin."""
self.p1ptr().addBin(low, high)
return self
def addBins(self, edges):
"""Add several bins."""
# TODO: simplify / make consistent
cdef vector[double] cedges
for i in edges:
cedges.push_back(i)
self.p1ptr().addBins(cedges)
return self
def mergeBins(self, a, b):
"""mergeBins(ia, ib) -> None.
Merge bins from indices ia through ib."""
self.p1ptr().mergeBins(a, b)
- def rebinBy(self, n):
+ def rebinBy(self, n, begin=0, end=None):
"""(n) -> None.
- Merge every group of n bins together."""
- self.p1ptr().rebinBy(int(n))
+ Merge every group of n bins together (between begin and end, if specified)."""
+ if end is None:
+ end = self.numBins
+ self.p1ptr().rebinBy(int(n), begin, end)
def rebinTo(self, edges):
"""([edges]) -> None.
Merge bins to produce the given new edges... which must be a subset of the current ones."""
self.p1ptr().rebinTo(edges)
- def rebin(self, arg):
+ def rebin(self, arg, **kwargs):
"""(n) -> None or ([edges]) -> None
Merge bins, like rebinBy if an int argument is given; like rebinTo if an iterable is given."""
if hasattr(arg, "__iter__"):
- self.rebinTo(arg)
+ self.rebinTo(arg, **kwargs)
else:
- self.rebinBy(arg)
+ self.rebinBy(arg, **kwargs)
def mkScatter(self, usefocus=False, usestddev=False):
"""None -> Scatter2D.
Convert this Profile1D to a Scatter2D, with y representing
mean bin y values and their standard errors."""
cdef c.Scatter2D s2 = c.mkScatter_Profile1D(deref(self.p1ptr()), usefocus, usestddev)
return cutil.new_owned_cls(Scatter2D, s2.newclone())
def divideBy(self, Profile1D h):
cdef c.Scatter2D s = c.Profile1D_div_Profile1D(deref(self.p1ptr()), deref(h.p1ptr()))
return cutil.new_owned_cls(Scatter2D, s.newclone())
def __iadd__(Profile1D self, Profile1D other):
c.Profile1D_iadd_Profile1D(self.p1ptr(), other.p1ptr())
return self
def __isub__(Profile1D self, Profile1D other):
c.Profile1D_isub_Profile1D(self.p1ptr(), other.p1ptr())
return self
def __add__(Profile1D self, Profile1D other):
h = Profile1D()
cutil.set_owned_ptr(h, c.Profile1D_add_Profile1D(self.p1ptr(), other.p1ptr()))
return h
def __sub__(Profile1D self, Profile1D other):
h = Profile1D()
cutil.set_owned_ptr(h, c.Profile1D_sub_Profile1D(self.p1ptr(), other.p1ptr()))
return h
def __div__(Profile1D self, Profile1D other):
return self.divideBy(other)
diff --git a/tests/Makefile.am b/tests/Makefile.am
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,120 +1,122 @@
EXTRA_DIST = \
pytest-unit \
pytest-counter \
pytest-h1d \
pytest-p1d \
pytest-h2d \
pytest-p2d \
pytest-s1d \
pytest-s2d \
pytest-div \
+ pytest-rebin \
pytest-iofilter \
pytest-operators \
shtest-yodamerge \
shtest-yoda2root \
test1.yoda test2.yoda \
merged12-ref.yoda merged12pi-ref.yoda
check_PROGRAMS = \
testweights \
testbinsearcher \
testhisto1Da testhisto1Db \
testhisto2Da \
testprofile1Da \
testindexedset \
testsortedvector\
testhisto1Dcreate \
testhisto1Dfill \
testhisto1Dmodify \
testprofile1Dcreate \
testprofile1Dfill \
testprofile1Dmodify \
testscatter2Dcreate \
testscatter2Dmodify \
testhisto2Dcreate
# testhisto2Dfill \
# testhisto2Dmodify \
# testscatter3Dcreate \
# testscatter3Dmodify
AM_LDFLAGS = -L$(top_builddir)/src -lYODA
testweights_SOURCES = TestWeights.cc
testbinsearcher_SOURCES = TestBinSearcher.cc
testhisto1Da_SOURCES = TestHisto1Da.cc
testhisto1Db_SOURCES = TestHisto1Db.cc
testprofile1Da_SOURCES = TestProfile1Da.cc
testindexedset_SOURCES = TestIndexedSet.cc
testsortedvector_SOURCES = TestSortedVector.cc
testhisto1Dcreate_SOURCES = Histo1D/H1DCreate.cc
testhisto1Dfill_SOURCES = Histo1D/H1DFill.cc
testhisto1Dmodify_SOURCES = Histo1D/H1DModify.cc
testprofile1Dcreate_SOURCES = Profile1D/P1DCreate.cc
testprofile1Dfill_SOURCES = Profile1D/P1DFill.cc
testprofile1Dmodify_SOURCES = Profile1D/P1DModify.cc
testhisto2Da_SOURCES = TestHisto2Da.cc
# testhisto2De_SOURCES = TestHisto2Derase.cc
testhisto2Dcreate_SOURCES = Histo2D/H2DCreate.cc
#testhisto2Dfill_SOURCES = Histo2D/H2DFill.cc
#testhisto2Dmodify_SOURCES = Histo2D/H2DModify.cc
testscatter2Dcreate_SOURCES = Scatter2D/S2DCreate.cc
testscatter2Dmodify_SOURCES = Scatter2D/S2DModify.cc
# testpoint3D_SOURCES = TestPoint3D.cc
# testscatter3D_SOURCES = TestScatter3D.cc
# testscatter3Dcreate_SOURCES = Scatter3D/S3DCreate.cc
# testscatter3Dmodify_SOURCES = Scatter3D/S3DModify.cc
TESTS_ENVIRONMENT = \
LD_LIBRARY_PATH=$(top_builddir)/src:$(top_builddir)/src/.libs:$(LD_LIBRARY_PATH) \
DYLD_LIBRARY_PATH=$(top_builddir)/src:$(top_builddir)/src/.libs:$(DYLD_LIBRARY_PATH) \
PYTHONPATH=$(top_builddir)/pyext/build:$(PYTHONPATH) \
PATH=$(top_builddir)/bin:$(top_srcdir)/bin:$(PATH) \
YODA_TESTS_SRC=$(srcdir)
TESTS = \
testweights \
testbinsearcher \
testhisto1Da \
testhisto1Db \
testhisto2Da \
testprofile1Da \
testindexedset \
testsortedvector \
testhisto1Dcreate \
testhisto1Dfill \
testhisto1Dmodify \
testprofile1Dcreate \
testprofile1Dfill \
testprofile1Dmodify \
testscatter2Dcreate \
testscatter2Dmodify \
testhisto2Dcreate \
pytest-unit \
pytest-counter \
pytest-h1d \
pytest-p1d \
pytest-h2d \
pytest-p2d \
pytest-s1d \
pytest-s2d \
pytest-div \
+ pytest-rebin \
pytest-iofilter \
pytest-operators \
shtest-yodamerge
CLEANFILES = \
merged12.yoda merged12pi.yoda \
h1d.yoda h1d.dat \
p1d.yoda p1d.dat \
h2d.yoda h2d.dat \
p2d.yoda p2d.dat \
s1d.yoda s2d.yoda \
counter.yoda \
test.aida
if ENABLE_ROOT
TESTS += shtest-yoda2root
CLEANFILES += test1.root
endif
diff --git a/tests/pytest-rebin b/tests/pytest-rebin
new file mode 100755
--- /dev/null
+++ b/tests/pytest-rebin
@@ -0,0 +1,41 @@
+#! /usr/bin/env python
+
+import yoda
+
+h = yoda.Histo1D(10, 0, 5)
+for x in (0.1, 0.2, 1.3, 2.1, 2.7, 2.8, 4.0, 4.1):
+ h.fill(x)
+print h.numBins
+print h.xEdges
+
+print "Ha1"
+ha1 = h.clone()
+ha1.rebinBy(2)
+print ha1.numBins
+print ha1.xEdges
+assert ha1.numBins == 5
+assert ha1.xEdges == [0.0, 1.0, 2.0, 3.0, 4.0, 5.0]
+
+print "Ha2"
+ha2 = h.clone()
+ha2.rebinBy(2, 2, 7)
+print ha2.numBins
+print ha2.xEdges
+assert ha2.numBins == 7
+assert ha2.xEdges == [0.0, 0.5, 1.0, 2.0, 3.0, 4.0, 4.5, 5.0]
+
+print "Hb1"
+hb1 = h.clone()
+hb1.rebinTo([0., 1., 3., 5.])
+print hb1.numBins
+print hb1.xEdges
+assert hb1.numBins == 3
+assert hb1.xEdges == [0.0, 1.0, 3.0, 5.0]
+
+print "Hb2"
+hb2 = h.clone()
+hb2.rebin([1., 1.5, 3., 4.5])
+print hb2.numBins
+print hb2.xEdges
+assert hb2.numBins == 3
+assert hb2.xEdges == [1.0, 1.5, 3.0, 4.5]

File Metadata

Mime Type
text/x-diff
Expires
Tue, Nov 19, 4:30 PM (1 d, 13 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3789443
Default Alt Text
(174 KB)

Event Timeline