diff --git a/HZallyyAnalysis/python/llyy_config.py b/HZallyyAnalysis/python/llyy_config.py index 8fe276f9cb323c9217151b4c1f488dd56c1a45be..92674844d42476aefa3cb73a80b4e6a3f38e2e3d 100644 --- a/HZallyyAnalysis/python/llyy_config.py +++ b/HZallyyAnalysis/python/llyy_config.py @@ -1,22 +1,26 @@ from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator from AthenaConfiguration.ComponentFactory import CompFactory import AthenaCommon.SystemOfUnits as Units +from itertools import chain from AthenaConfiguration.Enums import LHCPeriod from EasyjetHub.algs.postprocessing.SelectorAlgConfig import ( MuonSelectorAlgCfg, ElectronSelectorAlgCfg, LeptonOrderingAlgCfg, PhotonSelectorAlgCfg, JetSelectorAlgCfg) from EasyjetHub.output.ttree.selected_objects import ( - get_selected_objects_branches_variables, + get_selected_lepton_branches_variables, + get_selected_photon_branches_variables, ) def llyy_cfg(flags, smalljetkey, muonkey, electronkey, photonkey, float_variables=None, int_variables=None): + keys = ["photons", "leptons", "baseline"] if not float_variables: - float_variables = [] + float_variables = {key: [] for key in keys} if not int_variables: - int_variables = [] + int_variables = {key: [] for key in keys} + cfg = ComponentAccumulator() PhotonWPLabel = f'{flags.Analysis.Photon.ID}_{flags.Analysis.Photon.Iso}' @@ -71,38 +75,71 @@ def llyy_cfg(flags, smalljetkey, muonkey, electronkey, photonkey, ) # calculate final llyy vars cfg.addEventAlgo( - CompFactory.HZALLYY.BaselineVarsllyyAlg( - "FinalVarsllyyAlg", + CompFactory.HZALLYY.PhotonVarsAlg( + "PhotonVarsAlg", + isMC=flags.Input.isMC, + phWP=PhotonWPLabel, + photons=photonkey, + floatVariableList=float_variables['photons'], + intVariableList=int_variables['photons'], + ) + ) + # calculate final llyy vars + + cfg.addEventAlgo( + CompFactory.HZALLYY.LeptonVarsAlg( + "LeptonVarsAlg", isMC=flags.Input.isMC, muonWP=MuonWPLabel, eleWP=ElectronWPLabel, saveDummyEleSF=flags.GeoModel.Run is LHCPeriod.Run2, - phWP=PhotonWPLabel, muons=muonkey, electrons=electronkey, - photons=photonkey, - floatVariableList=float_variables, - intVariableList=int_variables + floatVariableList=float_variables['leptons'], + intVariableList=int_variables['leptons'], + ) + ) + cfg.addEventAlgo( + CompFactory.HZALLYY.BaselineVarsAlg( + "BaselineVarsAlg", + floatVariableList=float_variables['baseline'], + intVariableList=int_variables['baseline'], ) ) return cfg -def get_BaselineVarsllyyAlg_variables(flags): +def get_PhotonVarsAlg_variables(flags): float_variable_names = [] int_variable_names = [] - for object in ["ll", "yy", "H_Za"]: - for var in ["m", "pT", "Eta", "Phi", "dR", "dEta", "dPhi"]: - float_variable_names.append(f"{var}{object}") + int_variable_names = ["nPhotons"] + return float_variable_names, int_variable_names - for object in ["yy"]: - for var in ["X"]: - float_variable_names.append(f"{var}{object}") - int_variable_names += ["nElectrons", "nMuons", "nPhotons", "nJets"] +def get_LeptonVarsAlg_variables(flags): + float_variable_names = [] + int_variable_names = [] + int_variable_names += ["nLeptons", "nElectrons", "nMuons"] + float_variable_names += ["mll", "pTll", "Etall", "Phill", "dRll", + "dEtall", "dPhill"] + return float_variable_names, int_variable_names + + +def get_BaselineVarsAlg_variables(flags): + + float_variable_names = [] + int_variable_names = [] + float_variable_names += ["res_myy", "res_pTyy", "res_Etayy", "res_Phiyy", + "res_dRyy", "res_dEtayy", "res_dPhiyy", "res_Xyy", + "res_Ph1ptOvermyy", "res_Ph2ptOvermyy"] + float_variable_names += ["res_mH_Za", "res_pTH_Za", "res_EtaH_Za", "res_PhiH_Za", + "res_dRH_Za", "res_dEtaH_Za", "res_dPhiH_Za"] + float_variable_names += ["mer_mH_Za", "mer_pTH_Za", "mer_EtaH_Za", "mer_PhiH_Za", + "mer_dRH_Za", "mer_dEtaH_Za", "mer_dPhiH_Za"] + int_variable_names += ["isResolved_Event", "isMerged_Event"] return float_variable_names, int_variable_names @@ -117,36 +154,35 @@ def llyy_branches(flags): branches = [] # this will be all the variables that are calculated by the - # BaselineVarsllyyAlg algorithm + # PhotonVarsllyyAlg algorithm + all_baseline_variable_names = [] - float_variable_names = [] - int_variable_names = [] + keys = ["baseline", "photons", "leptons"] + float_variable_names = {key: [] for key in keys} + int_variable_names = {key: [] for key in keys} - # these are the variables that will always be stored by easyjet specific to HHbbtt + # these are the variables that will always be stored by easyjet specific to analysis # further below there are more high level variables which can be # stored using the flag # flags.Analysis.store_high_level_variables baseline_float_variables, baseline_int_variables \ - = get_BaselineVarsllyyAlg_variables(flags) - float_variable_names += baseline_float_variables - int_variable_names += baseline_int_variables - - if flags.Analysis.do_mmc: - # do not append mmc variables to float_variable_names - # or int_variable_names as they are stored by the - # mmc algortithm not BaselineVarsllyyAlg - for var in ["status", "pt", "eta", "phi", "m"]: - all_baseline_variable_names.append(f"mmc_{var}") - - if flags.Analysis.store_high_level_variables: - high_level_float_variables, high_level_int_variables \ - = get_BaselineVarsllyyAlg_highlevelvariables(flags) - float_variable_names += high_level_float_variables - int_variable_names += high_level_int_variables + = get_BaselineVarsAlg_variables(flags) + photon_float_variables, photon_int_variables \ + = get_PhotonVarsAlg_variables(flags) + lepton_float_variables, lepton_int_variables \ + = get_LeptonVarsAlg_variables(flags) + + float_variable_names['photons'] += photon_float_variables + int_variable_names['photons'] += photon_int_variables + float_variable_names['leptons'] += lepton_float_variables + int_variable_names['leptons'] += lepton_int_variables + float_variable_names['baseline'] += baseline_float_variables + int_variable_names['baseline'] += baseline_int_variables all_baseline_variable_names += [ - *float_variable_names, - *int_variable_names] + *chain.from_iterable(float_variable_names.values()), + *chain.from_iterable(int_variable_names.values())] + for var in all_baseline_variable_names: branches += [f"EventInfo.{var}_%SYS% -> llyy_{var}" + flags.Analysis.systematics_suffix_separator + "%SYS%"] @@ -154,15 +190,28 @@ def llyy_branches(flags): # These are the variables always saved with the objects selected by the analysis # This is tunable with the flags amount and variables # in the object configs. - object_level_branches, object_level_float_variables, object_level_int_variables \ - = get_selected_objects_branches_variables(flags, "llyy") - float_variable_names += object_level_float_variables - int_variable_names += object_level_int_variables + object_level_branches = {key: [] for key in keys} + object_level_float_variables = {key: [] for key in keys} + object_level_int_variables = {key: [] for key in keys} + + (object_level_branches['photons'], + object_level_float_variables['photons'], + object_level_int_variables['photons']) = \ + get_selected_photon_branches_variables(flags, "llyy") + + float_variable_names['photons'] += object_level_float_variables['photons'] + int_variable_names['photons'] += object_level_int_variables["photons"] - branches += object_level_branches + (object_level_branches['leptons'], + object_level_float_variables['leptons'], + object_level_int_variables['leptons']) = \ + get_selected_lepton_branches_variables(flags, "llyy") - branches += ["EventInfo.llyy_pass_sr_%SYS% -> llyy_pass_SR" - + flags.Analysis.systematics_suffix_separator + "%SYS%"] + float_variable_names['leptons'] += object_level_float_variables['leptons'] + int_variable_names['leptons'] += object_level_int_variables['leptons'] + + branches += object_level_branches["leptons"] + branches += object_level_branches["photons"] if (flags.Analysis.save_cutflow): cutList = flags.Analysis.CutList @@ -170,15 +219,4 @@ def llyy_branches(flags): branches += [f"EventInfo.{cut}_%SYS% -> llyy_{cut}" + flags.Analysis.systematics_suffix_separator + "%SYS%"] - # trigger variables do not need to be added to variable_names - # as it is written out in HHllyySelectorAlg - if flags.Analysis.store_high_level_variables: - branches += ["EventInfo.llyy_pass_sr_%SYS% -> llyy_pass_SR" - + flags.Analysis.systematics_suffix_separator + "%SYS%"] - - for cat in ["SLT", "DLT"]: - branches += \ - [f"EventInfo.pass_trigger_{cat}_%SYS% -> llyy_pass_trigger_{cat}" - + flags.Analysis.systematics_suffix_separator + "%SYS%"] - return (branches, float_variable_names, int_variable_names) diff --git a/HZallyyAnalysis/share/RunConfig-llyy.yaml b/HZallyyAnalysis/share/RunConfig-llyy.yaml index 7b4dda0613e32af794cadac237d66850e130c036..9fe64b146992c1b665599cc707b3742682dec159 100644 --- a/HZallyyAnalysis/share/RunConfig-llyy.yaml +++ b/HZallyyAnalysis/share/RunConfig-llyy.yaml @@ -14,7 +14,6 @@ do_small_R_jets: true do_muons: true do_electrons: true do_met : false -do_mmc : false do_photons : true # Toggles for reconstructed objects decorations @@ -38,21 +37,19 @@ Lepton: Photon: ID: "Loose" - Iso: "NonIso" + Iso: "FixedCutLoose" amount: 2 + # orthogonality studies orthogonality: include: EasyjetHub/orth-config.yaml - do_orth_check: false # if set to true, this will just add more information to your output ntuple on whether events fall into HH-like categories - it will not remove events (assuming overlap removal including all objects does not have an impact on your analysis) + do_orth_check: false # list of triggers per year to consider Trigger: include: HZallyyAnalysis/trigger.yaml -# apply trigger lists to filter events -do_trigger_filtering: true -# write objects with overlap removal applied -# turning this on you have to decide on one large R jet collection +do_trigger_filtering: true do_overlap_removal: true #Enable cutflow @@ -62,7 +59,11 @@ CutList : - PASS_TRIGGER - EXACTLY_TWO_LEPTONS - TWO_OPPOSITE_CHARGE_LEPTONS - - ATLEAST_TWO_PHOTONS + - LEP1_LEP2_DR + - LEP1_LEP2_PT + - DILEP_MASS + - DILEP_PT + - ATLEAST_ONE_PHOTON # Include the TTree configuration and update details diff --git a/HZallyyAnalysis/src/BaselineVarsAlg.cxx b/HZallyyAnalysis/src/BaselineVarsAlg.cxx new file mode 100644 index 0000000000000000000000000000000000000000..af2b90cc519a7d3df50a30de9ba9db27f3010bed --- /dev/null +++ b/HZallyyAnalysis/src/BaselineVarsAlg.cxx @@ -0,0 +1,180 @@ +/* + Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration +*/ + +#include "BaselineVarsAlg.h" +#include "AthContainers/AuxElement.h" +#include "TLorentzVector.h" +#include <AthenaKernel/Units.h> +namespace HZALLYY { + BaselineVarsAlg::BaselineVarsAlg(const std::string & name, + ISvcLocator * pSvcLocator): AthHistogramAlgorithm(name, pSvcLocator) { + + } + + StatusCode BaselineVarsAlg::initialize() { + ATH_MSG_INFO("*********************************\n"); + ATH_MSG_INFO(" BaselineVarsAlg \n"); + ATH_MSG_INFO("*********************************\n"); + + // Read syst-aware input handles + ATH_CHECK(m_eventHandle.initialize(m_systematicsList)); + + // Intialise syst-aware output decorators + for (const std::string &var: m_floatVariables) { + CP::SysWriteDecorHandle < float > whandle {var +"_%SYS%", this}; + m_Fbranches.emplace(var, whandle); + ATH_CHECK(m_Fbranches.at(var).initialize(m_systematicsList, m_eventHandle)); + } + + for (const std::string &var: m_intVariables) { + ATH_MSG_DEBUG("initializing integer variable: " <<var); + CP::SysWriteDecorHandle < int > whandle {var +"_%SYS%", this}; + m_Ibranches.emplace(var, whandle); + ATH_CHECK(m_Ibranches.at(var).initialize(m_systematicsList, m_eventHandle)); + }; + + for (const auto& particle : {"Lepton", "Photon"}) { + for (int i = 1; i <= 2; ++i) { + std::string base = std::string(particle) + std::to_string(i); + for (const auto& var : {"pt", "eta", "phi", "E"}) { + m_fvars.emplace_back(base + "_" + var); + } + } + } + for (const std::string &string_var: m_fvars) { + CP::SysReadDecorHandle<float> var {string_var+"_%SYS%", this}; + m_FDecors.emplace(string_var, var); + ATH_CHECK (m_FDecors.at(string_var).initialize(m_systematicsList, m_eventHandle)); + } + + for (const std::string &string_var: m_ivars) { + CP::SysReadDecorHandle<int> var {string_var+"_%SYS%", this}; + m_IDecors.emplace(string_var, var); + ATH_CHECK (m_IDecors.at(string_var).initialize(m_systematicsList, m_eventHandle)); + } + + // Intialise syst list (must come after all syst-aware inputs and outputs) + ATH_CHECK(m_systematicsList.initialize()); + + return StatusCode::SUCCESS; + } + + StatusCode BaselineVarsAlg::execute() { + + // Loop over all systs + for (const auto & sys: m_systematicsList.systematicsVector()) { + + // Retrieve inputs + const xAOD::EventInfo * event = nullptr; + ANA_CHECK(m_eventHandle.retrieve(event, sys)); + + for (const std::string & string_var: m_floatVariables) { + m_Fbranches.at(string_var).set( * event, -99., sys); + } + + for (const auto &var: m_intVariables) { + m_Ibranches.at(var).set( * event, -99, sys); + } + + TLorentzVector Leading_lep(0.,0.,0.,0.); + TLorentzVector Subleading_lep(0.,0.,0.,0.); + TLorentzVector Leading_photon(0.,0.,0.,0.); + TLorentzVector Subleading_photon(0.,0.,0.,0.); + TLorentzVector yy(0.,0.,0.,0.); + TLorentzVector ll(0.,0.,0.,0.); + TLorentzVector llyy(0.,0.,0.,0.); + + int n_leptons = m_IDecors.at("nLeptons").get(*event, sys); + int n_photons = m_IDecors.at("nPhotons").get(*event, sys); + + Leading_lep.SetPtEtaPhiE(m_FDecors.at("Lepton1_pt").get(*event, sys), + m_FDecors.at("Lepton1_eta").get(*event, sys), + m_FDecors.at("Lepton1_phi").get(*event, sys), + m_FDecors.at("Lepton1_E").get(*event, sys)); + + Subleading_lep.SetPtEtaPhiE(m_FDecors.at("Lepton2_pt").get(*event, sys), + m_FDecors.at("Lepton2_eta").get(*event, sys), + m_FDecors.at("Lepton2_phi").get(*event, sys), + m_FDecors.at("Lepton2_E").get(*event, sys)); + + Leading_photon.SetPtEtaPhiE(m_FDecors.at("Photon1_pt").get(*event, sys), + m_FDecors.at("Photon1_eta").get(*event, sys), + m_FDecors.at("Photon1_phi").get(*event, sys), + m_FDecors.at("Photon1_E").get(*event, sys)); + + Subleading_photon.SetPtEtaPhiE(m_FDecors.at("Photon2_pt").get(*event, sys), + m_FDecors.at("Photon2_eta").get(*event, sys), + m_FDecors.at("Photon2_phi").get(*event, sys), + m_FDecors.at("Photon2_E").get(*event, sys)); + + if(n_leptons>=2) ll = Leading_lep + Subleading_lep; + + + bool Is_Resolved = false; + bool Is_Merged = false; + + if ( n_photons >=2 && + Leading_photon.Pt() > 10 * Athena::Units::GeV && + Subleading_photon.Pt() > 10 * Athena::Units::GeV && + Leading_photon.DeltaR(Subleading_photon) < 1.5) + { + Is_Resolved = true; + yy = Leading_photon + Subleading_photon; + + m_Fbranches.at("res_myy").set(*event, yy.M(), sys); + m_Fbranches.at("res_pTyy").set(*event, yy.Pt(), sys); + m_Fbranches.at("res_Etayy").set(*event, yy.Eta(), sys); + m_Fbranches.at("res_Phiyy").set(*event, yy.Phi(), sys); + m_Fbranches.at("res_dRyy").set(*event, Leading_photon.DeltaR(Subleading_photon), sys); + m_Fbranches.at("res_dPhiyy").set(*event, abs(Leading_photon.DeltaPhi(Subleading_photon)), sys); + m_Fbranches.at("res_dEtayy").set(*event, abs(Leading_photon.Eta()- Subleading_photon.Eta()) , sys); + m_Fbranches.at("res_Xyy").set(*event, (Leading_photon.DeltaR(Subleading_photon) * yy.Pt())/(2*yy.M()) , sys); + m_Fbranches.at("res_Ph1ptOvermyy").set(*event, Leading_photon.Pt()/yy.M(), sys); + m_Fbranches.at("res_Ph2ptOvermyy").set(*event, Subleading_photon.Pt()/yy.M(), sys); + + // H->Za->yyll system building + if (n_leptons >= 2) { + + llyy = yy + ll; + + // Set variables for the H->Za system + m_Fbranches.at("res_mH_Za").set(*event, llyy.M(), sys); + m_Fbranches.at("res_pTH_Za").set(*event, llyy.Pt(), sys); + m_Fbranches.at("res_EtaH_Za").set(*event, llyy.Eta(), sys); + m_Fbranches.at("res_PhiH_Za").set(*event, llyy.Phi(), sys); + m_Fbranches.at("res_dRH_Za").set(*event, ll.DeltaR(yy), sys); + m_Fbranches.at("res_dPhiH_Za").set(*event, abs(ll.DeltaPhi(yy)), sys); + m_Fbranches.at("res_dEtaH_Za").set(*event, abs(ll.Eta() - yy.Eta()), sys); + } + } + + if ( !Is_Resolved && n_photons >=1 && + Leading_photon.Pt() > 20 * Athena::Units::GeV) + { + Is_Merged = true; + + // H->Za->yyll system building + if (n_leptons >= 2) { + + llyy = Leading_photon + ll; + + // Set variables for the H->Za system + m_Fbranches.at("mer_mH_Za").set(*event, llyy.M(), sys); + m_Fbranches.at("mer_pTH_Za").set(*event, llyy.Pt(), sys); + m_Fbranches.at("mer_EtaH_Za").set(*event, llyy.Eta(), sys); + m_Fbranches.at("mer_PhiH_Za").set(*event, llyy.Phi(), sys); + m_Fbranches.at("mer_dRH_Za").set(*event, ll.DeltaR(Leading_photon), sys); + m_Fbranches.at("mer_dPhiH_Za").set(*event, abs(ll.DeltaPhi(Leading_photon)), sys); + m_Fbranches.at("mer_dEtaH_Za").set(*event, abs(ll.Eta() - Leading_photon.Eta()), sys); + } + } + + m_Ibranches.at("isResolved_Event").set( * event, Is_Resolved, sys); + m_Ibranches.at("isMerged_Event").set( * event, Is_Merged, sys); + } // + + return StatusCode::SUCCESS; + } + +} diff --git a/HZallyyAnalysis/src/BaselineVarsAlg.h b/HZallyyAnalysis/src/BaselineVarsAlg.h new file mode 100644 index 0000000000000000000000000000000000000000..8944f619253e455e268bf689d310edf435903d6a --- /dev/null +++ b/HZallyyAnalysis/src/BaselineVarsAlg.h @@ -0,0 +1,62 @@ +/* + Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration +*/ + +// Always protect against multiple includes! +#ifndef HZALLYYANALYSIS_BASELINEVARSALG +#define HZALLYYANALYSIS_BASELINEVARSALG + +#include <AthenaBaseComps/AthHistogramAlgorithm.h> + +#include <SystematicsHandles/SysReadHandle.h> +#include <SystematicsHandles/SysListHandle.h> +#include <SystematicsHandles/SysWriteDecorHandle.h> +#include <SystematicsHandles/SysReadDecorHandle.h> +#include <xAODEventInfo/EventInfo.h> +namespace HZALLYY +{ + + /// \brief An algorithm for counting containers + class BaselineVarsAlg final : public AthHistogramAlgorithm + { + /// \brief The standard constructor + public: + BaselineVarsAlg(const std::string &name, ISvcLocator *pSvcLocator); + + /// \brief Initialisation method, for setting up tools and other persistent + /// configs + StatusCode initialize() override; + /// \brief Execute method, for actions to be taken in the event loop + StatusCode execute() override; + /// We use default finalize() -- this is for cleanup, and we don't do any + + private: + /// \brief Setup syst-aware input container handles + CP::SysListHandle m_systematicsList {this}; + + CP::SysReadHandle<xAOD::EventInfo> + m_eventHandle{ this, "event", "EventInfo", "EventInfo container to read" }; + + Gaudi::Property<std::vector<std::string>> m_floatVariables + {this, "floatVariableList", {}, "Name list of floating variables"}; + + Gaudi::Property<std::vector<std::string>> m_intVariables + {this, "intVariableList", {}, "Name list of integer variables"}; + + std::unordered_map<std::string, CP::SysReadDecorHandle<float>> m_FDecors; + std::unordered_map<std::string, CP::SysReadDecorHandle<int>> m_IDecors; + + std::vector<std::string> m_fvars; + std::vector<std::string> m_ivars + { + "nLeptons", + "nPhotons" + }; + + /// \brief Setup sys-aware output decorations + std::unordered_map<std::string, CP::SysWriteDecorHandle<float>> m_Fbranches; + std::unordered_map<std::string, CP::SysWriteDecorHandle<int>> m_Ibranches; + + }; +} +#endif diff --git a/HZallyyAnalysis/src/HZAllyySelectorAlg.cxx b/HZallyyAnalysis/src/HZAllyySelectorAlg.cxx index fa3338b63fc66747544f6406ae2aa05e6bacdcdc..b8ab030262af622ac96cfe831562e26d72e15e35 100644 --- a/HZallyyAnalysis/src/HZAllyySelectorAlg.cxx +++ b/HZallyyAnalysis/src/HZAllyySelectorAlg.cxx @@ -92,7 +92,11 @@ namespace HZALLYY m_bools.at(HZALLYY::PASS_TRIGGER) = false; m_bools.at(HZALLYY::EXACTLY_TWO_LEPTONS) = false; m_bools.at(HZALLYY::TWO_OPPOSITE_CHARGE_LEPTONS) = false; - m_bools.at(HZALLYY::ATLEAST_TWO_PHOTONS) = false; + m_bools.at(HZALLYY::LEP1_LEP2_DR) = false; + m_bools.at(HZALLYY::LEP1_LEP2_PT) = false; + m_bools.at(HZALLYY::DILEP_MASS) = false; + m_bools.at(HZALLYY::DILEP_PT) = false; + m_bools.at(HZALLYY::ATLEAST_ONE_PHOTON) = false; setThresholds(event, sys); @@ -130,7 +134,11 @@ namespace HZALLYY if(m_bools.at(HZALLYY::PASS_TRIGGER) && m_bools.at(HZALLYY::EXACTLY_TWO_LEPTONS) && m_bools.at(HZALLYY::TWO_OPPOSITE_CHARGE_LEPTONS) && - m_bools.at(HZALLYY::ATLEAST_TWO_PHOTONS)) pass_baseline=true; + m_bools.at(HZALLYY::LEP1_LEP2_DR) && + m_bools.at(HZALLYY::LEP1_LEP2_PT) && + m_bools.at(HZALLYY::DILEP_MASS) && + m_bools.at(HZALLYY::DILEP_PT) && + m_bools.at(HZALLYY::ATLEAST_ONE_PHOTON)) pass_baseline=true; if ((m_bypass or pass_baseline)) filter.setPassed(true); @@ -387,6 +395,15 @@ namespace HZALLYY { bool Two_Opposite_Sign_Electrons = false; bool Two_Opposite_Sign_Muons = false; + bool ee_deltaR = false; + bool mumu_deltaR = false; + bool electron_pT_thr_pass = false; + bool muon_pT_thr_pass = false; + bool ee_mass_thr_pass = false; + bool mumu_mass_thr_pass = false; + bool ee_pT_thr_pass = false; + bool mumu_pT_thr_pass = false; + if ( (electrons.size() == 2 || muons.size() == 2) && llyyCuts.exists("EXACTLY_TWO_LEPTONS")) @@ -397,24 +414,77 @@ namespace HZALLYY if (electrons.size() >= 2) { Two_Opposite_Sign_Electrons = electrons.at(0)->charge()*electrons.at(1)->charge() == -1; + + double ee_dR = electrons.at(0)->p4().DeltaR(electrons.at(1)->p4()); + if (ee_dR > 0.2) + ee_deltaR = true; + + if ( electrons.at(0)->pt() > 27 * Athena::Units::GeV && electrons.at(1)->pt() > 20 * Athena::Units::GeV ) + electron_pT_thr_pass = true; + + double m_ee = (electrons.at(0)->p4() + electrons.at(1)->p4()).M(); + if (m_ee >= 81 * Athena::Units::GeV && m_ee <= 101 * Athena::Units::GeV) + ee_mass_thr_pass = true; + + double pT_ee = (electrons.at(0)->p4() + electrons.at(1)->p4()).Pt(); + if (pT_ee > 10 * Athena::Units::GeV) + ee_pT_thr_pass = true; } + if (muons.size() >= 2) { Two_Opposite_Sign_Muons = muons.at(0)->charge()*muons.at(1)->charge() == -1; + + double mumu_dR = muons.at(0)->p4().DeltaR(muons.at(1)->p4()); + if (mumu_dR > 0.2) + mumu_deltaR = true; + + if ( muons.at(0)->pt() > 27 * Athena::Units::GeV && muons.at(1)->pt() > 20 * Athena::Units::GeV ) + muon_pT_thr_pass = true; + + double m_mumu = (muons.at(0)->p4() + muons.at(1)->p4()).M(); + if (m_mumu >= 81 * Athena::Units::GeV && m_mumu <= 101 * Athena::Units::GeV) + mumu_mass_thr_pass = true; + + double pT_mumu = (muons.at(0)->p4() + muons.at(1)->p4()).Pt(); + if (pT_mumu > 10 * Athena::Units::GeV) + mumu_pT_thr_pass = true; } + if ((Two_Opposite_Sign_Electrons || Two_Opposite_Sign_Muons ) && llyyCuts.exists("TWO_OPPOSITE_CHARGE_LEPTONS")) { m_bools.at(HZALLYY::TWO_OPPOSITE_CHARGE_LEPTONS) = true; } + + if ( (ee_deltaR || mumu_deltaR) && llyyCuts.exists("LEP1_LEP2_DR")) + { + m_bools.at(HZALLYY::LEP1_LEP2_DR) = true; + } + + if ( (electron_pT_thr_pass || muon_pT_thr_pass) && llyyCuts.exists("LEP1_LEP2_PT")) + { + m_bools.at(HZALLYY::LEP1_LEP2_PT) = true; + } + + if ( (ee_mass_thr_pass || mumu_mass_thr_pass) && llyyCuts.exists("DILEP_MASS")) + { + m_bools.at(HZALLYY::DILEP_MASS) = true; + } + + if ( (ee_pT_thr_pass || mumu_pT_thr_pass) && llyyCuts.exists("DILEP_PT")) + { + m_bools.at(HZALLYY::DILEP_PT) = true; + } + } void HZAllyySelectorAlg::evaluatePhotonCuts (const xAOD::PhotonContainer& photons, CutManager& llyyCuts) { - if (photons.size() >= 2 && llyyCuts.exists("ATLEAST_TWO_PHOTONS")) - m_bools.at(HZALLYY::ATLEAST_TWO_PHOTONS) = true; + if (photons.size() > 0 && llyyCuts.exists("ATLEAST_ONE_PHOTON")) + m_bools.at(HZALLYY::ATLEAST_ONE_PHOTON) = true; } void HZAllyySelectorAlg::setThresholds(const xAOD::EventInfo* event, diff --git a/HZallyyAnalysis/src/HZAllyySelectorAlg.h b/HZallyyAnalysis/src/HZAllyySelectorAlg.h index 34382ea003e6970855f156f3354b19b21b36ec28..8b4bf4103e6ca20acccc3245b88114a2cecbebc5 100644 --- a/HZallyyAnalysis/src/HZAllyySelectorAlg.h +++ b/HZallyyAnalysis/src/HZAllyySelectorAlg.h @@ -48,7 +48,11 @@ namespace HZALLYY PASS_TRIGGER, EXACTLY_TWO_LEPTONS, TWO_OPPOSITE_CHARGE_LEPTONS, - ATLEAST_TWO_PHOTONS + LEP1_LEP2_DR, + LEP1_LEP2_PT, + DILEP_MASS, + DILEP_PT, + ATLEAST_ONE_PHOTON }; /// \brief An algorithm for counting containers @@ -71,7 +75,11 @@ namespace HZALLYY "PASS_TRIGGER", "EXACTLY_TWO_LEPTONS", "TWO_OPPOSITE_CHARGE_LEPTONS", - "ATLEAST_TWO_PHOTONS" + "LEP1_LEP2_DR", + "LEP1_LEP2_PT", + "DILEP_MASS", + "DILEP_PT", + "ATLEAST_ONE_PHOTON" }; // ToolHandle<whatever> handle {this, "pythonName", "defaultValue", @@ -136,7 +144,12 @@ namespace HZALLYY {HZALLYY::PASS_TRIGGER, "PASS_TRIGGER"}, {HZALLYY::EXACTLY_TWO_LEPTONS, "EXACTLY_TWO_LEPTONS"}, {HZALLYY::TWO_OPPOSITE_CHARGE_LEPTONS, "TWO_OPPOSITE_CHARGE_LEPTONS"}, - {HZALLYY::ATLEAST_TWO_PHOTONS, "ATLEAST_TWO_PHOTONS"}, + {HZALLYY::LEP1_LEP2_DR, "LEP1_LEP2_DR"}, + {HZALLYY::LEP1_LEP2_PT, "LEP1_LEP2_PT"}, + {HZALLYY::DILEP_MASS, "DILEP_MASS"}, + {HZALLYY::DILEP_PT, "DILEP_PT"}, + {HZALLYY::ATLEAST_ONE_PHOTON, "ATLEAST_ONE_PHOTON"}, + }; CutManager m_llyyCuts; diff --git a/HZallyyAnalysis/src/BaselineVarsllyyAlg.cxx b/HZallyyAnalysis/src/LeptonVarsAlg.cxx similarity index 61% rename from HZallyyAnalysis/src/BaselineVarsllyyAlg.cxx rename to HZallyyAnalysis/src/LeptonVarsAlg.cxx index 1902e086f688365a306b38c6fdb4b07708bcadcf..8e5cb35c42fac1af6bf7e429f5b0ad12c6876c9c 100644 --- a/HZallyyAnalysis/src/BaselineVarsllyyAlg.cxx +++ b/HZallyyAnalysis/src/LeptonVarsAlg.cxx @@ -2,32 +2,22 @@ Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration */ -#include "BaselineVarsllyyAlg.h" - -#include "AthContainers/AuxElement.h" - -#include <AthContainers/ConstDataVector.h> - -#include "TLorentzVector.h" - -#include "EasyjetHub/MT2_ROOT.h" +#include "LeptonVarsAlg.h" namespace HZALLYY { - BaselineVarsllyyAlg::BaselineVarsllyyAlg(const std::string & name, + LeptonVarsAlg::LeptonVarsAlg(const std::string & name, ISvcLocator * pSvcLocator): AthHistogramAlgorithm(name, pSvcLocator) { } - StatusCode BaselineVarsllyyAlg::initialize() { + StatusCode LeptonVarsAlg::initialize() { ATH_MSG_INFO("*********************************\n"); - ATH_MSG_INFO(" BaselineVarsllyyAlg \n"); + ATH_MSG_INFO(" LeptonVarsAlg \n"); ATH_MSG_INFO("*********************************\n"); // Read syst-aware input handles - ATH_CHECK(m_llyyphotonHandle.initialize(m_systematicsList)); ATH_CHECK(m_llyyelectronHandle.initialize(m_systematicsList)); ATH_CHECK(m_llyymuonHandle.initialize(m_systematicsList)); - ATH_CHECK(m_llyyjetHandle.initialize(m_systematicsList)); ATH_CHECK(m_eventHandle.initialize(m_systematicsList)); if (m_isMC) { @@ -44,10 +34,6 @@ namespace HZALLYY { ATH_CHECK(m_ele_SF.initialize(m_systematicsList, m_electronHandle)); } - ATH_CHECK (m_photonHandle.initialize(m_systematicsList)); - m_ph_SF = CP::SysReadDecorHandle < float > ("effSF_" + m_phWPName + "_%SYS%", this); - ATH_CHECK(m_ph_SF.initialize(m_systematicsList, m_photonHandle)); - ATH_CHECK (m_muonHandle.initialize(m_systematicsList)); m_mu_SF = CP::SysReadDecorHandle < float > ("effSF_" + m_muWPName + "_%SYS%", this); ATH_CHECK(m_mu_SF.initialize(m_systematicsList, m_muonHandle)); @@ -74,7 +60,7 @@ namespace HZALLYY { return StatusCode::SUCCESS; } - StatusCode BaselineVarsllyyAlg::execute() { + StatusCode LeptonVarsAlg::execute() { // Loop over all systs for (const auto & sys: m_systematicsList.systematicsVector()) { @@ -82,19 +68,13 @@ namespace HZALLYY { // Retrieve inputs const xAOD::EventInfo * event = nullptr; ANA_CHECK(m_eventHandle.retrieve(event, sys)); - - const xAOD::PhotonContainer * photons = nullptr; - ANA_CHECK(m_llyyphotonHandle.retrieve(photons, sys)); - + const xAOD::MuonContainer * muons = nullptr; ANA_CHECK(m_llyymuonHandle.retrieve(muons, sys)); const xAOD::ElectronContainer * electrons = nullptr; ANA_CHECK(m_llyyelectronHandle.retrieve(electrons, sys)); - const xAOD::JetContainer *jets = nullptr; - ANA_CHECK(m_llyyjetHandle.retrieve (jets, sys)); - for (const std::string & string_var: m_floatVariables) { m_Fbranches.at(string_var).set( * event, -99., sys); } @@ -102,60 +82,6 @@ namespace HZALLYY { for (const auto &var: m_intVariables) { m_Ibranches.at(var).set( * event, -99, sys); } - - static const SG::AuxElement::ConstAccessor < int > HadronConeExclTruthLabelID("HadronConeExclTruthLabelID"); - - // Count photons - int n_photons = 0; - n_photons = photons -> size(); - - int n_jets = 0; - n_jets = jets -> size(); - - // Photon sector - // initialize - const xAOD::Photon * ph0 = nullptr; - const xAOD::Photon * ph1 = nullptr; - - for (unsigned int i = 0; i < std::min(size_t(2), photons -> size()); i++) { - const xAOD::Photon * ph = photons -> at(i); - if (i == 0) ph0 = ph; - else if (i == 1) ph1 = ph; - }// end photon - - - for (unsigned int i = 0; i < std::min(size_t(2), photons -> size()); i++) { - const xAOD::Photon * ph = photons -> at(i); - if (!ph) continue; - std::string prefix = "Photon" + std::to_string(i + 1); - TLorentzVector tlv = photons -> at(i) -> p4(); - - m_Fbranches.at(prefix + "_pt").set( * event, tlv.Pt(), sys); - m_Fbranches.at(prefix + "_eta").set( * event, tlv.Eta(), sys); - m_Fbranches.at(prefix + "_phi").set( * event, tlv.Phi(), sys); - m_Fbranches.at(prefix + "_E").set( * event, tlv.E(), sys); - - - if(m_isMC){ - m_Fbranches.at(prefix+"_effSF").set(*event, m_ph_SF.get(*ph, sys), sys); - } - - - - } - - TLorentzVector yy(0., 0., 0., 0.); - if (ph0 && ph1) { - yy = ph0 -> p4() + ph1 -> p4(); - m_Fbranches.at("myy").set( * event, yy.M(), sys); - m_Fbranches.at("pTyy").set( * event, yy.Pt(), sys); - m_Fbranches.at("Etayy").set( * event, yy.Eta(), sys); - m_Fbranches.at("Phiyy").set( * event, yy.Phi(), sys); - m_Fbranches.at("dRyy").set( * event, ph0 -> p4().DeltaR(ph1 -> p4()), sys); - m_Fbranches.at("dPhiyy").set( * event, ph0 -> p4().DeltaPhi(ph1 -> p4()), sys); - m_Fbranches.at("dEtayy").set( * event, ph0 -> p4().Eta()- ph1 -> p4().Eta() , sys); - m_Fbranches.at("Xyy").set( * event, (ph0 -> p4().DeltaR(ph1 -> p4()) * yy.Pt())/(2*yy.M()) , sys); - } int n_electrons = 0; int n_muons = 0; @@ -168,14 +94,12 @@ namespace HZALLYY { m_Ibranches.at("nElectrons").set( * event, n_electrons, sys); m_Ibranches.at("nMuons").set( * event, n_muons, sys); - m_Ibranches.at("nPhotons").set( * event, n_photons, sys); - m_Ibranches.at("nJets").set( * event, n_jets, sys); - + m_Ibranches.at("nLeptons").set(*event, electrons->size() + muons->size(), sys); // Electron sector const xAOD::Electron * ele0 = nullptr; const xAOD::Electron * ele1 = nullptr; - for (unsigned int i = 0; i < std::min(size_t(2), electrons -> size()); i++) { + for (unsigned int i = 0; i < std::min(std::size_t(2), electrons -> size()); i++) { const xAOD::Electron * ele = electrons -> at(i); if (i == 0) ele0 = ele; else if (i == 1) ele1 = ele; @@ -185,7 +109,7 @@ namespace HZALLYY { const xAOD::Muon * mu0 = nullptr; const xAOD::Muon * mu1 = nullptr; - for (unsigned int i = 0; i < std::min(size_t(2), muons -> size()); i++) { + for (unsigned int i = 0; i < std::min(std::size_t(2), muons -> size()); i++) { const xAOD::Muon * mu = muons -> at(i); if (i == 0) mu0 = mu; else if (i == 1) mu1 = mu; @@ -207,7 +131,7 @@ namespace HZALLYY { TLorentzVector Subleading_lep; TLorentzVector ll; - for (unsigned int i = 0; i < std::min(size_t(2), leptons.size()); i++) { + for (unsigned int i = 0; i < std::min(std::size_t(2), leptons.size()); i++) { std::string prefix = "Lepton" + std::to_string(i + 1); TLorentzVector tlv = leptons[i].first -> p4(); @@ -265,30 +189,11 @@ namespace HZALLYY { m_Fbranches.at("Etall").set( * event, ll.Eta(), sys); m_Fbranches.at("Phill").set( * event, ll.Phi(), sys); m_Fbranches.at("dRll").set( * event, Leading_lep.DeltaR(Subleading_lep), sys); - m_Fbranches.at("dPhill").set( * event, Leading_lep.DeltaPhi(Subleading_lep), sys); - m_Fbranches.at("dEtall").set( * event, Leading_lep.Eta() - Subleading_lep.Eta() , sys); + m_Fbranches.at("dPhill").set( * event, abs(Leading_lep.DeltaPhi(Subleading_lep)), sys); + m_Fbranches.at("dEtall").set( * event, abs(Leading_lep.Eta() - Subleading_lep.Eta()) , sys); } - - // H->Za->yyll system building - if (ph0 && ph1 && leptons.size() >= 2) { - - TLorentzVector Z_ll = Leading_lep + Subleading_lep; - TLorentzVector a_yy = ph0 -> p4() + ph1 -> p4(); - TLorentzVector H_Za = a_yy + Z_ll; - - // Set variables for the H->aa system - m_Fbranches.at("mH_Za").set(*event, H_Za.M(), sys); - m_Fbranches.at("pTH_Za").set(*event, H_Za.Pt(), sys); - m_Fbranches.at("EtaH_Za").set(*event, H_Za.Eta(), sys); - m_Fbranches.at("PhiH_Za").set(*event, H_Za.Phi(), sys); - m_Fbranches.at("dRH_Za").set(*event, Z_ll.DeltaR(a_yy), sys); - m_Fbranches.at("dPhiH_Za").set(*event, Z_ll.DeltaPhi(a_yy), sys); - m_Fbranches.at("dEtaH_Za").set(*event, Z_ll.Eta() - a_yy.Eta(), sys); - - } - - + } // return StatusCode::SUCCESS; diff --git a/HZallyyAnalysis/src/BaselineVarsllyyAlg.h b/HZallyyAnalysis/src/LeptonVarsAlg.h similarity index 76% rename from HZallyyAnalysis/src/BaselineVarsllyyAlg.h rename to HZallyyAnalysis/src/LeptonVarsAlg.h index a4ca3441782e265bbf4ad1f713fc23806b198ec2..36db64f544c30947bb0a328b29cbbd7cf6c893d9 100644 --- a/HZallyyAnalysis/src/BaselineVarsllyyAlg.h +++ b/HZallyyAnalysis/src/LeptonVarsAlg.h @@ -3,8 +3,8 @@ */ // Always protect against multiple includes! -#ifndef HZALLYYANALYSIS_FINALVARSHZALLYYALG -#define HZALLYYANALYSIS_FINALVARSHZALLYYALG +#ifndef HZALLYYANALYSIS_LEPTONVARSALG +#define HZALLYYANALYSIS_LEPTONVARSALG #include <AthenaBaseComps/AthHistogramAlgorithm.h> @@ -16,18 +16,16 @@ #include <xAODEventInfo/EventInfo.h> #include <xAODMuon/MuonContainer.h> #include <xAODEgamma/ElectronContainer.h> -#include <xAODEgamma/PhotonContainer.h> -#include <xAODJet/JetContainer.h> namespace HZALLYY { /// \brief An algorithm for counting containers - class BaselineVarsllyyAlg final : public AthHistogramAlgorithm + class LeptonVarsAlg final : public AthHistogramAlgorithm { /// \brief The standard constructor public: - BaselineVarsllyyAlg(const std::string &name, ISvcLocator *pSvcLocator); + LeptonVarsAlg(const std::string &name, ISvcLocator *pSvcLocator); /// \brief Initialisation method, for setting up tools and other persistent /// configs @@ -40,20 +38,9 @@ namespace HZALLYY /// \brief Setup syst-aware input container handles CP::SysListHandle m_systematicsList {this}; - CP::SysReadHandle<xAOD::PhotonContainer> - m_llyyphotonHandle{ this, "llyyphotons", "llyyAnalysisPhotons_%SYS%", "Photons container to read" }; - - CP::SysReadHandle<xAOD::PhotonContainer> - m_photonHandle{ this, "photons", "AnalysisPhotons_%SYS%", "Original Photons container to read" }; - - Gaudi::Property<std::string> m_phWPName - { this, "phWP", "", "Photon ID + Iso working point" }; - CP::SysReadDecorHandle<float> m_ph_SF{"", this}; - - CP::SysReadHandle<xAOD::ElectronContainer> m_electronHandle{ this, "electrons", "AnalysisElectrons_%SYS%", "Original Electron container to read" }; - + CP::SysReadHandle<xAOD::ElectronContainer> m_llyyelectronHandle{ this, "llyyelectrons", "llyyAnalysisElectrons_%SYS%", "Electron container to read" }; @@ -62,9 +49,6 @@ namespace HZALLYY CP::SysReadHandle<xAOD::MuonContainer> m_llyymuonHandle{ this, "llyymuons", "llyyAnalysisMuons_%SYS%", "Muon container to read" }; - - CP::SysReadHandle<xAOD::JetContainer> - m_llyyjetHandle{ this, "Jets", "llyyAnalysisJets_%SYS%", "Jet container to read" }; Gaudi::Property<bool> m_saveDummy_ele_SF {this, "saveDummyEleSF", false, @@ -87,9 +71,10 @@ namespace HZALLYY CP::SysReadDecorHandle<float> m_mu_SF{"", this}; CP::SysReadDecorHandle<int> m_mu_truthOrigin{"truthOrigin", this}; CP::SysReadDecorHandle<int> m_mu_truthType{"truthType", this}; - - CP::SysReadDecorHandle<int> m_nmuons{"n_muons_%SYS%", this}; + Gaudi::Property<bool> m_doSystematics + { this, "doSystematics", false, "Run on all systematics" }; + Gaudi::Property<std::vector<std::string>> m_floatVariables {this, "floatVariableList", {}, "Name list of floating variables"}; diff --git a/HZallyyAnalysis/src/PhotonVarsAlg.cxx b/HZallyyAnalysis/src/PhotonVarsAlg.cxx new file mode 100644 index 0000000000000000000000000000000000000000..4f4990568e610bf4b1c33cb10a40e7ab67e5bb67 --- /dev/null +++ b/HZallyyAnalysis/src/PhotonVarsAlg.cxx @@ -0,0 +1,88 @@ +/* + Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration +*/ + +#include "PhotonVarsAlg.h" + +namespace HZALLYY { + PhotonVarsAlg::PhotonVarsAlg(const std::string & name, + ISvcLocator * pSvcLocator): AthHistogramAlgorithm(name, pSvcLocator) { + + } + + StatusCode PhotonVarsAlg::initialize() { + ATH_MSG_INFO("*********************************\n"); + ATH_MSG_INFO(" PhotonVarsAlg \n"); + ATH_MSG_INFO("*********************************\n"); + + // Read syst-aware input handles + ATH_CHECK(m_llyyphotonHandle.initialize(m_systematicsList)); + ATH_CHECK(m_eventHandle.initialize(m_systematicsList)); + + if (m_isMC) { + ATH_CHECK (m_photonHandle.initialize(m_systematicsList)); + m_ph_SF = CP::SysReadDecorHandle < float > ("effSF_" + m_phWPName + "_%SYS%", this); + ATH_CHECK(m_ph_SF.initialize(m_systematicsList, m_photonHandle)); + } + + // Intialise syst-aware output decorators + for (const std::string &var: m_floatVariables) { + CP::SysWriteDecorHandle < float > whandle {var +"_%SYS%", this}; + m_Fbranches.emplace(var, whandle); + ATH_CHECK(m_Fbranches.at(var).initialize(m_systematicsList, m_eventHandle)); + } + + for (const std::string &var: m_intVariables) { + ATH_MSG_DEBUG("initializing integer variable: " <<var); + CP::SysWriteDecorHandle < int > whandle {var +"_%SYS%", this}; + m_Ibranches.emplace(var, whandle); + ATH_CHECK(m_Ibranches.at(var).initialize(m_systematicsList, m_eventHandle)); + }; + + // Intialise syst list (must come after all syst-aware inputs and outputs) + ATH_CHECK(m_systematicsList.initialize()); + + return StatusCode::SUCCESS; + } + + StatusCode PhotonVarsAlg::execute() { + + // Loop over all systs + for (const auto & sys: m_systematicsList.systematicsVector()) { + + // Retrieve inputs + const xAOD::EventInfo * event = nullptr; + ANA_CHECK(m_eventHandle.retrieve(event, sys)); + + const xAOD::PhotonContainer * photons = nullptr; + ANA_CHECK(m_llyyphotonHandle.retrieve(photons, sys)); + + for (const std::string & string_var: m_floatVariables) { + m_Fbranches.at(string_var).set( * event, -99., sys); + } + + for (const auto &var: m_intVariables) { + m_Ibranches.at(var).set( * event, -99, sys); + } + + for (unsigned int i = 0; i < std::min(std::size_t(2), photons -> size()); i++) { + const xAOD::Photon * ph = photons -> at(i); + if (!ph) continue; + std::string prefix = "Photon" + std::to_string(i + 1); + TLorentzVector tlv = ph -> p4(); + m_Fbranches.at(prefix + "_pt").set( * event, tlv.Pt(), sys); + m_Fbranches.at(prefix + "_eta").set( * event, tlv.Eta(), sys); + m_Fbranches.at(prefix + "_phi").set( * event, tlv.Phi(), sys); + m_Fbranches.at(prefix + "_E").set( * event, tlv.E(), sys); + if(m_isMC){ + m_Fbranches.at(prefix+"_effSF").set(*event, m_ph_SF.get(*ph, sys), sys); + } + } + + m_Ibranches.at("nPhotons").set( * event, photons -> size(), sys); + } // + + return StatusCode::SUCCESS; + } + +} diff --git a/HZallyyAnalysis/src/PhotonVarsAlg.h b/HZallyyAnalysis/src/PhotonVarsAlg.h new file mode 100644 index 0000000000000000000000000000000000000000..b0f0b6a6ad5f9aced64deda6596ed0dd6c5de1bb --- /dev/null +++ b/HZallyyAnalysis/src/PhotonVarsAlg.h @@ -0,0 +1,71 @@ +/* + Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration +*/ + +// Always protect against multiple includes! +#ifndef HZALLYYANALYSIS_PHOTONVARSALG +#define HZALLYYANALYSIS_PHOTONVARSALG + +#include <AthenaBaseComps/AthHistogramAlgorithm.h> + +#include <SystematicsHandles/SysReadHandle.h> +#include <SystematicsHandles/SysListHandle.h> +#include <SystematicsHandles/SysWriteDecorHandle.h> +#include <SystematicsHandles/SysReadDecorHandle.h> + +#include <xAODEventInfo/EventInfo.h> +#include <xAODEgamma/PhotonContainer.h> + +namespace HZALLYY +{ + + /// \brief An algorithm for counting containers + class PhotonVarsAlg final : public AthHistogramAlgorithm + { + /// \brief The standard constructor + public: + PhotonVarsAlg(const std::string &name, ISvcLocator *pSvcLocator); + + /// \brief Initialisation method, for setting up tools and other persistent + /// configs + StatusCode initialize() override; + /// \brief Execute method, for actions to be taken in the event loop + StatusCode execute() override; + /// We use default finalize() -- this is for cleanup, and we don't do any + + private: + /// \brief Setup syst-aware input container handles + CP::SysListHandle m_systematicsList {this}; + + CP::SysReadHandle<xAOD::PhotonContainer> + m_llyyphotonHandle{ this, "llyyphotons", "llyyAnalysisPhotons_%SYS%", "Photons container to read" }; + + CP::SysReadHandle<xAOD::PhotonContainer> + m_photonHandle{ this, "photons", "AnalysisPhotons_%SYS%", "Original Photons container to read" }; + + Gaudi::Property<std::string> m_phWPName + { this, "phWP", "", "Photon ID + Iso working point" }; + CP::SysReadDecorHandle<float> m_ph_SF{"", this}; + + CP::SysReadHandle<xAOD::EventInfo> + m_eventHandle{ this, "event", "EventInfo", "EventInfo container to read" }; + + Gaudi::Property<bool> m_isMC + { this, "isMC", false, "Is this simulation?" }; + + Gaudi::Property<bool> m_doSystematics + { this, "doSystematics", false, "Run on all systematics" }; + + Gaudi::Property<std::vector<std::string>> m_floatVariables + {this, "floatVariableList", {}, "Name list of floating variables"}; + + Gaudi::Property<std::vector<std::string>> m_intVariables + {this, "intVariableList", {}, "Name list of integer variables"}; + + /// \brief Setup sys-aware output decorations + std::unordered_map<std::string, CP::SysWriteDecorHandle<float>> m_Fbranches; + std::unordered_map<std::string, CP::SysWriteDecorHandle<int>> m_Ibranches; + + }; +} +#endif diff --git a/HZallyyAnalysis/src/components/HZallyyAnalysis_entries.cxx b/HZallyyAnalysis/src/components/HZallyyAnalysis_entries.cxx index 95ce6d3b55a7a9b8819c103dcff4a0b3ae619b08..e67d4042924c95936eb9e7e30a75313bfff9fb3e 100644 --- a/HZallyyAnalysis/src/components/HZallyyAnalysis_entries.cxx +++ b/HZallyyAnalysis/src/components/HZallyyAnalysis_entries.cxx @@ -1,8 +1,11 @@ -#include "../BaselineVarsllyyAlg.h" #include "../HZAllyySelectorAlg.h" +#include "../PhotonVarsAlg.h" +#include "../LeptonVarsAlg.h" +#include "../BaselineVarsAlg.h" using namespace HZALLYY; -DECLARE_COMPONENT(BaselineVarsllyyAlg) DECLARE_COMPONENT(HZAllyySelectorAlg) - +DECLARE_COMPONENT(PhotonVarsAlg) +DECLARE_COMPONENT(LeptonVarsAlg) +DECLARE_COMPONENT(BaselineVarsAlg)