thepeg
is hosted by
Hepforge
,
IPPP Durham
ThePEG
2.3.0
Analysis
LWH
VariAxis.h
1
// -*- C++ -*-
2
//
3
// VariAxis.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_VariAxis_H
10
#define LWH_VariAxis_H
11
//
12
// This is the declaration of the VariAxis class representing
13
//
14
15
16
#include <limits>
17
#include <cmath>
18
#include <algorithm>
19
#include <map>
20
#include "AIAxis.h"
21
22
namespace
LWH
{
23
24
using namespace
AIDA;
25
31
class
VariAxis
:
public
IAxis {
32
33
public
:
34
38
VariAxis
(
const
std::vector<double> & edges) {
39
for
(
int
i = 0, N = edges.size(); i < N; ++i )
binco
[edges[i]] = 0;
40
std::map<double,int>::iterator it =
binco
.begin();
41
for
(
int
i = 0, N = edges.size(); i < N; ++i ) (it++)->second = i;
42
}
43
47
VariAxis
(
const
VariAxis
& a)
48
: IAxis(a),
binco
(a.
binco
) {}
49
51
virtual
~VariAxis
() { }
52
59
bool
isFixedBinning
()
const
{
return
false
; }
60
66
double
lowerEdge
()
const
{
67
if
(
binco
.size() )
return
binco
.begin()->first;
68
return
0;
69
}
70
76
double
upperEdge
()
const
{
77
if
( !
binco
.size() )
return
0;
78
std::map<double,int>::const_iterator last =
binco
.end();
79
return
(--last)->first;
80
}
81
87
int
bins
()
const
{
return
binco
.size() - 1; }
88
97
std::pair<double,double>
binEdges
(
int
index)
const
{
98
std::pair<double,double> edges(0.0, 0.0);
99
if
( !
binco
.size() )
return
edges;
100
std::map<double,int>::const_iterator lo =
binco
.end();
101
std::map<double,int>::const_iterator up =
binco
.begin();
102
if
( index >= 0 )
while
( index-- >= 0 && up !=
binco
.end() ) lo = up++;
103
edges.first = ( lo ==
binco
.end() )? -std::numeric_limits<double>::max():
104
lo->first;
105
edges.second = ( up ==
binco
.end() )? std::numeric_limits<double>::max():
106
up->first;
107
return
edges;
108
}
109
118
double
binLowerEdge
(
int
index)
const
{
119
return
binEdges
(index).first;
120
}
121
130
double
binUpperEdge
(
int
index)
const
{
131
return
binEdges
(index).second;
132
}
133
141
double
binWidth
(
int
index)
const
{
142
std::pair<double,double> edges =
binEdges
(index);
143
return
edges.second - edges.first;
144
}
145
155
int
coordToIndex
(
double
coord)
const
{
156
std::map<double,int>::const_iterator up =
binco
.upper_bound(coord);
157
if
( up ==
binco
.begin() )
return
UNDERFLOW_BIN;
158
else
if
( up ==
binco
.end() )
return
OVERFLOW_BIN;
159
else
return
up->second - 1;
160
}
161
166
double
binMidPoint
(
int
index)
const
{
167
std::pair<double,double> edges =
binEdges
(index);
168
return
(edges.second + edges.first)/2.0;
169
}
170
171
private
:
172
177
std::map<double,int>
binco
;
178
179
};
180
181
}
182
183
#endif
/* LWH_VariAxis_H */
LWH::VariAxis
An VariAxis represents a binned histogram axis.
Definition:
VariAxis.h:31
LWH::VariAxis::binUpperEdge
double binUpperEdge(int index) const
Get the upper edge of the specified bin.
Definition:
VariAxis.h:130
LWH::VariAxis::VariAxis
VariAxis(const std::vector< double > &edges)
Standard constructor.
Definition:
VariAxis.h:38
LWH::VariAxis::binWidth
double binWidth(int index) const
Get the width of the specified bin.
Definition:
VariAxis.h:141
LWH::VariAxis::~VariAxis
virtual ~VariAxis()
Destructor.
Definition:
VariAxis.h:51
LWH::VariAxis::bins
int bins() const
The number of bins (excluding underflow and overflow) on the IAxis.
Definition:
VariAxis.h:87
LWH::VariAxis::isFixedBinning
bool isFixedBinning() const
Check if the IAxis has fixed binning, i.e.
Definition:
VariAxis.h:59
LWH::VariAxis::binLowerEdge
double binLowerEdge(int index) const
Get the lower edge of the specified bin.
Definition:
VariAxis.h:118
LWH::VariAxis::binco
std::map< double, int > binco
A map relating the lower edge of a bin to the corresponding bin number.
Definition:
VariAxis.h:177
LWH::VariAxis::binMidPoint
double binMidPoint(int index) const
Return the midpoint of the specified bin.
Definition:
VariAxis.h:166
LWH::VariAxis::lowerEdge
double lowerEdge() const
Get the lower edge of the IAxis.
Definition:
VariAxis.h:66
LWH::VariAxis::coordToIndex
int coordToIndex(double coord) const
Convert a coordinate on the axis to a bin number.
Definition:
VariAxis.h:155
LWH::VariAxis::binEdges
std::pair< double, double > binEdges(int index) const
Get the lower edge of the specified bin.
Definition:
VariAxis.h:97
LWH::VariAxis::upperEdge
double upperEdge() const
Get the upper edge of the IAxis.
Definition:
VariAxis.h:76
LWH::VariAxis::VariAxis
VariAxis(const VariAxis &a)
Copy constructor.
Definition:
VariAxis.h:47
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