ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
InnerDetector
InDetValidation
InDetPhysValMonitoring
src
logLinearBinning.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3
*/
4
//
5
// logLinearBinning.h
6
//
7
//
8
// Created by sroe on 22/11/2019, based on code by Max Goblirsch-Kolb.
9
//
10
#include "
logLinearBinning.h
"
11
#include <stdexcept>
12
#include <cmath>
13
#include <algorithm>
14
namespace
IDPVM
{
15
std::vector<double>
16
logLinearBinning
(
const
unsigned
int
nBins,
const
double
absXmin,
const
double
absXmax,
const
bool
symmetriseAroundZero){
17
// some checks to ensure the user is requesting something sensible
18
if
(absXmin <=0 or absXmax <=0){
19
throw
std::range_error(
"absXmin or absXmax argument to logLinearBinning is out of range"
);
20
}
else
if
(nBins ==0){
21
throw
std::range_error(
"nBins argument to logLinearBinning is zero"
);
22
}
23
// reserve the vector space
24
const
unsigned
int
asymVecSize = nBins + 1;
25
std::vector<double> theBinning(asymVecSize,0.);
26
// define our starting bin edge and step size in log space
27
const
double
logStart = std::log(absXmin);
28
const
double
logDist = std::log(absXmax) - logStart;
29
const
double
logStep = logDist / (double) nBins;
30
// then populate the bin array
31
double
thisLog{logStart};
32
for
(
auto
& thisBin:theBinning){
33
thisBin=std::exp(thisLog);
34
thisLog+=logStep;
35
}
36
//sroe: I think the following is logically incorrect, but for now will reproduce the original functionality
37
//pending testing
38
//
39
// if we want to symmetrise, we need one extra step to add the negative
40
// half axis (and the division at zero).
41
if
(symmetriseAroundZero){
42
std::vector<double> aux_negative;
43
aux_negative.reserve(nBins+1);
44
// flip signs (and populate new vec)
45
std::transform(theBinning.begin(),theBinning.end(), std::back_inserter(aux_negative),
46
[](
double
& val){return -1. * val;});
47
// reorder
48
std::reverse
(aux_negative.begin(),aux_negative.end());
49
// and add the split at zero
50
aux_negative.push_back(0.);
51
// then put it all together
52
theBinning.insert(theBinning.begin(), aux_negative.begin(), aux_negative.end());
53
}
54
return
theBinning;
55
}
56
}
logLinearBinning.h
IDPVM
Class to retrieve associated truth from a track, implementing a cached response.
Definition
InDetPhysValMonitoringTool.h:56
IDPVM::logLinearBinning
std::vector< double > logLinearBinning(const unsigned int nBins, const double absXmin, const double absXmax, const bool symmetriseAroundZero)
Definition
logLinearBinning.cxx:16
std::reverse
void reverse(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of reverse for DataVector/List.
Definition
DVL_algorithms.h:280
Generated on
for ATLAS Offline Software by
1.17.0