thepeg
is hosted by
Hepforge
,
IPPP Durham
ThePEG
2.3.0
Analysis
LWH
Axis.h
1
// -*- C++ -*-
2
//
3
// Axis.h is a part of ThePEG - Toolkit for HEP Event Generation
4
// Copyright (C) 1999-2019 Leif Lonnblad
5
//
6
// ThePEG is licenced under version 3 of the GPL, see COPYING for details.
7
// Please respect the MCnet academic guidelines, see GUIDELINES for details.
8
//
9
#ifndef LWH_Axis_H
10
#define LWH_Axis_H
11
//
12
// This is the declaration of the Axis class representing
13
//
14
15
16
#include <limits>
17
#include <cmath>
18
#include <algorithm>
19
#include "AIAxis.h"
20
21
namespace
LWH
{
22
23
using namespace
AIDA;
24
30
class
Axis
:
public
IAxis {
31
32
public
:
33
37
Axis
(
int
n,
double
lo,
double
up)
38
:
lower
(lo),
upper
(up),
nbins
(n) {}
39
43
Axis
(
const
Axis
& a)
44
: IAxis(a),
lower
(a.
lower
),
upper
(a.
upper
),
nbins
(a.
nbins
) {}
45
47
virtual
~Axis
() { }
48
55
bool
isFixedBinning
()
const
{
return
true
; }
56
62
double
lowerEdge
()
const
{
return
lower
; }
63
69
double
upperEdge
()
const
{
return
upper
; }
70
76
int
bins
()
const
{
return
nbins
; }
77
86
double
binLowerEdge
(
int
index)
const
{
87
return
index < 0? -std::numeric_limits<double>::max():
88
lower
+ double(std::min(index,
nbins
))*
binWidth
(0);
89
}
90
99
double
binUpperEdge
(
int
index)
const
{
100
return
index >=
nbins
? std::numeric_limits<double>::max():
101
lower
+ double(std::max(index, -1) + 1)*
binWidth
(0);
102
}
103
111
double
binWidth
(
int
)
const
{
112
return
(
upper
-
lower
)/double(
nbins
);
113
}
114
124
int
coordToIndex
(
double
coord)
const
{
125
if
( coord >=
upper
)
return
OVERFLOW_BIN;
126
else
if
( coord <
lower
)
return
UNDERFLOW_BIN;
127
else
return
int((coord -
lower
)/
binWidth
(0));
128
}
129
134
double
binMidPoint
(
int
index)
const
{
135
return
lower
+ (double(index) + 0.5)*
binWidth
(0);
136
}
137
138
private
:
139
141
double
lower
;
142
144
double
upper
;
145
147
int
nbins
;
148
149
};
150
151
}
152
153
#endif
/* LWH_Axis_H */
LWH::Axis
An Axis represents a binned histogram axis.
Definition:
Axis.h:30
LWH::Axis::binWidth
double binWidth(int) const
Get the width of the specified bin.
Definition:
Axis.h:111
LWH::Axis::binUpperEdge
double binUpperEdge(int index) const
Get the upper edge of the specified bin.
Definition:
Axis.h:99
LWH::Axis::Axis
Axis(const Axis &a)
Copy constructor.
Definition:
Axis.h:43
LWH::Axis::lower
double lower
The lower edge.
Definition:
Axis.h:141
LWH::Axis::isFixedBinning
bool isFixedBinning() const
Check if the IAxis has fixed binning, i.e.
Definition:
Axis.h:55
LWH::Axis::binMidPoint
double binMidPoint(int index) const
Return the midpoint of the specified bin.
Definition:
Axis.h:134
LWH::Axis::~Axis
virtual ~Axis()
Destructor.
Definition:
Axis.h:47
LWH::Axis::upperEdge
double upperEdge() const
Get the upper edge of the IAxis.
Definition:
Axis.h:69
LWH::Axis::coordToIndex
int coordToIndex(double coord) const
Convert a coordinate on the axis to a bin number.
Definition:
Axis.h:124
LWH::Axis::binLowerEdge
double binLowerEdge(int index) const
Get the lower edge of the specified bin.
Definition:
Axis.h:86
LWH::Axis::lowerEdge
double lowerEdge() const
Get the lower edge of the IAxis.
Definition:
Axis.h:62
LWH::Axis::upper
double upper
The upper edge.
Definition:
Axis.h:144
LWH::Axis::Axis
Axis(int n, double lo, double up)
Standard constructor.
Definition:
Axis.h:37
LWH::Axis::bins
int bins() const
The number of bins (excluding underflow and overflow) on the IAxis.
Definition:
Axis.h:76
LWH::Axis::nbins
int nbins
The number of bins.
Definition:
Axis.h:147
LWH
The LWH namespace contains a Light-Weight Histogram package which implements the most rudimentary his...
Definition:
AnalysisFactory.h:35
Generated on Thu Jun 20 2024 14:47:00 for ThePEG by
1.9.6