diff --git a/.github/workflows/tests/test_gen_jets.sh b/.github/workflows/tests/test_gen_jets.sh index 0d34978..656c569 100644 --- a/.github/workflows/tests/test_gen_jets.sh +++ b/.github/workflows/tests/test_gen_jets.sh @@ -1 +1 @@ -gen_jets.py --nov 10 -o test_jets.EVT.root \ No newline at end of file +gen_jets.py --nov 2 -o jets.EVT.root \ No newline at end of file diff --git a/.github/workflows/tests/test_gen_minbias.sh b/.github/workflows/tests/test_gen_minbias.sh index 7f64305..1ce7323 100644 --- a/.github/workflows/tests/test_gen_minbias.sh +++ b/.github/workflows/tests/test_gen_minbias.sh @@ -1 +1 @@ -gen_minbias.py --nov 1 --pileupAvg 10 --nov 10 -o test_mb.EVT.root \ No newline at end of file +gen_minbias.py --nov 1 --pileupAvg 1 -o mb.EVT.root \ No newline at end of file diff --git a/.github/workflows/tests/test_gen_zee.sh b/.github/workflows/tests/test_gen_zee.sh index 95ba3f8..ee4d288 100644 --- a/.github/workflows/tests/test_gen_zee.sh +++ b/.github/workflows/tests/test_gen_zee.sh @@ -1 +1 @@ -gen_zee.py --nov 10 -o test_zee.EVT.root \ No newline at end of file +gen_zee.py --nov 2 -o Zee.EVT.root \ No newline at end of file diff --git a/.github/workflows/tests/test_local.sh b/.github/workflows/tests/test_local.sh new file mode 100644 index 0000000..d363581 --- /dev/null +++ b/.github/workflows/tests/test_local.sh @@ -0,0 +1,60 @@ +#!/bin/bash +set -e + +workarea=$1 +place=$pwd + +mkdir -p $workarea +cd $workarea + +# stage 1 +if [ ! -f "stage_1.done" ]; then + gen_zee.py --nov 2 -o Zee.EVT.root + touch stage_1.done +fi + +# stage 2 +if [ ! -f "stage_2.done" ]; then + gen_jets.py --nov 2 -o jets.EVT.root + touch stage_2.done +fi + +# stage 3 +if [ ! -f "stage_3.done" ]; then + gen_minbias.py --nov 1 --pileupAvg 1 -o mb.EVT.root + touch stage_3.done +fi + +# stage 4 +if [ ! -f "stage_4.done" ]; then + simu_trf.py -i Zee.EVT.root -o Zee.HIT.root -nt 2 + touch stage_4.done +fi + +# stage 5 +if [ ! -f "stage_5.done" ]; then + simu_trf.py -i mb.EVT.root -o mb.HIT.root -nt 2 + touch stage_5.done +fi + +# stage 6 +if [ ! -f "stage_6.done" ]; then + merge_trf.py -i Zee.HIT.root -p mb.HIT.root -o Zee.merged.HIT.root + touch stage_6.done +fi + +# stage 7 +if [ ! -f "stage_7.done" ]; then + digit_trf.py -i Zee.HIT.root -o Zee.ESD.root + touch stage_7.done +fi + +# stage 8 +if [ ! -f "stage_8.done" ]; then + reco_trf.py -i Zee.ESD.root -o Zee.AOD.root + touch stage_8.done +fi + +cd $place + + diff --git a/.github/workflows/tests/test_simu_trf.sh b/.github/workflows/tests/test_simu_trf.sh index 9680263..e46e675 100644 --- a/.github/workflows/tests/test_simu_trf.sh +++ b/.github/workflows/tests/test_simu_trf.sh @@ -2,11 +2,9 @@ -CPU_N=$(grep -c ^processor /proc/cpuinfo) - # main event simulation command -simu_trf.py -i Zee.EVT.root -o Zee.HIT.root -nt $CPU_N +simu_trf.py -i Zee.EVT.root -o Zee.HIT.root -nt 2 # minimum bias event simulation -simu_trf.py -i mb.EVT.root -o mb.HIT.root -nt $CPU_N +simu_trf.py -i mb.EVT.root -o mb.HIT.root -nt 2 diff --git a/Makefile b/Makefile index 8325ef0..785551b 100644 --- a/Makefile +++ b/Makefile @@ -1,394 +1,31 @@ -# CMAKE generated file: DO NOT EDIT! -# Generated by "Unix Makefiles" Generator, CMake Version 3.16 +SHELL := /bin/bash -# Default target executed when no arguments are given to make. -default_target: all +DOCKER_NAMESPACE=lorenzetti -.PHONY : default_target +all: build_sources -# Allow only one "make -f Makefile2" at a time, but pass parallelism. -.NOTPARALLEL: +build_image: + docker build --progress=plain --compress -t ${DOCKER_NAMESPACE}/lorenzetti:latest . +build_singularity: + singularity build --sandbox lorenzetti_latest.sif docker://${DOCKER_NAMESPACE}/lorenzetti:latest -#============================================================================= -# Special targets provided by cmake. +build_sources: + mkdir -p build + cd build && cmake .. && make -j10 && cd .. -# Disable implicit rules so canonical targets will work. -.SUFFIXES: +test: + source .github/workflows/tests/test_local.sh tests +push: + docker push ${DOCKER_NAMESPACE}/lorenzetti:latest -# Remove some rules from gmake that .SUFFIXES does not remove. -SUFFIXES = +run: + xhost + && docker run -e DISPLAY=${DISPLAY} -v ${HOME}:${HOME} -v /tmp/.X11-unix:/tmp/.X11-unix -v ${XAUTHORITY}:/tmp/.XAuthority -e XAUTHORITY=/tmp/.XAuthority -it ${DOCKER_NAMESPACE}/lorenzetti:latest -.SUFFIXES: .hpux_make_needs_suffix_list - - -# Suppress display of executed commands. -$(VERBOSE).SILENT: - - -# A target that is always out of date. -cmake_force: - -.PHONY : cmake_force - -#============================================================================= -# Set environment variables for the build. - -# The shell in which to execute make rules. -SHELL = /bin/sh - -# The CMake executable. -CMAKE_COMMAND = /usr/bin/cmake - -# The command to remove a file. -RM = /usr/bin/cmake -E remove -f - -# Escaping for special characters. -EQUALS = = - -# The top-level source directory on which CMake was run. -CMAKE_SOURCE_DIR = /home/cluster/git_repos/lorenzetti - -# The top-level build directory on which CMake was run. -CMAKE_BINARY_DIR = /home/cluster/git_repos/lorenzetti - -#============================================================================= -# Targets provided globally by CMake. - -# Special rule for the target install/strip -install/strip: preinstall - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Installing the project stripped..." - /usr/bin/cmake -DCMAKE_INSTALL_DO_STRIP=1 -P cmake_install.cmake -.PHONY : install/strip - -# Special rule for the target install/strip -install/strip/fast: preinstall/fast - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Installing the project stripped..." - /usr/bin/cmake -DCMAKE_INSTALL_DO_STRIP=1 -P cmake_install.cmake -.PHONY : install/strip/fast - -# Special rule for the target install/local -install/local: preinstall - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Installing only the local directory..." - /usr/bin/cmake -DCMAKE_INSTALL_LOCAL_ONLY=1 -P cmake_install.cmake -.PHONY : install/local - -# Special rule for the target install/local -install/local/fast: preinstall/fast - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Installing only the local directory..." - /usr/bin/cmake -DCMAKE_INSTALL_LOCAL_ONLY=1 -P cmake_install.cmake -.PHONY : install/local/fast - -# Special rule for the target install -install: preinstall - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Install the project..." - /usr/bin/cmake -P cmake_install.cmake -.PHONY : install - -# Special rule for the target install -install/fast: preinstall/fast - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Install the project..." - /usr/bin/cmake -P cmake_install.cmake -.PHONY : install/fast - -# Special rule for the target list_install_components -list_install_components: - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Available install components are: \"Unspecified\"" -.PHONY : list_install_components - -# Special rule for the target list_install_components -list_install_components/fast: list_install_components - -.PHONY : list_install_components/fast - -# Special rule for the target rebuild_cache -rebuild_cache: - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake to regenerate build system..." - /usr/bin/cmake -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) -.PHONY : rebuild_cache - -# Special rule for the target rebuild_cache -rebuild_cache/fast: rebuild_cache - -.PHONY : rebuild_cache/fast - -# Special rule for the target edit_cache -edit_cache: - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "No interactive CMake dialog available..." - /usr/bin/cmake -E echo No\ interactive\ CMake\ dialog\ available. -.PHONY : edit_cache - -# Special rule for the target edit_cache -edit_cache/fast: edit_cache - -.PHONY : edit_cache/fast - -# The main all target -all: cmake_check_build_system - $(CMAKE_COMMAND) -E cmake_progress_start /home/cluster/git_repos/lorenzetti/CMakeFiles /home/cluster/git_repos/lorenzetti/CMakeFiles/progress.marks - $(MAKE) -f CMakeFiles/Makefile2 all - $(CMAKE_COMMAND) -E cmake_progress_start /home/cluster/git_repos/lorenzetti/CMakeFiles 0 -.PHONY : all - -# The main clean target clean: - $(MAKE) -f CMakeFiles/Makefile2 clean -.PHONY : clean - -# The main clean target -clean/fast: clean - -.PHONY : clean/fast - -# Prepare targets for installation. -preinstall: all - $(MAKE) -f CMakeFiles/Makefile2 preinstall -.PHONY : preinstall - -# Prepare targets for installation. -preinstall/fast: - $(MAKE) -f CMakeFiles/Makefile2 preinstall -.PHONY : preinstall/fast - -# clear depends -depend: - $(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1 -.PHONY : depend - -#============================================================================= -# Target rules for targets named lorenzetti - -# Build rule for target. -lorenzetti: cmake_check_build_system - $(MAKE) -f CMakeFiles/Makefile2 lorenzetti -.PHONY : lorenzetti - -# fast build rule for target. -lorenzetti/fast: - $(MAKE) -f CMakeFiles/lorenzetti.dir/build.make CMakeFiles/lorenzetti.dir/build -.PHONY : lorenzetti/fast - -#============================================================================= -# Target rules for targets named GaugiKernel - -# Build rule for target. -GaugiKernel: cmake_check_build_system - $(MAKE) -f CMakeFiles/Makefile2 GaugiKernel -.PHONY : GaugiKernel - -# fast build rule for target. -GaugiKernel/fast: - $(MAKE) -f core/GaugiKernel/CMakeFiles/GaugiKernel.dir/build.make core/GaugiKernel/CMakeFiles/GaugiKernel.dir/build -.PHONY : GaugiKernel/fast - -#============================================================================= -# Target rules for targets named GaugiKernelDict - -# Build rule for target. -GaugiKernelDict: cmake_check_build_system - $(MAKE) -f CMakeFiles/Makefile2 GaugiKernelDict -.PHONY : GaugiKernelDict - -# fast build rule for target. -GaugiKernelDict/fast: - $(MAKE) -f core/GaugiKernel/CMakeFiles/GaugiKernelDict.dir/build.make core/GaugiKernel/CMakeFiles/GaugiKernelDict.dir/build -.PHONY : GaugiKernelDict/fast - -#============================================================================= -# Target rules for targets named G4Kernel - -# Build rule for target. -G4Kernel: cmake_check_build_system - $(MAKE) -f CMakeFiles/Makefile2 G4Kernel -.PHONY : G4Kernel - -# fast build rule for target. -G4Kernel/fast: - $(MAKE) -f core/G4Kernel/CMakeFiles/G4Kernel.dir/build.make core/G4Kernel/CMakeFiles/G4Kernel.dir/build -.PHONY : G4Kernel/fast - -#============================================================================= -# Target rules for targets named G4KernelDict - -# Build rule for target. -G4KernelDict: cmake_check_build_system - $(MAKE) -f CMakeFiles/Makefile2 G4KernelDict -.PHONY : G4KernelDict - -# fast build rule for target. -G4KernelDict/fast: - $(MAKE) -f core/G4Kernel/CMakeFiles/G4KernelDict.dir/build.make core/G4Kernel/CMakeFiles/G4KernelDict.dir/build -.PHONY : G4KernelDict/fast - -#============================================================================= -# Target rules for targets named CaloHit - -# Build rule for target. -CaloHit: cmake_check_build_system - $(MAKE) -f CMakeFiles/Makefile2 CaloHit -.PHONY : CaloHit - -# fast build rule for target. -CaloHit/fast: - $(MAKE) -f events/CaloHit/CMakeFiles/CaloHit.dir/build.make events/CaloHit/CMakeFiles/CaloHit.dir/build -.PHONY : CaloHit/fast - -#============================================================================= -# Target rules for targets named CaloHitDict - -# Build rule for target. -CaloHitDict: cmake_check_build_system - $(MAKE) -f CMakeFiles/Makefile2 CaloHitDict -.PHONY : CaloHitDict - -# fast build rule for target. -CaloHitDict/fast: - $(MAKE) -f events/CaloHit/CMakeFiles/CaloHitDict.dir/build.make events/CaloHit/CMakeFiles/CaloHitDict.dir/build -.PHONY : CaloHitDict/fast - -#============================================================================= -# Target rules for targets named CaloCell - -# Build rule for target. -CaloCell: cmake_check_build_system - $(MAKE) -f CMakeFiles/Makefile2 CaloCell -.PHONY : CaloCell - -# fast build rule for target. -CaloCell/fast: - $(MAKE) -f events/CaloCell/CMakeFiles/CaloCell.dir/build.make events/CaloCell/CMakeFiles/CaloCell.dir/build -.PHONY : CaloCell/fast - -#============================================================================= -# Target rules for targets named CaloCellDict - -# Build rule for target. -CaloCellDict: cmake_check_build_system - $(MAKE) -f CMakeFiles/Makefile2 CaloCellDict -.PHONY : CaloCellDict - -# fast build rule for target. -CaloCellDict/fast: - $(MAKE) -f events/CaloCell/CMakeFiles/CaloCellDict.dir/build.make events/CaloCell/CMakeFiles/CaloCellDict.dir/build -.PHONY : CaloCellDict/fast - -#============================================================================= -# Target rules for targets named EventInfo - -# Build rule for target. -EventInfo: cmake_check_build_system - $(MAKE) -f CMakeFiles/Makefile2 EventInfo -.PHONY : EventInfo - -# fast build rule for target. -EventInfo/fast: - $(MAKE) -f events/EventInfo/CMakeFiles/EventInfo.dir/build.make events/EventInfo/CMakeFiles/EventInfo.dir/build -.PHONY : EventInfo/fast - -#============================================================================= -# Target rules for targets named EventInfoDict - -# Build rule for target. -EventInfoDict: cmake_check_build_system - $(MAKE) -f CMakeFiles/Makefile2 EventInfoDict -.PHONY : EventInfoDict - -# fast build rule for target. -EventInfoDict/fast: - $(MAKE) -f events/EventInfo/CMakeFiles/EventInfoDict.dir/build.make events/EventInfo/CMakeFiles/EventInfoDict.dir/build -.PHONY : EventInfoDict/fast - -#============================================================================= -# Target rules for targets named TruthParticle - -# Build rule for target. -TruthParticle: cmake_check_build_system - $(MAKE) -f CMakeFiles/Makefile2 TruthParticle -.PHONY : TruthParticle - -# fast build rule for target. -TruthParticle/fast: - $(MAKE) -f events/TruthParticle/CMakeFiles/TruthParticle.dir/build.make events/TruthParticle/CMakeFiles/TruthParticle.dir/build -.PHONY : TruthParticle/fast - -#============================================================================= -# Target rules for targets named TruthParticleDict - -# Build rule for target. -TruthParticleDict: cmake_check_build_system - $(MAKE) -f CMakeFiles/Makefile2 TruthParticleDict -.PHONY : TruthParticleDict - -# fast build rule for target. -TruthParticleDict/fast: - $(MAKE) -f events/TruthParticle/CMakeFiles/TruthParticleDict.dir/build.make events/TruthParticle/CMakeFiles/TruthParticleDict.dir/build -.PHONY : TruthParticleDict/fast - -#============================================================================= -# Target rules for targets named CaloCellBuilder - -# Build rule for target. -CaloCellBuilder: cmake_check_build_system - $(MAKE) -f CMakeFiles/Makefile2 CaloCellBuilder -.PHONY : CaloCellBuilder - -# fast build rule for target. -CaloCellBuilder/fast: - $(MAKE) -f reconstruction/calorimeter/CaloCellBuilder/CMakeFiles/CaloCellBuilder.dir/build.make reconstruction/calorimeter/CaloCellBuilder/CMakeFiles/CaloCellBuilder.dir/build -.PHONY : CaloCellBuilder/fast - -#============================================================================= -# Target rules for targets named CaloCellBuilderDict - -# Build rule for target. -CaloCellBuilderDict: cmake_check_build_system - $(MAKE) -f CMakeFiles/Makefile2 CaloCellBuilderDict -.PHONY : CaloCellBuilderDict - -# fast build rule for target. -CaloCellBuilderDict/fast: - $(MAKE) -f reconstruction/calorimeter/CaloCellBuilder/CMakeFiles/CaloCellBuilderDict.dir/build.make reconstruction/calorimeter/CaloCellBuilder/CMakeFiles/CaloCellBuilderDict.dir/build -.PHONY : CaloCellBuilderDict/fast - -# Help Target -help: - @echo "The following are some of the valid targets for this Makefile:" - @echo "... all (the default if no target is provided)" - @echo "... clean" - @echo "... depend" - @echo "... install/strip" - @echo "... install/local" - @echo "... install" - @echo "... list_install_components" - @echo "... rebuild_cache" - @echo "... edit_cache" - @echo "... lorenzetti" - @echo "... GaugiKernel" - @echo "... GaugiKernelDict" - @echo "... G4Kernel" - @echo "... G4KernelDict" - @echo "... CaloHit" - @echo "... CaloHitDict" - @echo "... CaloCell" - @echo "... CaloCellDict" - @echo "... EventInfo" - @echo "... EventInfoDict" - @echo "... TruthParticle" - @echo "... TruthParticleDict" - @echo "... CaloCellBuilder" - @echo "... CaloCellBuilderDict" -.PHONY : help - - - -#============================================================================= -# Special targets to cleanup operation of make. - -# Special rule to run CMake to check the build system integrity. -# No rule that depends on this can have commands that come from listfiles -# because they might be regenerated. -cmake_check_build_system: - $(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0 -.PHONY : cmake_check_build_system + docker system prune -a +pull: + singularity pull docker://lorenzetti/lorenzetti:latest + \ No newline at end of file diff --git a/reconstruction/calorimeter/CaloCellBuilder/src/PileupMerge.cxx b/reconstruction/calorimeter/CaloCellBuilder/src/PileupMerge.cxx index 62e9e55..1621669 100644 --- a/reconstruction/calorimeter/CaloCellBuilder/src/PileupMerge.cxx +++ b/reconstruction/calorimeter/CaloCellBuilder/src/PileupMerge.cxx @@ -1,6 +1,9 @@ #include "PileupMerge.h" +#include "CaloHit/CaloHitConverter.h" +#include "EventInfo/EventInfoConverter.h" + using namespace SG; using namespace Gaugi; @@ -80,7 +83,6 @@ StatusCode PileupMerge::execute( EventContext &ctx, int /*evt*/ ) const StatusCode PileupMerge::post_execute( EventContext &ctx ) const { - /* SG::ReadHandle container(m_inputHitsKey, ctx); if( !container.isValid() ) { @@ -182,7 +184,7 @@ StatusCode PileupMerge::post_execute( EventContext &ctx ) const delete collection_hits; delete collection_events; - */ + return StatusCode::SUCCESS; } diff --git a/scripts/merge_trf.py b/scripts/merge_trf.py index 33fd84f..4f1d20b 100755 --- a/scripts/merge_trf.py +++ b/scripts/merge_trf.py @@ -6,8 +6,7 @@ from G4Kernel import * import numpy as np import argparse -import sys,os -pi = np.pi +import sys,os, traceback mainLogger = Logger.getModuleLogger("job") @@ -30,6 +29,8 @@ parser.add_argument('-l', '--outputLevel', action='store', dest='outputLevel', required = False, type=str, default='INFO', help = "The output level messenger.") +parser.add_argument('-c','--command', action='store', dest='command', required = False, default="''", + help = "The preexec command") if len(sys.argv)==1: @@ -39,23 +40,26 @@ args = parser.parse_args() -outputLevel = LoggingLevel.fromstring(args.outputLevel) +outputLevel = LoggingLevel.toC(args.outputLevel) try: - + exec(args.command) + from GaugiKernel import ComponentAccumulator acc = ComponentAccumulator("ComponentAccumulator", args.outputFile) # the reader must be first in sequence from RootStreamBuilder import RootStreamHITReader, recordable + reader = RootStreamHITReader("HITReader", InputFile = args.inputFile, - HitsKey = recordable("Hits"), - EventKey = recordable("EventInfo"), - TruthKey = recordable("Particles"), - NtupleName = "CollectionTree", + OutputHitsKey = recordable("Hits"), + OutputEventKey = recordable("Events"), + OutputTruthKey = recordable("Particles"), + OutputSeedsKey = recordable("Seeds"), + OutputLevel = outputLevel, ) reader.merge(acc) @@ -65,10 +69,9 @@ pileup = PileupMerge( "PileupMerge", InputFile = args.pileupFile, InputHitsKey = recordable("Hits"), - InputEventKey = recordable("EventInfo"), - OutputHitsKey = recordable("Hits") + "_Merged", - OutputEventKey = recordable("EventInfo") + "_Merged", - NtupleName = "CollectionTree", + InputEventKey = recordable("Events"), + OutputHitsKey = "Hits_Merged", + OutputEventKey = "Events_Merged", OutputLevel = outputLevel ) acc += pileup @@ -79,18 +82,19 @@ from RootStreamBuilder import RootStreamHITMaker HIT = RootStreamHITMaker( "RootStreamHITMaker", # input from context - InputHitsKey = recordable("Hits")+"_Merged", - InputEventKey = recordable("EventInfo")+"_Merged", + InputHitsKey = "Hits_Merged", + InputEventKey = "Events_Merged", InputTruthKey = recordable("Particles"), + InputSeedsKey = recordable("Seeds"), # output to file OutputHitsKey = recordable("Hits"), - OutputEventKey = recordable("EventInfo"), - OutputTruthKey = recordable("Particles"), + OutputEventKey = recordable("Events"), OutputLevel = outputLevel) acc += HIT acc.run(args.numberOfEvents) sys.exit(0) except Exception as e: - print(e) - sys.exit(1) + traceback.print_exc() + mainLogger.error(e) + sys.exit(1) \ No newline at end of file