Project
Loading...
Searching...
No Matches
SACDrawHelper.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
13#include "TPCBase/Painter.h"
14#include "TH2Poly.h"
15#include "TCanvas.h"
16#include "TLatex.h"
17#include <fmt/format.h>
18#include <numeric>
19
20void o2::tpc::SACDrawHelper::drawSector(const SACDraw& SAC, const unsigned int sector, const std::string zAxisTitle, const std::string filename, const float minZ, const float maxZ)
21{
23 TH2Poly* poly = o2::tpc::painter::makeSectorHist("hSector", "Sector;local #it{x} (cm);local #it{y} (cm); #it{SAC}", 83.65f, 247.7f, -43.7f, 43.7f, painter::Type::Stack);
24
25 poly->SetContour(255);
26 poly->SetTitle(nullptr);
27 poly->GetYaxis()->SetTickSize(0.002f);
28 poly->GetYaxis()->SetTitleOffset(0.7f);
29 poly->GetZaxis()->SetTitleOffset(1.3f);
30 poly->SetStats(0);
31 poly->GetZaxis()->SetTitle(zAxisTitle.data());
32 if (minZ < maxZ) {
33 poly->SetMinimum(minZ);
34 poly->SetMaximum(maxZ);
35 }
36
37 TCanvas* can = new TCanvas("can", "can", 2000, 1400);
38 can->SetRightMargin(0.14f);
39 can->SetLeftMargin(0.06f);
40 can->SetTopMargin(0.04f);
41 poly->Draw("colz");
42
43 for (unsigned int stack = 0; stack < GEMSTACKSPERSECTOR; ++stack) {
44 const auto coordinate = coords[stack];
45 const float yPos = -static_cast<float>(coordinate.yVals[0] + coordinate.yVals[2]) / 2; // local coordinate system is mirrored
46 const float xPos = static_cast<float>(coordinate.xVals[0] + coordinate.xVals[2]) / 2;
47 poly->Fill(xPos, yPos, SAC.getSAC(sector, stack));
48 }
49
50 TLatex latex;
51 latex.DrawLatexNDC(.07, .9, fmt::format("Sector {}", sector).data());
52 if (!filename.empty()) {
53 can->SaveAs(filename.data());
54 delete poly;
55 delete can;
56 }
57}
58
59void o2::tpc::SACDrawHelper::drawSide(const SACDraw& SAC, const o2::tpc::Side side, const std::string zAxisTitle, const std::string filename, const float minZ, const float maxZ)
60{
61 TH2Poly* poly = o2::tpc::SACDrawHelper::drawSide(SAC, side, zAxisTitle);
62 if (minZ < maxZ) {
63 poly->SetMinimum(minZ);
64 poly->SetMaximum(maxZ);
65 }
66
67 TCanvas* can = new TCanvas("can", "can", 650, 600);
68 can->SetTopMargin(0.04f);
69 can->SetRightMargin(0.14f);
70 can->SetLeftMargin(0.1f);
71 poly->Draw("colz");
72
73 std::string sideName = (side == Side::A) ? "A-Side" : "C-Side";
74 TLatex latex;
75 latex.DrawLatexNDC(.13, .9, sideName.data());
76
77 if (!filename.empty()) {
78 can->SaveAs(filename.data());
79 delete poly;
80 delete can;
81 }
82}
83
84TH2Poly* o2::tpc::SACDrawHelper::drawSide(const SACDraw& SAC, const o2::tpc::Side side, const std::string zAxisTitle)
85{
88 poly->SetContour(255);
89 poly->SetTitle(nullptr);
90 poly->GetXaxis()->SetTitleOffset(1.2f);
91 poly->GetYaxis()->SetTitleOffset(1.3f);
92 poly->GetZaxis()->SetTitleOffset(1.3f);
93 poly->GetZaxis()->SetTitle(zAxisTitle.data());
94 poly->GetZaxis()->SetMaxDigits(3); // force exponential axis
95 poly->SetStats(0);
96
97 unsigned int sectorStart = (side == Side::A) ? 0 : o2::tpc::SECTORSPERSIDE;
98 unsigned int sectorEnd = (side == Side::A) ? o2::tpc::SECTORSPERSIDE : (sectorStart * SIDES);
99 for (unsigned int sector = sectorStart; sector < sectorEnd; ++sector) {
100 for (unsigned int stack = 0; stack < GEMSTACKSPERSECTOR; ++stack) {
101 const float angDeg = 10.f + sector * 20;
102 auto coordinate = coords[stack];
103 coordinate.rotate(angDeg);
104 auto const count = static_cast<float>(coordinate.yVals.size());
105 const float yPos = std::reduce(coordinate.yVals.begin(), coordinate.yVals.end()) / count;
106 const float xPos = std::reduce(coordinate.xVals.begin(), coordinate.xVals.end()) / count;
107 poly->Fill(xPos, yPos, SAC.getSAC(sector, stack));
108 }
109 }
110 return poly;
111}
112
114{
115 std::string stype = "SAC";
116 switch (type) {
117 case SACType::IDC:
118 default: {
119 return fmt::format("#it{{{}}} (ADC)", stype);
120 break;
121 }
122 case SACType::IDCZero: {
123 return fmt::format("#it{{{}_{{0}}}} (ADC)", stype);
124 break;
125 }
127 return fmt::format("#Delta#it{{{}}}", stype);
128 break;
129 case SACType::IDCOne: {
130 return fmt::format("#Delta#it{{{}}}_{{1}}", stype);
131 break;
132 }
133 case SACType::IDCOutlier: {
134 return fmt::format("#it{{{}}} (Outliers: Yellow)", stype);
135 break;
136 }
137 }
138}
uint32_t side
Definition RawData.h:0
uint32_t stack
Definition RawData.h:1
helper class for drawing SACs per sector/side
static std::string getZAxisTitle(const SACType type)
static void drawSector(const SACDraw &SAC, const unsigned int sector, const std::string zAxisTitle, const std::string filename, const float minZ=0, const float maxZ=-1)
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)
GLint GLsizei count
Definition glcorearb.h:399
GLsizei const GLubyte GLsizei GLenum const void * coords
Definition glcorearb.h:5468
GLint GLint GLsizei GLint GLenum GLenum type
Definition glcorearb.h:275
GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat maxZ
Definition glcorearb.h:2910
GLfloat GLfloat minZ
Definition glcorearb.h:2910
constexpr unsigned char SECTORSPERSIDE
Definition Defs.h:40
IDCType
IDC types.
@ IDC
integrated and grouped IDCs
@ IDCOne
IDC1: I_1(t) = <I(r,\phi,t) / I_0(r,\phi)>_{r,\phi}.
@ 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) )
constexpr unsigned char SIDES
Definition Defs.h:41
Side
TPC readout sidE.
Definition Defs.h:35
@ A
Definition Defs.h:35
constexpr unsigned short GEMSTACKSPERSECTOR
Definition Defs.h:57
std::string filename()
static std::vector< PadCoordinates > getStackCoordinatesSector()
create a vector of stack corner coordinate for one full sector
static TH2Poly * makeSectorHist(const std::string_view name="hSector", const std::string_view title="Sector;local #it{x} (cm);local #it{y} (cm)", const float xMin=83.65f, const float xMax=247.7f, const float yMin=-43.7f, const float yMax=43.7f, const Type type=Type::Pad)
@ Stack
drawing stacks
static TH2Poly * makeSideHist(Side side, const Type type=Type::Pad)