herwig is hosted by Hepforge, IPPP Durham
Herwig++  2.7.0
Analysis2::Histogram2 Class Reference

A more sophisticated histogram. More...

#include <Histogram2.h>

Inheritance diagram for Analysis2::Histogram2:

List of all members.

Public Member Functions

void book (const string &name, double event, double weight=1.)
 Book an event into the given channel.
Standard constructors and destructors.
 Histogram2 ()
 The default constructor.
virtual ~Histogram2 ()
 The destructor.
Constructors
 Histogram2 (double low, double high, unsigned int bins, const string &name="mc")
 Construct giving the range and a number of bins and insert a counting channel with name.
 Histogram2 (const vector< pair< double, double > > &, const string &name)
 Construct giving a binning and insert a counting channel with name.
 Histogram2 (const string &dataFile, const string &dataName)
 Construct giving a name of a data file and a name for the resulting channel.
void setName (const string &)
 Set a name for the histogram.
Channel administration
bool haveChannel (const string &) const
 Return true, if a channel by that name exists.
HistogramChannelchannel (const string &)
 Access a channel.
HistogramChannel channel (const string &) const
 Access a channel.
void insertChannel (const string &, const HistogramChannel &)
 Insert a new channel.
void insertChannel (const string &)
 Insert a new counting channel.
HistogramChannel removeChannel (const string &)
 Remove a channel.
Access the binning
const vector< pair< double,
double > > & 
binning () const
 Return the binning.
const map< double, unsigned int > & binhash () const
 Return the bin hash map.
pair< double, double > range () const
 Return the range.
Normalisation and statistical tests
void finish (const string &)
 Finish the given channel.
void differential (const string &)
 The given channel is a differential distribution, dvidie each bin by its bin width.
pair< double, double > integrate (const string &) const
 Return the integral of the given channel.
void normalise (const string &)
 Normalise the given channel to unity.
void normalise (const string &, const string &)
 Normalise the given channel to the integral of another one.
void rescale (const string &, double)
 Rescale the given channel.
void rescale (double)
 Rescale the all channels.
void normaliseToCrossSection (const string &name="mc")
 Normalise a channel to the total cross section.
pair< double, double > chi2perDOF (const string &, const string &, double minfrac=.0) const
 Return the $\chi^2$ per DOF taking the first channel as hypotheses and the second one as data/.
Support for histogram output
vector< string > channels () const
 Return the list of all channels in this histogram.
void output (ostream &, const string &name, unsigned int flags=0, char comment= '#') const
 Output a channel to the given ostream as a ascii table.
void store (const string &name)
 Write out the histogram to a file name.h2.
bool load (const string &name)
 Read in the histogram from a file name.h2 .
Histogram2Ptr loadToHistogram (const string &name) const
 Read in the histogram from a file name.h2 into a new histogram.
void combine (const string &prefix, const string &name, unsigned int numRuns, const string &dataChannel="", const string &mcChannel="MC")
 Combine histograms.
CrossSection xSec () const
 Return the cross section accumulated in this histogram.
void xSec (CrossSection)
 Set the cross section accumulated in this histogram.
Backward compatibility to Histogram. Note that prefactor is

is not supported (instead use multiplication operator and/or the normalise methods for the channel(s) to be considered).

 Histogram2 (vector< double > limits)
 Construct from vector of lower limits and upper limit of last bin and insert an initial counting channel mc.
 Histogram2 (vector< double > limits, vector< double > data, vector< double > dataerror)
 Construct giving the lower limits, followed by the upper limit of the last bin.
void operator+= (double)
 Operator to add a point to the histogrma with unit weight.
void addWeighted (double data, double weight)
 Function to add a weighted point to the histogram.
unsigned int numberOfBins () const
 Number of bins (not counting the overflow)
void normaliseToData ()
 Normalise the distributions to the data.
void chiSquared (double &chisq, unsigned int &ndegrees, double minfrac=0.) const
 Return the chi squared It assumes two channels to be present: mc and data.
Histogram2 ratioWith (const Histogram2 &h2) const
 Returns a new histogram containing bin-by-bin ratios of two histograms.
Functions used by the persistent I/O system.
void persistentOutput (PersistentOStream &os) const
 Function used to write out object persistently.
void persistentInput (PersistentIStream &is, int version)
 Function used to read in object persistently.

Static Public Member Functions

static void Init ()
 The standard Init function used to initialize the interfaces.

Protected Member Functions

Clone Methods.
virtual IBPtr clone () const
 Make a simple clone of this object.
virtual IBPtr fullclone () const
 Make a clone of this object, possibly modifying the cloned object to make it sane.

Private Member Functions

Histogram2operator= (const Histogram2 &)
 The assignment operator is private and must never be called.

Private Attributes

vector< pair< double, double > > _binning
 The binning.
pair< double, double > _range
 Seperatly keep the lowest bins lower and the highest bins uper bound to identify events ind under-/overflow.
map< double, unsigned int > _binhash
 Bin hashing: Map each bins upper bound to the bin id.
map< string, HistogramChannel_channels
 Map channels by their name.
CrossSection _xSec
 The cross section this histogram accumulated according to the event generator.

Static Private Attributes

static ClassDescription
< Histogram2
initHistogram2
 The static object used to initialize the description of this class.

Detailed Description

A more sophisticated histogram.

It is almost completely compatible to Histogram, but will use a different way to actually dump the histogram for use with the favorite plotting program.

See also:
The interfaces defined for Histogram2.

Definition at line 460 of file Histogram2.h.


Constructor & Destructor Documentation

Analysis2::Histogram2::Histogram2 ( double  low,
double  high,
unsigned int  bins,
const string &  name = "mc" 
) [explicit]

Construct giving the range and a number of bins and insert a counting channel with name.

If name is empty, no channel is inserted. Default name is given for backward compatibility.

Analysis2::Histogram2::Histogram2 ( const vector< pair< double, double > > &  ,
const string &  name 
) [explicit]

Construct giving a binning and insert a counting channel with name.

If name is empty, no channel is inserted.

Analysis2::Histogram2::Histogram2 ( const string &  dataFile,
const string &  dataName 
) [explicit]

Construct giving a name of a data file and a name for the resulting channel.

The data file is assumed to be in the format bin_low bin_high data error

Analysis2::Histogram2::Histogram2 ( vector< double >  limits,
vector< double >  data,
vector< double >  dataerror 
) [explicit]

Construct giving the lower limits, followed by the upper limit of the last bin.

Inserts channels data and mc


Member Function Documentation

void Analysis2::Histogram2::chiSquared ( double &  chisq,
unsigned int &  ndegrees,
double  minfrac = 0. 
) const [inline]

Return the chi squared It assumes two channels to be present: mc and data.

This is not checked!

virtual IBPtr Analysis2::Histogram2::clone ( ) const [inline, protected, virtual]

Make a simple clone of this object.

Returns:
a pointer to the new object.

Implements ThePEG::InterfacedBase.

void Analysis2::Histogram2::combine ( const string &  prefix,
const string &  name,
unsigned int  numRuns,
const string &  dataChannel = "",
const string &  mcChannel = "MC" 
)

Combine histograms.

Each run is assumed to be in a subdirectory prefix.runId, having written the histogram to a file prefix.runId/name.h2

runId is assumed to range from 0 to numRuns-1

dataChannel indicates a channel which is to be included only once.

All other channels are added into this histogram. If a mcChannel is given, this is used to compute the total cross section for the combined histogram.

virtual IBPtr Analysis2::Histogram2::fullclone ( ) const [inline, protected, virtual]

Make a clone of this object, possibly modifying the cloned object to make it sane.

Returns:
a pointer to the new object.

Reimplemented from ThePEG::InterfacedBase.

static void Analysis2::Histogram2::Init ( ) [static]

The standard Init function used to initialize the interfaces.

Called exactly once for each class by the class description system before the main function starts or when this class is dynamically loaded.

Reimplemented from ThePEG::Interfaced.

bool Analysis2::Histogram2::load ( const string &  name)

Read in the histogram from a file name.h2 .

Return false, if something did go wrong.

Histogram2Ptr Analysis2::Histogram2::loadToHistogram ( const string &  name) const

Read in the histogram from a file name.h2 into a new histogram.

It returns null, if reading failed.

void Analysis2::Histogram2::normaliseToCrossSection ( const string &  name = "mc") [inline]

Normalise a channel to the total cross section.

Default argument for backwards compatibility.

Histogram2& Analysis2::Histogram2::operator= ( const Histogram2 ) [private]

The assignment operator is private and must never be called.

In fact, it should not even be implemented.

Function used to read in object persistently.

Parameters:
isthe persistent input stream read from.
versionthe version number of the object when written.

Reimplemented from ThePEG::Interfaced.

Function used to write out object persistently.

Parameters:
osthe persistent output stream written to.

Reimplemented from ThePEG::Interfaced.


Member Data Documentation

vector<pair<double,double> > Analysis2::Histogram2::_binning [private]

The binning.

This identifies bin ids as the vector indices.

Definition at line 818 of file Histogram2.h.

The static object used to initialize the description of this class.

Indicates that this is an abstract class without persistent data.

Definition at line 847 of file Histogram2.h.


The documentation for this class was generated from the following file: