Skip to content

Commit

Permalink
Merge branch 'main' into ILD4FCCmodels
Browse files Browse the repository at this point in the history
  • Loading branch information
danieljeans authored Sep 18, 2024
2 parents 353b67c + 8a7c232 commit 942086c
Show file tree
Hide file tree
Showing 7 changed files with 787 additions and 48 deletions.
8 changes: 7 additions & 1 deletion FCCee/ALLEGRO/compact/ALLEGRO_o1_v03/ECalEndcaps_Turbine.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@
<constant name="ECalEndcapNumPlanes" value="928"/>
<constant name="ECalEndcapNumCalibLayers" value="10"/>
<constant name="nWheels" value="3" />
<!-- following three lines just to satisfy new segmentation interface -->
<constant name="BladeAngle1" value="41*deg" />
<constant name="BladeAngle2" value="41*deg" />
<constant name="BladeAngle3" value="41*deg" />

<constant name="BladeAngle" value="41*deg" />
<constant name="NobleLiquidGap" value="3.9*mm" />
<constant name="AbsorberBladeThickness" value="2.9*mm" />
Expand All @@ -51,6 +56,7 @@
<constant name="EMEC_steel_thickness" value="0.1*mm"/>
<!-- total amount of glue in one passive plate: it is divided for the outside layer on top and bottom -->
<constant name="EMEC_glue_thickness" value="0.1*mm"/>
<constant name="nUnitCellsLeastCommonMultiple" value="78336"/>
</define>

<display>
Expand Down Expand Up @@ -108,7 +114,7 @@
<supportTube name="supportTube" nWheels="nWheels" thickness="1.0*cm" sensitive="false">
<material name="CarbonFiber" />
</supportTube>
<turbineBlade name="turbineBlade" angle="BladeAngle" decreaseAnglePerWheel="false" sameNUnitCells="false" nUnitCells="144 272 512" nUnitCellsLeastCommonMultiple="78336">
<turbineBlade name="turbineBlade" angle="BladeAngle" decreaseAnglePerWheel="false" sameNUnitCells="false" nUnitCells="144 272 512" nUnitCellsLeastCommonMultiple="nUnitCellsLeastCommonMultiple">
<absorberBlade name="absorberBlade" thickness="AbsorberBladeThickness" scaleThickness="true" thicknessScaleFactor="1.0" sensitive="false">
<material name="Lead" />
</absorberBlade>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@
<constant name="ECalEndcapNumPlanes" value="928"/>
<constant name="ECalEndcapNumCalibLayers" value="10"/>
<constant name="nWheels" value="3"/>
<!-- following three lines just to satisfy new segmentation interface -->
<constant name="BladeAngle1" value="41*deg"/>
<constant name="BladeAngle2" value="41*deg"/>
<constant name="BladeAngle3" value="41*deg"/>

<constant name="BladeAngle" value="41*deg"/>
<constant name="NobleLiquidGap" value="3.9*mm"/>
<constant name="AbsorberBladeThickness" value="2.9*mm"/>
Expand All @@ -43,6 +48,7 @@
<constant name="EMEC_steel_thickness" value="0.1*mm"/>
<!-- total amount of glue in one passive plate: it is divided for the outside layer on top and bottom -->
<constant name="EMEC_glue_thickness" value="0.1*mm"/>
<constant name="nUnitCellsLeastCommonMultiple" value="78336"/>
</define>

<display>
Expand Down Expand Up @@ -100,7 +106,7 @@
<supportTube name="supportTube" nWheels="nWheels" thickness="1.0*cm" sensitive="false">
<material name="CarbonFiber"/>
</supportTube>
<turbineBlade name="turbineBlade" angle="BladeAngle" decreaseAnglePerWheel="false" sameNUnitCells="false" nUnitCells="144 272 512" nUnitCellsLeastCommonMultiple="78336">
<turbineBlade name="turbineBlade" angle="BladeAngle" decreaseAnglePerWheel="false" sameNUnitCells="false" nUnitCells="144 272 512" nUnitCellsLeastCommonMultiple="nUnitCellsLeastCommonMultiple">
<absorberBlade name="absorberBlade" thickness="AbsorberBladeThickness" scaleThickness="true" thicknessScaleFactor="1.0" sensitive="true">
<material name="Lead"/>
</absorberBlade>
Expand Down
66 changes: 31 additions & 35 deletions detector/calorimeter/ECalEndcap_Turbine_o1_v01_geo.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "DD4hep/DetFactoryHelper.h"
#include "DD4hep/Printout.h"
#include "TMatrixT.h"

// todo: remove gaudi logging and properly capture output
Expand Down Expand Up @@ -83,18 +84,18 @@ namespace det {

float BladeAngle = genericBladeElem.attr<float>(_Unicode(angle));
bool decreaseAnglePerWheel = genericBladeElem.attr<bool>(_Unicode(decreaseAnglePerWheel));
lLog << MSG::DEBUG << "Making wheel with inner, outer radii " << ri << ", " << ro << std:: endl;
lLog << MSG::DEBUG << "Blade angle is " << BladeAngle << "; decrease angle per wheel? " << decreaseAnglePerWheel << endmsg;
dd4hep::printout(dd4hep::DEBUG, "ECalEndcap_Turbine_o1_v01", "Making wheel with inner, outer radii %f, %f", ri, ro);
dd4hep::printout(dd4hep::DEBUG, "ECalEndcap_Turbine_o1_v01", "Blade angle is %f; decrease angle per wheel? ", BladeAngle, decreaseAnglePerWheel);
dd4hep::xml::Dimension dim(aXmlElement.child(_Unicode(dimensions)));
double grmin = dim.rmin1();
lLog << MSG::DEBUG << "delZ is " << delZ << endmsg;
dd4hep::printout( dd4hep::DEBUG, "ECalEndcap_Turbine_o1_v01", "delZ is %f", delZ);
if (decreaseAnglePerWheel) {
float tubeFracCovered = delZ/(2*grmin*TMath::Tan(BladeAngle));
BladeAngle = TMath::ATan(delZ/(2*ri*tubeFracCovered));
}

if (TMath::Abs(TMath::Tan(BladeAngle)) < delZ/(2.*ri)) {
lLog << MSG::ERROR << "The requested blade angle is too small for the given delZ and ri values. Please adjust to at least " << TMath::ATan(delZ/(2.*ri))*180./TMath::Pi() << " degrees!" << endmsg;
dd4hep::printout(dd4hep::ERROR, "ECalEndcap_Turbine_o1_v01", "The requested blade angle is too small for the given delZ and ri values. Please adjust to at least %f degrees!", TMath::ATan(delZ/(2.*ri))*180./TMath::Pi() );
return;
}

Expand All @@ -106,7 +107,7 @@ namespace det {
float CladdingThick = claddingElem.attr<float>(_Unicode(thickness));
float AbsThickMin = absBladeElem.attr<float>(_Unicode(thickness))-(GlueThick+CladdingThick);
if (AbsThickMin < 0.) {
lLog << MSG::ERROR << "Error: requested absorber thickness is negative after accounting for glue and cladding thickness" << endmsg;
dd4hep::printout(dd4hep::ERROR, "ECalEndcap_Turbine_o1_v01", "Error: requested absorber thickness is negative after accounting for glue and cladding thickness");
}
float ElectrodeThick = electrodeBladeElem.attr<float>(_Unicode(thickness));
float LArgapi = nobleLiquidElem.attr<float>(_Unicode(gap));
Expand All @@ -127,7 +128,7 @@ namespace det {
bool scaleBladeThickness = absBladeElem.attr<bool>(_Unicode(scaleThickness));
float bladeThicknessScaleFactor = absBladeElem.attr<float>(_Unicode(thicknessScaleFactor));

lLog << MSG::DEBUG << "nUnitCells: " << nUnitCells << endmsg;
dd4hep::printout(dd4hep::DEBUG, "ECalEndcap_Turbine_o1_v01", "nUnitCells: %d", nUnitCells);

float AbsThicki = AbsThickMin;
// make volumes for the noble liquid, electrode, and absorber blades
Expand All @@ -148,7 +149,7 @@ namespace det {
double leftoverS = (circ - nUnitCells*delrPhiNoGap);
double delrPhiGapOnly = leftoverS/(2*nUnitCells);
LArgapi = delrPhiGapOnly*TMath::Sin(BladeAngle);
lLog << MSG::DEBUG << "LArGap at inner radius is " << LArgapi << endmsg;
dd4hep::printout(dd4hep::DEBUG, "ECalEndcap_Turbine_o1_v01", "LArGap at inner radius is %f", LArgapi);

// now find gap at outer radius
circ = 2*TMath::Pi()*ro;
Expand Down Expand Up @@ -193,22 +194,22 @@ namespace det {
} else if (allNonActiveNotSensitive) {
numNonActiveLayers = 1;
} else {
lLog << MSG::ERROR << "Some non-active layers are sensitive and others are not -- this is likely a misconfiguration";
dd4hep::printout(dd4hep::ERROR, "ECalEndcap_Turbine_o1_v01", "Some non-active layers are sensitive and others are not -- this is likely a misconfiguration");
}

float delrNonActive = (ro-ri)/numNonActiveLayers;
float delrActive = (ro-ri)/ECalEndcapNumCalibLayers;

for (unsigned iLayer = 0; iLayer < numNonActiveLayers; iLayer++) {
float roLayer = riLayer + delrNonActive;
lLog << MSG::INFO << "Making layer in inner, outer radii " << riLayer << " " << roLayer << endmsg;
dd4hep::printout(dd4hep::INFO, "ECalEndcap_Turbine_o1_v01", "Making layer with inner, outer radii %f, %f", riLayer, roLayer);

if (scaleBladeThickness) {
AbsThicko = AbsThicki + bladeThicknessScaleFactor*((roLayer/riLayer)-1.)*AbsThicki;
} else {
AbsThicko = AbsThicki;
}
lLog << MSG::DEBUG << "Inner and outer absorber thicknesses " << AbsThicki << " " << AbsThicko << endmsg;
dd4hep::printout(dd4hep::DEBUG, "ECalEndcap_Turbine_o1_v01", "Inner and outer absorber thicknesses %f, %f ", AbsThicki, AbsThicko);
dd4hep::Solid claddingLayer = buildOneBlade(AbsThicki+GlueThick+CladdingThick, AbsThicko+GlueThick+CladdingThick, xRange, roLayer, riLayer, BladeAngle, delZ );

dd4hep::Solid glueLayer = buildOneBlade(AbsThicki+GlueThick, AbsThicko+GlueThick, xRange, roLayer, riLayer, BladeAngle, delZ );
Expand Down Expand Up @@ -264,8 +265,8 @@ namespace det {
leftoverS = (circ - nUnitCells*delrPhiNoGap);
delrPhiGapOnly = leftoverS/(2*nUnitCells);
LArgapo = delrPhiGapOnly*TMath::Sin(BladeAngle);
lLog << MSG::DEBUG << "Outer LAr gap is " << LArgapo << endmsg ;
lLog << MSG::INFO << "Inner and outer thicknesses of noble liquid volume " << ElectrodeThick+LArgapi*2 << " " << ElectrodeThick+LArgapo*2 << endmsg;
dd4hep::printout(dd4hep::DEBUG, "ECalEndcap_Turbine_o1_v01", "Outer LAr gap is %f", LArgapo) ;
dd4hep::printout(dd4hep::INFO, "ECalEndcap_Turbine_o1_v01", "Inner and outer thicknesses of noble liquid volume %f, %f", ElectrodeThick+LArgapi*2, ElectrodeThick+LArgapo*2);

dd4hep::Solid electrodeBladeAndGapLayer = buildOneBlade(ElectrodeThick+LArgapi*2, ElectrodeThick+LArgapo*2, xRange, roLayer, riLayer, BladeAngle, delZ);

Expand All @@ -289,12 +290,12 @@ namespace det {
LArgapi = LArgapo;
AbsThicki = AbsThicko;
}
lLog << MSG::INFO << "ECal endcap materials: nobleLiquid: " << nobleLiquidElem.materialStr() << " absorber: " << absBladeElem.materialStr() << " electrode: " << electrodeBladeElem.materialStr() << endmsg;
dd4hep::printout(dd4hep::INFO, "ECalEndcap_Turbine_o1_v01", "ECal endcap materials: nobleLiquid: %s absorber %s electrode %s", nobleLiquidElem.materialStr().c_str(), absBladeElem.materialStr().c_str(), electrodeBladeElem.materialStr().c_str() );

int nUnitCellsToDraw = nUnitCells;
// nUnitCellsToDraw = 2;

lLog << MSG::INFO << "Number of unit cells "<< nUnitCells << endmsg;
dd4hep::printout(dd4hep::INFO, "ECalEndcap_Turbine_o1_v01", "Number of unit cells %d", nUnitCells);

// place all components of the absorber blade inside passive volume

Expand All @@ -310,7 +311,7 @@ namespace det {
dd4hep::PlacedVolume absBladeVol_pv = glueLayerVols[iLayer].placeVolume(absBladeLayerVol, posLayer);

absBladeVol_pv.addPhysVolID("subtype", 0); // 0 = absorber, 1 = glue, 2 = cladding
lLog << MSG::DEBUG << "Blade layer, rho is " << iLayer << " " << absBladeVol_pv.position().Rho() << " " << roLayer/2. << endmsg;
dd4hep::printout( dd4hep::DEBUG, "ECalEndcap_Turbine_o1_v01_geo", "Blade layer, rho is %d, %f, %f", iLayer, absBladeVol_pv.position().Rho(), roLayer/2.);
absBladeVol_pv.addPhysVolID("layer", iWheel*numNonActiveLayers+iLayer);

riLayer = roLayer;
Expand Down Expand Up @@ -387,10 +388,9 @@ namespace det {
double zminLayer = getZmin(riLayer, BladeAngle, delZ);

dd4hep::Position posLayer(0,0,(zminLayer-zminri+roLayer-ro)/2.);
std::cout << "for active, riLayer, ri, roLayer, ro = " << riLayer << " " << ri << " " << roLayer << " " << ro << std::endl;

dd4hep::PlacedVolume LArVol_pv(activeVol.placeVolume(LArTotalLayerVol, posLayer));
lLog << MSG::DEBUG << "LAr layer: " << iLayer << endmsg;
dd4hep::printout(dd4hep::DEBUG, "ECalEndcap_Turbine_o1_v01", "LAr layer: %d", iLayer );
LArVol_pv.addPhysVolID("layer", iWheel*ECalEndcapNumCalibLayers+iLayer);

riLayer = roLayer;
Expand All @@ -404,7 +404,7 @@ namespace det {
float phi = (iUnitCell-nUnitCellsToDraw/2)*2*TMath::Pi()/nUnitCells;
float delPhi = 2*TMath::Pi()/nUnitCells;

lLog << MSG::DEBUG << "Placing blade, ro, ri = " << ro << " " << ri << endmsg;
dd4hep::printout( dd4hep::DEBUG, "ECalEndcap_Turbine_o1_v01", "Placing blade, ro, ri = %f %f", ro, ri);
TGeoRotation tgr;
tgr.RotateZ(BladeAngle*180/TMath::Pi());
tgr.RotateX(-phi*180/TMath::Pi());
Expand Down Expand Up @@ -466,7 +466,7 @@ namespace det {



lLog << MSG::DEBUG << "LArTotalLayerVols.size = " << LArTotalLayerVols.size() << endmsg;
dd4hep::printout(dd4hep::DEBUG, "ECalEndcap_Turbine_o1_v01", "LArTotalLayerVols.size = %d", LArTotalLayerVols.size());

}

Expand Down Expand Up @@ -510,17 +510,17 @@ namespace det {
dd4hep::Tube bathOuterShape(bathRmin, bathRmax, bathDelZ); // make it 4 volumes + 5th for detector envelope
dd4hep::Tube bathAndServicesOuterShape(cryoDim.rmin2(), cryoDim.rmax1(), caloDim.dz()); // make it 4 volumes + 5th for detector envelope

lLog << MSG::INFO << "Cryostat front thickness is " << cryoDim.rmin2() << endmsg;
dd4hep::printout( dd4hep::INFO, "ECalEndcap_Turbine_o1_v01", "Cryostat front thickness is %f", cryoDim.rmin2() );
if (cryoThicknessFront > 0) {
// 1. Create cryostat
dd4hep::Tube cryoFrontShape(cryoDim.rmin1(), cryoDim.rmin2(), cryoDim.dz());
dd4hep::Tube cryoBackShape(cryoDim.rmax1(), cryoDim.rmax2(), cryoDim.dz());
dd4hep::Tube cryoSideOuterShape(cryoDim.rmin2(), cryoDim.rmax1(), cryoDim.dz());
dd4hep::SubtractionSolid cryoSideShape(cryoSideOuterShape, bathAndServicesOuterShape);
lLog << MSG::INFO << "ECAL endcap cryostat: front: rmin (cm) = " << cryoDim.rmin1() << " rmax (cm) = " << cryoDim.rmin2() << " dz (cm) = " << cryoDim.dz() << endmsg;
lLog << MSG::INFO << "ECAL encdap cryostat: back: rmin (cm) = " << cryoDim.rmax1() << " rmax (cm) = " << cryoDim.rmax2() << " dz (cm) = " << cryoDim.dz() << endmsg;
lLog << MSG::INFO << "ECAL endcap cryostat: side: rmin (cm) = " << cryoDim.rmin2() << " rmax (cm) = " << cryoDim.rmax1() << " dz (cm) = " << cryoDim.dz() - caloDim.dz() << endmsg;
lLog << MSG::INFO << "Cryostat is made out of " << cryostat.materialStr() << endmsg;
dd4hep::printout(dd4hep::INFO, "ECalEndcap_Turbine_o1_v01", "ECAL endcap cryostat: front: rmin (cm) = %f rmax (cm) = %f dz (cm) = %f ", cryoDim.rmin1(), cryoDim.rmin2(), cryoDim.dz());
dd4hep::printout(dd4hep::INFO, "ECalEndcap_Turbine_o1_v01", "ECAL encdap cryostat: back: rmin (cm) = %f rmax (cm) = %f dz (cm) = %f", cryoDim.rmax1(), cryoDim.rmax2(), cryoDim.dz());
dd4hep::printout( dd4hep::INFO, "ECalEndcap_Turbine_o1_v01", "ECAL endcap cryostat: side: rmin (cm) = %f rmax (cm) = %f dz (cm) = %f", cryoDim.rmin2(), cryoDim.rmax1(), cryoDim.dz() - caloDim.dz());
dd4hep::printout( dd4hep::INFO, "ECalEndcap_Turbine_o1_v01", "Cryostat is made out of %s", cryostat.materialStr().c_str() );

dd4hep::Volume cryoFrontVol(cryostat.nameStr()+"_front", cryoFrontShape, aLcdd.material(cryostat.materialStr()));
dd4hep::Volume cryoBackVol(cryostat.nameStr()+"_back", cryoBackShape, aLcdd.material(cryostat.materialStr()));
Expand All @@ -533,19 +533,19 @@ namespace det {
cryoFrontVol.setSensitiveDetector(aSensDet);
cryoFrontPhysVol.addPhysVolID("cryo", 1);
cryoFrontPhysVol.addPhysVolID("type", sidetype+1);
lLog << MSG::INFO << "Cryostat front volume set as sensitive" << endmsg;
dd4hep::printout( dd4hep::INFO, "ECalEndcap_Turbine_o1_v01", "Cryostat front volume set as sensitive");
}
if (cryoBackSensitive) {
cryoBackVol.setSensitiveDetector(aSensDet);
cryoBackPhysVol.addPhysVolID("cryo", 1);
cryoBackPhysVol.addPhysVolID("type", sidetype+2);
lLog << MSG::INFO << "Cryostat back volume set as sensitive" << endmsg;
dd4hep::printout( dd4hep::INFO, "ECalEndcap_Turbine_o1_v01", "Cryostat back volume set as sensitive" );
}
if (cryoSideSensitive) {
cryoSideVol.setSensitiveDetector(aSensDet);
cryoSidePhysVol.addPhysVolID("cryo", 1);
cryoSidePhysVol.addPhysVolID("type", sidetype+3);
lLog << MSG::INFO << "Cryostat front volume set as sensitive" << endmsg;
dd4hep::printout( dd4hep::INFO, "ECalEndcap_Turbine_o1_v01", "Cryostat front volume set as sensitive");
}
dd4hep::DetElement cryoFrontDetElem(caloDetElem, "cryo_front", 0);
cryoFrontDetElem.setPlacement(cryoFrontPhysVol);
Expand All @@ -558,9 +558,7 @@ namespace det {
// 2. Create noble liquid bath
std::string nobleLiquidMaterial = nobleLiquid.materialStr();
dd4hep::Volume bathVol(nobleLiquidMaterial + "_bath", bathOuterShape, aLcdd.material(nobleLiquidMaterial));
lLog << MSG::INFO << "ECAL endcap bath: material = " << nobleLiquidMaterial << " rmin (cm) = " << bathRmin
<< " rmax (cm) = " << bathRmax << " dz (cm) = " << caloDim.dz() << " thickness in front of ECal (cm) = " << caloDim.rmin() - cryoDim.rmin2()
<< " thickness behind ECal (cm) = " << cryoDim.rmax1() - caloDim.rmax() << endmsg;
dd4hep::printout( dd4hep::INFO, "ECalEndcap_Turbine_o1_v01", "ECAL endcap bath: material = %s rmin (cm) = %f rmax (cm) = %f, dz (cm) = %f, thickness in front of ECal (cm) = %f, thickness behind ECal (cm) = %f", nobleLiquidMaterial.c_str(), bathRmin, bathRmax, caloDim.dz(), caloDim.rmin() - cryoDim.rmin2(), cryoDim.rmax1() - caloDim.rmax());
dd4hep::DetElement bathDetElem(caloDetElem, "bath", 1);

// 3. Create detector structure
Expand All @@ -569,7 +567,7 @@ namespace det {

dd4hep::xml::DetElement supportTubeElem = calo.child(_Unicode(supportTube));
unsigned nWheels = supportTubeElem.attr<unsigned>(_Unicode(nWheels));
lLog << MSG::INFO << "Will build " << nWheels << " wheels" << endmsg;
dd4hep::printout(dd4hep::INFO, "ECalEndcap_Turbine_o1_v01", "Will build %d wheels", nWheels);
double rmin = bathRmin;
double rmax = bathRmax;
float radiusRatio = pow(rmax/rmin, 1./nWheels);
Expand Down Expand Up @@ -604,7 +602,7 @@ namespace det {
dd4hep::PlacedVolume bathPhysVol = aEnvelope.placeVolume(bathVol);
bathDetElem.setPlacement(bathPhysVol);

lLog << MSG::DEBUG << "Total number of modules: " << iModule << endmsg;
dd4hep::printout(dd4hep::DEBUG, "ECalEndcap_Turbine_o1_v01", "Total number of modules: %d", iModule);

return;
}
Expand Down Expand Up @@ -634,11 +632,9 @@ createECalEndcapTurbine(dd4hep::Detector& aLcdd, dd4hep::xml::Handle_t aXmlEleme
// dd4hep::DetElement caloPositiveDetElem(caloDetElem, "positive", 0);
// dd4hep::DetElement caloNegativeDetElem(caloDetElem, "negative", 0);

lLog << MSG::DEBUG << "Placing dector on the positive side: (cm) " << dim.z_offset() << " with min, max radii " << dim.rmin1() << " " << dim.rmax1() << endmsg;
dd4hep::printout(dd4hep::DEBUG, "ECalEndcap_Turbine_o1_v01", "Placing detector on the positive side: (cm) %f with min, max radii %f %f",dim.z_offset(), dim.rmin1(), dim.rmax1() );
unsigned iModule = 0;
buildOneSide_Turbine(aLcdd, aSensDet, envelopeVol, aXmlElement, iModule);
// lLog << MSG::DEBUG << "Placing dector on the negative side: (cm) " << -dim.z_offset() << " with min, max radii " << dim.rmin1() << " " << dim.rmax() << endmsg;
// buildOneSide_Turbine(aLcdd, aSensDet, envelopeNegativeVol, aXmlElement, -1, iModule);

dd4hep::Assembly endcapsAssembly("ECalEndcaps_turbine");

Expand Down
Loading

0 comments on commit 942086c

Please sign in to comment.