16#include "fmt/format.h"
27 return !mSACOne[
side] ? -1 : mSACOne[
side]->getValue(
side, integrationInterval);
33 std::function<float(
const unsigned int,
const unsigned int)> SACFunc;
35 SACFunc = [
this, integrationInterval](
const unsigned int sector,
const unsigned int stack) {
40 SACFunc = [
this](
const unsigned int sector,
const unsigned int stack) {
45 SACFunc = [
this, integrationInterval](
const unsigned int sector,
const unsigned int stack) {
50 SACFunc = [
this](
const unsigned int sector,
const unsigned int stack) {
53 name =
"SACZero Outliers (Yellow)";
58 c =
new TCanvas(fmt::format(
"c_sides_{}",
name).
data(), fmt::format(
"sides_{}",
name).
data(), 500, 1000);
68 hSideA->SetTitle(fmt::format(
"{} ({}-Side)",
name.data(),
"A").data());
69 hSideC->SetTitle(fmt::format(
"{} ({}-Side)",
name.data(),
"C").data());
72 hSideA->SetMinimum(
minZ);
73 hSideC->SetMinimum(
minZ);
74 hSideA->SetMaximum(
maxZ);
75 hSideC->SetMaximum(
maxZ);
79 Double_t
levels[] = {-3., 0., 3.};
80 hSideA->SetContour(3,
levels);
81 hSideC->SetContour(3,
levels);
86 hSideA->Draw(
"colz PFC");
88 hSideC->Draw(
"colz PFC");
90 hSideA->SetBit(TObject::kCanDelete);
91 hSideC->SetBit(TObject::kCanDelete);
96TCanvas*
SACs::drawSACOneCanvas(
int nbins1D,
float xMin1D,
float xMax1D,
int integrationIntervals, TCanvas* outputCanvas)
const
98 auto* canv = outputCanvas;
101 canv =
new TCanvas(
"c_sides_SAC1_1D",
"SAC1 1D distribution for each side", 1000, 1000);
104 auto hAside1D =
new TH1F(
"h_SAC1_1D_ASide",
"SAC1 distribution over integration intervals A-Side", nbins1D, xMin1D, xMax1D);
105 auto hCside1D =
new TH1F(
"h_SAC1_1D_CSide",
"SAC1 distribution over integration intervals C-Side", nbins1D, xMin1D, xMax1D);
107 hAside1D->GetXaxis()->SetTitle(
"SAC1");
108 hAside1D->SetTitleOffset(1.05,
"XY");
109 hAside1D->SetTitleSize(0.05,
"XY");
110 hCside1D->GetXaxis()->SetTitle(
"SAC1");
111 hCside1D->SetTitleOffset(1.05,
"XY");
112 hCside1D->SetTitleSize(0.05,
"XY");
113 if (integrationIntervals <= 0) {
116 for (
unsigned int integrationInterval = 0; integrationInterval < integrationIntervals; ++integrationInterval) {
127 hAside1D->SetBit(TObject::kCanDelete);
128 hCside1D->SetBit(TObject::kCanDelete);
135 auto* canv = outputCanvas;
137 canv =
new TCanvas(fmt::format(
"c_FourierCoefficients_1D_{}Side", (
side ==
Side::A) ?
"A" :
"C").
data(), fmt::format(
"1D distributions of Fourier Coefficients ({}-Side)", (
side ==
Side::A) ?
"A" :
"C").
data(), 1000, 1000);
140 std::vector<TH1F*> histos;
142 for (
int i = 0;
i < mFourierSAC->
mCoeff[
side].getNCoefficientsPerTF();
i++) {
143 histos.emplace_back(
new TH1F(fmt::format(
"h_FourierCoeff{}_{}Side",
i, (
side ==
Side::A) ?
"A" :
"C").
data(), fmt::format(
"1D distribution of Fourier Coefficient {} ({}-Side)",
i, (
side ==
Side::A) ?
"A" :
"C").
data(), nbins1D, xMin1D, xMax1D));
144 histos.back()->GetXaxis()->SetTitle(fmt::format(
"Fourier Coefficient {}",
i).data());
148 const auto nCoeffPerTF = mFourierSAC->
mCoeff[
side].getNCoefficientsPerTF();
150 for (
int i = 0;
i < mFourierSAC->
mCoeff[
side].getNCoefficients();
i++) {
151 histos.at(
i % nCoeffPerTF)->Fill(
coeffs.at(
i));
154 canv->DivideSquare(mFourierSAC->
mCoeff[
side].getNCoefficientsPerTF());
158 for (
const auto& hist : histos) {
160 hist->SetTitleOffset(1.05,
"XY");
161 hist->SetTitleSize(0.05,
"XY");
163 hist->SetBit(TObject::kCanDelete);
172 TCanvas* canv =
nullptr;
177 canv =
new TCanvas(
"c_sides_SACZero_ScaleFactor",
"SACZero", 1000, 1000);
181 double xsides[] = {0, 1};
182 double yTotSAC0[] = {mScaleSACZeroAside, mScaleSACZeroCside};
183 auto gSACZeroScale =
new TGraph(2, xsides, yTotSAC0);
185 gSACZeroScale->SetName(
"g_SAC0ScaleFactor");
186 gSACZeroScale->SetTitle(Form(
"Scaling Factor (SACZero), Rejection Factor %.2f;Sides;SACZero Total (arb. unit)", mSACZeroMaxDeviation));
187 gSACZeroScale->SetMarkerColor(kBlue);
188 gSACZeroScale->SetMarkerStyle(21);
189 gSACZeroScale->SetMarkerSize(1);
190 gSACZeroScale->GetXaxis()->SetLabelColor(0);
191 gSACZeroScale->GetXaxis()->CenterTitle();
193 gSACZeroScale->Draw(
"ap");
195 TText* t =
new TText();
196 t->SetTextSize(0.035);
197 const char* labels[2] = {
"A-Side",
"C-Side"};
198 for (Int_t iSide = 0; iSide < 2; iSide++) {
199 t->DrawText((
double)iSide + 0.1, yTotSAC0[iSide], labels[iSide]);
201 gSACZeroScale->GetXaxis()->SetLimits(-0.5, 1.5);
204 gSACZeroScale->SetBit(TObject::kCanDelete);
205 t->SetBit(TObject::kCanDelete);
213 for (
unsigned int sector = sectorStart; sector < sectorEnd; ++sector) {
232 mScaleSACZeroAside = 0;
233 mScaleSACZeroCside = 0;
237 if (mScaleSACZeroAside == 0.0 || mScaleSACZeroCside == 0.0) {
238 LOGP(error,
"Please check the SAC0 total A side {} and C side {}, is zero, therefore no scaling applied!", mScaleSACZeroAside, mScaleSACZeroCside);
239 mScaleSACZeroAside = 1.0;
240 mScaleSACZeroCside = 1.0;
248 if (rejectOutliers) {
254 for (
unsigned int sector = sectorStart; sector < sectorEnd; ++sector) {
261 size_t n = SACZeroValues[
stack].size() / 2;
263 if (SACZeroValues[
stack].
size() % 2 != 0) {
266 medianSACZero[
stack] = (SACZeroValues[
stack].at(
n) + SACZeroValues[
stack].at(
n - 1)) / 2.;
272 float meanSACZero = 0;
273 float SACZeroChannelCounter = 0.;
277 for (
unsigned int sector = sectorStart; sector < sectorEnd; ++sector) {
282 if (rejectOutliers) {
283 if (abs((SACZeroVal - medianSACZero[
stack]) / medianSACZero[
stack]) >= mSACZeroMaxDeviation) {
284 mIsSACZeroOutlier[getStack(sector,
stack)] = 1;
288 mIsSACZeroOutlier[getStack(sector,
stack)] = -1;
289 meanSACZero += SACZeroVal;
290 SACZeroChannelCounter += 1.;
293 if (SACZeroChannelCounter > 0.) {
294 meanSACZero /= SACZeroChannelCounter;
helper class for drawing SACs per sector/side
ClassImp(o2::tpc::qc::SACs)
static std::string getZAxisTitle(const SACType type)
static void drawSide(const SACDraw &SAC, const o2::tpc::Side side, const std::string zAxisTitle, const std::string filename, const float minZ=0, const float maxZ=-1)
float getSACDeltaVal(const unsigned int stack, unsigned int interval) const
void setSACZeroVal(float factor, const unsigned int stack) const
TCanvas * drawSACZeroScale(TCanvas *outputCanvas=nullptr) const
void scaleSAC0(const float factor, const Side side)
int getSACRejection(const unsigned int stack) const
void setSACZeroScale(const bool rejectOutlier)
float getSACOneVal(const Side side, unsigned int integrationInterval) const
TCanvas * drawSACOneCanvas(int nbins1D, float xMin1D, float xMax1D, int integrationIntervals=-1, TCanvas *outputCanvas=nullptr) const
TCanvas * drawSACTypeSides(const SACType type, const unsigned int integrationInterval, const int minZ=0, const int maxZ=-1, TCanvas *canv=nullptr)
TCanvas * drawFourierCoeffSAC(Side side, int nbins1D, float xMin1D, float xMax1, TCanvas *outputCanvas=nullptr) const
auto getSACValue(const unsigned int stack, const unsigned int interval) const
float getMeanSACZero(const o2::tpc::Side side, bool rejectOutliers)
float getSACZeroVal(const unsigned int stack) const
GLuint const GLchar * name
GLint GLint GLsizei GLint GLenum GLenum type
GLint GLenum GLint const GLfloat * coeffs
GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat maxZ
constexpr unsigned char SECTORSPERSIDE
@ IDC
integrated and grouped IDCs
@ IDCZero
IDC0: I_0(r,\phi) = <I(r,\phi,t)>_t.
@ IDCDelta
IDCDelta: \Delta I(r,\phi,t) = I(r,\phi,t) / ( I_0(r,\phi) * I_1(t) )
Enum< T >::Iterator begin(Enum< T >)
constexpr unsigned char SIDES
constexpr unsigned short GEMSTACKSPERSECTOR
std::array< FourierCoeff, SIDES > mCoeff
std::function< float(const unsigned int, const unsigned int)> mSACFunc
function returning the value which will be drawn for sector, stack