From 2d70253208e55605147fc26edeb625206126a182 Mon Sep 17 00:00:00 2001 From: clementhelsens Date: Fri, 2 Oct 2020 16:06:10 +0200 Subject: [PATCH 01/11] add EDM4Hep2LCIO_example --- .../delphes/examples/EDM4Hep2LCIO_example.py | 117 ++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 plugins/delphes/examples/EDM4Hep2LCIO_example.py diff --git a/plugins/delphes/examples/EDM4Hep2LCIO_example.py b/plugins/delphes/examples/EDM4Hep2LCIO_example.py new file mode 100644 index 000000000..af7231d1c --- /dev/null +++ b/plugins/delphes/examples/EDM4Hep2LCIO_example.py @@ -0,0 +1,117 @@ +''' +Created on October 1st, 2020 + +Example for creating LCIO events and filling them with tracks from EDM4Hep + +@author: Clement Helsens +''' + +from pyLCIO import EVENT, IMPL, IOIMPL, UTIL +from time import time +import ROOT as r +import sys, math +#from sixlcio.moves import range + +def generateEvents(inputFileName, outputFileName, nEvents): + + fin = r.TFile(inputFileName) + ttree = fin.events + + # define a detector with positions for the tracker planes + detectorName = 'ToyTracker' + + # create a writer and open the output file + writer = IOIMPL.LCFactory.getInstance().createLCWriter() + writer.open( outputFileName, EVENT.LCIO.WRITE_NEW ) + + # create a run header and add it to the file (optional) + run = IMPL.LCRunHeaderImpl() + run.setRunNumber( 1 ) + run.setDetectorName(str(detectorName)) + run.setDescription( str('This is a test run' )) + writer.writeRunHeader( run ) + iEvent=0 + + + for e in ttree: + if iEvent>nEvents:break + # create an event and set its parameters + event = IMPL.LCEventImpl() + event.setEventNumber( iEvent ) + event.setDetectorName( str(detectorName )) + event.setRunNumber( 1 ) + event.setTimeStamp( int( time() * 1000000000. ) ) + + tracks = IMPL.LCCollectionVec(EVENT.LCIO.TRACK) + recops = IMPL.LCCollectionVec(EVENT.LCIO.RECONSTRUCTEDPARTICLE) + + print ('n reco particles ',e.ReconstructedParticles.size()) + print ('ntracks ',e.EFlowTrack_1.size()) + + counter=1 + #loop over the reconstructed particles + for rp in range(e.ReconstructedParticles.size()): + + recp = IMPL.ReconstructedParticleImpl() + recp.setCharge(e.ReconstructedParticles.at(rp).charge) + momentum = r.TVector3(e.ReconstructedParticles.at(rp).momentum.x, + e.ReconstructedParticles.at(rp).momentum.y, + e.ReconstructedParticles.at(rp).momentum.z) + recp.setMomentumVec(momentum) + recp.setEnergy(e.ReconstructedParticles.at(rp).energy) + + #get the track associated to the reco particle + track = IMPL.TrackImpl() + + #print ('ReconstructedParticles.tracks_begin ',e.ReconstructedParticles.at(rp).tracks_begin) + #print ('ReconstructedParticles.tracks_end ',e.ReconstructedParticles.at(rp).tracks_end) + #print ('ReconstructedParticles#3.size ',getattr(e,'ReconstructedParticles#3.size')) + #print ('ReconstructedParticles#3.index ',getattr(e,'ReconstructedParticles#3.index')) + #print ('ReconstructedParticles#3.collectionID ',getattr(e,'ReconstructedParticles#3.collectionID')) + #toto=getattr(e,'ReconstructedParticles#3.index') + #print ('reco particle ',counter) + counter+=1 + + if e.ReconstructedParticles.at(rp).tracks_begin ' % (sys.argv[0])) + +if __name__ == '__main__': + if len( sys.argv ) < 4: + usage() + sys.exit( 1 ) + print(sys.argv[1],' ---- ', int( sys.argv[2] )) + generateEvents( sys.argv[1],sys.argv[2], int( sys.argv[3] ) ) From 78348d8a107085de9b4e5e443c388fec02115666 Mon Sep 17 00:00:00 2001 From: clementhelsens Date: Fri, 2 Oct 2020 16:43:06 +0200 Subject: [PATCH 02/11] fix typo --- plugins/delphes/examples/EDM4Hep2LCIO_example.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/delphes/examples/EDM4Hep2LCIO_example.py b/plugins/delphes/examples/EDM4Hep2LCIO_example.py index af7231d1c..dba25f8b4 100644 --- a/plugins/delphes/examples/EDM4Hep2LCIO_example.py +++ b/plugins/delphes/examples/EDM4Hep2LCIO_example.py @@ -113,5 +113,5 @@ def usage(): if len( sys.argv ) < 4: usage() sys.exit( 1 ) - print(sys.argv[1],' ---- ', int( sys.argv[2] )) + #print(sys.argv[1],' ---- ', int( sys.argv[2] )) generateEvents( sys.argv[1],sys.argv[2], int( sys.argv[3] ) ) From 75649bcf79d33b9c69cf128793f8619218bc943a Mon Sep 17 00:00:00 2001 From: clementhelsens Date: Fri, 2 Oct 2020 16:44:43 +0200 Subject: [PATCH 03/11] remove printouts --- plugins/delphes/examples/EDM4Hep2LCIO_example.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/delphes/examples/EDM4Hep2LCIO_example.py b/plugins/delphes/examples/EDM4Hep2LCIO_example.py index dba25f8b4..05f555a0a 100644 --- a/plugins/delphes/examples/EDM4Hep2LCIO_example.py +++ b/plugins/delphes/examples/EDM4Hep2LCIO_example.py @@ -45,8 +45,8 @@ def generateEvents(inputFileName, outputFileName, nEvents): tracks = IMPL.LCCollectionVec(EVENT.LCIO.TRACK) recops = IMPL.LCCollectionVec(EVENT.LCIO.RECONSTRUCTEDPARTICLE) - print ('n reco particles ',e.ReconstructedParticles.size()) - print ('ntracks ',e.EFlowTrack_1.size()) + #print ('n reco particles ',e.ReconstructedParticles.size()) + #print ('ntracks ',e.EFlowTrack_1.size()) counter=1 #loop over the reconstructed particles From c22ee05f20c001ba79daf4fa986fdb57f3610532 Mon Sep 17 00:00:00 2001 From: clementhelsens Date: Mon, 5 Oct 2020 13:58:51 +0200 Subject: [PATCH 04/11] bug fix in covariance matrix and remove printout --- .../delphes/examples/EDM4Hep2LCIO_example.py | 28 ++++++------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/plugins/delphes/examples/EDM4Hep2LCIO_example.py b/plugins/delphes/examples/EDM4Hep2LCIO_example.py index 05f555a0a..f38c78cae 100644 --- a/plugins/delphes/examples/EDM4Hep2LCIO_example.py +++ b/plugins/delphes/examples/EDM4Hep2LCIO_example.py @@ -44,11 +44,7 @@ def generateEvents(inputFileName, outputFileName, nEvents): tracks = IMPL.LCCollectionVec(EVENT.LCIO.TRACK) recops = IMPL.LCCollectionVec(EVENT.LCIO.RECONSTRUCTEDPARTICLE) - - #print ('n reco particles ',e.ReconstructedParticles.size()) - #print ('ntracks ',e.EFlowTrack_1.size()) - counter=1 #loop over the reconstructed particles for rp in range(e.ReconstructedParticles.size()): @@ -63,38 +59,31 @@ def generateEvents(inputFileName, outputFileName, nEvents): #get the track associated to the reco particle track = IMPL.TrackImpl() - #print ('ReconstructedParticles.tracks_begin ',e.ReconstructedParticles.at(rp).tracks_begin) - #print ('ReconstructedParticles.tracks_end ',e.ReconstructedParticles.at(rp).tracks_end) - #print ('ReconstructedParticles#3.size ',getattr(e,'ReconstructedParticles#3.size')) - #print ('ReconstructedParticles#3.index ',getattr(e,'ReconstructedParticles#3.index')) - #print ('ReconstructedParticles#3.collectionID ',getattr(e,'ReconstructedParticles#3.collectionID')) - #toto=getattr(e,'ReconstructedParticles#3.index') - #print ('reco particle ',counter) - counter+=1 - if e.ReconstructedParticles.at(rp).tracks_begin Date: Tue, 22 Feb 2022 10:13:17 +0100 Subject: [PATCH 05/11] add dNdX to edm4hep:track --- edm4hep.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/edm4hep.yaml b/edm4hep.yaml index bbb4bbd5c..fa364c69b 100644 --- a/edm4hep.yaml +++ b/edm4hep.yaml @@ -357,6 +357,8 @@ datatypes : - int32_t ndf //number of degrees of freedom of the track fit - float dEdx //dEdx of the track. - float dEdxError //error of dEdx. + - float dNdx //dNdx of the track. + - float dNdxError //error of dNdx. - float radiusOfInnermostHit //radius of the innermost hit that has been used in the track fit VectorMembers: - int32_t subDetectorHitNumbers //number of hits in particular subdetectors.Check/set collection variable TrackSubdetectorNames for decoding the indices From 93b914c3ff1eaa1fe8b43f7490c0782d6430f2e7 Mon Sep 17 00:00:00 2001 From: clementhelsens Date: Mon, 14 Mar 2022 16:23:24 +0100 Subject: [PATCH 06/11] new implementation of quantity for dQ/dX --- edm4hep.yaml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/edm4hep.yaml b/edm4hep.yaml index fa364c69b..3747a892f 100644 --- a/edm4hep.yaml +++ b/edm4hep.yaml @@ -99,6 +99,11 @@ components: ObjectID(const podio::ObjectID& id ): index(id.index), collectionID(id.collectionID) {}\n " + # quantity with an identifier, a value and an error + edm4hep::Quantity: + - int16_t type // flag identifying how to interpret the quantity + - float value // value of the quantity + - float error // error on the value of the quantity datatypes : @@ -355,14 +360,11 @@ datatypes : - int32_t type //flagword that defines the type of track.Bits 16-31 are used internally - float chi2 //Chi^2 of the track fit - int32_t ndf //number of degrees of freedom of the track fit - - float dEdx //dEdx of the track. - - float dEdxError //error of dEdx. - - float dNdx //dNdx of the track. - - float dNdxError //error of dNdx. - float radiusOfInnermostHit //radius of the innermost hit that has been used in the track fit VectorMembers: - int32_t subDetectorHitNumbers //number of hits in particular subdetectors.Check/set collection variable TrackSubdetectorNames for decoding the indices - edm4hep::TrackState trackStates //track states + - edm4hep::Quantity dxQuantities // different measurements of dx quantities OneToManyRelations: - edm4hep::TrackerHit trackerHits //hits that have been used to create this track - edm4hep::Track tracks //tracks (segments) that have been combined to create this track From c5605cdbbc3c94fc5c9b5d385c890630af4ad286 Mon Sep 17 00:00:00 2001 From: clementhelsens Date: Mon, 14 Mar 2022 16:49:55 +0100 Subject: [PATCH 07/11] Add members --- edm4hep.yaml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/edm4hep.yaml b/edm4hep.yaml index 3747a892f..f346fdb78 100644 --- a/edm4hep.yaml +++ b/edm4hep.yaml @@ -101,9 +101,10 @@ components: # quantity with an identifier, a value and an error edm4hep::Quantity: - - int16_t type // flag identifying how to interpret the quantity - - float value // value of the quantity - - float error // error on the value of the quantity + Members: + - int16_t type // flag identifying how to interpret the quantity + - float value // value of the quantity + - float error // error on the value of the quantity datatypes : From 1a31eed47eb6446f15ed991be2e7e62b78600183 Mon Sep 17 00:00:00 2001 From: clementhelsens Date: Wed, 13 Apr 2022 14:19:04 +0200 Subject: [PATCH 08/11] add dedx back --- edm4hep.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/edm4hep.yaml b/edm4hep.yaml index f346fdb78..11959b258 100644 --- a/edm4hep.yaml +++ b/edm4hep.yaml @@ -361,6 +361,8 @@ datatypes : - int32_t type //flagword that defines the type of track.Bits 16-31 are used internally - float chi2 //Chi^2 of the track fit - int32_t ndf //number of degrees of freedom of the track fit + - float dEdx //dEdx of the track. + - float dEdxError //error of dEdx. - float radiusOfInnermostHit //radius of the innermost hit that has been used in the track fit VectorMembers: - int32_t subDetectorHitNumbers //number of hits in particular subdetectors.Check/set collection variable TrackSubdetectorNames for decoding the indices From 9a1a50421c420a1df97fc11d454d0bfdce03381c Mon Sep 17 00:00:00 2001 From: Valentin Volkl Date: Thu, 26 May 2022 14:57:22 +0200 Subject: [PATCH 09/11] test: set ROOT_INCLUDE_PATH, add regex fail to catch missing dict headers --- CMakeLists.txt | 9 ++++++++- test/CMakeLists.txt | 38 ++++++++++++++++++-------------------- 2 files changed, 26 insertions(+), 21 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f251eebba..688e8092b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.3) -project(EDM4HEP) +project(EDM4HEP LANGUAGES CXX) # project version SET( ${PROJECT_NAME}_VERSION_MAJOR 0 ) @@ -9,6 +9,13 @@ SET( ${PROJECT_NAME}_VERSION_PATCH 2 ) SET( ${PROJECT_NAME}_VERSION "${${PROJECT_NAME}_VERSION_MAJOR}.${${PROJECT_NAME}_VERSION_MINOR}.${${PROJECT_NAME}_VERSION_PATCH}" ) +#- RPATH settings ---------------------------------------------- +set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE CACHE BOOL "RPATH USE LINK PATH") +option(USE_RUNPATH_INSTEAD_OF_RPATH "Use runpath instead of rpath (allow specifying liked libraries via LD_LIBRARY_PATH)" OFF) +if(USE_RUNPATH_INSTEAD_OF_RPATH) + set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--enable-new-dtags") +endif() + #--- Run the podio class generator and link library ------- diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 421a6317f..824a7d178 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -2,32 +2,34 @@ IF(NOT BUILD_TESTING) RETURN() ENDIF() +function(set_test_env _testname) + set_property(TEST ${_testname} APPEND PROPERTY ENVIRONMENT + LD_LIBRARY_PATH=$:$:$ENV{LD_LIBRARY_PATH} + ROOT_INCLUDE_PATH=${PROJECT_SOURCE_DIR}/edm4hep:$ENV{ROOT_INCLUDE_PATH} + ) + set_tests_properties(${_testname} PROPERTIES + FAIL_REGULAR_EXPRESSION "[^a-z]Error;ERROR;error;Failed" + ) +endfunction() + add_executable(write_events write_events.cc) target_include_directories(write_events PUBLIC ${CMAKE_SOURCE_DIR}/edm4hep ) target_link_libraries(write_events edm4hep podio::podioRootIO) add_test(NAME write_events COMMAND write_events) -set_tests_properties(write_events PROPERTIES - ENVIRONMENT LD_LIBRARY_PATH=$:$:$ENV{LD_LIBRARY_PATH} - ) +set_test_env(write_events) add_executable(read_events read_events.cc) target_include_directories(read_events PUBLIC ${CMAKE_SOURCE_DIR}/edm4hep ) target_link_libraries(read_events edm4hep podio::podioRootIO) add_test(NAME read_events COMMAND read_events) -set_tests_properties(read_events PROPERTIES - DEPENDS write_events - ENVIRONMENT LD_LIBRARY_PATH=$:$:$ENV{LD_LIBRARY_PATH} - ) +set_test_env(read_events) IF (podio_VERSION VERSION_GREATER "0.13") add_executable(reco_particle_ref reco_particle_ref.cc) target_include_directories(reco_particle_ref PUBLIC ${CMAKE_SOURCE_DIR}/edm4hep) target_link_libraries(reco_particle_ref edm4hep podio::podioRootIO) add_test(NAME reco_particle_ref COMMAND reco_particle_ref) - set_tests_properties(reco_particle_ref PROPERTIES - ENVIRONMENT - LD_LIBRARY_PATH=$:$:$ENV{LD_LIBRARY_PATH} - ) + set_test_env(reco_particle_ref) ENDIF() IF(TARGET edm4hepSioBlocks) @@ -35,16 +37,14 @@ IF(TARGET edm4hepSioBlocks) target_include_directories(write_events_sio PUBLIC ${CMAKE_SOURCE_DIR}/edm4hep) target_link_libraries(write_events_sio edm4hep podio::podioSioIO) add_test(NAME write_events_sio COMMAND write_events_sio) - set_tests_properties(write_events_sio PROPERTIES - ENVIRONMENT LD_LIBRARY_PATH=$:$:$ENV{LD_LIBRARY_PATH} - ) + set_test_env(write_events_sio) add_executable(read_events_sio read_events_sio.cc) target_include_directories(read_events_sio PUBLIC ${CMAKE_SOURCE_DIR}/edm4hep) target_link_libraries(read_events_sio edm4hep podio::podioSioIO) add_test(NAME read_events_sio COMMAND read_events_sio) + set_test_env(read_events_sio) set_tests_properties(read_events_sio PROPERTIES - ENVIRONMENT LD_LIBRARY_PATH=$:$:$ENV{LD_LIBRARY_PATH} DEPENDS write_events_sio ) ENDIF() @@ -54,8 +54,8 @@ IF(TARGET ROOT::ROOTDataFrame) target_include_directories(test_rdf PUBLIC ${CMAKE_SOURCE_DIR}/edm4hep ${CMAKE_SOURCE_DIR}/dataframe ) target_link_libraries(test_rdf edm4hepRDF ROOT::ROOTDataFrame) add_test(NAME test_rdf COMMAND test_rdf) - set_tests_properties(test_rdf PROPERTIES - ENVIRONMENT LD_LIBRARY_PATH=$:$:$ENV{LD_LIBRARY_PATH} + set_test_env(test_rdf) + set_property(TEST test_rdf PROPERTY DEPENDS DEPENDS write_events ) endif() @@ -69,9 +69,7 @@ if(HepMC3_FOUND AND HepPDT_FOUND ) target_include_directories(edm4hep_testhepmc PUBLIC ${HEPMC3_INCLUDE_DIR} ${HEPPDT_INCLUDE_DIR} ) target_link_libraries(edm4hep_testhepmc edm4hep podio::podioRootIO ${HEPPDT_LIBRARIES} ${HEPMC3_LIBRARIES}) add_test(NAME edm4hep_testhepmc COMMAND edm4hep_testhepmc) - set_tests_properties(edm4hep_testhepmc PROPERTIES - ENVIRONMENT LD_LIBRARY_PATH=$:$:$ENV{LD_LIBRARY_PATH} - ) + set_test_env(edm4hep_testhepmc) endif() add_subdirectory(utils) From e4ccc92a5978bde777d855c70415ca0b572ae205 Mon Sep 17 00:00:00 2001 From: Valentin Volkl Date: Thu, 26 May 2022 15:19:18 +0200 Subject: [PATCH 10/11] link test_rdf to podioRootIO --- test/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 824a7d178..48fa3d4c3 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -4,7 +4,7 @@ ENDIF() function(set_test_env _testname) set_property(TEST ${_testname} APPEND PROPERTY ENVIRONMENT - LD_LIBRARY_PATH=$:$:$ENV{LD_LIBRARY_PATH} + LD_LIBRARY_PATH=/cvmfs/sw-nightlies.hsf.org/spackages5/root/6.26.02/x86_64-centos7-gcc11.2.0-opt/62nsk/lib:$:$:$ENV{LD_LIBRARY_PATH} ROOT_INCLUDE_PATH=${PROJECT_SOURCE_DIR}/edm4hep:$ENV{ROOT_INCLUDE_PATH} ) set_tests_properties(${_testname} PROPERTIES @@ -52,7 +52,7 @@ ENDIF() IF(TARGET ROOT::ROOTDataFrame) add_executable(test_rdf test_rdf.cc) target_include_directories(test_rdf PUBLIC ${CMAKE_SOURCE_DIR}/edm4hep ${CMAKE_SOURCE_DIR}/dataframe ) - target_link_libraries(test_rdf edm4hepRDF ROOT::ROOTDataFrame) + target_link_libraries(test_rdf edm4hepRDF ROOT::ROOTDataFrame podio::podioRootIO) add_test(NAME test_rdf COMMAND test_rdf) set_test_env(test_rdf) set_property(TEST test_rdf PROPERTY DEPENDS From 4f85c042b3381ff88db06e4996d429c4d40a2158 Mon Sep 17 00:00:00 2001 From: Valentin Volkl Date: Thu, 26 May 2022 15:47:42 +0200 Subject: [PATCH 11/11] remove debug env setting --- test/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 48fa3d4c3..09dd09ef3 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -4,7 +4,7 @@ ENDIF() function(set_test_env _testname) set_property(TEST ${_testname} APPEND PROPERTY ENVIRONMENT - LD_LIBRARY_PATH=/cvmfs/sw-nightlies.hsf.org/spackages5/root/6.26.02/x86_64-centos7-gcc11.2.0-opt/62nsk/lib:$:$:$ENV{LD_LIBRARY_PATH} + LD_LIBRARY_PATH=$:$:$ENV{LD_LIBRARY_PATH} ROOT_INCLUDE_PATH=${PROJECT_SOURCE_DIR}/edm4hep:$ENV{ROOT_INCLUDE_PATH} ) set_tests_properties(${_testname} PROPERTIES