From c2fceae7718fbe979caba755d3fc749ff44988fb Mon Sep 17 00:00:00 2001 From: Andrii Verbytskyi <andrii.verbytskyi@cern.ch> Date: Mon, 20 Apr 2020 11:40:15 +0000 Subject: [PATCH] Some clenup in the Generators, preparation for HepMC3 migration --- Generators/AtlasHepMC/AtlasHepMC/GenParticle.h | 6 +++--- Generators/AtlasHepMC/AtlasHepMC/SimpleVector_fwd.h | 9 +++++++++ .../GenAnalysisTools/EventBoost/src/EventBoost.cxx | 4 ++-- Generators/GenAnalysisTools/ReweightTools/CMakeLists.txt | 1 + Generators/GenInterfaces/CMakeLists.txt | 1 + .../GenInterfaces/GenInterfaces/GenInterfacesDict.h | 4 ++-- Generators/HepMCAnalysis_i/src/PdfAnalysis.cxx | 2 +- Generators/Hydjet_i/src/Hydjet_i.cxx | 8 ++++---- Generators/ParticleDecayer/src/ParticleDecayer.cxx | 4 ++-- Generators/QGSJet_i/CMakeLists.txt | 1 + Generators/Starlight_i/src/Starlight_i.cxx | 4 ++-- Generators/TruthIO/CMakeLists.txt | 1 + Generators/TruthUtils/CMakeLists.txt | 5 +++++ Generators/TruthUtils/TruthUtils/HepMCHelpers.h | 2 ++ .../TruthParticleID/McParticleEvent/CMakeLists.txt | 1 + Reconstruction/MissingETEvent/CMakeLists.txt | 1 + 16 files changed, 38 insertions(+), 16 deletions(-) create mode 100644 Generators/AtlasHepMC/AtlasHepMC/SimpleVector_fwd.h diff --git a/Generators/AtlasHepMC/AtlasHepMC/GenParticle.h b/Generators/AtlasHepMC/AtlasHepMC/GenParticle.h index 9c8a072c8b8..c245613597d 100644 --- a/Generators/AtlasHepMC/AtlasHepMC/GenParticle.h +++ b/Generators/AtlasHepMC/AtlasHepMC/GenParticle.h @@ -10,8 +10,8 @@ typedef GenParticle* ConstGenParticlePtr; inline GenParticlePtr newGenParticlePtr(const HepMC::FourVector &mom = HepMC::FourVector(0.0,0.0,0.0,0.0), int pid = 0, int status = 0) { return new HepMC::GenParticle(mom,pid,status); } -inline int barcode(GenParticlePtr p) { -return p->barcode(); -} +inline int barcode(GenParticle p) { return p.barcode(); } +template <class T> inline int barcode(T p) { return p->barcode(); } + } #endif diff --git a/Generators/AtlasHepMC/AtlasHepMC/SimpleVector_fwd.h b/Generators/AtlasHepMC/AtlasHepMC/SimpleVector_fwd.h new file mode 100644 index 00000000000..229542d3a31 --- /dev/null +++ b/Generators/AtlasHepMC/AtlasHepMC/SimpleVector_fwd.h @@ -0,0 +1,9 @@ +/* Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + Author: Andrii Verbytskyi andrii.verbytskyi@mpp.mpg.de + */ +#ifndef ATLASHEPMC_SIMPLEVECTOR_FWD_H +#define ATLASHEPMC_SIMPLEVECTOR_FWD_H +namespace HepMC { +class FourVector; +} +#endif \ No newline at end of file diff --git a/Generators/GenAnalysisTools/EventBoost/src/EventBoost.cxx b/Generators/GenAnalysisTools/EventBoost/src/EventBoost.cxx index 3b50172dd02..a891dd97543 100755 --- a/Generators/GenAnalysisTools/EventBoost/src/EventBoost.cxx +++ b/Generators/GenAnalysisTools/EventBoost/src/EventBoost.cxx @@ -276,7 +276,7 @@ bool EventBoost::doModification(HepMC::GenParticle * part, double& pxsum ) { double temp=mom.x(); mom.boost(boostvector); - part->set_momentum(mom); + part->set_momentum(HepMC::FourVector(mom.px(),mom.py(),mom.pz(),mom.e())); if (part->status()==1) { pxsum+=mom.x()-temp; } @@ -300,7 +300,7 @@ bool EventBoost::doVertexModification(HepMC::GenVertex * ver, double rand_x, dou CLHEP::HepLorentzVector vertex_offset(rand_x, rand_y, rand_z); CLHEP::HepLorentzVector new_vertex_pos(vertex.x()+vertex_offset.x(), vertex.y()+vertex_offset.y(), vertex.z()+vertex_offset.z()); - ver->set_position(new_vertex_pos); + ver->set_position(HepMC::FourVector(new_vertex_pos.x(),new_vertex_pos.y(),new_vertex_pos.z(),new_vertex_pos.t())); msg(MSG::DEBUG) << "Vertex position modified from ("<<vertex.x()<<", "<<vertex.y()<<", "<<vertex.z()<<") to ("<<new_vertex_pos.x()<<", "<<new_vertex_pos.y()<<", "<<new_vertex_pos.z()<<")" << endmsg; diff --git a/Generators/GenAnalysisTools/ReweightTools/CMakeLists.txt b/Generators/GenAnalysisTools/ReweightTools/CMakeLists.txt index 3877084fea5..82ba5b5dab6 100644 --- a/Generators/GenAnalysisTools/ReweightTools/CMakeLists.txt +++ b/Generators/GenAnalysisTools/ReweightTools/CMakeLists.txt @@ -14,6 +14,7 @@ atlas_depends_on_subdirs( PUBLIC PRIVATE Control/AthContainers Control/StoreGate + Generators/AtlasHepMC Generators/GeneratorObjects ) # External dependencies: diff --git a/Generators/GenInterfaces/CMakeLists.txt b/Generators/GenInterfaces/CMakeLists.txt index 793dd383df4..d37350aaf38 100644 --- a/Generators/GenInterfaces/CMakeLists.txt +++ b/Generators/GenInterfaces/CMakeLists.txt @@ -4,6 +4,7 @@ atlas_subdir( GenInterfaces ) # The dependencies of the package: atlas_depends_on_subdirs( PUBLIC + Generators/AtlasHepMC GaudiKernel ) # External dependencies: diff --git a/Generators/GenInterfaces/GenInterfaces/GenInterfacesDict.h b/Generators/GenInterfaces/GenInterfaces/GenInterfacesDict.h index a8a434b0192..b5027c62b81 100644 --- a/Generators/GenInterfaces/GenInterfaces/GenInterfacesDict.h +++ b/Generators/GenInterfaces/GenInterfaces/GenInterfacesDict.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #ifndef GENINTERFACES_GENINTERFACESDICT_H @@ -16,7 +16,7 @@ #include "GenInterfaces/IPDFReweightTool.h" #include "GenInterfaces/ITruthSelector.h" -#include "HepMC/SimpleVector.h" +#include "AtlasHepMC/SimpleVector.h" #include <vector> namespace HforToolDict { diff --git a/Generators/HepMCAnalysis_i/src/PdfAnalysis.cxx b/Generators/HepMCAnalysis_i/src/PdfAnalysis.cxx index d74a0511d11..1c9814872e9 100644 --- a/Generators/HepMCAnalysis_i/src/PdfAnalysis.cxx +++ b/Generators/HepMCAnalysis_i/src/PdfAnalysis.cxx @@ -25,7 +25,7 @@ #include "fastjet/JetDefinition.hh" #include "fastjet/SISConePlugin.hh" -// #include "TruthUtils/HepMCUtils.h" + #include "TruthUtils/HepMCHelpers.h" #include "../HepMCAnalysis_i/PdfAnalysis.h" diff --git a/Generators/Hydjet_i/src/Hydjet_i.cxx b/Generators/Hydjet_i/src/Hydjet_i.cxx index 879ceeae3a6..bcdd5121793 100644 --- a/Generators/Hydjet_i/src/Hydjet_i.cxx +++ b/Generators/Hydjet_i/src/Hydjet_i.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ // ------------------------------------------------------------- @@ -253,18 +253,18 @@ Hydjet::fillEvt(HepMC::GenEvent* evt) double eproj = m_e/2.0; int proj_id = (int) m_a; - v1->add_particle_in( new HepMC::GenParticle( CLHEP::HepLorentzVector(0., 0., eproj, eproj), proj_id, 101 ) ); + v1->add_particle_in( new HepMC::GenParticle( HepMC::FourVector(0., 0., eproj, eproj), proj_id, 101 ) ); double etarg = m_e/2.0; int targ_id = (int) m_a; - v1->add_particle_in( new HepMC::GenParticle( CLHEP::HepLorentzVector(0., 0., -etarg, etarg), targ_id, 102 ) ); + v1->add_particle_in( new HepMC::GenParticle( HepMC::FourVector(0., 0., -etarg, etarg), targ_id, 102 ) ); // Loop on all final particles and // put them all as outgoing from the event vertex for (int i = 1; i <= m_lujets.n(); ++i) { v1->add_particle_out( new HepMC::GenParticle( - CLHEP::HepLorentzVector(m_lujets.p(i, 1), m_lujets.p(i, 2), + HepMC::FourVector(m_lujets.p(i, 1), m_lujets.p(i, 2), m_lujets.p(i, 3), m_lujets.p(i, 4)), m_lujets.k(i, 2), 1 ) ); } diff --git a/Generators/ParticleDecayer/src/ParticleDecayer.cxx b/Generators/ParticleDecayer/src/ParticleDecayer.cxx index ea522466662..24ecfc76cac 100644 --- a/Generators/ParticleDecayer/src/ParticleDecayer.cxx +++ b/Generators/ParticleDecayer/src/ParticleDecayer.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ // SUMMARY: This code implements a "particle decayer" to allow us to augment the standard @@ -113,7 +113,7 @@ StatusCode ParticleDecayer::changeMass( HepMC::GenParticle* genpart, double newM double pz = p*cos(theta); //Fill the four-momentum const CLHEP::HepLorentzVector updatedLV(px,py,pz,e); - genpart->set_momentum(updatedLV); + genpart->set_momentum(HepMC::FourVector(updatedLV.x(),updatedLV.y(),updatedLV.z(),updatedLV.e())); genpart->set_generated_mass(newMass); return StatusCode::SUCCESS; } diff --git a/Generators/QGSJet_i/CMakeLists.txt b/Generators/QGSJet_i/CMakeLists.txt index 74608c333b6..2a134271151 100644 --- a/Generators/QGSJet_i/CMakeLists.txt +++ b/Generators/QGSJet_i/CMakeLists.txt @@ -8,6 +8,7 @@ atlas_subdir( QGSJet_i ) # Declare the package's dependencies: atlas_depends_on_subdirs( PUBLIC Generators/GeneratorModules + Generators/AtlasHepMC PRIVATE Control/AthenaKernel GaudiKernel diff --git a/Generators/Starlight_i/src/Starlight_i.cxx b/Generators/Starlight_i/src/Starlight_i.cxx index 2da86eaad0f..1db607d04d1 100644 --- a/Generators/Starlight_i/src/Starlight_i.cxx +++ b/Generators/Starlight_i/src/Starlight_i.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ // ------------------------------------------------------------- @@ -214,7 +214,7 @@ Starlight_i::fillEvt(HepMC::GenEvent* evt) ATH_MSG_DEBUG( "saving particle " << ipart ); v1->add_particle_out( - new HepMC::GenParticle(CLHEP::HepLorentzVector(px, py, pz, e), pid, 1) ); + new HepMC::GenParticle(HepMC::FourVector(px, py, pz, e), pid, 1) ); } ATH_MSG_DEBUG( "Saved " << ipart << " tracks " ); diff --git a/Generators/TruthIO/CMakeLists.txt b/Generators/TruthIO/CMakeLists.txt index ffe7a4f709d..401a857bb29 100644 --- a/Generators/TruthIO/CMakeLists.txt +++ b/Generators/TruthIO/CMakeLists.txt @@ -10,6 +10,7 @@ atlas_depends_on_subdirs( PUBLIC Control/AthenaBaseComps GaudiKernel Generators/GeneratorModules + Generators/AtlasHepMC PRIVATE Control/StoreGate Event/EventInfo diff --git a/Generators/TruthUtils/CMakeLists.txt b/Generators/TruthUtils/CMakeLists.txt index 92c4892cd90..c2a97430587 100644 --- a/Generators/TruthUtils/CMakeLists.txt +++ b/Generators/TruthUtils/CMakeLists.txt @@ -6,6 +6,11 @@ # Declare the package name: atlas_subdir( TruthUtils ) +# Declare the package's dependencies: +atlas_depends_on_subdirs( + PUBLIC + Generators/AtlasHepMC ) + # External dependencies: find_package( Boost ) find_package( HEPUtils ) diff --git a/Generators/TruthUtils/TruthUtils/HepMCHelpers.h b/Generators/TruthUtils/TruthUtils/HepMCHelpers.h index 38a8f236c34..94bfb1858e6 100644 --- a/Generators/TruthUtils/TruthUtils/HepMCHelpers.h +++ b/Generators/TruthUtils/TruthUtils/HepMCHelpers.h @@ -12,6 +12,8 @@ #include "TruthUtils/PIDHelpers.h" #include "TruthUtils/TruthParticleHelpers.h" #include "MCUtils/HepMCUtils.h" +#include "MCUtils/PIDUtils.h" +#include "AtlasHepMC/GenEvent.h" namespace MC { diff --git a/PhysicsAnalysis/TruthParticleID/McParticleEvent/CMakeLists.txt b/PhysicsAnalysis/TruthParticleID/McParticleEvent/CMakeLists.txt index 37b70bc2217..6eec381c1da 100644 --- a/PhysicsAnalysis/TruthParticleID/McParticleEvent/CMakeLists.txt +++ b/PhysicsAnalysis/TruthParticleID/McParticleEvent/CMakeLists.txt @@ -17,6 +17,7 @@ atlas_depends_on_subdirs( Generators/GeneratorObjects PhysicsAnalysis/AnalysisCommon/ParticleEvent Tracking/TrkEvent/VxVertex + Generators/AtlasHepMC PRIVATE AtlasTest/TestTools GaudiKernel ) diff --git a/Reconstruction/MissingETEvent/CMakeLists.txt b/Reconstruction/MissingETEvent/CMakeLists.txt index f39849d5f0c..f8b2161efad 100644 --- a/Reconstruction/MissingETEvent/CMakeLists.txt +++ b/Reconstruction/MissingETEvent/CMakeLists.txt @@ -16,6 +16,7 @@ atlas_depends_on_subdirs( PUBLIC Event/NavFourMom GaudiKernel PRIVATE + Generators/AtlasHepMC Control/CxxUtils Generators/GenAnalysisTools/TruthHelper ) -- GitLab