Skip to content

Commit 89be97b

Browse files
Bhawani Singhmartenole
authored andcommitted
TPC QCO: adds IDCvsSACZero Task
1 parent 94ad805 commit 89be97b

5 files changed

Lines changed: 296 additions & 1 deletion

File tree

Detectors/TPC/qc/CMakeLists.txt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ o2_add_library(TPCQC
1717
src/Tracks.cxx
1818
src/DCSPTemperature.cxx
1919
src/SACs.cxx
20+
src/IDCsVsSACs.cxx
2021
PUBLIC_LINK_LIBRARIES O2::TPCBase
2122
O2::DataFormatsTPC
2223
O2::GPUO2Interface
@@ -31,7 +32,8 @@ o2_target_root_dictionary(TPCQC
3132
include/TPCQC/Tracks.h
3233
include/TPCQC/CalPadWrapper.h
3334
include/TPCQC/DCSPTemperature.h
34-
include/TPCQC/SACs.h)
35+
include/TPCQC/SACs.h
36+
include/TPCQC/IDCsVsSACs.h)
3537

3638
o2_add_test(PID
3739
COMPONENT_NAME tpc
@@ -58,6 +60,12 @@ o2_add_test(SACs
5860
SOURCES test/test_SACs.cxx
5961
LABELS tpc)
6062

63+
o2_add_test(IDCsVsSACs
64+
COMPONENT_NAME tpc
65+
PUBLIC_LINK_LIBRARIES O2::TPCQC
66+
SOURCES test/test_IDCsVsSACs.cxx
67+
LABELS tpc)
68+
6169
o2_add_test_root_macro(macro/runPID.C
6270
PUBLIC_LINK_LIBRARIES O2::TPCQC
6371
O2::DataFormatsTPC
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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+
///
13+
/// @file IDCsVsSACs.h
14+
/// @author Bhawani Singh
15+
///
16+
17+
#ifndef AliceO2_TPC_IDCSVSSACS_H
18+
#define AliceO2_TPC_IDCSVSSACS_H
19+
20+
// root includes
21+
#include <string>
22+
23+
// o2 includes
24+
#include "DataFormatsTPC/Defs.h"
25+
26+
class TCanvas;
27+
namespace o2::tpc
28+
{
29+
template <class>
30+
class IDCCCDBHelper;
31+
template <class>
32+
class SACCCDBHelper;
33+
} // namespace o2::tpc
34+
// namespace o2::tpc
35+
namespace o2::tpc::qc
36+
{
37+
/// Keep QC information for SACs vs IDCs related observables
38+
/// \tparam DataT the data type for the IDCDelta which are stored in the CCDB (unsigned short, unsigned char, float)
39+
class IDCsVsSACs
40+
{
41+
public:
42+
IDCsVsSACs() = default;
43+
IDCsVsSACs(IDCCCDBHelper<unsigned char>* mIDCs,
44+
SACCCDBHelper<unsigned char>* mSACs)
45+
{
46+
mCCDBHelper = mIDCs;
47+
mSacCCDBHelper = mSACs;
48+
}
49+
/// draw IDC0 and SAC0 side by side
50+
TCanvas* drawComparisionSACandIDCZero(TCanvas* outputCanvas, int nbins1D, float xMin1D, float xMax1D, int nbins1DSAC, float xMin1DSAC, float xMax1DSAC) const;
51+
52+
private:
53+
IDCCCDBHelper<unsigned char>* mCCDBHelper;
54+
SACCCDBHelper<unsigned char>* mSacCCDBHelper;
55+
56+
ClassDefNV(IDCsVsSACs, 1)
57+
};
58+
} // namespace o2::tpc::qc
59+
#endif
Lines changed: 205 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,205 @@
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"
21+
#include "TPCCalibration/IDCCCDBHelper.h"
22+
#include "TPCCalibration/SACCCDBHelper.h"
23+
#include "TPCCalibration/IDCDrawHelper.h"
24+
#include "TPCCalibration/SACDrawHelper.h"
25+
#include "TPCCalibration/SACFactorization.h"
26+
#include "TPCBase/CalDet.h"
27+
#include "TPCBase/Mapper.h"
28+
#include "TPCBase/Painter.h"
29+
30+
TCanvas* 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+
42+
SACDrawHelper::SACDraw drawFun;
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) {
93+
/// get SACs zero values
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");
148+
o2::tpc::painter::drawSectorsXY(Side::A);
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");
155+
o2::tpc::painter::drawSectorsXY(Side::C);
156+
c->cd(3);
157+
hSac0SideA->Draw("colz");
158+
hSac0SideA->SetStats(0);
159+
hSac0SideA->SetTitleOffset(1.05, "XY");
160+
hSac0SideA->SetTitleSize(0.05, "XY");
161+
o2::tpc::painter::drawSectorsXY(Side::A);
162+
c->cd(4);
163+
hSac0SideC->Draw("colz");
164+
hSac0SideC->SetStats(0);
165+
hSac0SideC->SetTitleOffset(1.05, "XY");
166+
hSac0SideC->SetTitleSize(0.05, "XY");
167+
o2::tpc::painter::drawSectorsXY(Side::A);
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");
174+
o2::tpc::painter::drawSectorsXY(Side::A);
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");
181+
o2::tpc::painter::drawSectorsXY(Side::C);
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+
}

Detectors/TPC/qc/src/TPCQCLinkDef.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#pragma link C++ class o2::tpc::qc::CalPadWrapper + ;
2323
#pragma link C++ class o2::tpc::qc::DCSPTemperature + ;
2424
#pragma link C++ class o2::tpc::qc::SACs + ;
25+
#pragma link C++ class o2::tpc::qc::IDCsVsSACs + ;
2526
#pragma link C++ function o2::tpc::qc::helpers::makeLogBinning + ;
2627
#pragma link C++ function o2::tpc::qc::helpers::setStyleHistogram1D + ;
2728
#pragma link C++ function o2::tpc::qc::helpers::setStyleHistogram2D + ;
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
#define BOOST_TEST_MODULE Test TPC QC
13+
#define BOOST_TEST_MAIN
14+
#define BOOST_TEST_DYN_LINK
15+
#include <boost/test/unit_test.hpp>
16+
#include "TPCQC/IDCsVsSACs.h"
17+
#include <cmath>
18+
19+
BOOST_AUTO_TEST_CASE(ReadWriteROOTFile)
20+
{
21+
o2::tpc::qc::IDCsVsSACs idcVssacs;
22+
}

0 commit comments

Comments
 (0)