From 4da82463dce6b908f1ad1f0e46f56528270fb311 Mon Sep 17 00:00:00 2001 From: Andrii Verbytskyi <andrii.verbytskyi@cern.ch> Date: Mon, 9 Sep 2024 15:17:48 +0200 Subject: [PATCH 1/6] Delete ITrackParticleAndJetMerger.h --- .../ITrackParticleAndJetMerger.h | 58 ------------------- 1 file changed, 58 deletions(-) delete mode 100644 PhysicsAnalysis/AnalysisCommon/ParticleJetTools/ParticleJetTools/ITrackParticleAndJetMerger.h diff --git a/PhysicsAnalysis/AnalysisCommon/ParticleJetTools/ParticleJetTools/ITrackParticleAndJetMerger.h b/PhysicsAnalysis/AnalysisCommon/ParticleJetTools/ParticleJetTools/ITrackParticleAndJetMerger.h deleted file mode 100644 index cffc5f60a34f..000000000000 --- a/PhysicsAnalysis/AnalysisCommon/ParticleJetTools/ParticleJetTools/ITrackParticleAndJetMerger.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -/* ************************************************************************** - ITrackParticleAndJetMerger.h - Description - ------------------- - begin : 27.01.05 - authors : A. Wildauer - email : andreas.wildauer@cern.ch - - ***************************************************************************/ - -#ifndef PARTICLEJETTOOLS_ITRACKPARTICLEANDJETMERGER_H -#define PARTICLEJETTOOLS_ITRACKPARTICLEANDJETMERGER_H - -#include "GaudiKernel/IAlgTool.h" - -namespace Rec -{ - class TrackParticleContainer; -} - -class ParticleJetContainer; - -namespace Analysis -{ - - static const InterfaceID IID_ITrackParticleAndJetMerger("Analysis::ITrackParticleAndJetMerger", 1, 0); - - /** \class ITrackParticleAndJetMerger - Interface class for the TrackParticleAndJetMerger AlgTool, it inherits from IAlgTool - Detailed information about private members and member functions can be found in the actual implementation class - TrackParticleAndJetMerger. - - @author Andreas.Wildauer@cern.ch - */ - - class ITrackParticleAndJetMerger : virtual public IAlgTool - { - public: - - /** destructor */ - virtual ~ITrackParticleAndJetMerger() {}; - - /** AlgTool interface methods */ - static const InterfaceID& interfaceID() { return IID_ITrackParticleAndJetMerger; }; - - /** Method to merge tracks to JetParticles */ - virtual void mergeTrackWithJets( - ParticleJetContainer * SGParticleJetContainer, - const Rec::TrackParticleContainer * particleContainer - )=0; - - }; // End class -} // End namespace - -#endif -- GitLab From 11a98d5f95bad1df49462c81f1210ae25ebed4cc Mon Sep 17 00:00:00 2001 From: Andrii Verbytskyi <andrii.verbytskyi@mpp.mpg.de> Date: Fri, 18 Oct 2024 14:26:03 +0200 Subject: [PATCH 2/6] Introduce ShortEventAttribute --- Generators/AtlasHepMC/AtlasHepMC/GenEvent.h | 122 ++++++++++++++++++++ 1 file changed, 122 insertions(+) diff --git a/Generators/AtlasHepMC/AtlasHepMC/GenEvent.h b/Generators/AtlasHepMC/AtlasHepMC/GenEvent.h index 589424043f13..af6da845abe1 100644 --- a/Generators/AtlasHepMC/AtlasHepMC/GenEvent.h +++ b/Generators/AtlasHepMC/AtlasHepMC/GenEvent.h @@ -31,6 +31,128 @@ using Print=HepMC3::Print; using GenHeavyIon=HepMC3::GenHeavyIon; using GenEvent=HepMC3::GenEvent; +class ShortEventAttribute : public HepMC3::Attribute { +public: + ShortEventAttribute():HepMC3::Attribute(){} + ShortEventAttribute(const HepMC3::GenEvent* e):HepMC3::Attribute(){ from_event(e); } + + bool from_event(const HepMC3::GenEvent* e){ + NUP=e->particles().size(); + resize(); + XWGTUP = e->weights().size() ? e->weights()[0] : 1.0; + auto A_signal_process_id=e->attribute<HepMC3::IntAttribute>("signal_process_id"); + IDPRUP = A_signal_process_id?A_signal_process_id->value() : 0; + auto A_event_scale=e->attribute<HepMC3::DoubleAttribute>("event_scale"); + SCALUP = A_event_scale? A_event_scale->value():0; + auto A_alphaQCD=e->attribute<HepMC3::DoubleAttribute>("alphaQCD"); + AQCDUP = A_alphaQCD? A_alphaQCD->value():0; + auto A_alphaQED=e->attribute<HepMC3::DoubleAttribute>("alphaQED"); + AQEDUP = A_alphaQED? A_alphaQED->value():0; + + for ( int i = 0; i < NUP; ++i ){ + PUP[i][0] = e->particles().at(i)->momentum().px(); + PUP[i][1] = e->particles().at(i)->momentum().py(); + PUP[i][2] = e->particles().at(i)->momentum().pz(); + PUP[i][3] = e->particles().at(i)->momentum().e(); + PUP[i][4] = e->particles().at(i)->momentum().m(); + IDUP[i] = e->particles().at(i)->pdg_id(); + auto pv = e->particles().at(i)->production_vertex(); + auto ev = e->particles().at(i)->end_vertex(); + if (pv && ev ) ISTUP[i] = 2; + if (pv && !ev ) ISTUP[i] = 1; + if (e->particles().at(i)->status() == 4 || !pv ) ISTUP[i] = -1; + auto flow1 = e->particles().at(i)->attribute<HepMC3::IntAttribute>("flow1"); + auto flow2 = e->particles().at(i)->attribute<HepMC3::IntAttribute>("flow2"); + ICOLUP[i].first = flow1 ? flow1->value() : 0; + ICOLUP[i].second = flow2 ? flow2->value() : 0; + int l = 0,h = 0; + if (pv) for (auto p: pv->particles_in()) { l= std::min(l,p->id()); h=std::max(h,p->id());} + MOTHUP[i].first = h; + MOTHUP[i].second = l; + } + return true; + } + + bool from_string(const std::string &att) override { + std::istringstream iss(att); + iss >> NUP; + iss >> IDPRUP; + iss >> XWGTUP; + iss >> SCALUP; + iss >> AQEDUP; + iss >> AQCDUP; + resize(); + for ( int i = 0; i < NUP; ++i ){ + iss >> IDUP[i]; + iss >> ISTUP[i]; + iss >> MOTHUP[i].first; + iss >> MOTHUP[i].second; + iss >> ICOLUP[i].first; + iss >> ICOLUP[i].second; + iss >> PUP[i][0]; + iss >> PUP[i][1]; + iss >> PUP[i][2]; + iss >> PUP[i][3]; + iss >> PUP[i][4]; + iss >> VTIMUP[i]; + iss >> SPINUP[i]; + } + set_is_parsed(true); + return true; + } + + bool to_string(std::string &fl) const override { + std::ostringstream file; + file << " " << std::setw(4) << NUP + << " " << std::setw(6) << IDPRUP + << " " << std::setw(14) << XWGTUP + << " " << std::setw(14) << SCALUP + << " " << std::setw(14) << AQEDUP + << " " << std::setw(14) << AQCDUP << "\n"; + for ( int i = 0; i < NUP; ++i ) + file << " " << std::setw(8) << IDUP[i] + << " " << std::setw(2) << ISTUP[i] + << " " << std::setw(4) << MOTHUP[i].first + << " " << std::setw(4) << MOTHUP[i].second + << " " << std::setw(4) << ICOLUP[i].first + << " " << std::setw(4) << ICOLUP[i].second + << " " << std::setw(14) << PUP[i][0] + << " " << std::setw(14) << PUP[i][1] + << " " << std::setw(14) << PUP[i][2] + << " " << std::setw(14) << PUP[i][3] + << " " << std::setw(14) << PUP[i][4] + << " " << std::setw(1) << VTIMUP[i] + << " " << std::setw(1) << SPINUP[i] << std::endl; + fl+=file.str(); + return true; + } + + void resize() { + IDUP.resize(NUP); + ISTUP.resize(NUP); + MOTHUP.resize(NUP); + ICOLUP.resize(NUP); + PUP.resize(NUP, std::vector<double>(5)); + VTIMUP.resize(NUP); + SPINUP.resize(NUP); + } + + int NUP=0; + int IDPRUP=0; + double XWGTUP=0; + double SCALUP=0; + double AQEDUP=0; + double AQCDUP=0; + std::vector<long> IDUP{}; + std::vector<int> ISTUP{}; + std::vector< std::pair<int,int> > MOTHUP{}; + std::vector< std::pair<int,int> > ICOLUP{}; + std::vector< std::vector<double> > PUP{}; + std::vector<double> VTIMUP{}; + std::vector<double> SPINUP{}; +}; + + class GenEventBarcodes : public HepMC3::Attribute { public: -- GitLab From 824fd0bae2720b2d6e154ac38af6ed4afb67f896 Mon Sep 17 00:00:00 2001 From: Andrii Verbytskyi <you@example.com> Date: Fri, 14 Feb 2025 16:56:27 +0100 Subject: [PATCH 3/6] Drop Python path manipulations which are not needed anymore --- .../python/processes/powheg/ggF_HH.py | 21 ----------------- .../python/processes/powheg/ggF_HH_SMEFT.py | 23 ------------------- .../python/processes/powheg/ggF_HH_quartic.py | 23 ------------------- 3 files changed, 67 deletions(-) diff --git a/Generators/PowhegControl/python/processes/powheg/ggF_HH.py b/Generators/PowhegControl/python/processes/powheg/ggF_HH.py index a18721147478..729f57bbd46c 100644 --- a/Generators/PowhegControl/python/processes/powheg/ggF_HH.py +++ b/Generators/PowhegControl/python/processes/powheg/ggF_HH.py @@ -174,24 +174,6 @@ class ggF_HH(PowhegV2): logger.error('Impossible to link the needed files locally') raise - # need to override lhapdf python path while the powheg process has been compiled in a different platform - py_path_save = os.environ["PYTHONPATH"] - base_path = os.environ["LHAPDF_INSTAL_PATH"] - - # Search for the Python version in the lib folder - python_lib_path = glob.glob(os.path.join(base_path, "lib", "python*")) - - # Ensure at least one matching path is found - if python_lib_path: - python_lib_path = python_lib_path[0] - else: - raise ValueError("No Python version found in lib folder") - - # Build the temporary path - py_path_temp = python_lib_path + "/site-packages" + ":" + py_path_save - os.environ["PYTHONPATH"] = py_path_temp - logger.debug(f'Temporarily setting PYTHONPATH to:\n{py_path_temp}') - # handling the parameters of this process # these parameters need to be parsed in a specific format chhh_str = f'{list(self.parameters_by_keyword("chhh"))[0].value:+.4E}' @@ -212,7 +194,4 @@ class ggF_HH(PowhegV2): except RuntimeError: logger.error('Impossible to use creategrid.py to create the Virt_full_*.grid file') raise - - # cannot set PYTHONPATH back to its original value, because creategrid.py seems to be later re-used, and it requires lhapdf - logger.info('Although the produced Virt_full_*.grid file now exists in the local directory, Powheg will later try to find it in all directories contained in $PYTHONPATH. This will produce several "not found" info messages which can safely be ignored.') diff --git a/Generators/PowhegControl/python/processes/powheg/ggF_HH_SMEFT.py b/Generators/PowhegControl/python/processes/powheg/ggF_HH_SMEFT.py index 3fdb723bc17d..aadbf6b12676 100644 --- a/Generators/PowhegControl/python/processes/powheg/ggF_HH_SMEFT.py +++ b/Generators/PowhegControl/python/processes/powheg/ggF_HH_SMEFT.py @@ -190,25 +190,6 @@ class ggF_HH_SMEFT(PowhegV2): logger.error('Impossible to link the needed files locally') raise - # need to override lhapdf python path while the powheg process has been compiled in a different platform - py_path_save = os.environ["PYTHONPATH"] - base_path = os.environ["LHAPDF_INSTAL_PATH"] - - # Search for the Python version in the lib folder - python_lib_path = glob.glob(os.path.join(base_path, "lib", "python*")) - - # Ensure at least one matching path is found - if python_lib_path: - python_lib_path = python_lib_path[0] - else: - raise ValueError("No Python version found in lib folder") - - # Build the temporary path - py_path_temp = python_lib_path + "/site-packages" + ":" + py_path_save - - os.environ["PYTHONPATH"] = py_path_temp - logger.debug(f'Temporarily setting PYTHONPATH to:\n{py_path_temp}') - # handling the parameters of this process # these parameters need to be parsed in a specific format usesmeft_str = str(list(self.parameters_by_keyword("usesmeft"))[0].value) @@ -262,9 +243,5 @@ class ggF_HH_SMEFT(PowhegV2): logger.error('Impossible to use creategrid.py to create the Virt_full_*.grid file') raise - # setting PYTHONPATH back to its original value - os.environ["PYTHONPATH"] = py_path_save - logger.debug(f'Setting PYTHONPATH back to:\n{py_path_save}') - logger.info('Although the produced Virt_full_*.grid file now exists in the local directory, Powheg will later try to find it in all directories contained in $PYTHONPATH. This will produce several "not found" info messages which can safely be ignored.') diff --git a/Generators/PowhegControl/python/processes/powheg/ggF_HH_quartic.py b/Generators/PowhegControl/python/processes/powheg/ggF_HH_quartic.py index a341525e4081..7acf71460d1d 100644 --- a/Generators/PowhegControl/python/processes/powheg/ggF_HH_quartic.py +++ b/Generators/PowhegControl/python/processes/powheg/ggF_HH_quartic.py @@ -187,24 +187,6 @@ class ggF_HH_quartic(PowhegV2): logger.error('Impossible to link the needed files locally') raise - # need to override lhapdf python path while the powheg process has been compiled in a different platform - py_path_save = os.environ["PYTHONPATH"] - base_path = os.environ["LHAPDF_INSTAL_PATH"] - - # Search for the Python version in the lib folder - python_lib_path = glob.glob(os.path.join(base_path, "lib", "python*")) - - # Ensure at least one matching path is found - if python_lib_path: - python_lib_path = python_lib_path[0] - else: - raise ValueError("No Python version found in lib folder") - - # Build the temporary path - py_path_temp = python_lib_path + "/site-packages" + ":" + py_path_save - os.environ["PYTHONPATH"] = py_path_temp - logger.debug(f'Temporarily setting PYTHONPATH to:\n{py_path_temp}') - # handling the parameters of this process # these parameters need to be parsed in a specific format chhh_str = f'{list(self.parameters_by_keyword("chhh"))[0].value:+.4E}' @@ -226,9 +208,4 @@ class ggF_HH_quartic(PowhegV2): except RuntimeError: logger.error('Impossible to use creategrid.py to create the Virt_full_*.grid file') raise - - # setting PYTHONPATH back to its original value - os.environ["PYTHONPATH"] = py_path_save - logger.debug(f'Setting PYTHONPATH back to:\n{py_path_save}') - logger.info('Although the produced Virt_full_*.grid file now exists in the local directory, Powheg will later try to find it in all directories contained in $PYTHONPATH. This will produce several "not found" info messages which can safely be ignored.') -- GitLab From 2a539f126e67a07ce661a9c78b9306b081c33226 Mon Sep 17 00:00:00 2001 From: Andrii Verbytskyi <andrii.verbytskyi@cern.ch> Date: Fri, 14 Feb 2025 18:19:30 +0000 Subject: [PATCH 4/6] Update ggF_HH.py --- Generators/PowhegControl/python/processes/powheg/ggF_HH.py | 1 - 1 file changed, 1 deletion(-) diff --git a/Generators/PowhegControl/python/processes/powheg/ggF_HH.py b/Generators/PowhegControl/python/processes/powheg/ggF_HH.py index 729f57bbd46c..01c8b5e49678 100644 --- a/Generators/PowhegControl/python/processes/powheg/ggF_HH.py +++ b/Generators/PowhegControl/python/processes/powheg/ggF_HH.py @@ -1,6 +1,5 @@ # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration import os -import glob from AthenaCommon import Logging from ..powheg_V2 import PowhegV2 -- GitLab From 41aa5d75424fb811dd46647a6d03b4e31c18733a Mon Sep 17 00:00:00 2001 From: Andrii Verbytskyi <andrii.verbytskyi@cern.ch> Date: Fri, 14 Feb 2025 18:19:48 +0000 Subject: [PATCH 5/6] Update ggF_HH_SMEFT.py --- Generators/PowhegControl/python/processes/powheg/ggF_HH_SMEFT.py | 1 - 1 file changed, 1 deletion(-) diff --git a/Generators/PowhegControl/python/processes/powheg/ggF_HH_SMEFT.py b/Generators/PowhegControl/python/processes/powheg/ggF_HH_SMEFT.py index aadbf6b12676..acc78cb0a041 100644 --- a/Generators/PowhegControl/python/processes/powheg/ggF_HH_SMEFT.py +++ b/Generators/PowhegControl/python/processes/powheg/ggF_HH_SMEFT.py @@ -1,6 +1,5 @@ # Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration import os -import glob from AthenaCommon import Logging from ..powheg_V2 import PowhegV2 -- GitLab From 2dc83a89f0e9f2d858a6aa1f0af6d29b591dcd35 Mon Sep 17 00:00:00 2001 From: Andrii Verbytskyi <andrii.verbytskyi@cern.ch> Date: Fri, 14 Feb 2025 18:20:03 +0000 Subject: [PATCH 6/6] Update ggF_HH_quartic.py --- .../PowhegControl/python/processes/powheg/ggF_HH_quartic.py | 1 - 1 file changed, 1 deletion(-) diff --git a/Generators/PowhegControl/python/processes/powheg/ggF_HH_quartic.py b/Generators/PowhegControl/python/processes/powheg/ggF_HH_quartic.py index 7acf71460d1d..af9bc79e94c5 100644 --- a/Generators/PowhegControl/python/processes/powheg/ggF_HH_quartic.py +++ b/Generators/PowhegControl/python/processes/powheg/ggF_HH_quartic.py @@ -1,6 +1,5 @@ # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration import os -import glob from AthenaCommon import Logging from ..powheg_V2 import PowhegV2 -- GitLab