Skip to content
Snippets Groups Projects
Commit 0784c8a3 authored by guofangyi@ihep.ac.cn's avatar guofangyi@ihep.ac.cn
Browse files

Add CRD Ecal geometry

parent 4fa5b8a6
No related branches found
No related tags found
No related merge requests found
......@@ -2,4 +2,42 @@
# Package: DetCRD
# CEPC Reference Detector (CRD)
################################################################################
gaudi_subdir(DetCRD v0r0)
gaudi_depends_on_subdirs(GaudiKernel)
find_package(DD4hep COMPONENTS DDRec DDG4 DDParsers REQUIRED)
# find_package(DD4hep)
find_package(Geant4)
include(${Geant4_USE_FILE})
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${DD4hep_ROOT}/cmake )
include( DD4hep )
find_package(ROOT COMPONENTS MathCore GenVector Geom REQUIRED)
install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/compact DESTINATION Detector/DetCRD)
set(DetCRD_src
src/Calorimeter/CRDEcal.cpp
)
gaudi_add_module(DetCRD
${DetCRD_src}
INCLUDE_DIRS
# DD4hep
# ROOT
# Geant4
src/include
LINK_LIBRARIES
# GaudiKernel
DD4hep
${DD4hep_COMPONENT_LIBRARIES}
# ROOT
# Geant4
)
set(LIBRARY_OUTPUT_PATH ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
message(STATUS "LIBRARY_OUTPUT_PATH -> ${LIBRARY_OUTPUT_PATH}")
dd4hep_generate_rootmap(DetCRD)
<?xml version="1.0" encoding="UTF-8"?>
<lccdd>
<includes>
<gdmlFile ref="elements.xml"/>
<gdmlFile ref="materials.xml"/>
</includes>
<define>
<constant name="world_size" value="30*m"/>
<constant name="world_x" value="world_size"/>
<constant name="world_y" value="world_size"/>
<constant name="world_z" value="world_size"/>
<constant name="ecalbarrel_inner_radius" value="1800*mm"/>
<constant name="ecalbarrel_thickness" value="300*mm"/> <!--Must be n*10*mm! -->
<constant name="ecalbarrel_zlength" value="4600*mm"/> <!--Must be n*10*mm! -->
</define>
<display>
<vis name="Invisible" showDaughters="false" visible="false"/>
<vis name="InvisibleWithChildren" showDaughters="true" visible="false"/>
<vis name="VisibleRed" r="1.0" g="0.0" b="0.0" showDaughters="true" visible="true"/>
<vis name="VisibleBlue" r="0.0" g="0.0" b="1.0" showDaughters="false" visible="true"/>
<vis name="VisibleGreen" alpha="1.0" r="0.0" g="1.0" b="0.0" drawingStyle="solid" lineStyle="solid" showDaughters="true" visible="true"/>
</display>
<detectors>
<detector id="1" name="CaloDetector" type="CRDEcalBarrel" readout="CaloHitsCollection" vis="Invisible" sensitive="true">
<!-- Use cm as unit if you want to use Pandora for reconstruction -->
</detector>
</detectors>
<readouts>
<readout name="CaloHitsCollection">
<!-- <segmentation type="NoSegmentation"/> -->
<!--segmentation type="CartesianGridXYZ"
grid_size_x="1*cm"
grid_size_y="1*cm"
grid_size_z="1*cm"/-->
<id>block:8,layer:12,piece:12,bar:12</id>
</readout>
</readouts>
</lccdd>
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8"?>
<materials>
<!--
Air by weight from
http://www.engineeringtoolbox.com/air-composition-24_212.html
-->
<material name="Air">
<D type="density" unit="g/cm3" value="0.0012"/>
<fraction n="0.754" ref="N"/>
<fraction n="0.234" ref="O"/>
<fraction n="0.012" ref="Ar"/>
</material>
<!-- We model vakuum just as very thin air -->
<material name="Vacuum">
<D type="density" unit="g/cm3" value="0.0000000001" />
<fraction n="0.754" ref="N"/>
<fraction n="0.234" ref="O"/>
<fraction n="0.012" ref="Ar"/>
</material>
<material name="Epoxy">
<D type="density" value="1.3" unit="g/cm3"/>
<composite n="44" ref="H"/>
<composite n="15" ref="C"/>
<composite n="7" ref="O"/>
</material>
<material name="Quartz">
<D type="density" value="2.2" unit="g/cm3"/>
<composite n="1" ref="Si"/>
<composite n="2" ref="O"/>
</material>
<material name="G10">
<D type="density" value="1.7" unit="g/cm3"/>
<fraction n="0.08" ref="Cl"/>
<fraction n="0.773" ref="Quartz"/>
<fraction n="0.147" ref="Epoxy"/>
</material>
<material name="Polystyrene">
<D value="1.032" unit="g/cm3"/>
<composite n="19" ref="C"/>
<composite n="21" ref="H"/>
</material>
<material name="Steel235">
<D value="7.85" unit="g/cm3"/>
<fraction n="0.998" ref="Fe"/>
<fraction n=".002" ref="C"/>
</material>
<material name="SiliconOxide">
<D type="density" value="2.65" unit="g/cm3"/>
<composite n="1" ref="Si"/>
<composite n="2" ref="O"/>
</material>
<material name="BoronOxide">
<D type="density" value="2.46" unit="g/cm3"/>
<composite n="2" ref="B"/>
<composite n="3" ref="O"/>
</material>
<material name="SodiumOxide">
<D type="density" value="2.65" unit="g/cm3"/>
<composite n="2" ref="Na"/>
<composite n="1" ref="O"/>
</material>
<material name="AluminumOxide">
<D type="density" value="3.89" unit="g/cm3"/>
<composite n="2" ref="Al"/>
<composite n="3" ref="O"/>
</material>
<material name="PyrexGlass">
<D type="density" value="2.23" unit="g/cm3"/>
<fraction n="0.806" ref="SiliconOxide"/>
<fraction n="0.130" ref="BoronOxide"/>
<fraction n="0.040" ref="SodiumOxide"/>
<fraction n="0.023" ref="AluminumOxide"/>
</material>
<material name="CarbonFiber">
<D type="density" value="1.5" unit="g/cm3"/>
<fraction n="0.65" ref="C"/>
<fraction n="0.35" ref="Epoxy"/>
</material>
<material name="CarbonFiber_50D">
<D type="density" value="0.75" unit="g/cm3"/>
<fraction n="0.65" ref="C"/>
<fraction n="0.35" ref="Epoxy"/>
</material>
<material name="Rohacell31">
<D type="density" value="0.032" unit="g/cm3"/>
<composite n="9" ref="C"/>
<composite n="13" ref="H"/>
<composite n="2" ref="O"/>
<composite n="1" ref="N"/>
</material>
<material name="Rohacell31_50D">
<D type="density" value="0.016" unit="g/cm3"/>
<composite n="9" ref="C"/>
<composite n="13" ref="H"/>
<composite n="2" ref="O"/>
<composite n="1" ref="N"/>
</material>
<material name="RPCGasDefault" state="gas">
<D type="density" value="0.0037" unit="g/cm3"/>
<composite n="209" ref="C"/>
<composite n="239" ref="H"/>
<composite n="381" ref="F"/>
</material>
<material name="PolystyreneFoam">
<D type="density" value="0.0056" unit="g/cm3"/>
<fraction n="1.0" ref="Polystyrene"/>
</material>
<material name="Kapton">
<D value="1.43" unit="g/cm3" />
<composite n="22" ref="C"/>
<composite n="10" ref="H" />
<composite n="2" ref="N" />
<composite n="5" ref="O" />
</material>
<material name="PEEK">
<D value="1.37" unit="g/cm3" />
<composite n="19" ref="C"/>
<composite n="12" ref="H" />
<composite n="3" ref="O" />
</material>
<material name="G4_BGO" state="solid">
<MEE unit="eV" value="534.1"/>
<D value="7.13" unit="g/cm3" />
<fraction n="0.154126" ref="O"/>
<fraction n="0.174820" ref="Ge" />
<fraction n="0.671054" ref="Bi" />
</material>
</materials>
//====================================================================
// Detector description for CEPC Reference Detector ECal Barrel.
//--------------------------------------------------------------------
//
// Author : Fangyi Guo email: guofangyi@ihep.ac.cn
//
//====================================================================
#include "DD4hep/DetFactoryHelper.h"
#include "XML/Layering.h"
#include "XML/Utilities.h"
#include "DDRec/DetectorData.h"
#include "DDSegmentation/Segmentation.h"
#define MYDEBUG(x) std::cout << __FILE__ << ":" << __LINE__ << ": " << x << std::endl;
#define MYDEBUGVAL(x) std::cout << __FILE__ << ":" << __LINE__ << ": " << #x << ": " << x << std::endl;
using dd4hep::rec::LayeredCalorimeterData;
using namespace dd4hep;
using namespace std;
static dd4hep::Ref_t create_detector(dd4hep::Detector& theDetector,
xml_h e,
dd4hep::SensitiveDetector sens) {
xml_det_t x_det = e;
std::string det_name = x_det.nameStr();
std::string det_type = x_det.typeStr();
MYDEBUGVAL(det_name);
MYDEBUGVAL(det_type);
int detid = x_det.id();
//Global geometry
double R0 = theDetector.constant<double>("ecalbarrel_inner_radius");
double h0 = theDetector.constant<double>("ecalbarrel_thickness");
double Z0 = theDetector.constant<double>("ecalbarrel_zlength");
double dim_x1 = R0*tan(22.5*degree) + sqrt(2)*h0/2.;
double dim_x2 = dim_x1 - h0;
double dim_y = Z0/2.;
double dim_z = h0/2.;
double dx = dim_x1 - R0*tan(22.5*degree); //transport distance in x-axis
double r0 = R0+h0/2.; //rotation radius
//Crystal bar size
double barx = 10*mm; //Crystal size in R direction.
double bary = 10*mm; //Crystal size in z/phi direction (z for odd layer, phi for even layer).
int Nlayers = (int)h0/barx;
int Nbarz_odd = (int)Z0/bary;
int Nbarphi_odd; //Depends on layer. Layer1~5: 5. Layer7~23: 4. Layer25~27: 3.
int Nbarz_even = 12;
int Nbarphi_even; //Depends on layer
double barz_even = Z0/Nbarz_even; //~38 cm
double barz_odd; //Depends on layer
//Define detector and motherVolume(world)
dd4hep::DetElement ECAL(det_name, detid);
dd4hep::Volume motherVol = theDetector.pickMotherVolume(ECAL);
// Create a Tube-like envelope representing the whole detector volume
dd4hep::Tube envelope(R0, (R0+h0)/cos(22.5*degree), Z0/2, 0, 2*M_PI);
dd4hep::Material air(theDetector.material("Air"));
dd4hep::Volume envelopeVol(det_name, envelope, air);
dd4hep::PlacedVolume envelopePlv = motherVol.placeVolume(envelopeVol, Position(0,0,0));
envelopeVol.setVisAttributes(theDetector, x_det.visStr() );
ECAL.setPlacement(envelopePlv);
// dd4hep::Material det_pipe(theDetector.material("Steel235"));
// dd4hep::Volume pipe_vol("pipe", dd4hep::Tube(10*mm, 20*mm, 2300*mm), det_pipe);
// dd4hep::PlacedVolume pipePhv = motherVol.placeVolume(pipe_vol, Position(0.,0.,0.));
//Define specific material and volumen for detElement
dd4hep::Material mat_BGO(theDetector.material("G4_BGO"));
dd4hep::Trapezoid trap(dim_x1, dim_x2, dim_y, dim_y, dim_z);
dd4hep::Volume det_vol("trap_vol", trap, mat_BGO);
// det_vol.setVisAttributes(theDetector, x_det.visStr());
dd4hep::DetElement stavedet(ECAL, "trap",detid);
//Loop to place crystalls in one part
//Outer loop: layer (odd layer).
for(int ilayer=1; ilayer<=Nlayers; ilayer+=2){
double lx = dim_x1 - ilayer*10*mm;
//Loop in phi direction
if(ilayer<=5) Nbarphi_odd=5; else if(ilayer<=23) Nbarphi_odd=4; else Nbarphi_odd=3;
for(int iphi=1; iphi<=Nbarphi_odd; iphi++){
barz_odd = 2*lx/Nbarphi_odd;
//Loop in Z direction
dd4hep::Volume bar_odd("box_bar", dd4hep::Box(barz_odd/2, bary/2, barx/2), mat_BGO);
bar_odd.setSensitiveDetector(sens);
for(int iz=1; iz<=Nbarz_odd;iz++){
dd4hep::PlacedVolume plv = det_vol.placeVolume(bar_odd, Position((2*iphi-1)*barz_odd/2-lx, (2*iz-1)*barx/2-dim_y, (2*ilayer-1)*bary/2-dim_z));
plv.addPhysVolID("layer", ilayer).addPhysVolID("piece", iphi).addPhysVolID("bar", iz);
std::string barname = "CrystalBar_"+std::to_string(ilayer)+"_"+std::to_string(iphi)+"_"+std::to_string(iz);
dd4hep::DetElement sd(stavedet, barname, detid);
sd.setPlacement(plv);
}
}
}
//Loop in even layer
dd4hep::Volume bar_even("box_bar", dd4hep::Box(bary/2, barz_even/2, barx/2), mat_BGO);
bar_even.setSensitiveDetector(sens);
for(int ilayer=2; ilayer<=Nlayers; ilayer+=2){
double lx = dim_x1 - ilayer*10*mm;
//Loop in phi direction
Nbarphi_even = (int)floor(2*lx/bary);
for(int iphi=1; iphi<=Nbarphi_even; iphi++){
//Loop in Z direction
for(int iz=1; iz<=Nbarz_even;iz++){
dd4hep::PlacedVolume plv = det_vol.placeVolume(bar_even, Position(lx-(2*iphi-1)*bary/2, (2*iz-1)*barz_even/2-dim_y, (2*ilayer-1)*bary/2-dim_z));
plv.addPhysVolID("layer", ilayer).addPhysVolID("piece", iphi).addPhysVolID("bar", iz);
std::string barname = "CrystalBar_"+std::to_string(ilayer)+"_"+std::to_string(iphi)+"_"+std::to_string(iz);
dd4hep::DetElement sd(stavedet, barname, detid);
sd.setPlacement(plv);
}
}
}
//create a unique volume (PlacedVolume) for the detector
// dd4hep::Transform3D trans0(dd4hep::RotationX(-90*degree), dd4hep::Position(-dx, r0, 0.));
// dd4hep::PlacedVolume plv0 = motherVol.placeVolume(det_vol, trans0);
// stavedet.setPlacement(plv0);
for(int i=0;i<8;i++){
double rotAngle = 45*i*degree;
double posx = -r0*sin(rotAngle) - dx*cos(rotAngle);
double posy = r0*cos(rotAngle) - dx*sin(rotAngle);
dd4hep::Transform3D transform(dd4hep::RotationZ(rotAngle)*dd4hep::RotationX(-90*degree), dd4hep::Position(posx, posy, 0.));
dd4hep::PlacedVolume plv = envelopeVol.placeVolume(det_vol, transform);
plv.addPhysVolID("block", i);
DetElement sd(ECAL, _toString(i,"trap%3d"), detid);
sd.setPlacement(plv);
}
sens.setType("calorimeter");
MYDEBUG("create_detector DONE. ");
return ECAL;
}
DECLARE_DETELEMENT(CRDEcalBarrel, create_detector)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment