Skip to content

Commit 0b9da35

Browse files
committed
checkNeutronsInMC and get rid of fake events
1 parent dbf4e19 commit 0b9da35

File tree

1 file changed

+136
-128
lines changed

1 file changed

+136
-128
lines changed

PWGLF/Tasks/Strangeness/derivedupcanalysis.cxx

Lines changed: 136 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,6 @@ struct Derivedupcanalysis {
114114
Configurable<float> daughterEtaCut{"daughterEtaCut", 0.8, "max eta for daughters"};
115115

116116
Configurable<bool> doDaughterDCA{"doDaughterDCA", true, "dcaXY cut for daughter tracks"};
117-
Configurable<bool> checkNeutronsInMC{"checkNeutronsInMC", true, "require no neutrons for single-gap in MC"};
118-
Configurable<float> neutronEtaCut{"neutronEtaCut", 0.8, "ZN acceptance"};
119117

120118
// Standard V0 topological criteria
121119
struct : ConfigurableGroup {
@@ -213,6 +211,8 @@ struct Derivedupcanalysis {
213211
Configurable<bool> doTreatPiToMuon{"doTreatPiToMuon", false, "Take pi decay into muon into account in MC"};
214212
Configurable<bool> calculateFeeddownMatrix{"calculateFeeddownMatrix", true, "fill feeddown matrix if MC"};
215213
ConfigurableAxis axisGeneratorIds{"axisGeneratorIds", {256, -0.5f, 255.5f}, "axis for generatorIds"};
214+
Configurable<bool> checkNeutronsInMC{"checkNeutronsInMC", true, "require no neutrons for single-gap in MC"};
215+
Configurable<float> neutronEtaCut{"neutronEtaCut", 0.8, "ZN acceptance"};
216216

217217
// Occupancy cut
218218
Configurable<float> minOccupancy{"minOccupancy", -1, "minimum occupancy from neighbouring collisions"};
@@ -1720,32 +1720,34 @@ struct Derivedupcanalysis {
17201720
}
17211721

17221722
int selGapSide = collision.isUPC() ? getGapSide(collision) : -1;
1723-
for (const auto& neutron : neutrons) {
1724-
if (!neutron.has_straMCCollision() || !collision.has_straMCCollision())
1725-
continue;
1726-
1727-
const auto& mcCollisionNeutron = neutron.straMCCollision_as<StraMCCollisionsFull>(); // take gen. collision associated to the neutron
1728-
1729-
// Consider neutrons from the same collision
1730-
if (mcCollisionNeutron.globalIndex() != mcCollision.globalIndex())
1731-
continue;
1732-
1733-
const float eta = neutron.eta();
1734-
switch (selGapSide) {
1735-
case 0: // SGA
1736-
if (eta > neutronEtaCut)
1737-
selGapSide = -1;
1738-
break;
1739-
case 1: // SGC
1740-
if (eta < -neutronEtaCut)
1741-
selGapSide = -1;
1742-
break;
1743-
case 2: // DG
1744-
if (eta > neutronEtaCut)
1745-
selGapSide = 1;
1746-
else if (eta < -neutronEtaCut)
1747-
selGapSide = 0;
1748-
break;
1723+
if (checkNeutronsInMC) {
1724+
for (const auto& neutron : neutrons) {
1725+
if (!neutron.has_straMCCollision() || !collision.has_straMCCollision())
1726+
continue;
1727+
1728+
const auto& mcCollisionNeutron = neutron.straMCCollision_as<StraMCCollisionsFull>(); // take gen. collision associated to the neutron
1729+
1730+
// Consider neutrons from the same collision
1731+
if (mcCollisionNeutron.globalIndex() != mcCollision.globalIndex())
1732+
continue;
1733+
1734+
const float eta = neutron.eta();
1735+
switch (selGapSide) {
1736+
case 0: // SGA
1737+
if (eta > neutronEtaCut)
1738+
selGapSide = -1;
1739+
break;
1740+
case 1: // SGC
1741+
if (eta < -neutronEtaCut)
1742+
selGapSide = -1;
1743+
break;
1744+
case 2: // DG
1745+
if (eta > neutronEtaCut)
1746+
selGapSide = 1;
1747+
else if (eta < -neutronEtaCut)
1748+
selGapSide = 0;
1749+
break;
1750+
}
17491751
}
17501752
}
17511753

@@ -1799,32 +1801,34 @@ struct Derivedupcanalysis {
17991801
}
18001802

18011803
int selGapSide = collision.isUPC() ? getGapSide(collision) : -1;
1802-
for (const auto& neutron : neutrons) {
1803-
if (!neutron.has_straMCCollision() || !collision.has_straMCCollision())
1804-
continue;
1805-
1806-
const auto& mcCollisionNeutron = neutron.straMCCollision_as<StraMCCollisionsFull>(); // take gen. collision associated to the neutron
1807-
1808-
// Consider neutrons from the same collision
1809-
if (mcCollisionNeutron.globalIndex() != mcCollision.globalIndex())
1810-
continue;
1811-
1812-
const float eta = neutron.eta();
1813-
switch (selGapSide) {
1814-
case 0: // SGA
1815-
if (eta > neutronEtaCut)
1816-
selGapSide = -1;
1817-
break;
1818-
case 1: // SGC
1819-
if (eta < -neutronEtaCut)
1820-
selGapSide = -1;
1821-
break;
1822-
case 2: // DG
1823-
if (eta > neutronEtaCut)
1824-
selGapSide = 1;
1825-
else if (eta < -neutronEtaCut)
1826-
selGapSide = 0;
1827-
break;
1804+
if (checkNeutronsInMC) {
1805+
for (const auto& neutron : neutrons) {
1806+
if (!neutron.has_straMCCollision() || !collision.has_straMCCollision())
1807+
continue;
1808+
1809+
const auto& mcCollisionNeutron = neutron.straMCCollision_as<StraMCCollisionsFull>(); // take gen. collision associated to the neutron
1810+
1811+
// Consider neutrons from the same collision
1812+
if (mcCollisionNeutron.globalIndex() != mcCollision.globalIndex())
1813+
continue;
1814+
1815+
const float eta = neutron.eta();
1816+
switch (selGapSide) {
1817+
case 0: // SGA
1818+
if (eta > neutronEtaCut)
1819+
selGapSide = -1;
1820+
break;
1821+
case 1: // SGC
1822+
if (eta < -neutronEtaCut)
1823+
selGapSide = -1;
1824+
break;
1825+
case 2: // DG
1826+
if (eta > neutronEtaCut)
1827+
selGapSide = 1;
1828+
else if (eta < -neutronEtaCut)
1829+
selGapSide = 0;
1830+
break;
1831+
}
18281832
}
18291833
}
18301834

@@ -1869,7 +1873,11 @@ struct Derivedupcanalysis {
18691873
return;
18701874
}
18711875

1872-
const auto v0mother = v0.motherMCPart();
1876+
const auto v0mother = v0.template motherMCPart_as<aod::MotherMCParts>();
1877+
if (v0mother.size() < 1) {
1878+
return;
1879+
}
1880+
18731881
const float rapidityXi = RecoDecay::y(std::array{v0mother.px(), v0mother.py(), v0mother.pz()}, o2::constants::physics::MassXiMinus);
18741882
if (std::fabs(rapidityXi) > 0.5f) {
18751883
return;
@@ -1928,11 +1936,13 @@ struct Derivedupcanalysis {
19281936
{
19291937
if (!collision.has_straMCCollision()) {
19301938
histos.fill(HIST("eventQA/mc/hFakeEvents"), 0); // no assoc. MC collisions
1931-
} else {
1932-
const auto& mcCollision = collision.straMCCollision_as<StraMCCollisionsFull>();
1933-
if (std::find(generatorIds->begin(), generatorIds->end(), mcCollision.generatorsID()) == generatorIds->end()) {
1934-
return;
1935-
}
1939+
return;
1940+
}
1941+
1942+
const auto& mcCollision = collision.straMCCollision_as<StraMCCollisionsFull>(); // take gen. collision associated to the rec. collision
1943+
1944+
if (std::find(generatorIds->begin(), generatorIds->end(), mcCollision.generatorsID()) == generatorIds->end()) {
1945+
return;
19361946
}
19371947

19381948
if (!acceptEvent(collision, true)) {
@@ -1942,33 +1952,34 @@ struct Derivedupcanalysis {
19421952
histos.fill(HIST("eventQA/hRawGapSide"), collision.gapSide());
19431953

19441954
int selGapSide = collision.isUPC() ? getGapSide(collision) : -1;
1945-
for (const auto& neutron : neutrons) {
1946-
if (!neutron.has_straMCCollision() || !collision.has_straMCCollision())
1947-
continue;
1955+
if (checkNeutronsInMC) {
1956+
for (const auto& neutron : neutrons) {
1957+
if (!neutron.has_straMCCollision() || !collision.has_straMCCollision())
1958+
continue;
19481959

1949-
const auto& mcCollisionNeutron = neutron.straMCCollision_as<StraMCCollisionsFull>(); // take gen. collision associated to the neutron
1950-
const auto& mcCollision = collision.straMCCollision_as<StraMCCollisionsFull>(); // take gen. collision associated to the rec. collision
1960+
const auto& mcCollisionNeutron = neutron.straMCCollision_as<StraMCCollisionsFull>(); // take gen. collision associated to the neutron
19511961

1952-
// Consider neutrons from the same collision
1953-
if (mcCollisionNeutron.globalIndex() != mcCollision.globalIndex())
1954-
continue;
1962+
// Consider neutrons from the same collision
1963+
if (mcCollisionNeutron.globalIndex() != mcCollision.globalIndex())
1964+
continue;
19551965

1956-
const float eta = neutron.eta();
1957-
switch (selGapSide) {
1958-
case 0: // SGA
1959-
if (eta > neutronEtaCut)
1960-
selGapSide = -1;
1961-
break;
1962-
case 1: // SGC
1963-
if (eta < -neutronEtaCut)
1964-
selGapSide = -1;
1965-
break;
1966-
case 2: // DG
1967-
if (eta > neutronEtaCut)
1968-
selGapSide = 1;
1969-
else if (eta < -neutronEtaCut)
1970-
selGapSide = 0;
1971-
break;
1966+
const float eta = neutron.eta();
1967+
switch (selGapSide) {
1968+
case 0: // SGA
1969+
if (eta > neutronEtaCut)
1970+
selGapSide = -1;
1971+
break;
1972+
case 1: // SGC
1973+
if (eta < -neutronEtaCut)
1974+
selGapSide = -1;
1975+
break;
1976+
case 2: // DG
1977+
if (eta > neutronEtaCut)
1978+
selGapSide = 1;
1979+
else if (eta < -neutronEtaCut)
1980+
selGapSide = 0;
1981+
break;
1982+
}
19721983
}
19731984
}
19741985

@@ -1977,13 +1988,10 @@ struct Derivedupcanalysis {
19771988

19781989
fillHistogramsQA(collision, selGapSide);
19791990

1980-
if (collision.has_straMCCollision()) {
1981-
const auto& mcCollision = collision.straMCCollision_as<StraMCCollisionsFull>();
1982-
histos.fill(HIST("eventQA/mc/hNTracksGlobalvsMCNParticlesEta08rec"), collision.multNTracksGlobal(), mcCollision.multMCNParticlesEta08());
1983-
histos.fill(HIST("eventQA/mc/hNTracksPVeta1vsMCNParticlesEta10rec"), collision.multNTracksPVeta1(), mcCollision.multMCNParticlesEta10());
1984-
histos.fill(HIST("eventQA/mc/hNTracksGlobalvstotalMultMCParticles"), collision.multNTracksGlobal(), mcCollision.totalMultMCParticles());
1985-
histos.fill(HIST("eventQA/mc/hNTracksPVeta1vstotalMultMCParticles"), collision.multNTracksPVeta1(), mcCollision.totalMultMCParticles());
1986-
}
1991+
histos.fill(HIST("eventQA/mc/hNTracksGlobalvsMCNParticlesEta08rec"), collision.multNTracksGlobal(), mcCollision.multMCNParticlesEta08());
1992+
histos.fill(HIST("eventQA/mc/hNTracksPVeta1vsMCNParticlesEta10rec"), collision.multNTracksPVeta1(), mcCollision.multMCNParticlesEta10());
1993+
histos.fill(HIST("eventQA/mc/hNTracksGlobalvstotalMultMCParticles"), collision.multNTracksGlobal(), mcCollision.totalMultMCParticles());
1994+
histos.fill(HIST("eventQA/mc/hNTracksPVeta1vstotalMultMCParticles"), collision.multNTracksPVeta1(), mcCollision.totalMultMCParticles());
19871995

19881996
for (const auto& v0 : fullV0s) {
19891997
if ((v0.v0Type() != v0cuts.v0TypeSelection) && (v0cuts.v0TypeSelection > 0))
@@ -2045,11 +2053,13 @@ struct Derivedupcanalysis {
20452053
{
20462054
if (!collision.has_straMCCollision()) {
20472055
histos.fill(HIST("eventQA/mc/hFakeEvents"), 0); // no assoc. MC collisions
2048-
} else {
2049-
const auto& mcCollision = collision.straMCCollision_as<StraMCCollisionsFull>();
2050-
if (std::find(generatorIds->begin(), generatorIds->end(), mcCollision.generatorsID()) == generatorIds->end()) {
2051-
return;
2052-
}
2056+
return;
2057+
}
2058+
2059+
const auto& mcCollision = collision.straMCCollision_as<StraMCCollisionsFull>(); // take gen. collision associated to the rec. collision
2060+
2061+
if (std::find(generatorIds->begin(), generatorIds->end(), mcCollision.generatorsID()) == generatorIds->end()) {
2062+
return;
20532063
}
20542064

20552065
if (!acceptEvent(collision, true)) {
@@ -2059,48 +2069,46 @@ struct Derivedupcanalysis {
20592069
histos.fill(HIST("eventQA/hRawGapSide"), collision.gapSide());
20602070

20612071
int selGapSide = collision.isUPC() ? getGapSide(collision) : -1;
2062-
for (const auto& neutron : neutrons) {
2063-
if (!neutron.has_straMCCollision() || !collision.has_straMCCollision())
2064-
continue;
2072+
if (checkNeutronsInMC) {
2073+
for (const auto& neutron : neutrons) {
2074+
if (!neutron.has_straMCCollision() || !collision.has_straMCCollision())
2075+
continue;
20652076

2066-
const auto& mcCollisionNeutron = neutron.straMCCollision_as<StraMCCollisionsFull>(); // take gen. collision associated to the neutron
2067-
const auto& mcCollision = collision.straMCCollision_as<StraMCCollisionsFull>(); // take gen. collision associated to the rec. collision
2077+
const auto& mcCollisionNeutron = neutron.straMCCollision_as<StraMCCollisionsFull>(); // take gen. collision associated to the neutron
20682078

2069-
// Consider neutrons from the same collision
2070-
if (mcCollisionNeutron.globalIndex() != mcCollision.globalIndex())
2071-
continue;
2079+
// Consider neutrons from the same collision
2080+
if (mcCollisionNeutron.globalIndex() != mcCollision.globalIndex())
2081+
continue;
20722082

2073-
const float eta = neutron.eta();
2074-
switch (selGapSide) {
2075-
case 0: // SGA
2076-
if (eta > neutronEtaCut)
2077-
selGapSide = -1;
2078-
break;
2079-
case 1: // SGC
2080-
if (eta < -neutronEtaCut)
2081-
selGapSide = -1;
2082-
break;
2083-
case 2: // DG
2084-
if (eta > neutronEtaCut)
2085-
selGapSide = 1;
2086-
else if (eta < -neutronEtaCut)
2087-
selGapSide = 0;
2088-
break;
2089-
}
2083+
const float eta = neutron.eta();
2084+
switch (selGapSide) {
2085+
case 0: // SGA
2086+
if (eta > neutronEtaCut)
2087+
selGapSide = -1;
2088+
break;
2089+
case 1: // SGC
2090+
if (eta < -neutronEtaCut)
2091+
selGapSide = -1;
2092+
break;
2093+
case 2: // DG
2094+
if (eta > neutronEtaCut)
2095+
selGapSide = 1;
2096+
else if (eta < -neutronEtaCut)
2097+
selGapSide = 0;
2098+
break;
2099+
}
2100+
}
20902101
}
20912102

20922103
if (evSels.studyUPConly && (selGapSide < -0.5))
20932104
return;
20942105

20952106
fillHistogramsQA(collision, selGapSide);
20962107

2097-
if (collision.has_straMCCollision()) {
2098-
const auto& mcCollision = collision.straMCCollision_as<StraMCCollisionsFull>();
2099-
histos.fill(HIST("eventQA/mc/hNTracksGlobalvsMCNParticlesEta08rec"), collision.multNTracksGlobal(), mcCollision.multMCNParticlesEta08());
2100-
histos.fill(HIST("eventQA/mc/hNTracksPVeta1vsMCNParticlesEta10rec"), collision.multNTracksPVeta1(), mcCollision.multMCNParticlesEta10());
2101-
histos.fill(HIST("eventQA/mc/hNTracksGlobalvstotalMultMCParticles"), collision.multNTracksGlobal(), mcCollision.totalMultMCParticles());
2102-
histos.fill(HIST("eventQA/mc/hNTracksPVeta1vstotalMultMCParticles"), collision.multNTracksPVeta1(), mcCollision.totalMultMCParticles());
2103-
}
2108+
histos.fill(HIST("eventQA/mc/hNTracksGlobalvsMCNParticlesEta08rec"), collision.multNTracksGlobal(), mcCollision.multMCNParticlesEta08());
2109+
histos.fill(HIST("eventQA/mc/hNTracksPVeta1vsMCNParticlesEta10rec"), collision.multNTracksPVeta1(), mcCollision.multMCNParticlesEta10());
2110+
histos.fill(HIST("eventQA/mc/hNTracksGlobalvstotalMultMCParticles"), collision.multNTracksGlobal(), mcCollision.totalMultMCParticles());
2111+
histos.fill(HIST("eventQA/mc/hNTracksPVeta1vstotalMultMCParticles"), collision.multNTracksPVeta1(), mcCollision.totalMultMCParticles());
21042112

21052113
for (const auto& casc : fullCascades) {
21062114
std::bitset<kSelNum> selMap = computeBitmapCascade(casc, collision);

0 commit comments

Comments
 (0)