Skip to content

Commit a9ce428

Browse files
Merge branch 'AliceO2Group:master' into master
2 parents 2ae5ea2 + 3216d7f commit a9ce428

89 files changed

Lines changed: 1571 additions & 408 deletions

File tree

Some content is hidden

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

ALICE3/Tasks/alice3-cdeuteron.cxx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ struct Alice3CDeuteron {
176176
const o2::aod::McCollisions& Mccoll,
177177
const soa::Join<o2::aod::Tracks, o2::aod::McTrackLabels, o2::aod::TracksExtra, o2::aod::TracksCov,
178178
aod::pidTOFFullPi, aod::pidTOFFullKa, aod::pidTOFFullDe>& tracks,
179-
const aod::McParticles& mcParticles)
179+
const aod::McParticles_000& mcParticles)
180180
{
181181
const auto particlesInCollision = mcParticles.sliceBy(aod::mcparticle::mcCollisionId, coll.mcCollision().globalIndex());
182182
for (const auto& i : particlesInCollision) {
@@ -206,11 +206,11 @@ struct Alice3CDeuteron {
206206
// }
207207
int ntrks = 0;
208208
for (const auto& t : tracks) {
209-
if (t.mcParticle().pdgCode() == 1000010020) {
209+
if (t.mcParticle_as<aod::McParticles_000>().pdgCode() == 1000010020) {
210210
histos.fill(HIST("event/trackspdg"), 1);
211-
} else if (t.mcParticle().pdgCode() == -321) {
211+
} else if (t.mcParticle_as<aod::McParticles_000>().pdgCode() == -321) {
212212
histos.fill(HIST("event/trackspdg"), 2);
213-
} else if (t.mcParticle().pdgCode() == 211) {
213+
} else if (t.mcParticle_as<aod::McParticles_000>().pdgCode() == 211) {
214214
histos.fill(HIST("event/trackspdg"), 3);
215215
} else {
216216
histos.fill(HIST("event/trackspdg"), 4);
@@ -227,7 +227,7 @@ struct Alice3CDeuteron {
227227
int ncand = 0;
228228
histos.fill(HIST("event/nsigmaDe"), track1.pt(), track1.tofNSigmaDe());
229229
if (usePdg) {
230-
if (track1.mcParticle().pdgCode() != 1000010020) {
230+
if (track1.mcParticle_as<aod::McParticles_000>().pdgCode() != 1000010020) {
231231
continue;
232232
}
233233
} else if (abs(track1.tofNSigmaDe()) > maxNsigmaDe || track1.sign() < 0.f) {
@@ -248,7 +248,7 @@ struct Alice3CDeuteron {
248248
}
249249
histos.fill(HIST("event/nsigmaKa"), track2.pt(), track2.tofNSigmaKa());
250250
if (usePdg) {
251-
if (track2.mcParticle().pdgCode() != -321) {
251+
if (track2.mcParticle_as<aod::McParticles_000>().pdgCode() != -321) {
252252
continue;
253253
}
254254
} else if (abs(track2.tofNSigmaKa()) > maxNsigmaKa || track2.sign() > 0.f) {
@@ -271,7 +271,7 @@ struct Alice3CDeuteron {
271271
}
272272
histos.fill(HIST("event/nsigmaPi"), track3.pt(), track3.tofNSigmaPi());
273273
if (usePdg) {
274-
if (track3.mcParticle().pdgCode() != 211) {
274+
if (track3.mcParticle_as<aod::McParticles_000>().pdgCode() != 211) {
275275
continue;
276276
}
277277
} else if (abs(track3.tofNSigmaPi()) > maxNsigmaPi || track3.sign() < 0.f) {
@@ -316,9 +316,9 @@ struct Alice3CDeuteron {
316316
iscut = true;
317317
}
318318

319-
const auto mother1 = track1.mcParticle().mother0_as<aod::McParticles>();
320-
const auto mother2 = track2.mcParticle().mother0_as<aod::McParticles>();
321-
const auto mother3 = track3.mcParticle().mother0_as<aod::McParticles>();
319+
const auto mother1 = track1.mcParticle_as<aod::McParticles_000>().mother0_as<aod::McParticles_000>();
320+
const auto mother2 = track2.mcParticle_as<aod::McParticles_000>().mother0_as<aod::McParticles_000>();
321+
const auto mother3 = track3.mcParticle_as<aod::McParticles_000>().mother0_as<aod::McParticles_000>();
322322
bool issig = true;
323323
if (mother1 != mother2) {
324324
issig = false;
@@ -382,8 +382,8 @@ struct Alice3CDeuteron {
382382
const float vz = mother1.vz();
383383
const float rmc = sqrt((secVtx[0] - vx) * (secVtx[0] - vx) + (secVtx[1] - vy) * (secVtx[1] - vy) + (secVtx[2] - vz) * (secVtx[2] - vz));
384384
ncand++;
385-
const float radius3xy = sqrt((track3.mcParticle().vx() - coll.mcCollision().posX()) * (track3.mcParticle().vx() - coll.mcCollision().posX()) +
386-
(track3.mcParticle().vy() - coll.mcCollision().posY()) * (track3.mcParticle().vy() - coll.mcCollision().posY()));
385+
const float radius3xy = sqrt((track3.mcParticle_as<aod::McParticles_000>().vx() - coll.mcCollision().posX()) * (track3.mcParticle_as<aod::McParticles_000>().vx() - coll.mcCollision().posX()) +
386+
(track3.mcParticle_as<aod::McParticles_000>().vy() - coll.mcCollision().posY()) * (track3.mcParticle_as<aod::McParticles_000>().vy() - coll.mcCollision().posY()));
387387

388388
#define FillHistos(tag) \
389389
histos.fill(HIST(tag "/cpa"), CPA); \

ALICE3/Tasks/alice3-lutmaker.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ struct Alice3LutMaker {
185185
histos.add("QA/CovMat_c1Pt21Pt2", "c1Pt21Pt2" + commonTitle, kTH3F, {axisPt, axisEta, axisc1Pt21Pt2});
186186
}
187187

188-
void process(const o2::aod::McParticles& mcParticles,
188+
void process(const o2::aod::McParticles_000& mcParticles,
189189
const o2::soa::Join<o2::aod::Collisions, o2::aod::McCollisionLabels>&,
190190
const o2::soa::Join<o2::aod::Tracks, o2::aod::TracksCov, o2::aod::McTrackLabels>& tracks,
191191
const o2::aod::McCollisions&)
@@ -194,7 +194,7 @@ struct Alice3LutMaker {
194194
int ntrks = 0;
195195

196196
for (const auto& track : tracks) {
197-
const auto mcParticle = track.mcParticle();
197+
const auto mcParticle = track.mcParticle_as<aod::McParticles_000>();
198198
if (mcParticle.pdgCode() != pdg) {
199199
continue;
200200
}

ALICE3/Tasks/alice3-qa-singleparticle.cxx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ struct Alice3SingleParticle {
9999

100100
void process(const o2::aod::McCollisions& colls,
101101
const soa::Join<o2::aod::Tracks, o2::aod::McTrackLabels, o2::aod::TracksExtra>& tracks,
102-
const aod::McParticles& mcParticles)
102+
const aod::McParticles_000& mcParticles)
103103
{
104104
for (const auto& col : colls) {
105105
histos.fill(HIST("event/VtxX"), col.posX());
@@ -130,10 +130,10 @@ struct Alice3SingleParticle {
130130
histos.fill(HIST("particle/prodVy"), mcParticle.vy());
131131
histos.fill(HIST("particle/prodVz"), mcParticle.vz());
132132
if (!IsStable && mcParticle.has_daughter0()) {
133-
histos.get<TH1>(HIST("particle/daughters/PDGs"))->Fill(Form("%i", mcParticle.daughter0_as<aod::McParticles>().pdgCode()), 1.f);
134-
histos.fill(HIST("particle/daughters/prodVx"), mcParticle.daughter0_as<aod::McParticles>().vx());
135-
histos.fill(HIST("particle/daughters/prodVy"), mcParticle.daughter0_as<aod::McParticles>().vy());
136-
histos.fill(HIST("particle/daughters/prodVz"), mcParticle.daughter0_as<aod::McParticles>().vz());
133+
histos.get<TH1>(HIST("particle/daughters/PDGs"))->Fill(Form("%i", mcParticle.daughter0_as<aod::McParticles_000>().pdgCode()), 1.f);
134+
histos.fill(HIST("particle/daughters/prodVx"), mcParticle.daughter0_as<aod::McParticles_000>().vx());
135+
histos.fill(HIST("particle/daughters/prodVy"), mcParticle.daughter0_as<aod::McParticles_000>().vy());
136+
histos.fill(HIST("particle/daughters/prodVz"), mcParticle.daughter0_as<aod::McParticles_000>().vz());
137137
}
138138

139139
histos.fill(HIST("particle/prodRadius"), std::sqrt(mcParticle.vx() * mcParticle.vx() + mcParticle.vy() * mcParticle.vy()));
@@ -146,7 +146,7 @@ struct Alice3SingleParticle {
146146
}
147147

148148
for (const auto& track : tracks) {
149-
const auto mcParticle = track.mcParticle();
149+
const auto mcParticle = track.mcParticle_as<aod::McParticles_000>();
150150
histos.get<TH1>(HIST("track/PDGs"))->Fill(Form("%i", mcParticle.pdgCode()), 1.f);
151151
if (track.hasTOF()) {
152152
histos.get<TH1>(HIST("track/tofPDGs"))->Fill(Form("%i", mcParticle.pdgCode()), 1.f);
@@ -155,7 +155,7 @@ struct Alice3SingleParticle {
155155
if (!mcParticle.has_mother0()) {
156156
continue;
157157
}
158-
auto mother = mcParticle.mother0_as<aod::McParticles>();
158+
auto mother = mcParticle.mother0_as<aod::McParticles_000>();
159159
const auto ParticleIsInteresting = std::find(ParticlesOfInterest.begin(), ParticlesOfInterest.end(), mother.globalIndex()) != ParticlesOfInterest.end();
160160
if (!ParticleIsInteresting) {
161161
continue;
@@ -175,7 +175,7 @@ struct Alice3SingleParticle {
175175
}
176176
continue;
177177
}
178-
auto mother = mcParticle.mother0_as<aod::McParticles>();
178+
auto mother = mcParticle.mother0_as<aod::McParticles_000>();
179179
if (mcParticle.isPhysicalPrimary()) {
180180
histos.get<TH1>(HIST("track/primaries"))->Fill(Form("%i", mother.pdgCode()), 1.f);
181181
} else {

ALICE3/Tasks/pidFTOFqa.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ struct ftofPidQaMC {
9696
void process(const Trks& tracks,
9797
const aod::McTrackLabels& labels,
9898
const aod::FTOFs&,
99-
const aod::McParticles& mcParticles,
99+
const aod::McParticles_000& mcParticles,
100100
const aod::Collisions& colls)
101101
{
102102
for (const auto& col : colls) {
@@ -117,7 +117,7 @@ struct ftofPidQaMC {
117117
if (track.eta() > maxEta || track.eta() < minEta) {
118118
continue;
119119
}
120-
const auto mcParticle = labels.iteratorAt(track.globalIndex()).mcParticle();
120+
const auto mcParticle = labels.iteratorAt(track.globalIndex()).mcParticle_as<aod::McParticles_000>();
121121
if (pdgCode != 0 && abs(mcParticle.pdgCode()) != pdgCode) {
122122
continue;
123123
}

ALICE3/Tasks/pidRICHqa.cxx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ struct richPidQaMc {
245245
aod::pidTOFFullKa, aod::pidTOFFullPr, aod::McTrackLabels>;
246246
using TrksfRICH = soa::Join<aod::Tracks, aod::FRICHTracksIndex, aod::TracksExtra, aod::McTrackLabels>;
247247
void process(const Trks& tracks,
248-
const aod::McParticles& mcParticles,
248+
const aod::McParticles_000& mcParticles,
249249
const TrksfRICH& tracksfrich,
250250
const aod::RICHs&,
251251
const aod::FRICHs&,
@@ -287,7 +287,7 @@ struct richPidQaMc {
287287
return true;
288288
}
289289
histos.fill(h, 7);
290-
const auto mcParticle = t.mcParticle();
290+
const auto mcParticle = t.template mcParticle_as<aod::McParticles_000>();
291291
if (pdgCode != 0 && abs(mcParticle.pdgCode()) != pdgCode) {
292292
return true;
293293
}
@@ -335,8 +335,8 @@ struct richPidQaMc {
335335

336336
histos.fill(HIST(hbRICHNSigma[pid_type]), track.pt(), nsigma);
337337
histos.fill(HIST(hbRICHDelta[pid_type]), track.p(), delta);
338-
// const auto mcParticle = labels.iteratorAt(track.globalIndex()).mcParticle();
339-
const auto mcParticle = track.mcParticle();
338+
// const auto mcParticle = labels.iteratorAt(track.globalIndex()).mcParticle_as<aod::McParticles_000>();
339+
const auto mcParticle = track.mcParticle_as<aod::McParticles_000>();
340340
if (mcParticle.isPhysicalPrimary()) { // Selecting primaries
341341
histos.fill(HIST(hbRICHNSigmaPrm[pid_type]), track.pt(), nsigma);
342342
histos.fill(HIST("bRICH/signalvsPPrm"), track.p(), track.rich().richSignal());
@@ -377,7 +377,7 @@ struct richPidQaMc {
377377

378378
histos.fill(HIST(hfRICHNSigma[pid_type]), track.pt(), nsigma);
379379
histos.fill(HIST(hfRICHDelta[pid_type]), track.p(), delta);
380-
const auto mcParticle = track.mcParticle();
380+
const auto mcParticle = track.mcParticle_as<aod::McParticles_000>();
381381
if (mcParticle.isPhysicalPrimary()) { // Selecting primaries
382382
histos.fill(HIST(hfRICHNSigmaPrm[pid_type]), track.pt(), nsigma);
383383
histos.fill(HIST("fRICH/signalvsPPrm"), track.p(), track.frich().frichSignal());

Common/Core/RecoDecay.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "Framework/Logger.h"
3030

3131
using std::array;
32+
using namespace o2;
3233
using namespace o2::constants::math;
3334

3435
/// Base class for calculating properties of reconstructed decays
@@ -727,7 +728,7 @@ class RecoDecay
727728
if (!arrDaughters[iProng].has_mcParticle()) {
728729
return -1;
729730
}
730-
auto particleI = arrDaughters[iProng].mcParticle(); // ith daughter particle
731+
auto particleI = arrDaughters[iProng].template mcParticle_as<aod::McParticles_000>(); // ith daughter particle
731732
arrDaughtersIndex[iProng] = particleI.globalIndex();
732733
// Get the list of daughter indices from the mother of the first prong.
733734
if (iProng == 0) {

Common/Core/aodMerger.cxx

Lines changed: 79 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,44 @@
2424
#include <TMap.h>
2525
#include <TLeaf.h>
2626

27+
const char* removeVersionSuffix(const char* treeName)
28+
{
29+
// remove version suffix, e.g. O2v0_001 becomes O2v0
30+
static TString tmp;
31+
tmp = treeName;
32+
if (tmp.First("_") >= 0) {
33+
tmp.Remove(tmp.First("_"));
34+
}
35+
return tmp;
36+
}
37+
38+
const char* getTableName(const char* branchName, const char* treeName)
39+
{
40+
// Syntax for branchName:
41+
// fIndex<Table>[_<Suffix>]
42+
// fIndexArray<Table>[_<Suffix>]
43+
// fIndexSlice<Table>[_<Suffix>]
44+
// if <Table> is empty it is a self index and treeName is used as table name
45+
static TString tableName;
46+
tableName = branchName;
47+
if (tableName.BeginsWith("fIndexArray") || tableName.BeginsWith("fIndexSlice")) {
48+
tableName.Remove(0, 11);
49+
} else {
50+
tableName.Remove(0, 6);
51+
}
52+
if (tableName.First("_") >= 0) {
53+
tableName.Remove(tableName.First("_"));
54+
}
55+
if (tableName.Length() == 0) {
56+
return removeVersionSuffix(treeName);
57+
}
58+
tableName.Remove(tableName.Length() - 1); // remove s
59+
tableName.ToLower();
60+
tableName = "O2" + tableName;
61+
// printf("%s --> %s\n", branchName, tableName.Data());
62+
return tableName;
63+
}
64+
2765
// AOD merger with correct index rewriting
2866
// No need to know the datamodel because the branch names follow a canonical standard (identified by fIndex)
2967
int main(int argc, char* argv[])
@@ -191,6 +229,7 @@ int main(int argc, char* argv[])
191229
// register index and connect VLA columns
192230
std::vector<std::pair<int*, int>> indexList;
193231
std::vector<char*> vlaPointers;
232+
std::vector<int*> indexPointers;
194233
TObjArray* branches = inputTree->GetListOfBranches();
195234
for (int i = 0; i < branches->GetEntriesFast(); ++i) {
196235
TBranch* br = (TBranch*)branches->UncheckedAt(i);
@@ -199,27 +238,41 @@ int main(int argc, char* argv[])
199238
// detect VLA
200239
if (((TLeaf*)br->GetListOfLeaves()->First())->GetLeafCount() != nullptr) {
201240
int maximum = ((TLeaf*)br->GetListOfLeaves()->First())->GetLeafCount()->GetMaximum();
202-
char* buffer = new char[maximum * 8]; // assume 64 bit as largest case
203-
printf(" Allocated VLA buffer of size %d for branch name %s\n", maximum, br->GetName());
241+
242+
// get type
243+
static TClass* cls;
244+
EDataType type;
245+
br->GetExpectedType(cls, type);
246+
auto typeSize = TDataType::GetDataType(type)->Size();
247+
248+
char* buffer = new char[maximum * typeSize];
249+
vlaPointers.push_back(buffer);
250+
printf(" Allocated VLA buffer of length %d with %d bytes each for branch name %s\n", maximum, typeSize, br->GetName());
204251
inputTree->SetBranchAddress(br->GetName(), buffer);
205252
outputTree->SetBranchAddress(br->GetName(), buffer);
206-
vlaPointers.push_back(buffer);
207-
}
208253

209-
if (branchName.BeginsWith("fIndex")) {
210-
// Syntax: fIndex<Table>[_<Suffix>]
211-
branchName.Remove(0, 6);
212-
if (branchName.First("_") > 0) {
213-
branchName.Remove(branchName.First("_"));
254+
if (branchName.BeginsWith("fIndexArray")) {
255+
for (int i = 0; i < maximum; i++) {
256+
indexList.push_back({reinterpret_cast<int*>(buffer + i * typeSize), offsets[getTableName(branchName, treeName)]});
257+
}
214258
}
215-
branchName.Remove(branchName.Length() - 1); // remove s
216-
branchName.ToLower();
217-
branchName = "O2" + branchName;
259+
} else if (branchName.BeginsWith("fIndexSlice")) {
260+
int* buffer = new int[2];
261+
vlaPointers.push_back(reinterpret_cast<char*>(buffer));
262+
263+
inputTree->SetBranchAddress(br->GetName(), buffer);
264+
outputTree->SetBranchAddress(br->GetName(), buffer);
218265

219-
indexList.push_back({new int, offsets[branchName.Data()]});
266+
indexList.push_back({buffer, offsets[getTableName(branchName, treeName)]});
267+
indexList.push_back({buffer + 1, offsets[getTableName(branchName, treeName)]});
268+
} else if (branchName.BeginsWith("fIndex") && !branchName.EndsWith("_size")) {
269+
int* buffer = new int;
270+
indexPointers.push_back(buffer);
220271

221-
inputTree->SetBranchAddress(br->GetName(), indexList.back().first);
222-
outputTree->SetBranchAddress(br->GetName(), indexList.back().first);
272+
inputTree->SetBranchAddress(br->GetName(), buffer);
273+
outputTree->SetBranchAddress(br->GetName(), buffer);
274+
275+
indexList.push_back({buffer, offsets[getTableName(branchName, treeName)]});
223276
}
224277
}
225278

@@ -266,8 +319,8 @@ int main(int argc, char* argv[])
266319

267320
delete inputTree;
268321

269-
for (const auto& idx : indexList) {
270-
delete idx.first;
322+
for (auto& buffer : indexPointers) {
323+
delete[] buffer;
271324
}
272325
for (auto& buffer : vlaPointers) {
273326
delete[] buffer;
@@ -289,15 +342,21 @@ int main(int argc, char* argv[])
289342
}
290343
}
291344

345+
// set to -1 to identify not found tables
346+
for (auto& offset : offsets) {
347+
offset.second = -1;
348+
}
349+
292350
// update offsets
293351
for (auto const& tree : trees) {
294-
offsets[tree.first] = tree.second->GetEntries();
352+
offsets[removeVersionSuffix(tree.first.c_str())] = tree.second->GetEntries();
295353
}
296354

297355
// check for not found tables
298-
for (auto const& offset : offsets) {
299-
if (trees.count(offset.first) == 0) {
356+
for (auto& offset : offsets) {
357+
if (offset.second < 0) {
300358
printf("ERROR: Index on %s but no tree found\n", offset.first.c_str());
359+
offset.second = 0;
301360
}
302361
}
303362

Common/TableProducer/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,9 @@ o2physics_add_dpl_workflow(ft0-corrected-table
5858
o2physics_add_dpl_workflow(track-propagation
5959
SOURCES trackPropagation.cxx
6060
PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2Physics::AnalysisCore O2::ReconstructionDataFormats O2::DetectorsCommonDataFormats
61-
COMPONENT_NAME Analysis)
61+
COMPONENT_NAME Analysis)
62+
63+
o2physics_add_dpl_workflow(mc-converter
64+
SOURCES mcConverter.cxx
65+
PUBLIC_LINK_LIBRARIES O2::Framework
66+
COMPONENT_NAME Analysis)

0 commit comments

Comments
 (0)