From 630a642f67c07b9b6ac842dec8cf2a557dc6a530 Mon Sep 17 00:00:00 2001 From: Andrea Ciarma Date: Wed, 13 Apr 2022 11:11:37 +0200 Subject: [PATCH 01/21] added old version of MDIReader --- k4Gen/src/components/MDIReader.cpp | 156 +++++++++++++++++++++++++++++ k4Gen/src/components/MDIReader.h | 70 +++++++++++++ 2 files changed, 226 insertions(+) create mode 100644 k4Gen/src/components/MDIReader.cpp create mode 100644 k4Gen/src/components/MDIReader.h diff --git a/k4Gen/src/components/MDIReader.cpp b/k4Gen/src/components/MDIReader.cpp new file mode 100644 index 0000000..778072c --- /dev/null +++ b/k4Gen/src/components/MDIReader.cpp @@ -0,0 +1,156 @@ + +#include "MDIReader.h" + +#include "GaudiKernel/IIncidentSvc.h" +#include "GaudiKernel/Incident.h" +#include "GaudiKernel/IEventProcessor.h" + +#include "edm4hep/MCParticleCollection.h" + +#include +#include +#include + +DECLARE_COMPONENT(MDIReader) + +MDIReader::MDIReader(const std::string& name, ISvcLocator* svcLoc): +GaudiAlgorithm(name, svcLoc), + m_filename() { + + declareProperty("MDIFilename", m_filename="", "Name of the MDI file to read"); + declareProperty("GenParticles", m_genphandle, "Generated particles collection (output)"); + declareProperty("CrossingAngle",xing,"Half the crossing angle beam in [rad]"); + declareProperty("LongitudinalCut",cut_z,"the value for cut_z used in GP++ in [um]"); +} + +StatusCode MDIReader::initialize() +{ + StatusCode sc = GaudiAlgorithm::initialize(); + + m_input.open(m_filename.c_str(), std::ifstream::in); + + if ( !m_input.good() ) { + error() << "Failed to open input stream:"+m_filename << endmsg; + return StatusCode::FAILURE; + } + return StatusCode::SUCCESS; +} + +StatusCode MDIReader::execute() +{ + // First check the input file status + if(m_input.eof()) + { + error() << "End of file reached" << endmsg; + return StatusCode::FAILURE; + } + + // Loop over particles + int ISTHEP = 1; // status code + int IDHEP; // PDG code + int CHARGE; // charge + //int JMOHEP1; // first mother + //int JMOHEP2; // last mother + //int JDAHEP1; // first daughter + //int JDAHEP2; // last daughter + double PHEP1; // px in GeV/c + double PHEP2; // py in GeV/c + double PHEP3; // pz in GeV/c + double PHEP4; // energy in GeV + double PHEP5; // mass in GeV/c**2 + double VHEP1; // x vertex position in mm + double VHEP2; // y vertex position in mm + double VHEP3; // z vertex position in mm + double VHEP4 = 0; // production time in mm/c + + //these variables do not end up in the EDM format + double process; // 1=Breit-Wheeler 2=Bethe-Heitler 3=Landau-Lifshitz + double trash; // trash variable + double id_ee; // same id means they are a pair + double temp_x,temp_y,temp_z,temp_px, temp_py,temp_pz,temp_e; + + std::cout<<"The crossing angle is "<> PHEP4 + >> PHEP1 >> PHEP2 >> PHEP3 + >> VHEP1 >> VHEP2 >> VHEP3 + >> process >> trash >> id_ee; + + std::cout<create(); + + particle.setPDG(IDHEP); + particle.setCharge(CHARGE); + particle.setGeneratorStatus(ISTHEP); + particle.setMomentum({ + (float) (PHEP1), + (float) (PHEP2), + (float) (PHEP3), + }); + particle.setMass(PHEP5); + particle.setVertex({ + VHEP1, + VHEP2, + VHEP3, + }); + particle.setTime(VHEP4); + } + + m_genphandle.put(particles); + return StatusCode::SUCCESS; +} + +StatusCode MDIReader::finalize() +{ + m_input.close(); + std::cout<<"Fine di MDIreader"< m_genphandle {"GenParticles", Gaudi::DataHandle::Writer, this}; + + + /// Tools to handle input from HepMC-file + ToolHandle m_signalFileReader; + ToolHandle m_pileupFileReader; + + /// Tool to merge HepMC events + ToolHandle m_HepMCMergeTool; + // Tool to smear vertices + ToolHandle m_vertexSmearingTool; +}; + +#endif //GENERATION_MDIREADER_H From c90cc083d9323ff3ba1088d456b0f060348ee45d Mon Sep 17 00:00:00 2001 From: Andrea Ciarma Date: Wed, 13 Apr 2022 11:53:32 +0200 Subject: [PATCH 02/21] MDIReader - using MutableMCParticle --- k4Gen/src/components/MDIReader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/k4Gen/src/components/MDIReader.cpp b/k4Gen/src/components/MDIReader.cpp index 778072c..2a6cdc2 100644 --- a/k4Gen/src/components/MDIReader.cpp +++ b/k4Gen/src/components/MDIReader.cpp @@ -125,7 +125,7 @@ StatusCode MDIReader::execute() VHEP1=0; VHEP2=0; VHEP3=0; - edm4hep::MCParticle particle = particles->create(); + edm4hep::MutableMCParticle particle = particles->create(); particle.setPDG(IDHEP); particle.setCharge(CHARGE); From 8824975168ff7c463fa8b11a9738b4f4d8c1dabf Mon Sep 17 00:00:00 2001 From: Andrea Ciarma Date: Wed, 13 Apr 2022 14:27:09 +0200 Subject: [PATCH 03/21] MDIReader - minor changes --- k4Gen/src/components/MDIReader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/k4Gen/src/components/MDIReader.cpp b/k4Gen/src/components/MDIReader.cpp index 2a6cdc2..3f7f6b3 100644 --- a/k4Gen/src/components/MDIReader.cpp +++ b/k4Gen/src/components/MDIReader.cpp @@ -81,7 +81,7 @@ StatusCode MDIReader::execute() >> VHEP1 >> VHEP2 >> VHEP3 >> process >> trash >> id_ee; - std::cout< Date: Wed, 13 Apr 2022 17:31:19 +0200 Subject: [PATCH 04/21] MDIReader - added 'InputType' property --- k4Gen/src/components/MDIReader.cpp | 136 +++++++++++++++++++---------- k4Gen/src/components/MDIReader.h | 2 +- 2 files changed, 92 insertions(+), 46 deletions(-) diff --git a/k4Gen/src/components/MDIReader.cpp b/k4Gen/src/components/MDIReader.cpp index 3f7f6b3..1a67e93 100644 --- a/k4Gen/src/components/MDIReader.cpp +++ b/k4Gen/src/components/MDIReader.cpp @@ -21,6 +21,8 @@ GaudiAlgorithm(name, svcLoc), declareProperty("GenParticles", m_genphandle, "Generated particles collection (output)"); declareProperty("CrossingAngle",xing,"Half the crossing angle beam in [rad]"); declareProperty("LongitudinalCut",cut_z,"the value for cut_z used in GP++ in [um]"); + declareProperty("InputType",input_type,"string: guineapig, xtrack"); + declareProperty("BeamEnergy",beam_energy,"beam energy [GeV], necessary for xtrack type"); } StatusCode MDIReader::initialize() @@ -45,6 +47,16 @@ StatusCode MDIReader::execute() return StatusCode::FAILURE; } + // Check the input type flag + if(input_type!="guineapig" && input_type!="xtrack") + { + error() << "Input type flag - wrong definition: "<< input_type << endmsg; + return StatusCode::FAILURE; + } + else{ + std::cout<<"Selected input type : "<> PHEP4 - >> PHEP1 >> PHEP2 >> PHEP3 - >> VHEP1 >> VHEP2 >> VHEP3 - >> process >> trash >> id_ee; - - //std::cout<> PHEP4 + >> PHEP1 >> PHEP2 >> PHEP3 + >> VHEP1 >> VHEP2 >> VHEP3 + >> process >> trash >> id_ee; - if(m_input.eof())break; - else if(!m_input.good()) - { - std::cout<<"oopsie doopsie"<> VHEP3 + >> VHEP1 >> VHEP2 + >> PHEP1 >> PHEP2 + >> temp_z >> PHEP4 ; + + if(m_input.eof())break; + else if(!m_input.good()) + { + std::cout<<"oopsie doopsie"<create(); particle.setPDG(IDHEP); diff --git a/k4Gen/src/components/MDIReader.h b/k4Gen/src/components/MDIReader.h index 159f76f..3f6d146 100644 --- a/k4Gen/src/components/MDIReader.h +++ b/k4Gen/src/components/MDIReader.h @@ -52,7 +52,7 @@ class MDIReader: public GaudiAlgorithm { int NHEP; int m_format; std::string input_type; - double xing, cut_z; + double xing, cut_z, beam_energy; /// Handle for the genparticles to be written DataHandle m_genphandle {"GenParticles", Gaudi::DataHandle::Writer, this}; From 1a6b1b2be1a65471d3e6c6f50e7ad1883506c7af Mon Sep 17 00:00:00 2001 From: Andrea Ciarma Date: Wed, 13 Apr 2022 18:03:09 +0200 Subject: [PATCH 05/21] MDIReader - added 'xtrack' rotation --- k4Gen/src/components/MDIReader.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/k4Gen/src/components/MDIReader.cpp b/k4Gen/src/components/MDIReader.cpp index 1a67e93..47cf789 100644 --- a/k4Gen/src/components/MDIReader.cpp +++ b/k4Gen/src/components/MDIReader.cpp @@ -156,6 +156,12 @@ StatusCode MDIReader::execute() //VHEP3 = VHEP3 + temp_z; //is ct necessary? prob not + //---position rotation in CLD frame + temp_z = VHEP3*cos(-xing) + VHEP1*sin(-xing); + temp_x = -VHEP3*sin(-xing) + VHEP1*cos(-xing); + VHEP1 = temp_x; + VHEP3 = temp_z; + VHEP1 *=1e3; //convert from m to mm VHEP2 *=1e3; //convert from m to mm VHEP3 *=1e3; //convert from m to mm @@ -165,6 +171,10 @@ StatusCode MDIReader::execute() PHEP2 = PHEP2*beam_energy; PHEP3 = sqrt(pow(PHEP4,2) - pow(PHEP1,2) - pow(PHEP2,2) ); + //---momentum rotation in CLD frame + temp_pz = PHEP3*cos(-xing) + PHEP1*sin(-xing); + temp_px = -PHEP3*sin(-xing) + PHEP1*cos(-xing); + IDHEP = 11; CHARGE = -1; From 9dccdfe778a33281f56317987da0d4df3f0804dc Mon Sep 17 00:00:00 2001 From: Andrea Ciarma Date: Wed, 13 Apr 2022 18:27:26 +0200 Subject: [PATCH 06/21] MDIReader - 'xtrack' minor upd --- k4Gen/src/components/MDIReader.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/k4Gen/src/components/MDIReader.cpp b/k4Gen/src/components/MDIReader.cpp index 47cf789..fc5d7da 100644 --- a/k4Gen/src/components/MDIReader.cpp +++ b/k4Gen/src/components/MDIReader.cpp @@ -140,12 +140,15 @@ StatusCode MDIReader::execute() VHEP2=0; VHEP3=0; }//end if guineapig + else if(input_type=="xtrack"){ m_input >> VHEP3 >> VHEP1 >> VHEP2 >> PHEP1 >> PHEP2 >> temp_z >> PHEP4 ; + std::cout< Date: Thu, 14 Apr 2022 00:52:43 +0200 Subject: [PATCH 07/21] MDIReader - 'xtrack' minor upd --- k4Gen/src/components/MDIReader.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/k4Gen/src/components/MDIReader.cpp b/k4Gen/src/components/MDIReader.cpp index fc5d7da..abe55b5 100644 --- a/k4Gen/src/components/MDIReader.cpp +++ b/k4Gen/src/components/MDIReader.cpp @@ -147,8 +147,6 @@ StatusCode MDIReader::execute() >> PHEP1 >> PHEP2 >> temp_z >> PHEP4 ; - std::cout< Date: Thu, 5 May 2022 17:57:20 +0200 Subject: [PATCH 08/21] typo HEPPDT_INCLUDE_DIR, added package HEPMC --- k4Gen/CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/k4Gen/CMakeLists.txt b/k4Gen/CMakeLists.txt index 56f34a5..d7adc47 100644 --- a/k4Gen/CMakeLists.txt +++ b/k4Gen/CMakeLists.txt @@ -6,16 +6,18 @@ find_package(HepMC3) find_package(Pythia8 COMPONENTS pythia8 pythia8tohepmc) find_package(HepPDT) find_package(EvtGen) +find_package(HepMC) file(GLOB k4gen_plugin_sources src/components/*.cpp) gaudi_add_module(k4Gen SOURCES ${k4gen_plugin_sources} - LINK Gaudi::GaudiKernel ${HEPMC3_LIBRARIES} Gaudi::GaudiAlgLib k4FWCore::k4FWCore ${HEPPDT_LIBRARIES} ${EVTGEN_LIBRARIES} EDM4HEP::edm4hep EDM4HEP::edm4hepDict) + LINK Gaudi::GaudiKernel ${HEPMC3_LIBRARIES} Gaudi::GaudiAlgLib k4FWCore::k4FWCore ${HEPPDT_LIBRARIES} ${EVTGEN_LIBRARIES} EDM4HEP::edm4hep EDM4HEP::edm4hepDict ${HEPMC_LIBRARIES}) target_include_directories(k4Gen PUBLIC ${PYTHIA8_INCLUDE_DIRS} ${HEPMC3_INCLUDE_DIR} ${HEPPDT_ICNCLUDE_DIR} ${EVTGEN_INCLUDE_DIR} + ${HEPMC_INCLUDE_DIR} $ $) From d321837f4af3025878b07742be8028cb9e9e07d7 Mon Sep 17 00:00:00 2001 From: Andrea Ciarma Date: Thu, 5 May 2022 18:01:40 +0200 Subject: [PATCH 09/21] typo --- k4Gen/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/k4Gen/CMakeLists.txt b/k4Gen/CMakeLists.txt index d7adc47..b9b4320 100644 --- a/k4Gen/CMakeLists.txt +++ b/k4Gen/CMakeLists.txt @@ -15,7 +15,7 @@ gaudi_add_module(k4Gen target_include_directories(k4Gen PUBLIC ${PYTHIA8_INCLUDE_DIRS} ${HEPMC3_INCLUDE_DIR} - ${HEPPDT_ICNCLUDE_DIR} + ${HEPPDT_INCLUDE_DIR} ${EVTGEN_INCLUDE_DIR} ${HEPMC_INCLUDE_DIR} $ From 716b77394f10a4b0194cda0d803d08f41bd51785 Mon Sep 17 00:00:00 2001 From: Andrea Ciarma Date: Fri, 6 May 2022 09:54:21 +0200 Subject: [PATCH 10/21] set RPATH --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 15911f4..7d80255 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,6 +29,7 @@ endif() set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH}) +set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE CACHE BOOL "RPATH USE LINK PATH") add_subdirectory(k4Gen) From b329de8302404e80de672807be46f86a10f94124 Mon Sep 17 00:00:00 2001 From: Andrea Ciarma Date: Fri, 6 May 2022 11:12:48 +0200 Subject: [PATCH 11/21] changed std::cout to debug() --- k4Gen/src/components/MDIReader.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/k4Gen/src/components/MDIReader.cpp b/k4Gen/src/components/MDIReader.cpp index abe55b5..07ac423 100644 --- a/k4Gen/src/components/MDIReader.cpp +++ b/k4Gen/src/components/MDIReader.cpp @@ -54,7 +54,7 @@ StatusCode MDIReader::execute() return StatusCode::FAILURE; } else{ - std::cout<<"Selected input type : "< Date: Fri, 6 May 2022 14:09:54 +0200 Subject: [PATCH 12/21] MDIReader: removed HepMC dependancy --- k4Gen/src/components/MDIReader.h | 7 ------- 1 file changed, 7 deletions(-) diff --git a/k4Gen/src/components/MDIReader.h b/k4Gen/src/components/MDIReader.h index 3f6d146..34f5bf4 100644 --- a/k4Gen/src/components/MDIReader.h +++ b/k4Gen/src/components/MDIReader.h @@ -13,13 +13,6 @@ #include "GaudiKernel/SystemOfUnits.h" -#include "HepMC/IO_GenEvent.h" - - -namespace HepMC { - class GenEvent; -} - namespace edm4hep { class MCParticleCollection; } From 9c14623f2de32b657835b5c7918b81a2c7134a9e Mon Sep 17 00:00:00 2001 From: Andrea Ciarma Date: Fri, 6 May 2022 14:50:32 +0200 Subject: [PATCH 13/21] MDIReader: removed HepMC dependancy - fix --- k4Gen/src/components/MDIReader.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/k4Gen/src/components/MDIReader.h b/k4Gen/src/components/MDIReader.h index 34f5bf4..0b26afb 100644 --- a/k4Gen/src/components/MDIReader.h +++ b/k4Gen/src/components/MDIReader.h @@ -13,6 +13,9 @@ #include "GaudiKernel/SystemOfUnits.h" +#include "HepMC3/GenEvent.h" +#include "HepMC3/ReaderAscii.h" + namespace edm4hep { class MCParticleCollection; } From 200df77d1fce22673503dfc7cb40c0f3a2e2225f Mon Sep 17 00:00:00 2001 From: Andrea Ciarma Date: Fri, 6 May 2022 15:55:07 +0200 Subject: [PATCH 14/21] MDIReader: added test --- k4Gen/CMakeLists.txt | 6 ++ k4Gen/options/mdireader_test.py | 67 +++++++++++++++++++++++ k4Gen/options/mdireader_testparticles.dat | 3 + 3 files changed, 76 insertions(+) create mode 100644 k4Gen/options/mdireader_test.py create mode 100644 k4Gen/options/mdireader_testparticles.dat diff --git a/k4Gen/CMakeLists.txt b/k4Gen/CMakeLists.txt index b9b4320..05e122a 100644 --- a/k4Gen/CMakeLists.txt +++ b/k4Gen/CMakeLists.txt @@ -70,6 +70,12 @@ set_tests_properties(Pythia8ExtraSettings PROPERTIES ) set_test_env(Pythia8ExtraSettings) +add_test(NAME MDIreader + WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} + COMMAND k4run ${CMAKE_CURRENT_LIST_DIR}/options/mdireader_test.py + ) +set_test_env(MDIreader) + #--- Install the example options to the directory where the spack installation #--- points the $K4GEN environment variable install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/options diff --git a/k4Gen/options/mdireader_test.py b/k4Gen/options/mdireader_test.py new file mode 100644 index 0000000..ef3eea2 --- /dev/null +++ b/k4Gen/options/mdireader_test.py @@ -0,0 +1,67 @@ +from Gaudi.Configuration import * +import os + +# Data service +from Configurables import FCCDataSvc +podioevent = FCCDataSvc("EventDataSvc") + +from Configurables import MDIReader +mdi_converter = MDIReader("Reader",MDIFilename="mdireader_testparticles.dat") +mdi_converter.GenParticles.Path = "allGenParticles" +mdi_converter.CrossingAngle = 0.0 +mdi_converter.LongitudinalCut = 0 +mdi_converter.InputType = "xtrack" +mdi_converter.BeamEnergy = 45.6 + +# DD4hep geometry service +# Parses the given xml file +from Configurables import GeoSvc +geoservice = GeoSvc("GeoSvc", detectors=[ + #os.path.join(os.environ["FCCDETECTORS"], 'Detector/DetFCCeeCLD/compact/FCCee_DectMaster.xml'), + #os.path.join(os.environ["FCCDETECTORS"], 'Detector/DetFCCeeCLD/compact/FCCee_o2_v02/FCCee_o2_v02.xml'), + os.path.join(os.environ["FCCDETECTORS"], 'Detector/DetCommon/compact/Box.xml'), + ]) + +# Geant4 service +# Configures the Geant simulation: geometry, physics list and user actions +from Configurables import SimG4Svc, SimG4FullSimActions, SimG4UserLimitPhysicsList, SimG4UserLimitRegion +from GaudiKernel.SystemOfUnits import mm + + +# giving the names of tools will initialize the tools of that type +geantservice = SimG4Svc("SimG4Svc", detector='SimG4DD4hepDetector', physicslist="SimG4FtfpBert" + ) + + +# Geant4 algorithm +# Translates EDM to G4Event, passes the event to G4, writes out outputs via tools +from Configurables import SimG4Alg, SimG4PrimariesFromEdmTool + +particle_converter = SimG4PrimariesFromEdmTool("EdmConverter") +particle_converter.GenParticles.Path = "allGenParticles" + + +geantsim = SimG4Alg("SimG4Alg", + outputs= [ + ], + eventProvider=particle_converter) + + +# PODIO algorithm +from Configurables import PodioOutput +out = PodioOutput("out", + filename="mdireader_test_out.root", + OutputLevel=INFO) +out.outputCommands = ["keep *"] + +# ApplicationMgr +from Configurables import ApplicationMgr +ApplicationMgr( TopAlg = [mdi_converter, geantsim, out], + #TopAlg = [mdi_converter, out], + EvtSel = 'NONE', + EvtMax = 1, + # order is important, as GeoSvc is needed by SimG4Svc + ExtSvc = [podioevent, geoservice, geantservice], + #ExtSvc = [podioevent], + OutputLevel=INFO + ) diff --git a/k4Gen/options/mdireader_testparticles.dat b/k4Gen/options/mdireader_testparticles.dat new file mode 100644 index 0000000..d9c9109 --- /dev/null +++ b/k4Gen/options/mdireader_testparticles.dat @@ -0,0 +1,3 @@ +0.0 0.0 0.0 0.0 0.0 0.0 0.0 +0.5 -20.0e-3 20.0e-3 0.5 -0.5 0.0 -0.001 +-0.5 20.0e-3 -20.0e-3 -0.5 0.5 0.0 0.001 From 10158eb6fd3cfc20a6662319ae1cdb9c48d7cd8c Mon Sep 17 00:00:00 2001 From: Andrea Ciarma Date: Fri, 6 May 2022 16:47:39 +0200 Subject: [PATCH 15/21] MDIReader: test fix --- k4Gen/options/mdireader_test.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/k4Gen/options/mdireader_test.py b/k4Gen/options/mdireader_test.py index ef3eea2..f7971ab 100644 --- a/k4Gen/options/mdireader_test.py +++ b/k4Gen/options/mdireader_test.py @@ -6,7 +6,8 @@ podioevent = FCCDataSvc("EventDataSvc") from Configurables import MDIReader -mdi_converter = MDIReader("Reader",MDIFilename="mdireader_testparticles.dat") +#mdi_converter = MDIReader("Reader",MDIFilename="k4Gen/options/mdireader_testparticles.dat") +mdi_converter = MDIReader("Reader",MDIFilename=(os.path.join(os.environ["K4GEN"],'../options/mdireader_testparticles.dat'))) mdi_converter.GenParticles.Path = "allGenParticles" mdi_converter.CrossingAngle = 0.0 mdi_converter.LongitudinalCut = 0 From 096cc65559d66d1f5f23728c1b3013376c633315 Mon Sep 17 00:00:00 2001 From: Andrea Ciarma Date: Tue, 28 Jun 2022 18:11:19 +0200 Subject: [PATCH 16/21] removed Geant4 call in mdireader_test.py --- k4Gen/options/mdireader_test.py | 58 ++++++++++++++++----------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/k4Gen/options/mdireader_test.py b/k4Gen/options/mdireader_test.py index f7971ab..758e4c0 100644 --- a/k4Gen/options/mdireader_test.py +++ b/k4Gen/options/mdireader_test.py @@ -9,43 +9,43 @@ #mdi_converter = MDIReader("Reader",MDIFilename="k4Gen/options/mdireader_testparticles.dat") mdi_converter = MDIReader("Reader",MDIFilename=(os.path.join(os.environ["K4GEN"],'../options/mdireader_testparticles.dat'))) mdi_converter.GenParticles.Path = "allGenParticles" -mdi_converter.CrossingAngle = 0.0 +mdi_converter.CrossingAngle = 0.015 mdi_converter.LongitudinalCut = 0 mdi_converter.InputType = "xtrack" mdi_converter.BeamEnergy = 45.6 -# DD4hep geometry service -# Parses the given xml file -from Configurables import GeoSvc -geoservice = GeoSvc("GeoSvc", detectors=[ - #os.path.join(os.environ["FCCDETECTORS"], 'Detector/DetFCCeeCLD/compact/FCCee_DectMaster.xml'), - #os.path.join(os.environ["FCCDETECTORS"], 'Detector/DetFCCeeCLD/compact/FCCee_o2_v02/FCCee_o2_v02.xml'), - os.path.join(os.environ["FCCDETECTORS"], 'Detector/DetCommon/compact/Box.xml'), - ]) +## DD4hep geometry service +## Parses the given xml file +#from Configurables import GeoSvc +#geoservice = GeoSvc("GeoSvc", detectors=[ + # #os.path.join(os.environ["FCCDETECTORS"], 'Detector/DetFCCeeCLD/compact/FCCee_DectMaster.xml'), + # #os.path.join(os.environ["FCCDETECTORS"], 'Detector/DetFCCeeCLD/compact/FCCee_o2_v02/FCCee_o2_v02.xml'), + # os.path.join(os.environ["FCCDETECTORS"], 'Detector/DetCommon/compact/Box.xml'), + # ]) -# Geant4 service -# Configures the Geant simulation: geometry, physics list and user actions -from Configurables import SimG4Svc, SimG4FullSimActions, SimG4UserLimitPhysicsList, SimG4UserLimitRegion -from GaudiKernel.SystemOfUnits import mm +## Geant4 service +## Configures the Geant simulation: geometry, physics list and user actions +#from Configurables import SimG4Svc, SimG4FullSimActions, SimG4UserLimitPhysicsList, SimG4UserLimitRegion +#from GaudiKernel.SystemOfUnits import mm -# giving the names of tools will initialize the tools of that type -geantservice = SimG4Svc("SimG4Svc", detector='SimG4DD4hepDetector', physicslist="SimG4FtfpBert" - ) +## giving the names of tools will initialize the tools of that type +#geantservice = SimG4Svc("SimG4Svc", detector='SimG4DD4hepDetector', physicslist="SimG4FtfpBert" + # ) -# Geant4 algorithm -# Translates EDM to G4Event, passes the event to G4, writes out outputs via tools -from Configurables import SimG4Alg, SimG4PrimariesFromEdmTool +## Geant4 algorithm +## Translates EDM to G4Event, passes the event to G4, writes out outputs via tools +#from Configurables import SimG4Alg, SimG4PrimariesFromEdmTool -particle_converter = SimG4PrimariesFromEdmTool("EdmConverter") -particle_converter.GenParticles.Path = "allGenParticles" +#particle_converter = SimG4PrimariesFromEdmTool("EdmConverter") +#particle_converter.GenParticles.Path = "allGenParticles" -geantsim = SimG4Alg("SimG4Alg", - outputs= [ - ], - eventProvider=particle_converter) +#geantsim = SimG4Alg("SimG4Alg", + # outputs= [ + # ], + # eventProvider=particle_converter) # PODIO algorithm @@ -57,12 +57,12 @@ # ApplicationMgr from Configurables import ApplicationMgr -ApplicationMgr( TopAlg = [mdi_converter, geantsim, out], - #TopAlg = [mdi_converter, out], +ApplicationMgr( #TopAlg = [mdi_converter, geantsim, out], + TopAlg = [mdi_converter, out], EvtSel = 'NONE', EvtMax = 1, # order is important, as GeoSvc is needed by SimG4Svc - ExtSvc = [podioevent, geoservice, geantservice], - #ExtSvc = [podioevent], + #ExtSvc = [podioevent, geoservice, geantservice], + ExtSvc = [podioevent], OutputLevel=INFO ) From c696f338b6991275d5dce1084b6fd739c42b5137 Mon Sep 17 00:00:00 2001 From: Andrea Ciarma Date: Wed, 29 Jun 2022 15:08:22 +0200 Subject: [PATCH 17/21] resolve conflicts --- k4Gen/src/components/MDIReader.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/k4Gen/src/components/MDIReader.cpp b/k4Gen/src/components/MDIReader.cpp index 07ac423..9b3a891 100644 --- a/k4Gen/src/components/MDIReader.cpp +++ b/k4Gen/src/components/MDIReader.cpp @@ -82,6 +82,7 @@ StatusCode MDIReader::execute() double temp_x,temp_y,temp_z,temp_px, temp_py,temp_pz,temp_e; debug() <<"The crossing angle is "< Date: Wed, 29 Jun 2022 16:01:12 +0200 Subject: [PATCH 18/21] resolving conflicts --- k4Gen/CMakeLists.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/k4Gen/CMakeLists.txt b/k4Gen/CMakeLists.txt index 00b45dd..60c2320 100644 --- a/k4Gen/CMakeLists.txt +++ b/k4Gen/CMakeLists.txt @@ -6,12 +6,10 @@ find_package(HepMC3) find_package(Pythia8 COMPONENTS pythia8 pythia8tohepmc) find_package(HepPDT) find_package(EvtGen) -find_package(HepMC) file(GLOB k4gen_plugin_sources src/components/*.cpp) gaudi_add_module(k4Gen SOURCES ${k4gen_plugin_sources} -<<<<<<< HEAD LINK Gaudi::GaudiKernel ${HEPMC3_LIBRARIES} Gaudi::GaudiAlgLib k4FWCore::k4FWCore ${HEPPDT_LIBRARIES} ${EVTGEN_LIBRARIES} EDM4HEP::edm4hep EDM4HEP::edm4hepDict ${HEPMC_LIBRARIES}) target_include_directories(k4Gen PUBLIC ${PYTHIA8_INCLUDE_DIRS} From ffb2637ee8fa64f1d1e854f095afa094e17d60df Mon Sep 17 00:00:00 2001 From: Valentin Volkl Date: Fri, 1 Jul 2022 09:03:25 +0200 Subject: [PATCH 19/21] Update CMakeLists.txt --- CMakeLists.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5b2a688..4e525b9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,8 +38,7 @@ endif() set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH}) -set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE CACHE BOOL "RPATH USE LINK PATH") - +#--------------------------------------------------------------- add_subdirectory(k4Gen) #--------------------------------------------------------------- From 338f7b6c37908861347de9bc18182f9fe02164cb Mon Sep 17 00:00:00 2001 From: Valentin Volkl Date: Fri, 1 Jul 2022 09:04:26 +0200 Subject: [PATCH 20/21] Update k4Gen/options/mdireader_test.py --- k4Gen/options/mdireader_test.py | 32 -------------------------------- 1 file changed, 32 deletions(-) diff --git a/k4Gen/options/mdireader_test.py b/k4Gen/options/mdireader_test.py index 758e4c0..dfc0d38 100644 --- a/k4Gen/options/mdireader_test.py +++ b/k4Gen/options/mdireader_test.py @@ -14,38 +14,6 @@ mdi_converter.InputType = "xtrack" mdi_converter.BeamEnergy = 45.6 -## DD4hep geometry service -## Parses the given xml file -#from Configurables import GeoSvc -#geoservice = GeoSvc("GeoSvc", detectors=[ - # #os.path.join(os.environ["FCCDETECTORS"], 'Detector/DetFCCeeCLD/compact/FCCee_DectMaster.xml'), - # #os.path.join(os.environ["FCCDETECTORS"], 'Detector/DetFCCeeCLD/compact/FCCee_o2_v02/FCCee_o2_v02.xml'), - # os.path.join(os.environ["FCCDETECTORS"], 'Detector/DetCommon/compact/Box.xml'), - # ]) - -## Geant4 service -## Configures the Geant simulation: geometry, physics list and user actions -#from Configurables import SimG4Svc, SimG4FullSimActions, SimG4UserLimitPhysicsList, SimG4UserLimitRegion -#from GaudiKernel.SystemOfUnits import mm - - -## giving the names of tools will initialize the tools of that type -#geantservice = SimG4Svc("SimG4Svc", detector='SimG4DD4hepDetector', physicslist="SimG4FtfpBert" - # ) - - -## Geant4 algorithm -## Translates EDM to G4Event, passes the event to G4, writes out outputs via tools -#from Configurables import SimG4Alg, SimG4PrimariesFromEdmTool - -#particle_converter = SimG4PrimariesFromEdmTool("EdmConverter") -#particle_converter.GenParticles.Path = "allGenParticles" - - -#geantsim = SimG4Alg("SimG4Alg", - # outputs= [ - # ], - # eventProvider=particle_converter) # PODIO algorithm From 7bf63e45e4c1dd2f1485a0b5067c79c7d9cf30a4 Mon Sep 17 00:00:00 2001 From: Andrea Ciarma Date: Fri, 16 Dec 2022 16:54:27 +0100 Subject: [PATCH 21/21] MDIReader: added 'photons' and 'general' flags --- k4Gen/src/components/MDIReader.cpp | 89 ++++++++++++++++++++++++++++-- 1 file changed, 83 insertions(+), 6 deletions(-) diff --git a/k4Gen/src/components/MDIReader.cpp b/k4Gen/src/components/MDIReader.cpp index 9b3a891..0d2b954 100644 --- a/k4Gen/src/components/MDIReader.cpp +++ b/k4Gen/src/components/MDIReader.cpp @@ -21,7 +21,7 @@ GaudiAlgorithm(name, svcLoc), declareProperty("GenParticles", m_genphandle, "Generated particles collection (output)"); declareProperty("CrossingAngle",xing,"Half the crossing angle beam in [rad]"); declareProperty("LongitudinalCut",cut_z,"the value for cut_z used in GP++ in [um]"); - declareProperty("InputType",input_type,"string: guineapig, xtrack"); + declareProperty("InputType",input_type,"string: guineapig, xtrack, photons, general"); declareProperty("BeamEnergy",beam_energy,"beam energy [GeV], necessary for xtrack type"); } @@ -48,7 +48,7 @@ StatusCode MDIReader::execute() } // Check the input type flag - if(input_type!="guineapig" && input_type!="xtrack") + if(input_type!="guineapig" && input_type!="xtrack" && input_type!="photons" && input_type!="general") { error() << "Input type flag - wrong definition: "<< input_type << endmsg; return StatusCode::FAILURE; @@ -86,7 +86,7 @@ StatusCode MDIReader::execute() edm4hep::MCParticleCollection* particles = new edm4hep::MCParticleCollection(); - PHEP5 = 5.11e-4; + while(m_input.good()) { if(input_type=="guineapig"){ @@ -95,7 +95,7 @@ StatusCode MDIReader::execute() >> VHEP1 >> VHEP2 >> VHEP3 >> process >> trash >> id_ee; - + PHEP5 = 5.11e-4; //std::cout<> VHEP1 >> PHEP1 + >> VHEP2 >> PHEP2 + >> PHEP4 >> PHEP3 + >> trash ; + PHEP5 = 0; + if(m_input.eof())break; + else if(!m_input.good()) + { + debug() << "End of file reached before reading all the hits" << endmsg; + error() << "End of file reached before reading all the hits" << endmsg; + return StatusCode::FAILURE; + } + + //std::cout<> VHEP1 >> VHEP2 >> VHEP3 + >> PHEP1 >> PHEP2 >> PHEP3 + >> PHEP4 >> IDHEP; + if(m_input.eof())break; + else if(!m_input.good()) + { + debug() << "End of file reached before reading all the hits" << endmsg; + error() << "End of file reached before reading all the hits" << endmsg; + return StatusCode::FAILURE; + } + + //std::cout<create(); particle.setPDG(IDHEP);