ATLAS Offline Software
Loading...
Searching...
No Matches
TFCS1DFunctionSpline Class Reference

#include <TFCS1DFunctionSpline.h>

Inheritance diagram for TFCS1DFunctionSpline:
Collaboration diagram for TFCS1DFunctionSpline:

Public Member Functions

 TFCS1DFunctionSpline (TH1 *hist=nullptr, double maxdevgoal=0.01, double maxeffsiggoal=3, int maxnp=20)
 ~TFCS1DFunctionSpline ()
double Initialize (TH1 *hist, double maxdevgoal=0.01, double maxeffsiggoal=3, int maxnp=20)
double InitializeFromSpline (TH1 *hist, const TSpline3 &sp, double maxdevgoal=0.01, double maxeffsiggoal=3)
double InitializeEqualDistance (TH1 *hist, double maxdevgoal=0.01, double maxeffsiggoal=3, int nsplinepoints=5)
double InitializeEqualProbability (TH1 *hist, double maxdevgoal=0.01, double maxeffsiggoal=3, int nsplinepoints=5)
virtual double rnd_to_fct (double rnd) const
 Function gets random number rnd in the range [0,1) as argument and returns function value according to a histogram distribution.
const TSpline3 & spline () const
TSpline3 & spline ()
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 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.
virtual std::size_t MemorySize () const
 Gives the total memory size, including the size of additional memory allocated inside the class.
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 (const TH1 *hist, const TSpline3 &sp, double &maxeffsig, double &p_maxdev, double &p_maxeffsig, int ntoy=10000)
static void unit_test ATLAS_NOT_THREAD_SAFE (TH1 *hist=nullptr)
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.

Static Protected Member Functions

static double optimize (TSpline3 &sp_best, std::vector< double > &nprop, const TH1 *hist, TFCS1DFunctionInt32Histogram &hist_fct, double maxdevgoal=0.01, double maxeffsiggoal=3)

Protected Attributes

TSpline3 m_spline

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

Definition at line 17 of file TFCS1DFunctionSpline.h.

Constructor & Destructor Documentation

◆ TFCS1DFunctionSpline()

TFCS1DFunctionSpline::TFCS1DFunctionSpline ( TH1 * hist = nullptr,
double maxdevgoal = 0.01,
double maxeffsiggoal = 3,
int maxnp = 20 )
inline

Definition at line 21 of file TFCS1DFunctionSpline.h.

22 {
23 if (hist)
24 Initialize(hist, maxdevgoal, maxeffsiggoal, maxnp);
25 };
double Initialize(TH1 *hist, double maxdevgoal=0.01, double maxeffsiggoal=3, int maxnp=20)

◆ ~TFCS1DFunctionSpline()

TFCS1DFunctionSpline::~TFCS1DFunctionSpline ( )
inline

Definition at line 26 of file TFCS1DFunctionSpline.h.

26{};

Member Function Documentation

◆ ATLAS_NOT_THREAD_SAFE() [1/4]

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/4]

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/4]

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

◆ ATLAS_NOT_THREAD_SAFE() [4/4]

void unit_test TFCS1DFunctionSpline::ATLAS_NOT_THREAD_SAFE ( TH1 * hist = nullptr)
static

◆ 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_maxdev() [1/2]

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_maxdev() [2/2]

double TFCS1DFunctionSpline::get_maxdev ( const TH1 * hist,
const TSpline3 & sp,
double & maxeffsig,
double & p_maxdev,
double & p_maxeffsig,
int ntoy = 10000 )
static

Definition at line 320 of file TFCS1DFunctionSpline.cxx.

322 {
323 double maxdev = 0;
324 maxeffsig = 0;
325
326 TH1 *hist_clone = (TH1 *)hist->Clone("hist_clone");
327 hist_clone->SetDirectory(nullptr);
328 hist_clone->Reset();
329 double interr = 0;
330 double integral = hist->IntegralAndError(1, hist->GetNbinsX(), interr);
331 double effN = integral / interr;
332 effN *= effN;
333 // ATH_MSG_INFO("integral="<<integral<<" +- "<<interr<<"
334 // relerr="<<interr/integral); ATH_MSG_INFO("effN="<<effN<<" +-
335 // "<<TMath::Sqrt(effN)<<" relerr="<<1/TMath::Sqrt(effN));
336 double toyweight = 1.0 / ntoy;
337 for (int itoy = 0; itoy < ntoy; ++itoy) {
338 double prop = itoy * toyweight;
339 hist_clone->Fill(sp.Eval(prop), toyweight);
340 }
341
342 double int1 = 0;
343 double int2 = 0;
344 for (int i = 0; i <= hist->GetNbinsX() + 1; i++) {
345 int1 += hist->GetBinContent(i) / integral;
346 int2 += hist_clone->GetBinContent(i);
347 double val = TMath::Abs(int1 - int2);
348 if (val > maxdev) {
349 maxdev = val;
350 p_maxdev = int1;
351 }
352
353 // now view the normalized integral as selection efficiency from a total
354 // sample of sizze effN
355 double int1err = TMath::Sqrt(int1 * (1 - int1) / effN);
356 double valsig = 0;
357 if (int1err > 0)
358 valsig = val / int1err;
359 if (valsig > maxeffsig) {
360 maxeffsig = valsig;
361 p_maxeffsig = int1;
362 }
363
364 // ATH_MSG_INFO(i<<": diff="<<int1-int2<<" sig(diff)="<<valsig<<"
365 // int1="<<int1<<" +- "<<int1err<<" int2="<<int2<<" maxdev="<<maxdev<<"
366 // maxeffsig="<<maxeffsig);
367 }
368
369 delete hist_clone;
370
371 return maxdev;
372}
static Double_t sp

◆ Initialize()

double TFCS1DFunctionSpline::Initialize ( TH1 * hist,
double maxdevgoal = 0.01,
double maxeffsiggoal = 3,
int maxnp = 20 )

Definition at line 19 of file TFCS1DFunctionSpline.cxx.

20 {
21 double max_penalty_best = -1;
22 TSpline3 sp_best;
23 for (int np = 3; np <= maxnp; ++np) {
24 ATH_MSG_INFO("========== Spline #=" << np << " ==============");
25 double max_penalty;
26 if (max_penalty_best > 0) {
27 max_penalty =
28 InitializeFromSpline(hist, sp_best, maxdevgoal, maxeffsiggoal);
29 if (max_penalty_best < 0 || max_penalty < max_penalty_best) {
30 max_penalty_best = max_penalty;
31 sp_best = m_spline;
32 }
33 }
34
35 max_penalty = InitializeEqualDistance(hist, maxdevgoal, maxeffsiggoal, np);
36 if (max_penalty_best < 0 || max_penalty < max_penalty_best) {
37 max_penalty_best = max_penalty;
38 sp_best = m_spline;
39 }
40
41 max_penalty =
42 InitializeEqualProbability(hist, maxdevgoal, maxeffsiggoal, np);
43 if (max_penalty_best < 0 || max_penalty < max_penalty_best) {
44 max_penalty_best = max_penalty;
45 sp_best = m_spline;
46 }
47
48 ATH_MSG_INFO("========== Spline #=" << np << " max_penalty_best="
49 << max_penalty_best
50 << " ==============");
51 ATH_MSG(INFO) << "==== Best spline init | ";
52 for (int i = 0; i < sp_best.GetNp(); ++i) {
53 double p, x;
54 sp_best.GetKnot(i, p, x);
55 ATH_MSG(INFO) << i << " : p=" << p << " x=" << x << " ; ";
56 }
57 ATH_MSG(INFO) << " =====" << END_MSG(INFO);
58
59 if (max_penalty_best < 2)
60 break;
61 }
62 m_spline = sp_best;
63
64 return max_penalty_best;
65}
#define ATH_MSG(lvl)
#define ATH_MSG_INFO(x)
#define END_MSG(lvl)
Definition MLogging.h:171
#define x
double InitializeEqualDistance(TH1 *hist, double maxdevgoal=0.01, double maxeffsiggoal=3, int nsplinepoints=5)
double InitializeEqualProbability(TH1 *hist, double maxdevgoal=0.01, double maxeffsiggoal=3, int nsplinepoints=5)
double InitializeFromSpline(TH1 *hist, const TSpline3 &sp, double maxdevgoal=0.01, double maxeffsiggoal=3)

◆ InitializeEqualDistance()

double TFCS1DFunctionSpline::InitializeEqualDistance ( TH1 * hist,
double maxdevgoal = 0.01,
double maxeffsiggoal = 3,
int nsplinepoints = 5 )

Definition at line 136 of file TFCS1DFunctionSpline.cxx.

139 {
140 TFCS1DFunctionInt32Histogram hist_fct(hist);
141
142 double xmin = 0;
143 double xmax = 0;
144 for (int i = 1; i <= hist->GetNbinsX(); i++) {
145 xmin = hist->GetXaxis()->GetBinLowEdge(i);
146 if (hist->GetBinContent(i) > 0)
147 break;
148 }
149 for (int i = hist->GetNbinsX(); i >= 1; i--) {
150 xmax = hist->GetXaxis()->GetBinUpEdge(i);
151 if (hist->GetBinContent(i) > 0)
152 break;
153 }
154 // ATH_MSG_INFO("xmin="<<xmin<<" xmax="<<xmax);
155
156 double dx = (xmax - xmin) / (nsplinepoints - 1);
157
158 std::vector<double> nprop(nsplinepoints);
159 std::vector<double> nx(nsplinepoints);
160 nprop[0] = 0;
161 nx[0] = hist_fct.rnd_to_fct(nprop[0]);
162 // ATH_MSG_INFO(0<<" p="<<nprop[0]<<" x="<<nx[0]);
163 for (int i = 1; i < nsplinepoints; ++i) {
164 nx[i] = xmin + i * dx;
165 double p_min = 0;
166 double p_max = 1;
167 double p_test;
168 double tx;
169 do {
170 p_test = 0.5 * (p_min + p_max);
171 tx = hist_fct.rnd_to_fct(p_test);
172 if (nx[i] < tx)
173 p_max = p_test;
174 else
175 p_min = p_test;
176 if ((p_max - p_min) < 0.0000001)
177 break;
178 } while (TMath::Abs(tx - nx[i]) > dx / 10);
179 // ATH_MSG_INFO(i<<" p="<<p_test<<" x="<<tx);
180 nprop[i] = p_test;
181 }
182
183 double max_penalty =
184 optimize(m_spline, nprop, hist, hist_fct, maxdevgoal, maxeffsiggoal);
185 double maxeffsig;
186 double p_maxdev;
187 double p_maxeffsig;
188 double maxdev = get_maxdev(hist, m_spline, maxeffsig, p_maxdev, p_maxeffsig);
189 ATH_MSG_INFO("Spline init equ. dist. #=" << nsplinepoints << " : maxdev="
190 << maxdev << " p_maxdev=" << p_maxdev
191 << " maxeffsig=" << maxeffsig
192 << " p_maxeffsig=" << p_maxeffsig
193 << " max_penalty=" << max_penalty);
194 ATH_MSG(INFO) << " ";
195 for (int i = 0; i < m_spline.GetNp(); ++i) {
196 double p, x;
197 m_spline.GetKnot(i, p, x);
198 ATH_MSG(INFO) << i << " : p=" << p << " x=" << x << " ; ";
199 }
200 ATH_MSG(INFO) << END_MSG(INFO);
201 return max_penalty;
202}
static double get_maxdev(const TH1 *hist, const TSpline3 &sp, double &maxeffsig, double &p_maxdev, double &p_maxeffsig, int ntoy=10000)
static double optimize(TSpline3 &sp_best, std::vector< double > &nprop, const TH1 *hist, TFCS1DFunctionInt32Histogram &hist_fct, double maxdevgoal=0.01, double maxeffsiggoal=3)
double xmax
Definition listroot.cxx:61
double xmin
Definition listroot.cxx:60

◆ InitializeEqualProbability()

double TFCS1DFunctionSpline::InitializeEqualProbability ( TH1 * hist,
double maxdevgoal = 0.01,
double maxeffsiggoal = 3,
int nsplinepoints = 5 )

Definition at line 204 of file TFCS1DFunctionSpline.cxx.

207 {
208 TFCS1DFunctionInt32Histogram hist_fct(hist);
209
210 double dprop = 1.0 / (nsplinepoints - 1);
211 std::vector<double> nprop(nsplinepoints);
212 for (int i = 0; i < nsplinepoints; ++i) {
213 nprop[i] = i * dprop;
214 }
215
216 double max_penalty =
217 optimize(m_spline, nprop, hist, hist_fct, maxdevgoal, maxeffsiggoal);
218 double maxeffsig;
219 double p_maxdev;
220 double p_maxeffsig;
221 double maxdev = get_maxdev(hist, m_spline, maxeffsig, p_maxdev, p_maxeffsig);
222 ATH_MSG_INFO("Spline init equ. prob. #=" << nsplinepoints << " : maxdev="
223 << maxdev << " p_maxdev=" << p_maxdev
224 << " maxeffsig=" << maxeffsig
225 << " p_maxeffsig=" << p_maxeffsig
226 << " max_penalty=" << max_penalty);
227 ATH_MSG(INFO) << " ";
228 for (int i = 0; i < m_spline.GetNp(); ++i) {
229 double p, x;
230 m_spline.GetKnot(i, p, x);
231 ATH_MSG(INFO) << i << " : p=" << p << " x=" << x << " ; ";
232 }
233 ATH_MSG(INFO) << END_MSG(INFO);
234 return max_penalty;
235}

◆ InitializeFromSpline()

double TFCS1DFunctionSpline::InitializeFromSpline ( TH1 * hist,
const TSpline3 & sp,
double maxdevgoal = 0.01,
double maxeffsiggoal = 3 )

Definition at line 67 of file TFCS1DFunctionSpline.cxx.

69 {
70 TFCS1DFunctionInt32Histogram hist_fct(hist);
71
72 double maxeffsig;
73 double p_maxdev;
74 double p_maxeffsig;
75 double maxdev = get_maxdev(hist, sp, maxeffsig, p_maxdev, p_maxeffsig);
76 double p_improve;
77 if (maxdev / maxdevgoal > maxeffsig / maxeffsiggoal)
78 p_improve = p_maxdev;
79 else
80 p_improve = p_maxeffsig;
81
82 int nsplinepoints = sp.GetNp();
83 std::vector<double> nprop(nsplinepoints + 1);
84 int ind = 0;
85 ATH_MSG(INFO) << "Spline init p_improve=" << p_improve << " | ";
86 for (int i = 0; i < nsplinepoints; ++i) {
87 double p, x;
88 sp.GetKnot(i, p, x);
89 if (i == 0 && p_improve < p) {
90 nprop[ind] = (0 + p) / 2;
91 ATH_MSG(INFO) << ind << " : pi=" << nprop[ind] << " ; ";
92 ++ind;
93 }
94
95 nprop[ind] = p;
96 ATH_MSG(INFO) << ind << " : p=" << nprop[ind] << " ; ";
97 ++ind;
98
99 if (i == nsplinepoints - 1 && p_improve > p) {
100 nprop[ind] = (1 + p) / 2;
101 ATH_MSG(INFO) << ind << " : pi=" << nprop[ind] << " ; ";
102 ++ind;
103 }
104 if (i < nsplinepoints - 1) {
105 double pn, xn;
106 sp.GetKnot(i + 1, pn, xn);
107 if (p_improve > p && p_improve < pn) {
108 nprop[ind] = (p + pn) / 2;
109 ATH_MSG(INFO) << ind << " : pi=" << nprop[ind] << " ; ";
110 ++ind;
111 }
112 }
113 }
114 ATH_MSG(INFO) << END_MSG(INFO);
115 nsplinepoints = ind;
116 nprop.resize(nsplinepoints);
117
118 double max_penalty =
119 optimize(m_spline, nprop, hist, hist_fct, maxdevgoal, maxeffsiggoal);
120 maxdev = get_maxdev(hist, m_spline, maxeffsig, p_maxdev, p_maxeffsig);
121 ATH_MSG_INFO("Spline init spline #=" << nsplinepoints << " : maxdev="
122 << maxdev << " p_maxdev=" << p_maxdev
123 << " maxeffsig=" << maxeffsig
124 << " p_maxeffsig=" << p_maxeffsig
125 << " max_penalty=" << max_penalty);
126 ATH_MSG(INFO) << " ";
127 for (int i = 0; i < m_spline.GetNp(); ++i) {
128 double p, x;
129 m_spline.GetKnot(i, p, x);
130 ATH_MSG(INFO) << i << " : p=" << p << " x=" << x << " ; ";
131 }
132 ATH_MSG(INFO) << END_MSG(INFO);
133 return max_penalty;
134}

◆ 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()

virtual std::size_t TFCSFunction::MemorySize ( ) const
inlinevirtualinherited

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

Reimplemented in TFCS1DFunctionTemplateHistogram< Txvec, Ty, Trandom >, TFCS1DFunctionTemplateHistogram< TFCS1DFunction_HistogramInt16BinEdges, uint16_t, float >, TFCS1DFunctionTemplateHistogram< TFCS1DFunction_HistogramInt16BinEdges, uint32_t, float >, TFCS1DFunctionTemplateHistogram< TFCS1DFunction_HistogramInt32BinEdges, uint32_t, float >, TFCS1DFunctionTemplateHistogram< TFCS1DFunction_HistogramInt8BinEdges, uint16_t, float >, TFCS1DFunctionTemplateHistogram< TFCS1DFunction_HistogramInt8BinEdges, uint32_t, float >, TFCS1DFunctionTemplateHistogram< TFCS1DFunction_HistogramInt8BinEdges, uint8_t, float >, TFCS1DFunctionTemplateHistogram< Txvec, Ty, float >, TFCS2DFunctionTemplateHistogram< Txvec, Tyvec, Tz, Trandom >, TFCS2DFunctionTemplateHistogram< TFCS1DFunction_HistogramInt16BinEdges, TFCS1DFunction_HistogramInt16BinEdges, uint16_t, float >, TFCS2DFunctionTemplateHistogram< TFCS1DFunction_HistogramInt16BinEdges, TFCS1DFunction_HistogramInt16BinEdges, uint32_t, float >, TFCS2DFunctionTemplateHistogram< TFCS1DFunction_HistogramInt16BinEdges, TFCS1DFunction_HistogramInt16BinEdges, uint8_t, float >, TFCS2DFunctionTemplateHistogram< TFCS1DFunction_HistogramInt16BinEdges, TFCS1DFunction_HistogramInt32BinEdges, uint16_t, float >, TFCS2DFunctionTemplateHistogram< TFCS1DFunction_HistogramInt16BinEdges, TFCS1DFunction_HistogramInt32BinEdges, uint32_t, float >, TFCS2DFunctionTemplateHistogram< TFCS1DFunction_HistogramInt16BinEdges, TFCS1DFunction_HistogramInt32BinEdges, uint8_t, float >, TFCS2DFunctionTemplateHistogram< TFCS1DFunction_HistogramInt16BinEdges, TFCS1DFunction_HistogramInt8BinEdges, uint16_t, float >, TFCS2DFunctionTemplateHistogram< TFCS1DFunction_HistogramInt16BinEdges, TFCS1DFunction_HistogramInt8BinEdges, uint32_t, float >, TFCS2DFunctionTemplateHistogram< TFCS1DFunction_HistogramInt16BinEdges, TFCS1DFunction_HistogramInt8BinEdges, uint8_t, float >, TFCS2DFunctionTemplateHistogram< TFCS1DFunction_HistogramInt32BinEdges, TFCS1DFunction_HistogramInt16BinEdges, uint16_t, float >, TFCS2DFunctionTemplateHistogram< TFCS1DFunction_HistogramInt32BinEdges, TFCS1DFunction_HistogramInt16BinEdges, uint32_t, float >, TFCS2DFunctionTemplateHistogram< TFCS1DFunction_HistogramInt32BinEdges, TFCS1DFunction_HistogramInt16BinEdges, uint8_t, float >, TFCS2DFunctionTemplateHistogram< TFCS1DFunction_HistogramInt32BinEdges, TFCS1DFunction_HistogramInt32BinEdges, uint16_t, float >, TFCS2DFunctionTemplateHistogram< TFCS1DFunction_HistogramInt32BinEdges, TFCS1DFunction_HistogramInt32BinEdges, uint32_t, float >, TFCS2DFunctionTemplateHistogram< TFCS1DFunction_HistogramInt32BinEdges, TFCS1DFunction_HistogramInt32BinEdges, uint8_t, float >, TFCS2DFunctionTemplateHistogram< TFCS1DFunction_HistogramInt32BinEdges, TFCS1DFunction_HistogramInt8BinEdges, uint16_t, float >, TFCS2DFunctionTemplateHistogram< TFCS1DFunction_HistogramInt32BinEdges, TFCS1DFunction_HistogramInt8BinEdges, uint32_t, float >, TFCS2DFunctionTemplateHistogram< TFCS1DFunction_HistogramInt32BinEdges, TFCS1DFunction_HistogramInt8BinEdges, uint8_t, float >, TFCS2DFunctionTemplateHistogram< TFCS1DFunction_HistogramInt8BinEdges, TFCS1DFunction_HistogramInt16BinEdges, uint16_t, float >, TFCS2DFunctionTemplateHistogram< TFCS1DFunction_HistogramInt8BinEdges, TFCS1DFunction_HistogramInt16BinEdges, uint32_t, float >, TFCS2DFunctionTemplateHistogram< TFCS1DFunction_HistogramInt8BinEdges, TFCS1DFunction_HistogramInt16BinEdges, uint8_t, float >, TFCS2DFunctionTemplateHistogram< TFCS1DFunction_HistogramInt8BinEdges, TFCS1DFunction_HistogramInt32BinEdges, uint16_t, float >, TFCS2DFunctionTemplateHistogram< TFCS1DFunction_HistogramInt8BinEdges, TFCS1DFunction_HistogramInt32BinEdges, uint32_t, float >, TFCS2DFunctionTemplateHistogram< TFCS1DFunction_HistogramInt8BinEdges, TFCS1DFunction_HistogramInt32BinEdges, uint8_t, float >, TFCS2DFunctionTemplateHistogram< TFCS1DFunction_HistogramInt8BinEdges, TFCS1DFunction_HistogramInt8BinEdges, uint16_t, float >, TFCS2DFunctionTemplateHistogram< TFCS1DFunction_HistogramInt8BinEdges, TFCS1DFunction_HistogramInt8BinEdges, uint32_t, float >, TFCS2DFunctionTemplateHistogram< TFCS1DFunction_HistogramInt8BinEdges, TFCS1DFunction_HistogramInt8BinEdges, uint8_t, float >, and TFCS2DFunctionTemplateHistogram< Txvec, Tyvec, Tz, float >.

Definition at line 19 of file TFCSFunction.h.

19{ return sizeof(*this); };

◆ 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)

◆ optimize()

double TFCS1DFunctionSpline::optimize ( TSpline3 & sp_best,
std::vector< double > & nprop,
const TH1 * hist,
TFCS1DFunctionInt32Histogram & hist_fct,
double maxdevgoal = 0.01,
double maxeffsiggoal = 3 )
staticprotected

Definition at line 237 of file TFCS1DFunctionSpline.cxx.

241 {
242 int nsplinepoints = (int)nprop.size();
243 // double xmin=hist->GetXaxis()->GetXmin();
244 // double xmax=hist->GetXaxis()->GetXmax();
245 std::vector<double> nx(nsplinepoints);
246 std::vector<double> nprop_try = nprop;
247 double max_penalty = -1;
248 double p_gotobest = 0.5 / nsplinepoints;
249 int ntry = 200 / p_gotobest;
250 // int itrytot=0;
251 for (double dproploop = 0.4 / nsplinepoints; dproploop > 0.02 / nsplinepoints;
252 dproploop /= 2) {
253 double dprop = dproploop;
254 int n_nogain = 0;
255 for (int itry = 0; itry < ntry; ++itry) {
256 // itrytot++;
257 for (int i = 0; i < nsplinepoints; ++i) {
258 nx[i] = hist_fct.rnd_to_fct(nprop_try[i]);
259 }
260 TSpline3 sp("1Dspline", nprop_try.data(), nx.data(), nsplinepoints,
261 "b2e2", 0, 0);
262 double maxeffsig;
263 double p_maxdev;
264 double p_maxeffsig;
265 double maxdev = get_maxdev(hist, sp, maxeffsig, p_maxdev, p_maxeffsig);
266 double penalty = maxdev / maxdevgoal + maxeffsig / maxeffsiggoal;
267 if (max_penalty < 0 || penalty < max_penalty) {
268 max_penalty = penalty;
269 nprop = nprop_try;
270 sp_best = sp;
271 /*
272 ATH_MSG(INFO) <<"#="<<nsplinepoints<<" try="<<itrytot-1<<" | ";
273 for(int i=0;i<nsplinepoints;++i) {
274 ATH_MSG(INFO) <<i<<":p="<<nprop_try[i]<<" x="<<nx[i]<<" ; ";
275 }
276 ATH_MSG(INFO) <<"new maxdev="<<maxdev<<" maxeffsig="<<maxeffsig<<"
277 max_penalty="<<max_penalty<<END_MSG(INFO);
278 */
279 n_nogain = 0;
280 } else {
281 if (gRandom->Rndm() < p_gotobest)
282 nprop_try = nprop;
283 ++n_nogain;
284 // allow ~20 times retrying from the best found spline before aborting
285 if (n_nogain > 20 / p_gotobest)
286 break;
287 }
288 int ip = 1 + gRandom->Rndm() * (nsplinepoints - 1);
289 if (ip > nsplinepoints - 1)
290 ip = nsplinepoints - 1;
291 double d = dprop;
292 if (gRandom->Rndm() > 0.5)
293 d = -dprop;
294 double nprop_new = nprop_try[ip] + d;
295 if (ip > 0)
296 if (nprop_try[ip - 1] + dprop / 2 > nprop_new) {
297 nprop_new = nprop_try[ip];
298 dprop /= 2;
299 }
300 if (ip < nsplinepoints - 1)
301 if (nprop_new > nprop_try[ip + 1] - dprop / 2) {
302 nprop_new = nprop_try[ip];
303 dprop /= 2;
304 }
305 if (nprop_new < 0) {
306 nprop_new = 0;
307 dprop /= 2;
308 }
309 if (nprop_new > 1) {
310 nprop_new = 1;
311 dprop /= 2;
312 }
313 nprop_try[ip] = nprop_new;
314 }
315 nprop_try = nprop;
316 }
317 return max_penalty;
318}
virtual double rnd_to_fct(double rnd) const
Function gets random number rnd in the range [0,1) as argument and returns function value according t...

◆ rnd_to_fct() [1/2]

double TFCS1DFunctionSpline::rnd_to_fct ( double rnd) const
virtual

Function gets random number rnd in the range [0,1) as argument and returns function value according to a histogram distribution.

Implements TFCS1DFunction.

Definition at line 374 of file TFCS1DFunctionSpline.cxx.

374 {
375 return m_spline.Eval(rnd);
376}
static TRandom * rnd

◆ rnd_to_fct() [2/2]

void TFCS1DFunction::rnd_to_fct ( float value[],
const float rnd[] ) const
virtual

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 TFCS1DFunction.

Definition at line 27 of file TFCS1DFunction.cxx.

18 {
19 value[0] = rnd_to_fct(rnd[0]);
20}
virtual double rnd_to_fct(double rnd) const
Function gets random number rnd in the range [0,1) as argument and returns function value according t...

◆ 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}

◆ spline() [1/2]

TSpline3 & TFCS1DFunctionSpline::spline ( )
inline

Definition at line 52 of file TFCS1DFunctionSpline.h.

52{ return m_spline; };

◆ spline() [2/2]

const TSpline3 & TFCS1DFunctionSpline::spline ( ) const
inline

Definition at line 51 of file TFCS1DFunctionSpline.h.

51{ return m_spline; };

◆ 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_nm

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

Message source name.

Definition at line 211 of file MLogging.h.

◆ m_spline

TSpline3 TFCS1DFunctionSpline::m_spline
protected

Definition at line 62 of file TFCS1DFunctionSpline.h.


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