Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port DDCaloDigi to Gaudi #4

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ find_package(PandoraSDK)
find_package(LCContent)
find_package(Gaudi)
find_package(DD4hep)
find_package(CLHEP REQUIRED)

#---------------------------------------------------------------

Expand All @@ -53,6 +54,37 @@ endif()

include(CTest)


#---RPATH options-------------------------------------------------------------------------------
option(K4GAUDIPANDORA_SET_RPATH "Link libraries with built-in RPATH (run-time search path)" ON)

# When building, don't use the install RPATH already (but later on when installing)
set(CMAKE_SKIP_BUILD_RPATH FALSE) # don't skip the full RPATH for the build tree
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) # use always the build RPATH for the build tree
set(CMAKE_MACOSX_RPATH TRUE) # use RPATH for MacOSX
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) # point to directories outside the build tree to the install RPATH

# Check whether to add RPATH to the installation (the build tree always has the RPATH enabled)
if(APPLE)
set(CMAKE_INSTALL_NAME_DIR "@rpath")
set(CMAKE_INSTALL_RPATH "@loader_path/../lib") # self relative LIBDIR
# the RPATH to be used when installing, but only if it's not a system directory
list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
if("${isSystemDir}" STREQUAL "-1")
set(CMAKE_INSTALL_RPATH "@loader_path/../lib")
endif("${isSystemDir}" STREQUAL "-1")
elseif(K4GAUDIPANDORA_SET_RPATH)
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") # install LIBDIR
# the RPATH to be used when installing, but only if it's not a system directory
list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
if("${isSystemDir}" STREQUAL "-1")
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
endif("${isSystemDir}" STREQUAL "-1")
else()
set(CMAKE_SKIP_INSTALL_RPATH TRUE) # skip the full RPATH for the install tree
endif()


add_subdirectory(k4GaudiPandora)

include(cmake/CreateProjectConfig.cmake)
16 changes: 3 additions & 13 deletions k4GaudiPandora/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,10 @@ limitations under the License.
]]

set(_plugin_sources ${CMAKE_CURRENT_LIST_DIR}/
# src/components/*.cpp
src/CalorimeterHitType.cc
# src/DDBFieldPlugin.cc
# src/DDCaloDigi.cc
# src/DDCaloHitCreator.cc
# src/DDExternalClusteringAlgorithm.cc
# src/DDGeometryCreator.cc
# src/DDMCParticleCreator.cc
# src/DDPandoraPFANewProcessor.cc
# src/DDPfoCreator.cc
# src/DDScintillatorPpdDigi.cc
src/DDCaloDigi.cc
src/DDScintillatorPpdDigi.cc
src/DDSimpleMuonDigi.cc
# src/DDTrackCreatorBase.cc
# src/DDTrackCreatorCLIC.cc
# src/DDTrackCreatorILD.cc
)

gaudi_add_module(k4GaudiPandoraPlugins
Expand All @@ -42,6 +31,7 @@ gaudi_add_module(k4GaudiPandoraPlugins
EDM4HEP::edm4hep
DD4hep::DDRec
DD4hep::DDCore
CLHEP::CLHEP
)
target_include_directories(k4GaudiPandoraPlugins PRIVATE include)
install(TARGETS k4GaudiPandoraPlugins
Expand Down
624 changes: 262 additions & 362 deletions k4GaudiPandora/include/DDCaloDigi.h

Large diffs are not rendered by default.

36 changes: 18 additions & 18 deletions k4GaudiPandora/include/DDScintillatorPpdDigi.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,47 +16,47 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _DDScintillatorPpdDigi_h_
#define _DDScintillatorPpdDigi_h_
#ifndef DDSCINTILLATORPPDDIGI_H
#define DDSCINTILLATORPPDDIGI_H

class DDScintillatorPpdDigi {
public:
DDScintillatorPpdDigi();
~DDScintillatorPpdDigi() {}

// expected # photoelectrons / MIP
void setPEperMIP(float x) { _pe_per_mip = x; }
void setPEperMIP(float x) { m_PEperMIP = x; }

// calibration factor from input hit energy to MIPs
void setCalibMIP(float x) { _calib_mip = x; }
void setCalibMIP(float x) { m_calibMIP = x; }

// #pixels of PPD
void setNPix(int x) { _npix = x; }
// # pixels of PPD
void setNPix(int x) { m_Npix = x; }

// random miscalibration of total #pixels (as a fraction of pixel number: 0.05 = 5% miscalibration)
void setRandomMisCalibNPix(float x) { _misCalibNpix = x; }
// random miscalibration of total # pixels (as a fraction of pixel number: 0.05 = 5% miscalibration)
void setRandomMisCalibNPix(float x) { m_misCalibNpix = x; }

// spread in pixel capacitance (as a fraction: 0.05 = 5% spread)
void setPixSpread(float x) { _pixSpread = x; }
void setPixSpread(float x) { m_pixSpread = x; }

// electronics noise (in MIP units)
void setElecNoise(float x) { _elecNoise = x; }
void setElecNoise(float x) { m_elecNoise = x; }

// electronics dynamic range (in MIP units)
void setElecRange(float x) { _elecMaxDynRange_MIP = x; }
void setElecRange(float x) { m_elecMaxDynRange_MIP = x; }

float getDigitisedEnergy(float energy);

void printParameters();

private:
float _pe_per_mip = -99;
float _calib_mip = -99;
float _npix = -99;
float _misCalibNpix = 0;
float _pixSpread = 0;
float _elecNoise = 0;
float _elecMaxDynRange_MIP = 0;
float m_PEperMIP = -99;
float m_calibMIP = -99;
float m_Npix = -99;
float m_misCalibNpix = 0;
float m_pixSpread = 0;
float m_elecNoise = 0;
float m_elecMaxDynRange_MIP = 0;
};

#endif
167 changes: 167 additions & 0 deletions k4GaudiPandora/options/runDDCaloDigi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
#
# Copyright (c) 2020-2024 Key4hep-Project.
#
# This file is part of Key4hep.
# See https://key4hep.github.io/key4hep-doc/ for further info.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from Gaudi.Configuration import INFO
from k4FWCore import ApplicationMgr, IOSvc
from Configurables import EventDataSvc
from Configurables import DDCaloDigi

from Configurables import GeoSvc
from Configurables import UniqueIDGenSvc
from Configurables import RootHistSvc
from Configurables import Gaudi__Histograming__Sink__Root as RootHistoSink
import os

id_service = UniqueIDGenSvc("UniqueIDGenSvc")

geoservice = GeoSvc("GeoSvc")
geoservice.detectors = [os.environ["K4GEO"]+"/FCCee/CLD/compact/CLD_o2_v06/CLD_o2_v06.xml"]
geoservice.OutputLevel = INFO
geoservice.EnableGeant4Geo = False

calodigi = [DDCaloDigi("ECALBarrelDigi"),
DDCaloDigi("ECALEndcapDigi"),
DDCaloDigi("HCALBarrelDigi"),
DDCaloDigi("HCALEndcapDigi"),
DDCaloDigi("HCALRingDigi")]

ECALorHCAL = [True, True, False, False, False]

inputcollections = [["ECalBarrelCollection"],
["ECalEndcapCollection"],
["HCalBarrelCollection"],
["HCalEndcapCollection"],
["HCalRingCollection"]]

outputcollections = [["ECALBarrel"],
["ECALEndcap"],
["HCALBarrel"],
["HCALEndcap"],
["HCALRing"]]

relcollections = [["RelationCaloHitECALBarrel"],
["RelationCaloHitECALEndcap"],
["RelationCaloHitHCALBarrel"],
["RelationCaloHitHCALEndcap"],
["RelationCaloHitHCALRing"]]

#set properties
for calodigicol, ecalorhcal, inputcol, outputcol, relcol in zip(calodigi, ECALorHCAL, inputcollections, outputcollections, relcollections):

calodigicol.InputColIsECAL = ecalorhcal # True -- ECAL // False -- HCAL
calodigicol.InputCaloHitCollection = inputcol # "ECalBarrelCollection","ECalEndcapCollection"
# "HCalBarrelCollection","HCalEndcapCollection","HCalRingCollection"
calodigicol.OutputCaloHitCollection = outputcol
calodigicol.RelCollection = relcol

# digitazing parameters for ECAL and HCAL
calodigicol.ECALThreshold = 5.0e-5
calodigicol.ECALThresholdUnit = "GeV"
calodigicol.HCALThreshold = [0.00025]
calodigicol.HCALThresholdUnit = "GeV"
calodigicol.ECALLayers = [41,100]
calodigicol.HCALLayers = [100]
calodigicol.CalibrECAL = [37.5227197175, 37.5227197175]
calodigicol.CalibrHCALBarrel = [45.9956826061]
calodigicol.CalibrHCALEndcap = [46.9252540291]
calodigicol.CalibrHCALOther = [57.4588011802]
calodigicol.IfDigitalEcal = 0
calodigicol.MapsEcalCorrection = 0
calodigicol.IfDigitalHcal = 0
calodigicol.ECALGapCorrection = 1
calodigicol.HCALGapCorrection = 1
calodigicol.ECALEndcapCorrectionFactor = 1.03245503522
calodigicol.HCALEndcapCorrectionFactor = 1.000
calodigicol.ECALGapCorrectionFactor = 1.0
calodigicol.ECALModuleGapCorrectionFactor = 0.0
calodigicol.HCALModuleGapCorrectionFactor = 0.5

# timing parameters for ECAL
calodigicol.UseEcalTiming = 1
calodigicol.ECALCorrectTimesForPropagation = 1
calodigicol.ECALTimeWindowMin = -1.0
calodigicol.ECALEndcapTimeWindowMax = 10.0
calodigicol.ECALBarrelTimeWindowMax = 10.0
calodigicol.ECALDeltaTimeHitResolution = 10.0
calodigicol.ECALTimeResolution = 10.0
calodigicol.ECALSimpleTimingCut = True

# timing parameters for HCAL
calodigicol.UseHcalTiming = 1
calodigicol.HCALCorrectTimesForPropagation = 1
calodigicol.HCALTimeWindowMin = -1.0
calodigicol.HCALEndcapTimeWindowMax = 10.0
calodigicol.HCALBarrelTimeWindowMax = 10.0
calodigicol.HCALDeltaTimeHitResolution = 10.0
calodigicol.HCALTimeResolution = 10.0
calodigicol.HCALSimpleTimingCut = True

# parameters for extra ECAL digitization effects
calodigicol.CalibECALMIP = 1.0e-4
calodigicol.ECALApplyRealisticDigi = 0
calodigicol.ECAL_PPD_PE_per_MIP = 7.0
calodigicol.ECAL_PPD_N_Pixels = 10000
calodigicol.ECAL_PPD_N_Pixels_uncertainty = 0.05
calodigicol.ECAL_miscalibration_uncorrel = 0.0
calodigicol.ECAL_miscalibration_uncorrel_memorise = False
calodigicol.ECAL_miscalibration_correl = 0.0
calodigicol.ECAL_deadCellRate = 0.0
calodigicol.ECAL_deadCell_memorise = False
calodigicol.ECAL_strip_absorbtionLength = 1.0e6
calodigicol.ECAL_pixel_spread = 0.05
calodigicol.ECAL_elec_noise_mips = 0.0
calodigicol.energyPerEHpair = 3.6
calodigicol.ECAL_maxDynamicRange_MIP = 2500.0
calodigicol.StripEcal_default_nVirtualCells = 9
calodigicol.ECAL_default_layerConfig = "000000000000000"

# parameters for extra HCAL digitization effects
calodigicol.CalibHCALMIP = 1.0e-4
calodigicol.HCALApplyRealisticDigi = 0
calodigicol.HCAL_PPD_PE_per_MIP = 10.0
calodigicol.HCAL_PPD_N_Pixels = 400
calodigicol.HCAL_PPD_N_Pixels_uncertainty = 0.05
calodigicol.HCAL_miscalibration_uncorrel = 0.0
calodigicol.HCAL_miscalibration_uncorrel_memorise = False
calodigicol.HCAL_miscalibration_correl = 0.0
calodigicol.HCAL_deadCellRate = 0.0
calodigicol.HCAL_deadCell_memorise = False
calodigicol.HCAL_pixel_spread = 0.0
calodigicol.HCAL_elec_noise_mips = 0.0
calodigicol.HCAL_maxDynamicRange_MIP = 200.0


#
iosvc = IOSvc()
iosvc.Input = "../simulation/sim_partgun_1000.root"
iosvc.Output = "../outputfiles/DDCaloDigi/outputCaloDigi_Gaudi.root"

hps = RootHistSvc("HistogramPersistencySvc")
root_hist_svc = RootHistoSink("RootHistoSink")
root_hist_svc.FileName = "../outputfiles/DDCaloDigi/ddcalodigi_hist.root"

ApplicationMgr(TopAlg=[calodigi[0],
calodigi[1],
calodigi[2],
calodigi[3],
calodigi[4]],
EvtSel="NONE",
EvtMax=-1,
ExtSvc=[EventDataSvc("EventDataSvc"), root_hist_svc],
OutputLevel=INFO,
)
Loading
Loading