Skip to content

Commit 5f81644

Browse files
Bhawani Singhtklemenz
authored andcommitted
TPC QC: add task for SACs
1 parent a9bbc55 commit 5f81644

File tree

5 files changed

+288
-10
lines changed

5 files changed

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

Detectors/TPC/qc/src/SACs.cxx

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
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+
}

Detectors/TPC/qc/src/TPCQCLinkDef.h

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,16 @@
1515
#pragma link off all classes;
1616
#pragma link off all functions;
1717

18-
#pragma link C++ class o2::tpc::qc::PID+;
18+
#pragma link C++ class o2::tpc::qc::PID + ;
1919
#pragma link C++ class o2::tpc::qc::Tracking + ;
20-
#pragma link C++ class o2::tpc::qc::Clusters+;
21-
#pragma link C++ class o2::tpc::qc::Tracks+;
22-
#pragma link C++ class o2::tpc::qc::CalPadWrapper+;
20+
#pragma link C++ class o2::tpc::qc::Clusters + ;
21+
#pragma link C++ class o2::tpc::qc::Tracks + ;
22+
#pragma link C++ class o2::tpc::qc::CalPadWrapper + ;
2323
#pragma link C++ class o2::tpc::qc::DCSPTemperature + ;
24-
#pragma link C++ function o2::tpc::qc::helpers::makeLogBinning+;
25-
#pragma link C++ function o2::tpc::qc::helpers::setStyleHistogram1D+;
26-
#pragma link C++ function o2::tpc::qc::helpers::setStyleHistogram2D+;
27-
#pragma link C++ function o2::tpc::qc::helpers::newZSCalib+;
24+
#pragma link C++ class o2::tpc::qc::SACs + ;
25+
#pragma link C++ function o2::tpc::qc::helpers::makeLogBinning + ;
26+
#pragma link C++ function o2::tpc::qc::helpers::setStyleHistogram1D + ;
27+
#pragma link C++ function o2::tpc::qc::helpers::setStyleHistogram2D + ;
28+
#pragma link C++ function o2::tpc::qc::helpers::newZSCalib + ;
2829

2930
#endif
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)