Skip to content

Commit 20f1e56

Browse files
authored
[PWGCF] Update lambdaR2Correlation.cxx (#9977)
1 parent 2836d8f commit 20f1e56

File tree

1 file changed

+66
-94
lines changed

1 file changed

+66
-94
lines changed

PWGCF/TwoParticleCorrelations/Tasks/lambdaR2Correlation.cxx

Lines changed: 66 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "Framework/ASoAHelpers.h"
2424
#include "Framework/runDataProcessing.h"
2525
#include "PWGLF/DataModel/LFStrangenessTables.h"
26+
#include "PWGLF/DataModel/mcCentrality.h"
2627
#include "CommonConstants/PhysicsConstants.h"
2728
#include "Common/Core/RecoDecay.h"
2829
#include "CCDB/BasicCCDBManager.h"
@@ -134,8 +135,7 @@ using LambdaMcGenTrack = LambdaMcGenTracks::iterator;
134135
enum CollisionLabels {
135136
kTotColBeforeHasMcCollision = 1,
136137
kTotCol,
137-
kPassSelCol,
138-
kPassMultSelCol
138+
kPassSelCol
139139
};
140140

141141
enum TrackLabels {
@@ -281,6 +281,9 @@ struct LambdaTableProducer {
281281
{"hEffVsPtYVzLambda", "hEffVsPtYVzAntiLambda"},
282282
{"hEffVsPtEtaVzLambda", "hEffVsPtEtaVzAntiLambda"}};
283283

284+
// Initialize Global Variables
285+
float cent = 0.;
286+
284287
void init(InitContext const&)
285288
{
286289
// Set CCDB url
@@ -367,7 +370,7 @@ struct LambdaTableProducer {
367370
histos.addClone("McRec/Lambda/", "McRec/AntiLambda/");
368371

369372
// MC Generated Histograms
370-
if (doprocessMCGenRun3 || doprocessMCGenRun2) {
373+
if (doprocessMCRun3 || doprocessMCRun2) {
371374
// McReco Histos
372375
histos.add("Tracks/h2f_tracks_pid_before_sel", "PIDs", kTH2F, {axisPID, axisV0Pt});
373376
histos.add("Tracks/h2f_tracks_pid_after_sel", "PIDs", kTH2F, {axisPID, axisV0Pt});
@@ -376,8 +379,9 @@ struct LambdaTableProducer {
376379
histos.add("Tracks/h2f_lambda_from_omega", "PIDs", kTH2F, {axisPID, axisV0Pt});
377380

378381
// McGen Histos
382+
histos.add("McGen/h1f_collision_recgen", "# of Reco Collision Associated to One Mc Generator Collision", kTH1F, {axisMult});
379383
histos.add("McGen/h1f_collisions_info", "# of collisions", kTH1F, {axisCols});
380-
histos.add("McGen/h1f_collision_posZ", "V_{z}-distribution", kTH1F, {axisVz});
384+
histos.add("McGen/h2f_collision_posZ", "V_{z}-distribution", kTH2F, {axisVz, axisVz});
381385
histos.add("McGen/h1f_lambda_daughter_PDG", "PDG Daughters", kTH1F, {axisPID});
382386
histos.add("McGen/h1f_antilambda_daughter_PDG", "PDG Daughters", kTH1F, {axisPID});
383387

@@ -396,7 +400,6 @@ struct LambdaTableProducer {
396400
histos.get<TH1>(HIST("Events/h1f_collisions_info"))->GetXaxis()->SetBinLabel(CollisionLabels::kTotColBeforeHasMcCollision, "kTotColBeforeHasMcCollision");
397401
histos.get<TH1>(HIST("McGen/h1f_collisions_info"))->GetXaxis()->SetBinLabel(CollisionLabels::kTotCol, "kTotCol");
398402
histos.get<TH1>(HIST("McGen/h1f_collisions_info"))->GetXaxis()->SetBinLabel(CollisionLabels::kPassSelCol, "kPassSelCol");
399-
histos.get<TH1>(HIST("McGen/h1f_collisions_info"))->GetXaxis()->SetBinLabel(CollisionLabels::kPassMultSelCol, "kPassMultSelCol");
400403
histos.get<TH1>(HIST("Tracks/h1f_tracks_info"))->GetXaxis()->SetBinLabel(TrackLabels::kTracksBeforeHasMcParticle, "kTracksBeforeHasMcParticle");
401404
histos.get<TH1>(HIST("Tracks/h1f_tracks_info"))->GetXaxis()->SetBinLabel(TrackLabels::kNotPrimaryLambda, "kNotPrimaryLambda");
402405
histos.get<TH1>(HIST("Tracks/h1f_tracks_info"))->GetXaxis()->SetBinLabel(TrackLabels::kNotSecondaryLambda, "kNotSecondaryLambda");
@@ -412,7 +415,6 @@ struct LambdaTableProducer {
412415
// set bin labels
413416
histos.get<TH1>(HIST("Events/h1f_collisions_info"))->GetXaxis()->SetBinLabel(CollisionLabels::kTotCol, "kTotCol");
414417
histos.get<TH1>(HIST("Events/h1f_collisions_info"))->GetXaxis()->SetBinLabel(CollisionLabels::kPassSelCol, "kPassSelCol");
415-
histos.get<TH1>(HIST("Events/h1f_collisions_info"))->GetXaxis()->SetBinLabel(CollisionLabels::kPassMultSelCol, "kPassMultSelCol");
416418
histos.get<TH1>(HIST("Tracks/h1f_tracks_info"))->GetXaxis()->SetBinLabel(TrackLabels::kAllV0Tracks, "kAllV0Tracks");
417419
histos.get<TH1>(HIST("Tracks/h1f_tracks_info"))->GetXaxis()->SetBinLabel(TrackLabels::kV0KShortMassRej, "kV0KShortMassRej");
418420
histos.get<TH1>(HIST("Tracks/h1f_tracks_info"))->GetXaxis()->SetBinLabel(TrackLabels::kNotLambdaNotAntiLambda, "kNotLambdaNotAntiLambda");
@@ -432,24 +434,31 @@ struct LambdaTableProducer {
432434
template <RunType run, typename C>
433435
bool selCollision(C const& col)
434436
{
437+
// VtxZ Selection
435438
if (col.posZ() <= cMinZVtx || col.posZ() >= cMaxZVtx) {
436439
return false;
437440
}
438441

439-
if constexpr (run == kRun3) {
442+
if constexpr (run == kRun3) { // Run3 Min-Bias Trigger
443+
cent = col.centFT0M();
440444
if (cSel8Trig && !col.sel8()) {
441445
return false;
442446
}
443-
} else {
447+
} else { // Run2 Min-Bias Trigger
448+
cent = col.centRun2V0M();
444449
if (cInt7Trig && !col.alias_bit(kINT7)) {
445450
return false;
446451
}
447-
448452
if (cSel7Trig && !col.sel7()) {
449453
return false;
450454
}
451455
}
452456

457+
// Multiplicity Selection
458+
if (cent <= cMinMult || cent >= cMaxMult) {
459+
return false;
460+
}
461+
453462
if (cTriggerTvxSel && !col.selection_bit(aod::evsel::kIsTriggerTVX)) {
454463
return false;
455464
}
@@ -850,39 +859,20 @@ struct LambdaTableProducer {
850859
template <RunType run, DMCType dmc, typename C, typename V, typename T>
851860
void fillLambdaRecoTables(C const& collision, V const& v0tracks, T const& tracks)
852861
{
853-
// Check for corresponding MC Collision
854-
if constexpr (dmc == kMC) {
855-
histos.fill(HIST("Events/h1f_collisions_info"), kTotColBeforeHasMcCollision);
856-
if (!collision.has_mcCollision()) {
857-
return;
858-
}
859-
}
860-
862+
// Total Collisions
861863
histos.fill(HIST("Events/h1f_collisions_info"), kTotCol);
862864

863-
// Select Collision
864-
if (!selCollision<run>(collision)) {
865-
return;
865+
// Select Collision (Only for Data... McRec has been selected already !!!)
866+
if constexpr (dmc == kData) {
867+
if (!selCollision<run>(collision)) {
868+
return;
869+
}
866870
}
867871

868872
histos.fill(HIST("Events/h1f_collisions_info"), kPassSelCol);
869873
histos.fill(HIST("Events/h1f_collision_posZ"), collision.posZ());
870874

871-
float cent = 0.;
872-
873-
if constexpr (run == kRun3) {
874-
cent = collision.centFT0M();
875-
} else {
876-
cent = collision.centRun2V0M();
877-
}
878-
879-
// Multiplicity Selection
880-
if (cent <= cMinMult || cent >= cMaxMult) {
881-
return;
882-
}
883-
884-
histos.fill(HIST("Events/h1f_collisions_info"), kPassMultSelCol);
885-
875+
// Fill Collision Table
886876
lambdaCollisionTable(cent, collision.posX(), collision.posY(), collision.posZ());
887877

888878
// initialize v0track objects
@@ -946,33 +936,10 @@ struct LambdaTableProducer {
946936

947937
// MC Generater Level Tables
948938
template <RunType run, typename C, typename M>
949-
void fillLambdaMcGenTables(C const& collision, M const& mcParticles)
939+
void fillLambdaMcGenTables(C const& mcCollision, M const& mcParticles)
950940
{
951-
histos.fill(HIST("McGen/h1f_collisions_info"), kTotCol);
952-
953-
// Select Collision
954-
if (!collision.has_mcCollision() || !selCollision<run>(collision)) {
955-
return;
956-
}
957-
958-
histos.fill(HIST("McGen/h1f_collisions_info"), kPassSelCol);
959-
960-
float cent = 0.;
961-
if constexpr (run == kRun3) {
962-
cent = collision.centFT0M();
963-
} else {
964-
cent = collision.centRun2V0M();
965-
}
966-
967-
// Multiplicity Selection
968-
if (cent <= cMinMult || cent >= cMaxMult) {
969-
return;
970-
}
971-
972-
histos.fill(HIST("McGen/h1f_collisions_info"), kPassMultSelCol);
973-
974941
// Fill McGen Collision Table
975-
lambdaMCGenCollisionTable(cent, collision.posX(), collision.posY(), collision.posZ());
942+
lambdaMCGenCollisionTable(mcCollision.centFT0M(), mcCollision.posX(), mcCollision.posY(), mcCollision.posZ());
976943

977944
// initialize track objects
978945
ParticleType v0Type = kLambda;
@@ -1074,6 +1041,33 @@ struct LambdaTableProducer {
10741041
}
10751042
}
10761043

1044+
template <RunType run, DMCType dmc, typename M, typename C, typename V, typename T, typename P>
1045+
void analyzeMcRecoGen(M const& mcCollision, C const& collisions, V const& V0s, T const& tracks, P const& mcParticles)
1046+
{
1047+
// Number of Rec Collisions Associated to One Mc Gen Collision
1048+
int nRecCols = collisions.size();
1049+
if (nRecCols != 0) {
1050+
histos.fill(HIST("McGen/h1f_collision_recgen"), nRecCols);
1051+
}
1052+
// Do not analyze if more than one reco collision is accociated to one mc gen collision
1053+
if (nRecCols != 1) {
1054+
return;
1055+
}
1056+
histos.fill(HIST("McGen/h1f_collisions_info"), kTotCol);
1057+
// Check the reco collision
1058+
if (!collisions.begin().has_mcCollision() || !selCollision<run>(collisions.begin()) || collisions.begin().mcCollisionId() != mcCollision.globalIndex()) {
1059+
return;
1060+
}
1061+
histos.fill(HIST("McGen/h1f_collisions_info"), kPassSelCol);
1062+
histos.fill(HIST("McGen/h2f_collision_posZ"), mcCollision.posZ(), collisions.begin().posZ());
1063+
auto v0Tracks = V0s.sliceBy(perCollision, collisions.begin().globalIndex());
1064+
fillLambdaRecoTables<run, dmc>(collisions.begin(), v0Tracks, tracks);
1065+
fillLambdaMcGenTables<run>(mcCollision, mcParticles);
1066+
}
1067+
1068+
SliceCache cache;
1069+
Preslice<soa::Join<aod::V0Datas, aod::McV0Labels>> perCollision = aod::track::collisionId;
1070+
10771071
using CollisionsRun3 = soa::Join<aod::Collisions, aod::EvSels, aod::CentFT0Ms>;
10781072
using CollisionsRun2 = soa::Join<aod::Collisions, aod::EvSels, aod::CentRun2V0Ms>;
10791073
using Tracks = soa::Join<aod::Tracks, aod::TrackSelection, aod::TracksExtra, aod::TracksDCA, aod::pidTPCPi, aod::pidTPCPr, aod::pidTOFPi, aod::pidTOFPr>;
@@ -1094,47 +1088,25 @@ struct LambdaTableProducer {
10941088

10951089
PROCESS_SWITCH(LambdaTableProducer, processDataRun2, "Process for Run2 DATA", false);
10961090

1097-
void processMCRecoRun3(soa::Join<CollisionsRun3, aod::McCollisionLabels>::iterator const& collision,
1098-
aod::McCollisions const&,
1099-
McV0Tracks const& V0s, TracksMC const& tracks,
1100-
aod::McParticles const&)
1091+
void processMCRun3(soa::Join<aod::McCollisions, aod::McCentFT0Ms>::iterator const& mcCollision,
1092+
soa::SmallGroups<soa::Join<CollisionsRun3, aod::McCollisionLabels>> const& collisions,
1093+
McV0Tracks const& V0s, TracksMC const& tracks,
1094+
aod::McParticles const& mcParticles)
11011095
{
1102-
fillLambdaRecoTables<kRun3, kMC>(collision, V0s, tracks);
1096+
analyzeMcRecoGen<kRun3, kMC>(mcCollision, collisions, V0s, tracks, mcParticles);
11031097
}
11041098

1105-
PROCESS_SWITCH(LambdaTableProducer, processMCRecoRun3, "Process for Run3 MC Reconstructed", false);
1099+
PROCESS_SWITCH(LambdaTableProducer, processMCRun3, "Process for Run3 MC Generated", false);
11061100

1107-
void processMCRecoRun2(soa::Join<CollisionsRun2, aod::McCollisionLabels>::iterator const& collision,
1108-
aod::McCollisions const&,
1109-
McV0Tracks const& V0s, TracksMC const& tracks,
1110-
aod::McParticles const&)
1101+
void processMCRun2(soa::Join<aod::McCollisions, aod::McCentFT0Ms>::iterator const& mcCollision,
1102+
soa::SmallGroups<soa::Join<CollisionsRun2, aod::McCollisionLabels>> const& collisions,
1103+
McV0Tracks const& V0s, TracksMC const& tracks,
1104+
aod::McParticles const& mcParticles)
11111105
{
1112-
fillLambdaRecoTables<kRun2, kMC>(collision, V0s, tracks);
1113-
}
1114-
1115-
PROCESS_SWITCH(LambdaTableProducer, processMCRecoRun2, "Process for Run2 MC Reconstructed", false);
1116-
1117-
void processMCGenRun3(aod::McCollisions::iterator const&,
1118-
soa::SmallGroups<soa::Join<CollisionsRun3, aod::McCollisionLabels>> const& collisions,
1119-
aod::McParticles const& mcParticles)
1120-
{
1121-
for (auto const& collision : collisions) {
1122-
fillLambdaMcGenTables<kRun3>(collision, mcParticles);
1123-
}
1124-
}
1125-
1126-
PROCESS_SWITCH(LambdaTableProducer, processMCGenRun3, "Process for Run3 MC Generated", false);
1127-
1128-
void processMCGenRun2(aod::McCollisions::iterator const&,
1129-
soa::SmallGroups<soa::Join<CollisionsRun2, aod::McCollisionLabels>> const& collisions,
1130-
aod::McParticles const& mcParticles)
1131-
{
1132-
for (auto const& collision : collisions) {
1133-
fillLambdaMcGenTables<kRun2>(collision, mcParticles);
1134-
}
1106+
analyzeMcRecoGen<kRun2, kMC>(mcCollision, collisions, V0s, tracks, mcParticles);
11351107
}
11361108

1137-
PROCESS_SWITCH(LambdaTableProducer, processMCGenRun2, "Process for Run2 MC Generated", false);
1109+
PROCESS_SWITCH(LambdaTableProducer, processMCRun2, "Process for Run2 MC Generated", false);
11381110
};
11391111

11401112
struct LambdaTracksExtProducer {

0 commit comments

Comments
 (0)