Skip to content

Commit 3e72d6b

Browse files
Merge branch 'AliceO2Group:master' into master
2 parents 6730754 + cd473c3 commit 3e72d6b

File tree

171 files changed

+12502
-3691
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

171 files changed

+12502
-3691
lines changed

Common/Core/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ o2physics_add_library(AnalysisCore
2424
FFitWeights.cxx
2525
Zorro.cxx
2626
ZorroSummary.cxx
27+
INSTALL_HEADERS ZorroHelper.h ZorroSummary.h
2728
PUBLIC_LINK_LIBRARIES O2::Framework O2::DataFormatsParameters ROOT::EG O2::CCDB ROOT::Physics O2::FT0Base O2::FV0Base O2::DataFormatsParamTOF)
2829

2930
o2physics_target_root_dictionary(AnalysisCore

Common/Core/CollisionAssociation.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ class CollisionAssociation
8080
switch (mTrackSelection) {
8181
case o2::aod::track_association::TrackSelection::CentralBarrelRun2: {
8282
unsigned char itsClusterMap = track.itsClusterMap();
83-
if (!(track.tpcNClsFound() >= 50 && track.flags() & o2::aod::track::ITSrefit && track.flags() & o2::aod::track::TPCrefit && (TESTBIT(itsClusterMap, 0) || TESTBIT(itsClusterMap, 1)))) {
83+
int minTpcNClsFound{50};
84+
if (!(track.tpcNClsFound() >= minTpcNClsFound && track.flags() & o2::aod::track::ITSrefit && track.flags() & o2::aod::track::TPCrefit && (TESTBIT(itsClusterMap, 0) || TESTBIT(itsClusterMap, 1)))) {
8485
hasGoodQuality = false;
8586
}
8687
break;
@@ -127,7 +128,7 @@ class CollisionAssociation
127128
TTracksUnfiltered const& tracksUnfiltered,
128129
TTracks const& tracks,
129130
TAmbiTracks const& ambiguousTracks,
130-
o2::aod::BCs const&,
131+
o2::aod::BCs const& bcs,
131132
Assoc& association,
132133
RevIndices& reverseIndices)
133134
{
@@ -151,6 +152,11 @@ class CollisionAssociation
151152
for (const auto& ambTrack : ambiguousTracks) {
152153
if constexpr (isCentralBarrel) { // FIXME: to be removed as soon as it is possible to use getId<Table>() for joined tables
153154
if (ambTrack.trackId() == track.globalIndex()) {
155+
// special check to avoid crashes (in particular on some MC datasets)
156+
// related to shifts in ambiguous tracks association to bc slices (off by 1) - see https://mattermost.web.cern.ch/alice/pl/g9yaaf3tn3g4pgn7c1yex9copy
157+
if (ambTrack.bcIds()[0] >= bcs.size() || ambTrack.bcIds()[1] >= bcs.size()) {
158+
break;
159+
}
154160
if (!ambTrack.has_bc() || ambTrack.bc().size() == 0) {
155161
break;
156162
}
@@ -194,7 +200,7 @@ class CollisionAssociation
194200
uint64_t collBC = collision.bc().globalBC();
195201

196202
// This is done per block to allow optimization below. Within each block the globalBC increase continously
197-
for (auto& iterationWindow : trackIterationWindows) {
203+
for (auto& iterationWindow : trackIterationWindows) { // o2-linter: disable=const-ref-in-for-loop (iterationWindow is modified)
198204
bool iteratorMoved = false;
199205
const bool isAssignedTrackWindow = (iterationWindow.first != iterationWindow.second) ? iterationWindow.first.has_collision() : false;
200206
for (auto trackInWindow = iterationWindow.first; trackInWindow != iterationWindow.second; ++trackInWindow) {

Common/Core/FFitWeights.cxx

Lines changed: 106 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@
1616

1717
#include "FFitWeights.h"
1818

19+
#include "Framework/Logger.h"
20+
1921
#include <TCollection.h>
2022
#include <TH1.h>
21-
#include <TH2.h>
2223
#include <TNamed.h>
2324
#include <TObjArray.h>
2425
#include <TSpline.h>
@@ -35,25 +36,35 @@ ClassImp(FFitWeights)
3536

3637
FFitWeights::FFitWeights() : TNamed("", ""),
3738
fW_data{nullptr},
38-
CentBin{100},
39+
ptProfCent{nullptr},
40+
h2ptCent{nullptr},
41+
centBin{100},
3942
qAxis{nullptr},
4043
nResolution{3000},
44+
ptBin{100},
45+
ptAxis{nullptr},
4146
qnTYPE{0}
4247
{
4348
}
4449

4550
FFitWeights::FFitWeights(const char* name) : TNamed(name, name),
4651
fW_data{nullptr},
47-
CentBin{100},
52+
ptProfCent{nullptr},
53+
h2ptCent{nullptr},
54+
centBin{100},
4855
qAxis{nullptr},
4956
nResolution{3000},
57+
ptBin{100},
58+
ptAxis{nullptr},
5059
qnTYPE{0} {}
5160

5261
FFitWeights::~FFitWeights()
5362
{
5463
delete fW_data;
5564
if (qAxis)
5665
delete qAxis;
66+
if (ptAxis)
67+
delete ptAxis;
5768
};
5869

5970
void FFitWeights::init()
@@ -65,8 +76,16 @@ void FFitWeights::init()
6576
if (!qAxis)
6677
this->setBinAxis(500, 0, 25);
6778
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()));
79+
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()));
6980
}
81+
82+
if (!ptAxis)
83+
this->setPtAxis(3000, -3, 3);
84+
fW_data->Add(new TProfile("pMeanPt", "", centBin, 0, centBin));
85+
fW_data->Add(new TH2D("hPtWeight", "", centBin, 0, centBin, ptBin, ptAxis->GetXmin(), ptAxis->GetXmax()));
86+
87+
ptProfCent = reinterpret_cast<TProfile*>(fW_data->FindObject("pMeanPt"));
88+
h2ptCent = reinterpret_cast<TH2D*>(fW_data->FindObject("hPtWeight"));
7089
};
7190

7291
void FFitWeights::fillWeights(float centrality, float qn, int nh, const char* pf)
@@ -79,12 +98,28 @@ void FFitWeights::fillWeights(float centrality, float qn, int nh, const char* pf
7998

8099
TH2D* th2 = reinterpret_cast<TH2D*>(tar->FindObject(this->getQName(nh, pf)));
81100
if (!th2) {
82-
tar->Add(new TH2D(this->getQName(nh, pf), this->getAxisName(nh, pf), CentBin, 0, CentBin, qAxis->GetNbins(), qAxis->GetXmin(), qAxis->GetXmax()));
101+
tar->Add(new TH2D(this->getQName(nh, pf), this->getAxisName(nh, pf), centBin, 0, centBin, qAxis->GetNbins(), qAxis->GetXmin(), qAxis->GetXmax()));
83102
th2 = reinterpret_cast<TH2D*>(tar->At(tar->GetEntries() - 1));
84103
}
85104
th2->Fill(centrality, qn);
86105
};
87106

107+
void FFitWeights::fillPt(float centrality, float pt, bool first)
108+
{
109+
if (first) {
110+
ptProfCent->Fill(centrality, pt);
111+
} else {
112+
h2ptCent->Fill(centrality, pt);
113+
}
114+
};
115+
float FFitWeights::getPtMult(float centrality)
116+
{
117+
if (!ptProfCent) {
118+
ptProfCent = reinterpret_cast<TProfile*>(fW_data->FindObject("pMeanPt"));
119+
}
120+
return ptProfCent->GetBinContent(ptProfCent->FindBin(centrality));
121+
};
122+
88123
Long64_t FFitWeights::Merge(TCollection* collist)
89124
{
90125
Long64_t nmerged = 0;
@@ -93,32 +128,63 @@ Long64_t FFitWeights::Merge(TCollection* collist)
93128
fW_data->SetName("FFitWeights_Data");
94129
fW_data->SetOwner(kTRUE);
95130
}
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());
131+
FFitWeights* lW = 0;
132+
TIter allW(collist);
133+
while ((lW = (reinterpret_cast<FFitWeights*>(allW())))) {
134+
addArray(fW_data, lW->getDataArray());
100135
nmerged++;
101136
}
102137
return nmerged;
103138
};
104139
void FFitWeights::addArray(TObjArray* targ, TObjArray* sour)
105140
{
106-
if (!sour) {
107-
printf("Source array does not exist!\n");
141+
if (!sour)
108142
return;
109-
}
143+
110144
for (int i = 0; i < sour->GetEntries(); i++) {
111-
TH2D* sourh = reinterpret_cast<TH2D*>(sour->At(i));
112-
TH2D* targh = reinterpret_cast<TH2D*>(targ->FindObject(sourh->GetName()));
113-
if (!targh) {
114-
targh = reinterpret_cast<TH2D*>(sourh->Clone(sourh->GetName()));
115-
targh->SetDirectory(0);
116-
targ->Add(targh);
117-
} else {
118-
targh->Add(sourh);
145+
auto* obj = sour->At(i);
146+
if (!obj)
147+
continue;
148+
149+
auto* tObj = targ->FindObject(obj->GetName());
150+
if (!tObj) {
151+
auto* clone = static_cast<TObject*>(obj->Clone(obj->GetName()));
152+
if (auto* h = dynamic_cast<TH1*>(clone))
153+
h->SetDirectory(0);
154+
targ->Add(clone);
155+
} else if (auto* h1 = dynamic_cast<TH1*>(tObj)) {
156+
if (auto* h2 = dynamic_cast<TH1*>(obj))
157+
h1->Add(h2);
119158
}
120159
}
121-
};
160+
}
161+
162+
void FFitWeights::mptSel()
163+
{
164+
TObjArray* tar{nullptr};
165+
tar = fW_data;
166+
if (!tar)
167+
return;
168+
169+
TH2D* th2 = reinterpret_cast<TH2D*>(tar->FindObject("hPtWeight"));
170+
if (!th2) {
171+
return;
172+
}
173+
174+
TH1D* tmp{nullptr};
175+
TGraph* tmpgr{nullptr};
176+
for (int iSP{0}; iSP < NumberSp; iSP++) {
177+
tmp = th2->ProjectionY(Form("mpt_%i_%i", iSP, iSP + 1), iSP + 1, iSP + 1);
178+
std::vector<double> xq(nResolution);
179+
std::vector<double> yq(nResolution);
180+
for (int i{0}; i < nResolution; i++)
181+
xq[i] = static_cast<double>(i + 1) / static_cast<double>(nResolution);
182+
tmp->GetQuantiles(nResolution, yq.data(), xq.data());
183+
tmpgr = new TGraph(nResolution, yq.data(), xq.data());
184+
tmpgr->SetName(Form("sp_mpt_%i", iSP));
185+
fW_data->Add(tmpgr);
186+
}
187+
}
122188

123189
void FFitWeights::qSelection(const std::vector<int>& nhv, const std::vector<std::string>& stv) /* only execute OFFLINE */
124190
{
@@ -132,14 +198,14 @@ void FFitWeights::qSelection(const std::vector<int>& nhv, const std::vector<std:
132198
for (const auto& nh : nhv) {
133199
TH2D* th2{reinterpret_cast<TH2D*>(tar->FindObject(this->getQName(nh, pf.c_str())))};
134200
if (!th2) {
135-
printf("qh not found!\n");
201+
LOGF(info, "FFitWeights qh not found!");
136202
return;
137203
}
138204

139205
TH1D* tmp{nullptr};
140206
TGraph* tmpgr{nullptr};
141207
// TSpline3* spline = nullptr;
142-
for (int iSP{0}; iSP < 90; iSP++) {
208+
for (int iSP{0}; iSP < NumberSp; iSP++) {
143209
tmp = th2->ProjectionY(Form("q%i_%i_%i", nh, iSP, iSP + 1), iSP + 1, iSP + 1);
144210
std::vector<double> xq(nResolution);
145211
std::vector<double> yq(nResolution);
@@ -148,37 +214,36 @@ void FFitWeights::qSelection(const std::vector<int>& nhv, const std::vector<std:
148214
tmp->GetQuantiles(nResolution, yq.data(), xq.data());
149215
tmpgr = new TGraph(nResolution, yq.data(), xq.data());
150216
tmpgr->SetName(Form("sp_q%i%s_%i", nh, pf.c_str(), iSP));
151-
// spline = new TSpline3(Form("sp_q%i%s_%i", nh, pf.c_str(), iSP), tmpgr);
152-
// spline->SetName(Form("sp_q%i%s_%i", nh, pf.c_str(), iSP));
153217
fW_data->Add(tmpgr);
154218
}
155219
}
156220
}
157221
};
158-
159-
float FFitWeights::eval(float centr, const float& dqn, const int nh, const char* pf)
222+
float FFitWeights::internalEval(float centr, const float& val, const char* name)
160223
{
161-
TObjArray* tar{nullptr};
162-
163-
tar = fW_data;
164-
if (!tar)
224+
if (!fW_data) {
165225
return -1;
166-
167-
int isp{static_cast<int>(centr)};
168-
if (isp < 0 || isp > 90) {
226+
}
227+
int isp = static_cast<int>(centr);
228+
if (isp < 0 || isp > NumberSp) {
169229
return -1;
170230
}
171231

172-
TGraph* spline{nullptr};
173-
spline = reinterpret_cast<TGraph*>(tar->FindObject(Form("sp_q%i%s_%i", nh, pf, isp)));
232+
auto* spline = dynamic_cast<TGraph*>(fW_data->FindObject(Form(name, isp)));
174233
if (!spline) {
175234
return -1;
176235
}
177236

178-
float qn_val{static_cast<float>(100. * spline->Eval(dqn))};
179-
if (qn_val < 0 || qn_val > 100.05) {
180-
return -1;
181-
}
237+
float perc = 100.f * spline->Eval(val);
238+
return (perc < 0 || perc > MaxTol) ? -1 : perc;
239+
};
182240

183-
return qn_val;
241+
float FFitWeights::eval(float centr, const float& dqn, int nh, const char* pf)
242+
{
243+
return internalEval(centr, dqn, Form("sp_q%i%s_%%i", nh, pf));
244+
};
245+
246+
float FFitWeights::evalPt(float centr, const float& mpt)
247+
{
248+
return internalEval(centr, mpt, "sp_mpt_%i");
184249
};

Common/Core/FFitWeights.h

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@
1919

2020
#include <TAxis.h>
2121
#include <TCollection.h>
22+
#include <TH2.h>
2223
#include <TNamed.h>
2324
#include <TObjArray.h>
25+
#include <TProfile.h>
2426
#include <TString.h>
2527

2628
#include <Rtypes.h>
@@ -39,28 +41,44 @@ class FFitWeights : public TNamed
3941

4042
void init();
4143
void fillWeights(float centrality, float qn, int nh, const char* pf = "");
44+
void fillPt(float centrality, float pt, bool first);
45+
float getPtMult(float centrality);
4246
TObjArray* getDataArray() { return fW_data; }
4347

44-
void setCentBin(int bin) { CentBin = bin; }
48+
void setCentBin(int bin) { centBin = bin; }
4549
void setBinAxis(int bin, float min, float max)
4650
{
4751
qAxis = new TAxis(bin, min, max);
4852
}
4953
TAxis* getqVecAx() { return qAxis; }
5054

55+
void setPtBin(int bin) { ptBin = bin; }
56+
void setPtAxis(int bin, float min, float max)
57+
{
58+
ptAxis = new TAxis(bin, min, max);
59+
}
60+
TAxis* getPtAx() { return ptAxis; }
61+
5162
Long64_t Merge(TCollection* collist);
5263
void qSelection(const std::vector<int>& nhv, const std::vector<std::string>& stv);
5364
float eval(float centr, const float& dqn, const int nh, const char* pf = "");
65+
float evalPt(float centr, const float& mpt);
5466
void setResolution(int res) { nResolution = res; }
5567
int getResolution() const { return nResolution; }
5668
void setQnType(const std::vector<std::pair<int, std::string>>& qninp) { qnTYPE = qninp; }
5769

70+
void mptSel();
71+
5872
private:
5973
TObjArray* fW_data;
74+
TProfile* ptProfCent; //!
75+
TH2D* h2ptCent; //!
6076

61-
int CentBin;
77+
int centBin;
6278
TAxis* qAxis; //!
6379
int nResolution;
80+
int ptBin;
81+
TAxis* ptAxis; //!
6482

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

@@ -74,6 +92,11 @@ class FFitWeights : public TNamed
7492
};
7593
void addArray(TObjArray* targ, TObjArray* sour);
7694

95+
static constexpr int NumberSp = 90;
96+
static constexpr float MaxTol = 100.05;
97+
98+
float internalEval(float centr, const float& val, const char* name);
99+
77100
ClassDef(FFitWeights, 1); // calibration class
78101
};
79102
#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+
} // namespace meanptshape
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)