diff --git a/.gitignore b/.gitignore index 7b9ab073ef3ca0a2412212ed0a44395feb31847e..fc58c11b6a1c796c31b5ed56353db1397376dbfd 100644 --- a/.gitignore +++ b/.gitignore @@ -38,3 +38,5 @@ __pycache__/ # test for calorimeter calorimeters/test/ +*.d +*.pcm diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8eaaee8972d5ecbe5dbdf0dcca70e26d0505d5a7..9fb3a4e65853692bb653935578558bfc3b8965a2 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -67,6 +67,15 @@ zdc_simulation: - cp NPDet/src/GenericDetectors/calorimeters/compact/materials.xml ./. - bash calorimeters/run_simulation_zdc.sh +crystal_emcal_simulation: + stage: simulate + tags: + - sodium + script: + - cp NPDet/src/GenericDetectors/calorimeters/compact/elements.xml ./. + - cp NPDet/src/GenericDetectors/calorimeters/compact/materials.xml ./. + - bash calorimeters/run_simulation_crystal.sh + cal_test_1_dummy_test2: stage: benchmarks tags: @@ -142,6 +151,15 @@ zdc_benchmark_info_histogram: - root -b -q calorimeters/simple_info_plot_histograms.cxx+ allow_failure: true +crystal_benchmark: + stage: benchmarks + tags: + - sodium + script: + - ls -lrth sim_output + - root -b -q calorimeters/simple_checking_crystal.cxx+ + allow_failure: true + deploy_results: stage: deploy tags: diff --git a/calorimeters/Crystal_example.xml b/calorimeters/Crystal_example.xml new file mode 100644 index 0000000000000000000000000000000000000000..1a40a394dba36e3cdfd97f191a918fea99792aa7 --- /dev/null +++ b/calorimeters/Crystal_example.xml @@ -0,0 +1,88 @@ +<lccdd xmlns:compact="http://www.lcsim.org/schemas/compact/1.0" + xmlns:xs="http://www.w3.org/2001/XMLSchema" + xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/compact/1.0/compact.xsd"> + + <!-- Some information about detector --> + <info name="Electron_Endcap_EMcal_PbWO4_example" title="Electron Endcap EMCAL detector example" + author="Jihee Kim" + url="https://eicweb.phy.anl.gov/EIC/NPDet" + status="development" + version="v2.0 2020-07-30"> + <comment>Electron Endcap EMCAL detector</comment> + </info> + + <!-- Use DD4hep elements and materials definitions --> + <includes> + <gdmlFile ref="elements.xml"/> + <gdmlFile ref="materials.xml"/> + </includes> + + <!-- Define the dimensions of the world volume --> + <define> + <constant name="world_side" value="50*m"/> + <constant name="world_x" value="world_side"/> + <constant name="world_y" value="world_side"/> + <constant name="world_z" value="world_side"/> + + <constant name="tracker_region_zmax" value="6 * m"/> + <constant name="tracker_region_rmax" value="6 * m"/> + + <constant name="CrystalEndcap_ID" value="1"/> + <constant name="CrystalEndcap_rmin" value="120.0*mm"/> <!-- 12cm --> + <constant name="CrystalEndcap_rmax" value="600.0*mm"/> <!-- 60cm --> + <constant name="CrystalBox_x_length" value="20.0*mm"/> <!-- 2cm --> + <constant name="CrystalBox_y_length" value="20.0*mm"/> <!-- 2cm --> + <constant name="CrystalBox_z_length" value="200.0*mm"/> <!-- 20cm --> + <constant name="CrystalEndcap_x_pos" value="0.0*m"/> + <constant name="CrystalEndcap_y_pos" value="0.0*m"/> + <constant name="CrystalEndcap_z_pos" value="-1.0*m"/> + </define> + + <limits> + </limits> + + <regions> + </regions> + + <!-- Common Generic visualization attributes --> + <comment>Common Generic visualization attributes</comment> + <display> + <vis name="InvisibleNoDaughters" showDaughters="false" visible="false"/> + <vis name="InvisibleWithDaughters" showDaughters="true" visible="false"/> + <vis name="GreenVis" alpha="0.5" r= "0.0" g="1.0" b="0.0" showDaughters="true" visible="true"/> + <vis name="RedVis" alpha="0.5" r= "1.0" g="0.0" b="0.0" showDaughters="true" visible="true"/> + <vis name="BlueVis" alpha="0.5" r= "0.0" g="0.0" b="1.0" showDaughters="true" visible="true"/> + <vis name="OrangeVis" alpha="0.5" r= "1.0" g="0.45" b="0.0" showDaughters="true" visible="true"/> + <vis name="RedGreenVis" alpha="0.5" r= "1.0" g="1.0" b="0.0" showDaughters="true" visible="true"/> + <vis name="BlueGreenVis" alpha="0.5" r= "0.0" g="1.0" b="1.0" showDaughters="true" visible="true"/> + <vis name="PurpleVis" alpha="0.5" r= "1.0" g="0.0" b="1.0" showDaughters="true" visible="true"/> + <vis name="DoubleRedG" alpha="0.5" r= "2.0" g=".10" b="0.0" showDaughters="true" visible="true"/> + <vis name="RBG015" alpha="0.5" r= "0.0" g=".2" b="1.0" showDaughters="true" visible="true"/> + <vis name="RBG510" alpha="0.5" r= "1.0" g=".2" b="0.0" showDaughters="true" visible="true"/> + <vis name="RBG" alpha="0.5" r= "1.0" g="1.0" b="1.0" showDaughters="true" visible="true"/> + <vis name="GrayVis" alpha="0.5" r= "0.75" g="0.75" b="0.75" showDaughters="true" visible="true"/> + </display> + + <!-- Define detector --> + <detectors> + <detector id="CrystalEndcap_ID" name="ElectronECAL" type="crystal" readout="EcalHits" vis="GreenVis"> + <position x="CrystalEndcap_x_pos" y="CrystalEndcap_y_pos" z="CrystalEndcap_z_pos"/> + <dimensions rmin="CrystalEndcap_rmin" rmax="CrystalEndcap_rmax" x="CrystalBox_x_length" y="CrystalBox_y_length" z="CrystalBox_z_length"/> + </detector> + </detectors> + + <!-- Definition of the readout segmentation/definition --> + <readouts> + <readout name="EcalHits"> + <segmentation type="CartesianGridXY" grid_size_x="20.0*mm" grid_size_y="20.0*mm" /> + <id>system:8,sector:4,module:20,x:48:-8,y:-8</id> + </readout> + </readouts> + + + <plugins> + </plugins> + + <fields> + </fields> +</lccdd> diff --git a/calorimeters/run_simulation_crystal.sh b/calorimeters/run_simulation_crystal.sh new file mode 100755 index 0000000000000000000000000000000000000000..aabd423092cde1ab27dae07a036c0ad91e2c6bd7 --- /dev/null +++ b/calorimeters/run_simulation_crystal.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +ddsim --runType batch --numberOfEvents 100 \ + --compactFile ./calorimeters/Crystal_example.xml \ + --inputFiles ./data/emcal_electrons.hepmc \ + --outputFile ./sim_output/output_emcal_electrons.root diff --git a/calorimeters/simple_checking_crystal.cxx b/calorimeters/simple_checking_crystal.cxx new file mode 100644 index 0000000000000000000000000000000000000000..32997fb6688500d92d608ddd3feeeba94b08813e --- /dev/null +++ b/calorimeters/simple_checking_crystal.cxx @@ -0,0 +1,32 @@ +R__LOAD_LIBRARY(libDDG4IO.so) +#include "DDG4/Geant4Data.h" +#include "ROOT/RDataFrame.hxx" +#include "TCanvas.h" +#include "TChain.h" +#include <random> + +void simple_checking_crystal(const char* fname = "sim_output/output_emcal_electrons.root"){ + ROOT::EnableImplicitMT(); // Tell ROOT you want to go parallel + double degree = TMath::Pi()/180.0; + + TChain* t = new TChain("EVENT"); + t->Add(fname); + + ROOT::RDataFrame d0(*t);//, {"EcalHits","MCParticles"}); + + auto nhits = [] (std::vector<dd4hep::sim::Geant4Calorimeter::Hit*>& hits){ return (int) hits.size(); }; + + auto d1 = d0.Define("nhits", nhits, {"EcalHits"}); + auto h0 = d1.Histo1D(TH1D("h0", "nhits; ", 20, 0,20), "nhits"); + + auto n0 = d1.Filter([](int n){ return (n>0); },{"nhits"}).Count(); + + TCanvas* c = new TCanvas(); + + std::cout << *n0 << " events with nonzero hits\n"; + if(*n0<5) { + std::quick_exit(1); + } + +} +