diff --git a/compact/definitions.xml b/compact/definitions.xml index d8dac0d6ad99793791c0f5cd0b34c20371ad463d..ab5d0b01319a708d8c1050cb87605e94fca26b73 100644 --- a/compact/definitions.xml +++ b/compact/definitions.xml @@ -284,7 +284,9 @@ <constant name="ForwardRomanPotC_ID" value="157"/> <constant name="ForwardOffMTracker_ID" value="159"/> + <constant name="ffi_ZDC_ID" value="160"/> + <constant name="ffi_ZDC_HCAL_ID" value="161"/> <comment> ===================================== @@ -654,7 +656,7 @@ <comment> Global parameters </comment> <constant name="ffi_ZDC_width" value="60.0 * cm"/> - <constant name="ffi_ZDC_thickness" value="200.0 * cm"/> + <constant name="ffi_ZDC_thickness" value="61.0 * cm"/><comment> Changed from 200.0 cm </comment> <comment> Original Global parameters </comment> <!-- <constant name="ffi_ZDC_thickness" value="250.0 * cm"/> @@ -670,6 +672,21 @@ <constant name="ffi_ZDC_ECAL_ntower" value="20"/> --> + <comment> ZDC HCAL parameters </comment> + <constant name="ffi_ZDC_HCAL_CrossingAngle" value="0.020*rad"/> + <constant name="ffi_ZDC_HCAL_tracker_region_zmax" value="5*m"/> + <constant name="ffi_ZDC_HCAL_tracker_region_rmax" value="5*m"/> + + <constant name="ffi_ZDC_HCAL_offset" value="5.0*mm"/> + <constant name="ffi_ZDC_HCAL_st_length" value="20.0*mm"/> + <constant name="ffi_ZDC_HCAL_lt_length" value="ffi_ZDC_width"/><comment> Changed from 40.0mm </comment> + <constant name="ffi_ZDC_HCAL_st_x_pos" value="0.60*m"/> + <constant name="ffi_ZDC_HCAL_st_y_pos" value="0.0*m"/> + <constant name="ffi_ZDC_HCAL_st_z_pos" value="ffi_ZDC_z_pos + ffi_ZDC_ECAL_thickness + 1*cm"/> <comment> Was 34 m, changed to be placed right after ZDC(The ecal) </comment> + <constant name="ffi_ZDC_HCAL_lt_x_pos" value="ffi_ZDC_x_pos"/> + <constant name="ffi_ZDC_HCAL_lt_y_pos" value="ffi_ZDC_y_pos"/> + <constant name="ffi_ZDC_HCAL_lt_z_pos" value="ffi_ZDC_z_pos + ffi_ZDC_ECAL_thickness + 1*cm"/> <comment> Was 34 m, changed to be placed right after ZDC(The ecal) </comment> + <comment> ----------------------- Gaseous RICH Parameters diff --git a/compact/ffi_ZDC_HCAL.xml b/compact/ffi_ZDC_HCAL.xml new file mode 100644 index 0000000000000000000000000000000000000000..682dbd7a988b155876fcc9fa078c6924cbd2ba21 --- /dev/null +++ b/compact/ffi_ZDC_HCAL.xml @@ -0,0 +1,93 @@ +<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="ZDC" title="Zero Degree Calorimeter" + author="Marshall Scott" + url="https://eicweb.phy.anl.gov/EIC/detectors/reference_detector.git" + status="development" + version="v1 2021-04-20"> + <comment>Zero Degree Calorimeter detector</comment> + <comment>Copied from https://eicweb.phy.anl.gov/EIC/NPDet/-/blob/master/src/detectors/calorimeters/compact/ZDC_example.xml</comment> + </info> + + <!-- Use DD4hep elements and materials definitions --> + <includes> + </includes> + + <define> + </define> + + <limits> + </limits> + + <regions> + </regions> + + <display> + </display> + + <!-- Define detector --> + <detectors> + <detector id="ffi_ZDC_HCAL_ID" name="largeZDC" type="ffi_ZDC_HCAL" readout="ZDCHits" vis="RedVis"> + <position x="ffi_ZDC_HCAL_lt_x_pos" y="ffi_ZDC_HCAL_lt_y_pos" z="ffi_ZDC_HCAL_lt_z_pos"/> + <dimensions x = "ffi_ZDC_HCAL_lt_length" y = "ffi_ZDC_HCAL_lt_length"/> + <layer repeat="2"> + <slice name="Tungsten_slice" material="TungstenDens24" thickness="7*mm" vis = "GrayVis"/> + <slice name="Scint_slice" material="PlasticScint" thickness="3*mm" vis = "BlueVis" sensitive = "true"/> + </layer> + <layer repeat="1"> + <slice name="Tungsten_slice" material="TungstenDens24" thickness="7*mm" vis = "GrayVis"/> + <slice name="SciFi_belt" material="PlasticScint" thickness="1*mm" vis = "RedVis" sensitive = "true"/> + <slice name="SciFi_belt" material="PlasticScint" thickness="1*mm" vis = "RedVis" sensitive = "true"/> + </layer> + <layer repeat="2"> + <slice name="Scint_slice" material="PlasticScint" thickness="3*mm" vis = "BlueVis" sensitive = "true"/> + <slice name="Tungsten_slice" material="TungstenDens24" thickness="7*mm" vis = "GrayVis"/> + </layer> + <layer repeat="2"> + <slice name="SciFi_belt" material="PlasticScint" thickness="1*mm" vis = "RedVis" sensitive = "true"/> + </layer> + <layer repeat="7"> + <slice name="Scint_slice" material="PlasticScint" thickness="3*mm" vis = "BlueVis" sensitive = "true"/> + <slice name="Tungsten_slice" material="TungstenDens24" thickness="7*mm" vis = "GrayVis"/> + </layer> + <layer repeat="1"> + <slice name="Tungsten_slice" material="TungstenDens24" thickness="7*mm" vis = "GrayVis"/> + <slice name="Scint_slice" material="PlasticScint" thickness="3*mm" vis = "BlueVis" sensitive = "true"/> + <slice name="Tungsten_slice" material="TungstenDens24" thickness="7*mm" vis = "GrayVis"/> + <slice name="Tungsten_slice" material="TungstenDens24" thickness="7*mm" vis = "GrayVis"/> + </layer> + <layer repeat="2"> + <slice name="SciFi_belt" material="PlasticScint" thickness="1*mm" vis = "RedVis" sensitive = "true"/> + </layer> + <layer repeat="3"> + <slice name="Scint_slice" material="PlasticScint" thickness="3*mm" vis = "BlueVis" sensitive = "true"/> + <slice name="Tungsten_slice" material="TungstenDens24" thickness="7*mm" vis = "GrayVis"/> + <slice name="Tungsten_slice" material="TungstenDens24" thickness="7*mm" vis = "GrayVis"/> + </layer> + <layer repeat="2"> + <slice name="SciFi_belt" material="PlasticScint" thickness="1*mm" vis = "RedVis" sensitive = "true"/> + </layer> + <layer repeat="1"> + <slice name="Scint_slice" material="PlasticScint" thickness="3*mm" vis = "BlueVis" sensitive = "true"/> + <slice name="Tungsten_slice" material="TungstenDens24" thickness="7*mm" vis = "GrayVis"/> + </layer> + </detector> + </detectors> + + <!-- Definition of the readout segmentation/definition --> + <readouts> + <readout name="ZDCHits"> + <segmentation type="CartesianGridXY" grid_size_x="1.0*mm" grid_size_y="1.0*mm" /> + <id>system:8,layer:12,slice:12,x:48:-8,y:-8</id> + </readout> + </readouts> + + <plugins> + </plugins> + + <fields> + </fields> +</lccdd> diff --git a/reference_detector.xml b/reference_detector.xml index f1443893f7021c5abdc39c721dc94eef5c77388e..b84e4bf7f9d194f9db07ae3a4abf23d1634e6274 100644 --- a/reference_detector.xml +++ b/reference_detector.xml @@ -131,6 +131,10 @@ <include ref="compact/far_forward_romanpots.xml"/> <include ref="compact/far_forward_detectors.xml"/> + + <include ref="compact/ffi_ZDC_HCAL.xml"/> + + <!-- <include ref="compact/mm_tracker_barrel.xml"/> <include ref="compact/cb_VTX_Barrel.xml"/> diff --git a/src/ffi_ZDC_HCAL.cpp b/src/ffi_ZDC_HCAL.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d4cbf641dd868859b5d37352f259d2be88f57352 --- /dev/null +++ b/src/ffi_ZDC_HCAL.cpp @@ -0,0 +1,97 @@ +#include "DD4hep/DetFactoryHelper.h" +#include "DD4hep/Printout.h" +#include <XML/Helper.h> +#include "TMath.h" +#include "DDRec/Surface.h" +#include "DDRec/DetectorData.h" +#include "XML/Layering.h" +#include "Math/Transform3D.h" + +/////////////////////////// +// Zero Degree Hadron Calorimeter +/////////////////////////// + +using namespace std; +using namespace dd4hep; +using namespace dd4hep::rec; +using namespace dd4hep::detail; + + +static Ref_t createDetector(Detector& lcdd, xml_h e, SensitiveDetector sens) { + xml_det_t x_det = e; + int det_id = x_det.id(); + string det_name = x_det.nameStr(); + xml_dim_t pos = x_det.position(); + double x_pos = dd4hep::getAttrOrDefault(pos, _Unicode(x),0.0); + double y_pos = dd4hep::getAttrOrDefault(pos, _Unicode(y),0.0); + double z_pos = dd4hep::getAttrOrDefault(pos, _Unicode(z),0.0); + xml_dim_t dim = x_det.dimensions(); + double pixel_x = dim.x(); + double pixel_y = dim.y(); + Material air = lcdd.material("Air"); + double z = z_pos; + double zmin = z_pos; + DetElement det(det_name, det_id); + + int layer_num = 1; + int slice_num = 1; + double totWidth = Layering(x_det).totalThickness(); + Box envelope (pixel_x/2.0, pixel_y/2.0, totWidth/2.0); + Volume envelopeVol(det_name+"_envelope", envelope, air); + PlacedVolume pv; + + xml_comp_t x_layer = x_det.child(_U(layer)); + + // Read layers + for(xml_coll_t c(x_det,_U(layer)); c; ++c) + { + xml_comp_t x_layer = c; + int repeat = x_layer.repeat(); + double layerWidth = 0; + for(xml_coll_t l(x_layer,_U(slice)); l; ++l) + layerWidth += xml_comp_t(l).thickness(); + + // Loop over repeat# + for(int i=0; i< repeat; i++) + { + double zlayer = z; + string layer_name = det_name + _toString(layer_num,"_layer%d"); + Volume layer_vol(layer_name,Box(pixel_x/2.0, pixel_y/2.0,layerWidth/2.0),air); + + // Loop over slices + for(xml_coll_t l(x_layer,_U(slice)); l; ++l) + { + xml_comp_t x_slice = l; + double w = x_slice.thickness(); + string slice_name = layer_name + _toString(slice_num,"slice%d"); + Material slice_mat = lcdd.material(x_slice.materialStr()); + Volume slice_vol (slice_name,Box(pixel_x/2.0, pixel_y/2.0,w/2.0),slice_mat); + if(x_slice.isSensitive()) + { + sens.setType("calorimeter"); + slice_vol.setSensitiveDetector(sens); + } + slice_vol.setAttributes(lcdd,x_slice.regionStr(), x_slice.limitsStr(), x_slice.visStr()); + pv = layer_vol.placeVolume(slice_vol, Transform3D(RotationZYX(0, 0, 0),Position(0.0,0.0,z-zlayer-layerWidth/2.0+w/2.0))); + pv.addPhysVolID("slice", slice_num); + z += w; + ++slice_num; + } + string layer_vis = dd4hep::getAttrOrDefault(x_layer, _Unicode(vis), "InvisibleWithDaughters"); + layer_vol.setAttributes(lcdd, x_layer.regionStr(), x_layer.limitsStr(), layer_vis); + pv = envelopeVol.placeVolume(layer_vol, Transform3D(RotationZYX(0, 0, 0), Position(0,0,zlayer-zmin-totWidth/2.0+layerWidth/2.0))); + pv.addPhysVolID("layer", layer_num); + ++layer_num; + } + } + envelopeVol.setAttributes(lcdd, x_det.regionStr(), x_det.limitsStr(), "InvisibleWithDaughters"); + + Volume motherVol = lcdd.pickMotherVolume(det); + PlacedVolume phv = motherVol.placeVolume(envelopeVol, Position(x_pos,y_pos,z_pos+totWidth/2.0)); + phv.addPhysVolID("system", det.id()); + det.setPlacement(phv); + + return det; +} + +DECLARE_DETELEMENT(ffi_ZDC_HCAL, createDetector)