diff --git a/src/GenericDetectors/CMakeLists.txt b/src/GenericDetectors/CMakeLists.txt index 2974ab6dad22adb6fee29a0a21651f43deb49f66..7c77dc929994e580bb559dc165ae0afb50064cd4 100644 --- a/src/GenericDetectors/CMakeLists.txt +++ b/src/GenericDetectors/CMakeLists.txt @@ -38,6 +38,8 @@ dd4hep_add_plugin(GenDetectors calorimeters/src/HexagonalShashlykSamplingECAL_geo.cpp calorimeters/src/EndcapECAL_geo.cpp calorimeters/src/CrystalEndcapECAL_geo.cpp + calorimeters/src/ScintillatingTileEndcapHCAL_geo.cpp + beamline/src/Beampipe_geo.cpp beamline/src/IRChamber_geo.cpp beamline/src/Beampipe_geo.cpp beamline/src/B0pF_geo.cpp diff --git a/src/GenericDetectors/calorimeters/compact/ScintillatingTileEndcapHCAL_example.xml b/src/GenericDetectors/calorimeters/compact/ScintillatingTileEndcapHCAL_example.xml new file mode 100644 index 0000000000000000000000000000000000000000..80f7c6f2886cd199262f453452583b63aa7ce431 --- /dev/null +++ b/src/GenericDetectors/calorimeters/compact/ScintillatingTileEndcapHCAL_example.xml @@ -0,0 +1,110 @@ + + + + + Electron Endcap EMCAL detector + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Common Generic visualization attributes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + system:5,module:14,sensor:2,side:32:-2,strip:24 + + + + + + + + + + + + + + diff --git a/src/GenericDetectors/calorimeters/compact/macro/gps3.mac b/src/GenericDetectors/calorimeters/compact/macro/gps3.mac new file mode 100644 index 0000000000000000000000000000000000000000..da41b0db238e68858ec459c81b50d3b8d2286cd1 --- /dev/null +++ b/src/GenericDetectors/calorimeters/compact/macro/gps3.mac @@ -0,0 +1,26 @@ +/run/beamOn 1 +/control/verbose 2 +/run/initialize + +/gps/verbose 2 +/gps/particle pi- +/gps/number 1 + +/gps/ene/type Gauss +/gps/ene/mono 5.5 GeV +/gps/ene/sigma 2.0 GeV + +/gps/pos/type Volume +/gps/pos/shape Cylinder +/gps/pos/centre 0.0 0.0 0.0 cm +/gps/pos/radius 0.01 cm +/gps/pos/halfz 0.01 cm +/gps/position 0 0 0.02 cm + +/gps/direction 0 0.07 1.0 +#/gps/ang/type iso + + +/control/execute macro/vis3.mac + +/run/beamOn 1 diff --git a/src/GenericDetectors/calorimeters/compact/macro/vis3.mac b/src/GenericDetectors/calorimeters/compact/macro/vis3.mac new file mode 100644 index 0000000000000000000000000000000000000000..d08726b88f1b358950578f542db46e404444900e --- /dev/null +++ b/src/GenericDetectors/calorimeters/compact/macro/vis3.mac @@ -0,0 +1,18 @@ +/vis/open OGL 800x800-0+0 + +/vis/drawVolume +/vis/viewer/set/viewpointThetaPhi 90. 0. +#/vis/viewer/zoom 30. +#/vis/viewer/set/style wireframe +#/vis/scene/add/axes 0 0 0 1 m +/vis/scene/add/trajectories rich smooth +/vis/modeling/trajectories/create/drawByCharge +/vis/modeling/trajectories/drawByCharge-0/default/setDrawStepPts true +/vis/modeling/trajectories/drawByCharge-0/default/setStepPtsSize 2 +/vis/scene/add/hits +/vis/scene/endOfEventAction accumulate 200 + +/vis/viewer/flush + + + diff --git a/src/GenericDetectors/calorimeters/compact/scripts/run_example3 b/src/GenericDetectors/calorimeters/compact/scripts/run_example3 new file mode 100755 index 0000000000000000000000000000000000000000..6d6f60fc35900adf395284714864fca75f15b79c --- /dev/null +++ b/src/GenericDetectors/calorimeters/compact/scripts/run_example3 @@ -0,0 +1,7 @@ +#!/bin/bash + +ddsim --runType vis --enableG4GPS \ + --macroFile macro/gps3.mac \ + --compactFile $1 \ + --outputFile test_calorimeter_sampling.root || exit + #--outputFile test_tracker_disc.root || exit diff --git a/src/GenericDetectors/calorimeters/src/ScintillatingTileEndcapHCAL_geo.cpp b/src/GenericDetectors/calorimeters/src/ScintillatingTileEndcapHCAL_geo.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ab09178e1806b7992949c36ace77b643c1f1c31f --- /dev/null +++ b/src/GenericDetectors/calorimeters/src/ScintillatingTileEndcapHCAL_geo.cpp @@ -0,0 +1,181 @@ +//========================================================================== +// Scintillating Tile Endcap H Calorimeter Detector implementation +//-------------------------------------------------------------------------- +// J.KIM 2020-04-07 +// Created tile-shaped Pb/Sci +//========================================================================== +#include "DD4hep/DetFactoryHelper.h" +#include "DD4hep/Printout.h" +#include +#include "TMath.h" +#include "DDRec/Surface.h" +#include "DDRec/DetectorData.h" + +using namespace std; +using namespace dd4hep; +using namespace dd4hep::rec; +using namespace dd4hep::detail; + +static Ref_t createDetector(Detector& description, xml_h e, SensitiveDetector sens) { + xml_det_t x_det = e; + int det_id = x_det.id(); + string det_name = x_det.nameStr(); + // Size of Endcap + double rmin = 2.0*cm; + double rmax = 10.0*cm; + + Assembly assembly( det_name+"_assembly" ); + // Number of layers of each tile + int nlayers = 30; + // Thickness of plates + double layer0_thickness = 0.5*mm; //Pb_slice + double layer1_thickness = 1.5*mm; //Scint_slice + double total_layer_thickness = layer0_thickness + layer1_thickness; + // Size of tile + double width_x = 1*cm; + double width_y = 1*cm; + // Visualization Setting + auto gray_vis = description.visAttributes("GrayVis"); + auto red_vis = description.visAttributes("RedVis"); + + DetElement det(det_name, det_id); + + Assembly module_assembly( "module_assembly" ); + PlacedVolume module_PV; + + //Pb tile + Box lead_layer_shape(width_x/2.0, width_y/2.0,layer0_thickness/2.0); + Volume lead_layer_Vol("lead_layer_Vol", lead_layer_shape, description.material("Lead")); + lead_layer_Vol.setVisAttributes(gray_vis); + //Sci tile + Box scint_layer_shape(width_x/2.0, width_y/2.0,layer1_thickness/2.0); + Volume scint_layer_Vol("scint_layer_Vol", scint_layer_shape, description.material("PlasticScint")); + scint_layer_Vol.setVisAttributes(red_vis); + // A Stack of Pb and Scintillator tiles + for(int ilayer = 0; ilayer < nlayers; ilayer++) { + double z_layer = ilayer * total_layer_thickness + layer0_thickness / 2.0; + auto lead_PV = module_assembly.placeVolume(lead_layer_Vol, Position(0.0, 0.0, z_layer)); + lead_PV.addPhysVolID("layer", ilayer).addPhysVolID("slice", 1); + sens.setType("calorimeter"); + lead_layer_Vol.setSensitiveDetector(sens); + double dz_scint = layer0_thickness / 2.0 + layer1_thickness / 2.0; + auto scint_PV = module_assembly.placeVolume(scint_layer_Vol, Position(0.0, 0.0, z_layer + dz_scint)); + scint_PV.addPhysVolID("layer", ilayer).addPhysVolID("slice", 2); + sens.setType("calorimeter"); + scint_layer_Vol.setSensitiveDetector(sens); + } + + // How many + int nx = 10; + int ny = 10; + // Offset between X and Y + double offset_x = 0.1*mm; + double offset_y = 0.1*mm; + // Position of each stack of Pb/Sc + double pos_x = 0.0*cm; + double pos_y = 0.0*cm; + // Starting Position of each stack of Pb/Sc + double x_start = (width_x + offset_x)/2.0; + double y_start = (width_y + offset_x)/2.0; + // Spacing between stacks and Diagonal length + double x_spacing = width_x + offset_x; + double y_spacing = width_y + offset_y; + double diagonal = width_x*sqrt(2); + // Limit based on Endcap size + double limit_inner = rmin + diagonal/2.0; + double limit_outer = rmax - diagonal/2.0; + + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // Start placing stacks of Pb/Sc + // Divide 4 sections; X+Y+, X-Y+, X+Y-, X-Y- + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // X+Y+ + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + int imod = 0; + for(int ix = 0; ix limit_inner && sqrt((pos_x*pos_x) + (pos_y*pos_y)) < limit_outer) + { + module_PV = assembly.placeVolume(module_assembly, Position(pos_x,pos_y,0.0)); + imod++; + module_PV.addPhysVolID("module", imod); + } + else + continue; + } + } + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // X-Y+ + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + for(int ix = 0; ix limit_inner && sqrt((pos_x*pos_x) + (pos_y*pos_y)) < limit_outer) + { + module_PV = assembly.placeVolume(module_assembly, Position(pos_x,pos_y, 0.0)); + imod++; + module_PV.addPhysVolID("module", imod); + } + else + continue; + } + } + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // X+Y- + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + for(int ix = 0; ix limit_inner && sqrt((pos_x*pos_x) + (pos_y*pos_y)) < limit_outer) + { + module_PV = assembly.placeVolume(module_assembly, Position(pos_x,pos_y, 0.0)); + imod++; + module_PV.addPhysVolID("module", imod); + } + else + continue; + } + } + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // X-Y- + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + for(int ix = 0; ix limit_inner && sqrt((pos_x*pos_x) + (pos_y*pos_y)) < limit_outer) + { + module_PV = assembly.placeVolume(module_assembly, Position(pos_x,pos_y, 0.0)); + imod++; + module_PV.addPhysVolID("module", imod); + } + else + continue; + } + } + + Volume motherVol = description.pickMotherVolume(det); + PlacedVolume envPV = motherVol.placeVolume(assembly, Position(0, 0, 0)); + envPV.addPhysVolID("system", det_id); + det.setPlacement(envPV); + return det; +} + +// clang-format off +DECLARE_DETELEMENT(ScintillatingTileEndcapHCAL, createDetector)