Project
Loading...
Searching...
No Matches
BoostHistogramUtils.h
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
14
15#ifndef ALICEO2_UTILS_BOOSTHISTOGRAMUTILS
16#define ALICEO2_UTILS_BOOSTHISTOGRAMUTILS
17
18#include <cmath>
19#include <numeric>
20#include <algorithm>
21#include <vector>
22#include <array>
23#include <TH1.h>
24#include <TH2.h>
25#include <TFile.h>
26
27#include "Framework/Logger.h"
28#include "Rtypes.h"
29#include "TLinearFitter.h"
30#include "TVectorD.h"
31#include "TF1.h"
32#include "Foption.h"
33#include "HFitInterface.h"
34#include "TFitResultPtr.h"
35#include "TFitResult.h"
36#include "Fit/Fitter.h"
37#include "Fit/BinData.h"
38#include "Math/WrappedMultiTF1.h"
40#include <boost/histogram.hpp>
41#include <boost/histogram/histogram.hpp>
42#include <boost/format.hpp>
43#include <boost/histogram/axis.hpp>
44#include <boost/histogram/make_histogram.hpp>
45#include <boost/histogram/accumulators/mean.hpp>
46
47using boostHisto2d = boost::histogram::histogram<std::tuple<boost::histogram::axis::regular<double, boost::use_default, boost::use_default, boost::use_default>, boost::histogram::axis::regular<double, boost::use_default, boost::use_default, boost::use_default>>, boost::histogram::unlimited_storage<std::allocator<char>>>;
48using boostHisto1d = boost::histogram::histogram<std::tuple<boost::histogram::axis::regular<double, boost::use_default, boost::use_default, boost::use_default>>>;
49
50using boostHisto2d_VarAxis = boost::histogram::histogram<std::tuple<boost::histogram::axis::variable<double, boost::use_default, boost::use_default, std::allocator<double>>, boost::histogram::axis::variable<double, boost::use_default, boost::use_default, std::allocator<double>>>>;
51using boostHisto1d_VarAxis = boost::histogram::histogram<std::tuple<boost::histogram::axis::variable<double, boost::use_default, boost::use_default, boost::use_default>>>;
52
53namespace o2
54{
55namespace utils
56{
57
60template <typename AxisIterator>
62{
63 public:
64 BinCenterView(AxisIterator iter) : mBaseIterator(iter) {}
65 ~BinCenterView() = default;
66 AxisIterator& operator++()
67 {
68 ++mBaseIterator;
69 return mBaseIterator;
70 }
71 AxisIterator operator++(int)
72 {
73 AxisIterator result(mBaseIterator);
74 mBaseIterator++;
75 return result;
76 }
77 bool operator!=(const BinCenterView& rhs) const
78 {
79 return mBaseIterator != rhs.mBaseIterator;
80 }
81
82 decltype(auto) operator*() { return mBaseIterator->center(); }
83
84 private:
85 AxisIterator mBaseIterator;
86};
87
90template <typename AxisIterator>
92{
93 public:
94 BinUpperView(AxisIterator iter) : mBaseIterator(iter) {}
95 ~BinUpperView() = default;
96 AxisIterator&
98 {
99 ++mBaseIterator;
100 return mBaseIterator;
101 }
102 AxisIterator operator++(int)
103 {
104 AxisIterator result(mBaseIterator);
105 mBaseIterator++;
106 return result;
107 }
108
109 bool operator!=(const BinUpperView& rhs) const
110 {
111 return mBaseIterator != rhs.mBaseIterator;
112 }
113
114 decltype(auto) operator*() { return mBaseIterator->upper(); }
115
116 private:
117 AxisIterator mBaseIterator;
118};
119
122template <typename AxisIterator>
124{
125 public:
126 BinLowerView(AxisIterator iter) : mBaseIterator(iter) {}
127 ~BinLowerView() = default;
128 AxisIterator&
130 {
131 ++mBaseIterator;
132 return mBaseIterator;
133 }
134 AxisIterator operator++(int)
135 {
136 AxisIterator result(mBaseIterator);
137 mBaseIterator++;
138 return result;
139 }
140 bool operator!=(const BinLowerView& rhs) const
141 {
142 return mBaseIterator != rhs.mBaseIterator;
143 }
144
145 decltype(auto) operator*() { return mBaseIterator->lower(); }
146
147 private:
148 AxisIterator mBaseIterator;
149};
150
151template <typename AxisIterator>
153{
155 for (int i = 0; i < n; i++) {
156 ++result;
157 }
158 return result;
159}
160
161template <typename AxisIterator>
163{
165 for (int i = 0; i < n; i++) {
166 ++result;
167 }
168 return result;
169}
170
171template <typename AxisIterator>
173{
175 for (int i = 0; i < n; i++) {
176 ++result;
177 }
178 return result;
179}
180
181template <typename T, int nparams>
183{
184 public:
185 fitResult() = default;
186
187 fitResult(T chi2, const T (&list)[nparams]) : mChi2(chi2),
188 mFitParameters()
189 {
190 memcpy(mFitParameters.data(), list, sizeof(T) * nparams);
191 }
192
194 template <int index>
195 T getParameter() const
196 {
197 static_assert(index <= nparams, "Acessing invalid parameter");
198 return mFitParameters[index];
199 }
200
202 template <int index>
204 {
205 static_assert(index <= nparams, "Attempting to set invalid parameter");
206 mFitParameters[index] = parameter;
207 }
208
210 void setChi2(double chi2In)
211 {
212 mChi2 = chi2In;
213 }
214 T getChi2() const { return mChi2; }
215
216 private:
217 T mChi2;
218 std::array<T, nparams> mFitParameters;
219};
220
234
238
249template <typename T, typename Iterator, typename BinCenterView>
250std::vector<double> fitGaus(Iterator first, Iterator last, BinCenterView axisfirst, const bool ignoreUnderOverflowBin = true)
251{
252
253 if (ignoreUnderOverflowBin) {
254 first++;
255 last--;
256 axisfirst++;
257 }
258
259 TLinearFitter fitter(3, "pol2");
260 TMatrixD mat(3, 3);
261 double kTol = mat.GetTol();
262 fitter.StoreData(kFALSE);
263 fitter.ClearPoints();
264 TVectorD par(3);
265 TMatrixD A(3, 3);
266 TMatrixD b(3, 1);
267
268 // return type of std::max_element is an iterator, cannot cast implicitly to double
269 // pointer needs to be dereferenced afterwards
270 auto yMax = std::max_element(first, last);
271 auto nbins = std::distance(first, last);
272 auto getBinWidth = [](BinCenterView axisiter) {
273 double binCenter1 = *axisiter;
274 axisiter++;
275 double binCenter2 = *axisiter;
276 return std::abs(binCenter1 - binCenter2);
277 };
278 double binWidth = getBinWidth(axisfirst);
279
280 float meanCOG = 0;
281 float rms2COG = 0;
282 float sumCOG = 0;
283
284 float entries = 0;
285 int nfilled = 0;
286
287 for (auto iter = first; iter != last; iter++) {
288 entries += *iter;
289 if (*iter > 0) {
290 nfilled++;
291 }
292 }
293
294 if (*yMax < 4) {
296 }
297 if (entries < 12) {
299 }
300
301 // create the result, first fill it with all 0's
302 std::vector<double> result;
303 for (int r = 0; r < 5; r++) {
304 result.push_back(0);
305 }
306 // then set the third parameter to entries
307 result.at(3) = entries;
308
309 int npoints = 0;
310 // in this loop: increase iter and axisiter (iterator for bin center and bincontent)
311 auto axisiter = axisfirst;
312 for (auto iter = first; iter != last; iter++, axisiter++) {
313 if (nbins > 1) {
314 // dont take bins with 0 entries or bins with nan into account
315 // if y-value (*iter) is 1, log(*iter) will be 0. Exclude these cases
316 if (std::isnan(*axisiter) || std::isinf(*axisiter) || *iter <= 0 || *iter == 1) {
317 continue;
318 }
319 double x = *axisiter;
320 // take logarithm of gaussian in order to obtain a pol2
321 double y = std::log(*iter);
322 // first order taylor series of log(x) to approimate the errors df(x)/dx * err(f(x))
323 double ey = std::sqrt(fabs(*iter)) / fabs(*iter);
324
325 fitter.AddPoint(&x, y, ey);
326 if (npoints < 3) {
327 A(npoints, 0) = 1;
328 A(npoints, 1) = x;
329 A(npoints, 2) = x * x;
330 b(npoints, 0) = y;
331 meanCOG += x * nbins;
332 rms2COG += x * x * nbins;
333 sumCOG += nbins;
334 }
335 npoints++;
336 }
337 }
338 double chi2 = 0;
339 if (npoints >= 3) {
340 if (npoints == 3) {
341 // analytic calculation of the parameters for three points
342 A.Invert();
343 TMatrixD res(1, 3);
344 res.Mult(A, b);
345 par[0] = res(0, 0);
346 par[1] = res(0, 1);
347 par[2] = res(0, 2);
348 chi2 = -3.;
349 } else {
350 // use fitter for more than three points
351 fitter.Eval();
352 fitter.GetParameters(par);
353 fitter.GetCovarianceMatrix(mat);
354 result.at(4) = (fitter.GetChisquare() / double(npoints));
355 }
356
357 if (std::abs(par[1]) < kTol) {
359 }
360 if (std::abs(par[2]) < kTol) {
362 }
363
364 // calculate parameters for gaus from pol2 fit
365 T param1 = T(par[1] / (-2. * par[2]));
366 result.at(1) = param1;
367 result.at(2) = T(1. / std::sqrt(std::abs(-2. * par[2])));
368 auto lnparam0 = par[0] - par[1] * par[1] / (4 * par[2]);
369 if (lnparam0 > 307) {
371 }
372
373 result.at(0) = T(std::exp(lnparam0));
374 return result;
375
376 } else if (npoints == 2) {
377 // use center of gravity for 2 points
378 meanCOG /= sumCOG;
379 rms2COG /= sumCOG;
380
381 result.at(0) = *yMax;
382 result.at(1) = meanCOG;
383 result.at(2) = std::sqrt(std::abs(meanCOG * meanCOG - rms2COG));
384 result.at(4) = -2;
385 } else if (npoints == 1) {
386 meanCOG /= sumCOG;
387
388 result.at(0) = *yMax;
389 result.at(1) = meanCOG;
390 result.at(2) = binWidth / std::sqrt(12);
391 result.at(4) = -1;
392 }
393
394 return result;
395}
396
397template <typename valuetype, typename... axes>
398std::vector<double> fitBoostHistoWithGaus(boost::histogram::histogram<axes...>& hist)
399{
400 return fitGaus<valuetype>(hist.begin(), hist.end(), BinCenterView(hist.axis(0).begin()));
401}
402
404template <typename Hist>
405Hist boosthistoFromRoot_1D(TH1D* inHist1D)
406{
407 // first setup the proper boost histogram
408 int nBins = inHist1D->GetNbinsX();
409 std::vector<double> binEdges;
410 for (int i = 0; i < nBins + 1; i++) {
411 binEdges.push_back(inHist1D->GetBinLowEdge(i + 1));
412 }
413 Hist mHisto;
414
415 if constexpr (std::is_same<Hist, boostHisto1d_VarAxis>::value) {
416 mHisto = boost::histogram::make_histogram(boost::histogram::axis::variable<>(binEdges));
417 } else {
418 mHisto = boost::histogram::make_histogram(boost::histogram::axis::regular<>(nBins, binEdges[0], binEdges.back()));
419 }
420
421 // trasfer the acutal values
422 for (Int_t x = 1; x < nBins + 1; x++) {
423 mHisto.at(x - 1) = inHist1D->GetBinContent(x);
424 }
425 return mHisto;
426}
427
429template <typename Hist>
430Hist boostHistoFromRoot_2D(TH2D* inHist2D)
431{
432 // Get Xaxis binning
433 const int nBinsX = inHist2D->GetNbinsX();
434 std::vector<double> binEdgesX;
435 for (int i = 0; i < nBinsX + 1; i++) {
436 binEdgesX.push_back(inHist2D->GetXaxis()->GetBinLowEdge(i + 1));
437 }
438 // Get Yaxis binning
439 const int nBinsY = inHist2D->GetNbinsY();
440 std::vector<double> binEdgesY;
441 for (int i = 0; i < nBinsY + 1; i++) {
442 binEdgesY.push_back(inHist2D->GetYaxis()->GetBinLowEdge(i + 1));
443 }
444
445 Hist mHisto;
446
447 if constexpr (std::is_same<Hist, boostHisto2d_VarAxis>::value) {
448 mHisto = boost::histogram::make_histogram(boost::histogram::axis::variable<>(binEdgesX), boost::histogram::axis::variable<>(binEdgesY));
449 } else {
450 mHisto = boost::histogram::make_histogram(boost::histogram::axis::regular<>(nBinsX, binEdgesX[0], binEdgesX.back()), boost::histogram::axis::regular<>(nBinsY, binEdgesY[0], binEdgesY.back()));
451 }
452
453 // trasfer the acutal values
454 for (Int_t x = 1; x < nBinsX + 1; x++) {
455 for (Int_t y = 1; y < nBinsY + 1; y++) {
456 mHisto.at(x - 1, y - 1) = inHist2D->GetBinContent(x, y);
457 }
458 }
459 return mHisto;
460}
461
467template <typename... axes>
468double getMeanBoost1D(boost::histogram::histogram<axes...>& inHist1D, const double rangeLow = 0, const double rangeHigh = 0)
469{
470 // LOG(info) << "Entering the mean function for hist with rank " << inHist1D.rank() << " with " << inHist1D.axis(0).size() << " bins";
472 bool restrictRange = rangeLow < rangeHigh ? true : false;
473 auto histiter = inHist1D.begin() + 1;
474 const auto& axis = inHist1D.axis(0);
475 for (auto bincenter = BinCenterView(axis.begin()); bincenter != BinCenterView(axis.end()); ++bincenter, ++histiter) {
476 // std::cout << "bin center bin " << mynbins << ": " << *bincenter << " <-> value: " << *histiter << std::endl;
477 if (restrictRange) {
478 if (*bincenter < rangeLow || *bincenter > rangeHigh) {
479 continue;
480 }
481 }
482 stats.add(*bincenter, *histiter);
483 }
484 return stats.getMean();
485}
486
494template <typename... axes>
495double getVarianceBoost1D(boost::histogram::histogram<axes...>& inHist1D, double mean = -999999, const double rangeLow = 0, const double rangeHigh = 0, const double weight = 1)
496{
497 if (std::abs(mean + 999999) < 0.00001) {
498 mean = getMeanBoost1D(inHist1D, rangeLow, rangeHigh);
499 }
500 bool restrictRange = rangeLow < rangeHigh ? true : false;
501 unsigned int nMeas = 0; // counter for the number of data points
502 auto histiter = inHist1D.begin() + 1;
503 const auto& axis = inHist1D.axis(0);
504 double variance = 0;
505 for (auto bincenter = BinCenterView(axis.begin()); bincenter != BinCenterView(axis.end()); ++bincenter, ++histiter) {
506 if (restrictRange) {
507 LOG(debug) << " *bincenter " << *bincenter << " rangeLow " << rangeLow << " rangeHigh " << rangeHigh;
508 if (*bincenter < rangeLow || *bincenter > rangeHigh) {
509 continue;
510 }
511 }
512 nMeas += *histiter / weight; // to get the number of entries, for weighted histograms we need to divide by the weight to get back to the number of entries
513 variance += *histiter * (*bincenter - mean) * (*bincenter - mean);
514 }
515 if (nMeas <= 1) {
516 return 0;
517 }
518 variance /= (nMeas - 1);
519 return variance;
520}
521
523template <class BoostHist>
524TH1F TH1FFromBoost(BoostHist hist, const char* name = "hist")
525{
526 const int nbinsx = hist.axis(0).size();
527 const double binxlow = hist.axis(0).bin(0).lower();
528 const double binxhigh = hist.axis(0).bin(nbinsx - 1).upper();
529
530 TH1F hRoot(name, name, nbinsx, binxlow, binxhigh);
531 // trasfer the acutal values
532 for (int x = 0; x < nbinsx; x++) {
533 hRoot.SetBinContent(x + 1, hist.at(x));
534 }
535 return hRoot;
536}
537
539// template <typename valuetype, typename... axes>
540template <class BoostHist>
541TH2F TH2FFromBoost(BoostHist hist, const char* name = "hist")
542{
543 const int nbinsx = hist.axis(0).size();
544 const int nbinsy = hist.axis(1).size();
545 const double binxlow = hist.axis(0).bin(0).lower();
546 const double binxhigh = hist.axis(0).bin(nbinsx - 1).upper();
547 const double binylow = hist.axis(1).bin(0).lower();
548 const double binyhigh = hist.axis(1).bin(nbinsy - 1).upper();
549
550 TH2F hRoot(name, name, nbinsx, binxlow, binxhigh, nbinsy, binylow, binyhigh);
551 // trasfer the acutal values
552 for (int x = 0; x < nbinsx; x++) {
553 for (int y = 0; y < nbinsy; y++) {
554 hRoot.SetBinContent(x + 1, y + 1, hist.at(x, y));
555 }
556 }
557 return hRoot;
558}
559
566template <typename... axes>
567auto ProjectBoostHistoX(const boost::histogram::histogram<axes...>& hist2d, const int binLow, const int binHigh)
568{
569 using namespace boost::histogram::literals; // enables _c suffix needed for projection
570
571 unsigned int nbins = hist2d.axis(0).size();
572 // make reduced histo in range that we want to project
573 auto reducedHisto2d = boost::histogram::algorithm::reduce(hist2d, boost::histogram::algorithm::shrink(hist2d.axis(0).bin(0).lower(), hist2d.axis(0).bin(nbins - 1).upper()), boost::histogram::algorithm::shrink(binLow, binHigh));
574
575 // set under and overflow bin to 0 such that they will not be used in the projection
576 for (int i = 0; i < reducedHisto2d.axis(0).size(); ++i) {
577 reducedHisto2d.at(i, -1) = 0;
578 reducedHisto2d.at(i, reducedHisto2d.axis(1).size()) = 0;
579 }
580 // make the projection onto the x-axis (0_c) of the reduced histogram
581 auto histoProj = boost::histogram::algorithm::project(reducedHisto2d, 0_c);
582
583 return histoProj;
584}
585
592template <typename... axes>
593auto ProjectBoostHistoXFast(const boost::histogram::histogram<axes...>& hist2d, const int binLow, const int binHigh)
594{
595 unsigned int nbins = hist2d.axis(0).size();
596 double binStartX = hist2d.axis(0).bin(0).lower();
597 double binEndX = hist2d.axis(0).bin(nbins - 1).upper();
598 auto histoProj = boost::histogram::make_histogram(boost::histogram::axis::regular<>(nbins, binStartX, binEndX));
599
600 // Now rewrite the bin content of the 1d histogram to get the summed bin content in the specified range
601 for (int x = 0; x < nbins; ++x) {
602 histoProj.at(x) = 0;
603 for (int y = binLow; y < binHigh; ++y) {
604 histoProj.at(x) = histoProj.at(x) + hist2d.at(x, y);
605 }
606 }
607
608 return histoProj;
609}
610
620template <typename... axes>
621auto ReduceBoostHistoFastSlice(const boost::histogram::histogram<axes...>& hist2d, int binXLow, int binXHigh, int binYLow, int binYHigh, bool includeOverflowUnderflow)
622{
623 int nXbins = binXHigh - binXLow + 1;
624 int nYbins = binYHigh - binYLow + 1;
625 double valueStartX = hist2d.axis(0).bin(binXLow).lower();
626 double valueEndX = hist2d.axis(0).bin(binXHigh).upper();
627 double valueStartY = hist2d.axis(1).bin(binYLow).lower();
628 double valueEndY = hist2d.axis(1).bin(binYHigh).upper();
629
630 auto histoReduced = boost::histogram::make_histogram(boost::histogram::axis::regular<>(nXbins, valueStartX, valueEndX), boost::histogram::axis::regular<>(nYbins, valueStartY, valueEndY));
631
632 int nbinsxOld = hist2d.axis(0).size();
633 int nbinsyOld = hist2d.axis(1).size();
634 // Now rewrite the bin content of the 1d histogram to get the summed bin content in the specified range
635 for (int x = -1; x < nbinsxOld + 1; ++x) {
636 for (int y = -1; y < nbinsyOld + 1; ++y) {
637 int nXbinsNew = x - binXLow;
638 int nYbinsNew = y - binYLow;
639 if (nXbinsNew < 0 || nYbinsNew < 0 || nXbinsNew >= nXbins || nYbinsNew >= nYbins) {
640 if (!includeOverflowUnderflow) {
641 continue;
642 } else {
643 // handle the over and underflow
644 nXbinsNew = int(std::min(int(std::max(nXbinsNew, -1)), nXbins));
645 nYbinsNew = int(std::min(int(std::max(nYbinsNew, -1)), nYbins));
646 histoReduced.at(nXbinsNew, nYbinsNew) += hist2d.at(x, y);
647 }
648 } else {
649 histoReduced.at(nXbinsNew, nYbinsNew) = hist2d.at(x, y);
650 }
651 }
652 }
653
654 return histoReduced;
655}
656
657// \brief Function to project 2d boost histogram onto x-axis
664template <typename... axes>
665auto ReduceBoostHistoFastSlice1D(boost::histogram::histogram<axes...>& hist1d, int binXLow, int binXHigh, bool includeOverflowUnderflow)
666{
667 // LOG(info) << "Settting the binning with binXLost = " << binXLow << " and binXHigh = " << binXHigh;
668 int nXbins = binXHigh - binXLow + 1;
669 double valueStartX = hist1d.axis(0).bin(binXLow).lower();
670 double valueEndX = hist1d.axis(0).bin(binXHigh).upper();
671 // LOG(info) << "Binning is set, now making the histogram with " << nXbins << " bins in X with lower bound " << valueStartX << " and upper bound " << valueEndX;
672
673 auto histoReduced = boost::histogram::make_histogram(boost::histogram::axis::regular<>(nXbins, valueStartX, valueEndX));
674 // LOG(info) << "made the histogram";
675
676 int nbinsxOld = hist1d.axis(0).size();
677 // Now rewrite the bin content of the 1d histogram to get the summed bin content in the specified range
678 for (int x = -1; x < nbinsxOld + 1; ++x) {
679 int nXbinsNew = x - binXLow;
680 if (nXbinsNew < 0 || nXbinsNew >= nXbins) {
681 if (!includeOverflowUnderflow) {
682 continue;
683 } else {
684 // handle the over and underflow
685 nXbinsNew = int(std::min(int(std::max(nXbinsNew, -1)), nXbins));
686 histoReduced.at(nXbinsNew) += hist1d.at(x);
687 }
688 } else {
689 histoReduced.at(nXbinsNew) = hist1d.at(x);
690 }
691 }
692
693 return histoReduced;
694}
695
705template <typename... axes>
706auto ReduceBoostHistoFastSliceByValue(boost::histogram::histogram<axes...>& hist2d, double xLow, double xHigh, double yLow, double yHigh, bool includeOverflowUnderflow)
707{
708
709 int binXLow = hist2d.axis(0).index(xLow);
710 int binXHigh = hist2d.axis(0).index(xHigh);
711 int binYLow = hist2d.axis(1).index(yLow);
712 int binYHigh = hist2d.axis(1).index(yHigh);
713
714 return ReduceBoostHistoFastSlice(hist2d, binXLow, binXHigh, binYLow, binYHigh, includeOverflowUnderflow);
715}
716
722template <typename... axes>
723double getIntegralBoostHist(boost::histogram::histogram<axes...>& hist, double min, double max)
724{
725 // find bins for min and max values
726 std::array<int, 2> axisLimitsIndex = {hist.axis(0).index(min), hist.axis(0).index(max)};
727 // over/underflow bin have to be protected
728 for (auto& bin : axisLimitsIndex) {
729 if (bin < 0) {
730 bin = 0;
731 } else if (bin >= hist.axis(0).size()) {
732 bin = hist.axis(0).size() - 1;
733 }
734 }
735 // Reduce histogram to desired range
736 auto slicedHist = ReduceBoostHistoFastSlice1D(hist, axisLimitsIndex[0], axisLimitsIndex[1], false);
737 return boost::histogram::algorithm::sum(slicedHist);
738}
739
740} // namespace utils
741} // end namespace o2
742
743#endif
boost::histogram::histogram< std::tuple< boost::histogram::axis::variable< double, boost::use_default, boost::use_default, std::allocator< double > >, boost::histogram::axis::variable< double, boost::use_default, boost::use_default, std::allocator< double > > > > boostHisto2d_VarAxis
boost::histogram::histogram< std::tuple< boost::histogram::axis::regular< double, boost::use_default, boost::use_default, boost::use_default > > > boostHisto1d
boost::histogram::histogram< std::tuple< boost::histogram::axis::regular< double, boost::use_default, boost::use_default, boost::use_default >, boost::histogram::axis::regular< double, boost::use_default, boost::use_default, boost::use_default > >, boost::histogram::unlimited_storage< std::allocator< char > > > boostHisto2d
boost::histogram::histogram< std::tuple< boost::histogram::axis::variable< double, boost::use_default, boost::use_default, boost::use_default > > > boostHisto1d_VarAxis
std::ostringstream debug
std::vector< long > entries
int32_t i
configStandalone Reconstruction rec_tpc multiplier for the combined cluster track error during track following area in cm for the search of for z only used if decrease removal by when above this local occupancy rowx Shift of TPC revert cluster flag edge bit distance to edge exceeds this ZOffset for secondary multiple of radius max P of electron K BB bands crossing max P of electron p BB bands crossing max P of electron d BB bands crossing max P of electron t BB bands crossing min accepted dEdxMaxTPC of the track Additive extra cluster error for Y2 if edge flag set Additive extra cluster error for Y2 if single set Additive extra cluster error for Y2 if or single set Additive extra cluster error for Z2 if or single set Extra errors to add to track when crossing depending on addErrorsCECrossing Inner portion of y range in sector that is not used in searching for extrapolated track candidates factor2YS for track merging factor2K for track merging Margin in cm of Y position when rejecting edge clusters based on uncorrected track Y Max fraction of shared clusters for tracklet Except pad from cluster finding if total number of charges in a fragment is above this Except pad from cluster finding if number of consecutive charges in a fragment is above this Threshold where a timebin is considered disabling the noisy pad check for that pad Treat signal above this minimum as saturated Smoothing factor for the exponential Highly Ionising Particle tail filter Number of timebins to use for the averaging Add additional custom track errors when crossing relative as fraction of Do N fit passes in final fit of< 0:reject at max -n hits") AddOptionRTC(rejectIFCLowRadiusCluster, uint8_t, 1, "", 0, "Reject clusters that get the IFC mask error during refit") AddOptionRTC(dEdxTruncLow, uint8_t, 2, "", 0, "Low truncation threshold, fraction of 128") AddOptionRTC(dEdxTruncHigh, uint8_t, 77, "", 0, "High truncation threshold, fraction of 128") AddOptionRTC(extrapolationTracking, int8_t, 1, "", 0, "Enable Extrapolation Tracking(prolong tracks to adjacent sectors to find short segments)") AddOptionRTC(disableRefitAttachment, uint8_t, 0, "", 0, "Bitmask to disable certain attachment steps during refit(1:attachment, 2:propagation, 4:loop following, 8:mirroring)") AddOptionRTC(rejectionStrategy, uint8_t, o2::gpu::GPUSettings::RejectionStrategyA, "", 0, "Enable rejection of TPC clusters for compression(0=no, 1=strategy A, 2=strategy B)") AddOptionRTC(mergeLoopersAfterburner, uint8_t, 1, "", 0, "Run afterburner for additional looper merging") AddOptionRTC(compressionTypeMask, uint8_t, o2::gpu::GPUSettings::CompressionFull, "", 0, "TPC Compression mode bits(1=truncate charge/width LSB, 2=differences, 4=track-model)") AddOptionRTC(compressionSortOrder, uint8_t, o2::gpu::GPUSettings::SortTime, "", 0, "Sort order of TPC compression(0=time, 1=pad, 2=Z-time-pad, 3=Z-pad-time, 4=no sorting(use incoming order))") AddOptionRTC(sigBitsCharge, uint8_t, 4, "", 0, "Number of significant bits for TPC cluster charge in compression mode 1") AddOptionRTC(sigBitsWidth, uint8_t, 3, "", 0, "Number of significant bits for TPC cluster width in compression mode 1") AddOptionRTC(dropLoopers, uint8_t, 0, "", 0, "Drop looping tracks starting from second loop") AddOptionRTC(mergerInterpolateErrors, uint8_t, 1, "", 0, "Use interpolation instead of extrapolation for chi2 based cluster rejection") AddOptionRTC(mergerInterpolateRejectAlsoOnCurrentPosition, uint8_t, 1, "", 0, "When using mergerInterpolateErrors, reject based on chi2 twice computed with interpolated and current track position starting from NDF > mergerNonInterpolateRejectMinNDF Merge tracks accross the central electrode Enable PID response Add sub threshold clusters in TPC dEdx computation OR mask of TPC flags that will reject the cluster in alternative dEdx Reject edge clusters based on uncorrected track Y during track fit Increase decrease removal by when on this number of pads from the edge h configStandalone Reconstruction rec_trd Max chi2 for TRD tracklets to be matched to a track Chi2 cut for strict matching mode Number of sigmas for ITS TPC track time error estimate Addition to search road around track prolongation along Y in cm Optimal tracklet rphi resolution in maximum chi2 per attached tracklet for TRD tracks take into account the full likelihood of the slope including exponential tails Tracks with less attached tracklets are discarded after the tracking Post trigger Pile up integration time in BCs fits all iterations but the last one in projections Use material lookup table for TPC refit Apply workarounds to avoid cyclic merge should not be needed tpc dyn configStandalone Processing proc_rtc true
configStandalone Reconstruction rec_tpc multiplier for the combined cluster track error during track following area in cm for the search of for z only used if decrease removal by when above this local occupancy rowx Shift of TPC revert cluster flag edge bit distance to edge exceeds this parameter(fixed during CTF decoding)") AddOptionRTC(defaultZOffsetOverR
float & yMax
float chi2
uint32_t res
Definition RawData.h:0
Definition A.h:16
Axis iterator over bin centers.
bool operator!=(const BinCenterView &rhs) const
BinCenterView(AxisIterator iter)
Axis iterator over bin lower edges.
bool operator!=(const BinLowerView &rhs) const
BinLowerView(AxisIterator iter)
Axis iterator over bin upper edges.
bool operator!=(const BinUpperView &rhs) const
BinUpperView(AxisIterator iter)
void setParameter(T parameter)
Set the paratmeters of a fit result. Ex: result.setParameter<1>(T(value)));.
void setChi2(double chi2In)
Set the chi2 of the fit result.
T getParameter() const
Get the paratmeters of a fit result. Ex: result.getParameter<1>();.
fitResult(T chi2, const T(&list)[nparams])
GLdouble n
Definition glcorearb.h:1982
GLint GLenum GLint x
Definition glcorearb.h:403
GLuint64EXT * result
Definition glcorearb.h:5662
GLsizeiptr size
Definition glcorearb.h:659
GLuint index
Definition glcorearb.h:781
GLuint const GLchar * name
Definition glcorearb.h:781
GLint first
Definition glcorearb.h:399
GLuint GLuint GLfloat weight
Definition glcorearb.h:5477
GLboolean GLboolean GLboolean b
Definition glcorearb.h:1233
GLint y
Definition glcorearb.h:270
TH2F TH2FFromBoost(BoostHist hist, const char *name="hist")
Convert a 2D boost histogram to a root histogram.
auto ProjectBoostHistoXFast(const boost::histogram::histogram< axes... > &hist2d, const int binLow, const int binHigh)
Function to project 2d boost histogram onto x-axis.
Hist boosthistoFromRoot_1D(TH1D *inHist1D)
Convert a 1D root histogram to a Boost histogram.
FitGausError_t
Error code for invalid result in the fitGaus process.
@ FIT_ERROR_KTOL_MEAN
Gaus fit failed! std::abs(par[1]) < kTol.
@ FIT_ERROR_KTOL_RMS
Gaus fit failed! RMS < kTol.
@ FIT_ERROR_ENTRIES
Gaus fit failed! entries < 12.
@ FIT_ERROR_MIN
Gaus fit failed! yMax < 4.
@ FIT_ERROR_KTOL_SIGMA
Gaus fit failed! std::abs(par[2]) < kTol.
@ FIT_ERROR_MAX
Gaus fit failed! yMax too large.
double getIntegralBoostHist(boost::histogram::histogram< axes... > &hist, double min, double max)
Function to integrate 1d boost histogram in specified range.
TH1F TH1FFromBoost(BoostHist hist, const char *name="hist")
Convert a 2D boost histogram to a root histogram.
std::vector< double > fitBoostHistoWithGaus(boost::histogram::histogram< axes... > &hist)
auto ReduceBoostHistoFastSliceByValue(boost::histogram::histogram< axes... > &hist2d, double xLow, double xHigh, double yLow, double yHigh, bool includeOverflowUnderflow)
Function to project 2d boost histogram onto x-axis.
Hist boostHistoFromRoot_2D(TH2D *inHist2D)
Convert a 2D root histogram to a Boost histogram.
BinCenterView< AxisIterator > operator+(BinCenterView< AxisIterator > lhs, int n)
auto ProjectBoostHistoX(const boost::histogram::histogram< axes... > &hist2d, const int binLow, const int binHigh)
Function to project 2d boost histogram onto x-axis.
auto ReduceBoostHistoFastSlice(const boost::histogram::histogram< axes... > &hist2d, int binXLow, int binXHigh, int binYLow, int binYHigh, bool includeOverflowUnderflow)
Function to project 2d boost histogram onto x-axis.
std::string createErrorMessageFitGaus(o2::utils::FitGausError_t errorcode)
Printing an error message when then fit returns an invalid result.
auto ReduceBoostHistoFastSlice1D(boost::histogram::histogram< axes... > &hist1d, int binXLow, int binXHigh, bool includeOverflowUnderflow)
double getMeanBoost1D(boost::histogram::histogram< axes... > &inHist1D, const double rangeLow=0, const double rangeHigh=0)
Get the mean of a 1D boost histogram.
double getVarianceBoost1D(boost::histogram::histogram< axes... > &inHist1D, double mean=-999999, const double rangeLow=0, const double rangeHigh=0, const double weight=1)
Get the variance of a 1D boost histogram.
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
Common utility functions.
constexpr size_t min
constexpr size_t max
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"