Namespace: Met
-
namespace met
Functions
-
ROOT::RDF::RNode RecoilCorrection(ROOT::RDF::RNode df, correctionManager::CorrectionManager &correction_manager, const std::string &outputname, const std::string &p4_met, const std::string &p4_gen_boson, const std::string &p4_vis_gen_boson, const std::string &n_jets, const std::string &corr_file, const std::string &corr_name, const std::string &method, const std::string &order, const std::string &variation, bool apply_correction)
This function is used to apply recoil corrections on a given sample. It is only recommented to apply it to single boson samples, like Z, W or Higgs boson. The corrections are provided by the HLepRare group. For more information on how the recoil corrections were calculated and have to be used, check out this presentation. and the HLepRare group documentation.
Note
This function is intended to be used in Run3 where recoil corrections are provided in json files to be read by correctionlib. For Run2 recoil correction see the overloaded version of this function.
- Parameters:
df – input dataframe
correction_manager – correction manager responsible for loading the recoil corrections file
outputname – name of the new column containing the corrected MET Lorentz vector
p4_met – initial/uncorrected MET Lorentz vector
p4_gen_boson – name of the column containing the generator-level boson Lorentz vector
p4_vis_gen_boson – name of the column containing the visible part of the generator-level boson Lorentz vector
n_jets – name of the column containing the number of good jets in an event
corr_file – path to the json file with the recoil corrections
corr_name – name of the recoil correction, this is the first part of the correction string in the json file (e.g. “Recoil_correction”)
method – method to be used to apply the corrections, possible options are “Rescaling”, “QuantileMapHist” and “Uncertainty” (second part of the correction string)
order – order of the used DY samples: “LO” for madgraph, “NLO” for amc@nlo, “NNLO” for powheg
variation – name of the variation that should be evaluated, options are “nom”, “RespUp”, “RespDown”, “ResolUp”, “ResolDown”. This is only used if
methodis set to “Uncertainty”.apply_correction – if bool is set to true, the recoil correction is applied, if not, the output column contains the original MET vector
- Returns:
a new dataframe containing the new MET column
-
ROOT::RDF::RNode RecoilCorrection(ROOT::RDF::RNode df, const std::string &outputname, const std::string &p4_met, const std::string &p4_gen_boson, const std::string &p4_vis_gen_boson, const std::string &jet_pt, const std::string &corr_file, const std::string &syst_file, const bool apply_correction, const bool resolution, const bool response, const bool shift_up, const bool shift_down, const bool is_Wjets)
This function applies Recoil corrections on a given sample. For more information on recoil corrections, check this repo. The code for the application of these corrections can be found in
src/RecoilCorrections. This correction is applicable for processes involving W and Z bosons.Warning
The corrections are derived by the H(tautau) group for the legacy analyses of Run2. They are not up to standard with the correctionlib json format, therefore, to be used with caution.
- Parameters:
df – input dataframe
outputname – name of the new column containing the corrected MET
p4_met – initial/uncorrected MET Lorentz vector
p4_gen_boson – name of the column containing the generator-level boson Lorentz vector
p4_vis_gen_boson – name of the column containing the visible part of the generator-level boson Lorentz vector
jet_pt – name of the column containing the \(p_T\) of all jets in an event
corr_file – path to the recoil corrections file
syst_file – path to the systematics corrections file
apply_correction – if bool is set to true, the recoil correction is applied, if not, the output column contains the original MET vector
resolution – bool - if set, resolution corrections are applied
response – bool - if set, response corrections are applied
shift_up – bool - if set, the up shift is applied
shift_down – bool - if set, the down shift is applied
is_Wjets – bool - if set, the number of jets is incrased by one (this is only needed for W+jets samples)
- Returns:
a dataframe containing a new column with the new MET vector
-
ROOT::RDF::RNode METPhiCorrection(ROOT::RDF::RNode df, const std::string &outputname, const std::string &p4_met, const std::string &n_pv, const std::string &run, const std::string &corr_file, const std::string &corr_name)
This function applies MET \(\phi\) corrections as provided by JME POG for Run2 in correction JSON files.
Note
This function is only valid for Run2 data and MC. For Run3 the overloaded version of this function should be used.
- Parameters:
df – input dataframe
outputname – name of the new column containing the corrected MET Lorentz vector
p4_met – initial/uncorrected MET Lorentz vector
n_pv – name of the column containing the number of primary vertices in the event
run – name of the column containing the run number
corr_file – path to the file containing the correction
corr_name – name of the correction to be applied, e.g. “metphicorr_pfmet_mc”, possible options are “puppimet” instead of “pfmet” or “data” instead of “mc”
- Returns:
a dataframe with the new column containing the corrected MET Lorentz vector
-
ROOT::RDF::RNode METPhiCorrection(ROOT::RDF::RNode df, const std::string &outputname, const std::string &p4_met, const std::string &n_pv, const std::string &corr_file, const std::string &corr_name, const std::string &met_type, const std::string &era, const bool is_mc, const std::string &stat_variation, const std::string &pileup_variation)
This function applies MET \(\phi\) corrections as provided by JME POG for Run3 in correction JSON files.
Note
This function is only valid for Run3 data and MC. For Run2 the overloaded version of this function should be used.
- Parameters:
df – input dataframe
outputname – name of the new column containing the corrected MET Lorentz vector
p4_met – initial/uncorrected MET Lorentz vector
n_pv – name of the column containing the number of primary vertices in the event
corr_file – path to the file containing the correction
corr_name – name of the correction to be applied, e.g. “met_xy_corrections”
met_type – type of the MET, possible options are “PuppiMET” and “MET” (for PF)
era – data-taking period, possible options are e.g. “2022”, “2022EE”, “2023”, “2023BPix”
is_mc – boolean indicating whether the sample is MC or data
stat_variation – name of the statistical variation, possible options are “nom”, “xup”, “xdn”, “yup”, “ydn”
pileup_variation – name of the pileup variation, possible options are “nom”, “pu_up”, “pu_dn”
- Returns:
a dataframe with the new column containing the corrected MET Lorentz vector
-
ROOT::RDF::RNode Type1Correction(ROOT::RDF::RNode df, const std::string &outputname, const std::string &raw_met, const std::string &jet_pt_l1corr, const std::string &jet_pt_corr, const std::string &jet_phi, const std::string &jet_muon_subtr_delta_phi, const std::string &jet_ch_em_ef, const std::string &jet_ne_em_ef, const std::string &low_pt_jet_phi, const std::string &low_pt_jet_muon_subtr_delta_phi, const std::string &low_pt_jet_em_ef)
Applies Type-1 MET corrections by propagating jet energy corrections to the MET vector.
This function combines information from both corrected and uncorrected jets to update the MET vector. It concatenates jet kinematic variables and electromagnetic fractions, then applies Type-1 corrections by subtracting the difference between fully corrected and L1-corrected jet transverse momenta for jets passing selection criteria. Only jets with $p_T > 15$ GeV and $\mathrm{EmEF} < 0.9$ are propagated to MET.
Note
To be used for v15 nanoAOD samples to both data and MC.
- Parameters:
df – input dataframe
outputname – name of the new column containing the corrected MET Lorentz vector
raw_met – name of the column with the initial/uncorrected MET Lorentz vector
jet_pt_l1corr – name of the column with L1-corrected jet $p_T$’s
jet_pt_corr – name of the column with fully corrected jet $p_T$’s
jet_phi – name of the column with jet $\phi$’s
jet_muon_subtr_delta_phi – name of the column with the $\phi$ difference between before muon subtraction and after muon subtraction for jets
jet_ch_em_ef – name of the column with jet charged electromagnetic fraction
jet_ne_em_ef – name of the column with jet neutral electromagnetic fraction
low_pt_jet_phi – name of the column with corrected jet $\phi$’s
low_pt_jet_muon_subtr_delta_phi – name of the column with the $\phi$ difference between before muon subtraction and after muon subtraction for low-pt jets
low_pt_jet_em_ef – name of the column with low-pt jet electromagnetic fraction
- Returns:
a new dataframe with the new MET column
-
ROOT::RDF::RNode Type1Correction(ROOT::RDF::RNode df, const std::string &outputname, const std::string &raw_met, const std::string &jet_pt_l1corr, const std::string &jet_pt_corr, const std::string &jet_phi, const std::string &jet_ch_em_ef, const std::string &jet_ne_em_ef, const std::string &low_pt_jet_phi)
Applies Type-1 MET corrections by propagating jet energy corrections to the MET vector.
This function combines information from both corrected and uncorrected jets to update the MET vector. It concatenates jet kinematic variables and electromagnetic fractions, then applies Type-1 corrections by subtracting the difference between fully corrected and L1-corrected jet transverse momenta for jets passing selection criteria. Only jets with $p_T > 15$ GeV and $\mathrm{EmEF} < 0.9$ are propagated to MET.
Note
To be used for v9/v12 nanoAOD samples to both data and MC.
- Parameters:
df – input dataframe
outputname – name of the new column containing the corrected MET Lorentz vector
raw_met – name of the column with the initial/uncorrected MET Lorentz vector
jet_pt_l1corr – name of the column with L1-corrected jet $p_T$’s
jet_pt_corr – name of the column with fully corrected jet $p_T$’s
jet_phi – name of the column with jet $\phi$’s
jet_ch_em_ef – name of the column with jet charged electromagnetic fraction
jet_ne_em_ef – name of the column with jet neutral electromagnetic fraction
low_pt_jet_phi – name of the column with corrected jet $\phi$’s
- Returns:
A new DataFrame with the corrected MET column.
-
template<typename ...Lorentzvectors>
ROOT::RDF::RNode GetHadronicRecoil(ROOT::RDF::RNode df, const std::string &outputname, const std::string &p4_met, Lorentzvectors... lorentzvectors) Calculates the hadronic recoil and its components parallel and perpendicular to a visible system’s momentum. The recoil is a crucial observable in analyses with invisible particles (like neutrinos).
The hadronic recoil ( \(\vec{u}_T\)) is defined as the vector sum of the transverse momenta of all hadronic particles in the event. By momentum conservation in the transverse plane, it must balance the momentum of the hard-scatter system (visible leptons/photons and invisible MET).
It is calculated as:
\[ \vec{u}_T = -(\vec{p}_T^{\text{visible}} + \vec{p}_T^{\text{miss}}) \]where \(\vec{p}_T^{\text{visible}}\) is the vector sum of the transverse momenta of the specified input Lorentz vectors (e.g., \(\vec{p}_{T, \ell\ell}\) for a Z boson event). The function then projects this recoil vector onto the axis defined by the direction of the visible system’s transverse momentum, \(\hat{q}_T = \frac{\vec{p}_T^{\text{visible}}}{|\vec{p}_T^{\text{visible}}|}\).**Parallel Component ( \(u_\parallel\))**: The projection of the recoil onto the visible system’s axis. It is a measure of the recoil’s response.
\[ u_\parallel = \vec{u}_T \cdot \hat{q}_T \]**Perpendicular Component ( \(u_\perp\))**: The component of the recoil orthogonal to the visible system’s axis. It is a measure of the recoil’s resolution.
\[ u_\perp = |\vec{u}_T \times \hat{q}_T| \](calculated with a sign).
The function returns a vector of two doubles:
{u_parallel, u_perp}.Warning
Implemented calculation was not cross checked.
- Template Parameters:
Lorentzvectors – variadic template parameter pack representing Lorentz vectors
- Parameters:
df – input dataframe
outputname – name of the new column containing a
std::vector<double>with the parallel and perpendicular recoil componentsp4_met – name of the column containing the MET Lorentz vector
lorentzvectors – parameter pack of column names containing Lorentz vectors of visible particles (e.g., “Lepton_p4_1”, “Lepton_p4_2”).
- Returns:
a dataframe with the new column containing parallel and perpendicular recoil components
-
ROOT::RDF::RNode RecoilCorrection(ROOT::RDF::RNode df, correctionManager::CorrectionManager &correction_manager, const std::string &outputname, const std::string &p4_met, const std::string &p4_gen_boson, const std::string &p4_vis_gen_boson, const std::string &n_jets, const std::string &corr_file, const std::string &corr_name, const std::string &method, const std::string &order, const std::string &variation, bool apply_correction)