Commit f582f1dc authored by Whitney Armstrong's avatar Whitney Armstrong
Browse files

Merge branch '3-translate-cb_emcal' into 'master'

Resolve "Translate cb_EMCAL"

Closes #3

See merge request !7
parents 57733b96 a5c379bf
Pipeline #7563 failed with stages
in 2 minutes and 38 seconds
<lccdd>
<define>
<constant name="CrystalEndcap_rmin" value="VertexTrackerInnerRadius"/>
<constant name="CrystalEndcap_rmax" value="EcalEndcapN_rmin"/>
<constant name="CrystalBox_x_length" value="20.0*mm"/>
<constant name="CrystalBox_y_length" value="20.0*mm"/>
<constant name="CrystalBox_z_length" value="200.0*mm"/>
<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"/>
</define>
<limits>
</limits>
<regions>
</regions>
<!-- Common Generic visualization attributes -->
<comment>Common Generic visualization attributes</comment>
<display>
</display>
<detectors>
<comment>
---------------------
Barrel EM Calorimeter
---------------------
A layered EM calorimeter with tungsten and silicon (or scintillator) strips
</comment>
<detector
id="ECalBarrel_ID"
name="EcalBarrel"
type="DD4hep_EcalBarrel"
readout="EcalBarrelHits"
calorimeterType="EM_BARREL">
<dimensions
numsides="CaloSides"
rmin="EcalBarrel_rmin"
z="EcalBarrelLength"/>
<staves vis="EcalBarrelVis"/>
<layer repeat="1">
<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">
<slice material="TungstenDens24" thickness="EcalThinTungstenThickness"/>
<slice material="Air" thickness="EcalAir2Thickness"/>
<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="EcalBarrelThickLayers">
<slice material="TungstenDens24" thickness="EcalThickTungstenThickness"/>
<slice material="Air" thickness="EcalAir2Thickness"/>
<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>
</detector>
<comment>
-----------------------------
Forward 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"
readout="EcalEndcapHits"
vis="EcalEndcapVis"
calorimeterType="EM_ENDCAP" >
<dimensions
numsides="CaloSides"
zmin="EcalEndcap_zmin"
rmin="EcalEndcapP_rmin"
rmax="EcalBarrel_rmax " />
<layer repeat="1">
<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">
<slice material="TungstenDens24" thickness="EcalThinTungstenThickness"/>
<slice material="Air" thickness="EcalAir2Thickness"/>
<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="EcalEndcapThickLayers">
<slice material="TungstenDens24" thickness="EcalThickTungstenThickness"/>
<slice material="Air" thickness="EcalAir2Thickness"/>
<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>
</detector>
<comment>
-------------------------------
Backwards Endcap EM Calorimeter
-------------------------------
A layered EM calorimeter with tungsten and silicon (or scintillator) strips
</comment>
<detector id="ECalEndcapN_ID"
name="EcalEndcapN"
type="refdet_PolyhedraEndcapCalorimeter2"
reflect="true"
readout="EcalEndcapHits"
vis="EcalEndcapVis"
calorimeterType="EM_ENDCAP">
<dimensions
numsides="CaloSides"
zmin="EcalEndcap_zmin"
rmin="EcalEndcapN_rmin"
rmax="EcalBarrel_rmax " />
<layer repeat="1">
<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">
<slice material="TungstenDens24" thickness="EcalThinTungstenThickness"/>
<slice material="Air" thickness="EcalAir2Thickness"/>
<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="EcalEndcapThickLayers">
<slice material="TungstenDens24" thickness="EcalThickTungstenThickness"/>
<slice material="Air" thickness="EcalAir2Thickness"/>
<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>
</detector>
</detectors>
<!-- Definition of the readout segmentation/definition -->
<readouts>
<!--
<readout name="PlaneTrackerHits">
<segmentation type="CartesianGridXY" grid_size_x="20.0*mm" grid_size_y="20.0*mm" />
<id>system:5,module:4,x:32:-16,y:-16</id>
</readout>
<readout name="CrystalEcalHits">
<segmentation type="CartesianGridXY" grid_size_x="CrystalBox_x_length" grid_size_y="CrystalBox_y_length" />
<id>system:8,sector:4,module:20,x:48:-8,y:-8</id>
</readout>
-->
<readout name="EcalBarrelHits">
<segmentation type="CartesianGridXY" grid_size_x="3.5 * mm" grid_size_y="3.5 * mm"/>
<id>system:8,barrel:3,module:4,layer:6,slice:5,x:32:-16,y:-16</id>
</readout>
<readout name="EcalEndcapHits">
<segmentation type="CartesianGridXY" grid_size_x="3.5 * mm" grid_size_y="3.5 * mm"/>
<id>system:8,barrel:3,module:4,layer:6,slice:5,x:32:-16,y:-16</id>
</readout>
</readouts>
<plugins>
</plugins>
<fields>
</fields>
</lccdd>
......@@ -115,8 +115,8 @@
<include ref="compact/silicon_tracker.xml"/>
-->
<include ref="compact/solenoid.xml"/>
<!--
<include ref="compact/ecal.xml"/>
<!--
<include ref="compact/solenoid.xml"/>
<include ref="compact/hcal.xml"/>
<include ref="compact/reference_detector_rich.xml"/>
......
1.34392e+07
90
180
0
0
0
0
16.4
1
0.001
0
1
1
1
0.5
0.5
0.5
19
71
0.001
0.001
0.001
3
71
0.001
0
0
1
evince
0
0
1.34392e+07
0
180
0
0
0
0
8
3
0.001
0
1
1
1
0.5
0.5
0.5
19
71
0.01
0.01
0.01
3
70
0.01
1
1
1
evince
0
0
1.34392e+07
28.5
151.5
0
0
0
0
8
5
0.001
0
1
1
1
0.5
0.5
0.5
19
71
0.01
0.01
0.01
3
70
0.01
1
1
1
evince
0
0
1.34392e+07
90
0
1
0
0
491.1
1.2
5
0.001
0
1
1
1
0.5
0.5
0.5
19
71
0.01
0.01
0.01
3
70
0.01
1
1
1
evince
0
0
1.34392e+07
0
180
0
0
0
0
18.6
1
0.001
0
1
1
1
0.5
0.5
0.5
19
71
0.01
0.01
0.01
3
70
0.01
1
1
1
evince
0
0
//==========================================================================
// 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
//
//==========================================================================
//
// Modified for TOPSiDE detector
//
//==========================================================================
#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) {
xml_det_t x_det = e;
xml_dim_t dim = x_det.dimensions();
int det_id = x_det.id();
bool reflect = x_det.reflect(true);
string det_name = x_det.nameStr();
Material air = description.air();
int numsides = dim.numsides();
double rmin = dim.rmin();
double rmax = dim.rmax() * std::cos(M_PI / numsides);
double zmin = dim.zmin();
Layering layering(x_det);
double totalThickness = layering.totalThickness();
Volume endcapVol("endcap", PolyhedraRegular(numsides, rmin, rmax, totalThickness), air);
DetElement endcap("endcap", det_id);
int l_num = 1;
int layerType = 0;
double layerZ = -totalThickness / 2;
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;
int s_num = 1;
double sliceZ = -l_thick / 2;
for (xml_coll_t xs(x_layer, _U(slice)); xs; ++xs) {
xml_comp_t x_slice = xs;
string s_name = _toString(s_num, "slice%d");
double s_thick = x_slice.thickness();
Material s_mat = description.material(x_slice.materialStr());
Volume s_vol(s_name, PolyhedraRegular(numsides, rmin, rmax, s_thick), s_mat);
s_vol.setVisAttributes(description.visAttributes(x_slice.visStr()));
sliceZ += s_thick / 2;
PlacedVolume s_phv = l_vol.placeVolume(s_vol, Position(0, 0, sliceZ));
s_phv.addPhysVolID("slice", s_num);
if (x_slice.isSensitive()) {
sens.setType("calorimeter");
s_vol.setSensitiveDetector(sens);
sensitives.push_back(s_phv);
}
sliceZ += s_thick / 2;
s_num++;
}
l_vol.setVisAttributes(description.visAttributes(x_layer.visStr()));
if (l_repeat <= 0) throw std::runtime_error(x_det.nameStr() + "> Invalid repeat value");
for (int j = 0; j < l_repeat; ++j) {
string phys_lay = _toString(l_num, "layer%d");
layerZ += l_thick / 2;
DetElement layer_elt(endcap, phys_lay, l_num);
PlacedVolume pv = endcapVol.placeVolume(l_vol, Position(0, 0, layerZ));
pv.addPhysVolID("layer", l_num);
layer_elt.setPlacement(pv);
for (size_t ic = 0; ic < sensitives.size(); ++ic) {
PlacedVolume sens_pv = sensitives[ic];
DetElement comp_elt(layer_elt, sens_pv.volume().name(), l_num);
comp_elt.setPlacement(sens_pv);
}
layerZ += l_thick / 2;
++l_num;
}
++layerType;
}
double z_pos = zmin + totalThickness / 2;
PlacedVolume pv;
// Reflect it.
Assembly assembly(det_name);
DetElement endcapAssyDE(det_name, det_id);
Volume motherVol = description.pickMotherVolume(endcapAssyDE);
if (reflect) {
pv = assembly.placeVolume(endcapVol,
Transform3D(RotationZYX(M_PI / numsides, M_PI, 0), Position(0, 0, -z_pos)));
pv.addPhysVolID("barrel", 2);
Ref_t(endcap)->SetName((det_name + "_backward").c_str());
endcap.setPlacement(pv);
} else {
pv = assembly.placeVolume(endcapVol,
Transform3D(RotationZYX(M_PI / numsides, 0, 0), Position(0, 0, z_pos)));
pv.addPhysVolID("barrel", 1);
Ref_t(endcap)->SetName((det_name + "_forward").c_str());
endcap.setPlacement(pv);
}
endcapAssyDE.add(endcap);
pv = motherVol.placeVolume(assembly);
pv.addPhysVolID("system", det_id);
endcapAssyDE.setPlacement(pv);
return endcapAssyDE;
}
// clang-format off
DECLARE_DETELEMENT(refdet_PolyhedraEndcapCalorimeter2, create_detector)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment