Skip to content

Commit 052b78f

Browse files
sarjeetagamisarjeeta gami
andauthored
[PWGLF] update the efficiency in kstarpbpb task (#18501)
Co-authored-by: sarjeeta gami <sarjeetagami@sarjeetas-MacBook-Air-217.local>
1 parent 3f87474 commit 052b78f

1 file changed

Lines changed: 78 additions & 6 deletions

File tree

‎PWGLF/Tasks/Resonances/kstarpbpb.cxx‎

Lines changed: 78 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -195,14 +195,27 @@ struct Kstarpbpb {
195195
std::string prefix = "closure";
196196
Configurable<bool> injectPolarization{"injectPolarization", false, "Reweight the true K*/phi with W(cos theta*) so that the sample has rho00 = rho00Inj"};
197197
Configurable<float> rho00Inj{"rho00Inj", 1.0f / 3.0f, "Injected rho00, in [0,1] (1/3 = unpolarized)"};
198-
Configurable<bool> useTrueEP{"useTrueEP", true, "Use the MC true event plane angle as Psi (false: Psi = 0, fixed axis as in processMC)"};
198+
Configurable<bool> useTrueEP{"useTrueEP", true, "Use the MC true event plane angle as Psi (false: Psi = 0, fixed axis as in processMC with mcEffEP.psiSource = 0)"};
199199
Configurable<bool> splitSample{"splitSample", true, "Even MC events build Acc x Eff, odd MC events are the test sample (false: same events for both)"};
200200
Configurable<bool> fillRotBkg{"fillRotBkg", false, "Fill the rotated-pair background (weight 1), cross-check of the ME background"};
201201
Configurable<bool> genAcceptanceCut{"genAcceptanceCut", false, "Daughter pT/eta cut on the generated K*/phi (false: denominator is the full |y| < cut sample, so the correction is the full Acc x Eff in cos theta*)"};
202202
Configurable<bool> requirePrimaryTracks{"requirePrimaryTracks", false, "SE, ME and rotated pairs only from tracks matched to physical primaries (as in phianalysisrun3pbpb / kstar892LightIon); false: all tracks, as in data"};
203203
Configurable<bool> meRequireSingleReco{"meRequireSingleReco", true, "ME: both events must come from an MC collision with exactly one reco collision, as required in the SE (processMCClosure / processMCClosurePhi)"};
204204
ConfigurableAxis axisCosThetaStar{"axisCosThetaStar", {10, -1.0, 1.0}, "cos(#vartheta*)"};
205205
} closure;
206+
207+
// Psi of the EP-frame MC efficiency (processMC, processMCPhi). In data the axis follows Psi_FT0C, which is flat in the lab;
208+
// with a fixed Psi = 0 the axis is fixed in the lab, so azimuthal holes of the detector enter Acc x Eff(cos theta*).
209+
// psiSource = 1 follows the thesis (S. Kundu, App. B.10.4): Psi2 from the generated tracks in the forward EP-detector acceptance
210+
// (V0C there, FT0C here), one Psi per MC event, for both the generated and the reconstructed K*/phi.
211+
struct : ConfigurableGroup {
212+
std::string prefix = "mcEffEP";
213+
Configurable<int> psiSource{"psiSource", 1, "Psi of the EP-frame MC efficiency: 0 = fixed Psi = 0 (old: axis -y for K*, in-plane x for phi), 1 = Psi2 from generated charged primaries in [etaMin, etaMax] (thesis), 2 = MC true event plane (mcCollision.eventPlaneAngle())"};
214+
Configurable<float> etaMin{"etaMin", -3.3f, "eta min of the generated-track Q2 vector (FT0C acceptance)"};
215+
Configurable<float> etaMax{"etaMax", -2.1f, "eta max of the generated-track Q2 vector (FT0C acceptance)"};
216+
Configurable<bool> fillPhiVMinusPsi{"fillPhiVMinusPsi", false, "Fill gen/rec Acc x Eff maps vs pT, cos theta* and phi_V - Psi (thesis Fig. B.69 / Table B.1 check)"};
217+
ConfigurableAxis axisPhiVMinusPsi{"axisPhiVMinusPsi", {6, 0.0, o2::constants::math::PI}, "#varphi_{V} - #Psi"};
218+
} mcEffEP;
206219
Configurable<float> cfgMinTrackPt{"cfgMinTrackPt", 0.15f,
207220
"Minimum track pT"};
208221

@@ -321,6 +334,12 @@ struct Kstarpbpb {
321334
histos.add("hSparseKstarMCGenCosThetaStar_effy", "hSparseKstarMCGenCosThetaStar_effy", HistType::kTHnSparseD, {configThnAxisInvMass, configThnAxisPt, configThnAxisV2, configrapAxis, configThnAxisCentrality});
322335
histos.add("hSparseKstarMCRecSA", "hSparseKstarMCRecSA", HistType::kTHnSparseD, {configThnAxisInvMass, configThnAxisPt, configThnAxisV2, configrapAxis, configThnAxisCentrality});
323336
histos.add("hSparseKstarMCRecCosThetaStar_effy", "hSparseKstarMCRecCosThetaStar_effy", HistType::kTHnSparseD, {configThnAxisInvMass, configThnAxisPt, configThnAxisV2, configrapAxis, configThnAxisCentrality});
337+
histos.add("hMCEffPsi", "Psi of the MC efficiency;centrality (%);#Psi", kTH2F, {configThnAxisCentrality, {36, -o2::constants::math::PI, o2::constants::math::PI}});
338+
if (mcEffEP.fillPhiVMinusPsi) {
339+
const AxisSpec phiVMinusPsiAxis{mcEffEP.axisPhiVMinusPsi, "#varphi_{V} - #Psi"};
340+
histos.add("hSparseKstarMCGenCosThetaStarPhiVPsi", "Generated K*: p_{T}, cos#theta*, #varphi_{V} - #Psi, centrality", HistType::kTHnSparseD, {configThnAxisPt, configThnAxisV2, phiVMinusPsiAxis, configThnAxisCentrality});
341+
histos.add("hSparseKstarMCRecCosThetaStarPhiVPsi", "Reconstructed K*: p_{T}, cos#theta*, #varphi_{V} - #Psi, centrality", HistType::kTHnSparseD, {configThnAxisPt, configThnAxisV2, phiVMinusPsiAxis, configThnAxisCentrality});
342+
}
324343
}
325344

326345
if (doClosureTest) {
@@ -463,6 +482,12 @@ struct Kstarpbpb {
463482
histos.add("phi/hSparseV2MCGenCosThetaStar_effy", "hSparseV2SameEventCosThetaStar_effy", HistType::kTHnSparseF, {thnAxisInvMassPhi, thnAxisPtPhi, thnAxisCosThetaStarPhi, thnAxisRapidityPhi, thnAxisCentralityPhi});
464483
histos.add("phi/hSparseV2MCRecSA", "hSparseV2SameEventSA", HistType::kTHnSparseF, {thnAxisInvMassPhi, thnAxisPtPhi, thnAxisSAPhi, thnAxisRapidityPhi, thnAxisCentralityPhi});
465484
histos.add("phi/hSparseV2MCRecCosThetaStar_effy", "hSparseV2SameEventCosThetaStar_effy", HistType::kTHnSparseF, {thnAxisInvMassPhi, thnAxisPtPhi, thnAxisCosThetaStarPhi, thnAxisRapidityPhi, thnAxisCentralityPhi});
485+
histos.add("phi/hMCEffPsi", "Psi of the MC efficiency;centrality (%);#Psi", kTH2F, {thnAxisCentralityPhi, {36, -o2::constants::math::PI, o2::constants::math::PI}});
486+
if (mcEffEP.fillPhiVMinusPsi) {
487+
const AxisSpec phiVMinusPsiAxis{mcEffEP.axisPhiVMinusPsi, "#varphi_{V} - #Psi"};
488+
histos.add("phi/hSparseV2MCGenCosThetaStarPhiVPsi", "Generated #phi: p_{T}, cos#theta*, #varphi_{V} - #Psi, centrality", HistType::kTHnSparseF, {thnAxisPtPhi, thnAxisCosThetaStarPhi, phiVMinusPsiAxis, thnAxisCentralityPhi});
489+
histos.add("phi/hSparseV2MCRecCosThetaStarPhiVPsi", "Reconstructed #phi: p_{T}, cos#theta*, #varphi_{V} - #Psi, centrality", HistType::kTHnSparseF, {thnAxisPtPhi, thnAxisCosThetaStarPhi, phiVMinusPsiAxis, thnAxisCentralityPhi});
490+
}
466491
}
467492
}
468493

@@ -881,14 +906,47 @@ struct Kstarpbpb {
881906
}
882907

883908
// phipbpb.cxx builds the EP-frame MC efficiency with the in-plane vector at Psi = 0 (x axis); kept for identical results
909+
// with mcEffEP.psiSource = 0 only. With an event-by-event Psi the axis must be the plane normal, as in data (getSAAxis).
884910
ROOT::Math::XYZVector getSAAxisPhiMC(const ROOT::Math::PxPyPzMVector& mother, double psiSA)
885911
{
886-
if (cfgSAFrame.value == kEventPlane) {
912+
if (cfgSAFrame.value == kEventPlane && mcEffEP.psiSource == 0) {
887913
return {std::cos(2.0 * psiSA), std::sin(2.0 * psiSA), 0.};
888914
}
889915
return getSAAxis(mother, psiSA);
890916
}
891917

918+
// Psi2 = atan2(Q2y, Q2x) / 2 from the generated charged physical primaries in [etaMin, etaMax] (thesis Eq. B.16, unit weights)
919+
template <typename TParticles>
920+
double getGenPsi2(TParticles const& particles)
921+
{
922+
double qx = 0., qy = 0.;
923+
for (const auto& particle : particles) {
924+
if (!particle.isPhysicalPrimary() || particle.eta() < mcEffEP.etaMin || particle.eta() > mcEffEP.etaMax) {
925+
continue;
926+
}
927+
const int absPdg = std::abs(particle.pdgCode());
928+
if (absPdg != PDG_t::kPiPlus && absPdg != PDG_t::kKPlus && absPdg != PDG_t::kProton && absPdg != PDG_t::kElectron && absPdg != PDG_t::kMuonMinus) {
929+
continue;
930+
}
931+
qx += std::cos(2.0 * particle.phi());
932+
qy += std::sin(2.0 * particle.phi());
933+
}
934+
return 0.5 * std::atan2(qy, qx);
935+
}
936+
937+
// Psi of the EP-frame MC efficiency, one per MC event (see mcEffEP)
938+
template <typename TMcCollision, typename TParticles>
939+
double getMCEffPsi(TMcCollision const& mcCollision, TParticles const& particles)
940+
{
941+
if (mcEffEP.psiSource == 1) {
942+
return getGenPsi2(particles);
943+
}
944+
if (mcEffEP.psiSource == 2) {
945+
return mcCollision.eventPlaneAngle();
946+
}
947+
return 0.0;
948+
}
949+
892950
template <typename T>
893951
bool isFakeKaon(T const& track, int /*PID*/)
894952
{
@@ -1258,7 +1316,7 @@ struct Kstarpbpb {
12581316
}
12591317
PROCESS_SWITCH(Kstarpbpb, processMixedEvent, "Process Mixed event", true);
12601318

1261-
void processMC(CollisionMCTrueTable::iterator const& /*TrueCollision*/, CollisionMCRecTableCentFT0C const& RecCollisions, TrackMCTrueTable const& GenParticles, FilTrackMCRecTable const& RecTracks)
1319+
void processMC(CollisionMCTrueTable::iterator const& TrueCollision, CollisionMCRecTableCentFT0C const& RecCollisions, TrackMCTrueTable const& GenParticles, FilTrackMCRecTable const& RecTracks)
12621320
{
12631321
// scratch vectors: local to this call, never carry state across particles
12641322
ROOT::Math::PxPyPzMVector kstarMother, kaonPlus, pionMinus;
@@ -1274,7 +1332,7 @@ struct Kstarpbpb {
12741332
return;
12751333
}
12761334
for (const auto& RecCollision : RecCollisions) {
1277-
auto psiFT0C = 0.0;
1335+
auto psiFT0C = getMCEffPsi(TrueCollision, GenParticles); // one Psi per MC event (mcEffEP.psiSource; 0 = old fixed Psi = 0)
12781336
histos.fill(HIST("hMC"), 3);
12791337
if (!RecCollision.sel8()) {
12801338
histos.fill(HIST("hMC"), 4);
@@ -1292,6 +1350,7 @@ struct Kstarpbpb {
12921350
auto centrality = RecCollision.centFT0C();
12931351
histos.fill(HIST("CentPercentileMCRecHist"), centrality);
12941352
auto psiSA = getSAEventAngle(psiFT0C); // same angle for rec and gen of this event
1353+
histos.fill(HIST("hMCEffPsi"), centrality, psiSA);
12951354
auto oldindex = -999;
12961355
auto rectrackspart = RecTracks.sliceBy(perCollision, RecCollision.globalIndex());
12971356
// loop over reconstructed particle
@@ -1399,6 +1458,9 @@ struct Kstarpbpb {
13991458

14001459
histos.fill(HIST("hSparseKstarMCRecSA"), kstarMother.M(), kstarMother.Pt(), saRec, std::abs(kstarMother.Rapidity()), centrality);
14011460
histos.fill(HIST("hSparseKstarMCRecCosThetaStar_effy"), kstarMother.M(), kstarMother.Pt(), cosThetaStarRec, std::abs(kstarMother.Rapidity()), centrality);
1461+
if (mcEffEP.fillPhiVMinusPsi) {
1462+
histos.fill(HIST("hSparseKstarMCRecCosThetaStarPhiVPsi"), kstarMother.Pt(), cosThetaStarRec, getPhiInRange(kstarMother.Phi() - psiSA), centrality);
1463+
}
14021464
if (doClosureTest) {
14031465
histos.fill(HIST("closure/KstarMCRecTrueCosThetaStar"), kstarMother.M(), kstarMother.Pt(), cosThetaStarRec, std::abs(kstarMother.Rapidity()), centrality);
14041466
}
@@ -1471,6 +1533,9 @@ struct Kstarpbpb {
14711533

14721534
histos.fill(HIST("hSparseKstarMCGenSA"), kstarMother.M(), kstarMother.Pt(), saGen, std::abs(kstarMother.Rapidity()), centrality);
14731535
histos.fill(HIST("hSparseKstarMCGenCosThetaStar_effy"), kstarMother.M(), kstarMother.Pt(), cosThetaStarGen, std::abs(kstarMother.Rapidity()), centrality);
1536+
if (mcEffEP.fillPhiVMinusPsi) {
1537+
histos.fill(HIST("hSparseKstarMCGenCosThetaStarPhiVPsi"), kstarMother.Pt(), cosThetaStarGen, getPhiInRange(kstarMother.Phi() - psiSA), centrality);
1538+
}
14741539
if (doClosureTest) {
14751540
histos.fill(HIST("closure/KstarMCGenCosThetaStar"), kstarMother.M(), kstarMother.Pt(), cosThetaStarGen, std::abs(kstarMother.Rapidity()), centrality);
14761541
}
@@ -1826,7 +1891,7 @@ struct Kstarpbpb {
18261891
}
18271892
PROCESS_SWITCH(Kstarpbpb, processMEPhi, "Process mixed event phi(1020) spin alignment", false);
18281893

1829-
void processMCPhi(CollisionMCTrueTable::iterator const& /*TrueCollision*/, CollisionMCRecTableCentFT0C const& RecCollisions, TrackMCTrueTable const& GenParticles, FilTrackMCRecTable const& RecTracks)
1894+
void processMCPhi(CollisionMCTrueTable::iterator const& TrueCollision, CollisionMCRecTableCentFT0C const& RecCollisions, TrackMCTrueTable const& GenParticles, FilTrackMCRecTable const& RecTracks)
18301895
{
18311896
histos.fill(HIST("phi/hMC"), 0);
18321897
if (RecCollisions.size() == 0) {
@@ -1839,7 +1904,7 @@ struct Kstarpbpb {
18391904
}
18401905
ROOT::Math::PxPyPzMVector kaonPlusPhi, kaonMinusPhi, phiMother;
18411906
for (const auto& RecCollision : RecCollisions) {
1842-
auto psiFT0C = 0.0;
1907+
auto psiFT0C = getMCEffPsi(TrueCollision, GenParticles); // one Psi per MC event (mcEffEP.psiSource; 0 = old fixed Psi = 0)
18431908
histos.fill(HIST("phi/hMC"), 3);
18441909
if (!RecCollision.sel8()) {
18451910
histos.fill(HIST("phi/hMC"), 4);
@@ -1857,6 +1922,7 @@ struct Kstarpbpb {
18571922
auto centrality = RecCollision.centFT0C();
18581923
histos.fill(HIST("phi/CentPercentileMCRecHist"), centrality);
18591924
auto psiSA = getSAEventAngle(psiFT0C); // same angle for rec and gen of this event
1925+
histos.fill(HIST("phi/hMCEffPsi"), centrality, psiSA);
18601926
auto oldindex = -999;
18611927
auto rectrackspart = RecTracks.sliceBy(perCollision, RecCollision.globalIndex());
18621928
// loop over reconstructed particle
@@ -1932,6 +1998,9 @@ struct Kstarpbpb {
19321998
}
19331999
auto [cosThetaStar, sa] = getSAValuesPhi(phiMother, kaonMinusPhi, getSAAxisPhiMC(phiMother, psiSA), psiSA);
19342000
histos.fill(HIST("phi/hSparseV2MCRecCosThetaStar_effy"), phiMother.M(), phiMother.Pt(), cosThetaStar, std::abs(phiMother.Rapidity()), centrality);
2001+
if (mcEffEP.fillPhiVMinusPsi) {
2002+
histos.fill(HIST("phi/hSparseV2MCRecCosThetaStarPhiVPsi"), phiMother.Pt(), cosThetaStar, getPhiInRange(phiMother.Phi() - psiSA), centrality);
2003+
}
19352004
if (doClosureTest) {
19362005
histos.fill(HIST("closure/PhiMCRecTrueCosThetaStar"), phiMother.M(), phiMother.Pt(), cosThetaStar, std::abs(phiMother.Rapidity()), centrality);
19372006
}
@@ -1972,6 +2041,9 @@ struct Kstarpbpb {
19722041
phiMother = kaonPlusPhi + kaonMinusPhi;
19732042
auto [cosThetaStar, sa] = getSAValuesPhi(phiMother, kaonMinusPhi, getSAAxisPhiMC(phiMother, psiSA), psiSA);
19742043
histos.fill(HIST("phi/hSparseV2MCGenCosThetaStar_effy"), phiMother.M(), phiMother.Pt(), cosThetaStar, std::abs(phiMother.Rapidity()), centrality);
2044+
if (mcEffEP.fillPhiVMinusPsi) {
2045+
histos.fill(HIST("phi/hSparseV2MCGenCosThetaStarPhiVPsi"), phiMother.Pt(), cosThetaStar, getPhiInRange(phiMother.Phi() - psiSA), centrality);
2046+
}
19752047
if (doClosureTest) {
19762048
histos.fill(HIST("closure/PhiMCGenCosThetaStar"), phiMother.M(), phiMother.Pt(), cosThetaStar, std::abs(phiMother.Rapidity()), centrality);
19772049
}

0 commit comments

Comments
 (0)