/usr/include/ThePEG/Analysis/LWH/VariAxis.h is in libthepeg-dev 1.8.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | // -*- C++ -*-
//
// VariAxis.h is a part of ThePEG - Toolkit for HEP Event Generation
// Copyright (C) 1999-2011 Leif Lonnblad
//
// ThePEG is licenced under version 2 of the GPL, see COPYING for details.
// Please respect the MCnet academic guidelines, see GUIDELINES for details.
//
#ifndef LWH_VariAxis_H
#define LWH_VariAxis_H
//
// This is the declaration of the VariAxis class representing
//
#include <limits>
#include <cmath>
#include <algorithm>
#include <map>
#include "AIAxis.h"
namespace LWH {
using namespace AIDA;
/**
* An VariAxis represents a binned histogram axis. A 1D Histogram would have
* one VariAxis representing the X axis, while a 2D Histogram would have two
* axes representing the X and Y VariAxis.
*/
class VariAxis: public IAxis {
public:
/**
* Standard constructor.
*/
VariAxis(const std::vector<double> & edges) {
for ( int i = 0, N = edges.size(); i < N; ++i ) binco[edges[i]] = 0;
std::map<double,int>::iterator it = binco.begin();
for ( int i = 0, N = edges.size(); i < N; ++i ) (it++)->second = i;
}
/**
* Copy constructor.
*/
VariAxis(const VariAxis & a)
: IAxis(a), binco(a.binco) {}
/// Destructor.
virtual ~VariAxis() { }
/**
* Check if the IAxis has fixed binning, i.e. if all the bins have
* the same width. @return <code>true</code> if the binning is
* fixed, <code>false</code> otherwise.
*
*/
bool isFixedBinning() const {return false; }
/**
* Get the lower edge of the IAxis.
* @return The IAxis's lower edge.
*
*/
double lowerEdge() const {
if ( binco.size() ) return binco.begin()->first;
return 0;
}
/**
* Get the upper edge of the IAxis.
* @return The IAxis's upper edge.
*
*/
double upperEdge() const {
if ( !binco.size() ) return 0;
std::map<double,int>::const_iterator last = binco.end();
return (--last)->first;
}
/**
* The number of bins (excluding underflow and overflow) on the IAxis.
* @return The IAxis's number of bins.
*
*/
int bins() const { return binco.size() - 1; }
/**
* Get the lower edge of the specified bin.
* @param index The bin number: 0 to bins()-1 for the in-range bins
* or OVERFLOW or UNDERFLOW.
* @return The lower edge of the corresponding bin; for the
* underflow bin this is <tt>Double.NEGATIVE_INFINITY</tt>.
*
*/
std::pair<double,double> binEdges(int index) const {
std::pair<double,double> edges(0.0, 0.0);
if ( !binco.size() ) return edges;
std::map<double,int>::const_iterator lo = binco.end();
std::map<double,int>::const_iterator up = binco.begin();
if ( index >= 0 ) while ( index-- >= 0 && up != binco.end() ) lo = up++;
edges.first = ( lo == binco.end() )? -std::numeric_limits<double>::max():
lo->first;
edges.second = ( up == binco.end() )? std::numeric_limits<double>::max():
up->first;
return edges;
}
/**
* Get the lower edge of the specified bin.
* @param index The bin number: 0 to bins()-1 for the in-range bins
* or OVERFLOW or UNDERFLOW.
* @return The lower edge of the corresponding bin; for the
* underflow bin this is <tt>Double.NEGATIVE_INFINITY</tt>.
*
*/
double binLowerEdge(int index) const {
return binEdges(index).first;
}
/**
* Get the upper edge of the specified bin.
* @param index The bin number: 0 to bins()-1 for the in-range bins
* or OVERFLOW or UNDERFLOW.
* @return The upper edge of the corresponding bin; for the overflow
* bin this is <tt>Double.POSITIVE_INFINITY</tt>.
*
*/
double binUpperEdge(int index) const {
return binEdges(index).second;
}
/**
* Get the width of the specified bin.
* @param index The bin number: 0 to bins()-1) for the in-range bins
* or OVERFLOW or UNDERFLOW.
* @return The width of the corresponding bin.
*
*/
double binWidth(int index) const {
std::pair<double,double> edges = binEdges(index);
return edges.second - edges.first;
}
/**
* Convert a coordinate on the axis to a bin number. If the
* coordinate is less than the lowerEdge UNDERFLOW is returned; if
* the coordinate is greater or equal to the upperEdge OVERFLOW is
* returned.
* @param coord The coordinate to be converted.
* @return The corresponding bin number.
*
*/
int coordToIndex(double coord) const {
std::map<double,int>::const_iterator up = binco.upper_bound(coord);
if ( up == binco.begin() ) return UNDERFLOW_BIN;
else if ( up == binco.end() ) return OVERFLOW_BIN;
else return up->second - 1;
}
/**
* Return the midpoint of the specified bin. No checking is
* performed to ensure the argument is a valid bin.
*/
double binMidPoint(int index) const {
std::pair<double,double> edges = binEdges(index);
return (edges.second + edges.first)/2.0;
}
private:
/**
* A map relating the lower edge of a bin to the corresponding bin
* number.
*/
std::map<double,int> binco;
};
}
#endif /* LWH_VariAxis_H */
|