ATLAS Offline Software
Loading...
Searching...
No Matches
TFCS1DFunctionInt8Int16InterpolationHistogram Class Referenceabstract

#include <TFCS1DFunctionTemplateInterpolationHistogram.h>

Inheritance diagram for TFCS1DFunctionInt8Int16InterpolationHistogram:
Collaboration diagram for TFCS1DFunctionInt8Int16InterpolationHistogram:

Public Types

typedef TFCS1DFunction_size_t size_t
typedef float random_type
typedef TFCS1DFunction_HistogramInt8BinEdges xvec_type
typedef uint16_t y_value_type

Public Member Functions

 TFCS1DFunctionInt8Int16InterpolationHistogram (TH1 *h=nullptr)
virtual void rnd_to_fct (float value[], const float rnd[]) const
 Function gets array of random numbers rnd[] in the range [0,1) as arguments and returns function value in array value.
virtual double rnd_to_fct (double rnd) const =0
 Function gets random number rnd in the range [0,1) as argument and returns function value.
std::size_t MemorySizeArray () const
std::size_t MemorySize () const
 Gives the total memory size, including the size of additional memory allocated inside the class.
void set_nbins (size_t nbins)
 set number of bins
size_t get_nbins () const
 return number of bins
void Initialize (const TH1 *hist, bool doprint=true)
 Initialize from root histogram.
const TFCS1DFunction_HistogramInt8BinEdgesget_HistoBordersx () const
const TFCS1DFunction_HistogramContent< uint16_t, float > & get_HistoContents () const
virtual int ndim () const
 Return the number of dimensions for the function.
virtual bool operator== (const TFCS1DFunction &ref) const
 The == operator compares the content of instances.
bool msgLvl (const MSG::Level lvl) const
 Check whether the logging system is active at the provided verbosity level.
MsgStream & msg () const
 Return a stream for sending messages directly (no decoration)
MsgStream & msg (const MSG::Level lvl) const
 Return a decorated starting stream for sending messages.
MSG::Level level () const
 Retrieve output level.
virtual void setLevel (MSG::Level lvl)
 Update outputlevel.

Static Public Member Functions

static double get_maxdev (TH1 *, TH1 *)
static double CheckAndIntegrate1DHistogram (const TH1 *hist, std::vector< double > &integral_vec, int &first, int &last)
static TH1 *generate_histogram_random_slope ATLAS_NOT_THREAD_SAFE (int nbinsx=50, double xmin=0, double xmax=1, double zerothreshold=0.1)
static TH1 *generate_histogram_random_gauss ATLAS_NOT_THREAD_SAFE (int nbinsx=50, int ntoy=100000, double xmin=1, double xmax=5, double xpeak=1.5, double sigma=0.6)
static void unit_test ATLAS_NOT_THREAD_SAFE (TH1 *hist, TFCS1DFunction *rtof, int nrnd=1000000, TH1 *histfine=nullptr)
static std::string startMsg (MSG::Level lvl, const std::string &file, int line)
 Make a message to decorate the start of logging.

Protected Attributes

TFCS1DFunction_HistogramInt8BinEdges m_HistoBorders
TFCS1DFunction_HistogramContent< uint16_t, float > m_HistoContents

Private Attributes

std::string m_nm
 Message source name.

Static Private Attributes

static boost::thread_specific_ptr< MsgStream > m_msg_tls ATLAS_THREAD_SAFE
 Do not persistify!

Detailed Description

Member Typedef Documentation

◆ random_type

typedef float TFCS1DFunctionTemplateHistogram< TFCS1DFunction_HistogramInt8BinEdges, uint16_t, float >::random_type
inherited

Definition at line 18 of file TFCS1DFunctionTemplateHistogram.h.

◆ size_t

◆ xvec_type

◆ y_value_type

typedef uint16_t TFCS1DFunctionTemplateHistogram< TFCS1DFunction_HistogramInt8BinEdges, uint16_t, float >::y_value_type
inherited

Definition at line 20 of file TFCS1DFunctionTemplateHistogram.h.

Constructor & Destructor Documentation

◆ TFCS1DFunctionInt8Int16InterpolationHistogram()

TFCS1DFunctionInt8Int16InterpolationHistogram::TFCS1DFunctionInt8Int16InterpolationHistogram ( TH1 * h = nullptr)
inline

Member Function Documentation

◆ ATLAS_NOT_THREAD_SAFE() [1/3]

TH1 *generate_histogram_random_slope TFCS1DFunction::ATLAS_NOT_THREAD_SAFE ( int nbinsx = 50,
double xmin = 0,
double xmax = 1,
double zerothreshold = 0.1 )
staticinherited

◆ ATLAS_NOT_THREAD_SAFE() [2/3]

TH1 *generate_histogram_random_gauss TFCS1DFunction::ATLAS_NOT_THREAD_SAFE ( int nbinsx = 50,
int ntoy = 100000,
double xmin = 1,
double xmax = 5,
double xpeak = 1.5,
double sigma = 0.6 )
staticinherited

◆ ATLAS_NOT_THREAD_SAFE() [3/3]

void unit_test TFCS1DFunction::ATLAS_NOT_THREAD_SAFE ( TH1 * hist,
TFCS1DFunction * rtof,
int nrnd = 1000000,
TH1 * histfine = nullptr )
staticinherited

◆ CheckAndIntegrate1DHistogram()

double TFCS1DFunction::CheckAndIntegrate1DHistogram ( const TH1 * hist,
std::vector< double > & integral_vec,
int & first,
int & last )
staticinherited

Definition at line 53 of file TFCS1DFunction.cxx.

54 {
55 ISF_FCS::MLogging logger;
56 Int_t nbins = hist->GetNbinsX();
57
58 float integral = 0;
59 integral_vec.resize(nbins);
60 for (int ix = 1; ix <= nbins; ix++) {
61 float binval = hist->GetBinContent(ix);
62 if (binval < 0) {
63 // Can't work if a bin is negative, forcing bins to 0 in this case
64 double fraction = binval / hist->Integral();
65 if (std::abs(fraction) > 1e-5) {
66 ATH_MSG_NOCLASS(logger, "Warning: bin content is negative in histogram "
67 << hist->GetName() << " : "
68 << hist->GetTitle() << " binval=" << binval
69 << " " << fraction * 100
70 << "% of integral=" << hist->Integral()
71 << ". Forcing bin to 0.");
72 }
73 binval = 0;
74 }
75 integral += binval;
76 integral_vec[ix - 1] = integral;
77 }
78
79 for (first = 0; first < nbins; first++)
80 if (integral_vec[first] != 0)
81 break;
82 for (last = nbins - 1; last > 0; last--)
83 if (integral_vec[last] != integral)
84 break;
85 last++;
86
87 if (integral <= 0) {
88 ATH_MSG_NOCLASS(logger, "Error: histogram "
89 << hist->GetName() << " : " << hist->GetTitle()
90 << " integral=" << integral << " is <=0");
91 }
92 return integral;
93}
#define ATH_MSG_NOCLASS(logger_name, x)
Definition MLogging.h:52
double integral(TH1 *h)
Definition computils.cxx:59
static Root::TMsgLogger logger("iLumiCalc")
bool first
Definition DeMoScan.py:534

◆ get_HistoBordersx()

◆ get_HistoContents()

const TFCS1DFunction_HistogramContent< uint16_t, float > & TFCS1DFunctionTemplateHistogram< TFCS1DFunction_HistogramInt8BinEdges, uint16_t, float >::get_HistoContents ( ) const
inlineinherited

Definition at line 134 of file TFCS1DFunctionTemplateHistogram.h.

134 {
135 return m_HistoContents;
136 };

◆ get_maxdev()

double TFCS1DFunction::get_maxdev ( TH1 * h_input1,
TH1 * h_approx1 )
staticinherited

Definition at line 22 of file TFCS1DFunction.cxx.

22 {
23 TH1D *h_input = (TH1D *)h_input1->Clone("h_input");
24 TH1D *h_approx = (TH1D *)h_approx1->Clone("h_approx");
25
26 double maxdev = 0.0;
27
28 // normalize the histos to the same area:
29 double integral_input = h_input->Integral();
30 double integral_approx = 0.0;
31 for (int b = 1; b <= h_input->GetNbinsX(); b++)
32 integral_approx +=
33 h_approx->GetBinContent(h_approx->FindBin(h_input->GetBinCenter(b)));
34 h_approx->Scale(integral_input / integral_approx);
35
36 double ymax = h_approx->GetBinContent(h_approx->GetNbinsX()) -
37 h_approx->GetBinContent(h_approx->GetMinimumBin());
38 for (int i = 1; i <= h_input->GetNbinsX(); i++) {
39 double val = std::abs(h_approx->GetBinContent(
40 h_approx->FindBin(h_input->GetBinCenter(i))) -
41 h_input->GetBinContent(i)) /
42 ymax;
43 if (val > maxdev)
44 maxdev = val;
45 }
46
47 delete h_input;
48 delete h_approx;
49
50 return maxdev * 100.0;
51}
double ymax
Definition listroot.cxx:64

◆ get_nbins()

size_t TFCS1DFunctionTemplateHistogram< TFCS1DFunction_HistogramInt8BinEdges, uint16_t, float >::get_nbins ( ) const
inlineinherited

return number of bins

Definition at line 40 of file TFCS1DFunctionTemplateHistogram.h.

40{ return m_HistoContents.get_nbins(); };

◆ Initialize()

void TFCS1DFunctionTemplateHistogram< TFCS1DFunction_HistogramInt8BinEdges, uint16_t, float >::Initialize ( const TH1 * hist,
bool doprint = true )
inlineinherited

Initialize from root histogram.

Depending on the precision of the x- and y-axis, bins are merged if numerical identical

Definition at line 44 of file TFCS1DFunctionTemplateHistogram.h.

44 {
45 Int_t nbins = hist->GetNbinsX();
46
48 int first, last;
49 double integral =
51 if (integral <= 0) {
52 set_nbins(0);
53 } else {
55
56 m_HistoBorders.SetMinMax(hist->GetXaxis()->GetBinLowEdge(first + 1),
57 hist->GetXaxis()->GetBinUpEdge(last + 1));
58 Int_t ihist = 0;
59 for (Int_t ibin = first; ibin <= last; ++ibin) {
60 m_HistoBorders.SetBinLowEdge(ihist,
61 hist->GetXaxis()->GetBinLowEdge(ibin + 1));
62 if (ihist > 0)
63 if (m_HistoBorders.GetBinLowEdge(ihist - 1) ==
64 m_HistoBorders.GetBinLowEdge(ihist)) {
65 if (doprint)
66 ATH_MSG_INFO("Skip bin="
67 << ibin + 1
68 << " x=" << hist->GetXaxis()->GetBinLowEdge(ibin + 1)
69 << " fx=" << m_HistoBorders.GetBinLowEdge(ihist));
70 --ihist;
71 if (doprint)
72 ATH_MSG_INFO(" bin="
73 << ibin
74 << " x=" << hist->GetXaxis()->GetBinLowEdge(ibin)
75 << " fx=" << m_HistoBorders.GetBinLowEdge(ihist));
76 }
77 m_HistoContents.set_fraction(ihist,
79 if (ihist > 0)
80 if (m_HistoContents.get_fraction(ihist - 1) ==
81 m_HistoContents.get_fraction(ihist)) {
82 if (doprint)
83 ATH_MSG_INFO("Skip fbin="
84 << ihist
85 << " fx=" << m_HistoBorders.GetBinLowEdge(ihist)
86 << " frac=" << m_HistoContents.get_fraction(ihist));
87 --ihist;
88 if (doprint)
89 ATH_MSG_INFO(" fbin="
90 << ihist
91 << " fx=" << m_HistoBorders.GetBinLowEdge(ihist)
92 << " frac=" << m_HistoContents.get_fraction(ihist));
93 }
94
95 if (doprint)
96 ATH_MSG_INFO("bin=" << ibin + 1 << " fbin=" << ihist << "/"
97 << m_HistoBorders.get_nbins() << " x=["
98 << hist->GetXaxis()->GetBinLowEdge(ibin + 1)
99 << "," << hist->GetXaxis()->GetBinUpEdge(ibin + 1)
100 << "] fx=" << m_HistoBorders.GetBinLowEdge(ihist)
101 << " int=" << temp_HistoContents[ibin] / integral
102 << " frac="
103 << m_HistoContents.get_fraction(ihist));
104
105 ++ihist;
106 }
107 if (ihist != nbins) {
109 m_HistoBorders.SetMinMax(hist->GetXaxis()->GetBinLowEdge(first + 1),
110 hist->GetXaxis()->GetBinUpEdge(last + 1));
111 }
112 }
113 }
#define ATH_MSG_INFO(x)
static double CheckAndIntegrate1DHistogram(const TH1 *hist, std::vector< double > &integral_vec, int &first, int &last)

◆ level()

MSG::Level ISF_FCS::MLogging::level ( ) const
inlineinherited

Retrieve output level.

Definition at line 201 of file MLogging.h.

201{ return msg().level(); }
MsgStream & msg() const
Return a stream for sending messages directly (no decoration)
Definition MLogging.h:231

◆ MemorySize()

std::size_t TFCS1DFunctionTemplateHistogram< TFCS1DFunction_HistogramInt8BinEdges, uint16_t, float >::MemorySize ( ) const
inlinevirtualinherited

Gives the total memory size, including the size of additional memory allocated inside the class.

Reimplemented from TFCSFunction.

Definition at line 31 of file TFCS1DFunctionTemplateHistogram.h.

◆ MemorySizeArray()

std::size_t TFCS1DFunctionTemplateHistogram< TFCS1DFunction_HistogramInt8BinEdges, uint16_t, float >::MemorySizeArray ( ) const
inlineinherited

Definition at line 28 of file TFCS1DFunctionTemplateHistogram.h.

28 {
29 return m_HistoBorders.MemorySizeArray() + m_HistoContents.MemorySizeArray();
30 };

◆ msg() [1/2]

MsgStream & ISF_FCS::MLogging::msg ( ) const
inlineinherited

Return a stream for sending messages directly (no decoration)

Definition at line 231 of file MLogging.h.

231 {
232 MsgStream *ms = m_msg_tls.get();
233 if (!ms) {
234 ms = new MsgStream(Athena::getMessageSvc(), m_nm);
235 m_msg_tls.reset(ms);
236 }
237 return *ms;
238}
std::string m_nm
Message source name.
Definition MLogging.h:211
IMessageSvc * getMessageSvc(bool quiet=false)

◆ msg() [2/2]

MsgStream & ISF_FCS::MLogging::msg ( const MSG::Level lvl) const
inlineinherited

Return a decorated starting stream for sending messages.

Definition at line 240 of file MLogging.h.

240 {
241 return msg() << lvl;
242}

◆ msgLvl()

bool ISF_FCS::MLogging::msgLvl ( const MSG::Level lvl) const
inlineinherited

Check whether the logging system is active at the provided verbosity level.

Definition at line 222 of file MLogging.h.

222 {
223 if (msg().level() <= lvl) {
224 msg() << lvl;
225 return true;
226 } else {
227 return false;
228 }
229}
MSG::Level level() const
Retrieve output level.
Definition MLogging.h:201

◆ ndim()

virtual int TFCS1DFunction::ndim ( ) const
inlinevirtualinherited

Return the number of dimensions for the function.

Reimplemented from TFCSFunction.

Definition at line 22 of file TFCS1DFunction.h.

22{ return 1; };

◆ operator==()

virtual bool TFCS1DFunction::operator== ( const TFCS1DFunction & ref) const
inlinevirtualinherited

The == operator compares the content of instances.

The implementation in the base class only returns true for a comparison with itself

Reimplemented in TFCS1DFunctionInt32Histogram.

Definition at line 36 of file TFCS1DFunction.h.

36 {
37 return this == &ref;
38 };
const boost::regex ref(r_ef)

◆ rnd_to_fct() [1/2]

virtual double TFCS1DFunction::rnd_to_fct ( double rnd) const
pure virtualinherited

◆ rnd_to_fct() [2/2]

( float value[],
const float rnd[] ) const
virtualinherited

Function gets array of random numbers rnd[] in the range [0,1) as arguments and returns function value in array value.

For a n-dimensional function, value and rnd should both have n elements.

Reimplemented from TFCS1DFunctionTemplateHistogram< TFCS1DFunction_HistogramInt8BinEdges, uint16_t, float >.

◆ set_nbins()

void TFCS1DFunctionTemplateHistogram< TFCS1DFunction_HistogramInt8BinEdges, uint16_t, float >::set_nbins ( size_t nbins)
inlineinherited

set number of bins

Definition at line 34 of file TFCS1DFunctionTemplateHistogram.h.

34 {
35 m_HistoBorders.set_nbins(nbins);
36 m_HistoContents.set_nbins(nbins);
37 };

◆ setLevel()

void ISF_FCS::MLogging::setLevel ( MSG::Level lvl)
virtualinherited

Update outputlevel.

Definition at line 105 of file MLogging.cxx.

105 {
106 lvl = (lvl >= MSG::NUM_LEVELS) ? MSG::ALWAYS
107 : (lvl < MSG::NIL) ? MSG::NIL
108 : lvl;
109 msg().setLevel(lvl);
110}

◆ startMsg()

std::string ISF_FCS::MLogging::startMsg ( MSG::Level lvl,
const std::string & file,
int line )
staticinherited

Make a message to decorate the start of logging.

Print a message for the start of logging.

Definition at line 116 of file MLogging.cxx.

116 {
117 int col1_len = 20;
118 int col2_len = 5;
119 int col3_len = 10;
120 auto last_slash = file.find_last_of('/');
121 int path_len = last_slash == std::string::npos ? 0 : last_slash;
122 int trim_point = path_len;
123 int total_len = file.length();
124 if (total_len - path_len > col1_len)
125 trim_point = total_len - col1_len;
126 std::string trimmed_name = file.substr(trim_point);
127 const char *LevelNames[MSG::NUM_LEVELS] = {
128 "NIL", "VERBOSE", "DEBUG", "INFO", "WARNING", "ERROR", "FATAL", "ALWAYS"};
129 std::string level = LevelNames[lvl];
130 std::string level_string = std::string("(") + level + ") ";
131 std::stringstream output;
132 output << std::setw(col1_len) << std::right << trimmed_name << ":"
133 << std::setw(col2_len) << std::left << line << std::setw(col3_len)
134 << std::right << level_string;
135 return output.str();
136}
output
Definition merge.py:16
TFile * file

Member Data Documentation

◆ ATLAS_THREAD_SAFE

boost::thread_specific_ptr<MsgStream> m_msg_tls ISF_FCS::MLogging::ATLAS_THREAD_SAFE
inlinestaticprivateinherited

Do not persistify!

MsgStream instance (a std::cout like with print-out levels)

Definition at line 215 of file MLogging.h.

◆ m_HistoBorders

◆ m_HistoContents

TFCS1DFunction_HistogramContent<uint16_t, float> TFCS1DFunctionTemplateHistogram< TFCS1DFunction_HistogramInt8BinEdges, uint16_t, float >::m_HistoContents
protectedinherited

Definition at line 143 of file TFCS1DFunctionTemplateHistogram.h.

◆ m_nm

std::string ISF_FCS::MLogging::m_nm
privateinherited

Message source name.

Definition at line 211 of file MLogging.h.


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