Skip to content

Commit

Permalink
Merge branch 'key4hep:main' into ILD4FCCmodels
Browse files Browse the repository at this point in the history
  • Loading branch information
danieljeans authored Oct 3, 2024
2 parents 145b626 + 2a8573a commit a5d54ba
Show file tree
Hide file tree
Showing 6 changed files with 269 additions and 81 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ project(${PackageName})

# project version
SET( ${PackageName}_VERSION_MAJOR 0 )
SET( ${PackageName}_VERSION_MINOR 20 )
SET( ${PackageName}_VERSION_MINOR 21 )
SET( ${PackageName}_VERSION_PATCH 0 )

SET( ${PackageName}_VERSION "${${PackageName}_VERSION_MAJOR}.${${PackageName}_VERSION_MINOR}" )
Expand Down
22 changes: 11 additions & 11 deletions FCCee/IDEA/compact/IDEA_o1_v03/DectDimensions_IDEA_o1_v03.xml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@

<constant name="Solenoid_inner_radius" value="2100*mm"/>
<constant name="Solenoid_outer_radius" value="2400*mm"/>
<constant name="Solenoid_half_length" value="2500*mm"/>
<constant name="Solenoid_half_length" value="2380*mm"/>
<constant name="Solenoid_Coil_half_length" value="Solenoid_half_length-200*mm"/>
<constant name="Solenoid_Coil_radius" value="Solenoid_inner_radius+200*mm"/>

Expand All @@ -132,8 +132,8 @@

<!-- These are lead plates that we put in the endcap to have the same material budget (from solenoid) as in the barrel-->
<constant name="EndPlateAbsorber_inner_radius" value="380*mm"/>
<constant name="EndPlateAbsorber_outer_radius" value="2090*mm"/>
<constant name="EndPlateAbsorber_z_min" value="2490*mm"/>
<constant name="EndPlateAbsorber_outer_radius" value="2030*mm"/>
<constant name="EndPlateAbsorber_z_min" value="2350*mm"/>
<constant name="EndPlateAbsorber_z_half_length" value="4.209/2.0*mm"/>

<constant name="YokeBarrel_inner_radius" value="4479*mm"/>
Expand Down Expand Up @@ -209,12 +209,12 @@
<!-- Pre-shower Parameters-->
<constant name = "psNumSides" value = "32"/> <!-- The number of sides of the pre-shower -->
<!-- Barrel -->
<constant name = "psBarrelFirstLayerRadius" value = "2440*mm"/> <!-- 1st Barrel microRWELL detector inner radius-> its the start point of thicknesses of the microRWELL material. In our case the shape is Polygon, so the radius is in the middle of the polygon side. -->
<constant name = "psBarrelLength" value = "5100*mm"/> <!--Barrel detector length, in the description of the detctor we always use the half-length -->
<constant name = "psBarrelFirstLayerRadius" value = "2420*mm"/> <!-- 1st Barrel microRWELL detector inner radius-> its the start point of thicknesses of the microRWELL material. In our case the shape is Polygon, so the radius is in the middle of the polygon side. -->
<constant name = "psBarrelLength" value = "4900*mm"/> <!--Barrel detector length, in the description of the detctor we always use the half-length -->
<!-- Endcap -->
<constant name = "psEndcapFirstLayerZOffset" value = "2550*mm"/> <!-- 1st Endcap microRWELL detector inner ZOffset-> its the start point of thicknesses of the microRWELL volume -->
<constant name = "psEndcapFirstLayerZOffset" value = "2400*mm"/> <!-- 1st Endcap microRWELL detector inner ZOffset-> its the start point of thicknesses of the microRWELL volume -->
<constant name = "psEndcapLayersInnerRadius" value = "390*mm"/> <!--Endcap detector inner radius, its the start point of thicknesses of the detector material ** it applies for both detector layers and yoke-->
<constant name = "psEndcapLayersOuterRadius" value = "2430*mm"/> <!--Endcap detector outer radius, its the end point of thicknesses of the detector material ** it applies for both detector layers and yoke-->
<constant name = "psEndcapLayersOuterRadius" value = "2420*mm"/> <!--Endcap detector outer radius, its the end point of thicknesses of the detector material ** it applies for both detector layers and yoke-->
<!-- End of Pre-shower Parameters-->

<!-- Fiber dual-readout calorimeter tower dim-->
Expand All @@ -234,12 +234,12 @@
<!-- Muon System Parameters-->
<constant name = "numberOfSides" value = "8"/> <!-- The number of sides of the muon system e.g (Octagon, Hexagon, ...)-->
<!-- Barrel -->
<constant name = "BarrelFirstLayerRadius" value = "4500*mm"/> <!-- 1st Barrel microRWELL detector inner radius-> its the start point of thicknesses of the microRWELL material. In our case the shape is Polygon, so the radius is in the middle of the polygon side. -->
<constant name = "BarrelLength" value = "9000*mm"/> <!--Barrel detector length, in the description of the detctor we always use the half-length -->
<constant name = "BarrelFirstLayerRadius" value = "4530*mm"/> <!-- 1st Barrel microRWELL detector inner radius-> its the start point of thicknesses of the microRWELL material. In our case the shape is Polygon, so the radius is in the middle of the polygon side. -->
<constant name = "BarrelLength" value = "9060*mm"/> <!--Barrel detector length, in the description of the detctor we always use the half-length -->
<!-- Endcap -->
<constant name = "EndcapFirstLayerZOffset" value = "4500*mm"/> <!-- 1st Endcap microRWELL detector inner ZOffset-> its the start point of thicknesses of the microRWELL volume -->
<constant name = "EndcapFirstLayerZOffset" value = "4530*mm"/> <!-- 1st Endcap microRWELL detector inner ZOffset-> its the start point of thicknesses of the microRWELL volume -->
<constant name = "EndcapLayersInnerRadius" value = "700*mm"/> <!--Endcap detector inner radius, its the start point of thicknesses of the detector material ** it applies for both detector layers and yoke-->
<constant name = "EndcapLayersOuterRadius" value = "5320*mm"/> <!--Endcap detector outer radius, its the end point of thicknesses of the detector material ** it applies for both detector layers and yoke-->
<constant name = "EndcapLayersOuterRadius" value = "5350*mm"/> <!--Endcap detector outer radius, its the end point of thicknesses of the detector material ** it applies for both detector layers and yoke-->
<!-- End of Muon system Parameters-->
</define>

Expand Down
66 changes: 32 additions & 34 deletions detector/calorimeter/HCalThreePartsEndcap_o1_v02_geo.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
// DD4hep
#include "DD4hep/DetFactoryHelper.h"
#include <DDRec/DetectorData.h>

// todo: remove gaudi logging and properly capture output
#define endmsg std::endl
#define lLog std::cout
namespace MSG {
const std::string ERROR = "createHCalThrePartsEndcap ERROR ";
const std::string DEBUG = "createHCalThrePartsEndcap DEBUG ";
const std::string INFO = "createHCalThrePartsEndcap INFO ";
}
#include "DD4hep/Printout.h"

using dd4hep::Volume;
using dd4hep::DetElement;
Expand Down Expand Up @@ -54,8 +46,8 @@ static dd4hep::Ref_t createHCalEC(dd4hep::Detector& lcdd, xml_h xmlElement, dd4h
double space = xSpace.thickness();
xml_comp_t xSteelSupport = xmlElement.child(_Unicode(steel_support));
double dSteelSupport = xSteelSupport.thickness();
lLog << MSG::DEBUG << "steel support thickness " << dSteelSupport << endmsg;
lLog << MSG::DEBUG << "steel support material " << xSteelSupport.materialStr() << endmsg;

dd4hep::printout(dd4hep::DEBUG, "HCalThreePartsEndcap_o1_v02", "steel support thickness (cm): %.2f", dSteelSupport);

// Calculate sensitive barrel dimensions
double sensitiveBarrel1Rmin = dimensions.rmin1() + 2 * dRhoFacePlate + space;
Expand All @@ -71,18 +63,18 @@ static dd4hep::Ref_t createHCalEC(dd4hep::Detector& lcdd, xml_h xmlElement, dd4h
std::vector<xml_comp_t> sequences = {xmlElement.child(_Unicode(sequence_a)), xmlElement.child(_Unicode(sequence_b))};
// Check if both sequences are present
if (!sequences[0] || !sequences[1]) {
lLog << MSG::ERROR << "The two sequences sequence_a and sequence_b must be present in the xml file." << endmsg;
dd4hep::printout(dd4hep::ERROR, "HCalThreePartsEndcap_o1_v02", "The two sequences 'sequence_a' and 'sequence_b' must be present in the xml file.");
throw std::runtime_error("Missing sequence_a or sequence_b in the xml file.");
}
// Check if both sequences have the same dimensions
Dimension dimensionsA(sequences[0].dimensions());
Dimension dimensionsB(sequences[1].dimensions());
if (dimensionsA.dz() != dimensionsB.dz()) {
lLog << MSG::ERROR << "The dimensions of sequence_a and sequence_b do not match." << endmsg;
dd4hep::printout(dd4hep::ERROR, "HCalThreePartsEndcap_o1_v02", "The dimensions of sequence_a and sequence_b do not match.");
throw std::runtime_error("The dimensions of the sequence_a and sequence_b do not match.");
}
double dzSequence = dimensionsB.dz();
lLog << MSG::DEBUG << "sequence thickness " << dzSequence << endmsg;
dd4hep::printout(dd4hep::DEBUG, "HCalThreePartsEndcap_o1_v02", "sequence thickness %.2f", dzSequence);

// calculate the number of modules fitting in Z
unsigned int numSequencesZ1 = static_cast<unsigned>((2 * dimensions.width() - 2 * dZEndPlate - space) / dzSequence);
Expand Down Expand Up @@ -126,39 +118,38 @@ static dd4hep::Ref_t createHCalEC(dd4hep::Detector& lcdd, xml_h xmlElement, dd4h
}
}

lLog << MSG::DEBUG << "retrieved number of layers in first Endcap part: " << numLayersR1 << " , which end up to a full module depth in rho of " << moduleDepth1 << " cm" << endmsg;
lLog << MSG::DEBUG << "retrieved number of layers in second Endcap part: " << numLayersR2 << " , which end up to a full module depth in rho of " << moduleDepth2 << " cm" << endmsg;
lLog << MSG::DEBUG << "retrieved number of layers in third Endcap part: " << numLayersR3 << " , which end up to a full module depth in rho of " << moduleDepth3 << " cm" << endmsg;
dd4hep::printout(dd4hep::DEBUG, "HCalThreePartsEndcap_o1_v02", "retrieved number of layers in first Endcap part: %d , which end up to a full module depth in rho of %.2f cm", numLayersR1, moduleDepth1);
dd4hep::printout(dd4hep::DEBUG, "HCalThreePartsEndcap_o1_v02", "retrieved number of layers in second Endcap part: %d , which end up to a full module depth in rho of %.2f cm", numLayersR2, moduleDepth2);
dd4hep::printout(dd4hep::DEBUG, "HCalThreePartsEndcap_o1_v02", "retrieved number of layers in third Endcap part: %d , which end up to a full module depth in rho of %.2f cm", numLayersR3, moduleDepth3);

lLog << MSG::INFO << "constructing first part EC: with z offset " << extBarrelOffset1 << " cm: "<< numSequencesZ1 << " sequences in Z, " << numLayersR1 << " layers in Rho, " << numLayersR1 * numSequencesZ1 << " tiles" << endmsg;
lLog << MSG::INFO << "constructing second part EC: with offset " << extBarrelOffset2 << " cm: " << numSequencesZ2 << " sequences in Z, " << numLayersR2 << " layers in Rho, " << layerDepths2.size() * numSequencesZ2 << " tiles" << endmsg;
dd4hep::printout(dd4hep::INFO, "HCalThreePartsEndcap_o1_v02", "constructing first part EC: with z offset %.2f cm: %d sequences in Z, %d radial layers, %d tiles", extBarrelOffset1, numSequencesZ1, numLayersR1, numSequencesZ1*numLayersR1);
dd4hep::printout(dd4hep::INFO, "HCalThreePartsEndcap_o1_v02", "constructing second part EC: with z offset %.2f cm: %d sequences in Z, %d radial layers, %d tiles", extBarrelOffset2, numSequencesZ2, numLayersR2, numSequencesZ2*numLayersR2);
dd4hep::printout(dd4hep::INFO, "HCalThreePartsEndcap_o1_v02", "constructing third part EC: with z offset %.2f cm: %d sequences in Z, %d radial layers, %d tiles", extBarrelOffset3, numSequencesZ3, numLayersR3, numSequencesZ3*numLayersR3);

lLog << MSG::INFO << "constructing third part EC: with offset " << extBarrelOffset3 << " cm: " << numSequencesZ3 << " sequences in Z, " << numLayersR3 << " layers in Rho, " << layerDepths3.size() * numSequencesZ3 << " tiles" << endmsg;

lLog << MSG::INFO << "number of channels: " << (numLayersR1 * numSequencesZ1) + (numLayersR2 * numSequencesZ2) + (numLayersR3 * numSequencesZ3) << endmsg;
dd4hep::printout(dd4hep::DEBUG, "HCalThreePartsEndcap_o1_v02", "number of sequences in the whole Endcap ", numLayersR1*numSequencesZ1 + numLayersR2*numSequencesZ2 + numLayersR3*numSequencesZ3);

// Calculate correction along z based on the module size (can only have natural number of modules)
double dzDetector1 = (numSequencesZ1 * dzSequence) / 2 + 2 * dZEndPlate + space;
double dzDetector2 = (numSequencesZ2 * dzSequence) / 2;
double dzDetector3 = (numSequencesZ3 * dzSequence) / 2 + 2 * dZEndPlate + space;

lLog << MSG::INFO << "correction of dz (negative = size reduced) first part EC :" << dzDetector1*2 - dimensions.width()*2 << endmsg;
lLog << MSG::INFO << "dz second part EC:" << dzDetector2 * 2 << endmsg;
lLog << MSG::INFO << "width second part EC:" << dimensions.dz() * 2 << endmsg;
lLog << MSG::INFO << "correction of dz (negative = size reduced) second part EB:" << dzDetector2*2 - dimensions.dz()*2 << endmsg;
dd4hep::printout(dd4hep::DEBUG, "HCalThreePartsEndcap_o1_v02", "correction of dz (negative = size reduced) first part EC: %.2f", dzDetector1*2 - dimensions.width()*2);
dd4hep::printout(dd4hep::DEBUG, "HCalThreePartsEndcap_o1_v02", "dz second part EC: %.2f", dzDetector2 * 2);
dd4hep::printout(dd4hep::DEBUG, "HCalThreePartsEndcap_o1_v02", "width second part EC: %.2f", dimensions.dz() * 2);
dd4hep::printout(dd4hep::DEBUG, "HCalThreePartsEndcap_o1_v02", "correction of dz (negative = size reduced) second part EB: %.2f", dzDetector2*2 - dimensions.dz()*2);

lLog << MSG::INFO << "dz third part EC:" << dzDetector3 * 2 << endmsg;
dd4hep::printout(dd4hep::DEBUG, "HCalThreePartsEndcap_o1_v02", "dz third part EC: %.2f", dzDetector3 * 2);


for (int iSign = -1; iSign < 2; iSign+=2){
int sign;
if(iSign < 0){
sign = -1;
lLog << MSG::DEBUG << "Placing detector on the negative side: (cm) " << -(dimensions.offset() + dimensions.dz()) << endmsg;
dd4hep::printout(dd4hep::INFO, "HCalThreePartsEndcap_o1_v02", "Placing detector on the negative side: (cm) %.2f", -(dimensions.offset() + dimensions.dz()));
}
else{
sign = +1;
lLog << MSG::DEBUG << "Placing detector on the positive side: (cm) " << (dimensions.offset() + dimensions.dz()) << endmsg;
dd4hep::printout(dd4hep::INFO, "HCalThreePartsEndcap_o1_v02", "Placing detector on the positive side: (cm) %.2f", (dimensions.offset() + dimensions.dz()));
}
// Add structural support made of steel inside of HCal
DetElement facePlate1(caloDetElem, "FacePlate_" + std::to_string(1 * sign), 0);
Expand Down Expand Up @@ -231,7 +222,9 @@ static dd4hep::Ref_t createHCalEC(dd4hep::Detector& lcdd, xml_h xmlElement, dd4h
dd4hep::Tube tileSequenceShape(rminLayer, rmaxLayer, 0.5*dzSequence);
Volume tileSequenceVolume("HCalECTileSequenceVol1", tileSequenceShape, lcdd.air());

lLog << MSG::DEBUG << "layer radii: " << rminLayer << " - " << rmaxLayer << " [cm]" << endmsg;
if(iSign < 0){
dd4hep::printout(dd4hep::INFO, "HCalThreePartsEndcap_o1_v02", "first part: layer %d (cm): %.2f - %.2f", idxLayer, rminLayer, rmaxLayer);
}

dd4hep::Tube layerShape(rminLayer, rmaxLayer, dzDetector1 );
Volume layerVolume("HCalECLayerVol1", layerShape, lcdd.air());
Expand Down Expand Up @@ -301,7 +294,9 @@ static dd4hep::Ref_t createHCalEC(dd4hep::Detector& lcdd, xml_h xmlElement, dd4h
dd4hep::Tube tileSequenceShape(rminLayer, rmaxLayer, 0.5*dzSequence);
Volume tileSequenceVolume("HCalECTileSequenceVol2", tileSequenceShape, lcdd.air());

lLog << MSG::DEBUG << "layer radii: " << rminLayer << " - " << rmaxLayer << " [cm]" << endmsg;
if(iSign < 0){
dd4hep::printout(dd4hep::INFO, "HCalThreePartsEndcap_o1_v02", "second part: layer %d (cm): %.2f - %.2f", idxLayer, rminLayer, rmaxLayer);
}

dd4hep::Tube layerShape(rminLayer, rmaxLayer, dzDetector2);
Volume layerVolume("HCalECLayerVol2", layerShape, lcdd.air());
Expand Down Expand Up @@ -369,7 +364,9 @@ static dd4hep::Ref_t createHCalEC(dd4hep::Detector& lcdd, xml_h xmlElement, dd4h
dd4hep::Tube tileSequenceShape(rminLayer, rmaxLayer, 0.5*dzSequence);
Volume tileSequenceVolume("HCalECTileSequenceVol3", tileSequenceShape, lcdd.air());

lLog << MSG::DEBUG << "layer radii: " << rminLayer << " - " << rmaxLayer << " [cm]" << endmsg;
if(iSign < 0){
dd4hep::printout(dd4hep::INFO, "HCalThreePartsEndcap_o1_v02", "third part: layer %d (cm): %.2f - %.2f", idxLayer, rminLayer, rmaxLayer);
}

dd4hep::Tube layerShape(rminLayer, rmaxLayer, dzDetector3);
Volume layerVolume("HCalECLayerVol3", layerShape, lcdd.air());
Expand Down Expand Up @@ -422,8 +419,9 @@ static dd4hep::Ref_t createHCalEC(dd4hep::Detector& lcdd, xml_h xmlElement, dd4h
} // end loop placement of subwedges

// Placement of DetElements
lLog << MSG::DEBUG << "Layers in r : " << layers.size() << std::endl;
lLog << MSG::DEBUG << "Tiles in layers :" << tilesPerLayer.size() << std::endl;
dd4hep::printout(dd4hep::DEBUG, "HCalThreePartsEndcap_o1_v02", "Layers in r : %d", layers.size());
dd4hep::printout(dd4hep::DEBUG, "HCalThreePartsEndcap_o1_v02", "Tiles in layers : %d", tilesPerLayer.size());


// Place det elements wihtin each other to recover volume positions later via cellID
for (uint iLayer = 0; iLayer < (layerDepths1.size()+layerDepths2.size()+layerDepths3.size()); iLayer++){
Expand Down
Loading

0 comments on commit a5d54ba

Please sign in to comment.