Project
Loading...
Searching...
No Matches
Helpers.cxx
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
12#include <cassert>
13
14// o2 includes
15#include "TPCQC/Helpers.h"
16#include "TPCBase/Mapper.h"
17#include "TPCBase/ROC.h"
18
19using namespace o2::tpc::qc;
20
21//______________________________________________________________________________
22std::vector<double> helpers::makeLogBinning(const int nbins, const double min, const double max)
23{
24 assert(min > 0);
25 assert(min < max);
26
27 std::vector<double> binLim(nbins + 1);
28
29 const double expMax = std::log(max / min);
30 const double binWidth = expMax / nbins;
31
32 binLim[0] = min;
33 binLim[nbins] = max;
34
35 for (Int_t i = 1; i < nbins; ++i) {
36 binLim[i] = min * std::exp(i * binWidth);
37 }
38
39 return binLim;
40}
41
42//______________________________________________________________________________
44{
45 histo.SetStats(1);
46}
47
48//______________________________________________________________________________
49void helpers::setStyleHistogram1D(std::vector<TH1F>& histos)
50{
51 for (auto& hist : histos) {
53 }
54}
55
56//______________________________________________________________________________
58{
59 histo.SetOption("colz");
60 histo.SetStats(0);
61 histo.SetMinimum(0.9);
62}
63
64//______________________________________________________________________________
65void helpers::setStyleHistogram2D(std::vector<TH2F>& histos)
66{
67 for (auto& hist : histos) {
69 }
70}
71
72//______________________________________________________________________________
74{
75 // common and 1D case
76 histo.SetStats(1);
77 // 2D case
78 if (histo.InheritsFrom(TH2::Class())) {
79 histo.SetOption("colz");
80 histo.SetStats(0);
81 histo.SetMinimum(0.9);
82 }
83}
84
85//______________________________________________________________________________
86void helpers::setStyleHistogramsInMap(std::unordered_map<std::string_view, std::vector<std::unique_ptr<TH1>>>& mapOfvectors)
87{
88 for (const auto& keyValue : mapOfvectors) {
89 for (auto& hist : keyValue.second) {
91 }
92 }
93}
94
95//______________________________________________________________________________
96void helpers::setStyleHistogramsInMap(std::unordered_map<std::string_view, std::unique_ptr<TH1>>& mapOfHisto)
97{
98 for (const auto& keyValue : mapOfHisto) {
99 helpers::setStyleHistogram(*(keyValue.second));
100 }
101}
102
103//______________________________________________________________________________
104void helpers::setStyleHistogramsInMap(std::unordered_map<std::string, std::vector<std::unique_ptr<TH1>>>& mapOfvectors)
105{
106 for (const auto& keyValue : mapOfvectors) {
107 for (auto& hist : keyValue.second) {
109 }
110 }
111}
112
113//______________________________________________________________________________
114void helpers::setStyleHistogramsInMap(std::unordered_map<std::string, std::unique_ptr<TH1>>& mapOfHisto)
115{
116 for (const auto& keyValue : mapOfHisto) {
117 helpers::setStyleHistogram(*(keyValue.second));
118 }
119}
120
121//______________________________________________________________________________
122bool helpers::newZSCalib(const o2::tpc::CalDet<float>& refPedestal, const o2::tpc::CalDet<float>& refNoise, const o2::tpc::CalDet<float>& pedestal)
123{
125 o2::tpc::CalDet<float> diffCalDet = refPedestal - pedestal;
126
127 for (o2::tpc::ROC roc; !roc.looped(); ++roc) {
128 const int nrows = mapper.getNumberOfRowsROC(roc);
129 for (int irow = 0; irow < nrows; ++irow) {
130 const int npads = mapper.getNumberOfPadsInRowROC(roc, irow);
131 for (int ipad = 0; ipad < npads; ++ipad) {
132 const auto val = diffCalDet.getValue(roc, irow, ipad);
133 if (std::abs(val) > 3 * refNoise.getValue(roc, irow, ipad)) {
134 return true;
135 }
136 }
137 }
138 }
139
140 return false;
141}
int32_t i
uint32_t roc
Definition RawData.h:3
const T getValue(const int sec, const int globalPadInSector) const
Definition CalDet.h:154
int getNumberOfRowsROC(ROC roc) const
Definition Mapper.h:305
int getNumberOfPadsInRowROC(int roc, int row) const
Definition Mapper.h:342
static Mapper & instance(const std::string mappingDir="")
Definition Mapper.h:44
bool looped() const
if increment operator went above MaxROC
Definition ROC.h:108
GLuint GLfloat * val
Definition glcorearb.h:1582
std::vector< double > makeLogBinning(const int nbins, const double min, const double max)
get a vector containing binning info for constant sized bins on a log axis
Definition Helpers.cxx:22
void setStyleHistogram2D(TH2 &histo)
Set nice style for 2D histograms.
Definition Helpers.cxx:57
void setStyleHistogram(TH1 &histo)
set nice style for 1D histograms ptr
Definition Helpers.cxx:73
void setStyleHistogram1D(TH1 &histo)
Set nice style for single 1D histograms.
Definition Helpers.cxx:43
bool newZSCalib(const o2::tpc::CalDet< float > &refPedestal, const o2::tpc::CalDet< float > &refNoise, const o2::tpc::CalDet< float > &pedestal)
Definition Helpers.cxx:122
void setStyleHistogramsInMap(std::unordered_map< std::string_view, std::vector< std::unique_ptr< TH1 > > > &mapOfvectors)
Definition Helpers.cxx:86
constexpr size_t min
constexpr size_t max