|
| 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 "TPCQC/SACs.h" |
| 13 | +#include "TPCCalibration/SACDrawHelper.h" |
| 14 | +#include "TH2Poly.h" |
| 15 | +#include "fmt/format.h" |
| 16 | + |
| 17 | +ClassImp(o2::tpc::qc::SACs); |
| 18 | +using namespace o2::tpc::qc; |
| 19 | + |
| 20 | +float SACs::getSACOneVal(const Side side, unsigned int integrationInterval) const |
| 21 | +{ |
| 22 | + return !mSACOne[side] ? -1 : mSACOne[side]->getValue(side, integrationInterval); |
| 23 | +} |
| 24 | + |
| 25 | +TCanvas* SACs::drawSACTypeSides(const SACType type, const unsigned int integrationInterval, const int minZ, const int maxZ, TCanvas* canv) |
| 26 | +{ |
| 27 | + std::string name; |
| 28 | + std::function<float(const unsigned int, const unsigned int)> SACFunc; |
| 29 | + if (type == o2::tpc::SACType::IDC) { |
| 30 | + SACFunc = [this, integrationInterval](const unsigned int sector, const unsigned int stack) { |
| 31 | + return this->getSACValue(getStack(sector, stack), integrationInterval); |
| 32 | + }; |
| 33 | + name = "SAC"; |
| 34 | + } else if (type == o2::tpc::SACType::IDCZero) { |
| 35 | + SACFunc = [this](const unsigned int sector, const unsigned int stack) { |
| 36 | + return this->getSACZeroVal(getStack(sector, stack)); |
| 37 | + }; |
| 38 | + name = "SACZero"; |
| 39 | + } else if (type == o2::tpc::SACType::IDCDelta) { |
| 40 | + SACFunc = [this, integrationInterval](const unsigned int sector, const unsigned int stack) { |
| 41 | + return this->getSACDeltaVal(getStack(sector, stack), integrationInterval); |
| 42 | + }; |
| 43 | + name = "SACDelta"; |
| 44 | + } |
| 45 | + |
| 46 | + auto c = canv; |
| 47 | + if (!c) { |
| 48 | + c = new TCanvas(fmt::format("c_sides_{}", name).data(), fmt::format("sides_{}", name).data(), 500, 1000); |
| 49 | + } |
| 50 | + |
| 51 | + SACDrawHelper::SACDraw drawFun; |
| 52 | + drawFun.mSACFunc = SACFunc; |
| 53 | + const std::string zAxisTitle = SACDrawHelper::getZAxisTitle(type); |
| 54 | + |
| 55 | + auto hSideA = SACDrawHelper::drawSide(drawFun, o2::tpc::Side::A, zAxisTitle); |
| 56 | + auto hSideC = SACDrawHelper::drawSide(drawFun, o2::tpc::Side::C, zAxisTitle); |
| 57 | + |
| 58 | + hSideA->SetTitle(fmt::format("{} ({}-Side)", name.data(), "A").data()); |
| 59 | + hSideC->SetTitle(fmt::format("{} ({}-Side)", name.data(), "C").data()); |
| 60 | + |
| 61 | + if (minZ < maxZ) { |
| 62 | + hSideA->SetMinimum(minZ); |
| 63 | + hSideC->SetMinimum(minZ); |
| 64 | + hSideA->SetMaximum(maxZ); |
| 65 | + hSideC->SetMaximum(maxZ); |
| 66 | + } |
| 67 | + |
| 68 | + c->Divide(1, 2); |
| 69 | + c->cd(1); |
| 70 | + hSideA->Draw("colz"); |
| 71 | + c->cd(2); |
| 72 | + hSideC->Draw("colz"); |
| 73 | + |
| 74 | + hSideA->SetBit(TObject::kCanDelete); |
| 75 | + hSideC->SetBit(TObject::kCanDelete); |
| 76 | + |
| 77 | + return c; |
| 78 | +} |
| 79 | + |
| 80 | +TCanvas* SACs::drawSACOneCanvas(int nbins1D, float xMin1D, float xMax1D, int integrationIntervals, TCanvas* outputCanvas) const |
| 81 | +{ |
| 82 | + auto* canv = outputCanvas; |
| 83 | + |
| 84 | + if (!canv) { |
| 85 | + canv = new TCanvas("c_sides_SAC1_1D", "SAC1 1D distribution for each side", 1000, 1000); |
| 86 | + } |
| 87 | + |
| 88 | + auto hAside1D = new TH1F("h_SAC1_1D_ASide", "SAC1 distribution over integration intervals A-Side", nbins1D, xMin1D, xMax1D); |
| 89 | + auto hCside1D = new TH1F("h_SAC1_1D_CSide", "SAC1 distribution over integration intervals C-Side", nbins1D, xMin1D, xMax1D); |
| 90 | + |
| 91 | + hAside1D->GetXaxis()->SetTitle("SAC1"); |
| 92 | + hAside1D->SetTitleOffset(1.05, "XY"); |
| 93 | + hAside1D->SetTitleSize(0.05, "XY"); |
| 94 | + hCside1D->GetXaxis()->SetTitle("SAC1"); |
| 95 | + hCside1D->SetTitleOffset(1.05, "XY"); |
| 96 | + hCside1D->SetTitleSize(0.05, "XY"); |
| 97 | + if (integrationIntervals <= 0) { |
| 98 | + integrationIntervals = std::min(mSACOne[Side::A]->mSACOne[Side::A].getNIDCs(), mSACOne[Side::C]->mSACOne[Side::C].getNIDCs()); |
| 99 | + } |
| 100 | + for (unsigned int integrationInterval = 0; integrationInterval < integrationIntervals; ++integrationInterval) { |
| 101 | + hAside1D->Fill(getSACOneVal(Side::A, integrationInterval)); |
| 102 | + hCside1D->Fill(getSACOneVal(Side::C, integrationInterval)); |
| 103 | + } |
| 104 | + |
| 105 | + canv->Divide(1, 2); |
| 106 | + canv->cd(1); |
| 107 | + hAside1D->Draw(); |
| 108 | + canv->cd(2); |
| 109 | + hCside1D->Draw(); |
| 110 | + |
| 111 | + hAside1D->SetBit(TObject::kCanDelete); |
| 112 | + hCside1D->SetBit(TObject::kCanDelete); |
| 113 | + |
| 114 | + return canv; |
| 115 | +} |
| 116 | + |
| 117 | +TCanvas* SACs::drawFourierCoeffSAC(Side side, int nbins1D, float xMin1D, float xMax1D, TCanvas* outputCanvas) const |
| 118 | +{ |
| 119 | + auto* canv = outputCanvas; |
| 120 | + if (!canv) { |
| 121 | + 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); |
| 122 | + } |
| 123 | + |
| 124 | + std::vector<TH1F*> histos; |
| 125 | + |
| 126 | + for (int i = 0; i < mFourierSAC->mCoeff[side].getNCoefficientsPerTF(); i++) { |
| 127 | + 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)); |
| 128 | + histos.back()->GetXaxis()->SetTitle(fmt::format("Fourier Coefficient {}", i).data()); |
| 129 | + } |
| 130 | + |
| 131 | + const auto& coeffs = mFourierSAC->mCoeff[side].getFourierCoefficients(); |
| 132 | + const auto nCoeffPerTF = mFourierSAC->mCoeff[side].getNCoefficientsPerTF(); |
| 133 | + |
| 134 | + for (int i = 0; i < mFourierSAC->mCoeff[side].getNCoefficients(); i++) { |
| 135 | + histos.at(i % nCoeffPerTF)->Fill(coeffs.at(i)); |
| 136 | + } |
| 137 | + |
| 138 | + canv->DivideSquare(mFourierSAC->mCoeff[side].getNCoefficientsPerTF()); |
| 139 | + |
| 140 | + size_t pad = 1; |
| 141 | + |
| 142 | + for (const auto& hist : histos) { |
| 143 | + canv->cd(pad); |
| 144 | + hist->SetTitleOffset(1.05, "XY"); |
| 145 | + hist->SetTitleSize(0.05, "XY"); |
| 146 | + hist->Draw(); |
| 147 | + hist->SetBit(TObject::kCanDelete); |
| 148 | + pad++; |
| 149 | + } |
| 150 | + |
| 151 | + return canv; |
| 152 | +} |
0 commit comments