Commit 1da9e11c authored by Whitney Armstrong's avatar Whitney Armstrong
Browse files

Adds better parameterized detector.

- The detectors adjust depending on a few top level paramgters.
- There are many areas for improvement, like shifting the solenoid (if this is desired). 
- the forward RICH needs some attention and some changes were made to be more flexible. 

Merge branch '37-parameterized-detector-structure' into 'master'

Resolve "Parameterized Detector Structure"

Closes #37

See merge request !22
parents 64fcc24a 1faeeae6
Pipeline #8011 passed with stages
in 2 minutes and 29 seconds
......@@ -16,7 +16,7 @@ set(a_lib_name reference_detector)
dd4hep_configure_output()
dd4hep_add_plugin(${a_lib_name} SOURCES src/*.cpp
USES ActsCore ActsPluginDD4hep
# USES ActsCore ActsPluginDD4hep
)
target_link_libraries(${a_lib_name}
PUBLIC DD4hep::DDCore DD4hep::DDRec
......
......@@ -3,6 +3,9 @@
<comment> Central Barrel Tracker Silicon </comment>
<define>
<comment> Si layer opiton </comment>
<constant name="cb_CTD_Si_gap" value="5.0 * cm"/>
<constant name="cb_CTD_Si_layer" value="15"/>
</define>
<limits>
......
......@@ -21,7 +21,7 @@
</comment>
<detector id="Solenoid_ID" name="cb_Solenoid" type="cb_Solenoid" insideTrackingVolume="false" vis="cb_SolenoidVis">
<material name="Vacuum"/> <!-- G4_Galactic -->
<dimensions rmin="cb_Solenoid_rmin" rmax="cb_Solenoid_rmax" z="cb_Solenoid_z" delta="cb_Solenoid_shift"/>
<dimensions rmin="Solenoid_rmin" rmax="Solenoid_rmax" z="b_Solenoid_z" delta="cb_Solenoid_shift"/>
</detector>
</detectors>
......
This diff is collapsed.
......@@ -9,7 +9,7 @@
<constant name="CrystalBox_offset" value="0.000001*mm"/>
<constant name="CrystalEndcap_x_pos" value="0.0*m"/>
<constant name="CrystalEndcap_y_pos" value="0.0*m"/>
<constant name="CrystalEndcap_z_pos" value="-EcalEndcap_zmin"/>
<constant name="CrystalEndcap_z_pos" value="-EcalEndcapN_zmin"/>
</define>
......@@ -36,21 +36,23 @@
<detector
id="ECalBarrel_ID"
name="EcalBarrel"
type="DD4hep_EcalBarrel"
type="refdet_EcalBarrel"
readout="EcalBarrelHits"
calorimeterType="EM_BARREL">
calorimeterType="EM_BARREL"
offset="EcalBarrel_offset"
>
<dimensions
numsides="CaloSides"
rmin="EcalBarrel_rmin"
z="EcalBarrelLength"/>
<staves vis="EcalBarrelVis"/>
<layer repeat="1">
<layer repeat="EcalBarrelLayer1_NRepeat">
<slice material="Silicon" thickness="EcalSiliconThickness" sensitive="yes" limits="cal_limits"/>
<slice material="Copper" thickness="EcalCopperThickness"/>
<slice material="Kapton" thickness="EcalKaptonThickness"/>
<slice material="Air" thickness="EcalAir1Thickness"/>
</layer>
<layer repeat="EcalBarrelThinLayers">
<layer repeat="EcalBarrelLayer2_NRepeat">
<slice material="TungstenDens24" thickness="EcalThinTungstenThickness"/>
<slice material="Air" thickness="EcalAir2Thickness"/>
<slice material="Silicon" thickness="EcalSiliconThickness" sensitive="yes" limits="cal_limits"/>
......@@ -58,7 +60,7 @@
<slice material="Kapton" thickness="EcalKaptonThickness"/>
<slice material="Air" thickness="EcalAir1Thickness"/>
</layer>
<layer repeat="EcalBarrelThickLayers">
<layer repeat="EcalBarrelLayer3_NRepeat">
<slice material="TungstenDens24" thickness="EcalThickTungstenThickness"/>
<slice material="Air" thickness="EcalAir2Thickness"/>
<slice material="Silicon" thickness="EcalSiliconThickness" sensitive="yes" limits="cal_limits"/>
......@@ -69,30 +71,30 @@
</detector>
<comment>
-----------------------------
Forward Endcap EM Calorimeter
-----------------------------
------------------------------------------
Forward (Positive Z) Endcap EM Calorimeter
------------------------------------------
A layered EM calorimeter with tungsten and silicon (or scintillator) strips
</comment>
<detector id="ECalEndcapP_ID"
name="EcalEndcapP"
reflect="false"
type="DD4hep_PolyhedraEndcapCalorimeter2"
type="refdet_PolyhedraEndcapCalorimeter2"
readout="EcalEndcapHits"
vis="EcalEndcapVis"
calorimeterType="EM_ENDCAP" >
<dimensions
numsides="CaloSides"
zmin="EcalEndcap_zmin"
zmin="EcalEndcapP_zmin"
rmin="EcalEndcapP_rmin"
rmax="EcalBarrel_rmax " />
<layer repeat="1">
<layer repeat="EcalEndcapPLayer1_NRepeat">
<slice material="Silicon" thickness="EcalSiliconThickness" sensitive="yes" limits="cal_limits"/>
<slice material="Copper" thickness="EcalCopperThickness"/>
<slice material="Kapton" thickness="EcalKaptonThickness"/>
<slice material="Air" thickness="EcalAir1Thickness"/>
</layer>
<layer repeat="EcalEndcapThinLayers">
<layer repeat="EcalEndcapPLayer2_NRepeat">
<slice material="TungstenDens24" thickness="EcalThinTungstenThickness"/>
<slice material="Air" thickness="EcalAir2Thickness"/>
<slice material="Silicon" thickness="EcalSiliconThickness" sensitive="yes" limits="cal_limits"/>
......@@ -100,7 +102,7 @@
<slice material="Kapton" thickness="EcalKaptonThickness"/>
<slice material="Air" thickness="EcalAir1Thickness"/>
</layer>
<layer repeat="EcalEndcapThickLayers">
<layer repeat="EcalEndcapPLayer3_NRepeat">
<slice material="TungstenDens24" thickness="EcalThickTungstenThickness"/>
<slice material="Air" thickness="EcalAir2Thickness"/>
<slice material="Silicon" thickness="EcalSiliconThickness" sensitive="yes" limits="cal_limits"/>
......@@ -110,7 +112,6 @@
</layer>
</detector>
<comment>
-------------------------------
Backwards Endcap EM Calorimeter
......@@ -126,16 +127,16 @@
calorimeterType="EM_ENDCAP">
<dimensions
numsides="CaloSides"
zmin="EcalEndcap_zmin"
zmin="EcalEndcapN_zmin"
rmin="EcalEndcapN_rmin"
rmax="EcalBarrel_rmax " />
<layer repeat="1">
<layer repeat="EcalEndcapPLayer1_NRepeat">
<slice material="Silicon" thickness="EcalSiliconThickness" sensitive="yes" limits="cal_limits"/>
<slice material="Copper" thickness="EcalCopperThickness"/>
<slice material="Kapton" thickness="EcalKaptonThickness"/>
<slice material="Air" thickness="EcalAir1Thickness"/>
</layer>
<layer repeat="EcalEndcapThinLayers">
<layer repeat="EcalEndcapPLayer2_NRepeat">
<slice material="TungstenDens24" thickness="EcalThinTungstenThickness"/>
<slice material="Air" thickness="EcalAir2Thickness"/>
<slice material="Silicon" thickness="EcalSiliconThickness" sensitive="yes" limits="cal_limits"/>
......@@ -143,7 +144,7 @@
<slice material="Kapton" thickness="EcalKaptonThickness"/>
<slice material="Air" thickness="EcalAir1Thickness"/>
</layer>
<layer repeat="EcalEndcapThickLayers">
<layer repeat="EcalEndcapPLayer3_NRepeat">
<slice material="TungstenDens24" thickness="EcalThickTungstenThickness"/>
<slice material="Air" thickness="EcalAir2Thickness"/>
<slice material="Silicon" thickness="EcalSiliconThickness" sensitive="yes" limits="cal_limits"/>
......@@ -179,6 +180,4 @@
<plugins>
</plugins>
<fields>
</fields>
</lccdd>
......@@ -5,19 +5,44 @@
<detectors>
<detector id="ForwardRICH_ID" name="ForwardRICH" type="refdet_ForwardRICH" readout="ForwardRICHHits" vis="BlueVis">
<dimensions z0="RICHZMin" length="RICHDepth+20*cm" rmin="RICHRMin" rmax1="RICHRMax*cm" rmax2="RICHRMin+80*cm"/>
<dimensions
z0="RICHZMin"
snout_length="RICHLength - RICHDepth"
length="RICHLength"
rmin="RICHRMin"
rmax0="RICH_rmax0"
rmax1="RICH_rmax1"
rmax2="RICH_rmax2"/>
<radiator material="N2cherenkov" />
<mcppmt zdiff="15.0*cm" rmin="SolenoidYokeEndcapP_rmin - 10*cm" rmax="SolenoidYokeEndcapP_rmin + 80*cm" rtol="1.0*cm" vis="BlueVis"
module_size="10*cm" module_gap="0.2*cm" thickness="1.0*cm" material="Quartz" />
<tank zdiff="5.0*cm" length="RICHDepth" gas="N2cherenkov" vis="GreenVis"
rmin="RICHRMin" rmax1="RICHRMin+40*cm" rmax2="RICHRMin+80*cm" />
<mirror zdiff="RICHDepth+7.0*cm" thickness="1*mm" material="PyrexGlass" vis="GrayVis">
<slice focus="10*cm" curve="300*cm" rmin="RICHRMin" rmax="RICHRMin+80*cm" phiw="59*degree" rotz="0*degree" />
<slice focus="10*cm" curve="300*cm" rmin="RICHRMin" rmax="RICHRMin+80*cm" phiw="59*degree" rotz="60*degree" />
<slice focus="10*cm" curve="300*cm" rmin="RICHRMin" rmax="RICHRMin+80*cm" phiw="59*degree" rotz="120*degree" />
<slice focus="10*cm" curve="300*cm" rmin="RICHRMin" rmax="RICHRMin+80*cm" phiw="59*degree" rotz="180*degree" />
<slice focus="10*cm" curve="300*cm" rmin="RICHRMin" rmax="RICHRMin+80*cm" phiw="59*degree" rotz="240*degree" />
<slice focus="10*cm" curve="300*cm" rmin="RICHRMin" rmax="RICHRMin+80*cm" phiw="59*degree" rotz="300*degree" />
<tank
length="RICHDepth"
gas="N2cherenkov"
vis="GreenVis"
rmin="RICHRMin"
rmax1="RICH_rmax1"
rmax2="RICH_rmax2" />
<comment> What are the following MCP-PMT parameters?</comment>
<mcppmt
z0="-20.0*cm"
rmin="RICH_rmax1"
rmax="RICH_rmax2"
rtol="1.0*cm"
vis="BlueVis"
module_size="10*cm"
module_gap="0.2*cm"
thickness="1.0*cm"
material="Quartz" />
<mirror
z0="RICHLength - 40*cm"
thickness="1*mm"
material="PyrexGlass"
vis="GrayVis">
<slice focus="10*cm" curve="300*cm" rmin="RICHRMin" rmax="RICH_rmax1" phiw="59*degree" rotz="0*degree" />
<slice focus="10*cm" curve="300*cm" rmin="RICHRMin" rmax="RICH_rmax1" phiw="59*degree" rotz="60*degree" />
<slice focus="10*cm" curve="300*cm" rmin="RICHRMin" rmax="RICH_rmax1" phiw="59*degree" rotz="120*degree" />
<slice focus="10*cm" curve="300*cm" rmin="RICHRMin" rmax="RICH_rmax1" phiw="59*degree" rotz="180*degree" />
<slice focus="10*cm" curve="300*cm" rmin="RICHRMin" rmax="RICH_rmax1" phiw="59*degree" rotz="240*degree" />
<slice focus="10*cm" curve="300*cm" rmin="RICHRMin" rmax="RICH_rmax1" phiw="59*degree" rotz="300*degree" />
</mirror>
</detector>
</detectors>
......
<!-- Define parameter -->
<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"/>
</define>
......@@ -79,7 +79,7 @@
inner_z="SolenoidBarrel_zmax + SolenoidEndPlateGapThickness"
inner_r="SolenoidYokeEndcapP_rmin"
outer_r="SolenoidBarrel_rmax">
<slice material="Steel235" thickness="SolenoidYokeEndcapThickness/2.0" vis="SolenoidYokeVis" />
<slice material="Steel235" thickness="SolenoidYokeEndcap_thickness/2.0" vis="SolenoidYokeVis" />
</layer>
</detector>
<!--
......
......@@ -13,9 +13,9 @@
<define>
<include ref="compact/definitions.xml" />
<include ref="eic/eic_defs.xml" />
<include ref="ip6/ip6_defs.xml" />
<!--
<include ref="eic/eic_defs.xml" />
-->
</define>
......@@ -114,21 +114,20 @@
<include ref="reference_detector/vertex_tracker.xml"/>
<include ref="compact/silicon_tracker.xml"/>
-->
<include ref="compact/cb_CTD_Si.xml"/>
<include ref="ip6/beampipe.xml"/>
<include ref="compact/ffi_ZDC.xml"/>
<include ref="compact/solenoid.xml"/>
<include ref="compact/ecal.xml"/>
<include ref="compact/hcal.xml"/>
<include ref="compact/forward_rich.xml"/>
<include ref="compact/cb_CTD_Si.xml"/>
<include ref="compact/ce_mrich.xml"/>
<include ref="compact/ce_GEM.xml"/>
<include ref="compact/ffi_ZDC.xml"/>
<!--
<include ref="compact/forward_rich.xml"/>
<include ref="compact/hcal.xml"/>
<include ref="compact/roman_pots.xml"/>
-->
<include ref="eic/forward_ion_beamline.xml"/>
<!--
-->
<detectors>
</detectors>
......
......@@ -47,6 +47,7 @@ set -- "${POSITIONAL[@]}" # restore positional parameters
# Side view
dawncut 1 0 0 1 ${INPUT_FILE} ${FILE_TAG}_temp0.prim
dawncut -1 0 0 1 ${FILE_TAG}_temp0.prim ${FILE_TAG}.prim
../../bin/dawn_tweak --mag 10
dawn -d ${FILE_TAG}.prim
ps2pdf ${FILE_TAG}.eps ${FILE_TAG}_full.pdf
gs -o ${FILE_TAG}.pdf -sDEVICE=pdfwrite \
......@@ -59,7 +60,7 @@ pdftoppm ${FILE_TAG}.pdf ${FILE_TAG} -png -singlefile -cropbox
# Top view
dawncut 0 1 0 1 ${INPUT_FILE} ${FILE_TAG}_temp0.prim
dawncut 0 -1 0 1 ${FILE_TAG}_temp0.prim ${FILE_TAG}.prim
../../bin/dawn_tweak --theta 270
../../bin/dawn_tweak --theta 270 --mag 20
dawn -d ${FILE_TAG}.prim
ps2pdf ${FILE_TAG}.eps ${FILE_TAG}_top_full.pdf
gs -o ${FILE_TAG}_top.pdf -sDEVICE=pdfwrite \
......
//==========================================================================
// AIDA Detector description implementation
//--------------------------------------------------------------------------
// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
// All rights reserved.
//
// For the licensing terms see $DD4hepINSTALL/LICENSE.
// For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
//
// Author : M.Frank
//
//==========================================================================
//
// Specialized generic detector constructor
//
//==========================================================================
#include "DD4hep/DetFactoryHelper.h"
#include "XML/Layering.h"
using namespace std;
using namespace dd4hep;
using namespace dd4hep::detail;
static Ref_t create_detector(Detector& description, xml_h e, SensitiveDetector sens) {
static double tolerance = 0e0;
Layering layering (e);
xml_det_t x_det = e;
Material air = description.air();
int det_id = x_det.id();
string det_name = x_det.nameStr();
xml_comp_t x_staves = x_det.staves();
xml_comp_t x_dim = x_det.dimensions();
int nsides = x_dim.numsides();
double inner_r = x_dim.rmin();
double dphi = (2*M_PI/nsides);
double hphi = dphi/2;
double mod_z = layering.totalThickness();
double outer_r = inner_r + mod_z;
double totThick = mod_z;
double offset = x_det.attr<double>(_Unicode(offset));
DetElement sdet (det_name,det_id);
Volume motherVol = description.pickMotherVolume(sdet);
PolyhedraRegular hedra (nsides,inner_r,inner_r+totThick+tolerance*2e0,x_dim.z());
Volume envelope (det_name,hedra,air);
PlacedVolume env_phv = motherVol.placeVolume(envelope,Transform3D(Translation3D(0,0,offset)*RotationZ(M_PI/nsides)));
env_phv.addPhysVolID("system",det_id);
env_phv.addPhysVolID("barrel",0);
sdet.setPlacement(env_phv);
DetElement stave_det("stave0",det_id);
double dx = 0.0; //mod_z / std::sin(dphi); // dx per layer
// Compute the top and bottom face measurements.
double trd_x2 = (2 * std::tan(hphi) * outer_r - dx)/2 - tolerance;
double trd_x1 = (2 * std::tan(hphi) * inner_r + dx)/2 - tolerance;
double trd_y1 = x_dim.z()/2 - tolerance;
double trd_y2 = trd_y1;
double trd_z = mod_z/2 - tolerance;
// Create the trapezoid for the stave.
Trapezoid trd(trd_x1, // Outer side, i.e. the "short" X side.
trd_x2, // Inner side, i.e. the "long" X side.
trd_y1, // Corresponds to subdetector (or module) Z.
trd_y2, //
trd_z); // Thickness, in Y for top stave, when rotated.
Volume mod_vol("stave",trd,air);
sens.setType("calorimeter");
{ // ===== buildBarrelStave(description, sens, module_volume) =====
// Parameters for computing the layer X dimension:
double stave_z = trd_y1;
double tan_hphi = std::tan(hphi);
double l_dim_x = trd_x1; // Starting X dimension for the layer.
double l_pos_z = -(layering.totalThickness() / 2);
// Loop over the sets of layer elements in the detector.
int l_num = 1;
for(xml_coll_t li(x_det,_U(layer)); li; ++li) {
xml_comp_t x_layer = li;
int repeat = x_layer.repeat();
// Loop over number of repeats for this layer.
for (int j=0; j<repeat; j++) {
string l_name = _toString(l_num,"layer%d");
double l_thickness = layering.layer(l_num-1)->thickness(); // Layer's thickness.
Position l_pos(0,0,l_pos_z+l_thickness/2); // Position of the layer.
Box l_box(l_dim_x-tolerance,stave_z-tolerance,l_thickness / 2-tolerance);
Volume l_vol(l_name,l_box,air);
DetElement layer(stave_det, l_name, det_id);
// Loop over the sublayers or slices for this layer.
int s_num = 1;
double s_pos_z = -(l_thickness / 2);
for(xml_coll_t si(x_layer,_U(slice)); si; ++si) {
xml_comp_t x_slice = si;
string s_name = _toString(s_num,"slice%d");
double s_thick = x_slice.thickness();
Box s_box(l_dim_x-tolerance,stave_z-tolerance,s_thick / 2-tolerance);
Volume s_vol(s_name,s_box,description.material(x_slice.materialStr()));
DetElement slice(layer,s_name,det_id);
if ( x_slice.isSensitive() ) {
s_vol.setSensitiveDetector(sens);
}
slice.setAttributes(description,s_vol,x_slice.regionStr(),x_slice.limitsStr(),x_slice.visStr());
// Slice placement.
PlacedVolume slice_phv = l_vol.placeVolume(s_vol,Position(0,0,s_pos_z+s_thick/2));
slice_phv.addPhysVolID("slice", s_num);
slice.setPlacement(slice_phv);
// Increment Z position of slice.
s_pos_z += s_thick;
// Increment slice number.
++s_num;
}
// Set region, limitset, and vis of layer.
layer.setAttributes(description,l_vol,x_layer.regionStr(),x_layer.limitsStr(),x_layer.visStr());
PlacedVolume layer_phv = mod_vol.placeVolume(l_vol,l_pos);
layer_phv.addPhysVolID("layer", l_num);
layer.setPlacement(layer_phv);
// Increment to next layer Z position.
double xcut = l_thickness * tan_hphi;
l_dim_x += xcut;
l_pos_z += l_thickness;
++l_num;
}
}
}
// Set stave visualization.
if ( x_staves ) {
mod_vol.setVisAttributes(description.visAttributes(x_staves.visStr()));
}
// Phi start for a stave.
double phi = M_PI / nsides;
double mod_x_off = dx / 2; // Stave X offset, derived from the dx.
double mod_y_off = inner_r + mod_z/2; // Stave Y offset
// Create nsides staves.
for (int i = 0; i < nsides; i++, phi -= dphi) { // i is module number
// Compute the stave position
double m_pos_x = mod_x_off * std::cos(phi) - mod_y_off * std::sin(phi);
double m_pos_y = mod_x_off * std::sin(phi) + mod_y_off * std::cos(phi);
Transform3D tr(RotationZYX(0,phi,M_PI*0.5),Translation3D(-m_pos_x,-m_pos_y,0));
PlacedVolume pv = envelope.placeVolume(mod_vol,tr);
pv.addPhysVolID("system",det_id);
pv.addPhysVolID("barrel",0);
pv.addPhysVolID("module",i+1);
DetElement sd = i==0 ? stave_det : stave_det.clone(_toString(i,"stave%d"));
sd.setPlacement(pv);
sdet.add(sd);
}
// Set envelope volume attributes.
envelope.setAttributes(description,x_det.regionStr(),x_det.limitsStr(),x_det.visStr());
return sdet;
}
DECLARE_DETELEMENT(refdet_EcalBarrel,create_detector)
......@@ -36,17 +36,20 @@ static Ref_t createDetector(Detector& desc, xml::Handle_t handle, SensitiveDetec
xml::Component rads = detElem.child(_Unicode(radiator));
xml::Component mir = detElem.child(_Unicode(mirror));
xml::Component mcp = detElem.child(_Unicode(mcppmt));
xml::Component tank = detElem.child(_Unicode(tank));
// dimensions
double z0 = dims.z0();
double length = dims.length();
double rmin = dims.rmin();
double rmax0 = dims.attr<double>(_Unicode(rmax0));
double rmax1 = dims.attr<double>(_Unicode(rmax1));
double rmax2 = dims.attr<double>(_Unicode(rmax2));
double snout_length = dims.attr<double>(_Unicode(snout_length));
// mirror setting
auto mThick = mir.thickness();
auto mirZ = mir.attr<double>(_Unicode(zdiff));
auto mirZ = mir.attr<double>(_Unicode(z0));
// mcppmt setting
auto pRmin = mcp.rmin();
......@@ -55,27 +58,32 @@ static Ref_t createDetector(Detector& desc, xml::Handle_t handle, SensitiveDetec
auto pSize = mcp.attr<double>(_Unicode(module_size));
auto pGap = mcp.attr<double>(_Unicode(module_gap));
auto pTol = mcp.attr<double>(_Unicode(rtol));
auto pZ = mcp.attr<double>(_Unicode(zdiff));
auto pZ = mcp.attr<double>(_Unicode(z0));
// tank parameters
double tank_length = length - snout_length;
// materials
auto mirMat = desc.material(mir.materialStr());
auto gasMat = desc.material(rads.materialStr());
auto mcpMat = desc.material(mcp.materialStr());
double front_offset = snout_length+tank_length/2.0;
// constants
auto richCenterAngle = std::atan((rmin + (rmax2 - rmin)/2.)/mirZ);
auto richCenterAngle = std::atan((rmin + (rmax1 - rmin)/2.)/(front_offset+mirZ));
//std::cout << richCenterAngle*180./M_PI << std::endl;
// an envelope for the detector
// use a complicated shape to avoid conflict with the other parts
// cone for radiator and the first set of mirrors
double halfLength = length/2.;
Cone env1(halfLength, rmin, rmax1, rmin, rmax2);
Cone env1(snout_length/2.0, rmin, rmax0, rmin, rmax1);
// envelope for detection plane
// Cone env2(halfLength - pZ/2., rmin, pRmax, rmin, rmax2);
Tube env2(rmin, pRmax + pTol + pGap + 1.0*cm, (length - pZ)/2., 0., 2*M_PI);
Tube env2(rmin, pRmax + pTol + pGap + 1.0*cm, tank_length/2., 0., 2*M_PI);
UnionSolid envShape(env1, env2, Position(0., 0., pZ));
UnionSolid envShape(env2, env1, Position(0., 0., -tank_length/2.-snout_length/2));
Volume envVol(detName + "_envelope", envShape, gasMat);
envVol.setVisAttributes(desc.visAttributes(detElem.visStr()));
......@@ -112,7 +120,7 @@ static Ref_t createDetector(Detector& desc, xml::Handle_t handle, SensitiveDetec
double rotY = -std::asin(focus/curve);
mirVol.setSolid(Sphere(curve, curve + mThick, mTheta1, mTheta2, 0., wphi));
// action is in a reverse order
Transform3D tr = Translation3D(0., 0., mirZ - halfLength) // move for z position
Transform3D tr = Translation3D(0., 0., mirZ - front_offset) // move for z position
* RotationZ(rotZ) // rotate phi angle
* RotationY(rotY) // rotate for focus point
* RotationX(180*degree)
......@@ -122,7 +130,7 @@ static Ref_t createDetector(Detector& desc, xml::Handle_t handle, SensitiveDetec
// plane mirror
} else {
mirVol.setSolid(Tube(mRmin, mRmax, mThick/2.0, 0., wphi));
Transform3D tr = Translation3D(0., 0., mirZ - halfLength) // move for z position
Transform3D tr = Translation3D(0., 0., mirZ - front_offset) // move for z position
* RotationZ(rotZ) // rotate phi angle
* RotationZ(-wphi/2.); // center phi angle to 0. (-wphi/2., wphi/2.)
mirPV = envVol.placeVolume(mirVol, tr);
......@@ -152,11 +160,11 @@ static Ref_t createDetector(Detector& desc, xml::Handle_t handle, SensitiveDetec
// photo-detector plane envelope
for (size_t ipd = 0; ipd < 6; ++ipd) {
double phmin = -M_PI/6.;
double phmax = M_PI/6.;
double phmin = -M_PI/6.5; // added 0.5 to make it smaller
double phmax = M_PI/6.5;
Tube pdEnvShape(pRmin - pTol - pGap, pRmax + pTol + pGap, pThick/2.0 + 0.1*cm, phmin, phmax);
Volume pdVol("pd_envelope", pdEnvShape, desc.material("AirOptical"));
auto points = ref::utils::fillSquares({0., 0.}, pSize + pGap, pRmin - pTol - pGap, pRmax + pTol + pGap, phmin, phmax);
auto points = ref::utils::fillSquares({0., 0.}, pSize + pGap, pRmin + pTol + pGap, pRmax + pTol + pGap, phmin, phmax);
for (size_t i = 0; i < points.size(); ++i) {
auto pt = points[i];
auto mcpPV = pdVol.placeVolume(mcpVol, Position(pt.x(), pt.y(), 0.));
......@@ -164,7 +172,7 @@ static Ref_t createDetector(Detector& desc, xml::Handle_t handle, SensitiveDetec
DetElement mcpDE(det, Form("MCPPMT_DE%d_%d", ipd + 1, i + 1), i + 1);
mcpDE.setPlacement(mcpPV);
}
Transform3D tr = Translation3D(0., 0., -halfLength + pZ + pThick/2.0) // move for z position
Transform3D tr = Translation3D(0., 0., -front_offset + pZ + pThick/2.0) // move for z position
* RotationZ(ipd*M_PI/3.) // rotate phi angle
* RotationY(-richCenterAngle); // rotate to perpendicular position
auto pdPV = envVol.placeVolume(pdVol, tr);
......
</
......@@ -37,6 +37,11 @@ static Ref_t create_detector(Detector& description, xml_h e, SensitiveDetector s
Volume endcapVol("endcap", PolyhedraRegular(numsides, rmin, rmax, totalThickness), air);
DetElement endcap("endcap", det_id);
std::cout << "totalThickness = " << totalThickness << "\n";
std::cout << "zmin = " << zmin << "\n";
std::cout << "rmin = " << rmin << "\n";
std::cout << "rmax = " << rmax << "\n";
std::cout << "nlayers = " << std::size(layering.layers()) << "\n";
int l_num = 1;
int layerType = 0;
double layerZ = -totalThickness / 2;
......@@ -44,55 +49,59 @@ static Ref_t create_detector(Detector& description, xml_h e, SensitiveDetector s
endcapVol.setAttributes(description, x_det.regionStr(), x_det.limitsStr(), x_det.visStr());
for (xml_coll_t xc(x_det, _U(layer)); xc; ++xc) {
xml_comp_t x_layer = xc;
double l_thick = layering.layer(l_num - 1)->thickness();
string l_name = _toString(layerType, "layer%d");
int l_repeat = x_layer.repeat();
Volume l_vol(l_name, PolyhedraRegular(numsides, rmin, rmax, l_thick), air);
vector<PlacedVolume> sensitives;
std::cout << "l_num = " << l_num << "\n";
std::cout << "xc = " << xc << "\n";
xml_comp_t x_layer = xc;
double l_thick = layering.layer(l_num - 1)->thickness();
std::cout << "xc = " << xc << "\n";
string l_name = _toString(layerType, "layer%d");
int l_repeat = x_layer.repeat();
Volume l_vol(l_name, PolyhedraRegular(numsides, rmin, rmax, l_thick), air);