Skip to content

Commit ce8b290

Browse files
committed
mean-pt shape selection tables
1 parent 65082ef commit ce8b290

File tree

4 files changed

+259
-39
lines changed

4 files changed

+259
-39
lines changed

Common/Core/FFitWeights.cxx

Lines changed: 122 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <TCollection.h>
2020
#include <TH1.h>
2121
#include <TH2.h>
22+
#include <TProfile.h>
2223
#include <TNamed.h>
2324
#include <TObjArray.h>
2425
#include <TSpline.h>
@@ -35,25 +36,31 @@ ClassImp(FFitWeights)
3536

3637
FFitWeights::FFitWeights() : TNamed("", ""),
3738
fW_data{nullptr},
38-
CentBin{100},
39+
centBin{100},
3940
qAxis{nullptr},
4041
nResolution{3000},
42+
ptBin{100},
43+
ptAxis{nullptr},
4144
qnTYPE{0}
4245
{
4346
}
4447

4548
FFitWeights::FFitWeights(const char* name) : TNamed(name, name),
4649
fW_data{nullptr},
47-
CentBin{100},
50+
centBin{100},
4851
qAxis{nullptr},
4952
nResolution{3000},
53+
ptBin{100},
54+
ptAxis{nullptr},
5055
qnTYPE{0} {}
5156

5257
FFitWeights::~FFitWeights()
5358
{
5459
delete fW_data;
5560
if (qAxis)
5661
delete qAxis;
62+
if (ptAxis)
63+
delete ptAxis;
5764
};
5865

5966
void FFitWeights::init()
@@ -65,8 +72,14 @@ void FFitWeights::init()
6572
if (!qAxis)
6673
this->setBinAxis(500, 0, 25);
6774
for (const auto& qn : qnTYPE) {
68-
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()));
75+
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()));
6976
}
77+
78+
if (!ptAxis)
79+
this->setPtAxis(3000, -3, 3);
80+
//fW_data->Add(new TH2D("hPtWeight", "", centBin, 0, centBin, ptBin, ptAxis->GetXmin(), ptAxis->GetXmax()));
81+
fW_data->Add(new TProfile("pMeanPt","", centBin, 0, centBin));
82+
fW_data->Add(new TH2D("hPtWeight", "", centBin, 0, centBin, ptBin, ptAxis->GetXmin(), ptAxis->GetXmax()));
7083
};
7184

7285
void FFitWeights::fillWeights(float centrality, float qn, int nh, const char* pf)
@@ -79,11 +92,47 @@ void FFitWeights::fillWeights(float centrality, float qn, int nh, const char* pf
7992

8093
TH2D* th2 = reinterpret_cast<TH2D*>(tar->FindObject(this->getQName(nh, pf)));
8194
if (!th2) {
82-
tar->Add(new TH2D(this->getQName(nh, pf), this->getAxisName(nh, pf), CentBin, 0, CentBin, qAxis->GetNbins(), qAxis->GetXmin(), qAxis->GetXmax()));
95+
tar->Add(new TH2D(this->getQName(nh, pf), this->getAxisName(nh, pf), centBin, 0, centBin, qAxis->GetNbins(), qAxis->GetXmin(), qAxis->GetXmax()));
8396
th2 = reinterpret_cast<TH2D*>(tar->At(tar->GetEntries() - 1));
8497
}
8598
th2->Fill(centrality, qn);
8699
};
100+
void FFitWeights::fillPt(float centrality, float pt, bool first)
101+
{
102+
TObjArray* tar{nullptr};
103+
tar = fW_data;
104+
if (!tar)
105+
return;
106+
if (first) {
107+
auto tp = reinterpret_cast<TProfile*>(tar->FindObject("pMeanPt"));
108+
if (!tp) {
109+
tar->Add(new TProfile("pMeanPt", "", centBin, 0, centBin));
110+
tp = reinterpret_cast<TProfile*>(tar->At(tar->GetEntries() - 1));
111+
}
112+
tp->Fill(centrality, pt);
113+
}
114+
else {
115+
auto th2 = reinterpret_cast<TH2D*>(tar->FindObject("hPtWeight"));
116+
if (!th2) {
117+
tar->Add(new TH2D("hPtWeight", "", centBin, 0, centBin, ptBin, ptAxis->GetXmin(), ptAxis->GetXmax()));
118+
th2 = reinterpret_cast<TH2D*>(tar->At(tar->GetEntries() - 1));
119+
}
120+
th2->Fill(centrality, pt);
121+
}
122+
};
123+
float FFitWeights::getPtMult(float centrality)
124+
{
125+
TObjArray* tar{nullptr};
126+
tar = fW_data;
127+
if (!tar)
128+
return -1;
129+
130+
auto tp = reinterpret_cast<TProfile*>(tar->FindObject("pMeanPt"));
131+
if (!tp) {
132+
return -1;
133+
}
134+
return tp->GetBinContent(tp->FindBin(centrality));
135+
};
87136

88137
Long64_t FFitWeights::Merge(TCollection* collist)
89138
{
@@ -93,18 +142,19 @@ Long64_t FFitWeights::Merge(TCollection* collist)
93142
fW_data->SetName("FFitWeights_Data");
94143
fW_data->SetOwner(kTRUE);
95144
}
96-
FFitWeights* l_w = 0;
97-
TIter all_w(collist);
98-
while ((l_w = (reinterpret_cast<FFitWeights*>(all_w())))) {
99-
addArray(fW_data, l_w->getDataArray());
145+
FFitWeights* lW= 0;
146+
TIter allW(collist);
147+
while ((lW= (reinterpret_cast<FFitWeights*>(allW())))) {
148+
addArray(fW_data, lW->getDataArray());
100149
nmerged++;
101150
}
102151
return nmerged;
103152
};
104153
void FFitWeights::addArray(TObjArray* targ, TObjArray* sour)
105154
{
106155
if (!sour) {
107-
printf("Source array does not exist!\n");
156+
// printf("Source array does not exist!\n");
157+
//LOGF(info, "FFitWeights source array does not exist!");
108158
return;
109159
}
110160
for (int i = 0; i < sour->GetEntries(); i++) {
@@ -120,6 +170,34 @@ void FFitWeights::addArray(TObjArray* targ, TObjArray* sour)
120170
}
121171
};
122172

173+
void FFitWeights::mptSel()
174+
{
175+
TObjArray* tar{nullptr};
176+
tar = fW_data;
177+
if (!tar)
178+
return;
179+
180+
TH2D* th2 = reinterpret_cast<TH2D*>(tar->FindObject("hPtWeight"));
181+
if (!th2) {
182+
return;
183+
}
184+
185+
TH1D* tmp{nullptr};
186+
TGraph* tmpgr{nullptr};
187+
for (int iSP{0}; iSP < NumberSp; iSP++) {
188+
tmp = th2->ProjectionY(Form("mpt_%i_%i", iSP, iSP + 1), iSP + 1, iSP + 1);
189+
std::vector<double> xq(nResolution);
190+
std::vector<double> yq(nResolution);
191+
for (int i{0}; i < nResolution; i++)
192+
xq[i] = static_cast<double>(i + 1) / static_cast<double>(nResolution);
193+
tmp->GetQuantiles(nResolution, yq.data(), xq.data());
194+
tmpgr = new TGraph(nResolution, yq.data(), xq.data());
195+
tmpgr->SetName(Form("sp_mpt_%i", iSP));
196+
fW_data->Add(tmpgr);
197+
}
198+
199+
}
200+
123201
void FFitWeights::qSelection(const std::vector<int>& nhv, const std::vector<std::string>& stv) /* only execute OFFLINE */
124202
{
125203
TObjArray* tar{nullptr};
@@ -132,14 +210,15 @@ void FFitWeights::qSelection(const std::vector<int>& nhv, const std::vector<std:
132210
for (const auto& nh : nhv) {
133211
TH2D* th2{reinterpret_cast<TH2D*>(tar->FindObject(this->getQName(nh, pf.c_str())))};
134212
if (!th2) {
135-
printf("qh not found!\n");
213+
//printf("qh not found!\n");
214+
//LOGF(info, "FFitWeights qh not found!");
136215
return;
137216
}
138217

139218
TH1D* tmp{nullptr};
140219
TGraph* tmpgr{nullptr};
141220
// TSpline3* spline = nullptr;
142-
for (int iSP{0}; iSP < 90; iSP++) {
221+
for (int iSP{0}; iSP < NumberSp; iSP++) {
143222
tmp = th2->ProjectionY(Form("q%i_%i_%i", nh, iSP, iSP + 1), iSP + 1, iSP + 1);
144223
std::vector<double> xq(nResolution);
145224
std::vector<double> yq(nResolution);
@@ -161,11 +240,12 @@ float FFitWeights::eval(float centr, const float& dqn, const int nh, const char*
161240
TObjArray* tar{nullptr};
162241

163242
tar = fW_data;
164-
if (!tar)
243+
if (!tar) {
165244
return -1;
245+
}
166246

167247
int isp{static_cast<int>(centr)};
168-
if (isp < 0 || isp > 90) {
248+
if (isp < 0 || isp > NumberSp) {
169249
return -1;
170250
}
171251

@@ -175,10 +255,36 @@ float FFitWeights::eval(float centr, const float& dqn, const int nh, const char*
175255
return -1;
176256
}
177257

178-
float qn_val{static_cast<float>(100. * spline->Eval(dqn))};
179-
if (qn_val < 0 || qn_val > 100.05) {
258+
float qnVal{static_cast<float>(100. * spline->Eval(dqn))};
259+
if (qnVal < 0 || qnVal > MaxTol) {
180260
return -1;
181261
}
182262

183-
return qn_val;
263+
return qnVal;
184264
};
265+
266+
float FFitWeights::evalPt(float centr, const float& mpt)
267+
{
268+
TObjArray* tar{nullptr};
269+
tar = fW_data;
270+
if (!tar) {
271+
return -1;
272+
}
273+
274+
int isp{static_cast<int>(centr)};
275+
if (isp < 0 || isp > NumberSp) {
276+
return -1;
277+
}
278+
279+
TGraph* spline{nullptr};
280+
spline = reinterpret_cast<TGraph*>(tar->FindObject(Form("sp_mpt_%i", isp)));
281+
if (!spline) {
282+
return -1;
283+
}
284+
float ptVal{static_cast<float>(100. * spline->Eval(mpt))};
285+
if (ptVal < 0 || ptVal > MaxTol) {
286+
return -1;
287+
}
288+
return ptVal;
289+
};
290+

Common/Core/FFitWeights.h

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,28 +39,43 @@ class FFitWeights : public TNamed
3939

4040
void init();
4141
void fillWeights(float centrality, float qn, int nh, const char* pf = "");
42+
void fillPt(float centrality, float pt, bool first);
43+
float getPtMult(float centrality);
4244
TObjArray* getDataArray() { return fW_data; }
4345

44-
void setCentBin(int bin) { CentBin = bin; }
46+
void setCentBin(int bin) { centBin = bin; }
4547
void setBinAxis(int bin, float min, float max)
4648
{
4749
qAxis = new TAxis(bin, min, max);
4850
}
4951
TAxis* getqVecAx() { return qAxis; }
5052

53+
void setPtBin(int bin) { ptBin = bin; }
54+
void setPtAxis(int bin, float min, float max)
55+
{
56+
ptAxis = new TAxis(bin, min, max);
57+
}
58+
TAxis* getPtAx() { return ptAxis; }
59+
5160
Long64_t Merge(TCollection* collist);
5261
void qSelection(const std::vector<int>& nhv, const std::vector<std::string>& stv);
5362
float eval(float centr, const float& dqn, const int nh, const char* pf = "");
63+
float evalPt(float centr, const float& mpt);
5464
void setResolution(int res) { nResolution = res; }
5565
int getResolution() const { return nResolution; }
5666
void setQnType(const std::vector<std::pair<int, std::string>>& qninp) { qnTYPE = qninp; }
5767

68+
void mptSel();
69+
70+
5871
private:
5972
TObjArray* fW_data;
6073

61-
int CentBin;
74+
int centBin;
6275
TAxis* qAxis; //!
6376
int nResolution;
77+
int ptBin;
78+
TAxis* ptAxis; //!
6479

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

@@ -74,6 +89,9 @@ class FFitWeights : public TNamed
7489
};
7590
void addArray(TObjArray* targ, TObjArray* sour);
7691

92+
static constexpr int NumberSp = 90;
93+
static constexpr float MaxTol = 100.05;
94+
7795
ClassDef(FFitWeights, 1); // calibration class
7896
};
7997
#endif // COMMON_CORE_FFITWEIGHTS_H_

Common/DataModel/EseTable.h

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99
// granted to it by virtue of its status as an Intergovernmental Organization
1010
// or submit itself to any jurisdiction.
1111

12-
// q vector framework with ESE (20/08/2024)
13-
//
14-
/// \author Joachim Hansen <joachim.hansen@cern.ch>
12+
/// \file EseTable.h
13+
/// \brief ESE Framework (20/08/2024)
14+
/// \author Joachim C. K. B. Hansen, Lund University, joachim.hansen@cern.ch
15+
1516
//
1617

1718
#ifndef COMMON_DATAMODEL_ESETABLE_H_
@@ -46,6 +47,16 @@ using QPercentileTPCall = QPercentileTPCalls::iterator;
4647
using QPercentileTPCneg = QPercentileTPCnegs::iterator;
4748
using QPercentileTPCpos = QPercentileTPCposs::iterator;
4849

50+
namespace meanptshape
51+
{
52+
DECLARE_SOA_COLUMN(FMEANPT, fMEANPT, std::vector<float>);
53+
DECLARE_SOA_COLUMN(FMEANPTSHAPE, fMEANPTSHAPE, std::vector<float>);
54+
}
55+
DECLARE_SOA_TABLE(MeanPts, "AOD", "MEANPT", meanptshape::FMEANPT);
56+
DECLARE_SOA_TABLE(MeanPtShapes, "AOD", "MEANPTSHAPE", meanptshape::FMEANPTSHAPE);
57+
using MeanPt = MeanPts::iterator;
58+
using MeanPtShape = MeanPtShapes::iterator;
59+
4960
} // namespace o2::aod
5061

5162
#endif // COMMON_DATAMODEL_ESETABLE_H_

0 commit comments

Comments
 (0)