Skip to content

PWGHF: addition of D0 ML response class#3789

Merged
fgrosa merged 11 commits into
AliceO2Group:masterfrom
atavirag:d0-ml-response
Nov 14, 2023
Merged

PWGHF: addition of D0 ML response class#3789
fgrosa merged 11 commits into
AliceO2Group:masterfrom
atavirag:d0-ml-response

Conversation

@atavirag

@atavirag atavirag commented Nov 6, 2023

Copy link
Copy Markdown
Contributor

Following @AlexBigO's ML response class for Dplus, I made an equivalent class for D0 mesons. I added the variables currently available in treeCreatorD0ToKPi.cxx.

The PR also introduces a subscription in the candidateSelectorD0 to the tables aod::TracksPidPiExt and aod::TracksPidKaExt.

@AlexBigO

AlexBigO commented Nov 7, 2023

Copy link
Copy Markdown
Contributor

Hello @atavirag , I don't have any comments on the header but I have a few regarding the selector, otherwise it looks good to me :)

  1. You should define a configurable array containing the names of the wanted input features: as done here
  2. You need to cache the input indices to translate your configurables input features names into integers (via the enum defined in the header): you can use this line
  3. You should change the way aod::HfMlD0 is filled when a candidate does not pass preselections. This is a bug spotted by Fabio that we corrected in a recent PR for Dplus. The idea is to define an empty vector (see here) and then feed this vector to hfMlD0Candidate when preselections (Skim, Topol, Pid) are not fulfilled by the candidate (as done here for instance).

@atavirag

atavirag commented Nov 7, 2023

Copy link
Copy Markdown
Contributor Author

Hi @AlexBigO, I have just added your comments. Thank you!

}
hfMlResponse.cacheInputFeaturesIndices(namesInputFeatures);
hfMlResponse.init();
outputMl.assign(((std::vector<int>)cutDirMl).size(), -1.f); // dummy value for ML output

@AlexBigO AlexBigO Nov 7, 2023

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.

Everything is okay on my side. Just a minor comment, now you don't need this line (the one where you assign dummy values to the outputMl vector) anymore as the outputMl vector (defined above init) is going to be passed by reference in isSelectedMl.

@fgrosa fgrosa left a comment

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 @atavirag thanks a lot for the implementation! I added few comments regarding variables to remove or add and then the other missing thing to address (not present for the D+) is the way to handle the two possible mass hypotheses for the D0/D0bar candidates.

Comment thread PWGHF/Core/HfMlResponseD0ToKPi.h Outdated
Comment thread PWGHF/Core/HfMlResponseD0ToKPi.h Outdated
Comment thread PWGHF/Core/HfMlResponseD0ToKPi.h Outdated
Comment thread PWGHF/Core/HfMlResponseD0ToKPi.h Outdated
Comment thread PWGHF/Core/HfMlResponseD0ToKPi.h Outdated
Comment thread PWGHF/Core/HfMlResponseD0ToKPi.h Outdated
Comment thread PWGHF/Core/HfMlResponseD0ToKPi.h
Comment thread PWGHF/Core/HfMlResponseD0ToKPi.h Outdated
Comment thread PWGHF/Core/HfMlResponseD0ToKPi.h
Comment thread PWGHF/TableProducer/candidateSelectorD0.cxx Outdated
@atavirag

atavirag commented Nov 9, 2023

Copy link
Copy Markdown
Contributor Author

Hi @fgrosa, I just made a commit changing the variables. I also added the column hf_sel_candidate_d0::MlProbD0bar and, at least for now, made it so that it always tests the BDT output for both mass hypotheses. Please let me know if it's okay or if you'd prefer the other option to fill the table. Thanks!

@fgrosa fgrosa left a comment

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 @atavirag thanks! I still have a couple of suggestions, then I would wait for @fcatalan92's feedback on the table with the two vectors and the decision whether to apply anyway always the ML model to both mass hypotheses (as in your implementation) or instead whether to do it only for the hypothesis which is preselected (maybe better).

Comment thread PWGHF/TableProducer/candidateSelectorD0.cxx Outdated
Comment thread PWGHF/TableProducer/candidateSelectorD0.cxx Outdated
Comment thread PWGHF/TableProducer/candidateSelectorD0.cxx Outdated
Comment thread PWGHF/TableProducer/candidateSelectorD0.cxx Outdated
Comment thread PWGHF/TableProducer/candidateSelectorD0.cxx Outdated
Comment thread PWGHF/TableProducer/candidateSelectorD0.cxx Outdated
Comment thread PWGHF/TableProducer/candidateSelectorD0.cxx Outdated
@fcatalan92

Copy link
Copy Markdown
Collaborator

Hi @atavirag and @fgrosa, I would apply the model only to candidates that pass the pre-selections, so that we do not perform the model computation if not needed. I would also leave the vector empty in case the model is not applied, this prevents to use a wrong information later on, since if the vector is accessed we should get a crash (the correct way should be to check the flag of the ML selection before accessing the ML output).

@fcatalan92 fcatalan92 left a comment

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 @atavirag, thanks for the updates. I added a comment on the code.
Moreover, I have another remark: at the end of the part related to the ML application, you should clear the vectors, otherwise the ML output will be wrongly filled, e.g., also for candidates that do not pass the pre-selections.

Before exiting the if you can do

    outputMlD0.clear();
    outputMlD0bar.clear();

Comment thread PWGHF/TableProducer/candidateSelectorD0.cxx Outdated
@atavirag

Copy link
Copy Markdown
Contributor Author

Hi @atavirag, thanks for the updates. I added a comment on the code. Moreover, I have another remark: at the end of the part related to the ML application, you should clear the vectors, otherwise the ML output will be wrongly filled, e.g., also for candidates that do not pass the pre-selections.

Before exiting the if you can do

    outputMlD0.clear();
    outputMlD0bar.clear();

The vectors are currently being cleared at the beginning of the for loop, in lines 266 and 267. That is, before they get the chance to get filled again. Would it be okay to leave it like that?

@fcatalan92

Copy link
Copy Markdown
Collaborator

The vectors are currently being cleared at the beginning of the for loop, in lines 266 and 267. That is, before they get the chance to get filled again. Would it be okay to leave it like that?

Yes, they are fine. Sorry I missed that!

@fcatalan92 fcatalan92 requested a review from fgrosa November 13, 2023 10:24
@fgrosa fgrosa merged commit 6f39638 into AliceO2Group:master Nov 14, 2023
@atavirag atavirag deleted the d0-ml-response branch November 14, 2023 09:04
@vkucera

vkucera commented Nov 15, 2023

Copy link
Copy Markdown
Collaborator

This PR introduced a bug which prevents the workflow from running.
Fixed in #3872
@atavirag Please always test your changes locally before making a PR.
Also this new subscription should be mentioned in the PR description as it is not directly related to the ML response.

@atavirag

Copy link
Copy Markdown
Contributor Author

This PR introduced a bug which prevents the workflow from running. Fixed in #3872 @atavirag Please always test your changes locally before making a PR. Also this new subscription should be mentioned in the PR description as it is not directly related to the ML response.

I am sorry, thank you for the fix. I will add the subscription to the description.

chengtt0406 pushed a commit to chengtt0406/O2Physics that referenced this pull request Dec 6, 2023
* First version of addition of ML response class for D0s

* Please consider the following formatting changes

* Fix MegaLinter

* Add Alexandre's comments

* Remove dummy value of outputMl

* Add Fabrizio's suggestions

* Add new suggestions

* add Fabio's suggestions

* Always fill hfMlD0Candidate table

---------

Co-authored-by: ALICE Action Bot <alibuild@cern.ch>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

6 participants