Skip to content
Snippets Groups Projects
Commit 8f711cbc authored by Jihee Kim's avatar Jihee Kim
Browse files

Added box-shaped crystals assembly

parent 68b66bb0
Branches
Tags
No related merge requests found
......@@ -7,7 +7,7 @@
author="Jihee Kim"
url="https://eicweb.phy.anl.gov/EIC/NPDet"
status="development"
version="v1.0 2020-03-26">
version="v1.1 2020-03-31">
<comment>Electron Endcap EMCAL detector</comment>
</info>
......@@ -112,9 +112,8 @@
<!-- Define detector -->
<detectors>
<detector id="1" name="ForwardElectronECAL" type="CrystalEndcapECAL" readout="EcalEndcapHits"
vis="RedVis">
<dimensions rmin="15.0*cm" rmax="150.0*cm" zmin="-30.0*cm" zmax="30.0*cm"/>
<detector id="1" name="ForwardElectronECAL" type="CrystalEndcapECAL" readout="EcalEndcapHits" vis="RedVis">
<dimensions rmin="15.0*cm" rmax="60.0*cm" zmin="-30.0*cm" zmax="30.0*cm"/>
<comment>Electromagnetic Calorimeter Endcaps</comment>
</detector>
</detectors>
......@@ -125,11 +124,6 @@
<segmentation type="CartesianGridXY" grid_size_x="3.5" grid_size_y="3.5" />
<id>system:8,barrel:3,module:4,layer:6,slice:5,x:32:-16,y:-16</id>
</readout>
<readout name="EcalBarrelHits">
<segmentation type="CartesianGridXY" grid_size_x="3.5 * mm" grid_size_y="3.5 * mm"/>
<id>system:6,barrel:3,module:4,layer:6,slice:5,x:32:-16,y:-16</id>
</readout>
</readouts>
......
......@@ -5,11 +5,12 @@
// Authors : W.Armstrong
//
//==========================================================================
//
//
// J.KIM 2020-04-01
// Added box assembly of volumes
//==========================================================================
#include "DD4hep/DetFactoryHelper.h"
#include "XML/Layering.h"
#include <math.h>
using namespace std;
using namespace dd4hep;
......@@ -31,15 +32,179 @@ static Ref_t create_detector(Detector& description, xml_h e, SensitiveDetector s
Assembly assembly(det_name);
DetElement endcap_DE(det_name,det_id);
// Here we just create a tube to represent the calorimeter
// In the future this should be broken into individual blocks
// of cristals forming a grid.
Tube dummy_calorimeter_tube(rmin, rmax, thickness / 2.0);
Volume dummy_calorimeter_Vol(det_name + "_dummy", dummy_calorimeter_tube, PbWO4);
auto dummy_PV = assembly.placeVolume(dummy_calorimeter_Vol, Position(0.0, 0.0, 0.0));
dummy_PV.addPhysVolID("layer", 0);
// Create a tube to represent the calorimeter
Tube tube(rmin, rmax, thickness / 2.0);
Volume Vol("tube_volume", tube, PbWO4);
auto PV = assembly.placeVolume(Vol, Position(0.0, 0.0, 0.0));
PV.addPhysVolID("layer", 0);
sens.setType("calorimeter");
Vol.setSensitiveDetector(sens);
// Tube is filled with box-shaped crystals forming a grid.
Assembly box_assembly("box_assembly");
PlacedVolume pv_box;
// Box-shaped crystal dimension
double box_x_width = 2*cm;
double box_y_width = 2*cm;
double box_z_length = 60.5*cm;
// Gap between box-shaped crystals
double offset_x = 1*mm;
double offset_y = 1*mm;
// Number of crystals in a grid
int nx = floor(rmax/box_x_width);
int ny = floor(rmax/box_y_width);
// X or Y spacing increasement
double x_spacing = box_x_width + offset_x;
double y_spacing = box_y_width + offset_y;
// initial positions in X or Y.
double pos_x = 0*cm;
double pos_y = 0*cm;
// Create Box and Volume
Box box(box_x_width/2.0, box_y_width/2.0, box_z_length/2.0);
Volume vol("box_volume", box, PbWO4);
////////////////////////////////////////////////////////////////////////////////////
// Divide tube into 4 sections; top left, top right, bottom left, and bottom right
////////////////////////////////////////////////////////////////////////////////////
// Top left
////////////////////////////////////////////////////////////////////////////////////
for(int iy=0; iy<ny-1; iy++){
for(int ix=0; ix<nx; ix++){
double x_start = box_x_width/2.0;
if(ix==0)
{
pos_x = x_start;
if(sqrt((pos_x*pos_x) + (pos_y*pos_y)) > rmin)
pv_box = assembly.placeVolume(vol, Position(pos_x,pos_y,0.0));
else
continue;
}
else
{
// Move to +X
pos_x += x_spacing;
if(sqrt((pos_x*pos_x) + (pos_y*pos_y)) < rmax && sqrt((pos_x*pos_x) + (pos_y*pos_y)) > rmin)
pv_box = assembly.placeVolume(vol, Position(pos_x,pos_y,0.0));
else
continue;
}
pv_box.addPhysVolID("layer",0);
sens.setType("calorimeter");
vol.setSensitiveDetector(sens);
}
// Move to +Y
pos_y += y_spacing;
}
////////////////////////////////////////////////////////////////////////////////////
// Top right
////////////////////////////////////////////////////////////////////////////////////
// Initialize position in Y
pos_y = 0.0;
for(int iy=0; iy<ny-1; iy++){
for(int ix=0; ix<nx; ix++){
double x_start = box_x_width/2.0 + offset_x;
if(ix==0)
{
pos_x = - x_start;
if(sqrt((pos_x*pos_x) + (pos_y*pos_y)) > rmin)
pv_box = assembly.placeVolume(vol, Position(pos_x,pos_y,0.0));
else
continue;
}
else
{
// Move to -X
pos_x -= x_spacing;
if(sqrt((pos_x*pos_x) + (pos_y*pos_y)) < rmax && sqrt((pos_x*pos_x) + (pos_y*pos_y)) > rmin)
pv_box = assembly.placeVolume(vol, Position(pos_x,pos_y,0.0));
else
continue;
}
pv_box.addPhysVolID("layer",0);
sens.setType("calorimeter");
dummy_calorimeter_Vol.setSensitiveDetector(sens);
vol.setSensitiveDetector(sens);
}
// Move to +Y
pos_y += y_spacing;
}
////////////////////////////////////////////////////////////////////////////////////
// Bottom left
////////////////////////////////////////////////////////////////////////////////////
// It's below the first row of the section of Top left
// That's why ny goes up to ny -2 (the first row of Bottom left starts one row less)
pos_y = -y_spacing;
for(int iy=0; iy<ny-2; iy++){
for(int ix=0; ix<nx; ix++){
double x_start = box_x_width/2.0;
if(ix==0)
{
pos_x = x_start;
if(sqrt((pos_x*pos_x) + (pos_y*pos_y)) > rmin)
pv_box = assembly.placeVolume(vol, Position(pos_x,pos_y,0.0));
else
continue;
}
else
{
// Move to +X
pos_x += x_spacing;
if(sqrt((pos_x*pos_x) + (pos_y*pos_y)) < rmax && sqrt((pos_x*pos_x) + (pos_y*pos_y)) > rmin)
pv_box = assembly.placeVolume(vol, Position(pos_x,pos_y,0.0));
else
continue;
}
pv_box.addPhysVolID("layer",0);
sens.setType("calorimeter");
vol.setSensitiveDetector(sens);
}
// Move to -Y
pos_y -= y_spacing;
}
////////////////////////////////////////////////////////////////////////////////////
// Bottom right
////////////////////////////////////////////////////////////////////////////////////
// Again it's below the first row of the section of Top left
// That's why ny goes up to ny -2 (the first row of Bottom left starts one row less)
pos_y = -y_spacing;
for(int iy=0; iy<ny-2; iy++){
for(int ix=0; ix<nx; ix++)
{
double x_start = box_x_width/2.0 + offset_x;
if(ix==0)
{
pos_x = - x_start;
if(sqrt((pos_x*pos_x) + (pos_y*pos_y)) > rmin)
pv_box = assembly.placeVolume(vol, Position(pos_x,pos_y,0.0));
else
continue;
}
else
{
// Move to -X
pos_x -= x_spacing;
if(sqrt((pos_x*pos_x) + (pos_y*pos_y)) < rmax && sqrt((pos_x*pos_x) + (pos_y*pos_y)) > rmin)
pv_box = assembly.placeVolume(vol, Position(pos_x,pos_y,0.0));
else
continue;
}
pv_box.addPhysVolID("layer",0);
sens.setType("calorimeter");
vol.setSensitiveDetector(sens);
}
// Move to -Y
pos_y -= y_spacing;
}
////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////
Volume motherVol = description.pickMotherVolume(endcap_DE);
auto pv = motherVol.placeVolume(assembly, Position(0.0, 0.0, z_pos));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment