Skip to content

[PWGHF] Adding option to include reconstructed rapidity in MC THnSparse in D2H/Tasks/taskDplus.cxx - #18828

Open
lmattei01 wants to merge 8 commits into
AliceO2Group:masterfrom
lmattei01:myBranch_new
Open

lmattei01 wants to merge 8 commits into
AliceO2Group:masterfrom
lmattei01:myBranch_new

Conversation

@lmattei01

@lmattei01 lmattei01 commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Adding option to include reconstructed rapidity in MC THnSparse in D2H/Tasks/taskDplus.cxx

@github-actions

Copy link
Copy Markdown

O2 linter results: ❌ 0 errors, ⚠️ 0 warnings, 🔕 0 disabled

@github-actions github-actions Bot changed the title Adding option to include reconstructed rapidity in MC THnSparse [PWGHF] Adding option to include reconstructed rapidity in MC THnSparse Nov 20, 2026
@vkucera

vkucera commented Nov 20, 2026

Copy link
Copy Markdown
Collaborator

Hi @lmattei01 , who are you?

@vkucera

vkucera commented Nov 20, 2026

Copy link
Copy Markdown
Collaborator

@lmattei01 Please fix the title. It does not mention which part of HF you changed.

@lmattei01 lmattei01 changed the title [PWGHF] Adding option to include reconstructed rapidity in MC THnSparse [PWGHF] Adding option to include reconstructed rapidity in MC THnSparse in D2H/Tasks/taskDplus.cxx Nov 20, 2026
@lmattei01

Copy link
Copy Markdown
Contributor Author

@lmattei01 Please fix the title. It does not mention which part of HF you changed.

Hi @vkucera , thanks for the suggestion. I am a PhD student working on Jpsi-D+ associated production and I need reconstructed rapidity in the THnSparse of D+ on order to create 2D efficiency maps (pT vs y)

@vkucera

vkucera commented Nov 20, 2026

Copy link
Copy Markdown
Collaborator

@lmattei01 Please fix the title. It does not mention which part of HF you changed.

Hi @vkucera , thanks for the suggestion. I am a PhD student working on Jpsi-D+ associated production and I need reconstructed rapidity in the THnSparse of D+ on order to create 2D efficiency maps (pT vs y)

I meant your name. Please add it on your profile and check the rest of the contribution guidelines.

Comment thread PWGHF/D2H/Tasks/taskDplus.cxx Outdated
if (storeRecRapidity) {
axes.push_back(thnAxisY);
axesFD.push_back(thnAxisY);
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest you to put it at the end of all the configurable axes (after the other if (store...)); this because other analysers expect axes in a given position, and adding this now might change the position of axes in the outputs, creating confusion in other analyses

Comment thread PWGHF/D2H/Tasks/taskDplus.cxx Outdated
Comment on lines +375 to +376
} else if (!storeCentrality && !storeOccupancy && storeRecRapidity) {
registry.fill(HIST("hSparseMassPrompt"), HfHelper::invMassDplusToPiKPi(candidate), candidate.pt(), outputMl[0], outputMl[1], outputMl[2], HfHelper::yDplus(candidate));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should in principle add all the combinations, in fact currently if a user enables rapidity the rapidity with other optional variables, it gives a runtime error (or you forbid the activation of rapidity with other optional variables, throwing a FATAL with a meaningful error message)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lmattei01, one more suggestion: you can pack all the values to be filled (depending on boolean configurables) to the vector and then call the Fill() function only once. Otherwise when you attempt to foresee all the combinations, the number of LOC will grow in geometric progression.
As a reference you can have a look at the similar code for Lc baryon https://github.com/AliceO2Group/O2Physics/blob/dfbc8da2c9f7ff7cbd1f2cfed3787a3a45510ebb/PWGHF/D2H/Tasks/taskLc.cxx

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @fgrosa and @lubynets , thanks a lot for your suggestions. I have implemented the suggested changes, could you have a look? I only modified the part related to MC Rec, as the code for MC Gen and data was already good for my scopes

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello Lorenzo, thanks for implementing the suggestions! They look fine for me with two notes:

  • subtraction of "2" in the FD vector size when reserving it (I commented in the code);
  • the added rapidity axis (and vector element) is still in front of two FD-specific values, PtBHad and FlagBHad. But let Fabrizio comment on it whether it is critical.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @lubynets, since all the optional axes are added before the B-related ones, I think it's OK to keep it as it is now (I guess analysers are expecting the two additional B axes in the last positions). Also I think it's good to have the common axes in the same position for prompt and non-prompt sparses.

Please consider the following formatting changes to AliceO2Group#18828
Comment thread PWGHF/D2H/Tasks/taskDplus.cxx Outdated
registry.fill(HIST("hSparseMassFD"), HfHelper::invMassDplusToPiKPi(candidate), candidate.pt(), outputMl[0], outputMl[1], outputMl[2], numPvContributors, ptbhad, flagBHad, HfHelper::yDplus(candidate));
} else {
registry.fill(HIST("hSparseMassFD"), HfHelper::invMassDplusToPiKPi(candidate), candidate.pt(), outputMl[0], outputMl[1], outputMl[2], ptbhad, flagBHad);
valuesToFillMcRec.reserve(registry.get<THnSparse>(HIST("hSparseMassFD"))->GetNdimensions() - 2);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you subtract 2?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I subtract 2 because the two additional B axes are declared at the beginning but only filled later on, using "push_back". So I wanted to reserve (NdimensionFD - 2), which is the number of data I insert in the sparse right away

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure that understand your point. First of all, the statement about 2 FD-specific values is also applicable to any optional value, say rapidity - you push_back() them, not insert(). And secondly, due to underreservation the vector size you may lose the performance because of data reallocation when two last push_back() are called.
But the most curious thing for me is what is your motivation to reserve less elements than eventually the vector will have?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had some bad memory about allocation rules for vectors.
Sorry for the mess with the commits, it should be solved now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pwghf PWG-HF

Development

Successfully merging this pull request may close these issues.

5 participants