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+ }
0 commit comments