Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional functions for hadronic recoil quantities #273

Open
wants to merge 15 commits into
base: nmssm_devs
Choose a base branch
from

Conversation

moritzmolch
Copy link

@moritzmolch moritzmolch commented Jul 17, 2024

This pull request introduces functions to calculate quantities, which are related to the hadronic recoil in an event.

  • hadrecoil::scalar_ht takes a jet pt column and a column with indices of selected jets as input. The output is the scalar sum of the magnitude of the transverse momentum of the selected jets.

  • hadrecoil::vectorial_mht takes a jet pt column, a jet phi column and a column with indices of selected jets as input. The output is the negative vectorial sum of the transverse momentum vectors of the selected jets.

TODOs:

  • add documentation strings to the new functions
  • Add producers to the python configuration

@moritzmolch
Copy link
Author

Producers have been added to the config via this pull request: KIT-CMS/TauAnalysis-CROWN#50.

// add up the negative pt vectors of all selected jets
auto mht = ROOT::Math::PtEtaPhiMVector(0., 0., 0., 0.);
for (const int &jet_index : jet_collection) {
auto jet_pt_vec = dynamic_cast<ROOT::Math::PtEtaPhiMVector>(ROOT::Math::PtEtaPhiEVector(jet_pt.at(jet_index), jet_eta.at(jet_index), 0., jet_pt.at(jet_index)));
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not use pt, eta, phi and Mass of the jets, this information is available in NanoAOD

// add up the magnitudes of the pt of all selected jets
float ht = 0;
for (const int &jet_index : jet_collection) {
ht += jet_pt.at(jet_index);
Copy link
Contributor

Choose a reason for hiding this comment

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

I would like to see thisa implemented as a a basefunction in a more generic way

auto mht = ROOT::Math::PtEtaPhiMVector(0., 0., 0., 0.);
for (const int &jet_index : jet_collection) {
auto jet_pt_vec = dynamic_cast<ROOT::Math::PtEtaPhiMVector>(ROOT::Math::PtEtaPhiEVector(jet_pt.at(jet_index), jet_eta.at(jet_index), 0., jet_pt.at(jet_index)));
mht -= jet_pt_vec;
Copy link
Contributor

Choose a reason for hiding this comment

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

same as above, implement as a basefunction (maybe the negative sum as well as the positive)

Copy link
Contributor

@harrypuuter harrypuuter left a comment

Choose a reason for hiding this comment

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

one remark to use RVec::Construct rest looks good!

Comment on lines 167 to 188
inline ROOT::RDF::RNode BuildP4Collection(ROOT::RDF::RNode df,
const std::string &outputname,
const std::string &pts,
const std::string &etas,
const std::string &phis,
const std::string &masses,
const std::string &collection_index) {
auto build_collection_p4 = [](const ROOT::RVec<float> &pts,
const ROOT::RVec<float> &etas,
const ROOT::RVec<float> &phis,
const ROOT::RVec<float> &masses,
const ROOT::RVec<int> &collection_index) {
auto p4s = ROOT::RVec<ROOT::Math::PtEtaPhiMVector>();
for (int i = 0; i < collection_index.size(); ++i) {
auto p4 = ROOT::Math::PtEtaPhiMVector(pts.at(i), etas.at(i), phis.at(i), masses.at(i));
p4s.push_back(p4);
}
return p4s;
};
return df.Define(outputname, build_collection_p4, {pts, etas, phis, masses, collection_index});
}

Copy link
Contributor

Choose a reason for hiding this comment

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

There is https://root.cern/doc/master/group__vecops.html#ga84ffef84f7829e9d904cd92a57a0cd9a to further shorten this code and eliminate the for-loop

@moritzmolch
Copy link
Author

@harrypuuter I added your suggestions, the compiled binary runs on a DY sample without errors. I still have to check if the functions' outputs are reasonable.

Copy link
Contributor

@harrypuuter harrypuuter left a comment

Choose a reason for hiding this comment

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

looks good, I approve and you just merge it ones the results are validated

@nshadskiy
Copy link
Contributor

nshadskiy commented Jul 24, 2024

Thanks for all the checks @harrypuuter ! As it is now this PR would only be merged to my nmssm_devs branch. I guess we could merge it directly into the main branch, since nothing directly related to the NMSSM analysis is involved in the code changes.

@harrypuuter
Copy link
Contributor

yes, i would merge this directly to main as well

@moritzmolch moritzmolch changed the base branch from nmssm_devs to main July 25, 2024 08:09
@moritzmolch moritzmolch changed the base branch from main to nmssm_devs July 25, 2024 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants