Project
Loading...
Searching...
No Matches
IDCsVsSACs.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 <map>
13
14// root includes
15#include "TStyle.h"
16#include "TCanvas.h"
17#include "TH2Poly.h"
18#include "TProfile.h"
19
20#include "TPCQC/IDCsVsSACs.h"
26#include "TPCBase/CalDet.h"
27#include "TPCBase/Mapper.h"
28#include "TPCBase/Painter.h"
29
30TCanvas* o2::tpc::qc::IDCsVsSACs::drawComparisionSACandIDCZero(TCanvas* outputCanvas, int nbins1D, float xMin1D, float xMax1D, int nbins1DSAC, float xMin1DSAC, float xMax1DSAC) const
31{
32
33 const Mapper& mapper = Mapper::instance();
34
35 const auto& calDet = mCCDBHelper->getIDCZeroCalDet();
36 std::function<float(const unsigned int, const unsigned int)> SACFunc;
37
38 SACFunc = [&](const unsigned int sector, const unsigned int stack) {
39 return mSacCCDBHelper->getSACZeroVal(sector, stack);
40 };
41
43 drawFun.mSACFunc = SACFunc;
44
45 const std::string zAxisTitle = SACDrawHelper::getZAxisTitle(o2::tpc::SACType::IDCZero);
46 auto hSac0SideA = SACDrawHelper::drawSide(drawFun, o2::tpc::Side::A, zAxisTitle);
47 auto hSac0SideC = SACDrawHelper::drawSide(drawFun, o2::tpc::Side::C, zAxisTitle);
48
49 const std::string SACname = "SAC0";
50 hSac0SideA->SetTitle(fmt::format("{} ({}-Side)", SACname.data(), "A").data());
51 hSac0SideC->SetTitle(fmt::format("{} ({}-Side)", SACname.data(), "C").data());
52
53 // ===| name and title |======================================================
54 std::string title = calDet.getName();
55 std::string name = calDet.getName();
56 std::replace(name.begin(), name.end(), ' ', '_');
57 std::replace(title.begin(), title.end(), '_', ' ');
58
59 const std::string Rationame = "Ratio";
60
61 const int bufferSize = TH1::GetDefaultBufferSize();
62 TH1::SetDefaultBufferSize(Sector::MAXSECTOR * mapper.getPadsInSector());
63
64 auto h2DIdc0SideA = new TH2F(fmt::format("hIDC0_Aside_2D_{}", name).data(), fmt::format("{} (A-Side);#it{{x}} (cm);#it{{y}} (cm)", title).data(),
65 330, -270, 270, 330, -270, 270);
66
67 auto h2DIdc0SideC = new TH2F(fmt::format("hIDC0_Cside_2D_{}", name).data(), fmt::format("{} (C-Side);#it{{x}} (cm);#it{{y}} (cm)", title).data(),
68 330, -270, 270, 330, -270, 270);
69
70 auto hAsideRatio2D = new TH2F(fmt::format("hRatio_Aside_2D_{}", Rationame).data(), fmt::format("{} (A-Side);#it{{x}} (cm);#it{{y}} (cm)", Rationame).data(),
71 330, -270, 270, 330, -270, 270);
72
73 auto hCsideRatio2D = new TH2F(fmt::format("hRatio_CsideRatio_2D_{}", Rationame).data(), fmt::format("{} (C-Side);#it{{x}} (cm);#it{{y}} (cm)", Rationame).data(),
74 330, -270, 270, 330, -270, 270);
75
76 auto hAsideRatio1D = new TH1F(fmt::format("h_AsideRatio_1D_{}", Rationame).data(), fmt::format("{} (A-Side);IDC0/SAC0 (arb unit.);Entries", Rationame).data(),
77 nbins1D, xMin1D, xMax1D); // TODO: modify ranges
78
79 auto hCsideRatio1D = new TH1F(fmt::format("h_CsideRatio_1D_{}", Rationame).data(), fmt::format("{} (C-Side);IDC0/SAC0 (arb unit.);Entries", Rationame).data(),
80 nbins1D, xMin1D, xMax1D); // TODO: modify ranges
81
82 for (ROC roc; !roc.looped(); ++roc) {
83 auto hist2DIdc0 = h2DIdc0SideA;
84 auto histRatio2D = hAsideRatio2D;
85 auto histRatio1D = hAsideRatio1D;
86 if (roc.side() == Side::C) {
87 hist2DIdc0 = h2DIdc0SideC;
88 histRatio2D = hCsideRatio2D;
89 histRatio1D = hCsideRatio1D;
90 }
91 const int nrows = mapper.getNumberOfRowsROC(roc);
92 for (int irow = 0; irow < nrows; ++irow) {
94 const int part = o2::tpc::Mapper::REGION[irow] / 2;
95 const int stackID = (part < 2) ? 0 : part - 1;
96 const auto sacZero = mSacCCDBHelper->getSACZeroVal(roc.getSector(), stackID);
97 const int npads = mapper.getNumberOfPadsInRowROC(roc, irow);
98 for (int ipad = 0; ipad < npads; ++ipad) {
99 const auto val = calDet.getValue(roc, irow, ipad);
100 const GlobalPosition2D pos = mapper.getPadCentre(PadROCPos(roc, irow, ipad));
101 const int bin = hist2DIdc0->FindBin(pos.X(), pos.Y());
102 if (!hist2DIdc0->GetBinContent(bin)) {
103 hist2DIdc0->SetBinContent(bin, val);
104 if (val / sacZero != 0) {
105 histRatio2D->SetBinContent(bin, val / sacZero);
106 }
107 }
108 if (val / sacZero != 0) {
109 histRatio2D->SetBinContent(bin, val / sacZero);
110 histRatio1D->Fill(val / sacZero);
111 }
112 }
113 }
114 }
115
116 if (xMax1D > xMin1D) {
117
118 hSac0SideA->SetMinimum(xMin1DSAC);
119 hSac0SideC->SetMinimum(xMin1DSAC);
120 hSac0SideA->SetMaximum(xMax1DSAC);
121 hSac0SideC->SetMaximum(xMax1DSAC);
122
123 h2DIdc0SideA->SetMinimum(xMin1D);
124 h2DIdc0SideA->SetMaximum(xMax1D);
125 h2DIdc0SideC->SetMinimum(xMin1D);
126 h2DIdc0SideC->SetMaximum(xMax1D);
127 hAsideRatio2D->SetMinimum(xMin1D);
128 hCsideRatio2D->SetMaximum(xMax1D);
129 }
130
131 // ===| Draw histograms |=====================================================
132 gStyle->SetOptStat("mr");
133 auto c = outputCanvas;
134 if (!c) {
135 c = new TCanvas(fmt::format("c_{}", name).data(), title.data(), 1000, 1000);
136 }
137 gStyle->SetStatX(1. - gPad->GetRightMargin());
138 gStyle->SetStatY(1. - gPad->GetTopMargin());
139
140 c->Clear();
141 c->Divide(2, 4);
142
143 c->cd(1);
144 h2DIdc0SideA->Draw("colz");
145 h2DIdc0SideA->SetStats(0);
146 h2DIdc0SideA->SetTitleOffset(1.05, "XY");
147 h2DIdc0SideA->SetTitleSize(0.05, "XY");
149
150 c->cd(2);
151 h2DIdc0SideC->Draw("colz");
152 h2DIdc0SideC->SetStats(0);
153 h2DIdc0SideC->SetTitleOffset(1.05, "XY");
154 h2DIdc0SideC->SetTitleSize(0.05, "XY");
156 c->cd(3);
157 hSac0SideA->Draw("colz");
158 hSac0SideA->SetStats(0);
159 hSac0SideA->SetTitleOffset(1.05, "XY");
160 hSac0SideA->SetTitleSize(0.05, "XY");
162 c->cd(4);
163 hSac0SideC->Draw("colz");
164 hSac0SideC->SetStats(0);
165 hSac0SideC->SetTitleOffset(1.05, "XY");
166 hSac0SideC->SetTitleSize(0.05, "XY");
168
169 c->cd(5);
170 hAsideRatio2D->Draw("colz");
171 hAsideRatio2D->SetStats(0);
172 hAsideRatio2D->SetTitleOffset(1.05, "XY");
173 hAsideRatio2D->SetTitleSize(0.05, "XY");
175
176 c->cd(6);
177 hCsideRatio2D->Draw("colz");
178 hCsideRatio2D->SetStats(0);
179 hCsideRatio2D->SetTitleOffset(1.05, "XY");
180 hCsideRatio2D->SetTitleSize(0.05, "XY");
182 c->cd(7);
183 hAsideRatio1D->Draw();
184 hAsideRatio1D->SetTitleOffset(1.05, "XY");
185 hAsideRatio1D->SetTitleSize(0.05, "XY");
186 c->cd(8);
187 hCsideRatio1D->Draw();
188 hAsideRatio1D->SetTitleOffset(1.05, "XY");
189 hAsideRatio1D->SetTitleSize(0.05, "XY");
190
191 // reset the buffer size
192 TH1::SetDefaultBufferSize(bufferSize);
193
194 // associate histograms to canvas
195 hAsideRatio1D->SetBit(TObject::kCanDelete);
196 hCsideRatio1D->SetBit(TObject::kCanDelete);
197 h2DIdc0SideA->SetBit(TObject::kCanDelete);
198 h2DIdc0SideC->SetBit(TObject::kCanDelete);
199 hAsideRatio2D->SetBit(TObject::kCanDelete);
200 hCsideRatio2D->SetBit(TObject::kCanDelete);
201
202 hSac0SideA->SetBit(TObject::kCanDelete);
203 hSac0SideC->SetBit(TObject::kCanDelete);
204 return c;
205}
helper class for accessing IDCs from CCDB
helper class for drawing IDCs per region/side
uint16_t pos
Definition RawData.h:3
uint32_t roc
Definition RawData.h:3
uint32_t c
Definition RawData.h:2
uint32_t stack
Definition RawData.h:1
helper class for accessing SACs from CCDB
helper class for drawing SACs per sector/side
TPC factorization of SACs.
CalDet< float > getIDCZeroCalDet() const
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
static constexpr unsigned short getPadsInSector()
Definition Mapper.h:414
GlobalPosition2D getPadCentre(const PadSecPos &padSec) const
Definition Mapper.h:163
static constexpr unsigned REGION[PADROWS]
region for global pad row
Definition Mapper.h:537
Pad and row inside a ROC.
Definition PadROCPos.h:37
bool looped() const
if increment operator went above MaxROC
Definition ROC.h:108
float getSACZeroVal(const unsigned int sector, const unsigned int stack) const
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)
static constexpr int MAXSECTOR
Definition Sector.h:44
TCanvas * drawComparisionSACandIDCZero(TCanvas *outputCanvas, int nbins1D, float xMin1D, float xMax1D, int nbins1DSAC, float xMin1DSAC, float xMax1DSAC) const
draw IDC0 and SAC0 side by side
GLuint const GLchar * name
Definition glcorearb.h:781
GLboolean * data
Definition glcorearb.h:298
GLuint GLfloat * val
Definition glcorearb.h:1582
@ IDCZero
IDC0: I_0(r,\phi) = <I(r,\phi,t)>_t.
@ A
Definition Defs.h:35
@ C
Definition Defs.h:36
std::function< float(const unsigned int, const unsigned int)> mSACFunc
function returning the value which will be drawn for sector, stack
static void drawSectorsXY(Side side, int sectorLineColor=920, int sectorTextColor=1)
draw sector boundaris, side name and sector numbers