Skip to content

Commit feb839c

Browse files
Bhawani Singhtklemenz
authored andcommitted
TPC QC: add task for SACs
1 parent 43c182a commit feb839c

File tree

5 files changed

+285
-2
lines changed

5 files changed

+285
-2
lines changed

Detectors/TPC/qc/CMakeLists.txt

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@ o2_add_library(TPCQC
1616
src/Clusters.cxx
1717
src/Tracks.cxx
1818
src/DCSPTemperature.cxx
19+
src/SACs.cxx
1920
PUBLIC_LINK_LIBRARIES O2::TPCBase
2021
O2::DataFormatsTPC
21-
O2::GPUO2Interface)
22+
O2::GPUO2Interface
23+
O2::TPCCalibration)
2224

2325

2426
o2_target_root_dictionary(TPCQC
@@ -28,7 +30,8 @@ o2_target_root_dictionary(TPCQC
2830
include/TPCQC/Clusters.h
2931
include/TPCQC/Tracks.h
3032
include/TPCQC/CalPadWrapper.h
31-
include/TPCQC/DCSPTemperature.h)
33+
include/TPCQC/DCSPTemperature.h
34+
include/TPCQC/SACs.h)
3235

3336
o2_add_test(PID
3437
COMPONENT_NAME tpc
@@ -49,6 +52,12 @@ o2_add_test(Tracks
4952
SOURCES test/test_Tracks.cxx
5053
LABELS tpc)
5154

55+
o2_add_test(SACs
56+
COMPONENT_NAME tpc
57+
PUBLIC_LINK_LIBRARIES O2::TPCQC
58+
SOURCES test/test_SACs.cxx
59+
LABELS tpc)
60+
5261
o2_add_test_root_macro(macro/runPID.C
5362
PUBLIC_LINK_LIBRARIES O2::TPCQC
5463
O2::DataFormatsTPC
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
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 SACs.h
14+
/// @author
15+
///
16+
17+
#ifndef AliceO2_TPC_SACS_H
18+
#define AliceO2_TPC_SACS_H
19+
20+
// root includes
21+
#include "TCanvas.h"
22+
23+
// o2 includes
24+
25+
#include "TPCCalibration/IDCContainer.h"
26+
#include "DataFormatsTPC/Defs.h"
27+
28+
namespace o2::tpc::qc
29+
{
30+
31+
/// Keep QC information for SAC related observables
32+
///
33+
class SACs
34+
{
35+
public:
36+
SACs() = default;
37+
38+
/// \return returns the stored SAC value
39+
/// \param stack stack
40+
/// \param interval integration interval
41+
auto getSACValue(const unsigned int stack, const unsigned int interval) const { return mSACs[stack][interval]; }
42+
43+
/// \return returns the stored SAC0 value
44+
/// \param stack stack
45+
float getSACZeroVal(const unsigned int stack) const { return mSACZero.getValueIDCZero(getSide(stack), stack % GEMSTACKSPERSIDE); }
46+
47+
/// \return returns SAC1 value
48+
/// \param Side TPC side
49+
/// \param interval integration interval
50+
float getSACOneVal(const Side side, unsigned int integrationInterval) const;
51+
52+
/// \return returns the stored DeltaSAC value
53+
/// \param stack stack
54+
/// \param interval integration interval
55+
float getSACDeltaVal(const unsigned int stack, unsigned int interval) const { return mSACDelta.getValue(getSide(stack), getSACDeltaIndex(stack, interval)); }
56+
57+
/// \return returns index for SAC delta
58+
/// \param stack stack
59+
/// \param interval local integration interval
60+
unsigned int getSACDeltaIndex(const unsigned int stack, unsigned int interval) const { return stack % GEMSTACKSPERSIDE + GEMSTACKSPERSIDE * interval; }
61+
62+
void setSACZero(const SACZero& sacZero) { mSACZero = sacZero; }
63+
void setSACOne(SACOne* sacOne, const Side side = Side::A) { mSACOne[side] = sacOne; }
64+
65+
template <typename T>
66+
void setSACDelta(const SACDelta<T>& sacDelta)
67+
{
68+
mSACDelta = sacDelta;
69+
}
70+
71+
/// setting the fourier coefficients
72+
void setFourierCoeffSAC(FourierCoeffSAC* fourier) { mFourierSAC = fourier; }
73+
74+
TCanvas* drawSACTypeSides(const SACType type, const unsigned int integrationInterval, const int minZ = 0, const int maxZ = -1, TCanvas* canv = nullptr);
75+
TCanvas* drawSACOneCanvas(TCanvas* outputCanvas, int nbins1D, float xMin1D, float xMax1D, int integrationIntervals = -1) const;
76+
TCanvas* drawFourierCoeffSAC(TCanvas* outputCanvas, Side side, int nbins1D, float xMin1D, float xMax1D) const;
77+
78+
void dumpToFile(std::string filename, int type = 0);
79+
80+
private:
81+
std::array<std::vector<int32_t>, o2::tpc::GEMSTACKS> mSACs{};
82+
SACZero mSACZero{};
83+
std::array<SACOne*, SIDES> mSACOne = {nullptr, nullptr}; ///< I_1(t) = <I(r,\phi,t) / I_0(r,\phi)>_{r,\phi}
84+
SACDelta<unsigned char> mSACDelta{};
85+
FourierCoeffSAC* mFourierSAC = nullptr; ///< fourier coefficients of SACOne
86+
87+
/// \return returns side for given GEM stack
88+
Side getSide(const unsigned int gemStack) const { return (gemStack < GEMSTACKSPERSIDE) ? Side::A : Side::C; }
89+
90+
/// \return returns stack for given sector and stack
91+
unsigned int getStack(const unsigned int sector, const unsigned int stack) const { return static_cast<unsigned int>(stack + sector * GEMSTACKSPERSECTOR); }
92+
93+
ClassDefNV(SACs, 1)
94+
};
95+
} // namespace o2::tpc::qc
96+
#endif

Detectors/TPC/qc/src/SACs.cxx

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
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+
TCanvas* SACs::drawSACTypeSides(const SACType type, const unsigned int integrationInterval, const int minZ, const int maxZ, TCanvas* canv)
25+
{
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+
} else {
45+
}
46+
47+
auto c = canv;
48+
if (!c) {
49+
std::cout << "Using the Canvas that we want\n";
50+
c = new TCanvas(fmt::format("c_sides_{}", name).data(), fmt::format("sides_{}", name).data(), 500, 1000);
51+
}
52+
53+
SACDrawHelper::SACDraw drawFun;
54+
drawFun.mSACFunc = SACFunc;
55+
const std::string zAxisTitle = SACDrawHelper::getZAxisTitle(type);
56+
57+
auto hSideA = SACDrawHelper::drawSide(drawFun, o2::tpc::Side::A, zAxisTitle);
58+
auto hSideC = SACDrawHelper::drawSide(drawFun, o2::tpc::Side::C, zAxisTitle);
59+
60+
hSideA->SetTitle(fmt::format("{} ({}-Side)", name.data(), "A").data());
61+
hSideC->SetTitle(fmt::format("{} ({}-Side)", name.data(), "C").data());
62+
63+
if (minZ < maxZ) {
64+
65+
hSideA->SetMinimum(minZ);
66+
hSideC->SetMinimum(minZ);
67+
hSideA->SetMaximum(maxZ);
68+
hSideC->SetMaximum(maxZ);
69+
}
70+
71+
c->Divide(1, 2);
72+
c->cd(1);
73+
hSideA->Draw("colz");
74+
c->cd(2);
75+
hSideC->Draw("colz");
76+
return c;
77+
}
78+
79+
TCanvas* SACs::drawSACOneCanvas(TCanvas* outputCanvas, int nbins1D, float xMin1D, float xMax1D, int integrationIntervals) const
80+
{
81+
TCanvas* canv = nullptr;
82+
83+
if (outputCanvas) {
84+
canv = outputCanvas;
85+
} else {
86+
canv = new TCanvas("c_sides_SAC1_1D", "SAC1 1D distribution for each side", 1000, 1000);
87+
}
88+
89+
auto hAside1D = new TH1F("h_SAC1_1D_ASide", "SAC1 distribution over integration intervals A-Side", nbins1D, xMin1D, xMax1D);
90+
auto hCside1D = new TH1F("h_SAC1_1D_CSide", "SAC1 distribution over integration intervals C-Side", nbins1D, xMin1D, xMax1D);
91+
92+
hAside1D->GetXaxis()->SetTitle("SAC1");
93+
hAside1D->SetTitleOffset(1.05, "XY");
94+
hAside1D->SetTitleSize(0.05, "XY");
95+
hCside1D->GetXaxis()->SetTitle("SAC1");
96+
hCside1D->SetTitleOffset(1.05, "XY");
97+
hCside1D->SetTitleSize(0.05, "XY");
98+
if (integrationIntervals <= 0) {
99+
integrationIntervals = std::min(mSACOne[Side::A]->mSACOne[Side::A].getNIDCs(), mSACOne[Side::C]->mSACOne[Side::C].getNIDCs());
100+
}
101+
for (unsigned int integrationInterval = 0; integrationInterval < integrationIntervals; ++integrationInterval) {
102+
hAside1D->Fill(getSACOneVal(Side::A, integrationInterval));
103+
hCside1D->Fill(getSACOneVal(Side::C, integrationInterval));
104+
}
105+
106+
canv->Divide(1, 2);
107+
canv->cd(1);
108+
hAside1D->Draw();
109+
canv->cd(2);
110+
hCside1D->Draw();
111+
112+
hAside1D->SetBit(TObject::kCanDelete);
113+
hCside1D->SetBit(TObject::kCanDelete);
114+
115+
return canv;
116+
}
117+
118+
TCanvas* SACs::drawFourierCoeffSAC(TCanvas* outputCanvas, Side side, int nbins1D, float xMin1D, float xMax1D) const
119+
{
120+
TCanvas* canv = nullptr;
121+
122+
if (outputCanvas) {
123+
canv = outputCanvas;
124+
} else {
125+
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);
126+
}
127+
128+
std::vector<TH1F*> histos;
129+
130+
for (int i = 0; i < mFourierSAC->mCoeff[side].getNCoefficientsPerTF(); i++) {
131+
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));
132+
histos.back()->GetXaxis()->SetTitle(fmt::format("Fourier Coefficient {}", i).data());
133+
histos.back()->SetBit(TObject::kCanDelete);
134+
}
135+
136+
const auto& coeffs = mFourierSAC->mCoeff[side].getFourierCoefficients();
137+
const auto nCoeffPerTF = mFourierSAC->mCoeff[side].getNCoefficientsPerTF();
138+
139+
for (int i = 0; i < mFourierSAC->mCoeff[side].getNCoefficients(); i++) {
140+
histos.at(i % nCoeffPerTF)->Fill(coeffs.at(i));
141+
}
142+
143+
canv->DivideSquare(mFourierSAC->mCoeff[side].getNCoefficientsPerTF());
144+
145+
size_t pad = 1;
146+
147+
for (const auto& hist : histos) {
148+
canv->cd(pad);
149+
hist->SetTitleOffset(1.05, "XY");
150+
hist->SetTitleSize(0.05, "XY");
151+
hist->Draw();
152+
pad++;
153+
}
154+
155+
return canv;
156+
}

Detectors/TPC/qc/src/TPCQCLinkDef.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#pragma link C++ class o2::tpc::qc::Tracks+;
2222
#pragma link C++ class o2::tpc::qc::CalPadWrapper+;
2323
#pragma link C++ class o2::tpc::qc::DCSPTemperature + ;
24+
#pragma link C++ class o2::tpc::qc::SACs+ ;
2425
#pragma link C++ function o2::tpc::qc::helpers::makeLogBinning+;
2526
#pragma link C++ function o2::tpc::qc::helpers::setStyleHistogram1D+;
2627
#pragma link C++ function o2::tpc::qc::helpers::setStyleHistogram2D+;
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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/SACs.h"
17+
18+
BOOST_AUTO_TEST_CASE(ReadWriteROOTFile)
19+
{
20+
o2::tpc::qc::SACs sacs;
21+
}

0 commit comments

Comments
 (0)