Skip to content

Commit fc7b48c

Browse files
authored
[PWGCF] FemtoUniverse: Changing fillCollisions() to bool (AliceO2Group#8856)
1 parent c231493 commit fc7b48c

File tree

1 file changed

+73
-50
lines changed

1 file changed

+73
-50
lines changed

PWGCF/FemtoUniverse/TableProducer/femtoUniverseProducerTask.cxx

Lines changed: 73 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ struct femtoUniverseProducerTask {
123123
Configurable<bool> ConfIsForceGRP{"ConfIsForceGRP", false, "Set true if the magnetic field configuration is not available in the usual CCDB directory (e.g. for Run 2 converted data or unanchorad Monte Carlo)"};
124124

125125
Configurable<bool> ConfDoSpher{"ConfDoSpher", false, "Calculate sphericity. If false sphericity will take value of 2."};
126+
Configurable<bool> ConfFillCollExt{"ConfFillCollExt", false, "Option to fill collision extended table"};
126127

127128
/// Event cuts
128129
FemtoUniverseCollisionSelection colCuts;
@@ -722,8 +723,8 @@ struct femtoUniverseProducerTask {
722723

723724
if (std::abs(pdgCode1) == std::abs(321) || std::abs(pdgCode2) == std::abs(-321)) {
724725
if ((kaon1MC.isPhysicalPrimary() && kaon2MC.isPhysicalPrimary()) && (!motherskaon1MC.empty() && !motherskaon2MC.empty())) {
725-
for (auto& particleMotherOfNeg : motherskaon1MC) {
726-
for (auto& particleMotherOfPos : motherskaon2MC) {
726+
for (const auto& particleMotherOfNeg : motherskaon1MC) {
727+
for (const auto& particleMotherOfPos : motherskaon2MC) {
727728
if (particleMotherOfNeg == particleMotherOfPos && particleMotherOfNeg.pdgCode() == 333) {
728729
phiOrigin = aod::femtouniverseMCparticle::ParticleOriginMCTruth::kPrimary;
729730
} else {
@@ -762,7 +763,7 @@ struct femtoUniverseProducerTask {
762763
}
763764

764765
template <bool isMC, typename CollisionType, typename TrackType>
765-
void fillCollisions(CollisionType const& col, TrackType const& tracks)
766+
bool fillCollisions(CollisionType const& col, TrackType const& tracks)
766767
{
767768
const auto vtxZ = col.posZ();
768769
float mult = 0;
@@ -785,28 +786,30 @@ struct femtoUniverseProducerTask {
785786
// in case of trigger run - store such collisions but don't store any
786787
// particle candidates for such collisions
787788
if (!colCuts.isSelected(col)) {
788-
return;
789-
}
790-
if (!ConfIsUsePileUp) {
791-
if (ConfDoSpher) {
792-
outputCollision(vtxZ, mult, multNtr, colCuts.computeSphericity(col, tracks), mMagField);
793-
} else {
794-
outputCollision(vtxZ, mult, multNtr, 2, mMagField);
795-
}
789+
return false;
796790
} else {
797-
if (ConfDoSpher && (!ConfEvNoSameBunchPileup || col.selection_bit(aod::evsel::kNoSameBunchPileup)) && (!ConfEvIsGoodZvtxFT0vsPV || col.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV)) && (!ConfEvIsVertexITSTPC || col.selection_bit(aod::evsel::kIsVertexITSTPC))) {
798-
outputCollision(vtxZ, mult, multNtr, colCuts.computeSphericity(col, tracks), mMagField);
791+
if (!ConfIsUsePileUp) {
792+
if (ConfDoSpher) {
793+
outputCollision(vtxZ, mult, multNtr, colCuts.computeSphericity(col, tracks), mMagField);
794+
} else {
795+
outputCollision(vtxZ, mult, multNtr, 2, mMagField);
796+
}
799797
} else {
800-
outputCollision(vtxZ, mult, multNtr, 2, mMagField);
798+
if (ConfDoSpher && (!ConfEvNoSameBunchPileup || col.selection_bit(aod::evsel::kNoSameBunchPileup)) && (!ConfEvIsGoodZvtxFT0vsPV || col.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV)) && (!ConfEvIsVertexITSTPC || col.selection_bit(aod::evsel::kIsVertexITSTPC))) {
799+
outputCollision(vtxZ, mult, multNtr, colCuts.computeSphericity(col, tracks), mMagField);
800+
} else {
801+
outputCollision(vtxZ, mult, multNtr, 2, mMagField);
802+
}
801803
}
804+
colCuts.fillQA(col);
805+
return true;
802806
}
803-
colCuts.fillQA(col);
804807
}
805808

806809
template <typename CollisionType, typename TrackType>
807810
void fillMCTruthCollisions(CollisionType const& col, TrackType const& tracks)
808811
{
809-
for (auto& c : col) {
812+
for (const auto& c : col) {
810813
const auto vtxZ = c.posZ();
811814
float mult = 0;
812815
int multNtr = 0;
@@ -880,7 +883,7 @@ struct femtoUniverseProducerTask {
880883
std::vector<int> childIDs = {0, 0}; // these IDs are necessary to keep track of the children
881884
std::vector<int> tmpIDtrack; // this vector keeps track of the matching of the primary track table row <-> aod::track table global index
882885

883-
for (auto& track : tracks) {
886+
for (const auto& track : tracks) {
884887
/// if the most open selection criteria are not fulfilled there is no
885888
/// point looking further at the track
886889
if (!trackCuts.isSelectedMinimal(track)) {
@@ -932,7 +935,7 @@ struct femtoUniverseProducerTask {
932935
{
933936
std::vector<int> childIDs = {0, 0}; // these IDs are necessary to keep track of the children
934937
std::vector<int> tmpIDtrack; // this vector keeps track of the matching of the primary track table row <-> aod::track table global index
935-
for (auto& v0 : fullV0s) {
938+
for (const auto& v0 : fullV0s) {
936939
auto postrack = v0.template posTrack_as<TrackType>();
937940
auto negtrack = v0.template negTrack_as<TrackType>();
938941
///\tocheck funnily enough if we apply the filter the
@@ -1169,7 +1172,7 @@ struct femtoUniverseProducerTask {
11691172
bool isD0D0bar = false;
11701173
uint8_t daughFlag = 0; // flag = 0 (daugh of D0 or D0bar), 1 (daug of D0), -1 (daugh of D0bar)
11711174

1172-
for (auto const& hfCand : hfCands) {
1175+
for (const auto& hfCand : hfCands) {
11731176

11741177
if (!(hfCand.hfflag() & 1 << aod::hf_cand_2prong::DecayType::D0ToPiK)) {
11751178
continue;
@@ -1283,7 +1286,7 @@ struct femtoUniverseProducerTask {
12831286
std::vector<int> childIDs = {0, 0}; // these IDs are necessary to keep track of the children
12841287
std::vector<int> tmpIDtrack; // this vector keeps track of the matching of the primary track table row <-> aod::track table global index
12851288
// lorentz vectors and filling the tables
1286-
for (auto& [p1, p2] : combinations(soa::CombinationsFullIndexPolicy(tracks, tracks))) {
1289+
for (const auto& [p1, p2] : combinations(soa::CombinationsFullIndexPolicy(tracks, tracks))) {
12871290
if (!trackCuts.isSelectedMinimal(p1) || !trackCuts.isSelectedMinimal(p1)) {
12881291
continue;
12891292
}
@@ -1429,7 +1432,7 @@ struct femtoUniverseProducerTask {
14291432
std::vector<int> childIDs = {0, 0}; // these IDs are necessary to keep track of the children
14301433
std::vector<int> tmpIDtrack;
14311434

1432-
for (auto& particle : tracks) {
1435+
for (const auto& particle : tracks) {
14331436
/// if the most open selection criteria are not fulfilled there is no
14341437
/// point looking further at the track
14351438

@@ -1536,13 +1539,15 @@ struct femtoUniverseProducerTask {
15361539
typename CollisionType>
15371540
void fillCollisionsAndTracksAndV0AndPhi(CollisionType const& col, TrackType const& tracks, V0Type const& fullV0s)
15381541
{
1539-
fillCollisions<isMC>(col, tracks);
1540-
fillTracks<isMC>(tracks);
1541-
if (ConfIsActivateV0) {
1542-
fillV0<isMC>(col, fullV0s, tracks);
1543-
}
1544-
if (ConfIsActivatePhi) {
1545-
fillPhi<isMC>(col, tracks);
1542+
const auto colcheck = fillCollisions<isMC>(col, tracks);
1543+
if (colcheck) {
1544+
fillTracks<isMC>(tracks);
1545+
if (ConfIsActivateV0) {
1546+
fillV0<isMC>(col, fullV0s, tracks);
1547+
}
1548+
if (ConfIsActivatePhi) {
1549+
fillPhi<isMC>(col, tracks);
1550+
}
15461551
}
15471552
// if (ConfIsActivateCascade) {
15481553
// fillCascade<false>(col, fullCascades, tracks);
@@ -1581,9 +1586,11 @@ struct femtoUniverseProducerTask {
15811586
// get magnetic field for run
15821587
getMagneticFieldTesla(col.bc_as<aod::BCsWithTimestamps>());
15831588
// fill the tables
1584-
fillCollisions<false>(col, tracks);
1585-
fillTracks<false>(tracks);
1586-
fillCascade<false>(col, fullCascades, tracks);
1589+
const auto colcheck = fillCollisions<false>(col, tracks);
1590+
if (colcheck) {
1591+
fillTracks<false>(tracks);
1592+
fillCascade<false>(col, fullCascades, tracks);
1593+
}
15871594
}
15881595
PROCESS_SWITCH(femtoUniverseProducerTask, processTrackCascadeData, "Provide experimental data for track cascades", false);
15891596

@@ -1624,8 +1631,10 @@ struct femtoUniverseProducerTask {
16241631
// get magnetic field for run
16251632
getMagneticFieldTesla(col.bc_as<aod::BCsWithTimestamps>());
16261633
// fill the tables
1627-
fillCollisions<true>(col, tracks);
1628-
fillTracks<true>(tracks);
1634+
const auto colcheck = fillCollisions<true>(col, tracks);
1635+
if (colcheck) {
1636+
fillTracks<true>(tracks);
1637+
}
16291638
}
16301639
PROCESS_SWITCH(femtoUniverseProducerTask, processTrackMC, "Provide MC data for track analysis", false);
16311640

@@ -1638,9 +1647,11 @@ struct femtoUniverseProducerTask {
16381647
// get magnetic field for run
16391648
getMagneticFieldTesla(col.bc_as<aod::BCsWithTimestamps>());
16401649
// fill the tables
1641-
fillCollisions<true>(col, tracks);
1642-
fillTracks<true>(tracks);
1643-
fillPhi<true>(col, tracks);
1650+
const auto colcheck = fillCollisions<true>(col, tracks);
1651+
if (colcheck) {
1652+
fillTracks<true>(tracks);
1653+
fillPhi<true>(col, tracks);
1654+
}
16441655
}
16451656
PROCESS_SWITCH(femtoUniverseProducerTask, processTrackPhiMC, "Provide MC data for track Phi analysis", false);
16461657

@@ -1653,9 +1664,11 @@ struct femtoUniverseProducerTask {
16531664
// get magnetic field for run
16541665
getMagneticFieldTesla(col.bc_as<aod::BCsWithTimestamps>());
16551666
// fill the tables
1656-
fillCollisions<true>(col, tracks);
1657-
fillTracks<true>(tracks);
1658-
// fillD0mesons<true>(col, tracks, candidates);
1667+
const auto colcheck = fillCollisions<true>(col, tracks);
1668+
if (colcheck) {
1669+
fillTracks<true>(tracks);
1670+
// fillD0mesons<true>(col, tracks, candidates);
1671+
}
16591672
}
16601673
PROCESS_SWITCH(femtoUniverseProducerTask, processTrackD0MC, "Provide MC data for track D0 analysis", false);
16611674

@@ -1665,9 +1678,15 @@ struct femtoUniverseProducerTask {
16651678
{
16661679
// get magnetic field for run
16671680
getMagneticFieldTesla(col.bc_as<aod::BCsWithTimestamps>());
1681+
const double ir = 0.0; // fetch IR
16681682
// fill the tables
1669-
fillCollisions<false>(col, tracks);
1670-
fillTracks<false>(tracks);
1683+
const auto colcheck = fillCollisions<false>(col, tracks);
1684+
if (colcheck) {
1685+
if (ConfFillCollExt) {
1686+
fillCollisionsCentRun3ColExtra<false>(col, ir);
1687+
}
1688+
fillTracks<false>(tracks);
1689+
}
16711690
}
16721691
PROCESS_SWITCH(femtoUniverseProducerTask, processTrackData,
16731692
"Provide experimental data for track track", true);
@@ -1680,9 +1699,11 @@ struct femtoUniverseProducerTask {
16801699
// get magnetic field for run
16811700
getMagneticFieldTesla(col.bc_as<aod::BCsWithTimestamps>());
16821701
// fill the tables
1683-
fillCollisions<false>(col, tracks);
1684-
fillTracks<false>(tracks);
1685-
fillPhi<false>(col, tracks);
1702+
const auto colcheck = fillCollisions<false>(col, tracks);
1703+
if (colcheck) {
1704+
fillTracks<false>(tracks);
1705+
fillPhi<false>(col, tracks);
1706+
}
16861707
}
16871708
PROCESS_SWITCH(femtoUniverseProducerTask, processTrackPhiData,
16881709
"Provide experimental data for track phi", false);
@@ -1695,9 +1716,11 @@ struct femtoUniverseProducerTask {
16951716
// get magnetic field for run
16961717
getMagneticFieldTesla(col.bc_as<aod::BCsWithTimestamps>());
16971718
// fill the tables
1698-
fillCollisions<false>(col, tracks);
1699-
fillTracks<false>(tracks);
1700-
fillD0mesons<false>(col, tracks, candidates);
1719+
const auto colcheck = fillCollisions<false>(col, tracks);
1720+
if (colcheck) {
1721+
fillTracks<false>(tracks);
1722+
fillD0mesons<false>(col, tracks, candidates);
1723+
}
17011724
}
17021725
PROCESS_SWITCH(femtoUniverseProducerTask, processTrackD0mesonData,
17031726
"Provide experimental data for track D0 meson", false);
@@ -1736,19 +1759,19 @@ struct femtoUniverseProducerTask {
17361759
{
17371760
// recos
17381761
std::set<int> recoMcIds;
1739-
for (auto& col : collisions) {
1762+
for (const auto& col : collisions) {
17401763
auto groupedTracks = tracks.sliceBy(perCollisionTracks, col.globalIndex());
17411764
auto groupedV0s = fullV0s.sliceBy(perCollisionV0s, col.globalIndex());
17421765
getMagneticFieldTesla(col.bc_as<aod::BCsWithTimestamps>());
17431766
fillCollisionsAndTracksAndV0AndPhi<true>(col, groupedTracks, groupedV0s);
1744-
for (auto& track : groupedTracks) {
1767+
for (const auto& track : groupedTracks) {
17451768
if (trackCuts.isSelectedMinimal(track))
17461769
recoMcIds.insert(track.mcParticleId());
17471770
}
17481771
}
17491772

17501773
// truth
1751-
for (auto& mccol : mccols) {
1774+
for (const auto& mccol : mccols) {
17521775
auto groupedMCParticles = mcParticles.sliceBy(perMCCollision, mccol.globalIndex());
17531776
auto groupedCollisions = collisions.sliceBy(recoCollsPerMCColl, mccol.globalIndex());
17541777
fillMCTruthCollisions(groupedCollisions, groupedMCParticles); // fills the reco collisions for mc collision

0 commit comments

Comments
 (0)