Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 27 additions & 22 deletions Common/Core/FFitWeights.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@

#include "FFitWeights.h"

#include <string>
#include <cstdio>
#include <vector>

#include <TSpline.h>

ClassImp(FFitWeights)
Expand Down Expand Up @@ -43,55 +47,55 @@
delete qAxis;
};

void FFitWeights::Init()
void FFitWeights::init()
{
fW_data = new TObjArray();
fW_data->SetName("FFitWeights_Data");
fW_data->SetOwner(kTRUE);

if (!qAxis)
this->SetBinAxis(500, 0, 25);
this->setBinAxis(500, 0, 25);
for (const auto& qn : qnTYPE) {
fW_data->Add(new TH2D(this->GetQName(qn.first, qn.second.c_str()), this->GetAxisName(qn.first, qn.second.c_str()), CentBin, 0, CentBin, qAxis->GetNbins(), qAxis->GetXmin(), qAxis->GetXmax()));
fW_data->Add(new TH2D(this->getQName(qn.first, qn.second.c_str()), this->getAxisName(qn.first, qn.second.c_str()), CentBin, 0, CentBin, qAxis->GetNbins(), qAxis->GetXmin(), qAxis->GetXmax()));
}
};

void FFitWeights::Fill(float centrality, float qn, int nh, const char* pf)
void FFitWeights::fillWeights(float centrality, float qn, int nh, const char* pf)
{
TObjArray* tar{nullptr};

tar = fW_data;
if (!tar)
return;

TH2D* th2 = reinterpret_cast<TH2D*>(tar->FindObject(this->GetQName(nh, pf)));
TH2D* th2 = reinterpret_cast<TH2D*>(tar->FindObject(this->getQName(nh, pf)));
if (!th2) {
tar->Add(new TH2D(this->GetQName(nh, pf), this->GetAxisName(nh, pf), CentBin, 0, CentBin, qAxis->GetNbins(), qAxis->GetXmin(), qAxis->GetXmax()));
tar->Add(new TH2D(this->getQName(nh, pf), this->getAxisName(nh, pf), CentBin, 0, CentBin, qAxis->GetNbins(), qAxis->GetXmin(), qAxis->GetXmax()));
th2 = reinterpret_cast<TH2D*>(tar->At(tar->GetEntries() - 1));
}
th2->Fill(centrality, qn);
};

Long64_t FFitWeights::Merge(TCollection* collist)

Check warning on line 79 in Common/Core/FFitWeights.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[root-entity]

Consider replacing ROOT entities with equivalents from standard C++ or from O2.

Check warning on line 79 in Common/Core/FFitWeights.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[name/function-variable]

Use lowerCamelCase for names of functions and variables.
{
Long64_t nmerged = 0;

Check warning on line 81 in Common/Core/FFitWeights.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[root-entity]

Consider replacing ROOT entities with equivalents from standard C++ or from O2.
if (!fW_data) {
fW_data = new TObjArray();
fW_data->SetName("FFitWeights_Data");
fW_data->SetOwner(kTRUE);
}
FFitWeights* l_w = 0;

Check warning on line 87 in Common/Core/FFitWeights.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[name/function-variable]

Use lowerCamelCase for names of functions and variables.
TIter all_w(collist);

Check warning on line 88 in Common/Core/FFitWeights.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[name/function-variable]

Use lowerCamelCase for names of functions and variables.
while ((l_w = (reinterpret_cast<FFitWeights*>(all_w())))) {
AddArray(fW_data, l_w->GetDataArray());
addArray(fW_data, l_w->getDataArray());
nmerged++;
}
return nmerged;
};
void FFitWeights::AddArray(TObjArray* targ, TObjArray* sour)
void FFitWeights::addArray(TObjArray* targ, TObjArray* sour)
{
if (!sour) {
printf("Source array does not exist!\n");

Check warning on line 98 in Common/Core/FFitWeights.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[logging]

Consider using O2 logging (LOG, LOGF, LOGP).
return;
}
for (int i = 0; i < sour->GetEntries(); i++) {
Expand All @@ -107,7 +111,7 @@
}
};

void FFitWeights::qSelectionSpline(std::vector<int> nhv, std::vector<std::string> stv) /* only execute OFFLINE */
void FFitWeights::qSelection(std::vector<int> nhv, std::vector<std::string> stv) /* only execute OFFLINE */
{
TObjArray* tar{nullptr};

Expand All @@ -117,15 +121,15 @@

for (const auto& pf : stv) {
for (const auto& nh : nhv) {
TH2D* th2 = reinterpret_cast<TH2D*>(tar->FindObject(this->GetQName(nh, pf.c_str())));
TH2D* th2{reinterpret_cast<TH2D*>(tar->FindObject(this->getQName(nh, pf.c_str())))};
if (!th2) {
printf("qh not found!\n");

Check warning on line 126 in Common/Core/FFitWeights.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[logging]

Consider using O2 logging (LOG, LOGF, LOGP).
return;
}

TH1D* tmp = nullptr;
TGraph* tmpgr = nullptr;
TSpline3* spline = nullptr;
TH1D* tmp{nullptr};
TGraph* tmpgr{nullptr};
// TSpline3* spline = nullptr;
for (int iSP{0}; iSP < 90; iSP++) {
tmp = th2->ProjectionY(Form("q%i_%i_%i", nh, iSP, iSP + 1), iSP + 1, iSP + 1);
std::vector<double> xq(nResolution);
Expand All @@ -134,35 +138,36 @@
xq[i] = static_cast<double>(i + 1) / static_cast<double>(nResolution);
tmp->GetQuantiles(nResolution, yq.data(), xq.data());
tmpgr = new TGraph(nResolution, yq.data(), xq.data());
spline = new TSpline3(Form("sp_q%i%s_%i", nh, pf.c_str(), iSP), tmpgr);
spline->SetName(Form("sp_q%i%s_%i", nh, pf.c_str(), iSP));
fW_data->Add(spline);
tmpgr->SetName(Form("sp_q%i%s_%i", nh, pf.c_str(), iSP));
// spline = new TSpline3(Form("sp_q%i%s_%i", nh, pf.c_str(), iSP), tmpgr);
// spline->SetName(Form("sp_q%i%s_%i", nh, pf.c_str(), iSP));
fW_data->Add(tmpgr);
}
}
}
};

float FFitWeights::EvalSplines(float centr, const float& dqn, const int nh, const char* pf)
float FFitWeights::eval(float centr, const float& dqn, const int nh, const char* pf)
{
TObjArray* tar{nullptr};

tar = fW_data;
if (!tar)
return -1;

int isp = static_cast<int>(centr);
int isp{static_cast<int>(centr)};
if (isp < 0 || isp > 90) {
return -1;
}

TSpline3* spline = nullptr;
spline = reinterpret_cast<TSpline3*>(tar->FindObject(Form("sp_q%i%s_%i", nh, pf, isp)));
TGraph* spline{nullptr};
spline = reinterpret_cast<TGraph*>(tar->FindObject(Form("sp_q%i%s_%i", nh, pf, isp)));
if (!spline) {
return -1;
}

float qn_val = 100. * spline->Eval(dqn);
if (qn_val < 0) {
float qn_val{static_cast<float>(100. * spline->Eval(dqn))};

Check warning on line 169 in Common/Core/FFitWeights.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[name/function-variable]

Use lowerCamelCase for names of functions and variables.
if (qn_val < 0 || qn_val > 100.05) {
return -1;
}

Expand Down
27 changes: 14 additions & 13 deletions Common/Core/FFitWeights.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,25 +38,26 @@
{
public:
FFitWeights();
explicit FFitWeights(const char* name);

Check warning on line 41 in Common/Core/FFitWeights.h

View workflow job for this annotation

GitHub Actions / O2 linter

[name/function-variable]

Use lowerCamelCase for names of functions and variables.
~FFitWeights();

void Init();
void Fill(float centrality, float qn, int nh, const char* pf = "");
TObjArray* GetDataArray() { return fW_data; }
void init();
void fillWeights(float centrality, float qn, int nh, const char* pf = "");
TObjArray* getDataArray() { return fW_data; }

void SetCentBin(int bin) { CentBin = bin; }
void SetBinAxis(int bin, float min, float max)
void setCentBin(int bin) { CentBin = bin; }
void setBinAxis(int bin, float min, float max)
{
qAxis = new TAxis(bin, min, max);
}
TAxis* GetqVecAx() { return qAxis; }
TAxis* getqVecAx() { return qAxis; }

Long64_t Merge(TCollection* collist);

Check warning on line 55 in Common/Core/FFitWeights.h

View workflow job for this annotation

GitHub Actions / O2 linter

[root-entity]

Consider replacing ROOT entities with equivalents from standard C++ or from O2.
void qSelectionSpline(std::vector<int> nhv, std::vector<std::string> stv);
float EvalSplines(float centr, const float& dqn, const int nh, const char* pf = "");
void SetResolution(int res) { nResolution = res; }
void SetQnType(std::vector<std::pair<int, std::string>> qninp) { qnTYPE = qninp; }
void qSelection(std::vector<int> nhv, std::vector<std::string> stv);
float eval(float centr, const float& dqn, const int nh, const char* pf = "");
void setResolution(int res) { nResolution = res; }
int getResolution() const { return nResolution; }
void setQnType(std::vector<std::pair<int, std::string>> qninp) { qnTYPE = qninp; }

private:
TObjArray* fW_data;
Expand All @@ -67,15 +68,15 @@

std::vector<std::pair<int, std::string>> qnTYPE;

const char* GetQName(const int nh, const char* pf = "")
const char* getQName(const int nh, const char* pf = "")
{
return Form("q%i%s", nh, pf);
};
const char* GetAxisName(const int nh, const char* pf = "")
const char* getAxisName(const int nh, const char* pf = "")
{
return Form(";Centrality;q_{%i}^{%s}", nh, pf);
};
void AddArray(TObjArray* targ, TObjArray* sour);
void addArray(TObjArray* targ, TObjArray* sour);

ClassDef(FFitWeights, 1); // calibration class
};
Expand Down
15 changes: 9 additions & 6 deletions Common/DataModel/EseTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,23 @@ namespace q_vector
DECLARE_SOA_COLUMN(QPERCFT0C, qPERCFT0C, std::vector<float>);
DECLARE_SOA_COLUMN(QPERCFT0A, qPERCFT0A, std::vector<float>);
DECLARE_SOA_COLUMN(QPERCFV0A, qPERCFV0A, std::vector<float>);
DECLARE_SOA_COLUMN(QPERCTPC, qPERCTPC, std::vector<float>);
DECLARE_SOA_COLUMN(FESECOL, fESECOL, std::vector<int>);
DECLARE_SOA_COLUMN(QPERCTPCall, qPERCTPCall, std::vector<float>);
DECLARE_SOA_COLUMN(QPERCTPCneg, qPERCTPCneg, std::vector<float>);
DECLARE_SOA_COLUMN(QPERCTPCpos, qPERCTPCpos, std::vector<float>);
} // namespace q_vector
DECLARE_SOA_TABLE(QPercentileFT0Cs, "AOD", "QPERCENTILEFT0C", q_vector::QPERCFT0C);
DECLARE_SOA_TABLE(QPercentileFT0As, "AOD", "QPERCENTILEFT0A", q_vector::QPERCFT0A);
DECLARE_SOA_TABLE(QPercentileFV0As, "AOD", "QPERCENTILEFV0A", q_vector::QPERCFV0A);
DECLARE_SOA_TABLE(QPercentileTPCs, "AOD", "QPERCENTILETPC", q_vector::QPERCTPC);
DECLARE_SOA_TABLE(FEseCols, "AOD", "FEVENTSHAPE", q_vector::FESECOL);
DECLARE_SOA_TABLE(QPercentileTPCalls, "AOD", "QPERCENTILETPCall", q_vector::QPERCTPCall);
DECLARE_SOA_TABLE(QPercentileTPCnegs, "AOD", "QPERCENTILETPCneg", q_vector::QPERCTPCneg);
DECLARE_SOA_TABLE(QPercentileTPCposs, "AOD", "QPERCENTILETPCpos", q_vector::QPERCTPCpos);

using QPercentileFT0C = QPercentileFT0Cs::iterator;
using QPercentileFT0A = QPercentileFT0As::iterator;
using QPercentileFV0A = QPercentileFV0As::iterator;
using QPercentileTPC = QPercentileTPCs::iterator;
using FEseCol = FEseCols::iterator;
using QPercentileTPCall = QPercentileTPCalls::iterator;
using QPercentileTPCneg = QPercentileTPCnegs::iterator;
using QPercentileTPCpos = QPercentileTPCposs::iterator;

} // namespace o2::aod

Expand Down
Loading
Loading