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

Question about creating digi collections from simhits. #710

Open
saraheno opened this issue Feb 5, 2025 · 26 comments
Open

Question about creating digi collections from simhits. #710

saraheno opened this issue Feb 5, 2025 · 26 comments

Comments

@saraheno
Copy link

saraheno commented Feb 5, 2025

This thread is to continue the conversation I started incorrection in the ddsim repository regarding how to create digis from simhits.

In that thread, I asked about https://github.com/key4hep/k4GaudiPandora/blob/4b9f4b92e1e92abc15c594f7c74584f1f2269742/k4GaudiPandora/include/DDSimpleMuonDigi.h#L39

which is like

struct DDSimpleMuonDigi final
    : k4FWCore::MultiTransformer<
          std::tuple<edm4hep::CalorimeterHitCollection, edm4hep::CaloHitSimCaloHitLinkCollection>(
              const edm4hep::SimCalorimeterHitCollection&, const edm4hep::EventHeaderCollection&)> {
  DDSimpleMuonDigi(const std::string& name, ISvcLocator* svcLoc);

and wanted to understand how to alter that to work with my ddsim output created with code at https://github.com/saraheno/DualTestBeam.
I am trying to understand how to do this by reading https://key4hep.github.io/key4hep-doc/developing-key4hep-software/WritingAlgorithms.html

now in my code there is a line
https://github.com/saraheno/DualTestBeam/blob/15822226f728896704fc2d4f0aa6f3a497e398ea/src/DualCrysCalorimeterSDAction.cpp#L176

I think this defines a geant4hit collection using hits of the type DualCrysCalorimeterHit

and which I think is defining the output collection for my code, and its type.

so in that template structure above, I need to replace "const edm4hep::SimCalorimeterHitCollection&" with "Geant4HitCollection" ?
And I guess I don't know if I can just leave edm4hep::CalorimeterHitCollection as it is? where would I find its header file edm4hep/CalorimeterHitCollection.h ?

@andresailer
Copy link
Contributor

How are you creating your output files?

@andresailer
Copy link
Contributor

And no, the DualCrysCalorimeterHit usually does not define your output type. Whatever Geant4Output2... plugin that is used defines the output types, but I got lost in your repository.

@saraheno
Copy link
Author

saraheno commented Feb 5, 2025

I don't write specific code to do that. As far as I know, the output is defined in the ddsim command, when I do

ddsim --compactFile=DRConly.xml --runType=batch -G --steeringFile SCEPCALsteering.py --outputFile=out.root --part.userParticleHandler='' -G --gun.position="0.,0.,-1cm" --gun.direction "0 0 1" --gun.energy "5GeV" --gun.particle="e-" -N 1

and the extention on the --outFile defines it to put all the GEANT4 hit collections into the output in root format? I don't have any code I wrote (beyond what is in DualCrysCalorimeterSDAction.cpp that I pointed you to in my last point) where I personally do anything regarding the output of my ddsim run.

My steering file is https://github.com/saraheno/DualTestBeam/blob/master/compact/SCEPCALsteering.py#L372
but I think the line I am pointing to you there gets overwritten by the --outputFile in the ddsim run command?

should I be doing something else to follow current "best practices" for introducing students to the "IDEA" "FCCee" computing environment?

I know you hate graphic pastes, but don't know how otherwize to do this. this is what is in my output file

Image

@andresailer
Copy link
Contributor

You are not creating an edm4hep based root file. But DDG4s own root output.

(You can just type EVENTS->Print() in the root shell to get the list of branches, but the screenshot is acceptable in this case.)

Which version of the software were you using? In the latest versions, ddsim should automatically create EDM4hep if it is available.

@saraheno
Copy link
Author

saraheno commented Feb 6, 2025

I do not see the DD4hep version in the spew when I run ddsim. I don't know where to find the version number in the downloaded code. I downloaded it on 7 Jan with the command

$ git clone https://github.com/AIDASoft/DD4hep.git

What do I need to do in order to put out the edm4hep-based root file (although the thought makes me cry, as my analysis code is based on the current root tuple... but ya... I can update it). I don't see any other output, so am I turning off the edm4hep output somehow by turning on the DDG4's own root output?

@andresailer
Copy link
Contributor

You need to enable EDM4hep cmake -D DD4HEP_USE_EDM4HEP=ON (if I recall correctly)

@saraheno
Copy link
Author

saraheno commented Feb 6, 2025

I downloaded a version DD4hep with the git clone command. I tried to cmake as you suggest

when I try

cmake -DDD4HEP_USE_GEANT4=ON -DBoost_NO_BOOST_CMAKE=ON -DDD4HEP_USE_LCIO=ON -DBUILD_TESTING=ON -DROOT_DIR=$ROOTSYS -D CMAKE_BUILD_TYPE=Release -DDD4HEP_BUILD_EXAMPLES=ON -DCMAKE_INSTALL_PREFIX=../install -D DD4HEP_USE_EDM4HEP=ON ..

I get an error shown below.
Is this because I am using centos8? I need to move to the singularity?

-- Found OpenGL: /usr/lib64/libOpenGL.so
-- Found Motif: /usr/lib64/libXm.so
-- Found Geant4: /cvmfs/sft.cern.ch/lcg/views/LCG_102b/x86_64-centos8-gcc11-opt/lib64/Geant4-11.0.3/Geant4Config.cmake (found suitable version "11.0.3", minimum required is "10.2.2")
-- Check for LCIO (2.16.1)
-- Check for LCIO_LIBRARIES: lcio
-- Check for LCIO_LCIO_LIBRARY: /cvmfs/sft.cern.ch/lcg/releases/LCIO/02.16.01-21749/x86_64-centos8-gcc11-opt/lib/liblcio.so -- ok
-- Found LCIO: /cvmfs/sft.cern.ch/lcg/releases/LCIO/02.16.01-21749/x86_64-centos8-gcc11-opt
CMake Error at CMakeLists.txt:163 (find_package):
Could not find a configuration file for package "EDM4HEP" that is
compatible with requested version "0.10.5".

The following configuration files were considered but not accepted:

/cvmfs/sft.cern.ch/lcg/views/LCG_102b/x86_64-centos8-gcc11-opt/lib64/cmake/EDM4HEP/EDM4HEPConfig.cmake, version: 0.4.1

-- Configuring incomplete, errors occurred!
See also "/home/eno/CalVision/dd4hep/DD4hep/build/CMakeFiles/CMakeOutput.log".
See also "/home/eno/CalVision/dd4hep/DD4hep/build/CMakeFiles/CMakeError.log".
[eno@hepcms-rubin build]$ cmake -DDD4HEP_USE_GEANT4=ON -DBoost_NO_BOOST_CMAKE=ON -DDD4HEP_USE_LCIO=ON -DBUILD_TESTING=ON -DROOT_DIR=$ROOTSYS -D CMAKE_BUILD_TYPE=Release -DDD4HEP_BUILD_EXAMPLES=ON -DCMAKE_INSTALL_PREFIX=../install -D DD4HEP_USE_EDM4HEP=ON ..

@andresailer
Copy link
Contributor

You need a newer LCG release, like 107.

@saraheno
Copy link
Author

saraheno commented Feb 6, 2025

after upgrading to 107

using source /cvmfs/sft.cern.ch/lcg/views/LCG_107/x86_64-el8-gcc11-opt/setup.sh

I get the spew shown below. How do I fix this? the command I did was

cmake -DDD4HEP_USE_GEANT4=ON -DBoost_NO_BOOST_CMAKE=ON -DDD4HEP_USE_LCIO=ON -DBUILD_TESTING=ON -DROOT_DIR=$ROOTSYS -D CMAKE_BUILD_TYPE=Release -DDD4HEP_BUILD_EXAMPLES=ON -DCMAKE_INSTALL_PREFIX=../install -D DD4HEP_USE_EDM4HEP=ON ..

the error is

-- Detected CPU: icelake
-- Found XercesC: /cvmfs/sft.cern.ch/lcg/views/LCG_102b/x86_64-centos8-gcc11-opt/lib/libxerces-c.so (found version "3.2.3")
-- Check for LCIO (2.16.1)
-- Check for LCIO_LIBRARIES: lcio
-- Check for LCIO_LCIO_LIBRARY: /cvmfs/sft.cern.ch/lcg/releases/LCIO/02.16.01-21749/x86_64-centos8-gcc11-opt/lib/liblcio.so -- ok
CMake Error at CMakeLists.txt:163 (find_package):
By not providing "FindEDM4HEP.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "EDM4HEP", but
CMake did not find one.

Could not find a package configuration file provided by "EDM4HEP"
(requested version 0.10.5) with any of the following names:

EDM4HEPConfig.cmake
edm4hep-config.cmake

Add the installation prefix of "EDM4HEP" to CMAKE_PREFIX_PATH or set
"EDM4HEP_DIR" to a directory containing one of the above files. If
"EDM4HEP" provides a separate development package or SDK, be sure it has
been installed.

@andresailer
Copy link
Contributor

Right, later versions of EDM4hep require c++20, but gcc11 is built with c++17, so there is no EDM4hep...
Thus please use the el9 gcc13 version inside singularity

@saraheno
Copy link
Author

saraheno commented Feb 7, 2025

okay, I'm trying to compile it in singularity. I envoke the singularity using

singularity run -B /cvmfs:/cvmfs -B /data:/data docker://gitlab-registry.cern.ch/sft/docker/alma9-core:latest
source /cvmfs/sft.cern.ch/lcg/views/LCG_107/x86_64-el9-gcc11-opt/setup.sh
source /cvmfs/sw.hsf.org/key4hep/setup.sh

I then try to do the cmake

cmake -DDD4HEP_USE_GEANT4=ON -DBoost_NO_BOOST_CMAKE=ON -DDD4HEP_USE_LCIO=ON -DBUILD_TESTING=ON -DROOT_DIR=$ROOTSYS -D CMAKE_BUILD_TYPE=Release -DDD4HEP_BUILD_EXAMPLES=ON -DCMAKE_INSTALL_PREFIX=../install -D DD4HEP_USE_EDM4HEP=ON ..

but then I get

-- Detecting C compile features
-- Detecting C compile features - done
-- Will be building these packages: DDRec;DDDetectors;DDCond;DDAlign;DDCAD;DDDigi;DDG4;DDEve;UtilityApps
-- Including DD4hepBuild.cmake
-- DD4hep_configure_output: set CMAKE_INSTALL_PREFIX to /data/users/eno/CalVision/dd4hep/DD4hep/install
CMake Error at CMakeLists.txt:127 (find_package):
Could not find a package configuration file provided by "ROOT" (requested
version 6.08) with any of the following names:

ROOTConfig.cmake
root-config.cmake

Add the installation prefix of "ROOT" to CMAKE_PREFIX_PATH or set
"ROOT_DIR" to a directory containing one of the above files. If "ROOT"
provides a separate development package or SDK, be sure it has been
installed.

-- Configuring incomplete, errors occurred!

@jmcarcell
Copy link
Member

jmcarcell commented Feb 7, 2025

There are multiple issues above. Don't run these two together:

source /cvmfs/sft.cern.ch/lcg/views/LCG_107/x86_64-el9-gcc11-opt/setup.sh
source /cvmfs/sw.hsf.org/key4hep/setup.sh

With the first you set up the LCG stack and with the second the Key4hep stack. Many packages are in both and the result of doing this is most likely a broken environment. Then as Andre explained in his comment above you need to use a more recent compiler.

Try (GCC 13 should also work):

source /cvmfs/sft.cern.ch/lcg/views/LCG_107/x86_64-el9-gcc14-opt/setup.sh

@saraheno
Copy link
Author

saraheno commented Feb 7, 2025

thanks for your help. I still seem to be not understanding

[eno@hepcms-rubin ~]$ cd CalVision/dd4hep/
[eno@hepcms-rubin dd4hep]$ cat singularity.sh
singularity run -B /cvmfs:/cvmfs -B /data:/data  docker://gitlab-registry.cern.ch/sft/docker/alma9-core:latest
source /cvmfs/sft.cern.ch/lcg/views/LCG_107/x86_64-el9-gcc14-opt/setup.sh

[eno@hepcms-rubin dd4hep]$ source singularity.sh
INFO:    Using cached SIF image


Singularity> cd DD4hep/build
Singularity> cmake -DDD4HEP_USE_GEANT4=ON -DBoost_NO_BOOST_CMAKE=ON -DDD4HEP_USE_LCIO=ON -DBUILD_TESTING=ON -DROOT_DIR=$ROOTSYS -D CMAKE_BUILD_TYPE=Release -DDD4HEP_BUILD_EXAMPLES=ON -DCMAKE_INSTALL_PREFIX=../install -D DD4HEP_USE_EDM4HEP=ON ..
-- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE)
-- Could NOT find LATEX (missing: LATEX_COMPILER)
-- No LaTeX/Biber found, cannot compile user manual.
-- Will be building these packages: DDRec;DDDetectors;DDCond;DDAlign;DDCAD;DDDigi;DDG4;DDEve;UtilityApps
-- Including DD4hepBuild.cmake
-- DD4hep_configure_output: set CMAKE_INSTALL_PREFIX to /data/users/eno/CalVision/dd4hep/DD4hep/install
CMake Error at CMakeLists.txt:127 (find_package):
  Could not find a package configuration file provided by "ROOT" (requested
  version 6.08) with any of the following names:

    ROOTConfig.cmake
    root-config.cmake

  Add the installation prefix of "ROOT" to CMAKE_PREFIX_PATH or set
  "ROOT_DIR" to a directory containing one of the above files.  If "ROOT"
  provides a separate development package or SDK, be sure it has been
  installed.


-- Configuring incomplete, errors occurred!

@andresailer
Copy link
Contributor

When you run

source singularity.sh

The second command which is supposed to set up the environment is not actually run, because the singularity command does not actually return until you are done with whatever you want to do inside of it.

@saraheno
Copy link
Author

okay, it is doing better. but I'm still getting errors and failure to compile

log onto my cluster

source /cvmfs/sft.cern.ch/lcg/views/LCG_102b/x86_64-centos8-gcc11-opt/setup.sh
git clone https://github.com/AIDASoft/DD4hep.git
cd DD4hep
cd examples
git clone [email protected]:saraheno/DualTestBeam.git

edit CMakeFiles.txt and include DualTestBeam in the "SET" list

cd ../
mkdir build
mkdir install
cd build
singularity run -B /cvmfs:/cvmfs -B /data:/data docker://gitlab-registry.cern.ch/sft/docker/alma9-core:latest
source /cvmfs/sft.cern.ch/lcg/views/LCG_107/x86_64-el9-gcc14-opt/setup.sh >& output_setup.txt

this makes errors. I attach output_setup.txt

cmake -DDD4HEP_USE_GEANT4=ON -DBoost_NO_BOOST_CMAKE=ON -DDD4HEP_USE_LCIO=ON -DBUILD_TESTING=ON -DROOT_DIR=$ROOTSYS -D CMAKE_BUILD_TYPE=Release -DDD4HEP_BUILD_EXAMPLES=ON -DCMAKE_INSTALL_PREFIX=../install -D DD4HEP_USE_EDM4HEP=ON ..>& output_cmake.txt

this makes errors. I attach output_cmake.txt

make -j4 >& output_make.txt

this makes a huge spew. I attach output_make.txt

output_cmake.txt
output_setup.txt

output_make.txt

@andresailer
Copy link
Contributor

Don't mix and match

source /cvmfs/sft.cern.ch/lcg/views/LCG_102b/x86_64-centos8-gcc11-opt/setup.sh

@saraheno
Copy link
Author

okay, that fixed the compile (I thought the singularity would protect the second setup from the first? oh well). It compiled when I did the commands given below. But there must be something wrong with my CMakeLists.txt or something, as it no longer finds the modules in my examples/DualTestBeam/src area in this new environment.
I run in examples/DualTestBeam/compact with the command

ddsim --compactFile=DRConly.xml --runType=batch -G --steeringFile SCEPCALsteering.py --outputFile=out_Conly_20GeV_pi-.root --part.userParticleHandler= -G --gun.position="0. 0.mm -1cm" --gun.direction "0. 0. 1." --gun.energy "20*GeV" --gun.particle="pi-" -N 1 >& run.txt

I attach the crash in a file run.txt

run.txt

I'm a big confused because when I go to the build area and do "grep -r DRCrys * >& grep.txt" it looks like it is compiling it.

grep.txt

This is the compile commands

git clone https://github.com/AIDASoft/DD4hep.git
cd DD4hep
cd examples
git clone [email protected]:saraheno/DualTestBeam.git

edit CMakeFiles.txt and include DualTestBeam in the "SET" list

cd ../
mkdir build
mkdir install
cd build
singularity run -B /cvmfs:/cvmfs -B /data:/data docker://gitlab-registry.cern.ch/sft/docker/alma9-core:latest
source /cvmfs/sft.cern.ch/lcg/views/LCG_107/x86_64-el9-gcc14-opt/setup.sh >& output_setup2.txt
cmake -DDD4HEP_USE_GEANT4=ON -DBoost_NO_BOOST_CMAKE=ON -DDD4HEP_USE_LCIO=ON -DBUILD_TESTING=ON -DROOT_DIR=$ROOTSYS -D CMAKE_BUILD_TYPE=Release -DDD4HEP_BUILD_EXAMPLES=ON -DCMAKE_INSTALL_PREFIX=../install -D DD4HEP _USE_EDM4HEP=ON ..>& output_cmake2.txt
make -j4 >& output_make2.txt

@saraheno
Copy link
Author

nevermind. I know what I did wrong

@saraheno
Copy link
Author

saraheno commented Feb 11, 2025

okay, so now after remembering to do ./install/bin/thisdd4hep.sh, I'm getting a real crash, not just compilation problems.

what do I need to do to fix this ( as a reminder I'm trying to switch from ddsim's own root output to edh4hep output)?

Singularity> ddsim --compactFile=DRConly.xml --runType=batch -G --steeringFile SCEPCALsteering.py --outputFile=out_Conly_20GeV_pi-.root --part.userParticleHandler= -G --gun.position="0. 0.mm -1cm" --gun.direction "0. 0. 1." --gun.energy "20*GeV" --gun.particle="pi-" -N 1
PersistencyIO    INFO  +++ Set Streamer to dd4hep::OpaqueDataBlock
Info in <TGeoManager::TGeoManager>: Geometry default, Detector Geometry created
Info in <TGeoNavigator::BuildCache>: --- Maximum geometry depth set to 100
Info in <TGeoManager::SetTopVolume>: Top volume is world_volume. Master volume is world_volume
Creating DRCrys
 det_id is 5
 det_name is .. DRCrystal
 z offset is 50
honeycomb thickness is 0.000999
DRCrys layer 0
 ncount hwidth repeat hthickness 1 1.5015 1 2.501
DRCrys layer 1
 ncount hwidth repeat hthickness 1 1.5015 1 7.501
putting calorimeter in mother volume
 done
setting up optical surfaces
 done
 starting to build layers
DRCrys layer 0
 ncount hwidth repeat hthickness 1 0.5 1 2.501
layerbox0                    mat: Air             vis: Invisible       solid: TGeoBBox             sensitive: YES
tower                        mat: Air             vis: Invisible       solid: TGeoBBox             sensitive: YES
  DRCrys layer 0 repeat 0
  half  thickness is 2.501
 layer visstr is Invisible
 with slice 1
 with half  thickness 0.0005 and material killMedia1
          slice visstr is CrystalEcalSensitiveVis
 placed at -2.5005
 with slice 2
 with half  thickness 2.5 and material E_PbWO4
          slice visstr is CrystalEcalCrystalVis
 placed at -4.44089e-16
 with slice 3
 with half  thickness 0.0005 and material Air
          slice visstr is CrystalBarrelVis
 placed at 2.5005
 placed at z of 0
layer dx: 1.5025 dy: 0.501 dz: 2.502
placing crystal at (-1.003)
placing tower 1
placing crystal at (0)
placing tower 2
placing crystal at (1.003)
placing tower 3
placing crystal at (-1.003)
placing tower 1
placing crystal at (0)
placing tower 2
placing crystal at (1.003)
placing tower 3
Placing layer_0                      z-offset:       0 volume of type layerbox0
DRCrys layer 1
 ncount hwidth repeat hthickness 1 0.5 1 7.501
layerbox1                    mat: Air             vis: Invisible       solid: TGeoBBox             sensitive: YES
tower                        mat: Air             vis: Invisible       solid: TGeoBBox             sensitive: YES
  DRCrys layer 1 repeat 0
  half  thickness is 7.501
 layer visstr is Invisible
 with slice 1
 with half  thickness 7.5 and material E_PbWO4
          slice visstr is CrystalEcalCrystalVis
 placed at -0.001
 with slice 2
 with half  thickness 0.0005 and material killMedia1
          slice visstr is CrystalEcalSensitiveVis
 placed at 7.4995
 with slice 3
 with half  thickness 0.0005 and material Air
          slice visstr is CrystalBarrelVis
 placed at 7.5005
 placed at z of 0
layer dx: 1.5025 dy: 0.501 dz: 7.502
placing crystal at (-1.003)
placing tower 1
placing crystal at (0)
placing tower 2
placing crystal at (1.003)
placing tower 3
placing crystal at (-1.003)
placing tower 1
placing crystal at (0)
placing tower 2
placing crystal at (1.003)
placing tower 3
Placing layer_1                      z-offset:  10.002 volume of type layerbox1
exiting DRCrys creator
Creating EdgeDet
 det_id is 4
 det_name is .. EdgeDet
 half zlength 1755.02 half height 1168.35 half width 1168.35 thickness 1
setting envelope visibility to EDGEVis3
setting EdgeDet side sensitive
setting EdgeDet side sensitive
setting EdgeDet side sensitive
exiting DRFiber creator
Info in <TGeoManager::CheckGeometry>: Fixing runtime shapes...
Info in <TGeoManager::CheckGeometry>: ...Nothing to fix
Info in <TGeoManager::CloseGeometry>: Counting nodes...
Info in <TGeoManager::Voxelize>: Voxelizing...
Info in <TGeoManager::CloseGeometry>: Building cache...
Info in <TGeoManager::CountLevels>: max level = 6, max placements = 6
Info in <TGeoManager::CloseGeometry>: 125 nodes/ 13 volume UID's in Detector Geometry
Info in <TGeoManager::CloseGeometry>: ----------------modeler ready----------------
DDG4             INFO +++ Imported 47 global values to namespace:DDG4
Geant4Kernel           OutputLevel:  2
Geant4Kernel           UI:           UI
Geant4Kernel           NumEvents:    10
Geant4Kernel           NumThreads:   0
DDG4             INFO +++  List of sensitive detectors:
DDG4             INFO +++  DRCrystal                        type:calorimeter   --> Sensitive type: ('DualCrysCalorimeterSDAction', {'dialCherC': 1.25e-05, 'dialScintC': 5e-06, 'dialCherO': 0.000125, 'dialScintO': 5e-08, 'betarel': 0.648, 'printlimitSCE': 10, 'MAXEVENTSCE': 10})
DDG4             INFO +++  EdgeDet                          type:calorimeter   --> Sensitive type: ('DualCrysCalorimeterSDAction', {'dialCherC': 1.25e-05, 'dialScintC': 5e-06, 'dialCherO': 0.000125, 'dialScintO': 5e-08, 'betarel': 0.648, 'printlimitSCE': 10, 'MAXEVENTSCE': 10})
DDSim.Helper.Random INFO Choosing random seed for you: 1086849989
DDSim.Helper.OutputConfig INFO ++++ Setting up EDM4hep ROOT Output ++++
Segmentation fault (core dumped)

@saraheno
Copy link
Author

saraheno commented Feb 12, 2025

I think there must be some magic command I am missing to setup my edm4hep.root file? Or maybe I need some code to tell edm4hep about my custom hit class https://github.com/saraheno/DualTestBeam/blob/master/src/DualCrysCalorimeterHit.h? or maybe there is something about the custom hit class edm4hep doesn't like? maybe it has structures in it edm4hep doesn't like?

unfortunately the crash does not seem to be very informative. It just looks like

DDG4             INFO +++  EdgeDet                          type:calorimeter   --> Sensitive type: ('DualCrysCalorimeterSDAction', {'dialCherC': 1.25e-05, 'dialScintC': 5e-06, 'dialCherO': 0.000125, 'dialScintO': 5e-08, 'betarel': 0.648, 'printlimitSCE': 10, 'MAXEVENTSCE': 10})
DDSim.Helper.Random INFO Choosing random seed for you: 1194918799
DDSim.Helper.OutputConfig INFO ++++ Setting up EDM4hep ROOT Output ++++
Segmentation fault (core dumped)

I am guessing it is crashing while trying to setup the EDM4hep root output?
When I look in the steering file, I don't see many options about setting this up?
https://github.com/saraheno/DualTestBeam/blob/master/compact/SCEPCALsteering.py

@andresailer
Copy link
Contributor

Does the ddsim command work with your previous setup?

@andresailer
Copy link
Contributor

Also please remember our little friends the triple tick marks ```

@andresailer
Copy link
Contributor

The error message you see comes from

--gun.position="0. 0.mm -1cm"

Of course once you fix that issue and add -v VERBOSE to your ddsim call you will see that indeed you need to add your own output conversion

[snip]
EDM4hepOutput    VERB  +++ Saving 20 EDM4hep particles....
EDM4hepOutput    DEBUG +++ Saving EDM4hep collection DRCNoSegment with 16 entries.
EDM4hepOutput    ERROR +++ unknown type in Geant4HitCollection N9CalVision22DualCrysCalorimeterHitE 
EDM4hepOutput    DEBUG +++ Saving EDM4hep collection EdgeDetNoSegment with 3 entries.
EDM4hepOutput    ERROR +++ unknown type in Geant4HitCollection N9CalVision22DualCrysCalorimeterHitE 
[snip]

By the way if you apply these changes to your code, you don't have to compile all of dd4hep, but just your example, and then source bin/thisDualTestBeam.sh

diff --git a/CMakeLists.txt b/CMakeLists.txt
index f44e907..7160f15 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -14,6 +14,13 @@
 #==========================================================================
 cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
 
+
+set( PackageName DualTestBeam )
+#---------------------------
+
+project(${PackageName})
+
+
 IF(NOT TARGET DD4hep::DDCore)
   find_package ( DD4hep REQUIRED )
   include ( ${DD4hep_DIR}/cmake/DD4hep.cmake )
@@ -78,12 +85,13 @@ dd4hep_configure_output ()
 dd4hep_add_plugin ( DualTestBeam
     GENERATED G__DualTestBeam.cxx 
   SOURCES src/*.cpp src/plugins/*.cpp
-  USES    DD4hep::DDCore DD4hep::DDAlign DD4hep::DDCond DD4hep::DDG4 DDDetectors
+  USES    DD4hep::DDCore DD4hep::DDAlign DD4hep::DDCond DD4hep::DDG4
           ROOT::Core ROOT::Geom ROOT::GenVector CLHEP::CLHEP Geant4::Interface
 )
 
 
 
+dd4hep_instantiate_package(${PackageName})
 
 
 target_include_directories(DualTestBeam PUBLIC include)

@andresailer
Copy link
Contributor

You already created a different output plugin in the past AIDASoft/DD4hep#1104 (comment)

@saraheno
Copy link
Author

saraheno commented Feb 12, 2025

Thanks Andre.

Regarding the user defined output... I put that old code into my repository. No idea if it will compile.

but before I try to start compiling it. I'm a bit worried. My main goal is to make some code like

https://github.com/key4hep/k4GaudiPandora/blob/4b9f4b92e1e92abc15c594f7c74584f1f2269742/k4GaudiPandora/include/DDSimpleMuonDigi.h#L39

to read my custom hits and turn them into digis

I think I was told that to do this, I cannot use the native ddsim root tuple. I need a edm4hep root tuple. Does this code

https://github.com/saraheno/DualTestBeam/blob/master/src/SCEGeant4Output2ROOT.cpp
https://github.com/saraheno/DualTestBeam/blob/master/src/SCEGeant4Output2ROOT.h
https://github.com/saraheno/DualTestBeam/blob/7435b36c115528a86d0f0f98915aada2161e3460/compact/SCEPCALsteering.py#L373

work with or make or something like that an ed4hep root tuple?

Is there anything special I need to do so that what comes out can be read by something like the muon single digi code?

@saraheno
Copy link
Author

I have to admit, looking at the code now, I don't even understand why SCEGeant4Output2ROOT.* doesn't include my custom hit header DualCrystalCalorimeterHit.h. If I was making an edm4hep output for my custom class, shouldn't it include that header?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants